@opentui/core 0.0.0-20260331-98e5d2ed → 0.0.0-20260405-92749c32

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/3d.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  __export,
7
7
  __require,
8
8
  __toESM
9
- } from "./index-wv534m5j.js";
9
+ } from "./index-5s2g3z4r.js";
10
10
 
11
11
  // ../../node_modules/.bun/omggif@1.0.10/node_modules/omggif/omggif.js
12
12
  var require_omggif = __commonJS((exports) => {
@@ -1,12 +1,15 @@
1
1
  // @bun
2
2
  import {
3
3
  exports_src
4
- } from "./index-t2rqapaa.js";
4
+ } from "./index-tfxhv5e0.js";
5
5
  import {
6
6
  __require
7
- } from "./index-wv534m5j.js";
7
+ } from "./index-5s2g3z4r.js";
8
8
 
9
9
  // src/runtime-plugin.ts
10
+ import { readFileSync, realpathSync } from "fs";
11
+ import { basename, dirname, isAbsolute } from "path";
12
+ import { fileURLToPath } from "url";
10
13
  var CORE_RUNTIME_SPECIFIER = "@opentui/core";
11
14
  var CORE_TESTING_RUNTIME_SPECIFIER = "@opentui/core/testing";
12
15
  var RUNTIME_MODULE_PREFIX = "opentui:runtime-module:";
@@ -29,6 +32,18 @@ var escapeRegExp = (value) => {
29
32
  var exactSpecifierFilter = (specifier) => {
30
33
  return new RegExp(`^${escapeRegExp(specifier)}$`);
31
34
  };
35
+ var exactPathFilter = (path) => {
36
+ const variants = new Set([sourcePath(path), normalizeSourcePath(path)]);
37
+ for (const variant of [...variants]) {
38
+ if (variant.startsWith("/var/")) {
39
+ variants.add(`/private${variant}`);
40
+ }
41
+ if (variant.startsWith("/private/var/")) {
42
+ variants.add(variant.slice("/private".length));
43
+ }
44
+ }
45
+ return new RegExp(`^(?:${[...variants].map(escapeRegExp).join("|")})(?:[?#].*)?$`);
46
+ };
32
47
  var runtimeModuleIdForSpecifier = (specifier) => {
33
48
  return `${RUNTIME_MODULE_PREFIX}${encodeURIComponent(specifier)}`;
34
49
  };
@@ -44,9 +59,33 @@ var sourcePath = (path) => {
44
59
  const end = [searchIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0];
45
60
  return end === undefined ? path : path.slice(0, end);
46
61
  };
62
+ var normalizeSourcePath = (path) => {
63
+ const cleanPath = sourcePath(path);
64
+ try {
65
+ return realpathSync(cleanPath);
66
+ } catch {
67
+ return cleanPath;
68
+ }
69
+ };
47
70
  var isNodeModulesPath = (path) => {
48
71
  return /(?:^|[/\\])node_modules(?:[/\\])/.test(path);
49
72
  };
73
+ var nodeModulesPackageRootForPath = (path) => {
74
+ let currentDir = dirname(path);
75
+ while (true) {
76
+ const parentDir = dirname(currentDir);
77
+ if (parentDir === currentDir) {
78
+ return null;
79
+ }
80
+ if (basename(parentDir) === "node_modules") {
81
+ return currentDir;
82
+ }
83
+ if (basename(dirname(parentDir)) === "node_modules" && basename(parentDir).startsWith("@")) {
84
+ return currentDir;
85
+ }
86
+ currentDir = parentDir;
87
+ }
88
+ };
50
89
  var resolveRuntimePluginRewriteOptions = (options) => {
51
90
  return {
52
91
  nodeModulesRuntimeSpecifiers: options?.nodeModulesRuntimeSpecifiers ?? DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS.nodeModulesRuntimeSpecifiers,
@@ -69,7 +108,6 @@ var runtimeLoaderForPath = (path) => {
69
108
  }
70
109
  return null;
71
110
  };
72
- var runtimeSourceFilter = /\.(?:[cm]?js|[cm]?ts|jsx|tsx)(?:[?#].*)?$/;
73
111
  var resolveImportSpecifierPatterns = [
74
112
  /(from\s+["'])([^"']+)(["'])/g,
75
113
  /(import\s+["'])([^"']+)(["'])/g,
@@ -122,6 +160,28 @@ var resolveFromParent = (specifier, parent) => {
122
160
  return null;
123
161
  }
124
162
  };
163
+ var resolveSourcePathFromSpecifier = (specifier, importer) => {
164
+ if (specifier.startsWith("node:") || specifier.startsWith("bun:") || specifier.startsWith("http:") || specifier.startsWith("https:") || specifier.startsWith("data:") || specifier.startsWith(RUNTIME_MODULE_PREFIX)) {
165
+ return null;
166
+ }
167
+ if (specifier.startsWith("file:")) {
168
+ return normalizeSourcePath(fileURLToPath(specifier));
169
+ }
170
+ if (isAbsolute(specifier)) {
171
+ return normalizeSourcePath(specifier);
172
+ }
173
+ const resolvedSpecifier = resolveFromParent(specifier, importer);
174
+ if (!resolvedSpecifier) {
175
+ return null;
176
+ }
177
+ if (resolvedSpecifier.startsWith("file:")) {
178
+ return normalizeSourcePath(fileURLToPath(resolvedSpecifier));
179
+ }
180
+ if (isAbsolute(resolvedSpecifier)) {
181
+ return normalizeSourcePath(resolvedSpecifier);
182
+ }
183
+ return null;
184
+ };
125
185
  var rewriteImportsFromResolveParents = (code, resolveParentsByRecency) => {
126
186
  if (resolveParentsByRecency.length === 0) {
127
187
  return code;
@@ -163,6 +223,47 @@ function createRuntimePlugin(input = {}) {
163
223
  name: "bun-plugin-opentui-runtime-modules",
164
224
  setup: (build) => {
165
225
  const resolveParentsByRecency = [];
226
+ const installedRewriteLoaders = new Set;
227
+ const nodeModulesBareRewritePackageRoots = new Set;
228
+ const runtimeSpecifierRewriteNeededByPath = new Map;
229
+ const installRewriteLoader = (path) => {
230
+ const normalizedPath = normalizeSourcePath(path);
231
+ if (installedRewriteLoaders.has(normalizedPath)) {
232
+ return;
233
+ }
234
+ installedRewriteLoaders.add(normalizedPath);
235
+ build.onLoad({ filter: exactPathFilter(normalizedPath) }, async (args) => {
236
+ const path2 = normalizeSourcePath(args.path);
237
+ const nodeModulesPath = isNodeModulesPath(path2);
238
+ const shouldRewriteRuntimeSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesRuntimeSpecifiers;
239
+ const shouldRewriteBareSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesBareSpecifiers;
240
+ const loader = runtimeLoaderForPath(args.path);
241
+ if (!loader) {
242
+ throw new Error(`Unable to determine runtime loader for path: ${args.path}`);
243
+ }
244
+ const contents = await Bun.file(path2).text();
245
+ const runtimeRewrittenContents = shouldRewriteRuntimeSpecifiers ? rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier) : contents;
246
+ if (runtimeRewrittenContents !== contents && shouldRewriteBareSpecifiers) {
247
+ registerResolveParent(resolveParentsByRecency, path2);
248
+ }
249
+ const transformedContents = shouldRewriteBareSpecifiers ? rewriteImportsFromResolveParents(runtimeRewrittenContents, resolveParentsByRecency) : runtimeRewrittenContents;
250
+ return {
251
+ contents: transformedContents,
252
+ loader
253
+ };
254
+ });
255
+ };
256
+ const needsRuntimeSpecifierRewrite = (path) => {
257
+ const normalizedPath = normalizeSourcePath(path);
258
+ const cached = runtimeSpecifierRewriteNeededByPath.get(normalizedPath);
259
+ if (cached !== undefined) {
260
+ return cached;
261
+ }
262
+ const contents = readFileSync(normalizedPath, "utf8");
263
+ const needsRewrite = rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier) !== contents;
264
+ runtimeSpecifierRewriteNeededByPath.set(normalizedPath, needsRewrite);
265
+ return needsRewrite;
266
+ };
166
267
  for (const [specifier, moduleEntry] of runtimeModules.entries()) {
167
268
  const moduleId = runtimeModuleIdsBySpecifier.get(specifier);
168
269
  if (!moduleId) {
@@ -174,29 +275,35 @@ function createRuntimePlugin(input = {}) {
174
275
  }));
175
276
  build.onResolve({ filter: exactSpecifierFilter(specifier) }, () => ({ path: moduleId }));
176
277
  }
177
- build.onLoad({ filter: runtimeSourceFilter }, async (args) => {
178
- const path = sourcePath(args.path);
278
+ build.onResolve({ filter: /.*/ }, (args) => {
279
+ if (runtimeModuleIdsBySpecifier.has(args.path) || args.path.startsWith(RUNTIME_MODULE_PREFIX)) {
280
+ return;
281
+ }
282
+ const path = resolveSourcePathFromSpecifier(args.path, args.importer);
283
+ if (!path || !runtimeLoaderForPath(path)) {
284
+ return;
285
+ }
179
286
  const nodeModulesPath = isNodeModulesPath(path);
180
- const shouldRewriteRuntimeSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesRuntimeSpecifiers;
181
- const shouldRewriteBareSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesBareSpecifiers;
182
- if (!shouldRewriteRuntimeSpecifiers && !shouldRewriteBareSpecifiers) {
287
+ if (!nodeModulesPath) {
288
+ installRewriteLoader(path);
183
289
  return;
184
290
  }
185
- const loader = runtimeLoaderForPath(args.path);
186
- if (!loader) {
187
- throw new Error(`Unable to determine runtime loader for path: ${args.path}`);
291
+ if (!rewriteOptions.nodeModulesRuntimeSpecifiers && !rewriteOptions.nodeModulesBareSpecifiers) {
292
+ return;
293
+ }
294
+ const packageRoot = nodeModulesPackageRootForPath(path);
295
+ if (rewriteOptions.nodeModulesBareSpecifiers && packageRoot && nodeModulesBareRewritePackageRoots.has(packageRoot)) {
296
+ installRewriteLoader(path);
297
+ return;
298
+ }
299
+ if (!rewriteOptions.nodeModulesRuntimeSpecifiers || !needsRuntimeSpecifierRewrite(path)) {
300
+ return;
188
301
  }
189
- const file = Bun.file(path);
190
- const contents = await file.text();
191
- const runtimeRewrittenContents = shouldRewriteRuntimeSpecifiers ? rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier) : contents;
192
- if (runtimeRewrittenContents !== contents && shouldRewriteBareSpecifiers) {
193
- registerResolveParent(resolveParentsByRecency, path);
302
+ if (rewriteOptions.nodeModulesBareSpecifiers && packageRoot) {
303
+ nodeModulesBareRewritePackageRoots.add(packageRoot);
194
304
  }
195
- const transformedContents = shouldRewriteBareSpecifiers ? rewriteImportsFromResolveParents(runtimeRewrittenContents, resolveParentsByRecency) : runtimeRewrittenContents;
196
- return {
197
- contents: transformedContents,
198
- loader
199
- };
305
+ installRewriteLoader(path);
306
+ return;
200
307
  });
201
308
  }
202
309
  };
@@ -204,5 +311,5 @@ function createRuntimePlugin(input = {}) {
204
311
 
205
312
  export { isCoreRuntimeModuleSpecifier, runtimeModuleIdForSpecifier, createRuntimePlugin };
206
313
 
207
- //# debugId=28B0B69C36E6FDF764756E2164756E21
208
- //# sourceMappingURL=index-d991k25n.js.map
314
+ //# debugId=51B6742CA164953664756E2164756E21
315
+ //# sourceMappingURL=index-4zdxp7xb.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/runtime-plugin.ts"],
4
+ "sourcesContent": [
5
+ "import { readFileSync, realpathSync } from \"node:fs\"\nimport { basename, dirname, isAbsolute } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\nimport { type BunPlugin } from \"bun\"\nimport * as coreRuntime from \"./index.js\"\n\nexport type RuntimeModuleExports = Record<string, unknown>\nexport type RuntimeModuleLoader = () => RuntimeModuleExports | Promise<RuntimeModuleExports>\nexport type RuntimeModuleEntry = RuntimeModuleExports | RuntimeModuleLoader\n\nexport interface RuntimePluginRewriteOptions {\n nodeModulesRuntimeSpecifiers?: boolean\n nodeModulesBareSpecifiers?: boolean\n}\n\nexport interface CreateRuntimePluginOptions {\n core?: RuntimeModuleEntry\n additional?: Record<string, RuntimeModuleEntry>\n rewrite?: RuntimePluginRewriteOptions\n}\n\nconst CORE_RUNTIME_SPECIFIER = \"@opentui/core\"\nconst CORE_TESTING_RUNTIME_SPECIFIER = \"@opentui/core/testing\"\nconst RUNTIME_MODULE_PREFIX = \"opentui:runtime-module:\"\nconst MAX_RUNTIME_RESOLVE_PARENTS = 64\nconst DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS: Required<RuntimePluginRewriteOptions> = {\n nodeModulesRuntimeSpecifiers: true,\n nodeModulesBareSpecifiers: false,\n}\n\nconst DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS = [CORE_RUNTIME_SPECIFIER, CORE_TESTING_RUNTIME_SPECIFIER] as const\n\nconst DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET = new Set<string>(DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS)\n\nexport const isCoreRuntimeModuleSpecifier = (specifier: string): boolean => {\n return DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET.has(specifier)\n}\n\nconst loadCoreTestingRuntimeModule = async (): Promise<RuntimeModuleExports> => {\n return (await import(\"./testing.js\")) as RuntimeModuleExports\n}\n\nconst escapeRegExp = (value: string): string => {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n}\n\nconst exactSpecifierFilter = (specifier: string): RegExp => {\n return new RegExp(`^${escapeRegExp(specifier)}$`)\n}\n\nconst exactPathFilter = (path: string): RegExp => {\n const variants = new Set<string>([sourcePath(path), normalizeSourcePath(path)])\n\n for (const variant of [...variants]) {\n if (variant.startsWith(\"/var/\")) {\n variants.add(`/private${variant}`)\n }\n\n if (variant.startsWith(\"/private/var/\")) {\n variants.add(variant.slice(\"/private\".length))\n }\n }\n\n return new RegExp(`^(?:${[...variants].map(escapeRegExp).join(\"|\")})(?:[?#].*)?$`)\n}\n\nexport const runtimeModuleIdForSpecifier = (specifier: string): string => {\n return `${RUNTIME_MODULE_PREFIX}${encodeURIComponent(specifier)}`\n}\n\nconst resolveRuntimeModuleExports = async (moduleEntry: RuntimeModuleEntry): Promise<RuntimeModuleExports> => {\n if (typeof moduleEntry === \"function\") {\n return await moduleEntry()\n }\n\n return moduleEntry\n}\n\nconst sourcePath = (path: string): string => {\n const searchIndex = path.indexOf(\"?\")\n const hashIndex = path.indexOf(\"#\")\n const end = [searchIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0]\n return end === undefined ? path : path.slice(0, end)\n}\n\nconst normalizeSourcePath = (path: string): string => {\n const cleanPath = sourcePath(path)\n\n try {\n return realpathSync(cleanPath)\n } catch {\n return cleanPath\n }\n}\n\nconst isNodeModulesPath = (path: string): boolean => {\n return /(?:^|[/\\\\])node_modules(?:[/\\\\])/.test(path)\n}\n\nconst nodeModulesPackageRootForPath = (path: string): string | null => {\n let currentDir = dirname(path)\n\n while (true) {\n const parentDir = dirname(currentDir)\n if (parentDir === currentDir) {\n return null\n }\n\n if (basename(parentDir) === \"node_modules\") {\n return currentDir\n }\n\n if (basename(dirname(parentDir)) === \"node_modules\" && basename(parentDir).startsWith(\"@\")) {\n return currentDir\n }\n\n currentDir = parentDir\n }\n}\n\nconst resolveRuntimePluginRewriteOptions = (\n options: RuntimePluginRewriteOptions | undefined,\n): Required<RuntimePluginRewriteOptions> => {\n return {\n nodeModulesRuntimeSpecifiers:\n options?.nodeModulesRuntimeSpecifiers ?? DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS.nodeModulesRuntimeSpecifiers,\n nodeModulesBareSpecifiers:\n options?.nodeModulesBareSpecifiers ?? DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS.nodeModulesBareSpecifiers,\n }\n}\n\nconst runtimeLoaderForPath = (path: string): \"js\" | \"ts\" | \"jsx\" | \"tsx\" | null => {\n const cleanPath = sourcePath(path)\n\n if (cleanPath.endsWith(\".tsx\")) {\n return \"tsx\"\n }\n\n if (cleanPath.endsWith(\".jsx\")) {\n return \"jsx\"\n }\n\n if (cleanPath.endsWith(\".ts\") || cleanPath.endsWith(\".mts\") || cleanPath.endsWith(\".cts\")) {\n return \"ts\"\n }\n\n if (cleanPath.endsWith(\".js\") || cleanPath.endsWith(\".mjs\") || cleanPath.endsWith(\".cjs\")) {\n return \"js\"\n }\n\n return null\n}\n\nconst resolveImportSpecifierPatterns = [\n /(from\\s+[\"'])([^\"']+)([\"'])/g,\n /(import\\s+[\"'])([^\"']+)([\"'])/g,\n /(import\\s*\\(\\s*[\"'])([^\"']+)([\"']\\s*\\))/g,\n /(require\\s*\\(\\s*[\"'])([^\"']+)([\"']\\s*\\))/g,\n] as const\n\nconst isBareSpecifier = (specifier: string): boolean => {\n if (specifier.startsWith(\".\") || specifier.startsWith(\"/\") || specifier.startsWith(\"\\\\\")) {\n return false\n }\n\n if (\n specifier.startsWith(\"node:\") ||\n specifier.startsWith(\"bun:\") ||\n specifier.startsWith(\"http:\") ||\n specifier.startsWith(\"https:\") ||\n specifier.startsWith(\"file:\") ||\n specifier.startsWith(\"data:\")\n ) {\n return false\n }\n\n if (specifier.startsWith(RUNTIME_MODULE_PREFIX)) {\n return false\n }\n\n return true\n}\n\nconst registerResolveParent = (resolveParentsByRecency: string[], resolveParent: string): void => {\n const existingIndex = resolveParentsByRecency.indexOf(resolveParent)\n if (existingIndex >= 0) {\n resolveParentsByRecency.splice(existingIndex, 1)\n }\n\n resolveParentsByRecency.push(resolveParent)\n\n if (resolveParentsByRecency.length > MAX_RUNTIME_RESOLVE_PARENTS) {\n resolveParentsByRecency.shift()\n }\n}\n\nconst rewriteImportSpecifiers = (code: string, resolveReplacement: (specifier: string) => string | null): string => {\n let transformedCode = code\n\n for (const pattern of resolveImportSpecifierPatterns) {\n transformedCode = transformedCode.replace(pattern, (fullMatch, prefix, specifier, suffix) => {\n const replacement = resolveReplacement(specifier)\n if (!replacement || replacement === specifier) {\n return fullMatch\n }\n\n return `${prefix}${replacement}${suffix}`\n })\n }\n\n return transformedCode\n}\n\nconst resolveFromParent = (specifier: string, parent: string): string | null => {\n try {\n const resolvedSpecifier = import.meta.resolve(specifier, parent)\n if (\n resolvedSpecifier === specifier ||\n resolvedSpecifier.startsWith(\"node:\") ||\n resolvedSpecifier.startsWith(\"bun:\")\n ) {\n return null\n }\n\n return resolvedSpecifier\n } catch {\n return null\n }\n}\n\nconst resolveSourcePathFromSpecifier = (specifier: string, importer: string): string | null => {\n if (\n specifier.startsWith(\"node:\") ||\n specifier.startsWith(\"bun:\") ||\n specifier.startsWith(\"http:\") ||\n specifier.startsWith(\"https:\") ||\n specifier.startsWith(\"data:\") ||\n specifier.startsWith(RUNTIME_MODULE_PREFIX)\n ) {\n return null\n }\n\n if (specifier.startsWith(\"file:\")) {\n return normalizeSourcePath(fileURLToPath(specifier))\n }\n\n if (isAbsolute(specifier)) {\n return normalizeSourcePath(specifier)\n }\n\n const resolvedSpecifier = resolveFromParent(specifier, importer)\n if (!resolvedSpecifier) {\n return null\n }\n\n if (resolvedSpecifier.startsWith(\"file:\")) {\n return normalizeSourcePath(fileURLToPath(resolvedSpecifier))\n }\n\n if (isAbsolute(resolvedSpecifier)) {\n return normalizeSourcePath(resolvedSpecifier)\n }\n\n return null\n}\n\nconst rewriteImportsFromResolveParents = (code: string, resolveParentsByRecency: string[]): string => {\n if (resolveParentsByRecency.length === 0) {\n return code\n }\n\n const resolveFromParents = (specifier: string): string | null => {\n if (!isBareSpecifier(specifier)) {\n return null\n }\n\n for (let index = resolveParentsByRecency.length - 1; index >= 0; index -= 1) {\n const resolveParent = resolveParentsByRecency[index]\n const resolvedSpecifier = resolveFromParent(specifier, resolveParent)\n if (resolvedSpecifier) {\n return resolvedSpecifier\n }\n }\n\n return null\n }\n\n return rewriteImportSpecifiers(code, resolveFromParents)\n}\n\nconst rewriteRuntimeSpecifiers = (code: string, runtimeModuleIdsBySpecifier: Map<string, string>): string => {\n return rewriteImportSpecifiers(code, (specifier) => {\n const runtimeModuleId = runtimeModuleIdsBySpecifier.get(specifier)\n return runtimeModuleId ?? null\n })\n}\n\nexport function createRuntimePlugin(input: CreateRuntimePluginOptions = {}): BunPlugin {\n const runtimeModules = new Map<string, RuntimeModuleEntry>()\n runtimeModules.set(CORE_RUNTIME_SPECIFIER, input.core ?? (coreRuntime as RuntimeModuleExports))\n runtimeModules.set(CORE_TESTING_RUNTIME_SPECIFIER, loadCoreTestingRuntimeModule)\n const rewriteOptions = resolveRuntimePluginRewriteOptions(input.rewrite)\n\n for (const [specifier, moduleEntry] of Object.entries(input.additional ?? {})) {\n runtimeModules.set(specifier, moduleEntry)\n }\n\n const runtimeModuleIdsBySpecifier = new Map<string, string>()\n for (const specifier of runtimeModules.keys()) {\n runtimeModuleIdsBySpecifier.set(specifier, runtimeModuleIdForSpecifier(specifier))\n }\n\n return {\n name: \"bun-plugin-opentui-runtime-modules\",\n setup: (build) => {\n const resolveParentsByRecency: string[] = []\n const installedRewriteLoaders = new Set<string>()\n const nodeModulesBareRewritePackageRoots = new Set<string>()\n const runtimeSpecifierRewriteNeededByPath = new Map<string, boolean>()\n\n const installRewriteLoader = (path: string): void => {\n const normalizedPath = normalizeSourcePath(path)\n if (installedRewriteLoaders.has(normalizedPath)) {\n return\n }\n\n installedRewriteLoaders.add(normalizedPath)\n\n build.onLoad({ filter: exactPathFilter(normalizedPath) }, async (args) => {\n const path = normalizeSourcePath(args.path)\n const nodeModulesPath = isNodeModulesPath(path)\n const shouldRewriteRuntimeSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesRuntimeSpecifiers\n const shouldRewriteBareSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesBareSpecifiers\n const loader = runtimeLoaderForPath(args.path)\n\n if (!loader) {\n throw new Error(`Unable to determine runtime loader for path: ${args.path}`)\n }\n\n const contents = await Bun.file(path).text()\n const runtimeRewrittenContents = shouldRewriteRuntimeSpecifiers\n ? rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier)\n : contents\n\n if (runtimeRewrittenContents !== contents && shouldRewriteBareSpecifiers) {\n registerResolveParent(resolveParentsByRecency, path)\n }\n\n const transformedContents = shouldRewriteBareSpecifiers\n ? rewriteImportsFromResolveParents(runtimeRewrittenContents, resolveParentsByRecency)\n : runtimeRewrittenContents\n\n return {\n contents: transformedContents,\n loader,\n }\n })\n }\n\n const needsRuntimeSpecifierRewrite = (path: string): boolean => {\n const normalizedPath = normalizeSourcePath(path)\n const cached = runtimeSpecifierRewriteNeededByPath.get(normalizedPath)\n if (cached !== undefined) {\n return cached\n }\n\n const contents = readFileSync(normalizedPath, \"utf8\")\n const needsRewrite = rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier) !== contents\n runtimeSpecifierRewriteNeededByPath.set(normalizedPath, needsRewrite)\n return needsRewrite\n }\n\n for (const [specifier, moduleEntry] of runtimeModules.entries()) {\n const moduleId = runtimeModuleIdsBySpecifier.get(specifier)\n\n if (!moduleId) {\n continue\n }\n\n build.module(moduleId, async () => ({\n exports: await resolveRuntimeModuleExports(moduleEntry),\n loader: \"object\",\n }))\n\n build.onResolve({ filter: exactSpecifierFilter(specifier) }, () => ({ path: moduleId }))\n }\n\n build.onResolve({ filter: /.*/ }, (args) => {\n if (runtimeModuleIdsBySpecifier.has(args.path) || args.path.startsWith(RUNTIME_MODULE_PREFIX)) {\n return undefined\n }\n\n const path = resolveSourcePathFromSpecifier(args.path, args.importer)\n if (!path || !runtimeLoaderForPath(path)) {\n return undefined\n }\n\n const nodeModulesPath = isNodeModulesPath(path)\n\n if (!nodeModulesPath) {\n installRewriteLoader(path)\n return undefined\n }\n\n if (!rewriteOptions.nodeModulesRuntimeSpecifiers && !rewriteOptions.nodeModulesBareSpecifiers) {\n return undefined\n }\n\n const packageRoot = nodeModulesPackageRootForPath(path)\n if (rewriteOptions.nodeModulesBareSpecifiers && packageRoot && nodeModulesBareRewritePackageRoots.has(packageRoot)) {\n installRewriteLoader(path)\n return undefined\n }\n\n if (!rewriteOptions.nodeModulesRuntimeSpecifiers || !needsRuntimeSpecifierRewrite(path)) {\n return undefined\n }\n\n if (rewriteOptions.nodeModulesBareSpecifiers && packageRoot) {\n nodeModulesBareRewritePackageRoots.add(packageRoot)\n }\n\n installRewriteLoader(path)\n return undefined\n })\n },\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;AAAA;AACA;AACA;AAmBA,IAAM,yBAAyB;AAC/B,IAAM,iCAAiC;AACvC,IAAM,wBAAwB;AAC9B,IAAM,8BAA8B;AACpC,IAAM,yCAAgF;AAAA,EACpF,8BAA8B;AAAA,EAC9B,2BAA2B;AAC7B;AAEA,IAAM,yCAAyC,CAAC,wBAAwB,8BAA8B;AAEtG,IAAM,4CAA4C,IAAI,IAAY,sCAAsC;AAEjG,IAAM,+BAA+B,CAAC,cAA+B;AAAA,EAC1E,OAAO,0CAA0C,IAAI,SAAS;AAAA;AAGhE,IAAM,+BAA+B,YAA2C;AAAA,EAC9E,OAAQ,MAAa;AAAA;AAGvB,IAAM,eAAe,CAAC,UAA0B;AAAA,EAC9C,OAAO,MAAM,QAAQ,uBAAuB,MAAM;AAAA;AAGpD,IAAM,uBAAuB,CAAC,cAA8B;AAAA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