@octane-xplat/build 0.0.1 → 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 +71 -9
@@ -0,0 +1,564 @@
1
+ import { isSafeMdParserUrl } from "./markdown-url.js";
2
+ import "./markdown-ast.js";
3
+ // ../ui/src/markdown/markdown-plugins.ts
4
+ var markdownTransformPluginName = Symbol("MarkdownTransformPluginName");
5
+ var markdownTransformHasRenderer = Symbol("MarkdownTransformHasRenderer");
6
+ var markdownTransformSourceUnchanged = Symbol("MarkdownTransformSourceUnchanged");
7
+ var markdownTransformClaim = Symbol("MarkdownTransformClaim");
8
+ /**
9
+ * Definition key of the first-party source-lines plugin
10
+ * (`module:Markdown/sourceLines`). It is a parse option, not syntax: the
11
+ * plugin enters parse identity so the parser records block lines during the
12
+ * parse it already runs, and no other entry can carry it.
13
+ */
14
+ var markdownSourceLinesDefinition = Symbol("MarkdownSourceLines");
15
+ var markdownTransformTrusted = Symbol("MarkdownTransformTrusted");
16
+ var MARKDOWN_PLUGIN_BRAND = "@octane-xplat/ui/MarkdownPluginEntry";
17
+ var markdownPluginDefinition = Symbol.for(MARKDOWN_PLUGIN_BRAND);
18
+ /**
19
+ * @internal Validates an opaque entry and returns its frozen definition for
20
+ * first-party modules that carry their own Symbol.for-branded portable data.
21
+ */
22
+ function getMarkdownPluginDefinition(publicEntry) {
23
+ if (publicEntry == null || typeof publicEntry !== "object" || Object.getPrototypeOf(publicEntry) !== Object.prototype) fail("entries must come from a compatible createMarkdownPlugin()");
24
+ const entry = publicEntry;
25
+ const brand = entry[markdownPluginDefinition];
26
+ const definition = brand?.definition;
27
+ if (Reflect.ownKeys(entry).length !== 3 || typeof entry.name !== "string" || entry.apiVersion !== 1 || !Object.isFrozen(entry) || brand == null || typeof brand !== "object" || Object.getPrototypeOf(brand) !== Object.prototype || Reflect.ownKeys(brand).length !== 3 || !Object.isFrozen(brand) || brand.kind !== MARKDOWN_PLUGIN_BRAND || brand.apiVersion !== 1 || definition == null || typeof definition !== "object" || !Object.isFrozen(definition) || definition.name !== entry.name || definition.apiVersion !== entry.apiVersion) fail("entries must come from a compatible createMarkdownPlugin()");
28
+ return definition;
29
+ }
30
+ function fail(message) {
31
+ throw new Error(`Markdown plugin: ${message}`);
32
+ }
33
+ var preparedPluginLists = /* @__PURE__ */ new WeakMap();
34
+ function appendMapValue(map, key, value) {
35
+ const current = map.get(key);
36
+ if (current == null) map.set(key, [value]);
37
+ else current.push(value);
38
+ }
39
+ function syntaxOnlyEntry(publicEntry) {
40
+ const entry = publicEntry;
41
+ const definition = getMarkdownPluginDefinition(publicEntry);
42
+ if (definition.transform == null) return publicEntry;
43
+ const syntaxDefinition = Object.freeze({
44
+ ...definition,
45
+ transform: void 0
46
+ });
47
+ return Object.freeze({
48
+ name: entry.name,
49
+ apiVersion: entry.apiVersion,
50
+ [markdownPluginDefinition]: Object.freeze({
51
+ kind: MARKDOWN_PLUGIN_BRAND,
52
+ apiVersion: 1,
53
+ definition: syntaxDefinition
54
+ })
55
+ });
56
+ }
57
+ function prepareMarkdownPlugins(plugins) {
58
+ if (plugins.length === 0) return;
59
+ const cached = preparedPluginLists.get(plugins);
60
+ if (cached != null) return cached;
61
+ const names = /* @__PURE__ */ new Set();
62
+ const inlineByFirstCharacter = /* @__PURE__ */ new Map();
63
+ const blockByFirstCharacter = /* @__PURE__ */ new Map();
64
+ const transforms = [];
65
+ const renderers = /* @__PURE__ */ new Map();
66
+ const syntaxIdentity = [];
67
+ const entries = [];
68
+ const syntaxEntries = [];
69
+ let sourceLines = false;
70
+ for (const publicEntry of plugins) {
71
+ const definition = getMarkdownPluginDefinition(publicEntry);
72
+ const entry = publicEntry;
73
+ if (names.has(definition.name)) fail(`duplicate name "${definition.name}"`);
74
+ names.add(definition.name);
75
+ entries.push(entry);
76
+ if (definition.transform != null) transforms.push({
77
+ pluginName: definition.name,
78
+ transform: definition.transform,
79
+ claims: definition.transform[markdownTransformClaim],
80
+ trusted: definition.transform[markdownTransformTrusted] === true
81
+ });
82
+ if (definition.renderers != null) for (const [nodeName, renderer] of Object.entries(definition.renderers)) renderers.set(`${definition.name}\0${nodeName}`, {
83
+ pluginName: definition.name,
84
+ renderer
85
+ });
86
+ if (definition[markdownSourceLinesDefinition] === true) {
87
+ sourceLines = true;
88
+ syntaxEntries.push(syntaxOnlyEntry(publicEntry));
89
+ syntaxIdentity.push(`${definition.name}\0${definition.apiVersion}\0source-lines`);
90
+ }
91
+ if ("syntax" in definition && definition.syntax != null) {
92
+ syntaxEntries.push(syntaxOnlyEntry(publicEntry));
93
+ syntaxIdentity.push(`${definition.name}\0${definition.apiVersion}\0${definition.parseKey}`);
94
+ for (const contribution of definition.syntax.inline ?? []) {
95
+ const prepared = {
96
+ pluginName: definition.name,
97
+ display: "inline",
98
+ contribution
99
+ };
100
+ for (const firstCharacter of new Set(contribution.startsWith.map((prefix) => prefix[0]))) appendMapValue(inlineByFirstCharacter, firstCharacter, prepared);
101
+ }
102
+ for (const contribution of definition.syntax.block ?? []) {
103
+ const prepared = {
104
+ pluginName: definition.name,
105
+ display: "block",
106
+ contribution
107
+ };
108
+ for (const firstCharacter of new Set(contribution.startsWith.map((prefix) => prefix[0]))) appendMapValue(blockByFirstCharacter, firstCharacter, prepared);
109
+ }
110
+ }
111
+ }
112
+ const prepared = {
113
+ entries,
114
+ syntaxEntries,
115
+ inlineByFirstCharacter,
116
+ blockByFirstCharacter,
117
+ transforms,
118
+ hasUntrustedTransform: transforms.some((entry) => !entry.trusted),
119
+ syntaxIdentity: syntaxIdentity.join(""),
120
+ renderers,
121
+ sourceLines
122
+ };
123
+ preparedPluginLists.set(plugins, prepared);
124
+ return prepared;
125
+ }
126
+ function isMarkdownPluginData(value, seen = /* @__PURE__ */ new Set()) {
127
+ if (value == null || typeof value === "boolean" || typeof value === "string") return true;
128
+ if (typeof value === "number") return Number.isFinite(value);
129
+ if (typeof value !== "object" || seen.has(value)) return false;
130
+ seen.add(value);
131
+ let valid;
132
+ if (Array.isArray(value)) valid = value.every((item) => isMarkdownPluginData(item, seen));
133
+ else if (Object.getPrototypeOf(value) !== Object.prototype) valid = false;
134
+ else valid = Object.values(value).every((item) => isMarkdownPluginData(item, seen));
135
+ seen.delete(value);
136
+ return valid;
137
+ }
138
+ function freezeMarkdownPluginData(value) {
139
+ if (value != null && typeof value === "object" && !Object.isFrozen(value)) {
140
+ for (const nested of Object.values(value)) freezeMarkdownPluginData(nested);
141
+ Object.freeze(value);
142
+ }
143
+ return value;
144
+ }
145
+ /**
146
+ * The identity of a source-backed node's position: its offsets, or, for a
147
+ * block nested in a list item or quote, which carries lines and no offsets
148
+ * while source lines are on (`markdownSourceLinesPlugin`), its lines.
149
+ */
150
+ function positionKey(position) {
151
+ const start = position?.start.offset;
152
+ const end = position?.end.offset;
153
+ if (start != null && end != null) return `${start}:${end}`;
154
+ const startLine = position?.start.line;
155
+ const endLine = position?.end.line;
156
+ return startLine == null || endLine == null ? null : `line ${startLine}:${endLine}`;
157
+ }
158
+ /** A position's two points measure the same thing and never run backwards. */
159
+ function isValidPosition(position) {
160
+ const measures = [[
161
+ position.start?.offset,
162
+ position.end?.offset,
163
+ 0
164
+ ], [
165
+ position.start?.line,
166
+ position.end?.line,
167
+ 1
168
+ ]];
169
+ let measured = false;
170
+ for (const [start, end, minimum] of measures) {
171
+ if (start === void 0 && end === void 0) continue;
172
+ if (!Number.isInteger(start) || !Number.isInteger(end) || start < minimum || end < start) return false;
173
+ measured = true;
174
+ }
175
+ return measured;
176
+ }
177
+ function codeSourceSignature(node) {
178
+ return JSON.stringify([
179
+ node.lang,
180
+ node.meta,
181
+ node.value,
182
+ node.position ?? null
183
+ ]);
184
+ }
185
+ function collectCodeInternalProperties(root) {
186
+ const properties = /* @__PURE__ */ new Map();
187
+ const visit = (node) => {
188
+ if (node.type === "code") {
189
+ const descriptors = Object.getOwnPropertySymbols(node).map((symbol) => [symbol, Object.getOwnPropertyDescriptor(node, symbol)]).filter((entry) => entry[1]?.enumerable === true);
190
+ if (descriptors.length > 0) {
191
+ const key = codeSourceSignature(node);
192
+ properties.set(key, [...properties.get(key) ?? [], { descriptors }]);
193
+ }
194
+ }
195
+ if ("children" in node && Array.isArray(node.children)) {
196
+ for (const child of node.children) if (child != null && typeof child === "object") visit(child);
197
+ }
198
+ };
199
+ for (const child of root.children) visit(child);
200
+ return properties;
201
+ }
202
+ function restoreCodeInternalProperties(previous, next) {
203
+ const properties = collectCodeInternalProperties(previous);
204
+ if (properties.size === 0) return next;
205
+ const visit = (node) => {
206
+ let current = node;
207
+ if (node.type === "code") {
208
+ const key = codeSourceSignature(node);
209
+ const internal = properties.get(key)?.shift();
210
+ const shouldRestore = internal?.descriptors.some(([symbol, descriptor]) => {
211
+ const current = Object.getOwnPropertyDescriptor(node, symbol);
212
+ return current == null || current.value !== descriptor.value || current.get !== descriptor.get || current.set !== descriptor.set || current.enumerable !== descriptor.enumerable || current.configurable !== descriptor.configurable || current.writable !== descriptor.writable;
213
+ });
214
+ if (internal != null && shouldRestore === true) {
215
+ const clone = { ...node };
216
+ for (const [symbol, descriptor] of internal.descriptors) Object.defineProperty(clone, symbol, descriptor);
217
+ current = clone;
218
+ }
219
+ }
220
+ if ("children" in current && Array.isArray(current.children)) {
221
+ const currentChildren = current.children;
222
+ const children = currentChildren.map((child) => visit(child));
223
+ if (children.some((child, index) => child !== currentChildren[index])) current = {
224
+ ...current,
225
+ children
226
+ };
227
+ }
228
+ return current;
229
+ };
230
+ return {
231
+ ...next,
232
+ children: next.children.map((child) => visit(child))
233
+ };
234
+ }
235
+ function collectSourceInvariants(root) {
236
+ const positions = /* @__PURE__ */ new Map();
237
+ const visit = (node) => {
238
+ const key = positionKey(node.position);
239
+ if (key != null) {
240
+ const record = node;
241
+ const invariant = {
242
+ type: node.type,
243
+ startLine: record.position != null ? record.position.start.line : void 0,
244
+ endLine: record.position != null ? record.position.end.line : void 0,
245
+ depth: record.depth,
246
+ ordered: record.ordered,
247
+ start: record.start,
248
+ delimiter: record.delimiter,
249
+ plugin: record.plugin,
250
+ name: record.name,
251
+ display: record.display
252
+ };
253
+ positions.set(key, [...positions.get(key) ?? [], invariant]);
254
+ }
255
+ if ("children" in node && Array.isArray(node.children)) {
256
+ for (const child of node.children) if (child != null && typeof child === "object") visit(child);
257
+ }
258
+ };
259
+ for (const child of root.children) visit(child);
260
+ return positions;
261
+ }
262
+ function extensionSignature(node) {
263
+ return JSON.stringify([
264
+ node.plugin,
265
+ node.name,
266
+ node.display,
267
+ node.data,
268
+ node.source,
269
+ positionKey(node.position)
270
+ ]);
271
+ }
272
+ function collectExtensionSignatures(root) {
273
+ const signatures = /* @__PURE__ */ new Map();
274
+ const visit = (node) => {
275
+ if (node.type === "extension") {
276
+ const signature = extensionSignature(node);
277
+ const existing = signatures.get(signature);
278
+ signatures.set(signature, {
279
+ plugin: String(node.plugin),
280
+ count: (existing?.count ?? 0) + 1
281
+ });
282
+ }
283
+ if ("children" in node && Array.isArray(node.children)) {
284
+ for (const child of node.children) if (child != null && typeof child === "object") visit(child);
285
+ }
286
+ };
287
+ for (const child of root.children) visit(child);
288
+ return signatures;
289
+ }
290
+ var sourceHeadingMarker = Symbol("MarkdownSourceHeading");
291
+ function markSourceHeadings(root) {
292
+ const markers = /* @__PURE__ */ new Set();
293
+ const visit = (node) => {
294
+ if (node.type === "heading" && !(sourceHeadingMarker in node)) Object.defineProperty(node, sourceHeadingMarker, {
295
+ configurable: false,
296
+ enumerable: true,
297
+ value: Object.freeze({ depth: node.depth }),
298
+ writable: false
299
+ });
300
+ if (node.type === "heading") markers.add(node[sourceHeadingMarker]);
301
+ if ("children" in node && Array.isArray(node.children)) {
302
+ for (const child of node.children) if (child != null && typeof child === "object") visit(child);
303
+ }
304
+ };
305
+ for (const child of root.children) visit(child);
306
+ return markers;
307
+ }
308
+ var PHRASING_TYPES = /* @__PURE__ */ new Set([
309
+ "text",
310
+ "strong",
311
+ "emphasis",
312
+ "delete",
313
+ "inlineCode",
314
+ "inlineMath",
315
+ "break",
316
+ "link",
317
+ "image",
318
+ "citation"
319
+ ]);
320
+ var BLOCK_TYPES = /* @__PURE__ */ new Set([
321
+ "heading",
322
+ "paragraph",
323
+ "code",
324
+ "math",
325
+ "blockquote",
326
+ "list",
327
+ "table",
328
+ "thematicBreak",
329
+ "image"
330
+ ]);
331
+ var PHRASING_PARENTS = /* @__PURE__ */ new Set([
332
+ "heading",
333
+ "paragraph",
334
+ "strong",
335
+ "emphasis",
336
+ "delete",
337
+ "link",
338
+ "tableCell"
339
+ ]);
340
+ var BLOCK_PARENTS = /* @__PURE__ */ new Set([
341
+ "root",
342
+ "blockquote",
343
+ "listItem"
344
+ ]);
345
+ var CHILD_PARENT_TYPES = /* @__PURE__ */ new Set([
346
+ ...PHRASING_PARENTS,
347
+ ...BLOCK_PARENTS,
348
+ "list",
349
+ "table",
350
+ "tableRow"
351
+ ]);
352
+ function validateAst(doc, pluginNames, rendererKeys, sourcePositions, sourceHeadingMarkers, activePluginName, existingExtensions, display) {
353
+ if (doc == null || typeof doc !== "object") return false;
354
+ if (doc.kind !== "octane-xplat/md" || doc.v !== 2) return false;
355
+ if (doc.data !== void 0 && !isMarkdownPluginData(doc.data)) return false;
356
+ const seen = /* @__PURE__ */ new Set();
357
+ const seenHeadingMarkers = /* @__PURE__ */ new Set();
358
+ let count = 0;
359
+ const visit = (value, parent, insideLink) => {
360
+ if (value == null || typeof value !== "object" || seen.has(value)) return false;
361
+ if (++count > 1e5) return false;
362
+ seen.add(value);
363
+ const node = value;
364
+ const type = node.type;
365
+ if (typeof type !== "string") return false;
366
+ if (node.data !== void 0 && !isMarkdownPluginData(node.data)) return false;
367
+ if (parent != null) {
368
+ const extensionDisplay = type === "extension" ? node.display : void 0;
369
+ const phrasing = PHRASING_TYPES.has(type) || extensionDisplay === "inline";
370
+ const block = BLOCK_TYPES.has(type) || extensionDisplay === "block";
371
+ if (PHRASING_PARENTS.has(parent) && !phrasing || BLOCK_PARENTS.has(parent) && !block || insideLink && type === "link" || parent === "list" && type !== "listItem" || parent === "table" && type !== "tableRow" || parent === "tableRow" && type !== "tableCell") return false;
372
+ }
373
+ const position = node.position;
374
+ const key = positionKey(position);
375
+ if (position != null && !isValidPosition(position)) return false;
376
+ if (key != null) {
377
+ const invariants = sourcePositions.get(key) ?? [];
378
+ const invariantIndex = invariants.findIndex((invariant) => invariant.type === type && invariant.startLine === position?.start?.line && invariant.endLine === position?.end?.line && invariant.depth === node.depth && invariant.ordered === node.ordered && invariant.start === node.start && invariant.delimiter === node.delimiter && invariant.plugin === node.plugin && invariant.name === node.name && invariant.display === node.display);
379
+ if (invariantIndex < 0) return false;
380
+ invariants.splice(invariantIndex, 1);
381
+ }
382
+ if (type !== "extension" && node.source !== void 0) return false;
383
+ switch (type) {
384
+ case "heading": {
385
+ if (![
386
+ 1,
387
+ 2,
388
+ 3,
389
+ 4,
390
+ 5,
391
+ 6
392
+ ].includes(node.depth)) return false;
393
+ const marker = node[sourceHeadingMarker];
394
+ if (marker != null && (!sourceHeadingMarkers.has(marker) || marker.depth !== node.depth || seenHeadingMarkers.has(marker))) return false;
395
+ if (marker != null) seenHeadingMarkers.add(marker);
396
+ break;
397
+ }
398
+ case "text":
399
+ case "inlineCode":
400
+ case "inlineMath":
401
+ case "math":
402
+ if (typeof node.value !== "string") return false;
403
+ break;
404
+ case "code":
405
+ if (typeof node.value !== "string" || node.lang !== null && typeof node.lang !== "string" || node.meta !== void 0 && typeof node.meta !== "string") return false;
406
+ break;
407
+ case "link":
408
+ if (typeof node.url !== "string" || !isSafeMdParserUrl(node.url)) return false;
409
+ break;
410
+ case "image":
411
+ if (typeof node.url !== "string" || !isSafeMdParserUrl(node.url) || typeof node.alt !== "string") return false;
412
+ break;
413
+ case "citation":
414
+ if (typeof node.sourceId !== "string") return false;
415
+ break;
416
+ case "list":
417
+ if (typeof node.ordered !== "boolean" || node.start != null && !Number.isFinite(node.start) || node.delimiter != null && node.delimiter !== "." && node.delimiter !== ")") return false;
418
+ break;
419
+ case "table":
420
+ if (!Array.isArray(node.align) || !node.align.every((value) => value === null || value === "left" || value === "center" || value === "right")) return false;
421
+ break;
422
+ case "extension": {
423
+ if (typeof node.plugin !== "string" || !pluginNames.has(node.plugin) || typeof node.name !== "string" || node.display !== "inline" && node.display !== "block" || !isMarkdownPluginData(node.data) || !rendererKeys.has(`${node.plugin}\0${node.name}`)) return false;
424
+ const signature = extensionSignature(node);
425
+ const existing = existingExtensions.get(signature);
426
+ if (existing != null && existing.count > 0) existing.count--;
427
+ else if (node.plugin !== activePluginName || node.source !== void 0 || node.position !== void 0) return false;
428
+ break;
429
+ }
430
+ case "strong":
431
+ case "emphasis":
432
+ case "delete":
433
+ case "break":
434
+ case "paragraph":
435
+ case "blockquote":
436
+ case "listItem":
437
+ case "tableRow":
438
+ case "tableCell":
439
+ case "thematicBreak": break;
440
+ default: return false;
441
+ }
442
+ if (CHILD_PARENT_TYPES.has(type)) {
443
+ if (!Array.isArray(node.children)) return false;
444
+ for (const child of node.children) if (!visit(child, type, insideLink || type === "link")) return false;
445
+ } else if ("children" in node) return false;
446
+ return true;
447
+ };
448
+ return doc.children.every((child) => visit(child, "root", false)) && Array.from(existingExtensions.values()).every((extension) => extension.plugin === activePluginName || extension.count === 0) && (display === "block" || doc.children.length === 1 && doc.children[0]?.type === "paragraph");
449
+ }
450
+ /**
451
+ * Deeply freezes a Markdown tree.
452
+ *
453
+ * No memo set and no cycle set. Both were measured against this parser's own
454
+ * fixture and together cost four times the freezing they were guarding: a
455
+ * full freeze of a 12k-node tree runs at 19 percent of the parse that built
456
+ * it, a WeakSet memo takes that to 47 percent, and a cycle set to 75. Their
457
+ * absence is safe, not merely cheap: every tree reaching here is acyclic
458
+ * (the parser builds no cycles, and `validateAst` rejects any plugin tree
459
+ * that contains one), and `Object.freeze` on an already-frozen node is a
460
+ * no-op, so re-walking a shared subtree is correct — just not free.
461
+ *
462
+ * Deliberately NOT skipping nodes that look frozen: a node a plugin froze
463
+ * itself may still hold mutable children, and an undecorated sibling a
464
+ * trusted helper carried over by identity must be frozen like any other.
465
+ */
466
+ function freezeAstNode(value) {
467
+ if (value == null || typeof value !== "object") return;
468
+ if (Array.isArray(value)) for (let index = 0; index < value.length; index++) freezeAstNode(value[index]);
469
+ else for (const key in value) freezeAstNode(value[key]);
470
+ Object.freeze(value);
471
+ }
472
+ function freezeAst(value) {
473
+ freezeAstNode(value);
474
+ return value;
475
+ }
476
+ var reportedProductionPluginFailures = /* @__PURE__ */ new Set();
477
+ /**
478
+ * Freezes only what `next` does not share with `previous`.
479
+ *
480
+ * Valid ONLY when no plugin-authored transform runs in this pipeline. The
481
+ * nodes it skips are the ones a Core helper carried over untouched, and with
482
+ * every transform Core-authored there is no actor that could mutate them:
483
+ * they are left in exactly the state an omitted or empty plugin list leaves
484
+ * them in, which is the state rendering already observes for every
485
+ * zero-plugin document today. The moment one untrusted transform exists,
486
+ * `applyMarkdownTransforms` uses the full `freezeAst` instead, before that
487
+ * transform observes anything — a shared, undecorated sibling included.
488
+ */
489
+ function freezeBuiltAst(previous, next) {
490
+ if (next == null || typeof next !== "object" || next === previous) return next;
491
+ const before = previous != null && typeof previous === "object" ? previous : void 0;
492
+ if (Array.isArray(next)) {
493
+ const beforeArray = Array.isArray(previous) ? previous : void 0;
494
+ for (let index = 0; index < next.length; index++) freezeBuiltAst(beforeArray?.[index], next[index]);
495
+ } else for (const key in next) freezeBuiltAst(before?.[key], next[key]);
496
+ Object.freeze(next);
497
+ return next;
498
+ }
499
+ function reportMarkdownPluginFailure(pluginName, phase, error) {
500
+ const key = `markdown-plugin:${pluginName}:${phase}`;
501
+ const message = `plugin "${pluginName}" failed in ${phase}; rendered readable fallback.`;
502
+ if (!reportedProductionPluginFailures.has(key)) {
503
+ reportedProductionPluginFailures.add(key);
504
+ console.error(`Markdown: ${message}`);
505
+ }
506
+ }
507
+ function applyMarkdownTransforms(root, plugins, source, isFinal, display) {
508
+ if (plugins == null || plugins.transforms.length === 0) return root;
509
+ let pluginNames;
510
+ let rendererKeys;
511
+ let document = root;
512
+ const sourceHeadingMarkers = plugins.hasUntrustedTransform ? markSourceHeadings(document) : void 0;
513
+ let guarded = false;
514
+ let priorTransformChangedTree = false;
515
+ /** A trusted helper has produced a tree nothing has frozen yet. */
516
+ let deferredFreeze = false;
517
+ for (const prepared of plugins.transforms) {
518
+ if (!priorTransformChangedTree && prepared.claims?.(source) === false) continue;
519
+ if (!prepared.trusted) {
520
+ if (!guarded) {
521
+ pluginNames = new Set(plugins.entries.map((entry) => entry.name));
522
+ rendererKeys = new Set(plugins.renderers.keys());
523
+ guarded = true;
524
+ }
525
+ document = freezeAst(document);
526
+ deferredFreeze = false;
527
+ }
528
+ try {
529
+ const context = {
530
+ source,
531
+ isFinal,
532
+ display,
533
+ report(message) {
534
+ reportMarkdownPluginFailure(prepared.pluginName, "transform", message);
535
+ },
536
+ [markdownTransformPluginName]: prepared.pluginName,
537
+ [markdownTransformHasRenderer]: (nodeName) => plugins.renderers.has(`${prepared.pluginName}\0${nodeName}`),
538
+ [markdownTransformSourceUnchanged]: !priorTransformChangedTree
539
+ };
540
+ const next = prepared.transform(document, context);
541
+ if (next != null && typeof next === "object" && typeof next.then === "function") {
542
+ Promise.resolve(next).catch(() => {});
543
+ throw new TypeError("Async Markdown transforms are not supported");
544
+ }
545
+ if (next === document) continue;
546
+ if (prepared.trusted) {
547
+ priorTransformChangedTree = true;
548
+ deferredFreeze = true;
549
+ document = next;
550
+ continue;
551
+ }
552
+ const positions = collectSourceInvariants(document);
553
+ const existingExtensions = collectExtensionSignatures(document);
554
+ if (!validateAst(next, pluginNames, rendererKeys, positions, sourceHeadingMarkers, prepared.pluginName, existingExtensions, display)) throw new TypeError("Transform returned an invalid Markdown document");
555
+ priorTransformChangedTree = true;
556
+ document = freezeAst(restoreCodeInternalProperties(document, next));
557
+ } catch (error) {
558
+ reportMarkdownPluginFailure(prepared.pluginName, "transform", error);
559
+ }
560
+ }
561
+ if (!deferredFreeze) return document;
562
+ return plugins.hasUntrustedTransform ? freezeAst(document) : freezeBuiltAst(root, document);
563
+ }
564
+ export { applyMarkdownTransforms, freezeMarkdownPluginData, getMarkdownPluginDefinition, isMarkdownPluginData, prepareMarkdownPlugins, reportMarkdownPluginFailure };
@@ -0,0 +1,17 @@
1
+ // ../ui/src/markdown/markdown-url.ts
2
+ function normalizeUrl(url) {
3
+ return url.replace(/[\x00-\x1f\x7f]/g, "").trim();
4
+ }
5
+ /** The form a URL's scheme is compared in: lowercase, and without the spaces
6
+ * after the scheme's colon, which a data URL's media type ignores
7
+ * (`data: text/html` is HTML). */
8
+ function comparableUrl(normalized) {
9
+ return normalized.toLowerCase().replace(/^([a-z][a-z\d+.-]*:) +/, "$1");
10
+ }
11
+ /** Whether the parser may turn this destination into a link/image node.
12
+ * Matches the reference parser's acceptance exactly. */
13
+ function isSafeMdParserUrl(url) {
14
+ const lower = comparableUrl(normalizeUrl(url));
15
+ return !(lower.startsWith("javascript:") || lower.startsWith("vbscript:") || lower.startsWith("data:text/html"));
16
+ }
17
+ export { isSafeMdParserUrl };
@@ -0,0 +1,34 @@
1
+ import { lstatSync, realpathSync, statSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import { dirname, join, sep } from "node:path";
4
+ // ../cli/src/updates-worker.ts
5
+ function checkUpdatesDependencies() {
6
+ const project = realpathSync(process.cwd());
7
+ const require = createRequire(join(project, "package.json"));
8
+ return {
9
+ version: 1,
10
+ project,
11
+ resolved: [["@octane-xplat/updates", "@octane-xplat/updates/prepare"], ["@octane-xplat/fingerprint", "@octane-xplat/fingerprint"]].map(([name, specifier]) => {
12
+ for (let at = project;; at = dirname(at)) {
13
+ const candidate = join(at, "node_modules", name);
14
+ let found = false;
15
+ try {
16
+ lstatSync(candidate);
17
+ found = true;
18
+ } catch (error) {
19
+ if (error.code !== "ENOENT") throw error;
20
+ }
21
+ if (found) {
22
+ const root = realpathSync(candidate), entry = realpathSync(require.resolve(specifier));
23
+ if (!entry.startsWith(root + sep) || !statSync(entry).isFile()) throw new Error(`Reinstall ${name} in the selected project: invalid entry point`);
24
+ return {
25
+ specifier,
26
+ entry
27
+ };
28
+ }
29
+ if (dirname(at) === at) throw new Error(`Install ${name} in the selected project before running updates init`);
30
+ }
31
+ })
32
+ };
33
+ }
34
+ export { checkUpdatesDependencies };
@@ -0,0 +1,63 @@
1
+ import { compatibility } from "./compatibility-data/compatibility.js";
2
+ import { applyUpgrade, planUpgrade } from "./compatibility.js";
3
+ import { packageManagerFor, packageManagerRoot } from "./package-manager.js";
4
+ import { inspectCompatibility } from "./compatibility-check.js";
5
+ import { inspectPatches, patchStateDetail } from "./patches.js";
6
+ import { realpathSync } from "node:fs";
7
+ import { relative } from "node:path";
8
+ import { createHash } from "node:crypto";
9
+ import { spawnSync } from "node:child_process";
10
+ // ../cli/src/upgrade-worker.ts
11
+ function upgradeOperation(request) {
12
+ const root = realpathSync(packageManagerRoot(process.cwd()));
13
+ const manager = packageManagerFor(root);
14
+ if (typeof request.workspaceRoot !== "string" || realpathSync(request.workspaceRoot) !== root || request.expectedManager !== manager) throw new Error("Upgrade workspace or package manager changed; retry the operation");
15
+ if (request.frameworkVersion !== compatibility.frameworkVersion) throw new Error(`Upgrade requires the CLI worker for framework ${request.frameworkVersion}; the selected project worker provides ${compatibility.frameworkVersion}. Install the matching CLI worker before upgrading.`);
16
+ const data = {
17
+ version: 1,
18
+ root,
19
+ manager,
20
+ frameworkVersion: compatibility.frameworkVersion
21
+ };
22
+ if (request.operation === "upgrade-install") {
23
+ const windows = process.platform === "win32";
24
+ const install = spawnSync(windows ? `${manager} install --no-frozen-lockfile` : manager, windows ? [] : ["install", "--no-frozen-lockfile"], {
25
+ cwd: root,
26
+ shell: windows,
27
+ stdio: "inherit"
28
+ });
29
+ if (install.error) throw install.error;
30
+ return {
31
+ ...data,
32
+ exitCode: install.status ?? 1
33
+ };
34
+ }
35
+ const plan = planUpgrade(process.cwd());
36
+ const digest = createHash("sha256").update(JSON.stringify(plan)).digest("hex");
37
+ if (request.operation === "upgrade-plan") return {
38
+ ...data,
39
+ plan,
40
+ digest
41
+ };
42
+ if (request.operation === "upgrade-apply") {
43
+ if (request.digest !== digest) throw new Error("Workspace changed during upgrade; rerun xplat upgrade");
44
+ applyUpgrade(plan);
45
+ return {
46
+ ...data,
47
+ digest,
48
+ written: plan.files.length
49
+ };
50
+ }
51
+ if (request.operation !== "upgrade-verify") throw new Error("Unsupported upgrade operation");
52
+ const issues = plan.projects.flatMap((project) => inspectCompatibility(project).filter((row) => !row.ok).map((row) => `${relative(root, project) || "."}: ${row.name}: ${row.detail}`));
53
+ for (const patch of inspectPatches(root)) if (![
54
+ "applied",
55
+ "not-declared",
56
+ "not-applicable"
57
+ ].includes(patch.state)) issues.push(`${patch.specifier}: ${patchStateDetail(patch.state)}`);
58
+ return {
59
+ ...data,
60
+ issues
61
+ };
62
+ }
63
+ export { upgradeOperation };