@duet3d/monacotokens 3.6.0 → 3.6.2

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.
@@ -0,0 +1,13 @@
1
+ import type * as monaco from "monaco-editor-core/esm/vs/editor/editor.api.js";
2
+ /**
3
+ * Register all Duet-specific languages (gcode-fdm, gcode-cnc, stm32, menu) with a Monaco instance,
4
+ * attaching their tokenizers, language configurations, and (for gcode) completion + hover providers.
5
+ */
6
+ export declare function registerDuetLanguages(monacoInstance: typeof monaco): monaco.IDisposable[];
7
+ /**
8
+ * Wire up every per-editor Gcode feature in one call: the search action, signature-help watcher, deprecation
9
+ * decorations for codes / parameters and object-model paths, and the local-variable scanner. Intended to
10
+ * replace the separate attach/add calls at the call site. Returns a single IDisposable that releases all of
11
+ * them when disposed.
12
+ */
13
+ export declare function attachGcodeFeatures(monacoInstance: typeof monaco, editor: monaco.editor.IStandaloneCodeEditor): monaco.IDisposable;
@@ -0,0 +1,73 @@
1
+ import { gcodeFDMLanguage, gcodeCNCLanguage, gcodeLanguageConfiguration } from "./monaco-gcode";
2
+ import { stm32Language, stm32LanguageConfiguration } from "./monaco-stm32";
3
+ import { menuLanguage, menuLanguageConfiguration } from "./monaco-menu";
4
+ import { registerDuetProviders, attachGcodeSignatureHelpWatcher, attachGcodeDeprecationDecorations, attachObjectModelDeprecationDecorations } from "./providers";
5
+ import { attachLocalVariableScanner } from "./gcodes/local-variables";
6
+ import { addGcodeSearchAction } from "./gcodes/search";
7
+ /**
8
+ * Override Monaco's built-in `vs` and `vs-dark` themes to map the tokens our tokenizer emits to VSCode's
9
+ * TextMate-scope colours (Monaco standalone's defaults otherwise lack a dedicated "function" colour). Called
10
+ * once by `registerDuetLanguages`; uses `inherit: true` so the base theme's other colours stay in place.
11
+ */
12
+ function applyDuetThemeOverrides(monacoInstance) {
13
+ monacoInstance.editor.defineTheme("vs-dark", {
14
+ base: "vs-dark",
15
+ inherit: true,
16
+ rules: [
17
+ // VSCode Dark+ entity.name.function / support.function colour
18
+ { token: "support.function", foreground: "DCDCAA" }
19
+ ],
20
+ colors: {}
21
+ });
22
+ monacoInstance.editor.defineTheme("vs", {
23
+ base: "vs",
24
+ inherit: true,
25
+ rules: [
26
+ // VSCode Light+ entity.name.function / support.function colour
27
+ { token: "support.function", foreground: "795E26" }
28
+ ],
29
+ colors: {}
30
+ });
31
+ }
32
+ /**
33
+ * Register all Duet-specific languages (gcode-fdm, gcode-cnc, stm32, menu) with a Monaco instance,
34
+ * attaching their tokenizers, language configurations, and (for gcode) completion + hover providers.
35
+ */
36
+ export function registerDuetLanguages(monacoInstance) {
37
+ monacoInstance.languages.register({ id: "gcode-fdm" });
38
+ monacoInstance.languages.setMonarchTokensProvider("gcode-fdm", gcodeFDMLanguage);
39
+ monacoInstance.languages.setLanguageConfiguration("gcode-fdm", gcodeLanguageConfiguration);
40
+ monacoInstance.languages.register({ id: "gcode-cnc" });
41
+ monacoInstance.languages.setMonarchTokensProvider("gcode-cnc", gcodeCNCLanguage);
42
+ monacoInstance.languages.setLanguageConfiguration("gcode-cnc", gcodeLanguageConfiguration);
43
+ monacoInstance.languages.register({ id: "stm32" });
44
+ monacoInstance.languages.setMonarchTokensProvider("stm32", stm32Language);
45
+ monacoInstance.languages.setLanguageConfiguration("stm32", stm32LanguageConfiguration);
46
+ monacoInstance.languages.register({ id: "menu" });
47
+ monacoInstance.languages.setMonarchTokensProvider("menu", menuLanguage);
48
+ monacoInstance.languages.setLanguageConfiguration("menu", menuLanguageConfiguration);
49
+ applyDuetThemeOverrides(monacoInstance);
50
+ return registerDuetProviders(monacoInstance);
51
+ }
52
+ /**
53
+ * Wire up every per-editor Gcode feature in one call: the search action, signature-help watcher, deprecation
54
+ * decorations for codes / parameters and object-model paths, and the local-variable scanner. Intended to
55
+ * replace the separate attach/add calls at the call site. Returns a single IDisposable that releases all of
56
+ * them when disposed.
57
+ */
58
+ export function attachGcodeFeatures(monacoInstance, editor) {
59
+ const disposables = [
60
+ addGcodeSearchAction(monacoInstance, editor),
61
+ attachGcodeSignatureHelpWatcher(editor),
62
+ attachGcodeDeprecationDecorations(editor),
63
+ attachObjectModelDeprecationDecorations(editor),
64
+ attachLocalVariableScanner(editor)
65
+ ];
66
+ return {
67
+ dispose() {
68
+ for (const d of disposables) {
69
+ d.dispose();
70
+ }
71
+ }
72
+ };
73
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duet3d/monacotokens",
3
- "version": "3.6.0",
3
+ "version": "3.6.2",
4
4
  "description": "TypeScript library that holds syntax highlighting files for the Monaco editor",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",