@duet3d/monacotokens 3.7.0-alpha.2 → 3.7.0-alpha.3

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