@opentui/core 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/NativeSpanFeed.d.ts +4 -0
  2. package/{index-mn090kzf.js → index-59t85rvq.js} +3153 -2503
  3. package/index-59t85rvq.js.map +84 -0
  4. package/index.js +11256 -77
  5. package/index.js.map +29 -3
  6. package/lib/selection.d.ts +2 -1
  7. package/lib/singleton.d.ts +1 -0
  8. package/lib/tree-sitter/client.d.ts +17 -1
  9. package/lib/tree-sitter/index.d.ts +1 -0
  10. package/lib/tree-sitter/types.d.ts +104 -1
  11. package/lib/tree-sitter/update-assets.js +8 -6
  12. package/lib/tree-sitter/update-assets.js.map +3 -3
  13. package/package.json +27 -34
  14. package/parser.worker.js +452 -78
  15. package/parser.worker.js.map +8 -7
  16. package/platform/ffi.d.ts +6 -3
  17. package/platform/test.d.ts +12 -0
  18. package/platform/worker.d.ts +26 -4
  19. package/platform/worker.node-test.d.ts +1 -0
  20. package/renderables/Code.d.ts +4 -0
  21. package/renderables/Markdown.d.ts +1 -0
  22. package/runtime-plugin-support-configure.js +36 -18
  23. package/runtime-plugin-support-configure.js.map +1 -9
  24. package/runtime-plugin-support-configure.node.js +15 -0
  25. package/runtime-plugin-support.js +4 -19
  26. package/runtime-plugin-support.js.map +1 -10
  27. package/runtime-plugin-support.node.js +15 -0
  28. package/runtime-plugin.js +473 -16
  29. package/runtime-plugin.js.map +1 -9
  30. package/runtime-plugin.node.js +15 -0
  31. package/testing/bun-test-node.d.ts +87 -0
  32. package/testing/mock-tree-sitter-client.d.ts +4 -0
  33. package/testing.js +15 -9
  34. package/testing.js.map +3 -3
  35. package/zig.d.ts +1 -1
  36. package/index-jh82sd41.js +0 -44
  37. package/index-jh82sd41.js.map +0 -10
  38. package/index-mbck6rbg.js +0 -421
  39. package/index-mbck6rbg.js.map +0 -10
  40. package/index-mn090kzf.js.map +0 -84
  41. package/index-qndc8vq8.js +0 -11670
  42. package/index-qndc8vq8.js.map +0 -35
package/runtime-plugin.js CHANGED
@@ -1,16 +1,473 @@
1
- // @bun
2
- import {
3
- createRuntimePlugin,
4
- isCoreRuntimeModuleSpecifier,
5
- runtimeModuleIdForSpecifier
6
- } from "./index-mbck6rbg.js";
7
- import"./index-qndc8vq8.js";
8
- import"./index-mn090kzf.js";
9
- export {
10
- runtimeModuleIdForSpecifier,
11
- isCoreRuntimeModuleSpecifier,
12
- createRuntimePlugin
13
- };
14
-
15
- //# debugId=54AC4E2ADFC3366A64756E2164756E21
16
- //# sourceMappingURL=runtime-plugin.js.map
1
+ /*
2
+ * Exposes runtime-only modules (for example `@opentui/core`, `@opentui/solid`,
3
+ * `solid-js`) to externally loaded plugins by rewriting matching imports to
4
+ * virtual `opentui:runtime-module:*` ids.
5
+ *
6
+ * Why this is exact-path + prescan instead of one broad `onLoad`:
7
+ * - Bun can break CJS/UMD interop if a file is routed through plugin `onLoad`
8
+ * (real repro: `jsonc-parser` resolving to `lib/umd/main.js`;
9
+ * https://github.com/oven-sh/bun/issues/19279,
10
+ * https://github.com/oven-sh/bun/issues/21369), so arbitrary `node_modules`
11
+ * JS cannot be blanket-rewritten.
12
+ * - runtime `onResolve` is sync-only, so package/type/source discovery here is
13
+ * synchronous and cached.
14
+ * - a matched `onLoad` cannot safely fall through, so loaders must be narrow.
15
+ * - Bun may canonicalize paths before `onLoad`, so loaders are registered for
16
+ * both the resolved path spelling and its realpath, then canonical-checked.
17
+ * - Bun may native-load `node_modules` ESM without firing `onResolve` for
18
+ * nested package imports, so `node_modules` ESM is recursively prescanned and
19
+ * only files that actually need runtime rewriting get exact-path loaders.
20
+ *
21
+ * Behavior:
22
+ * - non-`node_modules` source files get a dedicated rewrite loader immediately.
23
+ * - `node_modules` files are rewritten only if they are ESM (`.mjs`, `.mts`,
24
+ * `.ts`, `.tsx`, `.jsx`, or `.js` under `package.json#type="module"`) and
25
+ * directly or transitively need runtime-module rewriting; unrelated CJS stays
26
+ * untouched.
27
+ * - optional bare-specifier rewriting is preserved for sibling files in
28
+ * packages already marked for runtime rewriting.
29
+ *
30
+ * Notes:
31
+ * - import scanning is regex-based, not a full parser.
32
+ * - CJS helper libraries that themselves import runtime modules are still not
33
+ * supported.
34
+ * - `package.json#type` caching is per plugin setup, not module-global, so a
35
+ * later plugin instance in the same process can observe filesystem changes.
36
+ */
37
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
38
+ import { basename, dirname, isAbsolute, join } from "node:path";
39
+ import { fileURLToPath } from "node:url";
40
+ import * as coreRuntime from "./index.js";
41
+ const CORE_RUNTIME_SPECIFIER = "@opentui/core";
42
+ const CORE_TESTING_RUNTIME_SPECIFIER = "@opentui/core/testing";
43
+ const RUNTIME_MODULE_PREFIX = "opentui:runtime-module:";
44
+ const MAX_RUNTIME_RESOLVE_PARENTS = 64;
45
+ const DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS = {
46
+ nodeModulesRuntimeSpecifiers: true,
47
+ nodeModulesBareSpecifiers: false,
48
+ };
49
+ const DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS = [CORE_RUNTIME_SPECIFIER, CORE_TESTING_RUNTIME_SPECIFIER];
50
+ const DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET = new Set(DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS);
51
+ export const isCoreRuntimeModuleSpecifier = (specifier) => {
52
+ return DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET.has(specifier);
53
+ };
54
+ const loadCoreTestingRuntimeModule = async () => {
55
+ return (await import("./testing.js"));
56
+ };
57
+ const escapeRegExp = (value) => {
58
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
59
+ };
60
+ const exactSpecifierFilter = (specifier) => {
61
+ return new RegExp(`^${escapeRegExp(specifier)}$`);
62
+ };
63
+ const exactPathFilter = (paths) => {
64
+ const candidates = [...new Set(paths.map(sourcePath))];
65
+ return new RegExp(`^(?:${candidates.map(escapeRegExp).join("|")})(?:[?#].*)?$`);
66
+ };
67
+ export const runtimeModuleIdForSpecifier = (specifier) => {
68
+ return `${RUNTIME_MODULE_PREFIX}${encodeURIComponent(specifier)}`;
69
+ };
70
+ const resolveRuntimeModuleExports = async (moduleEntry) => {
71
+ if (typeof moduleEntry === "function") {
72
+ return await moduleEntry();
73
+ }
74
+ return moduleEntry;
75
+ };
76
+ const sourcePath = (path) => {
77
+ const searchIndex = path.indexOf("?");
78
+ const hashIndex = path.indexOf("#");
79
+ const end = [searchIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0];
80
+ return end === undefined ? path : path.slice(0, end);
81
+ };
82
+ const normalizedSourcePathByPath = new Map();
83
+ const normalizeSourcePath = (path) => {
84
+ const cleanPath = sourcePath(path);
85
+ const cachedPath = normalizedSourcePathByPath.get(cleanPath);
86
+ if (cachedPath !== undefined) {
87
+ return cachedPath;
88
+ }
89
+ let normalizedPath = cleanPath;
90
+ try {
91
+ normalizedPath = realpathSync(cleanPath);
92
+ }
93
+ catch {
94
+ normalizedPath = cleanPath;
95
+ }
96
+ normalizedSourcePathByPath.set(cleanPath, normalizedPath);
97
+ return normalizedPath;
98
+ };
99
+ const isNodeModulesPath = (path) => {
100
+ return /(?:^|[/\\])node_modules(?:[/\\])/.test(path);
101
+ };
102
+ const packageTypeForPath = (path, packageTypeByPackageJsonPath) => {
103
+ let currentDir = dirname(path);
104
+ while (true) {
105
+ const packageJsonPath = join(currentDir, "package.json");
106
+ if (existsSync(packageJsonPath)) {
107
+ const cachedPackageType = packageTypeByPackageJsonPath.get(packageJsonPath);
108
+ if (cachedPackageType) {
109
+ return cachedPackageType;
110
+ }
111
+ let packageType = "commonjs";
112
+ try {
113
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
114
+ if (packageJson.type === "module") {
115
+ packageType = "module";
116
+ }
117
+ }
118
+ catch {
119
+ packageType = "commonjs";
120
+ }
121
+ packageTypeByPackageJsonPath.set(packageJsonPath, packageType);
122
+ return packageType;
123
+ }
124
+ const parentDir = dirname(currentDir);
125
+ if (parentDir === currentDir) {
126
+ return "commonjs";
127
+ }
128
+ currentDir = parentDir;
129
+ }
130
+ };
131
+ const isNodeModulesEsmPath = (path, packageTypeByPackageJsonPath) => {
132
+ const normalizedPath = normalizeSourcePath(path);
133
+ if (!isNodeModulesPath(normalizedPath)) {
134
+ return false;
135
+ }
136
+ if (normalizedPath.endsWith(".mjs") ||
137
+ normalizedPath.endsWith(".mts") ||
138
+ normalizedPath.endsWith(".ts") ||
139
+ normalizedPath.endsWith(".tsx") ||
140
+ normalizedPath.endsWith(".jsx")) {
141
+ return true;
142
+ }
143
+ if (normalizedPath.endsWith(".cjs") || normalizedPath.endsWith(".cts") || !normalizedPath.endsWith(".js")) {
144
+ return false;
145
+ }
146
+ return packageTypeForPath(normalizedPath, packageTypeByPackageJsonPath) === "module";
147
+ };
148
+ const nodeModulesPackageRootForPath = (path) => {
149
+ let currentDir = dirname(path);
150
+ while (true) {
151
+ const parentDir = dirname(currentDir);
152
+ if (parentDir === currentDir) {
153
+ return null;
154
+ }
155
+ if (basename(parentDir) === "node_modules") {
156
+ return currentDir;
157
+ }
158
+ if (basename(dirname(parentDir)) === "node_modules" && basename(parentDir).startsWith("@")) {
159
+ return currentDir;
160
+ }
161
+ currentDir = parentDir;
162
+ }
163
+ };
164
+ const resolveRuntimePluginRewriteOptions = (options) => {
165
+ return {
166
+ nodeModulesRuntimeSpecifiers: options?.nodeModulesRuntimeSpecifiers ?? DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS.nodeModulesRuntimeSpecifiers,
167
+ nodeModulesBareSpecifiers: options?.nodeModulesBareSpecifiers ?? DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS.nodeModulesBareSpecifiers,
168
+ };
169
+ };
170
+ const runtimeLoaderForPath = (path) => {
171
+ const cleanPath = sourcePath(path);
172
+ if (cleanPath.endsWith(".tsx")) {
173
+ return "tsx";
174
+ }
175
+ if (cleanPath.endsWith(".jsx")) {
176
+ return "jsx";
177
+ }
178
+ if (cleanPath.endsWith(".ts") || cleanPath.endsWith(".mts") || cleanPath.endsWith(".cts")) {
179
+ return "ts";
180
+ }
181
+ if (cleanPath.endsWith(".js") || cleanPath.endsWith(".mjs") || cleanPath.endsWith(".cjs")) {
182
+ return "js";
183
+ }
184
+ return null;
185
+ };
186
+ const resolveImportSpecifierPatterns = [
187
+ /(from\s+["'])([^"']+)(["'])/g,
188
+ /(import\s+["'])([^"']+)(["'])/g,
189
+ /(import\s*\(\s*["'])([^"']+)(["']\s*\))/g,
190
+ /(require\s*\(\s*["'])([^"']+)(["']\s*\))/g,
191
+ ];
192
+ const isBareSpecifier = (specifier) => {
193
+ if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("\\")) {
194
+ return false;
195
+ }
196
+ if (specifier.startsWith("node:") ||
197
+ specifier.startsWith("bun:") ||
198
+ specifier.startsWith("http:") ||
199
+ specifier.startsWith("https:") ||
200
+ specifier.startsWith("file:") ||
201
+ specifier.startsWith("data:")) {
202
+ return false;
203
+ }
204
+ if (specifier.startsWith(RUNTIME_MODULE_PREFIX)) {
205
+ return false;
206
+ }
207
+ return true;
208
+ };
209
+ const registerResolveParent = (resolveParentsByRecency, resolveParent) => {
210
+ const existingIndex = resolveParentsByRecency.indexOf(resolveParent);
211
+ if (existingIndex >= 0) {
212
+ resolveParentsByRecency.splice(existingIndex, 1);
213
+ }
214
+ resolveParentsByRecency.push(resolveParent);
215
+ if (resolveParentsByRecency.length > MAX_RUNTIME_RESOLVE_PARENTS) {
216
+ resolveParentsByRecency.shift();
217
+ }
218
+ };
219
+ const rewriteImportSpecifiers = (code, resolveReplacement) => {
220
+ let transformedCode = code;
221
+ for (const pattern of resolveImportSpecifierPatterns) {
222
+ transformedCode = transformedCode.replace(pattern, (fullMatch, prefix, specifier, suffix) => {
223
+ const replacement = resolveReplacement(specifier);
224
+ if (!replacement || replacement === specifier) {
225
+ return fullMatch;
226
+ }
227
+ return `${prefix}${replacement}${suffix}`;
228
+ });
229
+ }
230
+ return transformedCode;
231
+ };
232
+ const collectImportSpecifiers = (code) => {
233
+ const specifiers = new Set();
234
+ for (const pattern of resolveImportSpecifierPatterns) {
235
+ code.replace(pattern, (_fullMatch, _prefix, specifier) => {
236
+ specifiers.add(specifier);
237
+ return _fullMatch;
238
+ });
239
+ }
240
+ return [...specifiers];
241
+ };
242
+ const resolveFromParent = (specifier, parent) => {
243
+ try {
244
+ const resolvedSpecifier = import.meta.resolve(specifier, parent);
245
+ if (resolvedSpecifier === specifier ||
246
+ resolvedSpecifier.startsWith("node:") ||
247
+ resolvedSpecifier.startsWith("bun:")) {
248
+ return null;
249
+ }
250
+ return resolvedSpecifier;
251
+ }
252
+ catch {
253
+ return null;
254
+ }
255
+ };
256
+ const resolveSourcePathFromSpecifier = (specifier, importer) => {
257
+ if (specifier.startsWith("node:") ||
258
+ specifier.startsWith("bun:") ||
259
+ specifier.startsWith("http:") ||
260
+ specifier.startsWith("https:") ||
261
+ specifier.startsWith("data:") ||
262
+ specifier.startsWith(RUNTIME_MODULE_PREFIX)) {
263
+ return null;
264
+ }
265
+ if (specifier.startsWith("file:")) {
266
+ return sourcePath(fileURLToPath(specifier));
267
+ }
268
+ if (isAbsolute(specifier)) {
269
+ return sourcePath(specifier);
270
+ }
271
+ const resolvedSpecifier = resolveFromParent(specifier, importer);
272
+ if (!resolvedSpecifier) {
273
+ return null;
274
+ }
275
+ if (resolvedSpecifier.startsWith("file:")) {
276
+ return sourcePath(fileURLToPath(resolvedSpecifier));
277
+ }
278
+ if (isAbsolute(resolvedSpecifier)) {
279
+ return sourcePath(resolvedSpecifier);
280
+ }
281
+ return null;
282
+ };
283
+ const rewriteImportsFromResolveParents = (code, resolveParentsByRecency) => {
284
+ if (resolveParentsByRecency.length === 0) {
285
+ return code;
286
+ }
287
+ const resolveFromParents = (specifier) => {
288
+ if (!isBareSpecifier(specifier)) {
289
+ return null;
290
+ }
291
+ for (let index = resolveParentsByRecency.length - 1; index >= 0; index -= 1) {
292
+ const resolveParent = resolveParentsByRecency[index];
293
+ const resolvedSpecifier = resolveFromParent(specifier, resolveParent);
294
+ if (resolvedSpecifier) {
295
+ return resolvedSpecifier;
296
+ }
297
+ }
298
+ return null;
299
+ };
300
+ return rewriteImportSpecifiers(code, resolveFromParents);
301
+ };
302
+ const rewriteRuntimeSpecifiers = (code, runtimeModuleIdsBySpecifier) => {
303
+ return rewriteImportSpecifiers(code, (specifier) => {
304
+ const runtimeModuleId = runtimeModuleIdsBySpecifier.get(specifier);
305
+ return runtimeModuleId ?? null;
306
+ });
307
+ };
308
+ export function createRuntimePlugin(input = {}) {
309
+ const runtimeModules = new Map();
310
+ runtimeModules.set(CORE_RUNTIME_SPECIFIER, input.core ?? coreRuntime);
311
+ runtimeModules.set(CORE_TESTING_RUNTIME_SPECIFIER, loadCoreTestingRuntimeModule);
312
+ const rewriteOptions = resolveRuntimePluginRewriteOptions(input.rewrite);
313
+ for (const [specifier, moduleEntry] of Object.entries(input.additional ?? {})) {
314
+ runtimeModules.set(specifier, moduleEntry);
315
+ }
316
+ const runtimeModuleIdsBySpecifier = new Map();
317
+ for (const specifier of runtimeModules.keys()) {
318
+ runtimeModuleIdsBySpecifier.set(specifier, runtimeModuleIdForSpecifier(specifier));
319
+ }
320
+ return {
321
+ name: "bun-plugin-opentui-runtime-modules",
322
+ setup: (build) => {
323
+ const resolveParentsByRecency = [];
324
+ const installedRewriteLoaders = new Set();
325
+ const nodeModulesBareRewritePackageRoots = new Set();
326
+ const packageTypeByPackageJsonPath = new Map();
327
+ const sourceAnalysisByPath = new Map();
328
+ const nodeModulesRuntimeRewritePathsByPath = new Map();
329
+ const installRewriteLoader = (path) => {
330
+ const resolvedTargetPath = sourcePath(path);
331
+ const canonicalTargetPath = normalizeSourcePath(resolvedTargetPath);
332
+ if (installedRewriteLoaders.has(canonicalTargetPath)) {
333
+ return;
334
+ }
335
+ installedRewriteLoaders.add(canonicalTargetPath);
336
+ // Register both the resolved path spelling and its canonical realpath so Bun
337
+ // can reach the loader even if it reports the same file through a different alias.
338
+ build.onLoad({ filter: exactPathFilter([resolvedTargetPath, canonicalTargetPath]) }, async (args) => {
339
+ const loadedPath = normalizeSourcePath(args.path);
340
+ if (loadedPath !== canonicalTargetPath) {
341
+ return undefined;
342
+ }
343
+ const nodeModulesPath = isNodeModulesPath(loadedPath);
344
+ const shouldRewriteRuntimeSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesRuntimeSpecifiers;
345
+ const shouldRewriteBareSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesBareSpecifiers;
346
+ const loader = runtimeLoaderForPath(args.path);
347
+ if (!loader) {
348
+ throw new Error(`Unable to determine runtime loader for path: ${args.path}`);
349
+ }
350
+ const contents = await Bun.file(loadedPath).text();
351
+ const runtimeRewrittenContents = shouldRewriteRuntimeSpecifiers
352
+ ? rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier)
353
+ : contents;
354
+ if (runtimeRewrittenContents !== contents && shouldRewriteBareSpecifiers) {
355
+ registerResolveParent(resolveParentsByRecency, loadedPath);
356
+ }
357
+ const transformedContents = shouldRewriteBareSpecifiers
358
+ ? rewriteImportsFromResolveParents(runtimeRewrittenContents, resolveParentsByRecency)
359
+ : runtimeRewrittenContents;
360
+ return {
361
+ contents: transformedContents,
362
+ loader,
363
+ };
364
+ });
365
+ };
366
+ const analyzeSourcePath = (path) => {
367
+ const normalizedPath = normalizeSourcePath(path);
368
+ const cachedAnalysis = sourceAnalysisByPath.get(normalizedPath);
369
+ if (cachedAnalysis) {
370
+ return cachedAnalysis;
371
+ }
372
+ let contents;
373
+ try {
374
+ contents = readFileSync(normalizedPath, "utf8");
375
+ }
376
+ catch (error) {
377
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
378
+ const analysis = { importSpecifiers: [], needsRuntimeSpecifierRewrite: false };
379
+ sourceAnalysisByPath.set(normalizedPath, analysis);
380
+ return analysis;
381
+ }
382
+ throw error;
383
+ }
384
+ const importSpecifiers = collectImportSpecifiers(contents);
385
+ const analysis = {
386
+ importSpecifiers,
387
+ needsRuntimeSpecifierRewrite: importSpecifiers.some((specifier) => runtimeModuleIdsBySpecifier.has(specifier)),
388
+ };
389
+ sourceAnalysisByPath.set(normalizedPath, analysis);
390
+ return analysis;
391
+ };
392
+ const collectNodeModulesRuntimeRewritePaths = (path, visiting = new Set()) => {
393
+ const normalizedPath = normalizeSourcePath(path);
394
+ if (!isNodeModulesEsmPath(normalizedPath, packageTypeByPackageJsonPath)) {
395
+ return [];
396
+ }
397
+ const cachedPaths = nodeModulesRuntimeRewritePathsByPath.get(normalizedPath);
398
+ if (cachedPaths) {
399
+ return cachedPaths;
400
+ }
401
+ if (visiting.has(normalizedPath)) {
402
+ return [];
403
+ }
404
+ visiting.add(normalizedPath);
405
+ const rewritePaths = new Set();
406
+ const analysis = analyzeSourcePath(normalizedPath);
407
+ if (analysis.needsRuntimeSpecifierRewrite) {
408
+ rewritePaths.add(normalizedPath);
409
+ }
410
+ for (const specifier of analysis.importSpecifiers) {
411
+ const resolvedPath = resolveSourcePathFromSpecifier(specifier, normalizedPath);
412
+ if (!resolvedPath || !isNodeModulesEsmPath(resolvedPath, packageTypeByPackageJsonPath)) {
413
+ continue;
414
+ }
415
+ for (const nestedPath of collectNodeModulesRuntimeRewritePaths(resolvedPath, visiting)) {
416
+ rewritePaths.add(nestedPath);
417
+ }
418
+ }
419
+ visiting.delete(normalizedPath);
420
+ const resolvedRewritePaths = [...rewritePaths];
421
+ nodeModulesRuntimeRewritePathsByPath.set(normalizedPath, resolvedRewritePaths);
422
+ return resolvedRewritePaths;
423
+ };
424
+ for (const [specifier, moduleEntry] of runtimeModules.entries()) {
425
+ const moduleId = runtimeModuleIdsBySpecifier.get(specifier);
426
+ if (!moduleId) {
427
+ continue;
428
+ }
429
+ build.module(moduleId, async () => ({
430
+ exports: await resolveRuntimeModuleExports(moduleEntry),
431
+ loader: "object",
432
+ }));
433
+ build.onResolve({ filter: exactSpecifierFilter(specifier) }, () => ({ path: moduleId }));
434
+ }
435
+ build.onResolve({ filter: /.*/ }, (args) => {
436
+ if (runtimeModuleIdsBySpecifier.has(args.path) || args.path.startsWith(RUNTIME_MODULE_PREFIX)) {
437
+ return undefined;
438
+ }
439
+ const path = resolveSourcePathFromSpecifier(args.path, args.importer);
440
+ if (!path || !runtimeLoaderForPath(path)) {
441
+ return undefined;
442
+ }
443
+ const nodeModulesPath = isNodeModulesPath(path);
444
+ if (!nodeModulesPath) {
445
+ installRewriteLoader(path);
446
+ return undefined;
447
+ }
448
+ if (!rewriteOptions.nodeModulesRuntimeSpecifiers && !rewriteOptions.nodeModulesBareSpecifiers) {
449
+ return undefined;
450
+ }
451
+ for (const rewritePath of collectNodeModulesRuntimeRewritePaths(path)) {
452
+ installRewriteLoader(rewritePath);
453
+ }
454
+ const packageRoot = nodeModulesPackageRootForPath(path);
455
+ if (rewriteOptions.nodeModulesBareSpecifiers &&
456
+ packageRoot &&
457
+ nodeModulesBareRewritePackageRoots.has(packageRoot)) {
458
+ installRewriteLoader(path);
459
+ return undefined;
460
+ }
461
+ if (!rewriteOptions.nodeModulesRuntimeSpecifiers || !analyzeSourcePath(path).needsRuntimeSpecifierRewrite) {
462
+ return undefined;
463
+ }
464
+ if (rewriteOptions.nodeModulesBareSpecifiers && packageRoot) {
465
+ nodeModulesBareRewritePackageRoots.add(packageRoot);
466
+ }
467
+ installRewriteLoader(path);
468
+ return undefined;
469
+ });
470
+ },
471
+ };
472
+ }
473
+ //# sourceMappingURL=runtime-plugin.js.map
@@ -1,9 +1 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [
5
- ],
6
- "mappings": "",
7
- "debugId": "54AC4E2ADFC3366A64756E2164756E21",
8
- "names": []
9
- }
1
+ {"version":3,"file":"runtime-plugin.js","sourceRoot":"","sources":["runtime-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA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opentui/core/runtime-plugin is Bun-only and is not available in Node.js. Use Bun to import this entrypoint."
2
+
3
+ export function createRuntimePlugin() {
4
+ throw new Error("@opentui/core/runtime-plugin is Bun-only and is not available in Node.js. Use Bun to import this entrypoint.")
5
+ }
6
+
7
+ export function isCoreRuntimeModuleSpecifier() {
8
+ throw new Error("@opentui/core/runtime-plugin is Bun-only and is not available in Node.js. Use Bun to import this entrypoint.")
9
+ }
10
+
11
+ export function runtimeModuleIdForSpecifier() {
12
+ throw new Error("@opentui/core/runtime-plugin is Bun-only and is not available in Node.js. Use Bun to import this entrypoint.")
13
+ }
14
+
15
+ throw new Error(errorMessage)
@@ -0,0 +1,87 @@
1
+ import { after, afterEach, before, beforeEach, describe as nodeDescribe, test as nodeTest } from "node:test";
2
+ type AnyFunction = (...args: any[]) => any;
3
+ type ThrowMatcher = RegExp | string | Error | ((value: unknown) => boolean) | (new (...args: any[]) => Error);
4
+ declare const asymmetricMatcher: unique symbol;
5
+ interface AsymmetricMatcher {
6
+ readonly [asymmetricMatcher]: true;
7
+ matches(received: unknown): boolean;
8
+ }
9
+ interface MockedFunction<Fn extends AnyFunction = AnyFunction> {
10
+ (...args: Parameters<Fn>): ReturnType<Fn>;
11
+ mock: {
12
+ calls: unknown[][];
13
+ };
14
+ mockImplementation(implementation: Fn): MockedFunction<Fn>;
15
+ mockRestore(): void;
16
+ mockClear(): void;
17
+ }
18
+ declare function createEach(base: AnyFunction): (cases: readonly unknown[]) => (name: string, optionsOrFn?: unknown, maybeFn?: unknown) => void;
19
+ declare class AsyncExpectation<T> {
20
+ private readonly received;
21
+ private readonly mode;
22
+ private readonly inverted;
23
+ constructor(received: PromiseLike<T> | T, mode: "resolves" | "rejects", inverted?: boolean);
24
+ get not(): AsyncExpectation<T>;
25
+ toBe(expected: unknown): Promise<void>;
26
+ toEqual(expected: unknown): Promise<void>;
27
+ toBeNull(): Promise<void>;
28
+ toBeUndefined(): Promise<void>;
29
+ toContain(expected: unknown): Promise<void>;
30
+ toMatchSnapshot(snapshotName?: string): Promise<void>;
31
+ toMatchInlineSnapshot(snapshot: string): Promise<void>;
32
+ toThrow(expected?: ThrowMatcher): Promise<void>;
33
+ toHaveBeenCalled(): Promise<void>;
34
+ toHaveBeenCalledTimes(expected: number): Promise<void>;
35
+ toHaveBeenCalledWith(...expectedArgs: unknown[]): Promise<void>;
36
+ private unwrap;
37
+ }
38
+ declare class Expectation<T> {
39
+ private readonly received;
40
+ private readonly inverted;
41
+ constructor(received: T, inverted?: boolean);
42
+ get not(): Expectation<T>;
43
+ get resolves(): AsyncExpectation<T>;
44
+ get rejects(): AsyncExpectation<T>;
45
+ toBe(expected: unknown): void;
46
+ toEqual(expected: unknown): void;
47
+ toBeNull(): void;
48
+ toBeUndefined(): void;
49
+ toBeDefined(): void;
50
+ toContain(expected: unknown): void;
51
+ toHaveLength(expected: number): void;
52
+ toBeInstanceOf(expected: new (...args: any[]) => unknown): void;
53
+ toMatchObject(expected: object): void;
54
+ toBeTruthy(): void;
55
+ toBeFalsy(): void;
56
+ toBeGreaterThan(expected: number | bigint): void;
57
+ toBeGreaterThanOrEqual(expected: number | bigint): void;
58
+ toBeLessThan(expected: number | bigint): void;
59
+ toBeLessThanOrEqual(expected: number | bigint): void;
60
+ toBeCloseTo(expected: number, precision?: number): void;
61
+ toMatch(expected: RegExp | string): void;
62
+ toMatchSnapshot(snapshotName?: string): void;
63
+ toMatchInlineSnapshot(snapshot: string): void;
64
+ toThrow(expected?: ThrowMatcher): void;
65
+ toHaveBeenCalled(): void;
66
+ toHaveBeenCalledTimes(expected: number): void;
67
+ toHaveBeenCalledWith(...expectedArgs: unknown[]): void;
68
+ toHaveProperty(property: PropertyKey, expectedValue?: unknown): void;
69
+ private assertMatch;
70
+ }
71
+ interface ExpectApi {
72
+ <T>(received: T): Expectation<T>;
73
+ any(expectedType: unknown): AsymmetricMatcher;
74
+ }
75
+ export declare const expect: ExpectApi;
76
+ export declare function mock<Fn extends AnyFunction = () => undefined>(implementation?: Fn): MockedFunction<Fn>;
77
+ export declare function spyOn(object: object, key: string | symbol): MockedFunction;
78
+ export declare const beforeAll: typeof before;
79
+ export declare const afterAll: typeof after;
80
+ export declare const test: typeof nodeTest & {
81
+ each: ReturnType<typeof createEach>;
82
+ };
83
+ export declare const it: typeof nodeTest & {
84
+ each: ReturnType<typeof createEach>;
85
+ };
86
+ export declare const describe: typeof nodeDescribe;
87
+ export { afterEach, beforeEach };
@@ -1,12 +1,16 @@
1
1
  import { TreeSitterClient } from "../lib/tree-sitter/index.js";
2
+ import { type Clock } from "../lib/clock.js";
2
3
  import type { SimpleHighlight } from "../lib/tree-sitter/types.js";
3
4
  export declare class MockTreeSitterClient extends TreeSitterClient {
4
5
  private _highlightPromises;
5
6
  private _mockResult;
6
7
  private _autoResolveTimeout?;
8
+ private readonly _clock;
7
9
  constructor(options?: {
8
10
  autoResolveTimeout?: number;
11
+ clock?: Clock;
9
12
  });
13
+ destroy(): Promise<void>;
10
14
  highlightOnce(content: string, filetype: string): Promise<{
11
15
  highlights?: SimpleHighlight[];
12
16
  warning?: string;