@getcortexlabs/create-mavis 0.1.0-rc.13 → 0.1.0-rc.15
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 +44 -7
- package/package.json +4 -2
- package/src/adapters.mjs +56 -20
- package/src/add-desktop.mjs +308 -0
- package/src/add-macos.mjs +386 -0
- package/src/capabilities.mjs +352 -85
- package/src/cli.mjs +181 -9
- package/src/desktop.mjs +155 -0
- package/src/doctor.mjs +181 -18
- package/src/macos-capabilities.generated.mjs +4190 -0
- package/src/macos.mjs +147 -29
- package/src/migrate-directory.mjs +121 -0
- package/src/native-framework.mjs +144 -0
- package/src/portability.mjs +123 -5
- package/src/scaffold.mjs +59 -11
- package/src/ui.mjs +69 -12
- package/templates/desktop/common/LICENSE +21 -0
- package/templates/desktop/common/build.mjs +58 -0
- package/templates/desktop/common/src/components.ts +60 -0
- package/templates/desktop/common/src/contract.mjs +35 -0
- package/templates/desktop/common/src/renderer.ts +76 -0
- package/templates/desktop/common/src/storage.ts +29 -0
- package/templates/desktop/directory/main.ts +35 -0
- package/templates/desktop/macos/launch.mjs +6 -0
- package/templates/desktop/macos/package.mjs +114 -0
- package/templates/desktop/macos/src/host.mjs +468 -0
- package/templates/desktop/macos/src/motion.mjs +51 -0
- package/templates/desktop/welcome/Welcome.vue +56 -0
- package/templates/desktop/welcome/main.ts +24 -0
- package/templates/desktop/windows/NativeScript-LICENSE +19 -0
- package/templates/desktop/windows/launch.mjs +16 -0
- package/templates/desktop/windows/package.mjs +54 -0
- package/templates/desktop/windows/prepare-host.mjs +73 -0
- package/templates/desktop/windows/src/host.mjs +277 -0
- package/templates/directory/host/directory-storage.ts +78 -0
- package/templates/directory/macos/DirectoryStorage.swift +68 -0
- package/templates/directory/mobile/src/app.ts +11 -8
- package/templates/directory/nuxt/app/plugins/mavis.ts +11 -8
- package/templates/directory/shared/Edit.vue +8 -5
- package/templates/directory/shared/directory-store.ts +42 -46
- package/templates/directory/vite/src/main.ts +11 -8
- package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +2 -2
- package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +2 -2
- package/templates/macos/examples/tasks/shared/types.ts +1 -0
- package/templates/macos/mobile/src/App.vue +4 -2
- package/templates/macos/native/Package.swift +3 -1
- package/templates/macos/native/Sources/MavisDesktop/App.swift +26 -11
- package/templates/macos/native/Sources/MavisDesktop/Fonts/LICENSE +45 -0
- package/templates/macos/native/Sources/MavisDesktop/Fonts/lucide.ttf +0 -0
- package/templates/macos/scripts/generate.mjs +3 -26
- package/templates/macos/scripts/macos-manifest.mjs +33 -0
- package/templates/macos/scripts/macos.mjs +20 -18
- package/templates/macos/web/index.html +1 -1
- package/templates/macos/web/src/main.js +176 -3
- package/templates/macos/web/src/mavis.js +2 -0
- package/templates/macos/web/src/style.css +2 -1
- package/templates/macos/web/vite.config.mjs +12 -1
- package/templates/migrations/directory-rc13.json +36 -0
- package/templates/mobile/src/mavis.ts +2 -82
- package/templates/mobile/webpack.config.js +4 -0
- package/templates/native-framework/angular/screen.ts +84 -0
- package/templates/native-framework/common/nativescript.config.ts +6 -0
- package/templates/native-framework/common/src/app.ts +5 -0
- package/templates/native-framework/common/src/model.ts +40 -0
- package/templates/native-framework/common/src/references.d.ts +8 -0
- package/templates/native-framework/common/tsconfig.json +16 -0
- package/templates/native-framework/common/webpack.config.js +67 -0
- package/templates/native-framework/plain/screen.ts +102 -0
- package/templates/native-framework/react/screen.ts +83 -0
- package/templates/native-framework/solid/screen.ts +111 -0
- package/templates/native-framework/svelte/Welcome.svelte +26 -0
- package/templates/native-framework/svelte/screen.ts +14 -0
- package/templates/native-framework/svelte-tooling/svelte.config.js +20 -0
- package/templates/nuxt/app/mavis.ts +2 -84
- package/templates/vite/src/mavis.ts +2 -84
- package/templates/macos/scripts/portable/emit-swift.mjs +0 -1287
- package/templates/macos/scripts/portable/emit-vue.mjs +0 -615
- package/templates/macos/scripts/portable/index.mjs +0 -95
- package/templates/macos/scripts/portable/model.mjs +0 -1441
- package/templates/macos/scripts/portable/program.mjs +0 -163
package/src/portability.mjs
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { lstat, readFile, readdir, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
2
3
|
import { normalizeConfig } from './presets.mjs'
|
|
3
|
-
import { dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
4
|
+
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
5
|
+
import { pathToFileURL } from 'node:url'
|
|
4
6
|
import ts from 'typescript'
|
|
5
7
|
import { parse } from '@vue/compiler-sfc'
|
|
6
8
|
import { components, composables } from './shared-api.mjs'
|
|
9
|
+
import { checkShared } from '@getcortexlabs/mavis-compiler'
|
|
7
10
|
|
|
8
11
|
const rendererImports = new Set(['@getcortexlabs/mavis-web', '@getcortexlabs/mavis/vue'])
|
|
9
12
|
const sharedNames = new Set([...components, ...composables])
|
|
@@ -292,6 +295,88 @@ export function inspectSource(source, filename, { allowImports = [] } = {}) {
|
|
|
292
295
|
return { diagnostics, edits, imports }
|
|
293
296
|
}
|
|
294
297
|
|
|
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
|
+
|
|
295
380
|
async function projectConfig(root) {
|
|
296
381
|
try {
|
|
297
382
|
return normalizeConfig(JSON.parse(await readFile(join(root, 'mavis.config.json'), 'utf8')))
|
|
@@ -305,9 +390,17 @@ async function projectConfig(root) {
|
|
|
305
390
|
export async function checkPortability(root = process.cwd(), options = {}) {
|
|
306
391
|
root = resolve(root)
|
|
307
392
|
const config = await projectConfig(root)
|
|
308
|
-
if (config.
|
|
393
|
+
if (config.framework && config.framework !== 'vue')
|
|
309
394
|
throw new Error(
|
|
310
|
-
'
|
|
395
|
+
'This source audit applies to shared Vue and SwiftUI sources. Direct native starters use their framework typecheck and platform builds.',
|
|
396
|
+
)
|
|
397
|
+
if (config.target === 'desktop' && options.fixImports)
|
|
398
|
+
throw new Error(
|
|
399
|
+
'Migrate imports in the Web/mobile project before desktop adoption. Generated desktop hosts require the declared component subset; no files changed.',
|
|
400
|
+
)
|
|
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.',
|
|
311
404
|
)
|
|
312
405
|
const roots = options.path
|
|
313
406
|
? [options.path]
|
|
@@ -321,6 +414,7 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
321
414
|
)
|
|
322
415
|
throw new Error('Configure at least one source directory in portability.roots.')
|
|
323
416
|
const files = new Map(),
|
|
417
|
+
compiled = new Map(),
|
|
324
418
|
diagnostics = [],
|
|
325
419
|
fixes = []
|
|
326
420
|
const load = async (file, dependency = false) => {
|
|
@@ -338,6 +432,9 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
338
432
|
if (dependency) return
|
|
339
433
|
for (const item of (await readdir(file)).sort())
|
|
340
434
|
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'))
|
|
341
438
|
} else if (sourceExtensions.includes(extname(file)) && !files.has(file)) {
|
|
342
439
|
const source = await readFile(file, 'utf8')
|
|
343
440
|
const result = inspectSource(source, relative(root, file), config.portability)
|
|
@@ -402,8 +499,28 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
402
499
|
}
|
|
403
500
|
await load(file)
|
|
404
501
|
}
|
|
405
|
-
if (!files.size)
|
|
502
|
+
if (!files.size && !compiled.size)
|
|
406
503
|
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
|
+
)
|
|
407
524
|
if (options.fixImports) {
|
|
408
525
|
if (config.portability?.alias !== '#mavis')
|
|
409
526
|
throw new Error(
|
|
@@ -450,7 +567,7 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
450
567
|
throw new Error(`Source changed during migration: ${fix.file}`)
|
|
451
568
|
}
|
|
452
569
|
for (const fix of fixes) await writeFile(join(root, fix.file), fix.after)
|
|
453
|
-
const after = await checkPortability(root, { path: options.path })
|
|
570
|
+
const after = await checkPortability(root, { path: options.path, core: options.core })
|
|
454
571
|
return { ...after, fixes, written: true }
|
|
455
572
|
}
|
|
456
573
|
}
|
|
@@ -459,6 +576,7 @@ export async function checkPortability(root = process.cwd(), options = {}) {
|
|
|
459
576
|
diagnostics: diagnostics.sort(
|
|
460
577
|
(a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.column - b.column,
|
|
461
578
|
),
|
|
579
|
+
macos,
|
|
462
580
|
fixes,
|
|
463
581
|
written: false,
|
|
464
582
|
}
|
package/src/scaffold.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs'
|
|
2
2
|
import { mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, writeFile } from 'node:fs/promises'
|
|
3
|
-
import { dirname, join, relative, resolve, sep } from 'node:path'
|
|
3
|
+
import { dirname, join, posix, relative, resolve, sep } from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
import { directoryReadme } from './reference.mjs'
|
|
6
6
|
import { configOf, resolvePreset, versions as v } from './presets.mjs'
|
|
@@ -9,13 +9,24 @@ import { packageCommands, runInstall } from './package-manager.mjs'
|
|
|
9
9
|
const templates = fileURLToPath(new URL('../templates/', import.meta.url))
|
|
10
10
|
const json = (value) => `${JSON.stringify(value, null, 2)}\n`
|
|
11
11
|
|
|
12
|
-
async function copyTemplate(files, source, destination, replacements) {
|
|
12
|
+
export async function copyTemplate(files, source, destination, replacements) {
|
|
13
13
|
for (const entry of await readdir(join(templates, source), { withFileTypes: true })) {
|
|
14
|
-
const from = join(source, entry.name),
|
|
15
|
-
to = join(
|
|
14
|
+
const from = posix.join(source, entry.name),
|
|
15
|
+
to = posix.join(
|
|
16
|
+
destination.replaceAll('\\', '/'),
|
|
17
|
+
entry.name.replace(/^_gitignore$/, '.gitignore'),
|
|
18
|
+
)
|
|
16
19
|
if (entry.isDirectory()) await copyTemplate(files, from, to, replacements)
|
|
20
|
+
// A font is copied as it is: its bytes, not text.
|
|
21
|
+
else if (/\.ttf$/.test(entry.name)) files.set(to, await readFile(join(templates, from)))
|
|
17
22
|
else {
|
|
18
23
|
let content = await readFile(join(templates, from), 'utf8')
|
|
24
|
+
// This adapter lives beside shared/ in the template, beside its host entry when generated.
|
|
25
|
+
if (from === 'directory/host/directory-storage.ts')
|
|
26
|
+
content = content.replace(
|
|
27
|
+
"'../shared/directory-store'",
|
|
28
|
+
"'__MAVIS_SHARED__/directory-store'",
|
|
29
|
+
)
|
|
19
30
|
for (const [key, value] of Object.entries(replacements))
|
|
20
31
|
content = content.replaceAll(`__MAVIS_${key}__`, value)
|
|
21
32
|
files.set(to, content)
|
|
@@ -26,6 +37,14 @@ async function copyTemplate(files, source, destination, replacements) {
|
|
|
26
37
|
export async function projectFiles(options) {
|
|
27
38
|
const preset = resolvePreset(options)
|
|
28
39
|
const files = new Map()
|
|
40
|
+
if (preset.framework !== 'vue') {
|
|
41
|
+
const { nativeFrameworkFiles } = await import('./native-framework.mjs')
|
|
42
|
+
return nativeFrameworkFiles(preset, copyTemplate)
|
|
43
|
+
}
|
|
44
|
+
if (preset.target === 'desktop') {
|
|
45
|
+
const { desktopFiles } = await import('./desktop.mjs')
|
|
46
|
+
return desktopFiles(preset, copyTemplate, projectFiles)
|
|
47
|
+
}
|
|
29
48
|
if (preset.target === 'macos') {
|
|
30
49
|
const { macosFiles } = await import('./macos.mjs')
|
|
31
50
|
return macosFiles(preset, files, copyTemplate)
|
|
@@ -78,7 +97,15 @@ export async function projectFiles(options) {
|
|
|
78
97
|
...replacements,
|
|
79
98
|
SHARED: '#shared-ui',
|
|
80
99
|
})
|
|
81
|
-
if (directory)
|
|
100
|
+
if (directory) {
|
|
101
|
+
await copyTemplate(files, `directory/${preset.web}`, webDir, replacements)
|
|
102
|
+
await copyTemplate(
|
|
103
|
+
files,
|
|
104
|
+
'directory/host',
|
|
105
|
+
join(webDir, preset.web === 'nuxt' ? 'app/utils' : 'src'),
|
|
106
|
+
replacements,
|
|
107
|
+
)
|
|
108
|
+
}
|
|
82
109
|
const scripts =
|
|
83
110
|
preset.web === 'vite'
|
|
84
111
|
? { dev: 'vite', build: 'vue-tsc --noEmit && vite build', preview: 'vite preview' }
|
|
@@ -122,7 +149,10 @@ export async function projectFiles(options) {
|
|
|
122
149
|
SHARED_ROOT: shared ? '../../shared' : './src/shared',
|
|
123
150
|
SHARED: '#shared-ui',
|
|
124
151
|
})
|
|
125
|
-
if (directory)
|
|
152
|
+
if (directory) {
|
|
153
|
+
await copyTemplate(files, 'directory/mobile', mobileDir, replacements)
|
|
154
|
+
await copyTemplate(files, 'directory/host', join(mobileDir, 'src'), replacements)
|
|
155
|
+
}
|
|
126
156
|
files.set(
|
|
127
157
|
join(mobileDir, 'package.json'),
|
|
128
158
|
json({
|
|
@@ -256,7 +286,14 @@ export async function projectFiles(options) {
|
|
|
256
286
|
].join('\n\n') + '\n',
|
|
257
287
|
)
|
|
258
288
|
if (directory) files.set('README.md', directoryReadme(preset, sharedDir))
|
|
259
|
-
return {
|
|
289
|
+
return {
|
|
290
|
+
preset,
|
|
291
|
+
files: new Map(
|
|
292
|
+
[...files]
|
|
293
|
+
.map(([path, content]) => [path.replaceAll('\\', '/'), content])
|
|
294
|
+
.sort(([a], [b]) => a.localeCompare(b)),
|
|
295
|
+
),
|
|
296
|
+
}
|
|
260
297
|
}
|
|
261
298
|
|
|
262
299
|
export async function scaffold(options, cwd = process.cwd()) {
|
|
@@ -304,10 +341,21 @@ export async function scaffold(options, cwd = process.cwd()) {
|
|
|
304
341
|
export async function installProject(plan, { signal, onProgress } = {}) {
|
|
305
342
|
// The NativeScript app has its own dependency tree next to the root project.
|
|
306
343
|
const directories =
|
|
307
|
-
plan.preset.target === '
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
344
|
+
plan.preset.target === 'desktop'
|
|
345
|
+
? [
|
|
346
|
+
'',
|
|
347
|
+
...(plan.preset.targets.includes('native') ? ['apps/mobile'] : []),
|
|
348
|
+
...(plan.preset.targets.includes('macos') && process.platform === 'darwin'
|
|
349
|
+
? ['apps/macos']
|
|
350
|
+
: []),
|
|
351
|
+
...(plan.preset.targets.includes('windows') && process.platform === 'win32'
|
|
352
|
+
? ['apps/windows']
|
|
353
|
+
: []),
|
|
354
|
+
]
|
|
355
|
+
: plan.preset.target === 'both' ||
|
|
356
|
+
(plan.preset.target === 'macos' && plan.preset.targets.includes('native'))
|
|
357
|
+
? ['', 'apps/mobile']
|
|
358
|
+
: ['']
|
|
311
359
|
for (const directory of directories) {
|
|
312
360
|
const cwd = join(plan.destination, directory)
|
|
313
361
|
onProgress?.(directory || '.')
|
package/src/ui.mjs
CHANGED
|
@@ -28,22 +28,40 @@ export function validateDestination(name, cwd = process.cwd()) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export function projectSummary(preset, install) {
|
|
31
|
+
if (preset.target === 'desktop')
|
|
32
|
+
return [
|
|
33
|
+
`Project ${preset.name}`,
|
|
34
|
+
`Targets ${targetLabel(preset.targets)} · EXPERIMENTAL`,
|
|
35
|
+
`Hosts ${preset.targets.map((target) => (target === 'macos' ? 'NativeScript AppKit' : target === 'windows' ? 'NativeScript XAML Islands' : target === 'native' ? 'NativeScript iOS + Android' : preset.web === 'nuxt' ? 'Nuxt' : 'Vue + Vite')).join(' · ')}`,
|
|
36
|
+
'Authoring Shared Vue screens · native desktop component subset',
|
|
37
|
+
...status(preset),
|
|
38
|
+
`Framework ${catalog.frameworks[preset.framework].label}`,
|
|
39
|
+
`Example ${catalog.examples[preset.example].label}`,
|
|
40
|
+
`Theme ${preset.theme}`,
|
|
41
|
+
`Packages ${preset.packageManager} · ${install ? 'install for this OS now' : 'install later'}`,
|
|
42
|
+
].join('\n')
|
|
43
|
+
|
|
31
44
|
if (preset.target === 'macos')
|
|
32
45
|
return [
|
|
33
46
|
`Project ${preset.name}`,
|
|
34
47
|
`Targets ${targetLabel(preset.targets)} · EXPERIMENTAL`,
|
|
35
48
|
`Hosts ${[
|
|
36
|
-
preset.targets.includes('web') &&
|
|
49
|
+
preset.targets.includes('web') &&
|
|
50
|
+
(preset.web === 'nuxt' ? `Nuxt · ${preset.rendering.toUpperCase()}` : 'Vue + Vite'),
|
|
37
51
|
preset.targets.includes('native') && 'NativeScript iOS + Android',
|
|
38
52
|
preset.targets.includes('macos') && 'SwiftUI macOS',
|
|
39
53
|
]
|
|
40
54
|
.filter(Boolean)
|
|
41
55
|
.join(' · ')}`,
|
|
42
|
-
|
|
56
|
+
preset.authoring === 'vue'
|
|
57
|
+
? 'Authoring Shared Vue (shared/*.vue), compiled to SwiftUI for Mac'
|
|
58
|
+
: 'Authoring Shared TSX (shared/*.lite.tsx), compiled for each target',
|
|
43
59
|
...status(preset),
|
|
44
|
-
preset.example === '
|
|
45
|
-
? 'Example
|
|
46
|
-
:
|
|
60
|
+
preset.example === 'directory'
|
|
61
|
+
? 'Example Search, details and editing · shared/Directory.vue'
|
|
62
|
+
: preset.example === 'tasks'
|
|
63
|
+
? 'Example Tasks · list and detail, forms, shortcuts and motion · shared/Tasks.lite.tsx'
|
|
64
|
+
: 'Example Basic welcome · shared/Welcome.lite.tsx',
|
|
47
65
|
`Theme ${preset.theme === 'midnight' ? 'Midnight · dark' : 'Mavis · light'}`,
|
|
48
66
|
`Packages ${preset.packageManager} · ${install ? 'install now' : 'install later'}`,
|
|
49
67
|
].join('\n')
|
|
@@ -59,8 +77,14 @@ export function projectSummary(preset, install) {
|
|
|
59
77
|
}
|
|
60
78
|
|
|
61
79
|
export function sharedEntry(preset) {
|
|
80
|
+
if (preset.framework !== 'vue')
|
|
81
|
+
return preset.framework === 'svelte' ? 'src/Welcome.svelte' : 'src/screen.ts'
|
|
82
|
+
if (preset.target === 'desktop')
|
|
83
|
+
return `shared/${preset.example === 'directory' ? 'Directory' : 'Welcome'}.vue`
|
|
62
84
|
if (preset.target === 'macos')
|
|
63
|
-
return
|
|
85
|
+
return preset.example === 'directory'
|
|
86
|
+
? 'shared/Directory.vue'
|
|
87
|
+
: `shared/${preset.example === 'tasks' ? 'Tasks' : 'Welcome'}.lite.tsx`
|
|
64
88
|
const directory =
|
|
65
89
|
preset.target === 'both' ? 'shared' : preset.web === 'nuxt' ? 'app/shared' : 'src/shared'
|
|
66
90
|
return `${directory}/${preset.example === 'directory' ? 'Directory' : 'Welcome'}.vue`
|
|
@@ -68,6 +92,16 @@ export function sharedEntry(preset) {
|
|
|
68
92
|
|
|
69
93
|
export function nextSteps(preset, installed = false) {
|
|
70
94
|
const commands = packageCommands(preset.packageManager)
|
|
95
|
+
if (preset.target === 'desktop')
|
|
96
|
+
return [
|
|
97
|
+
`cd ${preset.name}`,
|
|
98
|
+
...(!installed ? [commands.run('install:apps')] : []),
|
|
99
|
+
...(preset.targets.includes('web') ? [commands.run('dev:web')] : []),
|
|
100
|
+
...(preset.targets.includes('native') ? [commands.run('ios'), commands.run('android')] : []),
|
|
101
|
+
...(preset.targets.includes('macos') ? [commands.run('macos') + ' # on macOS'] : []),
|
|
102
|
+
...(preset.targets.includes('windows') ? [commands.run('windows') + ' # on Windows'] : []),
|
|
103
|
+
'Run --doctor on each target OS. See README for the desktop component subset.',
|
|
104
|
+
].join('\n')
|
|
71
105
|
if (preset.target === 'macos') {
|
|
72
106
|
const has = (target) => preset.targets.includes(target)
|
|
73
107
|
return [
|
|
@@ -163,10 +197,25 @@ export async function wizard(initial, signal, io = prompts, check = checkPackage
|
|
|
163
197
|
fallback: ['web'],
|
|
164
198
|
options: choices(catalog.targets),
|
|
165
199
|
},
|
|
200
|
+
{
|
|
201
|
+
key: 'macosRuntime',
|
|
202
|
+
message: 'Choose the Mac runtime',
|
|
203
|
+
when: () => targets().includes('macos'),
|
|
204
|
+
fallback: 'appkit',
|
|
205
|
+
options: () =>
|
|
206
|
+
choices(catalog.macosRuntimes, targets().includes('windows') ? ['appkit'] : undefined),
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
key: 'framework',
|
|
210
|
+
message: 'Choose the framework for iOS and Android',
|
|
211
|
+
when: () => targets().length === 1 && targets()[0] === 'native',
|
|
212
|
+
fallback: 'vue',
|
|
213
|
+
options: choices(catalog.frameworks),
|
|
214
|
+
},
|
|
166
215
|
{
|
|
167
216
|
key: 'web',
|
|
168
217
|
message: 'Choose your web setup',
|
|
169
|
-
when: () => targets().includes('web')
|
|
218
|
+
when: () => targets().includes('web'),
|
|
170
219
|
// A --rendering flag leaves only the hosts that can serve it.
|
|
171
220
|
options: choices(
|
|
172
221
|
catalog.hosts,
|
|
@@ -192,10 +241,18 @@ export async function wizard(initial, signal, io = prompts, check = checkPackage
|
|
|
192
241
|
options: () =>
|
|
193
242
|
choices(
|
|
194
243
|
catalog.examples,
|
|
195
|
-
Object.keys(catalog.examples).filter(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
244
|
+
Object.keys(catalog.examples).filter(
|
|
245
|
+
(example) =>
|
|
246
|
+
catalog.examples[example].authoring.includes(
|
|
247
|
+
answers.framework && answers.framework !== 'vue'
|
|
248
|
+
? 'native'
|
|
249
|
+
: targets().includes('macos') && answers.macosRuntime === 'swiftui'
|
|
250
|
+
? 'mitosis'
|
|
251
|
+
: 'vue',
|
|
252
|
+
) ||
|
|
253
|
+
(targets().includes('macos') &&
|
|
254
|
+
answers.macosRuntime === 'swiftui' &&
|
|
255
|
+
catalog.examples[example].portableAuthoring),
|
|
199
256
|
),
|
|
200
257
|
),
|
|
201
258
|
},
|
|
@@ -316,7 +373,7 @@ export async function wizard(initial, signal, io = prompts, check = checkPackage
|
|
|
316
373
|
}
|
|
317
374
|
if (value.includes('macos'))
|
|
318
375
|
io.log.message(
|
|
319
|
-
`
|
|
376
|
+
`The Mac app defaults to NativeScript AppKit with shared Vue. SwiftUI remains available as a separate runtime choice.`,
|
|
320
377
|
)
|
|
321
378
|
}
|
|
322
379
|
answers[step.key] = value
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rafael Augusto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { build } from 'esbuild'
|
|
2
|
+
import { parse, compileScript } from '@vue/compiler-sfc'
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import { createRequire } from 'node:module'
|
|
5
|
+
import { dirname, resolve } from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
import { createHash } from 'node:crypto'
|
|
8
|
+
|
|
9
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
const require = createRequire(import.meta.url)
|
|
11
|
+
const jolt = dirname(require.resolve('@rafaelaugusto/jolt/package.json'))
|
|
12
|
+
const version = JSON.parse(await readFile(resolve(jolt, 'package.json'), 'utf8')).version
|
|
13
|
+
if (version !== '0.1.0-rc.17')
|
|
14
|
+
throw new Error(`This private adapter requires Jolt RC.17, found ${version}`)
|
|
15
|
+
await build({
|
|
16
|
+
entryPoints: [resolve(here, 'src/main.ts')],
|
|
17
|
+
outfile: resolve(here, 'dist/main.mjs'),
|
|
18
|
+
bundle: true,
|
|
19
|
+
packages: undefined,
|
|
20
|
+
external: ['@nativescript/windows-napi'],
|
|
21
|
+
nodePaths: [resolve(here, 'node_modules')],
|
|
22
|
+
platform: 'node',
|
|
23
|
+
target: 'node22',
|
|
24
|
+
format: 'esm',
|
|
25
|
+
sourcemap: true,
|
|
26
|
+
define: {
|
|
27
|
+
'process.env.NODE_ENV': '"production"',
|
|
28
|
+
__VUE_OPTIONS_API__: 'true',
|
|
29
|
+
__VUE_PROD_DEVTOOLS__: 'false',
|
|
30
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
|
|
31
|
+
},
|
|
32
|
+
alias: {
|
|
33
|
+
'#mavis': resolve(here, 'src/components.ts'),
|
|
34
|
+
'#shared-ui': resolve(here, '__MAVIS_SHARED_ROOT__'),
|
|
35
|
+
'#desktop-host': resolve(here, 'src/host.mjs'),
|
|
36
|
+
vue: resolve(here, 'node_modules/vue/dist/vue.runtime.esm-bundler.js'),
|
|
37
|
+
'vue-router': resolve(here, 'node_modules/vue-router/dist/vue-router.mjs'),
|
|
38
|
+
// Private, version-checked experiment. No public AppKit API is claimed.
|
|
39
|
+
'#jolt-track': resolve(jolt, 'dist/core/track.js'),
|
|
40
|
+
'#jolt-transition': resolve(jolt, 'dist/core/transition.js'),
|
|
41
|
+
},
|
|
42
|
+
plugins: [
|
|
43
|
+
{
|
|
44
|
+
name: 'shared-vue-screens',
|
|
45
|
+
setup(build) {
|
|
46
|
+
build.onLoad({ filter: /\.vue$/ }, async ({ path }) => {
|
|
47
|
+
const source = await readFile(path, 'utf8')
|
|
48
|
+
const { descriptor, errors } = parse(source, { filename: path })
|
|
49
|
+
if (errors.length) throw errors[0]
|
|
50
|
+
const id = createHash('sha256').update(path).digest('hex').slice(0, 8)
|
|
51
|
+
const script = compileScript(descriptor, { id, inlineTemplate: true })
|
|
52
|
+
return { contents: script.content, loader: 'ts', resolveDir: dirname(path) }
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
})
|
|
58
|
+
console.log('Built __MAVIS_NAME__ from shared Vue screens.')
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defineComponent, h, inject } from 'vue'
|
|
2
|
+
import { routerKey } from 'vue-router'
|
|
3
|
+
|
|
4
|
+
function component(name: string, tag: string) {
|
|
5
|
+
return defineComponent({
|
|
6
|
+
name,
|
|
7
|
+
inheritAttrs: false,
|
|
8
|
+
setup(_props, { attrs, slots }) {
|
|
9
|
+
return () => h(tag, attrs, slots.default?.())
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
function action(name: string, tag: string) {
|
|
14
|
+
return defineComponent({
|
|
15
|
+
name,
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
setup(_props, { attrs, slots }) {
|
|
18
|
+
const router = inject(routerKey, null)
|
|
19
|
+
return () =>
|
|
20
|
+
h(
|
|
21
|
+
tag,
|
|
22
|
+
{
|
|
23
|
+
...attrs,
|
|
24
|
+
onClick: () => {
|
|
25
|
+
if (attrs.disabled || attrs.loading) return
|
|
26
|
+
const listeners = Array.isArray(attrs.onClick) ? attrs.onClick : [attrs.onClick]
|
|
27
|
+
for (const listener of listeners) if (typeof listener === 'function') listener()
|
|
28
|
+
if (typeof attrs.href === 'string') void router?.push(attrs.href)
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
slots.default?.(),
|
|
32
|
+
)
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
export const MScreen = component('MScreen', 'screen')
|
|
37
|
+
export const MColumn = component('MColumn', 'column')
|
|
38
|
+
export const MRow = component('MRow', 'row')
|
|
39
|
+
export const MGrid = component('MGrid', 'grid')
|
|
40
|
+
export const MText = component('MText', 'text')
|
|
41
|
+
export const MInput = component('MInput', 'input')
|
|
42
|
+
export const MReveal = component('MReveal', 'reveal')
|
|
43
|
+
export const MButton = action('MButton', 'button')
|
|
44
|
+
export const MLink = action('MLink', 'link')
|
|
45
|
+
export const MCard = action('MCard', 'card')
|
|
46
|
+
function message(name: string) {
|
|
47
|
+
return defineComponent({
|
|
48
|
+
name,
|
|
49
|
+
inheritAttrs: false,
|
|
50
|
+
setup(_props, { attrs }) {
|
|
51
|
+
return () =>
|
|
52
|
+
h('column', { id: attrs.id, padding: 'md', gap: 'sm' }, [
|
|
53
|
+
h('text', { variant: 'heading', tone: attrs.tone }, String(attrs.title ?? '')),
|
|
54
|
+
h('text', { tone: 'muted' }, String(attrs.description ?? '')),
|
|
55
|
+
])
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
export const MAlert = message('MAlert')
|
|
60
|
+
export const MEmptyState = message('MEmptyState')
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The deliberately bounded contract shared by adoption diagnostics and both native hosts. */
|
|
2
|
+
export const desktopComponents = Object.freeze({
|
|
3
|
+
MScreen: { tag: 'screen', props: ['scroll'] },
|
|
4
|
+
MColumn: { tag: 'column', props: ['padding', 'gap'] },
|
|
5
|
+
MRow: { tag: 'row', props: ['padding', 'gap'] },
|
|
6
|
+
MGrid: { tag: 'grid', props: ['minColumnWidth', 'gap'] },
|
|
7
|
+
MText: { tag: 'text', props: ['text', 'as', 'variant', 'tone'] },
|
|
8
|
+
MInput: {
|
|
9
|
+
tag: 'input',
|
|
10
|
+
props: [
|
|
11
|
+
'modelValue',
|
|
12
|
+
'label',
|
|
13
|
+
'placeholder',
|
|
14
|
+
'readonly',
|
|
15
|
+
'disabled',
|
|
16
|
+
'onUpdate:modelValue',
|
|
17
|
+
'onSubmit',
|
|
18
|
+
'onEscape',
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
MReveal: { tag: 'reveal', props: ['show'] },
|
|
22
|
+
MButton: {
|
|
23
|
+
tag: 'button',
|
|
24
|
+
props: ['href', 'text', 'loading', 'loadingText', 'disabled', 'onClick'],
|
|
25
|
+
macos: ['shortcut'],
|
|
26
|
+
},
|
|
27
|
+
MLink: { tag: 'link', props: ['href', 'text', 'disabled', 'onClick'] },
|
|
28
|
+
MCard: { tag: 'card', props: ['href', 'padding', 'gap', 'onClick', 'disabled'] },
|
|
29
|
+
MAlert: { tag: null, props: ['title', 'description', 'tone'] },
|
|
30
|
+
MEmptyState: { tag: null, props: ['title', 'description'] },
|
|
31
|
+
})
|
|
32
|
+
export function nativeProps(kind, target) {
|
|
33
|
+
const component = Object.values(desktopComponents).find((component) => component.tag === kind)
|
|
34
|
+
return ['id', 'accessibilityLabel', ...(component?.props ?? []), ...(component?.[target] ?? [])]
|
|
35
|
+
}
|