covenant-bridge 0.1.5 → 0.2.1
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/backend.js +4503 -12
- package/dist/backend.js.map +1 -1
- package/manifest.json +9 -4
- package/package.json +14 -13
- package/dist/backend.d.ts +0 -8
- package/dist/backend.d.ts.map +0 -1
- package/dist/services/gcode.d.ts +0 -11
- package/dist/services/gcode.d.ts.map +0 -1
- package/dist/services/gcode.js +0 -55
- package/dist/services/gcode.js.map +0 -1
- package/dist/services/hal.d.ts +0 -12
- package/dist/services/hal.d.ts.map +0 -1
- package/dist/services/hal.js +0 -342
- package/dist/services/hal.js.map +0 -1
- package/dist/services/linuxcnc.d.ts +0 -11
- package/dist/services/linuxcnc.d.ts.map +0 -1
- package/dist/services/linuxcnc.js +0 -246
- package/dist/services/linuxcnc.js.map +0 -1
- package/dist/services/position-logger.d.ts +0 -11
- package/dist/services/position-logger.d.ts.map +0 -1
- package/dist/services/position-logger.js +0 -148
- package/dist/services/position-logger.js.map +0 -1
package/dist/backend.js
CHANGED
|
@@ -1,16 +1,4507 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// ../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/constants.js
|
|
37
|
+
var require_constants = __commonJS({
|
|
38
|
+
"../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/constants.js"(exports2) {
|
|
39
|
+
"use strict";
|
|
40
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
41
|
+
exports2.addon = void 0;
|
|
42
|
+
function loadAddon() {
|
|
43
|
+
const paths = [
|
|
44
|
+
"../build/Release/nml_addon.node",
|
|
45
|
+
"../../build/Release/nml_addon.node"
|
|
46
|
+
// Fallback for debug builds
|
|
47
|
+
];
|
|
48
|
+
for (const path of paths) {
|
|
49
|
+
try {
|
|
50
|
+
return require(path);
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
throw new Error("Failed to load linuxcnc-node nml native addon. Please ensure it's built correctly and that LinuxCNC is in your PATH.");
|
|
55
|
+
}
|
|
56
|
+
exports2.addon = loadAddon();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// ../node_modules/.pnpm/dlv@1.1.3/node_modules/dlv/dist/dlv.es.js
|
|
61
|
+
var dlv_es_exports = {};
|
|
62
|
+
__export(dlv_es_exports, {
|
|
63
|
+
default: () => dlv_es_default
|
|
64
|
+
});
|
|
65
|
+
function dlv_es_default(t, e, l, n, r) {
|
|
66
|
+
for (e = e.split ? e.split(".") : e, n = 0; n < e.length; n++) t = t ? t[e[n]] : r;
|
|
67
|
+
return t === r ? l : t;
|
|
68
|
+
}
|
|
69
|
+
var init_dlv_es = __esm({
|
|
70
|
+
"../node_modules/.pnpm/dlv@1.1.3/node_modules/dlv/dist/dlv.es.js"() {
|
|
71
|
+
"use strict";
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// ../node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js
|
|
76
|
+
var require_dist = __commonJS({
|
|
77
|
+
"../node_modules/.pnpm/dset@3.1.4/node_modules/dset/dist/index.js"(exports2) {
|
|
78
|
+
"use strict";
|
|
79
|
+
function dset(obj, keys, val) {
|
|
80
|
+
keys.split && (keys = keys.split("."));
|
|
81
|
+
var i = 0, l = keys.length, t = obj, x, k;
|
|
82
|
+
while (i < l) {
|
|
83
|
+
k = "" + keys[i++];
|
|
84
|
+
if (k === "__proto__" || k === "constructor" || k === "prototype") break;
|
|
85
|
+
t = t[k] = i === l ? val : typeof (x = t[k]) === typeof keys ? x : keys[i] * 0 !== 0 || !!~("" + keys[i]).indexOf(".") ? {} : [];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports2.dset = dset;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// ../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/statChannel.js
|
|
93
|
+
var require_statChannel = __commonJS({
|
|
94
|
+
"../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/statChannel.js"(exports2) {
|
|
95
|
+
"use strict";
|
|
96
|
+
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
97
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
98
|
+
};
|
|
99
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
100
|
+
exports2.StatChannel = exports2.DEFAULT_STAT_POLL_INTERVAL = void 0;
|
|
101
|
+
var node_events_1 = require("events");
|
|
102
|
+
var constants_1 = require_constants();
|
|
103
|
+
var dlv_1 = __importDefault((init_dlv_es(), __toCommonJS(dlv_es_exports)));
|
|
104
|
+
var dset_1 = require_dist();
|
|
105
|
+
exports2.DEFAULT_STAT_POLL_INTERVAL = 50;
|
|
106
|
+
var StatChannel2 = class extends node_events_1.EventEmitter {
|
|
107
|
+
constructor(options) {
|
|
108
|
+
super();
|
|
109
|
+
this.poller = null;
|
|
110
|
+
this.isPolling = false;
|
|
111
|
+
this.cursor = 0;
|
|
112
|
+
this.currentStat = null;
|
|
113
|
+
this.watchedProperties = /* @__PURE__ */ new Map();
|
|
114
|
+
this.nativeInstance = new constants_1.addon.NativeStatChannel();
|
|
115
|
+
this.pollInterval = options?.pollInterval ?? exports2.DEFAULT_STAT_POLL_INTERVAL;
|
|
116
|
+
this.currentStat = {};
|
|
117
|
+
const initialResult = this.nativeInstance.poll(true);
|
|
118
|
+
for (const change of initialResult.changes) {
|
|
119
|
+
(0, dset_1.dset)(this.currentStat, change.path, change.value);
|
|
120
|
+
}
|
|
121
|
+
this.cursor = initialResult.cursor;
|
|
122
|
+
this.startPolling();
|
|
123
|
+
}
|
|
124
|
+
startPolling() {
|
|
125
|
+
if (this.poller || !this.nativeInstance)
|
|
126
|
+
return;
|
|
127
|
+
this.poller = setInterval(() => this.performPoll(), this.pollInterval);
|
|
128
|
+
}
|
|
129
|
+
stopPolling() {
|
|
130
|
+
if (this.poller) {
|
|
131
|
+
clearInterval(this.poller);
|
|
132
|
+
this.poller = null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
performPoll() {
|
|
136
|
+
if (this.isPolling)
|
|
137
|
+
return;
|
|
138
|
+
this.isPolling = true;
|
|
139
|
+
try {
|
|
140
|
+
const result = this.nativeInstance.poll();
|
|
141
|
+
this.cursor = result.cursor;
|
|
142
|
+
if (result.changes.length > 0 && this.currentStat) {
|
|
143
|
+
for (const change of result.changes) {
|
|
144
|
+
(0, dset_1.dset)(this.currentStat, change.path, change.value);
|
|
145
|
+
}
|
|
146
|
+
this.emit("delta", result.changes);
|
|
147
|
+
for (const change of result.changes) {
|
|
148
|
+
const path = change.path;
|
|
149
|
+
const watched = this.watchedProperties.get(path);
|
|
150
|
+
if (watched) {
|
|
151
|
+
const oldValue = watched.lastValue;
|
|
152
|
+
const newValue = change.value;
|
|
153
|
+
watched.lastValue = typeof newValue === "object" && newValue !== null ? JSON.parse(JSON.stringify(newValue)) : newValue;
|
|
154
|
+
const listeners = this.rawListeners(path);
|
|
155
|
+
for (const listener of listeners) {
|
|
156
|
+
try {
|
|
157
|
+
listener(newValue, oldValue, path);
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.error(`Error in StatChannel watch callback for ${path}:`, e);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
} catch (e) {
|
|
166
|
+
console.error("Error during StatChannel poll:", e);
|
|
167
|
+
} finally {
|
|
168
|
+
this.isPolling = false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Ensures that a property path is being tracked for changes.
|
|
173
|
+
* This initializes the lastValue for comparing changes.
|
|
174
|
+
*/
|
|
175
|
+
ensureWatched(propertyPath) {
|
|
176
|
+
if (!this.watchedProperties.has(propertyPath)) {
|
|
177
|
+
const initialValue = this.currentStat ? (0, dlv_1.default)(this.currentStat, propertyPath) : null;
|
|
178
|
+
this.watchedProperties.set(propertyPath, {
|
|
179
|
+
lastValue: typeof initialValue === "object" && initialValue !== null ? JSON.parse(JSON.stringify(initialValue)) : initialValue
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
on(event, listener) {
|
|
184
|
+
if (event === "delta") {
|
|
185
|
+
return super.on(event, listener);
|
|
186
|
+
}
|
|
187
|
+
this.ensureWatched(event);
|
|
188
|
+
return super.on(event, listener);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Registers a one-time listener for changes to a specific property path.
|
|
192
|
+
* The listener will be removed after it fires once.
|
|
193
|
+
* @param propertyPath A dot-separated path to the property.
|
|
194
|
+
* @param listener The function to call when the property's value changes.
|
|
195
|
+
* @returns this (for chaining)
|
|
196
|
+
*/
|
|
197
|
+
once(propertyPath, listener) {
|
|
198
|
+
this.ensureWatched(propertyPath);
|
|
199
|
+
return super.once(propertyPath, listener);
|
|
200
|
+
}
|
|
201
|
+
off(event, listener) {
|
|
202
|
+
if (event === "delta") {
|
|
203
|
+
return super.off(event, listener);
|
|
204
|
+
}
|
|
205
|
+
const result = super.off(event, listener);
|
|
206
|
+
if (this.listenerCount(event) === 0) {
|
|
207
|
+
this.watchedProperties.delete(event);
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Removes a listener for a specific property path.
|
|
213
|
+
* Alias for off().
|
|
214
|
+
* @param propertyPath The property path.
|
|
215
|
+
* @param listener The listener function to remove.
|
|
216
|
+
* @returns this (for chaining)
|
|
217
|
+
*/
|
|
218
|
+
removeListener(propertyPath, listener) {
|
|
219
|
+
return this.off(propertyPath, listener);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Sets the polling interval for status updates.
|
|
223
|
+
* @param interval The new interval in milliseconds.
|
|
224
|
+
*/
|
|
225
|
+
setPollInterval(interval) {
|
|
226
|
+
this.pollInterval = Math.max(10, interval);
|
|
227
|
+
this.stopPolling();
|
|
228
|
+
this.startPolling();
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Gets the current polling interval.
|
|
232
|
+
* @returns The interval in milliseconds.
|
|
233
|
+
*/
|
|
234
|
+
getPollInterval() {
|
|
235
|
+
return this.pollInterval;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Retrieves the most recent full status object.
|
|
239
|
+
* @returns The current LinuxCNCStat object, or null if not yet available.
|
|
240
|
+
*/
|
|
241
|
+
get() {
|
|
242
|
+
return this.currentStat;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Forces a full resync of the stat object from native.
|
|
246
|
+
* Use this if cursor gaps are detected or for initial sync scenarios.
|
|
247
|
+
*/
|
|
248
|
+
sync() {
|
|
249
|
+
this.currentStat = {};
|
|
250
|
+
const result = this.nativeInstance.poll(true);
|
|
251
|
+
for (const change of result.changes) {
|
|
252
|
+
(0, dset_1.dset)(this.currentStat, change.path, change.value);
|
|
253
|
+
}
|
|
254
|
+
this.cursor = result.cursor;
|
|
255
|
+
this.watchedProperties.forEach((watched, path) => {
|
|
256
|
+
watched.lastValue = this.currentStat ? (0, dlv_1.default)(this.currentStat, path) : null;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Gets the current cursor value for sync verification.
|
|
261
|
+
* The cursor increments each time the native layer detects changes.
|
|
262
|
+
* @returns The current cursor value.
|
|
263
|
+
*/
|
|
264
|
+
getCursor() {
|
|
265
|
+
return this.cursor;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Cleans up resources, stopping the polling timer.
|
|
269
|
+
*/
|
|
270
|
+
destroy() {
|
|
271
|
+
this.stopPolling();
|
|
272
|
+
this.watchedProperties.clear();
|
|
273
|
+
this.removeAllListeners();
|
|
274
|
+
if (this.nativeInstance) {
|
|
275
|
+
this.nativeInstance.disconnect();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
// --- Convenience Getters for common properties ---
|
|
279
|
+
// These access the locally cached `this.currentStat`
|
|
280
|
+
get task() {
|
|
281
|
+
return this.currentStat?.task;
|
|
282
|
+
}
|
|
283
|
+
get motion() {
|
|
284
|
+
return this.currentStat?.motion;
|
|
285
|
+
}
|
|
286
|
+
get io() {
|
|
287
|
+
return this.currentStat?.io;
|
|
288
|
+
}
|
|
289
|
+
get toolTable() {
|
|
290
|
+
return this.currentStat?.toolTable;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
exports2.StatChannel = StatChannel2;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// ../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/constants.js
|
|
298
|
+
var require_constants2 = __commonJS({
|
|
299
|
+
"../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/constants.js"(exports2) {
|
|
300
|
+
"use strict";
|
|
301
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
302
|
+
exports2.EmcDebug = exports2.OrientState = exports2.JointType = exports2.NmlMessageType = exports2.ProgramUnits = exports2.RcsStatus = exports2.KinematicsType = exports2.MotionType = exports2.TrajMode = exports2.InterpState = exports2.ExecState = exports2.TaskState = exports2.TaskMode = void 0;
|
|
303
|
+
var TaskMode;
|
|
304
|
+
(function(TaskMode2) {
|
|
305
|
+
TaskMode2[TaskMode2["MANUAL"] = 1] = "MANUAL";
|
|
306
|
+
TaskMode2[TaskMode2["AUTO"] = 2] = "AUTO";
|
|
307
|
+
TaskMode2[TaskMode2["MDI"] = 3] = "MDI";
|
|
308
|
+
})(TaskMode || (exports2.TaskMode = TaskMode = {}));
|
|
309
|
+
var TaskState;
|
|
310
|
+
(function(TaskState2) {
|
|
311
|
+
TaskState2[TaskState2["ESTOP"] = 1] = "ESTOP";
|
|
312
|
+
TaskState2[TaskState2["ESTOP_RESET"] = 2] = "ESTOP_RESET";
|
|
313
|
+
TaskState2[TaskState2["OFF"] = 3] = "OFF";
|
|
314
|
+
TaskState2[TaskState2["ON"] = 4] = "ON";
|
|
315
|
+
})(TaskState || (exports2.TaskState = TaskState = {}));
|
|
316
|
+
var ExecState;
|
|
317
|
+
(function(ExecState2) {
|
|
318
|
+
ExecState2[ExecState2["ERROR"] = 1] = "ERROR";
|
|
319
|
+
ExecState2[ExecState2["DONE"] = 2] = "DONE";
|
|
320
|
+
ExecState2[ExecState2["WAITING_FOR_MOTION"] = 3] = "WAITING_FOR_MOTION";
|
|
321
|
+
ExecState2[ExecState2["WAITING_FOR_MOTION_QUEUE"] = 4] = "WAITING_FOR_MOTION_QUEUE";
|
|
322
|
+
ExecState2[ExecState2["WAITING_FOR_IO"] = 5] = "WAITING_FOR_IO";
|
|
323
|
+
ExecState2[ExecState2["WAITING_FOR_MOTION_AND_IO"] = 7] = "WAITING_FOR_MOTION_AND_IO";
|
|
324
|
+
ExecState2[ExecState2["WAITING_FOR_DELAY"] = 8] = "WAITING_FOR_DELAY";
|
|
325
|
+
ExecState2[ExecState2["WAITING_FOR_SYSTEM_CMD"] = 9] = "WAITING_FOR_SYSTEM_CMD";
|
|
326
|
+
ExecState2[ExecState2["WAITING_FOR_SPINDLE_ORIENTED"] = 10] = "WAITING_FOR_SPINDLE_ORIENTED";
|
|
327
|
+
})(ExecState || (exports2.ExecState = ExecState = {}));
|
|
328
|
+
var InterpState;
|
|
329
|
+
(function(InterpState2) {
|
|
330
|
+
InterpState2[InterpState2["IDLE"] = 1] = "IDLE";
|
|
331
|
+
InterpState2[InterpState2["READING"] = 2] = "READING";
|
|
332
|
+
InterpState2[InterpState2["PAUSED"] = 3] = "PAUSED";
|
|
333
|
+
InterpState2[InterpState2["WAITING"] = 4] = "WAITING";
|
|
334
|
+
})(InterpState || (exports2.InterpState = InterpState = {}));
|
|
335
|
+
var TrajMode;
|
|
336
|
+
(function(TrajMode2) {
|
|
337
|
+
TrajMode2[TrajMode2["FREE"] = 1] = "FREE";
|
|
338
|
+
TrajMode2[TrajMode2["COORD"] = 2] = "COORD";
|
|
339
|
+
TrajMode2[TrajMode2["TELEOP"] = 3] = "TELEOP";
|
|
340
|
+
})(TrajMode || (exports2.TrajMode = TrajMode = {}));
|
|
341
|
+
var MotionType;
|
|
342
|
+
(function(MotionType2) {
|
|
343
|
+
MotionType2[MotionType2["NONE"] = 0] = "NONE";
|
|
344
|
+
MotionType2[MotionType2["TRAVERSE"] = 1] = "TRAVERSE";
|
|
345
|
+
MotionType2[MotionType2["FEED"] = 2] = "FEED";
|
|
346
|
+
MotionType2[MotionType2["ARC"] = 3] = "ARC";
|
|
347
|
+
MotionType2[MotionType2["TOOLCHANGE"] = 4] = "TOOLCHANGE";
|
|
348
|
+
MotionType2[MotionType2["PROBING"] = 5] = "PROBING";
|
|
349
|
+
MotionType2[MotionType2["INDEXROTARY"] = 6] = "INDEXROTARY";
|
|
350
|
+
})(MotionType || (exports2.MotionType = MotionType = {}));
|
|
351
|
+
var KinematicsType;
|
|
352
|
+
(function(KinematicsType2) {
|
|
353
|
+
KinematicsType2[KinematicsType2["IDENTITY"] = 1] = "IDENTITY";
|
|
354
|
+
KinematicsType2[KinematicsType2["FORWARD_ONLY"] = 2] = "FORWARD_ONLY";
|
|
355
|
+
KinematicsType2[KinematicsType2["INVERSE_ONLY"] = 3] = "INVERSE_ONLY";
|
|
356
|
+
KinematicsType2[KinematicsType2["BOTH"] = 4] = "BOTH";
|
|
357
|
+
})(KinematicsType || (exports2.KinematicsType = KinematicsType = {}));
|
|
358
|
+
var RcsStatus;
|
|
359
|
+
(function(RcsStatus2) {
|
|
360
|
+
RcsStatus2[RcsStatus2["UNINITIALIZED"] = -1] = "UNINITIALIZED";
|
|
361
|
+
RcsStatus2[RcsStatus2["DONE"] = 1] = "DONE";
|
|
362
|
+
RcsStatus2[RcsStatus2["EXEC"] = 2] = "EXEC";
|
|
363
|
+
RcsStatus2[RcsStatus2["ERROR"] = 3] = "ERROR";
|
|
364
|
+
})(RcsStatus || (exports2.RcsStatus = RcsStatus = {}));
|
|
365
|
+
var ProgramUnits;
|
|
366
|
+
(function(ProgramUnits2) {
|
|
367
|
+
ProgramUnits2[ProgramUnits2["INCH"] = 1] = "INCH";
|
|
368
|
+
ProgramUnits2[ProgramUnits2["MM"] = 2] = "MM";
|
|
369
|
+
ProgramUnits2[ProgramUnits2["CM"] = 3] = "CM";
|
|
370
|
+
})(ProgramUnits || (exports2.ProgramUnits = ProgramUnits = {}));
|
|
371
|
+
var NmlMessageType;
|
|
372
|
+
(function(NmlMessageType2) {
|
|
373
|
+
NmlMessageType2[NmlMessageType2["EMC_OPERATOR_ERROR"] = 11] = "EMC_OPERATOR_ERROR";
|
|
374
|
+
NmlMessageType2[NmlMessageType2["EMC_OPERATOR_TEXT"] = 12] = "EMC_OPERATOR_TEXT";
|
|
375
|
+
NmlMessageType2[NmlMessageType2["EMC_OPERATOR_DISPLAY"] = 13] = "EMC_OPERATOR_DISPLAY";
|
|
376
|
+
NmlMessageType2[NmlMessageType2["NML_ERROR"] = 1] = "NML_ERROR";
|
|
377
|
+
NmlMessageType2[NmlMessageType2["NML_TEXT"] = 2] = "NML_TEXT";
|
|
378
|
+
NmlMessageType2[NmlMessageType2["NML_DISPLAY"] = 3] = "NML_DISPLAY";
|
|
379
|
+
})(NmlMessageType || (exports2.NmlMessageType = NmlMessageType = {}));
|
|
380
|
+
var JointType;
|
|
381
|
+
(function(JointType2) {
|
|
382
|
+
JointType2[JointType2["LINEAR"] = 1] = "LINEAR";
|
|
383
|
+
JointType2[JointType2["ANGULAR"] = 2] = "ANGULAR";
|
|
384
|
+
})(JointType || (exports2.JointType = JointType = {}));
|
|
385
|
+
var OrientState;
|
|
386
|
+
(function(OrientState2) {
|
|
387
|
+
OrientState2[OrientState2["NONE"] = 0] = "NONE";
|
|
388
|
+
OrientState2[OrientState2["COMPLETE"] = 1] = "COMPLETE";
|
|
389
|
+
OrientState2[OrientState2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
|
|
390
|
+
OrientState2[OrientState2["FAULTED"] = 3] = "FAULTED";
|
|
391
|
+
})(OrientState || (exports2.OrientState = OrientState = {}));
|
|
392
|
+
var EmcDebug;
|
|
393
|
+
(function(EmcDebug2) {
|
|
394
|
+
EmcDebug2[EmcDebug2["CONFIG"] = 2] = "CONFIG";
|
|
395
|
+
EmcDebug2[EmcDebug2["VERSIONS"] = 8] = "VERSIONS";
|
|
396
|
+
EmcDebug2[EmcDebug2["TASK_ISSUE"] = 16] = "TASK_ISSUE";
|
|
397
|
+
EmcDebug2[EmcDebug2["NML"] = 64] = "NML";
|
|
398
|
+
EmcDebug2[EmcDebug2["MOTION_TIME"] = 128] = "MOTION_TIME";
|
|
399
|
+
EmcDebug2[EmcDebug2["INTERP"] = 256] = "INTERP";
|
|
400
|
+
EmcDebug2[EmcDebug2["RCS"] = 512] = "RCS";
|
|
401
|
+
EmcDebug2[EmcDebug2["INTERP_LIST"] = 2048] = "INTERP_LIST";
|
|
402
|
+
EmcDebug2[EmcDebug2["IOCONTROL"] = 4096] = "IOCONTROL";
|
|
403
|
+
EmcDebug2[EmcDebug2["OWORD"] = 8192] = "OWORD";
|
|
404
|
+
EmcDebug2[EmcDebug2["REMAP"] = 16384] = "REMAP";
|
|
405
|
+
EmcDebug2[EmcDebug2["PYTHON"] = 32768] = "PYTHON";
|
|
406
|
+
EmcDebug2[EmcDebug2["NAMEDPARAM"] = 65536] = "NAMEDPARAM";
|
|
407
|
+
EmcDebug2[EmcDebug2["GDBONSIGNAL"] = 131072] = "GDBONSIGNAL";
|
|
408
|
+
EmcDebug2[EmcDebug2["STATE_TAGS"] = 524288] = "STATE_TAGS";
|
|
409
|
+
})(EmcDebug || (exports2.EmcDebug = EmcDebug = {}));
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
// ../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/core.js
|
|
414
|
+
var require_core = __commonJS({
|
|
415
|
+
"../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/core.js"(exports2) {
|
|
416
|
+
"use strict";
|
|
417
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
418
|
+
exports2.PositionIndex = exports2.PositionLoggerIndex = exports2.POSITION_STRIDE = void 0;
|
|
419
|
+
exports2.POSITION_STRIDE = 10;
|
|
420
|
+
var PositionLoggerIndex;
|
|
421
|
+
(function(PositionLoggerIndex2) {
|
|
422
|
+
PositionLoggerIndex2[PositionLoggerIndex2["X"] = 0] = "X";
|
|
423
|
+
PositionLoggerIndex2[PositionLoggerIndex2["Y"] = 1] = "Y";
|
|
424
|
+
PositionLoggerIndex2[PositionLoggerIndex2["Z"] = 2] = "Z";
|
|
425
|
+
PositionLoggerIndex2[PositionLoggerIndex2["A"] = 3] = "A";
|
|
426
|
+
PositionLoggerIndex2[PositionLoggerIndex2["B"] = 4] = "B";
|
|
427
|
+
PositionLoggerIndex2[PositionLoggerIndex2["C"] = 5] = "C";
|
|
428
|
+
PositionLoggerIndex2[PositionLoggerIndex2["U"] = 6] = "U";
|
|
429
|
+
PositionLoggerIndex2[PositionLoggerIndex2["V"] = 7] = "V";
|
|
430
|
+
PositionLoggerIndex2[PositionLoggerIndex2["W"] = 8] = "W";
|
|
431
|
+
PositionLoggerIndex2[PositionLoggerIndex2["MotionType"] = 9] = "MotionType";
|
|
432
|
+
})(PositionLoggerIndex || (exports2.PositionLoggerIndex = PositionLoggerIndex = {}));
|
|
433
|
+
var PositionIndex;
|
|
434
|
+
(function(PositionIndex2) {
|
|
435
|
+
PositionIndex2[PositionIndex2["X"] = 0] = "X";
|
|
436
|
+
PositionIndex2[PositionIndex2["Y"] = 1] = "Y";
|
|
437
|
+
PositionIndex2[PositionIndex2["Z"] = 2] = "Z";
|
|
438
|
+
PositionIndex2[PositionIndex2["A"] = 3] = "A";
|
|
439
|
+
PositionIndex2[PositionIndex2["B"] = 4] = "B";
|
|
440
|
+
PositionIndex2[PositionIndex2["C"] = 5] = "C";
|
|
441
|
+
PositionIndex2[PositionIndex2["U"] = 6] = "U";
|
|
442
|
+
PositionIndex2[PositionIndex2["V"] = 7] = "V";
|
|
443
|
+
PositionIndex2[PositionIndex2["W"] = 8] = "W";
|
|
444
|
+
})(PositionIndex || (exports2.PositionIndex = PositionIndex = {}));
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
// ../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/hal.js
|
|
449
|
+
var require_hal = __commonJS({
|
|
450
|
+
"../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/hal.js"(exports2) {
|
|
451
|
+
"use strict";
|
|
452
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
// ../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/gcode.js
|
|
457
|
+
var require_gcode = __commonJS({
|
|
458
|
+
"../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/gcode.js"(exports2) {
|
|
459
|
+
"use strict";
|
|
460
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
461
|
+
exports2.Plane = exports2.OperationType = void 0;
|
|
462
|
+
var OperationType;
|
|
463
|
+
(function(OperationType2) {
|
|
464
|
+
OperationType2[OperationType2["TRAVERSE"] = 1] = "TRAVERSE";
|
|
465
|
+
OperationType2[OperationType2["FEED"] = 2] = "FEED";
|
|
466
|
+
OperationType2[OperationType2["ARC"] = 3] = "ARC";
|
|
467
|
+
OperationType2[OperationType2["PROBE"] = 4] = "PROBE";
|
|
468
|
+
OperationType2[OperationType2["RIGID_TAP"] = 5] = "RIGID_TAP";
|
|
469
|
+
OperationType2[OperationType2["DWELL"] = 6] = "DWELL";
|
|
470
|
+
OperationType2[OperationType2["NURBS_G5"] = 7] = "NURBS_G5";
|
|
471
|
+
OperationType2[OperationType2["NURBS_G6"] = 8] = "NURBS_G6";
|
|
472
|
+
OperationType2[OperationType2["UNITS_CHANGE"] = 10] = "UNITS_CHANGE";
|
|
473
|
+
OperationType2[OperationType2["PLANE_CHANGE"] = 11] = "PLANE_CHANGE";
|
|
474
|
+
OperationType2[OperationType2["G5X_OFFSET"] = 12] = "G5X_OFFSET";
|
|
475
|
+
OperationType2[OperationType2["G92_OFFSET"] = 13] = "G92_OFFSET";
|
|
476
|
+
OperationType2[OperationType2["XY_ROTATION"] = 14] = "XY_ROTATION";
|
|
477
|
+
OperationType2[OperationType2["TOOL_OFFSET"] = 15] = "TOOL_OFFSET";
|
|
478
|
+
OperationType2[OperationType2["TOOL_CHANGE"] = 16] = "TOOL_CHANGE";
|
|
479
|
+
OperationType2[OperationType2["FEED_RATE_CHANGE"] = 17] = "FEED_RATE_CHANGE";
|
|
480
|
+
})(OperationType || (exports2.OperationType = OperationType = {}));
|
|
481
|
+
var Plane;
|
|
482
|
+
(function(Plane2) {
|
|
483
|
+
Plane2[Plane2["XY"] = 1] = "XY";
|
|
484
|
+
Plane2[Plane2["YZ"] = 2] = "YZ";
|
|
485
|
+
Plane2[Plane2["XZ"] = 3] = "XZ";
|
|
486
|
+
Plane2[Plane2["UV"] = 4] = "UV";
|
|
487
|
+
Plane2[Plane2["VW"] = 5] = "VW";
|
|
488
|
+
Plane2[Plane2["UW"] = 6] = "UW";
|
|
489
|
+
})(Plane || (exports2.Plane = Plane = {}));
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
// ../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/index.js
|
|
494
|
+
var require_dist2 = __commonJS({
|
|
495
|
+
"../node_modules/.pnpm/@linuxcnc-node+types@2.1.1/node_modules/@linuxcnc-node/types/dist/index.js"(exports2) {
|
|
496
|
+
"use strict";
|
|
497
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
498
|
+
if (k2 === void 0) k2 = k;
|
|
499
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
500
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
501
|
+
desc = { enumerable: true, get: function() {
|
|
502
|
+
return m[k];
|
|
503
|
+
} };
|
|
504
|
+
}
|
|
505
|
+
Object.defineProperty(o, k2, desc);
|
|
506
|
+
}) : (function(o, m, k, k2) {
|
|
507
|
+
if (k2 === void 0) k2 = k;
|
|
508
|
+
o[k2] = m[k];
|
|
509
|
+
}));
|
|
510
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
511
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
512
|
+
};
|
|
513
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
514
|
+
__exportStar(require_constants2(), exports2);
|
|
515
|
+
__exportStar(require_core(), exports2);
|
|
516
|
+
__exportStar(require_hal(), exports2);
|
|
517
|
+
__exportStar(require_gcode(), exports2);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
// ../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/commandChannel.js
|
|
522
|
+
var require_commandChannel = __commonJS({
|
|
523
|
+
"../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/commandChannel.js"(exports2) {
|
|
524
|
+
"use strict";
|
|
525
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
526
|
+
exports2.CommandChannel = void 0;
|
|
527
|
+
var constants_1 = require_constants();
|
|
528
|
+
var types_1 = require_dist2();
|
|
529
|
+
var CommandChannel2 = class {
|
|
530
|
+
constructor() {
|
|
531
|
+
this.nativeInstance = new constants_1.addon.NativeCommandChannel();
|
|
532
|
+
}
|
|
533
|
+
async exec(cmdFunc, ...args) {
|
|
534
|
+
try {
|
|
535
|
+
const status = await cmdFunc.apply(this.nativeInstance, args);
|
|
536
|
+
if (status !== types_1.RcsStatus.DONE && status !== types_1.RcsStatus.EXEC) {
|
|
537
|
+
throw new Error(`Command failed with RCS status: ${types_1.RcsStatus[status] || status}`);
|
|
538
|
+
}
|
|
539
|
+
return status;
|
|
540
|
+
} catch (e) {
|
|
541
|
+
throw new Error(`Command native execution failed: ${e.message || e}`);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
// --- Task Commands ---
|
|
545
|
+
/**
|
|
546
|
+
* Sets the task execution mode for LinuxCNC
|
|
547
|
+
*
|
|
548
|
+
* @param mode - The task mode to set (MDI, MANUAL, or AUTO)
|
|
549
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```typescript
|
|
553
|
+
* // Switch to MDI mode for manual data input
|
|
554
|
+
* await commandChannel.setTaskMode(TaskMode.MDI);
|
|
555
|
+
*
|
|
556
|
+
* // Switch to manual mode for jogging
|
|
557
|
+
* await commandChannel.setTaskMode(TaskMode.MANUAL);
|
|
558
|
+
*
|
|
559
|
+
* // Switch to auto mode for program execution
|
|
560
|
+
* await commandChannel.setTaskMode(TaskMode.AUTO);
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
async setTaskMode(mode) {
|
|
564
|
+
return this.exec(this.nativeInstance.setTaskMode, mode);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Sets the task state for LinuxCNC
|
|
568
|
+
*
|
|
569
|
+
* @param state - The task state to set (ESTOP, ESTOP_RESET, OFF, or ON)
|
|
570
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```typescript
|
|
574
|
+
* // Enable E-stop
|
|
575
|
+
* await commandChannel.setState(TaskState.ESTOP);
|
|
576
|
+
*
|
|
577
|
+
* // Reset E-stop
|
|
578
|
+
* await commandChannel.setState(TaskState.ESTOP_RESET);
|
|
579
|
+
*
|
|
580
|
+
* // Turn machine on
|
|
581
|
+
* await commandChannel.setState(TaskState.ON);
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
async setState(state) {
|
|
585
|
+
return this.exec(this.nativeInstance.setState, state);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* On completion of this call, the VAR file on disk is updated with live values from the interpreter.
|
|
589
|
+
*
|
|
590
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
591
|
+
*/
|
|
592
|
+
async taskPlanSynch() {
|
|
593
|
+
return this.exec(this.nativeInstance.taskPlanSynch);
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Resets the G-code interpreter
|
|
597
|
+
*
|
|
598
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
599
|
+
*/
|
|
600
|
+
async resetInterpreter() {
|
|
601
|
+
return this.exec(this.nativeInstance.resetInterpreter);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Opens a G-code program file for execution
|
|
605
|
+
*
|
|
606
|
+
* @param filePath - Absolute path to the G-code file to open
|
|
607
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```typescript
|
|
611
|
+
* // Open a G-code program
|
|
612
|
+
* await commandChannel.programOpen('/home/user/programs/part.ngc');
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
async programOpen(filePath) {
|
|
616
|
+
return this.exec(this.nativeInstance.programOpen, filePath);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Runs the currently loaded G-code program
|
|
620
|
+
*
|
|
621
|
+
* @param startLine - Line number to start execution from (default: 0 for beginning)
|
|
622
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
623
|
+
*
|
|
624
|
+
* @example
|
|
625
|
+
* ```typescript
|
|
626
|
+
* // Run program from the beginning
|
|
627
|
+
* await commandChannel.runProgram();
|
|
628
|
+
*
|
|
629
|
+
* // Run program starting from line 100
|
|
630
|
+
* await commandChannel.runProgram(100);
|
|
631
|
+
* ```
|
|
632
|
+
*/
|
|
633
|
+
async runProgram(startLine = 0) {
|
|
634
|
+
return this.exec(this.nativeInstance.runProgram, startLine);
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Pauses the currently running G-code program
|
|
638
|
+
* Program can be resumed with resumeProgram()
|
|
639
|
+
*
|
|
640
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* ```typescript
|
|
644
|
+
* // Pause the running program
|
|
645
|
+
* await commandChannel.pauseProgram();
|
|
646
|
+
* ```
|
|
647
|
+
*/
|
|
648
|
+
async pauseProgram() {
|
|
649
|
+
return this.exec(this.nativeInstance.pauseProgram);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Resumes a paused G-code program
|
|
653
|
+
*
|
|
654
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
655
|
+
*
|
|
656
|
+
* @example
|
|
657
|
+
* ```typescript
|
|
658
|
+
* // Resume the paused program
|
|
659
|
+
* await commandChannel.resumeProgram();
|
|
660
|
+
* ```
|
|
661
|
+
*/
|
|
662
|
+
async resumeProgram() {
|
|
663
|
+
return this.exec(this.nativeInstance.resumeProgram);
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Executes a single step of the G-code program
|
|
667
|
+
* Advances program execution by one line/block
|
|
668
|
+
*
|
|
669
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
670
|
+
*
|
|
671
|
+
* @example
|
|
672
|
+
* ```typescript
|
|
673
|
+
* // Step through program one line at a time
|
|
674
|
+
* await commandChannel.stepProgram();
|
|
675
|
+
* ```
|
|
676
|
+
*/
|
|
677
|
+
async stepProgram() {
|
|
678
|
+
return this.exec(this.nativeInstance.stepProgram);
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Reverses program execution direction
|
|
682
|
+
* Used for backing up through a program
|
|
683
|
+
*
|
|
684
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
685
|
+
*/
|
|
686
|
+
async reverseProgram() {
|
|
687
|
+
return this.exec(this.nativeInstance.reverseProgram);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Sets program execution direction to forward
|
|
691
|
+
* Used after reversing to resume normal forward execution
|
|
692
|
+
*
|
|
693
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
694
|
+
*/
|
|
695
|
+
async forwardProgram() {
|
|
696
|
+
return this.exec(this.nativeInstance.forwardProgram);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Aborts the currently running task/program
|
|
700
|
+
* Immediately stops all motion and task execution
|
|
701
|
+
*
|
|
702
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* ```typescript
|
|
706
|
+
* // Emergency stop of current program
|
|
707
|
+
* await commandChannel.abortTask();
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
710
|
+
async abortTask() {
|
|
711
|
+
return this.exec(this.nativeInstance.abortTask);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Enables or disables optional stop (M1) functionality
|
|
715
|
+
* When enabled, M1 codes in programs will pause execution
|
|
716
|
+
*
|
|
717
|
+
* @param enable - true to enable optional stops, false to disable
|
|
718
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```typescript
|
|
722
|
+
* // Enable optional stops
|
|
723
|
+
* await commandChannel.setOptionalStop(true);
|
|
724
|
+
*
|
|
725
|
+
* // Disable optional stops
|
|
726
|
+
* await commandChannel.setOptionalStop(false);
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
async setOptionalStop(enable) {
|
|
730
|
+
return this.exec(this.nativeInstance.setOptionalStop, enable);
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Enables or disables block delete functionality
|
|
734
|
+
* When enabled, lines beginning with "/" are skipped during execution
|
|
735
|
+
*
|
|
736
|
+
* @param enable - true to enable block delete, false to disable
|
|
737
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* ```typescript
|
|
741
|
+
* // Enable block delete - skip lines starting with "/"
|
|
742
|
+
* await commandChannel.setBlockDelete(true);
|
|
743
|
+
*
|
|
744
|
+
* // Disable block delete - execute all lines
|
|
745
|
+
* await commandChannel.setBlockDelete(false);
|
|
746
|
+
* ```
|
|
747
|
+
*/
|
|
748
|
+
async setBlockDelete(enable) {
|
|
749
|
+
return this.exec(this.nativeInstance.setBlockDelete, enable);
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Executes a Manual Data Input (MDI) command
|
|
753
|
+
* Allows direct execution of G-code commands without a program file
|
|
754
|
+
*
|
|
755
|
+
* @param command - G-code command string to execute
|
|
756
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
757
|
+
*
|
|
758
|
+
* @example
|
|
759
|
+
* ```typescript
|
|
760
|
+
* // Move to position
|
|
761
|
+
* await commandChannel.mdi('G0 X10 Y20 Z5');
|
|
762
|
+
*
|
|
763
|
+
* // Set spindle speed
|
|
764
|
+
* await commandChannel.mdi('S1000 M3');
|
|
765
|
+
* ```
|
|
766
|
+
*/
|
|
767
|
+
async mdi(command) {
|
|
768
|
+
return this.exec(this.nativeInstance.mdi, command);
|
|
769
|
+
}
|
|
770
|
+
// --- Trajectory Commands ---
|
|
771
|
+
/**
|
|
772
|
+
* Sets the trajectory mode for coordinated motion
|
|
773
|
+
*
|
|
774
|
+
* @param mode - The trajectory mode (FREE, COORD, or TELEOP)
|
|
775
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* ```typescript
|
|
779
|
+
* // Set to coordinated mode for normal G-code execution
|
|
780
|
+
* await commandChannel.setTrajMode(TrajMode.COORD);
|
|
781
|
+
*
|
|
782
|
+
* // Set to free mode for individual joint control
|
|
783
|
+
* await commandChannel.setTrajMode(TrajMode.FREE);
|
|
784
|
+
* ```
|
|
785
|
+
*/
|
|
786
|
+
async setTrajMode(mode) {
|
|
787
|
+
return this.exec(this.nativeInstance.setTrajMode, mode);
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Sets the maximum velocity for trajectory planning
|
|
791
|
+
*
|
|
792
|
+
* @param velocity - Maximum velocity in machine units per second
|
|
793
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```typescript
|
|
797
|
+
* // Set maximum velocity to 200 units/second
|
|
798
|
+
* await commandChannel.setMaxVelocity(200);
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
async setMaxVelocity(velocity) {
|
|
802
|
+
return this.exec(this.nativeInstance.setMaxVelocity, velocity);
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Sets the feedrate override scale factor
|
|
806
|
+
*
|
|
807
|
+
* @param scale - Feedrate scale factor (1.0 = 100%, 0.5 = 50%, 2.0 = 200%)
|
|
808
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
809
|
+
*
|
|
810
|
+
* @example
|
|
811
|
+
* ```typescript
|
|
812
|
+
* // Set feedrate to 50% of programmed values
|
|
813
|
+
* await commandChannel.setFeedRate(0.5);
|
|
814
|
+
*
|
|
815
|
+
* // Set feedrate to 120% of programmed values
|
|
816
|
+
* await commandChannel.setFeedRate(1.2);
|
|
817
|
+
* ```
|
|
818
|
+
*/
|
|
819
|
+
async setFeedRate(scale) {
|
|
820
|
+
return this.exec(this.nativeInstance.setFeedRate, scale);
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Sets the rapid traverse override scale factor
|
|
824
|
+
*
|
|
825
|
+
* @param scale - Rapid rate scale factor (1.0 = 100%, 0.25 = 25%)
|
|
826
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
827
|
+
*
|
|
828
|
+
* @example
|
|
829
|
+
* ```typescript
|
|
830
|
+
* // Set rapid rate to 50%
|
|
831
|
+
* await commandChannel.setRapidRate(0.5);
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
async setRapidRate(scale) {
|
|
835
|
+
return this.exec(this.nativeInstance.setRapidRate, scale);
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Sets the spindle speed override scale factor
|
|
839
|
+
*
|
|
840
|
+
* @param scale - Spindle override scale factor (1.0 = 100%)
|
|
841
|
+
* @param spindleIndex - Index of the spindle to control (default: 0)
|
|
842
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
843
|
+
*
|
|
844
|
+
* @example
|
|
845
|
+
* ```typescript
|
|
846
|
+
* // Set spindle speed to 80% of programmed values
|
|
847
|
+
* await commandChannel.setSpindleOverride(0.8);
|
|
848
|
+
*
|
|
849
|
+
* // Set spindle 1 speed to 110%
|
|
850
|
+
* await commandChannel.setSpindleOverride(1.1, 1);
|
|
851
|
+
* ```
|
|
852
|
+
*/
|
|
853
|
+
async setSpindleOverride(scale, spindleIndex = 0) {
|
|
854
|
+
return this.exec(this.nativeInstance.setSpindleOverride, scale, spindleIndex);
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Overrides axis limits to allow motion beyond normal soft limits
|
|
858
|
+
*
|
|
859
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
860
|
+
*
|
|
861
|
+
* @example
|
|
862
|
+
* ```typescript
|
|
863
|
+
* // Override limits for recovery from limit switch activation
|
|
864
|
+
* await commandChannel.overrideLimits();
|
|
865
|
+
* ```
|
|
866
|
+
*/
|
|
867
|
+
async overrideLimits() {
|
|
868
|
+
return this.exec(this.nativeInstance.overrideLimits);
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Enables or disables teleop mode
|
|
872
|
+
*
|
|
873
|
+
* @param enable - true to enable teleop mode, false for joint mode
|
|
874
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* ```typescript
|
|
878
|
+
* // Enable teleop mode for Cartesian jogging
|
|
879
|
+
* await commandChannel.teleopEnable(true);
|
|
880
|
+
*
|
|
881
|
+
* // Disable teleop mode for joint jogging
|
|
882
|
+
* await commandChannel.teleopEnable(false);
|
|
883
|
+
* ```
|
|
884
|
+
*/
|
|
885
|
+
async teleopEnable(enable) {
|
|
886
|
+
return this.exec(this.nativeInstance.teleopEnable, enable);
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Enables or disables feedrate override functionality
|
|
890
|
+
*
|
|
891
|
+
* @param enable - true to enable feedrate override, false to disable
|
|
892
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
893
|
+
*
|
|
894
|
+
* @example
|
|
895
|
+
* ```typescript
|
|
896
|
+
* // Enable feedrate override control
|
|
897
|
+
* await commandChannel.setFeedOverrideEnable(true);
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
async setFeedOverrideEnable(enable) {
|
|
901
|
+
return this.exec(this.nativeInstance.setFeedOverrideEnable, enable);
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Enables or disables spindle speed override functionality
|
|
905
|
+
*
|
|
906
|
+
* @param enable - true to enable spindle override, false to disable
|
|
907
|
+
* @param spindleIndex - Index of the spindle to control (default: 0)
|
|
908
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
909
|
+
*
|
|
910
|
+
* @example
|
|
911
|
+
* ```typescript
|
|
912
|
+
* // Enable spindle override control
|
|
913
|
+
* await commandChannel.setSpindleOverrideEnable(true);
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
916
|
+
async setSpindleOverrideEnable(enable, spindleIndex = 0) {
|
|
917
|
+
return this.exec(this.nativeInstance.setSpindleOverrideEnable, enable, spindleIndex);
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Enables or disables feed hold functionality
|
|
921
|
+
* When enabled, allows pausing motion without stopping the program
|
|
922
|
+
*
|
|
923
|
+
* @param enable - true to enable feed hold, false to disable
|
|
924
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```typescript
|
|
928
|
+
* // Enable feed hold capability
|
|
929
|
+
* await commandChannel.setFeedHoldEnable(true);
|
|
930
|
+
* ```
|
|
931
|
+
*/
|
|
932
|
+
async setFeedHoldEnable(enable) {
|
|
933
|
+
return this.exec(this.nativeInstance.setFeedHoldEnable, enable);
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Enables or disables adaptive feed functionality
|
|
937
|
+
* Allows external signals to modulate feedrate in real-time
|
|
938
|
+
*
|
|
939
|
+
* @param enable - true to enable adaptive feed, false to disable
|
|
940
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```typescript
|
|
944
|
+
* // Enable adaptive feed for force-sensitive machining
|
|
945
|
+
* await commandChannel.setAdaptiveFeedEnable(true);
|
|
946
|
+
* ```
|
|
947
|
+
*/
|
|
948
|
+
async setAdaptiveFeedEnable(enable) {
|
|
949
|
+
return this.exec(this.nativeInstance.setAdaptiveFeedEnable, enable);
|
|
950
|
+
}
|
|
951
|
+
// --- Joint Commands ---
|
|
952
|
+
/**
|
|
953
|
+
* Homes a specific joint by moving it to its home position
|
|
954
|
+
*
|
|
955
|
+
* @param jointIndex - Zero-based index of the joint to home, -1 to home all joints
|
|
956
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
957
|
+
*
|
|
958
|
+
* @example
|
|
959
|
+
* ```typescript
|
|
960
|
+
* // Home joint 0 (typically X-axis)
|
|
961
|
+
* await commandChannel.homeJoint(0);
|
|
962
|
+
*
|
|
963
|
+
* // Home joint 2 (typically Z-axis)
|
|
964
|
+
* await commandChannel.homeJoint(2);
|
|
965
|
+
*
|
|
966
|
+
* // Home all joints
|
|
967
|
+
* await commandChannel.homeJoint(-1);
|
|
968
|
+
* ```
|
|
969
|
+
*/
|
|
970
|
+
async homeJoint(jointIndex) {
|
|
971
|
+
return this.exec(this.nativeInstance.homeJoint, jointIndex);
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Unhomes a specific joint, clearing its homed status
|
|
975
|
+
*
|
|
976
|
+
* @param jointIndex - Zero-based index of the joint to unhome, -1 to unhome all joints
|
|
977
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
978
|
+
*
|
|
979
|
+
* @example
|
|
980
|
+
* ```typescript
|
|
981
|
+
* // Unhome joint 1 (typically Y-axis)
|
|
982
|
+
* await commandChannel.unhomeJoint(1);
|
|
983
|
+
*
|
|
984
|
+
* // Unhome all joints
|
|
985
|
+
* await commandChannel.unhomeJoint(-1);
|
|
986
|
+
* ```
|
|
987
|
+
*/
|
|
988
|
+
async unhomeJoint(jointIndex) {
|
|
989
|
+
return this.exec(this.nativeInstance.unhomeJoint, jointIndex);
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Stops jogging motion for a specific axis or joint
|
|
993
|
+
*
|
|
994
|
+
* @param axisOrJointIndex - Index of the axis (0=X,1=Y,2=Z...) or joint to stop
|
|
995
|
+
* @param isJointJog - true for joint jogging, false for axis jogging
|
|
996
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
997
|
+
*
|
|
998
|
+
* @example
|
|
999
|
+
* ```typescript
|
|
1000
|
+
* // Stop axis X jogging
|
|
1001
|
+
* await commandChannel.jogStop(0, false);
|
|
1002
|
+
*
|
|
1003
|
+
* // Stop joint 1 jogging
|
|
1004
|
+
* await commandChannel.jogStop(1, true);
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
1007
|
+
async jogStop(axisOrJointIndex, isJointJog) {
|
|
1008
|
+
return this.exec(this.nativeInstance.jogStop, axisOrJointIndex, isJointJog);
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Starts continuous jogging motion for a specific axis or joint
|
|
1012
|
+
*
|
|
1013
|
+
* @param axisOrJointIndex - Index of the axis (0=X,1=Y,2=Z...) or joint to jog
|
|
1014
|
+
* @param isJointJog - true for joint jogging, false for axis jogging
|
|
1015
|
+
* @param speed - Jogging speed in machine units per second
|
|
1016
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1017
|
+
*
|
|
1018
|
+
* @example
|
|
1019
|
+
* ```typescript
|
|
1020
|
+
* // Jog X axis continuously at 10 units/sec
|
|
1021
|
+
* await commandChannel.jogContinuous(0, false, 10);
|
|
1022
|
+
*
|
|
1023
|
+
* // Jog joint 2 continuously at -5 units/sec (negative direction)
|
|
1024
|
+
* await commandChannel.jogContinuous(2, true, -5);
|
|
1025
|
+
* ```
|
|
1026
|
+
*/
|
|
1027
|
+
async jogContinuous(axisOrJointIndex, isJointJog, speed) {
|
|
1028
|
+
return this.exec(this.nativeInstance.jogContinuous, axisOrJointIndex, isJointJog, speed);
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Jogs a specific distance at a given speed for an axis or joint
|
|
1032
|
+
*
|
|
1033
|
+
* @param axisOrJointIndex - Index of the axis (0=X,1=Y,2=Z...) or joint to jog
|
|
1034
|
+
* @param isJointJog - true for joint jogging, false for axis jogging
|
|
1035
|
+
* @param speed - Jogging speed in machine units per second
|
|
1036
|
+
* @param increment - Distance to jog in machine units
|
|
1037
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1038
|
+
*
|
|
1039
|
+
* @example
|
|
1040
|
+
* ```typescript
|
|
1041
|
+
* // Jog Y axis 1.0 unit at 5 units/sec
|
|
1042
|
+
* await commandChannel.jogIncrement(1, false, 5, 1.0);
|
|
1043
|
+
*
|
|
1044
|
+
* // Jog joint 0 back 0.1 units at 2 units/sec
|
|
1045
|
+
* await commandChannel.jogIncrement(0, true, 2, -0.1);
|
|
1046
|
+
* ```
|
|
1047
|
+
*/
|
|
1048
|
+
async jogIncrement(axisOrJointIndex, isJointJog, speed, increment) {
|
|
1049
|
+
return this.exec(this.nativeInstance.jogIncrement, axisOrJointIndex, isJointJog, speed, increment);
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Sets the minimum position limit for a joint
|
|
1053
|
+
*
|
|
1054
|
+
* @param jointIndex - Zero-based index of the joint
|
|
1055
|
+
* @param limit - Minimum position limit in machine units
|
|
1056
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```typescript
|
|
1060
|
+
* // Set minimum limit for joint 0 to -100 units
|
|
1061
|
+
* await commandChannel.setMinPositionLimit(0, -100);
|
|
1062
|
+
* ```
|
|
1063
|
+
*/
|
|
1064
|
+
async setMinPositionLimit(jointIndex, limit) {
|
|
1065
|
+
return this.exec(this.nativeInstance.setMinPositionLimit, jointIndex, limit);
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Sets the maximum position limit for a joint
|
|
1069
|
+
*
|
|
1070
|
+
* @param jointIndex - Zero-based index of the joint
|
|
1071
|
+
* @param limit - Maximum position limit in machine units
|
|
1072
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1073
|
+
*
|
|
1074
|
+
* @example
|
|
1075
|
+
* ```typescript
|
|
1076
|
+
* // Set maximum limit for joint 0 to 200 units
|
|
1077
|
+
* await commandChannel.setMaxPositionLimit(0, 200);
|
|
1078
|
+
* ```
|
|
1079
|
+
*/
|
|
1080
|
+
async setMaxPositionLimit(jointIndex, limit) {
|
|
1081
|
+
return this.exec(this.nativeInstance.setMaxPositionLimit, jointIndex, limit);
|
|
1082
|
+
}
|
|
1083
|
+
// --- Spindle Commands ---
|
|
1084
|
+
/**
|
|
1085
|
+
* Turns on the spindle at a specified speed
|
|
1086
|
+
*
|
|
1087
|
+
* @param speed - Spindle speed in RPM (positive = clockwise, negative = counterclockwise)
|
|
1088
|
+
* @param spindleIndex - Index of the spindle to control (default: 0)
|
|
1089
|
+
* @param waitForSpeed - Whether to wait for spindle to reach speed before continuing (default: true)
|
|
1090
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1091
|
+
*
|
|
1092
|
+
* @example
|
|
1093
|
+
* ```typescript
|
|
1094
|
+
* // Turn on spindle at 1000 RPM clockwise
|
|
1095
|
+
* await commandChannel.spindleOn(1000);
|
|
1096
|
+
*
|
|
1097
|
+
* // Turn on spindle 1 at 500 RPM counterclockwise
|
|
1098
|
+
* await commandChannel.spindleOn(-500, 1);
|
|
1099
|
+
*
|
|
1100
|
+
* // Start spindle without waiting for speed
|
|
1101
|
+
* await commandChannel.spindleOn(800, 0, false);
|
|
1102
|
+
* ```
|
|
1103
|
+
*/
|
|
1104
|
+
async spindleOn(speed, spindleIndex = 0, waitForSpeed = true) {
|
|
1105
|
+
return this.exec(this.nativeInstance.spindleOn, speed, spindleIndex, waitForSpeed);
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Increases spindle speed by a predefined increment
|
|
1109
|
+
* Spindle must already be running
|
|
1110
|
+
*
|
|
1111
|
+
* @param spindleIndex - Index of the spindle to control (default: 0)
|
|
1112
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1113
|
+
*
|
|
1114
|
+
* @example
|
|
1115
|
+
* ```typescript
|
|
1116
|
+
* // Increase speed of main spindle
|
|
1117
|
+
* await commandChannel.spindleIncrease();
|
|
1118
|
+
*
|
|
1119
|
+
* // Increase speed of spindle 1
|
|
1120
|
+
* await commandChannel.spindleIncrease(1);
|
|
1121
|
+
* ```
|
|
1122
|
+
*/
|
|
1123
|
+
async spindleIncrease(spindleIndex = 0) {
|
|
1124
|
+
return this.exec(this.nativeInstance.spindleIncrease, spindleIndex);
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Decreases spindle speed by a predefined increment
|
|
1128
|
+
* Spindle must already be running
|
|
1129
|
+
*
|
|
1130
|
+
* @param spindleIndex - Index of the spindle to control (default: 0)
|
|
1131
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1132
|
+
*
|
|
1133
|
+
* @example
|
|
1134
|
+
* ```typescript
|
|
1135
|
+
* // Decrease speed of main spindle
|
|
1136
|
+
* await commandChannel.spindleDecrease();
|
|
1137
|
+
*
|
|
1138
|
+
* // Decrease speed of spindle 1
|
|
1139
|
+
* await commandChannel.spindleDecrease(1);
|
|
1140
|
+
* ```
|
|
1141
|
+
*/
|
|
1142
|
+
async spindleDecrease(spindleIndex = 0) {
|
|
1143
|
+
return this.exec(this.nativeInstance.spindleDecrease, spindleIndex);
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Turns off the spindle
|
|
1147
|
+
*
|
|
1148
|
+
* @param spindleIndex - Index of the spindle to control (default: 0)
|
|
1149
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1150
|
+
*
|
|
1151
|
+
* @example
|
|
1152
|
+
* ```typescript
|
|
1153
|
+
* // Turn off main spindle
|
|
1154
|
+
* await commandChannel.spindleOff();
|
|
1155
|
+
*
|
|
1156
|
+
* // Turn off spindle 1
|
|
1157
|
+
* await commandChannel.spindleOff(1);
|
|
1158
|
+
* ```
|
|
1159
|
+
*/
|
|
1160
|
+
async spindleOff(spindleIndex = 0) {
|
|
1161
|
+
return this.exec(this.nativeInstance.spindleOff, spindleIndex);
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Engages or releases the spindle brake
|
|
1165
|
+
*
|
|
1166
|
+
* @param engage - true to engage brake, false to release brake
|
|
1167
|
+
* @param spindleIndex - Index of the spindle to control (default: 0)
|
|
1168
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1169
|
+
*
|
|
1170
|
+
* @example
|
|
1171
|
+
* ```typescript
|
|
1172
|
+
* // Engage spindle brake
|
|
1173
|
+
* await commandChannel.spindleBrake(true);
|
|
1174
|
+
*
|
|
1175
|
+
* // Release brake on spindle 1
|
|
1176
|
+
* await commandChannel.spindleBrake(false, 1);
|
|
1177
|
+
* ```
|
|
1178
|
+
*/
|
|
1179
|
+
async spindleBrake(engage, spindleIndex = 0) {
|
|
1180
|
+
return this.exec(this.nativeInstance.spindleBrake, engage, spindleIndex);
|
|
1181
|
+
}
|
|
1182
|
+
// --- Coolant Commands ---
|
|
1183
|
+
/**
|
|
1184
|
+
* Turns mist coolant on or off
|
|
1185
|
+
*
|
|
1186
|
+
* @param on - true to turn mist on, false to turn off
|
|
1187
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1188
|
+
*
|
|
1189
|
+
* @example
|
|
1190
|
+
* ```typescript
|
|
1191
|
+
* // Turn on mist coolant
|
|
1192
|
+
* await commandChannel.setMist(true);
|
|
1193
|
+
*
|
|
1194
|
+
* // Turn off mist coolant
|
|
1195
|
+
* await commandChannel.setMist(false);
|
|
1196
|
+
* ```
|
|
1197
|
+
*/
|
|
1198
|
+
async setMist(on) {
|
|
1199
|
+
return this.exec(this.nativeInstance.setMist, on);
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Turns flood coolant on or off
|
|
1203
|
+
*
|
|
1204
|
+
* @param on - true to turn flood on, false to turn off
|
|
1205
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1206
|
+
*
|
|
1207
|
+
* @example
|
|
1208
|
+
* ```typescript
|
|
1209
|
+
* // Turn on flood coolant
|
|
1210
|
+
* await commandChannel.setFlood(true);
|
|
1211
|
+
*
|
|
1212
|
+
* // Turn off flood coolant
|
|
1213
|
+
* await commandChannel.setFlood(false);
|
|
1214
|
+
* ```
|
|
1215
|
+
*/
|
|
1216
|
+
async setFlood(on) {
|
|
1217
|
+
return this.exec(this.nativeInstance.setFlood, on);
|
|
1218
|
+
}
|
|
1219
|
+
// --- Tool Commands ---
|
|
1220
|
+
/**
|
|
1221
|
+
* Reloads the tool table from disk
|
|
1222
|
+
* Updates the in-memory tool table with changes made to the tool table file
|
|
1223
|
+
*
|
|
1224
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1225
|
+
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* ```typescript
|
|
1228
|
+
* // Reload tool table after editing the .tbl file
|
|
1229
|
+
* await commandChannel.loadToolTable();
|
|
1230
|
+
* ```
|
|
1231
|
+
*/
|
|
1232
|
+
async loadToolTable() {
|
|
1233
|
+
return this.exec(this.nativeInstance.loadToolTable);
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Sets tool data for a specific tool number
|
|
1237
|
+
* Updates tool geometry and parameters in the tool table
|
|
1238
|
+
*
|
|
1239
|
+
* @param toolEntry - Tool entry containing tool number and optional geometry data
|
|
1240
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1241
|
+
*
|
|
1242
|
+
* @example
|
|
1243
|
+
* ```typescript
|
|
1244
|
+
* // Set basic tool data
|
|
1245
|
+
* await commandChannel.setTool({
|
|
1246
|
+
* toolNo: 3,
|
|
1247
|
+
* pocketNo: 3
|
|
1248
|
+
* });
|
|
1249
|
+
*
|
|
1250
|
+
* // Set tool with geometry data
|
|
1251
|
+
* await commandChannel.setTool({
|
|
1252
|
+
* toolNo: 1,
|
|
1253
|
+
* pocketNo: 1,
|
|
1254
|
+
* diameter: 6.35,
|
|
1255
|
+
* offset: {
|
|
1256
|
+
* x: 0,
|
|
1257
|
+
* y: 0,
|
|
1258
|
+
* z: 25.4
|
|
1259
|
+
* }
|
|
1260
|
+
* });
|
|
1261
|
+
* ```
|
|
1262
|
+
*/
|
|
1263
|
+
async setTool(toolEntry) {
|
|
1264
|
+
return this.exec(this.nativeInstance.setTool, toolEntry);
|
|
1265
|
+
}
|
|
1266
|
+
// --- IO Commands ---
|
|
1267
|
+
/**
|
|
1268
|
+
* Sets the state of a digital output pin
|
|
1269
|
+
*
|
|
1270
|
+
* @param index - Index of the digital output pin
|
|
1271
|
+
* @param value - true to set high, false to set low
|
|
1272
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1273
|
+
*
|
|
1274
|
+
* @example
|
|
1275
|
+
* ```typescript
|
|
1276
|
+
* // Set digital output 0 high
|
|
1277
|
+
* await commandChannel.setDigitalOutput(0, true);
|
|
1278
|
+
*
|
|
1279
|
+
* // Set digital output 3 low
|
|
1280
|
+
* await commandChannel.setDigitalOutput(3, false);
|
|
1281
|
+
* ```
|
|
1282
|
+
*/
|
|
1283
|
+
async setDigitalOutput(index, value) {
|
|
1284
|
+
return this.exec(this.nativeInstance.setDigitalOutput, index, value);
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Sets the value of an analog output pin
|
|
1288
|
+
*
|
|
1289
|
+
* @param index - Index of the analog output pin
|
|
1290
|
+
* @param value - Analog value to set
|
|
1291
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1292
|
+
*
|
|
1293
|
+
* @example
|
|
1294
|
+
* ```typescript
|
|
1295
|
+
* // Set analog output 0 to 13.3
|
|
1296
|
+
* await commandChannel.setAnalogOutput(0, 13.3);
|
|
1297
|
+
* ```
|
|
1298
|
+
*/
|
|
1299
|
+
async setAnalogOutput(index, value) {
|
|
1300
|
+
return this.exec(this.nativeInstance.setAnalogOutput, index, value);
|
|
1301
|
+
}
|
|
1302
|
+
// --- Debug & Message Commands ---
|
|
1303
|
+
/**
|
|
1304
|
+
* Sets debug flags for LinuxCNC components using OR-ed EmcDebug flags
|
|
1305
|
+
* Multiple debug categories can be enabled simultaneously by combining flags
|
|
1306
|
+
*
|
|
1307
|
+
* @param level - Debug flags from EmcDebug enum, can be OR-ed together
|
|
1308
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1309
|
+
*
|
|
1310
|
+
* @example
|
|
1311
|
+
* ```typescript
|
|
1312
|
+
* // Disable all debugging
|
|
1313
|
+
* await commandChannel.setDebugLevel(0);
|
|
1314
|
+
*
|
|
1315
|
+
* // Enable interpreter debugging only
|
|
1316
|
+
* await commandChannel.setDebugLevel(EmcDebug.INTERP);
|
|
1317
|
+
*
|
|
1318
|
+
* // Enable multiple debug categories
|
|
1319
|
+
* await commandChannel.setDebugLevel(EmcDebug.INTERP | EmcDebug.MOTION_TIME);
|
|
1320
|
+
*
|
|
1321
|
+
* // Enable task and NML debugging
|
|
1322
|
+
* await commandChannel.setDebugLevel(EmcDebug.TASK_ISSUE | EmcDebug.NML);
|
|
1323
|
+
*
|
|
1324
|
+
* // Enable Python and remap debugging for custom components
|
|
1325
|
+
* await commandChannel.setDebugLevel(EmcDebug.PYTHON | EmcDebug.REMAP);
|
|
1326
|
+
* ```
|
|
1327
|
+
*/
|
|
1328
|
+
async setDebugLevel(level) {
|
|
1329
|
+
return this.exec(this.nativeInstance.setDebugLevel, level);
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Sends an error message to the operator display
|
|
1333
|
+
*
|
|
1334
|
+
* @param message - Error message to display (max 254 characters)
|
|
1335
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1336
|
+
*
|
|
1337
|
+
* @example
|
|
1338
|
+
* ```typescript
|
|
1339
|
+
* // Send error message
|
|
1340
|
+
* await commandChannel.sendOperatorError('Tool change required');
|
|
1341
|
+
* ```
|
|
1342
|
+
*/
|
|
1343
|
+
async sendOperatorError(message) {
|
|
1344
|
+
return this.exec(this.nativeInstance.sendOperatorError, message);
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Sends a text message to the operator display
|
|
1348
|
+
*
|
|
1349
|
+
* @param message - Text message to display (max 254 characters)
|
|
1350
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1351
|
+
*
|
|
1352
|
+
* @example
|
|
1353
|
+
* ```typescript
|
|
1354
|
+
* // Send informational message
|
|
1355
|
+
* await commandChannel.sendOperatorText('Setup complete');
|
|
1356
|
+
* ```
|
|
1357
|
+
*/
|
|
1358
|
+
async sendOperatorText(message) {
|
|
1359
|
+
return this.exec(this.nativeInstance.sendOperatorText, message);
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Sends a display message to the operator
|
|
1363
|
+
*
|
|
1364
|
+
* @param message - Display message (max 254 characters)
|
|
1365
|
+
* @returns Promise resolving to RcsStatus indicating command completion
|
|
1366
|
+
*
|
|
1367
|
+
* @example
|
|
1368
|
+
* ```typescript
|
|
1369
|
+
* // Send display message
|
|
1370
|
+
* await commandChannel.sendOperatorDisplay('Insert tool T1 M6');
|
|
1371
|
+
* ```
|
|
1372
|
+
*/
|
|
1373
|
+
async sendOperatorDisplay(message) {
|
|
1374
|
+
return this.exec(this.nativeInstance.sendOperatorDisplay, message);
|
|
1375
|
+
}
|
|
1376
|
+
// --- Misc ---
|
|
1377
|
+
/**
|
|
1378
|
+
* Synchronously waits for the last command to complete
|
|
1379
|
+
* This does the same as await but provides a synchronous way to wait for command completion
|
|
1380
|
+
*
|
|
1381
|
+
* @param timeout - Maximum time to wait in seconds (default: 5 seconds)
|
|
1382
|
+
* @returns RcsStatus indicating completion status (RCS_DONE, RCS_ERROR, or -1 for timeout)
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* ```typescript
|
|
1386
|
+
* // These two approaches are equivalent:
|
|
1387
|
+
*
|
|
1388
|
+
* // Approach 1: Using await (asynchronous)
|
|
1389
|
+
* await commandChannel.runProgram();
|
|
1390
|
+
* console.log('Program completed');
|
|
1391
|
+
*
|
|
1392
|
+
* // Approach 2: Using waitComplete (synchronous)
|
|
1393
|
+
* commandChannel.runProgram(); // Fire and forget - don't await
|
|
1394
|
+
* const status = commandChannel.waitComplete(); // Synchronously wait for completion
|
|
1395
|
+
* if (status === RcsStatus.DONE) {
|
|
1396
|
+
* console.log('Program completed');
|
|
1397
|
+
* }
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
waitComplete(timeout) {
|
|
1401
|
+
if (!this.nativeInstance)
|
|
1402
|
+
throw new Error("CommandChannel native instance not available.");
|
|
1403
|
+
return this.nativeInstance.waitComplete(timeout);
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Gets the serial number of the current command
|
|
1407
|
+
* Each command sent has a unique serial number for tracking
|
|
1408
|
+
*
|
|
1409
|
+
* @returns The current command serial number
|
|
1410
|
+
*
|
|
1411
|
+
* @example
|
|
1412
|
+
* ```typescript
|
|
1413
|
+
* // Get current command serial number
|
|
1414
|
+
* const serial = commandChannel.getSerial();
|
|
1415
|
+
* console.log(`Current command serial: ${serial}`);
|
|
1416
|
+
* ```
|
|
1417
|
+
*/
|
|
1418
|
+
getSerial() {
|
|
1419
|
+
if (!this.nativeInstance)
|
|
1420
|
+
throw new Error("CommandChannel native instance not available.");
|
|
1421
|
+
return this.nativeInstance.serial;
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Destroys the command channel and cleans up resources
|
|
1425
|
+
* Call this when done using the command channel
|
|
1426
|
+
*/
|
|
1427
|
+
destroy() {
|
|
1428
|
+
if (this.nativeInstance) {
|
|
1429
|
+
this.nativeInstance.disconnect();
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
exports2.CommandChannel = CommandChannel2;
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
|
|
1437
|
+
// ../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/errorChannel.js
|
|
1438
|
+
var require_errorChannel = __commonJS({
|
|
1439
|
+
"../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/errorChannel.js"(exports2) {
|
|
1440
|
+
"use strict";
|
|
1441
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1442
|
+
exports2.ErrorChannel = exports2.DEFAULT_ERROR_POLL_INTERVAL = void 0;
|
|
1443
|
+
var events_1 = require("events");
|
|
1444
|
+
var constants_1 = require_constants();
|
|
1445
|
+
var types_1 = require_dist2();
|
|
1446
|
+
exports2.DEFAULT_ERROR_POLL_INTERVAL = 100;
|
|
1447
|
+
var ErrorChannel2 = class extends events_1.EventEmitter {
|
|
1448
|
+
constructor(options) {
|
|
1449
|
+
super();
|
|
1450
|
+
this.poller = null;
|
|
1451
|
+
this.isPolling = false;
|
|
1452
|
+
this.nativeInstance = new constants_1.addon.NativeErrorChannel();
|
|
1453
|
+
const pollInterval = options?.pollInterval ?? exports2.DEFAULT_ERROR_POLL_INTERVAL;
|
|
1454
|
+
this.poller = setInterval(() => this.poll(), pollInterval);
|
|
1455
|
+
}
|
|
1456
|
+
poll() {
|
|
1457
|
+
if (this.isPolling)
|
|
1458
|
+
return;
|
|
1459
|
+
this.isPolling = true;
|
|
1460
|
+
try {
|
|
1461
|
+
const error = this.nativeInstance.poll();
|
|
1462
|
+
if (error) {
|
|
1463
|
+
this.emit("message", error);
|
|
1464
|
+
switch (error.type) {
|
|
1465
|
+
case types_1.NmlMessageType.EMC_OPERATOR_ERROR:
|
|
1466
|
+
this.emit("operatorError", error);
|
|
1467
|
+
break;
|
|
1468
|
+
case types_1.NmlMessageType.EMC_OPERATOR_TEXT:
|
|
1469
|
+
this.emit("operatorText", error);
|
|
1470
|
+
break;
|
|
1471
|
+
case types_1.NmlMessageType.EMC_OPERATOR_DISPLAY:
|
|
1472
|
+
this.emit("operatorDisplay", error);
|
|
1473
|
+
break;
|
|
1474
|
+
case types_1.NmlMessageType.NML_ERROR:
|
|
1475
|
+
this.emit("nmlError", error);
|
|
1476
|
+
break;
|
|
1477
|
+
case types_1.NmlMessageType.NML_TEXT:
|
|
1478
|
+
this.emit("nmlText", error);
|
|
1479
|
+
break;
|
|
1480
|
+
case types_1.NmlMessageType.NML_DISPLAY:
|
|
1481
|
+
this.emit("nmlDisplay", error);
|
|
1482
|
+
break;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
} catch (e) {
|
|
1486
|
+
console.error("Error during ErrorChannel poll:", e);
|
|
1487
|
+
} finally {
|
|
1488
|
+
this.isPolling = false;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
destroy() {
|
|
1492
|
+
if (this.poller) {
|
|
1493
|
+
clearInterval(this.poller);
|
|
1494
|
+
this.poller = null;
|
|
1495
|
+
}
|
|
1496
|
+
this.removeAllListeners();
|
|
1497
|
+
this.nativeInstance.disconnect();
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
exports2.ErrorChannel = ErrorChannel2;
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
|
|
1504
|
+
// ../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/positionLogger.js
|
|
1505
|
+
var require_positionLogger = __commonJS({
|
|
1506
|
+
"../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/positionLogger.js"(exports2) {
|
|
1507
|
+
"use strict";
|
|
1508
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1509
|
+
exports2.PositionLogger = void 0;
|
|
1510
|
+
var constants_1 = require_constants();
|
|
1511
|
+
var PositionLogger2 = class {
|
|
1512
|
+
constructor() {
|
|
1513
|
+
this.nativeLogger = new constants_1.addon.NativePositionLogger();
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Start position logging
|
|
1517
|
+
* @param options Logging options
|
|
1518
|
+
*/
|
|
1519
|
+
start(options = {}) {
|
|
1520
|
+
const interval = options.interval || 0.01;
|
|
1521
|
+
const maxHistorySize = options.maxHistorySize || 1e4;
|
|
1522
|
+
this.nativeLogger.start(interval, maxHistorySize);
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* Stop position logging
|
|
1526
|
+
*/
|
|
1527
|
+
stop() {
|
|
1528
|
+
this.nativeLogger.stop();
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Clear the position history (invalidates all previous cursors)
|
|
1532
|
+
*/
|
|
1533
|
+
clear() {
|
|
1534
|
+
this.nativeLogger.clear();
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Get the current position as a Float64Array
|
|
1538
|
+
* Layout: [x, y, z, a, b, c, u, v, w, motionType]
|
|
1539
|
+
* @returns Float64Array with 10 values, or null if no position available
|
|
1540
|
+
*/
|
|
1541
|
+
getCurrentPosition() {
|
|
1542
|
+
return this.nativeLogger.getCurrentPosition();
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Get the motion history as a Float64Array
|
|
1546
|
+
* Layout: [x, y, z, a, b, c, u, v, w, motionType] repeated for each point
|
|
1547
|
+
* Use POSITION_STRIDE (10) to iterate through points
|
|
1548
|
+
* @param startIndex Starting index (default: 0)
|
|
1549
|
+
* @param count Number of points to retrieve (default: all)
|
|
1550
|
+
* @returns Float64Array with 10 values per point
|
|
1551
|
+
*/
|
|
1552
|
+
getMotionHistory(startIndex, count) {
|
|
1553
|
+
if (startIndex !== void 0 && count !== void 0) {
|
|
1554
|
+
return this.nativeLogger.getMotionHistory(startIndex, count);
|
|
1555
|
+
} else if (startIndex !== void 0) {
|
|
1556
|
+
return this.nativeLogger.getMotionHistory(startIndex);
|
|
1557
|
+
} else {
|
|
1558
|
+
return this.nativeLogger.getMotionHistory();
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Get the number of points in the motion history
|
|
1563
|
+
* @returns Number of logged points
|
|
1564
|
+
*/
|
|
1565
|
+
getHistoryCount() {
|
|
1566
|
+
return this.nativeLogger.getHistoryCount();
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Get the most recent points from the history
|
|
1570
|
+
* @param count Number of recent points to get (default: 10)
|
|
1571
|
+
* @returns Float64Array with 10 values per point
|
|
1572
|
+
*/
|
|
1573
|
+
getRecentHistory(count = 10) {
|
|
1574
|
+
const totalCount = this.getHistoryCount();
|
|
1575
|
+
if (totalCount === 0)
|
|
1576
|
+
return new Float64Array(0);
|
|
1577
|
+
const startIndex = Math.max(0, totalCount - count);
|
|
1578
|
+
const actualCount = Math.min(count, totalCount);
|
|
1579
|
+
return this.getMotionHistory(startIndex, actualCount);
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Get the current cursor position (monotonic counter of points ever added)
|
|
1583
|
+
* @returns Current cursor value
|
|
1584
|
+
*/
|
|
1585
|
+
getCurrentCursor() {
|
|
1586
|
+
return this.nativeLogger.getCurrentCursor();
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Get delta points since a given cursor position
|
|
1590
|
+
* Use this for efficient incremental updates instead of fetching full history.
|
|
1591
|
+
* @param cursor Last known cursor (0 for full history)
|
|
1592
|
+
* @returns Delta result with points, count, new cursor, and wasReset flag
|
|
1593
|
+
*/
|
|
1594
|
+
getDeltaSince(cursor2) {
|
|
1595
|
+
return this.nativeLogger.getDeltaSince(cursor2);
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
exports2.PositionLogger = PositionLogger2;
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1602
|
+
// ../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/index.js
|
|
1603
|
+
var require_dist3 = __commonJS({
|
|
1604
|
+
"../node_modules/.pnpm/@linuxcnc-node+core@2.1.3/node_modules/@linuxcnc-node/core/dist/index.js"(exports2) {
|
|
1605
|
+
"use strict";
|
|
1606
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1607
|
+
exports2.PositionLogger = exports2.ErrorChannel = exports2.CommandChannel = exports2.StatChannel = void 0;
|
|
1608
|
+
exports2.setNmlFilePath = setNmlFilePath;
|
|
1609
|
+
exports2.getNmlFilePath = getNmlFilePath;
|
|
1610
|
+
var statChannel_1 = require_statChannel();
|
|
1611
|
+
Object.defineProperty(exports2, "StatChannel", { enumerable: true, get: function() {
|
|
1612
|
+
return statChannel_1.StatChannel;
|
|
1613
|
+
} });
|
|
1614
|
+
var commandChannel_1 = require_commandChannel();
|
|
1615
|
+
Object.defineProperty(exports2, "CommandChannel", { enumerable: true, get: function() {
|
|
1616
|
+
return commandChannel_1.CommandChannel;
|
|
1617
|
+
} });
|
|
1618
|
+
var errorChannel_1 = require_errorChannel();
|
|
1619
|
+
Object.defineProperty(exports2, "ErrorChannel", { enumerable: true, get: function() {
|
|
1620
|
+
return errorChannel_1.ErrorChannel;
|
|
1621
|
+
} });
|
|
1622
|
+
var positionLogger_1 = require_positionLogger();
|
|
1623
|
+
Object.defineProperty(exports2, "PositionLogger", { enumerable: true, get: function() {
|
|
1624
|
+
return positionLogger_1.PositionLogger;
|
|
1625
|
+
} });
|
|
1626
|
+
var constants_1 = require_constants();
|
|
1627
|
+
var nmlFilePath = constants_1.addon.NMLFILE_DEFAULT;
|
|
1628
|
+
function setNmlFilePath(filePath) {
|
|
1629
|
+
constants_1.addon.setNmlFilePath(filePath);
|
|
1630
|
+
nmlFilePath = filePath;
|
|
1631
|
+
}
|
|
1632
|
+
function getNmlFilePath() {
|
|
1633
|
+
return constants_1.addon.getNmlFilePath();
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
|
|
1638
|
+
// ../node_modules/.pnpm/@linuxcnc-node+gcode@2.1.3/node_modules/@linuxcnc-node/gcode/dist/parser.js
|
|
1639
|
+
var require_parser = __commonJS({
|
|
1640
|
+
"../node_modules/.pnpm/@linuxcnc-node+gcode@2.1.3/node_modules/@linuxcnc-node/gcode/dist/parser.js"(exports2) {
|
|
1641
|
+
"use strict";
|
|
1642
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1643
|
+
exports2.parseGCode = parseGCode2;
|
|
1644
|
+
function loadAddon() {
|
|
1645
|
+
const paths = [
|
|
1646
|
+
"../build/Release/gcode_addon.node",
|
|
1647
|
+
// Installed in node_modules (path relative to dist/)
|
|
1648
|
+
"../../build/Release/gcode_addon.node"
|
|
1649
|
+
// Local development (path relative to src/ts/)
|
|
1650
|
+
];
|
|
1651
|
+
for (const path of paths) {
|
|
1652
|
+
try {
|
|
1653
|
+
return require(path);
|
|
1654
|
+
} catch {
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
throw new Error(`Failed to load gcode_addon.node. Tried paths:
|
|
1658
|
+
` + paths.map((p) => ` - ${p}`).join("\n"));
|
|
1659
|
+
}
|
|
1660
|
+
var addon = loadAddon();
|
|
1661
|
+
async function parseGCode2(filepath, options) {
|
|
1662
|
+
if (!options.iniPath) {
|
|
1663
|
+
throw new Error("iniPath is required in ParseOptions");
|
|
1664
|
+
}
|
|
1665
|
+
return new Promise((resolve, reject) => {
|
|
1666
|
+
const progressCallback = options.onProgress || ((_progress) => {
|
|
1667
|
+
});
|
|
1668
|
+
const progressUpdates = options.progressUpdates ?? 40;
|
|
1669
|
+
addon.parseGCode(filepath, options.iniPath, progressUpdates, progressCallback, (error, result) => {
|
|
1670
|
+
if (error) {
|
|
1671
|
+
reject(error);
|
|
1672
|
+
} else {
|
|
1673
|
+
resolve(result);
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1680
|
+
|
|
1681
|
+
// ../node_modules/.pnpm/@linuxcnc-node+gcode@2.1.3/node_modules/@linuxcnc-node/gcode/dist/index.js
|
|
1682
|
+
var require_dist4 = __commonJS({
|
|
1683
|
+
"../node_modules/.pnpm/@linuxcnc-node+gcode@2.1.3/node_modules/@linuxcnc-node/gcode/dist/index.js"(exports2) {
|
|
1684
|
+
"use strict";
|
|
1685
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1686
|
+
exports2.parseGCode = void 0;
|
|
1687
|
+
var parser_1 = require_parser();
|
|
1688
|
+
Object.defineProperty(exports2, "parseGCode", { enumerable: true, get: function() {
|
|
1689
|
+
return parser_1.parseGCode;
|
|
1690
|
+
} });
|
|
1691
|
+
}
|
|
1692
|
+
});
|
|
1693
|
+
|
|
1694
|
+
// ../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/constants.js
|
|
1695
|
+
var require_constants3 = __commonJS({
|
|
1696
|
+
"../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/constants.js"(exports2) {
|
|
1697
|
+
"use strict";
|
|
1698
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1699
|
+
exports2.RtapiMsgLevelFromValue = exports2.HalParamDirFromValue = exports2.HalPinDirFromValue = exports2.HalTypeFromValue = exports2.RtapiMsgLevelValue = exports2.HalParamDirValue = exports2.HalPinDirValue = exports2.HalTypeValue = exports2.halNative = void 0;
|
|
1700
|
+
function loadAddon() {
|
|
1701
|
+
const paths = [
|
|
1702
|
+
"../build/Release/hal_addon.node",
|
|
1703
|
+
"../../build/Release/hal_addon.node"
|
|
1704
|
+
];
|
|
1705
|
+
for (const path of paths) {
|
|
1706
|
+
try {
|
|
1707
|
+
return require(path);
|
|
1708
|
+
} catch {
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
throw new Error("Failed to load linuxcnc-node hal native addon. Please ensure it's built correctly and that LinuxCNC is in your PATH.");
|
|
1712
|
+
}
|
|
1713
|
+
exports2.halNative = loadAddon();
|
|
1714
|
+
exports2.HalTypeValue = {
|
|
1715
|
+
bit: 1,
|
|
1716
|
+
float: 2,
|
|
1717
|
+
s32: 3,
|
|
1718
|
+
u32: 4,
|
|
1719
|
+
s64: 6,
|
|
1720
|
+
u64: 7
|
|
1721
|
+
};
|
|
1722
|
+
exports2.HalPinDirValue = {
|
|
1723
|
+
in: 16,
|
|
1724
|
+
out: 32,
|
|
1725
|
+
io: 48
|
|
1726
|
+
};
|
|
1727
|
+
exports2.HalParamDirValue = {
|
|
1728
|
+
ro: 64,
|
|
1729
|
+
rw: 192
|
|
1730
|
+
};
|
|
1731
|
+
exports2.RtapiMsgLevelValue = {
|
|
1732
|
+
none: 0,
|
|
1733
|
+
err: 1,
|
|
1734
|
+
warn: 2,
|
|
1735
|
+
info: 3,
|
|
1736
|
+
dbg: 4,
|
|
1737
|
+
all: 5
|
|
1738
|
+
};
|
|
1739
|
+
function createReverseMap(map) {
|
|
1740
|
+
const reverse = {};
|
|
1741
|
+
for (const [key, value] of Object.entries(map)) {
|
|
1742
|
+
reverse[value] = key;
|
|
1743
|
+
}
|
|
1744
|
+
return reverse;
|
|
1745
|
+
}
|
|
1746
|
+
exports2.HalTypeFromValue = createReverseMap(exports2.HalTypeValue);
|
|
1747
|
+
exports2.HalPinDirFromValue = createReverseMap(exports2.HalPinDirValue);
|
|
1748
|
+
exports2.HalParamDirFromValue = createReverseMap(exports2.HalParamDirValue);
|
|
1749
|
+
exports2.RtapiMsgLevelFromValue = createReverseMap(exports2.RtapiMsgLevelValue);
|
|
1750
|
+
}
|
|
1751
|
+
});
|
|
1752
|
+
|
|
1753
|
+
// ../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/item.js
|
|
1754
|
+
var require_item = __commonJS({
|
|
1755
|
+
"../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/item.js"(exports2) {
|
|
1756
|
+
"use strict";
|
|
1757
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1758
|
+
exports2.Param = exports2.Pin = exports2.HalItem = void 0;
|
|
1759
|
+
var events_1 = require("events");
|
|
1760
|
+
var HalItem = class extends events_1.EventEmitter {
|
|
1761
|
+
constructor(component, nameSuffix, type, direction) {
|
|
1762
|
+
super();
|
|
1763
|
+
this.component = component;
|
|
1764
|
+
this.name = nameSuffix;
|
|
1765
|
+
this.type = type;
|
|
1766
|
+
this.direction = direction;
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Retrieves the current value of this item.
|
|
1770
|
+
*
|
|
1771
|
+
* @returns The item's value (number or boolean depending on type).
|
|
1772
|
+
*/
|
|
1773
|
+
getValue() {
|
|
1774
|
+
return this.component.getValue(this.name);
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Sets the value of this item.
|
|
1778
|
+
*
|
|
1779
|
+
* For pins, only applicable to `HAL_OUT` or `HAL_IO` pins.
|
|
1780
|
+
* For parameters, only applicable to `HAL_RW` parameters.
|
|
1781
|
+
*
|
|
1782
|
+
* @param value - The new value for the item.
|
|
1783
|
+
* @returns The value that was set.
|
|
1784
|
+
* @throws Error if trying to set an `HAL_IN` pin or `HAL_RO` parameter.
|
|
1785
|
+
*/
|
|
1786
|
+
setValue(value) {
|
|
1787
|
+
return this.component.setValue(this.name, value);
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
exports2.HalItem = HalItem;
|
|
1791
|
+
var Pin2 = class extends HalItem {
|
|
1792
|
+
};
|
|
1793
|
+
exports2.Pin = Pin2;
|
|
1794
|
+
var Param2 = class extends HalItem {
|
|
1795
|
+
};
|
|
1796
|
+
exports2.Param = Param2;
|
|
1797
|
+
}
|
|
1798
|
+
});
|
|
1799
|
+
|
|
1800
|
+
// ../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/component.js
|
|
1801
|
+
var require_component = __commonJS({
|
|
1802
|
+
"../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/component.js"(exports2) {
|
|
1803
|
+
"use strict";
|
|
1804
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1805
|
+
exports2.HalComponent = exports2.DEFAULT_POLL_INTERVAL = void 0;
|
|
1806
|
+
var events_1 = require("events");
|
|
1807
|
+
var constants_1 = require_constants3();
|
|
1808
|
+
var item_1 = require_item();
|
|
1809
|
+
exports2.DEFAULT_POLL_INTERVAL = 10;
|
|
1810
|
+
var HalComponent2 = class extends events_1.EventEmitter {
|
|
1811
|
+
/**
|
|
1812
|
+
* Creates a new HAL component.
|
|
1813
|
+
*
|
|
1814
|
+
* @param name - The name of the component (e.g., "my-component").
|
|
1815
|
+
* This will be registered with LinuxCNC HAL.
|
|
1816
|
+
* @param prefix - Optional prefix for pins and parameters created by this component.
|
|
1817
|
+
* If not provided, defaults to `name`.
|
|
1818
|
+
*/
|
|
1819
|
+
constructor(name, prefix) {
|
|
1820
|
+
super();
|
|
1821
|
+
this.pins = {};
|
|
1822
|
+
this.params = {};
|
|
1823
|
+
this.watchedItems = /* @__PURE__ */ new Map();
|
|
1824
|
+
this.monitoringTimer = null;
|
|
1825
|
+
this.monitoringOptions = {
|
|
1826
|
+
pollInterval: exports2.DEFAULT_POLL_INTERVAL
|
|
1827
|
+
};
|
|
1828
|
+
this.cursor = 0;
|
|
1829
|
+
this.nativeInstance = new constants_1.halNative.HalComponent(name, prefix);
|
|
1830
|
+
this.name = name;
|
|
1831
|
+
this.prefix = prefix || name;
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Checks if a HAL component with the given name exists in the system.
|
|
1835
|
+
*
|
|
1836
|
+
* @param name - The component name (e.g., "halui", "my-custom-comp").
|
|
1837
|
+
* @returns `true` if the component exists, `false` otherwise.
|
|
1838
|
+
*/
|
|
1839
|
+
static exists(name) {
|
|
1840
|
+
return constants_1.halNative.component_exists(name);
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Checks if the HAL component with the given name has been marked as ready.
|
|
1844
|
+
*
|
|
1845
|
+
* @param name - The component name.
|
|
1846
|
+
* @returns `true` if the component exists and is ready, `false` otherwise.
|
|
1847
|
+
*/
|
|
1848
|
+
static isReady(name) {
|
|
1849
|
+
return constants_1.halNative.component_is_ready(name);
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Gets the value of a pin or parameter by name.
|
|
1853
|
+
*
|
|
1854
|
+
* @param name - The nameSuffix of the pin or parameter.
|
|
1855
|
+
* @returns The current value.
|
|
1856
|
+
*/
|
|
1857
|
+
getValue(name) {
|
|
1858
|
+
return this.nativeInstance.getProperty(name);
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Sets the value of a pin or parameter by name.
|
|
1862
|
+
*
|
|
1863
|
+
* @param name - The nameSuffix of the pin or parameter.
|
|
1864
|
+
* @param value - The value to set.
|
|
1865
|
+
* @returns The value that was set.
|
|
1866
|
+
*/
|
|
1867
|
+
setValue(name, value) {
|
|
1868
|
+
if (typeof value !== "number" && typeof value !== "boolean") {
|
|
1869
|
+
throw new TypeError("Value must be a number or boolean");
|
|
1870
|
+
}
|
|
1871
|
+
return this.nativeInstance.setProperty(name, value);
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Creates a new HAL pin associated with this component.
|
|
1875
|
+
*
|
|
1876
|
+
* This method can only be called before `ready()` or after `unready()`.
|
|
1877
|
+
*
|
|
1878
|
+
* @param nameSuffix - The suffix for the pin name (e.g., "in1", "motor.0.pos").
|
|
1879
|
+
* The full HAL name will be `this.prefix + "." + nameSuffix`.
|
|
1880
|
+
* @param type - The data type of the pin (e.g., `"float"`, `"bit"`).
|
|
1881
|
+
* See {@link HalType} for available types.
|
|
1882
|
+
* @param direction - The direction of the pin (e.g., `"in"`, `"out"`, `"io"`).
|
|
1883
|
+
* See {@link HalPinDir} for available directions.
|
|
1884
|
+
* @returns A new `Pin` object instance.
|
|
1885
|
+
* @throws Error if component is ready or if pin creation fails.
|
|
1886
|
+
*/
|
|
1887
|
+
newPin(nameSuffix, type, direction) {
|
|
1888
|
+
const success = this.nativeInstance.newPin(nameSuffix, constants_1.HalTypeValue[type], constants_1.HalPinDirValue[direction]);
|
|
1889
|
+
if (!success) {
|
|
1890
|
+
console.error(`Failed to create pin '${nameSuffix}'`);
|
|
1891
|
+
}
|
|
1892
|
+
const pin = new item_1.Pin(this, nameSuffix, type, direction);
|
|
1893
|
+
this.pins[nameSuffix] = pin;
|
|
1894
|
+
this.setupItemListeners(pin, nameSuffix);
|
|
1895
|
+
return pin;
|
|
1896
|
+
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Creates a new HAL parameter associated with this component.
|
|
1899
|
+
*
|
|
1900
|
+
* This method can only be called before `ready()` or after `unready()`.
|
|
1901
|
+
*
|
|
1902
|
+
* @param nameSuffix - The suffix for the parameter name.
|
|
1903
|
+
* The full HAL name will be `this.prefix + "." + nameSuffix`.
|
|
1904
|
+
* @param type - The data type of the parameter. See {@link HalType} for available types.
|
|
1905
|
+
* @param direction - The writability of the parameter (`"ro"` for read-only,
|
|
1906
|
+
* `"rw"` for read-write). See {@link HalParamDir}.
|
|
1907
|
+
* @returns A new `Param` object instance.
|
|
1908
|
+
* @throws Error if component is ready or if parameter creation fails.
|
|
1909
|
+
*/
|
|
1910
|
+
newParam(nameSuffix, type, direction) {
|
|
1911
|
+
const success = this.nativeInstance.newParam(nameSuffix, constants_1.HalTypeValue[type], constants_1.HalParamDirValue[direction]);
|
|
1912
|
+
if (!success) {
|
|
1913
|
+
console.error(`Failed to create param '${nameSuffix}'`);
|
|
1914
|
+
}
|
|
1915
|
+
const param = new item_1.Param(this, nameSuffix, type, direction);
|
|
1916
|
+
this.params[nameSuffix] = param;
|
|
1917
|
+
this.setupItemListeners(param, nameSuffix);
|
|
1918
|
+
return param;
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Sets up auto-watch listeners for a pin or param.
|
|
1922
|
+
* @private
|
|
1923
|
+
*/
|
|
1924
|
+
setupItemListeners(item, name) {
|
|
1925
|
+
item.on("newListener", (event) => {
|
|
1926
|
+
if (event === "change" && !this.watchedItems.has(name)) {
|
|
1927
|
+
this.watchedItems.set(name, {
|
|
1928
|
+
item,
|
|
1929
|
+
lastValue: this.getValue(name)
|
|
1930
|
+
});
|
|
1931
|
+
this.ensureMonitoring();
|
|
1932
|
+
}
|
|
1933
|
+
});
|
|
1934
|
+
item.on("removeListener", (event) => {
|
|
1935
|
+
if (event === "change" && item.listenerCount("change") === 0) {
|
|
1936
|
+
this.watchedItems.delete(name);
|
|
1937
|
+
this.checkStopMonitoring();
|
|
1938
|
+
}
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Marks this component as ready and available to the HAL system.
|
|
1943
|
+
*
|
|
1944
|
+
* Once ready, pins can be linked, and parameters can be accessed by other
|
|
1945
|
+
* HAL components or tools. Pins and parameters cannot be added after `ready()`
|
|
1946
|
+
* is called, unless `unready()` is called first.
|
|
1947
|
+
*/
|
|
1948
|
+
ready() {
|
|
1949
|
+
this.nativeInstance.ready();
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Marks this component as not ready, allowing addition of more pins or parameters.
|
|
1953
|
+
*
|
|
1954
|
+
* `ready()` must be called again to make the component (and any new items)
|
|
1955
|
+
* available to HAL.
|
|
1956
|
+
*/
|
|
1957
|
+
unready() {
|
|
1958
|
+
this.nativeInstance.unready();
|
|
1959
|
+
}
|
|
1960
|
+
/**
|
|
1961
|
+
* Retrieves a map of all `Pin` objects created for this component.
|
|
1962
|
+
*
|
|
1963
|
+
* @returns An object where keys are the `nameSuffix` of the pins and values
|
|
1964
|
+
* are the corresponding `Pin` instances.
|
|
1965
|
+
*/
|
|
1966
|
+
getPins() {
|
|
1967
|
+
return this.pins;
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Retrieves a map of all `Param` objects created for this component.
|
|
1971
|
+
*
|
|
1972
|
+
* @returns An object where keys are the `nameSuffix` of the parameters and
|
|
1973
|
+
* values are the corresponding `Param` instances.
|
|
1974
|
+
*/
|
|
1975
|
+
getParams() {
|
|
1976
|
+
return this.params;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Gets a pin by name.
|
|
1980
|
+
*
|
|
1981
|
+
* @param name - The nameSuffix of the pin.
|
|
1982
|
+
* @returns The Pin instance, or undefined if not found.
|
|
1983
|
+
*/
|
|
1984
|
+
getPin(name) {
|
|
1985
|
+
return this.pins[name];
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* Gets a param by name.
|
|
1989
|
+
*
|
|
1990
|
+
* @param name - The nameSuffix of the param.
|
|
1991
|
+
* @returns The Param instance, or undefined if not found.
|
|
1992
|
+
*/
|
|
1993
|
+
getParam(name) {
|
|
1994
|
+
return this.params[name];
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Gets the current cursor value for sync operations.
|
|
1998
|
+
*
|
|
1999
|
+
* The cursor is monotonically increasing and increments with each delta emit.
|
|
2000
|
+
*
|
|
2001
|
+
* @returns The current cursor value.
|
|
2002
|
+
*/
|
|
2003
|
+
getCursor() {
|
|
2004
|
+
return this.cursor;
|
|
2005
|
+
}
|
|
2006
|
+
/**
|
|
2007
|
+
* Gets a snapshot of all current item values.
|
|
2008
|
+
*
|
|
2009
|
+
* Useful for initial sync or resync after cursor mismatch.
|
|
2010
|
+
*
|
|
2011
|
+
* @returns Object with items map, current cursor, and timestamp.
|
|
2012
|
+
*/
|
|
2013
|
+
getSnapshot() {
|
|
2014
|
+
const items = {};
|
|
2015
|
+
for (const [name] of this.watchedItems.entries()) {
|
|
2016
|
+
items[name] = this.getValue(name);
|
|
2017
|
+
}
|
|
2018
|
+
return {
|
|
2019
|
+
items,
|
|
2020
|
+
cursor: this.cursor,
|
|
2021
|
+
timestamp: Date.now()
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Configures the monitoring system settings.
|
|
2026
|
+
*
|
|
2027
|
+
* The monitoring system will check for value changes at the specified interval.
|
|
2028
|
+
*
|
|
2029
|
+
* @param options - Configuration object with `pollInterval` property (in milliseconds).
|
|
2030
|
+
* Default polling interval is 10ms.
|
|
2031
|
+
*/
|
|
2032
|
+
setMonitoringOptions(options) {
|
|
2033
|
+
this.monitoringOptions = { ...this.monitoringOptions, ...options };
|
|
2034
|
+
if (this.monitoringTimer && this.watchedItems.size > 0) {
|
|
2035
|
+
this.stopMonitoring();
|
|
2036
|
+
this.startMonitoring();
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Retrieves the current monitoring configuration.
|
|
2041
|
+
*
|
|
2042
|
+
* @returns A copy of the current monitoring options.
|
|
2043
|
+
*/
|
|
2044
|
+
getMonitoringOptions() {
|
|
2045
|
+
return { ...this.monitoringOptions };
|
|
2046
|
+
}
|
|
2047
|
+
/**
|
|
2048
|
+
* Starts the monitoring timer if not already running.
|
|
2049
|
+
* @private
|
|
2050
|
+
*/
|
|
2051
|
+
ensureMonitoring() {
|
|
2052
|
+
if (!this.monitoringTimer && this.watchedItems.size > 0) {
|
|
2053
|
+
this.startMonitoring();
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
/**
|
|
2057
|
+
* Stops monitoring if no items are being watched.
|
|
2058
|
+
* @private
|
|
2059
|
+
*/
|
|
2060
|
+
checkStopMonitoring() {
|
|
2061
|
+
if (this.watchedItems.size === 0) {
|
|
2062
|
+
this.stopMonitoring();
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* Starts the monitoring timer.
|
|
2067
|
+
* @private
|
|
2068
|
+
*/
|
|
2069
|
+
startMonitoring() {
|
|
2070
|
+
if (this.monitoringTimer) {
|
|
2071
|
+
return;
|
|
2072
|
+
}
|
|
2073
|
+
this.monitoringTimer = setInterval(() => {
|
|
2074
|
+
this.checkForChanges();
|
|
2075
|
+
}, this.monitoringOptions.pollInterval || exports2.DEFAULT_POLL_INTERVAL);
|
|
2076
|
+
}
|
|
2077
|
+
/**
|
|
2078
|
+
* Stops the monitoring timer.
|
|
2079
|
+
* @private
|
|
2080
|
+
*/
|
|
2081
|
+
stopMonitoring() {
|
|
2082
|
+
if (this.monitoringTimer) {
|
|
2083
|
+
clearInterval(this.monitoringTimer);
|
|
2084
|
+
this.monitoringTimer = null;
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
/**
|
|
2088
|
+
* Checks all watched items for value changes and emits events.
|
|
2089
|
+
*
|
|
2090
|
+
* Emits individual 'change' events on each HalItem, plus a batch 'delta'
|
|
2091
|
+
* event on the component with all changes aggregated.
|
|
2092
|
+
* @private
|
|
2093
|
+
*/
|
|
2094
|
+
checkForChanges() {
|
|
2095
|
+
const changes = [];
|
|
2096
|
+
for (const [name, watched] of this.watchedItems.entries()) {
|
|
2097
|
+
try {
|
|
2098
|
+
const currentValue = this.getValue(name);
|
|
2099
|
+
if (currentValue !== watched.lastValue) {
|
|
2100
|
+
const oldValue = watched.lastValue;
|
|
2101
|
+
watched.lastValue = currentValue;
|
|
2102
|
+
watched.item.emit("change", currentValue, oldValue);
|
|
2103
|
+
changes.push({ name, value: currentValue });
|
|
2104
|
+
}
|
|
2105
|
+
} catch (error) {
|
|
2106
|
+
console.error(`Error checking value for ${name}:`, error);
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
if (changes.length > 0) {
|
|
2110
|
+
this.cursor++;
|
|
2111
|
+
const delta = {
|
|
2112
|
+
changes,
|
|
2113
|
+
cursor: this.cursor,
|
|
2114
|
+
timestamp: Date.now()
|
|
2115
|
+
};
|
|
2116
|
+
this.emit("delta", delta);
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
/**
|
|
2120
|
+
* Cleans up the component, stops monitoring and removes all listeners.
|
|
2121
|
+
*
|
|
2122
|
+
* Should be called when the component is no longer needed to prevent memory leaks.
|
|
2123
|
+
*/
|
|
2124
|
+
dispose() {
|
|
2125
|
+
this.stopMonitoring();
|
|
2126
|
+
this.watchedItems.clear();
|
|
2127
|
+
for (const pin of Object.values(this.pins)) {
|
|
2128
|
+
pin.removeAllListeners();
|
|
2129
|
+
}
|
|
2130
|
+
for (const param of Object.values(this.params)) {
|
|
2131
|
+
param.removeAllListeners();
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
};
|
|
2135
|
+
exports2.HalComponent = HalComponent2;
|
|
2136
|
+
}
|
|
2137
|
+
});
|
|
2138
|
+
|
|
2139
|
+
// ../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/functions.js
|
|
2140
|
+
var require_functions = __commonJS({
|
|
2141
|
+
"../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/functions.js"(exports2) {
|
|
2142
|
+
"use strict";
|
|
2143
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2144
|
+
exports2.setSignalValue = exports2.setPinParamValue = exports2.pinHasWriter = exports2.newSignal = exports2.getInfoParams = exports2.getInfoSignals = exports2.getInfoPins = exports2.getValue = exports2.disconnect = exports2.connect = exports2.setMsgLevel = exports2.getMsgLevel = void 0;
|
|
2145
|
+
var constants_1 = require_constants3();
|
|
2146
|
+
var getMsgLevel2 = () => {
|
|
2147
|
+
const nativeValue = constants_1.halNative.get_msg_level();
|
|
2148
|
+
return constants_1.RtapiMsgLevelFromValue[nativeValue] ?? "none";
|
|
2149
|
+
};
|
|
2150
|
+
exports2.getMsgLevel = getMsgLevel2;
|
|
2151
|
+
var setMsgLevel2 = (level) => {
|
|
2152
|
+
constants_1.halNative.set_msg_level(constants_1.RtapiMsgLevelValue[level]);
|
|
2153
|
+
};
|
|
2154
|
+
exports2.setMsgLevel = setMsgLevel2;
|
|
2155
|
+
var connect = (pinName, signalName) => {
|
|
2156
|
+
return constants_1.halNative.connect(pinName, signalName);
|
|
2157
|
+
};
|
|
2158
|
+
exports2.connect = connect;
|
|
2159
|
+
var disconnect = (pinName) => {
|
|
2160
|
+
return constants_1.halNative.disconnect(pinName);
|
|
2161
|
+
};
|
|
2162
|
+
exports2.disconnect = disconnect;
|
|
2163
|
+
var getValue2 = (name) => {
|
|
2164
|
+
return constants_1.halNative.get_value(name);
|
|
2165
|
+
};
|
|
2166
|
+
exports2.getValue = getValue2;
|
|
2167
|
+
var getInfoPins2 = () => {
|
|
2168
|
+
const nativePins = constants_1.halNative.get_info_pins();
|
|
2169
|
+
return nativePins.map((pin) => ({
|
|
2170
|
+
...pin,
|
|
2171
|
+
type: constants_1.HalTypeFromValue[pin.type] ?? "bit",
|
|
2172
|
+
direction: constants_1.HalPinDirFromValue[pin.direction] ?? "in"
|
|
2173
|
+
}));
|
|
2174
|
+
};
|
|
2175
|
+
exports2.getInfoPins = getInfoPins2;
|
|
2176
|
+
var getInfoSignals2 = () => {
|
|
2177
|
+
const nativeSignals = constants_1.halNative.get_info_signals();
|
|
2178
|
+
return nativeSignals.map((signal) => ({
|
|
2179
|
+
...signal,
|
|
2180
|
+
type: constants_1.HalTypeFromValue[signal.type] ?? "bit"
|
|
2181
|
+
}));
|
|
2182
|
+
};
|
|
2183
|
+
exports2.getInfoSignals = getInfoSignals2;
|
|
2184
|
+
var getInfoParams2 = () => {
|
|
2185
|
+
const nativeParams = constants_1.halNative.get_info_params();
|
|
2186
|
+
return nativeParams.map((param) => ({
|
|
2187
|
+
...param,
|
|
2188
|
+
type: constants_1.HalTypeFromValue[param.type] ?? "bit",
|
|
2189
|
+
direction: constants_1.HalParamDirFromValue[param.direction] ?? "ro"
|
|
2190
|
+
}));
|
|
2191
|
+
};
|
|
2192
|
+
exports2.getInfoParams = getInfoParams2;
|
|
2193
|
+
var newSignal2 = (signalName, type) => {
|
|
2194
|
+
return constants_1.halNative.new_sig(signalName, constants_1.HalTypeValue[type]);
|
|
2195
|
+
};
|
|
2196
|
+
exports2.newSignal = newSignal2;
|
|
2197
|
+
var pinHasWriter2 = (pinName) => {
|
|
2198
|
+
return constants_1.halNative.pin_has_writer(pinName);
|
|
2199
|
+
};
|
|
2200
|
+
exports2.pinHasWriter = pinHasWriter2;
|
|
2201
|
+
var setPinParamValue = (name, value) => {
|
|
2202
|
+
return constants_1.halNative.set_p(name, String(value));
|
|
2203
|
+
};
|
|
2204
|
+
exports2.setPinParamValue = setPinParamValue;
|
|
2205
|
+
var setSignalValue2 = (name, value) => {
|
|
2206
|
+
return constants_1.halNative.set_s(name, String(value));
|
|
2207
|
+
};
|
|
2208
|
+
exports2.setSignalValue = setSignalValue2;
|
|
2209
|
+
}
|
|
2210
|
+
});
|
|
2211
|
+
|
|
2212
|
+
// ../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/index.js
|
|
2213
|
+
var require_dist5 = __commonJS({
|
|
2214
|
+
"../node_modules/.pnpm/@linuxcnc-node+hal@2.1.3/node_modules/@linuxcnc-node/hal/dist/index.js"(exports2) {
|
|
2215
|
+
"use strict";
|
|
2216
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2217
|
+
exports2.setSignalValue = exports2.setPinParamValue = exports2.pinHasWriter = exports2.newSignal = exports2.getInfoParams = exports2.getInfoSignals = exports2.getInfoPins = exports2.getValue = exports2.disconnect = exports2.connect = exports2.setMsgLevel = exports2.getMsgLevel = exports2.Param = exports2.Pin = exports2.HalItem = exports2.HalComponent = void 0;
|
|
2218
|
+
var component_1 = require_component();
|
|
2219
|
+
Object.defineProperty(exports2, "HalComponent", { enumerable: true, get: function() {
|
|
2220
|
+
return component_1.HalComponent;
|
|
2221
|
+
} });
|
|
2222
|
+
var item_1 = require_item();
|
|
2223
|
+
Object.defineProperty(exports2, "HalItem", { enumerable: true, get: function() {
|
|
2224
|
+
return item_1.HalItem;
|
|
2225
|
+
} });
|
|
2226
|
+
Object.defineProperty(exports2, "Pin", { enumerable: true, get: function() {
|
|
2227
|
+
return item_1.Pin;
|
|
2228
|
+
} });
|
|
2229
|
+
Object.defineProperty(exports2, "Param", { enumerable: true, get: function() {
|
|
2230
|
+
return item_1.Param;
|
|
2231
|
+
} });
|
|
2232
|
+
var functions_1 = require_functions();
|
|
2233
|
+
Object.defineProperty(exports2, "getMsgLevel", { enumerable: true, get: function() {
|
|
2234
|
+
return functions_1.getMsgLevel;
|
|
2235
|
+
} });
|
|
2236
|
+
Object.defineProperty(exports2, "setMsgLevel", { enumerable: true, get: function() {
|
|
2237
|
+
return functions_1.setMsgLevel;
|
|
2238
|
+
} });
|
|
2239
|
+
Object.defineProperty(exports2, "connect", { enumerable: true, get: function() {
|
|
2240
|
+
return functions_1.connect;
|
|
2241
|
+
} });
|
|
2242
|
+
Object.defineProperty(exports2, "disconnect", { enumerable: true, get: function() {
|
|
2243
|
+
return functions_1.disconnect;
|
|
2244
|
+
} });
|
|
2245
|
+
Object.defineProperty(exports2, "getValue", { enumerable: true, get: function() {
|
|
2246
|
+
return functions_1.getValue;
|
|
2247
|
+
} });
|
|
2248
|
+
Object.defineProperty(exports2, "getInfoPins", { enumerable: true, get: function() {
|
|
2249
|
+
return functions_1.getInfoPins;
|
|
2250
|
+
} });
|
|
2251
|
+
Object.defineProperty(exports2, "getInfoSignals", { enumerable: true, get: function() {
|
|
2252
|
+
return functions_1.getInfoSignals;
|
|
2253
|
+
} });
|
|
2254
|
+
Object.defineProperty(exports2, "getInfoParams", { enumerable: true, get: function() {
|
|
2255
|
+
return functions_1.getInfoParams;
|
|
2256
|
+
} });
|
|
2257
|
+
Object.defineProperty(exports2, "newSignal", { enumerable: true, get: function() {
|
|
2258
|
+
return functions_1.newSignal;
|
|
2259
|
+
} });
|
|
2260
|
+
Object.defineProperty(exports2, "pinHasWriter", { enumerable: true, get: function() {
|
|
2261
|
+
return functions_1.pinHasWriter;
|
|
2262
|
+
} });
|
|
2263
|
+
Object.defineProperty(exports2, "setPinParamValue", { enumerable: true, get: function() {
|
|
2264
|
+
return functions_1.setPinParamValue;
|
|
2265
|
+
} });
|
|
2266
|
+
Object.defineProperty(exports2, "setSignalValue", { enumerable: true, get: function() {
|
|
2267
|
+
return functions_1.setSignalValue;
|
|
2268
|
+
} });
|
|
2269
|
+
}
|
|
2270
|
+
});
|
|
2271
|
+
|
|
2272
|
+
// ../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
|
|
2273
|
+
var require_constants4 = __commonJS({
|
|
2274
|
+
"../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js"(exports2, module2) {
|
|
2275
|
+
"use strict";
|
|
2276
|
+
var WIN_SLASH = "\\\\/";
|
|
2277
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
2278
|
+
var DOT_LITERAL = "\\.";
|
|
2279
|
+
var PLUS_LITERAL = "\\+";
|
|
2280
|
+
var QMARK_LITERAL = "\\?";
|
|
2281
|
+
var SLASH_LITERAL = "\\/";
|
|
2282
|
+
var ONE_CHAR = "(?=.)";
|
|
2283
|
+
var QMARK = "[^/]";
|
|
2284
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
2285
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
2286
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
2287
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
2288
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
2289
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
2290
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
2291
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
2292
|
+
var STAR = `${QMARK}*?`;
|
|
2293
|
+
var SEP = "/";
|
|
2294
|
+
var POSIX_CHARS = {
|
|
2295
|
+
DOT_LITERAL,
|
|
2296
|
+
PLUS_LITERAL,
|
|
2297
|
+
QMARK_LITERAL,
|
|
2298
|
+
SLASH_LITERAL,
|
|
2299
|
+
ONE_CHAR,
|
|
2300
|
+
QMARK,
|
|
2301
|
+
END_ANCHOR,
|
|
2302
|
+
DOTS_SLASH,
|
|
2303
|
+
NO_DOT,
|
|
2304
|
+
NO_DOTS,
|
|
2305
|
+
NO_DOT_SLASH,
|
|
2306
|
+
NO_DOTS_SLASH,
|
|
2307
|
+
QMARK_NO_DOT,
|
|
2308
|
+
STAR,
|
|
2309
|
+
START_ANCHOR,
|
|
2310
|
+
SEP
|
|
2311
|
+
};
|
|
2312
|
+
var WINDOWS_CHARS = {
|
|
2313
|
+
...POSIX_CHARS,
|
|
2314
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
2315
|
+
QMARK: WIN_NO_SLASH,
|
|
2316
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
2317
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
2318
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
2319
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
2320
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
2321
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
2322
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
2323
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
2324
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
2325
|
+
SEP: "\\"
|
|
2326
|
+
};
|
|
2327
|
+
var POSIX_REGEX_SOURCE = {
|
|
2328
|
+
alnum: "a-zA-Z0-9",
|
|
2329
|
+
alpha: "a-zA-Z",
|
|
2330
|
+
ascii: "\\x00-\\x7F",
|
|
2331
|
+
blank: " \\t",
|
|
2332
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
2333
|
+
digit: "0-9",
|
|
2334
|
+
graph: "\\x21-\\x7E",
|
|
2335
|
+
lower: "a-z",
|
|
2336
|
+
print: "\\x20-\\x7E ",
|
|
2337
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
2338
|
+
space: " \\t\\r\\n\\v\\f",
|
|
2339
|
+
upper: "A-Z",
|
|
2340
|
+
word: "A-Za-z0-9_",
|
|
2341
|
+
xdigit: "A-Fa-f0-9"
|
|
2342
|
+
};
|
|
2343
|
+
module2.exports = {
|
|
2344
|
+
MAX_LENGTH: 1024 * 64,
|
|
2345
|
+
POSIX_REGEX_SOURCE,
|
|
2346
|
+
// regular expressions
|
|
2347
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
2348
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
2349
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
2350
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
2351
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
2352
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
2353
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
2354
|
+
REPLACEMENTS: {
|
|
2355
|
+
__proto__: null,
|
|
2356
|
+
"***": "*",
|
|
2357
|
+
"**/**": "**",
|
|
2358
|
+
"**/**/**": "**"
|
|
2359
|
+
},
|
|
2360
|
+
// Digits
|
|
2361
|
+
CHAR_0: 48,
|
|
2362
|
+
/* 0 */
|
|
2363
|
+
CHAR_9: 57,
|
|
2364
|
+
/* 9 */
|
|
2365
|
+
// Alphabet chars.
|
|
2366
|
+
CHAR_UPPERCASE_A: 65,
|
|
2367
|
+
/* A */
|
|
2368
|
+
CHAR_LOWERCASE_A: 97,
|
|
2369
|
+
/* a */
|
|
2370
|
+
CHAR_UPPERCASE_Z: 90,
|
|
2371
|
+
/* Z */
|
|
2372
|
+
CHAR_LOWERCASE_Z: 122,
|
|
2373
|
+
/* z */
|
|
2374
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
2375
|
+
/* ( */
|
|
2376
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
2377
|
+
/* ) */
|
|
2378
|
+
CHAR_ASTERISK: 42,
|
|
2379
|
+
/* * */
|
|
2380
|
+
// Non-alphabetic chars.
|
|
2381
|
+
CHAR_AMPERSAND: 38,
|
|
2382
|
+
/* & */
|
|
2383
|
+
CHAR_AT: 64,
|
|
2384
|
+
/* @ */
|
|
2385
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
2386
|
+
/* \ */
|
|
2387
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
2388
|
+
/* \r */
|
|
2389
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
2390
|
+
/* ^ */
|
|
2391
|
+
CHAR_COLON: 58,
|
|
2392
|
+
/* : */
|
|
2393
|
+
CHAR_COMMA: 44,
|
|
2394
|
+
/* , */
|
|
2395
|
+
CHAR_DOT: 46,
|
|
2396
|
+
/* . */
|
|
2397
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
2398
|
+
/* " */
|
|
2399
|
+
CHAR_EQUAL: 61,
|
|
2400
|
+
/* = */
|
|
2401
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
2402
|
+
/* ! */
|
|
2403
|
+
CHAR_FORM_FEED: 12,
|
|
2404
|
+
/* \f */
|
|
2405
|
+
CHAR_FORWARD_SLASH: 47,
|
|
2406
|
+
/* / */
|
|
2407
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
2408
|
+
/* ` */
|
|
2409
|
+
CHAR_HASH: 35,
|
|
2410
|
+
/* # */
|
|
2411
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
2412
|
+
/* - */
|
|
2413
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
2414
|
+
/* < */
|
|
2415
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
2416
|
+
/* { */
|
|
2417
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
2418
|
+
/* [ */
|
|
2419
|
+
CHAR_LINE_FEED: 10,
|
|
2420
|
+
/* \n */
|
|
2421
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
2422
|
+
/* \u00A0 */
|
|
2423
|
+
CHAR_PERCENT: 37,
|
|
2424
|
+
/* % */
|
|
2425
|
+
CHAR_PLUS: 43,
|
|
2426
|
+
/* + */
|
|
2427
|
+
CHAR_QUESTION_MARK: 63,
|
|
2428
|
+
/* ? */
|
|
2429
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
2430
|
+
/* > */
|
|
2431
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
2432
|
+
/* } */
|
|
2433
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
2434
|
+
/* ] */
|
|
2435
|
+
CHAR_SEMICOLON: 59,
|
|
2436
|
+
/* ; */
|
|
2437
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
2438
|
+
/* ' */
|
|
2439
|
+
CHAR_SPACE: 32,
|
|
2440
|
+
/* */
|
|
2441
|
+
CHAR_TAB: 9,
|
|
2442
|
+
/* \t */
|
|
2443
|
+
CHAR_UNDERSCORE: 95,
|
|
2444
|
+
/* _ */
|
|
2445
|
+
CHAR_VERTICAL_LINE: 124,
|
|
2446
|
+
/* | */
|
|
2447
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
2448
|
+
/* \uFEFF */
|
|
2449
|
+
/**
|
|
2450
|
+
* Create EXTGLOB_CHARS
|
|
2451
|
+
*/
|
|
2452
|
+
extglobChars(chars) {
|
|
2453
|
+
return {
|
|
2454
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
2455
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
2456
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
2457
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
2458
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
2459
|
+
};
|
|
2460
|
+
},
|
|
2461
|
+
/**
|
|
2462
|
+
* Create GLOB_CHARS
|
|
2463
|
+
*/
|
|
2464
|
+
globChars(win32) {
|
|
2465
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
2466
|
+
}
|
|
2467
|
+
};
|
|
2468
|
+
}
|
|
2469
|
+
});
|
|
2470
|
+
|
|
2471
|
+
// ../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
|
|
2472
|
+
var require_utils = __commonJS({
|
|
2473
|
+
"../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js"(exports2) {
|
|
2474
|
+
"use strict";
|
|
2475
|
+
var {
|
|
2476
|
+
REGEX_BACKSLASH,
|
|
2477
|
+
REGEX_REMOVE_BACKSLASH,
|
|
2478
|
+
REGEX_SPECIAL_CHARS,
|
|
2479
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
2480
|
+
} = require_constants4();
|
|
2481
|
+
exports2.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
2482
|
+
exports2.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
2483
|
+
exports2.isRegexChar = (str) => str.length === 1 && exports2.hasRegexChars(str);
|
|
2484
|
+
exports2.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
2485
|
+
exports2.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
2486
|
+
exports2.isWindows = () => {
|
|
2487
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
2488
|
+
const platform = navigator.platform.toLowerCase();
|
|
2489
|
+
return platform === "win32" || platform === "windows";
|
|
2490
|
+
}
|
|
2491
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
2492
|
+
return process.platform === "win32";
|
|
2493
|
+
}
|
|
2494
|
+
return false;
|
|
2495
|
+
};
|
|
2496
|
+
exports2.removeBackslashes = (str) => {
|
|
2497
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
2498
|
+
return match === "\\" ? "" : match;
|
|
2499
|
+
});
|
|
2500
|
+
};
|
|
2501
|
+
exports2.escapeLast = (input, char, lastIdx) => {
|
|
2502
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
2503
|
+
if (idx === -1) return input;
|
|
2504
|
+
if (input[idx - 1] === "\\") return exports2.escapeLast(input, char, idx - 1);
|
|
2505
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
2506
|
+
};
|
|
2507
|
+
exports2.removePrefix = (input, state = {}) => {
|
|
2508
|
+
let output = input;
|
|
2509
|
+
if (output.startsWith("./")) {
|
|
2510
|
+
output = output.slice(2);
|
|
2511
|
+
state.prefix = "./";
|
|
2512
|
+
}
|
|
2513
|
+
return output;
|
|
2514
|
+
};
|
|
2515
|
+
exports2.wrapOutput = (input, state = {}, options = {}) => {
|
|
2516
|
+
const prepend = options.contains ? "" : "^";
|
|
2517
|
+
const append = options.contains ? "" : "$";
|
|
2518
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
2519
|
+
if (state.negated === true) {
|
|
2520
|
+
output = `(?:^(?!${output}).*$)`;
|
|
2521
|
+
}
|
|
2522
|
+
return output;
|
|
2523
|
+
};
|
|
2524
|
+
exports2.basename = (path, { windows } = {}) => {
|
|
2525
|
+
const segs = path.split(windows ? /[\\/]/ : "/");
|
|
2526
|
+
const last = segs[segs.length - 1];
|
|
2527
|
+
if (last === "") {
|
|
2528
|
+
return segs[segs.length - 2];
|
|
2529
|
+
}
|
|
2530
|
+
return last;
|
|
2531
|
+
};
|
|
2532
|
+
}
|
|
2533
|
+
});
|
|
2534
|
+
|
|
2535
|
+
// ../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
|
|
2536
|
+
var require_scan = __commonJS({
|
|
2537
|
+
"../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js"(exports2, module2) {
|
|
2538
|
+
"use strict";
|
|
2539
|
+
var utils = require_utils();
|
|
2540
|
+
var {
|
|
2541
|
+
CHAR_ASTERISK,
|
|
2542
|
+
/* * */
|
|
2543
|
+
CHAR_AT,
|
|
2544
|
+
/* @ */
|
|
2545
|
+
CHAR_BACKWARD_SLASH,
|
|
2546
|
+
/* \ */
|
|
2547
|
+
CHAR_COMMA,
|
|
2548
|
+
/* , */
|
|
2549
|
+
CHAR_DOT,
|
|
2550
|
+
/* . */
|
|
2551
|
+
CHAR_EXCLAMATION_MARK,
|
|
2552
|
+
/* ! */
|
|
2553
|
+
CHAR_FORWARD_SLASH,
|
|
2554
|
+
/* / */
|
|
2555
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
2556
|
+
/* { */
|
|
2557
|
+
CHAR_LEFT_PARENTHESES,
|
|
2558
|
+
/* ( */
|
|
2559
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
2560
|
+
/* [ */
|
|
2561
|
+
CHAR_PLUS,
|
|
2562
|
+
/* + */
|
|
2563
|
+
CHAR_QUESTION_MARK,
|
|
2564
|
+
/* ? */
|
|
2565
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
2566
|
+
/* } */
|
|
2567
|
+
CHAR_RIGHT_PARENTHESES,
|
|
2568
|
+
/* ) */
|
|
2569
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
2570
|
+
/* ] */
|
|
2571
|
+
} = require_constants4();
|
|
2572
|
+
var isPathSeparator = (code) => {
|
|
2573
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
2574
|
+
};
|
|
2575
|
+
var depth = (token) => {
|
|
2576
|
+
if (token.isPrefix !== true) {
|
|
2577
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
var scan = (input, options) => {
|
|
2581
|
+
const opts = options || {};
|
|
2582
|
+
const length = input.length - 1;
|
|
2583
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
2584
|
+
const slashes = [];
|
|
2585
|
+
const tokens = [];
|
|
2586
|
+
const parts = [];
|
|
2587
|
+
let str = input;
|
|
2588
|
+
let index = -1;
|
|
2589
|
+
let start = 0;
|
|
2590
|
+
let lastIndex = 0;
|
|
2591
|
+
let isBrace = false;
|
|
2592
|
+
let isBracket = false;
|
|
2593
|
+
let isGlob = false;
|
|
2594
|
+
let isExtglob = false;
|
|
2595
|
+
let isGlobstar = false;
|
|
2596
|
+
let braceEscaped = false;
|
|
2597
|
+
let backslashes = false;
|
|
2598
|
+
let negated = false;
|
|
2599
|
+
let negatedExtglob = false;
|
|
2600
|
+
let finished = false;
|
|
2601
|
+
let braces = 0;
|
|
2602
|
+
let prev;
|
|
2603
|
+
let code;
|
|
2604
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
2605
|
+
const eos = () => index >= length;
|
|
2606
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
2607
|
+
const advance = () => {
|
|
2608
|
+
prev = code;
|
|
2609
|
+
return str.charCodeAt(++index);
|
|
2610
|
+
};
|
|
2611
|
+
while (index < length) {
|
|
2612
|
+
code = advance();
|
|
2613
|
+
let next;
|
|
2614
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
2615
|
+
backslashes = token.backslashes = true;
|
|
2616
|
+
code = advance();
|
|
2617
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
2618
|
+
braceEscaped = true;
|
|
2619
|
+
}
|
|
2620
|
+
continue;
|
|
2621
|
+
}
|
|
2622
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
2623
|
+
braces++;
|
|
2624
|
+
while (eos() !== true && (code = advance())) {
|
|
2625
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
2626
|
+
backslashes = token.backslashes = true;
|
|
2627
|
+
advance();
|
|
2628
|
+
continue;
|
|
2629
|
+
}
|
|
2630
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
2631
|
+
braces++;
|
|
2632
|
+
continue;
|
|
2633
|
+
}
|
|
2634
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
2635
|
+
isBrace = token.isBrace = true;
|
|
2636
|
+
isGlob = token.isGlob = true;
|
|
2637
|
+
finished = true;
|
|
2638
|
+
if (scanToEnd === true) {
|
|
2639
|
+
continue;
|
|
2640
|
+
}
|
|
2641
|
+
break;
|
|
2642
|
+
}
|
|
2643
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
2644
|
+
isBrace = token.isBrace = true;
|
|
2645
|
+
isGlob = token.isGlob = true;
|
|
2646
|
+
finished = true;
|
|
2647
|
+
if (scanToEnd === true) {
|
|
2648
|
+
continue;
|
|
2649
|
+
}
|
|
2650
|
+
break;
|
|
2651
|
+
}
|
|
2652
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
2653
|
+
braces--;
|
|
2654
|
+
if (braces === 0) {
|
|
2655
|
+
braceEscaped = false;
|
|
2656
|
+
isBrace = token.isBrace = true;
|
|
2657
|
+
finished = true;
|
|
2658
|
+
break;
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
if (scanToEnd === true) {
|
|
2663
|
+
continue;
|
|
2664
|
+
}
|
|
2665
|
+
break;
|
|
2666
|
+
}
|
|
2667
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
2668
|
+
slashes.push(index);
|
|
2669
|
+
tokens.push(token);
|
|
2670
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
2671
|
+
if (finished === true) continue;
|
|
2672
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
2673
|
+
start += 2;
|
|
2674
|
+
continue;
|
|
2675
|
+
}
|
|
2676
|
+
lastIndex = index + 1;
|
|
2677
|
+
continue;
|
|
2678
|
+
}
|
|
2679
|
+
if (opts.noext !== true) {
|
|
2680
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
2681
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
2682
|
+
isGlob = token.isGlob = true;
|
|
2683
|
+
isExtglob = token.isExtglob = true;
|
|
2684
|
+
finished = true;
|
|
2685
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
2686
|
+
negatedExtglob = true;
|
|
2687
|
+
}
|
|
2688
|
+
if (scanToEnd === true) {
|
|
2689
|
+
while (eos() !== true && (code = advance())) {
|
|
2690
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
2691
|
+
backslashes = token.backslashes = true;
|
|
2692
|
+
code = advance();
|
|
2693
|
+
continue;
|
|
2694
|
+
}
|
|
2695
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
2696
|
+
isGlob = token.isGlob = true;
|
|
2697
|
+
finished = true;
|
|
2698
|
+
break;
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
continue;
|
|
2702
|
+
}
|
|
2703
|
+
break;
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
if (code === CHAR_ASTERISK) {
|
|
2707
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
2708
|
+
isGlob = token.isGlob = true;
|
|
2709
|
+
finished = true;
|
|
2710
|
+
if (scanToEnd === true) {
|
|
2711
|
+
continue;
|
|
2712
|
+
}
|
|
2713
|
+
break;
|
|
2714
|
+
}
|
|
2715
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
2716
|
+
isGlob = token.isGlob = true;
|
|
2717
|
+
finished = true;
|
|
2718
|
+
if (scanToEnd === true) {
|
|
2719
|
+
continue;
|
|
2720
|
+
}
|
|
2721
|
+
break;
|
|
2722
|
+
}
|
|
2723
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
2724
|
+
while (eos() !== true && (next = advance())) {
|
|
2725
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
2726
|
+
backslashes = token.backslashes = true;
|
|
2727
|
+
advance();
|
|
2728
|
+
continue;
|
|
2729
|
+
}
|
|
2730
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
2731
|
+
isBracket = token.isBracket = true;
|
|
2732
|
+
isGlob = token.isGlob = true;
|
|
2733
|
+
finished = true;
|
|
2734
|
+
break;
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
if (scanToEnd === true) {
|
|
2738
|
+
continue;
|
|
2739
|
+
}
|
|
2740
|
+
break;
|
|
2741
|
+
}
|
|
2742
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
2743
|
+
negated = token.negated = true;
|
|
2744
|
+
start++;
|
|
2745
|
+
continue;
|
|
2746
|
+
}
|
|
2747
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
2748
|
+
isGlob = token.isGlob = true;
|
|
2749
|
+
if (scanToEnd === true) {
|
|
2750
|
+
while (eos() !== true && (code = advance())) {
|
|
2751
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
2752
|
+
backslashes = token.backslashes = true;
|
|
2753
|
+
code = advance();
|
|
2754
|
+
continue;
|
|
2755
|
+
}
|
|
2756
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
2757
|
+
finished = true;
|
|
2758
|
+
break;
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
continue;
|
|
2762
|
+
}
|
|
2763
|
+
break;
|
|
2764
|
+
}
|
|
2765
|
+
if (isGlob === true) {
|
|
2766
|
+
finished = true;
|
|
2767
|
+
if (scanToEnd === true) {
|
|
2768
|
+
continue;
|
|
2769
|
+
}
|
|
2770
|
+
break;
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
if (opts.noext === true) {
|
|
2774
|
+
isExtglob = false;
|
|
2775
|
+
isGlob = false;
|
|
2776
|
+
}
|
|
2777
|
+
let base = str;
|
|
2778
|
+
let prefix = "";
|
|
2779
|
+
let glob = "";
|
|
2780
|
+
if (start > 0) {
|
|
2781
|
+
prefix = str.slice(0, start);
|
|
2782
|
+
str = str.slice(start);
|
|
2783
|
+
lastIndex -= start;
|
|
2784
|
+
}
|
|
2785
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
2786
|
+
base = str.slice(0, lastIndex);
|
|
2787
|
+
glob = str.slice(lastIndex);
|
|
2788
|
+
} else if (isGlob === true) {
|
|
2789
|
+
base = "";
|
|
2790
|
+
glob = str;
|
|
2791
|
+
} else {
|
|
2792
|
+
base = str;
|
|
2793
|
+
}
|
|
2794
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
2795
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
2796
|
+
base = base.slice(0, -1);
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
if (opts.unescape === true) {
|
|
2800
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
2801
|
+
if (base && backslashes === true) {
|
|
2802
|
+
base = utils.removeBackslashes(base);
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
const state = {
|
|
2806
|
+
prefix,
|
|
2807
|
+
input,
|
|
2808
|
+
start,
|
|
2809
|
+
base,
|
|
2810
|
+
glob,
|
|
2811
|
+
isBrace,
|
|
2812
|
+
isBracket,
|
|
2813
|
+
isGlob,
|
|
2814
|
+
isExtglob,
|
|
2815
|
+
isGlobstar,
|
|
2816
|
+
negated,
|
|
2817
|
+
negatedExtglob
|
|
2818
|
+
};
|
|
2819
|
+
if (opts.tokens === true) {
|
|
2820
|
+
state.maxDepth = 0;
|
|
2821
|
+
if (!isPathSeparator(code)) {
|
|
2822
|
+
tokens.push(token);
|
|
2823
|
+
}
|
|
2824
|
+
state.tokens = tokens;
|
|
2825
|
+
}
|
|
2826
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
2827
|
+
let prevIndex;
|
|
2828
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
2829
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
2830
|
+
const i = slashes[idx];
|
|
2831
|
+
const value = input.slice(n, i);
|
|
2832
|
+
if (opts.tokens) {
|
|
2833
|
+
if (idx === 0 && start !== 0) {
|
|
2834
|
+
tokens[idx].isPrefix = true;
|
|
2835
|
+
tokens[idx].value = prefix;
|
|
2836
|
+
} else {
|
|
2837
|
+
tokens[idx].value = value;
|
|
2838
|
+
}
|
|
2839
|
+
depth(tokens[idx]);
|
|
2840
|
+
state.maxDepth += tokens[idx].depth;
|
|
2841
|
+
}
|
|
2842
|
+
if (idx !== 0 || value !== "") {
|
|
2843
|
+
parts.push(value);
|
|
2844
|
+
}
|
|
2845
|
+
prevIndex = i;
|
|
2846
|
+
}
|
|
2847
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
2848
|
+
const value = input.slice(prevIndex + 1);
|
|
2849
|
+
parts.push(value);
|
|
2850
|
+
if (opts.tokens) {
|
|
2851
|
+
tokens[tokens.length - 1].value = value;
|
|
2852
|
+
depth(tokens[tokens.length - 1]);
|
|
2853
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
state.slashes = slashes;
|
|
2857
|
+
state.parts = parts;
|
|
2858
|
+
}
|
|
2859
|
+
return state;
|
|
2860
|
+
};
|
|
2861
|
+
module2.exports = scan;
|
|
2862
|
+
}
|
|
2863
|
+
});
|
|
2864
|
+
|
|
2865
|
+
// ../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
|
|
2866
|
+
var require_parse = __commonJS({
|
|
2867
|
+
"../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js"(exports2, module2) {
|
|
2868
|
+
"use strict";
|
|
2869
|
+
var constants = require_constants4();
|
|
2870
|
+
var utils = require_utils();
|
|
2871
|
+
var {
|
|
2872
|
+
MAX_LENGTH,
|
|
2873
|
+
POSIX_REGEX_SOURCE,
|
|
2874
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
2875
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
2876
|
+
REPLACEMENTS
|
|
2877
|
+
} = constants;
|
|
2878
|
+
var expandRange = (args, options) => {
|
|
2879
|
+
if (typeof options.expandRange === "function") {
|
|
2880
|
+
return options.expandRange(...args, options);
|
|
2881
|
+
}
|
|
2882
|
+
args.sort();
|
|
2883
|
+
const value = `[${args.join("-")}]`;
|
|
2884
|
+
try {
|
|
2885
|
+
new RegExp(value);
|
|
2886
|
+
} catch (ex) {
|
|
2887
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
2888
|
+
}
|
|
2889
|
+
return value;
|
|
2890
|
+
};
|
|
2891
|
+
var syntaxError = (type, char) => {
|
|
2892
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
2893
|
+
};
|
|
2894
|
+
var parse = (input, options) => {
|
|
2895
|
+
if (typeof input !== "string") {
|
|
2896
|
+
throw new TypeError("Expected a string");
|
|
2897
|
+
}
|
|
2898
|
+
input = REPLACEMENTS[input] || input;
|
|
2899
|
+
const opts = { ...options };
|
|
2900
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
2901
|
+
let len = input.length;
|
|
2902
|
+
if (len > max) {
|
|
2903
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
2904
|
+
}
|
|
2905
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
2906
|
+
const tokens = [bos];
|
|
2907
|
+
const capture = opts.capture ? "" : "?:";
|
|
2908
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
2909
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
2910
|
+
const {
|
|
2911
|
+
DOT_LITERAL,
|
|
2912
|
+
PLUS_LITERAL,
|
|
2913
|
+
SLASH_LITERAL,
|
|
2914
|
+
ONE_CHAR,
|
|
2915
|
+
DOTS_SLASH,
|
|
2916
|
+
NO_DOT,
|
|
2917
|
+
NO_DOT_SLASH,
|
|
2918
|
+
NO_DOTS_SLASH,
|
|
2919
|
+
QMARK,
|
|
2920
|
+
QMARK_NO_DOT,
|
|
2921
|
+
STAR,
|
|
2922
|
+
START_ANCHOR
|
|
2923
|
+
} = PLATFORM_CHARS;
|
|
2924
|
+
const globstar = (opts2) => {
|
|
2925
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
2926
|
+
};
|
|
2927
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
2928
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
2929
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
2930
|
+
if (opts.capture) {
|
|
2931
|
+
star = `(${star})`;
|
|
2932
|
+
}
|
|
2933
|
+
if (typeof opts.noext === "boolean") {
|
|
2934
|
+
opts.noextglob = opts.noext;
|
|
2935
|
+
}
|
|
2936
|
+
const state = {
|
|
2937
|
+
input,
|
|
2938
|
+
index: -1,
|
|
2939
|
+
start: 0,
|
|
2940
|
+
dot: opts.dot === true,
|
|
2941
|
+
consumed: "",
|
|
2942
|
+
output: "",
|
|
2943
|
+
prefix: "",
|
|
2944
|
+
backtrack: false,
|
|
2945
|
+
negated: false,
|
|
2946
|
+
brackets: 0,
|
|
2947
|
+
braces: 0,
|
|
2948
|
+
parens: 0,
|
|
2949
|
+
quotes: 0,
|
|
2950
|
+
globstar: false,
|
|
2951
|
+
tokens
|
|
2952
|
+
};
|
|
2953
|
+
input = utils.removePrefix(input, state);
|
|
2954
|
+
len = input.length;
|
|
2955
|
+
const extglobs = [];
|
|
2956
|
+
const braces = [];
|
|
2957
|
+
const stack = [];
|
|
2958
|
+
let prev = bos;
|
|
2959
|
+
let value;
|
|
2960
|
+
const eos = () => state.index === len - 1;
|
|
2961
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
2962
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
2963
|
+
const remaining = () => input.slice(state.index + 1);
|
|
2964
|
+
const consume = (value2 = "", num = 0) => {
|
|
2965
|
+
state.consumed += value2;
|
|
2966
|
+
state.index += num;
|
|
2967
|
+
};
|
|
2968
|
+
const append = (token) => {
|
|
2969
|
+
state.output += token.output != null ? token.output : token.value;
|
|
2970
|
+
consume(token.value);
|
|
2971
|
+
};
|
|
2972
|
+
const negate = () => {
|
|
2973
|
+
let count = 1;
|
|
2974
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
2975
|
+
advance();
|
|
2976
|
+
state.start++;
|
|
2977
|
+
count++;
|
|
2978
|
+
}
|
|
2979
|
+
if (count % 2 === 0) {
|
|
2980
|
+
return false;
|
|
2981
|
+
}
|
|
2982
|
+
state.negated = true;
|
|
2983
|
+
state.start++;
|
|
2984
|
+
return true;
|
|
2985
|
+
};
|
|
2986
|
+
const increment = (type) => {
|
|
2987
|
+
state[type]++;
|
|
2988
|
+
stack.push(type);
|
|
2989
|
+
};
|
|
2990
|
+
const decrement = (type) => {
|
|
2991
|
+
state[type]--;
|
|
2992
|
+
stack.pop();
|
|
2993
|
+
};
|
|
2994
|
+
const push = (tok) => {
|
|
2995
|
+
if (prev.type === "globstar") {
|
|
2996
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
2997
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
2998
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
2999
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
3000
|
+
prev.type = "star";
|
|
3001
|
+
prev.value = "*";
|
|
3002
|
+
prev.output = star;
|
|
3003
|
+
state.output += prev.output;
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
3007
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
3008
|
+
}
|
|
3009
|
+
if (tok.value || tok.output) append(tok);
|
|
3010
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
3011
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
3012
|
+
prev.value += tok.value;
|
|
3013
|
+
return;
|
|
3014
|
+
}
|
|
3015
|
+
tok.prev = prev;
|
|
3016
|
+
tokens.push(tok);
|
|
3017
|
+
prev = tok;
|
|
3018
|
+
};
|
|
3019
|
+
const extglobOpen = (type, value2) => {
|
|
3020
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
3021
|
+
token.prev = prev;
|
|
3022
|
+
token.parens = state.parens;
|
|
3023
|
+
token.output = state.output;
|
|
3024
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
3025
|
+
increment("parens");
|
|
3026
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
3027
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
3028
|
+
extglobs.push(token);
|
|
3029
|
+
};
|
|
3030
|
+
const extglobClose = (token) => {
|
|
3031
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
3032
|
+
let rest;
|
|
3033
|
+
if (token.type === "negate") {
|
|
3034
|
+
let extglobStar = star;
|
|
3035
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
3036
|
+
extglobStar = globstar(opts);
|
|
3037
|
+
}
|
|
3038
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
3039
|
+
output = token.close = `)$))${extglobStar}`;
|
|
3040
|
+
}
|
|
3041
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
3042
|
+
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
3043
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
3044
|
+
}
|
|
3045
|
+
if (token.prev.type === "bos") {
|
|
3046
|
+
state.negatedExtglob = true;
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
push({ type: "paren", extglob: true, value, output });
|
|
3050
|
+
decrement("parens");
|
|
3051
|
+
};
|
|
3052
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
3053
|
+
let backslashes = false;
|
|
3054
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
3055
|
+
if (first === "\\") {
|
|
3056
|
+
backslashes = true;
|
|
3057
|
+
return m;
|
|
3058
|
+
}
|
|
3059
|
+
if (first === "?") {
|
|
3060
|
+
if (esc) {
|
|
3061
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
3062
|
+
}
|
|
3063
|
+
if (index === 0) {
|
|
3064
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
3065
|
+
}
|
|
3066
|
+
return QMARK.repeat(chars.length);
|
|
3067
|
+
}
|
|
3068
|
+
if (first === ".") {
|
|
3069
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
3070
|
+
}
|
|
3071
|
+
if (first === "*") {
|
|
3072
|
+
if (esc) {
|
|
3073
|
+
return esc + first + (rest ? star : "");
|
|
3074
|
+
}
|
|
3075
|
+
return star;
|
|
3076
|
+
}
|
|
3077
|
+
return esc ? m : `\\${m}`;
|
|
3078
|
+
});
|
|
3079
|
+
if (backslashes === true) {
|
|
3080
|
+
if (opts.unescape === true) {
|
|
3081
|
+
output = output.replace(/\\/g, "");
|
|
3082
|
+
} else {
|
|
3083
|
+
output = output.replace(/\\+/g, (m) => {
|
|
3084
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
if (output === input && opts.contains === true) {
|
|
3089
|
+
state.output = input;
|
|
3090
|
+
return state;
|
|
3091
|
+
}
|
|
3092
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
3093
|
+
return state;
|
|
3094
|
+
}
|
|
3095
|
+
while (!eos()) {
|
|
3096
|
+
value = advance();
|
|
3097
|
+
if (value === "\0") {
|
|
3098
|
+
continue;
|
|
3099
|
+
}
|
|
3100
|
+
if (value === "\\") {
|
|
3101
|
+
const next = peek();
|
|
3102
|
+
if (next === "/" && opts.bash !== true) {
|
|
3103
|
+
continue;
|
|
3104
|
+
}
|
|
3105
|
+
if (next === "." || next === ";") {
|
|
3106
|
+
continue;
|
|
3107
|
+
}
|
|
3108
|
+
if (!next) {
|
|
3109
|
+
value += "\\";
|
|
3110
|
+
push({ type: "text", value });
|
|
3111
|
+
continue;
|
|
3112
|
+
}
|
|
3113
|
+
const match = /^\\+/.exec(remaining());
|
|
3114
|
+
let slashes = 0;
|
|
3115
|
+
if (match && match[0].length > 2) {
|
|
3116
|
+
slashes = match[0].length;
|
|
3117
|
+
state.index += slashes;
|
|
3118
|
+
if (slashes % 2 !== 0) {
|
|
3119
|
+
value += "\\";
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
if (opts.unescape === true) {
|
|
3123
|
+
value = advance();
|
|
3124
|
+
} else {
|
|
3125
|
+
value += advance();
|
|
3126
|
+
}
|
|
3127
|
+
if (state.brackets === 0) {
|
|
3128
|
+
push({ type: "text", value });
|
|
3129
|
+
continue;
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
3133
|
+
if (opts.posix !== false && value === ":") {
|
|
3134
|
+
const inner = prev.value.slice(1);
|
|
3135
|
+
if (inner.includes("[")) {
|
|
3136
|
+
prev.posix = true;
|
|
3137
|
+
if (inner.includes(":")) {
|
|
3138
|
+
const idx = prev.value.lastIndexOf("[");
|
|
3139
|
+
const pre = prev.value.slice(0, idx);
|
|
3140
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
3141
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
3142
|
+
if (posix) {
|
|
3143
|
+
prev.value = pre + posix;
|
|
3144
|
+
state.backtrack = true;
|
|
3145
|
+
advance();
|
|
3146
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
3147
|
+
bos.output = ONE_CHAR;
|
|
3148
|
+
}
|
|
3149
|
+
continue;
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
3155
|
+
value = `\\${value}`;
|
|
3156
|
+
}
|
|
3157
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
3158
|
+
value = `\\${value}`;
|
|
3159
|
+
}
|
|
3160
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
3161
|
+
value = "^";
|
|
3162
|
+
}
|
|
3163
|
+
prev.value += value;
|
|
3164
|
+
append({ value });
|
|
3165
|
+
continue;
|
|
3166
|
+
}
|
|
3167
|
+
if (state.quotes === 1 && value !== '"') {
|
|
3168
|
+
value = utils.escapeRegex(value);
|
|
3169
|
+
prev.value += value;
|
|
3170
|
+
append({ value });
|
|
3171
|
+
continue;
|
|
3172
|
+
}
|
|
3173
|
+
if (value === '"') {
|
|
3174
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
3175
|
+
if (opts.keepQuotes === true) {
|
|
3176
|
+
push({ type: "text", value });
|
|
3177
|
+
}
|
|
3178
|
+
continue;
|
|
3179
|
+
}
|
|
3180
|
+
if (value === "(") {
|
|
3181
|
+
increment("parens");
|
|
3182
|
+
push({ type: "paren", value });
|
|
3183
|
+
continue;
|
|
3184
|
+
}
|
|
3185
|
+
if (value === ")") {
|
|
3186
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
3187
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
3188
|
+
}
|
|
3189
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
3190
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
3191
|
+
extglobClose(extglobs.pop());
|
|
3192
|
+
continue;
|
|
3193
|
+
}
|
|
3194
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
3195
|
+
decrement("parens");
|
|
3196
|
+
continue;
|
|
3197
|
+
}
|
|
3198
|
+
if (value === "[") {
|
|
3199
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
3200
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
3201
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
3202
|
+
}
|
|
3203
|
+
value = `\\${value}`;
|
|
3204
|
+
} else {
|
|
3205
|
+
increment("brackets");
|
|
3206
|
+
}
|
|
3207
|
+
push({ type: "bracket", value });
|
|
3208
|
+
continue;
|
|
3209
|
+
}
|
|
3210
|
+
if (value === "]") {
|
|
3211
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
3212
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
3213
|
+
continue;
|
|
3214
|
+
}
|
|
3215
|
+
if (state.brackets === 0) {
|
|
3216
|
+
if (opts.strictBrackets === true) {
|
|
3217
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
3218
|
+
}
|
|
3219
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
3220
|
+
continue;
|
|
3221
|
+
}
|
|
3222
|
+
decrement("brackets");
|
|
3223
|
+
const prevValue = prev.value.slice(1);
|
|
3224
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
3225
|
+
value = `/${value}`;
|
|
3226
|
+
}
|
|
3227
|
+
prev.value += value;
|
|
3228
|
+
append({ value });
|
|
3229
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
3230
|
+
continue;
|
|
3231
|
+
}
|
|
3232
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
3233
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
3234
|
+
if (opts.literalBrackets === true) {
|
|
3235
|
+
state.output += escaped;
|
|
3236
|
+
prev.value = escaped;
|
|
3237
|
+
continue;
|
|
3238
|
+
}
|
|
3239
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
3240
|
+
state.output += prev.value;
|
|
3241
|
+
continue;
|
|
3242
|
+
}
|
|
3243
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
3244
|
+
increment("braces");
|
|
3245
|
+
const open = {
|
|
3246
|
+
type: "brace",
|
|
3247
|
+
value,
|
|
3248
|
+
output: "(",
|
|
3249
|
+
outputIndex: state.output.length,
|
|
3250
|
+
tokensIndex: state.tokens.length
|
|
3251
|
+
};
|
|
3252
|
+
braces.push(open);
|
|
3253
|
+
push(open);
|
|
3254
|
+
continue;
|
|
3255
|
+
}
|
|
3256
|
+
if (value === "}") {
|
|
3257
|
+
const brace = braces[braces.length - 1];
|
|
3258
|
+
if (opts.nobrace === true || !brace) {
|
|
3259
|
+
push({ type: "text", value, output: value });
|
|
3260
|
+
continue;
|
|
3261
|
+
}
|
|
3262
|
+
let output = ")";
|
|
3263
|
+
if (brace.dots === true) {
|
|
3264
|
+
const arr = tokens.slice();
|
|
3265
|
+
const range = [];
|
|
3266
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
3267
|
+
tokens.pop();
|
|
3268
|
+
if (arr[i].type === "brace") {
|
|
3269
|
+
break;
|
|
3270
|
+
}
|
|
3271
|
+
if (arr[i].type !== "dots") {
|
|
3272
|
+
range.unshift(arr[i].value);
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
output = expandRange(range, opts);
|
|
3276
|
+
state.backtrack = true;
|
|
3277
|
+
}
|
|
3278
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
3279
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
3280
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
3281
|
+
brace.value = brace.output = "\\{";
|
|
3282
|
+
value = output = "\\}";
|
|
3283
|
+
state.output = out;
|
|
3284
|
+
for (const t of toks) {
|
|
3285
|
+
state.output += t.output || t.value;
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
push({ type: "brace", value, output });
|
|
3289
|
+
decrement("braces");
|
|
3290
|
+
braces.pop();
|
|
3291
|
+
continue;
|
|
3292
|
+
}
|
|
3293
|
+
if (value === "|") {
|
|
3294
|
+
if (extglobs.length > 0) {
|
|
3295
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
3296
|
+
}
|
|
3297
|
+
push({ type: "text", value });
|
|
3298
|
+
continue;
|
|
3299
|
+
}
|
|
3300
|
+
if (value === ",") {
|
|
3301
|
+
let output = value;
|
|
3302
|
+
const brace = braces[braces.length - 1];
|
|
3303
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
3304
|
+
brace.comma = true;
|
|
3305
|
+
output = "|";
|
|
3306
|
+
}
|
|
3307
|
+
push({ type: "comma", value, output });
|
|
3308
|
+
continue;
|
|
3309
|
+
}
|
|
3310
|
+
if (value === "/") {
|
|
3311
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
3312
|
+
state.start = state.index + 1;
|
|
3313
|
+
state.consumed = "";
|
|
3314
|
+
state.output = "";
|
|
3315
|
+
tokens.pop();
|
|
3316
|
+
prev = bos;
|
|
3317
|
+
continue;
|
|
3318
|
+
}
|
|
3319
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
3320
|
+
continue;
|
|
3321
|
+
}
|
|
3322
|
+
if (value === ".") {
|
|
3323
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
3324
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
3325
|
+
const brace = braces[braces.length - 1];
|
|
3326
|
+
prev.type = "dots";
|
|
3327
|
+
prev.output += value;
|
|
3328
|
+
prev.value += value;
|
|
3329
|
+
brace.dots = true;
|
|
3330
|
+
continue;
|
|
3331
|
+
}
|
|
3332
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
3333
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
3334
|
+
continue;
|
|
3335
|
+
}
|
|
3336
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
3337
|
+
continue;
|
|
3338
|
+
}
|
|
3339
|
+
if (value === "?") {
|
|
3340
|
+
const isGroup = prev && prev.value === "(";
|
|
3341
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
3342
|
+
extglobOpen("qmark", value);
|
|
3343
|
+
continue;
|
|
3344
|
+
}
|
|
3345
|
+
if (prev && prev.type === "paren") {
|
|
3346
|
+
const next = peek();
|
|
3347
|
+
let output = value;
|
|
3348
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
3349
|
+
output = `\\${value}`;
|
|
3350
|
+
}
|
|
3351
|
+
push({ type: "text", value, output });
|
|
3352
|
+
continue;
|
|
3353
|
+
}
|
|
3354
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
3355
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
3356
|
+
continue;
|
|
3357
|
+
}
|
|
3358
|
+
push({ type: "qmark", value, output: QMARK });
|
|
3359
|
+
continue;
|
|
3360
|
+
}
|
|
3361
|
+
if (value === "!") {
|
|
3362
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
3363
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
3364
|
+
extglobOpen("negate", value);
|
|
3365
|
+
continue;
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
3369
|
+
negate();
|
|
3370
|
+
continue;
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
if (value === "+") {
|
|
3374
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
3375
|
+
extglobOpen("plus", value);
|
|
3376
|
+
continue;
|
|
3377
|
+
}
|
|
3378
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
3379
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
3380
|
+
continue;
|
|
3381
|
+
}
|
|
3382
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
3383
|
+
push({ type: "plus", value });
|
|
3384
|
+
continue;
|
|
3385
|
+
}
|
|
3386
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
3387
|
+
continue;
|
|
3388
|
+
}
|
|
3389
|
+
if (value === "@") {
|
|
3390
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
3391
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
3392
|
+
continue;
|
|
3393
|
+
}
|
|
3394
|
+
push({ type: "text", value });
|
|
3395
|
+
continue;
|
|
3396
|
+
}
|
|
3397
|
+
if (value !== "*") {
|
|
3398
|
+
if (value === "$" || value === "^") {
|
|
3399
|
+
value = `\\${value}`;
|
|
3400
|
+
}
|
|
3401
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
3402
|
+
if (match) {
|
|
3403
|
+
value += match[0];
|
|
3404
|
+
state.index += match[0].length;
|
|
3405
|
+
}
|
|
3406
|
+
push({ type: "text", value });
|
|
3407
|
+
continue;
|
|
3408
|
+
}
|
|
3409
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
3410
|
+
prev.type = "star";
|
|
3411
|
+
prev.star = true;
|
|
3412
|
+
prev.value += value;
|
|
3413
|
+
prev.output = star;
|
|
3414
|
+
state.backtrack = true;
|
|
3415
|
+
state.globstar = true;
|
|
3416
|
+
consume(value);
|
|
3417
|
+
continue;
|
|
3418
|
+
}
|
|
3419
|
+
let rest = remaining();
|
|
3420
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
3421
|
+
extglobOpen("star", value);
|
|
3422
|
+
continue;
|
|
3423
|
+
}
|
|
3424
|
+
if (prev.type === "star") {
|
|
3425
|
+
if (opts.noglobstar === true) {
|
|
3426
|
+
consume(value);
|
|
3427
|
+
continue;
|
|
3428
|
+
}
|
|
3429
|
+
const prior = prev.prev;
|
|
3430
|
+
const before = prior.prev;
|
|
3431
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
3432
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
3433
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
3434
|
+
push({ type: "star", value, output: "" });
|
|
3435
|
+
continue;
|
|
3436
|
+
}
|
|
3437
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
3438
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
3439
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
3440
|
+
push({ type: "star", value, output: "" });
|
|
3441
|
+
continue;
|
|
3442
|
+
}
|
|
3443
|
+
while (rest.slice(0, 3) === "/**") {
|
|
3444
|
+
const after = input[state.index + 4];
|
|
3445
|
+
if (after && after !== "/") {
|
|
3446
|
+
break;
|
|
3447
|
+
}
|
|
3448
|
+
rest = rest.slice(3);
|
|
3449
|
+
consume("/**", 3);
|
|
3450
|
+
}
|
|
3451
|
+
if (prior.type === "bos" && eos()) {
|
|
3452
|
+
prev.type = "globstar";
|
|
3453
|
+
prev.value += value;
|
|
3454
|
+
prev.output = globstar(opts);
|
|
3455
|
+
state.output = prev.output;
|
|
3456
|
+
state.globstar = true;
|
|
3457
|
+
consume(value);
|
|
3458
|
+
continue;
|
|
3459
|
+
}
|
|
3460
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
3461
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
3462
|
+
prior.output = `(?:${prior.output}`;
|
|
3463
|
+
prev.type = "globstar";
|
|
3464
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
3465
|
+
prev.value += value;
|
|
3466
|
+
state.globstar = true;
|
|
3467
|
+
state.output += prior.output + prev.output;
|
|
3468
|
+
consume(value);
|
|
3469
|
+
continue;
|
|
3470
|
+
}
|
|
3471
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
3472
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
3473
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
3474
|
+
prior.output = `(?:${prior.output}`;
|
|
3475
|
+
prev.type = "globstar";
|
|
3476
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
3477
|
+
prev.value += value;
|
|
3478
|
+
state.output += prior.output + prev.output;
|
|
3479
|
+
state.globstar = true;
|
|
3480
|
+
consume(value + advance());
|
|
3481
|
+
push({ type: "slash", value: "/", output: "" });
|
|
3482
|
+
continue;
|
|
3483
|
+
}
|
|
3484
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
3485
|
+
prev.type = "globstar";
|
|
3486
|
+
prev.value += value;
|
|
3487
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
3488
|
+
state.output = prev.output;
|
|
3489
|
+
state.globstar = true;
|
|
3490
|
+
consume(value + advance());
|
|
3491
|
+
push({ type: "slash", value: "/", output: "" });
|
|
3492
|
+
continue;
|
|
3493
|
+
}
|
|
3494
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
3495
|
+
prev.type = "globstar";
|
|
3496
|
+
prev.output = globstar(opts);
|
|
3497
|
+
prev.value += value;
|
|
3498
|
+
state.output += prev.output;
|
|
3499
|
+
state.globstar = true;
|
|
3500
|
+
consume(value);
|
|
3501
|
+
continue;
|
|
3502
|
+
}
|
|
3503
|
+
const token = { type: "star", value, output: star };
|
|
3504
|
+
if (opts.bash === true) {
|
|
3505
|
+
token.output = ".*?";
|
|
3506
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
3507
|
+
token.output = nodot + token.output;
|
|
3508
|
+
}
|
|
3509
|
+
push(token);
|
|
3510
|
+
continue;
|
|
3511
|
+
}
|
|
3512
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
3513
|
+
token.output = value;
|
|
3514
|
+
push(token);
|
|
3515
|
+
continue;
|
|
3516
|
+
}
|
|
3517
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
3518
|
+
if (prev.type === "dot") {
|
|
3519
|
+
state.output += NO_DOT_SLASH;
|
|
3520
|
+
prev.output += NO_DOT_SLASH;
|
|
3521
|
+
} else if (opts.dot === true) {
|
|
3522
|
+
state.output += NO_DOTS_SLASH;
|
|
3523
|
+
prev.output += NO_DOTS_SLASH;
|
|
3524
|
+
} else {
|
|
3525
|
+
state.output += nodot;
|
|
3526
|
+
prev.output += nodot;
|
|
3527
|
+
}
|
|
3528
|
+
if (peek() !== "*") {
|
|
3529
|
+
state.output += ONE_CHAR;
|
|
3530
|
+
prev.output += ONE_CHAR;
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
push(token);
|
|
3534
|
+
}
|
|
3535
|
+
while (state.brackets > 0) {
|
|
3536
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
3537
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
3538
|
+
decrement("brackets");
|
|
3539
|
+
}
|
|
3540
|
+
while (state.parens > 0) {
|
|
3541
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
3542
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
3543
|
+
decrement("parens");
|
|
3544
|
+
}
|
|
3545
|
+
while (state.braces > 0) {
|
|
3546
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
3547
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
3548
|
+
decrement("braces");
|
|
3549
|
+
}
|
|
3550
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
3551
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
3552
|
+
}
|
|
3553
|
+
if (state.backtrack === true) {
|
|
3554
|
+
state.output = "";
|
|
3555
|
+
for (const token of state.tokens) {
|
|
3556
|
+
state.output += token.output != null ? token.output : token.value;
|
|
3557
|
+
if (token.suffix) {
|
|
3558
|
+
state.output += token.suffix;
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
return state;
|
|
3563
|
+
};
|
|
3564
|
+
parse.fastpaths = (input, options) => {
|
|
3565
|
+
const opts = { ...options };
|
|
3566
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
3567
|
+
const len = input.length;
|
|
3568
|
+
if (len > max) {
|
|
3569
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
3570
|
+
}
|
|
3571
|
+
input = REPLACEMENTS[input] || input;
|
|
3572
|
+
const {
|
|
3573
|
+
DOT_LITERAL,
|
|
3574
|
+
SLASH_LITERAL,
|
|
3575
|
+
ONE_CHAR,
|
|
3576
|
+
DOTS_SLASH,
|
|
3577
|
+
NO_DOT,
|
|
3578
|
+
NO_DOTS,
|
|
3579
|
+
NO_DOTS_SLASH,
|
|
3580
|
+
STAR,
|
|
3581
|
+
START_ANCHOR
|
|
3582
|
+
} = constants.globChars(opts.windows);
|
|
3583
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
3584
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
3585
|
+
const capture = opts.capture ? "" : "?:";
|
|
3586
|
+
const state = { negated: false, prefix: "" };
|
|
3587
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
3588
|
+
if (opts.capture) {
|
|
3589
|
+
star = `(${star})`;
|
|
3590
|
+
}
|
|
3591
|
+
const globstar = (opts2) => {
|
|
3592
|
+
if (opts2.noglobstar === true) return star;
|
|
3593
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
3594
|
+
};
|
|
3595
|
+
const create = (str) => {
|
|
3596
|
+
switch (str) {
|
|
3597
|
+
case "*":
|
|
3598
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
3599
|
+
case ".*":
|
|
3600
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
3601
|
+
case "*.*":
|
|
3602
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
3603
|
+
case "*/*":
|
|
3604
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
3605
|
+
case "**":
|
|
3606
|
+
return nodot + globstar(opts);
|
|
3607
|
+
case "**/*":
|
|
3608
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
3609
|
+
case "**/*.*":
|
|
3610
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
3611
|
+
case "**/.*":
|
|
3612
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
3613
|
+
default: {
|
|
3614
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
3615
|
+
if (!match) return;
|
|
3616
|
+
const source2 = create(match[1]);
|
|
3617
|
+
if (!source2) return;
|
|
3618
|
+
return source2 + DOT_LITERAL + match[2];
|
|
3619
|
+
}
|
|
3620
|
+
}
|
|
3621
|
+
};
|
|
3622
|
+
const output = utils.removePrefix(input, state);
|
|
3623
|
+
let source = create(output);
|
|
3624
|
+
if (source && opts.strictSlashes !== true) {
|
|
3625
|
+
source += `${SLASH_LITERAL}?`;
|
|
3626
|
+
}
|
|
3627
|
+
return source;
|
|
3628
|
+
};
|
|
3629
|
+
module2.exports = parse;
|
|
3630
|
+
}
|
|
3631
|
+
});
|
|
3632
|
+
|
|
3633
|
+
// ../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
|
|
3634
|
+
var require_picomatch = __commonJS({
|
|
3635
|
+
"../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js"(exports2, module2) {
|
|
3636
|
+
"use strict";
|
|
3637
|
+
var scan = require_scan();
|
|
3638
|
+
var parse = require_parse();
|
|
3639
|
+
var utils = require_utils();
|
|
3640
|
+
var constants = require_constants4();
|
|
3641
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
3642
|
+
var picomatch2 = (glob, options, returnState = false) => {
|
|
3643
|
+
if (Array.isArray(glob)) {
|
|
3644
|
+
const fns = glob.map((input) => picomatch2(input, options, returnState));
|
|
3645
|
+
const arrayMatcher = (str) => {
|
|
3646
|
+
for (const isMatch of fns) {
|
|
3647
|
+
const state2 = isMatch(str);
|
|
3648
|
+
if (state2) return state2;
|
|
3649
|
+
}
|
|
3650
|
+
return false;
|
|
3651
|
+
};
|
|
3652
|
+
return arrayMatcher;
|
|
3653
|
+
}
|
|
3654
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
3655
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
3656
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
3657
|
+
}
|
|
3658
|
+
const opts = options || {};
|
|
3659
|
+
const posix = opts.windows;
|
|
3660
|
+
const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
3661
|
+
const state = regex.state;
|
|
3662
|
+
delete regex.state;
|
|
3663
|
+
let isIgnored = () => false;
|
|
3664
|
+
if (opts.ignore) {
|
|
3665
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
3666
|
+
isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
|
|
3667
|
+
}
|
|
3668
|
+
const matcher = (input, returnObject = false) => {
|
|
3669
|
+
const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
|
|
3670
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
3671
|
+
if (typeof opts.onResult === "function") {
|
|
3672
|
+
opts.onResult(result);
|
|
3673
|
+
}
|
|
3674
|
+
if (isMatch === false) {
|
|
3675
|
+
result.isMatch = false;
|
|
3676
|
+
return returnObject ? result : false;
|
|
3677
|
+
}
|
|
3678
|
+
if (isIgnored(input)) {
|
|
3679
|
+
if (typeof opts.onIgnore === "function") {
|
|
3680
|
+
opts.onIgnore(result);
|
|
3681
|
+
}
|
|
3682
|
+
result.isMatch = false;
|
|
3683
|
+
return returnObject ? result : false;
|
|
3684
|
+
}
|
|
3685
|
+
if (typeof opts.onMatch === "function") {
|
|
3686
|
+
opts.onMatch(result);
|
|
3687
|
+
}
|
|
3688
|
+
return returnObject ? result : true;
|
|
3689
|
+
};
|
|
3690
|
+
if (returnState) {
|
|
3691
|
+
matcher.state = state;
|
|
3692
|
+
}
|
|
3693
|
+
return matcher;
|
|
3694
|
+
};
|
|
3695
|
+
picomatch2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
3696
|
+
if (typeof input !== "string") {
|
|
3697
|
+
throw new TypeError("Expected input to be a string");
|
|
3698
|
+
}
|
|
3699
|
+
if (input === "") {
|
|
3700
|
+
return { isMatch: false, output: "" };
|
|
3701
|
+
}
|
|
3702
|
+
const opts = options || {};
|
|
3703
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
3704
|
+
let match = input === glob;
|
|
3705
|
+
let output = match && format ? format(input) : input;
|
|
3706
|
+
if (match === false) {
|
|
3707
|
+
output = format ? format(input) : input;
|
|
3708
|
+
match = output === glob;
|
|
3709
|
+
}
|
|
3710
|
+
if (match === false || opts.capture === true) {
|
|
3711
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
3712
|
+
match = picomatch2.matchBase(input, regex, options, posix);
|
|
3713
|
+
} else {
|
|
3714
|
+
match = regex.exec(output);
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
return { isMatch: Boolean(match), match, output };
|
|
3718
|
+
};
|
|
3719
|
+
picomatch2.matchBase = (input, glob, options) => {
|
|
3720
|
+
const regex = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
|
|
3721
|
+
return regex.test(utils.basename(input));
|
|
3722
|
+
};
|
|
3723
|
+
picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
|
|
3724
|
+
picomatch2.parse = (pattern, options) => {
|
|
3725
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch2.parse(p, options));
|
|
3726
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
3727
|
+
};
|
|
3728
|
+
picomatch2.scan = (input, options) => scan(input, options);
|
|
3729
|
+
picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
3730
|
+
if (returnOutput === true) {
|
|
3731
|
+
return state.output;
|
|
3732
|
+
}
|
|
3733
|
+
const opts = options || {};
|
|
3734
|
+
const prepend = opts.contains ? "" : "^";
|
|
3735
|
+
const append = opts.contains ? "" : "$";
|
|
3736
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
3737
|
+
if (state && state.negated === true) {
|
|
3738
|
+
source = `^(?!${source}).*$`;
|
|
3739
|
+
}
|
|
3740
|
+
const regex = picomatch2.toRegex(source, options);
|
|
3741
|
+
if (returnState === true) {
|
|
3742
|
+
regex.state = state;
|
|
3743
|
+
}
|
|
3744
|
+
return regex;
|
|
3745
|
+
};
|
|
3746
|
+
picomatch2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
3747
|
+
if (!input || typeof input !== "string") {
|
|
3748
|
+
throw new TypeError("Expected a non-empty string");
|
|
3749
|
+
}
|
|
3750
|
+
let parsed = { negated: false, fastpaths: true };
|
|
3751
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
3752
|
+
parsed.output = parse.fastpaths(input, options);
|
|
3753
|
+
}
|
|
3754
|
+
if (!parsed.output) {
|
|
3755
|
+
parsed = parse(input, options);
|
|
3756
|
+
}
|
|
3757
|
+
return picomatch2.compileRe(parsed, options, returnOutput, returnState);
|
|
3758
|
+
};
|
|
3759
|
+
picomatch2.toRegex = (source, options) => {
|
|
3760
|
+
try {
|
|
3761
|
+
const opts = options || {};
|
|
3762
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
3763
|
+
} catch (err) {
|
|
3764
|
+
if (options && options.debug === true) throw err;
|
|
3765
|
+
return /$^/;
|
|
3766
|
+
}
|
|
3767
|
+
};
|
|
3768
|
+
picomatch2.constants = constants;
|
|
3769
|
+
module2.exports = picomatch2;
|
|
3770
|
+
}
|
|
3771
|
+
});
|
|
3772
|
+
|
|
3773
|
+
// ../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
|
|
3774
|
+
var require_picomatch2 = __commonJS({
|
|
3775
|
+
"../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js"(exports2, module2) {
|
|
3776
|
+
"use strict";
|
|
3777
|
+
var pico = require_picomatch();
|
|
3778
|
+
var utils = require_utils();
|
|
3779
|
+
function picomatch2(glob, options, returnState = false) {
|
|
3780
|
+
if (options && (options.windows === null || options.windows === void 0)) {
|
|
3781
|
+
options = { ...options, windows: utils.isWindows() };
|
|
3782
|
+
}
|
|
3783
|
+
return pico(glob, options, returnState);
|
|
3784
|
+
}
|
|
3785
|
+
Object.assign(picomatch2, pico);
|
|
3786
|
+
module2.exports = picomatch2;
|
|
3787
|
+
}
|
|
3788
|
+
});
|
|
3789
|
+
|
|
3790
|
+
// src/services/linuxcnc.ts
|
|
3791
|
+
var import_core = __toESM(require_dist3());
|
|
3792
|
+
init_dlv_es();
|
|
3793
|
+
var SERVICE_NAME = "linuxcnc";
|
|
3794
|
+
var statChannel = null;
|
|
3795
|
+
var commandChannel = null;
|
|
3796
|
+
var errorChannel = null;
|
|
3797
|
+
var connections = /* @__PURE__ */ new Map();
|
|
3798
|
+
function broadcastDelta(changes) {
|
|
3799
|
+
if (changes.length === 0 || !statChannel) return;
|
|
3800
|
+
const message = {
|
|
3801
|
+
changes,
|
|
3802
|
+
cursor: statChannel.getCursor(),
|
|
3803
|
+
timestamp: Date.now()
|
|
3804
|
+
};
|
|
3805
|
+
for (const conn of connections.values()) {
|
|
3806
|
+
try {
|
|
3807
|
+
conn.send("stat-delta", message);
|
|
3808
|
+
} catch (err) {
|
|
3809
|
+
console.error("[LinuxCNC] Error sending delta:", err);
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
}
|
|
3813
|
+
function initLinuxCNCService() {
|
|
3814
|
+
statChannel = new import_core.StatChannel({ pollInterval: 50 });
|
|
3815
|
+
commandChannel = new import_core.CommandChannel();
|
|
3816
|
+
errorChannel = new import_core.ErrorChannel({ pollInterval: 100 });
|
|
3817
|
+
statChannel.on("delta", broadcastDelta);
|
|
3818
|
+
errorChannel.on("message", (error) => {
|
|
3819
|
+
for (const conn of connections.values()) {
|
|
3820
|
+
try {
|
|
3821
|
+
conn.send("error-channel-event", error);
|
|
3822
|
+
} catch (err) {
|
|
3823
|
+
console.error("[LinuxCNC] Error forwarding error event:", err);
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
worker.appBus.exposeService(
|
|
3828
|
+
SERVICE_NAME,
|
|
3829
|
+
(connection, { appId: clientAppId }) => {
|
|
3830
|
+
console.log(`[LinuxCNC] Client connected: ${clientAppId}`);
|
|
3831
|
+
const typedConn = connection;
|
|
3832
|
+
connections.set(clientAppId, typedConn);
|
|
3833
|
+
connection.onClose(() => {
|
|
3834
|
+
console.log(`[LinuxCNC] Client disconnected: ${clientAppId}`);
|
|
3835
|
+
connections.delete(clientAppId);
|
|
3836
|
+
});
|
|
3837
|
+
typedConn.handle("stat/sync", () => {
|
|
3838
|
+
const stat = statChannel.get();
|
|
3839
|
+
if (!stat) {
|
|
3840
|
+
throw new Error("StatChannel not ready");
|
|
3841
|
+
}
|
|
3842
|
+
return {
|
|
3843
|
+
stat,
|
|
3844
|
+
cursor: statChannel.getCursor()
|
|
3845
|
+
};
|
|
3846
|
+
});
|
|
3847
|
+
typedConn.handle("stat/get-value", ({ path }) => {
|
|
3848
|
+
const stat = statChannel.get();
|
|
3849
|
+
if (!stat) {
|
|
3850
|
+
throw new Error("StatChannel not ready");
|
|
3851
|
+
}
|
|
3852
|
+
return { value: dlv_es_default(stat, path) };
|
|
3853
|
+
});
|
|
3854
|
+
typedConn.handle("cmd/set-task-mode", async ({ mode }) => {
|
|
3855
|
+
return commandChannel.setTaskMode(mode);
|
|
3856
|
+
});
|
|
3857
|
+
typedConn.handle("cmd/set-state", async ({ state }) => {
|
|
3858
|
+
return commandChannel.setState(state);
|
|
3859
|
+
});
|
|
3860
|
+
typedConn.handle("cmd/mdi", async ({ command }) => {
|
|
3861
|
+
return commandChannel.mdi(command);
|
|
3862
|
+
});
|
|
3863
|
+
typedConn.handle("cmd/abort", async () => {
|
|
3864
|
+
return commandChannel.abortTask();
|
|
3865
|
+
});
|
|
3866
|
+
typedConn.handle("cmd/task-plan-synch", async () => {
|
|
3867
|
+
return commandChannel.taskPlanSynch();
|
|
3868
|
+
});
|
|
3869
|
+
typedConn.handle("cmd/reset-interpreter", async () => {
|
|
3870
|
+
return commandChannel.resetInterpreter();
|
|
3871
|
+
});
|
|
3872
|
+
typedConn.handle("cmd/program-open", async ({ filePath }) => {
|
|
3873
|
+
return commandChannel.programOpen(filePath);
|
|
3874
|
+
});
|
|
3875
|
+
typedConn.handle("cmd/program-run", async ({ startLine }) => {
|
|
3876
|
+
return commandChannel.runProgram(startLine ?? 0);
|
|
3877
|
+
});
|
|
3878
|
+
typedConn.handle("cmd/program-pause", async () => {
|
|
3879
|
+
return commandChannel.pauseProgram();
|
|
3880
|
+
});
|
|
3881
|
+
typedConn.handle("cmd/program-resume", async () => {
|
|
3882
|
+
return commandChannel.resumeProgram();
|
|
3883
|
+
});
|
|
3884
|
+
typedConn.handle("cmd/program-step", async () => {
|
|
3885
|
+
return commandChannel.stepProgram();
|
|
3886
|
+
});
|
|
3887
|
+
typedConn.handle("cmd/program-reverse", async () => {
|
|
3888
|
+
return commandChannel.reverseProgram();
|
|
3889
|
+
});
|
|
3890
|
+
typedConn.handle("cmd/program-forward", async () => {
|
|
3891
|
+
return commandChannel.forwardProgram();
|
|
3892
|
+
});
|
|
3893
|
+
typedConn.handle("cmd/set-feed-rate", async ({ scale }) => {
|
|
3894
|
+
return commandChannel.setFeedRate(scale);
|
|
3895
|
+
});
|
|
3896
|
+
typedConn.handle("cmd/set-rapid-rate", async ({ scale }) => {
|
|
3897
|
+
return commandChannel.setRapidRate(scale);
|
|
3898
|
+
});
|
|
3899
|
+
typedConn.handle("cmd/set-max-velocity", async ({ velocity }) => {
|
|
3900
|
+
return commandChannel.setMaxVelocity(velocity);
|
|
3901
|
+
});
|
|
3902
|
+
typedConn.handle("cmd/set-traj-mode", async ({ mode }) => {
|
|
3903
|
+
return commandChannel.setTrajMode(mode);
|
|
3904
|
+
});
|
|
3905
|
+
typedConn.handle("cmd/teleop-enable", async ({ enable }) => {
|
|
3906
|
+
return commandChannel.teleopEnable(enable);
|
|
3907
|
+
});
|
|
3908
|
+
typedConn.handle("cmd/set-feed-override-enable", async ({ enable }) => {
|
|
3909
|
+
return commandChannel.setFeedOverrideEnable(enable);
|
|
3910
|
+
});
|
|
3911
|
+
typedConn.handle("cmd/set-feed-hold-enable", async ({ enable }) => {
|
|
3912
|
+
return commandChannel.setFeedHoldEnable(enable);
|
|
3913
|
+
});
|
|
3914
|
+
typedConn.handle("cmd/set-adaptive-feed-enable", async ({ enable }) => {
|
|
3915
|
+
return commandChannel.setAdaptiveFeedEnable(enable);
|
|
3916
|
+
});
|
|
3917
|
+
typedConn.handle(
|
|
3918
|
+
"cmd/jog-continuous",
|
|
3919
|
+
async ({ axis, speed, isJoint }) => {
|
|
3920
|
+
return commandChannel.jogContinuous(axis, isJoint ?? false, speed);
|
|
3921
|
+
}
|
|
3922
|
+
);
|
|
3923
|
+
typedConn.handle(
|
|
3924
|
+
"cmd/jog-increment",
|
|
3925
|
+
async ({ axis, speed, increment, isJoint }) => {
|
|
3926
|
+
return commandChannel.jogIncrement(
|
|
3927
|
+
axis,
|
|
3928
|
+
isJoint ?? false,
|
|
3929
|
+
speed,
|
|
3930
|
+
increment
|
|
3931
|
+
);
|
|
3932
|
+
}
|
|
3933
|
+
);
|
|
3934
|
+
typedConn.handle("cmd/jog-stop", async ({ axis, isJoint }) => {
|
|
3935
|
+
return commandChannel.jogStop(axis, isJoint ?? false);
|
|
3936
|
+
});
|
|
3937
|
+
typedConn.handle("cmd/home", async ({ joint }) => {
|
|
3938
|
+
return commandChannel.homeJoint(joint);
|
|
3939
|
+
});
|
|
3940
|
+
typedConn.handle("cmd/unhome", async ({ joint }) => {
|
|
3941
|
+
return commandChannel.unhomeJoint(joint);
|
|
3942
|
+
});
|
|
3943
|
+
typedConn.handle(
|
|
3944
|
+
"cmd/set-min-position-limit",
|
|
3945
|
+
async ({ joint, limit }) => {
|
|
3946
|
+
return commandChannel.setMinPositionLimit(joint, limit);
|
|
3947
|
+
}
|
|
3948
|
+
);
|
|
3949
|
+
typedConn.handle(
|
|
3950
|
+
"cmd/set-max-position-limit",
|
|
3951
|
+
async ({ joint, limit }) => {
|
|
3952
|
+
return commandChannel.setMaxPositionLimit(joint, limit);
|
|
3953
|
+
}
|
|
3954
|
+
);
|
|
3955
|
+
typedConn.handle("cmd/spindle-on", async ({ speed, spindle, wait }) => {
|
|
3956
|
+
return commandChannel.spindleOn(speed, spindle ?? 0, wait ?? false);
|
|
3957
|
+
});
|
|
3958
|
+
typedConn.handle("cmd/spindle-off", async ({ spindle }) => {
|
|
3959
|
+
return commandChannel.spindleOff(spindle ?? 0);
|
|
3960
|
+
});
|
|
3961
|
+
typedConn.handle("cmd/spindle-override", async ({ scale, spindle }) => {
|
|
3962
|
+
return commandChannel.setSpindleOverride(scale, spindle ?? 0);
|
|
3963
|
+
});
|
|
3964
|
+
typedConn.handle("cmd/spindle-brake", async ({ engage, spindle }) => {
|
|
3965
|
+
return commandChannel.spindleBrake(engage, spindle ?? 0);
|
|
3966
|
+
});
|
|
3967
|
+
typedConn.handle("cmd/spindle-increase", async ({ spindle }) => {
|
|
3968
|
+
return commandChannel.spindleIncrease(spindle ?? 0);
|
|
3969
|
+
});
|
|
3970
|
+
typedConn.handle("cmd/spindle-decrease", async ({ spindle }) => {
|
|
3971
|
+
return commandChannel.spindleDecrease(spindle ?? 0);
|
|
3972
|
+
});
|
|
3973
|
+
typedConn.handle(
|
|
3974
|
+
"cmd/set-spindle-override-enable",
|
|
3975
|
+
async ({ enable, spindle }) => {
|
|
3976
|
+
return commandChannel.setSpindleOverrideEnable(enable, spindle ?? 0);
|
|
3977
|
+
}
|
|
3978
|
+
);
|
|
3979
|
+
typedConn.handle("cmd/set-mist", async ({ on }) => {
|
|
3980
|
+
return commandChannel.setMist(on);
|
|
3981
|
+
});
|
|
3982
|
+
typedConn.handle("cmd/set-flood", async ({ on }) => {
|
|
3983
|
+
return commandChannel.setFlood(on);
|
|
3984
|
+
});
|
|
3985
|
+
typedConn.handle("cmd/load-tool-table", async () => {
|
|
3986
|
+
return commandChannel.loadToolTable();
|
|
3987
|
+
});
|
|
3988
|
+
typedConn.handle("cmd/set-tool", async ({ tool }) => {
|
|
3989
|
+
return commandChannel.setTool(tool);
|
|
3990
|
+
});
|
|
3991
|
+
typedConn.handle("cmd/set-digital-output", async ({ index, value }) => {
|
|
3992
|
+
return commandChannel.setDigitalOutput(index, value);
|
|
3993
|
+
});
|
|
3994
|
+
typedConn.handle("cmd/set-analog-output", async ({ index, value }) => {
|
|
3995
|
+
return commandChannel.setAnalogOutput(index, value);
|
|
3996
|
+
});
|
|
3997
|
+
typedConn.handle("cmd/override-limits", async () => {
|
|
3998
|
+
return commandChannel.overrideLimits();
|
|
3999
|
+
});
|
|
4000
|
+
typedConn.handle("cmd/set-optional-stop", async ({ enable }) => {
|
|
4001
|
+
return commandChannel.setOptionalStop(enable);
|
|
4002
|
+
});
|
|
4003
|
+
typedConn.handle("cmd/set-block-delete", async ({ enable }) => {
|
|
4004
|
+
return commandChannel.setBlockDelete(enable);
|
|
4005
|
+
});
|
|
4006
|
+
typedConn.handle("cmd/set-debug-level", async ({ level }) => {
|
|
4007
|
+
return commandChannel.setDebugLevel(level);
|
|
4008
|
+
});
|
|
4009
|
+
typedConn.handle("cmd/send-operator-error", async ({ message }) => {
|
|
4010
|
+
return commandChannel.sendOperatorError(message);
|
|
4011
|
+
});
|
|
4012
|
+
typedConn.handle("cmd/send-operator-text", async ({ message }) => {
|
|
4013
|
+
return commandChannel.sendOperatorText(message);
|
|
4014
|
+
});
|
|
4015
|
+
typedConn.handle("cmd/send-operator-display", async ({ message }) => {
|
|
4016
|
+
return commandChannel.sendOperatorDisplay(message);
|
|
4017
|
+
});
|
|
4018
|
+
typedConn.handle("ping", () => {
|
|
4019
|
+
return { timestamp: Date.now() };
|
|
4020
|
+
});
|
|
4021
|
+
},
|
|
4022
|
+
{ description: "LinuxCNC status monitoring and command execution" }
|
|
4023
|
+
);
|
|
4024
|
+
console.log(`[LinuxCNC] Service exposed as '${SERVICE_NAME}'`);
|
|
4025
|
+
}
|
|
4026
|
+
|
|
4027
|
+
// src/services/gcode.ts
|
|
4028
|
+
var import_gcode = __toESM(require_dist4());
|
|
4029
|
+
var SERVICE_NAME2 = "gcode";
|
|
4030
|
+
function initGCodeService() {
|
|
4031
|
+
worker.appBus.exposeService(
|
|
4032
|
+
SERVICE_NAME2,
|
|
4033
|
+
(connection, { appId: clientAppId }) => {
|
|
4034
|
+
console.log(`[GCode] Client connected: ${clientAppId}`);
|
|
4035
|
+
const typedConn = connection;
|
|
4036
|
+
connection.onClose(() => {
|
|
4037
|
+
console.log(`[GCode] Client disconnected: ${clientAppId}`);
|
|
4038
|
+
});
|
|
4039
|
+
typedConn.handle(
|
|
4040
|
+
"parse",
|
|
4041
|
+
async ({ filepath, iniPath, progressUpdates }) => {
|
|
4042
|
+
try {
|
|
4043
|
+
const result = await (0, import_gcode.parseGCode)(filepath, {
|
|
4044
|
+
iniPath,
|
|
4045
|
+
progressUpdates: progressUpdates ?? 40,
|
|
4046
|
+
onProgress: (progress) => {
|
|
4047
|
+
try {
|
|
4048
|
+
typedConn.send("parse-progress", progress);
|
|
4049
|
+
} catch (err) {
|
|
4050
|
+
console.error("[GCode] Error sending progress:", err);
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
});
|
|
4054
|
+
return result;
|
|
4055
|
+
} catch (err) {
|
|
4056
|
+
typedConn.send("error", {
|
|
4057
|
+
code: "PARSE_ERROR",
|
|
4058
|
+
message: err instanceof Error ? err.message : String(err)
|
|
4059
|
+
});
|
|
4060
|
+
throw err;
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
);
|
|
4064
|
+
typedConn.handle("ping", () => {
|
|
4065
|
+
return { timestamp: Date.now() };
|
|
4066
|
+
});
|
|
4067
|
+
},
|
|
4068
|
+
{ description: "G-code file parsing using LinuxCNC interpreter" }
|
|
4069
|
+
);
|
|
4070
|
+
console.log(`[GCode] Service exposed as '${SERVICE_NAME2}'`);
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
// src/services/hal.ts
|
|
4074
|
+
var import_hal = __toESM(require_dist5());
|
|
4075
|
+
var import_picomatch = __toESM(require_picomatch2());
|
|
4076
|
+
var SERVICE_NAME3 = "hal";
|
|
4077
|
+
function initHalService() {
|
|
4078
|
+
worker.appBus.exposeService(
|
|
4079
|
+
SERVICE_NAME3,
|
|
4080
|
+
(connection, { appId: clientAppId }) => {
|
|
4081
|
+
console.log(`[HAL] Client connected: ${clientAppId}`);
|
|
4082
|
+
const typedConn = connection;
|
|
4083
|
+
const state = {
|
|
4084
|
+
component: null,
|
|
4085
|
+
pins: /* @__PURE__ */ new Map(),
|
|
4086
|
+
params: /* @__PURE__ */ new Map(),
|
|
4087
|
+
lastValues: /* @__PURE__ */ new Map(),
|
|
4088
|
+
cursor: 0,
|
|
4089
|
+
pollInterval: null
|
|
4090
|
+
};
|
|
4091
|
+
connection.onClose(() => {
|
|
4092
|
+
console.log(`[HAL] Client disconnected: ${clientAppId}`);
|
|
4093
|
+
if (state.pollInterval) {
|
|
4094
|
+
clearInterval(state.pollInterval);
|
|
4095
|
+
}
|
|
4096
|
+
if (state.component) {
|
|
4097
|
+
state.component.dispose();
|
|
4098
|
+
}
|
|
4099
|
+
});
|
|
4100
|
+
function startPolling() {
|
|
4101
|
+
if (state.pollInterval) return;
|
|
4102
|
+
state.pollInterval = setInterval(() => {
|
|
4103
|
+
if (!state.component) return;
|
|
4104
|
+
const changes = [];
|
|
4105
|
+
for (const [name, pin] of state.pins) {
|
|
4106
|
+
const value = pin.getValue();
|
|
4107
|
+
const lastValue = state.lastValues.get(name);
|
|
4108
|
+
if (value !== lastValue) {
|
|
4109
|
+
changes.push({ name, value });
|
|
4110
|
+
state.lastValues.set(name, value);
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
for (const [name, param] of state.params) {
|
|
4114
|
+
const value = param.getValue();
|
|
4115
|
+
const lastValue = state.lastValues.get(name);
|
|
4116
|
+
if (value !== lastValue) {
|
|
4117
|
+
changes.push({ name, value });
|
|
4118
|
+
state.lastValues.set(name, value);
|
|
4119
|
+
}
|
|
4120
|
+
}
|
|
4121
|
+
if (changes.length > 0) {
|
|
4122
|
+
state.cursor++;
|
|
4123
|
+
const delta = {
|
|
4124
|
+
changes,
|
|
4125
|
+
cursor: state.cursor,
|
|
4126
|
+
timestamp: Date.now()
|
|
4127
|
+
};
|
|
4128
|
+
try {
|
|
4129
|
+
typedConn.send("items-delta", delta);
|
|
4130
|
+
} catch (err) {
|
|
4131
|
+
console.error("[HAL] Error sending delta:", err);
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4134
|
+
}, 10);
|
|
4135
|
+
}
|
|
4136
|
+
typedConn.handle("component/init", ({ name, prefix }) => {
|
|
4137
|
+
if (state.component) {
|
|
4138
|
+
return {
|
|
4139
|
+
success: false,
|
|
4140
|
+
componentName: "",
|
|
4141
|
+
error: "Component already initialized for this connection"
|
|
4142
|
+
};
|
|
4143
|
+
}
|
|
4144
|
+
try {
|
|
4145
|
+
state.component = new import_hal.HalComponent(name, prefix);
|
|
4146
|
+
return {
|
|
4147
|
+
success: true,
|
|
4148
|
+
componentName: state.component.name
|
|
4149
|
+
};
|
|
4150
|
+
} catch (err) {
|
|
4151
|
+
return {
|
|
4152
|
+
success: false,
|
|
4153
|
+
componentName: "",
|
|
4154
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4155
|
+
};
|
|
4156
|
+
}
|
|
4157
|
+
});
|
|
4158
|
+
typedConn.handle("component/ready", () => {
|
|
4159
|
+
if (!state.component) {
|
|
4160
|
+
return { success: false, error: "Component not initialized" };
|
|
4161
|
+
}
|
|
4162
|
+
try {
|
|
4163
|
+
state.component.ready();
|
|
4164
|
+
startPolling();
|
|
4165
|
+
typedConn.send("hal-ready", {
|
|
4166
|
+
componentName: state.component.name,
|
|
4167
|
+
prefix: state.component.prefix
|
|
4168
|
+
});
|
|
4169
|
+
return { success: true };
|
|
4170
|
+
} catch (err) {
|
|
4171
|
+
return {
|
|
4172
|
+
success: false,
|
|
4173
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4174
|
+
};
|
|
4175
|
+
}
|
|
4176
|
+
});
|
|
4177
|
+
typedConn.handle("component/unready", () => {
|
|
4178
|
+
if (!state.component) {
|
|
4179
|
+
return { success: false, error: "Component not initialized" };
|
|
4180
|
+
}
|
|
4181
|
+
try {
|
|
4182
|
+
state.component.unready();
|
|
4183
|
+
return { success: true };
|
|
4184
|
+
} catch (err) {
|
|
4185
|
+
return {
|
|
4186
|
+
success: false,
|
|
4187
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4188
|
+
};
|
|
4189
|
+
}
|
|
4190
|
+
});
|
|
4191
|
+
typedConn.handle("pin/create", ({ name, type, direction }) => {
|
|
4192
|
+
if (!state.component) {
|
|
4193
|
+
return {
|
|
4194
|
+
success: false,
|
|
4195
|
+
fullName: "",
|
|
4196
|
+
error: "Component not initialized"
|
|
4197
|
+
};
|
|
4198
|
+
}
|
|
4199
|
+
try {
|
|
4200
|
+
const pin = state.component.newPin(name, type, direction);
|
|
4201
|
+
state.pins.set(name, pin);
|
|
4202
|
+
state.lastValues.set(name, pin.getValue());
|
|
4203
|
+
return {
|
|
4204
|
+
success: true,
|
|
4205
|
+
fullName: `${state.component.prefix}.${pin.name}`
|
|
4206
|
+
};
|
|
4207
|
+
} catch (err) {
|
|
4208
|
+
return {
|
|
4209
|
+
success: false,
|
|
4210
|
+
fullName: "",
|
|
4211
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4212
|
+
};
|
|
4213
|
+
}
|
|
4214
|
+
});
|
|
4215
|
+
typedConn.handle("param/create", ({ name, type, direction }) => {
|
|
4216
|
+
if (!state.component) {
|
|
4217
|
+
return {
|
|
4218
|
+
success: false,
|
|
4219
|
+
fullName: "",
|
|
4220
|
+
error: "Component not initialized"
|
|
4221
|
+
};
|
|
4222
|
+
}
|
|
4223
|
+
try {
|
|
4224
|
+
const param = state.component.newParam(name, type, direction);
|
|
4225
|
+
state.params.set(name, param);
|
|
4226
|
+
state.lastValues.set(name, param.getValue());
|
|
4227
|
+
return {
|
|
4228
|
+
success: true,
|
|
4229
|
+
fullName: `${state.component.prefix}.${param.name}`
|
|
4230
|
+
};
|
|
4231
|
+
} catch (err) {
|
|
4232
|
+
return {
|
|
4233
|
+
success: false,
|
|
4234
|
+
fullName: "",
|
|
4235
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4236
|
+
};
|
|
4237
|
+
}
|
|
4238
|
+
});
|
|
4239
|
+
typedConn.handle("item/get-value", ({ name }) => {
|
|
4240
|
+
if (!state.component) {
|
|
4241
|
+
throw new Error("Component not initialized");
|
|
4242
|
+
}
|
|
4243
|
+
const value = state.component.getValue(name);
|
|
4244
|
+
return { value };
|
|
4245
|
+
});
|
|
4246
|
+
typedConn.handle("item/set-value", ({ name, value }) => {
|
|
4247
|
+
if (!state.component) {
|
|
4248
|
+
return { success: false, error: "Component not initialized" };
|
|
4249
|
+
}
|
|
4250
|
+
try {
|
|
4251
|
+
state.component.setValue(name, value);
|
|
4252
|
+
state.lastValues.set(name, value);
|
|
4253
|
+
return { success: true };
|
|
4254
|
+
} catch (err) {
|
|
4255
|
+
return {
|
|
4256
|
+
success: false,
|
|
4257
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4258
|
+
};
|
|
4259
|
+
}
|
|
4260
|
+
});
|
|
4261
|
+
typedConn.handle("items/sync", () => {
|
|
4262
|
+
if (!state.component) {
|
|
4263
|
+
throw new Error("Component not initialized");
|
|
4264
|
+
}
|
|
4265
|
+
const items = {};
|
|
4266
|
+
for (const [name, pin] of state.pins) {
|
|
4267
|
+
items[name] = pin.getValue();
|
|
4268
|
+
}
|
|
4269
|
+
for (const [name, param] of state.params) {
|
|
4270
|
+
items[name] = param.getValue();
|
|
4271
|
+
}
|
|
4272
|
+
return {
|
|
4273
|
+
items,
|
|
4274
|
+
cursor: state.cursor
|
|
4275
|
+
};
|
|
4276
|
+
});
|
|
4277
|
+
typedConn.handle("global/component-exists", ({ componentName }) => {
|
|
4278
|
+
return { exists: import_hal.HalComponent.exists(componentName) };
|
|
4279
|
+
});
|
|
4280
|
+
typedConn.handle("global/component-is-ready", ({ componentName }) => {
|
|
4281
|
+
return { ready: import_hal.HalComponent.isReady(componentName) };
|
|
4282
|
+
});
|
|
4283
|
+
typedConn.handle("global/signal-create", ({ name, type }) => {
|
|
4284
|
+
try {
|
|
4285
|
+
(0, import_hal.newSignal)(name, type);
|
|
4286
|
+
return { success: true };
|
|
4287
|
+
} catch (err) {
|
|
4288
|
+
return {
|
|
4289
|
+
success: false,
|
|
4290
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4291
|
+
};
|
|
4292
|
+
}
|
|
4293
|
+
});
|
|
4294
|
+
typedConn.handle("global/signal-get-value", ({ signalName }) => {
|
|
4295
|
+
const value = (0, import_hal.getValue)(signalName);
|
|
4296
|
+
return { value };
|
|
4297
|
+
});
|
|
4298
|
+
typedConn.handle("global/signal-set-value", ({ signalName, value }) => {
|
|
4299
|
+
try {
|
|
4300
|
+
(0, import_hal.setSignalValue)(signalName, value);
|
|
4301
|
+
return { success: true };
|
|
4302
|
+
} catch (err) {
|
|
4303
|
+
return {
|
|
4304
|
+
success: false,
|
|
4305
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4306
|
+
};
|
|
4307
|
+
}
|
|
4308
|
+
});
|
|
4309
|
+
typedConn.handle("global/signal-connect", ({ pinName, signalName }) => {
|
|
4310
|
+
return { success: false, error: "Not implemented - use halcmd net" };
|
|
4311
|
+
});
|
|
4312
|
+
typedConn.handle("global/signal-disconnect", ({ pinName }) => {
|
|
4313
|
+
return {
|
|
4314
|
+
success: false,
|
|
4315
|
+
error: "Not implemented - use halcmd unlinkp"
|
|
4316
|
+
};
|
|
4317
|
+
});
|
|
4318
|
+
typedConn.handle("global/pin-has-writer", ({ pinName }) => {
|
|
4319
|
+
return { hasWriter: (0, import_hal.pinHasWriter)(pinName) };
|
|
4320
|
+
});
|
|
4321
|
+
typedConn.handle("global/get-value", ({ name }) => {
|
|
4322
|
+
const value = (0, import_hal.getValue)(name);
|
|
4323
|
+
return { value, type: "pin" };
|
|
4324
|
+
});
|
|
4325
|
+
typedConn.handle("global/list-pins", ({ filter }) => {
|
|
4326
|
+
let pins = (0, import_hal.getInfoPins)();
|
|
4327
|
+
if (filter) {
|
|
4328
|
+
const isMatch = (0, import_picomatch.default)(filter);
|
|
4329
|
+
pins = pins.filter((p) => isMatch(p.name));
|
|
4330
|
+
}
|
|
4331
|
+
return { pins };
|
|
4332
|
+
});
|
|
4333
|
+
typedConn.handle("global/list-params", ({ filter }) => {
|
|
4334
|
+
let params = (0, import_hal.getInfoParams)();
|
|
4335
|
+
if (filter) {
|
|
4336
|
+
const isMatch = (0, import_picomatch.default)(filter);
|
|
4337
|
+
params = params.filter((p) => isMatch(p.name));
|
|
4338
|
+
}
|
|
4339
|
+
return { params };
|
|
4340
|
+
});
|
|
4341
|
+
typedConn.handle("global/list-signals", ({ filter }) => {
|
|
4342
|
+
let signals = (0, import_hal.getInfoSignals)();
|
|
4343
|
+
if (filter) {
|
|
4344
|
+
const isMatch = (0, import_picomatch.default)(filter);
|
|
4345
|
+
signals = signals.filter((s) => isMatch(s.name));
|
|
4346
|
+
}
|
|
4347
|
+
return { signals };
|
|
4348
|
+
});
|
|
4349
|
+
typedConn.handle("global/list-all", () => {
|
|
4350
|
+
return {
|
|
4351
|
+
pins: (0, import_hal.getInfoPins)(),
|
|
4352
|
+
params: (0, import_hal.getInfoParams)(),
|
|
4353
|
+
signals: (0, import_hal.getInfoSignals)()
|
|
4354
|
+
};
|
|
4355
|
+
});
|
|
4356
|
+
typedConn.handle("global/msg-level-get", () => {
|
|
4357
|
+
return { level: (0, import_hal.getMsgLevel)() };
|
|
4358
|
+
});
|
|
4359
|
+
typedConn.handle("global/msg-level-set", ({ level }) => {
|
|
4360
|
+
const previousLevel = (0, import_hal.getMsgLevel)();
|
|
4361
|
+
(0, import_hal.setMsgLevel)(level);
|
|
4362
|
+
return { success: true, previousLevel };
|
|
4363
|
+
});
|
|
4364
|
+
typedConn.handle("ping", () => {
|
|
4365
|
+
return { timestamp: Date.now() };
|
|
4366
|
+
});
|
|
4367
|
+
typedConn.handle("get-status", () => {
|
|
4368
|
+
return {
|
|
4369
|
+
connected: true,
|
|
4370
|
+
componentName: state.component?.name ?? "",
|
|
4371
|
+
componentReady: state.component ? import_hal.HalComponent.isReady(state.component.name) : false,
|
|
4372
|
+
pinCount: state.pins.size,
|
|
4373
|
+
paramCount: state.params.size,
|
|
4374
|
+
uptime: process.uptime()
|
|
4375
|
+
};
|
|
4376
|
+
});
|
|
4377
|
+
},
|
|
4378
|
+
{ description: "HAL component management and I/O access" }
|
|
4379
|
+
);
|
|
4380
|
+
console.log(`[HAL] Service exposed as '${SERVICE_NAME3}'`);
|
|
4381
|
+
}
|
|
4382
|
+
|
|
4383
|
+
// src/services/position-logger.ts
|
|
4384
|
+
var import_core2 = __toESM(require_dist3());
|
|
4385
|
+
var import_types = __toESM(require_dist2());
|
|
4386
|
+
var SERVICE_NAME4 = "position-logger";
|
|
4387
|
+
var UPDATE_INTERVAL_MS = 50;
|
|
4388
|
+
var logger = null;
|
|
4389
|
+
var cursor = 0;
|
|
4390
|
+
var lastHistoryCount = 0;
|
|
4391
|
+
var connections2 = /* @__PURE__ */ new Map();
|
|
4392
|
+
var updateInterval = null;
|
|
4393
|
+
function startUpdateLoop() {
|
|
4394
|
+
if (updateInterval) return;
|
|
4395
|
+
updateInterval = setInterval(() => {
|
|
4396
|
+
if (!logger || connections2.size === 0) return;
|
|
4397
|
+
const currentCount = logger.getHistoryCount();
|
|
4398
|
+
if (currentCount <= lastHistoryCount) return;
|
|
4399
|
+
const newPointCount = currentCount - lastHistoryCount;
|
|
4400
|
+
const newPoints = logger.getMotionHistory(lastHistoryCount, newPointCount);
|
|
4401
|
+
cursor++;
|
|
4402
|
+
lastHistoryCount = currentCount;
|
|
4403
|
+
const message = {
|
|
4404
|
+
points: newPoints,
|
|
4405
|
+
count: newPointCount,
|
|
4406
|
+
cursor
|
|
4407
|
+
};
|
|
4408
|
+
for (const conn of connections2.values()) {
|
|
4409
|
+
try {
|
|
4410
|
+
conn.send("position-update", message);
|
|
4411
|
+
} catch (err) {
|
|
4412
|
+
console.error("[PositionLogger] Error sending update:", err);
|
|
4413
|
+
}
|
|
4414
|
+
}
|
|
4415
|
+
}, UPDATE_INTERVAL_MS);
|
|
4416
|
+
}
|
|
4417
|
+
function stopUpdateLoop() {
|
|
4418
|
+
if (updateInterval) {
|
|
4419
|
+
clearInterval(updateInterval);
|
|
4420
|
+
updateInterval = null;
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
function initPositionLoggerService() {
|
|
4424
|
+
logger = new import_core2.PositionLogger();
|
|
4425
|
+
worker.appBus.exposeService(
|
|
4426
|
+
SERVICE_NAME4,
|
|
4427
|
+
(connection, { appId: clientAppId }) => {
|
|
4428
|
+
console.log(`[PositionLogger] Client connected: ${clientAppId}`);
|
|
4429
|
+
const typedConn = connection;
|
|
4430
|
+
connections2.set(clientAppId, typedConn);
|
|
4431
|
+
connection.onClose(() => {
|
|
4432
|
+
console.log(`[PositionLogger] Client disconnected: ${clientAppId}`);
|
|
4433
|
+
connections2.delete(clientAppId);
|
|
4434
|
+
if (connections2.size === 0) {
|
|
4435
|
+
stopUpdateLoop();
|
|
4436
|
+
}
|
|
4437
|
+
});
|
|
4438
|
+
typedConn.handle("start", ({ interval, maxHistory }) => {
|
|
4439
|
+
if (!logger) {
|
|
4440
|
+
return { success: false, cursor: 0 };
|
|
4441
|
+
}
|
|
4442
|
+
logger.start({
|
|
4443
|
+
interval: interval ?? 0.01,
|
|
4444
|
+
maxHistorySize: maxHistory ?? 1e4
|
|
4445
|
+
});
|
|
4446
|
+
lastHistoryCount = 0;
|
|
4447
|
+
cursor++;
|
|
4448
|
+
startUpdateLoop();
|
|
4449
|
+
return { success: true, cursor };
|
|
4450
|
+
});
|
|
4451
|
+
typedConn.handle("stop", () => {
|
|
4452
|
+
if (!logger) {
|
|
4453
|
+
return { success: false };
|
|
4454
|
+
}
|
|
4455
|
+
logger.stop();
|
|
4456
|
+
return { success: true };
|
|
4457
|
+
});
|
|
4458
|
+
typedConn.handle("clear", () => {
|
|
4459
|
+
if (!logger) {
|
|
4460
|
+
return { success: false };
|
|
4461
|
+
}
|
|
4462
|
+
logger.clear();
|
|
4463
|
+
lastHistoryCount = 0;
|
|
4464
|
+
cursor++;
|
|
4465
|
+
return { success: true };
|
|
4466
|
+
});
|
|
4467
|
+
typedConn.handle("sync", () => {
|
|
4468
|
+
if (!logger) {
|
|
4469
|
+
return {
|
|
4470
|
+
history: new Float64Array(0),
|
|
4471
|
+
count: 0,
|
|
4472
|
+
cursor: 0
|
|
4473
|
+
};
|
|
4474
|
+
}
|
|
4475
|
+
const currentCount = logger.getHistoryCount();
|
|
4476
|
+
const history = logger.getMotionHistory(0, currentCount);
|
|
4477
|
+
return {
|
|
4478
|
+
history,
|
|
4479
|
+
count: history.length / import_types.POSITION_STRIDE,
|
|
4480
|
+
cursor
|
|
4481
|
+
};
|
|
4482
|
+
});
|
|
4483
|
+
typedConn.handle("get-current", () => {
|
|
4484
|
+
if (!logger) {
|
|
4485
|
+
return { position: null };
|
|
4486
|
+
}
|
|
4487
|
+
const position = logger.getCurrentPosition();
|
|
4488
|
+
return { position };
|
|
4489
|
+
});
|
|
4490
|
+
typedConn.handle("get-cursor", () => {
|
|
4491
|
+
return { cursor };
|
|
4492
|
+
});
|
|
4493
|
+
typedConn.handle("ping", () => {
|
|
4494
|
+
return { timestamp: Date.now() };
|
|
4495
|
+
});
|
|
4496
|
+
},
|
|
4497
|
+
{ description: "Machine position logging and history streaming" }
|
|
4498
|
+
);
|
|
4499
|
+
console.log(`[PositionLogger] Service exposed as '${SERVICE_NAME4}'`);
|
|
4500
|
+
}
|
|
4501
|
+
|
|
4502
|
+
// src/backend.ts
|
|
4503
|
+
var appId = process.env.EDEN_APP_ID;
|
|
12
4504
|
console.log(`[Covenant Bridge] Starting for ${appId}`);
|
|
13
|
-
// Initialize all services
|
|
14
4505
|
initLinuxCNCService();
|
|
15
4506
|
initGCodeService();
|
|
16
4507
|
initHalService();
|