@designcrowd/library.brand-page 5.18.1-undo-24 → 5.18.1-undo-25
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/lib/src/{CreatedOnBrandCrowd-de-de-DKlq-FhR.js → CreatedOnBrandCrowd-de-de-D8EN1Yex.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-CKuJf1eN.js → CreatedOnBrandCrowd-en-us-c9lHtYxY.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-CDgHdsZn.js → CreatedOnBrandCrowd-es-es-DDNdrkk8.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-DKkek1Qq.js → CreatedOnBrandCrowd-fr-ca-CxrI2Jiz.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-DKkek1Qq.js → CreatedOnBrandCrowd-fr-fr-CxrI2Jiz.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-DtiYMB85.js → CreatedOnBrandCrowd-pt-br-BhVExk-j.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-DtiYMB85.js → CreatedOnBrandCrowd-pt-pt-BhVExk-j.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-DcipMp9e.js → CreatedOnDcom-de-de-CJE-iK-F.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-DUtpfMxY.js → CreatedOnDcom-en-us-B9i3r4YJ.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-3sfbICpP.js → CreatedOnDcom-es-es-BzfWd6rB.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-Dot_vGyn.js → CreatedOnDcom-fr-ca-BqddxBu1.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-BFu2DRry.js → CreatedOnDcom-fr-fr-BGv2wTc0.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-CZD58a0R.js → CreatedOnDcom-pt-br-CBOm5NjH.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-DRMoU43s.js → CreatedOnDcom-pt-pt-OpBrsJIk.js} +1 -1
- package/lib/src/brand-page-maker/stores/history/history-store.js +97 -28
- package/lib/src/index.mjs +1 -1
- package/lib/src/{lib-tDiln44T.js → lib-BzAs02mp.js} +10509 -10482
- package/package.json +1 -1
- package/src/brand-page-maker/stores/history/history-store.test.ts +216 -0
- package/src/brand-page-maker/stores/history/history-store.ts +114 -34
|
@@ -5,6 +5,8 @@ import { useAiWebsiteBuilderThreadStore } from '../ai-thread/ai-website-builder-
|
|
|
5
5
|
import { useEventTracker } from '../../composables/useEventTracker';
|
|
6
6
|
import { usePageNavigationStore } from '@shared/page-navigation/store/page-navigation-store';
|
|
7
7
|
import { useUiEditableLogoStore } from '@shared/logo-settings/store/editable-logo-store';
|
|
8
|
+
import { useShopConfigStore } from '@shared/ecommerce-settings/store/shop-settings-store';
|
|
9
|
+
import { useUiPageSettingsStore } from '@shared/page-settings/store';
|
|
8
10
|
import { ESCAPED_NEWLINE_CHARACTER } from '@src/constants/ui';
|
|
9
11
|
/**
|
|
10
12
|
* Single-stack history model with a pointer instead of two stacks.
|
|
@@ -48,6 +50,54 @@ const MAX_ENTRY_BYTES = 25 * 1024 * 1024;
|
|
|
48
50
|
// reactive cascades (template loadPageNo, router afterEach, layout settle)
|
|
49
51
|
// that would otherwise make undo light up before the user has done anything.
|
|
50
52
|
const BASELINE_SETTLE_MS = 2000;
|
|
53
|
+
// Content-level wrapper keys whose `paymentConfig` child is a denormalised
|
|
54
|
+
// cache of `shopConfigStore.paymentConfig` (the user's Stripe Connect
|
|
55
|
+
// linkage). The cache is hydrated lazily by
|
|
56
|
+
// `PaymentConfigField.mixin.ts:created()` when the user clicks into one of
|
|
57
|
+
// these sections — that hydration is not user authoring intent, and Stripe
|
|
58
|
+
// Connect linkage state is backend-confirmed (per `project-guardrails.md`).
|
|
59
|
+
//
|
|
60
|
+
// paymentConfig is kept fully invariant under undo/redo via two layers in
|
|
61
|
+
// this file:
|
|
62
|
+
// 1. Capture-time strip in `serializeCurrentSnapshot` — snapshots are
|
|
63
|
+
// paymentConfig-free, so no entry can carry a stale or absent value.
|
|
64
|
+
// 2. Restore-time re-stamp in `applySnapshotString` — after every undo /
|
|
65
|
+
// redo apply, every live wrapper's `paymentConfig` is reset from
|
|
66
|
+
// `shopConfigStore.paymentConfig`, which is itself never touched by
|
|
67
|
+
// undo/redo (see `applyHistorySnapshot` step 6).
|
|
68
|
+
//
|
|
69
|
+
// Together: the live wrapper always equals the live shop store, regardless
|
|
70
|
+
// of what the user does in between captures and restores.
|
|
71
|
+
const PAYMENT_CONFIG_WRAPPER_KEYS = [
|
|
72
|
+
'supportMeConfig',
|
|
73
|
+
'requestPaymentConfig',
|
|
74
|
+
'shopPaymentConfig',
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* Walk a `pages` array and remove the `paymentConfig` key from every
|
|
78
|
+
* payment-config wrapper found inside `pages[*].contents[*]`. Mutates in
|
|
79
|
+
* place — caller is responsible for passing a clone if the source must
|
|
80
|
+
* remain untouched.
|
|
81
|
+
*/
|
|
82
|
+
function stripPaymentConfigsFromPages(pages) {
|
|
83
|
+
if (!Array.isArray(pages))
|
|
84
|
+
return;
|
|
85
|
+
for (const page of pages) {
|
|
86
|
+
const contents = page?.contents;
|
|
87
|
+
if (!Array.isArray(contents))
|
|
88
|
+
continue;
|
|
89
|
+
for (const content of contents) {
|
|
90
|
+
if (!content || typeof content !== 'object')
|
|
91
|
+
continue;
|
|
92
|
+
for (const key of PAYMENT_CONFIG_WRAPPER_KEYS) {
|
|
93
|
+
const wrapper = content[key];
|
|
94
|
+
if (wrapper && typeof wrapper === 'object' && !Array.isArray(wrapper)) {
|
|
95
|
+
delete wrapper.paymentConfig;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
51
101
|
export const useHistoryStore = defineStore('history', () => {
|
|
52
102
|
const eventTracker = useEventTracker();
|
|
53
103
|
// --- State ---
|
|
@@ -81,7 +131,15 @@ export const useHistoryStore = defineStore('history', () => {
|
|
|
81
131
|
if (!cachedMakerStore)
|
|
82
132
|
return null;
|
|
83
133
|
try {
|
|
84
|
-
|
|
134
|
+
// JSON round-trip detaches the live reactive proxy, then we strip
|
|
135
|
+
// `paymentConfig` from every payment-config wrapper before re-
|
|
136
|
+
// stringifying. paymentConfig is the user's Stripe Connect linkage
|
|
137
|
+
// (backend-confirmed) and must not enter the undo stack — see
|
|
138
|
+
// `PAYMENT_CONFIG_WRAPPER_KEYS` above. The live store is never
|
|
139
|
+
// mutated; the strip operates on the detached clone only.
|
|
140
|
+
const cloned = JSON.parse(JSON.stringify(toRaw(cachedMakerStore.brandPageData)));
|
|
141
|
+
stripPaymentConfigsFromPages(cloned.pages);
|
|
142
|
+
return JSON.stringify(cloned);
|
|
85
143
|
}
|
|
86
144
|
catch (error) {
|
|
87
145
|
console.error('history-store: failed to serialize snapshot', error);
|
|
@@ -356,16 +414,6 @@ export const useHistoryStore = defineStore('history', () => {
|
|
|
356
414
|
}
|
|
357
415
|
return parts.join('\n');
|
|
358
416
|
}
|
|
359
|
-
// Wrapper keys whose `paymentConfig` child is a denormalised cache of
|
|
360
|
-
// `shopConfigStore.paymentConfig` (the user's Stripe Connect linkage).
|
|
361
|
-
// The cache is hydrated lazily by `PaymentConfigField.mixin.ts:created()`
|
|
362
|
-
// when the user clicks into one of these sections — that hydration is
|
|
363
|
-
// not user authoring intent and must not produce a phantom undo entry.
|
|
364
|
-
const PAYMENT_CONFIG_WRAPPER_KEYS = new Set([
|
|
365
|
-
'supportMeConfig',
|
|
366
|
-
'requestPaymentConfig',
|
|
367
|
-
'shopPaymentConfig',
|
|
368
|
-
]);
|
|
369
417
|
function normalizeNode(node) {
|
|
370
418
|
if (Array.isArray(node))
|
|
371
419
|
return node.map(normalizeNode);
|
|
@@ -379,23 +427,6 @@ export const useHistoryStore = defineStore('history', () => {
|
|
|
379
427
|
// represent a user-visible change.
|
|
380
428
|
if (key === 'isModifiedAfterTemplateApplied')
|
|
381
429
|
continue;
|
|
382
|
-
// Strip lazily-hydrated `paymentConfig` from payment-config wrappers
|
|
383
|
-
// (`supportMeConfig` / `requestPaymentConfig` / `shopPaymentConfig`)
|
|
384
|
-
// for the dedup compare. See `PAYMENT_CONFIG_WRAPPER_KEYS` above.
|
|
385
|
-
if (PAYMENT_CONFIG_WRAPPER_KEYS.has(key) &&
|
|
386
|
-
v !== null &&
|
|
387
|
-
typeof v === 'object' &&
|
|
388
|
-
!Array.isArray(v) &&
|
|
389
|
-
'paymentConfig' in v) {
|
|
390
|
-
const wrapper = v;
|
|
391
|
-
const stripped = {};
|
|
392
|
-
for (const k of Object.keys(wrapper)) {
|
|
393
|
-
if (k === 'paymentConfig')
|
|
394
|
-
continue;
|
|
395
|
-
stripped[k] = wrapper[k];
|
|
396
|
-
}
|
|
397
|
-
v = stripped;
|
|
398
|
-
}
|
|
399
430
|
// Collapse RTE default-hydration wrappers down to the plain text
|
|
400
431
|
// they wrap. Plain "X" and `<p style="..."><span ...><mark ...>X
|
|
401
432
|
// </mark></span></p>` share the same canonical "X" so a sidebar
|
|
@@ -800,11 +831,49 @@ export const useHistoryStore = defineStore('history', () => {
|
|
|
800
831
|
try {
|
|
801
832
|
await brandPageMakerStore.applyHistorySnapshot(snapshot, resolvedActivePageId, targetEntry?.logoEdits);
|
|
802
833
|
await nextTick();
|
|
834
|
+
// Re-stamp `wrapper.paymentConfig` on every payment-config wrapper in
|
|
835
|
+
// the freshly-restored content tree from the live shop store. The
|
|
836
|
+
// snapshot is paymentConfig-free (capture-time strip in
|
|
837
|
+
// `serializeCurrentSnapshot`), so without this step every wrapper
|
|
838
|
+
// would be left with `paymentConfig: undefined` after restore. The
|
|
839
|
+
// shop store's value is itself never undoable (see `project-
|
|
840
|
+
// guardrails.md` — Stripe Connect linkage is backend-confirmed).
|
|
841
|
+
restorePaymentConfigsOnLivePages();
|
|
803
842
|
}
|
|
804
843
|
finally {
|
|
805
844
|
isApplyingSnapshot.value = false;
|
|
806
845
|
}
|
|
807
846
|
}
|
|
847
|
+
/**
|
|
848
|
+
* Walk the live `pageSettingsStore.pages` and stamp
|
|
849
|
+
* `wrapper.paymentConfig = shopConfigStore.paymentConfig` on every
|
|
850
|
+
* payment-config wrapper. Called from `applySnapshotString` after
|
|
851
|
+
* `applyHistorySnapshot` rebuilds page contents.
|
|
852
|
+
*/
|
|
853
|
+
function restorePaymentConfigsOnLivePages() {
|
|
854
|
+
try {
|
|
855
|
+
const shopStore = useShopConfigStore();
|
|
856
|
+
const pageSettingsStore = useUiPageSettingsStore();
|
|
857
|
+
const livePaymentConfig = shopStore.paymentConfig;
|
|
858
|
+
for (const page of pageSettingsStore.pages) {
|
|
859
|
+
for (const item of page.contents) {
|
|
860
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
861
|
+
const content = item.settings.content;
|
|
862
|
+
for (const key of PAYMENT_CONFIG_WRAPPER_KEYS) {
|
|
863
|
+
const wrapper = content?.[key];
|
|
864
|
+
if (wrapper &&
|
|
865
|
+
typeof wrapper === 'object' &&
|
|
866
|
+
!Array.isArray(wrapper)) {
|
|
867
|
+
wrapper.paymentConfig = livePaymentConfig;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
catch (error) {
|
|
874
|
+
console.error('history-store: failed to restore paymentConfig on live pages', error);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
808
877
|
/** Move the pointer back one step and apply the entry at the new position. */
|
|
809
878
|
async function undo() {
|
|
810
879
|
if (!canUndo.value)
|
package/lib/src/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as E, a as T, b as s, c as I, d as S, e as N, f as e, B as A, g as O, h as C, i as G, j as D, k as P, l as t, m as R, n as L, o as M, p as o, q as r, r as b, s as n, t as F, u as i, v as l, w as g, x as B, y as c, z as Y, C as U, D as d, E as u, F as H, G as p, H as y, I as K, J as k, K as m, L as V, M as X, N as h, O as v, P as W, Q as f, R as x, S as z, T as w, U as Z, V as j, W as Q, X as q, Y as J, Z as $, $ as aa, a0 as _a, a1 as Ea, a2 as Ta, a3 as sa, a4 as Ia, a5 as Sa, a6 as Na, a7 as ea, a8 as Aa, a9 as Oa, aa as Ca, ab as Ga, ac as Da, ad as Pa, ae as ta, af as Ra, ag as La, ah as Ma, ai as oa, aj as ra, ak as ba, al as na, am as Fa, an as ia, ao as la, ap as ga, aq as Ba, ar as ca, as as Ya, at as Ua, au as da, av as ua, aw as Ha, ax as pa, ay as ya, az as Ka, aA as ka, aB as ma, aC as Va, aD as Xa, aE as ha, aF as va, aG as Wa, aH as fa, aI as xa, aJ as za, aK as wa, aL as Za, aM as ja, aN as Qa, aO as qa, aP as Ja, aQ as $a, aR as a_, aS as __, aT as E_, aU as T_, aV as s_, aW as I_, aX as S_, aY as N_, aZ as e_, a_ as A_, a$ as O_, b0 as C_, b1 as G_, b2 as D_, b3 as P_, b4 as t_, b5 as R_, b6 as L_, b7 as M_, b8 as o_, b9 as r_, ba as b_, bb as n_, bc as F_, bd as i_, be as l_, bf as g_, bg as B_, bh as c_, bi as Y_, bj as U_, bk as d_, bl as u_, bm as H_, bn as p_, bo as y_, bp as K_, bq as k_, br as m_, bs as V_, bt as X_, bu as h_, bv as v_, bw as W_, bx as f_, by as x_, bz as z_, bA as w_, bB as Z_, bC as j_, bD as Q_, bE as q_, bF as J_, bG as $_, bH as aE, bI as _E, bJ as EE, bK as TE, bL as sE, bM as IE, bN as SE, bO as NE, bP as eE, bQ as AE, bR as OE, bS as CE, bT as GE, bU as DE, bV as PE, bW as tE, bX as RE, bY as LE, bZ as ME, b_ as oE, b$ as rE, c0 as bE, c1 as nE, c2 as FE, c3 as iE, c4 as lE, c5 as gE, c6 as BE, c7 as cE, c8 as YE, c9 as UE, ca as dE, cb as uE, cc as HE, cd as pE, ce as yE, cf as KE, cg as kE, ch as mE, ci as VE, cj as XE, ck as hE, cl as vE, cm as WE, cn as fE, co as xE } from "./lib-
|
|
1
|
+
import { A as E, a as T, b as s, c as I, d as S, e as N, f as e, B as A, g as O, h as C, i as G, j as D, k as P, l as t, m as R, n as L, o as M, p as o, q as r, r as b, s as n, t as F, u as i, v as l, w as g, x as B, y as c, z as Y, C as U, D as d, E as u, F as H, G as p, H as y, I as K, J as k, K as m, L as V, M as X, N as h, O as v, P as W, Q as f, R as x, S as z, T as w, U as Z, V as j, W as Q, X as q, Y as J, Z as $, $ as aa, a0 as _a, a1 as Ea, a2 as Ta, a3 as sa, a4 as Ia, a5 as Sa, a6 as Na, a7 as ea, a8 as Aa, a9 as Oa, aa as Ca, ab as Ga, ac as Da, ad as Pa, ae as ta, af as Ra, ag as La, ah as Ma, ai as oa, aj as ra, ak as ba, al as na, am as Fa, an as ia, ao as la, ap as ga, aq as Ba, ar as ca, as as Ya, at as Ua, au as da, av as ua, aw as Ha, ax as pa, ay as ya, az as Ka, aA as ka, aB as ma, aC as Va, aD as Xa, aE as ha, aF as va, aG as Wa, aH as fa, aI as xa, aJ as za, aK as wa, aL as Za, aM as ja, aN as Qa, aO as qa, aP as Ja, aQ as $a, aR as a_, aS as __, aT as E_, aU as T_, aV as s_, aW as I_, aX as S_, aY as N_, aZ as e_, a_ as A_, a$ as O_, b0 as C_, b1 as G_, b2 as D_, b3 as P_, b4 as t_, b5 as R_, b6 as L_, b7 as M_, b8 as o_, b9 as r_, ba as b_, bb as n_, bc as F_, bd as i_, be as l_, bf as g_, bg as B_, bh as c_, bi as Y_, bj as U_, bk as d_, bl as u_, bm as H_, bn as p_, bo as y_, bp as K_, bq as k_, br as m_, bs as V_, bt as X_, bu as h_, bv as v_, bw as W_, bx as f_, by as x_, bz as z_, bA as w_, bB as Z_, bC as j_, bD as Q_, bE as q_, bF as J_, bG as $_, bH as aE, bI as _E, bJ as EE, bK as TE, bL as sE, bM as IE, bN as SE, bO as NE, bP as eE, bQ as AE, bR as OE, bS as CE, bT as GE, bU as DE, bV as PE, bW as tE, bX as RE, bY as LE, bZ as ME, b_ as oE, b$ as rE, c0 as bE, c1 as nE, c2 as FE, c3 as iE, c4 as lE, c5 as gE, c6 as BE, c7 as cE, c8 as YE, c9 as UE, ca as dE, cb as uE, cc as HE, cd as pE, ce as yE, cf as KE, cg as kE, ch as mE, ci as VE, cj as XE, ck as hE, cl as vE, cm as WE, cn as fE, co as xE } from "./lib-BzAs02mp.js";
|
|
2
2
|
import { createPinia as wE, setActivePinia as ZE } from "pinia";
|
|
3
3
|
export {
|
|
4
4
|
E as ABOUT_SECTION_SETTINGS_CONFIG,
|