@combeenation/custom-code-sdk 0.0.1-alpha10 → 0.0.1-alpha11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +1 -1
- package/dist/bundle.es.js +130 -128
- package/dist/index.d.ts +21 -0
- package/package.json +1 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var we=Object.defineProperty;var K=e=>{throw TypeError(e)};var Ae=(e,n,t)=>n in e?we(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var d=(e,n,t)=>Ae(e,typeof n!="symbol"?n+"":n,t),G=(e,n,t)=>n.has(e)||K("Cannot "+t);var i=(e,n,t)=>(G(e,n,"read from private field"),t?t.call(e):n.get(e)),a=(e,n,t)=>n.has(e)?K("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(e):n.set(e,t),u=(e,n,t,s)=>(G(e,n,"write to private field"),s?s.call(e,t):n.set(e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("zod"),N="0.0.1-alpha10";var z,g;class Ve{constructor(n){d(this,"id");a(this,z,"v1");a(this,g);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,z));if(u(this,g,t==null?void 0:t.getButtonSdkBridge(this.id)),!i(this,g))throw new Error(`Cannot access API for Button "${this.id}".`)}onRendered(n){var t;return((t=i(this,g))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}onClick(n){var t;return((t=i(this,g))==null?void 0:t.addOnClickCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,g))==null?void 0:t.setVisible(n))}setText(n){var t;(t=i(this,g))==null||t.setText(n)}}z=new WeakMap,g=new WeakMap;var F,p;class ke{constructor(n){d(this,"id");a(this,F,"v1");a(this,p);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,F));if(u(this,p,t==null?void 0:t.getCheckboxSdkBridge(this.id)),!i(this,p))throw new Error(`Cannot access API for Checkbox "${this.id}".`)}onRendered(n){var t;return((t=i(this,p))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,p))==null?void 0:t.setVisible(n))}}F=new WeakMap,p=new WeakMap;var T,b;class Ie{constructor(n){d(this,"id");a(this,T,"v1");a(this,b);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,T));if(u(this,b,t==null?void 0:t.getCollapsibleSdkBridge(this.id)),!i(this,b))throw new Error(`Cannot access API for Collapsible "${this.id}".`)}onRendered(n){var t;return((t=i(this,b))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,b))==null?void 0:t.setVisible(n))}}T=new WeakMap,b=new WeakMap;var O,c;class Pe{constructor(n){d(this,"id");a(this,O,"v1");a(this,c);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,O));if(u(this,c,t==null?void 0:t.getCustomCtrlSdkBridge(this.id)),!i(this,c))throw new Error(`Cannot access API for Custom Control "${this.id}".`)}set renderFn(n){var t;(t=i(this,c))==null||t.setRenderFn(n)}async render(n){var t;typeof n=="function"&&(this.renderFn=n),await((t=i(this,c))==null?void 0:t.render())}onRendered(n){var t;return((t=i(this,c))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}getElement(){var t;return(t=i(this,c))==null?void 0:t.getElement()}async setVisible(n){var t;await((t=i(this,c))==null?void 0:t.setVisible(n))}}O=new WeakMap,c=new WeakMap;var $,m;class ye{constructor(n){d(this,"id");a(this,$,"v1");a(this,m);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,$));if(u(this,m,t==null?void 0:t.getDataviewSdkBridge(this.id)),!i(this,m))throw new Error(`Cannot access API for Dataview "${this.id}".`)}onRendered(n){var t;return((t=i(this,m))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,m))==null?void 0:t.setVisible(n))}}$=new WeakMap,m=new WeakMap;var x,f;class Ee{constructor(n){d(this,"id");a(this,x,"v1");a(this,f);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,x));if(u(this,f,t==null?void 0:t.getInputSdkBridge(this.id)),!i(this,f))throw new Error(`Cannot access API for Input "${this.id}".`)}onRendered(n){var t;return((t=i(this,f))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,f))==null?void 0:t.setVisible(n))}}x=new WeakMap,f=new WeakMap;var M,w;class Be{constructor(n){d(this,"id");a(this,M,"v1");a(this,w);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,M));if(u(this,w,t==null?void 0:t.getPanelSdkBridge(this.id)),!i(this,w))throw new Error(`Cannot access API for Panel "${this.id}".`)}onRendered(n){var t;return((t=i(this,w))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,w))==null?void 0:t.setVisible(n))}}M=new WeakMap,w=new WeakMap;var L,l;class Re{constructor(n){d(this,"id");a(this,L,"v1");a(this,l);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,L));if(u(this,l,t==null?void 0:t.getTextSdkBridge(this.id)),!i(this,l))throw new Error(`Cannot access API for Text "${this.id}".`)}onRendered(n){var t;return((t=i(this,l))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,l))==null?void 0:t.setVisible(n))}setText(n){var t;(t=i(this,l))==null||t.setText(n)}}L=new WeakMap,l=new WeakMap;const X=1,v=[];function ve(e,n){if(v.length>=X)throw new Error(`Only ${X} \`ConfiguratorClient\` can be created at a time.`);v.push({client:e,internals:n})}function q(){const e=v[0];if(!e)throw new Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");return e.client}function Se(){const e=v[0];if(!e)throw new Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");return e.internals}const ze="v1";var R,J;const _=(J=(R=window.Cbn)==null?void 0:R.getCustomCodeSdkBridge)==null?void 0:J.call(R,"v1");if(!_)throw new Error("Cannot access Configurator SDK bridge. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");const H=_.createCfgrClient(ze,ve);if(!H)throw new Error("Cannot create Configurator Client. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");const A=_.getParentPageUtilsSdkBridge(),V=_.getCfgrUtilsSdkBridge(),S=H;var Z=(e=>(e[e.Any=1]="Any",e[e.Image=2]="Image",e))(Z||{}),h=(e=>(e[e.PdfAsset=0]="PdfAsset",e[e.Asset=1]="Asset",e[e.Merge=2]="Merge",e[e.Watermark=3]="Watermark",e[e.OutputToCfgnFile=4]="OutputToCfgnFile",e))(h||{}),W=(e=>(e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e))(W||{}),ee=(e=>(e[e.Top=0]="Top",e[e.Center=1]="Center",e[e.Bottom=2]="Bottom",e))(ee||{}),j=(e=>(e[e.PdfAsset=h.PdfAsset]="PdfAsset",e[e.Asset=h.Asset]="Asset",e))(j||{});const te=e=>V.uploadCfgnFiles(e,Z.Image),ne=e=>V.uploadCfgnFiles(e,Z.Any),se=e=>V.convertDocument(e);async function ie(e,n,t,s){const o=n.length>1,k="MergeTask",I="Task_",P=n.map((C,D)=>C.type===j.PdfAsset?{type:h.PdfAsset,name:`${I}${D}`,bundleAliasName:e,assetPath:C.assetPath,context:C.context}:{type:h.Asset,name:`${I}${D}`,bundleAliasName:e,assetPath:C.assetPath});return o&&P.push({type:h.Merge,name:k,inputTaskNames:P.map(C=>C.name)}),P.push({type:h.OutputToCfgnFile,inputTaskName:o?k:P[0].name,name:"OutputPdfTask",cfgnFileExtension:"pdf",cfgnFileName:t,cfgnFileDisplayName:s}),V.convertDocument(P)}const U={Text:"Text",Number:"Number",Logic:"Logic"},y={ValueComponent:"ValueComponent",TableComponent:"TableComponent",RecordComponent:"RecordComponent",ResourceComponent:"ResourceComponent",GraphicComponent:"GraphicComponent",CheckoutComponent:"CheckoutComponent"},E={ValueEditor:"ValueEditor",TableEditor:"TableEditor",Fiber:"Fiber",FiberEditor:"FiberEditor",CfgrField:"CfgrField"};r.z.enum([E.ValueEditor,E.TableEditor,E.Fiber,E.FiberEditor,E.CfgrField]);r.z.union([r.z.string(),r.z.number(),r.z.boolean()]);const B=e=>typeof e=="string";r.z.string();r.z.enum([U.Text,U.Number,U.Logic]);r.z.string();r.z.custom(e=>B(e)&&e.toLowerCase()===e);const oe=e=>(e==null?void 0:e.toLowerCase())??"";r.z.string();const Fe=r.z.custom(e=>B(e)?new RegExp(`^${y.ValueComponent}<.*>$`).test(e):!1),Te=r.z.custom(e=>B(e)?new RegExp(`^${y.RecordComponent}<.*>$`).test(e):!1),Oe=r.z.custom(e=>B(e)?new RegExp(`^${y.ResourceComponent}<.*>$`).test(e):!1),$e=r.z.custom(e=>B(e)?new RegExp(`^${y.TableComponent}<.*>$`).test(e):!1);r.z.union([Fe,$e,Te,Oe,r.z.literal(y.GraphicComponent),r.z.literal(y.CheckoutComponent)]);const Q=r.z.union([r.z.string(),r.z.number(),r.z.boolean()]),xe=r.z.union([Q,r.z.array(Q),r.z.object({}),r.z.unknown()]),Me=r.z.object({$typ:r.z.literal("Error"),Id:r.z.string(),Message:r.z.string(),route:r.z.unknown().optional()});Me.or(xe);const Y=new Map;function Le(e){const n=oe(e.name);Y.has(n)||Y.set(n,e)}class _e{constructor(n,t){d(this,"name");d(this,"zodType");this.name=n,this.zodType=t,Le(this)}async getValue(){return await q().getCmpValue(this.name)}async setInput(n){const t=oe(this.name);await Se().setCmpInput(t,n,this.zodType)}onValueChanged(n,t=!1,s){q().onCmpValueChanged(this.name,n,s,t)}}const re=()=>V.getAssetPaths();var ae=(e=>(e[e.Facebook=0]="Facebook",e[e.Pinterest=1]="Pinterest",e[e.Twitter=2]="Twitter",e[e.LinkedIn=3]="LinkedIn",e[e.WhatsApp=4]="WhatsApp",e[e.Custom=5]="Custom",e[e.NativeShare=6]="NativeShare",e))(ae||{});const Ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=",de=S.onAnyCmpValueChanged.bind(S),ce=async e=>{if(await S.finishConfiguration(e==null?void 0:e.input),e.sendDataToParentPage){const n=e.transformParentPageData();await A.sendConfigurationFinished(n)}},ue=async e=>{const n=ae[e.platform],t=e.imageUrl??Ue,s={...e,platform:n,imageUrl:t},o=await S.shareConfiguration(s);await V.openShareWindow(e.platform,o);const{shareUrl:k,shareConfigurationId:I}=o;return{shareUrl:k,shareConfigurationId:I}},ge=async e=>{const{promise:n,resolve:t}=Promise.withResolvers(),s={};for(const[o,k]of Object.entries(e))k.onValueChanged(I=>{s[o]=I,Object.keys(e).every(C=>C in s)&&t(s)},!0);return n},Ce=()=>A.isInIFrame(),le=e=>A.setIFrameSize(e),he=e=>V.navigateToLogin(e),pe=(e,n)=>A.sendCustomMsg(e,n),be=e=>A.redirectParentPage(e),me=()=>A.getParentPageUrl(),fe=(e,n)=>A.fireAnalyticsEvent(e,n),Ne=Object.freeze(Object.defineProperty({__proto__:null,configuratorIsInIFrame:Ce,convertDocument:se,createPdfFromAssets:ie,createSyncCmpValuesStore:ge,finishConfiguration:ce,fireAnalyticsEvent:fe,getAssetPaths:re,getParentPageUrl:me,navigateToLogin:he,onAnyCmpValueChanged:de,redirectParentPage:be,sendCustomMsgToParentPage:pe,setConfiguratorIFrameSize:le,shareConfiguration:ue,uploadFiles:ne,uploadImages:te,version:N},Symbol.toStringTag,{value:"Module"}));console.log(`Loading custom code SDK v${N}`);exports.Button=Ve;exports.CbnSdk=Ne;exports.Checkbox=ke;exports.Collapsible=Ie;exports.CreatePdfTaskTypes=j;exports.CustomControl=Pe;exports.Dataview=ye;exports.DocumentConvertTaskTypes=h;exports.Input=Ee;exports.Panel=Be;exports.Text=Re;exports.ValueComponent=_e;exports.WatermarkHorizontalAlignment=W;exports.WatermarkVerticalAlignment=ee;exports.configuratorIsInIFrame=Ce;exports.convertDocument=se;exports.createPdfFromAssets=ie;exports.createSyncCmpValuesStore=ge;exports.finishConfiguration=ce;exports.fireAnalyticsEvent=fe;exports.getAssetPaths=re;exports.getParentPageUrl=me;exports.navigateToLogin=he;exports.onAnyCmpValueChanged=de;exports.redirectParentPage=be;exports.sendCustomMsgToParentPage=pe;exports.setConfiguratorIFrameSize=le;exports.shareConfiguration=ue;exports.uploadFiles=ne;exports.uploadImages=te;exports.version=N;
|
|
1
|
+
"use strict";var Ae=Object.defineProperty;var K=e=>{throw TypeError(e)};var Ve=(e,n,t)=>n in e?Ae(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var d=(e,n,t)=>Ve(e,typeof n!="symbol"?n+"":n,t),G=(e,n,t)=>n.has(e)||K("Cannot "+t);var i=(e,n,t)=>(G(e,n,"read from private field"),t?t.call(e):n.get(e)),a=(e,n,t)=>n.has(e)?K("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(e):n.set(e,t),u=(e,n,t,s)=>(G(e,n,"write to private field"),s?s.call(e,t):n.set(e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("zod"),N="0.0.1-alpha11";var F,g;class ke{constructor(n){d(this,"id");a(this,F,"v1");a(this,g);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,F));if(u(this,g,t==null?void 0:t.getButtonSdkBridge(this.id)),!i(this,g))throw new Error(`Cannot access API for Button "${this.id}".`)}onRendered(n){var t;return((t=i(this,g))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}onClick(n){var t;return((t=i(this,g))==null?void 0:t.addOnClickCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,g))==null?void 0:t.setVisible(n))}setText(n){var t;(t=i(this,g))==null||t.setText(n)}}F=new WeakMap,g=new WeakMap;var T,p;class Pe{constructor(n){d(this,"id");a(this,T,"v1");a(this,p);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,T));if(u(this,p,t==null?void 0:t.getCheckboxSdkBridge(this.id)),!i(this,p))throw new Error(`Cannot access API for Checkbox "${this.id}".`)}onRendered(n){var t;return((t=i(this,p))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,p))==null?void 0:t.setVisible(n))}}T=new WeakMap,p=new WeakMap;var O,b;class Ie{constructor(n){d(this,"id");a(this,O,"v1");a(this,b);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,O));if(u(this,b,t==null?void 0:t.getCollapsibleSdkBridge(this.id)),!i(this,b))throw new Error(`Cannot access API for Collapsible "${this.id}".`)}onRendered(n){var t;return((t=i(this,b))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,b))==null?void 0:t.setVisible(n))}}O=new WeakMap,b=new WeakMap;var $,c;class ye{constructor(n){d(this,"id");a(this,$,"v1");a(this,c);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,$));if(u(this,c,t==null?void 0:t.getCustomCtrlSdkBridge(this.id)),!i(this,c))throw new Error(`Cannot access API for Custom Control "${this.id}".`)}set renderFn(n){var t;(t=i(this,c))==null||t.setRenderFn(n)}async render(n){var t;typeof n=="function"&&(this.renderFn=n),await((t=i(this,c))==null?void 0:t.render())}onRendered(n){var t;return((t=i(this,c))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}getElement(){var t;return(t=i(this,c))==null?void 0:t.getElement()}async setVisible(n){var t;await((t=i(this,c))==null?void 0:t.setVisible(n))}}$=new WeakMap,c=new WeakMap;var x,m;class Ee{constructor(n){d(this,"id");a(this,x,"v1");a(this,m);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,x));if(u(this,m,t==null?void 0:t.getDataviewSdkBridge(this.id)),!i(this,m))throw new Error(`Cannot access API for Dataview "${this.id}".`)}onRendered(n){var t;return((t=i(this,m))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,m))==null?void 0:t.setVisible(n))}}x=new WeakMap,m=new WeakMap;var M,f;class Be{constructor(n){d(this,"id");a(this,M,"v1");a(this,f);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,M));if(u(this,f,t==null?void 0:t.getInputSdkBridge(this.id)),!i(this,f))throw new Error(`Cannot access API for Input "${this.id}".`)}onRendered(n){var t;return((t=i(this,f))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,f))==null?void 0:t.setVisible(n))}}M=new WeakMap,f=new WeakMap;var L,w;class Se{constructor(n){d(this,"id");a(this,L,"v1");a(this,w);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,L));if(u(this,w,t==null?void 0:t.getPanelSdkBridge(this.id)),!i(this,w))throw new Error(`Cannot access API for Panel "${this.id}".`)}onRendered(n){var t;return((t=i(this,w))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,w))==null?void 0:t.setVisible(n))}}L=new WeakMap,w=new WeakMap;var _,l;class ve{constructor(n){d(this,"id");a(this,_,"v1");a(this,l);var s,o;this.id=n;const t=(o=(s=window.Cbn)==null?void 0:s.getCustomCodeSdkBridge)==null?void 0:o.call(s,i(this,_));if(u(this,l,t==null?void 0:t.getTextSdkBridge(this.id)),!i(this,l))throw new Error(`Cannot access API for Text "${this.id}".`)}onRendered(n){var t;return((t=i(this,l))==null?void 0:t.addOnRenderedCallback(n))??{unsubscribe:()=>{}}}async setVisible(n){var t;await((t=i(this,l))==null?void 0:t.setVisible(n))}setText(n){var t;(t=i(this,l))==null||t.setText(n)}}_=new WeakMap,l=new WeakMap;const X=1,R=[];function Re(e,n){if(R.length>=X)throw new Error(`Only ${X} \`ConfiguratorClient\` can be created at a time.`);R.push({client:e,internals:n})}function q(){const e=R[0];if(!e)throw new Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");return e.client}function ze(){const e=R[0];if(!e)throw new Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");return e.internals}const Fe="v1";var v,J;const B=(J=(v=window.Cbn)==null?void 0:v.getCustomCodeSdkBridge)==null?void 0:J.call(v,"v1");if(!B)throw new Error("Cannot access Configurator SDK bridge. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");const H=B.createCfgrClient(Fe,Re);if(!H)throw new Error("Cannot create Configurator Client. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");const A=B.getParentPageUtilsSdkBridge(),V=B.getCfgrUtilsSdkBridge(),Te=B.getViewer3dSdkBridge(),z=H;var Z=(e=>(e[e.Any=1]="Any",e[e.Image=2]="Image",e))(Z||{}),h=(e=>(e[e.PdfAsset=0]="PdfAsset",e[e.Asset=1]="Asset",e[e.Merge=2]="Merge",e[e.Watermark=3]="Watermark",e[e.OutputToCfgnFile=4]="OutputToCfgnFile",e))(h||{}),W=(e=>(e[e.Left=0]="Left",e[e.Center=1]="Center",e[e.Right=2]="Right",e))(W||{}),ee=(e=>(e[e.Top=0]="Top",e[e.Center=1]="Center",e[e.Bottom=2]="Bottom",e))(ee||{}),j=(e=>(e[e.PdfAsset=h.PdfAsset]="PdfAsset",e[e.Asset=h.Asset]="Asset",e))(j||{});const te=e=>V.uploadCfgnFiles(e,Z.Image),ne=e=>V.uploadCfgnFiles(e,Z.Any),se=e=>V.convertDocument(e);async function ie(e,n,t,s){const o=n.length>1,k="MergeTask",P="Task_",I=n.map((C,D)=>C.type===j.PdfAsset?{type:h.PdfAsset,name:`${P}${D}`,bundleAliasName:e,assetPath:C.assetPath,context:C.context}:{type:h.Asset,name:`${P}${D}`,bundleAliasName:e,assetPath:C.assetPath});return o&&I.push({type:h.Merge,name:k,inputTaskNames:I.map(C=>C.name)}),I.push({type:h.OutputToCfgnFile,inputTaskName:o?k:I[0].name,name:"OutputPdfTask",cfgnFileExtension:"pdf",cfgnFileName:t,cfgnFileDisplayName:s}),V.convertDocument(I)}const U={Text:"Text",Number:"Number",Logic:"Logic"},y={ValueComponent:"ValueComponent",TableComponent:"TableComponent",RecordComponent:"RecordComponent",ResourceComponent:"ResourceComponent",GraphicComponent:"GraphicComponent",CheckoutComponent:"CheckoutComponent"},E={ValueEditor:"ValueEditor",TableEditor:"TableEditor",Fiber:"Fiber",FiberEditor:"FiberEditor",CfgrField:"CfgrField"};r.z.enum([E.ValueEditor,E.TableEditor,E.Fiber,E.FiberEditor,E.CfgrField]);r.z.union([r.z.string(),r.z.number(),r.z.boolean()]);const S=e=>typeof e=="string";r.z.string();r.z.enum([U.Text,U.Number,U.Logic]);r.z.string();r.z.custom(e=>S(e)&&e.toLowerCase()===e);const oe=e=>(e==null?void 0:e.toLowerCase())??"";r.z.string();const Oe=r.z.custom(e=>S(e)?new RegExp(`^${y.ValueComponent}<.*>$`).test(e):!1),$e=r.z.custom(e=>S(e)?new RegExp(`^${y.RecordComponent}<.*>$`).test(e):!1),xe=r.z.custom(e=>S(e)?new RegExp(`^${y.ResourceComponent}<.*>$`).test(e):!1),Me=r.z.custom(e=>S(e)?new RegExp(`^${y.TableComponent}<.*>$`).test(e):!1);r.z.union([Oe,Me,$e,xe,r.z.literal(y.GraphicComponent),r.z.literal(y.CheckoutComponent)]);const Q=r.z.union([r.z.string(),r.z.number(),r.z.boolean()]),Le=r.z.union([Q,r.z.array(Q),r.z.object({}),r.z.unknown()]),_e=r.z.object({$typ:r.z.literal("Error"),Id:r.z.string(),Message:r.z.string(),route:r.z.unknown().optional()});_e.or(Le);const Y=new Map;function Ue(e){const n=oe(e.name);Y.has(n)||Y.set(n,e)}class Ne{constructor(n,t){d(this,"name");d(this,"zodType");this.name=n,this.zodType=t,Ue(this)}async getValue(){return await q().getCmpValue(this.name)}async setInput(n){const t=oe(this.name);await ze().setCmpInput(t,n,this.zodType)}onValueChanged(n,t=!1,s){q().onCmpValueChanged(this.name,n,s,t)}}const re=()=>V.getAssetPaths();var ae=(e=>(e[e.Facebook=0]="Facebook",e[e.Pinterest=1]="Pinterest",e[e.Twitter=2]="Twitter",e[e.LinkedIn=3]="LinkedIn",e[e.WhatsApp=4]="WhatsApp",e[e.Custom=5]="Custom",e[e.NativeShare=6]="NativeShare",e))(ae||{});const Ze="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=",de=z.onAnyCmpValueChanged.bind(z),ce=async e=>{if(await z.finishConfiguration(e==null?void 0:e.input),e.sendDataToParentPage){const n=e.transformParentPageData();await A.sendConfigurationFinished(n)}},ue=async e=>{const n=ae[e.platform],t=e.imageUrl??Ze,s={...e,platform:n,imageUrl:t},o=await z.shareConfiguration(s);await V.openShareWindow(e.platform,o);const{shareUrl:k,shareConfigurationId:P}=o;return{shareUrl:k,shareConfigurationId:P}},ge=()=>A.isInIFrame(),Ce=e=>A.setIFrameSize(e),le=e=>V.navigateToLogin(e),he=async e=>{const{promise:n,resolve:t}=Promise.withResolvers(),s={};for(const[o,k]of Object.entries(e))k.onValueChanged(P=>{s[o]=P,Object.keys(e).every(C=>C in s)&&t(s)},!0);return n},pe=(e,n)=>A.sendCustomMsg(e,n),be=e=>A.redirectParentPage(e),me=()=>A.getParentPageUrl(),fe=(e,n)=>A.fireAnalyticsEvent(e,n),we=async(e,n)=>Te.createArPage(e,n),je=Object.freeze(Object.defineProperty({__proto__:null,configuratorIsInIFrame:ge,convertDocument:se,createArPage:we,createPdfFromAssets:ie,createSyncCmpValuesStore:he,finishConfiguration:ce,fireAnalyticsEvent:fe,getAssetPaths:re,getParentPageUrl:me,navigateToLogin:le,onAnyCmpValueChanged:de,redirectParentPage:be,sendCustomMsgToParentPage:pe,setConfiguratorIFrameSize:Ce,shareConfiguration:ue,uploadFiles:ne,uploadImages:te,version:N},Symbol.toStringTag,{value:"Module"}));console.log(`Loading custom code SDK v${N}`);exports.Button=ke;exports.CbnSdk=je;exports.Checkbox=Pe;exports.Collapsible=Ie;exports.CreatePdfTaskTypes=j;exports.CustomControl=ye;exports.Dataview=Ee;exports.DocumentConvertTaskTypes=h;exports.Input=Be;exports.Panel=Se;exports.Text=ve;exports.ValueComponent=Ne;exports.WatermarkHorizontalAlignment=W;exports.WatermarkVerticalAlignment=ee;exports.configuratorIsInIFrame=ge;exports.convertDocument=se;exports.createArPage=we;exports.createPdfFromAssets=ie;exports.createSyncCmpValuesStore=he;exports.finishConfiguration=ce;exports.fireAnalyticsEvent=fe;exports.getAssetPaths=re;exports.getParentPageUrl=me;exports.navigateToLogin=le;exports.onAnyCmpValueChanged=de;exports.redirectParentPage=be;exports.sendCustomMsgToParentPage=pe;exports.setConfiguratorIFrameSize=Ce;exports.shareConfiguration=ue;exports.uploadFiles=ne;exports.uploadImages=te;exports.version=N;
|
package/dist/bundle.es.js
CHANGED
|
@@ -6,16 +6,16 @@ var ne = (e, n, t) => n in e ? te(e, n, { enumerable: !0, configurable: !0, writ
|
|
|
6
6
|
var d = (e, n, t) => ne(e, typeof n != "symbol" ? n + "" : n, t), D = (e, n, t) => n.has(e) || K("Cannot " + t);
|
|
7
7
|
var i = (e, n, t) => (D(e, n, "read from private field"), t ? t.call(e) : n.get(e)), a = (e, n, t) => n.has(e) ? K("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), u = (e, n, t, s) => (D(e, n, "write to private field"), s ? s.call(e, t) : n.set(e, t), t);
|
|
8
8
|
import { z as r } from "zod";
|
|
9
|
-
const Y = "0.0.1-
|
|
10
|
-
var
|
|
11
|
-
class
|
|
9
|
+
const Y = "0.0.1-alpha11";
|
|
10
|
+
var O, C;
|
|
11
|
+
class Me {
|
|
12
12
|
constructor(n) {
|
|
13
13
|
d(this, "id");
|
|
14
|
-
a(this,
|
|
14
|
+
a(this, O, "v1");
|
|
15
15
|
a(this, C);
|
|
16
16
|
var s, o;
|
|
17
17
|
this.id = n;
|
|
18
|
-
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this,
|
|
18
|
+
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, O));
|
|
19
19
|
if (u(this, C, t == null ? void 0 : t.getButtonSdkBridge(this.id)), !i(this, C))
|
|
20
20
|
throw new Error(`Cannot access API for Button "${this.id}".`);
|
|
21
21
|
}
|
|
@@ -38,16 +38,16 @@ class $e {
|
|
|
38
38
|
(t = i(this, C)) == null || t.setText(n);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
class
|
|
41
|
+
O = new WeakMap(), C = new WeakMap();
|
|
42
|
+
var T, p;
|
|
43
|
+
class _e {
|
|
44
44
|
constructor(n) {
|
|
45
45
|
d(this, "id");
|
|
46
|
-
a(this,
|
|
46
|
+
a(this, T, "v1");
|
|
47
47
|
a(this, p);
|
|
48
48
|
var s, o;
|
|
49
49
|
this.id = n;
|
|
50
|
-
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this,
|
|
50
|
+
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, T));
|
|
51
51
|
if (u(this, p, t == null ? void 0 : t.getCheckboxSdkBridge(this.id)), !i(this, p))
|
|
52
52
|
throw new Error(`Cannot access API for Checkbox "${this.id}".`);
|
|
53
53
|
}
|
|
@@ -61,16 +61,16 @@ class xe {
|
|
|
61
61
|
await ((t = i(this, p)) == null ? void 0 : t.setVisible(n));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
var
|
|
66
|
-
class
|
|
64
|
+
T = new WeakMap(), p = new WeakMap();
|
|
65
|
+
var $, b;
|
|
66
|
+
class Le {
|
|
67
67
|
constructor(n) {
|
|
68
68
|
d(this, "id");
|
|
69
|
-
a(this,
|
|
69
|
+
a(this, $, "v1");
|
|
70
70
|
a(this, b);
|
|
71
71
|
var s, o;
|
|
72
72
|
this.id = n;
|
|
73
|
-
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this,
|
|
73
|
+
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, $));
|
|
74
74
|
if (u(this, b, t == null ? void 0 : t.getCollapsibleSdkBridge(this.id)), !i(this, b))
|
|
75
75
|
throw new Error(`Cannot access API for Collapsible "${this.id}".`);
|
|
76
76
|
}
|
|
@@ -84,16 +84,16 @@ class Me {
|
|
|
84
84
|
await ((t = i(this, b)) == null ? void 0 : t.setVisible(n));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
var
|
|
89
|
-
class
|
|
87
|
+
$ = new WeakMap(), b = new WeakMap();
|
|
88
|
+
var x, c;
|
|
89
|
+
class Ue {
|
|
90
90
|
constructor(n) {
|
|
91
91
|
d(this, "id");
|
|
92
|
-
a(this,
|
|
92
|
+
a(this, x, "v1");
|
|
93
93
|
a(this, c);
|
|
94
94
|
var s, o;
|
|
95
95
|
this.id = n;
|
|
96
|
-
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this,
|
|
96
|
+
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, x));
|
|
97
97
|
if (u(this, c, t == null ? void 0 : t.getCustomCtrlSdkBridge(this.id)), !i(this, c))
|
|
98
98
|
throw new Error(`Cannot access API for Custom Control "${this.id}".`);
|
|
99
99
|
}
|
|
@@ -172,16 +172,16 @@ class _e {
|
|
|
172
172
|
await ((t = i(this, c)) == null ? void 0 : t.setVisible(n));
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
var
|
|
177
|
-
class
|
|
175
|
+
x = new WeakMap(), c = new WeakMap();
|
|
176
|
+
var M, m;
|
|
177
|
+
class Ne {
|
|
178
178
|
constructor(n) {
|
|
179
179
|
d(this, "id");
|
|
180
|
-
a(this,
|
|
180
|
+
a(this, M, "v1");
|
|
181
181
|
a(this, m);
|
|
182
182
|
var s, o;
|
|
183
183
|
this.id = n;
|
|
184
|
-
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this,
|
|
184
|
+
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, M));
|
|
185
185
|
if (u(this, m, t == null ? void 0 : t.getDataviewSdkBridge(this.id)), !i(this, m))
|
|
186
186
|
throw new Error(`Cannot access API for Dataview "${this.id}".`);
|
|
187
187
|
}
|
|
@@ -195,16 +195,16 @@ class Le {
|
|
|
195
195
|
await ((t = i(this, m)) == null ? void 0 : t.setVisible(n));
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
|
|
199
|
-
var
|
|
200
|
-
class
|
|
198
|
+
M = new WeakMap(), m = new WeakMap();
|
|
199
|
+
var _, f;
|
|
200
|
+
class Ze {
|
|
201
201
|
constructor(n) {
|
|
202
202
|
d(this, "id");
|
|
203
|
-
a(this,
|
|
203
|
+
a(this, _, "v1");
|
|
204
204
|
a(this, f);
|
|
205
205
|
var s, o;
|
|
206
206
|
this.id = n;
|
|
207
|
-
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this,
|
|
207
|
+
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, _));
|
|
208
208
|
if (u(this, f, t == null ? void 0 : t.getInputSdkBridge(this.id)), !i(this, f))
|
|
209
209
|
throw new Error(`Cannot access API for Input "${this.id}".`);
|
|
210
210
|
}
|
|
@@ -218,16 +218,16 @@ class Ue {
|
|
|
218
218
|
await ((t = i(this, f)) == null ? void 0 : t.setVisible(n));
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
|
|
222
|
-
var
|
|
223
|
-
class
|
|
221
|
+
_ = new WeakMap(), f = new WeakMap();
|
|
222
|
+
var L, w;
|
|
223
|
+
class je {
|
|
224
224
|
constructor(n) {
|
|
225
225
|
d(this, "id");
|
|
226
|
-
a(this,
|
|
226
|
+
a(this, L, "v1");
|
|
227
227
|
a(this, w);
|
|
228
228
|
var s, o;
|
|
229
229
|
this.id = n;
|
|
230
|
-
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this,
|
|
230
|
+
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, L));
|
|
231
231
|
if (u(this, w, t == null ? void 0 : t.getPanelSdkBridge(this.id)), !i(this, w))
|
|
232
232
|
throw new Error(`Cannot access API for Panel "${this.id}".`);
|
|
233
233
|
}
|
|
@@ -241,16 +241,16 @@ class Ne {
|
|
|
241
241
|
await ((t = i(this, w)) == null ? void 0 : t.setVisible(n));
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
|
|
245
|
-
var
|
|
246
|
-
class
|
|
244
|
+
L = new WeakMap(), w = new WeakMap();
|
|
245
|
+
var U, l;
|
|
246
|
+
class Ke {
|
|
247
247
|
constructor(n) {
|
|
248
248
|
d(this, "id");
|
|
249
|
-
a(this,
|
|
249
|
+
a(this, U, "v1");
|
|
250
250
|
a(this, l);
|
|
251
251
|
var s, o;
|
|
252
252
|
this.id = n;
|
|
253
|
-
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this,
|
|
253
|
+
const t = (o = (s = window.Cbn) == null ? void 0 : s.getCustomCodeSdkBridge) == null ? void 0 : o.call(s, i(this, U));
|
|
254
254
|
if (u(this, l, t == null ? void 0 : t.getTextSdkBridge(this.id)), !i(this, l))
|
|
255
255
|
throw new Error(`Cannot access API for Text "${this.id}".`);
|
|
256
256
|
}
|
|
@@ -268,73 +268,73 @@ class Ze {
|
|
|
268
268
|
(t = i(this, l)) == null || t.setText(n);
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
|
|
272
|
-
const G = 1,
|
|
271
|
+
U = new WeakMap(), l = new WeakMap();
|
|
272
|
+
const G = 1, v = [];
|
|
273
273
|
function se(e, n) {
|
|
274
|
-
if (
|
|
274
|
+
if (v.length >= G)
|
|
275
275
|
throw new Error(`Only ${G} \`ConfiguratorClient\` can be created at a time.`);
|
|
276
|
-
|
|
276
|
+
v.push({ client: e, internals: n });
|
|
277
277
|
}
|
|
278
278
|
function X() {
|
|
279
|
-
const e =
|
|
279
|
+
const e = v[0];
|
|
280
280
|
if (!e)
|
|
281
281
|
throw new Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");
|
|
282
282
|
return e.client;
|
|
283
283
|
}
|
|
284
284
|
function ie() {
|
|
285
|
-
const e =
|
|
285
|
+
const e = v[0];
|
|
286
286
|
if (!e)
|
|
287
287
|
throw new Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");
|
|
288
288
|
return e.internals;
|
|
289
289
|
}
|
|
290
290
|
const oe = "v1";
|
|
291
|
-
var
|
|
292
|
-
const
|
|
293
|
-
if (!
|
|
291
|
+
var S, q;
|
|
292
|
+
const y = (q = (S = window.Cbn) == null ? void 0 : S.getCustomCodeSdkBridge) == null ? void 0 : q.call(S, "v1");
|
|
293
|
+
if (!y)
|
|
294
294
|
throw new Error(
|
|
295
295
|
"Cannot access Configurator SDK bridge. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator."
|
|
296
296
|
);
|
|
297
|
-
const J =
|
|
297
|
+
const J = y.createCfgrClient(oe, se);
|
|
298
298
|
if (!J)
|
|
299
299
|
throw new Error(
|
|
300
300
|
"Cannot create Configurator Client. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator."
|
|
301
301
|
);
|
|
302
|
-
const A =
|
|
303
|
-
var Z = /* @__PURE__ */ ((e) => (e[e.Any = 1] = "Any", e[e.Image = 2] = "Image", e))(Z || {}), h = /* @__PURE__ */ ((e) => (e[e.PdfAsset = 0] = "PdfAsset", e[e.Asset = 1] = "Asset", e[e.Merge = 2] = "Merge", e[e.Watermark = 3] = "Watermark", e[e.OutputToCfgnFile = 4] = "OutputToCfgnFile", e))(h || {}),
|
|
304
|
-
const
|
|
305
|
-
async function
|
|
306
|
-
const o = n.length > 1, k = "MergeTask",
|
|
302
|
+
const A = y.getParentPageUtilsSdkBridge(), V = y.getCfgrUtilsSdkBridge(), re = y.getViewer3dSdkBridge(), F = J;
|
|
303
|
+
var Z = /* @__PURE__ */ ((e) => (e[e.Any = 1] = "Any", e[e.Image = 2] = "Image", e))(Z || {}), h = /* @__PURE__ */ ((e) => (e[e.PdfAsset = 0] = "PdfAsset", e[e.Asset = 1] = "Asset", e[e.Merge = 2] = "Merge", e[e.Watermark = 3] = "Watermark", e[e.OutputToCfgnFile = 4] = "OutputToCfgnFile", e))(h || {}), ae = /* @__PURE__ */ ((e) => (e[e.Left = 0] = "Left", e[e.Center = 1] = "Center", e[e.Right = 2] = "Right", e))(ae || {}), de = /* @__PURE__ */ ((e) => (e[e.Top = 0] = "Top", e[e.Center = 1] = "Center", e[e.Bottom = 2] = "Bottom", e))(de || {}), H = ((e) => (e[e.PdfAsset = h.PdfAsset] = "PdfAsset", e[e.Asset = h.Asset] = "Asset", e))(H || {});
|
|
304
|
+
const ce = (e) => V.uploadCfgnFiles(e, Z.Image), ue = (e) => V.uploadCfgnFiles(e, Z.Any), Ce = (e) => V.convertDocument(e);
|
|
305
|
+
async function ge(e, n, t, s) {
|
|
306
|
+
const o = n.length > 1, k = "MergeTask", B = "Task_", E = n.map(
|
|
307
307
|
(g, j) => g.type === H.PdfAsset ? {
|
|
308
308
|
type: h.PdfAsset,
|
|
309
|
-
name: `${
|
|
309
|
+
name: `${B}${j}`,
|
|
310
310
|
bundleAliasName: e,
|
|
311
311
|
assetPath: g.assetPath,
|
|
312
312
|
context: g.context
|
|
313
313
|
} : {
|
|
314
314
|
type: h.Asset,
|
|
315
|
-
name: `${
|
|
315
|
+
name: `${B}${j}`,
|
|
316
316
|
bundleAliasName: e,
|
|
317
317
|
assetPath: g.assetPath
|
|
318
318
|
}
|
|
319
319
|
);
|
|
320
|
-
return o &&
|
|
320
|
+
return o && E.push({
|
|
321
321
|
type: h.Merge,
|
|
322
322
|
name: k,
|
|
323
|
-
inputTaskNames:
|
|
324
|
-
}),
|
|
323
|
+
inputTaskNames: E.map((g) => g.name)
|
|
324
|
+
}), E.push({
|
|
325
325
|
type: h.OutputToCfgnFile,
|
|
326
|
-
inputTaskName: o ? k :
|
|
326
|
+
inputTaskName: o ? k : E[0].name,
|
|
327
327
|
name: "OutputPdfTask",
|
|
328
328
|
cfgnFileExtension: "pdf",
|
|
329
329
|
cfgnFileName: t,
|
|
330
330
|
cfgnFileDisplayName: s
|
|
331
|
-
}), V.convertDocument(
|
|
331
|
+
}), V.convertDocument(E);
|
|
332
332
|
}
|
|
333
333
|
const N = {
|
|
334
334
|
Text: "Text",
|
|
335
335
|
Number: "Number",
|
|
336
336
|
Logic: "Logic"
|
|
337
|
-
},
|
|
337
|
+
}, I = {
|
|
338
338
|
ValueComponent: "ValueComponent",
|
|
339
339
|
TableComponent: "TableComponent",
|
|
340
340
|
// TODO WTT: We're not actively supporting the following cmp types (yet). Neither in editor v2, nor in the headless
|
|
@@ -364,31 +364,31 @@ r.enum([
|
|
|
364
364
|
R.CfgrField
|
|
365
365
|
]);
|
|
366
366
|
r.union([r.string(), r.number(), r.boolean()]);
|
|
367
|
-
const
|
|
367
|
+
const P = (e) => typeof e == "string";
|
|
368
368
|
r.string();
|
|
369
369
|
r.enum([N.Text, N.Number, N.Logic]);
|
|
370
370
|
r.string();
|
|
371
|
-
r.custom((e) =>
|
|
371
|
+
r.custom((e) => P(e) && e.toLowerCase() === e);
|
|
372
372
|
const W = (e) => (e == null ? void 0 : e.toLowerCase()) ?? "";
|
|
373
373
|
r.string();
|
|
374
|
-
const
|
|
375
|
-
(e) =>
|
|
376
|
-
), le = r.custom(
|
|
377
|
-
(e) => y(e) ? new RegExp(`^${B.RecordComponent}<.*>$`).test(e) : !1
|
|
374
|
+
const le = r.custom(
|
|
375
|
+
(e) => P(e) ? new RegExp(`^${I.ValueComponent}<.*>$`).test(e) : !1
|
|
378
376
|
), he = r.custom(
|
|
379
|
-
(e) =>
|
|
377
|
+
(e) => P(e) ? new RegExp(`^${I.RecordComponent}<.*>$`).test(e) : !1
|
|
380
378
|
), pe = r.custom(
|
|
381
|
-
(e) =>
|
|
379
|
+
(e) => P(e) ? new RegExp(`^${I.ResourceComponent}<.*>$`).test(e) : !1
|
|
380
|
+
), be = r.custom(
|
|
381
|
+
(e) => P(e) ? new RegExp(`^${I.TableComponent}<.*>$`).test(e) : !1
|
|
382
382
|
);
|
|
383
383
|
r.union([
|
|
384
|
-
ge,
|
|
385
|
-
pe,
|
|
386
384
|
le,
|
|
385
|
+
be,
|
|
387
386
|
he,
|
|
388
|
-
|
|
389
|
-
r.literal(
|
|
387
|
+
pe,
|
|
388
|
+
r.literal(I.GraphicComponent),
|
|
389
|
+
r.literal(I.CheckoutComponent)
|
|
390
390
|
]);
|
|
391
|
-
const z = r.union([r.string(), r.number(), r.boolean()]),
|
|
391
|
+
const z = r.union([r.string(), r.number(), r.boolean()]), me = r.union([z, r.array(z), r.object({}), r.unknown()]), fe = r.object({
|
|
392
392
|
$typ: r.literal("Error"),
|
|
393
393
|
// TODO WTT: Introduce more specific typing here for known error IDs etc.? Maybe in combination w/ some server
|
|
394
394
|
// generated enum?
|
|
@@ -402,17 +402,17 @@ const z = r.union([r.string(), r.number(), r.boolean()]), be = r.union([z, r.arr
|
|
|
402
402
|
*/
|
|
403
403
|
route: r.unknown().optional()
|
|
404
404
|
});
|
|
405
|
-
|
|
405
|
+
fe.or(me);
|
|
406
406
|
const Q = /* @__PURE__ */ new Map();
|
|
407
|
-
function
|
|
407
|
+
function we(e) {
|
|
408
408
|
const n = W(e.name);
|
|
409
409
|
Q.has(n) || Q.set(n, e);
|
|
410
410
|
}
|
|
411
|
-
class
|
|
411
|
+
class De {
|
|
412
412
|
constructor(n, t) {
|
|
413
413
|
d(this, "name");
|
|
414
414
|
d(this, "zodType");
|
|
415
|
-
this.name = n, this.zodType = t,
|
|
415
|
+
this.name = n, this.zodType = t, we(this);
|
|
416
416
|
}
|
|
417
417
|
/**
|
|
418
418
|
* Function for receiving the value of a component.
|
|
@@ -440,76 +440,78 @@ class je {
|
|
|
440
440
|
X().onCmpValueChanged(this.name, n, s, t);
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
|
-
const
|
|
443
|
+
const Ae = () => V.getAssetPaths();
|
|
444
444
|
var ee = /* @__PURE__ */ ((e) => (e[e.Facebook = 0] = "Facebook", e[e.Pinterest = 1] = "Pinterest", e[e.Twitter = 2] = "Twitter", e[e.LinkedIn = 3] = "LinkedIn", e[e.WhatsApp = 4] = "WhatsApp", e[e.Custom = 5] = "Custom", e[e.NativeShare = 6] = "NativeShare", e))(ee || {});
|
|
445
|
-
const
|
|
446
|
-
if (await
|
|
445
|
+
const Ve = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=", ke = F.onAnyCmpValueChanged.bind(F), Be = async (e) => {
|
|
446
|
+
if (await F.finishConfiguration(e == null ? void 0 : e.input), e.sendDataToParentPage) {
|
|
447
447
|
const n = e.transformParentPageData();
|
|
448
448
|
await A.sendConfigurationFinished(n);
|
|
449
449
|
}
|
|
450
450
|
}, Ee = async (e) => {
|
|
451
|
-
const n = ee[e.platform], t = e.imageUrl ??
|
|
451
|
+
const n = ee[e.platform], t = e.imageUrl ?? Ve, s = { ...e, platform: n, imageUrl: t }, o = await F.shareConfiguration(s);
|
|
452
452
|
await V.openShareWindow(e.platform, o);
|
|
453
|
-
const { shareUrl: k, shareConfigurationId:
|
|
454
|
-
return { shareUrl: k, shareConfigurationId:
|
|
455
|
-
}, Ie = async (e) => {
|
|
453
|
+
const { shareUrl: k, shareConfigurationId: B } = o;
|
|
454
|
+
return { shareUrl: k, shareConfigurationId: B };
|
|
455
|
+
}, Ie = () => A.isInIFrame(), Re = (e) => A.setIFrameSize(e), ye = (e) => V.navigateToLogin(e), Pe = async (e) => {
|
|
456
456
|
const { promise: n, resolve: t } = Promise.withResolvers(), s = {};
|
|
457
457
|
for (const [o, k] of Object.entries(e))
|
|
458
|
-
k.onValueChanged((
|
|
459
|
-
s[o] =
|
|
458
|
+
k.onValueChanged((B) => {
|
|
459
|
+
s[o] = B, Object.keys(e).every((g) => g in s) && t(s);
|
|
460
460
|
}, !0);
|
|
461
461
|
return n;
|
|
462
|
-
},
|
|
462
|
+
}, Se = (e, n) => A.sendCustomMsg(e, n), ve = (e) => A.redirectParentPage(e), Fe = () => A.getParentPageUrl(), Oe = (e, n) => A.fireAnalyticsEvent(e, n), Te = async (e, n) => re.createArPage(e, n), Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
463
463
|
__proto__: null,
|
|
464
|
-
configuratorIsInIFrame:
|
|
465
|
-
convertDocument:
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
464
|
+
configuratorIsInIFrame: Ie,
|
|
465
|
+
convertDocument: Ce,
|
|
466
|
+
createArPage: Te,
|
|
467
|
+
createPdfFromAssets: ge,
|
|
468
|
+
createSyncCmpValuesStore: Pe,
|
|
469
|
+
finishConfiguration: Be,
|
|
470
|
+
fireAnalyticsEvent: Oe,
|
|
471
|
+
getAssetPaths: Ae,
|
|
472
|
+
getParentPageUrl: Fe,
|
|
472
473
|
navigateToLogin: ye,
|
|
473
|
-
onAnyCmpValueChanged:
|
|
474
|
-
redirectParentPage:
|
|
475
|
-
sendCustomMsgToParentPage:
|
|
474
|
+
onAnyCmpValueChanged: ke,
|
|
475
|
+
redirectParentPage: ve,
|
|
476
|
+
sendCustomMsgToParentPage: Se,
|
|
476
477
|
setConfiguratorIFrameSize: Re,
|
|
477
478
|
shareConfiguration: Ee,
|
|
478
|
-
uploadFiles:
|
|
479
|
-
uploadImages:
|
|
479
|
+
uploadFiles: ue,
|
|
480
|
+
uploadImages: ce,
|
|
480
481
|
version: Y
|
|
481
482
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
482
483
|
console.log(`Loading custom code SDK v${Y}`);
|
|
483
484
|
export {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
485
|
+
Me as Button,
|
|
486
|
+
Ge as CbnSdk,
|
|
487
|
+
_e as Checkbox,
|
|
488
|
+
Le as Collapsible,
|
|
488
489
|
H as CreatePdfTaskTypes,
|
|
489
|
-
|
|
490
|
-
|
|
490
|
+
Ue as CustomControl,
|
|
491
|
+
Ne as Dataview,
|
|
491
492
|
h as DocumentConvertTaskTypes,
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
493
|
+
Ze as Input,
|
|
494
|
+
je as Panel,
|
|
495
|
+
Ke as Text,
|
|
496
|
+
De as ValueComponent,
|
|
497
|
+
ae as WatermarkHorizontalAlignment,
|
|
498
|
+
de as WatermarkVerticalAlignment,
|
|
499
|
+
Ie as configuratorIsInIFrame,
|
|
500
|
+
Ce as convertDocument,
|
|
501
|
+
Te as createArPage,
|
|
502
|
+
ge as createPdfFromAssets,
|
|
503
|
+
Pe as createSyncCmpValuesStore,
|
|
504
|
+
Be as finishConfiguration,
|
|
505
|
+
Oe as fireAnalyticsEvent,
|
|
506
|
+
Ae as getAssetPaths,
|
|
507
|
+
Fe as getParentPageUrl,
|
|
506
508
|
ye as navigateToLogin,
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
509
|
+
ke as onAnyCmpValueChanged,
|
|
510
|
+
ve as redirectParentPage,
|
|
511
|
+
Se as sendCustomMsgToParentPage,
|
|
510
512
|
Re as setConfiguratorIFrameSize,
|
|
511
513
|
Ee as shareConfiguration,
|
|
512
|
-
|
|
513
|
-
|
|
514
|
+
ue as uploadFiles,
|
|
515
|
+
ce as uploadImages,
|
|
514
516
|
Y as version
|
|
515
517
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare namespace CbnSdk {
|
|
|
36
36
|
uploadImages,
|
|
37
37
|
convertDocument,
|
|
38
38
|
createPdfFromAssets,
|
|
39
|
+
createArPage,
|
|
39
40
|
version
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -150,6 +151,15 @@ export declare const configuratorIsInIFrame: () => boolean;
|
|
|
150
151
|
*/
|
|
151
152
|
export declare const convertDocument: (tasks: DocumentConvertTask[]) => Promise<string | undefined>;
|
|
152
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Uploads the given GLB file to a peristent storage and creates a dedicated page with an AR viewer that loads the GLB.
|
|
156
|
+
*
|
|
157
|
+
* After successful creation, it either redirects to that page or shows a dialog with a QR code linking to that page.
|
|
158
|
+
*
|
|
159
|
+
* Whether it redirects or shows a dialog depends on the browsers capabilities to directly open AR experiences.
|
|
160
|
+
*/
|
|
161
|
+
export declare const createArPage: (glb: File, options?: SdkCreateArPageOptions) => Promise<void>;
|
|
162
|
+
|
|
153
163
|
/**
|
|
154
164
|
* Creates a PDF from one or more assets which will be merged in the given order.
|
|
155
165
|
*
|
|
@@ -660,6 +670,17 @@ declare type SdkCfgnFileUploadResult<T extends string = string> = {
|
|
|
660
670
|
};
|
|
661
671
|
};
|
|
662
672
|
|
|
673
|
+
declare type SdkCreateArPageOptions = {
|
|
674
|
+
qrSubTitle?: string;
|
|
675
|
+
qrDescription?: string;
|
|
676
|
+
preparationText?: string;
|
|
677
|
+
popupBlockedTitle?: string;
|
|
678
|
+
popupBlockedDescription?: string;
|
|
679
|
+
popupBlockedLinkText?: string;
|
|
680
|
+
environment?: UrlString;
|
|
681
|
+
loadingScreenImg?: UrlString;
|
|
682
|
+
};
|
|
683
|
+
|
|
663
684
|
/**
|
|
664
685
|
* Send a custom message to the parent page via the "CustomMessage".\
|
|
665
686
|
* The parent page can handle those messages by implementing the function `Combeenation.on{msgName}`.
|