@octane-xplat/build 0.0.0-stage → 0.20.0

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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -2
  3. package/dist/add-worker.js +66 -0
  4. package/dist/build-worker.js +276 -0
  5. package/dist/compatibility-check.js +153 -0
  6. package/dist/compatibility-data/compatibility.js +106 -0
  7. package/dist/compatibility-data/compatibility.json +305 -0
  8. package/dist/compatibility.js +229 -0
  9. package/dist/css-layers.js +63 -0
  10. package/dist/css-platform.js +230 -0
  11. package/dist/css-platform.types.d.ts +11 -0
  12. package/dist/dev-inspector.web.js +125 -0
  13. package/dist/dev-log-client.web.js +79 -0
  14. package/dist/dev-log-server.js +13 -0
  15. package/dist/doctor-checks.js +317 -0
  16. package/dist/doctor-tool.js +27 -0
  17. package/dist/env.js +3 -0
  18. package/dist/fmt-plan.js +149 -0
  19. package/dist/fonts-worker.js +31 -0
  20. package/dist/fonts.js +614 -0
  21. package/dist/inline-stylesheets.js +37 -0
  22. package/dist/linux/config.js +43 -0
  23. package/dist/linux/host/bridge-selftest.linux.js +255 -0
  24. package/dist/linux/host/gjs-host.js +1412 -0
  25. package/dist/linux/package.js +176 -0
  26. package/dist/linux-gtk/vite.d.ts +23 -0
  27. package/dist/linux-gtk/vite.js +194 -0
  28. package/dist/macos/config.js +141 -0
  29. package/dist/macos/doctor-checks.js +58 -0
  30. package/dist/macos/executables.js +39 -0
  31. package/dist/macos/jsc-host/runtime.js +134 -0
  32. package/dist/macos/native.js +287 -0
  33. package/dist/macos/runtime-package.js +30 -0
  34. package/dist/macos/tab-item.js +62 -0
  35. package/dist/macos/vite.d.ts +21 -0
  36. package/dist/macos/vite.js +111 -0
  37. package/dist/markdown.js +11 -0
  38. package/dist/mason-engine.js +20 -0
  39. package/dist/mcp/contracts/actions.js +133 -0
  40. package/dist/mcp/dev-bridge.js +363 -0
  41. package/dist/mcp/dev-socket.js +161 -0
  42. package/dist/mcp/dev-stack.js +134 -0
  43. package/dist/mcp/inspection/dom.web.js +46 -0
  44. package/dist/native-regex.js +123 -0
  45. package/dist/package-manager.js +106 -0
  46. package/dist/package-root.js +48 -0
  47. package/dist/patches.js +356 -0
  48. package/dist/route-config.js +53 -0
  49. package/dist/route-data.js +42 -0
  50. package/dist/route-generator.js +514 -0
  51. package/dist/route-path.js +29 -0
  52. package/dist/route-source.js +67 -0
  53. package/dist/targets.js +38 -0
  54. package/dist/tsconfig-envs.js +287 -0
  55. package/dist/tsrx-leaf.js +57 -0
  56. package/dist/typecheck-globals/macos.d.ts +21 -0
  57. package/dist/typecheck-globals/native.d.ts +26 -0
  58. package/dist/ui/src/markdown/markdown-ast.js +33 -0
  59. package/dist/ui/src/markdown/markdown-character-references.js +79 -0
  60. package/dist/ui/src/markdown/markdown-parse.js +1930 -0
  61. package/dist/ui/src/markdown/markdown-plugins.js +564 -0
  62. package/dist/ui/src/markdown/markdown-url.js +17 -0
  63. package/dist/updates-worker.js +34 -0
  64. package/dist/upgrade-worker.js +63 -0
  65. package/dist/vite.d.ts +85 -0
  66. package/dist/vite.js +628 -0
  67. package/dist/workshop-worker.js +181 -0
  68. package/package.json +72 -5
@@ -0,0 +1,356 @@
1
+ import { packageManagerFor, packageManagerRoot, readBunLock, readProjectPackage, readProjectWorkspace, workspaceMembers } from "./package-manager.js";
2
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { createHash } from "node:crypto";
6
+ import { Scalar, isMap, parseAllDocuments, parseDocument } from "yaml";
7
+ // ../cli/src/patches.ts
8
+ var canonicalPatchesDir = join(dirname(fileURLToPath(import.meta.url)), "../patches");
9
+ var loadPatchManifest = () => JSON.parse(readFileSync(join(canonicalPatchesDir, "manifest.json"), "utf8")).patches;
10
+ var patchesFor = (manager) => loadPatchManifest().flatMap((patch) => (manager === "bun" ? patch.bunSpecifiers ?? [patch.specifier] : [patch.specifier]).map((specifier) => ({
11
+ ...patch,
12
+ specifier
13
+ })));
14
+ var specifierPackage = (spec) => {
15
+ const i = spec.indexOf("@", 1);
16
+ return i === -1 ? spec : spec.slice(0, i);
17
+ };
18
+ var specifierVersion = (spec) => spec.slice(spec.indexOf("@", 1) + 1);
19
+ var sha = (file) => createHash("sha256").update(readFileSync(file)).digest("hex");
20
+ var readJson = (file) => {
21
+ try {
22
+ return JSON.parse(readFileSync(file, "utf8"));
23
+ } catch {
24
+ return null;
25
+ }
26
+ };
27
+ var readLockfileDocs = (file) => {
28
+ try {
29
+ return parseAllDocuments(readFileSync(file, "utf8"));
30
+ } catch {
31
+ return [];
32
+ }
33
+ };
34
+ /** package name → declared range across all dep fields. */
35
+ var declaredDeps = (pkg) => ({
36
+ ...pkg?.dependencies,
37
+ ...pkg?.devDependencies,
38
+ ...pkg?.peerDependencies,
39
+ ...pkg?.optionalDependencies
40
+ });
41
+ var workspaceDeps = (appDir, manager) => Object.assign({}, ...workspaceMembers(appDir, manager).map((dir) => declaredDeps(readJson(join(dir, "package.json")))));
42
+ var resolveCatalogs = (appDir, deps, manager) => {
43
+ const config = readProjectWorkspace(appDir, manager);
44
+ const shared = config.catalog ?? config.catalogs?.default ?? {};
45
+ const named = config.catalogs ?? {};
46
+ for (const [name, spec] of Object.entries(deps)) if (spec === "catalog:" || spec === "catalog:default") {
47
+ if (shared[name]) deps[name] = shared[name];
48
+ } else if (spec?.startsWith("catalog:")) {
49
+ const pinned = named[spec.slice(8)]?.[name];
50
+ if (pinned) deps[name] = pinned;
51
+ }
52
+ return deps;
53
+ };
54
+ /** Read only the patch configuration owned by the selected package manager. */
55
+ var configuredPatches = (appDir, options = {}) => {
56
+ appDir = packageManagerRoot(appDir);
57
+ if (packageManagerFor(appDir, options.packageManager) === "bun") return readProjectPackage(appDir).patchedDependencies ?? {};
58
+ const file = join(appDir, "pnpm-workspace.yaml");
59
+ if (!existsSync(file)) return {};
60
+ const doc = parseDocument(readFileSync(file, "utf8"));
61
+ if (doc.errors.length) throw new Error(`Cannot read ${file}: ${doc.errors[0].message}`);
62
+ const pd = doc.get("patchedDependencies");
63
+ return isMap(pd) ? pd.toJSON() : {};
64
+ };
65
+ /** Specifiers recorded in the selected manager lockfile; null before install. */
66
+ var lockfilePatches = (appDir, manager) => {
67
+ if (manager === "bun") {
68
+ const lock = readBunLock(appDir);
69
+ return lock ? new Set(Object.keys(lock.patchedDependencies ?? {})) : null;
70
+ }
71
+ const lock = join(appDir, "pnpm-lock.yaml");
72
+ if (!existsSync(lock)) return null;
73
+ const patches = /* @__PURE__ */ new Set();
74
+ for (const doc of readLockfileDocs(lock)) {
75
+ const pd = doc.get("patchedDependencies");
76
+ if (isMap(pd)) for (const item of pd.items) patches.add(String(item.key));
77
+ }
78
+ return patches;
79
+ };
80
+ var lockfileResolvedVersions = (appDir, manager) => {
81
+ if (manager === "bun") {
82
+ const lock = readBunLock(appDir);
83
+ if (!lock) return null;
84
+ const versions = {};
85
+ for (const entry of Object.values(lock.packages ?? {})) {
86
+ const spec = entry?.[0];
87
+ if (typeof spec !== "string") continue;
88
+ const at = spec.indexOf("@", 1);
89
+ if (at === -1) continue;
90
+ const name = spec.slice(0, at);
91
+ const version = spec.slice(at + 1);
92
+ (versions[name] ??= /* @__PURE__ */ new Set()).add(version);
93
+ }
94
+ return versions;
95
+ }
96
+ const lock = join(appDir, "pnpm-lock.yaml");
97
+ if (!existsSync(lock)) return null;
98
+ const docs = readLockfileDocs(lock);
99
+ const resolved = {};
100
+ const add = (name, version) => {
101
+ if (!name || !version) return;
102
+ (resolved[name] ??= /* @__PURE__ */ new Set()).add(version);
103
+ };
104
+ for (const doc of docs) {
105
+ for (const importer of Object.values(doc?.get("importers")?.toJSON() ?? {})) for (const group of ["dependencies", "devDependencies"]) for (const [name, entry] of Object.entries(importer?.[group] ?? {})) {
106
+ const version = typeof entry === "string" ? entry : entry?.version;
107
+ if (!version) continue;
108
+ add(name, version.split("(")[0]);
109
+ }
110
+ for (const section of ["packages", "snapshots"]) {
111
+ const map = doc?.get(section);
112
+ if (!isMap(map)) continue;
113
+ for (const item of map.items) {
114
+ const key = String(item.key).split("(")[0];
115
+ const at = key.lastIndexOf("@");
116
+ if (at > 0) add(key.slice(0, at), key.slice(at + 1));
117
+ }
118
+ }
119
+ }
120
+ return resolved;
121
+ };
122
+ var versionOk = (declared, pinned, resolved) => resolved ? resolved.has(pinned) : declared === pinned || declared === "workspace:*" || declared === "*";
123
+ /**
124
+ * Per-patch state for an app:
125
+ * not-declared package isn't a dep of this app — patch not needed
126
+ * not-applicable package installed but not at the pinned version — patch can't bite
127
+ * missing-config no patchedDependencies entry
128
+ * missing-file configured path doesn't exist
129
+ * file-differs configured file isn't the framework copy
130
+ * version-mismatch declared range won't resolve the pinned version
131
+ * not-installed configured but absent from pnpm-lock.yaml
132
+ * applied configured, file matches, lockfile recorded it
133
+ */
134
+ var inspectPatches = (appDir, options = {}) => {
135
+ appDir = packageManagerRoot(appDir);
136
+ const manager = packageManagerFor(appDir, options.packageManager);
137
+ const deps = resolveCatalogs(appDir, {
138
+ ...workspaceDeps(appDir, manager),
139
+ ...declaredDeps(readJson(join(appDir, "package.json")))
140
+ }, manager);
141
+ const configured = configuredPatches(appDir, { packageManager: manager });
142
+ const locked = lockfilePatches(appDir, manager);
143
+ const resolved = lockfileResolvedVersions(appDir, manager);
144
+ return patchesFor(manager).map((patch) => {
145
+ const name = specifierPackage(patch.specifier);
146
+ const declared = deps[name];
147
+ const base = {
148
+ ...patch,
149
+ declared,
150
+ path: configured[patch.specifier]
151
+ };
152
+ if (declared === void 0 && !resolved?.[name]?.has(specifierVersion(patch.specifier))) return {
153
+ ...base,
154
+ state: "not-declared"
155
+ };
156
+ if (!base.path && !versionOk(declared, specifierVersion(patch.specifier), resolved?.[name])) return {
157
+ ...base,
158
+ state: "not-applicable"
159
+ };
160
+ if (!base.path) return {
161
+ ...base,
162
+ state: "missing-config"
163
+ };
164
+ const file = join(appDir, base.path);
165
+ if (!existsSync(file)) return {
166
+ ...base,
167
+ state: "missing-file"
168
+ };
169
+ if (sha(file) !== sha(join(canonicalPatchesDir, patch.file))) return {
170
+ ...base,
171
+ state: "file-differs"
172
+ };
173
+ if (!versionOk(declared, specifierVersion(patch.specifier), resolved?.[name])) return {
174
+ ...base,
175
+ state: "version-mismatch"
176
+ };
177
+ if (locked && !locked.has(patch.specifier)) return {
178
+ ...base,
179
+ state: "not-installed"
180
+ };
181
+ return {
182
+ ...base,
183
+ state: "applied"
184
+ };
185
+ });
186
+ };
187
+ var patchStateDetail = (state) => ({
188
+ "not-declared": "package not declared — not needed",
189
+ "not-applicable": "no install resolves the pinned version — not needed",
190
+ "missing-config": "no patchedDependencies entry",
191
+ "missing-file": "configured patch file does not exist",
192
+ "file-differs": "patch file differs from the framework copy",
193
+ "version-mismatch": `declared range won't resolve the pinned version`,
194
+ "not-installed": "configured but missing from the package manager lockfile",
195
+ applied: "applied"
196
+ })[state];
197
+ var detectIndent = (src) => src.match(/^([ \t]+)"/m)?.[1] ?? " ";
198
+ var wrapComment = (text, width = 88) => {
199
+ const words = text.split(" ");
200
+ const lines = [];
201
+ let line = "";
202
+ for (const w of words) if (line && line.length + w.length + 1 > width) {
203
+ lines.push(line);
204
+ line = w;
205
+ } else line = line ? `${line} ${w}` : w;
206
+ if (line) lines.push(line);
207
+ return lines.join("\n ");
208
+ };
209
+ /**
210
+ * Copy canonical patches into <appDir>/patches/ and register them. Only
211
+ * patches whose package the app declares are applied — an entry for a
212
+ * package the manager never resolves produces a "patch not applied" warning at
213
+ * install for no benefit.
214
+ */
215
+ var applyPatches = (appDir, { force = false, packageManager } = {}) => {
216
+ appDir = packageManagerRoot(appDir);
217
+ const manager = packageManagerFor(appDir, packageManager);
218
+ const pkg = readJson(join(appDir, "package.json"));
219
+ if (!pkg) return { error: `no package.json in ${appDir}` };
220
+ const deps = resolveCatalogs(appDir, {
221
+ ...workspaceDeps(appDir, manager),
222
+ ...declaredDeps(pkg)
223
+ }, manager);
224
+ const configured = configuredPatches(appDir, { packageManager: manager });
225
+ const resolved = lockfileResolvedVersions(appDir, manager);
226
+ const report = {
227
+ copied: [],
228
+ kept: [],
229
+ conflicts: [],
230
+ skipped: []
231
+ };
232
+ const relevant = [];
233
+ for (const patch of patchesFor(manager)) {
234
+ const name = specifierPackage(patch.specifier);
235
+ const declared = deps[name];
236
+ const pinned = specifierVersion(patch.specifier);
237
+ if (declared === void 0 && !resolved?.[name]?.has(pinned)) {
238
+ report.skipped.push({
239
+ ...patch,
240
+ reason: "package not declared or installed"
241
+ });
242
+ continue;
243
+ }
244
+ if (!versionOk(declared, pinned, resolved?.[name])) {
245
+ report.skipped.push({
246
+ ...patch,
247
+ reason: `no install resolves ${name}@${pinned} — the patch would not apply`
248
+ });
249
+ continue;
250
+ }
251
+ relevant.push(patch);
252
+ }
253
+ const skipMerge = /* @__PURE__ */ new Set();
254
+ for (const patch of relevant) {
255
+ const src = join(canonicalPatchesDir, patch.file);
256
+ const target = `patches/${patch.file}`;
257
+ const configuredPath = configured[patch.specifier];
258
+ if (configuredPath && configuredPath !== target) {
259
+ const alt = join(appDir, configuredPath);
260
+ if (existsSync(alt) && sha(alt) === sha(src)) {
261
+ report.kept.push(patch);
262
+ skipMerge.add(patch.specifier);
263
+ continue;
264
+ }
265
+ if (!force) {
266
+ report.conflicts.push({
267
+ ...patch,
268
+ reason: `patchedDependencies maps ${patch.specifier} → ${configuredPath}`
269
+ });
270
+ continue;
271
+ }
272
+ }
273
+ const dst = join(appDir, target);
274
+ if (existsSync(dst)) {
275
+ if (sha(src) === sha(dst)) {
276
+ report.kept.push(patch);
277
+ continue;
278
+ }
279
+ if (!force) {
280
+ report.conflicts.push({
281
+ ...patch,
282
+ reason: `patches/${patch.file} exists and differs`
283
+ });
284
+ continue;
285
+ }
286
+ }
287
+ mkdirSync(dirname(dst), { recursive: true });
288
+ copyFileSync(src, dst);
289
+ report.copied.push(patch);
290
+ }
291
+ const landed = new Set([...report.copied, ...report.kept].map((p) => p.specifier));
292
+ mergeConfig(appDir, relevant.filter((p) => landed.has(p.specifier) && !skipMerge.has(p.specifier)), {
293
+ force,
294
+ report,
295
+ manager
296
+ });
297
+ return report;
298
+ };
299
+ var mergeConfig = (appDir, patches, { force, report, manager }) => {
300
+ if (manager === "pnpm") {
301
+ const file = join(appDir, "pnpm-workspace.yaml");
302
+ const doc = parseDocument(existsSync(file) ? readFileSync(file, "utf8") : "packages: []\n");
303
+ let pd = doc.get("patchedDependencies");
304
+ if (pd === void 0) {
305
+ doc.set("patchedDependencies", doc.createNode({}));
306
+ pd = doc.get("patchedDependencies");
307
+ } else if (!isMap(pd)) {
308
+ report.conflicts.push({
309
+ specifier: "patchedDependencies",
310
+ reason: "pnpm-workspace.yaml has a non-map patchedDependencies — merge by hand"
311
+ });
312
+ return;
313
+ }
314
+ let changed = false;
315
+ for (const patch of patches) {
316
+ const target = `patches/${patch.file}`;
317
+ const existing = pd.get(patch.specifier);
318
+ if (existing === target) continue;
319
+ if (existing !== void 0 && !force) {
320
+ report.conflicts.push({
321
+ ...patch,
322
+ reason: `patchedDependencies already maps ${patch.specifier} → ${existing}`
323
+ });
324
+ continue;
325
+ }
326
+ const key = new Scalar(patch.specifier);
327
+ key.commentBefore = " " + wrapComment(patch.why);
328
+ pd.set(key, target);
329
+ changed = true;
330
+ }
331
+ if (changed) writeFileSync(file, String(doc));
332
+ return;
333
+ }
334
+ const file = join(appDir, "package.json");
335
+ const src = readFileSync(file, "utf8");
336
+ const pkg = JSON.parse(src);
337
+ const owner = pkg;
338
+ owner.patchedDependencies ??= {};
339
+ let changed = false;
340
+ for (const patch of patches) {
341
+ const target = `patches/${patch.file}`;
342
+ const existing = owner.patchedDependencies[patch.specifier];
343
+ if (existing === target) continue;
344
+ if (existing !== void 0 && !force) {
345
+ report.conflicts.push({
346
+ ...patch,
347
+ reason: `${manager === "bun" ? "patchedDependencies" : "pnpm.patchedDependencies"} already maps ${patch.specifier} → ${existing}`
348
+ });
349
+ continue;
350
+ }
351
+ owner.patchedDependencies[patch.specifier] = target;
352
+ changed = true;
353
+ }
354
+ if (changed) writeFileSync(file, JSON.stringify(pkg, null, detectIndent(src)) + "\n");
355
+ };
356
+ export { applyPatches, canonicalPatchesDir, configuredPatches, declaredDeps, inspectPatches, loadPatchManifest, patchStateDetail, specifierPackage, wrapComment };
@@ -0,0 +1,53 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ // ../cli/src/route-config.ts
4
+ var object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
5
+ /** Validate configuration before writing generated files. A missing file means
6
+ * conventional file discovery; malformed configuration is never ignored. */
7
+ function loadRoutingConfig(cwd, options = {}) {
8
+ const path = resolve(cwd, "xplat.routes.json");
9
+ if (!existsSync(path)) return;
10
+ const fail = (field, expected) => {
11
+ throw new Error(`xplat.routes.json ${field}: expected ${expected}`);
12
+ };
13
+ const input = JSON.parse(readFileSync(path, "utf8"));
14
+ if (!object(input)) return fail("config", "an object");
15
+ const fields = [
16
+ "directory",
17
+ "out",
18
+ "manifests",
19
+ "context",
20
+ "transitions",
21
+ "stacks",
22
+ "base",
23
+ "allowedOrigins",
24
+ "allowedSchemes"
25
+ ];
26
+ for (const field of Object.keys(input)) if (!fields.includes(field)) fail(field, `one of ${fields.join(", ")}`);
27
+ for (const field of ["directory", "out"]) if (input[field] !== void 0 && (typeof input[field] !== "string" || !input[field])) fail(field, "a nonempty path");
28
+ const reference = (value, field) => {
29
+ if (!object(value) || Object.keys(value).some((key) => !["module", "export"].includes(key))) return fail(field, "{ module: \"./source\", export: \"exportName\" }");
30
+ if (typeof value.module !== "string" || !value.module.startsWith("./")) fail(`${field}.module`, "a source path starting with ./");
31
+ if (typeof value.export !== "string" || !/^[$A-Z_a-z][$\w]*$/.test(value.export)) fail(`${field}.export`, "an exported identifier");
32
+ const source = resolve(cwd, value.module);
33
+ if (!options.allowMissingSources && ![
34
+ "",
35
+ ".ts",
36
+ ".tsx",
37
+ ".tsrx",
38
+ ".mts",
39
+ ".js",
40
+ ".mjs"
41
+ ].some((ext) => existsSync(source + ext))) fail(`${field}.module`, `an existing source module (${value.module})`);
42
+ };
43
+ if (input.manifests !== void 0) {
44
+ if (!Array.isArray(input.manifests)) fail("manifests", "an array of source references");
45
+ input.manifests.forEach((value, i) => reference(value, `manifests[${i}]`));
46
+ }
47
+ for (const field of ["context", "transitions"]) if (input[field] !== void 0) reference(input[field], field);
48
+ if (input.stacks !== void 0 && (!Array.isArray(input.stacks) || input.stacks.some((value) => typeof value !== "string" || !/^[\w-]+$/.test(value)))) fail("stacks", "an array of URL-safe flow names");
49
+ if (input.base !== void 0 && (typeof input.base !== "string" || !input.base.startsWith("/") || input.base.startsWith("//") || /[?#\\]/.test(input.base))) fail("base", "an application path beginning with /");
50
+ for (const field of ["allowedOrigins", "allowedSchemes"]) if (input[field] !== void 0 && (!Array.isArray(input[field]) || input[field].some((value) => typeof value !== "string" || !value))) fail(field, "an array of nonempty strings");
51
+ return input;
52
+ }
53
+ export { loadRoutingConfig };
@@ -0,0 +1,42 @@
1
+ // ../cli/src/route-data.ts
2
+ /** Validate the exact JSON projection before a baked value enters a bundle.
3
+ * JSON.stringify alone silently drops fields, changes numbers and calls toJSON. */
4
+ function assertRouteDataJson(data, route, source) {
5
+ const ancestors = /* @__PURE__ */ new Set();
6
+ const fail = (path, reason) => {
7
+ throw new TypeError(`baked route '${route}' (${source}) at ${path}: ${reason}`);
8
+ };
9
+ const visit = (value, path) => {
10
+ if (value === null || typeof value === "string" || typeof value === "boolean") return;
11
+ if (typeof value === "number") {
12
+ if (!Number.isFinite(value) || Object.is(value, -0)) fail(path, "use a finite JSON number other than negative zero");
13
+ return;
14
+ }
15
+ if (typeof value !== "object") fail(path, `${typeof value} is not JSON data`);
16
+ const object = value;
17
+ if (ancestors.has(object)) fail(path, "cyclic data is not JSON");
18
+ const array = Array.isArray(object);
19
+ const prototype = Object.getPrototypeOf(object);
20
+ if (array && prototype !== Array.prototype && prototype !== null || !array && prototype !== Object.prototype && prototype !== null) fail(path, "use a plain JSON object; convert class instances explicitly");
21
+ ancestors.add(object);
22
+ try {
23
+ if (array) {
24
+ for (let index = 0; index < object.length; index++) if (!Object.hasOwn(object, index)) fail(`${path}[${index}]`, "array holes are not JSON data");
25
+ }
26
+ for (const key of Reflect.ownKeys(object)) {
27
+ if (typeof key !== "string") fail(path, "symbol keys are not JSON data");
28
+ if (array && key === "length") continue;
29
+ const field = array ? `${path}[${key}]` : `${path}[${JSON.stringify(key)}]`;
30
+ if (array && (!/^(0|[1-9]\d*)$/.test(key) || Number(key) >= object.length)) fail(field, "extra array properties would be lost");
31
+ const descriptor = Object.getOwnPropertyDescriptor(object, key);
32
+ if (!("value" in descriptor)) fail(field, "accessors are not JSON data");
33
+ if (!descriptor.enumerable) fail(field, "non-enumerable properties would be lost");
34
+ visit(descriptor.value, field);
35
+ }
36
+ } finally {
37
+ ancestors.delete(object);
38
+ }
39
+ };
40
+ visit(data, "$");
41
+ }
42
+ export { assertRouteDataJson };