@abide/abide 0.34.1 → 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.
Files changed (40) hide show
  1. package/AGENTS.md +3 -3
  2. package/CHANGELOG.md +50 -0
  3. package/README.md +2 -2
  4. package/package.json +2 -1
  5. package/src/abideResolverPlugin.ts +53 -9
  6. package/src/lib/server/runtime/STREAMED_HTML_HEADER.ts +13 -0
  7. package/src/lib/server/runtime/buildPreloadManifest.ts +151 -0
  8. package/src/lib/server/runtime/createServer.ts +4 -1
  9. package/src/lib/server/runtime/createUiPageRenderer.ts +104 -9
  10. package/src/lib/server/runtime/flushingGzipStream.ts +62 -0
  11. package/src/lib/server/runtime/gzipResponse.ts +23 -11
  12. package/src/lib/server/runtime/serializeCacheSnapshot.ts +22 -33
  13. package/src/lib/server/runtime/snapshotEntryFromCache.ts +9 -0
  14. package/src/lib/server/sockets/defineSocket.ts +6 -1
  15. package/src/lib/shared/cacheEntryFromSnapshot.ts +14 -12
  16. package/src/lib/shared/contentBodyKind.ts +27 -0
  17. package/src/lib/shared/createSocketSubRegistry.ts +112 -0
  18. package/src/lib/shared/decodeResponse.ts +5 -4
  19. package/src/lib/shared/isStreamingResponse.ts +5 -5
  20. package/src/lib/test/createTestSocketChannel.ts +9 -70
  21. package/src/lib/ui/README.md +1 -1
  22. package/src/lib/ui/compile/REACTIVE_CALLEES.ts +6 -6
  23. package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +1 -0
  24. package/src/lib/ui/compile/compileShadow.ts +60 -55
  25. package/src/lib/ui/compile/desugarSignals.ts +93 -38
  26. package/src/lib/ui/compile/generateSSR.ts +28 -47
  27. package/src/lib/ui/compile/lowerDocAccess.ts +26 -11
  28. package/src/lib/ui/compile/parseTemplate.ts +8 -5
  29. package/src/lib/ui/compile/prepareNestedScript.ts +2 -2
  30. package/src/lib/ui/compile/renameSignalRefs.ts +153 -23
  31. package/src/lib/ui/compile/skeletonContext.ts +83 -0
  32. package/src/lib/ui/compile/types/SkeletonContext.ts +15 -0
  33. package/src/lib/ui/compile/types/TemplateAttr.ts +4 -2
  34. package/src/lib/ui/dom/applyResolved.ts +27 -7
  35. package/src/lib/ui/installHotBridge.ts +2 -0
  36. package/src/lib/ui/runtime/escapeKey.ts +10 -4
  37. package/src/lib/ui/seedStreamedResolution.ts +22 -0
  38. package/src/lib/ui/socketChannel.ts +18 -98
  39. package/src/lib/ui/startClient.ts +17 -3
  40. package/src/lib/shared/types/CacheSnapshot.ts +0 -16
@@ -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
- for (const entry of ssr.cache ?? []) {
54
- store.entries.set(entry.key, cacheEntryFromSnapshot(entry))
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
- }