@spiffcommerce/core 39.1.4 → 39.2.1

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.d.ts CHANGED
@@ -737,7 +737,7 @@ declare class AssetService implements AssetManager {
737
737
  uploadAsset(file: FileInfo, assetType: AssetType, anonymous?: boolean, temporary?: boolean): Promise<Asset>;
738
738
  uploadFile(file: File, onProgress: (val: number) => void): Promise<Asset>;
739
739
  removeBackgroundFromAsset(asset: Asset): Promise<Asset>;
740
- vectorizeAsset(asset: Asset): Promise<Asset>;
740
+ vectorizeAsset(asset: Asset, maxColors?: number | undefined): Promise<Asset>;
741
741
  removePersistedAsset(assetKey: string): void;
742
742
  getPersistedAssets(): PersistedAsset[];
743
743
  registerPersistedAssetListener(callback: () => void): void;
@@ -5588,7 +5588,12 @@ declare class FrameStepHandle extends StepHandle<FrameStepData> {
5588
5588
  * @returns A promise that resolves with the newly generated Asset.
5589
5589
  */
5590
5590
  removeBackgroundFromImageSelection(applyNewAsset?: boolean): Promise<Asset>;
5591
- vectorizeImageSelection(applyNewAsset?: boolean): Promise<Asset>;
5591
+ /**
5592
+ * Takes an asset and vectorizes it, stores the new asset in the state, and returns the new asset.
5593
+ * @param asset An optional asset to use for vectorization. If not supplied, the method will attempt to vectorize the current image selection. If there is no current image selection, the method will throw an error.
5594
+ * @returns The newly vectorized asset.
5595
+ */
5596
+ vectorize(asset?: Asset, maxColors?: number | undefined): Promise<Asset>;
5592
5597
  getBackgroundRemovedImageSelection(): Promise<Asset | undefined>;
5593
5598
  getVectorizedImageSelection(): Promise<Asset | undefined>;
5594
5599
  hasOriginalImageSelection(): boolean;
package/dist/index.mjs CHANGED
@@ -3529,8 +3529,8 @@ const ue = (i) => {
3529
3529
  }
3530
3530
  `, Or = C`
3531
3531
  ${ie(!1)}
3532
- mutation VectorizeAsset($key: String!) {
3533
- assetVectorize(key: $key) {
3532
+ mutation VectorizeAsset($key: String!, $options: AssetVectorizeOptions) {
3533
+ assetVectorize(key: $key, options: $options) {
3534
3534
  ...AssetFields
3535
3535
  }
3536
3536
  }
@@ -3684,37 +3684,40 @@ class Vr {
3684
3684
  })();
3685
3685
  return this.bgrmProcessCache.set(e, n), n;
3686
3686
  }
3687
- async vectorizeAsset(t) {
3688
- const e = t.key;
3689
- if (this.bgrmProcessCache.has(e))
3690
- return this.bgrmProcessCache.get(e);
3691
- if (G.has(Vt, e)) {
3692
- const r = this.getLocalOrFromServer(
3693
- G.get(Vt, e)
3687
+ async vectorizeAsset(t, e = void 0) {
3688
+ const a = t.key;
3689
+ if (this.bgrmProcessCache.has(a))
3690
+ return this.bgrmProcessCache.get(a);
3691
+ if (G.has(Vt, a)) {
3692
+ const s = this.getLocalOrFromServer(
3693
+ G.get(Vt, a)
3694
3694
  );
3695
- return this.bgrmProcessCache.set(e, r), r;
3695
+ return this.bgrmProcessCache.set(a, s), s;
3696
3696
  }
3697
- const n = (async () => {
3698
- const r = await S.getShadowGraphqlClient().mutate({
3697
+ const r = (async () => {
3698
+ const s = await S.getShadowGraphqlClient().mutate({
3699
3699
  mutation: Or,
3700
3700
  fetchPolicy: "no-cache",
3701
3701
  errorPolicy: "all",
3702
3702
  variables: {
3703
- key: e
3703
+ key: a,
3704
+ options: {
3705
+ maxColorCount: e
3706
+ }
3704
3707
  }
3705
3708
  });
3706
- if (this.bgrmProcessCache.delete(e), !r.data?.assetVectorize?.key)
3709
+ if (this.bgrmProcessCache.delete(a), !s.data?.assetVectorize?.key)
3707
3710
  throw new Error("Failed to vectorize image");
3708
- return ct.add(r.data.assetVectorize), G.add(
3711
+ return ct.add(s.data.assetVectorize), G.add(
3709
3712
  Vt,
3710
- e,
3711
- r.data.assetVectorize.key
3713
+ a,
3714
+ s.data.assetVectorize.key
3712
3715
  ), this.cache.set(
3713
- r.data.assetVectorize.key,
3714
- Promise.resolve(r.data.assetVectorize)
3715
- ), r.data.assetVectorize;
3716
+ s.data.assetVectorize.key,
3717
+ Promise.resolve(s.data.assetVectorize)
3718
+ ), s.data.assetVectorize;
3716
3719
  })();
3717
- return this.bgrmProcessCache.set(e, n), n;
3720
+ return this.bgrmProcessCache.set(a, r), r;
3718
3721
  }
3719
3722
  removePersistedAsset(t) {
3720
3723
  ct.remove(t), G.delete(Ut, t), G.delete(Vt, t), G.deleteForTransformedKey(Ut, t), G.deleteForTransformedKey(Vt, t);
@@ -16230,7 +16233,7 @@ class Wd {
16230
16233
  } catch (a) {
16231
16234
  throw console.error(a), new ft("Critical - Unable to synchronize workflow state with server.");
16232
16235
  }
16233
- }, this.options = t, this.options.applicationKey && ur(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 39.1.4"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
16236
+ }, this.options = t, this.options.applicationKey && ur(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 39.2.1"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
16234
16237
  }
16235
16238
  configure(t) {
16236
16239
  yt.setHubUrl(t.hubUrl), yt.setServerUrl(t.serverUrl), yt.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 && hr(t.bearerAuthenticationToken), this.options.applicationKey && this.getIntegration(), this.spiffRegion && this.userPoolRegion && this.userPoolClientId && Gt.init(this.spiffRegion, this.userPoolRegion, this.userPoolClientId);
@@ -17365,20 +17368,25 @@ class wc extends tt {
17365
17368
  }
17366
17369
  }), a;
17367
17370
  }
17368
- async vectorizeImageSelection(t = !0) {
17369
- const e = await this.getOriginalImageSelection();
17370
- if (!e)
17371
+ /**
17372
+ * Takes an asset and vectorizes it, stores the new asset in the state, and returns the new asset.
17373
+ * @param asset An optional asset to use for vectorization. If not supplied, the method will attempt to vectorize the current image selection. If there is no current image selection, the method will throw an error.
17374
+ * @returns The newly vectorized asset.
17375
+ */
17376
+ async vectorize(t, e = void 0) {
17377
+ const a = t ?? await this.getOriginalImageSelection();
17378
+ if (!a)
17371
17379
  throw new Error("You must supply an image selection before attempting to vectorize the image.");
17372
- const a = await W.vectorizeAsset(e);
17373
- t && await mt.selectImage(this.step, a, this.manager, !1);
17374
- const n = this.manager.getStepStorage(this.step.stepName)?.framePatternData || {};
17380
+ const n = await W.vectorizeAsset(a, e);
17381
+ await mt.selectImage(this.step, n, this.manager, !1);
17382
+ const r = this.manager.getStepStorage(this.step.stepName)?.framePatternData || {};
17375
17383
  return this.manager.updateStorage(this.step.stepName, {
17376
17384
  framePatternData: {
17377
- ...n,
17378
- vectorizedAssetKey: a.key,
17379
- useOriginalAsset: !t
17385
+ ...r,
17386
+ vectorizedAssetKey: n.key,
17387
+ useOriginalAsset: !1
17380
17388
  }
17381
- }), a;
17389
+ }), n;
17382
17390
  }
17383
17391
  async getBackgroundRemovedImageSelection() {
17384
17392
  const t = this.manager.getStepStorage(this.step.stepName)?.framePatternData?.backgroundRemovedAssetKey;