@veryfront/ext-content-mdx 0.1.1119 → 0.1.1122

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.
Files changed (188) hide show
  1. package/esm/_dnt.polyfills.d.ts +6 -0
  2. package/esm/_dnt.polyfills.d.ts.map +1 -1
  3. package/esm/deno.js +1 -1
  4. package/esm/src/config/defaults.d.ts +39 -0
  5. package/esm/src/config/defaults.d.ts.map +1 -0
  6. package/esm/src/config/defaults.js +65 -0
  7. package/esm/src/errors/error-registry/agent.d.ts +18 -0
  8. package/esm/src/errors/error-registry/agent.d.ts.map +1 -0
  9. package/esm/src/errors/error-registry/agent.js +60 -0
  10. package/esm/src/errors/error-registry/boundary.d.ts +16 -0
  11. package/esm/src/errors/error-registry/boundary.d.ts.map +1 -0
  12. package/esm/src/errors/error-registry/boundary.js +52 -0
  13. package/esm/src/errors/error-registry/build.d.ts +20 -0
  14. package/esm/src/errors/error-registry/build.d.ts.map +1 -0
  15. package/esm/src/errors/error-registry/build.js +68 -0
  16. package/esm/src/errors/error-registry/config.d.ts +31 -0
  17. package/esm/src/errors/error-registry/config.d.ts.map +1 -0
  18. package/esm/src/errors/error-registry/config.js +97 -0
  19. package/esm/src/errors/error-registry/deploy.d.ts +12 -0
  20. package/esm/src/errors/error-registry/deploy.d.ts.map +1 -0
  21. package/esm/src/errors/error-registry/deploy.js +36 -0
  22. package/esm/src/errors/error-registry/dev.d.ts +14 -0
  23. package/esm/src/errors/error-registry/dev.d.ts.map +1 -0
  24. package/esm/src/errors/error-registry/dev.js +44 -0
  25. package/esm/src/errors/error-registry/general.d.ts +29 -0
  26. package/esm/src/errors/error-registry/general.d.ts.map +1 -0
  27. package/esm/src/errors/error-registry/general.js +92 -0
  28. package/esm/src/errors/error-registry/module.d.ts +16 -0
  29. package/esm/src/errors/error-registry/module.d.ts.map +1 -0
  30. package/esm/src/errors/error-registry/module.js +52 -0
  31. package/esm/src/errors/error-registry/route.d.ts +16 -0
  32. package/esm/src/errors/error-registry/route.d.ts.map +1 -0
  33. package/esm/src/errors/error-registry/route.js +52 -0
  34. package/esm/src/errors/error-registry/runtime.d.ts +27 -0
  35. package/esm/src/errors/error-registry/runtime.d.ts.map +1 -0
  36. package/esm/src/errors/error-registry/runtime.js +87 -0
  37. package/esm/src/errors/error-registry/server.d.ts +39 -0
  38. package/esm/src/errors/error-registry/server.d.ts.map +1 -0
  39. package/esm/src/errors/error-registry/server.js +129 -0
  40. package/esm/src/errors/error-registry-helpers.d.ts +6 -0
  41. package/esm/src/errors/error-registry-helpers.d.ts.map +1 -0
  42. package/esm/src/errors/error-registry-helpers.js +9 -0
  43. package/esm/src/errors/error-registry.d.ts +120 -0
  44. package/esm/src/errors/error-registry.d.ts.map +1 -0
  45. package/esm/src/errors/error-registry.js +60 -0
  46. package/esm/src/errors/types.d.ts +84 -0
  47. package/esm/src/errors/types.d.ts.map +1 -0
  48. package/esm/src/errors/types.js +69 -0
  49. package/esm/src/errors/veryfront-error.d.ts +149 -0
  50. package/esm/src/errors/veryfront-error.d.ts.map +1 -0
  51. package/esm/src/errors/veryfront-error.js +61 -0
  52. package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts +13 -0
  53. package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts.map +1 -0
  54. package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.js +55 -0
  55. package/esm/src/observability/tracing/api-shim.d.ts +191 -0
  56. package/esm/src/observability/tracing/api-shim.d.ts.map +1 -0
  57. package/esm/src/observability/tracing/api-shim.js +281 -0
  58. package/esm/src/observability/tracing/otlp-setup.d.ts +63 -0
  59. package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -0
  60. package/esm/src/observability/tracing/otlp-setup.js +219 -0
  61. package/esm/src/observability/tracing/telemetry-env.d.ts +3 -0
  62. package/esm/src/observability/tracing/telemetry-env.d.ts.map +1 -0
  63. package/esm/src/observability/tracing/telemetry-env.js +10 -0
  64. package/esm/src/platform/adapters/base.d.ts +209 -0
  65. package/esm/src/platform/adapters/base.d.ts.map +1 -0
  66. package/esm/src/platform/adapters/base.js +15 -0
  67. package/esm/src/platform/compat/constants.d.ts +13 -0
  68. package/esm/src/platform/compat/constants.d.ts.map +1 -0
  69. package/esm/src/platform/compat/constants.js +12 -0
  70. package/esm/src/platform/compat/dynamic-import.d.ts +11 -0
  71. package/esm/src/platform/compat/dynamic-import.d.ts.map +1 -0
  72. package/esm/src/platform/compat/dynamic-import.js +10 -0
  73. package/esm/src/platform/compat/fs.d.ts +76 -0
  74. package/esm/src/platform/compat/fs.d.ts.map +1 -0
  75. package/esm/src/platform/compat/fs.js +336 -0
  76. package/esm/src/platform/compat/process/command.d.ts +33 -0
  77. package/esm/src/platform/compat/process/command.d.ts.map +1 -0
  78. package/esm/src/platform/compat/process/command.js +206 -0
  79. package/esm/src/platform/compat/process.d.ts +5 -0
  80. package/esm/src/platform/compat/process.d.ts.map +1 -0
  81. package/esm/src/platform/compat/process.js +4 -0
  82. package/esm/src/transforms/import-rewriter/url-builder.d.ts +70 -0
  83. package/esm/src/transforms/import-rewriter/url-builder.d.ts.map +1 -0
  84. package/esm/src/transforms/import-rewriter/url-builder.js +152 -0
  85. package/esm/src/transforms/mdx/compiler/import-rewriter.d.ts.map +1 -1
  86. package/esm/src/transforms/mdx/compiler/import-rewriter.js +2 -1
  87. package/esm/src/utils/base64url.d.ts +7 -0
  88. package/esm/src/utils/base64url.d.ts.map +1 -0
  89. package/esm/src/utils/base64url.js +39 -0
  90. package/esm/src/utils/bundle-manifest.d.ts +63 -0
  91. package/esm/src/utils/bundle-manifest.d.ts.map +1 -0
  92. package/esm/src/utils/bundle-manifest.js +96 -0
  93. package/esm/src/utils/constants/buffers.d.ts +24 -0
  94. package/esm/src/utils/constants/buffers.d.ts.map +1 -0
  95. package/esm/src/utils/constants/buffers.js +23 -0
  96. package/esm/src/utils/constants/build.d.ts +8 -0
  97. package/esm/src/utils/constants/build.d.ts.map +1 -0
  98. package/esm/src/utils/constants/build.js +7 -0
  99. package/esm/src/utils/constants/cache.d.ts +74 -0
  100. package/esm/src/utils/constants/cache.d.ts.map +1 -0
  101. package/esm/src/utils/constants/cache.js +133 -0
  102. package/esm/src/utils/constants/cdn.d.ts +29 -0
  103. package/esm/src/utils/constants/cdn.d.ts.map +1 -0
  104. package/esm/src/utils/constants/cdn.js +58 -0
  105. package/esm/src/utils/constants/crypto.d.ts +10 -0
  106. package/esm/src/utils/constants/crypto.d.ts.map +1 -0
  107. package/esm/src/utils/constants/crypto.js +9 -0
  108. package/esm/src/utils/constants/env.d.ts +16 -0
  109. package/esm/src/utils/constants/env.d.ts.map +1 -0
  110. package/esm/src/utils/constants/env.js +20 -0
  111. package/esm/src/utils/constants/hash.d.ts +5 -0
  112. package/esm/src/utils/constants/hash.d.ts.map +1 -0
  113. package/esm/src/utils/constants/hash.js +4 -0
  114. package/esm/src/utils/constants/hmr.d.ts +24 -0
  115. package/esm/src/utils/constants/hmr.d.ts.map +1 -0
  116. package/esm/src/utils/constants/hmr.js +26 -0
  117. package/esm/src/utils/constants/html.d.ts +13 -0
  118. package/esm/src/utils/constants/html.d.ts.map +1 -0
  119. package/esm/src/utils/constants/html.js +12 -0
  120. package/esm/src/utils/constants/http.d.ts +77 -0
  121. package/esm/src/utils/constants/http.d.ts.map +1 -0
  122. package/esm/src/utils/constants/http.js +76 -0
  123. package/esm/src/utils/constants/index.d.ts +23 -0
  124. package/esm/src/utils/constants/index.d.ts.map +1 -0
  125. package/esm/src/utils/constants/index.js +22 -0
  126. package/esm/src/utils/constants/limits.d.ts +27 -0
  127. package/esm/src/utils/constants/limits.d.ts.map +1 -0
  128. package/esm/src/utils/constants/limits.js +26 -0
  129. package/esm/src/utils/constants/metrics.d.ts +10 -0
  130. package/esm/src/utils/constants/metrics.d.ts.map +1 -0
  131. package/esm/src/utils/constants/metrics.js +34 -0
  132. package/esm/src/utils/constants/network.d.ts +23 -0
  133. package/esm/src/utils/constants/network.d.ts.map +1 -0
  134. package/esm/src/utils/constants/network.js +27 -0
  135. package/esm/src/utils/constants/priorities.d.ts +31 -0
  136. package/esm/src/utils/constants/priorities.d.ts.map +1 -0
  137. package/esm/src/utils/constants/priorities.js +30 -0
  138. package/esm/src/utils/constants/retry.d.ts +14 -0
  139. package/esm/src/utils/constants/retry.d.ts.map +1 -0
  140. package/esm/src/utils/constants/retry.js +13 -0
  141. package/esm/src/utils/constants/server.d.ts +107 -0
  142. package/esm/src/utils/constants/server.d.ts.map +1 -0
  143. package/esm/src/utils/constants/server.js +120 -0
  144. package/esm/src/utils/feature-flags.d.ts +7 -0
  145. package/esm/src/utils/feature-flags.d.ts.map +1 -0
  146. package/esm/src/utils/feature-flags.js +8 -0
  147. package/esm/src/utils/hash-utils.d.ts +22 -0
  148. package/esm/src/utils/hash-utils.d.ts.map +1 -0
  149. package/esm/src/utils/hash-utils.js +48 -0
  150. package/esm/src/utils/import-lockfile.d.ts +52 -0
  151. package/esm/src/utils/import-lockfile.d.ts.map +1 -0
  152. package/esm/src/utils/import-lockfile.js +187 -0
  153. package/esm/src/utils/index.d.ts +30 -0
  154. package/esm/src/utils/index.d.ts.map +1 -0
  155. package/esm/src/utils/index.js +29 -0
  156. package/esm/src/utils/logger/components.d.ts +73 -0
  157. package/esm/src/utils/logger/components.d.ts.map +1 -0
  158. package/esm/src/utils/logger/components.js +81 -0
  159. package/esm/src/utils/logger/index.d.ts +10 -0
  160. package/esm/src/utils/logger/index.d.ts.map +1 -0
  161. package/esm/src/utils/logger/index.js +9 -0
  162. package/esm/src/utils/logger/request-context.d.ts +27 -0
  163. package/esm/src/utils/logger/request-context.d.ts.map +1 -0
  164. package/esm/src/utils/logger/request-context.js +28 -0
  165. package/esm/src/utils/memoize.d.ts +19 -0
  166. package/esm/src/utils/memoize.d.ts.map +1 -0
  167. package/esm/src/utils/memoize.js +72 -0
  168. package/esm/src/utils/parallel.d.ts +21 -0
  169. package/esm/src/utils/parallel.d.ts.map +1 -0
  170. package/esm/src/utils/parallel.js +51 -0
  171. package/esm/src/utils/path-utils.d.ts +34 -0
  172. package/esm/src/utils/path-utils.d.ts.map +1 -0
  173. package/esm/src/utils/path-utils.js +138 -0
  174. package/esm/src/utils/perf-timer.d.ts +11 -0
  175. package/esm/src/utils/perf-timer.d.ts.map +1 -0
  176. package/esm/src/utils/perf-timer.js +114 -0
  177. package/esm/src/utils/platform.d.ts +9 -0
  178. package/esm/src/utils/platform.d.ts.map +1 -0
  179. package/esm/src/utils/platform.js +11 -0
  180. package/esm/src/utils/runtime-guards.d.ts +29 -0
  181. package/esm/src/utils/runtime-guards.d.ts.map +1 -0
  182. package/esm/src/utils/runtime-guards.js +23 -0
  183. package/esm/src/utils/sleep.d.ts +2 -0
  184. package/esm/src/utils/sleep.d.ts.map +1 -0
  185. package/esm/src/utils/sleep.js +19 -0
  186. package/esm/src/utils/version-constant.d.ts +1 -1
  187. package/esm/src/utils/version-constant.js +1 -1
  188. package/package.json +2 -2
@@ -0,0 +1,52 @@
1
+ export interface LockfileEntry {
2
+ resolved: string;
3
+ integrity: string;
4
+ dependencies?: string[];
5
+ fetchedAt?: string;
6
+ }
7
+ export interface LockfileData {
8
+ version: 1;
9
+ imports: Record<string, LockfileEntry>;
10
+ }
11
+ export declare function createEmptyLockfile(): LockfileData;
12
+ /** Compute integrity. */
13
+ export declare function computeIntegrity(content: string): Promise<string>;
14
+ export declare function verifyIntegrity(content: string, integrity: string): Promise<boolean>;
15
+ /** Public API contract for lockfile manager. */
16
+ export interface LockfileManager {
17
+ read(): Promise<LockfileData | null>;
18
+ write(data: LockfileData): Promise<void>;
19
+ get(url: string): Promise<LockfileEntry | null>;
20
+ set(url: string, entry: LockfileEntry): Promise<void>;
21
+ has(url: string): Promise<boolean>;
22
+ clear(): Promise<void>;
23
+ flush(): Promise<void>;
24
+ }
25
+ export type FSAdapter = {
26
+ readFile(path: string): Promise<string>;
27
+ writeFile(path: string, content: string): Promise<void>;
28
+ exists(path: string): Promise<boolean>;
29
+ remove?(path: string): Promise<void>;
30
+ };
31
+ /** Create lockfile manager. */
32
+ export declare function createLockfileManager(projectDir: string, fsAdapter?: FSAdapter): LockfileManager;
33
+ export interface FetchWithLockOptions {
34
+ lockfile: LockfileManager;
35
+ url: string;
36
+ fetchFn?: typeof fetch;
37
+ strict?: boolean;
38
+ }
39
+ export interface FetchWithLockResult {
40
+ content: string;
41
+ resolvedUrl: string;
42
+ fromCache: boolean;
43
+ integrity: string;
44
+ }
45
+ export declare function fetchWithLock(options: FetchWithLockOptions): Promise<FetchWithLockResult>;
46
+ export interface ParsedImport {
47
+ specifier: string;
48
+ type: "static" | "dynamic";
49
+ }
50
+ export declare function extractImports(content: string): ParsedImport[];
51
+ export declare function resolveImportUrl(specifier: string, baseUrl: string): string | null;
52
+ //# sourceMappingURL=import-lockfile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-lockfile.d.ts","sourceRoot":"","sources":["../../../src/src/utils/import-lockfile.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACxC;AAKD,wBAAgB,mBAAmB,IAAI,YAAY,CAElD;AAED,yBAAyB;AACzB,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGvE;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG1F;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B,IAAI,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACrC,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAChD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC,CAAC;AAqBF,+BAA+B;AAC/B,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,eAAe,CAkFhG;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,eAAe,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA2D/F;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC5B;AAMD,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,CAmB9D;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUlF"}
@@ -0,0 +1,187 @@
1
+ import { computeHash } from "./hash-utils.js";
2
+ import { serverLogger } from "./logger/index.js";
3
+ import { createFileSystem } from "../platform/compat/fs.js";
4
+ import { CACHE_ERROR, NETWORK_ERROR } from "../errors/error-registry.js";
5
+ const logger = serverLogger.component("lockfile");
6
+ const LOCKFILE_NAME = "veryfront.lock";
7
+ const LOCKFILE_VERSION = 1;
8
+ export function createEmptyLockfile() {
9
+ return { version: LOCKFILE_VERSION, imports: {} };
10
+ }
11
+ /** Compute integrity. */
12
+ export async function computeIntegrity(content) {
13
+ const hash = await computeHash(content);
14
+ return `sha256-${hash}`;
15
+ }
16
+ export async function verifyIntegrity(content, integrity) {
17
+ const computed = await computeIntegrity(content);
18
+ return computed === integrity;
19
+ }
20
+ function createPlatformFSAdapter() {
21
+ const fs = createFileSystem();
22
+ return {
23
+ readFile(path) {
24
+ return fs.readTextFile(path);
25
+ },
26
+ writeFile(path, content) {
27
+ return fs.writeTextFile(path, content);
28
+ },
29
+ exists(path) {
30
+ return fs.exists(path);
31
+ },
32
+ remove(path) {
33
+ return fs.remove(path);
34
+ },
35
+ };
36
+ }
37
+ /** Create lockfile manager. */
38
+ export function createLockfileManager(projectDir, fsAdapter) {
39
+ const fs = fsAdapter ?? createPlatformFSAdapter();
40
+ const lockfilePath = `${projectDir}/${LOCKFILE_NAME}`;
41
+ let cache = null;
42
+ let dirty = false;
43
+ async function read() {
44
+ if (cache)
45
+ return cache;
46
+ try {
47
+ const exists = await fs.exists(lockfilePath);
48
+ if (!exists)
49
+ return null;
50
+ const content = await fs.readFile(lockfilePath);
51
+ const parsed = JSON.parse(content);
52
+ if (parsed.version !== LOCKFILE_VERSION) {
53
+ logger.warn(`[lockfile] Version mismatch, expected ${LOCKFILE_VERSION}, got ${parsed.version}`);
54
+ cache = createEmptyLockfile();
55
+ return cache;
56
+ }
57
+ cache = parsed;
58
+ return cache;
59
+ }
60
+ catch (e) {
61
+ logger.debug(`Could not read lockfile: ${e}`);
62
+ return null;
63
+ }
64
+ }
65
+ async function write(data) {
66
+ cache = data;
67
+ const sorted = {
68
+ version: data.version,
69
+ imports: Object.fromEntries(Object.entries(data.imports).sort(([a], [b]) => a.localeCompare(b))),
70
+ };
71
+ await fs.writeFile(lockfilePath, `${JSON.stringify(sorted, null, 2)}\n`);
72
+ dirty = false;
73
+ logger.debug(`Written ${Object.keys(data.imports).length} entries`);
74
+ }
75
+ async function get(url) {
76
+ const data = await read();
77
+ return data?.imports[url] ?? null;
78
+ }
79
+ async function set(url, entry) {
80
+ const data = (await read()) ?? createEmptyLockfile();
81
+ data.imports[url] = entry;
82
+ cache = data;
83
+ dirty = true;
84
+ }
85
+ async function has(url) {
86
+ const data = await read();
87
+ return url in (data?.imports ?? {});
88
+ }
89
+ async function clear() {
90
+ cache = createEmptyLockfile();
91
+ dirty = false;
92
+ if (!fs.remove)
93
+ return;
94
+ const exists = await fs.exists(lockfilePath);
95
+ if (!exists)
96
+ return;
97
+ await fs.remove(lockfilePath);
98
+ }
99
+ async function flush() {
100
+ if (!dirty || !cache)
101
+ return;
102
+ await write(cache);
103
+ }
104
+ return { read, write, get, set, has, clear, flush };
105
+ }
106
+ const USER_AGENT_HEADERS = { "user-agent": "Mozilla/5.0 Veryfront/1.0" };
107
+ export async function fetchWithLock(options) {
108
+ const { lockfile, url, fetchFn = fetch, strict = false } = options;
109
+ const entry = await lockfile.get(url);
110
+ if (entry) {
111
+ logger.debug(`Cache hit for ${url}`);
112
+ const res = await fetchFn(entry.resolved, { headers: USER_AGENT_HEADERS });
113
+ if (!res.ok) {
114
+ if (strict) {
115
+ throw CACHE_ERROR.create({
116
+ detail: `Lockfile entry stale: ${url} resolved to ${entry.resolved} returned ${res.status}`,
117
+ });
118
+ }
119
+ logger.warn(`Cached URL ${entry.resolved} returned ${res.status}, refetching`);
120
+ }
121
+ else {
122
+ const content = await res.text();
123
+ const currentIntegrity = await computeIntegrity(content);
124
+ if (currentIntegrity === entry.integrity) {
125
+ return {
126
+ content,
127
+ resolvedUrl: entry.resolved,
128
+ fromCache: true,
129
+ integrity: entry.integrity,
130
+ };
131
+ }
132
+ if (strict) {
133
+ throw CACHE_ERROR.create({
134
+ detail: `Integrity mismatch for ${url}: expected ${entry.integrity}, got ${currentIntegrity}`,
135
+ });
136
+ }
137
+ logger.warn(`Integrity mismatch for ${url}, updating lockfile`);
138
+ }
139
+ }
140
+ logger.debug(`Fetching fresh: ${url}`);
141
+ const res = await fetchFn(url, { headers: USER_AGENT_HEADERS, redirect: "follow" });
142
+ if (!res.ok)
143
+ throw NETWORK_ERROR.create({ detail: `Failed to fetch ${url}: ${res.status}` });
144
+ const content = await res.text();
145
+ const resolvedUrl = res.url || url;
146
+ const integrity = await computeIntegrity(content);
147
+ await lockfile.set(url, {
148
+ resolved: resolvedUrl,
149
+ integrity,
150
+ fetchedAt: new Date().toISOString(),
151
+ });
152
+ await lockfile.flush();
153
+ return { content, resolvedUrl, fromCache: false, integrity };
154
+ }
155
+ const IMPORT_REGEX = /import\s+(?:(?:[\w*\s{},]*)\s+from\s+)?['"]([^'"]+)['"]/g;
156
+ const DYNAMIC_IMPORT_REGEX = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
157
+ const EXPORT_FROM_REGEX = /export\s+(?:[\w*\s{},]*)\s+from\s+['"]([^'"]+)['"]/g;
158
+ export function extractImports(content) {
159
+ const imports = [];
160
+ const seen = new Set();
161
+ function addMatches(regex, type) {
162
+ for (const match of content.matchAll(regex)) {
163
+ const specifier = match[1];
164
+ if (!specifier || seen.has(specifier))
165
+ continue;
166
+ seen.add(specifier);
167
+ imports.push({ specifier, type });
168
+ }
169
+ }
170
+ addMatches(IMPORT_REGEX, "static");
171
+ addMatches(EXPORT_FROM_REGEX, "static");
172
+ addMatches(DYNAMIC_IMPORT_REGEX, "dynamic");
173
+ return imports;
174
+ }
175
+ export function resolveImportUrl(specifier, baseUrl) {
176
+ if (specifier.startsWith("http://") || specifier.startsWith("https://"))
177
+ return specifier;
178
+ if (!specifier.startsWith("./") && !specifier.startsWith("../"))
179
+ return null;
180
+ try {
181
+ return new URL(specifier, baseUrl).toString();
182
+ }
183
+ catch (_) {
184
+ /* expected: specifier may not be a valid relative URL */
185
+ return null;
186
+ }
187
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Runtime detection, logging, constants, hashing, and feature flags.
3
+ *
4
+ * @module utils
5
+ *
6
+ * @example Structured logging
7
+ * ```ts
8
+ * import { serverLogger } from "veryfront/utils";
9
+ *
10
+ * serverLogger.info("Booting server", { project_id: "proj_123" });
11
+ * ```
12
+ */
13
+ export { type GlobalWithBun, type GlobalWithDeno, type GlobalWithProcess, hasBunRuntime, hasDenoRuntime, hasNodeProcess, } from "./runtime-guards.js";
14
+ export { __registerLogRecordEmitter, __registerTraceContextGetter, __registerTraceContextGetter as registerTraceContextGetter, agentLogger, bundlerLogger, cliLogger, createRunUserLogger, getBaseLogger, logger, refreshLoggerConfig, rendererLogger, runWithRequestContextAsync, serverLogger, } from "./logger/index.js";
15
+ export type { LogEntry, Logger, RequestContext } from "./logger/index.js";
16
+ export { redactSensitive, sanitizeUrlCredentials, sanitizeUrlForSpan } from "./logger/redact.js";
17
+ export { BREAKPOINT_LG, BREAKPOINT_MD, BREAKPOINT_SM, BREAKPOINT_XL, BYTES_PER_KB, DEFAULT_ALLOWED_CDN_HOSTS, DEFAULT_BUILD_CONCURRENCY, DEFAULT_DASHBOARD_PORT, DEFAULT_LRU_MAX_ENTRIES, DEV_SERVER_ENDPOINTS, FORBIDDEN_PATH_PATTERNS, getDenoStdNodeBase, getReactImportMap, HASH_SEED_DJB2, HASH_SEED_FNV1A, HMR_CLIENT_RELOAD_DELAY_MS, HMR_CLOSE_MESSAGE_TOO_LARGE, HMR_CLOSE_NORMAL, HMR_CLOSE_RATE_LIMIT, HMR_MAX_MESSAGE_SIZE_BYTES, HMR_MAX_MESSAGES_PER_MINUTE, HMR_RATE_LIMIT_WINDOW_MS, HTTP_BAD_REQUEST, HTTP_CONTENT_TYPE_IMAGE_GIF, HTTP_CONTENT_TYPE_IMAGE_ICO, HTTP_CONTENT_TYPE_IMAGE_JPEG, HTTP_CONTENT_TYPE_IMAGE_PNG, HTTP_CONTENT_TYPE_IMAGE_SVG, HTTP_CONTENT_TYPE_IMAGE_WEBP, HTTP_CONTENT_TYPES, HTTP_MODULE_FETCH_TIMEOUT_MS, HTTP_NETWORK_CONNECT_TIMEOUT, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_OK, HTTP_REDIRECT_FOUND, HTTP_SERVER_ERROR, HTTP_STATUS_CLIENT_ERROR_MIN, HTTP_STATUS_REDIRECT_MIN, HTTP_STATUS_SERVER_ERROR_MIN, HTTP_STATUS_SUCCESS_MIN, HTTP_UNAVAILABLE, IMAGE_OPTIMIZATION, MAX_BATCH_SIZE, MAX_PATH_LENGTH, MAX_PATH_TRAVERSAL_DEPTH, MS_PER_SECOND, PREFETCH_DEFAULT_DELAY_MS, PREFETCH_DEFAULT_TIMEOUT_MS, PREFETCH_MAX_SIZE_BYTES, REACT_DEFAULT_VERSION, RESPONSIVE_IMAGE_WIDTH_LG, RESPONSIVE_IMAGE_WIDTHS, RSC_MANIFEST_CACHE_TTL_MS, TSX_LAYOUT_MAX_ENTRIES, TSX_LAYOUT_PER_PROJECT_MAX_ENTRIES, Z_INDEX_DEV_INDICATOR, Z_INDEX_ERROR_OVERLAY, } from "./constants/index.js";
18
+ export { VERSION } from "./version.js";
19
+ export { type BundleCode as HashBundleCode, computeCodeHash, computeHash, computeHashBytes, fnv1aHash, shortHash, simpleHash, } from "./hash-utils.js";
20
+ export { base64urlEncode, base64urlEncodeBytes, encodeBase64 } from "./base64url.js";
21
+ export { sleep } from "./sleep.js";
22
+ export { MemoCache, memoize, memoizeAsync, simpleHash as memoizeHash } from "./memoize.js";
23
+ export { normalizePath } from "./path-utils.js";
24
+ export { type BundleCode, type BundleMetadata, getBundleManifestStore } from "./bundle-manifest.js";
25
+ export { isRSCEnabled } from "./feature-flags.js";
26
+ export { isCompiledBinary } from "./platform.js";
27
+ export { computeIntegrity, createLockfileManager, type LockfileManager, } from "./import-lockfile.js";
28
+ export { endRequest, isEnabled, startRequest, startTimer, timeAsync } from "./perf-timer.js";
29
+ export { parallelMap } from "./parallel.js";
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,4BAA4B,IAAI,0BAA0B,EAC1D,WAAW,EACX,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,mBAAmB,EACnB,cAAc,EACd,0BAA0B,EAC1B,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG1E,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEjG,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,0BAA0B,EAC1B,2BAA2B,EAC3B,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,gBAAgB,EAChB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC5B,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,cAAc,EACd,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACnB,iBAAiB,EACjB,4BAA4B,EAC5B,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,EACvB,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,kCAAkC,EAClC,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EACL,KAAK,UAAU,IAAI,cAAc,EACjC,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAErF,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEpG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,eAAe,GACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Runtime detection, logging, constants, hashing, and feature flags.
3
+ *
4
+ * @module utils
5
+ *
6
+ * @example Structured logging
7
+ * ```ts
8
+ * import { serverLogger } from "veryfront/utils";
9
+ *
10
+ * serverLogger.info("Booting server", { project_id: "proj_123" });
11
+ * ```
12
+ */
13
+ export { hasBunRuntime, hasDenoRuntime, hasNodeProcess, } from "./runtime-guards.js";
14
+ export { __registerLogRecordEmitter, __registerTraceContextGetter, __registerTraceContextGetter as registerTraceContextGetter, agentLogger, bundlerLogger, cliLogger, createRunUserLogger, getBaseLogger, logger, refreshLoggerConfig, rendererLogger, runWithRequestContextAsync, serverLogger, } from "./logger/index.js";
15
+ // Redaction / URL sanitization helpers
16
+ export { redactSensitive, sanitizeUrlCredentials, sanitizeUrlForSpan } from "./logger/redact.js";
17
+ export { BREAKPOINT_LG, BREAKPOINT_MD, BREAKPOINT_SM, BREAKPOINT_XL, BYTES_PER_KB, DEFAULT_ALLOWED_CDN_HOSTS, DEFAULT_BUILD_CONCURRENCY, DEFAULT_DASHBOARD_PORT, DEFAULT_LRU_MAX_ENTRIES, DEV_SERVER_ENDPOINTS, FORBIDDEN_PATH_PATTERNS, getDenoStdNodeBase, getReactImportMap, HASH_SEED_DJB2, HASH_SEED_FNV1A, HMR_CLIENT_RELOAD_DELAY_MS, HMR_CLOSE_MESSAGE_TOO_LARGE, HMR_CLOSE_NORMAL, HMR_CLOSE_RATE_LIMIT, HMR_MAX_MESSAGE_SIZE_BYTES, HMR_MAX_MESSAGES_PER_MINUTE, HMR_RATE_LIMIT_WINDOW_MS, HTTP_BAD_REQUEST, HTTP_CONTENT_TYPE_IMAGE_GIF, HTTP_CONTENT_TYPE_IMAGE_ICO, HTTP_CONTENT_TYPE_IMAGE_JPEG, HTTP_CONTENT_TYPE_IMAGE_PNG, HTTP_CONTENT_TYPE_IMAGE_SVG, HTTP_CONTENT_TYPE_IMAGE_WEBP, HTTP_CONTENT_TYPES, HTTP_MODULE_FETCH_TIMEOUT_MS, HTTP_NETWORK_CONNECT_TIMEOUT, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_OK, HTTP_REDIRECT_FOUND, HTTP_SERVER_ERROR, HTTP_STATUS_CLIENT_ERROR_MIN, HTTP_STATUS_REDIRECT_MIN, HTTP_STATUS_SERVER_ERROR_MIN, HTTP_STATUS_SUCCESS_MIN, HTTP_UNAVAILABLE, IMAGE_OPTIMIZATION, MAX_BATCH_SIZE, MAX_PATH_LENGTH, MAX_PATH_TRAVERSAL_DEPTH, MS_PER_SECOND, PREFETCH_DEFAULT_DELAY_MS, PREFETCH_DEFAULT_TIMEOUT_MS, PREFETCH_MAX_SIZE_BYTES, REACT_DEFAULT_VERSION, RESPONSIVE_IMAGE_WIDTH_LG, RESPONSIVE_IMAGE_WIDTHS, RSC_MANIFEST_CACHE_TTL_MS, TSX_LAYOUT_MAX_ENTRIES, TSX_LAYOUT_PER_PROJECT_MAX_ENTRIES, Z_INDEX_DEV_INDICATOR, Z_INDEX_ERROR_OVERLAY, } from "./constants/index.js";
18
+ export { VERSION } from "./version.js";
19
+ export { computeCodeHash, computeHash, computeHashBytes, fnv1aHash, shortHash, simpleHash, } from "./hash-utils.js";
20
+ export { base64urlEncode, base64urlEncodeBytes, encodeBase64 } from "./base64url.js";
21
+ export { sleep } from "./sleep.js";
22
+ export { MemoCache, memoize, memoizeAsync, simpleHash as memoizeHash } from "./memoize.js";
23
+ export { normalizePath } from "./path-utils.js";
24
+ export { getBundleManifestStore } from "./bundle-manifest.js";
25
+ export { isRSCEnabled } from "./feature-flags.js";
26
+ export { isCompiledBinary } from "./platform.js";
27
+ export { computeIntegrity, createLockfileManager, } from "./import-lockfile.js";
28
+ export { endRequest, isEnabled, startRequest, startTimer, timeAsync } from "./perf-timer.js";
29
+ export { parallelMap } from "./parallel.js";
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Canonical component names for structured logging.
3
+ *
4
+ * These names are used with `logger.component("name")` to create
5
+ * component-scoped loggers. The component field appears in JSON output
6
+ * for Grafana/Loki filtering and as `[name]` in text output.
7
+ *
8
+ * Convention: lowercase-kebab-case.
9
+ * Not enforced at runtime — any string is accepted. This registry is a
10
+ * non-exhaustive reference to promote reuse and discoverability.
11
+ *
12
+ * @module
13
+ */
14
+ export declare const LogComponents: {
15
+ readonly server: "server";
16
+ readonly config: "config";
17
+ readonly middleware: "middleware";
18
+ readonly cors: "cors";
19
+ readonly security: "security";
20
+ readonly discovery: "discovery";
21
+ readonly pipeline: "pipeline";
22
+ readonly global: "global";
23
+ readonly ssr: "ssr";
24
+ readonly ssrService: "ssr-service";
25
+ readonly ssrOrchestrator: "ssr-orchestrator";
26
+ readonly rsc: "rsc";
27
+ readonly html: "html";
28
+ readonly htmlGenerator: "html-generator";
29
+ readonly mdx: "mdx";
30
+ readonly mdxCompiler: "mdx-compiler";
31
+ readonly mdxCache: "mdx-cache";
32
+ readonly hmr: "hmr";
33
+ readonly hmrHandler: "hmr-handler";
34
+ readonly hmrServer: "hmr-server";
35
+ readonly renderer: "renderer";
36
+ readonly snippetRenderer: "snippet-renderer";
37
+ readonly build: "build";
38
+ readonly esm: "esm";
39
+ readonly esmTransform: "esm-transform";
40
+ readonly ssrTransform: "ssr-transform";
41
+ readonly ssrModuleLoader: "ssr-module-loader";
42
+ readonly moduleLoader: "module-loader";
43
+ readonly moduleServer: "module-server";
44
+ readonly cache: "cache";
45
+ readonly cacheRegistry: "cache-registry";
46
+ readonly distributedCache: "distributed-cache";
47
+ readonly httpCache: "http-cache";
48
+ readonly httpCacheWrapper: "http-cache-wrapper";
49
+ readonly ssrHttpCache: "ssr-http-cache";
50
+ readonly fileCache: "file-cache";
51
+ readonly moduleCache: "module-cache";
52
+ readonly transformCache: "transform-cache";
53
+ readonly api: "api";
54
+ readonly httpHandler: "http-handler";
55
+ readonly client: "client";
56
+ readonly runtimeHandler: "runtime-handler";
57
+ readonly redis: "redis";
58
+ readonly fsIntegration: "fs-integration";
59
+ readonly readOperations: "read-operations";
60
+ readonly otel: "otel";
61
+ readonly tracing: "tracing";
62
+ readonly metrics: "metrics";
63
+ readonly autoInstrument: "auto-instrument";
64
+ readonly perf: "perf";
65
+ readonly agent: "agent";
66
+ readonly tool: "tool";
67
+ readonly workflowDiscovery: "workflow-discovery";
68
+ readonly validator: "validator";
69
+ readonly error: "error";
70
+ readonly env: "env";
71
+ };
72
+ export type LogComponent = (typeof LogComponents)[keyof typeof LogComponents];
73
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/components.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4EhB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Canonical component names for structured logging.
3
+ *
4
+ * These names are used with `logger.component("name")` to create
5
+ * component-scoped loggers. The component field appears in JSON output
6
+ * for Grafana/Loki filtering and as `[name]` in text output.
7
+ *
8
+ * Convention: lowercase-kebab-case.
9
+ * Not enforced at runtime — any string is accepted. This registry is a
10
+ * non-exhaustive reference to promote reuse and discoverability.
11
+ *
12
+ * @module
13
+ */
14
+ export const LogComponents = {
15
+ // Server & infrastructure
16
+ server: "server",
17
+ config: "config",
18
+ middleware: "middleware",
19
+ cors: "cors",
20
+ security: "security",
21
+ discovery: "discovery",
22
+ pipeline: "pipeline",
23
+ global: "global",
24
+ // Rendering
25
+ ssr: "ssr",
26
+ ssrService: "ssr-service",
27
+ ssrOrchestrator: "ssr-orchestrator",
28
+ rsc: "rsc",
29
+ html: "html",
30
+ htmlGenerator: "html-generator",
31
+ mdx: "mdx",
32
+ mdxCompiler: "mdx-compiler",
33
+ mdxCache: "mdx-cache",
34
+ hmr: "hmr",
35
+ hmrHandler: "hmr-handler",
36
+ hmrServer: "hmr-server",
37
+ renderer: "renderer",
38
+ snippetRenderer: "snippet-renderer",
39
+ // Build & transforms
40
+ build: "build",
41
+ esm: "esm",
42
+ esmTransform: "esm-transform",
43
+ ssrTransform: "ssr-transform",
44
+ ssrModuleLoader: "ssr-module-loader",
45
+ moduleLoader: "module-loader",
46
+ moduleServer: "module-server",
47
+ // Caching
48
+ cache: "cache",
49
+ cacheRegistry: "cache-registry",
50
+ distributedCache: "distributed-cache",
51
+ httpCache: "http-cache",
52
+ httpCacheWrapper: "http-cache-wrapper",
53
+ ssrHttpCache: "ssr-http-cache",
54
+ fileCache: "file-cache",
55
+ moduleCache: "module-cache",
56
+ transformCache: "transform-cache",
57
+ // API & HTTP
58
+ api: "api",
59
+ httpHandler: "http-handler",
60
+ client: "client",
61
+ runtimeHandler: "runtime-handler",
62
+ // Platform & adapters
63
+ redis: "redis",
64
+ fsIntegration: "fs-integration",
65
+ readOperations: "read-operations",
66
+ // Observability
67
+ otel: "otel",
68
+ tracing: "tracing",
69
+ metrics: "metrics",
70
+ autoInstrument: "auto-instrument",
71
+ perf: "perf",
72
+ // Agent & AI
73
+ agent: "agent",
74
+ tool: "tool",
75
+ // Workflow
76
+ workflowDiscovery: "workflow-discovery",
77
+ // Misc
78
+ validator: "validator",
79
+ error: "error",
80
+ env: "env",
81
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Utils Logger
3
+ *
4
+ * @module utils/logger
5
+ */
6
+ export { __registerLogRecordEmitter, __registerRequestContextGetter, __registerTraceContextGetter, __resetLoggerConfigForTests, __resetLogRecordEmitterForTests, __resetTraceContextGetterForTests, agentLogger, bundlerLogger, cliLogger, createRequestLogger, createRunUserLogger, getBaseLogger, getDefaultLevel, type LogEntry, type LogFormat, type Logger, logger, LogLevel, proxyLogger, refreshLoggerConfig, rendererLogger, serverLogger, } from "./logger.js";
7
+ export { ANSI, colorize, formatContextText, formatErrorText, formatTimestamp, formatValue, isRecord, LEVEL_COLORS, LEVEL_GLYPHS, type LogLevelName, normalizeText, padTag, PREFIX_WIDTH, type SerializedError, serializeError, TAG_WIDTH, truncateText, } from "./core.js";
8
+ export { getRequestContext, getRequestLogger, type RequestContext, requestContextStore, runWithRequestContext, runWithRequestContextAsync, } from "./request-context.js";
9
+ export { type LogComponent, LogComponents } from "./components.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,4BAA4B,EAC5B,2BAA2B,EAC3B,+BAA+B,EAC/B,iCAAiC,EACjC,WAAW,EACX,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,MAAM,EACX,MAAM,EACN,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,KAAK,YAAY,EACjB,aAAa,EACb,MAAM,EACN,YAAY,EACZ,KAAK,eAAe,EACpB,cAAc,EACd,SAAS,EACT,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,cAAc,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Utils Logger
3
+ *
4
+ * @module utils/logger
5
+ */
6
+ export { __registerLogRecordEmitter, __registerRequestContextGetter, __registerTraceContextGetter, __resetLoggerConfigForTests, __resetLogRecordEmitterForTests, __resetTraceContextGetterForTests, agentLogger, bundlerLogger, cliLogger, createRequestLogger, createRunUserLogger, getBaseLogger, getDefaultLevel, logger, LogLevel, proxyLogger, refreshLoggerConfig, rendererLogger, serverLogger, } from "./logger.js";
7
+ export { ANSI, colorize, formatContextText, formatErrorText, formatTimestamp, formatValue, isRecord, LEVEL_COLORS, LEVEL_GLYPHS, normalizeText, padTag, PREFIX_WIDTH, serializeError, TAG_WIDTH, truncateText, } from "./core.js";
8
+ export { getRequestContext, getRequestLogger, requestContextStore, runWithRequestContext, runWithRequestContextAsync, } from "./request-context.js";
9
+ export { LogComponents } from "./components.js";
@@ -0,0 +1,27 @@
1
+ /**************************
2
+ * Request Context Store
3
+ *
4
+ * Uses AsyncLocalStorage to propagate request-scoped logger context
5
+ * throughout the call stack without explicit parameter passing.
6
+ *
7
+ * @module utils/logger/request-context
8
+ **************************/
9
+ import { AsyncLocalStorage } from "node:async_hooks";
10
+ import { type Logger } from "./logger.js";
11
+ /** Context for request. */
12
+ export interface RequestContext {
13
+ logger: Logger;
14
+ requestId: string;
15
+ projectSlug?: string;
16
+ projectId?: string;
17
+ domain?: string;
18
+ userId?: string;
19
+ conversationId?: string;
20
+ }
21
+ export declare const requestContextStore: AsyncLocalStorage<RequestContext>;
22
+ export declare function getRequestContext(): RequestContext | undefined;
23
+ export declare function getRequestLogger(): Logger | undefined;
24
+ export declare function runWithRequestContext<T>(context: RequestContext, fn: () => T): T;
25
+ /** Run with request context async. */
26
+ export declare function runWithRequestContextAsync<T>(context: RequestContext, fn: () => Promise<T>): Promise<T>;
27
+ //# sourceMappingURL=request-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/request-context.ts"],"names":[],"mappings":"AAAA;;;;;;;4BAO4B;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAkC,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1E,2BAA2B;AAC3B,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,mBAAmB,mCAA0C,CAAC;AAE3E,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAE9D;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEhF;AAED,sCAAsC;AACtC,wBAAgB,0BAA0B,CAAC,CAAC,EAC1C,OAAO,EAAE,cAAc,EACvB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
@@ -0,0 +1,28 @@
1
+ /**************************
2
+ * Request Context Store
3
+ *
4
+ * Uses AsyncLocalStorage to propagate request-scoped logger context
5
+ * throughout the call stack without explicit parameter passing.
6
+ *
7
+ * @module utils/logger/request-context
8
+ **************************/
9
+ import { AsyncLocalStorage } from "node:async_hooks";
10
+ import { __registerRequestContextGetter } from "./logger.js";
11
+ export const requestContextStore = new AsyncLocalStorage();
12
+ export function getRequestContext() {
13
+ return requestContextStore.getStore();
14
+ }
15
+ export function getRequestLogger() {
16
+ return getRequestContext()?.logger;
17
+ }
18
+ export function runWithRequestContext(context, fn) {
19
+ return requestContextStore.run(context, fn);
20
+ }
21
+ /** Run with request context async. */
22
+ export function runWithRequestContextAsync(context, fn) {
23
+ return requestContextStore.run(context, fn);
24
+ }
25
+ // Register the context getter with the logger module.
26
+ // This allows context-aware loggers to access request context
27
+ // without creating a circular dependency.
28
+ __registerRequestContextGetter(getRequestContext);
@@ -0,0 +1,19 @@
1
+ /** Implement memo cache. */
2
+ export declare class MemoCache<V> {
3
+ private cache;
4
+ get(key: string): V | undefined;
5
+ set(key: string, value: V): void;
6
+ has(key: string): boolean;
7
+ clear(): void;
8
+ size(): number;
9
+ }
10
+ /** Memoize async. */
11
+ export declare function memoizeAsync<Args extends unknown[], Result>(fn: (...args: Args) => Promise<Result>, keyHasher: (...args: Args) => string): (...args: Args) => Promise<Result>;
12
+ /** Memoize. */
13
+ export declare function memoize<Args extends unknown[], Result>(fn: (...args: Args) => Result, keyHasher: (...args: Args) => string): (...args: Args) => Result;
14
+ /**
15
+ * FNV-1a hash algorithm for fast cache key generation.
16
+ * 10-15x faster than JSON.stringify() and uses 70-80% less memory.
17
+ */
18
+ export declare function simpleHash(...values: unknown[]): string;
19
+ //# sourceMappingURL=memoize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../../src/src/utils/memoize.ts"],"names":[],"mappings":"AAGA,4BAA4B;AAC5B,qBAAa,SAAS,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,CAAwB;IAErC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI/B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIhC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,MAAM;CAGf;AA2CD,qBAAqB;AACrB,wBAAgB,YAAY,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EACzD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,EACtC,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GACnC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAEpC;AAED,eAAe;AACf,wBAAgB,OAAO,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM,EACpD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,EAC7B,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GACnC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,CAE3B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAavD"}
@@ -0,0 +1,72 @@
1
+ import { FNV1A_PRIME_32 } from "./constants/crypto.js";
2
+ import { HASH_SEED_FNV1A } from "./constants/hash.js";
3
+ /** Implement memo cache. */
4
+ export class MemoCache {
5
+ cache = new Map();
6
+ get(key) {
7
+ return this.cache.get(key);
8
+ }
9
+ set(key, value) {
10
+ this.cache.set(key, value);
11
+ }
12
+ has(key) {
13
+ return this.cache.has(key);
14
+ }
15
+ clear() {
16
+ this.cache.clear();
17
+ }
18
+ size() {
19
+ return this.cache.size;
20
+ }
21
+ }
22
+ function memoizeWithCache(fn, keyHasher) {
23
+ const cache = new MemoCache();
24
+ const inflight = new Map();
25
+ return (...args) => {
26
+ const key = keyHasher(...args);
27
+ if (cache.has(key)) {
28
+ return cache.get(key);
29
+ }
30
+ const existing = inflight.get(key);
31
+ if (existing)
32
+ return existing;
33
+ const result = fn(...args);
34
+ if (!(result instanceof Promise)) {
35
+ cache.set(key, result);
36
+ return result;
37
+ }
38
+ const promise = result.then((resolved) => {
39
+ cache.set(key, resolved);
40
+ inflight.delete(key);
41
+ return resolved;
42
+ }, (error) => {
43
+ inflight.delete(key);
44
+ throw error;
45
+ });
46
+ inflight.set(key, promise);
47
+ return promise;
48
+ };
49
+ }
50
+ /** Memoize async. */
51
+ export function memoizeAsync(fn, keyHasher) {
52
+ return memoizeWithCache(fn, keyHasher);
53
+ }
54
+ /** Memoize. */
55
+ export function memoize(fn, keyHasher) {
56
+ return memoizeWithCache(fn, keyHasher);
57
+ }
58
+ /**
59
+ * FNV-1a hash algorithm for fast cache key generation.
60
+ * 10-15x faster than JSON.stringify() and uses 70-80% less memory.
61
+ */
62
+ export function simpleHash(...values) {
63
+ let hash = HASH_SEED_FNV1A;
64
+ for (const value of values) {
65
+ const str = typeof value === "string" ? value : String(value);
66
+ for (let i = 0; i < str.length; i++) {
67
+ hash ^= str.charCodeAt(i);
68
+ hash = Math.imul(hash, FNV1A_PRIME_32);
69
+ }
70
+ }
71
+ return (hash >>> 0).toString(36);
72
+ }