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 +1 -1
- package/dist/index.js +3 -14
- package/dist/react.d.ts +1 -1
- package/dist/react.js +3 -14
- package/dist/tsx-context.d.ts +0 -9
- package/dist/tsx-instance.d.ts +2 -2
- package/dist/tsx.d.ts +2 -2
- package/package.json +1 -1
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
package/dist/tsx-context.d.ts
CHANGED
|
@@ -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>;
|
package/dist/tsx-instance.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Router } from './router.ts';
|
|
2
|
-
import { TsxContext, useCtx, setCtx
|
|
3
|
-
export { TsxContext, useCtx, setCtx
|
|
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
|
|
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
|
|
4
|
+
export { TsxContext, useCtx, setCtx };
|
|
5
5
|
export type { TsxOptions };
|
|
6
6
|
export declare function tsx(options: TsxOptions): Promise<Router & {
|
|
7
7
|
stop: () => void;
|