@abide/abide 0.33.0 → 0.34.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 (163) hide show
  1. package/AGENTS.md +39 -34
  2. package/CHANGELOG.md +30 -0
  3. package/README.md +21 -21
  4. package/bin/abide.ts +6 -2
  5. package/package.json +5 -5
  6. package/src/abideResolverPlugin.ts +1 -1
  7. package/src/build.ts +1 -1
  8. package/src/compile.ts +1 -1
  9. package/src/devEntry.ts +12 -1
  10. package/src/lib/bundle/BundleMenu.ts +1 -1
  11. package/src/lib/bundle/BundleMenuItem.ts +1 -1
  12. package/src/lib/bundle/BundleWindow.ts +1 -1
  13. package/src/lib/bundle/bundled.ts +1 -1
  14. package/src/lib/bundle/disconnected.abide +105 -75
  15. package/src/lib/bundle/exitWithParent.ts +7 -7
  16. package/src/lib/bundle/onMenu.ts +1 -1
  17. package/src/lib/mcp/createMcpServer.ts +1 -1
  18. package/src/lib/server/AppModule.ts +1 -1
  19. package/src/lib/server/DELETE.ts +1 -1
  20. package/src/lib/server/GET.ts +1 -1
  21. package/src/lib/server/HEAD.ts +1 -1
  22. package/src/lib/server/PATCH.ts +1 -1
  23. package/src/lib/server/POST.ts +1 -1
  24. package/src/lib/server/PUT.ts +1 -1
  25. package/src/lib/server/agent.ts +1 -1
  26. package/src/lib/server/appDataDir.ts +1 -1
  27. package/src/lib/server/cookies.ts +1 -1
  28. package/src/lib/server/env.ts +1 -1
  29. package/src/lib/server/error.ts +1 -1
  30. package/src/lib/server/json.ts +1 -1
  31. package/src/lib/server/jsonl.ts +1 -1
  32. package/src/lib/server/prompts/definePrompt.ts +1 -1
  33. package/src/lib/server/prompts/renderPromptTemplate.ts +1 -1
  34. package/src/lib/server/reachable.ts +1 -1
  35. package/src/lib/server/redirect.ts +1 -1
  36. package/src/lib/server/request.ts +1 -1
  37. package/src/lib/server/rpc/defineVerb.ts +1 -1
  38. package/src/lib/server/runtime/buildCacheSnapshot.ts +1 -1
  39. package/src/lib/server/runtime/types/InspectorCacheEntry.ts +2 -2
  40. package/src/lib/server/runtime/types/InspectorContext.ts +2 -2
  41. package/src/lib/server/server.ts +1 -1
  42. package/src/lib/server/socket.ts +1 -1
  43. package/src/lib/server/sockets/defineSocket.ts +1 -1
  44. package/src/lib/server/sse.ts +1 -1
  45. package/src/lib/shared/HttpError.ts +1 -1
  46. package/src/lib/shared/cache.ts +18 -18
  47. package/src/lib/shared/createSubscriber.ts +1 -1
  48. package/src/lib/shared/health.ts +1 -1
  49. package/src/lib/shared/html.ts +1 -1
  50. package/src/lib/shared/isSubscribable.ts +1 -1
  51. package/src/lib/shared/log.ts +1 -1
  52. package/src/lib/shared/online.ts +1 -1
  53. package/src/lib/shared/page.ts +1 -1
  54. package/src/lib/shared/pending.ts +2 -2
  55. package/src/lib/shared/probeRegistries.ts +2 -2
  56. package/src/lib/shared/refreshing.ts +2 -2
  57. package/src/lib/shared/selectorMatcher.ts +8 -8
  58. package/src/lib/shared/selectorPrefix.ts +1 -1
  59. package/src/lib/shared/snippet.ts +1 -1
  60. package/src/lib/shared/toTagSet.ts +4 -0
  61. package/src/lib/shared/trace.ts +1 -1
  62. package/src/lib/shared/types/CacheEntry.ts +3 -3
  63. package/src/lib/shared/types/CacheOptions.ts +3 -3
  64. package/src/lib/shared/types/CacheSelector.ts +2 -2
  65. package/src/lib/shared/url.ts +1 -1
  66. package/src/lib/shared/withJsonSchema.ts +1 -1
  67. package/src/lib/test/assertAgentFrameConformance.ts +1 -1
  68. package/src/lib/test/createScriptedSurface.ts +1 -1
  69. package/src/lib/test/createTestApp.ts +1 -1
  70. package/src/lib/ui/compile/REACTIVE_CALLEES.ts +7 -2
  71. package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +3 -4
  72. package/src/lib/ui/compile/abideUiPlugin.ts +1 -1
  73. package/src/lib/ui/compile/analyzeComponent.ts +2 -1
  74. package/src/lib/ui/compile/compileComponent.ts +3 -3
  75. package/src/lib/ui/compile/compileModule.ts +30 -2
  76. package/src/lib/ui/compile/compileSSR.ts +5 -5
  77. package/src/lib/ui/compile/compileShadow.ts +54 -36
  78. package/src/lib/ui/compile/desugarSignals.ts +147 -18
  79. package/src/lib/ui/compile/generateBuild.ts +15 -28
  80. package/src/lib/ui/compile/generateSSR.ts +20 -13
  81. package/src/lib/ui/compile/isControlFlow.ts +18 -0
  82. package/src/lib/ui/compile/isTextLeaf.ts +15 -0
  83. package/src/lib/ui/compile/lowerContext.ts +45 -5
  84. package/src/lib/ui/compile/prepareNestedScript.ts +12 -8
  85. package/src/lib/ui/compile/renameSignalRefs.ts +21 -4
  86. package/src/lib/ui/compile/skeletonable.ts +1 -14
  87. package/src/lib/ui/compile/types/AnalyzedComponent.ts +1 -0
  88. package/src/lib/ui/computed.ts +32 -0
  89. package/src/lib/ui/createScope.ts +91 -0
  90. package/src/lib/ui/dom/anchorCursor.ts +1 -1
  91. package/src/lib/ui/dom/appendSnippet.ts +1 -1
  92. package/src/lib/ui/dom/appendStatic.ts +1 -1
  93. package/src/lib/ui/dom/appendText.ts +1 -1
  94. package/src/lib/ui/dom/appendTextAt.ts +1 -1
  95. package/src/lib/ui/dom/applyResolved.ts +1 -1
  96. package/src/lib/ui/dom/attach.ts +7 -2
  97. package/src/lib/ui/dom/attr.ts +1 -1
  98. package/src/lib/ui/dom/awaitBlock.ts +1 -1
  99. package/src/lib/ui/dom/cloneStatic.ts +1 -1
  100. package/src/lib/ui/dom/each.ts +4 -3
  101. package/src/lib/ui/dom/eachAsync.ts +1 -1
  102. package/src/lib/ui/dom/hydrate.ts +20 -6
  103. package/src/lib/ui/dom/mount.ts +12 -1
  104. package/src/lib/ui/dom/mountChild.ts +6 -2
  105. package/src/lib/ui/dom/mountSlot.ts +1 -1
  106. package/src/lib/ui/dom/on.ts +10 -4
  107. package/src/lib/ui/dom/openMarker.ts +3 -3
  108. package/src/lib/ui/dom/skeleton.ts +13 -5
  109. package/src/lib/ui/dom/switchBlock.ts +1 -1
  110. package/src/lib/ui/dom/text.ts +1 -1
  111. package/src/lib/ui/dom/tryBlock.ts +1 -1
  112. package/src/lib/ui/dom/when.ts +1 -1
  113. package/src/lib/ui/effect.ts +7 -2
  114. package/src/lib/ui/enterScope.ts +18 -0
  115. package/src/lib/ui/exitScope.ts +8 -0
  116. package/src/lib/ui/history.ts +102 -0
  117. package/src/lib/ui/installHotBridge.ts +6 -8
  118. package/src/lib/ui/linked.ts +0 -1
  119. package/src/lib/ui/navigate.ts +1 -1
  120. package/src/lib/ui/outbox.ts +115 -0
  121. package/src/lib/ui/persist.ts +112 -0
  122. package/src/lib/ui/probeNavigation.ts +1 -1
  123. package/src/lib/ui/remoteProxy.ts +1 -1
  124. package/src/lib/ui/renderToStream.ts +1 -1
  125. package/src/lib/ui/router.ts +1 -1
  126. package/src/lib/ui/runtime/CURRENT_SCOPE.ts +10 -0
  127. package/src/lib/ui/runtime/OUTLET_TAG.ts +1 -1
  128. package/src/lib/ui/runtime/PATCH_BUS.ts +28 -0
  129. package/src/lib/ui/runtime/RESUME.ts +1 -1
  130. package/src/lib/ui/runtime/captureModelDoc.ts +29 -0
  131. package/src/lib/ui/runtime/claimExpected.ts +26 -0
  132. package/src/lib/ui/runtime/createComputedNode.ts +1 -1
  133. package/src/lib/ui/runtime/createDoc.ts +73 -3
  134. package/src/lib/ui/runtime/enterRenderPass.ts +1 -1
  135. package/src/lib/ui/runtime/escapeKey.ts +13 -0
  136. package/src/lib/ui/runtime/exitRenderPass.ts +1 -1
  137. package/src/lib/ui/runtime/hotReplace.ts +17 -8
  138. package/src/lib/ui/runtime/inScope.ts +19 -0
  139. package/src/lib/ui/runtime/localStoragePersistence.ts +34 -0
  140. package/src/lib/ui/runtime/nextBlockId.ts +1 -1
  141. package/src/lib/ui/runtime/seedModelDoc.ts +26 -0
  142. package/src/lib/ui/runtime/types/{Derived.ts → Computed.ts} +1 -1
  143. package/src/lib/ui/runtime/types/Doc.ts +3 -0
  144. package/src/lib/ui/runtime/types/HotInstance.ts +6 -2
  145. package/src/lib/ui/runtime/types/PatchEvent.ts +16 -0
  146. package/src/lib/ui/runtime/unescapeKey.ts +12 -0
  147. package/src/lib/ui/runtime/walkPath.ts +3 -1
  148. package/src/lib/ui/scope.ts +19 -0
  149. package/src/lib/ui/socketProxy.ts +1 -1
  150. package/src/lib/ui/startClient.ts +1 -1
  151. package/src/lib/ui/state.ts +1 -2
  152. package/src/lib/ui/sync.ts +42 -0
  153. package/src/lib/ui/tail.ts +1 -1
  154. package/src/lib/ui/types/History.ts +14 -0
  155. package/src/lib/ui/types/Outbox.ts +14 -0
  156. package/src/lib/ui/types/PersistHandle.ts +11 -0
  157. package/src/lib/ui/types/PersistenceStore.ts +12 -0
  158. package/src/lib/ui/types/Scope.ts +57 -0
  159. package/src/lib/ui/types/SyncTransport.ts +13 -0
  160. package/src/preload.ts +1 -1
  161. package/src/lib/shared/toScopeSet.ts +0 -4
  162. package/src/lib/ui/derived.ts +0 -49
  163. package/src/lib/ui/doc.ts +0 -15
@@ -0,0 +1,57 @@
1
+ import type { computed } from '../computed.ts'
2
+ import type { linked } from '../linked.ts'
3
+ import type { Cell } from '../runtime/types/Cell.ts'
4
+ import type { Patch } from '../runtime/types/Patch.ts'
5
+ import type { state } from '../state.ts'
6
+ import type { SyncTransport } from './SyncTransport.ts'
7
+
8
+ /*
9
+ A lexical scope: the unit that owns a region's reactive data, its lifetime, and
10
+ the capabilities applied to it. Its data surface MIRRORS `Doc` (read/replace/add/
11
+ remove/cell/derive/apply/snapshot) so the compiler can target a scope as a
12
+ component's data binding directly. It nests (`child`/`root`), and carries the
13
+ capability surface as methods so a scope is a passable value:
14
+ `<Child parentScope={scope} />`.
15
+
16
+ Capabilities route where the scope's changes go: `record()` to an undo journal,
17
+ `persist()` to durable storage, `broadcast()` to peers — declared once, then
18
+ `undo`/`redo` act on a recorded scope. `id` is the scope's identity for the
19
+ boundary-crossing capabilities — `persist()` defaults its key to it. `scope()` is
20
+ the ONLY public entry; everything else is a method reached through it (the
21
+ `history`/`persist`/`sync` helpers it composes are internal).
22
+ */
23
+ export type Scope = {
24
+ readonly id: string
25
+ readonly parent: Scope | undefined
26
+ /* data — mirrors Doc */
27
+ read: <T>(path: string) => T
28
+ replace: (path: string, value: unknown) => void
29
+ add: (path: string, value: unknown) => void
30
+ remove: (path: string) => void
31
+ apply: (patch: Patch) => void
32
+ cell: <T>(path: string) => Cell<T>
33
+ derive: <T>(path: string, compute: () => T) => () => T
34
+ snapshot: () => unknown
35
+ /* the `.value`-cell signal forms, reachable only through a scope (the standalone
36
+ `state`/`linked`/`computed` are no longer exported): a writable `state(x, transform)`
37
+ gate, a reseeding `linked`, and the read-only `computed(compute)`. A writable
38
+ computed does not exist — that write is expressed at the binding (`bind:value={{
39
+ get, set }}`). The serializable computed doc slot is `derive` above. */
40
+ state: typeof state
41
+ linked: typeof linked
42
+ computed: typeof computed
43
+ /* tree */
44
+ child: (initial?: unknown) => Scope
45
+ root: () => Scope
46
+ /* capabilities — enable where the scope's changes go */
47
+ record: (options?: { limit?: number }) => void
48
+ persist: (key?: string) => void
49
+ broadcast: (transport: SyncTransport) => void
50
+ /* undo/redo — act on a recorded scope */
51
+ undo: () => void
52
+ redo: () => void
53
+ canUndo: () => boolean
54
+ canRedo: () => boolean
55
+ /* lifetime */
56
+ dispose: () => void
57
+ }
@@ -0,0 +1,13 @@
1
+ import type { Patch } from '../runtime/types/Patch.ts'
2
+
3
+ /*
4
+ The bidirectional channel `sync` rides: `send` publishes a local patch to peers,
5
+ `subscribe` delivers patches from peers (returning an unsubscribe). Deliberately
6
+ minimal and patch-shaped — an app adapts it to a `socket` (publish ⇒ `send`, the
7
+ socket's frames ⇒ `subscribe`), and a test adapts it to an in-memory hub. A patch
8
+ is already the serializable wire unit, so nothing else is needed.
9
+ */
10
+ export type SyncTransport = {
11
+ send: (patch: Patch) => void
12
+ subscribe: (onPatch: (patch: Patch) => void) => () => void
13
+ }
package/src/preload.ts CHANGED
@@ -1,4 +1,4 @@
1
- // @readme plumbing
1
+ // @documentation plumbing
2
2
  import { plugin } from 'bun'
3
3
  import { abideResolverPlugin } from './abideResolverPlugin.ts'
4
4
  import { abideUiPlugin } from './lib/ui/compile/abideUiPlugin.ts'
@@ -1,4 +0,0 @@
1
- /* Normalizes a scope option (one tag or many) to a Set for O(1) membership. */
2
- export function toScopeSet(scope: string | string[]): Set<string> {
3
- return new Set(typeof scope === 'string' ? [scope] : scope)
4
- }
@@ -1,49 +0,0 @@
1
- import { createComputedNode } from './runtime/createComputedNode.ts'
2
- import { OWNER } from './runtime/OWNER.ts'
3
- import { readNode } from './runtime/readNode.ts'
4
- import type { Derived } from './runtime/types/Derived.ts'
5
- import type { State } from './runtime/types/State.ts'
6
- import { unlinkDeps } from './runtime/unlinkDeps.ts'
7
-
8
- /*
9
- A reactive cell computed from other cells — the abide replacement for `$derived`.
10
- Lazy: it recomputes on read only when a dependency has changed, and never
11
- serializes (it is re-derived from its inputs on resume). Read via `.value`.
12
-
13
- With a `set`, it becomes a writable lens (Vue/Svelte's writable computed): the
14
- value still derives from upstream, but assigning `.value` runs `set`, whose job
15
- is to write *through* to the upstream sources. The write retriggers those
16
- sources, marking this computed dirty, so the next read recomputes — there is no
17
- local store, upstream stays the single source of truth. `set` is imperative
18
- (void): it writes an external target, unlike `state`/`linked`'s `transform`,
19
- which returns a value into their own store.
20
- */
21
- // @readme plumbing
22
- export function derived<T>(compute: () => T): Derived<T>
23
- export function derived<T>(compute: () => T, set: (next: T) => void): State<T>
24
- export function derived<T>(compute: () => T, set?: (next: T) => void): Derived<T> | State<T> {
25
- const node = createComputedNode(compute as () => unknown)
26
- /* Tear down with the enclosing scope, the way an effect does. A computed only
27
- unlinks from its sources when it re-runs (`runNode` re-tracking); one read
28
- once and then abandoned never re-runs, so absent this it would sit in its
29
- source signals' subscriber lists forever — re-marked dirty on every write to
30
- them — for the source's lifetime. Outside a scope it owns its own life (no-op). */
31
- if (OWNER.current !== undefined) {
32
- OWNER.current.push(() => unlinkDeps(node))
33
- }
34
- if (set === undefined) {
35
- return {
36
- get value(): T {
37
- return readNode(node) as T
38
- },
39
- }
40
- }
41
- return {
42
- get value(): T {
43
- return readNode(node) as T
44
- },
45
- set value(next: T) {
46
- set(next)
47
- },
48
- }
49
- }
package/src/lib/ui/doc.ts DELETED
@@ -1,15 +0,0 @@
1
- import { createDoc } from './runtime/createDoc.ts'
2
- import type { Doc } from './runtime/types/Doc.ts'
3
-
4
- /*
5
- Creates a reactive document: a single immutable, serializable tree addressed by
6
- path, where every change is a patch. `doc.read(path)` is path-granular reactive
7
- read; `doc.replace/add/remove` emit patches that wake only the readers whose
8
- paths the change touched. This is the substrate the whole framework stands on —
9
- deep reactivity, resumability, undo, and sync all reduce to "a patch over a
10
- path", so they share one mechanism instead of being bolted on.
11
- */
12
- // @readme plumbing
13
- export function doc(initial: unknown = {}): Doc {
14
- return createDoc(initial)
15
- }