xbintsc 0.3.18 → 0.3.35

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 (194) hide show
  1. package/README.md +33 -0
  2. package/dist/src/cli/main.js +124 -30
  3. package/dist/src/cli/main.js.map +1 -1
  4. package/dist/src/codegen/generator/calls/access.js +8 -1
  5. package/dist/src/codegen/generator/calls/access.js.map +1 -1
  6. package/dist/src/codegen/generator/state.js +20 -0
  7. package/dist/src/codegen/generator/state.js.map +1 -1
  8. package/dist/src/codegen/generator/tables.d.ts +6 -0
  9. package/dist/src/codegen/generator/tables.js +38 -0
  10. package/dist/src/codegen/generator/tables.js.map +1 -1
  11. package/dist/src/driver/bundler/commonjs.d.ts +52 -0
  12. package/dist/src/driver/bundler/commonjs.js +493 -0
  13. package/dist/src/driver/bundler/commonjs.js.map +1 -0
  14. package/dist/src/driver/bundler/graph.d.ts +2 -1
  15. package/dist/src/driver/bundler/graph.js +32 -3
  16. package/dist/src/driver/bundler/graph.js.map +1 -1
  17. package/dist/src/driver/bundler/merge.d.ts +2 -1
  18. package/dist/src/driver/bundler/merge.js +16 -2
  19. package/dist/src/driver/bundler/merge.js.map +1 -1
  20. package/dist/src/driver/bundler/types.d.ts +8 -0
  21. package/dist/src/driver/compiler.d.ts +8 -1
  22. package/dist/src/driver/compiler.js +75 -7
  23. package/dist/src/driver/compiler.js.map +1 -1
  24. package/dist/src/driver/config.d.ts +53 -0
  25. package/dist/src/driver/config.js +141 -0
  26. package/dist/src/driver/config.js.map +1 -0
  27. package/dist/src/driver/icon.d.ts +62 -0
  28. package/dist/src/driver/icon.js +151 -0
  29. package/dist/src/driver/icon.js.map +1 -0
  30. package/dist/src/driver/index.d.ts +4 -0
  31. package/dist/src/driver/index.js +4 -0
  32. package/dist/src/driver/index.js.map +1 -1
  33. package/dist/src/driver/mac-bundle.d.ts +41 -0
  34. package/dist/src/driver/mac-bundle.js +123 -0
  35. package/dist/src/driver/mac-bundle.js.map +1 -0
  36. package/dist/src/driver/win-icon.d.ts +27 -0
  37. package/dist/src/driver/win-icon.js +80 -0
  38. package/dist/src/driver/win-icon.js.map +1 -0
  39. package/dist/src/extensions/gui/html.d.ts +25 -0
  40. package/dist/src/extensions/gui/html.js +203 -0
  41. package/dist/src/extensions/gui/html.js.map +1 -0
  42. package/dist/src/extensions/gui/index.js +11 -0
  43. package/dist/src/extensions/gui/index.js.map +1 -1
  44. package/dist/src/extensions/registry.d.ts +29 -0
  45. package/dist/src/extensions/registry.js +14 -0
  46. package/dist/src/extensions/registry.js.map +1 -1
  47. package/dist/src/index.d.ts +1 -1
  48. package/dist/src/index.js.map +1 -1
  49. package/dist/src/lexer/scanner/identifiers.js +4 -12
  50. package/dist/src/lexer/scanner/identifiers.js.map +1 -1
  51. package/dist/src/parser/statements.js +17 -4
  52. package/dist/src/parser/statements.js.map +1 -1
  53. package/dist/tests/cli/main.test.js +46 -1
  54. package/dist/tests/cli/main.test.js.map +1 -1
  55. package/dist/tests/driver/bundler-resolve.test.d.ts +1 -0
  56. package/dist/tests/driver/bundler-resolve.test.js +230 -0
  57. package/dist/tests/driver/bundler-resolve.test.js.map +1 -0
  58. package/dist/tests/driver/config.test.d.ts +1 -0
  59. package/dist/tests/driver/config.test.js +124 -0
  60. package/dist/tests/driver/config.test.js.map +1 -0
  61. package/dist/tests/driver/icon.test.d.ts +1 -0
  62. package/dist/tests/driver/icon.test.js +421 -0
  63. package/dist/tests/driver/icon.test.js.map +1 -0
  64. package/dist/tests/driver/modules.test.js +177 -0
  65. package/dist/tests/driver/modules.test.js.map +1 -1
  66. package/dist/tests/e2e/fetch.test.d.ts +12 -0
  67. package/dist/tests/e2e/fetch.test.js +272 -0
  68. package/dist/tests/e2e/fetch.test.js.map +1 -0
  69. package/dist/tests/e2e/gui-dom.test.d.ts +5 -0
  70. package/dist/tests/e2e/gui-dom.test.js +102 -0
  71. package/dist/tests/e2e/gui-dom.test.js.map +1 -0
  72. package/dist/tests/e2e/gui-events.test.d.ts +5 -0
  73. package/dist/tests/e2e/gui-events.test.js +60 -0
  74. package/dist/tests/e2e/gui-events.test.js.map +1 -0
  75. package/dist/tests/e2e/gui-helpers.d.ts +31 -0
  76. package/dist/tests/e2e/gui-helpers.js +74 -0
  77. package/dist/tests/e2e/gui-helpers.js.map +1 -0
  78. package/dist/tests/e2e/gui-layout.test.d.ts +4 -0
  79. package/dist/tests/e2e/gui-layout.test.js +88 -0
  80. package/dist/tests/e2e/gui-layout.test.js.map +1 -0
  81. package/dist/tests/e2e/gui-lifecycle.test.d.ts +5 -0
  82. package/dist/tests/e2e/gui-lifecycle.test.js +58 -0
  83. package/dist/tests/e2e/gui-lifecycle.test.js.map +1 -0
  84. package/dist/tests/e2e/gui-paint.test.d.ts +5 -0
  85. package/dist/tests/e2e/gui-paint.test.js +111 -0
  86. package/dist/tests/e2e/gui-paint.test.js.map +1 -0
  87. package/dist/tests/e2e/gui-script.test.d.ts +5 -0
  88. package/dist/tests/e2e/gui-script.test.js +78 -0
  89. package/dist/tests/e2e/gui-script.test.js.map +1 -0
  90. package/dist/tests/e2e/gui-style.test.d.ts +5 -0
  91. package/dist/tests/e2e/gui-style.test.js +175 -0
  92. package/dist/tests/e2e/gui-style.test.js.map +1 -0
  93. package/dist/tests/e2e/icon.test.d.ts +7 -0
  94. package/dist/tests/e2e/icon.test.js +80 -0
  95. package/dist/tests/e2e/icon.test.js.map +1 -0
  96. package/dist/tests/e2e/npm-modules.test.d.ts +4 -1
  97. package/dist/tests/e2e/npm-modules.test.js +47 -1
  98. package/dist/tests/e2e/npm-modules.test.js.map +1 -1
  99. package/dist/tests/e2e/runtime-coverage-typed-array.test.d.ts +9 -0
  100. package/dist/tests/e2e/runtime-coverage-typed-array.test.js +140 -0
  101. package/dist/tests/e2e/runtime-coverage-typed-array.test.js.map +1 -0
  102. package/dist/tests/extensions/gui-index.test.d.ts +1 -0
  103. package/dist/tests/extensions/gui-index.test.js +49 -0
  104. package/dist/tests/extensions/gui-index.test.js.map +1 -0
  105. package/dist/tests/extensions/gui.test.d.ts +1 -0
  106. package/dist/tests/extensions/gui.test.js +177 -0
  107. package/dist/tests/extensions/gui.test.js.map +1 -0
  108. package/dist/tests/extensions/registry.test.js +36 -0
  109. package/dist/tests/extensions/registry.test.js.map +1 -1
  110. package/dist/tests/parser/statements.test.js +11 -0
  111. package/dist/tests/parser/statements.test.js.map +1 -1
  112. package/dist/tests/public-api.test.d.ts +1 -0
  113. package/dist/tests/public-api.test.js +31 -0
  114. package/dist/tests/public-api.test.js.map +1 -0
  115. package/package.json +1 -1
  116. package/runtime/ext_gui/css.cpp +4 -517
  117. package/runtime/ext_gui/css_internal.h +27 -0
  118. package/runtime/ext_gui/css_match.cpp +195 -0
  119. package/runtime/ext_gui/css_selector.cpp +207 -0
  120. package/runtime/ext_gui/css_sheet.cpp +129 -0
  121. package/runtime/ext_gui/document.cpp +90 -0
  122. package/runtime/ext_gui/document.h +23 -0
  123. package/runtime/ext_gui/dom.cpp +43 -403
  124. package/runtime/ext_gui/dom.h +7 -0
  125. package/runtime/ext_gui/dom_api.cpp +164 -0
  126. package/runtime/ext_gui/dom_api.h +12 -0
  127. package/runtime/ext_gui/dom_api_document.cpp +96 -0
  128. package/runtime/ext_gui/dom_api_events.cpp +123 -0
  129. package/runtime/ext_gui/dom_api_internal.h +135 -0
  130. package/runtime/ext_gui/dom_api_node.cpp +329 -0
  131. package/runtime/ext_gui/dom_api_node_read.cpp +294 -0
  132. package/runtime/ext_gui/dom_api_proto.cpp +130 -0
  133. package/runtime/ext_gui/dom_api_style.cpp +192 -0
  134. package/runtime/ext_gui/dom_internal.h +39 -0
  135. package/runtime/ext_gui/dom_parse.cpp +348 -0
  136. package/runtime/ext_gui/dom_serialize.cpp +54 -0
  137. package/runtime/ext_gui/gui.cpp +61 -245
  138. package/runtime/ext_gui/gui_engine.h +54 -0
  139. package/runtime/ext_gui/gui_events.cpp +294 -0
  140. package/runtime/ext_gui/gui_internal.h +29 -0
  141. package/runtime/ext_gui/layout.cpp +6 -597
  142. package/runtime/ext_gui/layout_flex.cpp +200 -0
  143. package/runtime/ext_gui/layout_flow.cpp +191 -0
  144. package/runtime/ext_gui/layout_flow_internal.h +149 -0
  145. package/runtime/ext_gui/layout_inline.cpp +181 -0
  146. package/runtime/ext_gui/layout_internal.h +20 -0
  147. package/runtime/ext_gui/renderer.cpp +15 -679
  148. package/runtime/ext_gui/renderer_image.cpp +233 -0
  149. package/runtime/ext_gui/renderer_internal.h +112 -0
  150. package/runtime/ext_gui/renderer_shaders.h +108 -0
  151. package/runtime/ext_gui/renderer_text.cpp +342 -0
  152. package/runtime/ext_gui/script.cpp +63 -0
  153. package/runtime/ext_gui/style.cpp +12 -660
  154. package/runtime/ext_gui/style_internal.h +33 -0
  155. package/runtime/ext_gui/style_print.cpp +113 -0
  156. package/runtime/ext_gui/style_ua.cpp +98 -0
  157. package/runtime/ext_gui/style_values.cpp +468 -0
  158. package/runtime/ext_gui/window.cpp +60 -0
  159. package/runtime/rt.h +6 -0
  160. package/runtime/rt_internal.h +4 -0
  161. package/runtime/xt_builtins.c +1 -0
  162. package/runtime/xt_containers/access.inc +32 -1
  163. package/runtime/xt_fetch/buffer.inc +64 -0
  164. package/runtime/xt_fetch/headers.inc +312 -0
  165. package/runtime/xt_fetch/request.inc +386 -0
  166. package/runtime/xt_fetch/response.inc +107 -0
  167. package/runtime/xt_fetch/socket.inc +72 -0
  168. package/runtime/xt_fetch/url.inc +108 -0
  169. package/runtime/xt_fetch.c +39 -0
  170. package/runtime/xt_stdlib2/set.inc +1 -1
  171. package/runtime/xt_typed_array.c +614 -0
  172. package/src/cli/main.ts +137 -29
  173. package/src/codegen/generator/calls/access.ts +9 -1
  174. package/src/codegen/generator/state.ts +20 -0
  175. package/src/codegen/generator/tables.ts +40 -0
  176. package/src/driver/bundler/commonjs.ts +553 -0
  177. package/src/driver/bundler/graph.ts +35 -2
  178. package/src/driver/bundler/merge.ts +18 -1
  179. package/src/driver/bundler/types.ts +8 -0
  180. package/src/driver/compiler.ts +85 -7
  181. package/src/driver/config.ts +173 -0
  182. package/src/driver/icon.ts +184 -0
  183. package/src/driver/index.ts +30 -0
  184. package/src/driver/mac-bundle.ts +156 -0
  185. package/src/driver/win-icon.ts +96 -0
  186. package/src/extensions/gui/html.ts +236 -0
  187. package/src/extensions/gui/index.ts +11 -0
  188. package/src/extensions/registry.ts +39 -0
  189. package/src/index.ts +1 -1
  190. package/src/lexer/scanner/identifiers.ts +4 -11
  191. package/src/parser/statements.ts +17 -4
  192. package/dist/tests/e2e/gui.test.d.ts +0 -12
  193. package/dist/tests/e2e/gui.test.js +0 -493
  194. package/dist/tests/e2e/gui.test.js.map +0 -1
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Compile-time application icons.
3
+ *
4
+ * `--icon <file>` (or `app.icon` in `xbintsc.config.json`) reads an icon,
5
+ * validates it and embeds the raw bytes into the produced binary as a small
6
+ * linkable object. The `gui` extension picks the symbols up (weakly) to set the
7
+ * window / Dock icon; the Windows driver additionally turns the icon into a PE
8
+ * resource so Explorer and the taskbar show it. The core compiler never sees
9
+ * any of this — it is a driver concern, exactly like the per-platform linker
10
+ * flags.
11
+ *
12
+ * Supported inputs: `.png` (canonical), `.ico` and `.icns` (best effort on their
13
+ * home platform).
14
+ */
15
+ import { type Runner } from "./toolchain.js";
16
+ export type IconFormat = "png" | "ico" | "icns";
17
+ export interface IconInfo {
18
+ /** Absolute path the icon was read from. */
19
+ readonly path: string;
20
+ readonly format: IconFormat;
21
+ readonly bytes: Uint8Array;
22
+ /** Intrinsic size where it is cheap to sniff (0 when unknown, e.g. `.icns`). */
23
+ readonly width: number;
24
+ readonly height: number;
25
+ }
26
+ export declare class IconError extends Error {
27
+ constructor(message: string);
28
+ }
29
+ /**
30
+ * Sniff the format from the magic bytes and validate the file. Throws
31
+ * {@link IconError} with an actionable message for missing, empty or
32
+ * unsupported files.
33
+ */
34
+ export declare function readIcon(path: string): IconInfo;
35
+ /** The C symbols the embedded icon exposes to the runtime (and native code). */
36
+ export declare const ICON_SYMBOLS: {
37
+ readonly data: "xt_app_icon_data";
38
+ readonly size: "xt_app_icon_size";
39
+ readonly format: "xt_app_icon_format";
40
+ readonly width: "xt_app_icon_width";
41
+ readonly height: "xt_app_icon_height";
42
+ };
43
+ /**
44
+ * A zero-length icon. The GUI extension references {@link ICON_SYMBOLS}
45
+ * unconditionally, so the driver links this object into GUI programs even when
46
+ * no icon is configured; `size == 0` tells the runtime to skip it.
47
+ */
48
+ export declare const EMPTY_ICON: IconInfo;
49
+ /** Generate the C translation unit embedding the icon bytes. */
50
+ export declare function iconSource(icon: IconInfo): string;
51
+ /**
52
+ * Compile the icon into an object exposing {@link ICON_SYMBOLS}. Cached by the
53
+ * icon contents, so an unchanged icon is never recompiled.
54
+ */
55
+ export declare function ensureIconObject(runner: Runner, clang: string, cacheDir: string, icon: IconInfo, env?: Record<string, string>): string;
56
+ /**
57
+ * Wrap a PNG in a minimal ICO container. Vista+ accepts a PNG payload directly,
58
+ * so the PE resource path needs no BMP encoder.
59
+ */
60
+ export declare function pngToIco(png: Uint8Array, width: number, height: number): Uint8Array;
61
+ /** Normalize any supported icon to ICO bytes (used for the PE resource). */
62
+ export declare function toIcoBytes(icon: IconInfo): Uint8Array;
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Compile-time application icons.
3
+ *
4
+ * `--icon <file>` (or `app.icon` in `xbintsc.config.json`) reads an icon,
5
+ * validates it and embeds the raw bytes into the produced binary as a small
6
+ * linkable object. The `gui` extension picks the symbols up (weakly) to set the
7
+ * window / Dock icon; the Windows driver additionally turns the icon into a PE
8
+ * resource so Explorer and the taskbar show it. The core compiler never sees
9
+ * any of this — it is a driver concern, exactly like the per-platform linker
10
+ * flags.
11
+ *
12
+ * Supported inputs: `.png` (canonical), `.ico` and `.icns` (best effort on their
13
+ * home platform).
14
+ */
15
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
16
+ import { join, resolve } from "node:path";
17
+ import { hashParts } from "./cache.js";
18
+ import { compileC } from "./toolchain.js";
19
+ export class IconError extends Error {
20
+ constructor(message) {
21
+ super(message);
22
+ this.name = "IconError";
23
+ }
24
+ }
25
+ const PNG_MAGIC = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
26
+ function startsWith(bytes, magic) {
27
+ if (bytes.length < magic.length)
28
+ return false;
29
+ return magic.every((value, index) => bytes[index] === value);
30
+ }
31
+ function readUInt32BE(bytes, offset) {
32
+ return (((bytes[offset] << 24) | (bytes[offset + 1] << 16) | (bytes[offset + 2] << 8) | bytes[offset + 3]) >>> 0);
33
+ }
34
+ /**
35
+ * Sniff the format from the magic bytes and validate the file. Throws
36
+ * {@link IconError} with an actionable message for missing, empty or
37
+ * unsupported files.
38
+ */
39
+ export function readIcon(path) {
40
+ const absolute = resolve(path);
41
+ if (!existsSync(absolute)) {
42
+ throw new IconError(`Icon file not found: ${absolute}`);
43
+ }
44
+ const bytes = readFileSync(absolute);
45
+ if (bytes.length === 0) {
46
+ throw new IconError(`Icon file is empty: ${absolute}`);
47
+ }
48
+ if (startsWith(bytes, PNG_MAGIC)) {
49
+ // IHDR: width/height are big-endian at offsets 16 and 20.
50
+ const width = bytes.length >= 24 ? readUInt32BE(bytes, 16) : 0;
51
+ const height = bytes.length >= 24 ? readUInt32BE(bytes, 20) : 0;
52
+ return { path: absolute, format: "png", bytes, width, height };
53
+ }
54
+ // ICO / CUR: reserved(2) type(2) count(2), then ICONDIRENTRY[].
55
+ if (bytes.length >= 6 && bytes[0] === 0 && bytes[1] === 0 && bytes[2] === 1 && bytes[3] === 0) {
56
+ const width = bytes.length >= 7 ? bytes[6] || 256 : 0;
57
+ const height = bytes.length >= 8 ? bytes[7] || 256 : 0;
58
+ return { path: absolute, format: "ico", bytes, width, height };
59
+ }
60
+ if (startsWith(bytes, [0x69, 0x63, 0x6e, 0x73])) {
61
+ return { path: absolute, format: "icns", bytes, width: 0, height: 0 };
62
+ }
63
+ throw new IconError(`Unsupported icon format: ${absolute} (expected a PNG, ICO or ICNS file)`);
64
+ }
65
+ /** The C symbols the embedded icon exposes to the runtime (and native code). */
66
+ export const ICON_SYMBOLS = {
67
+ data: "xt_app_icon_data",
68
+ size: "xt_app_icon_size",
69
+ format: "xt_app_icon_format",
70
+ width: "xt_app_icon_width",
71
+ height: "xt_app_icon_height",
72
+ };
73
+ /**
74
+ * A zero-length icon. The GUI extension references {@link ICON_SYMBOLS}
75
+ * unconditionally, so the driver links this object into GUI programs even when
76
+ * no icon is configured; `size == 0` tells the runtime to skip it.
77
+ */
78
+ export const EMPTY_ICON = {
79
+ path: "",
80
+ format: "png",
81
+ bytes: Buffer.alloc(0),
82
+ width: 0,
83
+ height: 0,
84
+ };
85
+ /** Generate the C translation unit embedding the icon bytes. */
86
+ export function iconSource(icon) {
87
+ const lines = [];
88
+ const bytes = icon.bytes;
89
+ for (let offset = 0; offset < bytes.length; offset += 16) {
90
+ const chunk = Array.from(bytes.subarray(offset, offset + 16), (byte) => `0x${byte.toString(16).padStart(2, "0")}`);
91
+ lines.push(" " + chunk.join(", ") + ",");
92
+ }
93
+ // A zero-length array is not portable C, so an empty icon still emits one
94
+ // placeholder byte while reporting `size == 0`.
95
+ if (lines.length === 0)
96
+ lines.push(" 0x00,");
97
+ return [
98
+ "/* Generated by xbintsc - embedded application icon. Do not edit. */",
99
+ `const unsigned char ${ICON_SYMBOLS.data}[] = {`,
100
+ ...lines,
101
+ "};",
102
+ `const unsigned long long ${ICON_SYMBOLS.size} = ${bytes.length}ull;`,
103
+ `const char ${ICON_SYMBOLS.format}[] = "${icon.format}";`,
104
+ `const unsigned int ${ICON_SYMBOLS.width} = ${icon.width}u;`,
105
+ `const unsigned int ${ICON_SYMBOLS.height} = ${icon.height}u;`,
106
+ "",
107
+ ].join("\n");
108
+ }
109
+ /**
110
+ * Compile the icon into an object exposing {@link ICON_SYMBOLS}. Cached by the
111
+ * icon contents, so an unchanged icon is never recompiled.
112
+ */
113
+ export function ensureIconObject(runner, clang, cacheDir, icon, env) {
114
+ const key = hashParts(["icon", process.platform, Buffer.from(icon.bytes).toString("base64")]);
115
+ const sourcePath = join(cacheDir, `icon-${key}.c`);
116
+ const objectPath = join(cacheDir, `icon-${key}.o`);
117
+ if (!existsSync(objectPath)) {
118
+ mkdirSync(cacheDir, { recursive: true });
119
+ writeFileSync(sourcePath, iconSource(icon));
120
+ compileC(runner, clang, sourcePath, objectPath, cacheDir, env);
121
+ }
122
+ return objectPath;
123
+ }
124
+ /**
125
+ * Wrap a PNG in a minimal ICO container. Vista+ accepts a PNG payload directly,
126
+ * so the PE resource path needs no BMP encoder.
127
+ */
128
+ export function pngToIco(png, width, height) {
129
+ const header = Buffer.alloc(22);
130
+ header.writeUInt16LE(0, 0); // reserved
131
+ header.writeUInt16LE(1, 2); // type: icon
132
+ header.writeUInt16LE(1, 4); // image count
133
+ header.writeUInt8(width >= 256 || width <= 0 ? 0 : width, 6);
134
+ header.writeUInt8(height >= 256 || height <= 0 ? 0 : height, 7);
135
+ header.writeUInt8(0, 8); // palette size
136
+ header.writeUInt8(0, 9); // reserved
137
+ header.writeUInt16LE(1, 10); // color planes
138
+ header.writeUInt16LE(32, 12); // bits per pixel
139
+ header.writeUInt32LE(png.length, 14);
140
+ header.writeUInt32LE(22, 18); // payload offset
141
+ return Buffer.concat([header, Buffer.from(png)]);
142
+ }
143
+ /** Normalize any supported icon to ICO bytes (used for the PE resource). */
144
+ export function toIcoBytes(icon) {
145
+ if (icon.format === "ico")
146
+ return icon.bytes;
147
+ if (icon.format === "png")
148
+ return pngToIco(icon.bytes, icon.width, icon.height);
149
+ throw new IconError(`Cannot embed a .${icon.format} icon as a Windows PE resource; use a PNG or ICO.`);
150
+ }
151
+ //# sourceMappingURL=icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.js","sourceRoot":"","sources":["../../../src/driver/icon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS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AAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB;IAC/C,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACrC,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,iBAAiB;IAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,IAAc;IACvC,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC;IAC7C,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAChF,MAAM,IAAI,SAAS,CAAC,mBAAmB,IAAI,CAAC,MAAM,mDAAmD,CAAC,CAAC;AACzG,CAAC"}
@@ -4,3 +4,7 @@ export { findRuntimeDir, platformSlug, releaseArchiveBase, releaseArchiveFileNam
4
4
  export { findRuntimeLibrary, runtimeLibDir } from "./runtime-lib.js";
5
5
  export { findClang, realRunner, ToolchainError, type Runner, } from "./toolchain.js";
6
6
  export { resolveToolchain, type ResolvedToolchain, type ToolchainSource } from "./toolchain-provider.js";
7
+ export { CONFIG_FILE_NAME, findProjectConfig, loadProjectConfig, parseProjectConfig, resolveConfigPaths, ProjectConfigError, type AppConfig, type LoadedProjectConfig, type ProjectConfig, } from "./config.js";
8
+ export { ensureIconObject, iconSource, readIcon, toIcoBytes, pngToIco, ICON_SYMBOLS, EMPTY_ICON, IconError, type IconFormat, type IconInfo, } from "./icon.js";
9
+ export { ensureWindowsIconResource, resolveResourceCompiler, type ResourceCompiler, type ResourceCompilerKind, } from "./win-icon.js";
10
+ export { bundlePathFor, infoPlist, packageMacApp, type MacBundleOptions } from "./mac-bundle.js";
@@ -4,4 +4,8 @@ export { findRuntimeDir, platformSlug, releaseArchiveBase, releaseArchiveFileNam
4
4
  export { findRuntimeLibrary, runtimeLibDir } from "./runtime-lib.js";
5
5
  export { findClang, realRunner, ToolchainError, } from "./toolchain.js";
6
6
  export { resolveToolchain } from "./toolchain-provider.js";
7
+ export { CONFIG_FILE_NAME, findProjectConfig, loadProjectConfig, parseProjectConfig, resolveConfigPaths, ProjectConfigError, } from "./config.js";
8
+ export { ensureIconObject, iconSource, readIcon, toIcoBytes, pngToIco, ICON_SYMBOLS, EMPTY_ICON, IconError, } from "./icon.js";
9
+ export { ensureWindowsIconResource, resolveResourceCompiler, } from "./win-icon.js";
10
+ export { bundlePathFor, infoPlist, packageMacApp } from "./mac-bundle.js";
7
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/driver/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAsD,MAAM,eAAe,CAAC;AAC3H,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC/H,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,GAEf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAgD,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/driver/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAsD,MAAM,eAAe,CAAC;AAC3H,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC/H,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,GAEf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAgD,MAAM,yBAAyB,CAAC;AACzG,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GAInB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,GAGV,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GAGxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAyB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * macOS `.app` bundle generation.
3
+ *
4
+ * A bare Mach-O executable cannot carry a Finder icon, so when `app.bundle` is
5
+ * enabled on macOS the driver lays out a minimal bundle next to the executable:
6
+ *
7
+ * Demo.app/Contents/Info.plist
8
+ * Demo.app/Contents/MacOS/Demo
9
+ * Demo.app/Contents/Resources/AppIcon.icns
10
+ *
11
+ * An `.icns` input is copied verbatim; a `.png` is converted with the system
12
+ * `sips` + `iconutil` tools when available, otherwise the PNG is shipped and the
13
+ * app relies on the runtime Dock icon (set by the `gui` extension).
14
+ */
15
+ import type { IconInfo } from "./icon.js";
16
+ import type { Runner } from "./toolchain.js";
17
+ export interface MacBundleOptions {
18
+ readonly executablePath: string;
19
+ /** Display name; also the executable name inside the bundle. */
20
+ readonly name: string;
21
+ readonly bundleId: string;
22
+ readonly icon?: IconInfo;
23
+ readonly runner: Runner;
24
+ readonly env?: Record<string, string>;
25
+ }
26
+ /** `<dir>/<name>.app` for an executable at `<dir>/<name>`. */
27
+ export declare function bundlePathFor(executablePath: string, name: string): string;
28
+ export interface PlistOptions {
29
+ readonly name: string;
30
+ readonly bundleId: string;
31
+ readonly executable: string;
32
+ readonly iconFile?: string;
33
+ }
34
+ /** Render a minimal `Info.plist` for a GUI application bundle. */
35
+ export declare function infoPlist(options: PlistOptions): string;
36
+ /**
37
+ * Lay out the `.app` bundle containing a copy of `executablePath` and, when
38
+ * available, the icon. Returns the bundle path. Never throws for a missing
39
+ * image-conversion tool: it falls back to shipping the PNG.
40
+ */
41
+ export declare function packageMacApp(options: MacBundleOptions): string;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * macOS `.app` bundle generation.
3
+ *
4
+ * A bare Mach-O executable cannot carry a Finder icon, so when `app.bundle` is
5
+ * enabled on macOS the driver lays out a minimal bundle next to the executable:
6
+ *
7
+ * Demo.app/Contents/Info.plist
8
+ * Demo.app/Contents/MacOS/Demo
9
+ * Demo.app/Contents/Resources/AppIcon.icns
10
+ *
11
+ * An `.icns` input is copied verbatim; a `.png` is converted with the system
12
+ * `sips` + `iconutil` tools when available, otherwise the PNG is shipped and the
13
+ * app relies on the runtime Dock icon (set by the `gui` extension).
14
+ */
15
+ import { chmodSync, copyFileSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
16
+ import { dirname, join } from "node:path";
17
+ /** `<dir>/<name>.app` for an executable at `<dir>/<name>`. */
18
+ export function bundlePathFor(executablePath, name) {
19
+ return join(dirname(executablePath), `${name}.app`);
20
+ }
21
+ /** Escape the five XML predefined entities for the plist values. */
22
+ function xmlEscape(text) {
23
+ return text
24
+ .replace(/&/g, "&amp;")
25
+ .replace(/</g, "&lt;")
26
+ .replace(/>/g, "&gt;")
27
+ .replace(/"/g, "&quot;");
28
+ }
29
+ /** Render a minimal `Info.plist` for a GUI application bundle. */
30
+ export function infoPlist(options) {
31
+ const entries = [
32
+ ["CFBundleName", options.name],
33
+ ["CFBundleDisplayName", options.name],
34
+ ["CFBundleIdentifier", options.bundleId],
35
+ ["CFBundleExecutable", options.executable],
36
+ ["CFBundlePackageType", "APPL"],
37
+ ["CFBundleInfoDictionaryVersion", "6.0"],
38
+ ["CFBundleShortVersionString", "1.0.0"],
39
+ ["CFBundleVersion", "1"],
40
+ ["LSMinimumSystemVersion", "10.13"],
41
+ ["NSHighResolutionCapable", "true"],
42
+ ];
43
+ if (options.iconFile)
44
+ entries.push(["CFBundleIconFile", options.iconFile]);
45
+ const body = entries
46
+ .map(([key, value]) => `\t<key>${key}</key>\n\t<string>${xmlEscape(value)}</string>`)
47
+ .join("\n");
48
+ return [
49
+ '<?xml version="1.0" encoding="UTF-8"?>',
50
+ '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
51
+ '<plist version="1.0">',
52
+ "<dict>",
53
+ body,
54
+ "</dict>",
55
+ "</plist>",
56
+ "",
57
+ ].join("\n");
58
+ }
59
+ const ICONSET_SIZES = [16, 32, 64, 128, 256, 512];
60
+ /** Convert a PNG to `.icns` via `sips` + `iconutil`; false when unavailable. */
61
+ function convertPngToIcns(runner, pngPath, outIcns, env) {
62
+ const iconsetDir = join(dirname(outIcns), "AppIcon.iconset");
63
+ mkdirSync(iconsetDir, { recursive: true });
64
+ try {
65
+ for (const size of ICONSET_SIZES) {
66
+ for (const scale of [1, 2]) {
67
+ const pixels = size * scale;
68
+ if (pixels > 1024)
69
+ continue;
70
+ const suffix = scale === 1 ? "" : "@2x";
71
+ const out = join(iconsetDir, `icon_${size}x${size}${suffix}.png`);
72
+ const result = runner.run("sips", ["-z", String(pixels), String(pixels), pngPath, "--out", out], { env });
73
+ if (result.status !== 0)
74
+ return false;
75
+ }
76
+ }
77
+ const result = runner.run("iconutil", ["-c", "icns", iconsetDir, "-o", outIcns], { env });
78
+ return result.status === 0 && existsSync(outIcns);
79
+ }
80
+ catch {
81
+ return false;
82
+ }
83
+ finally {
84
+ rmSync(iconsetDir, { recursive: true, force: true });
85
+ }
86
+ }
87
+ /**
88
+ * Lay out the `.app` bundle containing a copy of `executablePath` and, when
89
+ * available, the icon. Returns the bundle path. Never throws for a missing
90
+ * image-conversion tool: it falls back to shipping the PNG.
91
+ */
92
+ export function packageMacApp(options) {
93
+ const { executablePath, name, bundleId, icon, runner } = options;
94
+ const bundleDir = bundlePathFor(executablePath, name);
95
+ const contents = join(bundleDir, "Contents");
96
+ const macosDir = join(contents, "MacOS");
97
+ const resourcesDir = join(contents, "Resources");
98
+ mkdirSync(macosDir, { recursive: true });
99
+ mkdirSync(resourcesDir, { recursive: true });
100
+ const innerExecutable = join(macosDir, name);
101
+ copyFileSync(executablePath, innerExecutable);
102
+ chmodSync(innerExecutable, 0o755);
103
+ let iconFile;
104
+ if (icon) {
105
+ const icnsPath = join(resourcesDir, "AppIcon.icns");
106
+ if (icon.format === "icns") {
107
+ copyFileSync(icon.path, icnsPath);
108
+ iconFile = "AppIcon";
109
+ }
110
+ else if (icon.format === "png") {
111
+ if (convertPngToIcns(runner, icon.path, icnsPath, options.env)) {
112
+ iconFile = "AppIcon";
113
+ }
114
+ else {
115
+ copyFileSync(icon.path, join(resourcesDir, "AppIcon.png"));
116
+ iconFile = "AppIcon.png";
117
+ }
118
+ }
119
+ }
120
+ writeFileSync(join(contents, "Info.plist"), infoPlist({ name, bundleId, executable: name, ...(iconFile ? { iconFile } : {}) }));
121
+ return bundleDir;
122
+ }
123
+ //# sourceMappingURL=mac-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mac-bundle.js","sourceRoot":"","sources":["../../../src/driver/mac-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,M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AAE,eAAe,CAAC,CAAC;IAC9C,SAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAElC,IAAI,QAA4B,CAAC;IACjC,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACpD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC3B,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAClC,QAAQ,GAAG,SAAS,CAAC;QACvB,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YACjC,IAAI,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/D,QAAQ,GAAG,SAAS,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACN,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;gBAC3D,QAAQ,GAAG,aAAa,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IAED,aAAa,CACX,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,EAC5B,SAAS,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CACnF,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Windows PE icon resource.
3
+ *
4
+ * Windows reads the application icon from a resource section in the `.exe`, so
5
+ * an embedded blob is not enough: the icon is wrapped in a `.rc` script and
6
+ * compiled to a resource object that is linked into the executable. `llvm-rc`
7
+ * (shipping with clang) is preferred; MinGW `windres` is the fallback. Both are
8
+ * optional — a missing resource compiler degrades to the runtime window icon
9
+ * instead of failing the build.
10
+ */
11
+ import { type IconInfo } from "./icon.js";
12
+ import type { Runner } from "./toolchain.js";
13
+ export type ResourceCompilerKind = "llvm-rc" | "windres";
14
+ export interface ResourceCompiler {
15
+ readonly tool: string;
16
+ readonly kind: ResourceCompilerKind;
17
+ }
18
+ /**
19
+ * Locate a resource compiler. `xbintsc_RC` wins, then `llvm-rc` next to the
20
+ * resolved clang, then `llvm-rc` and `windres` on `PATH`.
21
+ */
22
+ export declare function resolveResourceCompiler(runner: Runner, clang: string): ResourceCompiler | undefined;
23
+ /**
24
+ * Compile the icon into a linkable PE resource object (`.res` for llvm-rc, a
25
+ * COFF `.o` for windres). Cached by contents and compiler kind.
26
+ */
27
+ export declare function ensureWindowsIconResource(runner: Runner, cacheDir: string, icon: IconInfo, compiler: ResourceCompiler, env?: Record<string, string>): string;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Windows PE icon resource.
3
+ *
4
+ * Windows reads the application icon from a resource section in the `.exe`, so
5
+ * an embedded blob is not enough: the icon is wrapped in a `.rc` script and
6
+ * compiled to a resource object that is linked into the executable. `llvm-rc`
7
+ * (shipping with clang) is preferred; MinGW `windres` is the fallback. Both are
8
+ * optional — a missing resource compiler degrades to the runtime window icon
9
+ * instead of failing the build.
10
+ */
11
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
12
+ import { dirname, join } from "node:path";
13
+ import { hashParts } from "./cache.js";
14
+ import { IconError, toIcoBytes } from "./icon.js";
15
+ /**
16
+ * Locate a resource compiler. `xbintsc_RC` wins, then `llvm-rc` next to the
17
+ * resolved clang, then `llvm-rc` and `windres` on `PATH`.
18
+ */
19
+ export function resolveResourceCompiler(runner, clang) {
20
+ const exe = process.platform === "win32" ? ".exe" : "";
21
+ // An explicit override is trusted: probe it and fall back rather than
22
+ // rejecting it on a path prefix check (it may be a bare command on PATH).
23
+ const override = process.env.xbintsc_RC;
24
+ if (override) {
25
+ const kind = /windres/i.test(override) ? "windres" : "llvm-rc";
26
+ try {
27
+ if (runner.run(override, ["--version"]).status === 0)
28
+ return { tool: override, kind };
29
+ }
30
+ catch {
31
+ // Fall through to the discovered compilers.
32
+ }
33
+ }
34
+ const candidates = [];
35
+ if (clang && (clang.includes("/") || clang.includes("\\"))) {
36
+ candidates.push({ tool: join(dirname(clang), `llvm-rc${exe}`), kind: "llvm-rc" });
37
+ }
38
+ candidates.push({ tool: `llvm-rc${exe}`, kind: "llvm-rc" });
39
+ candidates.push({ tool: `windres${exe}`, kind: "windres" });
40
+ for (const candidate of candidates) {
41
+ if ((candidate.tool.includes("/") || candidate.tool.includes("\\")) && !existsSync(candidate.tool))
42
+ continue;
43
+ try {
44
+ if (runner.run(candidate.tool, ["--version"]).status === 0)
45
+ return candidate;
46
+ }
47
+ catch {
48
+ // Not runnable; try the next candidate.
49
+ }
50
+ }
51
+ return undefined;
52
+ }
53
+ /**
54
+ * Compile the icon into a linkable PE resource object (`.res` for llvm-rc, a
55
+ * COFF `.o` for windres). Cached by contents and compiler kind.
56
+ */
57
+ export function ensureWindowsIconResource(runner, cacheDir, icon, compiler, env) {
58
+ const icoBytes = toIcoBytes(icon);
59
+ const key = hashParts(["icon-res", compiler.kind, Buffer.from(icoBytes).toString("base64")]);
60
+ const icoName = `icon-${key}.ico`;
61
+ const icoPath = join(cacheDir, icoName);
62
+ const rcPath = join(cacheDir, `icon-${key}.rc`);
63
+ const objectPath = join(cacheDir, `icon-${key}.${compiler.kind === "windres" ? "o" : "res"}`);
64
+ if (existsSync(objectPath))
65
+ return objectPath;
66
+ mkdirSync(cacheDir, { recursive: true });
67
+ writeFileSync(icoPath, icoBytes);
68
+ // The .rc references the .ico by name; the compiler runs with `cacheDir` as
69
+ // its working directory so the relative path resolves.
70
+ writeFileSync(rcPath, `1 ICON "${icoName}"\n`);
71
+ const args = compiler.kind === "windres"
72
+ ? [rcPath, "-O", "coff", "-o", objectPath]
73
+ : ["/fo", objectPath, rcPath];
74
+ const result = runner.run(compiler.tool, args, { cwd: cacheDir, env });
75
+ if (result.status !== 0 || !existsSync(objectPath)) {
76
+ throw new IconError(`Failed to compile the Windows icon resource with ${compiler.tool}:\n${result.stderr || result.stdout}`);
77
+ }
78
+ return objectPath;
79
+ }
80
+ //# sourceMappingURL=win-icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"win-icon.js","sourceRoot":"","sources":["../../../src/driver/win-icon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAiB,MAAM,WAAW,CAAC;AAUjE;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,KAAa;IACnE,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,sEAAsE;IACtE,0EAA0E;IAC1E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IACxC,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,IAAI,GAAyB,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,IAAI,CAAC;YACH,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACxF,CAAC;QAAC,MAAM,CAAC;YACP,4CAA4C;QAC9C,CAAC;IACH,CAAC;IACD,MAAM,UAAU,GAAuB,EAAE,CAAC;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IAAI,MAAM,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CACxG,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * GUI `.html` asset loader.
3
+ *
4
+ * `import html from "./index.html"` normally yields the file contents as a
5
+ * string. When the file contains scripts, the loader also compiles them: each
6
+ * script body is wrapped in a function `(window, document) => { … }`,
7
+ * registered through the `__registerScript` builtin, and the element is
8
+ * replaced by an inert `<script data-xt-id="<hash>"></script>` marker. The
9
+ * engine runs the matching functions once the document has been parsed (see
10
+ * `runtime/ext_gui/script.cpp`).
11
+ *
12
+ * This is how xbintsc supports `<script>` without a JavaScript engine: the body
13
+ * is ordinary TypeScript compiled by the existing front end, ahead of time.
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.
22
+ */
23
+ import type { AssetLoadResult } from "../registry.js";
24
+ /** Rewrite `<script>` bodies into registered AOT functions + an HTML string. */
25
+ export declare function loadHtmlAsset(path: string, source: string): AssetLoadResult;