veryfront 0.1.824 → 0.1.825

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.824",
3
+ "version": "0.1.825",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "minimumDependencyAge": {
@@ -0,0 +1,2 @@
1
+ export declare function ensureFilenameDefaultExport(normalizedPath: string, moduleCode: string): string;
2
+ //# sourceMappingURL=filename-default-export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filename-default-export.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/loader-shared/filename-default-export.ts"],"names":[],"mappings":"AA8DA,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAa9F"}
@@ -0,0 +1,57 @@
1
+ const IDENTIFIER_PATTERN = /^[A-Za-z_$][\w$]*$/;
2
+ const DEFAULT_EXPORT_PATTERN = /\bexport\s+default\b|\bexport\s*\{[^}]*\bas\s+default\b[^}]*\}/;
3
+ function escapeRegex(value) {
4
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
+ }
6
+ function getModuleIdentifier(normalizedPath) {
7
+ const fileName = normalizedPath.replace(/\?.*$/, "").split("/").pop();
8
+ const identifier = fileName?.replace(/\.(?:[cm]?[jt]sx?|mdx)$/i, "");
9
+ if (!identifier || !IDENTIFIER_PATTERN.test(identifier))
10
+ return null;
11
+ return identifier;
12
+ }
13
+ function findExportMatch(moduleCode, exportName) {
14
+ const declarationPattern = new RegExp(`\\bexport\\s+(?:const|let|var|function|class)\\s+${escapeRegex(exportName)}\\b`);
15
+ if (declarationPattern.test(moduleCode))
16
+ return { localName: exportName, sourceClause: "" };
17
+ const exportListPattern = /\bexport\s*\{([^}]*)\}\s*(from\s*["'][^"']+["'])?\s*(?:;|$)/gm;
18
+ let match;
19
+ while ((match = exportListPattern.exec(moduleCode)) !== null) {
20
+ const specifiers = match[1]?.split(",") ?? [];
21
+ const sourceClause = match[2] ? ` ${match[2]}` : "";
22
+ for (const rawSpecifier of specifiers) {
23
+ const specifier = rawSpecifier.trim();
24
+ if (specifier === exportName)
25
+ return { localName: exportName, sourceClause };
26
+ const alias = specifier.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);
27
+ if (alias?.[2] === exportName && alias[1]) {
28
+ return { localName: alias[1], sourceClause };
29
+ }
30
+ }
31
+ }
32
+ return null;
33
+ }
34
+ function appendExportBeforeSourceMap(moduleCode, exportStatement) {
35
+ const sourceMapMarker = "//# sourceMappingURL=";
36
+ let sourceMapIndex = moduleCode.lastIndexOf(`\n${sourceMapMarker}`);
37
+ if (sourceMapIndex < 0 && moduleCode.startsWith(sourceMapMarker)) {
38
+ sourceMapIndex = 0;
39
+ }
40
+ if (sourceMapIndex < 0) {
41
+ return `${moduleCode.trimEnd()}\n${exportStatement}\n`;
42
+ }
43
+ const beforeSourceMap = moduleCode.slice(0, sourceMapIndex).trimEnd();
44
+ const sourceMap = moduleCode.slice(sourceMapIndex);
45
+ return `${beforeSourceMap}\n${exportStatement}${sourceMap.endsWith("\n") ? sourceMap : `${sourceMap}\n`}`;
46
+ }
47
+ export function ensureFilenameDefaultExport(normalizedPath, moduleCode) {
48
+ if (DEFAULT_EXPORT_PATTERN.test(moduleCode))
49
+ return moduleCode;
50
+ const exportName = getModuleIdentifier(normalizedPath);
51
+ if (!exportName)
52
+ return moduleCode;
53
+ const exportMatch = findExportMatch(moduleCode, exportName);
54
+ if (!exportMatch)
55
+ return moduleCode;
56
+ return appendExportBeforeSourceMap(moduleCode, `export { ${exportMatch.localName} as default }${exportMatch.sourceClause};`);
57
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAsCtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwDrD,CAAC;AAiBF,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,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6XzF;AAwWD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGrD"}
1
+ {"version":3,"file":"module-server.d.ts","sourceRoot":"","sources":["../../../../src/src/modules/server/module-server.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAuCtE;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwDrD,CAAC;AAiBF,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,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8XzF;AAwWD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGrD"}
@@ -21,6 +21,7 @@ import { readLimitedCrossProjectSource } from "./cross-project-source-limit.js";
21
21
  import { sha256Short } from "../../cache/hash.js";
22
22
  import { rewriteReleaseDependencyImportsForModule } from "../../release-assets/module-consumption.js";
23
23
  import { buildSourceMissCacheKey, hasSourceMiss, rememberSourceMiss, } from "./module-source-resolution-cache.js";
24
+ import { ensureFilenameDefaultExport } from "../loader-shared/filename-default-export.js";
24
25
  const logger = serverLogger.component("module-server");
25
26
  const PROJECT_FALLBACK_EMBEDDED_POLYFILLS = new Set(["deno"]);
26
27
  /**
@@ -348,6 +349,7 @@ export function serveModule(req, options) {
348
349
  reactVersion,
349
350
  };
350
351
  code = await profileModuleTransform(() => transformToESM(source, sourceFile, projectDir, adapter, transformOpts));
352
+ code = ensureFilenameDefaultExport(modulePath, code);
351
353
  if (isSSR) {
352
354
  code = await applySSRImportRewritesAsync(code, {
353
355
  projectSlug,
@@ -7,7 +7,6 @@
7
7
  * @module transforms/mdx/esm-module-loader/module-fetcher/module-cache
8
8
  */
9
9
  import type { Logger } from "../../../../utils/logger/logger.js";
10
- export declare function ensureFilenameDefaultExport(normalizedPath: string, moduleCode: string): string;
11
10
  /**
12
11
  * Normalize a module path, resolving relative paths if a parent is provided.
13
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"module-cache.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/module-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAkEjE,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAa9F;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAanF;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,GAAG,EAAE,MAAM,EACX,YAAY,SAAwB,GACnC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqCxB"}
1
+ {"version":3,"file":"module-cache.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/module-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAUjE;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAanF;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,GAAG,EAAE,MAAM,EACX,YAAY,SAAwB,GACnC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqCxB"}
@@ -15,59 +15,7 @@ import { hashString } from "../utils/hash.js";
15
15
  import { buildMdxEsmModuleFileName, buildMdxEsmPathCacheKey } from "../cache-format.js";
16
16
  import { hasUnresolvedImports } from "./nested-imports.js";
17
17
  import { recordModuleToSession } from "./render-sessions.js";
18
- const IDENTIFIER_PATTERN = /^[A-Za-z_$][\w$]*$/;
19
- const DEFAULT_EXPORT_PATTERN = /\bexport\s+default\b|\bexport\s*\{[^}]*\bas\s+default\b[^}]*\}/;
20
- function escapeRegex(value) {
21
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
22
- }
23
- function getModuleIdentifier(normalizedPath) {
24
- const fileName = normalizedPath.replace(/\?.*$/, "").split("/").pop();
25
- const identifier = fileName?.replace(/\.(?:[cm]?[jt]sx?|mdx)$/i, "");
26
- if (!identifier || !IDENTIFIER_PATTERN.test(identifier))
27
- return null;
28
- return identifier;
29
- }
30
- function findExportMatch(moduleCode, exportName) {
31
- const declarationPattern = new RegExp(`\\bexport\\s+(?:const|let|var|function|class)\\s+${escapeRegex(exportName)}\\b`);
32
- if (declarationPattern.test(moduleCode))
33
- return { localName: exportName, sourceClause: "" };
34
- const exportListPattern = /\bexport\s*\{([^}]*)\}\s*(from\s*["'][^"']+["'])?\s*(?:;|$)/gm;
35
- let match;
36
- while ((match = exportListPattern.exec(moduleCode)) !== null) {
37
- const specifiers = match[1]?.split(",") ?? [];
38
- const sourceClause = match[2] ? ` ${match[2]}` : "";
39
- for (const rawSpecifier of specifiers) {
40
- const specifier = rawSpecifier.trim();
41
- if (specifier === exportName)
42
- return { localName: exportName, sourceClause };
43
- const alias = specifier.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);
44
- if (alias?.[2] === exportName && alias[1]) {
45
- return { localName: alias[1], sourceClause };
46
- }
47
- }
48
- }
49
- return null;
50
- }
51
- function appendExportBeforeSourceMap(moduleCode, exportStatement) {
52
- const sourceMapMatch = moduleCode.match(/\n\/\/# sourceMappingURL=.*$/);
53
- if (sourceMapMatch?.index === undefined) {
54
- return `${moduleCode.trimEnd()}\n${exportStatement}\n`;
55
- }
56
- const beforeSourceMap = moduleCode.slice(0, sourceMapMatch.index).trimEnd();
57
- const sourceMap = moduleCode.slice(sourceMapMatch.index);
58
- return `${beforeSourceMap}\n${exportStatement}${sourceMap.endsWith("\n") ? sourceMap : `${sourceMap}\n`}`;
59
- }
60
- export function ensureFilenameDefaultExport(normalizedPath, moduleCode) {
61
- if (DEFAULT_EXPORT_PATTERN.test(moduleCode))
62
- return moduleCode;
63
- const exportName = getModuleIdentifier(normalizedPath);
64
- if (!exportName)
65
- return moduleCode;
66
- const exportMatch = findExportMatch(moduleCode, exportName);
67
- if (!exportMatch)
68
- return moduleCode;
69
- return appendExportBeforeSourceMap(moduleCode, `export { ${exportMatch.localName} as default }${exportMatch.sourceClause};`);
70
- }
18
+ import { ensureFilenameDefaultExport } from "../../../../modules/loader-shared/filename-default-export.js";
71
19
  /**
72
20
  * Normalize a module path, resolving relative paths if a parent is provided.
73
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/persistence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAEjE,OAAO,EAAE,WAAW,EAA+B,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,KAAK,kBAAkB,GAAG,OAAO,WAAW,CAAC;AAC7C,KAAK,uBAAuB,GAAG,OAAO,qBAAqB,CAAC;AAC5D,KAAK,gBAAgB,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/D,MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE;QACtB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,iBAAiB,EAAE,MAAM,CAAC;QAC1B,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;IACtC,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqCxB"}
1
+ {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/module-fetcher/persistence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,KAAK,kBAAkB,GAAG,OAAO,WAAW,CAAC;AAC7C,KAAK,uBAAuB,GAAG,OAAO,qBAAqB,CAAC;AAC5D,KAAK,gBAAgB,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/D,MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE;QACtB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,iBAAiB,EAAE,MAAM,CAAC;QAC1B,SAAS,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;IACtC,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqCxB"}
@@ -4,7 +4,8 @@
4
4
  * @module transforms/mdx/esm-module-loader/module-fetcher/persistence
5
5
  */
6
6
  import { LOG_PREFIX_MDX_LOADER } from "../constants.js";
7
- import { cacheModule, ensureFilenameDefaultExport } from "./module-cache.js";
7
+ import { ensureFilenameDefaultExport } from "../../../../modules/loader-shared/filename-default-export.js";
8
+ import { cacheModule } from "./module-cache.js";
8
9
  import { writeDistributedCache } from "./distributed-cache.js";
9
10
  /**
10
11
  * Persist fully resolved module code to distributed and local caches.
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.824";
2
+ export declare const VERSION = "0.1.825";
3
3
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
3
  /** Shared version value. */
4
- export const VERSION = "0.1.824";
4
+ export const VERSION = "0.1.825";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.824",
3
+ "version": "0.1.825",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",