Comparing version 16.3.2 to 16.3.3-beta.1
// src/application-host/application-loader-legacy.js | ||
import esbuild from "esbuild"; | ||
import { fileURLToPath } from "node:url"; | ||
import fs5 from "node:fs"; | ||
// node_modules/.pnpm/resolve.exports@2.0.2/node_modules/resolve.exports/dist/index.mjs | ||
function e(e2, n2, r2) { | ||
throw new Error(r2 ? `No known conditions for "${n2}" specifier in "${e2}" package` : `Missing "${n2}" specifier in "${e2}" package`); | ||
} | ||
function n(n2, i, o2, f2) { | ||
let s, u, l = r(n2, o2), c = function(e2) { | ||
let n3 = /* @__PURE__ */ new Set(["default", ...e2.conditions || []]); | ||
return e2.unsafe || n3.add(e2.require ? "require" : "import"), e2.unsafe || n3.add(e2.browser ? "browser" : "node"), n3; | ||
}(f2 || {}), a = i[l]; | ||
if (void 0 === a) { | ||
let e2, n3, r2, t2; | ||
for (t2 in i) | ||
n3 && t2.length < n3.length || ("/" === t2[t2.length - 1] && l.startsWith(t2) ? (u = l.substring(t2.length), n3 = t2) : t2.length > 1 && (r2 = t2.indexOf("*", 1), ~r2 && (e2 = RegExp("^" + t2.substring(0, r2) + "(.*)" + t2.substring(1 + r2)).exec(l), e2 && e2[1] && (u = e2[1], n3 = t2)))); | ||
a = i[n3]; | ||
} | ||
return a || e(n2, l), s = t(a, c), s || e(n2, l, 1), u && function(e2, n3) { | ||
let r2, t2 = 0, i2 = e2.length, o3 = /[*]/g, f3 = /[/]$/; | ||
for (; t2 < i2; t2++) | ||
e2[t2] = o3.test(r2 = e2[t2]) ? r2.replace(o3, n3) : f3.test(r2) ? r2 + n3 : r2; | ||
}(s, u), s; | ||
} | ||
function r(e2, n2, r2) { | ||
if (e2 === n2 || "." === n2) | ||
return "."; | ||
let t2 = e2 + "/", i = t2.length, o2 = n2.slice(0, i) === t2, f2 = o2 ? n2.slice(i) : n2; | ||
return "#" === f2[0] ? f2 : o2 || !r2 ? "./" === f2.slice(0, 2) ? f2 : "./" + f2 : f2; | ||
} | ||
function t(e2, n2, r2) { | ||
if (e2) { | ||
if ("string" == typeof e2) | ||
return r2 && r2.add(e2), [e2]; | ||
let i, o2; | ||
if (Array.isArray(e2)) { | ||
for (o2 = r2 || /* @__PURE__ */ new Set(), i = 0; i < e2.length; i++) | ||
t(e2[i], n2, o2); | ||
if (!r2 && o2.size) | ||
return [...o2]; | ||
} else | ||
for (i in e2) | ||
if (n2.has(i)) | ||
return t(e2[i], n2, r2); | ||
} | ||
} | ||
function o(e2, r2, t2) { | ||
let i, o2 = e2.exports; | ||
if (o2) { | ||
if ("string" == typeof o2) | ||
o2 = { ".": o2 }; | ||
else | ||
for (i in o2) { | ||
"." !== i[0] && (o2 = { ".": o2 }); | ||
break; | ||
} | ||
return n(e2.name, o2, r2 || ".", t2); | ||
} | ||
} | ||
function f(e2, r2, t2) { | ||
if (e2.imports) | ||
return n(e2.name, e2.imports, r2, t2); | ||
} | ||
// src/utils/broken-named-exports.js | ||
var broken_named_exports_default = { | ||
react: [ | ||
"Children", | ||
"Component", | ||
"Fragment", | ||
"Profiler", | ||
"PureComponent", | ||
"StrictMode", | ||
"Suspense", | ||
"__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED", | ||
"cloneElement", | ||
"createContext", | ||
"createElement", | ||
"createFactory", | ||
"createRef", | ||
"forwardRef", | ||
"isValidElement", | ||
"lazy", | ||
"memo", | ||
"useCallback", | ||
"useContext", | ||
"useDebugValue", | ||
"useEffect", | ||
"useImperativeHandle", | ||
"useLayoutEffect", | ||
"useMemo", | ||
"useReducer", | ||
"useRef", | ||
"useState", | ||
"version" | ||
], | ||
"react-dom": [ | ||
"__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED", | ||
"createPortal", | ||
"findDOMNode", | ||
"flushSync", | ||
"hydrate", | ||
"render", | ||
"unmountComponentAtNode", | ||
"unstable_batchedUpdates", | ||
"unstable_createPortal", | ||
"unstable_renderSubtreeIntoContainer", | ||
"version" | ||
], | ||
"react-is": ["isContextConsumer", "isValidElementType"] | ||
}; | ||
// src/config.js | ||
import path from "node:path"; | ||
import { pathToFileURL } from "node:url"; | ||
var DIR_NAME = ".dvlp"; | ||
var TESTING = process.env.NODE_ENV === "dvlptest" || process.env.CI != void 0; | ||
var VERSION = global.$VERSION || "0.0.0"; | ||
var dirPath = path.resolve(DIR_NAME); | ||
var versionDirPath = path.join(dirPath, VERSION); | ||
var applicationLoaderURL = pathToFileURL( | ||
path.join(versionDirPath, "app-loader.mjs") | ||
); | ||
var bundleDirName = path.join(DIR_NAME, VERSION, "bundled"); | ||
var bundleDirPath = path.resolve(bundleDirName); | ||
var bundleDirMetaPath = path.join(bundleDirPath, "__meta__.json"); | ||
var defaultPort = process.env.PORT ? Number(process.env.PORT) : 8080; | ||
var electronEntryURL = pathToFileURL( | ||
path.join(versionDirPath, "electron-entry.mjs") | ||
); | ||
var config = { | ||
activePort: defaultPort, | ||
applicationLoaderURL, | ||
brokenNamedExportsPackages: broken_named_exports_default, | ||
bundleDirPath, | ||
bundleDirMetaPath, | ||
bundleDirName, | ||
defaultPort, | ||
directories: [], | ||
dirPath, | ||
dvlpDirPath: path.resolve(DIR_NAME), | ||
electronEntryURL, | ||
esbuildTargetByExtension: { | ||
".js": "js", | ||
".mjs": "js", | ||
".cjs": "js", | ||
".json": "json", | ||
".jsx": "jsx", | ||
".ts": "ts", | ||
".tsx": "tsx", | ||
".mts": "ts", | ||
".cts": "ts" | ||
}, | ||
// Ordered to trigger transpiling if necessary | ||
extensionsByType: { | ||
css: [".pcss", ".sass", ".scss", ".less", ".styl", ".stylus", ".css"], | ||
html: [ | ||
".nunjs", | ||
".nunjucks", | ||
".hbs", | ||
".handlebars", | ||
".dust", | ||
".html", | ||
".htm" | ||
], | ||
js: [".ts", ".mts", ".cts", ".tsx", ".jsx", ".mjs", ".cjs", ".js", ".json"] | ||
}, | ||
latency: 50, | ||
maxAge: "60", | ||
maxAgeLong: "3600", | ||
reloadEndpoint: "/dvlpreload", | ||
serverStartTimeout: TESTING ? 4e3 : 1e4, | ||
testing: TESTING, | ||
typesByExtension: { | ||
".css": "css", | ||
".pcss": "css", | ||
".sass": "css", | ||
".scss": "css", | ||
".less": "css", | ||
".styl": "css", | ||
".stylus": "css", | ||
".html": "html", | ||
".htm": "html", | ||
".nunjs": "html", | ||
".nunjucks": "html", | ||
".hbs": "html", | ||
".handlebars": "html", | ||
".dust": "html", | ||
".js": "js", | ||
".mjs": "js", | ||
".cjs": "js", | ||
".json": "js", | ||
".jsx": "js", | ||
".ts": "js", | ||
".tsx": "js", | ||
".mts": "js", | ||
".cts": "js" | ||
}, | ||
version: VERSION, | ||
versionDirPath | ||
}; | ||
var config_default = config; | ||
// src/utils/is.js | ||
import fs from "node:fs"; | ||
import path2 from "node:path"; | ||
var RE_BARE_SPECIFIER = /^[^./](?!:)/; | ||
var RE_NODE_MODULES = /node_modules/; | ||
var RE_TYPE_CSS = /text\/css/i; | ||
var RE_TYPE_HTML = /text\/html/i; | ||
var RE_TYPE_JS = /application\/javascript/i; | ||
var realPath = "native" in fs.realpathSync && typeof fs.realpathSync.native === "function" ? fs.realpathSync.native : fs.realpathSync; | ||
function isAbsoluteFilePath(filePath) { | ||
return "string" == typeof filePath && path2.isAbsolute(filePath) && // Only absolute if from root | ||
path2.resolve(filePath).startsWith(process.cwd().slice(0, 5)); | ||
} | ||
function isBareSpecifier(id) { | ||
return RE_BARE_SPECIFIER.test(id); | ||
} | ||
function isBundledUrl(url) { | ||
return url.includes(config_default.bundleDirName.replace(/\\/g, "/")); | ||
} | ||
function isCssFilePath(filePath) { | ||
return config_default.extensionsByType.css.includes(path2.extname(filePath)); | ||
} | ||
function isCssRequest(req) { | ||
const filePath = new URL(req.url, "http://localhost").pathname; | ||
return req.type === "css" || isCssFilePath(filePath) || req.headers.accept && RE_TYPE_CSS.test(req.headers.accept); | ||
} | ||
function isHtmlFilePath(filePath) { | ||
return config_default.extensionsByType.html.includes(path2.extname(filePath)); | ||
} | ||
function isHtmlRequest(req) { | ||
const filePath = new URL(req.url, "http://localhost").pathname; | ||
return req.type === "html" || isHtmlFilePath(filePath) || req.headers.accept && RE_TYPE_HTML.test(req.headers.accept); | ||
} | ||
function isJsFilePath(filePath) { | ||
return config_default.extensionsByType.js.includes(path2.extname(filePath)); | ||
} | ||
function isJsRequest(req) { | ||
const filePath = new URL(req.url, "http://localhost").pathname; | ||
return req.type === "js" || isJsFilePath(filePath) || // Almost always '*/*' | ||
req.headers.accept && RE_TYPE_JS.test(req.headers.accept); | ||
} | ||
function isNodeModuleFilePath(filePath) { | ||
const isNodeModule = RE_NODE_MODULES.test(filePath); | ||
if (!isNodeModule) { | ||
return false; | ||
} | ||
try { | ||
return RE_NODE_MODULES.test(realPath(filePath)); | ||
} catch (err) { | ||
return true; | ||
} | ||
} | ||
function isRelativeFilePath(filePath) { | ||
return "string" == typeof filePath && filePath.startsWith("."); | ||
} | ||
function isValidFilePath(filePath, fromDir = process.cwd()) { | ||
if (isRelativeFilePath(filePath)) { | ||
filePath = path2.join(fromDir, filePath); | ||
} | ||
try { | ||
const stat = fs.statSync(filePath); | ||
if (stat.isFile()) { | ||
return true; | ||
} | ||
} catch (err) { | ||
} | ||
return false; | ||
} | ||
// src/utils/log.js | ||
function error() { | ||
} | ||
function noisyWarn() { | ||
} | ||
function warn() { | ||
} | ||
var WARN_MISSING_EXTENSION = ""; | ||
var WARN_PACKAGE_INDEX = ""; | ||
// src/utils/file.js | ||
import fs2 from "node:fs"; | ||
// node_modules/.pnpm/es-module-lexer@1.5.0/node_modules/es-module-lexer/dist/lexer.js | ||
var ImportType; | ||
!function(A2) { | ||
A2[A2.Static = 1] = "Static", A2[A2.Dynamic = 2] = "Dynamic", A2[A2.ImportMeta = 3] = "ImportMeta", A2[A2.StaticSourcePhase = 4] = "StaticSourcePhase", A2[A2.DynamicSourcePhase = 5] = "DynamicSourcePhase"; | ||
}(ImportType || (ImportType = {})); | ||
var A = 1 === new Uint8Array(new Uint16Array([1]).buffer)[0]; | ||
var C; | ||
var init = WebAssembly.compile((E = "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AgACAAIAFGIgIbQQAgASACGxACCyADC3IBBH9BACgCsAohAEEAKAK0CiEBAkACQANAIABBAmohAiAAIAFPDQECQAJAIAIvAQAiA0Gkf2oOAgEEAAsgAiEAIANBdmoOBAIBAQIBCyAAQQRqIQAMAAsLQQAgAjYCsAoQJEEADwtBACACNgKwCkHdAAtJAQN/QQAhAwJAIAJFDQACQANAIAAtAAAiBCABLQAAIgVHDQEgAUEBaiEBIABBAWohACACQX9qIgINAAwCCwsgBCAFayEDCyADCwvsAQIAQYAIC84BAAB4AHAAbwByAHQAbQBwAG8AcgB0AGUAdABhAG8AdQByAGMAZQByAG8AbQB1AG4AYwB0AGkAbwBuAHMAcwBlAHIAdAB2AG8AeQBpAGUAZABlAGwAZQBjAG8AbgB0AGkAbgBpAG4AcwB0AGEAbgB0AHkAYgByAGUAYQByAGUAdAB1AHIAZABlAGIAdQBnAGcAZQBhAHcAYQBpAHQAaAByAHcAaABpAGwAZQBmAG8AcgBpAGYAYwBhAHQAYwBmAGkAbgBhAGwAbABlAGwAcwAAQdAJCxABAAAAAgAAAAAEAABAOQAA", "undefined" != typeof Buffer ? Buffer.from(E, "base64") : Uint8Array.from(atob(E), (A2) => A2.charCodeAt(0)))).then(WebAssembly.instantiate).then(({ exports: A2 }) => { | ||
C = A2; | ||
}); | ||
var E; | ||
// src/utils/file.js | ||
import path3 from "node:path"; | ||
var FILE_TYPES = ["js", "css", "html"]; | ||
var MAX_FILE_SYSTEM_DEPTH = 10; | ||
var realPath2 = "native" in fs2.realpathSync && typeof fs2.realpathSync.native === "function" ? fs2.realpathSync.native : fs2.realpathSync; | ||
function find(req, { directories = config_default.directories, type } = {}) { | ||
const href = decodeURI( | ||
isRequestObject(req) ? new URL(req.url, "http://localhost").pathname : req | ||
); | ||
let filePath; | ||
if (type === void 0) { | ||
type = isRequestObject(req) ? getTypeFromRequest(req) : getTypeFromPath(req); | ||
} | ||
if (href.startsWith("/node_modules")) { | ||
directories = [ | ||
...directories, | ||
...resolveNodeModulesDirectories(process.cwd()).map( | ||
(nodeModulesDirPath) => path3.dirname(nodeModulesDirPath) | ||
) | ||
]; | ||
} | ||
if (isBundledUrl(href)) { | ||
filePath = path3.resolve(href.slice(1)); | ||
} else if (isAbsoluteFilePath(href)) { | ||
filePath = resolveFilePath(href, type); | ||
} else { | ||
for (const directory of directories) { | ||
filePath = resolveFilePath(path3.join(directory, href), type); | ||
if (filePath) { | ||
break; | ||
} | ||
} | ||
} | ||
if (!filePath) { | ||
return; | ||
} | ||
if (isRequestObject(req)) { | ||
req.filePath = filePath; | ||
req.type = getTypeFromPath(filePath); | ||
} | ||
return filePath; | ||
} | ||
function getProjectPath(filePath) { | ||
if (Array.isArray(filePath)) { | ||
filePath = filePath[0]; | ||
} | ||
const projectFilePath = isAbsoluteFilePath(filePath) ? path3.relative(process.cwd(), filePath) : filePath; | ||
return projectFilePath.startsWith("/") ? projectFilePath.slice(1) : projectFilePath; | ||
} | ||
function getTypeFromPath(filePath) { | ||
if (filePath !== void 0) { | ||
const pathname = new URL(filePath, "http://localhost").pathname; | ||
return config_default.typesByExtension[path3.extname(pathname)]; | ||
} | ||
} | ||
function getTypeFromRequest(req) { | ||
if (req.type) { | ||
return req.type; | ||
} else if (isJsRequest(req)) { | ||
return "js"; | ||
} else if (isCssRequest(req)) { | ||
return "css"; | ||
} else if (isHtmlRequest(req)) { | ||
return "html"; | ||
} | ||
} | ||
function resolveFilePath(filePath, type) { | ||
filePath = decodeURI(filePath).replace(/(\s)/g, "$1"); | ||
try { | ||
const stat = fs2.statSync(filePath); | ||
if (stat.isFile()) { | ||
return resolveRealFilePath(filePath); | ||
} | ||
} catch (err) { | ||
} | ||
if (type === void 0) { | ||
for (const ft of FILE_TYPES) { | ||
const fp2 = resolveFilePath(filePath, ft); | ||
if (fp2) { | ||
return resolveRealFilePath(fp2); | ||
} | ||
} | ||
type = "js"; | ||
} | ||
const hasExtension = path3.extname(filePath) !== ""; | ||
let fp = resolveFilePathExtension(filePath, config_default.extensionsByType[type]); | ||
if (fp) { | ||
if (!hasExtension && !isNodeModuleFilePath(fp)) { | ||
warn(WARN_MISSING_EXTENSION, `"${getProjectPath(filePath)}"`); | ||
} | ||
return resolveRealFilePath(fp); | ||
} | ||
fp = resolveFilePathExtension( | ||
path3.join(filePath, "index"), | ||
config_default.extensionsByType[type] | ||
); | ||
if (fp && type === "js") { | ||
if (!isNodeModuleFilePath(fp)) { | ||
warn(WARN_PACKAGE_INDEX, `"${getProjectPath(filePath)}"`); | ||
} | ||
} | ||
return resolveRealFilePath(fp); | ||
} | ||
function resolveFilePathExtension(filePath, extensions) { | ||
const ext = path3.extname(filePath); | ||
if (ext && extensions.includes(ext)) { | ||
filePath = filePath.replace(ext, ""); | ||
} | ||
for (const ext2 of extensions) { | ||
const fp = filePath + ext2; | ||
if (fs2.existsSync(fp)) { | ||
return fp; | ||
} | ||
} | ||
return ""; | ||
} | ||
function resolveRealFilePath(filePath) { | ||
if (!filePath || !path3.isAbsolute(filePath)) { | ||
return filePath; | ||
} | ||
try { | ||
return realPath2(filePath); | ||
} catch (err) { | ||
return filePath; | ||
} | ||
} | ||
function isRequestObject(req) { | ||
return typeof req !== "string"; | ||
} | ||
function resolveNodeModulesDirectories(filePath) { | ||
let dir = path3.extname(filePath) ? path3.dirname(filePath) : filePath; | ||
let dirs = []; | ||
let depth = MAX_FILE_SYSTEM_DEPTH; | ||
let parent; | ||
while (true) { | ||
parent = path3.dirname(dir); | ||
if (!--depth || parent.toLowerCase() === dir.toLowerCase()) { | ||
break; | ||
} | ||
const nodeModulesPath = path3.resolve(dir, "node_modules"); | ||
if (fs2.existsSync(nodeModulesPath)) { | ||
dirs.push(nodeModulesPath); | ||
} | ||
dir = parent; | ||
} | ||
return dirs.sort((a, b) => a.length >= b.length ? -1 : 1); | ||
} | ||
// src/resolver/package.js | ||
import fs3 from "node:fs"; | ||
import path4 from "node:path"; | ||
var MAX_FILE_SYSTEM_DEPTH2 = 10; | ||
var RE_TRAILING = /\/+$|\\+$/; | ||
function getPackage(filePath, packagePath = resolvePackagePath(filePath), env2 = "browser") { | ||
if (packagePath === void 0 || !fs3.existsSync(packagePath)) { | ||
return; | ||
} | ||
const manifestPath = path4.join(packagePath, "package.json"); | ||
const isProjectPackage = packagePath === process.cwd(); | ||
const paths = resolveNodeModulesDirectories(packagePath); | ||
const pkg = { | ||
env: env2, | ||
exportsConditions: [env2, "development", "dvlp"], | ||
isProjectPackage, | ||
manifestPath, | ||
main: "", | ||
name: "", | ||
path: packagePath, | ||
paths, | ||
type: void 0, | ||
version: "" | ||
}; | ||
const findOptions = { | ||
directories: [packagePath, ...pkg.paths], | ||
type: "js" | ||
}; | ||
try { | ||
const json = JSON.parse(fs3.readFileSync(manifestPath, "utf8")); | ||
const hasModuleField = json.module !== void 0; | ||
const type = hasModuleField ? "module" : json.type; | ||
const name = resolvePackageName(json.name, packagePath); | ||
let main = find(json.module || json.main || "index.js", findOptions); | ||
if (json.imports) { | ||
pkg.imports = json.imports; | ||
} | ||
if (json.exports) { | ||
pkg.exports = json.exports; | ||
} else if (env2 === "browser" && json.browser) { | ||
pkg.browser = {}; | ||
if (typeof json.browser === "string") { | ||
if (!hasModuleField) { | ||
main = find(json.browser, findOptions); | ||
} | ||
} else { | ||
for (let key in json.browser) { | ||
let value = json.browser[key]; | ||
if (typeof value === "string") { | ||
if (path4.extname(key) || isRelativeFilePath(key)) { | ||
key = find(key, findOptions); | ||
} | ||
if (path4.extname(value) || isRelativeFilePath(value)) { | ||
value = find(value, findOptions); | ||
} | ||
if (key !== void 0 && value !== void 0 && key !== value) { | ||
if (!hasModuleField && key === main) { | ||
main = value; | ||
} | ||
pkg.browser[key] = value; | ||
} else { | ||
} | ||
} else { | ||
} | ||
} | ||
} | ||
} | ||
pkg.name = name; | ||
pkg.main = main; | ||
pkg.type = type; | ||
pkg.version = json.version; | ||
} catch (err) { | ||
} | ||
return pkg; | ||
} | ||
function resolvePackagePath(filePath) { | ||
filePath = filePath.replace(RE_TRAILING, ""); | ||
const cwd = process.cwd(); | ||
const isNodeModule = filePath.includes("node_modules"); | ||
let depth = MAX_FILE_SYSTEM_DEPTH2; | ||
let dir = filePath; | ||
let parent = ""; | ||
let root = cwd; | ||
if (isNodeModule) { | ||
const parts = filePath.split(path4.sep); | ||
const idx = parts.indexOf("node_modules"); | ||
root = parts.slice(0, idx + 1).join(path4.sep); | ||
} | ||
while (true) { | ||
const pkgPath = path4.join(dir, "package.json"); | ||
if (fs3.existsSync(pkgPath)) { | ||
if (!isNodeModule) { | ||
return dir; | ||
} | ||
try { | ||
const json = JSON.parse(fs3.readFileSync(pkgPath, "utf8")); | ||
if (json.name || json.main || json.imports || json.exports || json.browser || json.module) { | ||
return dir; | ||
} | ||
} catch (err) { | ||
} | ||
} | ||
parent = path4.dirname(dir); | ||
if (dir === root || !--depth || parent.toLowerCase() === dir.toLowerCase()) { | ||
break; | ||
} | ||
dir = parent; | ||
} | ||
} | ||
function resolvePackageSourcePath(filePathOrSpecifier, pkg, verifyExport) { | ||
if (pkg.imports !== void 0 && filePathOrSpecifier.startsWith("#")) { | ||
return resolveImportPath(filePathOrSpecifier, pkg); | ||
} else if (pkg.exports && verifyExport) { | ||
let resolvedFilePath = resolveExportPath(filePathOrSpecifier, pkg); | ||
if (resolvedFilePath !== void 0 && !fs3.existsSync(resolvedFilePath)) { | ||
resolvedFilePath = find(resolvedFilePath, { type: "js" }); | ||
} | ||
return resolvedFilePath; | ||
} | ||
filePathOrSpecifier = resolveMainOrBrowserPath(filePathOrSpecifier, pkg); | ||
if (isAbsoluteFilePath(filePathOrSpecifier) && !isValidFilePath(filePathOrSpecifier)) { | ||
const foundFilePath = find(filePathOrSpecifier, { type: "js" }); | ||
if (!foundFilePath) { | ||
return; | ||
} | ||
return resolveMainOrBrowserPath(foundFilePath, pkg); | ||
} | ||
return filePathOrSpecifier; | ||
} | ||
function resolveImportPath(specifier, pkg) { | ||
try { | ||
const resolved = f( | ||
{ name: pkg.name, imports: pkg.imports }, | ||
specifier, | ||
{ | ||
// `node` automatically added if not set | ||
browser: pkg.env === "browser", | ||
conditions: pkg.exportsConditions | ||
} | ||
); | ||
if (resolved?.length) { | ||
return isBareSpecifier(resolved[0]) ? resolved[0] : path4.resolve(pkg.path, resolved[0]); | ||
} | ||
} catch (err) { | ||
if ( | ||
/** @type { Error } */ | ||
err.message.includes("Missing") | ||
) { | ||
error( | ||
`unable to resolve internal package reference. The ${pkg.name} package does not specify ${specifier} in it's "imports" map.` | ||
); | ||
} | ||
} | ||
} | ||
function resolveExportPath(filePathOrSpecifier, pkg) { | ||
const entry = filePathOrSpecifier.replace( | ||
isBareSpecifier(filePathOrSpecifier) ? pkg.name : pkg.path, | ||
"." | ||
); | ||
try { | ||
const resolved = o(pkg, entry.replace(/\\/g, "/"), { | ||
// `node` automatically added if not set | ||
browser: pkg.env === "browser", | ||
conditions: pkg.exportsConditions | ||
}); | ||
if (resolved?.length) { | ||
return path4.resolve(pkg.path, resolved[0]); | ||
} | ||
} catch (err) { | ||
if ( | ||
/** @type { Error } */ | ||
err.message.includes("Missing") | ||
) { | ||
error( | ||
`unable to resolve package entry. The ${pkg.name} package does not specify ${entry} in it's "exports" map.` | ||
); | ||
} | ||
} | ||
} | ||
function resolveMainOrBrowserPath(filePath, pkg) { | ||
let resolved = filePath; | ||
if (filePath === pkg.path && pkg.main) { | ||
resolved = pkg.main; | ||
} | ||
if (pkg.browser) { | ||
while (resolved in pkg.browser) { | ||
resolved = pkg.browser[resolved]; | ||
} | ||
} | ||
return resolved; | ||
} | ||
function resolvePackageName(packageName, packagePath) { | ||
if (!isNodeModuleFilePath(packagePath)) { | ||
return packageName || "project"; | ||
} | ||
return path4.relative( | ||
packagePath.slice(0, packagePath.lastIndexOf("node_modules") + 12), | ||
packagePath | ||
).replace(/\\/g, "/"); | ||
} | ||
// src/resolver/utils.js | ||
function getPackageNameFromSpecifier(specifier) { | ||
if (isBareSpecifier(specifier)) { | ||
const segments = specifier.split("/"); | ||
let name = segments[0]; | ||
if (name.startsWith("@")) { | ||
name += `/${segments[1]}`; | ||
} | ||
return name; | ||
} | ||
} | ||
function isSelfReferentialSpecifier(specifier, pkg) { | ||
return getPackageNameFromSpecifier(specifier) === pkg.name; | ||
} | ||
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js | ||
var ANSI_BACKGROUND_OFFSET = 10; | ||
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`; | ||
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`; | ||
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`; | ||
var styles = { | ||
modifier: { | ||
reset: [0, 0], | ||
// 21 isn't widely supported and 22 does the same thing | ||
bold: [1, 22], | ||
dim: [2, 22], | ||
italic: [3, 23], | ||
underline: [4, 24], | ||
overline: [53, 55], | ||
inverse: [7, 27], | ||
hidden: [8, 28], | ||
strikethrough: [9, 29] | ||
}, | ||
color: { | ||
black: [30, 39], | ||
red: [31, 39], | ||
green: [32, 39], | ||
yellow: [33, 39], | ||
blue: [34, 39], | ||
magenta: [35, 39], | ||
cyan: [36, 39], | ||
white: [37, 39], | ||
// Bright color | ||
blackBright: [90, 39], | ||
gray: [90, 39], | ||
// Alias of `blackBright` | ||
grey: [90, 39], | ||
// Alias of `blackBright` | ||
redBright: [91, 39], | ||
greenBright: [92, 39], | ||
yellowBright: [93, 39], | ||
blueBright: [94, 39], | ||
magentaBright: [95, 39], | ||
cyanBright: [96, 39], | ||
whiteBright: [97, 39] | ||
}, | ||
bgColor: { | ||
bgBlack: [40, 49], | ||
bgRed: [41, 49], | ||
bgGreen: [42, 49], | ||
bgYellow: [43, 49], | ||
bgBlue: [44, 49], | ||
bgMagenta: [45, 49], | ||
bgCyan: [46, 49], | ||
bgWhite: [47, 49], | ||
// Bright color | ||
bgBlackBright: [100, 49], | ||
bgGray: [100, 49], | ||
// Alias of `bgBlackBright` | ||
bgGrey: [100, 49], | ||
// Alias of `bgBlackBright` | ||
bgRedBright: [101, 49], | ||
bgGreenBright: [102, 49], | ||
bgYellowBright: [103, 49], | ||
bgBlueBright: [104, 49], | ||
bgMagentaBright: [105, 49], | ||
bgCyanBright: [106, 49], | ||
bgWhiteBright: [107, 49] | ||
} | ||
}; | ||
var modifierNames = Object.keys(styles.modifier); | ||
var foregroundColorNames = Object.keys(styles.color); | ||
var backgroundColorNames = Object.keys(styles.bgColor); | ||
var colorNames = [...foregroundColorNames, ...backgroundColorNames]; | ||
function assembleStyles() { | ||
const codes = /* @__PURE__ */ new Map(); | ||
for (const [groupName, group] of Object.entries(styles)) { | ||
for (const [styleName, style] of Object.entries(group)) { | ||
styles[styleName] = { | ||
open: `\x1B[${style[0]}m`, | ||
close: `\x1B[${style[1]}m` | ||
}; | ||
group[styleName] = styles[styleName]; | ||
codes.set(style[0], style[1]); | ||
} | ||
Object.defineProperty(styles, groupName, { | ||
value: group, | ||
enumerable: false | ||
}); | ||
} | ||
Object.defineProperty(styles, "codes", { | ||
value: codes, | ||
enumerable: false | ||
}); | ||
styles.color.close = "\x1B[39m"; | ||
styles.bgColor.close = "\x1B[49m"; | ||
styles.color.ansi = wrapAnsi16(); | ||
styles.color.ansi256 = wrapAnsi256(); | ||
styles.color.ansi16m = wrapAnsi16m(); | ||
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); | ||
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); | ||
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); | ||
Object.defineProperties(styles, { | ||
rgbToAnsi256: { | ||
value(red, green, blue) { | ||
if (red === green && green === blue) { | ||
if (red < 8) { | ||
return 16; | ||
} | ||
if (red > 248) { | ||
return 231; | ||
} | ||
return Math.round((red - 8) / 247 * 24) + 232; | ||
} | ||
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5); | ||
}, | ||
enumerable: false | ||
}, | ||
hexToRgb: { | ||
value(hex) { | ||
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16)); | ||
if (!matches) { | ||
return [0, 0, 0]; | ||
} | ||
let [colorString] = matches; | ||
if (colorString.length === 3) { | ||
colorString = [...colorString].map((character) => character + character).join(""); | ||
} | ||
const integer = Number.parseInt(colorString, 16); | ||
return [ | ||
/* eslint-disable no-bitwise */ | ||
integer >> 16 & 255, | ||
integer >> 8 & 255, | ||
integer & 255 | ||
/* eslint-enable no-bitwise */ | ||
]; | ||
}, | ||
enumerable: false | ||
}, | ||
hexToAnsi256: { | ||
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)), | ||
enumerable: false | ||
}, | ||
ansi256ToAnsi: { | ||
value(code) { | ||
if (code < 8) { | ||
return 30 + code; | ||
} | ||
if (code < 16) { | ||
return 90 + (code - 8); | ||
} | ||
let red; | ||
let green; | ||
let blue; | ||
if (code >= 232) { | ||
red = ((code - 232) * 10 + 8) / 255; | ||
green = red; | ||
blue = red; | ||
} else { | ||
code -= 16; | ||
const remainder = code % 36; | ||
red = Math.floor(code / 36) / 5; | ||
green = Math.floor(remainder / 6) / 5; | ||
blue = remainder % 6 / 5; | ||
} | ||
const value = Math.max(red, green, blue) * 2; | ||
if (value === 0) { | ||
return 30; | ||
} | ||
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red)); | ||
if (value === 2) { | ||
result += 60; | ||
} | ||
return result; | ||
}, | ||
enumerable: false | ||
}, | ||
rgbToAnsi: { | ||
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)), | ||
enumerable: false | ||
}, | ||
hexToAnsi: { | ||
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)), | ||
enumerable: false | ||
} | ||
}); | ||
return styles; | ||
} | ||
var ansiStyles = assembleStyles(); | ||
var ansi_styles_default = ansiStyles; | ||
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js | ||
import process2 from "node:process"; | ||
import os from "node:os"; | ||
import tty from "node:tty"; | ||
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) { | ||
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--"; | ||
const position = argv.indexOf(prefix + flag); | ||
const terminatorPosition = argv.indexOf("--"); | ||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); | ||
} | ||
var { env } = process2; | ||
var flagForceColor; | ||
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) { | ||
flagForceColor = 0; | ||
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) { | ||
flagForceColor = 1; | ||
} | ||
function envForceColor() { | ||
if ("FORCE_COLOR" in env) { | ||
if (env.FORCE_COLOR === "true") { | ||
return 1; | ||
} | ||
if (env.FORCE_COLOR === "false") { | ||
return 0; | ||
} | ||
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); | ||
} | ||
} | ||
function translateLevel(level) { | ||
if (level === 0) { | ||
return false; | ||
} | ||
return { | ||
level, | ||
hasBasic: true, | ||
has256: level >= 2, | ||
has16m: level >= 3 | ||
}; | ||
} | ||
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) { | ||
const noFlagForceColor = envForceColor(); | ||
if (noFlagForceColor !== void 0) { | ||
flagForceColor = noFlagForceColor; | ||
} | ||
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; | ||
if (forceColor === 0) { | ||
return 0; | ||
} | ||
if (sniffFlags) { | ||
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) { | ||
return 3; | ||
} | ||
if (hasFlag("color=256")) { | ||
return 2; | ||
} | ||
} | ||
if ("TF_BUILD" in env && "AGENT_NAME" in env) { | ||
return 1; | ||
} | ||
if (haveStream && !streamIsTTY && forceColor === void 0) { | ||
return 0; | ||
} | ||
const min = forceColor || 0; | ||
if (env.TERM === "dumb") { | ||
return min; | ||
} | ||
if (process2.platform === "win32") { | ||
const osRelease = os.release().split("."); | ||
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { | ||
return Number(osRelease[2]) >= 14931 ? 3 : 2; | ||
} | ||
return 1; | ||
} | ||
if ("CI" in env) { | ||
if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) { | ||
return 3; | ||
} | ||
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") { | ||
return 1; | ||
} | ||
return min; | ||
} | ||
if ("TEAMCITY_VERSION" in env) { | ||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; | ||
} | ||
if (env.COLORTERM === "truecolor") { | ||
return 3; | ||
} | ||
if (env.TERM === "xterm-kitty") { | ||
return 3; | ||
} | ||
if ("TERM_PROGRAM" in env) { | ||
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10); | ||
switch (env.TERM_PROGRAM) { | ||
case "iTerm.app": { | ||
return version >= 3 ? 3 : 2; | ||
} | ||
case "Apple_Terminal": { | ||
return 2; | ||
} | ||
} | ||
} | ||
if (/-256(color)?$/i.test(env.TERM)) { | ||
return 2; | ||
} | ||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { | ||
return 1; | ||
} | ||
if ("COLORTERM" in env) { | ||
return 1; | ||
} | ||
return min; | ||
} | ||
function createSupportsColor(stream, options = {}) { | ||
const level = _supportsColor(stream, { | ||
streamIsTTY: stream && stream.isTTY, | ||
...options | ||
}); | ||
return translateLevel(level); | ||
} | ||
var supportsColor = { | ||
stdout: createSupportsColor({ isTTY: tty.isatty(1) }), | ||
stderr: createSupportsColor({ isTTY: tty.isatty(2) }) | ||
}; | ||
var supports_color_default = supportsColor; | ||
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js | ||
function stringReplaceAll(string, substring, replacer) { | ||
let index = string.indexOf(substring); | ||
if (index === -1) { | ||
return string; | ||
} | ||
const substringLength = substring.length; | ||
let endIndex = 0; | ||
let returnValue = ""; | ||
do { | ||
returnValue += string.slice(endIndex, index) + substring + replacer; | ||
endIndex = index + substringLength; | ||
index = string.indexOf(substring, endIndex); | ||
} while (index !== -1); | ||
returnValue += string.slice(endIndex); | ||
return returnValue; | ||
} | ||
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) { | ||
let endIndex = 0; | ||
let returnValue = ""; | ||
do { | ||
const gotCR = string[index - 1] === "\r"; | ||
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix; | ||
endIndex = index + 1; | ||
index = string.indexOf("\n", endIndex); | ||
} while (index !== -1); | ||
returnValue += string.slice(endIndex); | ||
return returnValue; | ||
} | ||
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js | ||
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default; | ||
var GENERATOR = Symbol("GENERATOR"); | ||
var STYLER = Symbol("STYLER"); | ||
var IS_EMPTY = Symbol("IS_EMPTY"); | ||
var levelMapping = [ | ||
"ansi", | ||
"ansi", | ||
"ansi256", | ||
"ansi16m" | ||
]; | ||
var styles2 = /* @__PURE__ */ Object.create(null); | ||
var applyOptions = (object, options = {}) => { | ||
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { | ||
throw new Error("The `level` option should be an integer from 0 to 3"); | ||
} | ||
const colorLevel = stdoutColor ? stdoutColor.level : 0; | ||
object.level = options.level === void 0 ? colorLevel : options.level; | ||
}; | ||
var chalkFactory = (options) => { | ||
const chalk2 = (...strings) => strings.join(" "); | ||
applyOptions(chalk2, options); | ||
Object.setPrototypeOf(chalk2, createChalk.prototype); | ||
return chalk2; | ||
}; | ||
function createChalk(options) { | ||
return chalkFactory(options); | ||
} | ||
Object.setPrototypeOf(createChalk.prototype, Function.prototype); | ||
for (const [styleName, style] of Object.entries(ansi_styles_default)) { | ||
styles2[styleName] = { | ||
get() { | ||
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]); | ||
Object.defineProperty(this, styleName, { value: builder }); | ||
return builder; | ||
} | ||
}; | ||
} | ||
styles2.visible = { | ||
get() { | ||
const builder = createBuilder(this, this[STYLER], true); | ||
Object.defineProperty(this, "visible", { value: builder }); | ||
return builder; | ||
} | ||
}; | ||
var getModelAnsi = (model, level, type, ...arguments_) => { | ||
if (model === "rgb") { | ||
if (level === "ansi16m") { | ||
return ansi_styles_default[type].ansi16m(...arguments_); | ||
} | ||
if (level === "ansi256") { | ||
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_)); | ||
} | ||
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_)); | ||
} | ||
if (model === "hex") { | ||
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_)); | ||
} | ||
return ansi_styles_default[type][model](...arguments_); | ||
}; | ||
var usedModels = ["rgb", "hex", "ansi256"]; | ||
for (const model of usedModels) { | ||
styles2[model] = { | ||
get() { | ||
const { level } = this; | ||
return function(...arguments_) { | ||
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]); | ||
return createBuilder(this, styler, this[IS_EMPTY]); | ||
}; | ||
} | ||
}; | ||
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1); | ||
styles2[bgModel] = { | ||
get() { | ||
const { level } = this; | ||
return function(...arguments_) { | ||
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]); | ||
return createBuilder(this, styler, this[IS_EMPTY]); | ||
}; | ||
} | ||
}; | ||
} | ||
var proto = Object.defineProperties(() => { | ||
}, { | ||
...styles2, | ||
level: { | ||
enumerable: true, | ||
get() { | ||
return this[GENERATOR].level; | ||
}, | ||
set(level) { | ||
this[GENERATOR].level = level; | ||
} | ||
} | ||
}); | ||
var createStyler = (open, close, parent) => { | ||
let openAll; | ||
let closeAll; | ||
if (parent === void 0) { | ||
openAll = open; | ||
closeAll = close; | ||
} else { | ||
openAll = parent.openAll + open; | ||
closeAll = close + parent.closeAll; | ||
} | ||
return { | ||
open, | ||
close, | ||
openAll, | ||
closeAll, | ||
parent | ||
}; | ||
}; | ||
var createBuilder = (self, _styler, _isEmpty) => { | ||
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" ")); | ||
Object.setPrototypeOf(builder, proto); | ||
builder[GENERATOR] = self; | ||
builder[STYLER] = _styler; | ||
builder[IS_EMPTY] = _isEmpty; | ||
return builder; | ||
}; | ||
var applyStyle = (self, string) => { | ||
if (self.level <= 0 || !string) { | ||
return self[IS_EMPTY] ? "" : string; | ||
} | ||
let styler = self[STYLER]; | ||
if (styler === void 0) { | ||
return string; | ||
} | ||
const { openAll, closeAll } = styler; | ||
if (string.includes("\x1B")) { | ||
while (styler !== void 0) { | ||
string = stringReplaceAll(string, styler.close, styler.open); | ||
styler = styler.parent; | ||
} | ||
} | ||
const lfIndex = string.indexOf("\n"); | ||
if (lfIndex !== -1) { | ||
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); | ||
} | ||
return openAll + string + closeAll; | ||
}; | ||
Object.defineProperties(createChalk.prototype, styles2); | ||
var chalk = createChalk(); | ||
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 }); | ||
var source_default = chalk; | ||
// src/resolver/index.js | ||
import fs4 from "node:fs"; | ||
import path5 from "node:path"; | ||
import { pathToFileURL as pathToFileURL2 } from "node:url"; | ||
var packageCacheByImportDir = /* @__PURE__ */ new Map(); | ||
var packageVersionCacheByName = /* @__PURE__ */ new Map(); | ||
var packageCacheByNameAndVersion = /* @__PURE__ */ new Map(); | ||
var resolveCache = /* @__PURE__ */ new Map(); | ||
function nodeResolve(specifier, importer = "index.js") { | ||
if (!specifier) { | ||
return; | ||
} | ||
importer = path5.resolve(importer); | ||
const key = getCacheKey(importer, specifier, "node"); | ||
const cached = resolveCache.get(key); | ||
if (cached !== void 0) { | ||
return cached; | ||
} | ||
const result = doResolve( | ||
specifier, | ||
resolveRealFilePath(path5.dirname(importer)), | ||
true, | ||
"node" | ||
); | ||
if (result === void 0) { | ||
return; | ||
} | ||
result.url = pathToFileURL2(result.filePath).href; | ||
resolveCache.set(key, result); | ||
return result; | ||
} | ||
function getPackageForDir(dir, env2 = "browser") { | ||
const pkgPath = resolvePackagePath(dir); | ||
if (!pkgPath) { | ||
return; | ||
} | ||
const pkgKey = `${pkgPath}:${env2}`; | ||
let pkg = packageCacheByImportDir.get(pkgKey); | ||
if (!pkg) { | ||
pkg = getPackage(dir, pkgPath, env2); | ||
if (pkg) { | ||
packageCacheByImportDir.set(pkgKey, pkg); | ||
} | ||
} | ||
return pkg; | ||
} | ||
function doResolve(specifier, importerDirPath, isEntry, env2) { | ||
const pkg = resolvePackage(importerDirPath, env2); | ||
if (!pkg) { | ||
return; | ||
} | ||
const verifyExports = !isEntry || isSelfReferentialSpecifier(specifier, pkg); | ||
if (specifier === pkg.name || specifier.startsWith(`${pkg.name}/`)) { | ||
specifier = specifier.replace(pkg.name, "."); | ||
importerDirPath = pkg.path; | ||
} | ||
let filePath = resolvePackageSourcePath( | ||
isRelativeFilePath(specifier) ? path5.join(importerDirPath, specifier) : specifier, | ||
pkg, | ||
verifyExports | ||
); | ||
if (!filePath) { | ||
return; | ||
} else if (isAbsoluteFilePath(filePath)) { | ||
filePath = resolveRealFilePath(filePath); | ||
return { filePath, format: resolveFileFormat(filePath, pkg) }; | ||
} else if (!isBareSpecifier(filePath)) { | ||
return; | ||
} | ||
specifier = filePath; | ||
const packageName = ( | ||
/** @type { string } */ | ||
getPackageNameFromSpecifier(specifier) | ||
); | ||
const localPath = specifier.slice(packageName.length); | ||
for (const packageDirPath of pkg.paths) { | ||
const packagePath = path5.join(packageDirPath, packageName); | ||
if (importerDirPath !== packageDirPath && fs4.existsSync(packagePath)) { | ||
const result = doResolve( | ||
specifier, | ||
path5.join(resolveRealFilePath(packagePath), localPath), | ||
false, | ||
env2 | ||
); | ||
if (result !== void 0) { | ||
return { | ||
filePath: resolveRealFilePath(result.filePath), | ||
format: result.format | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
function getCacheKey(importerFilePath, specifier, env2) { | ||
if (isBareSpecifier(specifier) && !isNodeModuleFilePath(importerFilePath)) { | ||
return `src:${specifier}:${env2}`; | ||
} | ||
return `${getProjectPath(importerFilePath)}:${specifier}:${env2}`; | ||
} | ||
function resolvePackage(dir, env2) { | ||
let pkg = getPackageForDir(dir, env2); | ||
if (pkg && env2 === "browser") { | ||
if (!packageVersionCacheByName.has(pkg.name)) { | ||
packageVersionCacheByName.set(pkg.name, /* @__PURE__ */ new Set([pkg.version])); | ||
} else { | ||
const versions = ( | ||
/** @type { Set<string> } */ | ||
packageVersionCacheByName.get(pkg.name) | ||
); | ||
versions.add(pkg.version); | ||
if (versions.size > 1) { | ||
noisyWarn( | ||
`${source_default.yellow("\u26A0\uFE0F")} multiple versions of the "${pkg.name}" package used: ${Array.from(versions).join(", ")}` | ||
); | ||
} | ||
} | ||
const versionedKey = `${pkg.name}@${pkg.version}`; | ||
const versionedPackage = packageCacheByNameAndVersion.get(versionedKey); | ||
if (versionedPackage && versionedPackage !== pkg) { | ||
pkg = versionedPackage; | ||
} | ||
packageCacheByNameAndVersion.set(versionedKey, pkg); | ||
} | ||
return pkg; | ||
} | ||
function resolveFileFormat(filePath, pkg) { | ||
const ext = path5.extname(filePath); | ||
if (ext === ".mjs") { | ||
return "module"; | ||
} else if (ext === ".cjs") { | ||
return "commonjs"; | ||
} else { | ||
return pkg.type; | ||
} | ||
} | ||
// src/application-host/application-loader-legacy.js | ||
import { nodeResolve } from "dvlp/internal"; | ||
var IS_WIN32 = process.platform === "win32"; | ||
@@ -1298,3 +14,3 @@ var RE_EXTS = /\.(tsx?|json)$/; | ||
context, | ||
(specifier2, context2) => doResolve2(specifier2, context2, nextResolve) | ||
(specifier2, context2) => doResolve(specifier2, context2, nextResolve) | ||
); | ||
@@ -1304,5 +20,5 @@ resolved.shortCircuit = true; | ||
} | ||
return doResolve2(specifier, context, nextResolve); | ||
return doResolve(specifier, context, nextResolve); | ||
} | ||
function doResolve2(specifier, context, nextResolve) { | ||
function doResolve(specifier, context, nextResolve) { | ||
if (!specifier.startsWith("node:")) { | ||
@@ -1337,3 +53,3 @@ const resolved = nodeResolve( | ||
const filename = IS_WIN32 ? url : fileURLToPath(url); | ||
const source = fs5.readFileSync(new URL(url), { encoding: "utf8" }); | ||
const source = fs.readFileSync(new URL(url), { encoding: "utf8" }); | ||
const { code } = transform(source, filename, url, format); | ||
@@ -1340,0 +56,0 @@ return { format: "module", source: code, shortCircuit: true }; |
// src/application-host/application-loader.js | ||
import esbuild from "esbuild"; | ||
import { fileURLToPath } from "node:url"; | ||
import fs5 from "node:fs"; | ||
// node_modules/.pnpm/resolve.exports@2.0.2/node_modules/resolve.exports/dist/index.mjs | ||
function e(e2, n2, r2) { | ||
throw new Error(r2 ? `No known conditions for "${n2}" specifier in "${e2}" package` : `Missing "${n2}" specifier in "${e2}" package`); | ||
} | ||
function n(n2, i, o2, f2) { | ||
let s, u, l = r(n2, o2), c = function(e2) { | ||
let n3 = /* @__PURE__ */ new Set(["default", ...e2.conditions || []]); | ||
return e2.unsafe || n3.add(e2.require ? "require" : "import"), e2.unsafe || n3.add(e2.browser ? "browser" : "node"), n3; | ||
}(f2 || {}), a = i[l]; | ||
if (void 0 === a) { | ||
let e2, n3, r2, t2; | ||
for (t2 in i) | ||
n3 && t2.length < n3.length || ("/" === t2[t2.length - 1] && l.startsWith(t2) ? (u = l.substring(t2.length), n3 = t2) : t2.length > 1 && (r2 = t2.indexOf("*", 1), ~r2 && (e2 = RegExp("^" + t2.substring(0, r2) + "(.*)" + t2.substring(1 + r2)).exec(l), e2 && e2[1] && (u = e2[1], n3 = t2)))); | ||
a = i[n3]; | ||
} | ||
return a || e(n2, l), s = t(a, c), s || e(n2, l, 1), u && function(e2, n3) { | ||
let r2, t2 = 0, i2 = e2.length, o3 = /[*]/g, f3 = /[/]$/; | ||
for (; t2 < i2; t2++) | ||
e2[t2] = o3.test(r2 = e2[t2]) ? r2.replace(o3, n3) : f3.test(r2) ? r2 + n3 : r2; | ||
}(s, u), s; | ||
} | ||
function r(e2, n2, r2) { | ||
if (e2 === n2 || "." === n2) | ||
return "."; | ||
let t2 = e2 + "/", i = t2.length, o2 = n2.slice(0, i) === t2, f2 = o2 ? n2.slice(i) : n2; | ||
return "#" === f2[0] ? f2 : o2 || !r2 ? "./" === f2.slice(0, 2) ? f2 : "./" + f2 : f2; | ||
} | ||
function t(e2, n2, r2) { | ||
if (e2) { | ||
if ("string" == typeof e2) | ||
return r2 && r2.add(e2), [e2]; | ||
let i, o2; | ||
if (Array.isArray(e2)) { | ||
for (o2 = r2 || /* @__PURE__ */ new Set(), i = 0; i < e2.length; i++) | ||
t(e2[i], n2, o2); | ||
if (!r2 && o2.size) | ||
return [...o2]; | ||
} else | ||
for (i in e2) | ||
if (n2.has(i)) | ||
return t(e2[i], n2, r2); | ||
} | ||
} | ||
function o(e2, r2, t2) { | ||
let i, o2 = e2.exports; | ||
if (o2) { | ||
if ("string" == typeof o2) | ||
o2 = { ".": o2 }; | ||
else | ||
for (i in o2) { | ||
"." !== i[0] && (o2 = { ".": o2 }); | ||
break; | ||
} | ||
return n(e2.name, o2, r2 || ".", t2); | ||
} | ||
} | ||
function f(e2, r2, t2) { | ||
if (e2.imports) | ||
return n(e2.name, e2.imports, r2, t2); | ||
} | ||
// src/utils/broken-named-exports.js | ||
var broken_named_exports_default = { | ||
react: [ | ||
"Children", | ||
"Component", | ||
"Fragment", | ||
"Profiler", | ||
"PureComponent", | ||
"StrictMode", | ||
"Suspense", | ||
"__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED", | ||
"cloneElement", | ||
"createContext", | ||
"createElement", | ||
"createFactory", | ||
"createRef", | ||
"forwardRef", | ||
"isValidElement", | ||
"lazy", | ||
"memo", | ||
"useCallback", | ||
"useContext", | ||
"useDebugValue", | ||
"useEffect", | ||
"useImperativeHandle", | ||
"useLayoutEffect", | ||
"useMemo", | ||
"useReducer", | ||
"useRef", | ||
"useState", | ||
"version" | ||
], | ||
"react-dom": [ | ||
"__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED", | ||
"createPortal", | ||
"findDOMNode", | ||
"flushSync", | ||
"hydrate", | ||
"render", | ||
"unmountComponentAtNode", | ||
"unstable_batchedUpdates", | ||
"unstable_createPortal", | ||
"unstable_renderSubtreeIntoContainer", | ||
"version" | ||
], | ||
"react-is": ["isContextConsumer", "isValidElementType"] | ||
}; | ||
// src/config.js | ||
import path from "node:path"; | ||
import { pathToFileURL } from "node:url"; | ||
var DIR_NAME = ".dvlp"; | ||
var TESTING = process.env.NODE_ENV === "dvlptest" || process.env.CI != void 0; | ||
var VERSION = global.$VERSION || "0.0.0"; | ||
var dirPath = path.resolve(DIR_NAME); | ||
var versionDirPath = path.join(dirPath, VERSION); | ||
var applicationLoaderURL = pathToFileURL( | ||
path.join(versionDirPath, "app-loader.mjs") | ||
); | ||
var bundleDirName = path.join(DIR_NAME, VERSION, "bundled"); | ||
var bundleDirPath = path.resolve(bundleDirName); | ||
var bundleDirMetaPath = path.join(bundleDirPath, "__meta__.json"); | ||
var defaultPort = process.env.PORT ? Number(process.env.PORT) : 8080; | ||
var electronEntryURL = pathToFileURL( | ||
path.join(versionDirPath, "electron-entry.mjs") | ||
); | ||
var config = { | ||
activePort: defaultPort, | ||
applicationLoaderURL, | ||
brokenNamedExportsPackages: broken_named_exports_default, | ||
bundleDirPath, | ||
bundleDirMetaPath, | ||
bundleDirName, | ||
defaultPort, | ||
directories: [], | ||
dirPath, | ||
dvlpDirPath: path.resolve(DIR_NAME), | ||
electronEntryURL, | ||
esbuildTargetByExtension: { | ||
".js": "js", | ||
".mjs": "js", | ||
".cjs": "js", | ||
".json": "json", | ||
".jsx": "jsx", | ||
".ts": "ts", | ||
".tsx": "tsx", | ||
".mts": "ts", | ||
".cts": "ts" | ||
}, | ||
// Ordered to trigger transpiling if necessary | ||
extensionsByType: { | ||
css: [".pcss", ".sass", ".scss", ".less", ".styl", ".stylus", ".css"], | ||
html: [ | ||
".nunjs", | ||
".nunjucks", | ||
".hbs", | ||
".handlebars", | ||
".dust", | ||
".html", | ||
".htm" | ||
], | ||
js: [".ts", ".mts", ".cts", ".tsx", ".jsx", ".mjs", ".cjs", ".js", ".json"] | ||
}, | ||
latency: 50, | ||
maxAge: "60", | ||
maxAgeLong: "3600", | ||
reloadEndpoint: "/dvlpreload", | ||
serverStartTimeout: TESTING ? 4e3 : 1e4, | ||
testing: TESTING, | ||
typesByExtension: { | ||
".css": "css", | ||
".pcss": "css", | ||
".sass": "css", | ||
".scss": "css", | ||
".less": "css", | ||
".styl": "css", | ||
".stylus": "css", | ||
".html": "html", | ||
".htm": "html", | ||
".nunjs": "html", | ||
".nunjucks": "html", | ||
".hbs": "html", | ||
".handlebars": "html", | ||
".dust": "html", | ||
".js": "js", | ||
".mjs": "js", | ||
".cjs": "js", | ||
".json": "js", | ||
".jsx": "js", | ||
".ts": "js", | ||
".tsx": "js", | ||
".mts": "js", | ||
".cts": "js" | ||
}, | ||
version: VERSION, | ||
versionDirPath | ||
}; | ||
var config_default = config; | ||
// src/utils/is.js | ||
import fs from "node:fs"; | ||
import path2 from "node:path"; | ||
var RE_BARE_SPECIFIER = /^[^./](?!:)/; | ||
var RE_NODE_MODULES = /node_modules/; | ||
var RE_TYPE_CSS = /text\/css/i; | ||
var RE_TYPE_HTML = /text\/html/i; | ||
var RE_TYPE_JS = /application\/javascript/i; | ||
var realPath = "native" in fs.realpathSync && typeof fs.realpathSync.native === "function" ? fs.realpathSync.native : fs.realpathSync; | ||
function isAbsoluteFilePath(filePath) { | ||
return "string" == typeof filePath && path2.isAbsolute(filePath) && // Only absolute if from root | ||
path2.resolve(filePath).startsWith(process.cwd().slice(0, 5)); | ||
} | ||
function isBareSpecifier(id) { | ||
return RE_BARE_SPECIFIER.test(id); | ||
} | ||
function isBundledUrl(url) { | ||
return url.includes(config_default.bundleDirName.replace(/\\/g, "/")); | ||
} | ||
function isCssFilePath(filePath) { | ||
return config_default.extensionsByType.css.includes(path2.extname(filePath)); | ||
} | ||
function isCssRequest(req) { | ||
const filePath = new URL(req.url, "http://localhost").pathname; | ||
return req.type === "css" || isCssFilePath(filePath) || req.headers.accept && RE_TYPE_CSS.test(req.headers.accept); | ||
} | ||
function isHtmlFilePath(filePath) { | ||
return config_default.extensionsByType.html.includes(path2.extname(filePath)); | ||
} | ||
function isHtmlRequest(req) { | ||
const filePath = new URL(req.url, "http://localhost").pathname; | ||
return req.type === "html" || isHtmlFilePath(filePath) || req.headers.accept && RE_TYPE_HTML.test(req.headers.accept); | ||
} | ||
function isJsFilePath(filePath) { | ||
return config_default.extensionsByType.js.includes(path2.extname(filePath)); | ||
} | ||
function isJsRequest(req) { | ||
const filePath = new URL(req.url, "http://localhost").pathname; | ||
return req.type === "js" || isJsFilePath(filePath) || // Almost always '*/*' | ||
req.headers.accept && RE_TYPE_JS.test(req.headers.accept); | ||
} | ||
function isNodeModuleFilePath(filePath) { | ||
const isNodeModule = RE_NODE_MODULES.test(filePath); | ||
if (!isNodeModule) { | ||
return false; | ||
} | ||
try { | ||
return RE_NODE_MODULES.test(realPath(filePath)); | ||
} catch (err) { | ||
return true; | ||
} | ||
} | ||
function isRelativeFilePath(filePath) { | ||
return "string" == typeof filePath && filePath.startsWith("."); | ||
} | ||
function isValidFilePath(filePath, fromDir = process.cwd()) { | ||
if (isRelativeFilePath(filePath)) { | ||
filePath = path2.join(fromDir, filePath); | ||
} | ||
try { | ||
const stat = fs.statSync(filePath); | ||
if (stat.isFile()) { | ||
return true; | ||
} | ||
} catch (err) { | ||
} | ||
return false; | ||
} | ||
// src/utils/log.js | ||
function error() { | ||
} | ||
function noisyWarn() { | ||
} | ||
function warn() { | ||
} | ||
var WARN_MISSING_EXTENSION = ""; | ||
var WARN_PACKAGE_INDEX = ""; | ||
// src/utils/file.js | ||
import fs2 from "node:fs"; | ||
// node_modules/.pnpm/es-module-lexer@1.5.0/node_modules/es-module-lexer/dist/lexer.js | ||
var ImportType; | ||
!function(A2) { | ||
A2[A2.Static = 1] = "Static", A2[A2.Dynamic = 2] = "Dynamic", A2[A2.ImportMeta = 3] = "ImportMeta", A2[A2.StaticSourcePhase = 4] = "StaticSourcePhase", A2[A2.DynamicSourcePhase = 5] = "DynamicSourcePhase"; | ||
}(ImportType || (ImportType = {})); | ||
var A = 1 === new Uint8Array(new Uint16Array([1]).buffer)[0]; | ||
var C; | ||
var init = WebAssembly.compile((E = "AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gA39/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAAAAAAAAwMDAAUGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAmlwAAsCZXMADAJlZQANA2VscwAOA2VsZQAPAnJpABACcmUAEQFmABICbXMAEwVwYXJzZQAUC19faGVhcF9iYXNlAwEKxUAwaAEBf0EAIAA2AoAKQQAoAtwJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgKECkEAIAA2AogKQQBBADYC4AlBAEEANgLwCUEAQQA2AugJQQBBADYC5AlBAEEANgL4CUEAQQA2AuwJIAEL0wEBA39BACgC8AkhBEEAQQAoAogKIgU2AvAJQQAgBDYC9AlBACAFQSRqNgKICiAEQSBqQeAJIAQbIAU2AgBBACgC1AkhBEEAKALQCSEGIAUgATYCACAF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sAohBANAAkACQCADQf//A3EiA0EiRg0AIANBJ0YNACADECwaQQAoArAKIQMMAQsgAxAaQQBBACgCsApBAmoiAzYCsAoLQQEQKRoCQCAEIAMQLSIDQSxHDQBBAEEAKAKwCkECajYCsApBARApIQMLIANB/QBGDQNBACgCsAoiBSAERg0PIAUhBCAFQQAoArQKTQ0ADA8LC0EAIARBAmo2ArAKQQEQKRpBACgCsAoiAyADEC0aDAILQQBBADoAlAoCQAJAAkACQAJAAkAgA0Gff2oODAILBAELAwsLCwsLBQALIANB9gBGDQQMCgtBACAEQQ5qIgM2ArAKAkACQAJAQQEQKUGff2oOBgASAhISARILQQAoArAKIgUpAAJC84Dkg+CNwDFSDREgBS8BChAgRQ0RQQAgBUEKajYCsApBABApGgtBACgCsAoiBUECakGsCEEOEC8NECAFLwEQIgJBd2oiAUEXSw0NQQEgAXRBn4CABHFFDQ0MDgtBACgCsAoiBSkAAkLsgISDsI7AOVINDyAFLwEKIgJBd2oiAUEXTQ0GDAoLQQAgBEEKajYCsApBABApGkEAKAKwCiEEC0EAIARBEGo2ArAKAkBBARApIgRBKkcNAEEAQQAoArAKQQJqNgKwCkEBECkhBAtBACgCsAohAyAEECwaIANBACgCsAoiBCADIAQQAkEAQQAoArAKQX5qNgKwCg8LAkAgBCkAAkLsgISDsI7AOVINACAELwEKEB9FDQBBACAEQQpqNgKwCkEBECkhBEEAKAKwCiEDIAQQLBogA0EAKAKwCiIEIAMgBBACQQBBACgCsApBfmo2ArAKDwtBACAEQQRqIgQ2ArAKC0EAIARBBmo2ArAKQQBBADoAlApBARApIQRBACgCsAohAyAEECwhBEEAKAKwCiECIARB3/8DcSIBQdsARw0DQQAgAkECajYCsApBARApIQVBACgCsAohA0EAIQQMBAtBAEEBOgCMCkEAQQAoArAKQQJqNgKwCgtBARApIQRBACgCsAohAwJAIARB5gBHDQAgA0ECakGmCEEGEC8NAEEAIANBCGo2ArAKIABBARApQQAQKyACQRBqQeQJIAIbIQMDQCADKAIAIgNFDQUgA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QAA", "undefined" != typeof Buffer ? Buffer.from(E, "base64") : Uint8Array.from(atob(E), (A2) => A2.charCodeAt(0)))).then(WebAssembly.instantiate).then(({ exports: A2 }) => { | ||
C = A2; | ||
}); | ||
var E; | ||
// src/utils/file.js | ||
import path3 from "node:path"; | ||
var FILE_TYPES = ["js", "css", "html"]; | ||
var MAX_FILE_SYSTEM_DEPTH = 10; | ||
var realPath2 = "native" in fs2.realpathSync && typeof fs2.realpathSync.native === "function" ? fs2.realpathSync.native : fs2.realpathSync; | ||
function find(req, { directories = config_default.directories, type } = {}) { | ||
const href = decodeURI( | ||
isRequestObject(req) ? new URL(req.url, "http://localhost").pathname : req | ||
); | ||
let filePath; | ||
if (type === void 0) { | ||
type = isRequestObject(req) ? getTypeFromRequest(req) : getTypeFromPath(req); | ||
} | ||
if (href.startsWith("/node_modules")) { | ||
directories = [ | ||
...directories, | ||
...resolveNodeModulesDirectories(process.cwd()).map( | ||
(nodeModulesDirPath) => path3.dirname(nodeModulesDirPath) | ||
) | ||
]; | ||
} | ||
if (isBundledUrl(href)) { | ||
filePath = path3.resolve(href.slice(1)); | ||
} else if (isAbsoluteFilePath(href)) { | ||
filePath = resolveFilePath(href, type); | ||
} else { | ||
for (const directory of directories) { | ||
filePath = resolveFilePath(path3.join(directory, href), type); | ||
if (filePath) { | ||
break; | ||
} | ||
} | ||
} | ||
if (!filePath) { | ||
return; | ||
} | ||
if (isRequestObject(req)) { | ||
req.filePath = filePath; | ||
req.type = getTypeFromPath(filePath); | ||
} | ||
return filePath; | ||
} | ||
function getProjectPath(filePath) { | ||
if (Array.isArray(filePath)) { | ||
filePath = filePath[0]; | ||
} | ||
const projectFilePath = isAbsoluteFilePath(filePath) ? path3.relative(process.cwd(), filePath) : filePath; | ||
return projectFilePath.startsWith("/") ? projectFilePath.slice(1) : projectFilePath; | ||
} | ||
function getTypeFromPath(filePath) { | ||
if (filePath !== void 0) { | ||
const pathname = new URL(filePath, "http://localhost").pathname; | ||
return config_default.typesByExtension[path3.extname(pathname)]; | ||
} | ||
} | ||
function getTypeFromRequest(req) { | ||
if (req.type) { | ||
return req.type; | ||
} else if (isJsRequest(req)) { | ||
return "js"; | ||
} else if (isCssRequest(req)) { | ||
return "css"; | ||
} else if (isHtmlRequest(req)) { | ||
return "html"; | ||
} | ||
} | ||
function resolveFilePath(filePath, type) { | ||
filePath = decodeURI(filePath).replace(/(\s)/g, "$1"); | ||
try { | ||
const stat = fs2.statSync(filePath); | ||
if (stat.isFile()) { | ||
return resolveRealFilePath(filePath); | ||
} | ||
} catch (err) { | ||
} | ||
if (type === void 0) { | ||
for (const ft of FILE_TYPES) { | ||
const fp2 = resolveFilePath(filePath, ft); | ||
if (fp2) { | ||
return resolveRealFilePath(fp2); | ||
} | ||
} | ||
type = "js"; | ||
} | ||
const hasExtension = path3.extname(filePath) !== ""; | ||
let fp = resolveFilePathExtension(filePath, config_default.extensionsByType[type]); | ||
if (fp) { | ||
if (!hasExtension && !isNodeModuleFilePath(fp)) { | ||
warn(WARN_MISSING_EXTENSION, `"${getProjectPath(filePath)}"`); | ||
} | ||
return resolveRealFilePath(fp); | ||
} | ||
fp = resolveFilePathExtension( | ||
path3.join(filePath, "index"), | ||
config_default.extensionsByType[type] | ||
); | ||
if (fp && type === "js") { | ||
if (!isNodeModuleFilePath(fp)) { | ||
warn(WARN_PACKAGE_INDEX, `"${getProjectPath(filePath)}"`); | ||
} | ||
} | ||
return resolveRealFilePath(fp); | ||
} | ||
function resolveFilePathExtension(filePath, extensions) { | ||
const ext = path3.extname(filePath); | ||
if (ext && extensions.includes(ext)) { | ||
filePath = filePath.replace(ext, ""); | ||
} | ||
for (const ext2 of extensions) { | ||
const fp = filePath + ext2; | ||
if (fs2.existsSync(fp)) { | ||
return fp; | ||
} | ||
} | ||
return ""; | ||
} | ||
function resolveRealFilePath(filePath) { | ||
if (!filePath || !path3.isAbsolute(filePath)) { | ||
return filePath; | ||
} | ||
try { | ||
return realPath2(filePath); | ||
} catch (err) { | ||
return filePath; | ||
} | ||
} | ||
function isRequestObject(req) { | ||
return typeof req !== "string"; | ||
} | ||
function resolveNodeModulesDirectories(filePath) { | ||
let dir = path3.extname(filePath) ? path3.dirname(filePath) : filePath; | ||
let dirs = []; | ||
let depth = MAX_FILE_SYSTEM_DEPTH; | ||
let parent; | ||
while (true) { | ||
parent = path3.dirname(dir); | ||
if (!--depth || parent.toLowerCase() === dir.toLowerCase()) { | ||
break; | ||
} | ||
const nodeModulesPath = path3.resolve(dir, "node_modules"); | ||
if (fs2.existsSync(nodeModulesPath)) { | ||
dirs.push(nodeModulesPath); | ||
} | ||
dir = parent; | ||
} | ||
return dirs.sort((a, b) => a.length >= b.length ? -1 : 1); | ||
} | ||
// src/resolver/package.js | ||
import fs3 from "node:fs"; | ||
import path4 from "node:path"; | ||
var MAX_FILE_SYSTEM_DEPTH2 = 10; | ||
var RE_TRAILING = /\/+$|\\+$/; | ||
function getPackage(filePath, packagePath = resolvePackagePath(filePath), env2 = "browser") { | ||
if (packagePath === void 0 || !fs3.existsSync(packagePath)) { | ||
return; | ||
} | ||
const manifestPath = path4.join(packagePath, "package.json"); | ||
const isProjectPackage = packagePath === process.cwd(); | ||
const paths = resolveNodeModulesDirectories(packagePath); | ||
const pkg = { | ||
env: env2, | ||
exportsConditions: [env2, "development", "dvlp"], | ||
isProjectPackage, | ||
manifestPath, | ||
main: "", | ||
name: "", | ||
path: packagePath, | ||
paths, | ||
type: void 0, | ||
version: "" | ||
}; | ||
const findOptions = { | ||
directories: [packagePath, ...pkg.paths], | ||
type: "js" | ||
}; | ||
try { | ||
const json = JSON.parse(fs3.readFileSync(manifestPath, "utf8")); | ||
const hasModuleField = json.module !== void 0; | ||
const type = hasModuleField ? "module" : json.type; | ||
const name = resolvePackageName(json.name, packagePath); | ||
let main = find(json.module || json.main || "index.js", findOptions); | ||
if (json.imports) { | ||
pkg.imports = json.imports; | ||
} | ||
if (json.exports) { | ||
pkg.exports = json.exports; | ||
} else if (env2 === "browser" && json.browser) { | ||
pkg.browser = {}; | ||
if (typeof json.browser === "string") { | ||
if (!hasModuleField) { | ||
main = find(json.browser, findOptions); | ||
} | ||
} else { | ||
for (let key in json.browser) { | ||
let value = json.browser[key]; | ||
if (typeof value === "string") { | ||
if (path4.extname(key) || isRelativeFilePath(key)) { | ||
key = find(key, findOptions); | ||
} | ||
if (path4.extname(value) || isRelativeFilePath(value)) { | ||
value = find(value, findOptions); | ||
} | ||
if (key !== void 0 && value !== void 0 && key !== value) { | ||
if (!hasModuleField && key === main) { | ||
main = value; | ||
} | ||
pkg.browser[key] = value; | ||
} else { | ||
} | ||
} else { | ||
} | ||
} | ||
} | ||
} | ||
pkg.name = name; | ||
pkg.main = main; | ||
pkg.type = type; | ||
pkg.version = json.version; | ||
} catch (err) { | ||
} | ||
return pkg; | ||
} | ||
function resolvePackagePath(filePath) { | ||
filePath = filePath.replace(RE_TRAILING, ""); | ||
const cwd = process.cwd(); | ||
const isNodeModule = filePath.includes("node_modules"); | ||
let depth = MAX_FILE_SYSTEM_DEPTH2; | ||
let dir = filePath; | ||
let parent = ""; | ||
let root = cwd; | ||
if (isNodeModule) { | ||
const parts = filePath.split(path4.sep); | ||
const idx = parts.indexOf("node_modules"); | ||
root = parts.slice(0, idx + 1).join(path4.sep); | ||
} | ||
while (true) { | ||
const pkgPath = path4.join(dir, "package.json"); | ||
if (fs3.existsSync(pkgPath)) { | ||
if (!isNodeModule) { | ||
return dir; | ||
} | ||
try { | ||
const json = JSON.parse(fs3.readFileSync(pkgPath, "utf8")); | ||
if (json.name || json.main || json.imports || json.exports || json.browser || json.module) { | ||
return dir; | ||
} | ||
} catch (err) { | ||
} | ||
} | ||
parent = path4.dirname(dir); | ||
if (dir === root || !--depth || parent.toLowerCase() === dir.toLowerCase()) { | ||
break; | ||
} | ||
dir = parent; | ||
} | ||
} | ||
function resolvePackageSourcePath(filePathOrSpecifier, pkg, verifyExport) { | ||
if (pkg.imports !== void 0 && filePathOrSpecifier.startsWith("#")) { | ||
return resolveImportPath(filePathOrSpecifier, pkg); | ||
} else if (pkg.exports && verifyExport) { | ||
let resolvedFilePath = resolveExportPath(filePathOrSpecifier, pkg); | ||
if (resolvedFilePath !== void 0 && !fs3.existsSync(resolvedFilePath)) { | ||
resolvedFilePath = find(resolvedFilePath, { type: "js" }); | ||
} | ||
return resolvedFilePath; | ||
} | ||
filePathOrSpecifier = resolveMainOrBrowserPath(filePathOrSpecifier, pkg); | ||
if (isAbsoluteFilePath(filePathOrSpecifier) && !isValidFilePath(filePathOrSpecifier)) { | ||
const foundFilePath = find(filePathOrSpecifier, { type: "js" }); | ||
if (!foundFilePath) { | ||
return; | ||
} | ||
return resolveMainOrBrowserPath(foundFilePath, pkg); | ||
} | ||
return filePathOrSpecifier; | ||
} | ||
function resolveImportPath(specifier, pkg) { | ||
try { | ||
const resolved = f( | ||
{ name: pkg.name, imports: pkg.imports }, | ||
specifier, | ||
{ | ||
// `node` automatically added if not set | ||
browser: pkg.env === "browser", | ||
conditions: pkg.exportsConditions | ||
} | ||
); | ||
if (resolved?.length) { | ||
return isBareSpecifier(resolved[0]) ? resolved[0] : path4.resolve(pkg.path, resolved[0]); | ||
} | ||
} catch (err) { | ||
if ( | ||
/** @type { Error } */ | ||
err.message.includes("Missing") | ||
) { | ||
error( | ||
`unable to resolve internal package reference. The ${pkg.name} package does not specify ${specifier} in it's "imports" map.` | ||
); | ||
} | ||
} | ||
} | ||
function resolveExportPath(filePathOrSpecifier, pkg) { | ||
const entry = filePathOrSpecifier.replace( | ||
isBareSpecifier(filePathOrSpecifier) ? pkg.name : pkg.path, | ||
"." | ||
); | ||
try { | ||
const resolved = o(pkg, entry.replace(/\\/g, "/"), { | ||
// `node` automatically added if not set | ||
browser: pkg.env === "browser", | ||
conditions: pkg.exportsConditions | ||
}); | ||
if (resolved?.length) { | ||
return path4.resolve(pkg.path, resolved[0]); | ||
} | ||
} catch (err) { | ||
if ( | ||
/** @type { Error } */ | ||
err.message.includes("Missing") | ||
) { | ||
error( | ||
`unable to resolve package entry. The ${pkg.name} package does not specify ${entry} in it's "exports" map.` | ||
); | ||
} | ||
} | ||
} | ||
function resolveMainOrBrowserPath(filePath, pkg) { | ||
let resolved = filePath; | ||
if (filePath === pkg.path && pkg.main) { | ||
resolved = pkg.main; | ||
} | ||
if (pkg.browser) { | ||
while (resolved in pkg.browser) { | ||
resolved = pkg.browser[resolved]; | ||
} | ||
} | ||
return resolved; | ||
} | ||
function resolvePackageName(packageName, packagePath) { | ||
if (!isNodeModuleFilePath(packagePath)) { | ||
return packageName || "project"; | ||
} | ||
return path4.relative( | ||
packagePath.slice(0, packagePath.lastIndexOf("node_modules") + 12), | ||
packagePath | ||
).replace(/\\/g, "/"); | ||
} | ||
// src/resolver/utils.js | ||
function getPackageNameFromSpecifier(specifier) { | ||
if (isBareSpecifier(specifier)) { | ||
const segments = specifier.split("/"); | ||
let name = segments[0]; | ||
if (name.startsWith("@")) { | ||
name += `/${segments[1]}`; | ||
} | ||
return name; | ||
} | ||
} | ||
function isSelfReferentialSpecifier(specifier, pkg) { | ||
return getPackageNameFromSpecifier(specifier) === pkg.name; | ||
} | ||
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js | ||
var ANSI_BACKGROUND_OFFSET = 10; | ||
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`; | ||
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`; | ||
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`; | ||
var styles = { | ||
modifier: { | ||
reset: [0, 0], | ||
// 21 isn't widely supported and 22 does the same thing | ||
bold: [1, 22], | ||
dim: [2, 22], | ||
italic: [3, 23], | ||
underline: [4, 24], | ||
overline: [53, 55], | ||
inverse: [7, 27], | ||
hidden: [8, 28], | ||
strikethrough: [9, 29] | ||
}, | ||
color: { | ||
black: [30, 39], | ||
red: [31, 39], | ||
green: [32, 39], | ||
yellow: [33, 39], | ||
blue: [34, 39], | ||
magenta: [35, 39], | ||
cyan: [36, 39], | ||
white: [37, 39], | ||
// Bright color | ||
blackBright: [90, 39], | ||
gray: [90, 39], | ||
// Alias of `blackBright` | ||
grey: [90, 39], | ||
// Alias of `blackBright` | ||
redBright: [91, 39], | ||
greenBright: [92, 39], | ||
yellowBright: [93, 39], | ||
blueBright: [94, 39], | ||
magentaBright: [95, 39], | ||
cyanBright: [96, 39], | ||
whiteBright: [97, 39] | ||
}, | ||
bgColor: { | ||
bgBlack: [40, 49], | ||
bgRed: [41, 49], | ||
bgGreen: [42, 49], | ||
bgYellow: [43, 49], | ||
bgBlue: [44, 49], | ||
bgMagenta: [45, 49], | ||
bgCyan: [46, 49], | ||
bgWhite: [47, 49], | ||
// Bright color | ||
bgBlackBright: [100, 49], | ||
bgGray: [100, 49], | ||
// Alias of `bgBlackBright` | ||
bgGrey: [100, 49], | ||
// Alias of `bgBlackBright` | ||
bgRedBright: [101, 49], | ||
bgGreenBright: [102, 49], | ||
bgYellowBright: [103, 49], | ||
bgBlueBright: [104, 49], | ||
bgMagentaBright: [105, 49], | ||
bgCyanBright: [106, 49], | ||
bgWhiteBright: [107, 49] | ||
} | ||
}; | ||
var modifierNames = Object.keys(styles.modifier); | ||
var foregroundColorNames = Object.keys(styles.color); | ||
var backgroundColorNames = Object.keys(styles.bgColor); | ||
var colorNames = [...foregroundColorNames, ...backgroundColorNames]; | ||
function assembleStyles() { | ||
const codes = /* @__PURE__ */ new Map(); | ||
for (const [groupName, group] of Object.entries(styles)) { | ||
for (const [styleName, style] of Object.entries(group)) { | ||
styles[styleName] = { | ||
open: `\x1B[${style[0]}m`, | ||
close: `\x1B[${style[1]}m` | ||
}; | ||
group[styleName] = styles[styleName]; | ||
codes.set(style[0], style[1]); | ||
} | ||
Object.defineProperty(styles, groupName, { | ||
value: group, | ||
enumerable: false | ||
}); | ||
} | ||
Object.defineProperty(styles, "codes", { | ||
value: codes, | ||
enumerable: false | ||
}); | ||
styles.color.close = "\x1B[39m"; | ||
styles.bgColor.close = "\x1B[49m"; | ||
styles.color.ansi = wrapAnsi16(); | ||
styles.color.ansi256 = wrapAnsi256(); | ||
styles.color.ansi16m = wrapAnsi16m(); | ||
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); | ||
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); | ||
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); | ||
Object.defineProperties(styles, { | ||
rgbToAnsi256: { | ||
value(red, green, blue) { | ||
if (red === green && green === blue) { | ||
if (red < 8) { | ||
return 16; | ||
} | ||
if (red > 248) { | ||
return 231; | ||
} | ||
return Math.round((red - 8) / 247 * 24) + 232; | ||
} | ||
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5); | ||
}, | ||
enumerable: false | ||
}, | ||
hexToRgb: { | ||
value(hex) { | ||
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16)); | ||
if (!matches) { | ||
return [0, 0, 0]; | ||
} | ||
let [colorString] = matches; | ||
if (colorString.length === 3) { | ||
colorString = [...colorString].map((character) => character + character).join(""); | ||
} | ||
const integer = Number.parseInt(colorString, 16); | ||
return [ | ||
/* eslint-disable no-bitwise */ | ||
integer >> 16 & 255, | ||
integer >> 8 & 255, | ||
integer & 255 | ||
/* eslint-enable no-bitwise */ | ||
]; | ||
}, | ||
enumerable: false | ||
}, | ||
hexToAnsi256: { | ||
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)), | ||
enumerable: false | ||
}, | ||
ansi256ToAnsi: { | ||
value(code) { | ||
if (code < 8) { | ||
return 30 + code; | ||
} | ||
if (code < 16) { | ||
return 90 + (code - 8); | ||
} | ||
let red; | ||
let green; | ||
let blue; | ||
if (code >= 232) { | ||
red = ((code - 232) * 10 + 8) / 255; | ||
green = red; | ||
blue = red; | ||
} else { | ||
code -= 16; | ||
const remainder = code % 36; | ||
red = Math.floor(code / 36) / 5; | ||
green = Math.floor(remainder / 6) / 5; | ||
blue = remainder % 6 / 5; | ||
} | ||
const value = Math.max(red, green, blue) * 2; | ||
if (value === 0) { | ||
return 30; | ||
} | ||
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red)); | ||
if (value === 2) { | ||
result += 60; | ||
} | ||
return result; | ||
}, | ||
enumerable: false | ||
}, | ||
rgbToAnsi: { | ||
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)), | ||
enumerable: false | ||
}, | ||
hexToAnsi: { | ||
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)), | ||
enumerable: false | ||
} | ||
}); | ||
return styles; | ||
} | ||
var ansiStyles = assembleStyles(); | ||
var ansi_styles_default = ansiStyles; | ||
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js | ||
import process2 from "node:process"; | ||
import os from "node:os"; | ||
import tty from "node:tty"; | ||
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) { | ||
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--"; | ||
const position = argv.indexOf(prefix + flag); | ||
const terminatorPosition = argv.indexOf("--"); | ||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); | ||
} | ||
var { env } = process2; | ||
var flagForceColor; | ||
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) { | ||
flagForceColor = 0; | ||
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) { | ||
flagForceColor = 1; | ||
} | ||
function envForceColor() { | ||
if ("FORCE_COLOR" in env) { | ||
if (env.FORCE_COLOR === "true") { | ||
return 1; | ||
} | ||
if (env.FORCE_COLOR === "false") { | ||
return 0; | ||
} | ||
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); | ||
} | ||
} | ||
function translateLevel(level) { | ||
if (level === 0) { | ||
return false; | ||
} | ||
return { | ||
level, | ||
hasBasic: true, | ||
has256: level >= 2, | ||
has16m: level >= 3 | ||
}; | ||
} | ||
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) { | ||
const noFlagForceColor = envForceColor(); | ||
if (noFlagForceColor !== void 0) { | ||
flagForceColor = noFlagForceColor; | ||
} | ||
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; | ||
if (forceColor === 0) { | ||
return 0; | ||
} | ||
if (sniffFlags) { | ||
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) { | ||
return 3; | ||
} | ||
if (hasFlag("color=256")) { | ||
return 2; | ||
} | ||
} | ||
if ("TF_BUILD" in env && "AGENT_NAME" in env) { | ||
return 1; | ||
} | ||
if (haveStream && !streamIsTTY && forceColor === void 0) { | ||
return 0; | ||
} | ||
const min = forceColor || 0; | ||
if (env.TERM === "dumb") { | ||
return min; | ||
} | ||
if (process2.platform === "win32") { | ||
const osRelease = os.release().split("."); | ||
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { | ||
return Number(osRelease[2]) >= 14931 ? 3 : 2; | ||
} | ||
return 1; | ||
} | ||
if ("CI" in env) { | ||
if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) { | ||
return 3; | ||
} | ||
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") { | ||
return 1; | ||
} | ||
return min; | ||
} | ||
if ("TEAMCITY_VERSION" in env) { | ||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; | ||
} | ||
if (env.COLORTERM === "truecolor") { | ||
return 3; | ||
} | ||
if (env.TERM === "xterm-kitty") { | ||
return 3; | ||
} | ||
if ("TERM_PROGRAM" in env) { | ||
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10); | ||
switch (env.TERM_PROGRAM) { | ||
case "iTerm.app": { | ||
return version >= 3 ? 3 : 2; | ||
} | ||
case "Apple_Terminal": { | ||
return 2; | ||
} | ||
} | ||
} | ||
if (/-256(color)?$/i.test(env.TERM)) { | ||
return 2; | ||
} | ||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { | ||
return 1; | ||
} | ||
if ("COLORTERM" in env) { | ||
return 1; | ||
} | ||
return min; | ||
} | ||
function createSupportsColor(stream, options = {}) { | ||
const level = _supportsColor(stream, { | ||
streamIsTTY: stream && stream.isTTY, | ||
...options | ||
}); | ||
return translateLevel(level); | ||
} | ||
var supportsColor = { | ||
stdout: createSupportsColor({ isTTY: tty.isatty(1) }), | ||
stderr: createSupportsColor({ isTTY: tty.isatty(2) }) | ||
}; | ||
var supports_color_default = supportsColor; | ||
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js | ||
function stringReplaceAll(string, substring, replacer) { | ||
let index = string.indexOf(substring); | ||
if (index === -1) { | ||
return string; | ||
} | ||
const substringLength = substring.length; | ||
let endIndex = 0; | ||
let returnValue = ""; | ||
do { | ||
returnValue += string.slice(endIndex, index) + substring + replacer; | ||
endIndex = index + substringLength; | ||
index = string.indexOf(substring, endIndex); | ||
} while (index !== -1); | ||
returnValue += string.slice(endIndex); | ||
return returnValue; | ||
} | ||
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) { | ||
let endIndex = 0; | ||
let returnValue = ""; | ||
do { | ||
const gotCR = string[index - 1] === "\r"; | ||
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix; | ||
endIndex = index + 1; | ||
index = string.indexOf("\n", endIndex); | ||
} while (index !== -1); | ||
returnValue += string.slice(endIndex); | ||
return returnValue; | ||
} | ||
// node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js | ||
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default; | ||
var GENERATOR = Symbol("GENERATOR"); | ||
var STYLER = Symbol("STYLER"); | ||
var IS_EMPTY = Symbol("IS_EMPTY"); | ||
var levelMapping = [ | ||
"ansi", | ||
"ansi", | ||
"ansi256", | ||
"ansi16m" | ||
]; | ||
var styles2 = /* @__PURE__ */ Object.create(null); | ||
var applyOptions = (object, options = {}) => { | ||
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { | ||
throw new Error("The `level` option should be an integer from 0 to 3"); | ||
} | ||
const colorLevel = stdoutColor ? stdoutColor.level : 0; | ||
object.level = options.level === void 0 ? colorLevel : options.level; | ||
}; | ||
var chalkFactory = (options) => { | ||
const chalk2 = (...strings) => strings.join(" "); | ||
applyOptions(chalk2, options); | ||
Object.setPrototypeOf(chalk2, createChalk.prototype); | ||
return chalk2; | ||
}; | ||
function createChalk(options) { | ||
return chalkFactory(options); | ||
} | ||
Object.setPrototypeOf(createChalk.prototype, Function.prototype); | ||
for (const [styleName, style] of Object.entries(ansi_styles_default)) { | ||
styles2[styleName] = { | ||
get() { | ||
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]); | ||
Object.defineProperty(this, styleName, { value: builder }); | ||
return builder; | ||
} | ||
}; | ||
} | ||
styles2.visible = { | ||
get() { | ||
const builder = createBuilder(this, this[STYLER], true); | ||
Object.defineProperty(this, "visible", { value: builder }); | ||
return builder; | ||
} | ||
}; | ||
var getModelAnsi = (model, level, type, ...arguments_) => { | ||
if (model === "rgb") { | ||
if (level === "ansi16m") { | ||
return ansi_styles_default[type].ansi16m(...arguments_); | ||
} | ||
if (level === "ansi256") { | ||
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_)); | ||
} | ||
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_)); | ||
} | ||
if (model === "hex") { | ||
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_)); | ||
} | ||
return ansi_styles_default[type][model](...arguments_); | ||
}; | ||
var usedModels = ["rgb", "hex", "ansi256"]; | ||
for (const model of usedModels) { | ||
styles2[model] = { | ||
get() { | ||
const { level } = this; | ||
return function(...arguments_) { | ||
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]); | ||
return createBuilder(this, styler, this[IS_EMPTY]); | ||
}; | ||
} | ||
}; | ||
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1); | ||
styles2[bgModel] = { | ||
get() { | ||
const { level } = this; | ||
return function(...arguments_) { | ||
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]); | ||
return createBuilder(this, styler, this[IS_EMPTY]); | ||
}; | ||
} | ||
}; | ||
} | ||
var proto = Object.defineProperties(() => { | ||
}, { | ||
...styles2, | ||
level: { | ||
enumerable: true, | ||
get() { | ||
return this[GENERATOR].level; | ||
}, | ||
set(level) { | ||
this[GENERATOR].level = level; | ||
} | ||
} | ||
}); | ||
var createStyler = (open, close, parent) => { | ||
let openAll; | ||
let closeAll; | ||
if (parent === void 0) { | ||
openAll = open; | ||
closeAll = close; | ||
} else { | ||
openAll = parent.openAll + open; | ||
closeAll = close + parent.closeAll; | ||
} | ||
return { | ||
open, | ||
close, | ||
openAll, | ||
closeAll, | ||
parent | ||
}; | ||
}; | ||
var createBuilder = (self, _styler, _isEmpty) => { | ||
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" ")); | ||
Object.setPrototypeOf(builder, proto); | ||
builder[GENERATOR] = self; | ||
builder[STYLER] = _styler; | ||
builder[IS_EMPTY] = _isEmpty; | ||
return builder; | ||
}; | ||
var applyStyle = (self, string) => { | ||
if (self.level <= 0 || !string) { | ||
return self[IS_EMPTY] ? "" : string; | ||
} | ||
let styler = self[STYLER]; | ||
if (styler === void 0) { | ||
return string; | ||
} | ||
const { openAll, closeAll } = styler; | ||
if (string.includes("\x1B")) { | ||
while (styler !== void 0) { | ||
string = stringReplaceAll(string, styler.close, styler.open); | ||
styler = styler.parent; | ||
} | ||
} | ||
const lfIndex = string.indexOf("\n"); | ||
if (lfIndex !== -1) { | ||
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); | ||
} | ||
return openAll + string + closeAll; | ||
}; | ||
Object.defineProperties(createChalk.prototype, styles2); | ||
var chalk = createChalk(); | ||
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 }); | ||
var source_default = chalk; | ||
// src/resolver/index.js | ||
import fs4 from "node:fs"; | ||
import path5 from "node:path"; | ||
import { pathToFileURL as pathToFileURL2 } from "node:url"; | ||
var packageCacheByImportDir = /* @__PURE__ */ new Map(); | ||
var packageVersionCacheByName = /* @__PURE__ */ new Map(); | ||
var packageCacheByNameAndVersion = /* @__PURE__ */ new Map(); | ||
var resolveCache = /* @__PURE__ */ new Map(); | ||
function nodeResolve(specifier, importer = "index.js") { | ||
if (!specifier) { | ||
return; | ||
} | ||
importer = path5.resolve(importer); | ||
const key = getCacheKey(importer, specifier, "node"); | ||
const cached = resolveCache.get(key); | ||
if (cached !== void 0) { | ||
return cached; | ||
} | ||
const result = doResolve( | ||
specifier, | ||
resolveRealFilePath(path5.dirname(importer)), | ||
true, | ||
"node" | ||
); | ||
if (result === void 0) { | ||
return; | ||
} | ||
result.url = pathToFileURL2(result.filePath).href; | ||
resolveCache.set(key, result); | ||
return result; | ||
} | ||
function getPackageForDir(dir, env2 = "browser") { | ||
const pkgPath = resolvePackagePath(dir); | ||
if (!pkgPath) { | ||
return; | ||
} | ||
const pkgKey = `${pkgPath}:${env2}`; | ||
let pkg = packageCacheByImportDir.get(pkgKey); | ||
if (!pkg) { | ||
pkg = getPackage(dir, pkgPath, env2); | ||
if (pkg) { | ||
packageCacheByImportDir.set(pkgKey, pkg); | ||
} | ||
} | ||
return pkg; | ||
} | ||
function doResolve(specifier, importerDirPath, isEntry, env2) { | ||
const pkg = resolvePackage(importerDirPath, env2); | ||
if (!pkg) { | ||
return; | ||
} | ||
const verifyExports = !isEntry || isSelfReferentialSpecifier(specifier, pkg); | ||
if (specifier === pkg.name || specifier.startsWith(`${pkg.name}/`)) { | ||
specifier = specifier.replace(pkg.name, "."); | ||
importerDirPath = pkg.path; | ||
} | ||
let filePath = resolvePackageSourcePath( | ||
isRelativeFilePath(specifier) ? path5.join(importerDirPath, specifier) : specifier, | ||
pkg, | ||
verifyExports | ||
); | ||
if (!filePath) { | ||
return; | ||
} else if (isAbsoluteFilePath(filePath)) { | ||
filePath = resolveRealFilePath(filePath); | ||
return { filePath, format: resolveFileFormat(filePath, pkg) }; | ||
} else if (!isBareSpecifier(filePath)) { | ||
return; | ||
} | ||
specifier = filePath; | ||
const packageName = ( | ||
/** @type { string } */ | ||
getPackageNameFromSpecifier(specifier) | ||
); | ||
const localPath = specifier.slice(packageName.length); | ||
for (const packageDirPath of pkg.paths) { | ||
const packagePath = path5.join(packageDirPath, packageName); | ||
if (importerDirPath !== packageDirPath && fs4.existsSync(packagePath)) { | ||
const result = doResolve( | ||
specifier, | ||
path5.join(resolveRealFilePath(packagePath), localPath), | ||
false, | ||
env2 | ||
); | ||
if (result !== void 0) { | ||
return { | ||
filePath: resolveRealFilePath(result.filePath), | ||
format: result.format | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
function getCacheKey(importerFilePath, specifier, env2) { | ||
if (isBareSpecifier(specifier) && !isNodeModuleFilePath(importerFilePath)) { | ||
return `src:${specifier}:${env2}`; | ||
} | ||
return `${getProjectPath(importerFilePath)}:${specifier}:${env2}`; | ||
} | ||
function resolvePackage(dir, env2) { | ||
let pkg = getPackageForDir(dir, env2); | ||
if (pkg && env2 === "browser") { | ||
if (!packageVersionCacheByName.has(pkg.name)) { | ||
packageVersionCacheByName.set(pkg.name, /* @__PURE__ */ new Set([pkg.version])); | ||
} else { | ||
const versions = ( | ||
/** @type { Set<string> } */ | ||
packageVersionCacheByName.get(pkg.name) | ||
); | ||
versions.add(pkg.version); | ||
if (versions.size > 1) { | ||
noisyWarn( | ||
`${source_default.yellow("\u26A0\uFE0F")} multiple versions of the "${pkg.name}" package used: ${Array.from(versions).join(", ")}` | ||
); | ||
} | ||
} | ||
const versionedKey = `${pkg.name}@${pkg.version}`; | ||
const versionedPackage = packageCacheByNameAndVersion.get(versionedKey); | ||
if (versionedPackage && versionedPackage !== pkg) { | ||
pkg = versionedPackage; | ||
} | ||
packageCacheByNameAndVersion.set(versionedKey, pkg); | ||
} | ||
return pkg; | ||
} | ||
function resolveFileFormat(filePath, pkg) { | ||
const ext = path5.extname(filePath); | ||
if (ext === ".mjs") { | ||
return "module"; | ||
} else if (ext === ".cjs") { | ||
return "commonjs"; | ||
} else { | ||
return pkg.type; | ||
} | ||
} | ||
// src/application-host/application-loader.js | ||
import { nodeResolve } from "dvlp/internal"; | ||
var IS_WIN32 = process.platform === "win32"; | ||
@@ -1301,3 +17,3 @@ var RE_EXTS = /\.(tsx?|json)$/; | ||
context, | ||
(specifier2, context2) => doResolve2(specifier2, context2, nextResolve) | ||
(specifier2, context2) => doResolve(specifier2, context2, nextResolve) | ||
); | ||
@@ -1307,5 +23,5 @@ resolved.shortCircuit = true; | ||
} | ||
return doResolve2(specifier, context, nextResolve); | ||
return doResolve(specifier, context, nextResolve); | ||
} | ||
function doResolve2(specifier, context, nextResolve) { | ||
function doResolve(specifier, context, nextResolve) { | ||
if (!specifier.startsWith("node:")) { | ||
@@ -1343,3 +59,3 @@ const resolved = nodeResolve( | ||
const filename = IS_WIN32 ? url : fileURLToPath(url); | ||
const source = fs5.readFileSync(new URL(url), { encoding: "utf8" }); | ||
const source = fs.readFileSync(new URL(url), { encoding: "utf8" }); | ||
const { code } = transform(source, filename, url, format); | ||
@@ -1346,0 +62,0 @@ return { format: "module", source: code, shortCircuit: true }; |
@@ -41,3 +41,3 @@ #!/usr/bin/env node | ||
program.parse(process.argv); | ||
program.allowUnknownOption(true).parse(process.argv); | ||
@@ -49,12 +49,16 @@ async function boot(path = [process.cwd()]) { | ||
await server(path, { | ||
certsPath: options.ssl, | ||
electron: options.electron, | ||
hooksPath: options.hooks, | ||
mockPath: options.mock, | ||
port: options.port, | ||
reload: options.reload, | ||
silent: options.silent, | ||
verbose: options.verbose, | ||
}); | ||
await server( | ||
path.filter((arg) => !arg.startsWith('-')), | ||
{ | ||
argv: program.args.filter((arg) => arg.startsWith('-')), | ||
certsPath: options.ssl, | ||
electron: options.electron, | ||
hooksPath: options.hooks, | ||
mockPath: options.mock, | ||
port: options.port, | ||
reload: options.reload, | ||
silent: options.silent, | ||
verbose: options.verbose, | ||
}, | ||
); | ||
} catch (err) { | ||
@@ -61,0 +65,0 @@ console.error(err); |
@@ -19,2 +19,1 @@ import { createRequire as createRequireBecauseEsbuild } from 'module'; | ||
}); | ||
await import(workerData.dvlp.main); |
{ | ||
"name": "dvlp", | ||
"version": "16.3.2", | ||
"version": "16.3.3-beta.1", | ||
"description": "A no-nonsense dev server toolkit to help you develop quickly and easily for the web", | ||
@@ -5,0 +5,0 @@ "type": "module", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49
1231955
33303
2