@rebuy/rebuy 3.60.2 → 3.60.3

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.
@@ -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;
@@ -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 (Object.hasOwn(variables, key)) return key;
60
+ if (hasOwnKey(variables, key)) return key;
58
61
  const camel = toCamelCase(key);
59
- if (Object.hasOwn(variables, camel)) return camel;
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 && Object.hasOwn(content, language)) return content[language];
74
- if (Object.hasOwn(content, FALLBACK_LANGUAGE)) return content[FALLBACK_LANGUAGE];
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
 
@@ -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 (Object.hasOwn(variables, key)) return key;
22
+ if (hasOwnKey(variables, key)) return key;
20
23
  const camel = toCamelCase(key);
21
- if (Object.hasOwn(variables, camel)) return camel;
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 && Object.hasOwn(content, language)) return content[language];
36
- if (Object.hasOwn(content, FALLBACK_LANGUAGE)) return content[FALLBACK_LANGUAGE];
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
- * `Object.hasOwn`, never `in` — `in` would resolve an inherited `Object.prototype` key (`constructor`,
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
  */
@@ -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
 
@@ -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 && Object.hasOwn(converters, kind) ? converters[kind] : void 0;
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",
@@ -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
 
@@ -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 && Object.hasOwn(converters, kind) ? converters[kind] : void 0;
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",
@@ -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 && Object.hasOwn(converters, kind) ? converters[kind] : void 0;
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 && Object.hasOwn(converters, kind) ? converters[kind] : void 0;
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.2",
3
+ "version": "3.60.3",
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.",