veryfront 0.0.7 → 0.0.10

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
@@ -523,7 +523,7 @@ var init_deno = __esm({
523
523
  "deno.json"() {
524
524
  deno_default = {
525
525
  name: "veryfront",
526
- version: "0.0.7",
526
+ version: "0.0.10",
527
527
  nodeModulesDir: "auto",
528
528
  workspace: [
529
529
  "./examples/async-worker-redis",
@@ -652,6 +652,7 @@ var init_deno = __esm({
652
652
  dev: "deno run --allow-all --no-lock --unstable-net --unstable-worker-options src/cli/main.ts dev",
653
653
  build: "deno compile --allow-all --output ../../bin/veryfront src/cli/main.ts",
654
654
  "build:npm": "deno run -A scripts/build-npm.ts",
655
+ release: "deno run -A scripts/release.ts",
655
656
  test: "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all --unstable-worker-options --unstable-net",
656
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",
657
658
  "test:integration": "DENO_JOBS=1 deno test --parallel --fail-fast --allow-all tests --unstable-worker-options --unstable-net",
@@ -912,6 +913,7 @@ function fromBase64Url(encoded) {
912
913
  }
913
914
  var init_path_utils = __esm({
914
915
  "src/core/utils/path-utils.ts"() {
916
+ "use strict";
915
917
  init_logger();
916
918
  }
917
919
  });
@@ -1233,22 +1235,44 @@ var init_bundle_manifest_init = __esm({
1233
1235
  }
1234
1236
  });
1235
1237
 
1238
+ // src/platform/compat/runtime.ts
1239
+ var isDeno, isNode, isBun, isCloudflare;
1240
+ var init_runtime = __esm({
1241
+ "src/platform/compat/runtime.ts"() {
1242
+ "use strict";
1243
+ isDeno = typeof Deno !== "undefined";
1244
+ isNode = typeof globalThis.process !== "undefined" && globalThis.process?.versions?.node !== void 0;
1245
+ isBun = typeof globalThis.Bun !== "undefined";
1246
+ isCloudflare = typeof globalThis !== "undefined" && "caches" in globalThis && "WebSocketPair" in globalThis;
1247
+ }
1248
+ });
1249
+
1250
+ // src/platform/compat/process.ts
1251
+ import process2 from "node:process";
1252
+ function getEnv(key) {
1253
+ if (isDeno) {
1254
+ return process2.env(key);
1255
+ }
1256
+ return process2.env[key];
1257
+ }
1258
+ var init_process = __esm({
1259
+ "src/platform/compat/process.ts"() {
1260
+ "use strict";
1261
+ init_runtime();
1262
+ }
1263
+ });
1264
+
1236
1265
  // src/core/utils/feature-flags.ts
1237
1266
  function isRSCEnabled(config) {
1238
1267
  if (config?.experimental?.rsc !== void 0) {
1239
1268
  return config.experimental.rsc;
1240
1269
  }
1241
- if (typeof Deno !== "undefined" && Deno.env) {
1242
- return process.env("VERYFRONT_EXPERIMENTAL_RSC") === "1";
1243
- }
1244
- if (typeof process !== "undefined" && process?.env) {
1245
- return process.env.VERYFRONT_EXPERIMENTAL_RSC === "1";
1246
- }
1247
- return false;
1270
+ return getEnv("VERYFRONT_EXPERIMENTAL_RSC") === "1";
1248
1271
  }
1249
1272
  var init_feature_flags = __esm({
1250
1273
  "src/core/utils/feature-flags.ts"() {
1251
1274
  "use strict";
1275
+ init_process();
1252
1276
  }
1253
1277
  });
1254
1278
 
@@ -1707,6 +1731,7 @@ var init_define_config = __esm({
1707
1731
  "src/core/config/define-config.ts"() {
1708
1732
  "use strict";
1709
1733
  init_veryfront_error();
1734
+ init_process();
1710
1735
  }
1711
1736
  });
1712
1737
 
@@ -2158,9 +2183,9 @@ var init_filesystem_adapter = __esm({
2158
2183
  }
2159
2184
  async makeTempDir(prefix) {
2160
2185
  const { mkdtemp } = await import("node:fs/promises");
2161
- const { join: join9 } = await import("node:path");
2186
+ const { join: join8 } = await import("node:path");
2162
2187
  const { tmpdir } = await import("node:os");
2163
- return await mkdtemp(join9(tmpdir(), prefix));
2188
+ return await mkdtemp(join8(tmpdir(), prefix));
2164
2189
  }
2165
2190
  watch(paths, options) {
2166
2191
  const pathArray = Array.isArray(paths) ? paths : [paths];
@@ -2221,20 +2246,20 @@ var init_filesystem_adapter = __esm({
2221
2246
  });
2222
2247
 
2223
2248
  // src/platform/adapters/node/environment-adapter.ts
2224
- import process2 from "node:process";
2249
+ import process3 from "node:process";
2225
2250
  var NodeEnvironmentAdapter;
2226
2251
  var init_environment_adapter = __esm({
2227
2252
  "src/platform/adapters/node/environment-adapter.ts"() {
2228
2253
  "use strict";
2229
2254
  NodeEnvironmentAdapter = class {
2230
2255
  get(key) {
2231
- return process2.env[key];
2256
+ return process3.env[key];
2232
2257
  }
2233
2258
  set(key, value) {
2234
- process2.env[key] = value;
2259
+ process3.env[key] = value;
2235
2260
  }
2236
2261
  toObject() {
2237
- return { ...process2.env };
2262
+ return { ...process3.env };
2238
2263
  }
2239
2264
  };
2240
2265
  }
@@ -7179,18 +7204,6 @@ var init_error_catalog = __esm({
7179
7204
  }
7180
7205
  });
7181
7206
 
7182
- // src/platform/compat/runtime.ts
7183
- var isDeno, isNode, isBun, isCloudflare;
7184
- var init_runtime = __esm({
7185
- "src/platform/compat/runtime.ts"() {
7186
- "use strict";
7187
- isDeno = typeof Deno !== "undefined";
7188
- isNode = typeof globalThis.process !== "undefined" && globalThis.process?.versions?.node !== void 0;
7189
- isBun = typeof globalThis.Bun !== "undefined";
7190
- isCloudflare = typeof globalThis !== "undefined" && "caches" in globalThis && "WebSocketPair" in globalThis;
7191
- }
7192
- });
7193
-
7194
7207
  // src/platform/compat/console/ansi.ts
7195
7208
  var ansi, red, green, yellow, blue, magenta, cyan, white, gray, bold, dim, italic, underline, strikethrough, reset;
7196
7209
  var init_ansi = __esm({
@@ -7373,14 +7386,6 @@ var init_error_formatter = __esm({
7373
7386
  }
7374
7387
  });
7375
7388
 
7376
- // src/platform/compat/process.ts
7377
- import process3 from "node:process";
7378
- var init_process = __esm({
7379
- "src/platform/compat/process.ts"() {
7380
- init_runtime();
7381
- }
7382
- });
7383
-
7384
7389
  // src/core/errors/user-friendly/error-wrapper.ts
7385
7390
  var init_error_wrapper = __esm({
7386
7391
  "src/core/errors/user-friendly/error-wrapper.ts"() {
@@ -7476,9 +7481,9 @@ var init_filesystem_adapter2 = __esm({
7476
7481
  }
7477
7482
  async makeTempDir(prefix) {
7478
7483
  const { mkdtemp } = await import("node:fs/promises");
7479
- const { join: join9 } = await import("node:path");
7484
+ const { join: join8 } = await import("node:path");
7480
7485
  const { tmpdir } = await import("node:os");
7481
- return await mkdtemp(join9(tmpdir(), prefix));
7486
+ return await mkdtemp(join8(tmpdir(), prefix));
7482
7487
  }
7483
7488
  watch(paths, options) {
7484
7489
  const pathArray = Array.isArray(paths) ? paths : [paths];
@@ -7812,16 +7817,16 @@ function createMockAdapter() {
7812
7817
  files.set(path, content);
7813
7818
  return Promise.resolve();
7814
7819
  },
7815
- exists: async (path) => {
7820
+ exists: (path) => {
7816
7821
  if (files.has(path))
7817
- return true;
7822
+ return Promise.resolve(true);
7818
7823
  if (directories.has(path))
7819
- return true;
7824
+ return Promise.resolve(true);
7820
7825
  for (const filePath of files.keys()) {
7821
7826
  if (filePath.startsWith(path + "/"))
7822
- return true;
7827
+ return Promise.resolve(true);
7823
7828
  }
7824
- return false;
7829
+ return Promise.resolve(false);
7825
7830
  },
7826
7831
  readDir: async function* (path) {
7827
7832
  const entries = /* @__PURE__ */ new Map();
@@ -8496,6 +8501,7 @@ var LRUCacheAdapter = class {
8496
8501
 
8497
8502
  // src/core/utils/lru-wrapper.ts
8498
8503
  init_utils();
8504
+ init_process();
8499
8505
  var LRUCache = class {
8500
8506
  adapter;
8501
8507
  cleanupTimer;
@@ -8571,7 +8577,7 @@ function shouldDisableInterval() {
8571
8577
  return true;
8572
8578
  }
8573
8579
  try {
8574
- return process.env("VF_DISABLE_LRU_INTERVAL") === "1";
8580
+ return getEnv("VF_DISABLE_LRU_INTERVAL") === "1";
8575
8581
  } catch {
8576
8582
  return false;
8577
8583
  }
@@ -8901,9 +8907,122 @@ ${transformed}`;
8901
8907
 
8902
8908
  // src/build/transforms/mdx/parser.ts
8903
8909
  init_utils();
8910
+
8911
+ // src/build/transforms/mdx/module-loader/metadata-extractor.ts
8912
+ init_utils();
8913
+
8914
+ // src/build/transforms/mdx/module-loader/string-parser.ts
8915
+ function extractBalancedBlock(source, startIndex, open, close) {
8916
+ const closeCh = close || (open === "{" ? "}" : open === "[" ? "]" : ")");
8917
+ let depth = 0;
8918
+ let i = startIndex;
8919
+ while (i < source.length) {
8920
+ const ch = source[i];
8921
+ if (ch === '"' || ch === "'") {
8922
+ const quote = ch;
8923
+ i++;
8924
+ while (i < source.length) {
8925
+ const q = source[i];
8926
+ if (q === "\\") {
8927
+ i += 2;
8928
+ continue;
8929
+ }
8930
+ if (q === quote) {
8931
+ i++;
8932
+ break;
8933
+ }
8934
+ i++;
8935
+ }
8936
+ continue;
8937
+ }
8938
+ if (ch === open)
8939
+ depth++;
8940
+ if (ch === closeCh) {
8941
+ depth--;
8942
+ if (depth === 0) {
8943
+ return source.slice(startIndex, i + 1);
8944
+ }
8945
+ }
8946
+ i++;
8947
+ }
8948
+ return "";
8949
+ }
8950
+ function parseJsonish(value) {
8951
+ const jsonish = value.replace(/'([^']*)'/g, '"$1"').replace(/([{,]\s*)([A-Za-z_$][\w$]*)\s*:/g, '$1"$2":');
8952
+ return JSON.parse(jsonish);
8953
+ }
8954
+
8955
+ // src/build/transforms/mdx/module-loader/metadata-extractor.ts
8956
+ function extractFrontmatter(moduleCode) {
8957
+ try {
8958
+ const fmIndex = moduleCode.search(/(?:export\s+)?const\s+frontmatter\s*=\s*/);
8959
+ if (fmIndex < 0)
8960
+ return void 0;
8961
+ const braceStart = moduleCode.indexOf("{", fmIndex);
8962
+ if (braceStart < 0)
8963
+ return void 0;
8964
+ const raw = extractBalancedBlock(moduleCode, braceStart, "{", "}");
8965
+ if (!raw)
8966
+ return void 0;
8967
+ const jsonish = raw.replace(/([^\s"{[:,]+)\s*:/g, '"$1":').replace(/'([^']*)'/g, '"$1"');
8968
+ try {
8969
+ return JSON.parse(jsonish);
8970
+ } catch (e) {
8971
+ rendererLogger.debug("[mdx] frontmatter JSON parse failed", e);
8972
+ return void 0;
8973
+ }
8974
+ } catch (e) {
8975
+ rendererLogger.debug("[mdx] frontmatter extraction failed", e);
8976
+ return void 0;
8977
+ }
8978
+ }
8979
+ var METADATA_PATTERNS = [
8980
+ { regex: /(?:export\s+)?const\s+title\s*=\s*["']([^"']+)["']/, key: "title" },
8981
+ { regex: /(?:export\s+)?const\s+description\s*=\s*["']([^"']+)["']/, key: "description" },
8982
+ { regex: /(?:export\s+)?const\s+layout\s*=\s*(true|false|["'][^"']+["'])/, key: "layout" },
8983
+ { regex: /(?:export\s+)?const\s+headings\s*=\s*(\[[\s\S]*?\])/, key: "headings" },
8984
+ { regex: /(?:export\s+)?const\s+nested\s*=\s*({[\s\S]*?})/, key: "nested" },
8985
+ { regex: /(?:export\s+)?const\s+tags\s*=\s*(\[[\s\S]*?\])/, key: "tags" },
8986
+ { regex: /(?:export\s+)?const\s+date\s*=\s*["']([^"']+)["']/, key: "date" },
8987
+ { regex: /(?:export\s+)?const\s+draft\s*=\s*(true|false)/, key: "draft" }
8988
+ ];
8989
+ function extractMetadata(moduleCode) {
8990
+ const exports = {};
8991
+ METADATA_PATTERNS.forEach(({ regex, key }) => {
8992
+ const match = moduleCode.match(regex);
8993
+ if (!match)
8994
+ return;
8995
+ const value = match[1];
8996
+ switch (key) {
8997
+ case "title":
8998
+ case "description":
8999
+ case "date":
9000
+ exports[key] = value;
9001
+ break;
9002
+ case "layout":
9003
+ exports[key] = value === "true" ? true : value === "false" ? false : String(value).replace(/^"|"$/g, "");
9004
+ break;
9005
+ case "headings":
9006
+ case "tags":
9007
+ case "nested":
9008
+ try {
9009
+ exports[key] = parseJsonish(value);
9010
+ } catch (e) {
9011
+ rendererLogger.warn(`Failed to parse ${key}`, e);
9012
+ }
9013
+ break;
9014
+ case "draft":
9015
+ exports[key] = value === "true";
9016
+ break;
9017
+ }
9018
+ });
9019
+ return exports;
9020
+ }
9021
+
9022
+ // src/build/transforms/mdx/parser.ts
8904
9023
  function parseMDXCode(compiledCode) {
8905
9024
  rendererLogger.debug("Parsing MDX code, first 200 chars:", compiledCode.substring(0, 200));
8906
- const importRegex = /import\s+(?:{([^}]+)}|(\w+))\s+from\s+['"]([^'"]+)['"]/g;
9025
+ const importRegex = /^\s*import\s+(?:{([^}]+)}|(\w+))\s+from\s+['"]([^'"]+)['"]\s*;?\s*$/gm;
8907
9026
  const imports = /* @__PURE__ */ new Map();
8908
9027
  let match;
8909
9028
  while ((match = importRegex.exec(compiledCode)) !== null) {
@@ -8924,7 +9043,7 @@ function parseMDXCode(compiledCode) {
8924
9043
  }
8925
9044
  }
8926
9045
  }
8927
- const cleanedCode = compiledCode.replace(/import\s+.*?from\s+['"][^'"]+['"];?\s*/gm, "").replace(/export\s+\{[\s\S]*?\};?/gm, "").replace(/export\s+default\s+function/gm, "function").replace(/export\s+default\s+/gm, "").replace(/export\s+const\s+/gm, "const ").replace(/export\s+function\s+/gm, "function ").replace(/^const\s+React\s*=.*?;?\s*$/gm, "").replace(/^import\s+React\s+from.*?;?\s*$/gm, "").replace(/^const\s+(Fragment|Fragment2)\s*=.*?;?\s*$/gm, "").replace(/^const\s+(jsx|jsx2)\s*=.*?;?\s*$/gm, "").replace(/^const\s+(jsxs|jsxs2)\s*=.*?;?\s*$/gm, "");
9046
+ const cleanedCode = compiledCode.replace(importRegex, "").replace(/^\s*export\s+\{[\s\S]*?\};?\s*$/gm, "").replace(/^\s*export\s+default\s+function/gm, "function").replace(/^\s*export\s+default\s+/gm, "").replace(/^\s*export\s+const\s+/gm, "const ").replace(/^\s*export\s+function\s+/gm, "function ").replace(/^\s*const\s+React\s*=.*?;?\s*$/gm, "").replace(/^\s*import\s+React\s+from.*?;?\s*$/gm, "").replace(/^\s*const\s+(Fragment|Fragment2)\s*=.*?;?\s*$/gm, "").replace(/^\s*const\s+(jsx|jsx2)\s*=.*?;?\s*$/gm, "").replace(/^\s*const\s+(jsxs|jsxs2)\s*=.*?;?\s*$/gm, "");
8928
9047
  if (cleanedCode.includes("import React")) {
8929
9048
  rendererLogger.warn("Import React still in cleaned code");
8930
9049
  }
@@ -8933,46 +9052,16 @@ function parseMDXCode(compiledCode) {
8933
9052
  rendererLogger.debug("Code snippet:", cleanedCode.substring(0, 200));
8934
9053
  }
8935
9054
  const exports = {};
8936
- const frontmatterMatch = cleanedCode.match(/const\s+frontmatter\s*=\s*({[\s\S]*?});/);
8937
- if (frontmatterMatch) {
8938
- try {
8939
- const objectLiteral = (frontmatterMatch[1] ?? "{}").replace(/(\w+):/g, '"$1":').replace(/'/g, '"');
8940
- exports.frontmatter = JSON.parse(objectLiteral);
8941
- } catch {
8942
- rendererLogger.debug("[MDX] Could not parse frontmatter statically, will extract at runtime");
8943
- }
9055
+ const frontmatter = extractFrontmatter(cleanedCode);
9056
+ if (frontmatter) {
9057
+ exports.frontmatter = frontmatter;
8944
9058
  }
8945
- const exportMatches = [
8946
- { regex: /const\s+title\s*=\s*["']([^"']+)["']/, key: "title", parse: (v) => v },
8947
- {
8948
- regex: /const\s+description\s*=\s*["']([^"']+)["']/,
8949
- key: "description",
8950
- parse: (v) => v
8951
- },
8952
- { regex: /const\s+layout\s*=\s*true/, key: "layout", parse: () => true },
8953
- { regex: /const\s+layout\s*=\s*false/, key: "layout", parse: () => false },
8954
- { regex: /const\s+layout\s*=\s*["']([^"']+)["']/, key: "layout", parse: (v) => v },
8955
- {
8956
- regex: /const\s+headings\s*=\s*(\[[\s\S]*?\]);/,
8957
- key: "headings",
8958
- parse: (v) => {
8959
- try {
8960
- return JSON.parse(v.replace(/'/g, '"'));
8961
- } catch {
8962
- return [];
8963
- }
8964
- }
9059
+ const metadata = extractMetadata(cleanedCode);
9060
+ for (const [key, value] of Object.entries(metadata)) {
9061
+ if (value !== void 0) {
9062
+ exports[key] = value;
8965
9063
  }
8966
- ];
8967
- exportMatches.forEach(({ regex, key, parse }) => {
8968
- const m = cleanedCode.match(regex);
8969
- if (m) {
8970
- try {
8971
- exports[key] = parse(m[1] || m[0]);
8972
- } catch (_error) {
8973
- }
8974
- }
8975
- });
9064
+ }
8976
9065
  return { code: cleanedCode, imports, exports };
8977
9066
  }
8978
9067
 
@@ -9293,8 +9382,19 @@ init_path_utils();
9293
9382
  // src/routing/matchers/index.ts
9294
9383
  init_utils();
9295
9384
 
9296
- // src/routing/slug-mapper/path-candidate-generator.ts
9297
- import { join as join5 } from "path";
9385
+ // src/platform/compat/path-helper.ts
9386
+ import nodePath from "node:path";
9387
+ var pathMod = null;
9388
+ var denoPathPromise = null;
9389
+ if (typeof Deno === "undefined") {
9390
+ pathMod = nodePath;
9391
+ } else {
9392
+ denoPathPromise = import("path").then((mod) => {
9393
+ pathMod = mod;
9394
+ return pathMod;
9395
+ });
9396
+ }
9397
+ var sep = nodePath.sep;
9298
9398
 
9299
9399
  // src/routing/client/dom-utils.ts
9300
9400
  init_utils();
@@ -9317,7 +9417,7 @@ init_utils();
9317
9417
  // src/routing/api/handler.ts
9318
9418
  init_utils();
9319
9419
  init_config();
9320
- import { join as join8 } from "path";
9420
+ import { join as join7 } from "path";
9321
9421
  init_veryfront_error();
9322
9422
 
9323
9423
  // src/http/responses.ts
@@ -10074,7 +10174,7 @@ function createRscInstruments(meter, config) {
10074
10174
  }
10075
10175
 
10076
10176
  // src/observability/instruments/instruments-factory.ts
10077
- async function initializeInstruments(meter, config, runtimeState) {
10177
+ function initializeInstruments(meter, config, runtimeState) {
10078
10178
  const instruments = {
10079
10179
  httpRequestCounter: null,
10080
10180
  httpRequestDuration: null,
@@ -10124,7 +10224,7 @@ async function initializeInstruments(meter, config, runtimeState) {
10124
10224
  } catch (error2) {
10125
10225
  serverLogger.warn("[metrics] Failed to initialize metric instruments", error2);
10126
10226
  }
10127
- return instruments;
10227
+ return Promise.resolve(instruments);
10128
10228
  }
10129
10229
 
10130
10230
  // src/observability/metrics/recorder.ts
@@ -11373,9 +11473,11 @@ init_utils();
11373
11473
  // src/security/secure-fs.ts
11374
11474
  init_utils();
11375
11475
 
11476
+ // src/routing/api/api-route-matcher.ts
11477
+ init_process();
11478
+
11376
11479
  // src/routing/api/module-loader/loader.ts
11377
11480
  init_utils();
11378
- import { dirname as dirname2, isAbsolute, join as join6, resolve } from "path";
11379
11481
 
11380
11482
  // src/routing/api/module-loader/esbuild-plugin.ts
11381
11483
  init_utils();
@@ -11392,12 +11494,16 @@ init_utils();
11392
11494
  // src/routing/api/module-loader/loader.ts
11393
11495
  init_veryfront_error();
11394
11496
 
11497
+ // src/platform/compat/fs.ts
11498
+ init_veryfront_error();
11499
+ init_runtime();
11500
+
11395
11501
  // src/routing/api/route-discovery.ts
11396
11502
  import { relative } from "path";
11397
11503
 
11398
11504
  // src/core/utils/file-discovery.ts
11399
11505
  init_deno2();
11400
- import { join as join7 } from "path";
11506
+ import { join as join6 } from "path";
11401
11507
 
11402
11508
  // src/routing/api/route-executor.ts
11403
11509
  init_veryfront_error();