@getcortexlabs/create-mavis 0.1.0-rc.12.1 → 0.1.0-rc.13
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 +9 -5
- package/package.json +1 -1
- package/src/adapters.mjs +76 -0
- package/src/add-target.mjs +5 -0
- package/src/capabilities.mjs +626 -0
- package/src/cli.mjs +47 -12
- package/src/doctor.mjs +92 -25
- package/src/macos.mjs +276 -0
- package/src/package-manager.mjs +12 -4
- package/src/portability.mjs +6 -1
- package/src/presets.mjs +15 -81
- package/src/scaffold.mjs +15 -3
- package/src/ui.mjs +123 -61
- package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +57 -0
- package/templates/macos/examples/tasks/shared/TaskRow.lite.tsx +33 -0
- package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +251 -0
- package/templates/macos/examples/tasks/shared/types.ts +9 -0
- package/templates/macos/mobile/src/App.vue +12 -0
- package/templates/macos/mobile/src/app.ts +7 -0
- package/templates/macos/native/Package.swift +17 -0
- package/templates/macos/native/Sources/MavisDesktop/App.swift +20 -0
- package/templates/macos/root/tsconfig.json +14 -0
- package/templates/macos/scripts/generate.mjs +36 -0
- package/templates/macos/scripts/macos.mjs +56 -0
- package/templates/macos/scripts/portable/emit-swift.mjs +1287 -0
- package/templates/macos/scripts/portable/emit-vue.mjs +615 -0
- package/templates/macos/scripts/portable/index.mjs +95 -0
- package/templates/macos/scripts/portable/model.mjs +1441 -0
- package/templates/macos/scripts/portable/program.mjs +163 -0
- package/templates/macos/shared/Welcome.lite.tsx +42 -0
- package/templates/macos/web/index.html +12 -0
- package/templates/macos/web/src/main.js +39 -0
- package/templates/macos/web/src/style.css +13 -0
- package/templates/macos/web/vite.config.mjs +3 -0
|
@@ -0,0 +1,163 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useStore, Show } from '@builder.io/mitosis'
|
|
2
|
+
|
|
3
|
+
// This checked subset generates every target. Edit it, then run the generate command.
|
|
4
|
+
export default function Welcome() {
|
|
5
|
+
const state = useStore({ sparks: 0 })
|
|
6
|
+
return (
|
|
7
|
+
<MColumn gap="xl">
|
|
8
|
+
<MRow gap="sm">
|
|
9
|
+
<MText variant="overline" tone="primary">
|
|
10
|
+
MAVIS / FIRST LIGHT
|
|
11
|
+
</MText>
|
|
12
|
+
<MText variant="caption" tone="muted">
|
|
13
|
+
Experimental · __MAVIS_TARGETS__
|
|
14
|
+
</MText>
|
|
15
|
+
</MRow>
|
|
16
|
+
<MColumn gap="sm">
|
|
17
|
+
<MText variant="display">One idea.</MText>
|
|
18
|
+
<MText variant="display" tone="primary">
|
|
19
|
+
A new window.
|
|
20
|
+
</MText>
|
|
21
|
+
<MText tone="muted">Your first shared screen, at home on every target.</MText>
|
|
22
|
+
</MColumn>
|
|
23
|
+
<MColumn gap="md" padding="lg">
|
|
24
|
+
<MText variant="overline" tone="muted">
|
|
25
|
+
MAKE A LITTLE MAGIC
|
|
26
|
+
</MText>
|
|
27
|
+
<MText variant="title">{state.sparks}</MText>
|
|
28
|
+
<MText tone="muted">Sparks collected in this window.</MText>
|
|
29
|
+
<Show when={state.sparks > 0} animate>
|
|
30
|
+
<MText tone="primary">Motion runs through Jolt on every target.</MText>
|
|
31
|
+
</Show>
|
|
32
|
+
<MRow gap="sm">
|
|
33
|
+
<MButton text="Add a spark" onClick={() => (state.sparks = state.sparks + 1)} />
|
|
34
|
+
<MButton text="Start again" variant="secondary" onClick={() => (state.sparks = 0)} />
|
|
35
|
+
</MRow>
|
|
36
|
+
</MColumn>
|
|
37
|
+
<MText variant="caption" tone="muted">
|
|
38
|
+
One Welcome.lite.tsx · __MAVIS_HOSTS__
|
|
39
|
+
</MText>
|
|
40
|
+
</MColumn>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>__MAVIS_NAME__ · Mavis</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<main id="app"></main>
|
|
10
|
+
<script type="module" src="/src/main.js"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createApp } from 'vue'
|
|
2
|
+
import { createMavisServices } from '@getcortexlabs/mavis-web/services'
|
|
3
|
+
import {
|
|
4
|
+
MButton,
|
|
5
|
+
MCard,
|
|
6
|
+
MCheckbox,
|
|
7
|
+
MColumn,
|
|
8
|
+
MGrid,
|
|
9
|
+
MInput,
|
|
10
|
+
MReveal,
|
|
11
|
+
MRow,
|
|
12
|
+
MSelect,
|
|
13
|
+
MText,
|
|
14
|
+
mavis,
|
|
15
|
+
midnight,
|
|
16
|
+
} from '@getcortexlabs/mavis-web'
|
|
17
|
+
import Root from './generated/__MAVIS_ROOT__.vue'
|
|
18
|
+
import '@getcortexlabs/mavis-web/style.css'
|
|
19
|
+
import './style.css'
|
|
20
|
+
|
|
21
|
+
const app = createApp(Root)
|
|
22
|
+
for (const [name, component] of Object.entries({
|
|
23
|
+
MColumn,
|
|
24
|
+
MRow,
|
|
25
|
+
MGrid,
|
|
26
|
+
MCard,
|
|
27
|
+
MText,
|
|
28
|
+
MButton,
|
|
29
|
+
MInput,
|
|
30
|
+
MCheckbox,
|
|
31
|
+
MSelect,
|
|
32
|
+
MReveal,
|
|
33
|
+
}))
|
|
34
|
+
app.component(name, component)
|
|
35
|
+
app
|
|
36
|
+
.use(
|
|
37
|
+
createMavisServices({ theme: mavis, darkTheme: midnight, appearance: '__MAVIS_APPEARANCE__' }),
|
|
38
|
+
)
|
|
39
|
+
.mount('#app')
|