@tanqory/partner-cli 0.1.0-alpha.2 → 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.
- package/config/third-party-toolchains.json +18 -4
- package/lib/api.mjs +56 -0
- package/lib/check.mjs +25 -1
- package/lib/cli.mjs +52 -3
- package/lib/extensions.mjs +188 -0
- package/lib/mcp.mjs +23 -1
- package/lib/ops.mjs +61 -1
- package/lib/theme.mjs +16 -2
- package/lib/vendor/partner-checks.cjs +2528 -310
- package/package.json +3 -6
- package/starter/package.json +2 -2
- package/starter/scripts/build.mjs +13 -2
- package/starter/src/sections/commerce.tsx +12 -2
- package/starter/src/sections/editorial.tsx +7 -2
- package/starter/src/styles/theme.css +6 -2
|
@@ -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;
|
|
@@ -52,13 +60,13 @@ var require_editability = __commonJS({
|
|
|
52
60
|
var SVG_TEXT = /* @__PURE__ */ new Set(["text", "tspan", "title", "desc", "textPath"]);
|
|
53
61
|
var isWords = (s) => LETTER.test(s) && !/^\s*(&[a-z#0-9]+;\s*)+$/i.test(s);
|
|
54
62
|
function lineCol(src, i) {
|
|
55
|
-
let
|
|
63
|
+
let line3 = 1;
|
|
56
64
|
let last = -1;
|
|
57
65
|
for (let k = 0; k < i && k < src.length; k++) if (src.charCodeAt(k) === 10) {
|
|
58
|
-
|
|
66
|
+
line3++;
|
|
59
67
|
last = k;
|
|
60
68
|
}
|
|
61
|
-
return { line:
|
|
69
|
+
return { line: line3, column: i - last };
|
|
62
70
|
}
|
|
63
71
|
function scan(src) {
|
|
64
72
|
const n = src.length;
|
|
@@ -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
|
|
334
|
-
for (const k of ["zone", "requires", "presets", "blocks", "component", "title"])
|
|
335
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
375
|
+
out.push(def2);
|
|
368
376
|
}
|
|
369
377
|
return out;
|
|
370
378
|
}
|
|
@@ -379,10 +387,10 @@ var require_editability = __commonJS({
|
|
|
379
387
|
const errors = [];
|
|
380
388
|
const warnings = [];
|
|
381
389
|
const add = (sev, code, file, src, at, message, fix) => {
|
|
382
|
-
const { line:
|
|
390
|
+
const { line: line3, column } = lineCol(src, at);
|
|
383
391
|
const list = sev === "error" ? errors : warnings;
|
|
384
|
-
if (list.some((x) => x.code === code && x.file === file && x.line ===
|
|
385
|
-
list.push({ severity: sev, code, file, line:
|
|
392
|
+
if (list.some((x) => x.code === code && x.file === file && x.line === line3 && x.column === column)) return;
|
|
393
|
+
list.push({ severity: sev, code, file, line: line3, column, message, ...fix ? { fix } : {} });
|
|
386
394
|
};
|
|
387
395
|
let en = opts.locales || null;
|
|
388
396
|
if (!en && typeof files["locales/en.json"] === "string") {
|
|
@@ -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
|
|
407
|
-
if (o && typeof o === "object" && !Array.isArray(o)) for (const [k, v] of Object.entries(o))
|
|
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
|
-
|
|
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
|
|
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() && !
|
|
444
|
+
} else if (f.value.trim() && !plain2) plain2 = f;
|
|
437
445
|
}
|
|
438
|
-
if (
|
|
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
|
-
|
|
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
|
|
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) =>
|
|
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))
|
|
699
|
+
if (v && typeof v === "object") for (const [k, x] of Object.entries(v)) walk2(x, k);
|
|
691
700
|
};
|
|
692
|
-
|
|
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;
|
|
@@ -720,40 +729,2171 @@ var require_editability = __commonJS({
|
|
|
720
729
|
const list = [...found.entries()];
|
|
721
730
|
for (let i = 0; i < list.length; i += concurrency) {
|
|
722
731
|
await Promise.all(list.slice(i, i + concurrency).map(async ([url, where]) => {
|
|
723
|
-
const { line:
|
|
732
|
+
const { line: line3, column } = lineCol(where.src, where.at);
|
|
724
733
|
const r = await ask(url);
|
|
725
734
|
let host = "";
|
|
726
735
|
try {
|
|
727
736
|
host = new URL(url).hostname;
|
|
728
737
|
} catch {
|
|
729
738
|
}
|
|
730
|
-
if (!r.ok) errors.push({ severity: "error", code: "image_not_found", file: where.file, line:
|
|
731
|
-
else if (!STORE_HOST.test(host)) warnings.push({ severity: "warning", code: "image_external", file: where.file, line:
|
|
732
|
-
}));
|
|
739
|
+
if (!r.ok) errors.push({ severity: "error", code: "image_not_found", file: where.file, line: line3, column, message: `The image ${url.slice(0, 100)} ${r.why}: the page would show an empty frame.`, fix: "Never guess an image address. Upload the picture with theme_upload_asset (or choose one of the store's files) and use the URL it returns." });
|
|
740
|
+
else if (!STORE_HOST.test(host)) warnings.push({ severity: "warning", code: "image_external", file: where.file, line: line3, column, message: `The image ${url.slice(0, 100)} is on another site (${host}): it can change or disappear.`, fix: "Upload it with theme_upload_asset and use the store file URL it returns." });
|
|
741
|
+
}));
|
|
742
|
+
}
|
|
743
|
+
const sort = (a, b) => (a.file + a.line).localeCompare(b.file + b.line);
|
|
744
|
+
errors.sort(sort);
|
|
745
|
+
warnings.sort(sort);
|
|
746
|
+
return { ok: errors.length === 0, errors, warnings, checked: list.length };
|
|
747
|
+
}
|
|
748
|
+
function formatEditability(result) {
|
|
749
|
+
return [...result.errors, ...result.warnings].map((f) => `${f.file}:${f.line}:${f.column} ${f.severity} ${f.code} ${f.message}${f.fix ? ` Fix: ${f.fix}` : ""}`).join("\n");
|
|
750
|
+
}
|
|
751
|
+
module2.exports = { checkEditability: checkEditability2, checkImageLinks: checkImageLinks2, formatEditability, scanTsx: scan, STRUCTURAL_LINK };
|
|
752
|
+
}
|
|
753
|
+
});
|
|
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
|
+
|
|
870
|
+
// ../theme-standard/lib/source.js
|
|
871
|
+
var require_source = __commonJS({
|
|
872
|
+
"../theme-standard/lib/source.js"(exports2, module2) {
|
|
873
|
+
"use strict";
|
|
874
|
+
var MiB = 1024 * 1024;
|
|
875
|
+
var SOURCE_LIMITS3 = Object.freeze({
|
|
876
|
+
/** partnerThemeVersionCreate's multipart file (api-central). */
|
|
877
|
+
uploadBytes: 20 * MiB,
|
|
878
|
+
maxEntries: 1e4,
|
|
879
|
+
maxUnpackedBytes: 64 * MiB,
|
|
880
|
+
maxFileBytes: 8 * MiB,
|
|
881
|
+
maxArchiveBytes: 100 * MiB,
|
|
882
|
+
/** unpacked / compressed, checked once `ratioCheckAfterBytes` of archive have been read */
|
|
883
|
+
maxCompressionRatio: 100,
|
|
884
|
+
ratioCheckAfterBytes: 4 * MiB
|
|
885
|
+
});
|
|
886
|
+
var DENY_BASENAMES = Object.freeze([".npmrc", ".pnpmfile.cjs", "pnpm-workspace.yaml"]);
|
|
887
|
+
var DENY_SEGMENTS = Object.freeze(["node_modules", ".git", ".github", ".husky"]);
|
|
888
|
+
var basename2 = (path) => path.slice(path.lastIndexOf("/") + 1);
|
|
889
|
+
function denyReason3(path) {
|
|
890
|
+
const base = basename2(path);
|
|
891
|
+
for (const seg of path.split("/")) if (DENY_SEGMENTS.includes(seg)) return `${seg}/ is not accepted`;
|
|
892
|
+
if (DENY_BASENAMES.includes(base)) return `${base} is rejected (pnpm/npm configuration is platform-owned)`;
|
|
893
|
+
if (base.startsWith(".yarnrc")) return `${base} is rejected (yarn configuration is platform-owned)`;
|
|
894
|
+
if (base.startsWith("Dockerfile")) return "Dockerfiles are rejected";
|
|
895
|
+
if (base.startsWith(".env")) return "environment files are rejected";
|
|
896
|
+
if (base.endsWith(".sh")) return "shell scripts are rejected";
|
|
897
|
+
if (base.endsWith(".node")) return "native addons are rejected";
|
|
898
|
+
if (base.endsWith(".wasm") && !path.startsWith("assets/")) return "wasm outside assets/ is rejected";
|
|
899
|
+
return null;
|
|
900
|
+
}
|
|
901
|
+
var DENIED_NAMES = Object.freeze([".npmrc", ".pnpmfile.cjs", "pnpm-workspace.yaml", ".yarnrc*", ".env*", "Dockerfile*", "*.sh", "*.node", "*.wasm outside assets/"]);
|
|
902
|
+
function denyFix2(path) {
|
|
903
|
+
const base = basename2(path);
|
|
904
|
+
if (DENY_BASENAMES.includes(base) || base.startsWith(".yarnrc"))
|
|
905
|
+
return `Delete ${path}: the builder uses its own package manager settings. Nothing in your theme needs it at build time.`;
|
|
906
|
+
if (base.startsWith(".env")) return `Delete ${path} from the upload and keep secrets out of the theme: a storefront theme has no secrets.`;
|
|
907
|
+
if (base.startsWith("Dockerfile")) return `Delete ${path}: the platform builds the theme with its own image.`;
|
|
908
|
+
if (base.endsWith(".sh")) return `Delete ${path}, or rewrite what it does in your build file (a .mjs run with node).`;
|
|
909
|
+
if (base.endsWith(".node")) return `Delete ${path}: native addons cannot run in the sandbox or on the storefront.`;
|
|
910
|
+
if (base.endsWith(".wasm")) return `Move ${path} under assets/, the only place a .wasm file may be.`;
|
|
911
|
+
return `Delete ${path} from the upload.`;
|
|
912
|
+
}
|
|
913
|
+
var THEME_SOURCE_FILES = Object.freeze(["package.json", "pnpm-lock.yaml", "manifest.json"]);
|
|
914
|
+
var THEME_SOURCE_PREFIXES = Object.freeze(["src/", "sections/", "templates/", "layouts/", "assets/", "locales/", "config/"]);
|
|
915
|
+
var THEME_SOURCE_PATTERNS = Object.freeze([/^README[^/]*$/, /^LICENSE[^/]*$/]);
|
|
916
|
+
function isThemeSourcePath2(path) {
|
|
917
|
+
if (THEME_SOURCE_FILES.includes(path)) return true;
|
|
918
|
+
if (THEME_SOURCE_PREFIXES.some((p) => path.startsWith(p))) return true;
|
|
919
|
+
return THEME_SOURCE_PATTERNS.some((re) => re.test(path));
|
|
920
|
+
}
|
|
921
|
+
var THEME_SOURCE_LAYOUT2 = `${THEME_SOURCE_FILES.join(", ")}, README*, LICENSE* and the folders ${THEME_SOURCE_PREFIXES.join(" ")}`;
|
|
922
|
+
var STARTER_DEFAULT_BUILDS = Object.freeze(["scripts/abi/build.mjs", "scripts/build.mjs"]);
|
|
923
|
+
var STARTER_DEFAULT_OUT = "dist/abi";
|
|
924
|
+
var STARTER_PATH_RE = /^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;
|
|
925
|
+
var STARTER_IGNORED_FOLDERS = Object.freeze([
|
|
926
|
+
"tests",
|
|
927
|
+
".github",
|
|
928
|
+
".vscode",
|
|
929
|
+
".claude",
|
|
930
|
+
".codex",
|
|
931
|
+
".gemini",
|
|
932
|
+
".cursor",
|
|
933
|
+
".agents",
|
|
934
|
+
".idea",
|
|
935
|
+
"__MACOSX",
|
|
936
|
+
".git",
|
|
937
|
+
"node_modules",
|
|
938
|
+
"dist",
|
|
939
|
+
"reports",
|
|
940
|
+
"coverage"
|
|
941
|
+
]);
|
|
942
|
+
var STARTER_IGNORED_FILES = Object.freeze([".mcp.json", "AGENTS.md", "CLAUDE.md", ".gitignore", "_gitignore", ".DS_Store"]);
|
|
943
|
+
function isStarterIgnoredPath3(path) {
|
|
944
|
+
const first = path.split("/")[0];
|
|
945
|
+
const base = basename2(path);
|
|
946
|
+
return STARTER_IGNORED_FOLDERS.includes(first) || base === ".DS_Store" || base.startsWith("._") || // .tanqory/ holds theme inputs (e.g. the Nova fork's frozen contracts); only the dev server's state is dropped
|
|
947
|
+
path.startsWith(".tanqory/dev/") || STARTER_IGNORED_FILES.includes(path);
|
|
948
|
+
}
|
|
949
|
+
function withoutPackFolder3(files) {
|
|
950
|
+
if (files.length === 0 || !files.every((f) => f.path.startsWith("package/") && f.path.length > 8)) return files;
|
|
951
|
+
return files.map((f) => ({ ...f, path: f.path.slice("package/".length) }));
|
|
952
|
+
}
|
|
953
|
+
var textOf = (f) => f.text !== void 0 ? String(f.text) : Buffer.from(f.bytes).toString("utf8");
|
|
954
|
+
function isStarterTree3(files) {
|
|
955
|
+
if (!files.some((f) => f.path === "manifest.json")) return true;
|
|
956
|
+
const paths = new Set(files.map((f) => f.path));
|
|
957
|
+
if (STARTER_DEFAULT_BUILDS.some((b) => paths.has(b))) return true;
|
|
958
|
+
const pkg = files.find((f) => f.path === "package.json");
|
|
959
|
+
if (!pkg) return false;
|
|
960
|
+
try {
|
|
961
|
+
const tq = JSON.parse(textOf(pkg)).tanqory;
|
|
962
|
+
return typeof (tq && tq.build) === "string";
|
|
963
|
+
} catch {
|
|
964
|
+
return false;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
var THIRD_PARTY_PLATFORM_PACKAGES2 = /* @__PURE__ */ new Map([
|
|
968
|
+
["@tanqory/theme-kit", "runtime"],
|
|
969
|
+
["@tanqory/theme-abi", "runtime"],
|
|
970
|
+
["@tanqory/theme-conformance", "runtime"],
|
|
971
|
+
["@tanqory/cli", "dev"],
|
|
972
|
+
["@tanqory/dev-mcp", "dev"]
|
|
973
|
+
]);
|
|
974
|
+
var PLATFORM_PACKAGE_SECTIONS2 = Object.freeze({ runtime: ["dependencies", "devDependencies"], dev: ["devDependencies"] });
|
|
975
|
+
var EXACT_VERSION_RE3 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/;
|
|
976
|
+
var STARTER_PROVIDED_PACKAGES = /* @__PURE__ */ new Set(["react", "react-dom", "vite", "@vitejs/plugin-react"]);
|
|
977
|
+
var STARTER_DEV_TOOLS = Object.freeze(["typescript", "vitest", "jsdom", "axe-core", "playwright", "playwright-core", "@types/*", "@testing-library/*"]);
|
|
978
|
+
function isStarterDevTool(name) {
|
|
979
|
+
return /^(typescript|vitest|jsdom|axe-core|playwright|playwright-core)$/.test(name) || /^@types\/[a-z0-9._-]+$/.test(name) || /^@testing-library\/[a-z0-9._-]+$/.test(name);
|
|
980
|
+
}
|
|
981
|
+
function isPlainRegistryRange2(spec) {
|
|
982
|
+
if (typeof spec !== "string" || spec.length === 0 || spec.length > 128) return false;
|
|
983
|
+
const comparator = /^(?:[<>]=?|=|~|\^)?v?(?:0|[1-9]\d*|[xX*])(?:\.(?:0|[1-9]\d*|[xX*])){0,2}(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
984
|
+
return spec.split("||").every((set) => {
|
|
985
|
+
const parts = set.trim().split(/\s+/);
|
|
986
|
+
if (parts.length === 1 && parts[0] === "") return false;
|
|
987
|
+
if (parts.length === 3 && parts[1] === "-") return comparator.test(parts[0]) && comparator.test(parts[2]);
|
|
988
|
+
return parts.every((p) => comparator.test(p));
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
var DEP_SECTIONS = Object.freeze(["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]);
|
|
992
|
+
function starterPackageProblems3(pkgOrText, paths) {
|
|
993
|
+
const out = [];
|
|
994
|
+
const add = (kind, message, fix, entry) => out.push({ kind, path: "package.json", message, fix, ...entry ? { entry } : {} });
|
|
995
|
+
let pkg = pkgOrText;
|
|
996
|
+
if (typeof pkg === "string") {
|
|
997
|
+
try {
|
|
998
|
+
pkg = JSON.parse(pkg);
|
|
999
|
+
} catch {
|
|
1000
|
+
add("params", "package.json is not valid JSON", "Fix the JSON syntax of package.json.");
|
|
1001
|
+
return { problems: out };
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
if (!pkg || typeof pkg !== "object" || Array.isArray(pkg)) {
|
|
1005
|
+
add("params", "package.json is not valid JSON", "package.json must be one JSON object.");
|
|
1006
|
+
return { problems: out };
|
|
1007
|
+
}
|
|
1008
|
+
if (typeof pkg.name !== "string" || typeof pkg.version !== "string")
|
|
1009
|
+
add("params", 'package.json needs string "name" and "version"', 'Set "name" and "version" in package.json.');
|
|
1010
|
+
for (const key of ["resolutions", "workspaces", "overrides"])
|
|
1011
|
+
if (key in pkg) add("params", `package.json "${key}" is rejected`, `Remove "${key}" from package.json: the builder resolves packages from its own toolchain.`);
|
|
1012
|
+
const pnpm = pkg.pnpm && typeof pkg.pnpm === "object" ? pkg.pnpm : {};
|
|
1013
|
+
for (const key of ["overrides", "patchedDependencies", "onlyBuiltDependencies"])
|
|
1014
|
+
if (key in pnpm) add("params", `package.json "pnpm.${key}" is rejected`, `Remove "pnpm.${key}" from package.json.`);
|
|
1015
|
+
const tq = pkg.tanqory === void 0 ? {} : pkg.tanqory;
|
|
1016
|
+
if (typeof tq !== "object" || tq === null || Array.isArray(tq)) {
|
|
1017
|
+
add("params", 'package.json "tanqory" must be an object', 'Make "tanqory" an object: { "build": "scripts/build.mjs", "out": "dist/abi" }.');
|
|
1018
|
+
return { problems: out };
|
|
1019
|
+
}
|
|
1020
|
+
const build = tq.build !== void 0 ? tq.build : STARTER_DEFAULT_BUILDS.find((b) => paths.has(b)) || STARTER_DEFAULT_BUILDS[1];
|
|
1021
|
+
const outDir = tq.out !== void 0 ? tq.out : STARTER_DEFAULT_OUT;
|
|
1022
|
+
if (typeof build !== "string" || !STARTER_PATH_RE.test(build) || !build.endsWith(".mjs"))
|
|
1023
|
+
add("params", `package.json tanqory.build ${JSON.stringify(build)} must be a relative path to a .mjs file in the theme`, 'Point "tanqory.build" at your build file, e.g. "scripts/build.mjs".');
|
|
1024
|
+
else if (!paths.has(build))
|
|
1025
|
+
out.push({ kind: "params", path: build, message: `the build file ${build} is not in the upload (package.json tanqory.build, or ${STARTER_DEFAULT_BUILDS.join(" / ")})`, fix: `Add ${build} to the theme, or point package.json "tanqory.build" at the build file you have.` });
|
|
1026
|
+
if (typeof outDir !== "string" || !STARTER_PATH_RE.test(outDir))
|
|
1027
|
+
add("params", `package.json tanqory.out ${JSON.stringify(outDir)} must be a relative directory in the theme`, 'Set "tanqory.out" to the folder your build writes, e.g. "dist/abi".');
|
|
1028
|
+
let kit = false;
|
|
1029
|
+
for (const section of DEP_SECTIONS) {
|
|
1030
|
+
const deps = pkg[section] && typeof pkg[section] === "object" ? pkg[section] : {};
|
|
1031
|
+
for (const [name, spec] of Object.entries(deps)) {
|
|
1032
|
+
if (typeof spec !== "string" || !isPlainRegistryRange2(spec)) {
|
|
1033
|
+
add("deps", `package.json ${section}.${name}: ${JSON.stringify(spec)} is not a plain registry version range`, `Give ${name} a registry version such as "1.2.3" or "^1.2.3" (no git, file:, link:, workspace: or URL).`, name);
|
|
1034
|
+
continue;
|
|
1035
|
+
}
|
|
1036
|
+
const platform = THIRD_PARTY_PLATFORM_PACKAGES2.get(name);
|
|
1037
|
+
if (platform) {
|
|
1038
|
+
const allowed = PLATFORM_PACKAGE_SECTIONS2[platform];
|
|
1039
|
+
if (!allowed.includes(section)) add("deps", `package.json ${section}.${name}: ${name} may be named only in ${allowed.join(" or ")}`, `Move ${name} to ${allowed[allowed.length - 1]}.`, name);
|
|
1040
|
+
else if (!EXACT_VERSION_RE3.test(spec)) add("deps", `package.json ${section}.${name}: ${JSON.stringify(spec)} must be an exact version (e.g. "2.0.0-alpha.3"), not a range`, `Pin ${name} to one exact version, without ^ or ~.`, name);
|
|
1041
|
+
if (name === "@tanqory/theme-kit") kit = true;
|
|
1042
|
+
continue;
|
|
1043
|
+
}
|
|
1044
|
+
if (STARTER_PROVIDED_PACKAGES.has(name) && (section === "dependencies" || section === "devDependencies")) continue;
|
|
1045
|
+
if (isStarterDevTool(name) && section === "devDependencies") continue;
|
|
1046
|
+
add(
|
|
1047
|
+
"deps",
|
|
1048
|
+
`package.json ${section}.${name}: the builder does not provide ${name} (a starter build uses the kit, react, react-dom, vite and @vitejs/plugin-react from the builder image)`,
|
|
1049
|
+
isStarterDevTool(name) ? `Move ${name} to devDependencies.` : `Remove ${name}: copy the code you need into src/ (the builder installs nothing).`,
|
|
1050
|
+
name
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
if (!kit) add("deps", "package.json must pin @tanqory/theme-kit exactly: it selects the toolchain the build runs with", 'Add "@tanqory/theme-kit" with one exact version to dependencies.', "@tanqory/theme-kit");
|
|
1055
|
+
return { problems: out, build, out: outDir };
|
|
1056
|
+
}
|
|
1057
|
+
var CHECK_FIXES = Object.freeze({
|
|
1058
|
+
ingest_gate: "Change the file the finding names: see what an upload may hold (docs.<root>/themes/source/), then upload a new version.",
|
|
1059
|
+
sandbox_build: "Pin @tanqory/theme-kit and @tanqory/theme-abi exactly to versions the builder carries, and make the build write the same files every time (no dates, random names or absolute paths), then upload a new version.",
|
|
1060
|
+
source_text: "Use your theme's own words in every file name and text file: no other commerce platform's name.",
|
|
1061
|
+
editability: "Make every word, image, link and list a shopper sees a setting or a block, with labels in English (the finding's Fix says how).",
|
|
1062
|
+
manifest: "Fix the declaration in src/ the manifest is built from, build again and upload the new manifest.json with a new version.",
|
|
1063
|
+
manifest_brand_term: "Use your theme's own words in that label.",
|
|
1064
|
+
manifest_emoji: "Use words instead of the emoji in that label.",
|
|
1065
|
+
no_eval: "Remove eval, new Function and string timers from the client code: pass functions.",
|
|
1066
|
+
licences: "Ship a LICENSE file (copied into the build output), and use only packages whose licence is on the allowed list.",
|
|
1067
|
+
entry_scan: "Bundle everything server/entry.mjs and preview/entry.mjs import into them: one file each, zero imports.",
|
|
1068
|
+
abi_conformance: "Run the ABI conformance suites locally (tanqory-partner theme check --conformance) and fix each failing case.",
|
|
1069
|
+
network_allowlist: "Declare every outside origin the theme calls as a network:<https origin> capability, and call no other.",
|
|
1070
|
+
budgets: "Make the theme smaller and faster: split the client code, drop unused code and assets, fewer data calls per render.",
|
|
1071
|
+
accessibility: "Fix each serious or critical axe-core finding (labels, contrast, landmarks) on home, product and collection pages.",
|
|
1072
|
+
preview_renders: "Make every route and section preview render on the three sample stores (small, large, right to left) without an error."
|
|
1073
|
+
});
|
|
1074
|
+
module2.exports = {
|
|
1075
|
+
SOURCE_LIMITS: SOURCE_LIMITS3,
|
|
1076
|
+
DENY_BASENAMES,
|
|
1077
|
+
DENY_SEGMENTS,
|
|
1078
|
+
DENIED_NAMES,
|
|
1079
|
+
denyReason: denyReason3,
|
|
1080
|
+
denyFix: denyFix2,
|
|
1081
|
+
THEME_SOURCE_FILES,
|
|
1082
|
+
THEME_SOURCE_PREFIXES,
|
|
1083
|
+
THEME_SOURCE_PATTERNS,
|
|
1084
|
+
THEME_SOURCE_LAYOUT: THEME_SOURCE_LAYOUT2,
|
|
1085
|
+
isThemeSourcePath: isThemeSourcePath2,
|
|
1086
|
+
STARTER_DEFAULT_BUILDS,
|
|
1087
|
+
STARTER_DEFAULT_OUT,
|
|
1088
|
+
STARTER_PATH_RE,
|
|
1089
|
+
STARTER_IGNORED_FOLDERS,
|
|
1090
|
+
STARTER_IGNORED_FILES,
|
|
1091
|
+
isStarterIgnoredPath: isStarterIgnoredPath3,
|
|
1092
|
+
withoutPackFolder: withoutPackFolder3,
|
|
1093
|
+
isStarterTree: isStarterTree3,
|
|
1094
|
+
THIRD_PARTY_PLATFORM_PACKAGES: THIRD_PARTY_PLATFORM_PACKAGES2,
|
|
1095
|
+
PLATFORM_PACKAGE_SECTIONS: PLATFORM_PACKAGE_SECTIONS2,
|
|
1096
|
+
EXACT_VERSION_RE: EXACT_VERSION_RE3,
|
|
1097
|
+
STARTER_PROVIDED_PACKAGES,
|
|
1098
|
+
STARTER_DEV_TOOLS,
|
|
1099
|
+
isStarterDevTool,
|
|
1100
|
+
isPlainRegistryRange: isPlainRegistryRange2,
|
|
1101
|
+
starterPackageProblems: starterPackageProblems3,
|
|
1102
|
+
CHECK_FIXES
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
// ../theme-standard/lib/text-rules.js
|
|
1108
|
+
var require_text_rules = __commonJS({
|
|
1109
|
+
"../theme-standard/lib/text-rules.js"(exports2, module2) {
|
|
1110
|
+
"use strict";
|
|
1111
|
+
var BRAND_RE = new RegExp(Buffer.from("c2hvcGlmeQ==", "base64").toString(), "i");
|
|
1112
|
+
var EMOJI = /([\p{Extended_Pictographic}\u{1F1E6}-\u{1F1FF}])(\u{FE0F})?/gu;
|
|
1113
|
+
var TEXT_FORM_ALLOWED = /* @__PURE__ */ new Set(["\xA9", "\xAE", "\u2122"]);
|
|
1114
|
+
var LABEL_KEYS = /* @__PURE__ */ new Set(["name", "title", "label", "info", "placeholder", "description"]);
|
|
1115
|
+
var namesBrandTerm2 = (text) => BRAND_RE.test(text);
|
|
1116
|
+
var brandTermIndex = (text) => text.search(BRAND_RE);
|
|
1117
|
+
function firstEmoji(text) {
|
|
1118
|
+
for (const m of text.matchAll(EMOJI)) {
|
|
1119
|
+
const [, ch, vs] = m;
|
|
1120
|
+
if (!vs && TEXT_FORM_ALLOWED.has(ch)) continue;
|
|
1121
|
+
return `U+${ch.codePointAt(0).toString(16).toUpperCase().padStart(4, "0")}`;
|
|
1122
|
+
}
|
|
1123
|
+
return null;
|
|
1124
|
+
}
|
|
1125
|
+
var hasEmoji2 = (text) => firstEmoji(text) !== null;
|
|
1126
|
+
function textFindings(entries) {
|
|
1127
|
+
const out = [];
|
|
1128
|
+
for (const [path, text] of entries) {
|
|
1129
|
+
if (namesBrandTerm2(text)) out.push({ rule: "brand_term", path, message: "Names another commerce platform. Use your theme's own words." });
|
|
1130
|
+
const e = firstEmoji(text);
|
|
1131
|
+
if (e) out.push({ rule: "emoji", path, message: `Contains an emoji (${e}). Use words; Tanqory's editor and Theme Store show no emoji.` });
|
|
1132
|
+
}
|
|
1133
|
+
return out;
|
|
1134
|
+
}
|
|
1135
|
+
function manifestLabels2(manifest) {
|
|
1136
|
+
const out = [];
|
|
1137
|
+
const walk2 = (v, path, key) => {
|
|
1138
|
+
if (out.length >= 1e4) return;
|
|
1139
|
+
if (typeof v === "string") {
|
|
1140
|
+
if (key !== null && LABEL_KEYS.has(key)) out.push([path || "/", v]);
|
|
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);
|
|
1143
|
+
};
|
|
1144
|
+
walk2(manifest, "", null);
|
|
1145
|
+
return out;
|
|
1146
|
+
}
|
|
1147
|
+
function sourceTextFindings2(files, max = 50) {
|
|
1148
|
+
const out = [];
|
|
1149
|
+
for (const [path, bytes] of files) {
|
|
1150
|
+
if (out.length >= max) break;
|
|
1151
|
+
const buf = Buffer.from(bytes);
|
|
1152
|
+
if (namesBrandTerm2(path)) {
|
|
1153
|
+
out.push({ path, code: "brand_term", message: `The file name ${path} names another commerce platform. Rename it.` });
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1156
|
+
if (buf.subarray(0, 8192).includes(0)) continue;
|
|
1157
|
+
const text = buf.toString("utf8");
|
|
1158
|
+
const i = brandTermIndex(text);
|
|
1159
|
+
if (i >= 0) {
|
|
1160
|
+
const line3 = text.slice(0, i).split("\n").length;
|
|
1161
|
+
out.push({ path: `${path}:${line3}`, code: "brand_term", message: `${path} line ${line3} names another commerce platform. Use your theme's own words.` });
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
return out;
|
|
1165
|
+
}
|
|
1166
|
+
module2.exports = { LABEL_KEYS, namesBrandTerm: namesBrandTerm2, brandTermIndex, firstEmoji, hasEmoji: hasEmoji2, textFindings, manifestLabels: manifestLabels2, sourceTextFindings: sourceTextFindings2 };
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
// ../../apps/build-service/src/review/partner-source.ts
|
|
1171
|
+
var partner_source_exports = {};
|
|
1172
|
+
__export(partner_source_exports, {
|
|
1173
|
+
SOURCE_LIMITS: () => import_source3.SOURCE_LIMITS,
|
|
1174
|
+
budgetsLine: () => budgetsLine,
|
|
1175
|
+
checkPartnerSource: () => checkPartnerSource,
|
|
1176
|
+
denyFix: () => import_source3.denyFix,
|
|
1177
|
+
denyReason: () => import_source3.denyReason,
|
|
1178
|
+
editabilityLine: () => editabilityLine,
|
|
1179
|
+
entryScanLine: () => entryScanLine,
|
|
1180
|
+
isStarterIgnoredPath: () => import_source3.isStarterIgnoredPath,
|
|
1181
|
+
isStarterTree: () => import_source3.isStarterTree,
|
|
1182
|
+
localSandboxLines: () => localSandboxLines,
|
|
1183
|
+
networkLine: () => networkLine,
|
|
1184
|
+
reproducibleLine: () => reproducibleLine,
|
|
1185
|
+
starterPackageProblems: () => import_source3.starterPackageProblems,
|
|
1186
|
+
treeDigest: () => treeDigest,
|
|
1187
|
+
withoutPackFolder: () => import_source3.withoutPackFolder
|
|
1188
|
+
});
|
|
1189
|
+
module.exports = __toCommonJS(partner_source_exports);
|
|
1190
|
+
var import_node_fs4 = require("node:fs");
|
|
1191
|
+
var import_node_path4 = require("node:path");
|
|
1192
|
+
var import_node_stream = require("node:stream");
|
|
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
|
+
}
|
|
733
2667
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
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);
|
|
738
2687
|
}
|
|
739
|
-
|
|
740
|
-
|
|
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
|
+
);
|
|
741
2695
|
}
|
|
742
|
-
module2.exports = { checkEditability: checkEditability2, checkImageLinks: checkImageLinks2, formatEditability, scanTsx: scan, STRUCTURAL_LINK };
|
|
743
2696
|
}
|
|
744
|
-
}
|
|
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
|
+
}
|
|
745
2895
|
|
|
746
2896
|
// ../../apps/build-service/src/review/partner-source.ts
|
|
747
|
-
var partner_source_exports = {};
|
|
748
|
-
__export(partner_source_exports, {
|
|
749
|
-
checkPartnerSource: () => checkPartnerSource,
|
|
750
|
-
editabilityLine: () => editabilityLine
|
|
751
|
-
});
|
|
752
|
-
module.exports = __toCommonJS(partner_source_exports);
|
|
753
|
-
var import_node_fs4 = require("node:fs");
|
|
754
|
-
var import_node_path4 = require("node:path");
|
|
755
|
-
var import_node_stream = require("node:stream");
|
|
756
|
-
var import_theme_abi2 = require("@tanqory/theme-abi");
|
|
757
2897
|
var import_editability = __toESM(require_editability());
|
|
758
2898
|
|
|
759
2899
|
// ../../apps/build-service/src/artifact/digest.ts
|
|
@@ -770,9 +2910,9 @@ function sha256Digest(bytes) {
|
|
|
770
2910
|
var import_yaml = require("yaml");
|
|
771
2911
|
|
|
772
2912
|
// ../../apps/build-service/src/artifact/canonical-json.ts
|
|
773
|
-
var jcs =
|
|
774
|
-
var
|
|
775
|
-
var
|
|
2913
|
+
var jcs = (init_jcs(), __toCommonJS(jcs_exports));
|
|
2914
|
+
var CanonicalJsonError2 = jcs.CanonicalJsonError;
|
|
2915
|
+
var CANONICAL_JSON_MAX_DEPTH2 = jcs.CANONICAL_JSON_MAX_DEPTH;
|
|
776
2916
|
function canonicalize(value) {
|
|
777
2917
|
return jcs.canonicalJson(value);
|
|
778
2918
|
}
|
|
@@ -1111,6 +3251,7 @@ function allowlistProblem(allowlist, name, version, integrity) {
|
|
|
1111
3251
|
// ../../apps/build-service/src/config/third-party.ts
|
|
1112
3252
|
var import_node_fs2 = require("node:fs");
|
|
1113
3253
|
var import_node_path2 = require("node:path");
|
|
3254
|
+
var import_source = __toESM(require_source());
|
|
1114
3255
|
|
|
1115
3256
|
// ../../apps/build-service/src/config/first-party-themes.ts
|
|
1116
3257
|
var FIRST_PARTY_THEMES = Object.freeze([
|
|
@@ -1141,14 +3282,6 @@ var FIRST_PARTY_THEMES = Object.freeze([
|
|
|
1141
3282
|
]);
|
|
1142
3283
|
|
|
1143
3284
|
// ../../apps/build-service/src/config/third-party.ts
|
|
1144
|
-
var THIRD_PARTY_PLATFORM_PACKAGES = /* @__PURE__ */ new Map([
|
|
1145
|
-
["@tanqory/theme-kit", "runtime"],
|
|
1146
|
-
["@tanqory/theme-abi", "runtime"],
|
|
1147
|
-
["@tanqory/theme-conformance", "runtime"],
|
|
1148
|
-
["@tanqory/cli", "dev"],
|
|
1149
|
-
["@tanqory/dev-mcp", "dev"]
|
|
1150
|
-
]);
|
|
1151
|
-
var EXACT_VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/;
|
|
1152
3285
|
var THIRD_PARTY_TOOLCHAINS_PATH = (0, import_node_path2.join)(
|
|
1153
3286
|
__dirname,
|
|
1154
3287
|
"..",
|
|
@@ -1161,11 +3294,17 @@ function loadThirdPartyKits(path = THIRD_PARTY_TOOLCHAINS_PATH) {
|
|
|
1161
3294
|
if (!Array.isArray(doc.kits) || doc.kits.length === 0)
|
|
1162
3295
|
throw new Error(`${path}: kits must be a non-empty list`);
|
|
1163
3296
|
const seen = /* @__PURE__ */ new Set();
|
|
1164
|
-
|
|
1165
|
-
if (typeof k.version !== "string" || !EXACT_VERSION_RE.test(k.version) || !k.version.startsWith("2."))
|
|
3297
|
+
const kits = doc.kits.map((k) => {
|
|
3298
|
+
if (typeof k.version !== "string" || !import_source.EXACT_VERSION_RE.test(k.version) || !k.version.startsWith("2."))
|
|
1166
3299
|
throw new Error(`${path}: ${JSON.stringify(k.version)} is not an exact 2.x version`);
|
|
1167
3300
|
if (seen.has(k.version)) throw new Error(`${path}: ${k.version} is listed twice`);
|
|
1168
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
|
+
}
|
|
1169
3308
|
if ("pack" in k) {
|
|
1170
3309
|
if (k.pack !== `tanqory-theme-kit-${k.version}.tgz`)
|
|
1171
3310
|
throw new Error(`${path}: ${k.version} pack must be tanqory-theme-kit-${k.version}.tgz`);
|
|
@@ -1179,38 +3318,18 @@ function loadThirdPartyKits(path = THIRD_PARTY_TOOLCHAINS_PATH) {
|
|
|
1179
3318
|
throw new Error(`${path}: ${k.version} has no sha512 integrity`);
|
|
1180
3319
|
return { version: k.version, gitHead: k.gitHead, integrity: k.integrity };
|
|
1181
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;
|
|
1182
3325
|
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
"react",
|
|
1189
|
-
"react-dom",
|
|
1190
|
-
"vite",
|
|
1191
|
-
"@vitejs/plugin-react"
|
|
1192
|
-
]);
|
|
1193
|
-
function isStarterDevTool(name) {
|
|
1194
|
-
return /^(typescript|vitest|jsdom|axe-core|playwright|playwright-core)$/.test(name) || /^@types\/[a-z0-9._-]+$/.test(name) || /^@testing-library\/[a-z0-9._-]+$/.test(name);
|
|
1195
|
-
}
|
|
1196
|
-
function isStarterIgnoredPath(path) {
|
|
1197
|
-
const first = path.split("/")[0];
|
|
1198
|
-
return [
|
|
1199
|
-
"tests",
|
|
1200
|
-
".github",
|
|
1201
|
-
".vscode",
|
|
1202
|
-
".claude",
|
|
1203
|
-
".codex",
|
|
1204
|
-
".gemini",
|
|
1205
|
-
".cursor",
|
|
1206
|
-
".git",
|
|
1207
|
-
"node_modules",
|
|
1208
|
-
"dist",
|
|
1209
|
-
"reports",
|
|
1210
|
-
"coverage"
|
|
1211
|
-
].includes(first) || // .tanqory/ holds theme inputs (e.g. the Nova fork's frozen contracts); only the dev server's state is dropped
|
|
1212
|
-
path.startsWith(".tanqory/dev/") || [".mcp.json", "AGENTS.md", "CLAUDE.md", ".gitignore", "_gitignore", ".DS_Store"].includes(path);
|
|
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] };
|
|
1213
3331
|
}
|
|
3332
|
+
var STARTER_ABI_VERSION = "2.0";
|
|
1214
3333
|
|
|
1215
3334
|
// ../../apps/build-service/src/ingest/archive-guard.ts
|
|
1216
3335
|
var import_node_crypto3 = require("node:crypto");
|
|
@@ -1282,6 +3401,7 @@ function relativePathProblem(path, opts = {}) {
|
|
|
1282
3401
|
|
|
1283
3402
|
// ../../apps/build-service/src/artifact/inline-scripts.ts
|
|
1284
3403
|
var INLINE_SCRIPT_SOURCE = /^src\/inline\/[^/]+\.js$/;
|
|
3404
|
+
var INLINE_IMPORT_MAP_REFUSED = "inline_import_map_refused";
|
|
1285
3405
|
function inlineScriptProblem(bytes) {
|
|
1286
3406
|
const text = Buffer.from(bytes).toString("utf8");
|
|
1287
3407
|
if (!Buffer.from(text, "utf8").equals(Buffer.from(bytes)) || text.charCodeAt(0) === 65279)
|
|
@@ -1291,9 +3411,15 @@ function inlineScriptProblem(bytes) {
|
|
|
1291
3411
|
if (text.includes("<!--")) return 'must not contain "<!--" (HTML script-data escape)';
|
|
1292
3412
|
return null;
|
|
1293
3413
|
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
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
|
+
}
|
|
1297
3423
|
|
|
1298
3424
|
// ../../apps/build-service/src/artifact/files.ts
|
|
1299
3425
|
function leafOf(file) {
|
|
@@ -1304,28 +3430,16 @@ function leavesOf(files) {
|
|
|
1304
3430
|
}
|
|
1305
3431
|
|
|
1306
3432
|
// ../../apps/build-service/src/ingest/ingest-gate.ts
|
|
3433
|
+
var import_source2 = __toESM(require_source());
|
|
1307
3434
|
var INGEST_LIMITS = Object.freeze({
|
|
1308
|
-
maxEntries:
|
|
1309
|
-
maxUnpackedBytes:
|
|
1310
|
-
maxFileBytes:
|
|
1311
|
-
maxArchiveBytes:
|
|
3435
|
+
maxEntries: import_source2.SOURCE_LIMITS.maxEntries,
|
|
3436
|
+
maxUnpackedBytes: import_source2.SOURCE_LIMITS.maxUnpackedBytes,
|
|
3437
|
+
maxFileBytes: import_source2.SOURCE_LIMITS.maxFileBytes,
|
|
3438
|
+
maxArchiveBytes: import_source2.SOURCE_LIMITS.maxArchiveBytes,
|
|
1312
3439
|
/** unpacked / compressed, checked once ≥ ratioCheckAfterBytes of archive have been read */
|
|
1313
|
-
maxCompressionRatio:
|
|
1314
|
-
ratioCheckAfterBytes:
|
|
3440
|
+
maxCompressionRatio: import_source2.SOURCE_LIMITS.maxCompressionRatio,
|
|
3441
|
+
ratioCheckAfterBytes: import_source2.SOURCE_LIMITS.ratioCheckAfterBytes
|
|
1315
3442
|
});
|
|
1316
|
-
var DENY_BASENAMES = /* @__PURE__ */ new Set([".npmrc", ".pnpmfile.cjs", "pnpm-workspace.yaml"]);
|
|
1317
|
-
var DENY_SEGMENTS = /* @__PURE__ */ new Set(["node_modules", ".git", ".github", ".husky"]);
|
|
1318
|
-
var ALLOW_FILES = /* @__PURE__ */ new Set(["package.json", "pnpm-lock.yaml", "manifest.json"]);
|
|
1319
|
-
var ALLOW_PREFIXES = [
|
|
1320
|
-
"src/",
|
|
1321
|
-
"sections/",
|
|
1322
|
-
"templates/",
|
|
1323
|
-
"layouts/",
|
|
1324
|
-
"assets/",
|
|
1325
|
-
"locales/",
|
|
1326
|
-
"config/"
|
|
1327
|
-
];
|
|
1328
|
-
var ALLOW_PATTERNS = [/^README[^/]*$/, /^LICENSE[^/]*$/];
|
|
1329
3443
|
var FLATTENED_PREFIXES = ["locales/", "config/templates/", "config/regions/"];
|
|
1330
3444
|
var TOOLCHAIN_EXACT = /* @__PURE__ */ new Set([
|
|
1331
3445
|
"vite",
|
|
@@ -1343,48 +3457,10 @@ var VITE_IMPORT_ALLOW = [/^vite$/, /^@tanqory\/vite-plugin-[a-z0-9-]+$/, /^node:
|
|
|
1343
3457
|
function isToolchainPackage(name) {
|
|
1344
3458
|
return TOOLCHAIN_EXACT.has(name) || TOOLCHAIN_PREFIXES.some((p) => name.startsWith(p));
|
|
1345
3459
|
}
|
|
1346
|
-
var PLATFORM_PACKAGE_SECTIONS = {
|
|
1347
|
-
runtime: ["dependencies", "devDependencies"],
|
|
1348
|
-
dev: ["devDependencies"]
|
|
1349
|
-
};
|
|
1350
3460
|
function basename(path) {
|
|
1351
3461
|
return path.slice(path.lastIndexOf("/") + 1);
|
|
1352
3462
|
}
|
|
1353
|
-
function denyReason(path) {
|
|
1354
|
-
const base = basename(path);
|
|
1355
|
-
const segments = path.split("/");
|
|
1356
|
-
for (const seg of segments) {
|
|
1357
|
-
if (DENY_SEGMENTS.has(seg)) return `${seg}/ is not accepted`;
|
|
1358
|
-
}
|
|
1359
|
-
if (DENY_BASENAMES.has(base))
|
|
1360
|
-
return `${base} is rejected (pnpm/npm configuration is platform-owned)`;
|
|
1361
|
-
if (base.startsWith(".yarnrc"))
|
|
1362
|
-
return `${base} is rejected (yarn configuration is platform-owned)`;
|
|
1363
|
-
if (base.startsWith("Dockerfile")) return "Dockerfiles are rejected";
|
|
1364
|
-
if (base.startsWith(".env")) return "environment files are rejected";
|
|
1365
|
-
if (base.endsWith(".sh")) return "shell scripts are rejected";
|
|
1366
|
-
if (base.endsWith(".node")) return "native addons are rejected";
|
|
1367
|
-
if (base.endsWith(".wasm") && !path.startsWith("assets/"))
|
|
1368
|
-
return "wasm outside assets/ is rejected";
|
|
1369
|
-
return null;
|
|
1370
|
-
}
|
|
1371
|
-
function isAllowed(path) {
|
|
1372
|
-
if (ALLOW_FILES.has(path)) return true;
|
|
1373
|
-
if (ALLOW_PREFIXES.some((p) => path.startsWith(p))) return true;
|
|
1374
|
-
return ALLOW_PATTERNS.some((re) => re.test(path));
|
|
1375
|
-
}
|
|
1376
3463
|
var IMPORT_SPECIFIER_RE = /(?:\bimport\s*(?:[\w*{}\s,$]*\bfrom\s*)?|\bexport\s+[\w*{}\s,$]*\bfrom\s*|\brequire\s*\(\s*|\bimport\s*\(\s*)['"]([^'"]+)['"]/g;
|
|
1377
|
-
function isPlainRegistryRange(spec) {
|
|
1378
|
-
if (typeof spec !== "string" || spec.length === 0 || spec.length > 128) return false;
|
|
1379
|
-
const comparator = /^(?:[<>]=?|=|~|\^)?v?(?:0|[1-9]\d*|[xX*])(?:\.(?:0|[1-9]\d*|[xX*])){0,2}(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1380
|
-
return spec.split("||").every((set) => {
|
|
1381
|
-
const parts = set.trim().split(/\s+/);
|
|
1382
|
-
if (parts.length === 1 && parts[0] === "") return false;
|
|
1383
|
-
if (parts.length === 3 && parts[1] === "-")
|
|
1384
|
-
return comparator.test(parts[0]) && comparator.test(parts[2]);
|
|
1385
|
-
return parts.every((p) => comparator.test(p));
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1388
3464
|
function registryVersionOf(version) {
|
|
1389
3465
|
const m = /^(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(\(.+\))*$/.exec(version);
|
|
1390
3466
|
return m ? m[1] : void 0;
|
|
@@ -1409,9 +3485,9 @@ var IngestGate = class {
|
|
|
1409
3485
|
constructor(opts) {
|
|
1410
3486
|
this.opts = opts;
|
|
1411
3487
|
}
|
|
1412
|
-
inspect(
|
|
1413
|
-
|
|
1414
|
-
|
|
3488
|
+
inspect(raw) {
|
|
3489
|
+
const input = this.opts.thirdParty ? (0, import_source2.withoutPackFolder)(raw) : raw;
|
|
3490
|
+
if (this.opts.thirdParty && (0, import_source2.isStarterTree)(input)) return this.inspectStarter(input);
|
|
1415
3491
|
const files = sortLeaves(input);
|
|
1416
3492
|
if (files.length > INGEST_LIMITS.maxEntries) {
|
|
1417
3493
|
throw new IngestRejectedError(
|
|
@@ -1448,7 +3524,7 @@ var IngestGate = class {
|
|
|
1448
3524
|
if (seen.has(f.path))
|
|
1449
3525
|
throw new IngestRejectedError("params", `duplicate path ${f.path}`, f.path);
|
|
1450
3526
|
seen.add(f.path);
|
|
1451
|
-
const deny = denyReason(f.path);
|
|
3527
|
+
const deny = (0, import_source2.denyReason)(f.path);
|
|
1452
3528
|
if (deny) throw new IngestRejectedError("params", `${f.path}: ${deny}`, f.path);
|
|
1453
3529
|
const base = basename(f.path);
|
|
1454
3530
|
if (/^vite(st)?\.config\./.test(base)) {
|
|
@@ -1461,10 +3537,10 @@ var IngestGate = class {
|
|
|
1461
3537
|
);
|
|
1462
3538
|
}
|
|
1463
3539
|
}
|
|
1464
|
-
if (!
|
|
3540
|
+
if (!(0, import_source2.isThemeSourcePath)(f.path)) {
|
|
1465
3541
|
throw new IngestRejectedError(
|
|
1466
3542
|
"params",
|
|
1467
|
-
`${f.path} is outside the accepted source layout`,
|
|
3543
|
+
this.opts.thirdParty ? `${f.path} is outside the accepted source layout. A theme with manifest.json at its root and no build file of its own takes only ${import_source2.THEME_SOURCE_LAYOUT}. A theme with its own build file (package.json "tanqory.build", e.g. scripts/build.mjs, as create-tanqory-theme and tanqory-partner theme init make it) is built by that file and takes its whole folder.` : `${f.path} is outside the accepted source layout`,
|
|
1468
3544
|
f.path
|
|
1469
3545
|
);
|
|
1470
3546
|
}
|
|
@@ -1476,6 +3552,13 @@ var IngestGate = class {
|
|
|
1476
3552
|
`inline script ${f.path} ${inlineProblem}`,
|
|
1477
3553
|
f.path
|
|
1478
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
|
+
);
|
|
1479
3562
|
}
|
|
1480
3563
|
}
|
|
1481
3564
|
this.checkCollisions(files);
|
|
@@ -1517,7 +3600,9 @@ var IngestGate = class {
|
|
|
1517
3600
|
* - no manifest.json: the build writes it, and the platform checks the build's output.
|
|
1518
3601
|
*/
|
|
1519
3602
|
inspectStarter(input) {
|
|
1520
|
-
const files = sortLeaves(
|
|
3603
|
+
const files = sortLeaves(
|
|
3604
|
+
input.filter((f) => f.path !== "manifest.json" && !(0, import_source2.isStarterIgnoredPath)(f.path))
|
|
3605
|
+
);
|
|
1521
3606
|
if (files.length > INGEST_LIMITS.maxEntries)
|
|
1522
3607
|
throw new IngestRejectedError(
|
|
1523
3608
|
"size",
|
|
@@ -1543,7 +3628,7 @@ var IngestGate = class {
|
|
|
1543
3628
|
if (seen.has(f.path))
|
|
1544
3629
|
throw new IngestRejectedError("params", `duplicate path ${f.path}`, f.path);
|
|
1545
3630
|
seen.add(f.path);
|
|
1546
|
-
const deny = denyReason(f.path);
|
|
3631
|
+
const deny = (0, import_source2.denyReason)(f.path);
|
|
1547
3632
|
if (deny) throw new IngestRejectedError("params", `${f.path}: ${deny}`, f.path);
|
|
1548
3633
|
}
|
|
1549
3634
|
if (total > INGEST_LIMITS.maxUnpackedBytes)
|
|
@@ -1589,99 +3674,17 @@ var IngestGate = class {
|
|
|
1589
3674
|
};
|
|
1590
3675
|
}
|
|
1591
3676
|
checkStarterPackageJson(file, paths) {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
} catch {
|
|
1596
|
-
throw new IngestRejectedError("params", "package.json is not valid JSON", file.path);
|
|
1597
|
-
}
|
|
1598
|
-
if (typeof pkg["name"] !== "string" || typeof pkg["version"] !== "string")
|
|
1599
|
-
throw new IngestRejectedError(
|
|
1600
|
-
"params",
|
|
1601
|
-
'package.json needs string "name" and "version"',
|
|
1602
|
-
file.path
|
|
1603
|
-
);
|
|
1604
|
-
for (const key of ["resolutions", "workspaces", "overrides"])
|
|
1605
|
-
if (key in pkg)
|
|
1606
|
-
throw new IngestRejectedError("params", `package.json "${key}" is rejected`, file.path);
|
|
1607
|
-
const pnpm = pkg["pnpm"] ?? {};
|
|
1608
|
-
for (const key of ["overrides", "patchedDependencies", "onlyBuiltDependencies"])
|
|
1609
|
-
if (key in pnpm)
|
|
1610
|
-
throw new IngestRejectedError("params", `package.json "pnpm.${key}" is rejected`, file.path);
|
|
1611
|
-
const tq = pkg["tanqory"] ?? {};
|
|
1612
|
-
if (typeof tq !== "object" || Array.isArray(tq))
|
|
1613
|
-
throw new IngestRejectedError("params", 'package.json "tanqory" must be an object', file.path);
|
|
1614
|
-
const build = tq["build"] ?? STARTER_DEFAULT_BUILDS.find((b) => paths.has(b)) ?? STARTER_DEFAULT_BUILDS[1];
|
|
1615
|
-
const out = tq["out"] ?? STARTER_DEFAULT_OUT;
|
|
1616
|
-
if (typeof build !== "string" || !STARTER_PATH_RE.test(build) || !build.endsWith(".mjs"))
|
|
1617
|
-
throw new IngestRejectedError(
|
|
1618
|
-
"params",
|
|
1619
|
-
`package.json tanqory.build ${JSON.stringify(build)} must be a relative path to a .mjs file in the theme`,
|
|
1620
|
-
file.path
|
|
1621
|
-
);
|
|
1622
|
-
if (!paths.has(build))
|
|
1623
|
-
throw new IngestRejectedError(
|
|
1624
|
-
"params",
|
|
1625
|
-
`the build file ${build} is not in the upload (package.json tanqory.build, or ${STARTER_DEFAULT_BUILDS.join(" / ")})`,
|
|
1626
|
-
build
|
|
1627
|
-
);
|
|
1628
|
-
if (typeof out !== "string" || !STARTER_PATH_RE.test(out))
|
|
1629
|
-
throw new IngestRejectedError(
|
|
1630
|
-
"params",
|
|
1631
|
-
`package.json tanqory.out ${JSON.stringify(out)} must be a relative directory in the theme`,
|
|
1632
|
-
file.path
|
|
1633
|
-
);
|
|
1634
|
-
const sections = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
|
1635
|
-
let kit = false;
|
|
1636
|
-
for (const section of sections) {
|
|
1637
|
-
const deps = pkg[section] ?? {};
|
|
1638
|
-
for (const [name, spec] of Object.entries(deps)) {
|
|
1639
|
-
if (typeof spec !== "string" || !isPlainRegistryRange(spec))
|
|
1640
|
-
throw new IngestRejectedError(
|
|
1641
|
-
"deps",
|
|
1642
|
-
`package.json ${section}.${name}: ${JSON.stringify(spec)} is not a plain registry version range`,
|
|
1643
|
-
file.path,
|
|
1644
|
-
{ entry: name }
|
|
1645
|
-
);
|
|
1646
|
-
const platform = THIRD_PARTY_PLATFORM_PACKAGES.get(name);
|
|
1647
|
-
if (platform) {
|
|
1648
|
-
const allowed = PLATFORM_PACKAGE_SECTIONS[platform];
|
|
1649
|
-
if (!allowed.includes(section))
|
|
1650
|
-
throw new IngestRejectedError(
|
|
1651
|
-
"deps",
|
|
1652
|
-
`package.json ${section}.${name}: ${name} may be named only in ${allowed.join(" or ")}`,
|
|
1653
|
-
file.path,
|
|
1654
|
-
{ entry: name }
|
|
1655
|
-
);
|
|
1656
|
-
if (!EXACT_VERSION_RE.test(spec))
|
|
1657
|
-
throw new IngestRejectedError(
|
|
1658
|
-
"deps",
|
|
1659
|
-
`package.json ${section}.${name}: ${JSON.stringify(spec)} must be an exact version (e.g. "2.0.0-alpha.3"), not a range`,
|
|
1660
|
-
file.path,
|
|
1661
|
-
{ entry: name }
|
|
1662
|
-
);
|
|
1663
|
-
if (name === "@tanqory/theme-kit") kit = true;
|
|
1664
|
-
continue;
|
|
1665
|
-
}
|
|
1666
|
-
if (STARTER_PROVIDED_PACKAGES.has(name) && (section === "dependencies" || section === "devDependencies"))
|
|
1667
|
-
continue;
|
|
1668
|
-
if (isStarterDevTool(name) && section === "devDependencies") continue;
|
|
1669
|
-
throw new IngestRejectedError(
|
|
1670
|
-
"deps",
|
|
1671
|
-
`package.json ${section}.${name}: the builder does not provide ${name} (a starter build uses the kit, react, react-dom, vite and @vitejs/plugin-react from the builder image)`,
|
|
1672
|
-
file.path,
|
|
1673
|
-
{ entry: name }
|
|
1674
|
-
);
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
if (!kit)
|
|
3677
|
+
const { problems } = (0, import_source2.starterPackageProblems)(file.bytes.toString("utf8"), paths);
|
|
3678
|
+
const first = problems[0];
|
|
3679
|
+
if (first)
|
|
1678
3680
|
throw new IngestRejectedError(
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
{ entry:
|
|
3681
|
+
first.kind,
|
|
3682
|
+
first.message,
|
|
3683
|
+
first.path,
|
|
3684
|
+
first.entry ? { entry: first.entry } : void 0
|
|
1683
3685
|
);
|
|
1684
|
-
|
|
3686
|
+
const pkg = JSON.parse(file.bytes.toString("utf8"));
|
|
3687
|
+
return { name: pkg.name, version: pkg.version };
|
|
1685
3688
|
}
|
|
1686
3689
|
checkCollisions(files) {
|
|
1687
3690
|
const folded = /* @__PURE__ */ new Map();
|
|
@@ -1751,7 +3754,7 @@ var IngestGate = class {
|
|
|
1751
3754
|
]) {
|
|
1752
3755
|
const deps = pkg[section] ?? {};
|
|
1753
3756
|
for (const [name, spec] of Object.entries(deps)) {
|
|
1754
|
-
if (typeof spec !== "string" || !isPlainRegistryRange(spec)) {
|
|
3757
|
+
if (typeof spec !== "string" || !(0, import_source2.isPlainRegistryRange)(spec)) {
|
|
1755
3758
|
throw new IngestRejectedError(
|
|
1756
3759
|
"deps",
|
|
1757
3760
|
`package.json ${section}.${name}: ${JSON.stringify(spec)} is not a plain registry version range`,
|
|
@@ -1759,9 +3762,9 @@ var IngestGate = class {
|
|
|
1759
3762
|
{ entry: name }
|
|
1760
3763
|
);
|
|
1761
3764
|
}
|
|
1762
|
-
const platform = this.opts.thirdParty ? THIRD_PARTY_PLATFORM_PACKAGES.get(name) : void 0;
|
|
3765
|
+
const platform = this.opts.thirdParty ? import_source2.THIRD_PARTY_PLATFORM_PACKAGES.get(name) : void 0;
|
|
1763
3766
|
if (platform) {
|
|
1764
|
-
const sections = PLATFORM_PACKAGE_SECTIONS[platform];
|
|
3767
|
+
const sections = import_source2.PLATFORM_PACKAGE_SECTIONS[platform];
|
|
1765
3768
|
if (!sections.includes(section))
|
|
1766
3769
|
throw new IngestRejectedError(
|
|
1767
3770
|
"deps",
|
|
@@ -1769,7 +3772,7 @@ var IngestGate = class {
|
|
|
1769
3772
|
file.path,
|
|
1770
3773
|
{ entry: name }
|
|
1771
3774
|
);
|
|
1772
|
-
if (!EXACT_VERSION_RE.test(spec))
|
|
3775
|
+
if (!import_source2.EXACT_VERSION_RE.test(spec))
|
|
1773
3776
|
throw new IngestRejectedError(
|
|
1774
3777
|
"deps",
|
|
1775
3778
|
`package.json ${section}.${name}: ${JSON.stringify(spec)} must be an exact version (e.g. "2.0.0-alpha.3"), not a range`,
|
|
@@ -1791,7 +3794,7 @@ var IngestGate = class {
|
|
|
1791
3794
|
for (const section of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
1792
3795
|
const deps = pkg[section] ?? {};
|
|
1793
3796
|
for (const name of Object.keys(deps)) {
|
|
1794
|
-
if (this.opts.thirdParty && THIRD_PARTY_PLATFORM_PACKAGES.has(name)) continue;
|
|
3797
|
+
if (this.opts.thirdParty && import_source2.THIRD_PARTY_PLATFORM_PACKAGES.has(name)) continue;
|
|
1795
3798
|
if (!this.opts.allowlist.packages.has(name)) {
|
|
1796
3799
|
throw new IngestRejectedError(
|
|
1797
3800
|
"deps",
|
|
@@ -1875,7 +3878,7 @@ var IngestGate = class {
|
|
|
1875
3878
|
if (d.importer !== ".") refuse(`${at}: only the root importer "." is accepted`, d.name);
|
|
1876
3879
|
if (d.section === "peerDependencies")
|
|
1877
3880
|
refuse(`${at}: an importer peer dependency is not accepted`, d.name);
|
|
1878
|
-
if (!isPlainRegistryRange(d.specifier))
|
|
3881
|
+
if (!(0, import_source2.isPlainRegistryRange)(d.specifier))
|
|
1879
3882
|
refuse(
|
|
1880
3883
|
`${at}: specifier ${JSON.stringify(d.specifier)} is not a plain registry range`,
|
|
1881
3884
|
d.name
|
|
@@ -1885,7 +3888,7 @@ var IngestGate = class {
|
|
|
1885
3888
|
refuse(`${at}: version ${JSON.stringify(d.version)} is not a registry version`, d.name);
|
|
1886
3889
|
if (!checked.has(`${d.name}@${version}`))
|
|
1887
3890
|
refuse(`${at}: ${d.name}@${version} has no entry in packages:`, d.name);
|
|
1888
|
-
if (this.opts.thirdParty && THIRD_PARTY_PLATFORM_PACKAGES.has(d.name) && d.specifier !== version)
|
|
3891
|
+
if (this.opts.thirdParty && import_source2.THIRD_PARTY_PLATFORM_PACKAGES.has(d.name) && d.specifier !== version)
|
|
1889
3892
|
refuse(
|
|
1890
3893
|
`${at}: specifier ${d.specifier} must be the exact version it resolves to (${version})`,
|
|
1891
3894
|
d.name
|
|
@@ -1910,10 +3913,10 @@ var IngestGate = class {
|
|
|
1910
3913
|
return lock;
|
|
1911
3914
|
}
|
|
1912
3915
|
checkManifest(file) {
|
|
1913
|
-
if (file.bytes.byteLength >
|
|
3916
|
+
if (file.bytes.byteLength > LIMITS.manifestBytes.hard) {
|
|
1914
3917
|
throw new IngestRejectedError(
|
|
1915
3918
|
"manifest",
|
|
1916
|
-
`manifest.json is ${file.bytes.byteLength} bytes; hard limit ${
|
|
3919
|
+
`manifest.json is ${file.bytes.byteLength} bytes; hard limit ${LIMITS.manifestBytes.hard}`,
|
|
1917
3920
|
file.path
|
|
1918
3921
|
);
|
|
1919
3922
|
}
|
|
@@ -1923,7 +3926,7 @@ var IngestGate = class {
|
|
|
1923
3926
|
} catch {
|
|
1924
3927
|
throw new IngestRejectedError("manifest", "manifest.json is not valid JSON", file.path);
|
|
1925
3928
|
}
|
|
1926
|
-
const result =
|
|
3929
|
+
const result = validateManifest(parsed);
|
|
1927
3930
|
if (!result.ok) {
|
|
1928
3931
|
const first = result.errors[0];
|
|
1929
3932
|
throw new IngestRejectedError(
|
|
@@ -1972,7 +3975,7 @@ function platformOnlyClosure(lock) {
|
|
|
1972
3975
|
if (d.importer !== ".") continue;
|
|
1973
3976
|
const v = registryVersionOf(d.version);
|
|
1974
3977
|
if (!v) continue;
|
|
1975
|
-
(THIRD_PARTY_PLATFORM_PACKAGES.has(d.name) ? platformRoots : otherRoots).push(`${d.name}@${v}`);
|
|
3978
|
+
(import_source2.THIRD_PARTY_PLATFORM_PACKAGES.has(d.name) ? platformRoots : otherRoots).push(`${d.name}@${v}`);
|
|
1976
3979
|
}
|
|
1977
3980
|
const other = reach(otherRoots);
|
|
1978
3981
|
return new Set([...reach(platformRoots)].filter((k) => !other.has(k)));
|
|
@@ -2152,11 +4155,221 @@ async function extractTarballGuarded(input, limits = INGEST_LIMITS) {
|
|
|
2152
4155
|
};
|
|
2153
4156
|
}
|
|
2154
4157
|
|
|
4158
|
+
// ../../apps/build-service/src/review/partner-source.ts
|
|
4159
|
+
var import_text_rules = __toESM(require_text_rules());
|
|
4160
|
+
|
|
4161
|
+
// ../../apps/build-service/src/review/local-sandbox.ts
|
|
4162
|
+
var import_node_crypto4 = require("node:crypto");
|
|
4163
|
+
var import_node_zlib = require("node:zlib");
|
|
4164
|
+
|
|
4165
|
+
// ../../apps/build-service/src/artifact/entry-scan.ts
|
|
4166
|
+
var import_acorn = require("acorn");
|
|
4167
|
+
var import_acorn_walk = require("acorn-walk");
|
|
4168
|
+
function scanEntryModule(source) {
|
|
4169
|
+
let ast;
|
|
4170
|
+
try {
|
|
4171
|
+
ast = (0, import_acorn.parse)(source, {
|
|
4172
|
+
ecmaVersion: "latest",
|
|
4173
|
+
sourceType: "module",
|
|
4174
|
+
locations: true,
|
|
4175
|
+
allowHashBang: false
|
|
4176
|
+
});
|
|
4177
|
+
} catch (e) {
|
|
4178
|
+
return [{ kind: "parse_error", message: e.message }];
|
|
4179
|
+
}
|
|
4180
|
+
const findings = [];
|
|
4181
|
+
const line3 = (n) => n.loc?.start.line ?? 0;
|
|
4182
|
+
(0, import_acorn_walk.full)(ast, (node) => {
|
|
4183
|
+
switch (node.type) {
|
|
4184
|
+
case "ImportDeclaration":
|
|
4185
|
+
findings.push({ kind: "static_import", line: line3(node) });
|
|
4186
|
+
break;
|
|
4187
|
+
case "ImportExpression":
|
|
4188
|
+
findings.push({ kind: "dynamic_import", line: line3(node) });
|
|
4189
|
+
break;
|
|
4190
|
+
case "ExportAllDeclaration":
|
|
4191
|
+
findings.push({ kind: "export_from", line: line3(node) });
|
|
4192
|
+
break;
|
|
4193
|
+
case "ExportNamedDeclaration":
|
|
4194
|
+
if (node.source)
|
|
4195
|
+
findings.push({ kind: "export_from", line: line3(node) });
|
|
4196
|
+
break;
|
|
4197
|
+
case "CallExpression": {
|
|
4198
|
+
const callee = node.callee;
|
|
4199
|
+
if (callee.type === "Identifier" && callee.name === "require")
|
|
4200
|
+
findings.push({ kind: "require_call", line: line3(node) });
|
|
4201
|
+
if (callee.type === "Identifier" && callee.name === "importScripts")
|
|
4202
|
+
findings.push({ kind: "import_scripts_call", line: line3(node) });
|
|
4203
|
+
break;
|
|
4204
|
+
}
|
|
4205
|
+
}
|
|
4206
|
+
});
|
|
4207
|
+
return findings;
|
|
4208
|
+
}
|
|
4209
|
+
function describeFinding(f) {
|
|
4210
|
+
return f.kind === "parse_error" ? `does not parse as an ES module: ${f.message}` : `${f.kind.replace(/_/g, " ")} at line ${f.line}`;
|
|
4211
|
+
}
|
|
4212
|
+
function moduleReferences(source) {
|
|
4213
|
+
let ast;
|
|
4214
|
+
try {
|
|
4215
|
+
ast = (0, import_acorn.parse)(source, { ecmaVersion: "latest", sourceType: "module", locations: true });
|
|
4216
|
+
} catch {
|
|
4217
|
+
return void 0;
|
|
4218
|
+
}
|
|
4219
|
+
const out = [];
|
|
4220
|
+
const line3 = (n) => n.loc?.start.line ?? 0;
|
|
4221
|
+
const literal = (n) => {
|
|
4222
|
+
const v = n;
|
|
4223
|
+
return v?.type === "Literal" && typeof v.value === "string" ? v.value : null;
|
|
4224
|
+
};
|
|
4225
|
+
(0, import_acorn_walk.full)(ast, (node) => {
|
|
4226
|
+
const n = node;
|
|
4227
|
+
switch (node.type) {
|
|
4228
|
+
case "ImportDeclaration":
|
|
4229
|
+
out.push({ kind: "static_import", specifier: literal(n.source), line: line3(node) });
|
|
4230
|
+
break;
|
|
4231
|
+
case "ImportExpression":
|
|
4232
|
+
out.push({ kind: "dynamic_import", specifier: literal(n.source), line: line3(node) });
|
|
4233
|
+
break;
|
|
4234
|
+
case "ExportAllDeclaration":
|
|
4235
|
+
out.push({ kind: "export_from", specifier: literal(n.source), line: line3(node) });
|
|
4236
|
+
break;
|
|
4237
|
+
case "ExportNamedDeclaration":
|
|
4238
|
+
if (n.source)
|
|
4239
|
+
out.push({ kind: "export_from", specifier: literal(n.source), line: line3(node) });
|
|
4240
|
+
break;
|
|
4241
|
+
case "CallExpression":
|
|
4242
|
+
if (n.callee?.type === "Identifier" && n.callee.name === "require")
|
|
4243
|
+
out.push({ kind: "require_call", specifier: literal(n.arguments?.[0]), line: line3(node) });
|
|
4244
|
+
if (n.callee?.type === "Identifier" && n.callee.name === "importScripts")
|
|
4245
|
+
out.push({ kind: "import_scripts_call", specifier: null, line: line3(node) });
|
|
4246
|
+
break;
|
|
4247
|
+
}
|
|
4248
|
+
});
|
|
4249
|
+
return out;
|
|
4250
|
+
}
|
|
4251
|
+
function clientChunkProblem(path, source, shipped) {
|
|
4252
|
+
const refs = moduleReferences(source);
|
|
4253
|
+
if (!refs) return `${path} does not parse as an ES module`;
|
|
4254
|
+
for (const r of refs) {
|
|
4255
|
+
if (r.kind === "require_call" || r.kind === "import_scripts_call")
|
|
4256
|
+
return `${path}: ${r.kind.replace(/_/g, " ")} at line ${r.line}`;
|
|
4257
|
+
const m = r.specifier === null ? null : /^\.\/([A-Za-z0-9._-]+)$/.exec(r.specifier);
|
|
4258
|
+
if (!m || !shipped.has(m[1]))
|
|
4259
|
+
return `${path}: ${r.kind.replace(/_/g, " ")} of ${r.specifier === null ? "a computed specifier" : JSON.stringify(r.specifier)} at line ${r.line} \u2014 a client chunk may import only another shipped file (./<file>)`;
|
|
4260
|
+
}
|
|
4261
|
+
return void 0;
|
|
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
|
+
}
|
|
4273
|
+
|
|
4274
|
+
// ../../apps/build-service/src/review/local-sandbox.ts
|
|
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: [] };
|
|
4276
|
+
function treeDigest(files) {
|
|
4277
|
+
const h = (0, import_node_crypto4.createHash)("sha256");
|
|
4278
|
+
for (const f of [...files].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0))
|
|
4279
|
+
h.update(`${f.path}\0${(0, import_node_crypto4.createHash)("sha256").update(f.bytes).digest("hex")}
|
|
4280
|
+
`);
|
|
4281
|
+
return `sha256:${h.digest("hex")}`;
|
|
4282
|
+
}
|
|
4283
|
+
function reproducibleLine(first, second) {
|
|
4284
|
+
const a = new Map(first.map((f) => [f.path, (0, import_node_crypto4.createHash)("sha256").update(f.bytes).digest("hex")]));
|
|
4285
|
+
const b = new Map(second.map((f) => [f.path, (0, import_node_crypto4.createHash)("sha256").update(f.bytes).digest("hex")]));
|
|
4286
|
+
const errors = [];
|
|
4287
|
+
for (const p of [.../* @__PURE__ */ new Set([...a.keys(), ...b.keys()])].sort()) {
|
|
4288
|
+
if (a.get(p) === b.get(p)) continue;
|
|
4289
|
+
errors.push({
|
|
4290
|
+
path: p,
|
|
4291
|
+
code: "not_reproducible",
|
|
4292
|
+
message: !a.has(p) || !b.has(p) ? `${p} is written by only one of two builds of the same source. The sandbox builds twice and refuses any difference: write the same files every time.` : `${p} differs between two builds of the same source. The sandbox builds twice and refuses any difference: remove dates, random names and absolute paths from the build output.`
|
|
4293
|
+
});
|
|
4294
|
+
}
|
|
4295
|
+
return line("sandbox_build", errors, `Two builds wrote the same ${first.length} file(s) (${treeDigest(first)}).`);
|
|
4296
|
+
}
|
|
4297
|
+
function entryScanLine(out) {
|
|
4298
|
+
const errors = [];
|
|
4299
|
+
for (const entry of ["server/entry.mjs", "preview/entry.mjs"]) {
|
|
4300
|
+
const f = out.find((x) => x.path === entry);
|
|
4301
|
+
if (!f) continue;
|
|
4302
|
+
const findings = scanEntryModule(f.bytes.toString("utf8"));
|
|
4303
|
+
if (findings.length)
|
|
4304
|
+
errors.push({ path: entry, code: "entry_imports", message: `${entry} must be a single ESM file with zero imports: ${findings.map(describeFinding).join("; ")}. Bundle everything it imports into it.` });
|
|
4305
|
+
}
|
|
4306
|
+
const assets = out.filter((x) => x.path.startsWith("client/assets/"));
|
|
4307
|
+
const shipped = new Set(assets.map((x) => x.path.slice("client/assets/".length)));
|
|
4308
|
+
for (const f of assets.filter((x) => /\.m?js$/.test(x.path))) {
|
|
4309
|
+
const problem = clientChunkProblem(f.path, f.bytes.toString("utf8"), shipped);
|
|
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}.` });
|
|
4313
|
+
}
|
|
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.`);
|
|
4315
|
+
}
|
|
4316
|
+
var gz = (b) => (0, import_node_zlib.gzipSync)(b, { level: 9 }).length;
|
|
4317
|
+
function budgetsLine(out) {
|
|
4318
|
+
const at = (p) => out.find((x) => x.path === p)?.bytes;
|
|
4319
|
+
const entry = at("server/entry.mjs") ?? Buffer.alloc(0);
|
|
4320
|
+
const assets = out.filter((x) => x.path.startsWith("client/assets/"));
|
|
4321
|
+
let initial = 0;
|
|
4322
|
+
try {
|
|
4323
|
+
const cm = JSON.parse((at("client/client-manifest.json") ?? Buffer.from("{}")).toString("utf8"));
|
|
4324
|
+
const main = Object.values(cm).find((e) => e.isEntry);
|
|
4325
|
+
const files = main ? [main.file, ...main.imports ?? [], ...main.css ?? []] : [];
|
|
4326
|
+
for (const f of new Set(files)) {
|
|
4327
|
+
const b = typeof f === "string" ? at(`client/assets/${f}`) ?? at(`client/${f}`) : void 0;
|
|
4328
|
+
if (b) initial += gz(b);
|
|
4329
|
+
}
|
|
4330
|
+
} catch {
|
|
4331
|
+
}
|
|
4332
|
+
const rows = [
|
|
4333
|
+
["ssrEntryRawBytes", entry.length],
|
|
4334
|
+
["ssrEntryGzipBytes", gz(entry)],
|
|
4335
|
+
["manifestBytes", at("manifest.json")?.length ?? 0],
|
|
4336
|
+
["clientInitialGzipBytes", initial],
|
|
4337
|
+
["clientTotalRawBytes", assets.reduce((n, x) => n + x.bytes.length, 0)]
|
|
4338
|
+
];
|
|
4339
|
+
const errors = [];
|
|
4340
|
+
const over = [];
|
|
4341
|
+
for (const [k, v] of rows) {
|
|
4342
|
+
const { budget, hard } = LIMITS[k];
|
|
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.` });
|
|
4344
|
+
else if (budget !== null && v > budget) over.push(`${k} ${v} > budget ${budget}`);
|
|
4345
|
+
}
|
|
4346
|
+
return line("budgets", errors, `No static hard limit exceeded${over.length ? `; over budget (a warning): ${over.join(", ")}` : ""}. The sandbox also measures render budgets and Lighthouse.`);
|
|
4347
|
+
}
|
|
4348
|
+
function networkLine(manifest) {
|
|
4349
|
+
const caps = manifest?.capabilities?.server;
|
|
4350
|
+
const origins = Array.isArray(caps) ? caps.filter((c) => typeof c === "string" && c.startsWith("network:")).map((c) => c.slice(8)) : [];
|
|
4351
|
+
const errors = [];
|
|
4352
|
+
for (const o of origins) {
|
|
4353
|
+
let ok = false;
|
|
4354
|
+
try {
|
|
4355
|
+
const u = new URL(o);
|
|
4356
|
+
ok = u.protocol === "https:" && u.origin === o;
|
|
4357
|
+
} catch {
|
|
4358
|
+
ok = false;
|
|
4359
|
+
}
|
|
4360
|
+
if (!ok) errors.push({ path: `manifest.json capabilities.server network:${o}`, code: "network_origin", message: `network:${o} is not an https origin (https://host[:port], nothing after it). Declare the origin only.` });
|
|
4361
|
+
}
|
|
4362
|
+
return line("network_allowlist", errors, origins.length ? `${origins.length} network origin(s) declared (${origins.join(", ")}): reviewers ask why each is needed.` : "No network origin declared: the theme reads only the store's own data.");
|
|
4363
|
+
}
|
|
4364
|
+
|
|
4365
|
+
// ../../apps/build-service/src/review/partner-source.ts
|
|
4366
|
+
var import_source3 = __toESM(require_source());
|
|
4367
|
+
|
|
2155
4368
|
// ../../apps/build-service/src/review/static-checks.ts
|
|
2156
4369
|
var import_node_fs3 = require("node:fs");
|
|
2157
4370
|
var import_node_path3 = require("node:path");
|
|
2158
|
-
var
|
|
2159
|
-
var
|
|
4371
|
+
var import_acorn2 = require("acorn");
|
|
4372
|
+
var import_acorn_walk2 = require("acorn-walk");
|
|
2160
4373
|
var import_zod = require("zod");
|
|
2161
4374
|
var FINDINGS_MAX = 50;
|
|
2162
4375
|
var isClientScript = (p) => /^client\/assets\/[A-Za-z0-9._-]+\.m?js$/.test(p);
|
|
@@ -2170,17 +4383,17 @@ var calleeName = (callee) => {
|
|
|
2170
4383
|
function evalFindings(path, source) {
|
|
2171
4384
|
let ast;
|
|
2172
4385
|
try {
|
|
2173
|
-
ast = (0,
|
|
4386
|
+
ast = (0, import_acorn2.parse)(source, { ecmaVersion: "latest", sourceType: "module", locations: true });
|
|
2174
4387
|
} catch {
|
|
2175
4388
|
try {
|
|
2176
|
-
ast = (0,
|
|
4389
|
+
ast = (0, import_acorn2.parse)(source, { ecmaVersion: "latest", sourceType: "script", locations: true });
|
|
2177
4390
|
} catch (e) {
|
|
2178
4391
|
return [{ path, code: "parse_error", message: `${path} does not parse as JavaScript: ${e.message}` }];
|
|
2179
4392
|
}
|
|
2180
4393
|
}
|
|
2181
4394
|
const out = [];
|
|
2182
4395
|
const at = (n) => `${path}:${n.loc?.start.line ?? 0}:${(n.loc?.start.column ?? 0) + 1}`;
|
|
2183
|
-
(0,
|
|
4396
|
+
(0, import_acorn_walk2.full)(ast, (node) => {
|
|
2184
4397
|
if (node.type !== "CallExpression" && node.type !== "NewExpression") return;
|
|
2185
4398
|
const n = node;
|
|
2186
4399
|
const name = calleeName(n.callee);
|
|
@@ -2296,22 +4509,17 @@ function licencesLine(files, table) {
|
|
|
2296
4509
|
}
|
|
2297
4510
|
|
|
2298
4511
|
// ../../apps/build-service/src/review/partner-source.ts
|
|
2299
|
-
var
|
|
2300
|
-
var EMOJI = /([\p{Extended_Pictographic}\u{1F1E6}-\u{1F1FF}])(\u{FE0F})?/gu;
|
|
2301
|
-
var TEXT_FORM_ALLOWED = /* @__PURE__ */ new Set(["\xA9", "\xAE", "\u2122"]);
|
|
2302
|
-
var hasEmoji = (s) => [...s.matchAll(EMOJI)].some(([, ch, vs]) => vs || !TEXT_FORM_ALLOWED.has(ch));
|
|
2303
|
-
var LABEL_KEYS = /* @__PURE__ */ new Set(["name", "title", "label", "info", "placeholder", "description"]);
|
|
2304
|
-
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: [] };
|
|
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: [] };
|
|
2305
4513
|
function treeOf(dir) {
|
|
2306
4514
|
const out = [];
|
|
2307
|
-
const
|
|
4515
|
+
const walk2 = (abs) => {
|
|
2308
4516
|
for (const name of (0, import_node_fs4.readdirSync)(abs).sort()) {
|
|
2309
4517
|
const p = (0, import_node_path4.join)(abs, name);
|
|
2310
|
-
if ((0, import_node_fs4.statSync)(p).isDirectory())
|
|
4518
|
+
if ((0, import_node_fs4.statSync)(p).isDirectory()) walk2(p);
|
|
2311
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) });
|
|
2312
4520
|
}
|
|
2313
4521
|
};
|
|
2314
|
-
|
|
4522
|
+
walk2(dir);
|
|
2315
4523
|
return out;
|
|
2316
4524
|
}
|
|
2317
4525
|
var failure = (e) => ({
|
|
@@ -2332,49 +4540,37 @@ async function editabilityLine(files, imageFetch) {
|
|
|
2332
4540
|
const img = await (0, import_editability.checkImageLinks)(text, { fetch: imageFetch });
|
|
2333
4541
|
for (const e of img.errors) errs.push({ path: `${e.file}:${e.line}:${e.column}`, code: e.code, message: `${e.message}${e.fix ? ` Fix: ${e.fix}` : ""}` });
|
|
2334
4542
|
}
|
|
2335
|
-
return
|
|
4543
|
+
return line2("editability", errs, `${r.score.editable} settings; every section's words, images and links are editable (${r.score.percent} %)${r.warnings.length ? `; ${r.warnings.length} warning(s)` : ""}`);
|
|
2336
4544
|
}
|
|
2337
4545
|
async function checkPartnerSource(tgz, built, opts = {}) {
|
|
2338
4546
|
const lines = [];
|
|
2339
4547
|
let files = [];
|
|
2340
4548
|
try {
|
|
2341
|
-
files = (await extractTarballGuarded(import_node_stream.Readable.from([tgz]))).files;
|
|
4549
|
+
files = (0, import_source2.withoutPackFolder)((await extractTarballGuarded(import_node_stream.Readable.from([tgz]))).files);
|
|
2342
4550
|
} catch (e) {
|
|
2343
|
-
lines.push(
|
|
4551
|
+
lines.push(line2("archive", [failure(e)], ""));
|
|
2344
4552
|
}
|
|
2345
4553
|
let ingest = null;
|
|
2346
4554
|
try {
|
|
2347
4555
|
ingest = new IngestGate({ mirrorHosts: [], allowlist: loadMirrorAllowlist(), thirdParty: true }).inspect(files);
|
|
2348
|
-
lines.push(
|
|
4556
|
+
lines.push(line2("ingest_gate", [], `${ingest.layout} layout, ${ingest.files.length} build input(s)`));
|
|
2349
4557
|
} catch (e) {
|
|
2350
|
-
lines.push(
|
|
4558
|
+
lines.push(line2("ingest_gate", [failure(e)], ""));
|
|
2351
4559
|
}
|
|
2352
4560
|
const pkg = JSON.parse(files.find((f) => f.path === "package.json")?.bytes.toString("utf8") ?? "{}");
|
|
2353
4561
|
const pinOf = (name) => pkg["dependencies"]?.[name] ?? pkg["devDependencies"]?.[name];
|
|
2354
|
-
const toolchains = JSON.parse((0, import_node_fs4.readFileSync)(THIRD_PARTY_TOOLCHAINS_PATH, "utf8"));
|
|
2355
4562
|
const kits = loadThirdPartyKits().map((k) => k.version);
|
|
2356
|
-
const starterAbi =
|
|
4563
|
+
const starterAbi = loadStarterAbiPins();
|
|
2357
4564
|
const build = [];
|
|
2358
4565
|
const kit = pinOf("@tanqory/theme-kit");
|
|
2359
4566
|
if (!kit || !kits.includes(kit))
|
|
2360
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.` });
|
|
2361
4568
|
const abi = pinOf("@tanqory/theme-abi");
|
|
2362
|
-
if (abi !== void 0 && ingest?.layout !== "theme-source" && abi
|
|
2363
|
-
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.` });
|
|
2364
|
-
lines.push(
|
|
2365
|
-
const text = [];
|
|
2366
|
-
|
|
2367
|
-
if (BRAND_RE.test(f.path)) text.push({ path: f.path, code: "brand_term", message: `The file name ${f.path} names another commerce platform. Rename it.` });
|
|
2368
|
-
else if (!f.bytes.subarray(0, 8192).includes(0)) {
|
|
2369
|
-
const s = f.bytes.toString("utf8");
|
|
2370
|
-
const i = s.search(BRAND_RE);
|
|
2371
|
-
if (i >= 0) {
|
|
2372
|
-
const at = s.slice(0, i).split("\n").length;
|
|
2373
|
-
text.push({ path: `${f.path}:${at}`, code: "brand_term", message: `${f.path} line ${at} names another commerce platform. Use your theme's own words.` });
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2377
|
-
lines.push(line("source_text", text, `${files.length} source file(s) checked`));
|
|
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.` });
|
|
4571
|
+
lines.push(line2("sandbox_build", build, `@tanqory/theme-kit ${kit} and @tanqory/theme-abi ${abi ?? "(not pinned)"} are carried by the builder`));
|
|
4572
|
+
const text = (0, import_text_rules.sourceTextFindings)(files.map((f) => [f.path, f.bytes]));
|
|
4573
|
+
lines.push(line2("source_text", text, `${files.length} source file(s) checked`));
|
|
2378
4574
|
lines.push(await editabilityLine(files, opts.imageFetch));
|
|
2379
4575
|
if (built) {
|
|
2380
4576
|
const out = treeOf(built);
|
|
@@ -2384,20 +4580,13 @@ async function checkPartnerSource(tgz, built, opts = {}) {
|
|
|
2384
4580
|
if (!manifestFile) mErrors.push({ path: "manifest.json", code: "manifest_missing", message: `The build wrote no manifest.json in ${built}.` });
|
|
2385
4581
|
else {
|
|
2386
4582
|
manifest = JSON.parse(manifestFile.bytes.toString("utf8"));
|
|
2387
|
-
const r =
|
|
4583
|
+
const r = validateManifest(manifest, { artifactFiles: out.map((f) => f.path) });
|
|
2388
4584
|
if (!r.ok) for (const e of r.errors) mErrors.push({ path: e.path, code: e.code, message: e.message });
|
|
2389
4585
|
}
|
|
2390
|
-
lines.push(
|
|
2391
|
-
const labels =
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
if (key !== null && LABEL_KEYS.has(key)) labels.push([path || "/", v]);
|
|
2395
|
-
} else if (Array.isArray(v)) v.forEach((x, i) => walk(x, `${path}/${i}`, key));
|
|
2396
|
-
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);
|
|
2397
|
-
};
|
|
2398
|
-
walk(manifest, "", null);
|
|
2399
|
-
lines.push(line("manifest_brand_term", labels.filter(([, s]) => BRAND_RE.test(s)).map(([path]) => ({ path, code: "brand_term", message: `${path} names another commerce platform.` })), `${labels.length} label(s) checked`));
|
|
2400
|
-
lines.push(line("manifest_emoji", labels.filter(([, s]) => hasEmoji(s)).map(([path]) => ({ path, code: "emoji", message: `${path} contains an emoji.` })), `${labels.length} label(s) checked`));
|
|
4586
|
+
lines.push(line2("manifest", mErrors, "theme-manifest v2: schema and semantic checks passed"));
|
|
4587
|
+
const labels = (0, import_text_rules.manifestLabels)(manifest);
|
|
4588
|
+
lines.push(line2("manifest_brand_term", labels.filter(([, s]) => (0, import_text_rules.namesBrandTerm)(s)).map(([path]) => ({ path, code: "brand_term", message: `${path} names another commerce platform.` })), `${labels.length} label(s) checked`));
|
|
4589
|
+
lines.push(line2("manifest_emoji", labels.filter(([, s]) => (0, import_text_rules.hasEmoji)(s)).map(([path]) => ({ path, code: "emoji", message: `${path} contains an emoji.` })), `${labels.length} label(s) checked`));
|
|
2401
4590
|
const noEval = noEvalLine(out);
|
|
2402
4591
|
lines.push({ key: "no_eval", ...noEval });
|
|
2403
4592
|
if (ingest) {
|
|
@@ -2413,8 +4602,37 @@ async function checkPartnerSource(tgz, built, opts = {}) {
|
|
|
2413
4602
|
}
|
|
2414
4603
|
return { tgzBytes: tgz.length, layout: ingest?.layout ?? null, lines };
|
|
2415
4604
|
}
|
|
4605
|
+
function localSandboxLines(built, second) {
|
|
4606
|
+
const out = treeOf(built);
|
|
4607
|
+
const manifest = (() => {
|
|
4608
|
+
try {
|
|
4609
|
+
return JSON.parse(out.find((f) => f.path === "manifest.json")?.bytes.toString("utf8") ?? "null");
|
|
4610
|
+
} catch {
|
|
4611
|
+
return null;
|
|
4612
|
+
}
|
|
4613
|
+
})();
|
|
4614
|
+
return [
|
|
4615
|
+
...second ? [reproducibleLine(out, treeOf(second))] : [],
|
|
4616
|
+
entryScanLine(out),
|
|
4617
|
+
budgetsLine(out),
|
|
4618
|
+
networkLine(manifest)
|
|
4619
|
+
];
|
|
4620
|
+
}
|
|
2416
4621
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2417
4622
|
0 && (module.exports = {
|
|
4623
|
+
SOURCE_LIMITS,
|
|
4624
|
+
budgetsLine,
|
|
2418
4625
|
checkPartnerSource,
|
|
2419
|
-
|
|
4626
|
+
denyFix,
|
|
4627
|
+
denyReason,
|
|
4628
|
+
editabilityLine,
|
|
4629
|
+
entryScanLine,
|
|
4630
|
+
isStarterIgnoredPath,
|
|
4631
|
+
isStarterTree,
|
|
4632
|
+
localSandboxLines,
|
|
4633
|
+
networkLine,
|
|
4634
|
+
reproducibleLine,
|
|
4635
|
+
starterPackageProblems,
|
|
4636
|
+
treeDigest,
|
|
4637
|
+
withoutPackFolder
|
|
2420
4638
|
});
|