@abide/abide 0.34.2 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -3
- package/CHANGELOG.md +36 -0
- package/README.md +2 -2
- package/package.json +2 -1
- package/src/abideResolverPlugin.ts +53 -9
- package/src/lib/server/runtime/STREAMED_HTML_HEADER.ts +13 -0
- package/src/lib/server/runtime/buildPreloadManifest.ts +151 -0
- package/src/lib/server/runtime/createServer.ts +4 -1
- package/src/lib/server/runtime/createUiPageRenderer.ts +104 -9
- package/src/lib/server/runtime/flushingGzipStream.ts +62 -0
- package/src/lib/server/runtime/gzipResponse.ts +23 -11
- package/src/lib/server/runtime/serializeCacheSnapshot.ts +22 -33
- package/src/lib/ui/README.md +1 -1
- package/src/lib/ui/compile/REACTIVE_CALLEES.ts +6 -6
- package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +1 -0
- package/src/lib/ui/compile/compileShadow.ts +60 -55
- package/src/lib/ui/compile/desugarSignals.ts +93 -38
- package/src/lib/ui/compile/lowerDocAccess.ts +26 -11
- package/src/lib/ui/compile/parseTemplate.ts +8 -5
- package/src/lib/ui/compile/prepareNestedScript.ts +2 -2
- package/src/lib/ui/compile/renameSignalRefs.ts +153 -23
- package/src/lib/ui/compile/types/TemplateAttr.ts +4 -2
- package/src/lib/ui/dom/applyResolved.ts +27 -7
- package/src/lib/ui/installHotBridge.ts +2 -0
- package/src/lib/ui/runtime/escapeKey.ts +10 -4
- package/src/lib/ui/seedStreamedResolution.ts +22 -0
- package/src/lib/ui/startClient.ts +17 -3
- package/src/lib/shared/types/CacheSnapshot.ts +0 -16
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { activeCacheStore } from '../shared/activeCacheStore.ts'
|
|
2
|
+
import { cacheEntryFromSnapshot } from '../shared/cacheEntryFromSnapshot.ts'
|
|
3
|
+
import type { StreamedResolution } from '../shared/types/StreamedResolution.ts'
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Seeds one streamed cache resolution into the active store — the single sink for the
|
|
7
|
+
streamed (pending {#await}) cache partition. A full CacheSnapshotEntry warms the entry
|
|
8
|
+
so a `cache()` read resolves synchronously (no wire round-trip) and `<template await>`
|
|
9
|
+
adopts without a refetch; a `{ key, miss }` marker — a body the server couldn't snapshot
|
|
10
|
+
(binary / rejected / evicted) — is a no-op, so that read falls back to a live fetch.
|
|
11
|
+
|
|
12
|
+
Shared by startClient's boot drain, the live `window.__abideResolve`, and applyResolved,
|
|
13
|
+
so no resolved-frame consumer can swap DOM while silently dropping the cache channel —
|
|
14
|
+
the asymmetry that made streamed reads cold-miss to the network.
|
|
15
|
+
*/
|
|
16
|
+
// @documentation plumbing
|
|
17
|
+
export function seedStreamedResolution(resolution: StreamedResolution): void {
|
|
18
|
+
if ('miss' in resolution) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
activeCacheStore().entries.set(resolution.key, cacheEntryFromSnapshot(resolution))
|
|
22
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { cacheEntryFromSnapshot } from '../shared/cacheEntryFromSnapshot.ts'
|
|
2
1
|
import { createCacheStore } from '../shared/createCacheStore.ts'
|
|
3
2
|
import { setBaseResolver } from '../shared/setBaseResolver.ts'
|
|
4
3
|
import { setCacheStoreResolver } from '../shared/setCacheStoreResolver.ts'
|
|
5
4
|
import { setGlobalCacheStoreResolver } from '../shared/setGlobalCacheStoreResolver.ts'
|
|
6
5
|
import { setPageResolver } from '../shared/setPageResolver.ts'
|
|
7
6
|
import type { CacheSnapshotEntry } from '../shared/types/CacheSnapshotEntry.ts'
|
|
7
|
+
import type { StreamedResolution } from '../shared/types/StreamedResolution.ts'
|
|
8
8
|
import { installHotBridge } from './installHotBridge.ts'
|
|
9
9
|
import { probeNavigation } from './probeNavigation.ts'
|
|
10
10
|
import { router } from './router.ts'
|
|
11
11
|
import { clientPage } from './runtime/clientPage.ts'
|
|
12
12
|
import type { RouteLoader } from './runtime/types/RouteLoader.ts'
|
|
13
|
+
import { seedStreamedResolution } from './seedStreamedResolution.ts'
|
|
13
14
|
|
|
14
15
|
/* The server's __SSR__ payload this entry consumes. */
|
|
15
16
|
type SsrPayload = { cache?: CacheSnapshotEntry[]; base?: string }
|
|
@@ -50,9 +51,22 @@ export function startClient(
|
|
|
50
51
|
setCacheStoreResolver(() => store)
|
|
51
52
|
/* One tab store: cache(fn, { global: true }) shares it, so global is a no-op here. */
|
|
52
53
|
setGlobalCacheStoreResolver(() => store)
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
/* Seed both SSR cache partitions through the one streamed-resolution sink: `ssr.cache`
|
|
55
|
+
(inline — reads settled at render-return, in __SSR__) and `__abideResumeCache` (pending
|
|
56
|
+
{#await} reads whose `__abideResolve(...)` chunks the stream pushed during parse, before
|
|
57
|
+
this deferred bundle ran). A warm entry lets a `cache()` read resolve synchronously so
|
|
58
|
+
`<template await>` adopts without a refetch; a miss marker re-fetches live. */
|
|
59
|
+
const streamed =
|
|
60
|
+
(globalThis as { __abideResumeCache?: StreamedResolution[] }).__abideResumeCache ?? []
|
|
61
|
+
for (const resolution of [...(ssr.cache ?? []), ...streamed]) {
|
|
62
|
+
seedStreamedResolution(resolution)
|
|
55
63
|
}
|
|
64
|
+
/* Keep the cache channel live past boot: replace the head's buffering collector with
|
|
65
|
+
the store-connected sink so a post-load resolution — streaming SPA navigation or a
|
|
66
|
+
socket-delivered SSR frame, both routed through applyResolved — seeds the store
|
|
67
|
+
directly instead of pushing to a buffer nothing drains again. */
|
|
68
|
+
;(globalThis as { __abideResolve?: (resolution: StreamedResolution) => void }).__abideResolve =
|
|
69
|
+
seedStreamedResolution
|
|
56
70
|
|
|
57
71
|
return router(target, routes, layoutRoutes, probeNavigation)
|
|
58
72
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { CacheEntry } from './CacheEntry.ts'
|
|
2
|
-
import type { CacheSnapshotEntry } from './CacheSnapshotEntry.ts'
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
The SSR partition of a request's cache, read after `render()` returns.
|
|
6
|
-
`inline` are entries settled by then (consumed via `await`, so render blocked
|
|
7
|
-
on them) — they ship in the first chunk's `__SSR__` blob. `pending` are
|
|
8
|
-
GET/DELETE entries still in flight (consumed via `{#await}`, which render emits
|
|
9
|
-
as a pending branch without blocking) — the streamer awaits each and pushes a
|
|
10
|
-
`__abideResolve` chunk as it lands. Non-GET/DELETE pending entries are dropped:
|
|
11
|
-
they can't be snapshotted, so the client re-fetches them live on cache miss.
|
|
12
|
-
*/
|
|
13
|
-
export type CacheSnapshot = {
|
|
14
|
-
inline: CacheSnapshotEntry[]
|
|
15
|
-
pending: CacheEntry[]
|
|
16
|
-
}
|