@rebuy/rebuy 3.60.2 → 3.60.4
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/cab/hasOwnKey.d.ts +8 -0
- package/dist/cab/index.cjs +7 -4
- package/dist/cab/index.mjs +7 -4
- package/dist/cab/selectLanguage.d.ts +1 -1
- package/dist/server/index.cjs +61 -62
- package/dist/server/index.mjs +61 -62
- package/dist/transforms/index.cjs +4 -1
- package/dist/transforms/index.mjs +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether `key` is an OWN key of `object`, never an inherited `Object.prototype` one (`constructor`,
|
|
3
|
+
* `toString`, `__proto__`) — what `Object.hasOwn` answers, without needing it. `Object.hasOwn` is ES2022:
|
|
4
|
+
* Safari/iOS before 15.4 and Chromium before 93 lack it, those buyers still load every renderer that bundles
|
|
5
|
+
* `./cab`, and esbuild's `es2020` target rewrites syntax only, so the call shipped as-is and threw on the first
|
|
6
|
+
* section render (REB-24990). Read off `Object.prototype` so an own `hasOwnProperty` key cannot shadow it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const hasOwnKey: (object: object, key: PropertyKey) => boolean;
|
package/dist/cab/index.cjs
CHANGED
|
@@ -45,6 +45,9 @@ var asLayout = (section) => ({
|
|
|
45
45
|
visibility: void 0
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
// src/cab/hasOwnKey.ts
|
|
49
|
+
var hasOwnKey = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
50
|
+
|
|
48
51
|
// src/schema/widgets/checkout-and-beyond/regex.ts
|
|
49
52
|
var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
|
|
50
53
|
var DYNAMIC_TOKEN_ANYWHERE_REGEX = /\{\{\s*[A-Za-z0-9_]+\s*\}\}/;
|
|
@@ -54,9 +57,9 @@ var HTML_TAGS_REGEX = /<\/?[a-zA-Z][^>]*>/g;
|
|
|
54
57
|
var TOKEN_REGEX = /{{1,2}\s*([^{}\s]+)\s*}{1,2}/g;
|
|
55
58
|
var toCamelCase = (key) => key.replace(/_([a-z0-9])/g, (_, char) => char.toUpperCase());
|
|
56
59
|
var resolveKey = (key, variables) => {
|
|
57
|
-
if (
|
|
60
|
+
if (hasOwnKey(variables, key)) return key;
|
|
58
61
|
const camel = toCamelCase(key);
|
|
59
|
-
if (
|
|
62
|
+
if (hasOwnKey(variables, camel)) return camel;
|
|
60
63
|
const lower = camel.toLowerCase();
|
|
61
64
|
return Object.keys(variables).find((name) => name.toLowerCase() === lower);
|
|
62
65
|
};
|
|
@@ -70,8 +73,8 @@ var interpolateAndSanitize = (input, variables) => (input ?? "").replace(TOKEN_R
|
|
|
70
73
|
var FALLBACK_LANGUAGE = "en";
|
|
71
74
|
var selectLanguage = (content, language) => {
|
|
72
75
|
if (!content) return void 0;
|
|
73
|
-
if (language &&
|
|
74
|
-
if (
|
|
76
|
+
if (language && hasOwnKey(content, language)) return content[language];
|
|
77
|
+
if (hasOwnKey(content, FALLBACK_LANGUAGE)) return content[FALLBACK_LANGUAGE];
|
|
75
78
|
return Object.values(content)[0];
|
|
76
79
|
};
|
|
77
80
|
|
package/dist/cab/index.mjs
CHANGED
|
@@ -7,6 +7,9 @@ var asLayout = (section) => ({
|
|
|
7
7
|
visibility: void 0
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
// src/cab/hasOwnKey.ts
|
|
11
|
+
var hasOwnKey = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
12
|
+
|
|
10
13
|
// src/schema/widgets/checkout-and-beyond/regex.ts
|
|
11
14
|
var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
|
|
12
15
|
var DYNAMIC_TOKEN_ANYWHERE_REGEX = /\{\{\s*[A-Za-z0-9_]+\s*\}\}/;
|
|
@@ -16,9 +19,9 @@ var HTML_TAGS_REGEX = /<\/?[a-zA-Z][^>]*>/g;
|
|
|
16
19
|
var TOKEN_REGEX = /{{1,2}\s*([^{}\s]+)\s*}{1,2}/g;
|
|
17
20
|
var toCamelCase = (key) => key.replace(/_([a-z0-9])/g, (_, char) => char.toUpperCase());
|
|
18
21
|
var resolveKey = (key, variables) => {
|
|
19
|
-
if (
|
|
22
|
+
if (hasOwnKey(variables, key)) return key;
|
|
20
23
|
const camel = toCamelCase(key);
|
|
21
|
-
if (
|
|
24
|
+
if (hasOwnKey(variables, camel)) return camel;
|
|
22
25
|
const lower = camel.toLowerCase();
|
|
23
26
|
return Object.keys(variables).find((name) => name.toLowerCase() === lower);
|
|
24
27
|
};
|
|
@@ -32,8 +35,8 @@ var interpolateAndSanitize = (input, variables) => (input ?? "").replace(TOKEN_R
|
|
|
32
35
|
var FALLBACK_LANGUAGE = "en";
|
|
33
36
|
var selectLanguage = (content, language) => {
|
|
34
37
|
if (!content) return void 0;
|
|
35
|
-
if (language &&
|
|
36
|
-
if (
|
|
38
|
+
if (language && hasOwnKey(content, language)) return content[language];
|
|
39
|
+
if (hasOwnKey(content, FALLBACK_LANGUAGE)) return content[FALLBACK_LANGUAGE];
|
|
37
40
|
return Object.values(content)[0];
|
|
38
41
|
};
|
|
39
42
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Fallback chain: requested language, then 'en', then first available value.
|
|
3
3
|
*
|
|
4
|
-
* `
|
|
4
|
+
* Own keys only (`hasOwnKey`), never `in` — `in` would resolve an inherited `Object.prototype` key (`constructor`,
|
|
5
5
|
* `toString`) as if it were a translation. Far less reachable than in `interpolateAndSanitize`, since a
|
|
6
6
|
* language code is not merchant-authored, but the two must agree on what counts as present.
|
|
7
7
|
*/
|
package/dist/server/index.cjs
CHANGED
|
@@ -775,7 +775,7 @@ var isHTML = (html = "") => {
|
|
|
775
775
|
}
|
|
776
776
|
return html.search(HTML_TAGS_REGEX) !== -1;
|
|
777
777
|
};
|
|
778
|
-
var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text
|
|
778
|
+
var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text }) => isHTML(text)));
|
|
779
779
|
var checkForHTML = (input) => !((0, import_compat2.isString)(input) && isHTML(input) || (0, import_es_toolkit2.isPlainObject)(input) && hasHTMLInDoc(input));
|
|
780
780
|
var NO_HTML = { message: "HTML is not supported" };
|
|
781
781
|
var isSectionType = (sectionType) => (section) => (0, import_compat2.get)(section, "sectionType") === sectionType;
|
|
@@ -2829,17 +2829,17 @@ var CABImageSection = CABImageSectionFields.superRefine(({ category, source: sou
|
|
|
2829
2829
|
var HTML_COMMENT_RE = /<!--[\s\S]*?-->/g;
|
|
2830
2830
|
var STRIPPED_ELEMENT_RE = /<(script|style|iframe|object|embed|noscript|template)\b[^>]*>[\s\S]*?(?:<\/\1\s*>|$)/gi;
|
|
2831
2831
|
var HTML_TAG_RE = /<\/?[a-zA-Z][^>]*>/g;
|
|
2832
|
-
var stripContentBlockHtml = (
|
|
2832
|
+
var stripContentBlockHtml = (text) => text.replace(HTML_COMMENT_RE, "").replace(STRIPPED_ELEMENT_RE, "").replace(HTML_TAG_RE, "");
|
|
2833
2833
|
|
|
2834
2834
|
// src/transforms/contentBlockV1/convertTextToTiptapParagraph.ts
|
|
2835
2835
|
var convertTextToTiptapParagraph = ({
|
|
2836
2836
|
color,
|
|
2837
2837
|
fontSize,
|
|
2838
2838
|
marks: marks2 = [],
|
|
2839
|
-
text
|
|
2839
|
+
text,
|
|
2840
2840
|
textAlign
|
|
2841
2841
|
}) => {
|
|
2842
|
-
const sanitizedText = stripContentBlockHtml(
|
|
2842
|
+
const sanitizedText = stripContentBlockHtml(text);
|
|
2843
2843
|
return TiptapParagraph.parse({
|
|
2844
2844
|
attrs: { textAlign },
|
|
2845
2845
|
content: sanitizedText ? [
|
|
@@ -2913,13 +2913,13 @@ var convertContentBlockImageToV2 = (block) => {
|
|
|
2913
2913
|
// src/transforms/normalizeTokens.ts
|
|
2914
2914
|
var import_es_toolkit4 = require("es-toolkit");
|
|
2915
2915
|
var DEFAULT_KNOWN_TOKENS = ["firstName", "lastName", "email"];
|
|
2916
|
-
var normalizeTokens = (
|
|
2917
|
-
if (typeof
|
|
2916
|
+
var normalizeTokens = (text, knownTokens = DEFAULT_KNOWN_TOKENS) => {
|
|
2917
|
+
if (typeof text !== "string") return text;
|
|
2918
2918
|
return knownTokens.reduce((acc, token) => {
|
|
2919
2919
|
const snakeTolerant = (0, import_es_toolkit4.escapeRegExp)(token).replace(/([A-Z])/g, "_?$1");
|
|
2920
2920
|
const pattern = new RegExp(`\\{{1,2}\\s*${snakeTolerant}\\s*\\}{1,2}`, "gi");
|
|
2921
2921
|
return acc.replace(pattern, `{{${token}}}`);
|
|
2922
|
-
},
|
|
2922
|
+
}, text);
|
|
2923
2923
|
};
|
|
2924
2924
|
|
|
2925
2925
|
// src/transforms/contentBlockV1/convertContentBlockTextToV2.ts
|
|
@@ -2929,7 +2929,7 @@ var HEADER_PARAGRAPH_STYLES = {
|
|
|
2929
2929
|
superTitle: { color: "base", fontSize: "extraLarge", marks: [{ type: "bold" }] },
|
|
2930
2930
|
title: { color: "base", fontSize: "medium", marks: [{ type: "bold" }] }
|
|
2931
2931
|
};
|
|
2932
|
-
var convertContentBlockTextToV2 = (language3,
|
|
2932
|
+
var convertContentBlockTextToV2 = (language3, text = literalText, textAlign = "center") => {
|
|
2933
2933
|
const description = language3?.description;
|
|
2934
2934
|
const superTitle = language3?.superTitle;
|
|
2935
2935
|
const title = language3?.title;
|
|
@@ -2938,17 +2938,17 @@ var convertContentBlockTextToV2 = (language3, text2 = literalText, textAlign = "
|
|
|
2938
2938
|
content: [
|
|
2939
2939
|
superTitle ? convertTextToTiptapParagraph({
|
|
2940
2940
|
...HEADER_PARAGRAPH_STYLES.superTitle,
|
|
2941
|
-
text:
|
|
2941
|
+
text: text("superTitle", superTitle),
|
|
2942
2942
|
textAlign
|
|
2943
2943
|
}) : null,
|
|
2944
2944
|
title ? convertTextToTiptapParagraph({
|
|
2945
2945
|
...HEADER_PARAGRAPH_STYLES.title,
|
|
2946
|
-
text:
|
|
2946
|
+
text: text("title", title),
|
|
2947
2947
|
textAlign
|
|
2948
2948
|
}) : null,
|
|
2949
2949
|
description ? convertTextToTiptapParagraph({
|
|
2950
2950
|
...HEADER_PARAGRAPH_STYLES.description,
|
|
2951
|
-
text:
|
|
2951
|
+
text: text("description", description),
|
|
2952
2952
|
textAlign
|
|
2953
2953
|
}) : null
|
|
2954
2954
|
].filter((p) => p !== null),
|
|
@@ -3596,7 +3596,7 @@ var isMonetizeV1 = isWidgetV1(WidgetType.ui_extension_ad);
|
|
|
3596
3596
|
|
|
3597
3597
|
// src/transforms/normalizeTextContent.ts
|
|
3598
3598
|
var HTML_TAG_RE2 = /<[a-zA-Z]/;
|
|
3599
|
-
var containsHtml = (
|
|
3599
|
+
var containsHtml = (text) => HTML_TAG_RE2.test(text);
|
|
3600
3600
|
var isObject = (x) => x !== null && typeof x === "object" && !Array.isArray(x);
|
|
3601
3601
|
var normalizeTextValue = (value, options2 = {}) => {
|
|
3602
3602
|
const tokenized = normalizeTokens(value);
|
|
@@ -4528,6 +4528,9 @@ var parseShielded = (schema, raw, transform = (input) => input) => schema.parse(
|
|
|
4528
4528
|
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
4529
4529
|
var import_zod47 = require("zod");
|
|
4530
4530
|
|
|
4531
|
+
// src/cab/hasOwnKey.ts
|
|
4532
|
+
var hasOwnKey = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
4533
|
+
|
|
4531
4534
|
// src/transforms/postPurchase/convertCalloutBlock.ts
|
|
4532
4535
|
var import_zod41 = require("zod");
|
|
4533
4536
|
|
|
@@ -4541,12 +4544,12 @@ var sizes = {
|
|
|
4541
4544
|
xlarge: "extraLarge",
|
|
4542
4545
|
xsmall: "extraSmall"
|
|
4543
4546
|
};
|
|
4544
|
-
var styledTextRun = (
|
|
4547
|
+
var styledTextRun = (text, emphasized, size) => ({
|
|
4545
4548
|
marks: [
|
|
4546
4549
|
...emphasized ? [{ type: "bold" }] : [],
|
|
4547
4550
|
{ attrs: { color: "base", fontSize: sizes[size] }, type: "textStyle" }
|
|
4548
4551
|
],
|
|
4549
|
-
text
|
|
4552
|
+
text,
|
|
4550
4553
|
type: "text"
|
|
4551
4554
|
});
|
|
4552
4555
|
|
|
@@ -4571,16 +4574,16 @@ var convertCalloutBlock = (raw, report) => {
|
|
|
4571
4574
|
const horizontal = styled2 ? { center: "center", leading: "start", trailing: "end" }[styles2.textAlignment] : "center";
|
|
4572
4575
|
const sections = values2.flatMap(({ field, result }) => {
|
|
4573
4576
|
if (!result.success) return omit(`Unreadable post-purchase callout field: ${field}`);
|
|
4574
|
-
const
|
|
4575
|
-
if (
|
|
4576
|
-
const content = styled2 && typeof
|
|
4577
|
+
const text = result.data;
|
|
4578
|
+
if (text === "") return [];
|
|
4579
|
+
const content = styled2 && typeof text === "string" ? {
|
|
4577
4580
|
content: [
|
|
4578
4581
|
{
|
|
4579
4582
|
attrs: { textAlign: horizontal },
|
|
4580
|
-
content: [styledTextRun(
|
|
4583
|
+
content: [styledTextRun(text, styles2[`${field}Emphasized`], styles2[`${field}Size`])]
|
|
4581
4584
|
}
|
|
4582
4585
|
]
|
|
4583
|
-
} :
|
|
4586
|
+
} : text;
|
|
4584
4587
|
const section = CABTextSection.safeParse({ content: { en: content } });
|
|
4585
4588
|
return section.success ? [section.data] : omit(`Unreadable post-purchase callout field: ${field}`);
|
|
4586
4589
|
});
|
|
@@ -4659,16 +4662,16 @@ var convertImageContentText = (settings, report) => {
|
|
|
4659
4662
|
};
|
|
4660
4663
|
const value = ImageContentBlock.shape.settings.shape[field].safeParse(settings[field]);
|
|
4661
4664
|
if (!value.success) return omit();
|
|
4662
|
-
const
|
|
4663
|
-
if (
|
|
4664
|
-
const content = typeof
|
|
4665
|
+
const text = value.data;
|
|
4666
|
+
if (text === null || text === "") return [];
|
|
4667
|
+
const content = typeof text === "string" ? {
|
|
4665
4668
|
content: [
|
|
4666
4669
|
{
|
|
4667
4670
|
attrs: { textAlign: horizontal },
|
|
4668
|
-
content: [styledTextRun(
|
|
4671
|
+
content: [styledTextRun(text, field !== "description", settings[`${field}Size`])]
|
|
4669
4672
|
}
|
|
4670
4673
|
]
|
|
4671
|
-
} :
|
|
4674
|
+
} : text;
|
|
4672
4675
|
const section = CABTextSection.safeParse({ content: { en: content } });
|
|
4673
4676
|
return section.success ? [section.data] : omit();
|
|
4674
4677
|
});
|
|
@@ -4709,8 +4712,8 @@ var convertImageContentBlock = (raw, report) => {
|
|
|
4709
4712
|
}
|
|
4710
4713
|
const image = convertImageFrame({ alt, image: settings.image, imageSize: settings.imageSize });
|
|
4711
4714
|
if (!image) report?.({ detail: "Unreadable post-purchase image-content image", kind: "section" });
|
|
4712
|
-
const
|
|
4713
|
-
const textFrame = CABLayoutSection.parse({ direction: "grid", grid: { columns: ["100%"] }, sections: [
|
|
4715
|
+
const text = convertImageContentText(settings, report);
|
|
4716
|
+
const textFrame = CABLayoutSection.parse({ direction: "grid", grid: { columns: ["100%"] }, sections: [text] });
|
|
4714
4717
|
const placement = settings.imagePlacement ?? (settings.swapContent ? "right" : "left");
|
|
4715
4718
|
const imageFirst = placement === "left" || placement === "top";
|
|
4716
4719
|
const sections = imageFirst ? [image, textFrame] : [textFrame, image];
|
|
@@ -4785,8 +4788,8 @@ var convertPayButtonBlock = (raw, report, widgetSettings) => {
|
|
|
4785
4788
|
if (!parsed.success) return omit();
|
|
4786
4789
|
const { settings, styles: styles2 } = parsed.data;
|
|
4787
4790
|
const label2 = settings.label ? `${settings.label} \xB7 {{total}}` : "{{total}}";
|
|
4788
|
-
const
|
|
4789
|
-
if (!
|
|
4791
|
+
const text = CABTextSection.safeParse({ content: { en: label2 } });
|
|
4792
|
+
if (!text.success) return omit();
|
|
4790
4793
|
return [
|
|
4791
4794
|
CABLayoutSection.parse({
|
|
4792
4795
|
alignment: { horizontal: "center" },
|
|
@@ -4795,7 +4798,7 @@ var convertPayButtonBlock = (raw, report, widgetSettings) => {
|
|
|
4795
4798
|
sections: [
|
|
4796
4799
|
CABButtonSection.parse({
|
|
4797
4800
|
action: "addToOrder",
|
|
4798
|
-
sections: [
|
|
4801
|
+
sections: [text.data, soldOutSlot(ProductCardSettings.parse(widgetSettings ?? {}))]
|
|
4799
4802
|
})
|
|
4800
4803
|
],
|
|
4801
4804
|
width: styles2.buttonWidth
|
|
@@ -4835,8 +4838,8 @@ var productCardControls = (settings) => [
|
|
|
4835
4838
|
];
|
|
4836
4839
|
|
|
4837
4840
|
// src/transforms/postPurchase/productCardRows.ts
|
|
4838
|
-
var styledCopy = (
|
|
4839
|
-
content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text
|
|
4841
|
+
var styledCopy = (text, look) => ({
|
|
4842
|
+
content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text, type: "text" }], type: "paragraph" }],
|
|
4840
4843
|
type: "doc"
|
|
4841
4844
|
});
|
|
4842
4845
|
var merchantLabel = (value, fallback) => localizedContent({ en: fallback }, value);
|
|
@@ -4846,7 +4849,7 @@ var boundText = (variable, content) => ({
|
|
|
4846
4849
|
visibility: shownWhile(variable)
|
|
4847
4850
|
});
|
|
4848
4851
|
var earnedRow = ({ after, columns, label: label2, look, spacing, token, variable }) => {
|
|
4849
|
-
const styled2 = (
|
|
4852
|
+
const styled2 = (text) => look ? styledCopy(text, look) : text;
|
|
4850
4853
|
const value = earnedText(variable, styled2(token));
|
|
4851
4854
|
return {
|
|
4852
4855
|
direction: "grid",
|
|
@@ -4923,8 +4926,8 @@ var recurringSummary = (settings) => {
|
|
|
4923
4926
|
variable: HAS_RECURRING_SHIPPING
|
|
4924
4927
|
})
|
|
4925
4928
|
] : [],
|
|
4926
|
-
...FOOTNOTES.map((
|
|
4927
|
-
content: { en: styledCopy(
|
|
4929
|
+
...FOOTNOTES.map((text) => ({
|
|
4930
|
+
content: { en: styledCopy(text, small) },
|
|
4928
4931
|
sectionType: "text",
|
|
4929
4932
|
visibility: shownWhile(HAS_RECURRING_TOTAL)
|
|
4930
4933
|
}))
|
|
@@ -5082,9 +5085,9 @@ var convertTextBlock = (raw, report) => {
|
|
|
5082
5085
|
};
|
|
5083
5086
|
const sections = values2.flatMap(({ field, result }) => {
|
|
5084
5087
|
if (!result.success) return omit(field);
|
|
5085
|
-
const
|
|
5086
|
-
if (
|
|
5087
|
-
const content = styled2 ? { content: [{ attrs: { textAlign: horizontal }, content: [{ marks: styles[field], text
|
|
5088
|
+
const text = result.data;
|
|
5089
|
+
if (text === null || text === "") return [];
|
|
5090
|
+
const content = styled2 ? { content: [{ attrs: { textAlign: horizontal }, content: [{ marks: styles[field], text }] }] } : text;
|
|
5088
5091
|
const section = CABTextSection.safeParse({ content: { en: content } });
|
|
5089
5092
|
return section.success ? [section.data] : omit(field);
|
|
5090
5093
|
});
|
|
@@ -5119,13 +5122,13 @@ var convertTimerBlock = (raw, report) => {
|
|
|
5119
5122
|
}
|
|
5120
5123
|
]
|
|
5121
5124
|
} : withCountdown(title, countdown, horizontal);
|
|
5122
|
-
const
|
|
5123
|
-
if (!
|
|
5125
|
+
const text = CABTextSection.safeParse({ content: { en: content } });
|
|
5126
|
+
if (!text.success) return omit();
|
|
5124
5127
|
return [
|
|
5125
5128
|
CABBannerSection.parse({
|
|
5126
5129
|
color: styles2.timerBackgroundColor,
|
|
5127
5130
|
dismissible: false,
|
|
5128
|
-
sections: [
|
|
5131
|
+
sections: [text.data],
|
|
5129
5132
|
width: styles2.timerWidth
|
|
5130
5133
|
})
|
|
5131
5134
|
];
|
|
@@ -5156,7 +5159,7 @@ var convertMessagePreview = (id, settings, report) => {
|
|
|
5156
5159
|
sections: parsed.data.blocks.flatMap((block) => {
|
|
5157
5160
|
const type = BlockType2.safeParse(block);
|
|
5158
5161
|
const kind = type.success ? type.data.type : void 0;
|
|
5159
|
-
const convert2 = kind &&
|
|
5162
|
+
const convert2 = kind && hasOwnKey(converters, kind) ? converters[kind] : void 0;
|
|
5160
5163
|
if (convert2) return convert2(block, report, settings);
|
|
5161
5164
|
report?.({
|
|
5162
5165
|
detail: kind ? `Unsupported post-purchase block type: ${kind}` : "Unreadable post-purchase block: missing type",
|
|
@@ -5828,7 +5831,7 @@ var fetchAdsEngineOffers = async (input, ctx, prefetched) => {
|
|
|
5828
5831
|
// src/transforms/htmlToPlainText.ts
|
|
5829
5832
|
var paragraphText = (paragraph) => paragraph.content.map((run) => run.text).join("");
|
|
5830
5833
|
var FORCE_PARSER = { defaultTextStyle: {} };
|
|
5831
|
-
var withoutTagShapes = (
|
|
5834
|
+
var withoutTagShapes = (text) => isHTML(text) ? text.replace(/[<>]/g, "") : text;
|
|
5832
5835
|
var htmlToPlainText = (html) => withoutTagShapes(
|
|
5833
5836
|
normalizeTextValue(html, FORCE_PARSER).content.map((paragraph) => paragraphText(paragraph).trim()).filter((line) => line !== "").join("\n")
|
|
5834
5837
|
);
|
|
@@ -5836,12 +5839,11 @@ var htmlToPlainText = (html) => withoutTagShapes(
|
|
|
5836
5839
|
// src/server/composeOffer.ts
|
|
5837
5840
|
var ACCEPT_FALLBACK = "Accept";
|
|
5838
5841
|
var DECLINE_FALLBACK = "No Thanks";
|
|
5839
|
-
var label = (
|
|
5842
|
+
var label = (text) => ({
|
|
5840
5843
|
buttonField: ButtonField.buttonLabel,
|
|
5841
|
-
content: { en:
|
|
5844
|
+
content: { en: text },
|
|
5842
5845
|
sectionType: SectionType.text
|
|
5843
5846
|
});
|
|
5844
|
-
var text = (content) => ({ content: { en: content }, sectionType: SectionType.text });
|
|
5845
5847
|
var AS_DOC = { defaultTextStyle: {} };
|
|
5846
5848
|
var safeTextValue = (raw, options2) => {
|
|
5847
5849
|
const converted = normalizeTextValue(raw, options2);
|
|
@@ -5899,20 +5901,17 @@ var styled = (value, { align, bold, color, fontSize, href }) => ({
|
|
|
5899
5901
|
sectionType: SectionType.text
|
|
5900
5902
|
});
|
|
5901
5903
|
var shopName = (shop, storeName) => storeName?.replace(/<[^>]*>/g, "").trim() || shop.replace(/\.myshopify\.com$/, "") || "store";
|
|
5902
|
-
var
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
},
|
|
5914
|
-
text(input.orderName ? `Order ${input.orderName} Confirmed` : "Order Confirmed")
|
|
5915
|
-
];
|
|
5904
|
+
var headerSection = (input, storeName) => ({
|
|
5905
|
+
sections: [
|
|
5906
|
+
styled("Congratulations!", { bold: true, fontSize: "heading" }),
|
|
5907
|
+
styled(`Your ${shopName(input.shop, storeName)} purchase unlocked a bonus:`, {
|
|
5908
|
+
bold: true,
|
|
5909
|
+
fontSize: "heading"
|
|
5910
|
+
})
|
|
5911
|
+
],
|
|
5912
|
+
sectionType: SectionType.layout,
|
|
5913
|
+
spacing: Spacing.none
|
|
5914
|
+
});
|
|
5916
5915
|
var privacyHref = (offer, input) => {
|
|
5917
5916
|
const href = [offer.privacy_url, input.privacyPolicyUrl].find((url) => url && isValidHref(url));
|
|
5918
5917
|
return href ? { href } : {};
|
|
@@ -5924,9 +5923,9 @@ var legalCopy = (raw, visibleWhen) => ({
|
|
|
5924
5923
|
sectionType: SectionType.text,
|
|
5925
5924
|
...visibleWhen !== void 0 && { visibility: { variable: SHOW_EXTENDED, visibleWhen } }
|
|
5926
5925
|
});
|
|
5927
|
-
var disclosureToggle = (
|
|
5926
|
+
var disclosureToggle = (text, visibleWhen) => ({
|
|
5928
5927
|
buttonStyle: ButtonStyle.plain,
|
|
5929
|
-
sections: [label(
|
|
5928
|
+
sections: [label(text)],
|
|
5930
5929
|
sectionType: SectionType.button,
|
|
5931
5930
|
variableEffects: [{ effect: "toggle", variable: SHOW_EXTENDED }],
|
|
5932
5931
|
visibility: { variable: SHOW_EXTENDED, visibleWhen }
|
|
@@ -5981,7 +5980,7 @@ var composeOfferCard = (offer, input, storeName) => {
|
|
|
5981
5980
|
border: { style: BorderStyle.base },
|
|
5982
5981
|
padding: Spacing.tight,
|
|
5983
5982
|
sections: [
|
|
5984
|
-
|
|
5983
|
+
headerSection(input, storeName),
|
|
5985
5984
|
offer.image_url ? {
|
|
5986
5985
|
alignment: { horizontal: HorizontalAlignment.start, vertical: VerticalAlignment.middle },
|
|
5987
5986
|
direction: Direction.grid,
|
package/dist/server/index.mjs
CHANGED
|
@@ -702,7 +702,7 @@ var isHTML = (html = "") => {
|
|
|
702
702
|
}
|
|
703
703
|
return html.search(HTML_TAGS_REGEX) !== -1;
|
|
704
704
|
};
|
|
705
|
-
var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text
|
|
705
|
+
var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text }) => isHTML(text)));
|
|
706
706
|
var checkForHTML = (input) => !(isString(input) && isHTML(input) || isPlainObject2(input) && hasHTMLInDoc(input));
|
|
707
707
|
var NO_HTML = { message: "HTML is not supported" };
|
|
708
708
|
var isSectionType = (sectionType) => (section) => get(section, "sectionType") === sectionType;
|
|
@@ -2756,17 +2756,17 @@ var CABImageSection = CABImageSectionFields.superRefine(({ category, source: sou
|
|
|
2756
2756
|
var HTML_COMMENT_RE = /<!--[\s\S]*?-->/g;
|
|
2757
2757
|
var STRIPPED_ELEMENT_RE = /<(script|style|iframe|object|embed|noscript|template)\b[^>]*>[\s\S]*?(?:<\/\1\s*>|$)/gi;
|
|
2758
2758
|
var HTML_TAG_RE = /<\/?[a-zA-Z][^>]*>/g;
|
|
2759
|
-
var stripContentBlockHtml = (
|
|
2759
|
+
var stripContentBlockHtml = (text) => text.replace(HTML_COMMENT_RE, "").replace(STRIPPED_ELEMENT_RE, "").replace(HTML_TAG_RE, "");
|
|
2760
2760
|
|
|
2761
2761
|
// src/transforms/contentBlockV1/convertTextToTiptapParagraph.ts
|
|
2762
2762
|
var convertTextToTiptapParagraph = ({
|
|
2763
2763
|
color,
|
|
2764
2764
|
fontSize,
|
|
2765
2765
|
marks: marks2 = [],
|
|
2766
|
-
text
|
|
2766
|
+
text,
|
|
2767
2767
|
textAlign
|
|
2768
2768
|
}) => {
|
|
2769
|
-
const sanitizedText = stripContentBlockHtml(
|
|
2769
|
+
const sanitizedText = stripContentBlockHtml(text);
|
|
2770
2770
|
return TiptapParagraph.parse({
|
|
2771
2771
|
attrs: { textAlign },
|
|
2772
2772
|
content: sanitizedText ? [
|
|
@@ -2840,13 +2840,13 @@ var convertContentBlockImageToV2 = (block) => {
|
|
|
2840
2840
|
// src/transforms/normalizeTokens.ts
|
|
2841
2841
|
import { escapeRegExp } from "es-toolkit";
|
|
2842
2842
|
var DEFAULT_KNOWN_TOKENS = ["firstName", "lastName", "email"];
|
|
2843
|
-
var normalizeTokens = (
|
|
2844
|
-
if (typeof
|
|
2843
|
+
var normalizeTokens = (text, knownTokens = DEFAULT_KNOWN_TOKENS) => {
|
|
2844
|
+
if (typeof text !== "string") return text;
|
|
2845
2845
|
return knownTokens.reduce((acc, token) => {
|
|
2846
2846
|
const snakeTolerant = escapeRegExp(token).replace(/([A-Z])/g, "_?$1");
|
|
2847
2847
|
const pattern = new RegExp(`\\{{1,2}\\s*${snakeTolerant}\\s*\\}{1,2}`, "gi");
|
|
2848
2848
|
return acc.replace(pattern, `{{${token}}}`);
|
|
2849
|
-
},
|
|
2849
|
+
}, text);
|
|
2850
2850
|
};
|
|
2851
2851
|
|
|
2852
2852
|
// src/transforms/contentBlockV1/convertContentBlockTextToV2.ts
|
|
@@ -2856,7 +2856,7 @@ var HEADER_PARAGRAPH_STYLES = {
|
|
|
2856
2856
|
superTitle: { color: "base", fontSize: "extraLarge", marks: [{ type: "bold" }] },
|
|
2857
2857
|
title: { color: "base", fontSize: "medium", marks: [{ type: "bold" }] }
|
|
2858
2858
|
};
|
|
2859
|
-
var convertContentBlockTextToV2 = (language3,
|
|
2859
|
+
var convertContentBlockTextToV2 = (language3, text = literalText, textAlign = "center") => {
|
|
2860
2860
|
const description = language3?.description;
|
|
2861
2861
|
const superTitle = language3?.superTitle;
|
|
2862
2862
|
const title = language3?.title;
|
|
@@ -2865,17 +2865,17 @@ var convertContentBlockTextToV2 = (language3, text2 = literalText, textAlign = "
|
|
|
2865
2865
|
content: [
|
|
2866
2866
|
superTitle ? convertTextToTiptapParagraph({
|
|
2867
2867
|
...HEADER_PARAGRAPH_STYLES.superTitle,
|
|
2868
|
-
text:
|
|
2868
|
+
text: text("superTitle", superTitle),
|
|
2869
2869
|
textAlign
|
|
2870
2870
|
}) : null,
|
|
2871
2871
|
title ? convertTextToTiptapParagraph({
|
|
2872
2872
|
...HEADER_PARAGRAPH_STYLES.title,
|
|
2873
|
-
text:
|
|
2873
|
+
text: text("title", title),
|
|
2874
2874
|
textAlign
|
|
2875
2875
|
}) : null,
|
|
2876
2876
|
description ? convertTextToTiptapParagraph({
|
|
2877
2877
|
...HEADER_PARAGRAPH_STYLES.description,
|
|
2878
|
-
text:
|
|
2878
|
+
text: text("description", description),
|
|
2879
2879
|
textAlign
|
|
2880
2880
|
}) : null
|
|
2881
2881
|
].filter((p) => p !== null),
|
|
@@ -3523,7 +3523,7 @@ var isMonetizeV1 = isWidgetV1(WidgetType.ui_extension_ad);
|
|
|
3523
3523
|
|
|
3524
3524
|
// src/transforms/normalizeTextContent.ts
|
|
3525
3525
|
var HTML_TAG_RE2 = /<[a-zA-Z]/;
|
|
3526
|
-
var containsHtml = (
|
|
3526
|
+
var containsHtml = (text) => HTML_TAG_RE2.test(text);
|
|
3527
3527
|
var isObject = (x) => x !== null && typeof x === "object" && !Array.isArray(x);
|
|
3528
3528
|
var normalizeTextValue = (value, options2 = {}) => {
|
|
3529
3529
|
const tokenized = normalizeTokens(value);
|
|
@@ -4455,6 +4455,9 @@ var parseShielded = (schema, raw, transform = (input) => input) => schema.parse(
|
|
|
4455
4455
|
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
4456
4456
|
import { z as z47 } from "zod";
|
|
4457
4457
|
|
|
4458
|
+
// src/cab/hasOwnKey.ts
|
|
4459
|
+
var hasOwnKey = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
4460
|
+
|
|
4458
4461
|
// src/transforms/postPurchase/convertCalloutBlock.ts
|
|
4459
4462
|
import { z as z41 } from "zod";
|
|
4460
4463
|
|
|
@@ -4468,12 +4471,12 @@ var sizes = {
|
|
|
4468
4471
|
xlarge: "extraLarge",
|
|
4469
4472
|
xsmall: "extraSmall"
|
|
4470
4473
|
};
|
|
4471
|
-
var styledTextRun = (
|
|
4474
|
+
var styledTextRun = (text, emphasized, size) => ({
|
|
4472
4475
|
marks: [
|
|
4473
4476
|
...emphasized ? [{ type: "bold" }] : [],
|
|
4474
4477
|
{ attrs: { color: "base", fontSize: sizes[size] }, type: "textStyle" }
|
|
4475
4478
|
],
|
|
4476
|
-
text
|
|
4479
|
+
text,
|
|
4477
4480
|
type: "text"
|
|
4478
4481
|
});
|
|
4479
4482
|
|
|
@@ -4498,16 +4501,16 @@ var convertCalloutBlock = (raw, report) => {
|
|
|
4498
4501
|
const horizontal = styled2 ? { center: "center", leading: "start", trailing: "end" }[styles2.textAlignment] : "center";
|
|
4499
4502
|
const sections = values2.flatMap(({ field, result }) => {
|
|
4500
4503
|
if (!result.success) return omit(`Unreadable post-purchase callout field: ${field}`);
|
|
4501
|
-
const
|
|
4502
|
-
if (
|
|
4503
|
-
const content = styled2 && typeof
|
|
4504
|
+
const text = result.data;
|
|
4505
|
+
if (text === "") return [];
|
|
4506
|
+
const content = styled2 && typeof text === "string" ? {
|
|
4504
4507
|
content: [
|
|
4505
4508
|
{
|
|
4506
4509
|
attrs: { textAlign: horizontal },
|
|
4507
|
-
content: [styledTextRun(
|
|
4510
|
+
content: [styledTextRun(text, styles2[`${field}Emphasized`], styles2[`${field}Size`])]
|
|
4508
4511
|
}
|
|
4509
4512
|
]
|
|
4510
|
-
} :
|
|
4513
|
+
} : text;
|
|
4511
4514
|
const section = CABTextSection.safeParse({ content: { en: content } });
|
|
4512
4515
|
return section.success ? [section.data] : omit(`Unreadable post-purchase callout field: ${field}`);
|
|
4513
4516
|
});
|
|
@@ -4586,16 +4589,16 @@ var convertImageContentText = (settings, report) => {
|
|
|
4586
4589
|
};
|
|
4587
4590
|
const value = ImageContentBlock.shape.settings.shape[field].safeParse(settings[field]);
|
|
4588
4591
|
if (!value.success) return omit();
|
|
4589
|
-
const
|
|
4590
|
-
if (
|
|
4591
|
-
const content = typeof
|
|
4592
|
+
const text = value.data;
|
|
4593
|
+
if (text === null || text === "") return [];
|
|
4594
|
+
const content = typeof text === "string" ? {
|
|
4592
4595
|
content: [
|
|
4593
4596
|
{
|
|
4594
4597
|
attrs: { textAlign: horizontal },
|
|
4595
|
-
content: [styledTextRun(
|
|
4598
|
+
content: [styledTextRun(text, field !== "description", settings[`${field}Size`])]
|
|
4596
4599
|
}
|
|
4597
4600
|
]
|
|
4598
|
-
} :
|
|
4601
|
+
} : text;
|
|
4599
4602
|
const section = CABTextSection.safeParse({ content: { en: content } });
|
|
4600
4603
|
return section.success ? [section.data] : omit();
|
|
4601
4604
|
});
|
|
@@ -4636,8 +4639,8 @@ var convertImageContentBlock = (raw, report) => {
|
|
|
4636
4639
|
}
|
|
4637
4640
|
const image = convertImageFrame({ alt, image: settings.image, imageSize: settings.imageSize });
|
|
4638
4641
|
if (!image) report?.({ detail: "Unreadable post-purchase image-content image", kind: "section" });
|
|
4639
|
-
const
|
|
4640
|
-
const textFrame = CABLayoutSection.parse({ direction: "grid", grid: { columns: ["100%"] }, sections: [
|
|
4642
|
+
const text = convertImageContentText(settings, report);
|
|
4643
|
+
const textFrame = CABLayoutSection.parse({ direction: "grid", grid: { columns: ["100%"] }, sections: [text] });
|
|
4641
4644
|
const placement = settings.imagePlacement ?? (settings.swapContent ? "right" : "left");
|
|
4642
4645
|
const imageFirst = placement === "left" || placement === "top";
|
|
4643
4646
|
const sections = imageFirst ? [image, textFrame] : [textFrame, image];
|
|
@@ -4712,8 +4715,8 @@ var convertPayButtonBlock = (raw, report, widgetSettings) => {
|
|
|
4712
4715
|
if (!parsed.success) return omit();
|
|
4713
4716
|
const { settings, styles: styles2 } = parsed.data;
|
|
4714
4717
|
const label2 = settings.label ? `${settings.label} \xB7 {{total}}` : "{{total}}";
|
|
4715
|
-
const
|
|
4716
|
-
if (!
|
|
4718
|
+
const text = CABTextSection.safeParse({ content: { en: label2 } });
|
|
4719
|
+
if (!text.success) return omit();
|
|
4717
4720
|
return [
|
|
4718
4721
|
CABLayoutSection.parse({
|
|
4719
4722
|
alignment: { horizontal: "center" },
|
|
@@ -4722,7 +4725,7 @@ var convertPayButtonBlock = (raw, report, widgetSettings) => {
|
|
|
4722
4725
|
sections: [
|
|
4723
4726
|
CABButtonSection.parse({
|
|
4724
4727
|
action: "addToOrder",
|
|
4725
|
-
sections: [
|
|
4728
|
+
sections: [text.data, soldOutSlot(ProductCardSettings.parse(widgetSettings ?? {}))]
|
|
4726
4729
|
})
|
|
4727
4730
|
],
|
|
4728
4731
|
width: styles2.buttonWidth
|
|
@@ -4762,8 +4765,8 @@ var productCardControls = (settings) => [
|
|
|
4762
4765
|
];
|
|
4763
4766
|
|
|
4764
4767
|
// src/transforms/postPurchase/productCardRows.ts
|
|
4765
|
-
var styledCopy = (
|
|
4766
|
-
content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text
|
|
4768
|
+
var styledCopy = (text, look) => ({
|
|
4769
|
+
content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text, type: "text" }], type: "paragraph" }],
|
|
4767
4770
|
type: "doc"
|
|
4768
4771
|
});
|
|
4769
4772
|
var merchantLabel = (value, fallback) => localizedContent({ en: fallback }, value);
|
|
@@ -4773,7 +4776,7 @@ var boundText = (variable, content) => ({
|
|
|
4773
4776
|
visibility: shownWhile(variable)
|
|
4774
4777
|
});
|
|
4775
4778
|
var earnedRow = ({ after, columns, label: label2, look, spacing, token, variable }) => {
|
|
4776
|
-
const styled2 = (
|
|
4779
|
+
const styled2 = (text) => look ? styledCopy(text, look) : text;
|
|
4777
4780
|
const value = earnedText(variable, styled2(token));
|
|
4778
4781
|
return {
|
|
4779
4782
|
direction: "grid",
|
|
@@ -4850,8 +4853,8 @@ var recurringSummary = (settings) => {
|
|
|
4850
4853
|
variable: HAS_RECURRING_SHIPPING
|
|
4851
4854
|
})
|
|
4852
4855
|
] : [],
|
|
4853
|
-
...FOOTNOTES.map((
|
|
4854
|
-
content: { en: styledCopy(
|
|
4856
|
+
...FOOTNOTES.map((text) => ({
|
|
4857
|
+
content: { en: styledCopy(text, small) },
|
|
4855
4858
|
sectionType: "text",
|
|
4856
4859
|
visibility: shownWhile(HAS_RECURRING_TOTAL)
|
|
4857
4860
|
}))
|
|
@@ -5009,9 +5012,9 @@ var convertTextBlock = (raw, report) => {
|
|
|
5009
5012
|
};
|
|
5010
5013
|
const sections = values2.flatMap(({ field, result }) => {
|
|
5011
5014
|
if (!result.success) return omit(field);
|
|
5012
|
-
const
|
|
5013
|
-
if (
|
|
5014
|
-
const content = styled2 ? { content: [{ attrs: { textAlign: horizontal }, content: [{ marks: styles[field], text
|
|
5015
|
+
const text = result.data;
|
|
5016
|
+
if (text === null || text === "") return [];
|
|
5017
|
+
const content = styled2 ? { content: [{ attrs: { textAlign: horizontal }, content: [{ marks: styles[field], text }] }] } : text;
|
|
5015
5018
|
const section = CABTextSection.safeParse({ content: { en: content } });
|
|
5016
5019
|
return section.success ? [section.data] : omit(field);
|
|
5017
5020
|
});
|
|
@@ -5046,13 +5049,13 @@ var convertTimerBlock = (raw, report) => {
|
|
|
5046
5049
|
}
|
|
5047
5050
|
]
|
|
5048
5051
|
} : withCountdown(title, countdown, horizontal);
|
|
5049
|
-
const
|
|
5050
|
-
if (!
|
|
5052
|
+
const text = CABTextSection.safeParse({ content: { en: content } });
|
|
5053
|
+
if (!text.success) return omit();
|
|
5051
5054
|
return [
|
|
5052
5055
|
CABBannerSection.parse({
|
|
5053
5056
|
color: styles2.timerBackgroundColor,
|
|
5054
5057
|
dismissible: false,
|
|
5055
|
-
sections: [
|
|
5058
|
+
sections: [text.data],
|
|
5056
5059
|
width: styles2.timerWidth
|
|
5057
5060
|
})
|
|
5058
5061
|
];
|
|
@@ -5083,7 +5086,7 @@ var convertMessagePreview = (id, settings, report) => {
|
|
|
5083
5086
|
sections: parsed.data.blocks.flatMap((block) => {
|
|
5084
5087
|
const type = BlockType2.safeParse(block);
|
|
5085
5088
|
const kind = type.success ? type.data.type : void 0;
|
|
5086
|
-
const convert2 = kind &&
|
|
5089
|
+
const convert2 = kind && hasOwnKey(converters, kind) ? converters[kind] : void 0;
|
|
5087
5090
|
if (convert2) return convert2(block, report, settings);
|
|
5088
5091
|
report?.({
|
|
5089
5092
|
detail: kind ? `Unsupported post-purchase block type: ${kind}` : "Unreadable post-purchase block: missing type",
|
|
@@ -5755,7 +5758,7 @@ var fetchAdsEngineOffers = async (input, ctx, prefetched) => {
|
|
|
5755
5758
|
// src/transforms/htmlToPlainText.ts
|
|
5756
5759
|
var paragraphText = (paragraph) => paragraph.content.map((run) => run.text).join("");
|
|
5757
5760
|
var FORCE_PARSER = { defaultTextStyle: {} };
|
|
5758
|
-
var withoutTagShapes = (
|
|
5761
|
+
var withoutTagShapes = (text) => isHTML(text) ? text.replace(/[<>]/g, "") : text;
|
|
5759
5762
|
var htmlToPlainText = (html) => withoutTagShapes(
|
|
5760
5763
|
normalizeTextValue(html, FORCE_PARSER).content.map((paragraph) => paragraphText(paragraph).trim()).filter((line) => line !== "").join("\n")
|
|
5761
5764
|
);
|
|
@@ -5763,12 +5766,11 @@ var htmlToPlainText = (html) => withoutTagShapes(
|
|
|
5763
5766
|
// src/server/composeOffer.ts
|
|
5764
5767
|
var ACCEPT_FALLBACK = "Accept";
|
|
5765
5768
|
var DECLINE_FALLBACK = "No Thanks";
|
|
5766
|
-
var label = (
|
|
5769
|
+
var label = (text) => ({
|
|
5767
5770
|
buttonField: ButtonField.buttonLabel,
|
|
5768
|
-
content: { en:
|
|
5771
|
+
content: { en: text },
|
|
5769
5772
|
sectionType: SectionType.text
|
|
5770
5773
|
});
|
|
5771
|
-
var text = (content) => ({ content: { en: content }, sectionType: SectionType.text });
|
|
5772
5774
|
var AS_DOC = { defaultTextStyle: {} };
|
|
5773
5775
|
var safeTextValue = (raw, options2) => {
|
|
5774
5776
|
const converted = normalizeTextValue(raw, options2);
|
|
@@ -5826,20 +5828,17 @@ var styled = (value, { align, bold, color, fontSize, href }) => ({
|
|
|
5826
5828
|
sectionType: SectionType.text
|
|
5827
5829
|
});
|
|
5828
5830
|
var shopName = (shop, storeName) => storeName?.replace(/<[^>]*>/g, "").trim() || shop.replace(/\.myshopify\.com$/, "") || "store";
|
|
5829
|
-
var
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
},
|
|
5841
|
-
text(input.orderName ? `Order ${input.orderName} Confirmed` : "Order Confirmed")
|
|
5842
|
-
];
|
|
5831
|
+
var headerSection = (input, storeName) => ({
|
|
5832
|
+
sections: [
|
|
5833
|
+
styled("Congratulations!", { bold: true, fontSize: "heading" }),
|
|
5834
|
+
styled(`Your ${shopName(input.shop, storeName)} purchase unlocked a bonus:`, {
|
|
5835
|
+
bold: true,
|
|
5836
|
+
fontSize: "heading"
|
|
5837
|
+
})
|
|
5838
|
+
],
|
|
5839
|
+
sectionType: SectionType.layout,
|
|
5840
|
+
spacing: Spacing.none
|
|
5841
|
+
});
|
|
5843
5842
|
var privacyHref = (offer, input) => {
|
|
5844
5843
|
const href = [offer.privacy_url, input.privacyPolicyUrl].find((url) => url && isValidHref(url));
|
|
5845
5844
|
return href ? { href } : {};
|
|
@@ -5851,9 +5850,9 @@ var legalCopy = (raw, visibleWhen) => ({
|
|
|
5851
5850
|
sectionType: SectionType.text,
|
|
5852
5851
|
...visibleWhen !== void 0 && { visibility: { variable: SHOW_EXTENDED, visibleWhen } }
|
|
5853
5852
|
});
|
|
5854
|
-
var disclosureToggle = (
|
|
5853
|
+
var disclosureToggle = (text, visibleWhen) => ({
|
|
5855
5854
|
buttonStyle: ButtonStyle.plain,
|
|
5856
|
-
sections: [label(
|
|
5855
|
+
sections: [label(text)],
|
|
5857
5856
|
sectionType: SectionType.button,
|
|
5858
5857
|
variableEffects: [{ effect: "toggle", variable: SHOW_EXTENDED }],
|
|
5859
5858
|
visibility: { variable: SHOW_EXTENDED, visibleWhen }
|
|
@@ -5908,7 +5907,7 @@ var composeOfferCard = (offer, input, storeName) => {
|
|
|
5908
5907
|
border: { style: BorderStyle.base },
|
|
5909
5908
|
padding: Spacing.tight,
|
|
5910
5909
|
sections: [
|
|
5911
|
-
|
|
5910
|
+
headerSection(input, storeName),
|
|
5912
5911
|
offer.image_url ? {
|
|
5913
5912
|
alignment: { horizontal: HorizontalAlignment.start, vertical: VerticalAlignment.middle },
|
|
5914
5913
|
direction: Direction.grid,
|
|
@@ -3717,6 +3717,9 @@ var parseShielded = (schema, raw, transform = (input) => input) => schema.parse(
|
|
|
3717
3717
|
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
3718
3718
|
var import_zod34 = require("zod");
|
|
3719
3719
|
|
|
3720
|
+
// src/cab/hasOwnKey.ts
|
|
3721
|
+
var hasOwnKey = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
3722
|
+
|
|
3720
3723
|
// src/server/shared.ts
|
|
3721
3724
|
var NotFoundError = class extends Error {
|
|
3722
3725
|
constructor(message) {
|
|
@@ -4706,7 +4709,7 @@ var convertMessagePreview = (id, settings, report) => {
|
|
|
4706
4709
|
sections: parsed.data.blocks.flatMap((block) => {
|
|
4707
4710
|
const type = BlockType2.safeParse(block);
|
|
4708
4711
|
const kind = type.success ? type.data.type : void 0;
|
|
4709
|
-
const convert2 = kind &&
|
|
4712
|
+
const convert2 = kind && hasOwnKey(converters, kind) ? converters[kind] : void 0;
|
|
4710
4713
|
if (convert2) return convert2(block, report, settings);
|
|
4711
4714
|
report?.({
|
|
4712
4715
|
detail: kind ? `Unsupported post-purchase block type: ${kind}` : "Unreadable post-purchase block: missing type",
|
|
@@ -3656,6 +3656,9 @@ var parseShielded = (schema, raw, transform = (input) => input) => schema.parse(
|
|
|
3656
3656
|
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
3657
3657
|
import { z as z34 } from "zod";
|
|
3658
3658
|
|
|
3659
|
+
// src/cab/hasOwnKey.ts
|
|
3660
|
+
var hasOwnKey = (object, key) => Object.prototype.hasOwnProperty.call(object, key);
|
|
3661
|
+
|
|
3659
3662
|
// src/server/shared.ts
|
|
3660
3663
|
var NotFoundError = class extends Error {
|
|
3661
3664
|
constructor(message) {
|
|
@@ -4645,7 +4648,7 @@ var convertMessagePreview = (id, settings, report) => {
|
|
|
4645
4648
|
sections: parsed.data.blocks.flatMap((block) => {
|
|
4646
4649
|
const type = BlockType2.safeParse(block);
|
|
4647
4650
|
const kind = type.success ? type.data.type : void 0;
|
|
4648
|
-
const convert2 = kind &&
|
|
4651
|
+
const convert2 = kind && hasOwnKey(converters, kind) ? converters[kind] : void 0;
|
|
4649
4652
|
if (convert2) return convert2(block, report, settings);
|
|
4650
4653
|
report?.({
|
|
4651
4654
|
detail: kind ? `Unsupported post-purchase block type: ${kind}` : "Unreadable post-purchase block: missing type",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.60.
|
|
3
|
+
"version": "3.60.4",
|
|
4
4
|
"description": "Shared zod schemas, legacy-to-CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers (rebuy-api, admin-nextjs, rebuy-shopify-extensions)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rebuy, Inc.",
|