Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@opentui/core

Package Overview
Dependencies
Maintainers
3
Versions
277
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentui/core - npm Package Compare versions

Comparing version
0.3.3
to
0.3.4
index-0nvgrgam.js

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

+44
// @bun
import {
createRuntimePlugin
} from "./index-r49y8kdq.js";
// src/runtime-plugin-support-configure.ts
var {plugin: registerBunPlugin } = globalThis.Bun;
var runtimePluginSupportInstalledKey = "__opentuiCoreRuntimePluginSupportInstalled__";
function normalizeRewriteKey(rewrite) {
return `${rewrite?.nodeModulesRuntimeSpecifiers ?? true}:${rewrite?.nodeModulesBareSpecifiers ?? false}`;
}
function assertCompatibleInstall(install, options) {
for (const specifier of Object.keys(options.additional ?? {})) {
if (!install.additionalSpecifiers.has(specifier)) {
throw new Error(`OpenTUI Core runtime plugin support is already installed without ${specifier}. Call ensureRuntimePluginSupport({ additional }) from @opentui/core/runtime-plugin-support/configure before importing @opentui/core/runtime-plugin-support.`);
}
}
if (options.core && options.core !== install.core) {
throw new Error("OpenTUI Core runtime plugin support is already installed with a different core runtime module.");
}
if (options.rewrite && normalizeRewriteKey(options.rewrite) !== install.rewriteKey) {
throw new Error("OpenTUI Core runtime plugin support is already installed with different rewrite options.");
}
}
function ensureRuntimePluginSupport(options = {}) {
const state = globalThis;
const install = state[runtimePluginSupportInstalledKey];
if (install) {
assertCompatibleInstall(install, options);
return false;
}
registerBunPlugin(createRuntimePlugin(options));
state[runtimePluginSupportInstalledKey] = {
additionalSpecifiers: new Set(Object.keys(options.additional ?? {})),
core: options.core,
rewriteKey: normalizeRewriteKey(options.rewrite)
};
return true;
}
export { ensureRuntimePluginSupport };
//# debugId=09C0597CB92E654F64756E2164756E21
//# sourceMappingURL=index-8t841rbx.js.map
{
"version": 3,
"sources": ["../src/runtime-plugin-support-configure.ts"],
"sourcesContent": [
"import { plugin as registerBunPlugin } from \"bun\"\nimport { createRuntimePlugin, type CreateRuntimePluginOptions, type RuntimeModuleEntry } from \"./runtime-plugin.js\"\n\nconst runtimePluginSupportInstalledKey = \"__opentuiCoreRuntimePluginSupportInstalled__\"\n\ninterface RuntimePluginSupportInstall {\n additionalSpecifiers: ReadonlySet<string>\n core?: RuntimeModuleEntry\n rewriteKey: string\n}\n\ntype RuntimePluginSupportState = typeof globalThis & {\n [runtimePluginSupportInstalledKey]?: RuntimePluginSupportInstall\n}\n\nfunction normalizeRewriteKey(rewrite: CreateRuntimePluginOptions[\"rewrite\"] | undefined): string {\n return `${rewrite?.nodeModulesRuntimeSpecifiers ?? true}:${rewrite?.nodeModulesBareSpecifiers ?? false}`\n}\n\nfunction assertCompatibleInstall(install: RuntimePluginSupportInstall, options: CreateRuntimePluginOptions): void {\n for (const specifier of Object.keys(options.additional ?? {})) {\n if (!install.additionalSpecifiers.has(specifier)) {\n throw new Error(\n `OpenTUI Core runtime plugin support is already installed without ${specifier}. Call ensureRuntimePluginSupport({ additional }) from @opentui/core/runtime-plugin-support/configure before importing @opentui/core/runtime-plugin-support.`,\n )\n }\n }\n\n if (options.core && options.core !== install.core) {\n throw new Error(\"OpenTUI Core runtime plugin support is already installed with a different core runtime module.\")\n }\n\n if (options.rewrite && normalizeRewriteKey(options.rewrite) !== install.rewriteKey) {\n throw new Error(\"OpenTUI Core runtime plugin support is already installed with different rewrite options.\")\n }\n}\n\nexport function ensureRuntimePluginSupport(options: CreateRuntimePluginOptions = {}): boolean {\n const state = globalThis as RuntimePluginSupportState\n const install = state[runtimePluginSupportInstalledKey]\n\n if (install) {\n assertCompatibleInstall(install, options)\n return false\n }\n\n registerBunPlugin(createRuntimePlugin(options))\n\n state[runtimePluginSupportInstalledKey] = {\n additionalSpecifiers: new Set(Object.keys(options.additional ?? {})),\n core: options.core,\n rewriteKey: normalizeRewriteKey(options.rewrite),\n }\n return true\n}\n\nexport { createRuntimePlugin, runtimeModuleIdForSpecifier } from \"./runtime-plugin.js\"\nexport type {\n CreateRuntimePluginOptions,\n RuntimeModuleEntry,\n RuntimeModuleExports,\n RuntimeModuleLoader,\n} from \"./runtime-plugin.js\"\n"
],
"mappings": ";;;;;;AAAA;AAGA,IAAM,mCAAmC;AAYzC,SAAS,mBAAmB,CAAC,SAAoE;AAAA,EAC/F,OAAO,GAAG,SAAS,gCAAgC,QAAQ,SAAS,6BAA6B;AAAA;AAGnG,SAAS,uBAAuB,CAAC,SAAsC,SAA2C;AAAA,EAChH,WAAW,aAAa,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,GAAG;AAAA,IAC7D,IAAI,CAAC,QAAQ,qBAAqB,IAAI,SAAS,GAAG;AAAA,MAChD,MAAM,IAAI,MACR,oEAAoE,uKACtE;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAI,QAAQ,QAAQ,QAAQ,SAAS,QAAQ,MAAM;AAAA,IACjD,MAAM,IAAI,MAAM,gGAAgG;AAAA,EAClH;AAAA,EAEA,IAAI,QAAQ,WAAW,oBAAoB,QAAQ,OAAO,MAAM,QAAQ,YAAY;AAAA,IAClF,MAAM,IAAI,MAAM,0FAA0F;AAAA,EAC5G;AAAA;AAGK,SAAS,0BAA0B,CAAC,UAAsC,CAAC,GAAY;AAAA,EAC5F,MAAM,QAAQ;AAAA,EACd,MAAM,UAAU,MAAM;AAAA,EAEtB,IAAI,SAAS;AAAA,IACX,wBAAwB,SAAS,OAAO;AAAA,IACxC,OAAO;AAAA,EACT;AAAA,EAEA,kBAAkB,oBAAoB,OAAO,CAAC;AAAA,EAE9C,MAAM,oCAAoC;AAAA,IACxC,sBAAsB,IAAI,IAAI,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,CAAC;AAAA,IACnE,MAAM,QAAQ;AAAA,IACd,YAAY,oBAAoB,QAAQ,OAAO;AAAA,EACjD;AAAA,EACA,OAAO;AAAA;",
"debugId": "09C0597CB92E654F64756E2164756E21",
"names": []
}
// @bun
import {
exports_src
} from "./index-0nvgrgam.js";
import {
__require
} from "./index-54s7pk0d.js";
// src/runtime-plugin.ts
import { existsSync, readFileSync, realpathSync } from "fs";
import { basename, dirname, isAbsolute, join } from "path";
import { fileURLToPath } from "url";
var CORE_RUNTIME_SPECIFIER = "@opentui/core";
var CORE_TESTING_RUNTIME_SPECIFIER = "@opentui/core/testing";
var RUNTIME_MODULE_PREFIX = "opentui:runtime-module:";
var MAX_RUNTIME_RESOLVE_PARENTS = 64;
var DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS = {
nodeModulesRuntimeSpecifiers: true,
nodeModulesBareSpecifiers: false
};
var DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS = [CORE_RUNTIME_SPECIFIER, CORE_TESTING_RUNTIME_SPECIFIER];
var DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET = new Set(DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS);
var isCoreRuntimeModuleSpecifier = (specifier) => {
return DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET.has(specifier);
};
var loadCoreTestingRuntimeModule = async () => {
return await import("./testing.js");
};
var escapeRegExp = (value) => {
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
};
var exactSpecifierFilter = (specifier) => {
return new RegExp(`^${escapeRegExp(specifier)}$`);
};
var exactPathFilter = (paths) => {
const candidates = [...new Set(paths.map(sourcePath))];
return new RegExp(`^(?:${candidates.map(escapeRegExp).join("|")})(?:[?#].*)?$`);
};
var runtimeModuleIdForSpecifier = (specifier) => {
return `${RUNTIME_MODULE_PREFIX}${encodeURIComponent(specifier)}`;
};
var resolveRuntimeModuleExports = async (moduleEntry) => {
if (typeof moduleEntry === "function") {
return await moduleEntry();
}
return moduleEntry;
};
var sourcePath = (path) => {
const searchIndex = path.indexOf("?");
const hashIndex = path.indexOf("#");
const end = [searchIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0];
return end === undefined ? path : path.slice(0, end);
};
var normalizedSourcePathByPath = new Map;
var normalizeSourcePath = (path) => {
const cleanPath = sourcePath(path);
const cachedPath = normalizedSourcePathByPath.get(cleanPath);
if (cachedPath !== undefined) {
return cachedPath;
}
let normalizedPath = cleanPath;
try {
normalizedPath = realpathSync(cleanPath);
} catch {
normalizedPath = cleanPath;
}
normalizedSourcePathByPath.set(cleanPath, normalizedPath);
return normalizedPath;
};
var isNodeModulesPath = (path) => {
return /(?:^|[/\\])node_modules(?:[/\\])/.test(path);
};
var packageTypeForPath = (path, packageTypeByPackageJsonPath) => {
let currentDir = dirname(path);
while (true) {
const packageJsonPath = join(currentDir, "package.json");
if (existsSync(packageJsonPath)) {
const cachedPackageType = packageTypeByPackageJsonPath.get(packageJsonPath);
if (cachedPackageType) {
return cachedPackageType;
}
let packageType = "commonjs";
try {
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
if (packageJson.type === "module") {
packageType = "module";
}
} catch {
packageType = "commonjs";
}
packageTypeByPackageJsonPath.set(packageJsonPath, packageType);
return packageType;
}
const parentDir = dirname(currentDir);
if (parentDir === currentDir) {
return "commonjs";
}
currentDir = parentDir;
}
};
var isNodeModulesEsmPath = (path, packageTypeByPackageJsonPath) => {
const normalizedPath = normalizeSourcePath(path);
if (!isNodeModulesPath(normalizedPath)) {
return false;
}
if (normalizedPath.endsWith(".mjs") || normalizedPath.endsWith(".mts") || normalizedPath.endsWith(".ts") || normalizedPath.endsWith(".tsx") || normalizedPath.endsWith(".jsx")) {
return true;
}
if (normalizedPath.endsWith(".cjs") || normalizedPath.endsWith(".cts") || !normalizedPath.endsWith(".js")) {
return false;
}
return packageTypeForPath(normalizedPath, packageTypeByPackageJsonPath) === "module";
};
var nodeModulesPackageRootForPath = (path) => {
let currentDir = dirname(path);
while (true) {
const parentDir = dirname(currentDir);
if (parentDir === currentDir) {
return null;
}
if (basename(parentDir) === "node_modules") {
return currentDir;
}
if (basename(dirname(parentDir)) === "node_modules" && basename(parentDir).startsWith("@")) {
return currentDir;
}
currentDir = parentDir;
}
};
var resolveRuntimePluginRewriteOptions = (options) => {
return {
nodeModulesRuntimeSpecifiers: options?.nodeModulesRuntimeSpecifiers ?? DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS.nodeModulesRuntimeSpecifiers,
nodeModulesBareSpecifiers: options?.nodeModulesBareSpecifiers ?? DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS.nodeModulesBareSpecifiers
};
};
var runtimeLoaderForPath = (path) => {
const cleanPath = sourcePath(path);
if (cleanPath.endsWith(".tsx")) {
return "tsx";
}
if (cleanPath.endsWith(".jsx")) {
return "jsx";
}
if (cleanPath.endsWith(".ts") || cleanPath.endsWith(".mts") || cleanPath.endsWith(".cts")) {
return "ts";
}
if (cleanPath.endsWith(".js") || cleanPath.endsWith(".mjs") || cleanPath.endsWith(".cjs")) {
return "js";
}
return null;
};
var resolveImportSpecifierPatterns = [
/(from\s+["'])([^"']+)(["'])/g,
/(import\s+["'])([^"']+)(["'])/g,
/(import\s*\(\s*["'])([^"']+)(["']\s*\))/g,
/(require\s*\(\s*["'])([^"']+)(["']\s*\))/g
];
var isBareSpecifier = (specifier) => {
if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("\\")) {
return false;
}
if (specifier.startsWith("node:") || specifier.startsWith("bun:") || specifier.startsWith("http:") || specifier.startsWith("https:") || specifier.startsWith("file:") || specifier.startsWith("data:")) {
return false;
}
if (specifier.startsWith(RUNTIME_MODULE_PREFIX)) {
return false;
}
return true;
};
var registerResolveParent = (resolveParentsByRecency, resolveParent) => {
const existingIndex = resolveParentsByRecency.indexOf(resolveParent);
if (existingIndex >= 0) {
resolveParentsByRecency.splice(existingIndex, 1);
}
resolveParentsByRecency.push(resolveParent);
if (resolveParentsByRecency.length > MAX_RUNTIME_RESOLVE_PARENTS) {
resolveParentsByRecency.shift();
}
};
var rewriteImportSpecifiers = (code, resolveReplacement) => {
let transformedCode = code;
for (const pattern of resolveImportSpecifierPatterns) {
transformedCode = transformedCode.replace(pattern, (fullMatch, prefix, specifier, suffix) => {
const replacement = resolveReplacement(specifier);
if (!replacement || replacement === specifier) {
return fullMatch;
}
return `${prefix}${replacement}${suffix}`;
});
}
return transformedCode;
};
var collectImportSpecifiers = (code) => {
const specifiers = new Set;
for (const pattern of resolveImportSpecifierPatterns) {
code.replace(pattern, (_fullMatch, _prefix, specifier) => {
specifiers.add(specifier);
return _fullMatch;
});
}
return [...specifiers];
};
var resolveFromParent = (specifier, parent) => {
try {
const resolvedSpecifier = import.meta.resolve(specifier, parent);
if (resolvedSpecifier === specifier || resolvedSpecifier.startsWith("node:") || resolvedSpecifier.startsWith("bun:")) {
return null;
}
return resolvedSpecifier;
} catch {
return null;
}
};
var resolveSourcePathFromSpecifier = (specifier, importer) => {
if (specifier.startsWith("node:") || specifier.startsWith("bun:") || specifier.startsWith("http:") || specifier.startsWith("https:") || specifier.startsWith("data:") || specifier.startsWith(RUNTIME_MODULE_PREFIX)) {
return null;
}
if (specifier.startsWith("file:")) {
return sourcePath(fileURLToPath(specifier));
}
if (isAbsolute(specifier)) {
return sourcePath(specifier);
}
const resolvedSpecifier = resolveFromParent(specifier, importer);
if (!resolvedSpecifier) {
return null;
}
if (resolvedSpecifier.startsWith("file:")) {
return sourcePath(fileURLToPath(resolvedSpecifier));
}
if (isAbsolute(resolvedSpecifier)) {
return sourcePath(resolvedSpecifier);
}
return null;
};
var rewriteImportsFromResolveParents = (code, resolveParentsByRecency) => {
if (resolveParentsByRecency.length === 0) {
return code;
}
const resolveFromParents = (specifier) => {
if (!isBareSpecifier(specifier)) {
return null;
}
for (let index = resolveParentsByRecency.length - 1;index >= 0; index -= 1) {
const resolveParent = resolveParentsByRecency[index];
const resolvedSpecifier = resolveFromParent(specifier, resolveParent);
if (resolvedSpecifier) {
return resolvedSpecifier;
}
}
return null;
};
return rewriteImportSpecifiers(code, resolveFromParents);
};
var rewriteRuntimeSpecifiers = (code, runtimeModuleIdsBySpecifier) => {
return rewriteImportSpecifiers(code, (specifier) => {
const runtimeModuleId = runtimeModuleIdsBySpecifier.get(specifier);
return runtimeModuleId ?? null;
});
};
function createRuntimePlugin(input = {}) {
const runtimeModules = new Map;
runtimeModules.set(CORE_RUNTIME_SPECIFIER, input.core ?? exports_src);
runtimeModules.set(CORE_TESTING_RUNTIME_SPECIFIER, loadCoreTestingRuntimeModule);
const rewriteOptions = resolveRuntimePluginRewriteOptions(input.rewrite);
for (const [specifier, moduleEntry] of Object.entries(input.additional ?? {})) {
runtimeModules.set(specifier, moduleEntry);
}
const runtimeModuleIdsBySpecifier = new Map;
for (const specifier of runtimeModules.keys()) {
runtimeModuleIdsBySpecifier.set(specifier, runtimeModuleIdForSpecifier(specifier));
}
return {
name: "bun-plugin-opentui-runtime-modules",
setup: (build) => {
const resolveParentsByRecency = [];
const installedRewriteLoaders = new Set;
const nodeModulesBareRewritePackageRoots = new Set;
const packageTypeByPackageJsonPath = new Map;
const sourceAnalysisByPath = new Map;
const nodeModulesRuntimeRewritePathsByPath = new Map;
const installRewriteLoader = (path) => {
const resolvedTargetPath = sourcePath(path);
const canonicalTargetPath = normalizeSourcePath(resolvedTargetPath);
if (installedRewriteLoaders.has(canonicalTargetPath)) {
return;
}
installedRewriteLoaders.add(canonicalTargetPath);
build.onLoad({ filter: exactPathFilter([resolvedTargetPath, canonicalTargetPath]) }, async (args) => {
const loadedPath = normalizeSourcePath(args.path);
if (loadedPath !== canonicalTargetPath) {
return;
}
const nodeModulesPath = isNodeModulesPath(loadedPath);
const shouldRewriteRuntimeSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesRuntimeSpecifiers;
const shouldRewriteBareSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesBareSpecifiers;
const loader = runtimeLoaderForPath(args.path);
if (!loader) {
throw new Error(`Unable to determine runtime loader for path: ${args.path}`);
}
const contents = await Bun.file(loadedPath).text();
const runtimeRewrittenContents = shouldRewriteRuntimeSpecifiers ? rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier) : contents;
if (runtimeRewrittenContents !== contents && shouldRewriteBareSpecifiers) {
registerResolveParent(resolveParentsByRecency, loadedPath);
}
const transformedContents = shouldRewriteBareSpecifiers ? rewriteImportsFromResolveParents(runtimeRewrittenContents, resolveParentsByRecency) : runtimeRewrittenContents;
return {
contents: transformedContents,
loader
};
});
};
const analyzeSourcePath = (path) => {
const normalizedPath = normalizeSourcePath(path);
const cachedAnalysis = sourceAnalysisByPath.get(normalizedPath);
if (cachedAnalysis) {
return cachedAnalysis;
}
let contents;
try {
contents = readFileSync(normalizedPath, "utf8");
} catch (error) {
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
const analysis2 = { importSpecifiers: [], needsRuntimeSpecifierRewrite: false };
sourceAnalysisByPath.set(normalizedPath, analysis2);
return analysis2;
}
throw error;
}
const importSpecifiers = collectImportSpecifiers(contents);
const analysis = {
importSpecifiers,
needsRuntimeSpecifierRewrite: importSpecifiers.some((specifier) => runtimeModuleIdsBySpecifier.has(specifier))
};
sourceAnalysisByPath.set(normalizedPath, analysis);
return analysis;
};
const collectNodeModulesRuntimeRewritePaths = (path, visiting = new Set) => {
const normalizedPath = normalizeSourcePath(path);
if (!isNodeModulesEsmPath(normalizedPath, packageTypeByPackageJsonPath)) {
return [];
}
const cachedPaths = nodeModulesRuntimeRewritePathsByPath.get(normalizedPath);
if (cachedPaths) {
return cachedPaths;
}
if (visiting.has(normalizedPath)) {
return [];
}
visiting.add(normalizedPath);
const rewritePaths = new Set;
const analysis = analyzeSourcePath(normalizedPath);
if (analysis.needsRuntimeSpecifierRewrite) {
rewritePaths.add(normalizedPath);
}
for (const specifier of analysis.importSpecifiers) {
const resolvedPath = resolveSourcePathFromSpecifier(specifier, normalizedPath);
if (!resolvedPath || !isNodeModulesEsmPath(resolvedPath, packageTypeByPackageJsonPath)) {
continue;
}
for (const nestedPath of collectNodeModulesRuntimeRewritePaths(resolvedPath, visiting)) {
rewritePaths.add(nestedPath);
}
}
visiting.delete(normalizedPath);
const resolvedRewritePaths = [...rewritePaths];
nodeModulesRuntimeRewritePathsByPath.set(normalizedPath, resolvedRewritePaths);
return resolvedRewritePaths;
};
for (const [specifier, moduleEntry] of runtimeModules.entries()) {
const moduleId = runtimeModuleIdsBySpecifier.get(specifier);
if (!moduleId) {
continue;
}
build.module(moduleId, async () => ({
exports: await resolveRuntimeModuleExports(moduleEntry),
loader: "object"
}));
build.onResolve({ filter: exactSpecifierFilter(specifier) }, () => ({ path: moduleId }));
}
build.onResolve({ filter: /.*/ }, (args) => {
if (runtimeModuleIdsBySpecifier.has(args.path) || args.path.startsWith(RUNTIME_MODULE_PREFIX)) {
return;
}
const path = resolveSourcePathFromSpecifier(args.path, args.importer);
if (!path || !runtimeLoaderForPath(path)) {
return;
}
const nodeModulesPath = isNodeModulesPath(path);
if (!nodeModulesPath) {
installRewriteLoader(path);
return;
}
if (!rewriteOptions.nodeModulesRuntimeSpecifiers && !rewriteOptions.nodeModulesBareSpecifiers) {
return;
}
for (const rewritePath of collectNodeModulesRuntimeRewritePaths(path)) {
installRewriteLoader(rewritePath);
}
const packageRoot = nodeModulesPackageRootForPath(path);
if (rewriteOptions.nodeModulesBareSpecifiers && packageRoot && nodeModulesBareRewritePackageRoots.has(packageRoot)) {
installRewriteLoader(path);
return;
}
if (!rewriteOptions.nodeModulesRuntimeSpecifiers || !analyzeSourcePath(path).needsRuntimeSpecifierRewrite) {
return;
}
if (rewriteOptions.nodeModulesBareSpecifiers && packageRoot) {
nodeModulesBareRewritePackageRoots.add(packageRoot);
}
installRewriteLoader(path);
return;
});
}
};
}
export { isCoreRuntimeModuleSpecifier, runtimeModuleIdForSpecifier, createRuntimePlugin };
//# debugId=4F4ECA92927B118964756E2164756E21
//# sourceMappingURL=index-r49y8kdq.js.map
{
"version": 3,
"sources": ["../src/runtime-plugin.ts"],
"sourcesContent": [
"/*\n * Exposes runtime-only modules (for example `@opentui/core`, `@opentui/solid`,\n * `solid-js`) to externally loaded plugins by rewriting matching imports to\n * virtual `opentui:runtime-module:*` ids.\n *\n * Why this is exact-path + prescan instead of one broad `onLoad`:\n * - Bun can break CJS/UMD interop if a file is routed through plugin `onLoad`\n * (real repro: `jsonc-parser` resolving to `lib/umd/main.js`;\n * https://github.com/oven-sh/bun/issues/19279,\n * https://github.com/oven-sh/bun/issues/21369), so arbitrary `node_modules`\n * JS cannot be blanket-rewritten.\n * - runtime `onResolve` is sync-only, so package/type/source discovery here is\n * synchronous and cached.\n * - a matched `onLoad` cannot safely fall through, so loaders must be narrow.\n * - Bun may canonicalize paths before `onLoad`, so loaders are registered for\n * both the resolved path spelling and its realpath, then canonical-checked.\n * - Bun may native-load `node_modules` ESM without firing `onResolve` for\n * nested package imports, so `node_modules` ESM is recursively prescanned and\n * only files that actually need runtime rewriting get exact-path loaders.\n *\n * Behavior:\n * - non-`node_modules` source files get a dedicated rewrite loader immediately.\n * - `node_modules` files are rewritten only if they are ESM (`.mjs`, `.mts`,\n * `.ts`, `.tsx`, `.jsx`, or `.js` under `package.json#type=\"module\"`) and\n * directly or transitively need runtime-module rewriting; unrelated CJS stays\n * untouched.\n * - optional bare-specifier rewriting is preserved for sibling files in\n * packages already marked for runtime rewriting.\n *\n * Notes:\n * - import scanning is regex-based, not a full parser.\n * - CJS helper libraries that themselves import runtime modules are still not\n * supported.\n * - `package.json#type` caching is per plugin setup, not module-global, so a\n * later plugin instance in the same process can observe filesystem changes.\n */\nimport { existsSync, readFileSync, realpathSync } from \"node:fs\"\nimport { basename, dirname, isAbsolute, join } 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\ninterface SourceAnalysis {\n importSpecifiers: string[]\n needsRuntimeSpecifierRewrite: boolean\n}\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 = (paths: string[]): RegExp => {\n const candidates = [...new Set(paths.map(sourcePath))]\n return new RegExp(`^(?:${candidates.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 normalizedSourcePathByPath = new Map<string, string>()\n\nconst normalizeSourcePath = (path: string): string => {\n const cleanPath = sourcePath(path)\n const cachedPath = normalizedSourcePathByPath.get(cleanPath)\n if (cachedPath !== undefined) {\n return cachedPath\n }\n\n let normalizedPath = cleanPath\n\n try {\n normalizedPath = realpathSync(cleanPath)\n } catch {\n normalizedPath = cleanPath\n }\n\n normalizedSourcePathByPath.set(cleanPath, normalizedPath)\n return normalizedPath\n}\n\nconst isNodeModulesPath = (path: string): boolean => {\n return /(?:^|[/\\\\])node_modules(?:[/\\\\])/.test(path)\n}\n\nconst packageTypeForPath = (\n path: string,\n packageTypeByPackageJsonPath: Map<string, \"module\" | \"commonjs\">,\n): \"module\" | \"commonjs\" => {\n let currentDir = dirname(path)\n\n while (true) {\n const packageJsonPath = join(currentDir, \"package.json\")\n if (existsSync(packageJsonPath)) {\n const cachedPackageType = packageTypeByPackageJsonPath.get(packageJsonPath)\n if (cachedPackageType) {\n return cachedPackageType\n }\n\n let packageType: \"module\" | \"commonjs\" = \"commonjs\"\n\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { type?: string }\n if (packageJson.type === \"module\") {\n packageType = \"module\"\n }\n } catch {\n packageType = \"commonjs\"\n }\n\n packageTypeByPackageJsonPath.set(packageJsonPath, packageType)\n return packageType\n }\n\n const parentDir = dirname(currentDir)\n if (parentDir === currentDir) {\n return \"commonjs\"\n }\n\n currentDir = parentDir\n }\n}\n\nconst isNodeModulesEsmPath = (\n path: string,\n packageTypeByPackageJsonPath: Map<string, \"module\" | \"commonjs\">,\n): boolean => {\n const normalizedPath = normalizeSourcePath(path)\n\n if (!isNodeModulesPath(normalizedPath)) {\n return false\n }\n\n if (\n normalizedPath.endsWith(\".mjs\") ||\n normalizedPath.endsWith(\".mts\") ||\n normalizedPath.endsWith(\".ts\") ||\n normalizedPath.endsWith(\".tsx\") ||\n normalizedPath.endsWith(\".jsx\")\n ) {\n return true\n }\n\n if (normalizedPath.endsWith(\".cjs\") || normalizedPath.endsWith(\".cts\") || !normalizedPath.endsWith(\".js\")) {\n return false\n }\n\n return packageTypeForPath(normalizedPath, packageTypeByPackageJsonPath) === \"module\"\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 collectImportSpecifiers = (code: string): string[] => {\n const specifiers = new Set<string>()\n\n for (const pattern of resolveImportSpecifierPatterns) {\n code.replace(pattern, (_fullMatch, _prefix, specifier) => {\n specifiers.add(specifier)\n return _fullMatch\n })\n }\n\n return [...specifiers]\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 sourcePath(fileURLToPath(specifier))\n }\n\n if (isAbsolute(specifier)) {\n return sourcePath(specifier)\n }\n\n const resolvedSpecifier = resolveFromParent(specifier, importer)\n if (!resolvedSpecifier) {\n return null\n }\n\n if (resolvedSpecifier.startsWith(\"file:\")) {\n return sourcePath(fileURLToPath(resolvedSpecifier))\n }\n\n if (isAbsolute(resolvedSpecifier)) {\n return sourcePath(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 packageTypeByPackageJsonPath = new Map<string, \"module\" | \"commonjs\">()\n const sourceAnalysisByPath = new Map<string, SourceAnalysis>()\n const nodeModulesRuntimeRewritePathsByPath = new Map<string, string[]>()\n\n const installRewriteLoader = (path: string): void => {\n const resolvedTargetPath = sourcePath(path)\n const canonicalTargetPath = normalizeSourcePath(resolvedTargetPath)\n\n if (installedRewriteLoaders.has(canonicalTargetPath)) {\n return\n }\n\n installedRewriteLoaders.add(canonicalTargetPath)\n\n // Register both the resolved path spelling and its canonical realpath so Bun\n // can reach the loader even if it reports the same file through a different alias.\n build.onLoad({ filter: exactPathFilter([resolvedTargetPath, canonicalTargetPath]) }, async (args) => {\n const loadedPath = normalizeSourcePath(args.path)\n if (loadedPath !== canonicalTargetPath) {\n return undefined\n }\n\n const nodeModulesPath = isNodeModulesPath(loadedPath)\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(loadedPath).text()\n const runtimeRewrittenContents = shouldRewriteRuntimeSpecifiers\n ? rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier)\n : contents\n\n if (runtimeRewrittenContents !== contents && shouldRewriteBareSpecifiers) {\n registerResolveParent(resolveParentsByRecency, loadedPath)\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 analyzeSourcePath = (path: string): SourceAnalysis => {\n const normalizedPath = normalizeSourcePath(path)\n const cachedAnalysis = sourceAnalysisByPath.get(normalizedPath)\n if (cachedAnalysis) {\n return cachedAnalysis\n }\n\n let contents: string\n try {\n contents = readFileSync(normalizedPath, \"utf8\")\n } catch (error) {\n if (error && typeof error === \"object\" && \"code\" in error && error.code === \"ENOENT\") {\n const analysis = { importSpecifiers: [], needsRuntimeSpecifierRewrite: false }\n sourceAnalysisByPath.set(normalizedPath, analysis)\n return analysis\n }\n throw error\n }\n\n const importSpecifiers = collectImportSpecifiers(contents)\n const analysis = {\n importSpecifiers,\n needsRuntimeSpecifierRewrite: importSpecifiers.some((specifier) =>\n runtimeModuleIdsBySpecifier.has(specifier),\n ),\n }\n\n sourceAnalysisByPath.set(normalizedPath, analysis)\n return analysis\n }\n\n const collectNodeModulesRuntimeRewritePaths = (path: string, visiting = new Set<string>()): string[] => {\n const normalizedPath = normalizeSourcePath(path)\n\n if (!isNodeModulesEsmPath(normalizedPath, packageTypeByPackageJsonPath)) {\n return []\n }\n\n const cachedPaths = nodeModulesRuntimeRewritePathsByPath.get(normalizedPath)\n if (cachedPaths) {\n return cachedPaths\n }\n\n if (visiting.has(normalizedPath)) {\n return []\n }\n\n visiting.add(normalizedPath)\n\n const rewritePaths = new Set<string>()\n const analysis = analyzeSourcePath(normalizedPath)\n\n if (analysis.needsRuntimeSpecifierRewrite) {\n rewritePaths.add(normalizedPath)\n }\n\n for (const specifier of analysis.importSpecifiers) {\n const resolvedPath = resolveSourcePathFromSpecifier(specifier, normalizedPath)\n if (!resolvedPath || !isNodeModulesEsmPath(resolvedPath, packageTypeByPackageJsonPath)) {\n continue\n }\n\n for (const nestedPath of collectNodeModulesRuntimeRewritePaths(resolvedPath, visiting)) {\n rewritePaths.add(nestedPath)\n }\n }\n\n visiting.delete(normalizedPath)\n\n const resolvedRewritePaths = [...rewritePaths]\n nodeModulesRuntimeRewritePathsByPath.set(normalizedPath, resolvedRewritePaths)\n return resolvedRewritePaths\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 for (const rewritePath of collectNodeModulesRuntimeRewritePaths(path)) {\n installRewriteLoader(rewritePath)\n }\n\n const packageRoot = nodeModulesPackageRootForPath(path)\n if (\n rewriteOptions.nodeModulesBareSpecifiers &&\n packageRoot &&\n nodeModulesBareRewritePackageRoots.has(packageRoot)\n ) {\n installRewriteLoader(path)\n return undefined\n }\n\n if (!rewriteOptions.nodeModulesRuntimeSpecifiers || !analyzeSourcePath(path).needsRuntimeSpecifierRewrite) {\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"
],
"mappings": ";;;;;;;;;AAoCA;AACA;AACA;AAwBA,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,EAC1D,OAAO,IAAI,OAAO,IAAI,aAAa,SAAS,IAAI;AAAA;AAGlD,IAAM,kBAAkB,CAAC,UAA4B;AAAA,EACnD,MAAM,aAAa,CAAC,GAAG,IAAI,IAAI,MAAM,IAAI,UAAU,CAAC,CAAC;AAAA,EACrD,OAAO,IAAI,OAAO,OAAO,WAAW,IAAI,YAAY,EAAE,KAAK,GAAG,gBAAgB;AAAA;AAGzE,IAAM,8BAA8B,CAAC,cAA8B;AAAA,EACxE,OAAO,GAAG,wBAAwB,mBAAmB,SAAS;AAAA;AAGhE,IAAM,8BAA8B,OAAO,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6B,aAAa;AAAA,UAC3D,mCAAmC,IAAI,WAAW;AAAA,QACpD;AAAA,QAEA,qBAAqB,IAAI;AAAA,QACzB;AAAA,OACD;AAAA;AAAA,EAEL;AAAA;",
"debugId": "4F4ECA92927B118964756E2164756E21",
"names": []
}
+2
-2

@@ -75,3 +75,3 @@ // @bun

vstyles
} from "./index-qndc8vq8.js";
} from "./index-0nvgrgam.js";
import {

@@ -251,3 +251,3 @@ ASCIIFontSelectionHelper,

yellow
} from "./index-mn090kzf.js";
} from "./index-54s7pk0d.js";
export {

@@ -254,0 +254,0 @@ yellow,

@@ -7,3 +7,3 @@ {

"type": "module",
"version": "0.3.3",
"version": "0.3.4",
"description": "OpenTUI is a TypeScript library on a native Zig core for building terminal user interfaces (TUIs)",

@@ -73,11 +73,11 @@ "license": "MIT",

"optionalDependencies": {
"@opentui/core-darwin-x64": "0.3.3",
"@opentui/core-darwin-arm64": "0.3.3",
"@opentui/core-linux-x64": "0.3.3",
"@opentui/core-linux-arm64": "0.3.3",
"@opentui/core-win32-x64": "0.3.3",
"@opentui/core-win32-arm64": "0.3.3",
"@opentui/core-linux-x64-musl": "0.3.3",
"@opentui/core-linux-arm64-musl": "0.3.3"
"@opentui/core-darwin-x64": "0.3.4",
"@opentui/core-darwin-arm64": "0.3.4",
"@opentui/core-linux-x64": "0.3.4",
"@opentui/core-linux-arm64": "0.3.4",
"@opentui/core-win32-x64": "0.3.4",
"@opentui/core-win32-arm64": "0.3.4",
"@opentui/core-linux-x64-musl": "0.3.4",
"@opentui/core-linux-arm64-musl": "0.3.4"
}
}
import { type LineInfo, type RenderContext } from "../types.js";
import { StyledText } from "../lib/styled-text.js";
import { SyntaxStyle } from "../syntax-style.js";

@@ -26,2 +27,3 @@ import { TreeSitterClient } from "../lib/tree-sitter/index.js";

streaming?: boolean;
initialStyledText?: StyledText;
baseHighlight?: string;

@@ -43,2 +45,3 @@ onHighlight?: OnHighlightCallback;

private _streaming;
private _initialStyledText?;
private _hadInitialContent;

@@ -75,2 +78,3 @@ private _lastHighlights;

get streaming(): boolean;
set initialStyledText(value: StyledText | undefined);
set streaming(value: boolean);

@@ -77,0 +81,0 @@ get treeSitterClient(): TreeSitterClient;

@@ -182,2 +182,3 @@ import { Renderable, type RenderableOptions } from "../Renderable.js";

private createDefaultChunk;
private createInitialStyledText;
private renderInlineContent;

@@ -184,0 +185,0 @@ private renderInlineToken;

// @bun
import {
ensureRuntimePluginSupport
} from "./index-jh82sd41.js";
} from "./index-8t841rbx.js";
import {
createRuntimePlugin,
runtimeModuleIdForSpecifier
} from "./index-mbck6rbg.js";
import"./index-qndc8vq8.js";
import"./index-mn090kzf.js";
} from "./index-r49y8kdq.js";
import"./index-0nvgrgam.js";
import"./index-54s7pk0d.js";
export {

@@ -12,0 +12,0 @@ runtimeModuleIdForSpecifier,

// @bun
import {
ensureRuntimePluginSupport
} from "./index-jh82sd41.js";
} from "./index-8t841rbx.js";
import {
createRuntimePlugin,
runtimeModuleIdForSpecifier
} from "./index-mbck6rbg.js";
import"./index-qndc8vq8.js";
import"./index-mn090kzf.js";
} from "./index-r49y8kdq.js";
import"./index-0nvgrgam.js";
import"./index-54s7pk0d.js";
// src/runtime-plugin-support.ts

@@ -12,0 +12,0 @@ ensureRuntimePluginSupport();

@@ -6,5 +6,5 @@ // @bun

runtimeModuleIdForSpecifier
} from "./index-mbck6rbg.js";
import"./index-qndc8vq8.js";
import"./index-mn090kzf.js";
} from "./index-r49y8kdq.js";
import"./index-0nvgrgam.js";
import"./index-54s7pk0d.js";
export {

@@ -11,0 +11,0 @@ runtimeModuleIdForSpecifier,

@@ -6,3 +6,3 @@ // @bun

TreeSitterClient
} from "./index-mn090kzf.js";
} from "./index-54s7pk0d.js";

@@ -9,0 +9,0 @@ // src/testing/mock-keys.ts

// @bun
import {
createRuntimePlugin
} from "./index-mbck6rbg.js";
// src/runtime-plugin-support-configure.ts
var {plugin: registerBunPlugin } = globalThis.Bun;
var runtimePluginSupportInstalledKey = "__opentuiCoreRuntimePluginSupportInstalled__";
function normalizeRewriteKey(rewrite) {
return `${rewrite?.nodeModulesRuntimeSpecifiers ?? true}:${rewrite?.nodeModulesBareSpecifiers ?? false}`;
}
function assertCompatibleInstall(install, options) {
for (const specifier of Object.keys(options.additional ?? {})) {
if (!install.additionalSpecifiers.has(specifier)) {
throw new Error(`OpenTUI Core runtime plugin support is already installed without ${specifier}. Call ensureRuntimePluginSupport({ additional }) from @opentui/core/runtime-plugin-support/configure before importing @opentui/core/runtime-plugin-support.`);
}
}
if (options.core && options.core !== install.core) {
throw new Error("OpenTUI Core runtime plugin support is already installed with a different core runtime module.");
}
if (options.rewrite && normalizeRewriteKey(options.rewrite) !== install.rewriteKey) {
throw new Error("OpenTUI Core runtime plugin support is already installed with different rewrite options.");
}
}
function ensureRuntimePluginSupport(options = {}) {
const state = globalThis;
const install = state[runtimePluginSupportInstalledKey];
if (install) {
assertCompatibleInstall(install, options);
return false;
}
registerBunPlugin(createRuntimePlugin(options));
state[runtimePluginSupportInstalledKey] = {
additionalSpecifiers: new Set(Object.keys(options.additional ?? {})),
core: options.core,
rewriteKey: normalizeRewriteKey(options.rewrite)
};
return true;
}
export { ensureRuntimePluginSupport };
//# debugId=09C0597CB92E654F64756E2164756E21
//# sourceMappingURL=index-jh82sd41.js.map
{
"version": 3,
"sources": ["../src/runtime-plugin-support-configure.ts"],
"sourcesContent": [
"import { plugin as registerBunPlugin } from \"bun\"\nimport { createRuntimePlugin, type CreateRuntimePluginOptions, type RuntimeModuleEntry } from \"./runtime-plugin.js\"\n\nconst runtimePluginSupportInstalledKey = \"__opentuiCoreRuntimePluginSupportInstalled__\"\n\ninterface RuntimePluginSupportInstall {\n additionalSpecifiers: ReadonlySet<string>\n core?: RuntimeModuleEntry\n rewriteKey: string\n}\n\ntype RuntimePluginSupportState = typeof globalThis & {\n [runtimePluginSupportInstalledKey]?: RuntimePluginSupportInstall\n}\n\nfunction normalizeRewriteKey(rewrite: CreateRuntimePluginOptions[\"rewrite\"] | undefined): string {\n return `${rewrite?.nodeModulesRuntimeSpecifiers ?? true}:${rewrite?.nodeModulesBareSpecifiers ?? false}`\n}\n\nfunction assertCompatibleInstall(install: RuntimePluginSupportInstall, options: CreateRuntimePluginOptions): void {\n for (const specifier of Object.keys(options.additional ?? {})) {\n if (!install.additionalSpecifiers.has(specifier)) {\n throw new Error(\n `OpenTUI Core runtime plugin support is already installed without ${specifier}. Call ensureRuntimePluginSupport({ additional }) from @opentui/core/runtime-plugin-support/configure before importing @opentui/core/runtime-plugin-support.`,\n )\n }\n }\n\n if (options.core && options.core !== install.core) {\n throw new Error(\"OpenTUI Core runtime plugin support is already installed with a different core runtime module.\")\n }\n\n if (options.rewrite && normalizeRewriteKey(options.rewrite) !== install.rewriteKey) {\n throw new Error(\"OpenTUI Core runtime plugin support is already installed with different rewrite options.\")\n }\n}\n\nexport function ensureRuntimePluginSupport(options: CreateRuntimePluginOptions = {}): boolean {\n const state = globalThis as RuntimePluginSupportState\n const install = state[runtimePluginSupportInstalledKey]\n\n if (install) {\n assertCompatibleInstall(install, options)\n return false\n }\n\n registerBunPlugin(createRuntimePlugin(options))\n\n state[runtimePluginSupportInstalledKey] = {\n additionalSpecifiers: new Set(Object.keys(options.additional ?? {})),\n core: options.core,\n rewriteKey: normalizeRewriteKey(options.rewrite),\n }\n return true\n}\n\nexport { createRuntimePlugin, runtimeModuleIdForSpecifier } from \"./runtime-plugin.js\"\nexport type {\n CreateRuntimePluginOptions,\n RuntimeModuleEntry,\n RuntimeModuleExports,\n RuntimeModuleLoader,\n} from \"./runtime-plugin.js\"\n"
],
"mappings": ";;;;;;AAAA;AAGA,IAAM,mCAAmC;AAYzC,SAAS,mBAAmB,CAAC,SAAoE;AAAA,EAC/F,OAAO,GAAG,SAAS,gCAAgC,QAAQ,SAAS,6BAA6B;AAAA;AAGnG,SAAS,uBAAuB,CAAC,SAAsC,SAA2C;AAAA,EAChH,WAAW,aAAa,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,GAAG;AAAA,IAC7D,IAAI,CAAC,QAAQ,qBAAqB,IAAI,SAAS,GAAG;AAAA,MAChD,MAAM,IAAI,MACR,oEAAoE,uKACtE;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAI,QAAQ,QAAQ,QAAQ,SAAS,QAAQ,MAAM;AAAA,IACjD,MAAM,IAAI,MAAM,gGAAgG;AAAA,EAClH;AAAA,EAEA,IAAI,QAAQ,WAAW,oBAAoB,QAAQ,OAAO,MAAM,QAAQ,YAAY;AAAA,IAClF,MAAM,IAAI,MAAM,0FAA0F;AAAA,EAC5G;AAAA;AAGK,SAAS,0BAA0B,CAAC,UAAsC,CAAC,GAAY;AAAA,EAC5F,MAAM,QAAQ;AAAA,EACd,MAAM,UAAU,MAAM;AAAA,EAEtB,IAAI,SAAS;AAAA,IACX,wBAAwB,SAAS,OAAO;AAAA,IACxC,OAAO;AAAA,EACT;AAAA,EAEA,kBAAkB,oBAAoB,OAAO,CAAC;AAAA,EAE9C,MAAM,oCAAoC;AAAA,IACxC,sBAAsB,IAAI,IAAI,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,CAAC;AAAA,IACnE,MAAM,QAAQ;AAAA,IACd,YAAY,oBAAoB,QAAQ,OAAO;AAAA,EACjD;AAAA,EACA,OAAO;AAAA;",
"debugId": "09C0597CB92E654F64756E2164756E21",
"names": []
}
// @bun
import {
exports_src
} from "./index-qndc8vq8.js";
import {
__require
} from "./index-mn090kzf.js";
// src/runtime-plugin.ts
import { existsSync, readFileSync, realpathSync } from "fs";
import { basename, dirname, isAbsolute, join } from "path";
import { fileURLToPath } from "url";
var CORE_RUNTIME_SPECIFIER = "@opentui/core";
var CORE_TESTING_RUNTIME_SPECIFIER = "@opentui/core/testing";
var RUNTIME_MODULE_PREFIX = "opentui:runtime-module:";
var MAX_RUNTIME_RESOLVE_PARENTS = 64;
var DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS = {
nodeModulesRuntimeSpecifiers: true,
nodeModulesBareSpecifiers: false
};
var DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS = [CORE_RUNTIME_SPECIFIER, CORE_TESTING_RUNTIME_SPECIFIER];
var DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET = new Set(DEFAULT_CORE_RUNTIME_MODULE_SPECIFIERS);
var isCoreRuntimeModuleSpecifier = (specifier) => {
return DEFAULT_CORE_RUNTIME_MODULE_SPECIFIER_SET.has(specifier);
};
var loadCoreTestingRuntimeModule = async () => {
return await import("./testing.js");
};
var escapeRegExp = (value) => {
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
};
var exactSpecifierFilter = (specifier) => {
return new RegExp(`^${escapeRegExp(specifier)}$`);
};
var exactPathFilter = (paths) => {
const candidates = [...new Set(paths.map(sourcePath))];
return new RegExp(`^(?:${candidates.map(escapeRegExp).join("|")})(?:[?#].*)?$`);
};
var runtimeModuleIdForSpecifier = (specifier) => {
return `${RUNTIME_MODULE_PREFIX}${encodeURIComponent(specifier)}`;
};
var resolveRuntimeModuleExports = async (moduleEntry) => {
if (typeof moduleEntry === "function") {
return await moduleEntry();
}
return moduleEntry;
};
var sourcePath = (path) => {
const searchIndex = path.indexOf("?");
const hashIndex = path.indexOf("#");
const end = [searchIndex, hashIndex].filter((index) => index >= 0).sort((a, b) => a - b)[0];
return end === undefined ? path : path.slice(0, end);
};
var normalizedSourcePathByPath = new Map;
var normalizeSourcePath = (path) => {
const cleanPath = sourcePath(path);
const cachedPath = normalizedSourcePathByPath.get(cleanPath);
if (cachedPath !== undefined) {
return cachedPath;
}
let normalizedPath = cleanPath;
try {
normalizedPath = realpathSync(cleanPath);
} catch {
normalizedPath = cleanPath;
}
normalizedSourcePathByPath.set(cleanPath, normalizedPath);
return normalizedPath;
};
var isNodeModulesPath = (path) => {
return /(?:^|[/\\])node_modules(?:[/\\])/.test(path);
};
var packageTypeForPath = (path, packageTypeByPackageJsonPath) => {
let currentDir = dirname(path);
while (true) {
const packageJsonPath = join(currentDir, "package.json");
if (existsSync(packageJsonPath)) {
const cachedPackageType = packageTypeByPackageJsonPath.get(packageJsonPath);
if (cachedPackageType) {
return cachedPackageType;
}
let packageType = "commonjs";
try {
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
if (packageJson.type === "module") {
packageType = "module";
}
} catch {
packageType = "commonjs";
}
packageTypeByPackageJsonPath.set(packageJsonPath, packageType);
return packageType;
}
const parentDir = dirname(currentDir);
if (parentDir === currentDir) {
return "commonjs";
}
currentDir = parentDir;
}
};
var isNodeModulesEsmPath = (path, packageTypeByPackageJsonPath) => {
const normalizedPath = normalizeSourcePath(path);
if (!isNodeModulesPath(normalizedPath)) {
return false;
}
if (normalizedPath.endsWith(".mjs") || normalizedPath.endsWith(".mts") || normalizedPath.endsWith(".ts") || normalizedPath.endsWith(".tsx") || normalizedPath.endsWith(".jsx")) {
return true;
}
if (normalizedPath.endsWith(".cjs") || normalizedPath.endsWith(".cts") || !normalizedPath.endsWith(".js")) {
return false;
}
return packageTypeForPath(normalizedPath, packageTypeByPackageJsonPath) === "module";
};
var nodeModulesPackageRootForPath = (path) => {
let currentDir = dirname(path);
while (true) {
const parentDir = dirname(currentDir);
if (parentDir === currentDir) {
return null;
}
if (basename(parentDir) === "node_modules") {
return currentDir;
}
if (basename(dirname(parentDir)) === "node_modules" && basename(parentDir).startsWith("@")) {
return currentDir;
}
currentDir = parentDir;
}
};
var resolveRuntimePluginRewriteOptions = (options) => {
return {
nodeModulesRuntimeSpecifiers: options?.nodeModulesRuntimeSpecifiers ?? DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS.nodeModulesRuntimeSpecifiers,
nodeModulesBareSpecifiers: options?.nodeModulesBareSpecifiers ?? DEFAULT_RUNTIME_PLUGIN_REWRITE_OPTIONS.nodeModulesBareSpecifiers
};
};
var runtimeLoaderForPath = (path) => {
const cleanPath = sourcePath(path);
if (cleanPath.endsWith(".tsx")) {
return "tsx";
}
if (cleanPath.endsWith(".jsx")) {
return "jsx";
}
if (cleanPath.endsWith(".ts") || cleanPath.endsWith(".mts") || cleanPath.endsWith(".cts")) {
return "ts";
}
if (cleanPath.endsWith(".js") || cleanPath.endsWith(".mjs") || cleanPath.endsWith(".cjs")) {
return "js";
}
return null;
};
var resolveImportSpecifierPatterns = [
/(from\s+["'])([^"']+)(["'])/g,
/(import\s+["'])([^"']+)(["'])/g,
/(import\s*\(\s*["'])([^"']+)(["']\s*\))/g,
/(require\s*\(\s*["'])([^"']+)(["']\s*\))/g
];
var isBareSpecifier = (specifier) => {
if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("\\")) {
return false;
}
if (specifier.startsWith("node:") || specifier.startsWith("bun:") || specifier.startsWith("http:") || specifier.startsWith("https:") || specifier.startsWith("file:") || specifier.startsWith("data:")) {
return false;
}
if (specifier.startsWith(RUNTIME_MODULE_PREFIX)) {
return false;
}
return true;
};
var registerResolveParent = (resolveParentsByRecency, resolveParent) => {
const existingIndex = resolveParentsByRecency.indexOf(resolveParent);
if (existingIndex >= 0) {
resolveParentsByRecency.splice(existingIndex, 1);
}
resolveParentsByRecency.push(resolveParent);
if (resolveParentsByRecency.length > MAX_RUNTIME_RESOLVE_PARENTS) {
resolveParentsByRecency.shift();
}
};
var rewriteImportSpecifiers = (code, resolveReplacement) => {
let transformedCode = code;
for (const pattern of resolveImportSpecifierPatterns) {
transformedCode = transformedCode.replace(pattern, (fullMatch, prefix, specifier, suffix) => {
const replacement = resolveReplacement(specifier);
if (!replacement || replacement === specifier) {
return fullMatch;
}
return `${prefix}${replacement}${suffix}`;
});
}
return transformedCode;
};
var collectImportSpecifiers = (code) => {
const specifiers = new Set;
for (const pattern of resolveImportSpecifierPatterns) {
code.replace(pattern, (_fullMatch, _prefix, specifier) => {
specifiers.add(specifier);
return _fullMatch;
});
}
return [...specifiers];
};
var resolveFromParent = (specifier, parent) => {
try {
const resolvedSpecifier = import.meta.resolve(specifier, parent);
if (resolvedSpecifier === specifier || resolvedSpecifier.startsWith("node:") || resolvedSpecifier.startsWith("bun:")) {
return null;
}
return resolvedSpecifier;
} catch {
return null;
}
};
var resolveSourcePathFromSpecifier = (specifier, importer) => {
if (specifier.startsWith("node:") || specifier.startsWith("bun:") || specifier.startsWith("http:") || specifier.startsWith("https:") || specifier.startsWith("data:") || specifier.startsWith(RUNTIME_MODULE_PREFIX)) {
return null;
}
if (specifier.startsWith("file:")) {
return sourcePath(fileURLToPath(specifier));
}
if (isAbsolute(specifier)) {
return sourcePath(specifier);
}
const resolvedSpecifier = resolveFromParent(specifier, importer);
if (!resolvedSpecifier) {
return null;
}
if (resolvedSpecifier.startsWith("file:")) {
return sourcePath(fileURLToPath(resolvedSpecifier));
}
if (isAbsolute(resolvedSpecifier)) {
return sourcePath(resolvedSpecifier);
}
return null;
};
var rewriteImportsFromResolveParents = (code, resolveParentsByRecency) => {
if (resolveParentsByRecency.length === 0) {
return code;
}
const resolveFromParents = (specifier) => {
if (!isBareSpecifier(specifier)) {
return null;
}
for (let index = resolveParentsByRecency.length - 1;index >= 0; index -= 1) {
const resolveParent = resolveParentsByRecency[index];
const resolvedSpecifier = resolveFromParent(specifier, resolveParent);
if (resolvedSpecifier) {
return resolvedSpecifier;
}
}
return null;
};
return rewriteImportSpecifiers(code, resolveFromParents);
};
var rewriteRuntimeSpecifiers = (code, runtimeModuleIdsBySpecifier) => {
return rewriteImportSpecifiers(code, (specifier) => {
const runtimeModuleId = runtimeModuleIdsBySpecifier.get(specifier);
return runtimeModuleId ?? null;
});
};
function createRuntimePlugin(input = {}) {
const runtimeModules = new Map;
runtimeModules.set(CORE_RUNTIME_SPECIFIER, input.core ?? exports_src);
runtimeModules.set(CORE_TESTING_RUNTIME_SPECIFIER, loadCoreTestingRuntimeModule);
const rewriteOptions = resolveRuntimePluginRewriteOptions(input.rewrite);
for (const [specifier, moduleEntry] of Object.entries(input.additional ?? {})) {
runtimeModules.set(specifier, moduleEntry);
}
const runtimeModuleIdsBySpecifier = new Map;
for (const specifier of runtimeModules.keys()) {
runtimeModuleIdsBySpecifier.set(specifier, runtimeModuleIdForSpecifier(specifier));
}
return {
name: "bun-plugin-opentui-runtime-modules",
setup: (build) => {
const resolveParentsByRecency = [];
const installedRewriteLoaders = new Set;
const nodeModulesBareRewritePackageRoots = new Set;
const packageTypeByPackageJsonPath = new Map;
const sourceAnalysisByPath = new Map;
const nodeModulesRuntimeRewritePathsByPath = new Map;
const installRewriteLoader = (path) => {
const resolvedTargetPath = sourcePath(path);
const canonicalTargetPath = normalizeSourcePath(resolvedTargetPath);
if (installedRewriteLoaders.has(canonicalTargetPath)) {
return;
}
installedRewriteLoaders.add(canonicalTargetPath);
build.onLoad({ filter: exactPathFilter([resolvedTargetPath, canonicalTargetPath]) }, async (args) => {
const loadedPath = normalizeSourcePath(args.path);
if (loadedPath !== canonicalTargetPath) {
return;
}
const nodeModulesPath = isNodeModulesPath(loadedPath);
const shouldRewriteRuntimeSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesRuntimeSpecifiers;
const shouldRewriteBareSpecifiers = !nodeModulesPath || rewriteOptions.nodeModulesBareSpecifiers;
const loader = runtimeLoaderForPath(args.path);
if (!loader) {
throw new Error(`Unable to determine runtime loader for path: ${args.path}`);
}
const contents = await Bun.file(loadedPath).text();
const runtimeRewrittenContents = shouldRewriteRuntimeSpecifiers ? rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier) : contents;
if (runtimeRewrittenContents !== contents && shouldRewriteBareSpecifiers) {
registerResolveParent(resolveParentsByRecency, loadedPath);
}
const transformedContents = shouldRewriteBareSpecifiers ? rewriteImportsFromResolveParents(runtimeRewrittenContents, resolveParentsByRecency) : runtimeRewrittenContents;
return {
contents: transformedContents,
loader
};
});
};
const analyzeSourcePath = (path) => {
const normalizedPath = normalizeSourcePath(path);
const cachedAnalysis = sourceAnalysisByPath.get(normalizedPath);
if (cachedAnalysis) {
return cachedAnalysis;
}
let contents;
try {
contents = readFileSync(normalizedPath, "utf8");
} catch (error) {
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
const analysis2 = { importSpecifiers: [], needsRuntimeSpecifierRewrite: false };
sourceAnalysisByPath.set(normalizedPath, analysis2);
return analysis2;
}
throw error;
}
const importSpecifiers = collectImportSpecifiers(contents);
const analysis = {
importSpecifiers,
needsRuntimeSpecifierRewrite: importSpecifiers.some((specifier) => runtimeModuleIdsBySpecifier.has(specifier))
};
sourceAnalysisByPath.set(normalizedPath, analysis);
return analysis;
};
const collectNodeModulesRuntimeRewritePaths = (path, visiting = new Set) => {
const normalizedPath = normalizeSourcePath(path);
if (!isNodeModulesEsmPath(normalizedPath, packageTypeByPackageJsonPath)) {
return [];
}
const cachedPaths = nodeModulesRuntimeRewritePathsByPath.get(normalizedPath);
if (cachedPaths) {
return cachedPaths;
}
if (visiting.has(normalizedPath)) {
return [];
}
visiting.add(normalizedPath);
const rewritePaths = new Set;
const analysis = analyzeSourcePath(normalizedPath);
if (analysis.needsRuntimeSpecifierRewrite) {
rewritePaths.add(normalizedPath);
}
for (const specifier of analysis.importSpecifiers) {
const resolvedPath = resolveSourcePathFromSpecifier(specifier, normalizedPath);
if (!resolvedPath || !isNodeModulesEsmPath(resolvedPath, packageTypeByPackageJsonPath)) {
continue;
}
for (const nestedPath of collectNodeModulesRuntimeRewritePaths(resolvedPath, visiting)) {
rewritePaths.add(nestedPath);
}
}
visiting.delete(normalizedPath);
const resolvedRewritePaths = [...rewritePaths];
nodeModulesRuntimeRewritePathsByPath.set(normalizedPath, resolvedRewritePaths);
return resolvedRewritePaths;
};
for (const [specifier, moduleEntry] of runtimeModules.entries()) {
const moduleId = runtimeModuleIdsBySpecifier.get(specifier);
if (!moduleId) {
continue;
}
build.module(moduleId, async () => ({
exports: await resolveRuntimeModuleExports(moduleEntry),
loader: "object"
}));
build.onResolve({ filter: exactSpecifierFilter(specifier) }, () => ({ path: moduleId }));
}
build.onResolve({ filter: /.*/ }, (args) => {
if (runtimeModuleIdsBySpecifier.has(args.path) || args.path.startsWith(RUNTIME_MODULE_PREFIX)) {
return;
}
const path = resolveSourcePathFromSpecifier(args.path, args.importer);
if (!path || !runtimeLoaderForPath(path)) {
return;
}
const nodeModulesPath = isNodeModulesPath(path);
if (!nodeModulesPath) {
installRewriteLoader(path);
return;
}
if (!rewriteOptions.nodeModulesRuntimeSpecifiers && !rewriteOptions.nodeModulesBareSpecifiers) {
return;
}
for (const rewritePath of collectNodeModulesRuntimeRewritePaths(path)) {
installRewriteLoader(rewritePath);
}
const packageRoot = nodeModulesPackageRootForPath(path);
if (rewriteOptions.nodeModulesBareSpecifiers && packageRoot && nodeModulesBareRewritePackageRoots.has(packageRoot)) {
installRewriteLoader(path);
return;
}
if (!rewriteOptions.nodeModulesRuntimeSpecifiers || !analyzeSourcePath(path).needsRuntimeSpecifierRewrite) {
return;
}
if (rewriteOptions.nodeModulesBareSpecifiers && packageRoot) {
nodeModulesBareRewritePackageRoots.add(packageRoot);
}
installRewriteLoader(path);
return;
});
}
};
}
export { isCoreRuntimeModuleSpecifier, runtimeModuleIdForSpecifier, createRuntimePlugin };
//# debugId=4F4ECA92927B118964756E2164756E21
//# sourceMappingURL=index-mbck6rbg.js.map
{
"version": 3,
"sources": ["../src/runtime-plugin.ts"],
"sourcesContent": [
"/*\n * Exposes runtime-only modules (for example `@opentui/core`, `@opentui/solid`,\n * `solid-js`) to externally loaded plugins by rewriting matching imports to\n * virtual `opentui:runtime-module:*` ids.\n *\n * Why this is exact-path + prescan instead of one broad `onLoad`:\n * - Bun can break CJS/UMD interop if a file is routed through plugin `onLoad`\n * (real repro: `jsonc-parser` resolving to `lib/umd/main.js`;\n * https://github.com/oven-sh/bun/issues/19279,\n * https://github.com/oven-sh/bun/issues/21369), so arbitrary `node_modules`\n * JS cannot be blanket-rewritten.\n * - runtime `onResolve` is sync-only, so package/type/source discovery here is\n * synchronous and cached.\n * - a matched `onLoad` cannot safely fall through, so loaders must be narrow.\n * - Bun may canonicalize paths before `onLoad`, so loaders are registered for\n * both the resolved path spelling and its realpath, then canonical-checked.\n * - Bun may native-load `node_modules` ESM without firing `onResolve` for\n * nested package imports, so `node_modules` ESM is recursively prescanned and\n * only files that actually need runtime rewriting get exact-path loaders.\n *\n * Behavior:\n * - non-`node_modules` source files get a dedicated rewrite loader immediately.\n * - `node_modules` files are rewritten only if they are ESM (`.mjs`, `.mts`,\n * `.ts`, `.tsx`, `.jsx`, or `.js` under `package.json#type=\"module\"`) and\n * directly or transitively need runtime-module rewriting; unrelated CJS stays\n * untouched.\n * - optional bare-specifier rewriting is preserved for sibling files in\n * packages already marked for runtime rewriting.\n *\n * Notes:\n * - import scanning is regex-based, not a full parser.\n * - CJS helper libraries that themselves import runtime modules are still not\n * supported.\n * - `package.json#type` caching is per plugin setup, not module-global, so a\n * later plugin instance in the same process can observe filesystem changes.\n */\nimport { existsSync, readFileSync, realpathSync } from \"node:fs\"\nimport { basename, dirname, isAbsolute, join } 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\ninterface SourceAnalysis {\n importSpecifiers: string[]\n needsRuntimeSpecifierRewrite: boolean\n}\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 = (paths: string[]): RegExp => {\n const candidates = [...new Set(paths.map(sourcePath))]\n return new RegExp(`^(?:${candidates.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 normalizedSourcePathByPath = new Map<string, string>()\n\nconst normalizeSourcePath = (path: string): string => {\n const cleanPath = sourcePath(path)\n const cachedPath = normalizedSourcePathByPath.get(cleanPath)\n if (cachedPath !== undefined) {\n return cachedPath\n }\n\n let normalizedPath = cleanPath\n\n try {\n normalizedPath = realpathSync(cleanPath)\n } catch {\n normalizedPath = cleanPath\n }\n\n normalizedSourcePathByPath.set(cleanPath, normalizedPath)\n return normalizedPath\n}\n\nconst isNodeModulesPath = (path: string): boolean => {\n return /(?:^|[/\\\\])node_modules(?:[/\\\\])/.test(path)\n}\n\nconst packageTypeForPath = (\n path: string,\n packageTypeByPackageJsonPath: Map<string, \"module\" | \"commonjs\">,\n): \"module\" | \"commonjs\" => {\n let currentDir = dirname(path)\n\n while (true) {\n const packageJsonPath = join(currentDir, \"package.json\")\n if (existsSync(packageJsonPath)) {\n const cachedPackageType = packageTypeByPackageJsonPath.get(packageJsonPath)\n if (cachedPackageType) {\n return cachedPackageType\n }\n\n let packageType: \"module\" | \"commonjs\" = \"commonjs\"\n\n try {\n const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { type?: string }\n if (packageJson.type === \"module\") {\n packageType = \"module\"\n }\n } catch {\n packageType = \"commonjs\"\n }\n\n packageTypeByPackageJsonPath.set(packageJsonPath, packageType)\n return packageType\n }\n\n const parentDir = dirname(currentDir)\n if (parentDir === currentDir) {\n return \"commonjs\"\n }\n\n currentDir = parentDir\n }\n}\n\nconst isNodeModulesEsmPath = (\n path: string,\n packageTypeByPackageJsonPath: Map<string, \"module\" | \"commonjs\">,\n): boolean => {\n const normalizedPath = normalizeSourcePath(path)\n\n if (!isNodeModulesPath(normalizedPath)) {\n return false\n }\n\n if (\n normalizedPath.endsWith(\".mjs\") ||\n normalizedPath.endsWith(\".mts\") ||\n normalizedPath.endsWith(\".ts\") ||\n normalizedPath.endsWith(\".tsx\") ||\n normalizedPath.endsWith(\".jsx\")\n ) {\n return true\n }\n\n if (normalizedPath.endsWith(\".cjs\") || normalizedPath.endsWith(\".cts\") || !normalizedPath.endsWith(\".js\")) {\n return false\n }\n\n return packageTypeForPath(normalizedPath, packageTypeByPackageJsonPath) === \"module\"\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 collectImportSpecifiers = (code: string): string[] => {\n const specifiers = new Set<string>()\n\n for (const pattern of resolveImportSpecifierPatterns) {\n code.replace(pattern, (_fullMatch, _prefix, specifier) => {\n specifiers.add(specifier)\n return _fullMatch\n })\n }\n\n return [...specifiers]\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 sourcePath(fileURLToPath(specifier))\n }\n\n if (isAbsolute(specifier)) {\n return sourcePath(specifier)\n }\n\n const resolvedSpecifier = resolveFromParent(specifier, importer)\n if (!resolvedSpecifier) {\n return null\n }\n\n if (resolvedSpecifier.startsWith(\"file:\")) {\n return sourcePath(fileURLToPath(resolvedSpecifier))\n }\n\n if (isAbsolute(resolvedSpecifier)) {\n return sourcePath(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 packageTypeByPackageJsonPath = new Map<string, \"module\" | \"commonjs\">()\n const sourceAnalysisByPath = new Map<string, SourceAnalysis>()\n const nodeModulesRuntimeRewritePathsByPath = new Map<string, string[]>()\n\n const installRewriteLoader = (path: string): void => {\n const resolvedTargetPath = sourcePath(path)\n const canonicalTargetPath = normalizeSourcePath(resolvedTargetPath)\n\n if (installedRewriteLoaders.has(canonicalTargetPath)) {\n return\n }\n\n installedRewriteLoaders.add(canonicalTargetPath)\n\n // Register both the resolved path spelling and its canonical realpath so Bun\n // can reach the loader even if it reports the same file through a different alias.\n build.onLoad({ filter: exactPathFilter([resolvedTargetPath, canonicalTargetPath]) }, async (args) => {\n const loadedPath = normalizeSourcePath(args.path)\n if (loadedPath !== canonicalTargetPath) {\n return undefined\n }\n\n const nodeModulesPath = isNodeModulesPath(loadedPath)\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(loadedPath).text()\n const runtimeRewrittenContents = shouldRewriteRuntimeSpecifiers\n ? rewriteRuntimeSpecifiers(contents, runtimeModuleIdsBySpecifier)\n : contents\n\n if (runtimeRewrittenContents !== contents && shouldRewriteBareSpecifiers) {\n registerResolveParent(resolveParentsByRecency, loadedPath)\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 analyzeSourcePath = (path: string): SourceAnalysis => {\n const normalizedPath = normalizeSourcePath(path)\n const cachedAnalysis = sourceAnalysisByPath.get(normalizedPath)\n if (cachedAnalysis) {\n return cachedAnalysis\n }\n\n let contents: string\n try {\n contents = readFileSync(normalizedPath, \"utf8\")\n } catch (error) {\n if (error && typeof error === \"object\" && \"code\" in error && error.code === \"ENOENT\") {\n const analysis = { importSpecifiers: [], needsRuntimeSpecifierRewrite: false }\n sourceAnalysisByPath.set(normalizedPath, analysis)\n return analysis\n }\n throw error\n }\n\n const importSpecifiers = collectImportSpecifiers(contents)\n const analysis = {\n importSpecifiers,\n needsRuntimeSpecifierRewrite: importSpecifiers.some((specifier) =>\n runtimeModuleIdsBySpecifier.has(specifier),\n ),\n }\n\n sourceAnalysisByPath.set(normalizedPath, analysis)\n return analysis\n }\n\n const collectNodeModulesRuntimeRewritePaths = (path: string, visiting = new Set<string>()): string[] => {\n const normalizedPath = normalizeSourcePath(path)\n\n if (!isNodeModulesEsmPath(normalizedPath, packageTypeByPackageJsonPath)) {\n return []\n }\n\n const cachedPaths = nodeModulesRuntimeRewritePathsByPath.get(normalizedPath)\n if (cachedPaths) {\n return cachedPaths\n }\n\n if (visiting.has(normalizedPath)) {\n return []\n }\n\n visiting.add(normalizedPath)\n\n const rewritePaths = new Set<string>()\n const analysis = analyzeSourcePath(normalizedPath)\n\n if (analysis.needsRuntimeSpecifierRewrite) {\n rewritePaths.add(normalizedPath)\n }\n\n for (const specifier of analysis.importSpecifiers) {\n const resolvedPath = resolveSourcePathFromSpecifier(specifier, normalizedPath)\n if (!resolvedPath || !isNodeModulesEsmPath(resolvedPath, packageTypeByPackageJsonPath)) {\n continue\n }\n\n for (const nestedPath of collectNodeModulesRuntimeRewritePaths(resolvedPath, visiting)) {\n rewritePaths.add(nestedPath)\n }\n }\n\n visiting.delete(normalizedPath)\n\n const resolvedRewritePaths = [...rewritePaths]\n nodeModulesRuntimeRewritePathsByPath.set(normalizedPath, resolvedRewritePaths)\n return resolvedRewritePaths\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 for (const rewritePath of collectNodeModulesRuntimeRewritePaths(path)) {\n installRewriteLoader(rewritePath)\n }\n\n const packageRoot = nodeModulesPackageRootForPath(path)\n if (\n rewriteOptions.nodeModulesBareSpecifiers &&\n packageRoot &&\n nodeModulesBareRewritePackageRoots.has(packageRoot)\n ) {\n installRewriteLoader(path)\n return undefined\n }\n\n if (!rewriteOptions.nodeModulesRuntimeSpecifiers || !analyzeSourcePath(path).needsRuntimeSpecifierRewrite) {\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"
],
"mappings": ";;;;;;;;;AAoCA;AACA;AACA;AAwBA,IAAM,yBAAyB;AAC/B,IAAM,iCAAiC;AACvC,IAAM,wBAAwB;AAC9B,IAAM,8BAA8B;AAC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I,4BAA4B,IAAI,KAAK,IAAI,KAAK,KAAK,KAAK,WAAW,qBAAqB,GAAG;AAAA,UAC7F;AAAA,QACF;AAAA,QAEA,MAAM,OAAO,+BAA+B,KAAK,MAAM,KAAK,QAAQ;AAAA,QACpE,IAAI,CAAC,QAAQ,CAAC,qBAAqB,IAAI,GAAG;AAAA,UACxC;AAAA,QACF;AAAA,QAEA,MAAM,kBAAkB,kBAAkB,IAAI;AAAA,QAE9C,IAAI,CAAC,iBAAiB;AAAA,UACpB,qBAAqB,IAAI;AAAA,UACzB;AAAA,QACF;AAAA,QAEA,IAAI,CAAC,eAAe,gCAAgC,CAAC,eAAe,2BAA2B;AAAA,UAC7F;AAAA,QACF;AAAA,QAEA,WAAW,eAAe,sCAAsC,IAAI,GAAG;AAAA,UACrE,qBAAqB,WAAW;AAAA,QAClC;AAAA,QAEA,MAAM,cAAc,8BAA8B,IAAI;AAAA,QACtD,IACE,eAAe,6BACf,eACA,mCAAmC,IAAI,WAAW,GAClD;AAAA,UACA,qBAAqB,IAAI;AAAA,UACzB;AAAA,QACF;AAAA,QAEA,IAAI,CAAC,eAAe,gCAAgC,CAAC,kBAAkB,IAAI,EAAE,8BAA8B;AAAA,UACzG;AAAA,QACF;AAAA,QAEA,IAAI,eAAe,6BAA6B,aAAa;AAAA,UAC3D,mCAAmC,IAAI,WAAW;AAAA,QACpD;AAAA,QAEA,qBAAqB,IAAI;AAAA,QACzB;AAAA,OACD;AAAA;AAAA,EAEL;AAAA;",
"debugId": "4F4ECA92927B118964756E2164756E21",
"names": []
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display