xbintsc 0.3.15 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli/main.js +4 -4
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/state.js +8 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/tables.js +8 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/bundler/graph.d.ts +8 -0
- package/dist/src/driver/bundler/graph.js +85 -0
- package/dist/src/driver/bundler/graph.js.map +1 -0
- package/dist/src/driver/bundler/merge.d.ts +11 -0
- package/dist/src/driver/bundler/merge.js +288 -0
- package/dist/src/driver/bundler/merge.js.map +1 -0
- package/dist/src/driver/bundler/resolve.d.ts +12 -0
- package/dist/src/driver/bundler/resolve.js +246 -0
- package/dist/src/driver/bundler/resolve.js.map +1 -0
- package/dist/src/driver/bundler/symbols.d.ts +15 -0
- package/dist/src/driver/bundler/symbols.js +51 -0
- package/dist/src/driver/bundler/symbols.js.map +1 -0
- package/dist/src/driver/bundler/types.d.ts +36 -0
- package/dist/src/driver/bundler/types.js +5 -0
- package/dist/src/driver/bundler/types.js.map +1 -0
- package/dist/src/driver/modules.d.ts +9 -16
- package/dist/src/driver/modules.js +8 -644
- package/dist/src/driver/modules.js.map +1 -1
- package/dist/src/extensions/catalog.js +2 -1
- package/dist/src/extensions/catalog.js.map +1 -1
- package/dist/src/extensions/gui/index.d.ts +24 -0
- package/dist/src/extensions/gui/index.js +101 -0
- package/dist/src/extensions/gui/index.js.map +1 -0
- package/dist/tests/e2e/compile-basics.test.d.ts +4 -0
- package/dist/tests/e2e/compile-basics.test.js +134 -0
- package/dist/tests/e2e/compile-basics.test.js.map +1 -0
- package/dist/tests/e2e/compile-builtins.test.d.ts +4 -0
- package/dist/tests/e2e/compile-builtins.test.js +191 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -0
- package/dist/tests/e2e/compile-control-flow.test.d.ts +4 -0
- package/dist/tests/e2e/compile-control-flow.test.js +190 -0
- package/dist/tests/e2e/compile-control-flow.test.js.map +1 -0
- package/dist/tests/e2e/compile-modules.test.d.ts +4 -0
- package/dist/tests/e2e/compile-modules.test.js +48 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -0
- package/dist/tests/e2e/compile-objects-classes.test.d.ts +4 -0
- package/dist/tests/e2e/compile-objects-classes.test.js +362 -0
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -0
- package/dist/tests/e2e/differential-helpers.d.ts +12 -0
- package/dist/tests/e2e/differential-helpers.js +16 -0
- package/dist/tests/e2e/differential-helpers.js.map +1 -0
- package/dist/tests/e2e/differential-language.test.d.ts +4 -0
- package/dist/tests/e2e/{differential.test.js → differential-language.test.js} +5 -287
- package/dist/tests/e2e/differential-language.test.js.map +1 -0
- package/dist/tests/e2e/differential-symbols.test.d.ts +4 -0
- package/dist/tests/e2e/differential-symbols.test.js +92 -0
- package/dist/tests/e2e/differential-symbols.test.js.map +1 -0
- package/dist/tests/e2e/differential-values.test.d.ts +4 -0
- package/dist/tests/e2e/differential-values.test.js +197 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -0
- package/dist/tests/e2e/gui.test.d.ts +12 -0
- package/dist/tests/e2e/gui.test.js +493 -0
- package/dist/tests/e2e/gui.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-buffer.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-buffer.test.js +97 -0
- package/dist/tests/e2e/runtime-coverage-buffer.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-globals.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-globals.test.js +149 -0
- package/dist/tests/e2e/runtime-coverage-globals.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-node-modules.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-node-modules.test.js +177 -0
- package/dist/tests/e2e/runtime-coverage-node-modules.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-streams.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-streams.test.js +161 -0
- package/dist/tests/e2e/runtime-coverage-streams.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-system.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-system.test.js +91 -0
- package/dist/tests/e2e/runtime-coverage-system.test.js.map +1 -0
- package/dist/tests/e2e/timers.test.d.ts +7 -0
- package/dist/tests/e2e/timers.test.js +63 -0
- package/dist/tests/e2e/timers.test.js.map +1 -0
- package/package.json +2 -1
- package/runtime/ext_gui/css.cpp +743 -0
- package/runtime/ext_gui/css.h +98 -0
- package/runtime/ext_gui/document.cpp +264 -0
- package/runtime/ext_gui/document.h +89 -0
- package/runtime/ext_gui/dom.cpp +472 -0
- package/runtime/ext_gui/dom.h +71 -0
- package/runtime/ext_gui/gui.cpp +457 -0
- package/runtime/ext_gui/gui_engine.h +81 -0
- package/runtime/ext_gui/image.cpp +125 -0
- package/runtime/ext_gui/image.h +42 -0
- package/runtime/ext_gui/layout.cpp +748 -0
- package/runtime/ext_gui/layout.h +93 -0
- package/runtime/ext_gui/paint.cpp +137 -0
- package/runtime/ext_gui/paint.h +75 -0
- package/runtime/ext_gui/renderer.cpp +959 -0
- package/runtime/ext_gui/renderer.h +68 -0
- package/runtime/ext_gui/stb_image.h +7988 -0
- package/runtime/ext_gui/style.cpp +771 -0
- package/runtime/ext_gui/style.h +117 -0
- package/runtime/ext_gui/text.cpp +378 -0
- package/runtime/ext_gui/text.h +78 -0
- package/runtime/ext_gui/window.cpp +405 -0
- package/runtime/ext_node/fs/fs_common.h +13 -527
- package/runtime/ext_node/fs/parts/buffer-bridge.inc +6 -0
- package/runtime/ext_node/fs/parts/builtins.inc +69 -0
- package/runtime/ext_node/fs/parts/dir.inc +47 -0
- package/runtime/ext_node/fs/parts/encoding.inc +186 -0
- package/runtime/ext_node/fs/parts/errors.inc +66 -0
- package/runtime/ext_node/fs/parts/flags.inc +39 -0
- package/runtime/ext_node/fs/parts/platform.inc +86 -0
- package/runtime/ext_node/fs/parts/promisify.inc +15 -0
- package/runtime/ext_node/fs/parts/time.inc +9 -0
- package/runtime/rt.h +33 -0
- package/runtime/xt_builtins.c +4 -0
- package/runtime/xt_containers/access.inc +168 -0
- package/runtime/xt_containers/arrays.inc +108 -0
- package/runtime/xt_containers/boxes.inc +11 -0
- package/runtime/xt_containers/objects.inc +326 -0
- package/runtime/xt_containers.c +8 -618
- package/runtime/xt_io/base64.inc +87 -0
- package/runtime/xt_io/console.inc +119 -0
- package/runtime/xt_io/exception.inc +142 -0
- package/runtime/xt_io/inspect.inc +212 -0
- package/runtime/xt_io.c +8 -553
- package/runtime/xt_loop.c +262 -24
- package/runtime/xt_regex/api.inc +58 -0
- package/runtime/xt_regex/helpers.inc +68 -0
- package/runtime/xt_regex/matcher.inc +248 -0
- package/runtime/xt_regex/parser.inc +236 -0
- package/runtime/xt_regex/types.inc +58 -0
- package/runtime/xt_regex.h +9 -672
- package/runtime/xt_values/arithmetic.inc +150 -0
- package/runtime/xt_values/comparison.inc +112 -0
- package/runtime/xt_values/constructors.inc +41 -0
- package/runtime/xt_values/conversions.inc +115 -0
- package/runtime/xt_values/number-format.inc +180 -0
- package/runtime/xt_values/strings.inc +22 -0
- package/runtime/xt_values.c +10 -626
- package/scripts/build-gui.ts +317 -0
- package/src/cli/main.ts +4 -3
- package/src/codegen/generator/state.ts +8 -0
- package/src/codegen/generator/tables.ts +8 -0
- package/src/driver/bundler/graph.ts +95 -0
- package/src/driver/bundler/merge.ts +312 -0
- package/src/driver/bundler/resolve.ts +240 -0
- package/src/driver/bundler/symbols.ts +55 -0
- package/src/driver/bundler/types.ts +37 -0
- package/src/driver/modules.ts +9 -693
- package/src/extensions/catalog.ts +2 -1
- package/src/extensions/gui/index.ts +107 -0
- package/dist/tests/e2e/compile.test.d.ts +0 -8
- package/dist/tests/e2e/compile.test.js +0 -893
- package/dist/tests/e2e/compile.test.js.map +0 -1
- package/dist/tests/e2e/differential.test.d.ts +0 -7
- package/dist/tests/e2e/differential.test.js.map +0 -1
- package/dist/tests/e2e/runtime-coverage.test.d.ts +0 -11
- package/dist/tests/e2e/runtime-coverage.test.js +0 -646
- package/dist/tests/e2e/runtime-coverage.test.js.map +0 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module resolution for the bundler: relative paths, directory `index`
|
|
3
|
+
* entries, package `exports` maps and `node_modules` lookup.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
6
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
7
|
+
/**
|
|
8
|
+
* Source extensions probed for an extension-less specifier. TypeScript suffixes
|
|
9
|
+
* are tried before their JavaScript counterparts so a project that ships both
|
|
10
|
+
* `foo.ts` and a compiled `foo.js` prefers the source it is compiled from.
|
|
11
|
+
*/
|
|
12
|
+
const RESOLVE_SUFFIXES = ["", ".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
13
|
+
/** File extensions a directory `index` entry may use. */
|
|
14
|
+
const INDEX_SUFFIXES = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
15
|
+
/** Conditions consulted, in order, when reading a package `exports` map. */
|
|
16
|
+
const EXPORT_CONDITIONS = ["import", "module", "default", "node", "require"];
|
|
17
|
+
/** A specifier is a file path (`./x`, `../x`, `/x`) rather than a package. */
|
|
18
|
+
function isRelativeSpecifier(specifier) {
|
|
19
|
+
return specifier.startsWith(".") || isAbsolute(specifier);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a path on disk, tolerating TypeScript's `.js` import convention
|
|
23
|
+
* (`import "./foo.js"` pointing at `foo.ts`) and Node's directory/`index`
|
|
24
|
+
* conventions.
|
|
25
|
+
*/
|
|
26
|
+
function resolvePath(base) {
|
|
27
|
+
// A JavaScript specifier may refer to a TypeScript source that will emit it
|
|
28
|
+
// (`import "./foo.js"` pointing at `foo.ts`). Probe the matching TypeScript
|
|
29
|
+
// extensions after the literal path: `.js`/`.jsx` -> `.ts`/`.tsx`,
|
|
30
|
+
// `.mjs` -> `.mts`, `.cjs` -> `.cts`.
|
|
31
|
+
const candidates = [base];
|
|
32
|
+
const jsExtension = /\.((?:m|c)?jsx?)$/.exec(base);
|
|
33
|
+
if (jsExtension) {
|
|
34
|
+
const stem = base.slice(0, jsExtension.index);
|
|
35
|
+
switch (jsExtension[1]) {
|
|
36
|
+
case "jsx":
|
|
37
|
+
candidates.push(`${stem}.tsx`, `${stem}.ts`);
|
|
38
|
+
break;
|
|
39
|
+
case "mjs":
|
|
40
|
+
candidates.push(`${stem}.mts`);
|
|
41
|
+
break;
|
|
42
|
+
case "cjs":
|
|
43
|
+
candidates.push(`${stem}.cts`);
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
candidates.push(`${stem}.ts`, `${stem}.tsx`);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const candidate of candidates) {
|
|
51
|
+
if (existsSync(candidate) && statSync(candidate).isFile())
|
|
52
|
+
return candidate;
|
|
53
|
+
}
|
|
54
|
+
for (const suffix of RESOLVE_SUFFIXES) {
|
|
55
|
+
const candidate = base + suffix;
|
|
56
|
+
if (existsSync(candidate) && statSync(candidate).isFile())
|
|
57
|
+
return candidate;
|
|
58
|
+
}
|
|
59
|
+
if (existsSync(base) && statSync(base).isDirectory())
|
|
60
|
+
return resolveDirectory(base);
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
/** Resolve a directory to its package entry or an `index` file. */
|
|
64
|
+
function resolveDirectory(directory) {
|
|
65
|
+
const pkg = readPackageJson(directory);
|
|
66
|
+
if (pkg && typeof pkg.main === "string") {
|
|
67
|
+
const main = resolvePath(resolve(directory, pkg.main));
|
|
68
|
+
if (main)
|
|
69
|
+
return main;
|
|
70
|
+
}
|
|
71
|
+
for (const suffix of INDEX_SUFFIXES) {
|
|
72
|
+
const candidate = join(directory, `index${suffix}`);
|
|
73
|
+
if (existsSync(candidate) && statSync(candidate).isFile())
|
|
74
|
+
return candidate;
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
function resolveModule(fromDir, specifier) {
|
|
79
|
+
return resolvePath(resolve(fromDir, specifier));
|
|
80
|
+
}
|
|
81
|
+
function readPackageJson(directory) {
|
|
82
|
+
const file = join(directory, "package.json");
|
|
83
|
+
if (!existsSync(file) || !statSync(file).isFile())
|
|
84
|
+
return undefined;
|
|
85
|
+
try {
|
|
86
|
+
const parsed = JSON.parse(readFileSync(file, "utf8"));
|
|
87
|
+
return parsed && typeof parsed === "object" ? parsed : undefined;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** Split `pkg/sub/path` or `@scope/pkg/sub/path` into package name and subpath. */
|
|
94
|
+
function splitPackageSpecifier(specifier) {
|
|
95
|
+
const parts = specifier.split("/");
|
|
96
|
+
if (specifier.startsWith("@")) {
|
|
97
|
+
return { packageName: parts.slice(0, 2).join("/"), subpath: parts.slice(2).join("/") };
|
|
98
|
+
}
|
|
99
|
+
return { packageName: parts[0] ?? specifier, subpath: parts.slice(1).join("/") };
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Resolve a bare specifier against the `node_modules` directories above
|
|
103
|
+
* `fromDir`, following a package's `exports` map and falling back to
|
|
104
|
+
* `module`/`main`/`index`. Packages that only ship CommonJS resolve here too;
|
|
105
|
+
* their `require` calls are then rejected during code generation.
|
|
106
|
+
*/
|
|
107
|
+
function resolveNodePackage(fromDir, specifier) {
|
|
108
|
+
const { packageName, subpath } = splitPackageSpecifier(specifier);
|
|
109
|
+
if (!packageName || packageName.startsWith("."))
|
|
110
|
+
return undefined;
|
|
111
|
+
let directory = fromDir;
|
|
112
|
+
for (;;) {
|
|
113
|
+
const packageDir = join(directory, "node_modules", packageName);
|
|
114
|
+
if (existsSync(packageDir) && statSync(packageDir).isDirectory()) {
|
|
115
|
+
const resolved = subpath
|
|
116
|
+
? resolvePackageSubpath(packageDir, subpath)
|
|
117
|
+
: resolvePackageEntry(packageDir);
|
|
118
|
+
if (resolved)
|
|
119
|
+
return resolved;
|
|
120
|
+
}
|
|
121
|
+
const parent = dirname(directory);
|
|
122
|
+
if (parent === directory)
|
|
123
|
+
return undefined;
|
|
124
|
+
directory = parent;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function resolvePackageEntry(packageDir) {
|
|
128
|
+
const pkg = readPackageJson(packageDir);
|
|
129
|
+
if (pkg) {
|
|
130
|
+
const exported = resolveExportTarget(subpathValue(pkg.exports, "."));
|
|
131
|
+
if (exported) {
|
|
132
|
+
const resolved = resolvePath(resolve(packageDir, exported));
|
|
133
|
+
if (resolved)
|
|
134
|
+
return resolved;
|
|
135
|
+
}
|
|
136
|
+
if (typeof pkg.module === "string") {
|
|
137
|
+
const resolved = resolvePath(resolve(packageDir, pkg.module));
|
|
138
|
+
if (resolved)
|
|
139
|
+
return resolved;
|
|
140
|
+
}
|
|
141
|
+
if (typeof pkg.main === "string") {
|
|
142
|
+
const resolved = resolvePath(resolve(packageDir, pkg.main));
|
|
143
|
+
if (resolved)
|
|
144
|
+
return resolved;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return resolveDirectory(packageDir);
|
|
148
|
+
}
|
|
149
|
+
function resolvePackageSubpath(packageDir, subpath) {
|
|
150
|
+
const pkg = readPackageJson(packageDir);
|
|
151
|
+
const exported = resolveExportTarget(subpathValue(pkg?.exports, `./${subpath}`));
|
|
152
|
+
if (exported) {
|
|
153
|
+
const resolved = resolvePath(resolve(packageDir, exported));
|
|
154
|
+
if (resolved)
|
|
155
|
+
return resolved;
|
|
156
|
+
}
|
|
157
|
+
return resolvePath(join(packageDir, subpath));
|
|
158
|
+
}
|
|
159
|
+
/** Pick the export target for a subpath (`"."` or `"./sub"`) from an exports map. */
|
|
160
|
+
function subpathValue(exportsField, subpath) {
|
|
161
|
+
if (exportsField === undefined)
|
|
162
|
+
return undefined;
|
|
163
|
+
if (typeof exportsField === "string" || Array.isArray(exportsField)) {
|
|
164
|
+
return subpath === "." ? exportsField : undefined;
|
|
165
|
+
}
|
|
166
|
+
if (!exportsField || typeof exportsField !== "object")
|
|
167
|
+
return undefined;
|
|
168
|
+
const record = exportsField;
|
|
169
|
+
const keys = Object.keys(record);
|
|
170
|
+
// A map without `.`-prefixed keys is a condition map for the root export.
|
|
171
|
+
if (!keys.some((key) => key.startsWith("."))) {
|
|
172
|
+
return subpath === "." ? exportsField : undefined;
|
|
173
|
+
}
|
|
174
|
+
if (subpath in record)
|
|
175
|
+
return record[subpath];
|
|
176
|
+
// Wildcard patterns such as `"./*": "./dist/*.js"`.
|
|
177
|
+
for (const key of keys) {
|
|
178
|
+
const star = key.indexOf("*");
|
|
179
|
+
if (star === -1)
|
|
180
|
+
continue;
|
|
181
|
+
const prefix = key.slice(0, star);
|
|
182
|
+
const suffix = key.slice(star + 1);
|
|
183
|
+
if (subpath.startsWith(prefix) && subpath.endsWith(suffix)) {
|
|
184
|
+
const matched = subpath.slice(prefix.length, subpath.length - suffix.length);
|
|
185
|
+
return substituteStar(record[key], matched);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
function substituteStar(target, matched) {
|
|
191
|
+
if (typeof target === "string")
|
|
192
|
+
return target.split("*").join(matched);
|
|
193
|
+
if (Array.isArray(target))
|
|
194
|
+
return target.map((entry) => substituteStar(entry, matched));
|
|
195
|
+
if (target && typeof target === "object") {
|
|
196
|
+
const record = {};
|
|
197
|
+
for (const [key, value] of Object.entries(target))
|
|
198
|
+
record[key] = substituteStar(value, matched);
|
|
199
|
+
return record;
|
|
200
|
+
}
|
|
201
|
+
return target;
|
|
202
|
+
}
|
|
203
|
+
/** Pick a runtime string from a (possibly conditional) exports target. */
|
|
204
|
+
function resolveExportTarget(target) {
|
|
205
|
+
if (typeof target === "string")
|
|
206
|
+
return target;
|
|
207
|
+
if (Array.isArray(target)) {
|
|
208
|
+
for (const entry of target) {
|
|
209
|
+
const resolved = resolveExportTarget(entry);
|
|
210
|
+
if (resolved)
|
|
211
|
+
return resolved;
|
|
212
|
+
}
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
if (target && typeof target === "object") {
|
|
216
|
+
const record = target;
|
|
217
|
+
for (const condition of EXPORT_CONDITIONS) {
|
|
218
|
+
if (condition in record) {
|
|
219
|
+
const resolved = resolveExportTarget(record[condition]);
|
|
220
|
+
if (resolved)
|
|
221
|
+
return resolved;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Classify an import specifier. Known platform modules (extension modules and
|
|
229
|
+
* `node:` builtins) are left for code generation; relative paths and
|
|
230
|
+
* `node_modules` packages are resolved to a source file to bundle; a relative
|
|
231
|
+
* path that does not exist is an error.
|
|
232
|
+
*/
|
|
233
|
+
export function classifyDependency(fromDir, specifier, externalSpecifiers) {
|
|
234
|
+
if (specifier.startsWith("node:") || externalSpecifiers.has(specifier)) {
|
|
235
|
+
return { kind: "external" };
|
|
236
|
+
}
|
|
237
|
+
const resolved = isRelativeSpecifier(specifier)
|
|
238
|
+
? resolveModule(fromDir, specifier)
|
|
239
|
+
: resolveNodePackage(fromDir, specifier);
|
|
240
|
+
if (resolved)
|
|
241
|
+
return { kind: "file", path: resolved };
|
|
242
|
+
// A bare specifier that is not a file may still be a platform module the
|
|
243
|
+
// generator knows about (e.g. when the caller passes no extension registry).
|
|
244
|
+
return isRelativeSpecifier(specifier) ? { kind: "missing" } : { kind: "external" };
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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helpers: name extraction and declaration/reference
|
|
3
|
+
* renaming used while merging modules into a single file.
|
|
4
|
+
*/
|
|
5
|
+
import { ModifierKind, type Identifier, type Node } from "../../ast/nodes.js";
|
|
6
|
+
import type { SymbolInfo } from "../../binder/binder.js";
|
|
7
|
+
import type { ModuleRecord } from "./types.js";
|
|
8
|
+
export declare function hasModifier(node: Node, kind: ModifierKind): boolean;
|
|
9
|
+
export declare function declarationName(node: Node): Identifier | undefined;
|
|
10
|
+
/** Rewrite a symbol's declaration and every reference to `finalName`. */
|
|
11
|
+
export declare function renameSymbol(symbol: SymbolInfo, finalName: string): void;
|
|
12
|
+
/** Rewrite just the references of a symbol (used for imported names). */
|
|
13
|
+
export declare function renameReferences(symbol: SymbolInfo, finalName: string): void;
|
|
14
|
+
export declare function moduleScope(record: ModuleRecord): import("../../binder/types.js").Scope | undefined;
|
|
15
|
+
export declare function topLevelSymbols(record: ModuleRecord): SymbolInfo[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Top-level symbol helpers: name extraction and declaration/reference
|
|
3
|
+
* renaming used while merging modules into a single file.
|
|
4
|
+
*/
|
|
5
|
+
import { SyntaxKind } from "../../ast/nodes.js";
|
|
6
|
+
export function hasModifier(node, kind) {
|
|
7
|
+
const modifiers = node.modifiers;
|
|
8
|
+
return !!modifiers && modifiers.some((modifier) => modifier.modifierKind === kind);
|
|
9
|
+
}
|
|
10
|
+
export function declarationName(node) {
|
|
11
|
+
switch (node.kind) {
|
|
12
|
+
case SyntaxKind.FunctionDeclaration:
|
|
13
|
+
case SyntaxKind.ClassDeclaration:
|
|
14
|
+
case SyntaxKind.EnumDeclaration:
|
|
15
|
+
case SyntaxKind.InterfaceDeclaration:
|
|
16
|
+
case SyntaxKind.TypeAliasDeclaration:
|
|
17
|
+
case SyntaxKind.ModuleDeclaration:
|
|
18
|
+
return node.name;
|
|
19
|
+
case SyntaxKind.VariableDeclaration: {
|
|
20
|
+
const name = node.name;
|
|
21
|
+
return name.kind === SyntaxKind.Identifier ? name : undefined;
|
|
22
|
+
}
|
|
23
|
+
default:
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Rewrite a symbol's declaration and every reference to `finalName`. */
|
|
28
|
+
export function renameSymbol(symbol, finalName) {
|
|
29
|
+
for (const declaration of symbol.declarations) {
|
|
30
|
+
const name = declarationName(declaration);
|
|
31
|
+
if (name)
|
|
32
|
+
name.text = finalName;
|
|
33
|
+
}
|
|
34
|
+
for (const reference of symbol.references)
|
|
35
|
+
reference.text = finalName;
|
|
36
|
+
}
|
|
37
|
+
/** Rewrite just the references of a symbol (used for imported names). */
|
|
38
|
+
export function renameReferences(symbol, finalName) {
|
|
39
|
+
for (const reference of symbol.references)
|
|
40
|
+
reference.text = finalName;
|
|
41
|
+
}
|
|
42
|
+
export function moduleScope(record) {
|
|
43
|
+
return record.bind.scopes.get(record.sourceFile);
|
|
44
|
+
}
|
|
45
|
+
export function topLevelSymbols(record) {
|
|
46
|
+
const scope = moduleScope(record);
|
|
47
|
+
if (!scope)
|
|
48
|
+
return [];
|
|
49
|
+
return [...scope.symbols.values()];
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=symbols.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbols.js","sourceRoot":"","sources":["../../../../src/driver/bundler/symbols.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,UAAU,EAAwD,MAAM,oBAAoB,CAAC;AAIpH,MAAM,UAAU,WAAW,CAAC,IAAU,EAAE,IAAkB;IACxD,MAAM,SAAS,GAAI,IAAyD,CAAC,SAAS,CAAC;IACvF,OAAO,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAU;IACxC,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,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAoB;IAClD,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the source-level module bundler.
|
|
3
|
+
*/
|
|
4
|
+
import type { SourceFileNode } from "../../ast/nodes.js";
|
|
5
|
+
import type { BindResult } from "../../binder/binder.js";
|
|
6
|
+
export interface ModuleRecord {
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly text: string;
|
|
9
|
+
readonly sourceFile: SourceFileNode;
|
|
10
|
+
readonly bind: BindResult;
|
|
11
|
+
readonly prefix: string;
|
|
12
|
+
/** exported name -> final (renamed) local name */
|
|
13
|
+
readonly exports: Map<string, string>;
|
|
14
|
+
/** original local name of every top-level symbol */
|
|
15
|
+
readonly originalNames: Map<number, string>;
|
|
16
|
+
/** final name of every top-level symbol */
|
|
17
|
+
readonly finalNames: Map<number, string>;
|
|
18
|
+
}
|
|
19
|
+
export interface BundleResult {
|
|
20
|
+
readonly sourceFile: SourceFileNode;
|
|
21
|
+
readonly text: string;
|
|
22
|
+
readonly moduleCount: number;
|
|
23
|
+
}
|
|
24
|
+
export interface PackageJson {
|
|
25
|
+
readonly main?: string;
|
|
26
|
+
readonly module?: string;
|
|
27
|
+
readonly exports?: unknown;
|
|
28
|
+
}
|
|
29
|
+
export type DependencyResolution = {
|
|
30
|
+
readonly kind: "external";
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: "file";
|
|
33
|
+
readonly path: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "missing";
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/driver/bundler/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -6,20 +6,13 @@
|
|
|
6
6
|
* Each module's top-level bindings are renamed to a globally unique name and
|
|
7
7
|
* imported names are rewritten to the (renamed) exported binding.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export interface BundleResult {
|
|
17
|
-
readonly sourceFile: SourceFileNode;
|
|
18
|
-
readonly text: string;
|
|
19
|
-
readonly moduleCount: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Merge every module's statements into a single file. Dependencies come first
|
|
23
|
-
* (post-order over the import graph), the entry module last.
|
|
9
|
+
* The implementation lives under `bundler/` split by concern:
|
|
10
|
+
* resolve.ts specifier/path/package resolution
|
|
11
|
+
* graph.ts import-graph loading (parse + bind)
|
|
12
|
+
* symbols.ts top-level symbol renaming
|
|
13
|
+
* merge.ts the bundling passes themselves
|
|
14
|
+
*
|
|
15
|
+
* This file remains the public entry point for the driver and tests.
|
|
24
16
|
*/
|
|
25
|
-
export
|
|
17
|
+
export { bundleModules } from "./bundler/merge.js";
|
|
18
|
+
export type { BundleResult } from "./bundler/types.js";
|