@duet3d/monacotokens 3.6.1 → 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.
- package/dist/expressions/expressions.json +277 -0
- package/dist/expressions/index.d.ts +24 -0
- package/dist/expressions/index.js +2 -0
- package/dist/gcodes/gcodes.json +5821 -0
- package/dist/gcodes/index.d.ts +60 -0
- package/dist/gcodes/index.js +17 -0
- package/dist/gcodes/local-variables.d.ts +26 -0
- package/dist/gcodes/local-variables.js +62 -0
- package/dist/gcodes/search.d.ts +17 -0
- package/dist/gcodes/search.js +589 -0
- package/dist/monaco-gcode.js +17 -6
- package/dist/monaco-menu.d.ts +3 -0
- package/dist/monaco-menu.js +32 -0
- package/dist/monaco-stm32.d.ts +3 -0
- package/dist/monaco-stm32.js +81 -0
- package/dist/objectmodel/deprecations.d.ts +12 -0
- package/dist/objectmodel/deprecations.js +42 -0
- package/dist/objectmodel/enums.d.ts +4 -0
- package/dist/objectmodel/enums.js +17 -0
- package/dist/objectmodel/machine-context.d.ts +33 -0
- package/dist/objectmodel/machine-context.js +30 -0
- package/dist/objectmodel/paths.d.ts +3 -0
- package/dist/objectmodel/paths.js +5 -0
- package/dist/providers.d.ts +55 -0
- package/dist/providers.js +1581 -0
- package/dist/register.d.ts +13 -0
- package/dist/register.js +73 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One enumerated value of a parameter (e.g. "1" for G1 H meaning "Stop on endstop")
|
|
3
|
+
*/
|
|
4
|
+
export interface GcodeParameterValue {
|
|
5
|
+
/** Literal value as it appears in source (e.g. "0", "1", "-1") */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Human-readable meaning */
|
|
8
|
+
description: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Description of one parameter letter that a G/M/T-code accepts
|
|
12
|
+
*/
|
|
13
|
+
export interface GcodeParameter {
|
|
14
|
+
/** Single uppercase parameter letter (e.g. "X", "S") */
|
|
15
|
+
letter: string;
|
|
16
|
+
/** Human-readable description shown in tooltips and completion items */
|
|
17
|
+
description: string;
|
|
18
|
+
/** Optional enumeration of valid values, rendered as a table in tooltips */
|
|
19
|
+
values?: GcodeParameterValue[];
|
|
20
|
+
/** If set, this parameter is deprecated; the string is shown as the reason (e.g. "Use M18 S<timeout> instead") */
|
|
21
|
+
deprecated?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Description of a value that follows the code letter directly without a parameter letter (e.g. the tool
|
|
25
|
+
* number after T, the message after M117). Named after DSF's `UnprecedentedParameter` concept: the value
|
|
26
|
+
* has no parameter letter preceding it. Accepts literals, quoted strings, or `{...}` expressions.
|
|
27
|
+
*/
|
|
28
|
+
export interface GcodeUnprecedentedParameter {
|
|
29
|
+
/** Label shown in the signature, e.g. "<n>" */
|
|
30
|
+
label: string;
|
|
31
|
+
/** Description shown in the tooltip when this position is active */
|
|
32
|
+
description: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Description of one G/M/T-code (RRF dialect)
|
|
36
|
+
*/
|
|
37
|
+
export interface GcodeInfo {
|
|
38
|
+
/** Code identifier as it appears in source, e.g. "G1", "M104", "M203" */
|
|
39
|
+
code: string;
|
|
40
|
+
/** One-line summary shown in the completion dropdown and in hover headers */
|
|
41
|
+
summary: string;
|
|
42
|
+
/** Optional longer prose description shown above the parameter list in the signature-help doc panel */
|
|
43
|
+
description?: string;
|
|
44
|
+
/** Optional value that follows the code letter directly (e.g. the tool number for T, the message for M117) */
|
|
45
|
+
unprecedentedParameter?: GcodeUnprecedentedParameter;
|
|
46
|
+
/** Parameter letters this code understands */
|
|
47
|
+
parameters: GcodeParameter[];
|
|
48
|
+
/** If set, this code is deprecated; the string is shown as the reason */
|
|
49
|
+
deprecated?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Curated dataset of G/M/T-codes used to drive Monaco completion and hover providers.
|
|
53
|
+
* Sourced from gcode-data.json so it can be regenerated automatically from an upstream reference (docs.duet3d.com or DuetScreen) without touching TypeScript.
|
|
54
|
+
*/
|
|
55
|
+
export declare const gcodeData: GcodeInfo[];
|
|
56
|
+
/**
|
|
57
|
+
* Look up an entry by code. Accepts mixed-case ("g1", "M104", ...) by upper-casing the leading letter
|
|
58
|
+
* before matching against the canonical "G1" / "M104" / "T" form stored in gcodeData.
|
|
59
|
+
*/
|
|
60
|
+
export declare function findGcode(code: string): GcodeInfo | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import gcodeDataJson from "./gcodes.json";
|
|
2
|
+
/**
|
|
3
|
+
* Curated dataset of G/M/T-codes used to drive Monaco completion and hover providers.
|
|
4
|
+
* Sourced from gcode-data.json so it can be regenerated automatically from an upstream reference (docs.duet3d.com or DuetScreen) without touching TypeScript.
|
|
5
|
+
*/
|
|
6
|
+
export const gcodeData = gcodeDataJson;
|
|
7
|
+
/**
|
|
8
|
+
* Look up an entry by code. Accepts mixed-case ("g1", "M104", ...) by upper-casing the leading letter
|
|
9
|
+
* before matching against the canonical "G1" / "M104" / "T" form stored in gcodeData.
|
|
10
|
+
*/
|
|
11
|
+
export function findGcode(code) {
|
|
12
|
+
if (!code) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const canonical = code[0].toUpperCase() + code.substring(1);
|
|
16
|
+
return gcodeData.find(g => g.code === canonical);
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as monaco from "monaco-editor-core/esm/vs/editor/editor.api.js";
|
|
2
|
+
/**
|
|
3
|
+
* Names declared inside the currently-edited model via RRF's meta language (`var foo = ...`, `global bar = ...`).
|
|
4
|
+
* Populated by `attachLocalVariableScanner(editor)` and consulted by the expression completion provider when
|
|
5
|
+
* the user types `var.` / `global.`.
|
|
6
|
+
*/
|
|
7
|
+
export interface LocalVariables {
|
|
8
|
+
/** `var <name>` declarations seen on any line of the model. */
|
|
9
|
+
readonly vars: ReadonlySet<string>;
|
|
10
|
+
/** `global <name>` declarations seen on any line of the model. */
|
|
11
|
+
readonly globals: ReadonlySet<string>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Attach a background scanner that keeps track of `var` and `global` declarations in the given editor's model.
|
|
15
|
+
* Re-runs on every content change, debounced to avoid churn on large files. The result is consumed by the
|
|
16
|
+
* expression completion provider through `getLocalVariables(model)`.
|
|
17
|
+
*
|
|
18
|
+
* Scans up to `maxLines` lines (default 5000) - well beyond typical macro size but bounded for generated
|
|
19
|
+
* G-code exports that would otherwise pay a per-keystroke cost.
|
|
20
|
+
*/
|
|
21
|
+
export declare function attachLocalVariableScanner(editor: monaco.editor.IStandaloneCodeEditor, maxLines?: number): monaco.IDisposable;
|
|
22
|
+
/**
|
|
23
|
+
* Return the most recently scanned `var`/`global` declarations for the given model, or empty sets if no
|
|
24
|
+
* scanner is attached (or the first scan hasn't completed yet).
|
|
25
|
+
*/
|
|
26
|
+
export declare function getLocalVariables(model: monaco.editor.ITextModel): LocalVariables;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Debounce delay for rescanning a model's `var` / `global` declarations on content change (ms). */
|
|
2
|
+
const LOCAL_VARIABLE_RESCAN_DEBOUNCE_MS = 250;
|
|
3
|
+
const empty = { vars: new Set(), globals: new Set() };
|
|
4
|
+
// WeakMap so dispose is automatic when Monaco's model is garbage-collected
|
|
5
|
+
const scans = new WeakMap();
|
|
6
|
+
// Matches `var name`, `global name` optionally followed by `=` (trailing assignment not required for the capture)
|
|
7
|
+
const declRegex = /^\s*(var|global)\s+([A-Za-z_][\w]*)/;
|
|
8
|
+
function scan(model, maxLines) {
|
|
9
|
+
const vars = new Set();
|
|
10
|
+
const globals = new Set();
|
|
11
|
+
const lineCount = Math.min(model.getLineCount(), maxLines);
|
|
12
|
+
for (let line = 1; line <= lineCount; line++) {
|
|
13
|
+
const text = model.getLineContent(line);
|
|
14
|
+
const m = declRegex.exec(text);
|
|
15
|
+
if (m) {
|
|
16
|
+
(m[1] === "var" ? vars : globals).add(m[2]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return { vars, globals };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Attach a background scanner that keeps track of `var` and `global` declarations in the given editor's model.
|
|
23
|
+
* Re-runs on every content change, debounced to avoid churn on large files. The result is consumed by the
|
|
24
|
+
* expression completion provider through `getLocalVariables(model)`.
|
|
25
|
+
*
|
|
26
|
+
* Scans up to `maxLines` lines (default 5000) - well beyond typical macro size but bounded for generated
|
|
27
|
+
* G-code exports that would otherwise pay a per-keystroke cost.
|
|
28
|
+
*/
|
|
29
|
+
export function attachLocalVariableScanner(editor, maxLines = 5000) {
|
|
30
|
+
let timeout = null;
|
|
31
|
+
const rescan = () => {
|
|
32
|
+
const model = editor.getModel();
|
|
33
|
+
if (model) {
|
|
34
|
+
scans.set(model, scan(model, maxLines));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const schedule = () => {
|
|
38
|
+
if (timeout !== null) {
|
|
39
|
+
clearTimeout(timeout);
|
|
40
|
+
}
|
|
41
|
+
timeout = setTimeout(rescan, LOCAL_VARIABLE_RESCAN_DEBOUNCE_MS);
|
|
42
|
+
};
|
|
43
|
+
rescan();
|
|
44
|
+
const contentListener = editor.onDidChangeModelContent(schedule);
|
|
45
|
+
const modelListener = editor.onDidChangeModel(rescan);
|
|
46
|
+
return {
|
|
47
|
+
dispose: () => {
|
|
48
|
+
if (timeout !== null) {
|
|
49
|
+
clearTimeout(timeout);
|
|
50
|
+
}
|
|
51
|
+
contentListener.dispose();
|
|
52
|
+
modelListener.dispose();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Return the most recently scanned `var`/`global` declarations for the given model, or empty sets if no
|
|
58
|
+
* scanner is attached (or the first scan hasn't completed yet).
|
|
59
|
+
*/
|
|
60
|
+
export function getLocalVariables(model) {
|
|
61
|
+
return scans.get(model) ?? empty;
|
|
62
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as monaco from "monaco-editor-core/esm/vs/editor/editor.api.js";
|
|
2
|
+
/**
|
|
3
|
+
* Open the gcode search overlay anchored to the current cursor position, styled like the F2 rename widget.
|
|
4
|
+
*/
|
|
5
|
+
export declare function showGcodeSearch(monacoInstance: typeof monaco, editor: monaco.editor.IStandaloneCodeEditor): void;
|
|
6
|
+
/**
|
|
7
|
+
* Open a variant of the search overlay that lists object-model paths instead of G/M-codes. The model is
|
|
8
|
+
* flattened once on open (up to depth 3) and cached in the widget for the duration of the session; arrays
|
|
9
|
+
* are represented by their first element with an `[0]` placeholder. Local `var` / `global` declarations
|
|
10
|
+
* scanned from the current editor model are folded in as `var.<name>` / `global.<name>` entries.
|
|
11
|
+
*/
|
|
12
|
+
export declare function showObjectModelSearch(monacoInstance: typeof monaco, editor: monaco.editor.IStandaloneCodeEditor): void;
|
|
13
|
+
/**
|
|
14
|
+
* Register the F4 search action on a freshly created editor instance.
|
|
15
|
+
* Call this once per editor right after `monaco.editor.create(...)`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function addGcodeSearchAction(monacoInstance: typeof monaco, editor: monaco.editor.IStandaloneCodeEditor): monaco.IDisposable;
|