@getcortexlabs/create-mavis 0.1.0-rc.14 → 0.1.0-rc.16

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 (69) hide show
  1. package/README.md +21 -28
  2. package/package.json +2 -4
  3. package/src/adapters.mjs +45 -23
  4. package/src/add-desktop.mjs +354 -0
  5. package/src/capabilities.mjs +233 -134
  6. package/src/cli.mjs +64 -60
  7. package/src/desktop.mjs +155 -0
  8. package/src/doctor.mjs +77 -108
  9. package/src/native-framework.mjs +144 -0
  10. package/src/portability.mjs +7 -106
  11. package/src/scaffold.mjs +36 -12
  12. package/src/shared-api.mjs +3 -0
  13. package/src/ui.mjs +30 -42
  14. package/templates/desktop/common/LICENSE +21 -0
  15. package/templates/desktop/common/build.mjs +49 -0
  16. package/templates/desktop/common/src/components.ts +60 -0
  17. package/templates/desktop/common/src/contract.mjs +35 -0
  18. package/templates/desktop/common/src/renderer.ts +76 -0
  19. package/templates/desktop/common/src/storage.ts +29 -0
  20. package/templates/desktop/directory/main.ts +35 -0
  21. package/templates/desktop/macos/launch.mjs +6 -0
  22. package/templates/desktop/macos/package.mjs +114 -0
  23. package/templates/desktop/macos/src/host.mjs +471 -0
  24. package/templates/desktop/welcome/Welcome.vue +56 -0
  25. package/templates/desktop/welcome/main.ts +24 -0
  26. package/templates/desktop/windows/NativeScript-LICENSE +19 -0
  27. package/templates/desktop/windows/launch.mjs +16 -0
  28. package/templates/desktop/windows/package.mjs +54 -0
  29. package/templates/desktop/windows/prepare-host.mjs +73 -0
  30. package/templates/desktop/windows/src/host.mjs +294 -0
  31. package/templates/native-framework/angular/screen.ts +84 -0
  32. package/templates/native-framework/common/nativescript.config.ts +6 -0
  33. package/templates/native-framework/common/src/app.ts +5 -0
  34. package/templates/native-framework/common/src/model.ts +40 -0
  35. package/templates/native-framework/common/src/references.d.ts +8 -0
  36. package/templates/native-framework/common/tsconfig.json +16 -0
  37. package/templates/native-framework/common/webpack.config.js +67 -0
  38. package/templates/native-framework/plain/screen.ts +102 -0
  39. package/templates/native-framework/react/screen.ts +83 -0
  40. package/templates/native-framework/solid/screen.ts +111 -0
  41. package/templates/native-framework/svelte/Welcome.svelte +26 -0
  42. package/templates/native-framework/svelte/screen.ts +14 -0
  43. package/templates/native-framework/svelte-tooling/svelte.config.js +20 -0
  44. package/src/add-macos.mjs +0 -386
  45. package/src/macos-capabilities.generated.mjs +0 -4190
  46. package/src/macos.mjs +0 -394
  47. package/src/migrate-directory.mjs +0 -121
  48. package/templates/directory/macos/DirectoryStorage.swift +0 -68
  49. package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +0 -57
  50. package/templates/macos/examples/tasks/shared/TaskRow.lite.tsx +0 -33
  51. package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +0 -251
  52. package/templates/macos/examples/tasks/shared/types.ts +0 -10
  53. package/templates/macos/mobile/src/App.vue +0 -14
  54. package/templates/macos/mobile/src/app.ts +0 -7
  55. package/templates/macos/native/Package.swift +0 -19
  56. package/templates/macos/native/Sources/MavisDesktop/App.swift +0 -35
  57. package/templates/macos/native/Sources/MavisDesktop/Fonts/LICENSE +0 -45
  58. package/templates/macos/native/Sources/MavisDesktop/Fonts/lucide.ttf +0 -0
  59. package/templates/macos/root/tsconfig.json +0 -14
  60. package/templates/macos/scripts/generate.mjs +0 -13
  61. package/templates/macos/scripts/macos-manifest.mjs +0 -33
  62. package/templates/macos/scripts/macos.mjs +0 -58
  63. package/templates/macos/shared/Welcome.lite.tsx +0 -42
  64. package/templates/macos/web/index.html +0 -12
  65. package/templates/macos/web/src/main.js +0 -212
  66. package/templates/macos/web/src/mavis.js +0 -2
  67. package/templates/macos/web/src/style.css +0 -14
  68. package/templates/macos/web/vite.config.mjs +0 -14
  69. package/templates/migrations/directory-rc13.json +0 -36
@@ -1,251 +0,0 @@
1
- import { useStore, useRef, Show, For } from '@builder.io/mitosis'
2
- import type { Filter, PriorityOption, Task } from './types'
3
- import TaskRow from './TaskRow.lite'
4
- import TaskDetail from './TaskDetail.lite'
5
-
6
- // A small task manager: one source for every target. Tasks live in memory for the session.
7
- export default function Tasks() {
8
- const titleRef = useRef<MavisFieldRef>(null)
9
- const state = useStore({
10
- tasks: [
11
- {
12
- id: 'task1',
13
- title: 'Sketch the launch page',
14
- notes: 'Hero, pricing and one honest screenshot.',
15
- priority: 'high',
16
- done: false,
17
- },
18
- { id: 'task2', title: 'Reply to Noor', notes: '', priority: 'normal', done: true },
19
- {
20
- id: 'task3',
21
- title: 'Book the studio',
22
- notes: 'Thursday afternoon works best.',
23
- priority: 'low',
24
- done: false,
25
- },
26
- ] as Task[],
27
- blank: { id: '', title: '', notes: '', priority: 'normal', done: false } as Task,
28
- priorities: [
29
- { value: 'low', label: 'Low' },
30
- { value: 'normal', label: 'Normal' },
31
- { value: 'high', label: 'High' },
32
- ] as PriorityOption[],
33
- filter: 'all' as Filter,
34
- selected: 'task1' as string | undefined,
35
- count: 3,
36
- title: '',
37
- notes: '',
38
- priority: 'normal',
39
- submitted: false,
40
- get visible(): Task[] {
41
- return state.tasks.filter(
42
- (task) => state.filter === 'all' || (state.filter === 'done') === task.done,
43
- )
44
- },
45
- get done(): number {
46
- return state.tasks.filter((task) => task.done).length
47
- },
48
- get summary(): string {
49
- return `${state.tasks.length - state.done} open · ${state.done} done`
50
- },
51
- get current(): Task {
52
- return state.tasks.find((task) => task.id === state.selected) ?? state.blank
53
- },
54
- get hasCurrent(): boolean {
55
- return state.tasks.some((task) => task.id === state.selected)
56
- },
57
- get position(): number {
58
- return state.visible.findIndex((task) => task.id === state.selected)
59
- },
60
- get titleError(): string {
61
- return state.submitted && state.title.trim() === '' ? 'Give the task a title' : ''
62
- },
63
- compose() {
64
- titleRef.focus()
65
- },
66
- add() {
67
- state.submitted = true
68
- if (state.titleError !== '') {
69
- titleRef.focus()
70
- return
71
- }
72
- state.count += 1
73
- state.tasks.unshift({
74
- id: `task${state.count}`,
75
- title: state.title.trim(),
76
- notes: state.notes,
77
- priority: state.priority,
78
- done: false,
79
- })
80
- state.selected = `task${state.count}`
81
- // A new task is open: leave the Done filter so it shows up.
82
- if (state.filter === 'done') state.filter = 'all'
83
- state.title = ''
84
- state.notes = ''
85
- state.priority = 'normal'
86
- state.submitted = false
87
- },
88
- toggle() {
89
- state.tasks = state.tasks.map((task) =>
90
- task.id === state.selected ? { ...task, done: !task.done } : task,
91
- )
92
- },
93
- rename(title: string) {
94
- state.tasks = state.tasks.map((task) =>
95
- task.id === state.selected ? { ...task, title } : task,
96
- )
97
- },
98
- annotate(notes: string) {
99
- state.tasks = state.tasks.map((task) =>
100
- task.id === state.selected ? { ...task, notes } : task,
101
- )
102
- },
103
- prioritize(priority: string) {
104
- state.tasks = state.tasks.map((task) =>
105
- task.id === state.selected ? { ...task, priority } : task,
106
- )
107
- },
108
- move(by: number) {
109
- // Swap places with the neighbour on screen, also when a filter hides tasks in between.
110
- const task = state.visible[state.position]
111
- const other = state.visible[state.position + by]
112
- if (task === undefined) return
113
- if (other === undefined) return
114
- const from = state.tasks.findIndex((item) => item.id === task.id)
115
- const to = state.tasks.findIndex((item) => item.id === other.id)
116
- state.tasks.splice(from, 1)
117
- state.tasks.splice(to, 0, task)
118
- },
119
- remove() {
120
- const index = state.tasks.findIndex((task) => task.id === state.selected)
121
- if (index < 0) return
122
- // The neighbour on screen takes the selection.
123
- const next = state.visible[state.position + 1] ?? state.visible[state.position - 1]
124
- state.tasks.splice(index, 1)
125
- state.selected = next?.id
126
- },
127
- step(key: string) {
128
- const by = key === 'ArrowDown' ? 1 : key === 'ArrowUp' ? -1 : 0
129
- const task =
130
- state.visible[Math.max(0, Math.min(state.position + by, state.visible.length - 1))]
131
- if (task !== undefined) state.selected = task.id
132
- },
133
- })
134
- return (
135
- <MColumn gap="lg">
136
- <MColumn gap="xs">
137
- <MText variant="title">Tasks</MText>
138
- <MText tone="muted">{state.summary}</MText>
139
- </MColumn>
140
- <MRow gap="sm">
141
- <MButton text="New task" shortcut="mod+k" onClick={() => state.compose()} />
142
- <MButton
143
- text={state.current.done ? 'Reopen' : 'Complete'}
144
- variant="secondary"
145
- shortcut="mod+Enter"
146
- disabled={!state.hasCurrent}
147
- onClick={() => state.toggle()}
148
- />
149
- <MButton
150
- text="Delete"
151
- variant="secondary"
152
- shortcut="mod+d"
153
- disabled={!state.hasCurrent}
154
- onClick={() => state.remove()}
155
- />
156
- </MRow>
157
- <MGrid gap="lg" columns={2} minColumnWidth={320}>
158
- <MColumn gap="md">
159
- <MRow gap="sm">
160
- <MButton
161
- text={`All (${state.tasks.length})`}
162
- variant={state.filter === 'all' ? 'primary' : 'secondary'}
163
- onClick={() => (state.filter = 'all')}
164
- />
165
- <MButton
166
- text={`Open (${state.tasks.length - state.done})`}
167
- variant={state.filter === 'open' ? 'primary' : 'secondary'}
168
- onClick={() => (state.filter = 'open')}
169
- />
170
- <MButton
171
- text={`Done (${state.done})`}
172
- variant={state.filter === 'done' ? 'primary' : 'secondary'}
173
- onClick={() => (state.filter = 'done')}
174
- />
175
- </MRow>
176
- <Show
177
- when={state.tasks.length > 0}
178
- else={<MText tone="muted">No tasks yet. Add the first one.</MText>}
179
- >
180
- <Show
181
- when={state.visible.length > 0}
182
- else={<MText tone="muted">Nothing here. Try another filter.</MText>}
183
- >
184
- <MColumn gap="sm" label="Tasks" onKeyDown={(key) => state.step(key)}>
185
- <For each={state.visible} animate>
186
- {(task) => (
187
- <TaskRow
188
- key={task.id}
189
- task={task}
190
- selected={task.id === state.selected}
191
- onSelect={(id) => (state.selected = id)}
192
- />
193
- )}
194
- </For>
195
- </MColumn>
196
- </Show>
197
- </Show>
198
- </MColumn>
199
- <MColumn gap="lg">
200
- <Show
201
- when={state.hasCurrent}
202
- else={<MText tone="muted">Select a task to see its details.</MText>}
203
- >
204
- <TaskDetail
205
- task={state.current}
206
- priorities={state.priorities}
207
- canMoveUp={state.position > 0}
208
- canMoveDown={state.position >= 0 && state.position < state.visible.length - 1}
209
- onToggle={() => state.toggle()}
210
- onRename={(title) => state.rename(title)}
211
- onNotes={(notes) => state.annotate(notes)}
212
- onPriority={(priority) => state.prioritize(priority)}
213
- onMove={(by) => state.move(by)}
214
- />
215
- </Show>
216
- <MCard gap="md">
217
- <MText variant="overline" tone="muted">
218
- NEW TASK
219
- </MText>
220
- <MInput
221
- label="Title"
222
- ref={titleRef}
223
- value={state.title}
224
- onChange={(value) => (state.title = value)}
225
- placeholder="What needs doing?"
226
- maxLength={60}
227
- error={state.titleError}
228
- onSubmit={() => state.add()}
229
- />
230
- <MInput
231
- label="Notes"
232
- multiline
233
- rows={2}
234
- value={state.notes}
235
- onChange={(value) => (state.notes = value)}
236
- />
237
- <MSelect
238
- label="Priority"
239
- value={state.priority}
240
- options={state.priorities}
241
- onChange={(value) => (state.priority = value)}
242
- />
243
- <MRow gap="sm">
244
- <MButton text="Add task" onClick={() => state.add()} />
245
- </MRow>
246
- </MCard>
247
- </MColumn>
248
- </MGrid>
249
- </MColumn>
250
- )
251
- }
@@ -1,10 +0,0 @@
1
- export type Filter = 'all' | 'open' | 'done'
2
- export type PriorityOption = { value: string; label: string }
3
-
4
- export type Task = {
5
- id: string
6
- title: string
7
- notes: string
8
- priority: string
9
- done: boolean
10
- }
@@ -1,14 +0,0 @@
1
- <script setup lang="ts">
2
- import Root, { screen } from './generated/entry'
3
- </script>
4
- <template>
5
- <Frame>
6
- <!-- A screen with an MScreen of its own is the page; any other gets one around it. -->
7
- <Root v-if="screen" />
8
- <MScreen v-else scroll>
9
- <MColumn padding="lg">
10
- <Root />
11
- </MColumn>
12
- </MScreen>
13
- </Frame>
14
- </template>
@@ -1,7 +0,0 @@
1
- import { createApp } from 'nativescript-vue'
2
- import { createMavis } from '@getcortexlabs/mavis/vue'
3
- import { mavis, midnight } from '@getcortexlabs/mavis-core'
4
- import App from './App.vue'
5
- createApp(App)
6
- .use(createMavis({ theme: mavis, darkTheme: midnight, appearance: '__MAVIS_APPEARANCE__' }))
7
- .start()
@@ -1,19 +0,0 @@
1
- // swift-tools-version: 5.9
2
- import PackageDescription
3
-
4
- let package = Package(
5
- name: "MavisDesktop",
6
- platforms: [.macOS(.v14)],
7
- products: [.executable(name: "MavisDesktop", targets: ["MavisDesktop"])],
8
- dependencies: [
9
- .package(url: "https://github.com/rafaelaugustos/jolt-swift.git", exact: "__MAVIS_JOLT_SWIFT__"),
10
- ],
11
- targets: [
12
- .executableTarget(
13
- name: "MavisDesktop",
14
- dependencies: [.product(name: "JoltSwiftUI", package: "jolt-swift")],
15
- // The Lucide font MIcon draws with, and the pictures of shared/assets.
16
- resources: [.copy("Fonts"), .copy("Generated/Assets")]
17
- ),
18
- ]
19
- )
@@ -1,35 +0,0 @@
1
- import SwiftUI
2
-
3
- @main
4
- struct MavisDesktopApp: App {
5
- var body: some Scene {
6
- WindowGroup(MavisAppConfiguration.name) {
7
- // portability.entry of mavis.config.json, in Generated/MavisEntry.swift.
8
- MavisEntry()
9
- // Sheets, dialogs, popovers and menus open over the window's content.
10
- .mavisLayers()
11
- // Tooltips and toasts show over the window's whole content.
12
- .mavisFeedbackLayer()
13
- .tint(MavisTokens.primary)
14
- .frame(minWidth: MavisAppConfiguration.minWidth, minHeight: MavisAppConfiguration.minHeight)
15
- }
16
- .defaultSize(width: __MAVIS_MAC_DEFAULT_WIDTH__, height: 760)
17
- .commands { MavisEntryCommands() }
18
- }
19
- }
20
-
21
- /// The page around a screen without an MScreen of its own: it scrolls on the theme background.
22
- /// A screen with one fills the window itself.
23
- struct MavisPage<Content: View>: View {
24
- @ViewBuilder var content: () -> Content
25
-
26
- var body: some View {
27
- ScrollView {
28
- content()
29
- .padding(48)
30
- .frame(maxWidth: __MAVIS_MAC_WIDTH__, alignment: .leading)
31
- .frame(maxWidth: .infinity, alignment: .center)
32
- }
33
- .background(MavisTokens.background)
34
- }
35
- }
@@ -1,45 +0,0 @@
1
- Lucide icon font 1.65.0
2
-
3
- ISC License
4
-
5
- Copyright (c) 2026 Lucide Icons and Contributors
6
-
7
- Permission to use, copy, modify, and/or distribute this software for any
8
- purpose with or without fee is hereby granted, provided that the above
9
- copyright notice and this permission notice appear in all copies.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
-
19
- ---
20
-
21
- The following Lucide icons are derived from the Feather project:
22
-
23
- airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
24
-
25
- The MIT License (MIT) (for the icons listed above)
26
-
27
- Copyright (c) 2013-present Cole Bemis
28
-
29
- Permission is hereby granted, free of charge, to any person obtaining a copy
30
- of this software and associated documentation files (the "Software"), to deal
31
- in the Software without restriction, including without limitation the rights
32
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
- copies of the Software, and to permit persons to whom the Software is
34
- furnished to do so, subject to the following conditions:
35
-
36
- The above copyright notice and this permission notice shall be included in all
37
- copies or substantial portions of the Software.
38
-
39
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
- SOFTWARE.
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "noEmit": true,
5
- "jsx": "preserve",
6
- "target": "ES2022",
7
- "module": "ESNext",
8
- "moduleResolution": "Bundler",
9
- "lib": ["ES2023"],
10
- "types": [],
11
- "noUncheckedIndexedAccess": true
12
- },
13
- "include": ["shared", "mavis-env.d.ts"]
14
- }
@@ -1,13 +0,0 @@
1
- import { fileURLToPath } from 'node:url'
2
- import { generateProject, PortableError } from '@getcortexlabs/mavis-compiler'
3
-
4
- try {
5
- const result = await generateProject(fileURLToPath(new URL('..', import.meta.url)))
6
- console.log(
7
- `Generated ${result.targets.join(', ')} for ${result.components} shared component(s).`,
8
- )
9
- } catch (error) {
10
- if (!(error instanceof PortableError)) throw error
11
- console.error(error.message)
12
- process.exitCode = 1
13
- }
@@ -1,33 +0,0 @@
1
- const xml = (value) =>
2
- String(value)
3
- .replaceAll('&', '&amp;')
4
- .replaceAll('<', '&lt;')
5
- .replaceAll('>', '&gt;')
6
- .replaceAll('"', '&quot;')
7
-
8
- // Kept beside the launcher so both a new project and --add-macos package the
9
- // same identity and custom URL handlers. The route table still resolves URLs.
10
- export function macAppManifest(settings) {
11
- const schemes = settings.urlSchemes ?? []
12
- return `<?xml version="1.0" encoding="UTF-8"?>
13
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
14
- <plist version="1.0"><dict>
15
- <key>CFBundleExecutable</key><string>MavisDesktop</string>
16
- <key>CFBundleIdentifier</key><string>${xml(settings.bundleId)}</string>
17
- <key>CFBundleName</key><string>${xml(settings.name)}</string>
18
- ${settings.icon ? '<key>CFBundleIconFile</key><string>AppIcon.icns</string>' : ''}
19
- ${
20
- schemes.length
21
- ? `<key>CFBundleURLTypes</key><array><dict>
22
- <key>CFBundleTypeRole</key><string>Editor</string>
23
- <key>CFBundleURLName</key><string>${xml(settings.bundleId)}</string>
24
- <key>CFBundleURLSchemes</key><array>${schemes.map((scheme) => `<string>${xml(scheme)}</string>`).join('')}</array>
25
- </dict></array>`
26
- : ''
27
- }
28
- <key>CFBundlePackageType</key><string>APPL</string>
29
- <key>CFBundleShortVersionString</key><string>0.0.0</string>
30
- <key>LSMinimumSystemVersion</key><string>14.0</string>
31
- <key>NSHighResolutionCapable</key><true/>
32
- </dict></plist>`
33
- }
@@ -1,58 +0,0 @@
1
- import { spawnSync } from 'node:child_process'
2
- import { cp, mkdir, copyFile, readFile, readdir, rm, writeFile } from 'node:fs/promises'
3
- import { fileURLToPath } from 'node:url'
4
- import { join, isAbsolute } from 'node:path'
5
- import { macAppSettings } from '@getcortexlabs/mavis-compiler'
6
- import { macAppManifest } from './macos-manifest.mjs'
7
-
8
- if (process.platform !== 'darwin')
9
- throw new Error(
10
- 'The macOS app needs macOS 14+ and Xcode. Web and code generation work on other hosts.',
11
- )
12
- const action = process.argv[2] ?? 'build'
13
- if (!['build', 'run'].includes(action)) throw new Error('Expected build or run.')
14
- const root = fileURLToPath(new URL('../', import.meta.url))
15
- const config = JSON.parse(await readFile(join(root, 'mavis.config.json'), 'utf8'))
16
- const settings = macAppSettings(config.macos, config.name ?? '__MAVIS_NAME__')
17
- function run(command, args, capture = false) {
18
- const result = spawnSync(command, args, {
19
- cwd: root,
20
- encoding: 'utf8',
21
- stdio: capture ? 'pipe' : 'inherit',
22
- })
23
- if (result.error) throw result.error
24
- if (result.status !== 0)
25
- throw new Error(
26
- `${command} failed (${result.status}). Check Xcode installation and command-line tools.`,
27
- )
28
- return result.stdout?.trim()
29
- }
30
- run(process.execPath, ['scripts/generate.mjs'])
31
- run('swift', ['build', '--package-path', 'apps/macos', '-c', 'release'])
32
- const bin = run(
33
- 'swift',
34
- ['build', '--package-path', 'apps/macos', '-c', 'release', '--show-bin-path'],
35
- true,
36
- )
37
- const app = join(root, 'dist', settings.name + '.app')
38
- await rm(app, { recursive: true, force: true })
39
- await mkdir(join(app, 'Contents', 'MacOS'), { recursive: true })
40
- await copyFile(join(bin, 'MavisDesktop'), join(app, 'Contents', 'MacOS', 'MavisDesktop'))
41
- // Resource bundles of Swift packages travel inside the app: the app's own holds the Lucide font
42
- // of MIcon. JoltSwiftUI has none.
43
- for (const entry of await readdir(bin))
44
- if (entry.endsWith('.bundle'))
45
- await cp(join(bin, entry), join(app, 'Contents', 'Resources', entry), { recursive: true })
46
- if (settings.icon) {
47
- if (
48
- isAbsolute(settings.icon) ||
49
- settings.icon.includes('\\') ||
50
- settings.icon.split('/').includes('..')
51
- )
52
- throw new Error('macos.icon must stay inside the project.')
53
- await mkdir(join(app, 'Contents', 'Resources'), { recursive: true })
54
- await copyFile(join(root, settings.icon), join(app, 'Contents', 'Resources', 'AppIcon.icns'))
55
- }
56
- await writeFile(join(app, 'Contents', 'Info.plist'), macAppManifest(settings))
57
- console.log(`Built ${app}. Local unsigned development app; distribution/signing is not configured.`)
58
- if (action === 'run') run('open', ['-n', app])
@@ -1,42 +0,0 @@
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
- }
@@ -1,12 +0,0 @@
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
- <div id="app"></div>
10
- <script type="module" src="/src/main.js"></script>
11
- </body>
12
- </html>