@gaoding/editor-sdk
Advanced tools
Comparing version 2.0.0-alpha.0 to 2.0.0-alpha.1
@@ -1,2 +0,2 @@ | ||
(function(T,b){typeof exports=="object"&&typeof module!="undefined"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(T=typeof globalThis!="undefined"?globalThis:T||self,b(T.gaoding={}))})(this,function(T){"use strict";var b;(function(t){t.Call="call",t.Reply="reply",t.Syn="syn",t.SynAck="synAck",t.Ack="ack"})(b||(b={}));var _;(function(t){t.Fulfilled="fulfilled",t.Rejected="rejected"})(_||(_={}));var N;(function(t){t.ConnectionDestroyed="ConnectionDestroyed",t.ConnectionTimeout="ConnectionTimeout",t.NotInIframe="NotInIframe",t.NoIframeSrc="NoIframeSrc"})(N||(N={}));var V;(function(t){t.DataCloneError="DataCloneError"})(V||(V={}));var O;(function(t){t.Message="message"})(O||(O={}));var Fe=()=>{const t=[];let e=!1;return{destroy(r){e=!0,t.forEach(n=>{n(r)})},onDestroy(r){e?r():t.push(r)}}},Be=t=>(...e)=>{t&&console.log("[Penpal]",...e)};const ze={"http:":"80","https:":"443"},qe=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,Ke=["file:","data:"];var He=t=>{if(t&&Ke.find(u=>t.startsWith(u)))return"null";const e=document.location,r=qe.exec(t);let n,a,s;r?(n=r[1]?r[1]:e.protocol,a=r[2],s=r[4]):(n=e.protocol,a=e.hostname,s=e.port);const o=s&&s!==ze[n]?`:${s}`:"";return`${n}//${a}${o}`};const de=({name:t,message:e,stack:r})=>({name:t,message:e,stack:r}),Ve=t=>{const e=new Error;return Object.keys(t).forEach(r=>e[r]=t[r]),e};var Je=(t,e,r)=>{const{localName:n,local:a,remote:s,originForSending:o,originForReceiving:u}=t;let i=!1;const d=h=>{if(h.source!==s||h.data.penpal!==b.Call)return;if(h.origin!==u){r(`${n} received message from origin ${h.origin} which did not match expected origin ${u}`);return}const f=h.data,{methodName:l,args:c,id:y}=f;r(`${n}: Received ${l}() call`);const v=p=>m=>{if(r(`${n}: Sending ${l}() reply`),i){r(`${n}: Unable to send ${l}() reply due to destroyed connection`);return}const g={penpal:b.Reply,id:y,resolution:p,returnValue:m};p===_.Rejected&&m instanceof Error&&(g.returnValue=de(m),g.returnValueIsError=!0);try{s.postMessage(g,o)}catch(k){if(k.name===V.DataCloneError){const $={penpal:b.Reply,id:y,resolution:_.Rejected,returnValue:de(k),returnValueIsError:!0};s.postMessage($,o)}throw k}};new Promise(p=>p(e[l].apply(e,c))).then(v(_.Fulfilled),v(_.Rejected))};return a.addEventListener(O.Message,d),()=>{i=!0,a.removeEventListener(O.Message,d)}};let Ge=0;var We=()=>++Ge,Xe=(t,e,r,n,a)=>{const{localName:s,local:o,remote:u,originForSending:i,originForReceiving:d}=e;let h=!1;a(`${s}: Connecting call sender`);const f=l=>(...c)=>{a(`${s}: Sending ${l}() call`);let y;try{u.closed&&(y=!0)}catch{y=!0}if(y&&n(),h){const v=new Error(`Unable to send ${l}() call due to destroyed connection`);throw v.code=N.ConnectionDestroyed,v}return new Promise((v,p)=>{const m=We(),g=$=>{if($.source!==u||$.data.penpal!==b.Reply||$.data.id!==m)return;if($.origin!==d){a(`${s} received message from origin ${$.origin} which did not match expected origin ${d}`);return}const le=$.data;a(`${s}: Received ${l}() reply`),o.removeEventListener(O.Message,g);let ce=le.returnValue;le.returnValueIsError&&(ce=Ve(ce)),(le.resolution===_.Fulfilled?v:p)(ce)};o.addEventListener(O.Message,g);const k={penpal:b.Call,id:m,methodName:l,args:c};u.postMessage(k,i)})};return r.reduce((l,c)=>(l[c]=f(c),l),t),()=>{h=!0}},Ye=(t,e,r,n,a)=>{const{destroy:s,onDestroy:o}=n;let u,i;const d={};return h=>{if(h.origin!==e){a(`Parent: Handshake - Received ACK message from origin ${h.origin} which did not match expected origin ${e}`);return}a("Parent: Handshake - Received ACK");const f={localName:"Parent",local:window,remote:h.source,originForSending:r,originForReceiving:e};u&&u(),u=Je(f,t,a),o(u),i&&i.forEach(c=>{delete d[c]}),i=h.data.methodNames;const l=Xe(d,f,i,s,a);return o(l),d}},Ze=(t,e,r,n)=>a=>{if(a.origin!==r){t(`Parent: Handshake - Received SYN message from origin ${a.origin} which did not match expected origin ${r}`);return}t("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:b.SynAck,methodNames:Object.keys(e)};a.source.postMessage(s,n)};const Qe=6e4;var et=(t,e)=>{const{destroy:r,onDestroy:n}=e,a=setInterval(()=>{t.isConnected||(clearInterval(a),r())},Qe);n(()=>{clearInterval(a)})},tt=(t,e)=>{let r;return t!==void 0&&(r=window.setTimeout(()=>{const n=new Error(`Connection timed out after ${t}ms`);n.code=N.ConnectionTimeout,e(n)},t)),()=>{clearTimeout(r)}},rt=t=>{if(!t.src&&!t.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=N.NoIframeSrc,e}},nt=t=>{let{iframe:e,methods:r={},childOrigin:n,timeout:a,debug:s=!1}=t;const o=Be(s),u=Fe(),{onDestroy:i,destroy:d}=u;n||(rt(e),n=He(e.src));const h=n==="null"?"*":n,f=Ze(o,r,n,h),l=Ye(r,n,h,u,o);return{promise:new Promise((y,v)=>{const p=tt(a,d),m=g=>{if(!(g.source!==e.contentWindow||!g.data)){if(g.data.penpal===b.Syn){f(g);return}if(g.data.penpal===b.Ack){const k=l(g);k&&(p(),y(k));return}}};window.addEventListener(O.Message,m),o("Parent: Awaiting handshake"),et(e,u),i(g=>{window.removeEventListener(O.Message,m),g||(g=new Error("Connection destroyed"),g.code=N.ConnectionDestroyed),v(g)})}),destroy(){d()}}};const S={TEMPLATE_EDITOR_URL:"https://open.gaoding.com/design",KOUTU_EDITOR_URL:"https://open.gaoding.com/clip",IMAGE_EDITOR_URL:"https://open.gaoding.com/design/image",OPEN_PLATFORM_ORIGIN:"https://open.gaoding.com",get VERSION(){return"2.0.0-alpha.0"}};var J=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(d){a(d)}},o=i=>{try{u(r.throw(i))}catch(d){a(d)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function fe(t,e){const r=document.createElement("div");r.style.cssText=` | ||
(function(T,b){typeof exports=="object"&&typeof module!="undefined"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(T=typeof globalThis!="undefined"?globalThis:T||self,b(T.gaoding={}))})(this,function(T){"use strict";var b;(function(t){t.Call="call",t.Reply="reply",t.Syn="syn",t.SynAck="synAck",t.Ack="ack"})(b||(b={}));var _;(function(t){t.Fulfilled="fulfilled",t.Rejected="rejected"})(_||(_={}));var U;(function(t){t.ConnectionDestroyed="ConnectionDestroyed",t.ConnectionTimeout="ConnectionTimeout",t.NotInIframe="NotInIframe",t.NoIframeSrc="NoIframeSrc"})(U||(U={}));var J;(function(t){t.DataCloneError="DataCloneError"})(J||(J={}));var O;(function(t){t.Message="message"})(O||(O={}));var Fe=()=>{const t=[];let e=!1;return{destroy(r){e=!0,t.forEach(n=>{n(r)})},onDestroy(r){e?r():t.push(r)}}},je=t=>(...e)=>{t&&console.log("[Penpal]",...e)};const ze={"http:":"80","https:":"443"},qe=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,Ke=["file:","data:"];var He=t=>{if(t&&Ke.find(u=>t.startsWith(u)))return"null";const e=document.location,r=qe.exec(t);let n,a,s;r?(n=r[1]?r[1]:e.protocol,a=r[2],s=r[4]):(n=e.protocol,a=e.hostname,s=e.port);const o=s&&s!==ze[n]?`:${s}`:"";return`${n}//${a}${o}`};const fe=({name:t,message:e,stack:r})=>({name:t,message:e,stack:r}),Ve=t=>{const e=new Error;return Object.keys(t).forEach(r=>e[r]=t[r]),e};var Je=(t,e,r)=>{const{localName:n,local:a,remote:s,originForSending:o,originForReceiving:u}=t;let i=!1;const f=m=>{if(m.source!==s||m.data.penpal!==b.Call)return;if(m.origin!==u){r(`${n} received message from origin ${m.origin} which did not match expected origin ${u}`);return}const h=m.data,{methodName:l,args:c,id:y}=h;r(`${n}: Received ${l}() call`);const v=d=>p=>{if(r(`${n}: Sending ${l}() reply`),i){r(`${n}: Unable to send ${l}() reply due to destroyed connection`);return}const g={penpal:b.Reply,id:y,resolution:d,returnValue:p};d===_.Rejected&&p instanceof Error&&(g.returnValue=fe(p),g.returnValueIsError=!0);try{s.postMessage(g,o)}catch(A){if(A.name===J.DataCloneError){const $={penpal:b.Reply,id:y,resolution:_.Rejected,returnValue:fe(A),returnValueIsError:!0};s.postMessage($,o)}throw A}};new Promise(d=>d(e[l].apply(e,c))).then(v(_.Fulfilled),v(_.Rejected))};return a.addEventListener(O.Message,f),()=>{i=!0,a.removeEventListener(O.Message,f)}};let Ge=0;var We=()=>++Ge,Xe=(t,e,r,n,a)=>{const{localName:s,local:o,remote:u,originForSending:i,originForReceiving:f}=e;let m=!1;a(`${s}: Connecting call sender`);const h=l=>(...c)=>{a(`${s}: Sending ${l}() call`);let y;try{u.closed&&(y=!0)}catch{y=!0}if(y&&n(),m){const v=new Error(`Unable to send ${l}() call due to destroyed connection`);throw v.code=U.ConnectionDestroyed,v}return new Promise((v,d)=>{const p=We(),g=$=>{if($.source!==u||$.data.penpal!==b.Reply||$.data.id!==p)return;if($.origin!==f){a(`${s} received message from origin ${$.origin} which did not match expected origin ${f}`);return}const ce=$.data;a(`${s}: Received ${l}() reply`),o.removeEventListener(O.Message,g);let de=ce.returnValue;ce.returnValueIsError&&(de=Ve(de)),(ce.resolution===_.Fulfilled?v:d)(de)};o.addEventListener(O.Message,g);const A={penpal:b.Call,id:p,methodName:l,args:c};u.postMessage(A,i)})};return r.reduce((l,c)=>(l[c]=h(c),l),t),()=>{m=!0}},Ye=(t,e,r,n,a)=>{const{destroy:s,onDestroy:o}=n;let u,i;const f={};return m=>{if(m.origin!==e){a(`Parent: Handshake - Received ACK message from origin ${m.origin} which did not match expected origin ${e}`);return}a("Parent: Handshake - Received ACK");const h={localName:"Parent",local:window,remote:m.source,originForSending:r,originForReceiving:e};u&&u(),u=Je(h,t,a),o(u),i&&i.forEach(c=>{delete f[c]}),i=m.data.methodNames;const l=Xe(f,h,i,s,a);return o(l),f}},Ze=(t,e,r,n)=>a=>{if(a.origin!==r){t(`Parent: Handshake - Received SYN message from origin ${a.origin} which did not match expected origin ${r}`);return}t("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:b.SynAck,methodNames:Object.keys(e)};a.source.postMessage(s,n)};const Qe=6e4;var et=(t,e)=>{const{destroy:r,onDestroy:n}=e,a=setInterval(()=>{t.isConnected||(clearInterval(a),r())},Qe);n(()=>{clearInterval(a)})},tt=(t,e)=>{let r;return t!==void 0&&(r=window.setTimeout(()=>{const n=new Error(`Connection timed out after ${t}ms`);n.code=U.ConnectionTimeout,e(n)},t)),()=>{clearTimeout(r)}},rt=t=>{if(!t.src&&!t.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=U.NoIframeSrc,e}},nt=t=>{let{iframe:e,methods:r={},childOrigin:n,timeout:a,debug:s=!1}=t;const o=je(s),u=Fe(),{onDestroy:i,destroy:f}=u;n||(rt(e),n=He(e.src));const m=n==="null"?"*":n,h=Ze(o,r,n,m),l=Ye(r,n,m,u,o);return{promise:new Promise((y,v)=>{const d=tt(a,f),p=g=>{if(!(g.source!==e.contentWindow||!g.data)){if(g.data.penpal===b.Syn){h(g);return}if(g.data.penpal===b.Ack){const A=l(g);A&&(d(),y(A));return}}};window.addEventListener(O.Message,p),o("Parent: Awaiting handshake"),et(e,u),i(g=>{window.removeEventListener(O.Message,p),g||(g=new Error("Connection destroyed"),g.code=U.ConnectionDestroyed),v(g)})}),destroy(){f()}}};const S={TEMPLATE_EDITOR_URL:"https://open.gaoding.com/design",KOUTU_EDITOR_URL:"https://open.gaoding.com/clip",IMAGE_EDITOR_URL:"https://open.gaoding.com/design/image",OPEN_PLATFORM_ORIGIN:"https://open.gaoding.com",get VERSION(){return"2.0.0-alpha.1"}};var G=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(f){a(f)}},o=i=>{try{u(r.throw(i))}catch(f){a(f)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function he(t,e){const r=document.createElement("div");r.style.cssText=` | ||
position: relative; | ||
@@ -36,8 +36,8 @@ width: calc(100vw - 100px); | ||
opacity: 0.5; | ||
`;let u=!1,i="";function d(){!document.querySelector(".gaoding-editor-iframe-dialog")||(u?(i=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden"):document.documentElement.style.overflow=i)}function h(){return J(this,null,function*(){var l,c;e&&(yield e())===!1||(u=!1,d(),(l=o.parentElement)==null||l.removeChild(o),(c=s.parentElement)==null||c.removeChild(s))})}function f(){u=!0,document.body.appendChild(o),document.body.appendChild(s),d()}return n.addEventListener("click",h),{open:f,close:h}}function G(t){const e=document.createElement("iframe");e.style.cssText=` | ||
`;let u=!1,i="";function f(){!document.querySelector(".gaoding-editor-iframe-dialog")||(u?(i=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden"):document.documentElement.style.overflow=i)}function m(){return G(this,null,function*(){var l,c;e&&(yield e())===!1||(u=!1,f(),(l=o.parentElement)==null||l.removeChild(o),(c=s.parentElement)==null||c.removeChild(s))})}function h(){u=!0,document.body.appendChild(o),document.body.appendChild(s),f()}return n.addEventListener("click",m),{open:h,close:m}}function W(t){const e=document.createElement("iframe");e.style.cssText=` | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
`,e.referrerPolicy="strict-origin-when-cross-origin",e.className="gaoding-iframe",e.setAttribute("frameborder","0");let r=null,n="";function a(h,f){return J(this,null,function*(){const l=Object.assign({},f,{app_id:t.appId,v:S.VERSION}),c=`${h}?${Object.entries(l).filter(([y,v])=>v!==void 0).map(([y,v])=>`${y}=${v}`).join("&")}`;if(n!==c){if(n=c,!f){e.src=h;return}r&&r.destroy(),e.src=c,r=nt({iframe:e,debug:!0,methods:t.methods})}})}let s=null;t.container||(s=fe(e,t.onClose));let o=!1;function u(){if(o)return;if(o=!0,s){s.open();return}const h=typeof t.container=="string"?document.body.querySelector(t.container):t.container;if(!h)throw new Error(`\u65E0\u6548\u7684 container ${t.container}`);h.appendChild(e)}function i(){if(!!o){if(o=!1,s==null?void 0:s.close)return s.close();e.parentElement&&e.parentElement.removeChild(e)}}function d(h){s=fe(e,t.onClose),t.container=h}return{remove:i,insert:u,update:a,iframe:e,restetContainer:d,getService(){return J(this,null,function*(){return r.promise})}}}var at=Object.defineProperty,it=(t,e,r)=>e in t?at(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,st=(t,e,r)=>(it(t,typeof e!="symbol"?e+"":e,r),r),pe=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(d){a(d)}},o=i=>{try{u(r.throw(i))}catch(d){a(d)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});class W{constructor(){st(this,"events"),this.events={}}add(e,r){if(!r)return()=>{};const n=this.get(e);return n.push(r),this.events[e]=n,()=>this.off(e,r)}on(e,r){return this.add(e,r)}once(e,r){const n=this.add(e,(...a)=>{n(),r(...a)});return n}off(e,r){const n=this.get(e);if(n){const a=n.findIndex(s=>s===r);n.splice(a,1)}}get(e){return this.events[e]||[]}invoke(e,...r){for(const n of this.get(e))n(...r)}emit(e,...r){this.invoke(e,...r)}asyncInvoke(e,...r){return pe(this,null,function*(){for(const n of this.get(e))yield n(...r)})}asyncInvokeAll(e,...r){return pe(this,null,function*(){yield Promise.all(this.get(e).map(n=>n(...r)))})}}var R=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(d){a(d)}},o=i=>{try{u(r.throw(i))}catch(d){a(d)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function ot(t){const e=new W,r=null;let n=!1;const a=[];function s(){a.forEach(p=>p()),a.length=0}const o=G({appId:t.appId,container:t.container,onClose(){return R(this,null,function*(){if(t.onCloseModal&&(yield t.onCloseModal())===!1)return!1;e.emit("close")})},methods:{emit(p,...m){return R(this,null,function*(){e.emit(p,...m)})},onload(){return R(this,null,function*(){e.emit("load")})},onSelectTemplate(p){return R(this,null,function*(){return e.emit("select.template",p),!1})},onTemplateLoad(){return R(this,null,function*(){e.emit("template.load")})},getUseRightToken(p){return R(this,null,function*(){if(!t.getUseRightCert)return!1;const m=yield t.getUseRightCert(p);return m instanceof Error?{message:m.message}:m})},getUserCode(){return R(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{f()}})}}});function u(){return R(this,null,function*(){const p=yield o.getService();return{addImage(m,g){p.addImage(m,g)}}})}function i(p={}){return s(),n=!1,o.update(S.TEMPLATE_EDITOR_URL,{id:p.id,version:t.authorize?"TE002":"TE001"}),e.once("load",()=>R(this,null,function*(){n=!0;const m=yield o.getService();u(),yield m.init({appId:t.appId,version:t.authorize?"TE002":"TE001",fileTypes:p.fileTypes,disableModules:p.disableModules,filterPaidMaterial:p.filterPaidMaterial,categoryId:p.categoryId}),e.emit("editor.load")})),o.insert(),new Promise(m=>{a.push(e.once("save",g=>m(g))),a.push(e.once("close",()=>m(!1)))})}function d(p){return s(),n=!1,o.update(S.TEMPLATE_EDITOR_URL,{id:p.id,mode:"user",version:t.authorize?"TE002":"TE001"}),e.once("load",()=>R(this,null,function*(){n=!0;const m=yield o.getService();u(),yield m.init({appId:t.appId,version:t.authorize?"TE002":"TE001",disableModules:p.disableModules,filterPaidMaterial:p.filterPaidMaterial,fileTypes:p.fileTypes}),e.emit("editor.load")})),o.insert(),new Promise(m=>{a.push(e.once("save",g=>m(g))),a.push(e.once("close",()=>m(!1)))})}function h(p){return n=!1,s(),o.update(S.OPEN_PLATFORM_ORIGIN+"/template/search",{app_id:t.appId,version:t.authorize?"TE002":"TE001"}),e.once("load",()=>R(this,null,function*(){n=!0,(yield o.getService()).init({appId:t.appId,version:t.authorize?"TE002":"TE001",categories:p.categories})})),p.onSelectTemplate&&a.push(e.add("select.template",p.onSelectTemplate)),o.insert(),new Promise(m=>{a.push(e.once("select.template",g=>m(g))),a.push(e.once("close",()=>m(!1)))})}function f(){e.emit("close"),o.remove()}function l(p){e.add("save",p)}function c(p){e.add("close",p)}function y(p){e.add("editor.load",p)}function v(p){e.add("template.load",p)}return{get canva(){return r},get isLoad(){return n},openTemplateList:h,close:f,onSave:l,onTempalteLoad:v,onClose:c,onLoad:y,editTemplate:d,createTemplate:i}}var ut=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(d){a(d)}},o=i=>{try{u(r.throw(i))}catch(d){a(d)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function he(t){return ut(this,null,function*(){const e=t instanceof File?t.name:`${t.type}`;return new File([yield t.arrayBuffer()],e,{type:t.type})})}function me(t,e){if(!t)throw new Error(e)}var X={exports:{}},ve=function(e,r){return function(){for(var a=new Array(arguments.length),s=0;s<a.length;s++)a[s]=arguments[s];return e.apply(r,a)}},lt=ve,A=Object.prototype.toString;function Y(t){return A.call(t)==="[object Array]"}function Z(t){return typeof t=="undefined"}function ct(t){return t!==null&&!Z(t)&&t.constructor!==null&&!Z(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function dt(t){return A.call(t)==="[object ArrayBuffer]"}function ft(t){return typeof FormData!="undefined"&&t instanceof FormData}function pt(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function ht(t){return typeof t=="string"}function mt(t){return typeof t=="number"}function ye(t){return t!==null&&typeof t=="object"}function D(t){if(A.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function vt(t){return A.call(t)==="[object Date]"}function yt(t){return A.call(t)==="[object File]"}function gt(t){return A.call(t)==="[object Blob]"}function ge(t){return A.call(t)==="[object Function]"}function Et(t){return ye(t)&&ge(t.pipe)}function wt(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function bt(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Ct(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Q(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Y(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.call(null,t[a],a,t)}function ee(){var t={};function e(a,s){D(t[s])&&D(a)?t[s]=ee(t[s],a):D(a)?t[s]=ee({},a):Y(a)?t[s]=a.slice():t[s]=a}for(var r=0,n=arguments.length;r<n;r++)Q(arguments[r],e);return t}function Rt(t,e,r){return Q(e,function(a,s){r&&typeof a=="function"?t[s]=lt(a,r):t[s]=a}),t}function xt(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var C={isArray:Y,isArrayBuffer:dt,isBuffer:ct,isFormData:ft,isArrayBufferView:pt,isString:ht,isNumber:mt,isObject:ye,isPlainObject:D,isUndefined:Z,isDate:vt,isFile:yt,isBlob:gt,isFunction:ge,isStream:Et,isURLSearchParams:wt,isStandardBrowserEnv:Ct,forEach:Q,merge:ee,extend:Rt,trim:bt,stripBOM:xt},U=C;function Ee(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var we=function(e,r,n){if(!r)return e;var a;if(n)a=n(r);else if(U.isURLSearchParams(r))a=r.toString();else{var s=[];U.forEach(r,function(i,d){i===null||typeof i=="undefined"||(U.isArray(i)?d=d+"[]":i=[i],U.forEach(i,function(f){U.isDate(f)?f=f.toISOString():U.isObject(f)&&(f=JSON.stringify(f)),s.push(Ee(d)+"="+Ee(f))}))}),a=s.join("&")}if(a){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e},Tt=C;function j(){this.handlers=[]}j.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1},j.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},j.prototype.forEach=function(e){Tt.forEach(this.handlers,function(n){n!==null&&e(n)})};var St=j,It=C,Pt=function(e,r){It.forEach(e,function(a,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=a,delete e[s])})},be=function(e,r,n,a,s){return e.config=r,n&&(e.code=n),e.request=a,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},Ot=be,Ce=function(e,r,n,a,s){var o=new Error(e);return Ot(o,r,n,a,s)},kt=Ce,$t=function(e,r,n){var a=n.config.validateStatus;!n.status||!a||a(n.status)?e(n):r(kt("Request failed with status code "+n.status,n.config,null,n.request,n))},F=C,_t=F.isStandardBrowserEnv()?function(){return{write:function(r,n,a,s,o,u){var i=[];i.push(r+"="+encodeURIComponent(n)),F.isNumber(a)&&i.push("expires="+new Date(a).toGMTString()),F.isString(s)&&i.push("path="+s),F.isString(o)&&i.push("domain="+o),u===!0&&i.push("secure"),document.cookie=i.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),At=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Nt=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},Ut=At,Mt=Nt,Lt=function(e,r){return e&&!Ut(r)?Mt(e,r):r},te=C,Dt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],jt=function(e){var r={},n,a,s;return e&&te.forEach(e.split(` | ||
`),function(u){if(s=u.indexOf(":"),n=te.trim(u.substr(0,s)).toLowerCase(),a=te.trim(u.substr(s+1)),n){if(r[n]&&Dt.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([a]):r[n]=r[n]?r[n]+", "+a:a}}),r},Re=C,Ft=Re.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function a(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=a(window.location.href),function(o){var u=Re.isString(o)?a(o):o;return u.protocol===n.protocol&&u.host===n.host}}():function(){return function(){return!0}}(),B=C,Bt=$t,zt=_t,qt=we,Kt=Lt,Ht=jt,Vt=Ft,re=Ce,xe=function(e){return new Promise(function(n,a){var s=e.data,o=e.headers,u=e.responseType;B.isFormData(s)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(d+":"+h)}var f=Kt(e.baseURL,e.url);i.open(e.method.toUpperCase(),qt(f,e.params,e.paramsSerializer),!0),i.timeout=e.timeout;function l(){if(!!i){var y="getAllResponseHeaders"in i?Ht(i.getAllResponseHeaders()):null,v=!u||u==="text"||u==="json"?i.responseText:i.response,p={data:v,status:i.status,statusText:i.statusText,headers:y,config:e,request:i};Bt(n,a,p),i=null}}if("onloadend"in i?i.onloadend=l:i.onreadystatechange=function(){!i||i.readyState!==4||i.status===0&&!(i.responseURL&&i.responseURL.indexOf("file:")===0)||setTimeout(l)},i.onabort=function(){!i||(a(re("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){a(re("Network Error",e,null,i)),i=null},i.ontimeout=function(){var v="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(v=e.timeoutErrorMessage),a(re(v,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",i)),i=null},B.isStandardBrowserEnv()){var c=(e.withCredentials||Vt(f))&&e.xsrfCookieName?zt.read(e.xsrfCookieName):void 0;c&&(o[e.xsrfHeaderName]=c)}"setRequestHeader"in i&&B.forEach(o,function(v,p){typeof s=="undefined"&&p.toLowerCase()==="content-type"?delete o[p]:i.setRequestHeader(p,v)}),B.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),u&&u!=="json"&&(i.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&i.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(v){!i||(i.abort(),a(v),i=null)}),s||(s=null),i.send(s)})},E=C,Te=Pt,Jt=be,Gt={"Content-Type":"application/x-www-form-urlencoded"};function Se(t,e){!E.isUndefined(t)&&E.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Wt(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=xe),t}function Xt(t,e,r){if(E.isString(t))try{return(e||JSON.parse)(t),E.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var z={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Wt(),transformRequest:[function(e,r){return Te(r,"Accept"),Te(r,"Content-Type"),E.isFormData(e)||E.isArrayBuffer(e)||E.isBuffer(e)||E.isStream(e)||E.isFile(e)||E.isBlob(e)?e:E.isArrayBufferView(e)?e.buffer:E.isURLSearchParams(e)?(Se(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):E.isObject(e)||r&&r["Content-Type"]==="application/json"?(Se(r,"application/json"),Xt(e)):e}],transformResponse:[function(e){var r=this.transitional,n=r&&r.silentJSONParsing,a=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||a&&E.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?Jt(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};z.headers={common:{Accept:"application/json, text/plain, */*"}},E.forEach(["delete","get","head"],function(e){z.headers[e]={}}),E.forEach(["post","put","patch"],function(e){z.headers[e]=E.merge(Gt)});var ne=z,Yt=C,Zt=ne,Qt=function(e,r,n){var a=this||Zt;return Yt.forEach(n,function(o){e=o.call(a,e,r)}),e},Ie=function(e){return!!(e&&e.__CANCEL__)},Pe=C,ae=Qt,er=Ie,tr=ne;function ie(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var rr=function(e){ie(e),e.headers=e.headers||{},e.data=ae.call(e,e.data,e.headers,e.transformRequest),e.headers=Pe.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Pe.forEach(["delete","get","head","post","put","patch","common"],function(a){delete e.headers[a]});var r=e.adapter||tr.adapter;return r(e).then(function(a){return ie(e),a.data=ae.call(e,a.data,a.headers,e.transformResponse),a},function(a){return er(a)||(ie(e),a&&a.response&&(a.response.data=ae.call(e,a.response.data,a.response.headers,e.transformResponse))),Promise.reject(a)})},w=C,Oe=function(e,r){r=r||{};var n={},a=["url","method","data"],s=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],u=["validateStatus"];function i(l,c){return w.isPlainObject(l)&&w.isPlainObject(c)?w.merge(l,c):w.isPlainObject(c)?w.merge({},c):w.isArray(c)?c.slice():c}function d(l){w.isUndefined(r[l])?w.isUndefined(e[l])||(n[l]=i(void 0,e[l])):n[l]=i(e[l],r[l])}w.forEach(a,function(c){w.isUndefined(r[c])||(n[c]=i(void 0,r[c]))}),w.forEach(s,d),w.forEach(o,function(c){w.isUndefined(r[c])?w.isUndefined(e[c])||(n[c]=i(void 0,e[c])):n[c]=i(void 0,r[c])}),w.forEach(u,function(c){c in r?n[c]=i(e[c],r[c]):c in e&&(n[c]=i(void 0,e[c]))});var h=a.concat(s).concat(o).concat(u),f=Object.keys(e).concat(Object.keys(r)).filter(function(c){return h.indexOf(c)===-1});return w.forEach(f,d),n},nr={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]},ke=nr,se={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){se[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var $e={},ar=ke.version.split(".");function _e(t,e){for(var r=e?e.split("."):ar,n=t.split("."),a=0;a<3;a++){if(r[a]>n[a])return!0;if(r[a]<n[a])return!1}return!1}se.transitional=function(e,r,n){var a=r&&_e(r);function s(o,u){return"[Axios v"+ke.version+"] Transitional option '"+o+"'"+u+(n?". "+n:"")}return function(o,u,i){if(e===!1)throw new Error(s(u," has been removed in "+r));return a&&!$e[u]&&($e[u]=!0,console.warn(s(u," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(o,u,i):!0}};function ir(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),a=n.length;a-- >0;){var s=n[a],o=e[s];if(o){var u=t[s],i=u===void 0||o(u,s,t);if(i!==!0)throw new TypeError("option "+s+" must be "+i);continue}if(r!==!0)throw Error("Unknown option "+s)}}var sr={isOlderVersion:_e,assertOptions:ir,validators:se},Ae=C,or=we,Ne=St,Ue=rr,q=Oe,Me=sr,M=Me.validators;function L(t){this.defaults=t,this.interceptors={request:new Ne,response:new Ne}}L.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=q(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&Me.assertOptions(r,{silentJSONParsing:M.transitional(M.boolean,"1.0.0"),forcedJSONParsing:M.transitional(M.boolean,"1.0.0"),clarifyTimeoutError:M.transitional(M.boolean,"1.0.0")},!1);var n=[],a=!0;this.interceptors.request.forEach(function(l){typeof l.runWhen=="function"&&l.runWhen(e)===!1||(a=a&&l.synchronous,n.unshift(l.fulfilled,l.rejected))});var s=[];this.interceptors.response.forEach(function(l){s.push(l.fulfilled,l.rejected)});var o;if(!a){var u=[Ue,void 0];for(Array.prototype.unshift.apply(u,n),u=u.concat(s),o=Promise.resolve(e);u.length;)o=o.then(u.shift(),u.shift());return o}for(var i=e;n.length;){var d=n.shift(),h=n.shift();try{i=d(i)}catch(f){h(f);break}}try{o=Ue(i)}catch(f){return Promise.reject(f)}for(;s.length;)o=o.then(s.shift(),s.shift());return o},L.prototype.getUri=function(e){return e=q(this.defaults,e),or(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},Ae.forEach(["delete","get","head","options"],function(e){L.prototype[e]=function(r,n){return this.request(q(n||{},{method:e,url:r,data:(n||{}).data}))}}),Ae.forEach(["post","put","patch"],function(e){L.prototype[e]=function(r,n,a){return this.request(q(a||{},{method:e,url:r,data:n}))}});var ur=L;function oe(t){this.message=t}oe.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},oe.prototype.__CANCEL__=!0;var Le=oe,lr=Le;function K(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(a){e=a});var r=this;t(function(a){r.reason||(r.reason=new lr(a),e(r.reason))})}K.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},K.source=function(){var e,r=new K(function(a){e=a});return{token:r,cancel:e}};var cr=K,dr=function(e){return function(n){return e.apply(null,n)}},fr=function(e){return typeof e=="object"&&e.isAxiosError===!0},De=C,pr=ve,H=ur,hr=Oe,mr=ne;function je(t){var e=new H(t),r=pr(H.prototype.request,e);return De.extend(r,H.prototype,e),De.extend(r,e),r}var x=je(mr);x.Axios=H,x.create=function(e){return je(hr(x.defaults,e))},x.Cancel=Le,x.CancelToken=cr,x.isCancel=Ie,x.all=function(e){return Promise.all(e)},x.spread=dr,x.isAxiosError=fr,X.exports=x,X.exports.default=x;var vr=X.exports,yr=Object.defineProperty,gr=(t,e,r)=>e in t?yr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Er=(t,e,r)=>(gr(t,typeof e!="symbol"?e+"":e,r),r),ue=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(d){a(d)}},o=i=>{try{u(r.throw(i))}catch(d){a(d)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});class wr{constructor(){Er(this,"axios"),this.axios=vr.create({baseURL:S.OPEN_PLATFORM_ORIGIN})}createKoutuRecord(e){return ue(this,null,function*(){const r=e.url,n=yield this.axios.get(r,{responseType:"arraybuffer"}).then(u=>u.data),{width:a,height:s}=yield new Promise(u=>{const i=document.createElement("img");i.src=r,i.onload=()=>{u({width:i.width,height:i.height})}});return(yield this.axios.post("/sdk/api/koutu-records",{url:r,size:n.byteLength,width:a,height:s},{headers:{authorization:`Bearer ${e.token}`}})).data.work_id})}koutu(e){return ue(this,null,function*(){return(yield this.axios.post("/sdk/api/koutus",{app_id:e.appId,url:e.url,ability_code:e.abilityCode,work_id:e.workId,use_cert:e.useCert},{headers:{authorization:`Bearer ${e.token}`}})).data.result})}createAuth(e){return ue(this,null,function*(){return(yield this.axios.post("/sdk/api/auths",{code:e})).data.access_token})}}var I=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(d){a(d)}},o=i=>{try{u(r.throw(i))}catch(d){a(d)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function br(t){const e=new W,r=G({appId:t.appId,container:t.container,methods:{emit(f,...l){return I(this,null,function*(){e.emit(f,...l)})},onload(){e.emit("load")},getUseRightToken(f){return I(this,null,function*(){if(!t.getUseRightCert)return!1;const l=yield t.getUseRightCert(f);return l instanceof Error?{message:l.message}:l})},getUserCode(){return I(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{h()}})},download(f){return I(this,null,function*(){e.emit("save",f)})}}}),n=[];function a(){n.forEach(f=>f()),n.length=0}function s(f){return I(this,null,function*(){a(),r.update(S.KOUTU_EDITOR_URL,{version:t.authorize?"KE002":"KE001"}),r.insert(),e.once("load",()=>I(this,null,function*(){(yield r.getService()).init({appId:t.appId,version:t.authorize?"KE002":"KE001"})}));const l=typeof f=="string"?f:he(f);return(yield r.getService()).importFile(l),new Promise(y=>{n.push(e.once("save",v=>y(v))),n.push(e.once("close",()=>y(!1)))})})}function o(f){return I(this,null,function*(){return me(Number.isInteger(+f),`\u65E0\u6548\u7684ID ${f}`),a(),r.update(S.KOUTU_EDITOR_URL,{id:f,mode:"user",version:t.authorize?"KE002":"KE001"}),e.once("load",()=>I(this,null,function*(){(yield r.getService()).init({appId:t.appId,version:t.authorize?"KE002":"KE001"})})),new Promise(l=>{n.push(e.once("save",c=>l(c))),n.push(e.once("close",()=>l(!1)))})})}function u(f){return I(this,null,function*(){if(me(typeof f=="string","url \u5FC5\u987B\u662F url \u683C\u5F0F"),!t.authorize||!t.getUseRightCert)throw new Error("\u8D8B\u52BF");const l=new wr,c=yield t.authorize(),y=yield l.createAuth(c),v=yield l.createKoutuRecord({token:y,url:f}),p=yield t.getUseRightCert({abilityCode:"KE002",appId:t.appId,workId:v});if(p){if(p instanceof Error)throw p}else throw new Error("\u6CA1\u6709\u6743\u9650");return{result:yield l.koutu({url:f,appId:t.appId,workId:v,abilityCode:"KE002",useCert:p,token:y}),workId:v}})}function i(f){e.add("save",f)}function d(f){e.add("close",f)}function h(){e.emit("close"),r.remove()}return{onSave:i,onClose:d,close:h,koutu:u,editKoutu:o,importImage:s}}var P=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(d){a(d)}},o=i=>{try{u(r.throw(i))}catch(d){a(d)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function Cr(t){const e=new W,r=[];function n(){r.forEach(l=>l()),r.length=0}const a=G({container:t.container,appId:t.appId,methods:{emit(l,...c){return P(this,null,function*(){e.emit(l,...c)})},onload(){e.emit("load")},getUseRightToken(l){return P(this,null,function*(){if(!t.getUseRightCert)return!1;const c=yield t.getUseRightCert(l);return c instanceof Error?{message:c.message}:c})},getUserCode(){return P(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{d()}})},download(l){return P(this,null,function*(){e.emit("save",l)})}}});function s(l,c){e.on(l,c)}function o(l,c){e.off(l,c)}function u(l){return P(this,arguments,function*(c,y={}){n(),a.update(S.IMAGE_EDITOR_URL,{version:t.authorize?"IE002":"IE001"}),a.insert(),e.once("load",()=>P(this,null,function*(){(yield a.getService()).init({appId:t.appId,version:t.authorize?"IE002":"IE001",fileTypes:y.fileTypes,disableModules:y.disableModules})}));const v=yield a.getService(),p=yield Promise.all((Array.isArray(c)?c:[c]).map(m=>P(this,null,function*(){return typeof m=="string"?m:yield he(m)})));return v.importFile(p),new Promise(m=>{r.push(e.once("save",g=>m(g))),r.push(e.once("close",()=>m(!1)))})})}function i(l){return P(this,arguments,function*(c,y={}){return n(),a.update(S.IMAGE_EDITOR_URL,{id:c,mode:"user",version:t.authorize?"IE002":"IE001"}),a.insert(),e.once("load",()=>P(this,null,function*(){(yield a.getService()).init({appId:t.appId,version:"TE001",fileTypes:y.fileTypes,disableModules:y.disableModules})})),new Promise(v=>{r.push(e.once("save",p=>v(p))),r.push(e.once("close",()=>v(!1)))})})}function d(){e.emit("close"),a.remove()}function h(l){e.add("save",l)}function f(l){e.add("close",l)}return{editImage:i,close:d,onSave:h,onClose:f,importImage:u,on:s,off:o}}T.createImageEditor=Cr,T.createKoutuEditor=br,T.createTemplateEditor=ot,T.env=S,Object.defineProperty(T,"__esModule",{value:!0}),T[Symbol.toStringTag]="Module"}); | ||
`,e.referrerPolicy="strict-origin-when-cross-origin",e.className="gaoding-iframe",e.setAttribute("frameborder","0");let r=null,n="";function a(m,h){return G(this,null,function*(){const l=Object.assign({},h,{app_id:t.appId,v:S.VERSION}),c=`${m}?${Object.entries(l).filter(([y,v])=>v!==void 0).map(([y,v])=>`${y}=${v}`).join("&")}`;if(n!==c){if(n=c,!h){e.src=m;return}r&&r.destroy(),e.src=c,r=nt({iframe:e,methods:t.methods})}})}let s=null;t.container||(s=he(e,t.onClose));let o=!1;function u(){if(o)return;if(o=!0,s){s.open();return}const m=typeof t.container=="string"?document.body.querySelector(t.container):t.container;if(!m)throw new Error(`\u65E0\u6548\u7684 container ${t.container}`);m.appendChild(e)}function i(){if(!!o){if(o=!1,s==null?void 0:s.close)return s.close();e.parentElement&&e.parentElement.removeChild(e)}}function f(m){s=he(e,t.onClose),t.container=m}return{remove:i,insert:u,update:a,iframe:e,restetContainer:f,getService(){return G(this,null,function*(){return r.promise})}}}var at=Object.defineProperty,it=(t,e,r)=>e in t?at(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,st=(t,e,r)=>(it(t,typeof e!="symbol"?e+"":e,r),r),pe=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(f){a(f)}},o=i=>{try{u(r.throw(i))}catch(f){a(f)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});class X{constructor(){st(this,"events"),this.events={}}add(e,r){if(!r)return()=>{};const n=this.get(e);return n.push(r),this.events[e]=n,()=>this.off(e,r)}on(e,r){return this.add(e,r)}once(e,r){const n=this.add(e,(...a)=>{n(),r(...a)});return n}off(e,r){const n=this.get(e);if(n){const a=n.findIndex(s=>s===r);n.splice(a,1)}}get(e){return this.events[e]||[]}invoke(e,...r){for(const n of this.get(e))n(...r)}emit(e,...r){this.invoke(e,...r)}asyncInvoke(e,...r){return pe(this,null,function*(){for(const n of this.get(e))yield n(...r)})}asyncInvokeAll(e,...r){return pe(this,null,function*(){yield Promise.all(this.get(e).map(n=>n(...r)))})}}var ot=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(f){a(f)}},o=i=>{try{u(r.throw(i))}catch(f){a(f)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function me(t){return ot(this,null,function*(){const e=t instanceof File?t.name:`${t.type}`;return new File([yield t.arrayBuffer()],e,{type:t.type})})}function k(t,e){if(!t)throw new Error(e)}var R=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(f){a(f)}},o=i=>{try{u(r.throw(i))}catch(f){a(f)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function ut(t){const e=new X,r=null;let n=!1;const a=[];function s(){a.forEach(d=>d()),a.length=0}const o=W({appId:t.appId,container:t.container,onClose(){return R(this,null,function*(){if(t.onCloseModal&&(yield t.onCloseModal())===!1)return!1;e.emit("close")})},methods:{emit(d,...p){return R(this,null,function*(){e.emit(d,...p)})},onload(){return R(this,null,function*(){e.emit("load")})},onSelectTemplate(d){return R(this,null,function*(){return e.emit("select.template",d),!1})},onTemplateLoad(){return R(this,null,function*(){e.emit("template.load")})},getUseRightToken(d){return R(this,null,function*(){if(!t.getUseRightCert)return!1;const p=yield t.getUseRightCert(d);return p instanceof Error?{message:p.message}:p})},getUserCode(){return R(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{h()}})}}});function u(){return R(this,null,function*(){const d=yield o.getService();return{addImage(p,g){d.addImage(p,g)}}})}function i(d={}){return d.categories&&(k(Array.isArray(d.categories),"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B"),k(d.categories.map(p=>+p).filter(Boolean).length===d.categories.length,"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B")),s(),n=!1,o.update(S.TEMPLATE_EDITOR_URL,{id:d.id,version:t.authorize?"TE002":"TE001"}),e.once("load",()=>R(this,null,function*(){var p;n=!0;const g=yield o.getService();u(),yield g.init({appId:t.appId,version:t.authorize?"TE002":"TE001",fileTypes:d.fileTypes,disableModules:d.disableModules,filterPaidMaterial:d.filterPaidMaterial,categoryId:(p=d.categories)==null?void 0:p.join(",")}),e.emit("editor.load")})),o.insert(),new Promise(p=>{a.push(e.once("save",g=>p(g))),a.push(e.once("close",()=>p(!1)))})}function f(d){return d.categories&&(k(Array.isArray(d.categories),"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B"),k(d.categories.map(p=>+p).filter(Boolean).length===d.categories.length,"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B")),s(),n=!1,o.update(S.TEMPLATE_EDITOR_URL,{id:d.id,mode:"user",version:t.authorize?"TE002":"TE001"}),e.once("load",()=>R(this,null,function*(){var p;n=!0;const g=yield o.getService();u(),yield g.init({appId:t.appId,version:t.authorize?"TE002":"TE001",disableModules:d.disableModules,categoryId:(p=d.categories)==null?void 0:p.join(","),filterPaidMaterial:d.filterPaidMaterial,fileTypes:d.fileTypes}),e.emit("editor.load")})),o.insert(),new Promise(p=>{a.push(e.once("save",g=>p(g))),a.push(e.once("close",()=>p(!1)))})}function m(d){return d.categories&&(k(Array.isArray(d.categories),"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B"),k(d.categories.map(p=>+p).filter(Boolean).length===d.categories.length,"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B")),n=!1,s(),o.update(S.OPEN_PLATFORM_ORIGIN+"/template/search",{app_id:t.appId,version:t.authorize?"TE002":"TE001"}),e.once("load",()=>R(this,null,function*(){n=!0,(yield o.getService()).init({appId:t.appId,version:t.authorize?"TE002":"TE001",categories:d.categories})})),d.onSelectTemplate&&a.push(e.add("select.template",d.onSelectTemplate)),o.insert(),new Promise(p=>{a.push(e.once("select.template",g=>p(g))),a.push(e.once("close",()=>p(!1)))})}function h(){e.emit("close"),o.remove()}function l(d){e.add("save",d)}function c(d){e.add("close",d)}function y(d){e.add("editor.load",d)}function v(d){e.add("template.load",d)}return{get canva(){return r},get isLoad(){return n},openTemplateList:m,close:h,onSave:l,onTempalteLoad:v,onClose:c,onLoad:y,editTemplate:f,createTemplate:i}}var Y={exports:{}},ve=function(e,r){return function(){for(var a=new Array(arguments.length),s=0;s<a.length;s++)a[s]=arguments[s];return e.apply(r,a)}},lt=ve,N=Object.prototype.toString;function Z(t){return N.call(t)==="[object Array]"}function Q(t){return typeof t=="undefined"}function ct(t){return t!==null&&!Q(t)&&t.constructor!==null&&!Q(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function dt(t){return N.call(t)==="[object ArrayBuffer]"}function ft(t){return typeof FormData!="undefined"&&t instanceof FormData}function ht(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function pt(t){return typeof t=="string"}function mt(t){return typeof t=="number"}function ye(t){return t!==null&&typeof t=="object"}function D(t){if(N.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function vt(t){return N.call(t)==="[object Date]"}function yt(t){return N.call(t)==="[object File]"}function gt(t){return N.call(t)==="[object Blob]"}function ge(t){return N.call(t)==="[object Function]"}function Et(t){return ye(t)&&ge(t.pipe)}function wt(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function bt(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Ct(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function ee(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Z(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.call(null,t[a],a,t)}function te(){var t={};function e(a,s){D(t[s])&&D(a)?t[s]=te(t[s],a):D(a)?t[s]=te({},a):Z(a)?t[s]=a.slice():t[s]=a}for(var r=0,n=arguments.length;r<n;r++)ee(arguments[r],e);return t}function Rt(t,e,r){return ee(e,function(a,s){r&&typeof a=="function"?t[s]=lt(a,r):t[s]=a}),t}function xt(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var C={isArray:Z,isArrayBuffer:dt,isBuffer:ct,isFormData:ft,isArrayBufferView:ht,isString:pt,isNumber:mt,isObject:ye,isPlainObject:D,isUndefined:Q,isDate:vt,isFile:yt,isBlob:gt,isFunction:ge,isStream:Et,isURLSearchParams:wt,isStandardBrowserEnv:Ct,forEach:ee,merge:te,extend:Rt,trim:bt,stripBOM:xt},M=C;function Ee(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var we=function(e,r,n){if(!r)return e;var a;if(n)a=n(r);else if(M.isURLSearchParams(r))a=r.toString();else{var s=[];M.forEach(r,function(i,f){i===null||typeof i=="undefined"||(M.isArray(i)?f=f+"[]":i=[i],M.forEach(i,function(h){M.isDate(h)?h=h.toISOString():M.isObject(h)&&(h=JSON.stringify(h)),s.push(Ee(f)+"="+Ee(h))}))}),a=s.join("&")}if(a){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e},Tt=C;function F(){this.handlers=[]}F.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1},F.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},F.prototype.forEach=function(e){Tt.forEach(this.handlers,function(n){n!==null&&e(n)})};var St=F,It=C,Pt=function(e,r){It.forEach(e,function(a,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=a,delete e[s])})},be=function(e,r,n,a,s){return e.config=r,n&&(e.code=n),e.request=a,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},Ot=be,Ce=function(e,r,n,a,s){var o=new Error(e);return Ot(o,r,n,a,s)},kt=Ce,At=function(e,r,n){var a=n.config.validateStatus;!n.status||!a||a(n.status)?e(n):r(kt("Request failed with status code "+n.status,n.config,null,n.request,n))},j=C,$t=j.isStandardBrowserEnv()?function(){return{write:function(r,n,a,s,o,u){var i=[];i.push(r+"="+encodeURIComponent(n)),j.isNumber(a)&&i.push("expires="+new Date(a).toGMTString()),j.isString(s)&&i.push("path="+s),j.isString(o)&&i.push("domain="+o),u===!0&&i.push("secure"),document.cookie=i.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),_t=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Nt=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},Ut=_t,Mt=Nt,Lt=function(e,r){return e&&!Ut(r)?Mt(e,r):r},re=C,Bt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],Dt=function(e){var r={},n,a,s;return e&&re.forEach(e.split(` | ||
`),function(u){if(s=u.indexOf(":"),n=re.trim(u.substr(0,s)).toLowerCase(),a=re.trim(u.substr(s+1)),n){if(r[n]&&Bt.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([a]):r[n]=r[n]?r[n]+", "+a:a}}),r},Re=C,Ft=Re.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function a(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=a(window.location.href),function(o){var u=Re.isString(o)?a(o):o;return u.protocol===n.protocol&&u.host===n.host}}():function(){return function(){return!0}}(),z=C,jt=At,zt=$t,qt=we,Kt=Lt,Ht=Dt,Vt=Ft,ne=Ce,xe=function(e){return new Promise(function(n,a){var s=e.data,o=e.headers,u=e.responseType;z.isFormData(s)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",m=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(f+":"+m)}var h=Kt(e.baseURL,e.url);i.open(e.method.toUpperCase(),qt(h,e.params,e.paramsSerializer),!0),i.timeout=e.timeout;function l(){if(!!i){var y="getAllResponseHeaders"in i?Ht(i.getAllResponseHeaders()):null,v=!u||u==="text"||u==="json"?i.responseText:i.response,d={data:v,status:i.status,statusText:i.statusText,headers:y,config:e,request:i};jt(n,a,d),i=null}}if("onloadend"in i?i.onloadend=l:i.onreadystatechange=function(){!i||i.readyState!==4||i.status===0&&!(i.responseURL&&i.responseURL.indexOf("file:")===0)||setTimeout(l)},i.onabort=function(){!i||(a(ne("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){a(ne("Network Error",e,null,i)),i=null},i.ontimeout=function(){var v="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(v=e.timeoutErrorMessage),a(ne(v,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",i)),i=null},z.isStandardBrowserEnv()){var c=(e.withCredentials||Vt(h))&&e.xsrfCookieName?zt.read(e.xsrfCookieName):void 0;c&&(o[e.xsrfHeaderName]=c)}"setRequestHeader"in i&&z.forEach(o,function(v,d){typeof s=="undefined"&&d.toLowerCase()==="content-type"?delete o[d]:i.setRequestHeader(d,v)}),z.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),u&&u!=="json"&&(i.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&i.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(v){!i||(i.abort(),a(v),i=null)}),s||(s=null),i.send(s)})},E=C,Te=Pt,Jt=be,Gt={"Content-Type":"application/x-www-form-urlencoded"};function Se(t,e){!E.isUndefined(t)&&E.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Wt(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=xe),t}function Xt(t,e,r){if(E.isString(t))try{return(e||JSON.parse)(t),E.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var q={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Wt(),transformRequest:[function(e,r){return Te(r,"Accept"),Te(r,"Content-Type"),E.isFormData(e)||E.isArrayBuffer(e)||E.isBuffer(e)||E.isStream(e)||E.isFile(e)||E.isBlob(e)?e:E.isArrayBufferView(e)?e.buffer:E.isURLSearchParams(e)?(Se(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):E.isObject(e)||r&&r["Content-Type"]==="application/json"?(Se(r,"application/json"),Xt(e)):e}],transformResponse:[function(e){var r=this.transitional,n=r&&r.silentJSONParsing,a=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||a&&E.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?Jt(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};q.headers={common:{Accept:"application/json, text/plain, */*"}},E.forEach(["delete","get","head"],function(e){q.headers[e]={}}),E.forEach(["post","put","patch"],function(e){q.headers[e]=E.merge(Gt)});var ae=q,Yt=C,Zt=ae,Qt=function(e,r,n){var a=this||Zt;return Yt.forEach(n,function(o){e=o.call(a,e,r)}),e},Ie=function(e){return!!(e&&e.__CANCEL__)},Pe=C,ie=Qt,er=Ie,tr=ae;function se(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var rr=function(e){se(e),e.headers=e.headers||{},e.data=ie.call(e,e.data,e.headers,e.transformRequest),e.headers=Pe.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Pe.forEach(["delete","get","head","post","put","patch","common"],function(a){delete e.headers[a]});var r=e.adapter||tr.adapter;return r(e).then(function(a){return se(e),a.data=ie.call(e,a.data,a.headers,e.transformResponse),a},function(a){return er(a)||(se(e),a&&a.response&&(a.response.data=ie.call(e,a.response.data,a.response.headers,e.transformResponse))),Promise.reject(a)})},w=C,Oe=function(e,r){r=r||{};var n={},a=["url","method","data"],s=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],u=["validateStatus"];function i(l,c){return w.isPlainObject(l)&&w.isPlainObject(c)?w.merge(l,c):w.isPlainObject(c)?w.merge({},c):w.isArray(c)?c.slice():c}function f(l){w.isUndefined(r[l])?w.isUndefined(e[l])||(n[l]=i(void 0,e[l])):n[l]=i(e[l],r[l])}w.forEach(a,function(c){w.isUndefined(r[c])||(n[c]=i(void 0,r[c]))}),w.forEach(s,f),w.forEach(o,function(c){w.isUndefined(r[c])?w.isUndefined(e[c])||(n[c]=i(void 0,e[c])):n[c]=i(void 0,r[c])}),w.forEach(u,function(c){c in r?n[c]=i(e[c],r[c]):c in e&&(n[c]=i(void 0,e[c]))});var m=a.concat(s).concat(o).concat(u),h=Object.keys(e).concat(Object.keys(r)).filter(function(c){return m.indexOf(c)===-1});return w.forEach(h,f),n},nr={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]},ke=nr,oe={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){oe[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var Ae={},ar=ke.version.split(".");function $e(t,e){for(var r=e?e.split("."):ar,n=t.split("."),a=0;a<3;a++){if(r[a]>n[a])return!0;if(r[a]<n[a])return!1}return!1}oe.transitional=function(e,r,n){var a=r&&$e(r);function s(o,u){return"[Axios v"+ke.version+"] Transitional option '"+o+"'"+u+(n?". "+n:"")}return function(o,u,i){if(e===!1)throw new Error(s(u," has been removed in "+r));return a&&!Ae[u]&&(Ae[u]=!0,console.warn(s(u," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(o,u,i):!0}};function ir(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),a=n.length;a-- >0;){var s=n[a],o=e[s];if(o){var u=t[s],i=u===void 0||o(u,s,t);if(i!==!0)throw new TypeError("option "+s+" must be "+i);continue}if(r!==!0)throw Error("Unknown option "+s)}}var sr={isOlderVersion:$e,assertOptions:ir,validators:oe},_e=C,or=we,Ne=St,Ue=rr,K=Oe,Me=sr,L=Me.validators;function B(t){this.defaults=t,this.interceptors={request:new Ne,response:new Ne}}B.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=K(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&Me.assertOptions(r,{silentJSONParsing:L.transitional(L.boolean,"1.0.0"),forcedJSONParsing:L.transitional(L.boolean,"1.0.0"),clarifyTimeoutError:L.transitional(L.boolean,"1.0.0")},!1);var n=[],a=!0;this.interceptors.request.forEach(function(l){typeof l.runWhen=="function"&&l.runWhen(e)===!1||(a=a&&l.synchronous,n.unshift(l.fulfilled,l.rejected))});var s=[];this.interceptors.response.forEach(function(l){s.push(l.fulfilled,l.rejected)});var o;if(!a){var u=[Ue,void 0];for(Array.prototype.unshift.apply(u,n),u=u.concat(s),o=Promise.resolve(e);u.length;)o=o.then(u.shift(),u.shift());return o}for(var i=e;n.length;){var f=n.shift(),m=n.shift();try{i=f(i)}catch(h){m(h);break}}try{o=Ue(i)}catch(h){return Promise.reject(h)}for(;s.length;)o=o.then(s.shift(),s.shift());return o},B.prototype.getUri=function(e){return e=K(this.defaults,e),or(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},_e.forEach(["delete","get","head","options"],function(e){B.prototype[e]=function(r,n){return this.request(K(n||{},{method:e,url:r,data:(n||{}).data}))}}),_e.forEach(["post","put","patch"],function(e){B.prototype[e]=function(r,n,a){return this.request(K(a||{},{method:e,url:r,data:n}))}});var ur=B;function ue(t){this.message=t}ue.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},ue.prototype.__CANCEL__=!0;var Le=ue,lr=Le;function H(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(a){e=a});var r=this;t(function(a){r.reason||(r.reason=new lr(a),e(r.reason))})}H.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},H.source=function(){var e,r=new H(function(a){e=a});return{token:r,cancel:e}};var cr=H,dr=function(e){return function(n){return e.apply(null,n)}},fr=function(e){return typeof e=="object"&&e.isAxiosError===!0},Be=C,hr=ve,V=ur,pr=Oe,mr=ae;function De(t){var e=new V(t),r=hr(V.prototype.request,e);return Be.extend(r,V.prototype,e),Be.extend(r,e),r}var x=De(mr);x.Axios=V,x.create=function(e){return De(pr(x.defaults,e))},x.Cancel=Le,x.CancelToken=cr,x.isCancel=Ie,x.all=function(e){return Promise.all(e)},x.spread=dr,x.isAxiosError=fr,Y.exports=x,Y.exports.default=x;var vr=Y.exports,yr=Object.defineProperty,gr=(t,e,r)=>e in t?yr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Er=(t,e,r)=>(gr(t,typeof e!="symbol"?e+"":e,r),r),le=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(f){a(f)}},o=i=>{try{u(r.throw(i))}catch(f){a(f)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});class wr{constructor(){Er(this,"axios"),this.axios=vr.create({baseURL:S.OPEN_PLATFORM_ORIGIN})}createKoutuRecord(e){return le(this,null,function*(){const r=e.url,n=yield this.axios.get(r,{responseType:"arraybuffer"}).then(u=>u.data),{width:a,height:s}=yield new Promise(u=>{const i=document.createElement("img");i.src=r,i.onload=()=>{u({width:i.width,height:i.height})}});return(yield this.axios.post("/sdk/api/koutu-records",{url:r,size:n.byteLength,width:a,height:s},{headers:{authorization:`Bearer ${e.token}`}})).data.work_id})}koutu(e){return le(this,null,function*(){return(yield this.axios.post("/sdk/api/koutus",{app_id:e.appId,url:e.url,ability_code:e.abilityCode,work_id:e.workId,use_cert:e.useCert},{headers:{authorization:`Bearer ${e.token}`}})).data.result})}createAuth(e){return le(this,null,function*(){return(yield this.axios.post("/sdk/api/auths",{code:e})).data.access_token})}}var I=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(f){a(f)}},o=i=>{try{u(r.throw(i))}catch(f){a(f)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function br(t){const e=new X,r=W({appId:t.appId,container:t.container,methods:{emit(h,...l){return I(this,null,function*(){e.emit(h,...l)})},onload(){e.emit("load")},getUseRightToken(h){return I(this,null,function*(){if(!t.getUseRightCert)return!1;const l=yield t.getUseRightCert(h);return l instanceof Error?{message:l.message}:l})},getUserCode(){return I(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{m()}})},download(h){return I(this,null,function*(){e.emit("save",h)})}}}),n=[];function a(){n.forEach(h=>h()),n.length=0}function s(h){return I(this,null,function*(){a(),r.update(S.KOUTU_EDITOR_URL,{version:t.authorize?"KE002":"KE001"}),r.insert(),e.once("load",()=>I(this,null,function*(){(yield r.getService()).init({appId:t.appId,version:t.authorize?"KE002":"KE001"})}));const l=typeof h=="string"?h:me(h);return(yield r.getService()).importFile(l),new Promise(y=>{n.push(e.once("save",v=>y(v))),n.push(e.once("close",()=>y(!1)))})})}function o(h){return I(this,null,function*(){return k(Number.isInteger(+h),`\u65E0\u6548\u7684ID ${h}`),a(),r.update(S.KOUTU_EDITOR_URL,{id:h,mode:"user",version:t.authorize?"KE002":"KE001"}),e.once("load",()=>I(this,null,function*(){(yield r.getService()).init({appId:t.appId,version:t.authorize?"KE002":"KE001"})})),new Promise(l=>{n.push(e.once("save",c=>l(c))),n.push(e.once("close",()=>l(!1)))})})}function u(h){return I(this,null,function*(){if(k(typeof h=="string","url \u5FC5\u987B\u662F url \u683C\u5F0F"),!t.authorize||!t.getUseRightCert)throw new Error("\u8D8B\u52BF");const l=new wr,c=yield t.authorize(),y=yield l.createAuth(c),v=yield l.createKoutuRecord({token:y,url:h}),d=yield t.getUseRightCert({abilityCode:"KE002",appId:t.appId,workId:v});if(d){if(d instanceof Error)throw d}else throw new Error("\u6CA1\u6709\u6743\u9650");return{result:yield l.koutu({url:h,appId:t.appId,workId:v,abilityCode:"KE002",useCert:d,token:y}),workId:v}})}function i(h){e.add("save",h)}function f(h){e.add("close",h)}function m(){e.emit("close"),r.remove()}return{onSave:i,onClose:f,close:m,koutu:u,editKoutu:o,importImage:s}}var P=(t,e,r)=>new Promise((n,a)=>{var s=i=>{try{u(r.next(i))}catch(f){a(f)}},o=i=>{try{u(r.throw(i))}catch(f){a(f)}},u=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,o);u((r=r.apply(t,e)).next())});function Cr(t){const e=new X,r=[];function n(){r.forEach(l=>l()),r.length=0}const a=W({container:t.container,appId:t.appId,methods:{emit(l,...c){return P(this,null,function*(){e.emit(l,...c)})},onload(){e.emit("load")},getUseRightToken(l){return P(this,null,function*(){if(!t.getUseRightCert)return!1;const c=yield t.getUseRightCert(l);return c instanceof Error?{message:c.message}:c})},getUserCode(){return P(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{f()}})},download(l){return P(this,null,function*(){e.emit("save",l)})}}});function s(l,c){e.on(l,c)}function o(l,c){e.off(l,c)}function u(l){return P(this,arguments,function*(c,y={}){n(),a.update(S.IMAGE_EDITOR_URL,{version:t.authorize?"IE002":"IE001"}),a.insert(),e.once("load",()=>P(this,null,function*(){(yield a.getService()).init({appId:t.appId,version:t.authorize?"IE002":"IE001",fileTypes:y.fileTypes,disableModules:y.disableModules})}));const v=yield a.getService(),d=yield Promise.all((Array.isArray(c)?c:[c]).map(p=>P(this,null,function*(){return typeof p=="string"?p:yield me(p)})));return v.importFile(d),new Promise(p=>{r.push(e.once("save",g=>p(g))),r.push(e.once("close",()=>p(!1)))})})}function i(l){return P(this,arguments,function*(c,y={}){return n(),a.update(S.IMAGE_EDITOR_URL,{id:c,mode:"user",version:t.authorize?"IE002":"IE001"}),a.insert(),e.once("load",()=>P(this,null,function*(){(yield a.getService()).init({appId:t.appId,version:"TE001",fileTypes:y.fileTypes,disableModules:y.disableModules})})),new Promise(v=>{r.push(e.once("save",d=>v(d))),r.push(e.once("close",()=>v(!1)))})})}function f(){e.emit("close"),a.remove()}function m(l){e.add("save",l)}function h(l){e.add("close",l)}return{editImage:i,close:f,onSave:m,onClose:h,importImage:u,on:s,off:o}}T.createImageEditor=Cr,T.createKoutuEditor=br,T.createTemplateEditor=ut,T.env=S,Object.defineProperty(T,"__esModule",{value:!0}),T[Symbol.toStringTag]="Module"}); | ||
//# sourceMappingURL=editor-sdk.umd.js.map |
{ | ||
"name": "@gaoding/editor-sdk", | ||
"version": "2.0.0-alpha.0", | ||
"version": "2.0.0-alpha.1", | ||
"description": "稿定编辑器对外 SDK", | ||
@@ -29,3 +29,3 @@ "main": "dist/editor-sdk.umd.js", | ||
}, | ||
"gitHead": "d46affdf1c42426453a286fc5a6dd7a65a5588f5" | ||
"gitHead": "6a5f67f41cf6d84632e20799945065adb021f410" | ||
} |
@@ -20,3 +20,3 @@ interface Config { | ||
declare type FileType = 'jpg' | 'png' | 'gif' | 'ppt' | 'pdf' | 'mp4'; | ||
declare type EditorModuleType = 'panel.template' | 'material-panel' | 'my-panel'; | ||
declare type EditorModuleType = 'panel.template' | 'panel.element' | 'panel.text' | 'panel.photo' | 'panel.widget' | 'panel.chart' | 'panel.component' | 'panel.my-resource'; | ||
export declare function createTemplateEditor(config: Config): { | ||
@@ -26,3 +26,3 @@ readonly canva: null; | ||
openTemplateList: (options: { | ||
categories?: string[] | undefined; | ||
categories?: number[] | undefined; | ||
onSelectTemplate?(info: { | ||
@@ -44,2 +44,3 @@ id: string; | ||
fileTypes?: FileType[]; | ||
categories?: number[]; | ||
disableModules?: EditorModuleType[]; | ||
@@ -51,3 +52,3 @@ filterPaidMaterial?: never; | ||
fileTypes?: FileType[]; | ||
categoryId?: number; | ||
categories?: number[]; | ||
disableModules?: EditorModuleType[]; | ||
@@ -54,0 +55,0 @@ }) => Promise<unknown>; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
385367
18
2813