@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
@@ -0,0 +1,102 @@
1
+ import { Application, Page, GridLayout, type LayoutBase } from '@nativescript/core'
2
+ import { createNativeComponent } from '@getcortexlabs/mavis/native'
3
+ import { bridge, initial, theme, isolatedTheme, surface, type State } from './model'
4
+
5
+ export function start() {
6
+ Application.run({
7
+ create: () => {
8
+ let state: State = { ...initial }
9
+ const all: Array<{ dispose(): void }> = []
10
+ const create: typeof createNativeComponent = (name, props, options = {}) => {
11
+ const control = createNativeComponent(name, props, { theme, ...options })
12
+ all.push(control)
13
+ return control
14
+ }
15
+ const root = create('MColumn', {
16
+ id: 'catalog',
17
+ gap: 'md',
18
+ padding: 'lg',
19
+ height: '100%',
20
+ backgroundColor: theme.theme.colors.background,
21
+ })
22
+ const heading = create('MText', {
23
+ id: 'heading',
24
+ text: '__MAVIS_NAME__',
25
+ variant: 'title',
26
+ })
27
+ const row = create('MRow', { id: 'row', gap: 'sm' })
28
+ const button = create(
29
+ 'MButton',
30
+ { id: 'action', text: 'Count 0' },
31
+ { events: { activate: () => update({ count: state.count + 1 }) } },
32
+ )
33
+ const input = create(
34
+ 'MInput',
35
+ { id: 'editor', label: 'Name', modelValue: state.value },
36
+ { events: { valueChange: (value) => update({ value }) } },
37
+ )
38
+ const box = create('MBox', {
39
+ id: 'motion',
40
+ width: 100,
41
+ height: 30,
42
+ backgroundColor: '#4f46e5',
43
+ motionSurface: surface,
44
+ })
45
+ const separate = create(
46
+ 'MText',
47
+ { id: 'isolated', text: 'Independent theme' },
48
+ { theme: isolatedTheme },
49
+ )
50
+ const separateBox = create('MBox', {
51
+ padding: 'md',
52
+ radius: 'md',
53
+ backgroundColor: isolatedTheme.theme.colors.background,
54
+ })
55
+ separateBox.view.addChild(separate.view)
56
+ const offTheme = theme.subscribe(() =>
57
+ root.update({
58
+ id: 'catalog',
59
+ gap: 'md',
60
+ padding: 'lg',
61
+ height: '100%',
62
+ backgroundColor: theme.theme.colors.background,
63
+ }),
64
+ )
65
+ ;(row.view as LayoutBase).addChild(button.view)
66
+ for (const control of [heading, row, input, box, separateBox])
67
+ (root.view as LayoutBase).addChild(control.view)
68
+ function update(patch: Partial<State>) {
69
+ const before = state
70
+ state = { ...state, ...patch }
71
+ button.update({
72
+ id: 'action',
73
+ text: `Count ${state.count}`,
74
+ disabled: state.disabled,
75
+ loading: state.loading,
76
+ })
77
+ input.update({
78
+ id: 'editor',
79
+ label: 'Name',
80
+ modelValue: state.value,
81
+ disabled: state.disabled,
82
+ })
83
+ if (before.visible !== state.visible) {
84
+ if (state.visible) (root.view as LayoutBase).addChild(box.view)
85
+ else (root.view as LayoutBase).removeChild(box.view)
86
+ }
87
+ }
88
+ const page = new Page()
89
+ page.actionBarHidden = true
90
+ page.content = root.view
91
+ bridge.read = () => state
92
+ bridge.update = update
93
+ bridge.focus = input.focus
94
+ bridge.dispose = () => {
95
+ page.content = new GridLayout()
96
+ offTheme()
97
+ all.forEach((control) => control.dispose())
98
+ }
99
+ return page
100
+ },
101
+ })
102
+ }
@@ -0,0 +1,83 @@
1
+ import { Application, type View } from '@nativescript/core'
2
+ import { createElement as h, useState, useRef, useEffect } from 'react'
3
+ import { NSVRoot, render, unmountComponentAtNode } from 'react-nativescript'
4
+ import {
5
+ MColumn,
6
+ MRow,
7
+ MBox,
8
+ MText,
9
+ MButton,
10
+ MInput,
11
+ MThemeProvider,
12
+ type MavisComponentHandle,
13
+ } from '@getcortexlabs/mavis-react-nativescript'
14
+ import { bridge, initial, theme, isolatedTheme, surface } from './model'
15
+
16
+ function Catalog() {
17
+ const [state, setState] = useState(initial)
18
+ const [background, setBackground] = useState(theme.theme.colors.background)
19
+ useEffect(() => theme.subscribe(() => setBackground(theme.theme.colors.background)), [])
20
+ const input = useRef<MavisComponentHandle>(null)
21
+ bridge.read = () => state
22
+ bridge.update = (patch) => setState((value) => ({ ...value, ...patch }))
23
+ bridge.focus = () => input.current?.focus()
24
+ return h(
25
+ 'page',
26
+ { actionBarHidden: true },
27
+ h(
28
+ MThemeProvider,
29
+ { theme },
30
+ h(
31
+ MColumn,
32
+ { id: 'catalog', gap: 'md', padding: 'lg', height: '100%', backgroundColor: background },
33
+ h(MText, { id: 'heading', variant: 'title' }, '__MAVIS_NAME__'),
34
+ h(
35
+ MRow,
36
+ { id: 'row', gap: 'sm' },
37
+ h(
38
+ MButton,
39
+ {
40
+ id: 'action',
41
+ disabled: state.disabled,
42
+ loading: state.loading,
43
+ onClick: () => bridge.update?.({ count: state.count + 1 }),
44
+ },
45
+ `Count ${state.count}`,
46
+ ),
47
+ ),
48
+ h(MInput, {
49
+ id: 'editor',
50
+ label: 'Name',
51
+ modelValue: state.value,
52
+ disabled: state.disabled,
53
+ onValueChange: (value) => bridge.update?.({ value }),
54
+ ref: input,
55
+ }),
56
+ state.visible
57
+ ? h(MBox, {
58
+ id: 'motion',
59
+ width: 100,
60
+ height: 30,
61
+ backgroundColor: '#4f46e5',
62
+ motionSurface: surface,
63
+ })
64
+ : null,
65
+ h(
66
+ MBox,
67
+ { padding: 'md', radius: 'md', backgroundColor: isolatedTheme.theme.colors.background },
68
+ h(MText, { id: 'isolated', theme: isolatedTheme, text: 'Independent theme' }),
69
+ ),
70
+ ),
71
+ ),
72
+ )
73
+ }
74
+ export function start() {
75
+ Application.run({
76
+ create: () => {
77
+ const root = new NSVRoot()
78
+ render(h(Catalog), root, undefined, 'mavis-adapters')
79
+ bridge.dispose = () => unmountComponentAtNode('mavis-adapters')
80
+ return root.baseRef!.nativeView as View
81
+ },
82
+ })
83
+ }
@@ -0,0 +1,111 @@
1
+ import { Application } from '@nativescript/core'
2
+ import { createSignal, createComponent, Show, onCleanup } from 'solid-js'
3
+ import { createElement, render } from '@nativescript-community/solid-js'
4
+ import {
5
+ MColumn,
6
+ MRow,
7
+ MBox,
8
+ MText,
9
+ MButton,
10
+ MInput,
11
+ MThemeProvider,
12
+ } from '@getcortexlabs/mavis-solid-nativescript'
13
+ import { bridge, initial, theme, isolatedTheme, surface } from './model'
14
+
15
+ export function start() {
16
+ Application.run({
17
+ create: () => {
18
+ const page = createElement('page', { actionBarHidden: true })
19
+ const dispose = render(() => {
20
+ const [state, setState] = createSignal(initial)
21
+ const [background, setBackground] = createSignal(theme.theme.colors.background)
22
+ onCleanup(theme.subscribe(() => setBackground(theme.theme.colors.background)))
23
+ bridge.read = state
24
+ bridge.update = (patch) => setState((value) => ({ ...value, ...patch }))
25
+ return createComponent(MThemeProvider, {
26
+ theme,
27
+ get children() {
28
+ return createComponent(MColumn, {
29
+ id: 'catalog',
30
+ gap: 'md',
31
+ padding: 'lg',
32
+ height: '100%',
33
+ get backgroundColor() {
34
+ return background()
35
+ },
36
+ get children() {
37
+ return [
38
+ createComponent(MText, {
39
+ id: 'heading',
40
+ text: '__MAVIS_NAME__',
41
+ variant: 'title',
42
+ }),
43
+ createComponent(MRow, {
44
+ id: 'row',
45
+ gap: 'sm',
46
+ get children() {
47
+ return createComponent(MButton, {
48
+ id: 'action',
49
+ get text() {
50
+ return `Count ${state().count}`
51
+ },
52
+ get disabled() {
53
+ return state().disabled
54
+ },
55
+ get loading() {
56
+ return state().loading
57
+ },
58
+ onClick: () => bridge.update?.({ count: state().count + 1 }),
59
+ })
60
+ },
61
+ }),
62
+ createComponent(MInput, {
63
+ id: 'editor',
64
+ label: 'Name',
65
+ get modelValue() {
66
+ return state().value
67
+ },
68
+ get disabled() {
69
+ return state().disabled
70
+ },
71
+ onValueChange: (value) => bridge.update?.({ value }),
72
+ ref: (view) => {
73
+ bridge.focus = () => view.focusInput()
74
+ },
75
+ }),
76
+ createComponent(Show, {
77
+ get when() {
78
+ return state().visible
79
+ },
80
+ children: () =>
81
+ createComponent(MBox, {
82
+ id: 'motion',
83
+ width: 100,
84
+ height: 30,
85
+ backgroundColor: '#4f46e5',
86
+ motionSurface: surface,
87
+ }),
88
+ }),
89
+ createComponent(MBox, {
90
+ padding: 'md',
91
+ radius: 'md',
92
+ backgroundColor: isolatedTheme.theme.colors.background,
93
+ get children() {
94
+ return createComponent(MText, {
95
+ id: 'isolated',
96
+ text: 'Independent theme',
97
+ theme: isolatedTheme,
98
+ })
99
+ },
100
+ }),
101
+ ]
102
+ },
103
+ })
104
+ },
105
+ })
106
+ }, page)
107
+ bridge.dispose = dispose
108
+ return page
109
+ },
110
+ })
111
+ }
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ import { onDestroy } from 'svelte'
3
+ import { MColumn, MRow, MBox, MText, MButton, MInput, MThemeProvider } from '@getcortexlabs/mavis-svelte-nativescript'
4
+ import { bridge, initial, theme, isolatedTheme, surface } from './model'
5
+ let state = { ...initial }
6
+ let background = theme.theme.colors.background
7
+ onDestroy(theme.subscribe(() => background = theme.theme.colors.background))
8
+ let input: MInput
9
+ bridge.read = () => state
10
+ bridge.update = patch => { state = { ...state, ...patch } }
11
+ bridge.focus = () => input?.focusInput()
12
+ </script>
13
+
14
+ <page actionBarHidden={true}>
15
+ <MThemeProvider {theme}>
16
+ <MColumn id="catalog" gap="md" padding="lg" height="100%" backgroundColor={background}>
17
+ <MText id="heading" variant="title">__MAVIS_NAME__</MText>
18
+ <MRow id="row" gap="sm">
19
+ <MButton id="action" disabled={state.disabled} loading={state.loading} on:click={() => bridge.update?.({ count: state.count + 1 })}>Count {state.count}</MButton>
20
+ </MRow>
21
+ <MInput id="editor" label="Name" modelValue={state.value} disabled={state.disabled} on:valueChange={event => bridge.update?.({ value: event.detail })} bind:this={input} />
22
+ {#if state.visible}<MBox id="motion" width={100} height={30} backgroundColor="#4f46e5" motionSurface={surface} />{/if}
23
+ <MBox padding="md" radius="md" backgroundColor={isolatedTheme.theme.colors.background}><MText id="isolated" theme={isolatedTheme} text="Independent theme" /></MBox>
24
+ </MColumn>
25
+ </MThemeProvider>
26
+ </page>
@@ -0,0 +1,14 @@
1
+ import { svelteNative } from '@nativescript-community/svelte-native'
2
+ import Catalog from './Welcome.svelte'
3
+ import { bridge } from './model'
4
+ class OwnedCatalog extends Catalog {
5
+ constructor(options: ConstructorParameters<typeof Catalog>[0]) {
6
+ super(options)
7
+ // Core 9 can emit launch before Svelte Native resolves its page instance.
8
+ // Take disposal ownership from the actual public component constructor.
9
+ bridge.dispose = () => this.$destroy()
10
+ }
11
+ }
12
+ export function start() {
13
+ void svelteNative(OwnedCatalog, {})
14
+ }
@@ -0,0 +1,20 @@
1
+ // Use the project's pinned TypeScript for both svelte-check and webpack.
2
+ // svelte-check's default preprocessor can resolve a different TypeScript peer.
3
+ const ts = require('typescript')
4
+ module.exports = {
5
+ preprocess: {
6
+ script: ({ content, attributes, filename }) => {
7
+ if (attributes.lang !== 'ts') return undefined
8
+ const result = ts.transpileModule(content, {
9
+ fileName: filename,
10
+ compilerOptions: {
11
+ target: ts.ScriptTarget.ES2022,
12
+ module: ts.ModuleKind.ESNext,
13
+ verbatimModuleSyntax: true,
14
+ sourceMap: true,
15
+ },
16
+ })
17
+ return { code: result.outputText, map: result.sourceMapText }
18
+ },
19
+ },
20
+ }