@spiffcommerce/core 21.12.0 → 21.13.0-alpha.0
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 +7 -4
- package/dist/index.js +131 -95
- package/dist/index.umd.cjs +25 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHttpLink as IA, InMemoryCache as fA, ApolloClient as DA, from as FA, gql as D } from "@apollo/client/core";
|
|
2
|
-
import { fetch as et, getAttributesFromArrayBuffer as Rt, AssetType as ut, StepType as y, getFrameData as tt, frameDataCache as yA, GroupCommand as v, UpdateFramePattern as Ht, UpdateFrameThresholdSettingsCommand as MA, calculateOffsets as At, LayoutElementType as k, generate as J, CreateElementCommand as
|
|
2
|
+
import { fetch as et, getAttributesFromArrayBuffer as Rt, AssetType as ut, StepType as y, getFrameData as tt, frameDataCache as yA, GroupCommand as v, UpdateFramePattern as Ht, UpdateFrameThresholdSettingsCommand as MA, calculateOffsets as At, LayoutElementType as k, generate as J, CreateElementCommand as T, generateSVGWithUnknownColors as Ut, svgObjectURL as Pe, fetchAsString as _, DeleteElementCommand as ee, generateDefaultRectangleFrameSvg as Ct, GetSVGDimensions as SA, patternImageDataCache as Qt, fetchAsArrayBuffer as YA, findElement as xe, modifySVGWithElementProperties as PA, IllustrationColorCommand as We, IllustrationCacheCommand as xA, getFontMetrics as NA, getPatternImageData as Xe, FontAlignmentCommand as RA, FontColorCommand as HA, FontImageFillCommand as Oe, applyTextTransformations as qe, determineCorrectFontSizeAndLines as Me, FontSourceCommand as mt, loadFont as at, TextChangeCommand as UA, FontSizeCommand as vA, createElementNS as GA, createElement as Qe, _loadFontExternalDataURL as nt, UpdateWorkflowStateCommand as pt, CommandContext as kA, createCanvas as Ne, getSvgElement as vt, LayoutRenderingPurpose as Gt, renderPapyrusComponentAsString as kt, loadImage as bt, getDomParser as Jt, toBase64 as It, getVariant as bA, generateFrameSVG as JA, getDefaultVariant as be, domParser as Lt, sanitizeSvgTree as Tt, traverse as LA, xmlSerializer as Ot, CreateLayoutCommand as TA, AspectType as Be, rehydrateSerializedLayout as Ae } from "@spiffcommerce/papyrus";
|
|
3
3
|
import { AspectType as es, AssetType as ts, BringForwardCommand as As, BringToBackCommand as as, BringToFrontCommand as ns, CanvasCommand as is, CommandContext as ss, CreateElementCommand as os, CreateLayoutCommand as rs, DeleteElementCommand as cs, FontAlignmentCommand as gs, FontColorCommand as ls, FontSizeCommand as Bs, FontSourceCommand as ds, GroupCommand as ws, LayoutElementFactory as hs, LayoutElementType as Es, MoveCommand as us, ResizeCommand as Cs, RotateCommand as Qs, SendBackwardsCommand as ms, StepAspectType as ps, StepType as Is, TextChangeCommand as fs, UnitOfMeasurement as Ds, UpdateImageSourceCommand as Fs, dataUrlFromExternalUrl as ys, determineCorrectFontSizeAndLines as Ms, findElement as Ss, frameDataCache as Ys, generate as Ps, generateSVGWithUnknownColors as xs, getAttributesFromArrayBuffer as Ns, getAxisAlignedBoundingBox as Rs, getFrameData as Hs, getSvgElement as Us, loadFont as vs, patternImageDataCache as Gs, registerFetchImplementation as ks, registerWindowImplementation as bs, rehydrateSerializedLayout as Js, setCanvasModule as Ls } from "@spiffcommerce/papyrus";
|
|
4
|
-
import { setContext as
|
|
4
|
+
import { setContext as OA } from "@apollo/client/link/context";
|
|
5
5
|
import { onError as zA } from "@apollo/client/link/error";
|
|
6
6
|
import { Pith as zt } from "pith";
|
|
7
7
|
import Kt from "lodash.debounce";
|
|
@@ -180,7 +180,7 @@ class $A {
|
|
|
180
180
|
const e = IA({
|
|
181
181
|
uri: `${$.getServerUrl()}/graphql`,
|
|
182
182
|
fetch: et
|
|
183
|
-
}), t =
|
|
183
|
+
}), t = OA(async (i, s) => {
|
|
184
184
|
const { headers: o } = s, r = o || {}, g = await ZA(), B = s.bearer ?? g.bearer, l = s.partnerId ?? g.partnerId, d = s.activeIntegration ?? g.activeIntegration, w = s.transactionOwnerId, E = s.customerToken ?? g.customerToken, h = s.applicationKey ?? g.applicationKey, u = s.bundleOwnerId;
|
|
185
185
|
try {
|
|
186
186
|
if (window && window.__SENTRY__) {
|
|
@@ -1475,7 +1475,12 @@ function pe(c, e, t) {
|
|
|
1475
1475
|
}
|
|
1476
1476
|
class Ya {
|
|
1477
1477
|
constructor(e) {
|
|
1478
|
-
this.minZoomScale = [0.03], this.maxZoomScale = [20], this._debouncedUpdateFrameOffsets = Kt(this.updateFrameOffsets, 200), this.targetElements = [], this.onFrameDataChangeListeners = [], this.onZoomChangeListeners = [], this.forceImageCover = e, this.thresholdSettings = {
|
|
1478
|
+
this.minZoomScale = [0.03], this.maxZoomScale = [20], this._debouncedUpdateFrameOffsets = Kt(this.updateFrameOffsets, 200), this.targetElements = [], this.onFrameDataChangeListeners = [], this.onZoomChangeListeners = [], this.forceImageCover = e, this.thresholdSettings = {
|
|
1479
|
+
useThreshold: !1,
|
|
1480
|
+
invertThreshold: !1,
|
|
1481
|
+
threshold: 128,
|
|
1482
|
+
thresholdSaturation: 0.5
|
|
1483
|
+
};
|
|
1479
1484
|
}
|
|
1480
1485
|
/**
|
|
1481
1486
|
* When we want to connect a workflow manager to the state of the image cropper we
|
|
@@ -1573,9 +1578,11 @@ class Ya {
|
|
|
1573
1578
|
/**
|
|
1574
1579
|
* Sets the image currently contained by this frame.
|
|
1575
1580
|
* @param value The new image as an ImageData property
|
|
1581
|
+
* @param [recalculateOffsets=true] Optional: Enable/disable re-calculating of frame offsets.
|
|
1582
|
+
* Useful when you are replacing an image with the exact same dimensions (e.g. alterations to an image). Default: `true`.
|
|
1576
1583
|
*/
|
|
1577
|
-
setPatternData(e) {
|
|
1578
|
-
this.imageData = e, e && this.frameData && (this.recalculateOffsets(e), this.updateOffsets(this.offsets, void 0, !0)), this.imageData && this.frameData && this.recalculateZoomLimits(this.imageData, this.frameData);
|
|
1584
|
+
setPatternData(e, t = !0) {
|
|
1585
|
+
this.imageData = e, e && this.frameData && (t && this.recalculateOffsets(e), this.updateOffsets(this.offsets, void 0, !0)), this.imageData && this.frameData && this.recalculateZoomLimits(this.imageData, this.frameData);
|
|
1579
1586
|
}
|
|
1580
1587
|
/**
|
|
1581
1588
|
* Modify the offsets of the frame.
|
|
@@ -1597,13 +1604,26 @@ class Ya {
|
|
|
1597
1604
|
}
|
|
1598
1605
|
(!this.offsets || this.offsets.length !== this.frameData.length) && (this.offsets = new Array(this.frameData.length)), this.frameData.forEach((i, s) => {
|
|
1599
1606
|
this.offsets[s] = Sa(e[s], i, this.imageData, this.forceImageCover);
|
|
1600
|
-
}), this._debouncedUpdateFrameOffsets(
|
|
1607
|
+
}), this._debouncedUpdateFrameOffsets(
|
|
1608
|
+
this.offsets,
|
|
1609
|
+
a,
|
|
1610
|
+
this.frameData,
|
|
1611
|
+
this.thresholdSettings,
|
|
1612
|
+
this.targetElements,
|
|
1613
|
+
t
|
|
1614
|
+
);
|
|
1601
1615
|
}
|
|
1602
1616
|
getThresholdSettings() {
|
|
1603
1617
|
return this.thresholdSettings;
|
|
1604
1618
|
}
|
|
1605
1619
|
setThresholdSettings(e) {
|
|
1606
|
-
this.thresholdSettings = e, this.imageData && this.frameData && this._debouncedUpdateFrameOffsets(
|
|
1620
|
+
this.thresholdSettings = e, this.imageData && this.frameData && this._debouncedUpdateFrameOffsets(
|
|
1621
|
+
this.offsets,
|
|
1622
|
+
this.imageData,
|
|
1623
|
+
this.frameData,
|
|
1624
|
+
e,
|
|
1625
|
+
this.targetElements
|
|
1626
|
+
);
|
|
1607
1627
|
}
|
|
1608
1628
|
// Allows users of the frame service to listen to frame data changes.
|
|
1609
1629
|
onFrameDataChanged(e) {
|
|
@@ -1634,7 +1654,13 @@ class Ya {
|
|
|
1634
1654
|
s(
|
|
1635
1655
|
new v([
|
|
1636
1656
|
new Ht(o, t, e[r]),
|
|
1637
|
-
new MA(
|
|
1657
|
+
new MA(
|
|
1658
|
+
o,
|
|
1659
|
+
a.useThreshold,
|
|
1660
|
+
a.invertThreshold,
|
|
1661
|
+
a.threshold,
|
|
1662
|
+
a.thresholdSaturation
|
|
1663
|
+
)
|
|
1638
1664
|
])
|
|
1639
1665
|
);
|
|
1640
1666
|
}), this.stepName && this.workflowManager.updateStorage(this.stepName, {
|
|
@@ -1655,7 +1681,13 @@ class Ya {
|
|
|
1655
1681
|
recalculateOffsets(e) {
|
|
1656
1682
|
this.frameData && ((!this.offsets || this.offsets.length !== this.frameData.length) && (this.offsets = new Array(this.frameData.length)), this.frameData.forEach((t, A) => {
|
|
1657
1683
|
this.offsets[A] = At(e, t);
|
|
1658
|
-
}), this._debouncedUpdateFrameOffsets(
|
|
1684
|
+
}), this._debouncedUpdateFrameOffsets(
|
|
1685
|
+
this.offsets,
|
|
1686
|
+
e,
|
|
1687
|
+
this.frameData,
|
|
1688
|
+
this.thresholdSettings,
|
|
1689
|
+
this.targetElements
|
|
1690
|
+
));
|
|
1659
1691
|
}
|
|
1660
1692
|
}
|
|
1661
1693
|
class St {
|
|
@@ -1698,7 +1730,7 @@ class St {
|
|
|
1698
1730
|
id: d.id,
|
|
1699
1731
|
region: a
|
|
1700
1732
|
},
|
|
1701
|
-
command: new
|
|
1733
|
+
command: new T(d, n)
|
|
1702
1734
|
};
|
|
1703
1735
|
} else {
|
|
1704
1736
|
const l = this.configuration.type === y.SilentIllustration ? (B = this.configuration.data.asset) == null ? void 0 : B.fileLink : i, w = await Ut(await (async () => new Promise((h, u) => {
|
|
@@ -1733,7 +1765,7 @@ class St {
|
|
|
1733
1765
|
id: E.id,
|
|
1734
1766
|
region: a
|
|
1735
1767
|
},
|
|
1736
|
-
command: new
|
|
1768
|
+
command: new T(E, n)
|
|
1737
1769
|
};
|
|
1738
1770
|
}
|
|
1739
1771
|
}, this.configuration = e, this.layouts = t, this.product = A || void 0;
|
|
@@ -1871,7 +1903,7 @@ class xa {
|
|
|
1871
1903
|
throw new Error("Region not found");
|
|
1872
1904
|
if (!B || !g)
|
|
1873
1905
|
throw new Error("Neither a region or layout found!");
|
|
1874
|
-
return new
|
|
1906
|
+
return new T(
|
|
1875
1907
|
{
|
|
1876
1908
|
stepRegion: g,
|
|
1877
1909
|
stepName: a,
|
|
@@ -1952,7 +1984,7 @@ class Ra {
|
|
|
1952
1984
|
const u = (E = t.getStepSpecificServices(e.stepName)) == null ? void 0 : E.frameService;
|
|
1953
1985
|
if (!u)
|
|
1954
1986
|
throw new Error("Frame service unavailable, cannot load pattern!");
|
|
1955
|
-
await this.loadPatternFromString(B, u), t.updateMetadata(e.stepName, { image: B }), t.updateStorage(e.stepName, {
|
|
1987
|
+
await this.loadPatternFromString(B, u, !0), t.updateMetadata(e.stepName, { image: B }), t.updateStorage(e.stepName, {
|
|
1956
1988
|
framePatternSrc: B
|
|
1957
1989
|
});
|
|
1958
1990
|
}
|
|
@@ -1984,18 +2016,22 @@ class Ra {
|
|
|
1984
2016
|
await t.setSelectionsAndElements(e.stepName, [], o, g);
|
|
1985
2017
|
}
|
|
1986
2018
|
}
|
|
1987
|
-
selectImage(e, t, A) {
|
|
1988
|
-
|
|
2019
|
+
selectImage(e, t, A, a = !0) {
|
|
2020
|
+
var o;
|
|
2021
|
+
const n = this.patternSource(t), i = (o = A.getStepStorage(e.stepName)) == null ? void 0 : o.framePatternSrc;
|
|
2022
|
+
return i && i === n ? Promise.resolve() : (A.setEditedStatus(e.stepName, !0), (t.fileLink || "").endsWith("pdf") ? new Promise((r) => {
|
|
1989
2023
|
A.addPoller(
|
|
1990
2024
|
new aA(
|
|
1991
2025
|
async () => {
|
|
1992
|
-
var
|
|
1993
|
-
const
|
|
1994
|
-
return
|
|
2026
|
+
var d;
|
|
2027
|
+
const B = (d = (await G.getLocalOrFromServer(t.key || "")).versions) == null ? void 0 : d.find((w) => w.name === "svg");
|
|
2028
|
+
return B ? (await fetch(B.link)).status === 200 : !1;
|
|
1995
2029
|
},
|
|
1996
2030
|
() => {
|
|
1997
|
-
G.getLocalOrFromServer(t.key || "").then((
|
|
1998
|
-
this.loadPatternFromAsset(
|
|
2031
|
+
G.getLocalOrFromServer(t.key || "").then((g) => {
|
|
2032
|
+
this.loadPatternFromAsset(g, e, A, a).then(
|
|
2033
|
+
r
|
|
2034
|
+
);
|
|
1999
2035
|
});
|
|
2000
2036
|
},
|
|
2001
2037
|
() => {
|
|
@@ -2003,7 +2039,7 @@ class Ra {
|
|
|
2003
2039
|
}
|
|
2004
2040
|
)
|
|
2005
2041
|
);
|
|
2006
|
-
}) : this.loadPatternFromAsset(t, e, A);
|
|
2042
|
+
}) : this.loadPatternFromAsset(t, e, A, a));
|
|
2007
2043
|
}
|
|
2008
2044
|
async selectVariant(e, t, A, a, n) {
|
|
2009
2045
|
const i = await this.selectVariantCommand(
|
|
@@ -2016,7 +2052,7 @@ class Ra {
|
|
|
2016
2052
|
i && (i.command && a.getCommandDispatcher()(i.command), i.followup && await i.followup());
|
|
2017
2053
|
}
|
|
2018
2054
|
getCreateElementCommand(e, t, A, a) {
|
|
2019
|
-
return new
|
|
2055
|
+
return new T(
|
|
2020
2056
|
{
|
|
2021
2057
|
id: e,
|
|
2022
2058
|
type: k.Frame,
|
|
@@ -2044,23 +2080,23 @@ class Ra {
|
|
|
2044
2080
|
A
|
|
2045
2081
|
);
|
|
2046
2082
|
}
|
|
2047
|
-
async loadPatternFromString(e, t) {
|
|
2083
|
+
async loadPatternFromString(e, t, A) {
|
|
2048
2084
|
if (e.endsWith("svg")) {
|
|
2049
|
-
const
|
|
2085
|
+
const a = await SA(e), n = a.width, i = a.height, s = {
|
|
2050
2086
|
src: e,
|
|
2051
|
-
width:
|
|
2052
|
-
height:
|
|
2053
|
-
aspect:
|
|
2087
|
+
width: n,
|
|
2088
|
+
height: i,
|
|
2089
|
+
aspect: n / i
|
|
2054
2090
|
};
|
|
2055
|
-
Qt.set(e,
|
|
2091
|
+
Qt.set(e, s), t.setPatternData(s, A);
|
|
2056
2092
|
} else {
|
|
2057
|
-
const
|
|
2093
|
+
const a = await YA(e, !0), n = await Rt(a), i = {
|
|
2058
2094
|
src: e,
|
|
2059
|
-
width:
|
|
2060
|
-
height:
|
|
2061
|
-
aspect:
|
|
2095
|
+
width: n.width,
|
|
2096
|
+
height: n.height,
|
|
2097
|
+
aspect: n.width / n.height
|
|
2062
2098
|
};
|
|
2063
|
-
Qt.set(e,
|
|
2099
|
+
Qt.set(e, i), t.setPatternData(i, A);
|
|
2064
2100
|
}
|
|
2065
2101
|
}
|
|
2066
2102
|
async selectVariantCommand(e, t, A, a, n, i) {
|
|
@@ -2120,7 +2156,7 @@ class Ra {
|
|
|
2120
2156
|
)) == null ? void 0 : d.frameService;
|
|
2121
2157
|
if (!w)
|
|
2122
2158
|
throw new Error("Frame service unavailable, cannot load pattern!");
|
|
2123
|
-
await this.loadPatternFromString(i, w);
|
|
2159
|
+
await this.loadPatternFromString(i, w, !0);
|
|
2124
2160
|
}
|
|
2125
2161
|
}
|
|
2126
2162
|
);
|
|
@@ -2140,14 +2176,14 @@ class Ra {
|
|
|
2140
2176
|
return A;
|
|
2141
2177
|
throw new he(e);
|
|
2142
2178
|
}
|
|
2143
|
-
async loadPatternFromAsset(e, t, A) {
|
|
2144
|
-
var
|
|
2145
|
-
const
|
|
2146
|
-
if (!
|
|
2179
|
+
async loadPatternFromAsset(e, t, A, a) {
|
|
2180
|
+
var o;
|
|
2181
|
+
const n = this.patternSource(e), i = A.markUpdatePending(), s = (o = A.getStepSpecificServices(t.stepName)) == null ? void 0 : o.frameService;
|
|
2182
|
+
if (!s)
|
|
2147
2183
|
throw new Error("Frame service unavailable, cannot load pattern!");
|
|
2148
|
-
await this.loadPatternFromString(
|
|
2149
|
-
framePatternSrc:
|
|
2150
|
-
}), A.markUpdateCompleted(
|
|
2184
|
+
await this.loadPatternFromString(n, s, a), A.updateMetadata(t.stepName, { image: n }), A.updateStorage(t.stepName, {
|
|
2185
|
+
framePatternSrc: n
|
|
2186
|
+
}), A.markUpdateCompleted(i);
|
|
2151
2187
|
}
|
|
2152
2188
|
}
|
|
2153
2189
|
const Se = new Ra();
|
|
@@ -2160,7 +2196,7 @@ class Ha {
|
|
|
2160
2196
|
});
|
|
2161
2197
|
}
|
|
2162
2198
|
getCreateElementCommand(e, t, A, a) {
|
|
2163
|
-
return new
|
|
2199
|
+
return new T(
|
|
2164
2200
|
{
|
|
2165
2201
|
stepRegion: t,
|
|
2166
2202
|
stepName: a.stepName,
|
|
@@ -2564,7 +2600,7 @@ class Ga {
|
|
|
2564
2600
|
return console.error(`Can not find layout for region: ${l.panelId}`), null;
|
|
2565
2601
|
const u = [];
|
|
2566
2602
|
return d && u.push(new ee(w)), u.push(
|
|
2567
|
-
new
|
|
2603
|
+
new T(
|
|
2568
2604
|
{
|
|
2569
2605
|
stepRegion: l,
|
|
2570
2606
|
stepName: e.stepName,
|
|
@@ -2692,7 +2728,7 @@ class ba {
|
|
|
2692
2728
|
const E = J();
|
|
2693
2729
|
return {
|
|
2694
2730
|
regionElement: { id: E, region: l },
|
|
2695
|
-
command: new
|
|
2731
|
+
command: new T(
|
|
2696
2732
|
{
|
|
2697
2733
|
stepName: e.stepName,
|
|
2698
2734
|
stepRegion: l,
|
|
@@ -2922,7 +2958,7 @@ class La {
|
|
|
2922
2958
|
return {
|
|
2923
2959
|
id: C,
|
|
2924
2960
|
region: d,
|
|
2925
|
-
command: new
|
|
2961
|
+
command: new T(
|
|
2926
2962
|
{
|
|
2927
2963
|
stepRegion: d,
|
|
2928
2964
|
stepName: e.stepName,
|
|
@@ -2961,7 +2997,7 @@ class La {
|
|
|
2961
2997
|
}
|
|
2962
2998
|
}
|
|
2963
2999
|
const le = new La();
|
|
2964
|
-
class
|
|
3000
|
+
class Ta {
|
|
2965
3001
|
constructor() {
|
|
2966
3002
|
this.latestToast = null, this.toastType = null, this.toastCallbacks = [];
|
|
2967
3003
|
}
|
|
@@ -2986,7 +3022,7 @@ class Oa {
|
|
|
2986
3022
|
);
|
|
2987
3023
|
}
|
|
2988
3024
|
}
|
|
2989
|
-
const
|
|
3025
|
+
const Oa = new Ta(), ze = 30;
|
|
2990
3026
|
class ve extends Error {
|
|
2991
3027
|
constructor(e) {
|
|
2992
3028
|
super(e), Object.setPrototypeOf(this, new.target.prototype), this.name = ve.name;
|
|
@@ -3158,7 +3194,7 @@ class Ka {
|
|
|
3158
3194
|
fillImage: t
|
|
3159
3195
|
});
|
|
3160
3196
|
for (const r of A) {
|
|
3161
|
-
const g = new
|
|
3197
|
+
const g = new Oe(r.id, t);
|
|
3162
3198
|
n(g);
|
|
3163
3199
|
}
|
|
3164
3200
|
}
|
|
@@ -3292,7 +3328,7 @@ class Ka {
|
|
|
3292
3328
|
if (a.length > 0) {
|
|
3293
3329
|
const l = a.map((E) => new mt(E.id, g));
|
|
3294
3330
|
if (o) {
|
|
3295
|
-
const E = a.map((h) => new
|
|
3331
|
+
const E = a.map((h) => new Oe(h.id, o));
|
|
3296
3332
|
l.push(...E);
|
|
3297
3333
|
}
|
|
3298
3334
|
const d = await this.changeInputTextWithRegion(
|
|
@@ -3333,7 +3369,7 @@ class Ka {
|
|
|
3333
3369
|
), w = l.flatMap((h) => h.commands);
|
|
3334
3370
|
if (o) {
|
|
3335
3371
|
const h = l.map(
|
|
3336
|
-
(u) => new
|
|
3372
|
+
(u) => new Oe(u.regionElement.id, o)
|
|
3337
3373
|
);
|
|
3338
3374
|
w.push(...h);
|
|
3339
3375
|
}
|
|
@@ -3366,8 +3402,8 @@ class Ka {
|
|
|
3366
3402
|
let u;
|
|
3367
3403
|
if (h && h.variants) {
|
|
3368
3404
|
const N = h.variants.find((R) => {
|
|
3369
|
-
var
|
|
3370
|
-
return R.id === ((
|
|
3405
|
+
var O;
|
|
3406
|
+
return R.id === ((O = h.defaultVariant) == null ? void 0 : O.id);
|
|
3371
3407
|
}) || h.variants[0];
|
|
3372
3408
|
u = this.createTextFillSpotColor(h, N), i.updateStorage(e, {
|
|
3373
3409
|
colorProfileAssetKey: (E = h.colorProfile) == null ? void 0 : E.key
|
|
@@ -3420,7 +3456,7 @@ class Ka {
|
|
|
3420
3456
|
Q.push(
|
|
3421
3457
|
this.generateTextChangeCommandsForRegion(F, A, m.id, P)
|
|
3422
3458
|
);
|
|
3423
|
-
const S = new
|
|
3459
|
+
const S = new T(m, d);
|
|
3424
3460
|
return {
|
|
3425
3461
|
regionElement: { id: w, region: B },
|
|
3426
3462
|
commands: [S, ...Q],
|
|
@@ -3431,7 +3467,7 @@ class Ka {
|
|
|
3431
3467
|
throw console.log(h), new ve("Error adding font to region");
|
|
3432
3468
|
}
|
|
3433
3469
|
}, g = await Promise.all(A.regions.map(r)).catch((B) => {
|
|
3434
|
-
throw B instanceof ve ? (
|
|
3470
|
+
throw B instanceof ve ? (Oa.setLatestToast("Failed to load font.", ke.Error), B) : B instanceof Ge ? B : new Error(B);
|
|
3435
3471
|
});
|
|
3436
3472
|
return await i.setSelectionsAndElements(
|
|
3437
3473
|
e,
|
|
@@ -6470,7 +6506,7 @@ const En = async (c) => {
|
|
|
6470
6506
|
}, EA = async (c, e, t, A, a, n, i, s, o, r) => {
|
|
6471
6507
|
var F;
|
|
6472
6508
|
await (async () => {
|
|
6473
|
-
var
|
|
6509
|
+
var O;
|
|
6474
6510
|
if (r !== void 0)
|
|
6475
6511
|
return r;
|
|
6476
6512
|
await c.outstandingRequestsPromise();
|
|
@@ -6482,7 +6518,7 @@ const En = async (c) => {
|
|
|
6482
6518
|
context: {
|
|
6483
6519
|
transactionOwnerId: P
|
|
6484
6520
|
}
|
|
6485
|
-
}), R = (
|
|
6521
|
+
}), R = (O = N.data) == null ? void 0 : O.transactions[0].workflowState;
|
|
6486
6522
|
return N.errors ? (N.errors.forEach((L) => {
|
|
6487
6523
|
N.errors && console.log("Server Error:", L.message);
|
|
6488
6524
|
}), null) : R ?? null;
|
|
@@ -6492,16 +6528,16 @@ const En = async (c) => {
|
|
|
6492
6528
|
let S = 0;
|
|
6493
6529
|
if (Object.keys(n).length > 0)
|
|
6494
6530
|
for (const N of Object.keys(n)) {
|
|
6495
|
-
const R = n[N],
|
|
6531
|
+
const R = n[N], O = e.steps.find((L) => L.stepName === N);
|
|
6496
6532
|
for (let L = 0; L < R.selections.length; ++L) {
|
|
6497
6533
|
const W = R.selections[L];
|
|
6498
|
-
if (
|
|
6499
|
-
const
|
|
6500
|
-
P[
|
|
6534
|
+
if (O && (!M || O.option && (O.option.variants || []).length > 1 && !O.data.hideSelectionInCart && !O.data.hideSelectionsInCart)) {
|
|
6535
|
+
const Te = O.stepTitle;
|
|
6536
|
+
P[Te] ? P[Te].push({
|
|
6501
6537
|
id: W.id || "",
|
|
6502
6538
|
name: W.name,
|
|
6503
6539
|
priceModifier: W.priceModifier
|
|
6504
|
-
}) : P[
|
|
6540
|
+
}) : P[Te] = [
|
|
6505
6541
|
{
|
|
6506
6542
|
id: W.id || "",
|
|
6507
6543
|
name: W.name,
|
|
@@ -7117,7 +7153,7 @@ const Dn = [
|
|
|
7117
7153
|
if (!w)
|
|
7118
7154
|
throw new z(d);
|
|
7119
7155
|
const E = J();
|
|
7120
|
-
return new
|
|
7156
|
+
return new T(
|
|
7121
7157
|
{
|
|
7122
7158
|
id: E,
|
|
7123
7159
|
src: g,
|
|
@@ -7158,7 +7194,7 @@ const Dn = [
|
|
|
7158
7194
|
top: a.y
|
|
7159
7195
|
});
|
|
7160
7196
|
return [
|
|
7161
|
-
new
|
|
7197
|
+
new T(
|
|
7162
7198
|
{
|
|
7163
7199
|
id: l,
|
|
7164
7200
|
path: B.path,
|
|
@@ -7206,7 +7242,7 @@ const Dn = [
|
|
|
7206
7242
|
const o = await _(s, !0), r = /<svg.*?<\/svg>/s, g = o.match(r) || [], B = (g == null ? void 0 : g.length) > 0 ? g[0] : "", w = Lt().parseFromString(B, "image/svg+xml").firstElementChild;
|
|
7207
7243
|
if (!w)
|
|
7208
7244
|
return console.error("Failed to read SVG."), [];
|
|
7209
|
-
|
|
7245
|
+
Tt(w);
|
|
7210
7246
|
const E = {};
|
|
7211
7247
|
LA(w, (f) => {
|
|
7212
7248
|
Dn.includes(f.tagName) && !f.attributes.getNamedItem("fill") && f.setAttribute("fill", "#000000");
|
|
@@ -7221,7 +7257,7 @@ const Dn = [
|
|
|
7221
7257
|
f.classList.add(N), E[N] = { browserValue: P };
|
|
7222
7258
|
}
|
|
7223
7259
|
});
|
|
7224
|
-
const u =
|
|
7260
|
+
const u = Ot().serializeToString(w), C = a.colors;
|
|
7225
7261
|
if (C) {
|
|
7226
7262
|
for (const [f, F] of Object.entries(E))
|
|
7227
7263
|
for (const M of Object.keys(C))
|
|
@@ -7235,7 +7271,7 @@ const Dn = [
|
|
|
7235
7271
|
if (!F)
|
|
7236
7272
|
throw new z(f);
|
|
7237
7273
|
const M = J();
|
|
7238
|
-
return new
|
|
7274
|
+
return new T(
|
|
7239
7275
|
{
|
|
7240
7276
|
colors: E,
|
|
7241
7277
|
id: M,
|
|
@@ -7264,7 +7300,7 @@ const Dn = [
|
|
|
7264
7300
|
if (!r)
|
|
7265
7301
|
throw new z(o);
|
|
7266
7302
|
const g = J();
|
|
7267
|
-
return new
|
|
7303
|
+
return new T(
|
|
7268
7304
|
{
|
|
7269
7305
|
colors: {},
|
|
7270
7306
|
id: g,
|
|
@@ -7307,7 +7343,7 @@ const Dn = [
|
|
|
7307
7343
|
if (!d)
|
|
7308
7344
|
throw new z(l);
|
|
7309
7345
|
const w = J();
|
|
7310
|
-
return new
|
|
7346
|
+
return new T(
|
|
7311
7347
|
{
|
|
7312
7348
|
id: w,
|
|
7313
7349
|
src: s,
|
|
@@ -7364,7 +7400,7 @@ const Dn = [
|
|
|
7364
7400
|
/>
|
|
7365
7401
|
</svg>
|
|
7366
7402
|
`, w = { "spiff-fill-shape": { browserValue: i.color || "#000000" } }, E = J();
|
|
7367
|
-
return new
|
|
7403
|
+
return new T(
|
|
7368
7404
|
{
|
|
7369
7405
|
colors: w,
|
|
7370
7406
|
id: E,
|
|
@@ -7415,7 +7451,7 @@ const Dn = [
|
|
|
7415
7451
|
excludeFromExport: e.data.excludeFromPrint,
|
|
7416
7452
|
preserveAspectRatio: "none"
|
|
7417
7453
|
};
|
|
7418
|
-
A.push(new
|
|
7454
|
+
A.push(new T(B, g));
|
|
7419
7455
|
});
|
|
7420
7456
|
} catch (r) {
|
|
7421
7457
|
console.error(r);
|
|
@@ -7425,7 +7461,7 @@ const Dn = [
|
|
|
7425
7461
|
const l = /<svg.*?<\/svg>/s, d = B.match(l) || [], w = (d == null ? void 0 : d.length) > 0 ? d[0] : "", u = Lt().parseFromString(w, "image/svg+xml").firstElementChild;
|
|
7426
7462
|
if (!u)
|
|
7427
7463
|
throw new ge("Failed to read SVG.");
|
|
7428
|
-
return
|
|
7464
|
+
return Tt(u), Ot().serializeToString(u);
|
|
7429
7465
|
};
|
|
7430
7466
|
o.forEach((B) => {
|
|
7431
7467
|
const l = c.find((w) => w.panelId === B.panelId);
|
|
@@ -7450,7 +7486,7 @@ const Dn = [
|
|
|
7450
7486
|
productOverlay: e.type === y.ProductOverlay ? !0 : void 0,
|
|
7451
7487
|
excludeFromExport: e.data.excludeFromPrint
|
|
7452
7488
|
};
|
|
7453
|
-
A.push(new
|
|
7489
|
+
A.push(new T(d, l));
|
|
7454
7490
|
});
|
|
7455
7491
|
}
|
|
7456
7492
|
return A;
|
|
@@ -7529,7 +7565,7 @@ const Dn = [
|
|
|
7529
7565
|
}
|
|
7530
7566
|
);
|
|
7531
7567
|
a.push(
|
|
7532
|
-
new
|
|
7568
|
+
new T(
|
|
7533
7569
|
{
|
|
7534
7570
|
...C,
|
|
7535
7571
|
fontSize: I,
|
|
@@ -7540,7 +7576,7 @@ const Dn = [
|
|
|
7540
7576
|
)
|
|
7541
7577
|
);
|
|
7542
7578
|
} else
|
|
7543
|
-
a.push(new
|
|
7579
|
+
a.push(new T(C, u));
|
|
7544
7580
|
}
|
|
7545
7581
|
return a;
|
|
7546
7582
|
}, Rn = (c, e) => c.conditions ? c.conditions.every((t) => {
|
|
@@ -7784,7 +7820,7 @@ const Vi = (c, e) => {
|
|
|
7784
7820
|
serializableWorkflow: { steps: [] },
|
|
7785
7821
|
layouts: {}
|
|
7786
7822
|
};
|
|
7787
|
-
a = new v(t.map((o) => new
|
|
7823
|
+
a = new v(t.map((o) => new TA(o))).apply(a);
|
|
7788
7824
|
const i = await Hn(c, e, t, A);
|
|
7789
7825
|
return new v(i).apply(a);
|
|
7790
7826
|
}, bn = D`
|
|
@@ -7927,7 +7963,7 @@ const Vi = (c, e) => {
|
|
|
7927
7963
|
}
|
|
7928
7964
|
}
|
|
7929
7965
|
}
|
|
7930
|
-
`,
|
|
7966
|
+
`, Tn = D`
|
|
7931
7967
|
query GetBundlesForCustomer($id: String!) {
|
|
7932
7968
|
customers(ids: [$id]) {
|
|
7933
7969
|
bundleStakeholders {
|
|
@@ -7948,7 +7984,7 @@ const Vi = (c, e) => {
|
|
|
7948
7984
|
}
|
|
7949
7985
|
}
|
|
7950
7986
|
}
|
|
7951
|
-
`,
|
|
7987
|
+
`, On = D`
|
|
7952
7988
|
${uA}
|
|
7953
7989
|
query GetProductCollectionProducts($id: String!) {
|
|
7954
7990
|
productCollections(ids: [$id]) {
|
|
@@ -8301,12 +8337,11 @@ class ti extends wt {
|
|
|
8301
8337
|
const A = await G.getLocalOrFromServer(t);
|
|
8302
8338
|
if (!A)
|
|
8303
8339
|
return;
|
|
8304
|
-
await this.applyImageSelection(A, e, !1);
|
|
8305
8340
|
const a = this.bundle.getGlobalPropertyStateManager().getAspectStorage(this.property.name);
|
|
8306
|
-
a ? this.updateSharedStepStorage({ ...a }) : (this.updateSharedStepStorage({ originalAssetKey: t }), await this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name, { originalAssetKey: t }));
|
|
8341
|
+
await this.applyImageSelection(A, e, !1), a ? this.updateSharedStepStorage({ ...a }) : (this.updateSharedStepStorage({ originalAssetKey: t }), await this.bundle.getGlobalPropertyStateManager().setAspectStorage(this.property.name, { originalAssetKey: t }));
|
|
8307
8342
|
}
|
|
8308
8343
|
async applyImageSelection(e, t, A = !0) {
|
|
8309
|
-
const n = this.getSharedSteps(t).map((i) => i.selectImage(e, A));
|
|
8344
|
+
const n = this.getSharedSteps(t).map((i) => i.selectImage(e, A, !1));
|
|
8310
8345
|
await Promise.all(n);
|
|
8311
8346
|
}
|
|
8312
8347
|
updateSharedStepStorage(e) {
|
|
@@ -8726,7 +8761,7 @@ class ci {
|
|
|
8726
8761
|
if (this.collection.productCollectionProducts)
|
|
8727
8762
|
return this.collection.productCollectionProducts.map((t) => new je(t));
|
|
8728
8763
|
const e = await x.getShadowGraphqlClient().query({
|
|
8729
|
-
query:
|
|
8764
|
+
query: On,
|
|
8730
8765
|
variables: {
|
|
8731
8766
|
id: this.getId()
|
|
8732
8767
|
},
|
|
@@ -10640,7 +10675,7 @@ class Ni {
|
|
|
10640
10675
|
if (!this.customer)
|
|
10641
10676
|
throw new Error("Customer not authenticated.");
|
|
10642
10677
|
const e = await x.getShadowGraphqlClient().query({
|
|
10643
|
-
query:
|
|
10678
|
+
query: Tn,
|
|
10644
10679
|
variables: {
|
|
10645
10680
|
id: this.customer.id
|
|
10646
10681
|
},
|
|
@@ -10790,7 +10825,7 @@ class Ni {
|
|
|
10790
10825
|
return {
|
|
10791
10826
|
transaction: S,
|
|
10792
10827
|
workflowId: S.workflowId,
|
|
10793
|
-
readOnly: ((R = Q.find((
|
|
10828
|
+
readOnly: ((R = Q.find((O) => O.option.transactionId === S.id)) == null ? void 0 : R.option.readOnly) ?? !1,
|
|
10794
10829
|
index: Q[N].index
|
|
10795
10830
|
};
|
|
10796
10831
|
});
|
|
@@ -10828,14 +10863,14 @@ class Ni {
|
|
|
10828
10863
|
...r.map(a),
|
|
10829
10864
|
...g.map(n)
|
|
10830
10865
|
])).flat(), l = [...new Set(B.map((Q) => Q.workflowId))], d = await pA(l, t), w = new Map(d.map((Q) => [Q.id, Q])), E = Y.getMap("transactionOwnerIds") || /* @__PURE__ */ new Map(), h = B.map(async (Q) => {
|
|
10831
|
-
var
|
|
10866
|
+
var O;
|
|
10832
10867
|
const { transaction: p, workflowId: f, readOnly: F, index: M } = Q, P = w.get(f), S = e[M];
|
|
10833
10868
|
!E.get(p.id) && p.transactionOwnerId && E.set(p.id, p.transactionOwnerId);
|
|
10834
10869
|
const N = E.get(p.id) || void 0, R = {
|
|
10835
10870
|
product: p.product,
|
|
10836
10871
|
transaction: p,
|
|
10837
10872
|
layouts: [],
|
|
10838
|
-
singleVariantsRenderable: (
|
|
10873
|
+
singleVariantsRenderable: (O = S == null ? void 0 : S.workflowConfiguration) == null ? void 0 : O.singleVariantsRenderable,
|
|
10839
10874
|
stateMutationFunc: F ? async () => {
|
|
10840
10875
|
throw new b("State mutation is forbidden in read only mode!");
|
|
10841
10876
|
} : async (L) => this.updateTransactionState({ ...L, context: { transactionOwnerId: N } }),
|
|
@@ -11252,14 +11287,15 @@ class Hi extends X {
|
|
|
11252
11287
|
* Updates the image selection inside the frame.
|
|
11253
11288
|
* @param asset The asset to use.
|
|
11254
11289
|
* @param storeAsOriginal Optional: Store this asset as the original, unmodified version of the image. Default: `true`.
|
|
11290
|
+
* @param [recalculateOffsets=true] Optional: Recalculates the offsets of the image inside the frame. Default: `true`.
|
|
11255
11291
|
*/
|
|
11256
|
-
async selectImage(e, t = !0) {
|
|
11257
|
-
var
|
|
11258
|
-
if (await Se.selectImage(this.step, e, this.manager), t) {
|
|
11259
|
-
const
|
|
11292
|
+
async selectImage(e, t = !0, A = !0) {
|
|
11293
|
+
var a;
|
|
11294
|
+
if (await Se.selectImage(this.step, e, this.manager, A), t) {
|
|
11295
|
+
const n = ((a = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : a.framePatternData) || {};
|
|
11260
11296
|
this.manager.updateStorage(this.step.stepName, {
|
|
11261
11297
|
framePatternData: {
|
|
11262
|
-
...
|
|
11298
|
+
...n,
|
|
11263
11299
|
originalAssetKey: e.key,
|
|
11264
11300
|
backgroundRemovedAssetKey: void 0,
|
|
11265
11301
|
useOriginalAsset: void 0
|
|
@@ -11285,7 +11321,7 @@ class Hi extends X {
|
|
|
11285
11321
|
if (!t)
|
|
11286
11322
|
throw new Error("You must supply an image selection before attempting to remove the background.");
|
|
11287
11323
|
const A = await G.removeBackgroundFromAsset(t);
|
|
11288
|
-
e && await Se.selectImage(this.step, A, this.manager);
|
|
11324
|
+
e && await Se.selectImage(this.step, A, this.manager, !1);
|
|
11289
11325
|
const a = ((n = this.manager.getStepStorage(this.step.stepName)) == null ? void 0 : n.framePatternData) || {};
|
|
11290
11326
|
return this.manager.updateStorage(this.step.stepName, {
|
|
11291
11327
|
framePatternData: {
|
|
@@ -11340,14 +11376,14 @@ class Hi extends X {
|
|
|
11340
11376
|
if (!A)
|
|
11341
11377
|
throw new Error("You must provide an image selection before calling setUseOriginalImageSelection");
|
|
11342
11378
|
if (e)
|
|
11343
|
-
await this.selectImage(A, !1);
|
|
11379
|
+
await this.selectImage(A, !1, !1);
|
|
11344
11380
|
else {
|
|
11345
11381
|
const n = await this.getBackgroundRemovedImageSelection();
|
|
11346
11382
|
if (!n)
|
|
11347
11383
|
throw new Error(
|
|
11348
11384
|
"You must call removeBackgroundFromImageSelection before attempting to apply the image."
|
|
11349
11385
|
);
|
|
11350
|
-
await this.selectImage(n, !1);
|
|
11386
|
+
await this.selectImage(n, !1, !1);
|
|
11351
11387
|
}
|
|
11352
11388
|
this.manager.updateStorage(this.step.stepName, {
|
|
11353
11389
|
framePatternData: { ...t, useOriginalAsset: e }
|
|
@@ -11476,5 +11512,5 @@ export {
|
|
|
11476
11512
|
$ as spiffCoreConfiguration,
|
|
11477
11513
|
Vi as stepAspectValuesToDesignInputSteps,
|
|
11478
11514
|
j as textStepService,
|
|
11479
|
-
|
|
11515
|
+
Oa as toast
|
|
11480
11516
|
};
|