@combeenation/custom-code-sdk 0.0.1-rc2 → 0.0.1-rc4

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.
@@ -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-rc4`,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)}},u=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)}},ee=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.OutputToTempCfgnFile=3]=`OutputToTempCfgnFile`,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{tasks:i,lastTaskName:a}=j(e,t);return i.push({type:S.OutputToCfgnFile,inputTaskName:a,name:`OutputPdfTask`,cfgnFileExtension:`pdf`,cfgnFileName:n,cfgnFileDisplayName:r}),y.convertDocument(i)}async function A(e,t,n){let{tasks:r,lastTaskName:i}=j(e,t);return r.push({type:S.OutputToTempCfgnFile,inputTaskName:i,name:`OutputPdfTask`,cfgnFileExtension:`pdf`,cfgnFileDisplayName:n}),y.convertDocument(r)}function j(e,t){let n=t.length>1,r=`Task_`,i=t.map((t,n)=>t.type===C.PdfAsset?{type:S.PdfAsset,name:`${r}${n}`,bundleAliasName:e,assetPath:t.assetPath,context:t.context}:{type:S.Asset,name:`${r}${n}`,bundleAliasName:e,assetPath:t.assetPath});return n&&i.push({type:S.Merge,name:`MergeTask`,inputTaskNames:i.map(e=>e.name)}),{tasks:i,lastTaskName:i[i.length-1].name}}var M={Text:`Text`,Number:`Number`,Logic:`Logic`,Image:`Image`,FileUrl:`FileUrl`,TextAsset:`TextAsset`,Table:`Table`};`${M.Text}`,`${M.Number}`;var N={ValueComponent:`ValueComponent`,TableComponent:`TableComponent`,RecordComponent:`RecordComponent`,ResourceComponent:`ResourceComponent`,GraphicComponent:`GraphicComponent`,CheckoutComponent:`CheckoutComponent`};N.GraphicComponent,N.CheckoutComponent,N.ResourceComponent,N.RecordComponent,n.z.union([n.z.string(),n.z.number(),n.z.boolean()]);var P=e=>typeof e==`string`;n.z.string(),n.z.enum([M.Text,M.Number,M.Logic]),n.z.string(),n.z.custom(e=>P(e)&&e.toLowerCase()===e);var F=e=>e?.toLowerCase()??``;n.z.string();var ae=n.z.custom(e=>P(e)?RegExp(`^${N.ValueComponent}<.*>$`).test(e):!1),oe=n.z.custom(e=>P(e)?RegExp(`^${N.RecordComponent}<.*>$`).test(e):!1),se=n.z.custom(e=>P(e)?RegExp(`^${N.ResourceComponent}<.*>$`).test(e):!1),ce=n.z.custom(e=>P(e)?RegExp(`^${N.TableComponent}<.*>$`).test(e):!1);n.z.union([ae,ce,oe,se,n.z.literal(N.GraphicComponent),n.z.literal(N.CheckoutComponent)]);var I=n.z.union([n.z.string(),n.z.number(),n.z.boolean()]),le=n.z.union([I,n.z.array(I),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 L=new Map;function ue(e){let t=F(e.name);L.has(t)||L.set(t,e)}var de={green:`#36D792`,yellow:`#D19A66`,red:`red`};function fe(e,t){return e&&t?`[${e}.${t}]`:e?`[${e}]`:t?`[${t}]`:``}function pe(e,t,n=``,r,i=`green`){let a=fe(e,t),o=de[i]??`inherit`;console.error(`%c${a}%c ${n}`,`color: ${o}`,`color: inherit`,r)}var me=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=F(this.name),n=await ne().setCmpInput(t,e,this.zodType);n&&pe(`ConfiguratorClient`,`setInput`,n)}onValueChanged(e,t=!1,n){m().onCmpValueChanged(this.name,e,n,t)}},R=()=>y.getAssetPaths(),he=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}({}),z=b.onAnyCmpValueChanged.bind(b),B=async e=>{if(await y.finishConfiguration(e?.input)&&e.sendDataToParentPage){let t=e.transformParentPageData();await _.sendConfigurationFinished(t)}},V=async e=>{await y.restartConfiguration(e)},H=async(e,t)=>{await y.changeDistributor(e,t)},U=async e=>{let t=he[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 W(e){return await y.executeIntegration(e)}var G=()=>_.isInIFrame(),K=e=>_.setIFrameSize(e),q=e=>y.navigateToLogin(e),J=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 Y(e,t){return new i(v.createCtrl(`button`,e.id,t))}function X(e,t){return new a(v.createCtrl(`checkbox`,e.id,t))}function Z(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 Q(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 ge(e,t){return new d(v.createCtrl(`text`,e.id,t))}function $(e,t){return new ee(v.createCtrl(`panel`,e.id,t))}function _e(e,t){return new u(v.createCtrl(`textbox`,e.id,t))}function ve(e,t){return new c(v.createCtrl(`customctrl`,e.id,t))}function ye(e,t){return new o(v.createCtrl(`collapsible`,e.id,t))}var be="`beforeConfiguratorIsRendered` has no effect because it was called after the configurator was already rendered.\nCall it from the top-level code of your entry file. Do not call it from an async callback.",xe="`beforeConfiguratorIsRendered` is ignored because it was called more than once.\nIt must only be called once.",Se=e=>{let t=ie.registerBeforeConfiguratorIsRendered(e);t===`called-after-cfgr-render`?console.error(be):t===`already-registered`&&console.error(xe)},Ce=(e,t)=>_.sendCustomMsg(e,t),we=e=>_.redirectParentPage(e),Te=()=>_.getParentPageUrl(),Ee=(e,t)=>_.fireAnalyticsEvent(e,t),De=e=>_.onParentPageEvent(e),Oe=async(e,t)=>re.createArPage(e,t),ke=t({addButtonControl:()=>Y,addCheckboxControl:()=>X,addCollapsibleControl:()=>ye,addComboboxControl:()=>Q,addCustomControl:()=>ve,addDataviewControl:()=>Z,addInputControl:()=>_e,addPanelControl:()=>$,addTextControl:()=>ge,beforeConfiguratorIsRendered:()=>Se,changeDistributor:()=>H,configuratorIsInIFrame:()=>G,convertDocument:()=>O,createArPage:()=>Oe,createPdfFromAssets:()=>k,createSyncCmpValuesStore:()=>J,createTempPdfFromAssets:()=>A,executeIntegration:()=>W,finishConfiguration:()=>B,fireAnalyticsEvent:()=>Ee,getAssetPaths:()=>R,getParentPageUrl:()=>Te,navigateToLogin:()=>q,onAnyCmpValueChanged:()=>z,onParentPageEvent:()=>De,redirectParentPage:()=>we,restartConfiguration:()=>V,sendCustomMsgToParentPage:()=>Ce,setConfiguratorIFrameSize:()=>K,shareConfiguration:()=>U,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 ke}}),exports.Checkbox=a,exports.Collapsible=o,exports.Combobox=s,exports.CreatePdfTaskTypes=C,exports.CustomControl=c,exports.Dataview=l,exports.DocumentConvertTaskTypes=S,exports.Input=u,exports.Panel=ee,exports.Text=d,exports.ValueComponent=me,exports.addButtonControl=Y,exports.addCheckboxControl=X,exports.addCollapsibleControl=ye,exports.addComboboxControl=Q,exports.addCustomControl=ve,exports.addDataviewControl=Z,exports.addInputControl=_e,exports.addPanelControl=$,exports.addTextControl=ge,exports.beforeConfiguratorIsRendered=Se,exports.changeDistributor=H,exports.configuratorIsInIFrame=G,exports.convertDocument=O,exports.createArPage=Oe,exports.createPdfFromAssets=k,exports.createSyncCmpValuesStore=J,exports.createTempPdfFromAssets=A,exports.executeIntegration=W,exports.finishConfiguration=B,exports.fireAnalyticsEvent=Ee,exports.getAssetPaths=R,exports.getParentPageUrl=Te,exports.navigateToLogin=q,exports.onAnyCmpValueChanged=z,exports.onParentPageEvent=De,exports.redirectParentPage=we,exports.restartConfiguration=V,exports.sendCustomMsgToParentPage=Ce,exports.setConfiguratorIFrameSize=K,exports.shareConfiguration=U,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-rc2", i = class {
10
+ }, r = "0.0.1-rc4", i = class {
11
11
  id;
12
12
  #e = "v1";
13
13
  #t = void 0;
@@ -175,7 +175,7 @@ var t = Object.defineProperty, n = (e, n) => {
175
175
  setProperty(e, t) {
176
176
  this.#t?.setProperty(e, t);
177
177
  }
178
- }, ee = class {
178
+ }, u = class {
179
179
  id;
180
180
  #e = "v1";
181
181
  #t = void 0;
@@ -199,7 +199,7 @@ var t = Object.defineProperty, n = (e, n) => {
199
199
  setProperty(e, t) {
200
200
  this.#t?.setProperty(e, t);
201
201
  }
202
- }, u = class {
202
+ }, ee = class {
203
203
  id;
204
204
  #e = "v1";
205
205
  #t = void 0;
@@ -265,39 +265,56 @@ if (!g) throw Error("Cannot create Configurator Client. Make sure to only use th
265
265
  var _ = h.getParentPageUtilsSdkBridge(), v = h.getCtrlsSdkBridge(), y = h.getCfgrUtilsSdkBridge(), re = h.getViewer3dSdkBridge(), ie = h.getLifecycleSdkBridge(), b = g, x = /* @__PURE__ */ function(e) {
266
266
  return e[e.Any = 1] = "Any", e[e.Image = 2] = "Image", e;
267
267
  }({}), S = /* @__PURE__ */ function(e) {
268
- return e[e.PdfAsset = 0] = "PdfAsset", e[e.Asset = 1] = "Asset", e[e.Merge = 2] = "Merge", e[e.OutputToCfgnFile = 4] = "OutputToCfgnFile", e;
268
+ return e[e.PdfAsset = 0] = "PdfAsset", e[e.Asset = 1] = "Asset", e[e.Merge = 2] = "Merge", e[e.OutputToTempCfgnFile = 3] = "OutputToTempCfgnFile", e[e.OutputToCfgnFile = 4] = "OutputToCfgnFile", e;
269
269
  }({}), C = /* @__PURE__ */ function(e) {
270
270
  return e[e.PdfAsset = S.PdfAsset] = "PdfAsset", e[e.Asset = S.Asset] = "Asset", e;
271
271
  }({}), 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);
272
272
  async function k(e, t, n, r) {
273
- let i = t.length > 1, a = "MergeTask", o = "Task_", s = t.map((t, n) => t.type === C.PdfAsset ? {
273
+ let { tasks: i, lastTaskName: a } = j(e, t);
274
+ return i.push({
275
+ type: S.OutputToCfgnFile,
276
+ inputTaskName: a,
277
+ name: "OutputPdfTask",
278
+ cfgnFileExtension: "pdf",
279
+ cfgnFileName: n,
280
+ cfgnFileDisplayName: r
281
+ }), y.convertDocument(i);
282
+ }
283
+ async function A(e, t, n) {
284
+ let { tasks: r, lastTaskName: i } = j(e, t);
285
+ return r.push({
286
+ type: S.OutputToTempCfgnFile,
287
+ inputTaskName: i,
288
+ name: "OutputPdfTask",
289
+ cfgnFileExtension: "pdf",
290
+ cfgnFileDisplayName: n
291
+ }), y.convertDocument(r);
292
+ }
293
+ function j(e, t) {
294
+ let n = t.length > 1, r = "Task_", i = t.map((t, n) => t.type === C.PdfAsset ? {
274
295
  type: S.PdfAsset,
275
- name: `${o}${n}`,
296
+ name: `${r}${n}`,
276
297
  bundleAliasName: e,
277
298
  assetPath: t.assetPath,
278
299
  context: t.context
279
300
  } : {
280
301
  type: S.Asset,
281
- name: `${o}${n}`,
302
+ name: `${r}${n}`,
282
303
  bundleAliasName: e,
283
304
  assetPath: t.assetPath
284
305
  });
285
- return i && s.push({
306
+ return n && i.push({
286
307
  type: S.Merge,
287
- name: a,
288
- inputTaskNames: s.map((e) => e.name)
289
- }), s.push({
290
- type: S.OutputToCfgnFile,
291
- inputTaskName: i ? a : s[0].name,
292
- name: "OutputPdfTask",
293
- cfgnFileExtension: "pdf",
294
- cfgnFileName: n,
295
- cfgnFileDisplayName: r
296
- }), y.convertDocument(s);
308
+ name: "MergeTask",
309
+ inputTaskNames: i.map((e) => e.name)
310
+ }), {
311
+ tasks: i,
312
+ lastTaskName: i[i.length - 1].name
313
+ };
297
314
  }
298
315
  //#endregion
299
316
  //#region ../../packages/be-lib/src/lib/hive-enums.ts
300
- var A = {
317
+ var M = {
301
318
  Text: "Text",
302
319
  Number: "Number",
303
320
  Logic: "Logic",
@@ -306,8 +323,8 @@ var A = {
306
323
  TextAsset: "TextAsset",
307
324
  Table: "Table"
308
325
  };
309
- `${A.Text}`, `${A.Number}`;
310
- var j = {
326
+ `${M.Text}`, `${M.Number}`;
327
+ var N = {
311
328
  ValueComponent: "ValueComponent",
312
329
  TableComponent: "TableComponent",
313
330
  RecordComponent: "RecordComponent",
@@ -315,50 +332,36 @@ var j = {
315
332
  GraphicComponent: "GraphicComponent",
316
333
  CheckoutComponent: "CheckoutComponent"
317
334
  };
318
- j.GraphicComponent, j.CheckoutComponent, j.ResourceComponent, j.RecordComponent;
319
- var M = {
320
- ValueEditor: "ValueEditor",
321
- TableEditor: "TableEditor",
322
- Fiber: "Fiber",
323
- FiberEditor: "FiberEditor",
324
- CfgrField: "CfgrField"
325
- };
326
- e.enum([
327
- M.ValueEditor,
328
- M.TableEditor,
329
- M.Fiber,
330
- M.FiberEditor,
331
- M.CfgrField
332
- ]), e.union([
335
+ N.GraphicComponent, N.CheckoutComponent, N.ResourceComponent, N.RecordComponent, e.union([
333
336
  e.string(),
334
337
  e.number(),
335
338
  e.boolean()
336
339
  ]);
337
- var N = (e) => typeof e == "string";
340
+ var P = (e) => typeof e == "string";
338
341
  e.string(), e.enum([
339
- A.Text,
340
- A.Number,
341
- A.Logic
342
- ]), e.string(), e.custom((e) => N(e) && e.toLowerCase() === e);
343
- var P = (e) => e?.toLowerCase() ?? "";
342
+ M.Text,
343
+ M.Number,
344
+ M.Logic
345
+ ]), e.string(), e.custom((e) => P(e) && e.toLowerCase() === e);
346
+ var F = (e) => e?.toLowerCase() ?? "";
344
347
  e.string();
345
- var ae = e.custom((e) => N(e) ? RegExp(`^${j.ValueComponent}<.*>$`).test(e) : !1), oe = e.custom((e) => N(e) ? RegExp(`^${j.RecordComponent}<.*>$`).test(e) : !1), se = e.custom((e) => N(e) ? RegExp(`^${j.ResourceComponent}<.*>$`).test(e) : !1), ce = e.custom((e) => N(e) ? RegExp(`^${j.TableComponent}<.*>$`).test(e) : !1);
348
+ var ae = e.custom((e) => P(e) ? RegExp(`^${N.ValueComponent}<.*>$`).test(e) : !1), oe = e.custom((e) => P(e) ? RegExp(`^${N.RecordComponent}<.*>$`).test(e) : !1), se = e.custom((e) => P(e) ? RegExp(`^${N.ResourceComponent}<.*>$`).test(e) : !1), ce = e.custom((e) => P(e) ? RegExp(`^${N.TableComponent}<.*>$`).test(e) : !1);
346
349
  e.union([
347
350
  ae,
348
351
  ce,
349
352
  oe,
350
353
  se,
351
- e.literal(j.GraphicComponent),
352
- e.literal(j.CheckoutComponent)
354
+ e.literal(N.GraphicComponent),
355
+ e.literal(N.CheckoutComponent)
353
356
  ]);
354
- var F = e.union([
357
+ var I = e.union([
355
358
  e.string(),
356
359
  e.number(),
357
360
  e.boolean()
358
361
  ]), le = e.union([
359
- F,
360
- e.array(F),
361
- e.object({}),
362
+ I,
363
+ e.array(I),
364
+ e.looseObject({}),
362
365
  e.unknown()
363
366
  ]);
364
367
  e.object({
@@ -369,14 +372,28 @@ e.object({
369
372
  }).or(le);
370
373
  //#endregion
371
374
  //#region ../configurator-client/src/cmps-registry.ts
372
- var I = /* @__PURE__ */ new Map();
375
+ var L = /* @__PURE__ */ new Map();
373
376
  function ue(e) {
374
- let t = P(e.name);
375
- I.has(t) || I.set(t, e);
377
+ let t = F(e.name);
378
+ L.has(t) || L.set(t, e);
379
+ }
380
+ //#endregion
381
+ //#region ../../packages/std-lib/src/log.utils.ts
382
+ var de = {
383
+ green: "#36D792",
384
+ yellow: "#D19A66",
385
+ red: "red"
386
+ };
387
+ function fe(e, t) {
388
+ return e && t ? `[${e}.${t}]` : e ? `[${e}]` : t ? `[${t}]` : "";
389
+ }
390
+ function pe(e, t, n = "", r, i = "green") {
391
+ let a = fe(e, t), o = de[i] ?? "inherit";
392
+ console.error(`%c${a}%c ${n}`, `color: ${o}`, "color: inherit", r);
376
393
  }
377
394
  //#endregion
378
395
  //#region ../configurator-client/src/cmps/value-component.ts
379
- var de = class {
396
+ var me = class {
380
397
  name;
381
398
  zodType;
382
399
  constructor(e, t) {
@@ -386,25 +403,30 @@ var de = class {
386
403
  return await m().getCmpValue(this.name);
387
404
  }
388
405
  async setInput(e) {
389
- let t = P(this.name);
390
- await ne().setCmpInput(t, e, this.zodType);
406
+ let t = F(this.name), n = await ne().setCmpInput(t, e, this.zodType);
407
+ n && pe("ConfiguratorClient", "setInput", n);
391
408
  }
392
409
  onValueChanged(e, t = !1, n) {
393
410
  m().onCmpValueChanged(this.name, e, n, t);
394
411
  }
395
- }, fe = () => y.getAssetPaths(), pe = /* @__PURE__ */ function(e) {
412
+ }, R = () => y.getAssetPaths(), he = /* @__PURE__ */ function(e) {
396
413
  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
- }({}), L = b.onAnyCmpValueChanged.bind(b), R = async (e) => {
398
- if (await b.finishConfiguration(e?.input), e.sendDataToParentPage) {
414
+ }({}), z = b.onAnyCmpValueChanged.bind(b), B = async (e) => {
415
+ if (await y.finishConfiguration(e?.input) && e.sendDataToParentPage) {
399
416
  let t = e.transformParentPageData();
400
417
  await _.sendConfigurationFinished(t);
401
418
  }
402
- }, z = async (e) => {
403
- let t = pe[e.platform], n = e.imageUrl ?? "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=", r = {
419
+ }, V = async (e) => {
420
+ await y.restartConfiguration(e);
421
+ }, H = async (e, t) => {
422
+ await y.changeDistributor(e, t);
423
+ }, U = async (e) => {
424
+ let t = he[e.platform], n = e.imageUrl ?? "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+X2ZkAAAAASUVORK5CYII=", r = {
404
425
  ...e,
405
426
  platform: t,
406
427
  imageUrl: n
407
- }, i = await b.shareConfiguration(r);
428
+ }, i = await y.shareConfiguration(r);
429
+ if (!i) return;
408
430
  await y.openShareWindow(e.platform, i);
409
431
  let { shareUrl: a, shareConfigurationId: o } = i;
410
432
  return {
@@ -412,12 +434,12 @@ var de = class {
412
434
  shareConfigurationId: o
413
435
  };
414
436
  };
415
- async function B(e) {
437
+ async function W(e) {
416
438
  return await y.executeIntegration(e);
417
439
  }
418
440
  //#endregion
419
441
  //#region src/utils/cfgr.utils.ts
420
- var V = () => _.isInIFrame(), H = (e) => _.setIFrameSize(e), U = (e) => y.navigateToLogin(e), W = async (e) => {
442
+ var G = () => _.isInIFrame(), K = (e) => _.setIFrameSize(e), q = (e) => y.navigateToLogin(e), J = async (e) => {
421
443
  let { promise: t, resolve: n } = Promise.withResolvers(), r = {};
422
444
  for (let [t, i] of Object.entries(e)) i.onValueChanged((i) => {
423
445
  r[t] = i, Object.keys(e).every((e) => e in r) && n(r);
@@ -426,13 +448,13 @@ var V = () => _.isInIFrame(), H = (e) => _.setIFrameSize(e), U = (e) => y.naviga
426
448
  };
427
449
  //#endregion
428
450
  //#region src/utils/ctrl.utils.ts
429
- function G(e, t) {
451
+ function Y(e, t) {
430
452
  return new i(v.createCtrl("button", e.id, t));
431
453
  }
432
- function K(e, t) {
454
+ function X(e, t) {
433
455
  return new a(v.createCtrl("checkbox", e.id, t));
434
456
  }
435
- function q(e, t) {
457
+ function Z(e, t) {
436
458
  return new l(v.createCtrl("dataview", e.id, {
437
459
  position: t.position,
438
460
  properties: {
@@ -442,7 +464,7 @@ function q(e, t) {
442
464
  }
443
465
  }));
444
466
  }
445
- function J(e, t) {
467
+ function Q(e, t) {
446
468
  return new s(v.createCtrl("combobox", e.id, {
447
469
  position: t.position,
448
470
  properties: {
@@ -452,54 +474,57 @@ function J(e, t) {
452
474
  }
453
475
  }));
454
476
  }
455
- function Y(e, t) {
477
+ function ge(e, t) {
456
478
  return new d(v.createCtrl("text", e.id, t));
457
479
  }
458
- function X(e, t) {
459
- return new u(v.createCtrl("panel", e.id, t));
480
+ function $(e, t) {
481
+ return new ee(v.createCtrl("panel", e.id, t));
460
482
  }
461
- function Z(e, t) {
462
- return new ee(v.createCtrl("textbox", e.id, t));
483
+ function _e(e, t) {
484
+ return new u(v.createCtrl("textbox", e.id, t));
463
485
  }
464
- function Q(e, t) {
486
+ function ve(e, t) {
465
487
  return new c(v.createCtrl("customctrl", e.id, t));
466
488
  }
467
- function $(e, t) {
489
+ function ye(e, t) {
468
490
  return new o(v.createCtrl("collapsible", e.id, t));
469
491
  }
470
492
  //#endregion
471
493
  //#region src/utils/lifecycle.utils.ts
472
- 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) => {
494
+ var be = "`beforeConfiguratorIsRendered` has no effect because it was called after the configurator was already rendered.\nCall it from the top-level code of your entry file. Do not call it from an async callback.", xe = "`beforeConfiguratorIsRendered` is ignored because it was called more than once.\nIt must only be called once.", Se = (e) => {
473
495
  let t = ie.registerBeforeConfiguratorIsRendered(e);
474
- t === "called-after-cfgr-render" ? console.error(me) : t === "already-registered" && console.error(he);
475
- }, _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 = /* @__PURE__ */ n({
476
- addButtonControl: () => G,
477
- addCheckboxControl: () => K,
478
- addCollapsibleControl: () => $,
479
- addComboboxControl: () => J,
480
- addCustomControl: () => Q,
481
- addDataviewControl: () => q,
482
- addInputControl: () => Z,
483
- addPanelControl: () => X,
484
- addTextControl: () => Y,
485
- beforeConfiguratorIsRendered: () => ge,
486
- configuratorIsInIFrame: () => V,
496
+ t === "called-after-cfgr-render" ? console.error(be) : t === "already-registered" && console.error(xe);
497
+ }, Ce = (e, t) => _.sendCustomMsg(e, t), we = (e) => _.redirectParentPage(e), Te = () => _.getParentPageUrl(), Ee = (e, t) => _.fireAnalyticsEvent(e, t), De = (e) => _.onParentPageEvent(e), Oe = async (e, t) => re.createArPage(e, t), ke = /* @__PURE__ */ n({
498
+ addButtonControl: () => Y,
499
+ addCheckboxControl: () => X,
500
+ addCollapsibleControl: () => ye,
501
+ addComboboxControl: () => Q,
502
+ addCustomControl: () => ve,
503
+ addDataviewControl: () => Z,
504
+ addInputControl: () => _e,
505
+ addPanelControl: () => $,
506
+ addTextControl: () => ge,
507
+ beforeConfiguratorIsRendered: () => Se,
508
+ changeDistributor: () => H,
509
+ configuratorIsInIFrame: () => G,
487
510
  convertDocument: () => O,
488
- createArPage: () => Se,
511
+ createArPage: () => Oe,
489
512
  createPdfFromAssets: () => k,
490
- createSyncCmpValuesStore: () => W,
491
- executeIntegration: () => B,
492
- finishConfiguration: () => R,
493
- fireAnalyticsEvent: () => be,
494
- getAssetPaths: () => fe,
495
- getParentPageUrl: () => ye,
496
- navigateToLogin: () => U,
497
- onAnyCmpValueChanged: () => L,
498
- onParentPageEvent: () => xe,
499
- redirectParentPage: () => ve,
500
- sendCustomMsgToParentPage: () => _e,
501
- setConfiguratorIFrameSize: () => H,
502
- shareConfiguration: () => z,
513
+ createSyncCmpValuesStore: () => J,
514
+ createTempPdfFromAssets: () => A,
515
+ executeIntegration: () => W,
516
+ finishConfiguration: () => B,
517
+ fireAnalyticsEvent: () => Ee,
518
+ getAssetPaths: () => R,
519
+ getParentPageUrl: () => Te,
520
+ navigateToLogin: () => q,
521
+ onAnyCmpValueChanged: () => z,
522
+ onParentPageEvent: () => De,
523
+ redirectParentPage: () => we,
524
+ restartConfiguration: () => V,
525
+ sendCustomMsgToParentPage: () => Ce,
526
+ setConfiguratorIFrameSize: () => K,
527
+ shareConfiguration: () => U,
503
528
  uploadFiles: () => T,
504
529
  uploadImages: () => w,
505
530
  uploadTempFiles: () => D,
@@ -510,4 +535,4 @@ var me = "`beforeConfiguratorIsRendered` has no effect because it was called aft
510
535
  //#region src/index.ts
511
536
  console.log(`Loading custom code SDK v${r}`);
512
537
  //#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, R as finishConfiguration, be as fireAnalyticsEvent, fe as getAssetPaths, ye as getParentPageUrl, U as navigateToLogin, L as onAnyCmpValueChanged, xe as onParentPageEvent, ve as redirectParentPage, _e as sendCustomMsgToParentPage, H as setConfiguratorIFrameSize, z as shareConfiguration, T as uploadFiles, w as uploadImages, D as uploadTempFiles, E as uploadTempImages, r as version };
538
+ export { i as Button, ke as CbnSdk, a as Checkbox, o as Collapsible, s as Combobox, C as CreatePdfTaskTypes, c as CustomControl, l as Dataview, S as DocumentConvertTaskTypes, u as Input, ee as Panel, d as Text, me as ValueComponent, Y as addButtonControl, X as addCheckboxControl, ye as addCollapsibleControl, Q as addComboboxControl, ve as addCustomControl, Z as addDataviewControl, _e as addInputControl, $ as addPanelControl, ge as addTextControl, Se as beforeConfiguratorIsRendered, H as changeDistributor, G as configuratorIsInIFrame, O as convertDocument, Oe as createArPage, k as createPdfFromAssets, J as createSyncCmpValuesStore, A as createTempPdfFromAssets, W as executeIntegration, B as finishConfiguration, Ee as fireAnalyticsEvent, R as getAssetPaths, Te as getParentPageUrl, q as navigateToLogin, z as onAnyCmpValueChanged, De as onParentPageEvent, we as redirectParentPage, V as restartConfiguration, Ce as sendCustomMsgToParentPage, K as setConfiguratorIFrameSize, U as shareConfiguration, T as uploadFiles, w as uploadImages, D as uploadTempFiles, E as uploadTempImages, r as version };
package/dist/index.d.ts CHANGED
@@ -91,9 +91,9 @@ declare type AssetName = z.infer<typeof ZAssetName>;
91
91
  *
92
92
  * !!! Info !!!
93
93
  *
94
- * The callback must be registered in the synchronous top-level context of your main entry file.\
95
- * The callback will have **no** effect when registered in any async context, i.e. after any `await` or inside some
96
- * async callback function etc.
94
+ * The callback must be registered in the top-level context of your main entry file.\
95
+ * The callback will have **no** effect when registered in any async callback like `window.setTimeout` or any kind of
96
+ * DOM event listener etc.
97
97
  */
98
98
  export declare const beforeConfiguratorIsRendered: (callback: () => Promise<void>) => void;
99
99
 
@@ -158,6 +158,7 @@ export declare namespace CbnSdk {
158
158
  addPanelControl,
159
159
  addTextControl,
160
160
  beforeConfiguratorIsRendered,
161
+ changeDistributor,
161
162
  configuratorIsInIFrame,
162
163
  finishConfiguration,
163
164
  fireAnalyticsEvent,
@@ -167,6 +168,7 @@ export declare namespace CbnSdk {
167
168
  navigateToLogin,
168
169
  onAnyCmpValueChanged,
169
170
  redirectParentPage,
171
+ restartConfiguration,
170
172
  sendCustomMsgToParentPage,
171
173
  setConfiguratorIFrameSize,
172
174
  shareConfiguration,
@@ -178,6 +180,7 @@ export declare namespace CbnSdk {
178
180
  uploadTempImages,
179
181
  convertDocument,
180
182
  createPdfFromAssets,
183
+ createTempPdfFromAssets,
181
184
  createArPage,
182
185
  version
183
186
  }
@@ -190,6 +193,14 @@ export declare type CfgnFileUploadData<T extends string = string> = {
190
193
  };
191
194
  };
192
195
 
196
+ /**
197
+ * Restarts the configurator with a new configuration for the given distributor.
198
+ *
199
+ * @param distributorName Name of the distributor to switch to. If omitted, switches to the company tenant.
200
+ * @param copyCfgnValues If `true` (default), the values of the current configuration are copied over to the new one.
201
+ */
202
+ export declare const changeDistributor: (distributorName?: string, copyCfgnValues?: boolean) => Promise<void>;
203
+
193
204
  export declare class Checkbox {
194
205
  #private;
195
206
  readonly id: CtrlId;
@@ -600,6 +611,8 @@ declare type CreateInputProperties = {
600
611
  visible: boolean | undefined;
601
612
  cssClasses: string[] | undefined;
602
613
  placeholder: string | undefined;
614
+ tooltipText: string | undefined;
615
+ tooltipPos: ElementPosOption | undefined;
603
616
  };
604
617
 
605
618
  declare type CreatePanelProperties = {
@@ -628,6 +641,9 @@ declare type CreatePanelProperties = {
628
641
  /**
629
642
  * Creates a PDF from one or more assets which will be merged in the given order.
630
643
  *
644
+ * Consider using {@link createTempPdfFromAssets} if the PDF doesn't need to be persisted and
645
+ * isn't relevant for the finished configuration.
646
+ *
631
647
  * Simplified helper built on top of {@link convertDocument}.
632
648
  * Use {@link convertDocument} directly for advanced scenarios.
633
649
  *
@@ -736,6 +752,41 @@ export declare const createSyncCmpValuesStore: <TCmps extends {
736
752
  [id: CmpName]: ValueComponent;
737
753
  }>(cmps: TCmps) => Promise<Readonly<SyncCmpValuesStore<TCmps>>>;
738
754
 
755
+ /**
756
+ * Creates a temporary PDF from one or more assets which will be merged in the given order.
757
+ *
758
+ * Simplified helper built on top of {@link convertDocument}.
759
+ * Use {@link convertDocument} directly for advanced scenarios.
760
+ *
761
+ * @param bundleAliasName Bundle name where the assets are stored
762
+ * @param assetTasks One or more "assets tasks" which will be merged in the given order
763
+ * @param name Optional name which will be used when downloading the file
764
+ * @returns URL to the generated cfgn file, if successful
765
+ *
766
+ * @example
767
+ * ```ts
768
+ * const resultUrl = await createTempPdfFromAssets(
769
+ * 'MyBundle',
770
+ * [
771
+ * {
772
+ * type: 'PdfAsset',
773
+ * assetPath: 'quotePdfAsset',
774
+ * context: {
775
+ * subject: 'MySubject',
776
+ * },
777
+ * },
778
+ * {
779
+ * type: 'Asset',
780
+ * assetPath: 'Pdf2',
781
+ * },
782
+ * ],
783
+ * `Your_quote_${new Date().toISOString()}`
784
+ * );
785
+ * ```
786
+ *
787
+ */
788
+ export declare function createTempPdfFromAssets(bundleAliasName: string, assetTasks: CreatePdfTasks[], name: string): Promise<string | undefined>;
789
+
739
790
  declare type CreateTextProperties = {
740
791
  text: string | undefined;
741
792
  width: string | undefined;
@@ -994,15 +1045,24 @@ export declare type DocumentConvertTask = {
994
1045
  cfgnFileExtension: string;
995
1046
  /** Optional name which will be used when downloading the file */
996
1047
  cfgnFileDisplayName?: string;
1048
+ } | {
1049
+ type: DocumentConvertTaskTypes.OutputToTempCfgnFile;
1050
+ name: string;
1051
+ inputTaskName: string;
1052
+ cfgnFileExtension: string;
1053
+ /** Optional name which will be used when downloading the file */
1054
+ cfgnFileDisplayName?: string;
997
1055
  };
998
1056
 
999
1057
  export declare enum DocumentConvertTaskTypes {
1000
1058
  /** Create a PDF with dynamic content based on the given `context` */
1001
1059
  PdfAsset = 0,
1002
- /** Retrieve an asset to be used for suceeding tasks (e.g. static PDF for merge) */
1060
+ /** Retrieve an asset to be used for succeeding tasks (e.g. static PDF for merge) */
1003
1061
  Asset = 1,
1004
1062
  /** Merge multiple input tasks into a single document */
1005
1063
  Merge = 2,
1064
+ /** Finalize the conversion by storing it as a temporary `Configuration file` */
1065
+ OutputToTempCfgnFile = 3,
1006
1066
  /** Finalize the conversion by storing it as `Configuration file` */
1007
1067
  OutputToCfgnFile = 4
1008
1068
  }
@@ -1348,6 +1408,13 @@ export declare type ProductCustomFields = {
1348
1408
  */
1349
1409
  export declare const redirectParentPage: (url: string) => Promise<ParentPageComResult<void>>;
1350
1410
 
1411
+ /**
1412
+ * Restarts the configurator with a new configuration.
1413
+ *
1414
+ * @param copyCfgnValues If `true`, the values of the current configuration are copied over to the new one.
1415
+ */
1416
+ export declare const restartConfiguration: (copyCfgnValues?: boolean) => Promise<void>;
1417
+
1351
1418
  declare type SdkAssetPaths = {
1352
1419
  babylonJsAssets: {
1353
1420
  [key: AssetName]: UrlString;
@@ -1470,7 +1537,7 @@ export declare const shareConfiguration: (data: {
1470
1537
  */
1471
1538
  shareUrl: string;
1472
1539
  shareConfigurationId: string;
1473
- }>;
1540
+ } | undefined>;
1474
1541
 
1475
1542
  export declare type ShopifyFinishJson = {
1476
1543
  products: {
@@ -1684,7 +1751,7 @@ declare const ZAlignmentBlockOption: z.ZodUnion<readonly [z.ZodLiteral<"topLeft"
1684
1751
 
1685
1752
  declare const ZAssetName: z.ZodString;
1686
1753
 
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.$strip>, z.ZodUnknown]>;
1754
+ 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
1755
 
1689
1756
  declare const ZCtrlId: z.ZodString;
1690
1757
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combeenation/custom-code-sdk",
3
- "version": "0.0.1-rc2",
3
+ "version": "0.0.1-rc4",
4
4
  "description": "Combeenation custom code SDK package",
5
5
  "keywords": [],
6
6
  "homepage": "",
@@ -30,12 +30,12 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@combeenation/configurator-client": "*",
33
- "@microsoft/api-extractor": "7.58.7",
33
+ "@microsoft/api-extractor": "7.59.2",
34
34
  "@repo/std-configs": "*",
35
35
  "@repo/std-lib": "*",
36
36
  "typescript": "6.0.3",
37
- "unplugin-dts": "1.0.1",
38
- "vite": "8.0.14"
37
+ "unplugin-dts": "1.1.1",
38
+ "vite": "8.3.1"
39
39
  },
40
40
  "@comment dependencies": [
41
41
  "All our external (!) sub dependencies shall be included in `vite.config.ts:rolldownOptions.external`.",