@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"experimental.js","sourceRoot":"","sources":["../src/experimental.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,cAAc,cAAc,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.js","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA"}
|
package/dist/legacy.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,cAAc,sBAAsB,CAAA"}
|
package/dist/legacy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy.js","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,cAAc,sBAAsB,CAAA"}
|
package/dist/mun.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Mün View authoring and optional language compiler entry point. */
|
|
2
|
+
export * from "@mun-ui/core";
|
|
3
|
+
export { compileMunFile, compileMunUiProgram } from "@mun-ui/compiler";
|
|
4
|
+
export type { MunUiCompileOptions } from "@mun-ui/compiler";
|
|
5
|
+
//# sourceMappingURL=mun.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mun.d.ts","sourceRoot":"","sources":["../src/mun.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/mun.js
ADDED
package/dist/mun.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mun.js","sourceRoot":"","sources":["../src/mun.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in: progressive (variable-radius) blur. Bundled with `@mun-ui/ui`, never
|
|
3
|
+
* imported implicitly; `.mun` files import it explicitly like any ES module.
|
|
4
|
+
* The implementation lives in the internal `@mun-ui/progressive-blur` module, so
|
|
5
|
+
* old and new import paths share one module instance.
|
|
6
|
+
*/
|
|
7
|
+
export * from "@mun-ui/progressive-blur";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/progressive-blur/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in: progressive (variable-radius) blur. Bundled with `@mun-ui/ui`, never
|
|
3
|
+
* imported implicitly; `.mun` files import it explicitly like any ES module.
|
|
4
|
+
* The implementation lives in the internal `@mun-ui/progressive-blur` module, so
|
|
5
|
+
* old and new import paths share one module instance.
|
|
6
|
+
*/
|
|
7
|
+
export * from "@mun-ui/progressive-blur";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/progressive-blur/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,0BAA0B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/progressive-blur/plan.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,cAAc,+BAA+B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/progressive-blur/plan.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,cAAc,+BAA+B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-types.d.ts","sourceRoot":"","sources":["../src/react-types.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-types.js","sourceRoot":"","sources":["../src/react-types.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Global browser rendering quality, shared by optional GPU renderers and blur. */
|
|
2
|
+
export { getRenderingQuality, observeRenderingQuality, prepareRenderingQuality, setRenderingQualityDebug } from "@mun-ui/animation/rendering-quality";
|
|
3
|
+
export type { RenderingQuality, RenderingQualityController, RenderingQualitySnapshot } from "@mun-ui/animation/rendering-quality";
|
|
4
|
+
//# sourceMappingURL=rendering-quality.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rendering-quality.d.ts","sourceRoot":"","sources":["../src/rendering-quality.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AACrJ,YAAY,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/* SPDX-License-Identifier: MIT */
|
|
2
|
+
/** Global browser rendering quality, shared by optional GPU renderers and blur. */
|
|
3
|
+
export { getRenderingQuality, observeRenderingQuality, prepareRenderingQuality, setRenderingQualityDebug } from "@mun-ui/animation/rendering-quality";
|
|
4
|
+
//# sourceMappingURL=rendering-quality.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rendering-quality.js","sourceRoot":"","sources":["../src/rendering-quality.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAElC,mFAAmF;AACnF,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA"}
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
package/dist/state.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
|
package/dist/vite.js
ADDED
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { homedir } from 'node:os'
|
|
3
|
+
import { dirname, resolve } from 'node:path'
|
|
4
|
+
|
|
5
|
+
const SERVER_COMMAND = ['mun', 'lsp', '--stdio']
|
|
6
|
+
|
|
7
|
+
function readJson(path, fallback = undefined) {
|
|
8
|
+
try { return JSON.parse(readFileSync(path, 'utf8')) } catch { return fallback }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function writeJson(path, value) {
|
|
12
|
+
mkdirSync(dirname(path), { recursive: true })
|
|
13
|
+
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function writeText(path, value) {
|
|
17
|
+
mkdirSync(dirname(path), { recursive: true })
|
|
18
|
+
writeFileSync(path, value)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function nvimConfig() {
|
|
22
|
+
return `-- Mün language server integration. Generated by mun.\nvim.filetype.add({ extension = { ["mun"] = "mun" } })\nlocal group = vim.api.nvim_create_augroup("MunLsp", { clear = true })\nvim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {\n group = group,\n pattern = { "*.mun" },\n callback = function(args)\n vim.lsp.start({\n name = "mun",\n cmd = { "${SERVER_COMMAND[0]}", "${SERVER_COMMAND[1]}", "${SERVER_COMMAND[2]}" },\n root_dir = vim.fs.root(args.buf, { "mun.toml", ".git" }) or vim.fn.getcwd(),\n })\n end,\n})\n`
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function vimConfig() {
|
|
26
|
+
return `" Mün language server integration. Generated by mun.\nif exists('*lsp#register_server')\n augroup mun_lsp\n autocmd!\n autocmd User lsp_setup call lsp#register_server({\n \\ 'name': 'mun',\n \\ 'cmd': {server_info -> ['${SERVER_COMMAND[0]}', '${SERVER_COMMAND[1]}', '${SERVER_COMMAND[2]}']},\n \\ 'allowlist': ['mun']\n \\ })\n autocmd BufNewFile,BufRead *.mun set filetype=mun\n augroup END\nendif\n`
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function zedConfig() {
|
|
30
|
+
return { language_servers: { mun: { command: SERVER_COMMAND[0], args: SERVER_COMMAND.slice(1) } }, languages: { Mun: { file_types: ['mun'], language_servers: ['mun'] } } }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function helixConfig() {
|
|
34
|
+
return `[language-server.mun]\ncommand = "${SERVER_COMMAND[0]}"\nargs = ["${SERVER_COMMAND[1]}", "${SERVER_COMMAND[2]}"]\n\n[[language]]\nname = "mun"\nfile-types = ["mun"]\nlanguage-servers = ["mun"]\n`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function installEditors({ editor = 'all', projectRoot = process.cwd(), global = false } = {}) {
|
|
38
|
+
const root = global ? homedir() : resolve(projectRoot)
|
|
39
|
+
const target = global ? 'global' : root
|
|
40
|
+
const installed = []
|
|
41
|
+
const selected = editor === 'all' ? new Set(['vim', 'nvim', 'vscode', 'zed', 'helix', 'generic']) : new Set(editor.split(',').map(value => value.trim()).filter(Boolean))
|
|
42
|
+
const unknown = [...selected].filter(value => !['vim', 'nvim', 'vscode', 'zed', 'helix', 'generic'].includes(value))
|
|
43
|
+
if (unknown.length) throw new Error(`Unknown editor: ${unknown.join(', ')}. Use vim, nvim, vscode, zed, helix, generic, or all.`)
|
|
44
|
+
if (selected.has('nvim')) {
|
|
45
|
+
const path = global ? resolve(root, '.config/nvim/lua/mun/lsp.lua') : resolve(root, '.mun/editors/nvim.lua')
|
|
46
|
+
writeText(path, nvimConfig()); installed.push(path)
|
|
47
|
+
}
|
|
48
|
+
if (selected.has('vim')) {
|
|
49
|
+
const path = global ? resolve(root, '.vim/pack/mun/start/mun-lsp/plugin/mun-lsp.vim') : resolve(root, '.mun/editors/vim.vim')
|
|
50
|
+
writeText(path, vimConfig()); installed.push(path)
|
|
51
|
+
}
|
|
52
|
+
if (selected.has('vscode')) {
|
|
53
|
+
const settingsPath = resolve(root, '.vscode/settings.json')
|
|
54
|
+
let settingsOutput = settingsPath
|
|
55
|
+
const settings = readJson(settingsPath, undefined)
|
|
56
|
+
if (settings || !existsSync(settingsPath)) {
|
|
57
|
+
const mergedSettings = settings ?? {}
|
|
58
|
+
mergedSettings['files.associations'] = { ...(mergedSettings['files.associations'] ?? {}), '*.mun': 'mun' }
|
|
59
|
+
writeJson(settingsPath, mergedSettings)
|
|
60
|
+
} else {
|
|
61
|
+
settingsOutput = resolve(root, '.mun/editors/vscode-settings.json')
|
|
62
|
+
writeJson(settingsOutput, {
|
|
63
|
+
'files.associations': { '*.mun': 'mun' },
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
const extensionsPath = resolve(root, '.vscode/extensions.json')
|
|
67
|
+
let extensionsOutput = extensionsPath
|
|
68
|
+
const extensions = readJson(extensionsPath, undefined)
|
|
69
|
+
if (extensions || !existsSync(extensionsPath)) {
|
|
70
|
+
const mergedExtensions = extensions ?? {}
|
|
71
|
+
mergedExtensions.recommendations = [...new Set([...(mergedExtensions.recommendations ?? []), 'mun.mun-language-support'])]
|
|
72
|
+
writeJson(extensionsPath, mergedExtensions)
|
|
73
|
+
} else {
|
|
74
|
+
extensionsOutput = resolve(root, '.mun/editors/vscode-extensions.json')
|
|
75
|
+
writeText(extensionsOutput, '{\n "recommendations": ["mun.mun-language-support"]\n}\n')
|
|
76
|
+
}
|
|
77
|
+
installed.push(settingsOutput, extensionsOutput)
|
|
78
|
+
}
|
|
79
|
+
if (selected.has('zed')) {
|
|
80
|
+
const path = global ? resolve(root, '.config/zed/settings.json') : resolve(root, '.mun/editors/zed.json')
|
|
81
|
+
const existing = readJson(path, undefined)
|
|
82
|
+
if (existsSync(path) && !existing) throw new Error(`Cannot safely merge ${path}; preserve it and install a project-local integration instead.`)
|
|
83
|
+
const generated = zedConfig()
|
|
84
|
+
writeJson(path, { ...existing, language_servers: { ...existing?.language_servers, ...generated.language_servers }, languages: { ...existing?.languages, ...generated.languages } }); installed.push(path)
|
|
85
|
+
}
|
|
86
|
+
if (selected.has('helix')) {
|
|
87
|
+
const path = global ? resolve(root, '.config/helix/languages.toml') : resolve(root, '.mun/editors/helix.toml')
|
|
88
|
+
const existing = existsSync(path) ? readFileSync(path, 'utf8') : ''
|
|
89
|
+
if (!existing.includes('[language-server.mun]')) writeText(path, `${existing}${existing && !existing.endsWith('\n') ? '\n' : ''}${helixConfig()}`)
|
|
90
|
+
installed.push(path)
|
|
91
|
+
}
|
|
92
|
+
if (selected.has('generic')) {
|
|
93
|
+
const path = resolve(root, '.mun/lsp.json')
|
|
94
|
+
writeJson(path, { name: 'mun', command: SERVER_COMMAND[0], args: SERVER_COMMAND.slice(1), transport: 'stdio', fileExtensions: ['.mun'] })
|
|
95
|
+
installed.push(path)
|
|
96
|
+
}
|
|
97
|
+
console.log(`Installed Mün LSP integration (${[...selected].join(', ')}) for ${target}.`)
|
|
98
|
+
installed.forEach(path => console.log(` ${path}`))
|
|
99
|
+
return installed
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { installEditors, SERVER_COMMAND }
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync, existsSync, readdirSync, statSync } from 'node:fs'
|
|
3
|
+
import { dirname, resolve } from 'node:path'
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
5
|
+
import { LanguageService, tokenTypes } from './service.mjs'
|
|
6
|
+
import { offsetAt } from './source.mjs'
|
|
7
|
+
import { MessageReader, encode } from '../vscode/protocol.mjs'
|
|
8
|
+
|
|
9
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..')
|
|
10
|
+
const version = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8')).version
|
|
11
|
+
const service = new LanguageService()
|
|
12
|
+
const open = new Set()
|
|
13
|
+
let shutdown = false
|
|
14
|
+
function send(message) { process.stdout.write(encode(message)) }
|
|
15
|
+
function response(id, result) { send({ jsonrpc: '2.0', id, result }) }
|
|
16
|
+
function error(id, code, message) { send({ jsonrpc: '2.0', id, error: { code, message } }) }
|
|
17
|
+
function publish(uri) { send({ jsonrpc: '2.0', method: 'textDocument/publishDiagnostics', params: { uri, diagnostics: service.diagnostics(uri) } }) }
|
|
18
|
+
|
|
19
|
+
function projectRoot(path) {
|
|
20
|
+
let directory = existsSync(path) && statSync(path).isDirectory() ? path : dirname(path)
|
|
21
|
+
while (true) {
|
|
22
|
+
if (existsSync(resolve(directory, 'mun.toml'))) return directory
|
|
23
|
+
const parent = dirname(directory)
|
|
24
|
+
if (parent === directory) return undefined
|
|
25
|
+
directory = parent
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function indexProject(path) {
|
|
29
|
+
const directory = projectRoot(path)
|
|
30
|
+
if (!directory) return
|
|
31
|
+
function walk(path) {
|
|
32
|
+
for (const entry of readdirSync(path, { withFileTypes: true })) {
|
|
33
|
+
if (entry.name.startsWith('.') || ['node_modules', 'Assets', 'build', 'dist'].includes(entry.name) || entry.isSymbolicLink()) continue
|
|
34
|
+
const file = resolve(path, entry.name)
|
|
35
|
+
if (entry.isDirectory()) walk(file)
|
|
36
|
+
else if (entry.name.endsWith('.mun') && entry.isFile()) {
|
|
37
|
+
const uri = pathToFileURL(file).href
|
|
38
|
+
if (!open.has(uri)) service.update(uri, readFileSync(file, 'utf8'))
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
walk(directory)
|
|
43
|
+
}
|
|
44
|
+
function handle(message) {
|
|
45
|
+
const { id, method, params = {} } = message
|
|
46
|
+
if (method === 'initialize') {
|
|
47
|
+
for (const uri of [...(params.workspaceFolders ?? []).map(folder => folder.uri), ...(params.rootUri ? [params.rootUri] : [])]) {
|
|
48
|
+
try { indexProject(fileURLToPath(uri)) } catch (e) { console.error(e.message) }
|
|
49
|
+
}
|
|
50
|
+
response(id, {
|
|
51
|
+
capabilities: {
|
|
52
|
+
positionEncoding: 'utf-16',
|
|
53
|
+
textDocumentSync: { openClose: true, change: 2, save: { includeText: true } },
|
|
54
|
+
completionProvider: { triggerCharacters: ['.', '@', '$', ':'] }, hoverProvider: true,
|
|
55
|
+
signatureHelpProvider: { triggerCharacters: ['(', ',', ':'] }, definitionProvider: true,
|
|
56
|
+
referencesProvider: true, renameProvider: { prepareProvider: true },
|
|
57
|
+
documentFormattingProvider: true, documentSymbolProvider: true, workspaceSymbolProvider: true,
|
|
58
|
+
semanticTokensProvider: { legend: { tokenTypes, tokenModifiers: [] }, full: true },
|
|
59
|
+
foldingRangeProvider: true, selectionRangeProvider: true,
|
|
60
|
+
codeActionProvider: { codeActionKinds: ['quickfix'] },
|
|
61
|
+
},
|
|
62
|
+
serverInfo: { name: 'mun-lsp', version },
|
|
63
|
+
}); return
|
|
64
|
+
}
|
|
65
|
+
if (method === 'shutdown') { shutdown = true; response(id, null); return }
|
|
66
|
+
if (method === 'exit') { process.exit(shutdown ? 0 : 1); return }
|
|
67
|
+
if (method === 'initialized' || method === '$/cancelRequest') return
|
|
68
|
+
if (shutdown) { if (id !== undefined) error(id, -32600, 'Server has shut down.'); return }
|
|
69
|
+
if (method === 'textDocument/didOpen') {
|
|
70
|
+
const { uri, text, version } = params.textDocument
|
|
71
|
+
if (!uri.endsWith('.mun')) return
|
|
72
|
+
try { indexProject(fileURLToPath(uri)) } catch (e) { console.error(e.message) }
|
|
73
|
+
open.add(uri); service.update(uri, text, version); publish(uri); return
|
|
74
|
+
}
|
|
75
|
+
if (method === 'textDocument/didChange') {
|
|
76
|
+
const { uri, version } = params.textDocument
|
|
77
|
+
let source = service.snapshot(uri)?.source ?? ''
|
|
78
|
+
for (const change of params.contentChanges ?? []) source = change.range ? source.slice(0, offsetAt(source, change.range.start)) + change.text + source.slice(offsetAt(source, change.range.end)) : change.text
|
|
79
|
+
service.update(uri, source, version); publish(uri); return
|
|
80
|
+
}
|
|
81
|
+
if (method === 'textDocument/didSave') {
|
|
82
|
+
const { uri } = params.textDocument
|
|
83
|
+
if (params.text !== undefined) service.update(uri, params.text)
|
|
84
|
+
publish(uri); return
|
|
85
|
+
}
|
|
86
|
+
if (method === 'textDocument/didClose') {
|
|
87
|
+
const { uri } = params.textDocument
|
|
88
|
+
open.delete(uri)
|
|
89
|
+
try { service.update(uri, readFileSync(fileURLToPath(uri), 'utf8')) } catch { service.remove(uri) }
|
|
90
|
+
send({ jsonrpc: '2.0', method: 'textDocument/publishDiagnostics', params: { uri, diagnostics: [] } }); return
|
|
91
|
+
}
|
|
92
|
+
if (method === 'workspace/didChangeWatchedFiles') {
|
|
93
|
+
for (const change of params.changes ?? []) {
|
|
94
|
+
if (!change.uri.endsWith('.mun') || open.has(change.uri)) continue
|
|
95
|
+
if (change.type === 3) service.remove(change.uri)
|
|
96
|
+
else try { service.update(change.uri, readFileSync(fileURLToPath(change.uri), 'utf8')) } catch (e) { console.error(e.message) }
|
|
97
|
+
}
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
const uri = params.textDocument?.uri
|
|
101
|
+
const requests = {
|
|
102
|
+
'textDocument/completion': () => ({ isIncomplete: false, items: service.completion(uri, params.position) }),
|
|
103
|
+
'textDocument/hover': () => service.hover(uri, params.position),
|
|
104
|
+
'textDocument/signatureHelp': () => service.signatureHelp(uri, params.position),
|
|
105
|
+
'textDocument/definition': () => service.definition(uri, params.position),
|
|
106
|
+
'textDocument/references': () => service.references(uri, params.position, params.context?.includeDeclaration),
|
|
107
|
+
'textDocument/prepareRename': () => service.prepareRename(uri, params.position),
|
|
108
|
+
'textDocument/rename': () => service.rename(uri, params.position, params.newName),
|
|
109
|
+
'textDocument/formatting': () => service.formatting(uri),
|
|
110
|
+
'textDocument/codeAction': () => service.codeActions(uri, params.range, params.context),
|
|
111
|
+
'textDocument/documentSymbol': () => service.symbols(uri),
|
|
112
|
+
'workspace/symbol': () => service.workspaceSymbols(params.query ?? ''),
|
|
113
|
+
'textDocument/semanticTokens/full': () => service.semanticTokens(uri),
|
|
114
|
+
'textDocument/foldingRange': () => service.folding(uri),
|
|
115
|
+
'textDocument/selectionRange': () => service.selectionRanges(uri, params.positions),
|
|
116
|
+
}
|
|
117
|
+
if (id !== undefined) {
|
|
118
|
+
if (!requests[method]) { error(id, -32601, `Unsupported method: ${method}`); return }
|
|
119
|
+
try { response(id, requests[method]()) } catch (e) { error(id, -32602, e.message) }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const reader = new MessageReader(handle, e => { console.error(`LSP protocol error: ${e.message}`); process.exitCode = 1; process.stdin.destroy() })
|
|
123
|
+
process.stdin.on('data', chunk => reader.feed(chunk))
|