@tanstack/redact 0.0.4 → 0.0.5

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.
@@ -65,9 +65,9 @@ export interface FiberRoot {
65
65
  current: Fiber;
66
66
  pending: Set<Fiber>;
67
67
  scheduled: boolean;
68
- onRecoverableError?: (err: unknown) => void;
69
- onCaughtError?: (err: unknown) => void;
70
- onUncaughtError?: (err: unknown) => void;
68
+ onRecoverableError?: ((err: unknown) => void) | undefined;
69
+ onCaughtError?: ((err: unknown) => void) | undefined;
70
+ onUncaughtError?: ((err: unknown) => void) | undefined;
71
71
  identifierPrefix: string;
72
72
  hydrating: boolean;
73
73
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/core/internal.ts"],
4
- "sourcesContent": ["import type { ReactElement, ReactNode, Ref } from './types'\n\nexport const enum FiberTag {\n Host = 0,\n Text = 1,\n Function = 2,\n Class = 3,\n Fragment = 4,\n Portal = 5,\n Provider = 6,\n Consumer = 7,\n ForwardRef = 8,\n Memo = 9,\n Lazy = 10,\n Suspense = 11,\n Root = 12,\n}\n\nexport const enum FiberFlag {\n None = 0,\n Placement = 1 << 0,\n Update = 1 << 1,\n Deletion = 1 << 2,\n Ref = 1 << 3,\n Effect = 1 << 4,\n LayoutEffect = 1 << 5,\n ContentReset = 1 << 6,\n DidCapture = 1 << 7,\n}\n\nexport interface Hook {\n state: any\n queue: any\n deps: any\n cleanup: any\n next: Hook | null\n}\n\nexport interface Effect {\n tag: 'effect' | 'layout' | 'insertion'\n create: () => any\n destroy: (() => void) | void\n deps: ReadonlyArray<unknown> | undefined\n}\n\nexport interface Fiber {\n tag: FiberTag\n type: any\n key: string | null\n ref: Ref<any> | null\n pendingProps: any\n memoizedProps: any\n memoizedState: any\n stateNode: any\n dom: Node | null\n parent: Fiber | null\n child: Fiber | null\n sibling: Fiber | null\n hooks: Hook | null\n effects: Effect[] | null\n layoutEffects: Effect[] | null\n cleanups: Array<() => void> | null\n flags: FiberFlag\n dirty: boolean\n unmounted: boolean\n root: FiberRoot | null\n}\n\nexport interface FiberRoot {\n container: Element | DocumentFragment\n current: Fiber\n pending: Set<Fiber>\n scheduled: boolean\n onRecoverableError?: (err: unknown) => void\n onCaughtError?: (err: unknown) => void\n onUncaughtError?: (err: unknown) => void\n identifierPrefix: string\n hydrating: boolean\n}\n\nexport function createFiber(tag: FiberTag, type: any, key: string | null): Fiber {\n return {\n tag,\n type,\n key,\n ref: null,\n pendingProps: null,\n memoizedProps: null,\n memoizedState: null,\n stateNode: null,\n dom: null,\n parent: null,\n child: null,\n sibling: null,\n hooks: null,\n effects: null,\n layoutEffects: null,\n cleanups: null,\n flags: FiberFlag.None,\n dirty: false,\n unmounted: false,\n root: null,\n }\n}\n\nexport type ChildNode = ReactElement | string | number | boolean | null | undefined | ChildNode[]\nexport type { ReactElement, ReactNode }\n"],
4
+ "sourcesContent": ["import type { ReactElement, ReactNode, Ref } from './types'\n\nexport const enum FiberTag {\n Host = 0,\n Text = 1,\n Function = 2,\n Class = 3,\n Fragment = 4,\n Portal = 5,\n Provider = 6,\n Consumer = 7,\n ForwardRef = 8,\n Memo = 9,\n Lazy = 10,\n Suspense = 11,\n Root = 12,\n}\n\nexport const enum FiberFlag {\n None = 0,\n Placement = 1 << 0,\n Update = 1 << 1,\n Deletion = 1 << 2,\n Ref = 1 << 3,\n Effect = 1 << 4,\n LayoutEffect = 1 << 5,\n ContentReset = 1 << 6,\n DidCapture = 1 << 7,\n}\n\nexport interface Hook {\n state: any\n queue: any\n deps: any\n cleanup: any\n next: Hook | null\n}\n\nexport interface Effect {\n tag: 'effect' | 'layout' | 'insertion'\n create: () => any\n destroy: (() => void) | void\n deps: ReadonlyArray<unknown> | undefined\n}\n\nexport interface Fiber {\n tag: FiberTag\n type: any\n key: string | null\n ref: Ref<any> | null\n pendingProps: any\n memoizedProps: any\n memoizedState: any\n stateNode: any\n dom: Node | null\n parent: Fiber | null\n child: Fiber | null\n sibling: Fiber | null\n hooks: Hook | null\n effects: Effect[] | null\n layoutEffects: Effect[] | null\n cleanups: Array<() => void> | null\n flags: FiberFlag\n dirty: boolean\n unmounted: boolean\n root: FiberRoot | null\n}\n\nexport interface FiberRoot {\n container: Element | DocumentFragment\n current: Fiber\n pending: Set<Fiber>\n scheduled: boolean\n onRecoverableError?: ((err: unknown) => void) | undefined\n onCaughtError?: ((err: unknown) => void) | undefined\n onUncaughtError?: ((err: unknown) => void) | undefined\n identifierPrefix: string\n hydrating: boolean\n}\n\nexport function createFiber(tag: FiberTag, type: any, key: string | null): Fiber {\n return {\n tag,\n type,\n key,\n ref: null,\n pendingProps: null,\n memoizedProps: null,\n memoizedState: null,\n stateNode: null,\n dom: null,\n parent: null,\n child: null,\n sibling: null,\n hooks: null,\n effects: null,\n layoutEffects: null,\n cleanups: null,\n flags: FiberFlag.None,\n dirty: false,\n unmounted: false,\n root: null,\n }\n}\n\nexport type ChildNode = ReactElement | string | number | boolean | null | undefined | ChildNode[]\nexport type { ReactElement, ReactNode }\n"],
5
5
  "mappings": ";AAEO,IAAW,WAAX,kBAAWA,cAAX;AACL,EAAAA,oBAAA,UAAO,KAAP;AACA,EAAAA,oBAAA,UAAO,KAAP;AACA,EAAAA,oBAAA,cAAW,KAAX;AACA,EAAAA,oBAAA,WAAQ,KAAR;AACA,EAAAA,oBAAA,cAAW,KAAX;AACA,EAAAA,oBAAA,YAAS,KAAT;AACA,EAAAA,oBAAA,cAAW,KAAX;AACA,EAAAA,oBAAA,cAAW,KAAX;AACA,EAAAA,oBAAA,gBAAa,KAAb;AACA,EAAAA,oBAAA,UAAO,KAAP;AACA,EAAAA,oBAAA,UAAO,MAAP;AACA,EAAAA,oBAAA,cAAW,MAAX;AACA,EAAAA,oBAAA,UAAO,MAAP;AAbgB,SAAAA;AAAA,GAAA;AAgBX,IAAW,YAAX,kBAAWC,eAAX;AACL,EAAAA,sBAAA,UAAO,KAAP;AACA,EAAAA,sBAAA,eAAY,KAAZ;AACA,EAAAA,sBAAA,YAAS,KAAT;AACA,EAAAA,sBAAA,cAAW,KAAX;AACA,EAAAA,sBAAA,SAAM,KAAN;AACA,EAAAA,sBAAA,YAAS,MAAT;AACA,EAAAA,sBAAA,kBAAe,MAAf;AACA,EAAAA,sBAAA,kBAAe,MAAf;AACA,EAAAA,sBAAA,gBAAa,OAAb;AATgB,SAAAA;AAAA,GAAA;AA8DX,SAAS,YAAY,KAAe,MAAW,KAA2B;AAC/E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL,cAAc;AAAA,IACd,eAAe;AAAA,IACf,eAAe;AAAA,IACf,WAAW;AAAA,IACX,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,IACT,OAAO;AAAA,IACP,SAAS;AAAA,IACT,eAAe;AAAA,IACf,UAAU;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,WAAW;AAAA,IACX,MAAM;AAAA,EACR;AACF;",
6
6
  "names": ["FiberTag", "FiberFlag"]
7
7
  }
@@ -1,3 +1,9 @@
1
1
  import './features';
2
2
  export { createRoot, hydrateRoot } from './root';
3
3
  export type { Root, RootOptions } from './root';
4
+ import { createRoot, hydrateRoot } from './root';
5
+ declare const _default: {
6
+ createRoot: typeof createRoot;
7
+ hydrateRoot: typeof hydrateRoot;
8
+ };
9
+ export default _default;
@@ -1,8 +1,14 @@
1
1
  // packages/redact/src/dom/client.ts
2
2
  import "./features";
3
3
  import { createRoot, hydrateRoot } from "./root";
4
+ import { createRoot as createRoot2, hydrateRoot as hydrateRoot2 } from "./root";
5
+ var client_default = {
6
+ createRoot: createRoot2,
7
+ hydrateRoot: hydrateRoot2
8
+ };
4
9
  export {
5
10
  createRoot,
11
+ client_default as default,
6
12
  hydrateRoot
7
13
  };
8
14
  //# sourceMappingURL=client.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dom/client.ts"],
4
- "sourcesContent": ["import './features'\n\nexport { createRoot, hydrateRoot } from './root'\nexport type { Root, RootOptions } from './root'\n"],
5
- "mappings": ";AAAA,OAAO;AAEP,SAAS,YAAY,mBAAmB;",
6
- "names": []
4
+ "sourcesContent": ["import './features'\n\nexport { createRoot, hydrateRoot } from './root'\nexport type { Root, RootOptions } from './root'\n\n// Default export \u2014 real React's `react-dom/client` is named-only too, but\n// bundlers synthesize a default from the CJS `module.exports` object.\n// Redact ships pure ESM, so without an explicit default, strict bundlers\n// (rolldown, modern Vite) reject `import ReactDOM from 'react-dom/client'`.\nimport { createRoot, hydrateRoot } from './root'\nexport default {\n createRoot,\n hydrateRoot,\n}\n"],
5
+ "mappings": ";AAAA,OAAO;AAEP,SAAS,YAAY,mBAAmB;AAOxC,SAAS,cAAAA,aAAY,eAAAC,oBAAmB;AACxC,IAAO,iBAAQ;AAAA,EACb,YAAAD;AAAA,EACA,aAAAC;AACF;",
6
+ "names": ["createRoot", "hydrateRoot"]
7
7
  }
@@ -0,0 +1 @@
1
+ export declare function c(size: number): Array<unknown>;
@@ -0,0 +1,16 @@
1
+ // packages/redact/src/react/compiler-runtime.ts
2
+ import { useRef } from "./hooks";
3
+ var MEMO_CACHE_SENTINEL = /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel");
4
+ function c(size) {
5
+ const ref = useRef(null);
6
+ if (ref.current === null) {
7
+ const arr = new Array(size);
8
+ for (let i = 0; i < size; i++) arr[i] = MEMO_CACHE_SENTINEL;
9
+ ref.current = arr;
10
+ }
11
+ return ref.current;
12
+ }
13
+ export {
14
+ c
15
+ };
16
+ //# sourceMappingURL=compiler-runtime.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/react/compiler-runtime.ts"],
4
+ "sourcesContent": ["// React Compiler runtime \u2014 emitted code calls `c(size)` to obtain a\n// per-component-instance memo cache. Each slot starts as a sentinel; the\n// compiled code overwrites slots with computed values and uses sentinel\n// identity to detect first-run / dependency-change.\n//\n// The cache must persist across renders of the same fiber, so we lean on\n// `useRef`. Slots are filled with the canonical\n// `Symbol.for('react.memo_cache_sentinel')` so any tooling that compares\n// against the same well-known symbol stays interoperable.\nimport { useRef } from './hooks'\n\nconst MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel')\n\nexport function c(size: number): Array<unknown> {\n const ref = useRef<Array<unknown> | null>(null)\n if (ref.current === null) {\n const arr = new Array<unknown>(size)\n for (let i = 0; i < size; i++) arr[i] = MEMO_CACHE_SENTINEL\n ref.current = arr\n }\n return ref.current\n}\n"],
5
+ "mappings": ";AASA,SAAS,cAAc;AAEvB,IAAM,sBAAsB,uBAAO,IAAI,2BAA2B;AAE3D,SAAS,EAAE,MAA8B;AAC9C,QAAM,MAAM,OAA8B,IAAI;AAC9C,MAAI,IAAI,YAAY,MAAM;AACxB,UAAM,MAAM,IAAI,MAAe,IAAI;AACnC,aAAS,IAAI,GAAG,IAAI,MAAM,IAAK,KAAI,CAAC,IAAI;AACxC,QAAI,UAAU;AAAA,EAChB;AACA,SAAO,IAAI;AACb;",
6
+ "names": []
7
+ }
@@ -23,7 +23,12 @@ export declare function useId(): string;
23
23
  export declare function useTransition(): [boolean, (fn: () => void) => void];
24
24
  export declare function useDeferredValue<T>(v: T): T;
25
25
  export declare function useSyncExternalStore<T>(subscribe: (cb: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T): T;
26
- export declare function use<T>(resource: any): T;
26
+ export declare function use<T>(resource: PromiseLike<T> | {
27
+ _currentValue: T;
28
+ } | {
29
+ $$typeof: symbol;
30
+ _currentValue: T;
31
+ }): T;
27
32
  export declare function startTransition(fn: () => void): void;
28
33
  export declare function useActionState<S, P>(_action: (state: Awaited<S>, payload: P) => S | Promise<S>, initial: Awaited<S>): [Awaited<S>, (payload: P) => void, boolean];
29
34
  export declare function useFormStatus(): {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/react/hooks.ts"],
4
- "sourcesContent": ["import type {\n Dispatch,\n SetStateAction,\n EffectCallback,\n DependencyList,\n} from '../core'\nimport type { Context } from './context'\nimport { getDispatcher } from './shared-internals'\n\nexport function useState<S>(initial: S | (() => S)): [S, Dispatch<SetStateAction<S>>] {\n return getDispatcher().useState(initial)\n}\n\nexport function useReducer<S, A>(\n reducer: (s: S, a: A) => S,\n initial: any,\n init?: (a: any) => S,\n): [S, Dispatch<A>] {\n return getDispatcher().useReducer(reducer, initial, init)\n}\n\nexport function useEffect(create: EffectCallback, deps?: DependencyList): void {\n getDispatcher().useEffect(create, deps)\n}\n\nexport function useLayoutEffect(create: EffectCallback, deps?: DependencyList): void {\n getDispatcher().useLayoutEffect(create, deps)\n}\n\nexport function useInsertionEffect(create: EffectCallback, deps?: DependencyList): void {\n getDispatcher().useInsertionEffect(create, deps)\n}\n\nexport function useRef<T>(initial: T): { current: T }\nexport function useRef<T>(initial: T | null): { current: T | null }\nexport function useRef<T = undefined>(): { current: T | undefined }\nexport function useRef(initial?: any): { current: any } {\n return getDispatcher().useRef(initial)\n}\n\nexport function useMemo<T>(factory: () => T, deps?: DependencyList): T {\n return getDispatcher().useMemo(factory, deps)\n}\n\nexport function useCallback<T extends Function>(fn: T, deps?: DependencyList): T {\n return getDispatcher().useCallback(fn, deps)\n}\n\nexport function useContext<T>(ctx: Context<T>): T {\n return getDispatcher().useContext(ctx)\n}\n\nexport function useImperativeHandle<T>(\n ref: any,\n factory: () => T,\n deps?: DependencyList,\n): void {\n getDispatcher().useImperativeHandle(ref, factory, deps)\n}\n\nexport function useDebugValue<T>(value: T, formatter?: (v: T) => any): void {\n getDispatcher().useDebugValue(value, formatter)\n}\n\nexport function useId(): string {\n return getDispatcher().useId()\n}\n\nexport function useTransition(): [boolean, (fn: () => void) => void] {\n return getDispatcher().useTransition()\n}\n\nexport function useDeferredValue<T>(v: T): T {\n return getDispatcher().useDeferredValue(v)\n}\n\nexport function useSyncExternalStore<T>(\n subscribe: (cb: () => void) => () => void,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n): T {\n return getDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)\n}\n\nexport function use<T>(resource: any): T {\n return getDispatcher().use(resource)\n}\n\nexport function startTransition(fn: () => void): void {\n fn()\n}\n\nexport function useActionState<S, P>(\n _action: (state: Awaited<S>, payload: P) => S | Promise<S>,\n initial: Awaited<S>,\n): [Awaited<S>, (payload: P) => void, boolean] {\n return [initial, () => {}, false]\n}\n\nexport function useFormStatus() {\n return { pending: false, data: null, method: null, action: null }\n}\n\nexport function useOptimistic<S, A = S>(\n state: S,\n _updateFn?: (s: S, a: A) => S,\n): [S, (action: A) => void] {\n return [state, () => {}]\n}\n\n// Composed hook \u2014 returns a stable callback that always invokes the latest\n// `fn`. The ref is updated in useInsertionEffect so any useLayoutEffect /\n// useEffect reading ref.current in the next commit sees the fresh function.\nexport function useEffectEvent<Args extends unknown[], Return>(\n fn: (...args: Args) => Return,\n): (...args: Args) => Return {\n const ref = useRef(fn)\n useInsertionEffect(() => {\n ref.current = fn\n })\n return useCallback(\n ((...args: Args) => ref.current(...args)) as (...args: Args) => Return,\n [],\n )\n}\n\n// `useSyncExternalStoreWithSelector` \u2014 provided here so consumers (like\n// @tanstack/react-store) that historically import from\n// `use-sync-external-store/shim/with-selector` can be aliased to this\n// package via the @tanstack/redact/vite plugin. The CJS shim is unsuitable\n// for Cloudflare Workers (it does `var React = require('react')` which\n// fails in workerd). Implementation matches React's reference impl \u2014\n// selector + isEqual gate to avoid re-renders when the selected slice is\n// unchanged across snapshots.\nexport function useSyncExternalStoreWithSelector<Snapshot, Selection>(\n subscribe: (cb: () => void) => () => void,\n getSnapshot: () => Snapshot,\n getServerSnapshot: (() => Snapshot) | undefined,\n selector: (snapshot: Snapshot) => Selection,\n isEqual?: (a: Selection, b: Selection) => boolean,\n): Selection {\n const instRef = useRef<{ hasValue: boolean; value: Selection | null } | null>(null)\n let inst: { hasValue: boolean; value: Selection | null }\n if (instRef.current === null) {\n inst = { hasValue: false, value: null }\n instRef.current = inst\n } else {\n inst = instRef.current\n }\n\n const [getSelection, getServerSelection] = useMemo(() => {\n let hasMemo = false\n let memoizedSnapshot: Snapshot\n let memoizedSelection: Selection\n const memoizedSelector = (nextSnapshot: Snapshot): Selection => {\n if (!hasMemo) {\n hasMemo = true\n memoizedSnapshot = nextSnapshot\n const nextSelection = selector(nextSnapshot)\n if (isEqual !== undefined && inst.hasValue) {\n const currentSelection = inst.value as Selection\n if (isEqual(currentSelection, nextSelection)) {\n memoizedSelection = currentSelection\n return currentSelection\n }\n }\n memoizedSelection = nextSelection\n return nextSelection\n }\n const prevSnapshot: Snapshot = memoizedSnapshot\n const prevSelection: Selection = memoizedSelection\n if (Object.is(prevSnapshot, nextSnapshot)) return prevSelection\n const nextSelection = selector(nextSnapshot)\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) return prevSelection\n memoizedSnapshot = nextSnapshot\n memoizedSelection = nextSelection\n return nextSelection\n }\n const get = () => memoizedSelector(getSnapshot())\n const getServer =\n getServerSnapshot === undefined ? undefined : () => memoizedSelector(getServerSnapshot())\n return [get, getServer] as const\n }, [getSnapshot, getServerSnapshot, selector, isEqual])\n\n const value = useSyncExternalStore(subscribe, getSelection, getServerSelection)\n useDebugValue(value)\n inst.hasValue = true\n inst.value = value\n return value\n}\n"],
5
- "mappings": ";AAOA,SAAS,qBAAqB;AAEvB,SAAS,SAAY,SAA0D;AACpF,SAAO,cAAc,EAAE,SAAS,OAAO;AACzC;AAEO,SAAS,WACd,SACA,SACA,MACkB;AAClB,SAAO,cAAc,EAAE,WAAW,SAAS,SAAS,IAAI;AAC1D;AAEO,SAAS,UAAU,QAAwB,MAA6B;AAC7E,gBAAc,EAAE,UAAU,QAAQ,IAAI;AACxC;AAEO,SAAS,gBAAgB,QAAwB,MAA6B;AACnF,gBAAc,EAAE,gBAAgB,QAAQ,IAAI;AAC9C;AAEO,SAAS,mBAAmB,QAAwB,MAA6B;AACtF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B,WAAW,cAAc,kBAAkB;AAC9E,gBAAc,KAAK;AACnB,OAAK,WAAW;AAChB,OAAK,QAAQ;AACb,SAAO;AACT;",
4
+ "sourcesContent": ["import type {\n Dispatch,\n SetStateAction,\n EffectCallback,\n DependencyList,\n} from '../core'\nimport type { Context } from './context'\nimport { getDispatcher } from './shared-internals'\n\nexport function useState<S>(initial: S | (() => S)): [S, Dispatch<SetStateAction<S>>] {\n return getDispatcher().useState(initial)\n}\n\nexport function useReducer<S, A>(\n reducer: (s: S, a: A) => S,\n initial: any,\n init?: (a: any) => S,\n): [S, Dispatch<A>] {\n return getDispatcher().useReducer(reducer, initial, init)\n}\n\nexport function useEffect(create: EffectCallback, deps?: DependencyList): void {\n getDispatcher().useEffect(create, deps)\n}\n\nexport function useLayoutEffect(create: EffectCallback, deps?: DependencyList): void {\n getDispatcher().useLayoutEffect(create, deps)\n}\n\nexport function useInsertionEffect(create: EffectCallback, deps?: DependencyList): void {\n getDispatcher().useInsertionEffect(create, deps)\n}\n\nexport function useRef<T>(initial: T): { current: T }\nexport function useRef<T>(initial: T | null): { current: T | null }\nexport function useRef<T = undefined>(): { current: T | undefined }\nexport function useRef(initial?: any): { current: any } {\n return getDispatcher().useRef(initial)\n}\n\nexport function useMemo<T>(factory: () => T, deps?: DependencyList): T {\n return getDispatcher().useMemo(factory, deps)\n}\n\nexport function useCallback<T extends Function>(fn: T, deps?: DependencyList): T {\n return getDispatcher().useCallback(fn, deps)\n}\n\nexport function useContext<T>(ctx: Context<T>): T {\n return getDispatcher().useContext(ctx)\n}\n\nexport function useImperativeHandle<T>(\n ref: any,\n factory: () => T,\n deps?: DependencyList,\n): void {\n getDispatcher().useImperativeHandle(ref, factory, deps)\n}\n\nexport function useDebugValue<T>(value: T, formatter?: (v: T) => any): void {\n getDispatcher().useDebugValue(value, formatter)\n}\n\nexport function useId(): string {\n return getDispatcher().useId()\n}\n\nexport function useTransition(): [boolean, (fn: () => void) => void] {\n return getDispatcher().useTransition()\n}\n\nexport function useDeferredValue<T>(v: T): T {\n return getDispatcher().useDeferredValue(v)\n}\n\nexport function useSyncExternalStore<T>(\n subscribe: (cb: () => void) => () => void,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n): T {\n return getDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)\n}\n\nexport function use<T>(resource: PromiseLike<T> | { _currentValue: T } | { $$typeof: symbol; _currentValue: T }): T {\n return getDispatcher().use(resource)\n}\n\nexport function startTransition(fn: () => void): void {\n fn()\n}\n\nexport function useActionState<S, P>(\n _action: (state: Awaited<S>, payload: P) => S | Promise<S>,\n initial: Awaited<S>,\n): [Awaited<S>, (payload: P) => void, boolean] {\n return [initial, () => {}, false]\n}\n\nexport function useFormStatus() {\n return { pending: false, data: null, method: null, action: null }\n}\n\nexport function useOptimistic<S, A = S>(\n state: S,\n _updateFn?: (s: S, a: A) => S,\n): [S, (action: A) => void] {\n return [state, () => {}]\n}\n\n// Composed hook \u2014 returns a stable callback that always invokes the latest\n// `fn`. The ref is updated in useInsertionEffect so any useLayoutEffect /\n// useEffect reading ref.current in the next commit sees the fresh function.\nexport function useEffectEvent<Args extends unknown[], Return>(\n fn: (...args: Args) => Return,\n): (...args: Args) => Return {\n const ref = useRef(fn)\n useInsertionEffect(() => {\n ref.current = fn\n })\n return useCallback(\n ((...args: Args) => ref.current(...args)) as (...args: Args) => Return,\n [],\n )\n}\n\n// `useSyncExternalStoreWithSelector` \u2014 provided here so consumers (like\n// @tanstack/react-store) that historically import from\n// `use-sync-external-store/shim/with-selector` can be aliased to this\n// package via the @tanstack/redact/vite plugin. The CJS shim is unsuitable\n// for Cloudflare Workers (it does `var React = require('react')` which\n// fails in workerd). Implementation matches React's reference impl \u2014\n// selector + isEqual gate to avoid re-renders when the selected slice is\n// unchanged across snapshots.\nexport function useSyncExternalStoreWithSelector<Snapshot, Selection>(\n subscribe: (cb: () => void) => () => void,\n getSnapshot: () => Snapshot,\n getServerSnapshot: (() => Snapshot) | undefined,\n selector: (snapshot: Snapshot) => Selection,\n isEqual?: (a: Selection, b: Selection) => boolean,\n): Selection {\n const instRef = useRef<{ hasValue: boolean; value: Selection | null } | null>(null)\n let inst: { hasValue: boolean; value: Selection | null }\n if (instRef.current === null) {\n inst = { hasValue: false, value: null }\n instRef.current = inst\n } else {\n inst = instRef.current\n }\n\n const [getSelection, getServerSelection] = useMemo(() => {\n let hasMemo = false\n let memoizedSnapshot: Snapshot\n let memoizedSelection: Selection\n const memoizedSelector = (nextSnapshot: Snapshot): Selection => {\n if (!hasMemo) {\n hasMemo = true\n memoizedSnapshot = nextSnapshot\n const nextSelection = selector(nextSnapshot)\n if (isEqual !== undefined && inst.hasValue) {\n const currentSelection = inst.value as Selection\n if (isEqual(currentSelection, nextSelection)) {\n memoizedSelection = currentSelection\n return currentSelection\n }\n }\n memoizedSelection = nextSelection\n return nextSelection\n }\n const prevSnapshot: Snapshot = memoizedSnapshot\n const prevSelection: Selection = memoizedSelection\n if (Object.is(prevSnapshot, nextSnapshot)) return prevSelection\n const nextSelection = selector(nextSnapshot)\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) return prevSelection\n memoizedSnapshot = nextSnapshot\n memoizedSelection = nextSelection\n return nextSelection\n }\n const get = () => memoizedSelector(getSnapshot())\n const getServer =\n getServerSnapshot === undefined ? undefined : () => memoizedSelector(getServerSnapshot())\n return [get, getServer] as const\n }, [getSnapshot, getServerSnapshot, selector, isEqual])\n\n const value = useSyncExternalStore(subscribe, getSelection, getServerSelection)\n useDebugValue(value)\n inst.hasValue = true\n inst.value = value\n return value\n}\n"],
5
+ "mappings": ";AAOA,SAAS,qBAAqB;AAEvB,SAAS,SAAY,SAA0D;AACpF,SAAO,cAAc,EAAE,SAAS,OAAO;AACzC;AAEO,SAAS,WACd,SACA,SACA,MACkB;AAClB,SAAO,cAAc,EAAE,WAAW,SAAS,SAAS,IAAI;AAC1D;AAEO,SAAS,UAAU,QAAwB,MAA6B;AAC7E,gBAAc,EAAE,UAAU,QAAQ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iBAAiB,kBAAkB,CAAC;AAC1F,WAAO,CAAC,KAAK,SAAS;AAAA,EACxB,GAAG,CAAC,aAAa,mBAAmB,UAAU,OAAO,CAAC;AAEtD,QAAM,QAAQ,qBAAqB,WAAW,cAAc,kBAAkB;AAC9E,gBAAc,KAAK;AACnB,OAAK,WAAW;AAChB,OAAK,QAAQ;AACb,SAAO;AACT;",
6
6
  "names": ["nextSelection"]
7
7
  }
@@ -1,4 +1,8 @@
1
1
  export { createElement, cloneElement, isValidElement, createRef, Fragment } from './element';
2
+ export type { ReactElement, ReactNode, Key, Ref, RefObject, RefCallback, Dispatch, SetStateAction, EffectCallback, DependencyList, } from '../core';
3
+ export type FC<P = {}> = (props: P & {
4
+ children?: import('../core').ReactNode;
5
+ }) => import('../core').ReactElement | null;
2
6
  export { useState, useReducer, useEffect, useLayoutEffect, useInsertionEffect, useRef, useMemo, useCallback, useContext, useImperativeHandle, useDebugValue, useId, useTransition, useDeferredValue, useSyncExternalStore, useSyncExternalStoreWithSelector, use, useActionState, useFormStatus, useOptimistic, useEffectEvent, startTransition, } from './hooks';
3
7
  export { createContext, REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE, REACT_CONSUMER_TYPE, type Context, type ProviderExoticComponent, type ConsumerExoticComponent, } from './context';
4
8
  export { Component, PureComponent } from './class';
@@ -23,8 +27,8 @@ declare const _default: {
23
27
  isValidElement: typeof isValidElement;
24
28
  createRef: typeof createRef;
25
29
  Fragment: (props: {
26
- children?: import("../core").ReactNode;
27
- }) => import("../core").ReactElement;
30
+ children?: import(".").ReactNode;
31
+ }) => import(".").ReactElement;
28
32
  useState: typeof useState;
29
33
  useReducer: typeof useReducer;
30
34
  useEffect: typeof useEffect;
@@ -65,11 +69,11 @@ declare const _default: {
65
69
  children?: any;
66
70
  }) => any;
67
71
  Children: {
68
- map(children: import("../core").ReactNode, fn: (child: import("../core").ReactNode, index: number) => any): any[] | null;
69
- forEach(children: import("../core").ReactNode, fn: (child: import("../core").ReactNode, index: number) => void): void;
70
- count(children: import("../core").ReactNode): number;
71
- toArray(children: import("../core").ReactNode): any[];
72
- only(children: import("../core").ReactNode): import("../core").ReactElement;
72
+ map(children: import(".").ReactNode, fn: (child: import(".").ReactNode, index: number) => any): any[] | null;
73
+ forEach(children: import(".").ReactNode, fn: (child: import(".").ReactNode, index: number) => void): void;
74
+ count(children: import(".").ReactNode): number;
75
+ toArray(children: import(".").ReactNode): any[];
76
+ only(children: import(".").ReactNode): import(".").ReactElement;
73
77
  };
74
78
  version: string;
75
79
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/react/index.ts"],
4
- "sourcesContent": ["export { createElement, cloneElement, isValidElement, createRef, Fragment } from './element'\nexport {\n useState,\n useReducer,\n useEffect,\n useLayoutEffect,\n useInsertionEffect,\n useRef,\n useMemo,\n useCallback,\n useContext,\n useImperativeHandle,\n useDebugValue,\n useId,\n useTransition,\n useDeferredValue,\n useSyncExternalStore,\n useSyncExternalStoreWithSelector,\n use,\n useActionState,\n useFormStatus,\n useOptimistic,\n useEffectEvent,\n startTransition,\n} from './hooks'\nexport {\n createContext,\n REACT_CONTEXT_TYPE,\n REACT_PROVIDER_TYPE,\n REACT_CONSUMER_TYPE,\n type Context,\n type ProviderExoticComponent,\n type ConsumerExoticComponent,\n} from './context'\nexport { Component, PureComponent } from './class'\nexport {\n memo, forwardRef, lazy,\n REACT_MEMO_TYPE,\n REACT_FORWARD_REF_TYPE,\n REACT_LAZY_TYPE,\n} from './memo'\nexport {\n Suspense, StrictMode, Profiler,\n REACT_SUSPENSE_TYPE,\n REACT_STRICT_MODE_TYPE,\n REACT_PROFILER_TYPE,\n} from './suspense'\nexport { REACT_PORTAL_TYPE } from './portal'\nexport { Children } from './children'\nexport { ReactSharedInternals } from './shared-internals'\n\n// Stub exports\nexport const cache = <T extends Function>(fn: T): T => fn\nexport const act = async (fn: () => any) => {\n const r = fn()\n if (r && typeof r.then === 'function') await r\n}\nexport function taintUniqueValue(_msg: string, _lifetime: any, _value: any): void {}\nexport function taintObjectReference(_msg: string, _object: any): void {}\n\nexport const version = '19.2.3'\n\n// Default export for `import React from 'react'` usage\nimport { createElement, cloneElement, isValidElement, createRef, Fragment } from './element'\nimport {\n useState,\n useReducer,\n useEffect,\n useLayoutEffect,\n useInsertionEffect,\n useRef,\n useMemo,\n useCallback,\n useContext,\n useImperativeHandle,\n useDebugValue,\n useId,\n useTransition,\n useDeferredValue,\n useSyncExternalStore,\n use,\n useActionState,\n useFormStatus,\n useOptimistic,\n useEffectEvent,\n startTransition,\n} from './hooks'\nimport { createContext } from './context'\nimport { Component, PureComponent } from './class'\nimport { memo, forwardRef, lazy } from './memo'\nimport { Suspense, StrictMode, Profiler } from './suspense'\nimport { Children } from './children'\n\nexport default {\n createElement,\n cloneElement,\n isValidElement,\n createRef,\n Fragment,\n useState,\n useReducer,\n useEffect,\n useLayoutEffect,\n useInsertionEffect,\n useRef,\n useMemo,\n useCallback,\n useContext,\n useImperativeHandle,\n useDebugValue,\n useId,\n useTransition,\n useDeferredValue,\n useSyncExternalStore,\n use,\n useActionState,\n useFormStatus,\n useOptimistic,\n useEffectEvent,\n startTransition,\n createContext,\n Component,\n PureComponent,\n memo,\n forwardRef,\n lazy,\n Suspense,\n StrictMode,\n Profiler,\n Children,\n version: '19.2.3',\n}\n"],
5
- "mappings": ";AAAA,SAAS,eAAe,cAAc,gBAAgB,WAAW,gBAAgB;AACjF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,WAAW,qBAAqB;AACz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A,cAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,OAAAC;AAAA,EACA,eAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,KAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,MAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAS;AACX;",
4
+ "sourcesContent": ["export { createElement, cloneElement, isValidElement, createRef, Fragment } from './element'\nexport type {\n ReactElement,\n ReactNode,\n Key,\n Ref,\n RefObject,\n RefCallback,\n Dispatch,\n SetStateAction,\n EffectCallback,\n DependencyList,\n} from '../core'\n\n// Lightweight functional-component alias \u2014 matches React's FC shape closely\n// enough for the common `const X: FC<P> = (props) => \u2026` pattern used in\n// tests and downstream consumer code.\nexport type FC<P = {}> = (props: P & { children?: import('../core').ReactNode }) => import('../core').ReactElement | null\nexport {\n useState,\n useReducer,\n useEffect,\n useLayoutEffect,\n useInsertionEffect,\n useRef,\n useMemo,\n useCallback,\n useContext,\n useImperativeHandle,\n useDebugValue,\n useId,\n useTransition,\n useDeferredValue,\n useSyncExternalStore,\n useSyncExternalStoreWithSelector,\n use,\n useActionState,\n useFormStatus,\n useOptimistic,\n useEffectEvent,\n startTransition,\n} from './hooks'\nexport {\n createContext,\n REACT_CONTEXT_TYPE,\n REACT_PROVIDER_TYPE,\n REACT_CONSUMER_TYPE,\n type Context,\n type ProviderExoticComponent,\n type ConsumerExoticComponent,\n} from './context'\nexport { Component, PureComponent } from './class'\nexport {\n memo, forwardRef, lazy,\n REACT_MEMO_TYPE,\n REACT_FORWARD_REF_TYPE,\n REACT_LAZY_TYPE,\n} from './memo'\nexport {\n Suspense, StrictMode, Profiler,\n REACT_SUSPENSE_TYPE,\n REACT_STRICT_MODE_TYPE,\n REACT_PROFILER_TYPE,\n} from './suspense'\nexport { REACT_PORTAL_TYPE } from './portal'\nexport { Children } from './children'\nexport { ReactSharedInternals } from './shared-internals'\n\n// Stub exports\nexport const cache = <T extends Function>(fn: T): T => fn\nexport const act = async (fn: () => any) => {\n const r = fn()\n if (r && typeof r.then === 'function') await r\n}\nexport function taintUniqueValue(_msg: string, _lifetime: any, _value: any): void {}\nexport function taintObjectReference(_msg: string, _object: any): void {}\n\nexport const version = '19.2.3'\n\n// Default export for `import React from 'react'` usage\nimport { createElement, cloneElement, isValidElement, createRef, Fragment } from './element'\nimport {\n useState,\n useReducer,\n useEffect,\n useLayoutEffect,\n useInsertionEffect,\n useRef,\n useMemo,\n useCallback,\n useContext,\n useImperativeHandle,\n useDebugValue,\n useId,\n useTransition,\n useDeferredValue,\n useSyncExternalStore,\n use,\n useActionState,\n useFormStatus,\n useOptimistic,\n useEffectEvent,\n startTransition,\n} from './hooks'\nimport { createContext } from './context'\nimport { Component, PureComponent } from './class'\nimport { memo, forwardRef, lazy } from './memo'\nimport { Suspense, StrictMode, Profiler } from './suspense'\nimport { Children } from './children'\n\nexport default {\n createElement,\n cloneElement,\n isValidElement,\n createRef,\n Fragment,\n useState,\n useReducer,\n useEffect,\n useLayoutEffect,\n useInsertionEffect,\n useRef,\n useMemo,\n useCallback,\n useContext,\n useImperativeHandle,\n useDebugValue,\n useId,\n useTransition,\n useDeferredValue,\n useSyncExternalStore,\n use,\n useActionState,\n useFormStatus,\n useOptimistic,\n useEffectEvent,\n startTransition,\n createContext,\n Component,\n PureComponent,\n memo,\n forwardRef,\n lazy,\n Suspense,\n StrictMode,\n Profiler,\n Children,\n version: '19.2.3',\n}\n"],
5
+ "mappings": ";AAAA,SAAS,eAAe,cAAc,gBAAgB,WAAW,gBAAgB;AAkBjF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,WAAW,qBAAqB;AACzC;AAAA,EACE;AAAA,EAAM;AAAA,EAAY;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EAAU;AAAA,EAAY;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AACzB,SAAS,4BAA4B;AAcrC,SAAS,iBAAAA,gBAAe,gBAAAC,eAAc,kBAAAC,iBAAgB,aAAAC,YAAW,YAAAC,iBAAgB;AACjF;AAAA,EACE,YAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,cAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,SAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,mBAAAC;AAAA,OACK;AACP,SAAS,iBAAAC,sBAAqB;AAC9B,SAAS,aAAAC,YAAW,iBAAAC,sBAAqB;AACzC,SAAS,QAAAC,OAAM,cAAAC,aAAY,QAAAC,aAAY;AACvC,SAAS,YAAAC,WAAU,cAAAC,aAAY,YAAAC,iBAAgB;AAC/C,SAAS,YAAAC,iBAAgB;AAvClB,IAAM,QAAQ,CAAqB,OAAa;AAChD,IAAM,MAAM,OAAO,OAAkB;AAC1C,QAAM,IAAI,GAAG;AACb,MAAI,KAAK,OAAO,EAAE,SAAS,WAAY,OAAM;AAC/C;AACO,SAAS,iBAAiB,MAAc,WAAgB,QAAmB;AAAC;AAC5E,SAAS,qBAAqB,MAAc,SAAoB;AAAC;AAEjE,IAAM,UAAU;AAiCvB,IAAO,gBAAQ;AAAA,EACb,eAAAnC;AAAA,EACA,cAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,OAAAC;AAAA,EACA,eAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,KAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,MAAAC;AAAA,EACA,YAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAS;AACX;",
6
6
  "names": ["createElement", "cloneElement", "isValidElement", "createRef", "Fragment", "useState", "useReducer", "useEffect", "useLayoutEffect", "useInsertionEffect", "useRef", "useMemo", "useCallback", "useContext", "useImperativeHandle", "useDebugValue", "useId", "useTransition", "useDeferredValue", "useSyncExternalStore", "use", "useActionState", "useFormStatus", "useOptimistic", "useEffectEvent", "startTransition", "createContext", "Component", "PureComponent", "memo", "forwardRef", "lazy", "Suspense", "StrictMode", "Profiler", "Children"]
7
7
  }
@@ -3,3 +3,16 @@ export { Fragment } from './element';
3
3
  export declare function jsx(type: any, props: any, key?: any): ReactElement;
4
4
  export declare const jsxs: typeof jsx;
5
5
  export declare const jsxDEV: typeof jsx;
6
+ export declare namespace JSX {
7
+ type Element = ReactElement;
8
+ type ElementType = any;
9
+ interface IntrinsicElements {
10
+ [elemName: string]: any;
11
+ }
12
+ interface ElementChildrenAttribute {
13
+ children: {};
14
+ }
15
+ interface ElementAttributesProperty {
16
+ props: {};
17
+ }
18
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/react/jsx-runtime.ts"],
4
- "sourcesContent": ["import { REACT_ELEMENT_TYPE, type ReactElement } from '../core'\n\nexport { Fragment } from './element'\n\nexport function jsx(type: any, props: any, key?: any): ReactElement {\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type,\n key: key == null ? null : '' + key,\n ref: props?.ref ?? null,\n props,\n }\n}\n\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n"],
4
+ "sourcesContent": ["import { REACT_ELEMENT_TYPE, type ReactElement } from '../core'\n\nexport { Fragment } from './element'\n\nexport function jsx(type: any, props: any, key?: any): ReactElement {\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type,\n key: key == null ? null : '' + key,\n ref: props?.ref ?? null,\n props,\n }\n}\n\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\n// Permissive JSX namespace \u2014 picked up by TypeScript via the\n// `jsxImportSource: \"@tanstack/redact\"` + `jsx: \"react-jsx\"` pair. The\n// runtime accepts any element type and any props; matching that with strict\n// element typings would require an entire React.dom.d.ts surface, which\n// isn't a stated goal of redact (consumers who want strict JSX still alias\n// `react`/`react-dom` types from the real packages).\nexport namespace JSX {\n export type Element = ReactElement\n export type ElementType = any\n export interface IntrinsicElements {\n [elemName: string]: any\n }\n export interface ElementChildrenAttribute {\n children: {}\n }\n export interface ElementAttributesProperty {\n props: {}\n }\n}\n"],
5
5
  "mappings": ";AAAA,SAAS,0BAA6C;AAEtD,SAAS,gBAAgB;AAElB,SAAS,IAAI,MAAW,OAAY,KAAyB;AAClE,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA,KAAK,OAAO,OAAO,OAAO,KAAK;AAAA,IAC/B,KAAK,OAAO,OAAO;AAAA,IACnB;AAAA,EACF;AACF;AAEO,IAAM,OAAO;AACb,IAAM,SAAS;",
6
6
  "names": []
7
7
  }
@@ -1,29 +1,20 @@
1
+ import type { ReactElement, ReactNode, Ref } from '../core';
1
2
  export declare const REACT_MEMO_TYPE: unique symbol;
2
3
  export declare const REACT_FORWARD_REF_TYPE: unique symbol;
3
4
  export declare const REACT_LAZY_TYPE: unique symbol;
4
- export declare function memo<P>(type: (props: P) => any, areEqual?: (prev: Readonly<P>, next: Readonly<P>) => boolean): {
5
- $$typeof: symbol;
6
- type: (props: P) => any;
7
- compare: (prev: Readonly<P>, next: Readonly<P>) => boolean;
5
+ export type ExoticComponent<P> = ((props: P & {
6
+ children?: ReactNode;
7
+ ref?: any;
8
+ key?: any;
9
+ }) => ReactElement | null) & {
10
+ readonly $$typeof: symbol;
8
11
  };
12
+ export declare function memo<P>(type: (props: P) => any, areEqual?: (prev: Readonly<P>, next: Readonly<P>) => boolean): ExoticComponent<P>;
9
13
  export declare function forwardRef<R, P = {}>(render: (props: P, ref: {
10
14
  current: R | null;
11
- } | ((r: R | null) => void) | null) => any): {
12
- $$typeof: symbol;
13
- render: (props: P, ref: {
14
- current: R | null;
15
- } | ((r: R | null) => void) | null) => any;
16
- };
15
+ } | ((r: R | null) => void) | null) => any): ExoticComponent<P & {
16
+ ref?: Ref<R>;
17
+ }>;
17
18
  export declare function lazy<T extends {
18
19
  default: any;
19
- }>(ctor: () => Promise<T>): {
20
- $$typeof: symbol;
21
- _payload: {
22
- status: -1 | 0 | 1 | 2;
23
- result: any;
24
- };
25
- _init: (p: {
26
- status: -1 | 0 | 1 | 2;
27
- result: any;
28
- }) => any;
29
- };
20
+ }>(ctor: () => Promise<T>): ExoticComponent<T['default'] extends (props: infer P) => any ? P : {}>;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/react/memo.ts"],
4
- "sourcesContent": ["export const REACT_MEMO_TYPE = Symbol.for('react.memo')\nexport const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref')\nexport const REACT_LAZY_TYPE = Symbol.for('react.lazy')\n\nexport function memo<P>(\n type: (props: P) => any,\n areEqual?: (prev: Readonly<P>, next: Readonly<P>) => boolean,\n) {\n return { $$typeof: REACT_MEMO_TYPE, type, compare: areEqual ?? null }\n}\n\nexport function forwardRef<R, P = {}>(\n render: (props: P, ref: { current: R | null } | ((r: R | null) => void) | null) => any,\n) {\n return { $$typeof: REACT_FORWARD_REF_TYPE, render }\n}\n\nexport function lazy<T extends { default: any }>(ctor: () => Promise<T>) {\n const payload = {\n status: -1 as -1 | 0 | 1 | 2,\n result: undefined as any,\n }\n return {\n $$typeof: REACT_LAZY_TYPE,\n _payload: payload,\n _init: (p: typeof payload): any => {\n if (p.status === 1) return p.result\n if (p.status === 2) throw p.result\n if (p.status === 0) throw p.result // pending promise\n const thenable = ctor().then(\n (mod) => {\n p.status = 1\n p.result = mod.default\n },\n (err) => {\n p.status = 2\n p.result = err\n },\n )\n p.status = 0\n p.result = thenable\n throw thenable\n },\n }\n}\n"],
5
- "mappings": ";AAAO,IAAM,kBAAkB,uBAAO,IAAI,YAAY;AAC/C,IAAM,yBAAyB,uBAAO,IAAI,mBAAmB;AAC7D,IAAM,kBAAkB,uBAAO,IAAI,YAAY;AAE/C,SAAS,KACd,MACA,UACA;AACA,SAAO,EAAE,UAAU,iBAAiB,MAAM,SAAS,YAAY,KAAK;AACtE;AAEO,SAAS,WACd,QACA;AACA,SAAO,EAAE,UAAU,wBAAwB,OAAO;AACpD;AAEO,SAAS,KAAiC,MAAwB;AACvE,QAAM,UAAU;AAAA,IACd,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACA,SAAO;AAAA,IACL,UAAU;AAAA,IACV,UAAU;AAAA,IACV,OAAO,CAAC,MAA2B;AACjC,UAAI,EAAE,WAAW,EAAG,QAAO,EAAE;AAC7B,UAAI,EAAE,WAAW,EAAG,OAAM,EAAE;AAC5B,UAAI,EAAE,WAAW,EAAG,OAAM,EAAE;AAC5B,YAAM,WAAW,KAAK,EAAE;AAAA,QACtB,CAAC,QAAQ;AACP,YAAE,SAAS;AACX,YAAE,SAAS,IAAI;AAAA,QACjB;AAAA,QACA,CAAC,QAAQ;AACP,YAAE,SAAS;AACX,YAAE,SAAS;AAAA,QACb;AAAA,MACF;AACA,QAAE,SAAS;AACX,QAAE,SAAS;AACX,YAAM;AAAA,IACR;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import type { ReactElement, ReactNode, Ref } from '../core'\n\nexport const REACT_MEMO_TYPE = Symbol.for('react.memo')\nexport const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref')\nexport const REACT_LAZY_TYPE = Symbol.for('react.lazy')\n\n// Component-shaped return type so JSX usage of memo/forwardRef/lazy results\n// type-checks. The runtime value is a `$$typeof`-tagged record that the\n// reconciler recognizes via type-matchers; the cast lets TypeScript treat\n// it as a callable component at JSX sites without changing what the runtime\n// actually does. `children` is included for the common\n// `<Comp>...</Comp>` form even when the inner P doesn't list it.\nexport type ExoticComponent<P> = ((\n props: P & { children?: ReactNode; ref?: any; key?: any },\n) => ReactElement | null) & {\n readonly $$typeof: symbol\n}\n\nexport function memo<P>(\n type: (props: P) => any,\n areEqual?: (prev: Readonly<P>, next: Readonly<P>) => boolean,\n): ExoticComponent<P> {\n return { $$typeof: REACT_MEMO_TYPE, type, compare: areEqual ?? null } as unknown as ExoticComponent<P>\n}\n\nexport function forwardRef<R, P = {}>(\n render: (props: P, ref: { current: R | null } | ((r: R | null) => void) | null) => any,\n): ExoticComponent<P & { ref?: Ref<R> }> {\n return { $$typeof: REACT_FORWARD_REF_TYPE, render } as unknown as ExoticComponent<P & { ref?: Ref<R> }>\n}\n\nexport function lazy<T extends { default: any }>(ctor: () => Promise<T>): ExoticComponent<\n T['default'] extends (props: infer P) => any ? P : {}\n> {\n const payload = {\n status: -1 as -1 | 0 | 1 | 2,\n result: undefined as any,\n }\n return {\n $$typeof: REACT_LAZY_TYPE,\n _payload: payload,\n _init: (p: typeof payload): any => {\n if (p.status === 1) return p.result\n if (p.status === 2) throw p.result\n if (p.status === 0) throw p.result // pending promise\n const thenable = ctor().then(\n (mod) => {\n p.status = 1\n p.result = mod.default\n },\n (err) => {\n p.status = 2\n p.result = err\n },\n )\n p.status = 0\n p.result = thenable\n throw thenable\n },\n } as unknown as ExoticComponent<T['default'] extends (props: infer P) => any ? P : {}>\n}\n"],
5
+ "mappings": ";AAEO,IAAM,kBAAkB,uBAAO,IAAI,YAAY;AAC/C,IAAM,yBAAyB,uBAAO,IAAI,mBAAmB;AAC7D,IAAM,kBAAkB,uBAAO,IAAI,YAAY;AAc/C,SAAS,KACd,MACA,UACoB;AACpB,SAAO,EAAE,UAAU,iBAAiB,MAAM,SAAS,YAAY,KAAK;AACtE;AAEO,SAAS,WACd,QACuC;AACvC,SAAO,EAAE,UAAU,wBAAwB,OAAO;AACpD;AAEO,SAAS,KAAiC,MAE/C;AACA,QAAM,UAAU;AAAA,IACd,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AACA,SAAO;AAAA,IACL,UAAU;AAAA,IACV,UAAU;AAAA,IACV,OAAO,CAAC,MAA2B;AACjC,UAAI,EAAE,WAAW,EAAG,QAAO,EAAE;AAC7B,UAAI,EAAE,WAAW,EAAG,OAAM,EAAE;AAC5B,UAAI,EAAE,WAAW,EAAG,OAAM,EAAE;AAC5B,YAAM,WAAW,KAAK,EAAE;AAAA,QACtB,CAAC,QAAQ;AACP,YAAE,SAAS;AACX,YAAE,SAAS,IAAI;AAAA,QACjB;AAAA,QACA,CAAC,QAAQ;AACP,YAAE,SAAS;AACX,YAAE,SAAS;AAAA,QACb;AAAA,MACF;AACA,QAAE,SAAS;AACX,QAAE,SAAS;AACX,YAAM;AAAA,IACR;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -9,10 +9,10 @@ export interface SuspendedBoundary {
9
9
  }
10
10
  export interface WalkOptions {
11
11
  emit: (chunk: string) => void;
12
- onSuspend?: (boundary: SuspendedBoundary) => void;
12
+ onSuspend?: ((boundary: SuspendedBoundary) => void) | undefined;
13
13
  nextBoundaryId: () => number;
14
- bootstrapped?: boolean;
15
- isBoundaryResolution?: boolean;
14
+ bootstrapped?: boolean | undefined;
15
+ isBoundaryResolution?: boolean | undefined;
16
16
  /**
17
17
  * Tracks whether the most recent emission within the *current text flow*
18
18
  * ended with a text node. When the next emission is also text, we emit a
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/server/walk.ts"],
4
- "sourcesContent": ["import {\n REACT_ELEMENT_TYPE,\n REACT_LEGACY_ELEMENT_TYPE,\n REACT_FRAGMENT_TYPE,\n type ReactNode,\n type ReactElement,\n} from '../core'\nimport {\n REACT_SUSPENSE_TYPE,\n REACT_PROVIDER_TYPE,\n REACT_CONSUMER_TYPE,\n REACT_FORWARD_REF_TYPE,\n REACT_MEMO_TYPE,\n REACT_LAZY_TYPE,\n REACT_STRICT_MODE_TYPE,\n REACT_PROFILER_TYPE,\n REACT_PORTAL_TYPE,\n} from '../react'\nimport {\n attrToHtml,\n escapeText,\n escapeScript,\n VOID_ELEMENTS,\n RAW_TEXT_ELEMENTS,\n} from './escape'\nimport {\n pushContext,\n popContext,\n snapshotContexts,\n type ContextSnapshot,\n} from './dispatcher'\n\nexport interface SuspendedBoundary {\n id: number\n fallbackHTML: string\n children: ReactNode\n thenable: Promise<any>\n contextSnapshot: ContextSnapshot\n}\n\nexport interface WalkOptions {\n emit: (chunk: string) => void\n onSuspend?: (boundary: SuspendedBoundary) => void\n nextBoundaryId: () => number\n bootstrapped?: boolean\n isBoundaryResolution?: boolean\n /**\n * Tracks whether the most recent emission within the *current text flow*\n * ended with a text node. When the next emission is also text, we emit a\n * `<!-- -->` separator so the browser's HTML parser doesn't merge them\n * into a single text node \u2014 required for hydration to line up text\n * boundaries with the React tree. Reset to `false` whenever we enter a\n * new host element (`<tag>` opens a fresh text flow).\n */\n textState?: { lastWasText: boolean }\n}\n\n/**\n * Synchronously walk a React node and emit HTML string pieces to `opts.emit`.\n * Suspended boundaries are emitted as fallbacks with marker IDs; if `opts.onSuspend`\n * is provided, the suspension is recorded for later streaming.\n */\nexport function walk(node: ReactNode, opts: WalkOptions): void {\n // Seed a text state if the caller didn't provide one so the separator logic\n // is active for the whole tree.\n if (!opts.textState) opts = { ...opts, textState: { lastWasText: false } }\n walkNode(node, opts)\n}\n\n// --- <select> selection context ----------------------------------------------\n// Stack of active select values (or `undefined` when the current select has\n// no controlled value). `<option>` walks read the top of stack to decide\n// whether to emit `selected=\"\"`.\nconst selectValueStack: unknown[] = []\nfunction pushSelectContext(value: unknown): void {\n selectValueStack.push(value)\n}\nfunction popSelectContext(): void {\n selectValueStack.pop()\n}\nfunction currentSelectValue(): unknown {\n return selectValueStack.length ? selectValueStack[selectValueStack.length - 1] : undefined\n}\n\nfunction optionChildText(children: unknown): string {\n // `<option>Text</option>` \u2014 if no `value` prop, the option's value is its\n // flat string/number child content. Matches DOM semantics (`option.value`\n // defaults to `textContent` when no attribute is set).\n if (children == null) return ''\n if (typeof children === 'string' || typeof children === 'number') return '' + children\n if (Array.isArray(children)) return children.map(optionChildText).join('')\n return ''\n}\n\nfunction emitText(text: string, opts: WalkOptions): void {\n // Empty string renders no text node and doesn't start/extend a text flow \u2014\n // skip entirely so sibling text isn't separated by a stray `<!-- -->`.\n if (text === '') return\n if (opts.textState?.lastWasText) opts.emit('<!-- -->')\n opts.emit(escapeText(text))\n if (opts.textState) opts.textState.lastWasText = true\n}\n\nfunction walkNode(node: ReactNode, opts: WalkOptions): void {\n if (node == null || node === false || node === true) return\n\n if (typeof node === 'string') {\n emitText(node, opts)\n return\n }\n if (typeof node === 'number') {\n emitText(String(node), opts)\n return\n }\n if (Array.isArray(node)) {\n for (const c of node) walkNode(c, opts)\n return\n }\n if (typeof (node as any)[Symbol.iterator] === 'function') {\n for (const item of node as Iterable<ReactNode>) walkNode(item, opts)\n return\n }\n\n if (typeof node !== 'object') return\n const t = (node as any).$$typeof\n\n // Raw React.lazy in the tree (RSC Flight encodes 'use client' components \u2014\n // CodeBlock, CodeExplorer, etc. \u2014 as bare Lazy objects directly in the\n // tree, not wrapped in REACT_ELEMENT_TYPE). SSR previously dropped these\n // here, so code snippets never made it into the server HTML. The RSC\n // decoder server-side awaits payloads before rendering, so status is\n // 'fulfilled' and `_init()` returns the resolved element synchronously.\n // If still pending (shouldn't happen post-awaitLazyElements), throw the\n // thenable so streaming SSR suspends the current boundary and retries.\n if (t === REACT_LAZY_TYPE) {\n const lazy = node as any\n const resolved = lazy._init(lazy._payload)\n walkNode(resolved, opts)\n return\n }\n\n if (t !== REACT_ELEMENT_TYPE && t !== REACT_LEGACY_ELEMENT_TYPE) return\n\n const el = node as ReactElement\n walkElement(el, opts)\n}\n\nfunction walkElement(el: ReactElement, opts: WalkOptions): void {\n const type = el.type\n const props = el.props ?? {}\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PROFILER_TYPE) {\n walkNode(props.children, opts)\n return\n }\n\n if (type === REACT_SUSPENSE_TYPE) {\n walkSuspense(props, opts)\n return\n }\n\n if (typeof type === 'string') {\n walkHost(type, props, opts)\n return\n }\n\n const marker = (type as any)?.$$typeof\n\n if (marker === REACT_PORTAL_TYPE) {\n // Portals don't render to the main HTML output on the server.\n return\n }\n\n if (marker === REACT_PROVIDER_TYPE) {\n const ctx = (type as any)._context\n pushContext(ctx, props.value)\n try {\n walkNode(props.children, opts)\n } finally {\n popContext(ctx)\n }\n return\n }\n\n if (marker === REACT_CONSUMER_TYPE) {\n const ctx = (type as any)._context\n const render = props.children\n if (typeof render === 'function') {\n walkNode(render(ctx._currentValue), opts)\n }\n return\n }\n\n if (marker === REACT_FORWARD_REF_TYPE) {\n const render = (type as any).render\n const ref = (props as any).ref ?? null\n const { ref: _omit, ...rest } = props as any\n const rendered = render(rest, ref)\n walkNode(rendered, opts)\n return\n }\n\n if (marker === REACT_MEMO_TYPE) {\n const inner = (type as any).type\n walkElement({ ...el, type: inner } as ReactElement, opts)\n return\n }\n\n if (marker === REACT_LAZY_TYPE) {\n const { _payload, _init } = type as any\n try {\n const resolved = _init(_payload)\n walkElement({ ...el, type: resolved } as ReactElement, opts)\n } catch (thenable: any) {\n if (isThenable(thenable)) {\n // Suspend this point\n throw thenable\n }\n throw thenable\n }\n return\n }\n\n if (typeof type === 'function') {\n walkComponent(type, props, opts)\n return\n }\n}\n\nfunction walkHost(\n tag: string,\n props: Record<string, any>,\n opts: WalkOptions,\n): void {\n // <textarea value=\"...\"> serializes its value as a TEXT CHILD, not an\n // attribute. `defaultValue` is the fallback when `value` is absent. This\n // matches React and the HTML spec \u2014 `<textarea value=\"x\">` is not valid\n // HTML; the value is the element's textContent.\n const isTextarea = tag === 'textarea'\n const textareaValue = isTextarea\n ? props.value != null\n ? props.value\n : props.defaultValue\n : undefined\n\n // <input defaultValue=\"...\"> should parse with that value \u2014 emit it as a\n // `value` attribute. Similarly `defaultChecked` becomes `checked`. This\n // keeps hydration consistent: the browser parser sees the initial value,\n // and on client commit our setProp seeds `.defaultValue`/`.defaultChecked`\n // without stomping the user-typed value.\n const isInput = tag === 'input'\n const inputValueAttr =\n isInput && props.value == null && props.defaultValue != null\n ? props.defaultValue\n : undefined\n const inputCheckedAttr =\n isInput && props.checked == null && props.defaultChecked != null\n ? props.defaultChecked\n : undefined\n\n // <select value=\"...\"> does NOT become an attribute on `<select>` \u2014 the\n // HTML spec has no such attribute. React resolves the selection by stamping\n // `selected` on the matching `<option>` children during render. Stash the\n // target value(s) on the walk state and the child `<option>` walk reads it.\n const isSelect = tag === 'select'\n if (isSelect) {\n const val = props.value != null ? props.value : props.defaultValue\n pushSelectContext(val)\n }\n const isOption = tag === 'option'\n\n // Prepend the HTML5 doctype to the stream when rendering an <html> root.\n // Without it the browser parses the document in quirks mode, which breaks\n // CSS sizing (documentElement.clientHeight returns the content height, not\n // the viewport) \u2014 and Floating-UI-based libraries (Radix dropdowns etc.)\n // then compute off-screen positions for overlays.\n if (tag === 'html') opts.emit('<!DOCTYPE html>')\n\n opts.emit('<' + tag)\n for (const k in props) {\n if (isTextarea && (k === 'value' || k === 'defaultValue')) continue\n if (isInput && (k === 'defaultValue' || k === 'defaultChecked')) continue\n if (isSelect && (k === 'value' || k === 'defaultValue')) continue\n if (isOption && k === 'selected') continue\n opts.emit(attrToHtml(k, props[k]))\n }\n if (inputValueAttr !== undefined) {\n opts.emit(attrToHtml('value', inputValueAttr))\n }\n if (inputCheckedAttr !== undefined) {\n opts.emit(attrToHtml('checked', inputCheckedAttr))\n }\n if (isOption) {\n const selectVal = currentSelectValue()\n if (selectVal !== undefined) {\n const optionValue =\n props.value != null ? props.value : optionChildText(props.children)\n const matches = Array.isArray(selectVal)\n ? selectVal.some((v) => '' + v === '' + optionValue)\n : '' + selectVal === '' + optionValue\n if (matches) opts.emit(' selected=\"\"')\n } else if (props.selected) {\n opts.emit(' selected=\"\"')\n }\n }\n\n if (VOID_ELEMENTS.has(tag)) {\n opts.emit('/>')\n if (opts.textState) opts.textState.lastWasText = false\n return\n }\n opts.emit('>')\n // Opening a host element starts a fresh text flow context for its children.\n // Children's text separator tracking is independent of the outer context.\n const parentTextState = opts.textState\n const childOpts: WalkOptions = { ...opts, textState: { lastWasText: false } }\n\n const dangerouslyHtml = props.dangerouslySetInnerHTML?.__html\n\n if (isTextarea && textareaValue != null) {\n opts.emit(escapeText(String(textareaValue)))\n opts.emit(`</${tag}>`)\n if (parentTextState) parentTextState.lastWasText = false\n return\n }\n\n if (RAW_TEXT_ELEMENTS.has(tag)) {\n // script/style: raw-text. React allows either a string/number child or\n // dangerouslySetInnerHTML \u2014 some libs (Start's Scripts) use the latter.\n if (dangerouslyHtml != null) {\n opts.emit(escapeScript(String(dangerouslyHtml)))\n } else {\n const children = props.children\n if (typeof children === 'string' || typeof children === 'number') {\n opts.emit(escapeScript(String(children)))\n } else if (Array.isArray(children)) {\n opts.emit(escapeScript(children.filter((c) => c != null).join('')))\n }\n }\n opts.emit(`</${tag}>`)\n if (parentTextState) parentTextState.lastWasText = false\n return\n }\n\n if (dangerouslyHtml != null) {\n opts.emit(String(dangerouslyHtml))\n } else {\n walkNode(props.children, childOpts)\n }\n opts.emit(`</${tag}>`)\n if (isSelect) popSelectContext()\n // Host element closing resets outer flow \u2014 next sibling text starts fresh.\n if (parentTextState) parentTextState.lastWasText = false\n}\n\nfunction walkComponent(\n fn: Function,\n props: Record<string, any>,\n opts: WalkOptions,\n): void {\n if ((fn as any).prototype?.isReactComponent) {\n const ctxType = (fn as any).contextType\n const ctxValue = ctxType ? ctxType._currentValue : undefined\n const instance = new (fn as any)(props, ctxValue)\n instance.props = props\n instance.context = ctxValue\n if ((fn as any).getDerivedStateFromProps) {\n const d = (fn as any).getDerivedStateFromProps(props, instance.state)\n if (d) instance.state = { ...instance.state, ...d }\n }\n walkNode(instance.render(), opts)\n return\n }\n const rendered = (fn as any)(props)\n walkNode(rendered, opts)\n}\n\nfunction walkSuspense(\n props: Record<string, any>,\n opts: WalkOptions,\n): void {\n const id = opts.nextBoundaryId()\n // Snapshot contexts BEFORE attempting children, so if a descendant suspends\n // we can replay the same provider stack when re-rendering the boundary.\n const contextSnapshot = snapshotContexts()\n\n // Try to render the children synchronously. If a thenable is thrown,\n // record the boundary and emit the fallback.\n const childParts: string[] = []\n const childEmit = (s: string) => childParts.push(s)\n try {\n walkNode(props.children, {\n emit: childEmit,\n onSuspend: opts.onSuspend,\n nextBoundaryId: opts.nextBoundaryId,\n })\n } catch (thenable: any) {\n if (isThenable(thenable)) {\n const fallbackParts: string[] = []\n try {\n walkNode(props.fallback, {\n emit: (s) => fallbackParts.push(s),\n onSuspend: opts.onSuspend,\n nextBoundaryId: opts.nextBoundaryId,\n })\n } catch {\n // Fallback suspending is unsupported; emit nothing\n }\n emitBoundary(opts, id, fallbackParts.join(''))\n\n if (opts.onSuspend) {\n opts.onSuspend({\n id,\n fallbackHTML: fallbackParts.join(''),\n children: props.children,\n thenable,\n contextSnapshot,\n })\n }\n return\n }\n throw thenable\n }\n\n // Children rendered fully \u2014 emit them wrapped in resolved-boundary markers\n // (`<!--$N-->` / `<!--/$-->`). Without markers, the client hydrator has no\n // way to know this subtree is inside a Suspense, so if the client version\n // of a descendant (e.g. `React.lazy`) suspends it can't pinpoint which DOM\n // range to adopt on resolve \u2014 it creates fresh DOM next to the SSR content,\n // producing visible duplicates (e.g. double navbar logos). Markers let the\n // client treat this as a resolved boundary and hydrate in-place.\n opts.emit(`<!--$${id}-->`)\n opts.emit(childParts.join(''))\n opts.emit(`<!--/$-->`)\n}\n\nfunction emitBoundary(opts: WalkOptions, id: number, fallbackHTML: string): void {\n // Visible div wrapper so the fallback UI shows; B: id lets $RC locate it on\n // reveal. The leading/trailing comments let hydration detect a pending\n // boundary and register a reveal callback.\n opts.emit(`<!--$?${id}--><div id=\"B:${id}\">`)\n opts.emit(fallbackHTML)\n opts.emit(`</div><!--/$-->`)\n}\n\nfunction isThenable(x: any): x is Promise<any> {\n return x != null && typeof x.then === 'function'\n}\n"],
4
+ "sourcesContent": ["import {\n REACT_ELEMENT_TYPE,\n REACT_LEGACY_ELEMENT_TYPE,\n REACT_FRAGMENT_TYPE,\n type ReactNode,\n type ReactElement,\n} from '../core'\nimport {\n REACT_SUSPENSE_TYPE,\n REACT_PROVIDER_TYPE,\n REACT_CONSUMER_TYPE,\n REACT_FORWARD_REF_TYPE,\n REACT_MEMO_TYPE,\n REACT_LAZY_TYPE,\n REACT_STRICT_MODE_TYPE,\n REACT_PROFILER_TYPE,\n REACT_PORTAL_TYPE,\n} from '../react'\nimport {\n attrToHtml,\n escapeText,\n escapeScript,\n VOID_ELEMENTS,\n RAW_TEXT_ELEMENTS,\n} from './escape'\nimport {\n pushContext,\n popContext,\n snapshotContexts,\n type ContextSnapshot,\n} from './dispatcher'\n\nexport interface SuspendedBoundary {\n id: number\n fallbackHTML: string\n children: ReactNode\n thenable: Promise<any>\n contextSnapshot: ContextSnapshot\n}\n\nexport interface WalkOptions {\n emit: (chunk: string) => void\n onSuspend?: ((boundary: SuspendedBoundary) => void) | undefined\n nextBoundaryId: () => number\n bootstrapped?: boolean | undefined\n isBoundaryResolution?: boolean | undefined\n /**\n * Tracks whether the most recent emission within the *current text flow*\n * ended with a text node. When the next emission is also text, we emit a\n * `<!-- -->` separator so the browser's HTML parser doesn't merge them\n * into a single text node \u2014 required for hydration to line up text\n * boundaries with the React tree. Reset to `false` whenever we enter a\n * new host element (`<tag>` opens a fresh text flow).\n */\n textState?: { lastWasText: boolean }\n}\n\n/**\n * Synchronously walk a React node and emit HTML string pieces to `opts.emit`.\n * Suspended boundaries are emitted as fallbacks with marker IDs; if `opts.onSuspend`\n * is provided, the suspension is recorded for later streaming.\n */\nexport function walk(node: ReactNode, opts: WalkOptions): void {\n // Seed a text state if the caller didn't provide one so the separator logic\n // is active for the whole tree.\n if (!opts.textState) opts = { ...opts, textState: { lastWasText: false } }\n walkNode(node, opts)\n}\n\n// --- <select> selection context ----------------------------------------------\n// Stack of active select values (or `undefined` when the current select has\n// no controlled value). `<option>` walks read the top of stack to decide\n// whether to emit `selected=\"\"`.\nconst selectValueStack: unknown[] = []\nfunction pushSelectContext(value: unknown): void {\n selectValueStack.push(value)\n}\nfunction popSelectContext(): void {\n selectValueStack.pop()\n}\nfunction currentSelectValue(): unknown {\n return selectValueStack.length ? selectValueStack[selectValueStack.length - 1] : undefined\n}\n\nfunction optionChildText(children: unknown): string {\n // `<option>Text</option>` \u2014 if no `value` prop, the option's value is its\n // flat string/number child content. Matches DOM semantics (`option.value`\n // defaults to `textContent` when no attribute is set).\n if (children == null) return ''\n if (typeof children === 'string' || typeof children === 'number') return '' + children\n if (Array.isArray(children)) return children.map(optionChildText).join('')\n return ''\n}\n\nfunction emitText(text: string, opts: WalkOptions): void {\n // Empty string renders no text node and doesn't start/extend a text flow \u2014\n // skip entirely so sibling text isn't separated by a stray `<!-- -->`.\n if (text === '') return\n if (opts.textState?.lastWasText) opts.emit('<!-- -->')\n opts.emit(escapeText(text))\n if (opts.textState) opts.textState.lastWasText = true\n}\n\nfunction walkNode(node: ReactNode, opts: WalkOptions): void {\n if (node == null || node === false || node === true) return\n\n if (typeof node === 'string') {\n emitText(node, opts)\n return\n }\n if (typeof node === 'number') {\n emitText(String(node), opts)\n return\n }\n if (Array.isArray(node)) {\n for (const c of node) walkNode(c, opts)\n return\n }\n if (typeof (node as any)[Symbol.iterator] === 'function') {\n for (const item of node as Iterable<ReactNode>) walkNode(item, opts)\n return\n }\n\n if (typeof node !== 'object') return\n const t = (node as any).$$typeof\n\n // Raw React.lazy in the tree (RSC Flight encodes 'use client' components \u2014\n // CodeBlock, CodeExplorer, etc. \u2014 as bare Lazy objects directly in the\n // tree, not wrapped in REACT_ELEMENT_TYPE). SSR previously dropped these\n // here, so code snippets never made it into the server HTML. The RSC\n // decoder server-side awaits payloads before rendering, so status is\n // 'fulfilled' and `_init()` returns the resolved element synchronously.\n // If still pending (shouldn't happen post-awaitLazyElements), throw the\n // thenable so streaming SSR suspends the current boundary and retries.\n if (t === REACT_LAZY_TYPE) {\n const lazy = node as any\n const resolved = lazy._init(lazy._payload)\n walkNode(resolved, opts)\n return\n }\n\n if (t !== REACT_ELEMENT_TYPE && t !== REACT_LEGACY_ELEMENT_TYPE) return\n\n const el = node as ReactElement\n walkElement(el, opts)\n}\n\nfunction walkElement(el: ReactElement, opts: WalkOptions): void {\n const type = el.type\n const props = el.props ?? {}\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PROFILER_TYPE) {\n walkNode(props.children, opts)\n return\n }\n\n if (type === REACT_SUSPENSE_TYPE) {\n walkSuspense(props, opts)\n return\n }\n\n if (typeof type === 'string') {\n walkHost(type, props, opts)\n return\n }\n\n const marker = (type as any)?.$$typeof\n\n if (marker === REACT_PORTAL_TYPE) {\n // Portals don't render to the main HTML output on the server.\n return\n }\n\n if (marker === REACT_PROVIDER_TYPE) {\n const ctx = (type as any)._context\n pushContext(ctx, props.value)\n try {\n walkNode(props.children, opts)\n } finally {\n popContext(ctx)\n }\n return\n }\n\n if (marker === REACT_CONSUMER_TYPE) {\n const ctx = (type as any)._context\n const render = props.children\n if (typeof render === 'function') {\n walkNode(render(ctx._currentValue), opts)\n }\n return\n }\n\n if (marker === REACT_FORWARD_REF_TYPE) {\n const render = (type as any).render\n const ref = (props as any).ref ?? null\n const { ref: _omit, ...rest } = props as any\n const rendered = render(rest, ref)\n walkNode(rendered, opts)\n return\n }\n\n if (marker === REACT_MEMO_TYPE) {\n const inner = (type as any).type\n walkElement({ ...el, type: inner } as ReactElement, opts)\n return\n }\n\n if (marker === REACT_LAZY_TYPE) {\n const { _payload, _init } = type as any\n try {\n const resolved = _init(_payload)\n walkElement({ ...el, type: resolved } as ReactElement, opts)\n } catch (thenable: any) {\n if (isThenable(thenable)) {\n // Suspend this point\n throw thenable\n }\n throw thenable\n }\n return\n }\n\n if (typeof type === 'function') {\n walkComponent(type, props, opts)\n return\n }\n}\n\nfunction walkHost(\n tag: string,\n props: Record<string, any>,\n opts: WalkOptions,\n): void {\n // <textarea value=\"...\"> serializes its value as a TEXT CHILD, not an\n // attribute. `defaultValue` is the fallback when `value` is absent. This\n // matches React and the HTML spec \u2014 `<textarea value=\"x\">` is not valid\n // HTML; the value is the element's textContent.\n const isTextarea = tag === 'textarea'\n const textareaValue = isTextarea\n ? props.value != null\n ? props.value\n : props.defaultValue\n : undefined\n\n // <input defaultValue=\"...\"> should parse with that value \u2014 emit it as a\n // `value` attribute. Similarly `defaultChecked` becomes `checked`. This\n // keeps hydration consistent: the browser parser sees the initial value,\n // and on client commit our setProp seeds `.defaultValue`/`.defaultChecked`\n // without stomping the user-typed value.\n const isInput = tag === 'input'\n const inputValueAttr =\n isInput && props.value == null && props.defaultValue != null\n ? props.defaultValue\n : undefined\n const inputCheckedAttr =\n isInput && props.checked == null && props.defaultChecked != null\n ? props.defaultChecked\n : undefined\n\n // <select value=\"...\"> does NOT become an attribute on `<select>` \u2014 the\n // HTML spec has no such attribute. React resolves the selection by stamping\n // `selected` on the matching `<option>` children during render. Stash the\n // target value(s) on the walk state and the child `<option>` walk reads it.\n const isSelect = tag === 'select'\n if (isSelect) {\n const val = props.value != null ? props.value : props.defaultValue\n pushSelectContext(val)\n }\n const isOption = tag === 'option'\n\n // Prepend the HTML5 doctype to the stream when rendering an <html> root.\n // Without it the browser parses the document in quirks mode, which breaks\n // CSS sizing (documentElement.clientHeight returns the content height, not\n // the viewport) \u2014 and Floating-UI-based libraries (Radix dropdowns etc.)\n // then compute off-screen positions for overlays.\n if (tag === 'html') opts.emit('<!DOCTYPE html>')\n\n opts.emit('<' + tag)\n for (const k in props) {\n if (isTextarea && (k === 'value' || k === 'defaultValue')) continue\n if (isInput && (k === 'defaultValue' || k === 'defaultChecked')) continue\n if (isSelect && (k === 'value' || k === 'defaultValue')) continue\n if (isOption && k === 'selected') continue\n opts.emit(attrToHtml(k, props[k]))\n }\n if (inputValueAttr !== undefined) {\n opts.emit(attrToHtml('value', inputValueAttr))\n }\n if (inputCheckedAttr !== undefined) {\n opts.emit(attrToHtml('checked', inputCheckedAttr))\n }\n if (isOption) {\n const selectVal = currentSelectValue()\n if (selectVal !== undefined) {\n const optionValue =\n props.value != null ? props.value : optionChildText(props.children)\n const matches = Array.isArray(selectVal)\n ? selectVal.some((v) => '' + v === '' + optionValue)\n : '' + selectVal === '' + optionValue\n if (matches) opts.emit(' selected=\"\"')\n } else if (props.selected) {\n opts.emit(' selected=\"\"')\n }\n }\n\n if (VOID_ELEMENTS.has(tag)) {\n opts.emit('/>')\n if (opts.textState) opts.textState.lastWasText = false\n return\n }\n opts.emit('>')\n // Opening a host element starts a fresh text flow context for its children.\n // Children's text separator tracking is independent of the outer context.\n const parentTextState = opts.textState\n const childOpts: WalkOptions = { ...opts, textState: { lastWasText: false } }\n\n const dangerouslyHtml = props.dangerouslySetInnerHTML?.__html\n\n if (isTextarea && textareaValue != null) {\n opts.emit(escapeText(String(textareaValue)))\n opts.emit(`</${tag}>`)\n if (parentTextState) parentTextState.lastWasText = false\n return\n }\n\n if (RAW_TEXT_ELEMENTS.has(tag)) {\n // script/style: raw-text. React allows either a string/number child or\n // dangerouslySetInnerHTML \u2014 some libs (Start's Scripts) use the latter.\n if (dangerouslyHtml != null) {\n opts.emit(escapeScript(String(dangerouslyHtml)))\n } else {\n const children = props.children\n if (typeof children === 'string' || typeof children === 'number') {\n opts.emit(escapeScript(String(children)))\n } else if (Array.isArray(children)) {\n opts.emit(escapeScript(children.filter((c) => c != null).join('')))\n }\n }\n opts.emit(`</${tag}>`)\n if (parentTextState) parentTextState.lastWasText = false\n return\n }\n\n if (dangerouslyHtml != null) {\n opts.emit(String(dangerouslyHtml))\n } else {\n walkNode(props.children, childOpts)\n }\n opts.emit(`</${tag}>`)\n if (isSelect) popSelectContext()\n // Host element closing resets outer flow \u2014 next sibling text starts fresh.\n if (parentTextState) parentTextState.lastWasText = false\n}\n\nfunction walkComponent(\n fn: Function,\n props: Record<string, any>,\n opts: WalkOptions,\n): void {\n if ((fn as any).prototype?.isReactComponent) {\n const ctxType = (fn as any).contextType\n const ctxValue = ctxType ? ctxType._currentValue : undefined\n const instance = new (fn as any)(props, ctxValue)\n instance.props = props\n instance.context = ctxValue\n if ((fn as any).getDerivedStateFromProps) {\n const d = (fn as any).getDerivedStateFromProps(props, instance.state)\n if (d) instance.state = { ...instance.state, ...d }\n }\n walkNode(instance.render(), opts)\n return\n }\n const rendered = (fn as any)(props)\n walkNode(rendered, opts)\n}\n\nfunction walkSuspense(\n props: Record<string, any>,\n opts: WalkOptions,\n): void {\n const id = opts.nextBoundaryId()\n // Snapshot contexts BEFORE attempting children, so if a descendant suspends\n // we can replay the same provider stack when re-rendering the boundary.\n const contextSnapshot = snapshotContexts()\n\n // Try to render the children synchronously. If a thenable is thrown,\n // record the boundary and emit the fallback.\n const childParts: string[] = []\n const childEmit = (s: string) => childParts.push(s)\n try {\n walkNode(props.children, {\n emit: childEmit,\n onSuspend: opts.onSuspend,\n nextBoundaryId: opts.nextBoundaryId,\n })\n } catch (thenable: any) {\n if (isThenable(thenable)) {\n const fallbackParts: string[] = []\n try {\n walkNode(props.fallback, {\n emit: (s) => fallbackParts.push(s),\n onSuspend: opts.onSuspend,\n nextBoundaryId: opts.nextBoundaryId,\n })\n } catch {\n // Fallback suspending is unsupported; emit nothing\n }\n emitBoundary(opts, id, fallbackParts.join(''))\n\n if (opts.onSuspend) {\n opts.onSuspend({\n id,\n fallbackHTML: fallbackParts.join(''),\n children: props.children,\n thenable,\n contextSnapshot,\n })\n }\n return\n }\n throw thenable\n }\n\n // Children rendered fully \u2014 emit them wrapped in resolved-boundary markers\n // (`<!--$N-->` / `<!--/$-->`). Without markers, the client hydrator has no\n // way to know this subtree is inside a Suspense, so if the client version\n // of a descendant (e.g. `React.lazy`) suspends it can't pinpoint which DOM\n // range to adopt on resolve \u2014 it creates fresh DOM next to the SSR content,\n // producing visible duplicates (e.g. double navbar logos). Markers let the\n // client treat this as a resolved boundary and hydrate in-place.\n opts.emit(`<!--$${id}-->`)\n opts.emit(childParts.join(''))\n opts.emit(`<!--/$-->`)\n}\n\nfunction emitBoundary(opts: WalkOptions, id: number, fallbackHTML: string): void {\n // Visible div wrapper so the fallback UI shows; B: id lets $RC locate it on\n // reveal. The leading/trailing comments let hydration detect a pending\n // boundary and register a reveal callback.\n opts.emit(`<!--$?${id}--><div id=\"B:${id}\">`)\n opts.emit(fallbackHTML)\n opts.emit(`</div><!--/$-->`)\n}\n\nfunction isThenable(x: any): x is Promise<any> {\n return x != null && typeof x.then === 'function'\n}\n"],
5
5
  "mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAgCA,SAAS,KAAK,MAAiB,MAAyB;AAG7D,MAAI,CAAC,KAAK,UAAW,QAAO,EAAE,GAAG,MAAM,WAAW,EAAE,aAAa,MAAM,EAAE;AACzE,WAAS,MAAM,IAAI;AACrB;AAMA,IAAM,mBAA8B,CAAC;AACrC,SAAS,kBAAkB,OAAsB;AAC/C,mBAAiB,KAAK,KAAK;AAC7B;AACA,SAAS,mBAAyB;AAChC,mBAAiB,IAAI;AACvB;AACA,SAAS,qBAA8B;AACrC,SAAO,iBAAiB,SAAS,iBAAiB,iBAAiB,SAAS,CAAC,IAAI;AACnF;AAEA,SAAS,gBAAgB,UAA2B;AAIlD,MAAI,YAAY,KAAM,QAAO;AAC7B,MAAI,OAAO,aAAa,YAAY,OAAO,aAAa,SAAU,QAAO,KAAK;AAC9E,MAAI,MAAM,QAAQ,QAAQ,EAAG,QAAO,SAAS,IAAI,eAAe,EAAE,KAAK,EAAE;AACzE,SAAO;AACT;AAEA,SAAS,SAAS,MAAc,MAAyB;AAGvD,MAAI,SAAS,GAAI;AACjB,MAAI,KAAK,WAAW,YAAa,MAAK,KAAK,UAAU;AACrD,OAAK,KAAK,WAAW,IAAI,CAAC;AAC1B,MAAI,KAAK,UAAW,MAAK,UAAU,c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BAAiB,EAAE,IAAI;AAC5C,OAAK,KAAK,YAAY;AACtB,OAAK,KAAK,iBAAiB;AAC7B;AAEA,SAAS,WAAW,GAA2B;AAC7C,SAAO,KAAK,QAAQ,OAAO,EAAE,SAAS;AACxC;",
6
6
  "names": []
7
7
  }
@@ -50,6 +50,7 @@ var ALIASES = {
50
50
  // React drop-in shim targets. Subpaths first.
51
51
  "react/jsx-runtime": "@tanstack/redact/jsx-runtime",
52
52
  "react/jsx-dev-runtime": "@tanstack/redact/jsx-dev-runtime",
53
+ "react/compiler-runtime": "@tanstack/redact/compiler-runtime",
53
54
  "react-dom/client": "@tanstack/redact/dom-client",
54
55
  "react-dom/server": "@tanstack/redact/server",
55
56
  "react-dom/test-utils": "@tanstack/redact/dom-test-utils",
@@ -65,6 +66,7 @@ var ALIASES = {
65
66
  // Subpaths first here too.
66
67
  "@tanstack/redact/jsx-runtime": "@tanstack/redact/jsx-runtime",
67
68
  "@tanstack/redact/jsx-dev-runtime": "@tanstack/redact/jsx-dev-runtime",
69
+ "@tanstack/redact/compiler-runtime": "@tanstack/redact/compiler-runtime",
68
70
  "@tanstack/redact/dom-client": "@tanstack/redact/dom-client",
69
71
  "@tanstack/redact/dom-test-utils": "@tanstack/redact/dom-test-utils",
70
72
  "@tanstack/redact/server": "@tanstack/redact/server",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/vite/index.ts"],
4
- "sourcesContent": ["import { existsSync, readFileSync, realpathSync } from 'node:fs'\nimport { dirname, resolve as resolvePath } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport type RedactPreset = 'nano' | 'full'\n\n/**\n * Opt-in feature set. Each flag toggles whether the feature's real\n * implementation ships (`true`) or is swapped with a stub module that\n * degrades gracefully (`false`). Missing keys fall back to the preset's\n * default. Adding a feature to this interface propagates to consumer\n * configs as autocompleted options.\n */\nexport interface RedactFeatures {\n /**\n * `createPortal`. When `false`, portal elements render in place as a\n * Fragment (the `container` prop is ignored). `renderPortal` and its\n * deps are stripped from the bundle.\n */\n portal?: boolean\n /**\n * `createContext` / `useContext` / `<Provider>` / `<Consumer>`. When\n * `false`, Providers render as Fragments (value never propagates),\n * Consumers invoke their function-children with the context's default\n * value, and `useContext` returns the default. Provider-walk logic and\n * `renderProvider` are stripped.\n */\n context?: boolean\n /**\n * `<Suspense>` boundaries + streaming hydration. When `false`, Suspense\n * elements render as Fragments (children mount inline, `fallback` is\n * ignored). Thrown thenables still schedule a re-render on settle, so\n * eventual consistency works \u2014 just no fallback UI during the pending\n * window. Boundary-handler stack and hydration integration are stripped.\n */\n suspense?: boolean\n /**\n * `React.memo`. When `false`, memoized components still render but without\n * the prop-equality gate \u2014 every parent rerender passes through.\n * `shallowEqual` and the force-rerender bypass are stripped.\n */\n memo?: boolean\n /**\n * `React.forwardRef`. When `false`, forwardRef components still render but\n * the ref prop isn't forwarded to the inner function. React 19+ treats\n * refs as normal props on function components anyway, so most apps can\n * drop this. The dispatcher save/restore machinery is stripped.\n */\n forwardRef?: boolean\n /**\n * `React.lazy`. When `false`, lazy elements still resolve if their payload\n * is already available synchronously (e.g. pre-awaited RSC Flight); async\n * resolution throws a clear error. The hydration-deferred-reveal path and\n * Suspense coordination are stripped.\n */\n lazy?: boolean\n /**\n * Class components (`extends Component`). When `false`, class components\n * still render but only honor the core contract: constructor + `render()`\n * + `setState`. Dropped: `contextType`, `getDerivedStateFromProps`,\n * `shouldComponentUpdate`, `componentDidMount`/`Update`/`WillUnmount`,\n * `getDerivedStateFromError`/`componentDidCatch` (error boundaries).\n */\n classComponents?: boolean\n /**\n * SSR hydration (`hydrateRoot`). When `false`, `hydrateRoot` throws\n * (use `createRoot` for SPAs). The HydrationCursor / DOM adoption /\n * streaming-boundary coordination / event-replay / scroll-guard\n * machinery is stripped \u2014 the biggest single chunk of reducible code.\n */\n hydration?: boolean\n}\n\ninterface ResolvedFeatures {\n portal: boolean\n context: boolean\n suspense: boolean\n memo: boolean\n forwardRef: boolean\n lazy: boolean\n classComponents: boolean\n hydration: boolean\n}\n\nconst PRESET_DEFAULTS: Record<RedactPreset, ResolvedFeatures> = {\n // Opt-in: everything off. Turn individual features on via `features`.\n nano: {\n portal: false, context: false, suspense: false, memo: false,\n forwardRef: false, lazy: false, classComponents: false, hydration: false,\n },\n // Opt-out: everything on (drop-in React parity). Turn features off via `features`.\n full: {\n portal: true, context: true, suspense: true, memo: true,\n forwardRef: true, lazy: true, classComponents: true, hydration: true,\n },\n}\n\nfunction resolveFeatures(\n preset: RedactPreset,\n overrides: RedactFeatures,\n): ResolvedFeatures {\n const p = PRESET_DEFAULTS[preset]\n return {\n portal: overrides.portal ?? p.portal,\n context: overrides.context ?? p.context,\n suspense: overrides.suspense ?? p.suspense,\n memo: overrides.memo ?? p.memo,\n forwardRef: overrides.forwardRef ?? p.forwardRef,\n lazy: overrides.lazy ?? p.lazy,\n classComponents: overrides.classComponents ?? p.classComponents,\n hydration: overrides.hydration ?? p.hydration,\n }\n}\n\nexport interface RedactOptions {\n /** Skip aliasing specific specifiers, e.g. if a consumer wants real React somewhere. */\n skip?: ReadonlyArray<string>\n /**\n * Override package resolution root. Defaults to the Vite config root. Useful\n * for monorepos where the plugin lives in a different workspace than the\n * consumer app.\n */\n resolveFrom?: string\n /**\n * Explicit package roots, bypassing node_modules lookup. Keys are package\n * names (e.g. `@tanstack/redact`), values are absolute paths to the package\n * directory. Handy for cross-workspace testing / bring-your-own-build setups.\n */\n packageRoots?: Record<string, string>\n /**\n * Starting point for feature selection. `'full'` (default) turns every\n * feature on \u2014 drop-in React parity, opt-out individual features via\n * `features`. `'nano'` turns everything off \u2014 opt in to what you need.\n */\n preset?: RedactPreset\n /**\n * Per-feature overrides merged on top of the preset's defaults. Enables\n * fine-grained \"preset minus X\" or \"preset plus Y\" configurations.\n */\n features?: RedactFeatures\n}\n\n// Alias map. ORDER MATTERS \u2014 Vite's alias matcher uses first-match against\n// prefix, so more-specific specifiers MUST come before less-specific ones.\n// Without this, `react-dom/server` would prefix-match `react-dom` first and\n// resolve to `@tanstack/redact/dom/server` (wrong) instead of\n// `@tanstack/redact/server`.\n//\n// `use-sync-external-store` aliases are here because its CJS-only React 17\n// compat shim does `var React = require('react')`. That survives Vite's\n// pre-bundling intact and explodes in Cloudflare Workers (no `require`).\n// Modern React has `useSyncExternalStore` built-in, and `@tanstack/redact`\n// additionally exports `useSyncExternalStoreWithSelector` so this alias\n// is safe everywhere.\nconst ALIASES: Record<string, string> = {\n // ---- most-specific first ----\n 'use-sync-external-store/shim/with-selector': '@tanstack/redact',\n 'use-sync-external-store/shim/with-selector.js': '@tanstack/redact',\n 'use-sync-external-store/with-selector': '@tanstack/redact',\n 'use-sync-external-store/with-selector.js': '@tanstack/redact',\n 'use-sync-external-store/shim': '@tanstack/redact',\n 'use-sync-external-store': '@tanstack/redact',\n\n // React drop-in shim targets. Subpaths first.\n 'react/jsx-runtime': '@tanstack/redact/jsx-runtime',\n 'react/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',\n 'react-dom/client': '@tanstack/redact/dom-client',\n 'react-dom/server': '@tanstack/redact/server',\n 'react-dom/test-utils': '@tanstack/redact/dom-test-utils',\n 'react-dom': '@tanstack/redact/dom',\n react: '@tanstack/redact',\n scheduler: '@tanstack/redact/scheduler',\n\n // Self-aliases so Vite resolves `@tanstack/redact/*` imports to the same\n // canonical file path no matter where they originate (worker bundle vs\n // deps_ssr pre-bundle vs source). Without these, Cloudflare's\n // `noExternal: true` worker config inlines one copy while Vite's\n // optimizeDeps pre-bundles another, ending up with two separate\n // ReactSharedInternals instances and a null dispatcher in user hooks.\n // Subpaths first here too.\n '@tanstack/redact/jsx-runtime': '@tanstack/redact/jsx-runtime',\n '@tanstack/redact/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',\n '@tanstack/redact/dom-client': '@tanstack/redact/dom-client',\n '@tanstack/redact/dom-test-utils': '@tanstack/redact/dom-test-utils',\n '@tanstack/redact/server': '@tanstack/redact/server',\n '@tanstack/redact/scheduler': '@tanstack/redact/scheduler',\n '@tanstack/redact/dom': '@tanstack/redact/dom',\n '@tanstack/redact': '@tanstack/redact',\n}\n\nfunction splitSpecifier(specifier: string): { pkg: string; sub: string } {\n if (specifier.startsWith('@')) {\n const slash1 = specifier.indexOf('/')\n const slash2 = specifier.indexOf('/', slash1 + 1)\n if (slash2 < 0) return { pkg: specifier, sub: '' }\n return { pkg: specifier.slice(0, slash2), sub: specifier.slice(slash2 + 1) }\n }\n const slash = specifier.indexOf('/')\n if (slash < 0) return { pkg: specifier, sub: '' }\n return { pkg: specifier.slice(0, slash), sub: specifier.slice(slash + 1) }\n}\n\nfunction findPackageDir(pkg: string, fromDir: string): string | null {\n let dir = fromDir\n while (true) {\n const candidate = resolvePath(dir, 'node_modules', pkg)\n if (existsSync(resolvePath(candidate, 'package.json'))) return candidate\n const parent = dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n}\n\nfunction resolveExport(packageDir: string, sub: string): string | null {\n const pkgJsonPath = resolvePath(packageDir, 'package.json')\n let pkg: any\n try {\n pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf8'))\n } catch {\n return null\n }\n const key = sub ? './' + sub : '.'\n const exp = pkg.exports?.[key]\n // Prefer published `import` (dist/.js) over `source` \u2014 dist is a single\n // transformed bundle so Vite's dep optimizer doesn't thrash on dozens of\n // individual source files. The package keeps cross-subpath imports\n // external, so there's still only one runtime instance.\n const pick = (v: any): string | null => {\n if (typeof v === 'string') return v\n if (v && typeof v === 'object') {\n return pick(v.import ?? v.module ?? v.source ?? v.default ?? null)\n }\n return null\n }\n const target = pick(exp)\n if (target) return resolvePath(packageDir, target)\n if (!sub) {\n const main = pkg.module ?? pkg.main\n if (typeof main === 'string') return resolvePath(packageDir, main)\n }\n return null\n}\n\n// When installed from npm, `@tanstack/redact` is declared as a `dependency`\n// of consumer apps. Under pnpm's strict mode it ends up nested under the\n// plugin's own `.pnpm/@tanstack+redact@.../node_modules/` rather than\n// hoisted to the consumer's root, so a `findPackageDir` walk starting at\n// the Vite project root won't always find it. Search from the plugin's own\n// directory first (which walks into its nested node_modules), then fall\n// back to the consumer root for hoisted installs.\nconst pluginDir = dirname(fileURLToPath(import.meta.url))\n\nfunction resolveSpecifier(\n specifier: string,\n fromDir: string,\n packageRoots: Record<string, string>,\n): string | null {\n const { pkg, sub } = splitSpecifier(specifier)\n const packageDir =\n packageRoots[pkg] ??\n findPackageDir(pkg, pluginDir) ??\n findPackageDir(pkg, fromDir)\n if (!packageDir) return null\n const target = resolveExport(packageDir, sub)\n if (!target) return null\n // Canonicalize through pnpm symlinks. Under strict pnpm, the package may\n // live nested under `.pnpm/@tanstack+redact@.../node_modules/*`, but each\n // of those is itself a symlink to the flat `.pnpm/@tanstack+redact@.../`\n // entry. Vite's `fetchModule` (used by TanStack Start's server-fn\n // compiler) follows the realpath, so the id seen by the capture-transform\n // differs from the nested id we'd return. That leaves the compiler's\n // moduleCache keyed on the realpath while `getModuleInfo` looks up the\n // nested path \u2192 miss \u2192 \"could not load module info\". Returning the\n // canonical realpath here keeps the two sides in agreement.\n try {\n return realpathSync(target)\n } catch {\n return target\n }\n}\n\nexport function redact(options: RedactOptions = {}): any {\n const skip = new Set(options.skip ?? [])\n const entries = Object.entries(ALIASES).filter(([k]) => !skip.has(k))\n const features = resolveFeatures(options.preset ?? 'full', options.features ?? {})\n\n const resolvedMap: Record<string, string> = {}\n let done = false\n\n function resolveAll(root: string): void {\n if (done) return\n const fromDir = options.resolveFrom ?? root\n const packageRoots = options.packageRoots ?? {}\n for (const [from, to] of entries) {\n const resolved = resolveSpecifier(to, fromDir, packageRoots)\n if (resolved) resolvedMap[from] = resolved\n }\n done = true\n }\n\n return {\n name: 'redact',\n enforce: 'pre',\n\n config() {\n const excludeList = entries.map(([k]) => k)\n // Single package \u2014 only one name to dedupe / no-external.\n const noExt = ['@tanstack/redact']\n const aliasMap = Object.fromEntries(entries.filter(([from, to]) => from !== to))\n // Dedupe `@tanstack/redact` so Vite resolves it to a single instance\n // even when multiple packages (e.g. @tanstack/react-router and user\n // code) drag it into different parts of the module graph.\n const dedupe = noExt\n // Scope `resolve.alias` to client + ssr environments ONLY. Do NOT set\n // a top-level alias: it would apply to the `rsc` environment too,\n // where `@vitejs/plugin-rsc`'s vendored `react-server-dom-server`\n // imports `react` and needs the *real* React (with the `.d` field on\n // ReactSharedInternals that our shim deliberately doesn't have).\n // Aliasing `react` \u2192 `@tanstack/redact` in the RSC env crashes Flight\n // serialization. The Cloudflare vite-plugin's rolldown worker-runner\n // also pre-scans bare specifiers via Vite's alias map (not plugin\n // hooks), but it scans within the *ssr* environment specifically \u2014\n // so per-env `environments.ssr.resolve.alias` covers it. The\n // `enforce: 'pre'` resolveId hook below already skips RSC, so the\n // remaining concern is alias placement. Object form is required \u2014\n // array form is silently ignored by rolldown's worker-runner.\n return {\n environments: {\n client: {\n optimizeDeps: { exclude: excludeList },\n resolve: { alias: aliasMap, dedupe },\n },\n ssr: {\n optimizeDeps: { exclude: excludeList },\n resolve: { alias: aliasMap, dedupe, noExternal: noExt },\n },\n },\n ssr: { noExternal: noExt },\n }\n },\n\n configResolved(config: any) {\n resolveAll(config.root)\n // With `packageRoots`, package sources live outside the consumer's Vite\n // project root, so the default server.fs.allow list blocks them. Append\n // to the resolved allow list rather than replacing via `config()`, so we\n // keep Vite's defaults (root + node_modules + client runtime).\n const fsAllow = Object.values(options.packageRoots ?? {})\n if (fsAllow.length && config.server?.fs?.allow) {\n for (const p of fsAllow) {\n if (!config.server.fs.allow.includes(p)) {\n config.server.fs.allow.push(p)\n }\n }\n }\n },\n\n async resolveId(this: any, id: string, importer?: string, opts?: any) {\n // Skip the RSC environment \u2014 it relies on real React internals via\n // @vitejs/plugin-rsc's vendored react-server-dom. Substituting our\n // shim there breaks Flight serialization. Client + SSR envs still swap.\n const envName = this?.environment?.name\n if (envName === 'rsc') return null\n\n // Feature-flag swap: when the reconciler's `features/index` module\n // imports a feature by relative path, redirect to that feature's stub\n // if the flag is off. The stub registers a graceful-degradation\n // matcher (e.g. Portal \u2192 Fragment) so user code keeps working.\n if (importer && /[\\\\/]features[\\\\/]index\\.[jt]sx?$/.test(importer)) {\n const m = id.match(/^\\.\\/([a-z-]+)$/)\n if (m) {\n const name = m[1] as keyof ResolvedFeatures\n if (name in features && !features[name]) {\n const r = await this.resolve(`./${name}/stub`, importer, {\n ...opts,\n skipSelf: true,\n })\n if (r) return r.id\n }\n }\n }\n\n // Hydration swap: hydration isn't self-registering, so it's imported\n // from reconcile.ts, root.ts, and the Suspense/Lazy feature modules.\n // Any specifier ending in `/hydration` that resolves to our feature\n // module gets redirected to the stub when the flag is off.\n if (!features.hydration && importer && /[\\\\/]hydration$/.test(id)) {\n const r = await this.resolve(id, importer, { ...opts, skipSelf: true })\n if (r && /features[\\\\/]hydration[\\\\/]index\\.(ts|js)$/.test(r.id)) {\n return r.id.replace(/index\\.(ts|js)$/, 'stub.$1')\n }\n }\n\n return resolvedMap[id] ?? null\n },\n }\n}\n\nexport default redact\n"],
5
- "mappings": ";AAAA,SAAS,YAAY,cAAc,oBAAoB;AACvD,SAAS,SAAS,WAAW,mBAAmB;AAChD,SAAS,qBAAqB;AAkF9B,IAAM,kBAA0D;AAAA;AAAA,EAE9D,MAAM;AAAA,IACJ,QAAQ;AAAA,IAAO,SAAS;AAAA,IAAO,UAAU;AAAA,IAAO,MAAM;AAAA,IACtD,YAAY;AAAA,IAAO,MAAM;AAAA,IAAO,iBAAiB;AAAA,IAAO,WAAW;AAAA,EACrE;AAAA;AAAA,EAEA,MAAM;AAAA,IACJ,QAAQ;AAAA,IAAM,SAAS;AAAA,IAAM,UAAU;AAAA,IAAM,MAAM;AAAA,IACnD,YAAY;AAAA,IAAM,MAAM;AAAA,IAAM,iBAAiB;AAAA,IAAM,WAAW;AAAA,EAClE;AACF;AAEA,SAAS,gBACP,QACA,WACkB;AAClB,QAAM,IAAI,gBAAgB,MAAM;AAChC,SAAO;AAAA,IACL,QAAQ,UAAU,UAAU,EAAE;AAAA,IAC9B,SAAS,U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,EACF;AACF;AAEA,IAAO,eAAQ;",
4
+ "sourcesContent": ["import { existsSync, readFileSync, realpathSync } from 'node:fs'\nimport { dirname, resolve as resolvePath } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport type RedactPreset = 'nano' | 'full'\n\n/**\n * Opt-in feature set. Each flag toggles whether the feature's real\n * implementation ships (`true`) or is swapped with a stub module that\n * degrades gracefully (`false`). Missing keys fall back to the preset's\n * default. Adding a feature to this interface propagates to consumer\n * configs as autocompleted options.\n */\nexport interface RedactFeatures {\n /**\n * `createPortal`. When `false`, portal elements render in place as a\n * Fragment (the `container` prop is ignored). `renderPortal` and its\n * deps are stripped from the bundle.\n */\n portal?: boolean\n /**\n * `createContext` / `useContext` / `<Provider>` / `<Consumer>`. When\n * `false`, Providers render as Fragments (value never propagates),\n * Consumers invoke their function-children with the context's default\n * value, and `useContext` returns the default. Provider-walk logic and\n * `renderProvider` are stripped.\n */\n context?: boolean\n /**\n * `<Suspense>` boundaries + streaming hydration. When `false`, Suspense\n * elements render as Fragments (children mount inline, `fallback` is\n * ignored). Thrown thenables still schedule a re-render on settle, so\n * eventual consistency works \u2014 just no fallback UI during the pending\n * window. Boundary-handler stack and hydration integration are stripped.\n */\n suspense?: boolean\n /**\n * `React.memo`. When `false`, memoized components still render but without\n * the prop-equality gate \u2014 every parent rerender passes through.\n * `shallowEqual` and the force-rerender bypass are stripped.\n */\n memo?: boolean\n /**\n * `React.forwardRef`. When `false`, forwardRef components still render but\n * the ref prop isn't forwarded to the inner function. React 19+ treats\n * refs as normal props on function components anyway, so most apps can\n * drop this. The dispatcher save/restore machinery is stripped.\n */\n forwardRef?: boolean\n /**\n * `React.lazy`. When `false`, lazy elements still resolve if their payload\n * is already available synchronously (e.g. pre-awaited RSC Flight); async\n * resolution throws a clear error. The hydration-deferred-reveal path and\n * Suspense coordination are stripped.\n */\n lazy?: boolean\n /**\n * Class components (`extends Component`). When `false`, class components\n * still render but only honor the core contract: constructor + `render()`\n * + `setState`. Dropped: `contextType`, `getDerivedStateFromProps`,\n * `shouldComponentUpdate`, `componentDidMount`/`Update`/`WillUnmount`,\n * `getDerivedStateFromError`/`componentDidCatch` (error boundaries).\n */\n classComponents?: boolean\n /**\n * SSR hydration (`hydrateRoot`). When `false`, `hydrateRoot` throws\n * (use `createRoot` for SPAs). The HydrationCursor / DOM adoption /\n * streaming-boundary coordination / event-replay / scroll-guard\n * machinery is stripped \u2014 the biggest single chunk of reducible code.\n */\n hydration?: boolean\n}\n\ninterface ResolvedFeatures {\n portal: boolean\n context: boolean\n suspense: boolean\n memo: boolean\n forwardRef: boolean\n lazy: boolean\n classComponents: boolean\n hydration: boolean\n}\n\nconst PRESET_DEFAULTS: Record<RedactPreset, ResolvedFeatures> = {\n // Opt-in: everything off. Turn individual features on via `features`.\n nano: {\n portal: false, context: false, suspense: false, memo: false,\n forwardRef: false, lazy: false, classComponents: false, hydration: false,\n },\n // Opt-out: everything on (drop-in React parity). Turn features off via `features`.\n full: {\n portal: true, context: true, suspense: true, memo: true,\n forwardRef: true, lazy: true, classComponents: true, hydration: true,\n },\n}\n\nfunction resolveFeatures(\n preset: RedactPreset,\n overrides: RedactFeatures,\n): ResolvedFeatures {\n const p = PRESET_DEFAULTS[preset]\n return {\n portal: overrides.portal ?? p.portal,\n context: overrides.context ?? p.context,\n suspense: overrides.suspense ?? p.suspense,\n memo: overrides.memo ?? p.memo,\n forwardRef: overrides.forwardRef ?? p.forwardRef,\n lazy: overrides.lazy ?? p.lazy,\n classComponents: overrides.classComponents ?? p.classComponents,\n hydration: overrides.hydration ?? p.hydration,\n }\n}\n\nexport interface RedactOptions {\n /** Skip aliasing specific specifiers, e.g. if a consumer wants real React somewhere. */\n skip?: ReadonlyArray<string>\n /**\n * Override package resolution root. Defaults to the Vite config root. Useful\n * for monorepos where the plugin lives in a different workspace than the\n * consumer app.\n */\n resolveFrom?: string\n /**\n * Explicit package roots, bypassing node_modules lookup. Keys are package\n * names (e.g. `@tanstack/redact`), values are absolute paths to the package\n * directory. Handy for cross-workspace testing / bring-your-own-build setups.\n */\n packageRoots?: Record<string, string>\n /**\n * Starting point for feature selection. `'full'` (default) turns every\n * feature on \u2014 drop-in React parity, opt-out individual features via\n * `features`. `'nano'` turns everything off \u2014 opt in to what you need.\n */\n preset?: RedactPreset\n /**\n * Per-feature overrides merged on top of the preset's defaults. Enables\n * fine-grained \"preset minus X\" or \"preset plus Y\" configurations.\n */\n features?: RedactFeatures\n}\n\n// Alias map. ORDER MATTERS \u2014 Vite's alias matcher uses first-match against\n// prefix, so more-specific specifiers MUST come before less-specific ones.\n// Without this, `react-dom/server` would prefix-match `react-dom` first and\n// resolve to `@tanstack/redact/dom/server` (wrong) instead of\n// `@tanstack/redact/server`.\n//\n// `use-sync-external-store` aliases are here because its CJS-only React 17\n// compat shim does `var React = require('react')`. That survives Vite's\n// pre-bundling intact and explodes in Cloudflare Workers (no `require`).\n// Modern React has `useSyncExternalStore` built-in, and `@tanstack/redact`\n// additionally exports `useSyncExternalStoreWithSelector` so this alias\n// is safe everywhere.\nconst ALIASES: Record<string, string> = {\n // ---- most-specific first ----\n 'use-sync-external-store/shim/with-selector': '@tanstack/redact',\n 'use-sync-external-store/shim/with-selector.js': '@tanstack/redact',\n 'use-sync-external-store/with-selector': '@tanstack/redact',\n 'use-sync-external-store/with-selector.js': '@tanstack/redact',\n 'use-sync-external-store/shim': '@tanstack/redact',\n 'use-sync-external-store': '@tanstack/redact',\n\n // React drop-in shim targets. Subpaths first.\n 'react/jsx-runtime': '@tanstack/redact/jsx-runtime',\n 'react/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',\n 'react/compiler-runtime': '@tanstack/redact/compiler-runtime',\n 'react-dom/client': '@tanstack/redact/dom-client',\n 'react-dom/server': '@tanstack/redact/server',\n 'react-dom/test-utils': '@tanstack/redact/dom-test-utils',\n 'react-dom': '@tanstack/redact/dom',\n react: '@tanstack/redact',\n scheduler: '@tanstack/redact/scheduler',\n\n // Self-aliases so Vite resolves `@tanstack/redact/*` imports to the same\n // canonical file path no matter where they originate (worker bundle vs\n // deps_ssr pre-bundle vs source). Without these, Cloudflare's\n // `noExternal: true` worker config inlines one copy while Vite's\n // optimizeDeps pre-bundles another, ending up with two separate\n // ReactSharedInternals instances and a null dispatcher in user hooks.\n // Subpaths first here too.\n '@tanstack/redact/jsx-runtime': '@tanstack/redact/jsx-runtime',\n '@tanstack/redact/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',\n '@tanstack/redact/compiler-runtime': '@tanstack/redact/compiler-runtime',\n '@tanstack/redact/dom-client': '@tanstack/redact/dom-client',\n '@tanstack/redact/dom-test-utils': '@tanstack/redact/dom-test-utils',\n '@tanstack/redact/server': '@tanstack/redact/server',\n '@tanstack/redact/scheduler': '@tanstack/redact/scheduler',\n '@tanstack/redact/dom': '@tanstack/redact/dom',\n '@tanstack/redact': '@tanstack/redact',\n}\n\nfunction splitSpecifier(specifier: string): { pkg: string; sub: string } {\n if (specifier.startsWith('@')) {\n const slash1 = specifier.indexOf('/')\n const slash2 = specifier.indexOf('/', slash1 + 1)\n if (slash2 < 0) return { pkg: specifier, sub: '' }\n return { pkg: specifier.slice(0, slash2), sub: specifier.slice(slash2 + 1) }\n }\n const slash = specifier.indexOf('/')\n if (slash < 0) return { pkg: specifier, sub: '' }\n return { pkg: specifier.slice(0, slash), sub: specifier.slice(slash + 1) }\n}\n\nfunction findPackageDir(pkg: string, fromDir: string): string | null {\n let dir = fromDir\n while (true) {\n const candidate = resolvePath(dir, 'node_modules', pkg)\n if (existsSync(resolvePath(candidate, 'package.json'))) return candidate\n const parent = dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n}\n\nfunction resolveExport(packageDir: string, sub: string): string | null {\n const pkgJsonPath = resolvePath(packageDir, 'package.json')\n let pkg: any\n try {\n pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf8'))\n } catch {\n return null\n }\n const key = sub ? './' + sub : '.'\n const exp = pkg.exports?.[key]\n // Prefer published `import` (dist/.js) over `source` \u2014 dist is a single\n // transformed bundle so Vite's dep optimizer doesn't thrash on dozens of\n // individual source files. The package keeps cross-subpath imports\n // external, so there's still only one runtime instance.\n const pick = (v: any): string | null => {\n if (typeof v === 'string') return v\n if (v && typeof v === 'object') {\n return pick(v.import ?? v.module ?? v.source ?? v.default ?? null)\n }\n return null\n }\n const target = pick(exp)\n if (target) return resolvePath(packageDir, target)\n if (!sub) {\n const main = pkg.module ?? pkg.main\n if (typeof main === 'string') return resolvePath(packageDir, main)\n }\n return null\n}\n\n// When installed from npm, `@tanstack/redact` is declared as a `dependency`\n// of consumer apps. Under pnpm's strict mode it ends up nested under the\n// plugin's own `.pnpm/@tanstack+redact@.../node_modules/` rather than\n// hoisted to the consumer's root, so a `findPackageDir` walk starting at\n// the Vite project root won't always find it. Search from the plugin's own\n// directory first (which walks into its nested node_modules), then fall\n// back to the consumer root for hoisted installs.\nconst pluginDir = dirname(fileURLToPath(import.meta.url))\n\nfunction resolveSpecifier(\n specifier: string,\n fromDir: string,\n packageRoots: Record<string, string>,\n): string | null {\n const { pkg, sub } = splitSpecifier(specifier)\n const packageDir =\n packageRoots[pkg] ??\n findPackageDir(pkg, pluginDir) ??\n findPackageDir(pkg, fromDir)\n if (!packageDir) return null\n const target = resolveExport(packageDir, sub)\n if (!target) return null\n // Canonicalize through pnpm symlinks. Under strict pnpm, the package may\n // live nested under `.pnpm/@tanstack+redact@.../node_modules/*`, but each\n // of those is itself a symlink to the flat `.pnpm/@tanstack+redact@.../`\n // entry. Vite's `fetchModule` (used by TanStack Start's server-fn\n // compiler) follows the realpath, so the id seen by the capture-transform\n // differs from the nested id we'd return. That leaves the compiler's\n // moduleCache keyed on the realpath while `getModuleInfo` looks up the\n // nested path \u2192 miss \u2192 \"could not load module info\". Returning the\n // canonical realpath here keeps the two sides in agreement.\n try {\n return realpathSync(target)\n } catch {\n return target\n }\n}\n\nexport function redact(options: RedactOptions = {}): any {\n const skip = new Set(options.skip ?? [])\n const entries = Object.entries(ALIASES).filter(([k]) => !skip.has(k))\n const features = resolveFeatures(options.preset ?? 'full', options.features ?? {})\n\n const resolvedMap: Record<string, string> = {}\n let done = false\n\n function resolveAll(root: string): void {\n if (done) return\n const fromDir = options.resolveFrom ?? root\n const packageRoots = options.packageRoots ?? {}\n for (const [from, to] of entries) {\n const resolved = resolveSpecifier(to, fromDir, packageRoots)\n if (resolved) resolvedMap[from] = resolved\n }\n done = true\n }\n\n return {\n name: 'redact',\n enforce: 'pre',\n\n config() {\n const excludeList = entries.map(([k]) => k)\n // Single package \u2014 only one name to dedupe / no-external.\n const noExt = ['@tanstack/redact']\n const aliasMap = Object.fromEntries(entries.filter(([from, to]) => from !== to))\n // Dedupe `@tanstack/redact` so Vite resolves it to a single instance\n // even when multiple packages (e.g. @tanstack/react-router and user\n // code) drag it into different parts of the module graph.\n const dedupe = noExt\n // Scope `resolve.alias` to client + ssr environments ONLY. Do NOT set\n // a top-level alias: it would apply to the `rsc` environment too,\n // where `@vitejs/plugin-rsc`'s vendored `react-server-dom-server`\n // imports `react` and needs the *real* React (with the `.d` field on\n // ReactSharedInternals that our shim deliberately doesn't have).\n // Aliasing `react` \u2192 `@tanstack/redact` in the RSC env crashes Flight\n // serialization. The Cloudflare vite-plugin's rolldown worker-runner\n // also pre-scans bare specifiers via Vite's alias map (not plugin\n // hooks), but it scans within the *ssr* environment specifically \u2014\n // so per-env `environments.ssr.resolve.alias` covers it. The\n // `enforce: 'pre'` resolveId hook below already skips RSC, so the\n // remaining concern is alias placement. Object form is required \u2014\n // array form is silently ignored by rolldown's worker-runner.\n return {\n environments: {\n client: {\n optimizeDeps: { exclude: excludeList },\n resolve: { alias: aliasMap, dedupe },\n },\n ssr: {\n optimizeDeps: { exclude: excludeList },\n resolve: { alias: aliasMap, dedupe, noExternal: noExt },\n },\n },\n ssr: { noExternal: noExt },\n }\n },\n\n configResolved(config: any) {\n resolveAll(config.root)\n // With `packageRoots`, package sources live outside the consumer's Vite\n // project root, so the default server.fs.allow list blocks them. Append\n // to the resolved allow list rather than replacing via `config()`, so we\n // keep Vite's defaults (root + node_modules + client runtime).\n const fsAllow = Object.values(options.packageRoots ?? {})\n if (fsAllow.length && config.server?.fs?.allow) {\n for (const p of fsAllow) {\n if (!config.server.fs.allow.includes(p)) {\n config.server.fs.allow.push(p)\n }\n }\n }\n },\n\n async resolveId(this: any, id: string, importer?: string, opts?: any) {\n // Skip the RSC environment \u2014 it relies on real React internals via\n // @vitejs/plugin-rsc's vendored react-server-dom. Substituting our\n // shim there breaks Flight serialization. Client + SSR envs still swap.\n const envName = this?.environment?.name\n if (envName === 'rsc') return null\n\n // Feature-flag swap: when the reconciler's `features/index` module\n // imports a feature by relative path, redirect to that feature's stub\n // if the flag is off. The stub registers a graceful-degradation\n // matcher (e.g. Portal \u2192 Fragment) so user code keeps working.\n if (importer && /[\\\\/]features[\\\\/]index\\.[jt]sx?$/.test(importer)) {\n const m = id.match(/^\\.\\/([a-z-]+)$/)\n if (m) {\n const name = m[1] as keyof ResolvedFeatures\n if (name in features && !features[name]) {\n const r = await this.resolve(`./${name}/stub`, importer, {\n ...opts,\n skipSelf: true,\n })\n if (r) return r.id\n }\n }\n }\n\n // Hydration swap: hydration isn't self-registering, so it's imported\n // from reconcile.ts, root.ts, and the Suspense/Lazy feature modules.\n // Any specifier ending in `/hydration` that resolves to our feature\n // module gets redirected to the stub when the flag is off.\n if (!features.hydration && importer && /[\\\\/]hydration$/.test(id)) {\n const r = await this.resolve(id, importer, { ...opts, skipSelf: true })\n if (r && /features[\\\\/]hydration[\\\\/]index\\.(ts|js)$/.test(r.id)) {\n return r.id.replace(/index\\.(ts|js)$/, 'stub.$1')\n }\n }\n\n return resolvedMap[id] ?? null\n },\n }\n}\n\nexport default redact\n"],
5
+ "mappings": ";AAAA,SAAS,YAAY,cAAc,oBAAoB;AACvD,SAAS,SAAS,WAAW,mBAAmB;AAChD,SAAS,qBAAqB;AAkF9B,IAAM,kBAA0D;AAAA;AAAA,EAE9D,MAAM;AAAA,IACJ,Q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IAAI,GAAG;AACvC,kBAAM,IAAI,MAAM,KAAK,QAAQ,KAAK,IAAI,SAAS,UAAU;AAAA,cACvD,GAAG;AAAA,cACH,UAAU;AAAA,YACZ,CAAC;AACD,gBAAI,EAAG,QAAO,EAAE;AAAA,UAClB;AAAA,QACF;AAAA,MACF;AAMA,UAAI,CAAC,SAAS,aAAa,YAAY,kBAAkB,KAAK,EAAE,GAAG;AACjE,cAAM,IAAI,MAAM,KAAK,QAAQ,IAAI,UAAU,EAAE,GAAG,MAAM,UAAU,KAAK,CAAC;AACtE,YAAI,KAAK,6CAA6C,KAAK,EAAE,EAAE,GAAG;AAChE,iBAAO,EAAE,GAAG,QAAQ,mBAAmB,SAAS;AAAA,QAClD;AAAA,MACF;AAEA,aAAO,YAAY,EAAE,KAAK;AAAA,IAC5B;AAAA,EACF;AACF;AAEA,IAAO,eAAQ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/redact",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "React, redacted. A minimal React-API-compatible drop-in replacement.",
5
5
  "type": "module",
6
6
  "main": "./dist/react/index.js",
@@ -19,6 +19,10 @@
19
19
  "types": "./dist/react/jsx-runtime.d.ts",
20
20
  "default": "./dist/react/jsx-runtime.js"
21
21
  },
22
+ "./compiler-runtime": {
23
+ "types": "./dist/react/compiler-runtime.d.ts",
24
+ "default": "./dist/react/compiler-runtime.js"
25
+ },
22
26
  "./dom": {
23
27
  "types": "./dist/dom/index.d.ts",
24
28
  "default": "./dist/dom/index.js"
@@ -71,9 +71,9 @@ export interface FiberRoot {
71
71
  current: Fiber
72
72
  pending: Set<Fiber>
73
73
  scheduled: boolean
74
- onRecoverableError?: (err: unknown) => void
75
- onCaughtError?: (err: unknown) => void
76
- onUncaughtError?: (err: unknown) => void
74
+ onRecoverableError?: ((err: unknown) => void) | undefined
75
+ onCaughtError?: ((err: unknown) => void) | undefined
76
+ onUncaughtError?: ((err: unknown) => void) | undefined
77
77
  identifierPrefix: string
78
78
  hydrating: boolean
79
79
  }
package/src/dom/client.ts CHANGED
@@ -2,3 +2,13 @@ import './features'
2
2
 
3
3
  export { createRoot, hydrateRoot } from './root'
4
4
  export type { Root, RootOptions } from './root'
5
+
6
+ // Default export — real React's `react-dom/client` is named-only too, but
7
+ // bundlers synthesize a default from the CJS `module.exports` object.
8
+ // Redact ships pure ESM, so without an explicit default, strict bundlers
9
+ // (rolldown, modern Vite) reject `import ReactDOM from 'react-dom/client'`.
10
+ import { createRoot, hydrateRoot } from './root'
11
+ export default {
12
+ createRoot,
13
+ hydrateRoot,
14
+ }
@@ -0,0 +1,22 @@
1
+ // React Compiler runtime — emitted code calls `c(size)` to obtain a
2
+ // per-component-instance memo cache. Each slot starts as a sentinel; the
3
+ // compiled code overwrites slots with computed values and uses sentinel
4
+ // identity to detect first-run / dependency-change.
5
+ //
6
+ // The cache must persist across renders of the same fiber, so we lean on
7
+ // `useRef`. Slots are filled with the canonical
8
+ // `Symbol.for('react.memo_cache_sentinel')` so any tooling that compares
9
+ // against the same well-known symbol stays interoperable.
10
+ import { useRef } from './hooks'
11
+
12
+ const MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel')
13
+
14
+ export function c(size: number): Array<unknown> {
15
+ const ref = useRef<Array<unknown> | null>(null)
16
+ if (ref.current === null) {
17
+ const arr = new Array<unknown>(size)
18
+ for (let i = 0; i < size; i++) arr[i] = MEMO_CACHE_SENTINEL
19
+ ref.current = arr
20
+ }
21
+ return ref.current
22
+ }
@@ -82,7 +82,7 @@ export function useSyncExternalStore<T>(
82
82
  return getDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)
83
83
  }
84
84
 
85
- export function use<T>(resource: any): T {
85
+ export function use<T>(resource: PromiseLike<T> | { _currentValue: T } | { $$typeof: symbol; _currentValue: T }): T {
86
86
  return getDispatcher().use(resource)
87
87
  }
88
88
 
@@ -1,4 +1,21 @@
1
1
  export { createElement, cloneElement, isValidElement, createRef, Fragment } from './element'
2
+ export type {
3
+ ReactElement,
4
+ ReactNode,
5
+ Key,
6
+ Ref,
7
+ RefObject,
8
+ RefCallback,
9
+ Dispatch,
10
+ SetStateAction,
11
+ EffectCallback,
12
+ DependencyList,
13
+ } from '../core'
14
+
15
+ // Lightweight functional-component alias — matches React's FC shape closely
16
+ // enough for the common `const X: FC<P> = (props) => …` pattern used in
17
+ // tests and downstream consumer code.
18
+ export type FC<P = {}> = (props: P & { children?: import('../core').ReactNode }) => import('../core').ReactElement | null
2
19
  export {
3
20
  useState,
4
21
  useReducer,
@@ -14,3 +14,23 @@ export function jsx(type: any, props: any, key?: any): ReactElement {
14
14
 
15
15
  export const jsxs = jsx
16
16
  export const jsxDEV = jsx
17
+
18
+ // Permissive JSX namespace — picked up by TypeScript via the
19
+ // `jsxImportSource: "@tanstack/redact"` + `jsx: "react-jsx"` pair. The
20
+ // runtime accepts any element type and any props; matching that with strict
21
+ // element typings would require an entire React.dom.d.ts surface, which
22
+ // isn't a stated goal of redact (consumers who want strict JSX still alias
23
+ // `react`/`react-dom` types from the real packages).
24
+ export namespace JSX {
25
+ export type Element = ReactElement
26
+ export type ElementType = any
27
+ export interface IntrinsicElements {
28
+ [elemName: string]: any
29
+ }
30
+ export interface ElementChildrenAttribute {
31
+ children: {}
32
+ }
33
+ export interface ElementAttributesProperty {
34
+ props: {}
35
+ }
36
+ }
package/src/react/memo.ts CHANGED
@@ -1,21 +1,37 @@
1
+ import type { ReactElement, ReactNode, Ref } from '../core'
2
+
1
3
  export const REACT_MEMO_TYPE = Symbol.for('react.memo')
2
4
  export const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref')
3
5
  export const REACT_LAZY_TYPE = Symbol.for('react.lazy')
4
6
 
7
+ // Component-shaped return type so JSX usage of memo/forwardRef/lazy results
8
+ // type-checks. The runtime value is a `$$typeof`-tagged record that the
9
+ // reconciler recognizes via type-matchers; the cast lets TypeScript treat
10
+ // it as a callable component at JSX sites without changing what the runtime
11
+ // actually does. `children` is included for the common
12
+ // `<Comp>...</Comp>` form even when the inner P doesn't list it.
13
+ export type ExoticComponent<P> = ((
14
+ props: P & { children?: ReactNode; ref?: any; key?: any },
15
+ ) => ReactElement | null) & {
16
+ readonly $$typeof: symbol
17
+ }
18
+
5
19
  export function memo<P>(
6
20
  type: (props: P) => any,
7
21
  areEqual?: (prev: Readonly<P>, next: Readonly<P>) => boolean,
8
- ) {
9
- return { $$typeof: REACT_MEMO_TYPE, type, compare: areEqual ?? null }
22
+ ): ExoticComponent<P> {
23
+ return { $$typeof: REACT_MEMO_TYPE, type, compare: areEqual ?? null } as unknown as ExoticComponent<P>
10
24
  }
11
25
 
12
26
  export function forwardRef<R, P = {}>(
13
27
  render: (props: P, ref: { current: R | null } | ((r: R | null) => void) | null) => any,
14
- ) {
15
- return { $$typeof: REACT_FORWARD_REF_TYPE, render }
28
+ ): ExoticComponent<P & { ref?: Ref<R> }> {
29
+ return { $$typeof: REACT_FORWARD_REF_TYPE, render } as unknown as ExoticComponent<P & { ref?: Ref<R> }>
16
30
  }
17
31
 
18
- export function lazy<T extends { default: any }>(ctor: () => Promise<T>) {
32
+ export function lazy<T extends { default: any }>(ctor: () => Promise<T>): ExoticComponent<
33
+ T['default'] extends (props: infer P) => any ? P : {}
34
+ > {
19
35
  const payload = {
20
36
  status: -1 as -1 | 0 | 1 | 2,
21
37
  result: undefined as any,
@@ -41,5 +57,5 @@ export function lazy<T extends { default: any }>(ctor: () => Promise<T>) {
41
57
  p.result = thenable
42
58
  throw thenable
43
59
  },
44
- }
60
+ } as unknown as ExoticComponent<T['default'] extends (props: infer P) => any ? P : {}>
45
61
  }
@@ -40,10 +40,10 @@ export interface SuspendedBoundary {
40
40
 
41
41
  export interface WalkOptions {
42
42
  emit: (chunk: string) => void
43
- onSuspend?: (boundary: SuspendedBoundary) => void
43
+ onSuspend?: ((boundary: SuspendedBoundary) => void) | undefined
44
44
  nextBoundaryId: () => number
45
- bootstrapped?: boolean
46
- isBoundaryResolution?: boolean
45
+ bootstrapped?: boolean | undefined
46
+ isBoundaryResolution?: boolean | undefined
47
47
  /**
48
48
  * Tracks whether the most recent emission within the *current text flow*
49
49
  * ended with a text node. When the next emission is also text, we emit a
package/src/vite/index.ts CHANGED
@@ -164,6 +164,7 @@ const ALIASES: Record<string, string> = {
164
164
  // React drop-in shim targets. Subpaths first.
165
165
  'react/jsx-runtime': '@tanstack/redact/jsx-runtime',
166
166
  'react/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',
167
+ 'react/compiler-runtime': '@tanstack/redact/compiler-runtime',
167
168
  'react-dom/client': '@tanstack/redact/dom-client',
168
169
  'react-dom/server': '@tanstack/redact/server',
169
170
  'react-dom/test-utils': '@tanstack/redact/dom-test-utils',
@@ -180,6 +181,7 @@ const ALIASES: Record<string, string> = {
180
181
  // Subpaths first here too.
181
182
  '@tanstack/redact/jsx-runtime': '@tanstack/redact/jsx-runtime',
182
183
  '@tanstack/redact/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',
184
+ '@tanstack/redact/compiler-runtime': '@tanstack/redact/compiler-runtime',
183
185
  '@tanstack/redact/dom-client': '@tanstack/redact/dom-client',
184
186
  '@tanstack/redact/dom-test-utils': '@tanstack/redact/dom-test-utils',
185
187
  '@tanstack/redact/server': '@tanstack/redact/server',