@tsplc/compiler 0.5.13 → 0.5.15
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 +33 -8
- package/dist/cli.js +794 -621
- package/dist/cli.js.map +19 -16
- package/dist/clock.js +5 -2
- package/dist/clock.js.map +5 -4
- package/dist/codesys.js +4162 -4157
- package/dist/codesys.js.map +43 -29
- package/dist/index.js +7852 -6549
- package/dist/index.js.map +53 -50
- package/dist/ir.js +2482 -2277
- package/dist/ir.js.map +28 -25
- package/dist/retain.js +3 -1
- package/dist/retain.js.map +3 -3
- package/dist/signals.js +115 -0
- package/dist/signals.js.map +10 -0
- package/dist/telemetry.js +25 -20
- package/dist/telemetry.js.map +6 -6
- package/package.json +19 -39
- package/src/codesys/config.ts +3 -3
- package/src/codesys/debug.ts +92 -108
- package/src/codesys/emit.ts +100 -88
- package/src/codesys/endpoints.ts +111 -0
- package/src/codesys/engineering.ts +30 -54
- package/src/codesys/explain/expressions.ts +445 -0
- package/src/codesys/explain/flags.ts +134 -0
- package/src/codesys/explain/parameters.ts +53 -0
- package/src/codesys/explain/rows.ts +182 -0
- package/src/codesys/explain/tables.ts +79 -0
- package/src/codesys/explain/tasks.ts +68 -0
- package/src/codesys/explain/writes.ts +497 -0
- package/src/codesys/explain.ts +85 -1401
- package/src/codesys/expressions.ts +41 -33
- package/src/codesys/global-lists.ts +114 -94
- package/src/codesys/global-names.ts +12 -14
- package/src/codesys/http.ts +428 -388
- package/src/codesys/instrumentation.ts +142 -148
- package/src/codesys/io-paths.ts +31 -23
- package/src/codesys/loops.ts +101 -0
- package/src/codesys/manifest.ts +269 -269
- package/src/codesys/names.ts +10 -33
- package/src/codesys/numeric.ts +89 -42
- package/src/codesys/plan.ts +202 -190
- package/src/codesys/programs.ts +23 -16
- package/src/codesys/publication.ts +13 -86
- package/src/codesys/required.ts +8 -0
- package/src/codesys/routines.ts +103 -489
- package/src/codesys/scheduling.ts +96 -0
- package/src/codesys/service-channels.ts +23 -0
- package/src/codesys/sources.ts +34 -28
- package/src/codesys/st-files.ts +112 -105
- package/src/codesys/statements.ts +409 -0
- package/src/codesys/storage.ts +41 -23
- package/src/codesys/symbols.ts +130 -119
- package/src/codesys/task-access.ts +65 -221
- package/src/codesys/telemetry-settings.ts +19 -0
- package/src/codesys/telemetry.ts +185 -148
- package/src/codesys/types.ts +69 -109
- package/src/codesys/vendor.ts +13 -50
- package/src/frontend/analyzer.ts +66 -111
- package/src/frontend/async.ts +316 -128
- package/src/frontend/blocks.ts +178 -154
- package/src/frontend/configuration.ts +49 -153
- package/src/frontend/const-functions.ts +50 -40
- package/src/frontend/control-flow.ts +164 -129
- package/src/frontend/cooperative.ts +17 -9
- package/src/frontend/coroutines.ts +539 -441
- package/src/frontend/dialect-names.ts +104 -0
- package/src/frontend/elaborate/array-searches.ts +77 -69
- package/src/frontend/elaborate/assignments.ts +68 -77
- package/src/frontend/elaborate/calls.ts +878 -512
- package/src/frontend/elaborate/capture-protocol.ts +118 -21
- package/src/frontend/elaborate/capture.ts +196 -109
- package/src/frontend/elaborate/declarations.ts +124 -0
- package/src/frontend/elaborate/dialect.ts +119 -46
- package/src/frontend/elaborate/expressions.ts +763 -442
- package/src/frontend/elaborate/filtered-arrays.ts +127 -91
- package/src/frontend/elaborate/frame.ts +50 -2
- package/src/frontend/elaborate/generics.ts +20 -34
- package/src/frontend/elaborate/graph.ts +13 -87
- package/src/frontend/elaborate/imports.ts +0 -5
- package/src/frontend/elaborate/index.ts +416 -169
- package/src/frontend/elaborate/initializers.ts +64 -42
- package/src/frontend/elaborate/iterators.ts +228 -364
- package/src/frontend/elaborate/layouts.ts +477 -116
- package/src/frontend/elaborate/model.ts +113 -55
- package/src/frontend/elaborate/references.ts +116 -138
- package/src/frontend/elaborate/retention.ts +137 -59
- package/src/frontend/elaborate/specialize.ts +617 -308
- package/src/frontend/elaborate/statements.ts +436 -247
- package/src/frontend/elaborate/storage.ts +280 -213
- package/src/frontend/elaborate/time-constructors.ts +34 -0
- package/src/frontend/elaborate/values.ts +77 -7
- package/src/frontend/elaborate/writes.ts +98 -84
- package/src/frontend/expressions.ts +149 -151
- package/src/frontend/generated-names.ts +3 -3
- package/src/frontend/intrinsics.ts +31 -17
- package/src/frontend/lowering-key.ts +23 -0
- package/src/frontend/module-graph.ts +105 -43
- package/src/frontend/positions.ts +43 -35
- package/src/frontend/promise-chains.ts +226 -266
- package/src/frontend/promises.ts +88 -67
- package/src/frontend/routines.ts +122 -65
- package/src/frontend/sdk.ts +104 -5
- package/src/frontend/services.ts +149 -102
- package/src/frontend/statements.ts +60 -64
- package/src/frontend/tasks.ts +151 -96
- package/src/frontend/telemetry.ts +1 -1
- package/src/frontend/types.ts +366 -181
- package/src/frontend/typescript.ts +239 -112
- package/src/index.ts +2 -1
- package/src/ir/aggregates.ts +90 -75
- package/src/ir/allocation.ts +29 -18
- package/src/ir/conditions.ts +38 -78
- package/src/ir/core-model.ts +128 -11
- package/src/ir/declarations.ts +18 -32
- package/src/ir/diagnostics.ts +25 -18
- package/src/ir/domains.ts +26 -23
- package/src/ir/fold.ts +55 -50
- package/src/ir/identity.ts +10 -0
- package/src/ir/index.ts +31 -7
- package/src/ir/job-errors.ts +30 -8
- package/src/ir/layouts.ts +63 -34
- package/src/ir/link.ts +11 -46
- package/src/ir/model.ts +25 -6
- package/src/ir/normalize.ts +3 -28
- package/src/ir/numeric.ts +45 -18
- package/src/ir/operands.ts +102 -0
- package/src/ir/ranges.ts +242 -67
- package/src/ir/routine.ts +126 -183
- package/src/ir/scalars.ts +29 -25
- package/src/ir/share.ts +323 -343
- package/src/ir/short-circuit.ts +140 -0
- package/src/ir/tables.ts +111 -0
- package/src/ir/temporaries.ts +15 -113
- package/src/ir/types.ts +32 -8
- package/src/project/artifacts.ts +143 -71
- package/src/project/cli.ts +104 -87
- package/src/project/debugger.ts +48 -34
- package/src/project/deployments.ts +12 -68
- package/src/project/flags.ts +14 -0
- package/src/project/plant.ts +293 -225
- package/src/project/project-commands.ts +254 -192
- package/src/project/project.ts +184 -141
- package/src/project/release.ts +22 -28
- package/src/project/server.ts +22 -26
- package/src/project/terminal.ts +13 -2
- package/src/runtime/async.ts +17 -13
- package/src/runtime/launch.ts +5 -2
- package/src/runtime/main.ts +8 -3
- package/src/runtime/missing-file.ts +3 -0
- package/src/runtime/process.ts +24 -19
- package/src/runtime/program.ts +20 -53
- package/src/runtime/retain.ts +18 -10
- package/src/runtime/runtime.ts +47 -60
- package/src/runtime/settings.ts +27 -0
- package/src/runtime/storage.ts +49 -74
- package/src/runtime/symbols.ts +19 -75
- package/src/runtime/telemetry.ts +37 -14
- package/src/runtime/transport.ts +26 -30
- package/stdlib/clock.ts +4 -2
- package/stdlib/plc-time.ts +2 -0
- package/stdlib/retain.ts +2 -0
- package/stdlib/signals.ts +142 -0
- package/stdlib/telemetry.ts +5 -12
- package/types/dialect.d.ts +49 -0
- package/types/globals.d.ts +2 -42
- package/types/index.d.ts +3 -1
- package/types/retain.d.ts +8 -2
- package/types/telemetry.d.ts +3 -0
- package/dist/bun-runtime.js +0 -1472
- package/dist/bun-runtime.js.map +0 -26
- package/dist/elaborate-capture.js +0 -304
- package/dist/elaborate-capture.js.map +0 -11
- package/dist/math.js +0 -24
- package/dist/math.js.map +0 -10
- package/dist/project.js +0 -626
- package/dist/project.js.map +0 -12
- package/dist/server-check.js +0 -59
- package/dist/server-check.js.map +0 -11
- package/src/frontend/exposure.ts +0 -181
- package/src/project/index.ts +0 -6
- package/src/runtime/.runtime-65O4JH/server/router.ts +0 -17
- package/src/runtime/.runtime-65O4JH/src/cell.ts +0 -45
- package/src/runtime/.runtime-65O4JH/src/controller.ts +0 -58
- package/src/runtime/.runtime-65O4JH/src/lane.ts +0 -6
- package/src/runtime/.runtime-65O4JH/src/main.ts +0 -11
- package/src/runtime/.runtime-65O4JH/src/services.ts +0 -8
- package/src/runtime/.runtime-65O4JH/tsconfig.json +0 -13
- package/src/runtime/.runtime-65O4JH/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-Brw2kO/server/router.ts +0 -17
- package/src/runtime/.runtime-Brw2kO/src/cell.ts +0 -45
- package/src/runtime/.runtime-Brw2kO/src/controller.ts +0 -58
- package/src/runtime/.runtime-Brw2kO/src/lane.ts +0 -6
- package/src/runtime/.runtime-Brw2kO/src/main.ts +0 -11
- package/src/runtime/.runtime-Brw2kO/src/services.ts +0 -8
- package/src/runtime/.runtime-Brw2kO/tsconfig.json +0 -13
- package/src/runtime/.runtime-Brw2kO/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-NHfu1D/server/router.ts +0 -17
- package/src/runtime/.runtime-NHfu1D/src/cell.ts +0 -45
- package/src/runtime/.runtime-NHfu1D/src/controller.ts +0 -58
- package/src/runtime/.runtime-NHfu1D/src/lane.ts +0 -6
- package/src/runtime/.runtime-NHfu1D/src/main.ts +0 -11
- package/src/runtime/.runtime-NHfu1D/src/services.ts +0 -8
- package/src/runtime/.runtime-NHfu1D/tsconfig.json +0 -13
- package/src/runtime/.runtime-NHfu1D/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-VaUSOu/server/router.ts +0 -17
- package/src/runtime/.runtime-VaUSOu/src/cell.ts +0 -45
- package/src/runtime/.runtime-VaUSOu/src/controller.ts +0 -58
- package/src/runtime/.runtime-VaUSOu/src/lane.ts +0 -6
- package/src/runtime/.runtime-VaUSOu/src/main.ts +0 -11
- package/src/runtime/.runtime-VaUSOu/src/services.ts +0 -8
- package/src/runtime/.runtime-VaUSOu/tsconfig.json +0 -13
- package/src/runtime/.runtime-VaUSOu/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-WbtNvR/server/router.ts +0 -17
- package/src/runtime/.runtime-WbtNvR/src/cell.ts +0 -45
- package/src/runtime/.runtime-WbtNvR/src/controller.ts +0 -58
- package/src/runtime/.runtime-WbtNvR/src/lane.ts +0 -6
- package/src/runtime/.runtime-WbtNvR/src/main.ts +0 -11
- package/src/runtime/.runtime-WbtNvR/src/services.ts +0 -8
- package/src/runtime/.runtime-WbtNvR/tsconfig.json +0 -13
- package/src/runtime/.runtime-WbtNvR/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-opcua-GMPUt8/server/router.ts +0 -17
- package/src/runtime/.runtime-opcua-GMPUt8/src/cell.ts +0 -45
- package/src/runtime/.runtime-opcua-GMPUt8/src/controller.ts +0 -58
- package/src/runtime/.runtime-opcua-GMPUt8/src/lane.ts +0 -6
- package/src/runtime/.runtime-opcua-GMPUt8/src/main.ts +0 -11
- package/src/runtime/.runtime-opcua-GMPUt8/src/services.ts +0 -8
- package/src/runtime/.runtime-opcua-GMPUt8/tsconfig.json +0 -13
- package/src/runtime/.runtime-opcua-GMPUt8/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-opcua-UwafxO/server/router.ts +0 -17
- package/src/runtime/.runtime-opcua-UwafxO/src/cell.ts +0 -45
- package/src/runtime/.runtime-opcua-UwafxO/src/controller.ts +0 -58
- package/src/runtime/.runtime-opcua-UwafxO/src/lane.ts +0 -6
- package/src/runtime/.runtime-opcua-UwafxO/src/main.ts +0 -11
- package/src/runtime/.runtime-opcua-UwafxO/src/services.ts +0 -8
- package/src/runtime/.runtime-opcua-UwafxO/tsconfig.json +0 -13
- package/src/runtime/.runtime-opcua-UwafxO/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-opcua-ecaSee/server/router.ts +0 -17
- package/src/runtime/.runtime-opcua-ecaSee/src/cell.ts +0 -45
- package/src/runtime/.runtime-opcua-ecaSee/src/controller.ts +0 -58
- package/src/runtime/.runtime-opcua-ecaSee/src/lane.ts +0 -6
- package/src/runtime/.runtime-opcua-ecaSee/src/main.ts +0 -11
- package/src/runtime/.runtime-opcua-ecaSee/src/services.ts +0 -8
- package/src/runtime/.runtime-opcua-ecaSee/tsconfig.json +0 -13
- package/src/runtime/.runtime-opcua-ecaSee/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-opcua-y91UCm/server/router.ts +0 -17
- package/src/runtime/.runtime-opcua-y91UCm/src/cell.ts +0 -45
- package/src/runtime/.runtime-opcua-y91UCm/src/controller.ts +0 -58
- package/src/runtime/.runtime-opcua-y91UCm/src/lane.ts +0 -6
- package/src/runtime/.runtime-opcua-y91UCm/src/main.ts +0 -11
- package/src/runtime/.runtime-opcua-y91UCm/src/services.ts +0 -8
- package/src/runtime/.runtime-opcua-y91UCm/tsconfig.json +0 -13
- package/src/runtime/.runtime-opcua-y91UCm/tsplc.config.ts +0 -31
- package/src/runtime/.runtime-ybIxYh/server/router.ts +0 -17
- package/src/runtime/.runtime-ybIxYh/src/cell.ts +0 -45
- package/src/runtime/.runtime-ybIxYh/src/controller.ts +0 -58
- package/src/runtime/.runtime-ybIxYh/src/lane.ts +0 -6
- package/src/runtime/.runtime-ybIxYh/src/main.ts +0 -11
- package/src/runtime/.runtime-ybIxYh/src/services.ts +0 -8
- package/src/runtime/.runtime-ybIxYh/tsconfig.json +0 -13
- package/src/runtime/.runtime-ybIxYh/tsplc.config.ts +0 -31
- package/stdlib/math.ts +0 -23
- package/types/plc.d.ts +0 -4
package/dist/retain.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// packages/compiler/stdlib/retain.ts
|
|
2
2
|
var retain = (value) => value;
|
|
3
|
+
var persist = (value) => value;
|
|
3
4
|
export {
|
|
5
|
+
persist,
|
|
4
6
|
retain
|
|
5
7
|
};
|
|
6
8
|
|
|
7
|
-
//# debugId=
|
|
9
|
+
//# debugId=285AE75D69F13A9864756E2164756E21
|
|
8
10
|
//# sourceMappingURL=retain.js.map
|
package/dist/retain.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../stdlib/retain.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/** `retain` as a program running under Bun sees it: retention is the PLC's, so the value passes through. */\nexport const retain = <T>(value: T): T => value;\n"
|
|
5
|
+
"/** `retain` as a program running under Bun sees it: retention is the PLC's, so the value passes through. */\nexport const retain = <T>(value: T): T => value;\n/** `persist` as a program running under Bun sees it: as `retain`, the value passes through. */\nexport const persist = <T>(value: T): T => value;\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AACO,IAAM,SAAS,CAAI,UAAgB;",
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AACO,IAAM,SAAS,CAAI,UAAgB;AAEnC,IAAM,UAAU,CAAI,UAAgB;",
|
|
8
|
+
"debugId": "285AE75D69F13A9864756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/signals.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// packages/compiler/stdlib/signals.ts
|
|
2
|
+
var elapsedSince = (last, now) => last === undefined ? 0 : Math.max(now - last, 0);
|
|
3
|
+
|
|
4
|
+
class OnDelayTimer {
|
|
5
|
+
durationMs;
|
|
6
|
+
heldMs = 0;
|
|
7
|
+
previous = false;
|
|
8
|
+
lastNow;
|
|
9
|
+
constructor(durationMs) {
|
|
10
|
+
this.durationMs = durationMs;
|
|
11
|
+
}
|
|
12
|
+
get elapsedMs() {
|
|
13
|
+
return this.heldMs;
|
|
14
|
+
}
|
|
15
|
+
get output() {
|
|
16
|
+
return this.previous && this.heldMs >= this.durationMs;
|
|
17
|
+
}
|
|
18
|
+
update(now, input) {
|
|
19
|
+
const step = elapsedSince(this.lastNow, now);
|
|
20
|
+
this.lastNow = now;
|
|
21
|
+
this.heldMs = input && this.previous ? Math.min(this.heldMs + step, this.durationMs) : 0;
|
|
22
|
+
this.previous = input;
|
|
23
|
+
return this.output;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class OffDelayTimer {
|
|
28
|
+
durationMs;
|
|
29
|
+
offMs = 0;
|
|
30
|
+
previous = false;
|
|
31
|
+
on = false;
|
|
32
|
+
lastNow;
|
|
33
|
+
constructor(durationMs) {
|
|
34
|
+
this.durationMs = durationMs;
|
|
35
|
+
}
|
|
36
|
+
get elapsedMs() {
|
|
37
|
+
return this.offMs;
|
|
38
|
+
}
|
|
39
|
+
get output() {
|
|
40
|
+
return this.on;
|
|
41
|
+
}
|
|
42
|
+
update(now, input) {
|
|
43
|
+
const step = elapsedSince(this.lastNow, now);
|
|
44
|
+
this.lastNow = now;
|
|
45
|
+
if (input) {
|
|
46
|
+
this.on = true;
|
|
47
|
+
this.offMs = 0;
|
|
48
|
+
} else if (this.on) {
|
|
49
|
+
this.offMs = this.previous ? 0 : Math.min(this.offMs + step, this.durationMs);
|
|
50
|
+
this.on = this.offMs < this.durationMs;
|
|
51
|
+
}
|
|
52
|
+
this.previous = input;
|
|
53
|
+
return this.on;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class PulseTimer {
|
|
58
|
+
durationMs;
|
|
59
|
+
onMs = 0;
|
|
60
|
+
previous = false;
|
|
61
|
+
on = false;
|
|
62
|
+
lastNow;
|
|
63
|
+
constructor(durationMs) {
|
|
64
|
+
this.durationMs = durationMs;
|
|
65
|
+
}
|
|
66
|
+
get elapsedMs() {
|
|
67
|
+
return this.onMs;
|
|
68
|
+
}
|
|
69
|
+
get output() {
|
|
70
|
+
return this.on;
|
|
71
|
+
}
|
|
72
|
+
update(now, input) {
|
|
73
|
+
const step = elapsedSince(this.lastNow, now);
|
|
74
|
+
this.lastNow = now;
|
|
75
|
+
if (this.on) {
|
|
76
|
+
this.onMs = Math.min(this.onMs + step, this.durationMs);
|
|
77
|
+
this.on = this.onMs < this.durationMs;
|
|
78
|
+
} else if (input && !this.previous) {
|
|
79
|
+
this.on = true;
|
|
80
|
+
this.onMs = 0;
|
|
81
|
+
}
|
|
82
|
+
this.previous = input;
|
|
83
|
+
return this.on;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
class RisingEdge {
|
|
88
|
+
previous = false;
|
|
89
|
+
rose = false;
|
|
90
|
+
update(input) {
|
|
91
|
+
this.rose = input && !this.previous;
|
|
92
|
+
this.previous = input;
|
|
93
|
+
return this.rose;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
class FallingEdge {
|
|
98
|
+
previous = false;
|
|
99
|
+
fell = false;
|
|
100
|
+
update(input) {
|
|
101
|
+
this.fell = this.previous && !input;
|
|
102
|
+
this.previous = input;
|
|
103
|
+
return this.fell;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
FallingEdge,
|
|
108
|
+
OffDelayTimer,
|
|
109
|
+
OnDelayTimer,
|
|
110
|
+
PulseTimer,
|
|
111
|
+
RisingEdge
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//# debugId=A826A69143FC38D864756E2164756E21
|
|
115
|
+
//# sourceMappingURL=signals.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../stdlib/signals.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// PLC implementation source: timers and edge detectors for a plain TypeScript program. Each is an\n// ordinary class the compiler specializes like a program's own, and the same classes run under Bun\n// for tests and simulation. Every update takes the scan's `now()`, so one scan reads one time.\n\n/**\n * Milliseconds since `last`, the previous update's `now()`. The PLC clock is a DINT that wraps\n * after 24.8 days: on the PLC the subtraction wraps with it, and under Bun the one negative step\n * across the wrap counts as none, so a timer measures scan by scan instead of from a start time.\n */\nconst elapsedSince = (last: number | undefined, now: number): number =>\n\tlast === undefined ? 0 : Math.max(now - last, 0);\n\n/** Turns its output on once the input has been on for `durationMs`, and off as soon as the input goes off. IEC `TON`. */\nexport class OnDelayTimer {\n\tprivate heldMs = 0;\n\tprivate previous = false;\n\tprivate lastNow: number | undefined;\n\n\tconstructor(readonly durationMs: number) {}\n\n\t/** How long the input has been on, up to `durationMs`. */\n\tget elapsedMs(): number {\n\t\treturn this.heldMs;\n\t}\n\n\tget output(): boolean {\n\t\treturn this.previous && this.heldMs >= this.durationMs;\n\t}\n\n\t/** Takes this scan's input and `now()`, and returns the output. */\n\tupdate(now: number, input: boolean): boolean {\n\t\tconst step = elapsedSince(this.lastNow, now);\n\t\tthis.lastNow = now;\n\t\tthis.heldMs =\n\t\t\tinput && this.previous\n\t\t\t\t? Math.min(this.heldMs + step, this.durationMs)\n\t\t\t\t: 0;\n\t\tthis.previous = input;\n\t\treturn this.output;\n\t}\n}\n\n/** Turns its output on with the input, and off once the input has been off for `durationMs`. IEC `TOF`. */\nexport class OffDelayTimer {\n\tprivate offMs = 0;\n\tprivate previous = false;\n\tprivate on = false;\n\tprivate lastNow: number | undefined;\n\n\tconstructor(readonly durationMs: number) {}\n\n\t/** How long the input has been off since the output last turned on, up to `durationMs`. */\n\tget elapsedMs(): number {\n\t\treturn this.offMs;\n\t}\n\n\tget output(): boolean {\n\t\treturn this.on;\n\t}\n\n\t/** Takes this scan's input and `now()`, and returns the output. */\n\tupdate(now: number, input: boolean): boolean {\n\t\tconst step = elapsedSince(this.lastNow, now);\n\t\tthis.lastNow = now;\n\t\tif (input) {\n\t\t\tthis.on = true;\n\t\t\tthis.offMs = 0;\n\t\t} else if (this.on) {\n\t\t\tthis.offMs = this.previous\n\t\t\t\t? 0\n\t\t\t\t: Math.min(this.offMs + step, this.durationMs);\n\t\t\tthis.on = this.offMs < this.durationMs;\n\t\t}\n\t\tthis.previous = input;\n\t\treturn this.on;\n\t}\n}\n\n/**\n * Turns its output on for `durationMs` when the input rises, whatever the input does meanwhile. A\n * new pulse needs the input to rise again after the last one ends. IEC `TP`.\n */\nexport class PulseTimer {\n\tprivate onMs = 0;\n\tprivate previous = false;\n\tprivate on = false;\n\tprivate lastNow: number | undefined;\n\n\tconstructor(readonly durationMs: number) {}\n\n\t/** How long the current pulse has lasted, up to `durationMs`. */\n\tget elapsedMs(): number {\n\t\treturn this.onMs;\n\t}\n\n\tget output(): boolean {\n\t\treturn this.on;\n\t}\n\n\t/** Takes this scan's input and `now()`, and returns the output. */\n\tupdate(now: number, input: boolean): boolean {\n\t\tconst step = elapsedSince(this.lastNow, now);\n\t\tthis.lastNow = now;\n\t\tif (this.on) {\n\t\t\tthis.onMs = Math.min(this.onMs + step, this.durationMs);\n\t\t\tthis.on = this.onMs < this.durationMs;\n\t\t} else if (input && !this.previous) {\n\t\t\tthis.on = true;\n\t\t\tthis.onMs = 0;\n\t\t}\n\t\tthis.previous = input;\n\t\treturn this.on;\n\t}\n}\n\n/** True for the one scan in which its input goes from off to on, including an input already on at the first scan. IEC `R_TRIG`. */\nexport class RisingEdge {\n\tprivate previous = false;\n\t/** Whether the last update saw the input rise. */\n\trose = false;\n\n\t/** Takes this scan's input, and returns whether it rose. */\n\tupdate(input: boolean): boolean {\n\t\tthis.rose = input && !this.previous;\n\t\tthis.previous = input;\n\t\treturn this.rose;\n\t}\n}\n\n/** True for the one scan in which its input goes from on to off. An input off from the first scan never falls. */\nexport class FallingEdge {\n\tprivate previous = false;\n\t/** Whether the last update saw the input fall. */\n\tfell = false;\n\n\t/** Takes this scan's input, and returns whether it fell. */\n\tupdate(input: boolean): boolean {\n\t\tthis.fell = this.previous && !input;\n\t\tthis.previous = input;\n\t\treturn this.fell;\n\t}\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AASA,IAAM,eAAe,CAAC,MAA0B,QAC/C,SAAS,YAAY,IAAI,KAAK,IAAI,MAAM,MAAM,CAAC;AAAA;AAGzC,MAAM,aAAa;AAAA,EAKJ;AAAA,EAJb,SAAS;AAAA,EACT,WAAW;AAAA,EACX;AAAA,EAER,WAAW,CAAU,YAAoB;AAAA,IAApB;AAAA;AAAA,MAGjB,SAAS,GAAW;AAAA,IACvB,OAAO,KAAK;AAAA;AAAA,MAGT,MAAM,GAAY;AAAA,IACrB,OAAO,KAAK,YAAY,KAAK,UAAU,KAAK;AAAA;AAAA,EAI7C,MAAM,CAAC,KAAa,OAAyB;AAAA,IAC5C,MAAM,OAAO,aAAa,KAAK,SAAS,GAAG;AAAA,IAC3C,KAAK,UAAU;AAAA,IACf,KAAK,SACJ,SAAS,KAAK,WACX,KAAK,IAAI,K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AAU;AAAA,MACtD,KAAK,KAAK,KAAK,OAAO,KAAK;AAAA,IAC5B,EAAE,KAAK,IAAI,SAAS,CAAC,KAAK,UAAU;AAAA,MACnC,KAAK,KAAK;AAAA,MACV,KAAK,OAAO;AAAA,IACb;AAAA,IACA,KAAK,WAAW;AAAA,IAChB,OAAO,KAAK;AAAA;AAEd;AAAA;AAGO,MAAM,WAAW;AAAA,EACf,WAAW;AAAA,EAEnB,OAAO;AAAA,EAGP,MAAM,CAAC,OAAyB;AAAA,IAC/B,KAAK,OAAO,SAAS,CAAC,KAAK;AAAA,IAC3B,KAAK,WAAW;AAAA,IAChB,OAAO,KAAK;AAAA;AAEd;AAAA;AAGO,MAAM,YAAY;AAAA,EAChB,WAAW;AAAA,EAEnB,OAAO;AAAA,EAGP,MAAM,CAAC,OAAyB;AAAA,IAC/B,KAAK,OAAO,KAAK,YAAY,CAAC;AAAA,IAC9B,KAAK,WAAW;AAAA,IAChB,OAAO,KAAK;AAAA;AAEd;",
|
|
8
|
+
"debugId": "A826A69143FC38D864756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/telemetry.js
CHANGED
|
@@ -13,9 +13,13 @@ var jobError = {
|
|
|
13
13
|
noRequestSlot: 7,
|
|
14
14
|
codeChanged: 11001
|
|
15
15
|
};
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
|
|
16
|
+
var httpBase = 1e4;
|
|
17
|
+
var httpErrors = {
|
|
18
|
+
base: httpBase,
|
|
19
|
+
last: 10999,
|
|
20
|
+
refused: httpBase + 400
|
|
21
|
+
};
|
|
22
|
+
var errorMeanings = {
|
|
19
23
|
[jobError.cancelled]: "cancelled",
|
|
20
24
|
[jobError.timeout]: "timeout",
|
|
21
25
|
[jobError.tooLarge]: "request or response too large to encode",
|
|
@@ -23,21 +27,28 @@ var jobErrors = {
|
|
|
23
27
|
[jobError.network]: "network error or server restarted",
|
|
24
28
|
[jobError.tls]: "TLS error",
|
|
25
29
|
[jobError.noRequestSlot]: "no free request slot",
|
|
26
|
-
[jobError.codeChanged]: "an online change replaced the job's code while it ran"
|
|
27
|
-
|
|
30
|
+
[jobError.codeChanged]: "an online change replaced the job's code while it ran"
|
|
31
|
+
};
|
|
32
|
+
var jobErrors = {
|
|
33
|
+
...errorMeanings,
|
|
34
|
+
[httpErrors.base]: `HTTP status: ${httpErrors.base} + status code`
|
|
28
35
|
};
|
|
29
36
|
var errorName = (code) => {
|
|
30
37
|
if (code > httpErrors.base && code <= httpErrors.last) {
|
|
31
38
|
return `HTTP ${code - httpErrors.base}`;
|
|
32
39
|
}
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
return errorMeanings[code];
|
|
41
|
+
};
|
|
42
|
+
var failureCode = (reason) => typeof reason === "number" ? reason : 0;
|
|
43
|
+
var failureName = (reason) => {
|
|
44
|
+
if (typeof reason === "number") {
|
|
45
|
+
return errorName(reason);
|
|
35
46
|
}
|
|
36
|
-
return
|
|
47
|
+
return reason instanceof Error ? reason.message : String(reason);
|
|
37
48
|
};
|
|
38
49
|
|
|
39
|
-
// packages/compiler/stdlib/
|
|
40
|
-
var
|
|
50
|
+
// packages/compiler/stdlib/plc-time.ts
|
|
51
|
+
var plcTime = () => Math.floor(performance.now()) >>> 0;
|
|
41
52
|
|
|
42
53
|
// packages/compiler/stdlib/telemetry.ts
|
|
43
54
|
class Text {
|
|
@@ -67,12 +78,6 @@ var reportedValue = (value) => {
|
|
|
67
78
|
}
|
|
68
79
|
return value;
|
|
69
80
|
};
|
|
70
|
-
var exceptionName = (error) => {
|
|
71
|
-
if (typeof error === "number") {
|
|
72
|
-
return errorName(error);
|
|
73
|
-
}
|
|
74
|
-
return error instanceof Error ? error.message : String(error);
|
|
75
|
-
};
|
|
76
81
|
var report = (record, properties = {}) => collector?.({
|
|
77
82
|
...record,
|
|
78
83
|
properties: Object.fromEntries(Object.entries(properties).map(([name, value]) => [
|
|
@@ -81,7 +86,7 @@ var report = (record, properties = {}) => collector?.({
|
|
|
81
86
|
])),
|
|
82
87
|
source: source(),
|
|
83
88
|
scan: 0,
|
|
84
|
-
time:
|
|
89
|
+
time: plcTime()
|
|
85
90
|
});
|
|
86
91
|
var telemetry = {
|
|
87
92
|
capture: (event, properties) => report({ kind: "event", event }, properties),
|
|
@@ -89,8 +94,8 @@ var telemetry = {
|
|
|
89
94
|
warn: (message, properties) => report({ kind: "log", level: "warn", message }, properties),
|
|
90
95
|
error: (message, properties) => report({ kind: "log", level: "error", message }, properties),
|
|
91
96
|
captureException: (error, properties) => {
|
|
92
|
-
const code =
|
|
93
|
-
const name =
|
|
97
|
+
const code = failureCode(error);
|
|
98
|
+
const name = failureName(error);
|
|
94
99
|
report({ kind: "exception", code, ...name && { name }, handled: true }, properties);
|
|
95
100
|
},
|
|
96
101
|
text: (bytes, length) => {
|
|
@@ -112,5 +117,5 @@ export {
|
|
|
112
117
|
telemetry
|
|
113
118
|
};
|
|
114
119
|
|
|
115
|
-
//# debugId=
|
|
120
|
+
//# debugId=A73F9037C038FC8864756E2164756E21
|
|
116
121
|
//# sourceMappingURL=telemetry.js.map
|
package/dist/telemetry.js.map
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../stdlib/telemetry.ts", "../src/ir/job-errors.ts", "../stdlib/
|
|
3
|
+
"sources": ["../stdlib/telemetry.ts", "../src/ir/job-errors.ts", "../stdlib/plc-time.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport {
|
|
6
|
-
"/** Job error codes by meaning, as generated async blocks and service calls set them. */\nexport const jobError = {\n\tcancelled: 1,\n\ttimeout: 2,\n\ttooLarge: 3,\n\tmalformedResponse: 4,\n\tnetwork: 5,\n\ttls: 6,\n\tnoRequestSlot: 7,\n\t/**\n\t * An online change replaced the code of a job that was running: its step and stored state\n\t * were made for the old code, so it stops instead of resuming in the new. Like `cancelled`,\n\t * it skips `catch`, so a retry can't send a request twice.\n\t */\n\tcodeChanged: 11001,\n} as const;\n\n
|
|
7
|
-
"/** Milliseconds since the process started, as the PLC's `
|
|
5
|
+
"import { relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { failureCode, failureName } from \"../src/ir/job-errors\";\nimport { plcTime } from \"./plc-time\";\n\ntype Reported = Readonly<Record<string, unknown>>;\nclass Text {\n\tconstructor(readonly value: string) {}\n}\ntype Value = boolean | number | bigint | string | Text;\ntype Properties = Readonly<Record<string, Value>>;\n\nconst module = fileURLToPath(import.meta.url);\nlet collector: ((record: Reported) => void) | undefined;\n\n/** The program's call: the first stack frame outside this module, relative to the working directory. */\nconst source = () => {\n\tfor (const line of new Error().stack?.split(\"\\n\") ?? []) {\n\t\tconst [, file, lineNumber] =\n\t\t\t/\\(?((?:\\/|[A-Za-z]:\\\\)[^():]+):(\\d+):\\d+\\)?$/.exec(line) ?? [];\n\t\tif (file && file !== module) {\n\t\t\treturn `${relative(process.cwd(), file).replaceAll(\"\\\\\", \"/\")}:${lineNumber}`;\n\t\t}\n\t}\n\treturn \"\";\n};\n\nconst reportedValue = (value: Value) => {\n\tif (value instanceof Text) {\n\t\treturn value.value;\n\t}\n\tif (typeof value === \"bigint\") {\n\t\treturn Number(value);\n\t}\n\treturn value;\n};\n\nconst report = (record: Reported, properties: Properties = {}) =>\n\tcollector?.({\n\t\t...record,\n\t\tproperties: Object.fromEntries(\n\t\t\tObject.entries(properties).map(([name, value]) => [\n\t\t\t\tname,\n\t\t\t\treportedValue(value),\n\t\t\t]),\n\t\t),\n\t\tsource: source(),\n\t\tscan: 0,\n\t\ttime: plcTime(),\n\t});\n\n/** What a PLC program's `telemetry` calls do under Bun; see `types/telemetry.d.ts`. */\nexport const telemetry = {\n\tcapture: (event: string, properties?: Properties) =>\n\t\treport({ kind: \"event\", event }, properties),\n\tinfo: (message: string, properties?: Properties) =>\n\t\treport({ kind: \"log\", level: \"info\", message }, properties),\n\twarn: (message: string, properties?: Properties) =>\n\t\treport({ kind: \"log\", level: \"warn\", message }, properties),\n\terror: (message: string, properties?: Properties) =>\n\t\treport({ kind: \"log\", level: \"error\", message }, properties),\n\t// Under Bun a failure can be a thrown Error rather than a code; it is sent as code 0 with its message.\n\tcaptureException: (error: unknown, properties?: Properties) => {\n\t\tconst code = failureCode(error);\n\t\tconst name = failureName(error);\n\t\treport(\n\t\t\t{ kind: \"exception\", code, ...(name && { name }), handled: true },\n\t\t\tproperties,\n\t\t);\n\t},\n\ttext: (bytes: readonly number[], length: number) => {\n\t\tconst sent = bytes.slice(0, Math.max(0, Math.min(length, bytes.length)));\n\t\tconst end = sent.indexOf(0);\n\t\treturn new Text(\n\t\t\tnew TextDecoder().decode(\n\t\t\t\tUint8Array.from(end < 0 ? sent : sent.slice(0, end)),\n\t\t\t),\n\t\t);\n\t},\n};\n\nexport const onTelemetry = (next: (record: Reported) => void) => {\n\tcollector = next;\n\treturn () => {\n\t\tif (collector === next) {\n\t\t\tcollector = undefined;\n\t\t}\n\t};\n};\n",
|
|
6
|
+
"/** Job error codes by meaning, as generated async blocks and service calls set them. */\nexport const jobError = {\n\tcancelled: 1,\n\ttimeout: 2,\n\ttooLarge: 3,\n\tmalformedResponse: 4,\n\tnetwork: 5,\n\ttls: 6,\n\tnoRequestSlot: 7,\n\t/**\n\t * An online change replaced the code of a job that was running: its step and stored state\n\t * were made for the old code, so it stops instead of resuming in the new. Like `cancelled`,\n\t * it skips `catch`, so a retry can't send a request twice.\n\t */\n\tcodeChanged: 11001,\n} as const;\n\nconst httpBase = 10000;\n\n/**\n * An HTTP response fails a job with `base` + its status, up to `last`. `refused` is a 400: the\n * server can't take the request, so sending it again cannot succeed.\n */\nexport const httpErrors = {\n\tbase: httpBase,\n\tlast: 10999,\n\trefused: httpBase + 400,\n};\n\n/** Codes tsPLC itself reports from 11000 on, which a program's own `throw` may not use. */\nexport const reservedErrors = { first: 11000, last: 11099 };\n\nconst errorMeanings: Record<number, string> = {\n\t[jobError.cancelled]: \"cancelled\",\n\t[jobError.timeout]: \"timeout\",\n\t[jobError.tooLarge]: \"request or response too large to encode\",\n\t[jobError.malformedResponse]: \"malformed response\",\n\t[jobError.network]: \"network error or server restarted\",\n\t[jobError.tls]: \"TLS error\",\n\t[jobError.noRequestSlot]: \"no free request slot\",\n\t[jobError.codeChanged]:\n\t\t\"an online change replaced the job's code while it ran\",\n};\n\n/** Job error codes, as every generated async block and service call reports them. */\nexport const jobErrors: Record<string, string> = {\n\t...errorMeanings,\n\t[httpErrors.base]: `HTTP status: ${httpErrors.base} + status code`,\n};\n\n/** What a telemetry exception record calls an error code: its meaning when it is a job error. */\nexport const errorName = (code: number): string | undefined => {\n\tif (code > httpErrors.base && code <= httpErrors.last) {\n\t\treturn `HTTP ${code - httpErrors.base}`;\n\t}\n\treturn errorMeanings[code];\n};\n\n/** The code a failure reports: its job error code, or 0 for anything else thrown, such as an Error under Bun. */\nexport const failureCode = (reason: unknown): number =>\n\ttypeof reason === \"number\" ? reason : 0;\n\n/** What an exception record calls a failure: a job error's meaning, or a thrown Error's message. */\nexport const failureName = (reason: unknown): string | undefined => {\n\tif (typeof reason === \"number\") {\n\t\treturn errorName(reason);\n\t}\n\treturn reason instanceof Error ? reason.message : String(reason);\n};\n",
|
|
7
|
+
"/** Milliseconds since the process started, as the PLC's `TIME()` counts them in a UDINT, which telemetry's `time` carries. */\nexport const plcTime = (): number => Math.floor(performance.now()) >>> 0;\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";AAAA;AACA;;;ACAO,IAAM,WAAW;AAAA,EACvB,WAAW;AAAA,EACX,SAAS;AAAA,EACT,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,KAAK;AAAA,EACL,eAAe;AAAA,EAMf,aAAa;AACd;
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";AAAA;AACA;;;ACAO,IAAM,WAAW;AAAA,EACvB,WAAW;AAAA,EACX,SAAS;AAAA,EACT,UAAU;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EAAE,KAAK,GAAI,SAAS,KAAK,GAChE,UACD;AAAA;AAAA,EAED,MAAM,CAAC,OAA0B,WAAmB;AAAA,IACnD,MAAM,OAAO,MAAM,MAAM,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,MAAM,MAAM,CAAC,CAAC;AAAA,IACvE,MAAM,MAAM,KAAK,QAAQ,CAAC;AAAA,IAC1B,OAAO,IAAI,KACV,IAAI,YAAY,EAAE,OACjB,WAAW,KAAK,MAAM,IAAI,OAAO,KAAK,MAAM,GAAG,GAAG,CAAC,CACpD,CACD;AAAA;AAEF;AAEO,IAAM,cAAc,CAAC,SAAqC;AAAA,EAChE,YAAY;AAAA,EACZ,OAAO,MAAM;AAAA,IACZ,IAAI,cAAc,MAAM;AAAA,MACvB,YAAY;AAAA,IACb;AAAA;AAAA;",
|
|
10
|
+
"debugId": "A73F9037C038FC8864756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"url": "git+https://github.com/rip-technologies/tsplc.git",
|
|
18
18
|
"directory": "packages/compiler"
|
|
19
19
|
},
|
|
20
|
-
"version": "0.5.
|
|
20
|
+
"version": "0.5.15",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
@@ -35,11 +35,6 @@
|
|
|
35
35
|
"bun": "./src/codesys/index.ts",
|
|
36
36
|
"default": "./dist/codesys.js"
|
|
37
37
|
},
|
|
38
|
-
"./project": {
|
|
39
|
-
"types": "./src/project/index.ts",
|
|
40
|
-
"bun": "./src/project/index.ts",
|
|
41
|
-
"default": "./dist/project.js"
|
|
42
|
-
},
|
|
43
38
|
"./clock": {
|
|
44
39
|
"types": "./types/clock.d.ts",
|
|
45
40
|
"bun": "./stdlib/clock.ts",
|
|
@@ -55,24 +50,20 @@
|
|
|
55
50
|
"bun": "./stdlib/retain.ts",
|
|
56
51
|
"default": "./dist/retain.js"
|
|
57
52
|
},
|
|
58
|
-
"./math": {
|
|
59
|
-
"types": "./stdlib/math.ts",
|
|
60
|
-
"bun": "./stdlib/math.ts",
|
|
61
|
-
"default": "./dist/math.js"
|
|
62
|
-
},
|
|
63
53
|
"./collections": {
|
|
64
54
|
"types": "./stdlib/collections.ts",
|
|
65
55
|
"bun": "./stdlib/collections.ts",
|
|
66
56
|
"default": "./dist/collections.js"
|
|
67
57
|
},
|
|
58
|
+
"./signals": {
|
|
59
|
+
"types": "./stdlib/signals.ts",
|
|
60
|
+
"bun": "./stdlib/signals.ts",
|
|
61
|
+
"default": "./dist/signals.js"
|
|
62
|
+
},
|
|
68
63
|
"./types": {
|
|
69
64
|
"types": "./types/index.d.ts",
|
|
70
65
|
"default": "./types/index.d.ts"
|
|
71
66
|
},
|
|
72
|
-
"./data-types": {
|
|
73
|
-
"types": "./types/data-types.d.ts",
|
|
74
|
-
"default": "./types/data-types.d.ts"
|
|
75
|
-
},
|
|
76
67
|
"./globals": {
|
|
77
68
|
"types": "./types/globals.d.ts",
|
|
78
69
|
"default": "./types/globals.d.ts"
|
|
@@ -84,10 +75,6 @@
|
|
|
84
75
|
"./config": {
|
|
85
76
|
"types": "./types/config.d.ts",
|
|
86
77
|
"default": "./types/config.d.ts"
|
|
87
|
-
},
|
|
88
|
-
"./plc": {
|
|
89
|
-
"types": "./types/plc.d.ts",
|
|
90
|
-
"default": "./types/plc.d.ts"
|
|
91
78
|
}
|
|
92
79
|
},
|
|
93
80
|
"files": [
|
|
@@ -106,17 +93,17 @@
|
|
|
106
93
|
"bun": ">=1.4.3"
|
|
107
94
|
},
|
|
108
95
|
"dependencies": {
|
|
109
|
-
"@tsplc/agent": "0.5.
|
|
110
|
-
"@tsplc/build": "0.5.
|
|
111
|
-
"@tsplc/config": "0.5.
|
|
112
|
-
"@tsplc/debug": "0.5.
|
|
113
|
-
"@tsplc/opcua": "0.5.
|
|
114
|
-
"@tsplc/typegen": "0.5.
|
|
96
|
+
"@tsplc/agent": "0.5.15",
|
|
97
|
+
"@tsplc/build": "0.5.15",
|
|
98
|
+
"@tsplc/config": "0.5.15",
|
|
99
|
+
"@tsplc/debug": "0.5.15",
|
|
100
|
+
"@tsplc/opcua": "0.5.15",
|
|
101
|
+
"@tsplc/typegen": "0.5.15",
|
|
115
102
|
"typescript": "6.0.3",
|
|
116
103
|
"zod": "4.3.6",
|
|
117
104
|
"@types/bun": "1.4.2",
|
|
118
|
-
"@tsplc/server": "0.5.
|
|
119
|
-
"@tsplc/iec": "0.5.
|
|
105
|
+
"@tsplc/server": "0.5.15",
|
|
106
|
+
"@tsplc/iec": "0.5.15"
|
|
120
107
|
},
|
|
121
108
|
"bin": {
|
|
122
109
|
"tsplc": "./dist/cli.js"
|
|
@@ -124,20 +111,13 @@
|
|
|
124
111
|
"buildEntries": {
|
|
125
112
|
"./dist/cli.js": {
|
|
126
113
|
"source": "./src/project/cli.ts"
|
|
127
|
-
},
|
|
128
|
-
"./dist/elaborate-capture.js": {
|
|
129
|
-
"source": "./src/frontend/elaborate/capture.ts",
|
|
130
|
-
"target": "bun"
|
|
131
|
-
},
|
|
132
|
-
"./dist/bun-runtime.js": {
|
|
133
|
-
"source": "./src/runtime/main.ts",
|
|
134
|
-
"target": "bun"
|
|
135
|
-
},
|
|
136
|
-
"./dist/server-check.js": {
|
|
137
|
-
"source": "./src/project/server-check.ts",
|
|
138
|
-
"target": "bun"
|
|
139
114
|
}
|
|
140
115
|
},
|
|
116
|
+
"imports": {
|
|
117
|
+
"#elaborate-capture": "./src/frontend/elaborate/capture.ts",
|
|
118
|
+
"#bun-runtime": "./src/runtime/main.ts",
|
|
119
|
+
"#server-check": "./src/project/server-check.ts"
|
|
120
|
+
},
|
|
141
121
|
"publishConfig": {
|
|
142
122
|
"access": "public"
|
|
143
123
|
}
|
package/src/codesys/config.ts
CHANGED
|
@@ -18,17 +18,17 @@ const addressSchema = directIoBindingSchema.extend({
|
|
|
18
18
|
// Explicit IEC object names keep their exact spelling, so they must already be valid.
|
|
19
19
|
const iecNames = z
|
|
20
20
|
.record(
|
|
21
|
-
z.string().
|
|
21
|
+
z.string().nonempty(),
|
|
22
22
|
z
|
|
23
23
|
.string()
|
|
24
24
|
.refine(isIecIdentifier, "Use a valid, non-reserved IEC identifier."),
|
|
25
25
|
)
|
|
26
|
-
.
|
|
26
|
+
.default({});
|
|
27
27
|
export const optionsSchema = z
|
|
28
28
|
.object({
|
|
29
29
|
engineering: engineeringSchema,
|
|
30
30
|
http: httpOptionsSchema,
|
|
31
|
-
io: z.record(z.string().
|
|
31
|
+
io: z.record(z.string().nonempty(), addressSchema),
|
|
32
32
|
publish: publicationSchema.default({ production: [], development: [] }),
|
|
33
33
|
buildTarget: buildTargetSchema.default("production"),
|
|
34
34
|
programNames: iecNames,
|