@tsplc/tmp-debug 0.0.0-stage → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/dist/api.js +744 -0
- package/dist/api.js.map +12 -0
- package/dist/constant.js +33 -0
- package/dist/constant.js.map +10 -0
- package/dist/explain-file.js +468 -0
- package/dist/explain-file.js.map +11 -0
- package/dist/explain.js +1310 -0
- package/dist/explain.js.map +19 -0
- package/dist/format.js +214 -0
- package/dist/format.js.map +12 -0
- package/dist/index.js +4066 -0
- package/dist/index.js.map +44 -0
- package/dist/manifest.js +240 -0
- package/dist/manifest.js.map +10 -0
- package/dist/paths.js +242 -0
- package/dist/paths.js.map +10 -0
- package/package.json +72 -4
- package/src/adapter.ts +77 -0
- package/src/api.ts +446 -0
- package/src/app-server.ts +151 -0
- package/src/build-files.ts +46 -0
- package/src/constant.ts +41 -0
- package/src/debugger.ts +237 -0
- package/src/errors.ts +13 -0
- package/src/explain-expressions.ts +484 -0
- package/src/explain-file.ts +325 -0
- package/src/explain-frames.ts +155 -0
- package/src/explain-loops.ts +151 -0
- package/src/explain-operations.ts +232 -0
- package/src/explain-tables.ts +345 -0
- package/src/explain-value.ts +203 -0
- package/src/explain-verdicts.ts +548 -0
- package/src/explain.ts +82 -0
- package/src/hardware.ts +159 -0
- package/src/http.ts +218 -0
- package/src/index.ts +44 -0
- package/src/jobs.ts +139 -0
- package/src/login-value.ts +165 -0
- package/src/login.ts +315 -0
- package/src/manifest.ts +328 -0
- package/src/opcua.ts +80 -0
- package/src/paths.ts +363 -0
- package/src/requests.ts +99 -0
- package/src/server-cursor.ts +22 -0
- package/src/shown.ts +229 -0
- package/src/telemetry.ts +125 -0
- package/src/timeline.ts +148 -0
- package/src/trace.ts +62 -0
- package/src/ui/bits.ts +48 -0
- package/src/ui/client.ts +87 -0
- package/src/ui/dom.ts +61 -0
- package/src/ui/explain-read.ts +105 -0
- package/src/ui/format.ts +261 -0
- package/src/ui/hardware.ts +425 -0
- package/src/ui/header.ts +207 -0
- package/src/ui/health.ts +64 -0
- package/src/ui/index.ts +27 -0
- package/src/ui/jobs.ts +263 -0
- package/src/ui/links.ts +59 -0
- package/src/ui/live-value.ts +85 -0
- package/src/ui/main.ts +76 -0
- package/src/ui/overview.ts +178 -0
- package/src/ui/page.ts +286 -0
- package/src/ui/pages.ts +64 -0
- package/src/ui/recent-window.ts +49 -0
- package/src/ui/recent.ts +355 -0
- package/src/ui/request-trace.ts +38 -0
- package/src/ui/requests.ts +80 -0
- package/src/ui/routes.ts +98 -0
- package/src/ui/store.ts +295 -0
- package/src/ui/success-cache.ts +11 -0
- package/src/ui/tree.ts +162 -0
- package/src/ui/variables.ts +597 -0
- package/src/ui/why-watch.ts +11 -0
- package/src/ui/why.ts +694 -0
- package/src/values.ts +170 -0
- package/src/watch.ts +32 -0
package/dist/api.js
ADDED
|
@@ -0,0 +1,744 @@
|
|
|
1
|
+
// packages/debug/src/api.ts
|
|
2
|
+
import { qualitySchema } from "@tsplc/opcua/contract";
|
|
3
|
+
import { serviceCall } from "@tsplc/server/requests";
|
|
4
|
+
import { appRecord } from "@tsplc/server/telemetry";
|
|
5
|
+
import { z as z3 } from "zod";
|
|
6
|
+
|
|
7
|
+
// packages/debug/src/explain-file.ts
|
|
8
|
+
import {
|
|
9
|
+
valueBinaryOperators,
|
|
10
|
+
valueUnaryOperators
|
|
11
|
+
} from "@tsplc/iec/arithmetic";
|
|
12
|
+
import { z as z2 } from "zod";
|
|
13
|
+
|
|
14
|
+
// packages/debug/src/manifest.ts
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
var sourceRange = z.object({
|
|
17
|
+
file: z.number().int(),
|
|
18
|
+
line: z.number().int(),
|
|
19
|
+
column: z.number().int(),
|
|
20
|
+
endLine: z.number().int(),
|
|
21
|
+
endColumn: z.number().int()
|
|
22
|
+
});
|
|
23
|
+
var json = z.lazy(() => z.union([
|
|
24
|
+
z.string(),
|
|
25
|
+
z.number(),
|
|
26
|
+
z.boolean(),
|
|
27
|
+
z.null(),
|
|
28
|
+
z.array(json),
|
|
29
|
+
z.record(z.string(), json)
|
|
30
|
+
]));
|
|
31
|
+
var debugField = z.object({
|
|
32
|
+
name: z.string(),
|
|
33
|
+
target: z.string(),
|
|
34
|
+
type: z.string(),
|
|
35
|
+
declaration: sourceRange.optional(),
|
|
36
|
+
generated: z.literal(true).optional()
|
|
37
|
+
});
|
|
38
|
+
var debugType = z.discriminatedUnion("kind", [
|
|
39
|
+
z.object({
|
|
40
|
+
kind: z.literal("scalar"),
|
|
41
|
+
iec: z.string(),
|
|
42
|
+
capacity: z.number().int().optional()
|
|
43
|
+
}),
|
|
44
|
+
z.object({
|
|
45
|
+
kind: z.literal("enum"),
|
|
46
|
+
name: z.string(),
|
|
47
|
+
members: z.record(z.string(), z.number().int()),
|
|
48
|
+
texts: z.record(z.string(), z.string()).optional()
|
|
49
|
+
}),
|
|
50
|
+
z.object({
|
|
51
|
+
kind: z.literal("record"),
|
|
52
|
+
name: z.string(),
|
|
53
|
+
declaration: sourceRange.optional(),
|
|
54
|
+
fields: z.array(debugField)
|
|
55
|
+
}),
|
|
56
|
+
z.object({
|
|
57
|
+
kind: z.literal("array"),
|
|
58
|
+
element: z.string(),
|
|
59
|
+
length: z.number().int(),
|
|
60
|
+
lower: z.number().int(),
|
|
61
|
+
index: z.string().optional()
|
|
62
|
+
})
|
|
63
|
+
]);
|
|
64
|
+
var debugRoot = z.object({
|
|
65
|
+
path: z.string(),
|
|
66
|
+
target: z.string(),
|
|
67
|
+
type: z.string(),
|
|
68
|
+
declaration: sourceRange.optional(),
|
|
69
|
+
readable: z.boolean(),
|
|
70
|
+
generated: z.literal(true).optional()
|
|
71
|
+
});
|
|
72
|
+
var debugConstant = z.object({
|
|
73
|
+
path: z.string(),
|
|
74
|
+
type: z.string(),
|
|
75
|
+
value: json,
|
|
76
|
+
declaration: sourceRange.optional()
|
|
77
|
+
});
|
|
78
|
+
var debugIo = z.object({
|
|
79
|
+
path: z.string(),
|
|
80
|
+
target: z.string(),
|
|
81
|
+
direction: z.enum(["input", "output"]),
|
|
82
|
+
type: z.string(),
|
|
83
|
+
device: z.string().optional(),
|
|
84
|
+
channel: z.string().optional(),
|
|
85
|
+
address: z.string().optional(),
|
|
86
|
+
inverted: z.literal(true).optional(),
|
|
87
|
+
shared: z.literal(true).optional()
|
|
88
|
+
});
|
|
89
|
+
var debugChannel = z.object({
|
|
90
|
+
id: z.string(),
|
|
91
|
+
name: z.string(),
|
|
92
|
+
direction: z.enum(["input", "output"]),
|
|
93
|
+
type: z.string(),
|
|
94
|
+
offsetBits: z.number().int(),
|
|
95
|
+
bits: z.number().int(),
|
|
96
|
+
address: z.string().optional(),
|
|
97
|
+
unit: z.string().optional(),
|
|
98
|
+
description: z.string().optional()
|
|
99
|
+
});
|
|
100
|
+
var debugDevice = z.object({
|
|
101
|
+
id: z.string(),
|
|
102
|
+
product: z.string().optional(),
|
|
103
|
+
vendor: z.string().optional(),
|
|
104
|
+
productCode: z.string().optional(),
|
|
105
|
+
network: z.object({ address: z.string(), rpiMs: z.number().optional() }).optional(),
|
|
106
|
+
connection: z.string().optional(),
|
|
107
|
+
assemblies: z.array(z.object({
|
|
108
|
+
direction: z.enum(["input", "output"]),
|
|
109
|
+
bytes: z.number().int(),
|
|
110
|
+
address: z.string().optional(),
|
|
111
|
+
raw: z.string().optional()
|
|
112
|
+
})),
|
|
113
|
+
health: z.object({
|
|
114
|
+
state: z.string().optional(),
|
|
115
|
+
states: z.record(z.string(), z.number().int()).optional(),
|
|
116
|
+
diagnostic: z.string().optional(),
|
|
117
|
+
message: z.string().optional()
|
|
118
|
+
}).optional(),
|
|
119
|
+
status: z.record(z.string(), z.string()).optional(),
|
|
120
|
+
channels: z.array(debugChannel)
|
|
121
|
+
});
|
|
122
|
+
var debugFunction = z.object({
|
|
123
|
+
id: z.number().int(),
|
|
124
|
+
name: z.string(),
|
|
125
|
+
declaration: sourceRange,
|
|
126
|
+
instance: z.string().optional(),
|
|
127
|
+
task: z.string().optional(),
|
|
128
|
+
target: z.string(),
|
|
129
|
+
reads: z.array(z.object({ range: sourceRange, path: z.string() }))
|
|
130
|
+
});
|
|
131
|
+
var jobStateFields = {
|
|
132
|
+
step: "UINT",
|
|
133
|
+
cancelling: "BOOL",
|
|
134
|
+
busy: "BOOL",
|
|
135
|
+
done: "BOOL",
|
|
136
|
+
error: "UDINT"
|
|
137
|
+
};
|
|
138
|
+
var instrumentationFields = {
|
|
139
|
+
busy: jobStateFields.busy,
|
|
140
|
+
step: jobStateFields.step,
|
|
141
|
+
startedAt: "UDINT",
|
|
142
|
+
job: "UDINT",
|
|
143
|
+
sequence: "UDINT"
|
|
144
|
+
};
|
|
145
|
+
var debugJob = z.object({
|
|
146
|
+
id: z.number().int(),
|
|
147
|
+
name: z.string(),
|
|
148
|
+
declaration: sourceRange,
|
|
149
|
+
instance: z.string().optional(),
|
|
150
|
+
target: z.string(),
|
|
151
|
+
steps: z.array(z.object({
|
|
152
|
+
step: z.number().int(),
|
|
153
|
+
kind: z.enum(["await", "return", "throw", "statement"]),
|
|
154
|
+
range: sourceRange,
|
|
155
|
+
text: z.string()
|
|
156
|
+
})),
|
|
157
|
+
startedAt: z.string().optional(),
|
|
158
|
+
requests: z.array(z.object({
|
|
159
|
+
service: z.string(),
|
|
160
|
+
target: z.string(),
|
|
161
|
+
sequence: z.string(),
|
|
162
|
+
job: z.number().int().optional()
|
|
163
|
+
})),
|
|
164
|
+
generated: z.literal(true).optional()
|
|
165
|
+
});
|
|
166
|
+
var debugEventSite = z.object({
|
|
167
|
+
id: z.number().int(),
|
|
168
|
+
kind: z.enum(["state", "decision", "job"]),
|
|
169
|
+
job: z.number().int().optional(),
|
|
170
|
+
phase: z.enum(["started", "finished"]).optional(),
|
|
171
|
+
path: z.string(),
|
|
172
|
+
function: z.number().int().optional(),
|
|
173
|
+
type: z.string(),
|
|
174
|
+
range: sourceRange,
|
|
175
|
+
text: z.string(),
|
|
176
|
+
task: z.string(),
|
|
177
|
+
operands: z.array(z.object({
|
|
178
|
+
text: z.string(),
|
|
179
|
+
range: sourceRange,
|
|
180
|
+
type: z.string(),
|
|
181
|
+
path: z.string().optional(),
|
|
182
|
+
stable: z.boolean()
|
|
183
|
+
}))
|
|
184
|
+
});
|
|
185
|
+
var debugWriter = z.object({
|
|
186
|
+
output: z.string(),
|
|
187
|
+
target: z.string(),
|
|
188
|
+
exact: z.boolean().optional(),
|
|
189
|
+
sites: z.array(z.object({
|
|
190
|
+
id: z.number().int(),
|
|
191
|
+
range: sourceRange,
|
|
192
|
+
function: z.number().int(),
|
|
193
|
+
assignments: z.array(z.number().int()).optional()
|
|
194
|
+
}))
|
|
195
|
+
});
|
|
196
|
+
var debugTask = z.object({
|
|
197
|
+
name: z.string(),
|
|
198
|
+
intervalMs: z.number(),
|
|
199
|
+
priority: z.number().int(),
|
|
200
|
+
clock: z.string().optional()
|
|
201
|
+
});
|
|
202
|
+
var debugManifest = z.object({
|
|
203
|
+
kind: z.literal("tsplc-debug"),
|
|
204
|
+
version: z.literal(1),
|
|
205
|
+
build: z.object({
|
|
206
|
+
id: z.string(),
|
|
207
|
+
target: z.string(),
|
|
208
|
+
compiler: z.string()
|
|
209
|
+
}),
|
|
210
|
+
sources: z.array(z.string()),
|
|
211
|
+
types: z.record(z.string(), debugType),
|
|
212
|
+
roots: z.array(debugRoot),
|
|
213
|
+
constants: z.array(debugConstant),
|
|
214
|
+
io: z.array(debugIo),
|
|
215
|
+
devices: z.array(debugDevice),
|
|
216
|
+
functions: z.array(debugFunction),
|
|
217
|
+
jobs: z.array(debugJob),
|
|
218
|
+
events: z.array(debugEventSite),
|
|
219
|
+
writers: z.array(debugWriter),
|
|
220
|
+
tasks: z.array(debugTask),
|
|
221
|
+
errors: z.record(z.string(), z.string()),
|
|
222
|
+
explain: z.object({ sha256: z.string() }).optional()
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// packages/debug/src/explain-file.ts
|
|
226
|
+
var tableIndex = z2.number().int().nonnegative();
|
|
227
|
+
var position = z2.number().int().nonnegative();
|
|
228
|
+
var explainExpression = z2.discriminatedUnion("kind", [
|
|
229
|
+
z2.object({
|
|
230
|
+
kind: z2.literal("read"),
|
|
231
|
+
path: tableIndex,
|
|
232
|
+
capturedAt: position,
|
|
233
|
+
interleaved: z2.literal(true).optional(),
|
|
234
|
+
type: z2.string()
|
|
235
|
+
}),
|
|
236
|
+
z2.object({
|
|
237
|
+
kind: z2.literal("pattern"),
|
|
238
|
+
path: tableIndex,
|
|
239
|
+
indexes: z2.array(tableIndex),
|
|
240
|
+
capturedAt: position,
|
|
241
|
+
interleaved: z2.literal(true).optional(),
|
|
242
|
+
type: z2.string()
|
|
243
|
+
}),
|
|
244
|
+
z2.object({ kind: z2.literal("constant"), value: json, type: z2.string() }),
|
|
245
|
+
z2.object({
|
|
246
|
+
kind: z2.literal("record"),
|
|
247
|
+
fields: z2.record(z2.string(), tableIndex),
|
|
248
|
+
type: z2.string()
|
|
249
|
+
}),
|
|
250
|
+
z2.object({
|
|
251
|
+
kind: z2.literal("array"),
|
|
252
|
+
lower: z2.number().int(),
|
|
253
|
+
items: z2.array(tableIndex),
|
|
254
|
+
type: z2.string()
|
|
255
|
+
}),
|
|
256
|
+
z2.object({
|
|
257
|
+
kind: z2.literal("local"),
|
|
258
|
+
local: tableIndex,
|
|
259
|
+
path: z2.array(z2.string()),
|
|
260
|
+
at: position,
|
|
261
|
+
type: z2.string()
|
|
262
|
+
}),
|
|
263
|
+
z2.object({
|
|
264
|
+
kind: z2.literal("parameter"),
|
|
265
|
+
parameter: z2.number().int().nonnegative(),
|
|
266
|
+
path: z2.array(z2.string()),
|
|
267
|
+
at: position,
|
|
268
|
+
local: tableIndex.nullable(),
|
|
269
|
+
type: z2.string()
|
|
270
|
+
}),
|
|
271
|
+
z2.object({
|
|
272
|
+
kind: z2.literal("call"),
|
|
273
|
+
call: tableIndex,
|
|
274
|
+
path: z2.array(z2.string()),
|
|
275
|
+
type: z2.string()
|
|
276
|
+
}),
|
|
277
|
+
z2.object({ kind: z2.literal("clock"), type: z2.string() }),
|
|
278
|
+
z2.object({ kind: z2.literal("reference"), operand: tableIndex }),
|
|
279
|
+
z2.object({
|
|
280
|
+
kind: z2.literal("unary"),
|
|
281
|
+
operator: z2.enum(valueUnaryOperators),
|
|
282
|
+
operand: tableIndex,
|
|
283
|
+
type: z2.string()
|
|
284
|
+
}),
|
|
285
|
+
z2.object({
|
|
286
|
+
kind: z2.literal("binary"),
|
|
287
|
+
operator: z2.enum(valueBinaryOperators),
|
|
288
|
+
policy: z2.enum(["wrap", "saturate"]).optional(),
|
|
289
|
+
left: tableIndex,
|
|
290
|
+
right: tableIndex,
|
|
291
|
+
type: z2.string()
|
|
292
|
+
}),
|
|
293
|
+
z2.object({
|
|
294
|
+
kind: z2.literal("convert"),
|
|
295
|
+
policy: z2.enum(["exact", "wrap", "saturate"]),
|
|
296
|
+
operand: tableIndex,
|
|
297
|
+
type: z2.string()
|
|
298
|
+
}),
|
|
299
|
+
z2.object({
|
|
300
|
+
kind: z2.literal("logical"),
|
|
301
|
+
operator: z2.enum(["and", "or"]),
|
|
302
|
+
left: tableIndex,
|
|
303
|
+
right: tableIndex
|
|
304
|
+
}),
|
|
305
|
+
z2.object({
|
|
306
|
+
kind: z2.literal("select"),
|
|
307
|
+
condition: tableIndex,
|
|
308
|
+
then: tableIndex,
|
|
309
|
+
else: tableIndex,
|
|
310
|
+
type: z2.string()
|
|
311
|
+
}),
|
|
312
|
+
z2.object({
|
|
313
|
+
kind: z2.literal("opaque"),
|
|
314
|
+
text: tableIndex,
|
|
315
|
+
reads: z2.array(tableIndex),
|
|
316
|
+
type: z2.string()
|
|
317
|
+
})
|
|
318
|
+
]);
|
|
319
|
+
var exitsCondition = z2.object({
|
|
320
|
+
kind: z2.literal("exits"),
|
|
321
|
+
get any() {
|
|
322
|
+
return z2.array(z2.array(explainCondition));
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
var explainCondition = z2.union([
|
|
326
|
+
z2.object({
|
|
327
|
+
kind: z2.literal("test"),
|
|
328
|
+
test: tableIndex,
|
|
329
|
+
holds: z2.boolean(),
|
|
330
|
+
at: position,
|
|
331
|
+
text: tableIndex.nullable()
|
|
332
|
+
}),
|
|
333
|
+
z2.object({
|
|
334
|
+
kind: z2.literal("cases"),
|
|
335
|
+
test: tableIndex,
|
|
336
|
+
values: z2.array(json),
|
|
337
|
+
member: z2.boolean(),
|
|
338
|
+
at: position,
|
|
339
|
+
text: tableIndex.nullable()
|
|
340
|
+
}),
|
|
341
|
+
exitsCondition,
|
|
342
|
+
z2.object({ kind: z2.literal("loop"), loop: tableIndex }),
|
|
343
|
+
z2.object({ kind: z2.literal("loopReturns"), loop: tableIndex }),
|
|
344
|
+
z2.object({ kind: z2.literal("job"), step: z2.number().int() }),
|
|
345
|
+
z2.object({ kind: z2.literal("jobBusy") })
|
|
346
|
+
]);
|
|
347
|
+
var record = {
|
|
348
|
+
routine: tableIndex,
|
|
349
|
+
position,
|
|
350
|
+
conditions: tableIndex.nullable(),
|
|
351
|
+
site: tableIndex.nullable()
|
|
352
|
+
};
|
|
353
|
+
var written = z2.discriminatedUnion("kind", [
|
|
354
|
+
z2.object({ kind: z2.literal("path"), path: tableIndex }),
|
|
355
|
+
z2.object({
|
|
356
|
+
kind: z2.literal("pattern"),
|
|
357
|
+
path: tableIndex,
|
|
358
|
+
indexes: z2.array(tableIndex)
|
|
359
|
+
})
|
|
360
|
+
]);
|
|
361
|
+
var explainAssignment = z2.object({
|
|
362
|
+
...record,
|
|
363
|
+
kind: z2.enum(["assign", "call", "block", "input", "return", "counter"]),
|
|
364
|
+
writes: written,
|
|
365
|
+
whole: z2.boolean(),
|
|
366
|
+
value: tableIndex.nullable(),
|
|
367
|
+
block: z2.object({
|
|
368
|
+
kind: z2.string(),
|
|
369
|
+
inputs: z2.record(z2.string(), tableIndex),
|
|
370
|
+
elapsed: tableIndex.nullable()
|
|
371
|
+
}).nullable(),
|
|
372
|
+
via: z2.array(tableIndex),
|
|
373
|
+
loop: tableIndex.nullable()
|
|
374
|
+
});
|
|
375
|
+
var explainLocal = z2.object({
|
|
376
|
+
routine: tableIndex,
|
|
377
|
+
name: z2.string(),
|
|
378
|
+
parameter: z2.boolean(),
|
|
379
|
+
reference: z2.boolean(),
|
|
380
|
+
definitions: z2.array(z2.object({
|
|
381
|
+
...record,
|
|
382
|
+
kind: z2.enum(["assign", "borrowed", "counter"]),
|
|
383
|
+
path: z2.array(z2.string()),
|
|
384
|
+
value: tableIndex.nullable(),
|
|
385
|
+
call: tableIndex.nullable(),
|
|
386
|
+
loop: tableIndex.nullable()
|
|
387
|
+
}))
|
|
388
|
+
});
|
|
389
|
+
var explainCall = z2.object({
|
|
390
|
+
...record,
|
|
391
|
+
callee: z2.string(),
|
|
392
|
+
receiver: z2.discriminatedUnion("kind", [
|
|
393
|
+
z2.object({ kind: z2.literal("none") }),
|
|
394
|
+
z2.object({ kind: z2.literal("path"), path: tableIndex }),
|
|
395
|
+
z2.object({
|
|
396
|
+
kind: z2.literal("pattern"),
|
|
397
|
+
path: tableIndex,
|
|
398
|
+
indexes: z2.array(tableIndex)
|
|
399
|
+
})
|
|
400
|
+
]),
|
|
401
|
+
arguments: z2.array(tableIndex),
|
|
402
|
+
loop: tableIndex.nullable()
|
|
403
|
+
});
|
|
404
|
+
var explainFlags = z2.object({
|
|
405
|
+
path: tableIndex,
|
|
406
|
+
input: z2.number().int().nullable(),
|
|
407
|
+
clientWritable: z2.boolean(),
|
|
408
|
+
hmiControl: z2.string().nullable(),
|
|
409
|
+
retained: z2.boolean(),
|
|
410
|
+
constantTable: z2.boolean(),
|
|
411
|
+
writerTasks: z2.array(z2.string()),
|
|
412
|
+
service: z2.object({ job: z2.number().int(), service: z2.string() }).nullable(),
|
|
413
|
+
initial: json.nullable(),
|
|
414
|
+
reference: z2.boolean()
|
|
415
|
+
});
|
|
416
|
+
var explainFile = z2.object({
|
|
417
|
+
kind: z2.literal("tsplc-explain"),
|
|
418
|
+
version: z2.literal(1),
|
|
419
|
+
paths: z2.array(z2.string()),
|
|
420
|
+
texts: z2.array(z2.string()),
|
|
421
|
+
expressions: z2.array(explainExpression),
|
|
422
|
+
conditions: z2.array(z2.object({ parent: tableIndex.nullable(), condition: explainCondition })),
|
|
423
|
+
sites: z2.array(z2.object({ range: sourceRange, text: tableIndex.nullable() })),
|
|
424
|
+
routines: z2.array(z2.object({
|
|
425
|
+
key: z2.string(),
|
|
426
|
+
function: z2.number().int().nullable(),
|
|
427
|
+
instance: tableIndex.nullable(),
|
|
428
|
+
name: z2.string(),
|
|
429
|
+
declaration: sourceRange.nullable(),
|
|
430
|
+
job: z2.number().int().nullable(),
|
|
431
|
+
paths: z2.array(tableIndex),
|
|
432
|
+
locals: z2.array(tableIndex),
|
|
433
|
+
calls: z2.array(tableIndex),
|
|
434
|
+
loops: z2.array(tableIndex)
|
|
435
|
+
})),
|
|
436
|
+
loops: z2.array(z2.object({
|
|
437
|
+
routine: tableIndex,
|
|
438
|
+
position,
|
|
439
|
+
counter: tableIndex,
|
|
440
|
+
first: tableIndex,
|
|
441
|
+
limit: tableIndex,
|
|
442
|
+
exclusive: z2.boolean(),
|
|
443
|
+
step: tableIndex,
|
|
444
|
+
maxIterations: z2.number().int().nonnegative(),
|
|
445
|
+
breaks: z2.array(z2.array(explainCondition)),
|
|
446
|
+
parent: tableIndex.nullable(),
|
|
447
|
+
site: tableIndex.nullable()
|
|
448
|
+
})),
|
|
449
|
+
assignments: z2.array(explainAssignment),
|
|
450
|
+
locals: z2.array(explainLocal),
|
|
451
|
+
returns: z2.array(z2.object({ ...record, value: tableIndex.nullable() })),
|
|
452
|
+
calls: z2.array(explainCall),
|
|
453
|
+
entries: z2.array(z2.object({
|
|
454
|
+
routine: tableIndex,
|
|
455
|
+
task: z2.string(),
|
|
456
|
+
order: z2.number().int().nonnegative()
|
|
457
|
+
})),
|
|
458
|
+
flags: z2.array(explainFlags),
|
|
459
|
+
references: z2.record(z2.string(), tableIndex)
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
// packages/debug/src/api.ts
|
|
463
|
+
import { qualitySchema as qualitySchema2 } from "@tsplc/opcua/contract";
|
|
464
|
+
var dashboardHeader = "x-tsplc-dashboard";
|
|
465
|
+
var tokenQueryParameter = "token";
|
|
466
|
+
var errorBodySchema = z3.object({ error: z3.string() });
|
|
467
|
+
var sampleSchema = z3.object({
|
|
468
|
+
path: z3.string(),
|
|
469
|
+
value: z3.unknown(),
|
|
470
|
+
quality: qualitySchema,
|
|
471
|
+
status: z3.string(),
|
|
472
|
+
receivedAt: z3.string(),
|
|
473
|
+
read: z3.number().int().optional()
|
|
474
|
+
});
|
|
475
|
+
var connectionStateSchema = z3.enum([
|
|
476
|
+
"connecting",
|
|
477
|
+
"connected",
|
|
478
|
+
"lost",
|
|
479
|
+
"failed",
|
|
480
|
+
"unavailable"
|
|
481
|
+
]);
|
|
482
|
+
var sessionSchema = z3.object({
|
|
483
|
+
build: z3.object({
|
|
484
|
+
manifest: z3.string().nullable(),
|
|
485
|
+
controller: z3.string().nullable(),
|
|
486
|
+
matches: z3.boolean()
|
|
487
|
+
}),
|
|
488
|
+
connection: z3.object({
|
|
489
|
+
state: connectionStateSchema,
|
|
490
|
+
since: z3.string(),
|
|
491
|
+
endpoint: z3.string(),
|
|
492
|
+
error: z3.string().optional()
|
|
493
|
+
}),
|
|
494
|
+
reading: z3.object({ method: z3.string(), intervalMs: z3.number() }),
|
|
495
|
+
tasks: z3.array(z3.object({
|
|
496
|
+
name: z3.string(),
|
|
497
|
+
scan: z3.number().nullable(),
|
|
498
|
+
scansPerSecond: z3.number().nullable(),
|
|
499
|
+
dropped: z3.number()
|
|
500
|
+
})),
|
|
501
|
+
clock: z3.object({ offsetMs: z3.number(), uncertaintyMs: z3.number() }).nullable(),
|
|
502
|
+
release: z3.object({ id: z3.string(), deployedAt: z3.string(), operation: z3.string() }).optional(),
|
|
503
|
+
projectRoot: z3.string().optional()
|
|
504
|
+
});
|
|
505
|
+
var traceEventSchema = z3.object({
|
|
506
|
+
sequence: z3.number(),
|
|
507
|
+
task: z3.string(),
|
|
508
|
+
scan: z3.number(),
|
|
509
|
+
plcTime: z3.number(),
|
|
510
|
+
site: z3.number(),
|
|
511
|
+
value: z3.unknown(),
|
|
512
|
+
operands: z3.array(z3.object({
|
|
513
|
+
text: z3.string(),
|
|
514
|
+
path: z3.string().optional(),
|
|
515
|
+
stable: z3.boolean(),
|
|
516
|
+
value: z3.unknown()
|
|
517
|
+
}))
|
|
518
|
+
});
|
|
519
|
+
var requestTraceSchema = serviceCall;
|
|
520
|
+
var jobStateSchema = z3.object({
|
|
521
|
+
id: z3.number(),
|
|
522
|
+
quality: qualitySchema,
|
|
523
|
+
busy: z3.boolean().nullable(),
|
|
524
|
+
cancelling: z3.boolean().optional(),
|
|
525
|
+
step: z3.number().optional(),
|
|
526
|
+
current: z3.object({ kind: z3.string(), range: sourceRange, text: z3.string() }).optional(),
|
|
527
|
+
startedAt: z3.string().optional(),
|
|
528
|
+
elapsedMs: z3.number().optional(),
|
|
529
|
+
request: z3.object({
|
|
530
|
+
service: z3.string(),
|
|
531
|
+
sequence: z3.number(),
|
|
532
|
+
trace: requestTraceSchema.optional()
|
|
533
|
+
}).optional(),
|
|
534
|
+
unread: z3.literal(true).optional(),
|
|
535
|
+
failure: z3.object({
|
|
536
|
+
at: z3.string(),
|
|
537
|
+
code: z3.number(),
|
|
538
|
+
name: z3.string().optional(),
|
|
539
|
+
source: z3.string()
|
|
540
|
+
}).optional()
|
|
541
|
+
});
|
|
542
|
+
var healthStateSchema = z3.enum(["unknown", "ok", "fault", "stale"]);
|
|
543
|
+
var deviceStateSchema = z3.object({
|
|
544
|
+
id: z3.string(),
|
|
545
|
+
health: z3.object({
|
|
546
|
+
state: healthStateSchema,
|
|
547
|
+
value: z3.number().optional(),
|
|
548
|
+
name: z3.string().optional(),
|
|
549
|
+
diagnostic: z3.boolean().optional(),
|
|
550
|
+
message: z3.string().optional(),
|
|
551
|
+
quality: qualitySchema
|
|
552
|
+
}),
|
|
553
|
+
assemblies: z3.array(z3.object({
|
|
554
|
+
direction: z3.enum(["input", "output"]),
|
|
555
|
+
address: z3.string().optional(),
|
|
556
|
+
bytes: z3.array(z3.number()).nullable(),
|
|
557
|
+
quality: qualitySchema
|
|
558
|
+
})),
|
|
559
|
+
channels: z3.array(z3.object({
|
|
560
|
+
id: z3.string(),
|
|
561
|
+
path: z3.string(),
|
|
562
|
+
value: z3.unknown(),
|
|
563
|
+
quality: qualitySchema
|
|
564
|
+
})),
|
|
565
|
+
status: z3.record(z3.string(), z3.object({ value: z3.unknown(), quality: qualitySchema }))
|
|
566
|
+
});
|
|
567
|
+
var timelineSourceSchema = z3.enum([
|
|
568
|
+
"plc",
|
|
569
|
+
"server",
|
|
570
|
+
"agent",
|
|
571
|
+
"debugger"
|
|
572
|
+
]);
|
|
573
|
+
var timelinePlacement = {
|
|
574
|
+
at: z3.string(),
|
|
575
|
+
approximate: z3.boolean(),
|
|
576
|
+
source: timelineSourceSchema,
|
|
577
|
+
cursor: z3.string().optional()
|
|
578
|
+
};
|
|
579
|
+
var timelineEntrySchema = z3.discriminatedUnion("kind", [
|
|
580
|
+
z3.object({
|
|
581
|
+
...timelinePlacement,
|
|
582
|
+
kind: z3.literal("app"),
|
|
583
|
+
task: z3.string(),
|
|
584
|
+
sequence: z3.number(),
|
|
585
|
+
record: appRecord
|
|
586
|
+
}),
|
|
587
|
+
z3.object({
|
|
588
|
+
...timelinePlacement,
|
|
589
|
+
kind: z3.literal("trace"),
|
|
590
|
+
trace: traceEventSchema
|
|
591
|
+
}),
|
|
592
|
+
z3.object({
|
|
593
|
+
...timelinePlacement,
|
|
594
|
+
kind: z3.literal("request"),
|
|
595
|
+
request: requestTraceSchema
|
|
596
|
+
}),
|
|
597
|
+
z3.object({
|
|
598
|
+
...timelinePlacement,
|
|
599
|
+
kind: z3.literal("deploy"),
|
|
600
|
+
release: z3.string(),
|
|
601
|
+
operation: z3.string(),
|
|
602
|
+
build: z3.string().optional(),
|
|
603
|
+
user: z3.string().optional(),
|
|
604
|
+
host: z3.string().optional()
|
|
605
|
+
}),
|
|
606
|
+
z3.object({
|
|
607
|
+
...timelinePlacement,
|
|
608
|
+
kind: z3.literal("audit"),
|
|
609
|
+
command: z3.string(),
|
|
610
|
+
values: z3.record(z3.string(), z3.string()),
|
|
611
|
+
previous: z3.record(z3.string(), z3.string()).optional(),
|
|
612
|
+
user: z3.string().optional(),
|
|
613
|
+
host: z3.string().optional(),
|
|
614
|
+
release: z3.string().optional(),
|
|
615
|
+
error: z3.string().optional()
|
|
616
|
+
}),
|
|
617
|
+
z3.object({
|
|
618
|
+
...timelinePlacement,
|
|
619
|
+
kind: z3.literal("connection"),
|
|
620
|
+
state: connectionStateSchema,
|
|
621
|
+
error: z3.string().optional()
|
|
622
|
+
})
|
|
623
|
+
]);
|
|
624
|
+
var watchGroupsSchema = z3.strictObject({
|
|
625
|
+
groups: z3.record(z3.string().nonempty(), z3.array(z3.string().nonempty()))
|
|
626
|
+
});
|
|
627
|
+
var clockSample = (task) => `tsplc:clock/${task}`;
|
|
628
|
+
var slotSample = (writer) => `tsplc:writer/${writer}`;
|
|
629
|
+
var interestQuery = (interest) => Object.fromEntries(Object.entries(interest).flatMap(([name, values]) => {
|
|
630
|
+
const list = [...new Set(values.map(String))].sort().join(",");
|
|
631
|
+
return list ? [[name, list]] : [];
|
|
632
|
+
}));
|
|
633
|
+
var streamEventSchemas = {
|
|
634
|
+
session: sessionSchema,
|
|
635
|
+
sample: sampleSchema,
|
|
636
|
+
job: jobStateSchema,
|
|
637
|
+
request: requestTraceSchema,
|
|
638
|
+
device: deviceStateSchema,
|
|
639
|
+
timeline: timelineEntrySchema
|
|
640
|
+
};
|
|
641
|
+
var isStreamEventName = (name) => Object.hasOwn(streamEventSchemas, name);
|
|
642
|
+
var decodeNamed = (name, data) => {
|
|
643
|
+
const schemas = streamEventSchemas;
|
|
644
|
+
const parsed = schemas[name].safeParse(JSON.parse(data));
|
|
645
|
+
if (!parsed.success) {
|
|
646
|
+
throw new Error(`The debugger sent a malformed ${name} event: ${z3.prettifyError(parsed.error)}`);
|
|
647
|
+
}
|
|
648
|
+
return { name, data: parsed.data };
|
|
649
|
+
};
|
|
650
|
+
var decodeStreamEvent = (name, data) => isStreamEventName(name) ? decodeNamed(name, data) : undefined;
|
|
651
|
+
var explanationSchema = z3.object({
|
|
652
|
+
path: z3.string(),
|
|
653
|
+
type: z3.string(),
|
|
654
|
+
writers: z3.array(z3.object({
|
|
655
|
+
assignment: z3.number().int(),
|
|
656
|
+
indexes: z3.array(z3.number().int()),
|
|
657
|
+
chains: z3.array(z3.object({
|
|
658
|
+
task: z3.string(),
|
|
659
|
+
entry: z3.number().int(),
|
|
660
|
+
calls: z3.array(z3.number().int())
|
|
661
|
+
}))
|
|
662
|
+
})),
|
|
663
|
+
flags: explainFlags.omit({ path: true }),
|
|
664
|
+
io: debugIo.nullable()
|
|
665
|
+
});
|
|
666
|
+
var forcedSchema = z3.object({
|
|
667
|
+
forced: z3.array(z3.string()).nullable(),
|
|
668
|
+
at: z3.string()
|
|
669
|
+
});
|
|
670
|
+
var apiResponseSchemas = {
|
|
671
|
+
"GET /api/session": sessionSchema,
|
|
672
|
+
"GET /api/manifest": debugManifest,
|
|
673
|
+
"GET /api/values": z3.array(sampleSchema),
|
|
674
|
+
"GET /api/jobs": z3.array(jobStateSchema),
|
|
675
|
+
"GET /api/hardware": z3.array(deviceStateSchema),
|
|
676
|
+
"GET /api/timeline": z3.array(timelineEntrySchema),
|
|
677
|
+
"GET /api/watch": watchGroupsSchema,
|
|
678
|
+
"PUT /api/watch": watchGroupsSchema,
|
|
679
|
+
"GET /api/explain": explanationSchema,
|
|
680
|
+
"GET /api/explain-file": explainFile,
|
|
681
|
+
"GET /api/forced": forcedSchema
|
|
682
|
+
};
|
|
683
|
+
async function* parseEventStream(chunks) {
|
|
684
|
+
let buffer = "";
|
|
685
|
+
let event = "";
|
|
686
|
+
let data = [];
|
|
687
|
+
for await (const chunk of chunks) {
|
|
688
|
+
buffer += chunk;
|
|
689
|
+
const end = buffer.endsWith("\r") ? buffer.length - 1 : buffer.length;
|
|
690
|
+
const lines = buffer.slice(0, end).split(/\r\n|\r|\n/);
|
|
691
|
+
buffer = lines.splice(-1).join("") + buffer.slice(end);
|
|
692
|
+
for (const line of lines) {
|
|
693
|
+
if (!line) {
|
|
694
|
+
if (data.length) {
|
|
695
|
+
yield { event: event || "message", data: data.join(`
|
|
696
|
+
`) };
|
|
697
|
+
}
|
|
698
|
+
event = "";
|
|
699
|
+
data = [];
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
if (line.startsWith(":")) {
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
const colon = line.indexOf(":");
|
|
706
|
+
const field = colon < 0 ? line : line.slice(0, colon);
|
|
707
|
+
const value = colon < 0 ? "" : line.slice(colon + 1).replace(/^ /, "");
|
|
708
|
+
if (field === "event") {
|
|
709
|
+
event = value;
|
|
710
|
+
} else if (field === "data") {
|
|
711
|
+
data.push(value);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
export {
|
|
717
|
+
apiResponseSchemas,
|
|
718
|
+
clockSample,
|
|
719
|
+
connectionStateSchema,
|
|
720
|
+
dashboardHeader,
|
|
721
|
+
decodeStreamEvent,
|
|
722
|
+
deviceStateSchema,
|
|
723
|
+
errorBodySchema,
|
|
724
|
+
explanationSchema,
|
|
725
|
+
forcedSchema,
|
|
726
|
+
healthStateSchema,
|
|
727
|
+
interestQuery,
|
|
728
|
+
jobStateSchema,
|
|
729
|
+
parseEventStream,
|
|
730
|
+
qualitySchema2 as qualitySchema,
|
|
731
|
+
requestTraceSchema,
|
|
732
|
+
sampleSchema,
|
|
733
|
+
sessionSchema,
|
|
734
|
+
slotSample,
|
|
735
|
+
streamEventSchemas,
|
|
736
|
+
timelineEntrySchema,
|
|
737
|
+
timelineSourceSchema,
|
|
738
|
+
tokenQueryParameter,
|
|
739
|
+
traceEventSchema,
|
|
740
|
+
watchGroupsSchema
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
//# debugId=650A4E87AEF6248164756E2164756E21
|
|
744
|
+
//# sourceMappingURL=api.js.map
|