@getcortexlabs/create-mavis 0.1.0-rc.15 → 0.1.0-rc.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -29
- package/package.json +2 -4
- package/src/adapters.mjs +0 -7
- package/src/add-desktop.mjs +50 -4
- package/src/capabilities.mjs +39 -186
- package/src/cli.mjs +16 -102
- package/src/desktop.mjs +1 -1
- package/src/doctor.mjs +4 -116
- package/src/native-framework.mjs +1 -1
- package/src/portability.mjs +2 -116
- package/src/scaffold.mjs +1 -6
- package/src/shared-api.mjs +3 -0
- package/src/ui.mjs +4 -64
- package/templates/desktop/common/build.mjs +0 -9
- package/templates/desktop/macos/src/host.mjs +9 -6
- package/templates/desktop/windows/src/host.mjs +21 -4
- package/templates/nuxt/nuxt.config.ts +2 -0
- package/src/add-macos.mjs +0 -386
- package/src/macos-capabilities.generated.mjs +0 -4190
- package/src/macos.mjs +0 -394
- package/src/migrate-directory.mjs +0 -121
- package/templates/desktop/macos/src/motion.mjs +0 -51
- package/templates/directory/macos/DirectoryStorage.swift +0 -68
- package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +0 -57
- package/templates/macos/examples/tasks/shared/TaskRow.lite.tsx +0 -33
- package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +0 -251
- package/templates/macos/examples/tasks/shared/types.ts +0 -10
- package/templates/macos/mobile/src/App.vue +0 -14
- package/templates/macos/mobile/src/app.ts +0 -7
- package/templates/macos/native/Package.swift +0 -19
- package/templates/macos/native/Sources/MavisDesktop/App.swift +0 -35
- package/templates/macos/native/Sources/MavisDesktop/Fonts/LICENSE +0 -45
- package/templates/macos/native/Sources/MavisDesktop/Fonts/lucide.ttf +0 -0
- package/templates/macos/root/tsconfig.json +0 -14
- package/templates/macos/scripts/generate.mjs +0 -13
- package/templates/macos/scripts/macos-manifest.mjs +0 -33
- package/templates/macos/scripts/macos.mjs +0 -58
- package/templates/macos/shared/Welcome.lite.tsx +0 -42
- package/templates/macos/web/index.html +0 -12
- package/templates/macos/web/src/main.js +0 -212
- package/templates/macos/web/src/mavis.js +0 -2
- package/templates/macos/web/src/style.css +0 -14
- package/templates/macos/web/vite.config.mjs +0 -14
- package/templates/migrations/directory-rc13.json +0 -36
package/src/cli.mjs
CHANGED
|
@@ -5,10 +5,8 @@ import { confirm, isCancel } from '@clack/prompts'
|
|
|
5
5
|
import { readFile } from 'node:fs/promises'
|
|
6
6
|
import { scaffold, installProject } from './scaffold.mjs'
|
|
7
7
|
import { planTarget, applyTarget } from './add-target.mjs'
|
|
8
|
-
import { planMacos, applyMacos } from './add-macos.mjs'
|
|
9
8
|
import { planDesktop, applyDesktop } from './add-desktop.mjs'
|
|
10
|
-
import {
|
|
11
|
-
import { checkPortability, formatMacReadiness } from './portability.mjs'
|
|
9
|
+
import { checkPortability } from './portability.mjs'
|
|
12
10
|
import { doctor } from './doctor.mjs'
|
|
13
11
|
import {
|
|
14
12
|
atLeast,
|
|
@@ -36,17 +34,15 @@ const help = `Create Mavis — Web, Native (iOS/Android), Mac and Windows
|
|
|
36
34
|
|
|
37
35
|
--targets web,native,macos,windows
|
|
38
36
|
Default: web. Desktop uses shared Vue (experimental)
|
|
39
|
-
--macos-runtime appkit
|
|
40
|
-
Default: appkit; SwiftUI keeps the compiler workflow
|
|
37
|
+
--macos-runtime appkit NativeScript AppKit is the macOS runtime
|
|
41
38
|
--target mobile|web|both|macos
|
|
42
39
|
Earlier names: native, web, web+native, web+macos
|
|
43
40
|
--add-native Add apps/mobile to an existing Vue/Vite or Nuxt app
|
|
44
41
|
--add-web Add apps/web to an existing NativeScript-Vue app
|
|
45
|
-
--add-macos Preview adding
|
|
42
|
+
--add-macos Preview adding NativeScript AppKit; --write applies
|
|
46
43
|
--add-windows Preview adding NativeScript Windows; --write applies
|
|
47
|
-
--
|
|
48
|
-
--
|
|
49
|
-
--entry path.vue Shared Vue/TSX entry for --add-macos
|
|
44
|
+
--shared-root path Source roots for desktop adoption (comma-separated)
|
|
45
|
+
--entry path.vue Shared Vue entry for --add-macos
|
|
50
46
|
--screen path.vue Reuse an existing screen without moving it
|
|
51
47
|
--screen-root screen|content Existing MScreen or content to wrap (auto-detected)
|
|
52
48
|
--web vite|nuxt Default: vite
|
|
@@ -55,9 +51,7 @@ const help = `Create Mavis — Web, Native (iOS/Android), Mac and Windows
|
|
|
55
51
|
validated and what is planned (add --json for tools)
|
|
56
52
|
--familiar vue|react|angular|svelte|solid|other
|
|
57
53
|
What you already know. Changes the advice, not what runs
|
|
58
|
-
--example welcome|directory
|
|
59
|
-
Starter, shared search/detail/edit reference, or the
|
|
60
|
-
Tasks app (with macos: one source for every target)
|
|
54
|
+
--example welcome|directory Starter or shared search/detail/edit reference
|
|
61
55
|
--check-portability Audit shared sources without SDK checks
|
|
62
56
|
--path directory Override the configured shared source directory
|
|
63
57
|
--fix-imports Preview safe renderer-import replacements
|
|
@@ -68,7 +62,7 @@ const help = `Create Mavis — Web, Native (iOS/Android), Mac and Windows
|
|
|
68
62
|
Default: the invoking manager, or npm
|
|
69
63
|
--framework vue|plain|react|angular|svelte|solid
|
|
70
64
|
Direct frameworks: iOS/Android only; desktop/Web use Vue
|
|
71
|
-
--authoring vue|
|
|
65
|
+
--authoring vue|native Vue or direct native framework authoring
|
|
72
66
|
--yes, -y Use defaults without prompts (skip installation)
|
|
73
67
|
--install / --no-install Install dependencies now or later
|
|
74
68
|
--dry-run Show the complete file plan without writing
|
|
@@ -100,7 +94,6 @@ try {
|
|
|
100
94
|
'add-macos': { type: 'boolean' },
|
|
101
95
|
'add-windows': { type: 'boolean' },
|
|
102
96
|
'macos-runtime': { type: 'string' },
|
|
103
|
-
'migrate-directory': { type: 'boolean' },
|
|
104
97
|
'shared-root': { type: 'string' },
|
|
105
98
|
entry: { type: 'string' },
|
|
106
99
|
screen: { type: 'string' },
|
|
@@ -134,10 +127,7 @@ try {
|
|
|
134
127
|
values.json ? JSON.stringify(describeCapabilities(), null, 2) : formatCapabilities(),
|
|
135
128
|
)
|
|
136
129
|
else if (values.version) console.log(version)
|
|
137
|
-
else if (
|
|
138
|
-
values['add-windows'] ||
|
|
139
|
-
(values['add-macos'] && values['macos-runtime'] !== 'swiftui')
|
|
140
|
-
) {
|
|
130
|
+
else if (values['add-windows'] || values['add-macos']) {
|
|
141
131
|
if (
|
|
142
132
|
positionals.length ||
|
|
143
133
|
values.targets ||
|
|
@@ -156,8 +146,7 @@ try {
|
|
|
156
146
|
values['screen-root'] ||
|
|
157
147
|
values.web ||
|
|
158
148
|
values.rendering ||
|
|
159
|
-
values.path
|
|
160
|
-
values['migrate-directory']
|
|
149
|
+
values.path
|
|
161
150
|
)
|
|
162
151
|
throw new Error(
|
|
163
152
|
'Run --add-macos or --add-windows in the existing project, with --shared-root and --entry if needed. Add one target at a time.',
|
|
@@ -165,7 +154,7 @@ try {
|
|
|
165
154
|
if (values['add-windows'] && values['macos-runtime'])
|
|
166
155
|
throw new Error('--macos-runtime belongs to --add-macos.')
|
|
167
156
|
if (values['macos-runtime'] && values['macos-runtime'] !== 'appkit')
|
|
168
|
-
throw new Error('
|
|
157
|
+
throw new Error('The macOS runtime is NativeScript AppKit.')
|
|
169
158
|
if (values.install || values['no-install'])
|
|
170
159
|
throw new Error(
|
|
171
160
|
'Desktop adoption previews changes; use --write, then install in the new host directory.',
|
|
@@ -209,70 +198,6 @@ try {
|
|
|
209
198
|
: 'No files changed. Review and rerun with --write.',
|
|
210
199
|
)
|
|
211
200
|
}
|
|
212
|
-
} else if (values['add-macos']) {
|
|
213
|
-
if (
|
|
214
|
-
positionals.length ||
|
|
215
|
-
values['add-native'] ||
|
|
216
|
-
values['add-web'] ||
|
|
217
|
-
values['add-windows'] ||
|
|
218
|
-
values.target ||
|
|
219
|
-
values.targets ||
|
|
220
|
-
values['check-portability'] ||
|
|
221
|
-
values['fix-imports'] ||
|
|
222
|
-
values.path ||
|
|
223
|
-
values.doctor ||
|
|
224
|
-
values.example ||
|
|
225
|
-
values.theme ||
|
|
226
|
-
values.framework ||
|
|
227
|
-
values.authoring ||
|
|
228
|
-
values.screen ||
|
|
229
|
-
values['screen-root'] ||
|
|
230
|
-
values.web ||
|
|
231
|
-
values.rendering
|
|
232
|
-
)
|
|
233
|
-
throw new Error(
|
|
234
|
-
'Run --add-macos in the existing project. Choose source roots with --shared-root and an entry with --entry.',
|
|
235
|
-
)
|
|
236
|
-
if (values.install || values['no-install'])
|
|
237
|
-
throw new Error(
|
|
238
|
-
'--add-macos does not install dependencies; review and apply with --write, then run your package manager.',
|
|
239
|
-
)
|
|
240
|
-
if (values.write && values['dry-run']) throw new Error('Choose --write or --dry-run, not both.')
|
|
241
|
-
const plan = await planMacos({
|
|
242
|
-
roots: values['shared-root']?.split(',').map((root) => root.trim()),
|
|
243
|
-
entry: values.entry,
|
|
244
|
-
packageManager: values['package-manager'],
|
|
245
|
-
migrateDirectory: values['migrate-directory'],
|
|
246
|
-
})
|
|
247
|
-
const summary = {
|
|
248
|
-
directory: 'apps/macos',
|
|
249
|
-
entry: plan.entry,
|
|
250
|
-
roots: plan.roots,
|
|
251
|
-
manager: plan.manager,
|
|
252
|
-
alreadyAdded: plan.alreadyAdded,
|
|
253
|
-
components: plan.components,
|
|
254
|
-
files: [...plan.files.keys()],
|
|
255
|
-
config: plan.config,
|
|
256
|
-
migration: plan.migration ?? [],
|
|
257
|
-
applied: Boolean(values.write && !plan.alreadyAdded),
|
|
258
|
-
}
|
|
259
|
-
if (values.write) await applyMacos(plan, { signal: cancellation.signal })
|
|
260
|
-
if (values.json) console.log(JSON.stringify(summary, null, 2))
|
|
261
|
-
else {
|
|
262
|
-
ui.message(
|
|
263
|
-
`${plan.alreadyAdded ? 'Already configured' : values.write ? 'Added' : 'Preview'}: SwiftUI in apps/macos; ${plan.components} shared components`,
|
|
264
|
-
)
|
|
265
|
-
for (const diff of summary.migration) console.log(migrationDiff(diff))
|
|
266
|
-
for (const name of summary.files)
|
|
267
|
-
console.log(` ${plan.original.get(name) === undefined ? '+' : '~'} ${name}`)
|
|
268
|
-
console.log(
|
|
269
|
-
plan.alreadyAdded
|
|
270
|
-
? 'Existing files were preserved.'
|
|
271
|
-
: values.write
|
|
272
|
-
? `Run ${packageCommands(plan.manager).install}, then ${packageCommands(plan.manager).run('build:macos')}.`
|
|
273
|
-
: 'No files changed. Review this plan and rerun with --write to add Mac and migrate mavis.config.json to schema 2.',
|
|
274
|
-
)
|
|
275
|
-
}
|
|
276
201
|
} else if (values['add-native'] || values['add-web']) {
|
|
277
202
|
if (!atLeast(process.versions.node, requirements.node))
|
|
278
203
|
throw new Error(
|
|
@@ -300,8 +225,8 @@ try {
|
|
|
300
225
|
throw new Error('--web and --rendering belong to --add-web.')
|
|
301
226
|
if (values.install && values['no-install'])
|
|
302
227
|
throw new Error('Choose either --install or --no-install.')
|
|
303
|
-
if (values.entry || values['shared-root']
|
|
304
|
-
throw new Error('--entry and --shared-root require --add-macos.')
|
|
228
|
+
if (values.entry || values['shared-root'])
|
|
229
|
+
throw new Error('--entry and --shared-root require --add-macos or --add-windows.')
|
|
305
230
|
if (values['screen-root'] && !values.screen) throw new Error('--screen-root requires --screen.')
|
|
306
231
|
const target = await planTarget({
|
|
307
232
|
target: values['add-native'] ? 'mobile' : 'web',
|
|
@@ -389,22 +314,15 @@ try {
|
|
|
389
314
|
console.log(
|
|
390
315
|
`${result.files.length} files checked; ${result.diagnostics.length} findings. ${values['fix-imports'] && !values.write ? 'Preview only. Use --write to apply safe import changes.' : ''}`,
|
|
391
316
|
)
|
|
392
|
-
console.log(formatMacReadiness(result.macos))
|
|
393
317
|
}
|
|
394
|
-
|
|
395
|
-
const config = await readFile('mavis.config.json', 'utf8').then(JSON.parse, () => ({}))
|
|
396
|
-
const blocked =
|
|
397
|
-
config.targets?.includes('macos') &&
|
|
398
|
-
config.apps?.macos?.toolkit !== 'nativescript-appkit' &&
|
|
399
|
-
result.macos.files?.some((file) => !file.ready)
|
|
400
|
-
if (result.diagnostics.length || blocked) process.exitCode = 1
|
|
318
|
+
if (result.diagnostics.length) process.exitCode = 1
|
|
401
319
|
} else if (values.doctor) {
|
|
402
320
|
const results = await doctor()
|
|
403
321
|
for (const item of results) console.log(`${item.ok ? '✓' : '—'} ${item.name}: ${item.detail}`)
|
|
404
322
|
if (results.some((item) => !item.ok)) process.exitCode = 1
|
|
405
323
|
} else {
|
|
406
|
-
if (values.entry || values['shared-root']
|
|
407
|
-
throw new Error('--entry and --shared-root require --add-macos.')
|
|
324
|
+
if (values.entry || values['shared-root'])
|
|
325
|
+
throw new Error('--entry and --shared-root require --add-macos or --add-windows.')
|
|
408
326
|
if (values.screen || values['screen-root'])
|
|
409
327
|
throw new Error('--screen requires --add-native or --add-web.')
|
|
410
328
|
if (values.write || values.path || values.json)
|
|
@@ -461,11 +379,7 @@ try {
|
|
|
461
379
|
})
|
|
462
380
|
ui.note(nextSteps(plan.preset, options.install), 'Next steps')
|
|
463
381
|
ui.message(`Make it yours: ${sharedEntry(plan.preset)}`)
|
|
464
|
-
if (plan.preset.target === '
|
|
465
|
-
ui.message(
|
|
466
|
-
`Experimental shared TSX: see the README for the supported subset.${plan.preset.targets.includes('macos') ? ' The Mac app needs macOS 14+ and Xcode.' : ''}${plan.preset.targets.includes('native') ? ' Native needs the NativeScript CLI and platform SDKs; check with --doctor.' : ''}`,
|
|
467
|
-
)
|
|
468
|
-
else if (plan.preset.target === 'desktop')
|
|
382
|
+
if (plan.preset.target === 'desktop')
|
|
469
383
|
ui.message(
|
|
470
384
|
'Experimental NativeScript desktop subset: check the generated README and --doctor for platform requirements and supported components.',
|
|
471
385
|
)
|
package/src/desktop.mjs
CHANGED
|
@@ -90,7 +90,7 @@ export async function desktopFiles(preset, copyTemplate, projectFiles) {
|
|
|
90
90
|
)
|
|
91
91
|
.join(
|
|
92
92
|
'\n',
|
|
93
|
-
)}\n\nPackaged apps include Node and the NativeScript runtime. They do not need a globally installed Node or a development server. For distribution, add your own signing and installer/notarization workflow.\n\n## Current component contract\n\nMScreen, MColumn, MRow, MGrid, MText, MInput, MButton, MLink, MCard, MAlert, MEmptyState and MReveal. See \`apps/*/src/host.mjs\` for accepted properties; unsupported properties produce an error. MRow divides space evenly; MGrid adapts to minColumnWidth. NativeScript Core mobile widgets are not desktop controls. Existing Mavis components outside this subset require a desktop implementation.\n\nAppKit uses native menus and
|
|
93
|
+
)}\n\nPackaged apps include Node and the NativeScript runtime. They do not need a globally installed Node or a development server. For distribution, add your own signing and installer/notarization workflow.\n\n## Current component contract\n\nMScreen, MColumn, MRow, MGrid, MText, MInput, MButton, MLink, MCard, MAlert, MEmptyState and MReveal. See \`apps/*/src/host.mjs\` for accepted properties; unsupported properties produce an error. MRow divides space evenly; MGrid adapts to minColumnWidth. NativeScript Core mobile widgets are not desktop controls. Existing Mavis components outside this subset require a desktop implementation.\n\nAppKit uses native menus and Core Animation. Windows uses XAML controls and Storyboards. MReveal fades in on both through the public Jolt desktop drivers and respects system motion settings. The built-in themes are supported; arbitrary theme overrides and motion recipes are outside this starter's contract.\n\nDesktop storage stays under the user's application-data directory, in \`${preset.name}\`. Nothing is sent to a server. Commit generated lockfiles.\n`,
|
|
94
94
|
)
|
|
95
95
|
return { preset, files: new Map([...files].sort(([a], [b]) => a.localeCompare(b))) }
|
|
96
96
|
}
|
package/src/doctor.mjs
CHANGED
|
@@ -20,7 +20,8 @@ export async function doctor(cwd = process.cwd()) {
|
|
|
20
20
|
let config
|
|
21
21
|
try {
|
|
22
22
|
config = normalizeConfig(JSON.parse(await readFile(join(cwd, 'mavis.config.json'), 'utf8')))
|
|
23
|
-
} catch {
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.message.includes('archived SwiftUI')) throw error
|
|
24
25
|
throw new Error('Run --doctor from a generated project containing mavis.config.json.')
|
|
25
26
|
}
|
|
26
27
|
// The same check the creator runs before writing a project, on what this one records.
|
|
@@ -99,59 +100,10 @@ export async function doctor(cwd = process.cwd()) {
|
|
|
99
100
|
name: 'Desktop component contract',
|
|
100
101
|
ok: true,
|
|
101
102
|
detail:
|
|
102
|
-
'Experimental subset; build and run each host to validate its controls. --capabilities --json lists exact accepted props.
|
|
103
|
+
'Experimental subset; build and run each host to validate its controls. --capabilities --json lists exact accepted props.',
|
|
103
104
|
})
|
|
104
105
|
return results
|
|
105
106
|
}
|
|
106
|
-
if (config.target === 'macos') {
|
|
107
|
-
const result =
|
|
108
|
-
process.platform === 'darwin'
|
|
109
|
-
? spawnSync('xcrun', ['swift', '--version'], { encoding: 'utf8', timeout: 10000 })
|
|
110
|
-
: null
|
|
111
|
-
results.push({
|
|
112
|
-
name: 'SwiftUI build host',
|
|
113
|
-
ok: result?.status === 0,
|
|
114
|
-
detail: result
|
|
115
|
-
? (result.error?.message ?? (result.stdout || result.stderr)).trim().split('\n')[0]
|
|
116
|
-
: 'macOS 14+ and Xcode are required for the native app. Web remains available.',
|
|
117
|
-
})
|
|
118
|
-
// Use the compiler installed in this project, not a copied implementation.
|
|
119
|
-
try {
|
|
120
|
-
const compiler = await import(
|
|
121
|
-
pathToFileURL(
|
|
122
|
-
createRequire(join(cwd, 'package.json')).resolve('@getcortexlabs/mavis-compiler'),
|
|
123
|
-
)
|
|
124
|
-
)
|
|
125
|
-
results.push(...(await checkMacVersions(cwd, config, compiler)))
|
|
126
|
-
compiler.macAppSettings(config.macos, config.name)
|
|
127
|
-
const { model } = await compiler.compileProject(
|
|
128
|
-
await compiler.readShared(cwd, { roots: config.portability?.roots }),
|
|
129
|
-
{
|
|
130
|
-
theme: config.theme,
|
|
131
|
-
root: config.portability?.entry ?? 'Welcome',
|
|
132
|
-
sourceRoot: config.portability?.sourceRoot ?? config.portability?.roots?.[0] ?? 'shared',
|
|
133
|
-
destinations: config.portability?.destinations,
|
|
134
|
-
},
|
|
135
|
-
)
|
|
136
|
-
compiler.startupPlan(model, config.portability?.startup)
|
|
137
|
-
results.push({
|
|
138
|
-
name: 'Shared sources',
|
|
139
|
-
ok: true,
|
|
140
|
-
detail: `${model.components.length} component(s) type-checked for ${config.targets.join(', ')}. Run generate to write them; this does not prove a build.`,
|
|
141
|
-
})
|
|
142
|
-
} catch (error) {
|
|
143
|
-
results.push({
|
|
144
|
-
name: 'Shared sources',
|
|
145
|
-
ok: false,
|
|
146
|
-
detail:
|
|
147
|
-
error.code === 'ERR_MODULE_NOT_FOUND'
|
|
148
|
-
? 'Install the project dependencies, then run doctor again.'
|
|
149
|
-
: error.message,
|
|
150
|
-
})
|
|
151
|
-
}
|
|
152
|
-
if (config.targets.includes('native')) nativeChecks(results)
|
|
153
|
-
return results
|
|
154
|
-
}
|
|
155
107
|
if (config.target !== 'web') nativeChecks(results)
|
|
156
108
|
if (config.framework !== 'vue') {
|
|
157
109
|
results.push({
|
|
@@ -180,7 +132,6 @@ export function checkRecordedProject(config) {
|
|
|
180
132
|
config.targets.every((target) => catalog.targets[target]),
|
|
181
133
|
message: 'Invalid NativeScript desktop configuration.',
|
|
182
134
|
}
|
|
183
|
-
if (config.portability?.existing) return existingProject(config)
|
|
184
135
|
return checkProject({
|
|
185
136
|
name: config.name,
|
|
186
137
|
targets: config.targets,
|
|
@@ -190,10 +141,7 @@ export function checkRecordedProject(config) {
|
|
|
190
141
|
macosRuntime: config.macosRuntime,
|
|
191
142
|
authoring: config.authoring,
|
|
192
143
|
example: config.example,
|
|
193
|
-
theme:
|
|
194
|
-
config.targets?.includes('macos') && typeof config.theme === 'object'
|
|
195
|
-
? undefined
|
|
196
|
-
: config.theme,
|
|
144
|
+
theme: config.theme,
|
|
197
145
|
packageManager: config.packageManager,
|
|
198
146
|
})
|
|
199
147
|
}
|
|
@@ -224,63 +172,3 @@ function nativeChecks(results) {
|
|
|
224
172
|
detail: 'iOS builds require macOS and Xcode; Android remains available.',
|
|
225
173
|
})
|
|
226
174
|
}
|
|
227
|
-
|
|
228
|
-
function existingProject(config) {
|
|
229
|
-
const ok =
|
|
230
|
-
Array.isArray(config.targets) &&
|
|
231
|
-
config.targets.includes('macos') &&
|
|
232
|
-
config.targets.every((target) => catalog.targets[target]) &&
|
|
233
|
-
['vue', 'mitosis'].includes(config.authoring) &&
|
|
234
|
-
catalog.packageManagers.includes(config.packageManager) &&
|
|
235
|
-
(!config.targets.includes('web') ||
|
|
236
|
-
catalog.hosts[config.web]?.rendering?.includes(config.rendering))
|
|
237
|
-
return {
|
|
238
|
-
ok,
|
|
239
|
-
message:
|
|
240
|
-
'Invalid targets, authoring, package manager or Web host/rendering in mavis.config.json.',
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/** Read-only release alignment check, independent of the Swift/NativeScript SDK probes. */
|
|
245
|
-
export async function checkMacVersions(cwd, config, compiler) {
|
|
246
|
-
const results = []
|
|
247
|
-
const manifests = []
|
|
248
|
-
for (const name of ['package.json', 'apps/web/package.json', 'apps/mobile/package.json']) {
|
|
249
|
-
try {
|
|
250
|
-
manifests.push(JSON.parse(await readFile(join(cwd, name), 'utf8')))
|
|
251
|
-
} catch (error) {
|
|
252
|
-
if (error.code !== 'ENOENT') throw error
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
const dependencies = manifests.map((pkg) => ({ ...pkg.devDependencies, ...pkg.dependencies }))
|
|
256
|
-
const declared = dependencies[0]?.['@getcortexlabs/mavis-compiler']
|
|
257
|
-
const expected = config.versions?.mavis ?? compiler.compilerVersion
|
|
258
|
-
const renderers = dependencies.flatMap((dep) =>
|
|
259
|
-
['@getcortexlabs/mavis-core', '@getcortexlabs/mavis-web', '@getcortexlabs/mavis'].flatMap(
|
|
260
|
-
(name) => (dep[name] ? [dep[name]] : []),
|
|
261
|
-
),
|
|
262
|
-
)
|
|
263
|
-
results.push({
|
|
264
|
-
name: 'Mavis compiler version',
|
|
265
|
-
ok:
|
|
266
|
-
declared === compiler.compilerVersion &&
|
|
267
|
-
compiler.compilerVersion === expected &&
|
|
268
|
-
renderers.every((version) => [expected, '^' + expected, '~' + expected].includes(version)),
|
|
269
|
-
detail: `Installed compiler ${compiler.compilerVersion}; requested ${declared ?? 'missing'}; Mavis ${expected}. Upgrade Mavis and the compiler together.`,
|
|
270
|
-
})
|
|
271
|
-
const jolts = dependencies.flatMap((dep) =>
|
|
272
|
-
dep['@rafaelaugusto/jolt'] ? [dep['@rafaelaugusto/jolt']] : [],
|
|
273
|
-
)
|
|
274
|
-
const swift = await readFile(join(cwd, 'apps/macos/Package.swift'), 'utf8')
|
|
275
|
-
const pin = /jolt-swift[^\n]*exact:\s*"([^"]+)"/.exec(swift)?.[1]
|
|
276
|
-
const expectedJolt = config.versions?.jolt ?? versions.jolt
|
|
277
|
-
results.push({
|
|
278
|
-
name: 'Jolt / SwiftUI version',
|
|
279
|
-
ok:
|
|
280
|
-
expectedJolt === versions.jolt &&
|
|
281
|
-
pin === compiler.joltSwift.version &&
|
|
282
|
-
jolts.every((version) => version === expectedJolt),
|
|
283
|
-
detail: `Jolt ${[...new Set(jolts)].join(', ') || expectedJolt}; SwiftUI ${pin ?? 'missing exact pin'}; creator expects JavaScript ${versions.jolt}; compiler expects SwiftUI ${compiler.joltSwift.version}.`,
|
|
284
|
-
})
|
|
285
|
-
return results
|
|
286
|
-
}
|
package/src/native-framework.mjs
CHANGED
|
@@ -138,7 +138,7 @@ export async function nativeFrameworkFiles(preset, copyTemplate) {
|
|
|
138
138
|
const commands = packageCommands(preset.packageManager)
|
|
139
139
|
files.set(
|
|
140
140
|
'README.md',
|
|
141
|
-
`# ${preset.name}\n\nDirect ${framework === 'plain' ? 'JavaScript/TypeScript' : framework} components on NativeScript iOS and Android.\n\n\`\`\`sh\n${commands.install}\n${commands.run('ios')}\n${commands.run('android')}\n\`\`\`\n\nEdit \`src/${framework === 'svelte' ? 'Welcome.svelte' : 'screen.ts'}\`. The screen uses its framework's state and lifecycle and renders native views directly. No Vue runtime is installed. \`src/model.ts\` supplies the starting themes and a scoped motion example.\n\nRequires Node 22.23.3+, NativeScript CLI, a JDK and Android SDK; iOS builds need macOS/Xcode. Run \`ns doctor\` and \`${commands.run('typecheck')}\`.\n\nThis starter supports MBox, MRow, MColumn, MText, MButton and MInput. The full Vue component catalog is a different adapter. Rich MText children, arbitrary MButton slots and some effects are not implemented in the direct adapters; see the Mavis native adapter guide. Web, Mac and Windows creator hosts currently use Vue and cannot be combined with this framework preset.\n\nDependencies are pinned. Core 9 compatibility overrides for React NativeScript and Svelte Native are explicit in the package-manager configuration. Jolt RC.
|
|
141
|
+
`# ${preset.name}\n\nDirect ${framework === 'plain' ? 'JavaScript/TypeScript' : framework} components on NativeScript iOS and Android.\n\n\`\`\`sh\n${commands.install}\n${commands.run('ios')}\n${commands.run('android')}\n\`\`\`\n\nEdit \`src/${framework === 'svelte' ? 'Welcome.svelte' : 'screen.ts'}\`. The screen uses its framework's state and lifecycle and renders native views directly. No Vue runtime is installed. \`src/model.ts\` supplies the starting themes and a scoped motion example.\n\nRequires Node 22.23.3+, NativeScript CLI, a JDK and Android SDK; iOS builds need macOS/Xcode. Run \`ns doctor\` and \`${commands.run('typecheck')}\`.\n\nThis starter supports MBox, MRow, MColumn, MText, MButton and MInput. The full Vue component catalog is a different adapter. Rich MText children, arbitrary MButton slots and some effects are not implemented in the direct adapters; see the Mavis native adapter guide. Web, Mac and Windows creator hosts currently use Vue and cannot be combined with this framework preset.\n\nDependencies are pinned. Core 9 compatibility overrides for React NativeScript and Svelte Native are explicit in the package-manager configuration. Jolt RC.18 accepts the selected framework without peer overrides. Only the selected framework is installed. Commit the generated lockfile. ${framework === 'svelte' ? 'Svelte Native 1.0.32 still uses the tested custom-event and bootstrap ownership workarounds in Mavis; upstream adoption is tracked in Mavis #380 and #381.' : ''}\n`,
|
|
142
142
|
)
|
|
143
143
|
return { preset, files }
|
|
144
144
|
}
|
package/src/portability.mjs
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { lstat, readFile, readdir, writeFile } from 'node:fs/promises'
|
|
2
|
-
import { createRequire } from 'node:module'
|
|
3
2
|
import { normalizeConfig } from './presets.mjs'
|
|
4
3
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
5
|
-
import { pathToFileURL } from 'node:url'
|
|
6
4
|
import ts from 'typescript'
|
|
7
5
|
import { parse } from '@vue/compiler-sfc'
|
|
8
6
|
import { components, composables } from './shared-api.mjs'
|
|
9
|
-
import { checkShared } from '@getcortexlabs/mavis-compiler'
|
|
10
7
|
|
|
11
8
|
const rendererImports = new Set(['@getcortexlabs/mavis-web', '@getcortexlabs/mavis/vue'])
|
|
12
9
|
const sharedNames = new Set([...components, ...composables])
|
|
@@ -295,88 +292,6 @@ export function inspectSource(source, filename, { allowImports = [] } = {}) {
|
|
|
295
292
|
return { diagnostics, edits, imports }
|
|
296
293
|
}
|
|
297
294
|
|
|
298
|
-
// The Mavis core a project installed: the Mac check reads its theme's tokens.
|
|
299
|
-
async function projectCore(root) {
|
|
300
|
-
for (const base of ['', 'apps/web', 'apps/mobile'])
|
|
301
|
-
try {
|
|
302
|
-
const found = createRequire(join(root, base, 'package.json')).resolve(
|
|
303
|
-
'@getcortexlabs/mavis-core',
|
|
304
|
-
)
|
|
305
|
-
return await import(pathToFileURL(found))
|
|
306
|
-
} catch {}
|
|
307
|
-
try {
|
|
308
|
-
return await import('@getcortexlabs/mavis-core')
|
|
309
|
-
} catch {}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Whether each shared file can be compiled for the experimental Mac target, with the reasons
|
|
314
|
-
* the Mac compiler's own front ends give. It reads one flat folder of Name.vue, Name.lite.tsx
|
|
315
|
-
* and type files, so every folder is checked on its own.
|
|
316
|
-
*/
|
|
317
|
-
async function macReadiness(root, sources, config, only, core) {
|
|
318
|
-
core ??= await projectCore(root)
|
|
319
|
-
if (!core)
|
|
320
|
-
return {
|
|
321
|
-
checked: false,
|
|
322
|
-
reason:
|
|
323
|
-
'Install the project dependencies first: the Mac check reads the theme from @getcortexlabs/mavis-core.',
|
|
324
|
-
}
|
|
325
|
-
const folders = new Map()
|
|
326
|
-
for (const [file, source] of sources) {
|
|
327
|
-
if (/\.d\.ts$/.test(file) || !/\.(vue|ts|lite\.tsx)$/.test(file)) continue
|
|
328
|
-
const folder = dirname(file)
|
|
329
|
-
if (!folders.has(folder)) folders.set(folder, new Map())
|
|
330
|
-
folders.get(folder).set(`shared/${basename(file)}`, source)
|
|
331
|
-
}
|
|
332
|
-
const files = []
|
|
333
|
-
for (const [folder, shared] of folders) {
|
|
334
|
-
let checked
|
|
335
|
-
try {
|
|
336
|
-
checked = await checkShared(shared, core[config.theme] ?? core.mavis)
|
|
337
|
-
} catch (error) {
|
|
338
|
-
checked = [...shared.keys()].map((file) => ({
|
|
339
|
-
file,
|
|
340
|
-
ready: false,
|
|
341
|
-
problems: [{ message: error.message }],
|
|
342
|
-
}))
|
|
343
|
-
}
|
|
344
|
-
// The compiler names every file shared/…; say where it really is.
|
|
345
|
-
const actual = (text) => text.replaceAll('shared/', `${relative(root, folder)}/`)
|
|
346
|
-
for (const item of checked)
|
|
347
|
-
files.push({
|
|
348
|
-
file: actual(item.file),
|
|
349
|
-
ready: item.ready,
|
|
350
|
-
problems: item.problems.map((problem) => ({
|
|
351
|
-
...problem,
|
|
352
|
-
message: actual(problem.message),
|
|
353
|
-
})),
|
|
354
|
-
})
|
|
355
|
-
}
|
|
356
|
-
return {
|
|
357
|
-
checked: true,
|
|
358
|
-
files: files
|
|
359
|
-
.filter((item) => !only || only.has(item.file))
|
|
360
|
-
.sort((a, b) => a.file.localeCompare(b.file)),
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/** The Mac check as lines for a terminal. */
|
|
365
|
-
export function formatMacReadiness(macos) {
|
|
366
|
-
if (!macos.checked) return `Mac target (experimental): not checked. ${macos.reason}`
|
|
367
|
-
const ready = macos.files.filter((file) => file.ready).length
|
|
368
|
-
return [
|
|
369
|
-
`Mac target (experimental): ${ready} of ${macos.files.length} shared files are ready to compile.`,
|
|
370
|
-
...macos.files.flatMap((file) => [
|
|
371
|
-
` ${file.ready ? 'ready ' : 'not ready'} ${file.file}`,
|
|
372
|
-
...file.problems.map(
|
|
373
|
-
(problem) =>
|
|
374
|
-
` ${problem.line ? `${problem.line}:${problem.column} ` : ''}${problem.message}`,
|
|
375
|
-
),
|
|
376
|
-
]),
|
|
377
|
-
].join('\n')
|
|
378
|
-
}
|
|
379
|
-
|
|
380
295
|
async function projectConfig(root) {
|
|
381
296
|
try {
|
|
382
297
|
return normalizeConfig(JSON.parse(await readFile(join(root, 'mavis.config.json'), 'utf8')))
|
|
@@ -392,16 +307,12 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
392
307
|
const config = await projectConfig(root)
|
|
393
308
|
if (config.framework && config.framework !== 'vue')
|
|
394
309
|
throw new Error(
|
|
395
|
-
'This source audit applies to shared Vue
|
|
310
|
+
'This source audit applies to shared Vue sources. Direct native starters use their framework typecheck and platform builds.',
|
|
396
311
|
)
|
|
397
312
|
if (config.target === 'desktop' && options.fixImports)
|
|
398
313
|
throw new Error(
|
|
399
314
|
'Migrate imports in the Web/mobile project before desktop adoption. Generated desktop hosts require the declared component subset; no files changed.',
|
|
400
315
|
)
|
|
401
|
-
if (config.authoring === 'mitosis' && options.fixImports)
|
|
402
|
-
throw new Error(
|
|
403
|
-
'Import migrations are not supported in a project whose shared sources are compiled for each target.',
|
|
404
|
-
)
|
|
405
316
|
const roots = options.path
|
|
406
317
|
? [options.path]
|
|
407
318
|
: (config.portability?.roots ?? [
|
|
@@ -414,7 +325,6 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
414
325
|
)
|
|
415
326
|
throw new Error('Configure at least one source directory in portability.roots.')
|
|
416
327
|
const files = new Map(),
|
|
417
|
-
compiled = new Map(),
|
|
418
328
|
diagnostics = [],
|
|
419
329
|
fixes = []
|
|
420
330
|
const load = async (file, dependency = false) => {
|
|
@@ -432,9 +342,6 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
432
342
|
if (dependency) return
|
|
433
343
|
for (const item of (await readdir(file)).sort())
|
|
434
344
|
if (!ignored.has(item)) await load(join(file, item))
|
|
435
|
-
} else if (/\.lite\.tsx$/.test(file)) {
|
|
436
|
-
// Compiled for every target, never run as written: only the Mac check below reads it.
|
|
437
|
-
compiled.set(file, await readFile(file, 'utf8'))
|
|
438
345
|
} else if (sourceExtensions.includes(extname(file)) && !files.has(file)) {
|
|
439
346
|
const source = await readFile(file, 'utf8')
|
|
440
347
|
const result = inspectSource(source, relative(root, file), config.portability)
|
|
@@ -499,28 +406,8 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
499
406
|
}
|
|
500
407
|
await load(file)
|
|
501
408
|
}
|
|
502
|
-
if (!files.size
|
|
409
|
+
if (!files.size)
|
|
503
410
|
throw new Error('No Vue or script sources found in the configured portability paths.')
|
|
504
|
-
const within = new Set()
|
|
505
|
-
for (const name of roots) {
|
|
506
|
-
const start = resolve(root, name)
|
|
507
|
-
for (const file of [...files.keys(), ...compiled.keys()])
|
|
508
|
-
if (file === start || file.startsWith(start + sep)) within.add(relative(root, file))
|
|
509
|
-
}
|
|
510
|
-
const macos =
|
|
511
|
-
config.apps?.macos?.toolkit === 'nativescript-appkit' || config.targets?.includes('windows')
|
|
512
|
-
? {
|
|
513
|
-
checked: false,
|
|
514
|
-
reason:
|
|
515
|
-
'NativeScript desktop uses direct Vue; the SwiftUI compiler audit does not apply. Build and test each desktop host against its declared subset.',
|
|
516
|
-
}
|
|
517
|
-
: await macReadiness(
|
|
518
|
-
root,
|
|
519
|
-
new Map([...[...files].map(([file, { source }]) => [file, source]), ...compiled]),
|
|
520
|
-
config,
|
|
521
|
-
within,
|
|
522
|
-
options.core,
|
|
523
|
-
)
|
|
524
411
|
if (options.fixImports) {
|
|
525
412
|
if (config.portability?.alias !== '#mavis')
|
|
526
413
|
throw new Error(
|
|
@@ -576,7 +463,6 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
576
463
|
diagnostics: diagnostics.sort(
|
|
577
464
|
(a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column,
|
|
578
465
|
),
|
|
579
|
-
macos,
|
|
580
466
|
fixes,
|
|
581
467
|
written: false,
|
|
582
468
|
}
|
package/src/scaffold.mjs
CHANGED
|
@@ -45,10 +45,6 @@ export async function projectFiles(options) {
|
|
|
45
45
|
const { desktopFiles } = await import('./desktop.mjs')
|
|
46
46
|
return desktopFiles(preset, copyTemplate, projectFiles)
|
|
47
47
|
}
|
|
48
|
-
if (preset.target === 'macos') {
|
|
49
|
-
const { macosFiles } = await import('./macos.mjs')
|
|
50
|
-
return macosFiles(preset, files, copyTemplate)
|
|
51
|
-
}
|
|
52
48
|
const shared = preset.target === 'both'
|
|
53
49
|
const directory = preset.example === 'directory'
|
|
54
50
|
const commands = packageCommands(preset.packageManager)
|
|
@@ -352,8 +348,7 @@ export async function installProject(plan, { signal, onProgress } = {}) {
|
|
|
352
348
|
? ['apps/windows']
|
|
353
349
|
: []),
|
|
354
350
|
]
|
|
355
|
-
: plan.preset.target === 'both'
|
|
356
|
-
(plan.preset.target === 'macos' && plan.preset.targets.includes('native'))
|
|
351
|
+
: plan.preset.target === 'both'
|
|
357
352
|
? ['', 'apps/mobile']
|
|
358
353
|
: ['']
|
|
359
354
|
for (const directory of directories) {
|