@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
@@ -6,49 +6,55 @@ export interface DirectoryEntry {
6
6
  city: string
7
7
  }
8
8
  export interface DirectoryStorage {
9
- read(): Promise<string | null>
10
- write(value: string): Promise<void>
9
+ load(): Promise<DirectorySnapshot>
10
+ rename(id: string, name: string): Promise<DirectorySnapshot>
11
11
  }
12
- const seed: DirectoryEntry[] = [
12
+ export interface DirectorySnapshot {
13
+ entries: DirectoryEntry[]
14
+ revision: number
15
+ loadError: boolean
16
+ }
17
+ export const directorySeed: DirectoryEntry[] = [
13
18
  { id: 'garden', name: 'Community garden', city: 'Porto' },
14
19
  { id: 'library', name: 'Open library', city: 'Recife' },
15
20
  { id: 'studio', name: 'Neighbourhood studio', city: 'Porto' },
16
21
  ]
17
22
 
23
+ /** JSON decoding belongs to the host; the accepted directory records are the same everywhere. */
24
+ export function validDirectoryEntries(entries: DirectoryEntry[]): boolean {
25
+ return (
26
+ entries.length === directorySeed.length &&
27
+ entries.every((entry) => entry.name.trim() !== '') &&
28
+ directorySeed.every(
29
+ (original) => entries.filter((entry) => entry.id === original.id).length === 1,
30
+ )
31
+ )
32
+ }
33
+
18
34
  /** Create once per app/request. Storage is a host service, never a module singleton. */
19
35
  export function createDirectory(storage: DirectoryStorage) {
20
- const entries = ref(seed.map((entry) => ({ ...entry })))
36
+ const entries = ref<DirectoryEntry[]>(directorySeed.map((entry) => ({ ...entry })))
21
37
  const query = ref('')
22
38
  const storageError = ref('')
23
- let restoring: Promise<void> | undefined
24
- let writing = Promise.resolve()
25
- const restore = () =>
26
- (restoring ??= (async () => {
27
- try {
28
- const value = await storage.read()
29
- if (value === null) return
30
- const parsed: unknown = JSON.parse(value)
31
- if (
32
- !Array.isArray(parsed) ||
33
- parsed.length !== seed.length ||
34
- !seed.every(
35
- (original) =>
36
- parsed.filter(
37
- (entry) =>
38
- entry?.id === original.id &&
39
- typeof entry.name === 'string' &&
40
- entry.name.trim() &&
41
- typeof entry.city === 'string',
42
- ).length === 1,
43
- )
44
- )
45
- throw new Error('Invalid saved directory')
46
- entries.value = parsed.map(({ id, name, city }) => ({ id, name, city }))
47
- } catch {
48
- storageError.value =
49
- 'Saved entries could not be loaded. The sample entries are still available.'
50
- }
51
- })())
39
+ let revision = -1
40
+ function accept(snapshot: DirectorySnapshot) {
41
+ // A delayed load or save must not undo a newer confirmed write.
42
+ if (snapshot.revision < revision) return
43
+ revision = snapshot.revision
44
+ entries.value = snapshot.entries.map((entry) => ({ ...entry }))
45
+ if (snapshot.loadError)
46
+ storageError.value =
47
+ 'Saved entries could not be loaded. The sample entries are still available.'
48
+ }
49
+ async function restore() {
50
+ try {
51
+ const snapshot = await storage.load()
52
+ accept(snapshot)
53
+ } catch {
54
+ storageError.value =
55
+ 'Saved entries could not be loaded. The sample entries are still available.'
56
+ }
57
+ }
52
58
  return {
53
59
  entries: readonly(entries),
54
60
  query,
@@ -57,19 +63,9 @@ export function createDirectory(storage: DirectoryStorage) {
57
63
  async save(id: string, name: string) {
58
64
  if (!name.trim() || !entries.value.some((entry) => entry.id === id))
59
65
  throw new Error('Invalid entry')
60
- const pending = writing
61
- .catch(() => {})
62
- .then(async () => {
63
- await restore()
64
- const next = entries.value.map((entry) =>
65
- entry.id === id ? { ...entry, name: name.trim() } : { ...entry },
66
- )
67
- // Commit state only after the host confirms persistence. A rejected write preserves the draft.
68
- await storage.write(JSON.stringify(next))
69
- entries.value = next
70
- })
71
- writing = pending
72
- await pending
66
+ // The host performs an atomic edit against its latest persisted value, not a stale snapshot.
67
+ const snapshot = await storage.rename(id, name.trim())
68
+ accept(snapshot)
73
69
  },
74
70
  }
75
71
  }
@@ -5,18 +5,21 @@ import { createRouterNavigation, mavis, midnight } from '@getcortexlabs/mavis-co
5
5
  import { createDirectory, directoryKey } from '__MAVIS_SHARED__/directory-store'
6
6
  import { routes } from '__MAVIS_SHARED__/routes'
7
7
  import App from './App.vue'
8
+ import { createDirectoryStorage } from './directory-storage'
8
9
  import '@getcortexlabs/mavis-web/style.css'
9
10
  import './style.css'
10
11
 
11
12
  const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes })
12
- const directory = createDirectory({
13
- async read() {
14
- return localStorage.getItem('mavis:directory')
15
- },
16
- async write(value) {
17
- localStorage.setItem('mavis:directory', value)
18
- },
19
- })
13
+ const directory = createDirectory(
14
+ createDirectoryStorage({
15
+ async read() {
16
+ return localStorage.getItem('mavis:directory')
17
+ },
18
+ async write(value) {
19
+ localStorage.setItem('mavis:directory', value)
20
+ },
21
+ }),
22
+ )
20
23
  const app = createApp(App)
21
24
  .use(router)
22
25
  .use(
@@ -1,9 +1,9 @@
1
- import type { Task } from './types'
1
+ import type { PriorityOption, Task } from './types'
2
2
 
3
3
  // The selected task. Every edit goes straight to the list, so the row updates while you type.
4
4
  export default function TaskDetail(props: {
5
5
  task: Task
6
- priorities: SelectOption[]
6
+ priorities: PriorityOption[]
7
7
  canMoveUp: boolean
8
8
  canMoveDown: boolean
9
9
  onToggle: () => void
@@ -1,5 +1,5 @@
1
1
  import { useStore, useRef, Show, For } from '@builder.io/mitosis'
2
- import type { Filter, Task } from './types'
2
+ import type { Filter, PriorityOption, Task } from './types'
3
3
  import TaskRow from './TaskRow.lite'
4
4
  import TaskDetail from './TaskDetail.lite'
5
5
 
@@ -29,7 +29,7 @@ export default function Tasks() {
29
29
  { value: 'low', label: 'Low' },
30
30
  { value: 'normal', label: 'Normal' },
31
31
  { value: 'high', label: 'High' },
32
- ] as SelectOption[],
32
+ ] as PriorityOption[],
33
33
  filter: 'all' as Filter,
34
34
  selected: 'task1' as string | undefined,
35
35
  count: 3,
@@ -1,4 +1,5 @@
1
1
  export type Filter = 'all' | 'open' | 'done'
2
+ export type PriorityOption = { value: string; label: string }
2
3
 
3
4
  export type Task = {
4
5
  id: string
@@ -1,9 +1,11 @@
1
1
  <script setup lang="ts">
2
- import Root from './generated/__MAVIS_ROOT__.vue'
2
+ import Root, { screen } from './generated/entry'
3
3
  </script>
4
4
  <template>
5
5
  <Frame>
6
- <MScreen scroll>
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>
7
9
  <MColumn padding="lg">
8
10
  <Root />
9
11
  </MColumn>
@@ -11,7 +11,9 @@ let package = Package(
11
11
  targets: [
12
12
  .executableTarget(
13
13
  name: "MavisDesktop",
14
- dependencies: [.product(name: "JoltSwiftUI", package: "jolt-swift")]
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")]
15
17
  ),
16
18
  ]
17
19
  )
@@ -3,18 +3,33 @@ import SwiftUI
3
3
  @main
4
4
  struct MavisDesktopApp: App {
5
5
  var body: some Scene {
6
- WindowGroup("__MAVIS_NAME__") {
7
- ScrollView {
8
- __MAVIS_ROOT__()
9
- .padding(48)
10
- .frame(maxWidth: __MAVIS_MAC_WIDTH__, alignment: .leading)
11
- .frame(maxWidth: .infinity, alignment: .center)
12
- }
13
- .background(MavisTokens.background)
14
- .tint(MavisTokens.primary)
15
- .preferredColorScheme(.__MAVIS_APPEARANCE__)
16
- .frame(minWidth: __MAVIS_MAC_MIN_WIDTH__, minHeight: 640)
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)
17
15
  }
18
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)
19
34
  }
20
35
  }
@@ -0,0 +1,45 @@
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,33 +1,10 @@
1
- import { mkdir, readFile, rm, writeFile } from 'node:fs/promises'
2
- import { join } from 'node:path'
3
1
  import { fileURLToPath } from 'node:url'
4
- import { compileProject, readShared, PortableError } from './portable/index.mjs'
2
+ import { generateProject, PortableError } from '@getcortexlabs/mavis-compiler'
5
3
 
6
- const root = fileURLToPath(new URL('..', import.meta.url))
7
- // Each target's generated folder. They are replaced on every run; never edit their files.
8
- const folders = {
9
- web: 'apps/web/src/generated',
10
- native: 'apps/mobile/src/generated',
11
- macos: 'apps/macos/Sources/MavisDesktop/Generated',
12
- }
13
4
  try {
14
- const config = JSON.parse(await readFile(join(root, 'mavis.config.json'), 'utf8'))
15
- const files = await readShared(root)
16
- const { model, vue, native, swift, environment } = await compileProject(files, {
17
- theme: config.theme,
18
- root: config.portability?.entry ?? 'Welcome',
19
- })
20
- const outputs = { web: vue, native, macos: swift }
21
- // Write only after every target compiled.
22
- for (const target of config.targets) {
23
- const folder = join(root, folders[target])
24
- await rm(folder, { recursive: true, force: true })
25
- await mkdir(folder, { recursive: true })
26
- for (const [name, text] of outputs[target]) await writeFile(join(folder, name), text)
27
- }
28
- await writeFile(join(root, 'mavis-env.d.ts'), environment)
5
+ const result = await generateProject(fileURLToPath(new URL('..', import.meta.url)))
29
6
  console.log(
30
- `Generated ${config.targets.join(', ')} for ${model.components.length} shared component(s).`,
7
+ `Generated ${result.targets.join(', ')} for ${result.components} shared component(s).`,
31
8
  )
32
9
  } catch (error) {
33
10
  if (!(error instanceof PortableError)) throw error
@@ -0,0 +1,33 @@
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,7 +1,9 @@
1
1
  import { spawnSync } from 'node:child_process'
2
- import { cp, mkdir, copyFile, readdir, rm, writeFile } from 'node:fs/promises'
2
+ import { cp, mkdir, copyFile, readFile, readdir, rm, writeFile } from 'node:fs/promises'
3
3
  import { fileURLToPath } from 'node:url'
4
- import { join } from 'node:path'
4
+ import { join, isAbsolute } from 'node:path'
5
+ import { macAppSettings } from '@getcortexlabs/mavis-compiler'
6
+ import { macAppManifest } from './macos-manifest.mjs'
5
7
 
6
8
  if (process.platform !== 'darwin')
7
9
  throw new Error(
@@ -10,6 +12,8 @@ if (process.platform !== 'darwin')
10
12
  const action = process.argv[2] ?? 'build'
11
13
  if (!['build', 'run'].includes(action)) throw new Error('Expected build or run.')
12
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__')
13
17
  function run(command, args, capture = false) {
14
18
  const result = spawnSync(command, args, {
15
19
  cwd: root,
@@ -30,27 +34,25 @@ const bin = run(
30
34
  ['build', '--package-path', 'apps/macos', '-c', 'release', '--show-bin-path'],
31
35
  true,
32
36
  )
33
- const app = join(root, 'dist', '__MAVIS_NAME__.app')
37
+ const app = join(root, 'dist', settings.name + '.app')
34
38
  await rm(app, { recursive: true, force: true })
35
39
  await mkdir(join(app, 'Contents', 'MacOS'), { recursive: true })
36
40
  await copyFile(join(bin, 'MavisDesktop'), join(app, 'Contents', 'MacOS', 'MavisDesktop'))
37
- // Package resources, such as Jolt's motion definitions, travel inside the app.
41
+ // Resource bundles of Swift packages travel inside the app: the app's own holds the Lucide font
42
+ // of MIcon. JoltSwiftUI has none.
38
43
  for (const entry of await readdir(bin))
39
44
  if (entry.endsWith('.bundle'))
40
45
  await cp(join(bin, entry), join(app, 'Contents', 'Resources', entry), { recursive: true })
41
- await writeFile(
42
- join(app, 'Contents', 'Info.plist'),
43
- `<?xml version="1.0" encoding="UTF-8"?>
44
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
45
- <plist version="1.0"><dict>
46
- <key>CFBundleExecutable</key><string>MavisDesktop</string>
47
- <key>CFBundleIdentifier</key><string>com.mavis.experimental.__MAVIS_APPID__</string>
48
- <key>CFBundleName</key><string>__MAVIS_NAME__</string>
49
- <key>CFBundlePackageType</key><string>APPL</string>
50
- <key>CFBundleShortVersionString</key><string>0.0.0</string>
51
- <key>LSMinimumSystemVersion</key><string>14.0</string>
52
- <key>NSHighResolutionCapable</key><true/>
53
- </dict></plist>`,
54
- )
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))
55
57
  console.log(`Built ${app}. Local unsigned development app; distribution/signing is not configured.`)
56
58
  if (action === 'run') run('open', ['-n', app])
@@ -6,7 +6,7 @@
6
6
  <title>__MAVIS_NAME__ · Mavis</title>
7
7
  </head>
8
8
  <body>
9
- <main id="app"></main>
9
+ <div id="app"></div>
10
10
  <script type="module" src="/src/main.js"></script>
11
11
  </body>
12
12
  </html>
@@ -1,35 +1,208 @@
1
- import { createApp } from 'vue'
1
+ import { createApp, h } from 'vue'
2
2
  import { createMavisServices } from '@getcortexlabs/mavis-web/services'
3
3
  import {
4
+ MAlert,
5
+ MBadge,
6
+ MAccordion,
7
+ MAvatar,
8
+ MAppBar,
9
+ MBox,
10
+ MBreadcrumb,
4
11
  MButton,
5
12
  MCard,
13
+ MCarousel,
14
+ MChart,
15
+ MHeatmap,
6
16
  MCheckbox,
17
+ MChip,
18
+ MCollapsibleHeader,
7
19
  MColumn,
20
+ MEmptyState,
21
+ MDonutChart,
22
+ MGauge,
23
+ MDialog,
24
+ MCommandPalette,
25
+ MFormErrors,
26
+ MFormGroup,
27
+ MGradientBackground,
28
+ MDataTable,
29
+ MCombobox,
30
+ MComposer,
31
+ MColorPicker,
32
+ MFilePicker,
33
+ MPopover,
34
+ MMenu,
35
+ MSpeedDial,
36
+ MTour,
37
+ MTourTarget,
8
38
  MGrid,
39
+ MIcon,
40
+ MImage,
41
+ MImageCompare,
42
+ MImageCropper,
43
+ MImageViewer,
9
44
  MInput,
45
+ MListItem,
46
+ MLink,
47
+ MMasonry,
48
+ MNavigationRail,
49
+ MPagination,
50
+ MNumberInput,
51
+ MMultiSelect,
52
+ MPinInput,
53
+ MPlatform,
54
+ MProgress,
55
+ MRadioGroup,
56
+ MRangeSlider,
57
+ MRating,
58
+ MRefreshControl,
59
+ MResizablePanels,
10
60
  MReveal,
61
+ MAnimatedText,
62
+ MNumberFlow,
63
+ MConfetti,
64
+ MParticleField,
65
+ MMarquee,
11
66
  MRow,
67
+ MScreen,
68
+ MCalendar,
69
+ MTimePicker,
70
+ MScheduler,
71
+ MDatePicker,
72
+ MDateRangePicker,
73
+ MSegmentedControl,
12
74
  MSelect,
75
+ MSeparator,
76
+ MSortableList,
77
+ MSwipeActions,
78
+ MSwipeDeck,
79
+ MKanban,
80
+ MSkeleton,
81
+ MSlider,
82
+ MSheet,
83
+ MSpan,
84
+ MSparkline,
85
+ MStack,
86
+ MSwitch,
87
+ MSteps,
88
+ MTabBar,
89
+ MTabs,
13
90
  MText,
91
+ MThemeProvider,
92
+ MToast,
93
+ MNotificationCenter,
94
+ MTimeline,
95
+ MTreeView,
96
+ MTooltip,
97
+ MTransferList,
98
+ MTreeSelect,
99
+ MVirtualList,
14
100
  mavis,
15
101
  midnight,
16
102
  } from '@getcortexlabs/mavis-web'
17
- import Root from './generated/__MAVIS_ROOT__.vue'
103
+ import Root, { screen } from './generated/entry'
18
104
  import '@getcortexlabs/mavis-web/style.css'
19
105
  import './style.css'
20
106
 
21
- const app = createApp(Root)
107
+ // A screen with an MScreen of its own fills the window; any other gets a page around it.
108
+ const app = createApp(screen ? Root : () => h('main', { class: 'mavis-page' }, h(Root)))
22
109
  for (const [name, component] of Object.entries({
110
+ MScreen,
111
+ MCalendar,
112
+ MTimePicker,
113
+ MScheduler,
114
+ MDatePicker,
115
+ MDateRangePicker,
23
116
  MColumn,
24
117
  MRow,
118
+ MStack,
25
119
  MGrid,
120
+ MBox,
26
121
  MCard,
27
122
  MText,
123
+ MSpan,
124
+ MSeparator,
125
+ MThemeProvider,
126
+ MPlatform,
28
127
  MButton,
29
128
  MInput,
30
129
  MCheckbox,
31
130
  MSelect,
131
+ MMasonry,
132
+ MResizablePanels,
133
+ MVirtualList,
134
+ MCollapsibleHeader,
135
+ MRefreshControl,
136
+ MIcon,
137
+ MBadge,
138
+ MProgress,
139
+ MSkeleton,
140
+ MAlert,
141
+ MEmptyState,
142
+ MSwitch,
143
+ MSlider,
144
+ MSegmentedControl,
145
+ MRadioGroup,
146
+ MListItem,
147
+ MAccordion,
148
+ MTabs,
149
+ MSteps,
150
+ MPagination,
151
+ MSparkline,
152
+ MImage,
153
+ MSheet,
154
+ MChip,
155
+ MNumberInput,
156
+ MRangeSlider,
157
+ MMultiSelect,
158
+ MAvatar,
159
+ MDonutChart,
160
+ MGauge,
161
+ MTimeline,
162
+ MTreeView,
163
+ MBreadcrumb,
164
+ MAppBar,
165
+ MTabBar,
166
+ MNavigationRail,
167
+ MLink,
168
+ MDialog,
169
+ MCommandPalette,
170
+ MTooltip,
171
+ MToast,
172
+ MNotificationCenter,
173
+ MRating,
174
+ MPinInput,
175
+ MFormGroup,
176
+ MFormErrors,
177
+ MGradientBackground,
178
+ MCarousel,
179
+ MImageCompare,
180
+ MImageCropper,
181
+ MImageViewer,
182
+ MDataTable,
183
+ MSortableList,
184
+ MSwipeActions,
185
+ MSwipeDeck,
186
+ MKanban,
187
+ MCombobox,
188
+ MComposer,
189
+ MColorPicker,
190
+ MFilePicker,
191
+ MPopover,
192
+ MMenu,
193
+ MSpeedDial,
194
+ MTour,
195
+ MTourTarget,
196
+ MTransferList,
197
+ MTreeSelect,
198
+ MChart,
199
+ MHeatmap,
32
200
  MReveal,
201
+ MAnimatedText,
202
+ MNumberFlow,
203
+ MConfetti,
204
+ MParticleField,
205
+ MMarquee,
33
206
  }))
34
207
  app.component(name, component)
35
208
  app
@@ -0,0 +1,2 @@
1
+ // Resolved by this host. Shared screens import the renderer's public API from #mavis.
2
+ export * from '@getcortexlabs/mavis-web'