vorzelajs 0.0.4 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AA+DA,wBAAsB,MAAM,kBA4D3B"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAgEA,wBAAsB,MAAM,kBAqE3B"}
package/dist/cli/dev.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { createServer } from 'node:http';
2
2
  import { createServer as createNetServer } from 'node:net';
3
+ import path from 'node:path';
4
+ import url from 'node:url';
3
5
  import { getRequestListener } from '@hono/node-server';
4
6
  import { createVorzelaApp } from '../server/index.js';
5
7
  import { resolveVorzelaConfig } from '../vite/index.js';
@@ -48,6 +50,11 @@ export async function runDev() {
48
50
  const { vorzelaServerOnlyPlugin } = await import('../vite/server-only.js');
49
51
  const solidPlugin = await import('vite-plugin-solid').then((m) => m.default).catch(() => null);
50
52
  const baseConfig = await resolveVorzelaConfig(appRoot);
53
+ // Resolve the framework's internal entry-client file
54
+ const devThisFile = url.fileURLToPath(import.meta.url);
55
+ const frameworkDir = path.resolve(path.dirname(devThisFile), '..');
56
+ const internalExt = path.extname(devThisFile) === '.js' ? '.jsx' : '.tsx';
57
+ const entryClientPath = path.resolve(frameworkDir, `internal/entry-client${internalExt}`);
51
58
  const { createServer: createViteServer } = await import('vite');
52
59
  const resolvedHmrPort = await findAvailablePort(hmrPort);
53
60
  const vite = await createViteServer({
@@ -58,11 +65,14 @@ export async function runDev() {
58
65
  port: resolvedHmrPort,
59
66
  },
60
67
  middlewareMode: true,
68
+ fs: {
69
+ allow: [appRoot, frameworkDir],
70
+ },
61
71
  },
62
72
  });
63
73
  const devAssets = {
64
74
  css: ['/src/styles.css'],
65
- js: ['/src/entry-client.tsx'],
75
+ js: [`/@fs/${entryClientPath}`],
66
76
  };
67
77
  const loadEntry = async () => {
68
78
  return vite.ssrLoadModule('virtual:vorzela/entry-server');
@@ -1 +1 @@
1
- {"version":3,"file":"error-stack.d.ts","sourceRoot":"","sources":["../../src/debug/error-stack.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,eAAe,EAAE,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAaD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAiC1E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,EAAE,SAAS,SAAI,YAYjF"}
1
+ {"version":3,"file":"error-stack.d.ts","sourceRoot":"","sources":["../../src/debug/error-stack.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,eAAe,EAAE,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AA4ED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAa1E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,EAAE,SAAS,SAAI,YAYjF"}
@@ -1,4 +1,3 @@
1
- import ErrorStackParser from 'error-stack-parser';
2
1
  function formatFrameSource(frame) {
3
2
  const fileName = frame.fileName ?? '<unknown>';
4
3
  const lineNumber = frame.lineNumber ?? 0;
@@ -8,36 +7,69 @@ function formatFrameSource(frame) {
8
7
  : '';
9
8
  return `${functionName}(${fileName}:${lineNumber}:${columnNumber})`;
10
9
  }
10
+ function createFrame(source, parts = {}) {
11
+ return {
12
+ ...parts,
13
+ source,
14
+ };
15
+ }
16
+ function parseStackLine(line) {
17
+ const trimmed = line.trim();
18
+ if (trimmed === '' || trimmed.toLowerCase().startsWith('error')) {
19
+ return undefined;
20
+ }
21
+ const v8Named = /^at\s+(.*?)\s+\((.+):(\d+):(\d+)\)$/u.exec(trimmed);
22
+ if (v8Named) {
23
+ const [, functionName, fileName, lineNumber, columnNumber] = v8Named;
24
+ return createFrame(trimmed, {
25
+ columnNumber: Number(columnNumber),
26
+ fileName,
27
+ functionName,
28
+ lineNumber: Number(lineNumber),
29
+ });
30
+ }
31
+ const v8Anonymous = /^at\s+(.+):(\d+):(\d+)$/u.exec(trimmed);
32
+ if (v8Anonymous) {
33
+ const [, fileName, lineNumber, columnNumber] = v8Anonymous;
34
+ return createFrame(trimmed, {
35
+ columnNumber: Number(columnNumber),
36
+ fileName,
37
+ lineNumber: Number(lineNumber),
38
+ });
39
+ }
40
+ const firefoxNamed = /^(.*?)@(.+):(\d+):(\d+)$/u.exec(trimmed);
41
+ if (firefoxNamed) {
42
+ const [, functionName, fileName, lineNumber, columnNumber] = firefoxNamed;
43
+ return createFrame(trimmed, {
44
+ columnNumber: Number(columnNumber),
45
+ fileName,
46
+ functionName: functionName || undefined,
47
+ lineNumber: Number(lineNumber),
48
+ });
49
+ }
50
+ return createFrame(trimmed);
51
+ }
52
+ function parseStackFrames(stack) {
53
+ return stack
54
+ .split('\n')
55
+ .map(parseStackLine)
56
+ .filter((frame) => frame !== undefined)
57
+ .map((frame) => ({
58
+ ...frame,
59
+ source: frame.fileName || frame.functionName ? formatFrameSource(frame) : frame.source,
60
+ }));
61
+ }
11
62
  export function parseErrorStack(error) {
12
63
  if (!(error instanceof Error)) {
13
64
  return undefined;
14
65
  }
15
- try {
16
- const frames = ErrorStackParser.parse(error).map((frame) => {
17
- const normalizedFrame = {
18
- columnNumber: frame.columnNumber,
19
- fileName: frame.fileName,
20
- functionName: frame.functionName,
21
- lineNumber: frame.lineNumber,
22
- source: '',
23
- };
24
- normalizedFrame.source = formatFrameSource(normalizedFrame);
25
- return normalizedFrame;
26
- });
27
- return {
28
- frames,
29
- stack: error.stack,
30
- };
31
- }
32
- catch {
33
- if (!error.stack) {
34
- return undefined;
35
- }
36
- return {
37
- frames: [],
38
- stack: error.stack,
39
- };
66
+ if (!error.stack) {
67
+ return undefined;
40
68
  }
69
+ return {
70
+ frames: parseStackFrames(error.stack),
71
+ stack: error.stack,
72
+ };
41
73
  }
42
74
  export function formatParsedStack(stack, maxFrames = 8) {
43
75
  if (!stack) {
@@ -1 +1 @@
1
- {"version":3,"file":"routes-plugin.d.ts","sourceRoot":"","sources":["../../src/vite/routes-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA+VlC,wBAAsB,cAAc,CAAC,WAAW,SAAgB,iBA2B/D;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CA2C5C"}
1
+ {"version":3,"file":"routes-plugin.d.ts","sourceRoot":"","sources":["../../src/vite/routes-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAwWlC,wBAAsB,cAAc,CAAC,WAAW,SAAgB,iBA2B/D;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CA2C5C"}
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  const ROUTES_DIR = path.join('src', 'routes');
4
+ const SOURCE_DIR = 'src';
4
5
  const OUTPUT_FILE = path.join('src', 'routeTree.gen.ts');
5
6
  const OUTPUT_HYDRATION_FILE = path.join('src', 'routeHydration.gen.ts');
6
7
  const ROUTE_FILE_PATTERN = /\.(ts|tsx)$/u;
@@ -186,8 +187,11 @@ function detectRouteHydration(source) {
186
187
  ? 'client'
187
188
  : 'static';
188
189
  }
189
- function isLocalModuleSpecifier(specifier) {
190
- return specifier.startsWith('./') || specifier.startsWith('../');
190
+ function isHydrationTrackedSpecifier(specifier) {
191
+ return specifier.startsWith('./')
192
+ || specifier.startsWith('../')
193
+ || specifier === '~'
194
+ || specifier.startsWith('~/');
191
195
  }
192
196
  function extractLocalImportSpecifiers(source) {
193
197
  const specifiers = new Set();
@@ -195,7 +199,7 @@ function extractLocalImportSpecifiers(source) {
195
199
  pattern.lastIndex = 0;
196
200
  for (const match of source.matchAll(pattern)) {
197
201
  const specifier = match[1];
198
- if (specifier && isLocalModuleSpecifier(specifier) && !isServerOnlyModuleSpecifier(specifier)) {
202
+ if (specifier && isHydrationTrackedSpecifier(specifier) && !isServerOnlyModuleSpecifier(specifier)) {
199
203
  specifiers.add(specifier);
200
204
  }
201
205
  }
@@ -211,8 +215,12 @@ async function pathExists(filePath) {
211
215
  return false;
212
216
  }
213
217
  }
214
- async function resolveLocalModulePath(specifier, importerPath) {
215
- const basePath = path.resolve(path.dirname(importerPath), specifier);
218
+ async function resolveLocalModulePath(specifier, importerPath, projectRoot) {
219
+ const basePath = specifier === '~'
220
+ ? path.resolve(projectRoot, SOURCE_DIR)
221
+ : specifier.startsWith('~/')
222
+ ? path.resolve(projectRoot, SOURCE_DIR, specifier.slice(2))
223
+ : path.resolve(path.dirname(importerPath), specifier);
216
224
  const candidates = path.extname(basePath)
217
225
  ? [basePath]
218
226
  : [
@@ -226,7 +234,7 @@ async function resolveLocalModulePath(specifier, importerPath) {
226
234
  }
227
235
  return null;
228
236
  }
229
- async function detectRouteHydrationFromFile(filePath, cache) {
237
+ async function detectRouteHydrationFromFile(filePath, cache, projectRoot) {
230
238
  const resolvedPath = path.resolve(filePath);
231
239
  const cached = cache.get(resolvedPath);
232
240
  if (cached) {
@@ -238,11 +246,11 @@ async function detectRouteHydrationFromFile(filePath, cache) {
238
246
  return 'client';
239
247
  }
240
248
  for (const specifier of extractLocalImportSpecifiers(source)) {
241
- const dependencyPath = await resolveLocalModulePath(specifier, resolvedPath);
249
+ const dependencyPath = await resolveLocalModulePath(specifier, resolvedPath, projectRoot);
242
250
  if (!dependencyPath) {
243
251
  continue;
244
252
  }
245
- if (await detectRouteHydrationFromFile(dependencyPath, cache) === 'client') {
253
+ if (await detectRouteHydrationFromFile(dependencyPath, cache, projectRoot) === 'client') {
246
254
  return 'client';
247
255
  }
248
256
  }
@@ -251,7 +259,7 @@ async function detectRouteHydrationFromFile(filePath, cache) {
251
259
  cache.set(resolvedPath, pending);
252
260
  return pending;
253
261
  }
254
- async function createGeneratedHydrationFile(routes) {
262
+ async function createGeneratedHydrationFile(routes, projectRoot) {
255
263
  const sortedRoutes = [...routes].sort((left, right) => {
256
264
  if (left.id === '__root__')
257
265
  return -1;
@@ -261,7 +269,7 @@ async function createGeneratedHydrationFile(routes) {
261
269
  });
262
270
  const hydrationCache = new Map();
263
271
  const hydrationEntries = await Promise.all(sortedRoutes.map(async (route) => {
264
- const detected = await detectRouteHydrationFromFile(route.filePath, hydrationCache);
272
+ const detected = await detectRouteHydrationFromFile(route.filePath, hydrationCache, projectRoot);
265
273
  return ` '${route.id}': { detected: '${detected}' }`;
266
274
  }));
267
275
  return `/* eslint-disable */
@@ -302,7 +310,7 @@ export async function generateRoutes(projectRoot = process.cwd()) {
302
310
  assertNoDuplicateMatchPaths(routesWithParents);
303
311
  await Promise.all([
304
312
  writeIfChanged(outputPath, createGeneratedFile(routesWithParents)),
305
- writeIfChanged(hydrationOutputPath, await createGeneratedHydrationFile(routesWithParents)),
313
+ writeIfChanged(hydrationOutputPath, await createGeneratedHydrationFile(routesWithParents, projectRoot)),
306
314
  ]);
307
315
  }
308
316
  export function vorzelaRoutesPlugin() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vorzelajs",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "description": "Batteries-included SolidJS framework with file-based routing, streamed SSR, and server-only boundaries",
6
6
  "license": "MIT",