@useinsider/guido 3.4.1 → 3.4.2-beta.6886b92

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.
@@ -155,6 +155,8 @@ class z {
155
155
  }
156
156
  migrate(t) {
157
157
  try {
158
+ if (!this.containsItemsBlock(t))
159
+ return t;
158
160
  let o = this.removeJinjaConditionals(t);
159
161
  o = this.replaceTemplateVariables(o);
160
162
  const l = this.parser.parseFromString(o, "text/html"), a = l.querySelectorAll(
@@ -178,15 +180,15 @@ class z {
178
180
  originalPriceStyles: e.originalPriceStyles,
179
181
  quantityStyles: e.quantityStyles,
180
182
  nodeConfig: R(e.configBlockAttributes)
181
- }), d = this.parser.parseFromString(
183
+ }), u = this.parser.parseFromString(
182
184
  `<table><tbody><tr>${c}</tr></tbody></table>`,
183
185
  "text/html"
184
186
  ).querySelector("td");
185
- if (d && i.parentNode) {
187
+ if (u && i.parentNode) {
186
188
  const p = R(e.configBlockAttributes);
187
- d.setAttribute("esd-ext-config", JSON.stringify(p));
188
- const u = d.querySelector("esd-config-block");
189
- u && u.remove(), i.parentNode.replaceChild(d, i);
189
+ u.setAttribute("esd-ext-config", JSON.stringify(p));
190
+ const d = u.querySelector("esd-config-block");
191
+ d && d.remove(), i.parentNode.replaceChild(u, i);
190
192
  }
191
193
  }), l.documentElement.outerHTML);
192
194
  } catch (o) {
@@ -201,22 +203,22 @@ class z {
201
203
  */
202
204
  extractConfiguration(t) {
203
205
  var C, D, P;
204
- const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", d = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", u = this.extractConfigBlockAttributes(t, o, l), S = u["data-card_orientation_control_value"];
206
+ const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", u = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, o, l), S = d["data-card_orientation_control_value"];
205
207
  let b;
206
208
  S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
207
- const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, h = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), k = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
209
+ const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, k = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), h = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
208
210
  return {
209
211
  orientation: b,
210
212
  itemsType: o,
211
213
  itemId: i,
212
214
  currencySymbol: c,
213
- currencyLocation: d,
215
+ currencyLocation: u,
214
216
  formattedPrice: p,
215
- configBlockAttributes: u,
217
+ configBlockAttributes: d,
216
218
  nameStyles: I,
217
219
  buttonStyles: m,
218
- priceStyles: h,
219
- originalPriceStyles: k,
220
+ priceStyles: k,
221
+ originalPriceStyles: h,
220
222
  quantityStyles: L
221
223
  };
222
224
  }
@@ -296,6 +298,14 @@ class z {
296
298
  "data-product_button_link": "{{Abandoned Cart Item (1) Url}}"
297
299
  };
298
300
  }
301
+ /**
302
+ * Fast check for the presence of any items block (cart / browsed / purchased)
303
+ * in the raw HTML. Used to gate the migration pipeline so non-items templates
304
+ * are returned untouched.
305
+ */
306
+ containsItemsBlock(t) {
307
+ return t.includes("esd-cart-items-block") || t.includes("esd-browsed-items-block") || t.includes("esd-purchased-items-block");
308
+ }
299
309
  /**
300
310
  * Removes Jinja2 conditional statements from HTML
301
311
  * Handles all items block types:
@@ -337,18 +347,18 @@ class z {
337
347
  const [, i, e, c] = n, _ = x[i];
338
348
  if (!_)
339
349
  return console.warn(`Unknown variable prefix: ${i}`), l;
340
- const d = q[e];
341
- if (!d)
350
+ const u = q[e];
351
+ if (!u)
342
352
  return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
343
- const { pairsKey: p, defaultKey: u, isArray: S } = d, y = o[p][_];
353
+ const { pairsKey: p, defaultKey: d, isArray: S } = u, y = o[p][_];
344
354
  if (!y)
345
355
  return console.warn(`No data found for: ${p}.${_}`), l;
346
356
  if (S) {
347
- const f = parseInt(c) - 1, m = y[u];
348
- return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${u}[${f}]`), l);
357
+ const f = parseInt(c) - 1, m = y[d];
358
+ return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${d}[${f}]`), l);
349
359
  }
350
- const I = y[u];
351
- return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${u}`), l);
360
+ const I = y[d];
361
+ return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${d}`), l);
352
362
  });
353
363
  }
354
364
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.4.1",
3
+ "version": "3.4.2-beta.6886b92",
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",