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

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 (46) hide show
  1. package/README.md +26 -5
  2. package/package.json +4 -2
  3. package/src/adapters.mjs +7 -0
  4. package/src/add-macos.mjs +386 -0
  5. package/src/capabilities.mjs +78 -57
  6. package/src/cli.mjs +86 -4
  7. package/src/doctor.mjs +100 -18
  8. package/src/macos-capabilities.generated.mjs +4190 -0
  9. package/src/macos.mjs +147 -29
  10. package/src/migrate-directory.mjs +121 -0
  11. package/src/portability.mjs +108 -5
  12. package/src/scaffold.mjs +21 -2
  13. package/src/ui.mjs +21 -12
  14. package/templates/directory/host/directory-storage.ts +78 -0
  15. package/templates/directory/macos/DirectoryStorage.swift +68 -0
  16. package/templates/directory/mobile/src/app.ts +11 -8
  17. package/templates/directory/nuxt/app/plugins/mavis.ts +11 -8
  18. package/templates/directory/shared/Edit.vue +8 -5
  19. package/templates/directory/shared/directory-store.ts +42 -46
  20. package/templates/directory/vite/src/main.ts +11 -8
  21. package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +2 -2
  22. package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +2 -2
  23. package/templates/macos/examples/tasks/shared/types.ts +1 -0
  24. package/templates/macos/mobile/src/App.vue +4 -2
  25. package/templates/macos/native/Package.swift +3 -1
  26. package/templates/macos/native/Sources/MavisDesktop/App.swift +26 -11
  27. package/templates/macos/native/Sources/MavisDesktop/Fonts/LICENSE +45 -0
  28. package/templates/macos/native/Sources/MavisDesktop/Fonts/lucide.ttf +0 -0
  29. package/templates/macos/scripts/generate.mjs +3 -26
  30. package/templates/macos/scripts/macos-manifest.mjs +33 -0
  31. package/templates/macos/scripts/macos.mjs +20 -18
  32. package/templates/macos/web/index.html +1 -1
  33. package/templates/macos/web/src/main.js +176 -3
  34. package/templates/macos/web/src/mavis.js +2 -0
  35. package/templates/macos/web/src/style.css +2 -1
  36. package/templates/macos/web/vite.config.mjs +12 -1
  37. package/templates/migrations/directory-rc13.json +36 -0
  38. package/templates/mobile/src/mavis.ts +2 -82
  39. package/templates/mobile/webpack.config.js +4 -0
  40. package/templates/nuxt/app/mavis.ts +2 -84
  41. package/templates/vite/src/mavis.ts +2 -84
  42. package/templates/macos/scripts/portable/emit-swift.mjs +0 -1287
  43. package/templates/macos/scripts/portable/emit-vue.mjs +0 -615
  44. package/templates/macos/scripts/portable/index.mjs +0 -95
  45. package/templates/macos/scripts/portable/model.mjs +0 -1441
  46. package/templates/macos/scripts/portable/program.mjs +0 -163
package/src/ui.mjs CHANGED
@@ -33,17 +33,22 @@ export function projectSummary(preset, install) {
33
33
  `Project ${preset.name}`,
34
34
  `Targets ${targetLabel(preset.targets)} · EXPERIMENTAL`,
35
35
  `Hosts ${[
36
- preset.targets.includes('web') && 'Vue + Vite',
36
+ preset.targets.includes('web') &&
37
+ (preset.web === 'nuxt' ? `Nuxt · ${preset.rendering.toUpperCase()}` : 'Vue + Vite'),
37
38
  preset.targets.includes('native') && 'NativeScript iOS + Android',
38
39
  preset.targets.includes('macos') && 'SwiftUI macOS',
39
40
  ]
40
41
  .filter(Boolean)
41
42
  .join(' · ')}`,
42
- 'Authoring Shared TSX (shared/*.lite.tsx), compiled for each target',
43
+ preset.authoring === 'vue'
44
+ ? 'Authoring Shared Vue (shared/*.vue), compiled to SwiftUI for Mac'
45
+ : 'Authoring Shared TSX (shared/*.lite.tsx), compiled for each target',
43
46
  ...status(preset),
44
- preset.example === 'tasks'
45
- ? 'Example Tasks · list and detail, forms, shortcuts and motion · shared/Tasks.lite.tsx'
46
- : 'Example Basic welcome · shared/Welcome.lite.tsx',
47
+ preset.example === 'directory'
48
+ ? 'Example Search, details and editing · shared/Directory.vue'
49
+ : preset.example === 'tasks'
50
+ ? 'Example Tasks · list and detail, forms, shortcuts and motion · shared/Tasks.lite.tsx'
51
+ : 'Example Basic welcome · shared/Welcome.lite.tsx',
47
52
  `Theme ${preset.theme === 'midnight' ? 'Midnight · dark' : 'Mavis · light'}`,
48
53
  `Packages ${preset.packageManager} · ${install ? 'install now' : 'install later'}`,
49
54
  ].join('\n')
@@ -60,7 +65,9 @@ export function projectSummary(preset, install) {
60
65
 
61
66
  export function sharedEntry(preset) {
62
67
  if (preset.target === 'macos')
63
- return `shared/${preset.example === 'tasks' ? 'Tasks' : 'Welcome'}.lite.tsx`
68
+ return preset.example === 'directory'
69
+ ? 'shared/Directory.vue'
70
+ : `shared/${preset.example === 'tasks' ? 'Tasks' : 'Welcome'}.lite.tsx`
64
71
  const directory =
65
72
  preset.target === 'both' ? 'shared' : preset.web === 'nuxt' ? 'app/shared' : 'src/shared'
66
73
  return `${directory}/${preset.example === 'directory' ? 'Directory' : 'Welcome'}.vue`
@@ -166,7 +173,7 @@ export async function wizard(initial, signal, io = prompts, check = checkPackage
166
173
  {
167
174
  key: 'web',
168
175
  message: 'Choose your web setup',
169
- when: () => targets().includes('web') && !targets().includes('macos'),
176
+ when: () => targets().includes('web'),
170
177
  // A --rendering flag leaves only the hosts that can serve it.
171
178
  options: choices(
172
179
  catalog.hosts,
@@ -192,10 +199,12 @@ export async function wizard(initial, signal, io = prompts, check = checkPackage
192
199
  options: () =>
193
200
  choices(
194
201
  catalog.examples,
195
- Object.keys(catalog.examples).filter((example) =>
196
- catalog.examples[example].authoring.includes(
197
- targets().includes('macos') ? 'mitosis' : 'vue',
198
- ),
202
+ Object.keys(catalog.examples).filter(
203
+ (example) =>
204
+ catalog.examples[example].authoring.includes(
205
+ targets().includes('macos') ? 'mitosis' : 'vue',
206
+ ) ||
207
+ (targets().includes('macos') && catalog.examples[example].portableAuthoring),
199
208
  ),
200
209
  ),
201
210
  },
@@ -316,7 +325,7 @@ export async function wizard(initial, signal, io = prompts, check = checkPackage
316
325
  }
317
326
  if (value.includes('macos'))
318
327
  io.log.message(
319
- `Shared screens will be TSX (shared/*.lite.tsx), compiled for ${value.join(', ')}.${value.includes('web') ? ' The Web app uses Vue + Vite: Nuxt needs server rendering in the compiler, which is not there yet.' : ''}`,
328
+ `The Mac app uses generated SwiftUI. Choose shared TSX or the Directory example with shared Vue screens. Web can use Vue + Vite or Nuxt.`,
320
329
  )
321
330
  }
322
331
  answers[step.key] = value
@@ -0,0 +1,78 @@
1
+ import {
2
+ directorySeed,
3
+ validDirectoryEntries,
4
+ type DirectoryEntry,
5
+ type DirectorySnapshot,
6
+ type DirectoryStorage,
7
+ } from '../shared/directory-store'
8
+
9
+ export interface DirectoryPersistence {
10
+ read(): Promise<string | null>
11
+ write(value: string): Promise<void>
12
+ }
13
+
14
+ /** Host boundary: JSON and the write queue stay out of the shared screen/store. */
15
+ export function createDirectoryStorage(persistence: DirectoryPersistence): DirectoryStorage {
16
+ let entries = directorySeed.map((entry) => ({ ...entry }))
17
+ let revision = 0
18
+ let loadError = false
19
+ let restoring: Promise<void> | undefined
20
+ let writing = Promise.resolve()
21
+ const snapshot = (): DirectorySnapshot => ({
22
+ entries: entries.map((entry) => ({ ...entry })),
23
+ revision,
24
+ loadError,
25
+ })
26
+ const restore = () =>
27
+ (restoring ??= (async () => {
28
+ try {
29
+ const value = await persistence.read()
30
+ if (value === null) return
31
+ const parsed: unknown = JSON.parse(value)
32
+ if (
33
+ !Array.isArray(parsed) ||
34
+ !parsed.every(
35
+ (entry) =>
36
+ entry !== null &&
37
+ typeof entry === 'object' &&
38
+ typeof entry.id === 'string' &&
39
+ typeof entry.name === 'string' &&
40
+ typeof entry.city === 'string',
41
+ ) ||
42
+ !validDirectoryEntries(parsed)
43
+ )
44
+ throw new Error('Invalid saved directory')
45
+ entries = (parsed as DirectoryEntry[]).map(({ id, name, city }) => ({ id, name, city }))
46
+ } catch {
47
+ loadError = true
48
+ }
49
+ })())
50
+ return {
51
+ async load() {
52
+ await restore()
53
+ return snapshot()
54
+ },
55
+ rename(id, name) {
56
+ const operation = writing
57
+ .catch(() => {})
58
+ .then(async () => {
59
+ await restore()
60
+ if (!name.trim() || !entries.some((entry) => entry.id === id))
61
+ throw new Error('Invalid entry')
62
+ const next = entries.map((entry) =>
63
+ entry.id === id ? { ...entry, name: name.trim() } : { ...entry },
64
+ )
65
+ await persistence.write(JSON.stringify(next))
66
+ entries = next
67
+ revision += 1
68
+ return snapshot()
69
+ })
70
+ // A failed write does not poison the queue or change the committed state.
71
+ writing = operation.then(
72
+ () => {},
73
+ () => {},
74
+ )
75
+ return operation
76
+ },
77
+ }
78
+ }
@@ -0,0 +1,68 @@
1
+ import Foundation
2
+
3
+ /// One instance per app. Uses the same JSON array and key as the Web and NativeScript hosts.
4
+ @MainActor final class UserDefaultsDirectoryStorage: DirectoryStorage {
5
+ private let defaults: UserDefaults
6
+ private let key: String
7
+ private var entries = DirectoryStoreModule.directorySeed
8
+ private var loaded = false
9
+ private var revision: Double = 0
10
+ private var loadError = false
11
+
12
+ init(defaults: UserDefaults = .standard, key: String = "mavis:directory") {
13
+ self.defaults = defaults
14
+ self.key = key
15
+ }
16
+
17
+ private func snapshot() -> DirectorySnapshot {
18
+ DirectorySnapshot(entries: entries, revision: revision, loadError: loadError)
19
+ }
20
+
21
+ private func restore() {
22
+ guard !loaded else { return }
23
+ loaded = true
24
+ guard let text = defaults.string(forKey: key) else { return }
25
+ do {
26
+ guard let data = text.data(using: .utf8),
27
+ let values = try JSONSerialization.jsonObject(with: data) as? [[String: Any]]
28
+ else { throw MavisFailure(message: "Invalid saved directory") }
29
+ let decoded = try values.map { value -> DirectoryEntry in
30
+ guard let id = value["id"] as? String,
31
+ let name = value["name"] as? String,
32
+ let city = value["city"] as? String
33
+ else { throw MavisFailure(message: "Invalid saved directory") }
34
+ return DirectoryEntry(id: id, name: name, city: city)
35
+ }
36
+ guard DirectoryStoreModule.validDirectoryEntries(decoded)
37
+ else { throw MavisFailure(message: "Invalid saved directory") }
38
+ entries = decoded
39
+ } catch {
40
+ loadError = true
41
+ }
42
+ }
43
+
44
+ func load() async throws -> DirectorySnapshot {
45
+ restore()
46
+ return snapshot()
47
+ }
48
+
49
+ func rename(_ id: String, _ name: String) async throws -> DirectorySnapshot {
50
+ // This operation has no suspension: MainActor serializes restore/edit/write/commit.
51
+ restore()
52
+ let trimmed = mavisTrim(name)
53
+ guard !trimmed.isEmpty, entries.contains(where: { $0.id == id })
54
+ else { throw MavisFailure(message: "Invalid entry") }
55
+ let next = entries.map { entry in
56
+ DirectoryEntry(id: entry.id, name: entry.id == id ? trimmed : entry.name, city: entry.city)
57
+ }
58
+ let data = try JSONSerialization.data(withJSONObject: next.map {
59
+ ["id": $0.id, "name": $0.name, "city": $0.city]
60
+ })
61
+ guard let text = String(data: data, encoding: .utf8)
62
+ else { throw MavisFailure(message: "Could not encode directory") }
63
+ defaults.set(text, forKey: key)
64
+ entries = next
65
+ revision += 1
66
+ return snapshot()
67
+ }
68
+ }
@@ -6,16 +6,19 @@ import { createRouterNavigation, mavis, midnight } from '@getcortexlabs/mavis-co
6
6
  import { createDirectory, directoryKey } from '__MAVIS_SHARED__/directory-store'
7
7
  import { routes } from '__MAVIS_SHARED__/routes'
8
8
  import App from './App.vue'
9
+ import { createDirectoryStorage } from './directory-storage'
9
10
 
10
11
  const router = createRouter({ routes })
11
- const directory = createDirectory({
12
- async read() {
13
- return ApplicationSettings.getString('mavis:directory', '') || null
14
- },
15
- async write(value) {
16
- ApplicationSettings.setString('mavis:directory', value)
17
- },
18
- })
12
+ const directory = createDirectory(
13
+ createDirectoryStorage({
14
+ async read() {
15
+ return ApplicationSettings.getString('mavis:directory', '') || null
16
+ },
17
+ async write(value) {
18
+ ApplicationSettings.setString('mavis:directory', value)
19
+ },
20
+ }),
21
+ )
19
22
  createApp(App)
20
23
  .use(router)
21
24
  .use(
@@ -2,6 +2,7 @@ import { createMavisServices } from '@getcortexlabs/mavis-web/services'
2
2
  import { createRouterNavigation, mavis, midnight } from '@getcortexlabs/mavis-core'
3
3
  import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
4
4
  import { createDirectory, directoryKey } from '__MAVIS_SHARED__/directory-store'
5
+ import { createDirectoryStorage } from '../utils/directory-storage'
5
6
 
6
7
  export default defineNuxtPlugin(({ vueApp, $router }) => {
7
8
  const saved = useCookie<string>('appearance')
@@ -18,14 +19,16 @@ export default defineNuxtPlugin(({ vueApp, $router }) => {
18
19
  )
19
20
  const theme = vueApp.runWithContext(useMavisTheme)
20
21
  // Each server request has its own store. Storage is accessed only after hydration.
21
- const directory = createDirectory({
22
- async read() {
23
- return localStorage.getItem('mavis:directory')
24
- },
25
- async write(value) {
26
- localStorage.setItem('mavis:directory', value)
27
- },
28
- })
22
+ const directory = createDirectory(
23
+ createDirectoryStorage({
24
+ async read() {
25
+ return localStorage.getItem('mavis:directory')
26
+ },
27
+ async write(value) {
28
+ localStorage.setItem('mavis:directory', value)
29
+ },
30
+ }),
31
+ )
29
32
  vueApp.provide(directoryKey, directory)
30
33
  onNuxtReady(() => {
31
34
  theme.setAppearance(saved.value === 'dark' || saved.value === 'light' ? saved.value : 'system')
@@ -20,9 +20,12 @@ const dirty = ref(false),
20
20
  saving = ref(false),
21
21
  saved = ref(false),
22
22
  error = ref('')
23
- watch(entry, (value) => {
24
- if (!dirty.value) name.value = value?.name ?? ''
25
- })
23
+ watch(
24
+ () => entry.value?.name ?? '',
25
+ (value) => {
26
+ if (!dirty.value) name.value = value
27
+ },
28
+ )
26
29
  watch(
27
30
  () => props.id,
28
31
  () => {
@@ -38,8 +41,8 @@ function edit() {
38
41
  }
39
42
  async function save() {
40
43
  if (saving.value || !name.value.trim()) return
41
- const id = props.id,
42
- draft = name.value
44
+ const id = props.id
45
+ const draft = name.value
43
46
  saving.value = true
44
47
  saved.value = false
45
48
  error.value = ''
@@ -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