@gaoding/editor-sdk
Advanced tools
Comparing version 1.5.5 to 2.0.0-alpha.0
@@ -1,10 +0,2 @@ | ||
(function(A,I){typeof exports=="object"&&typeof module!="undefined"?I(exports):typeof define=="function"&&define.amd?define(["exports"],I):(A=typeof globalThis!="undefined"?globalThis:A||self,I(A.gaoding={}))})(this,function(A){"use strict";var I;(function(t){t.Call="call",t.Reply="reply",t.Syn="syn",t.SynAck="synAck",t.Ack="ack"})(I||(I={}));var j;(function(t){t.Fulfilled="fulfilled",t.Rejected="rejected"})(j||(j={}));var q;(function(t){t.ConnectionDestroyed="ConnectionDestroyed",t.ConnectionTimeout="ConnectionTimeout",t.NotInIframe="NotInIframe",t.NoIframeSrc="NoIframeSrc"})(q||(q={}));var ne;(function(t){t.DataCloneError="DataCloneError"})(ne||(ne={}));var $;(function(t){t.Message="message"})($||($={}));var Je=()=>{const t=[];let e=!1;return{destroy(r){e=!0,t.forEach(n=>{n(r)})},onDestroy(r){e?r():t.push(r)}}},Ge=t=>(...e)=>{t&&console.log("[Penpal]",...e)};const We={"http:":"80","https:":"443"},Xe=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,Ye=["file:","data:"];var Ze=t=>{if(t&&Ye.find(a=>t.startsWith(a)))return"null";const e=document.location,r=Xe.exec(t);let n,o,i;r?(n=r[1]?r[1]:e.protocol,o=r[2],i=r[4]):(n=e.protocol,o=e.hostname,i=e.port);const u=i&&i!==We[n]?`:${i}`:"";return`${n}//${o}${u}`};const ye=({name:t,message:e,stack:r})=>({name:t,message:e,stack:r}),Qe=t=>{const e=new Error;return Object.keys(t).forEach(r=>e[r]=t[r]),e};var et=(t,e,r)=>{const{localName:n,local:o,remote:i,originForSending:u,originForReceiving:a}=t;let s=!1;const d=y=>{if(y.source!==i||y.data.penpal!==I.Call)return;if(y.origin!==a){r(`${n} received message from origin ${y.origin} which did not match expected origin ${a}`);return}const l=y.data,{methodName:c,args:f,id:w}=l;r(`${n}: Received ${c}() call`);const h=E=>C=>{if(r(`${n}: Sending ${c}() reply`),s){r(`${n}: Unable to send ${c}() reply due to destroyed connection`);return}const v={penpal:I.Reply,id:w,resolution:E,returnValue:C};E===j.Rejected&&C instanceof Error&&(v.returnValue=ye(C),v.returnValueIsError=!0);try{i.postMessage(v,u)}catch(g){if(g.name===ne.DataCloneError){const p={penpal:I.Reply,id:w,resolution:j.Rejected,returnValue:ye(g),returnValueIsError:!0};i.postMessage(p,u)}throw g}};new Promise(E=>E(e[c].apply(e,f))).then(h(j.Fulfilled),h(j.Rejected))};return o.addEventListener($.Message,d),()=>{s=!0,o.removeEventListener($.Message,d)}};let tt=0;var rt=()=>++tt,nt=(t,e,r,n,o)=>{const{localName:i,local:u,remote:a,originForSending:s,originForReceiving:d}=e;let y=!1;o(`${i}: Connecting call sender`);const l=c=>(...f)=>{o(`${i}: Sending ${c}() call`);let w;try{a.closed&&(w=!0)}catch{w=!0}if(w&&n(),y){const h=new Error(`Unable to send ${c}() call due to destroyed connection`);throw h.code=q.ConnectionDestroyed,h}return new Promise((h,E)=>{const C=rt(),v=p=>{if(p.source!==a||p.data.penpal!==I.Reply||p.data.id!==C)return;if(p.origin!==d){o(`${i} received message from origin ${p.origin} which did not match expected origin ${d}`);return}const m=p.data;o(`${i}: Received ${c}() reply`),u.removeEventListener($.Message,v);let P=m.returnValue;m.returnValueIsError&&(P=Qe(P)),(m.resolution===j.Fulfilled?h:E)(P)};u.addEventListener($.Message,v);const g={penpal:I.Call,id:C,methodName:c,args:f};a.postMessage(g,s)})};return r.reduce((c,f)=>(c[f]=l(f),c),t),()=>{y=!0}},ot=(t,e,r,n,o)=>{const{destroy:i,onDestroy:u}=n;let a,s;const d={};return y=>{if(y.origin!==e){o(`Parent: Handshake - Received ACK message from origin ${y.origin} which did not match expected origin ${e}`);return}o("Parent: Handshake - Received ACK");const l={localName:"Parent",local:window,remote:y.source,originForSending:r,originForReceiving:e};a&&a(),a=et(l,t,o),u(a),s&&s.forEach(f=>{delete d[f]}),s=y.data.methodNames;const c=nt(d,l,s,i,o);return u(c),d}},st=(t,e,r,n)=>o=>{if(o.origin!==r){t(`Parent: Handshake - Received SYN message from origin ${o.origin} which did not match expected origin ${r}`);return}t("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:I.SynAck,methodNames:Object.keys(e)};o.source.postMessage(i,n)};const it=6e4;var at=(t,e)=>{const{destroy:r,onDestroy:n}=e,o=setInterval(()=>{t.isConnected||(clearInterval(o),r())},it);n(()=>{clearInterval(o)})},ut=(t,e)=>{let r;return t!==void 0&&(r=window.setTimeout(()=>{const n=new Error(`Connection timed out after ${t}ms`);n.code=q.ConnectionTimeout,e(n)},t)),()=>{clearTimeout(r)}},lt=t=>{if(!t.src&&!t.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=q.NoIframeSrc,e}},L=t=>{let{iframe:e,methods:r={},childOrigin:n,timeout:o,debug:i=!1}=t;const u=Ge(i),a=Je(),{onDestroy:s,destroy:d}=a;n||(lt(e),n=Ze(e.src));const y=n==="null"?"*":n,l=st(u,r,n,y),c=ot(r,n,y,a,u);return{promise:new Promise((w,h)=>{const E=ut(o,d),C=v=>{if(!(v.source!==e.contentWindow||!v.data)){if(v.data.penpal===I.Syn){l(v);return}if(v.data.penpal===I.Ack){const g=c(v);g&&(E(),w(g));return}}};window.addEventListener($.Message,C),u("Parent: Awaiting handshake"),at(e,a),s(v=>{window.removeEventListener($.Message,C),v||(v=new Error("Connection destroyed"),v.code=q.ConnectionDestroyed),h(v)})}),destroy(){d()}}},ct=(t,e,r)=>new Promise((n,o)=>{var i=s=>{try{a(r.next(s))}catch(d){o(d)}},u=s=>{try{a(r.throw(s))}catch(d){o(d)}},a=s=>s.done?n(s.value):Promise.resolve(s.value).then(i,u);a((r=r.apply(t,e)).next())});function M(t,e,r){const n=document.createElement("iframe");n.style.cssText=` | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
`,n.referrerPolicy="strict-origin-when-cross-origin",n.className="gaoding-iframe",n.setAttribute("frameborder","0"),n.src=`${t}?${Object.entries(e).filter(([a,s])=>s!==void 0).map(([a,s])=>`${a}=${s}`).join("&")}`;let o;try{o=typeof r=="string"?document.body.querySelector(r):r}catch{throw new Error(`container \u914D\u7F6E\u7684\u300Ccss\u7B5B\u9009\u5668\u300D\u65E0\u6548 "${r}"`)}if(!o)throw new Error(`\u65E0\u6548\u7684 container \u914D\u7F6E ${r}`);function i(){o.appendChild(n)}function u(){o==null||o.removeChild(n)}return{open:i,close:u,iframe:n}}function N(t,e,r,n=!1){const o=document.createElement("iframe");o.style.cssText=` | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
`,o.referrerPolicy="strict-origin-when-cross-origin",o.setAttribute("frameborder","0"),o.src=`${t}?${Object.entries(e).filter(([h,E])=>E!==void 0).map(([h,E])=>`${h}=${E}`).join("&")}`;const i=document.createElement("div");i.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 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=` | ||
position: relative; | ||
@@ -18,3 +10,3 @@ width: calc(100vw - 100px); | ||
display: block; | ||
`,n&&(i.style.visibility="hidden");const u=document.createElement("div");u.style.cssText=` | ||
`;const n=document.createElement("div");n.style.cssText=` | ||
font-size: 13px; | ||
@@ -32,3 +24,3 @@ width: 42px; | ||
justify-content: center; | ||
`;const a=document.createElement("img");a.src="https://st-gdx.dancf.com/gaodingx/34555636/design/20190509-142237-249d.png",a.style.cssText="display: block; width: 24px;",u.appendChild(a);const s=document.createElement("div");s.style.cssText=` | ||
`;const a=document.createElement("img");a.src="https://st-gdx.dancf.com/gaodingx/34555636/design/20190509-142237-249d.png",a.style.cssText="display: block; width: 24px;",n.appendChild(a);const s=document.createElement("div");s.style.cssText=` | ||
position: fixed; | ||
@@ -40,3 +32,3 @@ left: 0px; | ||
z-index: 1000; | ||
`,s.className="gaoding-editor-iframe-dialog",i.appendChild(u),i.appendChild(o),s.appendChild(i),i.appendChild(o);const d=document.createElement("div");n||(d.style.cssText=` | ||
`,s.className="gaoding-editor-iframe-dialog",r.appendChild(n),r.appendChild(t),s.appendChild(r),r.appendChild(t);const o=document.createElement("div");o.style.cssText=` | ||
position: fixed; | ||
@@ -47,3 +39,8 @@ inset: 0px; | ||
opacity: 0.5; | ||
`);let y=!1,l="";function c(){n||!document.querySelector(".gaoding-editor-iframe-dialog")||(y?(l=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden"):document.documentElement.style.overflow=l)}function f(){return ct(this,null,function*(){var h,E;r&&(yield r())===!1||(y=!1,c(),(h=d.parentElement)==null||h.removeChild(d),(E=s.parentElement)==null||E.removeChild(s))})}function w(){y=!0,document.body.appendChild(d),document.body.appendChild(s),c()}return u.addEventListener("click",f),{iframe:o,open:w,close:f}}function V(t,e){if(!t)throw new Error(e)}const T={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"};var dt=Object.defineProperty,ft=Object.defineProperties,pt=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable,Ee=(t,e,r)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,J=(t,e)=>{for(var r in e||(e={}))ht.call(e,r)&&Ee(t,r,e[r]);if(ge)for(var r of ge(e))mt.call(e,r)&&Ee(t,r,e[r]);return t},G=(t,e)=>ft(t,pt(e)),b=(t,e,r)=>new Promise((n,o)=>{var i=s=>{try{a(r.next(s))}catch(d){o(d)}},u=s=>{try{a(r.throw(s))}catch(d){o(d)}},a=s=>s.done?n(s.value):Promise.resolve(s.value).then(i,u);a((r=r.apply(t,e)).next())});const vt={okText:"\u4FDD\u5B58",exportTypes:void 0,disableModules:[],autoClose:!0};function U(t){return"version"in t&&t.version==="TE002"}function yt(t){var e,r;const n=Object.assign({},vt,t);V(!!(t==null?void 0:t.appId),"\u7F3A\u5C11 appId \u53C2\u6570");const o={app_id:n.appId,version:U(n)?n.version:"TE001",buttonText:n.okText,exportTypes:(e=n.exportTypes)==null?void 0:e.join(","),filterPaidMaterial:n.filterPaidMaterial,disableModules:["vip"].concat((r=n.disableModules)!=null?r:[]).join(",")};let i=()=>{};function u(l){return b(this,null,function*(){let c="";return U(n)&&(c=yield n.getUserCode()),new Promise((f,w)=>{const h=Object.assign({version:"TE001"},o,{id:l.id,thirdCateId:l.categoryId}),E=l.container||n.container,{open:C,iframe:v,close:g}=E?M(T.TEMPLATE_EDITOR_URL,h,E):N(T.TEMPLATE_EDITOR_URL,h,()=>b(this,null,function*(){if(n.onCloseModal&&(yield n.onCloseModal())===!1)return!1;f(!1)}));C();const p=L({iframe:v,methods:{onload(){return b(this,null,function*(){const m=yield p.promise;m.init(G(J({},h),{appId:n.appId})),l.onload&&l.onload(m)})},onTemplateLoad(){return b(this,null,function*(){const m=yield p.promise;l.onTemplateLoad&&l.onTemplateLoad(m)})},getUseRightToken(m){return b(this,null,function*(){const P=U(n)?yield n.getUseRightToken(m):!0;return P instanceof Error?{message:P.message}:P})},getUserCode(){return b(this,null,function*(){if(c){const m=c;return c="",m}try{return U(n)?n.getUserCode():!1}catch(m){w(m),g()}})},download(m){return b(this,null,function*(){f(m),n.autoClose&&(g(),p.destroy())})}}});i=()=>{f(!1),g(),p.destroy()}})})}function a(){return b(this,arguments,function*(l={}){return new Promise((c,f)=>{const w=Object.assign({version:"TE001"},o),h=n.container,{open:E,iframe:C,close:v}=h?M(T.OPEN_PLATFORM_ORIGIN+"/template/search",w,h):N(T.OPEN_PLATFORM_ORIGIN+"/template/search",w,()=>b(this,null,function*(){if(n.onCloseModal&&(yield n.onCloseModal())===!1)return!1;c(!1)}));E();const g=L({iframe:C,methods:{onload(){return b(this,null,function*(){const p=yield g.promise;p.init(G(J({},w),{appId:n.appId})),l.onload&&l.onload(p)})},onSelectTemplate(p){return b(this,null,function*(){if(l.onSelectTemplate)return l.onSelectTemplate(p)})},onTemplateLoad(){return b(this,null,function*(){const p=yield g.promise;l.onTemplateLoad&&l.onTemplateLoad(p)})},getUseRightToken(p){return b(this,null,function*(){const m=U(n)?yield n.getUseRightToken(p):!0;return m instanceof Error?{message:m.message}:m})},getUserCode(){return b(this,null,function*(){try{return U(n)?n.getUserCode():!1}catch(p){f(p),v()}})},download(p){return b(this,null,function*(){c(p),n.autoClose&&(v(),g.destroy())})}}});i=()=>{c(!1),v(),g.destroy()}})})}function s(l){return b(this,null,function*(){V(!!(l==null?void 0:l.categoryId)||!!(l==null?void 0:l.id),"openTemplate \u7F3A\u5C11 id \u6216\u8005 categoryId \u53C2\u6570");let c="";return U(n)&&(c=yield n.getUserCode()),new Promise((f,w)=>{const h=Object.assign({version:"TE001"},o,{id:l.id,mode:"user",thirdCateId:l.categoryId}),E=l.container||n.container,{open:C,iframe:v,close:g}=E?M(T.TEMPLATE_EDITOR_URL,h,E):N(T.TEMPLATE_EDITOR_URL,h,()=>b(this,null,function*(){if(n.onCloseModal&&(yield n.onCloseModal())===!1)return!1;f(!1)}));C();const p=L({iframe:v,methods:{onload(){return b(this,null,function*(){const m=yield p.promise;m.init(G(J({},h),{appId:n.appId})),l.onload&&l.onload(m)})},onTemplateLoad(){return b(this,null,function*(){const m=yield p.promise;l.onTemplateLoad&&l.onTemplateLoad(m)})},getUseRightToken(m){return b(this,null,function*(){const P=U(n)?yield n.getUseRightToken(m):!0;return P instanceof Error?{message:P.message}:P})},getUserCode(){return b(this,null,function*(){if(c){const m=c;return c="",m}try{return U(n)?n.getUserCode():!1}catch(m){w(m),g()}})},download(m){return b(this,null,function*(){f(m),n.autoClose&&(g(),p.destroy())})}}});i=()=>{f(!1),g(),p.destroy()}})})}function d(){return b(this,arguments,function*(l={}){return new Promise((c,f)=>{const w=Object.assign({version:"TE001"},o,{thirdCateId:l.categoryId,mode:"create",width:l.width,height:l.height}),h=l.container||n.container,{open:E,iframe:C,close:v}=l.container?M(T.TEMPLATE_EDITOR_URL,w,h):N(T.TEMPLATE_EDITOR_URL,w,()=>b(this,null,function*(){if(n.onCloseModal&&(yield n.onCloseModal())===!1)return!1;c(!1)})),g=L({iframe:C,methods:{onload(){return b(this,null,function*(){const p=yield g.promise;p.init(G(J({},w),{appId:n.appId})),l.onload&&l.onload(p)})},onTemplateLoad(){return b(this,null,function*(){const p=yield g.promise;l.onTemplateLoad&&l.onTemplateLoad(p)})},getUseRightToken(p){return b(this,null,function*(){const m=U(n)?yield n.getUseRightToken(p):!0;return m instanceof Error?{message:m.message}:m})},getUserCode(){return b(this,null,function*(){try{return U(n)?n.getUserCode():!1}catch(p){f(p),v()}})},download(p){return b(this,null,function*(){c(p),n.autoClose&&(v(),g.destroy())})}}});E(),i=()=>{c(!1),v(),g.destroy()}})})}function y(){i(),i=()=>{}}return{close:y,openUserRecord:s,editTemplate:s,create:d,openTemplateList:a,openTemplate:u}}var we=(t,e,r)=>new Promise((n,o)=>{var i=s=>{try{a(r.next(s))}catch(d){o(d)}},u=s=>{try{a(r.throw(s))}catch(d){o(d)}},a=s=>s.done?n(s.value):Promise.resolve(s.value).then(i,u);a((r=r.apply(t,e)).next())});function Ce(t){return we(this,null,function*(){const e=t instanceof File?t.name:`${t.type}`;return new File([yield t.arrayBuffer()],e,{type:t.type})})}function be(t){return Object.keys(t).reduce((e,r)=>(e[r]=function(...n){return we(this,null,function*(){try{return yield t[r](...n)}catch(o){return{type:"error",message:o.message}}})},e),{})}var oe={exports:{}},Te=function(e,r){return function(){for(var o=new Array(arguments.length),i=0;i<o.length;i++)o[i]=arguments[i];return e.apply(r,o)}},gt=Te,F=Object.prototype.toString;function se(t){return F.call(t)==="[object Array]"}function ie(t){return typeof t=="undefined"}function Et(t){return t!==null&&!ie(t)&&t.constructor!==null&&!ie(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function wt(t){return F.call(t)==="[object ArrayBuffer]"}function Ct(t){return typeof FormData!="undefined"&&t instanceof FormData}function bt(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function Tt(t){return typeof t=="string"}function Rt(t){return typeof t=="number"}function Re(t){return t!==null&&typeof t=="object"}function W(t){if(F.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Ot(t){return F.call(t)==="[object Date]"}function kt(t){return F.call(t)==="[object File]"}function It(t){return F.call(t)==="[object Blob]"}function Oe(t){return F.call(t)==="[object Function]"}function _t(t){return Re(t)&&Oe(t.pipe)}function xt(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function Pt(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Ut(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function ae(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),se(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.call(null,t[o],o,t)}function ue(){var t={};function e(o,i){W(t[i])&&W(o)?t[i]=ue(t[i],o):W(o)?t[i]=ue({},o):se(o)?t[i]=o.slice():t[i]=o}for(var r=0,n=arguments.length;r<n;r++)ae(arguments[r],e);return t}function St(t,e,r){return ae(e,function(o,i){r&&typeof o=="function"?t[i]=gt(o,r):t[i]=o}),t}function At(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}var _={isArray:se,isArrayBuffer:wt,isBuffer:Et,isFormData:Ct,isArrayBufferView:bt,isString:Tt,isNumber:Rt,isObject:Re,isPlainObject:W,isUndefined:ie,isDate:Ot,isFile:kt,isBlob:It,isFunction:Oe,isStream:_t,isURLSearchParams:xt,isStandardBrowserEnv:Ut,forEach:ae,merge:ue,extend:St,trim:Pt,stripBOM:At},K=_;function ke(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Ie=function(e,r,n){if(!r)return e;var o;if(n)o=n(r);else if(K.isURLSearchParams(r))o=r.toString();else{var i=[];K.forEach(r,function(s,d){s===null||typeof s=="undefined"||(K.isArray(s)?d=d+"[]":s=[s],K.forEach(s,function(l){K.isDate(l)?l=l.toISOString():K.isObject(l)&&(l=JSON.stringify(l)),i.push(ke(d)+"="+ke(l))}))}),o=i.join("&")}if(o){var u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e},$t=_;function X(){this.handlers=[]}X.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},X.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},X.prototype.forEach=function(e){$t.forEach(this.handlers,function(n){n!==null&&e(n)})};var Lt=X,Mt=_,Nt=function(e,r){Mt.forEach(e,function(o,i){i!==r&&i.toUpperCase()===r.toUpperCase()&&(e[r]=o,delete e[i])})},_e=function(e,r,n,o,i){return e.config=r,n&&(e.code=n),e.request=o,e.response=i,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},Dt=_e,xe=function(e,r,n,o,i){var u=new Error(e);return Dt(u,r,n,o,i)},jt=xe,Ft=function(e,r,n){var o=n.config.validateStatus;!n.status||!o||o(n.status)?e(n):r(jt("Request failed with status code "+n.status,n.config,null,n.request,n))},Y=_,Bt=Y.isStandardBrowserEnv()?function(){return{write:function(r,n,o,i,u,a){var s=[];s.push(r+"="+encodeURIComponent(n)),Y.isNumber(o)&&s.push("expires="+new Date(o).toGMTString()),Y.isString(i)&&s.push("path="+i),Y.isString(u)&&s.push("domain="+u),a===!0&&s.push("secure"),document.cookie=s.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(){}}}(),qt=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Kt=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e},Ht=qt,zt=Kt,Vt=function(e,r){return e&&!Ht(r)?zt(e,r):r},le=_,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"],Gt=function(e){var r={},n,o,i;return e&&le.forEach(e.split(` | ||
`),function(a){if(i=a.indexOf(":"),n=le.trim(a.substr(0,i)).toLowerCase(),o=le.trim(a.substr(i+1)),n){if(r[n]&&Jt.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([o]):r[n]=r[n]?r[n]+", "+o:o}}),r},Pe=_,Wt=Pe.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function o(i){var u=i;return e&&(r.setAttribute("href",u),u=r.href),r.setAttribute("href",u),{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=o(window.location.href),function(u){var a=Pe.isString(u)?o(u):u;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}(),Z=_,Xt=Ft,Yt=Bt,Zt=Ie,Qt=Vt,er=Gt,tr=Wt,ce=xe,Ue=function(e){return new Promise(function(n,o){var i=e.data,u=e.headers,a=e.responseType;Z.isFormData(i)&&delete u["Content-Type"];var s=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",y=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";u.Authorization="Basic "+btoa(d+":"+y)}var l=Qt(e.baseURL,e.url);s.open(e.method.toUpperCase(),Zt(l,e.params,e.paramsSerializer),!0),s.timeout=e.timeout;function c(){if(!!s){var w="getAllResponseHeaders"in s?er(s.getAllResponseHeaders()):null,h=!a||a==="text"||a==="json"?s.responseText:s.response,E={data:h,status:s.status,statusText:s.statusText,headers:w,config:e,request:s};Xt(n,o,E),s=null}}if("onloadend"in s?s.onloadend=c:s.onreadystatechange=function(){!s||s.readyState!==4||s.status===0&&!(s.responseURL&&s.responseURL.indexOf("file:")===0)||setTimeout(c)},s.onabort=function(){!s||(o(ce("Request aborted",e,"ECONNABORTED",s)),s=null)},s.onerror=function(){o(ce("Network Error",e,null,s)),s=null},s.ontimeout=function(){var h="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(h=e.timeoutErrorMessage),o(ce(h,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",s)),s=null},Z.isStandardBrowserEnv()){var f=(e.withCredentials||tr(l))&&e.xsrfCookieName?Yt.read(e.xsrfCookieName):void 0;f&&(u[e.xsrfHeaderName]=f)}"setRequestHeader"in s&&Z.forEach(u,function(h,E){typeof i=="undefined"&&E.toLowerCase()==="content-type"?delete u[E]:s.setRequestHeader(E,h)}),Z.isUndefined(e.withCredentials)||(s.withCredentials=!!e.withCredentials),a&&a!=="json"&&(s.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&s.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&s.upload&&s.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(h){!s||(s.abort(),o(h),s=null)}),i||(i=null),s.send(i)})},R=_,Se=Nt,rr=_e,nr={"Content-Type":"application/x-www-form-urlencoded"};function Ae(t,e){!R.isUndefined(t)&&R.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function or(){var t;return(typeof XMLHttpRequest!="undefined"||typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]")&&(t=Ue),t}function sr(t,e,r){if(R.isString(t))try{return(e||JSON.parse)(t),R.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:or(),transformRequest:[function(e,r){return Se(r,"Accept"),Se(r,"Content-Type"),R.isFormData(e)||R.isArrayBuffer(e)||R.isBuffer(e)||R.isStream(e)||R.isFile(e)||R.isBlob(e)?e:R.isArrayBufferView(e)?e.buffer:R.isURLSearchParams(e)?(Ae(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):R.isObject(e)||r&&r["Content-Type"]==="application/json"?(Ae(r,"application/json"),sr(e)):e}],transformResponse:[function(e){var r=this.transitional,n=r&&r.silentJSONParsing,o=r&&r.forcedJSONParsing,i=!n&&this.responseType==="json";if(i||o&&R.isString(e)&&e.length)try{return JSON.parse(e)}catch(u){if(i)throw u.name==="SyntaxError"?rr(u,this,"E_JSON_PARSE"):u}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, */*"}},R.forEach(["delete","get","head"],function(e){Q.headers[e]={}}),R.forEach(["post","put","patch"],function(e){Q.headers[e]=R.merge(nr)});var de=Q,ir=_,ar=de,ur=function(e,r,n){var o=this||ar;return ir.forEach(n,function(u){e=u.call(o,e,r)}),e},$e=function(e){return!!(e&&e.__CANCEL__)},Le=_,fe=ur,lr=$e,cr=de;function pe(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var dr=function(e){pe(e),e.headers=e.headers||{},e.data=fe.call(e,e.data,e.headers,e.transformRequest),e.headers=Le.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Le.forEach(["delete","get","head","post","put","patch","common"],function(o){delete e.headers[o]});var r=e.adapter||cr.adapter;return r(e).then(function(o){return pe(e),o.data=fe.call(e,o.data,o.headers,e.transformResponse),o},function(o){return lr(o)||(pe(e),o&&o.response&&(o.response.data=fe.call(e,o.response.data,o.response.headers,e.transformResponse))),Promise.reject(o)})},O=_,Me=function(e,r){r=r||{};var n={},o=["url","method","data"],i=["headers","auth","proxy","params"],u=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function s(c,f){return O.isPlainObject(c)&&O.isPlainObject(f)?O.merge(c,f):O.isPlainObject(f)?O.merge({},f):O.isArray(f)?f.slice():f}function d(c){O.isUndefined(r[c])?O.isUndefined(e[c])||(n[c]=s(void 0,e[c])):n[c]=s(e[c],r[c])}O.forEach(o,function(f){O.isUndefined(r[f])||(n[f]=s(void 0,r[f]))}),O.forEach(i,d),O.forEach(u,function(f){O.isUndefined(r[f])?O.isUndefined(e[f])||(n[f]=s(void 0,e[f])):n[f]=s(void 0,r[f])}),O.forEach(a,function(f){f in r?n[f]=s(e[f],r[f]):f in e&&(n[f]=s(void 0,e[f]))});var y=o.concat(i).concat(u).concat(a),l=Object.keys(e).concat(Object.keys(r)).filter(function(f){return y.indexOf(f)===-1});return O.forEach(l,d),n},fr={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"}]},Ne=fr,he={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){he[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var De={},pr=Ne.version.split(".");function je(t,e){for(var r=e?e.split("."):pr,n=t.split("."),o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]<n[o])return!1}return!1}he.transitional=function(e,r,n){var o=r&&je(r);function i(u,a){return"[Axios v"+Ne.version+"] Transitional option '"+u+"'"+a+(n?". "+n:"")}return function(u,a,s){if(e===!1)throw new Error(i(a," has been removed in "+r));return o&&!De[a]&&(De[a]=!0,console.warn(i(a," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(u,a,s):!0}};function hr(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),o=n.length;o-- >0;){var i=n[o],u=e[i];if(u){var a=t[i],s=a===void 0||u(a,i,t);if(s!==!0)throw new TypeError("option "+i+" must be "+s);continue}if(r!==!0)throw Error("Unknown option "+i)}}var mr={isOlderVersion:je,assertOptions:hr,validators:he},Fe=_,vr=Ie,Be=Lt,qe=dr,ee=Me,Ke=mr,H=Ke.validators;function z(t){this.defaults=t,this.interceptors={request:new Be,response:new Be}}z.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=ee(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&&Ke.assertOptions(r,{silentJSONParsing:H.transitional(H.boolean,"1.0.0"),forcedJSONParsing:H.transitional(H.boolean,"1.0.0"),clarifyTimeoutError:H.transitional(H.boolean,"1.0.0")},!1);var n=[],o=!0;this.interceptors.request.forEach(function(c){typeof c.runWhen=="function"&&c.runWhen(e)===!1||(o=o&&c.synchronous,n.unshift(c.fulfilled,c.rejected))});var i=[];this.interceptors.response.forEach(function(c){i.push(c.fulfilled,c.rejected)});var u;if(!o){var a=[qe,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(i),u=Promise.resolve(e);a.length;)u=u.then(a.shift(),a.shift());return u}for(var s=e;n.length;){var d=n.shift(),y=n.shift();try{s=d(s)}catch(l){y(l);break}}try{u=qe(s)}catch(l){return Promise.reject(l)}for(;i.length;)u=u.then(i.shift(),i.shift());return u},z.prototype.getUri=function(e){return e=ee(this.defaults,e),vr(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},Fe.forEach(["delete","get","head","options"],function(e){z.prototype[e]=function(r,n){return this.request(ee(n||{},{method:e,url:r,data:(n||{}).data}))}}),Fe.forEach(["post","put","patch"],function(e){z.prototype[e]=function(r,n,o){return this.request(ee(o||{},{method:e,url:r,data:n}))}});var yr=z;function me(t){this.message=t}me.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},me.prototype.__CANCEL__=!0;var He=me,gr=He;function te(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(o){e=o});var r=this;t(function(o){r.reason||(r.reason=new gr(o),e(r.reason))})}te.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},te.source=function(){var e,r=new te(function(o){e=o});return{token:r,cancel:e}};var Er=te,wr=function(e){return function(n){return e.apply(null,n)}},Cr=function(e){return typeof e=="object"&&e.isAxiosError===!0},ze=_,br=Te,re=yr,Tr=Me,Rr=de;function Ve(t){var e=new re(t),r=br(re.prototype.request,e);return ze.extend(r,re.prototype,e),ze.extend(r,e),r}var S=Ve(Rr);S.Axios=re,S.create=function(e){return Ve(Tr(S.defaults,e))},S.Cancel=He,S.CancelToken=Er,S.isCancel=$e,S.all=function(e){return Promise.all(e)},S.spread=wr,S.isAxiosError=Cr,oe.exports=S,oe.exports.default=S;var Or=oe.exports,kr=Object.defineProperty,Ir=(t,e,r)=>e in t?kr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_r=(t,e,r)=>(Ir(t,typeof e!="symbol"?e+"":e,r),r),ve=(t,e,r)=>new Promise((n,o)=>{var i=s=>{try{a(r.next(s))}catch(d){o(d)}},u=s=>{try{a(r.throw(s))}catch(d){o(d)}},a=s=>s.done?n(s.value):Promise.resolve(s.value).then(i,u);a((r=r.apply(t,e)).next())});class xr{constructor(){_r(this,"axios"),this.axios=Or.create({baseURL:T.OPEN_PLATFORM_ORIGIN})}createKoutuRecord(e){return ve(this,null,function*(){const r=e.url,n=yield this.axios.get(r,{responseType:"arraybuffer"}).then(a=>a.data),{width:o,height:i}=yield new Promise(a=>{const s=document.createElement("img");s.src=r,s.onload=()=>{a({width:s.width,height:s.height})}});return(yield this.axios.post("/sdk/api/koutu-records",{url:r,size:n.byteLength,width:o,height:i},{headers:{authorization:`Bearer ${e.token}`}})).data.work_id})}koutu(e){return ve(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 ve(this,null,function*(){return(yield this.axios.post("/sdk/api/auths",{code:e})).data.access_token})}}var k=(t,e,r)=>new Promise((n,o)=>{var i=s=>{try{a(r.next(s))}catch(d){o(d)}},u=s=>{try{a(r.throw(s))}catch(d){o(d)}},a=s=>s.done?n(s.value):Promise.resolve(s.value).then(i,u);a((r=r.apply(t,e)).next())});function D(t){return t.version==="KE002"}const Pr={autoClose:!0};function Ur(t){const e=Object.assign({},Pr,t),r=new xr;V(!!(e==null?void 0:e.appId),"\u7F3A\u5C11 appId \u53C2\u6570");let n=()=>{};function o(s){return k(this,arguments,function*(d,y={}){let l="";return D(e)&&(l=yield e.getUserCode()),new Promise((c,f)=>k(this,null,function*(){const w=y.container||t.container,{open:h,close:E,iframe:C}=w?M(T.KOUTU_EDITOR_URL,{app_id:e.appId,version:e.version||"KE001"},w):N(`${T.KOUTU_EDITOR_URL}`,{app_id:e.appId,version:e.version||"KE001"},()=>k(this,null,function*(){if(e.onCloseModal&&(yield e.onCloseModal())===!1)return!1;c(!1)})),v=L({iframe:C,methods:be({onload(){return k(this,null,function*(){(yield v.promise).init({version:D(e)?e.version:"KE001",appId:e.appId})})},getUseRightToken(m){return k(this,null,function*(){return D(e)?yield e.getUseRightToken(m):!1})},getUserCode(){return k(this,null,function*(){try{if(l){const m=l;return l="",m}return D(e)?yield e.getUserCode():!1}catch(m){f(m),E()}})},download(m){return k(this,null,function*(){c(m),e.autoClose&&(E(),v.destroy())})}})});n=()=>{c(!1),E(),v.destroy()},h();const g=yield v.promise,p=typeof d=="string"?d:yield Ce(d);g.importFile(p)}))})}function i(s){return k(this,null,function*(){if(!D(e))throw new Error("\u81EA\u52A8\u62A0\u56FE\u4E0D\u652F\u6301\u57FA\u7840\u7248\u4F7F\u7528");const d=yield e.getUserCode(),y=yield r.createAuth(d),l=yield r.createKoutuRecord({token:y,url:s}),c=yield e.getUseRightToken({abilityCode:e.version,appId:e.appId,workId:l,useKey:e.version});if(c){if(c instanceof Error)throw c}else throw new Error("\u6CA1\u6709\u6743\u9650");return{result:yield r.koutu({url:s,appId:e.appId,workId:l,abilityCode:e.version,useCert:c,token:y}),workId:l}})}function u(s){return k(this,arguments,function*(d,y={}){return new Promise((l,c)=>k(this,null,function*(){const f=y.container||y.container,{open:w,close:h,iframe:E}=f?M(T.KOUTU_EDITOR_URL,{app_id:e.appId,version:e.version||"KE001",id:d},f):N(`${T.KOUTU_EDITOR_URL}`,{app_id:e.appId,version:e.version||"KE001",id:d},()=>k(this,null,function*(){if(e.onCloseModal&&(yield e.onCloseModal())===!1)return!1;l(!1)})),C=L({iframe:E,methods:be({onload(){return k(this,null,function*(){(yield C.promise).init({version:D(e)?e.version:"KE001",appId:e.appId})})},getUseRightToken(g){return k(this,null,function*(){return D(e)?yield e.getUseRightToken(g):!1})},getUserCode(){return k(this,null,function*(){try{return D(e)?e.getUserCode():!1}catch(g){c(g),h()}})},download(g){return k(this,null,function*(){l(g),e.autoClose&&(h(),C.destroy())})}})});w(),n=()=>{l(!1),h(),C.destroy()},(yield C.promise).openWork(d)}))})}function a(){n(),n=()=>{}}return{close:a,importFile:o,openUserRecord:u,openWork:u,ediotKoutu:u,koutu:i,autoKoutu:i}}var x=(t,e,r)=>new Promise((n,o)=>{var i=s=>{try{a(r.next(s))}catch(d){o(d)}},u=s=>{try{a(r.throw(s))}catch(d){o(d)}},a=s=>s.done?n(s.value):Promise.resolve(s.value).then(i,u);a((r=r.apply(t,e)).next())});const Sr={autoClose:!0};function B(t){return t.version==="IE002"}function Ar(t){const e=Object.assign({},Sr,t);V(!!(t==null?void 0:t.appId),"\u7F3A\u5C11 appId \u53C2\u6570");const r={version:B(e)?e.version:"IE001",appId:e.appId};let n=()=>{};function o(a){return x(this,arguments,function*(s,d={}){let y="";return B(e)&&(y=yield e.getUserCode()),new Promise((l,c)=>x(this,null,function*(){const f=d.container||t.container,{open:w,close:h,iframe:E}=f?M(T.IMAGE_EDITOR_URL,{app_id:e.appId,version:e.version||"IE001"},f):N(`${T.IMAGE_EDITOR_URL}`,{app_id:e.appId,version:e.version||"IE001"},()=>x(this,null,function*(){if(e.onCloseModal&&(yield e.onCloseModal())===!1)return!1;l(!1)})),C=L({iframe:E,methods:{onload(){return x(this,null,function*(){(yield C.promise).init(r)})},getUseRightToken(p){return x(this,null,function*(){const m=B(e)?yield e.getUseRightToken(p):!0;return m instanceof Error?{message:m.message}:m})},getUserCode(){return x(this,null,function*(){if(y){const p=y;return y="",p}try{return B(e)?e.getUserCode():!1}catch(p){c(p),h()}})},download(p){l(p),e.autoClose&&(h(),C.destroy())}}});w(),n=()=>{l(!1),h(),C.destroy()};const v=yield C.promise,g=yield Promise.all((Array.isArray(s)?s:[s]).map(p=>x(this,null,function*(){return typeof p=="string"?p:yield Ce(p)})));v.importFile(g)}))})}function i(a){return x(this,arguments,function*(s,d={}){let y="";return B(e)&&(y=yield e.getUserCode()),new Promise((l,c)=>x(this,null,function*(){const f=d.container||t.container,{open:w,close:h,iframe:E}=f?M(T.IMAGE_EDITOR_URL,{app_id:e.appId,version:e.version||"IE001",id:s,mode:"user"},f):N(`${T.IMAGE_EDITOR_URL}`,{app_id:e.appId,version:e.version||"IE001",id:s,mode:"user"},()=>x(this,null,function*(){if(e.onCloseModal&&(yield e.onCloseModal())===!1)return!1;l(!1)})),C=L({iframe:E,methods:{onload(){return x(this,null,function*(){(yield C.promise).init(r)})},getUseRightToken(v){return x(this,null,function*(){const g=B(e)?yield e.getUseRightToken(v):!0;return g instanceof Error?{message:g.message}:g})},getUserCode(){return x(this,null,function*(){if(y){const v=y;return y="",v}try{return B(e)?e.getUserCode():!1}catch(v){c(v),h()}})},download(v){l(v),e.autoClose&&(h(),C.destroy())}}});w(),n=()=>{l(!1),h(),C.destroy()}}))})}function u(){n(),n=()=>{}}return{close:u,openUserRecord:i,editImage:i,importImage:o,importFile:o}}A.createImageEditor=Ar,A.createKoutuEditor=Ur,A.createTemplateEditor=yt,A.env=T,Object.defineProperty(A,"__esModule",{value:!0}),A[Symbol.toStringTag]="Module"}); | ||
`;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=` | ||
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"}); | ||
//# sourceMappingURL=editor-sdk.umd.js.map |
{ | ||
"name": "@gaoding/editor-sdk", | ||
"version": "1.5.5", | ||
"version": "2.0.0-alpha.0", | ||
"description": "稿定编辑器对外 SDK", | ||
"main": "dist/editor-sdk.umd.js", | ||
"module": "dist/editor-sdk.es.js", | ||
"esnext": "src/index.ts", | ||
"types": "types/index.d.ts", | ||
@@ -14,6 +13,6 @@ "files": [ | ||
"scripts": { | ||
"build": "vite build && tsc", | ||
"build": "vite build && tsc --build", | ||
"prepublishOnly": "npm run build", | ||
"serve": "vite preview", | ||
"watch": "vite build -w", | ||
"prepublishOnly": "npm run build" | ||
"watch": "tsc -w & vite build -w" | ||
}, | ||
@@ -25,3 +24,2 @@ "dependencies": { | ||
"devDependencies": { | ||
"typescript": "^4.3.2", | ||
"vite": "2.6.14" | ||
@@ -33,4 +31,3 @@ }, | ||
}, | ||
"gitHead": "2704d0b6e028a871e51beeefaeb24f64a1634bfb", | ||
"source-code": "src/index.ts" | ||
"gitHead": "d46affdf1c42426453a286fc5a6dd7a65a5588f5" | ||
} |
170
README.md
# 稿定开放平台编辑器 SDK | ||
### 浏览器版本要求 | ||
Chrome >= 60 | ||
Firefox >= 55 | ||
Safari >= 14 | ||
Edge >= 16 | ||
### 使用 | ||
```shell | ||
yarn add @gaoding/editor-sdk | ||
#or | ||
npm install @gaoding/editor-sdk | ||
``` | ||
## 模板编辑器 | ||
- 打开指定模板 | ||
```typescript | ||
import { createTemplateEditor } from '@gaoding/editor-sdk'; | ||
const editor = createTemplateEditor({ | ||
appId: '在稿定开放平台应用详情里查看', | ||
}); | ||
``` | ||
const res = await editor.openTemplate({ | ||
id: '模板ID', | ||
}); | ||
// 如果 res 为 false 表示没有进行导出操作 | ||
if (res) { | ||
// files 为导出的文件数组, urls 为导出的文件 url 地址 | ||
const { files, urls } = res; | ||
// ...do something | ||
} | ||
``` | ||
- 导入文件, 比如 PSD,PPTX,AI | ||
```typescript | ||
import { createTemplateEditor } from '@gaoding/editor-sdk'; | ||
const editor = createTemplateEditor({ | ||
appId: '在稿定开放平台应用详情里查看', | ||
}); | ||
const res = await editor.importFile(); | ||
// 如果 res 为 false 表示没有进行导出操作 | ||
if (res) { | ||
// files 为导出的文件数组, urls 为导出的文件 url 地址 | ||
const { files, urls } = res; | ||
// ...do something | ||
} | ||
``` | ||
- 创建空白画布 | ||
```typescript | ||
import { createTemplateEditor } from '@gaoding/editor-sdk'; | ||
const editor = createTemplateEditor({ | ||
appId: '在稿定开放平台应用详情里查看', | ||
}); | ||
const res = await editor.create({ width: 500, height: 500, categoryId: 1 }); | ||
// 如果 res 为 false 表示没有进行导出操作 | ||
if (res) { | ||
// files 为导出的文件数组, urls 为导出的文件 url 地址 | ||
const { files, urls } = res; | ||
// ...do something | ||
} | ||
``` | ||
## 图片编辑器 | ||
- 导入文件 | ||
```typescript | ||
import { createImageEditor } from '@gaoding/editor-sdk'; | ||
const editor = createImageEditor({ | ||
appId: '在稿定开放平台应用详情里查看', | ||
}); | ||
// editor.importFile(file: string | Blob) 支持 Blob 文件 和 url | ||
// 如果如果传的是 url 需要保证支持跨域 | ||
const res = await editor.importFile( | ||
'https://st0.dancf.com/static/02/202104280445-9936.png', | ||
); | ||
// 如果 res 为 false 表示没有进行导出操作 | ||
if (res) { | ||
// files 为导出的文件数组, urls 为导出的文件 url 地址 | ||
const { files, urls } = res; | ||
// ...do something | ||
} | ||
``` | ||
## 抠图编辑器 | ||
- 导入文件 | ||
```typescript | ||
import { createKoutuEditor } from '@gaoding/editor-sdk'; | ||
const editor = createKoutuEditor({ | ||
appId: '在稿定开放平台应用详情里查看', | ||
}); | ||
// editor.importFile(file: string | Blob) 支持 Blob 文件 和 url | ||
// 如果如果传的是 url 需要保证支持跨域 | ||
const res = await editor.importFile( | ||
'https://st0.dancf.com/static/02/202104280445-9936.png', | ||
); | ||
// 如果 res 为 false 表示没有进行导出操作 | ||
if (res) { | ||
// urls 为导出的文件 url 地址 | ||
const { urls } = res; | ||
// ...do something | ||
} | ||
``` | ||
- 高级版 | ||
```typescript | ||
import { createKoutuEditor } from '@gaoding/editor-sdk'; | ||
const editor = createKoutuEditor({ | ||
appId: '在稿定开放平台应用详情里查看', | ||
version: 'KE002', | ||
async getUseRightToken(info) { | ||
// 使用权益的API | ||
return request | ||
.post('/demo-api/use-certs', { | ||
app_id: info.appId, | ||
ability_code: info.abilityCode, | ||
}) | ||
.then(res => res.data); | ||
}, | ||
getUserCode() { | ||
// 获取用户授权码的API | ||
return request | ||
.get('/demo-api/authorized/code', { | ||
params: { app_id: formData.appId }, | ||
}) | ||
.then(res => res.data); | ||
}, | ||
}); | ||
// editor.importFile(file: string | Blob) 支持 Blob 文件 和 url | ||
// 如果如果传的是 url 需要保证支持跨域 | ||
const res = await editor.importFile( | ||
'https://st0.dancf.com/static/02/202104280445-9936.png', | ||
); | ||
// 如果 res 为 false 表示没有进行导出操作 | ||
if (res) { | ||
// urls 为导出的文件 url 地址 | ||
const { urls } = res; | ||
// ...do something | ||
} | ||
``` | ||
[查看文档](https://open.gaoding.com/docs) |
@@ -6,2 +6,3 @@ export declare const env: { | ||
OPEN_PLATFORM_ORIGIN: string; | ||
readonly VERSION: string; | ||
}; |
@@ -1,16 +0,10 @@ | ||
import { ImageEditorMethods } from './type'; | ||
interface Config { | ||
appId: string; | ||
container?: string; | ||
autoClose?: boolean; | ||
onCloseModal?: () => Promise<void | boolean> | void | boolean; | ||
} | ||
interface IE002Config extends Config { | ||
version: 'IE002'; | ||
/** | ||
* 获取用户权益授权码 | ||
* 获取使用权益凭证 | ||
*/ | ||
getUseRightToken(info: { | ||
getUseRightCert?(info: { | ||
appId: string; | ||
useKey: string; | ||
abilityCode: string; | ||
@@ -20,35 +14,26 @@ workId: string; | ||
/** | ||
* 获取用户标识code | ||
* 获取用户授权标识 | ||
*/ | ||
getUserCode: ImageEditorMethods['getUserCode']; | ||
authorize?(): Promise<string>; | ||
} | ||
export declare function createImageEditor(config: IE002Config | Config): { | ||
declare type EditorModuleType = 'panel.template' | 'panel.ajustment' | 'panel.mark' | 'panel.text' | 'panel.border' | 'panel.element' | 'panel.watermark' | 'panel.upload'; | ||
export declare function createImageEditor(config: Config): { | ||
editImage: (id: string, options?: { | ||
disableModules?: EditorModuleType[]; | ||
fileTypes?: string[]; | ||
}) => Promise<unknown>; | ||
close: () => void; | ||
openUserRecord: (id: string, options?: { | ||
container?: string | HTMLElement; | ||
onCloseModal?: () => Promise<void | boolean> | void | boolean; | ||
}) => Promise<false | { | ||
onSave: (fn: (info: { | ||
workId: string; | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
editImage: (id: string, options?: { | ||
container?: string | HTMLElement; | ||
onCloseModal?: () => Promise<void | boolean> | void | boolean; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
importImage: (file: (string | Blob)[], options?: { | ||
container?: string | HTMLElement; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
importFile: (file: (string | Blob)[], options?: { | ||
container?: string | HTMLElement; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
title: string; | ||
}) => void) => void; | ||
onClose: (fn: () => any) => void; | ||
importImage: (file: (string | Blob) | (string | Blob)[], options?: { | ||
disableModules?: EditorModuleType[]; | ||
fileTypes?: string[]; | ||
}) => Promise<unknown>; | ||
on: (eventName: string, fn: (...args: any[]) => any) => void; | ||
off: (eventName: string, fn: (...args: any[]) => any) => void; | ||
}; | ||
export {}; |
@@ -5,2 +5,1 @@ export * from './template'; | ||
export * from './env'; | ||
export * from './type'; |
@@ -1,16 +0,9 @@ | ||
import { KoutuEditorMethods } from './type'; | ||
interface Config { | ||
appId: string; | ||
container?: string; | ||
autoClose?: boolean; | ||
onCloseModal?: () => Promise<void | boolean> | void | boolean; | ||
} | ||
interface KE002Config extends Config { | ||
version: 'KE002'; | ||
/** | ||
* 获取用户权益授权码 | ||
*/ | ||
getUseRightToken(info: { | ||
getUseRightCert?(info: { | ||
appId: string; | ||
useKey: string; | ||
abilityCode: string; | ||
@@ -22,33 +15,12 @@ workId: string; | ||
*/ | ||
getUserCode: KoutuEditorMethods['getUserCode']; | ||
authorize?(): Promise<string>; | ||
} | ||
export declare function createKoutuEditor(config: Config | KE002Config): { | ||
export declare function createKoutuEditor(config: Config): { | ||
onSave: (fn: (info: { | ||
workId: string; | ||
files: Blob[]; | ||
title: string; | ||
}) => void) => void; | ||
onClose: (fn: () => any) => void; | ||
close: () => void; | ||
importFile: (file: string | Blob, options?: { | ||
container?: string | HTMLElement; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
openUserRecord: (id: string, config?: { | ||
container?: string | HTMLElement; | ||
onCloseModal?: () => Promise<void | boolean> | void | boolean; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
openWork: (id: string, config?: { | ||
container?: string | HTMLElement; | ||
onCloseModal?: () => Promise<void | boolean> | void | boolean; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
ediotKoutu: (id: string, config?: { | ||
container?: string | HTMLElement; | ||
onCloseModal?: () => Promise<void | boolean> | void | boolean; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
koutu: (url: string) => Promise<{ | ||
@@ -58,7 +30,5 @@ result: string; | ||
}>; | ||
autoKoutu: (url: string) => Promise<{ | ||
result: string; | ||
workId: string; | ||
}>; | ||
editKoutu: (id: string) => Promise<unknown>; | ||
importImage: (file: string | Blob) => Promise<unknown>; | ||
}; | ||
export {}; |
@@ -1,20 +0,9 @@ | ||
import { TemplateEditorMethods, TemplateEditorService } from './type'; | ||
declare type ExportType = 'png' | 'jpg'; | ||
declare type EditorModule = 'help' | 'copyright' | 'vip' | 'myResource' | 'photoResource' | 'viewMenu' | 'title'; | ||
interface Config { | ||
appId: string; | ||
okText?: string; | ||
exportTypes?: ExportType[]; | ||
filterPaidMaterial?: boolean; | ||
disableModules?: EditorModule[]; | ||
container?: string; | ||
autoClose?: boolean; | ||
onCloseModal?: () => Promise<void | boolean> | void | boolean; | ||
} | ||
interface AdvancedConfig extends Config { | ||
version: 'TE002'; | ||
onCloseModal?(): Promise<boolean | void> | void | boolean; | ||
/** | ||
* 获取用户权益授权码 | ||
* 获取使用权益凭证 | ||
*/ | ||
getUseRightToken(info: { | ||
getUseRightCert?(info: { | ||
appId: string; | ||
@@ -26,60 +15,39 @@ useKey: string; | ||
/** | ||
* 获取用户标识code | ||
* 获取用户授权标识 | ||
*/ | ||
getUserCode: TemplateEditorMethods['getUserCode']; | ||
authorize?(): Promise<string>; | ||
} | ||
interface OpenTemplateConfig { | ||
onload?: (e: TemplateEditorService) => void; | ||
onTemplateLoad?: (e: TemplateEditorService) => void; | ||
container?: string | HTMLElement; | ||
} | ||
export declare function createTemplateEditor(config: AdvancedConfig | Config): { | ||
declare type FileType = 'jpg' | 'png' | 'gif' | 'ppt' | 'pdf' | 'mp4'; | ||
declare type EditorModuleType = 'panel.template' | 'material-panel' | 'my-panel'; | ||
export declare function createTemplateEditor(config: Config): { | ||
readonly canva: null; | ||
readonly isLoad: boolean; | ||
openTemplateList: (options: { | ||
categories?: string[] | undefined; | ||
onSelectTemplate?(info: { | ||
id: string; | ||
}): void; | ||
}) => Promise<unknown>; | ||
close: () => void; | ||
openUserRecord: (config: OpenTemplateConfig & ({ | ||
id: string; | ||
categoryId?: string; | ||
} | { | ||
id?: string; | ||
categoryId: string; | ||
})) => Promise<false | { | ||
onSave: (fn: (info: { | ||
workId: string; | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
editTemplate: (config: OpenTemplateConfig & ({ | ||
title: string; | ||
}) => void) => void; | ||
onTempalteLoad: (fn: () => any) => void; | ||
onClose: (fn: () => any) => void; | ||
onLoad: (fn: () => any) => void; | ||
editTemplate: (options: { | ||
id: string; | ||
categoryId?: string; | ||
} | { | ||
fileTypes?: FileType[]; | ||
disableModules?: EditorModuleType[]; | ||
filterPaidMaterial?: never; | ||
}) => Promise<unknown>; | ||
createTemplate: (options?: { | ||
id?: string; | ||
categoryId: string; | ||
})) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
create: (options?: { | ||
width?: number | undefined; | ||
height?: number | undefined; | ||
container?: string | HTMLElement | undefined; | ||
categoryId?: string | undefined; | ||
onload?: ((e: TemplateEditorService) => void) | undefined; | ||
onTemplateLoad?: ((e: TemplateEditorService) => void) | undefined; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
openTemplateList: (config?: OpenTemplateConfig & { | ||
onSelectTemplate?(info: { | ||
id: number; | ||
}): Promise<boolean | undefined>; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
openTemplate: (config: OpenTemplateConfig & { | ||
id?: string; | ||
categoryId?: string; | ||
}) => Promise<false | { | ||
files: Blob[]; | ||
urls: string[]; | ||
}>; | ||
fileTypes?: FileType[]; | ||
categoryId?: number; | ||
disableModules?: EditorModuleType[]; | ||
}) => Promise<unknown>; | ||
}; | ||
export {}; |
@@ -5,1 +5,2 @@ export declare function copyFile(file: File | Blob): Promise<File>; | ||
}>(methods: T): T; | ||
export declare function assert(condition: boolean, message: string): void; |
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
379586
1
17
2794
2
3