veryfront
Advanced tools
+1
-1
| export default { | ||
| "name": "veryfront", | ||
| "version": "0.1.57", | ||
| "version": "0.1.58", | ||
| "license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "nodeModulesDir": "auto", |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAkBtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkDrD,CAAC;AASF,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,uBAAuB;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAqTzG;AAmND;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAG7D"} | ||
| {"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAkBtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkDrD,CAAC;AASF,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,uBAAuB;IACvB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAqTzG;AAuND;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAG7D"} |
@@ -391,17 +391,21 @@ /** Module Server - serves transformed ESM modules at /_vf_modules/* URLs */ | ||
| : basePathWithoutExt; | ||
| for (const ext of extensions) { | ||
| const frameworkPath = join(frameworkDir, pathWithinFramework + ext); | ||
| try { | ||
| const stat = await platformFs.stat(frameworkPath); | ||
| if (stat.isFile) { | ||
| logger.debug(`Found framework ${label} file`, { | ||
| basePath: basePathWithoutExt, | ||
| resolvedPath: frameworkPath, | ||
| }); | ||
| return { path: frameworkPath, isFrameworkFile: true }; | ||
| // Try direct file match first, then index file fallback | ||
| const candidates = [pathWithinFramework, `${pathWithinFramework}/index`]; | ||
| for (const candidate of candidates) { | ||
| for (const ext of extensions) { | ||
| const frameworkPath = join(frameworkDir, candidate + ext); | ||
| try { | ||
| const stat = await platformFs.stat(frameworkPath); | ||
| if (stat.isFile) { | ||
| logger.debug(`Found framework ${label} file`, { | ||
| basePath: basePathWithoutExt, | ||
| resolvedPath: frameworkPath, | ||
| }); | ||
| return { path: frameworkPath, isFrameworkFile: true }; | ||
| } | ||
| } | ||
| catch (_) { | ||
| /* expected: file may not exist at this extension */ | ||
| } | ||
| } | ||
| catch (_) { | ||
| /* expected: file may not exist at this extension */ | ||
| } | ||
| } | ||
@@ -408,0 +412,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"veryfront-strategy.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/import-rewriter/strategies/veryfront-strategy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AAerB,qBAAa,iBAAkB,YAAW,qBAAqB;IAC7D,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,QAAQ,OAAO;IAExB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO;IAQzD,OAAO,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,EAAE,cAAc,GAAG,aAAa;CAoCvE;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"} | ||
| {"version":3,"file":"veryfront-strategy.d.ts","sourceRoot":"","sources":["../../../../../src/src/transforms/import-rewriter/strategies/veryfront-strategy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AAkBrB,qBAAa,iBAAkB,YAAW,qBAAqB;IAC7D,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,QAAQ,OAAO;IAExB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO;IAQzD,OAAO,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,EAAE,cAAc,GAAG,aAAa;CA2CvE;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"} |
@@ -8,3 +8,3 @@ /** | ||
| import { buildVeryfrontModuleUrl } from "../url-builder.js"; | ||
| import { resolveVeryfrontModuleUrl } from "../../veryfront-module-urls.js"; | ||
| import { resolveInternalModuleUrl, resolveVeryfrontModuleUrl, } from "../../veryfront-module-urls.js"; | ||
| /** | ||
@@ -36,3 +36,2 @@ * SSR-specific module overrides. | ||
| if (mapped) { | ||
| // For SSR, append ?ssr=true to signal server-side rendering | ||
| if (ctx.target === "ssr") | ||
@@ -42,2 +41,11 @@ return { specifier: `${mapped}?ssr=true` }; | ||
| } | ||
| // Try resolving via #veryfront/* import map (handles paths where the | ||
| // filesystem layout differs from the specifier, e.g. #veryfront/compat/console | ||
| // maps to src/platform/compat/console/index.ts, not src/compat/console.ts) | ||
| const internalMapped = resolveInternalModuleUrl(specifier); | ||
| if (internalMapped) { | ||
| if (ctx.target === "ssr") | ||
| return { specifier: `${internalMapped}?ssr=true` }; | ||
| return { specifier: internalMapped }; | ||
| } | ||
| const builtUrl = buildVeryfrontModuleUrl(path); | ||
@@ -44,0 +52,0 @@ if (ctx.target === "ssr") |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"path-resolver.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAU,MAAM,mCAAmC,CAAC;AAW7E,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,EACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAmBzD;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GACtC,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CA6DzD;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA+D1F;AAED;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CAClD,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GACvC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiExB"} | ||
| {"version":3,"file":"path-resolver.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/pipeline/stages/ssr-vf-modules/path-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAU,MAAM,mCAAmC,CAAC;AAY7E,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,EACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAmBzD;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GACtC,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CA6DzD;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkE1F;AAED;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CAClD,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GACvC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiExB"} |
@@ -10,2 +10,3 @@ /** | ||
| import { rendererLogger as logger } from "../../../../utils/index.js"; | ||
| import { resolveInternalModuleTarget } from "../../../veryfront-module-urls.js"; | ||
| import { EMBEDDED_SRC_DIR, EXTENSIONS, FRAMEWORK_LOOKUPS, FRAMEWORK_ROOT, LOG_PREFIX, } from "./constants.js"; | ||
@@ -99,3 +100,6 @@ export async function tryReadWithExtensions(fs, basePath) { | ||
| return null; | ||
| const relativePath = specifier.slice("#veryfront/".length); | ||
| const mappedTarget = resolveInternalModuleTarget(specifier); | ||
| if (!mappedTarget?.startsWith("./src/")) | ||
| return null; | ||
| const relativePath = mappedTarget.slice("./src/".length); | ||
| const hasExtension = /\.(tsx?|jsx?|mjs)$/.test(relativePath); | ||
@@ -102,0 +106,0 @@ // Check embedded sources first (for compiled binaries), then regular src/ |
@@ -0,2 +1,11 @@ | ||
| export declare function resolveVeryfrontModuleTarget(specifier: string): string | null; | ||
| export declare function resolveInternalModuleTarget(specifier: string): string | null; | ||
| export declare function resolveVeryfrontModuleUrl(specifier: string): string | null; | ||
| /** | ||
| * Resolve an internal #veryfront/* specifier to a /_vf_modules/ URL. | ||
| * Uses the deno.json import map to get the correct filesystem path, | ||
| * which may differ from the specifier path (e.g. #veryfront/compat/console | ||
| * maps to src/platform/compat/console/index.ts, not src/compat/console.ts). | ||
| */ | ||
| export declare function resolveInternalModuleUrl(specifier: string): string | null; | ||
| //# sourceMappingURL=veryfront-module-urls.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"veryfront-module-urls.d.ts","sourceRoot":"","sources":["../../../src/src/transforms/veryfront-module-urls.ts"],"names":[],"mappings":"AAmDA,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE1E"} | ||
| {"version":3,"file":"veryfront-module-urls.d.ts","sourceRoot":"","sources":["../../../src/src/transforms/veryfront-module-urls.ts"],"names":[],"mappings":"AAwGA,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE7E;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE5E;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGzE"} |
| import denoConfig from "../../deno.js"; | ||
| const MODULE_EXT_RE = /\.(mjs|cjs|js|jsx|ts|tsx)$/; | ||
| const SRC_PREFIX = "./src/"; | ||
| function createTargetIndex() { | ||
| return { | ||
| exactTargets: new Map(), | ||
| prefixTargets: [], | ||
| }; | ||
| } | ||
| function normalizeModulePath(path) { | ||
| if (!path) | ||
| return path; | ||
| if (path.endsWith("/")) | ||
| return path; | ||
| return path.replace(MODULE_EXT_RE, ".js"); | ||
| } | ||
| function toModuleServerUrl(target) { | ||
@@ -10,19 +23,44 @@ if (!target.startsWith(SRC_PREFIX)) | ||
| return null; | ||
| const withoutExt = relative.replace(MODULE_EXT_RE, ""); | ||
| return `/_vf_modules/_veryfront/${withoutExt}.js`; | ||
| return `/_vf_modules/_veryfront/${normalizeModulePath(relative)}`; | ||
| } | ||
| function addMapping(map, specifier, target) { | ||
| const url = toModuleServerUrl(target); | ||
| if (!url) | ||
| function addMapping(index, specifier, target) { | ||
| if (!target.startsWith(SRC_PREFIX)) | ||
| return; | ||
| map.set(specifier, url); | ||
| if (specifier.endsWith("/")) { | ||
| index.prefixTargets.push({ | ||
| specifierPrefix: specifier, | ||
| targetPrefix: target.endsWith("/") ? target : `${target}/`, | ||
| }); | ||
| return; | ||
| } | ||
| index.exactTargets.set(specifier, target); | ||
| } | ||
| function finalizeIndex(index) { | ||
| index.prefixTargets.sort((a, b) => b.specifierPrefix.length - a.specifierPrefix.length); | ||
| } | ||
| function resolveTarget(index, specifier) { | ||
| const exact = index.exactTargets.get(specifier); | ||
| if (exact) | ||
| return exact; | ||
| for (const { specifierPrefix, targetPrefix } of index.prefixTargets) { | ||
| if (!specifier.startsWith(specifierPrefix)) | ||
| continue; | ||
| return `${targetPrefix}${specifier.slice(specifierPrefix.length)}`; | ||
| } | ||
| return null; | ||
| } | ||
| const config = denoConfig; | ||
| const veryfrontModuleUrlMap = new Map(); | ||
| const veryfrontTargetIndex = createTargetIndex(); | ||
| const internalTargetIndex = createTargetIndex(); | ||
| for (const [specifier, target] of Object.entries(config.imports ?? {})) { | ||
| if (!specifier.startsWith("veryfront/")) | ||
| continue; | ||
| if (typeof target !== "string") | ||
| continue; | ||
| addMapping(veryfrontModuleUrlMap, specifier, target); | ||
| if (specifier === "veryfront" || specifier.startsWith("veryfront/")) { | ||
| addMapping(veryfrontTargetIndex, specifier, target); | ||
| } | ||
| // Also index #veryfront imports so the import rewriter can | ||
| // generate correct /_vf_modules/ URLs that match the actual filesystem layout. | ||
| if (specifier === "#veryfront" || specifier.startsWith("#veryfront/")) { | ||
| addMapping(internalTargetIndex, specifier, target); | ||
| } | ||
| } | ||
@@ -33,3 +71,3 @@ for (const [key, target] of Object.entries(config.exports ?? {})) { | ||
| if (key === ".") { | ||
| addMapping(veryfrontModuleUrlMap, "veryfront", target); | ||
| addMapping(veryfrontTargetIndex, "veryfront", target); | ||
| continue; | ||
@@ -39,6 +77,25 @@ } | ||
| continue; | ||
| addMapping(veryfrontModuleUrlMap, `veryfront/${key.slice(2)}`, target); | ||
| addMapping(veryfrontTargetIndex, `veryfront/${key.slice(2)}`, target); | ||
| } | ||
| finalizeIndex(veryfrontTargetIndex); | ||
| finalizeIndex(internalTargetIndex); | ||
| export function resolveVeryfrontModuleTarget(specifier) { | ||
| return resolveTarget(veryfrontTargetIndex, specifier); | ||
| } | ||
| export function resolveInternalModuleTarget(specifier) { | ||
| return resolveTarget(internalTargetIndex, specifier); | ||
| } | ||
| export function resolveVeryfrontModuleUrl(specifier) { | ||
| return veryfrontModuleUrlMap.get(specifier) ?? null; | ||
| const target = resolveVeryfrontModuleTarget(specifier); | ||
| return target ? toModuleServerUrl(target) : null; | ||
| } | ||
| /** | ||
| * Resolve an internal #veryfront/* specifier to a /_vf_modules/ URL. | ||
| * Uses the deno.json import map to get the correct filesystem path, | ||
| * which may differ from the specifier path (e.g. #veryfront/compat/console | ||
| * maps to src/platform/compat/console/index.ts, not src/compat/console.ts). | ||
| */ | ||
| export function resolveInternalModuleUrl(specifier) { | ||
| const target = resolveInternalModuleTarget(specifier); | ||
| return target ? toModuleServerUrl(target) : null; | ||
| } |
+1
-1
| { | ||
| "name": "veryfront", | ||
| "version": "0.1.57", | ||
| "version": "0.1.58", | ||
| "description": "The simplest way to build AI-powered apps", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
+1
-1
| export default { | ||
| "name": "veryfront", | ||
| "version": "0.1.57", | ||
| "version": "0.1.58", | ||
| "license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "nodeModulesDir": "auto", |
@@ -517,15 +517,19 @@ /** Module Server - serves transformed ESM modules at /_vf_modules/* URLs */ | ||
| for (const ext of extensions) { | ||
| const frameworkPath = join(frameworkDir, pathWithinFramework + ext); | ||
| try { | ||
| const stat = await platformFs.stat(frameworkPath); | ||
| if (stat.isFile) { | ||
| logger.debug(`Found framework ${label} file`, { | ||
| basePath: basePathWithoutExt, | ||
| resolvedPath: frameworkPath, | ||
| }); | ||
| return { path: frameworkPath, isFrameworkFile: true }; | ||
| // Try direct file match first, then index file fallback | ||
| const candidates = [pathWithinFramework, `${pathWithinFramework}/index`]; | ||
| for (const candidate of candidates) { | ||
| for (const ext of extensions) { | ||
| const frameworkPath = join(frameworkDir, candidate + ext); | ||
| try { | ||
| const stat = await platformFs.stat(frameworkPath); | ||
| if (stat.isFile) { | ||
| logger.debug(`Found framework ${label} file`, { | ||
| basePath: basePathWithoutExt, | ||
| resolvedPath: frameworkPath, | ||
| }); | ||
| return { path: frameworkPath, isFrameworkFile: true }; | ||
| } | ||
| } catch (_) { | ||
| /* expected: file may not exist at this extension */ | ||
| } | ||
| } catch (_) { | ||
| /* expected: file may not exist at this extension */ | ||
| } | ||
@@ -532,0 +536,0 @@ } |
@@ -15,3 +15,6 @@ /** | ||
| import { buildVeryfrontModuleUrl } from "../url-builder.js"; | ||
| import { resolveVeryfrontModuleUrl } from "../../veryfront-module-urls.js"; | ||
| import { | ||
| resolveInternalModuleUrl, | ||
| resolveVeryfrontModuleUrl, | ||
| } from "../../veryfront-module-urls.js"; | ||
@@ -50,6 +53,13 @@ /** | ||
| if (mapped) { | ||
| // For SSR, append ?ssr=true to signal server-side rendering | ||
| if (ctx.target === "ssr") return { specifier: `${mapped}?ssr=true` }; | ||
| return { specifier: mapped }; | ||
| } | ||
| // Try resolving via #veryfront/* import map (handles paths where the | ||
| // filesystem layout differs from the specifier, e.g. #veryfront/compat/console | ||
| // maps to src/platform/compat/console/index.ts, not src/compat/console.ts) | ||
| const internalMapped = resolveInternalModuleUrl(specifier); | ||
| if (internalMapped) { | ||
| if (ctx.target === "ssr") return { specifier: `${internalMapped}?ssr=true` }; | ||
| return { specifier: internalMapped }; | ||
| } | ||
| const builtUrl = buildVeryfrontModuleUrl(path); | ||
@@ -56,0 +66,0 @@ if (ctx.target === "ssr") return { specifier: `${builtUrl}?ssr=true` }; |
@@ -11,2 +11,3 @@ /** | ||
| import { rendererLogger as logger } from "../../../../utils/index.js"; | ||
| import { resolveInternalModuleTarget } from "../../../veryfront-module-urls.js"; | ||
| import { | ||
@@ -124,3 +125,6 @@ EMBEDDED_SRC_DIR, | ||
| const relativePath = specifier.slice("#veryfront/".length); | ||
| const mappedTarget = resolveInternalModuleTarget(specifier); | ||
| if (!mappedTarget?.startsWith("./src/")) return null; | ||
| const relativePath = mappedTarget.slice("./src/".length); | ||
| const hasExtension = /\.(tsx?|jsx?|mjs)$/.test(relativePath); | ||
@@ -127,0 +131,0 @@ |
@@ -11,2 +11,20 @@ import denoConfig from "../../deno.js"; | ||
| type ModuleTargetIndex = { | ||
| exactTargets: Map<string, string>; | ||
| prefixTargets: Array<{ specifierPrefix: string; targetPrefix: string }>; | ||
| }; | ||
| function createTargetIndex(): ModuleTargetIndex { | ||
| return { | ||
| exactTargets: new Map<string, string>(), | ||
| prefixTargets: [], | ||
| }; | ||
| } | ||
| function normalizeModulePath(path: string): string { | ||
| if (!path) return path; | ||
| if (path.endsWith("/")) return path; | ||
| return path.replace(MODULE_EXT_RE, ".js"); | ||
| } | ||
| function toModuleServerUrl(target: string): string | null { | ||
@@ -18,23 +36,55 @@ if (!target.startsWith(SRC_PREFIX)) return null; | ||
| const withoutExt = relative.replace(MODULE_EXT_RE, ""); | ||
| return `/_vf_modules/_veryfront/${withoutExt}.js`; | ||
| return `/_vf_modules/_veryfront/${normalizeModulePath(relative)}`; | ||
| } | ||
| function addMapping( | ||
| map: Map<string, string>, | ||
| index: ModuleTargetIndex, | ||
| specifier: string, | ||
| target: string, | ||
| ): void { | ||
| const url = toModuleServerUrl(target); | ||
| if (!url) return; | ||
| map.set(specifier, url); | ||
| if (!target.startsWith(SRC_PREFIX)) return; | ||
| if (specifier.endsWith("/")) { | ||
| index.prefixTargets.push({ | ||
| specifierPrefix: specifier, | ||
| targetPrefix: target.endsWith("/") ? target : `${target}/`, | ||
| }); | ||
| return; | ||
| } | ||
| index.exactTargets.set(specifier, target); | ||
| } | ||
| function finalizeIndex(index: ModuleTargetIndex): void { | ||
| index.prefixTargets.sort((a, b) => b.specifierPrefix.length - a.specifierPrefix.length); | ||
| } | ||
| function resolveTarget(index: ModuleTargetIndex, specifier: string): string | null { | ||
| const exact = index.exactTargets.get(specifier); | ||
| if (exact) return exact; | ||
| for (const { specifierPrefix, targetPrefix } of index.prefixTargets) { | ||
| if (!specifier.startsWith(specifierPrefix)) continue; | ||
| return `${targetPrefix}${specifier.slice(specifierPrefix.length)}`; | ||
| } | ||
| return null; | ||
| } | ||
| const config = denoConfig as DenoConfig; | ||
| const veryfrontModuleUrlMap = new Map<string, string>(); | ||
| const veryfrontTargetIndex = createTargetIndex(); | ||
| const internalTargetIndex = createTargetIndex(); | ||
| for (const [specifier, target] of Object.entries(config.imports ?? {})) { | ||
| if (!specifier.startsWith("veryfront/")) continue; | ||
| if (typeof target !== "string") continue; | ||
| addMapping(veryfrontModuleUrlMap, specifier, target); | ||
| if (specifier === "veryfront" || specifier.startsWith("veryfront/")) { | ||
| addMapping(veryfrontTargetIndex, specifier, target); | ||
| } | ||
| // Also index #veryfront imports so the import rewriter can | ||
| // generate correct /_vf_modules/ URLs that match the actual filesystem layout. | ||
| if (specifier === "#veryfront" || specifier.startsWith("#veryfront/")) { | ||
| addMapping(internalTargetIndex, specifier, target); | ||
| } | ||
| } | ||
@@ -46,3 +96,3 @@ | ||
| if (key === ".") { | ||
| addMapping(veryfrontModuleUrlMap, "veryfront", target); | ||
| addMapping(veryfrontTargetIndex, "veryfront", target); | ||
| continue; | ||
@@ -52,7 +102,30 @@ } | ||
| if (!key.startsWith("./")) continue; | ||
| addMapping(veryfrontModuleUrlMap, `veryfront/${key.slice(2)}`, target); | ||
| addMapping(veryfrontTargetIndex, `veryfront/${key.slice(2)}`, target); | ||
| } | ||
| finalizeIndex(veryfrontTargetIndex); | ||
| finalizeIndex(internalTargetIndex); | ||
| export function resolveVeryfrontModuleTarget(specifier: string): string | null { | ||
| return resolveTarget(veryfrontTargetIndex, specifier); | ||
| } | ||
| export function resolveInternalModuleTarget(specifier: string): string | null { | ||
| return resolveTarget(internalTargetIndex, specifier); | ||
| } | ||
| export function resolveVeryfrontModuleUrl(specifier: string): string | null { | ||
| return veryfrontModuleUrlMap.get(specifier) ?? null; | ||
| const target = resolveVeryfrontModuleTarget(specifier); | ||
| return target ? toModuleServerUrl(target) : null; | ||
| } | ||
| /** | ||
| * Resolve an internal #veryfront/* specifier to a /_vf_modules/ URL. | ||
| * Uses the deno.json import map to get the correct filesystem path, | ||
| * which may differ from the specifier path (e.g. #veryfront/compat/console | ||
| * maps to src/platform/compat/console/index.ts, not src/compat/console.ts). | ||
| */ | ||
| export function resolveInternalModuleUrl(specifier: string): string | null { | ||
| const target = resolveInternalModuleTarget(specifier); | ||
| return target ? toModuleServerUrl(target) : null; | ||
| } |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
16713197
0.04%349143
0.04%