@abide/abide 0.33.1 → 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.
- package/AGENTS.md +39 -34
- package/CHANGELOG.md +24 -0
- package/README.md +21 -21
- package/package.json +5 -5
- package/src/abideResolverPlugin.ts +1 -1
- package/src/build.ts +1 -1
- package/src/compile.ts +1 -1
- package/src/lib/bundle/BundleMenu.ts +1 -1
- package/src/lib/bundle/BundleMenuItem.ts +1 -1
- package/src/lib/bundle/BundleWindow.ts +1 -1
- package/src/lib/bundle/bundled.ts +1 -1
- package/src/lib/bundle/disconnected.abide +105 -75
- package/src/lib/bundle/onMenu.ts +1 -1
- package/src/lib/mcp/createMcpServer.ts +1 -1
- package/src/lib/server/AppModule.ts +1 -1
- package/src/lib/server/DELETE.ts +1 -1
- package/src/lib/server/GET.ts +1 -1
- package/src/lib/server/HEAD.ts +1 -1
- package/src/lib/server/PATCH.ts +1 -1
- package/src/lib/server/POST.ts +1 -1
- package/src/lib/server/PUT.ts +1 -1
- package/src/lib/server/agent.ts +1 -1
- package/src/lib/server/appDataDir.ts +1 -1
- package/src/lib/server/cookies.ts +1 -1
- package/src/lib/server/env.ts +1 -1
- package/src/lib/server/error.ts +1 -1
- package/src/lib/server/json.ts +1 -1
- package/src/lib/server/jsonl.ts +1 -1
- package/src/lib/server/prompts/definePrompt.ts +1 -1
- package/src/lib/server/prompts/renderPromptTemplate.ts +1 -1
- package/src/lib/server/reachable.ts +1 -1
- package/src/lib/server/redirect.ts +1 -1
- package/src/lib/server/request.ts +1 -1
- package/src/lib/server/rpc/defineVerb.ts +1 -1
- package/src/lib/server/runtime/buildCacheSnapshot.ts +1 -1
- package/src/lib/server/runtime/types/InspectorCacheEntry.ts +2 -2
- package/src/lib/server/runtime/types/InspectorContext.ts +2 -2
- package/src/lib/server/server.ts +1 -1
- package/src/lib/server/socket.ts +1 -1
- package/src/lib/server/sockets/defineSocket.ts +1 -1
- package/src/lib/server/sse.ts +1 -1
- package/src/lib/shared/HttpError.ts +1 -1
- package/src/lib/shared/cache.ts +18 -18
- package/src/lib/shared/createSubscriber.ts +1 -1
- package/src/lib/shared/health.ts +1 -1
- package/src/lib/shared/html.ts +1 -1
- package/src/lib/shared/isSubscribable.ts +1 -1
- package/src/lib/shared/log.ts +1 -1
- package/src/lib/shared/online.ts +1 -1
- package/src/lib/shared/page.ts +1 -1
- package/src/lib/shared/pending.ts +2 -2
- package/src/lib/shared/probeRegistries.ts +2 -2
- package/src/lib/shared/refreshing.ts +2 -2
- package/src/lib/shared/selectorMatcher.ts +8 -8
- package/src/lib/shared/selectorPrefix.ts +1 -1
- package/src/lib/shared/snippet.ts +1 -1
- package/src/lib/shared/toTagSet.ts +4 -0
- package/src/lib/shared/trace.ts +1 -1
- package/src/lib/shared/types/CacheEntry.ts +3 -3
- package/src/lib/shared/types/CacheOptions.ts +3 -3
- package/src/lib/shared/types/CacheSelector.ts +2 -2
- package/src/lib/shared/url.ts +1 -1
- package/src/lib/shared/withJsonSchema.ts +1 -1
- package/src/lib/test/assertAgentFrameConformance.ts +1 -1
- package/src/lib/test/createScriptedSurface.ts +1 -1
- package/src/lib/test/createTestApp.ts +1 -1
- package/src/lib/ui/compile/REACTIVE_CALLEES.ts +7 -2
- package/src/lib/ui/compile/UI_RUNTIME_IMPORTS.ts +3 -4
- package/src/lib/ui/compile/abideUiPlugin.ts +1 -1
- package/src/lib/ui/compile/analyzeComponent.ts +2 -1
- package/src/lib/ui/compile/compileComponent.ts +3 -3
- package/src/lib/ui/compile/compileModule.ts +30 -2
- package/src/lib/ui/compile/compileSSR.ts +5 -5
- package/src/lib/ui/compile/compileShadow.ts +54 -36
- package/src/lib/ui/compile/desugarSignals.ts +147 -18
- package/src/lib/ui/compile/generateBuild.ts +15 -28
- package/src/lib/ui/compile/generateSSR.ts +20 -13
- package/src/lib/ui/compile/isControlFlow.ts +18 -0
- package/src/lib/ui/compile/isTextLeaf.ts +15 -0
- package/src/lib/ui/compile/lowerContext.ts +45 -5
- package/src/lib/ui/compile/prepareNestedScript.ts +12 -8
- package/src/lib/ui/compile/renameSignalRefs.ts +21 -4
- package/src/lib/ui/compile/skeletonable.ts +1 -14
- package/src/lib/ui/compile/types/AnalyzedComponent.ts +1 -0
- package/src/lib/ui/computed.ts +32 -0
- package/src/lib/ui/createScope.ts +91 -0
- package/src/lib/ui/dom/anchorCursor.ts +1 -1
- package/src/lib/ui/dom/appendSnippet.ts +1 -1
- package/src/lib/ui/dom/appendStatic.ts +1 -1
- package/src/lib/ui/dom/appendText.ts +1 -1
- package/src/lib/ui/dom/appendTextAt.ts +1 -1
- package/src/lib/ui/dom/applyResolved.ts +1 -1
- package/src/lib/ui/dom/attach.ts +7 -2
- package/src/lib/ui/dom/attr.ts +1 -1
- package/src/lib/ui/dom/awaitBlock.ts +1 -1
- package/src/lib/ui/dom/cloneStatic.ts +1 -1
- package/src/lib/ui/dom/each.ts +4 -3
- package/src/lib/ui/dom/eachAsync.ts +1 -1
- package/src/lib/ui/dom/hydrate.ts +20 -6
- package/src/lib/ui/dom/mount.ts +12 -1
- package/src/lib/ui/dom/mountChild.ts +6 -2
- package/src/lib/ui/dom/mountSlot.ts +1 -1
- package/src/lib/ui/dom/on.ts +10 -4
- package/src/lib/ui/dom/openMarker.ts +3 -3
- package/src/lib/ui/dom/skeleton.ts +13 -5
- package/src/lib/ui/dom/switchBlock.ts +1 -1
- package/src/lib/ui/dom/text.ts +1 -1
- package/src/lib/ui/dom/tryBlock.ts +1 -1
- package/src/lib/ui/dom/when.ts +1 -1
- package/src/lib/ui/effect.ts +7 -2
- package/src/lib/ui/enterScope.ts +18 -0
- package/src/lib/ui/exitScope.ts +8 -0
- package/src/lib/ui/history.ts +102 -0
- package/src/lib/ui/installHotBridge.ts +6 -8
- package/src/lib/ui/linked.ts +0 -1
- package/src/lib/ui/navigate.ts +1 -1
- package/src/lib/ui/outbox.ts +115 -0
- package/src/lib/ui/persist.ts +112 -0
- package/src/lib/ui/probeNavigation.ts +1 -1
- package/src/lib/ui/remoteProxy.ts +1 -1
- package/src/lib/ui/renderToStream.ts +1 -1
- package/src/lib/ui/router.ts +1 -1
- package/src/lib/ui/runtime/CURRENT_SCOPE.ts +10 -0
- package/src/lib/ui/runtime/OUTLET_TAG.ts +1 -1
- package/src/lib/ui/runtime/PATCH_BUS.ts +28 -0
- package/src/lib/ui/runtime/RESUME.ts +1 -1
- package/src/lib/ui/runtime/captureModelDoc.ts +29 -0
- package/src/lib/ui/runtime/claimExpected.ts +26 -0
- package/src/lib/ui/runtime/createComputedNode.ts +1 -1
- package/src/lib/ui/runtime/createDoc.ts +73 -3
- package/src/lib/ui/runtime/enterRenderPass.ts +1 -1
- package/src/lib/ui/runtime/escapeKey.ts +13 -0
- package/src/lib/ui/runtime/exitRenderPass.ts +1 -1
- package/src/lib/ui/runtime/hotReplace.ts +17 -8
- package/src/lib/ui/runtime/inScope.ts +19 -0
- package/src/lib/ui/runtime/localStoragePersistence.ts +34 -0
- package/src/lib/ui/runtime/nextBlockId.ts +1 -1
- package/src/lib/ui/runtime/seedModelDoc.ts +26 -0
- package/src/lib/ui/runtime/types/{Derived.ts → Computed.ts} +1 -1
- package/src/lib/ui/runtime/types/Doc.ts +3 -0
- package/src/lib/ui/runtime/types/HotInstance.ts +6 -2
- package/src/lib/ui/runtime/types/PatchEvent.ts +16 -0
- package/src/lib/ui/runtime/unescapeKey.ts +12 -0
- package/src/lib/ui/runtime/walkPath.ts +3 -1
- package/src/lib/ui/scope.ts +19 -0
- package/src/lib/ui/socketProxy.ts +1 -1
- package/src/lib/ui/startClient.ts +1 -1
- package/src/lib/ui/state.ts +1 -2
- package/src/lib/ui/sync.ts +42 -0
- package/src/lib/ui/tail.ts +1 -1
- package/src/lib/ui/types/History.ts +14 -0
- package/src/lib/ui/types/Outbox.ts +14 -0
- package/src/lib/ui/types/PersistHandle.ts +11 -0
- package/src/lib/ui/types/PersistenceStore.ts +12 -0
- package/src/lib/ui/types/Scope.ts +57 -0
- package/src/lib/ui/types/SyncTransport.ts +13 -0
- package/src/preload.ts +1 -1
- package/src/lib/shared/toScopeSet.ts +0 -4
- package/src/lib/ui/derived.ts +0 -49
- 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
package/src/lib/ui/derived.ts
DELETED
|
@@ -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
|
-
}
|