@getcortexlabs/create-mavis 0.1.0-rc.14 → 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.
- package/README.md +25 -9
- package/package.json +2 -2
- package/src/adapters.mjs +49 -20
- package/src/add-desktop.mjs +308 -0
- package/src/add-macos.mjs +3 -3
- package/src/capabilities.mjs +288 -42
- package/src/cli.mjs +98 -8
- package/src/desktop.mjs +155 -0
- package/src/doctor.mjs +86 -5
- package/src/native-framework.mjs +144 -0
- package/src/portability.mjs +22 -7
- package/src/scaffold.mjs +38 -9
- package/src/ui.mjs +51 -3
- package/templates/desktop/common/LICENSE +21 -0
- package/templates/desktop/common/build.mjs +58 -0
- package/templates/desktop/common/src/components.ts +60 -0
- package/templates/desktop/common/src/contract.mjs +35 -0
- package/templates/desktop/common/src/renderer.ts +76 -0
- package/templates/desktop/common/src/storage.ts +29 -0
- package/templates/desktop/directory/main.ts +35 -0
- package/templates/desktop/macos/launch.mjs +6 -0
- package/templates/desktop/macos/package.mjs +114 -0
- package/templates/desktop/macos/src/host.mjs +468 -0
- package/templates/desktop/macos/src/motion.mjs +51 -0
- package/templates/desktop/welcome/Welcome.vue +56 -0
- package/templates/desktop/welcome/main.ts +24 -0
- package/templates/desktop/windows/NativeScript-LICENSE +19 -0
- package/templates/desktop/windows/launch.mjs +16 -0
- package/templates/desktop/windows/package.mjs +54 -0
- package/templates/desktop/windows/prepare-host.mjs +73 -0
- package/templates/desktop/windows/src/host.mjs +277 -0
- package/templates/native-framework/angular/screen.ts +84 -0
- package/templates/native-framework/common/nativescript.config.ts +6 -0
- package/templates/native-framework/common/src/app.ts +5 -0
- package/templates/native-framework/common/src/model.ts +40 -0
- package/templates/native-framework/common/src/references.d.ts +8 -0
- package/templates/native-framework/common/tsconfig.json +16 -0
- package/templates/native-framework/common/webpack.config.js +67 -0
- package/templates/native-framework/plain/screen.ts +102 -0
- package/templates/native-framework/react/screen.ts +83 -0
- package/templates/native-framework/solid/screen.ts +111 -0
- package/templates/native-framework/svelte/Welcome.svelte +26 -0
- package/templates/native-framework/svelte/screen.ts +14 -0
- package/templates/native-framework/svelte-tooling/svelte.config.js +20 -0
|
@@ -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
|
+
}
|