UNPKG

dingtalk-docs-cool-app

Version:

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

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