@tokenoftrust/storefront-runner 2.4.77 → 2.4.78

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "2.4.77",
3
+ "version": "2.4.78",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
6
6
  "packageManager": "pnpm@11.9.0",
@@ -47,9 +47,37 @@ const DEFAULT_SPEC_HEADING = "Product Details";
47
47
  const DEFAULT_FAQ_HEADING = "Frequently Asked Questions";
48
48
  const DEFAULT_BOX_CONTENTS_LABEL = "What's in the box";
49
49
 
50
+ /**
51
+ * True for a metafield that carries an unresolved platform reference rather
52
+ * than displayable content — a Shopify metaobject/product/variant/file/
53
+ * collection/page reference (bare or `list.*`), surfaced either through its
54
+ * declared `type` or, when type is absent/untrusted, through the `gid://`
55
+ * shape of its value itself (bare or as a JSON array of them, the `list.*`
56
+ * on-disk form). No declared section may render one: a raw `gid://...`
57
+ * identifier is never product content, no matter which section asked for it.
58
+ */
59
+ function isUnresolvedReference(m: Metafield): boolean {
60
+ if (m.type && /_reference$/.test(m.type)) return true;
61
+ const v = m.value?.trim();
62
+ if (!v) return false;
63
+ if (v.startsWith("gid://")) return true;
64
+ if (v.startsWith("[")) {
65
+ try {
66
+ const parsed = JSON.parse(v);
67
+ if (Array.isArray(parsed) && parsed.length > 0 && parsed.every((x) => typeof x === "string" && x.startsWith("gid://"))) {
68
+ return true;
69
+ }
70
+ } catch {
71
+ /* not JSON — fall through, not a reference by this check */
72
+ }
73
+ }
74
+ return false;
75
+ }
76
+
50
77
  function metafieldLookup(metafields: readonly Metafield[]): (namespace: string, key: string) => string | undefined {
51
78
  const map = new Map<string, string>();
52
79
  for (const m of metafields) {
80
+ if (isUnresolvedReference(m)) continue;
53
81
  const v = m.value?.trim();
54
82
  if (v) map.set(`${m.namespace}.${m.key}`, v);
55
83
  }