@tanstack/solid-start-client
Advanced tools
| import { InternalHydrateProps } from './Hydrate.js'; | ||
| import { JSX } from '@solidjs/web'; | ||
| export declare function GenericHydrate(props: InternalHydrateProps): JSX.Element; |
| import { Dynamic, createComponent, memo, mergeProps } from "@solidjs/web"; | ||
| import { useHydrated } from "@tanstack/solid-router"; | ||
| import * as Solid from "solid-js"; | ||
| import { isServer } from "@tanstack/router-core/isServer"; | ||
| import { hydrateIdAttribute, hydrateWhenAttribute } from "@tanstack/start-client-core/hydration/constants"; | ||
| import { createResolvedGate, getFallbackHtml, getOrCreateGate, onGateResolve, releaseGate, runHydrationStrategyCleanup, saveFallbackHtml, waitForHydrationPrefetchStrategy } from "@tanstack/start-client-core/hydration/runtime"; | ||
| import { listenForDelegatedHydrationIntent } from "@tanstack/start-client-core/hydration"; | ||
| //#region src/GenericHydrate.tsx | ||
| var hydrateIdSelector = `[${hydrateIdAttribute}]`; | ||
| var dynamicType = "dynamic"; | ||
| var dynamicHydrateStrategy = { | ||
| _t: dynamicType, | ||
| _d: () => true | ||
| }; | ||
| function shouldDeferHydration(strategy) { | ||
| return strategy._d ? strategy._d() : strategy._t !== "load"; | ||
| } | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function HydratedBoundary(props) { | ||
| let didHydrate = false; | ||
| Solid.createEffect(() => true, () => { | ||
| if (didHydrate) return; | ||
| didHydrate = true; | ||
| props.onHydrated?.(); | ||
| props.onStrategyHydrated?.(props.id); | ||
| }); | ||
| return props.children; | ||
| } | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function GenericHydrate(props) { | ||
| const when = props.when; | ||
| const dynamicHydrate = typeof when === "function"; | ||
| const initialHydrateStrategy = dynamicHydrate ? isServer ?? typeof window === "undefined" ? dynamicHydrateStrategy : when() : when; | ||
| const markerHydrateType = dynamicHydrate ? dynamicType : initialHydrateStrategy._t; | ||
| const prefetchStrategy = () => props.prefetch; | ||
| const hydrated = useHydrated(); | ||
| const uniqueId = Solid.createUniqueId(); | ||
| const id = props.h ? `${props.h}${uniqueId}` : uniqueId; | ||
| const initialHydrateType = initialHydrateStrategy._t; | ||
| const shouldPreserveServerHTML = (isServer ?? typeof window === "undefined") || !hydrated(); | ||
| const shouldDeferInitialHydration = !hydrated() && shouldDeferHydration(initialHydrateStrategy); | ||
| const gate = isServer ?? typeof window === "undefined" ? createResolvedGate(id, initialHydrateType) : getOrCreateGate(id, initialHydrateType); | ||
| const [ready, setReady] = Solid.createSignal((isServer ?? typeof window === "undefined") || !shouldDeferInitialHydration && initialHydrateType !== "never"); | ||
| const [prefetchError, setPrefetchError] = Solid.createSignal(); | ||
| const controller = { | ||
| abortController: new AbortController(), | ||
| hydrationRequested: false, | ||
| hydrationListeners: /* @__PURE__ */ new Set(), | ||
| hydrationResolvePending: false, | ||
| started: false | ||
| }; | ||
| let didPrefetch = false; | ||
| let didClearPreservedServerHTML = false; | ||
| let markerElement; | ||
| let preservedServerChildNodes; | ||
| let cleanupHydrationRuntime = () => {}; | ||
| let didReleaseGate = false; | ||
| const clearPreservedServerHTML = () => { | ||
| if (!shouldPreserveServerHTML || !shouldDeferInitialHydration || !markerElement || !preservedServerChildNodes || didClearPreservedServerHTML) return; | ||
| didClearPreservedServerHTML = true; | ||
| for (const child of preservedServerChildNodes) child.remove(); | ||
| }; | ||
| if (!(isServer ?? typeof window === "undefined") && initialHydrateType !== "never" && (!shouldDeferInitialHydration || !shouldDeferHydration(initialHydrateStrategy))) gate.resolve(); | ||
| const onHydrate = (listener) => { | ||
| if (controller.hydrationRequested) { | ||
| listener(); | ||
| return () => {}; | ||
| } | ||
| controller.hydrationListeners.add(listener); | ||
| return () => { | ||
| controller.hydrationListeners.delete(listener); | ||
| }; | ||
| }; | ||
| const requestHydration = () => { | ||
| if (!controller.hydrationRequested) { | ||
| controller.hydrationRequested = true; | ||
| controller.hydrationListeners.forEach((listener) => listener()); | ||
| controller.hydrationListeners.clear(); | ||
| } | ||
| if (!controller.promise) { | ||
| resolveGate(); | ||
| return; | ||
| } | ||
| if (controller.hydrationResolvePending) return; | ||
| controller.hydrationResolvePending = true; | ||
| controller.promise.then(() => resolveGate(), (error) => { | ||
| if (!controller.abortController.signal.aborted) setPrefetchError(() => error); | ||
| }); | ||
| }; | ||
| const resolveGate = gate.resolve; | ||
| Solid.onCleanup(() => { | ||
| controller.abortController.abort(); | ||
| controller.hydrationListeners.clear(); | ||
| cleanupHydrationRuntime(); | ||
| if (!didReleaseGate) { | ||
| didReleaseGate = true; | ||
| releaseGate(gate); | ||
| } | ||
| }); | ||
| Solid.createEffect(() => { | ||
| const currentHydrateStrategy = initialHydrateStrategy; | ||
| return { | ||
| currentHydrateStrategy, | ||
| currentPrefetchStrategy: prefetchStrategy(), | ||
| currentHydrateType: currentHydrateStrategy._t | ||
| }; | ||
| }, ({ currentHydrateStrategy, currentPrefetchStrategy, currentHydrateType }) => { | ||
| gate.when = currentHydrateType; | ||
| for (const element of document.querySelectorAll(hydrateIdSelector)) if (element.getAttribute(hydrateIdAttribute) === id) { | ||
| markerElement = element; | ||
| preservedServerChildNodes ??= Array.from(element.childNodes); | ||
| saveFallbackHtml(id, element); | ||
| break; | ||
| } | ||
| if (currentHydrateType === "never" && !shouldPreserveServerHTML && markerElement) markerElement.replaceChildren(); | ||
| if (currentPrefetchStrategy && !controller.started) { | ||
| controller.started = true; | ||
| const preload = () => props.p?.() ?? Promise.resolve(); | ||
| if (typeof currentPrefetchStrategy === "function") { | ||
| const promise = Promise.resolve().then(() => currentPrefetchStrategy({ | ||
| element: markerElement ?? null, | ||
| signal: controller.abortController.signal, | ||
| preload, | ||
| waitFor: (strategy) => waitForHydrationPrefetchStrategy(strategy, { | ||
| element: markerElement ?? null, | ||
| signal: controller.abortController.signal, | ||
| onHydrate | ||
| }) | ||
| })).then(() => void 0); | ||
| controller.promise = promise; | ||
| promise.catch((error) => { | ||
| if (!controller.abortController.signal.aborted) setPrefetchError(() => error); | ||
| }); | ||
| } else if (props.p) { | ||
| const currentStrategy = currentPrefetchStrategy; | ||
| const prefetch = () => { | ||
| if (didPrefetch) return; | ||
| didPrefetch = true; | ||
| preload(); | ||
| }; | ||
| const cleanupPrefetch = runHydrationStrategyCleanup(currentStrategy._s?.({ | ||
| element: markerElement ?? null, | ||
| prefetch | ||
| })); | ||
| if (cleanupPrefetch) Solid.onCleanup(cleanupPrefetch); | ||
| } | ||
| } | ||
| if (currentHydrateType !== "never" && (!shouldDeferInitialHydration || !shouldDeferHydration(currentHydrateStrategy))) { | ||
| gate.resolve(); | ||
| setReady(true); | ||
| } | ||
| const cleanups = []; | ||
| let removeResolveListener = () => {}; | ||
| let disposed = false; | ||
| const resolveBoundary = () => { | ||
| setReady(true); | ||
| }; | ||
| const cleanup = () => { | ||
| if (disposed) return; | ||
| disposed = true; | ||
| if (gate.resolve === requestHydration) gate.resolve = resolveGate; | ||
| removeResolveListener(); | ||
| cleanups.forEach((fn) => fn()); | ||
| }; | ||
| cleanupHydrationRuntime = cleanup; | ||
| const addCleanup = (fn) => { | ||
| if (!fn) return; | ||
| if (disposed || gate.resolved) { | ||
| fn(); | ||
| return; | ||
| } | ||
| cleanups.push(fn); | ||
| }; | ||
| Solid.onCleanup(cleanup); | ||
| removeResolveListener = onGateResolve(gate, () => { | ||
| cleanup(); | ||
| resolveBoundary(); | ||
| }); | ||
| if (gate.resolved || !shouldDeferInitialHydration || currentHydrateType === "never") { | ||
| if (gate.resolved) resolveBoundary(); | ||
| return; | ||
| } | ||
| gate.resolve = requestHydration; | ||
| const context = { | ||
| element: markerElement ?? null, | ||
| gate | ||
| }; | ||
| addCleanup(runHydrationStrategyCleanup(currentHydrateStrategy._s?.(context))); | ||
| if (currentHydrateStrategy._t !== "interaction") addCleanup(runHydrationStrategyCleanup(markerElement ? listenForDelegatedHydrationIntent(markerElement, context) : void 0)); | ||
| }); | ||
| Solid.createRenderEffect(() => !((isServer ?? typeof window === "undefined") || gate.resolved || initialHydrateStrategy._t === "never" || shouldDeferHydration(initialHydrateStrategy)), (shouldResolve) => { | ||
| if (shouldResolve) gate.resolve(); | ||
| }); | ||
| const markerAttributes = markerHydrateType === dynamicType ? void 0 : initialHydrateStrategy._a?.(); | ||
| const markerProps = { | ||
| component: "div", | ||
| [hydrateIdAttribute]: id, | ||
| [hydrateWhenAttribute]: markerHydrateType, | ||
| ...markerAttributes | ||
| }; | ||
| const fallback = () => { | ||
| if (!shouldPreserveServerHTML) return props.fallback ?? null; | ||
| const html = getFallbackHtml(id); | ||
| if (!html) return null; | ||
| return createComponent(Dynamic, { | ||
| component: "div", | ||
| style: { display: "contents" }, | ||
| innerHTML: html | ||
| }); | ||
| }; | ||
| const hydratedChildren = () => { | ||
| return createComponent(HydratedBoundary, { | ||
| id, | ||
| get onHydrated() { | ||
| return props.onHydrated; | ||
| }, | ||
| onStrategyHydrated: (id) => { | ||
| clearPreservedServerHTML(); | ||
| markerElement?.removeAttribute(hydrateWhenAttribute); | ||
| initialHydrateStrategy._o?.(id); | ||
| }, | ||
| get children() { | ||
| return props.children; | ||
| } | ||
| }); | ||
| }; | ||
| return createComponent(Dynamic, mergeProps(markerProps, { get children() { | ||
| return [memo(() => (() => { | ||
| const error = prefetchError(); | ||
| if (error) throw error; | ||
| return null; | ||
| })()), memo(() => initialHydrateType === "never" && !shouldPreserveServerHTML ? props.fallback ?? null : createComponent(Solid.Loading, { | ||
| get fallback() { | ||
| return fallback(); | ||
| }, | ||
| get children() { | ||
| return createComponent(Solid.Show, { | ||
| get when() { | ||
| return ready(); | ||
| }, | ||
| get fallback() { | ||
| return fallback(); | ||
| }, | ||
| get children() { | ||
| return hydratedChildren(); | ||
| } | ||
| }); | ||
| } | ||
| }))]; | ||
| } })); | ||
| } | ||
| //#endregion | ||
| export { GenericHydrate }; | ||
| //# sourceMappingURL=GenericHydrate.js.map |
| {"version":3,"file":"GenericHydrate.js","names":["Solid","Dynamic","useHydrated","isServer","hydrateIdAttribute","hydrateWhenAttribute","createResolvedGate","getFallbackHtml","getOrCreateGate","onGateResolve","releaseGate","runHydrationStrategyCleanup","saveFallbackHtml","waitForHydrationPrefetchStrategy","listenForDelegatedHydrationIntent","HydrationRuntimeContext","HydrationStrategy","HydrationWhen","HydrationGateRecord","InternalHydrateProps","DynamicProps","JSX","HydrationFallbackDynamicProps","HydrationMarkerDynamicProps","key","PrefetchController","abortController","AbortController","hydrationRequested","hydrationListeners","Set","hydrationResolvePending","started","promise","Promise","hydrateIdSelector","dynamicType","dynamicHydrateStrategy","_t","_d","shouldDeferHydration","strategy","HydratedBoundary","props","id","onHydrated","onStrategyHydrated","children","Element","didHydrate","createEffect","GenericHydrate","when","dynamicHydrate","initialHydrateStrategy","window","markerHydrateType","prefetchStrategy","prefetch","hydrated","uniqueId","createUniqueId","h","initialHydrateType","shouldPreserveServerHTML","shouldDeferInitialHydration","gate","ready","setReady","createSignal","prefetchError","setPrefetchError","controller","didPrefetch","didClearPreservedServerHTML","markerElement","HTMLDivElement","preservedServerChildNodes","Array","ChildNode","cleanupHydrationRuntime","didReleaseGate","clearPreservedServerHTML","child","remove","resolve","onHydrate","listener","add","delete","requestHydration","forEach","clear","resolveGate","then","error","signal","aborted","onCleanup","abort","currentHydrateStrategy","currentPrefetchStrategy","currentHydrateType","element","document","querySelectorAll","getAttribute","from","childNodes","replaceChildren","preload","p","waitFor","undefined","catch","currentStrategy","cleanupPrefetch","_s","cleanups","removeResolveListener","disposed","resolveBoundary","cleanup","fn","addCleanup","resolved","push","context","createRenderEffect","shouldResolve","markerAttributes","_a","markerProps","component","fallback","html","fallbackProps","style","display","innerHTML","_$createComponent","hydratedChildren","removeAttribute","_o","_$mergeProps","_$memo","Loading","Show"],"sources":["../../src/GenericHydrate.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport { Dynamic } from '@solidjs/web'\n\nimport { useHydrated } from '@tanstack/solid-router'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport {\n hydrateIdAttribute,\n hydrateWhenAttribute,\n} from '@tanstack/start-client-core/hydration/constants'\nimport {\n createResolvedGate,\n getFallbackHtml,\n getOrCreateGate,\n onGateResolve,\n releaseGate,\n runHydrationStrategyCleanup,\n saveFallbackHtml,\n waitForHydrationPrefetchStrategy,\n} from '@tanstack/start-client-core/hydration/runtime'\nimport { listenForDelegatedHydrationIntent } from '@tanstack/start-client-core/hydration'\nimport type {\n HydrationRuntimeContext,\n HydrationStrategy,\n HydrationWhen,\n} from '@tanstack/start-client-core/hydration'\nimport type { HydrationGateRecord } from '@tanstack/start-client-core/hydration/runtime'\nimport type { InternalHydrateProps } from './Hydrate'\nimport type { DynamicProps, JSX } from '@solidjs/web'\n\ntype HydrationFallbackDynamicProps = DynamicProps<'div'>\ntype HydrationMarkerDynamicProps = DynamicProps<'div'> & {\n [hydrateIdAttribute]: string\n [hydrateWhenAttribute]: HydrationWhen\n [key: `data-${string}`]: string | undefined\n}\ntype PrefetchController = {\n abortController: AbortController\n hydrationRequested: boolean\n hydrationListeners: Set<() => void>\n hydrationResolvePending: boolean\n started: boolean\n promise?: Promise<void>\n}\n\nconst hydrateIdSelector = `[${hydrateIdAttribute}]`\nconst dynamicType = 'dynamic'\nconst dynamicHydrateStrategy = {\n _t: dynamicType,\n _d: () => true,\n} satisfies HydrationStrategy<typeof dynamicType, false>\n\nfunction shouldDeferHydration(strategy: HydrationStrategy) {\n return strategy._d ? strategy._d() : strategy._t !== 'load'\n}\n\n/* @__NO_SIDE_EFFECTS__ */\nfunction HydratedBoundary(props: {\n id: string\n onHydrated?: () => void\n onStrategyHydrated?: (id: string) => void\n children: JSX.Element\n}) {\n let didHydrate = false\n\n Solid.createEffect(\n () => true,\n () => {\n if (didHydrate) return\n didHydrate = true\n props.onHydrated?.()\n props.onStrategyHydrated?.(props.id)\n },\n )\n\n return props.children\n}\n\n/* @__NO_SIDE_EFFECTS__ */\nexport function GenericHydrate(props: InternalHydrateProps) {\n const when = props.when\n const dynamicHydrate = typeof when === 'function'\n const initialHydrateStrategy: HydrationStrategy = dynamicHydrate\n ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n (isServer ?? typeof window === 'undefined')\n ? dynamicHydrateStrategy\n : when()\n : when\n const markerHydrateType: HydrationWhen = dynamicHydrate\n ? dynamicType\n : initialHydrateStrategy._t!\n const prefetchStrategy = () => props.prefetch\n const hydrated = useHydrated()\n const uniqueId = Solid.createUniqueId()\n const id = props.h ? `${props.h}${uniqueId}` : uniqueId\n const initialHydrateType = initialHydrateStrategy._t!\n const shouldPreserveServerHTML =\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n (isServer ?? typeof window === 'undefined') || !hydrated()\n const shouldDeferInitialHydration =\n !hydrated() && shouldDeferHydration(initialHydrateStrategy)\n const gate: HydrationGateRecord =\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n (isServer ?? typeof window === 'undefined')\n ? createResolvedGate(id, initialHydrateType)\n : getOrCreateGate(id, initialHydrateType)\n const [ready, setReady] = Solid.createSignal(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n (isServer ?? typeof window === 'undefined') ||\n (!shouldDeferInitialHydration && initialHydrateType !== 'never'),\n )\n const [prefetchError, setPrefetchError] = Solid.createSignal<unknown>()\n const controller: PrefetchController = {\n abortController: new AbortController(),\n hydrationRequested: false,\n hydrationListeners: new Set<() => void>(),\n hydrationResolvePending: false,\n started: false,\n }\n let didPrefetch = false\n let didClearPreservedServerHTML = false\n let markerElement: HTMLDivElement | undefined\n let preservedServerChildNodes: Array<ChildNode> | undefined\n let cleanupHydrationRuntime = () => {}\n let didReleaseGate = false\n\n const clearPreservedServerHTML = () => {\n if (\n !shouldPreserveServerHTML ||\n !shouldDeferInitialHydration ||\n !markerElement ||\n !preservedServerChildNodes ||\n didClearPreservedServerHTML\n ) {\n return\n }\n\n didClearPreservedServerHTML = true\n for (const child of preservedServerChildNodes) {\n child.remove()\n }\n }\n\n if (\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n !(isServer ?? typeof window === 'undefined') &&\n initialHydrateType !== 'never' &&\n (!shouldDeferInitialHydration ||\n !shouldDeferHydration(initialHydrateStrategy))\n ) {\n gate.resolve()\n }\n\n const onHydrate = (listener: () => void) => {\n if (controller.hydrationRequested) {\n listener()\n return () => {}\n }\n\n controller.hydrationListeners.add(listener)\n return () => {\n controller.hydrationListeners.delete(listener)\n }\n }\n\n const requestHydration = () => {\n if (!controller.hydrationRequested) {\n controller.hydrationRequested = true\n controller.hydrationListeners.forEach((listener) => listener())\n controller.hydrationListeners.clear()\n }\n\n if (!controller.promise) {\n resolveGate()\n return\n }\n if (controller.hydrationResolvePending) return\n controller.hydrationResolvePending = true\n\n controller.promise.then(\n () => resolveGate(),\n (error) => {\n if (!controller.abortController.signal.aborted) {\n setPrefetchError(() => error)\n }\n },\n )\n }\n const resolveGate = gate.resolve\n\n Solid.onCleanup(() => {\n controller.abortController.abort()\n controller.hydrationListeners.clear()\n cleanupHydrationRuntime()\n if (!didReleaseGate) {\n didReleaseGate = true\n releaseGate(gate)\n }\n })\n\n Solid.createEffect(\n () => {\n const currentHydrateStrategy = initialHydrateStrategy\n const currentPrefetchStrategy = prefetchStrategy()\n const currentHydrateType = currentHydrateStrategy._t!\n\n return {\n currentHydrateStrategy,\n currentPrefetchStrategy,\n currentHydrateType,\n }\n },\n ({\n currentHydrateStrategy,\n currentPrefetchStrategy,\n currentHydrateType,\n }) => {\n gate.when = currentHydrateType\n for (const element of document.querySelectorAll<HTMLDivElement>(\n hydrateIdSelector,\n )) {\n if (element.getAttribute(hydrateIdAttribute) === id) {\n markerElement = element\n preservedServerChildNodes ??= Array.from(element.childNodes)\n saveFallbackHtml(id, element)\n break\n }\n }\n\n if (\n currentHydrateType === 'never' &&\n !shouldPreserveServerHTML &&\n markerElement\n ) {\n markerElement.replaceChildren()\n }\n\n if (currentPrefetchStrategy && !controller.started) {\n controller.started = true\n const preload = () => props.p?.() ?? Promise.resolve()\n\n if (typeof currentPrefetchStrategy === 'function') {\n const promise = Promise.resolve()\n .then(() =>\n currentPrefetchStrategy({\n element: markerElement ?? null,\n signal: controller.abortController.signal,\n preload,\n waitFor: (strategy) =>\n waitForHydrationPrefetchStrategy(strategy, {\n element: markerElement ?? null,\n signal: controller.abortController.signal,\n onHydrate,\n }),\n }),\n )\n .then(() => undefined)\n\n controller.promise = promise\n promise.catch((error) => {\n if (!controller.abortController.signal.aborted) {\n setPrefetchError(() => error)\n }\n })\n } else if (props.p) {\n const currentStrategy = currentPrefetchStrategy\n const prefetch = () => {\n if (didPrefetch) return\n didPrefetch = true\n void preload()\n }\n const cleanupPrefetch = runHydrationStrategyCleanup(\n currentStrategy._s?.({\n element: markerElement ?? null,\n prefetch,\n }),\n )\n if (cleanupPrefetch) Solid.onCleanup(cleanupPrefetch)\n }\n }\n\n if (\n currentHydrateType !== 'never' &&\n (!shouldDeferInitialHydration ||\n !shouldDeferHydration(currentHydrateStrategy))\n ) {\n gate.resolve()\n setReady(true)\n }\n\n const cleanups: Array<() => void> = []\n let removeResolveListener = () => {}\n let disposed = false\n\n const resolveBoundary = () => {\n setReady(true)\n }\n\n const cleanup = () => {\n if (disposed) return\n disposed = true\n if (gate.resolve === requestHydration) {\n gate.resolve = resolveGate\n }\n removeResolveListener()\n cleanups.forEach((fn) => fn())\n }\n cleanupHydrationRuntime = cleanup\n\n const addCleanup = (fn: void | (() => void)) => {\n if (!fn) return\n if (disposed || gate.resolved) {\n fn()\n return\n }\n cleanups.push(fn)\n }\n\n Solid.onCleanup(cleanup)\n\n removeResolveListener = onGateResolve(gate, () => {\n cleanup()\n resolveBoundary()\n })\n\n if (\n gate.resolved ||\n !shouldDeferInitialHydration ||\n currentHydrateType === 'never'\n ) {\n if (gate.resolved) resolveBoundary()\n return\n }\n\n gate.resolve = requestHydration\n const context: HydrationRuntimeContext = {\n element: markerElement ?? null,\n gate,\n }\n addCleanup(\n runHydrationStrategyCleanup(currentHydrateStrategy._s?.(context)),\n )\n\n if (currentHydrateStrategy._t !== 'interaction') {\n addCleanup(\n runHydrationStrategyCleanup(\n markerElement\n ? listenForDelegatedHydrationIntent(markerElement, context)\n : undefined,\n ),\n )\n }\n },\n )\n\n // prettier-ignore\n Solid.createRenderEffect(\n () =>\n !(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n (isServer ?? typeof window === 'undefined') ||\n gate.resolved ||\n initialHydrateStrategy._t === 'never' ||\n shouldDeferHydration(initialHydrateStrategy)\n ),\n (shouldResolve) => {\n if (shouldResolve) {\n gate.resolve()\n }\n },\n )\n\n const markerAttributes =\n markerHydrateType === dynamicType\n ? undefined\n : initialHydrateStrategy._a?.()\n const markerProps: HydrationMarkerDynamicProps = {\n component: 'div',\n [hydrateIdAttribute]: id,\n [hydrateWhenAttribute]: markerHydrateType,\n ...markerAttributes,\n }\n const fallback = () => {\n if (!shouldPreserveServerHTML) return props.fallback ?? null\n\n const html = getFallbackHtml(id)\n if (!html) return null\n\n const fallbackProps: HydrationFallbackDynamicProps = {\n component: 'div',\n style: { display: 'contents' },\n innerHTML: html,\n }\n\n return <Dynamic {...fallbackProps} />\n }\n const hydratedChildren = () => {\n const children = (\n <HydratedBoundary\n id={id}\n onHydrated={props.onHydrated}\n onStrategyHydrated={(id) => {\n clearPreservedServerHTML()\n markerElement?.removeAttribute(hydrateWhenAttribute)\n initialHydrateStrategy._o?.(id)\n }}\n >\n {props.children}\n </HydratedBoundary>\n )\n\n return children\n }\n\n return (\n <Dynamic {...markerProps}>\n {(() => {\n const error = prefetchError()\n if (error) throw error\n return null\n })()}\n {initialHydrateType === 'never' && !shouldPreserveServerHTML ? (\n (props.fallback ?? null)\n ) : (\n <Solid.Loading fallback={fallback()}>\n <Solid.Show when={ready()} fallback={fallback()}>\n {hydratedChildren()}\n </Solid.Show>\n </Solid.Loading>\n )}\n </Dynamic>\n )\n}\n"],"mappings":";;;;;;;;AA4CA,IAAMmC,oBAAoB,IAAI/B,mBAAkB;AAChD,IAAMgC,cAAc;AACpB,IAAMC,yBAAyB;CAC7BC,IAAIF;CACJG,UAAU;AACZ;AAEA,SAASC,qBAAqBC,UAA6B;CACzD,OAAOA,SAASF,K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AI;MAAA,OAAEe,MAAM;KAAC;KAAA,IAAEmE,WAAQ;MAAA,OAAEA,SAAS;KAAC;KAAA,IAAAvF,WAAA;MAAA,OAC5C8F,iBAAiB;KAAC;IAAA,CAAA;GAAA;EAAA,CAAA,CAGxB,CAAA;CAAA,EAAA,CAAA,CAAA;AAGP"} |
| import { HydrationStrategy as CoreHydrationStrategy, HydrationPrefetchFunction, HydrationPrefetchStrategy, HydrationWhen } from '@tanstack/start-client-core/hydration'; | ||
| import { JSX } from '@solidjs/web'; | ||
| export type { HydrationInteractionEvent, HydrationInteractionEvents, HydrationPrefetchContext, HydrationPrefetchFunction, HydrationPrefetchStrategy, HydrationPrefetchWaitReason, HydrationWhen, } from '@tanstack/start-client-core/hydration'; | ||
| export type SolidHydrationStrategy<TWhen extends HydrationWhen = HydrationWhen, TCanPrefetch extends boolean = boolean> = CoreHydrationStrategy<TWhen, TCanPrefetch> & { | ||
| _h: (props: HydrateProps) => JSX.Element; | ||
| }; | ||
| export type HydrationStrategy<TWhen extends HydrationWhen = HydrationWhen, TCanPrefetch extends boolean = boolean> = SolidHydrationStrategy<TWhen, TCanPrefetch>; | ||
| export type HydrateWhen = SolidHydrationStrategy | (() => SolidHydrationStrategy); | ||
| type HydrateCommonOptions = { | ||
| when: HydrateWhen; | ||
| fallback?: JSX.Element; | ||
| onHydrated?: () => void; | ||
| }; | ||
| export type HydrateOptions = (HydrateCommonOptions & { | ||
| prefetch?: never; | ||
| split?: boolean; | ||
| }) | (HydrateCommonOptions & { | ||
| prefetch: HydrationPrefetchStrategy; | ||
| split?: true; | ||
| }) | (HydrateCommonOptions & { | ||
| prefetch: HydrationPrefetchFunction; | ||
| split?: boolean; | ||
| }); | ||
| export type HydrateProps = HydrateOptions & { | ||
| children: JSX.Element; | ||
| }; | ||
| export type InternalHydrateProps = HydrateProps & { | ||
| h?: string; | ||
| p?: () => Promise<void>; | ||
| }; | ||
| export declare function Hydrate(props: HydrateProps): JSX.Element; |
| import { GenericHydrate } from "./GenericHydrate.js"; | ||
| import { createComponent } from "@solidjs/web"; | ||
| //#region src/Hydrate.tsx | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function Hydrate(props) { | ||
| if (typeof props.when === "function" || typeof props.prefetch === "function") return createComponent(GenericHydrate, props); | ||
| return props.when._h(props); | ||
| } | ||
| //#endregion | ||
| export { Hydrate }; | ||
| //# sourceMappingURL=Hydrate.js.map |
| {"version":3,"file":"Hydrate.js","names":["GenericHydrate","HydrationStrategy","CoreHydrationStrategy","HydrationPrefetchFunction","HydrationPrefetchStrategy","HydrationWhen","JSX","HydrationInteractionEvent","HydrationInteractionEvents","HydrationPrefetchContext","HydrationPrefetchWaitReason","SolidHydrationStrategy","TWhen","TCanPrefetch","_h","props","HydrateProps","Element","HydrateWhen","HydrateCommonOptions","when","fallback","onHydrated","HydrateOptions","prefetch","split","children","InternalHydrateProps","h","p","Promise","Hydrate","_$createComponent"],"sources":["../../src/Hydrate.tsx"],"sourcesContent":["import { GenericHydrate } from './GenericHydrate'\nimport type {\n HydrationStrategy as CoreHydrationStrategy,\n HydrationPrefetchFunction,\n HydrationPrefetchStrategy,\n HydrationWhen,\n} from '@tanstack/start-client-core/hydration'\nimport type { JSX } from '@solidjs/web'\n\nexport type {\n HydrationInteractionEvent,\n HydrationInteractionEvents,\n HydrationPrefetchContext,\n HydrationPrefetchFunction,\n HydrationPrefetchStrategy,\n HydrationPrefetchWaitReason,\n HydrationWhen,\n} from '@tanstack/start-client-core/hydration'\n\nexport type SolidHydrationStrategy<\n TWhen extends HydrationWhen = HydrationWhen,\n TCanPrefetch extends boolean = boolean,\n> = CoreHydrationStrategy<TWhen, TCanPrefetch> & {\n _h: (props: HydrateProps) => JSX.Element\n}\n\nexport type HydrationStrategy<\n TWhen extends HydrationWhen = HydrationWhen,\n TCanPrefetch extends boolean = boolean,\n> = SolidHydrationStrategy<TWhen, TCanPrefetch>\n\nexport type HydrateWhen =\n | SolidHydrationStrategy\n | (() => SolidHydrationStrategy)\n\ntype HydrateCommonOptions = {\n when: HydrateWhen\n fallback?: JSX.Element\n onHydrated?: () => void\n}\n\nexport type HydrateOptions =\n | (HydrateCommonOptions & {\n prefetch?: never\n split?: boolean\n })\n | (HydrateCommonOptions & {\n prefetch: HydrationPrefetchStrategy\n split?: true\n })\n | (HydrateCommonOptions & {\n prefetch: HydrationPrefetchFunction\n split?: boolean\n })\n\nexport type HydrateProps = HydrateOptions & {\n children: JSX.Element\n}\n\nexport type InternalHydrateProps = HydrateProps & {\n h?: string\n p?: () => Promise<void>\n}\n\n/* @__NO_SIDE_EFFECTS__ */\nexport function Hydrate(props: HydrateProps) {\n if (\n typeof props.when === 'function' ||\n typeof props.prefetch === 'function'\n ) {\n return <GenericHydrate {...(props as InternalHydrateProps)} />\n }\n\n return props.when._h(props)\n}\n"],"mappings":";;;;AAiEA,SAAgB+B,QAAQhB,OAAqB;CAC3C,IACE,OAAOA,MAAMK,SAAS,cACtB,OAAOL,MAAMS,aAAa,YAE1B,OAAAQ,gBAAQhC,gBAAoBe,KAA6B;CAG3D,OAAOA,MAAMK,KAAKN,GAAGC,KAAK;AAC5B"} |
| export { condition, interaction, media } from './hydration/generic.js'; | ||
| export { idle } from './hydration/idle.js'; | ||
| export { load } from './hydration/load.js'; | ||
| export { never } from './hydration/never.js'; | ||
| export { visible } from './hydration/visible.js'; | ||
| export type { HydrationCondition, HydrationInteractionEvent, HydrationInteractionEvents, IdleHydrationOptions, HydrationPrefetchContext, HydrationPrefetchFunction, HydrationPrefetchWhen, HydrationPrefetchStrategy, HydrationPrefetchWaitReason, HydrationStrategyTypes, HydrationWhen, VisibleHydrationOptions, } from '@tanstack/start-client-core/hydration'; | ||
| export type { HydrationStrategy, SolidHydrationStrategy } from './Hydrate.js'; |
| import { condition, interaction, media } from "./hydration/generic.js"; | ||
| import { idle } from "./hydration/idle.js"; | ||
| import { load } from "./hydration/load.js"; | ||
| import { never } from "./hydration/never.js"; | ||
| import { visible } from "./hydration/visible.js"; | ||
| export { condition, idle, interaction, load, media, never, visible }; |
| import { HydrationCondition, HydrationInteractionEvents, HydrationPrefetchStrategy } from '@tanstack/start-client-core/hydration'; | ||
| import { SolidHydrationStrategy } from '../Hydrate.js'; | ||
| export declare function media(query: string): SolidHydrationStrategy<'media', true> & HydrationPrefetchStrategy<'media'>; | ||
| export declare function condition(condition: HydrationCondition): SolidHydrationStrategy<'condition', false>; | ||
| export declare function interaction(options?: { | ||
| events?: HydrationInteractionEvents; | ||
| }): SolidHydrationStrategy<'interaction', true> & HydrationPrefetchStrategy<'interaction'>; |
| import { GenericHydrate } from "../GenericHydrate.js"; | ||
| import { condition, interaction, media, withHydrationRenderer } from "@tanstack/start-client-core/hydration"; | ||
| //#region src/hydration/generic.ts | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function media$1(query) { | ||
| return /* @__PURE__ */ withHydrationRenderer(media(query), GenericHydrate); | ||
| } | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function condition$1(condition$2) { | ||
| return /* @__PURE__ */ withHydrationRenderer(condition(condition$2), GenericHydrate); | ||
| } | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function interaction$1(options) { | ||
| return /* @__PURE__ */ withHydrationRenderer(interaction(options), GenericHydrate); | ||
| } | ||
| //#endregion | ||
| export { condition$1 as condition, interaction$1 as interaction, media$1 as media }; | ||
| //# sourceMappingURL=generic.js.map |
| {"version":3,"file":"generic.js","names":[],"sources":["../../../src/hydration/generic.ts"],"sourcesContent":["import {\n condition as coreCondition,\n interaction as coreInteraction,\n media as coreMedia,\n withHydrationRenderer,\n} from '@tanstack/start-client-core/hydration'\nimport { GenericHydrate } from '../GenericHydrate'\nimport type {\n HydrationCondition,\n HydrationInteractionEvents,\n HydrationPrefetchStrategy,\n} from '@tanstack/start-client-core/hydration'\nimport type { SolidHydrationStrategy } from '../Hydrate'\n\n/* @__NO_SIDE_EFFECTS__ */\nexport function media(\n query: string,\n): SolidHydrationStrategy<'media', true> & HydrationPrefetchStrategy<'media'> {\n return /* @__PURE__ */ withHydrationRenderer(coreMedia(query), GenericHydrate)\n}\n\n/* @__NO_SIDE_EFFECTS__ */\nexport function condition(\n condition: HydrationCondition,\n): SolidHydrationStrategy<'condition', false> {\n return /* @__PURE__ */ withHydrationRenderer(\n coreCondition(condition),\n GenericHydrate,\n )\n}\n\n/* @__NO_SIDE_EFFECTS__ */\nexport function interaction(options?: {\n events?: HydrationInteractionEvents\n}): SolidHydrationStrategy<'interaction', true> &\n HydrationPrefetchStrategy<'interaction'> {\n return /* @__PURE__ */ withHydrationRenderer(\n coreInteraction(options),\n GenericHydrate,\n )\n}\n"],"mappings":";;;;AAeA,SAAgB,QACd,OAC4E;CAC5E,OAAuB,sCAAsB,MAAU,KAAK,GAAG,cAAc;AAC/E;;AAGA,SAAgB,YACd,aAC4C;CAC5C,OAAuB,sCACrB,UAAc,WAAS,GACvB,cACF;AACF;;AAGA,SAAgB,cAAY,SAGe;CACzC,OAAuB,sCACrB,YAAgB,OAAO,GACvB,cACF;AACF"} |
| import { HydrationPrefetchStrategy, IdleHydrationOptions } from '@tanstack/start-client-core/hydration'; | ||
| import { SolidHydrationStrategy } from '../Hydrate.js'; | ||
| export declare function idle(options?: IdleHydrationOptions): SolidHydrationStrategy<'idle', true> & HydrationPrefetchStrategy<'idle'>; |
| import { GenericHydrate } from "../GenericHydrate.js"; | ||
| import { idle, withHydrationRenderer } from "@tanstack/start-client-core/hydration"; | ||
| //#region src/hydration/idle.ts | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function idle$1(options = {}) { | ||
| return /* @__PURE__ */ withHydrationRenderer(idle(options), GenericHydrate); | ||
| } | ||
| //#endregion | ||
| export { idle$1 as idle }; | ||
| //# sourceMappingURL=idle.js.map |
| {"version":3,"file":"idle.js","names":[],"sources":["../../../src/hydration/idle.ts"],"sourcesContent":["import {\n idle as coreIdle,\n withHydrationRenderer,\n} from '@tanstack/start-client-core/hydration'\nimport { GenericHydrate } from '../GenericHydrate'\nimport type {\n HydrationPrefetchStrategy,\n IdleHydrationOptions,\n} from '@tanstack/start-client-core/hydration'\nimport type { SolidHydrationStrategy } from '../Hydrate'\n\n/* @__NO_SIDE_EFFECTS__ */\nexport function idle(\n options: IdleHydrationOptions = {},\n): SolidHydrationStrategy<'idle', true> & HydrationPrefetchStrategy<'idle'> {\n return /* @__PURE__ */ withHydrationRenderer(\n coreIdle(options),\n GenericHydrate,\n )\n}\n"],"mappings":";;;;AAYA,SAAgB,OACd,UAAgC,CAAC,GACyC;CAC1E,OAAuB,sCACrB,KAAS,OAAO,GAChB,cACF;AACF"} |
| import { HydrationPrefetchStrategy } from '@tanstack/start-client-core/hydration'; | ||
| import { SolidHydrationStrategy } from '../Hydrate.js'; | ||
| export declare function load(): SolidHydrationStrategy<'load', true> & HydrationPrefetchStrategy<'load'>; |
| import { GenericHydrate } from "../GenericHydrate.js"; | ||
| import { load, withHydrationRenderer } from "@tanstack/start-client-core/hydration"; | ||
| //#region src/hydration/load.tsx | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function load$1() { | ||
| return /* @__PURE__ */ withHydrationRenderer(load(), GenericHydrate); | ||
| } | ||
| //#endregion | ||
| export { load$1 as load }; | ||
| //# sourceMappingURL=load.js.map |
| {"version":3,"file":"load.js","names":["load","coreLoad","withHydrationRenderer","GenericHydrate","HydrationPrefetchStrategy","SolidHydrationStrategy"],"sources":["../../../src/hydration/load.tsx"],"sourcesContent":["import {\n load as coreLoad,\n withHydrationRenderer,\n} from '@tanstack/start-client-core/hydration'\nimport { GenericHydrate } from '../GenericHydrate'\nimport type { HydrationPrefetchStrategy } from '@tanstack/start-client-core/hydration'\nimport type { SolidHydrationStrategy } from '../Hydrate'\n\n/* @__NO_SIDE_EFFECTS__ */\nexport function load(): SolidHydrationStrategy<'load', true> &\n HydrationPrefetchStrategy<'load'> {\n return /* @__PURE__ */ withHydrationRenderer(coreLoad(), GenericHydrate)\n}\n"],"mappings":";;;;AASA,SAAgBA,SACoB;CAClC,OAAuBE,sCAAsBD,KAAS,GAAGE,cAAc;AACzE"} |
| import { SolidHydrationStrategy } from '../Hydrate.js'; | ||
| export declare function never(): SolidHydrationStrategy<'never', false>; |
| import { GenericHydrate } from "../GenericHydrate.js"; | ||
| import { never, withHydrationRenderer } from "@tanstack/start-client-core/hydration"; | ||
| //#region src/hydration/never.ts | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function never$1() { | ||
| return /* @__PURE__ */ withHydrationRenderer(never(), GenericHydrate); | ||
| } | ||
| //#endregion | ||
| export { never$1 as never }; | ||
| //# sourceMappingURL=never.js.map |
| {"version":3,"file":"never.js","names":[],"sources":["../../../src/hydration/never.ts"],"sourcesContent":["import {\n never as coreNever,\n withHydrationRenderer,\n} from '@tanstack/start-client-core/hydration'\nimport { GenericHydrate } from '../GenericHydrate'\nimport type { SolidHydrationStrategy } from '../Hydrate'\n\n/* @__NO_SIDE_EFFECTS__ */\nexport function never(): SolidHydrationStrategy<'never', false> {\n return /* @__PURE__ */ withHydrationRenderer(coreNever(), GenericHydrate)\n}\n"],"mappings":";;;;AAQA,SAAgB,UAAgD;CAC9D,OAAuB,sCAAsB,MAAU,GAAG,cAAc;AAC1E"} |
| import { HydrationPrefetchStrategy, VisibleHydrationOptions } from '@tanstack/start-client-core/hydration'; | ||
| import { SolidHydrationStrategy } from '../Hydrate.js'; | ||
| export declare function visible(options?: VisibleHydrationOptions): SolidHydrationStrategy<'visible', true> & HydrationPrefetchStrategy<'visible'>; |
| import { GenericHydrate } from "../GenericHydrate.js"; | ||
| import { visible, withHydrationRenderer } from "@tanstack/start-client-core/hydration"; | ||
| //#region src/hydration/visible.tsx | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function visible$1(options) { | ||
| return /* @__PURE__ */ withHydrationRenderer(visible(options), GenericHydrate); | ||
| } | ||
| //#endregion | ||
| export { visible$1 as visible }; | ||
| //# sourceMappingURL=visible.js.map |
| {"version":3,"file":"visible.js","names":["visible","coreVisible","withHydrationRenderer","GenericHydrate","HydrationPrefetchStrategy","VisibleHydrationOptions","SolidHydrationStrategy","options"],"sources":["../../../src/hydration/visible.tsx"],"sourcesContent":["import {\n visible as coreVisible,\n withHydrationRenderer,\n} from '@tanstack/start-client-core/hydration'\nimport { GenericHydrate } from '../GenericHydrate'\nimport type {\n HydrationPrefetchStrategy,\n VisibleHydrationOptions,\n} from '@tanstack/start-client-core/hydration'\nimport type { SolidHydrationStrategy } from '../Hydrate'\n\n/* @__NO_SIDE_EFFECTS__ */\nexport function visible(\n options?: VisibleHydrationOptions,\n): SolidHydrationStrategy<'visible', true> &\n HydrationPrefetchStrategy<'visible'> {\n return /* @__PURE__ */ withHydrationRenderer(\n coreVisible(options),\n GenericHydrate,\n )\n}\n"],"mappings":";;;;AAYA,SAAgBA,UACdO,SAEqC;CACrC,OAAuBL,sCACrBD,QAAYM,OAAO,GACnBJ,cACF;AACF"} |
| export {}; |
| import * as Solid from 'solid-js' | ||
| import { Dynamic } from '@solidjs/web' | ||
| import { useHydrated } from '@tanstack/solid-router' | ||
| import { isServer } from '@tanstack/router-core/isServer' | ||
| import { | ||
| hydrateIdAttribute, | ||
| hydrateWhenAttribute, | ||
| } from '@tanstack/start-client-core/hydration/constants' | ||
| import { | ||
| createResolvedGate, | ||
| getFallbackHtml, | ||
| getOrCreateGate, | ||
| onGateResolve, | ||
| releaseGate, | ||
| runHydrationStrategyCleanup, | ||
| saveFallbackHtml, | ||
| waitForHydrationPrefetchStrategy, | ||
| } from '@tanstack/start-client-core/hydration/runtime' | ||
| import { listenForDelegatedHydrationIntent } from '@tanstack/start-client-core/hydration' | ||
| import type { | ||
| HydrationRuntimeContext, | ||
| HydrationStrategy, | ||
| HydrationWhen, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import type { HydrationGateRecord } from '@tanstack/start-client-core/hydration/runtime' | ||
| import type { InternalHydrateProps } from './Hydrate' | ||
| import type { DynamicProps, JSX } from '@solidjs/web' | ||
| type HydrationFallbackDynamicProps = DynamicProps<'div'> | ||
| type HydrationMarkerDynamicProps = DynamicProps<'div'> & { | ||
| [hydrateIdAttribute]: string | ||
| [hydrateWhenAttribute]: HydrationWhen | ||
| [key: `data-${string}`]: string | undefined | ||
| } | ||
| type PrefetchController = { | ||
| abortController: AbortController | ||
| hydrationRequested: boolean | ||
| hydrationListeners: Set<() => void> | ||
| hydrationResolvePending: boolean | ||
| started: boolean | ||
| promise?: Promise<void> | ||
| } | ||
| const hydrateIdSelector = `[${hydrateIdAttribute}]` | ||
| const dynamicType = 'dynamic' | ||
| const dynamicHydrateStrategy = { | ||
| _t: dynamicType, | ||
| _d: () => true, | ||
| } satisfies HydrationStrategy<typeof dynamicType, false> | ||
| function shouldDeferHydration(strategy: HydrationStrategy) { | ||
| return strategy._d ? strategy._d() : strategy._t !== 'load' | ||
| } | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| function HydratedBoundary(props: { | ||
| id: string | ||
| onHydrated?: () => void | ||
| onStrategyHydrated?: (id: string) => void | ||
| children: JSX.Element | ||
| }) { | ||
| let didHydrate = false | ||
| Solid.createEffect( | ||
| () => true, | ||
| () => { | ||
| if (didHydrate) return | ||
| didHydrate = true | ||
| props.onHydrated?.() | ||
| props.onStrategyHydrated?.(props.id) | ||
| }, | ||
| ) | ||
| return props.children | ||
| } | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| export function GenericHydrate(props: InternalHydrateProps) { | ||
| const when = props.when | ||
| const dynamicHydrate = typeof when === 'function' | ||
| const initialHydrateStrategy: HydrationStrategy = dynamicHydrate | ||
| ? // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| (isServer ?? typeof window === 'undefined') | ||
| ? dynamicHydrateStrategy | ||
| : when() | ||
| : when | ||
| const markerHydrateType: HydrationWhen = dynamicHydrate | ||
| ? dynamicType | ||
| : initialHydrateStrategy._t! | ||
| const prefetchStrategy = () => props.prefetch | ||
| const hydrated = useHydrated() | ||
| const uniqueId = Solid.createUniqueId() | ||
| const id = props.h ? `${props.h}${uniqueId}` : uniqueId | ||
| const initialHydrateType = initialHydrateStrategy._t! | ||
| const shouldPreserveServerHTML = | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| (isServer ?? typeof window === 'undefined') || !hydrated() | ||
| const shouldDeferInitialHydration = | ||
| !hydrated() && shouldDeferHydration(initialHydrateStrategy) | ||
| const gate: HydrationGateRecord = | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| (isServer ?? typeof window === 'undefined') | ||
| ? createResolvedGate(id, initialHydrateType) | ||
| : getOrCreateGate(id, initialHydrateType) | ||
| const [ready, setReady] = Solid.createSignal( | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| (isServer ?? typeof window === 'undefined') || | ||
| (!shouldDeferInitialHydration && initialHydrateType !== 'never'), | ||
| ) | ||
| const [prefetchError, setPrefetchError] = Solid.createSignal<unknown>() | ||
| const controller: PrefetchController = { | ||
| abortController: new AbortController(), | ||
| hydrationRequested: false, | ||
| hydrationListeners: new Set<() => void>(), | ||
| hydrationResolvePending: false, | ||
| started: false, | ||
| } | ||
| let didPrefetch = false | ||
| let didClearPreservedServerHTML = false | ||
| let markerElement: HTMLDivElement | undefined | ||
| let preservedServerChildNodes: Array<ChildNode> | undefined | ||
| let cleanupHydrationRuntime = () => {} | ||
| let didReleaseGate = false | ||
| const clearPreservedServerHTML = () => { | ||
| if ( | ||
| !shouldPreserveServerHTML || | ||
| !shouldDeferInitialHydration || | ||
| !markerElement || | ||
| !preservedServerChildNodes || | ||
| didClearPreservedServerHTML | ||
| ) { | ||
| return | ||
| } | ||
| didClearPreservedServerHTML = true | ||
| for (const child of preservedServerChildNodes) { | ||
| child.remove() | ||
| } | ||
| } | ||
| if ( | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| !(isServer ?? typeof window === 'undefined') && | ||
| initialHydrateType !== 'never' && | ||
| (!shouldDeferInitialHydration || | ||
| !shouldDeferHydration(initialHydrateStrategy)) | ||
| ) { | ||
| gate.resolve() | ||
| } | ||
| const onHydrate = (listener: () => void) => { | ||
| if (controller.hydrationRequested) { | ||
| listener() | ||
| return () => {} | ||
| } | ||
| controller.hydrationListeners.add(listener) | ||
| return () => { | ||
| controller.hydrationListeners.delete(listener) | ||
| } | ||
| } | ||
| const requestHydration = () => { | ||
| if (!controller.hydrationRequested) { | ||
| controller.hydrationRequested = true | ||
| controller.hydrationListeners.forEach((listener) => listener()) | ||
| controller.hydrationListeners.clear() | ||
| } | ||
| if (!controller.promise) { | ||
| resolveGate() | ||
| return | ||
| } | ||
| if (controller.hydrationResolvePending) return | ||
| controller.hydrationResolvePending = true | ||
| controller.promise.then( | ||
| () => resolveGate(), | ||
| (error) => { | ||
| if (!controller.abortController.signal.aborted) { | ||
| setPrefetchError(() => error) | ||
| } | ||
| }, | ||
| ) | ||
| } | ||
| const resolveGate = gate.resolve | ||
| Solid.onCleanup(() => { | ||
| controller.abortController.abort() | ||
| controller.hydrationListeners.clear() | ||
| cleanupHydrationRuntime() | ||
| if (!didReleaseGate) { | ||
| didReleaseGate = true | ||
| releaseGate(gate) | ||
| } | ||
| }) | ||
| Solid.createEffect( | ||
| () => { | ||
| const currentHydrateStrategy = initialHydrateStrategy | ||
| const currentPrefetchStrategy = prefetchStrategy() | ||
| const currentHydrateType = currentHydrateStrategy._t! | ||
| return { | ||
| currentHydrateStrategy, | ||
| currentPrefetchStrategy, | ||
| currentHydrateType, | ||
| } | ||
| }, | ||
| ({ | ||
| currentHydrateStrategy, | ||
| currentPrefetchStrategy, | ||
| currentHydrateType, | ||
| }) => { | ||
| gate.when = currentHydrateType | ||
| for (const element of document.querySelectorAll<HTMLDivElement>( | ||
| hydrateIdSelector, | ||
| )) { | ||
| if (element.getAttribute(hydrateIdAttribute) === id) { | ||
| markerElement = element | ||
| preservedServerChildNodes ??= Array.from(element.childNodes) | ||
| saveFallbackHtml(id, element) | ||
| break | ||
| } | ||
| } | ||
| if ( | ||
| currentHydrateType === 'never' && | ||
| !shouldPreserveServerHTML && | ||
| markerElement | ||
| ) { | ||
| markerElement.replaceChildren() | ||
| } | ||
| if (currentPrefetchStrategy && !controller.started) { | ||
| controller.started = true | ||
| const preload = () => props.p?.() ?? Promise.resolve() | ||
| if (typeof currentPrefetchStrategy === 'function') { | ||
| const promise = Promise.resolve() | ||
| .then(() => | ||
| currentPrefetchStrategy({ | ||
| element: markerElement ?? null, | ||
| signal: controller.abortController.signal, | ||
| preload, | ||
| waitFor: (strategy) => | ||
| waitForHydrationPrefetchStrategy(strategy, { | ||
| element: markerElement ?? null, | ||
| signal: controller.abortController.signal, | ||
| onHydrate, | ||
| }), | ||
| }), | ||
| ) | ||
| .then(() => undefined) | ||
| controller.promise = promise | ||
| promise.catch((error) => { | ||
| if (!controller.abortController.signal.aborted) { | ||
| setPrefetchError(() => error) | ||
| } | ||
| }) | ||
| } else if (props.p) { | ||
| const currentStrategy = currentPrefetchStrategy | ||
| const prefetch = () => { | ||
| if (didPrefetch) return | ||
| didPrefetch = true | ||
| void preload() | ||
| } | ||
| const cleanupPrefetch = runHydrationStrategyCleanup( | ||
| currentStrategy._s?.({ | ||
| element: markerElement ?? null, | ||
| prefetch, | ||
| }), | ||
| ) | ||
| if (cleanupPrefetch) Solid.onCleanup(cleanupPrefetch) | ||
| } | ||
| } | ||
| if ( | ||
| currentHydrateType !== 'never' && | ||
| (!shouldDeferInitialHydration || | ||
| !shouldDeferHydration(currentHydrateStrategy)) | ||
| ) { | ||
| gate.resolve() | ||
| setReady(true) | ||
| } | ||
| const cleanups: Array<() => void> = [] | ||
| let removeResolveListener = () => {} | ||
| let disposed = false | ||
| const resolveBoundary = () => { | ||
| setReady(true) | ||
| } | ||
| const cleanup = () => { | ||
| if (disposed) return | ||
| disposed = true | ||
| if (gate.resolve === requestHydration) { | ||
| gate.resolve = resolveGate | ||
| } | ||
| removeResolveListener() | ||
| cleanups.forEach((fn) => fn()) | ||
| } | ||
| cleanupHydrationRuntime = cleanup | ||
| const addCleanup = (fn: void | (() => void)) => { | ||
| if (!fn) return | ||
| if (disposed || gate.resolved) { | ||
| fn() | ||
| return | ||
| } | ||
| cleanups.push(fn) | ||
| } | ||
| Solid.onCleanup(cleanup) | ||
| removeResolveListener = onGateResolve(gate, () => { | ||
| cleanup() | ||
| resolveBoundary() | ||
| }) | ||
| if ( | ||
| gate.resolved || | ||
| !shouldDeferInitialHydration || | ||
| currentHydrateType === 'never' | ||
| ) { | ||
| if (gate.resolved) resolveBoundary() | ||
| return | ||
| } | ||
| gate.resolve = requestHydration | ||
| const context: HydrationRuntimeContext = { | ||
| element: markerElement ?? null, | ||
| gate, | ||
| } | ||
| addCleanup( | ||
| runHydrationStrategyCleanup(currentHydrateStrategy._s?.(context)), | ||
| ) | ||
| if (currentHydrateStrategy._t !== 'interaction') { | ||
| addCleanup( | ||
| runHydrationStrategyCleanup( | ||
| markerElement | ||
| ? listenForDelegatedHydrationIntent(markerElement, context) | ||
| : undefined, | ||
| ), | ||
| ) | ||
| } | ||
| }, | ||
| ) | ||
| // prettier-ignore | ||
| Solid.createRenderEffect( | ||
| () => | ||
| !( | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| (isServer ?? typeof window === 'undefined') || | ||
| gate.resolved || | ||
| initialHydrateStrategy._t === 'never' || | ||
| shouldDeferHydration(initialHydrateStrategy) | ||
| ), | ||
| (shouldResolve) => { | ||
| if (shouldResolve) { | ||
| gate.resolve() | ||
| } | ||
| }, | ||
| ) | ||
| const markerAttributes = | ||
| markerHydrateType === dynamicType | ||
| ? undefined | ||
| : initialHydrateStrategy._a?.() | ||
| const markerProps: HydrationMarkerDynamicProps = { | ||
| component: 'div', | ||
| [hydrateIdAttribute]: id, | ||
| [hydrateWhenAttribute]: markerHydrateType, | ||
| ...markerAttributes, | ||
| } | ||
| const fallback = () => { | ||
| if (!shouldPreserveServerHTML) return props.fallback ?? null | ||
| const html = getFallbackHtml(id) | ||
| if (!html) return null | ||
| const fallbackProps: HydrationFallbackDynamicProps = { | ||
| component: 'div', | ||
| style: { display: 'contents' }, | ||
| innerHTML: html, | ||
| } | ||
| return <Dynamic {...fallbackProps} /> | ||
| } | ||
| const hydratedChildren = () => { | ||
| const children = ( | ||
| <HydratedBoundary | ||
| id={id} | ||
| onHydrated={props.onHydrated} | ||
| onStrategyHydrated={(id) => { | ||
| clearPreservedServerHTML() | ||
| markerElement?.removeAttribute(hydrateWhenAttribute) | ||
| initialHydrateStrategy._o?.(id) | ||
| }} | ||
| > | ||
| {props.children} | ||
| </HydratedBoundary> | ||
| ) | ||
| return children | ||
| } | ||
| return ( | ||
| <Dynamic {...markerProps}> | ||
| {(() => { | ||
| const error = prefetchError() | ||
| if (error) throw error | ||
| return null | ||
| })()} | ||
| {initialHydrateType === 'never' && !shouldPreserveServerHTML ? ( | ||
| (props.fallback ?? null) | ||
| ) : ( | ||
| <Solid.Loading fallback={fallback()}> | ||
| <Solid.Show when={ready()} fallback={fallback()}> | ||
| {hydratedChildren()} | ||
| </Solid.Show> | ||
| </Solid.Loading> | ||
| )} | ||
| </Dynamic> | ||
| ) | ||
| } |
| import { GenericHydrate } from './GenericHydrate' | ||
| import type { | ||
| HydrationStrategy as CoreHydrationStrategy, | ||
| HydrationPrefetchFunction, | ||
| HydrationPrefetchStrategy, | ||
| HydrationWhen, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import type { JSX } from '@solidjs/web' | ||
| export type { | ||
| HydrationInteractionEvent, | ||
| HydrationInteractionEvents, | ||
| HydrationPrefetchContext, | ||
| HydrationPrefetchFunction, | ||
| HydrationPrefetchStrategy, | ||
| HydrationPrefetchWaitReason, | ||
| HydrationWhen, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| export type SolidHydrationStrategy< | ||
| TWhen extends HydrationWhen = HydrationWhen, | ||
| TCanPrefetch extends boolean = boolean, | ||
| > = CoreHydrationStrategy<TWhen, TCanPrefetch> & { | ||
| _h: (props: HydrateProps) => JSX.Element | ||
| } | ||
| export type HydrationStrategy< | ||
| TWhen extends HydrationWhen = HydrationWhen, | ||
| TCanPrefetch extends boolean = boolean, | ||
| > = SolidHydrationStrategy<TWhen, TCanPrefetch> | ||
| export type HydrateWhen = | ||
| | SolidHydrationStrategy | ||
| | (() => SolidHydrationStrategy) | ||
| type HydrateCommonOptions = { | ||
| when: HydrateWhen | ||
| fallback?: JSX.Element | ||
| onHydrated?: () => void | ||
| } | ||
| export type HydrateOptions = | ||
| | (HydrateCommonOptions & { | ||
| prefetch?: never | ||
| split?: boolean | ||
| }) | ||
| | (HydrateCommonOptions & { | ||
| prefetch: HydrationPrefetchStrategy | ||
| split?: true | ||
| }) | ||
| | (HydrateCommonOptions & { | ||
| prefetch: HydrationPrefetchFunction | ||
| split?: boolean | ||
| }) | ||
| export type HydrateProps = HydrateOptions & { | ||
| children: JSX.Element | ||
| } | ||
| export type InternalHydrateProps = HydrateProps & { | ||
| h?: string | ||
| p?: () => Promise<void> | ||
| } | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| export function Hydrate(props: HydrateProps) { | ||
| if ( | ||
| typeof props.when === 'function' || | ||
| typeof props.prefetch === 'function' | ||
| ) { | ||
| return <GenericHydrate {...(props as InternalHydrateProps)} /> | ||
| } | ||
| return props.when._h(props) | ||
| } |
| export { condition, interaction, media } from './hydration/generic' | ||
| export { idle } from './hydration/idle' | ||
| export { load } from './hydration/load' | ||
| export { never } from './hydration/never' | ||
| export { visible } from './hydration/visible' | ||
| export type { | ||
| HydrationCondition, | ||
| HydrationInteractionEvent, | ||
| HydrationInteractionEvents, | ||
| IdleHydrationOptions, | ||
| HydrationPrefetchContext, | ||
| HydrationPrefetchFunction, | ||
| HydrationPrefetchWhen, | ||
| HydrationPrefetchStrategy, | ||
| HydrationPrefetchWaitReason, | ||
| HydrationStrategyTypes, | ||
| HydrationWhen, | ||
| VisibleHydrationOptions, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| export type { HydrationStrategy, SolidHydrationStrategy } from './Hydrate' |
| import { | ||
| condition as coreCondition, | ||
| interaction as coreInteraction, | ||
| media as coreMedia, | ||
| withHydrationRenderer, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import { GenericHydrate } from '../GenericHydrate' | ||
| import type { | ||
| HydrationCondition, | ||
| HydrationInteractionEvents, | ||
| HydrationPrefetchStrategy, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import type { SolidHydrationStrategy } from '../Hydrate' | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| export function media( | ||
| query: string, | ||
| ): SolidHydrationStrategy<'media', true> & HydrationPrefetchStrategy<'media'> { | ||
| return /* @__PURE__ */ withHydrationRenderer(coreMedia(query), GenericHydrate) | ||
| } | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| export function condition( | ||
| condition: HydrationCondition, | ||
| ): SolidHydrationStrategy<'condition', false> { | ||
| return /* @__PURE__ */ withHydrationRenderer( | ||
| coreCondition(condition), | ||
| GenericHydrate, | ||
| ) | ||
| } | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| export function interaction(options?: { | ||
| events?: HydrationInteractionEvents | ||
| }): SolidHydrationStrategy<'interaction', true> & | ||
| HydrationPrefetchStrategy<'interaction'> { | ||
| return /* @__PURE__ */ withHydrationRenderer( | ||
| coreInteraction(options), | ||
| GenericHydrate, | ||
| ) | ||
| } |
| import { | ||
| idle as coreIdle, | ||
| withHydrationRenderer, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import { GenericHydrate } from '../GenericHydrate' | ||
| import type { | ||
| HydrationPrefetchStrategy, | ||
| IdleHydrationOptions, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import type { SolidHydrationStrategy } from '../Hydrate' | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| export function idle( | ||
| options: IdleHydrationOptions = {}, | ||
| ): SolidHydrationStrategy<'idle', true> & HydrationPrefetchStrategy<'idle'> { | ||
| return /* @__PURE__ */ withHydrationRenderer( | ||
| coreIdle(options), | ||
| GenericHydrate, | ||
| ) | ||
| } |
| import { | ||
| load as coreLoad, | ||
| withHydrationRenderer, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import { GenericHydrate } from '../GenericHydrate' | ||
| import type { HydrationPrefetchStrategy } from '@tanstack/start-client-core/hydration' | ||
| import type { SolidHydrationStrategy } from '../Hydrate' | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| export function load(): SolidHydrationStrategy<'load', true> & | ||
| HydrationPrefetchStrategy<'load'> { | ||
| return /* @__PURE__ */ withHydrationRenderer(coreLoad(), GenericHydrate) | ||
| } |
| import { | ||
| never as coreNever, | ||
| withHydrationRenderer, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import { GenericHydrate } from '../GenericHydrate' | ||
| import type { SolidHydrationStrategy } from '../Hydrate' | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| export function never(): SolidHydrationStrategy<'never', false> { | ||
| return /* @__PURE__ */ withHydrationRenderer(coreNever(), GenericHydrate) | ||
| } |
| import { | ||
| visible as coreVisible, | ||
| withHydrationRenderer, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import { GenericHydrate } from '../GenericHydrate' | ||
| import type { | ||
| HydrationPrefetchStrategy, | ||
| VisibleHydrationOptions, | ||
| } from '@tanstack/start-client-core/hydration' | ||
| import type { SolidHydrationStrategy } from '../Hydrate' | ||
| /* @__NO_SIDE_EFFECTS__ */ | ||
| export function visible( | ||
| options?: VisibleHydrationOptions, | ||
| ): SolidHydrationStrategy<'visible', true> & | ||
| HydrationPrefetchStrategy<'visible'> { | ||
| return /* @__PURE__ */ withHydrationRenderer( | ||
| coreVisible(options), | ||
| GenericHydrate, | ||
| ) | ||
| } |
| import { expectTypeOf, test } from 'vitest' | ||
| import { visible } from '../hydration' | ||
| import { Hydrate } from '../Hydrate' | ||
| import type { | ||
| HydrateOptions, | ||
| HydrateProps, | ||
| HydrationPrefetchFunction, | ||
| HydrationPrefetchStrategy, | ||
| HydrationStrategy, | ||
| } from '../Hydrate' | ||
| import type { HydrationStrategy as CoreHydrationStrategy } from '@tanstack/start-client-core/hydration' | ||
| import type { JSX } from '@solidjs/web' | ||
| type CommonHydrateProps = { | ||
| fallback?: JSX.Element | ||
| onHydrated?: () => void | ||
| children: JSX.Element | ||
| } | ||
| type SplitHydrateProps = CommonHydrateProps & { | ||
| when: HydrationStrategy | (() => HydrationStrategy) | ||
| prefetch?: never | ||
| split?: boolean | ||
| } | ||
| type PrefetchHydrateProps = CommonHydrateProps & { | ||
| when: HydrationStrategy | (() => HydrationStrategy) | ||
| prefetch: HydrationPrefetchStrategy | ||
| split?: true | ||
| } | ||
| type FunctionPrefetchHydrateProps = CommonHydrateProps & { | ||
| when: HydrationStrategy | (() => HydrationStrategy) | ||
| prefetch: HydrationPrefetchFunction | ||
| split?: boolean | ||
| } | ||
| test('Hydrate component accepts the public HydrateProps type', () => { | ||
| expectTypeOf(Hydrate).toBeFunction() | ||
| expectTypeOf(Hydrate).parameter(0).branded.toEqualTypeOf<HydrateProps>() | ||
| }) | ||
| test('HydrateOptions supports reusable spread props', () => { | ||
| const belowFoldProps = { | ||
| when: () => visible({ rootMargin: '800px' }), | ||
| } satisfies HydrateOptions | ||
| expectTypeOf(belowFoldProps).toMatchTypeOf<HydrateOptions>() | ||
| const withFunctionPrefetch = { | ||
| when: visible(), | ||
| split: false, | ||
| prefetch: (ctx) => { | ||
| expectTypeOf(ctx.element).toEqualTypeOf<Element | null>() | ||
| expectTypeOf(ctx.signal).toEqualTypeOf<AbortSignal>() | ||
| expectTypeOf(ctx.preload).returns.toEqualTypeOf<Promise<void>>() | ||
| expectTypeOf(ctx.waitFor).returns.toEqualTypeOf< | ||
| Promise<'prefetch' | 'hydrate' | 'abort'> | ||
| >() | ||
| }, | ||
| } satisfies HydrateOptions | ||
| expectTypeOf(withFunctionPrefetch).toMatchTypeOf<HydrateOptions>() | ||
| }) | ||
| test('Hydrate props are exact for strategy and prefetch forms', () => { | ||
| expectTypeOf< | ||
| Extract<HydrateProps, { prefetch?: never }> | ||
| >().branded.toEqualTypeOf<SplitHydrateProps>() | ||
| expectTypeOf< | ||
| Extract<HydrateProps, { prefetch: HydrationPrefetchStrategy }> | ||
| >().branded.toEqualTypeOf<PrefetchHydrateProps>() | ||
| expectTypeOf< | ||
| Extract<HydrateProps, { prefetch: HydrationPrefetchFunction }> | ||
| >().branded.toEqualTypeOf<FunctionPrefetchHydrateProps>() | ||
| }) | ||
| test('Hydrate requires a strategy', () => { | ||
| expectTypeOf<{ | ||
| when: HydrationStrategy | ||
| children: JSX.Element | ||
| }>().toMatchTypeOf<HydrateProps>() | ||
| expectTypeOf<{ | ||
| when: () => HydrationStrategy | ||
| children: JSX.Element | ||
| }>().toMatchTypeOf<HydrateProps>() | ||
| expectTypeOf<{ | ||
| children: JSX.Element | ||
| }>().not.toMatchTypeOf<HydrateProps>() | ||
| expectTypeOf<{ | ||
| when: () => true | ||
| children: JSX.Element | ||
| }>().not.toMatchTypeOf<HydrateProps>() | ||
| expectTypeOf<{ | ||
| when: false | ||
| children: JSX.Element | ||
| }>().not.toMatchTypeOf<HydrateProps>() | ||
| }) | ||
| test('Hydrate requires a framework-renderable strategy', () => { | ||
| expectTypeOf<CoreHydrationStrategy>().not.toMatchTypeOf<HydrationStrategy>() | ||
| expectTypeOf<ReturnType<typeof visible>>().toMatchTypeOf<HydrationStrategy>() | ||
| expectTypeOf<{ | ||
| when: CoreHydrationStrategy | ||
| children: JSX.Element | ||
| }>().not.toMatchTypeOf<HydrateProps>() | ||
| }) | ||
| test('Hydrate enforces prefetch only with split boundaries', () => { | ||
| expectTypeOf<{ | ||
| when: HydrationStrategy | ||
| prefetch: HydrationPrefetchStrategy | ||
| children: JSX.Element | ||
| }>().toMatchTypeOf<HydrateProps>() | ||
| expectTypeOf<{ | ||
| when: HydrationStrategy | ||
| prefetch: HydrationPrefetchStrategy | ||
| split: true | ||
| children: JSX.Element | ||
| }>().toMatchTypeOf<HydrateProps>() | ||
| expectTypeOf<{ | ||
| when: HydrationStrategy | ||
| prefetch: HydrationPrefetchStrategy | ||
| split: false | ||
| children: JSX.Element | ||
| }>().not.toMatchTypeOf<HydrateProps>() | ||
| expectTypeOf<{ | ||
| when: HydrationStrategy | ||
| prefetch: HydrationPrefetchFunction | ||
| split: false | ||
| children: JSX.Element | ||
| }>().toMatchTypeOf<HydrateProps>() | ||
| expectTypeOf<{ | ||
| when: HydrationStrategy | ||
| prefetch: HydrationPrefetchFunction | ||
| children: JSX.Element | ||
| }>().toMatchTypeOf<HydrateProps>() | ||
| }) |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"hydrateStart.js","names":[],"sources":["../../src/hydrateStart.ts"],"sourcesContent":["import { hydrateStart as coreHydrateStart } from '@tanstack/start-client-core/client'\nimport type { AnyRouter } from '@tanstack/router-core'\n\n/**\n * Solid-specific wrapper for hydrateStart that signals hydration completion\n */\nexport async function hydrateStart(): Promise<AnyRouter> {\n const router = await coreHydrateStart()\n // Signal that router hydration is complete so cleanup can happen if stream has ended\n window.$_TSR?.h()\n return router\n}\n"],"mappings":";;;;;AAMA,eAAsB,iBAAmC;CACvD,MAAM,SAAS,MAAM,cAAkB;AAEvC,QAAO,OAAO,GAAG;AACjB,QAAO"} | ||
| {"version":3,"file":"hydrateStart.js","names":[],"sources":["../../src/hydrateStart.ts"],"sourcesContent":["import { hydrateStart as coreHydrateStart } from '@tanstack/start-client-core/client'\nimport type { AnyRouter } from '@tanstack/router-core'\n\n/**\n * Solid-specific wrapper for hydrateStart that signals hydration completion\n */\nexport async function hydrateStart(): Promise<AnyRouter> {\n const router = await coreHydrateStart()\n // Signal that router hydration is complete so cleanup can happen if stream has ended\n window.$_TSR?.h()\n return router\n}\n"],"mappings":";;;;;AAMA,eAAsB,iBAAmC;CACvD,MAAM,SAAS,MAAM,aAAiB;CAEtC,OAAO,OAAO,EAAE;CAChB,OAAO;AACT"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"StartClient.js","names":["RouterProvider","AnyRouter","StartClient","props","router","_$createComponent"],"sources":["../../src/StartClient.tsx"],"sourcesContent":["import { RouterProvider } from '@tanstack/solid-router'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport function StartClient(props: { router: AnyRouter }) {\n return <RouterProvider router={props.router} />\n}\n"],"mappings":";;;AAGA,SAAgBE,YAAYC,OAA8B;AACxD,QAAAE,gBAAQL,gBAAc,EAAA,IAACI,SAAM;AAAA,SAAED,MAAMC;IAAM,CAAA"} | ||
| {"version":3,"file":"StartClient.js","names":["RouterProvider","AnyRouter","StartClient","props","router","_$createComponent"],"sources":["../../src/StartClient.tsx"],"sourcesContent":["import { RouterProvider } from '@tanstack/solid-router'\nimport type { AnyRouter } from '@tanstack/router-core'\n\nexport function StartClient(props: { router: AnyRouter }) {\n return <RouterProvider router={props.router} />\n}\n"],"mappings":";;;AAGA,SAAgBE,YAAYC,OAA8B;CACxD,OAAAE,gBAAQL,gBAAc,EAAA,IAACI,SAAM;EAAA,OAAED,MAAMC;CAAM,EAAA,CAAA;AAC7C"} |
+16
-4
| { | ||
| "name": "@tanstack/solid-start-client", | ||
| "version": "2.0.0-beta.19", | ||
| "version": "2.0.0-beta.20", | ||
| "description": "Modern and scalable routing for Solid applications", | ||
@@ -35,2 +35,14 @@ "author": "Tanner Linsley", | ||
| }, | ||
| "./hydration": { | ||
| "import": { | ||
| "types": "./dist/esm/hydration.d.ts", | ||
| "default": "./dist/esm/hydration.js" | ||
| } | ||
| }, | ||
| "./Hydrate": { | ||
| "import": { | ||
| "types": "./dist/esm/Hydrate.d.ts", | ||
| "default": "./dist/esm/Hydrate.js" | ||
| } | ||
| }, | ||
| "./package.json": "./package.json" | ||
@@ -47,5 +59,5 @@ }, | ||
| "dependencies": { | ||
| "@tanstack/router-core": "1.168.9", | ||
| "@tanstack/solid-router": "2.0.0-beta.19", | ||
| "@tanstack/start-client-core": "1.167.9" | ||
| "@tanstack/router-core": "1.171.8", | ||
| "@tanstack/solid-router": "2.0.0-beta.20", | ||
| "@tanstack/start-client-core": "1.170.6" | ||
| }, | ||
@@ -52,0 +64,0 @@ "devDependencies": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
74912
873.14%51
183.33%1152
1594.12%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed