@getcortexlabs/create-mavis 0.1.0-alpha.9 → 0.1.0-rc.12
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 +6 -2
- package/package.json +2 -2
- package/src/add-target.mjs +367 -0
- package/src/cli.mjs +114 -2
- package/src/portability.mjs +17 -2
- package/src/presets.mjs +4 -2
- package/src/scaffold.mjs +11 -0
- package/src/shared-api.mjs +57 -11
- package/templates/mobile/src/mavis.ts +27 -0
- package/templates/nuxt/app/mavis.ts +27 -0
- package/templates/nuxt/nuxt.config.ts +11 -0
- package/templates/shared/Welcome.vue +101 -31
- package/templates/vite/src/mavis.ts +27 -0
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ pnpm install
|
|
|
21
21
|
pnpm run dev
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
The wizard, package-manager selection and both examples are included in
|
|
24
|
+
The wizard, package-manager selection and both examples are included in RC.12.
|
|
25
25
|
|
|
26
26
|
- `--dry-run` prints the file plan without writing or installing.
|
|
27
27
|
- Existing directories are never merged or overwritten.
|
|
@@ -31,7 +31,7 @@ The wizard, package-manager selection and both examples are included in alpha.9.
|
|
|
31
31
|
|
|
32
32
|
Node.js 22.16+ is required. Native projects also need the NativeScript CLI and the platform SDK. iOS requires macOS and Xcode. A shared project keeps native dependencies separate from its Web workspace so each renderer loads the correct Vue runtime.
|
|
33
33
|
|
|
34
|
-
Templates pin **Mavis 0.1.0-
|
|
34
|
+
Templates pin **Mavis 0.1.0-rc.12** and **Jolt 0.1.0-rc.11.1**. The CLI and its generated projects use the same Mavis release. Commit the generated lockfile (both lockfiles for a shared project).
|
|
35
35
|
|
|
36
36
|
pnpm requires **10.26+**. Its generated workspace files keep the mobile installation separate, use a hoisted layout for Vite deduplication, shared imports and NativeScript, and allow only the starter's required dependency build scripts. Yarn Classic and modern Yarn use `node_modules`; initial empty `yarn.lock` files mark separate projects before installation. The starter declares its dependency build scripts explicitly; other package-manager policies remain in effect. If modern Yarn reports a fresh dependency as quarantined, retry after its configured minimum package age. Do not add `apps/mobile` to the Web workspace.
|
|
37
37
|
|
|
@@ -44,3 +44,7 @@ MIT · [Mavis UI](https://github.com/getcortexlabs/mavis-ui)
|
|
|
44
44
|
`#mavis` resolves shared named imports and types for Vue + Vite SPA, Nuxt SSR/SSG and NativeScript iOS/Android. The new `--example directory` adds shared search, details, editing, persistence and automatic navigation through an app-owned router adapter.
|
|
45
45
|
|
|
46
46
|
`--check-portability` reports platform dependencies with locations. `--fix-imports` previews safe named-import changes to `#mavis`; add `--write` to apply. `--path` selects a source directory and `--json` emits structured diagnostics. `--doctor` also runs this source audit. Unknown dependencies, HTML/CSS and device services still require review and target tests.
|
|
47
|
+
|
|
48
|
+
## Add a host to an existing Mavis application (RC.12)
|
|
49
|
+
|
|
50
|
+
Run `create-mavis --add-native` in a Vue + Vite/Nuxt package, or `create-mavis --add-web [--web nuxt]` in a NativeScript-Vue package. Use `--dry-run` to inspect the plan and `--screen path/to/Screen.vue` to reuse an existing screen without moving it. The command creates an isolated host under `apps`, adds root launch/install scripts and preserves existing source/configuration/lockfiles. Dependencies install only with `--install`; npm, pnpm and Yarn are supported. Conflicts and unsupported workspaces/version baselines are reported before writing. The selected screen's services, aliases and router remain application-owned; portability diagnostics are not automatic conversion. Upgrade the existing Mavis renderer to RC.12 before adding a host.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getcortexlabs/create-mavis",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-rc.12",
|
|
4
4
|
"description": "Create Vue Web, Nuxt and NativeScript projects with Mavis UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public",
|
|
27
|
-
"tag": "
|
|
27
|
+
"tag": "rc"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@vue/compiler-sfc": "3.5.44",
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { lstat, mkdir, mkdtemp, readFile, rename, rm, rmdir, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
3
|
+
import { parse } from '@vue/compiler-sfc'
|
|
4
|
+
import { projectFiles } from './scaffold.mjs'
|
|
5
|
+
import { versions } from './presets.mjs'
|
|
6
|
+
import { checkPortability } from './portability.mjs'
|
|
7
|
+
import { detectPackageManager, packageCommands } from './package-manager.mjs'
|
|
8
|
+
|
|
9
|
+
const json = (value) => JSON.stringify(value, null, 2) + '\n'
|
|
10
|
+
const posix = (path) => path.split(sep).join('/')
|
|
11
|
+
async function optional(path) {
|
|
12
|
+
try {
|
|
13
|
+
return await readFile(path, 'utf8')
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (error.code !== 'ENOENT') throw error
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function safePath(root, name) {
|
|
19
|
+
const path = resolve(root, name),
|
|
20
|
+
rel = relative(root, path)
|
|
21
|
+
if (!rel || isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`))
|
|
22
|
+
throw new Error('Paths must stay inside the existing project.')
|
|
23
|
+
let current = root
|
|
24
|
+
for (const part of rel.split(sep)) {
|
|
25
|
+
current = join(current, part)
|
|
26
|
+
try {
|
|
27
|
+
if ((await lstat(current)).isSymbolicLink()) throw new Error(`Refusing symlink: ${current}`)
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (error.code !== 'ENOENT') throw error
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return path
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Add an isolated host; the original application is never treated as a template. */
|
|
36
|
+
export async function planTarget(options, cwd = process.cwd()) {
|
|
37
|
+
const root = resolve(cwd)
|
|
38
|
+
const packageFile = await safePath(root, 'package.json')
|
|
39
|
+
const original = await readFile(packageFile, 'utf8'),
|
|
40
|
+
pkg = JSON.parse(original)
|
|
41
|
+
const deps = { ...pkg.devDependencies, ...pkg.dependencies }
|
|
42
|
+
const target = options.target
|
|
43
|
+
if (!['mobile', 'web'].includes(target)) throw new Error('Choose --add-native or --add-web.')
|
|
44
|
+
const source = deps.nuxt
|
|
45
|
+
? 'nuxt'
|
|
46
|
+
: deps.vite && deps.vue
|
|
47
|
+
? 'vite'
|
|
48
|
+
: deps['nativescript-vue'] && deps['@nativescript/core']
|
|
49
|
+
? 'mobile'
|
|
50
|
+
: null
|
|
51
|
+
if (!source || (target === 'mobile' ? source === 'mobile' : source !== 'mobile'))
|
|
52
|
+
throw new Error(
|
|
53
|
+
target === 'mobile'
|
|
54
|
+
? '--add-native needs an existing Vue + Vite or Nuxt package.'
|
|
55
|
+
: '--add-web needs an existing NativeScript-Vue package.',
|
|
56
|
+
)
|
|
57
|
+
// A root workspace can later absorb the new renderer during root installation.
|
|
58
|
+
// Work inside a concrete host package instead of changing workspace ownership.
|
|
59
|
+
const workspace = await optional(join(root, 'pnpm-workspace.yaml'))
|
|
60
|
+
if (
|
|
61
|
+
pkg.workspaces?.length ||
|
|
62
|
+
pkg.workspaces?.packages?.length ||
|
|
63
|
+
(workspace && !/^packages:\s*\[\s*\]/m.test(workspace))
|
|
64
|
+
)
|
|
65
|
+
throw new Error(
|
|
66
|
+
'Run this command inside a standalone host package; a workspace root needs an explicit isolation plan.',
|
|
67
|
+
)
|
|
68
|
+
const mavis = deps[target === 'mobile' ? '@getcortexlabs/mavis-web' : '@getcortexlabs/mavis']
|
|
69
|
+
if (!mavis || ![versions.mavis, `^${versions.mavis}`, `~${versions.mavis}`].includes(mavis))
|
|
70
|
+
throw new Error(
|
|
71
|
+
`This creator supports Mavis ${versions.mavis}. Align the existing renderer first; no dependencies were changed.`,
|
|
72
|
+
)
|
|
73
|
+
const locks = []
|
|
74
|
+
for (const [name, file] of [
|
|
75
|
+
['npm', 'package-lock.json'],
|
|
76
|
+
['pnpm', 'pnpm-lock.yaml'],
|
|
77
|
+
['yarn', 'yarn.lock'],
|
|
78
|
+
])
|
|
79
|
+
if ((await optional(join(root, file))) !== undefined) locks.push(name)
|
|
80
|
+
const declaredManager = pkg.packageManager?.split('@')[0]
|
|
81
|
+
if (!options.packageManager && !declaredManager && locks.length > 1)
|
|
82
|
+
throw new Error('Multiple lockfiles found. Choose --package-manager npm, pnpm or yarn.')
|
|
83
|
+
const manager =
|
|
84
|
+
options.packageManager ??
|
|
85
|
+
declaredManager ??
|
|
86
|
+
locks[0] ??
|
|
87
|
+
(workspace !== undefined ? 'pnpm' : undefined) ??
|
|
88
|
+
detectPackageManager()
|
|
89
|
+
const commands = packageCommands(manager)
|
|
90
|
+
const host = target === 'mobile' ? 'mobile' : (options.web ?? 'vite')
|
|
91
|
+
const rendering =
|
|
92
|
+
host === 'mobile' ? null : (options.rendering ?? (host === 'nuxt' ? 'ssr' : 'client'))
|
|
93
|
+
const destination = `apps/${target}`
|
|
94
|
+
await safePath(root, destination)
|
|
95
|
+
const screen = options.screen ? posix(relative(root, await safePath(root, options.screen))) : null
|
|
96
|
+
if (screen && !screen.endsWith('.vue'))
|
|
97
|
+
throw new Error('--screen must name an existing .vue file.')
|
|
98
|
+
if (options.screenRoot && !['screen', 'content'].includes(options.screenRoot))
|
|
99
|
+
throw new Error('--screen-root must be screen or content.')
|
|
100
|
+
const metadataPath = join(root, destination, 'mavis.host.json')
|
|
101
|
+
const existing = await optional(metadataPath)
|
|
102
|
+
if (existing) {
|
|
103
|
+
const state = JSON.parse(existing)
|
|
104
|
+
if (
|
|
105
|
+
state.schemaVersion !== 1 ||
|
|
106
|
+
state.source !== source ||
|
|
107
|
+
state.host !== host ||
|
|
108
|
+
state.manager !== manager ||
|
|
109
|
+
state.rendering !== rendering ||
|
|
110
|
+
state.screen !== screen ||
|
|
111
|
+
state.requestedScreenRoot !== (options.screenRoot ?? null)
|
|
112
|
+
)
|
|
113
|
+
throw new Error(
|
|
114
|
+
`${destination} was added with different choices. Existing files are preserved.`,
|
|
115
|
+
)
|
|
116
|
+
for (const [name, value] of Object.entries(state.scripts))
|
|
117
|
+
if (pkg.scripts?.[name] !== value)
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Existing script ${name} changed. Resolve it explicitly; host files are preserved.`,
|
|
120
|
+
)
|
|
121
|
+
return {
|
|
122
|
+
root,
|
|
123
|
+
destination,
|
|
124
|
+
host,
|
|
125
|
+
manager,
|
|
126
|
+
screen,
|
|
127
|
+
files: new Map(),
|
|
128
|
+
scripts: state.scripts,
|
|
129
|
+
alreadyAdded: true,
|
|
130
|
+
diagnostics: [],
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
await lstat(join(root, destination))
|
|
135
|
+
throw new Error(`${destination} already exists. No files were changed.`)
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (error.code !== 'ENOENT') throw error
|
|
138
|
+
}
|
|
139
|
+
const name = (pkg.name ?? 'mavis-app')
|
|
140
|
+
.replace(/^@[^/]+\//, '')
|
|
141
|
+
.toLowerCase()
|
|
142
|
+
.replace(/[^a-z0-9-]/g, '-')
|
|
143
|
+
.slice(0, 48)
|
|
144
|
+
const generated = await projectFiles({
|
|
145
|
+
name: /^[a-z]/.test(name) ? name : `app-${name}`,
|
|
146
|
+
target,
|
|
147
|
+
web: host === 'mobile' ? 'vite' : host,
|
|
148
|
+
rendering: options.rendering,
|
|
149
|
+
packageManager: manager,
|
|
150
|
+
})
|
|
151
|
+
const files = generated.files
|
|
152
|
+
const native = target === 'mobile'
|
|
153
|
+
if (native) {
|
|
154
|
+
const file = 'webpack.config.js'
|
|
155
|
+
files.set(
|
|
156
|
+
file,
|
|
157
|
+
files
|
|
158
|
+
.get(file)
|
|
159
|
+
.replace(
|
|
160
|
+
" config.resolve.alias.set('vue$'",
|
|
161
|
+
() =>
|
|
162
|
+
" for (const [name, entry] of Object.entries({ '@getcortexlabs/mavis-core$': 'index.js', '@getcortexlabs/mavis-core/vue$': 'vue/index.js', '@getcortexlabs/mavis-core/experimental$': 'experimental.js' }))\n config.resolve.alias.set(name, resolve(__dirname, 'node_modules/@getcortexlabs/mavis-core/dist', entry))\n config.resolve.alias.set('vue$'",
|
|
163
|
+
),
|
|
164
|
+
)
|
|
165
|
+
} else if (host === 'vite') {
|
|
166
|
+
const file = 'vite.config.ts'
|
|
167
|
+
files.set(
|
|
168
|
+
file,
|
|
169
|
+
files.get(file).replace("dedupe: ['vue'", "dedupe: ['@getcortexlabs/mavis-core', 'vue'"),
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
const scripts = native
|
|
173
|
+
? {
|
|
174
|
+
'install:mobile': commands.installAt(destination),
|
|
175
|
+
ios: commands.run('ios', destination),
|
|
176
|
+
android: commands.run('android', destination),
|
|
177
|
+
}
|
|
178
|
+
: {
|
|
179
|
+
'install:web': commands.installAt(destination),
|
|
180
|
+
'dev:web': commands.run('dev', destination),
|
|
181
|
+
'build:web': commands.run(
|
|
182
|
+
generated.preset.rendering === 'ssg' ? 'generate' : 'build',
|
|
183
|
+
destination,
|
|
184
|
+
),
|
|
185
|
+
'preview:web': commands.run('preview', destination),
|
|
186
|
+
}
|
|
187
|
+
for (const [name, value] of Object.entries(scripts))
|
|
188
|
+
if (pkg.scripts?.[name] !== undefined && pkg.scripts[name] !== value)
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Script conflict: ${name}. Rename the existing script explicitly before adding this target.`,
|
|
191
|
+
)
|
|
192
|
+
const manifest = JSON.parse(files.get('package.json'))
|
|
193
|
+
manifest.name += native ? '-mobile' : '-web'
|
|
194
|
+
for (const name of [
|
|
195
|
+
'@getcortexlabs/mavis-core',
|
|
196
|
+
native ? '@getcortexlabs/mavis' : '@getcortexlabs/mavis-web',
|
|
197
|
+
])
|
|
198
|
+
manifest.dependencies[name] = mavis
|
|
199
|
+
manifest.dependencies['@rafaelaugusto/jolt'] = deps['@rafaelaugusto/jolt'] ?? versions.jolt
|
|
200
|
+
files.set('package.json', json(manifest))
|
|
201
|
+
if (manager === 'npm') files.set('.npmrc', 'workspaces=false\n')
|
|
202
|
+
let diagnostics = [],
|
|
203
|
+
screenRoot = null
|
|
204
|
+
if (screen) {
|
|
205
|
+
const input = await readFile(join(root, screen), 'utf8')
|
|
206
|
+
const { descriptor, errors } = parse(input, { filename: screen })
|
|
207
|
+
if (errors.length || !descriptor.template || descriptor.template.src)
|
|
208
|
+
throw new Error('The selected screen must contain a valid inline Vue template.')
|
|
209
|
+
const roots = descriptor.template.ast?.children.filter((node) => node.type === 1) ?? []
|
|
210
|
+
screenRoot =
|
|
211
|
+
options.screenRoot ??
|
|
212
|
+
(roots.length === 1 && ['MScreen', 'm-screen'].includes(roots[0].tag) ? 'screen' : 'content')
|
|
213
|
+
if (roots.some((node) => ['Frame', 'Page'].includes(node.tag)))
|
|
214
|
+
throw new Error('Select shared content or an MScreen, not a native Frame/Page entry.')
|
|
215
|
+
diagnostics = (await checkPortability(root, { path: screen })).diagnostics
|
|
216
|
+
const entry = native
|
|
217
|
+
? 'src/App.vue'
|
|
218
|
+
: host === 'nuxt'
|
|
219
|
+
? 'app/app.vue'
|
|
220
|
+
: 'src/ExistingScreen.vue'
|
|
221
|
+
const screenImport = posix(
|
|
222
|
+
relative(dirname(join(root, destination, entry)), join(root, screen)),
|
|
223
|
+
)
|
|
224
|
+
const view =
|
|
225
|
+
screenRoot === 'screen'
|
|
226
|
+
? '<ExistingScreen />'
|
|
227
|
+
: '<MScreen scroll><ExistingScreen /></MScreen>'
|
|
228
|
+
files.set(
|
|
229
|
+
entry,
|
|
230
|
+
`<script setup lang="ts">\nimport ExistingScreen from ${JSON.stringify(screenImport.startsWith('.') ? screenImport : './' + screenImport)}\n</script>\n<template>${native ? `<Frame>${view}</Frame>` : view}</template>\n`,
|
|
231
|
+
)
|
|
232
|
+
if (native)
|
|
233
|
+
files.set(
|
|
234
|
+
'src/app.ts',
|
|
235
|
+
"import { createApp } from 'nativescript-vue'\nimport { createMavis } from '@getcortexlabs/mavis/vue'\nimport App from './App.vue'\ncreateApp(App).use(createMavis()).start()\n",
|
|
236
|
+
)
|
|
237
|
+
if (host === 'vite')
|
|
238
|
+
files.set(
|
|
239
|
+
'src/main.ts',
|
|
240
|
+
"import { createApp } from 'vue'\nimport { createMavis } from '@getcortexlabs/mavis-web'\nimport App from './ExistingScreen.vue'\nimport '@getcortexlabs/mavis-web/style.css'\nimport './style.css'\ncreateApp(App).use(createMavis()).mount('#app')\n",
|
|
241
|
+
)
|
|
242
|
+
// Explicit type resolution for source files outside this host's dependency tree.
|
|
243
|
+
if (host === 'nuxt') {
|
|
244
|
+
const paths = { vue: 'vue' }
|
|
245
|
+
for (const [name, entry] of Object.entries({
|
|
246
|
+
'@getcortexlabs/mavis-core': 'index.d.ts',
|
|
247
|
+
'@getcortexlabs/mavis-core/vue': 'vue/index.d.ts',
|
|
248
|
+
'@getcortexlabs/mavis-core/experimental': 'experimental.d.ts',
|
|
249
|
+
}))
|
|
250
|
+
paths[name] = `@getcortexlabs/mavis-core/dist/${entry}`
|
|
251
|
+
const entries = Object.entries(paths)
|
|
252
|
+
.map(
|
|
253
|
+
([name, entry]) =>
|
|
254
|
+
`${JSON.stringify(name)}: [fileURLToPath(new URL(${JSON.stringify('./node_modules/' + entry)}, import.meta.url))]`,
|
|
255
|
+
)
|
|
256
|
+
.join(', ')
|
|
257
|
+
files.set(
|
|
258
|
+
'nuxt.config.ts',
|
|
259
|
+
files
|
|
260
|
+
.get('nuxt.config.ts')
|
|
261
|
+
.replace(
|
|
262
|
+
' devtools:',
|
|
263
|
+
() =>
|
|
264
|
+
` typescript: { tsConfig: { compilerOptions: { paths: { ${entries} } } } },\n devtools:`,
|
|
265
|
+
),
|
|
266
|
+
)
|
|
267
|
+
} else {
|
|
268
|
+
const config = JSON.parse(files.get('tsconfig.json'))
|
|
269
|
+
config.compilerOptions.paths.vue = [
|
|
270
|
+
native ? './node_modules/nativescript-vue' : './node_modules/vue',
|
|
271
|
+
]
|
|
272
|
+
for (const [name, entry] of Object.entries({
|
|
273
|
+
'@getcortexlabs/mavis-core': 'index.d.ts',
|
|
274
|
+
'@getcortexlabs/mavis-core/vue': 'vue/index.d.ts',
|
|
275
|
+
'@getcortexlabs/mavis-core/experimental': 'experimental.d.ts',
|
|
276
|
+
}))
|
|
277
|
+
config.compilerOptions.paths[name] = [
|
|
278
|
+
`./node_modules/@getcortexlabs/mavis-core/dist/${entry}`,
|
|
279
|
+
]
|
|
280
|
+
config.include = [
|
|
281
|
+
'src',
|
|
282
|
+
posix(relative(join(root, destination), join(root, screen))),
|
|
283
|
+
...(host === 'vite' ? ['vite.config.ts'] : []),
|
|
284
|
+
]
|
|
285
|
+
files.set('tsconfig.json', json(config))
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
const state = {
|
|
289
|
+
schemaVersion: 1,
|
|
290
|
+
rendering,
|
|
291
|
+
source,
|
|
292
|
+
host,
|
|
293
|
+
manager,
|
|
294
|
+
screen,
|
|
295
|
+
screenRoot,
|
|
296
|
+
requestedScreenRoot: options.screenRoot ?? null,
|
|
297
|
+
scripts,
|
|
298
|
+
}
|
|
299
|
+
files.set('mavis.host.json', json(state))
|
|
300
|
+
files.set(
|
|
301
|
+
'README.md',
|
|
302
|
+
`# ${native ? 'NativeScript' : host === 'nuxt' ? 'Nuxt' : 'Vue + Vite'} host\n\nAdded to the existing ${source} application. Original sources, Web/native configuration and lockfiles stay in place.\n\nFrom the repository root:\n\n\`\`\`sh\n${commands.run(native ? 'install:mobile' : 'install:web')}\n${commands.run(native ? 'ios' : 'dev:web')}\n${native ? commands.run('android') : commands.run('build:web')}\n\`\`\`\n\n${screen ? `Entry: \`${screen}\` (${screenRoot}). The host imports this file; it does not copy it. Run the creator with \`--check-portability --path ${JSON.stringify(screen)}\` from the original project root. Configure app-owned services, routes and aliases used by that screen in this host.` : `Start with \`${destination}/${host === 'nuxt' ? 'app' : 'src'}/shared/Welcome.vue\`, then import a portable screen from the existing application in the host entry.`}\n\n${native ? 'NativeScript CLI, Android SDK/JDK and macOS/Xcode for iOS are required. Run `ns doctor` inside this directory. The Frame owns one MScreen/Page; use `--screen-root screen` for a component that already owns MScreen, or `content` to wrap it.' : 'The Web renderer has its own Vue runtime. Device services and native-only components need Web adapters. Nuxt SSR must not execute browser globals during setup.'}\n\nNative and Web dependencies are installed separately. Do not add this host to a workspace that hoists both Vue runtimes. No existing screen, router, service or import is migrated automatically. Review portability findings before considering a selected screen ready for the new platform.\n`,
|
|
303
|
+
)
|
|
304
|
+
return {
|
|
305
|
+
root,
|
|
306
|
+
destination,
|
|
307
|
+
host,
|
|
308
|
+
manager,
|
|
309
|
+
screen,
|
|
310
|
+
files,
|
|
311
|
+
scripts,
|
|
312
|
+
original,
|
|
313
|
+
packageFile,
|
|
314
|
+
diagnostics,
|
|
315
|
+
preset: generated.preset,
|
|
316
|
+
alreadyAdded: false,
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export async function applyTarget(plan, { signal } = {}) {
|
|
321
|
+
if (plan.alreadyAdded) return
|
|
322
|
+
signal?.throwIfAborted()
|
|
323
|
+
const target = await safePath(plan.root, plan.destination)
|
|
324
|
+
const staging = await mkdtemp(join(plan.root, '.mavis-add-'))
|
|
325
|
+
let created = false
|
|
326
|
+
const written = []
|
|
327
|
+
try {
|
|
328
|
+
for (const [file, content] of plan.files) {
|
|
329
|
+
signal?.throwIfAborted()
|
|
330
|
+
const output = join(staging, 'host', file)
|
|
331
|
+
await mkdir(dirname(output), { recursive: true })
|
|
332
|
+
await writeFile(output, content, { flag: 'wx' })
|
|
333
|
+
}
|
|
334
|
+
const pkg = JSON.parse(plan.original)
|
|
335
|
+
pkg.scripts = { ...pkg.scripts, ...plan.scripts }
|
|
336
|
+
await writeFile(join(staging, 'package.json'), json(pkg), { flag: 'wx' })
|
|
337
|
+
if ((await readFile(plan.packageFile, 'utf8')) !== plan.original)
|
|
338
|
+
throw new Error('package.json changed after planning. Run the command again.')
|
|
339
|
+
await mkdir(dirname(target), { recursive: true })
|
|
340
|
+
await mkdir(target)
|
|
341
|
+
created = true
|
|
342
|
+
for (const file of plan.files.keys()) {
|
|
343
|
+
signal?.throwIfAborted()
|
|
344
|
+
await mkdir(dirname(join(target, file)), { recursive: true })
|
|
345
|
+
await safePath(plan.root, join(plan.destination, file))
|
|
346
|
+
await writeFile(join(target, file), plan.files.get(file), { flag: 'wx' })
|
|
347
|
+
written.push(file)
|
|
348
|
+
}
|
|
349
|
+
signal?.throwIfAborted()
|
|
350
|
+
if ((await readFile(plan.packageFile, 'utf8')) !== plan.original)
|
|
351
|
+
throw new Error('package.json changed during creation. Run the command again.')
|
|
352
|
+
await rename(join(staging, 'package.json'), plan.packageFile)
|
|
353
|
+
} catch (error) {
|
|
354
|
+
if (created) {
|
|
355
|
+
for (const file of written.reverse()) {
|
|
356
|
+
const path = join(target, file)
|
|
357
|
+
if ((await optional(path)) === plan.files.get(file)) await rm(path)
|
|
358
|
+
for (let folder = dirname(path); folder.startsWith(target); folder = dirname(folder))
|
|
359
|
+
await rmdir(folder).catch(() => {})
|
|
360
|
+
}
|
|
361
|
+
await rmdir(target).catch(() => {})
|
|
362
|
+
}
|
|
363
|
+
throw error
|
|
364
|
+
} finally {
|
|
365
|
+
await rm(staging, { recursive: true, force: true })
|
|
366
|
+
}
|
|
367
|
+
}
|
package/src/cli.mjs
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from 'node:util'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { confirm, isCancel } from '@clack/prompts'
|
|
3
5
|
import { readFile } from 'node:fs/promises'
|
|
4
6
|
import { scaffold, installProject } from './scaffold.mjs'
|
|
7
|
+
import { planTarget, applyTarget } from './add-target.mjs'
|
|
5
8
|
import { checkPortability } from './portability.mjs'
|
|
6
9
|
import { doctor } from './doctor.mjs'
|
|
7
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
checkPackageManager,
|
|
12
|
+
detectPackageManager,
|
|
13
|
+
packageCommands,
|
|
14
|
+
runInstall,
|
|
15
|
+
} from './package-manager.mjs'
|
|
8
16
|
import { resolvePreset } from './presets.mjs'
|
|
9
17
|
import { nextSteps, projectSummary, sharedEntry, terminalUI, wizard } from './ui.mjs'
|
|
10
18
|
|
|
@@ -15,6 +23,10 @@ const help = `Create Mavis — Vue Web, Nuxt and NativeScript
|
|
|
15
23
|
create-mavis my-app --target both --web nuxt --package-manager pnpm --no-install
|
|
16
24
|
|
|
17
25
|
--target mobile|web|both Default: web
|
|
26
|
+
--add-native Add apps/mobile to an existing Vue/Vite or Nuxt app
|
|
27
|
+
--add-web Add apps/web to an existing NativeScript-Vue app
|
|
28
|
+
--screen path.vue Reuse an existing screen without moving it
|
|
29
|
+
--screen-root screen|content Existing MScreen or content to wrap (auto-detected)
|
|
18
30
|
--web vite|nuxt Default: vite
|
|
19
31
|
--rendering client|ssr|ssg Default: client (Vite), ssr (Nuxt)
|
|
20
32
|
--example welcome|directory Starter or shared search/detail/edit reference
|
|
@@ -53,6 +65,10 @@ try {
|
|
|
53
65
|
allowPositionals: true,
|
|
54
66
|
options: {
|
|
55
67
|
target: { type: 'string' },
|
|
68
|
+
'add-native': { type: 'boolean' },
|
|
69
|
+
'add-web': { type: 'boolean' },
|
|
70
|
+
screen: { type: 'string' },
|
|
71
|
+
'screen-root': { type: 'string' },
|
|
56
72
|
web: { type: 'string' },
|
|
57
73
|
rendering: { type: 'string' },
|
|
58
74
|
theme: { type: 'string' },
|
|
@@ -76,7 +92,101 @@ try {
|
|
|
76
92
|
})
|
|
77
93
|
if (values.help) console.log(help)
|
|
78
94
|
else if (values.version) console.log(version)
|
|
79
|
-
else if (values['
|
|
95
|
+
else if (values['add-native'] || values['add-web']) {
|
|
96
|
+
const [major, minor] = process.versions.node.split('.').map(Number)
|
|
97
|
+
if (major < 22 || (major === 22 && minor < 16))
|
|
98
|
+
throw new Error(`Mavis needs Node.js 22.16 or newer. You are using ${process.version}.`)
|
|
99
|
+
if (values['add-native'] && values['add-web']) throw new Error('Add one target at a time.')
|
|
100
|
+
if (
|
|
101
|
+
positionals.length ||
|
|
102
|
+
values.target ||
|
|
103
|
+
values['check-portability'] ||
|
|
104
|
+
values['fix-imports'] ||
|
|
105
|
+
values.write ||
|
|
106
|
+
values.path ||
|
|
107
|
+
values.doctor ||
|
|
108
|
+
values.example ||
|
|
109
|
+
values.theme ||
|
|
110
|
+
values.framework ||
|
|
111
|
+
values.authoring
|
|
112
|
+
)
|
|
113
|
+
throw new Error(
|
|
114
|
+
'Run --add-native or --add-web inside the existing host package, without create/audit options.',
|
|
115
|
+
)
|
|
116
|
+
if (values['add-native'] && (values.web || values.rendering))
|
|
117
|
+
throw new Error('--web and --rendering belong to --add-web.')
|
|
118
|
+
if (values.install && values['no-install'])
|
|
119
|
+
throw new Error('Choose either --install or --no-install.')
|
|
120
|
+
if (values['screen-root'] && !values.screen) throw new Error('--screen-root requires --screen.')
|
|
121
|
+
const target = await planTarget({
|
|
122
|
+
target: values['add-native'] ? 'mobile' : 'web',
|
|
123
|
+
web: values.web,
|
|
124
|
+
rendering: values.rendering,
|
|
125
|
+
screen: values.screen,
|
|
126
|
+
screenRoot: values['screen-root'],
|
|
127
|
+
packageManager: values['package-manager'],
|
|
128
|
+
})
|
|
129
|
+
const summary = {
|
|
130
|
+
host: target.host,
|
|
131
|
+
directory: target.destination,
|
|
132
|
+
manager: target.manager,
|
|
133
|
+
screen: target.screen,
|
|
134
|
+
alreadyAdded: target.alreadyAdded,
|
|
135
|
+
create: [...target.files.keys()].map((file) => `${target.destination}/${file}`),
|
|
136
|
+
packageScripts: target.scripts,
|
|
137
|
+
diagnostics: target.diagnostics,
|
|
138
|
+
}
|
|
139
|
+
if (values.json) console.log(JSON.stringify(summary, null, 2))
|
|
140
|
+
else {
|
|
141
|
+
ui.message(
|
|
142
|
+
`${target.alreadyAdded ? 'Already configured' : 'Plan'}: ${target.host} in ${target.destination} (${target.manager})`,
|
|
143
|
+
)
|
|
144
|
+
for (const file of summary.create) console.log(` + ${file}`)
|
|
145
|
+
if (!target.alreadyAdded)
|
|
146
|
+
console.log(` package.json: add scripts ${Object.keys(target.scripts).join(', ')}`)
|
|
147
|
+
for (const item of target.diagnostics)
|
|
148
|
+
console.log(`${item.file}:${item.line}:${item.column} [${item.code}] ${item.message}`)
|
|
149
|
+
}
|
|
150
|
+
if (!values['dry-run'] && !target.alreadyAdded) {
|
|
151
|
+
if (values.install) {
|
|
152
|
+
const manager = checkPackageManager(target.manager)
|
|
153
|
+
if (!manager.ok)
|
|
154
|
+
throw new Error(`${manager.detail}\nUse --no-install to add the host and install later.`)
|
|
155
|
+
}
|
|
156
|
+
const accepted =
|
|
157
|
+
interactive && !values.yes
|
|
158
|
+
? await confirm({
|
|
159
|
+
message: 'Add this host and the listed package scripts?',
|
|
160
|
+
signal: cancellation.signal,
|
|
161
|
+
})
|
|
162
|
+
: true
|
|
163
|
+
if (isCancel(accepted) || !accepted) process.exitCode = 130
|
|
164
|
+
else {
|
|
165
|
+
await applyTarget(target, { signal: cancellation.signal })
|
|
166
|
+
if (values.install)
|
|
167
|
+
await runInstall(
|
|
168
|
+
target.manager,
|
|
169
|
+
join(target.root, target.destination),
|
|
170
|
+
cancellation.signal,
|
|
171
|
+
)
|
|
172
|
+
if (!values.json) {
|
|
173
|
+
const commands = packageCommands(target.manager)
|
|
174
|
+
ui.success(`Added ${target.destination}. Existing sources and lockfiles were preserved.`)
|
|
175
|
+
ui.note(
|
|
176
|
+
[
|
|
177
|
+
...(values.install
|
|
178
|
+
? []
|
|
179
|
+
: [commands.run(target.host === 'mobile' ? 'install:mobile' : 'install:web')]),
|
|
180
|
+
commands.run(target.host === 'mobile' ? 'ios' : 'dev:web'),
|
|
181
|
+
...(target.host === 'mobile' ? [commands.run('android')] : []),
|
|
182
|
+
`Read ${target.destination}/README.md${target.diagnostics.length ? ' and resolve the portability findings before using the selected screen.' : '.'}`,
|
|
183
|
+
].join('\n'),
|
|
184
|
+
'Next steps',
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
} else if (values['check-portability'] || values['fix-imports']) {
|
|
80
190
|
if (values.write && !values['fix-imports']) throw new Error('--write requires --fix-imports.')
|
|
81
191
|
const result = await checkPortability(process.cwd(), {
|
|
82
192
|
path: values.path,
|
|
@@ -101,6 +211,8 @@ try {
|
|
|
101
211
|
for (const item of results) console.log(`${item.ok ? '✓' : '—'} ${item.name}: ${item.detail}`)
|
|
102
212
|
if (results.some((item) => !item.ok)) process.exitCode = 1
|
|
103
213
|
} else {
|
|
214
|
+
if (values.screen || values['screen-root'])
|
|
215
|
+
throw new Error('--screen requires --add-native or --add-web.')
|
|
104
216
|
if (values.write || values.path || values.json)
|
|
105
217
|
throw new Error('--write, --path and --json require --check-portability or --fix-imports.')
|
|
106
218
|
if (positionals.length > 1) throw new Error('Provide one project name.')
|
package/src/portability.mjs
CHANGED
|
@@ -32,7 +32,7 @@ const ignored = new Set([
|
|
|
32
32
|
'platforms',
|
|
33
33
|
'artifacts',
|
|
34
34
|
])
|
|
35
|
-
const sourceExtensions = ['.vue', '.ts', '.tsx', '.js', '.jsx', '.mjs']
|
|
35
|
+
const sourceExtensions = ['.vue', '.ts', '.mts', '.cts', '.tsx', '.js', '.jsx', '.mjs', '.cjs']
|
|
36
36
|
const platformImports =
|
|
37
37
|
/^(?:@getcortexlabs\/mavis(?:-web)?(?:\/|$)|@nativescript\/|nativescript-vue$|vue-router(?:-ns)?$|nuxt(?:\/|$)|#app$|node:|@rafaelaugusto\/jolt(?:\/|$))/
|
|
38
38
|
const portableImports = new Set([
|
|
@@ -64,6 +64,17 @@ export function inspectSource(source, filename, { allowImports = [] } = {}) {
|
|
|
64
64
|
})
|
|
65
65
|
}
|
|
66
66
|
let script = source
|
|
67
|
+
const kinds = {
|
|
68
|
+
ts: ts.ScriptKind.TS,
|
|
69
|
+
mts: ts.ScriptKind.TS,
|
|
70
|
+
cts: ts.ScriptKind.TS,
|
|
71
|
+
tsx: ts.ScriptKind.TSX,
|
|
72
|
+
js: ts.ScriptKind.JS,
|
|
73
|
+
mjs: ts.ScriptKind.JS,
|
|
74
|
+
cjs: ts.ScriptKind.JS,
|
|
75
|
+
jsx: ts.ScriptKind.JSX,
|
|
76
|
+
}
|
|
77
|
+
let scriptKind = kinds[extname(filename).slice(1)] ?? ts.ScriptKind.TS
|
|
67
78
|
let template
|
|
68
79
|
const templateExpressions = []
|
|
69
80
|
if (filename.endsWith('.vue')) {
|
|
@@ -77,6 +88,10 @@ export function inspectSource(source, filename, { allowImports = [] } = {}) {
|
|
|
77
88
|
'Only Vue HTML templates can be audited; review this template language separately.',
|
|
78
89
|
)
|
|
79
90
|
template = descriptor.template?.ast
|
|
91
|
+
const language = descriptor.scriptSetup?.lang ?? descriptor.script?.lang ?? 'js'
|
|
92
|
+
scriptKind = kinds[language] ?? ts.ScriptKind.JS
|
|
93
|
+
if (!(language in kinds))
|
|
94
|
+
report('script-language', 0, `Unsupported script language: ${language}.`)
|
|
80
95
|
script = source.replace(/[^\r\n]/g, ' ')
|
|
81
96
|
for (const block of [descriptor.script, descriptor.scriptSetup].filter(Boolean)) {
|
|
82
97
|
if (block.src)
|
|
@@ -147,7 +162,7 @@ export function inspectSource(source, filename, { allowImports = [] } = {}) {
|
|
|
147
162
|
script,
|
|
148
163
|
ts.ScriptTarget.Latest,
|
|
149
164
|
true,
|
|
150
|
-
|
|
165
|
+
scriptKind,
|
|
151
166
|
)
|
|
152
167
|
const host = {
|
|
153
168
|
getSourceFile: (name) => (name === file.fileName ? file : undefined),
|
package/src/presets.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { packageManagers } from './package-manager.mjs'
|
|
|
2
2
|
|
|
3
3
|
/** Baseline pins; coordinated releases update Mavis after validating source templates with matching tarballs. */
|
|
4
4
|
export const versions = Object.freeze({
|
|
5
|
-
mavis: '0.1.0-
|
|
6
|
-
jolt: '0.1.0-rc.
|
|
5
|
+
mavis: '0.1.0-rc.12',
|
|
6
|
+
jolt: '0.1.0-rc.11.1',
|
|
7
7
|
vue: '3.5.44',
|
|
8
8
|
nuxt: '4.6.3',
|
|
9
9
|
vite: '6.4.5',
|
|
@@ -16,6 +16,8 @@ export const versions = Object.freeze({
|
|
|
16
16
|
android: '9.1.1',
|
|
17
17
|
ios: '9.1.0',
|
|
18
18
|
webpack: '5.0.39',
|
|
19
|
+
webpackCore: '5.112.2',
|
|
20
|
+
webpackCli: '6.0.1',
|
|
19
21
|
router: '4.6.4',
|
|
20
22
|
nativeRouter: '0.1.0-rc.4',
|
|
21
23
|
})
|
package/src/scaffold.mjs
CHANGED
|
@@ -29,6 +29,12 @@ export async function projectFiles(options) {
|
|
|
29
29
|
const shared = preset.target === 'both'
|
|
30
30
|
const directory = preset.example === 'directory'
|
|
31
31
|
const commands = packageCommands(preset.packageManager)
|
|
32
|
+
// Yarn can otherwise resolve Nuxt's Vue range to a second, newer copy.
|
|
33
|
+
// Keep the Web app and Nuxt on one render context and compatible App types.
|
|
34
|
+
const yarnVue =
|
|
35
|
+
preset.packageManager === 'yarn'
|
|
36
|
+
? { resolutions: { vue: v.vue, '@vue/runtime-core': v.vue } }
|
|
37
|
+
: {}
|
|
32
38
|
const buildPolicy = (native) => ({
|
|
33
39
|
esbuild: true,
|
|
34
40
|
...(native
|
|
@@ -86,12 +92,14 @@ export async function projectFiles(options) {
|
|
|
86
92
|
...common,
|
|
87
93
|
name: `${preset.name}${shared ? '-web' : ''}`,
|
|
88
94
|
...yarnBuilds(false),
|
|
95
|
+
...(!shared ? yarnVue : {}),
|
|
89
96
|
type: 'module',
|
|
90
97
|
scripts,
|
|
91
98
|
dependencies: {
|
|
92
99
|
...dependencies,
|
|
93
100
|
'@getcortexlabs/mavis-web': v.mavis,
|
|
94
101
|
vue: v.vue,
|
|
102
|
+
'@vue/runtime-core': v.vue,
|
|
95
103
|
...(directory && preset.web === 'vite' ? { 'vue-router': v.router } : {}),
|
|
96
104
|
...(preset.web === 'nuxt' ? { nuxt: v.nuxt } : {}),
|
|
97
105
|
},
|
|
@@ -136,6 +144,8 @@ export async function projectFiles(options) {
|
|
|
136
144
|
'@nativescript/android': v.android,
|
|
137
145
|
'@nativescript/ios': v.ios,
|
|
138
146
|
'@nativescript/webpack': v.webpack,
|
|
147
|
+
webpack: v.webpackCore,
|
|
148
|
+
'webpack-cli': v.webpackCli,
|
|
139
149
|
typescript: v.typescript,
|
|
140
150
|
'vue-tsc': v.vueTsc,
|
|
141
151
|
},
|
|
@@ -149,6 +159,7 @@ export async function projectFiles(options) {
|
|
|
149
159
|
...common,
|
|
150
160
|
name: preset.name,
|
|
151
161
|
...yarnBuilds(false),
|
|
162
|
+
...yarnVue,
|
|
152
163
|
...(preset.packageManager !== 'pnpm' ? { workspaces: ['apps/web'] } : {}),
|
|
153
164
|
scripts: {
|
|
154
165
|
'dev:web': commands.run('dev', 'apps/web'),
|
package/src/shared-api.mjs
CHANGED
|
@@ -1,40 +1,68 @@
|
|
|
1
1
|
/** Shared renderer exports, also used by the conservative import migration. */
|
|
2
2
|
export const components = [
|
|
3
|
-
'
|
|
4
|
-
'
|
|
3
|
+
'MKanban',
|
|
4
|
+
'MDonutChart',
|
|
5
|
+
'MSparkline',
|
|
6
|
+
'MGradientBackground',
|
|
7
|
+
'MParticleField',
|
|
8
|
+
'MConfetti',
|
|
9
|
+
'MColorPicker',
|
|
10
|
+
'MSwipeDeck',
|
|
11
|
+
'MGauge',
|
|
12
|
+
'MTour',
|
|
13
|
+
'MTourTarget',
|
|
14
|
+
'MTransferList',
|
|
15
|
+
'MMarquee',
|
|
16
|
+
'MCollapsibleHeader',
|
|
17
|
+
'MRefreshControl',
|
|
18
|
+
'MComposer',
|
|
19
|
+
'MSpeedDial',
|
|
20
|
+
'MPinInput',
|
|
21
|
+
'MAnimatedText',
|
|
22
|
+
|
|
23
|
+
'MSortableList',
|
|
24
|
+
'MSwipeActions',
|
|
25
|
+
'MNumberFlow',
|
|
26
|
+
'MResizablePanels',
|
|
27
|
+
'MImageCompare',
|
|
28
|
+
'MImageViewer',
|
|
29
|
+
|
|
5
30
|
'MScreen',
|
|
6
|
-
'MBox',
|
|
7
31
|
'MRow',
|
|
8
32
|
'MColumn',
|
|
9
33
|
'MStack',
|
|
10
34
|
'MGrid',
|
|
11
35
|
'MLink',
|
|
36
|
+
'MBox',
|
|
12
37
|
'MCard',
|
|
13
38
|
'MText',
|
|
39
|
+
'MSpan',
|
|
40
|
+
'MThemeProvider',
|
|
41
|
+
'MPlatform',
|
|
42
|
+
'MIcon',
|
|
14
43
|
'MButton',
|
|
44
|
+
'MInput',
|
|
15
45
|
'MSlider',
|
|
16
46
|
'MSwitch',
|
|
17
47
|
'MCheckbox',
|
|
18
48
|
'MRadioGroup',
|
|
19
49
|
'MSelect',
|
|
20
|
-
'
|
|
50
|
+
'MSheet',
|
|
21
51
|
'MDialog',
|
|
52
|
+
'MToast',
|
|
22
53
|
'MTabs',
|
|
23
|
-
'MSkeleton',
|
|
24
54
|
'MChip',
|
|
25
55
|
'MEmptyState',
|
|
26
|
-
'MProgress',
|
|
27
56
|
'MAccordion',
|
|
28
57
|
'MSegmentedControl',
|
|
58
|
+
'MSkeleton',
|
|
59
|
+
'MProgress',
|
|
29
60
|
'MAlert',
|
|
30
|
-
'MListItem',
|
|
31
|
-
'MSeparator',
|
|
32
61
|
'MAvatar',
|
|
33
62
|
'MBadge',
|
|
34
|
-
'
|
|
35
|
-
'
|
|
63
|
+
'MListItem',
|
|
64
|
+
'MSeparator',
|
|
36
65
|
'MReveal',
|
|
37
|
-
'MSheet',
|
|
38
66
|
'MDatePicker',
|
|
39
67
|
'MDateRangePicker',
|
|
40
68
|
'MNumberInput',
|
|
@@ -46,6 +74,24 @@ export const components = [
|
|
|
46
74
|
'MFormErrors',
|
|
47
75
|
'MSteps',
|
|
48
76
|
'MPagination',
|
|
77
|
+
'MPopover',
|
|
78
|
+
'MMenu',
|
|
79
|
+
'MAppBar',
|
|
80
|
+
'MTabBar',
|
|
81
|
+
'MTimePicker',
|
|
82
|
+
'MVirtualList',
|
|
83
|
+
'MDataTable',
|
|
84
|
+
'MCarousel',
|
|
85
|
+
'MRangeSlider',
|
|
86
|
+
'MCalendar',
|
|
87
|
+
'MRating',
|
|
88
|
+
'MTreeView',
|
|
89
|
+
'MCommandPalette',
|
|
90
|
+
'MNavigationRail',
|
|
91
|
+
'MBreadcrumb',
|
|
92
|
+
'MTooltip',
|
|
93
|
+
'MTimeline',
|
|
94
|
+
'MChart',
|
|
49
95
|
]
|
|
50
96
|
export const composables = [
|
|
51
97
|
'useMavisTheme',
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
// Resolved by this host. Shared screens import from #mavis.
|
|
2
2
|
export {
|
|
3
3
|
MThemeProvider,
|
|
4
|
+
MPlatform,
|
|
5
|
+
MPopover,
|
|
6
|
+
MMenu,
|
|
7
|
+
MAppBar,
|
|
8
|
+
MTabBar,
|
|
9
|
+
MTimePicker,
|
|
10
|
+
MVirtualList,
|
|
11
|
+
MDataTable,
|
|
12
|
+
MCarousel,
|
|
13
|
+
MRangeSlider,
|
|
14
|
+
MCalendar,
|
|
15
|
+
MRating,
|
|
16
|
+
MTreeView,
|
|
17
|
+
MCommandPalette,
|
|
18
|
+
MNavigationRail,
|
|
19
|
+
MBreadcrumb,
|
|
20
|
+
MTooltip,
|
|
21
|
+
MTimeline,
|
|
22
|
+
MChart,
|
|
23
|
+
MImageViewer,
|
|
24
|
+
MSortableList,
|
|
25
|
+
MSwipeActions,
|
|
26
|
+
MNumberFlow,
|
|
27
|
+
MResizablePanels,
|
|
28
|
+
MImageCompare,
|
|
4
29
|
MSpan,
|
|
5
30
|
MScreen,
|
|
6
31
|
MBox,
|
|
@@ -46,6 +71,8 @@ export {
|
|
|
46
71
|
MFormErrors,
|
|
47
72
|
MSteps,
|
|
48
73
|
MPagination,
|
|
74
|
+
useMavisPlatform,
|
|
75
|
+
useMavisListMotion,
|
|
49
76
|
useMavisTheme,
|
|
50
77
|
useToast,
|
|
51
78
|
useFormController,
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
// Resolved by this host. Shared screens import from #mavis.
|
|
2
2
|
export {
|
|
3
3
|
MThemeProvider,
|
|
4
|
+
MPlatform,
|
|
5
|
+
MPopover,
|
|
6
|
+
MMenu,
|
|
7
|
+
MAppBar,
|
|
8
|
+
MTabBar,
|
|
9
|
+
MTimePicker,
|
|
10
|
+
MVirtualList,
|
|
11
|
+
MDataTable,
|
|
12
|
+
MCarousel,
|
|
13
|
+
MRangeSlider,
|
|
14
|
+
MCalendar,
|
|
15
|
+
MRating,
|
|
16
|
+
MTreeView,
|
|
17
|
+
MCommandPalette,
|
|
18
|
+
MNavigationRail,
|
|
19
|
+
MBreadcrumb,
|
|
20
|
+
MTooltip,
|
|
21
|
+
MTimeline,
|
|
22
|
+
MChart,
|
|
23
|
+
MImageViewer,
|
|
24
|
+
MSortableList,
|
|
25
|
+
MSwipeActions,
|
|
26
|
+
MNumberFlow,
|
|
27
|
+
MResizablePanels,
|
|
28
|
+
MImageCompare,
|
|
4
29
|
MSpan,
|
|
5
30
|
MScreen,
|
|
6
31
|
MBox,
|
|
@@ -46,6 +71,8 @@ export {
|
|
|
46
71
|
MFormErrors,
|
|
47
72
|
MSteps,
|
|
48
73
|
MPagination,
|
|
74
|
+
useMavisPlatform,
|
|
75
|
+
useMavisListMotion,
|
|
49
76
|
useMavisTheme,
|
|
50
77
|
useToast,
|
|
51
78
|
useFormController,
|
|
@@ -5,6 +5,17 @@ export default defineNuxtConfig({
|
|
|
5
5
|
'#shared-ui': fileURLToPath(new URL('__MAVIS_SHARED_ROOT__', import.meta.url)),
|
|
6
6
|
'#mavis': fileURLToPath(new URL('./app/mavis.ts', import.meta.url)),
|
|
7
7
|
},
|
|
8
|
+
vite: {
|
|
9
|
+
resolve: {
|
|
10
|
+
dedupe: [
|
|
11
|
+
'vue',
|
|
12
|
+
'@vue/runtime-core',
|
|
13
|
+
'@vue/reactivity',
|
|
14
|
+
'@vue/shared',
|
|
15
|
+
'@getcortexlabs/mavis-core',
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
8
19
|
devtools: { enabled: false },
|
|
9
20
|
css: ['@getcortexlabs/mavis-web/style.css', '~/assets/main.css'],
|
|
10
21
|
app: { head: { title: '__MAVIS_NAME__', htmlAttrs: { lang: 'en' } } },
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import { computed, ref } from 'vue'
|
|
3
3
|
import {
|
|
4
4
|
MAlert,
|
|
5
|
+
MBadge,
|
|
6
|
+
MStack,
|
|
7
|
+
MProgress,
|
|
8
|
+
MSeparator,
|
|
5
9
|
MButton,
|
|
6
10
|
MCard,
|
|
7
11
|
MColumn,
|
|
@@ -21,6 +25,32 @@ const name = ref('A new beginning')
|
|
|
21
25
|
const saving = ref(false)
|
|
22
26
|
const saved = ref(false)
|
|
23
27
|
const error = ref('')
|
|
28
|
+
const done = ref(['imagine'])
|
|
29
|
+
const milestones = [
|
|
30
|
+
{
|
|
31
|
+
id: 'imagine',
|
|
32
|
+
title: 'Find the spark',
|
|
33
|
+
detail: 'One idea worth making room for.',
|
|
34
|
+
icon: 'sparkles',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'shape',
|
|
38
|
+
title: 'Give it a shape',
|
|
39
|
+
detail: 'A name, a direction, a first draft.',
|
|
40
|
+
icon: 'pencil',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'share',
|
|
44
|
+
title: 'Put it into the world',
|
|
45
|
+
detail: 'Small steps become something real.',
|
|
46
|
+
icon: 'send',
|
|
47
|
+
},
|
|
48
|
+
] as const
|
|
49
|
+
function toggle(id: string) {
|
|
50
|
+
done.value = done.value.includes(id)
|
|
51
|
+
? done.value.filter((value) => value !== id)
|
|
52
|
+
: [...done.value, id]
|
|
53
|
+
}
|
|
24
54
|
const canSave = computed(() => name.value.trim().length > 0)
|
|
25
55
|
async function save() {
|
|
26
56
|
if (!canSave.value || saving.value) return
|
|
@@ -55,39 +85,79 @@ async function save() {
|
|
|
55
85
|
/>
|
|
56
86
|
</m-row>
|
|
57
87
|
<m-column paddingY="xl" gap="md">
|
|
58
|
-
<m-text variant="overline" tone="accent">
|
|
59
|
-
<m-text as="h1" variant="display">
|
|
60
|
-
<m-text tone="muted"
|
|
61
|
-
|
|
62
|
-
<m-card gap="lg">
|
|
63
|
-
<m-row justify="between" gap="sm">
|
|
64
|
-
<m-text variant="heading">Start something</m-text>
|
|
65
|
-
<m-icon name="sparkles" tone="primary" />
|
|
66
|
-
</m-row>
|
|
67
|
-
<m-input
|
|
68
|
-
v-model="name"
|
|
69
|
-
label="Project name"
|
|
70
|
-
name="project-name"
|
|
71
|
-
autocomplete="off"
|
|
72
|
-
helperText="A small beginning is still a beginning."
|
|
73
|
-
@update:modelValue="saved = false"
|
|
74
|
-
@submit="save"
|
|
75
|
-
/>
|
|
76
|
-
<m-alert v-if="error" tone="error" title="Let’s try again" :description="error" />
|
|
77
|
-
<m-button
|
|
78
|
-
:disabled="!canSave"
|
|
79
|
-
:loading="saving"
|
|
80
|
-
loadingText="Saving…"
|
|
81
|
-
icon="arrow-right"
|
|
82
|
-
@click="save"
|
|
83
|
-
>Create project</m-button
|
|
88
|
+
<m-text variant="overline" tone="accent">YOUR PERSONAL CREATIVE SPACE.</m-text>
|
|
89
|
+
<m-text as="h1" variant="display">Good things start here.</m-text>
|
|
90
|
+
<m-text tone="muted"
|
|
91
|
+
>Collect an idea, find your rhythm, and make a little progress every day.</m-text
|
|
84
92
|
>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
</m-column>
|
|
94
|
+
<m-stack
|
|
95
|
+
direction="column"
|
|
96
|
+
:responsive="{ at: 800, direction: 'row', align: 'start' }"
|
|
97
|
+
gap="lg"
|
|
98
|
+
>
|
|
99
|
+
<m-column :grow="1" :shrink="1" gap="lg">
|
|
100
|
+
<m-card :backgroundColor="theme.colors.primarySoft" gap="lg">
|
|
101
|
+
<m-row justify="between" gap="sm" wrap>
|
|
102
|
+
<m-badge text="IN THE MAKING" tone="primary" />
|
|
103
|
+
<m-icon name="sunrise" :size="36" tone="primary" />
|
|
104
|
+
</m-row>
|
|
105
|
+
<m-text variant="title">{{ name.trim() || 'Your next chapter' }}</m-text>
|
|
106
|
+
<m-text tone="muted">A little momentum goes a long way.</m-text>
|
|
107
|
+
<m-progress label="Your momentum" :value="done.length" :max="3" />
|
|
108
|
+
</m-card>
|
|
109
|
+
<m-column gap="sm">
|
|
110
|
+
<m-row justify="between"
|
|
111
|
+
><m-text variant="heading">Make a little room.</m-text
|
|
112
|
+
><m-badge :text="`${done.length} / 3`"
|
|
113
|
+
/></m-row>
|
|
114
|
+
<m-card v-for="step in milestones" :key="step.id" padding="md" gap="sm">
|
|
115
|
+
<m-row gap="md" align="center">
|
|
116
|
+
<m-button
|
|
117
|
+
:icon="done.includes(step.id) ? 'check' : step.icon"
|
|
118
|
+
:variant="done.includes(step.id) ? 'primary' : 'secondary'"
|
|
119
|
+
:accessibilityLabel="`${done.includes(step.id) ? 'Undo' : 'Complete'}: ${step.title}`"
|
|
120
|
+
@click="toggle(step.id)"
|
|
121
|
+
/>
|
|
122
|
+
<m-column :grow="1" :shrink="1" gap="xs"
|
|
123
|
+
><m-text weight="600">{{ step.title }}</m-text
|
|
124
|
+
><m-text variant="caption" tone="muted">{{ step.detail }}</m-text></m-column
|
|
125
|
+
>
|
|
126
|
+
</m-row>
|
|
127
|
+
</m-card>
|
|
128
|
+
</m-column>
|
|
129
|
+
</m-column>
|
|
130
|
+
<m-card :grow="1" :shrink="1" gap="lg">
|
|
131
|
+
<m-row justify="between" gap="sm">
|
|
132
|
+
<m-text variant="heading">Start something</m-text>
|
|
133
|
+
<m-icon name="sparkles" tone="primary" />
|
|
134
|
+
</m-row>
|
|
135
|
+
<m-input
|
|
136
|
+
v-model="name"
|
|
137
|
+
label="Project name"
|
|
138
|
+
name="project-name"
|
|
139
|
+
autocomplete="off"
|
|
140
|
+
helperText="A small beginning is still a beginning."
|
|
141
|
+
@update:modelValue="saved = false"
|
|
142
|
+
@submit="save"
|
|
143
|
+
/>
|
|
144
|
+
<m-alert v-if="error" tone="error" title="Let’s try again" :description="error" />
|
|
145
|
+
<m-button
|
|
146
|
+
:disabled="!canSave"
|
|
147
|
+
:loading="saving"
|
|
148
|
+
loadingText="Saving…"
|
|
149
|
+
icon="arrow-right"
|
|
150
|
+
@click="save"
|
|
151
|
+
>Create project</m-button
|
|
88
152
|
>
|
|
89
|
-
|
|
90
|
-
|
|
153
|
+
<m-reveal :show="saved">
|
|
154
|
+
<m-text tone="success"
|
|
155
|
+
>Your draft is ready. Connect the host service to make it yours.</m-text
|
|
156
|
+
>
|
|
157
|
+
</m-reveal>
|
|
158
|
+
</m-card>
|
|
159
|
+
</m-stack>
|
|
160
|
+
<m-separator />
|
|
91
161
|
<m-row gap="sm" wrap>
|
|
92
162
|
<m-icon name="layers" tone="accent" />
|
|
93
163
|
<m-text variant="caption" tone="muted">One screen. Your theme. Your platform.</m-text>
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
// Resolved by this host. Shared screens import from #mavis.
|
|
2
2
|
export {
|
|
3
3
|
MThemeProvider,
|
|
4
|
+
MPlatform,
|
|
5
|
+
MPopover,
|
|
6
|
+
MMenu,
|
|
7
|
+
MAppBar,
|
|
8
|
+
MTabBar,
|
|
9
|
+
MTimePicker,
|
|
10
|
+
MVirtualList,
|
|
11
|
+
MDataTable,
|
|
12
|
+
MCarousel,
|
|
13
|
+
MRangeSlider,
|
|
14
|
+
MCalendar,
|
|
15
|
+
MRating,
|
|
16
|
+
MTreeView,
|
|
17
|
+
MCommandPalette,
|
|
18
|
+
MNavigationRail,
|
|
19
|
+
MBreadcrumb,
|
|
20
|
+
MTooltip,
|
|
21
|
+
MTimeline,
|
|
22
|
+
MChart,
|
|
23
|
+
MImageViewer,
|
|
24
|
+
MSortableList,
|
|
25
|
+
MSwipeActions,
|
|
26
|
+
MNumberFlow,
|
|
27
|
+
MResizablePanels,
|
|
28
|
+
MImageCompare,
|
|
4
29
|
MSpan,
|
|
5
30
|
MScreen,
|
|
6
31
|
MBox,
|
|
@@ -46,6 +71,8 @@ export {
|
|
|
46
71
|
MFormErrors,
|
|
47
72
|
MSteps,
|
|
48
73
|
MPagination,
|
|
74
|
+
useMavisPlatform,
|
|
75
|
+
useMavisListMotion,
|
|
49
76
|
useMavisTheme,
|
|
50
77
|
useToast,
|
|
51
78
|
useFormController,
|