@mun-ui/ui 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +104 -2
- package/bin/compile.mjs +38 -0
- package/bin/dev-protocol.mjs +94 -0
- package/bin/formatter.mjs +109 -0
- package/bin/hot-reload.mjs +38 -0
- package/bin/mun.mjs +521 -0
- package/bin/native.mjs +133 -0
- package/bin/pnpm-workspace.mjs +58 -0
- package/bin/program-patch.mjs +104 -0
- package/bin/project.mjs +322 -0
- package/bin/watch.mjs +316 -0
- package/bin/workflow.mjs +261 -0
- package/dist/astro.d.ts +3 -0
- package/dist/astro.d.ts.map +1 -0
- package/dist/astro.js +3 -0
- package/dist/astro.js.map +1 -0
- package/dist/closures.d.ts +2 -0
- package/dist/closures.d.ts.map +1 -0
- package/dist/closures.js +2 -0
- package/dist/closures.js.map +1 -0
- package/dist/compiler/index.d.ts +2 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +2 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +3 -0
- package/dist/core.js.map +1 -0
- package/dist/experimental.d.ts +2 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +2 -0
- package/dist/experimental.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +2 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +2 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/legacy.d.ts +3 -0
- package/dist/legacy.d.ts.map +1 -0
- package/dist/legacy.js +3 -0
- package/dist/legacy.js.map +1 -0
- package/dist/mun.d.ts +5 -0
- package/dist/mun.d.ts.map +1 -0
- package/dist/mun.js +4 -0
- package/dist/mun.js.map +1 -0
- package/dist/progressive-blur/index.d.ts +8 -0
- package/dist/progressive-blur/index.d.ts.map +1 -0
- package/dist/progressive-blur/index.js +8 -0
- package/dist/progressive-blur/index.js.map +1 -0
- package/dist/progressive-blur/plan.d.ts +3 -0
- package/dist/progressive-blur/plan.d.ts.map +1 -0
- package/dist/progressive-blur/plan.js +3 -0
- package/dist/progressive-blur/plan.js.map +1 -0
- package/dist/react-types.d.ts +2 -0
- package/dist/react-types.d.ts.map +1 -0
- package/dist/react-types.js +2 -0
- package/dist/react-types.js.map +1 -0
- package/dist/rendering-quality.d.ts +4 -0
- package/dist/rendering-quality.d.ts.map +1 -0
- package/dist/rendering-quality.js +4 -0
- package/dist/rendering-quality.js.map +1 -0
- package/dist/state.d.ts +2 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +2 -0
- package/dist/state.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +2 -0
- package/dist/vite.js.map +1 -0
- package/editors/install.mjs +102 -0
- package/editors/lsp/mun-lsp.mjs +123 -0
- package/editors/lsp/service.mjs +306 -0
- package/editors/lsp/source.mjs +58 -0
- package/editors/vscode/client.mjs +40 -0
- package/editors/vscode/dev-client.mjs +83 -0
- package/editors/vscode/discovery.mjs +46 -0
- package/editors/vscode/export.mjs +42 -0
- package/editors/vscode/extension.cjs +226 -0
- package/editors/vscode/language-configuration.json +15 -0
- package/editors/vscode/package.json +119 -0
- package/editors/vscode/protocol.mjs +29 -0
- package/editors/vscode/syntaxes/mun.tmLanguage.json +130 -0
- package/native/Cargo.lock +3581 -0
- package/native/Cargo.toml +21 -0
- package/native/README.md +21 -0
- package/native/mun-native/Cargo.toml +23 -0
- package/native/mun-native/src/accessibility.rs +738 -0
- package/native/mun-native/src/dev.rs +604 -0
- package/native/mun-native/src/lib.rs +2676 -0
- package/native/mun-native/src/main.rs +204 -0
- package/native/mun-native/src/offscreen.rs +393 -0
- package/native/mun-native/src/rect.wgsl +63 -0
- package/native/mun-native/src/text.rs +310 -0
- package/native/mun-native/tests/offscreen_rendering.rs +161 -0
- package/native/mun-native/tests/stress.rs +408 -0
- package/native/mun-native/tests/window_lifecycle.rs +183 -0
- package/native/mun-runtime/Cargo.toml +13 -0
- package/native/mun-runtime/src/accessibility.rs +193 -0
- package/native/mun-runtime/src/collection.rs +1073 -0
- package/native/mun-runtime/src/gesture.rs +1070 -0
- package/native/mun-runtime/src/input.rs +325 -0
- package/native/mun-runtime/src/ir.rs +782 -0
- package/native/mun-runtime/src/kinetics.rs +500 -0
- package/native/mun-runtime/src/layout.rs +173 -0
- package/native/mun-runtime/src/layout_cache.rs +209 -0
- package/native/mun-runtime/src/lib.rs +49 -0
- package/native/mun-runtime/src/motion.rs +1162 -0
- package/native/mun-runtime/src/retained.rs +574 -0
- package/native/mun-runtime/src/runtime.rs +7078 -0
- package/native/mun-runtime/src/scene.rs +530 -0
- package/native/mun-runtime/src/scroll.rs +521 -0
- package/native/mun-runtime/src/scroll_view.rs +220 -0
- package/native/mun-runtime/src/text_edit.rs +670 -0
- package/native/mun-runtime/src/timeline.rs +1534 -0
- package/native/mun-runtime/src/validate.rs +677 -0
- package/native/mun-runtime/tests/accessibility_semantics.rs +168 -0
- package/native/mun-runtime/tests/compiler_contract.rs +110 -0
- package/native/mun-runtime/tests/flexible_frames.rs +47 -0
- package/native/mun-runtime/tests/hot_update.rs +367 -0
- package/native/mun-runtime/tests/incremental_runtime.rs +323 -0
- package/native/mun-runtime/tests/ir_validation.rs +167 -0
- package/native/mun-runtime/tests/keyed_collections.rs +251 -0
- package/native/mun-runtime/tests/native_controls_style.rs +491 -0
- package/native/mun-runtime/tests/native_demo.rs +285 -0
- package/native/mun-runtime/tests/native_layout_style.rs +175 -0
- package/native/mun-runtime/tests/native_settings_pane.rs +152 -0
- package/native/mun-runtime/tests/scroll_view.rs +403 -0
- package/native/mun-runtime/tests/text_editing.rs +491 -0
- package/package.json +210 -3
- package/schemas/README.md +19 -0
- package/schemas/semantic-ui-ir-v1.schema.json +1972 -0
- package/templates/native/App.mun +15 -0
- package/templates/native/gitignore +3 -0
- package/templates/native/mun.toml +8 -0
- package/templates/project/gitignore +5 -0
- package/templates/project/index.html +13 -0
- package/templates/project/package.json +21 -0
- package/templates/project/src/App.mun +13 -0
- package/templates/project/src/index.css +21 -0
- package/templates/project/src/main.ts +5 -0
- package/templates/project/tsconfig.json +20 -0
- package/templates/project/vite.config.ts +6 -0
- package/templates/vite/src/App.css +134 -0
- package/templates/vite/src/App.tsx +91 -0
- package/templates/vite/src/index.css +23 -0
- package/templates/vite/vite.config.ts +10 -0
package/bin/mun.mjs
ADDED
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process'
|
|
4
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
5
|
+
import { basename, dirname, relative, resolve, sep } from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
import { updatePnpmWorkspaceOverrides } from './pnpm-workspace.mjs'
|
|
8
|
+
import { installEditors } from '../editors/install.mjs'
|
|
9
|
+
import { runNativeSource } from './native.mjs'
|
|
10
|
+
import { projectCommand } from './workflow.mjs'
|
|
11
|
+
|
|
12
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
13
|
+
const packageManifest = JSON.parse(readFileSync(resolve(packageRoot, 'package.json'), 'utf8'))
|
|
14
|
+
const supportedPackageManagers = ['pnpm', 'npm', 'yarn', 'bun']
|
|
15
|
+
const argv = process.argv.slice(2)
|
|
16
|
+
const command = argv[0]
|
|
17
|
+
const positionals = []
|
|
18
|
+
const options = {
|
|
19
|
+
force: false,
|
|
20
|
+
noInstall: false,
|
|
21
|
+
packageManager: undefined,
|
|
22
|
+
help: false,
|
|
23
|
+
local: false,
|
|
24
|
+
localRoot: undefined,
|
|
25
|
+
renderer: undefined,
|
|
26
|
+
editor: 'all',
|
|
27
|
+
global: false,
|
|
28
|
+
projectRoot: undefined,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function takeValue(argument, index, longName) {
|
|
32
|
+
if (argument === longName) {
|
|
33
|
+
const value = argv[index + 1]
|
|
34
|
+
if (!value || value.startsWith('-')) throw new Error(`${longName} requires a value.`)
|
|
35
|
+
return { value, consumed: 1 }
|
|
36
|
+
}
|
|
37
|
+
if (argument.startsWith(`${longName}=`)) return { value: argument.slice(longName.length + 1), consumed: 0 }
|
|
38
|
+
return undefined
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
for (let index = 1; index < argv.length; index += 1) {
|
|
43
|
+
const argument = argv[index]
|
|
44
|
+
if (argument === '--') continue
|
|
45
|
+
if (argument === '--force') options.force = true
|
|
46
|
+
else if (argument === '--no-install' || argument === '--skip-install') options.noInstall = true
|
|
47
|
+
else if (argument === '--local') options.local = true
|
|
48
|
+
else if (argument === '--global') options.global = true
|
|
49
|
+
else if (argument === '--help' || argument === '-h') options.help = true
|
|
50
|
+
else if (argument === '--check') options.check = true
|
|
51
|
+
else if (argument === '--verbose') options.verbose = true
|
|
52
|
+
else if (argument === '--values') options.values = true
|
|
53
|
+
else if (argument === '--json') options.json = true
|
|
54
|
+
else if (argument === '--version' || argument === '-v') options.version = true
|
|
55
|
+
else {
|
|
56
|
+
const packageManager = takeValue(argument, index, '--package-manager') ?? takeValue(argument, index, '--pm')
|
|
57
|
+
const localRoot = takeValue(argument, index, '--local-root')
|
|
58
|
+
const renderer = takeValue(argument, index, '--renderer')
|
|
59
|
+
const editor = takeValue(argument, index, '--editor')
|
|
60
|
+
const project = takeValue(argument, index, '--project')
|
|
61
|
+
const target = takeValue(argument, index, '--target')
|
|
62
|
+
const sign = takeValue(argument, index, '--sign')
|
|
63
|
+
const notarize = takeValue(argument, index, '--notarize-profile')
|
|
64
|
+
if (sign) { options.sign = sign.value; index += sign.consumed }
|
|
65
|
+
else if (notarize) { options.notarizeProfile = notarize.value; index += notarize.consumed }
|
|
66
|
+
else if (target) {
|
|
67
|
+
options.target = target.value
|
|
68
|
+
index += target.consumed
|
|
69
|
+
} else if (packageManager) {
|
|
70
|
+
options.packageManager = packageManager.value
|
|
71
|
+
index += packageManager.consumed
|
|
72
|
+
} else if (localRoot) {
|
|
73
|
+
options.local = true
|
|
74
|
+
options.localRoot = localRoot.value
|
|
75
|
+
index += localRoot.consumed
|
|
76
|
+
} else if (renderer) {
|
|
77
|
+
options.renderer = renderer.value
|
|
78
|
+
index += renderer.consumed
|
|
79
|
+
} else if (editor) {
|
|
80
|
+
options.editor = editor.value
|
|
81
|
+
index += editor.consumed
|
|
82
|
+
} else if (project) {
|
|
83
|
+
options.projectRoot = project.value
|
|
84
|
+
index += project.consumed
|
|
85
|
+
} else {
|
|
86
|
+
positionals.push(argument)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(`Mün ${command ?? 'command'} failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
92
|
+
printHelp()
|
|
93
|
+
process.exitCode = 1
|
|
94
|
+
process.exit(process.exitCode)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const projectFiles = [
|
|
98
|
+
['templates/project/gitignore', '.gitignore'],
|
|
99
|
+
['templates/project/index.html', 'index.html'],
|
|
100
|
+
['templates/project/package.json', 'package.json'],
|
|
101
|
+
['templates/project/tsconfig.json', 'tsconfig.json'],
|
|
102
|
+
['templates/project/vite.config.ts', 'vite.config.ts'],
|
|
103
|
+
['templates/project/src/App.mun', 'src/App.mun'],
|
|
104
|
+
['templates/project/src/index.css', 'src/index.css'],
|
|
105
|
+
['templates/project/src/main.ts', 'src/main.ts'],
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
const localPackagePaths = {
|
|
109
|
+
'@mun-ui/ui': '.',
|
|
110
|
+
'@mun-ui/astro': 'packages/astro',
|
|
111
|
+
'@mun-ui/animation': 'packages/animation',
|
|
112
|
+
'@mun-ui/core': 'packages/core',
|
|
113
|
+
'@mun-ui/compiler': 'packages/compiler',
|
|
114
|
+
'@mun-ui/execution': 'packages/execution',
|
|
115
|
+
'@mun-ui/legacy-react': 'packages/legacy-react',
|
|
116
|
+
'@mun-ui/progressive-blur': 'packages/progressive-blur',
|
|
117
|
+
'@mun-ui/react': 'packages/react',
|
|
118
|
+
'@mun-ui/vue': 'packages/vue',
|
|
119
|
+
'@mun-ui/web': 'packages/web',
|
|
120
|
+
'@mun-ui/vite': 'packages/vite',
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function template(source) {
|
|
124
|
+
return readFileSync(resolve(packageRoot, source), 'utf8')
|
|
125
|
+
.replaceAll('__MUN_VERSION__', packageManifest.version)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function writeTemplates(projectRoot, files) {
|
|
129
|
+
for (const [source, destination] of files) {
|
|
130
|
+
const target = resolve(projectRoot, destination)
|
|
131
|
+
mkdirSync(dirname(target), { recursive: true })
|
|
132
|
+
writeFileSync(target, template(source)
|
|
133
|
+
.replaceAll('__MUN_PROJECT_NAME__', projectName(projectRoot))
|
|
134
|
+
.replaceAll('__MUN_PROJECT_APP_NAME__', projectAppName(projectRoot)))
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function projectName(projectRoot) {
|
|
139
|
+
const name = basename(projectRoot)
|
|
140
|
+
.toLowerCase()
|
|
141
|
+
.replace(/[^a-z0-9._-]+/gu, '-')
|
|
142
|
+
.replace(/^[._-]+|[._-]+$/gu, '')
|
|
143
|
+
return name || 'mun-app'
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function projectAppName(projectRoot) {
|
|
147
|
+
const words = basename(projectRoot).split(/[^A-Za-z0-9]+/u).filter(Boolean)
|
|
148
|
+
const name = words.map(word => `${word[0].toUpperCase()}${word.slice(1)}`).join('') || 'Mun'
|
|
149
|
+
return /^[A-Za-z]/u.test(name) ? `${name}App` : `Mun${name}App`
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function detectPackageManager(projectRoot) {
|
|
153
|
+
const userAgent = process.env.npm_config_user_agent ?? ''
|
|
154
|
+
for (const manager of ['pnpm', 'yarn', 'bun', 'npm']) {
|
|
155
|
+
if (userAgent.startsWith(`${manager}/`)) return manager
|
|
156
|
+
}
|
|
157
|
+
if (existsSync(resolve(projectRoot, 'pnpm-lock.yaml')) || existsSync(resolve(projectRoot, 'pnpm-workspace.yaml'))) return 'pnpm'
|
|
158
|
+
if (existsSync(resolve(projectRoot, 'yarn.lock'))) return 'yarn'
|
|
159
|
+
if (existsSync(resolve(projectRoot, 'bun.lockb')) || existsSync(resolve(projectRoot, 'bun.lock'))) return 'bun'
|
|
160
|
+
return 'npm'
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function packageManagerFor(projectRoot, { local = false } = {}) {
|
|
164
|
+
if (local) {
|
|
165
|
+
assertLocalPackageManager()
|
|
166
|
+
return 'pnpm'
|
|
167
|
+
}
|
|
168
|
+
const packageManager = options.packageManager ?? detectPackageManager(projectRoot)
|
|
169
|
+
if (!supportedPackageManagers.includes(packageManager)) {
|
|
170
|
+
throw new Error(`Unsupported package manager: ${packageManager}. Use pnpm, npm, yarn, or bun.`)
|
|
171
|
+
}
|
|
172
|
+
return packageManager
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function installDependencies(projectRoot, packageManager) {
|
|
176
|
+
console.log(`Installing dependencies with ${packageManager}...`)
|
|
177
|
+
const result = spawnSync(packageManager, ['install'], { cwd: projectRoot, stdio: 'inherit' })
|
|
178
|
+
if (result.error) throw new Error(`Could not run ${packageManager}: ${result.error.message}`)
|
|
179
|
+
if (result.status !== 0) throw new Error(`${packageManager} install failed with exit code ${result.status ?? 1}.`)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function normalizeLocalRoot(value = packageRoot) {
|
|
183
|
+
return resolve(process.cwd(), value)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function assertLocalPackageManager() {
|
|
187
|
+
if (options.packageManager && options.packageManager !== 'pnpm') {
|
|
188
|
+
throw new Error('Local Mün source linking currently requires pnpm. Remove --pm or use --pm pnpm.')
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function packageRunCommand(packageManager, script) {
|
|
193
|
+
if (packageManager === 'npm' || packageManager === 'bun') return `${packageManager} run ${script}`
|
|
194
|
+
return `${packageManager} ${script}`
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function shellPath(path) {
|
|
198
|
+
if (/^[A-Za-z0-9_./~-]+$/u.test(path)) return path
|
|
199
|
+
return `'${path.replaceAll("'", "'\\''")}'`
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function displayProjectPath(projectRoot) {
|
|
203
|
+
const path = relative(process.cwd(), projectRoot)
|
|
204
|
+
if (!path || path === '.') return '.'
|
|
205
|
+
if (!path.startsWith('..') && !path.startsWith(sep)) return path
|
|
206
|
+
return projectRoot
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function printScaffoldNextSteps(projectRoot, packageManager, installed) {
|
|
210
|
+
const steps = []
|
|
211
|
+
const projectPath = displayProjectPath(projectRoot)
|
|
212
|
+
if (projectPath !== '.') steps.push(`cd ${shellPath(projectPath)}`)
|
|
213
|
+
if (!installed) steps.push(`${packageManager} install`)
|
|
214
|
+
steps.push(packageRunCommand(packageManager, 'dev'))
|
|
215
|
+
console.log(`\nNext steps:\n${steps.map(step => ` ${step}`).join('\n')}`)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function printInstallRecovery(projectRoot, packageManager) {
|
|
219
|
+
const projectPath = displayProjectPath(projectRoot)
|
|
220
|
+
const prefix = projectPath === '.' ? '' : ` cd ${shellPath(projectPath)}\n`
|
|
221
|
+
console.error('\nThe project files are ready, but dependency installation did not finish.')
|
|
222
|
+
console.error(`Retry with:\n${prefix} ${packageManager} install`)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function assertSourceCheckout(localRoot) {
|
|
226
|
+
const manifestPath = resolve(localRoot, 'package.json')
|
|
227
|
+
if (!existsSync(manifestPath)) throw new Error(`Local Mün checkout has no package.json: ${localRoot}`)
|
|
228
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
229
|
+
if (manifest.name !== '@mun-ui/ui') throw new Error(`Local checkout is not @mun-ui/ui: ${localRoot}`)
|
|
230
|
+
for (const relativePath of Object.values(localPackagePaths)) {
|
|
231
|
+
if (relativePath === '.') continue
|
|
232
|
+
if (!existsSync(resolve(localRoot, relativePath, 'package.json'))) {
|
|
233
|
+
throw new Error(`Local Mün checkout is incomplete; missing ${relativePath}/package.json in ${localRoot}`)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return localRoot
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function detectRenderer(projectRoot) {
|
|
240
|
+
const manifestPath = resolve(projectRoot, 'package.json')
|
|
241
|
+
if (!existsSync(manifestPath)) throw new Error(`Target project has no package.json: ${projectRoot}`)
|
|
242
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
243
|
+
const dependencies = { ...manifest.dependencies, ...manifest.devDependencies, ...manifest.peerDependencies }
|
|
244
|
+
const hasAstro = Boolean(dependencies.astro)
|
|
245
|
+
const hasReact = Boolean(dependencies.react || dependencies['react-dom'])
|
|
246
|
+
const hasVue = Boolean(dependencies.vue)
|
|
247
|
+
if (hasAstro) return 'astro'
|
|
248
|
+
if (hasReact && hasVue) {
|
|
249
|
+
throw new Error('Both React and Vue are present in the target project. Pass --renderer astro, react, vue, or web explicitly.')
|
|
250
|
+
}
|
|
251
|
+
if (hasVue) return 'vue'
|
|
252
|
+
if (hasReact) return 'react'
|
|
253
|
+
return 'web'
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function linkSpecifier(path) {
|
|
257
|
+
return `link:${path.split(sep).join('/')}`
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function configureLocalDependencies(projectRoot, localRoot, renderer = 'react', { includeRootPackage = true } = {}) {
|
|
261
|
+
if (!['astro', 'react', 'vue', 'web'].includes(renderer)) {
|
|
262
|
+
throw new Error(`Unsupported Mün renderer: ${renderer}. Use astro, react, vue, or web.`)
|
|
263
|
+
}
|
|
264
|
+
localRoot = assertSourceCheckout(localRoot)
|
|
265
|
+
const manifestPath = resolve(projectRoot, 'package.json')
|
|
266
|
+
if (!existsSync(manifestPath)) throw new Error(`Target project has no package.json: ${projectRoot}`)
|
|
267
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
268
|
+
manifest.dependencies ??= {}
|
|
269
|
+
manifest.devDependencies ??= {}
|
|
270
|
+
|
|
271
|
+
// Templates depend on @mun-ui/ui for its opt-in features; never let a local
|
|
272
|
+
// project resolve it from the registry.
|
|
273
|
+
const linkRootPackage = includeRootPackage || manifest.dependencies['@mun-ui/ui'] !== undefined
|
|
274
|
+
if (linkRootPackage) manifest.dependencies['@mun-ui/ui'] = linkSpecifier(localRoot)
|
|
275
|
+
manifest.dependencies[`@mun-ui/${renderer}`] = linkSpecifier(resolve(localRoot, `packages/${renderer}`))
|
|
276
|
+
manifest.devDependencies['@mun-ui/vite'] = linkSpecifier(resolve(localRoot, 'packages/vite'))
|
|
277
|
+
|
|
278
|
+
// link: packages deliberately do not install their own dependency graph.
|
|
279
|
+
// Add the internal runtime/compiler plumbing directly so bundlers that
|
|
280
|
+
// resolve through the consumer's node_modules (Vite/Rolldown included)
|
|
281
|
+
// see the same graph as the Mün workspace.
|
|
282
|
+
for (const name of ['@mun-ui/animation', '@mun-ui/core', '@mun-ui/compiler', '@mun-ui/execution', '@mun-ui/web']) {
|
|
283
|
+
manifest.devDependencies[name] = linkSpecifier(resolve(localRoot, localPackagePaths[name]))
|
|
284
|
+
}
|
|
285
|
+
// Opt-in @mun-ui/ui features re-export internal modules; a linked @mun-ui/ui
|
|
286
|
+
// does not install them itself.
|
|
287
|
+
if (linkRootPackage) manifest.devDependencies['@mun-ui/progressive-blur'] = linkSpecifier(resolve(localRoot, localPackagePaths['@mun-ui/progressive-blur']))
|
|
288
|
+
// pnpm 11 moved overrides out of package.json and into pnpm-workspace.yaml.
|
|
289
|
+
// Keep every internal package pinned to this checkout so unpublished
|
|
290
|
+
// transitive @mun-ui/* dependencies never fall through to the registry.
|
|
291
|
+
if (manifest.pnpm?.overrides) {
|
|
292
|
+
delete manifest.pnpm.overrides
|
|
293
|
+
if (Object.keys(manifest.pnpm).length === 0) delete manifest.pnpm
|
|
294
|
+
}
|
|
295
|
+
const selectedOverrideNames = [
|
|
296
|
+
'@mun-ui/animation',
|
|
297
|
+
'@mun-ui/core',
|
|
298
|
+
'@mun-ui/compiler',
|
|
299
|
+
'@mun-ui/execution',
|
|
300
|
+
'@mun-ui/web',
|
|
301
|
+
'@mun-ui/vite',
|
|
302
|
+
`@mun-ui/${renderer}`,
|
|
303
|
+
]
|
|
304
|
+
if (linkRootPackage) selectedOverrideNames.push('@mun-ui/progressive-blur')
|
|
305
|
+
const overridePaths = includeRootPackage
|
|
306
|
+
? localPackagePaths
|
|
307
|
+
: Object.fromEntries([...new Set(selectedOverrideNames)].map(name => [name, localPackagePaths[name]]))
|
|
308
|
+
const overrides = Object.fromEntries(
|
|
309
|
+
Object.entries(overridePaths).map(([name, relativePath]) => [
|
|
310
|
+
name,
|
|
311
|
+
linkSpecifier(resolve(localRoot, relativePath)),
|
|
312
|
+
]),
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`)
|
|
316
|
+
updatePnpmWorkspaceOverrides(projectRoot, overrides)
|
|
317
|
+
console.log(`Linked Mün ${packageManifest.version} (${renderer}) from ${localRoot}`)
|
|
318
|
+
return manifest
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function printHelp() {
|
|
322
|
+
console.log(`Mün UI CLI
|
|
323
|
+
|
|
324
|
+
Usage:
|
|
325
|
+
mun new <directory> [--target native|web]
|
|
326
|
+
mun create <directory> [--target native|web]
|
|
327
|
+
mun init [--target native|web]
|
|
328
|
+
mun dev [--verbose] # experimental native project
|
|
329
|
+
mun inspect [--values] [--json]
|
|
330
|
+
mun run [input.mun] # experimental native host
|
|
331
|
+
mun check
|
|
332
|
+
mun fmt [--check]
|
|
333
|
+
mun build
|
|
334
|
+
mun package [--sign <identity>] [--notarize-profile <keychain-profile>]
|
|
335
|
+
mun doctor
|
|
336
|
+
mun compile <input.mun> [output.json]
|
|
337
|
+
mun link <project> [--renderer astro|react|vue|web] [--pm <manager>] [--no-install] [--local-root <path>]
|
|
338
|
+
mun lsp [--stdio]
|
|
339
|
+
mun lsp install [--editor ...] [--project <path>] [--global]
|
|
340
|
+
mun editor install [--editor vim|nvim|vscode|zed|helix|generic|all] [--project <path>] [--global]
|
|
341
|
+
mun editor export vscode [output.vsix]
|
|
342
|
+
|
|
343
|
+
Local checkout workflow:
|
|
344
|
+
# from the Mün repository
|
|
345
|
+
pnpm build
|
|
346
|
+
pnpm dev:link ../my-app
|
|
347
|
+
|
|
348
|
+
# or scaffold a separate app using this checkout without npm publication
|
|
349
|
+
node bin/mun.mjs create ../my-app --local
|
|
350
|
+
|
|
351
|
+
Initializer aliases after publishing:
|
|
352
|
+
npm create mun <directory>
|
|
353
|
+
pnpm create mun <directory>
|
|
354
|
+
|
|
355
|
+
new/create/init scaffold a web application with Vite by default. Use --target native for the experimental native runtime.
|
|
356
|
+
--local rewrites Mün dependencies to link: paths pointing at the source checkout.
|
|
357
|
+
Local source mode always uses pnpm because it relies on pnpm workspace overrides.
|
|
358
|
+
--no-install leaves dependency installation to you and prints the exact commands to continue.
|
|
359
|
+
link auto-detects Astro, React, or Vue from the target package.json and otherwise uses Web.
|
|
360
|
+
Use --renderer to override detection. link adds the same local links and pnpm-workspace.yaml overrides to an existing project.`)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function compileCommand() {
|
|
364
|
+
if (positionals.length < 1 || positionals.length > 2) {
|
|
365
|
+
console.error('Usage: mun compile <input.mun> [output.json]')
|
|
366
|
+
return 1
|
|
367
|
+
}
|
|
368
|
+
const script = resolve(packageRoot, 'bin/compile.mjs')
|
|
369
|
+
const result = spawnSync(process.execPath, [script, ...positionals], {
|
|
370
|
+
cwd: process.cwd(),
|
|
371
|
+
stdio: 'inherit',
|
|
372
|
+
})
|
|
373
|
+
return result.status ?? 1
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function runCommand() {
|
|
377
|
+
if (positionals.length > 1) throw new Error('Usage: mun run [input.mun]')
|
|
378
|
+
return positionals.length ? runNativeSource(positionals[0]) : projectCommand('run', options)
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function editorCommand() {
|
|
382
|
+
const action = positionals[0]
|
|
383
|
+
if (action === 'install') {
|
|
384
|
+
if (positionals.length > 1) options.editor = positionals[1]
|
|
385
|
+
return installEditors({ editor: options.editor, projectRoot: options.projectRoot ?? process.cwd(), global: options.global }) && 0
|
|
386
|
+
}
|
|
387
|
+
if (action === 'export' && positionals[1] === 'vscode') {
|
|
388
|
+
const script = resolve(packageRoot, 'editors/vscode/export.mjs')
|
|
389
|
+
const result = spawnSync(process.execPath, [script, ...positionals.slice(2)], { cwd: packageRoot, stdio: 'inherit' })
|
|
390
|
+
return result.status ?? 1
|
|
391
|
+
}
|
|
392
|
+
console.error('Usage: mun editor install [--editor vim|nvim|vscode|zed|helix|generic|all] [--project <path>] [--global]')
|
|
393
|
+
console.error(' mun editor export vscode [output.vsix]')
|
|
394
|
+
return 1
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function scaffold(projectRoot, commandName) {
|
|
398
|
+
const targetExists = existsSync(projectRoot)
|
|
399
|
+
const targetIsNonEmpty = targetExists && readdirSync(projectRoot).length > 0
|
|
400
|
+
if (targetIsNonEmpty && !options.force) {
|
|
401
|
+
console.error(`Mün ${commandName} cannot use a non-empty directory: ${projectRoot}`)
|
|
402
|
+
console.error('Choose a new directory, use an empty directory, or re-run with --force.')
|
|
403
|
+
return 1
|
|
404
|
+
}
|
|
405
|
+
if (targetIsNonEmpty && options.force) {
|
|
406
|
+
console.warn('Using --force: Mün template files will be replaced; unrelated files will be kept.')
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const target = options.target ?? (options.renderer === 'native' ? 'native' : 'web')
|
|
410
|
+
if (!['native', 'web'].includes(target)) throw new Error(`Unsupported project target: ${target}. Use native or web.`)
|
|
411
|
+
if (target === 'native') {
|
|
412
|
+
if (options.renderer && options.renderer !== 'native') throw new Error('Native scaffolds do not use a Web renderer.')
|
|
413
|
+
if (options.packageManager) packageManagerFor(projectRoot)
|
|
414
|
+
if (options.local) assertSourceCheckout(normalizeLocalRoot(options.localRoot))
|
|
415
|
+
mkdirSync(projectRoot, { recursive: true })
|
|
416
|
+
writeTemplates(projectRoot, [
|
|
417
|
+
['templates/native/mun.toml', 'mun.toml'],
|
|
418
|
+
['templates/native/App.mun', 'Sources/App.mun'],
|
|
419
|
+
['templates/native/gitignore', '.gitignore'],
|
|
420
|
+
])
|
|
421
|
+
mkdirSync(resolve(projectRoot, 'Assets'), { recursive: true })
|
|
422
|
+
console.log(`Created experimental native Mün app in ${projectRoot}`)
|
|
423
|
+
console.log(`\nNext steps:\n cd ${projectRoot}\n mun dev`)
|
|
424
|
+
return 0
|
|
425
|
+
}
|
|
426
|
+
if (options.renderer && options.renderer !== 'web') {
|
|
427
|
+
throw new Error('The built-in project template uses the renderer-independent Web adapter. Use `mun link` to connect an existing React or Vue project.')
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const packageManager = packageManagerFor(projectRoot, { local: options.local })
|
|
431
|
+
const localRoot = options.local ? assertSourceCheckout(normalizeLocalRoot(options.localRoot)) : undefined
|
|
432
|
+
|
|
433
|
+
mkdirSync(projectRoot, { recursive: true })
|
|
434
|
+
writeTemplates(projectRoot, projectFiles)
|
|
435
|
+
if (localRoot) configureLocalDependencies(projectRoot, localRoot, 'web', { includeRootPackage: false })
|
|
436
|
+
console.log(`Created Mün app in ${projectRoot}`)
|
|
437
|
+
if (!options.noInstall) {
|
|
438
|
+
try {
|
|
439
|
+
installDependencies(projectRoot, packageManager)
|
|
440
|
+
} catch (error) {
|
|
441
|
+
printInstallRecovery(projectRoot, packageManager)
|
|
442
|
+
console.error(`Install error: ${error instanceof Error ? error.message : String(error)}`)
|
|
443
|
+
return 1
|
|
444
|
+
}
|
|
445
|
+
} else {
|
|
446
|
+
console.log('Skipped dependency installation (--no-install).')
|
|
447
|
+
}
|
|
448
|
+
printScaffoldNextSteps(projectRoot, packageManager, !options.noInstall)
|
|
449
|
+
return 0
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function linkProject(target) {
|
|
453
|
+
const projectRoot = resolve(process.cwd(), target)
|
|
454
|
+
const localRoot = normalizeLocalRoot(options.localRoot)
|
|
455
|
+
const packageManager = packageManagerFor(projectRoot, { local: true })
|
|
456
|
+
const renderer = options.renderer ?? detectRenderer(projectRoot)
|
|
457
|
+
configureLocalDependencies(projectRoot, localRoot, renderer)
|
|
458
|
+
if (!options.noInstall) installDependencies(projectRoot, packageManager)
|
|
459
|
+
else {
|
|
460
|
+
console.log('Skipped dependency installation (--no-install).')
|
|
461
|
+
console.log(`\nNext step:\n ${packageManager} install`)
|
|
462
|
+
}
|
|
463
|
+
return 0
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function main() {
|
|
467
|
+
if (command === '--version' || command === '-v') { console.log(packageManifest.version); return 0 }
|
|
468
|
+
if (command === '--help' || command === '-h') { printHelp(); return 0 }
|
|
469
|
+
if (options.help || !command) { printHelp(); return 0 }
|
|
470
|
+
if (options.version) { console.log(packageManifest.version); return 0 }
|
|
471
|
+
if (['check', 'fmt', 'build', 'package', 'doctor', 'dev', 'inspect'].includes(command)) {
|
|
472
|
+
if (positionals.length) throw new Error(`Usage: mun ${command} [--project <directory>]`)
|
|
473
|
+
return projectCommand(command, options)
|
|
474
|
+
}
|
|
475
|
+
if (options.help || !command) {
|
|
476
|
+
printHelp()
|
|
477
|
+
return 0
|
|
478
|
+
}
|
|
479
|
+
if (command === 'compile') return compileCommand()
|
|
480
|
+
if (command === 'run') return runCommand()
|
|
481
|
+
if (command === 'create' || command === 'new') {
|
|
482
|
+
const target = positionals[0]
|
|
483
|
+
if (!target || positionals.length > 1) {
|
|
484
|
+
console.error('Usage: mun create <directory> [--pm <manager>] [--no-install] [--force] [--local]')
|
|
485
|
+
return 1
|
|
486
|
+
}
|
|
487
|
+
const projectRoot = resolve(process.cwd(), target)
|
|
488
|
+
return scaffold(projectRoot, 'create')
|
|
489
|
+
}
|
|
490
|
+
if (command === 'init') {
|
|
491
|
+
if (positionals.length > 0) {
|
|
492
|
+
console.error('Usage: mun init [--force] [--no-install] [--local]')
|
|
493
|
+
return 1
|
|
494
|
+
}
|
|
495
|
+
return scaffold(process.cwd(), 'init')
|
|
496
|
+
}
|
|
497
|
+
if (command === 'link') {
|
|
498
|
+
if (positionals.length !== 1) {
|
|
499
|
+
console.error('Usage: mun link <project> [--renderer react|vue|web] [--no-install] [--local-root <path>]')
|
|
500
|
+
return 1
|
|
501
|
+
}
|
|
502
|
+
return linkProject(positionals[0])
|
|
503
|
+
}
|
|
504
|
+
if (command === 'lsp') {
|
|
505
|
+
if (positionals[0] === 'install') return installEditors({ editor: options.editor, projectRoot: options.projectRoot ?? process.cwd(), global: options.global }) && 0
|
|
506
|
+
const script = resolve(packageRoot, 'editors/lsp/mun-lsp.mjs')
|
|
507
|
+
const result = spawnSync(process.execPath, [script, ...argv.slice(1)], { cwd: packageRoot, stdio: 'inherit' })
|
|
508
|
+
return result.status ?? 1
|
|
509
|
+
}
|
|
510
|
+
if (command === 'editor') return editorCommand()
|
|
511
|
+
console.error(`Unknown Mün command: ${command}`)
|
|
512
|
+
printHelp()
|
|
513
|
+
return 1
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
try {
|
|
517
|
+
process.exitCode = await main()
|
|
518
|
+
} catch (error) {
|
|
519
|
+
console.error(`Mün ${command ?? 'command'} failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
520
|
+
process.exitCode = 1
|
|
521
|
+
}
|
package/bin/native.mjs
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process'
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { homedir, tmpdir } from 'node:os'
|
|
4
|
+
import { dirname, relative, resolve, sep } from 'node:path'
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
6
|
+
import { compileMunUiProgram } from '@mun-ui/compiler'
|
|
7
|
+
|
|
8
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
9
|
+
const packageManifest = JSON.parse(readFileSync(resolve(packageRoot, 'package.json'), 'utf8'))
|
|
10
|
+
|
|
11
|
+
function displayPath(path, cwd) {
|
|
12
|
+
const local = relative(cwd, path)
|
|
13
|
+
return local && !local.startsWith('..') ? local : path
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function nativeBinaryName() {
|
|
17
|
+
return process.platform === 'win32' ? 'mun-native.exe' : 'mun-native'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function nativeCacheRoot(env) {
|
|
21
|
+
if (env.MUN_CACHE_DIR) return resolve(env.MUN_CACHE_DIR)
|
|
22
|
+
if (process.platform === 'darwin') return resolve(homedir(), 'Library', 'Caches', 'Mun')
|
|
23
|
+
if (process.platform === 'win32') {
|
|
24
|
+
return resolve(env.LOCALAPPDATA || resolve(homedir(), 'AppData', 'Local'), 'Mun', 'Cache')
|
|
25
|
+
}
|
|
26
|
+
return resolve(env.XDG_CACHE_HOME || resolve(homedir(), '.cache'), 'mun')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function runProcess(command, args, options) {
|
|
30
|
+
const result = spawnSync(command, args, options)
|
|
31
|
+
if (result.error) throw new Error(`Could not run ${command}: ${result.error.message}`)
|
|
32
|
+
return result.status ?? 1
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function resolveNativeHost(cwd, env, irVersion) {
|
|
36
|
+
const override = env.MUN_NATIVE_HOST?.trim()
|
|
37
|
+
if (override) {
|
|
38
|
+
const command = override.includes('/') || override.includes('\\') || override.includes(sep)
|
|
39
|
+
? resolve(cwd, override)
|
|
40
|
+
: override
|
|
41
|
+
return { kind: 'binary', command }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const binary = nativeBinaryName()
|
|
45
|
+
const key = `${process.platform}-${process.arch}`
|
|
46
|
+
const packaged = resolve(packageRoot, 'native', 'bin', key, binary)
|
|
47
|
+
if (existsSync(packaged)) {
|
|
48
|
+
verifyPackagedHost(resolve(packageRoot, 'native', 'bin', key, 'mun-native.json'), key, irVersion)
|
|
49
|
+
return { kind: 'binary', command: packaged }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Building the host from source is a development path for repository
|
|
53
|
+
// checkouts (or an explicit opt-in); installed packages use a packaged host.
|
|
54
|
+
const manifest = resolve(packageRoot, 'native', 'Cargo.toml')
|
|
55
|
+
const developmentCheckout = existsSync(resolve(packageRoot, '.git'))
|
|
56
|
+
if (existsSync(manifest) && (developmentCheckout || env.MUN_NATIVE_BUILD_FROM_SOURCE === '1')) {
|
|
57
|
+
return { kind: 'cargo', manifest }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
throw new Error(
|
|
61
|
+
`No Mün native host is packaged for ${key} in ${packageManifest.name}@${packageManifest.version}. ` +
|
|
62
|
+
'Install a release that includes this platform, set MUN_NATIVE_HOST to a mun-native executable, ' +
|
|
63
|
+
'or set MUN_NATIVE_BUILD_FROM_SOURCE=1 to build one with Cargo.',
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Reject a packaged host assembled for another package version, IR contract or platform. */
|
|
68
|
+
function verifyPackagedHost(path, key, irVersion) {
|
|
69
|
+
let metadata
|
|
70
|
+
try {
|
|
71
|
+
metadata = JSON.parse(readFileSync(path, 'utf8'))
|
|
72
|
+
} catch (error) {
|
|
73
|
+
throw new Error(`Packaged Mün native host for ${key} has no readable metadata (${path}): ${error.message}`)
|
|
74
|
+
}
|
|
75
|
+
const expected = {
|
|
76
|
+
packageVersion: packageManifest.version,
|
|
77
|
+
semanticUiIrVersion: irVersion,
|
|
78
|
+
platform: process.platform,
|
|
79
|
+
arch: process.arch,
|
|
80
|
+
}
|
|
81
|
+
for (const [field, value] of Object.entries(expected)) {
|
|
82
|
+
if (metadata[field] !== value) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Packaged Mün native host for ${key} was built for ${field} ${JSON.stringify(metadata[field])}, ` +
|
|
85
|
+
`but this ${packageManifest.name} requires ${JSON.stringify(value)}. Reinstall ${packageManifest.name} or set MUN_NATIVE_HOST.`,
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function runNativeSource(inputArg, {
|
|
92
|
+
cwd = process.cwd(),
|
|
93
|
+
env = process.env,
|
|
94
|
+
} = {}) {
|
|
95
|
+
const input = resolve(cwd, inputArg)
|
|
96
|
+
if (!input.endsWith('.mun')) {
|
|
97
|
+
throw new Error(`Mün run expects canonical .mun source: ${displayPath(input, cwd)}`)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const source = readFileSync(input, 'utf8')
|
|
101
|
+
const program = compileMunUiProgram(source, input)
|
|
102
|
+
const temporary = mkdtempSync(resolve(tmpdir(), 'mun-native-'))
|
|
103
|
+
const ir = resolve(temporary, 'program.mun.ir.json')
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
writeFileSync(ir, `${JSON.stringify(program, null, 2)}\n`)
|
|
107
|
+
const host = resolveNativeHost(cwd, env, program.version)
|
|
108
|
+
|
|
109
|
+
if (host.kind === 'binary') {
|
|
110
|
+
return runProcess(host.command, [ir], { cwd, env, stdio: 'inherit' })
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const cache = resolve(
|
|
114
|
+
nativeCacheRoot(env),
|
|
115
|
+
'native',
|
|
116
|
+
packageManifest.version,
|
|
117
|
+
`${process.platform}-${process.arch}`,
|
|
118
|
+
)
|
|
119
|
+
mkdirSync(cache, { recursive: true })
|
|
120
|
+
const cargo = env.CARGO?.trim() || 'cargo'
|
|
121
|
+
return runProcess(
|
|
122
|
+
cargo,
|
|
123
|
+
['run', '--locked', '--manifest-path', host.manifest, '-p', 'mun-native', '--', ir],
|
|
124
|
+
{
|
|
125
|
+
cwd: packageRoot,
|
|
126
|
+
env: { ...env, CARGO_TARGET_DIR: env.CARGO_TARGET_DIR || cache },
|
|
127
|
+
stdio: 'inherit',
|
|
128
|
+
},
|
|
129
|
+
)
|
|
130
|
+
} finally {
|
|
131
|
+
rmSync(temporary, { recursive: true, force: true })
|
|
132
|
+
}
|
|
133
|
+
}
|