@tanstack/redact 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/internal.d.ts +23 -39
- package/dist/core/internal.js +7 -23
- package/dist/core/internal.js.map +3 -3
- package/dist/dom/dispatcher.d.ts +3 -1
- package/dist/dom/dispatcher.js +104 -97
- package/dist/dom/dispatcher.js.map +2 -2
- package/dist/dom/dom.js +1 -1
- package/dist/dom/dom.js.map +2 -2
- package/dist/dom/event-replay.js +7 -29
- package/dist/dom/event-replay.js.map +2 -2
- package/dist/dom/features/class/full.js +16 -16
- package/dist/dom/features/class/full.js.map +2 -2
- package/dist/dom/features/class/stub.js +7 -7
- package/dist/dom/features/class/stub.js.map +2 -2
- package/dist/dom/features/context/full.js +7 -7
- package/dist/dom/features/context/full.js.map +2 -2
- package/dist/dom/features/context/stub.js +3 -3
- package/dist/dom/features/context/stub.js.map +2 -2
- package/dist/dom/features/forward-ref/full.js +11 -11
- package/dist/dom/features/forward-ref/full.js.map +2 -2
- package/dist/dom/features/hydration/full.d.ts +26 -14
- package/dist/dom/features/hydration/full.js +412 -92
- package/dist/dom/features/hydration/full.js.map +2 -2
- package/dist/dom/features/hydration/stub.d.ts +13 -12
- package/dist/dom/features/hydration/stub.js +23 -8
- package/dist/dom/features/hydration/stub.js.map +2 -2
- package/dist/dom/features/lazy/full.js +3 -43
- package/dist/dom/features/lazy/full.js.map +2 -2
- package/dist/dom/features/lazy/stub.js +1 -1
- package/dist/dom/features/lazy/stub.js.map +2 -2
- package/dist/dom/features/memo/full.js +3 -3
- package/dist/dom/features/memo/full.js.map +2 -2
- package/dist/dom/features/memo/stub.js +1 -1
- package/dist/dom/features/memo/stub.js.map +2 -2
- package/dist/dom/features/portal/full.js +2 -2
- package/dist/dom/features/portal/full.js.map +2 -2
- package/dist/dom/features/suspense/full.js +151 -109
- package/dist/dom/features/suspense/full.js.map +2 -2
- package/dist/dom/reconcile.d.ts +3 -1
- package/dist/dom/reconcile.js +141 -129
- package/dist/dom/reconcile.js.map +2 -2
- package/dist/dom/root-internal.d.ts +9 -0
- package/dist/dom/root-internal.js +31 -0
- package/dist/dom/root-internal.js.map +7 -0
- package/dist/dom/root.d.ts +1 -1
- package/dist/dom/root.js +4 -136
- package/dist/dom/root.js.map +2 -2
- package/dist/dom/test-utils.js +1 -1
- package/dist/dom/test-utils.js.map +2 -2
- package/dist/react/children.js +4 -1
- package/dist/react/children.js.map +2 -2
- package/dist/react/class.js +8 -2
- package/dist/react/class.js.map +2 -2
- package/dist/react/context.js +4 -1
- package/dist/react/context.js.map +2 -2
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +2 -2
- package/dist/react/shared-internals.d.ts +4 -7
- package/dist/react/shared-internals.js +4 -7
- package/dist/react/shared-internals.js.map +2 -2
- package/dist/server/stream.d.ts +5 -1
- package/dist/server/stream.js.map +2 -2
- package/dist/vite/index.js +19 -3
- package/dist/vite/index.js.map +2 -2
- package/package.json +1 -1
- package/src/core/internal.ts +30 -50
- package/src/dom/dispatcher.ts +114 -105
- package/src/dom/dom.ts +1 -1
- package/src/dom/event-replay.ts +14 -30
- package/src/dom/features/class/full.ts +16 -16
- package/src/dom/features/class/stub.ts +7 -7
- package/src/dom/features/context/full.ts +7 -7
- package/src/dom/features/context/stub.ts +3 -3
- package/src/dom/features/forward-ref/full.ts +11 -11
- package/src/dom/features/hydration/full.ts +516 -104
- package/src/dom/features/hydration/stub.ts +28 -14
- package/src/dom/features/lazy/full.ts +3 -56
- package/src/dom/features/lazy/stub.ts +1 -1
- package/src/dom/features/memo/full.ts +3 -3
- package/src/dom/features/memo/stub.ts +1 -1
- package/src/dom/features/portal/full.ts +2 -2
- package/src/dom/features/suspense/full.ts +176 -129
- package/src/dom/reconcile.ts +164 -170
- package/src/dom/root-internal.ts +40 -0
- package/src/dom/root.ts +5 -165
- package/src/dom/test-utils.ts +1 -1
- package/src/react/children.ts +4 -1
- package/src/react/class.ts +8 -2
- package/src/react/context.ts +4 -1
- package/src/react/index.ts +1 -1
- package/src/react/shared-internals.ts +8 -14
- package/src/server/stream.ts +9 -4
- package/src/vite/index.ts +34 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react/children.ts"],
|
|
4
|
-
"sourcesContent": ["import { isValidElement, cloneElement } from './element'\nimport type { ReactNode, ReactElement } from '../core'\n\nfunction flatten(node: ReactNode, out: any[], prefix: string): void {\n if (node == null || typeof node === 'boolean') return\n if (Array.isArray(node)) {\n for (let i = 0; i < node.length; i++) flatten(node[i], out, prefix + '.' + i)\n return\n }\n out.push(node)\n}\n\nfunction getKey(node: any, index: number, prefix: string): string {\n if (isValidElement(node) && node.key != null) return prefix + '$' + node.key\n return prefix + ':' + index\n}\n\nfunction mapChildren(\n children: ReactNode,\n fn: (child: ReactNode, index: number) => any,\n prefix = '',\n): any[] {\n const flat: any[] = []\n flatten(children, flat, prefix)\n const out: any[] = []\n for (let i = 0; i < flat.length; i++) {\n const child = flat[i]\n const mapped = fn(child, i)\n if (mapped == null) continue\n if (Array.isArray(mapped)) {\n for (let j = 0; j < mapped.length; j++) {\n const m = mapped[j]\n if (m == null) continue\n out.push(\n isValidElement(m) && m.key == null\n ? cloneElement(m as ReactElement, { key: getKey(child, i, prefix) + '/' + j })\n : m,\n )\n }\n } else {\n out.push(\n isValidElement(mapped) && mapped.key == null\n ? cloneElement(mapped as ReactElement, { key: getKey(child, i, prefix) })\n : mapped,\n )\n }\n }\n return out\n}\n\nexport const Children = {\n map(children: ReactNode, fn: (child: ReactNode, index: number) => any): any[] | null {\n if (children == null) return null\n return mapChildren(children, fn)\n },\n forEach(children: ReactNode, fn: (child: ReactNode, index: number) => void): void {\n if (children == null) return\n mapChildren(children, (c, i) => {\n fn(c, i)\n return null\n })\n },\n count(children: ReactNode): number {\n let n = 0\n const flat: any[] = []\n flatten(children, flat, '')\n for (let i = 0; i < flat.length; i++) n++\n return n\n },\n toArray(children: ReactNode): any[] {\n const flat: any[] = []\n flatten(children, flat, '')\n return flat.map((c, i) =>\n isValidElement(c) && c.key == null\n ? cloneElement(c as ReactElement, { key: '' + i })\n : c,\n )\n },\n only(children: ReactNode): ReactElement {\n if (!isValidElement(children)) {\n throw new Error('Children.only expected a single React element.')\n }\n return children\n },\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,gBAAgB,oBAAoB;AAG7C,SAAS,QAAQ,MAAiB,KAAY,QAAsB;AAClE,MAAI,QAAQ,QAAQ,OAAO,SAAS,UAAW;AAC/C,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,IAAK,SAAQ,KAAK,CAAC,GAAG,KAAK,SAAS,MAAM,CAAC;AAC5E;AAAA,EACF;AACA,MAAI,KAAK,IAAI;AACf;AAEA,SAAS,OAAO,MAAW,OAAe,QAAwB;AAChE,MAAI,eAAe,IAAI,KAAK,KAAK,OAAO,KAAM,QAAO,SAAS,MAAM,KAAK;AACzE,SAAO,SAAS,MAAM;AACxB;AAEA,SAAS,YACP,UACA,IACA,SAAS,IACF;AACP,QAAM,OAAc,CAAC;AACrB,UAAQ,UAAU,MAAM,MAAM;AAC9B,QAAM,MAAa,CAAC;AACpB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,UAAM,SAAS,GAAG,OAAO,CAAC;AAC1B,QAAI,UAAU,KAAM;AACpB,QAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,eAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,cAAM,IAAI,OAAO,CAAC;AAClB,YAAI,KAAK,KAAM;AACf,YAAI;AAAA,UACF,eAAe,CAAC,KAAK,EAAE,OAAO,OAC1B,aAAa,GAAmB,EAAE,KAAK,OAAO,OAAO,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC,IAC3E;AAAA,QACN;AAAA,MACF;AAAA,IACF,OAAO;AACL,UAAI;AAAA,QACF,eAAe,MAAM,KAAK,OAAO,OAAO,OACpC,aAAa,QAAwB,EAAE,KAAK,OAAO,OAAO,GAAG,MAAM,EAAE,CAAC,IACtE;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,IAAM,WAAW;AAAA,EACtB,IAAI,UAAqB,IAA4D;AACnF,QAAI,YAAY,KAAM,QAAO;AAC7B,WAAO,YAAY,UAAU,EAAE;AAAA,EACjC;AAAA,EACA,QAAQ,UAAqB,IAAqD;AAChF,QAAI,YAAY,KAAM;AACtB,gBAAY,UAAU,CAAC,GAAG,MAAM;AAC9B,SAAG,GAAG,CAAC;AACP,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAAA,EACA,MAAM,UAA6B;AACjC,QAAI,IAAI;AACR,UAAM,OAAc,CAAC;AACrB,YAAQ,UAAU,MAAM,EAAE;AAC1B,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,IAAK;AACtC,WAAO;AAAA,EACT;AAAA,EACA,QAAQ,UAA4B;AAClC,UAAM,OAAc,CAAC;AACrB,YAAQ,UAAU,MAAM,EAAE;AAC1B,WAAO,KAAK;AAAA,MAAI,CAAC,GAAG,MAClB,eAAe,CAAC,KAAK,EAAE,OAAO,OAC1B,aAAa,GAAmB,EAAE,KAAK,KAAK,EAAE,CAAC,IAC/C;AAAA,IACN;AAAA,EACF;AAAA,EACA,KAAK,UAAmC;AACtC,QAAI,CAAC,eAAe,QAAQ,GAAG;AAC7B,
|
|
4
|
+
"sourcesContent": ["import { isValidElement, cloneElement } from './element'\nimport type { ReactNode, ReactElement } from '../core'\n\nfunction flatten(node: ReactNode, out: any[], prefix: string): void {\n if (node == null || typeof node === 'boolean') return\n if (Array.isArray(node)) {\n for (let i = 0; i < node.length; i++) flatten(node[i], out, prefix + '.' + i)\n return\n }\n out.push(node)\n}\n\nfunction getKey(node: any, index: number, prefix: string): string {\n if (isValidElement(node) && node.key != null) return prefix + '$' + node.key\n return prefix + ':' + index\n}\n\nfunction mapChildren(\n children: ReactNode,\n fn: (child: ReactNode, index: number) => any,\n prefix = '',\n): any[] {\n const flat: any[] = []\n flatten(children, flat, prefix)\n const out: any[] = []\n for (let i = 0; i < flat.length; i++) {\n const child = flat[i]\n const mapped = fn(child, i)\n if (mapped == null) continue\n if (Array.isArray(mapped)) {\n for (let j = 0; j < mapped.length; j++) {\n const m = mapped[j]\n if (m == null) continue\n out.push(\n isValidElement(m) && m.key == null\n ? cloneElement(m as ReactElement, { key: getKey(child, i, prefix) + '/' + j })\n : m,\n )\n }\n } else {\n out.push(\n isValidElement(mapped) && mapped.key == null\n ? cloneElement(mapped as ReactElement, { key: getKey(child, i, prefix) })\n : mapped,\n )\n }\n }\n return out\n}\n\nexport const Children = {\n map(children: ReactNode, fn: (child: ReactNode, index: number) => any): any[] | null {\n if (children == null) return null\n return mapChildren(children, fn)\n },\n forEach(children: ReactNode, fn: (child: ReactNode, index: number) => void): void {\n if (children == null) return\n mapChildren(children, (c, i) => {\n fn(c, i)\n return null\n })\n },\n count(children: ReactNode): number {\n let n = 0\n const flat: any[] = []\n flatten(children, flat, '')\n for (let i = 0; i < flat.length; i++) n++\n return n\n },\n toArray(children: ReactNode): any[] {\n const flat: any[] = []\n flatten(children, flat, '')\n return flat.map((c, i) =>\n isValidElement(c) && c.key == null\n ? cloneElement(c as ReactElement, { key: '' + i })\n : c,\n )\n },\n only(children: ReactNode): ReactElement {\n if (!isValidElement(children)) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('Children.only expected a single React element.')\n }\n throw new Error()\n }\n return children\n },\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,gBAAgB,oBAAoB;AAG7C,SAAS,QAAQ,MAAiB,KAAY,QAAsB;AAClE,MAAI,QAAQ,QAAQ,OAAO,SAAS,UAAW;AAC/C,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,aAAS,IAAI,GAAG,IAAI,KAAK,QA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,CAAC;AACP,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAAA,EACA,MAAM,UAA6B;AACjC,QAAI,IAAI;AACR,UAAM,OAAc,CAAC;AACrB,YAAQ,UAAU,MAAM,EAAE;AAC1B,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,IAAK;AACtC,WAAO;AAAA,EACT;AAAA,EACA,QAAQ,UAA4B;AAClC,UAAM,OAAc,CAAC;AACrB,YAAQ,UAAU,MAAM,EAAE;AAC1B,WAAO,KAAK;AAAA,MAAI,CAAC,GAAG,MAClB,eAAe,CAAC,KAAK,EAAE,OAAO,OAC1B,aAAa,GAAmB,EAAE,KAAK,KAAK,EAAE,CAAC,IAC/C;AAAA,IACN;AAAA,EACF;AAAA,EACA,KAAK,UAAmC;AACtC,QAAI,CAAC,eAAe,QAAQ,GAAG;AAC7B,UAAI,MAAuC;AACzC,cAAM,IAAI,MAAM,gDAAgD;AAAA,MAClE;AACA,YAAM,IAAI,MAAM;AAAA,IAClB;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/react/class.js
CHANGED
|
@@ -17,7 +17,10 @@ var Component = class {
|
|
|
17
17
|
}
|
|
18
18
|
setState(updater, callback) {
|
|
19
19
|
if (!this._enqueueUpdate) {
|
|
20
|
-
|
|
20
|
+
if (true) {
|
|
21
|
+
throw new Error("Cannot call setState on an um component.");
|
|
22
|
+
}
|
|
23
|
+
throw new Error();
|
|
21
24
|
}
|
|
22
25
|
this._enqueueUpdate(updater, callback);
|
|
23
26
|
}
|
|
@@ -26,7 +29,10 @@ var Component = class {
|
|
|
26
29
|
this._forceUpdate(callback);
|
|
27
30
|
}
|
|
28
31
|
render() {
|
|
29
|
-
|
|
32
|
+
if (true) {
|
|
33
|
+
throw new Error("Component subclass must implement render().");
|
|
34
|
+
}
|
|
35
|
+
throw new Error();
|
|
30
36
|
}
|
|
31
37
|
};
|
|
32
38
|
Component.prototype.isReactComponent = {};
|
package/dist/react/class.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react/class.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReactNode } from '../core'\n\ntype SetStateCallback<S, P> =\n | Partial<S>\n | ((prev: S, props: P) => Partial<S> | null)\n | null\n\nexport class Component<P = {}, S = {}> {\n static contextType?: any\n static getDerivedStateFromProps?(props: any, state: any): any\n static getDerivedStateFromError?(error: any): any\n static defaultProps?: any\n static displayName?: string\n\n props: P\n state: S = {} as S\n context: any\n refs: Record<string, any> = {}\n\n // Injected by reconciler\n _fiber: any = null\n _enqueueUpdate: ((updater: SetStateCallback<S, P>, cb?: () => void) => void) | null = null\n _forceUpdate: ((cb?: () => void) => void) | null = null\n\n constructor(props: P, context?: any) {\n this.props = props\n this.context = context\n }\n\n setState(updater: SetStateCallback<S, P>, callback?: () => void): void {\n if (!this._enqueueUpdate) {\n throw new Error('Cannot call setState on an
|
|
5
|
-
"mappings": ";AAOO,IAAM,YAAN,MAAgC;AAAA,EACrC,OAAO;AAAA,EAGP,OAAO;AAAA,EACP,OAAO;AAAA,EAEP;AAAA,EACA,QAAW,CAAC;AAAA,EACZ;AAAA,EACA,OAA4B,CAAC;AAAA;AAAA,EAG7B,SAAc;AAAA,EACd,iBAAsF;AAAA,EACtF,eAAmD;AAAA,EAEnD,YAAY,OAAU,SAAe;AACnC,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,SAAS,SAAiC,UAA6B;AACrE,QAAI,CAAC,KAAK,gBAAgB;AACxB,
|
|
4
|
+
"sourcesContent": ["import type { ReactNode } from '../core'\n\ntype SetStateCallback<S, P> =\n | Partial<S>\n | ((prev: S, props: P) => Partial<S> | null)\n | null\n\nexport class Component<P = {}, S = {}> {\n static contextType?: any\n static getDerivedStateFromProps?(props: any, state: any): any\n static getDerivedStateFromError?(error: any): any\n static defaultProps?: any\n static displayName?: string\n\n props: P\n state: S = {} as S\n context: any\n refs: Record<string, any> = {}\n\n // Injected by reconciler\n _fiber: any = null\n _enqueueUpdate: ((updater: SetStateCallback<S, P>, cb?: () => void) => void) | null = null\n _forceUpdate: ((cb?: () => void) => void) | null = null\n\n constructor(props: P, context?: any) {\n this.props = props\n this.context = context\n }\n\n setState(updater: SetStateCallback<S, P>, callback?: () => void): void {\n if (!this._enqueueUpdate) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('Cannot call setState on an um component.')\n }\n throw new Error()\n }\n this._enqueueUpdate(updater, callback)\n }\n\n forceUpdate(callback?: () => void): void {\n if (!this._forceUpdate) return\n this._forceUpdate(callback)\n }\n\n render(): ReactNode {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('Component subclass must implement render().')\n }\n throw new Error()\n }\n\n componentDidMount?(): void\n componentDidUpdate?(prevProps: P, prevState: S, snapshot?: any): void\n componentWillUnmount?(): void\n shouldComponentUpdate?(nextProps: P, nextState: S, nextCtx: any): boolean\n getSnapshotBeforeUpdate?(prevProps: P, prevState: S): any\n componentDidCatch?(error: any, info: { componentStack: string }): void\n}\n;(Component.prototype as any).isReactComponent = {}\n\nexport class PureComponent<P = {}, S = {}> extends Component<P, S> {}\n;(PureComponent.prototype as any).isPureReactComponent = true\n"],
|
|
5
|
+
"mappings": ";AAOO,IAAM,YAAN,MAAgC;AAAA,EACrC,OAAO;AAAA,EAGP,OAAO;AAAA,EACP,OAAO;AAAA,EAEP;AAAA,EACA,QAAW,CAAC;AAAA,EACZ;AAAA,EACA,OAA4B,CAAC;AAAA;AAAA,EAG7B,SAAc;AAAA,EACd,iBAAsF;AAAA,EACtF,eAAmD;AAAA,EAEnD,YAAY,OAAU,SAAe;AACnC,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,SAAS,SAAiC,UAA6B;AACrE,QAAI,CAAC,KAAK,gBAAgB;AACxB,UAAI,MAAuC;AACzC,cAAM,IAAI,MAAM,0CAA0C;AAAA,MAC5D;AACA,YAAM,IAAI,MAAM;AAAA,IAClB;AACA,SAAK,eAAe,SAAS,QAAQ;AAAA,EACvC;AAAA,EAEA,YAAY,UAA6B;AACvC,QAAI,CAAC,KAAK,aAAc;AACxB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AAAA,EAEA,SAAoB;AAClB,QAAI,MAAuC;AACzC,YAAM,IAAI,MAAM,6CAA6C;AAAA,IAC/D;AACA,UAAM,IAAI,MAAM;AAAA,EAClB;AAQF;AACE,UAAU,UAAkB,mBAAmB,CAAC;AAE3C,IAAM,gBAAN,cAA4C,UAAgB;AAAC;AAClE,cAAc,UAAkB,uBAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/react/context.js
CHANGED
|
@@ -9,7 +9,10 @@ function createContext(defaultValue) {
|
|
|
9
9
|
_currentValue: defaultValue
|
|
10
10
|
};
|
|
11
11
|
const Provider = function Provider2(_props) {
|
|
12
|
-
|
|
12
|
+
if (true) {
|
|
13
|
+
throw new Error("Provider components are handled by the renderer.");
|
|
14
|
+
}
|
|
15
|
+
throw new Error();
|
|
13
16
|
};
|
|
14
17
|
Provider.$$typeof = REACT_PROVIDER_TYPE;
|
|
15
18
|
Provider._context = context;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react/context.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReactElement, ReactNode } from '../core'\nimport { useContext } from './hooks'\n\nexport const REACT_CONTEXT_TYPE = Symbol.for('react.context')\nexport const REACT_PROVIDER_TYPE = Symbol.for('react.provider')\nexport const REACT_CONSUMER_TYPE = Symbol.for('react.consumer')\n\nexport interface Context<T> {\n $$typeof: typeof REACT_CONTEXT_TYPE\n _currentValue: T\n Provider: ProviderExoticComponent<{ value: T; children?: ReactNode }>\n Consumer: ConsumerExoticComponent<T>\n displayName?: string\n}\n\nexport interface ProviderExoticComponent<P> {\n $$typeof: typeof REACT_PROVIDER_TYPE\n _context: Context<any>\n (props: P): ReactElement\n}\n\nexport interface ConsumerExoticComponent<T> {\n $$typeof: typeof REACT_CONSUMER_TYPE\n _context: Context<T>\n (props: { children: (value: T) => ReactNode }): ReactElement\n}\n\nexport function createContext<T>(defaultValue: T): Context<T> {\n const context: Context<T> = {\n $$typeof: REACT_CONTEXT_TYPE,\n _currentValue: defaultValue,\n } as Context<T>\n\n const Provider: any = function Provider(_props: any): any {\n throw new Error('Provider components are handled by the renderer.')\n }\n Provider.$$typeof = REACT_PROVIDER_TYPE\n Provider._context = context\n\n const Consumer: any = function Consumer(props: { children: (v: T) => any }): any {\n return props.children(useContext(context))\n }\n Consumer.$$typeof = REACT_CONSUMER_TYPE\n Consumer._context = context\n\n context.Provider = Provider\n context.Consumer = Consumer\n\n return context\n}\n"],
|
|
5
|
-
"mappings": ";AACA,SAAS,kBAAkB;AAEpB,IAAM,qBAAqB,uBAAO,IAAI,eAAe;AACrD,IAAM,sBAAsB,uBAAO,IAAI,gBAAgB;AACvD,IAAM,sBAAsB,uBAAO,IAAI,gBAAgB;AAsBvD,SAAS,cAAiB,cAA6B;AAC5D,QAAM,UAAsB;AAAA,IAC1B,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAEA,QAAM,WAAgB,SAASA,UAAS,QAAkB;AACxD,
|
|
4
|
+
"sourcesContent": ["import type { ReactElement, ReactNode } from '../core'\nimport { useContext } from './hooks'\n\nexport const REACT_CONTEXT_TYPE = Symbol.for('react.context')\nexport const REACT_PROVIDER_TYPE = Symbol.for('react.provider')\nexport const REACT_CONSUMER_TYPE = Symbol.for('react.consumer')\n\nexport interface Context<T> {\n $$typeof: typeof REACT_CONTEXT_TYPE\n _currentValue: T\n Provider: ProviderExoticComponent<{ value: T; children?: ReactNode }>\n Consumer: ConsumerExoticComponent<T>\n displayName?: string\n}\n\nexport interface ProviderExoticComponent<P> {\n $$typeof: typeof REACT_PROVIDER_TYPE\n _context: Context<any>\n (props: P): ReactElement\n}\n\nexport interface ConsumerExoticComponent<T> {\n $$typeof: typeof REACT_CONSUMER_TYPE\n _context: Context<T>\n (props: { children: (value: T) => ReactNode }): ReactElement\n}\n\nexport function createContext<T>(defaultValue: T): Context<T> {\n const context: Context<T> = {\n $$typeof: REACT_CONTEXT_TYPE,\n _currentValue: defaultValue,\n } as Context<T>\n\n const Provider: any = function Provider(_props: any): any {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('Provider components are handled by the renderer.')\n }\n throw new Error()\n }\n Provider.$$typeof = REACT_PROVIDER_TYPE\n Provider._context = context\n\n const Consumer: any = function Consumer(props: { children: (v: T) => any }): any {\n return props.children(useContext(context))\n }\n Consumer.$$typeof = REACT_CONSUMER_TYPE\n Consumer._context = context\n\n context.Provider = Provider\n context.Consumer = Consumer\n\n return context\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,kBAAkB;AAEpB,IAAM,qBAAqB,uBAAO,IAAI,eAAe;AACrD,IAAM,sBAAsB,uBAAO,IAAI,gBAAgB;AACvD,IAAM,sBAAsB,uBAAO,IAAI,gBAAgB;AAsBvD,SAAS,cAAiB,cAA6B;AAC5D,QAAM,UAAsB;AAAA,IAC1B,UAAU;AAAA,IACV,eAAe;AAAA,EACjB;AAEA,QAAM,WAAgB,SAASA,UAAS,QAAkB;AACxD,QAAI,MAAuC;AACzC,YAAM,IAAI,MAAM,kDAAkD;AAAA,IACpE;AACA,UAAM,IAAI,MAAM;AAAA,EAClB;AACA,WAAS,WAAW;AACpB,WAAS,WAAW;AAEpB,QAAM,WAAgB,SAASC,UAAS,OAAyC;AAC/E,WAAO,MAAM,SAAS,WAAW,OAAO,CAAC;AAAA,EAC3C;AACA,WAAS,WAAW;AACpB,WAAS,WAAW;AAEpB,UAAQ,WAAW;AACnB,UAAQ,WAAW;AAEnB,SAAO;AACT;",
|
|
6
6
|
"names": ["Provider", "Consumer"]
|
|
7
7
|
}
|
package/dist/react/index.js
CHANGED
|
@@ -82,7 +82,7 @@ import { Children as Children2 } from "./children";
|
|
|
82
82
|
var cache = (fn) => fn;
|
|
83
83
|
var act = async (fn) => {
|
|
84
84
|
const r = fn();
|
|
85
|
-
if (r && typeof r.then
|
|
85
|
+
if (r && typeof r.then == "function") await r;
|
|
86
86
|
};
|
|
87
87
|
function taintUniqueValue(_msg, _lifetime, _value) {
|
|
88
88
|
}
|
package/dist/react/index.js.map
CHANGED
|
@@ -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 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
|
|
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,
|
|
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;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OAAa;AAChD,IAAM,MAAM,OAAO,OAAkB;AAC1C,QAAM,IAAI,GAAG;AACb,MAAI,KAAK,OAAO,EAAE,QAAQ,WAAY,OAAM;AAC9C;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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Fiber,
|
|
1
|
+
import type { Fiber, Hook } from '../core';
|
|
2
2
|
export interface Dispatcher {
|
|
3
3
|
useState<S>(initial: S | (() => S)): [S, (s: S | ((p: S) => S)) => void];
|
|
4
4
|
useReducer<S, A>(reducer: (s: S, a: A) => S, initial: S | any, init?: (a: any) => S): [S, (a: A) => void];
|
|
@@ -21,12 +21,9 @@ export interface Dispatcher {
|
|
|
21
21
|
}
|
|
22
22
|
interface SharedInternals {
|
|
23
23
|
H: Dispatcher | null;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
currentRoot: FiberRoot | null;
|
|
28
|
-
currentHook: Hook | null;
|
|
29
|
-
hookIndex: number;
|
|
24
|
+
F: Fiber | null;
|
|
25
|
+
K: Hook | null;
|
|
26
|
+
I: number;
|
|
30
27
|
}
|
|
31
28
|
export declare const ReactSharedInternals: SharedInternals;
|
|
32
29
|
export declare function getDispatcher(): Dispatcher;
|
|
@@ -3,12 +3,9 @@ var KEY = /* @__PURE__ */ Symbol.for("@tanstack/redact.ReactSharedInternals");
|
|
|
3
3
|
var g = globalThis;
|
|
4
4
|
var ReactSharedInternals = g[KEY] ?? (g[KEY] = {
|
|
5
5
|
H: null,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
currentRoot: null,
|
|
10
|
-
currentHook: null,
|
|
11
|
-
hookIndex: 0
|
|
6
|
+
F: null,
|
|
7
|
+
K: null,
|
|
8
|
+
I: 0
|
|
12
9
|
});
|
|
13
10
|
function getDispatcher() {
|
|
14
11
|
const d = ReactSharedInternals.H;
|
|
@@ -18,7 +15,7 @@ function getDispatcher() {
|
|
|
18
15
|
'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
16
|
);
|
|
20
17
|
}
|
|
21
|
-
throw new Error(
|
|
18
|
+
throw new Error();
|
|
22
19
|
}
|
|
23
20
|
return d;
|
|
24
21
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react/shared-internals.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Fiber,
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import type { Fiber, 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 F: Fiber | null\n K: Hook | null\n I: 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 F: null,\n K: null,\n I: 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()\n }\n return d\n}\n"],
|
|
5
|
+
"mappings": ";AA8CA,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,GAAG;AACL;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;AAAA,EAClB;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/server/stream.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export interface StreamOptions {
|
|
|
19
19
|
export interface ReadableStreamResult extends ReadableStream<Uint8Array> {
|
|
20
20
|
allReady: Promise<void>;
|
|
21
21
|
}
|
|
22
|
+
export interface PipeableWritable {
|
|
23
|
+
write(chunk: string): unknown;
|
|
24
|
+
end(): unknown;
|
|
25
|
+
}
|
|
22
26
|
export interface OrchestratorState {
|
|
23
27
|
nextId: number;
|
|
24
28
|
pending: Set<Promise<void>>;
|
|
@@ -29,7 +33,7 @@ type Emit = (chunk: string) => void;
|
|
|
29
33
|
export declare function streamHtml(children: ReactNode, emit: Emit, options: StreamOptions, state: OrchestratorState): Promise<void>;
|
|
30
34
|
export declare function renderToReadableStream(children: ReactNode, options?: StreamOptions): Promise<ReadableStreamResult>;
|
|
31
35
|
export interface PipeableHandle {
|
|
32
|
-
pipe<T extends
|
|
36
|
+
pipe<T extends PipeableWritable>(dest: T): T;
|
|
33
37
|
abort(reason?: unknown): void;
|
|
34
38
|
}
|
|
35
39
|
export interface PipeableOptions extends StreamOptions {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/server/stream.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReactNode } from '../core'\nimport {\n beginSSR,\n endSSR,\n installSSRDispatcher,\n uninstallSSRDispatcher,\n applyContextSnapshot,\n} from './dispatcher'\nimport { walk, type SuspendedBoundary } from './walk'\nimport { BOUNDARY_REVEAL_RUNTIME, revealScript } from './bootstrap-script'\nimport { escapeScript } from './escape'\n\nexport interface StreamOptions {\n identifierPrefix?: string\n nonce?: string\n bootstrapScriptContent?: string | ReadonlyArray<string>\n bootstrapScripts?: ReadonlyArray<string | { src: string; async?: boolean; nonce?: string }>\n bootstrapModules?: ReadonlyArray<string | { src: string; nonce?: string }>\n onError?: (error: unknown) => string | void\n signal?: AbortSignal\n progressiveChunkSize?: number\n}\n\nexport interface ReadableStreamResult extends ReadableStream<Uint8Array> {\n allReady: Promise<void>\n}\n\nexport interface OrchestratorState {\n nextId: number\n pending: Set<Promise<void>>\n closed: boolean\n errored: unknown | null\n}\n\ntype Emit = (chunk: string) => void\n\nexport async function streamHtml(\n children: ReactNode,\n emit: Emit,\n options: StreamOptions,\n state: OrchestratorState,\n): Promise<void> {\n installSSRDispatcher()\n beginSSR(options.identifierPrefix)\n const nonce = options.nonce\n\n try {\n const boundaries: SuspendedBoundary[] = []\n\n // Buffer shell + bootstrap into a string[] and flush as a single emit.\n // Per-emit overhead in renderToReadableStream is TextEncoder.encode +\n // controller.enqueue \u2014 each walkHost normally fires 3+ emits (opening\n // tag, per-attribute, closing bracket), which for a ~30-component tree\n // is ~100 stream-controller round-trips. Batching collapses those into\n // one encode and one enqueue per shell \u2014 measured ~2-4% of total SSR\n // time on CPU profiles.\n const shellChunks: string[] = []\n const bufferedEmit: Emit = (chunk) => {\n shellChunks.push(chunk)\n }\n\n // 1. Render the shell. A root-level `use(promise)` has no Suspense\n // boundary to capture it, but App Router SSR commonly suspends at this\n // level while resolving the RSC stream. Wait and retry without leaking\n // partial shell chunks or boundary ids from the aborted attempt.\n let shellRendered = false\n let rootRetries = 0\n while (!shellRendered) {\n const chunkCount = shellChunks.length\n const boundaryCount = boundaries.length\n const nextId = state.nextId\n try {\n walk(children, {\n emit: bufferedEmit,\n onSuspend: (b) => boundaries.push(b),\n nextBoundaryId: () => state.nextId++,\n })\n shellRendered = true\n } catch (err) {\n shellChunks.length = chunkCount\n boundaries.length = boundaryCount\n state.nextId = nextId\n if (!isThenable(err)) throw err\n if (++rootRetries > 50) {\n throw new Error('renderToReadableStream exceeded 50 root suspension retries.')\n }\n await err\n }\n }\n\n // 2. Inject runtime + bootstrap scripts (once, after shell). Skip the\n // reveal/event-replay runtime when nothing needs it \u2014 no suspensions to\n // reveal and no bootstrap scripts to guard against early user input. That\n // keeps fully-static SSR responses byte-equivalent to a plain walk and\n // matches React's behavior where `renderToReadableStream` of a static\n // tree emits only the markup.\n const hasBootstrap =\n bootstrapScriptContentToArray(options.bootstrapScriptContent).length > 0 ||\n (options.bootstrapScripts?.length ?? 0) > 0 ||\n (options.bootstrapModules?.length ?? 0) > 0\n if (boundaries.length > 0 || hasBootstrap) {\n shellChunks.push(`<script${nonce ? ` nonce=\"${nonce}\"` : ''}>${BOUNDARY_REVEAL_RUNTIME}</script>`)\n for (const content of bootstrapScriptContentToArray(options.bootstrapScriptContent)) {\n shellChunks.push(inlineBootstrapTag(content, nonce))\n }\n for (const s of options.bootstrapScripts ?? []) {\n shellChunks.push(bootstrapTag(s, 'script', nonce))\n }\n for (const m of options.bootstrapModules ?? []) {\n shellChunks.push(bootstrapTag(m, 'module', nonce))\n }\n }\n\n if (shellChunks.length) emit(normalizeDocumentShell(shellChunks.join('')))\n\n // 3. Stream suspended boundaries as they resolve\n for (const b of boundaries) streamBoundary(b, emit, options, state)\n await drain(state)\n } catch (err) {\n state.errored = err\n if (options.onError) options.onError(err)\n throw err\n } finally {\n endSSR()\n uninstallSSRDispatcher()\n state.closed = true\n }\n}\n\nfunction streamBoundary(\n b: SuspendedBoundary,\n emit: Emit,\n options: StreamOptions,\n state: OrchestratorState,\n): void {\n const task = (async () => {\n try {\n await b.thenable\n } catch (err) {\n if (options.onError) options.onError(err)\n }\n if (state.closed) return\n\n // Re-render the boundary's children into a string, restoring the\n // provider stack from when the boundary first suspended.\n const parts: string[] = []\n const sub: SuspendedBoundary[] = []\n const restore = applyContextSnapshot(b.contextSnapshot)\n try {\n walk(b.children, {\n emit: (s) => parts.push(s),\n onSuspend: (n) => sub.push(n),\n nextBoundaryId: () => state.nextId++,\n })\n } catch (err) {\n if (options.onError) options.onError(err)\n restore()\n return\n }\n restore()\n\n emit(`<div hidden id=\"S:${b.id}\">${parts.join('')}</div>${revealScript(b.id, options.nonce)}`)\n\n // Recurse: any nested suspensions inside the now-revealed content\n for (const s of sub) streamBoundary(s, emit, options, state)\n })()\n state.pending.add(task)\n task.finally(() => state.pending.delete(task))\n}\n\nasync function drain(state: OrchestratorState): Promise<void> {\n while (state.pending.size > 0) {\n await Promise.race(state.pending)\n }\n}\n\nfunction isThenable(value: unknown): value is Promise<unknown> {\n return !!value && typeof (value as { then?: unknown }).then === 'function'\n}\n\nfunction bootstrapScriptContentToArray(\n content: StreamOptions['bootstrapScriptContent'],\n): string[] {\n if (content === undefined) return []\n return typeof content === 'string' ? [content] : [...content]\n}\n\nfunction inlineBootstrapTag(content: string, defaultNonce: string | undefined): string {\n const nAttr = defaultNonce ? ` nonce=\"${defaultNonce}\"` : ''\n return `<script${nAttr}>${escapeScript(content)}</script>`\n}\n\nfunction normalizeDocumentShell(html: string): string {\n const doctypeIndex = html.indexOf('<!DOCTYPE html><html')\n if (doctypeIndex <= 0) return html\n\n const headPrefix = html.slice(0, doctypeIndex)\n if (!isHeadPrefix(headPrefix)) return html\n\n const documentHtml = html.slice(doctypeIndex)\n const headOpen = documentHtml.match(/<head(?:\\s[^>]*)?>/)\n if (!headOpen || headOpen.index === undefined) return html\n\n const insertAt = headOpen.index + headOpen[0].length\n return documentHtml.slice(0, insertAt) + headPrefix + documentHtml.slice(insertAt)\n}\n\nfunction isHeadPrefix(value: string): boolean {\n if (!value) return false\n return stripLeadingHeadTags(value).trim() === ''\n}\n\nfunction stripLeadingHeadTags(value: string): string {\n let rest = value\n let changed = true\n while (changed) {\n changed = false\n const next = rest.replace(\n /^\\s*(?:<meta\\b[^>]*>|<link\\b[^>]*>|<base\\b[^>]*>|<title\\b[^>]*>[\\s\\S]*?<\\/title>|<style\\b[^>]*>[\\s\\S]*?<\\/style>|<script\\b[^>]*>[\\s\\S]*?<\\/script>)/i,\n '',\n )\n if (next !== rest) {\n rest = next\n changed = true\n }\n }\n return rest\n}\n\nfunction bootstrapTag(\n entry: string | { src: string; async?: boolean; nonce?: string },\n kind: 'script' | 'module',\n defaultNonce: string | undefined,\n): string {\n const src = typeof entry === 'string' ? entry : entry.src\n const nonce = typeof entry === 'string' ? defaultNonce : entry.nonce ?? defaultNonce\n const nAttr = nonce ? ` nonce=\"${nonce}\"` : ''\n if (kind === 'module') return `<script type=\"module\"${nAttr} src=\"${src}\"></script>`\n return `<script async${nAttr} src=\"${src}\"></script>`\n}\n\n// ---------------------------------------------------------------------------\n// Web Streams: renderToReadableStream\n// ---------------------------------------------------------------------------\n\nexport function renderToReadableStream(\n children: ReactNode,\n options: StreamOptions = {},\n): Promise<ReadableStreamResult> {\n const state: OrchestratorState = {\n nextId: 0,\n pending: new Set(),\n closed: false,\n errored: null,\n }\n const encoder = new TextEncoder()\n\n let allReadyResolve!: () => void\n let allReadyReject!: (e: unknown) => void\n const allReady = new Promise<void>((r, rej) => {\n allReadyResolve = r\n allReadyReject = rej\n })\n\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n const emit = (chunk: string) => {\n try {\n controller.enqueue(encoder.encode(chunk))\n } catch {}\n }\n\n streamHtml(children, emit, options, state).then(\n () => {\n try {\n controller.close()\n } catch {}\n allReadyResolve()\n },\n (err) => {\n try {\n controller.error(err)\n } catch {}\n allReadyReject(err)\n },\n )\n\n options.signal?.addEventListener('abort', () => {\n state.closed = true\n try {\n controller.close()\n } catch {}\n })\n },\n })\n\n return Promise.resolve(Object.assign(stream, { allReady }))\n}\n\n// ---------------------------------------------------------------------------\n// Node Streams: renderToPipeableStream\n// ---------------------------------------------------------------------------\n\nexport interface PipeableHandle {\n pipe<T extends NodeJS.WritableStream>(dest: T): T\n abort(reason?: unknown): void\n}\n\nexport interface PipeableOptions extends StreamOptions {\n onShellReady?: () => void\n onShellError?: (err: unknown) => void\n onAllReady?: () => void\n}\n\nexport function renderToPipeableStream(\n children: ReactNode,\n options: PipeableOptions = {},\n): PipeableHandle {\n const state: OrchestratorState = {\n nextId: 0,\n pending: new Set(),\n closed: false,\n errored: null,\n }\n\n const buffers: string[] = []\n let dest: NodeJS.WritableStream | null = null\n let shellReady = false\n let finished = false\n let aborted = false\n\n const flushTo = (w: NodeJS.WritableStream) => {\n if (!buffers.length) return\n for (const b of buffers) w.write(b)\n buffers.length = 0\n }\n\n const emit: Emit = (chunk) => {\n if (aborted || finished) return\n if (dest) dest.write(chunk)\n else buffers.push(chunk)\n }\n\n // Kick off rendering\n streamHtml(children, emit, options, state).then(\n () => {\n finished = true\n if (dest) dest.end()\n options.onAllReady?.()\n },\n (err) => {\n if (!shellReady) {\n options.onShellError?.(err)\n } else {\n options.onError?.(err)\n if (dest) dest.end()\n }\n },\n )\n\n // We call onShellReady once the first synchronous emit has landed.\n // streamHtml above runs the shell synchronously before the first await in drain(),\n // so we can schedule onShellReady right after the first microtask.\n queueMicrotask(() => {\n if (aborted || finished) return\n shellReady = true\n options.onShellReady?.()\n })\n\n return {\n pipe<T extends NodeJS.WritableStream>(target: T): T {\n dest = target\n flushTo(target)\n if (finished) target.end()\n return target\n },\n abort(_reason?: unknown) {\n aborted = true\n state.closed = true\n if (dest) dest.end()\n },\n }\n}\n"],
|
|
5
|
-
"mappings": ";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,YAAoC;AAC7C,SAAS,yBAAyB,oBAAoB;AACtD,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import type { ReactNode } from '../core'\nimport {\n beginSSR,\n endSSR,\n installSSRDispatcher,\n uninstallSSRDispatcher,\n applyContextSnapshot,\n} from './dispatcher'\nimport { walk, type SuspendedBoundary } from './walk'\nimport { BOUNDARY_REVEAL_RUNTIME, revealScript } from './bootstrap-script'\nimport { escapeScript } from './escape'\n\nexport interface StreamOptions {\n identifierPrefix?: string\n nonce?: string\n bootstrapScriptContent?: string | ReadonlyArray<string>\n bootstrapScripts?: ReadonlyArray<string | { src: string; async?: boolean; nonce?: string }>\n bootstrapModules?: ReadonlyArray<string | { src: string; nonce?: string }>\n onError?: (error: unknown) => string | void\n signal?: AbortSignal\n progressiveChunkSize?: number\n}\n\nexport interface ReadableStreamResult extends ReadableStream<Uint8Array> {\n allReady: Promise<void>\n}\n\nexport interface PipeableWritable {\n write(chunk: string): unknown\n end(): unknown\n}\n\nexport interface OrchestratorState {\n nextId: number\n pending: Set<Promise<void>>\n closed: boolean\n errored: unknown | null\n}\n\ntype Emit = (chunk: string) => void\n\nexport async function streamHtml(\n children: ReactNode,\n emit: Emit,\n options: StreamOptions,\n state: OrchestratorState,\n): Promise<void> {\n installSSRDispatcher()\n beginSSR(options.identifierPrefix)\n const nonce = options.nonce\n\n try {\n const boundaries: SuspendedBoundary[] = []\n\n // Buffer shell + bootstrap into a string[] and flush as a single emit.\n // Per-emit overhead in renderToReadableStream is TextEncoder.encode +\n // controller.enqueue \u2014 each walkHost normally fires 3+ emits (opening\n // tag, per-attribute, closing bracket), which for a ~30-component tree\n // is ~100 stream-controller round-trips. Batching collapses those into\n // one encode and one enqueue per shell \u2014 measured ~2-4% of total SSR\n // time on CPU profiles.\n const shellChunks: string[] = []\n const bufferedEmit: Emit = (chunk) => {\n shellChunks.push(chunk)\n }\n\n // 1. Render the shell. A root-level `use(promise)` has no Suspense\n // boundary to capture it, but App Router SSR commonly suspends at this\n // level while resolving the RSC stream. Wait and retry without leaking\n // partial shell chunks or boundary ids from the aborted attempt.\n let shellRendered = false\n let rootRetries = 0\n while (!shellRendered) {\n const chunkCount = shellChunks.length\n const boundaryCount = boundaries.length\n const nextId = state.nextId\n try {\n walk(children, {\n emit: bufferedEmit,\n onSuspend: (b) => boundaries.push(b),\n nextBoundaryId: () => state.nextId++,\n })\n shellRendered = true\n } catch (err) {\n shellChunks.length = chunkCount\n boundaries.length = boundaryCount\n state.nextId = nextId\n if (!isThenable(err)) throw err\n if (++rootRetries > 50) {\n throw new Error('renderToReadableStream exceeded 50 root suspension retries.')\n }\n await err\n }\n }\n\n // 2. Inject runtime + bootstrap scripts (once, after shell). Skip the\n // reveal/event-replay runtime when nothing needs it \u2014 no suspensions to\n // reveal and no bootstrap scripts to guard against early user input. That\n // keeps fully-static SSR responses byte-equivalent to a plain walk and\n // matches React's behavior where `renderToReadableStream` of a static\n // tree emits only the markup.\n const hasBootstrap =\n bootstrapScriptContentToArray(options.bootstrapScriptContent).length > 0 ||\n (options.bootstrapScripts?.length ?? 0) > 0 ||\n (options.bootstrapModules?.length ?? 0) > 0\n if (boundaries.length > 0 || hasBootstrap) {\n shellChunks.push(`<script${nonce ? ` nonce=\"${nonce}\"` : ''}>${BOUNDARY_REVEAL_RUNTIME}</script>`)\n for (const content of bootstrapScriptContentToArray(options.bootstrapScriptContent)) {\n shellChunks.push(inlineBootstrapTag(content, nonce))\n }\n for (const s of options.bootstrapScripts ?? []) {\n shellChunks.push(bootstrapTag(s, 'script', nonce))\n }\n for (const m of options.bootstrapModules ?? []) {\n shellChunks.push(bootstrapTag(m, 'module', nonce))\n }\n }\n\n if (shellChunks.length) emit(normalizeDocumentShell(shellChunks.join('')))\n\n // 3. Stream suspended boundaries as they resolve\n for (const b of boundaries) streamBoundary(b, emit, options, state)\n await drain(state)\n } catch (err) {\n state.errored = err\n if (options.onError) options.onError(err)\n throw err\n } finally {\n endSSR()\n uninstallSSRDispatcher()\n state.closed = true\n }\n}\n\nfunction streamBoundary(\n b: SuspendedBoundary,\n emit: Emit,\n options: StreamOptions,\n state: OrchestratorState,\n): void {\n const task = (async () => {\n try {\n await b.thenable\n } catch (err) {\n if (options.onError) options.onError(err)\n }\n if (state.closed) return\n\n // Re-render the boundary's children into a string, restoring the\n // provider stack from when the boundary first suspended.\n const parts: string[] = []\n const sub: SuspendedBoundary[] = []\n const restore = applyContextSnapshot(b.contextSnapshot)\n try {\n walk(b.children, {\n emit: (s) => parts.push(s),\n onSuspend: (n) => sub.push(n),\n nextBoundaryId: () => state.nextId++,\n })\n } catch (err) {\n if (options.onError) options.onError(err)\n restore()\n return\n }\n restore()\n\n emit(`<div hidden id=\"S:${b.id}\">${parts.join('')}</div>${revealScript(b.id, options.nonce)}`)\n\n // Recurse: any nested suspensions inside the now-revealed content\n for (const s of sub) streamBoundary(s, emit, options, state)\n })()\n state.pending.add(task)\n task.finally(() => state.pending.delete(task))\n}\n\nasync function drain(state: OrchestratorState): Promise<void> {\n while (state.pending.size > 0) {\n await Promise.race(state.pending)\n }\n}\n\nfunction isThenable(value: unknown): value is Promise<unknown> {\n return !!value && typeof (value as { then?: unknown }).then === 'function'\n}\n\nfunction bootstrapScriptContentToArray(\n content: StreamOptions['bootstrapScriptContent'],\n): string[] {\n if (content === undefined) return []\n return typeof content === 'string' ? [content] : [...content]\n}\n\nfunction inlineBootstrapTag(content: string, defaultNonce: string | undefined): string {\n const nAttr = defaultNonce ? ` nonce=\"${defaultNonce}\"` : ''\n return `<script${nAttr}>${escapeScript(content)}</script>`\n}\n\nfunction normalizeDocumentShell(html: string): string {\n const doctypeIndex = html.indexOf('<!DOCTYPE html><html')\n if (doctypeIndex <= 0) return html\n\n const headPrefix = html.slice(0, doctypeIndex)\n if (!isHeadPrefix(headPrefix)) return html\n\n const documentHtml = html.slice(doctypeIndex)\n const headOpen = documentHtml.match(/<head(?:\\s[^>]*)?>/)\n if (!headOpen || headOpen.index === undefined) return html\n\n const insertAt = headOpen.index + headOpen[0].length\n return documentHtml.slice(0, insertAt) + headPrefix + documentHtml.slice(insertAt)\n}\n\nfunction isHeadPrefix(value: string): boolean {\n if (!value) return false\n return stripLeadingHeadTags(value).trim() === ''\n}\n\nfunction stripLeadingHeadTags(value: string): string {\n let rest = value\n let changed = true\n while (changed) {\n changed = false\n const next = rest.replace(\n /^\\s*(?:<meta\\b[^>]*>|<link\\b[^>]*>|<base\\b[^>]*>|<title\\b[^>]*>[\\s\\S]*?<\\/title>|<style\\b[^>]*>[\\s\\S]*?<\\/style>|<script\\b[^>]*>[\\s\\S]*?<\\/script>)/i,\n '',\n )\n if (next !== rest) {\n rest = next\n changed = true\n }\n }\n return rest\n}\n\nfunction bootstrapTag(\n entry: string | { src: string; async?: boolean; nonce?: string },\n kind: 'script' | 'module',\n defaultNonce: string | undefined,\n): string {\n const src = typeof entry === 'string' ? entry : entry.src\n const nonce = typeof entry === 'string' ? defaultNonce : entry.nonce ?? defaultNonce\n const nAttr = nonce ? ` nonce=\"${nonce}\"` : ''\n if (kind === 'module') return `<script type=\"module\"${nAttr} src=\"${src}\"></script>`\n return `<script async${nAttr} src=\"${src}\"></script>`\n}\n\n// ---------------------------------------------------------------------------\n// Web Streams: renderToReadableStream\n// ---------------------------------------------------------------------------\n\nexport function renderToReadableStream(\n children: ReactNode,\n options: StreamOptions = {},\n): Promise<ReadableStreamResult> {\n const state: OrchestratorState = {\n nextId: 0,\n pending: new Set(),\n closed: false,\n errored: null,\n }\n const encoder = new TextEncoder()\n\n let allReadyResolve!: () => void\n let allReadyReject!: (e: unknown) => void\n const allReady = new Promise<void>((r, rej) => {\n allReadyResolve = r\n allReadyReject = rej\n })\n\n const stream = new ReadableStream<Uint8Array>({\n start(controller) {\n const emit = (chunk: string) => {\n try {\n controller.enqueue(encoder.encode(chunk))\n } catch {}\n }\n\n streamHtml(children, emit, options, state).then(\n () => {\n try {\n controller.close()\n } catch {}\n allReadyResolve()\n },\n (err) => {\n try {\n controller.error(err)\n } catch {}\n allReadyReject(err)\n },\n )\n\n options.signal?.addEventListener('abort', () => {\n state.closed = true\n try {\n controller.close()\n } catch {}\n })\n },\n })\n\n return Promise.resolve(Object.assign(stream, { allReady }))\n}\n\n// ---------------------------------------------------------------------------\n// Node Streams: renderToPipeableStream\n// ---------------------------------------------------------------------------\n\nexport interface PipeableHandle {\n pipe<T extends PipeableWritable>(dest: T): T\n abort(reason?: unknown): void\n}\n\nexport interface PipeableOptions extends StreamOptions {\n onShellReady?: () => void\n onShellError?: (err: unknown) => void\n onAllReady?: () => void\n}\n\nexport function renderToPipeableStream(\n children: ReactNode,\n options: PipeableOptions = {},\n): PipeableHandle {\n const state: OrchestratorState = {\n nextId: 0,\n pending: new Set(),\n closed: false,\n errored: null,\n }\n\n const buffers: string[] = []\n let dest: PipeableWritable | null = null\n let shellReady = false\n let finished = false\n let aborted = false\n\n const flushTo = (w: PipeableWritable) => {\n if (!buffers.length) return\n for (const b of buffers) w.write(b)\n buffers.length = 0\n }\n\n const emit: Emit = (chunk) => {\n if (aborted || finished) return\n if (dest) dest.write(chunk)\n else buffers.push(chunk)\n }\n\n // Kick off rendering\n streamHtml(children, emit, options, state).then(\n () => {\n finished = true\n if (dest) dest.end()\n options.onAllReady?.()\n },\n (err) => {\n if (!shellReady) {\n options.onShellError?.(err)\n } else {\n options.onError?.(err)\n if (dest) dest.end()\n }\n },\n )\n\n // We call onShellReady once the first synchronous emit has landed.\n // streamHtml above runs the shell synchronously before the first await in drain(),\n // so we can schedule onShellReady right after the first microtask.\n queueMicrotask(() => {\n if (aborted || finished) return\n shellReady = true\n options.onShellReady?.()\n })\n\n return {\n pipe<T extends PipeableWritable>(target: T): T {\n dest = target\n flushTo(target)\n if (finished) target.end()\n return target\n },\n abort(_reason?: unknown) {\n aborted = true\n state.closed = true\n if (dest) dest.end()\n },\n }\n}\n"],
|
|
5
|
+
"mappings": ";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,YAAoC;AAC7C,SAAS,yBAAyB,oBAAoB;AACtD,SAAS,oBAAoB;AA+B7B,eAAsB,WACpB,UACA,MACA,SACA,OACe;AACf,uBAAqB;AACrB,WAAS,QAAQ,gBAAgB;AACjC,QAAM,QAAQ,QAAQ;AAEtB,MAAI;AACF,UAAM,aAAkC,CAAC;AASzC,UAAM,cAAwB,CAAC;AAC/B,UAAM,eAAqB,CAAC,UAAU;AACpC,kBAAY,KAAK,KAAK;AAAA,IACxB;AAMA,QAAI,gBAAgB;AACpB,QAAI,cAAc;AAClB,WAAO,CAAC,eAAe;AACrB,YAAM,aAAa,YAAY;AAC/B,YAAM,gBAAgB,WAAW;AACjC,YAAM,SAAS,MAAM;AACrB,UAAI;AACF,aAAK,UAAU;AAAA,UACb,MAAM;AAAA,UACN,WAAW,CAAC,MAAM,WAAW,KAAK,CAAC;AAAA,UACnC,gBAAgB,MAAM,MAAM;AAAA,QAC9B,CAAC;AACD,wBAAgB;AAAA,MAClB,SAAS,KAAK;AACZ,oBAAY,SAAS;AACrB,mBAAW,SAAS;AACpB,cAAM,SAAS;AACf,YAAI,CAAC,WAAW,GAAG,EAAG,OAAM;AAC5B,YAAI,EAAE,cAAc,IAAI;AACtB,gBAAM,IAAI,MAAM,6DAA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IACzC,MAAM;AACJ,iBAAW;AACX,UAAI,KAAM,MAAK,IAAI;AACnB,cAAQ,aAAa;AAAA,IACvB;AAAA,IACA,CAAC,QAAQ;AACP,UAAI,CAAC,YAAY;AACf,gBAAQ,eAAe,GAAG;AAAA,MAC5B,OAAO;AACL,gBAAQ,UAAU,GAAG;AACrB,YAAI,KAAM,MAAK,IAAI;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAKA,iBAAe,MAAM;AACnB,QAAI,WAAW,SAAU;AACzB,iBAAa;AACb,YAAQ,eAAe;AAAA,EACzB,CAAC;AAED,SAAO;AAAA,IACL,KAAiC,QAAc;AAC7C,aAAO;AACP,cAAQ,MAAM;AACd,UAAI,SAAU,QAAO,IAAI;AACzB,aAAO;AAAA,IACT;AAAA,IACA,MAAM,SAAmB;AACvB,gBAAU;AACV,YAAM,SAAS;AACf,UAAI,KAAM,MAAK,IAAI;AAAA,IACrB;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/vite/index.js
CHANGED
|
@@ -135,9 +135,18 @@ function resolveSpecifier(specifier, fromDir, packageRoots) {
|
|
|
135
135
|
return target;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
+
function pruneOptimizeDepsInclude(optimizeDeps, blocked) {
|
|
139
|
+
if (!optimizeDeps?.include) return;
|
|
140
|
+
optimizeDeps.include = optimizeDeps.include.filter((id) => {
|
|
141
|
+
const tailSpecifier = id.split(">").pop()?.trim() ?? id;
|
|
142
|
+
return !blocked.has(id) && !blocked.has(tailSpecifier);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
138
145
|
function redact(options = {}) {
|
|
139
146
|
const skip = new Set(options.skip ?? []);
|
|
140
147
|
const entries = Object.entries(ALIASES).filter(([k]) => !skip.has(k));
|
|
148
|
+
const excludeList = entries.map(([k]) => k);
|
|
149
|
+
const optimizeDepsBlocked = new Set(excludeList);
|
|
141
150
|
const features = resolveFeatures(options.preset ?? "full", options.features ?? {});
|
|
142
151
|
const resolvedMap = {};
|
|
143
152
|
let done = false;
|
|
@@ -151,11 +160,10 @@ function redact(options = {}) {
|
|
|
151
160
|
}
|
|
152
161
|
done = true;
|
|
153
162
|
}
|
|
154
|
-
return {
|
|
163
|
+
return [{
|
|
155
164
|
name: "redact",
|
|
156
165
|
enforce: "pre",
|
|
157
166
|
config() {
|
|
158
|
-
const excludeList = entries.map(([k]) => k);
|
|
159
167
|
const noExt = ["@tanstack/redact"];
|
|
160
168
|
const aliasMap = Object.fromEntries(entries.filter(([from, to]) => from !== to));
|
|
161
169
|
const dedupe = noExt;
|
|
@@ -208,7 +216,15 @@ function redact(options = {}) {
|
|
|
208
216
|
}
|
|
209
217
|
return resolvedMap[id] ?? null;
|
|
210
218
|
}
|
|
211
|
-
}
|
|
219
|
+
}, {
|
|
220
|
+
name: "redact:optimize-deps-guard",
|
|
221
|
+
enforce: "post",
|
|
222
|
+
configResolved(config) {
|
|
223
|
+
pruneOptimizeDepsInclude(config.optimizeDeps, optimizeDepsBlocked);
|
|
224
|
+
pruneOptimizeDepsInclude(config.environments?.client?.optimizeDeps, optimizeDepsBlocked);
|
|
225
|
+
pruneOptimizeDepsInclude(config.environments?.ssr?.optimizeDeps, optimizeDepsBlocked);
|
|
226
|
+
}
|
|
227
|
+
}];
|
|
212
228
|
}
|
|
213
229
|
var vite_default = redact;
|
|
214
230
|
export {
|
package/dist/vite/index.js.map
CHANGED
|
@@ -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/compiler-runtime': '@tanstack/redact/compiler-runtime',\n 'react-dom/client': '@tanstack/redact/dom-client',\n 'react-dom/server.edge': '@tanstack/redact/server',\n 'react-dom/static.edge': '@tanstack/redact/server',\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,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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AAO,IAAI,UAAU,IAAI;AAC/B,QAAI,OAAO,SAAS,SAAU,QAAO,YAAY,YAAY,IAAI;AAAA,EACnE;AACA,SAAO;AACT;AASA,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAExD,SAAS,iBACP,WACA,SACA,cACe;AACf,QAAM,EAAE,KAAK,IAAI,IAAI,eAAe,SAAS;AAC7C,QAAM,aACJ,aAAa,GAAG,KAChB,eAAe,KAAK,SAAS,KAC7B,eAAe,KAAK,OAAO;AAC7B,MAAI,CAAC,WAAY,QAAO;AACxB,QAAM,SAAS,cAAc,YAAY,GAAG;AAC5C,MAAI,CAAC,OAAQ,QAAO;AAUpB,MAAI;AACF,WAAO,aAAa,MAAM;AAAA,EAC5B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,OAAO,UAAyB,CAAC,GAAQ;AACvD,QAAM,OAAO,IAAI,IAAI,QAAQ,QAAQ,CAAC,CAAC;AACvC,QAAM,UAAU,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;AACpE,QAAM,WAAW,gBAAgB,QAAQ,UAAU,QAAQ,QAAQ,YAAY,CAAC,CAAC;AAEjF,QAAM,cAAsC,CAAC;AAC7C,MAAI,OAAO;AAEX,WAAS,WAAW,MAAoB;AACtC,QAAI,KAAM;AACV,UAAM,UAAU,QAAQ,eAAe;AACvC,UAAM,eAAe,QAAQ,gBAAgB,CAAC;AAC9C,eAAW,CAAC,MAAM,EAAE,KAAK,SAAS;AAChC,YAAM,WAAW,iBAAiB,IAAI,SAAS,YAAY;AAC3D,UAAI,SAAU,aAAY,IAAI,IAAI;AAAA,IACpC;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,
|
|
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.edge': '@tanstack/redact/server',\n 'react-dom/static.edge': '@tanstack/redact/server',\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\ninterface OptimizeDepsWithInclude {\n include?: Array<string>\n}\n\nfunction pruneOptimizeDepsInclude(\n optimizeDeps: OptimizeDepsWithInclude | undefined,\n blocked: ReadonlySet<string>,\n): void {\n if (!optimizeDeps?.include) return\n\n optimizeDeps.include = optimizeDeps.include.filter((id) => {\n const tailSpecifier = id.split('>').pop()?.trim() ?? id\n return !blocked.has(id) && !blocked.has(tailSpecifier)\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 excludeList = entries.map(([k]) => k)\n const optimizeDepsBlocked = new Set(excludeList)\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 // 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 name: 'redact:optimize-deps-guard',\n enforce: 'post',\n\n configResolved(config: any) {\n // `optimizeDeps.exclude` loses when another plugin force-adds the same\n // ids to `include`. That lets Vite pre-bundle real React next to Redact,\n // producing duplicate dispatcher state. Prune after config settles so\n // Redact's client/SSR shims stay canonical.\n pruneOptimizeDepsInclude(config.optimizeDeps, optimizeDepsBlocked)\n pruneOptimizeDepsInclude(config.environments?.client?.optimizeDeps, optimizeDepsBlocked)\n pruneOptimizeDepsInclude(config.environments?.ssr?.optimizeDeps, optimizeDepsBlocked)\n // Leave `environments.rsc` untouched. RSC depends on real React internals.\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,UAAU,WAAW,EAAE;AAAA,IAChC,UAAU,UAAU,YAAY,EAAE;AAAA,IAClC,MAAM,UAAU,QAAQ,EAAE;AAAA,IAC1B,YAAY,UAAU,cAAc,EAAE;AAAA,IACtC,MAAM,UAAU,QAAQ,EAAE;AAAA,IAC1B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