@webjsdev/server 0.8.88 → 0.8.89

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webjsdev/server",
3
- "version": "0.8.88",
3
+ "version": "0.8.89",
4
4
  "type": "module",
5
5
  "description": "The server for WebJs, a full-stack JavaScript framework built on web components with server-side rendering and no build step. Provides the file-based router, SSR, server actions, route handlers, middleware, and live reload on Node 24+ or Bun.",
6
6
  "main": "index.js",
package/src/context.js CHANGED
@@ -178,9 +178,9 @@ setCspNonceProvider(() => {
178
178
  return match ? match[1] : '';
179
179
  });
180
180
 
181
- // Re-export for backwards-compat: callers that imported cspNonce from
182
- // @webjsdev/server still work. New code should import from
183
- // @webjsdev/core for browser-isomorphism.
181
+ // `cspNonce` is also reachable from @webjsdev/server for server-only modules
182
+ // (route handlers, actions); a layout or page imports it from @webjsdev/core
183
+ // so the module stays browser-isomorphic.
184
184
  export { cspNonce };
185
185
 
186
186
  /**
package/src/importmap.js CHANGED
@@ -296,11 +296,9 @@ export function vendorIntegrityFor(url) {
296
296
  * Initialized to the two minimum-safe defaults (the bare specifier
297
297
  * pointing at the browser source-mode entry and the catch-all prefix
298
298
  * pointing at `src/`) so any consumer that calls `buildImportMap()`
299
- * before `setCoreInstall` runs still gets a usable map. Pre-#118 the
300
- * legacy `coreMappings` were always derived from a boolean and so
301
- * could not be empty; this keeps that fail-open posture for embedded
302
- * SSR test helpers and one-shot tooling that imports `importmap.js`
303
- * without booting `dev.js`.
299
+ * before `setCoreInstall` runs still gets a usable map: a fail-open
300
+ * posture for embedded SSR test helpers and one-shot tooling that
301
+ * imports `importmap.js` without booting `dev.js`.
304
302
  *
305
303
  * @type {Record<string, string>}
306
304
  */
@@ -329,9 +327,7 @@ let _coreEntries = {
329
327
  * rebuilds today; if `@webjsdev/core/package.json` is edited in a
330
328
  * long-running dev session (e.g. workspace dev that runs a fresh
331
329
  * `npm run build:dist`), the derivation is refreshed on next server
332
- * restart, not on the watcher tick. Pre-#118 the legacy
333
- * `setCoreDistMode` had the same behaviour: only the dist-presence
334
- * boolean was watched, not the package.json itself.
330
+ * restart, not on the watcher tick.
335
331
  *
336
332
  * Like `setVendorEntries`, the importmap-hash is recomputed eagerly
337
333
  * so `importMapHash()` stays synchronous on the per-request SSR
package/src/rate-limit.js CHANGED
@@ -313,9 +313,3 @@ export function parseWindow(w) {
313
313
  const mult = { ms: 1, s: 1000, m: 60_000, h: 3_600_000 }[unit];
314
314
  return n * (mult || 1);
315
315
  }
316
-
317
- /** Testing hook: reset the default store (for unit tests). */
318
- export function _resetRateLimits() {
319
- // With the cache store, there's nothing to reset here: the store
320
- // handles its own state. This function exists for API compatibility.
321
- }
package/src/session.js CHANGED
@@ -235,7 +235,7 @@ export function storeSessionStorage(opts = {}) {
235
235
  };
236
236
  }
237
237
 
238
- // Backwards-compatible aliases
238
+ // Short aliases
239
239
  export const cookieSession = cookieSessionStorage;
240
240
  export const storeSession = storeSessionStorage;
241
241
 
package/src/ssr/head.js CHANGED
@@ -457,9 +457,9 @@ export function wrapHead(opts) {
457
457
 
458
458
  if (m.description) metaTags.push(`<meta name="description" content="${escapeAttr(m.description)}">`);
459
459
 
460
- // viewport: support string form (legacy), `metadata.viewport` object form,
461
- // and the new Next.js 14+ `export const viewport = { … }` shape captured
462
- // into `_viewport` by collectMetadata.
460
+ // viewport: the `metadata.viewport` string or object form, or the Next.js
461
+ // 14+ `export const viewport = { … }` shape captured into `_viewport` by
462
+ // collectMetadata.
463
463
  let viewportStr = '';
464
464
  if (typeof m.viewport === 'string') {
465
465
  viewportStr = m.viewport;
package/src/ssr/render.js CHANGED
@@ -830,7 +830,7 @@ async function ssrBoundaryHtml(file, heading, opts) {
830
830
  moduleUrls = [];
831
831
  }
832
832
  }
833
- const nonce = opts.req ? getNonce(opts.req) : undefined;
833
+ const nonce = getNonce();
834
834
  return wrapInDocument(body, {
835
835
  metadata: { title: heading.replace(/^\d+:\s*/, '') },
836
836
  moduleUrls,
@@ -900,7 +900,7 @@ async function ssrNotFoundHtml(notFoundFile, opts) {
900
900
  moduleUrls = [];
901
901
  }
902
902
  }
903
- const nonce = opts.req ? getNonce(opts.req) : undefined;
903
+ const nonce = getNonce();
904
904
  return wrapInDocument(body, {
905
905
  metadata: { title: 'Not found' },
906
906
  moduleUrls,
@@ -1194,7 +1194,7 @@ export async function ssrPage(route, params, url, opts) {
1194
1194
  ),
1195
1195
  );
1196
1196
  // Extract CSP nonce from request headers (if present).
1197
- const nonce = opts.req ? getNonce(opts.req) : undefined;
1197
+ const nonce = getNonce();
1198
1198
  const wrapOpts = {
1199
1199
  metadata,
1200
1200
  moduleUrls,
@@ -1342,7 +1342,7 @@ export async function ssrPage(route, params, url, opts) {
1342
1342
  // Error paths still need to honor the request's CSP nonce so the
1343
1343
  // error page's boot scripts (when moduleUrls is non-empty) and
1344
1344
  // the meta csp-nonce tag both pass strict-CSP enforcement.
1345
- const errNonce = opts.req ? getNonce(opts.req) : undefined;
1345
+ const errNonce = getNonce();
1346
1346
  // One dedup set for the whole 500 path: the walk below and the
1347
1347
  // global-error attempt after it collapse REPEATS of the same cause (a
1348
1348
  // shared layout that fails every attempt) while still reporting a
@@ -16,19 +16,15 @@ import { escapeAttr, escapeHtml } from './escape.js';
16
16
  * scope. Delegates to `cspNonce()`, which returns the per-request nonce
17
17
  * the handler MINTED when CSP is enabled (issue #233), or, as a fallback,
18
18
  * the nonce parsed from an inbound `Content-Security-Policy` request
19
- * header (the legacy consume-only path). Using the same source as the
19
+ * header (a proxy that mints its own). Using the same source as the
20
20
  * `Content-Security-Policy` response header is what guarantees the inline
21
21
  * boot script, the importmap, the modulepreload hints, and the header all
22
- * carry the EXACT same nonce: one minted value, no drift.
22
+ * carry the EXACT same nonce: one minted value, no drift. The value comes
23
+ * from the request-scoped AsyncLocalStorage store, so it takes no request.
23
24
  *
24
- * `req` is accepted (and ignored) so existing call sites stay unchanged;
25
- * the value comes from the request-scoped AsyncLocalStorage store, not
26
- * the argument.
27
- *
28
- * @param {Request} [_req]
29
25
  * @returns {string | undefined}
30
26
  */
31
- export function getNonce(_req) {
27
+ export function getNonce() {
32
28
  return cspNonce() || undefined;
33
29
  }
34
30