@tsplc/compiler 0.5.2 → 0.5.4
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/bun-runtime.js.map +7 -7
- package/dist/cli.js.map +8 -8
- package/dist/codesys.js +91 -20
- package/dist/codesys.js.map +24 -24
- package/dist/elaborate-capture.js.map +1 -1
- package/dist/index.js.map +35 -35
- package/dist/ir.js.map +19 -19
- package/dist/project.js.map +1 -1
- package/dist/server-check.js.map +1 -1
- package/dist/telemetry.js.map +1 -1
- package/package.json +9 -9
- package/src/codesys/config.ts +2 -2
- package/src/codesys/debug.ts +2 -2
- package/src/codesys/emit.ts +10 -10
- package/src/codesys/engineering.ts +1 -1
- package/src/codesys/expressions.ts +1 -1
- package/src/codesys/global-lists.ts +6 -6
- package/src/codesys/global-names.ts +3 -3
- package/src/codesys/http.ts +77 -6
- package/src/codesys/index.ts +8 -8
- package/src/codesys/instrumentation.ts +9 -13
- package/src/codesys/io-paths.ts +1 -1
- package/src/codesys/manifest.ts +5 -5
- package/src/codesys/plan.ts +9 -9
- package/src/codesys/programs.ts +3 -3
- package/src/codesys/publication.ts +4 -4
- package/src/codesys/routines.ts +5 -5
- package/src/codesys/sources.ts +48 -8
- package/src/codesys/st-files.ts +14 -20
- package/src/codesys/symbols.ts +6 -6
- package/src/codesys/telemetry.ts +8 -8
- package/src/codesys/types.ts +2 -2
- package/src/codesys/vendor.ts +2 -2
- package/src/frontend/analyzer.ts +9 -9
- package/src/frontend/async.ts +6 -6
- package/src/frontend/blocks.ts +1 -1
- package/src/frontend/configuration.ts +4 -4
- package/src/frontend/const-functions.ts +2 -2
- package/src/frontend/cooperative.ts +1 -1
- package/src/frontend/coroutines.ts +6 -6
- package/src/frontend/elaborate/calls.ts +9 -12
- package/src/frontend/elaborate/capture.ts +1 -1
- package/src/frontend/elaborate/dialect.ts +7 -7
- package/src/frontend/elaborate/expressions.ts +12 -12
- package/src/frontend/elaborate/frame.ts +4 -4
- package/src/frontend/elaborate/graph.ts +1 -1
- package/src/frontend/elaborate/index.ts +12 -12
- package/src/frontend/elaborate/initializers.ts +4 -4
- package/src/frontend/elaborate/layouts.ts +3 -3
- package/src/frontend/elaborate/model.ts +1 -1
- package/src/frontend/elaborate/retention.ts +5 -5
- package/src/frontend/elaborate/specialize.ts +11 -11
- package/src/frontend/elaborate/statements.ts +8 -11
- package/src/frontend/elaborate/storage.ts +6 -11
- package/src/frontend/elaborate/values.ts +2 -2
- package/src/frontend/exposure.ts +3 -3
- package/src/frontend/expressions.ts +5 -5
- package/src/frontend/intrinsics.ts +2 -2
- package/src/frontend/module-graph.ts +1 -1
- package/src/frontend/promise-chains.ts +2 -2
- package/src/frontend/promises.ts +5 -5
- package/src/frontend/routines.ts +2 -2
- package/src/frontend/services.ts +3 -3
- package/src/frontend/statements.ts +4 -4
- package/src/frontend/tasks.ts +5 -10
- package/src/frontend/telemetry.ts +2 -2
- package/src/frontend/types.ts +1 -1
- package/src/frontend/typescript.ts +11 -15
- package/src/index.ts +1 -1
- package/src/ir/aggregates.ts +6 -6
- package/src/ir/allocation.ts +5 -5
- package/src/ir/core-model.ts +3 -3
- package/src/ir/declarations.ts +6 -6
- package/src/ir/domains.ts +3 -7
- package/src/ir/fold.ts +4 -9
- package/src/ir/index.ts +16 -16
- package/src/ir/layouts.ts +3 -3
- package/src/ir/link.ts +5 -5
- package/src/ir/model.ts +2 -2
- package/src/ir/normalization-error.ts +1 -1
- package/src/ir/normalize.ts +8 -8
- package/src/ir/numeric.ts +2 -2
- package/src/ir/operands.ts +2 -2
- package/src/ir/ranges.ts +4 -9
- package/src/ir/routine.ts +10 -15
- package/src/ir/scalars.ts +5 -5
- package/src/ir/share.ts +4 -4
- package/src/ir/temporaries.ts +4 -4
- package/src/project/cli.ts +3 -3
- package/src/project/debugger.ts +1 -1
- package/src/project/index.ts +1 -1
- package/src/project/plant.ts +2 -2
- package/src/project/project-commands.ts +3 -3
- package/src/project/project.ts +2 -2
- package/src/project/release.ts +2 -2
- package/src/project/server-check.ts +1 -1
- package/src/runtime/main.ts +2 -2
- package/src/runtime/process.ts +1 -1
- package/src/runtime/program.ts +2 -2
- package/src/runtime/retain.ts +1 -1
- package/src/runtime/runtime.ts +11 -16
- package/stdlib/telemetry.ts +2 -2
package/dist/codesys.js
CHANGED
|
@@ -1427,6 +1427,11 @@ import { secretValue } from "@tsplc/config";
|
|
|
1427
1427
|
import { elementaryType, integerRange as integerRange2 } from "@tsplc/iec";
|
|
1428
1428
|
import { plcBufferBytes } from "@tsplc/server/wire";
|
|
1429
1429
|
var opcuaServiceCapacity = 16;
|
|
1430
|
+
var socketLevel = "16#FFFF";
|
|
1431
|
+
var socketKeepAliveOption = "16#8";
|
|
1432
|
+
var keepAliveIdleMs = 2000;
|
|
1433
|
+
var keepAliveIntervalMs = 1000;
|
|
1434
|
+
var keepAliveProbes = 3;
|
|
1430
1435
|
var resolveHttpEndpoint = (value, input, environment) => {
|
|
1431
1436
|
const url = new URL(value);
|
|
1432
1437
|
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.hash || url.hostname.includes(":")) {
|
|
@@ -1721,6 +1726,7 @@ VAR
|
|
|
1721
1726
|
writer : NBS.TCP_Write;
|
|
1722
1727
|
reader : NBS.TCP_Read;
|
|
1723
1728
|
timeout : TON;
|
|
1729
|
+
keepAlive : ${name}_KeepAlive;
|
|
1724
1730
|
stage : UINT;
|
|
1725
1731
|
wire : STRING(8192);
|
|
1726
1732
|
received : STRING(8192);
|
|
@@ -1748,6 +1754,7 @@ END_VAR
|
|
|
1748
1754
|
RETURN;
|
|
1749
1755
|
END_IF;
|
|
1750
1756
|
IF stage=0 THEN
|
|
1757
|
+
client.SetOptionProvider(itfOptionProvider:=keepAlive);
|
|
1751
1758
|
payload:=''; malformed:=FALSE; used:=0; received:='';${trace ? `
|
|
1752
1759
|
${trace.sequence}:=${trace.sequence}+1;` : ""}
|
|
1753
1760
|
${body}
|
|
@@ -1828,7 +1835,55 @@ END_VAR`,
|
|
|
1828
1835
|
${release}
|
|
1829
1836
|
FB_exit:=TRUE;`
|
|
1830
1837
|
};
|
|
1831
|
-
return [block, exit];
|
|
1838
|
+
return [block, exit, ...tcpKeepAlive(id, name)];
|
|
1839
|
+
};
|
|
1840
|
+
var tcpKeepAlive = (owner, name) => {
|
|
1841
|
+
const id = `${owner}:keepAlive`;
|
|
1842
|
+
return [
|
|
1843
|
+
{
|
|
1844
|
+
id,
|
|
1845
|
+
kind: "functionBlock",
|
|
1846
|
+
name: `${name}_KeepAlive`,
|
|
1847
|
+
declaration: `FUNCTION_BLOCK ${name}_KeepAlive IMPLEMENTS NBS.IOptionProvider
|
|
1848
|
+
VAR
|
|
1849
|
+
keepAlive : ARRAY[0..6] OF DINT := [1, ${keepAliveProbes}, 0, ${keepAliveIdleMs}, 0, ${keepAliveIntervalMs}, 0];
|
|
1850
|
+
END_VAR`,
|
|
1851
|
+
implementation: ""
|
|
1852
|
+
},
|
|
1853
|
+
{
|
|
1854
|
+
id: `${id}:GetOptionCount`,
|
|
1855
|
+
parent: id,
|
|
1856
|
+
kind: "method",
|
|
1857
|
+
name: "GetOptionCount",
|
|
1858
|
+
declaration: `METHOD PUBLIC GetOptionCount : USINT
|
|
1859
|
+
VAR_OUTPUT eErrorID : NBS.ERROR; END_VAR`,
|
|
1860
|
+
implementation: "GetOptionCount:=1;eErrorID:=NBS.ERROR.NO_ERROR;"
|
|
1861
|
+
},
|
|
1862
|
+
{
|
|
1863
|
+
id: `${id}:GetParams`,
|
|
1864
|
+
parent: id,
|
|
1865
|
+
kind: "method",
|
|
1866
|
+
name: "GetParams",
|
|
1867
|
+
declaration: `METHOD PUBLIC GetParams : NBS.ERROR
|
|
1868
|
+
VAR_INPUT usiIndex : USINT; END_VAR
|
|
1869
|
+
VAR_OUTPUT eOperation : NBS.OPERATION; optOption : NBS.OPTION; END_VAR`,
|
|
1870
|
+
implementation: `eOperation:=NBS.OPERATION.SET_OPTION;
|
|
1871
|
+
optOption.diLevel:=${socketLevel};
|
|
1872
|
+
optOption.diOption:=${socketKeepAliveOption};
|
|
1873
|
+
optOption.pdiOptionValue:=ADR(keepAlive);
|
|
1874
|
+
optOption.udiOptionLen:=SIZEOF(keepAlive);
|
|
1875
|
+
GetParams:=NBS.ERROR.NO_ERROR;`
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
id: `${id}:SetResult`,
|
|
1879
|
+
parent: id,
|
|
1880
|
+
kind: "method",
|
|
1881
|
+
name: "SetResult",
|
|
1882
|
+
declaration: `METHOD PUBLIC SetResult : NBS.ERROR
|
|
1883
|
+
VAR_INPUT usiIndex : USINT; udiResult : UDINT; END_VAR`,
|
|
1884
|
+
implementation: "SetResult:=NBS.ERROR.NO_ERROR;"
|
|
1885
|
+
}
|
|
1886
|
+
];
|
|
1832
1887
|
};
|
|
1833
1888
|
var httpCertificateVerifier = (owner, name, endpoint) => {
|
|
1834
1889
|
if (!endpoint.tls) {
|
|
@@ -2540,11 +2595,35 @@ import {
|
|
|
2540
2595
|
} from "@tsplc/compiler/ir";
|
|
2541
2596
|
import { serviceOfPath } from "@tsplc/server";
|
|
2542
2597
|
// packages/compiler/package.json
|
|
2543
|
-
var version = "0.5.
|
|
2598
|
+
var version = "0.5.4";
|
|
2544
2599
|
|
|
2545
2600
|
// packages/compiler/src/codesys/sources.ts
|
|
2546
2601
|
import { existsSync, readFileSync } from "node:fs";
|
|
2547
|
-
import { isAbsolute, relative } from "node:path";
|
|
2602
|
+
import { dirname, isAbsolute, join, relative, resolve as resolve2 } from "node:path";
|
|
2603
|
+
var projectSource = (root, file) => {
|
|
2604
|
+
const path = relative(root, file);
|
|
2605
|
+
return !isAbsolute(path) && !path.split(/[\\/]/).includes("node_modules");
|
|
2606
|
+
};
|
|
2607
|
+
var packageDirectory = (directory) => {
|
|
2608
|
+
if (existsSync(join(directory, "package.json"))) {
|
|
2609
|
+
return directory;
|
|
2610
|
+
}
|
|
2611
|
+
const parent = dirname(directory);
|
|
2612
|
+
return parent === directory ? undefined : packageDirectory(parent);
|
|
2613
|
+
};
|
|
2614
|
+
var sourceFolders = (root, module) => {
|
|
2615
|
+
if (!/^[\w./ -]+\.tsx?$/.test(module)) {
|
|
2616
|
+
return;
|
|
2617
|
+
}
|
|
2618
|
+
const file = resolve2(root, module);
|
|
2619
|
+
if (!projectSource(root, file)) {
|
|
2620
|
+
return;
|
|
2621
|
+
}
|
|
2622
|
+
const base = relative(root, file).startsWith("..") ? packageDirectory(dirname(file)) ?? dirname(file) : root;
|
|
2623
|
+
const segments = relative(base, file).replaceAll("\\", "/").split("/");
|
|
2624
|
+
const folders = segments.slice(0, -1);
|
|
2625
|
+
return folders[0] === "src" ? folders.slice(1) : folders;
|
|
2626
|
+
};
|
|
2548
2627
|
|
|
2549
2628
|
class Sources {
|
|
2550
2629
|
root;
|
|
@@ -2557,10 +2636,8 @@ class Sources {
|
|
|
2557
2636
|
if (this.loaded.has(file)) {
|
|
2558
2637
|
return this.loaded.get(file);
|
|
2559
2638
|
}
|
|
2560
|
-
const path = relative(this.root, file);
|
|
2561
|
-
const inside = !path.startsWith("..") && !isAbsolute(path) && !path.split(/[\\/]/).includes("node_modules");
|
|
2562
2639
|
let source;
|
|
2563
|
-
if (
|
|
2640
|
+
if (projectSource(this.root, file) && existsSync(file)) {
|
|
2564
2641
|
const text = readFileSync(file, "utf8");
|
|
2565
2642
|
const lines = [0];
|
|
2566
2643
|
for (let index = 0;index < text.length; index++) {
|
|
@@ -2970,7 +3047,7 @@ ${instances.length ? ` instance : STRING(${maximum(instances)});
|
|
|
2970
3047
|
];
|
|
2971
3048
|
const { start, rest } = header(build);
|
|
2972
3049
|
const helpers = httpMethods(writer).filter((item) => ["ByteLength", "Append", "WriteString"].includes(item.name));
|
|
2973
|
-
const [client,
|
|
3050
|
+
const [client, ...clientLifecycle] = nativeHttp({
|
|
2974
3051
|
id: telemetryClient,
|
|
2975
3052
|
name: names.client,
|
|
2976
3053
|
ports: `VAR_INPUT
|
|
@@ -3131,7 +3208,7 @@ WriteString(text);
|
|
|
3131
3208
|
...failures,
|
|
3132
3209
|
...trace,
|
|
3133
3210
|
client,
|
|
3134
|
-
|
|
3211
|
+
...clientLifecycle,
|
|
3135
3212
|
...httpMethods(telemetryClient),
|
|
3136
3213
|
...httpCertificateVerifier(telemetryClient, names.client, endpoint)
|
|
3137
3214
|
];
|
|
@@ -4851,18 +4928,12 @@ function objectPaths(plan, symbols, objects) {
|
|
|
4851
4928
|
const owner = required2(block === undefined ? undefined : byId.get(block)?.item);
|
|
4852
4929
|
return `${objectPath(owner)}/methods/${object.name}`;
|
|
4853
4930
|
}
|
|
4854
|
-
const
|
|
4855
|
-
if (
|
|
4856
|
-
|
|
4857
|
-
if (segments[0] === "src") {
|
|
4858
|
-
segments.shift();
|
|
4859
|
-
}
|
|
4860
|
-
if (object.kind !== "dataType" && segments.at(-1) === object.name) {
|
|
4861
|
-
segments.pop();
|
|
4862
|
-
}
|
|
4863
|
-
return [...segments, object.name].join("/");
|
|
4931
|
+
const folders = sourceFolders(plan.project.root, sourceModule(object));
|
|
4932
|
+
if (!folders) {
|
|
4933
|
+
return `${generatedFolder(object)}/${object.name}`;
|
|
4864
4934
|
}
|
|
4865
|
-
|
|
4935
|
+
const kept = object.kind !== "dataType" && folders.at(-1) === object.name ? folders.slice(0, -1) : folders;
|
|
4936
|
+
return [...kept, object.name].join("/");
|
|
4866
4937
|
};
|
|
4867
4938
|
return objectPath;
|
|
4868
4939
|
}
|
|
@@ -5035,5 +5106,5 @@ export {
|
|
|
5035
5106
|
publicationSelectors
|
|
5036
5107
|
};
|
|
5037
5108
|
|
|
5038
|
-
//# debugId=
|
|
5109
|
+
//# debugId=C878C71EAAC4771A64756E2164756E21
|
|
5039
5110
|
//# sourceMappingURL=codesys.js.map
|