@spiffcommerce/core 27.0.0-beta.7123ea0f-ccbb-57f9-919e-cf0e8d93ccc4 → 27.0.0-beta.dd54188f-e25d-5605-a565-cd093566398b

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/index.mjs CHANGED
@@ -5875,7 +5875,14 @@ const Hi = (r) => r.substring(0, 5).toLowerCase().trim() === "data:", Ue = /* @_
5875
5875
  })()
5876
5876
  } : r, ya = 1.1, ts = (r) => {
5877
5877
  var m, g, p, f, C;
5878
- const e = (r.rotation || 0) * Math.PI / 180, a = Math.cos(e), n = -Math.sin(e), i = `text-path-${r.id}`, s = `text-fill-${r.id}`, o = r.x + (r.curved ? 0 : r.width / 2), l = r.y + (r.curved ? 0 : r.height / 2), c = gr.compile(r.text || "")((m = r._renderingConfiguration) == null ? void 0 : m.templatingContext), d = c.split(`
5878
+ const e = (r.rotation || 0) * Math.PI / 180, a = Math.cos(e), n = -Math.sin(e), i = `text-path-${r.id}`, s = `text-fill-${r.id}`, o = r.x + (r.curved ? 0 : r.width / 2), l = r.y + (r.curved ? 0 : r.height / 2);
5879
+ let c = "";
5880
+ try {
5881
+ c = gr.compile(r.text || "")((m = r._renderingConfiguration) == null ? void 0 : m.templatingContext);
5882
+ } catch {
5883
+ c = r.text ?? "";
5884
+ }
5885
+ const d = c.split(`
5879
5886
  `), A = (g = r.strokeColor) != null && g.browserValue && r.strokeThickness ? (p = r.strokeColor) == null ? void 0 : p.browserValue : void 0, u = (f = r.strokeColor) != null && f.browserValue && r.strokeThickness ? r.strokeThickness : void 0;
5880
5887
  if (r.curved && !r.paths || !r.fontData)
5881
5888
  return null;
@@ -10192,26 +10199,30 @@ class Ya extends Dn {
10192
10199
  }
10193
10200
  class mo {
10194
10201
  constructor(t, e, a, n, i, s, o, l, c, d, A, u, h, m = !1, g, p = !1, f = !1, C = !1) {
10202
+ var w;
10195
10203
  this.workflowStatePromiseQueue = new Fn(1), this.initialized = !1, this.readOnly = !1, this.isReloadedTransaction = !1, this.singleVariantsRenderable = !1, this.stepTags = {}, this.renderLayouts = () => {
10196
- var v;
10204
+ var B;
10197
10205
  if (!this.previewService)
10198
10206
  return;
10199
- const w = this.getCommandContext().getAllLayouts(), S = (v = this.getLayoutPreviewService()) == null ? void 0 : v.getAll();
10200
- if (S)
10201
- for (const [, B] of S)
10202
- B.render(w);
10203
- }, this.experience = t, this.client = e, this.updateTransaction = o, this.graphQlClient = l, this.commandContext = s, this.reloadedState = h, this.transaction = c, this.readOnly = m, this.singleVariantsRenderable = f, this.confirmedDesign = !1, this.editedSteps = {}, this.informationResults = [], this.mandatorySteps = {}, this.pendingUpdates = [], this.selectionCost = 0, this.workflow = a, this.stepSpecificServices = {}, this.profanityFilter = n, this.pollers = [], this.allScenes = [], this.layouts = i, this.product = d, this.previewService = A, this.modelContainer = g, this.stepElements = {}, this.stepInitialised = {}, this.stepMetadata = {}, this.stepSelections = {}, this.storage = {}, this.validationErrors = { steps: /* @__PURE__ */ new Map() }, this.confirmCallbacks = [], this.editedCallbacks = [], this.elementsCallbacks = [], this.informationResultCallbacks = [], this.initCallbacks = [], this.mandatoryCallbacks = [], this.makingAdjustmentsCallback = [], this.metadataCallbacks = [], this.selectionCallbacks = [], this.stepSpecificStorageCallbacks = {}, this.storageCallbacks = [], this.validationCallbacks = [], this.recipientCallbacks = [], this.currentAdjustingStepId = "", this.renderableContextService = u, this.isReloadedTransaction = p, this.workflow.steps.forEach((w) => {
10204
- this.stepTags[w.stepName] = w.tags ?? [];
10207
+ const S = this.getCommandContext().getAllLayouts(), v = (B = this.getLayoutPreviewService()) == null ? void 0 : B.getAll();
10208
+ if (v)
10209
+ for (const [, E] of v)
10210
+ E.render(S);
10211
+ }, this.experience = t, this.client = e, this.updateTransaction = o, this.graphQlClient = l, this.commandContext = s, this.reloadedState = h, this.transaction = c, this.readOnly = m, this.singleVariantsRenderable = f, this.confirmedDesign = !1, this.editedSteps = {}, this.informationResults = [], this.mandatorySteps = {}, this.pendingUpdates = [], this.selectionCost = 0, this.workflow = a, this.stepSpecificServices = {}, this.profanityFilter = n, this.pollers = [], this.allScenes = [], this.layouts = i, this.product = d, this.previewService = A, this.modelContainer = g, this.stepElements = {}, this.stepInitialised = {}, this.stepMetadata = {}, this.stepSelections = {}, this.storage = {}, this.validationErrors = { steps: /* @__PURE__ */ new Map() }, this.confirmCallbacks = [], this.editedCallbacks = [], this.elementsCallbacks = [], this.informationResultCallbacks = [], this.initCallbacks = [], this.mandatoryCallbacks = [], this.makingAdjustmentsCallback = [], this.metadataCallbacks = [], this.selectionCallbacks = [], this.stepSpecificStorageCallbacks = {}, this.storageCallbacks = [], this.validationCallbacks = [], this.recipientCallbacks = [], this.currentAdjustingStepId = "", this.renderableContextService = u, (w = this.renderableContextService) == null || w.setWorkflowManager(this), this.isReloadedTransaction = p, this.workflow.steps.forEach((S) => {
10212
+ this.stepTags[S.stepName] = S.tags ?? [];
10205
10213
  }), C && (this.workflowStatePromiseQueue.enabled = !1), this.initializationPromise = this.initializeDefaultWorkflowState(a), this.initializationPromise.then(() => {
10206
10214
  this.initialized = !0;
10207
- }), this.initializationPromise.catch((w) => {
10208
- throw console.error(w), this.initialized = !1, new Error("Workflow initialization failed due to an error. See console.");
10215
+ }), this.initializationPromise.catch((S) => {
10216
+ throw console.error(S), this.initialized = !1, new Error("Workflow initialization failed due to an error. See console.");
10209
10217
  }), this.initializationPromise.finally(
10210
10218
  () => this.getCommandContext().registerStateCallback(() => {
10211
10219
  this.updateStateWithServer(), this.renderLayouts();
10212
10220
  })
10213
10221
  );
10214
10222
  }
10223
+ getTemplatingContext() {
10224
+ return { recipient: this.transaction.recipient };
10225
+ }
10215
10226
  async updateRecipient(t, e, a, n, i, s, o, l, c, d) {
10216
10227
  var A, u, h, m, g;
10217
10228
  if ((A = this.transaction.recipient) != null && A.id)
@@ -12279,7 +12290,8 @@ class Oo {
12279
12290
  const m = Sa(u.layoutState.layout, u.layoutState.elements, {
12280
12291
  renderingConfiguration: {
12281
12292
  purpose: Ht.Print,
12282
- region: { left: A.x, top: A.y, width: A.width, height: A.height }
12293
+ region: { left: A.x, top: A.y, width: A.width, height: A.height },
12294
+ templatingContext: this.workflowManager.getTemplatingContext()
12283
12295
  }
12284
12296
  }), g = un(m);
12285
12297
  await (await Aa.from(h, g, {
@@ -13095,7 +13107,13 @@ class Jo {
13095
13107
  t.forEach(
13096
13108
  (a) => e.set(
13097
13109
  a.id,
13098
- new Xo(a.id, a.name, this, { width: a.width, height: a.height })
13110
+ new Xo(
13111
+ a.id,
13112
+ a.name,
13113
+ this,
13114
+ { width: a.width, height: a.height },
13115
+ this.getWorkflowManager.bind(this)
13116
+ )
13099
13117
  )
13100
13118
  ), this.layouts = e;
13101
13119
  }
@@ -13108,6 +13126,12 @@ class Jo {
13108
13126
  getAll() {
13109
13127
  return this.layouts;
13110
13128
  }
13129
+ setWorkflowManager(t) {
13130
+ this.workflowManager = t;
13131
+ }
13132
+ getWorkflowManager() {
13133
+ return this.workflowManager;
13134
+ }
13111
13135
  }
13112
13136
  const Ko = () => new Promise((r, t) => {
13113
13137
  try {
@@ -13118,8 +13142,8 @@ const Ko = () => new Promise((r, t) => {
13118
13142
  }
13119
13143
  }), _o = Ko();
13120
13144
  class Xo {
13121
- constructor(t, e, a, n) {
13122
- this.hasSetStaticContext = !1, this.interactiveDirty = !1, this.staticCtxDirty = !1, this.lastRequestedRenderArguments = void 0, this.lastCompletedStaticRender = void 0, this.renderQueue = new Fn(2), this.id = t, this.name = e, this.service = a, this.panelSize = n;
13145
+ constructor(t, e, a, n, i) {
13146
+ this.hasSetStaticContext = !1, this.interactiveDirty = !1, this.staticCtxDirty = !1, this.lastRequestedRenderArguments = void 0, this.lastCompletedStaticRender = void 0, this.renderQueue = new Fn(2), this.id = t, this.name = e, this.service = a, this.panelSize = n, this.getWorkflowManager = i;
13123
13147
  }
13124
13148
  getID() {
13125
13149
  return this.id;
@@ -13180,15 +13204,15 @@ class Xo {
13180
13204
  () => {
13181
13205
  this.markLastCompletedStaticRender(), this.setStaticContextDirty(!0);
13182
13206
  },
13183
- e
13207
+ e,
13208
+ this.getWorkflowManager
13184
13209
  )
13185
13210
  );
13186
13211
  }
13187
13212
  }
13188
13213
  class Zo extends Dn {
13189
- // TODO: Do we need to pass this whole array in?
13190
- constructor(t, e, a, n, i) {
13191
- super(), this.layoutId = t, this.ctx = e, this.nonPOTSupport = a, this.onRender = n, this.layouts = i;
13214
+ constructor(t, e, a, n, i, s) {
13215
+ super(), this.layoutId = t, this.ctx = e, this.nonPOTSupport = a, this.onRender = n, this.layouts = i, this.getWorkflowManager = s;
13192
13216
  }
13193
13217
  /**
13194
13218
  * Returns the resolution expected for generated textures.
@@ -13224,20 +13248,24 @@ class Zo extends Dn {
13224
13248
  * a loose target but should be kept in mind when making changes.
13225
13249
  */
13226
13250
  async execute() {
13227
- const t = this.layouts.find((h) => h.layoutState.layout.id === this.layoutId);
13251
+ var h, m;
13252
+ const t = this.layouts.find((g) => g.layoutState.layout.id === this.layoutId);
13228
13253
  if (!t)
13229
13254
  return;
13230
13255
  const e = t.layoutState.elements || [], a = t.layoutState.layout.width, n = t.layoutState.layout.height, i = a === 1 || n === 1 ? { width: 1, height: 1 } : this.getDynamicTextureResolution(), s = i.width, o = i.height;
13231
13256
  let l, c;
13232
13257
  if (this.nonPOTSupport) {
13233
- const h = s / o;
13234
- a / n < h ? (l = s, c = n * (s / a)) : (l = a * (o / n), c = o);
13235
- const g = this.resizeFit({ width: l, height: c });
13236
- l = g.width, c = g.height;
13258
+ const g = s / o;
13259
+ a / n < g ? (l = s, c = n * (s / a)) : (l = a * (o / n), c = o);
13260
+ const f = this.resizeFit({ width: l, height: c });
13261
+ l = f.width, c = f.height;
13237
13262
  } else
13238
13263
  l = i.width, c = i.height;
13239
13264
  const d = Sa(t.layoutState.layout, e, {
13240
- renderingConfiguration: { purpose: Ht.ThreeD }
13265
+ renderingConfiguration: {
13266
+ purpose: Ht.ThreeD,
13267
+ templatingContext: (m = (h = this.getWorkflowManager) == null ? void 0 : h.call(this)) == null ? void 0 : m.getTemplatingContext()
13268
+ }
13241
13269
  }), A = un(d), u = await Aa.from(this.ctx, A, {
13242
13270
  anonymousCrossOrigin: !0,
13243
13271
  ignoreDimensions: !this.nonPOTSupport,
@@ -15754,7 +15782,7 @@ class rd {
15754
15782
  } catch (a) {
15755
15783
  throw console.error(a), new ut("Critical - Unable to synchronize workflow state with server.");
15756
15784
  }
15757
- }, this.options = t, this.options.applicationKey && Rr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 27.0.0"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
15785
+ }, this.options = t, this.options.applicationKey && Rr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 27.0.0-beta.03520a63-5cd6-54a3-a288-e777858aba3b"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
15758
15786
  }
15759
15787
  configure(t) {
15760
15788
  mt.setHubUrl(t.hubUrl), mt.setServerUrl(t.serverUrl), mt.setServicesApiUrl(t.servicesApiUrl), this.marketplaceThemeInstallId = t.marketplaceThemeInstallId, this.marketplaceThemeInstallConfigurationId = t.marketplaceThemeInstallConfigurationId, this.userPoolClientId = t.userPoolClientId, this.userPoolRegion = t.userPoolRegion, this.spiffRegion = t.spiffRegion, t.bearerAuthenticationToken && $r(t.bearerAuthenticationToken), this.options.applicationKey && this.getIntegration(), this.spiffRegion && this.userPoolRegion && this.userPoolClientId && Lt.init(this.spiffRegion, this.userPoolRegion, this.userPoolClientId);