@tsplc/compiler 0.2.21 → 0.4.0
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 +1 -1
- package/dist/cli.js +280 -223
- package/dist/cli.js.map +12 -12
- package/dist/codesys.js +452 -330
- package/dist/codesys.js.map +24 -24
- package/dist/elaborate-capture.js +112 -7
- package/dist/elaborate-capture.js.map +5 -4
- package/dist/index.js +5682 -5407
- package/dist/index.js.map +39 -37
- package/dist/ir.js +1154 -327
- package/dist/ir.js.map +23 -20
- package/dist/project.js +68 -29
- package/dist/project.js.map +4 -4
- package/dist/retain.js +8 -0
- package/dist/retain.js.map +10 -0
- package/dist/server-check.js +59 -0
- package/dist/server-check.js.map +11 -0
- package/dist/telemetry.js +19 -10
- package/dist/telemetry.js.map +3 -3
- package/package.json +33 -12
- package/src/codesys/config.ts +1 -1
- package/src/codesys/debug.ts +7 -21
- package/src/codesys/engineering.ts +8 -12
- package/src/codesys/global-lists.ts +19 -17
- package/src/codesys/global-names.ts +3 -3
- package/src/codesys/http.ts +37 -34
- package/src/codesys/index.ts +5 -22
- package/src/codesys/instrumentation.ts +3 -1
- package/src/codesys/io-paths.ts +2 -1
- package/src/codesys/manifest.ts +35 -18
- package/src/codesys/numeric.ts +2 -4
- package/src/codesys/plan.ts +94 -26
- package/src/codesys/publication.ts +4 -3
- package/src/codesys/routines.ts +2 -2
- package/src/codesys/sources.ts +1 -0
- package/src/codesys/st-files.ts +86 -50
- package/src/codesys/storage.ts +44 -9
- package/src/codesys/task-access.ts +32 -10
- package/src/codesys/telemetry.ts +93 -46
- package/src/codesys/types.ts +81 -3
- package/src/codesys/vendor.ts +1 -1
- package/src/frontend/analyzer.ts +15 -14
- package/src/frontend/async.ts +23 -21
- package/src/frontend/blocks.ts +7 -6
- package/src/frontend/configuration.ts +8 -6
- package/src/frontend/const-functions.ts +5 -5
- package/src/frontend/cooperative.ts +2 -1
- package/src/frontend/coroutines.ts +24 -21
- package/src/frontend/elaborate/calls.ts +12 -7
- package/src/frontend/elaborate/capture-protocol.ts +103 -0
- package/src/frontend/elaborate/capture.ts +48 -19
- package/src/frontend/elaborate/dialect.ts +2 -2
- package/src/frontend/elaborate/expressions.ts +9 -6
- package/src/frontend/elaborate/frame.ts +1 -1
- package/src/frontend/elaborate/graph.ts +27 -43
- package/src/frontend/elaborate/index.ts +52 -17
- package/src/frontend/elaborate/initializers.ts +3 -2
- package/src/frontend/elaborate/layouts.ts +2 -2
- package/src/frontend/elaborate/model.ts +34 -21
- package/src/frontend/elaborate/retention.ts +206 -0
- package/src/frontend/elaborate/specialize.ts +7 -6
- package/src/frontend/elaborate/statements.ts +47 -38
- package/src/frontend/elaborate/storage.ts +26 -6
- package/src/frontend/exposure.ts +6 -6
- package/src/frontend/expressions.ts +26 -25
- package/src/frontend/intrinsics.ts +3 -3
- package/src/frontend/module-graph.ts +1 -1
- package/src/frontend/positions.ts +2 -1
- package/src/frontend/promise-chains.ts +1 -0
- package/src/frontend/promises.ts +8 -7
- package/src/frontend/routines.ts +3 -2
- package/src/frontend/sdk.ts +2 -2
- package/src/frontend/services.ts +23 -20
- package/src/frontend/statements.ts +8 -6
- package/src/frontend/tasks.ts +11 -6
- package/src/frontend/telemetry.ts +1 -1
- package/src/frontend/types.ts +11 -9
- package/src/frontend/typescript.ts +92 -42
- package/src/index.ts +2 -1
- package/src/ir/aggregates.ts +4 -3
- package/src/ir/allocation.ts +2 -1
- package/src/ir/core-model.ts +38 -8
- package/src/ir/declarations.ts +12 -12
- package/src/ir/domains.ts +8 -8
- package/src/ir/fold.ts +2 -2
- package/src/ir/index.ts +53 -40
- package/src/ir/job-errors.ts +22 -11
- package/src/ir/layouts.ts +3 -2
- package/src/ir/link.ts +6 -24
- package/src/ir/model.ts +3 -2
- package/src/ir/normalization-error.ts +1 -1
- package/src/ir/normalize.ts +19 -12
- package/src/ir/numeric.ts +1 -0
- package/src/{codesys → ir}/operands.ts +2 -6
- package/src/ir/ranges.ts +2 -2
- package/src/ir/routine.ts +35 -20
- package/src/ir/scalars.ts +3 -3
- package/src/ir/share.ts +862 -0
- package/src/ir/temporaries.ts +236 -0
- package/src/ir/types.ts +1 -1
- package/src/project/artifacts.ts +12 -2
- package/src/project/cli.ts +42 -44
- package/src/project/debugger.ts +15 -9
- package/src/project/index.ts +1 -1
- package/src/project/plant.ts +34 -23
- package/src/project/project-commands.ts +92 -73
- package/src/project/project.ts +91 -42
- package/src/project/release.ts +50 -57
- package/src/project/server-check.ts +54 -0
- package/src/project/server.ts +60 -41
- package/src/project/terminal.ts +3 -1
- package/stdlib/retain.ts +2 -0
- package/types/globals.d.ts +1 -0
- package/types/retain.d.ts +6 -0
- package/types/telemetry.d.ts +2 -2
package/src/project/release.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { basename, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
|
-
import type { ReleaseFile } from "@tsplc/agent/client";
|
|
5
4
|
import type { ReleaseManifest } from "@tsplc/agent";
|
|
5
|
+
import type { ReleaseFile } from "@tsplc/agent/client";
|
|
6
|
+
import type { CompileEnvironment } from "@tsplc/compiler";
|
|
7
|
+
import { hasErrors } from "@tsplc/compiler/ir";
|
|
6
8
|
import {
|
|
7
9
|
buildTargetFor,
|
|
8
10
|
controllerFor,
|
|
11
|
+
type LoadedConfig,
|
|
9
12
|
serverTokenEnv,
|
|
10
|
-
type loadTsplcConfig,
|
|
11
13
|
} from "@tsplc/config";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { buildConfigs, buildProject
|
|
17
|
-
import { bundleServer } from "./server.ts";
|
|
18
|
-
|
|
19
|
-
type LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;
|
|
14
|
+
import type { ReleaseConfig } from "@tsplc/config/build";
|
|
15
|
+
import { debugManifestFile } from "@tsplc/debug/manifest";
|
|
16
|
+
import { contractVariables, plcContractSchema } from "@tsplc/opcua/contract";
|
|
17
|
+
import { generatedFiles, generateProject } from "@tsplc/typegen";
|
|
18
|
+
import { buildConfigs, buildProject } from "./project.ts";
|
|
19
|
+
import { bundleServer, checkServer } from "./server.ts";
|
|
20
20
|
|
|
21
21
|
/** Every published leaf the generated contract describes, as CODESYS expressions name it. */
|
|
22
22
|
const releaseVariables = async (
|
|
@@ -26,27 +26,12 @@ const releaseVariables = async (
|
|
|
26
26
|
if (!config.typegen) {
|
|
27
27
|
return [];
|
|
28
28
|
}
|
|
29
|
-
const contract =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
z.string(),
|
|
36
|
-
z.array(
|
|
37
|
-
z.object({
|
|
38
|
-
field: z.string(),
|
|
39
|
-
type: z.string(),
|
|
40
|
-
description: z.string(),
|
|
41
|
-
}),
|
|
42
|
-
),
|
|
43
|
-
),
|
|
44
|
-
})
|
|
45
|
-
.parse(
|
|
46
|
-
await import(
|
|
47
|
-
pathToFileURL(resolve(root, config.typegen.dir, "plc.ts")).href
|
|
48
|
-
),
|
|
49
|
-
);
|
|
29
|
+
const contract = plcContractSchema.parse(
|
|
30
|
+
await import(
|
|
31
|
+
pathToFileURL(resolve(root, config.typegen.dir, generatedFiles.contract))
|
|
32
|
+
.href
|
|
33
|
+
),
|
|
34
|
+
);
|
|
50
35
|
return contractVariables(contract).map(({ path, type }) => ({ path, type }));
|
|
51
36
|
};
|
|
52
37
|
|
|
@@ -59,12 +44,18 @@ export const prepareRelease = async (
|
|
|
59
44
|
file: string,
|
|
60
45
|
loaded: LoadedConfig,
|
|
61
46
|
flags: { simulate?: boolean; "frozen-lockfile"?: boolean },
|
|
47
|
+
environment: CompileEnvironment,
|
|
62
48
|
) => {
|
|
63
49
|
const { config, root } = loaded;
|
|
64
50
|
if (!config.compiler) {
|
|
65
51
|
throw new Error("tsplc deploy deploys tsPLC programs; configure compiler.");
|
|
66
52
|
}
|
|
67
53
|
const command = flags.simulate ? "run" : "deploy";
|
|
54
|
+
const serverCheck = config.server?.runtime
|
|
55
|
+
? checkServer(config, root)
|
|
56
|
+
: undefined;
|
|
57
|
+
// A failed PLC build reports its own diagnostics; the check's outcome is read only after a success.
|
|
58
|
+
serverCheck?.catch(() => undefined);
|
|
68
59
|
const emitted = await buildProject(file, {
|
|
69
60
|
emitOnly: true,
|
|
70
61
|
forController: true,
|
|
@@ -72,6 +63,7 @@ export const prepareRelease = async (
|
|
|
72
63
|
...buildConfigs(loaded, flags),
|
|
73
64
|
buildTarget: buildTargetFor(command),
|
|
74
65
|
controller: controllerFor(config, command),
|
|
66
|
+
environment,
|
|
75
67
|
});
|
|
76
68
|
if (hasErrors(emitted.diagnostics)) {
|
|
77
69
|
return { diagnostics: emitted.diagnostics };
|
|
@@ -80,10 +72,7 @@ export const prepareRelease = async (
|
|
|
80
72
|
if (!settings) {
|
|
81
73
|
throw new Error("Configure build settings for deployment.");
|
|
82
74
|
}
|
|
83
|
-
await generateProject(file, {
|
|
84
|
-
loaded,
|
|
85
|
-
targets: await projectTargets(file, { loaded }),
|
|
86
|
-
});
|
|
75
|
+
await generateProject(file, { loaded, targets: emitted.targets });
|
|
87
76
|
|
|
88
77
|
const portable = (path: string) => path.split(sep).join("/");
|
|
89
78
|
const libraries = (settings.libraries ?? []).map((library) => ({
|
|
@@ -108,12 +97,12 @@ export const prepareRelease = async (
|
|
|
108
97
|
});
|
|
109
98
|
}
|
|
110
99
|
// The agent's debugger reads the program through its debug manifest.
|
|
111
|
-
const debugManifest = resolve(settings.sourceDir,
|
|
100
|
+
const debugManifest = resolve(settings.sourceDir, debugManifestFile);
|
|
112
101
|
if (existsSync(debugManifest)) {
|
|
113
|
-
files.push({ path:
|
|
102
|
+
files.push({ path: debugManifestFile, content: Bun.file(debugManifest) });
|
|
114
103
|
}
|
|
115
104
|
const serverScript =
|
|
116
|
-
|
|
105
|
+
serverCheck && (await bundleServer(await serverCheck, config, root));
|
|
117
106
|
const server = serverScript
|
|
118
107
|
? {
|
|
119
108
|
path: `server/${basename(serverScript)}`,
|
|
@@ -123,26 +112,30 @@ export const prepareRelease = async (
|
|
|
123
112
|
if (server) {
|
|
124
113
|
files.push(server);
|
|
125
114
|
}
|
|
115
|
+
// Paths are relative to the release. Naming every release field keeps a new build setting
|
|
116
|
+
// from reaching the agent, or being left behind, without a decision here.
|
|
117
|
+
const releaseConfig: {
|
|
118
|
+
[Key in keyof Required<ReleaseConfig>]: ReleaseConfig[Key];
|
|
119
|
+
} = {
|
|
120
|
+
io: {},
|
|
121
|
+
deviceTree: settings.deviceTree,
|
|
122
|
+
controller: settings.controller,
|
|
123
|
+
libraryReferences: settings.libraryReferences,
|
|
124
|
+
libraries: libraries.map(({ release, ...library }) => ({
|
|
125
|
+
...library,
|
|
126
|
+
path: release,
|
|
127
|
+
})),
|
|
128
|
+
task: settings.task,
|
|
129
|
+
tasks: settings.tasks,
|
|
130
|
+
removeObjects: settings.removeObjects,
|
|
131
|
+
symbols: settings.symbols,
|
|
132
|
+
timeouts: settings.timeouts,
|
|
133
|
+
template: "template.project",
|
|
134
|
+
sourceDir: "st",
|
|
135
|
+
entry: `st/${portable(relative(settings.sourceDir, settings.entry))}`,
|
|
136
|
+
};
|
|
126
137
|
const manifest: ReleaseManifest = {
|
|
127
|
-
|
|
128
|
-
config: {
|
|
129
|
-
io: {},
|
|
130
|
-
deviceTree: settings.deviceTree,
|
|
131
|
-
controller: settings.controller,
|
|
132
|
-
libraryReferences: settings.libraryReferences,
|
|
133
|
-
libraries: libraries.map(({ release, ...library }) => ({
|
|
134
|
-
...library,
|
|
135
|
-
path: release,
|
|
136
|
-
})),
|
|
137
|
-
task: settings.task,
|
|
138
|
-
tasks: settings.tasks,
|
|
139
|
-
removeObjects: settings.removeObjects,
|
|
140
|
-
symbols: settings.symbols,
|
|
141
|
-
timeouts: settings.timeouts,
|
|
142
|
-
template: "template.project",
|
|
143
|
-
sourceDir: "st",
|
|
144
|
-
entry: `st/${portable(relative(settings.sourceDir, settings.entry))}`,
|
|
145
|
-
},
|
|
138
|
+
config: releaseConfig,
|
|
146
139
|
variables: await releaseVariables(config, root),
|
|
147
140
|
server: server?.path,
|
|
148
141
|
debug: config.debug,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { typeCheckOnly } from "@tsplc/compiler";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import type { z } from "zod";
|
|
5
|
+
import {
|
|
6
|
+
serverCheckRequestSchema,
|
|
7
|
+
type serverCheckResultSchema,
|
|
8
|
+
} from "./server.ts";
|
|
9
|
+
|
|
10
|
+
/** Type-checks the server entry under the tsconfig beside it, as it will be built. */
|
|
11
|
+
const serverFailure = ({
|
|
12
|
+
entry,
|
|
13
|
+
root,
|
|
14
|
+
}: z.infer<typeof serverCheckRequestSchema>): string | null => {
|
|
15
|
+
const tsconfig = ts.findConfigFile(dirname(entry), ts.sys.fileExists);
|
|
16
|
+
if (!tsconfig) {
|
|
17
|
+
return "Server entry requires a tsconfig.json.";
|
|
18
|
+
}
|
|
19
|
+
const read = ts.readConfigFile(tsconfig, ts.sys.readFile);
|
|
20
|
+
if (read.error) {
|
|
21
|
+
return ts.flattenDiagnosticMessageText(read.error.messageText, "\n");
|
|
22
|
+
}
|
|
23
|
+
const parsed = ts.parseJsonConfigFileContent(
|
|
24
|
+
read.config,
|
|
25
|
+
ts.sys,
|
|
26
|
+
dirname(tsconfig),
|
|
27
|
+
);
|
|
28
|
+
const program = ts.createProgram({
|
|
29
|
+
rootNames: [
|
|
30
|
+
entry,
|
|
31
|
+
...parsed.fileNames.filter((file) => /\.d\.[cm]?ts$/.test(file)),
|
|
32
|
+
],
|
|
33
|
+
options: { ...parsed.options, ...typeCheckOnly },
|
|
34
|
+
projectReferences: parsed.projectReferences,
|
|
35
|
+
});
|
|
36
|
+
const diagnostics = [...parsed.errors, ...ts.getPreEmitDiagnostics(program)];
|
|
37
|
+
if (!diagnostics.length) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return ts.formatDiagnosticsWithColorAndContext(diagnostics, {
|
|
41
|
+
getCanonicalFileName: (path) => path,
|
|
42
|
+
getCurrentDirectory: () => root,
|
|
43
|
+
getNewLine: () => "\n",
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// A worker thread runs this module, so the check of a server's thousands of files overlaps the PLC build.
|
|
48
|
+
declare const self: Worker;
|
|
49
|
+
self.onmessage = (event: MessageEvent) => {
|
|
50
|
+
const result: z.infer<typeof serverCheckResultSchema> = {
|
|
51
|
+
failure: serverFailure(serverCheckRequestSchema.parse(event.data)),
|
|
52
|
+
};
|
|
53
|
+
self.postMessage(result);
|
|
54
|
+
};
|
package/src/project/server.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import { mkdtemp,
|
|
3
|
-
import { dirname, resolve, join } from "node:path";
|
|
2
|
+
import { mkdir, mkdtemp, rename, rm } from "node:fs/promises";
|
|
4
3
|
import { createRequire } from "node:module";
|
|
5
|
-
import
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
6
|
import type { ResolvedTsplcConfig } from "@tsplc/config";
|
|
7
|
-
import {
|
|
7
|
+
import { z } from "zod";
|
|
8
8
|
|
|
9
9
|
const resolveServerModule = (root: string, name: string) =>
|
|
10
10
|
name.startsWith(".") ||
|
|
@@ -32,47 +32,66 @@ const serverOutput = (
|
|
|
32
32
|
`${kebabCase(config.name)}-services${extension}`,
|
|
33
33
|
);
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
const
|
|
35
|
+
/** What `checkServer` posts to its worker: the server entry and the project root diagnostics are relative to. */
|
|
36
|
+
export const serverCheckRequestSchema = z.strictObject({
|
|
37
|
+
entry: z.string(),
|
|
38
|
+
root: z.string(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/** The worker's answer: why the server entry fails its type check, or null when it passes. */
|
|
42
|
+
export const serverCheckResultSchema = z.strictObject({
|
|
43
|
+
failure: z.string().nullable(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/** The type-check script beside this module: its source, or the bundle a built package ships. */
|
|
47
|
+
const serverCheckScript = () => {
|
|
48
|
+
const script = ["./server-check.ts", "./server-check.js"]
|
|
49
|
+
.map((path) => fileURLToPath(new URL(path, import.meta.url)))
|
|
50
|
+
.find((path) => existsSync(path));
|
|
51
|
+
if (!script) {
|
|
52
|
+
throw new Error("The server type-check script is missing from this build.");
|
|
53
|
+
}
|
|
54
|
+
return script;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** A server entry that passed its type check, and the runtime it is built for. */
|
|
58
|
+
export interface CheckedServer {
|
|
59
|
+
entry: string;
|
|
60
|
+
runtime: NonNullable<NonNullable<ResolvedTsplcConfig["server"]>["runtime"]>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Type-checks the host entry as it will be built, on a worker thread: a caller that builds the
|
|
65
|
+
* PLC program meanwhile awaits the result after it. The check rejects with the diagnostics.
|
|
66
|
+
*/
|
|
67
|
+
export const checkServer = async (
|
|
68
|
+
config: ResolvedTsplcConfig,
|
|
69
|
+
root: string,
|
|
70
|
+
): Promise<CheckedServer> => {
|
|
37
71
|
const runtime = config.server?.runtime;
|
|
38
72
|
if (!runtime) {
|
|
39
73
|
throw new Error("Configure server.runtime to build the server.");
|
|
40
74
|
}
|
|
41
75
|
const entry = resolveServerModule(root, runtime.entry);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
...parsed.fileNames.filter((file) => /\.d\.[cm]?ts$/.test(file)),
|
|
61
|
-
],
|
|
62
|
-
options: { ...parsed.options, ...typeCheckOnly },
|
|
63
|
-
projectReferences: parsed.projectReferences,
|
|
64
|
-
});
|
|
65
|
-
const diagnostics = [...parsed.errors, ...ts.getPreEmitDiagnostics(program)];
|
|
66
|
-
if (diagnostics.length) {
|
|
67
|
-
throw new Error(
|
|
68
|
-
ts.formatDiagnosticsWithColorAndContext(diagnostics, {
|
|
69
|
-
getCanonicalFileName: (path) => path,
|
|
70
|
-
getCurrentDirectory: () => root,
|
|
71
|
-
getNewLine: () => "\n",
|
|
72
|
-
}),
|
|
73
|
-
);
|
|
76
|
+
const worker = new Worker(serverCheckScript());
|
|
77
|
+
try {
|
|
78
|
+
const answer = await new Promise<unknown>((resolve, reject) => {
|
|
79
|
+
worker.onmessage = (event: MessageEvent) => resolve(event.data);
|
|
80
|
+
worker.onerror = (event) => reject(new Error(event.message));
|
|
81
|
+
const request: z.infer<typeof serverCheckRequestSchema> = {
|
|
82
|
+
entry,
|
|
83
|
+
root,
|
|
84
|
+
};
|
|
85
|
+
worker.postMessage(request);
|
|
86
|
+
});
|
|
87
|
+
const { failure } = serverCheckResultSchema.parse(answer);
|
|
88
|
+
if (failure !== null) {
|
|
89
|
+
throw new Error(failure);
|
|
90
|
+
}
|
|
91
|
+
return { entry, runtime };
|
|
92
|
+
} finally {
|
|
93
|
+
worker.terminate();
|
|
74
94
|
}
|
|
75
|
-
return { entry, runtime };
|
|
76
95
|
};
|
|
77
96
|
|
|
78
97
|
/**
|
|
@@ -81,10 +100,10 @@ const checkedServerEntry = (config: ResolvedTsplcConfig, root: string) => {
|
|
|
81
100
|
* where an executable, which embeds Bun, is over 100, and deployments upload it.
|
|
82
101
|
*/
|
|
83
102
|
export const bundleServer = async (
|
|
103
|
+
{ entry }: CheckedServer,
|
|
84
104
|
config: ResolvedTsplcConfig,
|
|
85
105
|
root: string,
|
|
86
106
|
) => {
|
|
87
|
-
const { entry } = checkedServerEntry(config, root);
|
|
88
107
|
const outFile = serverOutput(config, root, ".js");
|
|
89
108
|
const result = await Bun.build({
|
|
90
109
|
entrypoints: [entry],
|
|
@@ -108,10 +127,10 @@ export const bundleServer = async (
|
|
|
108
127
|
|
|
109
128
|
/** Compiles the host entry, which starts its own listener, into `build/server/<name>-services`. */
|
|
110
129
|
export const buildServer = async (
|
|
130
|
+
{ entry, runtime }: CheckedServer,
|
|
111
131
|
config: ResolvedTsplcConfig,
|
|
112
132
|
root: string,
|
|
113
133
|
) => {
|
|
114
|
-
const { entry, runtime } = checkedServerEntry(config, root);
|
|
115
134
|
const windows = runtime.target
|
|
116
135
|
? runtime.target.includes("windows")
|
|
117
136
|
: process.platform === "win32";
|
package/src/project/terminal.ts
CHANGED
|
@@ -5,7 +5,9 @@ export const choose = async <T>(
|
|
|
5
5
|
items: readonly T[],
|
|
6
6
|
label: (item: T) => string,
|
|
7
7
|
) => {
|
|
8
|
-
items.forEach((item, index) =>
|
|
8
|
+
items.forEach((item, index) => {
|
|
9
|
+
console.log(` ${index + 1}. ${label(item)}`);
|
|
10
|
+
});
|
|
9
11
|
while (true) {
|
|
10
12
|
const item =
|
|
11
13
|
items[Number(await ask(`${question} [1-${items.length}]: `)) - 1];
|
package/stdlib/retain.ts
ADDED
package/types/globals.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import "./data-types";
|
|
|
4
4
|
// declaration identity rather than trusting a same-named user alias.
|
|
5
5
|
declare global {
|
|
6
6
|
interface VoidFunction {
|
|
7
|
+
// biome-ignore lint/style/useShorthandFunctionType: This declaration must merge with lib.dom's interface.
|
|
7
8
|
(): void;
|
|
8
9
|
}
|
|
9
10
|
type Input<T> = import("./index").Input<T>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps state through a warm restart: `retain(initializer)` returns its argument, and the PLC
|
|
3
|
+
* declares the storage that holds it `RETAIN`. A plain TypeScript program imports it from here,
|
|
4
|
+
* because its setup and unit tests run under Bun (docs/language/plain-typescript.md).
|
|
5
|
+
*/
|
|
6
|
+
export { retain } from "./index";
|
package/types/telemetry.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type TelemetryProperties = Readonly<Record<string, TelemetryValue>>;
|
|
|
19
19
|
* not every scan: each call fills a slot of a fixed ring the task sends to its server.
|
|
20
20
|
*/
|
|
21
21
|
export interface Telemetry {
|
|
22
|
-
/** An event, such as `"
|
|
22
|
+
/** An event, such as `"part detected"`. */
|
|
23
23
|
capture(event: string, properties?: TelemetryProperties): void;
|
|
24
24
|
info(message: string, properties?: TelemetryProperties): void;
|
|
25
25
|
warn(message: string, properties?: TelemetryProperties): void;
|
|
@@ -29,7 +29,7 @@ export interface Telemetry {
|
|
|
29
29
|
* Known job error codes are sent with their meaning.
|
|
30
30
|
*/
|
|
31
31
|
captureException(error: unknown, properties?: TelemetryProperties): void;
|
|
32
|
-
/** The first `length` bytes of `bytes`, up to the first 0, as text
|
|
32
|
+
/** The first `length` bytes of `bytes`, up to the first 0, as text, such as a serial number in its buffer. */
|
|
33
33
|
text(bytes: readonly BYTE[], length: number): TelemetryText;
|
|
34
34
|
}
|
|
35
35
|
export declare const telemetry: Telemetry;
|