@tanstack/redact 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/internal.d.ts +3 -3
- package/dist/core/internal.js.map +1 -1
- package/dist/dom/client.d.ts +6 -0
- package/dist/dom/client.js +6 -0
- package/dist/dom/client.js.map +3 -3
- package/dist/dom/reconcile.js +5 -13
- package/dist/dom/reconcile.js.map +2 -2
- package/dist/dom/root.js +8 -0
- package/dist/dom/root.js.map +2 -2
- package/dist/react/compiler-runtime.d.ts +1 -0
- package/dist/react/compiler-runtime.js +16 -0
- package/dist/react/compiler-runtime.js.map +7 -0
- package/dist/react/hooks.d.ts +6 -1
- package/dist/react/hooks.js.map +2 -2
- package/dist/react/index.d.ts +11 -7
- package/dist/react/index.js.map +2 -2
- package/dist/react/jsx-runtime.d.ts +13 -0
- package/dist/react/jsx-runtime.js.map +1 -1
- package/dist/react/memo.d.ts +12 -21
- package/dist/react/memo.js.map +2 -2
- package/dist/server/walk.d.ts +3 -3
- package/dist/server/walk.js.map +1 -1
- package/dist/vite/index.js +2 -0
- package/dist/vite/index.js.map +2 -2
- package/package.json +5 -1
- package/src/core/internal.ts +3 -3
- package/src/dom/client.ts +10 -0
- package/src/dom/reconcile.ts +12 -12
- package/src/dom/root.ts +10 -0
- package/src/react/compiler-runtime.ts +22 -0
- package/src/react/hooks.ts +1 -1
- package/src/react/index.ts +17 -0
- package/src/react/jsx-runtime.ts +20 -0
- package/src/react/memo.ts +22 -6
- package/src/server/walk.ts +3 -3
- package/src/vite/index.ts +2 -0
package/src/react/memo.ts
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode, Ref } from '../core'
|
|
2
|
+
|
|
1
3
|
export const REACT_MEMO_TYPE = Symbol.for('react.memo')
|
|
2
4
|
export const REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref')
|
|
3
5
|
export const REACT_LAZY_TYPE = Symbol.for('react.lazy')
|
|
4
6
|
|
|
7
|
+
// Component-shaped return type so JSX usage of memo/forwardRef/lazy results
|
|
8
|
+
// type-checks. The runtime value is a `$$typeof`-tagged record that the
|
|
9
|
+
// reconciler recognizes via type-matchers; the cast lets TypeScript treat
|
|
10
|
+
// it as a callable component at JSX sites without changing what the runtime
|
|
11
|
+
// actually does. `children` is included for the common
|
|
12
|
+
// `<Comp>...</Comp>` form even when the inner P doesn't list it.
|
|
13
|
+
export type ExoticComponent<P> = ((
|
|
14
|
+
props: P & { children?: ReactNode; ref?: any; key?: any },
|
|
15
|
+
) => ReactElement | null) & {
|
|
16
|
+
readonly $$typeof: symbol
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
export function memo<P>(
|
|
6
20
|
type: (props: P) => any,
|
|
7
21
|
areEqual?: (prev: Readonly<P>, next: Readonly<P>) => boolean,
|
|
8
|
-
) {
|
|
9
|
-
return { $$typeof: REACT_MEMO_TYPE, type, compare: areEqual ?? null }
|
|
22
|
+
): ExoticComponent<P> {
|
|
23
|
+
return { $$typeof: REACT_MEMO_TYPE, type, compare: areEqual ?? null } as unknown as ExoticComponent<P>
|
|
10
24
|
}
|
|
11
25
|
|
|
12
26
|
export function forwardRef<R, P = {}>(
|
|
13
27
|
render: (props: P, ref: { current: R | null } | ((r: R | null) => void) | null) => any,
|
|
14
|
-
) {
|
|
15
|
-
return { $$typeof: REACT_FORWARD_REF_TYPE, render }
|
|
28
|
+
): ExoticComponent<P & { ref?: Ref<R> }> {
|
|
29
|
+
return { $$typeof: REACT_FORWARD_REF_TYPE, render } as unknown as ExoticComponent<P & { ref?: Ref<R> }>
|
|
16
30
|
}
|
|
17
31
|
|
|
18
|
-
export function lazy<T extends { default: any }>(ctor: () => Promise<T>)
|
|
32
|
+
export function lazy<T extends { default: any }>(ctor: () => Promise<T>): ExoticComponent<
|
|
33
|
+
T['default'] extends (props: infer P) => any ? P : {}
|
|
34
|
+
> {
|
|
19
35
|
const payload = {
|
|
20
36
|
status: -1 as -1 | 0 | 1 | 2,
|
|
21
37
|
result: undefined as any,
|
|
@@ -41,5 +57,5 @@ export function lazy<T extends { default: any }>(ctor: () => Promise<T>) {
|
|
|
41
57
|
p.result = thenable
|
|
42
58
|
throw thenable
|
|
43
59
|
},
|
|
44
|
-
}
|
|
60
|
+
} as unknown as ExoticComponent<T['default'] extends (props: infer P) => any ? P : {}>
|
|
45
61
|
}
|
package/src/server/walk.ts
CHANGED
|
@@ -40,10 +40,10 @@ export interface SuspendedBoundary {
|
|
|
40
40
|
|
|
41
41
|
export interface WalkOptions {
|
|
42
42
|
emit: (chunk: string) => void
|
|
43
|
-
onSuspend?: (boundary: SuspendedBoundary) => void
|
|
43
|
+
onSuspend?: ((boundary: SuspendedBoundary) => void) | undefined
|
|
44
44
|
nextBoundaryId: () => number
|
|
45
|
-
bootstrapped?: boolean
|
|
46
|
-
isBoundaryResolution?: boolean
|
|
45
|
+
bootstrapped?: boolean | undefined
|
|
46
|
+
isBoundaryResolution?: boolean | undefined
|
|
47
47
|
/**
|
|
48
48
|
* Tracks whether the most recent emission within the *current text flow*
|
|
49
49
|
* ended with a text node. When the next emission is also text, we emit a
|
package/src/vite/index.ts
CHANGED
|
@@ -164,6 +164,7 @@ const ALIASES: Record<string, string> = {
|
|
|
164
164
|
// React drop-in shim targets. Subpaths first.
|
|
165
165
|
'react/jsx-runtime': '@tanstack/redact/jsx-runtime',
|
|
166
166
|
'react/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',
|
|
167
|
+
'react/compiler-runtime': '@tanstack/redact/compiler-runtime',
|
|
167
168
|
'react-dom/client': '@tanstack/redact/dom-client',
|
|
168
169
|
'react-dom/server': '@tanstack/redact/server',
|
|
169
170
|
'react-dom/test-utils': '@tanstack/redact/dom-test-utils',
|
|
@@ -180,6 +181,7 @@ const ALIASES: Record<string, string> = {
|
|
|
180
181
|
// Subpaths first here too.
|
|
181
182
|
'@tanstack/redact/jsx-runtime': '@tanstack/redact/jsx-runtime',
|
|
182
183
|
'@tanstack/redact/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',
|
|
184
|
+
'@tanstack/redact/compiler-runtime': '@tanstack/redact/compiler-runtime',
|
|
183
185
|
'@tanstack/redact/dom-client': '@tanstack/redact/dom-client',
|
|
184
186
|
'@tanstack/redact/dom-test-utils': '@tanstack/redact/dom-test-utils',
|
|
185
187
|
'@tanstack/redact/server': '@tanstack/redact/server',
|