@bleedingdev/tanstack-redact 0.0.0-bootstrap → 0.2.1
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 +1 -1
- 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 +35 -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 +113 -8
- 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 +22 -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,555 @@
|
|
|
1
|
+
import { boundaryId } from './stream-ids'
|
|
2
|
+
import { childInsertionContext, type InsertionContext } from './insertion-context'
|
|
3
|
+
import { forkId } from '../dom/react-ids'
|
|
4
|
+
import { isTextContent } from '../core/functions';
|
|
5
|
+
import { isFunction, isThenable } from '../core/functions'
|
|
6
|
+
import { resolveClassProps } from '../core/class-props'
|
|
7
|
+
import {
|
|
8
|
+
REACT_ELEMENT_TYPE,
|
|
9
|
+
REACT_LEGACY_ELEMENT_TYPE,
|
|
10
|
+
REACT_FRAGMENT_TYPE,
|
|
11
|
+
type ReactNode,
|
|
12
|
+
type ReactElement,
|
|
13
|
+
} from '../core'
|
|
14
|
+
import {
|
|
15
|
+
REACT_SUSPENSE_TYPE,
|
|
16
|
+
REACT_CONTEXT_TYPE,
|
|
17
|
+
REACT_PROVIDER_TYPE,
|
|
18
|
+
REACT_CONSUMER_TYPE,
|
|
19
|
+
REACT_FORWARD_REF_TYPE,
|
|
20
|
+
REACT_MEMO_TYPE,
|
|
21
|
+
REACT_LAZY_TYPE,
|
|
22
|
+
REACT_STRICT_MODE_TYPE,
|
|
23
|
+
REACT_PROFILER_TYPE,
|
|
24
|
+
REACT_PORTAL_TYPE,
|
|
25
|
+
REACT_ACTIVITY_TYPE,
|
|
26
|
+
REACT_VIEW_TRANSITION_TYPE,
|
|
27
|
+
} from '../react'
|
|
28
|
+
import {
|
|
29
|
+
escapeAttr,
|
|
30
|
+
attrToHtml,
|
|
31
|
+
escapeText,
|
|
32
|
+
escapeScript,
|
|
33
|
+
VOID_ELEMENTS,
|
|
34
|
+
RAW_TEXT_ELEMENTS,
|
|
35
|
+
} from './escape'
|
|
36
|
+
import {
|
|
37
|
+
pushContext,
|
|
38
|
+
popContext,
|
|
39
|
+
snapshotContexts,
|
|
40
|
+
recordHostResource,
|
|
41
|
+
currentSSRFrame,
|
|
42
|
+
type ContextSnapshot,
|
|
43
|
+
} from './dispatcher'
|
|
44
|
+
import { isBrowserError } from '../core/browser'
|
|
45
|
+
import { resourceKind } from '../core/resource-hints'
|
|
46
|
+
import type { ResourceScope } from './resource-hints'
|
|
47
|
+
|
|
48
|
+
export interface ServerErrorInfo {
|
|
49
|
+
componentStack: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type BrowserBailoutCallback = (error: Error, errorInfo: ServerErrorInfo) => void
|
|
53
|
+
|
|
54
|
+
/** Streamed output keeps pending boundaries addressable until it is written. */
|
|
55
|
+
export type HtmlPart = string | SuspendedBoundary
|
|
56
|
+
|
|
57
|
+
export interface SuspendedBoundary {
|
|
58
|
+
id: number
|
|
59
|
+
treeId: bigint
|
|
60
|
+
insertionContext: InsertionContext
|
|
61
|
+
fallback: HtmlPart[]
|
|
62
|
+
children: ReactNode
|
|
63
|
+
thenable: Promise<any>
|
|
64
|
+
contextSnapshot: ContextSnapshot
|
|
65
|
+
componentStack: string
|
|
66
|
+
// Set by the stream: completed content and failure markers are inlined
|
|
67
|
+
// when the boundary is written; `written` boundaries need a later reveal.
|
|
68
|
+
content?: HtmlPart[]
|
|
69
|
+
marker?: string
|
|
70
|
+
written?: boolean
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface WalkOptions {
|
|
74
|
+
insertionContext?: InsertionContext | undefined
|
|
75
|
+
treeId?: bigint | undefined
|
|
76
|
+
emit: (chunk: HtmlPart) => void
|
|
77
|
+
onHead?: () => void
|
|
78
|
+
onSuspend?: ((boundary: SuspendedBoundary) => void) | undefined
|
|
79
|
+
onBrowserBailout?: BrowserBailoutCallback | undefined
|
|
80
|
+
onError?: ((error: unknown) => unknown) | undefined
|
|
81
|
+
componentStack?: string | undefined
|
|
82
|
+
thrownInfo?: { componentStack?: string | undefined }
|
|
83
|
+
nextBoundaryId: () => number
|
|
84
|
+
bootstrapped?: boolean | undefined
|
|
85
|
+
isBoundaryResolution?: boolean | undefined
|
|
86
|
+
resourceScope?: ResourceScope | undefined
|
|
87
|
+
// Shared traversal flags: SVG = 1, adjacent text = 2.
|
|
88
|
+
// Host children restore previous flags on return or throw.
|
|
89
|
+
textState?: { bits: number }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Synchronously walk a React node and emit HTML string pieces to `opts.emit`.
|
|
94
|
+
* Suspended boundaries are emitted as fallbacks with marker IDs; if `opts.onSuspend`
|
|
95
|
+
* is provided, the suspension is recorded for later streaming.
|
|
96
|
+
*/
|
|
97
|
+
export function walk(node: ReactNode, opts: WalkOptions): void {
|
|
98
|
+
// Seed a text state if the caller didn't provide one so the separator logic
|
|
99
|
+
// is active for the whole tree.
|
|
100
|
+
if (!opts.textState) opts = { ...opts, textState: { bits: +(opts.insertionContext === 'svg') } }
|
|
101
|
+
walkNode(node, opts)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// --- <select> selection context ----------------------------------------------
|
|
105
|
+
// Stack of active select values (or `undefined` when the current select has
|
|
106
|
+
// no controlled value). `<option>` walks read the top of stack to decide
|
|
107
|
+
// whether to emit `selected=""`.
|
|
108
|
+
const selectValueStack: unknown[] = []
|
|
109
|
+
function pushSelectContext(value: unknown): void {
|
|
110
|
+
selectValueStack.push(value)
|
|
111
|
+
}
|
|
112
|
+
function popSelectContext(): void {
|
|
113
|
+
selectValueStack.pop()
|
|
114
|
+
}
|
|
115
|
+
function currentSelectValue(): unknown {
|
|
116
|
+
return selectValueStack.length ? selectValueStack[selectValueStack.length - 1] : undefined
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function optionChildText(children: unknown): string {
|
|
120
|
+
// `<option>Text</option>` — if no `value` prop, the option's value is its
|
|
121
|
+
// flat string/number child content. Matches DOM semantics (`option.value`
|
|
122
|
+
// defaults to `textContent` when no attribute is set).
|
|
123
|
+
if (children == null) return ''
|
|
124
|
+
if (isTextContent(children)) return '' + children
|
|
125
|
+
if (Array.isArray(children)) return children.map(optionChildText).join('')
|
|
126
|
+
return ''
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function emitText(text: string, opts: WalkOptions): void {
|
|
130
|
+
// Empty string renders no text node and doesn't start/extend a text flow —
|
|
131
|
+
// skip entirely so sibling text isn't separated by a stray `<!-- -->`.
|
|
132
|
+
if (text === '') return
|
|
133
|
+
if (opts.textState!.bits & 2) opts.emit('<!-- -->')
|
|
134
|
+
opts.emit(escapeText(text))
|
|
135
|
+
opts.textState!.bits |= 2
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function walkNode(node: ReactNode, opts: WalkOptions): void {
|
|
139
|
+
if (node == null || node === false || node === true) return
|
|
140
|
+
|
|
141
|
+
if (isTextContent(node)) {
|
|
142
|
+
emitText('' + node, opts)
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
if (Array.isArray(node)) {
|
|
146
|
+
const treeId = opts.treeId ?? 1n
|
|
147
|
+
for (let i = 0; i < node.length; i++) walkNode(node[i], { ...opts, treeId: forkId(treeId, node.length, i) })
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
if (isFunction((node as any)[Symbol.iterator])) {
|
|
151
|
+
walkNode(Array.from(node as Iterable<ReactNode>), opts)
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (typeof node !== 'object') return
|
|
156
|
+
const t = (node as any).$$typeof
|
|
157
|
+
|
|
158
|
+
// Raw React.lazy in the tree (RSC Flight encodes 'use client' components —
|
|
159
|
+
// CodeBlock, CodeExplorer, etc. — as bare Lazy objects directly in the
|
|
160
|
+
// tree, not wrapped in REACT_ELEMENT_TYPE). SSR previously dropped these
|
|
161
|
+
// here, so code snippets never made it into the server HTML. The RSC
|
|
162
|
+
// decoder server-side awaits payloads before rendering, so status is
|
|
163
|
+
// 'fulfilled' and `_init()` returns the resolved element synchronously.
|
|
164
|
+
// If still pending (shouldn't happen post-awaitLazyElements), throw the
|
|
165
|
+
// thenable so streaming SSR suspends the current boundary and retries.
|
|
166
|
+
if (t === REACT_LAZY_TYPE) {
|
|
167
|
+
const lazy = node as any
|
|
168
|
+
const resolved = lazy._init(lazy._payload)
|
|
169
|
+
walkNode(resolved, opts)
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (t !== REACT_ELEMENT_TYPE && t !== REACT_LEGACY_ELEMENT_TYPE) return
|
|
174
|
+
|
|
175
|
+
const el = node as ReactElement
|
|
176
|
+
walkElement(el, opts)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function walkElement(el: ReactElement, opts: WalkOptions): void {
|
|
180
|
+
const type = el.type
|
|
181
|
+
const props = el.props ?? {}
|
|
182
|
+
|
|
183
|
+
if (typeof type === 'string') {
|
|
184
|
+
walkHost(type, props, opts)
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (type === REACT_FRAGMENT_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PROFILER_TYPE) {
|
|
189
|
+
walkNode(props.children, opts)
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (type === REACT_SUSPENSE_TYPE) {
|
|
194
|
+
walkSuspense(props, opts)
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (type === REACT_ACTIVITY_TYPE) {
|
|
199
|
+
if (props.mode !== 'hidden') walkNode(props.children, opts)
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
if (type === REACT_VIEW_TRANSITION_TYPE) {
|
|
203
|
+
walkNode(props.children, opts)
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const marker = (type as any)?.$$typeof
|
|
208
|
+
|
|
209
|
+
if (marker === REACT_PORTAL_TYPE) {
|
|
210
|
+
// Portals don't render to the main HTML output on the server.
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (marker === REACT_CONTEXT_TYPE || marker === REACT_PROVIDER_TYPE) {
|
|
215
|
+
const ctx = (type as any)._context
|
|
216
|
+
pushContext(ctx, props.value)
|
|
217
|
+
try {
|
|
218
|
+
walkNode(props.children, opts)
|
|
219
|
+
} finally {
|
|
220
|
+
popContext(ctx)
|
|
221
|
+
}
|
|
222
|
+
return
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (marker === REACT_CONSUMER_TYPE) {
|
|
226
|
+
const render = props.children
|
|
227
|
+
if (isFunction(render)) {
|
|
228
|
+
walkNode(render((type as any)._context._currentValue), opts)
|
|
229
|
+
}
|
|
230
|
+
return
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (marker === REACT_FORWARD_REF_TYPE) {
|
|
234
|
+
const render = (type as any).render
|
|
235
|
+
const ref = (props as any).ref ?? null
|
|
236
|
+
const { ref: _omit, ...rest } = props as any
|
|
237
|
+
walkComponent(render, rest, opts, ref)
|
|
238
|
+
return
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (marker === REACT_MEMO_TYPE) {
|
|
242
|
+
const inner = (type as any).type
|
|
243
|
+
walkElement({ ...el, type: inner } as ReactElement, opts)
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (marker === REACT_LAZY_TYPE) {
|
|
248
|
+
const { _payload, _init } = type as any
|
|
249
|
+
const resolved = _init(_payload)
|
|
250
|
+
walkElement({ ...el, type: resolved } as ReactElement, opts)
|
|
251
|
+
return
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (isFunction(type)) {
|
|
255
|
+
walkComponent(type, props, opts)
|
|
256
|
+
return
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function walkHost(
|
|
261
|
+
tag: string,
|
|
262
|
+
props: Record<string, any>,
|
|
263
|
+
opts: WalkOptions,
|
|
264
|
+
): void {
|
|
265
|
+
const isSvg = !!(opts.textState!.bits & 1) || tag === 'svg'
|
|
266
|
+
if (!isSvg && resourceKind(tag, props) && recordHostResource(tag, props, opts.resourceScope)) return
|
|
267
|
+
// <textarea value="..."> serializes its value as a TEXT CHILD, not an
|
|
268
|
+
// attribute. `defaultValue` is the fallback when `value` is absent. This
|
|
269
|
+
// matches React and the HTML spec — `<textarea value="x">` is not valid
|
|
270
|
+
// HTML; the value is the element's textContent.
|
|
271
|
+
const isTextarea = tag === 'textarea'
|
|
272
|
+
const textareaValue = isTextarea
|
|
273
|
+
? props.value != null
|
|
274
|
+
? props.value
|
|
275
|
+
: props.defaultValue
|
|
276
|
+
: undefined
|
|
277
|
+
|
|
278
|
+
// <input defaultValue="..."> should parse with that value — emit it as a
|
|
279
|
+
// `value` attribute. Similarly `defaultChecked` becomes `checked`. This
|
|
280
|
+
// keeps hydration consistent: the browser parser sees the initial value,
|
|
281
|
+
// and on client commit our setProp seeds `.defaultValue`/`.defaultChecked`
|
|
282
|
+
// without stomping the user-typed value.
|
|
283
|
+
const isInput = tag === 'input'
|
|
284
|
+
const inputValueAttr =
|
|
285
|
+
isInput && props.value == null && props.defaultValue != null
|
|
286
|
+
? props.defaultValue
|
|
287
|
+
: undefined
|
|
288
|
+
const inputCheckedAttr =
|
|
289
|
+
isInput && props.checked == null && props.defaultChecked != null
|
|
290
|
+
? props.defaultChecked
|
|
291
|
+
: undefined
|
|
292
|
+
|
|
293
|
+
// <select value="..."> does NOT become an attribute on `<select>` — the
|
|
294
|
+
// HTML spec has no such attribute. React resolves the selection by stamping
|
|
295
|
+
// `selected` on the matching `<option>` children during render. Stash the
|
|
296
|
+
// target value(s) on the walk state and the child `<option>` walk reads it.
|
|
297
|
+
const isSelect = tag === 'select'
|
|
298
|
+
if (isSelect) {
|
|
299
|
+
const val = props.value != null ? props.value : props.defaultValue
|
|
300
|
+
pushSelectContext(val)
|
|
301
|
+
}
|
|
302
|
+
const isOption = tag === 'option'
|
|
303
|
+
try {
|
|
304
|
+
|
|
305
|
+
// Prepend the HTML5 doctype to the stream when rendering an <html> root.
|
|
306
|
+
// Without it the browser parses the document in quirks mode, which breaks
|
|
307
|
+
// CSS sizing (documentElement.clientHeight returns the content height, not
|
|
308
|
+
// the viewport) — and Floating-UI-based libraries (Radix dropdowns etc.)
|
|
309
|
+
// then compute off-screen positions for overlays.
|
|
310
|
+
if (tag === 'html') opts.emit('<!DOCTYPE html>')
|
|
311
|
+
|
|
312
|
+
opts.emit('<' + tag)
|
|
313
|
+
for (const k in props) {
|
|
314
|
+
if (isTextarea && (k === 'value' || k === 'defaultValue')) continue
|
|
315
|
+
if (isInput && (k === 'defaultValue' || k === 'defaultChecked')) continue
|
|
316
|
+
if (isSelect && (k === 'value' || k === 'defaultValue')) continue
|
|
317
|
+
if (isOption && k === 'selected') continue
|
|
318
|
+
opts.emit(attrToHtml(k, props[k], isSvg))
|
|
319
|
+
}
|
|
320
|
+
if (inputValueAttr !== undefined) {
|
|
321
|
+
opts.emit(attrToHtml('value', inputValueAttr, isSvg))
|
|
322
|
+
}
|
|
323
|
+
if (inputCheckedAttr !== undefined) {
|
|
324
|
+
opts.emit(attrToHtml('checked', inputCheckedAttr, isSvg))
|
|
325
|
+
}
|
|
326
|
+
if (isOption) {
|
|
327
|
+
const selectVal = currentSelectValue()
|
|
328
|
+
if (selectVal !== undefined) {
|
|
329
|
+
const optionValue =
|
|
330
|
+
props.value != null ? props.value : optionChildText(props.children)
|
|
331
|
+
const matches = Array.isArray(selectVal)
|
|
332
|
+
? selectVal.some((v) => '' + v === '' + optionValue)
|
|
333
|
+
: '' + selectVal === '' + optionValue
|
|
334
|
+
if (matches) opts.emit(' selected=""')
|
|
335
|
+
} else if (props.selected) {
|
|
336
|
+
opts.emit(' selected=""')
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (VOID_ELEMENTS.has(tag)) {
|
|
341
|
+
opts.emit('/>')
|
|
342
|
+
opts.textState!.bits &= 1
|
|
343
|
+
return
|
|
344
|
+
}
|
|
345
|
+
opts.emit('>')
|
|
346
|
+
if (tag === 'head') opts.onHead?.()
|
|
347
|
+
// Opening a host element starts a fresh text flow context for its children.
|
|
348
|
+
// Children's text separator tracking is independent of the outer context.
|
|
349
|
+
const parentTextState = opts.textState
|
|
350
|
+
|
|
351
|
+
if (tag === 'html' && !hasHeadChild(props.children)) {
|
|
352
|
+
opts.emit('<head>')
|
|
353
|
+
opts.onHead?.()
|
|
354
|
+
opts.emit('</head>')
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const dangerouslyHtml = props.dangerouslySetInnerHTML?.__html
|
|
358
|
+
|
|
359
|
+
if (isTextarea && textareaValue != null) {
|
|
360
|
+
opts.emit(escapeText(String(textareaValue)))
|
|
361
|
+
opts.emit(`</${tag}>`)
|
|
362
|
+
parentTextState!.bits &= 1
|
|
363
|
+
return
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (RAW_TEXT_ELEMENTS.has(tag)) {
|
|
367
|
+
// script/style: raw-text. React allows either a string/number child or
|
|
368
|
+
// dangerouslySetInnerHTML — some libs (Start's Scripts) use the latter.
|
|
369
|
+
if (dangerouslyHtml != null) {
|
|
370
|
+
opts.emit(escapeScript(String(dangerouslyHtml)))
|
|
371
|
+
} else {
|
|
372
|
+
const children = props.children
|
|
373
|
+
if (typeof children === 'string' || typeof children === 'number') {
|
|
374
|
+
opts.emit(escapeScript(String(children)))
|
|
375
|
+
} else if (Array.isArray(children)) {
|
|
376
|
+
opts.emit(escapeScript(children.filter((c) => c != null).join('')))
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
opts.emit(`</${tag}>`)
|
|
380
|
+
parentTextState!.bits &= 1
|
|
381
|
+
return
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
if (dangerouslyHtml != null) {
|
|
385
|
+
opts.emit(String(dangerouslyHtml))
|
|
386
|
+
} else {
|
|
387
|
+
const previousState = parentTextState!.bits
|
|
388
|
+
parentTextState!.bits = +(isSvg && tag !== 'foreignObject')
|
|
389
|
+
try {
|
|
390
|
+
walkNode(props.children, { ...opts, insertionContext: childInsertionContext(tag, props, opts.insertionContext ?? 'html') })
|
|
391
|
+
} finally {
|
|
392
|
+
parentTextState!.bits = previousState
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
opts.emit(`</${tag}>`)
|
|
396
|
+
// Host element closing resets outer flow — next sibling text starts fresh.
|
|
397
|
+
parentTextState!.bits &= 1
|
|
398
|
+
} finally {
|
|
399
|
+
if (isSelect) popSelectContext()
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function hasHeadChild(children: unknown): boolean {
|
|
404
|
+
if (children == null || typeof children === 'boolean') return false
|
|
405
|
+
if (Array.isArray(children)) return children.some(hasHeadChild)
|
|
406
|
+
if (typeof children !== 'string' && isIterable(children)) {
|
|
407
|
+
for (const child of children as Iterable<unknown>) {
|
|
408
|
+
if (hasHeadChild(child)) return true
|
|
409
|
+
}
|
|
410
|
+
return false
|
|
411
|
+
}
|
|
412
|
+
return isElementOfType(children, 'head')
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function isElementOfType(value: unknown, type: string): value is ReactElement {
|
|
416
|
+
const marker = (value as ReactElement | null)?.$$typeof as unknown
|
|
417
|
+
return (
|
|
418
|
+
!!value &&
|
|
419
|
+
typeof value === 'object' &&
|
|
420
|
+
(marker === REACT_ELEMENT_TYPE || marker === REACT_LEGACY_ELEMENT_TYPE) &&
|
|
421
|
+
(value as ReactElement).type === type
|
|
422
|
+
)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function isIterable(value: unknown): value is Iterable<unknown> {
|
|
426
|
+
return !!value && isFunction((value as { [Symbol.iterator]?: unknown })[Symbol.iterator])
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function walkComponent(
|
|
430
|
+
fn: Function,
|
|
431
|
+
props: Record<string, any>,
|
|
432
|
+
opts: WalkOptions,
|
|
433
|
+
ref?: unknown,
|
|
434
|
+
): void {
|
|
435
|
+
if (opts.onBrowserBailout) {
|
|
436
|
+
opts = { ...opts, componentStack: `\n at ${(fn as any).displayName || fn.name || 'Anonymous'}${opts.componentStack || ''}` }
|
|
437
|
+
}
|
|
438
|
+
const frame = currentSSRFrame()
|
|
439
|
+
const previousTree = frame.treeId, previousLocal = frame.localId
|
|
440
|
+
frame.treeId = opts.treeId ?? 1n
|
|
441
|
+
frame.localId = 0
|
|
442
|
+
try {
|
|
443
|
+
if ((fn as any).prototype?.isReactComponent) {
|
|
444
|
+
props = resolveClassProps(fn, props)
|
|
445
|
+
const ctxType = (fn as any).contextType
|
|
446
|
+
const ctxValue = ctxType ? ctxType._currentValue : undefined
|
|
447
|
+
const instance = new (fn as any)(props, ctxValue)
|
|
448
|
+
instance.props = props
|
|
449
|
+
instance.context = ctxValue
|
|
450
|
+
if ((fn as any).getDerivedStateFromProps) {
|
|
451
|
+
const d = (fn as any).getDerivedStateFromProps(props, instance.state)
|
|
452
|
+
if (d) instance.state = { ...instance.state, ...d }
|
|
453
|
+
}
|
|
454
|
+
walkNode(instance.render(), opts)
|
|
455
|
+
return
|
|
456
|
+
}
|
|
457
|
+
const rendered = (fn as any)(props, ref)
|
|
458
|
+
// A component which materialized IDs owns one extra tree slot for its children.
|
|
459
|
+
walkNode(rendered, frame.localId ? { ...opts, treeId: forkId(frame.treeId, 1, 0) } : opts)
|
|
460
|
+
} catch (error) {
|
|
461
|
+
if (opts.thrownInfo && !opts.thrownInfo.componentStack) opts.thrownInfo.componentStack = opts.componentStack
|
|
462
|
+
if (isBrowserError(error) && !(error as any).componentStack) {
|
|
463
|
+
Object.defineProperty(error, 'componentStack', { value: opts.componentStack })
|
|
464
|
+
}
|
|
465
|
+
throw error
|
|
466
|
+
} finally {
|
|
467
|
+
frame.treeId = previousTree
|
|
468
|
+
frame.localId = previousLocal
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function walkSuspense(
|
|
473
|
+
props: Record<string, any>,
|
|
474
|
+
opts: WalkOptions,
|
|
475
|
+
): void {
|
|
476
|
+
const id = opts.nextBoundaryId()
|
|
477
|
+
// Snapshot contexts BEFORE attempting children, so if a descendant suspends
|
|
478
|
+
// we can replay the same provider stack when re-rendering the boundary.
|
|
479
|
+
const contextSnapshot = snapshotContexts()
|
|
480
|
+
|
|
481
|
+
// Try to render the children synchronously. If a thenable is thrown,
|
|
482
|
+
// record the boundary and emit the fallback.
|
|
483
|
+
const childParts: HtmlPart[] = []
|
|
484
|
+
const nested: SuspendedBoundary[] = []
|
|
485
|
+
const thrownInfo: { componentStack?: string | undefined } = {}
|
|
486
|
+
const childEmit = (s: HtmlPart) => childParts.push(s)
|
|
487
|
+
const resourceScope: ResourceScope | undefined = currentSSRFrame().shellFlushed ? {} : undefined
|
|
488
|
+
try {
|
|
489
|
+
walkNode(props.children, {
|
|
490
|
+
...opts,
|
|
491
|
+
resourceScope,
|
|
492
|
+
thrownInfo,
|
|
493
|
+
emit: childEmit,
|
|
494
|
+
onSuspend: opts.onSuspend ? (boundary) => nested.push(boundary) : undefined,
|
|
495
|
+
nextBoundaryId: opts.nextBoundaryId,
|
|
496
|
+
})
|
|
497
|
+
} catch (thenable: any) {
|
|
498
|
+
nested.length = 0
|
|
499
|
+
const suspended = isThenable(thenable)
|
|
500
|
+
if (!suspended) {
|
|
501
|
+
if (isBrowserError(thenable)) opts.onBrowserBailout?.(thenable, { componentStack: (thenable as any).componentStack || opts.componentStack || '' })
|
|
502
|
+
else opts.onError?.(thenable)
|
|
503
|
+
}
|
|
504
|
+
const fallbackParts: HtmlPart[] = []
|
|
505
|
+
walkNode(props.fallback, {
|
|
506
|
+
...opts,
|
|
507
|
+
emit: (s) => fallbackParts.push(s),
|
|
508
|
+
onSuspend: opts.onSuspend ? (boundary) => nested.push(boundary) : undefined,
|
|
509
|
+
nextBoundaryId: opts.nextBoundaryId,
|
|
510
|
+
})
|
|
511
|
+
// A streamed suspension is emitted as itself, so the stream can still
|
|
512
|
+
// inline its content if it completes before these bytes are written.
|
|
513
|
+
const boundary: SuspendedBoundary | undefined = suspended && opts.onSuspend ? {
|
|
514
|
+
id, treeId: opts.treeId ?? 1n, insertionContext: opts.insertionContext ?? 'html', fallback: fallbackParts, children: props.children, thenable, contextSnapshot,
|
|
515
|
+
componentStack: thrownInfo.componentStack || opts.componentStack || '',
|
|
516
|
+
} : undefined
|
|
517
|
+
if (boundary) opts.emit(boundary)
|
|
518
|
+
else emitBoundary(opts, id, fallbackParts, suspended ? '$?' : isBrowserError(thenable) ? '$!' : '$E')
|
|
519
|
+
for (const inner of nested) opts.onSuspend?.(inner)
|
|
520
|
+
if (boundary) opts.onSuspend!(boundary)
|
|
521
|
+
return
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if (resourceScope) currentSSRFrame().resources?.mergeScope(resourceScope, opts.resourceScope)
|
|
525
|
+
|
|
526
|
+
// Children rendered fully — emit them wrapped in resolved-boundary markers
|
|
527
|
+
// (`<!--$N-->` / `<!--/$-->`). Without markers, the client hydrator has no
|
|
528
|
+
// way to know this subtree is inside a Suspense, so if the client version
|
|
529
|
+
// of a descendant (e.g. `React.lazy`) suspends it can't pinpoint which DOM
|
|
530
|
+
// range to adopt on resolve — it creates fresh DOM next to the SSR content,
|
|
531
|
+
// producing visible duplicates (e.g. double navbar logos). Markers let the
|
|
532
|
+
// client treat this as a resolved boundary and hydrate in-place.
|
|
533
|
+
emitBoundary(opts, id, childParts, '$')
|
|
534
|
+
for (const boundary of nested) opts.onSuspend?.(boundary)
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function emitBoundary(opts: WalkOptions, id: number, parts: HtmlPart[], marker: string): void {
|
|
538
|
+
const [open, close] = boundaryEdges(id, marker, opts.insertionContext, currentSSRFrame().identifierPrefix)
|
|
539
|
+
opts.emit(open)
|
|
540
|
+
for (const part of parts) opts.emit(part)
|
|
541
|
+
opts.emit(close)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Boundary markers: `$` completed, `$E`/`$!` client-rendered, `$?` pending.
|
|
546
|
+
* A pending template is allowed in table insertion modes and does not break
|
|
547
|
+
* out of SVG/MathML. The visible fallback is a sibling, not an HTML div wrapper.
|
|
548
|
+
* Bare rows/columns create implicit containers. Close them on both sides so
|
|
549
|
+
* neither preceding rows nor the fallback can move a marker inside one.
|
|
550
|
+
* These end tags are ignored when no such container is open.
|
|
551
|
+
*/
|
|
552
|
+
export function boundaryEdges(id: number, marker: string, context: InsertionContext | undefined, prefix: string): [string, string] {
|
|
553
|
+
const close = context === 'table' ? '</tbody></colgroup>' : ''
|
|
554
|
+
return [`${close}<!--${marker}${id}-->${marker === '$?' ? `<template id="${escapeAttr(boundaryId(id, prefix))}"></template>` : ''}`, `${close}<!--/$-->`]
|
|
555
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { createRequire, findPackageJSON } from 'node:module'
|
|
3
|
+
import { dirname, resolve } from 'node:path'
|
|
4
|
+
import { pathToFileURL } from 'node:url'
|
|
5
|
+
import { correctFlightTimings } from './flight-timing'
|
|
6
|
+
|
|
7
|
+
const shimPackages = ['next', 'vinext', 'server-only', 'client-only', 'private-next-instrumentation-client']
|
|
8
|
+
const requestHandlers = ['vinext/server/app-rsc-handler', 'vinext/server/app-rsc-combined-handler']
|
|
9
|
+
const clientDependencies = ['vinext > @unpic/react', 'vinext > ipaddr.js', 'vinext > web-vitals']
|
|
10
|
+
|
|
11
|
+
// These modules carry framework state or request semantics. Both Vite's main
|
|
12
|
+
// graph and its separate dependency optimizer must see the same correction.
|
|
13
|
+
export function correctVinextModule(code: string, id: string, directory: string): string | null {
|
|
14
|
+
id = id.split('?')[0]!.replace(/\\/g, '/')
|
|
15
|
+
directory = directory.replace(/\\/g, '/')
|
|
16
|
+
if (id === directory + '/server/app-rsc-handler.js') {
|
|
17
|
+
const original = 'if (!options.skipTrailingSlashRedirect) {'
|
|
18
|
+
if (code.includes('if (!isDataRequest && !options.skipTrailingSlashRedirect) {')) return null
|
|
19
|
+
if (code.split(original).length !== 2) throw new Error('Unsupported Vinext Pages data handler. Update the Redact integration for this Vinext build.')
|
|
20
|
+
return code.replace(original, 'if (!isDataRequest && !options.skipTrailingSlashRedirect) {')
|
|
21
|
+
}
|
|
22
|
+
if (id === directory + '/client/instrumentation-client-state.js') {
|
|
23
|
+
if (code.includes('Symbol.for("vinext.client.instrumentationHooks")')) return null
|
|
24
|
+
const replacements = [
|
|
25
|
+
['let clientInstrumentationHooks = null;', 'const clientInstrumentationKey = Symbol.for("vinext.client.instrumentationHooks");'],
|
|
26
|
+
['clientInstrumentationHooks = hooks;', 'Reflect.set(globalThis, clientInstrumentationKey, hooks);'],
|
|
27
|
+
['return clientInstrumentationHooks;', 'return Reflect.get(globalThis, clientInstrumentationKey) ?? null;'],
|
|
28
|
+
['clientInstrumentationHooks?.onRouterTransitionStart?.(href, navigationType);', 'getClientInstrumentationHooks()?.onRouterTransitionStart?.(href, navigationType);'],
|
|
29
|
+
]
|
|
30
|
+
for (const [original, corrected] of replacements) {
|
|
31
|
+
const expected = original === 'return clientInstrumentationHooks;' ? 3 : 2
|
|
32
|
+
if (code.split(original!).length !== expected) throw new Error('Unsupported Vinext instrumentation state. Update the Redact integration for this Vinext build.')
|
|
33
|
+
code = code.split(original!).join(corrected!)
|
|
34
|
+
}
|
|
35
|
+
return code
|
|
36
|
+
}
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isShimInclude(id: string, excludes: string[]) {
|
|
41
|
+
const target = id.slice(id.lastIndexOf('>') + 1).trim()
|
|
42
|
+
// A package root covers its explicit, nested, .js, and glob entrypoints.
|
|
43
|
+
return excludes.some(excluded => target === excluded || target.startsWith(excluded + '/'))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function vinextCompatibility() {
|
|
47
|
+
let directory = '', hasApp = false, excludes: string[] = [], externalRequire: any
|
|
48
|
+
const transform = function(this: any, code: string, id: string) {
|
|
49
|
+
const corrected = directory && (correctVinextModule(code, id, directory) || correctFlightTimings(code, id, source => this.parse(source)))
|
|
50
|
+
return corrected ? { code: corrected, map: null } : null
|
|
51
|
+
}
|
|
52
|
+
const modulePlugin = { name: 'redact:vinext-modules', transform }
|
|
53
|
+
const requirePlugins = new WeakSet<object>()
|
|
54
|
+
function configure(name: string, config: any) {
|
|
55
|
+
if (!directory) return
|
|
56
|
+
const client = name === 'client' || config.consumer === 'client'
|
|
57
|
+
if (!client) {
|
|
58
|
+
config.resolve ||= {}
|
|
59
|
+
if (Array.isArray(config.resolve.external)) config.resolve.external = config.resolve.external.filter((id: string) => !requestHandlers.includes(id))
|
|
60
|
+
if (config.resolve.noExternal !== true) {
|
|
61
|
+
const existing = config.resolve.noExternal
|
|
62
|
+
config.resolve.noExternal = [...(Array.isArray(existing) ? existing : existing ? [existing] : []), 'vinext']
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const optimizer = config.optimizeDeps ||= {}
|
|
66
|
+
const optimizerActive = !optimizer.noDiscovery || !!optimizer.include?.length
|
|
67
|
+
const options = optimizer.rolldownOptions ||= {}
|
|
68
|
+
let plugins = [options.plugins || []].flat(Infinity)
|
|
69
|
+
plugins = plugins.filter((plugin: any) => plugin?.name !== modulePlugin.name)
|
|
70
|
+
if (!client || hasApp) {
|
|
71
|
+
optimizer.exclude = [...new Set([...(optimizer.exclude || []), ...excludes])]
|
|
72
|
+
optimizer.include = optimizer.include?.filter((id: string) => !isShimInclude(id, excludes))
|
|
73
|
+
plugins = plugins.filter((plugin: any) => plugin?.name !== 'vinext:dep-optimize-alias')
|
|
74
|
+
if (!client && !plugins.some((plugin: any) => plugin && typeof plugin === 'object' && requirePlugins.has(plugin))) {
|
|
75
|
+
// Rolldown's built-in plugins are class instances. Preserve the instance
|
|
76
|
+
// so its native implementation and options reach the optimizer.
|
|
77
|
+
const plugin = externalRequire({ external: excludes })
|
|
78
|
+
requirePlugins.add(plugin)
|
|
79
|
+
plugins.push(plugin)
|
|
80
|
+
}
|
|
81
|
+
if (client && optimizerActive) {
|
|
82
|
+
optimizer.include = [...new Set([...(optimizer.include || []), ...clientDependencies.filter(id => !isShimInclude(id, optimizer.exclude.filter((entry: string) => !shimPackages.includes(entry))))])]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
options.plugins = [...plugins, modulePlugin]
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
config: {
|
|
89
|
+
order: 'post',
|
|
90
|
+
async handler(config: any) {
|
|
91
|
+
const require = createRequire(resolve(config.root || '.', 'package.json'))
|
|
92
|
+
// Vinext is ESM-only, so resolve its public package manifest through its
|
|
93
|
+
// import condition without loading a second copy of the plugin.
|
|
94
|
+
const packagePath = findPackageJSON('vinext', pathToFileURL(resolve(config.root || '.', 'package.json')))
|
|
95
|
+
if (!packagePath) throw new Error('Install vinext 1.3.0 before using the Redact Vinext integration.')
|
|
96
|
+
directory = resolve(dirname(packagePath), 'dist')
|
|
97
|
+
const pkg = JSON.parse(readFileSync(packagePath, 'utf8'))
|
|
98
|
+
if (pkg.version !== '1.3.0') throw new Error(`Redact Vinext integration supports vinext 1.3.0; found ${pkg.version}.`)
|
|
99
|
+
hasApp = !!config.environments?.rsc
|
|
100
|
+
const aliases = Array.isArray(config.resolve?.alias) ? config.resolve.alias : Object.entries(config.resolve?.alias || {}).map(([find, replacement]) => ({ find, replacement }))
|
|
101
|
+
const publicShims = Object.keys((await import(pathToFileURL(resolve(directory, 'shims/public-shim-map.json.js')).href)).default)
|
|
102
|
+
const shimEntries = [...publicShims, 'next/dist/client/components/navigation'].flatMap(id => [id, id + '.js'])
|
|
103
|
+
excludes = [...new Set([...shimPackages, ...shimEntries, ...aliases.filter((alias: any) => typeof alias.find === 'string' && (alias.find.startsWith('next/') || alias.replacement?.replace(/\\/g, '/').startsWith(directory.replace(/\\/g, '/') + '/'))).map((alias: any) => alias.find)])] as string[]
|
|
104
|
+
const vite = await import(pathToFileURL(require.resolve('vite')).href)
|
|
105
|
+
externalRequire = vite.esmExternalRequirePlugin
|
|
106
|
+
if (typeof externalRequire !== 'function') throw new Error('Redact Vinext integration requires Vite 8 with esmExternalRequirePlugin support.')
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
configEnvironment: { order: 'post', handler: configure },
|
|
110
|
+
configResolved: {
|
|
111
|
+
order: 'post',
|
|
112
|
+
handler(config: any) {
|
|
113
|
+
for (const [name, environment] of Object.entries(config.environments)) configure(name, environment)
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
resolveHandler(id: string) {
|
|
117
|
+
if (directory && requestHandlers.includes(id)) return { id: resolve(directory, id.slice('vinext/'.length) + '.js'), external: false }
|
|
118
|
+
return null
|
|
119
|
+
},
|
|
120
|
+
transform,
|
|
121
|
+
}
|
|
122
|
+
}
|