veryfront 0.0.5 → 0.0.6

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
@@ -65,8 +65,7 @@ function getEnvironmentVariable(name) {
65
65
  const value = globalThis.process?.env[name];
66
66
  return value === "" ? void 0 : value;
67
67
  }
68
- } catch (error2) {
69
- console.debug(`Failed to get environment variable ${name}:`, error2);
68
+ } catch {
70
69
  return void 0;
71
70
  }
72
71
  return void 0;
@@ -184,10 +183,10 @@ var init_logger = __esm({
184
183
  const end = performance.now();
185
184
  this.debug(`${label} completed in ${(end - start).toFixed(2)}ms`);
186
185
  return result;
187
- } catch (_error) {
186
+ } catch (error2) {
188
187
  const end = performance.now();
189
- this.error(`${label} failed after ${(end - start).toFixed(2)}ms`, _error);
190
- throw _error;
188
+ this.error(`${label} failed after ${(end - start).toFixed(2)}ms`, error2);
189
+ throw error2;
191
190
  }
192
191
  }
193
192
  };
@@ -243,19 +242,19 @@ var init_cache = __esm({
243
242
  MS_PER_SECOND = 1e3;
244
243
  DEFAULT_LRU_MAX_ENTRIES = 100;
245
244
  COMPONENT_LOADER_MAX_ENTRIES = 100;
246
- COMPONENT_LOADER_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;
245
+ COMPONENT_LOADER_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;
247
246
  MDX_RENDERER_MAX_ENTRIES = 200;
248
- MDX_RENDERER_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;
247
+ MDX_RENDERER_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;
249
248
  RENDERER_CORE_MAX_ENTRIES = 100;
250
- RENDERER_CORE_TTL_MS = 5 * MINUTES_PER_HOUR * MS_PER_SECOND;
249
+ RENDERER_CORE_TTL_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;
251
250
  TSX_LAYOUT_MAX_ENTRIES = 50;
252
- TSX_LAYOUT_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;
251
+ TSX_LAYOUT_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;
253
252
  DATA_FETCHING_MAX_ENTRIES = 200;
254
- DATA_FETCHING_TTL_MS = 10 * MINUTES_PER_HOUR * MS_PER_SECOND;
253
+ DATA_FETCHING_TTL_MS = 10 * SECONDS_PER_MINUTE * MS_PER_SECOND;
255
254
  MDX_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
256
- MDX_CACHE_TTL_DEVELOPMENT_MS = 5 * MINUTES_PER_HOUR * MS_PER_SECOND;
255
+ MDX_CACHE_TTL_DEVELOPMENT_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;
257
256
  BUNDLE_CACHE_TTL_PRODUCTION_MS = HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
258
- BUNDLE_CACHE_TTL_DEVELOPMENT_MS = 5 * MINUTES_PER_HOUR * MS_PER_SECOND;
257
+ BUNDLE_CACHE_TTL_DEVELOPMENT_MS = 5 * SECONDS_PER_MINUTE * MS_PER_SECOND;
259
258
  BUNDLE_MANIFEST_PROD_TTL_MS = 7 * HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
260
259
  BUNDLE_MANIFEST_DEV_TTL_MS = MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
261
260
  RSC_MANIFEST_CACHE_TTL_MS = 5e3;
@@ -310,6 +309,7 @@ function getUnoCSSTailwindResetUrl() {
310
309
  var ESM_CDN_BASE, JSDELIVR_CDN_BASE, DENO_STD_BASE, REACT_VERSION_17, REACT_VERSION_18_2, REACT_VERSION_18_3, REACT_VERSION_19_RC, REACT_VERSION_19, REACT_DEFAULT_VERSION, DEFAULT_ALLOWED_CDN_HOSTS, DENO_STD_VERSION, UNOCSS_VERSION;
311
310
  var init_cdn = __esm({
312
311
  "src/core/utils/constants/cdn.ts"() {
312
+ "use strict";
313
313
  ESM_CDN_BASE = "https://esm.sh";
314
314
  JSDELIVR_CDN_BASE = "https://cdn.jsdelivr.net";
315
315
  DENO_STD_BASE = "https://deno.land";
@@ -522,7 +522,7 @@ var init_deno = __esm({
522
522
  "deno.json"() {
523
523
  deno_default = {
524
524
  name: "veryfront",
525
- version: "0.1.0",
525
+ version: "0.0.6",
526
526
  nodeModulesDir: "auto",
527
527
  workspace: [
528
528
  "./examples/async-worker-redis",
@@ -911,6 +911,7 @@ function fromBase64Url(encoded) {
911
911
  }
912
912
  var init_path_utils = __esm({
913
913
  "src/core/utils/path-utils.ts"() {
914
+ "use strict";
914
915
  init_logger();
915
916
  }
916
917
  });
@@ -5864,11 +5865,15 @@ async function createNodeServer(handler, options = {}) {
5864
5865
  headersRecord[key] = value[0] || "";
5865
5866
  }
5866
5867
  }
5867
- const request = new Request(url.toString(), {
5868
+ const requestInit = {
5868
5869
  method: _req.method,
5869
5870
  headers: headersRecord,
5870
5871
  body
5871
- });
5872
+ };
5873
+ if (body !== null) {
5874
+ requestInit.duplex = "half";
5875
+ }
5876
+ const request = new Request(url.toString(), requestInit);
5872
5877
  const response = await handler(request);
5873
5878
  if (response.status === 101) {
5874
5879
  return;
@@ -7233,7 +7238,6 @@ var init_deno3 = __esm({
7233
7238
  "use strict";
7234
7239
  init_ansi();
7235
7240
  colors = {
7236
- // Basic colors
7237
7241
  red,
7238
7242
  green,
7239
7243
  yellow,
@@ -7242,13 +7246,11 @@ var init_deno3 = __esm({
7242
7246
  magenta,
7243
7247
  white,
7244
7248
  gray,
7245
- // Text modifiers
7246
7249
  bold,
7247
7250
  dim,
7248
7251
  italic,
7249
7252
  underline,
7250
7253
  strikethrough,
7251
- // Utility
7252
7254
  reset
7253
7255
  };
7254
7256
  }
@@ -7279,7 +7281,6 @@ var init_node3 = __esm({
7279
7281
  "src/platform/compat/console/node.ts"() {
7280
7282
  "use strict";
7281
7283
  colors2 = {
7282
- // Basic colors
7283
7284
  red: pc.red,
7284
7285
  green: pc.green,
7285
7286
  yellow: pc.yellow,
@@ -7288,13 +7289,11 @@ var init_node3 = __esm({
7288
7289
  magenta: pc.magenta,
7289
7290
  white: pc.white,
7290
7291
  gray: pc.gray,
7291
- // Text modifiers
7292
7292
  bold: pc.bold,
7293
7293
  dim: pc.dim,
7294
7294
  italic: pc.italic,
7295
7295
  underline: pc.underline,
7296
7296
  strikethrough: pc.strikethrough,
7297
- // Utility - picocolors doesn't have reset, so we implement it
7298
7297
  reset: (text2) => pc.reset(text2)
7299
7298
  };
7300
7299
  red2 = pc.red;
@@ -7376,10 +7375,9 @@ var init_error_formatter = __esm({
7376
7375
 
7377
7376
  // src/platform/compat/process.ts
7378
7377
  import process3 from "node:process";
7379
- var IS_DENO;
7380
7378
  var init_process = __esm({
7381
7379
  "src/platform/compat/process.ts"() {
7382
- IS_DENO = typeof Deno !== "undefined" && "Deno" in globalThis;
7380
+ init_runtime();
7383
7381
  }
7384
7382
  });
7385
7383
 
@@ -7799,9 +7797,7 @@ function createMockAdapter() {
7799
7797
  },
7800
7798
  fs: {
7801
7799
  files,
7802
- // Expose files Map for tests to populate
7803
7800
  directories,
7804
- // Expose directories Set for tests to track empty dirs
7805
7801
  readFile: (path) => {
7806
7802
  const content = files.get(path);
7807
7803
  if (!content) {
@@ -7825,12 +7821,7 @@ function createMockAdapter() {
7825
7821
  if (filePath.startsWith(path + "/"))
7826
7822
  return true;
7827
7823
  }
7828
- try {
7829
- await Deno.stat(path);
7830
- return true;
7831
- } catch {
7832
- return false;
7833
- }
7824
+ return false;
7834
7825
  },
7835
7826
  readDir: async function* (path) {
7836
7827
  const entries = /* @__PURE__ */ new Map();
@@ -8128,7 +8119,7 @@ var init_detect = __esm({
8128
8119
  });
8129
8120
 
8130
8121
  // src/react/components/LayoutComponent.tsx
8131
- import { useMemo } from "react";
8122
+ import { useMemo, useRef } from "react";
8132
8123
 
8133
8124
  // src/build/transforms/mdx/index.ts
8134
8125
  init_utils();
@@ -8581,7 +8572,7 @@ function shouldDisableInterval() {
8581
8572
  }
8582
8573
  try {
8583
8574
  return process.env("VF_DISABLE_LRU_INTERVAL") === "1";
8584
- } catch (_error) {
8575
+ } catch {
8585
8576
  return false;
8586
8577
  }
8587
8578
  }
@@ -8609,11 +8600,6 @@ import { dirname, join as join2 } from "path";
8609
8600
  // src/module-system/import-map/default-import-map.ts
8610
8601
  init_utils();
8611
8602
  function getDefaultImportMap() {
8612
- const _versionMap = {
8613
- 17: REACT_VERSION_17,
8614
- 18: REACT_DEFAULT_VERSION,
8615
- 19: REACT_VERSION_19
8616
- };
8617
8603
  const reactVersion = REACT_DEFAULT_VERSION;
8618
8604
  const importMap = getReactImportMap(reactVersion);
8619
8605
  importMap["react/"] = `https://esm.sh/react@${reactVersion}/`;
@@ -8648,7 +8634,7 @@ function resolveImport(specifier, importMap, scope) {
8648
8634
  function transformImportsWithMap(code, importMap, scope, options) {
8649
8635
  let transformedCode = code;
8650
8636
  transformedCode = transformedCode.replace(
8651
- /((?:import|export)\s+(?:[\w,{ /* empty */ }\s*]+\s+from\s+)?|export\s+(?:\*|\{[^}]+\})\s+from\s+)["']([^"']+)["']/g,
8637
+ /((?:import|export)\s+(?:[\w,{}\s*]+\s+from\s+)?|export\s+(?:\*|\{[^}]+\})\s+from\s+)["']([^"']+)["']/g,
8652
8638
  (_match, prefix, specifier) => {
8653
8639
  const isBare = !specifier.startsWith("http") && !specifier.startsWith("/") && !specifier.startsWith(".");
8654
8640
  if (isBare && !options?.resolveBare) {
@@ -9090,7 +9076,7 @@ init_utils();
9090
9076
  import { Fragment, jsx } from "react/jsx-runtime";
9091
9077
 
9092
9078
  // src/react/components/ProviderComponent.tsx
9093
- import { useMemo as useMemo2 } from "react";
9079
+ import { useMemo as useMemo2, useRef as useRef2 } from "react";
9094
9080
  init_utils();
9095
9081
  import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
9096
9082
 
@@ -9123,13 +9109,9 @@ function Link({ prefetch = true, children, ...rest }) {
9123
9109
  // src/react/components/MDXProvider.tsx
9124
9110
  import { createContext, useContext } from "react";
9125
9111
  import { jsx as jsx5 } from "react/jsx-runtime";
9126
- var MDXContext = createContext({
9127
- /* empty */
9128
- });
9112
+ var MDXContext = createContext({});
9129
9113
  function MDXProvider({
9130
- components = {
9131
- /* empty */
9132
- },
9114
+ components = {},
9133
9115
  children
9134
9116
  }) {
9135
9117
  return /* @__PURE__ */ jsx5(MDXContext.Provider, { value: components, children });
@@ -9275,10 +9257,7 @@ function OptimizedBackgroundImage({
9275
9257
  backgroundRepeat: "no-repeat",
9276
9258
  ...style
9277
9259
  };
9278
- return (
9279
- // @ts-ignore - csstype version conflict between dependencies
9280
- /* @__PURE__ */ jsx8("div", { className, style: bgStyle, children })
9281
- );
9260
+ return /* @__PURE__ */ jsx8("div", { className, style: bgStyle, children });
9282
9261
  }
9283
9262
 
9284
9263
  // src/react/components/optimized-image/useOptimizedImage.ts
@@ -9388,7 +9367,7 @@ function jsonResponse(data, status = HttpStatus.OK, options) {
9388
9367
  status,
9389
9368
  headers
9390
9369
  });
9391
- } catch (_error) {
9370
+ } catch {
9392
9371
  return errorResponse(
9393
9372
  HttpStatus.INTERNAL_SERVER_ERROR,
9394
9373
  "Failed to serialize response data"
@@ -9648,14 +9627,10 @@ var ContextPropagation = class {
9648
9627
  async withActiveSpan(span, fn) {
9649
9628
  if (!span)
9650
9629
  return await fn();
9651
- try {
9652
- return await this.api.context.with(
9653
- this.api.trace.setSpan(this.api.context.active(), span),
9654
- fn
9655
- );
9656
- } catch (error2) {
9657
- throw error2;
9658
- }
9630
+ return await this.api.context.with(
9631
+ this.api.trace.setSpan(this.api.context.active(), span),
9632
+ fn
9633
+ );
9659
9634
  }
9660
9635
  withSpan(name, fn, startSpan2, endSpan2) {
9661
9636
  const span = startSpan2(name);
@@ -10149,7 +10124,6 @@ async function initializeInstruments(meter, config, runtimeState) {
10149
10124
  } catch (error2) {
10150
10125
  serverLogger.warn("[metrics] Failed to initialize metric instruments", error2);
10151
10126
  }
10152
- await Promise.resolve();
10153
10127
  return instruments;
10154
10128
  }
10155
10129
 
@@ -10158,37 +10132,17 @@ var MetricsRecorder = class {
10158
10132
  constructor(instruments, runtimeState) {
10159
10133
  this.instruments = instruments;
10160
10134
  this.runtimeState = runtimeState;
10161
- this.stateLock = { locked: false };
10162
- }
10163
- /**
10164
- * Execute state mutation atomically to prevent race conditions
10165
- */
10166
- atomicUpdate(fn) {
10167
- while (this.stateLock.locked) {
10168
- }
10169
- this.stateLock.locked = true;
10170
- try {
10171
- fn();
10172
- } finally {
10173
- this.stateLock.locked = false;
10174
- }
10175
10135
  }
10176
- // HTTP Metrics
10177
10136
  recordHttpRequest(attributes) {
10178
10137
  this.instruments.httpRequestCounter?.add(1, attributes);
10179
10138
  this.instruments.httpActiveRequests?.add(1, attributes);
10180
- this.atomicUpdate(() => {
10181
- this.runtimeState.activeRequests++;
10182
- });
10139
+ this.runtimeState.activeRequests++;
10183
10140
  }
10184
10141
  recordHttpRequestComplete(durationMs, attributes) {
10185
10142
  this.instruments.httpRequestDuration?.record(durationMs, attributes);
10186
10143
  this.instruments.httpActiveRequests?.add(-1, attributes);
10187
- this.atomicUpdate(() => {
10188
- this.runtimeState.activeRequests--;
10189
- });
10144
+ this.runtimeState.activeRequests--;
10190
10145
  }
10191
- // Cache Metrics
10192
10146
  recordCacheGet(hit, attributes) {
10193
10147
  this.instruments.cacheGetCounter?.add(1, attributes);
10194
10148
  if (hit) {
@@ -10199,23 +10153,17 @@ var MetricsRecorder = class {
10199
10153
  }
10200
10154
  recordCacheSet(attributes) {
10201
10155
  this.instruments.cacheSetCounter?.add(1, attributes);
10202
- this.atomicUpdate(() => {
10203
- this.runtimeState.cacheSize++;
10204
- });
10156
+ this.runtimeState.cacheSize++;
10205
10157
  }
10206
10158
  recordCacheInvalidate(count, attributes) {
10207
10159
  this.instruments.cacheInvalidateCounter?.add(count, attributes);
10208
- this.atomicUpdate(() => {
10209
- this.runtimeState.cacheSize = Math.max(
10210
- 0,
10211
- this.runtimeState.cacheSize - count
10212
- );
10213
- });
10160
+ this.runtimeState.cacheSize = Math.max(
10161
+ 0,
10162
+ this.runtimeState.cacheSize - count
10163
+ );
10214
10164
  }
10215
10165
  setCacheSize(size) {
10216
- this.atomicUpdate(() => {
10217
- this.runtimeState.cacheSize = size;
10218
- });
10166
+ this.runtimeState.cacheSize = size;
10219
10167
  }
10220
10168
  // Render Metrics
10221
10169
  recordRender(durationMs, attributes) {
@@ -10670,7 +10618,6 @@ init_logger();
10670
10618
  init_veryfront_error();
10671
10619
 
10672
10620
  // src/security/http/response/security-handler.ts
10673
- init_utils();
10674
10621
  function generateNonce() {
10675
10622
  const array = new Uint8Array(16);
10676
10623
  crypto.getRandomValues(array);
@@ -10720,7 +10667,6 @@ function getSecurityHeader(headerName, defaultValue, config, adapter) {
10720
10667
  return (typeof configValue === "string" ? configValue : void 0) || envValue || defaultValue;
10721
10668
  }
10722
10669
  function applySecurityHeaders(headers, isDev, nonce, cspUserHeader, config, adapter) {
10723
- serverLogger.debug("[NONCE-TRACE] applySecurityHeaders called", { nonce });
10724
10670
  const getHeaderOverride = (name) => {
10725
10671
  const overrides = config?.headers;
10726
10672
  if (!overrides)
@@ -11041,10 +10987,8 @@ function stream(streamData, req, config) {
11041
10987
  }
11042
10988
 
11043
10989
  // src/security/http/response/builder.ts
11044
- init_utils();
11045
10990
  var ResponseBuilder = class {
11046
10991
  constructor(config) {
11047
- // Fluent methods - bind imported functions to this instance
11048
10992
  this.withCORS = withCORS;
11049
10993
  this.withCORSAsync = withCORSAsync;
11050
10994
  this.withSecurity = withSecurity;
@@ -11053,7 +10997,6 @@ var ResponseBuilder = class {
11053
10997
  this.withHeaders = withHeaders;
11054
10998
  this.withStatus = withStatus;
11055
10999
  this.withAllow = withAllow;
11056
- // Response methods - bind imported functions to this instance
11057
11000
  this.json = json;
11058
11001
  this.text = text;
11059
11002
  this.html = html;
@@ -11066,15 +11009,10 @@ var ResponseBuilder = class {
11066
11009
  this.securityConfig = config?.securityConfig ?? null;
11067
11010
  this.isDev = config?.isDev ?? false;
11068
11011
  this.nonce = config?.nonce ?? generateNonce();
11069
- serverLogger.debug("[NONCE-TRACE] ResponseBuilder nonce", {
11070
- nonce: this.nonce,
11071
- provided: !!config?.nonce
11072
- });
11073
11012
  this.cspUserHeader = config?.cspUserHeader ?? null;
11074
11013
  this.adapter = config?.adapter;
11075
11014
  }
11076
11015
  static {
11077
- // Static helper methods - delegate to static-helpers module
11078
11016
  this.error = error;
11079
11017
  }
11080
11018
  static {
@@ -11462,7 +11400,6 @@ init_deno2();
11462
11400
  import { join as join7 } from "path";
11463
11401
 
11464
11402
  // src/routing/api/route-executor.ts
11465
- init_utils();
11466
11403
  init_veryfront_error();
11467
11404
 
11468
11405
  // src/routing/api/method-validator.ts