@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.
Files changed (80) hide show
  1. package/README.md +44 -7
  2. package/package.json +4 -2
  3. package/src/adapters.mjs +56 -20
  4. package/src/add-desktop.mjs +308 -0
  5. package/src/add-macos.mjs +386 -0
  6. package/src/capabilities.mjs +352 -85
  7. package/src/cli.mjs +181 -9
  8. package/src/desktop.mjs +155 -0
  9. package/src/doctor.mjs +181 -18
  10. package/src/macos-capabilities.generated.mjs +4190 -0
  11. package/src/macos.mjs +147 -29
  12. package/src/migrate-directory.mjs +121 -0
  13. package/src/native-framework.mjs +144 -0
  14. package/src/portability.mjs +123 -5
  15. package/src/scaffold.mjs +59 -11
  16. package/src/ui.mjs +69 -12
  17. package/templates/desktop/common/LICENSE +21 -0
  18. package/templates/desktop/common/build.mjs +58 -0
  19. package/templates/desktop/common/src/components.ts +60 -0
  20. package/templates/desktop/common/src/contract.mjs +35 -0
  21. package/templates/desktop/common/src/renderer.ts +76 -0
  22. package/templates/desktop/common/src/storage.ts +29 -0
  23. package/templates/desktop/directory/main.ts +35 -0
  24. package/templates/desktop/macos/launch.mjs +6 -0
  25. package/templates/desktop/macos/package.mjs +114 -0
  26. package/templates/desktop/macos/src/host.mjs +468 -0
  27. package/templates/desktop/macos/src/motion.mjs +51 -0
  28. package/templates/desktop/welcome/Welcome.vue +56 -0
  29. package/templates/desktop/welcome/main.ts +24 -0
  30. package/templates/desktop/windows/NativeScript-LICENSE +19 -0
  31. package/templates/desktop/windows/launch.mjs +16 -0
  32. package/templates/desktop/windows/package.mjs +54 -0
  33. package/templates/desktop/windows/prepare-host.mjs +73 -0
  34. package/templates/desktop/windows/src/host.mjs +277 -0
  35. package/templates/directory/host/directory-storage.ts +78 -0
  36. package/templates/directory/macos/DirectoryStorage.swift +68 -0
  37. package/templates/directory/mobile/src/app.ts +11 -8
  38. package/templates/directory/nuxt/app/plugins/mavis.ts +11 -8
  39. package/templates/directory/shared/Edit.vue +8 -5
  40. package/templates/directory/shared/directory-store.ts +42 -46
  41. package/templates/directory/vite/src/main.ts +11 -8
  42. package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +2 -2
  43. package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +2 -2
  44. package/templates/macos/examples/tasks/shared/types.ts +1 -0
  45. package/templates/macos/mobile/src/App.vue +4 -2
  46. package/templates/macos/native/Package.swift +3 -1
  47. package/templates/macos/native/Sources/MavisDesktop/App.swift +26 -11
  48. package/templates/macos/native/Sources/MavisDesktop/Fonts/LICENSE +45 -0
  49. package/templates/macos/native/Sources/MavisDesktop/Fonts/lucide.ttf +0 -0
  50. package/templates/macos/scripts/generate.mjs +3 -26
  51. package/templates/macos/scripts/macos-manifest.mjs +33 -0
  52. package/templates/macos/scripts/macos.mjs +20 -18
  53. package/templates/macos/web/index.html +1 -1
  54. package/templates/macos/web/src/main.js +176 -3
  55. package/templates/macos/web/src/mavis.js +2 -0
  56. package/templates/macos/web/src/style.css +2 -1
  57. package/templates/macos/web/vite.config.mjs +12 -1
  58. package/templates/migrations/directory-rc13.json +36 -0
  59. package/templates/mobile/src/mavis.ts +2 -82
  60. package/templates/mobile/webpack.config.js +4 -0
  61. package/templates/native-framework/angular/screen.ts +84 -0
  62. package/templates/native-framework/common/nativescript.config.ts +6 -0
  63. package/templates/native-framework/common/src/app.ts +5 -0
  64. package/templates/native-framework/common/src/model.ts +40 -0
  65. package/templates/native-framework/common/src/references.d.ts +8 -0
  66. package/templates/native-framework/common/tsconfig.json +16 -0
  67. package/templates/native-framework/common/webpack.config.js +67 -0
  68. package/templates/native-framework/plain/screen.ts +102 -0
  69. package/templates/native-framework/react/screen.ts +83 -0
  70. package/templates/native-framework/solid/screen.ts +111 -0
  71. package/templates/native-framework/svelte/Welcome.svelte +26 -0
  72. package/templates/native-framework/svelte/screen.ts +14 -0
  73. package/templates/native-framework/svelte-tooling/svelte.config.js +20 -0
  74. package/templates/nuxt/app/mavis.ts +2 -84
  75. package/templates/vite/src/mavis.ts +2 -84
  76. package/templates/macos/scripts/portable/emit-swift.mjs +0 -1287
  77. package/templates/macos/scripts/portable/emit-vue.mjs +0 -615
  78. package/templates/macos/scripts/portable/index.mjs +0 -95
  79. package/templates/macos/scripts/portable/model.mjs +0 -1441
  80. package/templates/macos/scripts/portable/program.mjs +0 -163
@@ -1,95 +0,0 @@
1
- import { createHash } from 'node:crypto'
2
- import { readdir, readFile } from 'node:fs/promises'
3
- import { join } from 'node:path'
4
- import { createProgram, prelude } from './program.mjs'
5
- import { buildModel, PortableError } from './model.mjs'
6
- import {
7
- emitVue,
8
- emitVueNativeRuntime,
9
- emitVueRuntime,
10
- emitVueTypes,
11
- usesRuntime,
12
- } from './emit-vue.mjs'
13
- import { SwiftEmitter, runtime, themeTokens } from './emit-swift.mjs'
14
-
15
- export { PortableError }
16
- export const compilerName = 'Mavis portable compiler (experimental)'
17
-
18
- const sha = (text) => createHash('sha256').update(text).digest('hex')
19
-
20
- /** Component (Name.lite.tsx) and type (name.ts) files from a project's shared folder. */
21
- export async function readShared(projectRoot) {
22
- const files = new Map()
23
- for (const name of (await readdir(join(projectRoot, 'shared'))).sort())
24
- if (/\.lite\.tsx$/.test(name) || (/\.ts$/.test(name) && !/\.d\.ts$/.test(name)))
25
- files.set(`shared/${name}`, await readFile(join(projectRoot, 'shared', name), 'utf8'))
26
- return files
27
- }
28
-
29
- /**
30
- * Checks the shared sources and produces Vue for the Web (vue) and NativeScript (native) and
31
- * SwiftUI files. Nothing is written
32
- * here; callers replace generated files only after the whole project compiled.
33
- *
34
- * files: Map<'shared/Name.lite.tsx' | 'shared/types.ts', source text>
35
- */
36
- export async function compileProject(files, { theme = 'mavis', root = 'Welcome', namespace } = {}) {
37
- const core = await import('@getcortexlabs/mavis-core')
38
- if (!['mavis', 'midnight'].includes(theme)) throw new PortableError('Unknown starter theme.')
39
- const tokenTheme = core[theme]
40
- for (const path of files.keys())
41
- if (!/^shared\/([A-Z][A-Za-z0-9]*\.lite\.tsx|[a-z][A-Za-z0-9]*\.ts)$/.test(path))
42
- throw new PortableError(
43
- `${path}: Shared files are Name.lite.tsx components or lowercase .ts type files.`,
44
- )
45
- const program = createProgram(files, tokenTheme)
46
- if (program.diagnostics.length) throw new PortableError(program.diagnostics.join('\n'))
47
- const model = buildModel(program, [...files.keys()].sort())
48
- const names = new Set(model.components.map((component) => component.name))
49
- if (!names.has(root))
50
- throw new PortableError(`shared/${root}.lite.tsx: The root component ${root} is missing.`)
51
- for (const record of model.records)
52
- if (names.has(record.name))
53
- throw new PortableError(`${record.name} is both a record type and a component; rename one.`)
54
-
55
- const header = (path) =>
56
- `Generated by the ${compilerName} from ${path} (sha256 ${sha(files.get(path))}). Do not edit.`
57
- const typesHeader = `Generated by the ${compilerName}; types from ${[...files.keys()].sort().join(', ')}. Do not edit.`
58
- const vue = new Map()
59
- const native = new Map()
60
- const swift = new Map()
61
- const swiftEmitter = new SwiftEmitter(model)
62
- const { tokens, source: tokenSource, controls } = themeTokens(tokenTheme)
63
- for (const component of model.components) {
64
- vue.set(`${component.name}.vue`, emitVue(component, header(component.path)))
65
- native.set(
66
- `${component.name}.vue`,
67
- emitVue(component, header(component.path), { target: 'native' }),
68
- )
69
- swift.set(
70
- `${component.name}.swift`,
71
- swiftEmitter.component(component, tokens, header(component.path), namespace),
72
- )
73
- }
74
- vue.set('types.ts', emitVueTypes(model.records, typesHeader))
75
- native.set('types.ts', emitVueTypes(model.records, typesHeader))
76
- if (model.components.some((component) => usesRuntime(component.view)))
77
- vue.set('runtime.ts', emitVueRuntime(`Generated by the ${compilerName}. Do not edit.`))
78
- if (model.components.some((component) => usesRuntime(component.view, 'native')))
79
- native.set(
80
- 'runtime.ts',
81
- emitVueNativeRuntime(`Generated by the ${compilerName} for NativeScript. Do not edit.`),
82
- )
83
- swift.set('MavisTypes.swift', swiftEmitter.types(model.records, typesHeader, namespace))
84
- swift.set('MavisRuntime.swift', `// Generated by the ${compilerName}. Do not edit.\n${runtime}`)
85
- swift.set(
86
- 'MavisControls.swift',
87
- `// Generated by the ${compilerName} for the ${theme} theme. Do not edit.\n${controls}`,
88
- )
89
- swift.set(
90
- 'MavisTokens.swift',
91
- `// Generated by the ${compilerName} for the ${theme} theme. Do not edit.\n${tokenSource}`,
92
- )
93
- // Ambient types so editors check shared/ the same way (see tsconfig.json).
94
- return { model, vue, native, swift, environment: prelude(tokenTheme) }
95
- }