create-octane-xplat 0.18.0 → 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 (77) hide show
  1. package/README.md +2 -144
  2. package/compatibility.json +97 -19
  3. package/compatibility.ts +141 -72
  4. package/dist/compatibility.js +66 -26
  5. package/dist/index.js +127 -64
  6. package/dist/package-manager.js +62 -0
  7. package/dist/scaffold.js +377 -127
  8. package/index.ts +256 -154
  9. package/library-template/AGENTS.md +6 -4
  10. package/library-template/README.md +22 -18
  11. package/library-template/bunfig +4 -0
  12. package/library-template/package.json +115 -18
  13. package/library-template/patches/@nativescript-community__octane@0.2.5.patch +1018 -0
  14. package/library-template/patches/@nativescript-community__sqlite-bridge@4.1.1.patch +30 -0
  15. package/library-template/patches/@nativescript-community__vite-octane@0.2.1.patch +72 -0
  16. package/library-template/patches/@nativescript__core@9.1.3.patch +1280 -0
  17. package/library-template/patches/@nativescript__doctor@2.0.18.patch +13 -0
  18. package/library-template/patches/@nativescript__vite@8.0.20.patch +2019 -0
  19. package/library-template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
  20. package/library-template/patches/@octanejs__tiptap@0.0.62.patch +12 -0
  21. package/library-template/patches/@sveltejs__acorn-typescript@1.0.13.patch +16 -0
  22. package/library-template/patches/css@3.0.0.patch +52 -0
  23. package/library-template/patches/octane@0.16.3.patch +1479 -0
  24. package/library-template/src/Badge.tsx +7 -6
  25. package/library-template/src/Badge.web.tsx +7 -6
  26. package/library-template/src/Welcome.stories.tsx +12 -0
  27. package/library-template/src/normalizeBadgeLabel.ts +1 -1
  28. package/library-template/src/props.ts +11 -11
  29. package/library-template/tests/normalizeBadgeLabel.test.ts +1 -1
  30. package/library-template/tests/packed-consumer.mjs +140 -123
  31. package/library-template/tsconfig.envs.json +1 -0
  32. package/library-template/tsconfig.json +1 -0
  33. package/library-template/tsconfig.types.json +15 -1
  34. package/library-template/tsrx-typegen.json +1 -1
  35. package/library-template/workshop.config.ts +3 -0
  36. package/package-manager.ts +93 -0
  37. package/package.json +70 -58
  38. package/scaffold.ts +1056 -526
  39. package/template/.agents/skills/xplat/SKILL.md +6 -6
  40. package/template/.agents/skills/xplat/references/components.md +1 -1
  41. package/template/.agents/skills/xplat/references/navigation.md +1 -1
  42. package/template/.agents/skills/xplat/references/styling.md +14 -14
  43. package/template/AGENTS.md +10 -10
  44. package/template/bunfig +4 -0
  45. package/template/gitignore +1 -0
  46. package/template/nativescript.config.ts +13 -16
  47. package/template/package.json +119 -10
  48. package/template/patches/@nativescript-community__octane@0.2.5.patch +1018 -0
  49. package/template/patches/@nativescript-community__sqlite-bridge@4.1.1.patch +30 -0
  50. package/template/patches/@nativescript-community__vite-octane@0.2.1.patch +72 -0
  51. package/template/patches/@nativescript__core@9.1.3.patch +1280 -0
  52. package/template/patches/@nativescript__doctor@2.0.18.patch +13 -0
  53. package/template/patches/@nativescript__vite@8.0.20.patch +2019 -0
  54. package/template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
  55. package/template/patches/@octanejs__tiptap@0.0.62.patch +12 -0
  56. package/template/patches/@sveltejs__acorn-typescript@1.0.13.patch +16 -0
  57. package/template/patches/css@3.0.0.patch +52 -0
  58. package/template/patches/octane@0.16.3.patch +1479 -0
  59. package/template/src/App.tsrx +77 -42
  60. package/template/src/Welcome.stories.tsx +22 -0
  61. package/template/src/app.spec.tsrx +169 -163
  62. package/template/src/app.web.test.tsx +18 -13
  63. package/template/src/failure-reporting.spec.ts +3 -3
  64. package/template/src/main.ts +14 -13
  65. package/template/src/main.tsrx +2 -0
  66. package/template/src/main.web.tsrx +5 -5
  67. package/template/src/native-runtime.spec.ts +13 -11
  68. package/template/src/test-setup.web.ts +9 -8
  69. package/template/src/test.ts +6 -6
  70. package/template/tsconfig.json +17 -1
  71. package/template/vite.config.native.mts +1 -2
  72. package/template/vite.config.ts +29 -23
  73. package/template/vitest.config.mts +18 -18
  74. package/template/vitest.web.config.mts +7 -7
  75. package/template/workshop.config.ts +3 -0
  76. package/library-template/pnpm-workspace.yaml +0 -171
  77. package/template/pnpm-workspace.yaml +0 -192
package/README.md CHANGED
@@ -1,147 +1,5 @@
1
1
  # create-octane-xplat
2
2
 
3
- > Get a TypeScript app running, then build its first useful flow with your
4
- > coding agent.
3
+ [Documentation](https://octane-xplat.goddardai.org/package-create).
5
4
 
6
- Xplat's target direction spans web, iOS, Android, macOS, Windows, and Linux.
7
- This starter configures **web, iOS, and Android**. macOS, Windows, and Linux
8
- are separate experiments — an AppKit host, a WinUI 3 scaffold with runtime
9
- verification pending, and a WebKitGTK webview host. See
10
- [target support](https://octane-xplat.goddardai.org/spec#choose-your-targets).
11
- The framework is `0.x` and its API surface is still changing.
12
-
13
- With Node.js and pnpm 11.24.0 installed:
14
-
15
- ```sh
16
- pnpm create octane-xplat my-app
17
- ```
18
-
19
- The starter's `tsconfig.json` selects the shared native JSX types from its
20
- direct `@octane-xplat/jsx` dependency. Browser JSX leaves select DOM types on
21
- their first line, as `src/main.web.tsrx` does:
22
-
23
- ```tsx
24
- /** @jsxImportSource @octane-xplat/jsx/dom */
25
- export function BrowserMessage() {
26
- return <p>Ready</p>
27
- }
28
- ```
29
-
30
- See [platform files and JSX types](https://octane-xplat.goddardai.org/platform/module-resolution#typescript)
31
- when adding a native or browser implementation.
32
-
33
- ## Start a library package
34
-
35
- To start a reusable package instead of an app, select the library template:
36
-
37
- ```sh
38
- pnpm create octane-xplat my-controls --template library
39
- cd my-controls
40
- pnpm typecheck
41
- pnpm typegen
42
- pnpm test:packed
43
- ```
44
-
45
- The library starter publishes source for web, iOS, and Android, which the
46
- consuming app compiles. It includes conditional exports, generated `.d.ts`
47
- declarations, lint and unit-test
48
- scripts, and a packed-consumer check. Pass `--name @acme/my-controls` to set a
49
- scoped npm package name; otherwise the folder name becomes the package name.
50
- Library creation installs dependencies but does not start an app dev server.
51
- Desktop targets are not included in this starter.
52
-
53
- The creator asks which platforms to target — web, iOS, and Android are all
54
- pre-selected. Pass `--targets` to skip the prompt:
55
-
56
- ```sh
57
- pnpm create octane-xplat my-app --targets web # web only
58
- pnpm create octane-xplat my-app --targets web,android # web + Android
59
- ```
60
-
61
- Platforms skipped here can be enabled later with `pnpm xplat add <platform>`
62
- inside the app. (Non-interactive runs without `--targets` scaffold all
63
- three.)
64
-
65
- The creator copies the template, installs dependencies with pnpm, and starts
66
- the web dev server when the web target is included. Open the printed URL and
67
- open `my-app` in your agent.
68
- Ask it to read `AGENTS.md` and `.agents/skills/xplat/SKILL.md`, then build a
69
- packing checklist with add, pack, and remove actions using in-memory state.
70
- Check the result before asking for the next feature: add “Passport” and
71
- “Charger,” pack Passport, and confirm that one item remains. Reloading should
72
- clear the list in this in-memory version. The
73
- [first-flow guide](https://octane-xplat.goddardai.org/toolchain#build-and-check-your-first-flow)
74
- includes the full prompt and failure checks.
75
-
76
- The generated app pins pnpm 11.24.0. Its `pnpm-workspace.yaml` loads
77
- `@octane-xplat/patches` as a `configDependencies` package, making the
78
- framework patches available during the first install.
79
-
80
- Apps start with the runtime, build packages, and tests their selected platforms
81
- need. Feature packages are added when you use them.
82
-
83
- ## Run app tests
84
-
85
- New apps include Vitest, configuration, sample tests, and scripts. From your
86
- app's folder, run the command for a platform you enabled:
87
-
88
- ```sh
89
- pnpm test:web # when web is enabled
90
- pnpm test:ios -- --device DEVICE_UDID # when iOS is enabled
91
- pnpm test:android -- --device DEVICE_SERIAL # when Android is enabled
92
- ```
93
-
94
- Web tests use jsdom, which simulates a browser's
95
- document on your computer; phone tests use NativeScript's test runner on a
96
- selected simulator or device. The runners are explicit development dependencies
97
- with framework-managed versions in `catalog:xplat`. Adapt the sample tests to
98
- your app as you replace the starter screen.
99
-
100
- Platforms added later also receive their test setup. The library template
101
- includes its component tests and publishing checks.
102
- See [checking an app](../../docs/testing/testing.md#add-automated-tests) for the
103
- commands, file conventions, and checks that still need a browser or phone.
104
-
105
- ## Keep compatible versions
106
-
107
- App and library starters share the framework's compatible compiler, runtime,
108
- and tool versions through `catalog:xplat`. To update an existing project,
109
- preview and apply a published CLI release's set, then check the installed
110
- packages:
111
-
112
- ```sh
113
- pnpm dlx @octane-xplat/cli@latest upgrade --check
114
- pnpm dlx @octane-xplat/cli@latest upgrade
115
- pnpm xplat doctor
116
- ```
117
-
118
- An upgrade covers the workspace's managed dependencies and patches. Your
119
- app-specific packages and library consumer peer ranges remain yours. See
120
- [compatible versions](../cli/README.md#compatible-versions) for local links,
121
- custom patches, deferred installs, and failure recovery.
122
-
123
- Leave the server running while you edit. After stopping it, restart from the
124
- app directory:
125
-
126
- ```sh
127
- cd my-app
128
- pnpm dev # web
129
- ```
130
-
131
- From that directory, these commands run other targets or check the app — the
132
- `dev:*`/`build:*` entries exist only for platforms chosen at create time
133
- (`pnpm xplat add` adds the rest later):
134
-
135
- ```sh
136
- pnpm dev:ios # needs macOS, Xcode, and NativeScript setup
137
- pnpm dev:android # needs Android SDK, compatible JDK, and NativeScript setup
138
- pnpm lint
139
- pnpm typecheck # tsconfig.json + every declared environment
140
- pnpm build # web production bundle
141
- ```
142
-
143
- [Get a working app and iterate](https://octane-xplat.goddardai.org/toolchain)
144
- provides prerequisites, live-update boundaries, and version guidance. The
145
- starter's Xplat skill is included; NativeScript's official skills are optional
146
- and installed separately. Ask your agent to report checks and targets actually
147
- run. [llms.txt](https://octane-xplat.goddardai.org/llms.txt) indexes the docs.
5
+ [API reference](https://octane-xplat.goddardai.org/api-create).
@@ -1,13 +1,15 @@
1
1
  {
2
- "$comment": "Release compatibility set, shared by create-octane-xplat and xplat doctor/upgrade. Edit external pins here, then run pnpm 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.",
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
3
  "schemaVersion": 1,
4
- "frameworkVersion": "0.18.0",
4
+ "frameworkVersion": "0.20.0",
5
5
  "tools": {
6
- "nodeMinimum": "22.18.0",
6
+ "nodeMinimum": "22.22.2",
7
+ "bun": "1.4.4",
7
8
  "pnpm": "11.24.0"
8
9
  },
9
10
  "frameworkPackages": [
10
11
  "@octane-xplat/ads",
12
+ "@octane-xplat/app-menu",
11
13
  "@octane-xplat/audio",
12
14
  "@octane-xplat/auth",
13
15
  "@octane-xplat/background-tasks",
@@ -15,6 +17,7 @@
15
17
  "@octane-xplat/barcode-scanner",
16
18
  "@octane-xplat/billing",
17
19
  "@octane-xplat/biometrics",
20
+ "@octane-xplat/build",
18
21
  "@octane-xplat/calendar",
19
22
  "@octane-xplat/camera",
20
23
  "@octane-xplat/canvas",
@@ -22,21 +25,28 @@
22
25
  "@octane-xplat/cli",
23
26
  "@octane-xplat/contacts",
24
27
  "@octane-xplat/context-menu",
28
+ "@octane-xplat/crypto",
25
29
  "@octane-xplat/css-engine",
26
30
  "@octane-xplat/date-picker",
27
31
  "@octane-xplat/desktop-webview",
28
32
  "@octane-xplat/dnd-kit",
33
+ "@octane-xplat/docs-search",
34
+ "@octane-xplat/drawer",
29
35
  "@octane-xplat/effects",
30
36
  "@octane-xplat/files",
37
+ "@octane-xplat/fingerprint",
31
38
  "@octane-xplat/firebase-analytics",
32
39
  "@octane-xplat/firebase-crashlytics",
40
+ "@octane-xplat/form",
33
41
  "@octane-xplat/geofencing",
34
42
  "@octane-xplat/geolocation",
35
43
  "@octane-xplat/gif",
44
+ "@octane-xplat/global-shortcuts",
36
45
  "@octane-xplat/haptics",
37
46
  "@octane-xplat/icons",
38
47
  "@octane-xplat/image",
39
48
  "@octane-xplat/image-crop",
49
+ "@octane-xplat/image-manipulator",
40
50
  "@octane-xplat/intersection-observer",
41
51
  "@octane-xplat/jsx",
42
52
  "@octane-xplat/keyboard",
@@ -44,45 +54,60 @@
44
54
  "@octane-xplat/lib",
45
55
  "@octane-xplat/lingui",
46
56
  "@octane-xplat/lint",
57
+ "@octane-xplat/linux-gtk",
47
58
  "@octane-xplat/lottie",
48
- "@octane-xplat/macos-renderer",
59
+ "@octane-xplat/macos-appkit",
60
+ "@octane-xplat/macos-build",
49
61
  "@octane-xplat/maps",
50
62
  "@octane-xplat/mcp",
51
63
  "@octane-xplat/media",
64
+ "@octane-xplat/media-converter",
65
+ "@octane-xplat/media-library",
52
66
  "@octane-xplat/motion",
53
67
  "@octane-xplat/nano-icons",
68
+ "@octane-xplat/network",
54
69
  "@octane-xplat/notifications",
55
70
  "@octane-xplat/pager",
56
71
  "@octane-xplat/patches",
57
72
  "@octane-xplat/picker",
58
73
  "@octane-xplat/platform",
59
74
  "@octane-xplat/posthog",
75
+ "@octane-xplat/print",
60
76
  "@octane-xplat/push",
61
77
  "@octane-xplat/recorder",
62
78
  "@octane-xplat/richtext",
63
79
  "@octane-xplat/rolling-text",
80
+ "@octane-xplat/screen-orientation",
64
81
  "@octane-xplat/secure-storage",
65
82
  "@octane-xplat/sentry",
66
83
  "@octane-xplat/shaders",
67
84
  "@octane-xplat/share",
68
85
  "@octane-xplat/sheet",
86
+ "@octane-xplat/shortcuts",
69
87
  "@octane-xplat/smooth-corners",
70
88
  "@octane-xplat/sounds",
89
+ "@octane-xplat/speech-recognition",
90
+ "@octane-xplat/splash-screen",
71
91
  "@octane-xplat/sqlite",
72
92
  "@octane-xplat/store-review",
93
+ "@octane-xplat/stripe",
73
94
  "@octane-xplat/table",
74
95
  "@octane-xplat/tiptap",
96
+ "@octane-xplat/tracking-transparency",
97
+ "@octane-xplat/tray",
75
98
  "@octane-xplat/ui",
76
99
  "@octane-xplat/updates",
77
100
  "@octane-xplat/video",
101
+ "@octane-xplat/view-shot",
78
102
  "@octane-xplat/web-browser",
79
103
  "@octane-xplat/web-host",
80
104
  "@octane-xplat/workshop",
81
- "create-octane-xplat"
105
+ "create-octane-xplat",
106
+ "octane-xplat"
82
107
  ],
83
108
  "packages": {
84
109
  "octane": {
85
- "version": "0.14.0",
110
+ "version": "0.16.3",
86
111
  "group": "runtime",
87
112
  "singleton": true
88
113
  },
@@ -97,27 +122,23 @@
97
122
  "singleton": true
98
123
  },
99
124
  "typescript": {
100
- "version": "5.9.3",
125
+ "version": "7.1.0-beta",
101
126
  "group": "compiler"
102
127
  },
103
128
  "@tsrx/oxc": {
104
129
  "version": "0.20.0",
105
130
  "group": "compiler"
106
131
  },
107
- "@tsrx/typescript-plugin": {
108
- "version": "0.4.11",
109
- "group": "compiler"
110
- },
111
132
  "tsrx-typegen": {
112
- "version": "0.2.2",
133
+ "version": "0.6.0",
113
134
  "group": "compiler"
114
135
  },
115
136
  "vite": {
116
- "version": "8.3.0",
137
+ "version": "8.3.6",
117
138
  "group": "bundler"
118
139
  },
119
140
  "@octanejs/vite-plugin": {
120
- "version": "0.1.61",
141
+ "version": "0.5.0",
121
142
  "group": "bundler"
122
143
  },
123
144
  "@nativescript-community/vite-octane": {
@@ -153,11 +174,11 @@
153
174
  "group": "native-toolchain"
154
175
  },
155
176
  "@nativescript/macos-node-api": {
156
- "version": "0.4.4-next.2026-08-09-31292056208",
177
+ "version": "0.5.0-beta.0",
157
178
  "group": "native-toolchain"
158
179
  },
159
180
  "@nativescript/windows": {
160
- "version": "0.1.0-alpha.144",
181
+ "version": "0.1.0-alpha.146",
161
182
  "group": "native-toolchain"
162
183
  },
163
184
  "vitest": {
@@ -169,7 +190,7 @@
169
190
  "group": "testing"
170
191
  },
171
192
  "@nativescript-community/gesturehandler": {
172
- "version": "2.0.45",
193
+ "version": "2.1.0",
173
194
  "group": "plugin"
174
195
  },
175
196
  "@nativescript-community/ui-drawer": {
@@ -185,7 +206,7 @@
185
206
  "group": "plugin"
186
207
  },
187
208
  "@octane-xplat/nativescript-mason-core": {
188
- "version": "1.0.0-beta.5",
209
+ "version": "1.0.0-beta.7",
189
210
  "group": "runtime"
190
211
  },
191
212
  "@octane-xplat/nativescript-masonkit": {
@@ -199,6 +220,11 @@
199
220
  "@nativescript/font-manager": {
200
221
  "version": "1.0.20",
201
222
  "group": "plugin"
223
+ },
224
+ "typescript-classic": {
225
+ "version": "5.9.3",
226
+ "specifier": "npm:typescript@5.9.3",
227
+ "group": "compiler"
202
228
  }
203
229
  },
204
230
  "profiles": {
@@ -222,6 +248,58 @@
222
248
  "overrides": {
223
249
  "@nativescript/vite>esbuild": "0.27.7",
224
250
  "@nativescript-community/vite-octane>esbuild": "0.27.7",
225
- "vite>esbuild": "0.27.7"
251
+ "vite>esbuild": "0.27.7",
252
+ "regenerate": "1.5.0",
253
+ "oxlint-tsgolint": "7.0.2005",
254
+ "@lexical/a11y": "0.53.0",
255
+ "@lexical/code": "0.53.0",
256
+ "@lexical/devtools-core": "0.53.0",
257
+ "@lexical/dragon": "0.53.0",
258
+ "@lexical/extension": "0.53.0",
259
+ "@lexical/hashtag": "0.53.0",
260
+ "@lexical/history": "0.53.0",
261
+ "@lexical/html": "0.53.0",
262
+ "@lexical/internal": "0.53.0",
263
+ "@lexical/link": "0.53.0",
264
+ "@lexical/list": "0.53.0",
265
+ "@lexical/mark": "0.53.0",
266
+ "@lexical/markdown": "0.53.0",
267
+ "@lexical/overflow": "0.53.0",
268
+ "@lexical/plain-text": "0.53.0",
269
+ "@lexical/rich-text": "0.53.0",
270
+ "@lexical/selection": "0.53.0",
271
+ "@lexical/table": "0.53.0",
272
+ "@lexical/text": "0.53.0",
273
+ "@lexical/utils": "0.53.0",
274
+ "@lexical/yjs": "0.53.0",
275
+ "lexical": "0.53.0",
276
+ "@tiptap/core": "3.32.2",
277
+ "@tiptap/pm": "3.32.2",
278
+ "@tiptap/starter-kit": "3.32.2",
279
+ "@tiptap/static-renderer": "3.32.2",
280
+ "@tiptap/extensions": "3.32.2",
281
+ "@tiptap/extension-blockquote": "3.32.2",
282
+ "@tiptap/extension-bold": "3.32.2",
283
+ "@tiptap/extension-bubble-menu": "3.32.2",
284
+ "@tiptap/extension-bullet-list": "3.32.2",
285
+ "@tiptap/extension-code": "3.32.2",
286
+ "@tiptap/extension-code-block": "3.32.2",
287
+ "@tiptap/extension-document": "3.32.2",
288
+ "@tiptap/extension-dropcursor": "3.32.2",
289
+ "@tiptap/extension-floating-menu": "3.32.2",
290
+ "@tiptap/extension-gapcursor": "3.32.2",
291
+ "@tiptap/extension-hard-break": "3.32.2",
292
+ "@tiptap/extension-heading": "3.32.2",
293
+ "@tiptap/extension-horizontal-rule": "3.32.2",
294
+ "@tiptap/extension-italic": "3.32.2",
295
+ "@tiptap/extension-link": "3.32.2",
296
+ "@tiptap/extension-list": "3.32.2",
297
+ "@tiptap/extension-list-item": "3.32.2",
298
+ "@tiptap/extension-list-keymap": "3.32.2",
299
+ "@tiptap/extension-ordered-list": "3.32.2",
300
+ "@tiptap/extension-paragraph": "3.32.2",
301
+ "@tiptap/extension-strike": "3.32.2",
302
+ "@tiptap/extension-text": "3.32.2",
303
+ "@tiptap/extension-underline": "3.32.2"
226
304
  }
227
305
  }
package/compatibility.ts CHANGED
@@ -1,109 +1,178 @@
1
- import { existsSync, readFileSync, writeFileSync } from 'node:fs'
1
+ import { existsSync, globSync, readFileSync, writeFileSync } from 'node:fs'
2
2
  import { createRequire } from 'node:module'
3
3
  import { basename, dirname, join, resolve } from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
5
- import { parseDocument } from 'yaml'
5
+ import { parse } from 'yaml'
6
6
 
7
7
  /** One supported external version, optionally using a preview tarball specifier. */
8
8
  export type ManagedPackage = {
9
- version: string
10
- specifier?: string
11
- group: string
12
- singleton?: boolean
9
+ version: string
10
+ specifier?: string
11
+ group: string
12
+ singleton?: boolean
13
13
  }
14
14
 
15
15
  /** The release-owned pins used by creator, doctor, and upgrade. */
16
16
  export type Compatibility = {
17
- schemaVersion: number
18
- frameworkVersion: string
19
- tools: { nodeMinimum: string; pnpm: string }
20
- frameworkPackages: string[]
21
- packages: Record<string, ManagedPackage>
22
- profiles: Record<string, Record<string, Partial<ManagedPackage>>>
23
- overrides: Record<string, string>
17
+ schemaVersion: number
18
+ frameworkVersion: string
19
+ tools: { nodeMinimum: string; bun: string; pnpm: string }
20
+ frameworkPackages: string[]
21
+ packages: Record<string, ManagedPackage>
22
+ profiles: Record<string, Record<string, Partial<ManagedPackage>>>
23
+ overrides: Record<string, string>
24
24
  }
25
25
 
26
26
  const dir = dirname(fileURLToPath(import.meta.url))
27
27
  const root = basename(dir) === 'dist' ? dirname(dir) : dir
28
+
28
29
  // Keep JSON on disk: Vite's asset URL transform produces a data URL here.
29
30
  export const compatibility: Compatibility = createRequire(import.meta.url)(
30
- join(root, 'compatibility.json'),
31
+ join(root, 'compatibility.json'),
31
32
  )
32
33
 
33
34
  /** Look up a known framework package or a profile's external dependency pin. */
34
35
  export function managedPackage(name: string, profile = 'default'): ManagedPackage | undefined {
35
- if (compatibility.frameworkPackages.includes(name)) {
36
- return {
37
- version: compatibility.frameworkVersion,
38
- group: 'framework',
39
- singleton: name === '@octane-xplat/ui',
40
- }
41
- }
42
-
43
- const base = compatibility.packages[name]
44
- return base ? { ...base, ...compatibility.profiles[profile]?.[name] } : undefined
36
+ if (compatibility.frameworkPackages.includes(name)) {
37
+ return {
38
+ version: compatibility.frameworkVersion,
39
+ group: 'framework',
40
+ singleton: name === '@octane-xplat/ui',
41
+ }
42
+ }
43
+
44
+ const base = compatibility.packages[name]
45
+
46
+ return base ? { ...base, ...compatibility.profiles[profile]?.[name] } : undefined
45
47
  }
46
48
 
47
- /** Return the pnpm specifier, keeping preview URLs separate from package versions. */
49
+ /** Return the install specifier, keeping preview URLs separate from package versions. */
48
50
  export function managedSpecifier(name: string, profile = 'default') {
49
- const entry = managedPackage(name, profile)
50
- return entry?.specifier ?? entry?.version
51
+ const entry = managedPackage(name, profile)
52
+
53
+ return entry?.specifier ?? entry?.version
51
54
  }
52
55
 
53
- /** Named pnpm catalog reserved for this compatibility profile. */
56
+ /** Named catalog reserved for this compatibility profile. */
54
57
  export const managedCatalog = (profile = 'default') =>
55
- profile === 'default' ? 'xplat' : `xplat-${profile}`
58
+ profile === 'default' ? 'xplat' : `xplat-${profile}`
56
59
 
57
60
  /** Installed dependency fields; library consumer peers intentionally keep their ranges. */
58
61
  export const dependencySections = [
59
- 'dependencies',
60
- 'devDependencies',
61
- 'optionalDependencies',
62
+ 'dependencies',
63
+ 'devDependencies',
64
+ 'optionalDependencies',
62
65
  ] as const
63
66
 
64
67
  /** Select Windows preview pins, rejecting a package that also needs mobile pins. */
65
68
  export function projectProfile(pkg: Record<string, any>): string {
66
- const deps = Object.assign({}, ...dependencySections.map((section) => pkg[section]))
67
- const windows = deps['@nativescript/windows'] || pkg.xplat?.targets?.windows
68
- if (windows && (deps['@nativescript/ios'] || deps['@nativescript/android'])) {
69
- throw new Error(
70
- 'Windows preview and mobile need separate workspace packages: their NativeScript pins differ',
71
- )
72
- }
73
-
74
- return windows ? 'windows' : 'default'
69
+ const deps = Object.assign({}, ...dependencySections.map((section) => pkg[section]))
70
+ const windows = deps['@nativescript/windows'] || pkg.xplat?.targets?.windows
71
+
72
+ if (windows && (deps['@nativescript/ios'] || deps['@nativescript/android'])) {
73
+ throw new Error(
74
+ 'Windows preview and mobile need separate workspace packages: their NativeScript pins differ',
75
+ )
76
+ }
77
+
78
+ return windows ? 'windows' : 'default'
79
+ }
80
+
81
+ /**
82
+ * An ancestor's workspace membership patterns: pnpm-workspace.yaml `packages`
83
+ * wins when the ancestor is not Bun-pinned, matching the CLI's root rules.
84
+ */
85
+ function workspacePatterns(root: string): string[] {
86
+ const yamlFile = join(root, 'pnpm-workspace.yaml')
87
+ const pkgFile = join(root, 'package.json')
88
+ const pkg = existsSync(pkgFile) ? JSON.parse(readFileSync(pkgFile, 'utf8')) : {}
89
+
90
+ if (pkg.packageManager?.split('@')[0] !== 'bun' && existsSync(yamlFile)) {
91
+ const packages = parse(readFileSync(yamlFile, 'utf8'))?.packages
92
+
93
+ return Array.isArray(packages) ? packages : []
94
+ }
95
+
96
+ const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages
97
+
98
+ return Array.isArray(patterns) ? patterns : []
99
+ }
100
+
101
+ /**
102
+ * Find the workspace that owns this app, respecting package membership.
103
+ * Mirrors the CLI's packageManagerRoot: ancestors need a package.json or a
104
+ * pnpm-workspace.yaml, and membership comes from the manager's config home.
105
+ */
106
+ export function compatibilityRoot(appRoot: string) {
107
+ const app = resolve(appRoot)
108
+
109
+ for (let at = dirname(app); dirname(at) !== at; at = dirname(at)) {
110
+ if (!existsSync(join(at, 'package.json')) && !existsSync(join(at, 'pnpm-workspace.yaml'))) {
111
+ continue
112
+ }
113
+
114
+ const patterns = workspacePatterns(at)
115
+
116
+ if (!patterns.length) {
117
+ continue
118
+ }
119
+
120
+ const included = patterns.filter((p) => !p.startsWith('!'))
121
+ const exclude = [
122
+ '**/node_modules/**',
123
+ ...patterns.filter((p) => p.startsWith('!')).map((p) => p.slice(1)),
124
+ ]
125
+
126
+ if (globSync(included, { cwd: at, exclude }).some((p) => resolve(at, p) === app)) {
127
+ return at
128
+ }
129
+ }
130
+
131
+ return app
75
132
  }
76
133
 
77
- /** Add missing pins when enabling a target in an older scaffold. Existing pins stay intact. */
134
+ /** Add missing Bun catalog pins when enabling a target. Existing pins stay intact. */
78
135
  export function ensureCompatibilityCatalog(appRoot: string, pkg: Record<string, any>) {
79
- let at = resolve(appRoot)
80
- while (!existsSync(join(at, 'pnpm-workspace.yaml')) && dirname(at) !== at) {
81
- at = dirname(at)
82
- }
83
- const workspace = existsSync(join(at, 'pnpm-workspace.yaml')) ? at : appRoot
84
- const path = join(workspace, 'pnpm-workspace.yaml')
85
- const before = existsSync(path) ? readFileSync(path, 'utf8') : ''
86
- const doc = parseDocument(before || '{}\n')
87
- if (doc.errors.length) {
88
- throw new Error(`${path}: ${doc.errors[0].message}`)
89
- }
90
-
91
- const profile = projectProfile(pkg)
92
- for (const section of dependencySections) {
93
- for (const [name, spec] of Object.entries(pkg[section] ?? {})) {
94
- if (spec !== `catalog:${managedCatalog(profile)}`) {
95
- continue
96
- }
97
-
98
- const key = ['catalogs', managedCatalog(profile), name]
99
- if (!doc.hasIn(key)) {
100
- doc.setIn(key, managedSpecifier(name, profile))
101
- }
102
- }
103
- }
104
-
105
- const after = String(doc)
106
- if (after !== before) {
107
- writeFileSync(path, after)
108
- }
136
+ const root = compatibilityRoot(appRoot)
137
+ const file = join(root, 'package.json')
138
+ const owner = root === resolve(appRoot) ? pkg : JSON.parse(readFileSync(file, 'utf8'))
139
+
140
+ mergeCompatibilityCatalog(pkg, owner)
141
+ if (owner !== pkg) {
142
+ writeFileSync(file, JSON.stringify(owner, null, '\t') + '\n')
143
+ }
144
+ }
145
+
146
+ /** Catalog pins a package requests via `catalog:` specifiers, managed set only. */
147
+ export function requestedCatalogPins(pkg: Record<string, any>) {
148
+ const profile = projectProfile(pkg)
149
+ const catalog = managedCatalog(profile)
150
+ const pins: Record<string, string> = {}
151
+
152
+ for (const section of dependencySections) {
153
+ for (const [name, spec] of Object.entries(pkg[section] ?? {})) {
154
+ if (spec === `catalog:${catalog}` && pins[name] === undefined) {
155
+ pins[name] = managedSpecifier(name, profile)!
156
+ }
157
+ }
158
+ }
159
+
160
+ return { catalog, pins }
161
+ }
162
+
163
+ /** Merge catalog policy without filesystem effects; shared by scaffold plans. */
164
+ export function mergeCompatibilityCatalog(pkg: Record<string, any>, owner: Record<string, any>) {
165
+ if (Array.isArray(owner.workspaces)) {
166
+ owner.workspaces = { packages: owner.workspaces }
167
+ }
168
+
169
+ owner.workspaces ??= { packages: [] }
170
+
171
+ const catalogs = owner.catalogs ?? (owner.workspaces.catalogs ??= {})
172
+ const { catalog, pins } = requestedCatalogPins(pkg)
173
+ const target = (catalogs[catalog] ??= {})
174
+
175
+ for (const [name, spec] of Object.entries(pins)) {
176
+ target[name] ??= spec
177
+ }
109
178
  }