@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.
Files changed (115) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +280 -223
  3. package/dist/cli.js.map +12 -12
  4. package/dist/codesys.js +452 -330
  5. package/dist/codesys.js.map +24 -24
  6. package/dist/elaborate-capture.js +112 -7
  7. package/dist/elaborate-capture.js.map +5 -4
  8. package/dist/index.js +5682 -5407
  9. package/dist/index.js.map +39 -37
  10. package/dist/ir.js +1154 -327
  11. package/dist/ir.js.map +23 -20
  12. package/dist/project.js +68 -29
  13. package/dist/project.js.map +4 -4
  14. package/dist/retain.js +8 -0
  15. package/dist/retain.js.map +10 -0
  16. package/dist/server-check.js +59 -0
  17. package/dist/server-check.js.map +11 -0
  18. package/dist/telemetry.js +19 -10
  19. package/dist/telemetry.js.map +3 -3
  20. package/package.json +33 -12
  21. package/src/codesys/config.ts +1 -1
  22. package/src/codesys/debug.ts +7 -21
  23. package/src/codesys/engineering.ts +8 -12
  24. package/src/codesys/global-lists.ts +19 -17
  25. package/src/codesys/global-names.ts +3 -3
  26. package/src/codesys/http.ts +37 -34
  27. package/src/codesys/index.ts +5 -22
  28. package/src/codesys/instrumentation.ts +3 -1
  29. package/src/codesys/io-paths.ts +2 -1
  30. package/src/codesys/manifest.ts +35 -18
  31. package/src/codesys/numeric.ts +2 -4
  32. package/src/codesys/plan.ts +94 -26
  33. package/src/codesys/publication.ts +4 -3
  34. package/src/codesys/routines.ts +2 -2
  35. package/src/codesys/sources.ts +1 -0
  36. package/src/codesys/st-files.ts +86 -50
  37. package/src/codesys/storage.ts +44 -9
  38. package/src/codesys/task-access.ts +32 -10
  39. package/src/codesys/telemetry.ts +93 -46
  40. package/src/codesys/types.ts +81 -3
  41. package/src/codesys/vendor.ts +1 -1
  42. package/src/frontend/analyzer.ts +15 -14
  43. package/src/frontend/async.ts +23 -21
  44. package/src/frontend/blocks.ts +7 -6
  45. package/src/frontend/configuration.ts +8 -6
  46. package/src/frontend/const-functions.ts +5 -5
  47. package/src/frontend/cooperative.ts +2 -1
  48. package/src/frontend/coroutines.ts +24 -21
  49. package/src/frontend/elaborate/calls.ts +12 -7
  50. package/src/frontend/elaborate/capture-protocol.ts +103 -0
  51. package/src/frontend/elaborate/capture.ts +48 -19
  52. package/src/frontend/elaborate/dialect.ts +2 -2
  53. package/src/frontend/elaborate/expressions.ts +9 -6
  54. package/src/frontend/elaborate/frame.ts +1 -1
  55. package/src/frontend/elaborate/graph.ts +27 -43
  56. package/src/frontend/elaborate/index.ts +52 -17
  57. package/src/frontend/elaborate/initializers.ts +3 -2
  58. package/src/frontend/elaborate/layouts.ts +2 -2
  59. package/src/frontend/elaborate/model.ts +34 -21
  60. package/src/frontend/elaborate/retention.ts +206 -0
  61. package/src/frontend/elaborate/specialize.ts +7 -6
  62. package/src/frontend/elaborate/statements.ts +47 -38
  63. package/src/frontend/elaborate/storage.ts +26 -6
  64. package/src/frontend/exposure.ts +6 -6
  65. package/src/frontend/expressions.ts +26 -25
  66. package/src/frontend/intrinsics.ts +3 -3
  67. package/src/frontend/module-graph.ts +1 -1
  68. package/src/frontend/positions.ts +2 -1
  69. package/src/frontend/promise-chains.ts +1 -0
  70. package/src/frontend/promises.ts +8 -7
  71. package/src/frontend/routines.ts +3 -2
  72. package/src/frontend/sdk.ts +2 -2
  73. package/src/frontend/services.ts +23 -20
  74. package/src/frontend/statements.ts +8 -6
  75. package/src/frontend/tasks.ts +11 -6
  76. package/src/frontend/telemetry.ts +1 -1
  77. package/src/frontend/types.ts +11 -9
  78. package/src/frontend/typescript.ts +92 -42
  79. package/src/index.ts +2 -1
  80. package/src/ir/aggregates.ts +4 -3
  81. package/src/ir/allocation.ts +2 -1
  82. package/src/ir/core-model.ts +38 -8
  83. package/src/ir/declarations.ts +12 -12
  84. package/src/ir/domains.ts +8 -8
  85. package/src/ir/fold.ts +2 -2
  86. package/src/ir/index.ts +53 -40
  87. package/src/ir/job-errors.ts +22 -11
  88. package/src/ir/layouts.ts +3 -2
  89. package/src/ir/link.ts +6 -24
  90. package/src/ir/model.ts +3 -2
  91. package/src/ir/normalization-error.ts +1 -1
  92. package/src/ir/normalize.ts +19 -12
  93. package/src/ir/numeric.ts +1 -0
  94. package/src/{codesys → ir}/operands.ts +2 -6
  95. package/src/ir/ranges.ts +2 -2
  96. package/src/ir/routine.ts +35 -20
  97. package/src/ir/scalars.ts +3 -3
  98. package/src/ir/share.ts +862 -0
  99. package/src/ir/temporaries.ts +236 -0
  100. package/src/ir/types.ts +1 -1
  101. package/src/project/artifacts.ts +12 -2
  102. package/src/project/cli.ts +42 -44
  103. package/src/project/debugger.ts +15 -9
  104. package/src/project/index.ts +1 -1
  105. package/src/project/plant.ts +34 -23
  106. package/src/project/project-commands.ts +92 -73
  107. package/src/project/project.ts +91 -42
  108. package/src/project/release.ts +50 -57
  109. package/src/project/server-check.ts +54 -0
  110. package/src/project/server.ts +60 -41
  111. package/src/project/terminal.ts +3 -1
  112. package/stdlib/retain.ts +2 -0
  113. package/types/globals.d.ts +1 -0
  114. package/types/retain.d.ts +6 -0
  115. package/types/telemetry.d.ts +2 -2
package/dist/project.js CHANGED
@@ -7,32 +7,37 @@ import {
7
7
  rm as rm2,
8
8
  writeFile as writeFile2
9
9
  } from "node:fs/promises";
10
- import { dirname as dirname2, join as join2, resolve } from "node:path";
10
+ import { basename, dirname as dirname2, join as join2, resolve } from "node:path";
11
+ import { installLibraries } from "@tsplc/build";
12
+ import {
13
+ analyze,
14
+ checkHostConfig
15
+ } from "@tsplc/compiler";
11
16
  import {
12
17
  buildCodesys,
13
18
  codesysBuildConfig,
14
19
  diagnoseCodesys,
15
20
  emitCodesys,
16
21
  ioTargets,
17
- publicationSelectors,
18
- planCodesys
22
+ planCodesys,
23
+ publicationSelectors
19
24
  } from "@tsplc/compiler/codesys";
20
- import { analyze, checkHostConfig } from "@tsplc/compiler";
25
+ import {
26
+ hasErrors,
27
+ normalizeModule
28
+ } from "@tsplc/compiler/ir";
21
29
  import {
22
30
  compilerConfig,
23
31
  loadTsplcConfig,
24
32
  simulationConfig
25
33
  } from "@tsplc/config";
34
+ import { emittedFiles, emittedStDirectory as emittedStDirectory2 } from "@tsplc/config/project-files";
35
+ import { debugManifestFile } from "@tsplc/debug/manifest";
26
36
  import {
27
37
  deviceTree,
28
38
  loadHardware,
29
39
  resolveIo
30
40
  } from "@tsplc/typegen";
31
- import { installLibraries } from "@tsplc/build";
32
- import {
33
- hasErrors,
34
- normalizeModule
35
- } from "@tsplc/compiler/ir";
36
41
 
37
42
  // packages/compiler/src/project/artifacts.ts
38
43
  import { createHash } from "node:crypto";
@@ -47,6 +52,10 @@ import {
47
52
  } from "node:fs/promises";
48
53
  import { dirname, join } from "node:path";
49
54
  import { sha256Digest } from "@tsplc/config/build";
55
+ import {
56
+ emittedStDirectory,
57
+ generatedDirectory
58
+ } from "@tsplc/config/project-files";
50
59
  import { z } from "zod";
51
60
  var missing = (cause) => cause instanceof Error && ("code" in cause) && cause.code === "ENOENT";
52
61
  var digest = (value) => createHash("sha256").update(value).digest("hex");
@@ -151,8 +160,8 @@ async function engineeringDirectory(path, configFile) {
151
160
  await inspect(path);
152
161
  }
153
162
  async function owned(configFile, withdrawReceipt = false) {
154
- const root = join(dirname(configFile), ".tsplc");
155
- const output = join(root, "artifacts");
163
+ const root = join(dirname(configFile), generatedDirectory);
164
+ const output = join(dirname(configFile), dirname(emittedStDirectory));
156
165
  if (!await directory(root) || !await directory(output)) {
157
166
  return { root, output, unknown: [] };
158
167
  }
@@ -185,13 +194,18 @@ async function owned(configFile, withdrawReceipt = false) {
185
194
  "manifest.json",
186
195
  "receipt.json"
187
196
  ]);
197
+ const checked = new Set;
188
198
  for (const file of ownership.files) {
189
199
  let parent = output;
190
200
  for (const part of file.path.split("/").slice(0, -1)) {
191
201
  parent = join(parent, part);
202
+ if (checked.has(parent)) {
203
+ continue;
204
+ }
192
205
  if (!await directory(parent)) {
193
206
  throw new Error(`Missing generated directory: ${parent}`);
194
207
  }
208
+ checked.add(parent);
195
209
  }
196
210
  const path = join(output, file.path);
197
211
  const entry = await lstat(path);
@@ -277,13 +291,25 @@ async function cleanArtifacts(configFile) {
277
291
  }
278
292
 
279
293
  // packages/compiler/src/project/project.ts
294
+ var emittedSt = basename(emittedStDirectory2);
280
295
  var failure = (origin, code, cause) => ({
281
296
  origin,
282
297
  code,
283
298
  severity: "error",
284
299
  message: cause instanceof Error ? cause.message : String(cause)
285
300
  });
286
- async function loadProject(file, { loaded, buildTarget, configured, hostConfigDiagnostics }) {
301
+ var loadEnvironment = (environment) => ({
302
+ env: environment ?? process.env,
303
+ target: undefined,
304
+ forAgent: false
305
+ });
306
+ async function loadProject(file, {
307
+ loaded,
308
+ buildTarget,
309
+ configured,
310
+ hostConfigDiagnostics,
311
+ environment
312
+ }) {
287
313
  let configFile = resolve(file);
288
314
  try {
289
315
  configFile = await realpath(configFile);
@@ -291,7 +317,7 @@ async function loadProject(file, { loaded, buildTarget, configured, hostConfigDi
291
317
  if (hasErrors(diagnostics)) {
292
318
  return { configFile, diagnostics };
293
319
  }
294
- const { config: shared, env } = loaded ?? await loadTsplcConfig(configFile);
320
+ const { config: shared, env } = loaded ?? await loadTsplcConfig(configFile, loadEnvironment(environment));
295
321
  const root = dirname2(configFile);
296
322
  const catalog = await loadHardware(shared, root);
297
323
  const config = compilerConfig(shared, resolveIo(shared, catalog), buildTarget);
@@ -301,7 +327,7 @@ async function loadProject(file, { loaded, buildTarget, configured, hostConfigDi
301
327
  config: { ...config, ...sourceInput(config, root) },
302
328
  project: {
303
329
  root,
304
- env,
330
+ environment: env,
305
331
  ...shared.debug && { debug: shared.debug },
306
332
  ...shared.telemetry && { telemetry: shared.telemetry },
307
333
  ...shared.server && { server: shared.server },
@@ -328,18 +354,22 @@ function sourceInput(compiler, root) {
328
354
  }
329
355
  async function projectTargets(file = "tsplc.config.ts", options = {}) {
330
356
  const configFile = await realpath(resolve(file));
331
- const { config, env } = options.loaded ?? await loadTsplcConfig(configFile);
357
+ const { config, env } = options.loaded ?? await loadTsplcConfig(configFile, loadEnvironment(options.environment));
332
358
  if (!config.compiler) {
333
359
  return;
334
360
  }
335
361
  const source = analyze({
336
362
  ...sourceInput(config.compiler, dirname2(configFile)),
337
363
  services: config.server,
338
- env
364
+ environment: env
339
365
  });
340
366
  const core = source.module && normalizeModule(source.module).core;
341
- return core ? { io: ioTargets(core), publication: publicationSelectors(core) } : undefined;
367
+ return core ? coreTargets(core) : undefined;
342
368
  }
369
+ var coreTargets = (core) => ({
370
+ io: ioTargets(core),
371
+ publication: publicationSelectors(core)
372
+ });
343
373
  async function checkProject(file = "tsplc.config.ts", options = {}) {
344
374
  const loaded = await loadProject(file, options);
345
375
  if (!loaded.config || !loaded.project) {
@@ -358,7 +388,7 @@ async function checkProject(file = "tsplc.config.ts", options = {}) {
358
388
  tsconfig: config.tsconfig,
359
389
  programs: config.programs,
360
390
  services: loaded.shared?.server,
361
- env: loaded.project.env
391
+ environment: loaded.project.environment
362
392
  });
363
393
  if (!source.module) {
364
394
  return { ...loaded, diagnostics: source.diagnostics };
@@ -422,7 +452,7 @@ async function buildProject(file = "tsplc.config.ts", options = {}) {
422
452
  const outDir = shared?.build && resolve(dirname2(configFile), shared.build.outDir);
423
453
  const controllerConfig = outDir ? codesysBuildConfig(checked.plan, bundle, {
424
454
  configFile,
425
- sourceDir: join2(previous.output, "st"),
455
+ sourceDir: join2(previous.output, emittedSt),
426
456
  outDir,
427
457
  controller: options.controller,
428
458
  ...engineering
@@ -437,12 +467,12 @@ async function buildProject(file = "tsplc.config.ts", options = {}) {
437
467
  `
438
468
  },
439
469
  {
440
- path: "io-symbols.json",
470
+ path: emittedFiles.ioSymbols,
441
471
  content: `${JSON.stringify(bundle.ioSymbols, null, 2)}
442
472
  `
443
473
  },
444
474
  {
445
- path: "publication.json",
475
+ path: emittedFiles.publication,
446
476
  content: `${JSON.stringify(bundle.publication, null, 2)}
447
477
  `
448
478
  },
@@ -451,13 +481,21 @@ async function buildProject(file = "tsplc.config.ts", options = {}) {
451
481
  content: `${JSON.stringify(checked.config, null, 2)}
452
482
  `
453
483
  },
454
- ...bundle.debug ? [{ path: "debug.json", content: `${JSON.stringify(bundle.debug)}
455
- ` }] : []
484
+ ...bundle.debug ? [
485
+ {
486
+ path: debugManifestFile,
487
+ content: `${JSON.stringify(bundle.debug)}
488
+ `
489
+ }
490
+ ] : []
456
491
  ];
492
+ const stagedSt = join2(staging, emittedSt);
493
+ const directories = new Set(artifacts.map((artifact) => dirname2(join2(stagedSt, artifact.path))));
494
+ for (const directory of directories) {
495
+ await mkdir2(directory, { recursive: true });
496
+ }
457
497
  for (const artifact of artifacts) {
458
- const path = join2(staging, "st", artifact.path);
459
- await mkdir2(dirname2(path), { recursive: true });
460
- await writeFile2(path, artifact.content);
498
+ await writeFile2(join2(stagedSt, artifact.path), artifact.content);
461
499
  }
462
500
  let vendor;
463
501
  if (!options.emitOnly) {
@@ -466,11 +504,11 @@ async function buildProject(file = "tsplc.config.ts", options = {}) {
466
504
  try {
467
505
  vendor = await buildCodesys(checked.plan, bundle, {
468
506
  configFile,
469
- sourceDir: join2(staging, "st"),
507
+ sourceDir: join2(staging, emittedSt),
470
508
  outDir: engineeringDir,
471
509
  controller: options.controller,
472
510
  ...engineering
473
- });
511
+ }, { progress: options.progress });
474
512
  } catch (cause) {
475
513
  return { diagnostics: diagnoseCodesys(cause, bundle) };
476
514
  }
@@ -501,6 +539,7 @@ async function buildProject(file = "tsplc.config.ts", options = {}) {
501
539
  directory: previous.output,
502
540
  status,
503
541
  ...controllerConfig && { controllerConfig },
542
+ targets: coreTargets(checked.plan.core),
504
543
  diagnostics: [...checked.diagnostics, ...bundle.diagnostics]
505
544
  };
506
545
  } catch (cause) {
@@ -552,5 +591,5 @@ export {
552
591
  projectTargets
553
592
  };
554
593
 
555
- //# debugId=904B812690CB29FE64756E2164756E21
594
+ //# debugId=547FFDAEB3537A5B64756E2164756E21
556
595
  //# sourceMappingURL=project.js.map
@@ -2,10 +2,10 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/project/project.ts", "../src/project/artifacts.ts"],
4
4
  "sourcesContent": [
5
- "import {\n\tcopyFile,\n\tmkdir,\n\tmkdtemp,\n\trealpath,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport {\n\tbuildCodesys,\n\tcodesysBuildConfig,\n\ttype CodesysPlan,\n\ttype CodesysProject,\n\ttype SourceMapping,\n\tdiagnoseCodesys,\n\temitCodesys,\n\tioTargets,\n\tpublicationSelectors,\n\tplanCodesys,\n} from \"@tsplc/compiler/codesys\";\nimport { analyze, checkHostConfig } from \"@tsplc/compiler\";\nimport {\n\ttype Controller,\n\ttype BuildTarget,\n\ttype NormalizedConfig,\n\ttype ResolvedTsplcConfig,\n\tcompilerConfig,\n\tloadTsplcConfig,\n\tsimulationConfig,\n} from \"@tsplc/config\";\nimport {\n\tdeviceTree,\n\ttype ProjectTargets,\n\tloadHardware,\n\tresolveIo,\n} from \"@tsplc/typegen\";\nimport { installLibraries } from \"@tsplc/build\";\nimport {\n\ttype Diagnostic,\n\thasErrors,\n\tnormalizeModule,\n} from \"@tsplc/compiler/ir\";\nimport {\n\tcleanArtifacts,\n\tengineeringDirectory,\n\towned,\n\tpublishArtifacts,\n} from \"./artifacts.ts\";\n\nconst failure = (\n\torigin: Diagnostic[\"origin\"],\n\tcode: string,\n\tcause: unknown,\n): Diagnostic => ({\n\torigin,\n\tcode,\n\tseverity: \"error\",\n\tmessage: cause instanceof Error ? cause.message : String(cause),\n});\n\ntype LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;\n\n/**\n * `buildProject`'s `loaded` and `configured` options. With `simulate` the build omits fieldbus\n * I/O so a plant simulator can write the inputs; generated types and the debug manifest keep\n * describing the hardware project.\n */\nexport const buildConfigs = (\n\tloaded: LoadedConfig,\n\toptions: { simulate?: boolean },\n) =>\n\toptions.simulate\n\t\t? {\n\t\t\t\tloaded: { ...loaded, config: simulationConfig(loaded.config) },\n\t\t\t\tconfigured: loaded.config,\n\t\t\t}\n\t\t: { loaded };\n\ninterface ProjectOptions {\n\tloaded?: LoadedConfig;\n\tbuildTarget?: BuildTarget;\n\t/** The configuration `loaded` simulates, whose hardware the debug manifest describes. */\n\tconfigured?: ResolvedTsplcConfig;\n\t/**\n\t * The host config check's diagnostics, when the caller ran it before loading the config. The\n\t * check type-checks the config and takes seconds.\n\t */\n\thostConfigDiagnostics?: readonly Diagnostic[];\n}\n\nasync function loadProject(\n\tfile: string,\n\t{ loaded, buildTarget, configured, hostConfigDiagnostics }: ProjectOptions,\n): Promise<{\n\tconfig?: NormalizedConfig;\n\tconfigFile: string;\n\tshared?: ResolvedTsplcConfig;\n\tproject?: CodesysProject;\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\tlet configFile = resolve(file);\n\ttry {\n\t\tconfigFile = await realpath(configFile);\n\t\tconst diagnostics = hostConfigDiagnostics ?? checkHostConfig(configFile);\n\t\tif (hasErrors(diagnostics)) {\n\t\t\treturn { configFile, diagnostics };\n\t\t}\n\t\tconst { config: shared, env } =\n\t\t\tloaded ?? (await loadTsplcConfig(configFile));\n\t\tconst root = dirname(configFile);\n\t\tconst catalog = await loadHardware(shared, root);\n\n\t\tconst config = compilerConfig(\n\t\t\tshared,\n\t\t\tresolveIo(shared, catalog),\n\t\t\tbuildTarget,\n\t\t);\n\t\treturn {\n\t\t\tconfigFile,\n\t\t\tshared,\n\t\t\tconfig: { ...config, ...sourceInput(config, root) },\n\t\t\tproject: {\n\t\t\t\troot,\n\t\t\t\tenv,\n\t\t\t\t...(shared.debug && { debug: shared.debug }),\n\t\t\t\t...(shared.telemetry && { telemetry: shared.telemetry }),\n\t\t\t\t...(shared.server && { server: shared.server }),\n\t\t\t\t// A simulation build drops fieldbus IO, but the debugger still shows the hardware it stands in for.\n\t\t\t\thardware: {\n\t\t\t\t\tcatalog: configured ? await loadHardware(configured, root) : catalog,\n\t\t\t\t\tconfig: configured ?? shared,\n\t\t\t\t\ttree: shared.codesys?.deviceTree !== undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdiagnostics,\n\t\t};\n\t} catch (cause) {\n\t\treturn { configFile, diagnostics: [failure(\"config\", \"PLC5003\", cause)] };\n\t}\n}\n\n/** The analyzer's entry points, resolved against the config file's directory. */\nfunction sourceInput(\n\tcompiler: {\n\t\ttsconfig: string;\n\t\tprograms: Record<string, { module: string; export: string }>;\n\t},\n\troot: string,\n) {\n\treturn {\n\t\ttsconfig: resolve(root, compiler.tsconfig),\n\t\tprograms: Object.fromEntries(\n\t\t\tObject.entries(compiler.programs).map(([name, entry]) => [\n\t\t\t\tname,\n\t\t\t\t{ ...entry, module: resolve(root, entry.module) },\n\t\t\t]),\n\t\t),\n\t};\n}\n\n/**\n * I/O keys and publication selectors from analyzed PLC source. It ignores the\n * config's own type errors, so a typo cannot switch off the types that flag it;\n * it is undefined only while the source itself fails analysis.\n */\nexport async function projectTargets(\n\tfile = \"tsplc.config.ts\",\n\toptions: { loaded?: LoadedConfig } = {},\n): Promise<ProjectTargets | undefined> {\n\tconst configFile = await realpath(resolve(file));\n\tconst { config, env } = options.loaded ?? (await loadTsplcConfig(configFile));\n\tif (!config.compiler) {\n\t\treturn undefined;\n\t}\n\tconst source = analyze({\n\t\t...sourceInput(config.compiler, dirname(configFile)),\n\t\tservices: config.server,\n\t\tenv,\n\t});\n\tconst core = source.module && normalizeModule(source.module).core;\n\treturn core\n\t\t? { io: ioTargets(core), publication: publicationSelectors(core) }\n\t\t: undefined;\n}\n\nexport async function checkProject(\n\tfile = \"tsplc.config.ts\",\n\toptions: ProjectOptions = {},\n): Promise<{\n\tconfigFile: string;\n\tconfig?: NormalizedConfig;\n\tshared?: ResolvedTsplcConfig;\n\tplan?: CodesysPlan;\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\tconst loaded = await loadProject(file, options);\n\tif (!loaded.config || !loaded.project) {\n\t\treturn loaded;\n\t}\n\n\tconst config = loaded.config;\n\tif (config.target.kind !== \"codesys\") {\n\t\treturn {\n\t\t\t...loaded,\n\t\t\tdiagnostics: [\n\t\t\t\tfailure(\n\t\t\t\t\t\"backend\",\n\t\t\t\t\t\"PLC7001\",\n\t\t\t\t\t`Unsupported target: ${config.target.kind}`,\n\t\t\t\t),\n\t\t\t],\n\t\t};\n\t}\n\n\tconst source = analyze({\n\t\ttsconfig: config.tsconfig,\n\t\tprograms: config.programs,\n\t\tservices: loaded.shared?.server,\n\t\tenv: loaded.project.env,\n\t});\n\tif (!source.module) {\n\t\treturn { ...loaded, diagnostics: source.diagnostics };\n\t}\n\tconst normalized = normalizeModule(source.module);\n\tif (!normalized.core) {\n\t\treturn { ...loaded, diagnostics: normalized.diagnostics };\n\t}\n\n\tconst tasks = config.tasks.map((task) => ({\n\t\tname: task.name,\n\t\tintervalNanoseconds: task.schedule.interval.nanoseconds,\n\t\tpriority: task.priority,\n\t\tprograms: task.programs,\n\t}));\n\tconst planned = planCodesys(\n\t\tnormalized.core,\n\t\t{ tasks },\n\t\tconfig.target.options,\n\t\tloaded.project,\n\t);\n\treturn {\n\t\t...loaded,\n\t\t...planned,\n\t\tdiagnostics: [\n\t\t\t...loaded.diagnostics,\n\t\t\t...source.diagnostics,\n\t\t\t...normalized.diagnostics,\n\t\t\t...planned.diagnostics,\n\t\t],\n\t};\n}\n\n/** The installed libraries and fieldbus device tree a CODESYS project of this program needs. */\nasync function engineeringInputs(\n\tshared: ResolvedTsplcConfig,\n\tconfigFile: string,\n\tbundle: Pick<ReturnType<typeof emitCodesys>, \"ioMappings\">,\n\toptions: { frozen?: boolean },\n) {\n\tconst root = dirname(configFile);\n\tconst tree = await deviceTree(shared, await loadHardware(shared, root));\n\treturn {\n\t\tlibraries: await installLibraries(shared.dependencies, root, options),\n\t\t// The emitted names locate mapped IO; the tree maps their channels.\n\t\tdeviceTree: tree && {\n\t\t\t...tree,\n\t\t\tmappings: bundle.ioMappings.map(({ address, variable }) => ({\n\t\t\t\taddress,\n\t\t\t\tvariable,\n\t\t\t})),\n\t\t},\n\t};\n}\n\nexport async function buildProject(\n\tfile = \"tsplc.config.ts\",\n\toptions: ProjectOptions & {\n\t\temitOnly?: boolean;\n\t\tfrozenLockfile?: boolean;\n\t\tcontroller?: Controller;\n\t\t/** Resolve libraries and the device tree into `controllerConfig` even when only emitting. */\n\t\tforController?: boolean;\n\t} = {},\n): Promise<{\n\tdirectory?: string;\n\tstatus?: \"emitted\" | \"vendor-compiled\";\n\tcontrollerConfig?: ReturnType<typeof codesysBuildConfig>;\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\tlet staging: string | undefined;\n\ttry {\n\t\tconst configFile = await realpath(resolve(file));\n\t\t// Withdraw the previous success receipt before checking the new source.\n\t\t// Old artifacts remain owned and intact until publication succeeds.\n\t\tconst previous = await owned(configFile, true);\n\t\tif (previous.unknown.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Output contains unrelated files: ${previous.unknown.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tconst checked = await checkProject(configFile, options);\n\t\tif (!checked.plan || !checked.config) {\n\t\t\treturn { diagnostics: checked.diagnostics };\n\t\t}\n\t\tconst bundle = emitCodesys(checked.plan);\n\t\tif (hasErrors(bundle.diagnostics)) {\n\t\t\treturn { diagnostics: bundle.diagnostics };\n\t\t}\n\t\tconst shared = checked.shared;\n\t\tconst engineering =\n\t\t\tshared && (!options.emitOnly || options.forController)\n\t\t\t\t? await engineeringInputs(shared, configFile, bundle, {\n\t\t\t\t\t\tfrozen: options.frozenLockfile,\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t\tconst outDir =\n\t\t\tshared?.build && resolve(dirname(configFile), shared.build.outDir);\n\t\tconst controllerConfig = outDir\n\t\t\t? codesysBuildConfig(checked.plan, bundle, {\n\t\t\t\t\tconfigFile,\n\t\t\t\t\tsourceDir: join(previous.output, \"st\"),\n\t\t\t\t\toutDir,\n\t\t\t\t\tcontroller: options.controller,\n\t\t\t\t\t...engineering,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\tawait mkdir(previous.root, { recursive: true });\n\t\tstaging = await mkdtemp(join(previous.root, \"stage-\"));\n\t\tconst artifacts = [\n\t\t\t...bundle.artifacts,\n\t\t\t{\n\t\t\t\tpath: \"mappings.json\",\n\t\t\t\tcontent: `${JSON.stringify(compactMappings(bundle.mappings))}\\n`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"io-symbols.json\",\n\t\t\t\tcontent: `${JSON.stringify(bundle.ioSymbols, null, 2)}\\n`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"publication.json\",\n\t\t\t\tcontent: `${JSON.stringify(bundle.publication, null, 2)}\\n`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"config.json\",\n\t\t\t\tcontent: `${JSON.stringify(checked.config, null, 2)}\\n`,\n\t\t\t},\n\t\t\t...(bundle.debug\n\t\t\t\t? [{ path: \"debug.json\", content: `${JSON.stringify(bundle.debug)}\\n` }]\n\t\t\t\t: []),\n\t\t];\n\t\tfor (const artifact of artifacts) {\n\t\t\tconst path = join(staging, \"st\", artifact.path);\n\t\t\tawait mkdir(dirname(path), { recursive: true });\n\t\t\tawait writeFile(path, artifact.content);\n\t\t}\n\n\t\tlet vendor: Awaited<ReturnType<typeof buildCodesys>> | undefined;\n\t\tif (!options.emitOnly) {\n\t\t\t// The engineering cache has its own ownership marker and survives clean.\n\t\t\tconst engineeringDir = outDir ?? join(previous.root, \"engineering\");\n\t\t\tawait engineeringDirectory(engineeringDir, configFile);\n\t\t\ttry {\n\t\t\t\tvendor = await buildCodesys(checked.plan, bundle, {\n\t\t\t\t\tconfigFile,\n\t\t\t\t\tsourceDir: join(staging, \"st\"),\n\t\t\t\t\toutDir: engineeringDir,\n\t\t\t\t\tcontroller: options.controller,\n\t\t\t\t\t...engineering,\n\t\t\t\t});\n\t\t\t} catch (cause) {\n\t\t\t\treturn { diagnostics: diagnoseCodesys(cause, bundle) };\n\t\t\t}\n\n\t\t\tconst vendorArtifacts = [\n\t\t\t\t[\"Application.project\", vendor.project],\n\t\t\t\t[\"Application.app\", vendor.output],\n\t\t\t\t[\"Application.crc\", vendor.checksum],\n\t\t\t] as const;\n\t\t\tfor (const [name, path] of vendorArtifacts) {\n\t\t\t\tif (!path) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst destination = join(staging, \"vendor\", name);\n\t\t\t\tawait mkdir(dirname(destination), { recursive: true });\n\t\t\t\tawait copyFile(path, destination);\n\t\t\t}\n\t\t}\n\n\t\tconst status = vendor ? \"vendor-compiled\" : \"emitted\";\n\t\tawait publishArtifacts(staging, previous, {\n\t\t\tconfigFile,\n\t\t\tstatus,\n\t\t\t...(vendor && {\n\t\t\t\tvendor: { application: vendor.application, tasks: vendor.tasks },\n\t\t\t}),\n\t\t});\n\t\t// Publication moved this directory into place; it is no longer staging.\n\t\tstaging = undefined;\n\t\treturn {\n\t\t\tdirectory: previous.output,\n\t\t\tstatus,\n\t\t\t...(controllerConfig && { controllerConfig }),\n\t\t\tdiagnostics: [...checked.diagnostics, ...bundle.diagnostics],\n\t\t};\n\t} catch (cause) {\n\t\treturn { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n\t} finally {\n\t\tif (staging) {\n\t\t\tawait rm(staging, { recursive: true, force: true });\n\t\t}\n\t}\n}\n\n/**\n * Source mappings with each ST path and source file written once: `mappings` rows are\n * `[object, line, file, start, end, sourceLine, sourceColumn]`, indexing `objects` and `files`.\n */\nfunction compactMappings(mappings: readonly SourceMapping[]) {\n\tconst objects = new Map<string, number>();\n\tconst files = new Map<string, number>();\n\tconst index = (table: Map<string, number>, value: string) => {\n\t\tconst known = table.get(value);\n\t\tif (known !== undefined) {\n\t\t\treturn known;\n\t\t}\n\t\ttable.set(value, table.size);\n\t\treturn table.size - 1;\n\t};\n\tconst rows = mappings.map(({ path, line, span }) => [\n\t\tindex(objects, path),\n\t\tline,\n\t\tindex(files, span.file),\n\t\tspan.start,\n\t\tspan.end,\n\t\tspan.line,\n\t\tspan.column,\n\t]);\n\treturn {\n\t\tobjects: [...objects.keys()],\n\t\tfiles: [...files.keys()],\n\t\tmappings: rows,\n\t};\n}\n\nexport async function cleanProject(file = \"tsplc.config.ts\"): Promise<{\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\ttry {\n\t\tawait cleanArtifacts(await realpath(resolve(file)));\n\t\treturn { diagnostics: [] };\n\t} catch (cause) {\n\t\treturn { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n\t}\n}\n",
6
- "import { createHash } from \"node:crypto\";\nimport {\n\tlstat,\n\tmkdir,\n\treaddir,\n\treadFile,\n\trename,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport type { buildCodesys } from \"@tsplc/compiler/codesys\";\nimport { sha256Digest } from \"@tsplc/config/build\";\nimport { z } from \"zod\";\n\nconst missing = (cause: unknown): boolean =>\n\tcause instanceof Error && \"code\" in cause && cause.code === \"ENOENT\";\nconst digest = (value: string | Uint8Array): string =>\n\tcreateHash(\"sha256\").update(value).digest(\"hex\");\n\n// Ownership is an explicit boundary: generated files must match their manifest,\n// and engineering trees must belong to this configuration before vendor writes.\nconst generatedFileSchema = z.object({\n\tpath: z\n\t\t.string()\n\t\t.regex(/^[A-Za-z0-9_ .-]+(?:\\/[A-Za-z0-9_ .-]+)*$/)\n\t\t.refine(\n\t\t\t(path) =>\n\t\t\t\t!path.split(\"/\").some((part) => part === \".\" || part === \"..\") &&\n\t\t\t\t![\"manifest.json\", \"receipt.json\"].includes(path),\n\t\t),\n\tsha256: sha256Digest,\n});\n\n/** The manifest's envelope; its entries are checked one by one to name the failure. */\nconst manifestSchema = z.object({\n\tkind: z.literal(\"tsplc-artifacts\"),\n\tversion: z.literal(1),\n\tconfigFile: z.string(),\n\tfiles: z.array(z.unknown()),\n});\n\ntype Manifest = Omit<z.infer<typeof manifestSchema>, \"files\"> & {\n\tfiles: z.infer<typeof generatedFileSchema>[];\n};\n\nconst buildStatusSchema = z.enum([\"emitted\", \"vendor-compiled\"]);\n\nconst receiptSchema = z.object({\n\tkind: z.literal(\"tsplc-build\"),\n\tversion: z.literal(1),\n\tconfigFile: z.string(),\n\tstatus: buildStatusSchema,\n});\n\nconst engineeringMarkerSchema = z.object({\n\tkind: z.literal(\"tsplc-engineering\"),\n\tversion: z.literal(1),\n\tconfigFile: z.string(),\n});\n\nfunction manifest(value: unknown, configFile: string): Manifest {\n\tconst parsed = manifestSchema.safeParse(value);\n\tif (!parsed.success || parsed.data.configFile !== configFile) {\n\t\tthrow new Error(\n\t\t\t\"Output directory has no matching tsPLC ownership manifest.\",\n\t\t);\n\t}\n\n\tconst files = parsed.data.files.map((item) => {\n\t\tconst file = generatedFileSchema.safeParse(item);\n\t\tif (!file.success) {\n\t\t\tthrow new Error(\"Invalid generated file ownership entry.\");\n\t\t}\n\t\treturn file.data;\n\t});\n\tif (new Set(files.map((item) => item.path)).size !== files.length) {\n\t\tthrow new Error(\"Duplicate generated file ownership entry.\");\n\t}\n\treturn { ...parsed.data, files };\n}\n\nasync function directory(path: string): Promise<boolean> {\n\ttry {\n\t\tconst entry = await lstat(path);\n\t\tif (!entry.isDirectory() || entry.isSymbolicLink()) {\n\t\t\tthrow new Error(`Generated directory must be a real directory: ${path}`);\n\t\t}\n\t\treturn true;\n\t} catch (cause) {\n\t\tif (missing(cause)) {\n\t\t\treturn false;\n\t\t}\n\t\tthrow cause;\n\t}\n}\n\nasync function filesIn(path: string, prefix = \"\"): Promise<string[]> {\n\tconst result: string[] = [];\n\tfor (const entry of await readdir(path, { withFileTypes: true })) {\n\t\tconst name = prefix + entry.name;\n\t\tif (entry.isDirectory() && !entry.isSymbolicLink()) {\n\t\t\tresult.push(...(await filesIn(join(path, entry.name), `${name}/`)));\n\t\t} else {\n\t\t\tresult.push(name);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport async function engineeringDirectory(\n\tpath: string,\n\tconfigFile: string,\n): Promise<void> {\n\tconst marker = join(path, \"ownership.json\");\n\tconst exists = await directory(path);\n\tif (!exists || !(await readdir(path)).length) {\n\t\tawait mkdir(path, { recursive: true });\n\t\tawait writeFile(\n\t\t\tmarker,\n\t\t\t`${JSON.stringify({ kind: \"tsplc-engineering\", version: 1, configFile }, null, 2)}\\n`,\n\t\t\t{ flag: \"wx\" },\n\t\t);\n\t} else {\n\t\tconst entry = await lstat(marker).catch((cause: unknown) => {\n\t\t\tif (missing(cause)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Engineering cache has no matching tsPLC ownership marker: ${path}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow cause;\n\t\t});\n\t\tif (!entry.isFile() || entry.isSymbolicLink()) {\n\t\t\tthrow new Error(\"Engineering ownership marker must be a real file.\");\n\t\t}\n\t\tconst value = engineeringMarkerSchema.safeParse(\n\t\t\tJSON.parse(await readFile(marker, \"utf8\")),\n\t\t);\n\t\tif (!value.success || value.data.configFile !== configFile) {\n\t\t\tthrow new Error(\n\t\t\t\t`Engineering cache has no matching tsPLC ownership marker: ${path}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst inspect = async (directory: string): Promise<void> => {\n\t\tfor (const entry of await readdir(directory, { withFileTypes: true })) {\n\t\t\tconst child = join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Engineering cache must not contain symlinks: ${child}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait inspect(child);\n\t\t\t}\n\t\t}\n\t};\n\tawait inspect(path);\n}\n\nexport async function owned(\n\tconfigFile: string,\n\twithdrawReceipt = false,\n): Promise<{\n\troot: string;\n\toutput: string;\n\townership?: Manifest;\n\tunknown: string[];\n}> {\n\tconst root = join(dirname(configFile), \".tsplc\");\n\tconst output = join(root, \"artifacts\");\n\tif (!(await directory(root)) || !(await directory(output))) {\n\t\treturn { root, output, unknown: [] };\n\t}\n\n\tconst manifestPath = join(output, \"manifest.json\");\n\tconst manifestEntry = await lstat(manifestPath);\n\tif (!manifestEntry.isFile() || manifestEntry.isSymbolicLink()) {\n\t\tthrow new Error(\"Ownership manifest must be a real file.\");\n\t}\n\tconst ownership = manifest(\n\t\tJSON.parse(await readFile(manifestPath, \"utf8\")),\n\t\tconfigFile,\n\t);\n\tconst receipt = join(output, \"receipt.json\");\n\ttry {\n\t\tconst entry = await lstat(receipt);\n\t\tif (!entry.isFile() || entry.isSymbolicLink()) {\n\t\t\tthrow new Error(\"Build receipt must be a real file.\");\n\t\t}\n\t\tconst value = receiptSchema.safeParse(\n\t\t\tJSON.parse(await readFile(receipt, \"utf8\")),\n\t\t);\n\t\tif (!value.success || value.data.configFile !== configFile) {\n\t\t\tthrow new Error(\"Build receipt is not owned by this configuration.\");\n\t\t}\n\t\tif (withdrawReceipt) {\n\t\t\tawait rm(receipt);\n\t\t}\n\t} catch (cause) {\n\t\tif (!missing(cause)) {\n\t\t\tthrow cause;\n\t\t}\n\t}\n\n\tconst names = new Set([\n\t\t...ownership.files.map((file) => file.path),\n\t\t\"manifest.json\",\n\t\t\"receipt.json\",\n\t]);\n\tfor (const file of ownership.files) {\n\t\tlet parent = output;\n\t\tfor (const part of file.path.split(\"/\").slice(0, -1)) {\n\t\t\tparent = join(parent, part);\n\t\t\tif (!(await directory(parent))) {\n\t\t\t\tthrow new Error(`Missing generated directory: ${parent}`);\n\t\t\t}\n\t\t}\n\t\tconst path = join(output, file.path);\n\t\tconst entry = await lstat(path);\n\t\tif (\n\t\t\t!entry.isFile() ||\n\t\t\tentry.isSymbolicLink() ||\n\t\t\tdigest(await readFile(path)) !== file.sha256\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Generated file was replaced or edited; preserve it before rebuilding/cleaning: ${path}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\troot,\n\t\toutput,\n\t\townership,\n\t\tunknown: (await filesIn(output)).filter((name) => !names.has(name)),\n\t};\n}\n\ninterface Receipt {\n\tconfigFile: string;\n\tstatus: z.infer<typeof buildStatusSchema>;\n\tvendor?: Pick<\n\t\tAwaited<ReturnType<typeof buildCodesys>>,\n\t\t\"application\" | \"tasks\"\n\t>;\n}\n\n// Compile in a separate staging tree. Recheck ownership immediately before the\n// swap, because the vendor build may have given the user time to edit old files.\nexport async function publishArtifacts(\n\tstaging: string,\n\tprevious: Awaited<ReturnType<typeof owned>>,\n\treceipt: Receipt,\n): Promise<void> {\n\tconst configFile = receipt.configFile;\n\tconst generated = (await filesIn(staging)).sort();\n\tconst ownership: Manifest = {\n\t\tkind: \"tsplc-artifacts\",\n\t\tversion: 1,\n\t\tconfigFile,\n\t\tfiles: [],\n\t};\n\tfor (const path of generated) {\n\t\townership.files.push({\n\t\t\tpath,\n\t\t\tsha256: digest(await readFile(join(staging, path))),\n\t\t});\n\t}\n\tawait writeFile(\n\t\tjoin(staging, \"manifest.json\"),\n\t\t`${JSON.stringify(ownership, null, 2)}\\n`,\n\t);\n\tawait writeFile(\n\t\tjoin(staging, \"receipt.json\"),\n\t\t`${JSON.stringify(\n\t\t\t{\n\t\t\t\tkind: \"tsplc-build\",\n\t\t\t\tversion: 1,\n\t\t\t\tgeneratedAt: new Date().toISOString(),\n\t\t\t\t...receipt,\n\t\t\t},\n\t\t\tnull,\n\t\t\t2,\n\t\t)}\\n`,\n\t);\n\n\tconst current = await owned(configFile);\n\tif (\n\t\tJSON.stringify(current.ownership) !== JSON.stringify(previous.ownership)\n\t) {\n\t\tthrow new Error(\n\t\t\t\"Output ownership changed during the build; preserve it before rebuilding.\",\n\t\t);\n\t}\n\tif (current.unknown.length) {\n\t\tthrow new Error(\n\t\t\t`Output contains unrelated files: ${current.unknown.join(\", \")}`,\n\t\t);\n\t}\n\n\tconst backup = `${staging}-previous`;\n\tif (previous.ownership) {\n\t\tawait rename(previous.output, backup);\n\t}\n\ttry {\n\t\tawait rename(staging, previous.output);\n\t} catch (cause) {\n\t\tif (previous.ownership) {\n\t\t\tawait rename(backup, previous.output);\n\t\t}\n\t\tthrow cause;\n\t}\n\tif (previous.ownership) {\n\t\tawait rm(backup, { recursive: true });\n\t}\n}\n\nexport async function cleanArtifacts(configFile: string): Promise<void> {\n\tconst generated = await owned(configFile);\n\tif (!generated.ownership) {\n\t\treturn;\n\t}\n\tfor (const entry of generated.ownership.files) {\n\t\tawait rm(join(generated.output, entry.path));\n\t}\n\tawait rm(join(generated.output, \"receipt.json\"), { force: true });\n\tawait rm(join(generated.output, \"manifest.json\"));\n\n\t// Remove empty generated directories while preserving unrelated files.\n\tconst removeEmpty = async (path: string): Promise<void> => {\n\t\tfor (const entry of await readdir(path, { withFileTypes: true })) {\n\t\t\tif (entry.isDirectory() && !entry.isSymbolicLink()) {\n\t\t\t\tawait removeEmpty(join(path, entry.name));\n\t\t\t}\n\t\t}\n\t\tif (!(await readdir(path)).length) {\n\t\t\tawait rm(path, { recursive: true });\n\t\t}\n\t};\n\tawait removeEmpty(generated.output);\n}\n"
5
+ "import {\n\tcopyFile,\n\tmkdir,\n\tmkdtemp,\n\trealpath,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { installLibraries, type ProgressOptions } from \"@tsplc/build\";\nimport {\n\tanalyze,\n\ttype CompileEnvironment,\n\tcheckHostConfig,\n} from \"@tsplc/compiler\";\nimport {\n\tbuildCodesys,\n\ttype CodesysPlan,\n\ttype CodesysProject,\n\tcodesysBuildConfig,\n\tdiagnoseCodesys,\n\temitCodesys,\n\tioTargets,\n\tplanCodesys,\n\tpublicationSelectors,\n\ttype SourceMapping,\n} from \"@tsplc/compiler/codesys\";\nimport {\n\ttype Diagnostic,\n\thasErrors,\n\tnormalizeModule,\n\ttype VerifiedCoreModule,\n} from \"@tsplc/compiler/ir\";\nimport {\n\ttype BuildTarget,\n\ttype Controller,\n\tcompilerConfig,\n\ttype LoadedConfig,\n\tloadTsplcConfig,\n\ttype NormalizedConfig,\n\ttype ResolvedTsplcConfig,\n\tsimulationConfig,\n} from \"@tsplc/config\";\nimport { emittedFiles, emittedStDirectory } from \"@tsplc/config/project-files\";\nimport { debugManifestFile } from \"@tsplc/debug/manifest\";\nimport {\n\tdeviceTree,\n\tloadHardware,\n\ttype ProjectTargets,\n\tresolveIo,\n} from \"@tsplc/typegen\";\nimport {\n\tcleanArtifacts,\n\tengineeringDirectory,\n\towned,\n\tpublishArtifacts,\n} from \"./artifacts.ts\";\n\n/** The emitted ST's directory inside the compiler's artifacts directory. */\nconst emittedSt = basename(emittedStDirectory);\n\nconst failure = (\n\torigin: Diagnostic[\"origin\"],\n\tcode: string,\n\tcause: unknown,\n): Diagnostic => ({\n\torigin,\n\tcode,\n\tseverity: \"error\",\n\tmessage: cause instanceof Error ? cause.message : String(cause),\n});\n\n/**\n * `buildProject`'s `loaded` and `configured` options. With `simulate` the build omits fieldbus\n * I/O so a plant simulator can write the inputs; generated types and the debug manifest keep\n * describing the hardware project.\n */\nexport const buildConfigs = (\n\tloaded: LoadedConfig,\n\toptions: { simulate?: boolean },\n) =>\n\toptions.simulate\n\t\t? {\n\t\t\t\tloaded: { ...loaded, config: simulationConfig(loaded.config) },\n\t\t\t\tconfigured: loaded.config,\n\t\t\t}\n\t\t: { loaded };\n\ninterface ProjectOptions {\n\tloaded?: LoadedConfig;\n\tbuildTarget?: BuildTarget;\n\t/** The configuration `loaded` simulates, whose hardware the debug manifest describes. */\n\tconfigured?: ResolvedTsplcConfig;\n\t/**\n\t * The host config check's diagnostics, when the caller ran it before loading the config. The\n\t * check type-checks the config and takes seconds.\n\t */\n\thostConfigDiagnostics?: readonly Diagnostic[];\n\t/** What the program's `env()` calls, endpoints and telemetry read; this process's environment by default. */\n\tenvironment?: CompileEnvironment;\n}\n\n/** Loads the config in `environment`, this process's by default, with its only target's values. */\nconst loadEnvironment = (environment: CompileEnvironment | undefined) => ({\n\tenv: environment ?? process.env,\n\ttarget: undefined,\n\tforAgent: false,\n});\n\nasync function loadProject(\n\tfile: string,\n\t{\n\t\tloaded,\n\t\tbuildTarget,\n\t\tconfigured,\n\t\thostConfigDiagnostics,\n\t\tenvironment,\n\t}: ProjectOptions,\n): Promise<{\n\tconfig?: NormalizedConfig;\n\tconfigFile: string;\n\tshared?: ResolvedTsplcConfig;\n\tproject?: CodesysProject;\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\tlet configFile = resolve(file);\n\ttry {\n\t\tconfigFile = await realpath(configFile);\n\t\tconst diagnostics = hostConfigDiagnostics ?? checkHostConfig(configFile);\n\t\tif (hasErrors(diagnostics)) {\n\t\t\treturn { configFile, diagnostics };\n\t\t}\n\t\tconst { config: shared, env } =\n\t\t\tloaded ??\n\t\t\t(await loadTsplcConfig(configFile, loadEnvironment(environment)));\n\t\tconst root = dirname(configFile);\n\t\tconst catalog = await loadHardware(shared, root);\n\n\t\tconst config = compilerConfig(\n\t\t\tshared,\n\t\t\tresolveIo(shared, catalog),\n\t\t\tbuildTarget,\n\t\t);\n\t\treturn {\n\t\t\tconfigFile,\n\t\t\tshared,\n\t\t\tconfig: { ...config, ...sourceInput(config, root) },\n\t\t\tproject: {\n\t\t\t\troot,\n\t\t\t\tenvironment: env,\n\t\t\t\t...(shared.debug && { debug: shared.debug }),\n\t\t\t\t...(shared.telemetry && { telemetry: shared.telemetry }),\n\t\t\t\t...(shared.server && { server: shared.server }),\n\t\t\t\t// A simulation build drops fieldbus IO, but the debugger still shows the hardware it stands in for.\n\t\t\t\thardware: {\n\t\t\t\t\tcatalog: configured ? await loadHardware(configured, root) : catalog,\n\t\t\t\t\tconfig: configured ?? shared,\n\t\t\t\t\ttree: shared.codesys?.deviceTree !== undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdiagnostics,\n\t\t};\n\t} catch (cause) {\n\t\treturn { configFile, diagnostics: [failure(\"config\", \"PLC5003\", cause)] };\n\t}\n}\n\n/** The analyzer's entry points, resolved against the config file's directory. */\nfunction sourceInput(\n\tcompiler: {\n\t\ttsconfig: string;\n\t\tprograms: Record<string, { module: string; export: string }>;\n\t},\n\troot: string,\n) {\n\treturn {\n\t\ttsconfig: resolve(root, compiler.tsconfig),\n\t\tprograms: Object.fromEntries(\n\t\t\tObject.entries(compiler.programs).map(([name, entry]) => [\n\t\t\t\tname,\n\t\t\t\t{ ...entry, module: resolve(root, entry.module) },\n\t\t\t]),\n\t\t),\n\t};\n}\n\n/**\n * I/O keys and publication selectors from analyzed PLC source. It ignores the\n * config's own type errors, so a typo cannot switch off the types that flag it;\n * it is undefined only while the source itself fails analysis.\n */\nexport async function projectTargets(\n\tfile = \"tsplc.config.ts\",\n\toptions: Pick<ProjectOptions, \"loaded\" | \"environment\"> = {},\n): Promise<ProjectTargets | undefined> {\n\tconst configFile = await realpath(resolve(file));\n\tconst { config, env } =\n\t\toptions.loaded ??\n\t\t(await loadTsplcConfig(configFile, loadEnvironment(options.environment)));\n\tif (!config.compiler) {\n\t\treturn undefined;\n\t}\n\tconst source = analyze({\n\t\t...sourceInput(config.compiler, dirname(configFile)),\n\t\tservices: config.server,\n\t\tenvironment: env,\n\t});\n\tconst core = source.module && normalizeModule(source.module).core;\n\treturn core ? coreTargets(core) : undefined;\n}\n\nconst coreTargets = (core: VerifiedCoreModule): ProjectTargets => ({\n\tio: ioTargets(core),\n\tpublication: publicationSelectors(core),\n});\n\nexport async function checkProject(\n\tfile = \"tsplc.config.ts\",\n\toptions: ProjectOptions = {},\n): Promise<{\n\tconfigFile: string;\n\tconfig?: NormalizedConfig;\n\tshared?: ResolvedTsplcConfig;\n\tplan?: CodesysPlan;\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\tconst loaded = await loadProject(file, options);\n\tif (!loaded.config || !loaded.project) {\n\t\treturn loaded;\n\t}\n\n\tconst config = loaded.config;\n\tif (config.target.kind !== \"codesys\") {\n\t\treturn {\n\t\t\t...loaded,\n\t\t\tdiagnostics: [\n\t\t\t\tfailure(\n\t\t\t\t\t\"backend\",\n\t\t\t\t\t\"PLC7001\",\n\t\t\t\t\t`Unsupported target: ${config.target.kind}`,\n\t\t\t\t),\n\t\t\t],\n\t\t};\n\t}\n\n\tconst source = analyze({\n\t\ttsconfig: config.tsconfig,\n\t\tprograms: config.programs,\n\t\tservices: loaded.shared?.server,\n\t\tenvironment: loaded.project.environment,\n\t});\n\tif (!source.module) {\n\t\treturn { ...loaded, diagnostics: source.diagnostics };\n\t}\n\tconst normalized = normalizeModule(source.module);\n\tif (!normalized.core) {\n\t\treturn { ...loaded, diagnostics: normalized.diagnostics };\n\t}\n\n\tconst tasks = config.tasks.map((task) => ({\n\t\tname: task.name,\n\t\tintervalNanoseconds: task.schedule.interval.nanoseconds,\n\t\tpriority: task.priority,\n\t\tprograms: task.programs,\n\t}));\n\tconst planned = planCodesys(\n\t\tnormalized.core,\n\t\t{ tasks },\n\t\tconfig.target.options,\n\t\tloaded.project,\n\t);\n\treturn {\n\t\t...loaded,\n\t\t...planned,\n\t\tdiagnostics: [\n\t\t\t...loaded.diagnostics,\n\t\t\t...source.diagnostics,\n\t\t\t...normalized.diagnostics,\n\t\t\t...planned.diagnostics,\n\t\t],\n\t};\n}\n\n/** The installed libraries and fieldbus device tree a CODESYS project of this program needs. */\nasync function engineeringInputs(\n\tshared: ResolvedTsplcConfig,\n\tconfigFile: string,\n\tbundle: Pick<ReturnType<typeof emitCodesys>, \"ioMappings\">,\n\toptions: { frozen?: boolean },\n) {\n\tconst root = dirname(configFile);\n\tconst tree = await deviceTree(shared, await loadHardware(shared, root));\n\treturn {\n\t\tlibraries: await installLibraries(shared.dependencies, root, options),\n\t\t// The emitted names locate mapped IO; the tree maps their channels.\n\t\tdeviceTree: tree && {\n\t\t\t...tree,\n\t\t\tmappings: bundle.ioMappings.map(({ address, variable }) => ({\n\t\t\t\taddress,\n\t\t\t\tvariable,\n\t\t\t})),\n\t\t},\n\t};\n}\n\nexport async function buildProject(\n\tfile = \"tsplc.config.ts\",\n\toptions: ProjectOptions & {\n\t\temitOnly?: boolean;\n\t\tfrozenLockfile?: boolean;\n\t\tcontroller?: Controller;\n\t\t/** Resolve libraries and the device tree into `controllerConfig` even when only emitting. */\n\t\tforController?: boolean;\n\t} & ProgressOptions = {},\n): Promise<{\n\tdirectory?: string;\n\tstatus?: \"emitted\" | \"vendor-compiled\";\n\tcontrollerConfig?: ReturnType<typeof codesysBuildConfig>;\n\t/** What `projectTargets` reads from the program, from this build's own analysis. */\n\ttargets?: ProjectTargets;\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\tlet staging: string | undefined;\n\ttry {\n\t\tconst configFile = await realpath(resolve(file));\n\t\t// Withdraw the previous success receipt before checking the new source.\n\t\t// Old artifacts remain owned and intact until publication succeeds.\n\t\tconst previous = await owned(configFile, true);\n\t\tif (previous.unknown.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Output contains unrelated files: ${previous.unknown.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tconst checked = await checkProject(configFile, options);\n\t\tif (!checked.plan || !checked.config) {\n\t\t\treturn { diagnostics: checked.diagnostics };\n\t\t}\n\t\tconst bundle = emitCodesys(checked.plan);\n\t\tif (hasErrors(bundle.diagnostics)) {\n\t\t\treturn { diagnostics: bundle.diagnostics };\n\t\t}\n\t\tconst shared = checked.shared;\n\t\tconst engineering =\n\t\t\tshared && (!options.emitOnly || options.forController)\n\t\t\t\t? await engineeringInputs(shared, configFile, bundle, {\n\t\t\t\t\t\tfrozen: options.frozenLockfile,\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t\tconst outDir =\n\t\t\tshared?.build && resolve(dirname(configFile), shared.build.outDir);\n\t\tconst controllerConfig = outDir\n\t\t\t? codesysBuildConfig(checked.plan, bundle, {\n\t\t\t\t\tconfigFile,\n\t\t\t\t\tsourceDir: join(previous.output, emittedSt),\n\t\t\t\t\toutDir,\n\t\t\t\t\tcontroller: options.controller,\n\t\t\t\t\t...engineering,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\tawait mkdir(previous.root, { recursive: true });\n\t\tstaging = await mkdtemp(join(previous.root, \"stage-\"));\n\t\tconst artifacts = [\n\t\t\t...bundle.artifacts,\n\t\t\t{\n\t\t\t\tpath: \"mappings.json\",\n\t\t\t\tcontent: `${JSON.stringify(compactMappings(bundle.mappings))}\\n`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: emittedFiles.ioSymbols,\n\t\t\t\tcontent: `${JSON.stringify(bundle.ioSymbols, null, 2)}\\n`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: emittedFiles.publication,\n\t\t\t\tcontent: `${JSON.stringify(bundle.publication, null, 2)}\\n`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"config.json\",\n\t\t\t\tcontent: `${JSON.stringify(checked.config, null, 2)}\\n`,\n\t\t\t},\n\t\t\t...(bundle.debug\n\t\t\t\t? [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpath: debugManifestFile,\n\t\t\t\t\t\t\tcontent: `${JSON.stringify(bundle.debug)}\\n`,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t];\n\t\tconst stagedSt = join(staging, emittedSt);\n\t\t// Thousands of artifacts share a few hundred directories; each is made once.\n\t\tconst directories = new Set(\n\t\t\tartifacts.map((artifact) => dirname(join(stagedSt, artifact.path))),\n\t\t);\n\t\tfor (const directory of directories) {\n\t\t\tawait mkdir(directory, { recursive: true });\n\t\t}\n\t\tfor (const artifact of artifacts) {\n\t\t\tawait writeFile(join(stagedSt, artifact.path), artifact.content);\n\t\t}\n\n\t\tlet vendor: Awaited<ReturnType<typeof buildCodesys>> | undefined;\n\t\tif (!options.emitOnly) {\n\t\t\t// The engineering cache has its own ownership marker and survives clean.\n\t\t\tconst engineeringDir = outDir ?? join(previous.root, \"engineering\");\n\t\t\tawait engineeringDirectory(engineeringDir, configFile);\n\t\t\ttry {\n\t\t\t\tvendor = await buildCodesys(\n\t\t\t\t\tchecked.plan,\n\t\t\t\t\tbundle,\n\t\t\t\t\t{\n\t\t\t\t\t\tconfigFile,\n\t\t\t\t\t\tsourceDir: join(staging, emittedSt),\n\t\t\t\t\t\toutDir: engineeringDir,\n\t\t\t\t\t\tcontroller: options.controller,\n\t\t\t\t\t\t...engineering,\n\t\t\t\t\t},\n\t\t\t\t\t{ progress: options.progress },\n\t\t\t\t);\n\t\t\t} catch (cause) {\n\t\t\t\treturn { diagnostics: diagnoseCodesys(cause, bundle) };\n\t\t\t}\n\n\t\t\tconst vendorArtifacts = [\n\t\t\t\t[\"Application.project\", vendor.project],\n\t\t\t\t[\"Application.app\", vendor.output],\n\t\t\t\t[\"Application.crc\", vendor.checksum],\n\t\t\t] as const;\n\t\t\tfor (const [name, path] of vendorArtifacts) {\n\t\t\t\tif (!path) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst destination = join(staging, \"vendor\", name);\n\t\t\t\tawait mkdir(dirname(destination), { recursive: true });\n\t\t\t\tawait copyFile(path, destination);\n\t\t\t}\n\t\t}\n\n\t\tconst status = vendor ? \"vendor-compiled\" : \"emitted\";\n\t\tawait publishArtifacts(staging, previous, {\n\t\t\tconfigFile,\n\t\t\tstatus,\n\t\t\t...(vendor && {\n\t\t\t\tvendor: { application: vendor.application, tasks: vendor.tasks },\n\t\t\t}),\n\t\t});\n\t\t// Publication moved this directory into place; it is no longer staging.\n\t\tstaging = undefined;\n\t\treturn {\n\t\t\tdirectory: previous.output,\n\t\t\tstatus,\n\t\t\t...(controllerConfig && { controllerConfig }),\n\t\t\ttargets: coreTargets(checked.plan.core),\n\t\t\tdiagnostics: [...checked.diagnostics, ...bundle.diagnostics],\n\t\t};\n\t} catch (cause) {\n\t\treturn { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n\t} finally {\n\t\tif (staging) {\n\t\t\tawait rm(staging, { recursive: true, force: true });\n\t\t}\n\t}\n}\n\n/**\n * Source mappings with each ST path and source file written once: `mappings` rows are\n * `[object, line, file, start, end, sourceLine, sourceColumn]`, indexing `objects` and `files`.\n */\nfunction compactMappings(mappings: readonly SourceMapping[]) {\n\tconst objects = new Map<string, number>();\n\tconst files = new Map<string, number>();\n\tconst index = (table: Map<string, number>, value: string) => {\n\t\tconst known = table.get(value);\n\t\tif (known !== undefined) {\n\t\t\treturn known;\n\t\t}\n\t\ttable.set(value, table.size);\n\t\treturn table.size - 1;\n\t};\n\tconst rows = mappings.map(({ path, line, span }) => [\n\t\tindex(objects, path),\n\t\tline,\n\t\tindex(files, span.file),\n\t\tspan.start,\n\t\tspan.end,\n\t\tspan.line,\n\t\tspan.column,\n\t]);\n\treturn {\n\t\tobjects: [...objects.keys()],\n\t\tfiles: [...files.keys()],\n\t\tmappings: rows,\n\t};\n}\n\nexport async function cleanProject(file = \"tsplc.config.ts\"): Promise<{\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\ttry {\n\t\tawait cleanArtifacts(await realpath(resolve(file)));\n\t\treturn { diagnostics: [] };\n\t} catch (cause) {\n\t\treturn { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n\t}\n}\n",
6
+ "import { createHash } from \"node:crypto\";\nimport {\n\tlstat,\n\tmkdir,\n\treaddir,\n\treadFile,\n\trename,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport type { buildCodesys } from \"@tsplc/compiler/codesys\";\nimport { sha256Digest } from \"@tsplc/config/build\";\nimport {\n\temittedStDirectory,\n\tgeneratedDirectory,\n} from \"@tsplc/config/project-files\";\nimport { z } from \"zod\";\n\nconst missing = (cause: unknown): boolean =>\n\tcause instanceof Error && \"code\" in cause && cause.code === \"ENOENT\";\nconst digest = (value: string | Uint8Array): string =>\n\tcreateHash(\"sha256\").update(value).digest(\"hex\");\n\n// Ownership is an explicit boundary: generated files must match their manifest,\n// and engineering trees must belong to this configuration before vendor writes.\nconst generatedFileSchema = z.object({\n\tpath: z\n\t\t.string()\n\t\t.regex(/^[A-Za-z0-9_ .-]+(?:\\/[A-Za-z0-9_ .-]+)*$/)\n\t\t.refine(\n\t\t\t(path) =>\n\t\t\t\t!path.split(\"/\").some((part) => part === \".\" || part === \"..\") &&\n\t\t\t\t![\"manifest.json\", \"receipt.json\"].includes(path),\n\t\t),\n\tsha256: sha256Digest,\n});\n\n/** The manifest's envelope; its entries are checked one by one to name the failure. */\nconst manifestSchema = z.object({\n\tkind: z.literal(\"tsplc-artifacts\"),\n\tversion: z.literal(1),\n\tconfigFile: z.string(),\n\tfiles: z.array(z.unknown()),\n});\n\ntype Manifest = Omit<z.infer<typeof manifestSchema>, \"files\"> & {\n\tfiles: z.infer<typeof generatedFileSchema>[];\n};\n\nconst buildStatusSchema = z.enum([\"emitted\", \"vendor-compiled\"]);\n\nconst receiptSchema = z.object({\n\tkind: z.literal(\"tsplc-build\"),\n\tversion: z.literal(1),\n\tconfigFile: z.string(),\n\tstatus: buildStatusSchema,\n});\n\nconst engineeringMarkerSchema = z.object({\n\tkind: z.literal(\"tsplc-engineering\"),\n\tversion: z.literal(1),\n\tconfigFile: z.string(),\n});\n\nfunction manifest(value: unknown, configFile: string): Manifest {\n\tconst parsed = manifestSchema.safeParse(value);\n\tif (!parsed.success || parsed.data.configFile !== configFile) {\n\t\tthrow new Error(\n\t\t\t\"Output directory has no matching tsPLC ownership manifest.\",\n\t\t);\n\t}\n\n\tconst files = parsed.data.files.map((item) => {\n\t\tconst file = generatedFileSchema.safeParse(item);\n\t\tif (!file.success) {\n\t\t\tthrow new Error(\"Invalid generated file ownership entry.\");\n\t\t}\n\t\treturn file.data;\n\t});\n\tif (new Set(files.map((item) => item.path)).size !== files.length) {\n\t\tthrow new Error(\"Duplicate generated file ownership entry.\");\n\t}\n\treturn { ...parsed.data, files };\n}\n\nasync function directory(path: string): Promise<boolean> {\n\ttry {\n\t\tconst entry = await lstat(path);\n\t\tif (!entry.isDirectory() || entry.isSymbolicLink()) {\n\t\t\tthrow new Error(`Generated directory must be a real directory: ${path}`);\n\t\t}\n\t\treturn true;\n\t} catch (cause) {\n\t\tif (missing(cause)) {\n\t\t\treturn false;\n\t\t}\n\t\tthrow cause;\n\t}\n}\n\nasync function filesIn(path: string, prefix = \"\"): Promise<string[]> {\n\tconst result: string[] = [];\n\tfor (const entry of await readdir(path, { withFileTypes: true })) {\n\t\tconst name = prefix + entry.name;\n\t\tif (entry.isDirectory() && !entry.isSymbolicLink()) {\n\t\t\tresult.push(...(await filesIn(join(path, entry.name), `${name}/`)));\n\t\t} else {\n\t\t\tresult.push(name);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport async function engineeringDirectory(\n\tpath: string,\n\tconfigFile: string,\n): Promise<void> {\n\tconst marker = join(path, \"ownership.json\");\n\tconst exists = await directory(path);\n\tif (!exists || !(await readdir(path)).length) {\n\t\tawait mkdir(path, { recursive: true });\n\t\tawait writeFile(\n\t\t\tmarker,\n\t\t\t`${JSON.stringify({ kind: \"tsplc-engineering\", version: 1, configFile }, null, 2)}\\n`,\n\t\t\t{ flag: \"wx\" },\n\t\t);\n\t} else {\n\t\tconst entry = await lstat(marker).catch((cause: unknown) => {\n\t\t\tif (missing(cause)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Engineering cache has no matching tsPLC ownership marker: ${path}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow cause;\n\t\t});\n\t\tif (!entry.isFile() || entry.isSymbolicLink()) {\n\t\t\tthrow new Error(\"Engineering ownership marker must be a real file.\");\n\t\t}\n\t\tconst value = engineeringMarkerSchema.safeParse(\n\t\t\tJSON.parse(await readFile(marker, \"utf8\")),\n\t\t);\n\t\tif (!value.success || value.data.configFile !== configFile) {\n\t\t\tthrow new Error(\n\t\t\t\t`Engineering cache has no matching tsPLC ownership marker: ${path}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst inspect = async (directory: string): Promise<void> => {\n\t\tfor (const entry of await readdir(directory, { withFileTypes: true })) {\n\t\t\tconst child = join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Engineering cache must not contain symlinks: ${child}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait inspect(child);\n\t\t\t}\n\t\t}\n\t};\n\tawait inspect(path);\n}\n\nexport async function owned(\n\tconfigFile: string,\n\twithdrawReceipt = false,\n): Promise<{\n\troot: string;\n\toutput: string;\n\townership?: Manifest;\n\tunknown: string[];\n}> {\n\tconst root = join(dirname(configFile), generatedDirectory);\n\tconst output = join(dirname(configFile), dirname(emittedStDirectory));\n\tif (!(await directory(root)) || !(await directory(output))) {\n\t\treturn { root, output, unknown: [] };\n\t}\n\n\tconst manifestPath = join(output, \"manifest.json\");\n\tconst manifestEntry = await lstat(manifestPath);\n\tif (!manifestEntry.isFile() || manifestEntry.isSymbolicLink()) {\n\t\tthrow new Error(\"Ownership manifest must be a real file.\");\n\t}\n\tconst ownership = manifest(\n\t\tJSON.parse(await readFile(manifestPath, \"utf8\")),\n\t\tconfigFile,\n\t);\n\tconst receipt = join(output, \"receipt.json\");\n\ttry {\n\t\tconst entry = await lstat(receipt);\n\t\tif (!entry.isFile() || entry.isSymbolicLink()) {\n\t\t\tthrow new Error(\"Build receipt must be a real file.\");\n\t\t}\n\t\tconst value = receiptSchema.safeParse(\n\t\t\tJSON.parse(await readFile(receipt, \"utf8\")),\n\t\t);\n\t\tif (!value.success || value.data.configFile !== configFile) {\n\t\t\tthrow new Error(\"Build receipt is not owned by this configuration.\");\n\t\t}\n\t\tif (withdrawReceipt) {\n\t\t\tawait rm(receipt);\n\t\t}\n\t} catch (cause) {\n\t\tif (!missing(cause)) {\n\t\t\tthrow cause;\n\t\t}\n\t}\n\n\tconst names = new Set([\n\t\t...ownership.files.map((file) => file.path),\n\t\t\"manifest.json\",\n\t\t\"receipt.json\",\n\t]);\n\t// Thousands of files share a few hundred directories; each is checked once.\n\tconst checked = new Set<string>();\n\tfor (const file of ownership.files) {\n\t\tlet parent = output;\n\t\tfor (const part of file.path.split(\"/\").slice(0, -1)) {\n\t\t\tparent = join(parent, part);\n\t\t\tif (checked.has(parent)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!(await directory(parent))) {\n\t\t\t\tthrow new Error(`Missing generated directory: ${parent}`);\n\t\t\t}\n\t\t\tchecked.add(parent);\n\t\t}\n\t\tconst path = join(output, file.path);\n\t\tconst entry = await lstat(path);\n\t\tif (\n\t\t\t!entry.isFile() ||\n\t\t\tentry.isSymbolicLink() ||\n\t\t\tdigest(await readFile(path)) !== file.sha256\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Generated file was replaced or edited; preserve it before rebuilding/cleaning: ${path}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\troot,\n\t\toutput,\n\t\townership,\n\t\tunknown: (await filesIn(output)).filter((name) => !names.has(name)),\n\t};\n}\n\ninterface Receipt {\n\tconfigFile: string;\n\tstatus: z.infer<typeof buildStatusSchema>;\n\tvendor?: Pick<\n\t\tAwaited<ReturnType<typeof buildCodesys>>,\n\t\t\"application\" | \"tasks\"\n\t>;\n}\n\n// Compile in a separate staging tree. Recheck ownership immediately before the\n// swap, because the vendor build may have given the user time to edit old files.\nexport async function publishArtifacts(\n\tstaging: string,\n\tprevious: Awaited<ReturnType<typeof owned>>,\n\treceipt: Receipt,\n): Promise<void> {\n\tconst configFile = receipt.configFile;\n\tconst generated = (await filesIn(staging)).sort();\n\tconst ownership: Manifest = {\n\t\tkind: \"tsplc-artifacts\",\n\t\tversion: 1,\n\t\tconfigFile,\n\t\tfiles: [],\n\t};\n\tfor (const path of generated) {\n\t\townership.files.push({\n\t\t\tpath,\n\t\t\tsha256: digest(await readFile(join(staging, path))),\n\t\t});\n\t}\n\tawait writeFile(\n\t\tjoin(staging, \"manifest.json\"),\n\t\t`${JSON.stringify(ownership, null, 2)}\\n`,\n\t);\n\tawait writeFile(\n\t\tjoin(staging, \"receipt.json\"),\n\t\t`${JSON.stringify(\n\t\t\t{\n\t\t\t\tkind: \"tsplc-build\",\n\t\t\t\tversion: 1,\n\t\t\t\tgeneratedAt: new Date().toISOString(),\n\t\t\t\t...receipt,\n\t\t\t},\n\t\t\tnull,\n\t\t\t2,\n\t\t)}\\n`,\n\t);\n\n\tconst current = await owned(configFile);\n\tif (\n\t\tJSON.stringify(current.ownership) !== JSON.stringify(previous.ownership)\n\t) {\n\t\tthrow new Error(\n\t\t\t\"Output ownership changed during the build; preserve it before rebuilding.\",\n\t\t);\n\t}\n\tif (current.unknown.length) {\n\t\tthrow new Error(\n\t\t\t`Output contains unrelated files: ${current.unknown.join(\", \")}`,\n\t\t);\n\t}\n\n\tconst backup = `${staging}-previous`;\n\tif (previous.ownership) {\n\t\tawait rename(previous.output, backup);\n\t}\n\ttry {\n\t\tawait rename(staging, previous.output);\n\t} catch (cause) {\n\t\tif (previous.ownership) {\n\t\t\tawait rename(backup, previous.output);\n\t\t}\n\t\tthrow cause;\n\t}\n\tif (previous.ownership) {\n\t\tawait rm(backup, { recursive: true });\n\t}\n}\n\nexport async function cleanArtifacts(configFile: string): Promise<void> {\n\tconst generated = await owned(configFile);\n\tif (!generated.ownership) {\n\t\treturn;\n\t}\n\tfor (const entry of generated.ownership.files) {\n\t\tawait rm(join(generated.output, entry.path));\n\t}\n\tawait rm(join(generated.output, \"receipt.json\"), { force: true });\n\tawait rm(join(generated.output, \"manifest.json\"));\n\n\t// Remove empty generated directories while preserving unrelated files.\n\tconst removeEmpty = async (path: string): Promise<void> => {\n\t\tfor (const entry of await readdir(path, { withFileTypes: true })) {\n\t\t\tif (entry.isDirectory() && !entry.isSymbolicLink()) {\n\t\t\t\tawait removeEmpty(join(path, entry.name));\n\t\t\t}\n\t\t}\n\t\tif (!(await readdir(path)).length) {\n\t\t\tawait rm(path, { recursive: true });\n\t\t}\n\t};\n\tawait removeEmpty(generated.output);\n}\n"
7
7
  ],
8
- "mappings": ";AAAA;AAAA;AAAA,WAEC;AAAA;AAAA;AAAA,QAGA;AAAA,eACA;AAAA;AAED,oBAAS,kBAAS;AAClB;AAAA;AAAA;AAAA;AAAA;AAAA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756E2164756E21",
10
10
  "names": []
11
11
  }
package/dist/retain.js ADDED
@@ -0,0 +1,8 @@
1
+ // packages/compiler/stdlib/retain.ts
2
+ var retain = (value) => value;
3
+ export {
4
+ retain
5
+ };
6
+
7
+ //# debugId=A03AEA5B694A74C464756E2164756E21
8
+ //# sourceMappingURL=retain.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../stdlib/retain.ts"],
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"
6
+ ],
7
+ "mappings": ";AACO,IAAM,SAAS,CAAI,UAAgB;",
8
+ "debugId": "A03AEA5B694A74C464756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,59 @@
1
+ // @bun
2
+ // packages/compiler/src/project/server-check.ts
3
+ import { dirname } from "path";
4
+ import { typeCheckOnly } from "@tsplc/compiler";
5
+ import ts from "typescript";
6
+
7
+ // packages/compiler/src/project/server.ts
8
+ import { z } from "zod";
9
+ var serverCheckRequestSchema = z.strictObject({
10
+ entry: z.string(),
11
+ root: z.string()
12
+ });
13
+ var serverCheckResultSchema = z.strictObject({
14
+ failure: z.string().nullable()
15
+ });
16
+
17
+ // packages/compiler/src/project/server-check.ts
18
+ var serverFailure = ({
19
+ entry,
20
+ root
21
+ }) => {
22
+ const tsconfig = ts.findConfigFile(dirname(entry), ts.sys.fileExists);
23
+ if (!tsconfig) {
24
+ return "Server entry requires a tsconfig.json.";
25
+ }
26
+ const read = ts.readConfigFile(tsconfig, ts.sys.readFile);
27
+ if (read.error) {
28
+ return ts.flattenDiagnosticMessageText(read.error.messageText, `
29
+ `);
30
+ }
31
+ const parsed = ts.parseJsonConfigFileContent(read.config, ts.sys, dirname(tsconfig));
32
+ const program = ts.createProgram({
33
+ rootNames: [
34
+ entry,
35
+ ...parsed.fileNames.filter((file) => /\.d\.[cm]?ts$/.test(file))
36
+ ],
37
+ options: { ...parsed.options, ...typeCheckOnly },
38
+ projectReferences: parsed.projectReferences
39
+ });
40
+ const diagnostics = [...parsed.errors, ...ts.getPreEmitDiagnostics(program)];
41
+ if (!diagnostics.length) {
42
+ return null;
43
+ }
44
+ return ts.formatDiagnosticsWithColorAndContext(diagnostics, {
45
+ getCanonicalFileName: (path) => path,
46
+ getCurrentDirectory: () => root,
47
+ getNewLine: () => `
48
+ `
49
+ });
50
+ };
51
+ self.onmessage = (event) => {
52
+ const result = {
53
+ failure: serverFailure(serverCheckRequestSchema.parse(event.data))
54
+ };
55
+ self.postMessage(result);
56
+ };
57
+
58
+ //# debugId=81486E03709D174864756E2164756E21
59
+ //# sourceMappingURL=server-check.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/project/server-check.ts", "../src/project/server.ts"],
4
+ "sourcesContent": [
5
+ "import { dirname } from \"node:path\";\nimport { typeCheckOnly } from \"@tsplc/compiler\";\nimport ts from \"typescript\";\nimport type { z } from \"zod\";\nimport {\n\tserverCheckRequestSchema,\n\ttype serverCheckResultSchema,\n} from \"./server.ts\";\n\n/** Type-checks the server entry under the tsconfig beside it, as it will be built. */\nconst serverFailure = ({\n\tentry,\n\troot,\n}: z.infer<typeof serverCheckRequestSchema>): string | null => {\n\tconst tsconfig = ts.findConfigFile(dirname(entry), ts.sys.fileExists);\n\tif (!tsconfig) {\n\t\treturn \"Server entry requires a tsconfig.json.\";\n\t}\n\tconst read = ts.readConfigFile(tsconfig, ts.sys.readFile);\n\tif (read.error) {\n\t\treturn ts.flattenDiagnosticMessageText(read.error.messageText, \"\\n\");\n\t}\n\tconst parsed = ts.parseJsonConfigFileContent(\n\t\tread.config,\n\t\tts.sys,\n\t\tdirname(tsconfig),\n\t);\n\tconst program = ts.createProgram({\n\t\trootNames: [\n\t\t\tentry,\n\t\t\t...parsed.fileNames.filter((file) => /\\.d\\.[cm]?ts$/.test(file)),\n\t\t],\n\t\toptions: { ...parsed.options, ...typeCheckOnly },\n\t\tprojectReferences: parsed.projectReferences,\n\t});\n\tconst diagnostics = [...parsed.errors, ...ts.getPreEmitDiagnostics(program)];\n\tif (!diagnostics.length) {\n\t\treturn null;\n\t}\n\treturn ts.formatDiagnosticsWithColorAndContext(diagnostics, {\n\t\tgetCanonicalFileName: (path) => path,\n\t\tgetCurrentDirectory: () => root,\n\t\tgetNewLine: () => \"\\n\",\n\t});\n};\n\n// A worker thread runs this module, so the check of a server's thousands of files overlaps the PLC build.\ndeclare const self: Worker;\nself.onmessage = (event: MessageEvent) => {\n\tconst result: z.infer<typeof serverCheckResultSchema> = {\n\t\tfailure: serverFailure(serverCheckRequestSchema.parse(event.data)),\n\t};\n\tself.postMessage(result);\n};\n",
6
+ "import { existsSync } from \"node:fs\";\nimport { mkdir, mkdtemp, rename, rm } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { ResolvedTsplcConfig } from \"@tsplc/config\";\nimport { z } from \"zod\";\n\nconst resolveServerModule = (root: string, name: string) =>\n\tname.startsWith(\".\") ||\n\tname.startsWith(\"/\") ||\n\texistsSync(resolve(root, name))\n\t\t? resolve(root, name)\n\t\t: createRequire(join(root, \"package.json\")).resolve(name);\n\nconst kebabCase = (name: string) =>\n\tname\n\t\t.replace(/([a-z0-9])([A-Z])|([A-Z])([A-Z][a-z])/g, \"$1$3-$2$4\")\n\t\t.replace(/[^A-Za-z0-9]+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\")\n\t\t.toLowerCase();\n\n/** `build/server/<name>-services<extension>`, where the server's script or executable goes. */\nconst serverOutput = (\n\tconfig: ResolvedTsplcConfig,\n\troot: string,\n\textension: string,\n) =>\n\tresolve(\n\t\troot,\n\t\t\"build/server\",\n\t\t`${kebabCase(config.name)}-services${extension}`,\n\t);\n\n/** What `checkServer` posts to its worker: the server entry and the project root diagnostics are relative to. */\nexport const serverCheckRequestSchema = z.strictObject({\n\tentry: z.string(),\n\troot: z.string(),\n});\n\n/** The worker's answer: why the server entry fails its type check, or null when it passes. */\nexport const serverCheckResultSchema = z.strictObject({\n\tfailure: z.string().nullable(),\n});\n\n/** The type-check script beside this module: its source, or the bundle a built package ships. */\nconst serverCheckScript = () => {\n\tconst script = [\"./server-check.ts\", \"./server-check.js\"]\n\t\t.map((path) => fileURLToPath(new URL(path, import.meta.url)))\n\t\t.find((path) => existsSync(path));\n\tif (!script) {\n\t\tthrow new Error(\"The server type-check script is missing from this build.\");\n\t}\n\treturn script;\n};\n\n/** A server entry that passed its type check, and the runtime it is built for. */\nexport interface CheckedServer {\n\tentry: string;\n\truntime: NonNullable<NonNullable<ResolvedTsplcConfig[\"server\"]>[\"runtime\"]>;\n}\n\n/**\n * Type-checks the host entry as it will be built, on a worker thread: a caller that builds the\n * PLC program meanwhile awaits the result after it. The check rejects with the diagnostics.\n */\nexport const checkServer = async (\n\tconfig: ResolvedTsplcConfig,\n\troot: string,\n): Promise<CheckedServer> => {\n\tconst runtime = config.server?.runtime;\n\tif (!runtime) {\n\t\tthrow new Error(\"Configure server.runtime to build the server.\");\n\t}\n\tconst entry = resolveServerModule(root, runtime.entry);\n\tconst worker = new Worker(serverCheckScript());\n\ttry {\n\t\tconst answer = await new Promise<unknown>((resolve, reject) => {\n\t\t\tworker.onmessage = (event: MessageEvent) => resolve(event.data);\n\t\t\tworker.onerror = (event) => reject(new Error(event.message));\n\t\t\tconst request: z.infer<typeof serverCheckRequestSchema> = {\n\t\t\t\tentry,\n\t\t\t\troot,\n\t\t\t};\n\t\t\tworker.postMessage(request);\n\t\t});\n\t\tconst { failure } = serverCheckResultSchema.parse(answer);\n\t\tif (failure !== null) {\n\t\t\tthrow new Error(failure);\n\t\t}\n\t\treturn { entry, runtime };\n\t} finally {\n\t\tworker.terminate();\n\t}\n};\n\n/**\n * Bundles the host entry, which starts its own listener, into one minified script,\n * `build/server/<name>-services.js`, which the plant agent runs on its own Bun. It is a few MB\n * where an executable, which embeds Bun, is over 100, and deployments upload it.\n */\nexport const bundleServer = async (\n\t{ entry }: CheckedServer,\n\tconfig: ResolvedTsplcConfig,\n\troot: string,\n) => {\n\tconst outFile = serverOutput(config, root, \".js\");\n\tconst result = await Bun.build({\n\t\tentrypoints: [entry],\n\t\ttarget: \"bun\",\n\t\tminify: true,\n\t\tenv: \"disable\",\n\t});\n\tif (!result.success) {\n\t\tthrow new AggregateError(result.logs, \"Server bundle build failed.\");\n\t}\n\tconst [script, ...assets] = result.outputs;\n\tif (!script || assets.length) {\n\t\tthrow new Error(\n\t\t\t`The server bundle needs files beside its script (${assets.map(({ path }) => path).join(\", \")}), which deployments don't carry.`,\n\t\t);\n\t}\n\tawait mkdir(dirname(outFile), { recursive: true });\n\tawait Bun.write(outFile, script);\n\treturn outFile;\n};\n\n/** Compiles the host entry, which starts its own listener, into `build/server/<name>-services`. */\nexport const buildServer = async (\n\t{ entry, runtime }: CheckedServer,\n\tconfig: ResolvedTsplcConfig,\n\troot: string,\n) => {\n\tconst windows = runtime.target\n\t\t? runtime.target.includes(\"windows\")\n\t\t: process.platform === \"win32\";\n\tconst outFile = serverOutput(config, root, windows ? \".exe\" : \"\");\n\tawait mkdir(dirname(outFile), { recursive: true });\n\t// Compile beside the output so dependency resolution starts from the owning project.\n\tconst staging = await mkdtemp(join(dirname(outFile), \".tsplc-server-\"));\n\ttry {\n\t\tconst binary = join(staging, \"server\");\n\t\tconst result = await Bun.build({\n\t\t\tentrypoints: [entry],\n\t\t\tenv: \"disable\",\n\t\t\tcompile: {\n\t\t\t\toutfile: binary,\n\t\t\t\t...(runtime.target ? { target: runtime.target } : {}),\n\t\t\t\tautoloadDotenv: false,\n\t\t\t\tautoloadBunfig: false,\n\t\t\t\tautoloadTsconfig: false,\n\t\t\t\tautoloadPackageJson: false,\n\t\t\t},\n\t\t});\n\t\tif (!result.success) {\n\t\t\tthrow new AggregateError(result.logs, \"Server executable build failed.\");\n\t\t}\n\t\t// Bun names a Windows executable itself.\n\t\tawait rename(windows ? `${binary}.exe` : binary, outFile);\n\t\treturn {\n\t\t\tserver: {\n\t\t\t\texecutable: outFile,\n\t\t\t\ttarget: runtime.target ?? `bun-${process.platform}-${process.arch}`,\n\t\t\t},\n\t\t};\n\t} finally {\n\t\tawait rm(staging, { recursive: true, force: true });\n\t}\n};\n"
7
+ ],
8
+ "mappings": ";;AAAA;AACA;AACA;;;ACIA;AA6BO,IAAM,2BAA2B,EAAE,aAAa;AAAA,EACtD,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AAChB,CAAC;AAGM,IAAM,0BAA0B,EAAE,aAAa;AAAA,EACrD,SAAS,EAAE,OAAO,EAAE,SAAS;AAC9B,CAAC;;;ADjCD,IAAM,gBAAgB;AAAA,EACrB;AAAA,EACA;AAAA,MAC8D;AAAA,EAC9D,MAAM,WAAW,GAAG,eAAe,QAAQ,KAAK,GAAG,GAAG,IAAI,UAAU;AAAA,EACpE,IAAI,CAAC,UAAU;AAAA,IACd,OAAO;AAAA,EACR;AAAA,EACA,MAAM,OAAO,GAAG,eAAe,UAAU,GAAG,IAAI,QAAQ;AAAA,EACxD,IAAI,KAAK,OAAO;AAAA,IACf,OAAO,GAAG,6BAA6B,KAAK,MAAM,aAAa;AAAA,CAAI;AAAA,EACpE;AAAA,EACA,MAAM,SAAS,GAAG,2BACjB,KAAK,QACL,GAAG,KACH,QAAQ,QAAQ,CACjB;AAAA,EACA,MAAM,UAAU,GAAG,cAAc;AAAA,IAChC,WAAW;AAAA,MACV;AAAA,MACA,GAAG,OAAO,UAAU,OAAO,CAAC,SAAS,gBAAgB,KAAK,IAAI,CAAC;AAAA,IAChE;AAAA,IACA,SAAS,KAAK,OAAO,YAAY,cAAc;AAAA,IAC/C,mBAAmB,OAAO;AAAA,EAC3B,CAAC;AAAA,EACD,MAAM,cAAc,CAAC,GAAG,OAAO,QAAQ,GAAG,GAAG,sBAAsB,OAAO,CAAC;AAAA,EAC3E,IAAI,CAAC,YAAY,QAAQ;AAAA,IACxB,OAAO;AAAA,EACR;AAAA,EACA,OAAO,GAAG,qCAAqC,aAAa;AAAA,IAC3D,sBAAsB,CAAC,SAAS;AAAA,IAChC,qBAAqB,MAAM;AAAA,IAC3B,YAAY,MAAM;AAAA;AAAA,EACnB,CAAC;AAAA;AAKF,KAAK,YAAY,CAAC,UAAwB;AAAA,EACzC,MAAM,SAAkD;AAAA,IACvD,SAAS,cAAc,yBAAyB,MAAM,MAAM,IAAI,CAAC;AAAA,EAClE;AAAA,EACA,KAAK,YAAY,MAAM;AAAA;",
9
+ "debugId": "81486E03709D174864756E2164756E21",
10
+ "names": []
11
+ }
package/dist/telemetry.js CHANGED
@@ -3,17 +3,26 @@ import { relative } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
 
5
5
  // packages/compiler/src/ir/job-errors.ts
6
- var jobErrors = {
7
- "1": "cancelled",
8
- "2": "timeout",
9
- "3": "request or response too large to encode",
10
- "4": "malformed response",
11
- "5": "network error or server restarted",
12
- "6": "TLS error",
13
- "7": "no free request slot",
14
- "10000": "HTTP status: 10000 + status code"
6
+ var jobError = {
7
+ cancelled: 1,
8
+ timeout: 2,
9
+ tooLarge: 3,
10
+ malformedResponse: 4,
11
+ network: 5,
12
+ tls: 6,
13
+ noRequestSlot: 7
15
14
  };
16
15
  var httpErrors = { base: 1e4, last: 10999 };
16
+ var jobErrors = {
17
+ [jobError.cancelled]: "cancelled",
18
+ [jobError.timeout]: "timeout",
19
+ [jobError.tooLarge]: "request or response too large to encode",
20
+ [jobError.malformedResponse]: "malformed response",
21
+ [jobError.network]: "network error or server restarted",
22
+ [jobError.tls]: "TLS error",
23
+ [jobError.noRequestSlot]: "no free request slot",
24
+ [httpErrors.base]: "HTTP status: 10000 + status code"
25
+ };
17
26
  var errorName = (code) => {
18
27
  if (code > httpErrors.base && code <= httpErrors.last) {
19
28
  return `HTTP ${code - httpErrors.base}`;
@@ -97,5 +106,5 @@ export {
97
106
  telemetry
98
107
  };
99
108
 
100
- //# debugId=80AC1E2249312EFF64756E2164756E21
109
+ //# debugId=B79F687B98CD337A64756E2164756E21
101
110
  //# sourceMappingURL=telemetry.js.map
@@ -3,10 +3,10 @@
3
3
  "sources": ["../stdlib/telemetry.ts", "../src/ir/job-errors.ts", "../stdlib/clock.ts"],
4
4
  "sourcesContent": [
5
5
  "import { relative } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { errorName } from \"../src/ir/job-errors.ts\";\nimport { now } from \"./clock.ts\";\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 exceptionName = (error: unknown) => {\n\tif (typeof error === \"number\") {\n\t\treturn errorName(error);\n\t}\n\treturn error instanceof Error ? error.message : String(error);\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: now(),\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 = typeof error === \"number\" ? error : 0;\n\t\tconst name = exceptionName(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, as every generated async block and service call reports them. */\nexport const jobErrors: Record<string, string> = {\n\t\"1\": \"cancelled\",\n\t\"2\": \"timeout\",\n\t\"3\": \"request or response too large to encode\",\n\t\"4\": \"malformed response\",\n\t\"5\": \"network error or server restarted\",\n\t\"6\": \"TLS error\",\n\t\"7\": \"no free request slot\",\n\t\"10000\": \"HTTP status: 10000 + status code\",\n};\n\n/** An HTTP response fails a job with `base` + its status, up to `last`. */\nexport const httpErrors = { base: 10000, last: 10999 };\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 code < httpErrors.base ? jobErrors[code] : undefined;\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} as const;\n\n/** An HTTP response fails a job with `base` + its status, up to `last`. */\nexport const httpErrors = { base: 10000, last: 10999 };\n\n/** Job error codes, as every generated async block and service call reports them. */\nexport const jobErrors: Record<string, 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[httpErrors.base]: \"HTTP status: 10000 + 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 code < httpErrors.base ? jobErrors[code] : undefined;\n};\n",
7
7
  "/** Milliseconds since the process started, as the PLC's `now()` counts them; used when a program runs under Bun. */\nexport const now = (): number => Math.floor(performance.now());\n"
8
8
  ],
9
- "mappings": ";AAAA;AACA;;;ACAO,IAAM,YAAoC;AAAA,EAChD,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,SAAS;AACV;AAGO,IAAM,aAAa,EAAE,MAAM,KAAO,MAAM,MAAM;AAG9C,IAAM,YAAY,CAAC,SAAqC;AAAA,EAC9D,IAAI,OAAO,WAAW,QAAQ,QAAQ,WAAW,MAAM;AAAA,IACtD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