weifuwu 0.17.18 → 0.17.19

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.d.ts CHANGED
@@ -4,7 +4,7 @@ export { serve, createTestServer } from './serve.ts';
4
4
  export type { ServeOptions, Server } from './serve.ts';
5
5
  export { Router } from './router.ts';
6
6
  export type { WebSocketHandler } from './router.ts';
7
- export { tsx, TsxContext, useCtx, setCtx, getCtx } from './tsx.ts';
7
+ export { tsx, TsxContext, useCtx, setCtx } from './tsx.ts';
8
8
  export type { TsxOptions } from './tsx.ts';
9
9
  export { auth, cors, logger } from './middleware.ts';
10
10
  export type { AuthOptions, CORSOptions, LoggerOptions } from './middleware.ts';
package/dist/index.js CHANGED
@@ -598,15 +598,10 @@ function setCtx(value) {
598
598
  _snapshot = { params: _ctx.params, query: _ctx.query, user: _ctx.user, parsed: _ctx.parsed, prefs: _ctx.prefs, env: _ctx.env };
599
599
  _listeners.forEach((fn) => fn());
600
600
  }
601
- var _cachedT = null;
602
601
  function _buildT() {
603
- if (_cachedT) return _cachedT;
604
602
  const messages2 = typeof window !== "undefined" ? window.__LOCALE_DATA__ : globalThis.__LOCALE_DATA__;
605
- if (!messages2) {
606
- _cachedT = fallbackT;
607
- return fallbackT;
608
- }
609
- _cachedT = (key, params, fallback) => {
603
+ if (!messages2) return fallbackT;
604
+ return (key, params, fallback) => {
610
605
  const msg = key.split(".").reduce((o, k) => o?.[k], messages2);
611
606
  if (msg === void 0 || msg === null) return fallback ?? key;
612
607
  if (!params) return String(msg);
@@ -614,22 +609,17 @@ function _buildT() {
614
609
  for (const [k, v] of Object.entries(params)) result = result.replace(`{${k}}`, v);
615
610
  return result;
616
611
  };
617
- return _cachedT;
618
612
  }
619
613
  function _readCtx() {
620
614
  const alsStore = _alsGetStore?.();
621
615
  const base = alsStore ?? _ctx;
622
616
  const data = typeof window !== "undefined" ? window.__WEIFUWU_CTX : null;
623
- const t = typeof base.t === "function" && base.t !== fallbackT ? base.t : _buildT();
624
- return { ...base, ...data, t };
617
+ return { ...base, ...data, t: _buildT() };
625
618
  }
626
619
  function useCtx() {
627
620
  useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
628
621
  return _readCtx();
629
622
  }
630
- function getCtx() {
631
- return _readCtx();
632
- }
633
623
  var TsxContext = createContext(DEFAULT_CTX);
634
624
 
635
625
  // tsx-instance.ts
@@ -8635,7 +8625,6 @@ export {
8635
8625
  generateObject,
8636
8626
  generateText2 as generateText,
8637
8627
  getCookies,
8638
- getCtx,
8639
8628
  graphql,
8640
8629
  health,
8641
8630
  helmet,
package/dist/react.d.ts CHANGED
@@ -3,7 +3,7 @@ export type { UseWebsocketOptions, UseWebsocketReturn } from './use-websocket.ts
3
3
  export { useAction } from './use-action.ts';
4
4
  export type { UseActionOptions, UseActionReturn } from './use-action.ts';
5
5
  export { Link, useNavigate, navigate, useNavigating } from './client-router.ts';
6
- export { TsxContext, useCtx, setCtx, getCtx } from './tsx-context.ts';
6
+ export { TsxContext, useCtx, setCtx } from './tsx-context.ts';
7
7
  export { Head } from './head.tsx';
8
8
  export { createStore, useData, useQueryState } from './client-state.ts';
9
9
  export type { StoreApi } from './client-state.ts';
package/dist/react.js CHANGED
@@ -162,15 +162,10 @@ function setCtx(value) {
162
162
  _snapshot = { params: _ctx.params, query: _ctx.query, user: _ctx.user, parsed: _ctx.parsed, prefs: _ctx.prefs, env: _ctx.env };
163
163
  _listeners.forEach((fn) => fn());
164
164
  }
165
- var _cachedT = null;
166
165
  function _buildT() {
167
- if (_cachedT) return _cachedT;
168
166
  const messages = typeof window !== "undefined" ? window.__LOCALE_DATA__ : globalThis.__LOCALE_DATA__;
169
- if (!messages) {
170
- _cachedT = fallbackT;
171
- return fallbackT;
172
- }
173
- _cachedT = (key, params, fallback) => {
167
+ if (!messages) return fallbackT;
168
+ return (key, params, fallback) => {
174
169
  const msg = key.split(".").reduce((o, k) => o?.[k], messages);
175
170
  if (msg === void 0 || msg === null) return fallback ?? key;
176
171
  if (!params) return String(msg);
@@ -178,22 +173,17 @@ function _buildT() {
178
173
  for (const [k, v] of Object.entries(params)) result = result.replace(`{${k}}`, v);
179
174
  return result;
180
175
  };
181
- return _cachedT;
182
176
  }
183
177
  function _readCtx() {
184
178
  const alsStore = _alsGetStore?.();
185
179
  const base = alsStore ?? _ctx;
186
180
  const data = typeof window !== "undefined" ? window.__WEIFUWU_CTX : null;
187
- const t = typeof base.t === "function" && base.t !== fallbackT ? base.t : _buildT();
188
- return { ...base, ...data, t };
181
+ return { ...base, ...data, t: _buildT() };
189
182
  }
190
183
  function useCtx() {
191
184
  useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
192
185
  return _readCtx();
193
186
  }
194
- function getCtx() {
195
- return _readCtx();
196
- }
197
187
  var TsxContext = createContext(DEFAULT_CTX);
198
188
 
199
189
  // client-router.ts
@@ -539,7 +529,6 @@ export {
539
529
  Link,
540
530
  TsxContext,
541
531
  createStore,
542
- getCtx,
543
532
  navigate,
544
533
  setCtx,
545
534
  useAction,
@@ -12,14 +12,5 @@ export interface CtxValue {
12
12
  /** @internal Injected by tsx-instance.ts for async-safe context isolation */
13
13
  export declare function __registerAls(getStore: () => CtxValue | undefined): void;
14
14
  export declare function setCtx(value: Partial<CtxValue>): void;
15
- /**
16
- * React hook — returns the current request context.
17
- * Must be called from a React component or custom hook.
18
- */
19
15
  export declare function useCtx(): CtxValue;
20
- /**
21
- * Plain accessor — returns the current request context without calling any React hooks.
22
- * Safe to call from utility functions, route handlers, middleware, load functions, etc.
23
- */
24
- export declare function getCtx(): CtxValue;
25
16
  export declare const TsxContext: import("react").Context<CtxValue>;
@@ -1,6 +1,6 @@
1
1
  import { Router } from './router.ts';
2
- import { TsxContext, useCtx, setCtx, getCtx } from './tsx-context.ts';
3
- export { TsxContext, useCtx, setCtx, getCtx };
2
+ import { TsxContext, useCtx, setCtx } from './tsx-context.ts';
3
+ export { TsxContext, useCtx, setCtx };
4
4
  export interface TsxOptions {
5
5
  dir: string;
6
6
  }
package/dist/tsx.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { TsxContext, useCtx, setCtx, getCtx } from './tsx-instance.ts';
1
+ import { TsxContext, useCtx, setCtx } from './tsx-instance.ts';
2
2
  import type { TsxOptions } from './tsx-instance.ts';
3
3
  import type { Router } from './router.ts';
4
- export { TsxContext, useCtx, setCtx, getCtx };
4
+ export { TsxContext, useCtx, setCtx };
5
5
  export type { TsxOptions };
6
6
  export declare function tsx(options: TsxOptions): Promise<Router & {
7
7
  stop: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weifuwu",
3
- "version": "0.17.18",
3
+ "version": "0.17.19",
4
4
  "description": "Web-standard HTTP framework for Node.js — (req, ctx) => Response",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",