@tanqory/partner-cli 0.1.0-alpha.3 → 0.1.0-alpha.6

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.
@@ -6,6 +6,14 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __esm = (fn, res, err) => function __init() {
10
+ if (err) throw err[0];
11
+ try {
12
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
13
+ } catch (e) {
14
+ throw err = [e], e;
15
+ }
16
+ };
9
17
  var __commonJS = (cb, mod) => function __require() {
10
18
  try {
11
19
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -330,27 +338,27 @@ var require_editability = __commonJS({
330
338
  };
331
339
  const typeAt = prop("type");
332
340
  const type = typeAt >= 0 ? literalAt(src, typeAt) : null;
333
- const def = { kind: m[1] === "Section" ? "section" : "block", type, start: m.index, open, close, settings: [], has: {} };
334
- for (const k of ["zone", "requires", "presets", "blocks", "component", "title"]) def.has[k] = prop(k) >= 0;
335
- def.componentAt = def.has.component ? prop("component") : close;
341
+ const def2 = { kind: m[1] === "Section" ? "section" : "block", type, start: m.index, open, close, settings: [], has: {} };
342
+ for (const k of ["zone", "requires", "presets", "blocks", "component", "title"]) def2.has[k] = prop(k) >= 0;
343
+ def2.componentAt = def2.has.component ? prop("component") : close;
336
344
  const presetsAt = prop("presets");
337
345
  if (presetsAt >= 0) {
338
346
  const o = mask.indexOf("[", presetsAt);
339
347
  const c = o >= 0 ? matchBracket(mask, o) : -1;
340
- def.presets = c > 0 ? src.slice(o, c + 1) : "";
348
+ def2.presets = c > 0 ? src.slice(o, c + 1) : "";
341
349
  }
342
350
  const blocksAt = prop("blocks");
343
351
  if (blocksAt >= 0) {
344
352
  const o = mask.indexOf("[", blocksAt);
345
353
  const c = o >= 0 && o - blocksAt < 4 ? matchBracket(mask, o) : -1;
346
- def.blocksList = c > 0 ? src.slice(o, c + 1) : "";
354
+ def2.blocksList = c > 0 ? src.slice(o, c + 1) : "";
347
355
  }
348
356
  const settingsAt = prop("settings");
349
357
  if (settingsAt >= 0) {
350
358
  const o = mask.indexOf("{", settingsAt);
351
359
  const c = o >= 0 && o - settingsAt < 4 ? matchBracket(mask, o) : -1;
352
360
  if (c > 0) {
353
- def.settingsRange = [o, c];
361
+ def2.settingsRange = [o, c];
354
362
  const fr = /([A-Za-z_$][\w$]*)\s*:\s*field\s*\.\s*(\w+)\s*\(/g;
355
363
  const seg = mask.slice(o, c);
356
364
  let f;
@@ -360,11 +368,11 @@ var require_editability = __commonJS({
360
368
  const args = callClose > 0 ? src.slice(callOpen + 1, callClose) : "";
361
369
  const kind = f[2];
362
370
  const dflt = kind === "resource" ? null : ["text", "textarea", "richtext", "url", "color"].includes(kind) ? literalAt(args, 0) : null;
363
- def.settings.push({ key: f[1], kind, default: dflt, hasLabel: /\blabel\s*:/.test(args), at: o + f.index, resourceKind: kind === "resource" ? literalAt(args, 0) : null });
371
+ def2.settings.push({ key: f[1], kind, default: dflt, hasLabel: /\blabel\s*:/.test(args), at: o + f.index, resourceKind: kind === "resource" ? literalAt(args, 0) : null });
364
372
  }
365
373
  }
366
374
  }
367
- out.push(def);
375
+ out.push(def2);
368
376
  }
369
377
  return out;
370
378
  }
@@ -403,11 +411,11 @@ var require_editability = __commonJS({
403
411
  if (typeof t !== "string") return null;
404
412
  try {
405
413
  const out = {};
406
- const walk = (o, p) => {
407
- if (o && typeof o === "object" && !Array.isArray(o)) for (const [k, v] of Object.entries(o)) walk(v, p ? `${p}.${k}` : k);
414
+ const walk2 = (o, p) => {
415
+ if (o && typeof o === "object" && !Array.isArray(o)) for (const [k, v] of Object.entries(o)) walk2(v, p ? `${p}.${k}` : k);
408
416
  else if (typeof o === "string") out[p] = o;
409
417
  };
410
- walk(JSON.parse(t), "");
418
+ walk2(JSON.parse(t), "");
411
419
  return out;
412
420
  } catch {
413
421
  return null;
@@ -427,15 +435,15 @@ var require_editability = __commonJS({
427
435
  let v;
428
436
  while (v = inner.exec(m[1])) found.push({ at: m.index + m[0].indexOf(m[1]) + v.index + v[0].length - v[2].length - 1, value: v[2] });
429
437
  }
430
- let plain = null;
438
+ let plain2 = null;
431
439
  for (const f of found) {
432
440
  if (f.value.startsWith("t:")) {
433
441
  const key = f.value.slice(2);
434
442
  if (!schemaEn) add("error", "missing_label_translation", file, src, f.at, `"${f.value}" needs locales/en.schema.json, which the theme does not have (or is not valid JSON).`, `Add locales/en.schema.json with the key ${key} (nested JSON, as the reference's schema locale files).`);
435
443
  else if (typeof schemaEn[key] !== "string" || !schemaEn[key].trim()) add("error", "missing_label_translation", file, src, f.at, `"${f.value}" has no English words in locales/en.schema.json.`, `Add "${key}" to locales/en.schema.json.`);
436
- } else if (f.value.trim() && !plain) plain = f;
444
+ } else if (f.value.trim() && !plain2) plain2 = f;
437
445
  }
438
- if (plain) add("warning", "label_not_translated", file, src, plain.at, `Labels such as "${plain.value.slice(0, 40)}" are plain English, so a merchant using the editor in another language reads them in English.`, `Write labels as t:<key> (label: 't:labels.heading') with the words in locales/en.schema.json; other languages go in locales/<lang>.schema.json (optional).`);
446
+ if (plain2) add("warning", "label_not_translated", file, src, plain2.at, `Labels such as "${plain2.value.slice(0, 40)}" are plain English, so a merchant using the editor in another language reads them in English.`, `Write labels as t:<key> (label: 't:labels.heading') with the words in locales/en.schema.json; other languages go in locales/<lang>.schema.json (optional).`);
439
447
  };
440
448
  if (typeof files["src/settings.ts"] === "string") labelScan("src/settings.ts", files["src/settings.ts"], [[0, files["src/settings.ts"].length]]);
441
449
  const sections = [];
@@ -571,7 +579,8 @@ var require_editability = __commonJS({
571
579
  if (d.kind === "section" && !d.has.presets && !d.has.zone && !d.has.requires && !TEMPLATE_SECTIONS.has(d.type || "")) {
572
580
  add("error", "no_preset", file, src, at, `Section "${d.type}" has no preset, so the merchant cannot add it from "Add section".`, `presets: [{ name: '${d.type}', settings: { ...the sample content }${d.has.blocks ? ", blocks: [{ type: '\u2026', settings: {\u2026} }, \u2026]" : ""} }]`);
573
581
  }
574
- if (d.kind === "section" && d.has.blocks && d.blocksList && /\w/.test(d.blocksList) && d.has.presets && !/\bblocks\s*:/.test(d.presets || "")) {
582
+ const ownBlocks = (d.blocksList || "").replace(/\bAPP_BLOCKS\b|['"`]@app['"`]/g, "");
583
+ if (d.kind === "section" && d.has.blocks && /\w/.test(ownBlocks) && d.has.presets && !/\bblocks\s*:/.test(d.presets || "")) {
575
584
  add("error", "preset_without_blocks", file, src, at, `Section "${d.type}" takes blocks, but its preset adds none: a merchant who adds it gets an empty section.`, "Add the sample items to the preset: presets: [{ name: \u2026, blocks: [{ type: \u2026, settings: {\u2026} }, { \u2026 }, { \u2026 }] }]");
576
585
  }
577
586
  const stems = /* @__PURE__ */ new Map();
@@ -678,18 +687,18 @@ var require_editability = __commonJS({
678
687
  } catch {
679
688
  continue;
680
689
  }
681
- const walk = (v, key) => {
690
+ const walk2 = (v, key) => {
682
691
  if (typeof v === "string") {
683
692
  if (/^https?:\/\//i.test(v) && (IMAGE_KEY.test(key || "") || IMAGE_EXT.test(v))) note(v, file, text);
684
693
  return;
685
694
  }
686
695
  if (Array.isArray(v)) {
687
- v.forEach((x) => walk(x, key));
696
+ v.forEach((x) => walk2(x, key));
688
697
  return;
689
698
  }
690
- if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk(x, k);
699
+ if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk2(x, k);
691
700
  };
692
- walk(doc, "");
701
+ walk2(doc, "");
693
702
  } else if (/^src\/.+\.(tsx|ts|jsx|js)$/.test(file)) {
694
703
  const re = /(['"`])(https?:\/\/[^'"`\s]+?\.(?:png|jpe?g|webp|gif|avif|svg)(?:\?[^'"`\s]*)?)\1/gi;
695
704
  let m;
@@ -743,6 +752,121 @@ var require_editability = __commonJS({
743
752
  }
744
753
  });
745
754
 
755
+ // ../theme-abi/src/jcs.ts
756
+ var jcs_exports = {};
757
+ __export(jcs_exports, {
758
+ CANONICAL_JSON_MAX_DEPTH: () => CANONICAL_JSON_MAX_DEPTH,
759
+ CanonicalJsonError: () => CanonicalJsonError,
760
+ canonicalJson: () => canonicalJson
761
+ });
762
+ function unpairedSurrogateIndex(s) {
763
+ for (let i = 0; i < s.length; i++) {
764
+ const c = s.charCodeAt(i);
765
+ if (c < 55296 || c > 57343) continue;
766
+ if (c <= 56319 && i + 1 < s.length) {
767
+ const next = s.charCodeAt(i + 1);
768
+ if (next >= 56320 && next <= 57343) {
769
+ i++;
770
+ continue;
771
+ }
772
+ }
773
+ return i;
774
+ }
775
+ return -1;
776
+ }
777
+ function isPlainObject(value) {
778
+ if (Object.prototype.toString.call(value) !== "[object Object]") return false;
779
+ const proto = Object.getPrototypeOf(value);
780
+ return proto === null || Object.getPrototypeOf(proto) === null;
781
+ }
782
+ function canonicalJson(value) {
783
+ const stack = [];
784
+ const open = /* @__PURE__ */ new Set();
785
+ let result = "";
786
+ const pathOf = (at) => `$${stack.map((f) => f.at).join("")}${at}`;
787
+ const refuse = (code, at, what) => {
788
+ const path = pathOf(at);
789
+ throw new CanonicalJsonError(code, path, what(path));
790
+ };
791
+ const emit = (text) => {
792
+ const parent = stack[stack.length - 1];
793
+ if (parent === void 0) result = text;
794
+ else parent.parts.push(parent.prefix + text);
795
+ };
796
+ const visit = (v, at) => {
797
+ if (stack.length > CANONICAL_JSON_MAX_DEPTH) refuse("too_deep", at, (p) => `nesting deeper than ${CANONICAL_JSON_MAX_DEPTH} at ${p}`);
798
+ if (v === null) return emit("null");
799
+ switch (typeof v) {
800
+ case "boolean":
801
+ return emit(v ? "true" : "false");
802
+ case "number":
803
+ if (!Number.isFinite(v)) refuse("non_finite_number", at, (p) => `non-finite number at ${p}`);
804
+ return emit(JSON.stringify(v));
805
+ case "string":
806
+ if (unpairedSurrogateIndex(v) !== -1) refuse("unpaired_surrogate", at, (p) => `unpaired surrogate in string at ${p}: the value has no canonical form`);
807
+ return emit(JSON.stringify(v));
808
+ case "object": {
809
+ if (open.has(v)) refuse("cyclic_value", at, (p) => `the value at ${p} contains itself`);
810
+ let keys = null;
811
+ if (!Array.isArray(v)) {
812
+ if (!isPlainObject(v)) refuse("unsupported_type", at, (p) => `${Object.prototype.toString.call(v).slice(8, -1)} at ${p} is not a JSON value`);
813
+ const obj = v;
814
+ keys = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
815
+ for (const k of keys) {
816
+ if (unpairedSurrogateIndex(k) !== -1) {
817
+ refuse("unpaired_surrogate", at, (p) => `unpaired surrogate in object key ${JSON.stringify(k)} at ${p}: the value has no canonical form`);
818
+ }
819
+ }
820
+ }
821
+ open.add(v);
822
+ stack.push({ container: v, keys, length: keys === null ? v.length : keys.length, index: 0, parts: [], prefix: "", at });
823
+ return;
824
+ }
825
+ default:
826
+ return refuse("unsupported_type", at, (p) => `${typeof v} at ${p} is not a JSON value`);
827
+ }
828
+ };
829
+ visit(value, "");
830
+ for (; ; ) {
831
+ const top = stack[stack.length - 1];
832
+ if (top === void 0) return result;
833
+ if (top.index >= top.length) {
834
+ stack.pop();
835
+ open.delete(top.container);
836
+ emit(top.keys === null ? `[${top.parts.join(",")}]` : `{${top.parts.join(",")}}`);
837
+ continue;
838
+ }
839
+ const i = top.index++;
840
+ if (top.keys === null) {
841
+ const arr = top.container;
842
+ if (!(i in arr) || arr[i] === void 0) refuse("unsupported_type", `[${i}]`, (p) => `undefined or a hole in an array at ${p}`);
843
+ visit(arr[i], `[${i}]`);
844
+ } else {
845
+ const k = top.keys[i];
846
+ top.prefix = `${JSON.stringify(k)}:`;
847
+ visit(top.container[k], `.${k}`);
848
+ }
849
+ }
850
+ }
851
+ var CANONICAL_JSON_MAX_DEPTH, CanonicalJsonError;
852
+ var init_jcs = __esm({
853
+ "../theme-abi/src/jcs.ts"() {
854
+ "use strict";
855
+ CANONICAL_JSON_MAX_DEPTH = 128;
856
+ CanonicalJsonError = class extends TypeError {
857
+ name = "CanonicalJsonError";
858
+ code;
859
+ /** Where the value sits, e.g. `$[0].filters[2]`. For a bad key: the object holding it. */
860
+ path;
861
+ constructor(code, path, message) {
862
+ super(message);
863
+ this.code = code;
864
+ this.path = path;
865
+ }
866
+ };
867
+ }
868
+ });
869
+
746
870
  // ../theme-standard/lib/source.js
747
871
  var require_source = __commonJS({
748
872
  "../theme-standard/lib/source.js"(exports2, module2) {
@@ -1010,14 +1134,14 @@ var require_text_rules = __commonJS({
1010
1134
  }
1011
1135
  function manifestLabels2(manifest) {
1012
1136
  const out = [];
1013
- const walk = (v, path, key) => {
1137
+ const walk2 = (v, path, key) => {
1014
1138
  if (out.length >= 1e4) return;
1015
1139
  if (typeof v === "string") {
1016
1140
  if (key !== null && LABEL_KEYS.has(key)) out.push([path || "/", v]);
1017
- } else if (Array.isArray(v)) v.forEach((x, i) => walk(x, `${path}/${i}`, key));
1018
- else if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk(x, `${path}/${k.replace(/~/g, "~0").replace(/\//g, "~1")}`, k);
1141
+ } else if (Array.isArray(v)) v.forEach((x, i) => walk2(x, `${path}/${i}`, key));
1142
+ else if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk2(x, `${path}/${k.replace(/~/g, "~0").replace(/\//g, "~1")}`, k);
1019
1143
  };
1020
- walk(manifest, "", null);
1144
+ walk2(manifest, "", null);
1021
1145
  return out;
1022
1146
  }
1023
1147
  function sourceTextFindings2(files, max = 50) {
@@ -1066,7 +1190,1710 @@ module.exports = __toCommonJS(partner_source_exports);
1066
1190
  var import_node_fs4 = require("node:fs");
1067
1191
  var import_node_path4 = require("node:path");
1068
1192
  var import_node_stream = require("node:stream");
1069
- var import_theme_abi3 = require("@tanqory/theme-abi");
1193
+
1194
+ // ../theme-abi/src/capabilities.ts
1195
+ var FIXED_CAPABILITIES = Object.freeze(/* @__PURE__ */ new Set([
1196
+ "data:shop",
1197
+ "data:localization",
1198
+ "data:catalog",
1199
+ "data:content",
1200
+ "data:search",
1201
+ "data:cart",
1202
+ "data:customer",
1203
+ "data:metaobjects",
1204
+ "data:products.recommendations",
1205
+ "data:inventory",
1206
+ "actions:cart",
1207
+ "actions:consent",
1208
+ "actions:customer",
1209
+ "actions:form.submit",
1210
+ "preview:renderSection"
1211
+ ]));
1212
+ var IMPLICIT_CAPABILITIES = Object.freeze(/* @__PURE__ */ new Set([
1213
+ "data:shop",
1214
+ "data:localization"
1215
+ ]));
1216
+ var DEFAULT_GRANTED_CAPABILITIES = Object.freeze(/* @__PURE__ */ new Set([
1217
+ "data:catalog",
1218
+ "data:content",
1219
+ "data:cart"
1220
+ ]));
1221
+ var OPT_IN_CAPABILITIES = Object.freeze(/* @__PURE__ */ new Set([
1222
+ "data:search",
1223
+ "data:customer",
1224
+ "data:metaobjects",
1225
+ "data:products.recommendations",
1226
+ "data:inventory"
1227
+ ]));
1228
+ var BROWSER_CAPABILITY_CEILING = Object.freeze(/* @__PURE__ */ new Set([
1229
+ "data:shop",
1230
+ "data:localization",
1231
+ "data:catalog",
1232
+ "data:content",
1233
+ "data:search",
1234
+ "data:cart",
1235
+ "data:products.recommendations",
1236
+ "data:inventory",
1237
+ "actions:cart",
1238
+ "actions:consent"
1239
+ ]));
1240
+ var DEFAULT_BROWSER_CAPABILITIES = Object.freeze(/* @__PURE__ */ new Set([
1241
+ "data:shop",
1242
+ "data:localization",
1243
+ "data:catalog",
1244
+ "data:content",
1245
+ "data:search",
1246
+ "data:cart",
1247
+ "actions:cart",
1248
+ "actions:consent"
1249
+ ]));
1250
+ var SERVER_ONLY_CAPABILITIES = Object.freeze(/* @__PURE__ */ new Set([
1251
+ "data:customer",
1252
+ "data:metaobjects",
1253
+ "actions:customer",
1254
+ "actions:form.submit"
1255
+ ]));
1256
+ var PREVIEW_CAPABILITIES = Object.freeze(/* @__PURE__ */ new Set([
1257
+ "data:shop",
1258
+ "data:localization",
1259
+ "data:catalog",
1260
+ "data:content",
1261
+ "data:search",
1262
+ "data:cart",
1263
+ "data:products.recommendations",
1264
+ "data:inventory",
1265
+ "actions:cart",
1266
+ "actions:consent",
1267
+ "preview:renderSection"
1268
+ ]));
1269
+ var SSR_ALLOWED_ACTIONS = Object.freeze(/* @__PURE__ */ new Set([
1270
+ "cart.create",
1271
+ "consent.set"
1272
+ ]));
1273
+ function isNetworkCapability(value) {
1274
+ if (typeof value !== "string" || !value.startsWith("network:https://")) return false;
1275
+ const literal = value.slice("network:".length);
1276
+ let url;
1277
+ try {
1278
+ url = new URL(literal);
1279
+ } catch {
1280
+ return false;
1281
+ }
1282
+ return url.protocol === "https:" && url.hostname.length > 0 && url.origin === literal;
1283
+ }
1284
+ function isBrowserCapability(value) {
1285
+ return typeof value === "string" && BROWSER_CAPABILITY_CEILING.has(value);
1286
+ }
1287
+
1288
+ // ../theme-abi/src/limits.ts
1289
+ var KIB = 1024;
1290
+ var MIB = 1024 * KIB;
1291
+ var LIMITS_VERSION = "2.1";
1292
+ var row = (s) => Object.freeze(s);
1293
+ var LIMITS = Object.freeze({
1294
+ limitsVersion: LIMITS_VERSION,
1295
+ // ── runtime: measured per render by the conformance runner; the edge also enforces `hard` ──
1296
+ /** Hard: kill ⇒ LKG + `x-tq-degraded: lkg`, counts a breach. Budget: `slow_render`. */
1297
+ cpuPerRenderMs: row({ class: "runtime", budget: 50, hard: 200 }),
1298
+ /** Budget → artifact flagged `slow_init`; hard ⇒ quarantine. */
1299
+ moduleInitCpuMs: row({ class: "runtime", budget: 100, hard: 500 }),
1300
+ /** Serve. `signal` aborts. */
1301
+ wallClockPerRenderMs: row({ class: "runtime", budget: 1500, hard: 5e3 }),
1302
+ /** Preview-only (editor canvas; suite 6). Rule-6 exempt while suite 6 is `not_applicable`. */
1303
+ wallClockPerRenderPreviewMs: row({ class: "runtime", budget: null, hard: 15e3, profile: "preview" }),
1304
+ /** Runtime-enforced isolate limit; may be `not_measured` (rule-6 exempt). */
1305
+ memoryBytes: row({ class: "runtime", budget: null, hard: 128 * MIB, rule6Exempt: true }),
1306
+ /** Streamed, counted. */
1307
+ responseBytes: row({ class: "runtime", budget: 512 * KIB, hard: 2 * MIB }),
1308
+ /**
1309
+ * `snapshot()` + sidebar + recommendations. Budget 3 (was 1, TS-10 2026-11-19): a page's natural round is the merchant's
1310
+ * strings, the snapshot and, where the page lists them, the collections, run together; budget 1 flagged every page of
1311
+ * the reference theme, so it carried no signal. Latency is what `sequentialRounds` measures (budget kept at 1).
1312
+ */
1313
+ dataCallsPerRender: row({ class: "runtime", budget: 3, hard: 4 }),
1314
+ /** data + `network:` + asset probes. Budget 3 (was 2) with the data calls above. */
1315
+ subRequestsPerRender: row({ class: "runtime", budget: 3, hard: 8 }),
1316
+ /** Each round is a cross-region hop. */
1317
+ sequentialRounds: row({ class: "runtime", budget: 1, hard: 2 }),
1318
+ networkCalls: row({ class: "runtime", budget: 0, hard: 2 }),
1319
+ logLinesPerRender: row({ class: "runtime", budget: null, hard: 50 }),
1320
+ logBytesPerRender: row({ class: "runtime", budget: null, hard: 8 * KIB }),
1321
+ /** Budget-only (never refuses): client bytes actually fetched by the hydrated page, gz; suite 5. */
1322
+ clientInitialTransferredGzipBytes: row({ class: "runtime", budget: 250 * KIB, hard: null }),
1323
+ // ── static: artifact bytes and manifest/content structure (validateManifest() / suite 1) ──
1324
+ ssrEntryRawBytes: row({ class: "static", budget: 2 * MIB, hard: 4 * MIB }),
1325
+ ssrEntryGzipBytes: row({ class: "static", budget: 512 * KIB, hard: 1 * MIB }),
1326
+ /** entry + imports + css, gz. */
1327
+ clientInitialGzipBytes: row({ class: "static", budget: 250 * KIB, hard: 400 * KIB }),
1328
+ clientTotalRawBytes: row({ class: "static", budget: 10 * MIB, hard: 25 * MIB }),
1329
+ /** Incl. `x-*`. */
1330
+ manifestBytes: row({ class: "static", budget: 256 * KIB, hard: 512 * KIB }),
1331
+ components: row({ class: "static", budget: 128, hard: 256 }),
1332
+ attributesPerComponent: row({ class: "static", budget: null, hard: 64 }),
1333
+ presetsPerComponent: row({ class: "static", budget: null, hard: 16 }),
1334
+ blocksPerNode: row({ class: "static", budget: null, hard: 64 }),
1335
+ /** Blocks below a section (a section's own blocks are depth 1). 8, as the reference platform's theme blocks. */
1336
+ nestingDepth: row({ class: "static", budget: null, hard: 8 }),
1337
+ templates: row({ class: "static", budget: null, hard: 128 }),
1338
+ regions: row({ class: "static", budget: null, hard: 32 }),
1339
+ customRoutes: row({ class: "static", budget: null, hard: 16 }),
1340
+ forms: row({ class: "static", budget: null, hard: 16 }),
1341
+ /**
1342
+ * 100 (was 50, Lim-3 2026-11-19): every platform language (55 + English) and the 24 site-only languages (80), with
1343
+ * headroom. Each locale is data the server reads per request (Nova since deae44e440), not code in the server entry.
1344
+ */
1345
+ locales: row({ class: "static", budget: null, hard: 100 }),
1346
+ // ── host-policy: enforced by host/edge; never measured, never in a report ──
1347
+ /** Enforced by the egress proxy. */
1348
+ networkCallTimeoutMs: row({ class: "host-policy", budget: null, hard: 2e3 }),
1349
+ /** ⇒ `ROLLBACK kind=QUARANTINE` CAS to the control-chosen `lkgReleaseId`, per `(store, releaseId)`. */
1350
+ quarantineBreaches: row({ class: "host-policy", budget: null, hard: 20 }),
1351
+ quarantineWindowMs: row({ class: "host-policy", budget: null, hard: 6e4 }),
1352
+ quarantineErrorRatePercent: row({ class: "host-policy", budget: null, hard: 5 }),
1353
+ quarantineErrorRateSampleRequests: row({ class: "host-policy", budget: null, hard: 500 })
1354
+ });
1355
+ var LIMIT_KEYS = Object.freeze(
1356
+ Object.keys(LIMITS).filter((k) => k !== "limitsVersion")
1357
+ );
1358
+ var LIMIT_UNITS = Object.freeze({
1359
+ cpuPerRenderMs: "ms",
1360
+ moduleInitCpuMs: "ms",
1361
+ wallClockPerRenderMs: "ms",
1362
+ wallClockPerRenderPreviewMs: "ms",
1363
+ memoryBytes: "bytes",
1364
+ responseBytes: "bytes",
1365
+ dataCallsPerRender: "count",
1366
+ subRequestsPerRender: "count",
1367
+ sequentialRounds: "count",
1368
+ networkCalls: "count",
1369
+ logLinesPerRender: "count",
1370
+ logBytesPerRender: "bytes",
1371
+ clientInitialTransferredGzipBytes: "bytes",
1372
+ ssrEntryRawBytes: "bytes",
1373
+ ssrEntryGzipBytes: "bytes",
1374
+ clientInitialGzipBytes: "bytes",
1375
+ clientTotalRawBytes: "bytes",
1376
+ manifestBytes: "bytes",
1377
+ components: "count",
1378
+ attributesPerComponent: "count",
1379
+ presetsPerComponent: "count",
1380
+ blocksPerNode: "count",
1381
+ nestingDepth: "count",
1382
+ templates: "count",
1383
+ regions: "count",
1384
+ customRoutes: "count",
1385
+ forms: "count",
1386
+ locales: "count",
1387
+ networkCallTimeoutMs: "ms",
1388
+ quarantineBreaches: "count",
1389
+ quarantineWindowMs: "ms",
1390
+ quarantineErrorRatePercent: "percent",
1391
+ quarantineErrorRateSampleRequests: "count"
1392
+ });
1393
+ var CACHE_HINT_LIMITS = Object.freeze({
1394
+ maxAgeSeconds: 60,
1395
+ swrSeconds: 600,
1396
+ maxTags: 8,
1397
+ tagPattern: /^[a-z0-9:_-]{1,64}$/
1398
+ });
1399
+
1400
+ // ../theme-abi/src/field-types.ts
1401
+ var import__ = require("ajv/dist/2020.js");
1402
+ var FIELD_TYPES_REGISTRY_VERSION = "1";
1403
+ var FIELD_REGISTRY_VERSIONS = Object.freeze(["1", "2", "3", "4"]);
1404
+ function isFieldRegistryVersion(value) {
1405
+ return typeof value === "string" && FIELD_REGISTRY_VERSIONS.includes(value);
1406
+ }
1407
+ var UNIVERSAL_FIELD_CONSTRAINTS = Object.freeze(["label", "info", "default", "placeholder", "group", "visible_if"]);
1408
+ var def = (d) => Object.freeze({ ...d, constraints: Object.freeze([...d.constraints]), dynamicSourceTypes: Object.freeze([...d.dynamicSourceTypes]) });
1409
+ var plain = { constraints: [], media: null, resource: null };
1410
+ var resourceType = (id, doc, sources = []) => def({ id, control: "resource-picker", value: "string", constraints: ["resolve"], dynamicBindable: sources.length > 0, dynamicSourceTypes: sources, aiGenerate: true, media: null, resource: id, doc });
1411
+ var FIELD_TYPE_IDS_V1 = Object.freeze([
1412
+ "text",
1413
+ "textarea",
1414
+ "richtext",
1415
+ "html",
1416
+ "number",
1417
+ "range",
1418
+ "boolean",
1419
+ "color",
1420
+ "select",
1421
+ "radio",
1422
+ "text_alignment",
1423
+ "url",
1424
+ "image",
1425
+ "video",
1426
+ "collection",
1427
+ "product",
1428
+ "page",
1429
+ "blog",
1430
+ "article",
1431
+ "menu",
1432
+ "json",
1433
+ "list"
1434
+ ]);
1435
+ function nullProtoMap(entries) {
1436
+ return Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), entries));
1437
+ }
1438
+ var FIELD_TYPES_V1 = nullProtoMap({
1439
+ text: def({ ...plain, id: "text", control: "text-input", value: "string", dynamicBindable: true, dynamicSourceTypes: ["single_line_text_field"], aiGenerate: true, doc: "Single-line text." }),
1440
+ textarea: def({ ...plain, id: "textarea", control: "textarea", value: "string", dynamicBindable: true, dynamicSourceTypes: ["multi_line_text_field"], aiGenerate: true, doc: "Multi-line plain text, no markup." }),
1441
+ richtext: def({ ...plain, id: "richtext", control: "rich-text", value: "string", dynamicBindable: true, dynamicSourceTypes: ["rich_text_field"], aiGenerate: true, doc: "Formatted text." }),
1442
+ html: def({ ...plain, id: "html", control: "textarea", value: "string", dynamicBindable: false, dynamicSourceTypes: [], aiGenerate: false, doc: "Author-trusted; never bind shopper input." }),
1443
+ number: def({ ...plain, id: "number", control: "number-input", value: "number", constraints: ["min", "max", "step"], dynamicBindable: true, dynamicSourceTypes: ["number_integer", "number_decimal"], aiGenerate: true, doc: "Numeric input." }),
1444
+ range: def({ ...plain, id: "range", control: "slider", value: "number", constraints: ["min", "max", "step", "unit"], dynamicBindable: false, dynamicSourceTypes: [], aiGenerate: true, doc: "Slider; declare min/max/step." }),
1445
+ boolean: def({ ...plain, id: "boolean", control: "switch", value: "boolean", dynamicBindable: false, dynamicSourceTypes: ["boolean"], aiGenerate: true, doc: "On/off." }),
1446
+ color: def({ ...plain, id: "color", control: "color", value: "string", dynamicBindable: true, dynamicSourceTypes: ["color"], aiGenerate: true, doc: "Colour." }),
1447
+ select: def({ ...plain, id: "select", control: "select", value: "string", constraints: ["options"], dynamicBindable: false, dynamicSourceTypes: [], aiGenerate: true, doc: "Dropdown." }),
1448
+ radio: def({ ...plain, id: "radio", control: "segmented", value: "string", constraints: ["options"], dynamicBindable: false, dynamicSourceTypes: [], aiGenerate: true, doc: "Segmented choice." }),
1449
+ text_alignment: def({ ...plain, id: "text_alignment", control: "segmented", value: "string", dynamicBindable: false, dynamicSourceTypes: [], aiGenerate: true, doc: "Editor supplies the three choices." }),
1450
+ url: def({ ...plain, id: "url", control: "link-picker", value: "string", dynamicBindable: true, dynamicSourceTypes: ["url"], aiGenerate: true, doc: "A link." }),
1451
+ image: def({ ...plain, id: "image", control: "media-picker", value: "string", dynamicBindable: true, dynamicSourceTypes: ["file_reference", "image"], aiGenerate: true, media: "image", doc: "Media-library picker." }),
1452
+ video: def({ ...plain, id: "video", control: "media-picker", value: "string", dynamicBindable: true, dynamicSourceTypes: ["file_reference"], aiGenerate: true, media: "video", doc: "Hosted video; external URL \u2192 `url`." }),
1453
+ collection: resourceType("collection", "Collection handle.", ["collection_reference"]),
1454
+ product: resourceType("product", "Product handle.", ["product_reference"]),
1455
+ page: resourceType("page", "Page handle.", ["page_reference"]),
1456
+ blog: resourceType("blog", "Blog handle."),
1457
+ article: resourceType("article", "Article handle.", ["article_reference"]),
1458
+ menu: resourceType("menu", "Store menu handle."),
1459
+ json: def({ ...plain, id: "json", control: "json-editor", value: "object", constraints: ["schema"], dynamicBindable: false, dynamicSourceTypes: [], aiGenerate: true, doc: "Free-form structured value validated against `schema` when present." }),
1460
+ list: def({ ...plain, id: "list", control: "list", value: "array", constraints: ["items", "min", "max"], dynamicBindable: false, dynamicSourceTypes: [], aiGenerate: true, doc: "Ordered values of one element spec." })
1461
+ });
1462
+ var FIELD_TYPE_REQUIRED_CONSTRAINTS = nullProtoMap({
1463
+ select: Object.freeze(["options"]),
1464
+ radio: Object.freeze(["options"]),
1465
+ list: Object.freeze(["items"])
1466
+ });
1467
+ var FIELD_VALUE_SHAPES_V1 = nullProtoMap({
1468
+ text: { kind: "string" },
1469
+ textarea: { kind: "string" },
1470
+ richtext: { kind: "string", note: "sanitised HTML" },
1471
+ html: { kind: "string", note: "raw HTML" },
1472
+ number: { kind: "number" },
1473
+ range: { kind: "number" },
1474
+ boolean: { kind: "boolean" },
1475
+ color: { kind: "string", formats: ["#rrggbb", "#rrggbbaa"] },
1476
+ select: { kind: "string", oneOf: "options[].value" },
1477
+ radio: { kind: "string", oneOf: "options[].value" },
1478
+ text_alignment: { kind: "string", enum: ["left", "center", "right"] },
1479
+ url: { kind: "string", schemes: ["https:", "http:", "mailto:", "tel:"], siteRelative: true },
1480
+ image: { kind: "string", schemes: ["https:"], siteRelative: false },
1481
+ video: { kind: "string", schemes: ["https:"], siteRelative: false },
1482
+ collection: { kind: "string", note: "handle" },
1483
+ product: { kind: "string", note: "handle" },
1484
+ page: { kind: "string", note: "handle" },
1485
+ blog: { kind: "string", note: "handle" },
1486
+ article: { kind: "string", note: "`<blog>/<article>` handle" },
1487
+ menu: { kind: "string", note: "handle" },
1488
+ json: { kind: "object", note: "\u2264 16 KiB serialised" },
1489
+ list: { kind: "array", of: "items.value", note: "\u2264 64 entries; `items` depth \u2264 2" }
1490
+ });
1491
+ var REJECTED_FIELD_TYPE_ALIASES = nullProtoMap({
1492
+ image_picker: "image",
1493
+ link_list: "menu",
1494
+ checkbox: "boolean",
1495
+ color_background: "color"
1496
+ });
1497
+ var EDITOR_ONLY_FIELD_TYPES = Object.freeze([
1498
+ "inline_richtext",
1499
+ "color_scheme",
1500
+ "color_scheme_group",
1501
+ "font_picker",
1502
+ "product_list",
1503
+ "collection_list",
1504
+ "metaobject",
1505
+ "video_url",
1506
+ "header",
1507
+ "paragraph",
1508
+ "article_list",
1509
+ "metaobject_list"
1510
+ ]);
1511
+ var FIELD_VALUE_LIMITS = Object.freeze({
1512
+ /** `json` value, serialised. */
1513
+ jsonValueBytes: 16 * KIB,
1514
+ /** `json` `schema` constraint, serialised. */
1515
+ jsonSchemaBytes: 8 * KIB,
1516
+ /** `list` entries. */
1517
+ listMaxEntries: 64,
1518
+ /** `list` `items` nesting. */
1519
+ listItemsMaxDepth: 2
1520
+ });
1521
+ var TEXT_ALIGNMENTS = FIELD_VALUE_SHAPES_V1.text_alignment.enum;
1522
+ var FIELD_TYPES_V2 = FIELD_TYPES_V1;
1523
+ var FIELD_VALUE_SHAPES_V2 = nullProtoMap({
1524
+ ...Object.fromEntries(Object.entries(FIELD_VALUE_SHAPES_V1)),
1525
+ text_alignment: { kind: "string", enum: ["left", "center", "right", "start", "end"] },
1526
+ image: { ...FIELD_VALUE_SHAPES_V1.image, assetRef: true },
1527
+ video: { ...FIELD_VALUE_SHAPES_V1.video, assetRef: true }
1528
+ });
1529
+ var FIELD_TYPES_CHANGED_IN_V2 = Object.freeze(["text_alignment", "image", "video"]);
1530
+ var TEXT_ALIGNMENTS_V2 = FIELD_VALUE_SHAPES_V2.text_alignment.enum;
1531
+ var FIELD_TYPES_ADDED_IN_V3 = Object.freeze(["color_palette"]);
1532
+ var FIELD_TYPE_IDS_V3 = Object.freeze([...FIELD_TYPE_IDS_V1, ...FIELD_TYPES_ADDED_IN_V3]);
1533
+ var PALETTE_LIMITS = Object.freeze({ maxEntries: 20, nameMaxLength: 30 });
1534
+ var FIELD_TYPES_V3 = nullProtoMap({
1535
+ ...Object.fromEntries(Object.entries(FIELD_TYPES_V2)),
1536
+ color_palette: def({ ...plain, id: "color_palette", control: "color-palette", value: "array", constraints: ["max"], dynamicBindable: false, dynamicSourceTypes: [], aiGenerate: true, doc: "Named colours; colour settings pick from them." })
1537
+ });
1538
+ var FIELD_VALUE_SHAPES_V3 = nullProtoMap({
1539
+ ...Object.fromEntries(Object.entries(FIELD_VALUE_SHAPES_V2)),
1540
+ color_palette: { kind: "array", note: '\u2264 20 entries, each `{ "name", "color" }`: `name` 1\u201330 characters after trimming, unique ignoring case; `color` `#rrggbb`' }
1541
+ });
1542
+ var FIELD_TYPES_ADDED_IN_V4 = Object.freeze(["model"]);
1543
+ var FIELD_TYPE_IDS_V4 = Object.freeze([...FIELD_TYPE_IDS_V3, ...FIELD_TYPES_ADDED_IN_V4]);
1544
+ var FIELD_TYPES_V4 = nullProtoMap({
1545
+ ...Object.fromEntries(Object.entries(FIELD_TYPES_V3)),
1546
+ model: def({ ...plain, id: "model", control: "media-picker", value: "string", dynamicBindable: true, dynamicSourceTypes: ["file_reference"], aiGenerate: false, media: "model", doc: "A 3D model of the store's files (.glb); the platform viewer shows it." })
1547
+ });
1548
+ var FIELD_VALUE_SHAPES_V4 = nullProtoMap({
1549
+ ...Object.fromEntries(Object.entries(FIELD_VALUE_SHAPES_V3)),
1550
+ model: { kind: "string", schemes: ["https:"], siteRelative: false }
1551
+ });
1552
+ function nullProtoRecord(entries) {
1553
+ return Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), entries));
1554
+ }
1555
+ var FIELD_TYPES_BY_REGISTRY = nullProtoRecord({ "1": FIELD_TYPES_V1, "2": FIELD_TYPES_V2, "3": FIELD_TYPES_V3, "4": FIELD_TYPES_V4 });
1556
+ var FIELD_VALUE_SHAPES_BY_REGISTRY = nullProtoRecord({ "1": FIELD_VALUE_SHAPES_V1, "2": FIELD_VALUE_SHAPES_V2, "3": FIELD_VALUE_SHAPES_V3, "4": FIELD_VALUE_SHAPES_V4 });
1557
+ function isFieldTypeIdIn(value, registry) {
1558
+ return typeof value === "string" && Object.hasOwn(FIELD_TYPES_BY_REGISTRY[registry], value);
1559
+ }
1560
+ function safePathname(v) {
1561
+ try {
1562
+ return new URL(v.trim()).pathname;
1563
+ } catch {
1564
+ return "";
1565
+ }
1566
+ }
1567
+ var ASSET_REF_SCHEME = "asset:";
1568
+ var ASSET_REF_PREFIX = "asset:client/assets/";
1569
+ var ASSET_FILE_PATTERN = /^[A-Za-z0-9._-]+$/;
1570
+ function parseAssetRef(value) {
1571
+ if (!value.startsWith(ASSET_REF_PREFIX)) return null;
1572
+ const file = value.slice(ASSET_REF_PREFIX.length);
1573
+ if (!ASSET_FILE_PATTERN.test(file) || file.includes("..") || file === ".") return null;
1574
+ return { file, artifactPath: `client/assets/${file}` };
1575
+ }
1576
+ function rejectedAliasReplacement(type) {
1577
+ return Object.hasOwn(REJECTED_FIELD_TYPE_ALIASES, type) ? REJECTED_FIELD_TYPE_ALIASES[type] : void 0;
1578
+ }
1579
+ var MAX_JSON_DEPTH = 256;
1580
+ function findNonJsonValue(v) {
1581
+ try {
1582
+ return walk(v, "", /* @__PURE__ */ new Set(), 0);
1583
+ } catch (e) {
1584
+ return { path: "", reason: `value could not be inspected (${e instanceof Error ? e.name : "error"})` };
1585
+ }
1586
+ }
1587
+ function escapeSeg(s) {
1588
+ return s.replace(/~/g, "~0").replace(/\//g, "~1");
1589
+ }
1590
+ function walk(v, path, ancestors, depth) {
1591
+ if (v === null) return null;
1592
+ switch (typeof v) {
1593
+ case "string":
1594
+ case "boolean":
1595
+ return null;
1596
+ case "number":
1597
+ return Number.isFinite(v) ? null : { path, reason: `non-finite number ${String(v)}` };
1598
+ case "undefined":
1599
+ case "bigint":
1600
+ case "symbol":
1601
+ case "function":
1602
+ return { path, reason: typeof v };
1603
+ }
1604
+ const obj = v;
1605
+ if (depth >= MAX_JSON_DEPTH) return { path, reason: `nesting deeper than ${MAX_JSON_DEPTH}` };
1606
+ if (ancestors.has(obj)) return { path, reason: "cycle" };
1607
+ if (Object.getOwnPropertySymbols(obj).length > 0) return { path, reason: "symbol-keyed property" };
1608
+ ancestors.add(obj);
1609
+ try {
1610
+ if (Array.isArray(obj)) {
1611
+ if (Object.getPrototypeOf(obj) !== Array.prototype) return { path, reason: "array subclass" };
1612
+ for (let i = 0; i < obj.length; i++) {
1613
+ const d = Object.getOwnPropertyDescriptor(obj, i);
1614
+ if (!d) return { path: `${path}/${i}`, reason: "sparse array hole" };
1615
+ if (!("value" in d)) return { path: `${path}/${i}`, reason: "accessor property" };
1616
+ const r = walk(d.value, `${path}/${i}`, ancestors, depth + 1);
1617
+ if (r) return r;
1618
+ }
1619
+ return null;
1620
+ }
1621
+ const proto = Object.getPrototypeOf(obj);
1622
+ if (proto !== Object.prototype && proto !== null) {
1623
+ const name = proto.constructor?.name;
1624
+ return { path, reason: `non-plain object${typeof name === "string" && name ? ` (${name})` : ""}` };
1625
+ }
1626
+ for (const key of Object.getOwnPropertyNames(obj)) {
1627
+ const d = Object.getOwnPropertyDescriptor(obj, key);
1628
+ const p = `${path}/${escapeSeg(key)}`;
1629
+ if (!d.enumerable) return { path: p, reason: "non-enumerable property" };
1630
+ if (!("value" in d)) return { path: p, reason: "accessor property" };
1631
+ const r = walk(d.value, p, ancestors, depth + 1);
1632
+ if (r) return r;
1633
+ }
1634
+ return null;
1635
+ } finally {
1636
+ ancestors.delete(obj);
1637
+ }
1638
+ }
1639
+ var SCHEME_RE = /^([A-Za-z][A-Za-z0-9+.-]*):/;
1640
+ function isAllowedUrl(value, shape) {
1641
+ const v = value.trim();
1642
+ if (v.length === 0) return false;
1643
+ if (v.startsWith("/")) {
1644
+ if (!shape.siteRelative) return false;
1645
+ const second = v.slice(1).replace(/[\t\n\r]/g, "").charAt(0);
1646
+ return second !== "/" && second !== "\\";
1647
+ }
1648
+ let url;
1649
+ try {
1650
+ url = new URL(v);
1651
+ } catch {
1652
+ return false;
1653
+ }
1654
+ const allowed = shape.schemes ?? [];
1655
+ const literal = SCHEME_RE.exec(v.replace(/[\t\n\r]/g, ""))?.[1]?.toLowerCase();
1656
+ return allowed.includes(url.protocol) && literal !== void 0 && allowed.includes(`${literal}:`);
1657
+ }
1658
+ var HEX_FORMAT = nullProtoMap({
1659
+ "#rrggbb": /^#[0-9a-fA-F]{6}$/,
1660
+ "#rrggbbaa": /^#[0-9a-fA-F]{8}$/
1661
+ });
1662
+ var HANDLE_RE = /^\S+$/;
1663
+ var encoder = new TextEncoder();
1664
+ var jsonSchemaCache = /* @__PURE__ */ new WeakMap();
1665
+ function jsonKind(v) {
1666
+ if (v === null) return "null";
1667
+ if (Array.isArray(v)) return "array";
1668
+ return typeof v;
1669
+ }
1670
+ function jsonSchemaValidator(schema) {
1671
+ let fn = jsonSchemaCache.get(schema);
1672
+ if (!fn) {
1673
+ fn = new import__.Ajv2020({ allErrors: true, strict: false }).compile(schema);
1674
+ jsonSchemaCache.set(schema, fn);
1675
+ }
1676
+ return fn;
1677
+ }
1678
+ function check(type, value, spec, path, out, ctx) {
1679
+ const push = (code, message, params) => out.push(params ? { path, code, message, params } : { path, code, message });
1680
+ if (!isFieldTypeIdIn(type, ctx.registry)) {
1681
+ const replacement = rejectedAliasReplacement(type);
1682
+ if (replacement) push("rejected_field_type_alias", `field type "${type}" is not supported; use "${replacement}"`, { type, replacement });
1683
+ else push("unknown_field_type", `field type "${type}" is not in tanqory-field-types@${ctx.registry}`, { type });
1684
+ return;
1685
+ }
1686
+ const shape = FIELD_VALUE_SHAPES_BY_REGISTRY[ctx.registry][type];
1687
+ const kind = jsonKind(value);
1688
+ if (kind !== shape.kind) {
1689
+ push("value_type_mismatch", `"${type}" stores a ${shape.kind}; got ${kind}`, { expected: shape.kind, actual: kind });
1690
+ return;
1691
+ }
1692
+ switch (type) {
1693
+ case "color": {
1694
+ const formats = shape.formats ?? [];
1695
+ if (!formats.some((f) => HEX_FORMAT[f]?.test(value))) push("value_invalid_color", `"${String(value)}" is not ${formats.join(" or ")}`, { formats });
1696
+ return;
1697
+ }
1698
+ case "text_alignment":
1699
+ if (!(shape.enum ?? []).includes(value)) push("value_invalid_alignment", `"${String(value)}" must be one of ${(shape.enum ?? []).join(", ")}`, { allowed: shape.enum });
1700
+ return;
1701
+ case "select":
1702
+ case "radio": {
1703
+ if (!spec?.options) {
1704
+ push("spec_missing_constraint", `"${type}" requires \`options\` to validate a value`, { constraint: "options" });
1705
+ return;
1706
+ }
1707
+ const allowed = spec.options.map((o) => o.value);
1708
+ if (!allowed.includes(value)) push("value_not_in_options", `"${String(value)}" is not one of the declared options`, { allowed });
1709
+ return;
1710
+ }
1711
+ case "model":
1712
+ if (!isAllowedUrl(value, shape)) {
1713
+ push("value_invalid_url", `"${String(value)}" violates the model URL rule (allowed: https:)`, { schemes: shape.schemes, siteRelative: false });
1714
+ } else if (!/\.glb$/i.test(safePathname(value))) {
1715
+ push("value_not_a_model", `"${String(value)}" is not a .glb model file`);
1716
+ }
1717
+ return;
1718
+ case "url":
1719
+ case "image":
1720
+ case "video":
1721
+ if (shape.assetRef && value.startsWith(ASSET_REF_SCHEME)) {
1722
+ if (ctx.origin !== "theme") {
1723
+ push("value_asset_ref_not_allowed", `"${String(value)}": asset: references are valid only in theme defaults and presets, not in merchant content`);
1724
+ return;
1725
+ }
1726
+ const ref = parseAssetRef(value);
1727
+ if (!ref) {
1728
+ push("value_invalid_asset_ref", `"${String(value)}" is not asset:client/assets/<file> with <file> matching [A-Za-z0-9._-]+ (no "/", no "..")`);
1729
+ } else if (ctx.files && !ctx.files.has(ref.artifactPath)) {
1730
+ push("asset_not_in_artifact", `"${ref.artifactPath}" is not listed in the artifact files`, { artifactPath: ref.artifactPath });
1731
+ }
1732
+ return;
1733
+ }
1734
+ if (!isAllowedUrl(value, shape)) {
1735
+ push("value_invalid_url", `"${String(value)}" violates the ${type} URL rule (allowed: ${[...shape.schemes ?? [], ...shape.siteRelative ? ["site-relative /path"] : []].join(", ")})`, { schemes: shape.schemes, siteRelative: shape.siteRelative });
1736
+ }
1737
+ return;
1738
+ case "collection":
1739
+ case "product":
1740
+ case "page":
1741
+ case "blog":
1742
+ case "menu":
1743
+ if (!HANDLE_RE.test(value)) push("value_invalid_handle", `"${String(value)}" is not a ${type} handle`);
1744
+ return;
1745
+ case "article": {
1746
+ const parts = value.split("/");
1747
+ if (parts.length !== 2 || !parts.every((p) => HANDLE_RE.test(p))) push("value_invalid_handle", `"${String(value)}" is not a <blog>/<article> handle`);
1748
+ return;
1749
+ }
1750
+ case "number":
1751
+ case "range": {
1752
+ const n = value;
1753
+ if (spec?.min !== void 0 && n < spec.min || spec?.max !== void 0 && n > spec.max) {
1754
+ push("value_out_of_range", `${n} is outside [${spec?.min ?? "-\u221E"}, ${spec?.max ?? "\u221E"}]`, { min: spec?.min, max: spec?.max });
1755
+ }
1756
+ return;
1757
+ }
1758
+ case "json": {
1759
+ const bytes = encoder.encode(JSON.stringify(value)).byteLength;
1760
+ if (bytes > FIELD_VALUE_LIMITS.jsonValueBytes) {
1761
+ push("value_too_large", `json value is ${bytes} bytes serialised; maximum is ${FIELD_VALUE_LIMITS.jsonValueBytes}`, { bytes, max: FIELD_VALUE_LIMITS.jsonValueBytes });
1762
+ return;
1763
+ }
1764
+ if (spec?.schema) {
1765
+ const validate = jsonSchemaValidator(spec.schema);
1766
+ if (!validate(value)) {
1767
+ for (const e of validate.errors ?? []) out.push({ path: path + e.instancePath, code: "json_schema_mismatch", message: e.message ?? e.keyword, params: { keyword: e.keyword } });
1768
+ }
1769
+ }
1770
+ return;
1771
+ }
1772
+ case "color_palette": {
1773
+ const arr = value;
1774
+ const max = Math.min(spec?.max ?? PALETTE_LIMITS.maxEntries, PALETTE_LIMITS.maxEntries);
1775
+ if (arr.length > max) push("list_length_out_of_range", `palette has ${arr.length} colours; at most ${max}`, { length: arr.length, min: 0, max });
1776
+ const seen = /* @__PURE__ */ new Set();
1777
+ arr.forEach((el, i) => {
1778
+ const at = `${path}/${i}`;
1779
+ const bad = (message) => {
1780
+ out.push({ path: at, code: "value_invalid_palette_entry", message });
1781
+ };
1782
+ if (el === null || typeof el !== "object" || Array.isArray(el)) return bad('a palette colour is an object { "name", "color" }');
1783
+ const keys = Object.keys(el);
1784
+ const extra = keys.filter((k) => k !== "name" && k !== "color");
1785
+ if (extra.length) return bad(`a palette colour holds only "name" and "color" (found ${extra.map((k) => `"${k}"`).join(", ")})`);
1786
+ const { name, color } = el;
1787
+ const trimmed = typeof name === "string" ? name.trim() : "";
1788
+ if (typeof name !== "string" || trimmed.length === 0 || [...trimmed].length > PALETTE_LIMITS.nameMaxLength) {
1789
+ return bad(`"name" must be 1 to ${PALETTE_LIMITS.nameMaxLength} characters`);
1790
+ }
1791
+ if (seen.has(trimmed.toLowerCase())) return bad(`"${trimmed}" is already a colour in this palette`);
1792
+ seen.add(trimmed.toLowerCase());
1793
+ if (typeof color !== "string" || !HEX_FORMAT["#rrggbb"].test(color)) {
1794
+ out.push({ path: `${at}/color`, code: "value_invalid_color", message: `"${String(color)}" is not #rrggbb`, params: { formats: ["#rrggbb"] } });
1795
+ }
1796
+ });
1797
+ return;
1798
+ }
1799
+ case "list": {
1800
+ const arr = value;
1801
+ const max = Math.min(spec?.max ?? FIELD_VALUE_LIMITS.listMaxEntries, FIELD_VALUE_LIMITS.listMaxEntries);
1802
+ const min = spec?.min ?? 0;
1803
+ if (arr.length < min || arr.length > max) push("list_length_out_of_range", `list has ${arr.length} entries; allowed [${min}, ${max}]`, { length: arr.length, min, max });
1804
+ if (!spec?.items) {
1805
+ push("spec_missing_constraint", '"list" requires `items` to validate its entries', { constraint: "items" });
1806
+ return;
1807
+ }
1808
+ const items = spec.items;
1809
+ arr.forEach((el, i) => check(items.type, el, items, `${path}/${i}`, out, ctx));
1810
+ return;
1811
+ }
1812
+ default:
1813
+ return;
1814
+ }
1815
+ }
1816
+ function validateFieldValue(type, value, spec, options = {}) {
1817
+ const registry = options.registry ?? FIELD_TYPES_REGISTRY_VERSION;
1818
+ if (!isFieldRegistryVersion(registry)) {
1819
+ return { ok: false, errors: [{ path: "", code: "unsupported_field_registry", message: `tanqory-field-types@${String(registry)} is not supported (supported: ${FIELD_REGISTRY_VERSIONS.join(", ")})`, params: { registry, supported: FIELD_REGISTRY_VERSIONS } }] };
1820
+ }
1821
+ let files = null;
1822
+ try {
1823
+ files = options.artifactFiles ? new Set(options.artifactFiles) : null;
1824
+ } catch {
1825
+ files = /* @__PURE__ */ new Set();
1826
+ }
1827
+ const ctx = { registry, origin: options.origin ?? "content", files };
1828
+ const nonJson = findNonJsonValue(value);
1829
+ if (nonJson) {
1830
+ return { ok: false, errors: [{ path: nonJson.path, code: "not_json_value", message: `value is not a JSON value: ${nonJson.reason}`, params: { reason: nonJson.reason } }] };
1831
+ }
1832
+ const errors = [];
1833
+ try {
1834
+ check(type, value, spec, "", errors, ctx);
1835
+ } catch (e) {
1836
+ errors.push({ path: "", code: "json_schema_mismatch", message: `schema could not be applied (${e instanceof Error ? e.message : "error"})` });
1837
+ }
1838
+ return errors.length === 0 ? { ok: true } : { ok: false, errors };
1839
+ }
1840
+
1841
+ // ../theme-abi/src/manifest/validate.ts
1842
+ var import__2 = require("ajv/dist/2020.js");
1843
+
1844
+ // ../theme-abi/src/schema/theme-manifest.v2.schema.generated.ts
1845
+ var THEME_MANIFEST_V2_SCHEMA = {
1846
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1847
+ "$id": "https://schemas.tanqory.com/theme-abi/v2/theme-manifest.schema.json",
1848
+ "title": "ThemeManifest v2",
1849
+ "description": "Static description of a theme for the platform (routing, regions, components, settings, capabilities). Produced by the builder into manifest.json and exported verbatim as `manifest` from server/entry.mjs. Keys starting with `x-` are vendor namespaces the platform ignores and never validates (Nova uses `x-nova`).",
1850
+ "type": "object",
1851
+ "required": [
1852
+ "abi",
1853
+ "name",
1854
+ "version",
1855
+ "engines",
1856
+ "capabilities",
1857
+ "client",
1858
+ "contentVersion",
1859
+ "routes",
1860
+ "templates",
1861
+ "regions",
1862
+ "components",
1863
+ "settingsSchema"
1864
+ ],
1865
+ "additionalProperties": false,
1866
+ "patternProperties": {
1867
+ "^x-[a-z0-9][a-z0-9-]*$": {
1868
+ "description": "Vendor namespace. Ignored by the platform. Counted toward manifest size."
1869
+ }
1870
+ },
1871
+ "properties": {
1872
+ "abi": {
1873
+ "type": "string",
1874
+ "pattern": "^2\\.[0-9]+$",
1875
+ "description": "ABI the theme was built against (major.minor)."
1876
+ },
1877
+ "name": {
1878
+ "type": "string",
1879
+ "pattern": "^(@[a-z0-9][a-z0-9-]*/)?[a-z0-9][a-z0-9._-]*$",
1880
+ "maxLength": 128
1881
+ },
1882
+ "version": {
1883
+ "type": "string",
1884
+ "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9A-Za-z.-]+)?(\\+[0-9A-Za-z.-]+)?$",
1885
+ "description": "Theme semver (marketplace version)."
1886
+ },
1887
+ "engines": {
1888
+ "type": "object",
1889
+ "required": [
1890
+ "tanqory-abi",
1891
+ "tanqory-field-types"
1892
+ ],
1893
+ "additionalProperties": false,
1894
+ "properties": {
1895
+ "tanqory-abi": {
1896
+ "type": "string",
1897
+ "description": 'Semver range of hosts this theme accepts, e.g. "^2.0".'
1898
+ },
1899
+ "tanqory-field-types": {
1900
+ "type": "string",
1901
+ "pattern": "^[0-9]+$",
1902
+ "description": "Field-type registry version every `type` below is validated against."
1903
+ },
1904
+ "tanqory-editor-profile": {
1905
+ "type": "string",
1906
+ "pattern": "^[0-9]+$",
1907
+ "description": "Editor-profile protocol version (theme-abi-v2 \xA72.2.2); required with client.editorProfile. A builder that does not implement it refuses the theme (editor_profile_unsupported)."
1908
+ },
1909
+ "tanqory-client-chunks": {
1910
+ "type": "string",
1911
+ "pattern": "^[0-9]+$",
1912
+ "description": "Client-chunks protocol version (theme-abi-v2 \xA72.2.1); required with client.chunks. A builder that does not implement it refuses the theme (client_chunks_unsupported)."
1913
+ }
1914
+ }
1915
+ },
1916
+ "capabilities": {
1917
+ "type": "object",
1918
+ "required": [
1919
+ "server",
1920
+ "browser"
1921
+ ],
1922
+ "additionalProperties": false,
1923
+ "description": "Security B-6: both arrays required and explicit; browser \u2286 server. The builder copies both verbatim into the signed statement; the runtime uses the statement's copy, never this file.",
1924
+ "properties": {
1925
+ "server": {
1926
+ "type": "array",
1927
+ "uniqueItems": true,
1928
+ "maxItems": 32,
1929
+ "items": {
1930
+ "$ref": "#/$defs/capability"
1931
+ },
1932
+ "description": "What render() may use. `ctx.data`/`ctx.actions` outside this set throw CapabilityError. `network:<origin>` is the ONLY egress form (proxied fetch to that origin, counted as a sub-request, store/marketplace-approved)."
1933
+ },
1934
+ "browser": {
1935
+ "type": "array",
1936
+ "uniqueItems": true,
1937
+ "maxItems": 16,
1938
+ "items": {
1939
+ "type": "string",
1940
+ "pattern": "^(data:(shop|localization|catalog|content|search|cart|products\\.recommendations|inventory)|actions:(cart|consent))$"
1941
+ },
1942
+ "description": "What hydrated theme JS may call via /_tq/data/* and /_tq/actions/*. Ceiling per capability-security-v1.md \xA72.6 / B-6 / A10: data:customer, data:metaobjects, actions:customer, actions:form.submit are NEVER browser-mintable (the pattern excludes them, so validation fails on them); data:products.recommendations and data:inventory ARE allowed. Must be \u2286 server (checked by `theme check`, not expressible here). `tanqory theme init` scaffolds {data:shop, data:localization, data:catalog, data:content, data:search, data:cart, actions:cart, actions:consent}; an empty array is valid for zero-JS themes."
1943
+ }
1944
+ }
1945
+ },
1946
+ "forms": {
1947
+ "type": "object",
1948
+ "maxProperties": 16,
1949
+ "propertyNames": {
1950
+ "pattern": "^[a-z][a-z0-9-]*$"
1951
+ },
1952
+ "additionalProperties": {
1953
+ "type": "object",
1954
+ "required": [
1955
+ "fields"
1956
+ ],
1957
+ "additionalProperties": false,
1958
+ "properties": {
1959
+ "title": {
1960
+ "type": "string",
1961
+ "maxLength": 64
1962
+ },
1963
+ "fields": {
1964
+ "type": "array",
1965
+ "minItems": 1,
1966
+ "maxItems": 32,
1967
+ "uniqueItems": true,
1968
+ "items": {
1969
+ "type": "string",
1970
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$"
1971
+ }
1972
+ }
1973
+ }
1974
+ },
1975
+ "description": 'Forms submittable through actions:form.submit (server-side POST only). Native HTML: the theme writes only `<form data-tq-form="<id>" method="post">`; the form posts to the same path it was rendered on (no `action`, or `action` = that path); the gateway injects both hidden fields `_tq_form` and `_tq_csrf` after its cache (theme must not render them), strips both on POST, accepts application/x-www-form-urlencoded only, caps the body at 8 KiB (8192 bytes) before the isolate, filters to `fields`, and exposes ctx.request.form (owner approval 2026-10-07). Field names are an allowlist and must not start with `_tq_`; destination is the merchant inbox, never a theme URL.'
1976
+ },
1977
+ "client": {
1978
+ "type": "object",
1979
+ "required": [
1980
+ "hydration"
1981
+ ],
1982
+ "additionalProperties": false,
1983
+ "properties": {
1984
+ "hydration": {
1985
+ "enum": [
1986
+ "none",
1987
+ "full",
1988
+ "partial"
1989
+ ],
1990
+ "description": "none = zero-JS/HTMX theme: client-manifest has no isEntry script and the hydration-parity suite is skipped (per-content-type assertions still run)."
1991
+ },
1992
+ "editorProfile": {
1993
+ "type": "boolean",
1994
+ "description": 'Editor-only metadata out of the shopper bundle (theme-abi-v2 \xA72.2.2): the server resolves settings into the page state; src/client/preview-entry is the preview profile, served on preview hosts only. Needs engines["tanqory-editor-profile"].'
1995
+ },
1996
+ "editorOnly": {
1997
+ "type": "array",
1998
+ "maxItems": 32,
1999
+ "items": {
2000
+ "type": "string",
2001
+ "minLength": 1,
2002
+ "maxLength": 200
2003
+ },
2004
+ "description": "Globs of theme modules the shopper bundle (src/client/entry) must not contain; the build refuses one that does (theme-abi-v2 \xA72.2.2)."
2005
+ },
2006
+ "chunks": {
2007
+ "enum": [
2008
+ "sections"
2009
+ ],
2010
+ "description": 'Opt-in client chunks (theme-abi-v2 \xA72.2.1): each relative import() in client code becomes a chunk loaded through the platform gate (modulepreload with integrity, awaited). Needs engines["tanqory-client-chunks"]. Absent: one client bundle, import() refused.'
2011
+ }
2012
+ }
2013
+ },
2014
+ "contentVersion": {
2015
+ "type": "integer",
2016
+ "minimum": 1,
2017
+ "description": "Version of the content-document shape this theme reads. Docs at a lower version are migrated by the platform via declared `migrations` before render."
2018
+ },
2019
+ "minContentVersion": {
2020
+ "type": "integer",
2021
+ "minimum": 1,
2022
+ "description": "Oldest version this artifact's migrate() accepts. Absent \u21D2 equals contentVersion (no chain required); > contentVersion is `migration_range_invalid` (validateManifest semantic check). Docs older than this are first brought up by the previously installed artifact's chain (platform-chained migration)."
2023
+ },
2024
+ "migrations": {
2025
+ "type": "array",
2026
+ "items": {
2027
+ "type": "object",
2028
+ "required": [
2029
+ "from",
2030
+ "to"
2031
+ ],
2032
+ "additionalProperties": false,
2033
+ "properties": {
2034
+ "from": {
2035
+ "type": "integer",
2036
+ "minimum": 1
2037
+ },
2038
+ "to": {
2039
+ "type": "integer",
2040
+ "minimum": 2
2041
+ },
2042
+ "note": {
2043
+ "type": "string",
2044
+ "maxLength": 512
2045
+ }
2046
+ }
2047
+ },
2048
+ "description": "Each step must be implemented by the entry's `migrate(doc, from, to)`. Steps must chain gap-free from `minContentVersion` (default: 1) to `contentVersion`. Docs below `minContentVersion` are migrated by the platform through the previously installed artifact's chain first (S5)."
2049
+ },
2050
+ "routes": {
2051
+ "type": "object",
2052
+ "description": "Default template per platform route kind. `home` and `not_found` are required. A missing kind means the platform serves its own minimal page for that kind.",
2053
+ "required": [
2054
+ "home",
2055
+ "not_found"
2056
+ ],
2057
+ "properties": {
2058
+ "home": {
2059
+ "type": "string",
2060
+ "description": "Template name (key of `templates`)."
2061
+ },
2062
+ "not_found": {
2063
+ "type": "string",
2064
+ "description": "Template name (key of `templates`)."
2065
+ }
2066
+ },
2067
+ "propertyNames": {
2068
+ "pattern": "^(home|product|collection|collections|page|blog|article|search|cart|customer|policy|metaobject|not_found|custom:[a-z][a-z0-9-]*)$"
2069
+ },
2070
+ "additionalProperties": {
2071
+ "type": "string",
2072
+ "description": "Template name (key of `templates`)."
2073
+ }
2074
+ },
2075
+ "customRoutes": {
2076
+ "type": "object",
2077
+ "maxProperties": 16,
2078
+ "propertyNames": {
2079
+ "pattern": "^[a-z][a-z0-9-]*$"
2080
+ },
2081
+ "additionalProperties": {
2082
+ "type": "object",
2083
+ "required": [
2084
+ "path"
2085
+ ],
2086
+ "additionalProperties": false,
2087
+ "properties": {
2088
+ "path": {
2089
+ "type": "string",
2090
+ "pattern": "^/[A-Za-z0-9._~/-]*(:[a-z][A-Za-z0-9]*(/[A-Za-z0-9._~/-]*)?)*$",
2091
+ "description": 'URL pattern with `:param` captures, e.g. "/lookbook/:season". Must not start with /collections, /products, /pages, /blogs, /policies, /cart, /search, /account (the built-in `customer` kind), /checkout, /orders, /api, /_tq (the reserved platform prefix is `/_tq/`).'
2092
+ }
2093
+ }
2094
+ },
2095
+ "description": "Theme-defined route kinds. Route kind is `custom:<key>`; captures appear in ctx.route.params."
2096
+ },
2097
+ "templates": {
2098
+ "type": "object",
2099
+ "minProperties": 2,
2100
+ "maxProperties": 128,
2101
+ "propertyNames": {
2102
+ "pattern": "^[a-z0-9][a-z0-9.-]*$"
2103
+ },
2104
+ "additionalProperties": {
2105
+ "type": "object",
2106
+ "required": [
2107
+ "route",
2108
+ "regions"
2109
+ ],
2110
+ "additionalProperties": false,
2111
+ "properties": {
2112
+ "route": {
2113
+ "type": "string",
2114
+ "pattern": "^(home|product|collection|collections|page|blog|article|search|cart|customer|policy|metaobject|not_found|custom:[a-z][a-z0-9-]*)$"
2115
+ },
2116
+ "title": {
2117
+ "type": "string",
2118
+ "maxLength": 128
2119
+ },
2120
+ "regions": {
2121
+ "type": "array",
2122
+ "minItems": 1,
2123
+ "maxItems": 16,
2124
+ "uniqueItems": true,
2125
+ "items": {
2126
+ "type": "string"
2127
+ },
2128
+ "description": "Ordered region ids this template renders (keys of `regions`)."
2129
+ }
2130
+ }
2131
+ },
2132
+ "description": "Template name \u2192 route kind. A resource's templateSuffix selects `<route>.<suffix>` when it exists, else `routes[kind]`."
2133
+ },
2134
+ "regions": {
2135
+ "type": "object",
2136
+ "minProperties": 1,
2137
+ "maxProperties": 32,
2138
+ "propertyNames": {
2139
+ "pattern": "^[a-z][a-z0-9-]*$"
2140
+ },
2141
+ "additionalProperties": {
2142
+ "type": "object",
2143
+ "required": [
2144
+ "title",
2145
+ "scope"
2146
+ ],
2147
+ "additionalProperties": false,
2148
+ "properties": {
2149
+ "title": {
2150
+ "type": "string",
2151
+ "maxLength": 64
2152
+ },
2153
+ "scope": {
2154
+ "enum": [
2155
+ "shared",
2156
+ "template"
2157
+ ],
2158
+ "description": "`shared`: one doc per region for the whole store (header/footer pattern), editable in place from any template; `template`: one doc per template."
2159
+ },
2160
+ "accepts": {
2161
+ "type": "array",
2162
+ "uniqueItems": true,
2163
+ "items": {
2164
+ "type": "string"
2165
+ },
2166
+ "description": "Component ids (role section|layout) allowed here. Absent = every section whose `regions` lists this id."
2167
+ },
2168
+ "min": {
2169
+ "type": "integer",
2170
+ "minimum": 0
2171
+ },
2172
+ "max": {
2173
+ "type": "integer",
2174
+ "minimum": 1,
2175
+ "maximum": 64
2176
+ }
2177
+ }
2178
+ },
2179
+ "description": "Theme-declared regions. The platform imposes none; today's header/template/footer is just one possible declaration."
2180
+ },
2181
+ "components": {
2182
+ "type": "object",
2183
+ "minProperties": 1,
2184
+ "maxProperties": 256,
2185
+ "propertyNames": {
2186
+ "pattern": "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)?$"
2187
+ },
2188
+ "additionalProperties": {
2189
+ "$ref": "#/$defs/component"
2190
+ }
2191
+ },
2192
+ "settingsSchema": {
2193
+ "type": "array",
2194
+ "maxItems": 32,
2195
+ "items": {
2196
+ "type": "object",
2197
+ "required": [
2198
+ "group",
2199
+ "items"
2200
+ ],
2201
+ "additionalProperties": false,
2202
+ "properties": {
2203
+ "group": {
2204
+ "type": "string",
2205
+ "maxLength": 64
2206
+ },
2207
+ "items": {
2208
+ "type": "array",
2209
+ "maxItems": 64,
2210
+ "items": {
2211
+ "allOf": [
2212
+ {
2213
+ "$ref": "#/$defs/field"
2214
+ },
2215
+ {
2216
+ "type": "object",
2217
+ "required": [
2218
+ "key"
2219
+ ],
2220
+ "properties": {
2221
+ "key": {
2222
+ "type": "string",
2223
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$"
2224
+ }
2225
+ }
2226
+ }
2227
+ ]
2228
+ }
2229
+ }
2230
+ }
2231
+ }
2232
+ }
2233
+ },
2234
+ "$defs": {
2235
+ "capability": {
2236
+ "type": "string",
2237
+ "pattern": "^(data:(shop|localization|catalog|content|search|cart|customer|metaobjects|products\\.recommendations|inventory)|actions:(cart|consent|customer|form\\.submit)|preview:renderSection|network:https://.+)$",
2238
+ "description": "Normative set = `Capability` in render-context.v2.d.ts (`network:https://${string}` \u2014 origin well-formedness is a validateManifest() semantic check). Security (capability-security-v1.md \xA72) cites this type."
2239
+ },
2240
+ "field": {
2241
+ "type": "object",
2242
+ "required": [
2243
+ "type"
2244
+ ],
2245
+ "additionalProperties": false,
2246
+ "properties": {
2247
+ "key": {
2248
+ "type": "string"
2249
+ },
2250
+ "type": {
2251
+ "type": "string",
2252
+ "pattern": "^[a-z][a-z0-9_]*$",
2253
+ "description": 'Id in the field-type registry version named by engines["tanqory-field-types"]. Unknown ids fail `theme check`.'
2254
+ },
2255
+ "label": {
2256
+ "type": "string",
2257
+ "maxLength": 128
2258
+ },
2259
+ "info": {
2260
+ "type": "string",
2261
+ "maxLength": 512
2262
+ },
2263
+ "default": {},
2264
+ "placeholder": {
2265
+ "type": "string",
2266
+ "maxLength": 128
2267
+ },
2268
+ "group": {
2269
+ "type": "string",
2270
+ "maxLength": 64
2271
+ },
2272
+ "min": {
2273
+ "type": "number"
2274
+ },
2275
+ "max": {
2276
+ "type": "number"
2277
+ },
2278
+ "step": {
2279
+ "type": "number",
2280
+ "exclusiveMinimum": 0
2281
+ },
2282
+ "unit": {
2283
+ "type": "string",
2284
+ "maxLength": 8
2285
+ },
2286
+ "options": {
2287
+ "type": "array",
2288
+ "maxItems": 64,
2289
+ "items": {
2290
+ "type": "object",
2291
+ "required": [
2292
+ "value",
2293
+ "label"
2294
+ ],
2295
+ "additionalProperties": false,
2296
+ "properties": {
2297
+ "value": {
2298
+ "type": "string"
2299
+ },
2300
+ "label": {
2301
+ "type": "string"
2302
+ }
2303
+ }
2304
+ }
2305
+ },
2306
+ "visible_if": {
2307
+ "oneOf": [
2308
+ {
2309
+ "type": "string",
2310
+ "maxLength": 256
2311
+ },
2312
+ {
2313
+ "type": "object"
2314
+ }
2315
+ ]
2316
+ },
2317
+ "dynamic": {
2318
+ "type": "boolean"
2319
+ },
2320
+ "resolve": {
2321
+ "type": "boolean",
2322
+ "description": "Resource-typed fields only: platform resolves the referenced resource into snapshot.refs."
2323
+ },
2324
+ "items": {
2325
+ "$ref": "#/$defs/field",
2326
+ "description": "`list` type only: the element field spec (depth \u2264 2)."
2327
+ },
2328
+ "schema": {
2329
+ "type": "object",
2330
+ "description": "`json` type only: optional JSON Schema (draft 2020-12, \u2264 8 KB serialised) the editor validates the value against."
2331
+ }
2332
+ }
2333
+ },
2334
+ "contentNode": {
2335
+ "type": "object",
2336
+ "required": [
2337
+ "type",
2338
+ "id"
2339
+ ],
2340
+ "additionalProperties": false,
2341
+ "properties": {
2342
+ "type": {
2343
+ "type": "string"
2344
+ },
2345
+ "id": {
2346
+ "type": "string",
2347
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$",
2348
+ "maxLength": 64
2349
+ },
2350
+ "settings": {
2351
+ "type": "object"
2352
+ },
2353
+ "blocks": {
2354
+ "type": "array",
2355
+ "maxItems": 64,
2356
+ "items": {
2357
+ "$ref": "#/$defs/contentNode"
2358
+ }
2359
+ },
2360
+ "disabled": {
2361
+ "type": "boolean"
2362
+ }
2363
+ }
2364
+ },
2365
+ "component": {
2366
+ "type": "object",
2367
+ "required": [
2368
+ "role",
2369
+ "title",
2370
+ "attributes"
2371
+ ],
2372
+ "additionalProperties": false,
2373
+ "properties": {
2374
+ "role": {
2375
+ "enum": [
2376
+ "section",
2377
+ "block",
2378
+ "layout"
2379
+ ],
2380
+ "description": "section: merchant-placed in a region \xB7 block: nested in a section \xB7 layout: a region-level unit (e.g. header bar) the theme pins."
2381
+ },
2382
+ "title": {
2383
+ "type": "string",
2384
+ "maxLength": 128
2385
+ },
2386
+ "description": {
2387
+ "type": "string",
2388
+ "maxLength": 512
2389
+ },
2390
+ "category": {
2391
+ "type": "string",
2392
+ "maxLength": 64
2393
+ },
2394
+ "icon": {
2395
+ "type": "string",
2396
+ "maxLength": 64
2397
+ },
2398
+ "regions": {
2399
+ "type": "array",
2400
+ "uniqueItems": true,
2401
+ "items": {
2402
+ "type": "string"
2403
+ },
2404
+ "description": "Sections/layout: regions that accept this component."
2405
+ },
2406
+ "parents": {
2407
+ "type": "array",
2408
+ "uniqueItems": true,
2409
+ "items": {
2410
+ "type": "string"
2411
+ },
2412
+ "description": "Blocks: component ids that may contain this block."
2413
+ },
2414
+ "children": {
2415
+ "type": "array",
2416
+ "uniqueItems": true,
2417
+ "maxItems": 64,
2418
+ "items": {
2419
+ "type": "string"
2420
+ },
2421
+ "description": 'Sections and blocks: block ids accepted, plus the reserved entry "@app" for blocks of installed apps (theme-abi-v2.md \xA77.2; not on role layout).'
2422
+ },
2423
+ "requires": {
2424
+ "type": "array",
2425
+ "uniqueItems": true,
2426
+ "items": {
2427
+ "type": "string",
2428
+ "pattern": "^(home|product|collection|collections|page|blog|article|search|cart|customer|policy|metaobject|not_found|custom:[a-z][a-z0-9-]*)$"
2429
+ },
2430
+ "description": "Route kinds (any RouteKind, aligned with the .d.ts) whose resource this component needs. The editor refuses to place it on other templates."
2431
+ },
2432
+ "attributes": {
2433
+ "type": "object",
2434
+ "maxProperties": 64,
2435
+ "propertyNames": {
2436
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$"
2437
+ },
2438
+ "additionalProperties": {
2439
+ "$ref": "#/$defs/field"
2440
+ }
2441
+ },
2442
+ "presets": {
2443
+ "type": "array",
2444
+ "maxItems": 16,
2445
+ "items": {
2446
+ "type": "object",
2447
+ "additionalProperties": false,
2448
+ "properties": {
2449
+ "name": {
2450
+ "type": "string",
2451
+ "maxLength": 128
2452
+ },
2453
+ "settings": {
2454
+ "type": "object"
2455
+ },
2456
+ "blocks": {
2457
+ "type": "array",
2458
+ "maxItems": 64,
2459
+ "items": {
2460
+ "$ref": "#/$defs/contentNode"
2461
+ }
2462
+ }
2463
+ }
2464
+ }
2465
+ },
2466
+ "limits": {
2467
+ "type": "object",
2468
+ "additionalProperties": false,
2469
+ "properties": {
2470
+ "maxBlocks": {
2471
+ "type": "integer",
2472
+ "minimum": 0,
2473
+ "maximum": 64
2474
+ }
2475
+ }
2476
+ }
2477
+ }
2478
+ }
2479
+ }
2480
+ };
2481
+
2482
+ // ../theme-abi/src/app-blocks.ts
2483
+ var APP_BLOCKS_CHILD = "@app";
2484
+
2485
+ // ../theme-abi/src/manifest/semantics.ts
2486
+ var LIST_MAX_DEPTH = 2;
2487
+ var CAPABILITY_PATH_MAX_DEPTH = 2;
2488
+ function escapePointer(segment) {
2489
+ return segment.replace(/~/g, "~0").replace(/\//g, "~1");
2490
+ }
2491
+ var Collector = class {
2492
+ errors = [];
2493
+ push(code, path, message, params) {
2494
+ this.errors.push(params ? { path, code, keyword: code, message, params } : { path, code, keyword: code, message });
2495
+ }
2496
+ };
2497
+ function capabilityPathDepth(cap) {
2498
+ if (cap.startsWith("network:")) return 0;
2499
+ const idx = cap.indexOf(":");
2500
+ const path = idx === -1 ? cap : cap.slice(idx + 1);
2501
+ return path.split(".").length;
2502
+ }
2503
+ function checkCapabilities(m, out) {
2504
+ const server = new Set(m.capabilities.server);
2505
+ m.capabilities.server.forEach((cap, i) => {
2506
+ const path = `/capabilities/server/${i}`;
2507
+ if (cap.startsWith("network:") && !isNetworkCapability(cap)) {
2508
+ out.push(
2509
+ "network_origin_malformed",
2510
+ path,
2511
+ `"${cap}" is not a well-formed https origin: expected network:https://<host>[:port] with no path, query, fragment or credentials`,
2512
+ { capability: cap }
2513
+ );
2514
+ }
2515
+ const depth = capabilityPathDepth(cap);
2516
+ if (depth > CAPABILITY_PATH_MAX_DEPTH) {
2517
+ out.push(
2518
+ "capability_path_depth_exceeded",
2519
+ path,
2520
+ `capability "${cap}" has path depth ${depth}; maximum is ${CAPABILITY_PATH_MAX_DEPTH}`,
2521
+ { capability: cap, depth, maxDepth: CAPABILITY_PATH_MAX_DEPTH }
2522
+ );
2523
+ }
2524
+ });
2525
+ m.capabilities.browser.forEach((cap, i) => {
2526
+ const path = `/capabilities/browser/${i}`;
2527
+ if (!isBrowserCapability(cap)) {
2528
+ out.push(
2529
+ "browser_capability_not_mintable",
2530
+ path,
2531
+ `"${cap}" is outside the browser ceiling (A10): never browser-mintable`,
2532
+ { capability: cap }
2533
+ );
2534
+ }
2535
+ if (!server.has(cap)) {
2536
+ out.push(
2537
+ "browser_not_subset_of_server",
2538
+ path,
2539
+ `browser capability "${cap}" is not declared in capabilities.server (theme-abi-v2.md \xA77.1)`,
2540
+ { capability: cap }
2541
+ );
2542
+ }
2543
+ const depth = capabilityPathDepth(cap);
2544
+ if (depth > CAPABILITY_PATH_MAX_DEPTH) {
2545
+ out.push(
2546
+ "capability_path_depth_exceeded",
2547
+ path,
2548
+ `capability "${cap}" has path depth ${depth}; maximum is ${CAPABILITY_PATH_MAX_DEPTH}`,
2549
+ { capability: cap, depth, maxDepth: CAPABILITY_PATH_MAX_DEPTH }
2550
+ );
2551
+ }
2552
+ });
2553
+ }
2554
+ function customRouteKey(kind) {
2555
+ return kind.startsWith("custom:") ? kind.slice("custom:".length) : null;
2556
+ }
2557
+ function checkReferences(m, out) {
2558
+ const templates = new Set(Object.keys(m.templates));
2559
+ const regions = new Set(Object.keys(m.regions));
2560
+ const components = m.components;
2561
+ const customRoutes = new Set(Object.keys(m.customRoutes ?? {}));
2562
+ const requireCustomRoute = (kind, path) => {
2563
+ const key = customRouteKey(kind);
2564
+ if (key !== null && !customRoutes.has(key)) {
2565
+ out.push(
2566
+ "custom_route_undeclared",
2567
+ path,
2568
+ `route kind "${kind}" has no matching customRoutes["${key}"] entry`,
2569
+ { kind, customRoute: key }
2570
+ );
2571
+ }
2572
+ };
2573
+ for (const [kind, template] of Object.entries(m.routes)) {
2574
+ const path = `/routes/${escapePointer(kind)}`;
2575
+ if (!templates.has(template)) {
2576
+ out.push(
2577
+ "route_template_missing",
2578
+ path,
2579
+ `routes["${kind}"] names template "${template}", which is not a key of templates`,
2580
+ { kind, template }
2581
+ );
2582
+ }
2583
+ requireCustomRoute(kind, path);
2584
+ }
2585
+ for (const [name, t] of Object.entries(m.templates)) {
2586
+ const base = `/templates/${escapePointer(name)}`;
2587
+ t.regions.forEach((r, i) => {
2588
+ if (!regions.has(r)) {
2589
+ out.push(
2590
+ "template_region_missing",
2591
+ `${base}/regions/${i}`,
2592
+ `template "${name}" renders region "${r}", which is not a key of regions`,
2593
+ { template: name, region: r }
2594
+ );
2595
+ }
2596
+ });
2597
+ requireCustomRoute(t.route, `${base}/route`);
2598
+ }
2599
+ for (const [name, r] of Object.entries(m.regions)) {
2600
+ r.accepts?.forEach((c, i) => {
2601
+ const path = `/regions/${escapePointer(name)}/accepts/${i}`;
2602
+ const def2 = components[c];
2603
+ if (!def2) {
2604
+ out.push(
2605
+ "region_accepts_unknown_component",
2606
+ path,
2607
+ `region "${name}" accepts component "${c}", which is not a key of components`,
2608
+ { region: name, component: c }
2609
+ );
2610
+ } else if (def2.role === "block") {
2611
+ out.push(
2612
+ "region_accepts_non_section",
2613
+ path,
2614
+ `region "${name}" accepts "${c}", but its role is "block" (only section|layout may be placed in a region)`,
2615
+ { region: name, component: c, role: def2.role }
2616
+ );
2617
+ }
2618
+ });
2619
+ }
2620
+ for (const [id, c] of Object.entries(components)) {
2621
+ const base = `/components/${escapePointer(id)}`;
2622
+ c.regions?.forEach((r, i) => {
2623
+ if (!regions.has(r)) {
2624
+ out.push(
2625
+ "component_region_missing",
2626
+ `${base}/regions/${i}`,
2627
+ `component "${id}" lists region "${r}", which is not a key of regions`,
2628
+ { component: id, region: r }
2629
+ );
2630
+ }
2631
+ });
2632
+ c.parents?.forEach((p, i) => {
2633
+ if (!(p in components)) {
2634
+ out.push(
2635
+ "component_parent_missing",
2636
+ `${base}/parents/${i}`,
2637
+ `component "${id}" lists parent "${p}", which is not a key of components`,
2638
+ { component: id, parent: p }
2639
+ );
2640
+ }
2641
+ });
2642
+ c.children?.forEach((ch, i) => {
2643
+ if (ch === APP_BLOCKS_CHILD) return;
2644
+ if (!(ch in components)) {
2645
+ out.push(
2646
+ "component_child_missing",
2647
+ `${base}/children/${i}`,
2648
+ `component "${id}" lists child "${ch}", which is not a key of components`,
2649
+ { component: id, child: ch }
2650
+ );
2651
+ }
2652
+ });
2653
+ c.requires?.forEach((kind, i) => requireCustomRoute(kind, `${base}/requires/${i}`));
2654
+ c.presets?.forEach((preset, p) => {
2655
+ if (preset.blocks) checkBlockTypes(preset.blocks, `${base}/presets/${p}/blocks`, components, out);
2656
+ if (preset.settings) {
2657
+ for (const key of Object.keys(preset.settings)) {
2658
+ if (!(key in c.attributes)) {
2659
+ out.push(
2660
+ "preset_setting_unknown",
2661
+ `${base}/presets/${p}/settings/${escapePointer(key)}`,
2662
+ `preset setting "${key}" is not an attribute of component "${id}"`,
2663
+ { component: id, setting: key }
2664
+ );
2665
+ }
2666
+ }
2667
+ }
2668
+ });
2669
+ }
2670
+ const to = m.contentVersion;
2671
+ const from = m.minContentVersion ?? to;
2672
+ if (from > to) {
2673
+ out.push(
2674
+ "migration_range_invalid",
2675
+ "/minContentVersion",
2676
+ `minContentVersion (${from}) must not exceed contentVersion (${to})`,
2677
+ { minContentVersion: from, contentVersion: to }
2678
+ );
2679
+ } else if (to > from) {
2680
+ const steps = /* @__PURE__ */ new Map();
2681
+ for (const s of m.migrations ?? []) steps.set(s.from, s.to);
2682
+ let v = from;
2683
+ const seen = /* @__PURE__ */ new Set();
2684
+ while (v < to && steps.has(v) && !seen.has(v)) {
2685
+ seen.add(v);
2686
+ v = steps.get(v);
2687
+ }
2688
+ if (v !== to) {
2689
+ out.push(
2690
+ "migration_chain_broken",
2691
+ "/migrations",
2692
+ `migrations must chain gap-free from ${from} to ${to}; chain stops at ${v}`,
2693
+ { from, to, reachedVersion: v }
2694
+ );
2695
+ }
2696
+ }
2697
+ }
2698
+ function checkBlockTypes(nodes, pointer, components, out) {
2699
+ nodes.forEach((node, i) => {
2700
+ if (!(node.type in components)) {
2701
+ out.push(
2702
+ "preset_block_type_missing",
2703
+ `${pointer}/${i}/type`,
2704
+ `preset block type "${node.type}" is not a key of components`,
2705
+ { type: node.type }
2706
+ );
2707
+ }
2708
+ if (node.blocks) checkBlockTypes(node.blocks, `${pointer}/${i}/blocks`, components, out);
2709
+ });
2710
+ }
2711
+ function checkListDepth(spec, pointer, depth, out) {
2712
+ if (!spec.items) return;
2713
+ const itemsPointer = `${pointer}/items`;
2714
+ if (depth + 1 > LIST_MAX_DEPTH) {
2715
+ out.push(
2716
+ "list_depth_exceeded",
2717
+ itemsPointer,
2718
+ `\`list\` items nesting exceeds depth ${LIST_MAX_DEPTH} (theme-abi-v2.md \xA77.4)`,
2719
+ { maxDepth: LIST_MAX_DEPTH, depth: depth + 1 }
2720
+ );
2721
+ return;
2722
+ }
2723
+ checkListDepth(spec.items, itemsPointer, depth + 1, out);
2724
+ }
2725
+ function checkNesting(nodes, pointer, depth, out) {
2726
+ const max = LIMITS.nestingDepth.hard;
2727
+ nodes.forEach((node, i) => {
2728
+ if (!node.blocks || node.blocks.length === 0) return;
2729
+ const blocksPointer = `${pointer}/${i}/blocks`;
2730
+ if (depth + 1 > max) {
2731
+ out.push(
2732
+ "nesting_depth_exceeded",
2733
+ blocksPointer,
2734
+ `content-node nesting exceeds depth ${max} (theme-abi-v2.md \xA78)`,
2735
+ { maxDepth: max, depth: depth + 1 }
2736
+ );
2737
+ return;
2738
+ }
2739
+ checkNesting(node.blocks, blocksPointer, depth + 1, out);
2740
+ });
2741
+ }
2742
+ function checkDepth(m, out) {
2743
+ for (const [componentId, component] of Object.entries(m.components)) {
2744
+ const base = `/components/${escapePointer(componentId)}`;
2745
+ for (const [attrKey, spec] of Object.entries(component.attributes)) {
2746
+ checkListDepth(spec, `${base}/attributes/${escapePointer(attrKey)}`, 0, out);
2747
+ }
2748
+ component.presets?.forEach((preset, p) => {
2749
+ if (preset.blocks) checkNesting(preset.blocks, `${base}/presets/${p}/blocks`, 1, out);
2750
+ });
2751
+ }
2752
+ m.settingsSchema.forEach((group, g) => {
2753
+ group.items.forEach((item, i) => checkListDepth(item, `/settingsSchema/${g}/items/${i}`, 0, out));
2754
+ });
2755
+ }
2756
+ function collectNodeIds(nodes, pointer, seen, out) {
2757
+ nodes.forEach((node, i) => {
2758
+ const idPath = `${pointer}/${i}/id`;
2759
+ const first = seen.get(node.id);
2760
+ if (first !== void 0) {
2761
+ out.push(
2762
+ "duplicate_node_id",
2763
+ idPath,
2764
+ `node id "${node.id}" is already used at ${first}`,
2765
+ { id: node.id, firstPath: first }
2766
+ );
2767
+ } else {
2768
+ seen.set(node.id, idPath);
2769
+ }
2770
+ if (node.blocks) collectNodeIds(node.blocks, `${pointer}/${i}/blocks`, seen, out);
2771
+ });
2772
+ }
2773
+ function checkDuplicates(m, out) {
2774
+ for (const [componentId, component] of Object.entries(m.components)) {
2775
+ component.presets?.forEach((preset, p) => {
2776
+ if (preset.blocks) collectNodeIds(preset.blocks, `/components/${escapePointer(componentId)}/presets/${p}/blocks`, /* @__PURE__ */ new Map(), out);
2777
+ });
2778
+ }
2779
+ const keys = /* @__PURE__ */ new Map();
2780
+ m.settingsSchema.forEach((group, g) => {
2781
+ group.items.forEach((item, i) => {
2782
+ const path = `/settingsSchema/${g}/items/${i}/key`;
2783
+ const first = keys.get(item.key);
2784
+ if (first !== void 0) {
2785
+ out.push(
2786
+ "duplicate_setting_key",
2787
+ path,
2788
+ `settings key "${item.key}" is already declared at ${first}`,
2789
+ { key: item.key, firstPath: first }
2790
+ );
2791
+ } else {
2792
+ keys.set(item.key, path);
2793
+ }
2794
+ });
2795
+ });
2796
+ }
2797
+ function checkManifestSemantics(m, options = {}) {
2798
+ const out = new Collector();
2799
+ checkCapabilities(m, out);
2800
+ checkReferences(m, out);
2801
+ checkDepth(m, out);
2802
+ checkDuplicates(m, out);
2803
+ checkFieldValues(m, options, out);
2804
+ return out.errors;
2805
+ }
2806
+ function checkFieldValues(m, options, out) {
2807
+ const declared = m.engines["tanqory-field-types"];
2808
+ if (!isFieldRegistryVersion(declared)) {
2809
+ out.push(
2810
+ "field_registry_unsupported",
2811
+ "/engines/tanqory-field-types",
2812
+ `tanqory-field-types@${declared} is not supported (supported: ${FIELD_REGISTRY_VERSIONS.join(", ")})`,
2813
+ { registry: declared, supported: FIELD_REGISTRY_VERSIONS }
2814
+ );
2815
+ return;
2816
+ }
2817
+ const registry = declared;
2818
+ const files = options.artifactFiles ? [...options.artifactFiles] : void 0;
2819
+ const checkValue = (spec, value, pointer, code) => {
2820
+ if (!isFieldTypeIdIn(spec.type, registry)) return;
2821
+ const r = validateFieldValue(spec.type, value, spec, files ? { registry, origin: "theme", artifactFiles: files } : { registry, origin: "theme" });
2822
+ if (r.ok) return;
2823
+ for (const e of r.errors) {
2824
+ const c = e.code === "asset_not_in_artifact" ? "asset_not_in_artifact" : code;
2825
+ out.push(c, pointer + e.path, `${e.message}`, { fieldType: spec.type, fieldCode: e.code, ...e.params ?? {} });
2826
+ }
2827
+ };
2828
+ const checkSettings = (attrs, settings, pointer) => {
2829
+ for (const [key, value] of Object.entries(settings)) {
2830
+ if (!Object.hasOwn(attrs, key)) continue;
2831
+ checkValue(attrs[key], value, `${pointer}/${escapePointer(key)}`, "preset_setting_invalid");
2832
+ }
2833
+ };
2834
+ const checkBlocks = (nodes, pointer) => {
2835
+ nodes.forEach((node, i) => {
2836
+ const def2 = Object.hasOwn(m.components, node.type) ? m.components[node.type] : void 0;
2837
+ if (def2 && node.settings) checkSettings(def2.attributes, node.settings, `${pointer}/${i}/settings`);
2838
+ if (node.blocks) checkBlocks(node.blocks, `${pointer}/${i}/blocks`);
2839
+ });
2840
+ };
2841
+ for (const [id, c] of Object.entries(m.components)) {
2842
+ const base = `/components/${escapePointer(id)}`;
2843
+ for (const [key, spec] of Object.entries(c.attributes)) {
2844
+ if (Object.hasOwn(spec, "default")) checkValue(spec, spec.default, `${base}/attributes/${escapePointer(key)}/default`, "field_default_invalid");
2845
+ }
2846
+ c.presets?.forEach((preset, p) => {
2847
+ if (preset.settings) checkSettings(c.attributes, preset.settings, `${base}/presets/${p}/settings`);
2848
+ if (preset.blocks) checkBlocks(preset.blocks, `${base}/presets/${p}/blocks`);
2849
+ });
2850
+ }
2851
+ m.settingsSchema.forEach((group, g) => {
2852
+ group.items.forEach((item, i) => {
2853
+ if (Object.hasOwn(item, "default")) checkValue(item, item.default, `/settingsSchema/${g}/items/${i}/default`, "field_default_invalid");
2854
+ });
2855
+ });
2856
+ }
2857
+
2858
+ // ../theme-abi/src/manifest/validate.ts
2859
+ var compiled;
2860
+ function compiledValidator() {
2861
+ if (!compiled) {
2862
+ const ajv = new import__2.Ajv2020({ allErrors: true, strict: true, strictRequired: true, allowUnionTypes: true });
2863
+ compiled = ajv.compile(THEME_MANIFEST_V2_SCHEMA);
2864
+ }
2865
+ return compiled;
2866
+ }
2867
+ function fromAjv(e) {
2868
+ let path = e.instancePath;
2869
+ if (e.keyword === "required" && typeof e.params["missingProperty"] === "string") {
2870
+ path = `${path}/${escapePointer(e.params["missingProperty"])}`;
2871
+ } else if (e.keyword === "additionalProperties" && typeof e.params["additionalProperty"] === "string") {
2872
+ path = `${path}/${escapePointer(e.params["additionalProperty"])}`;
2873
+ } else if (e.keyword === "propertyNames" && typeof e.params["propertyName"] === "string") {
2874
+ path = `${path}/${escapePointer(e.params["propertyName"])}`;
2875
+ }
2876
+ return {
2877
+ path,
2878
+ code: "schema",
2879
+ keyword: e.keyword,
2880
+ message: e.message ?? e.keyword,
2881
+ params: e.params
2882
+ };
2883
+ }
2884
+ function validateManifest(input, options = {}) {
2885
+ const validate = compiledValidator();
2886
+ if (!validate(input)) {
2887
+ const errors2 = (validate.errors ?? []).map(fromAjv);
2888
+ return { ok: false, errors: errors2 };
2889
+ }
2890
+ const manifest = input;
2891
+ const errors = checkManifestSemantics(manifest, options);
2892
+ if (errors.length > 0) return { ok: false, errors };
2893
+ return { ok: true, manifest, errors: [] };
2894
+ }
2895
+
2896
+ // ../../apps/build-service/src/review/partner-source.ts
1070
2897
  var import_editability = __toESM(require_editability());
1071
2898
 
1072
2899
  // ../../apps/build-service/src/artifact/digest.ts
@@ -1083,9 +2910,9 @@ function sha256Digest(bytes) {
1083
2910
  var import_yaml = require("yaml");
1084
2911
 
1085
2912
  // ../../apps/build-service/src/artifact/canonical-json.ts
1086
- var jcs = require("@tanqory/theme-abi/jcs");
1087
- var CanonicalJsonError = jcs.CanonicalJsonError;
1088
- var CANONICAL_JSON_MAX_DEPTH = jcs.CANONICAL_JSON_MAX_DEPTH;
2913
+ var jcs = (init_jcs(), __toCommonJS(jcs_exports));
2914
+ var CanonicalJsonError2 = jcs.CanonicalJsonError;
2915
+ var CANONICAL_JSON_MAX_DEPTH2 = jcs.CANONICAL_JSON_MAX_DEPTH;
1089
2916
  function canonicalize(value) {
1090
2917
  return jcs.canonicalJson(value);
1091
2918
  }
@@ -1467,11 +3294,17 @@ function loadThirdPartyKits(path = THIRD_PARTY_TOOLCHAINS_PATH) {
1467
3294
  if (!Array.isArray(doc.kits) || doc.kits.length === 0)
1468
3295
  throw new Error(`${path}: kits must be a non-empty list`);
1469
3296
  const seen = /* @__PURE__ */ new Set();
1470
- return doc.kits.map((k) => {
3297
+ const kits = doc.kits.map((k) => {
1471
3298
  if (typeof k.version !== "string" || !import_source.EXACT_VERSION_RE.test(k.version) || !k.version.startsWith("2."))
1472
3299
  throw new Error(`${path}: ${JSON.stringify(k.version)} is not an exact 2.x version`);
1473
3300
  if (seen.has(k.version)) throw new Error(`${path}: ${k.version} is listed twice`);
1474
3301
  seen.add(k.version);
3302
+ if ("aliasOf" in k) {
3303
+ if ("pack" in k || "integrity" in k || "gitHead" in k)
3304
+ throw new Error(`${path}: ${k.version} is an alias; it pins no pack, gitHead or integrity`);
3305
+ if (typeof k.aliasOf !== "string") throw new Error(`${path}: ${k.version} aliasOf must be a version`);
3306
+ return { version: k.version, aliasOf: k.aliasOf };
3307
+ }
1475
3308
  if ("pack" in k) {
1476
3309
  if (k.pack !== `tanqory-theme-kit-${k.version}.tgz`)
1477
3310
  throw new Error(`${path}: ${k.version} pack must be tanqory-theme-kit-${k.version}.tgz`);
@@ -1485,6 +3318,16 @@ function loadThirdPartyKits(path = THIRD_PARTY_TOOLCHAINS_PATH) {
1485
3318
  throw new Error(`${path}: ${k.version} has no sha512 integrity`);
1486
3319
  return { version: k.version, gitHead: k.gitHead, integrity: k.integrity };
1487
3320
  });
3321
+ for (const k of kits)
3322
+ if ("aliasOf" in k && !kits.some((t) => t.version === k.aliasOf && "pack" in t))
3323
+ throw new Error(`${path}: ${k.version} aliasOf ${k.aliasOf} is not a pack kit of this file`);
3324
+ return kits;
3325
+ }
3326
+ function loadStarterAbiPins(path = THIRD_PARTY_TOOLCHAINS_PATH) {
3327
+ const doc = JSON.parse((0, import_node_fs2.readFileSync)(path, "utf8"));
3328
+ const carried = doc.starter?.packages?.find((p) => p.name === "@tanqory/theme-abi")?.version;
3329
+ const aliases = (doc.starter?.abiAliases ?? []).filter((a) => a.aliasOf === carried).map((a) => a.version);
3330
+ return { carried, accepted: carried === void 0 ? [] : [carried, ...aliases] };
1488
3331
  }
1489
3332
  var STARTER_ABI_VERSION = "2.0";
1490
3333
 
@@ -1558,6 +3401,7 @@ function relativePathProblem(path, opts = {}) {
1558
3401
 
1559
3402
  // ../../apps/build-service/src/artifact/inline-scripts.ts
1560
3403
  var INLINE_SCRIPT_SOURCE = /^src\/inline\/[^/]+\.js$/;
3404
+ var INLINE_IMPORT_MAP_REFUSED = "inline_import_map_refused";
1561
3405
  function inlineScriptProblem(bytes) {
1562
3406
  const text = Buffer.from(bytes).toString("utf8");
1563
3407
  if (!Buffer.from(text, "utf8").equals(Buffer.from(bytes)) || text.charCodeAt(0) === 65279)
@@ -1567,9 +3411,15 @@ function inlineScriptProblem(bytes) {
1567
3411
  if (text.includes("<!--")) return 'must not contain "<!--" (HTML script-data escape)';
1568
3412
  return null;
1569
3413
  }
1570
-
1571
- // ../../apps/build-service/src/ingest/ingest-gate.ts
1572
- var import_theme_abi = require("@tanqory/theme-abi");
3414
+ function inlineImportMapProblem(bytes) {
3415
+ let v;
3416
+ try {
3417
+ v = JSON.parse(Buffer.from(bytes).toString("utf8").trim());
3418
+ } catch {
3419
+ return null;
3420
+ }
3421
+ return v !== null && typeof v === "object" && !Array.isArray(v) ? "is a JSON object, which a page could load as a second import map; only the platform's import map may be one (theme-abi-v2.md \xA72.2.1)" : null;
3422
+ }
1573
3423
 
1574
3424
  // ../../apps/build-service/src/artifact/files.ts
1575
3425
  function leafOf(file) {
@@ -1702,6 +3552,13 @@ var IngestGate = class {
1702
3552
  `inline script ${f.path} ${inlineProblem}`,
1703
3553
  f.path
1704
3554
  );
3555
+ const mapProblem = inlineImportMapProblem(f.bytes);
3556
+ if (mapProblem)
3557
+ throw new IngestRejectedError(
3558
+ "params",
3559
+ `${INLINE_IMPORT_MAP_REFUSED}: inline script ${f.path} ${mapProblem}`,
3560
+ f.path
3561
+ );
1705
3562
  }
1706
3563
  }
1707
3564
  this.checkCollisions(files);
@@ -2056,10 +3913,10 @@ var IngestGate = class {
2056
3913
  return lock;
2057
3914
  }
2058
3915
  checkManifest(file) {
2059
- if (file.bytes.byteLength > import_theme_abi.LIMITS.manifestBytes.hard) {
3916
+ if (file.bytes.byteLength > LIMITS.manifestBytes.hard) {
2060
3917
  throw new IngestRejectedError(
2061
3918
  "manifest",
2062
- `manifest.json is ${file.bytes.byteLength} bytes; hard limit ${import_theme_abi.LIMITS.manifestBytes.hard}`,
3919
+ `manifest.json is ${file.bytes.byteLength} bytes; hard limit ${LIMITS.manifestBytes.hard}`,
2063
3920
  file.path
2064
3921
  );
2065
3922
  }
@@ -2069,7 +3926,7 @@ var IngestGate = class {
2069
3926
  } catch {
2070
3927
  throw new IngestRejectedError("manifest", "manifest.json is not valid JSON", file.path);
2071
3928
  }
2072
- const result = (0, import_theme_abi.validateManifest)(parsed);
3929
+ const result = validateManifest(parsed);
2073
3930
  if (!result.ok) {
2074
3931
  const first = result.errors[0];
2075
3932
  throw new IngestRejectedError(
@@ -2304,7 +4161,6 @@ var import_text_rules = __toESM(require_text_rules());
2304
4161
  // ../../apps/build-service/src/review/local-sandbox.ts
2305
4162
  var import_node_crypto4 = require("node:crypto");
2306
4163
  var import_node_zlib = require("node:zlib");
2307
- var import_theme_abi2 = require("@tanqory/theme-abi");
2308
4164
 
2309
4165
  // ../../apps/build-service/src/artifact/entry-scan.ts
2310
4166
  var import_acorn = require("acorn");
@@ -2404,6 +4260,16 @@ function clientChunkProblem(path, source, shipped) {
2404
4260
  }
2405
4261
  return void 0;
2406
4262
  }
4263
+ function clientReactBuildProblem(path, source) {
4264
+ const names = new Set(
4265
+ [...source.matchAll(/\.(renderToString|renderToStaticMarkup|renderToReadableStream|renderToPipeableStream|renderToStaticNodeStream|prerender|prerenderToNodeStream|resumeAndPrerender)\s*=\s*function\b/g)].map((m) => m[1])
4266
+ );
4267
+ if (names.size >= 2)
4268
+ return `${path} contains React's server renderer (react-dom/server or react-dom/static: ${[...names].sort().join(", ")}). It renders on the server only; in a browser bundle it is ~70 kB of dead code. Import it from server code only, or from the module that defines what you need rather than a barrel that re-exports it`;
4269
+ if (source.includes('Each child in a list should have a unique "key" prop') || source.includes('Each child in a list should have a unique \\"key\\" prop'))
4270
+ return `${path} contains a React development build (its dev-only warnings). Build with NODE_ENV=production`;
4271
+ return void 0;
4272
+ }
2407
4273
 
2408
4274
  // ../../apps/build-service/src/review/local-sandbox.ts
2409
4275
  var line = (key, errors, passed) => errors.length ? { key, status: "failed", message: errors[0].message, errors: errors.slice(0, 50) } : { key, status: "passed", message: passed, errors: [] };
@@ -2442,6 +4308,8 @@ function entryScanLine(out) {
2442
4308
  for (const f of assets.filter((x) => /\.m?js$/.test(x.path))) {
2443
4309
  const problem = clientChunkProblem(f.path, f.bytes.toString("utf8"), shipped);
2444
4310
  if (problem) errors.push({ path: f.path, code: "client_chunk_import", message: `${problem}. Bundle the module into the theme's own chunks.` });
4311
+ const react = clientReactBuildProblem(f.path, f.bytes.toString("utf8"));
4312
+ if (react) errors.push({ path: f.path, code: "client_react_build", message: `${react}.` });
2445
4313
  }
2446
4314
  return line("entry_scan", errors, `server/entry.mjs${out.some((x) => x.path === "preview/entry.mjs") ? " and preview/entry.mjs" : ""} import nothing; ${assets.length} client file(s) import only each other.`);
2447
4315
  }
@@ -2471,7 +4339,7 @@ function budgetsLine(out) {
2471
4339
  const errors = [];
2472
4340
  const over = [];
2473
4341
  for (const [k, v] of rows) {
2474
- const { budget, hard } = import_theme_abi2.LIMITS[k];
4342
+ const { budget, hard } = LIMITS[k];
2475
4343
  if (v > hard) errors.push({ path: k, code: "over_hard_limit", message: `${k} is ${v}, over the hard limit ${hard} (ABI \xA78). Make the theme smaller: split the client code, drop unused code and assets.` });
2476
4344
  else if (budget !== null && v > budget) over.push(`${k} ${v} > budget ${budget}`);
2477
4345
  }
@@ -2644,14 +4512,14 @@ function licencesLine(files, table) {
2644
4512
  var line2 = (key, errors, passed) => errors.length ? { key, status: "failed", message: errors[0].message, errors: errors.slice(0, 50) } : { key, status: "passed", message: passed, errors: [] };
2645
4513
  function treeOf(dir) {
2646
4514
  const out = [];
2647
- const walk = (abs) => {
4515
+ const walk2 = (abs) => {
2648
4516
  for (const name of (0, import_node_fs4.readdirSync)(abs).sort()) {
2649
4517
  const p = (0, import_node_path4.join)(abs, name);
2650
- if ((0, import_node_fs4.statSync)(p).isDirectory()) walk(p);
4518
+ if ((0, import_node_fs4.statSync)(p).isDirectory()) walk2(p);
2651
4519
  else out.push({ path: (0, import_node_path4.relative)(dir, p).split(import_node_path4.sep).join("/"), bytes: (0, import_node_fs4.readFileSync)(p) });
2652
4520
  }
2653
4521
  };
2654
- walk(dir);
4522
+ walk2(dir);
2655
4523
  return out;
2656
4524
  }
2657
4525
  var failure = (e) => ({
@@ -2691,16 +4559,15 @@ async function checkPartnerSource(tgz, built, opts = {}) {
2691
4559
  }
2692
4560
  const pkg = JSON.parse(files.find((f) => f.path === "package.json")?.bytes.toString("utf8") ?? "{}");
2693
4561
  const pinOf = (name) => pkg["dependencies"]?.[name] ?? pkg["devDependencies"]?.[name];
2694
- const toolchains = JSON.parse((0, import_node_fs4.readFileSync)(THIRD_PARTY_TOOLCHAINS_PATH, "utf8"));
2695
4562
  const kits = loadThirdPartyKits().map((k) => k.version);
2696
- const starterAbi = toolchains.starter?.packages?.find((p) => p.name === "@tanqory/theme-abi")?.version;
4563
+ const starterAbi = loadStarterAbiPins();
2697
4564
  const build = [];
2698
4565
  const kit = pinOf("@tanqory/theme-kit");
2699
4566
  if (!kit || !kits.includes(kit))
2700
4567
  build.push({ path: "package.json", code: "kit_not_carried", message: `package.json pins @tanqory/theme-kit ${JSON.stringify(kit ?? null)}; the builder carries ${kits.join(", ")}. Pin one of those exactly.` });
2701
4568
  const abi = pinOf("@tanqory/theme-abi");
2702
- if (abi !== void 0 && ingest?.layout !== "theme-source" && abi !== starterAbi)
2703
- build.push({ path: "package.json", code: "abi_not_carried", message: `package.json pins @tanqory/theme-abi ${JSON.stringify(abi)}; the builder's starter toolchain carries ${starterAbi}. Pin that exactly.` });
4569
+ if (abi !== void 0 && ingest?.layout !== "theme-source" && !starterAbi.accepted.includes(abi))
4570
+ build.push({ path: "package.json", code: "abi_not_carried", message: `package.json pins @tanqory/theme-abi ${JSON.stringify(abi)}; the builder's starter toolchain carries ${starterAbi.carried}. Pin that exactly.` });
2704
4571
  lines.push(line2("sandbox_build", build, `@tanqory/theme-kit ${kit} and @tanqory/theme-abi ${abi ?? "(not pinned)"} are carried by the builder`));
2705
4572
  const text = (0, import_text_rules.sourceTextFindings)(files.map((f) => [f.path, f.bytes]));
2706
4573
  lines.push(line2("source_text", text, `${files.length} source file(s) checked`));
@@ -2713,7 +4580,7 @@ async function checkPartnerSource(tgz, built, opts = {}) {
2713
4580
  if (!manifestFile) mErrors.push({ path: "manifest.json", code: "manifest_missing", message: `The build wrote no manifest.json in ${built}.` });
2714
4581
  else {
2715
4582
  manifest = JSON.parse(manifestFile.bytes.toString("utf8"));
2716
- const r = (0, import_theme_abi3.validateManifest)(manifest, { artifactFiles: out.map((f) => f.path) });
4583
+ const r = validateManifest(manifest, { artifactFiles: out.map((f) => f.path) });
2717
4584
  if (!r.ok) for (const e of r.errors) mErrors.push({ path: e.path, code: e.code, message: e.message });
2718
4585
  }
2719
4586
  lines.push(line2("manifest", mErrors, "theme-manifest v2: schema and semantic checks passed"));