@useinsider/guido 3.20.0-beta.af394f2 → 3.20.0-beta.d753259
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/composables/useLegacyStrategyConversion.js +16 -16
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +238 -212
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +181 -180
- package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +19 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +40 -25
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +15 -20
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +14 -8
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +5 -5
- package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +17 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useRecommendationExtensionStore as m } from "../store/recommendation.js";
|
|
2
|
+
import { commitBlockChangeOutsidePanel as u } from "./nodeConfigWriter.js";
|
|
3
|
+
async function l(e, { pickUpdates: n, description: c, fetch: s = !0 }) {
|
|
4
|
+
const t = m(), o = t.blockStates[e];
|
|
5
|
+
if (!o)
|
|
6
|
+
return !1;
|
|
7
|
+
const { configVersion: i } = o, a = n(o.recommendationConfigs);
|
|
8
|
+
if (s)
|
|
9
|
+
try {
|
|
10
|
+
await t.fetchRecommendationProductsForBlock(e);
|
|
11
|
+
} catch (f) {
|
|
12
|
+
console.error("[recommendation] product refetch outside the panel failed", f);
|
|
13
|
+
}
|
|
14
|
+
const r = t.blockStates[e];
|
|
15
|
+
return r ? r.configVersion !== i ? l(e, { pickUpdates: n, description: c }) : u(e, a, r.recommendationProducts, c) : !1;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
l as refreshBlockOutsidePanel
|
|
19
|
+
};
|
|
@@ -1,32 +1,47 @@
|
|
|
1
|
-
import { ModificationDescription as
|
|
2
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
3
|
-
import { isPartnerManagedBlock as
|
|
4
|
-
import { RecommendationConfigService as
|
|
5
|
-
let
|
|
6
|
-
function
|
|
7
|
-
|
|
1
|
+
import { ModificationDescription as l } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
import { RECOMMENDATION_ID_ATTR as a } from "../constants/selectors.js";
|
|
3
|
+
import { isPartnerManagedBlock as d, updateProductContentInPlace as m, regenerateProductRowsWithStyles as C } from "../controls/main/utils.js";
|
|
4
|
+
import { RecommendationConfigService as c } from "../services/configService.js";
|
|
5
|
+
let i = null;
|
|
6
|
+
function M(t) {
|
|
7
|
+
i = t;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
function s(t) {
|
|
10
|
+
const e = i == null ? void 0 : i.getDocumentRootHtmlNode();
|
|
11
|
+
return !e || !("querySelector" in e) ? null : e.querySelector(`[${a}="${t}"]`) ?? null;
|
|
12
|
+
}
|
|
13
|
+
function N(t, e) {
|
|
14
|
+
const o = c.getConfig(t);
|
|
15
|
+
return Object.keys(e).some((n) => JSON.stringify(o[n]) !== JSON.stringify(e[n]));
|
|
16
|
+
}
|
|
17
|
+
function p(t, e) {
|
|
18
|
+
const o = c.getConfig(t);
|
|
19
|
+
return ["filters", "strategy", "strategyId", "size"].some((n) => n in e && JSON.stringify(o[n]) !== JSON.stringify(e[n]));
|
|
20
|
+
}
|
|
21
|
+
function P(t, e, o) {
|
|
22
|
+
const n = s(t);
|
|
23
|
+
return !i || !n ? !1 : (p(n, e) && c.updateConfig(i, n, e, o), !0);
|
|
24
|
+
}
|
|
25
|
+
function D(t, e, o, n) {
|
|
26
|
+
const r = s(t);
|
|
27
|
+
if (!i || !r)
|
|
15
28
|
return !1;
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
19
|
-
let
|
|
20
|
-
return
|
|
21
|
-
currentNode:
|
|
22
|
-
documentModifier:
|
|
23
|
-
products:
|
|
29
|
+
const f = i.getDocumentModifier(), u = N(r, e);
|
|
30
|
+
if (c.stageConfig(f, r, e), d(r))
|
|
31
|
+
return u && f.apply(new l(n)), !0;
|
|
32
|
+
let g = !1;
|
|
33
|
+
return m({
|
|
34
|
+
currentNode: r,
|
|
35
|
+
documentModifier: f,
|
|
36
|
+
products: o,
|
|
24
37
|
onApplied: () => {
|
|
25
|
-
|
|
38
|
+
g = !0;
|
|
26
39
|
}
|
|
27
|
-
}) || (
|
|
40
|
+
}) || (g = C({ currentNode: r, documentModifier: f, products: o })), !g && u && f.apply(new l(n)), !0;
|
|
28
41
|
}
|
|
29
42
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
D as commitBlockChangeOutsidePanel,
|
|
44
|
+
p as hasEditedConfigChange,
|
|
45
|
+
M as registerNodeConfigWriter,
|
|
46
|
+
P as writeBlockConfigOutsidePanel
|
|
32
47
|
};
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
import { useRecommendationExtensionStore as
|
|
2
|
-
import {
|
|
3
|
-
async function
|
|
4
|
-
|
|
5
|
-
if (!o)
|
|
1
|
+
import { useRecommendationExtensionStore as s } from "../store/recommendation.js";
|
|
2
|
+
import { refreshBlockOutsidePanel as c } from "./blockRefresh.js";
|
|
3
|
+
async function d(e, n) {
|
|
4
|
+
if (!s().blockStates[e])
|
|
6
5
|
return !1;
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
o.recommendationProducts,
|
|
18
|
-
r
|
|
19
|
-
);
|
|
20
|
-
return n || console.error("[recommendation] strategy change did not reach a node", { blockId: e }), n;
|
|
6
|
+
const t = await c(e, {
|
|
7
|
+
pickUpdates: ({ strategyId: o, strategy: r, size: i, nodeConfigVersion: a }) => ({
|
|
8
|
+
strategyId: o,
|
|
9
|
+
strategy: r,
|
|
10
|
+
size: i,
|
|
11
|
+
configVersion: a
|
|
12
|
+
}),
|
|
13
|
+
description: n
|
|
14
|
+
});
|
|
15
|
+
return t || console.error("[recommendation] strategy change did not reach a node", { blockId: e }), t;
|
|
21
16
|
}
|
|
22
17
|
export {
|
|
23
|
-
|
|
18
|
+
d as commitStrategyChange
|
|
24
19
|
};
|
|
@@ -22,9 +22,11 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
22
22
|
private storeUnsubscription;
|
|
23
23
|
private pendingNodeConfigWrite;
|
|
24
24
|
private pendingConfigFlushTimer;
|
|
25
|
-
private
|
|
25
|
+
private trackedBlockId;
|
|
26
26
|
private fetchedConfigVersion;
|
|
27
|
-
private
|
|
27
|
+
private hasUnrenderedProducts;
|
|
28
|
+
private panelGeneration;
|
|
29
|
+
private isPanelAlive;
|
|
28
30
|
private algorithmControl;
|
|
29
31
|
private localeControl;
|
|
30
32
|
private currencyControl;
|
|
@@ -76,6 +78,7 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
76
78
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
77
79
|
private _isPendingStrategyIdChange;
|
|
78
80
|
private _capturePendingNodeConfigWrite;
|
|
81
|
+
private _getNodeConfigUpdates;
|
|
79
82
|
/**
|
|
80
83
|
* Accumulates the pending write into `documentModifier` without applying, so the
|
|
81
84
|
* caller's apply() commits config and re-render as ONE undo entry.
|
|
@@ -96,8 +99,8 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
96
99
|
private _clearConfigFlush;
|
|
97
100
|
/**
|
|
98
101
|
* Writes the deferred change standalone when the batch it was staged into never
|
|
99
|
-
* committed. Always targets
|
|
100
|
-
*
|
|
102
|
+
* committed. Always targets a LIVE node — a captured one is an immutable snapshot
|
|
103
|
+
* the intervening re-render staled, and saveConfig swallows that failure.
|
|
101
104
|
*/
|
|
102
105
|
private _flushPendingNodeConfig;
|
|
103
106
|
private _syncNodeConfigToStore;
|
|
@@ -111,6 +114,7 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
111
114
|
* Marks the block as initialized to prevent redundant fetches on re-selection.
|
|
112
115
|
*/
|
|
113
116
|
private _fetchBlockData;
|
|
117
|
+
private _isPanelOn;
|
|
114
118
|
/**
|
|
115
119
|
* Applies smart defaults for newly dropped blocks.
|
|
116
120
|
*
|
|
@@ -131,10 +135,12 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
131
135
|
*/
|
|
132
136
|
private _debouncedFetchProducts;
|
|
133
137
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
138
|
+
* Lands what the panel still owes its block before it stops watching it: the config now, the
|
|
139
|
+
* products through a block-scoped refresh. Never throws — it runs from Stripo's teardown.
|
|
136
140
|
*/
|
|
137
|
-
private
|
|
141
|
+
private _finishBlockOutsidePanel;
|
|
142
|
+
private _refreshOutsidePanel;
|
|
143
|
+
private _getBlockConfigVersion;
|
|
138
144
|
/**
|
|
139
145
|
* Debounced content update when products arrive from API.
|
|
140
146
|
*
|
|
@@ -150,7 +156,7 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
150
156
|
/**
|
|
151
157
|
* Listen to store changes that require product refresh or regeneration.
|
|
152
158
|
*
|
|
153
|
-
* Uses configVersion counter (
|
|
159
|
+
* Uses the block's configVersion counter (bumped by patchCurrentBlockConfig and legacy conversion)
|
|
154
160
|
* to distinguish user-initiated config changes from internal mutations
|
|
155
161
|
* (e.g., fetchRecommendationCreateData setting preferred currency).
|
|
156
162
|
*
|
|
@@ -54,6 +54,7 @@ interface PerBlockState {
|
|
|
54
54
|
*/
|
|
55
55
|
syncedConfigFingerprint: string | null;
|
|
56
56
|
legacyConversionLoading: boolean;
|
|
57
|
+
configVersion: number;
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
60
|
* Persisted-config subset used by `seedBlockUrlConfig` to reconstruct
|
|
@@ -618,13 +619,12 @@ export declare const useRecommendationExtensionStore: import("pinia").StoreDefin
|
|
|
618
619
|
*/
|
|
619
620
|
invalidBlockFields(): string[];
|
|
620
621
|
fetchRecommendationProducts(): Promise<void>;
|
|
621
|
-
_doFetchProducts(): Promise<void>;
|
|
622
622
|
/**
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
* started it even after the user selected another one.
|
|
623
|
+
* Fetches one block's products whether or not it is selected: the panel teardown and the
|
|
624
|
+
* strategy drawer refresh the block they were handed after the user may have moved on.
|
|
626
625
|
*/
|
|
627
|
-
|
|
626
|
+
fetchRecommendationProductsForBlock(blockId: number): Promise<void>;
|
|
627
|
+
_doFetchProducts(targetBlockId?: number): Promise<void>;
|
|
628
628
|
_doFetchStrategyProducts(blockId: number): Promise<void>;
|
|
629
629
|
_setBlockProducts(blockId: number, products: RecommendationProduct[], size: number): void;
|
|
630
630
|
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PerBlockConfigs } from '../store/recommendation';
|
|
2
|
+
import type { PartialNodeConfig } from '../types/nodeConfig';
|
|
3
|
+
interface BlockRefreshOptions {
|
|
4
|
+
pickUpdates: (configs: PerBlockConfigs) => PartialNodeConfig;
|
|
5
|
+
description: string;
|
|
6
|
+
fetch?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Fetches one block's products and commits them with its config straight to the document, for
|
|
10
|
+
* callers the settings panel can no longer serve (deselect, block switch, host-rendered strategy UI).
|
|
11
|
+
* @param options.pickUpdates - the config keys this caller owns on the node
|
|
12
|
+
* @param options.description - labels the undo entry
|
|
13
|
+
* @param options.fetch - false when the block's products already landed and only need rendering
|
|
14
|
+
* @returns whether the write reached a node
|
|
15
|
+
*/
|
|
16
|
+
export declare function refreshBlockOutsidePanel(blockId: number, { pickUpdates, description, fetch }: BlockRefreshOptions): Promise<boolean>;
|
|
17
|
+
export {};
|
|
@@ -13,6 +13,13 @@ interface ConfigWriterApi {
|
|
|
13
13
|
* itself is torn down.
|
|
14
14
|
*/
|
|
15
15
|
export declare function registerNodeConfigWriter(api: ConfigWriterApi): void;
|
|
16
|
+
export declare function hasEditedConfigChange(node: ImmutableHtmlNode, updates: PartialNodeConfig): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Writes a config change to the block's node on its own, found by id — never through a
|
|
19
|
+
* panel-held node, which may already belong to the block the user switched to.
|
|
20
|
+
* @returns whether the block's node was found
|
|
21
|
+
*/
|
|
22
|
+
export declare function writeBlockConfigOutsidePanel(blockId: number, updates: PartialNodeConfig, description: string): boolean;
|
|
16
23
|
/**
|
|
17
24
|
* Commits a config change and its product re-render straight to the document,
|
|
18
25
|
* bypassing the settings panel.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.20.0-beta.
|
|
3
|
+
"version": "3.20.0-beta.d753259",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|