veryfront 0.0.73 → 0.0.74

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 (43) hide show
  1. package/README.md +3 -0
  2. package/dist/ai/components.js +3 -3
  3. package/dist/ai/components.js.map +1 -1
  4. package/dist/ai/dev.js +130 -21
  5. package/dist/ai/dev.js.map +2 -2
  6. package/dist/ai/index.js +895 -418
  7. package/dist/ai/index.js.map +4 -4
  8. package/dist/ai/production.js +135 -38
  9. package/dist/ai/production.js.map +2 -2
  10. package/dist/ai/react.js +8 -7
  11. package/dist/ai/react.js.map +2 -2
  12. package/dist/ai/workflow.js +468 -110
  13. package/dist/ai/workflow.js.map +4 -4
  14. package/dist/components.js +8178 -1164
  15. package/dist/components.js.map +4 -4
  16. package/dist/config.js +377 -39
  17. package/dist/config.js.map +3 -3
  18. package/dist/context.d.ts +44 -0
  19. package/dist/context.js +52 -0
  20. package/dist/context.js.map +7 -0
  21. package/dist/data.js +176 -62
  22. package/dist/data.js.map +3 -3
  23. package/dist/fonts.d.ts +24 -0
  24. package/dist/fonts.js +45 -0
  25. package/dist/fonts.js.map +7 -0
  26. package/dist/head.d.ts +21 -0
  27. package/dist/head.js +34 -0
  28. package/dist/head.js.map +7 -0
  29. package/dist/index.js +8098 -1048
  30. package/dist/index.js.map +4 -4
  31. package/dist/oauth/handlers.js +6 -7
  32. package/dist/oauth/handlers.js.map +1 -1
  33. package/dist/oauth/index.js +6 -7
  34. package/dist/oauth/index.js.map +1 -1
  35. package/dist/oauth/providers.js +0 -3
  36. package/dist/oauth/providers.js.map +1 -1
  37. package/dist/oauth/token-store.js +6 -4
  38. package/dist/oauth/token-store.js.map +1 -1
  39. package/dist/router.d.ts +69 -0
  40. package/dist/router.js +61 -0
  41. package/dist/router.js.map +7 -0
  42. package/package.json +19 -2
  43. package/dist/cli.js +0 -107694
package/dist/data.js CHANGED
@@ -21,8 +21,10 @@ globalThis.Deno = globalThis.Deno || {
21
21
 
22
22
  // src/core/utils/cache/stores/memory/lru-list-manager.ts
23
23
  var LRUListManager = class {
24
- head = null;
25
- tail = null;
24
+ constructor() {
25
+ this.head = null;
26
+ this.tail = null;
27
+ }
26
28
  getHead() {
27
29
  return this.head;
28
30
  }
@@ -71,7 +73,6 @@ var LRUListManager = class {
71
73
 
72
74
  // src/core/utils/cache/eviction/eviction-manager.ts
73
75
  var EvictionManager = class {
74
- onEvict;
75
76
  constructor(options = {}) {
76
77
  this.onEvict = options.onEvict;
77
78
  }
@@ -258,17 +259,11 @@ function defaultSizeEstimator(value) {
258
259
  }
259
260
  }
260
261
  var LRUCacheAdapter = class {
261
- store = /* @__PURE__ */ new Map();
262
- tagIndex = /* @__PURE__ */ new Map();
263
- listManager = new LRUListManager();
264
- evictionManager;
265
- entryManager;
266
- currentSize = 0;
267
- maxEntries;
268
- maxSizeBytes;
269
- defaultTtlMs;
270
- onEvict;
271
262
  constructor(options = {}) {
263
+ this.store = /* @__PURE__ */ new Map();
264
+ this.tagIndex = /* @__PURE__ */ new Map();
265
+ this.listManager = new LRUListManager();
266
+ this.currentSize = 0;
272
267
  this.maxEntries = options.maxEntries || 1e3;
273
268
  this.maxSizeBytes = options.maxSizeBytes || 50 * 1024 * 1024;
274
269
  this.defaultTtlMs = options.ttlMs;
@@ -418,19 +413,69 @@ function getEnvironmentVariable(name) {
418
413
  }
419
414
  return void 0;
420
415
  }
416
+ function isProductionEnvironment() {
417
+ return getEnvironmentVariable("NODE_ENV") === "production";
418
+ }
421
419
 
422
420
  // src/core/utils/logger/logger.ts
423
421
  var cachedLogLevel;
422
+ var cachedLogFormat;
424
423
  function resolveLogLevel(force = false) {
425
424
  if (force || cachedLogLevel === void 0) {
426
425
  cachedLogLevel = getDefaultLevel();
427
426
  }
428
427
  return cachedLogLevel;
429
428
  }
430
- var ConsoleLogger = class {
431
- constructor(prefix, level = resolveLogLevel()) {
429
+ function resolveLogFormat(force = false) {
430
+ if (force || cachedLogFormat === void 0) {
431
+ cachedLogFormat = getDefaultFormat();
432
+ }
433
+ return cachedLogFormat;
434
+ }
435
+ function getDefaultFormat() {
436
+ const envFormat = getEnvironmentVariable("LOG_FORMAT");
437
+ if (envFormat === "json" || envFormat === "text") {
438
+ return envFormat;
439
+ }
440
+ return isProductionEnvironment() ? "json" : "text";
441
+ }
442
+ function serializeError(err) {
443
+ if (err instanceof Error) {
444
+ return {
445
+ name: err.name,
446
+ message: err.message,
447
+ stack: err.stack
448
+ };
449
+ }
450
+ if (err !== void 0 && err !== null) {
451
+ return {
452
+ name: "UnknownError",
453
+ message: String(err)
454
+ };
455
+ }
456
+ return void 0;
457
+ }
458
+ function extractContext(args) {
459
+ let context;
460
+ let error;
461
+ for (const arg of args) {
462
+ if (arg instanceof Error) {
463
+ error = serializeError(arg);
464
+ } else if (typeof arg === "object" && arg !== null && !Array.isArray(arg)) {
465
+ context = { ...context, ...arg };
466
+ }
467
+ }
468
+ return { context, error };
469
+ }
470
+ var ConsoleLogger = class _ConsoleLogger {
471
+ constructor(prefix, level = resolveLogLevel(), format = resolveLogFormat(), boundContext) {
432
472
  this.prefix = prefix;
433
473
  this.level = level;
474
+ this.format = format;
475
+ this.boundContext = {};
476
+ if (boundContext) {
477
+ this.boundContext = boundContext;
478
+ }
434
479
  }
435
480
  setLevel(level) {
436
481
  this.level = level;
@@ -438,36 +483,88 @@ var ConsoleLogger = class {
438
483
  getLevel() {
439
484
  return this.level;
440
485
  }
441
- debug(message, ...args) {
442
- if (this.level <= 0 /* DEBUG */) {
443
- console.debug(`[${this.prefix}] DEBUG: ${message}`, ...args);
486
+ setFormat(format) {
487
+ this.format = format;
488
+ }
489
+ getFormat() {
490
+ return this.format;
491
+ }
492
+ /**
493
+ * Create a child logger with additional bound context.
494
+ */
495
+ child(context) {
496
+ return new _ConsoleLogger(this.prefix, this.level, this.format, {
497
+ ...this.boundContext,
498
+ ...context
499
+ });
500
+ }
501
+ formatJson(level, message, args) {
502
+ const { context, error } = extractContext(args);
503
+ const entry = {
504
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
505
+ level,
506
+ service: this.prefix.toLowerCase(),
507
+ message
508
+ };
509
+ const mergedContext = { ...this.boundContext, ...context };
510
+ if (Object.keys(mergedContext).length > 0) {
511
+ if ("requestId" in mergedContext) {
512
+ entry.requestId = String(mergedContext.requestId);
513
+ delete mergedContext.requestId;
514
+ }
515
+ if ("traceId" in mergedContext) {
516
+ entry.traceId = String(mergedContext.traceId);
517
+ delete mergedContext.traceId;
518
+ }
519
+ if ("projectSlug" in mergedContext) {
520
+ entry.projectSlug = String(mergedContext.projectSlug);
521
+ delete mergedContext.projectSlug;
522
+ }
523
+ if ("durationMs" in mergedContext) {
524
+ entry.durationMs = Number(mergedContext.durationMs);
525
+ delete mergedContext.durationMs;
526
+ }
527
+ if (Object.keys(mergedContext).length > 0) {
528
+ entry.context = mergedContext;
529
+ }
444
530
  }
531
+ if (error) {
532
+ entry.error = error;
533
+ }
534
+ return JSON.stringify(entry);
445
535
  }
446
- info(message, ...args) {
447
- if (this.level <= 1 /* INFO */) {
448
- console.log(`[${this.prefix}] ${message}`, ...args);
536
+ log(level, logLevel, consoleFn, message, args) {
537
+ if (this.level > logLevel)
538
+ return;
539
+ if (this.format === "json") {
540
+ consoleFn(this.formatJson(level, message, args));
541
+ } else {
542
+ const prefix = level === "info" ? "" : ` ${level.toUpperCase()}:`;
543
+ consoleFn(`[${this.prefix}]${prefix} ${message}`, ...args);
449
544
  }
450
545
  }
546
+ debug(message, ...args) {
547
+ this.log("debug", 0 /* DEBUG */, console.debug, message, args);
548
+ }
549
+ info(message, ...args) {
550
+ this.log("info", 1 /* INFO */, console.log, message, args);
551
+ }
451
552
  warn(message, ...args) {
452
- if (this.level <= 2 /* WARN */) {
453
- console.warn(`[${this.prefix}] WARN: ${message}`, ...args);
454
- }
553
+ this.log("warn", 2 /* WARN */, console.warn, message, args);
455
554
  }
456
555
  error(message, ...args) {
457
- if (this.level <= 3 /* ERROR */) {
458
- console.error(`[${this.prefix}] ERROR: ${message}`, ...args);
459
- }
556
+ this.log("error", 3 /* ERROR */, console.error, message, args);
460
557
  }
461
558
  async time(label, fn) {
462
559
  const start = performance.now();
463
560
  try {
464
561
  const result = await fn();
465
- const end = performance.now();
466
- this.debug(`${label} completed in ${(end - start).toFixed(2)}ms`);
562
+ const durationMs = performance.now() - start;
563
+ this.debug(`${label} completed`, { durationMs: Math.round(durationMs) });
467
564
  return result;
468
565
  } catch (error) {
469
- const end = performance.now();
470
- this.error(`${label} failed after ${(end - start).toFixed(2)}ms`, error);
566
+ const durationMs = performance.now() - start;
567
+ this.error(`${label} failed`, { durationMs: Math.round(durationMs) }, error);
471
568
  throw error;
472
569
  }
473
570
  }
@@ -510,6 +607,7 @@ var serverLogger = createLogger("SERVER");
510
607
  var rendererLogger = createLogger("RENDERER");
511
608
  var bundlerLogger = createLogger("BUNDLER");
512
609
  var agentLogger = createLogger("AGENT");
610
+ var proxyLogger = createLogger("PROXY");
513
611
  var logger = createLogger("VERYFRONT");
514
612
 
515
613
  // src/core/utils/constants/cache.ts
@@ -537,7 +635,7 @@ var LRU_DEFAULT_MAX_SIZE_BYTES = 50 * 1024 * 1024;
537
635
  // deno.json
538
636
  var deno_default = {
539
637
  name: "veryfront",
540
- version: "0.0.73",
638
+ version: "0.0.74",
541
639
  nodeModulesDir: "auto",
542
640
  exclude: [
543
641
  "npm/",
@@ -622,12 +720,12 @@ var deno_default = {
622
720
  csstype: "https://esm.sh/csstype@3.2.3",
623
721
  "@types/react": "https://esm.sh/@types/react@18.3.27?deps=csstype@3.2.3",
624
722
  "@types/react-dom": "https://esm.sh/@types/react-dom@18.3.7?deps=csstype@3.2.3",
625
- react: "https://esm.sh/react@18.3.1",
626
- "react-dom": "https://esm.sh/react-dom@18.3.1",
627
- "react-dom/server": "https://esm.sh/react-dom@18.3.1/server",
628
- "react-dom/client": "https://esm.sh/react-dom@18.3.1/client",
629
- "react/jsx-runtime": "https://esm.sh/react@18.3.1/jsx-runtime",
630
- "react/jsx-dev-runtime": "https://esm.sh/react@18.3.1/jsx-dev-runtime",
723
+ react: "npm:react@18.3.1",
724
+ "react-dom": "npm:react-dom@18.3.1",
725
+ "react-dom/server": "npm:react-dom@18.3.1/server.node",
726
+ "react-dom/client": "npm:react-dom@18.3.1/client",
727
+ "react/jsx-runtime": "npm:react@18.3.1/jsx-runtime",
728
+ "react/jsx-dev-runtime": "npm:react@18.3.1/jsx-dev-runtime",
631
729
  "@mdx-js/mdx": "npm:@mdx-js/mdx@3.0.0",
632
730
  "@mdx-js/react": "npm:@mdx-js/react@3.0.0",
633
731
  "unist-util-visit": "npm:unist-util-visit@5.0.0",
@@ -637,27 +735,36 @@ var deno_default = {
637
735
  "remark-frontmatter": "npm:remark-frontmatter@5.0.0",
638
736
  "rehype-highlight": "npm:rehype-highlight@7.0.2",
639
737
  "rehype-slug": "npm:rehype-slug@6.0.0",
640
- esbuild: "https://deno.land/x/esbuild@v0.20.1/wasm.js",
641
- "esbuild/mod.js": "https://deno.land/x/esbuild@v0.20.1/mod.js",
738
+ esbuild: "npm:esbuild@0.20.2",
739
+ "esbuild/mod.js": "npm:esbuild@0.20.2",
642
740
  "es-module-lexer": "npm:es-module-lexer@1.5.0",
643
- zod: "npm:zod@3.23.8",
741
+ zod: "npm:zod@3.25.76",
644
742
  "mime-types": "npm:mime-types@2.1.35",
645
743
  mdast: "npm:@types/mdast@4.0.3",
646
744
  hast: "npm:@types/hast@3.0.3",
647
745
  unist: "npm:@types/unist@3.0.2",
648
746
  unified: "npm:unified@11.0.5",
649
- ai: "https://esm.sh/ai@5.0.76?deps=react@18.3.1,react-dom@18.3.1",
650
- "ai/react": "https://esm.sh/@ai-sdk/react@2.0.1?deps=react@18.3.1,react-dom@18.3.1",
651
- "@ai-sdk/react": "https://esm.sh/@ai-sdk/react@2.0.1?deps=react@18.3.1,react-dom@18.3.1",
747
+ ai: "npm:ai@5.0.76",
748
+ "ai/react": "npm:@ai-sdk/react@2.0.1",
749
+ "@ai-sdk/react": "npm:@ai-sdk/react@2.0.1",
652
750
  "@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@2.0.1",
653
751
  "@ai-sdk/anthropic": "https://esm.sh/@ai-sdk/anthropic@2.0.1",
654
752
  unocss: "https://esm.sh/unocss@0.59.0",
655
753
  "@unocss/core": "https://esm.sh/@unocss/core@0.59.0",
656
754
  "@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0",
755
+ "next-themes": "npm:next-themes@0.3.0",
657
756
  redis: "npm:redis",
658
757
  pg: "npm:pg",
659
758
  "@opentelemetry/api": "npm:@opentelemetry/api@1",
660
- "@opentelemetry/core": "npm:@opentelemetry/core@1"
759
+ "@opentelemetry/core": "npm:@opentelemetry/core@1",
760
+ "@opentelemetry/sdk-trace-base": "npm:@opentelemetry/sdk-trace-base@1",
761
+ "@opentelemetry/exporter-trace-otlp-http": "npm:@opentelemetry/exporter-trace-otlp-http@0.57",
762
+ "@opentelemetry/resources": "npm:@opentelemetry/resources@1",
763
+ "@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@1",
764
+ "@babel/parser": "npm:@babel/parser@7.26.3",
765
+ "@babel/traverse": "npm:@babel/traverse@7.26.3",
766
+ "@babel/generator": "npm:@babel/generator@7.26.3",
767
+ "@babel/types": "npm:@babel/types@7.26.3"
661
768
  },
662
769
  compilerOptions: {
663
770
  jsx: "react-jsx",
@@ -665,7 +772,7 @@ var deno_default = {
665
772
  strict: true,
666
773
  noImplicitAny: true,
667
774
  noUncheckedIndexedAccess: true,
668
- types: [],
775
+ types: ["npm:@types/react@18"],
669
776
  lib: [
670
777
  "deno.window",
671
778
  "dom",
@@ -680,9 +787,9 @@ var deno_default = {
680
787
  build: "deno compile --allow-all --output ../../bin/veryfront src/cli/main.ts",
681
788
  "build:npm": "deno run -A scripts/build-npm.ts",
682
789
  release: "deno run -A scripts/release.ts",
683
- test: "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",
684
- "test:unit": "DENO_JOBS=1 deno test --parallel --allow-all --v8-flags=--max-old-space-size=8192 --ignore=tests --unstable-worker-options --unstable-net",
685
- "test:integration": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",
790
+ test: "VF_DISABLE_LRU_INTERVAL=1 DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",
791
+ "test:unit": "VF_DISABLE_LRU_INTERVAL=1 DENO_JOBS=1 deno test --parallel --allow-all --v8-flags=--max-old-space-size=8192 --ignore=tests,src/ai/workflow/__tests__ --unstable-worker-options --unstable-net",
792
+ "test:integration": "VF_DISABLE_LRU_INTERVAL=1 DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",
686
793
  "test:coverage": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net || exit 1",
687
794
  "test:coverage:unit": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --ignore=tests --unstable-worker-options --unstable-net || exit 1",
688
795
  "test:coverage:integration": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage tests --unstable-worker-options --unstable-net || exit 1",
@@ -763,6 +870,7 @@ function getEnv(key) {
763
870
 
764
871
  // src/core/utils/version.ts
765
872
  var VERSION = getEnv("VERYFRONT_VERSION") || (typeof deno_default.version === "string" ? deno_default.version : "0.0.0");
873
+ var SERVER_START_TIME = Date.now();
766
874
 
767
875
  // src/core/utils/constants/http.ts
768
876
  var KB_IN_BYTES = 1024;
@@ -867,9 +975,11 @@ var VERYFRONT_PATHS = {
867
975
 
868
976
  // src/core/utils/bundle-manifest.ts
869
977
  var InMemoryBundleManifestStore = class {
870
- metadata = /* @__PURE__ */ new Map();
871
- code = /* @__PURE__ */ new Map();
872
- sourceIndex = /* @__PURE__ */ new Map();
978
+ constructor() {
979
+ this.metadata = /* @__PURE__ */ new Map();
980
+ this.code = /* @__PURE__ */ new Map();
981
+ this.sourceIndex = /* @__PURE__ */ new Map();
982
+ }
873
983
  getBundleMetadata(key) {
874
984
  const entry = this.metadata.get(key);
875
985
  if (!entry)
@@ -960,6 +1070,9 @@ var InMemoryBundleManifestStore = class {
960
1070
  };
961
1071
  var manifestStore = new InMemoryBundleManifestStore();
962
1072
 
1073
+ // src/core/utils/perf-timer.ts
1074
+ var enabled = typeof process !== "undefined" ? process.env?.VERYFRONT_PERF === "1" : typeof Deno !== "undefined" ? Deno.env.get("VERYFRONT_PERF") === "1" : false;
1075
+
963
1076
  // src/core/utils/lru-wrapper.ts
964
1077
  var LRUCache = class {
965
1078
  adapter;
@@ -989,6 +1102,9 @@ var LRUCache = class {
989
1102
  this.adapter.cleanupExpired();
990
1103
  }, this.cleanupIntervalMs);
991
1104
  this.cleanupTimer = timer;
1105
+ if (typeof Deno !== "undefined" && "unrefTimer" in Deno) {
1106
+ Deno.unrefTimer(timer);
1107
+ }
992
1108
  }
993
1109
  toStringKey(key) {
994
1110
  if (typeof key === "string") {
@@ -1054,11 +1170,13 @@ function isLruIntervalDisabled() {
1054
1170
  }
1055
1171
  }
1056
1172
  var CacheManager = class {
1057
- cache = new LRUCache({
1058
- maxEntries: DATA_FETCHING_MAX_ENTRIES,
1059
- ttlMs: isLruIntervalDisabled() ? void 0 : DATA_FETCHING_TTL_MS
1060
- });
1061
- cacheKeys = /* @__PURE__ */ new Set();
1173
+ constructor() {
1174
+ this.cache = new LRUCache({
1175
+ maxEntries: DATA_FETCHING_MAX_ENTRIES,
1176
+ ttlMs: isLruIntervalDisabled() ? void 0 : DATA_FETCHING_TTL_MS
1177
+ });
1178
+ this.cacheKeys = /* @__PURE__ */ new Set();
1179
+ }
1062
1180
  get(key) {
1063
1181
  const entry = this.cache.get(key);
1064
1182
  return entry ?? null;
@@ -1138,8 +1256,8 @@ var StaticDataFetcher = class {
1138
1256
  constructor(cacheManager, adapter) {
1139
1257
  this.cacheManager = cacheManager;
1140
1258
  this.adapter = adapter;
1259
+ this.pendingRevalidations = /* @__PURE__ */ new Map();
1141
1260
  }
1142
- pendingRevalidations = /* @__PURE__ */ new Map();
1143
1261
  async fetch(pageModule, context) {
1144
1262
  if (!pageModule.getStaticData) {
1145
1263
  return { props: {} };
@@ -1228,10 +1346,6 @@ var StaticPathsFetcher = class {
1228
1346
 
1229
1347
  // src/data/data-fetcher.ts
1230
1348
  var DataFetcher = class {
1231
- cacheManager;
1232
- serverFetcher;
1233
- staticFetcher;
1234
- pathsFetcher;
1235
1349
  constructor(adapter) {
1236
1350
  this.cacheManager = new CacheManager();
1237
1351
  this.serverFetcher = new ServerDataFetcher(adapter);