@duet3d/monacotokens 3.7.0-alpha.9 → 3.7.0-beta.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/README.md +55 -5
- package/dist/expressions/expressions.json +7 -3
- package/dist/gcodes/gcodes.json +1923 -1391
- package/dist/gcodes/index.d.ts +24 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/monaco-gcode.js +20 -5
- package/dist/objectmodel/axes.d.ts +12 -0
- package/dist/objectmodel/axes.js +18 -0
- package/dist/providers.js +179 -33
- package/package.json +14 -7
package/README.md
CHANGED
|
@@ -1,15 +1,65 @@
|
|
|
1
1
|
# MonacoTokens
|
|
2
2
|
|
|
3
|
-
TypeScript library
|
|
3
|
+
TypeScript support library for editing RepRapFirmware (RRF) files in the [Monaco editor](https://microsoft.github.io/monaco-editor/). It provides syntax highlighting, autocompletion, hover tooltips, signature help and object-model awareness for G-code and the other file formats used by Duet boards.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Languages
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- `gcodeCNCLanguage` (RRF G-code to be used in CNC and Laser mode)
|
|
7
|
+
`registerDuetLanguages()` registers four Monaco languages:
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
- `gcode-fdm` - RRF G-code in FFF/FDM mode
|
|
10
|
+
- `gcode-cnc` - RRF G-code in CNC and Laser mode
|
|
11
|
+
- `stm32` - `board.txt` hardware configuration (RRF on STM32/LPC)
|
|
12
|
+
- `menu` - PanelDue `menu` files
|
|
11
13
|
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
Since v3.6 the package has grown from plain tokenizers into a full editing experience:
|
|
17
|
+
|
|
18
|
+
- **One-call registration** - `registerDuetLanguages(monaco)` registers all languages with their bracket/comment configuration and theme colour overrides.
|
|
19
|
+
- **G-code autocompletion** - codes (G/M/T) and their parameters from a curated dictionary, including value enumerations where a parameter takes a fixed set of options.
|
|
20
|
+
- **Hover tooltips** - code summaries and per-parameter documentation.
|
|
21
|
+
- **Signature help** - a floating parameter list for the code being typed, with the active parameter highlighted.
|
|
22
|
+
- **Object-model awareness** - completion and hover for object-model expressions (e.g. `move.axes[0].letter`), enum values resolved from the model, and `var`/`global` local-variable completion inside meta G-code.
|
|
23
|
+
- **Meta G-code expressions** - functions, keywords and operators used in conditional G-code.
|
|
24
|
+
- **Machine-aware axis parameters** - per-axis parameters (positions, speeds, currents, ...) follow the connected machine: the suggestion list and parameter summary only offer the axes the machine actually has, while hovering or typing any supported axis still shows its documentation.
|
|
25
|
+
- **Deprecation hints** - deprecated codes, parameters and object-model paths are decorated in the editor and flagged in tooltips.
|
|
26
|
+
- **In-editor G-code search** plus a signature-help watcher that keeps the parameter popup in sync.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Register the languages once per Monaco instance:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { registerDuetLanguages } from "@duet3d/monacotokens";
|
|
34
|
+
|
|
35
|
+
registerDuetLanguages(monaco);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Attach the per-editor G-code features (search action, signature-help watcher, deprecation decorations and the local-variable scanner) to each editor:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { attachGcodeFeatures } from "@duet3d/monacotokens";
|
|
42
|
+
|
|
43
|
+
const features = attachGcodeFeatures(monaco, editor);
|
|
44
|
+
// later, when disposing the editor:
|
|
45
|
+
features.dispose();
|
|
12
46
|
```
|
|
47
|
+
|
|
48
|
+
### Machine context
|
|
49
|
+
|
|
50
|
+
For object-model and machine-aware completion (including the axis parameters above), provide the live object model. The providers read through the reference at completion time, so in-place model updates are picked up automatically. Pass a fresh reference whenever your store swaps the model (e.g. on reconnect), and `null` when no machine is connected:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { setMachineContext } from "@duet3d/monacotokens";
|
|
54
|
+
|
|
55
|
+
setMachineContext({ model: machineModel });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Without a machine context, axis parameters fall back to the standard letters (X, Y, Z, U, V, W, A, B, C, D), exported as `DEFAULT_AXIS_LETTERS`; the full set of valid axis identifiers is exported as `ALL_AXIS_LETTERS`.
|
|
59
|
+
|
|
60
|
+
The lower-level Monarch tokenizers (`gcodeFDMLanguage`, `gcodeCNCLanguage`, `stm32Language`, `menuLanguage`) and their language configurations remain exported for manual registration if you do not want the providers:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
13
63
|
monaco.languages.register({ id: "gcode-fdm" });
|
|
14
64
|
monaco.languages.setMonarchTokensProvider("gcode-fdm", gcodeFDMLanguage);
|
|
15
65
|
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
{
|
|
124
124
|
"name": "round",
|
|
125
125
|
"syntax": "round(x)",
|
|
126
|
-
"description": "Round x to nearest integer (rounds to even when exactly halfway); returns int if it fits in 32 bits"
|
|
126
|
+
"description": "Round x to nearest integer (rounds to even when exactly halfway); returns int if it fits in 32 bits, else float"
|
|
127
127
|
},
|
|
128
128
|
{
|
|
129
129
|
"name": "sin",
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
"name": "input",
|
|
190
|
-
"description": "
|
|
190
|
+
"description": "Value entered in the last M291 input dialog (modes 4-7)"
|
|
191
191
|
}
|
|
192
192
|
],
|
|
193
193
|
"scopes": [
|
|
@@ -230,13 +230,17 @@
|
|
|
230
230
|
"description": "Information about the current job"
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
|
-
"name": "
|
|
233
|
+
"name": "ledStrips",
|
|
234
234
|
"description": "List of configured LED strips"
|
|
235
235
|
},
|
|
236
236
|
{
|
|
237
237
|
"name": "limits",
|
|
238
238
|
"description": "Machine configuration limits"
|
|
239
239
|
},
|
|
240
|
+
{
|
|
241
|
+
"name": "messages",
|
|
242
|
+
"description": "List of generic messages not associated with a particular code reply"
|
|
243
|
+
},
|
|
240
244
|
{
|
|
241
245
|
"name": "move",
|
|
242
246
|
"description": "Information about the move subsystem"
|