@bleedingdev/tanstack-redact 0.0.0-stage → 0.2.2
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/LICENSE +21 -0
- package/dist/cloudflare/index.d.ts +6 -0
- package/dist/cloudflare/index.js +39 -0
- package/dist/cloudflare/index.js.map +7 -0
- package/dist/core/attributes.d.ts +4 -0
- package/dist/core/attributes.js +30 -0
- package/dist/core/attributes.js.map +7 -0
- package/dist/core/browser.d.ts +9 -0
- package/dist/core/browser.js +32 -0
- package/dist/core/browser.js.map +7 -0
- package/dist/core/class-props.d.ts +1 -0
- package/dist/core/class-props.js +15 -0
- package/dist/core/class-props.js.map +7 -0
- package/dist/core/devtools.d.ts +26 -0
- package/dist/core/devtools.js +70 -0
- package/dist/core/devtools.js.map +7 -0
- package/dist/core/functions.d.ts +6 -0
- package/dist/core/functions.js +14 -0
- package/dist/core/functions.js.map +7 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +7 -0
- package/dist/core/internal.d.ts +103 -0
- package/dist/core/internal.js +43 -0
- package/dist/core/internal.js.map +7 -0
- package/dist/core/resource-hints.d.ts +7 -0
- package/dist/core/resource-hints.js +20 -0
- package/dist/core/resource-hints.js.map +7 -0
- package/dist/core/types.d.ts +23 -0
- package/dist/core/types.js +8 -0
- package/dist/core/types.js.map +7 -0
- package/dist/core/unitless-style.d.ts +1 -0
- package/dist/core/unitless-style.js +5 -0
- package/dist/core/unitless-style.js.map +7 -0
- package/dist/dom/_all.d.ts +27 -0
- package/dist/dom/_all.js +51 -0
- package/dist/dom/_all.js.map +7 -0
- package/dist/dom/client.d.ts +9 -0
- package/dist/dom/client.js +13 -0
- package/dist/dom/client.js.map +7 -0
- package/dist/dom/commit.d.ts +27 -0
- package/dist/dom/commit.js +237 -0
- package/dist/dom/commit.js.map +7 -0
- package/dist/dom/devtools-effects.d.ts +8 -0
- package/dist/dom/devtools-effects.js +80 -0
- package/dist/dom/devtools-effects.js.map +7 -0
- package/dist/dom/devtools.d.ts +33 -0
- package/dist/dom/devtools.js +635 -0
- package/dist/dom/devtools.js.map +7 -0
- package/dist/dom/dispatcher.d.ts +4 -0
- package/dist/dom/dispatcher.js +437 -0
- package/dist/dom/dispatcher.js.map +7 -0
- package/dist/dom/document-metadata.d.ts +7 -0
- package/dist/dom/document-metadata.js +44 -0
- package/dist/dom/document-metadata.js.map +7 -0
- package/dist/dom/dom.d.ts +11 -0
- package/dist/dom/dom.js +165 -0
- package/dist/dom/dom.js.map +7 -0
- package/dist/dom/error-info.d.ts +2 -0
- package/dist/dom/error-info.js +19 -0
- package/dist/dom/error-info.js.map +7 -0
- package/dist/dom/event-replay.d.ts +13 -0
- package/dist/dom/event-replay.js +24 -0
- package/dist/dom/event-replay.js.map +7 -0
- package/dist/dom/features/activity/full.d.ts +1 -0
- package/dist/dom/features/activity/full.js +140 -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 +2 -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 +10 -0
- package/dist/dom/features/activity/stub.js.map +7 -0
- package/dist/dom/features/class/full.d.ts +1 -0
- package/dist/dom/features/class/full.js +208 -0
- package/dist/dom/features/class/full.js.map +7 -0
- package/dist/dom/features/class/index.d.ts +1 -0
- package/dist/dom/features/class/index.js +2 -0
- package/dist/dom/features/class/index.js.map +7 -0
- package/dist/dom/features/class/stub.d.ts +1 -0
- package/dist/dom/features/class/stub.js +46 -0
- package/dist/dom/features/class/stub.js.map +7 -0
- package/dist/dom/features/context/full.d.ts +4 -0
- package/dist/dom/features/context/full.js +103 -0
- package/dist/dom/features/context/full.js.map +7 -0
- package/dist/dom/features/context/index.d.ts +1 -0
- package/dist/dom/features/context/index.js +2 -0
- package/dist/dom/features/context/index.js.map +7 -0
- package/dist/dom/features/context/stub.d.ts +4 -0
- package/dist/dom/features/context/stub.js +21 -0
- package/dist/dom/features/context/stub.js.map +7 -0
- package/dist/dom/features/forward-ref/full.d.ts +1 -0
- package/dist/dom/features/forward-ref/full.js +9 -0
- package/dist/dom/features/forward-ref/full.js.map +7 -0
- package/dist/dom/features/forward-ref/index.d.ts +1 -0
- package/dist/dom/features/forward-ref/index.js +2 -0
- package/dist/dom/features/forward-ref/index.js.map +7 -0
- package/dist/dom/features/forward-ref/stub.d.ts +1 -0
- package/dist/dom/features/forward-ref/stub.js +9 -0
- package/dist/dom/features/forward-ref/stub.js.map +7 -0
- package/dist/dom/features/fragment-refs/index.d.ts +1 -0
- package/dist/dom/features/fragment-refs/index.js +9 -0
- package/dist/dom/features/fragment-refs/index.js.map +7 -0
- package/dist/dom/features/fragment-refs/stub.d.ts +5 -0
- package/dist/dom/features/fragment-refs/stub.js +17 -0
- package/dist/dom/features/fragment-refs/stub.js.map +7 -0
- package/dist/dom/features/hydration/full.d.ts +68 -0
- package/dist/dom/features/hydration/full.js +493 -0
- package/dist/dom/features/hydration/full.js.map +7 -0
- package/dist/dom/features/hydration/index.d.ts +1 -0
- package/dist/dom/features/hydration/index.js +2 -0
- package/dist/dom/features/hydration/index.js.map +7 -0
- package/dist/dom/features/hydration/stub.d.ts +36 -0
- package/dist/dom/features/hydration/stub.js +80 -0
- package/dist/dom/features/hydration/stub.js.map +7 -0
- package/dist/dom/features/index.d.ts +8 -0
- package/dist/dom/features/index.js +9 -0
- package/dist/dom/features/index.js.map +7 -0
- package/dist/dom/features/lazy/full.d.ts +1 -0
- package/dist/dom/features/lazy/full.js +23 -0
- package/dist/dom/features/lazy/full.js.map +7 -0
- package/dist/dom/features/lazy/index.d.ts +1 -0
- package/dist/dom/features/lazy/index.js +2 -0
- package/dist/dom/features/lazy/index.js.map +7 -0
- package/dist/dom/features/lazy/stub.d.ts +1 -0
- package/dist/dom/features/lazy/stub.js +19 -0
- package/dist/dom/features/lazy/stub.js.map +7 -0
- package/dist/dom/features/memo/full.d.ts +1 -0
- package/dist/dom/features/memo/full.js +34 -0
- package/dist/dom/features/memo/full.js.map +7 -0
- package/dist/dom/features/memo/index.d.ts +1 -0
- package/dist/dom/features/memo/index.js +2 -0
- package/dist/dom/features/memo/index.js.map +7 -0
- package/dist/dom/features/memo/stub.d.ts +1 -0
- package/dist/dom/features/memo/stub.js +9 -0
- package/dist/dom/features/memo/stub.js.map +7 -0
- package/dist/dom/features/portal/full.d.ts +1 -0
- package/dist/dom/features/portal/full.js +11 -0
- package/dist/dom/features/portal/full.js.map +7 -0
- package/dist/dom/features/portal/index.d.ts +1 -0
- package/dist/dom/features/portal/index.js +2 -0
- package/dist/dom/features/portal/index.js.map +7 -0
- package/dist/dom/features/portal/stub.d.ts +1 -0
- package/dist/dom/features/portal/stub.js +5 -0
- package/dist/dom/features/portal/stub.js.map +7 -0
- package/dist/dom/features/suspense/full.d.ts +1 -0
- package/dist/dom/features/suspense/full.js +389 -0
- package/dist/dom/features/suspense/full.js.map +7 -0
- package/dist/dom/features/suspense/index.d.ts +1 -0
- package/dist/dom/features/suspense/index.js +2 -0
- package/dist/dom/features/suspense/index.js.map +7 -0
- package/dist/dom/features/suspense/stub.d.ts +1 -0
- package/dist/dom/features/suspense/stub.js +4 -0
- package/dist/dom/features/suspense/stub.js.map +7 -0
- package/dist/dom/features/suspense-runtime/index.d.ts +1 -0
- package/dist/dom/features/suspense-runtime/index.js +2 -0
- package/dist/dom/features/suspense-runtime/index.js.map +7 -0
- package/dist/dom/features/suspense-runtime/stub.d.ts +1 -0
- package/dist/dom/features/suspense-runtime/stub.js +11 -0
- package/dist/dom/features/suspense-runtime/stub.js.map +7 -0
- package/dist/dom/features/view-transition/full.d.ts +7 -0
- package/dist/dom/features/view-transition/full.js +324 -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 +2 -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 +117 -0
- package/dist/dom/features/view-transition/resources.js.map +7 -0
- package/dist/dom/features/view-transition/stub.d.ts +7 -0
- package/dist/dom/features/view-transition/stub.js +21 -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 +404 -0
- package/dist/dom/features/view-transition/visual.js.map +7 -0
- package/dist/dom/form-actions.d.ts +4 -0
- package/dist/dom/form-actions.js +74 -0
- package/dist/dom/form-actions.js.map +7 -0
- package/dist/dom/form-controls.d.ts +3 -0
- package/dist/dom/form-controls.js +91 -0
- package/dist/dom/form-controls.js.map +7 -0
- package/dist/dom/fragment-instance.d.ts +33 -0
- package/dist/dom/fragment-instance.js +449 -0
- package/dist/dom/fragment-instance.js.map +7 -0
- package/dist/dom/index.d.ts +61 -0
- package/dist/dom/index.js +71 -0
- package/dist/dom/index.js.map +7 -0
- package/dist/dom/portal.d.ts +2 -0
- package/dist/dom/portal.js +14 -0
- package/dist/dom/portal.js.map +7 -0
- package/dist/dom/react-ids.d.ts +6 -0
- package/dist/dom/react-ids.js +38 -0
- package/dist/dom/react-ids.js.map +7 -0
- package/dist/dom/reconcile.d.ts +86 -0
- package/dist/dom/reconcile.js +1305 -0
- package/dist/dom/reconcile.js.map +7 -0
- package/dist/dom/refresh.d.ts +12 -0
- package/dist/dom/refresh.js +174 -0
- package/dist/dom/refresh.js.map +7 -0
- package/dist/dom/resource-hints.d.ts +6 -0
- package/dist/dom/resource-hints.js +107 -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 +47 -0
- package/dist/dom/resource-store.js.map +7 -0
- package/dist/dom/resources.d.ts +1 -0
- package/dist/dom/resources.js +46 -0
- package/dist/dom/resources.js.map +7 -0
- package/dist/dom/retained-effects.d.ts +6 -0
- package/dist/dom/retained-effects.js +67 -0
- package/dist/dom/retained-effects.js.map +7 -0
- package/dist/dom/root-internal.d.ts +11 -0
- package/dist/dom/root-internal.js +35 -0
- package/dist/dom/root-internal.js.map +7 -0
- package/dist/dom/root.d.ts +17 -0
- package/dist/dom/root.js +38 -0
- package/dist/dom/root.js.map +7 -0
- package/dist/dom/synthetic-event.d.ts +1 -0
- package/dist/dom/synthetic-event.js +37 -0
- package/dist/dom/synthetic-event.js.map +7 -0
- package/dist/dom/test-utils.d.ts +1 -0
- package/dist/dom/test-utils.js +5 -0
- package/dist/dom/test-utils.js.map +7 -0
- package/dist/dom/transitions.d.ts +9 -0
- package/dist/dom/transitions.js +147 -0
- package/dist/dom/transitions.js.map +7 -0
- package/dist/dom/tree.d.ts +5 -0
- package/dist/dom/tree.js +62 -0
- package/dist/dom/tree.js.map +7 -0
- package/dist/dom/walk.d.ts +2 -0
- package/dist/dom/walk.js +14 -0
- package/dist/dom/walk.js.map +7 -0
- package/dist/next/client.d.ts +9 -0
- package/dist/next/client.js +14 -0
- package/dist/next/client.js.map +7 -0
- package/dist/next/dev-cache-loader.cjs +13 -0
- package/dist/next/index.d.ts +2 -0
- package/dist/next/index.js +97 -0
- package/dist/next/index.js.map +7 -0
- package/dist/next/loader.cjs +10 -0
- package/dist/next/react.d.ts +71 -0
- package/dist/next/react.js +9 -0
- package/dist/next/react.js.map +7 -0
- package/dist/react/act.d.ts +3 -0
- package/dist/react/act.js +124 -0
- package/dist/react/act.js.map +7 -0
- package/dist/react/action-scope.d.ts +17 -0
- package/dist/react/action-scope.js +60 -0
- package/dist/react/action-scope.js.map +7 -0
- package/dist/react/activity.d.ts +7 -0
- package/dist/react/activity.js +7 -0
- package/dist/react/activity.js.map +7 -0
- package/dist/react/children.d.ts +8 -0
- package/dist/react/children.js +76 -0
- package/dist/react/children.js.map +7 -0
- package/dist/react/class.d.ts +36 -0
- package/dist/react/class.js +39 -0
- package/dist/react/class.js.map +7 -0
- package/dist/react/compiler-runtime.d.ts +1 -0
- package/dist/react/compiler-runtime.js +9 -0
- package/dist/react/compiler-runtime.js.map +7 -0
- package/dist/react/context.d.ts +32 -0
- package/dist/react/context.js +25 -0
- package/dist/react/context.js.map +7 -0
- package/dist/react/element.d.ts +13 -0
- package/dist/react/element.js +70 -0
- package/dist/react/element.js.map +7 -0
- package/dist/react/form-state.d.ts +26 -0
- package/dist/react/form-state.js +30 -0
- package/dist/react/form-state.js.map +7 -0
- package/dist/react/hooks.d.ts +67 -0
- package/dist/react/hooks.js +165 -0
- package/dist/react/hooks.js.map +7 -0
- package/dist/react/index.d.ts +99 -0
- package/dist/react/index.js +143 -0
- package/dist/react/index.js.map +7 -0
- package/dist/react/jsx-runtime.d.ts +24 -0
- package/dist/react/jsx-runtime.js +37 -0
- package/dist/react/jsx-runtime.js.map +7 -0
- package/dist/react/memo.d.ts +20 -0
- package/dist/react/memo.js +27 -0
- package/dist/react/memo.js.map +7 -0
- package/dist/react/portal.d.ts +1 -0
- package/dist/react/portal.js +5 -0
- package/dist/react/portal.js.map +7 -0
- package/dist/react/shared-internals.d.ts +52 -0
- package/dist/react/shared-internals.js +22 -0
- package/dist/react/shared-internals.js.map +7 -0
- package/dist/react/suspense.d.ts +15 -0
- package/dist/react/suspense.js +15 -0
- package/dist/react/suspense.js.map +7 -0
- package/dist/react/thenable.d.ts +1 -0
- package/dist/react/thenable.js +25 -0
- package/dist/react/thenable.js.map +7 -0
- package/dist/react/view-transition.d.ts +32 -0
- package/dist/react/view-transition.js +12 -0
- package/dist/react/view-transition.js.map +7 -0
- package/dist/scheduler/index.d.ts +44 -0
- package/dist/scheduler/index.js +109 -0
- package/dist/scheduler/index.js.map +7 -0
- package/dist/server/bootstrap-script.d.ts +3 -0
- package/dist/server/bootstrap-script.js +17 -0
- package/dist/server/bootstrap-script.js.map +7 -0
- package/dist/server/dispatcher.d.ts +57 -0
- package/dist/server/dispatcher.js +157 -0
- package/dist/server/dispatcher.js.map +7 -0
- package/dist/server/escape.d.ts +6 -0
- package/dist/server/escape.js +75 -0
- package/dist/server/escape.js.map +7 -0
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.js +25 -0
- package/dist/server/index.js.map +7 -0
- package/dist/server/insertion-context.d.ts +3 -0
- package/dist/server/insertion-context.js +32 -0
- package/dist/server/renderToString.d.ts +7 -0
- package/dist/server/renderToString.js +33 -0
- package/dist/server/renderToString.js.map +7 -0
- package/dist/server/resource-hints.d.ts +22 -0
- package/dist/server/resource-hints.js +168 -0
- package/dist/server/resource-hints.js.map +7 -0
- package/dist/server/stream-ids.d.ts +3 -0
- package/dist/server/stream-ids.js +8 -0
- package/dist/server/stream.d.ts +61 -0
- package/dist/server/stream.js +418 -0
- package/dist/server/stream.js.map +7 -0
- package/dist/server/walk.d.ts +58 -0
- package/dist/server/walk.js +378 -0
- package/dist/server/walk.js.map +7 -0
- package/dist/vinext/compatibility.d.ts +23 -0
- package/dist/vinext/compatibility.js +127 -0
- package/dist/vinext/compatibility.js.map +7 -0
- package/dist/vinext/flight-timing.d.ts +1 -0
- package/dist/vinext/flight-timing.js +46 -0
- package/dist/vinext/flight-timing.js.map +7 -0
- package/dist/vinext/index.d.ts +5 -0
- package/dist/vinext/index.js +50 -0
- package/dist/vinext/index.js.map +7 -0
- package/dist/vite/index.d.ts +102 -0
- package/dist/vite/index.js +291 -0
- package/dist/vite/index.js.map +7 -0
- package/dist/vite/react18.d.ts +4 -0
- package/dist/vite/react18.js +74 -0
- package/dist/vite/react18.js.map +7 -0
- package/package.json +121 -4
- package/src/cloudflare/index.ts +44 -0
- package/src/core/attributes.ts +20 -0
- package/src/core/browser.ts +34 -0
- package/src/core/class-props.ts +12 -0
- package/src/core/devtools.ts +69 -0
- package/src/core/functions.ts +11 -0
- package/src/core/index.ts +2 -0
- package/src/core/internal.ts +123 -0
- package/src/core/resource-hints.ts +39 -0
- package/src/core/types.ts +39 -0
- package/src/core/unitless-style.ts +1 -0
- package/src/dom/_all.ts +46 -0
- package/src/dom/client.ts +17 -0
- package/src/dom/commit.ts +223 -0
- package/src/dom/devtools-effects.ts +78 -0
- package/src/dom/devtools.ts +527 -0
- package/src/dom/dispatcher.ts +476 -0
- package/src/dom/document-metadata.ts +41 -0
- package/src/dom/dom.ts +181 -0
- package/src/dom/error-info.ts +20 -0
- package/src/dom/event-replay.ts +39 -0
- package/src/dom/features/activity/full.ts +150 -0
- package/src/dom/features/activity/index.ts +1 -0
- package/src/dom/features/activity/stub.ts +12 -0
- package/src/dom/features/class/full.ts +202 -0
- package/src/dom/features/class/index.ts +1 -0
- package/src/dom/features/class/stub.ts +58 -0
- package/src/dom/features/context/full.ts +107 -0
- package/src/dom/features/context/index.ts +1 -0
- package/src/dom/features/context/stub.ts +26 -0
- package/src/dom/features/forward-ref/full.ts +9 -0
- package/src/dom/features/forward-ref/index.ts +1 -0
- package/src/dom/features/forward-ref/stub.ts +15 -0
- package/src/dom/features/fragment-refs/index.ts +1 -0
- package/src/dom/features/fragment-refs/stub.ts +6 -0
- package/src/dom/features/hydration/full.ts +563 -0
- package/src/dom/features/hydration/index.ts +1 -0
- package/src/dom/features/hydration/stub.ts +86 -0
- package/src/dom/features/index.ts +12 -0
- package/src/dom/features/lazy/full.ts +27 -0
- package/src/dom/features/lazy/index.ts +1 -0
- package/src/dom/features/lazy/stub.ts +24 -0
- package/src/dom/features/memo/full.ts +39 -0
- package/src/dom/features/memo/index.ts +1 -0
- package/src/dom/features/memo/stub.ts +13 -0
- package/src/dom/features/portal/full.ts +14 -0
- package/src/dom/features/portal/index.ts +1 -0
- package/src/dom/features/portal/stub.ts +11 -0
- package/src/dom/features/suspense/full.ts +469 -0
- package/src/dom/features/suspense/index.ts +1 -0
- package/src/dom/features/suspense/stub.ts +13 -0
- package/src/dom/features/suspense-runtime/index.ts +1 -0
- package/src/dom/features/suspense-runtime/stub.ts +1 -0
- package/src/dom/features/view-transition/full.ts +292 -0
- package/src/dom/features/view-transition/index.ts +1 -0
- package/src/dom/features/view-transition/resources.ts +123 -0
- package/src/dom/features/view-transition/stub.ts +8 -0
- package/src/dom/features/view-transition/visual.ts +454 -0
- package/src/dom/form-actions.ts +69 -0
- package/src/dom/form-controls.ts +91 -0
- package/src/dom/fragment-instance.ts +462 -0
- package/src/dom/index.ts +49 -0
- package/src/dom/portal.ts +16 -0
- package/src/dom/react-ids.ts +36 -0
- package/src/dom/reconcile.ts +1423 -0
- package/src/dom/refresh.ts +171 -0
- package/src/dom/resource-hints.ts +104 -0
- package/src/dom/resource-store.ts +50 -0
- package/src/dom/resources.ts +47 -0
- package/src/dom/retained-effects.ts +57 -0
- package/src/dom/root-internal.ts +37 -0
- package/src/dom/root.ts +59 -0
- package/src/dom/synthetic-event.ts +27 -0
- package/src/dom/test-utils.ts +1 -0
- package/src/dom/transitions.ts +141 -0
- package/src/dom/tree.ts +56 -0
- package/src/dom/walk.ts +8 -0
- package/src/next/client.ts +10 -0
- package/src/next/dev-cache-loader.cjs +13 -0
- package/src/next/index.ts +95 -0
- package/src/next/loader.cjs +10 -0
- package/src/next/react.ts +7 -0
- package/src/react/act.ts +105 -0
- package/src/react/action-scope.ts +57 -0
- package/src/react/activity.ts +10 -0
- package/src/react/children.ts +86 -0
- package/src/react/class.ts +66 -0
- package/src/react/compiler-runtime.ts +8 -0
- package/src/react/context.ts +46 -0
- package/src/react/element.ts +82 -0
- package/src/react/form-state.ts +35 -0
- package/src/react/hooks.ts +214 -0
- package/src/react/index.ts +91 -0
- package/src/react/jsx-runtime.ts +50 -0
- package/src/react/memo.ts +42 -0
- package/src/react/portal.ts +1 -0
- package/src/react/shared-internals.ts +80 -0
- package/src/react/suspense.ts +18 -0
- package/src/react/thenable.ts +21 -0
- package/src/react/view-transition.ts +41 -0
- package/src/scheduler/index.ts +124 -0
- package/src/server/bootstrap-script.ts +92 -0
- package/src/server/dispatcher.ts +168 -0
- package/src/server/escape.ts +102 -0
- package/src/server/index.ts +26 -0
- package/src/server/insertion-context.ts +28 -0
- package/src/server/renderToString.ts +35 -0
- package/src/server/resource-hints.ts +166 -0
- package/src/server/stream-ids.ts +5 -0
- package/src/server/stream.ts +525 -0
- package/src/server/walk.ts +555 -0
- package/src/vinext/compatibility.ts +122 -0
- package/src/vinext/flight-timing.ts +37 -0
- package/src/vinext/index.ts +47 -0
- package/src/vite/index.ts +476 -0
- package/src/vite/react18.ts +74 -0
- package/vendor/cloudflare-vite-plugin/LICENSE +25 -0
- package/vendor/cloudflare-vite-plugin/README.md +9 -0
- package/vendor/cloudflare-vite-plugin/dist/chunk-U6NEESU5-BmLHqeIt.mjs +43 -0
- package/vendor/cloudflare-vite-plugin/dist/index.d.mts +155 -0
- package/vendor/cloudflare-vite-plugin/dist/index.mjs +94700 -0
- package/vendor/cloudflare-vite-plugin/dist/open-PCXX3ZDZ-DYH87NhH.mjs +530 -0
- package/vendor/cloudflare-vite-plugin/dist/package-4cnqy5mM.mjs +84 -0
- package/vendor/cloudflare-vite-plugin/dist/workers/asset-worker/index.js +5996 -0
- package/vendor/cloudflare-vite-plugin/dist/workers/router-worker/index.js +6414 -0
- package/vendor/cloudflare-vite-plugin/dist/workers/runner-worker/index.js +457 -0
- package/vendor/cloudflare-vite-plugin/dist/workers/runner-worker/module-runner-legacy.js +1129 -0
- package/vendor/cloudflare-vite-plugin/dist/workers/runner-worker/module-runner.js +1259 -0
- package/vendor/cloudflare-vite-plugin/dist/workers/vite-proxy-worker/index.js +31 -0
- package/vendor/cloudflare-vite-plugin/package.json +90 -0
- package/vendor/cloudflare-vite-plugin/provenance.json +26 -0
- package/README.md +0 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// React's completed-component track already checks these bounds. Error and
|
|
2
|
+
// cancellation tracks in React 19.3.1 omit them and can pass a negative end to
|
|
3
|
+
// Performance.measure. Keep the correction in development Flight modules.
|
|
4
|
+
// https://github.com/react/react/pull/37572
|
|
5
|
+
function walk(node: any, visit: (node: any) => void): void {
|
|
6
|
+
if (!node || typeof node !== 'object') return
|
|
7
|
+
if (Array.isArray(node)) { for (const item of node) walk(item, visit); return }
|
|
8
|
+
if (typeof node.type !== 'string') return
|
|
9
|
+
visit(node)
|
|
10
|
+
for (const [key, value] of Object.entries(node)) if (key !== 'parent' && value && typeof value === 'object') walk(value, visit)
|
|
11
|
+
}
|
|
12
|
+
function property(node: any, name: string): any {
|
|
13
|
+
return node?.type === 'ObjectExpression'
|
|
14
|
+
? node.properties.find((entry: any) => (entry.key?.name ?? entry.key?.value) === name)?.value
|
|
15
|
+
: undefined
|
|
16
|
+
}
|
|
17
|
+
export function correctFlightTimings(code: string, id: string, parse: (code: string) => any): string | null {
|
|
18
|
+
if (!/(?:^|[/\\])react-server-dom-webpack-client\.(?:browser|edge|node)\.development\.js$/.test(id.split('?')[0]!)) return null
|
|
19
|
+
const edits: { start: number; end: number; text: string }[] = []
|
|
20
|
+
walk(parse(code), node => {
|
|
21
|
+
if (node.type !== 'IfStatement' || node.test.type !== 'Identifier' || node.test.name !== 'supportsUserTiming') return
|
|
22
|
+
walk(node.consequent, call => {
|
|
23
|
+
if (call.type !== 'CallExpression' || call.callee.type !== 'MemberExpression' ||
|
|
24
|
+
call.callee.object.name !== 'performance' || call.callee.property.name !== 'measure') return
|
|
25
|
+
const options = call.arguments[1]
|
|
26
|
+
const end = property(options, 'end')
|
|
27
|
+
const track = property(property(property(options, 'detail'), 'devtools'), 'track')
|
|
28
|
+
if (end?.type !== 'Identifier' || !/^childrenEndTime(?:\$jscomp\$\d+)?$/.test(end.name) ||
|
|
29
|
+
track?.type !== 'MemberExpression' || track.object.name !== 'trackNames' ||
|
|
30
|
+
track.property.type !== 'Identifier' || !/^trackIdx(?:\$jscomp\$\d+)?$/.test(track.property.name)) return
|
|
31
|
+
edits.push({ start: node.test.start, end: node.test.end, text: `supportsUserTiming && ${end.name} >= 0 && ${track.property.name} < 10` })
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
if (!edits.length) return null
|
|
35
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) code = code.slice(0, edit.start) + edit.text + code.slice(edit.end)
|
|
36
|
+
return code
|
|
37
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { vinextCompatibility } from './compatibility'
|
|
3
|
+
|
|
4
|
+
/** Use Redact in Vinext's browser environment, with native React for SSR and RSC. */
|
|
5
|
+
export function redact(options: { renderer?: 'redact' | 'react' } = {}): any {
|
|
6
|
+
const compatibility = vinextCompatibility()
|
|
7
|
+
const entries: Record<string, string> = {
|
|
8
|
+
react: '../next/react.js',
|
|
9
|
+
'react/jsx-runtime': '../react/jsx-runtime.js',
|
|
10
|
+
'react/jsx-dev-runtime': '../react/jsx-runtime.js',
|
|
11
|
+
'react/compiler-runtime': '../react/compiler-runtime.js',
|
|
12
|
+
'react-dom': '../dom/index.js',
|
|
13
|
+
'react-dom/client': '../next/client.js',
|
|
14
|
+
'react-dom/test-utils': '../dom/test-utils.js',
|
|
15
|
+
scheduler: '../scheduler/index.js',
|
|
16
|
+
}
|
|
17
|
+
const resolved = Object.fromEntries(Object.entries(entries).map(([name, target]) => [name, fileURLToPath(new URL(target, import.meta.url))]))
|
|
18
|
+
return {
|
|
19
|
+
...compatibility,
|
|
20
|
+
name: 'redact:vinext',
|
|
21
|
+
enforce: 'pre',
|
|
22
|
+
configEnvironment: {
|
|
23
|
+
order: 'post',
|
|
24
|
+
handler(name: string, config: any) {
|
|
25
|
+
compatibility.configEnvironment.handler(name, config)
|
|
26
|
+
if (options.renderer === 'react' || (name !== 'client' && config.consumer !== 'client')) return
|
|
27
|
+
config.optimizeDeps = {
|
|
28
|
+
...config.optimizeDeps,
|
|
29
|
+
exclude: [...new Set([...(config.optimizeDeps?.exclude || []), ...Object.keys(entries), '@tanstack/redact'])],
|
|
30
|
+
include: config.optimizeDeps?.include?.filter((id: string) => !entries[id.split('>').pop()!.trim()]),
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
resolveId: {
|
|
35
|
+
order: 'pre',
|
|
36
|
+
handler(this: any, id: string) {
|
|
37
|
+
if (this.environment?.config.consumer !== 'client') return compatibility.resolveHandler(id)
|
|
38
|
+
// Vite aliases are global. Browser React must resolve here so SSR and
|
|
39
|
+
// Flight retain their native React module and export conditions.
|
|
40
|
+
if (options.renderer === 'react') return null
|
|
41
|
+
return resolved[id] ?? null
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default redact
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs'
|
|
2
|
+
import { dirname, resolve as resolvePath } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { adaptReact18 } from './react18'
|
|
5
|
+
|
|
6
|
+
export type RedactPreset = 'nano' | 'full'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Opt-in feature set. Each flag toggles whether the feature's real
|
|
10
|
+
* implementation ships (`true`) or is swapped with a stub module that
|
|
11
|
+
* degrades gracefully (`false`). Missing keys fall back to the preset's
|
|
12
|
+
* default. Adding a feature to this interface propagates to consumer
|
|
13
|
+
* configs as autocompleted options.
|
|
14
|
+
*/
|
|
15
|
+
export interface RedactFeatures {
|
|
16
|
+
/** Activity visibility, retained state and disconnected effects. */
|
|
17
|
+
activity?: boolean
|
|
18
|
+
/** DOM instances, events, focus, layout and observers for Fragment refs. */
|
|
19
|
+
fragmentRefs?: boolean
|
|
20
|
+
/** Experimental native ViewTransition animations. Opt-in until snapshot parity is complete. */
|
|
21
|
+
viewTransitions?: boolean
|
|
22
|
+
/**
|
|
23
|
+
* `createPortal`. When `false`, portal elements render in place as a
|
|
24
|
+
* Fragment (the `container` prop is ignored). `renderPortal` and its
|
|
25
|
+
* deps are stripped from the bundle.
|
|
26
|
+
*/
|
|
27
|
+
portal?: boolean
|
|
28
|
+
/**
|
|
29
|
+
* `createContext` / `useContext` / `<Provider>` / `<Consumer>`. When
|
|
30
|
+
* `false`, Providers render as Fragments (value never propagates),
|
|
31
|
+
* Consumers invoke their function-children with the context's default
|
|
32
|
+
* value, and `useContext` returns the default. Provider-walk logic and
|
|
33
|
+
* `renderProvider` are stripped.
|
|
34
|
+
*/
|
|
35
|
+
context?: boolean
|
|
36
|
+
/**
|
|
37
|
+
* `<Suspense>` boundaries + streaming hydration. When `false`, Suspense
|
|
38
|
+
* elements render as Fragments (children mount inline, `fallback` is
|
|
39
|
+
* ignored). Thrown thenables still schedule a re-render on settle, so
|
|
40
|
+
* eventual consistency works — just no fallback UI during the pending
|
|
41
|
+
* window. Boundary-handler stack and hydration integration are stripped.
|
|
42
|
+
*/
|
|
43
|
+
suspense?: boolean
|
|
44
|
+
/**
|
|
45
|
+
* `React.memo`. When `false`, memoized components still render but without
|
|
46
|
+
* the prop-equality gate — every parent rerender passes through.
|
|
47
|
+
* `shallowEqual` and the force-rerender bypass are stripped.
|
|
48
|
+
*/
|
|
49
|
+
memo?: boolean
|
|
50
|
+
/**
|
|
51
|
+
* `React.forwardRef`. When `false`, forwardRef components still render but
|
|
52
|
+
* the ref prop isn't forwarded to the inner function. React 19+ treats
|
|
53
|
+
* refs as normal props on function components anyway, so most apps can
|
|
54
|
+
* drop this. The dispatcher save/restore machinery is stripped.
|
|
55
|
+
*/
|
|
56
|
+
forwardRef?: boolean
|
|
57
|
+
/**
|
|
58
|
+
* `React.lazy`. When `false`, lazy elements still resolve if their payload
|
|
59
|
+
* is already available synchronously (e.g. pre-awaited RSC Flight); async
|
|
60
|
+
* resolution throws a clear error. The hydration-deferred-reveal path and
|
|
61
|
+
* Suspense coordination are stripped.
|
|
62
|
+
*/
|
|
63
|
+
lazy?: boolean
|
|
64
|
+
/**
|
|
65
|
+
* Class components (`extends Component`). When `false`, class components
|
|
66
|
+
* still render but only honor the core contract: constructor + `render()`
|
|
67
|
+
* + `setState`. Dropped: `contextType`, `getDerivedStateFromProps`,
|
|
68
|
+
* `shouldComponentUpdate`, `componentDidMount`/`Update`/`WillUnmount`,
|
|
69
|
+
* `getDerivedStateFromError`/`componentDidCatch` (error boundaries).
|
|
70
|
+
*/
|
|
71
|
+
classComponents?: boolean
|
|
72
|
+
/**
|
|
73
|
+
* SSR hydration (`hydrateRoot`). When `false`, `hydrateRoot` throws
|
|
74
|
+
* (use `createRoot` for SPAs). The HydrationCursor / DOM adoption /
|
|
75
|
+
* streaming-boundary coordination / event-replay / scroll-guard
|
|
76
|
+
* machinery is stripped — the biggest single chunk of reducible code.
|
|
77
|
+
*/
|
|
78
|
+
hydration?: boolean
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface ResolvedFeatures {
|
|
82
|
+
activity: boolean
|
|
83
|
+
fragmentRefs: boolean
|
|
84
|
+
viewTransitions: boolean
|
|
85
|
+
portal: boolean
|
|
86
|
+
context: boolean
|
|
87
|
+
suspense: boolean
|
|
88
|
+
memo: boolean
|
|
89
|
+
forwardRef: boolean
|
|
90
|
+
lazy: boolean
|
|
91
|
+
classComponents: boolean
|
|
92
|
+
hydration: boolean
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const PRESET_DEFAULTS: Record<RedactPreset, ResolvedFeatures> = {
|
|
96
|
+
// Opt-in: everything off. Turn individual features on via `features`.
|
|
97
|
+
nano: {
|
|
98
|
+
activity: false, fragmentRefs: false, viewTransitions: false,
|
|
99
|
+
portal: false, context: false, suspense: false, memo: false,
|
|
100
|
+
forwardRef: false, lazy: false, classComponents: false, hydration: false,
|
|
101
|
+
},
|
|
102
|
+
// Opt-out: everything on (drop-in React parity). Turn features off via `features`.
|
|
103
|
+
full: {
|
|
104
|
+
activity: true, fragmentRefs: true, viewTransitions: false,
|
|
105
|
+
portal: true, context: true, suspense: true, memo: true,
|
|
106
|
+
forwardRef: true, lazy: true, classComponents: true, hydration: true,
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function resolveFeatures(
|
|
111
|
+
preset: RedactPreset,
|
|
112
|
+
overrides: RedactFeatures,
|
|
113
|
+
): ResolvedFeatures {
|
|
114
|
+
const p = PRESET_DEFAULTS[preset]
|
|
115
|
+
return {
|
|
116
|
+
activity: overrides.activity ?? p.activity,
|
|
117
|
+
fragmentRefs: overrides.fragmentRefs ?? p.fragmentRefs,
|
|
118
|
+
viewTransitions: overrides.viewTransitions ?? p.viewTransitions,
|
|
119
|
+
portal: overrides.portal ?? p.portal,
|
|
120
|
+
context: overrides.context ?? p.context,
|
|
121
|
+
suspense: overrides.suspense ?? p.suspense,
|
|
122
|
+
memo: overrides.memo ?? p.memo,
|
|
123
|
+
forwardRef: overrides.forwardRef ?? p.forwardRef,
|
|
124
|
+
lazy: overrides.lazy ?? p.lazy,
|
|
125
|
+
classComponents: overrides.classComponents ?? p.classComponents,
|
|
126
|
+
hydration: overrides.hydration ?? p.hydration,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface RedactOptions {
|
|
131
|
+
/** Skip aliasing specific specifiers, e.g. if a consumer wants real React somewhere. */
|
|
132
|
+
skip?: ReadonlyArray<string>
|
|
133
|
+
/**
|
|
134
|
+
* Override package resolution root. Defaults to the Vite config root. Useful
|
|
135
|
+
* for monorepos where the plugin lives in a different workspace than the
|
|
136
|
+
* consumer app.
|
|
137
|
+
*/
|
|
138
|
+
resolveFrom?: string
|
|
139
|
+
/**
|
|
140
|
+
* Explicit package roots, bypassing node_modules lookup. Keys are package
|
|
141
|
+
* names (e.g. `@tanstack/redact`), values are absolute paths to the package
|
|
142
|
+
* directory. Handy for cross-workspace testing / bring-your-own-build setups.
|
|
143
|
+
*/
|
|
144
|
+
packageRoots?: Record<string, string>
|
|
145
|
+
/**
|
|
146
|
+
* Starting point for feature selection. `'full'` (default) turns every
|
|
147
|
+
* feature on — drop-in React parity, opt-out individual features via
|
|
148
|
+
* `features`. `'nano'` turns everything off — opt in to what you need.
|
|
149
|
+
*/
|
|
150
|
+
preset?: RedactPreset
|
|
151
|
+
/**
|
|
152
|
+
* Per-feature overrides merged on top of the preset's defaults. Enables
|
|
153
|
+
* fine-grained "preset minus X" or "preset plus Y" configurations.
|
|
154
|
+
*/
|
|
155
|
+
features?: RedactFeatures
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Alias map. ORDER MATTERS — Vite's alias matcher uses first-match against
|
|
159
|
+
// prefix, so more-specific specifiers MUST come before less-specific ones.
|
|
160
|
+
// Without this, `react-dom/server` would prefix-match `react-dom` first and
|
|
161
|
+
// resolve to `@tanstack/redact/dom/server` (wrong) instead of
|
|
162
|
+
// `@tanstack/redact/server`.
|
|
163
|
+
//
|
|
164
|
+
// `use-sync-external-store` aliases are here because its CJS-only React 17
|
|
165
|
+
// compat shim does `var React = require('react')`. That survives Vite's
|
|
166
|
+
// pre-bundling intact and explodes in Cloudflare Workers (no `require`).
|
|
167
|
+
// Modern React has `useSyncExternalStore` built-in, and `@tanstack/redact`
|
|
168
|
+
// additionally exports `useSyncExternalStoreWithSelector` so this alias
|
|
169
|
+
// is safe everywhere.
|
|
170
|
+
const ALIASES: Record<string, string> = {
|
|
171
|
+
// ---- most-specific first ----
|
|
172
|
+
'use-sync-external-store/shim/with-selector': '@tanstack/redact',
|
|
173
|
+
'use-sync-external-store/shim/with-selector.js': '@tanstack/redact',
|
|
174
|
+
'use-sync-external-store/with-selector': '@tanstack/redact',
|
|
175
|
+
'use-sync-external-store/with-selector.js': '@tanstack/redact',
|
|
176
|
+
// Explicit file subpaths (react-aria imports `shim/index.js`). Without these,
|
|
177
|
+
// dev resolves the raw CJS shim and its named ESM import fails.
|
|
178
|
+
'use-sync-external-store/shim/index.js': '@tanstack/redact',
|
|
179
|
+
'use-sync-external-store/index.js': '@tanstack/redact',
|
|
180
|
+
'use-sync-external-store/shim': '@tanstack/redact',
|
|
181
|
+
'use-sync-external-store': '@tanstack/redact',
|
|
182
|
+
|
|
183
|
+
// React drop-in shim targets. Subpaths first.
|
|
184
|
+
'react/jsx-runtime': '@tanstack/redact/jsx-runtime',
|
|
185
|
+
'react/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',
|
|
186
|
+
'react/compiler-runtime': '@tanstack/redact/compiler-runtime',
|
|
187
|
+
'react-dom/client': '@tanstack/redact/dom-client',
|
|
188
|
+
'react-dom/server.browser': '@tanstack/redact/server',
|
|
189
|
+
'react-dom/server.bun': '@tanstack/redact/server',
|
|
190
|
+
'react-dom/server.edge': '@tanstack/redact/server',
|
|
191
|
+
'react-dom/server.node': '@tanstack/redact/server',
|
|
192
|
+
'react-dom/static.edge': '@tanstack/redact/server',
|
|
193
|
+
'react-dom/server': '@tanstack/redact/server',
|
|
194
|
+
'react-dom/test-utils': '@tanstack/redact/dom-test-utils',
|
|
195
|
+
'react-dom': '@tanstack/redact/dom',
|
|
196
|
+
react: '@tanstack/redact',
|
|
197
|
+
scheduler: '@tanstack/redact/scheduler',
|
|
198
|
+
|
|
199
|
+
// Self-aliases so Vite resolves `@tanstack/redact/*` imports to the same
|
|
200
|
+
// canonical file path no matter where they originate (worker bundle vs
|
|
201
|
+
// deps_ssr pre-bundle vs source). Without these, Cloudflare's
|
|
202
|
+
// `noExternal: true` worker config inlines one copy while Vite's
|
|
203
|
+
// optimizeDeps pre-bundles another, ending up with two separate
|
|
204
|
+
// ReactSharedInternals instances and a null dispatcher in user hooks.
|
|
205
|
+
// Subpaths first here too.
|
|
206
|
+
'@tanstack/redact/jsx-runtime': '@tanstack/redact/jsx-runtime',
|
|
207
|
+
'@tanstack/redact/jsx-dev-runtime': '@tanstack/redact/jsx-dev-runtime',
|
|
208
|
+
'@tanstack/redact/compiler-runtime': '@tanstack/redact/compiler-runtime',
|
|
209
|
+
'@tanstack/redact/dom-client': '@tanstack/redact/dom-client',
|
|
210
|
+
'@tanstack/redact/dom-test-utils': '@tanstack/redact/dom-test-utils',
|
|
211
|
+
'@tanstack/redact/server': '@tanstack/redact/server',
|
|
212
|
+
'@tanstack/redact/scheduler': '@tanstack/redact/scheduler',
|
|
213
|
+
'@tanstack/redact/dom': '@tanstack/redact/dom',
|
|
214
|
+
'@tanstack/redact': '@tanstack/redact',
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function splitSpecifier(specifier: string): { pkg: string; sub: string } {
|
|
218
|
+
if (specifier.startsWith('@')) {
|
|
219
|
+
const slash1 = specifier.indexOf('/')
|
|
220
|
+
const slash2 = specifier.indexOf('/', slash1 + 1)
|
|
221
|
+
if (slash2 < 0) return { pkg: specifier, sub: '' }
|
|
222
|
+
return { pkg: specifier.slice(0, slash2), sub: specifier.slice(slash2 + 1) }
|
|
223
|
+
}
|
|
224
|
+
const slash = specifier.indexOf('/')
|
|
225
|
+
if (slash < 0) return { pkg: specifier, sub: '' }
|
|
226
|
+
return { pkg: specifier.slice(0, slash), sub: specifier.slice(slash + 1) }
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function findPackageDir(pkg: string, fromDir: string): string | null {
|
|
230
|
+
let dir = fromDir
|
|
231
|
+
while (true) {
|
|
232
|
+
const candidate = resolvePath(dir, 'node_modules', pkg)
|
|
233
|
+
if (existsSync(resolvePath(candidate, 'package.json'))) return candidate
|
|
234
|
+
const parent = dirname(dir)
|
|
235
|
+
if (parent === dir) return null
|
|
236
|
+
dir = parent
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function resolveExport(packageDir: string, sub: string): string | null {
|
|
241
|
+
const pkgJsonPath = resolvePath(packageDir, 'package.json')
|
|
242
|
+
let pkg: any
|
|
243
|
+
try {
|
|
244
|
+
pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf8'))
|
|
245
|
+
} catch {
|
|
246
|
+
return null
|
|
247
|
+
}
|
|
248
|
+
const key = sub ? './' + sub : '.'
|
|
249
|
+
const exp = pkg.exports?.[key]
|
|
250
|
+
// Prefer published JavaScript over TypeScript sources. Dist preserves one
|
|
251
|
+
// file per module, so subpath imports share state and feature boundaries.
|
|
252
|
+
const pick = (v: any): string | null => {
|
|
253
|
+
if (typeof v === 'string') return v
|
|
254
|
+
if (v && typeof v === 'object') {
|
|
255
|
+
return pick(v.import ?? v.module ?? v.source ?? v.default ?? null)
|
|
256
|
+
}
|
|
257
|
+
return null
|
|
258
|
+
}
|
|
259
|
+
const target = pick(exp)
|
|
260
|
+
if (target) return resolvePath(packageDir, target)
|
|
261
|
+
if (!sub) {
|
|
262
|
+
const main = pkg.module ?? pkg.main
|
|
263
|
+
if (typeof main === 'string') return resolvePath(packageDir, main)
|
|
264
|
+
}
|
|
265
|
+
return null
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// When installed from npm, `@tanstack/redact` is declared as a `dependency`
|
|
269
|
+
// of consumer apps. Under pnpm's strict mode it ends up nested under the
|
|
270
|
+
// plugin's own `.pnpm/@tanstack+redact@.../node_modules/` rather than
|
|
271
|
+
// hoisted to the consumer's root, so a `findPackageDir` walk starting at
|
|
272
|
+
// the Vite project root won't always find it. Search from the plugin's own
|
|
273
|
+
// directory first (which walks into its nested node_modules), then fall
|
|
274
|
+
// back to the consumer root for hoisted installs.
|
|
275
|
+
const pluginDir = dirname(fileURLToPath(import.meta.url))
|
|
276
|
+
|
|
277
|
+
function resolveSpecifier(
|
|
278
|
+
specifier: string,
|
|
279
|
+
fromDir: string,
|
|
280
|
+
packageRoots: Record<string, string>,
|
|
281
|
+
): string | null {
|
|
282
|
+
const { pkg, sub } = splitSpecifier(specifier)
|
|
283
|
+
const packageDir =
|
|
284
|
+
packageRoots[pkg] ??
|
|
285
|
+
findPackageDir(pkg, pluginDir) ??
|
|
286
|
+
findPackageDir(pkg, fromDir)
|
|
287
|
+
if (!packageDir) return null
|
|
288
|
+
const target = resolveExport(packageDir, sub)
|
|
289
|
+
if (!target) return null
|
|
290
|
+
// Canonicalize through pnpm symlinks. Under strict pnpm, the package may
|
|
291
|
+
// live nested under `.pnpm/@tanstack+redact@.../node_modules/*`, but each
|
|
292
|
+
// of those is itself a symlink to the flat `.pnpm/@tanstack+redact@.../`
|
|
293
|
+
// entry. Vite's `fetchModule` (used by TanStack Start's server-fn
|
|
294
|
+
// compiler) follows the realpath, so the id seen by the capture-transform
|
|
295
|
+
// differs from the nested id we'd return. That leaves the compiler's
|
|
296
|
+
// moduleCache keyed on the realpath while `getModuleInfo` looks up the
|
|
297
|
+
// nested path → miss → "could not load module info". Returning the
|
|
298
|
+
// canonical realpath here keeps the two sides in agreement.
|
|
299
|
+
try {
|
|
300
|
+
return realpathSync(target)
|
|
301
|
+
} catch {
|
|
302
|
+
return target
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface OptimizeDepsWithInclude {
|
|
307
|
+
include?: Array<string>
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function pruneOptimizeDepsInclude(
|
|
311
|
+
optimizeDeps: OptimizeDepsWithInclude | undefined,
|
|
312
|
+
blocked: ReadonlySet<string>,
|
|
313
|
+
): void {
|
|
314
|
+
if (!optimizeDeps?.include) return
|
|
315
|
+
|
|
316
|
+
optimizeDeps.include = optimizeDeps.include.filter((id) => {
|
|
317
|
+
const tailSpecifier = id.split('>').pop()?.trim() ?? id
|
|
318
|
+
return !blocked.has(id) && !blocked.has(tailSpecifier)
|
|
319
|
+
})
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export function redact(options: RedactOptions = {}): any {
|
|
323
|
+
const skip = new Set(options.skip ?? [])
|
|
324
|
+
const entries = Object.entries(ALIASES).filter(([k]) => !skip.has(k))
|
|
325
|
+
const excludeList = entries.map(([k]) => k)
|
|
326
|
+
const optimizeDepsBlocked = new Set(excludeList)
|
|
327
|
+
const features = resolveFeatures(options.preset ?? 'full', options.features ?? {})
|
|
328
|
+
|
|
329
|
+
const resolvedMap: Record<string, string> = {}
|
|
330
|
+
let done = false
|
|
331
|
+
let react18Version: string | undefined
|
|
332
|
+
let runtimeRoot: string | undefined
|
|
333
|
+
|
|
334
|
+
function resolveAll(root: string): void {
|
|
335
|
+
if (done) return
|
|
336
|
+
const fromDir = options.resolveFrom ?? root
|
|
337
|
+
const packageRoots = options.packageRoots ?? {}
|
|
338
|
+
for (const [from, to] of entries) {
|
|
339
|
+
const resolved = resolveSpecifier(to, fromDir, packageRoots)
|
|
340
|
+
if (resolved) resolvedMap[from] = resolved
|
|
341
|
+
}
|
|
342
|
+
done = true
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return [{
|
|
346
|
+
name: 'redact',
|
|
347
|
+
enforce: 'pre',
|
|
348
|
+
|
|
349
|
+
config() {
|
|
350
|
+
// Single package — only one name to dedupe / no-external.
|
|
351
|
+
const noExt = ['@tanstack/redact']
|
|
352
|
+
const aliasMap = Object.fromEntries(entries.filter(([from, to]) => from !== to))
|
|
353
|
+
// Dedupe `@tanstack/redact` so Vite resolves it to a single instance
|
|
354
|
+
// even when multiple packages (e.g. @tanstack/react-router and user
|
|
355
|
+
// code) drag it into different parts of the module graph.
|
|
356
|
+
const dedupe = noExt
|
|
357
|
+
// Scope `resolve.alias` to client + ssr environments ONLY. Do NOT set
|
|
358
|
+
// a top-level alias: it would apply to the `rsc` environment too,
|
|
359
|
+
// where `@vitejs/plugin-rsc`'s vendored `react-server-dom-server`
|
|
360
|
+
// imports `react` and needs the *real* React (with the `.d` field on
|
|
361
|
+
// ReactSharedInternals that our shim deliberately doesn't have).
|
|
362
|
+
// Aliasing `react` → `@tanstack/redact` in the RSC env crashes Flight
|
|
363
|
+
// serialization. The Cloudflare vite-plugin's rolldown worker-runner
|
|
364
|
+
// also pre-scans bare specifiers via Vite's alias map (not plugin
|
|
365
|
+
// hooks), but it scans within the *ssr* environment specifically —
|
|
366
|
+
// so per-env `environments.ssr.resolve.alias` covers it. The
|
|
367
|
+
// `enforce: 'pre'` resolveId hook below already skips RSC, so the
|
|
368
|
+
// remaining concern is alias placement. Object form is required —
|
|
369
|
+
// array form is silently ignored by rolldown's worker-runner.
|
|
370
|
+
return {
|
|
371
|
+
environments: {
|
|
372
|
+
client: {
|
|
373
|
+
optimizeDeps: { exclude: excludeList },
|
|
374
|
+
resolve: { alias: aliasMap, dedupe },
|
|
375
|
+
},
|
|
376
|
+
ssr: {
|
|
377
|
+
optimizeDeps: { exclude: excludeList },
|
|
378
|
+
resolve: { alias: aliasMap, dedupe, noExternal: noExt },
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
ssr: { noExternal: noExt },
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
|
|
385
|
+
configResolved(config: any) {
|
|
386
|
+
resolveAll(config.root)
|
|
387
|
+
const reactDir = findPackageDir('react', options.resolveFrom ?? config.root)
|
|
388
|
+
if (reactDir) {
|
|
389
|
+
const installedVersion = JSON.parse(readFileSync(resolvePath(reactDir, 'package.json'), 'utf8')).version
|
|
390
|
+
if (/^18\./.test(installedVersion)) react18Version = installedVersion
|
|
391
|
+
}
|
|
392
|
+
if (resolvedMap.react) {
|
|
393
|
+
runtimeRoot = resolvePath(dirname(resolvedMap.react), '..').replaceAll('\\', '/') + '/'
|
|
394
|
+
}
|
|
395
|
+
// With `packageRoots`, package sources live outside the consumer's Vite
|
|
396
|
+
// project root, so the default server.fs.allow list blocks them. Append
|
|
397
|
+
// to the resolved allow list rather than replacing via `config()`, so we
|
|
398
|
+
// keep Vite's defaults (root + node_modules + client runtime).
|
|
399
|
+
const fsAllow = Object.values(options.packageRoots ?? {})
|
|
400
|
+
if (fsAllow.length && config.server?.fs?.allow) {
|
|
401
|
+
for (const p of fsAllow) {
|
|
402
|
+
if (!config.server.fs.allow.includes(p)) {
|
|
403
|
+
config.server.fs.allow.push(p)
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
|
|
409
|
+
async resolveId(this: any, id: string, importer?: string, opts?: any) {
|
|
410
|
+
// Skip the RSC environment — it relies on real React internals via
|
|
411
|
+
// @vitejs/plugin-rsc's vendored react-server-dom. Substituting our
|
|
412
|
+
// shim there breaks Flight serialization. Client + SSR envs still swap.
|
|
413
|
+
const envName = this?.environment?.name
|
|
414
|
+
if (envName === 'rsc') return null
|
|
415
|
+
|
|
416
|
+
// Feature-flag swap: when the reconciler's `features/index` module
|
|
417
|
+
// imports a feature by relative path, redirect to that feature's stub
|
|
418
|
+
// if the flag is off. The stub registers a graceful-degradation
|
|
419
|
+
// matcher (e.g. Portal → Fragment) so user code keeps working.
|
|
420
|
+
if (importer && /[\\/]features[\\/]index\.[jt]sx?$/.test(importer)) {
|
|
421
|
+
const m = id.match(/^\.\/([a-z-]+)(\/index\.js)?$/)
|
|
422
|
+
if (m) {
|
|
423
|
+
const dir = m[1]!
|
|
424
|
+
const name = (dir === 'forward-ref' ? 'forwardRef' : dir === 'fragment-refs' ? 'fragmentRefs' : dir === 'view-transition' ? 'viewTransitions' : dir === 'class' ? 'classComponents' : dir) as keyof ResolvedFeatures
|
|
425
|
+
if (name in features && !features[name]) {
|
|
426
|
+
const r = await this.resolve(`./${dir}/stub${m[2] ? '.js' : ''}`, importer, {
|
|
427
|
+
...opts,
|
|
428
|
+
skipSelf: true,
|
|
429
|
+
})
|
|
430
|
+
if (r) return r.id
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Peer imports must use the same feature selection as the registration
|
|
436
|
+
// entrypoint, or an enabled feature can bring a disabled one back in.
|
|
437
|
+
const peer = id.match(/[\\/](context|hydration|fragment-refs|view-transition|class|suspense-runtime)(?:[\\/]index\.js)?$/)
|
|
438
|
+
const peerKey = peer?.[1] === 'suspense-runtime' ? 'suspense' : peer?.[1] === 'fragment-refs' ? 'fragmentRefs' : peer?.[1] === 'view-transition' ? 'viewTransitions' : peer?.[1] === 'class' ? 'classComponents' : peer?.[1] as 'context' | 'hydration' | undefined
|
|
439
|
+
if (importer && peer && peerKey && !features[peerKey]) {
|
|
440
|
+
const r = await this.resolve(id, importer, { ...opts, skipSelf: true })
|
|
441
|
+
const resolvedFeature = r?.id.match(/features[\\/](context|hydration|fragment-refs|view-transition|class|suspense-runtime)[\\/]index\.(ts|js)$/)
|
|
442
|
+
if (resolvedFeature?.[1] === peer[1]) {
|
|
443
|
+
return r.id.replace(/index\.(ts|js)$/, 'stub.$1')
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return resolvedMap[id] ?? null
|
|
448
|
+
},
|
|
449
|
+
}, {
|
|
450
|
+
name: 'redact:react18',
|
|
451
|
+
enforce: 'post',
|
|
452
|
+
transform(this: any, code: string, id: string) {
|
|
453
|
+
if (!react18Version || !runtimeRoot || this?.environment?.name === 'rsc') return null
|
|
454
|
+
const path = id.split('?')[0]!.replaceAll('\\', '/')
|
|
455
|
+
if (!path.startsWith(runtimeRoot)) return null
|
|
456
|
+
const module = path.slice(runtimeRoot.length).replace(/\.[jt]s$/, '')
|
|
457
|
+
return adaptReact18(code, id, module, react18Version, (source) => this.parse(source))
|
|
458
|
+
},
|
|
459
|
+
}, {
|
|
460
|
+
name: 'redact:optimize-deps-guard',
|
|
461
|
+
enforce: 'post',
|
|
462
|
+
|
|
463
|
+
configResolved(config: any) {
|
|
464
|
+
// `optimizeDeps.exclude` loses when another plugin force-adds the same
|
|
465
|
+
// ids to `include`. That lets Vite pre-bundle real React next to Redact,
|
|
466
|
+
// producing duplicate dispatcher state. Prune after config settles so
|
|
467
|
+
// Redact's client/SSR shims stay canonical.
|
|
468
|
+
pruneOptimizeDepsInclude(config.optimizeDeps, optimizeDepsBlocked)
|
|
469
|
+
pruneOptimizeDepsInclude(config.environments?.client?.optimizeDeps, optimizeDepsBlocked)
|
|
470
|
+
pruneOptimizeDepsInclude(config.environments?.ssr?.optimizeDeps, optimizeDepsBlocked)
|
|
471
|
+
// Leave `environments.rsc` untouched. RSC depends on real React internals.
|
|
472
|
+
},
|
|
473
|
+
}]
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
export default redact
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import MagicString from 'magic-string'
|
|
2
|
+
|
|
3
|
+
// Only these owned modules differ between React's public element protocols.
|
|
4
|
+
// Run after Vite's TypeScript transform, before bundling and minification.
|
|
5
|
+
const editsPerModule: Record<string, number> = {
|
|
6
|
+
'core/types': 1,
|
|
7
|
+
'react/context': 2,
|
|
8
|
+
'react/index': 2,
|
|
9
|
+
'dom/index': 2,
|
|
10
|
+
'dom/features/context/full': 1,
|
|
11
|
+
'dom/features/context/stub': 1,
|
|
12
|
+
'server/walk': 1,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function adaptReact18(code: string, id: string, module: string, version: string, parse: (code: string) => any) {
|
|
16
|
+
const expected = editsPerModule[module]
|
|
17
|
+
if (!expected) return null
|
|
18
|
+
const output = new MagicString(code)
|
|
19
|
+
let edits = 0
|
|
20
|
+
function visit(node: any): void {
|
|
21
|
+
if (!node || typeof node !== 'object') return
|
|
22
|
+
let replacement: string | undefined
|
|
23
|
+
if (node.type === 'Literal') {
|
|
24
|
+
if (module === 'core/types' && node.value === 'react.transitional.element') replacement = JSON.stringify('react.element')
|
|
25
|
+
}
|
|
26
|
+
if ((module === 'react/index' || module === 'dom/index')
|
|
27
|
+
&& ((node.type === 'VariableDeclarator' && node.id?.name === 'version')
|
|
28
|
+
|| (node.type === 'Property' && node.key?.name === 'version'))) {
|
|
29
|
+
const value = node.init ?? node.value
|
|
30
|
+
if (value?.type === 'Literal' && typeof value.value === 'string') {
|
|
31
|
+
output.overwrite(value.start, value.end, JSON.stringify(version))
|
|
32
|
+
edits++
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (module === 'react/context' && node.type === 'CallExpression'
|
|
37
|
+
&& node.callee?.object?.name === 'Symbol' && node.callee?.property?.name === 'for'
|
|
38
|
+
&& node.arguments?.[0]?.value === 'react.consumer') replacement = 'REACT_CONTEXT_TYPE'
|
|
39
|
+
if (module === 'react/context' && node.type === 'FunctionDeclaration' && node.id?.name === 'createContext') {
|
|
40
|
+
if (node.params?.[0]?.name !== 'defaultValue') throw new Error('React 18 adaptation failed: createContext signature changed')
|
|
41
|
+
// React 18 consumers are context objects, not callable components.
|
|
42
|
+
output.overwrite(node.body.start, node.body.end, `{
|
|
43
|
+
const context = { $$typeof: REACT_CONTEXT_TYPE, _currentValue: defaultValue };
|
|
44
|
+
context.Provider = { $$typeof: REACT_PROVIDER_TYPE, _context: context };
|
|
45
|
+
context.Consumer = context._context = context;
|
|
46
|
+
return context;
|
|
47
|
+
}`)
|
|
48
|
+
edits++
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
// React 18 uses react.context for consumers, not providers.
|
|
52
|
+
if ((module.startsWith('dom/features/context/') || module === 'server/walk')
|
|
53
|
+
&& node.type === 'BinaryExpression' && node.operator === '==='
|
|
54
|
+
&& node.left?.name === 'marker' && node.right?.name === 'REACT_CONTEXT_TYPE') {
|
|
55
|
+
replacement = 'false'
|
|
56
|
+
}
|
|
57
|
+
if (replacement !== undefined) {
|
|
58
|
+
// A pure-call annotation no longer applies when a call becomes a symbol.
|
|
59
|
+
for (const annotation of node._rollupAnnotations ?? []) {
|
|
60
|
+
if (annotation.type === 'pure') output.remove(annotation.start, annotation.end)
|
|
61
|
+
}
|
|
62
|
+
output.overwrite(node.start, node.end, replacement)
|
|
63
|
+
edits++
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
for (const value of Object.values(node)) {
|
|
67
|
+
if (Array.isArray(value)) value.forEach(visit)
|
|
68
|
+
else if (value && typeof value === 'object') visit(value)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
visit(parse(code))
|
|
72
|
+
if (edits !== expected) throw new Error(`React 18 adaptation failed for ${module}: expected ${expected} protocol edits, found ${edits}`)
|
|
73
|
+
return { code: output.toString(), map: output.generateMap({ source: id, includeContent: true, hires: true }) }
|
|
74
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Copyright (c) 2020 Cloudflare, Inc. <wrangler@cloudflare.com>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any
|
|
4
|
+
person obtaining a copy of this software and associated
|
|
5
|
+
documentation files (the "Software"), to deal in the
|
|
6
|
+
Software without restriction, including without
|
|
7
|
+
limitation the rights to use, copy, modify, merge,
|
|
8
|
+
publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software
|
|
10
|
+
is furnished to do so, subject to the following
|
|
11
|
+
conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice
|
|
14
|
+
shall be included in all copies or substantial portions
|
|
15
|
+
of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
18
|
+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
20
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
21
|
+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
22
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
24
|
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
25
|
+
DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Cloudflare Vite integration
|
|
2
|
+
|
|
3
|
+
This directory contains the published `@cloudflare/vite-plugin@1.65.0` distribution, with one maintained correction to the development module runner. Indirect `eval` uses the evaluator already provided to that runner, before application modules initialize. Production Workers retain their original evaluation restriction.
|
|
4
|
+
|
|
5
|
+
The original MIT license is in `LICENSE`. `provenance.json` records every source file hash and the upstream fix. `scripts/vendor-cloudflare.mjs` reproduces this distribution from the pinned npm tarball. The build verifies its contents before packaging.
|
|
6
|
+
|
|
7
|
+
`@tanstack/redact/cloudflare` loads this copy using the installed Cloudflare plugin's dependency graph. It requires that exact peer version and scopes dependency resolution to this directory. Other modules use their original resolution. The application must resolve Miniflare's Undici dependency to the fixed version, currently `7.30.1`.
|
|
8
|
+
|
|
9
|
+
This is Node and Worker tooling. It is not imported by any Redact browser runtime entry.
|