@combeenation/custom-code-sdk 0.0.1-rc2 → 0.0.1-rc3
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 +18 -15
- package/dist/index.d.ts +4 -2
- package/package.json +1 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};let n=require("zod");var r=`0.0.1-rc2`,i=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getButtonSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Button "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}onClick(e){return this.#t?.addOnClickCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setText(e){this.#t?.setText(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},a=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getCheckboxSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Checkbox "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setChecked(e){this.#t?.setChecked(e)}onCheckedChange(e){return this.#t?.onCheckedChange(e)??{unsubscribe:()=>{}}}setProperty(e,t){this.#t?.setProperty(e,t)}},o=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getCollapsibleSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Collapsible "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},s=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getComboboxSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Combobox "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}onItemRendered(e){return this.#t?.addOnItemRenderedCallback(e)??{unsubscribe:()=>{}}}onValueItemRendered(e){return this.#t?.addOnValueItemRenderedCallback(e)??{unsubscribe:()=>{}}}onGroupHeaderRendered(e){return this.#t?.addOnGroupHeaderRenderedCallback(e)??{unsubscribe:()=>{}}}onValueChange(e){return this.#t?.addOnValueChangeCallback(e)??{unsubscribe:()=>{}}}onItemClicked(e){return this.#t?.addOnItemClickedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setEntries(e){this.#t?.setEntries(e)}setGroupData(e){this.#t?.setGroupData(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},c=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getCustomCtrlSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Custom Control "${this.id}".`)}set renderFn(e){this.#t?.setRenderFn(e)}async render(e){typeof e==`function`&&(this.renderFn=e),await this.#t?.render()}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}getElement(){return this.#t?.getElement()}async setVisible(e){await this.#t?.setVisible(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},l=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getDataviewSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Dataview "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}onItemRendered(e){return this.#t?.addOnItemRenderedCallback(e)??{unsubscribe:()=>{}}}onGroupHeaderRendered(e){return this.#t?.addOnGroupHeaderRenderedCallback(e)??{unsubscribe:()=>{}}}onValueChange(e){return this.#t?.addOnValueChangeCallback(e)??{unsubscribe:()=>{}}}onItemClicked(e){return this.#t?.addOnItemClickedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setEntries(e){this.#t?.setEntries(e)}setGroupData(e){this.#t?.setGroupData(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},ee=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getInputSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Input "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setValue(e){this.#t?.setValue(e)}onValueChange(e){return this.#t?.onValueChange(e)??{unsubscribe:()=>{}}}setProperty(e,t){this.#t?.setProperty(e,t)}},u=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getPanelSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Panel "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},d=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getTextSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Text "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setText(e){this.#t?.setText(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},f=1,p=[];function te(e,t){if(p.length>=f)throw Error(`Only ${f} \`ConfiguratorClient\` can be created at a time.`);p.push({client:e,internals:t})}function m(){let e=p[0];if(!e)throw Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");return e.client}function ne(){let e=p[0];if(!e)throw Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");return e.internals}var h=window.Cbn?.getCustomCodeSdkBridge?.(`v1`);if(!h)throw Error("Cannot access Configurator SDK bridge. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");var g=h.createCfgrClient(`v1`,te);if(!g)throw Error("Cannot create Configurator Client. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");var _=h.getParentPageUtilsSdkBridge(),v=h.getCtrlsSdkBridge(),y=h.getCfgrUtilsSdkBridge(),re=h.getViewer3dSdkBridge(),ie=h.getLifecycleSdkBridge(),b=g,x=function(e){return e[e.Any=1]=`Any`,e[e.Image=2]=`Image`,e}({}),S=function(e){return e[e.PdfAsset=0]=`PdfAsset`,e[e.Asset=1]=`Asset`,e[e.Merge=2]=`Merge`,e[e.OutputToCfgnFile=4]=`OutputToCfgnFile`,e}({}),C=function(e){return e[e.PdfAsset=S.PdfAsset]=`PdfAsset`,e[e.Asset=S.Asset]=`Asset`,e}({}),w=e=>y.uploadCfgnFiles(e,x.Image),T=e=>y.uploadCfgnFiles(e,x.Any),E=e=>y.uploadTempCfgnFiles(e,x.Image),D=e=>y.uploadTempCfgnFiles(e,x.Any),O=e=>y.convertDocument(e);async function k(e,t,n,r){let i=t.length>1,a=`MergeTask`,o=`Task_`,s=t.map((t,n)=>t.type===C.PdfAsset?{type:S.PdfAsset,name:`${o}${n}`,bundleAliasName:e,assetPath:t.assetPath,context:t.context}:{type:S.Asset,name:`${o}${n}`,bundleAliasName:e,assetPath:t.assetPath});return i&&s.push({type:S.Merge,name:a,inputTaskNames:s.map(e=>e.name)}),s.push({type:S.OutputToCfgnFile,inputTaskName:i?a:s[0].name,name:`OutputPdfTask`,cfgnFileExtension:`pdf`,cfgnFileName:n,cfgnFileDisplayName:r}),y.convertDocument(s)}var A={Text:`Text`,Number:`Number`,Logic:`Logic`,Image:`Image`,FileUrl:`FileUrl`,TextAsset:`TextAsset`,Table:`Table`};`${A.Text}`,`${A.Number}`;var j={ValueComponent:`ValueComponent`,TableComponent:`TableComponent`,RecordComponent:`RecordComponent`,ResourceComponent:`ResourceComponent`,GraphicComponent:`GraphicComponent`,CheckoutComponent:`CheckoutComponent`};j.GraphicComponent,j.CheckoutComponent,j.ResourceComponent,j.RecordComponent;var M={ValueEditor:`ValueEditor`,TableEditor:`TableEditor`,Fiber:`Fiber`,FiberEditor:`FiberEditor`,CfgrField:`CfgrField`};n.z.enum([M.ValueEditor,M.TableEditor,M.Fiber,M.FiberEditor,M.CfgrField]),n.z.union([n.z.string(),n.z.number(),n.z.boolean()]);var N=e=>typeof e==`string`;n.z.string(),n.z.enum([A.Text,A.Number,A.Logic]),n.z.string(),n.z.custom(e=>N(e)&&e.toLowerCase()===e);var P=e=>e?.toLowerCase()??``;n.z.string();var ae=n.z.custom(e=>N(e)?RegExp(`^${j.ValueComponent}<.*>$`).test(e):!1),oe=n.z.custom(e=>N(e)?RegExp(`^${j.RecordComponent}<.*>$`).test(e):!1),se=n.z.custom(e=>N(e)?RegExp(`^${j.ResourceComponent}<.*>$`).test(e):!1),ce=n.z.custom(e=>N(e)?RegExp(`^${j.TableComponent}<.*>$`).test(e):!1);n.z.union([ae,ce,oe,se,n.z.literal(j.GraphicComponent),n.z.literal(j.CheckoutComponent)]);var F=n.z.union([n.z.string(),n.z.number(),n.z.boolean()]),le=n.z.union([F,n.z.array(F),n.z.object({}),n.z.unknown()]);n.z.object({$typ:n.z.literal(`Error`),Id:n.z.string(),Message:n.z.string(),route:n.z.unknown().optional()}).or(le);var I=new Map;function ue(e){let t=P(e.name);I.has(t)||I.set(t,e)}var de=class{name;zodType;constructor(e,t){this.name=e,this.zodType=t,ue(this)}async getValue(){return await m().getCmpValue(this.name)}async setInput(e){let t=P(this.name);await ne().setCmpInput(t,e,this.zodType)}onValueChanged(e,t=!1,n){m().onCmpValueChanged(this.name,e,n,t)}},fe=()=>y.getAssetPaths(),pe=function(e){return 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}({}),L=b.onAnyCmpValueChanged.bind(b),R=async e=>{if(await b.finishConfiguration(e?.input),e.sendDataToParentPage){let t=e.transformParentPageData();await _.sendConfigurationFinished(t)}},z=async e=>{let t=pe[e.platform],n=e.imageUrl??`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=`,r={...e,platform:t,imageUrl:n},i=await b.shareConfiguration(r);await y.openShareWindow(e.platform,i);let{shareUrl:a,shareConfigurationId:o}=i;return{shareUrl:a,shareConfigurationId:o}};async function B(e){return await y.executeIntegration(e)}var V=()=>_.isInIFrame(),H=e=>_.setIFrameSize(e),U=e=>y.navigateToLogin(e),W=async e=>{let{promise:t,resolve:n}=Promise.withResolvers(),r={};for(let[t,i]of Object.entries(e))i.onValueChanged(i=>{r[t]=i,Object.keys(e).every(e=>e in r)&&n(r)},!0);return t};function G(e,t){return new i(v.createCtrl(`button`,e.id,t))}function K(e,t){return new a(v.createCtrl(`checkbox`,e.id,t))}function q(e,t){return new l(v.createCtrl(`dataview`,e.id,{position:t.position,properties:{...t.properties,listMode:t.mode,valueType:t.mode===`no-selection`?void 0:t.valueType}}))}function J(e,t){return new s(v.createCtrl(`combobox`,e.id,{position:t.position,properties:{...t.properties,listMode:t.mode,valueType:t.mode===`no-selection`?void 0:t.valueType}}))}function Y(e,t){return new d(v.createCtrl(`text`,e.id,t))}function X(e,t){return new u(v.createCtrl(`panel`,e.id,t))}function Z(e,t){return new ee(v.createCtrl(`textbox`,e.id,t))}function Q(e,t){return new c(v.createCtrl(`customctrl`,e.id,t))}function $(e,t){return new o(v.createCtrl(`collapsible`,e.id,t))}var me="`beforeConfiguratorIsRendered` has no effect because it was called after the configurator was already rendered.\nMake sure to call it synchronously in the top-level code of your entry file before any top-level `await`.",he="`beforeConfiguratorIsRendered` is ignored because it was called more than once.\nIt must only be called once.",ge=e=>{let t=ie.registerBeforeConfiguratorIsRendered(e);t===`called-after-cfgr-render`?console.error(me):t===`already-registered`&&console.error(he)},_e=(e,t)=>_.sendCustomMsg(e,t),ve=e=>_.redirectParentPage(e),ye=()=>_.getParentPageUrl(),be=(e,t)=>_.fireAnalyticsEvent(e,t),xe=e=>_.onParentPageEvent(e),Se=async(e,t)=>re.createArPage(e,t),Ce=t({addButtonControl:()=>G,addCheckboxControl:()=>K,addCollapsibleControl:()=>$,addComboboxControl:()=>J,addCustomControl:()=>Q,addDataviewControl:()=>q,addInputControl:()=>Z,addPanelControl:()=>X,addTextControl:()=>Y,beforeConfiguratorIsRendered:()=>ge,configuratorIsInIFrame:()=>V,convertDocument:()=>O,createArPage:()=>Se,createPdfFromAssets:()=>k,createSyncCmpValuesStore:()=>W,executeIntegration:()=>B,finishConfiguration:()=>R,fireAnalyticsEvent:()=>be,getAssetPaths:()=>fe,getParentPageUrl:()=>ye,navigateToLogin:()=>U,onAnyCmpValueChanged:()=>L,onParentPageEvent:()=>xe,redirectParentPage:()=>ve,sendCustomMsgToParentPage:()=>_e,setConfiguratorIFrameSize:()=>H,shareConfiguration:()=>z,uploadFiles:()=>T,uploadImages:()=>w,uploadTempFiles:()=>D,uploadTempImages:()=>E,version:()=>r});console.log(`Loading custom code SDK v${r}`),exports.Button=i,Object.defineProperty(exports,"CbnSdk",{enumerable:!0,get:function(){return Ce}}),exports.Checkbox=a,exports.Collapsible=o,exports.Combobox=s,exports.CreatePdfTaskTypes=C,exports.CustomControl=c,exports.Dataview=l,exports.DocumentConvertTaskTypes=S,exports.Input=ee,exports.Panel=u,exports.Text=d,exports.ValueComponent=de,exports.addButtonControl=G,exports.addCheckboxControl=K,exports.addCollapsibleControl=$,exports.addComboboxControl=J,exports.addCustomControl=Q,exports.addDataviewControl=q,exports.addInputControl=Z,exports.addPanelControl=X,exports.addTextControl=Y,exports.beforeConfiguratorIsRendered=ge,exports.configuratorIsInIFrame=V,exports.convertDocument=O,exports.createArPage=Se,exports.createPdfFromAssets=k,exports.createSyncCmpValuesStore=W,exports.executeIntegration=B,exports.finishConfiguration=R,exports.fireAnalyticsEvent=be,exports.getAssetPaths=fe,exports.getParentPageUrl=ye,exports.navigateToLogin=U,exports.onAnyCmpValueChanged=L,exports.onParentPageEvent=xe,exports.redirectParentPage=ve,exports.sendCustomMsgToParentPage=_e,exports.setConfiguratorIFrameSize=H,exports.shareConfiguration=z,exports.uploadFiles=T,exports.uploadImages=w,exports.uploadTempFiles=D,exports.uploadTempImages=E,exports.version=r;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};let n=require("zod");var r=`0.0.1-rc3`,i=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getButtonSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Button "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}onClick(e){return this.#t?.addOnClickCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setText(e){this.#t?.setText(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},a=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getCheckboxSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Checkbox "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setChecked(e){this.#t?.setChecked(e)}onCheckedChange(e){return this.#t?.onCheckedChange(e)??{unsubscribe:()=>{}}}setProperty(e,t){this.#t?.setProperty(e,t)}},o=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getCollapsibleSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Collapsible "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},s=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getComboboxSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Combobox "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}onItemRendered(e){return this.#t?.addOnItemRenderedCallback(e)??{unsubscribe:()=>{}}}onValueItemRendered(e){return this.#t?.addOnValueItemRenderedCallback(e)??{unsubscribe:()=>{}}}onGroupHeaderRendered(e){return this.#t?.addOnGroupHeaderRenderedCallback(e)??{unsubscribe:()=>{}}}onValueChange(e){return this.#t?.addOnValueChangeCallback(e)??{unsubscribe:()=>{}}}onItemClicked(e){return this.#t?.addOnItemClickedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setEntries(e){this.#t?.setEntries(e)}setGroupData(e){this.#t?.setGroupData(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},c=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getCustomCtrlSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Custom Control "${this.id}".`)}set renderFn(e){this.#t?.setRenderFn(e)}async render(e){typeof e==`function`&&(this.renderFn=e),await this.#t?.render()}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}getElement(){return this.#t?.getElement()}async setVisible(e){await this.#t?.setVisible(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},l=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getDataviewSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Dataview "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}onItemRendered(e){return this.#t?.addOnItemRenderedCallback(e)??{unsubscribe:()=>{}}}onGroupHeaderRendered(e){return this.#t?.addOnGroupHeaderRenderedCallback(e)??{unsubscribe:()=>{}}}onValueChange(e){return this.#t?.addOnValueChangeCallback(e)??{unsubscribe:()=>{}}}onItemClicked(e){return this.#t?.addOnItemClickedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setEntries(e){this.#t?.setEntries(e)}setGroupData(e){this.#t?.setGroupData(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},ee=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getInputSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Input "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setValue(e){this.#t?.setValue(e)}onValueChange(e){return this.#t?.onValueChange(e)??{unsubscribe:()=>{}}}setProperty(e,t){this.#t?.setProperty(e,t)}},u=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getPanelSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Panel "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},d=class{id;#e=`v1`;#t=void 0;constructor(e){this.id=e;let t=window.Cbn?.getCustomCodeSdkBridge?.(this.#e);if(this.#t=t?.getTextSdkBridge(this.id),!this.#t)throw Error(`Cannot access API for Text "${this.id}".`)}onRendered(e){return this.#t?.addOnRenderedCallback(e)??{unsubscribe:()=>{}}}async setVisible(e){await this.#t?.setVisible(e)}setText(e){this.#t?.setText(e)}setProperty(e,t){this.#t?.setProperty(e,t)}},f=1,p=[];function te(e,t){if(p.length>=f)throw Error(`Only ${f} \`ConfiguratorClient\` can be created at a time.`);p.push({client:e,internals:t})}function m(){let e=p[0];if(!e)throw Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");return e.client}function ne(){let e=p[0];if(!e)throw Error("Operation not possible as no `ConfiguratorClient` has been registered yet.");return e.internals}var h=window.Cbn?.getCustomCodeSdkBridge?.(`v1`);if(!h)throw Error("Cannot access Configurator SDK bridge. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");var g=h.createCfgrClient(`v1`,te);if(!g)throw Error("Cannot create Configurator Client. Make sure to only use the `custom-code-sdk` inside a Combeenation Configurator.");var _=h.getParentPageUtilsSdkBridge(),v=h.getCtrlsSdkBridge(),y=h.getCfgrUtilsSdkBridge(),re=h.getViewer3dSdkBridge(),ie=h.getLifecycleSdkBridge(),b=g,x=function(e){return e[e.Any=1]=`Any`,e[e.Image=2]=`Image`,e}({}),S=function(e){return e[e.PdfAsset=0]=`PdfAsset`,e[e.Asset=1]=`Asset`,e[e.Merge=2]=`Merge`,e[e.OutputToCfgnFile=4]=`OutputToCfgnFile`,e}({}),C=function(e){return e[e.PdfAsset=S.PdfAsset]=`PdfAsset`,e[e.Asset=S.Asset]=`Asset`,e}({}),w=e=>y.uploadCfgnFiles(e,x.Image),T=e=>y.uploadCfgnFiles(e,x.Any),E=e=>y.uploadTempCfgnFiles(e,x.Image),D=e=>y.uploadTempCfgnFiles(e,x.Any),O=e=>y.convertDocument(e);async function k(e,t,n,r){let i=t.length>1,a=`MergeTask`,o=`Task_`,s=t.map((t,n)=>t.type===C.PdfAsset?{type:S.PdfAsset,name:`${o}${n}`,bundleAliasName:e,assetPath:t.assetPath,context:t.context}:{type:S.Asset,name:`${o}${n}`,bundleAliasName:e,assetPath:t.assetPath});return i&&s.push({type:S.Merge,name:a,inputTaskNames:s.map(e=>e.name)}),s.push({type:S.OutputToCfgnFile,inputTaskName:i?a:s[0].name,name:`OutputPdfTask`,cfgnFileExtension:`pdf`,cfgnFileName:n,cfgnFileDisplayName:r}),y.convertDocument(s)}var A={Text:`Text`,Number:`Number`,Logic:`Logic`,Image:`Image`,FileUrl:`FileUrl`,TextAsset:`TextAsset`,Table:`Table`};`${A.Text}`,`${A.Number}`;var j={ValueComponent:`ValueComponent`,TableComponent:`TableComponent`,RecordComponent:`RecordComponent`,ResourceComponent:`ResourceComponent`,GraphicComponent:`GraphicComponent`,CheckoutComponent:`CheckoutComponent`};j.GraphicComponent,j.CheckoutComponent,j.ResourceComponent,j.RecordComponent;var M={ValueEditor:`ValueEditor`,TableEditor:`TableEditor`,Fiber:`Fiber`,FiberEditor:`FiberEditor`,CfgrField:`CfgrField`,Watch:`Watch`};n.z.enum([M.ValueEditor,M.TableEditor,M.Fiber,M.FiberEditor,M.CfgrField,M.Watch]),n.z.union([n.z.string(),n.z.number(),n.z.boolean()]);var N=e=>typeof e==`string`;n.z.string(),n.z.enum([A.Text,A.Number,A.Logic]),n.z.string(),n.z.custom(e=>N(e)&&e.toLowerCase()===e);var P=e=>e?.toLowerCase()??``;n.z.string();var ae=n.z.custom(e=>N(e)?RegExp(`^${j.ValueComponent}<.*>$`).test(e):!1),oe=n.z.custom(e=>N(e)?RegExp(`^${j.RecordComponent}<.*>$`).test(e):!1),se=n.z.custom(e=>N(e)?RegExp(`^${j.ResourceComponent}<.*>$`).test(e):!1),ce=n.z.custom(e=>N(e)?RegExp(`^${j.TableComponent}<.*>$`).test(e):!1);n.z.union([ae,ce,oe,se,n.z.literal(j.GraphicComponent),n.z.literal(j.CheckoutComponent)]);var F=n.z.union([n.z.string(),n.z.number(),n.z.boolean()]),le=n.z.union([F,n.z.array(F),n.z.looseObject({}),n.z.unknown()]);n.z.object({$typ:n.z.literal(`Error`),Id:n.z.string(),Message:n.z.string(),route:n.z.unknown().optional()}).or(le);var I=new Map;function ue(e){let t=P(e.name);I.has(t)||I.set(t,e)}var de=class{name;zodType;constructor(e,t){this.name=e,this.zodType=t,ue(this)}async getValue(){return await m().getCmpValue(this.name)}async setInput(e){let t=P(this.name);await ne().setCmpInput(t,e,this.zodType)}onValueChanged(e,t=!1,n){m().onCmpValueChanged(this.name,e,n,t)}},L=()=>y.getAssetPaths(),fe=function(e){return 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}({}),R=b.onAnyCmpValueChanged.bind(b),z=async e=>{if(await y.finishConfiguration(e?.input)&&e.sendDataToParentPage){let t=e.transformParentPageData();await _.sendConfigurationFinished(t)}},pe=async e=>{let t=fe[e.platform],n=e.imageUrl??`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=`,r={...e,platform:t,imageUrl:n},i=await y.shareConfiguration(r);if(!i)return;await y.openShareWindow(e.platform,i);let{shareUrl:a,shareConfigurationId:o}=i;return{shareUrl:a,shareConfigurationId:o}};async function B(e){return await y.executeIntegration(e)}var V=()=>_.isInIFrame(),H=e=>_.setIFrameSize(e),U=e=>y.navigateToLogin(e),W=async e=>{let{promise:t,resolve:n}=Promise.withResolvers(),r={};for(let[t,i]of Object.entries(e))i.onValueChanged(i=>{r[t]=i,Object.keys(e).every(e=>e in r)&&n(r)},!0);return t};function G(e,t){return new i(v.createCtrl(`button`,e.id,t))}function K(e,t){return new a(v.createCtrl(`checkbox`,e.id,t))}function q(e,t){return new l(v.createCtrl(`dataview`,e.id,{position:t.position,properties:{...t.properties,listMode:t.mode,valueType:t.mode===`no-selection`?void 0:t.valueType}}))}function J(e,t){return new s(v.createCtrl(`combobox`,e.id,{position:t.position,properties:{...t.properties,listMode:t.mode,valueType:t.mode===`no-selection`?void 0:t.valueType}}))}function Y(e,t){return new d(v.createCtrl(`text`,e.id,t))}function X(e,t){return new u(v.createCtrl(`panel`,e.id,t))}function Z(e,t){return new ee(v.createCtrl(`textbox`,e.id,t))}function Q(e,t){return new c(v.createCtrl(`customctrl`,e.id,t))}function $(e,t){return new o(v.createCtrl(`collapsible`,e.id,t))}var me="`beforeConfiguratorIsRendered` has no effect because it was called after the configurator was already rendered.\nMake sure to call it synchronously in the top-level code of your entry file before any top-level `await`.",he="`beforeConfiguratorIsRendered` is ignored because it was called more than once.\nIt must only be called once.",ge=e=>{let t=ie.registerBeforeConfiguratorIsRendered(e);t===`called-after-cfgr-render`?console.error(me):t===`already-registered`&&console.error(he)},_e=(e,t)=>_.sendCustomMsg(e,t),ve=e=>_.redirectParentPage(e),ye=()=>_.getParentPageUrl(),be=(e,t)=>_.fireAnalyticsEvent(e,t),xe=e=>_.onParentPageEvent(e),Se=async(e,t)=>re.createArPage(e,t),Ce=t({addButtonControl:()=>G,addCheckboxControl:()=>K,addCollapsibleControl:()=>$,addComboboxControl:()=>J,addCustomControl:()=>Q,addDataviewControl:()=>q,addInputControl:()=>Z,addPanelControl:()=>X,addTextControl:()=>Y,beforeConfiguratorIsRendered:()=>ge,configuratorIsInIFrame:()=>V,convertDocument:()=>O,createArPage:()=>Se,createPdfFromAssets:()=>k,createSyncCmpValuesStore:()=>W,executeIntegration:()=>B,finishConfiguration:()=>z,fireAnalyticsEvent:()=>be,getAssetPaths:()=>L,getParentPageUrl:()=>ye,navigateToLogin:()=>U,onAnyCmpValueChanged:()=>R,onParentPageEvent:()=>xe,redirectParentPage:()=>ve,sendCustomMsgToParentPage:()=>_e,setConfiguratorIFrameSize:()=>H,shareConfiguration:()=>pe,uploadFiles:()=>T,uploadImages:()=>w,uploadTempFiles:()=>D,uploadTempImages:()=>E,version:()=>r});console.log(`Loading custom code SDK v${r}`),exports.Button=i,Object.defineProperty(exports,"CbnSdk",{enumerable:!0,get:function(){return Ce}}),exports.Checkbox=a,exports.Collapsible=o,exports.Combobox=s,exports.CreatePdfTaskTypes=C,exports.CustomControl=c,exports.Dataview=l,exports.DocumentConvertTaskTypes=S,exports.Input=ee,exports.Panel=u,exports.Text=d,exports.ValueComponent=de,exports.addButtonControl=G,exports.addCheckboxControl=K,exports.addCollapsibleControl=$,exports.addComboboxControl=J,exports.addCustomControl=Q,exports.addDataviewControl=q,exports.addInputControl=Z,exports.addPanelControl=X,exports.addTextControl=Y,exports.beforeConfiguratorIsRendered=ge,exports.configuratorIsInIFrame=V,exports.convertDocument=O,exports.createArPage=Se,exports.createPdfFromAssets=k,exports.createSyncCmpValuesStore=W,exports.executeIntegration=B,exports.finishConfiguration=z,exports.fireAnalyticsEvent=be,exports.getAssetPaths=L,exports.getParentPageUrl=ye,exports.navigateToLogin=U,exports.onAnyCmpValueChanged=R,exports.onParentPageEvent=xe,exports.redirectParentPage=ve,exports.sendCustomMsgToParentPage=_e,exports.setConfiguratorIFrameSize=H,exports.shareConfiguration=pe,exports.uploadFiles=T,exports.uploadImages=w,exports.uploadTempFiles=D,exports.uploadTempImages=E,exports.version=r;
|
package/dist/bundle.es.js
CHANGED
|
@@ -7,7 +7,7 @@ var t = Object.defineProperty, n = (e, n) => {
|
|
|
7
7
|
enumerable: !0
|
|
8
8
|
});
|
|
9
9
|
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
10
|
-
}, r = "0.0.1-
|
|
10
|
+
}, r = "0.0.1-rc3", i = class {
|
|
11
11
|
id;
|
|
12
12
|
#e = "v1";
|
|
13
13
|
#t = void 0;
|
|
@@ -321,14 +321,16 @@ var M = {
|
|
|
321
321
|
TableEditor: "TableEditor",
|
|
322
322
|
Fiber: "Fiber",
|
|
323
323
|
FiberEditor: "FiberEditor",
|
|
324
|
-
CfgrField: "CfgrField"
|
|
324
|
+
CfgrField: "CfgrField",
|
|
325
|
+
Watch: "Watch"
|
|
325
326
|
};
|
|
326
327
|
e.enum([
|
|
327
328
|
M.ValueEditor,
|
|
328
329
|
M.TableEditor,
|
|
329
330
|
M.Fiber,
|
|
330
331
|
M.FiberEditor,
|
|
331
|
-
M.CfgrField
|
|
332
|
+
M.CfgrField,
|
|
333
|
+
M.Watch
|
|
332
334
|
]), e.union([
|
|
333
335
|
e.string(),
|
|
334
336
|
e.number(),
|
|
@@ -358,7 +360,7 @@ var F = e.union([
|
|
|
358
360
|
]), le = e.union([
|
|
359
361
|
F,
|
|
360
362
|
e.array(F),
|
|
361
|
-
e.
|
|
363
|
+
e.looseObject({}),
|
|
362
364
|
e.unknown()
|
|
363
365
|
]);
|
|
364
366
|
e.object({
|
|
@@ -392,19 +394,20 @@ var de = class {
|
|
|
392
394
|
onValueChanged(e, t = !1, n) {
|
|
393
395
|
m().onCmpValueChanged(this.name, e, n, t);
|
|
394
396
|
}
|
|
395
|
-
},
|
|
397
|
+
}, L = () => y.getAssetPaths(), fe = /* @__PURE__ */ function(e) {
|
|
396
398
|
return 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;
|
|
397
|
-
}({}),
|
|
398
|
-
if (await
|
|
399
|
+
}({}), R = b.onAnyCmpValueChanged.bind(b), z = async (e) => {
|
|
400
|
+
if (await y.finishConfiguration(e?.input) && e.sendDataToParentPage) {
|
|
399
401
|
let t = e.transformParentPageData();
|
|
400
402
|
await _.sendConfigurationFinished(t);
|
|
401
403
|
}
|
|
402
|
-
},
|
|
403
|
-
let t =
|
|
404
|
+
}, pe = async (e) => {
|
|
405
|
+
let t = fe[e.platform], n = e.imageUrl ?? "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=", r = {
|
|
404
406
|
...e,
|
|
405
407
|
platform: t,
|
|
406
408
|
imageUrl: n
|
|
407
|
-
}, i = await
|
|
409
|
+
}, i = await y.shareConfiguration(r);
|
|
410
|
+
if (!i) return;
|
|
408
411
|
await y.openShareWindow(e.platform, i);
|
|
409
412
|
let { shareUrl: a, shareConfigurationId: o } = i;
|
|
410
413
|
return {
|
|
@@ -489,17 +492,17 @@ var me = "`beforeConfiguratorIsRendered` has no effect because it was called aft
|
|
|
489
492
|
createPdfFromAssets: () => k,
|
|
490
493
|
createSyncCmpValuesStore: () => W,
|
|
491
494
|
executeIntegration: () => B,
|
|
492
|
-
finishConfiguration: () =>
|
|
495
|
+
finishConfiguration: () => z,
|
|
493
496
|
fireAnalyticsEvent: () => be,
|
|
494
|
-
getAssetPaths: () =>
|
|
497
|
+
getAssetPaths: () => L,
|
|
495
498
|
getParentPageUrl: () => ye,
|
|
496
499
|
navigateToLogin: () => U,
|
|
497
|
-
onAnyCmpValueChanged: () =>
|
|
500
|
+
onAnyCmpValueChanged: () => R,
|
|
498
501
|
onParentPageEvent: () => xe,
|
|
499
502
|
redirectParentPage: () => ve,
|
|
500
503
|
sendCustomMsgToParentPage: () => _e,
|
|
501
504
|
setConfiguratorIFrameSize: () => H,
|
|
502
|
-
shareConfiguration: () =>
|
|
505
|
+
shareConfiguration: () => pe,
|
|
503
506
|
uploadFiles: () => T,
|
|
504
507
|
uploadImages: () => w,
|
|
505
508
|
uploadTempFiles: () => D,
|
|
@@ -510,4 +513,4 @@ var me = "`beforeConfiguratorIsRendered` has no effect because it was called aft
|
|
|
510
513
|
//#region src/index.ts
|
|
511
514
|
console.log(`Loading custom code SDK v${r}`);
|
|
512
515
|
//#endregion
|
|
513
|
-
export { i as Button, Ce as CbnSdk, a as Checkbox, o as Collapsible, s as Combobox, C as CreatePdfTaskTypes, c as CustomControl, l as Dataview, S as DocumentConvertTaskTypes, ee as Input, u as Panel, d as Text, de as ValueComponent, G as addButtonControl, K as addCheckboxControl, $ as addCollapsibleControl, J as addComboboxControl, Q as addCustomControl, q as addDataviewControl, Z as addInputControl, X as addPanelControl, Y as addTextControl, ge as beforeConfiguratorIsRendered, V as configuratorIsInIFrame, O as convertDocument, Se as createArPage, k as createPdfFromAssets, W as createSyncCmpValuesStore, B as executeIntegration,
|
|
516
|
+
export { i as Button, Ce as CbnSdk, a as Checkbox, o as Collapsible, s as Combobox, C as CreatePdfTaskTypes, c as CustomControl, l as Dataview, S as DocumentConvertTaskTypes, ee as Input, u as Panel, d as Text, de as ValueComponent, G as addButtonControl, K as addCheckboxControl, $ as addCollapsibleControl, J as addComboboxControl, Q as addCustomControl, q as addDataviewControl, Z as addInputControl, X as addPanelControl, Y as addTextControl, ge as beforeConfiguratorIsRendered, V as configuratorIsInIFrame, O as convertDocument, Se as createArPage, k as createPdfFromAssets, W as createSyncCmpValuesStore, B as executeIntegration, z as finishConfiguration, be as fireAnalyticsEvent, L as getAssetPaths, ye as getParentPageUrl, U as navigateToLogin, R as onAnyCmpValueChanged, xe as onParentPageEvent, ve as redirectParentPage, _e as sendCustomMsgToParentPage, H as setConfiguratorIFrameSize, pe as shareConfiguration, T as uploadFiles, w as uploadImages, D as uploadTempFiles, E as uploadTempImages, r as version };
|
package/dist/index.d.ts
CHANGED
|
@@ -600,6 +600,8 @@ declare type CreateInputProperties = {
|
|
|
600
600
|
visible: boolean | undefined;
|
|
601
601
|
cssClasses: string[] | undefined;
|
|
602
602
|
placeholder: string | undefined;
|
|
603
|
+
tooltipText: string | undefined;
|
|
604
|
+
tooltipPos: ElementPosOption | undefined;
|
|
603
605
|
};
|
|
604
606
|
|
|
605
607
|
declare type CreatePanelProperties = {
|
|
@@ -1470,7 +1472,7 @@ export declare const shareConfiguration: (data: {
|
|
|
1470
1472
|
*/
|
|
1471
1473
|
shareUrl: string;
|
|
1472
1474
|
shareConfigurationId: string;
|
|
1473
|
-
}>;
|
|
1475
|
+
} | undefined>;
|
|
1474
1476
|
|
|
1475
1477
|
export declare type ShopifyFinishJson = {
|
|
1476
1478
|
products: {
|
|
@@ -1684,7 +1686,7 @@ declare const ZAlignmentBlockOption: z.ZodUnion<readonly [z.ZodLiteral<"topLeft"
|
|
|
1684
1686
|
|
|
1685
1687
|
declare const ZAssetName: z.ZodString;
|
|
1686
1688
|
|
|
1687
|
-
declare const ZCmpValue: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>, z.ZodObject<{}, z.core.$
|
|
1689
|
+
declare const ZCmpValue: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>, z.ZodObject<{}, z.core.$loose>, z.ZodUnknown]>;
|
|
1688
1690
|
|
|
1689
1691
|
declare const ZCtrlId: z.ZodString;
|
|
1690
1692
|
|