@duet3d/monacotokens 3.7.0-alpha.6 → 3.7.0-alpha.8
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/dist/expressions/index.js +2 -8
- package/dist/gcodes/index.js +4 -11
- package/dist/gcodes/local-variables.d.ts +1 -1
- package/dist/gcodes/local-variables.js +2 -6
- package/dist/gcodes/search.d.ts +1 -1
- package/dist/gcodes/search.js +15 -20
- package/dist/index.js +12 -28
- package/dist/monaco-gcode.d.ts +1 -1
- package/dist/monaco-gcode.js +3 -6
- package/dist/monaco-menu.d.ts +1 -1
- package/dist/monaco-menu.js +2 -5
- package/dist/monaco-stm32.d.ts +1 -1
- package/dist/monaco-stm32.js +2 -5
- package/dist/objectmodel/deprecations.js +6 -13
- package/dist/objectmodel/enums.js +5 -11
- package/dist/objectmodel/machine-context.js +3 -8
- package/dist/objectmodel/paths.js +1 -4
- package/dist/providers.d.ts +1 -1
- package/dist/providers.js +40 -53
- package/dist/register.d.ts +1 -1
- package/dist/register.js +22 -26
- package/package.json +10 -3
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.expressionData = void 0;
|
|
7
|
-
const expressions_json_1 = __importDefault(require("./expressions.json"));
|
|
8
|
-
exports.expressionData = expressions_json_1.default;
|
|
1
|
+
import data from "./expressions.json";
|
|
2
|
+
export const expressionData = data;
|
package/dist/gcodes/index.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.gcodeData = void 0;
|
|
7
|
-
exports.findGcode = findGcode;
|
|
8
|
-
const gcodes_json_1 = __importDefault(require("./gcodes.json"));
|
|
1
|
+
import gcodeDataJson from "./gcodes.json";
|
|
9
2
|
/**
|
|
10
3
|
* Curated dataset of G/M/T-codes used to drive Monaco completion and hover providers.
|
|
11
4
|
* Sourced from gcode-data.json so it can be regenerated automatically from an upstream reference (docs.duet3d.com or DuetScreen) without touching TypeScript.
|
|
12
5
|
*/
|
|
13
|
-
|
|
6
|
+
export const gcodeData = gcodeDataJson;
|
|
14
7
|
/**
|
|
15
8
|
* Look up an entry by code. Accepts mixed-case ("g1", "M104", ...) by upper-casing the leading letter
|
|
16
9
|
* before matching against the canonical "G1" / "M104" / "T" form stored in gcodeData.
|
|
17
10
|
*/
|
|
18
|
-
function findGcode(code) {
|
|
11
|
+
export function findGcode(code) {
|
|
19
12
|
if (!code) {
|
|
20
13
|
return undefined;
|
|
21
14
|
}
|
|
22
15
|
const canonical = code[0].toUpperCase() + code.substring(1);
|
|
23
|
-
return
|
|
16
|
+
return gcodeData.find(g => g.code === canonical);
|
|
24
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api";
|
|
1
|
+
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
|
|
2
2
|
/**
|
|
3
3
|
* Names declared inside the currently-edited model via RRF's meta language (`var foo = ...`, `global bar = ...`).
|
|
4
4
|
* Populated by `attachLocalVariableScanner(editor)` and consulted by the expression completion provider when
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.attachLocalVariableScanner = attachLocalVariableScanner;
|
|
4
|
-
exports.getLocalVariables = getLocalVariables;
|
|
5
1
|
/** Debounce delay for rescanning a model's `var` / `global` declarations on content change (ms). */
|
|
6
2
|
const LOCAL_VARIABLE_RESCAN_DEBOUNCE_MS = 250;
|
|
7
3
|
const empty = { vars: new Set(), globals: new Set() };
|
|
@@ -30,7 +26,7 @@ function scan(model, maxLines) {
|
|
|
30
26
|
* Scans up to `maxLines` lines (default 5000) - well beyond typical macro size but bounded for generated
|
|
31
27
|
* G-code exports that would otherwise pay a per-keystroke cost.
|
|
32
28
|
*/
|
|
33
|
-
function attachLocalVariableScanner(editor, maxLines = 5000) {
|
|
29
|
+
export function attachLocalVariableScanner(editor, maxLines = 5000) {
|
|
34
30
|
let timeout = null;
|
|
35
31
|
const rescan = () => {
|
|
36
32
|
const model = editor.getModel();
|
|
@@ -61,6 +57,6 @@ function attachLocalVariableScanner(editor, maxLines = 5000) {
|
|
|
61
57
|
* Return the most recently scanned `var`/`global` declarations for the given model, or empty sets if no
|
|
62
58
|
* scanner is attached (or the first scan hasn't completed yet).
|
|
63
59
|
*/
|
|
64
|
-
function getLocalVariables(model) {
|
|
60
|
+
export function getLocalVariables(model) {
|
|
65
61
|
return scans.get(model) ?? empty;
|
|
66
62
|
}
|
package/dist/gcodes/search.d.ts
CHANGED
package/dist/gcodes/search.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const _1 = require(".");
|
|
7
|
-
const machine_context_1 = require("../objectmodel/machine-context");
|
|
8
|
-
const local_variables_1 = require("./local-variables");
|
|
9
|
-
const deprecations_1 = require("../objectmodel/deprecations");
|
|
10
|
-
const providers_1 = require("../providers");
|
|
1
|
+
import { gcodeData } from ".";
|
|
2
|
+
import { getMachineContext } from "../objectmodel/machine-context";
|
|
3
|
+
import { getLocalVariables } from "./local-variables";
|
|
4
|
+
import { getPathDeprecation } from "../objectmodel/deprecations";
|
|
5
|
+
import { flattenObjectModel, isInsideExpression } from "../providers";
|
|
11
6
|
const widgetId = "duet.gcodeSearchWidget";
|
|
12
7
|
let activeWidget = null;
|
|
13
8
|
/**
|
|
14
9
|
* Open the gcode search overlay anchored to the current cursor position, styled like the F2 rename widget.
|
|
15
10
|
*/
|
|
16
|
-
function showGcodeSearch(monacoInstance, editor) {
|
|
11
|
+
export function showGcodeSearch(monacoInstance, editor) {
|
|
17
12
|
if (activeWidget) {
|
|
18
13
|
activeWidget.dispose();
|
|
19
14
|
}
|
|
@@ -144,8 +139,8 @@ function showGcodeSearch(monacoInstance, editor) {
|
|
|
144
139
|
function render(query) {
|
|
145
140
|
const q = query.trim().toLowerCase();
|
|
146
141
|
entries = q.length === 0
|
|
147
|
-
?
|
|
148
|
-
:
|
|
142
|
+
? gcodeData.slice()
|
|
143
|
+
: gcodeData.filter(g => g.code.toLowerCase().includes(q) || g.summary.toLowerCase().includes(q));
|
|
149
144
|
selectedIndex = 0;
|
|
150
145
|
list.innerHTML = "";
|
|
151
146
|
rowEls = [];
|
|
@@ -323,7 +318,7 @@ function showGcodeSearch(monacoInstance, editor) {
|
|
|
323
318
|
* are represented by their first element with an `[0]` placeholder. Local `var` / `global` declarations
|
|
324
319
|
* scanned from the current editor model are folded in as `var.<name>` / `global.<name>` entries.
|
|
325
320
|
*/
|
|
326
|
-
function showObjectModelSearch(monacoInstance, editor) {
|
|
321
|
+
export function showObjectModelSearch(monacoInstance, editor) {
|
|
327
322
|
if (activeWidget) {
|
|
328
323
|
activeWidget.dispose();
|
|
329
324
|
}
|
|
@@ -361,15 +356,15 @@ function showObjectModelSearch(monacoInstance, editor) {
|
|
|
361
356
|
const pathColor = isDarkTheme ? "#9CDCFE" : "#001080";
|
|
362
357
|
// Collect all paths once - model-derived paths plus the local scanner's var/global declarations
|
|
363
358
|
const allPaths = new Set();
|
|
364
|
-
const ctx =
|
|
359
|
+
const ctx = getMachineContext();
|
|
365
360
|
if (ctx?.model) {
|
|
366
|
-
for (const p of
|
|
361
|
+
for (const p of flattenObjectModel(ctx.model)) {
|
|
367
362
|
allPaths.add(p);
|
|
368
363
|
}
|
|
369
364
|
}
|
|
370
365
|
const model = editor.getModel();
|
|
371
366
|
if (model) {
|
|
372
|
-
const locals =
|
|
367
|
+
const locals = getLocalVariables(model);
|
|
373
368
|
for (const n of locals.vars) {
|
|
374
369
|
allPaths.add(`var.${n}`);
|
|
375
370
|
}
|
|
@@ -408,7 +403,7 @@ function showObjectModelSearch(monacoInstance, editor) {
|
|
|
408
403
|
const pathSpan = document.createElement("span");
|
|
409
404
|
pathSpan.textContent = path;
|
|
410
405
|
pathSpan.style.cssText = `color: ${pathColor}; flex: 1; overflow: hidden; text-overflow: ellipsis`;
|
|
411
|
-
const deprecation = ctxModel ?
|
|
406
|
+
const deprecation = ctxModel ? getPathDeprecation(path) : null;
|
|
412
407
|
if (deprecation !== null) {
|
|
413
408
|
pathSpan.style.textDecoration = "line-through";
|
|
414
409
|
pathSpan.style.opacity = "0.7";
|
|
@@ -568,7 +563,7 @@ function showObjectModelSearch(monacoInstance, editor) {
|
|
|
568
563
|
* Register the F4 search action on a freshly created editor instance.
|
|
569
564
|
* Call this once per editor right after `monaco.editor.create(...)`.
|
|
570
565
|
*/
|
|
571
|
-
function addGcodeSearchAction(monacoInstance, editor) {
|
|
566
|
+
export function addGcodeSearchAction(monacoInstance, editor) {
|
|
572
567
|
return editor.addAction({
|
|
573
568
|
id: "duet.searchGcode",
|
|
574
569
|
label: "Search G/M-code or object-model path",
|
|
@@ -583,7 +578,7 @@ function addGcodeSearchAction(monacoInstance, editor) {
|
|
|
583
578
|
if (model && position) {
|
|
584
579
|
const lineContent = model.getLineContent(position.lineNumber);
|
|
585
580
|
const beforeCursor = lineContent.substring(0, position.column - 1);
|
|
586
|
-
if (
|
|
581
|
+
if (isInsideExpression(beforeCursor)) {
|
|
587
582
|
showObjectModelSearch(monacoInstance, editor);
|
|
588
583
|
return;
|
|
589
584
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./monaco-gcode"), exports);
|
|
18
|
-
__exportStar(require("./monaco-stm32"), exports);
|
|
19
|
-
__exportStar(require("./monaco-menu"), exports);
|
|
20
|
-
__exportStar(require("./gcodes"), exports);
|
|
21
|
-
__exportStar(require("./expressions"), exports);
|
|
22
|
-
__exportStar(require("./objectmodel/machine-context"), exports);
|
|
23
|
-
__exportStar(require("./gcodes/local-variables"), exports);
|
|
24
|
-
__exportStar(require("./objectmodel/deprecations"), exports);
|
|
25
|
-
__exportStar(require("./objectmodel/enums"), exports);
|
|
26
|
-
__exportStar(require("./providers"), exports);
|
|
27
|
-
__exportStar(require("./gcodes/search"), exports);
|
|
28
|
-
__exportStar(require("./register"), exports);
|
|
1
|
+
export * from "./monaco-gcode";
|
|
2
|
+
export * from "./monaco-stm32";
|
|
3
|
+
export * from "./monaco-menu";
|
|
4
|
+
export * from "./gcodes";
|
|
5
|
+
export * from "./expressions";
|
|
6
|
+
export * from "./objectmodel/machine-context";
|
|
7
|
+
export * from "./gcodes/local-variables";
|
|
8
|
+
export * from "./objectmodel/deprecations";
|
|
9
|
+
export * from "./objectmodel/enums";
|
|
10
|
+
export * from "./providers";
|
|
11
|
+
export * from "./gcodes/search";
|
|
12
|
+
export * from "./register";
|
package/dist/monaco-gcode.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api";
|
|
1
|
+
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
|
|
2
2
|
export declare const gcodeFDMLanguage: monaco.languages.IMonarchLanguage;
|
|
3
3
|
export declare const gcodeCNCLanguage: monaco.languages.IMonarchLanguage;
|
|
4
4
|
export declare const gcodeLanguageConfiguration: monaco.languages.LanguageConfiguration;
|
package/dist/monaco-gcode.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gcodeLanguageConfiguration = exports.gcodeCNCLanguage = exports.gcodeFDMLanguage = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Generate a Monarch language for RRF-style G-code
|
|
6
3
|
* @param cncMode If true, comments in parentheses are allowed
|
|
@@ -186,9 +183,9 @@ function generateMonarchLanguage(fdmMode) {
|
|
|
186
183
|
}
|
|
187
184
|
};
|
|
188
185
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
186
|
+
export const gcodeFDMLanguage = generateMonarchLanguage(true);
|
|
187
|
+
export const gcodeCNCLanguage = generateMonarchLanguage(false);
|
|
188
|
+
export const gcodeLanguageConfiguration = {
|
|
192
189
|
comments: {
|
|
193
190
|
lineComment: ";"
|
|
194
191
|
},
|
package/dist/monaco-menu.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api";
|
|
1
|
+
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
|
|
2
2
|
export declare const menuLanguage: monaco.languages.IMonarchLanguage;
|
|
3
3
|
export declare const menuLanguageConfiguration: monaco.languages.LanguageConfiguration;
|
package/dist/monaco-menu.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.menuLanguageConfiguration = exports.menuLanguage = void 0;
|
|
4
|
-
exports.menuLanguage = {
|
|
1
|
+
export const menuLanguage = {
|
|
5
2
|
keywords: ["image", "text", "button", "value", "alter", "files"],
|
|
6
3
|
symbols: /[=><!~?:&|+\-*#\/\^%]+/,
|
|
7
4
|
operators: ['*', '/', '+', '-', "==", "!=", '=', "<=", '<', ">=", ">>>", ">>", '>', '!', "&&", '&', "||", '|', '^', '?', ':'],
|
|
@@ -28,7 +25,7 @@ exports.menuLanguage = {
|
|
|
28
25
|
]
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
|
-
|
|
28
|
+
export const menuLanguageConfiguration = {
|
|
32
29
|
comments: {
|
|
33
30
|
lineComment: ";"
|
|
34
31
|
}
|
package/dist/monaco-stm32.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api";
|
|
1
|
+
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
|
|
2
2
|
export declare const stm32Language: monaco.languages.IMonarchLanguage;
|
|
3
3
|
export declare const stm32LanguageConfiguration: monaco.languages.LanguageConfiguration;
|
package/dist/monaco-stm32.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stm32LanguageConfiguration = exports.stm32Language = void 0;
|
|
4
|
-
exports.stm32Language = {
|
|
1
|
+
export const stm32Language = {
|
|
5
2
|
keywordsPrimary: ["8266wifi", "accelerometer", "atx", "board", "heat", "lcd", "led", "leds", "pins", "power", "sbc", "sdCard", "serial", "SPI0", "SPI1", "SPI2", "SPI3", "SPI4", "SPI5", "SPI6", "SPI7", "SPI8", "stepper"],
|
|
6
3
|
keywordsSecondary: ["clockReg", "csPin", "espDataReadyPin", "espResetPin", "TfrReadyPin", "serialRxTxPins", "spiChannel", "initialPowerOn", "powerPin", "powerPinInverted", "spiTempSensorChannel", "spiTempSensorCSPins", "tempSensePins", "thermistorSeriesResistor", "encoderPinA", "encoderPinB", "encoderPinSw", "lcdBeepPin", "lcdCSPin", "lcdDCPin", "panelButtonPin", "neopixelPin", "activity", "activityOn", "diagnostic", "diagnosticOn", "SetHigh", "SetLow", "VInDetectPin", "voltage", "loadConfig", "external", "internal", "aux", "aux2", "pins", "directionPins", "enablePins", "numSmartDrivers", "num5160Drivers", "stepPins", "TmcDiagPins", "TmcUartPins"],
|
|
7
4
|
keywordsTertiary: ["cardDetectPin", "csPin", "spiChannel", "spiFrequencyHz", "spiFrequencyHz", "rxTxPins", "rxTxPins"],
|
|
@@ -66,7 +63,7 @@ exports.stm32Language = {
|
|
|
66
63
|
]
|
|
67
64
|
}
|
|
68
65
|
};
|
|
69
|
-
|
|
66
|
+
export const stm32LanguageConfiguration = {
|
|
70
67
|
comments: {
|
|
71
68
|
lineComment: ";"
|
|
72
69
|
},
|
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPathDeprecation = getPathDeprecation;
|
|
7
|
-
exports.getMemberDeprecation = getMemberDeprecation;
|
|
8
|
-
const deprecations_json_1 = __importDefault(require("@duet3d/objectmodel/dist/deprecations.json"));
|
|
9
|
-
const paths_1 = require("./paths");
|
|
1
|
+
import deprecationsJson from "@duet3d/objectmodel/deprecations.json";
|
|
2
|
+
import { normalisePath } from "./paths";
|
|
10
3
|
/**
|
|
11
4
|
* Map of full object-model paths (with `[]` standing for any array index) to the deprecation message extracted
|
|
12
5
|
* from the property's `@deprecated` JSDoc tag. Built by @duet3d/objectmodel's build script from its TS sources.
|
|
13
6
|
*/
|
|
14
|
-
const deprecations =
|
|
7
|
+
const deprecations = deprecationsJson;
|
|
15
8
|
/**
|
|
16
9
|
* Look up the deprecation message for a full object-model path (with literal numeric indices) or any of its
|
|
17
10
|
* prefixes. Returns the deprecation message when the path itself or a containing path is deprecated (the
|
|
18
11
|
* shallowest match wins so the user sees the root cause, e.g. `move.rotation.angle` reports `move.rotation`
|
|
19
12
|
* as deprecated). Returns null when neither the path nor any prefix is deprecated.
|
|
20
13
|
*/
|
|
21
|
-
function getPathDeprecation(path) {
|
|
14
|
+
export function getPathDeprecation(path) {
|
|
22
15
|
if (!path) {
|
|
23
16
|
return null;
|
|
24
17
|
}
|
|
25
|
-
const key =
|
|
18
|
+
const key = normalisePath(path);
|
|
26
19
|
// Walk prefixes from shallowest to deepest; first hit wins
|
|
27
20
|
let cursor = 0;
|
|
28
21
|
while (cursor < key.length) {
|
|
@@ -43,7 +36,7 @@ function getPathDeprecation(path) {
|
|
|
43
36
|
* Look up the deprecation message for `parentPath + "." + field`. `parentPath` is the dotted path of the parent
|
|
44
37
|
* value from the root (e.g. `move.extruders[0]`), or empty for a top-level field. Returns null if not deprecated.
|
|
45
38
|
*/
|
|
46
|
-
function getMemberDeprecation(parentPath, field) {
|
|
39
|
+
export function getMemberDeprecation(parentPath, field) {
|
|
47
40
|
const fullPath = parentPath ? `${parentPath}.${field}` : field;
|
|
48
41
|
return getPathDeprecation(fullPath);
|
|
49
42
|
}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEnumValuesForPath = getEnumValuesForPath;
|
|
7
|
-
const enums_json_1 = __importDefault(require("@duet3d/objectmodel/dist/enums.json"));
|
|
8
|
-
const paths_1 = require("./paths");
|
|
1
|
+
import enumValuesJson from "@duet3d/objectmodel/enums.json";
|
|
2
|
+
import { normalisePath } from "./paths";
|
|
9
3
|
/**
|
|
10
4
|
* Map of full object-model paths (with `[]` standing for any array index) to the list of valid enum / string-
|
|
11
5
|
* literal values the field can take. Generated by @duet3d/objectmodel's build script from its TS sources.
|
|
12
6
|
*/
|
|
13
|
-
const enumValues =
|
|
7
|
+
const enumValues = enumValuesJson;
|
|
14
8
|
/**
|
|
15
9
|
* Return the list of valid values for a given object-model path, or null if the path has no known enum values.
|
|
16
10
|
*/
|
|
17
|
-
function getEnumValuesForPath(path) {
|
|
11
|
+
export function getEnumValuesForPath(path) {
|
|
18
12
|
if (!path) {
|
|
19
13
|
return null;
|
|
20
14
|
}
|
|
21
|
-
const key =
|
|
15
|
+
const key = normalisePath(path);
|
|
22
16
|
return Object.prototype.hasOwnProperty.call(enumValues, key) ? enumValues[key] : null;
|
|
23
17
|
}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setMachineContext = setMachineContext;
|
|
4
|
-
exports.getMachineContext = getMachineContext;
|
|
5
|
-
exports.onMachineContextChange = onMachineContextChange;
|
|
6
1
|
let current = null;
|
|
7
2
|
const listeners = new Set();
|
|
8
3
|
/**
|
|
9
4
|
* Set (or clear) the runtime machine context. Pass `null` when the machine is disconnected.
|
|
10
5
|
*/
|
|
11
|
-
function setMachineContext(context) {
|
|
6
|
+
export function setMachineContext(context) {
|
|
12
7
|
current = context;
|
|
13
8
|
for (const listener of listeners) {
|
|
14
9
|
try {
|
|
@@ -23,13 +18,13 @@ function setMachineContext(context) {
|
|
|
23
18
|
/**
|
|
24
19
|
* Get the currently installed machine context, or null when no machine is connected.
|
|
25
20
|
*/
|
|
26
|
-
function getMachineContext() {
|
|
21
|
+
export function getMachineContext() {
|
|
27
22
|
return current;
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
30
25
|
* Subscribe to machine-context changes. Returns an unsubscribe function.
|
|
31
26
|
*/
|
|
32
|
-
function onMachineContextChange(listener) {
|
|
27
|
+
export function onMachineContextChange(listener) {
|
|
33
28
|
listeners.add(listener);
|
|
34
29
|
return () => listeners.delete(listener);
|
|
35
30
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalisePath = normalisePath;
|
|
4
1
|
/** Normalise a runtime object-model path (with literal numeric indices) to the lookup form used by
|
|
5
2
|
* the deprecations / enums maps, where `[]` stands in for any array index. */
|
|
6
|
-
function normalisePath(path) {
|
|
3
|
+
export function normalisePath(path) {
|
|
7
4
|
return path.replace(/\[\d+\]/g, "[]");
|
|
8
5
|
}
|
package/dist/providers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api";
|
|
1
|
+
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
|
|
2
2
|
export { getMachineContext, onMachineContextChange } from "./objectmodel/machine-context";
|
|
3
3
|
/**
|
|
4
4
|
* Flatten a machine object-model snapshot into a list of dotted paths (with `[0]` placeholders for arrays).
|
package/dist/providers.js
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.registerProvidersFor = registerProvidersFor;
|
|
8
|
-
exports.registerDuetProviders = registerDuetProviders;
|
|
9
|
-
exports.attachGcodeSignatureHelpWatcher = attachGcodeSignatureHelpWatcher;
|
|
10
|
-
exports.attachGcodeDeprecationDecorations = attachGcodeDeprecationDecorations;
|
|
11
|
-
exports.attachObjectModelDeprecationDecorations = attachObjectModelDeprecationDecorations;
|
|
12
|
-
const gcodes_1 = require("./gcodes");
|
|
13
|
-
const expressions_1 = require("./expressions");
|
|
14
|
-
const machine_context_1 = require("./objectmodel/machine-context");
|
|
15
|
-
const local_variables_1 = require("./gcodes/local-variables");
|
|
16
|
-
const deprecations_1 = require("./objectmodel/deprecations");
|
|
17
|
-
const enums_1 = require("./objectmodel/enums");
|
|
1
|
+
import { gcodeData, findGcode } from "./gcodes";
|
|
2
|
+
import { expressionData } from "./expressions";
|
|
3
|
+
import { getMachineContext } from "./objectmodel/machine-context";
|
|
4
|
+
import { getLocalVariables } from "./gcodes/local-variables";
|
|
5
|
+
import { getMemberDeprecation, getPathDeprecation } from "./objectmodel/deprecations";
|
|
6
|
+
import { getEnumValuesForPath } from "./objectmodel/enums";
|
|
18
7
|
// Re-export the runtime-context helpers so consumers (Vue DWC, React DuetWebUI, ...) can install a context
|
|
19
8
|
// without adding a separate import path
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, "getMachineContext", { enumerable: true, get: function () { return machine_context_2.getMachineContext; } });
|
|
22
|
-
Object.defineProperty(exports, "onMachineContextChange", { enumerable: true, get: function () { return machine_context_2.onMachineContextChange; } });
|
|
9
|
+
export { getMachineContext, onMachineContextChange } from "./objectmodel/machine-context";
|
|
23
10
|
/**
|
|
24
11
|
* Find the enclosing function call (if any) for the cursor position. Walks back from the end of `beforeCursor`
|
|
25
12
|
* keeping track of paren depth so that `max(a, min(b,|` correctly reports `min` with argIndex 1, not `max`.
|
|
@@ -89,8 +76,8 @@ function resolveExpressionPath(path, model) {
|
|
|
89
76
|
return null;
|
|
90
77
|
}
|
|
91
78
|
const root = String(tokens[0]);
|
|
92
|
-
const ctx =
|
|
93
|
-
const local =
|
|
79
|
+
const ctx = getMachineContext();
|
|
80
|
+
const local = getLocalVariables(model);
|
|
94
81
|
let current;
|
|
95
82
|
if (root === "var") {
|
|
96
83
|
// `var.<name>` resolves to a placeholder object carrying the locally-declared names; the value isn't
|
|
@@ -154,7 +141,7 @@ function listMemberKeys(value) {
|
|
|
154
141
|
* Walks the entire reachable subtree; arrays contribute a single representative `[0]` entry so the list
|
|
155
142
|
* doesn't explode on machines with many tools/axes. Cycles are guarded via a visited WeakSet.
|
|
156
143
|
*/
|
|
157
|
-
function flattenObjectModel(root) {
|
|
144
|
+
export function flattenObjectModel(root) {
|
|
158
145
|
if (!root || typeof root !== "object") {
|
|
159
146
|
return [];
|
|
160
147
|
}
|
|
@@ -222,7 +209,7 @@ function isInsideLineComment(beforeCursor) {
|
|
|
222
209
|
* - after an `=` on a `set|var|global` line (whole line is expression territory), OR
|
|
223
210
|
* - after `if|elif|while` (condition is an expression).
|
|
224
211
|
*/
|
|
225
|
-
function isInsideExpression(beforeCursor) {
|
|
212
|
+
export function isInsideExpression(beforeCursor) {
|
|
226
213
|
// Count unmatched `{` up to cursor - quick check first
|
|
227
214
|
let depth = 0;
|
|
228
215
|
let inString = false;
|
|
@@ -286,7 +273,7 @@ const metaKeywords = [
|
|
|
286
273
|
* A bare `T` is only treated as its own code when it's the first code on the line; otherwise it's a parameter
|
|
287
274
|
* letter of the preceding command (e.g. `M104 T1` - the T belongs to M104, not a separate `T` code).
|
|
288
275
|
*/
|
|
289
|
-
function findCodeAtCursor(line, column) {
|
|
276
|
+
export function findCodeAtCursor(line, column) {
|
|
290
277
|
// Local regex so there's no shared lastIndex state to reset between calls. Matches G/M codes with their
|
|
291
278
|
// numeric suffix (e.g. G1, G38.2, M104) or a bare T. Anything after T (tool number, sign, expression) is
|
|
292
279
|
// treated as T's unprecedentedParameter
|
|
@@ -581,7 +568,7 @@ const deprecatedInlineHtml = "<span style=\"color:#cca700;\"><i>(deprecated)</i>
|
|
|
581
568
|
* Build a Markdown documentation block for a code (used by both completion and hover).
|
|
582
569
|
*/
|
|
583
570
|
function buildCodeDoc(code) {
|
|
584
|
-
const info =
|
|
571
|
+
const info = findGcode(code);
|
|
585
572
|
if (!info) {
|
|
586
573
|
return "";
|
|
587
574
|
}
|
|
@@ -680,7 +667,7 @@ function installSuggestWidgetWidth() {
|
|
|
680
667
|
/**
|
|
681
668
|
* Register Duet-specific completion and hover providers for a language id.
|
|
682
669
|
*/
|
|
683
|
-
function registerProvidersFor(monacoInstance, languageId) {
|
|
670
|
+
export function registerProvidersFor(monacoInstance, languageId) {
|
|
684
671
|
installSuggestWidgetWidth();
|
|
685
672
|
const disposables = [];
|
|
686
673
|
// Completion: codes when typing G/M/T at line start, parameter letters after a known code
|
|
@@ -701,7 +688,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
701
688
|
// general vocabulary. Runs ahead of the member-access branch so typed paths don't fall through
|
|
702
689
|
const eqMatch = /([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\[\d+\])*)\s*(?:==|!=)\s*"?([A-Za-z_][\w]*)?$/.exec(beforeCursor);
|
|
703
690
|
if (eqMatch) {
|
|
704
|
-
const values =
|
|
691
|
+
const values = getEnumValuesForPath(eqMatch[1]);
|
|
705
692
|
if (values) {
|
|
706
693
|
const wordInfo = model.getWordUntilPosition(position);
|
|
707
694
|
const range = {
|
|
@@ -744,7 +731,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
744
731
|
const value = resolveExpressionPath(chainMatch[1], model);
|
|
745
732
|
const suggestions = [];
|
|
746
733
|
for (const name of listMemberKeys(value)) {
|
|
747
|
-
const deprecation =
|
|
734
|
+
const deprecation = getMemberDeprecation(chainMatch[1], name);
|
|
748
735
|
// Using the structured label form puts the `deprecated - <reason>` string in the description
|
|
749
736
|
// column (right-aligned dim text) so it's visible on every row, not only the highlighted one
|
|
750
737
|
const deprecationLabel = deprecation === null
|
|
@@ -783,7 +770,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
783
770
|
endColumn: wordInfo.endColumn
|
|
784
771
|
};
|
|
785
772
|
const suggestions = [];
|
|
786
|
-
for (const f of
|
|
773
|
+
for (const f of expressionData.functions) {
|
|
787
774
|
suggestions.push({
|
|
788
775
|
label: { label: f.name, description: f.syntax },
|
|
789
776
|
kind: monacoInstance.languages.CompletionItemKind.Function,
|
|
@@ -793,7 +780,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
793
780
|
range
|
|
794
781
|
});
|
|
795
782
|
}
|
|
796
|
-
for (const c of
|
|
783
|
+
for (const c of expressionData.constants) {
|
|
797
784
|
suggestions.push({
|
|
798
785
|
label: { label: c.name, description: c.description },
|
|
799
786
|
kind: monacoInstance.languages.CompletionItemKind.Constant,
|
|
@@ -803,7 +790,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
803
790
|
range
|
|
804
791
|
});
|
|
805
792
|
}
|
|
806
|
-
for (const s of
|
|
793
|
+
for (const s of expressionData.scopes) {
|
|
807
794
|
suggestions.push({
|
|
808
795
|
label: { label: s.name, description: s.description },
|
|
809
796
|
kind: monacoInstance.languages.CompletionItemKind.Module,
|
|
@@ -813,7 +800,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
813
800
|
range
|
|
814
801
|
});
|
|
815
802
|
}
|
|
816
|
-
for (const ns of
|
|
803
|
+
for (const ns of expressionData.objectModel) {
|
|
817
804
|
// No description here - sub-keys don't carry any either (see comment in listMemberKeys),
|
|
818
805
|
// so keep the top level consistent rather than teasing docs the deeper levels can't match
|
|
819
806
|
suggestions.push({
|
|
@@ -835,7 +822,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
835
822
|
endColumn: wordInfo.endColumn
|
|
836
823
|
};
|
|
837
824
|
const triggerHints = { id: "editor.action.triggerParameterHints", title: "Trigger Parameter Hints" };
|
|
838
|
-
const suggestions =
|
|
825
|
+
const suggestions = gcodeData.map(info => ({
|
|
839
826
|
label: { label: info.code, description: info.summary },
|
|
840
827
|
kind: monacoInstance.languages.CompletionItemKind.Function,
|
|
841
828
|
detail: info.summary,
|
|
@@ -861,7 +848,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
861
848
|
// Inside a code call: suggest parameter letters (excluding ones already present on the line)
|
|
862
849
|
const code = findCodeAtCursor(lineContent, position.column - 1);
|
|
863
850
|
if (code) {
|
|
864
|
-
const info =
|
|
851
|
+
const info = findGcode(code.code);
|
|
865
852
|
if (info && info.parameters.length > 0) {
|
|
866
853
|
const wordInfo = model.getWordUntilPosition(position);
|
|
867
854
|
const range = {
|
|
@@ -932,7 +919,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
932
919
|
}
|
|
933
920
|
// Function call inside an expression (e.g. `sin(|` or `atan2(y,|`) takes precedence
|
|
934
921
|
if (fnCall) {
|
|
935
|
-
const fn =
|
|
922
|
+
const fn = expressionData.functions.find(f => f.name === fnCall.name);
|
|
936
923
|
if (fn) {
|
|
937
924
|
const parsed = parseFunctionSyntax(fn.syntax);
|
|
938
925
|
const params = parsed.params.map(p => ({
|
|
@@ -976,7 +963,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
976
963
|
if (!code) {
|
|
977
964
|
return null;
|
|
978
965
|
}
|
|
979
|
-
const info =
|
|
966
|
+
const info = findGcode(code.code);
|
|
980
967
|
if (!info || (info.parameters.length === 0 && !info.unprecedentedParameter)) {
|
|
981
968
|
return null;
|
|
982
969
|
}
|
|
@@ -1106,7 +1093,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
1106
1093
|
// sits inside a known parameter's value range, show that parameter's doc
|
|
1107
1094
|
const enclosingCode = findCodeAtCursor(lineContent, position.column);
|
|
1108
1095
|
if (enclosingCode) {
|
|
1109
|
-
const info =
|
|
1096
|
+
const info = findGcode(enclosingCode.code);
|
|
1110
1097
|
const paramAtCursor = info ? findParameterAtCursor(lineContent, enclosingCode.startColumn + enclosingCode.code.length - 1, position.column) : null;
|
|
1111
1098
|
if (info && paramAtCursor) {
|
|
1112
1099
|
const param = info.parameters.find(p => p.letter.toUpperCase() === paramAtCursor.letter.toUpperCase());
|
|
@@ -1154,7 +1141,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
1154
1141
|
// recognised parameter letter AND the cursor sits in the direct-value segment, fall through to
|
|
1155
1142
|
// the unprecedentedParameter hover instead of returning nothing
|
|
1156
1143
|
if (enclosing && !wordIsCode) {
|
|
1157
|
-
const info =
|
|
1144
|
+
const info = findGcode(enclosing.code);
|
|
1158
1145
|
// First try: cursor sits anywhere inside a parameter's expanded value range (e.g. on the
|
|
1159
1146
|
// `100` of `S100`, inside `{global.x}` of `E{global.x}`, inside `"foo.g"` of `P"foo.g"`, or
|
|
1160
1147
|
// inside `1:2:3` of `E1:2:3`). This covers hovers that don't land on the letter itself
|
|
@@ -1190,7 +1177,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
1190
1177
|
// so the tooltip stays visible while the cursor moves anywhere inside the expression - useful for
|
|
1191
1178
|
// multi-token values like `{global.tool}` or `"Hello World"`
|
|
1192
1179
|
if (enclosing && !wordIsCode) {
|
|
1193
|
-
const info =
|
|
1180
|
+
const info = findGcode(enclosing.code);
|
|
1194
1181
|
if (info?.unprecedentedParameter) {
|
|
1195
1182
|
const segment = findUnprecedentedParameterRange(lineContent, enclosing.startColumn + enclosing.code.length - 1);
|
|
1196
1183
|
if (segment && word.startColumn >= segment.startCol && word.endColumn <= segment.endCol) {
|
|
@@ -1237,7 +1224,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
1237
1224
|
const canonical = enclosing.code;
|
|
1238
1225
|
const doc = buildCodeDoc(canonical);
|
|
1239
1226
|
if (doc) {
|
|
1240
|
-
const info =
|
|
1227
|
+
const info = findGcode(canonical);
|
|
1241
1228
|
let endCol = word.endColumn;
|
|
1242
1229
|
if (info?.unprecedentedParameter) {
|
|
1243
1230
|
const segment = findUnprecedentedParameterRange(lineContent, enclosing.startColumn + enclosing.code.length - 1);
|
|
@@ -1255,14 +1242,14 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
1255
1242
|
// when the cursor is inside an expression context. Checked before the OM chain so `sin` alone (no
|
|
1256
1243
|
// `.` / `[n]`) is covered; `fans[0].max` stays on the OM chain path since that match wins anyway
|
|
1257
1244
|
if (insideExpression) {
|
|
1258
|
-
const fn =
|
|
1245
|
+
const fn = expressionData.functions.find(f => f.name === word.word);
|
|
1259
1246
|
if (fn) {
|
|
1260
1247
|
return {
|
|
1261
1248
|
range: new monacoInstance.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn),
|
|
1262
1249
|
contents: [md(`**${fn.syntax}**\n\n${fn.description}`)]
|
|
1263
1250
|
};
|
|
1264
1251
|
}
|
|
1265
|
-
const constant =
|
|
1252
|
+
const constant = expressionData.constants.find(c => c.name === word.word);
|
|
1266
1253
|
if (constant) {
|
|
1267
1254
|
return {
|
|
1268
1255
|
range: new monacoInstance.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn),
|
|
@@ -1275,11 +1262,11 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
1275
1262
|
// callback we surface the @deprecated note if one applies to the hovered prefix
|
|
1276
1263
|
const omHover = findObjectModelHover(lineContent, position.column);
|
|
1277
1264
|
if (omHover) {
|
|
1278
|
-
const ctx =
|
|
1265
|
+
const ctx = getMachineContext();
|
|
1279
1266
|
const description = ctx?.getObjectModelDescription
|
|
1280
1267
|
? await Promise.resolve(ctx.getObjectModelDescription(omHover.normalized))
|
|
1281
1268
|
: null;
|
|
1282
|
-
const deprecation =
|
|
1269
|
+
const deprecation = getPathDeprecation(omHover.prefix);
|
|
1283
1270
|
if (description || deprecation !== null) {
|
|
1284
1271
|
let body = `\`${omHover.normalized}\``;
|
|
1285
1272
|
if (description) {
|
|
@@ -1302,7 +1289,7 @@ function registerProvidersFor(monacoInstance, languageId) {
|
|
|
1302
1289
|
/**
|
|
1303
1290
|
* Register Duet completion and hover providers for both gcode-fdm and gcode-cnc languages.
|
|
1304
1291
|
*/
|
|
1305
|
-
function registerDuetProviders(monacoInstance) {
|
|
1292
|
+
export function registerDuetProviders(monacoInstance) {
|
|
1306
1293
|
return [
|
|
1307
1294
|
...registerProvidersFor(monacoInstance, "gcode-fdm"),
|
|
1308
1295
|
...registerProvidersFor(monacoInstance, "gcode-cnc")
|
|
@@ -1314,7 +1301,7 @@ function registerDuetProviders(monacoInstance) {
|
|
|
1314
1301
|
* Monaco only re-invokes the signature-help provider on content changes, so this bridges arrow-key / click movement.
|
|
1315
1302
|
* Call this once per editor right after `monaco.editor.create(...)`.
|
|
1316
1303
|
*/
|
|
1317
|
-
function attachGcodeSignatureHelpWatcher(editor) {
|
|
1304
|
+
export function attachGcodeSignatureHelpWatcher(editor) {
|
|
1318
1305
|
// Close parameter hints when the suggest widget transitions from hidden to visible, so the two popups don't
|
|
1319
1306
|
// overlap while the user is typing. We only react on the visible-edge and skip the action if parameter hints
|
|
1320
1307
|
// is currently open because that means Monaco just invoked it (e.g. after Enter on a completion item) and we
|
|
@@ -1346,7 +1333,7 @@ function attachGcodeSignatureHelpWatcher(editor) {
|
|
|
1346
1333
|
shouldDismiss = true;
|
|
1347
1334
|
}
|
|
1348
1335
|
else if (code) {
|
|
1349
|
-
const info =
|
|
1336
|
+
const info = findGcode(code.code);
|
|
1350
1337
|
if (!info || (info.parameters.length === 0 && !info.unprecedentedParameter)) {
|
|
1351
1338
|
shouldDismiss = true;
|
|
1352
1339
|
}
|
|
@@ -1414,9 +1401,9 @@ function attachGcodeSignatureHelpWatcher(editor) {
|
|
|
1414
1401
|
* `M84 S`). Re-runs on every content change; hover tooltip carries the deprecation reason.
|
|
1415
1402
|
* Call once per editor; the returned IDisposable removes the listener and clears the decorations.
|
|
1416
1403
|
*/
|
|
1417
|
-
function attachGcodeDeprecationDecorations(editor) {
|
|
1404
|
+
export function attachGcodeDeprecationDecorations(editor) {
|
|
1418
1405
|
// Codes with `deprecated` flag: the code identifier itself gets struck through
|
|
1419
|
-
const deprecatedCodes =
|
|
1406
|
+
const deprecatedCodes = gcodeData.filter(g => !!g.deprecated);
|
|
1420
1407
|
const deprecatedCodeAlternation = deprecatedCodes.length > 0
|
|
1421
1408
|
? deprecatedCodes.map(g => g.code.replace(/[.\\$^*+?()[\]{}|]/g, "\\$&")).join("|")
|
|
1422
1409
|
: null;
|
|
@@ -1471,7 +1458,7 @@ function attachGcodeDeprecationDecorations(editor) {
|
|
|
1471
1458
|
for (let i = 0; i < codeOccurrences.length; i++) {
|
|
1472
1459
|
const occ = codeOccurrences[i];
|
|
1473
1460
|
const canonical = occ.code[0].toUpperCase() + occ.code.substring(1);
|
|
1474
|
-
const info =
|
|
1461
|
+
const info = findGcode(canonical);
|
|
1475
1462
|
if (!info) {
|
|
1476
1463
|
continue;
|
|
1477
1464
|
}
|
|
@@ -1566,7 +1553,7 @@ function installDeprecatedCodeStyle() {
|
|
|
1566
1553
|
* the normalised path is present in the deprecations map shipped by @duet3d/objectmodel. Re-runs on every
|
|
1567
1554
|
* content change; hover tooltip carries the deprecation reason.
|
|
1568
1555
|
*/
|
|
1569
|
-
function attachObjectModelDeprecationDecorations(editor) {
|
|
1556
|
+
export function attachObjectModelDeprecationDecorations(editor) {
|
|
1570
1557
|
// Identifier chain with at least one `.` or `[n]` step. Non-greedy on boundaries so adjacent text
|
|
1571
1558
|
// (e.g. trailing brackets / punctuation) isn't consumed
|
|
1572
1559
|
const chainRegex = /[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\[\d+\])+/g;
|
|
@@ -1577,7 +1564,7 @@ function attachObjectModelDeprecationDecorations(editor) {
|
|
|
1577
1564
|
chainRegex.lastIndex = 0;
|
|
1578
1565
|
let m;
|
|
1579
1566
|
while ((m = chainRegex.exec(text)) !== null) {
|
|
1580
|
-
const deprecation =
|
|
1567
|
+
const deprecation = getPathDeprecation(m[0]);
|
|
1581
1568
|
if (deprecation === null) {
|
|
1582
1569
|
continue;
|
|
1583
1570
|
}
|
package/dist/register.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api";
|
|
1
|
+
import type * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
|
|
2
2
|
/**
|
|
3
3
|
* Register all Duet-specific languages (gcode-fdm, gcode-cnc, stm32, menu) with a Monaco instance,
|
|
4
4
|
* attaching their tokenizers, language configurations, and (for gcode) completion + hover providers.
|
package/dist/register.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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");
|
|
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";
|
|
11
7
|
/**
|
|
12
8
|
* Override Monaco's built-in `vs` and `vs-dark` themes to map the tokens our tokenizer emits to VSCode's
|
|
13
9
|
* TextMate-scope colours (Monaco standalone's defaults otherwise lack a dedicated "function" colour). Called
|
|
@@ -37,21 +33,21 @@ function applyDuetThemeOverrides(monacoInstance) {
|
|
|
37
33
|
* Register all Duet-specific languages (gcode-fdm, gcode-cnc, stm32, menu) with a Monaco instance,
|
|
38
34
|
* attaching their tokenizers, language configurations, and (for gcode) completion + hover providers.
|
|
39
35
|
*/
|
|
40
|
-
function registerDuetLanguages(monacoInstance) {
|
|
36
|
+
export function registerDuetLanguages(monacoInstance) {
|
|
41
37
|
monacoInstance.languages.register({ id: "gcode-fdm" });
|
|
42
|
-
monacoInstance.languages.setMonarchTokensProvider("gcode-fdm",
|
|
43
|
-
monacoInstance.languages.setLanguageConfiguration("gcode-fdm",
|
|
38
|
+
monacoInstance.languages.setMonarchTokensProvider("gcode-fdm", gcodeFDMLanguage);
|
|
39
|
+
monacoInstance.languages.setLanguageConfiguration("gcode-fdm", gcodeLanguageConfiguration);
|
|
44
40
|
monacoInstance.languages.register({ id: "gcode-cnc" });
|
|
45
|
-
monacoInstance.languages.setMonarchTokensProvider("gcode-cnc",
|
|
46
|
-
monacoInstance.languages.setLanguageConfiguration("gcode-cnc",
|
|
41
|
+
monacoInstance.languages.setMonarchTokensProvider("gcode-cnc", gcodeCNCLanguage);
|
|
42
|
+
monacoInstance.languages.setLanguageConfiguration("gcode-cnc", gcodeLanguageConfiguration);
|
|
47
43
|
monacoInstance.languages.register({ id: "stm32" });
|
|
48
|
-
monacoInstance.languages.setMonarchTokensProvider("stm32",
|
|
49
|
-
monacoInstance.languages.setLanguageConfiguration("stm32",
|
|
44
|
+
monacoInstance.languages.setMonarchTokensProvider("stm32", stm32Language);
|
|
45
|
+
monacoInstance.languages.setLanguageConfiguration("stm32", stm32LanguageConfiguration);
|
|
50
46
|
monacoInstance.languages.register({ id: "menu" });
|
|
51
|
-
monacoInstance.languages.setMonarchTokensProvider("menu",
|
|
52
|
-
monacoInstance.languages.setLanguageConfiguration("menu",
|
|
47
|
+
monacoInstance.languages.setMonarchTokensProvider("menu", menuLanguage);
|
|
48
|
+
monacoInstance.languages.setLanguageConfiguration("menu", menuLanguageConfiguration);
|
|
53
49
|
applyDuetThemeOverrides(monacoInstance);
|
|
54
|
-
return
|
|
50
|
+
return registerDuetProviders(monacoInstance);
|
|
55
51
|
}
|
|
56
52
|
/**
|
|
57
53
|
* Wire up every per-editor Gcode feature in one call: the search action, signature-help watcher, deprecation
|
|
@@ -59,13 +55,13 @@ function registerDuetLanguages(monacoInstance) {
|
|
|
59
55
|
* replace the separate attach/add calls at the call site. Returns a single IDisposable that releases all of
|
|
60
56
|
* them when disposed.
|
|
61
57
|
*/
|
|
62
|
-
function attachGcodeFeatures(monacoInstance, editor) {
|
|
58
|
+
export function attachGcodeFeatures(monacoInstance, editor) {
|
|
63
59
|
const disposables = [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
addGcodeSearchAction(monacoInstance, editor),
|
|
61
|
+
attachGcodeSignatureHelpWatcher(editor),
|
|
62
|
+
attachGcodeDeprecationDecorations(editor),
|
|
63
|
+
attachObjectModelDeprecationDecorations(editor),
|
|
64
|
+
attachLocalVariableScanner(editor)
|
|
69
65
|
];
|
|
70
66
|
return {
|
|
71
67
|
dispose() {
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duet3d/monacotokens",
|
|
3
|
-
"version": "3.7.0-alpha.
|
|
3
|
+
"version": "3.7.0-alpha.8",
|
|
4
4
|
"description": "TypeScript library that holds syntax highlighting files for the Monaco editor",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"scripts": {
|
|
8
15
|
"build": "tsc",
|
|
9
16
|
"prepublishOnly": "npm run build"
|
|
@@ -19,13 +26,13 @@
|
|
|
19
26
|
},
|
|
20
27
|
"homepage": "https://github.com/Duet3D/MonacoTokens#readme",
|
|
21
28
|
"devDependencies": {
|
|
22
|
-
"typescript": "^
|
|
29
|
+
"typescript": "^6.0.3"
|
|
23
30
|
},
|
|
24
31
|
"files": [
|
|
25
32
|
"/dist"
|
|
26
33
|
],
|
|
27
34
|
"dependencies": {
|
|
28
|
-
"@duet3d/objectmodel": "~3.7.0-alpha.
|
|
35
|
+
"@duet3d/objectmodel": "~3.7.0-alpha.8",
|
|
29
36
|
"monaco-editor": "^0.55.1"
|
|
30
37
|
}
|
|
31
38
|
}
|