@octane-xplat/build 0.0.0-nightly.g1b95ef7

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 (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/add-worker.js +66 -0
  4. package/dist/build-worker.js +287 -0
  5. package/dist/compatibility-check.js +155 -0
  6. package/dist/compatibility-data/compatibility.js +109 -0
  7. package/dist/compatibility-data/compatibility.json +298 -0
  8. package/dist/compatibility.js +240 -0
  9. package/dist/css-platform.js +236 -0
  10. package/dist/css-platform.types.d.ts +11 -0
  11. package/dist/dev-inspector.web.js +125 -0
  12. package/dist/dev-log-client.web.js +79 -0
  13. package/dist/dev-log-server.js +13 -0
  14. package/dist/devtools-worker.js +94 -0
  15. package/dist/doctor-checks.js +414 -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 +44 -0
  22. package/dist/linux/config.js +43 -0
  23. package/dist/linux/gtk-runtime.js +86 -0
  24. package/dist/linux/package.js +189 -0
  25. package/dist/linux-gtk/bindings.mjs +675 -0
  26. package/dist/linux-gtk/native-gi-projection.js +36 -0
  27. package/dist/linux-gtk/vite.d.ts +39 -0
  28. package/dist/linux-gtk/vite.js +281 -0
  29. package/dist/macos/config.js +136 -0
  30. package/dist/macos/core-ui.js +59 -0
  31. package/dist/macos/core-vite.js +122 -0
  32. package/dist/macos/doctor-checks.js +58 -0
  33. package/dist/macos/executables.js +39 -0
  34. package/dist/macos/jsc-host/runtime.js +134 -0
  35. package/dist/macos/native.js +286 -0
  36. package/dist/macos/runtime-package.js +30 -0
  37. package/dist/macos/tab-item.js +62 -0
  38. package/dist/macos/vite.d.ts +13 -0
  39. package/dist/macos/vite.js +22 -0
  40. package/dist/markdown.js +11 -0
  41. package/dist/mason-engine.js +20 -0
  42. package/dist/mcp/contracts/actions.js +133 -0
  43. package/dist/mcp/dev-bridge.js +363 -0
  44. package/dist/mcp/dev-socket.js +203 -0
  45. package/dist/mcp/dev-stack.js +134 -0
  46. package/dist/mcp/inspection/dom.web.js +46 -0
  47. package/dist/native-regex.js +123 -0
  48. package/dist/package-manager.js +106 -0
  49. package/dist/package-root.js +48 -0
  50. package/dist/patches.js +356 -0
  51. package/dist/route-config.js +53 -0
  52. package/dist/route-data.js +42 -0
  53. package/dist/route-generator.js +514 -0
  54. package/dist/route-path.js +29 -0
  55. package/dist/route-source.js +67 -0
  56. package/dist/targets.js +37 -0
  57. package/dist/tsconfig-envs.js +400 -0
  58. package/dist/tsconfig-pin.js +31 -0
  59. package/dist/tsrx-leaf.js +57 -0
  60. package/dist/typecheck-globals/macos.d.ts +21 -0
  61. package/dist/typecheck-globals/native.d.ts +42 -0
  62. package/dist/ui/src/markdown/markdown-ast.js +33 -0
  63. package/dist/ui/src/markdown/markdown-character-references.js +79 -0
  64. package/dist/ui/src/markdown/markdown-parse.js +1930 -0
  65. package/dist/ui/src/markdown/markdown-plugins.js +564 -0
  66. package/dist/ui/src/markdown/markdown-url.js +17 -0
  67. package/dist/updates-worker.js +34 -0
  68. package/dist/upgrade-worker.js +63 -0
  69. package/dist/vite-target.js +57 -0
  70. package/dist/vite.d.ts +125 -0
  71. package/dist/vite.js +797 -0
  72. package/dist/workshop-worker.js +181 -0
  73. package/package.json +74 -0
@@ -0,0 +1,298 @@
1
+ {
2
+ "$comment": "Release compatibility set, shared by create-octane-xplat and xplat doctor/upgrade. Edit external pins here, then run bun run sync:compatibility. Framework package names are generated from the lockstep release set. Optional packages are managed only when declared; library consumer peer ranges remain app-owned.",
3
+ "schemaVersion": 1,
4
+ "frameworkVersion": "0.0.0-nightly.g1b95ef7",
5
+ "tools": {
6
+ "nodeMinimum": "22.22.2",
7
+ "bun": "1.4.4",
8
+ "pnpm": "11.24.0"
9
+ },
10
+ "frameworkPackages": [
11
+ "@octane-xplat/ads",
12
+ "@octane-xplat/app-menu",
13
+ "@octane-xplat/audio",
14
+ "@octane-xplat/auth",
15
+ "@octane-xplat/background-tasks",
16
+ "@octane-xplat/bamboo",
17
+ "@octane-xplat/barcode-scanner",
18
+ "@octane-xplat/billing",
19
+ "@octane-xplat/biometrics",
20
+ "@octane-xplat/build",
21
+ "@octane-xplat/calendar",
22
+ "@octane-xplat/camera",
23
+ "@octane-xplat/canvas",
24
+ "@octane-xplat/charts",
25
+ "@octane-xplat/cli",
26
+ "@octane-xplat/contacts",
27
+ "@octane-xplat/context-menu",
28
+ "@octane-xplat/crypto",
29
+ "@octane-xplat/css-engine",
30
+ "@octane-xplat/date-picker",
31
+ "@octane-xplat/devtools",
32
+ "@octane-xplat/dnd-kit",
33
+ "@octane-xplat/docs-search",
34
+ "@octane-xplat/effects",
35
+ "@octane-xplat/files",
36
+ "@octane-xplat/fingerprint",
37
+ "@octane-xplat/firebase-analytics",
38
+ "@octane-xplat/firebase-crashlytics",
39
+ "@octane-xplat/form",
40
+ "@octane-xplat/geofencing",
41
+ "@octane-xplat/geolocation",
42
+ "@octane-xplat/gif",
43
+ "@octane-xplat/global-shortcuts",
44
+ "@octane-xplat/haptics",
45
+ "@octane-xplat/icons",
46
+ "@octane-xplat/image",
47
+ "@octane-xplat/image-crop",
48
+ "@octane-xplat/image-manipulator",
49
+ "@octane-xplat/intersection-observer",
50
+ "@octane-xplat/jsx",
51
+ "@octane-xplat/keyboard",
52
+ "@octane-xplat/lexical",
53
+ "@octane-xplat/lib",
54
+ "@octane-xplat/lingui",
55
+ "@octane-xplat/lint",
56
+ "@octane-xplat/linux-gtk",
57
+ "@octane-xplat/lottie",
58
+ "@octane-xplat/macos-appkit",
59
+ "@octane-xplat/macos-build",
60
+ "@octane-xplat/maps",
61
+ "@octane-xplat/mcp",
62
+ "@octane-xplat/media",
63
+ "@octane-xplat/media-converter",
64
+ "@octane-xplat/media-library",
65
+ "@octane-xplat/motion",
66
+ "@octane-xplat/nano-icons",
67
+ "@octane-xplat/nativescript-octane",
68
+ "@octane-xplat/network",
69
+ "@octane-xplat/notifications",
70
+ "@octane-xplat/pager",
71
+ "@octane-xplat/picker",
72
+ "@octane-xplat/platform",
73
+ "@octane-xplat/posthog",
74
+ "@octane-xplat/pretext",
75
+ "@octane-xplat/print",
76
+ "@octane-xplat/push",
77
+ "@octane-xplat/recorder",
78
+ "@octane-xplat/richtext",
79
+ "@octane-xplat/rolling-text",
80
+ "@octane-xplat/screen-orientation",
81
+ "@octane-xplat/secure-storage",
82
+ "@octane-xplat/sentry",
83
+ "@octane-xplat/shaders",
84
+ "@octane-xplat/share",
85
+ "@octane-xplat/sheet",
86
+ "@octane-xplat/shortcuts",
87
+ "@octane-xplat/smooth-corners",
88
+ "@octane-xplat/sounds",
89
+ "@octane-xplat/speech-recognition",
90
+ "@octane-xplat/splash-screen",
91
+ "@octane-xplat/sqlite",
92
+ "@octane-xplat/store-review",
93
+ "@octane-xplat/stripe",
94
+ "@octane-xplat/table",
95
+ "@octane-xplat/tailwind",
96
+ "@octane-xplat/tiptap",
97
+ "@octane-xplat/tracking-transparency",
98
+ "@octane-xplat/tray",
99
+ "@octane-xplat/tweaks",
100
+ "@octane-xplat/ui",
101
+ "@octane-xplat/updates",
102
+ "@octane-xplat/video",
103
+ "@octane-xplat/view-shot",
104
+ "@octane-xplat/vite-octane",
105
+ "@octane-xplat/web-browser",
106
+ "@octane-xplat/web-host",
107
+ "@octane-xplat/workshop",
108
+ "create-octane-xplat",
109
+ "octane-xplat"
110
+ ],
111
+ "packages": {
112
+ "octane": {
113
+ "version": "0.23.2",
114
+ "group": "runtime",
115
+ "singleton": true
116
+ },
117
+ "@nativescript/core": {
118
+ "version": "9.1.3",
119
+ "group": "runtime",
120
+ "singleton": true
121
+ },
122
+ "typescript": {
123
+ "version": "7.1.0-dev.20261121.1",
124
+ "group": "compiler"
125
+ },
126
+ "@tsrx/oxc": {
127
+ "version": "0.24.0",
128
+ "group": "compiler"
129
+ },
130
+ "tsrx-typegen": {
131
+ "version": "0.6.2",
132
+ "group": "compiler"
133
+ },
134
+ "vite": {
135
+ "version": "8.3.6",
136
+ "group": "bundler"
137
+ },
138
+ "@octanejs/vite-plugin": {
139
+ "version": "0.6.6",
140
+ "group": "bundler"
141
+ },
142
+ "@nativescript/vite": {
143
+ "version": "8.0.20",
144
+ "group": "bundler"
145
+ },
146
+ "nativescript": {
147
+ "version": "9.1.1",
148
+ "group": "native-toolchain"
149
+ },
150
+ "@nativescript/ios": {
151
+ "version": "9.1.0",
152
+ "group": "native-toolchain"
153
+ },
154
+ "@nativescript/android": {
155
+ "version": "9.1.1",
156
+ "group": "native-toolchain"
157
+ },
158
+ "@nativescript/types": {
159
+ "version": "9.1.4",
160
+ "group": "native-toolchain"
161
+ },
162
+ "@nativescript/types-ios": {
163
+ "version": "9.1.3",
164
+ "group": "native-toolchain"
165
+ },
166
+ "@nativescript/types-android": {
167
+ "version": "9.1.1",
168
+ "group": "native-toolchain"
169
+ },
170
+ "@nativescript/macos-node-api": {
171
+ "version": "0.5.0-beta.0",
172
+ "group": "native-toolchain"
173
+ },
174
+ "@nativescript/windows": {
175
+ "version": "1.0.0-beta.24",
176
+ "group": "native-toolchain"
177
+ },
178
+ "vitest": {
179
+ "version": "4.1.11",
180
+ "group": "testing"
181
+ },
182
+ "@nativescript/unit-test-runner": {
183
+ "version": "5.0.0",
184
+ "group": "testing"
185
+ },
186
+ "@nativescript-community/gesturehandler": {
187
+ "version": "2.1.0",
188
+ "group": "plugin"
189
+ },
190
+ "@nativescript-community/ui-drawer": {
191
+ "version": "0.1.32",
192
+ "group": "plugin"
193
+ },
194
+ "@nativescript-community/ui-image": {
195
+ "version": "5.0.18",
196
+ "group": "plugin"
197
+ },
198
+ "@valor/nativescript-websockets": {
199
+ "version": "2.0.3",
200
+ "group": "plugin"
201
+ },
202
+ "@octane-xplat/nativescript-mason-core": {
203
+ "version": "1.0.0-beta.13",
204
+ "group": "runtime"
205
+ },
206
+ "@octane-xplat/nativescript-masonkit": {
207
+ "version": "1.0.0-beta.126",
208
+ "group": "runtime"
209
+ },
210
+ "jsdom": {
211
+ "version": "30.1.1",
212
+ "group": "testing"
213
+ },
214
+ "@nativescript/font-manager": {
215
+ "version": "1.0.20",
216
+ "group": "plugin"
217
+ },
218
+ "typescript-classic": {
219
+ "version": "5.9.3",
220
+ "specifier": "npm:typescript@5.9.3",
221
+ "group": "compiler"
222
+ }
223
+ },
224
+ "profiles": {
225
+ "windows": {
226
+ "@nativescript/core": {
227
+ "version": "9.1.4-next.0",
228
+ "specifier": "https://pkg.pr.new/@nativescript/core@abae298"
229
+ },
230
+ "@nativescript/vite": {
231
+ "version": "8.0.21",
232
+ "specifier": "https://pkg.pr.new/@nativescript/vite@abae298"
233
+ },
234
+ "nativescript": {
235
+ "version": "9.1.2-dev.2026-09-24-36031892256"
236
+ },
237
+ "@nativescript/font-manager": {
238
+ "version": "1.0.18"
239
+ }
240
+ }
241
+ },
242
+ "overrides": {
243
+ "@nativescript/vite>esbuild": "0.27.7",
244
+ "vite>esbuild": "0.27.7",
245
+ "regenerate": "1.5.0",
246
+ "oxlint-tsgolint": "7.0.2005",
247
+ "@lexical/a11y": "0.53.0",
248
+ "@lexical/code": "0.53.0",
249
+ "@lexical/devtools-core": "0.53.0",
250
+ "@lexical/dragon": "0.53.0",
251
+ "@lexical/extension": "0.53.0",
252
+ "@lexical/hashtag": "0.53.0",
253
+ "@lexical/history": "0.53.0",
254
+ "@lexical/html": "0.53.0",
255
+ "@lexical/internal": "0.53.0",
256
+ "@lexical/link": "0.53.0",
257
+ "@lexical/list": "0.53.0",
258
+ "@lexical/mark": "0.53.0",
259
+ "@lexical/markdown": "0.53.0",
260
+ "@lexical/overflow": "0.53.0",
261
+ "@lexical/plain-text": "0.53.0",
262
+ "@lexical/rich-text": "0.53.0",
263
+ "@lexical/selection": "0.53.0",
264
+ "@lexical/table": "0.53.0",
265
+ "@lexical/text": "0.53.0",
266
+ "@lexical/utils": "0.53.0",
267
+ "@lexical/yjs": "0.53.0",
268
+ "lexical": "0.53.0",
269
+ "@tiptap/core": "3.32.2",
270
+ "@tiptap/pm": "3.32.2",
271
+ "@tiptap/starter-kit": "3.32.2",
272
+ "@tiptap/static-renderer": "3.32.2",
273
+ "@tiptap/extensions": "3.32.2",
274
+ "@tiptap/extension-blockquote": "3.32.2",
275
+ "@tiptap/extension-bold": "3.32.2",
276
+ "@tiptap/extension-bubble-menu": "3.32.2",
277
+ "@tiptap/extension-bullet-list": "3.32.2",
278
+ "@tiptap/extension-code": "3.32.2",
279
+ "@tiptap/extension-code-block": "3.32.2",
280
+ "@tiptap/extension-document": "3.32.2",
281
+ "@tiptap/extension-dropcursor": "3.32.2",
282
+ "@tiptap/extension-floating-menu": "3.32.2",
283
+ "@tiptap/extension-gapcursor": "3.32.2",
284
+ "@tiptap/extension-hard-break": "3.32.2",
285
+ "@tiptap/extension-heading": "3.32.2",
286
+ "@tiptap/extension-horizontal-rule": "3.32.2",
287
+ "@tiptap/extension-italic": "3.32.2",
288
+ "@tiptap/extension-link": "3.32.2",
289
+ "@tiptap/extension-list": "3.32.2",
290
+ "@tiptap/extension-list-item": "3.32.2",
291
+ "@tiptap/extension-list-keymap": "3.32.2",
292
+ "@tiptap/extension-ordered-list": "3.32.2",
293
+ "@tiptap/extension-paragraph": "3.32.2",
294
+ "@tiptap/extension-strike": "3.32.2",
295
+ "@tiptap/extension-text": "3.32.2",
296
+ "@tiptap/extension-underline": "3.32.2"
297
+ }
298
+ }
@@ -0,0 +1,240 @@
1
+ import { packageManagerFor, packageManagerRoot, readProjectWorkspace } from "./package-manager.js";
2
+ import { compatibility, dependencySections, managedCatalog, managedPackage, managedSpecifier, projectProfile } from "./compatibility-data/compatibility.js";
3
+ import { canonicalPatchesDir, loadPatchManifest, specifierPackage } from "./patches.js";
4
+ import { masonCorePackage, masonFullPackage, masonLegacyPackage } from "./mason-engine.js";
5
+ import { existsSync, globSync, mkdirSync, readFileSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
6
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
7
+ import { isMap, parseDocument } from "yaml";
8
+ // ../cli/src/compatibility.ts
9
+ var readPackage = (path) => JSON.parse(readFileSync(path, "utf8"));
10
+ var localSpecifier = (spec) => /^(workspace:|link:|file:|portal:)/.test(spec);
11
+ var patchPrefix = "node_modules/.pnpm-config/@octane-xplat/patches/patches/";
12
+ var workspaceRoot = packageManagerRoot;
13
+ function readWorkspace(root) {
14
+ if (packageManagerFor(root) === "bun") return parseDocument(JSON.stringify(readProjectWorkspace(root, "bun")));
15
+ const path = join(root, "pnpm-workspace.yaml");
16
+ const doc = parseDocument(existsSync(path) ? readFileSync(path, "utf8") : "{}\n");
17
+ if (doc.errors.length) throw new Error(`${path}: ${doc.errors[0].message}`);
18
+ return doc;
19
+ }
20
+ function resolveCatalog(spec, name, config) {
21
+ if (!spec.startsWith("catalog:")) return spec;
22
+ const catalog = spec.slice(8);
23
+ return (catalog && catalog !== "default" ? config.catalogs?.[catalog]?.[name] : config.catalog?.[name]) ?? spec;
24
+ }
25
+ /** Match workspace package globs, including nested directories and exclusions. */
26
+ function workspacePackages(root, patterns = []) {
27
+ const included = patterns.filter((pattern) => !pattern.startsWith("!"));
28
+ const excluded = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => pattern.slice(1));
29
+ const paths = /* @__PURE__ */ new Set([root]);
30
+ for (const match of included.length ? globSync(included, {
31
+ cwd: root,
32
+ exclude: ["**/node_modules/**", ...excluded]
33
+ }) : []) {
34
+ const path = resolve(root, match);
35
+ const rel = relative(realpathSync(root), realpathSync(path));
36
+ if (isAbsolute(rel) || rel === ".." || rel.startsWith(`..${sep}`)) throw new Error(`Workspace package ${match} points outside ${root}; align it in its own workspace`);
37
+ paths.add(path);
38
+ }
39
+ return [...paths].sort().filter((path) => existsSync(join(path, "package.json")));
40
+ }
41
+ var formatPackage = (pkg, raw) => JSON.stringify(pkg, null, raw.match(/^([\t ]+)"/m)?.[1] ?? " ") + "\n";
42
+ /** Pure preflight: no writes, installs, or package code execution. */
43
+ function planUpgrade(dir) {
44
+ const root = workspaceRoot(dir);
45
+ const manager = packageManagerFor(root);
46
+ const ws = readWorkspace(root);
47
+ const config = ws.toJS() ?? {};
48
+ const paths = workspacePackages(root, config.packages);
49
+ if (!paths.length || !existsSync(join(resolve(dir), "package.json"))) throw new Error("Run xplat upgrade inside a package with a package.json");
50
+ const plan = {
51
+ root,
52
+ version: compatibility.frameworkVersion,
53
+ packages: paths,
54
+ files: [],
55
+ updates: [],
56
+ skipped: [],
57
+ projects: []
58
+ };
59
+ const expected = /* @__PURE__ */ new Map();
60
+ const expectedSpecs = /* @__PURE__ */ new Map();
61
+ const applicable = /* @__PURE__ */ new Set();
62
+ const packages = paths.map((path) => {
63
+ const file = join(path, "package.json");
64
+ const raw = readFileSync(file, "utf8");
65
+ return {
66
+ path,
67
+ file,
68
+ raw,
69
+ pkg: JSON.parse(raw)
70
+ };
71
+ });
72
+ const change = (path, after) => {
73
+ const before = existsSync(path) ? readFileSync(path, "utf8") : null;
74
+ if (after !== before) plan.files.push({
75
+ path,
76
+ before,
77
+ after
78
+ });
79
+ };
80
+ for (const { path, pkg } of packages) {
81
+ const profile = projectProfile(pkg);
82
+ const label = relative(root, path) || ".";
83
+ const deps = Object.assign({}, ...dependencySections.map((section) => pkg[section]));
84
+ if (deps.octane && !deps["@tsrx/oxc"] && !localSpecifier(deps.octane)) {
85
+ pkg.devDependencies ??= {};
86
+ pkg.devDependencies["@tsrx/oxc"] = managedSpecifier("@tsrx/oxc", profile);
87
+ plan.updates.push(`${label}: add @tsrx/oxc compiler peer`);
88
+ }
89
+ const engine = profile === "windows" ? masonFullPackage : masonCorePackage;
90
+ const replacedEngines = [
91
+ masonCorePackage,
92
+ masonFullPackage,
93
+ masonLegacyPackage
94
+ ].filter((name) => name !== engine);
95
+ if (deps["@octane-xplat/nativescript-octane"] && !deps[engine] && !replacedEngines.some((name) => deps[name]) && !localSpecifier(deps["@octane-xplat/nativescript-octane"])) {
96
+ pkg.dependencies ??= {};
97
+ pkg.dependencies[engine] = managedSpecifier(engine, profile);
98
+ plan.updates.push(`${label}: add ${engine} mason engine`);
99
+ }
100
+ for (const name of replacedEngines) {
101
+ if (!deps[name]) continue;
102
+ for (const section of dependencySections) delete pkg[section]?.[name];
103
+ pkg.dependencies ??= {};
104
+ pkg.dependencies[engine] ??= managedSpecifier(engine, profile);
105
+ plan.updates.push(`${label}: replace ${name} with ${engine}`);
106
+ }
107
+ for (const section of dependencySections) for (const [name, declared] of Object.entries(pkg[section] ?? {})) {
108
+ const managed = managedPackage(name, profile);
109
+ if (!managed) continue;
110
+ const spec = resolveCatalog(declared, name, config);
111
+ if (localSpecifier(spec)) {
112
+ plan.skipped.push(`${label}: keep ${name} ${declared}`);
113
+ continue;
114
+ }
115
+ const desired = managedSpecifier(name, profile);
116
+ if ((/^[\w+.-]+:/.test(spec) || spec.includes("/")) && spec !== desired) throw new Error(`${label}: ${name} uses a custom source; replace it with a registry pin or a local dependency before upgrading`);
117
+ const catalog = managedCatalog(profile);
118
+ pkg[section][name] = `catalog:${catalog}`;
119
+ ws.setIn([
120
+ "catalogs",
121
+ catalog,
122
+ name
123
+ ], desired);
124
+ if (declared !== `catalog:${catalog}` || spec !== desired) plan.updates.push(`${label}: ${name} ${spec} → ${desired}`);
125
+ applicable.add(name);
126
+ if (!plan.projects.includes(path)) plan.projects.push(path);
127
+ const versions = expected.get(name) ?? /* @__PURE__ */ new Set();
128
+ versions.add(managed.version);
129
+ expected.set(name, versions);
130
+ const specs = expectedSpecs.get(name) ?? /* @__PURE__ */ new Set();
131
+ specs.add(desired);
132
+ expectedSpecs.set(name, specs);
133
+ }
134
+ if (path === root || dependencySections.some((section) => Object.keys(pkg[section] ?? {}).some((name) => applicable.has(name)))) {
135
+ pkg.packageManager = `${manager}@${compatibility.tools[manager]}`;
136
+ pkg.engines ??= {};
137
+ pkg.engines.node ??= `>=${compatibility.tools.nodeMinimum}`;
138
+ if (manager === "bun") pkg.engines.bun ??= `>=${compatibility.tools.bun}`;
139
+ }
140
+ }
141
+ const rootPackage = packages.find((pkg) => pkg.path === root);
142
+ const usesCli = packages.some(({ pkg }) => dependencySections.some((section) => ["@octane-xplat/cli", "octane-xplat"].some((name) => pkg[section]?.[name])));
143
+ if (manager === "bun" && rootPackage && usesCli) {
144
+ for (const name of ["octane-xplat", "@octane-xplat/cli"]) if (!(rootPackage.pkg.trustedDependencies ?? []).includes(name)) {
145
+ rootPackage.pkg.trustedDependencies = [...rootPackage.pkg.trustedDependencies ?? [], name];
146
+ plan.updates.push(`.: trust the ${name} install script`);
147
+ }
148
+ }
149
+ if (manager === "pnpm" && usesCli) {
150
+ for (const name of ["octane-xplat", "@octane-xplat/cli"]) if (ws.getIn(["allowBuilds", name]) !== true) {
151
+ ws.setIn(["allowBuilds", name], true);
152
+ plan.updates.push(`.: allow the ${name} install script`);
153
+ }
154
+ }
155
+ for (const overrides of [config.overrides ?? {}, rootPackage?.pkg.pnpm?.overrides ?? {}]) for (const [selector, value] of Object.entries(overrides)) {
156
+ const name = specifierPackage(selector.split(">").at(-1));
157
+ if (!applicable.has(name)) continue;
158
+ const versions = expected.get(name);
159
+ if (versions.size !== 1) throw new Error(`Override ${selector} spans incompatible profiles; scope it to the appropriate workspace package`);
160
+ const desired = [...versions][0];
161
+ const source = resolveCatalog(String(value), name, config);
162
+ if (!expectedSpecs.get(name).has(source)) throw new Error(`Override ${selector} conflicts with ${desired}; remove this override before upgrading`);
163
+ }
164
+ for (const [selector, version] of Object.entries(compatibility.overrides)) {
165
+ const existing = config.overrides?.[selector];
166
+ if (existing && existing !== version) throw new Error(`Override ${selector} conflicts with framework pin ${version}`);
167
+ ws.setIn(["overrides", selector], version);
168
+ }
169
+ const oldPatches = {
170
+ ...rootPackage?.pkg.pnpm?.patchedDependencies,
171
+ ...rootPackage?.pkg.patchedDependencies,
172
+ ...config.patchedDependencies
173
+ };
174
+ const wanted = loadPatchManifest().filter((patch) => {
175
+ const name = specifierPackage(patch.specifier);
176
+ const version = patch.specifier.slice(name.length + 1);
177
+ const versions = expected.get(name);
178
+ if (versions) return versions.has(version);
179
+ return patch.template !== false && !managedPackage(name);
180
+ });
181
+ for (const patch of wanted) {
182
+ const existing = oldPatches[patch.specifier];
183
+ if (existing && !String(existing).startsWith(patchPrefix)) {
184
+ const file = resolve(root, existing);
185
+ const canonical = readFileSync(join(canonicalPatchesDir, patch.file));
186
+ if (!existsSync(file) || !canonical.equals(readFileSync(file))) throw new Error(`Custom patch for ${patch.specifier} at ${existing} differs from the framework patch; reconcile it before upgrading`);
187
+ }
188
+ }
189
+ for (const [specifier, path] of Object.entries(oldPatches)) if (String(path).startsWith(patchPrefix)) delete oldPatches[specifier];
190
+ for (const patch of wanted) {
191
+ oldPatches[patch.specifier] ??= `patches/${patch.file}`;
192
+ change(join(root, oldPatches[patch.specifier]), readFileSync(join(canonicalPatchesDir, patch.file), "utf8"));
193
+ }
194
+ if (Object.keys(oldPatches).length) {
195
+ ws.set("patchedDependencies", oldPatches);
196
+ ws.set("allowUnusedPatches", true);
197
+ }
198
+ if (manager === "pnpm" && ws.getIn(["configDependencies", "@octane-xplat/patches"]) !== void 0) {
199
+ ws.deleteIn(["configDependencies", "@octane-xplat/patches"]);
200
+ const remaining = ws.get("configDependencies");
201
+ if (isMap(remaining) && remaining.items.length === 0) ws.delete("configDependencies");
202
+ plan.updates.push(".: retire the @octane-xplat/patches config dependency");
203
+ }
204
+ if (rootPackage?.pkg.pnpm?.patchedDependencies) delete rootPackage.pkg.pnpm.patchedDependencies;
205
+ if (manager === "bun" && rootPackage) {
206
+ const result = ws.toJS();
207
+ const owner = rootPackage.pkg;
208
+ if (Array.isArray(owner.workspaces)) owner.workspaces = { packages: owner.workspaces };
209
+ owner.workspaces ??= { packages: [] };
210
+ for (const key of ["catalog", "catalogs"]) if (result[key]) {
211
+ if (Object.hasOwn(owner, key)) owner[key] = result[key];
212
+ else owner.workspaces[key] = result[key];
213
+ }
214
+ for (const key of ["overrides", "patchedDependencies"]) if (result[key]) owner[key] = result[key];
215
+ }
216
+ for (const { file, raw, pkg } of packages) {
217
+ const after = formatPackage(pkg, raw);
218
+ if (JSON.stringify(JSON.parse(raw)) !== JSON.stringify(pkg)) change(file, after);
219
+ }
220
+ if (manager === "pnpm") change(join(root, "pnpm-workspace.yaml"), String(ws));
221
+ return plan;
222
+ }
223
+ /** Refuse stale previews and roll back authored files if a write fails. */
224
+ function applyUpgrade(plan) {
225
+ for (const file of plan.files) if ((existsSync(file.path) ? readFileSync(file.path, "utf8") : null) !== file.before) throw new Error(`${file.path} changed during upgrade; rerun xplat upgrade`);
226
+ const written = [];
227
+ try {
228
+ for (const file of plan.files) {
229
+ written.push(file);
230
+ mkdirSync(dirname(file.path), { recursive: true });
231
+ writeFileSync(file.path, file.after);
232
+ }
233
+ } catch (error) {
234
+ for (const file of written.reverse()) if (file.before === null) {
235
+ if (existsSync(file.path)) unlinkSync(file.path);
236
+ } else writeFileSync(file.path, file.before);
237
+ throw error;
238
+ }
239
+ }
240
+ export { applyUpgrade, compatibility, localSpecifier, managedPackage, managedSpecifier, planUpgrade, readPackage, readWorkspace, resolveCatalog, workspaceRoot };