@gaoding/editor-sdk
Advanced tools
Comparing version 2.1.0 to 2.2.0-alpha.0
@@ -1,2 +0,2 @@ | ||
(function(S,C){typeof exports=="object"&&typeof module!="undefined"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(S=typeof globalThis!="undefined"?globalThis:S||self,C(S.gaoding={}))})(this,function(S){"use strict";var C;(function(t){t.Call="call",t.Reply="reply",t.Syn="syn",t.SynAck="synAck",t.Ack="ack"})(C||(C={}));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 k;(function(t){t.Message="message"})(k||(k={}));var Be=()=>{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!==C.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:d,id:v}=h;r(`${n}: Received ${l}() call`);const y=c=>p=>{if(r(`${n}: Sending ${l}() reply`),i){r(`${n}: Unable to send ${l}() reply due to destroyed connection`);return}const g={penpal:C.Reply,id:v,resolution:c,returnValue:p};c===$.Rejected&&p instanceof Error&&(g.returnValue=fe(p),g.returnValueIsError=!0);try{s.postMessage(g,o)}catch(T){if(T.name===J.DataCloneError){const A={penpal:C.Reply,id:v,resolution:$.Rejected,returnValue:fe(T),returnValueIsError:!0};s.postMessage(A,o)}throw T}};new Promise(c=>c(e[l].apply(e,d))).then(y($.Fulfilled),y($.Rejected))};return a.addEventListener(k.Message,f),()=>{i=!0,a.removeEventListener(k.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=>(...d)=>{a(`${s}: Sending ${l}() call`);let v;try{u.closed&&(v=!0)}catch{v=!0}if(v&&n(),m){const y=new Error(`Unable to send ${l}() call due to destroyed connection`);throw y.code=U.ConnectionDestroyed,y}return new Promise((y,c)=>{const p=We(),g=A=>{if(A.source!==u||A.data.penpal!==C.Reply||A.data.id!==p)return;if(A.origin!==f){a(`${s} received message from origin ${A.origin} which did not match expected origin ${f}`);return}const ce=A.data;a(`${s}: Received ${l}() reply`),o.removeEventListener(k.Message,g);let de=ce.returnValue;ce.returnValueIsError&&(de=Ve(de)),(ce.resolution===$.Fulfilled?y:c)(de)};o.addEventListener(k.Message,g);const T={penpal:C.Call,id:p,methodName:l,args:d};u.postMessage(T,i)})};return r.reduce((l,d)=>(l[d]=h(d),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(d=>{delete f[d]}),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:C.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=Be(),{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((v,y)=>{const c=tt(a,f),p=g=>{if(!(g.source!==e.contentWindow||!g.data)){if(g.data.penpal===C.Syn){h(g);return}if(g.data.penpal===C.Ack){const T=l(g);T&&(c(),v(T));return}}};window.addEventListener(k.Message,p),o("Parent: Awaiting handshake"),et(e,u),i(g=>{window.removeEventListener(k.Message,p),g||(g=new Error("Connection destroyed"),g.code=U.ConnectionDestroyed),y(g)})}),destroy(){f()}}};const E={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.1.0"}};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=` | ||
(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 N;(function(t){t.Fulfilled="fulfilled",t.Rejected="rejected"})(N||(N={}));var L;(function(t){t.ConnectionDestroyed="ConnectionDestroyed",t.ConnectionTimeout="ConnectionTimeout",t.NotInIframe="NotInIframe",t.NoIframeSrc="NoIframeSrc"})(L||(L={}));var X;(function(t){t.DataCloneError="DataCloneError"})(X||(X={}));var A;(function(t){t.Message="message"})(A||(A={}));var je=()=>{const t=[];let e=!1;return{destroy(r){e=!0,t.forEach(n=>{n(r)})},onDestroy(r){e?r():t.push(r)}}},ze=t=>(...e)=>{t&&console.log("[Penpal]",...e)};const qe={"http:":"80","https:":"443"},Ke=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,He=["file:","data:"];var Ve=t=>{if(t&&He.find(u=>t.startsWith(u)))return"null";const e=document.location,r=Ke.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!==qe[n]?`:${s}`:"";return`${n}//${a}${o}`};const he=({name:t,message:e,stack:r})=>({name:t,message:e,stack:r}),Je=t=>{const e=new Error;return Object.keys(t).forEach(r=>e[r]=t[r]),e};var Ge=(t,e,r)=>{const{localName:n,local:a,remote:s,originForSending:o,originForReceiving:u}=t;let i=!1;const d=y=>{if(y.source!==s||y.data.penpal!==b.Call)return;if(y.origin!==u){r(`${n} received message from origin ${y.origin} which did not match expected origin ${u}`);return}const h=y.data,{methodName:l,args:f,id:p}=h;r(`${n}: Received ${l}() call`);const m=c=>v=>{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:p,resolution:c,returnValue:v};c===N.Rejected&&v instanceof Error&&(g.returnValue=he(v),g.returnValueIsError=!0);try{s.postMessage(g,o)}catch(P){if(P.name===X.DataCloneError){const $={penpal:b.Reply,id:p,resolution:N.Rejected,returnValue:he(P),returnValueIsError:!0};s.postMessage($,o)}throw P}};new Promise(c=>c(e[l].apply(e,f))).then(m(N.Fulfilled),m(N.Rejected))};return a.addEventListener(A.Message,d),()=>{i=!0,a.removeEventListener(A.Message,d)}};let We=0;var Xe=()=>++We,Ye=(t,e,r,n,a)=>{const{localName:s,local:o,remote:u,originForSending:i,originForReceiving:d}=e;let y=!1;a(`${s}: Connecting call sender`);const h=l=>(...f)=>{a(`${s}: Sending ${l}() call`);let p;try{u.closed&&(p=!0)}catch{p=!0}if(p&&n(),y){const m=new Error(`Unable to send ${l}() call due to destroyed connection`);throw m.code=L.ConnectionDestroyed,m}return new Promise((m,c)=>{const v=Xe(),g=$=>{if($.source!==u||$.data.penpal!==b.Reply||$.data.id!==v)return;if($.origin!==d){a(`${s} received message from origin ${$.origin} which did not match expected origin ${d}`);return}const de=$.data;a(`${s}: Received ${l}() reply`),o.removeEventListener(A.Message,g);let fe=de.returnValue;de.returnValueIsError&&(fe=Je(fe)),(de.resolution===N.Fulfilled?m:c)(fe)};o.addEventListener(A.Message,g);const P={penpal:b.Call,id:v,methodName:l,args:f};u.postMessage(P,i)})};return r.reduce((l,f)=>(l[f]=h(f),l),t),()=>{y=!0}},Ze=(t,e,r,n,a)=>{const{destroy:s,onDestroy:o}=n;let u,i;const d={};return y=>{if(y.origin!==e){a(`Parent: Handshake - Received ACK message from origin ${y.origin} which did not match expected origin ${e}`);return}a("Parent: Handshake - Received ACK");const h={localName:"Parent",local:window,remote:y.source,originForSending:r,originForReceiving:e};u&&u(),u=Ge(h,t,a),o(u),i&&i.forEach(f=>{delete d[f]}),i=y.data.methodNames;const l=Ye(d,h,i,s,a);return o(l),d}},Qe=(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 et=6e4;var tt=(t,e)=>{const{destroy:r,onDestroy:n}=e,a=setInterval(()=>{t.isConnected||(clearInterval(a),r())},et);n(()=>{clearInterval(a)})},rt=(t,e)=>{let r;return t!==void 0&&(r=window.setTimeout(()=>{const n=new Error(`Connection timed out after ${t}ms`);n.code=L.ConnectionTimeout,e(n)},t)),()=>{clearTimeout(r)}},nt=t=>{if(!t.src&&!t.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=L.NoIframeSrc,e}},at=t=>{let{iframe:e,methods:r={},childOrigin:n,timeout:a,debug:s=!1}=t;const o=ze(s),u=je(),{onDestroy:i,destroy:d}=u;n||(nt(e),n=Ve(e.src));const y=n==="null"?"*":n,h=Qe(o,r,n,y),l=Ze(r,n,y,u,o);return{promise:new Promise((p,m)=>{const c=rt(a,d),v=g=>{if(!(g.source!==e.contentWindow||!g.data)){if(g.data.penpal===b.Syn){h(g);return}if(g.data.penpal===b.Ack){const P=l(g);P&&(c(),p(P));return}}};window.addEventListener(A.Message,v),o("Parent: Awaiting handshake"),tt(e,u),i(g=>{window.removeEventListener(A.Message,v),g||(g=new Error("Connection destroyed"),g.code=L.ConnectionDestroyed),m(g)})}),destroy(){d()}}};const it="2.2.0-alpha.0",E={TEMPLATE_EDITOR_URL:"https://open.gaoding.com/design",MOBILE_TEMPLATE_EDITOR_URL:"https://open.gaoding.com/h5/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 it}};var Y=(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 pe(t,e){const r=document.createElement("div");r.style.cssText=` | ||
position: relative; | ||
@@ -36,8 +36,9 @@ width: calc(100vw - 100px); | ||
opacity: 0.5; | ||
`;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,d;e&&(yield e())===!1||(u=!1,f(),(l=o.parentElement)==null||l.removeChild(o),(d=s.parentElement)==null||d.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=` | ||
`;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 y(){return Y(this,null,function*(){var l,f;e&&(yield e())===!1||(u=!1,d(),(l=o.parentElement)==null||l.removeChild(o),(f=s.parentElement)==null||f.removeChild(s))})}function h(){u||(u=!0,document.body.appendChild(o),document.body.appendChild(s),d())}return n.addEventListener("click",y),{open:h,close:y}}function B(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(f,m){return G(this,null,function*(){const h=Object.assign({},m,{app_id:t.appId,v:E.VERSION}),l=`${f}?${Object.entries(h).filter(([d,v])=>v!==void 0).map(([d,v])=>`${d}=${v}`).join("&")}`;if(n!==l){if(n=l,!m){e.src=f;return}e.src=l,r&&r.destroy(),r=nt({iframe:e,methods:t.methods})}})}let s=null;t.container||(s=he(e,t.onClose));function o(){if(s)return s.open();const f=typeof t.container=="string"?document.body.querySelector(t.container):t.container;if(!f)throw new Error(`\u65E0\u6548\u7684 container ${t.container}`);f.appendChild(e)}function u(){if(s==null?void 0:s.close)return s.close();e.parentElement&&e.parentElement.removeChild(e)}function i(f){s=he(e,t.onClose),t.container=f}return{remove:u,insert:o,update:a,iframe:e,restetContainer:i,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){const n=[...this.get(e)];for(const a of n)a(...r)}emit(e,...r){this.invoke(e,...r)}asyncInvoke(e,...r){return pe(this,null,function*(){const n=[...this.get(e)];for(const a of n)yield a(...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 _(t,e){if(!t)throw new Error(e)}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 ut(t){const e=new X;let r=null,n=!1;const a=[];function s(){a.forEach(c=>c()),a.length=0}const o=W({appId:t.appId,container:t.container,onClose(){return I(this,null,function*(){if(t.onCloseModal&&(yield t.onCloseModal())===!1)return!1;e.emit("close")})},methods:{emit(c,...p){return I(this,null,function*(){e.emit(c,...p)})},onload(){return I(this,null,function*(){e.emit("load")})},onSelectTemplate(c){return I(this,null,function*(){return e.emit("select.template",c),!1})},onTemplateLoad(){return I(this,null,function*(){r=yield u(),e.emit("template.load")})},getUseRightToken(c){return I(this,null,function*(){if(!t.getUseRightCert)return!1;const p=yield t.getUseRightCert(c);return p instanceof Error?{message:p.message}:p})},getUserCode(){return I(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{h()}})}}});function u(){return I(this,null,function*(){const c=yield o.getService();return{addImage(p,g){return I(this,null,function*(){c.addImage(p,g)})}}})}function i(c={}){c.categoryId&&_(["number","string"].includes(typeof c.categoryId)&&!Number.isNaN(+c.categoryId),"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B"),s(),n=!1;const p={version:t.authorize?"TE002":"TE001",buttonText:c.okText||"\u4FDD\u5B58"};return c.templateId?p.id=c.templateId:(p.mode="create",c.size&&(p.width=c.size.width,p.height=c.size.height)),o.update(E.TEMPLATE_EDITOR_URL,p),e.once("load",()=>I(this,null,function*(){n=!0,yield(yield o.getService()).init({appId:t.appId,version:t.authorize?"TE002":"TE001",fileTypes:c.fileTypes,disableModules:c.disableModules,v:E.VERSION,filterPaidMaterial:c.filterPaidMaterial,categoryId:c.categoryId}),e.emit("editor.load")})),o.insert(),new Promise(g=>{a.push(e.once("save",T=>g(T))),a.push(e.once("close",()=>g(!1)))})}function f(c){return c.categories&&(_(Array.isArray(c.categories),"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B"),_(c.categories.map(p=>+p).filter(Boolean).length===c.categories.length,"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B")),s(),n=!1,o.update(E.TEMPLATE_EDITOR_URL,{id:c.id,buttonText:c.okText||"\u4FDD\u5B58",mode:"user",version:t.authorize?"TE002":"TE001"}),e.once("load",()=>I(this,null,function*(){var p;n=!0,yield(yield o.getService()).init({appId:t.appId,version:t.authorize?"TE002":"TE001",disableModules:c.disableModules,categoryId:(p=c.categories)==null?void 0:p.join(","),v:E.VERSION,filterPaidMaterial:c.filterPaidMaterial,fileTypes:c.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(c){return c.categories&&(_(Array.isArray(c.categories),"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B"),_(c.categories.map(p=>+p).filter(Boolean).length===c.categories.length,"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B")),n=!1,s(),o.update(E.OPEN_PLATFORM_ORIGIN+"/template/search",{app_id:t.appId,version:t.authorize?"TE002":"TE001"}),e.once("load",()=>I(this,null,function*(){n=!0,(yield o.getService()).init({appId:t.appId,v:E.VERSION,version:t.authorize?"TE002":"TE001",categories:c.categories})})),c.onSelectTemplate&&a.push(e.add("select.template",c.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(c){e.add("save",c)}function d(c){e.add("close",c)}function v(c){e.add("editor.load",c)}function y(c){e.add("template.load",c)}return{get canva(){return r},get isLoad(){return n},openTemplateList:m,close:h,onSave:l,onTemplateLoad:y,onClose:d,onLoad:v,editDesign:f,createDesign: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 F(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){F(t[s])&&F(a)?t[s]=te(t[s],a):F(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 It(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var R={isArray:Z,isArrayBuffer:dt,isBuffer:ct,isFormData:ft,isArrayBufferView:ht,isString:pt,isNumber:mt,isObject:ye,isPlainObject:F,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:It},M=R;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},xt=R;function B(){this.handlers=[]}B.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},B.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},B.prototype.forEach=function(e){xt.forEach(this.handlers,function(n){n!==null&&e(n)})};var St=B,Tt=R,Ot=function(e,r){Tt.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},Pt=be,Ce=function(e,r,n,a,s){var o=new Error(e);return Pt(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=R,$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,Dt=function(e,r){return e&&!Ut(r)?Mt(e,r):r},re=R,Lt=["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"],Ft=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]&&Lt.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=R,Bt=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=R,jt=At,zt=$t,qt=we,Kt=Dt,Ht=Ft,Vt=Bt,ne=Ce,Ie=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 v="getAllResponseHeaders"in i?Ht(i.getAllResponseHeaders()):null,y=!u||u==="text"||u==="json"?i.responseText:i.response,c={data:y,status:i.status,statusText:i.statusText,headers:v,config:e,request:i};jt(n,a,c),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 y="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(y=e.timeoutErrorMessage),a(ne(y,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",i)),i=null},z.isStandardBrowserEnv()){var d=(e.withCredentials||Vt(h))&&e.xsrfCookieName?zt.read(e.xsrfCookieName):void 0;d&&(o[e.xsrfHeaderName]=d)}"setRequestHeader"in i&&z.forEach(o,function(y,c){typeof s=="undefined"&&c.toLowerCase()==="content-type"?delete o[c]:i.setRequestHeader(c,y)}),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(y){!i||(i.abort(),a(y),i=null)}),s||(s=null),i.send(s)})},w=R,xe=Ot,Jt=be,Gt={"Content-Type":"application/x-www-form-urlencoded"};function Se(t,e){!w.isUndefined(t)&&w.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=Ie),t}function Xt(t,e,r){if(w.isString(t))try{return(e||JSON.parse)(t),w.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 xe(r,"Accept"),xe(r,"Content-Type"),w.isFormData(e)||w.isArrayBuffer(e)||w.isBuffer(e)||w.isStream(e)||w.isFile(e)||w.isBlob(e)?e:w.isArrayBufferView(e)?e.buffer:w.isURLSearchParams(e)?(Se(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):w.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&&w.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, */*"}},w.forEach(["delete","get","head"],function(e){q.headers[e]={}}),w.forEach(["post","put","patch"],function(e){q.headers[e]=w.merge(Gt)});var ae=q,Yt=R,Zt=ae,Qt=function(e,r,n){var a=this||Zt;return Yt.forEach(n,function(o){e=o.call(a,e,r)}),e},Te=function(e){return!!(e&&e.__CANCEL__)},Oe=R,ie=Qt,er=Te,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=Oe.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Oe.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)})},b=R,Pe=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,d){return b.isPlainObject(l)&&b.isPlainObject(d)?b.merge(l,d):b.isPlainObject(d)?b.merge({},d):b.isArray(d)?d.slice():d}function f(l){b.isUndefined(r[l])?b.isUndefined(e[l])||(n[l]=i(void 0,e[l])):n[l]=i(e[l],r[l])}b.forEach(a,function(d){b.isUndefined(r[d])||(n[d]=i(void 0,r[d]))}),b.forEach(s,f),b.forEach(o,function(d){b.isUndefined(r[d])?b.isUndefined(e[d])||(n[d]=i(void 0,e[d])):n[d]=i(void 0,r[d])}),b.forEach(u,function(d){d in r?n[d]=i(e[d],r[d]):d in e&&(n[d]=i(void 0,e[d]))});var m=a.concat(s).concat(o).concat(u),h=Object.keys(e).concat(Object.keys(r)).filter(function(d){return m.indexOf(d)===-1});return b.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=R,or=we,Ne=St,Ue=rr,K=Pe,Me=sr,D=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=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:D.transitional(D.boolean,"1.0.0"),forcedJSONParsing:D.transitional(D.boolean,"1.0.0"),clarifyTimeoutError:D.transitional(D.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},L.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){L.prototype[e]=function(r,n){return this.request(K(n||{},{method:e,url:r,data:(n||{}).data}))}}),_e.forEach(["post","put","patch"],function(e){L.prototype[e]=function(r,n,a){return this.request(K(a||{},{method:e,url:r,data:n}))}});var ur=L;function ue(t){this.message=t}ue.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},ue.prototype.__CANCEL__=!0;var De=ue,lr=De;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},Le=R,hr=ve,V=ur,pr=Pe,mr=ae;function Fe(t){var e=new V(t),r=hr(V.prototype.request,e);return Le.extend(r,V.prototype,e),Le.extend(r,e),r}var x=Fe(mr);x.Axios=V,x.create=function(e){return Fe(pr(x.defaults,e))},x.Cancel=De,x.CancelToken=cr,x.isCancel=Te,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:E.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 O=(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 O(this,null,function*(){e.emit(h,...l)})},onload(){e.emit("load")},getUseRightToken(h){return O(this,null,function*(){if(!t.getUseRightCert)return!1;const l=yield t.getUseRightCert(h);return l instanceof Error?{message:l.message}:l})},getUserCode(){return O(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{m()}})},download(h){return O(this,null,function*(){e.emit("save",h)})}}}),n=[];function a(){n.forEach(h=>h()),n.length=0}function s(h){return O(this,null,function*(){return a(),r.update(E.KOUTU_EDITOR_URL,{version:t.authorize?"KE002":"KE001"}),r.insert(),e.once("load",()=>O(this,null,function*(){(yield r.getService()).init({appId:t.appId,v:E.VERSION,version:t.authorize?"KE002":"KE001"});const d=typeof h=="string"?h:yield me(h);(yield r.getService()).importFile(d)})),new Promise(l=>{n.push(e.once("save",d=>l(d))),n.push(e.once("close",()=>l(!1)))})})}function o(h){return O(this,null,function*(){return _(Number.isInteger(+h),`\u65E0\u6548\u7684ID ${h}`),a(),r.update(E.KOUTU_EDITOR_URL,{id:h,mode:"user",version:t.authorize?"KE002":"KE001"}),r.insert(),e.once("load",()=>O(this,null,function*(){const l=yield r.getService();l.init({appId:t.appId,v:E.VERSION,version:t.authorize?"KE002":"KE001"}),l.openWork(h)})),new Promise(l=>{n.push(e.once("save",d=>l(d))),n.push(e.once("close",()=>l(!1)))})})}function u(h){return O(this,null,function*(){if(_(typeof h=="string","url \u5FC5\u987B\u662F url \u683C\u5F0F"),!t.authorize||!t.getUseRightCert)throw new Error("\u7F3A\u5C11 authorize \u6216\u8005 getUseRightCert \u53C2\u6570");const l=new wr,d=yield t.authorize(),v=yield l.createAuth(d),y=yield l.createKoutuRecord({token:v,url:h}),c=yield t.getUseRightCert({abilityCode:"KE002",appId:t.appId,workId:y});if(c){if(c instanceof Error)throw c}else throw new Error("\u6CA1\u6709\u6743\u9650");return{result:yield l.koutu({url:h,appId:t.appId,workId:y,abilityCode:"KE002",useCert:c,token:v}),workId:y}})}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,...d){return P(this,null,function*(){e.emit(l,...d)})},onload(){e.emit("load")},getUseRightToken(l){return P(this,null,function*(){if(!t.getUseRightCert)return!1;const d=yield t.getUseRightCert(l);return d instanceof Error?{message:d.message}:d})},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,d){e.on(l,d)}function o(l,d){e.off(l,d)}function u(l){return P(this,arguments,function*(d,v={}){return n(),a.update(E.IMAGE_EDITOR_URL,{version:t.authorize?"IE002":"IE001"}),a.insert(),e.once("load",()=>P(this,null,function*(){(yield a.getService()).init({appId:t.appId,v:E.VERSION,version:t.authorize?"IE002":"IE001",fileTypes:v.fileTypes,disableModules:v.disableModules});const c=yield a.getService(),p=yield Promise.all((Array.isArray(d)?d:[d]).map(g=>P(this,null,function*(){return typeof g=="string"?g:yield me(g)})));c.importFile(p)})),new Promise(y=>{r.push(e.once("save",c=>y(c))),r.push(e.once("close",()=>y(!1)))})})}function i(l){return P(this,arguments,function*(d,v={}){return n(),a.update(E.IMAGE_EDITOR_URL,{id:d,mode:"user",version:t.authorize?"IE002":"IE001"}),a.insert(),e.once("load",()=>P(this,null,function*(){(yield a.getService()).init({appId:t.appId,v:E.VERSION,version:t.authorize?"IE002":"IE001",fileTypes:v.fileTypes,disableModules:v.disableModules})})),new Promise(y=>{r.push(e.once("save",c=>y(c))),r.push(e.once("close",()=>y(!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}}S.createImageEditor=Cr,S.createKoutuEditor=br,S.createTemplateEditor=ut,S.env=E,Object.defineProperty(S,"__esModule",{value:!0}),S[Symbol.toStringTag]="Module"}); | ||
${t.css} | ||
`,e.referrerPolicy="strict-origin-when-cross-origin",e.className="gaoding-iframe",e.setAttribute("frameborder","0");let r=null,n="";function a(d,y){return Y(this,null,function*(){const h=Object.assign({},y,{app_id:t.appId,v:E.VERSION}),l=`${d}?${Object.entries(h).filter(([f,p])=>p!==void 0).map(([f,p])=>`${f}=${p}`).join("&")}`;if(n!==l){if(n=l,!y){e.src=d;return}e.src=l,r&&r.destroy(),r=at({iframe:e,methods:t.methods})}})}let s=null;t.container||(s=pe(e,t.onClose));function o(){if(s)return s.open();const d=typeof t.container=="string"?document.body.querySelector(t.container):t.container;if(!d)throw new Error(`\u65E0\u6548\u7684 container ${t.container}`);d.appendChild(e)}function u(){if(s==null?void 0:s.close)return s.close();e.parentElement&&e.parentElement.removeChild(e)}function i(d){s=pe(e,t.onClose),t.container=d}return{remove:u,insert:o,update:a,iframe:e,restetContainer:i,getService(){return Y(this,null,function*(){return r.promise})}}}var st=Object.defineProperty,ot=(t,e,r)=>e in t?st(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e,r)=>(ot(t,typeof e!="symbol"?e+"":e,r),r),me=(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 j{constructor(){ut(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){const n=[...this.get(e)];for(const a of n)a(...r)}emit(e,...r){this.invoke(e,...r)}asyncInvoke(e,...r){return me(this,null,function*(){const n=[...this.get(e)];for(const a of n)yield a(...r)})}asyncInvokeAll(e,...r){return me(this,null,function*(){yield Promise.all(this.get(e).map(n=>n(...r)))})}}var lt=(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 ve(t){return lt(this,null,function*(){const e=t instanceof File?t.name:`${t.type}`;return new File([yield t.arrayBuffer()],e,{type:t.type})})}function S(t,e){if(!t)throw new Error(e)}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 ct(t){const e=new j;let r=null,n=!1;const a=[];function s(){a.forEach(c=>c()),a.length=0}const o=B({appId:t.appId,container:t.container,onClose(){return I(this,null,function*(){if(t.onCloseModal&&(yield t.onCloseModal())===!1)return!1;e.emit("close")})},methods:{emit(c,...v){return I(this,null,function*(){e.emit(c,...v)})},onload(){return I(this,null,function*(){e.emit("load")})},onSelectTemplate(c){return I(this,null,function*(){return e.emit("select.template",c),!1})},onTemplateLoad(){return I(this,null,function*(){r=yield u(),e.emit("template.load")})},getUseRightToken(c){return I(this,null,function*(){if(!t.getUseRightCert)return!1;const v=yield t.getUseRightCert(c);return v instanceof Error?{message:v.message}:v})},getUserCode(){return I(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{h()}})}}});function u(){return I(this,null,function*(){const c=yield o.getService();return{addImage(v,g){return I(this,null,function*(){c.addImage(v,g)})}}})}function i(c={}){c.categoryId&&S(["number","string"].includes(typeof c.categoryId)&&!Number.isNaN(+c.categoryId),"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B"),s(),n=!1;const v={version:t.authorize?"TE002":"TE001",buttonText:c.okText||"\u4FDD\u5B58"};return c.templateId?v.id=c.templateId:(v.mode="create",c.size&&(v.width=c.size.width,v.height=c.size.height)),o.update(E.TEMPLATE_EDITOR_URL,v),e.once("load",()=>I(this,null,function*(){n=!0,yield(yield o.getService()).init({appId:t.appId,version:t.authorize?"TE002":"TE001",fileTypes:c.fileTypes,disableModules:c.disableModules,v:E.VERSION,filterPaidMaterial:c.filterPaidMaterial,categoryId:c.categoryId}),e.emit("editor.load")})),o.insert(),new Promise(g=>{a.push(e.once("save",P=>g(P))),a.push(e.once("close",()=>g(!1)))})}function d(c){return c.categories&&(S(Array.isArray(c.categories),"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B"),S(c.categories.map(v=>+v).filter(Boolean).length===c.categories.length,"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B")),s(),n=!1,o.update(E.TEMPLATE_EDITOR_URL,{id:c.id,buttonText:c.okText||"\u4FDD\u5B58",mode:"user",version:t.authorize?"TE002":"TE001"}),e.once("load",()=>I(this,null,function*(){var v;n=!0,yield(yield o.getService()).init({appId:t.appId,version:t.authorize?"TE002":"TE001",disableModules:c.disableModules,categoryId:(v=c.categories)==null?void 0:v.join(","),v:E.VERSION,filterPaidMaterial:c.filterPaidMaterial,fileTypes:c.fileTypes}),e.emit("editor.load")})),o.insert(),new Promise(v=>{a.push(e.once("save",g=>v(g))),a.push(e.once("close",()=>v(!1)))})}function y(c){return c.categories&&(S(Array.isArray(c.categories),"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B"),S(c.categories.map(v=>+v).filter(Boolean).length===c.categories.length,"categories \u53C2\u6570\u5FC5\u987B\u662F number \u6570\u7EC4\u7C7B\u578B")),n=!1,s(),o.update(E.OPEN_PLATFORM_ORIGIN+"/template/search",{app_id:t.appId,version:t.authorize?"TE002":"TE001"}),e.once("load",()=>I(this,null,function*(){n=!0,(yield o.getService()).init({appId:t.appId,v:E.VERSION,version:t.authorize?"TE002":"TE001",categories:c.categories})})),c.onSelectTemplate&&a.push(e.add("select.template",c.onSelectTemplate)),o.insert(),new Promise(v=>{a.push(e.once("select.template",g=>v(g))),a.push(e.once("close",()=>v(!1)))})}function h(){e.emit("close"),o.remove()}function l(c){e.add("save",c)}function f(c){e.add("close",c)}function p(c){e.add("editor.load",c)}function m(c){e.add("template.load",c)}return{get canva(){return r},get isLoad(){return n},openTemplateList:y,close:h,onSave:l,onTemplateLoad:m,onClose:f,onLoad:p,editDesign:d,createDesign:i}}var O=(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 dt(t){S(!!t,"createTemplateEditor \u9700\u8981\u4F20\u5165\u53C2\u6570\u624D\u80FD\u4F7F\u7528"),S(typeof t.authorize=="function","authorize \u5FC5\u73B0\u662F\u4E2A function"),S(typeof t.container=="string","\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 container"),S(typeof t.getUseRightCert=="function","\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 getUseRightCert");const e=new j;let r=!1;const n=[];function a(){n.forEach(p=>p()),n.length=0}const s=B({appId:t.appId,container:t.container,css:"min-height: 100vh;",methods:{emit(p,...m){return O(this,null,function*(){e.emit(p,...m)})},onload(){return O(this,null,function*(){e.emit("load")})},onSelectTemplate(p){return O(this,null,function*(){return e.emit("select.template",p),!1})},onTemplateLoad(){return O(this,null,function*(){e.emit("template.load")})},getUseRightCert(p){return O(this,null,function*(){if(!t.getUseRightCert)return!1;const m=yield t.getUseRightCert(p);return m instanceof Error?{message:m.message}:m})},getUserCode(){return O(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{d()}})}}});function o(p){return O(this,null,function*(){a(),r=!1;const m=yield t.authorize(),c={version:"TE002",user_code:m};return p.templateId&&(c.id=p.templateId),s.update(E.MOBILE_TEMPLATE_EDITOR_URL,c),e.once("load",()=>O(this,null,function*(){r=!0,yield(yield s.getService()).init({appId:t.appId,version:"TE002"}),e.emit("editor.load")})),s.insert(),new Promise(v=>{n.push(e.once("save",g=>v(g))),n.push(e.once("close",()=>v(!1)))})})}function u(p){return a(),r=!1,s.update(E.MOBILE_TEMPLATE_EDITOR_URL,{id:p.id,mode:"user",version:"TE002"}),e.once("load",()=>O(this,null,function*(){r=!0,yield(yield s.getService()).init({appId:t.appId,version:"TE002",v:E.VERSION}),e.emit("editor.load")})),s.insert(),new Promise(m=>{n.push(e.once("save",c=>m(c))),n.push(e.once("close",()=>m(!1)))})}function i(p){return r=!1,a(),s.update(E.OPEN_PLATFORM_ORIGIN+"/mt/templates",{app_id:t.appId,version:"TE002"}),e.once("load",()=>O(this,null,function*(){r=!0,(yield s.getService()).init({appId:t.appId,v:E.VERSION,version:"TE002"})})),p.onSelectTemplate&&n.push(e.add("select.template",p.onSelectTemplate)),s.insert(),new Promise(m=>{n.push(e.once("select.template",c=>m(c))),n.push(e.once("close",()=>m(!1)))})}function d(){e.emit("close"),s.remove()}function y(p){e.add("save",p)}function h(p){e.add("close",p)}function l(p){e.add("editor.load",p)}function f(p){e.add("template.load",p)}return{get isLoad(){return r},openTemplateList:i,close:d,onSave:y,onTemplateLoad:f,onClose:h,onLoad:l,editDesign:u,createDesign:o}}var Z={exports:{}},ye=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)}},ft=ye,U=Object.prototype.toString;function Q(t){return U.call(t)==="[object Array]"}function ee(t){return typeof t=="undefined"}function ht(t){return t!==null&&!ee(t)&&t.constructor!==null&&!ee(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function pt(t){return U.call(t)==="[object ArrayBuffer]"}function mt(t){return typeof FormData!="undefined"&&t instanceof FormData}function vt(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function yt(t){return typeof t=="string"}function gt(t){return typeof t=="number"}function ge(t){return t!==null&&typeof t=="object"}function z(t){if(U.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Et(t){return U.call(t)==="[object Date]"}function wt(t){return U.call(t)==="[object File]"}function Ct(t){return U.call(t)==="[object Blob]"}function Ee(t){return U.call(t)==="[object Function]"}function bt(t){return ge(t)&&Ee(t.pipe)}function Rt(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function It(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Tt(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function te(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Q(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 re(){var t={};function e(a,s){z(t[s])&&z(a)?t[s]=re(t[s],a):z(a)?t[s]=re({},a):Q(a)?t[s]=a.slice():t[s]=a}for(var r=0,n=arguments.length;r<n;r++)te(arguments[r],e);return t}function St(t,e,r){return te(e,function(a,s){r&&typeof a=="function"?t[s]=ft(a,r):t[s]=a}),t}function xt(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var R={isArray:Q,isArrayBuffer:pt,isBuffer:ht,isFormData:mt,isArrayBufferView:vt,isString:yt,isNumber:gt,isObject:ge,isPlainObject:z,isUndefined:ee,isDate:Et,isFile:wt,isBlob:Ct,isFunction:Ee,isStream:bt,isURLSearchParams:Rt,isStandardBrowserEnv:Tt,forEach:te,merge:re,extend:St,trim:It,stripBOM:xt},M=R;function we(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Ce=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,d){i===null||typeof i=="undefined"||(M.isArray(i)?d=d+"[]":i=[i],M.forEach(i,function(h){M.isDate(h)?h=h.toISOString():M.isObject(h)&&(h=JSON.stringify(h)),s.push(we(d)+"="+we(h))}))}),a=s.join("&")}if(a){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e},Ot=R;function q(){this.handlers=[]}q.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},q.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},q.prototype.forEach=function(e){Ot.forEach(this.handlers,function(n){n!==null&&e(n)})};var Pt=q,kt=R,_t=function(e,r){kt.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},At=be,Re=function(e,r,n,a,s){var o=new Error(e);return At(o,r,n,a,s)},$t=Re,Nt=function(e,r,n){var a=n.config.validateStatus;!n.status||!a||a(n.status)?e(n):r($t("Request failed with status code "+n.status,n.config,null,n.request,n))},K=R,Ut=K.isStandardBrowserEnv()?function(){return{write:function(r,n,a,s,o,u){var i=[];i.push(r+"="+encodeURIComponent(n)),K.isNumber(a)&&i.push("expires="+new Date(a).toGMTString()),K.isString(s)&&i.push("path="+s),K.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(){}}}(),Lt=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Mt=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},Dt=Lt,Ft=Mt,Bt=function(e,r){return e&&!Dt(r)?Ft(e,r):r},ne=R,jt=["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"],zt=function(e){var r={},n,a,s;return e&&ne.forEach(e.split(` | ||
`),function(u){if(s=u.indexOf(":"),n=ne.trim(u.substr(0,s)).toLowerCase(),a=ne.trim(u.substr(s+1)),n){if(r[n]&&jt.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([a]):r[n]=r[n]?r[n]+", "+a:a}}),r},Ie=R,qt=Ie.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=Ie.isString(o)?a(o):o;return u.protocol===n.protocol&&u.host===n.host}}():function(){return function(){return!0}}(),H=R,Kt=Nt,Ht=Ut,Vt=Ce,Jt=Bt,Gt=zt,Wt=qt,ae=Re,Te=function(e){return new Promise(function(n,a){var s=e.data,o=e.headers,u=e.responseType;H.isFormData(s)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",y=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(d+":"+y)}var h=Jt(e.baseURL,e.url);i.open(e.method.toUpperCase(),Vt(h,e.params,e.paramsSerializer),!0),i.timeout=e.timeout;function l(){if(!!i){var p="getAllResponseHeaders"in i?Gt(i.getAllResponseHeaders()):null,m=!u||u==="text"||u==="json"?i.responseText:i.response,c={data:m,status:i.status,statusText:i.statusText,headers:p,config:e,request:i};Kt(n,a,c),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(ae("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){a(ae("Network Error",e,null,i)),i=null},i.ontimeout=function(){var m="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(m=e.timeoutErrorMessage),a(ae(m,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",i)),i=null},H.isStandardBrowserEnv()){var f=(e.withCredentials||Wt(h))&&e.xsrfCookieName?Ht.read(e.xsrfCookieName):void 0;f&&(o[e.xsrfHeaderName]=f)}"setRequestHeader"in i&&H.forEach(o,function(m,c){typeof s=="undefined"&&c.toLowerCase()==="content-type"?delete o[c]:i.setRequestHeader(c,m)}),H.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(m){!i||(i.abort(),a(m),i=null)}),s||(s=null),i.send(s)})},w=R,Se=_t,Xt=be,Yt={"Content-Type":"application/x-www-form-urlencoded"};function xe(t,e){!w.isUndefined(t)&&w.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Zt(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=Te),t}function Qt(t,e,r){if(w.isString(t))try{return(e||JSON.parse)(t),w.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var V={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Zt(),transformRequest:[function(e,r){return Se(r,"Accept"),Se(r,"Content-Type"),w.isFormData(e)||w.isArrayBuffer(e)||w.isBuffer(e)||w.isStream(e)||w.isFile(e)||w.isBlob(e)?e:w.isArrayBufferView(e)?e.buffer:w.isURLSearchParams(e)?(xe(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):w.isObject(e)||r&&r["Content-Type"]==="application/json"?(xe(r,"application/json"),Qt(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&&w.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?Xt(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}};V.headers={common:{Accept:"application/json, text/plain, */*"}},w.forEach(["delete","get","head"],function(e){V.headers[e]={}}),w.forEach(["post","put","patch"],function(e){V.headers[e]=w.merge(Yt)});var ie=V,er=R,tr=ie,rr=function(e,r,n){var a=this||tr;return er.forEach(n,function(o){e=o.call(a,e,r)}),e},Oe=function(e){return!!(e&&e.__CANCEL__)},Pe=R,se=rr,nr=Oe,ar=ie;function oe(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var ir=function(e){oe(e),e.headers=e.headers||{},e.data=se.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||ar.adapter;return r(e).then(function(a){return oe(e),a.data=se.call(e,a.data,a.headers,e.transformResponse),a},function(a){return nr(a)||(oe(e),a&&a.response&&(a.response.data=se.call(e,a.response.data,a.response.headers,e.transformResponse))),Promise.reject(a)})},C=R,ke=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,f){return C.isPlainObject(l)&&C.isPlainObject(f)?C.merge(l,f):C.isPlainObject(f)?C.merge({},f):C.isArray(f)?f.slice():f}function d(l){C.isUndefined(r[l])?C.isUndefined(e[l])||(n[l]=i(void 0,e[l])):n[l]=i(e[l],r[l])}C.forEach(a,function(f){C.isUndefined(r[f])||(n[f]=i(void 0,r[f]))}),C.forEach(s,d),C.forEach(o,function(f){C.isUndefined(r[f])?C.isUndefined(e[f])||(n[f]=i(void 0,e[f])):n[f]=i(void 0,r[f])}),C.forEach(u,function(f){f in r?n[f]=i(e[f],r[f]):f in e&&(n[f]=i(void 0,e[f]))});var y=a.concat(s).concat(o).concat(u),h=Object.keys(e).concat(Object.keys(r)).filter(function(f){return y.indexOf(f)===-1});return C.forEach(h,d),n},sr={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"}]},_e=sr,ue={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){ue[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var Ae={},or=_e.version.split(".");function $e(t,e){for(var r=e?e.split("."):or,n=t.split("."),a=0;a<3;a++){if(r[a]>n[a])return!0;if(r[a]<n[a])return!1}return!1}ue.transitional=function(e,r,n){var a=r&&$e(r);function s(o,u){return"[Axios v"+_e.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 ur(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 lr={isOlderVersion:$e,assertOptions:ur,validators:ue},Ne=R,cr=Ce,Ue=Pt,Le=ir,J=ke,Me=lr,D=Me.validators;function F(t){this.defaults=t,this.interceptors={request:new Ue,response:new Ue}}F.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=J(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:D.transitional(D.boolean,"1.0.0"),forcedJSONParsing:D.transitional(D.boolean,"1.0.0"),clarifyTimeoutError:D.transitional(D.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=[Le,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(),y=n.shift();try{i=d(i)}catch(h){y(h);break}}try{o=Le(i)}catch(h){return Promise.reject(h)}for(;s.length;)o=o.then(s.shift(),s.shift());return o},F.prototype.getUri=function(e){return e=J(this.defaults,e),cr(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},Ne.forEach(["delete","get","head","options"],function(e){F.prototype[e]=function(r,n){return this.request(J(n||{},{method:e,url:r,data:(n||{}).data}))}}),Ne.forEach(["post","put","patch"],function(e){F.prototype[e]=function(r,n,a){return this.request(J(a||{},{method:e,url:r,data:n}))}});var dr=F;function le(t){this.message=t}le.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},le.prototype.__CANCEL__=!0;var De=le,fr=De;function G(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 fr(a),e(r.reason))})}G.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},G.source=function(){var e,r=new G(function(a){e=a});return{token:r,cancel:e}};var hr=G,pr=function(e){return function(n){return e.apply(null,n)}},mr=function(e){return typeof e=="object"&&e.isAxiosError===!0},Fe=R,vr=ye,W=dr,yr=ke,gr=ie;function Be(t){var e=new W(t),r=vr(W.prototype.request,e);return Fe.extend(r,W.prototype,e),Fe.extend(r,e),r}var x=Be(gr);x.Axios=W,x.create=function(e){return Be(yr(x.defaults,e))},x.Cancel=De,x.CancelToken=hr,x.isCancel=Oe,x.all=function(e){return Promise.all(e)},x.spread=pr,x.isAxiosError=mr,Z.exports=x,Z.exports.default=x;var Er=Z.exports,wr=Object.defineProperty,Cr=(t,e,r)=>e in t?wr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,br=(t,e,r)=>(Cr(t,typeof e!="symbol"?e+"":e,r),r),ce=(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 Rr{constructor(){br(this,"axios"),this.axios=Er.create({baseURL:E.OPEN_PLATFORM_ORIGIN})}createKoutuRecord(e){return ce(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 ce(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 ce(this,null,function*(){return(yield this.axios.post("/sdk/api/auths",{code:e})).data.access_token})}}var k=(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 Ir(t){const e=new j,r=B({appId:t.appId,container:t.container,methods:{emit(h,...l){return k(this,null,function*(){e.emit(h,...l)})},onload(){e.emit("load")},getUseRightToken(h){return k(this,null,function*(){if(!t.getUseRightCert)return!1;const l=yield t.getUseRightCert(h);return l instanceof Error?{message:l.message}:l})},getUserCode(){return k(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{y()}})},download(h){return k(this,null,function*(){e.emit("save",h)})}}}),n=[];function a(){n.forEach(h=>h()),n.length=0}function s(h){return k(this,null,function*(){return a(),r.update(E.KOUTU_EDITOR_URL,{version:t.authorize?"KE002":"KE001"}),r.insert(),e.once("load",()=>k(this,null,function*(){(yield r.getService()).init({appId:t.appId,v:E.VERSION,version:t.authorize?"KE002":"KE001"});const f=typeof h=="string"?h:yield ve(h);(yield r.getService()).importFile(f)})),new Promise(l=>{n.push(e.once("save",f=>l(f))),n.push(e.once("close",()=>l(!1)))})})}function o(h){return k(this,null,function*(){return S(Number.isInteger(+h),`\u65E0\u6548\u7684ID ${h}`),a(),r.update(E.KOUTU_EDITOR_URL,{id:h,mode:"user",version:t.authorize?"KE002":"KE001"}),r.insert(),e.once("load",()=>k(this,null,function*(){const l=yield r.getService();l.init({appId:t.appId,v:E.VERSION,version:t.authorize?"KE002":"KE001"}),l.openWork(h)})),new Promise(l=>{n.push(e.once("save",f=>l(f))),n.push(e.once("close",()=>l(!1)))})})}function u(h){return k(this,null,function*(){if(S(typeof h=="string","url \u5FC5\u987B\u662F url \u683C\u5F0F"),!t.authorize||!t.getUseRightCert)throw new Error("\u7F3A\u5C11 authorize \u6216\u8005 getUseRightCert \u53C2\u6570");const l=new Rr,f=yield t.authorize(),p=yield l.createAuth(f),m=yield l.createKoutuRecord({token:p,url:h}),c=yield t.getUseRightCert({abilityCode:"KE002",appId:t.appId,workId:m});if(c){if(c instanceof Error)throw c}else throw new Error("\u6CA1\u6709\u6743\u9650");return{result:yield l.koutu({url:h,appId:t.appId,workId:m,abilityCode:"KE002",useCert:c,token:p}),workId:m}})}function i(h){e.add("save",h)}function d(h){e.add("close",h)}function y(){e.emit("close"),r.remove()}return{onSave:i,onClose:d,close:y,koutu:u,editKoutu:o,importImage:s}}var _=(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 Tr(t){const e=new j,r=[];function n(){r.forEach(l=>l()),r.length=0}const a=B({container:t.container,appId:t.appId,methods:{emit(l,...f){return _(this,null,function*(){e.emit(l,...f)})},onload(){e.emit("load")},getUseRightToken(l){return _(this,null,function*(){if(!t.getUseRightCert)return!1;const f=yield t.getUseRightCert(l);return f instanceof Error?{message:f.message}:f})},getUserCode(){return _(this,null,function*(){if(!t.authorize)return!1;try{return yield t.authorize()}catch{d()}})},download(l){return _(this,null,function*(){e.emit("save",l)})}}});function s(l,f){e.on(l,f)}function o(l,f){e.off(l,f)}function u(l){return _(this,arguments,function*(f,p={}){return n(),a.update(E.IMAGE_EDITOR_URL,{version:t.authorize?"IE002":"IE001"}),a.insert(),e.once("load",()=>_(this,null,function*(){(yield a.getService()).init({appId:t.appId,v:E.VERSION,version:t.authorize?"IE002":"IE001",fileTypes:p.fileTypes,disableModules:p.disableModules});const c=yield a.getService(),v=yield Promise.all((Array.isArray(f)?f:[f]).map(g=>_(this,null,function*(){return typeof g=="string"?g:yield ve(g)})));c.importFile(v)})),new Promise(m=>{r.push(e.once("save",c=>m(c))),r.push(e.once("close",()=>m(!1)))})})}function i(l){return _(this,arguments,function*(f,p={}){return n(),a.update(E.IMAGE_EDITOR_URL,{id:f,mode:"user",version:t.authorize?"IE002":"IE001"}),a.insert(),e.once("load",()=>_(this,null,function*(){(yield a.getService()).init({appId:t.appId,v:E.VERSION,version:t.authorize?"IE002":"IE001",fileTypes:p.fileTypes,disableModules:p.disableModules})})),new Promise(m=>{r.push(e.once("save",c=>m(c))),r.push(e.once("close",()=>m(!1)))})})}function d(){e.emit("close"),a.remove()}function y(l){e.add("save",l)}function h(l){e.add("close",l)}return{editImage:i,close:d,onSave:y,onClose:h,importImage:u,on:s,off:o}}T.createImageEditor=Tr,T.createKoutuEditor=Ir,T.createMobileTemplateEditor=dt,T.createTemplateEditor=ct,T.env=E,Object.defineProperty(T,"__esModule",{value:!0}),T[Symbol.toStringTag]="Module"}); | ||
//# sourceMappingURL=editor-sdk.umd.js.map |
{ | ||
"name": "@gaoding/editor-sdk", | ||
"version": "2.1.0", | ||
"version": "2.2.0-alpha.0", | ||
"description": "稿定编辑器对外 SDK", | ||
@@ -29,3 +29,3 @@ "main": "dist/editor-sdk.umd.js", | ||
}, | ||
"gitHead": "5ad9bf615c0566eff550acd1be9354b36ce3bc12" | ||
"gitHead": "fe6db3252749fdf9979d8aa6e9fd492fe90d37c5" | ||
} |
# 稿定开放平台编辑器 SDK | ||
[查看文档](https://open.gaoding.com/docs) | ||
[查看文档](https://open.gaoding.com/docs/pqxi5a) |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
428929
32
3526
2