@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,476 @@
|
|
|
1
|
+
import { invokeCommit } from './reconcile';
|
|
2
|
+
import { isFunction } from '../core/functions';
|
|
3
|
+
import { scheduleUpdate, enqueueEffect, readContext, rememberActivityEffect, disposeCleanup, handleCommitError, findRoot } from './reconcile';
|
|
4
|
+
import { p as deferTransitionPassive } from './features/view-transition';
|
|
5
|
+
import { readThenable } from '../react/thenable';
|
|
6
|
+
import type { Hook, Fiber, FiberRoot, Effect, ReactNode } from '../core';
|
|
7
|
+
import { reactId } from './features/hydration';
|
|
8
|
+
import { ReactSharedInternals, REACT_CONTEXT_TYPE } from '../react';
|
|
9
|
+
import { runAction, trackAction, withinAction, type ActionScope } from '../react/action-scope';
|
|
10
|
+
import { REACT_RECOVERABLE_TYPE } from '../core/browser';
|
|
11
|
+
import { isRefreshing, finishRefresh, resolveRefreshType } from './refresh';
|
|
12
|
+
import { formState, idleFormStatus, actionInitialState } from '../react/form-state';
|
|
13
|
+
import { transitionScope } from '../react/hooks';
|
|
14
|
+
import { queueCommitEffects } from './commit';
|
|
15
|
+
import { q as queueTransition, r as reduceTransition, v as deferValue } from './features/suspense-runtime';
|
|
16
|
+
import { devToolsDispatcher, wrapDevToolsRender } from './devtools';
|
|
17
|
+
// The renderer owns action lifetimes, including calls through another copy
|
|
18
|
+
// of the public React API that shares these internals.
|
|
19
|
+
ReactSharedInternals.X = action => {
|
|
20
|
+
const scope = runAction(action);
|
|
21
|
+
return scope.d.then(() => {
|
|
22
|
+
if (scope.f && !scope.h)
|
|
23
|
+
throw scope.e;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export function cleanupEffect(hook: Hook, fiber: Fiber): void {
|
|
27
|
+
if (!hook.c)
|
|
28
|
+
return;
|
|
29
|
+
const cleanup = hook.c;
|
|
30
|
+
hook.c = null;
|
|
31
|
+
disposeCleanup(fiber, cleanup);
|
|
32
|
+
}
|
|
33
|
+
function hookValue(hook: Hook, value: any): any {
|
|
34
|
+
if (!Object.is(hook.s, value))
|
|
35
|
+
hookFlags |= 1;
|
|
36
|
+
return hook.s = value;
|
|
37
|
+
}
|
|
38
|
+
function initializeReducer(hook: Hook, fiber: Fiber, initialArg: any, init: ((arg: any) => any) | undefined, eager: boolean): void {
|
|
39
|
+
hook.d = hook.s = init ? init(initialArg) : initialArg;
|
|
40
|
+
hook.q = (action: any) => {
|
|
41
|
+
if (fiber.u || fiber.pd)
|
|
42
|
+
return;
|
|
43
|
+
if (queueTransition?.(hook, fiber, action))
|
|
44
|
+
return;
|
|
45
|
+
if (eager && ReactSharedInternals.F !== fiber && !hook.c) {
|
|
46
|
+
try {
|
|
47
|
+
const next = basicReducer(hook.s, action);
|
|
48
|
+
if (Object.is(next, hook.s))
|
|
49
|
+
return;
|
|
50
|
+
hook.s = next;
|
|
51
|
+
hook.c = 0;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
hook.c = [action];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else
|
|
58
|
+
(hook.c ||= []).push(action);
|
|
59
|
+
scheduleUpdate(fiber);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
type BasicStateAction<S> = S | ((p: S) => S);
|
|
63
|
+
// Reducer slots reuse the effect-cleanup field for pending actions. Zero marks
|
|
64
|
+
// eager state work, null means no update. Replacing arrays lets retries restore
|
|
65
|
+
// pending actions without copying or shifting them.
|
|
66
|
+
// State and reducer slots keep their last rendered value in d, even undefined.
|
|
67
|
+
const initialState = (value: any): any => (isFunction(value) ? value() : value);
|
|
68
|
+
function getCurrentFiber(): Fiber {
|
|
69
|
+
const f = ReactSharedInternals.F;
|
|
70
|
+
if (!f) {
|
|
71
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
72
|
+
throw new Error('Hook called outside a function component render.');
|
|
73
|
+
}
|
|
74
|
+
throw new Error();
|
|
75
|
+
}
|
|
76
|
+
return f;
|
|
77
|
+
}
|
|
78
|
+
let hookEffects: any[] | undefined;
|
|
79
|
+
// Bit 1 records a changed value; bit 2 records a processed reducer queue.
|
|
80
|
+
let hookFlags = 0;
|
|
81
|
+
export const HOOK_BAILOUT = Symbol();
|
|
82
|
+
function nextHook(): Hook {
|
|
83
|
+
const hooks = getCurrentFiber().h ||= [];
|
|
84
|
+
const index = ReactSharedInternals.I++;
|
|
85
|
+
return hooks[index] ||= { s: undefined, q: undefined, d: undefined, c: undefined };
|
|
86
|
+
}
|
|
87
|
+
export function renderWithHooks(fiber: Fiber, render: (props: any, ref?: any) => ReactNode, props: any, ref?: any, canBail?: boolean): ReactNode | typeof HOOK_BAILOUT {
|
|
88
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
89
|
+
render = resolveRefreshType(render);
|
|
90
|
+
if (isRefreshing(fiber))
|
|
91
|
+
canBail = false;
|
|
92
|
+
}
|
|
93
|
+
const previousDispatcher = ReactSharedInternals.H, previousFiber = ReactSharedInternals.F, previousIndex = ReactSharedInternals.I;
|
|
94
|
+
if (process.env.NODE_ENV !== 'production') render = wrapDevToolsRender(render);
|
|
95
|
+
const previousEffects = hookEffects, previousFlags = hookFlags;
|
|
96
|
+
hookEffects = undefined;
|
|
97
|
+
hookFlags = 0;
|
|
98
|
+
ReactSharedInternals.H = DISPATCHER;
|
|
99
|
+
ReactSharedInternals.F = fiber;
|
|
100
|
+
try {
|
|
101
|
+
let rendered: ReactNode, attempts = 0;
|
|
102
|
+
do {
|
|
103
|
+
if (++attempts > 25)
|
|
104
|
+
throw new Error(process.env.NODE_ENV !== 'production' ? 'Too many re-renders.' : '');
|
|
105
|
+
if (hookEffects) {
|
|
106
|
+
resetHookEffects(hookEffects);
|
|
107
|
+
hookEffects = undefined;
|
|
108
|
+
}
|
|
109
|
+
if (fiber.r?.ri)
|
|
110
|
+
fiber.il = 0;
|
|
111
|
+
ReactSharedInternals.I = 0;
|
|
112
|
+
if (process.env.NODE_ENV !== 'production') ReactSharedInternals.H = devToolsDispatcher(fiber, DISPATCHER);
|
|
113
|
+
fiber.g = false;
|
|
114
|
+
rendered = render(props, ref);
|
|
115
|
+
} while (fiber.g);
|
|
116
|
+
if (canBail && hookFlags === 2) {
|
|
117
|
+
// React accepts the rendered dependencies on a reducer bailout, but
|
|
118
|
+
// keeps the previous committed effect descriptions until real work.
|
|
119
|
+
hookEffects = undefined;
|
|
120
|
+
return HOOK_BAILOUT;
|
|
121
|
+
}
|
|
122
|
+
if (hookEffects) {
|
|
123
|
+
const effects: any[] = hookEffects;
|
|
124
|
+
for (let index = 0; index < effects.length; index += 4) {
|
|
125
|
+
const hook = effects[index], effect = effects[index + 2];
|
|
126
|
+
rememberActivityEffect(fiber, hook, effect);
|
|
127
|
+
if (effects[index + 3])
|
|
128
|
+
enqueueEffect(fiber, effect);
|
|
129
|
+
}
|
|
130
|
+
hookEffects = undefined;
|
|
131
|
+
}
|
|
132
|
+
if (process.env.NODE_ENV !== 'production')
|
|
133
|
+
finishRefresh(fiber);
|
|
134
|
+
return rendered;
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
if (hookEffects)
|
|
138
|
+
resetHookEffects(hookEffects);
|
|
139
|
+
hookEffects = previousEffects;
|
|
140
|
+
hookFlags = previousFlags;
|
|
141
|
+
ReactSharedInternals.H = previousDispatcher;
|
|
142
|
+
ReactSharedInternals.F = previousFiber;
|
|
143
|
+
ReactSharedInternals.I = previousIndex;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function useEffectImpl(type: Effect['t'], create: () => any, deps?: ReadonlyArray<unknown>, subscription?: boolean): void {
|
|
147
|
+
const hook = nextHook();
|
|
148
|
+
const fiber = getCurrentFiber();
|
|
149
|
+
const changed = hook.d === undefined || !depsEqual(hook.d, deps);
|
|
150
|
+
if (!changed && !fiber.r?.a && !(type === 1 && !subscription && fiber.r?.sp))
|
|
151
|
+
return;
|
|
152
|
+
const previous = hook.d;
|
|
153
|
+
hook.d = deps;
|
|
154
|
+
const effect: Effect = {
|
|
155
|
+
t: type,
|
|
156
|
+
s: subscription,
|
|
157
|
+
c: () => {
|
|
158
|
+
cleanupEffect(hook, fiber);
|
|
159
|
+
const cleanup = create();
|
|
160
|
+
// Each effect owns its cleanup even when hooks return the same function.
|
|
161
|
+
hook.c = isFunction(cleanup) ? () => {
|
|
162
|
+
if (type === 0) {
|
|
163
|
+
const dispose = () => invokeCommit(fiber, cleanup);
|
|
164
|
+
if (!(deferTransitionPassive && deferTransitionPassive(dispose)))
|
|
165
|
+
queueCommitEffects(dispose);
|
|
166
|
+
}
|
|
167
|
+
else
|
|
168
|
+
cleanup();
|
|
169
|
+
} : null;
|
|
170
|
+
return hook.c;
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
if (type !== 2 && !subscription)
|
|
174
|
+
effect.d = () => cleanupEffect(hook, fiber);
|
|
175
|
+
(hookEffects ||= []).push(hook, previous, effect, changed);
|
|
176
|
+
}
|
|
177
|
+
function depsEqual(a: ReadonlyArray<unknown> | undefined, b: ReadonlyArray<unknown> | undefined): boolean {
|
|
178
|
+
if (process.env.NODE_ENV !== 'production' && isRefreshing(ReactSharedInternals.F))
|
|
179
|
+
return false;
|
|
180
|
+
if (a === b)
|
|
181
|
+
return true;
|
|
182
|
+
if (!a || !b)
|
|
183
|
+
return false;
|
|
184
|
+
if (a.length !== b.length)
|
|
185
|
+
return false;
|
|
186
|
+
for (let i = 0; i < a.length; i++) {
|
|
187
|
+
if (!Object.is(a[i], b[i]))
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
function resetHookEffects(effects: any[]): void {
|
|
193
|
+
for (let index = 0; index < effects.length; index += 4)
|
|
194
|
+
effects[index].d = effects[index + 1];
|
|
195
|
+
}
|
|
196
|
+
// Singleton — every method reads render context via ReactSharedInternals,
|
|
197
|
+
// and per-hook closures live on the hook itself, so nothing is render-local
|
|
198
|
+
// to capture. Allocating a fresh wrapper + 17 method closures per function-
|
|
199
|
+
// component render was pure GC pressure.
|
|
200
|
+
const DISPATCHER = {
|
|
201
|
+
useTransition(): [
|
|
202
|
+
boolean,
|
|
203
|
+
(fn: () => void) => void
|
|
204
|
+
] {
|
|
205
|
+
const hook = nextHook(), fiber = getCurrentFiber();
|
|
206
|
+
const queue = hook.q ||= { p: 0, f: false, e: undefined };
|
|
207
|
+
hook.c ||= (fn: () => void) => {
|
|
208
|
+
const scope = transitionScope(() => runAction(fn, fiber.r, scope => {
|
|
209
|
+
scope.n = undefined;
|
|
210
|
+
queue.p++;
|
|
211
|
+
scheduleUpdate(fiber);
|
|
212
|
+
fiber.bt = false;
|
|
213
|
+
}));
|
|
214
|
+
const finish = () => {
|
|
215
|
+
if (scope.f && !scope.h) {
|
|
216
|
+
queue.f = true;
|
|
217
|
+
queue.e = scope.e;
|
|
218
|
+
}
|
|
219
|
+
if (!scope.n)
|
|
220
|
+
queue.p--;
|
|
221
|
+
scheduleUpdate(fiber);
|
|
222
|
+
};
|
|
223
|
+
if (!scope.p) {
|
|
224
|
+
finish();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (scope.p > (scope.v || 0))
|
|
228
|
+
scope.n?.(scope);
|
|
229
|
+
scope.d.then(finish);
|
|
230
|
+
};
|
|
231
|
+
if (queue.f)
|
|
232
|
+
throw queue.e;
|
|
233
|
+
return [hookValue(hook, queue.p > 0), hook.c];
|
|
234
|
+
},
|
|
235
|
+
useMemo<T>(factory: () => T, deps?: ReadonlyArray<unknown>) {
|
|
236
|
+
const hook = nextHook();
|
|
237
|
+
if (hook.d === undefined || !depsEqual(hook.d, deps)) {
|
|
238
|
+
hook.s = factory();
|
|
239
|
+
hook.d = deps;
|
|
240
|
+
}
|
|
241
|
+
return hook.s as T;
|
|
242
|
+
},
|
|
243
|
+
useLayoutEffect(create: () => any, deps?: ReadonlyArray<unknown>) {
|
|
244
|
+
useEffectImpl(1, create, deps);
|
|
245
|
+
},
|
|
246
|
+
useInsertionEffect(create: () => any, deps?: ReadonlyArray<unknown>) {
|
|
247
|
+
useEffectImpl(2, create, deps);
|
|
248
|
+
},
|
|
249
|
+
useCallback<T extends Function>(fn: T, deps?: ReadonlyArray<unknown>): T {
|
|
250
|
+
return this.useMemo(() => fn, deps) as T;
|
|
251
|
+
},
|
|
252
|
+
useRef<T>(initial: T) {
|
|
253
|
+
return (nextHook().s ||= { current: initial }) as {
|
|
254
|
+
current: T;
|
|
255
|
+
};
|
|
256
|
+
},
|
|
257
|
+
useContext<T>(ctx: any): T {
|
|
258
|
+
return readContext(getCurrentFiber(), ctx);
|
|
259
|
+
},
|
|
260
|
+
useImperativeHandle<T>(ref: any, factory: () => T, deps?: ReadonlyArray<unknown>) {
|
|
261
|
+
useEffectImpl(1, () => {
|
|
262
|
+
if (!ref)
|
|
263
|
+
return;
|
|
264
|
+
const value = factory();
|
|
265
|
+
if (isFunction(ref)) {
|
|
266
|
+
const cleanup = ref(value);
|
|
267
|
+
return isFunction(cleanup) ? cleanup : () => ref(null);
|
|
268
|
+
}
|
|
269
|
+
ref.current = value;
|
|
270
|
+
return () => { ref.current = null; };
|
|
271
|
+
}, deps == null ? undefined : [...deps, ref]);
|
|
272
|
+
},
|
|
273
|
+
use<T>(resource: any): T {
|
|
274
|
+
if (resource?.$$typeof === REACT_RECOVERABLE_TYPE)
|
|
275
|
+
return undefined as T;
|
|
276
|
+
if (resource?.$$typeof === REACT_CONTEXT_TYPE) {
|
|
277
|
+
return readContext(getCurrentFiber(), resource);
|
|
278
|
+
}
|
|
279
|
+
if (isFunction(resource?.then)) {
|
|
280
|
+
return readThenable(resource) as T;
|
|
281
|
+
}
|
|
282
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
283
|
+
throw new Error(resource == null ? 'use() received null or undefined' : 'use() expected a Promise or Context');
|
|
284
|
+
}
|
|
285
|
+
throw new Error();
|
|
286
|
+
},
|
|
287
|
+
useDebugValue<T>(_value: T, _formatter?: (v: T) => any): void {
|
|
288
|
+
// noop
|
|
289
|
+
},
|
|
290
|
+
useDeferredValue<T>(v: T): T {
|
|
291
|
+
if (!deferValue)
|
|
292
|
+
return v;
|
|
293
|
+
const hook = nextHook();
|
|
294
|
+
return hookValue(hook, deferValue(hook, getCurrentFiber(), v));
|
|
295
|
+
},
|
|
296
|
+
useReducer<S, A>(reducer: (s: S, a: A) => S, initialArg: any, init?: (a: any) => S) {
|
|
297
|
+
const hook = nextHook();
|
|
298
|
+
if (hook.q === undefined)
|
|
299
|
+
initializeReducer(hook, getCurrentFiber(), initialArg, init, reducer === basicReducer);
|
|
300
|
+
const reduced = reduceTransition?.(hook, reducer);
|
|
301
|
+
const actions = hook.c;
|
|
302
|
+
if (actions != null || reduced) {
|
|
303
|
+
hook.c = null;
|
|
304
|
+
let state = hook.s;
|
|
305
|
+
if (actions)
|
|
306
|
+
for (const action of actions)
|
|
307
|
+
state = reducer(state, action);
|
|
308
|
+
hookFlags |= Object.is(state, hook.d) ? 2 : 3;
|
|
309
|
+
hook.d = hook.s = state;
|
|
310
|
+
}
|
|
311
|
+
return [hook.s, hook.q] as [
|
|
312
|
+
S,
|
|
313
|
+
(a: A) => void
|
|
314
|
+
];
|
|
315
|
+
},
|
|
316
|
+
useSyncExternalStore<T>(subscribe: (cb: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T): T {
|
|
317
|
+
const fiber = getCurrentFiber();
|
|
318
|
+
const hook = nextHook();
|
|
319
|
+
const store: {
|
|
320
|
+
g: () => T;
|
|
321
|
+
} = hook.q ||= {};
|
|
322
|
+
store.g = getSnapshot;
|
|
323
|
+
// During hydration, use the server snapshot (if provided) so the tree
|
|
324
|
+
// matches the SSR output. Components like TanStack Router's ClientOnly
|
|
325
|
+
// rely on this: they render `false` on server, `true` on client — and
|
|
326
|
+
// if we return `true` during hydration, client and server diverge and
|
|
327
|
+
// the tree mounts fresh next to the SSR fallback DOM.
|
|
328
|
+
const root = fiber.r ?? findRoot(fiber);
|
|
329
|
+
const isHydrating = Boolean(root?.h);
|
|
330
|
+
const value = isHydrating && getServerSnapshot ? getServerSnapshot() : getSnapshot();
|
|
331
|
+
hookValue(hook, value);
|
|
332
|
+
useEffectImpl(1, () => {
|
|
333
|
+
let active = true;
|
|
334
|
+
const check = () => {
|
|
335
|
+
if (!active || fiber.u)
|
|
336
|
+
return;
|
|
337
|
+
try {
|
|
338
|
+
if (Object.is(hook.s, store.g()))
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
catch { }
|
|
342
|
+
scheduleUpdate(fiber);
|
|
343
|
+
};
|
|
344
|
+
const unsubscribe = subscribe(check);
|
|
345
|
+
check();
|
|
346
|
+
return () => {
|
|
347
|
+
active = false;
|
|
348
|
+
if (isFunction(unsubscribe))
|
|
349
|
+
unsubscribe();
|
|
350
|
+
};
|
|
351
|
+
}, [subscribe], true);
|
|
352
|
+
return value;
|
|
353
|
+
},
|
|
354
|
+
useActionState<S, P>(action: (state: Awaited<S>, payload: P) => S | Promise<S>, initial: Awaited<S>): [
|
|
355
|
+
Awaited<S>,
|
|
356
|
+
(payload: P) => void,
|
|
357
|
+
boolean
|
|
358
|
+
] {
|
|
359
|
+
const hook = nextHook(), fiber = getCurrentFiber();
|
|
360
|
+
// q is included in commit checkpoints. Each queue owns the committed
|
|
361
|
+
// callback, latest result, outstanding count, failure and async tail.
|
|
362
|
+
const queue = hook.q ||= { a: action, v: actionInitialState(fiber, initial), p: 0, f: false, e: undefined, t: null };
|
|
363
|
+
useEffectImpl(2, () => { queue.a = action; }, [action]);
|
|
364
|
+
hook.c ||= (payload: P) => {
|
|
365
|
+
if (queue.f || fiber.u || fiber.pd)
|
|
366
|
+
return;
|
|
367
|
+
const invoke = queue.a, scope = ReactSharedInternals.B;
|
|
368
|
+
if (scope) {
|
|
369
|
+
queue.p++;
|
|
370
|
+
scheduleUpdate(fiber);
|
|
371
|
+
}
|
|
372
|
+
const execute = async () => {
|
|
373
|
+
if (queue.f)
|
|
374
|
+
return;
|
|
375
|
+
try {
|
|
376
|
+
queue.v = await withinAction(scope, () => invoke(queue.v, payload));
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
queue.f = true;
|
|
380
|
+
queue.e = error;
|
|
381
|
+
if (scope) {
|
|
382
|
+
scope.f = true;
|
|
383
|
+
scope.h = true;
|
|
384
|
+
scope.e = error;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
scheduleUpdate(fiber);
|
|
388
|
+
};
|
|
389
|
+
const task = queue.t ? queue.t.then(execute) : execute();
|
|
390
|
+
queue.t = task;
|
|
391
|
+
if (scope)
|
|
392
|
+
trackAction(scope, task);
|
|
393
|
+
task.then(() => {
|
|
394
|
+
if (queue.t === task)
|
|
395
|
+
queue.t = null;
|
|
396
|
+
if (scope) {
|
|
397
|
+
queue.p--;
|
|
398
|
+
scheduleUpdate(fiber);
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
if (queue.f)
|
|
403
|
+
throw queue.e;
|
|
404
|
+
const pending = queue.p > 0;
|
|
405
|
+
if (!Object.is(hook.s, queue.v) || hook.d !== pending)
|
|
406
|
+
hookFlags |= 1;
|
|
407
|
+
hook.s = queue.v;
|
|
408
|
+
hook.d = pending;
|
|
409
|
+
return [queue.v, hook.c, pending];
|
|
410
|
+
},
|
|
411
|
+
useOptimistic<S, A>(state: S, updateFn?: (state: S, action: A) => S): [
|
|
412
|
+
S,
|
|
413
|
+
(action: A) => void
|
|
414
|
+
] {
|
|
415
|
+
const hook = nextHook(), fiber = getCurrentFiber();
|
|
416
|
+
if (!hook.q) {
|
|
417
|
+
hook.s = [];
|
|
418
|
+
const update = () => scheduleUpdate(fiber);
|
|
419
|
+
hook.q = (action: A) => {
|
|
420
|
+
const scope = ReactSharedInternals.B;
|
|
421
|
+
if (!scope?.p || fiber.u || fiber.pd)
|
|
422
|
+
return;
|
|
423
|
+
hook.s = [...hook.s, [scope, action]];
|
|
424
|
+
scope.l.add(update);
|
|
425
|
+
update();
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
hook.s = hook.s.filter(([scope]: [
|
|
429
|
+
ActionScope
|
|
430
|
+
]) => scope.p > 0);
|
|
431
|
+
let value = state;
|
|
432
|
+
for (const [, action] of hook.s)
|
|
433
|
+
value = updateFn ? updateFn(value, action) : action;
|
|
434
|
+
if (!Object.is(hook.d, value))
|
|
435
|
+
hookFlags |= 1;
|
|
436
|
+
hook.d = value;
|
|
437
|
+
return [value, hook.q];
|
|
438
|
+
},
|
|
439
|
+
useEffect(create: () => any, deps?: ReadonlyArray<unknown>) {
|
|
440
|
+
useEffectImpl(0, create, deps);
|
|
441
|
+
},
|
|
442
|
+
useCacheRefresh(): () => void {
|
|
443
|
+
// There is no client cache to invalidate. Preserve hook identity and
|
|
444
|
+
// leave state and scheduling alone, as with the uncached client cache().
|
|
445
|
+
return this.useCallback(() => { }, []);
|
|
446
|
+
},
|
|
447
|
+
useState<S>(initial: S | (() => S)): [
|
|
448
|
+
S,
|
|
449
|
+
(a: BasicStateAction<S>) => void
|
|
450
|
+
] {
|
|
451
|
+
return DISPATCHER.useReducer<S, BasicStateAction<S>>(basicReducer, initial, initialState);
|
|
452
|
+
},
|
|
453
|
+
useFormStatus() {
|
|
454
|
+
let parent = getCurrentFiber().p;
|
|
455
|
+
while (parent && parent.type !== 'form')
|
|
456
|
+
parent = parent.p;
|
|
457
|
+
const state = parent ? formState(parent) : null;
|
|
458
|
+
const subscribe = this.useCallback((listener: () => void) => {
|
|
459
|
+
state?.l.add(listener);
|
|
460
|
+
return () => { state?.l.delete(listener); };
|
|
461
|
+
}, [state]);
|
|
462
|
+
return this.useSyncExternalStore(subscribe, () => state?.s ?? idleFormStatus, () => idleFormStatus);
|
|
463
|
+
},
|
|
464
|
+
useId(): string {
|
|
465
|
+
const hook = nextHook();
|
|
466
|
+
const fiber = getCurrentFiber();
|
|
467
|
+
const root = findRoot(fiber);
|
|
468
|
+
if (root?.ri) {
|
|
469
|
+
const id = reactId(fiber, root);
|
|
470
|
+
return hook.s ??= id;
|
|
471
|
+
}
|
|
472
|
+
return hook.s ??= (root?.i ?? (root?.h ? ':R' : ':r')) + (root?.h ? root.ic++ : idCounter++).toString(36);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
const basicReducer = <S>(state: S, action: BasicStateAction<S>): S => (isFunction(action) ? (action as (p: S) => S)(state) : action);
|
|
476
|
+
let idCounter = 0;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FiberTag, type Fiber } from '../core';
|
|
2
|
+
export function documentSingleton(fiber: Fiber): HTMLElement | null {
|
|
3
|
+
const doc = fiber.r?.c as Document | undefined;
|
|
4
|
+
return doc?.nodeType === 9 && DOCUMENT_SHELL_TAGS.test(fiber.type) ? doc[fiber.type === 'html' ? 'documentElement' : fiber.type as 'head' | 'body'] : null;
|
|
5
|
+
}
|
|
6
|
+
export const DOCUMENT_HEAD_TAGS = /^(base|link|meta|script|style|title)$/;
|
|
7
|
+
export const DOCUMENT_SHELL_TAGS = /^(html|head|body)$/;
|
|
8
|
+
export function clearAttributes(node: Element): void {
|
|
9
|
+
for (let attribute; attribute = node.attributes[0];)
|
|
10
|
+
node.removeAttribute(attribute.name);
|
|
11
|
+
}
|
|
12
|
+
// React's document server renderer hoists metadata even when a component
|
|
13
|
+
// returns it inside a body wrapper or a Suspense boundary.
|
|
14
|
+
export function documentMetadataParent(fiber: Fiber): HTMLHeadElement | null {
|
|
15
|
+
const container = fiber.r?.c;
|
|
16
|
+
const doc = container?.nodeType === 9 ? container as unknown as Document : container?.ownerDocument;
|
|
17
|
+
if (!doc?.head || fiber.v?.itemProp != null ||
|
|
18
|
+
!['title', 'meta', 'base', 'link'].includes(fiber.type) ||
|
|
19
|
+
fiber.type === 'link' && fiber.v?.rel === 'stylesheet')
|
|
20
|
+
return null;
|
|
21
|
+
for (let parent = fiber.p; parent; parent = parent.p) {
|
|
22
|
+
if (parent.t === FiberTag.Portal || parent.type === 'svg')
|
|
23
|
+
return null;
|
|
24
|
+
if (parent.type === 'foreignObject')
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
return doc.head;
|
|
28
|
+
}
|
|
29
|
+
export function clearHostContainer(container: Node): void {
|
|
30
|
+
if (container.nodeType !== 9 && !DOCUMENT_SHELL_TAGS.test((container as Element).localName)) {
|
|
31
|
+
container.textContent = '';
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
for (let index = container.childNodes.length; index--;) {
|
|
35
|
+
const node = container.childNodes[index]!, tag = (node as Element).localName;
|
|
36
|
+
if (DOCUMENT_SHELL_TAGS.test(tag))
|
|
37
|
+
clearHostContainer(node);
|
|
38
|
+
else if (node.nodeType !== 10 && !/^(script|style)$/.test(tag) && !(tag === 'link' && /^stylesheet$/i.test((node as HTMLLinkElement).rel)))
|
|
39
|
+
node.remove();
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/dom/dom.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { createSyntheticEvent } from './synthetic-event';
|
|
2
|
+
import { UNITLESS_STYLE } from '../core/unitless-style';
|
|
3
|
+
import { devToolsMetadata } from '../core/devtools';
|
|
4
|
+
import { formActions } from './form-actions';
|
|
5
|
+
import { attributeName, attributeValue } from '../core/attributes';
|
|
6
|
+
import { isString } from "../core/functions";
|
|
7
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
8
|
+
const IDL_ATTRS = /^(value|checked|selected|disabled|multiple|muted|readonly)$/;
|
|
9
|
+
export const isSvgElement = (el: Element): boolean => (el.namespaceURI === SVG_NS);
|
|
10
|
+
export function setProp(el: Element, name: string, next: any, prev: any, isSvg: boolean): void {
|
|
11
|
+
if (isReservedProp(name))
|
|
12
|
+
return;
|
|
13
|
+
// These names need no alias or boolean-attribute normalization.
|
|
14
|
+
if (/^(aria|data)-./.test(name)) {
|
|
15
|
+
if (next == null)
|
|
16
|
+
el.removeAttribute(name);
|
|
17
|
+
else
|
|
18
|
+
el.setAttribute(name, '' + next);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (name === 'action' || name === 'formAction') {
|
|
22
|
+
if (isFunction(next)) {
|
|
23
|
+
formActions.set(el, next);
|
|
24
|
+
el.removeAttribute(name.toLowerCase());
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
formActions.delete(el);
|
|
28
|
+
}
|
|
29
|
+
// defaultValue / defaultChecked are IDL-property-only — they seed the
|
|
30
|
+
// initial value/checked of a form control on first mount and must NOT be
|
|
31
|
+
// emitted as HTML attributes (which would leak as `defaultValue="..."`).
|
|
32
|
+
// Setting `el.defaultValue` on a fresh control also sets the initial
|
|
33
|
+
// `el.value`, which is what consumers expect. Skip on hydrated DOM so we
|
|
34
|
+
// don't clobber a live user-typed value.
|
|
35
|
+
if (name === 'defaultValue' || name === 'defaultChecked') {
|
|
36
|
+
if (prev === undefined && next != null) {
|
|
37
|
+
try {
|
|
38
|
+
;
|
|
39
|
+
(el as any)[name] = next;
|
|
40
|
+
}
|
|
41
|
+
catch { }
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (name === 'className' && !isSvg) {
|
|
46
|
+
;
|
|
47
|
+
(el as HTMLElement).className = next == null ? '' : '' + next;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (name === 'style') {
|
|
51
|
+
setStyle(el as HTMLElement, next, prev);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (name === 'dangerouslySetInnerHTML') {
|
|
55
|
+
const nextHtml = next?.__html ?? '';
|
|
56
|
+
const prevHtml = prev?.__html ?? '';
|
|
57
|
+
if (nextHtml !== prevHtml)
|
|
58
|
+
(el as HTMLElement).innerHTML = nextHtml;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (name[0] === 'o' && name[1] === 'n') {
|
|
62
|
+
setEventHandler(el, name, next);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const attr = attributeName(name, isSvg);
|
|
66
|
+
if (!isSvg && IDL_ATTRS.test(name) && name in el) {
|
|
67
|
+
try {
|
|
68
|
+
(el as any)[name] = next == null ? '' : next;
|
|
69
|
+
return;
|
|
70
|
+
} catch {}
|
|
71
|
+
}
|
|
72
|
+
const value = attributeValue(name, next, attr);
|
|
73
|
+
if (value === null) el.removeAttribute(attr);
|
|
74
|
+
else el.setAttribute(attr, value);
|
|
75
|
+
}
|
|
76
|
+
function setStyleProperty(style: CSSStyleDeclaration, key: string, value: any): void {
|
|
77
|
+
if (key[0] === '-') {
|
|
78
|
+
style.setProperty(key, value == null ? '' : '' + value);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
;
|
|
82
|
+
(style as any)[key] = value == null || value === '' ? ''
|
|
83
|
+
: value + (typeof value === 'number' && !UNITLESS_STYLE.test(key) ? 'px' : '');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function setStyle(el: HTMLElement, next: any, prev: any): void {
|
|
87
|
+
const style = el.style;
|
|
88
|
+
if (isString(next)) {
|
|
89
|
+
style.cssText = next;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (isString(prev))
|
|
93
|
+
style.cssText = '';
|
|
94
|
+
if (prev && isObject(prev)) {
|
|
95
|
+
for (const k in prev) {
|
|
96
|
+
if (!next || !(k in next))
|
|
97
|
+
setStyleProperty(style, k, '');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (next && isObject(next)) {
|
|
101
|
+
for (const k in next) {
|
|
102
|
+
if (!prev || prev[k] !== next[k])
|
|
103
|
+
setStyleProperty(style, k, next[k]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function setEventHandler(el: Element, name: string, next: any): void {
|
|
108
|
+
// Only function handlers are accepted. Reject strings/objects/etc — the
|
|
109
|
+
// legacy `onclick="..."` HTML attribute (string handler) is a known XSS
|
|
110
|
+
// vector if a parent spreads untrusted props onto a host element. React
|
|
111
|
+
// also ignores non-function handlers.
|
|
112
|
+
const enabled = isFunction(next);
|
|
113
|
+
const capture = name.endsWith('Capture') && !name.endsWith('PointerCapture');
|
|
114
|
+
const lower = name.slice(2, capture ? -7 : undefined).toLowerCase();
|
|
115
|
+
const events = lower === 'change' && (el.tagName === 'TEXTAREA' ||
|
|
116
|
+
(el.tagName === 'INPUT' && !/^(checkbox|radio|file)$/.test((el as HTMLInputElement).type)))
|
|
117
|
+
? ['input', 'change']
|
|
118
|
+
: [lower === 'focus' ? 'focusin' : lower === 'blur' ? 'focusout' : lower === 'doubleclick' ? 'dblclick' : lower];
|
|
119
|
+
// Key by the React prop name (not DOM event name) so `onChange` and
|
|
120
|
+
// `onInput` on the same text input — which both dispatch from the native
|
|
121
|
+
// `input` event — can coexist without clobbering each other's handlers.
|
|
122
|
+
const handlers = ((el as any).__h ||= Object.create(null));
|
|
123
|
+
let existing = handlers[name];
|
|
124
|
+
// Replace the listener when a control's type changes its native event.
|
|
125
|
+
if (existing && (!enabled || existing.e[0] !== events[0])) {
|
|
126
|
+
for (const event of existing.e)
|
|
127
|
+
el.removeEventListener(event, existing, capture);
|
|
128
|
+
if (enabled) delete (el as any).__v;
|
|
129
|
+
existing = handlers[name] = null;
|
|
130
|
+
}
|
|
131
|
+
if (!enabled)
|
|
132
|
+
return;
|
|
133
|
+
if (!existing) {
|
|
134
|
+
const entry = ((e: Event) => {
|
|
135
|
+
if (events.length > 1) {
|
|
136
|
+
const value = (el as HTMLInputElement).value;
|
|
137
|
+
if (e.type === 'change' && (el as any).__v === value)
|
|
138
|
+
return;
|
|
139
|
+
(el as any).__v = e.type === 'input' ? value : undefined;
|
|
140
|
+
}
|
|
141
|
+
const event = createSyntheticEvent(e);
|
|
142
|
+
try {
|
|
143
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
144
|
+
const previous = devToolsMetadata.current;
|
|
145
|
+
devToolsMetadata.current = devToolsMetadata.hosts.get(el) || null;
|
|
146
|
+
try { entry.c(event); } finally { devToolsMetadata.current = previous; }
|
|
147
|
+
} else entry.c(event);
|
|
148
|
+
} finally { event.currentTarget = null; }
|
|
149
|
+
}) as ((e: Event) => void) & {
|
|
150
|
+
c: Function;
|
|
151
|
+
e: string[];
|
|
152
|
+
};
|
|
153
|
+
entry.e = events;
|
|
154
|
+
existing = handlers[name] = entry;
|
|
155
|
+
for (const event of events)
|
|
156
|
+
el.addEventListener(event, entry, capture);
|
|
157
|
+
}
|
|
158
|
+
existing.c = next;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface SyntheticEvent extends Event {
|
|
162
|
+
nativeEvent: Event;
|
|
163
|
+
isDefaultPrevented(): boolean;
|
|
164
|
+
isPropagationStopped(): boolean;
|
|
165
|
+
persist(): void;
|
|
166
|
+
currentTarget: EventTarget & Element;
|
|
167
|
+
}
|
|
168
|
+
export function createHostNode(type: string, isSvg: boolean, owner: Document = document): Element {
|
|
169
|
+
if (isSvg || type === 'svg') {
|
|
170
|
+
return owner.createElementNS(SVG_NS, type);
|
|
171
|
+
}
|
|
172
|
+
return owner.createElement(type);
|
|
173
|
+
}
|
|
174
|
+
import { isObject } from '../core/functions';
|
|
175
|
+
import { isFunction, isReservedProp } from '../core/functions';
|
|
176
|
+
|
|
177
|
+
// Renderer writes have already been observed by the app. Native change events
|
|
178
|
+
// should only report a value that differs from that renderer-owned value.
|
|
179
|
+
export function trackInputValue(el: HTMLInputElement | HTMLTextAreaElement): void {
|
|
180
|
+
(el as any).__v = el.value;
|
|
181
|
+
}
|