@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,163 +0,0 @@
1
- import ts from 'typescript'
2
-
3
- export const preludePath = 'shared/__mavis_prelude__.d.ts'
4
-
5
- export const keys = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']
6
-
7
- /** Each primitive's properties: how a value is checked and passed to both renderers. */
8
- export const primitives = {
9
- MColumn: { gap: 'space', padding: 'space', label: 'string', onKeyDown: 'key' },
10
- MRow: { gap: 'space', padding: 'space', label: 'string', onKeyDown: 'key' },
11
- MGrid: { gap: 'space', columns: 'number', minColumnWidth: 'number' },
12
- MCard: { gap: 'space', padding: 'space', tone: 'string', label: 'string', onClick: 'handler' },
13
- MText: { variant: 'string', tone: 'string' },
14
- MButton: {
15
- text: 'string',
16
- variant: 'string',
17
- disabled: 'boolean',
18
- onClick: 'handler',
19
- shortcut: 'shortcut',
20
- },
21
- MInput: {
22
- label: 'string',
23
- value: 'string',
24
- onChange: 'string-handler',
25
- placeholder: 'string',
26
- helperText: 'string',
27
- error: 'string',
28
- type: 'string',
29
- multiline: 'boolean',
30
- rows: 'number',
31
- maxLength: 'number',
32
- disabled: 'boolean',
33
- readonly: 'boolean',
34
- onSubmit: 'handler',
35
- onEscape: 'handler',
36
- ref: 'ref',
37
- },
38
- MCheckbox: {
39
- label: 'string',
40
- checked: 'boolean',
41
- onChange: 'boolean-handler',
42
- indeterminate: 'boolean',
43
- helperText: 'string',
44
- disabled: 'boolean',
45
- },
46
- MSelect: {
47
- label: 'string',
48
- value: 'optional-string',
49
- options: 'options',
50
- onChange: 'string-handler',
51
- placeholder: 'string',
52
- helperText: 'string',
53
- error: 'string',
54
- disabled: 'boolean',
55
- },
56
- }
57
-
58
- const union = (values) => values.map((value) => JSON.stringify(value)).join(' | ')
59
-
60
- /** Ambient declarations for the shared sources: Mavis primitives and the Mitosis authoring API. */
61
- export function prelude(theme) {
62
- return `declare namespace JSX {
63
- interface Element { readonly __mavisElement: true }
64
- interface ElementChildrenAttribute { children: {} }
65
- interface IntrinsicAttributes { key?: string | number }
66
- interface IntrinsicElements {}
67
- }
68
- type MavisSpace = ${union(Object.keys(theme.space))}
69
- type MavisVariant = ${union(Object.keys(theme.typography))}
70
- type MavisTone = ${union(Object.keys(theme.colors))}
71
- type MavisText = string | number | boolean
72
- type MavisKey = ${union(keys)}
73
- /** Command on Apple keyboards, Control elsewhere, with a letter or Enter. */
74
- type MavisShortcut = ${union([...'abcdefghijklmnopqrstuvwxyz'].map((letter) => `mod+${letter}`))} | 'mod+Enter'
75
- /** A field you can move focus to from an action: const titleRef = useRef<MavisFieldRef>(null). */
76
- interface MavisFieldRef { focus(): void; blur(): void }
77
- type SelectOption = { value: string; label: string; disabled?: boolean }
78
- type MavisStack = { gap?: MavisSpace; padding?: MavisSpace; label?: string; onKeyDown?: (key: MavisKey) => void; children?: unknown }
79
- declare function MColumn(props: MavisStack): JSX.Element
80
- declare function MRow(props: MavisStack): JSX.Element
81
- declare function MGrid(props: { gap?: MavisSpace; columns?: number; minColumnWidth?: number; children?: unknown }): JSX.Element
82
- declare function MCard(props: { gap?: MavisSpace; padding?: MavisSpace; tone?: MavisTone; label?: string; onClick?: () => void; children?: unknown }): JSX.Element
83
- declare function MText(props: { variant?: MavisVariant; tone?: MavisTone; children?: MavisText | MavisText[] }): JSX.Element
84
- declare function MButton(props: { text: string; variant?: 'primary' | 'secondary'; disabled?: boolean; onClick: () => void; shortcut?: MavisShortcut }): JSX.Element
85
- declare function MInput(props: { label: string; value: string; onChange: (value: string) => void; placeholder?: string; helperText?: string; error?: string; type?: 'text' | 'email' | 'password'; multiline?: boolean; rows?: number; maxLength?: number; disabled?: boolean; readonly?: boolean; onSubmit?: () => void; onEscape?: () => void; ref?: MavisFieldRef }): JSX.Element
86
- declare function MCheckbox(props: { label: string; checked: boolean; onChange: (checked: boolean) => void; indeterminate?: boolean; helperText?: string; disabled?: boolean }): JSX.Element
87
- declare function MSelect(props: { label: string; value: string | undefined; options: SelectOption[]; onChange: (value: string) => void; placeholder?: string; helperText?: string; error?: string; disabled?: boolean }): JSX.Element
88
- declare module '@builder.io/mitosis' {
89
- export function useStore<T extends object>(initial: T): T
90
- export function useRef<T>(initial?: T | null): T
91
- export function Show(props: { when: boolean; else?: JSX.Element; animate?: boolean; children?: unknown }): JSX.Element
92
- export function For<T>(props: { each: readonly T[]; animate?: boolean; children: (item: T, index: number) => JSX.Element }): JSX.Element
93
- }
94
- `
95
- }
96
-
97
- export const compilerOptions = {
98
- strict: true,
99
- noEmit: true,
100
- jsx: ts.JsxEmit.Preserve,
101
- target: ts.ScriptTarget.ES2022,
102
- module: ts.ModuleKind.ESNext,
103
- moduleResolution: ts.ModuleResolutionKind.Bundler,
104
- allowImportingTsExtensions: false,
105
- lib: ['lib.es2023.d.ts'],
106
- // Reading list[i] can miss in JavaScript; make that visible in the types too.
107
- noUncheckedIndexedAccess: true,
108
- types: [],
109
- }
110
-
111
- /**
112
- * Type-checks the shared sources in memory. `files` maps a project-relative path
113
- * (shared/Welcome.lite.tsx) to its text.
114
- */
115
- export function createProgram(files, theme) {
116
- const root = '/mavis/'
117
- const texts = new Map([...files].map(([path, text]) => [root + path, text]))
118
- texts.set(root + preludePath, prelude(theme))
119
- const base = ts.createCompilerHost(compilerOptions)
120
- const host = {
121
- ...base,
122
- getCurrentDirectory: () => root,
123
- fileExists: (name) => texts.has(name) || (!name.startsWith(root) && base.fileExists(name)),
124
- readFile: (name) =>
125
- texts.get(name) ?? (name.startsWith(root) ? undefined : base.readFile(name)),
126
- getSourceFile(name, languageVersion) {
127
- const text = texts.get(name)
128
- if (text !== undefined)
129
- return ts.createSourceFile(
130
- name,
131
- text,
132
- languageVersion,
133
- true,
134
- name.endsWith('x') ? ts.ScriptKind.TSX : ts.ScriptKind.TS,
135
- )
136
- return name.startsWith(root) ? undefined : base.getSourceFile(name, languageVersion)
137
- },
138
- writeFile() {},
139
- directoryExists: (name) =>
140
- name.startsWith(root)
141
- ? [...texts.keys()].some((path) => path.startsWith(name.endsWith('/') ? name : name + '/'))
142
- : (base.directoryExists?.(name) ?? true),
143
- getDirectories: () => [],
144
- }
145
- const program = ts.createProgram([...texts.keys()], compilerOptions, host)
146
- const relative = (name) => name.slice(root.length)
147
- const diagnostics = ts
148
- .getPreEmitDiagnostics(program)
149
- .filter((diagnostic) => !diagnostic.file || diagnostic.file.fileName.startsWith(root))
150
- .map((diagnostic) => {
151
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')
152
- if (!diagnostic.file || diagnostic.start === undefined) return message
153
- const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start)
154
- return `${relative(diagnostic.file.fileName)}:${line + 1}:${character + 1}: ${message}`
155
- })
156
- return {
157
- program,
158
- checker: program.getTypeChecker(),
159
- diagnostics,
160
- sourceFile: (path) => program.getSourceFile(root + path),
161
- relative,
162
- }
163
- }