@useinsider/guido 3.20.0 → 3.20.1-beta.8a05319
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/config/compiler/itemsCompilerRules.js +14 -5
- package/dist/config/compiler/utils/itemsCompilerUtils.js +48 -21
- package/dist/config/migrator/itemsBlockMigrator.js +112 -108
- package/dist/extensions/Blocks/Items/block.js +78 -67
- package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
- package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
- package/dist/extensions/Blocks/Recommendation/block.js +51 -44
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +90 -73
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +209 -203
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +122 -90
- package/dist/extensions/Blocks/Recommendation/utils/blockUrlConfig.js +25 -0
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +46 -25
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +40 -17
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
- package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +18 -5
- package/dist/src/extensions/Blocks/Recommendation/utils/blockUrlConfig.d.ts +4 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +7 -0
- package/dist/src/utils/liquidProtection.d.ts +3 -0
- package/dist/utils/liquidProtection.js +5 -0
- package/dist/utils/templatePreparation.js +61 -85
- package/package.json +1 -1
|
@@ -17,6 +17,8 @@ export declare class RecommendationBlock extends Block {
|
|
|
17
17
|
private _pendingBlockId;
|
|
18
18
|
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
19
19
|
private _resetSourceIds;
|
|
20
|
+
/** Ids handed to duplicates the document root does not show yet: a copied module renames all its blocks at once. */
|
|
21
|
+
private _unsettledDuplicateIds;
|
|
20
22
|
constructor();
|
|
21
23
|
getId(): string;
|
|
22
24
|
getIcon(): string;
|
|
@@ -139,6 +139,8 @@ export declare class RecommendationBlockControl extends CommonControl {
|
|
|
139
139
|
* fails when the size actually changed.
|
|
140
140
|
*/
|
|
141
141
|
private _debouncedRegenerateWithProducts;
|
|
142
|
+
/** Draws the current block's products into this panel's node. */
|
|
143
|
+
private _regenerateWithProducts;
|
|
142
144
|
/**
|
|
143
145
|
* Listen to store changes that require product refresh or regeneration.
|
|
144
146
|
*
|
|
@@ -620,12 +620,25 @@ export declare const useRecommendationExtensionStore: import("pinia").StoreDefin
|
|
|
620
620
|
fetchRecommendationProducts(): Promise<void>;
|
|
621
621
|
_doFetchProducts(): Promise<void>;
|
|
622
622
|
/**
|
|
623
|
-
* Block-scoped counterpart of `fetchRecommendationProducts`, which only
|
|
624
|
-
*
|
|
625
|
-
*
|
|
623
|
+
* Block-scoped counterpart of `fetchRecommendationProducts`, which only serves the selected block:
|
|
624
|
+
* the legacy conversion and the duplicate refresh must reach a block that may no longer be selected.
|
|
625
|
+
* @returns whether real products arrived
|
|
626
626
|
*/
|
|
627
|
-
fetchStrategyProductsForBlock(blockId: number
|
|
628
|
-
|
|
627
|
+
fetchStrategyProductsForBlock(blockId: number, options?: {
|
|
628
|
+
keepOnFailure?: boolean;
|
|
629
|
+
}): Promise<boolean>;
|
|
630
|
+
/**
|
|
631
|
+
* Reloads a block's products and adopts its strategy's current size, which may have
|
|
632
|
+
* moved since the block was assigned.
|
|
633
|
+
* @returns whether a fresh listing holds the strategy and its products arrived
|
|
634
|
+
*/
|
|
635
|
+
refreshStrategyBlock(blockId: number): Promise<boolean>;
|
|
636
|
+
_doFetchStrategyProducts(blockId: number, options?: {
|
|
637
|
+
keepOnFailure?: boolean;
|
|
638
|
+
}): Promise<boolean>;
|
|
639
|
+
_loadStrategyProducts(blockId: number, token: number, { keepOnFailure }: {
|
|
640
|
+
keepOnFailure?: boolean;
|
|
641
|
+
}): Promise<boolean>;
|
|
629
642
|
_setBlockProducts(blockId: number, products: RecommendationProduct[], size: number): void;
|
|
630
643
|
}>;
|
|
631
644
|
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PerBlockUrlConfig } from '../store/recommendation';
|
|
2
|
+
import type { RecommendationNodeConfig } from '../types/nodeConfig';
|
|
3
|
+
/** Maps a persisted node config onto the store's per-block seed, defaulting what an older config lacks. */
|
|
4
|
+
export declare function toBlockUrlConfig(config: Partial<RecommendationNodeConfig>): PerBlockUrlConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DocumentModifier } from '../services/configService';
|
|
2
|
-
import type { PartialNodeConfig } from '../types/nodeConfig';
|
|
2
|
+
import type { PartialNodeConfig, RecommendationNodeConfig } from '../types/nodeConfig';
|
|
3
3
|
import type { RecommendationProduct } from '@@/Types/recommendation';
|
|
4
4
|
import { ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
|
|
5
5
|
interface ConfigWriterApi {
|
|
@@ -13,6 +13,8 @@ interface ConfigWriterApi {
|
|
|
13
13
|
* itself is torn down.
|
|
14
14
|
*/
|
|
15
15
|
export declare function registerNodeConfigWriter(api: ConfigWriterApi): void;
|
|
16
|
+
/** Reads the persisted config of every node carrying a block id (two while a duplicate still shares it). */
|
|
17
|
+
export declare function readBlockNodeConfigs(blockId: number): RecommendationNodeConfig[];
|
|
16
18
|
/**
|
|
17
19
|
* Commits a config change and its product re-render straight to the document,
|
|
18
20
|
* bypassing the settings panel.
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import type { RecommendationNodeConfig } from '../types/nodeConfig';
|
|
2
|
+
/**
|
|
3
|
+
* Re-reads the strategy of a duplicated block and its source and redraws both: the clone copies the
|
|
4
|
+
* cards the source last drew, so a strategy edited since then only reached a block once selected (SD-153266).
|
|
5
|
+
* @param config - the arriving block's persisted config; seeds either block its store entry does not match
|
|
6
|
+
*/
|
|
7
|
+
export declare function refreshDuplicatedStrategyBlocks(sourceId: number, duplicateId: number, config: RecommendationNodeConfig): Promise<void>;
|
|
1
8
|
/**
|
|
2
9
|
* Writes a strategy change and its products straight to the document, without the settings panel.
|
|
3
10
|
*
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const p = (l) => l.split(/(<!--[\s\S]*?-->)/).map((e, c) => c % 2 ? e : e.replaceAll("{%", "<!--lq{%").replaceAll("%}", "%}lq-->")).join(""), r = (l) => l.replaceAll("<!--lq{%", "{%").replaceAll("%}lq-->", "%}").replaceAll("<!--lq{%", "{%").replaceAll("%}lq-->", "%}");
|
|
2
|
+
export {
|
|
3
|
+
p as protectLiquid,
|
|
4
|
+
r as restoreLiquid
|
|
5
|
+
};
|
|
@@ -1,123 +1,99 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useHtmlCompiler as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}), [...new Set(t)];
|
|
1
|
+
import { useActionsApi as D } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useConfig as E } from "../composables/useConfig.js";
|
|
3
|
+
import { useHtmlCompiler as F } from "../composables/useHtmlCompiler.js";
|
|
4
|
+
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
import { toBlockUrlConfig as I } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
|
|
6
|
+
import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
7
|
+
import { parsePageList as R } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
8
|
+
import { useDynamicContentStore as U } from "../stores/dynamic-content.js";
|
|
9
|
+
import { useEditorStore as L } from "../stores/editor.js";
|
|
10
|
+
import { useUnsubscribeStore as N } from "../stores/unsubscribe.js";
|
|
11
|
+
import { isPlainObject as v } from "./genericUtil.js";
|
|
12
|
+
import { assignTrackingIds as z } from "./linkTrackingIds.js";
|
|
13
|
+
function M(n) {
|
|
14
|
+
const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
|
|
15
|
+
return r.forEach((i) => {
|
|
16
|
+
const t = i.getAttribute(g.PAGE_LIST);
|
|
17
|
+
t && e.push(...R(t));
|
|
18
|
+
}), [...new Set(e)];
|
|
20
19
|
}
|
|
21
|
-
async function
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
20
|
+
async function S(n) {
|
|
21
|
+
const o = new DOMParser().parseFromString(n, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
22
|
+
if (o.length === 0)
|
|
24
23
|
return;
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!Number.isFinite(r))
|
|
24
|
+
const r = b();
|
|
25
|
+
o.forEach((e) => {
|
|
26
|
+
const i = e.getAttribute("recommendation-id"), t = i ? Number(i) : NaN;
|
|
27
|
+
if (!Number.isFinite(t))
|
|
30
28
|
return;
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
29
|
+
const m = e.getAttribute("esd-ext-config");
|
|
30
|
+
if (!m)
|
|
33
31
|
return;
|
|
34
|
-
let
|
|
32
|
+
let a;
|
|
35
33
|
try {
|
|
36
|
-
|
|
34
|
+
a = JSON.parse(m);
|
|
37
35
|
} catch {
|
|
38
36
|
return;
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
return;
|
|
42
|
-
const C = !!e.strategyId || (e.configVersion ?? 0) >= x, o = {
|
|
43
|
-
// Normalize legacy strategy keys (e.g. `mostViewed` → `mostPopular`) so
|
|
44
|
-
// already-saved blocks that never re-run the migrator don't emit a
|
|
45
|
-
// strategy-less campaign URL. `||` also catches '' / undefined (SD-144882).
|
|
46
|
-
strategy: L(e.strategy) || (C ? "" : n.strategy),
|
|
47
|
-
strategyId: e.strategyId ?? n.strategyId,
|
|
48
|
-
language: e.language ?? n.language,
|
|
49
|
-
size: e.size ?? n.size,
|
|
50
|
-
// Spread the default arrays so each block gets a fresh reference
|
|
51
|
-
// instead of sharing the singleton in DEFAULT_NODE_CONFIG.
|
|
52
|
-
productIds: e.productIds ?? [...n.productIds],
|
|
53
|
-
filters: e.filters ?? [...n.filters],
|
|
54
|
-
shuffleProducts: e.shuffleProducts ?? n.shuffleProducts,
|
|
55
|
-
currencyCode: ((d = e.currency) == null ? void 0 : d.code) ?? m.code,
|
|
56
|
-
currencySymbol: ((g = e.currency) == null ? void 0 : g.symbol) ?? m.symbol,
|
|
57
|
-
currencyAlignment: ((f = e.currency) == null ? void 0 : f.alignment) ?? m.alignment,
|
|
58
|
-
currencyDecimalCount: ((s = e.currency) == null ? void 0 : s.decimalCount) ?? m.decimalCount,
|
|
59
|
-
currencyDecimalSeparator: ((y = e.currency) == null ? void 0 : y.decimalSeparator) ?? m.decimalSeparator,
|
|
60
|
-
currencyThousandSeparator: ((S = e.currency) == null ? void 0 : S.thousandSeparator) ?? m.thousandSeparator
|
|
61
|
-
};
|
|
62
|
-
i.seedBlockUrlConfig(r, o);
|
|
38
|
+
v(a) && r.seedBlockUrlConfig(t, I(a));
|
|
63
39
|
});
|
|
64
40
|
try {
|
|
65
|
-
await
|
|
66
|
-
} catch (
|
|
41
|
+
await r.fetchRecommendationCreateData();
|
|
42
|
+
} catch (e) {
|
|
67
43
|
console.warn(
|
|
68
44
|
"Recommendation reference data pre-load failed; validator will skip the availability check.",
|
|
69
|
-
|
|
45
|
+
e
|
|
70
46
|
);
|
|
71
47
|
}
|
|
72
48
|
}
|
|
73
|
-
const
|
|
74
|
-
const
|
|
49
|
+
const Y = () => {
|
|
50
|
+
const n = U(), c = L(), o = N(), { getCompiledEmail: r, getTemplateData: e, updateHtmlAndCss: i } = D(), { compileHtml: t, compileAmpHtml: m } = F(), { isFeatureEnabled: a } = E();
|
|
75
51
|
return {
|
|
76
52
|
prepareTemplateDetails: async () => {
|
|
77
|
-
let { html:
|
|
78
|
-
if (
|
|
53
|
+
let { html: s, css: u, syncModulesIds: h = [] } = await e();
|
|
54
|
+
if (a("linkTrackingIds"))
|
|
79
55
|
try {
|
|
80
|
-
const { html:
|
|
81
|
-
|
|
82
|
-
} catch (
|
|
83
|
-
console.error("Tracking-id step failed, saving anyway:",
|
|
56
|
+
const { html: d, changed: P, nextSeq: x } = z(s, c.trackIdSessionFloor);
|
|
57
|
+
c.trackIdSessionFloor = x, P && (s = d, await i(d, u));
|
|
58
|
+
} catch (d) {
|
|
59
|
+
console.error("Tracking-id step failed, saving anyway:", d);
|
|
84
60
|
}
|
|
85
|
-
const { html:
|
|
61
|
+
const { html: y, ampHtml: p = "", ampErrors: T = [] } = await r({
|
|
86
62
|
minimize: !0,
|
|
87
63
|
resetDataSavedFlag: !1
|
|
88
64
|
});
|
|
89
|
-
|
|
90
|
-
const { compiledHtml:
|
|
65
|
+
o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(s);
|
|
66
|
+
const { compiledHtml: A, stats: l, appliedRules: w } = t(y), C = p && m(p).compiledHtml, H = n.getSelectedDynamicContentList, k = b(), f = M(s);
|
|
91
67
|
return console.debug("HTML Compilation Stats:", {
|
|
92
|
-
originalSize:
|
|
93
|
-
compiledSize:
|
|
94
|
-
reduction: `${
|
|
95
|
-
appliedRules:
|
|
96
|
-
executionTime: `${
|
|
68
|
+
originalSize: l.originalSize,
|
|
69
|
+
compiledSize: l.compiledSize,
|
|
70
|
+
reduction: `${l.reductionPercentage.toFixed(2)}%`,
|
|
71
|
+
appliedRules: w,
|
|
72
|
+
executionTime: `${l.executionTime.toFixed(2)}ms`
|
|
97
73
|
}), {
|
|
98
|
-
dynamicContentList:
|
|
99
|
-
compiledHtml:
|
|
100
|
-
rawHtml:
|
|
101
|
-
css:
|
|
102
|
-
ampHtml:
|
|
103
|
-
ampErrors:
|
|
104
|
-
modules:
|
|
74
|
+
dynamicContentList: H,
|
|
75
|
+
compiledHtml: A,
|
|
76
|
+
rawHtml: s,
|
|
77
|
+
css: u,
|
|
78
|
+
ampHtml: C,
|
|
79
|
+
ampErrors: T,
|
|
80
|
+
modules: h.map(Number),
|
|
105
81
|
recommendation: {
|
|
106
|
-
campaignUrls:
|
|
82
|
+
campaignUrls: k.recommendationCampaignUrls,
|
|
107
83
|
configs: {}
|
|
108
84
|
},
|
|
109
85
|
unsubscribe: {
|
|
110
|
-
status:
|
|
111
|
-
config:
|
|
86
|
+
status: f.length > 0,
|
|
87
|
+
config: f
|
|
112
88
|
}
|
|
113
89
|
};
|
|
114
90
|
},
|
|
115
91
|
// Exposed so the back/test validate-only path can seed the reco store the
|
|
116
92
|
// same way a full save does (required-field findings depend on it).
|
|
117
|
-
hydrateRecommendationStore:
|
|
93
|
+
hydrateRecommendationStore: S
|
|
118
94
|
};
|
|
119
95
|
};
|
|
120
96
|
export {
|
|
121
97
|
M as getHtmlReferencedUnsubscribePages,
|
|
122
|
-
|
|
98
|
+
Y as useTemplatePreparation
|
|
123
99
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.20.
|
|
3
|
+
"version": "3.20.1-beta.8a05319",
|
|
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",
|