@tanstack/redact 0.0.1

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.
Files changed (233) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +4 -0
  3. package/dist/core/index.js.map +7 -0
  4. package/dist/core/internal.d.ts +76 -0
  5. package/dist/core/internal.js +59 -0
  6. package/dist/core/internal.js.map +7 -0
  7. package/dist/core/types.d.ts +21 -0
  8. package/dist/core/types.js +10 -0
  9. package/dist/core/types.js.map +7 -0
  10. package/dist/dom/_all.d.ts +17 -0
  11. package/dist/dom/_all.js +51 -0
  12. package/dist/dom/_all.js.map +7 -0
  13. package/dist/dom/client.d.ts +3 -0
  14. package/dist/dom/client.js +8 -0
  15. package/dist/dom/client.js.map +7 -0
  16. package/dist/dom/dispatcher.d.ts +20 -0
  17. package/dist/dom/dispatcher.js +267 -0
  18. package/dist/dom/dispatcher.js.map +7 -0
  19. package/dist/dom/dom.d.ts +10 -0
  20. package/dist/dom/dom.js +262 -0
  21. package/dist/dom/dom.js.map +7 -0
  22. package/dist/dom/event-replay.d.ts +13 -0
  23. package/dist/dom/event-replay.js +46 -0
  24. package/dist/dom/event-replay.js.map +7 -0
  25. package/dist/dom/features/class/full.d.ts +1 -0
  26. package/dist/dom/features/class/full.js +91 -0
  27. package/dist/dom/features/class/full.js.map +7 -0
  28. package/dist/dom/features/class/index.d.ts +1 -0
  29. package/dist/dom/features/class/index.js +3 -0
  30. package/dist/dom/features/class/index.js.map +7 -0
  31. package/dist/dom/features/class/stub.d.ts +1 -0
  32. package/dist/dom/features/class/stub.js +50 -0
  33. package/dist/dom/features/class/stub.js.map +7 -0
  34. package/dist/dom/features/context/full.d.ts +1 -0
  35. package/dist/dom/features/context/full.js +49 -0
  36. package/dist/dom/features/context/full.js.map +7 -0
  37. package/dist/dom/features/context/index.d.ts +1 -0
  38. package/dist/dom/features/context/index.js +3 -0
  39. package/dist/dom/features/context/index.js.map +7 -0
  40. package/dist/dom/features/context/stub.d.ts +1 -0
  41. package/dist/dom/features/context/stub.js +22 -0
  42. package/dist/dom/features/context/stub.js.map +7 -0
  43. package/dist/dom/features/forward-ref/full.d.ts +1 -0
  44. package/dist/dom/features/forward-ref/full.js +51 -0
  45. package/dist/dom/features/forward-ref/full.js.map +7 -0
  46. package/dist/dom/features/forward-ref/index.d.ts +1 -0
  47. package/dist/dom/features/forward-ref/index.js +3 -0
  48. package/dist/dom/features/forward-ref/index.js.map +7 -0
  49. package/dist/dom/features/forward-ref/stub.d.ts +1 -0
  50. package/dist/dom/features/forward-ref/stub.js +22 -0
  51. package/dist/dom/features/forward-ref/stub.js.map +7 -0
  52. package/dist/dom/features/hydration/full.d.ts +61 -0
  53. package/dist/dom/features/hydration/full.js +264 -0
  54. package/dist/dom/features/hydration/full.js.map +7 -0
  55. package/dist/dom/features/hydration/index.d.ts +1 -0
  56. package/dist/dom/features/hydration/index.js +3 -0
  57. package/dist/dom/features/hydration/index.js.map +7 -0
  58. package/dist/dom/features/hydration/stub.d.ts +28 -0
  59. package/dist/dom/features/hydration/stub.js +66 -0
  60. package/dist/dom/features/hydration/stub.js.map +7 -0
  61. package/dist/dom/features/index.d.ts +7 -0
  62. package/dist/dom/features/index.js +9 -0
  63. package/dist/dom/features/index.js.map +7 -0
  64. package/dist/dom/features/lazy/full.d.ts +1 -0
  65. package/dist/dom/features/lazy/full.js +78 -0
  66. package/dist/dom/features/lazy/full.js.map +7 -0
  67. package/dist/dom/features/lazy/index.d.ts +1 -0
  68. package/dist/dom/features/lazy/index.js +3 -0
  69. package/dist/dom/features/lazy/index.js.map +7 -0
  70. package/dist/dom/features/lazy/stub.d.ts +1 -0
  71. package/dist/dom/features/lazy/stub.js +36 -0
  72. package/dist/dom/features/lazy/stub.js.map +7 -0
  73. package/dist/dom/features/memo/full.d.ts +1 -0
  74. package/dist/dom/features/memo/full.js +59 -0
  75. package/dist/dom/features/memo/full.js.map +7 -0
  76. package/dist/dom/features/memo/index.d.ts +1 -0
  77. package/dist/dom/features/memo/index.js +3 -0
  78. package/dist/dom/features/memo/index.js.map +7 -0
  79. package/dist/dom/features/memo/stub.d.ts +1 -0
  80. package/dist/dom/features/memo/stub.js +36 -0
  81. package/dist/dom/features/memo/stub.js.map +7 -0
  82. package/dist/dom/features/portal/full.d.ts +1 -0
  83. package/dist/dom/features/portal/full.js +19 -0
  84. package/dist/dom/features/portal/full.js.map +7 -0
  85. package/dist/dom/features/portal/index.d.ts +1 -0
  86. package/dist/dom/features/portal/index.js +3 -0
  87. package/dist/dom/features/portal/index.js.map +7 -0
  88. package/dist/dom/features/portal/stub.d.ts +1 -0
  89. package/dist/dom/features/portal/stub.js +7 -0
  90. package/dist/dom/features/portal/stub.js.map +7 -0
  91. package/dist/dom/features/suspense/full.d.ts +1 -0
  92. package/dist/dom/features/suspense/full.js +146 -0
  93. package/dist/dom/features/suspense/full.js.map +7 -0
  94. package/dist/dom/features/suspense/index.d.ts +1 -0
  95. package/dist/dom/features/suspense/index.js +3 -0
  96. package/dist/dom/features/suspense/index.js.map +7 -0
  97. package/dist/dom/features/suspense/stub.d.ts +1 -0
  98. package/dist/dom/features/suspense/stub.js +6 -0
  99. package/dist/dom/features/suspense/stub.js.map +7 -0
  100. package/dist/dom/index.d.ts +25 -0
  101. package/dist/dom/index.js +45 -0
  102. package/dist/dom/index.js.map +7 -0
  103. package/dist/dom/portal.d.ts +2 -0
  104. package/dist/dom/portal.js +15 -0
  105. package/dist/dom/portal.js.map +7 -0
  106. package/dist/dom/reconcile.d.ts +40 -0
  107. package/dist/dom/reconcile.js +795 -0
  108. package/dist/dom/reconcile.js.map +7 -0
  109. package/dist/dom/root.d.ts +15 -0
  110. package/dist/dom/root.js +85 -0
  111. package/dist/dom/root.js.map +7 -0
  112. package/dist/dom/test-utils.d.ts +1 -0
  113. package/dist/dom/test-utils.js +10 -0
  114. package/dist/dom/test-utils.js.map +7 -0
  115. package/dist/react/children.d.ts +8 -0
  116. package/dist/react/children.js +75 -0
  117. package/dist/react/children.js.map +7 -0
  118. package/dist/react/class.d.ts +31 -0
  119. package/dist/react/class.js +40 -0
  120. package/dist/react/class.js.map +7 -0
  121. package/dist/react/context.d.ts +27 -0
  122. package/dist/react/context.js +31 -0
  123. package/dist/react/context.js.map +7 -0
  124. package/dist/react/element.d.ts +10 -0
  125. package/dist/react/element.js +64 -0
  126. package/dist/react/element.js.map +7 -0
  127. package/dist/react/hooks.d.ts +37 -0
  128. package/dist/react/hooks.js +146 -0
  129. package/dist/react/hooks.js.map +7 -0
  130. package/dist/react/index.d.ts +76 -0
  131. package/dist/react/index.js +187 -0
  132. package/dist/react/index.js.map +7 -0
  133. package/dist/react/jsx-runtime.d.ts +5 -0
  134. package/dist/react/jsx-runtime.js +21 -0
  135. package/dist/react/jsx-runtime.js.map +7 -0
  136. package/dist/react/memo.d.ts +29 -0
  137. package/dist/react/memo.js +47 -0
  138. package/dist/react/memo.js.map +7 -0
  139. package/dist/react/portal.d.ts +1 -0
  140. package/dist/react/portal.js +6 -0
  141. package/dist/react/portal.js.map +7 -0
  142. package/dist/react/shared-internals.d.ts +33 -0
  143. package/dist/react/shared-internals.js +29 -0
  144. package/dist/react/shared-internals.js.map +7 -0
  145. package/dist/react/suspense.d.ts +15 -0
  146. package/dist/react/suspense.js +16 -0
  147. package/dist/react/suspense.js.map +7 -0
  148. package/dist/scheduler/index.d.ts +44 -0
  149. package/dist/scheduler/index.js +109 -0
  150. package/dist/scheduler/index.js.map +7 -0
  151. package/dist/server/bootstrap-script.d.ts +22 -0
  152. package/dist/server/bootstrap-script.js +16 -0
  153. package/dist/server/bootstrap-script.js.map +7 -0
  154. package/dist/server/dispatcher.d.ts +37 -0
  155. package/dist/server/dispatcher.js +140 -0
  156. package/dist/server/dispatcher.js.map +7 -0
  157. package/dist/server/escape.d.ts +7 -0
  158. package/dist/server/escape.js +159 -0
  159. package/dist/server/escape.js.map +7 -0
  160. package/dist/server/index.d.ts +16 -0
  161. package/dist/server/index.js +26 -0
  162. package/dist/server/index.js.map +7 -0
  163. package/dist/server/renderToString.d.ts +7 -0
  164. package/dist/server/renderToString.js +29 -0
  165. package/dist/server/renderToString.js.map +7 -0
  166. package/dist/server/stream.d.ts +40 -0
  167. package/dist/server/stream.js +200 -0
  168. package/dist/server/stream.js.map +7 -0
  169. package/dist/server/walk.d.ts +33 -0
  170. package/dist/server/walk.js +298 -0
  171. package/dist/server/walk.js.map +7 -0
  172. package/dist/vite/index.d.ts +96 -0
  173. package/dist/vite/index.js +217 -0
  174. package/dist/vite/index.js.map +7 -0
  175. package/package.json +83 -0
  176. package/src/core/index.ts +2 -0
  177. package/src/core/internal.ts +107 -0
  178. package/src/core/types.ts +36 -0
  179. package/src/dom/_all.ts +54 -0
  180. package/src/dom/client.ts +4 -0
  181. package/src/dom/dispatcher.ts +318 -0
  182. package/src/dom/dom.ts +316 -0
  183. package/src/dom/event-replay.ts +55 -0
  184. package/src/dom/features/class/full.ts +104 -0
  185. package/src/dom/features/class/index.ts +1 -0
  186. package/src/dom/features/class/stub.ts +65 -0
  187. package/src/dom/features/context/full.ts +57 -0
  188. package/src/dom/features/context/index.ts +1 -0
  189. package/src/dom/features/context/stub.ts +32 -0
  190. package/src/dom/features/forward-ref/full.ts +54 -0
  191. package/src/dom/features/forward-ref/index.ts +1 -0
  192. package/src/dom/features/forward-ref/stub.ts +28 -0
  193. package/src/dom/features/hydration/full.ts +345 -0
  194. package/src/dom/features/hydration/index.ts +1 -0
  195. package/src/dom/features/hydration/stub.ts +72 -0
  196. package/src/dom/features/index.ts +11 -0
  197. package/src/dom/features/lazy/full.ts +98 -0
  198. package/src/dom/features/lazy/index.ts +1 -0
  199. package/src/dom/features/lazy/stub.ts +45 -0
  200. package/src/dom/features/memo/full.ts +74 -0
  201. package/src/dom/features/memo/index.ts +1 -0
  202. package/src/dom/features/memo/stub.ts +42 -0
  203. package/src/dom/features/portal/full.ts +22 -0
  204. package/src/dom/features/portal/index.ts +1 -0
  205. package/src/dom/features/portal/stub.ts +11 -0
  206. package/src/dom/features/suspense/full.ts +191 -0
  207. package/src/dom/features/suspense/index.ts +1 -0
  208. package/src/dom/features/suspense/stub.ts +12 -0
  209. package/src/dom/index.ts +33 -0
  210. package/src/dom/portal.ts +16 -0
  211. package/src/dom/reconcile.ts +1169 -0
  212. package/src/dom/root.ts +107 -0
  213. package/src/dom/test-utils.ts +6 -0
  214. package/src/react/children.ts +85 -0
  215. package/src/react/class.ts +56 -0
  216. package/src/react/context.ts +50 -0
  217. package/src/react/element.ts +80 -0
  218. package/src/react/hooks.ts +190 -0
  219. package/src/react/index.ts +132 -0
  220. package/src/react/jsx-runtime.ts +16 -0
  221. package/src/react/memo.ts +45 -0
  222. package/src/react/portal.ts +1 -0
  223. package/src/react/shared-internals.ts +79 -0
  224. package/src/react/suspense.ts +18 -0
  225. package/src/scheduler/index.ts +124 -0
  226. package/src/server/bootstrap-script.ts +52 -0
  227. package/src/server/dispatcher.ts +158 -0
  228. package/src/server/escape.ts +187 -0
  229. package/src/server/index.ts +26 -0
  230. package/src/server/renderToString.ts +33 -0
  231. package/src/server/stream.ts +302 -0
  232. package/src/server/walk.ts +448 -0
  233. package/src/vite/index.ts +401 -0
@@ -0,0 +1,33 @@
1
+ import type { Fiber, FiberRoot, Hook } from '../core';
2
+ export interface Dispatcher {
3
+ useState<S>(initial: S | (() => S)): [S, (s: S | ((p: S) => S)) => void];
4
+ useReducer<S, A>(reducer: (s: S, a: A) => S, initial: S | any, init?: (a: any) => S): [S, (a: A) => void];
5
+ useEffect(create: () => any, deps?: ReadonlyArray<unknown>): void;
6
+ useLayoutEffect(create: () => any, deps?: ReadonlyArray<unknown>): void;
7
+ useInsertionEffect(create: () => any, deps?: ReadonlyArray<unknown>): void;
8
+ useRef<T>(initial: T): {
9
+ current: T;
10
+ };
11
+ useMemo<T>(factory: () => T, deps?: ReadonlyArray<unknown>): T;
12
+ useCallback<T extends Function>(fn: T, deps?: ReadonlyArray<unknown>): T;
13
+ useContext<T>(ctx: any): T;
14
+ useImperativeHandle<T>(ref: any, factory: () => T, deps?: ReadonlyArray<unknown>): void;
15
+ useDebugValue<T>(value: T, formatter?: (v: T) => any): void;
16
+ useId(): string;
17
+ useTransition(): [boolean, (fn: () => void) => void];
18
+ useDeferredValue<T>(v: T): T;
19
+ useSyncExternalStore<T>(subscribe: (cb: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T): T;
20
+ use<T>(promiseOrContext: any): T;
21
+ }
22
+ interface SharedInternals {
23
+ H: Dispatcher | null;
24
+ T: any;
25
+ S: ((fn: () => void) => void) | null;
26
+ currentFiber: Fiber | null;
27
+ currentRoot: FiberRoot | null;
28
+ currentHook: Hook | null;
29
+ hookIndex: number;
30
+ }
31
+ export declare const ReactSharedInternals: SharedInternals;
32
+ export declare function getDispatcher(): Dispatcher;
33
+ export {};
@@ -0,0 +1,29 @@
1
+ // packages/redact/src/react/shared-internals.ts
2
+ var KEY = /* @__PURE__ */ Symbol.for("@tanstack/redact.ReactSharedInternals");
3
+ var g = globalThis;
4
+ var ReactSharedInternals = g[KEY] ?? (g[KEY] = {
5
+ H: null,
6
+ T: null,
7
+ S: null,
8
+ currentFiber: null,
9
+ currentRoot: null,
10
+ currentHook: null,
11
+ hookIndex: 0
12
+ });
13
+ function getDispatcher() {
14
+ const d = ReactSharedInternals.H;
15
+ if (!d) {
16
+ if (true) {
17
+ throw new Error(
18
+ 'Hooks can only be called inside a function component. If this fires during SSR/RSC, the most common cause is a component that uses client-only hooks (useState, useContext, useRouter, etc.) being rendered in the RSC server environment without a "use client" directive at the top of its file.'
19
+ );
20
+ }
21
+ throw new Error("Hooks can only be called inside a function component.");
22
+ }
23
+ return d;
24
+ }
25
+ export {
26
+ ReactSharedInternals,
27
+ getDispatcher
28
+ };
29
+ //# sourceMappingURL=shared-internals.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/react/shared-internals.ts"],
4
+ "sourcesContent": ["import type { Fiber, FiberRoot, Hook } from '../core'\n\nexport interface Dispatcher {\n useState<S>(initial: S | (() => S)): [S, (s: S | ((p: S) => S)) => void]\n useReducer<S, A>(\n reducer: (s: S, a: A) => S,\n initial: S | any,\n init?: (a: any) => S,\n ): [S, (a: A) => void]\n useEffect(create: () => any, deps?: ReadonlyArray<unknown>): void\n useLayoutEffect(create: () => any, deps?: ReadonlyArray<unknown>): void\n useInsertionEffect(create: () => any, deps?: ReadonlyArray<unknown>): void\n useRef<T>(initial: T): { current: T }\n useMemo<T>(factory: () => T, deps?: ReadonlyArray<unknown>): T\n useCallback<T extends Function>(fn: T, deps?: ReadonlyArray<unknown>): T\n useContext<T>(ctx: any): T\n useImperativeHandle<T>(ref: any, factory: () => T, deps?: ReadonlyArray<unknown>): void\n useDebugValue<T>(value: T, formatter?: (v: T) => any): void\n useId(): string\n useTransition(): [boolean, (fn: () => void) => void]\n useDeferredValue<T>(v: T): T\n useSyncExternalStore<T>(\n subscribe: (cb: () => void) => () => void,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n ): T\n use<T>(promiseOrContext: any): T\n}\n\ninterface SharedInternals {\n H: Dispatcher | null\n T: any\n S: ((fn: () => void) => void) | null\n currentFiber: Fiber | null\n currentRoot: FiberRoot | null\n currentHook: Hook | null\n hookIndex: number\n}\n\n// Stash the singleton on `globalThis` under a registered symbol. Module-scoped\n// state goes wrong fast in environments that end up with multiple copies of\n// `@tanstack/redact` in flight \u2014 most notably Cloudflare's `vite-plugin` dev\n// mode, where the worker entry inlines `@tanstack/redact` once via `noExternal`\n// while user code reaches a separate pre-bundled `deps_ssr/redact.js` copy.\n// Each copy would otherwise have its own `ReactSharedInternals.H`, so the SSR\n// dispatcher installed by one would be invisible to hooks called through the\n// other and `useContext` would explode with \"Hooks can only be called inside a\n// function component\". `Symbol.for` survives module re-evaluation and isolate\n// boundaries, giving every copy the same backing object.\nconst KEY = Symbol.for('@tanstack/redact.ReactSharedInternals')\nconst g = globalThis as unknown as { [k: symbol]: SharedInternals | undefined }\n\nexport const ReactSharedInternals: SharedInternals =\n g[KEY] ??\n (g[KEY] = {\n H: null,\n T: null,\n S: null,\n currentFiber: null,\n currentRoot: null,\n currentHook: null,\n hookIndex: 0,\n })\n\nexport function getDispatcher(): Dispatcher {\n const d = ReactSharedInternals.H\n if (!d) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n 'Hooks can only be called inside a function component. ' +\n 'If this fires during SSR/RSC, the most common cause is a component that uses client-only hooks ' +\n '(useState, useContext, useRouter, etc.) being rendered in the RSC server environment without a ' +\n '\"use client\" directive at the top of its file.',\n )\n }\n throw new Error('Hooks can only be called inside a function component.')\n }\n return d\n}\n"],
5
+ "mappings": ";AAiDA,IAAM,MAAM,uBAAO,IAAI,uCAAuC;AAC9D,IAAM,IAAI;AAEH,IAAM,uBACX,EAAE,GAAG,MACJ,EAAE,GAAG,IAAI;AAAA,EACR,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,cAAc;AAAA,EACd,aAAa;AAAA,EACb,aAAa;AAAA,EACb,WAAW;AACb;AAEK,SAAS,gBAA4B;AAC1C,QAAM,IAAI,qBAAqB;AAC/B,MAAI,CAAC,GAAG;AACN,QAAI,MAAuC;AACzC,YAAM,IAAI;AAAA,QACR;AAAA,MAIF;AAAA,IACF;AACA,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ export declare const REACT_SUSPENSE_TYPE: unique symbol;
2
+ export declare const REACT_STRICT_MODE_TYPE: unique symbol;
3
+ export declare const REACT_PROFILER_TYPE: unique symbol;
4
+ export declare const Suspense: (props: {
5
+ children?: any;
6
+ fallback?: any;
7
+ }) => any;
8
+ export declare const StrictMode: (props: {
9
+ children?: any;
10
+ }) => any;
11
+ export declare const Profiler: (props: {
12
+ id: string;
13
+ onRender?: any;
14
+ children?: any;
15
+ }) => any;
@@ -0,0 +1,16 @@
1
+ // packages/redact/src/react/suspense.ts
2
+ var REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
3
+ var REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode");
4
+ var REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler");
5
+ var Suspense = REACT_SUSPENSE_TYPE;
6
+ var StrictMode = REACT_STRICT_MODE_TYPE;
7
+ var Profiler = REACT_PROFILER_TYPE;
8
+ export {
9
+ Profiler,
10
+ REACT_PROFILER_TYPE,
11
+ REACT_STRICT_MODE_TYPE,
12
+ REACT_SUSPENSE_TYPE,
13
+ StrictMode,
14
+ Suspense
15
+ };
16
+ //# sourceMappingURL=suspense.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/react/suspense.ts"],
4
+ "sourcesContent": ["export const REACT_SUSPENSE_TYPE = Symbol.for('react.suspense')\nexport const REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode')\nexport const REACT_PROFILER_TYPE = Symbol.for('react.profiler')\n\nexport const Suspense = REACT_SUSPENSE_TYPE as any as (props: {\n children?: any\n fallback?: any\n}) => any\n\nexport const StrictMode = REACT_STRICT_MODE_TYPE as any as (props: {\n children?: any\n}) => any\n\nexport const Profiler = REACT_PROFILER_TYPE as any as (props: {\n id: string\n onRender?: any\n children?: any\n}) => any\n"],
5
+ "mappings": ";AAAO,IAAM,sBAAsB,uBAAO,IAAI,gBAAgB;AACvD,IAAM,yBAAyB,uBAAO,IAAI,mBAAmB;AAC7D,IAAM,sBAAsB,uBAAO,IAAI,gBAAgB;AAEvD,IAAM,WAAW;AAKjB,IAAM,aAAa;AAInB,IAAM,WAAW;",
6
+ "names": []
7
+ }
@@ -0,0 +1,44 @@
1
+ type Callback = () => unknown;
2
+ interface Task {
3
+ id: number;
4
+ callback: Callback | null;
5
+ priority: number;
6
+ cancelled: boolean;
7
+ }
8
+ export declare function unstable_scheduleCallback(priority: number, cb: Callback): Task;
9
+ export declare function unstable_cancelCallback(task: Task): void;
10
+ export declare function unstable_shouldYield(): boolean;
11
+ export declare function unstable_requestPaint(): void;
12
+ export declare function unstable_now(): number;
13
+ export declare function unstable_getCurrentPriorityLevel(): number;
14
+ export declare function unstable_runWithPriority<T>(_priority: number, fn: () => T): T;
15
+ export declare function unstable_next<T>(fn: () => T): T;
16
+ export declare function unstable_wrapCallback<T extends (...args: any[]) => any>(fn: T): T;
17
+ export declare function unstable_continueExecution(): void;
18
+ export declare function unstable_pauseExecution(): void;
19
+ export declare function unstable_getFirstCallbackNode(): Task | null;
20
+ export declare const unstable_IdlePriority = 5;
21
+ export declare const unstable_ImmediatePriority = 1;
22
+ export declare const unstable_LowPriority = 4;
23
+ export declare const unstable_NormalPriority = 3;
24
+ export declare const unstable_UserBlockingPriority = 2;
25
+ declare const _default: {
26
+ unstable_scheduleCallback: typeof unstable_scheduleCallback;
27
+ unstable_cancelCallback: typeof unstable_cancelCallback;
28
+ unstable_shouldYield: typeof unstable_shouldYield;
29
+ unstable_requestPaint: typeof unstable_requestPaint;
30
+ unstable_now: typeof unstable_now;
31
+ unstable_getCurrentPriorityLevel: typeof unstable_getCurrentPriorityLevel;
32
+ unstable_runWithPriority: typeof unstable_runWithPriority;
33
+ unstable_next: typeof unstable_next;
34
+ unstable_wrapCallback: typeof unstable_wrapCallback;
35
+ unstable_continueExecution: typeof unstable_continueExecution;
36
+ unstable_pauseExecution: typeof unstable_pauseExecution;
37
+ unstable_getFirstCallbackNode: typeof unstable_getFirstCallbackNode;
38
+ unstable_IdlePriority: number;
39
+ unstable_ImmediatePriority: number;
40
+ unstable_LowPriority: number;
41
+ unstable_NormalPriority: number;
42
+ unstable_UserBlockingPriority: number;
43
+ };
44
+ export default _default;
@@ -0,0 +1,109 @@
1
+ // packages/redact/src/scheduler/index.ts
2
+ var PRIORITY_IMMEDIATE = 1;
3
+ var PRIORITY_USER_BLOCKING = 2;
4
+ var PRIORITY_NORMAL = 3;
5
+ var PRIORITY_LOW = 4;
6
+ var PRIORITY_IDLE = 5;
7
+ var nextId = 0;
8
+ function unstable_scheduleCallback(priority, cb) {
9
+ const task = {
10
+ id: ++nextId,
11
+ callback: cb,
12
+ priority,
13
+ cancelled: false
14
+ };
15
+ const run = () => {
16
+ if (task.cancelled || !task.callback) return;
17
+ const fn = task.callback;
18
+ task.callback = null;
19
+ try {
20
+ fn();
21
+ } catch (e) {
22
+ setTimeout(() => {
23
+ throw e;
24
+ }, 0);
25
+ }
26
+ };
27
+ if (priority <= PRIORITY_IMMEDIATE) {
28
+ queueMicrotask(run);
29
+ } else {
30
+ setTimeout(run, 0);
31
+ }
32
+ return task;
33
+ }
34
+ function unstable_cancelCallback(task) {
35
+ task.cancelled = true;
36
+ task.callback = null;
37
+ }
38
+ function unstable_shouldYield() {
39
+ return false;
40
+ }
41
+ function unstable_requestPaint() {
42
+ }
43
+ function unstable_now() {
44
+ return typeof performance !== "undefined" ? performance.now() : Date.now();
45
+ }
46
+ function unstable_getCurrentPriorityLevel() {
47
+ return PRIORITY_NORMAL;
48
+ }
49
+ function unstable_runWithPriority(_priority, fn) {
50
+ return fn();
51
+ }
52
+ function unstable_next(fn) {
53
+ return fn();
54
+ }
55
+ function unstable_wrapCallback(fn) {
56
+ return fn;
57
+ }
58
+ function unstable_continueExecution() {
59
+ }
60
+ function unstable_pauseExecution() {
61
+ }
62
+ function unstable_getFirstCallbackNode() {
63
+ return null;
64
+ }
65
+ var unstable_IdlePriority = PRIORITY_IDLE;
66
+ var unstable_ImmediatePriority = PRIORITY_IMMEDIATE;
67
+ var unstable_LowPriority = PRIORITY_LOW;
68
+ var unstable_NormalPriority = PRIORITY_NORMAL;
69
+ var unstable_UserBlockingPriority = PRIORITY_USER_BLOCKING;
70
+ var scheduler_default = {
71
+ unstable_scheduleCallback,
72
+ unstable_cancelCallback,
73
+ unstable_shouldYield,
74
+ unstable_requestPaint,
75
+ unstable_now,
76
+ unstable_getCurrentPriorityLevel,
77
+ unstable_runWithPriority,
78
+ unstable_next,
79
+ unstable_wrapCallback,
80
+ unstable_continueExecution,
81
+ unstable_pauseExecution,
82
+ unstable_getFirstCallbackNode,
83
+ unstable_IdlePriority,
84
+ unstable_ImmediatePriority,
85
+ unstable_LowPriority,
86
+ unstable_NormalPriority,
87
+ unstable_UserBlockingPriority
88
+ };
89
+ export {
90
+ scheduler_default as default,
91
+ unstable_IdlePriority,
92
+ unstable_ImmediatePriority,
93
+ unstable_LowPriority,
94
+ unstable_NormalPriority,
95
+ unstable_UserBlockingPriority,
96
+ unstable_cancelCallback,
97
+ unstable_continueExecution,
98
+ unstable_getCurrentPriorityLevel,
99
+ unstable_getFirstCallbackNode,
100
+ unstable_next,
101
+ unstable_now,
102
+ unstable_pauseExecution,
103
+ unstable_requestPaint,
104
+ unstable_runWithPriority,
105
+ unstable_scheduleCallback,
106
+ unstable_shouldYield,
107
+ unstable_wrapCallback
108
+ };
109
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/scheduler/index.ts"],
4
+ "sourcesContent": ["// Minimal `scheduler` package surface \u2014 enough for React-ecosystem libraries\n// (react-three/fiber, react-query's older scheduler calls, some devtools) to\n// resolve the import without crashing. We don't implement priority lanes or\n// interruptible work; everything runs on microtask or the next task.\n\nconst PRIORITY_IMMEDIATE = 1\nconst PRIORITY_USER_BLOCKING = 2\nconst PRIORITY_NORMAL = 3\nconst PRIORITY_LOW = 4\nconst PRIORITY_IDLE = 5\n\ntype Callback = () => unknown\n\ninterface Task {\n id: number\n callback: Callback | null\n priority: number\n cancelled: boolean\n}\n\nlet nextId = 0\n\nexport function unstable_scheduleCallback(priority: number, cb: Callback): Task {\n const task: Task = {\n id: ++nextId,\n callback: cb,\n priority,\n cancelled: false,\n }\n const run = () => {\n if (task.cancelled || !task.callback) return\n const fn = task.callback\n task.callback = null\n try {\n fn()\n } catch (e) {\n // Re-throw on next task so the host sees it\n setTimeout(() => {\n throw e\n }, 0)\n }\n }\n // Immediate \u2192 microtask so ordering is predictable; everything else \u2192 next task.\n if (priority <= PRIORITY_IMMEDIATE) {\n queueMicrotask(run)\n } else {\n setTimeout(run, 0)\n }\n return task\n}\n\nexport function unstable_cancelCallback(task: Task): void {\n task.cancelled = true\n task.callback = null\n}\n\nexport function unstable_shouldYield(): boolean {\n // We never yield \u2014 work runs to completion on whichever task schedules it.\n return false\n}\n\nexport function unstable_requestPaint(): void {\n // no-op\n}\n\nexport function unstable_now(): number {\n return typeof performance !== 'undefined' ? performance.now() : Date.now()\n}\n\nexport function unstable_getCurrentPriorityLevel(): number {\n return PRIORITY_NORMAL\n}\n\nexport function unstable_runWithPriority<T>(_priority: number, fn: () => T): T {\n return fn()\n}\n\nexport function unstable_next<T>(fn: () => T): T {\n return fn()\n}\n\nexport function unstable_wrapCallback<T extends (...args: any[]) => any>(fn: T): T {\n return fn\n}\n\nexport function unstable_continueExecution(): void {\n // no-op\n}\n\nexport function unstable_pauseExecution(): void {\n // no-op\n}\n\nexport function unstable_getFirstCallbackNode(): Task | null {\n return null\n}\n\nexport const unstable_IdlePriority = PRIORITY_IDLE\nexport const unstable_ImmediatePriority = PRIORITY_IMMEDIATE\nexport const unstable_LowPriority = PRIORITY_LOW\nexport const unstable_NormalPriority = PRIORITY_NORMAL\nexport const unstable_UserBlockingPriority = PRIORITY_USER_BLOCKING\n\n// Some libraries (e.g. @react-three/fiber) import `scheduler` with a default\n// binding expecting the namespace object. Provide one.\nexport default {\n unstable_scheduleCallback,\n unstable_cancelCallback,\n unstable_shouldYield,\n unstable_requestPaint,\n unstable_now,\n unstable_getCurrentPriorityLevel,\n unstable_runWithPriority,\n unstable_next,\n unstable_wrapCallback,\n unstable_continueExecution,\n unstable_pauseExecution,\n unstable_getFirstCallbackNode,\n unstable_IdlePriority,\n unstable_ImmediatePriority,\n unstable_LowPriority,\n unstable_NormalPriority,\n unstable_UserBlockingPriority,\n}\n"],
5
+ "mappings": ";AAKA,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAC/B,IAAM,kBAAkB;AACxB,IAAM,eAAe;AACrB,IAAM,gBAAgB;AAWtB,IAAI,SAAS;AAEN,SAAS,0BAA0B,UAAkB,IAAoB;AAC9E,QAAM,OAAa;AAAA,IACjB,IAAI,EAAE;AAAA,IACN,UAAU;AAAA,IACV;AAAA,IACA,WAAW;AAAA,EACb;AACA,QAAM,MAAM,MAAM;AAChB,QAAI,KAAK,aAAa,CAAC,KAAK,SAAU;AACtC,UAAM,KAAK,KAAK;AAChB,SAAK,WAAW;AAChB,QAAI;AACF,SAAG;AAAA,IACL,SAAS,GAAG;AAEV,iBAAW,MAAM;AACf,cAAM;AAAA,MACR,GAAG,CAAC;AAAA,IACN;AAAA,EACF;AAEA,MAAI,YAAY,oBAAoB;AAClC,mBAAe,GAAG;AAAA,EACpB,OAAO;AACL,eAAW,KAAK,CAAC;AAAA,EACnB;AACA,SAAO;AACT;AAEO,SAAS,wBAAwB,MAAkB;AACxD,OAAK,YAAY;AACjB,OAAK,WAAW;AAClB;AAEO,SAAS,uBAAgC;AAE9C,SAAO;AACT;AAEO,SAAS,wBAA8B;AAE9C;AAEO,SAAS,eAAuB;AACrC,SAAO,OAAO,gBAAgB,cAAc,YAAY,IAAI,IAAI,KAAK,IAAI;AAC3E;AAEO,SAAS,mCAA2C;AACzD,SAAO;AACT;AAEO,SAAS,yBAA4B,WAAmB,IAAgB;AAC7E,SAAO,GAAG;AACZ;AAEO,SAAS,cAAiB,IAAgB;AAC/C,SAAO,GAAG;AACZ;AAEO,SAAS,sBAAyD,IAAU;AACjF,SAAO;AACT;AAEO,SAAS,6BAAmC;AAEnD;AAEO,SAAS,0BAAgC;AAEhD;AAEO,SAAS,gCAA6C;AAC3D,SAAO;AACT;AAEO,IAAM,wBAAwB;AAC9B,IAAM,6BAA6B;AACnC,IAAM,uBAAuB;AAC7B,IAAM,0BAA0B;AAChC,IAAM,gCAAgC;AAI7C,IAAO,oBAAQ;AAAA,EACb;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;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Inline client runtime injected into the streamed HTML. Two jobs:
3
+ *
4
+ * 1. Reveal suspense boundaries as their resolved chunks arrive ($RC).
5
+ * 2. Capture interaction events from the moment the shell is visible so the
6
+ * main bundle can replay them against un-hydrated subtrees ($RE_q buffer).
7
+ *
8
+ * Wire format:
9
+ * Fallback: <!--$?ID--><div hidden id="B:ID">fallback</div><!--/$-->
10
+ * Resolved: emits <div hidden id="S:ID">real</div><script>$RC(ID)</script>
11
+ * which splices real into place and rewrites the comment to <!--$ID-->.
12
+ *
13
+ * Client hydration calls $RH(ID, cb) to register a callback invoked once the
14
+ * boundary has been revealed (or immediately, if it was already revealed).
15
+ *
16
+ * Early-event buffering: before the main bundle is parsed, we attach capture
17
+ * listeners for a small set of interactive events and push them into a buffer.
18
+ * The bundle drains and replays them via the replay code in @tanstack/redact/dom.
19
+ */
20
+ export declare const BOUNDARY_REVEAL_RUNTIME: string;
21
+ export declare function injectBootstrapScript(nonce?: string): string;
22
+ export declare function revealScript(id: number, nonce?: string): string;
@@ -0,0 +1,16 @@
1
+ // packages/redact/src/server/bootstrap-script.ts
2
+ var BOUNDARY_REVEAL_RUNTIME = `(function(){var c={};window.$RH=function(i,f){if(!document.getElementById("B:"+i))f();else c[i]=f;};window.$RC=function(i){var s=document.getElementById("S:"+i),b=document.getElementById("B:"+i);if(!s||!b)return;var p=b.parentNode,m=b.previousSibling;while(s.firstChild)p.insertBefore(s.firstChild,b);s.parentNode.removeChild(s);p.removeChild(b);if(m&&m.nodeType===8)m.data="$"+i;if(c[i]){var f=c[i];delete c[i];f()}};var q=[];window.$RE_q=q;var evs=["click","submit","input","change","keydown"];function h(e){q.push([e.type,e.target,e.timeStamp])}for(var j=0;j<evs.length;j++)document.addEventListener(evs[j],h,true);window.$RE_stop=function(){for(var j=0;j<evs.length;j++)document.removeEventListener(evs[j],h,true)};})();`;
3
+ function injectBootstrapScript(nonce) {
4
+ const n = nonce ? ` nonce="${nonce}"` : "";
5
+ return `<script${n}>${BOUNDARY_REVEAL_RUNTIME}<\/script>`;
6
+ }
7
+ function revealScript(id, nonce) {
8
+ const n = nonce ? ` nonce="${nonce}"` : "";
9
+ return `<script${n}>$RC(${id})<\/script>`;
10
+ }
11
+ export {
12
+ BOUNDARY_REVEAL_RUNTIME,
13
+ injectBootstrapScript,
14
+ revealScript
15
+ };
16
+ //# sourceMappingURL=bootstrap-script.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/server/bootstrap-script.ts"],
4
+ "sourcesContent": ["/**\n * Inline client runtime injected into the streamed HTML. Two jobs:\n *\n * 1. Reveal suspense boundaries as their resolved chunks arrive ($RC).\n * 2. Capture interaction events from the moment the shell is visible so the\n * main bundle can replay them against un-hydrated subtrees ($RE_q buffer).\n *\n * Wire format:\n * Fallback: <!--$?ID--><div hidden id=\"B:ID\">fallback</div><!--/$-->\n * Resolved: emits <div hidden id=\"S:ID\">real</div><script>$RC(ID)</script>\n * which splices real into place and rewrites the comment to <!--$ID-->.\n *\n * Client hydration calls $RH(ID, cb) to register a callback invoked once the\n * boundary has been revealed (or immediately, if it was already revealed).\n *\n * Early-event buffering: before the main bundle is parsed, we attach capture\n * listeners for a small set of interactive events and push them into a buffer.\n * The bundle drains and replays them via the replay code in @tanstack/redact/dom.\n */\nexport const BOUNDARY_REVEAL_RUNTIME =\n `(function(){` +\n `var c={};` +\n `window.$RH=function(i,f){` +\n `if(!document.getElementById(\"B:\"+i))f();` +\n `else c[i]=f;` +\n `};` +\n `window.$RC=function(i){` +\n `var s=document.getElementById(\"S:\"+i),b=document.getElementById(\"B:\"+i);` +\n `if(!s||!b)return;` +\n `var p=b.parentNode,m=b.previousSibling;` +\n `while(s.firstChild)p.insertBefore(s.firstChild,b);` +\n `s.parentNode.removeChild(s);` +\n `p.removeChild(b);` +\n `if(m&&m.nodeType===8)m.data=\"$\"+i;` +\n `if(c[i]){var f=c[i];delete c[i];f()}` +\n `};` +\n `var q=[];window.$RE_q=q;` +\n `var evs=[\"click\",\"submit\",\"input\",\"change\",\"keydown\"];` +\n `function h(e){q.push([e.type,e.target,e.timeStamp])}` +\n `for(var j=0;j<evs.length;j++)document.addEventListener(evs[j],h,true);` +\n `window.$RE_stop=function(){for(var j=0;j<evs.length;j++)document.removeEventListener(evs[j],h,true)};` +\n `})();`\n\nexport function injectBootstrapScript(nonce?: string): string {\n const n = nonce ? ` nonce=\"${nonce}\"` : ''\n return `<script${n}>${BOUNDARY_REVEAL_RUNTIME}</script>`\n}\n\nexport function revealScript(id: number, nonce?: string): string {\n const n = nonce ? ` nonce=\"${nonce}\"` : ''\n return `<script${n}>$RC(${id})</script>`\n}\n"],
5
+ "mappings": ";AAmBO,IAAM,0BACX;AAuBK,SAAS,sBAAsB,OAAwB;AAC5D,QAAM,IAAI,QAAQ,WAAW,KAAK,MAAM;AACxC,SAAO,UAAU,CAAC,IAAI,uBAAuB;AAC/C;AAEO,SAAS,aAAa,IAAY,OAAwB;AAC/D,QAAM,IAAI,QAAQ,WAAW,KAAK,MAAM;AACxC,SAAO,UAAU,CAAC,QAAQ,EAAE;AAC9B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,37 @@
1
+ export declare function beginSSR(identifierPrefix?: string): void;
2
+ export declare function endSSR(): void;
3
+ export declare function pushContext(context: any, value: any): void;
4
+ export declare function popContext(context: any): void;
5
+ export type ContextSnapshot = Array<{
6
+ context: any;
7
+ value: any;
8
+ }>;
9
+ export declare function snapshotContexts(): ContextSnapshot;
10
+ /**
11
+ * Push snapshot values and return a function that pops them.
12
+ * Called when we re-render a suspended boundary so it sees the same provider
13
+ * values that were active at suspension time.
14
+ */
15
+ export declare function applyContextSnapshot(snapshot: ContextSnapshot): () => void;
16
+ export declare const ssrDispatcher: {
17
+ useState<S>(initial: S | (() => S)): [S, any];
18
+ useReducer<S, A>(_reducer: (s: S, a: A) => S, initialArg: any, init?: (a: any) => S): any[];
19
+ useEffect(): void;
20
+ useLayoutEffect(): void;
21
+ useInsertionEffect(): void;
22
+ useRef<T>(initial: T): {
23
+ current: T;
24
+ };
25
+ useMemo<T>(factory: () => T): T;
26
+ useCallback<T extends Function>(fn: T): T;
27
+ useContext<T>(ctx: any): T;
28
+ useImperativeHandle(): void;
29
+ useDebugValue(): void;
30
+ useId(): string;
31
+ useTransition(): [boolean, (fn: () => void) => void];
32
+ useDeferredValue<T>(v: T): T;
33
+ useSyncExternalStore<T>(_subscribe: (cb: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T): T;
34
+ use<T>(resource: any): T;
35
+ };
36
+ export declare function installSSRDispatcher(): void;
37
+ export declare function uninstallSSRDispatcher(): void;
@@ -0,0 +1,140 @@
1
+ // packages/redact/src/server/dispatcher.ts
2
+ import { ReactSharedInternals, REACT_CONTEXT_TYPE } from "../react";
3
+ var frame = null;
4
+ function beginSSR(identifierPrefix = ":R") {
5
+ frame = { idCounter: 0, identifierPrefix, contextStack: [] };
6
+ }
7
+ function endSSR() {
8
+ if (frame) {
9
+ for (let i = frame.contextStack.length - 1; i >= 0; i--) {
10
+ const { context, prev } = frame.contextStack[i];
11
+ context._currentValue = prev;
12
+ }
13
+ }
14
+ frame = null;
15
+ }
16
+ function pushContext(context, value) {
17
+ if (!frame) throw new Error("pushContext called outside SSR");
18
+ frame.contextStack.push({ context, prev: context._currentValue });
19
+ context._currentValue = value;
20
+ }
21
+ function popContext(context) {
22
+ if (!frame) return;
23
+ const top = frame.contextStack.pop();
24
+ if (top && top.context === context) context._currentValue = top.prev;
25
+ }
26
+ function snapshotContexts() {
27
+ if (!frame) return [];
28
+ const out = [];
29
+ for (const entry of frame.contextStack) {
30
+ out.push({ context: entry.context, value: entry.context._currentValue });
31
+ }
32
+ return out;
33
+ }
34
+ function applyContextSnapshot(snapshot) {
35
+ for (const { context, value } of snapshot) pushContext(context, value);
36
+ return () => {
37
+ for (let i = snapshot.length - 1; i >= 0; i--) popContext(snapshot[i].context);
38
+ };
39
+ }
40
+ var ssrDispatcher = {
41
+ useState(initial) {
42
+ const v = typeof initial === "function" ? initial() : initial;
43
+ return [v, (() => {
44
+ })];
45
+ },
46
+ useReducer(_reducer, initialArg, init) {
47
+ const v = init ? init(initialArg) : initialArg;
48
+ return [v, (() => {
49
+ })];
50
+ },
51
+ useEffect() {
52
+ },
53
+ useLayoutEffect() {
54
+ },
55
+ useInsertionEffect() {
56
+ },
57
+ useRef(initial) {
58
+ return { current: initial };
59
+ },
60
+ useMemo(factory) {
61
+ return factory();
62
+ },
63
+ useCallback(fn) {
64
+ return fn;
65
+ },
66
+ useContext(ctx) {
67
+ return ctx._currentValue;
68
+ },
69
+ useImperativeHandle() {
70
+ },
71
+ useDebugValue() {
72
+ },
73
+ useId() {
74
+ if (!frame) return ":r0:";
75
+ return `${frame.identifierPrefix}${(frame.idCounter++).toString(36)}`;
76
+ },
77
+ useTransition() {
78
+ return [false, (fn) => fn()];
79
+ },
80
+ useDeferredValue(v) {
81
+ return v;
82
+ },
83
+ useSyncExternalStore(_subscribe, getSnapshot, getServerSnapshot) {
84
+ return getServerSnapshot ? getServerSnapshot() : getSnapshot();
85
+ },
86
+ use(resource) {
87
+ if (resource == null) throw new Error("use() received null or undefined");
88
+ if (resource.$$typeof === REACT_CONTEXT_TYPE) {
89
+ return resource._currentValue;
90
+ }
91
+ if (typeof resource.then === "function") {
92
+ const thenable = resource;
93
+ switch (thenable.status) {
94
+ case "fulfilled":
95
+ return thenable.value;
96
+ case "rejected":
97
+ throw thenable.reason;
98
+ default: {
99
+ if (thenable.status === void 0) {
100
+ thenable.status = "pending";
101
+ thenable.then(
102
+ (v) => {
103
+ if (thenable.status === "pending") {
104
+ thenable.status = "fulfilled";
105
+ thenable.value = v;
106
+ }
107
+ },
108
+ (e) => {
109
+ if (thenable.status === "pending") {
110
+ thenable.status = "rejected";
111
+ thenable.reason = e;
112
+ }
113
+ }
114
+ );
115
+ }
116
+ throw thenable;
117
+ }
118
+ }
119
+ }
120
+ throw new Error("use() expected a Promise or Context");
121
+ }
122
+ };
123
+ function installSSRDispatcher() {
124
+ ReactSharedInternals.H = ssrDispatcher;
125
+ }
126
+ function uninstallSSRDispatcher() {
127
+ ReactSharedInternals.H = null;
128
+ }
129
+ export {
130
+ applyContextSnapshot,
131
+ beginSSR,
132
+ endSSR,
133
+ installSSRDispatcher,
134
+ popContext,
135
+ pushContext,
136
+ snapshotContexts,
137
+ ssrDispatcher,
138
+ uninstallSSRDispatcher
139
+ };
140
+ //# sourceMappingURL=dispatcher.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/server/dispatcher.ts"],
4
+ "sourcesContent": ["import { ReactSharedInternals, REACT_CONTEXT_TYPE } from '../react'\n\ninterface SSRFrame {\n idCounter: number\n identifierPrefix: string\n contextStack: Array<{ context: any; prev: any }>\n}\n\nlet frame: SSRFrame | null = null\n\nexport function beginSSR(identifierPrefix = ':R'): void {\n frame = { idCounter: 0, identifierPrefix, contextStack: [] }\n}\n\nexport function endSSR(): void {\n // Restore any remaining pushed contexts (defensive)\n if (frame) {\n for (let i = frame.contextStack.length - 1; i >= 0; i--) {\n const { context, prev } = frame.contextStack[i]!\n context._currentValue = prev\n }\n }\n frame = null\n}\n\nexport function pushContext(context: any, value: any): void {\n if (!frame) throw new Error('pushContext called outside SSR')\n frame.contextStack.push({ context, prev: context._currentValue })\n context._currentValue = value\n}\n\nexport function popContext(context: any): void {\n if (!frame) return\n const top = frame.contextStack.pop()\n if (top && top.context === context) context._currentValue = top.prev\n}\n\nexport type ContextSnapshot = Array<{ context: any; value: any }>\n\nexport function snapshotContexts(): ContextSnapshot {\n if (!frame) return []\n const out: ContextSnapshot = []\n for (const entry of frame.contextStack) {\n out.push({ context: entry.context, value: entry.context._currentValue })\n }\n return out\n}\n\n/**\n * Push snapshot values and return a function that pops them.\n * Called when we re-render a suspended boundary so it sees the same provider\n * values that were active at suspension time.\n */\nexport function applyContextSnapshot(snapshot: ContextSnapshot): () => void {\n for (const { context, value } of snapshot) pushContext(context, value)\n return () => {\n for (let i = snapshot.length - 1; i >= 0; i--) popContext(snapshot[i]!.context)\n }\n}\n\nexport const ssrDispatcher = {\n useState<S>(initial: S | (() => S)) {\n const v = typeof initial === 'function' ? (initial as () => S)() : initial\n return [v, (() => {}) as any] as [S, any]\n },\n useReducer<S, A>(_reducer: (s: S, a: A) => S, initialArg: any, init?: (a: any) => S) {\n const v = init ? init(initialArg) : initialArg\n return [v, (() => {}) as any]\n },\n useEffect() {\n // noop on server\n },\n useLayoutEffect() {\n // noop on server\n },\n useInsertionEffect() {\n // noop on server\n },\n useRef<T>(initial: T) {\n return { current: initial }\n },\n useMemo<T>(factory: () => T) {\n return factory()\n },\n useCallback<T extends Function>(fn: T) {\n return fn\n },\n useContext<T>(ctx: any): T {\n return ctx._currentValue\n },\n useImperativeHandle() {\n // noop on server\n },\n useDebugValue() {\n // noop\n },\n useId(): string {\n if (!frame) return ':r0:'\n return `${frame.identifierPrefix}${(frame.idCounter++).toString(36)}`\n },\n useTransition(): [boolean, (fn: () => void) => void] {\n return [false, (fn) => fn()]\n },\n useDeferredValue<T>(v: T): T {\n return v\n },\n useSyncExternalStore<T>(\n _subscribe: (cb: () => void) => () => void,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n ): T {\n return getServerSnapshot ? getServerSnapshot() : getSnapshot()\n },\n use<T>(resource: any): T {\n if (resource == null) throw new Error('use() received null or undefined')\n if (resource.$$typeof === REACT_CONTEXT_TYPE) {\n return resource._currentValue\n }\n if (typeof resource.then === 'function') {\n const thenable = resource\n switch (thenable.status) {\n case 'fulfilled':\n return thenable.value\n case 'rejected':\n throw thenable.reason\n default: {\n if (thenable.status === undefined) {\n thenable.status = 'pending'\n thenable.then(\n (v: any) => {\n if (thenable.status === 'pending') {\n thenable.status = 'fulfilled'\n thenable.value = v\n }\n },\n (e: any) => {\n if (thenable.status === 'pending') {\n thenable.status = 'rejected'\n thenable.reason = e\n }\n },\n )\n }\n throw thenable\n }\n }\n }\n throw new Error('use() expected a Promise or Context')\n },\n}\n\nexport function installSSRDispatcher(): void {\n ReactSharedInternals.H = ssrDispatcher as any\n}\n\nexport function uninstallSSRDispatcher(): void {\n ReactSharedInternals.H = null\n}\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ export declare function escapeAttr(value: string): string;
2
+ export declare function escapeText(value: string): string;
3
+ export declare function escapeScript(value: string): string;
4
+ export declare const VOID_ELEMENTS: Set<string>;
5
+ export declare const RAW_TEXT_ELEMENTS: Set<string>;
6
+ export declare const ATTR_ALIASES: Record<string, string>;
7
+ export declare function attrToHtml(name: string, value: unknown): string;