@useinsider/guido 3.2.0-beta.f15b321 → 3.2.0-beta.f5e9ee4
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/README.md
CHANGED
|
@@ -496,18 +496,6 @@ npm install ../guido/useinsider-guido-1.0.0.tgz
|
|
|
496
496
|
|
|
497
497
|
---
|
|
498
498
|
|
|
499
|
-
## Documentation
|
|
500
|
-
|
|
501
|
-
Internal documentation for contributors and the release process lives in [`wiki/`](./wiki/):
|
|
502
|
-
|
|
503
|
-
| Document | Purpose |
|
|
504
|
-
|---|---|
|
|
505
|
-
| [`wiki/RELEASING.md`](./wiki/RELEASING.md) | Release policy — Thursday train cadence, hotfix lane, cross-repo coupled changes, bootstrap checklist |
|
|
506
|
-
| [`wiki/SEMANTIC_VERSIONING.md`](./wiki/SEMANTIC_VERSIONING.md) | How version numbers are assigned (conventional commits + release-please) |
|
|
507
|
-
| [`wiki/release-policy-playground.html`](./wiki/release-policy-playground.html) | 🎮 Interactive playground — pick a release scenario, see workflows + branches + step-by-step actions. Recommended for first-time onboarding. Open the file directly in a browser. |
|
|
508
|
-
|
|
509
|
-
---
|
|
510
|
-
|
|
511
499
|
## License
|
|
512
500
|
|
|
513
501
|
ISC License
|
|
@@ -8,8 +8,8 @@ import { regenerateMobileProductRows as C } from "./controls/main/utils.js";
|
|
|
8
8
|
import { ensureMobileCssRulesExist as g, setMobileLayoutOptOut as d, hasMobileLayoutOptOut as A } from "./controls/mobileLayout/cssRules.js";
|
|
9
9
|
import { RecommendationConfigService as c } from "./services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as p } from "./store/recommendation.js";
|
|
11
|
-
import { getDefaultTemplate as
|
|
12
|
-
const f = B.Recommendation,
|
|
11
|
+
import { getDefaultTemplate as D } from "./templates/grid/template.js";
|
|
12
|
+
const f = B.Recommendation, l = "recommendation-block-v2", m = "recommendation-id";
|
|
13
13
|
let h = !1;
|
|
14
14
|
class q extends b {
|
|
15
15
|
constructor() {
|
|
@@ -56,7 +56,7 @@ class q extends b {
|
|
|
56
56
|
*/
|
|
57
57
|
getTemplate() {
|
|
58
58
|
const t = this._generateNextId();
|
|
59
|
-
return this._pendingBlockId = t,
|
|
59
|
+
return this._pendingBlockId = t, D(t);
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
62
|
* Called when a new block is dropped into the template
|
|
@@ -68,13 +68,20 @@ class q extends b {
|
|
|
68
68
|
onCreated(t) {
|
|
69
69
|
const e = this._pendingBlockId ?? this._generateNextId();
|
|
70
70
|
this._pendingBlockId = null, this._assignRecommendationId(t, e);
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
const { config: i, wasFreshDrop: o } = c.initializeConfig(
|
|
72
|
+
this.api,
|
|
73
|
+
t,
|
|
74
|
+
{ recommendationId: e }
|
|
75
|
+
), s = p();
|
|
76
|
+
if (s.setCurrentBlock(e), o) {
|
|
77
|
+
g(this.api);
|
|
78
|
+
const a = this._getBlockElement(t);
|
|
79
|
+
a && (d(this.api, a, !0), C({
|
|
80
|
+
currentNode: t,
|
|
81
|
+
documentModifier: this.api.getDocumentModifier()
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
s.patchCurrentBlockConfig({ language: i.language }, { triggerRefetch: !1 });
|
|
78
85
|
}
|
|
79
86
|
/**
|
|
80
87
|
* Called when the document changes or template is loaded
|
|
@@ -97,10 +104,10 @@ class q extends b {
|
|
|
97
104
|
c.needsMigration(t) && this._migrateFromLegacy(t);
|
|
98
105
|
try {
|
|
99
106
|
h || (g(this.api), h = !0);
|
|
100
|
-
const e = c.getConfig(t),
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
A(
|
|
107
|
+
const e = c.getConfig(t), i = this._getBlockElement(t);
|
|
108
|
+
if (i) {
|
|
109
|
+
const o = !e.mobileLayoutEnabled;
|
|
110
|
+
A(i) !== o && d(this.api, i, o);
|
|
104
111
|
}
|
|
105
112
|
} catch {
|
|
106
113
|
}
|
|
@@ -124,10 +131,10 @@ class q extends b {
|
|
|
124
131
|
let t = 0;
|
|
125
132
|
try {
|
|
126
133
|
const e = this.api.getDocumentRoot();
|
|
127
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
128
|
-
if ("getAttribute" in
|
|
129
|
-
const s =
|
|
130
|
-
|
|
134
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${l}`).forEach((o) => {
|
|
135
|
+
if ("getAttribute" in o) {
|
|
136
|
+
const s = o.getAttribute(m), a = s ? parseInt(s) : 0;
|
|
137
|
+
a > t && (t = a);
|
|
131
138
|
}
|
|
132
139
|
});
|
|
133
140
|
} catch {
|
|
@@ -141,11 +148,11 @@ class q extends b {
|
|
|
141
148
|
* added classes via setAttribute.
|
|
142
149
|
*/
|
|
143
150
|
_assignRecommendationId(t, e) {
|
|
144
|
-
const
|
|
145
|
-
if (!
|
|
151
|
+
const i = this._getBlockElement(t);
|
|
152
|
+
if (!i)
|
|
146
153
|
return;
|
|
147
|
-
const
|
|
148
|
-
|
|
154
|
+
const o = this.api.getDocumentModifier();
|
|
155
|
+
o.modifyHtml(i).setAttribute(m, e.toString()), o.apply(new y(`Assign recommendation ID ${e}`));
|
|
149
156
|
}
|
|
150
157
|
/**
|
|
151
158
|
* Gets the recommendation-id from a block node
|
|
@@ -154,11 +161,11 @@ class q extends b {
|
|
|
154
161
|
const e = this._getBlockElement(t);
|
|
155
162
|
if (!e || !("getAttribute" in e))
|
|
156
163
|
return null;
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
164
|
+
const i = e.getAttribute(m);
|
|
165
|
+
if (!i)
|
|
159
166
|
return null;
|
|
160
|
-
const
|
|
161
|
-
return Number.isNaN(
|
|
167
|
+
const o = parseInt(i);
|
|
168
|
+
return Number.isNaN(o) ? null : o;
|
|
162
169
|
}
|
|
163
170
|
/**
|
|
164
171
|
* Gets the block element (the element with BLOCK_CLASS)
|
|
@@ -166,10 +173,10 @@ class q extends b {
|
|
|
166
173
|
_getBlockElement(t) {
|
|
167
174
|
if ("getAttribute" in t) {
|
|
168
175
|
const e = t.getAttribute("class");
|
|
169
|
-
if (e && e.includes(
|
|
176
|
+
if (e && e.includes(l))
|
|
170
177
|
return t;
|
|
171
178
|
}
|
|
172
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
179
|
+
return "querySelector" in t ? t.querySelector(`.${l}`) ?? null : null;
|
|
173
180
|
}
|
|
174
181
|
/**
|
|
175
182
|
* Migrate configuration from legacy format
|
|
@@ -85,21 +85,28 @@ class C {
|
|
|
85
85
|
*
|
|
86
86
|
* Called when a block is first created (dropped into template).
|
|
87
87
|
* Can optionally merge in partial config from migration.
|
|
88
|
+
*
|
|
89
|
+
* The `wasFreshDrop` flag distinguishes a brand-new drop (no prior config)
|
|
90
|
+
* from a clone (Stripo replays the source's setNodeConfig payload before
|
|
91
|
+
* onCreated fires). Callers use this to skip side-effects already inherited
|
|
92
|
+
* from the source.
|
|
88
93
|
* @example
|
|
89
94
|
* // In Block.onCreated lifecycle
|
|
90
|
-
* RecommendationConfigService.initializeConfig(this.api, node);
|
|
95
|
+
* const { config, wasFreshDrop } = RecommendationConfigService.initializeConfig(this.api, node);
|
|
91
96
|
* @param api - Stripo extension API with document modifier
|
|
92
97
|
* @param node - The immutable HTML node to initialize
|
|
93
98
|
* @param partialConfig - Optional partial config to merge with defaults
|
|
94
|
-
* @returns The initialized configuration
|
|
99
|
+
* @returns The initialized configuration and whether the node was a fresh drop
|
|
95
100
|
*/
|
|
96
101
|
static initializeConfig(i, t, o) {
|
|
102
|
+
if (this.hasConfig(t))
|
|
103
|
+
return { config: o ? this.updateConfig(i, t, o, "Initialize recommendation block") : this.getConfig(t), wasFreshDrop: !1 };
|
|
97
104
|
const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
|
|
98
105
|
return this.saveConfig(i, t, n, "Initialize recommendation block"), g({
|
|
99
106
|
currentNode: t,
|
|
100
107
|
documentModifier: i.getDocumentModifier(),
|
|
101
108
|
currency: n.currency
|
|
102
|
-
}), n;
|
|
109
|
+
}), { config: n, wasFreshDrop: !0 };
|
|
103
110
|
}
|
|
104
111
|
/**
|
|
105
112
|
* Save complete configuration to a node
|
|
@@ -143,7 +150,7 @@ class C {
|
|
|
143
150
|
const c = t.getAttribute("data-row-spacing");
|
|
144
151
|
c && (o.rowSpacing = parseInt(c) || e.rowSpacing);
|
|
145
152
|
}
|
|
146
|
-
return this.initializeConfig(i, t, o);
|
|
153
|
+
return this.initializeConfig(i, t, o).config;
|
|
147
154
|
}
|
|
148
155
|
/**
|
|
149
156
|
* Check if configuration needs migration
|
|
@@ -95,15 +95,23 @@ export declare class RecommendationConfigService {
|
|
|
95
95
|
*
|
|
96
96
|
* Called when a block is first created (dropped into template).
|
|
97
97
|
* Can optionally merge in partial config from migration.
|
|
98
|
+
*
|
|
99
|
+
* The `wasFreshDrop` flag distinguishes a brand-new drop (no prior config)
|
|
100
|
+
* from a clone (Stripo replays the source's setNodeConfig payload before
|
|
101
|
+
* onCreated fires). Callers use this to skip side-effects already inherited
|
|
102
|
+
* from the source.
|
|
98
103
|
* @example
|
|
99
104
|
* // In Block.onCreated lifecycle
|
|
100
|
-
* RecommendationConfigService.initializeConfig(this.api, node);
|
|
105
|
+
* const { config, wasFreshDrop } = RecommendationConfigService.initializeConfig(this.api, node);
|
|
101
106
|
* @param api - Stripo extension API with document modifier
|
|
102
107
|
* @param node - The immutable HTML node to initialize
|
|
103
108
|
* @param partialConfig - Optional partial config to merge with defaults
|
|
104
|
-
* @returns The initialized configuration
|
|
109
|
+
* @returns The initialized configuration and whether the node was a fresh drop
|
|
105
110
|
*/
|
|
106
|
-
static initializeConfig(api: DocumentModifierApi, node: ImmutableHtmlNode, partialConfig?: PartialNodeConfig):
|
|
111
|
+
static initializeConfig(api: DocumentModifierApi, node: ImmutableHtmlNode, partialConfig?: PartialNodeConfig): {
|
|
112
|
+
config: RecommendationNodeConfig;
|
|
113
|
+
wasFreshDrop: boolean;
|
|
114
|
+
};
|
|
107
115
|
/**
|
|
108
116
|
* Save complete configuration to a node
|
|
109
117
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.2.0-beta.
|
|
3
|
+
"version": "3.2.0-beta.f5e9ee4",
|
|
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",
|