@tanstack/redact 0.0.21 → 0.1.0
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/attributes.js +2 -1
- package/dist/core/attributes.js.map +2 -2
- package/dist/core/browser.d.ts +9 -0
- package/dist/core/browser.js +35 -0
- package/dist/core/browser.js.map +7 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +3 -3
- package/dist/core/internal.d.ts +31 -8
- package/dist/core/internal.js +3 -1
- package/dist/core/internal.js.map +2 -2
- package/dist/core/resource-hints.d.ts +7 -0
- package/dist/core/resource-hints.js +19 -0
- package/dist/core/resource-hints.js.map +7 -0
- package/dist/core/types.js +1 -1
- package/dist/dom/_all.d.ts +11 -16
- package/dist/dom/_all.js +9 -20
- package/dist/dom/_all.js.map +2 -2
- package/dist/dom/client.d.ts +4 -4
- package/dist/dom/client.js +4 -4
- package/dist/dom/commit.d.ts +23 -0
- package/dist/dom/commit.js +191 -0
- package/dist/dom/commit.js.map +7 -0
- package/dist/dom/dispatcher.d.ts +4 -22
- package/dist/dom/dispatcher.js +184 -126
- package/dist/dom/dispatcher.js.map +3 -3
- package/dist/dom/dom.d.ts +2 -0
- package/dist/dom/dom.js +72 -52
- package/dist/dom/dom.js.map +2 -2
- package/dist/dom/error-info.d.ts +2 -0
- package/dist/dom/error-info.js +16 -0
- package/dist/dom/error-info.js.map +7 -0
- package/dist/dom/event-replay.js +1 -1
- package/dist/dom/features/activity/full.d.ts +1 -0
- package/dist/dom/features/activity/full.js +162 -0
- package/dist/dom/features/activity/full.js.map +7 -0
- package/dist/dom/features/activity/index.d.ts +1 -0
- package/dist/dom/features/activity/index.js +3 -0
- package/dist/dom/features/activity/index.js.map +7 -0
- package/dist/dom/features/activity/stub.d.ts +1 -0
- package/dist/dom/features/activity/stub.js +12 -0
- package/dist/dom/features/activity/stub.js.map +7 -0
- package/dist/dom/features/class/full.js +87 -27
- package/dist/dom/features/class/full.js.map +2 -2
- package/dist/dom/features/class/index.d.ts +1 -1
- package/dist/dom/features/class/index.js +2 -2
- package/dist/dom/features/class/stub.js +3 -3
- package/dist/dom/features/context/full.d.ts +4 -1
- package/dist/dom/features/context/full.js +69 -9
- package/dist/dom/features/context/full.js.map +2 -2
- package/dist/dom/features/context/index.d.ts +1 -1
- package/dist/dom/features/context/index.js +2 -2
- package/dist/dom/features/context/stub.d.ts +4 -1
- package/dist/dom/features/context/stub.js +15 -4
- package/dist/dom/features/context/stub.js.map +2 -2
- package/dist/dom/features/forward-ref/full.js +12 -21
- package/dist/dom/features/forward-ref/full.js.map +2 -2
- package/dist/dom/features/forward-ref/index.d.ts +1 -1
- package/dist/dom/features/forward-ref/index.js +2 -2
- package/dist/dom/features/forward-ref/stub.js +4 -4
- package/dist/dom/features/fragment-refs/index.d.ts +1 -0
- package/dist/dom/features/fragment-refs/index.js +8 -0
- package/dist/dom/features/fragment-refs/index.js.map +7 -0
- package/dist/dom/features/fragment-refs/stub.d.ts +3 -0
- package/dist/dom/features/fragment-refs/stub.js +14 -0
- package/dist/dom/features/fragment-refs/stub.js.map +7 -0
- package/dist/dom/features/hydration/full.d.ts +11 -6
- package/dist/dom/features/hydration/full.js +76 -77
- package/dist/dom/features/hydration/full.js.map +2 -2
- package/dist/dom/features/hydration/index.d.ts +1 -1
- package/dist/dom/features/hydration/index.js +2 -2
- package/dist/dom/features/hydration/stub.d.ts +7 -2
- package/dist/dom/features/hydration/stub.js +1 -1
- package/dist/dom/features/hydration/stub.js.map +1 -1
- package/dist/dom/features/index.d.ts +8 -7
- package/dist/dom/features/index.js +9 -8
- package/dist/dom/features/index.js.map +2 -2
- package/dist/dom/features/lazy/full.js +4 -4
- package/dist/dom/features/lazy/index.d.ts +1 -1
- package/dist/dom/features/lazy/index.js +2 -2
- package/dist/dom/features/lazy/stub.js +4 -4
- package/dist/dom/features/memo/full.js +8 -6
- package/dist/dom/features/memo/full.js.map +2 -2
- package/dist/dom/features/memo/index.d.ts +1 -1
- package/dist/dom/features/memo/index.js +2 -2
- package/dist/dom/features/memo/stub.js +4 -4
- package/dist/dom/features/portal/full.js +4 -4
- package/dist/dom/features/portal/index.d.ts +1 -1
- package/dist/dom/features/portal/index.js +2 -2
- package/dist/dom/features/portal/stub.js +4 -4
- package/dist/dom/features/suspense/full.js +197 -52
- package/dist/dom/features/suspense/full.js.map +2 -2
- package/dist/dom/features/suspense/index.d.ts +1 -1
- package/dist/dom/features/suspense/index.js +2 -2
- package/dist/dom/features/suspense/stub.js +4 -4
- package/dist/dom/features/view-transition/full.d.ts +6 -0
- package/dist/dom/features/view-transition/full.js +280 -0
- package/dist/dom/features/view-transition/full.js.map +7 -0
- package/dist/dom/features/view-transition/index.d.ts +1 -0
- package/dist/dom/features/view-transition/index.js +3 -0
- package/dist/dom/features/view-transition/index.js.map +7 -0
- package/dist/dom/features/view-transition/resources.d.ts +11 -0
- package/dist/dom/features/view-transition/resources.js +108 -0
- package/dist/dom/features/view-transition/resources.js.map +7 -0
- package/dist/dom/features/view-transition/stub.d.ts +6 -0
- package/dist/dom/features/view-transition/stub.js +22 -0
- package/dist/dom/features/view-transition/stub.js.map +7 -0
- package/dist/dom/features/view-transition/visual.d.ts +14 -0
- package/dist/dom/features/view-transition/visual.js +356 -0
- package/dist/dom/features/view-transition/visual.js.map +7 -0
- package/dist/dom/fragment-instance.d.ts +40 -0
- package/dist/dom/fragment-instance.js +324 -0
- package/dist/dom/fragment-instance.js.map +7 -0
- package/dist/dom/index.d.ts +11 -11
- package/dist/dom/index.js +11 -18
- package/dist/dom/index.js.map +3 -3
- package/dist/dom/portal.d.ts +2 -2
- package/dist/dom/portal.js +2 -2
- package/dist/dom/portal.js.map +1 -1
- package/dist/dom/reconcile.d.ts +32 -3
- package/dist/dom/reconcile.js +689 -221
- package/dist/dom/reconcile.js.map +2 -2
- package/dist/dom/resource-hints.d.ts +6 -0
- package/dist/dom/resource-hints.js +115 -0
- package/dist/dom/resource-hints.js.map +7 -0
- package/dist/dom/resource-store.d.ts +13 -0
- package/dist/dom/resource-store.js +43 -0
- package/dist/dom/resource-store.js.map +7 -0
- package/dist/dom/resources.d.ts +1 -0
- package/dist/dom/resources.js +44 -0
- package/dist/dom/resources.js.map +7 -0
- package/dist/dom/retained-effects.d.ts +6 -0
- package/dist/dom/retained-effects.js +49 -0
- package/dist/dom/retained-effects.js.map +7 -0
- package/dist/dom/root-internal.d.ts +4 -4
- package/dist/dom/root-internal.js +2 -2
- package/dist/dom/root-internal.js.map +2 -2
- package/dist/dom/root.d.ts +5 -5
- package/dist/dom/root.js +11 -11
- package/dist/dom/root.js.map +2 -2
- package/dist/dom/test-utils.js +1 -1
- package/dist/react/activity.d.ts +7 -0
- package/dist/react/activity.js +8 -0
- package/dist/react/activity.js.map +7 -0
- package/dist/react/children.d.ts +1 -1
- package/dist/react/children.js +3 -3
- package/dist/react/children.js.map +1 -1
- package/dist/react/class.d.ts +1 -1
- package/dist/react/class.js +3 -3
- package/dist/react/class.js.map +1 -1
- package/dist/react/compiler-runtime.js +2 -2
- package/dist/react/context.d.ts +1 -1
- package/dist/react/context.js +3 -3
- package/dist/react/context.js.map +1 -1
- package/dist/react/element.d.ts +6 -3
- package/dist/react/element.js +2 -2
- package/dist/react/element.js.map +2 -2
- package/dist/react/hooks.d.ts +26 -7
- package/dist/react/hooks.js +13 -3
- package/dist/react/hooks.js.map +2 -2
- package/dist/react/index.d.ts +39 -24
- package/dist/react/index.js +39 -19
- package/dist/react/index.js.map +3 -3
- package/dist/react/jsx-runtime.d.ts +2 -2
- package/dist/react/jsx-runtime.js +3 -3
- package/dist/react/memo.d.ts +1 -1
- package/dist/react/memo.js +1 -1
- package/dist/react/portal.js +1 -1
- package/dist/react/shared-internals.d.ts +15 -5
- package/dist/react/shared-internals.js +2 -3
- package/dist/react/shared-internals.js.map +2 -2
- package/dist/react/suspense.js +1 -1
- package/dist/react/view-transition.d.ts +32 -0
- package/dist/react/view-transition.js +13 -0
- package/dist/react/view-transition.js.map +7 -0
- package/dist/scheduler/index.js +1 -1
- package/dist/server/bootstrap-script.d.ts +1 -23
- package/dist/server/bootstrap-script.js +7 -6
- package/dist/server/bootstrap-script.js.map +2 -2
- package/dist/server/dispatcher.d.ts +28 -6
- package/dist/server/dispatcher.js +33 -15
- package/dist/server/dispatcher.js.map +2 -2
- package/dist/server/escape.js +16 -15
- package/dist/server/escape.js.map +2 -2
- package/dist/server/index.d.ts +6 -6
- package/dist/server/index.js +7 -7
- package/dist/server/renderToString.d.ts +1 -1
- package/dist/server/renderToString.js +12 -8
- package/dist/server/renderToString.js.map +2 -2
- package/dist/server/resource-hints.d.ts +22 -0
- package/dist/server/resource-hints.js +148 -0
- package/dist/server/resource-hints.js.map +7 -0
- package/dist/server/stream.d.ts +15 -2
- package/dist/server/stream.js +155 -63
- package/dist/server/stream.js.map +2 -2
- package/dist/server/walk.d.ts +15 -2
- package/dist/server/walk.js +143 -96
- package/dist/server/walk.js.map +2 -2
- package/dist/vite/index.d.ts +6 -0
- package/dist/vite/index.js +22 -6
- package/dist/vite/index.js.map +2 -2
- package/package.json +1 -1
- package/src/core/attributes.ts +1 -0
- package/src/core/browser.ts +33 -0
- package/src/core/internal.ts +24 -6
- package/src/core/resource-hints.ts +36 -0
- package/src/dom/_all.ts +1 -7
- package/src/dom/commit.ts +186 -0
- package/src/dom/dispatcher.ts +190 -134
- package/src/dom/dom.ts +70 -54
- package/src/dom/error-info.ts +15 -0
- package/src/dom/features/activity/full.ts +166 -0
- package/src/dom/features/activity/index.ts +1 -0
- package/src/dom/features/activity/stub.ts +14 -0
- package/src/dom/features/class/full.ts +72 -28
- package/src/dom/features/context/full.ts +66 -4
- package/src/dom/features/context/stub.ts +6 -0
- package/src/dom/features/forward-ref/full.ts +9 -19
- package/src/dom/features/fragment-refs/index.ts +1 -0
- package/src/dom/features/fragment-refs/stub.ts +3 -0
- package/src/dom/features/hydration/full.ts +84 -85
- package/src/dom/features/hydration/stub.ts +1 -1
- package/src/dom/features/index.ts +1 -0
- package/src/dom/features/memo/full.ts +4 -3
- package/src/dom/features/suspense/full.ts +192 -55
- package/src/dom/features/view-transition/full.ts +288 -0
- package/src/dom/features/view-transition/index.ts +1 -0
- package/src/dom/features/view-transition/resources.ts +107 -0
- package/src/dom/features/view-transition/stub.ts +7 -0
- package/src/dom/features/view-transition/visual.ts +406 -0
- package/src/dom/fragment-instance.ts +337 -0
- package/src/dom/index.ts +6 -7
- package/src/dom/portal.ts +1 -1
- package/src/dom/reconcile.ts +695 -242
- package/src/dom/resource-hints.ts +115 -0
- package/src/dom/resource-store.ts +52 -0
- package/src/dom/resources.ts +39 -0
- package/src/dom/retained-effects.ts +38 -0
- package/src/dom/root-internal.ts +4 -4
- package/src/dom/root.ts +12 -14
- package/src/react/activity.ts +10 -0
- package/src/react/element.ts +6 -2
- package/src/react/hooks.ts +12 -3
- package/src/react/index.ts +18 -0
- package/src/react/shared-internals.ts +3 -3
- package/src/react/view-transition.ts +41 -0
- package/src/server/bootstrap-script.ts +36 -5
- package/src/server/dispatcher.ts +35 -13
- package/src/server/escape.ts +15 -12
- package/src/server/renderToString.ts +7 -5
- package/src/server/resource-hints.ts +165 -0
- package/src/server/stream.ts +154 -62
- package/src/server/walk.ts +72 -11
- package/src/vite/index.ts +30 -13
package/src/vite/index.ts
CHANGED
|
@@ -12,6 +12,12 @@ export type RedactPreset = 'nano' | 'full'
|
|
|
12
12
|
* configs as autocompleted options.
|
|
13
13
|
*/
|
|
14
14
|
export interface RedactFeatures {
|
|
15
|
+
/** Activity visibility, retained state and disconnected effects. */
|
|
16
|
+
activity?: boolean
|
|
17
|
+
/** DOM instances, events, focus, layout and observers for Fragment refs. */
|
|
18
|
+
fragmentRefs?: boolean
|
|
19
|
+
/** Experimental native ViewTransition animations. Opt-in until snapshot parity is complete. */
|
|
20
|
+
viewTransitions?: boolean
|
|
15
21
|
/**
|
|
16
22
|
* `createPortal`. When `false`, portal elements render in place as a
|
|
17
23
|
* Fragment (the `container` prop is ignored). `renderPortal` and its
|
|
@@ -72,6 +78,9 @@ export interface RedactFeatures {
|
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
interface ResolvedFeatures {
|
|
81
|
+
activity: boolean
|
|
82
|
+
fragmentRefs: boolean
|
|
83
|
+
viewTransitions: boolean
|
|
75
84
|
portal: boolean
|
|
76
85
|
context: boolean
|
|
77
86
|
suspense: boolean
|
|
@@ -85,11 +94,13 @@ interface ResolvedFeatures {
|
|
|
85
94
|
const PRESET_DEFAULTS: Record<RedactPreset, ResolvedFeatures> = {
|
|
86
95
|
// Opt-in: everything off. Turn individual features on via `features`.
|
|
87
96
|
nano: {
|
|
97
|
+
activity: false, fragmentRefs: false, viewTransitions: false,
|
|
88
98
|
portal: false, context: false, suspense: false, memo: false,
|
|
89
99
|
forwardRef: false, lazy: false, classComponents: false, hydration: false,
|
|
90
100
|
},
|
|
91
101
|
// Opt-out: everything on (drop-in React parity). Turn features off via `features`.
|
|
92
102
|
full: {
|
|
103
|
+
activity: true, fragmentRefs: true, viewTransitions: false,
|
|
93
104
|
portal: true, context: true, suspense: true, memo: true,
|
|
94
105
|
forwardRef: true, lazy: true, classComponents: true, hydration: true,
|
|
95
106
|
},
|
|
@@ -101,6 +112,9 @@ function resolveFeatures(
|
|
|
101
112
|
): ResolvedFeatures {
|
|
102
113
|
const p = PRESET_DEFAULTS[preset]
|
|
103
114
|
return {
|
|
115
|
+
activity: overrides.activity ?? p.activity,
|
|
116
|
+
fragmentRefs: overrides.fragmentRefs ?? p.fragmentRefs,
|
|
117
|
+
viewTransitions: overrides.viewTransitions ?? p.viewTransitions,
|
|
104
118
|
portal: overrides.portal ?? p.portal,
|
|
105
119
|
context: overrides.context ?? p.context,
|
|
106
120
|
suspense: overrides.suspense ?? p.suspense,
|
|
@@ -166,7 +180,10 @@ const ALIASES: Record<string, string> = {
|
|
|
166
180
|
'react/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',
|
|
167
181
|
'react/compiler-runtime': '@tanstack/redact/compiler-runtime',
|
|
168
182
|
'react-dom/client': '@tanstack/redact/dom-client',
|
|
183
|
+
'react-dom/server.browser': '@tanstack/redact/server',
|
|
184
|
+
'react-dom/server.bun': '@tanstack/redact/server',
|
|
169
185
|
'react-dom/server.edge': '@tanstack/redact/server',
|
|
186
|
+
'react-dom/server.node': '@tanstack/redact/server',
|
|
170
187
|
'react-dom/static.edge': '@tanstack/redact/server',
|
|
171
188
|
'react-dom/server': '@tanstack/redact/server',
|
|
172
189
|
'react-dom/test-utils': '@tanstack/redact/dom-test-utils',
|
|
@@ -225,10 +242,8 @@ function resolveExport(packageDir: string, sub: string): string | null {
|
|
|
225
242
|
}
|
|
226
243
|
const key = sub ? './' + sub : '.'
|
|
227
244
|
const exp = pkg.exports?.[key]
|
|
228
|
-
// Prefer published
|
|
229
|
-
//
|
|
230
|
-
// individual source files. The package keeps cross-subpath imports
|
|
231
|
-
// external, so there's still only one runtime instance.
|
|
245
|
+
// Prefer published JavaScript over TypeScript sources. Dist preserves one
|
|
246
|
+
// file per module, so subpath imports share state and feature boundaries.
|
|
232
247
|
const pick = (v: any): string | null => {
|
|
233
248
|
if (typeof v === 'string') return v
|
|
234
249
|
if (v && typeof v === 'object') {
|
|
@@ -388,11 +403,12 @@ export function redact(options: RedactOptions = {}): any {
|
|
|
388
403
|
// if the flag is off. The stub registers a graceful-degradation
|
|
389
404
|
// matcher (e.g. Portal → Fragment) so user code keeps working.
|
|
390
405
|
if (importer && /[\\/]features[\\/]index\.[jt]sx?$/.test(importer)) {
|
|
391
|
-
const m = id.match(/^\.\/([a-z-]+)
|
|
406
|
+
const m = id.match(/^\.\/([a-z-]+)(\/index\.js)?$/)
|
|
392
407
|
if (m) {
|
|
393
|
-
const
|
|
408
|
+
const dir = m[1]!
|
|
409
|
+
const name = (dir === 'forward-ref' ? 'forwardRef' : dir === 'fragment-refs' ? 'fragmentRefs' : dir === 'view-transition' ? 'viewTransitions' : dir === 'class' ? 'classComponents' : dir) as keyof ResolvedFeatures
|
|
394
410
|
if (name in features && !features[name]) {
|
|
395
|
-
const r = await this.resolve(`./${
|
|
411
|
+
const r = await this.resolve(`./${dir}/stub${m[2] ? '.js' : ''}`, importer, {
|
|
396
412
|
...opts,
|
|
397
413
|
skipSelf: true,
|
|
398
414
|
})
|
|
@@ -401,13 +417,14 @@ export function redact(options: RedactOptions = {}): any {
|
|
|
401
417
|
}
|
|
402
418
|
}
|
|
403
419
|
|
|
404
|
-
//
|
|
405
|
-
//
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
if (
|
|
420
|
+
// Peer imports must use the same feature selection as the registration
|
|
421
|
+
// entrypoint, or an enabled feature can bring a disabled one back in.
|
|
422
|
+
const peer = id.match(/[\\/](context|hydration|fragment-refs|view-transition)(?:[\\/]index\.js)?$/)
|
|
423
|
+
const peerKey = peer?.[1] === 'fragment-refs' ? 'fragmentRefs' : peer?.[1] === 'view-transition' ? 'viewTransitions' : peer?.[1] as 'context' | 'hydration' | undefined
|
|
424
|
+
if (importer && peer && peerKey && !features[peerKey]) {
|
|
409
425
|
const r = await this.resolve(id, importer, { ...opts, skipSelf: true })
|
|
410
|
-
|
|
426
|
+
const resolvedFeature = r?.id.match(/features[\\/](context|hydration|fragment-refs|view-transition)[\\/]index\.(ts|js)$/)
|
|
427
|
+
if (resolvedFeature?.[1] === peer[1]) {
|
|
411
428
|
return r.id.replace(/index\.(ts|js)$/, 'stub.$1')
|
|
412
429
|
}
|
|
413
430
|
}
|