veryfront 0.0.30 → 0.0.32

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/dist/index.js CHANGED
@@ -236,7 +236,6 @@ var init_build = __esm({
236
236
  var SECONDS_PER_MINUTE, MINUTES_PER_HOUR, HOURS_PER_DAY, MS_PER_SECOND, DEFAULT_LRU_MAX_ENTRIES, COMPONENT_LOADER_MAX_ENTRIES, COMPONENT_LOADER_TTL_MS, MDX_RENDERER_MAX_ENTRIES, MDX_RENDERER_TTL_MS, RENDERER_CORE_MAX_ENTRIES, RENDERER_CORE_TTL_MS, TSX_LAYOUT_MAX_ENTRIES, TSX_LAYOUT_TTL_MS, DATA_FETCHING_MAX_ENTRIES, DATA_FETCHING_TTL_MS, MDX_CACHE_TTL_PRODUCTION_MS, MDX_CACHE_TTL_DEVELOPMENT_MS, BUNDLE_CACHE_TTL_PRODUCTION_MS, BUNDLE_CACHE_TTL_DEVELOPMENT_MS, BUNDLE_MANIFEST_PROD_TTL_MS, BUNDLE_MANIFEST_DEV_TTL_MS, RSC_MANIFEST_CACHE_TTL_MS, SERVER_ACTION_DEFAULT_TTL_SEC, DENO_KV_SAFE_SIZE_LIMIT_BYTES, HTTP_CACHE_SHORT_MAX_AGE_SEC, HTTP_CACHE_MEDIUM_MAX_AGE_SEC, HTTP_CACHE_LONG_MAX_AGE_SEC, ONE_DAY_MS, CACHE_CLEANUP_INTERVAL_MS, LRU_DEFAULT_MAX_ENTRIES, LRU_DEFAULT_MAX_SIZE_BYTES, CLEANUP_INTERVAL_MULTIPLIER;
237
237
  var init_cache = __esm({
238
238
  "src/core/utils/constants/cache.ts"() {
239
- "use strict";
240
239
  SECONDS_PER_MINUTE = 60;
241
240
  MINUTES_PER_HOUR = 60;
242
241
  HOURS_PER_DAY = 24;
@@ -523,8 +522,15 @@ var init_deno = __esm({
523
522
  "deno.json"() {
524
523
  deno_default = {
525
524
  name: "veryfront",
526
- version: "0.0.30",
527
- nodeModulesDir: "auto",
525
+ version: "0.0.32",
526
+ exclude: [
527
+ "npm/",
528
+ "dist/",
529
+ "coverage/",
530
+ "scripts/",
531
+ "examples/",
532
+ "tests/"
533
+ ],
528
534
  exports: {
529
535
  ".": "./src/index.ts",
530
536
  "./cli": "./src/cli/main.ts",
@@ -618,11 +624,13 @@ var init_deno = __esm({
618
624
  unified: "https://esm.sh/unified@11.0.5?dts",
619
625
  ai: "https://esm.sh/ai@5.0.76?deps=react@18.3.1,react-dom@18.3.1",
620
626
  "ai/react": "https://esm.sh/@ai-sdk/react@2.0.59?deps=react@18.3.1,react-dom@18.3.1",
627
+ "@ai-sdk/react": "https://esm.sh/@ai-sdk/react@2.0.59?deps=react@18.3.1,react-dom@18.3.1",
621
628
  "@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@2.0.1",
622
629
  "@ai-sdk/anthropic": "https://esm.sh/@ai-sdk/anthropic@2.0.4",
623
630
  unocss: "https://esm.sh/unocss@0.59.0",
624
631
  "@unocss/core": "https://esm.sh/@unocss/core@0.59.0",
625
- "@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0"
632
+ "@unocss/preset-wind": "https://esm.sh/@unocss/preset-wind@0.59.0",
633
+ redis: "npm:redis"
626
634
  },
627
635
  compilerOptions: {
628
636
  jsx: "react-jsx",
@@ -648,8 +656,6 @@ var init_deno = __esm({
648
656
  test: "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",
649
657
  "test:unit": "DENO_JOBS=1 deno test --parallel --allow-all --v8-flags=--max-old-space-size=8192 --ignore=tests --unstable-worker-options --unstable-net",
650
658
  "test:integration": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",
651
- "test:batches": "deno run --allow-all scripts/test-batches.ts",
652
- "test:unsafe": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net",
653
659
  "test:coverage": "rm -rf coverage && DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --coverage=coverage --unstable-worker-options --unstable-net || exit 1",
654
660
  "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",
655
661
  "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",
@@ -663,6 +669,7 @@ var init_deno = __esm({
663
669
  "lint:ban-deep-imports": "deno run --allow-read scripts/ban-deep-imports.ts",
664
670
  "lint:ban-internal-root-imports": "deno run --allow-read scripts/ban-internal-root-imports.ts",
665
671
  "lint:check-awaits": "deno run --allow-read scripts/check-unawaited-promises.ts",
672
+ "lint:platform": "deno run --allow-read scripts/lint-platform-agnostic.ts",
666
673
  "check:circular": "deno run -A jsr:@cunarist/deno-circular-deps src/index.ts"
667
674
  },
668
675
  lint: {
@@ -723,17 +730,61 @@ var init_runtime = __esm({
723
730
  });
724
731
 
725
732
  // src/platform/compat/process.ts
726
- import process2 from "node:process";
733
+ function cwd() {
734
+ if (isDeno) {
735
+ return process.cwd();
736
+ }
737
+ if (hasNodeProcess2) {
738
+ return nodeProcess.cwd();
739
+ }
740
+ throw new Error("cwd() is not supported in this runtime");
741
+ }
727
742
  function getEnv(key) {
728
743
  if (isDeno) {
729
- return process2.env(key);
744
+ return process.env(key);
745
+ }
746
+ if (hasNodeProcess2) {
747
+ return nodeProcess.env[key];
748
+ }
749
+ return void 0;
750
+ }
751
+ function memoryUsage() {
752
+ if (isDeno) {
753
+ const usage2 = Deno.memoryUsage();
754
+ return {
755
+ rss: usage2.rss,
756
+ heapTotal: usage2.heapTotal,
757
+ heapUsed: usage2.heapUsed,
758
+ external: usage2.external
759
+ };
760
+ }
761
+ if (!hasNodeProcess2) {
762
+ throw new Error("memoryUsage() is not supported in this runtime");
763
+ }
764
+ const usage = nodeProcess.memoryUsage();
765
+ return {
766
+ rss: usage.rss,
767
+ heapTotal: usage.heapTotal,
768
+ heapUsed: usage.heapUsed,
769
+ external: usage.external || 0
770
+ };
771
+ }
772
+ function execPath() {
773
+ if (isDeno) {
774
+ return Deno.execPath();
775
+ }
776
+ if (hasNodeProcess2) {
777
+ return nodeProcess.execPath;
730
778
  }
731
- return process2.env[key];
779
+ return "";
732
780
  }
781
+ var nodeProcess, hasNodeProcess2;
733
782
  var init_process = __esm({
734
783
  "src/platform/compat/process.ts"() {
735
784
  "use strict";
736
785
  init_runtime();
786
+ nodeProcess = globalThis.process;
787
+ hasNodeProcess2 = !!nodeProcess?.versions?.node;
737
788
  }
738
789
  });
739
790
 
@@ -1271,13 +1322,11 @@ var init_feature_flags = __esm({
1271
1322
 
1272
1323
  // src/core/utils/platform.ts
1273
1324
  function isCompiledBinary() {
1274
- const hasDeno = typeof Deno !== "undefined";
1275
- const hasExecPath = hasDeno && typeof Deno.execPath === "function";
1276
- if (!hasExecPath)
1325
+ if (!isDeno)
1277
1326
  return false;
1278
1327
  try {
1279
- const execPath = Deno.execPath();
1280
- return execPath.includes("veryfront");
1328
+ const path = execPath();
1329
+ return path.includes("veryfront");
1281
1330
  } catch {
1282
1331
  return false;
1283
1332
  }
@@ -1285,6 +1334,8 @@ function isCompiledBinary() {
1285
1334
  var init_platform = __esm({
1286
1335
  "src/core/utils/platform.ts"() {
1287
1336
  "use strict";
1337
+ init_runtime();
1338
+ init_process();
1288
1339
  }
1289
1340
  });
1290
1341
 
@@ -1674,7 +1725,7 @@ var init_schema = __esm({
1674
1725
  });
1675
1726
 
1676
1727
  // src/core/config/loader.ts
1677
- import { join } from "path";
1728
+ import { join } from "node:path";
1678
1729
  function getDefaultImportMapForConfig() {
1679
1730
  return { imports: getReactImportMap(REACT_DEFAULT_VERSION) };
1680
1731
  }
@@ -2267,20 +2318,20 @@ var init_filesystem_adapter = __esm({
2267
2318
  });
2268
2319
 
2269
2320
  // src/platform/adapters/node/environment-adapter.ts
2270
- import process3 from "node:process";
2321
+ import process2 from "node:process";
2271
2322
  var NodeEnvironmentAdapter;
2272
2323
  var init_environment_adapter = __esm({
2273
2324
  "src/platform/adapters/node/environment-adapter.ts"() {
2274
2325
  "use strict";
2275
2326
  NodeEnvironmentAdapter = class {
2276
2327
  get(key) {
2277
- return process3.env[key];
2328
+ return process2.env[key];
2278
2329
  }
2279
2330
  set(key, value) {
2280
- process3.env[key] = value;
2331
+ process2.env[key] = value;
2281
2332
  }
2282
2333
  toObject() {
2283
- return { ...process3.env };
2334
+ return { ...process2.env };
2284
2335
  }
2285
2336
  };
2286
2337
  }
@@ -8075,7 +8126,9 @@ var init_registry = __esm({
8075
8126
  "Cloudflare Workers detected but requires manual initialization. Use: await runtime.set(createCloudflareAdapter(env))"
8076
8127
  );
8077
8128
  }
8078
- return "node";
8129
+ throw new Error(
8130
+ "Unsupported runtime detected. Supported runtimes: deno, node, bun. For Cloudflare Workers, call runtime.set(createCloudflareAdapter(env))."
8131
+ );
8079
8132
  }
8080
8133
  /**
8081
8134
  * Initialize the adapter
@@ -8102,7 +8155,6 @@ __export(detect_exports, {
8102
8155
  nodeAdapter: () => nodeAdapter,
8103
8156
  runtime: () => runtime
8104
8157
  });
8105
- import process4 from "node:process";
8106
8158
  function isDeno2(global) {
8107
8159
  return "Deno" in global && typeof global.Deno === "object";
8108
8160
  }
@@ -8119,7 +8171,8 @@ function detectRuntime() {
8119
8171
  if (isBun2(globalThis)) {
8120
8172
  return "bun";
8121
8173
  }
8122
- if (process4?.versions?.node) {
8174
+ const globalProcess = globalThis.process;
8175
+ if (globalProcess?.versions?.node) {
8123
8176
  return "node";
8124
8177
  }
8125
8178
  if (isCloudflare2(globalThis)) {
@@ -8650,7 +8703,7 @@ function getCacheNamespace() {
8650
8703
  // src/module-system/import-map/loader.ts
8651
8704
  init_utils();
8652
8705
  init_config();
8653
- import { dirname, join as join2 } from "path";
8706
+ import { dirname, join as join2 } from "node:path";
8654
8707
 
8655
8708
  // src/module-system/import-map/default-import-map.ts
8656
8709
  init_utils();
@@ -8721,9 +8774,9 @@ function transformImportsWithMap(code, importMap, scope, options) {
8721
8774
  }
8722
8775
 
8723
8776
  // src/build/transforms/mdx/esm-module-loader.ts
8724
- import { join as join4 } from "path";
8725
- var _global = globalThis;
8726
- var IS_NODE = typeof Deno === "undefined" && typeof _global.process !== "undefined" && _global.process?.versions?.node;
8777
+ init_runtime();
8778
+ init_process();
8779
+ import { join as join4 } from "node:path";
8727
8780
  var LOG_PREFIX_MDX_LOADER = "[mdx-loader]";
8728
8781
  var LOG_PREFIX_MDX_RENDERER = "[mdx-renderer]";
8729
8782
  var JSX_IMPORT_PATTERN = /import\s+([^'"]+)\s+from\s+['"]file:\/\/([^'"]+\.(jsx|tsx))['"];?/g;
@@ -8806,9 +8859,9 @@ async function loadModuleESM(compiledProgramCode, context) {
8806
8859
  const { getAdapter: getAdapter2 } = await Promise.resolve().then(() => (init_detect(), detect_exports));
8807
8860
  const adapter = await getAdapter2();
8808
8861
  if (!context.esmCacheDir) {
8809
- if (IS_NODE) {
8862
+ if (isNode) {
8810
8863
  const projectCacheDir = join4(
8811
- _global.process.cwd(),
8864
+ cwd(),
8812
8865
  "node_modules",
8813
8866
  ".cache",
8814
8867
  "veryfront-mdx"
@@ -8820,7 +8873,7 @@ async function loadModuleESM(compiledProgramCode, context) {
8820
8873
  }
8821
8874
  }
8822
8875
  let rewritten;
8823
- if (IS_NODE) {
8876
+ if (isNode) {
8824
8877
  rewritten = compiledProgramCode;
8825
8878
  } else {
8826
8879
  rewritten = transformImportsWithMap(
@@ -8875,7 +8928,7 @@ ${transformed}`;
8875
8928
  if (/\bconst\s+MDXLayout\b/.test(rewritten) && !/export\s+\{[^}]*MDXLayout/.test(rewritten)) {
8876
8929
  rewritten += "\nexport { MDXLayout as __vfLayout };\n";
8877
8930
  }
8878
- if (IS_NODE && HTTP_IMPORT_PATTERN.test(rewritten)) {
8931
+ if (isNode && HTTP_IMPORT_PATTERN.test(rewritten)) {
8879
8932
  rendererLogger.info(`${LOG_PREFIX_MDX_LOADER} Bundling HTTP imports via esbuild for Node.js`);
8880
8933
  const { build: build2 } = await import("esbuild/mod.js");
8881
8934
  const tempSourcePath = join4(context.esmCacheDir, `temp-${hashString(rewritten)}.mjs`);
@@ -9417,6 +9470,7 @@ import { jsx as jsx9 } from "react/jsx-runtime";
9417
9470
 
9418
9471
  // src/data/data-fetching-cache.ts
9419
9472
  init_cache();
9473
+ init_process();
9420
9474
 
9421
9475
  // src/data/server-data-fetcher.ts
9422
9476
  init_utils();
@@ -9447,7 +9501,7 @@ var pathMod = null;
9447
9501
  if (typeof Deno === "undefined") {
9448
9502
  pathMod = nodePath;
9449
9503
  } else {
9450
- import("path").then((mod) => {
9504
+ import("node:path").then((mod) => {
9451
9505
  pathMod = mod;
9452
9506
  });
9453
9507
  }
@@ -9474,7 +9528,7 @@ init_utils();
9474
9528
  // src/routing/api/handler.ts
9475
9529
  init_utils();
9476
9530
  init_config();
9477
- import { join as join7 } from "path";
9531
+ import { join as join7 } from "node:path";
9478
9532
  init_veryfront_error();
9479
9533
 
9480
9534
  // src/http/responses.ts
@@ -9610,6 +9664,7 @@ init_logger();
9610
9664
  init_utils();
9611
9665
 
9612
9666
  // src/observability/tracing/config.ts
9667
+ init_process();
9613
9668
  var DEFAULT_CONFIG2 = {
9614
9669
  enabled: false,
9615
9670
  exporter: "console",
@@ -9645,13 +9700,10 @@ function applyEnvFromAdapter(config, envAdapter) {
9645
9700
  }
9646
9701
  function applyEnvFromDeno(config) {
9647
9702
  try {
9648
- const denoEnv = globalThis.Deno?.env;
9649
- if (!denoEnv)
9650
- return;
9651
- config.enabled = denoEnv.get("OTEL_TRACES_ENABLED") === "true" || denoEnv.get("VERYFRONT_OTEL") === "1" || config.enabled;
9652
- config.serviceName = denoEnv.get("OTEL_SERVICE_NAME") || config.serviceName;
9653
- config.endpoint = denoEnv.get("OTEL_EXPORTER_OTLP_ENDPOINT") || denoEnv.get("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") || config.endpoint;
9654
- const exporterType = denoEnv.get("OTEL_TRACES_EXPORTER");
9703
+ config.enabled = getEnv("OTEL_TRACES_ENABLED") === "true" || getEnv("VERYFRONT_OTEL") === "1" || config.enabled;
9704
+ config.serviceName = getEnv("OTEL_SERVICE_NAME") || config.serviceName;
9705
+ config.endpoint = getEnv("OTEL_EXPORTER_OTLP_ENDPOINT") || getEnv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") || config.endpoint;
9706
+ const exporterType = getEnv("OTEL_TRACES_EXPORTER");
9655
9707
  if (isValidExporter(exporterType)) {
9656
9708
  config.exporter = exporterType;
9657
9709
  }
@@ -9894,6 +9946,8 @@ var tracingManager = new TracingManager();
9894
9946
  init_utils();
9895
9947
 
9896
9948
  // src/observability/metrics/config.ts
9949
+ init_process();
9950
+ init_process();
9897
9951
  var DEFAULT_METRICS_COLLECT_INTERVAL_MS2 = 6e4;
9898
9952
  var DEFAULT_CONFIG3 = {
9899
9953
  enabled: false,
@@ -9920,14 +9974,11 @@ function loadConfig2(config, adapter) {
9920
9974
  }
9921
9975
  } else {
9922
9976
  try {
9923
- const env = process.env;
9924
- if (env) {
9925
- finalConfig.enabled = env.OTEL_METRICS_ENABLED === "true" || env.VERYFRONT_OTEL === "1" || finalConfig.enabled;
9926
- finalConfig.endpoint = env.OTEL_EXPORTER_OTLP_ENDPOINT || env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT || finalConfig.endpoint;
9927
- const exporterType = env.OTEL_METRICS_EXPORTER;
9928
- if (exporterType === "prometheus" || exporterType === "otlp" || exporterType === "console") {
9929
- finalConfig.exporter = exporterType;
9930
- }
9977
+ finalConfig.enabled = getEnv("OTEL_METRICS_ENABLED") === "true" || getEnv("VERYFRONT_OTEL") === "1" || finalConfig.enabled;
9978
+ finalConfig.endpoint = getEnv("OTEL_EXPORTER_OTLP_ENDPOINT") || getEnv("OTEL_EXPORTER_OTLP_METRICS_ENDPOINT") || finalConfig.endpoint;
9979
+ const exporterType = getEnv("OTEL_METRICS_EXPORTER");
9980
+ if (exporterType === "prometheus" || exporterType === "otlp" || exporterType === "console") {
9981
+ finalConfig.exporter = exporterType;
9931
9982
  }
9932
9983
  } catch {
9933
9984
  }
@@ -9936,10 +9987,7 @@ function loadConfig2(config, adapter) {
9936
9987
  }
9937
9988
  function getMemoryUsage() {
9938
9989
  try {
9939
- if (process?.memoryUsage) {
9940
- return process.memoryUsage();
9941
- }
9942
- return null;
9990
+ return memoryUsage();
9943
9991
  } catch {
9944
9992
  return null;
9945
9993
  }
@@ -10112,9 +10160,9 @@ function createMemoryInstruments(meter, config) {
10112
10160
  }
10113
10161
  );
10114
10162
  memoryUsageGauge.addCallback((result) => {
10115
- const memoryUsage = getMemoryUsage();
10116
- if (memoryUsage) {
10117
- result.observe(memoryUsage.rss);
10163
+ const memoryUsage2 = getMemoryUsage();
10164
+ if (memoryUsage2) {
10165
+ result.observe(memoryUsage2.rss);
10118
10166
  }
10119
10167
  });
10120
10168
  const heapUsageGauge = meter.createObservableGauge(
@@ -10125,9 +10173,9 @@ function createMemoryInstruments(meter, config) {
10125
10173
  }
10126
10174
  );
10127
10175
  heapUsageGauge.addCallback((result) => {
10128
- const memoryUsage = getMemoryUsage();
10129
- if (memoryUsage) {
10130
- result.observe(memoryUsage.heapUsed);
10176
+ const memoryUsage2 = getMemoryUsage();
10177
+ if (memoryUsage2) {
10178
+ result.observe(memoryUsage2.heapUsed);
10131
10179
  }
10132
10180
  });
10133
10181
  return {
@@ -10770,6 +10818,7 @@ function applyCORSHeadersSync(options) {
10770
10818
 
10771
10819
  // src/security/http/cors/constants.ts
10772
10820
  init_config();
10821
+ init_process();
10773
10822
 
10774
10823
  // src/security/http/cors/preflight.ts
10775
10824
  init_logger();
@@ -11560,12 +11609,15 @@ init_veryfront_error();
11560
11609
  init_veryfront_error();
11561
11610
  init_runtime();
11562
11611
 
11612
+ // src/routing/api/module-loader/loader.ts
11613
+ init_runtime();
11614
+
11563
11615
  // src/routing/api/route-discovery.ts
11564
- import { relative } from "path";
11616
+ import { relative } from "node:path";
11565
11617
 
11566
11618
  // src/core/utils/file-discovery.ts
11567
11619
  init_deno2();
11568
- import { join as join6 } from "path";
11620
+ import { join as join6 } from "node:path";
11569
11621
 
11570
11622
  // src/routing/api/route-executor.ts
11571
11623
  init_veryfront_error();