xbintsc 0.5.52 → 0.6.8

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 (156) hide show
  1. package/README.md +8 -2
  2. package/README.zh-CN.md +9 -3
  3. package/dist/scripts/fetch-tarball.d.ts +28 -0
  4. package/dist/scripts/fetch-tarball.js +57 -0
  5. package/dist/scripts/fetch-tarball.js.map +1 -0
  6. package/dist/scripts/gui-build-options.d.ts +77 -0
  7. package/dist/scripts/gui-build-options.js +134 -0
  8. package/dist/scripts/gui-build-options.js.map +1 -0
  9. package/dist/src/cli/help.d.ts +1 -1
  10. package/dist/src/cli/hints.d.ts +6 -2
  11. package/dist/src/cli/hints.js +16 -2
  12. package/dist/src/cli/hints.js.map +1 -1
  13. package/dist/src/cli/main.js +9 -0
  14. package/dist/src/cli/main.js.map +1 -1
  15. package/dist/src/driver/app-artifacts.d.ts +2 -0
  16. package/dist/src/driver/app-artifacts.js +3 -3
  17. package/dist/src/driver/app-artifacts.js.map +1 -1
  18. package/dist/src/driver/compiler.js +147 -52
  19. package/dist/src/driver/compiler.js.map +1 -1
  20. package/dist/src/driver/icon.d.ts +1 -1
  21. package/dist/src/driver/icon.js +3 -3
  22. package/dist/src/driver/icon.js.map +1 -1
  23. package/dist/src/driver/macos-sdk.d.ts +32 -0
  24. package/dist/src/driver/macos-sdk.js +50 -0
  25. package/dist/src/driver/macos-sdk.js.map +1 -0
  26. package/dist/src/driver/options.d.ts +6 -0
  27. package/dist/src/driver/platform-support.d.ts +45 -0
  28. package/dist/src/driver/platform-support.js +66 -0
  29. package/dist/src/driver/platform-support.js.map +1 -0
  30. package/dist/src/driver/prebuilt.d.ts +26 -0
  31. package/dist/src/driver/prebuilt.js +58 -0
  32. package/dist/src/driver/prebuilt.js.map +1 -0
  33. package/dist/src/driver/runtime-objects.d.ts +11 -0
  34. package/dist/src/driver/runtime-objects.js +14 -5
  35. package/dist/src/driver/runtime-objects.js.map +1 -1
  36. package/dist/src/driver/toolchain-provider.d.ts +8 -0
  37. package/dist/src/driver/toolchain-provider.js +8 -0
  38. package/dist/src/driver/toolchain-provider.js.map +1 -1
  39. package/dist/src/driver/toolchain.d.ts +20 -1
  40. package/dist/src/driver/toolchain.js +19 -0
  41. package/dist/src/driver/toolchain.js.map +1 -1
  42. package/dist/src/driver/version.d.ts +1 -1
  43. package/dist/src/driver/version.js +1 -1
  44. package/dist/src/driver/version.js.map +1 -1
  45. package/dist/src/driver/win-entry.d.ts +1 -1
  46. package/dist/src/driver/win-entry.js +4 -4
  47. package/dist/src/driver/win-entry.js.map +1 -1
  48. package/dist/src/extensions/gui/html.d.ts +10 -7
  49. package/dist/src/extensions/gui/html.js +53 -29
  50. package/dist/src/extensions/gui/html.js.map +1 -1
  51. package/dist/src/extensions/node/child_process/index.d.ts +4 -3
  52. package/dist/src/extensions/node/child_process/index.js +4 -3
  53. package/dist/src/extensions/node/child_process/index.js.map +1 -1
  54. package/dist/tests/cli/hints.test.js +9 -1
  55. package/dist/tests/cli/hints.test.js.map +1 -1
  56. package/dist/tests/cli/main.test.js +9 -0
  57. package/dist/tests/cli/main.test.js.map +1 -1
  58. package/dist/tests/driver/compiler.test.js +107 -0
  59. package/dist/tests/driver/compiler.test.js.map +1 -1
  60. package/dist/tests/driver/cxx-compile-flags.test.d.ts +1 -0
  61. package/dist/tests/driver/cxx-compile-flags.test.js +24 -0
  62. package/dist/tests/driver/cxx-compile-flags.test.js.map +1 -0
  63. package/dist/tests/driver/macos-sdk.test.d.ts +1 -0
  64. package/dist/tests/driver/macos-sdk.test.js +83 -0
  65. package/dist/tests/driver/macos-sdk.test.js.map +1 -0
  66. package/dist/tests/driver/platform-support.test.d.ts +1 -0
  67. package/dist/tests/driver/platform-support.test.js +41 -0
  68. package/dist/tests/driver/platform-support.test.js.map +1 -0
  69. package/dist/tests/driver/prebuilt.test.d.ts +1 -0
  70. package/dist/tests/driver/prebuilt.test.js +44 -0
  71. package/dist/tests/driver/prebuilt.test.js.map +1 -0
  72. package/dist/tests/driver/toolchain-provider.test.js +24 -0
  73. package/dist/tests/driver/toolchain-provider.test.js.map +1 -1
  74. package/dist/tests/driver/toolchain.test.js +23 -0
  75. package/dist/tests/driver/toolchain.test.js.map +1 -1
  76. package/dist/tests/e2e/async-await.test.js +4 -2
  77. package/dist/tests/e2e/async-await.test.js.map +1 -1
  78. package/dist/tests/e2e/compile-node.test.js +21 -0
  79. package/dist/tests/e2e/compile-node.test.js.map +1 -1
  80. package/dist/tests/e2e/fetch.test.js +34 -6
  81. package/dist/tests/e2e/fetch.test.js.map +1 -1
  82. package/dist/tests/e2e/gui-example-pelican3d.test.d.ts +10 -0
  83. package/dist/tests/e2e/gui-example-pelican3d.test.js +94 -0
  84. package/dist/tests/e2e/gui-example-pelican3d.test.js.map +1 -0
  85. package/dist/tests/e2e/gui-script.test.js +48 -0
  86. package/dist/tests/e2e/gui-script.test.js.map +1 -1
  87. package/dist/tests/e2e/unhandled-rejection.test.d.ts +14 -0
  88. package/dist/tests/e2e/unhandled-rejection.test.js +107 -0
  89. package/dist/tests/e2e/unhandled-rejection.test.js.map +1 -0
  90. package/dist/tests/extensions/gui.test.js +44 -0
  91. package/dist/tests/extensions/gui.test.js.map +1 -1
  92. package/dist/tests/scripts/fetch-tarball.test.d.ts +1 -0
  93. package/dist/tests/scripts/fetch-tarball.test.js +70 -0
  94. package/dist/tests/scripts/fetch-tarball.test.js.map +1 -0
  95. package/doc/ai/cli.md +6 -0
  96. package/doc/ai/language-support.md +1 -0
  97. package/doc/ai/troubleshooting.md +32 -2
  98. package/doc/ai/zh-CN/cli.md +5 -0
  99. package/doc/ai/zh-CN/language-support.md +1 -0
  100. package/doc/ai/zh-CN/troubleshooting.md +27 -2
  101. package/doc/gui/build.md +7 -3
  102. package/doc/gui/dom.md +3 -1
  103. package/doc/gui/webgl.md +4 -0
  104. package/doc/gui-scripts.md +33 -17
  105. package/doc/gui.md +17 -1
  106. package/doc/implemented/async.md +1 -0
  107. package/doc/implemented/modules.md +9 -6
  108. package/doc/implemented/node/child-process.md +12 -4
  109. package/doc/implemented/runtime-core.md +1 -1
  110. package/doc/npm-package.md +23 -2
  111. package/doc/post/make-js-great-again.md +30 -0
  112. package/doc/requirements.md +31 -0
  113. package/doc/unimplemented/deviations.md +1 -0
  114. package/doc/zh-CN/gui/build.md +4 -2
  115. package/doc/zh-CN/gui/dom.md +3 -1
  116. package/doc/zh-CN/gui/webgl.md +1 -0
  117. package/doc/zh-CN/gui-scripts.md +23 -11
  118. package/doc/zh-CN/gui.md +11 -1
  119. package/doc/zh-CN/implemented/async.md +1 -0
  120. package/doc/zh-CN/implemented/modules.md +8 -4
  121. package/doc/zh-CN/implemented/node/child-process.md +10 -3
  122. package/doc/zh-CN/implemented/runtime-core.md +1 -1
  123. package/doc/zh-CN/npm-package.md +18 -1
  124. package/doc/zh-CN/post/make-js-great-again.md +32 -0
  125. package/doc/zh-CN/requirements.md +25 -0
  126. package/doc/zh-CN/unimplemented/deviations.md +1 -0
  127. package/package.json +7 -7
  128. package/runtime/ext_node/child_process/child_process.c +149 -7
  129. package/runtime/rt.h +4 -0
  130. package/runtime/xt_async.c +4 -0
  131. package/runtime/xt_generator.c +2 -0
  132. package/runtime/xt_loop.c +8 -4
  133. package/runtime/xt_promise.c +103 -0
  134. package/scripts/build-gui.ts +17 -5
  135. package/scripts/build-media.ts +89 -10
  136. package/scripts/build-runtime.ts +7 -2
  137. package/scripts/fetch-tarball.ts +71 -0
  138. package/scripts/gui-build-cache.ts +28 -0
  139. package/scripts/gui-build-options.ts +26 -2
  140. package/scripts/package-release.ts +8 -0
  141. package/src/cli/hints.ts +19 -2
  142. package/src/cli/main.ts +11 -0
  143. package/src/driver/app-artifacts.ts +5 -3
  144. package/src/driver/compiler.ts +167 -56
  145. package/src/driver/icon.ts +3 -2
  146. package/src/driver/macos-sdk.ts +52 -0
  147. package/src/driver/options.ts +6 -0
  148. package/src/driver/platform-support.ts +69 -0
  149. package/src/driver/prebuilt.ts +61 -0
  150. package/src/driver/runtime-objects.ts +26 -5
  151. package/src/driver/toolchain-provider.ts +11 -0
  152. package/src/driver/toolchain.ts +26 -1
  153. package/src/driver/version.ts +1 -1
  154. package/src/driver/win-entry.ts +4 -3
  155. package/src/extensions/gui/html.ts +61 -31
  156. package/src/extensions/node/child_process/index.ts +4 -3
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Detecting a prebuilt runtime archive that this machine's toolchain cannot
3
+ * link.
4
+ *
5
+ * The optional `@xbintsc/<os>-<arch>` package carries archives compiled on the
6
+ * release runner (`core.a`, `ext_node.a`, `gui.a`, `media.a`). Its Xcode
7
+ * Command Line Tools or Visual Studio C++ toolset can be **newer** than the
8
+ * one on the machine that runs the build: a linker can then reject the archive
9
+ * with unresolved symbols (`LNK2038`/`LNK2019`, `Undefined symbols`,
10
+ * `undefined reference`) or `was built for newer macOS version`.
11
+ *
12
+ * The driver answers that with one automatic retry that compiles the runtime
13
+ * from the sources shipped in the npm package. Its decision is based on the
14
+ * linker's own output rather than a version comparison, because an archive does
15
+ * not record the toolset that produced it portably: Mach-O objects carry
16
+ * `LC_BUILD_VERSION`, COFF objects do not carry an MSVC toolset version.
17
+ *
18
+ * `gui.a`/`media.a` are exempt: they bundle SDL3/FFmpeg/glslang, whose sources
19
+ * are not part of the npm package, so they cannot be rebuilt from it.
20
+ */
21
+ import { dirname, resolve } from "node:path";
22
+ const ARCHIVE_SUFFIXES = [".a", ".lib"];
23
+ /** True when `candidate` is a static archive that sits in one of `dirs`. */
24
+ export function isPrebuiltArchivePath(candidate, dirs) {
25
+ if (!ARCHIVE_SUFFIXES.some((suffix) => candidate.endsWith(suffix)))
26
+ return false;
27
+ const parent = dirname(resolve(candidate));
28
+ return dirs.some((dir) => resolve(dir) === parent);
29
+ }
30
+ /**
31
+ * Linker messages that mean "these objects were produced by a different
32
+ * toolchain/SDK". Kept deliberately narrow: a missing file, a bad flag or a
33
+ * permission error must not trigger the (slow) source rebuild.
34
+ */
35
+ const MISMATCH_PATTERNS = [
36
+ /LNK2038/i, // mismatch detected for 'RuntimeLibrary'/'_MSC_VER'
37
+ /LNK20(?:01|19)/i, // unresolved external symbol
38
+ /undefined symbols?/i, // ld64
39
+ /undefined reference/i, // GNU/LLD
40
+ /symbol\(s\) not found/i, // ld64 summary line
41
+ /was built for newer (?:macOS|iOS|tvOS|watchOS|visionOS)/i, // ld64 warning
42
+ /but linking in object file built for/i, // ld64 deployment-target error
43
+ /has an incompatible (?:architecture|platform)/i,
44
+ ];
45
+ /** Whether a failed link's stderr looks like a toolchain/archive mismatch. */
46
+ export function looksLikePrebuiltLinkFailure(stderr) {
47
+ return MISMATCH_PATTERNS.some((pattern) => pattern.test(stderr));
48
+ }
49
+ /** First non-empty line of a command's stderr, for a one-line build notice. */
50
+ export function firstFailureLine(stderr) {
51
+ for (const line of stderr.split(/\r?\n/)) {
52
+ const trimmed = line.trim();
53
+ if (trimmed.length > 0)
54
+ return trimmed.length > 160 ? `${trimmed.slice(0, 157)}...` : trimmed;
55
+ }
56
+ return "";
57
+ }
58
+ //# sourceMappingURL=prebuilt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prebuilt.js","sourceRoot":"","sources":["../../../src/driver/prebuilt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,CAAU,CAAC;AAEjD,4EAA4E;AAC5E,MAAM,UAAU,qBAAqB,CAAC,SAAiB,EAAE,IAAuB;IAC9E,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACjF,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,iBAAiB,GAAG;IACxB,UAAU,EAAE,oDAAoD;IAChE,iBAAiB,EAAE,6BAA6B;IAChD,qBAAqB,EAAE,OAAO;IAC9B,sBAAsB,EAAE,UAAU;IAClC,wBAAwB,EAAE,oBAAoB;IAC9C,0DAA0D,EAAE,eAAe;IAC3E,uCAAuC,EAAE,+BAA+B;IACxE,gDAAgD;CACxC,CAAC;AAEX,8EAA8E;AAC9E,MAAM,UAAU,4BAA4B,CAAC,MAAc;IACzD,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;IAChG,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -17,6 +17,12 @@ export interface RuntimeObjects {
17
17
  readonly featureObjects: readonly string[];
18
18
  /** Pre-built C++/Rust objects and archives contributed by native extensions. */
19
19
  readonly nativeObjects: readonly string[];
20
+ /**
21
+ * The prebuilt `core`/`ext_<name>` archives this link used. Empty when the
22
+ * runtime was compiled from source. The driver retries a failed link without
23
+ * them, so it has to know whether the first attempt used any.
24
+ */
25
+ readonly prebuiltArchives: readonly string[];
20
26
  }
21
27
  export interface RuntimeObjectsOptions {
22
28
  readonly runner: Runner;
@@ -26,11 +32,16 @@ export interface RuntimeObjectsOptions {
26
32
  readonly registry: ExtensionRegistry;
27
33
  readonly preferPrebuilt: boolean;
28
34
  readonly env: Record<string, string>;
35
+ /** macOS SDK for `-isysroot`; part of the object cache key. */
36
+ readonly sdkRoot?: string;
29
37
  readonly lto: boolean;
30
38
  readonly pgo: PgoMode | undefined;
31
39
  readonly pgoDir: string;
32
40
  /** Optional link features selected for this program. */
33
41
  readonly features?: readonly ResolvedLinkFeature[];
42
+ /** Override the folders searched for prebuilt archives (defaults to the
43
+ * runtime's `lib/<os>-<arch>` plus the installed platform package). */
44
+ readonly runtimeLibDirs?: readonly string[];
34
45
  }
35
46
  /**
36
47
  * Compile the core runtime and every extension source, reusing cached object
@@ -9,7 +9,7 @@ import { existsSync, readFileSync, readdirSync } from "node:fs";
9
9
  import { basename, join, resolve } from "node:path";
10
10
  import { hashParts } from "./cache.js";
11
11
  import { findRuntimeLibrary } from "./runtime-lib.js";
12
- import { compileC, optimizationFlags, RUNTIME_CFLAGS } from "./toolchain.js";
12
+ import { compileC, optimizationFlags, RUNTIME_CFLAGS, sysrootFlags } from "./toolchain.js";
13
13
  import { COMPILER_VERSION } from "./version.js";
14
14
  /** Core runtime translation units (each compiled and cached independently). */
15
15
  export const RUNTIME_SOURCES = [
@@ -50,6 +50,9 @@ export const RUNTIME_SOURCES = [
50
50
  export function ensureRuntimeObjects(options) {
51
51
  const { runner, clang, runtimeDir, cacheDir, registry, preferPrebuilt, env, lto, pgo, pgoDir } = options;
52
52
  const optimization = optimizationFlags(lto, pgo, pgoDir);
53
+ /* The sysroot joins the extra flags (and therefore the cache key): objects
54
+ compiled against a different SDK are a different artifact. */
55
+ const compileFlags = [...optimization, ...sysrootFlags(options.sdkRoot)];
53
56
  /* Runtime objects depend on the shared headers (rt.h/rt_internal.h/...) and
54
57
  the `#include`d implementation fragments (`.inc`), so any change to them
55
58
  must invalidate every cached object. Hash them all. */
@@ -71,7 +74,7 @@ export function ensureRuntimeObjects(options) {
71
74
  "runtime",
72
75
  COMPILER_VERSION,
73
76
  RUNTIME_CFLAGS.join(" "),
74
- optimization.join(" "),
77
+ compileFlags.join(" "),
75
78
  tag,
76
79
  headerStamp,
77
80
  body,
@@ -80,23 +83,28 @@ export function ensureRuntimeObjects(options) {
80
83
  ]);
81
84
  const objectPath = join(cacheDir, `${tag}-${key}.o`);
82
85
  if (!existsSync(objectPath)) {
83
- compileC(runner, clang, sourcePath, objectPath, runtimeDir, env, optimization);
86
+ compileC(runner, clang, sourcePath, objectPath, runtimeDir, env, compileFlags);
84
87
  }
85
88
  return objectPath;
86
89
  };
87
- const coreArchive = preferPrebuilt ? findRuntimeLibrary("core") : undefined;
90
+ const coreArchive = preferPrebuilt ? findRuntimeLibrary("core", options.runtimeLibDirs) : undefined;
88
91
  const runtimeObjects = coreArchive
89
92
  ? [coreArchive]
90
93
  : RUNTIME_SOURCES.map((source) => compileOne(join(runtimeDir, source), basename(source, ".c")));
94
+ /** Prebuilt archives this link uses; the driver retries without them. */
95
+ const prebuiltArchives = coreArchive ? [coreArchive] : [];
91
96
  const extensionObjects = [];
92
97
  const seen = new Set();
93
98
  for (const extension of registry.all()) {
94
99
  const sources = extension.runtimeSources ? extension.runtimeSources() : [];
95
100
  if (sources.length === 0)
96
101
  continue;
97
- const archive = preferPrebuilt ? findRuntimeLibrary(`ext_${extension.name}`) : undefined;
102
+ const archive = preferPrebuilt
103
+ ? findRuntimeLibrary(`ext_${extension.name}`, options.runtimeLibDirs)
104
+ : undefined;
98
105
  if (archive) {
99
106
  extensionObjects.push(archive);
107
+ prebuiltArchives.push(archive);
100
108
  continue;
101
109
  }
102
110
  for (const sourcePath of sources) {
@@ -127,6 +135,7 @@ export function ensureRuntimeObjects(options) {
127
135
  extensionObjects,
128
136
  featureObjects: [...new Set(featureObjects)],
129
137
  nativeObjects: [...new Set(registry.nativeObjects())],
138
+ prebuiltArchives,
130
139
  };
131
140
  }
132
141
  //# sourceMappingURL=runtime-objects.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-objects.js","sourceRoot":"","sources":["../../../src/driver/runtime-objects.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,cAAc,EAA6B,MAAM,gBAAgB,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY;IACZ,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,WAAW;IACX,kBAAkB;IAClB,aAAa;IACb,cAAc;IACd,cAAc;IACd,YAAY;IACZ,WAAW;IACX,eAAe;IACf,gBAAgB;IAChB,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,eAAe;IACf,mBAAmB;IACnB,uBAAuB;IACvB,kBAAkB;IAClB,iBAAiB;IACjB,UAAU;IACV,iBAAiB;IACjB,mBAAmB;IACnB,SAAS;CACD,CAAC;AA0BX;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACzG,MAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;I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AC,SAAS,CAAC,CAAC;YACpB,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,gBAAgB,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAChH,CAAC;IACH,CAAC;IACD,uEAAuE;IACvE,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;QAC7C;;uCAE+B;QAC/B,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAChD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;YACtC,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;gBAAE,SAAS;YAClC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACpB,gBAAgB,CAAC,IAAI,CACnB,UAAU,CAAC,UAAU,EAAE,WAAW,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAChF,CAAC;QACJ,CAAC;QACD,cAAc,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAChD,CAAC;IACD,OAAO;QACL,cAAc;QACd,gBAAgB;QAChB,cAAc,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5C,aAAa,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;QACrD,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
@@ -22,6 +22,11 @@
22
22
  * skipped (or rejected, when named explicitly) instead of producing objects
23
23
  * the linker cannot mix.
24
24
  *
25
+ * On macOS the resolved driver also carries the SDK as `sdkRoot`, which the
26
+ * compile and link steps pass as `-isysroot` (see `macos-sdk.ts`): an Apple
27
+ * clang invoked by absolute path does not infer the SDK by itself, and without
28
+ * one not even `<stdio.h>` — nor the linker's `libm` stub — is found.
29
+ *
25
30
  * Extra linker arguments (for example `-fuse-ld=lld`) can be supplied through
26
31
  * `xbintsc_LINKER_ARGS`.
27
32
  */
@@ -39,6 +44,9 @@ export interface ResolvedToolchain {
39
44
  /** Extra environment for the toolchain subprocesses, merged over the current
40
45
  * environment. */
41
46
  readonly env: Record<string, string>;
47
+ /** macOS SDK to pass as `-isysroot`; lost off macOS or when `SDKROOT` is
48
+ * already set. See `macos-sdk.ts`. */
49
+ readonly sdkRoot?: string;
42
50
  }
43
51
  /** Resolve the toolchain that `build` should use. See the module docblock. */
44
52
  export declare function resolveToolchain(runner?: Runner): ResolvedToolchain;
@@ -22,10 +22,16 @@
22
22
  * skipped (or rejected, when named explicitly) instead of producing objects
23
23
  * the linker cannot mix.
24
24
  *
25
+ * On macOS the resolved driver also carries the SDK as `sdkRoot`, which the
26
+ * compile and link steps pass as `-isysroot` (see `macos-sdk.ts`): an Apple
27
+ * clang invoked by absolute path does not infer the SDK by itself, and without
28
+ * one not even `<stdio.h>` — nor the linker's `libm` stub — is found.
29
+ *
25
30
  * Extra linker arguments (for example `-fuse-ld=lld`) can be supplied through
26
31
  * `xbintsc_LINKER_ARGS`.
27
32
  */
28
33
  import { locateClang, realRunner } from "./toolchain.js";
34
+ import { macosSdkRoot } from "./macos-sdk.js";
29
35
  function linkerArgs(fallback) {
30
36
  const raw = process.env.xbintsc_LINKER_ARGS;
31
37
  if (raw)
@@ -35,12 +41,14 @@ function linkerArgs(fallback) {
35
41
  /** Resolve the toolchain that `build` should use. See the module docblock. */
36
42
  export function resolveToolchain(runner = realRunner) {
37
43
  const location = locateClang(runner);
44
+ const sdkRoot = macosSdkRoot(runner);
38
45
  return {
39
46
  clang: location.command,
40
47
  source: location.source,
41
48
  ...(location.version ? { version: location.version } : {}),
42
49
  linkerArgs: linkerArgs([]),
43
50
  env: {},
51
+ ...(sdkRoot === undefined ? {} : { sdkRoot }),
44
52
  };
45
53
  }
46
54
  //# sourceMappingURL=toolchain-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolchain-provider.js","sourceRoot":"","sources":["../../../src/driver/toolchain-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAkC,MAAM,gBAAgB,CAAC;AAkBzF,SAAS,UAAU,CAAC,QAA2B;IAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAC5C,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACvB,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,gBAAgB,CAAC,SAAiB,UAAU;IAC1D,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,OAAO;QACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC;QAC1B,GAAG,EAAE,EAAE;KACR,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"toolchain-provider.js","sourceRoot":"","sources":["../../../src/driver/toolchain-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAkC,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAqB9C,SAAS,UAAU,CAAC,QAA2B;IAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAC5C,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACvB,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,gBAAgB,CAAC,SAAiB,UAAU;IAC1D,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACrC,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,OAAO;QACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC;QAC1B,GAAG,EAAE,EAAE;QACP,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;KAC9C,CAAC;AACJ,CAAC"}
@@ -90,12 +90,22 @@ export declare function findClang(runner?: Runner): string;
90
90
  export type PgoMode = "generate" | "use";
91
91
  /** clang flags for LTO and the selected PGO stage. */
92
92
  export declare function optimizationFlags(lto: boolean | undefined, pgo: PgoMode | undefined, pgoDir: string | undefined): string[];
93
+ /**
94
+ * `-isysroot` for a resolved macOS SDK, or nothing off macOS.
95
+ *
96
+ * The sysroot travels on the command line and not as `SDKROOT` in the
97
+ * environment because the self-hosted compiler's `spawnSync` ignores
98
+ * `options.env`; flags survive that. See `macos-sdk.ts`.
99
+ */
100
+ export declare function sysrootFlags(sdkRoot: string | undefined): string[];
93
101
  export interface CompileIrOptions {
94
102
  readonly clang: string;
95
103
  readonly irPath: string;
96
104
  readonly objectPath: string;
97
105
  readonly optimize: string;
98
106
  readonly env?: Record<string, string>;
107
+ /** macOS SDK for `-isysroot`; see {@link sysrootFlags}. */
108
+ readonly sdkRoot?: string;
99
109
  /** Emit debug info (`-g`) and keep frame pointers for crash backtraces. */
100
110
  readonly debug?: boolean;
101
111
  /** Compile to LTO bitcode and let the linker optimize across units. */
@@ -113,11 +123,20 @@ export interface LinkOptions {
113
123
  readonly linkerFlags: readonly string[];
114
124
  readonly optimize: string;
115
125
  readonly env?: Record<string, string>;
126
+ /** macOS SDK for `-isysroot`; the linker's stubs (`libm`, `libSystem`) come
127
+ * from it, so a link without one fails with `library 'm' not found`. */
128
+ readonly sdkRoot?: string;
116
129
  readonly lto?: boolean;
117
130
  readonly pgo?: PgoMode;
118
131
  readonly pgoDir?: string;
119
132
  }
120
- export declare function link(runner: Runner, options: LinkOptions): void;
133
+ /**
134
+ * Link the program and return the command result. A successful link can still
135
+ * carry a warning (for example ld64's "object file was built for newer macOS
136
+ * version"); the driver inspects `stderr` to decide whether a prebuilt archive
137
+ * should be rebuilt from source.
138
+ */
139
+ export declare function link(runner: Runner, options: LinkOptions): CommandResult;
121
140
  /**
122
141
  * Flags shared by every runtime/extension C compile. Exported so the object
123
142
  * cache key can change when they do: the cache is keyed by source content, and
@@ -224,6 +224,16 @@ export function optimizationFlags(lto, pgo, pgoDir) {
224
224
  flags.push(`-fprofile-use=${pgoDir ?? "pgo"}`);
225
225
  return flags;
226
226
  }
227
+ /**
228
+ * `-isysroot` for a resolved macOS SDK, or nothing off macOS.
229
+ *
230
+ * The sysroot travels on the command line and not as `SDKROOT` in the
231
+ * environment because the self-hosted compiler's `spawnSync` ignores
232
+ * `options.env`; flags survive that. See `macos-sdk.ts`.
233
+ */
234
+ export function sysrootFlags(sdkRoot) {
235
+ return sdkRoot === undefined ? [] : ["-isysroot", sdkRoot];
236
+ }
227
237
  /**
228
238
  * One function/data item per section so the linker can drop everything a
229
239
  * program never references. This is what `--gc-sections` / `-dead_strip` need;
@@ -239,6 +249,7 @@ export function compileIr(runner, options) {
239
249
  ...SECTION_FLAGS,
240
250
  ...debugFlags,
241
251
  ...profileFlags,
252
+ ...sysrootFlags(options.sdkRoot),
242
253
  "-c",
243
254
  options.irPath,
244
255
  "-o",
@@ -255,6 +266,12 @@ function deadStripFlag() {
255
266
  return ["-Wl,-dead_strip"];
256
267
  return ["-Wl,--gc-sections"];
257
268
  }
269
+ /**
270
+ * Link the program and return the command result. A successful link can still
271
+ * carry a warning (for example ld64's "object file was built for newer macOS
272
+ * version"); the driver inspects `stderr` to decide whether a prebuilt archive
273
+ * should be rebuilt from source.
274
+ */
258
275
  export function link(runner, options) {
259
276
  const profileFlags = optimizationFlags(options.lto, options.pgo, options.pgoDir);
260
277
  const args = [
@@ -264,6 +281,7 @@ export function link(runner, options) {
264
281
  * understands both ELF/Mach-O and COFF; without it MSVC link.exe rejects
265
282
  * the bitcode object on Windows. */
266
283
  ...(options.lto ? ["-fuse-ld=lld"] : []),
284
+ ...sysrootFlags(options.sdkRoot),
267
285
  ...options.objectPaths,
268
286
  "-o",
269
287
  options.outputPath,
@@ -273,6 +291,7 @@ export function link(runner, options) {
273
291
  const result = runner.run(options.clang, args, { env: options.env });
274
292
  if (result.status !== 0)
275
293
  throw new ToolchainError(`${options.clang} link`, result.status, result.stderr);
294
+ return result;
276
295
  }
277
296
  /**
278
297
  * Flags shared by every runtime/extension C compile. Exported so the object
@@ -1 +1 @@
1
- {"version":3,"file":"toolchain.js","sourceRoot":"","sources":["../../../src/driver/toolchain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,M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,CAAC,CAAC;IAC9F,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,cAAc,CACtB,GAAG,IAAI,QAAQ,EACf,MAAM,CAAC,MAAM,EACb,GAAG,MAAM,CAAC,MAAM,oEAAoE,CACrF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -9,4 +9,4 @@
9
9
  * `main`/`master` only (see `.githooks/pre-commit`), so feature branches never
10
10
  * change this line and merging two of them cannot conflict here.
11
11
  */
12
- export declare const COMPILER_VERSION = "0.5.52";
12
+ export declare const COMPILER_VERSION = "0.6.8";
@@ -9,5 +9,5 @@
9
9
  * `main`/`master` only (see `.githooks/pre-commit`), so feature branches never
10
10
  * change this line and merging two of them cannot conflict here.
11
11
  */
12
- export const COMPILER_VERSION = "0.5.52";
12
+ export const COMPILER_VERSION = "0.6.8";
13
13
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/driver/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/driver/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC"}
@@ -18,4 +18,4 @@ export declare const WINDOWS_ENTRY_SOURCE = "/* Generated by xbintsc - Windows G
18
18
  * Compile the entry shim into an object file (cached by source + platform +
19
19
  * toolchain) and return its path.
20
20
  */
21
- export declare function ensureWindowsEntryObject(runner: Runner, clang: string, cacheDir: string, env?: Record<string, string>): string;
21
+ export declare function ensureWindowsEntryObject(runner: Runner, clang: string, cacheDir: string, env?: Record<string, string>, sdkRoot?: string): string;
@@ -14,7 +14,7 @@
14
14
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
15
15
  import { join } from "node:path";
16
16
  import { hashParts } from "./cache.js";
17
- import { compileC } from "./toolchain.js";
17
+ import { compileC, sysrootFlags } from "./toolchain.js";
18
18
  /** The bridge source. `main` is the entry point the runtime emits. */
19
19
  export const WINDOWS_ENTRY_SOURCE = `/* Generated by xbintsc - Windows GUI subsystem entry point. Do not edit. */
20
20
  #ifndef UNICODE
@@ -38,14 +38,14 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR command_line, i
38
38
  * Compile the entry shim into an object file (cached by source + platform +
39
39
  * toolchain) and return its path.
40
40
  */
41
- export function ensureWindowsEntryObject(runner, clang, cacheDir, env) {
42
- const key = hashParts(["win-gui-entry", process.platform, clang, WINDOWS_ENTRY_SOURCE]);
41
+ export function ensureWindowsEntryObject(runner, clang, cacheDir, env, sdkRoot) {
42
+ const key = hashParts(["win-gui-entry", process.platform, clang, sdkRoot ?? "", WINDOWS_ENTRY_SOURCE]);
43
43
  const sourcePath = join(cacheDir, `winentry-${key}.c`);
44
44
  const objectPath = join(cacheDir, `winentry-${key}.o`);
45
45
  if (!existsSync(objectPath)) {
46
46
  mkdirSync(cacheDir, { recursive: true });
47
47
  writeFileSync(sourcePath, WINDOWS_ENTRY_SOURCE);
48
- compileC(runner, clang, sourcePath, objectPath, cacheDir, env);
48
+ compileC(runner, clang, sourcePath, objectPath, cacheDir, env, sysrootFlags(sdkRoot));
49
49
  }
50
50
  return objectPath;
51
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"win-entry.js","sourceRoot":"","sources":["../../../src/driver/win-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAe,MAAM,gBAAgB,CAAC;AAEvD,sEAAsE;AACtE,MAAM,CAAC,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b,QAAgB,EAChB,GAA4B,EAC5B,OAAgB;IAEhB,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,eAAe,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,IAAI,EAAE,EAAE,oBAAoB,CAAC,CAAC,CAAC;IACvG,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,aAAa,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;QAChD,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -12,13 +12,16 @@
12
12
  * This is how xbintsc supports `<script>` without a JavaScript engine: the body
13
13
  * is ordinary TypeScript compiled by the existing front end, ahead of time.
14
14
  *
15
- * Inline `<script lang="ts">body</script>` bodies are wrapped directly. External
16
- * `<script src="./app.ts">` files are read, their top-level `import`/`export
17
- * … from` statements are hoisted to the generated module (with relative
18
- * specifiers rewritten so they resolve from the HTML file), and the remaining
19
- * statements are wrapped in the script function. All scripts run in document
20
- * order after parsing (there is no "eager" execution point), i.e. every script
21
- * is effectively `defer`red.
15
+ * Both forms are compiled the same way: an inline
16
+ * `<script lang="ts">body</script>` body and an external `<script src="./app.ts">`
17
+ * file are parsed as a module, their top-level `import`/`export … from`
18
+ * statements are hoisted to the generated module (with relative specifiers
19
+ * rewritten so they resolve from the HTML file), and the remaining statements
20
+ * are wrapped in the script function. An inline body therefore resolves imports
21
+ * relative to the page that contains it, exactly like `<script type="module">`
22
+ * in a browser — including a `node:`/bare specifier, which links like any other
23
+ * module import. All scripts run in document order after parsing (there is no
24
+ * "eager" execution point), i.e. every script is effectively `defer`red.
22
25
  */
23
26
  import type { AssetLoadResult } from "../registry.js";
24
27
  /** Rewrite `<script>` bodies into registered AOT functions + an HTML string. */
@@ -12,13 +12,16 @@
12
12
  * This is how xbintsc supports `<script>` without a JavaScript engine: the body
13
13
  * is ordinary TypeScript compiled by the existing front end, ahead of time.
14
14
  *
15
- * Inline `<script lang="ts">body</script>` bodies are wrapped directly. External
16
- * `<script src="./app.ts">` files are read, their top-level `import`/`export
17
- * … from` statements are hoisted to the generated module (with relative
18
- * specifiers rewritten so they resolve from the HTML file), and the remaining
19
- * statements are wrapped in the script function. All scripts run in document
20
- * order after parsing (there is no "eager" execution point), i.e. every script
21
- * is effectively `defer`red.
15
+ * Both forms are compiled the same way: an inline
16
+ * `<script lang="ts">body</script>` body and an external `<script src="./app.ts">`
17
+ * file are parsed as a module, their top-level `import`/`export … from`
18
+ * statements are hoisted to the generated module (with relative specifiers
19
+ * rewritten so they resolve from the HTML file), and the remaining statements
20
+ * are wrapped in the script function. An inline body therefore resolves imports
21
+ * relative to the page that contains it, exactly like `<script type="module">`
22
+ * in a browser — including a `node:`/bare specifier, which links like any other
23
+ * module import. All scripts run in document order after parsing (there is no
24
+ * "eager" execution point), i.e. every script is effectively `defer`red.
22
25
  */
23
26
  import { existsSync, readFileSync } from "node:fs";
24
27
  import { dirname, relative, resolve } from "node:path";
@@ -134,12 +137,13 @@ function deferredPrelude(alias, declaration) {
134
137
  lines.push(`${alias}();`);
135
138
  return lines;
136
139
  }
137
- /** Split an external script module into hoisted imports and a body. */
138
- function compileModuleSource(htmlPath, scriptPath, scriptIndex) {
140
+ /** Split a script module into hoisted imports and a body. */
141
+ function compileModuleSource(htmlPath, scriptPath, scriptSource, scriptIndex) {
139
142
  /* Mask the normalized text: the parser indexes the `SourceFile` text, where
140
143
  * `\r\n` already became `\n`, so blanking statement spans in the raw file
141
- * would remove the wrong characters on a CRLF checkout. */
142
- const source = new SourceFile(scriptPath, readFileSync(scriptPath, "utf8")).text;
144
+ * would remove the wrong characters on a CRLF checkout. An inline body is
145
+ * already normalized (the page was), so this is the identity for it. */
146
+ const source = new SourceFile(scriptPath, scriptSource).text;
143
147
  const bag = new DiagnosticBag();
144
148
  const parsed = new Parser(new SourceFile(scriptPath, source), bag).parseSourceFile();
145
149
  const chars = source.split("");
@@ -242,6 +246,32 @@ export function loadHtmlAsset(path, source) {
242
246
  const lazyImports = [];
243
247
  const importedText = new Set();
244
248
  const bound = new Set();
249
+ /* Every script's hoisted imports live at module scope, so they are collected
250
+ * here and placed in front of the script functions. `element` and `hint` only
251
+ * shape the error for an eager binding claimed by two scripts. */
252
+ const hoistImports = (compiled, element, hint) => {
253
+ for (const text of compiled.imports) {
254
+ if (!importedText.has(text)) {
255
+ importedText.add(text);
256
+ imports.push(text);
257
+ }
258
+ }
259
+ lazyImports.push(...compiled.lazyImports);
260
+ for (const name of compiled.localNames) {
261
+ if (bound.has(name)) {
262
+ throw new Error(`gui: ${element} imports '${name}', already imported by another <script>; ${hint}`);
263
+ }
264
+ bound.add(name);
265
+ }
266
+ };
267
+ const register = (compiled, file) => {
268
+ /* Hash the wrapped body, prelude included: the engine keys the registry by
269
+ * id, so two scripts with the same statements but different deferred
270
+ * imports must not collapse into one entry. */
271
+ const id = hashString([...compiled.prelude, compiled.body].join("\n"));
272
+ scripts.push({ id, body: compiled.body, prelude: compiled.prelude, ...(file ? { file } : {}) });
273
+ return id;
274
+ };
245
275
  /* The engine's cascade only reads `<style>` elements, so a linked stylesheet
246
276
  * would be dropped at runtime. Inline it (and its `@import`s) now. */
247
277
  const styles = inlineStylesheets(path, page);
@@ -254,22 +284,9 @@ export function loadHtmlAsset(path, source) {
254
284
  if (!existsSync(scriptPath)) {
255
285
  throw new Error(`gui: <script src="${src}"> not found (looked for ${scriptPath})`);
256
286
  }
257
- const compiled = compileModuleSource(path, scriptPath, scripts.length);
258
- for (const text of compiled.imports) {
259
- if (!importedText.has(text)) {
260
- importedText.add(text);
261
- imports.push(text);
262
- }
263
- }
264
- lazyImports.push(...compiled.lazyImports);
265
- for (const name of compiled.localNames) {
266
- if (bound.has(name)) {
267
- throw new Error(`gui: <script src="${src}"> imports '${name}', already imported by another <script src>; alias it in ${scriptPath}`);
268
- }
269
- bound.add(name);
270
- }
271
- const id = hashString([...compiled.prelude, compiled.body].join("\n"));
272
- scripts.push({ id, body: compiled.body, prelude: compiled.prelude, file: scriptPath });
287
+ const compiled = compileModuleSource(path, scriptPath, readFileSync(scriptPath, "utf8"), scripts.length);
288
+ hoistImports(compiled, `<script src="${src}">`, `alias it in ${scriptPath}`);
289
+ const id = register(compiled, scriptPath);
273
290
  return `<script data-xt-id="${id}"></script>`;
274
291
  }
275
292
  /* A `src` URL, or a data block: leave the element untouched. */
@@ -277,8 +294,15 @@ export function loadHtmlAsset(path, source) {
277
294
  return match;
278
295
  if (inlineBody.trim() === "")
279
296
  return match;
280
- const id = hashString(inlineBody);
281
- scripts.push({ id, body: inlineBody, prelude: [] });
297
+ /* An inline body is compiled exactly like a `<script src>` file, so an
298
+ * `import` links the same way in both: a bare or `node:` specifier is
299
+ * hoisted to the generated module, a relative one is deferred, and both
300
+ * resolve from the HTML file as a browser module script would. Wrapping the
301
+ * body verbatim used to leave an inline `import` inside the script function,
302
+ * where codegen cannot link its binding (TS5001). */
303
+ const compiled = compileModuleSource(path, path, inlineBody, scripts.length);
304
+ hoistImports(compiled, "inline <script>", "alias it");
305
+ const id = register(compiled);
282
306
  return `<script data-xt-id="${id}"></script>`;
283
307
  });
284
308
  const parts = [...imports, ...lazyImports];