UNPKG

dingtalk-docs-cool-app

Version:

钉钉文档酷应用插件扩展 开发者初始化包

1 lines 1.69 kB
import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _regeneratorRuntime from"@babel/runtime/regenerator";import{getWindowName,jointDingtalkDocsAddonSandboxCdnUrl,parseScriptServiceFrameName}from"./utils";import{loadScript}from"./loadScript";import{Exception}from"./types/error";var ScriptExecutor=function(){function r(){}return r.prototype.init=function(){var r=_asyncToGenerator(_regeneratorRuntime.mark((function r(e,t){var n,o,i,a,c;return _regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,n=getWindowName(e),o=parseScriptServiceFrameName(n),i=o.isPre,a=o.dingtalkDocsAddonVersion,"boolean"==typeof i&&"string"==typeof a){r.next=5;break}throw new Exception("invalid_operation","not running in the dingtalk-docs runtime.");case 5:return c=jointDingtalkDocsAddonSandboxCdnUrl(i,a),r.next=8,loadScript(c);case 8:if(e.__dingtalk_docs_addon_global){r.next=10;break}throw new Exception("internal_error");case 10:e.__dingtalk_docs_addon_global.initScript(t),r.next=17;break;case 13:r.prev=13,r.t0=r.catch(0),Promise.reject(r.t0),null==t||null==t.onError||t.onError(r.t0);case 17:case"end":return r.stop()}}),r,null,[[0,13]])})));return function(e,t){return r.apply(this,arguments)}}(),r}(),scriptExecutor=null;export var initScript=function(){var r=_asyncToGenerator(_regeneratorRuntime.mark((function r(e){return _regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!scriptExecutor){r.next=2;break}return r.abrupt("return");case 2:return scriptExecutor=new ScriptExecutor,r.next=5,scriptExecutor.init(window,e);case 5:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}();