@mun-ui/ui 0.0.0-stage → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +114 -2
  3. package/bin/compile.mjs +38 -0
  4. package/bin/desktop.mjs +143 -0
  5. package/bin/dev-protocol.mjs +94 -0
  6. package/bin/formatter.mjs +109 -0
  7. package/bin/hot-reload.mjs +38 -0
  8. package/bin/mun.mjs +538 -0
  9. package/bin/native.mjs +133 -0
  10. package/bin/pnpm-workspace.mjs +58 -0
  11. package/bin/program-patch.mjs +104 -0
  12. package/bin/project.mjs +322 -0
  13. package/bin/watch.mjs +316 -0
  14. package/bin/workflow.mjs +261 -0
  15. package/dist/astro.d.ts +3 -0
  16. package/dist/astro.d.ts.map +1 -0
  17. package/dist/astro.js +3 -0
  18. package/dist/astro.js.map +1 -0
  19. package/dist/closures.d.ts +2 -0
  20. package/dist/closures.d.ts.map +1 -0
  21. package/dist/closures.js +2 -0
  22. package/dist/closures.js.map +1 -0
  23. package/dist/compiler/index.d.ts +2 -0
  24. package/dist/compiler/index.d.ts.map +1 -0
  25. package/dist/compiler/index.js +2 -0
  26. package/dist/compiler/index.js.map +1 -0
  27. package/dist/core.d.ts +3 -0
  28. package/dist/core.d.ts.map +1 -0
  29. package/dist/core.js +3 -0
  30. package/dist/core.js.map +1 -0
  31. package/dist/experimental.d.ts +2 -0
  32. package/dist/experimental.d.ts.map +1 -0
  33. package/dist/experimental.js +2 -0
  34. package/dist/experimental.js.map +1 -0
  35. package/dist/index.d.ts +3 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +3 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/jsx-dev-runtime.d.ts +2 -0
  40. package/dist/jsx-dev-runtime.d.ts.map +1 -0
  41. package/dist/jsx-dev-runtime.js +2 -0
  42. package/dist/jsx-dev-runtime.js.map +1 -0
  43. package/dist/jsx-runtime.d.ts +2 -0
  44. package/dist/jsx-runtime.d.ts.map +1 -0
  45. package/dist/jsx-runtime.js +2 -0
  46. package/dist/jsx-runtime.js.map +1 -0
  47. package/dist/legacy.d.ts +3 -0
  48. package/dist/legacy.d.ts.map +1 -0
  49. package/dist/legacy.js +3 -0
  50. package/dist/legacy.js.map +1 -0
  51. package/dist/mun.d.ts +5 -0
  52. package/dist/mun.d.ts.map +1 -0
  53. package/dist/mun.js +4 -0
  54. package/dist/mun.js.map +1 -0
  55. package/dist/progressive-blur/index.d.ts +8 -0
  56. package/dist/progressive-blur/index.d.ts.map +1 -0
  57. package/dist/progressive-blur/index.js +8 -0
  58. package/dist/progressive-blur/index.js.map +1 -0
  59. package/dist/progressive-blur/plan.d.ts +3 -0
  60. package/dist/progressive-blur/plan.d.ts.map +1 -0
  61. package/dist/progressive-blur/plan.js +3 -0
  62. package/dist/progressive-blur/plan.js.map +1 -0
  63. package/dist/react-types.d.ts +2 -0
  64. package/dist/react-types.d.ts.map +1 -0
  65. package/dist/react-types.js +2 -0
  66. package/dist/react-types.js.map +1 -0
  67. package/dist/rendering-quality.d.ts +4 -0
  68. package/dist/rendering-quality.d.ts.map +1 -0
  69. package/dist/rendering-quality.js +4 -0
  70. package/dist/rendering-quality.js.map +1 -0
  71. package/dist/state.d.ts +2 -0
  72. package/dist/state.d.ts.map +1 -0
  73. package/dist/state.js +2 -0
  74. package/dist/state.js.map +1 -0
  75. package/dist/types.d.ts +2 -0
  76. package/dist/types.d.ts.map +1 -0
  77. package/dist/types.js +2 -0
  78. package/dist/types.js.map +1 -0
  79. package/dist/vite.d.ts +2 -0
  80. package/dist/vite.d.ts.map +1 -0
  81. package/dist/vite.js +2 -0
  82. package/dist/vite.js.map +1 -0
  83. package/editors/install.mjs +102 -0
  84. package/editors/lsp/mun-lsp.mjs +123 -0
  85. package/editors/lsp/service.mjs +306 -0
  86. package/editors/lsp/source.mjs +58 -0
  87. package/editors/vscode/client.mjs +40 -0
  88. package/editors/vscode/dev-client.mjs +83 -0
  89. package/editors/vscode/discovery.mjs +46 -0
  90. package/editors/vscode/export.mjs +42 -0
  91. package/editors/vscode/extension.cjs +226 -0
  92. package/editors/vscode/language-configuration.json +15 -0
  93. package/editors/vscode/package.json +119 -0
  94. package/editors/vscode/protocol.mjs +29 -0
  95. package/editors/vscode/syntaxes/mun.tmLanguage.json +130 -0
  96. package/native/Cargo.lock +3581 -0
  97. package/native/Cargo.toml +21 -0
  98. package/native/README.md +21 -0
  99. package/native/mun-native/Cargo.toml +23 -0
  100. package/native/mun-native/src/accessibility.rs +738 -0
  101. package/native/mun-native/src/dev.rs +604 -0
  102. package/native/mun-native/src/host_services.rs +202 -0
  103. package/native/mun-native/src/lib.rs +2843 -0
  104. package/native/mun-native/src/main.rs +204 -0
  105. package/native/mun-native/src/offscreen.rs +393 -0
  106. package/native/mun-native/src/rect.wgsl +63 -0
  107. package/native/mun-native/src/text.rs +401 -0
  108. package/native/mun-native/tests/offscreen_rendering.rs +161 -0
  109. package/native/mun-native/tests/stress.rs +408 -0
  110. package/native/mun-native/tests/window_lifecycle.rs +183 -0
  111. package/native/mun-runtime/Cargo.toml +13 -0
  112. package/native/mun-runtime/src/accessibility.rs +193 -0
  113. package/native/mun-runtime/src/collection.rs +1090 -0
  114. package/native/mun-runtime/src/gesture.rs +1070 -0
  115. package/native/mun-runtime/src/input.rs +325 -0
  116. package/native/mun-runtime/src/ir.rs +852 -0
  117. package/native/mun-runtime/src/kinetics.rs +500 -0
  118. package/native/mun-runtime/src/layout.rs +258 -0
  119. package/native/mun-runtime/src/layout_cache.rs +209 -0
  120. package/native/mun-runtime/src/lib.rs +52 -0
  121. package/native/mun-runtime/src/motion.rs +1162 -0
  122. package/native/mun-runtime/src/retained.rs +574 -0
  123. package/native/mun-runtime/src/runtime.rs +7449 -0
  124. package/native/mun-runtime/src/scene.rs +567 -0
  125. package/native/mun-runtime/src/scroll.rs +521 -0
  126. package/native/mun-runtime/src/scroll_view.rs +220 -0
  127. package/native/mun-runtime/src/text_edit.rs +670 -0
  128. package/native/mun-runtime/src/timeline.rs +1534 -0
  129. package/native/mun-runtime/src/validate.rs +677 -0
  130. package/native/mun-runtime/tests/accessibility_semantics.rs +168 -0
  131. package/native/mun-runtime/tests/compiler_contract.rs +110 -0
  132. package/native/mun-runtime/tests/flexible_frames.rs +47 -0
  133. package/native/mun-runtime/tests/host_services.rs +107 -0
  134. package/native/mun-runtime/tests/hot_update.rs +367 -0
  135. package/native/mun-runtime/tests/incremental_runtime.rs +323 -0
  136. package/native/mun-runtime/tests/ir_validation.rs +167 -0
  137. package/native/mun-runtime/tests/keyed_collections.rs +251 -0
  138. package/native/mun-runtime/tests/minimum_window_size.rs +80 -0
  139. package/native/mun-runtime/tests/native_controls_style.rs +491 -0
  140. package/native/mun-runtime/tests/native_demo.rs +285 -0
  141. package/native/mun-runtime/tests/native_layout_style.rs +175 -0
  142. package/native/mun-runtime/tests/native_settings_pane.rs +152 -0
  143. package/native/mun-runtime/tests/priority_proposals.rs +69 -0
  144. package/native/mun-runtime/tests/scroll_view.rs +403 -0
  145. package/native/mun-runtime/tests/text_editing.rs +491 -0
  146. package/native/mun-runtime/tests/text_proposals.rs +42 -0
  147. package/native/mun-runtime/tests/typography.rs +63 -0
  148. package/package.json +213 -3
  149. package/schemas/README.md +19 -0
  150. package/schemas/semantic-ui-ir-v1.schema.json +2061 -0
  151. package/templates/desktop/gitignore +5 -0
  152. package/templates/desktop/package.json +10 -0
  153. package/templates/desktop/src-tauri/Cargo.toml +14 -0
  154. package/templates/desktop/src-tauri/build.rs +1 -0
  155. package/templates/desktop/src-tauri/capabilities/main.json +12 -0
  156. package/templates/desktop/src-tauri/icons/icon.icns +0 -0
  157. package/templates/desktop/src-tauri/icons/icon.ico +0 -0
  158. package/templates/desktop/src-tauri/icons/icon.png +0 -0
  159. package/templates/desktop/src-tauri/src/main.rs +2 -0
  160. package/templates/desktop/src-tauri/tauri.conf.json +42 -0
  161. package/templates/desktop/vite.config.ts +10 -0
  162. package/templates/native/App.mun +15 -0
  163. package/templates/native/gitignore +3 -0
  164. package/templates/native/mun.toml +8 -0
  165. package/templates/project/gitignore +5 -0
  166. package/templates/project/index.html +13 -0
  167. package/templates/project/package.json +24 -0
  168. package/templates/project/src/App.mun +13 -0
  169. package/templates/project/src/index.css +30 -0
  170. package/templates/project/src/main.ts +5 -0
  171. package/templates/project/tsconfig.json +20 -0
  172. package/templates/project/vite.config.ts +6 -0
  173. package/templates/vite/src/App.css +134 -0
  174. package/templates/vite/src/App.tsx +91 -0
  175. package/templates/vite/src/index.css +23 -0
  176. package/templates/vite/vite.config.ts +10 -0
@@ -0,0 +1,2 @@
1
+ export * from "@mun-ui/react/legacy/experimental";
2
+ //# sourceMappingURL=experimental.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experimental.js","sourceRoot":"","sources":["../src/experimental.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** SwiftUI-inspired JavaScript View authoring API. Use @mun-ui/web to render. */
2
+ export * from "@mun-ui/core";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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,3 @@
1
+ /** SwiftUI-inspired JavaScript View authoring API. Use @mun-ui/web to render. */
2
+ export * from "@mun-ui/core";
3
+ //# sourceMappingURL=index.js.map
@@ -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,2 @@
1
+ export * from "@mun-ui/react/legacy/jsx-dev-runtime";
2
+ //# sourceMappingURL=jsx-dev-runtime.d.ts.map
@@ -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,2 @@
1
+ export * from "@mun-ui/react/legacy/jsx-dev-runtime";
2
+ //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -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,2 @@
1
+ export * from "@mun-ui/react/legacy/jsx-runtime";
2
+ //# sourceMappingURL=jsx-runtime.d.ts.map
@@ -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,2 @@
1
+ export * from "@mun-ui/react/legacy/jsx-runtime";
2
+ //# sourceMappingURL=jsx-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** Legacy React compatibility facade. Prefer the renderer-independent Mün UI API. */
2
+ export * from "@mun-ui/react/legacy";
3
+ //# sourceMappingURL=legacy.d.ts.map
@@ -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,3 @@
1
+ /** Legacy React compatibility facade. Prefer the renderer-independent Mün UI API. */
2
+ export * from "@mun-ui/react/legacy";
3
+ //# sourceMappingURL=legacy.js.map
@@ -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
@@ -0,0 +1,4 @@
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
+ //# sourceMappingURL=mun.js.map
@@ -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,3 @@
1
+ /** Opt-in: the pure, DOM-free progressive-blur planner shared by every renderer. */
2
+ export * from "@mun-ui/progressive-blur/plan";
3
+ //# sourceMappingURL=plan.d.ts.map
@@ -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,3 @@
1
+ /** Opt-in: the pure, DOM-free progressive-blur planner shared by every renderer. */
2
+ export * from "@mun-ui/progressive-blur/plan";
3
+ //# sourceMappingURL=plan.js.map
@@ -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,2 @@
1
+ export * from "@mun-ui/react/legacy/react-types";
2
+ //# sourceMappingURL=react-types.d.ts.map
@@ -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,2 @@
1
+ export * from "@mun-ui/react/legacy/react-types";
2
+ //# sourceMappingURL=react-types.js.map
@@ -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"}
@@ -0,0 +1,2 @@
1
+ export * from "@mun-ui/react/legacy/state";
2
+ //# sourceMappingURL=state.d.ts.map
@@ -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,2 @@
1
+ export * from "@mun-ui/react/legacy/state";
2
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from "@mun-ui/react/legacy/types";
2
+ //# sourceMappingURL=types.d.ts.map
@@ -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,2 @@
1
+ export * from "@mun-ui/react/legacy/types";
2
+ //# sourceMappingURL=types.js.map
@@ -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,2 @@
1
+ export * from "@mun-ui/react/legacy/vite";
2
+ //# sourceMappingURL=vite.d.ts.map
@@ -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
@@ -0,0 +1,2 @@
1
+ export * from "@mun-ui/react/legacy/vite";
2
+ //# sourceMappingURL=vite.js.map
@@ -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))