@astrale-os/shell-react 0.1.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/LICENSE +202 -0
- package/dist/application/apps/app-host.d.ts +31 -0
- package/dist/application/apps/app-host.d.ts.map +1 -0
- package/dist/application/apps/app-host.js +59 -0
- package/dist/application/apps/app-logo.d.ts +19 -0
- package/dist/application/apps/app-logo.d.ts.map +1 -0
- package/dist/application/apps/app-logo.js +31 -0
- package/dist/application/apps/apps.hook.d.ts +12 -0
- package/dist/application/apps/apps.hook.d.ts.map +1 -0
- package/dist/application/apps/apps.hook.js +51 -0
- package/dist/application/apps/open-app.hook.d.ts +10 -0
- package/dist/application/apps/open-app.hook.d.ts.map +1 -0
- package/dist/application/apps/open-app.hook.js +7 -0
- package/dist/application/index.d.ts +18 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +12 -0
- package/dist/application/roles.hook.d.ts +7 -0
- package/dist/application/roles.hook.d.ts.map +1 -0
- package/dist/application/roles.hook.js +23 -0
- package/dist/application/spaces/current-space.hook.d.ts +7 -0
- package/dist/application/spaces/current-space.hook.d.ts.map +1 -0
- package/dist/application/spaces/current-space.hook.js +27 -0
- package/dist/application/spaces/current-space.store.d.ts +32 -0
- package/dist/application/spaces/current-space.store.d.ts.map +1 -0
- package/dist/application/spaces/current-space.store.js +79 -0
- package/dist/application/spaces/space.hook.d.ts +5 -0
- package/dist/application/spaces/space.hook.d.ts.map +1 -0
- package/dist/application/spaces/space.hook.js +25 -0
- package/dist/application/spaces/spaces.hook.d.ts +14 -0
- package/dist/application/spaces/spaces.hook.d.ts.map +1 -0
- package/dist/application/spaces/spaces.hook.js +82 -0
- package/dist/application/user/user.hook.d.ts +10 -0
- package/dist/application/user/user.hook.d.ts.map +1 -0
- package/dist/application/user/user.hook.js +19 -0
- package/dist/application/user/user.store.d.ts +35 -0
- package/dist/application/user/user.store.d.ts.map +1 -0
- package/dist/application/user/user.store.js +51 -0
- package/dist/auth/act-as.context.d.ts +40 -0
- package/dist/auth/act-as.context.d.ts.map +1 -0
- package/dist/auth/act-as.context.js +84 -0
- package/dist/auth/auth.hook.d.ts +3 -0
- package/dist/auth/auth.hook.d.ts.map +1 -0
- package/dist/auth/auth.hook.js +25 -0
- package/dist/auth/can.hook.d.ts +40 -0
- package/dist/auth/can.hook.d.ts.map +1 -0
- package/dist/auth/can.hook.js +119 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/self.hook.d.ts +3 -0
- package/dist/auth/self.hook.d.ts.map +1 -0
- package/dist/auth/self.hook.js +11 -0
- package/dist/auth/session-kernel.d.ts +4 -0
- package/dist/auth/session-kernel.d.ts.map +1 -0
- package/dist/auth/session-kernel.js +21 -0
- package/dist/graph/action.d.ts +22 -0
- package/dist/graph/action.d.ts.map +1 -0
- package/dist/graph/action.js +85 -0
- package/dist/graph/async.d.ts +11 -0
- package/dist/graph/async.d.ts.map +1 -0
- package/dist/graph/async.js +60 -0
- package/dist/graph/call/call.hook.d.ts +21 -0
- package/dist/graph/call/call.hook.d.ts.map +1 -0
- package/dist/graph/call/call.hook.js +23 -0
- package/dist/graph/call/stream.hook.d.ts +28 -0
- package/dist/graph/call/stream.hook.d.ts.map +1 -0
- package/dist/graph/call/stream.hook.js +137 -0
- package/dist/graph/graph.context.d.ts +4 -0
- package/dist/graph/graph.context.d.ts.map +1 -0
- package/dist/graph/graph.context.js +10 -0
- package/dist/graph/guards.error.d.ts +9 -0
- package/dist/graph/guards.error.d.ts.map +1 -0
- package/dist/graph/guards.error.js +7 -0
- package/dist/graph/index.d.ts +20 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +9 -0
- package/dist/graph/memory/base.d.ts +21 -0
- package/dist/graph/memory/base.d.ts.map +1 -0
- package/dist/graph/memory/base.js +33 -0
- package/dist/graph/memory/read/envelope.d.ts +71 -0
- package/dist/graph/memory/read/envelope.d.ts.map +1 -0
- package/dist/graph/memory/read/envelope.js +29 -0
- package/dist/graph/memory/read/idle.d.ts +18 -0
- package/dist/graph/memory/read/idle.d.ts.map +1 -0
- package/dist/graph/memory/read/idle.js +16 -0
- package/dist/graph/memory/read/read.d.ts +9 -0
- package/dist/graph/memory/read/read.d.ts.map +1 -0
- package/dist/graph/memory/read/read.js +87 -0
- package/dist/graph/memory/scope.d.ts +7 -0
- package/dist/graph/memory/scope.d.ts.map +1 -0
- package/dist/graph/memory/scope.js +25 -0
- package/dist/graph/mutate/move.hook.d.ts +7 -0
- package/dist/graph/mutate/move.hook.d.ts.map +1 -0
- package/dist/graph/mutate/move.hook.js +49 -0
- package/dist/graph/mutate/mutate.hook.d.ts +17 -0
- package/dist/graph/mutate/mutate.hook.d.ts.map +1 -0
- package/dist/graph/mutate/mutate.hook.js +45 -0
- package/dist/graph/query/children.hook.d.ts +29 -0
- package/dist/graph/query/children.hook.d.ts.map +1 -0
- package/dist/graph/query/children.hook.js +64 -0
- package/dist/graph/query/graph.hook.d.ts +9 -0
- package/dist/graph/query/graph.hook.d.ts.map +1 -0
- package/dist/graph/query/graph.hook.js +5 -0
- package/dist/graph/query/neighbors.hook.d.ts +7 -0
- package/dist/graph/query/neighbors.hook.d.ts.map +1 -0
- package/dist/graph/query/neighbors.hook.js +79 -0
- package/dist/graph/query/node.hook.d.ts +14 -0
- package/dist/graph/query/node.hook.d.ts.map +1 -0
- package/dist/graph/query/node.hook.js +43 -0
- package/dist/graph/query/query.hook.d.ts +14 -0
- package/dist/graph/query/query.hook.d.ts.map +1 -0
- package/dist/graph/query/query.hook.js +23 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/intents/envelope.d.ts +33 -0
- package/dist/intents/envelope.d.ts.map +1 -0
- package/dist/intents/envelope.js +19 -0
- package/dist/intents/index.d.ts +6 -0
- package/dist/intents/index.d.ts.map +1 -0
- package/dist/intents/index.js +3 -0
- package/dist/intents/listen-intent.hook.d.ts +16 -0
- package/dist/intents/listen-intent.hook.d.ts.map +1 -0
- package/dist/intents/listen-intent.hook.js +75 -0
- package/dist/intents/reply.d.ts +9 -0
- package/dist/intents/reply.d.ts.map +1 -0
- package/dist/intents/reply.js +14 -0
- package/dist/intents/send-intent.hook.d.ts +12 -0
- package/dist/intents/send-intent.hook.d.ts.map +1 -0
- package/dist/intents/send-intent.hook.js +86 -0
- package/dist/navigation/adapters/adapter.d.ts +15 -0
- package/dist/navigation/adapters/adapter.d.ts.map +1 -0
- package/dist/navigation/adapters/adapter.js +1 -0
- package/dist/navigation/adapters/memory.adapter.d.ts +9 -0
- package/dist/navigation/adapters/memory.adapter.d.ts.map +1 -0
- package/dist/navigation/adapters/memory.adapter.js +15 -0
- package/dist/navigation/adapters/url.adapter.d.ts +6 -0
- package/dist/navigation/adapters/url.adapter.d.ts.map +1 -0
- package/dist/navigation/adapters/url.adapter.js +59 -0
- package/dist/navigation/history.d.ts +63 -0
- package/dist/navigation/history.d.ts.map +1 -0
- package/dist/navigation/history.js +144 -0
- package/dist/navigation/hooks/ancestors.hook.d.ts +13 -0
- package/dist/navigation/hooks/ancestors.hook.d.ts.map +1 -0
- package/dist/navigation/hooks/ancestors.hook.js +56 -0
- package/dist/navigation/hooks/location.hook.d.ts +4 -0
- package/dist/navigation/hooks/location.hook.d.ts.map +1 -0
- package/dist/navigation/hooks/location.hook.js +17 -0
- package/dist/navigation/hooks/navigate.hook.d.ts +12 -0
- package/dist/navigation/hooks/navigate.hook.d.ts.map +1 -0
- package/dist/navigation/hooks/navigate.hook.js +33 -0
- package/dist/navigation/hooks/scope.hook.d.ts +12 -0
- package/dist/navigation/hooks/scope.hook.d.ts.map +1 -0
- package/dist/navigation/hooks/scope.hook.js +21 -0
- package/dist/navigation/index.d.ts +16 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +10 -0
- package/dist/navigation/link.d.ts +11 -0
- package/dist/navigation/link.d.ts.map +1 -0
- package/dist/navigation/link.js +62 -0
- package/dist/navigation/location.d.ts +48 -0
- package/dist/navigation/location.d.ts.map +1 -0
- package/dist/navigation/location.js +88 -0
- package/dist/navigation/scope.context.d.ts +64 -0
- package/dist/navigation/scope.context.d.ts.map +1 -0
- package/dist/navigation/scope.context.js +178 -0
- package/dist/navigation/snapshot.d.ts +22 -0
- package/dist/navigation/snapshot.d.ts.map +1 -0
- package/dist/navigation/snapshot.js +65 -0
- package/dist/schema/bind-read.d.ts +37 -0
- package/dist/schema/bind-read.d.ts.map +1 -0
- package/dist/schema/bind-read.js +205 -0
- package/dist/schema/binding.d.ts +21 -0
- package/dist/schema/binding.d.ts.map +1 -0
- package/dist/schema/binding.js +55 -0
- package/dist/schema/domain.hook.d.ts +10 -0
- package/dist/schema/domain.hook.d.ts.map +1 -0
- package/dist/schema/domain.hook.js +7 -0
- package/dist/schema/function.hook.d.ts +9 -0
- package/dist/schema/function.hook.d.ts.map +1 -0
- package/dist/schema/function.hook.js +40 -0
- package/dist/schema/index.d.ts +10 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +8 -0
- package/dist/schema/kernel.hook.d.ts +10 -0
- package/dist/schema/kernel.hook.d.ts.map +1 -0
- package/dist/schema/kernel.hook.js +8 -0
- package/dist/schema/method.hook.d.ts +14 -0
- package/dist/schema/method.hook.d.ts.map +1 -0
- package/dist/schema/method.hook.js +49 -0
- package/dist/schema/tag.d.ts +11 -0
- package/dist/schema/tag.d.ts.map +1 -0
- package/dist/schema/tag.js +11 -0
- package/dist/schema/types.d.ts +73 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +1 -0
- package/dist/schema/write.d.ts +15 -0
- package/dist/schema/write.d.ts.map +1 -0
- package/dist/schema/write.js +45 -0
- package/dist/selection/index.d.ts +4 -0
- package/dist/selection/index.d.ts.map +1 -0
- package/dist/selection/index.js +4 -0
- package/dist/selection/live.d.ts +21 -0
- package/dist/selection/live.d.ts.map +1 -0
- package/dist/selection/live.js +116 -0
- package/dist/selection/scope.context.d.ts +26 -0
- package/dist/selection/scope.context.d.ts.map +1 -0
- package/dist/selection/scope.context.js +100 -0
- package/dist/selection/selection.hook.d.ts +4 -0
- package/dist/selection/selection.hook.d.ts.map +1 -0
- package/dist/selection/selection.hook.js +14 -0
- package/dist/session/boot/boot.d.ts +19 -0
- package/dist/session/boot/boot.d.ts.map +1 -0
- package/dist/session/boot/boot.js +45 -0
- package/dist/session/boot/ownership.d.ts +18 -0
- package/dist/session/boot/ownership.d.ts.map +1 -0
- package/dist/session/boot/ownership.js +39 -0
- package/dist/session/boot/status.d.ts +24 -0
- package/dist/session/boot/status.d.ts.map +1 -0
- package/dist/session/boot/status.js +11 -0
- package/dist/session/connection/connection.hook.d.ts +3 -0
- package/dist/session/connection/connection.hook.d.ts.map +1 -0
- package/dist/session/connection/connection.hook.js +12 -0
- package/dist/session/connection/connection.store.d.ts +24 -0
- package/dist/session/connection/connection.store.d.ts.map +1 -0
- package/dist/session/connection/connection.store.js +31 -0
- package/dist/session/index.d.ts +8 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +6 -0
- package/dist/session/kernel-client.hook.d.ts +9 -0
- package/dist/session/kernel-client.hook.d.ts.map +1 -0
- package/dist/session/kernel-client.hook.js +5 -0
- package/dist/session/kernel-instance.hook.d.ts +9 -0
- package/dist/session/kernel-instance.hook.d.ts.map +1 -0
- package/dist/session/kernel-instance.hook.js +10 -0
- package/dist/session/provider.d.ts +31 -0
- package/dist/session/provider.d.ts.map +1 -0
- package/dist/session/provider.js +165 -0
- package/dist/session/session.context.d.ts +18 -0
- package/dist/session/session.context.d.ts.map +1 -0
- package/dist/session/session.context.js +8 -0
- package/dist/session/shell.hook.d.ts +4 -0
- package/dist/session/shell.hook.d.ts.map +1 -0
- package/dist/session/shell.hook.js +15 -0
- package/dist/window/adopt.d.ts +27 -0
- package/dist/window/adopt.d.ts.map +1 -0
- package/dist/window/adopt.js +27 -0
- package/dist/window/hooks/close-guard.hook.d.ts +6 -0
- package/dist/window/hooks/close-guard.hook.d.ts.map +1 -0
- package/dist/window/hooks/close-guard.hook.js +90 -0
- package/dist/window/hooks/target-node.hook.d.ts +7 -0
- package/dist/window/hooks/target-node.hook.d.ts.map +1 -0
- package/dist/window/hooks/target-node.hook.js +77 -0
- package/dist/window/hooks/views-for.hook.d.ts +8 -0
- package/dist/window/hooks/views-for.hook.d.ts.map +1 -0
- package/dist/window/hooks/views-for.hook.js +51 -0
- package/dist/window/hooks/window.hook.d.ts +4 -0
- package/dist/window/hooks/window.hook.d.ts.map +1 -0
- package/dist/window/hooks/window.hook.js +14 -0
- package/dist/window/hooks/windows.hook.d.ts +15 -0
- package/dist/window/hooks/windows.hook.d.ts.map +1 -0
- package/dist/window/hooks/windows.hook.js +25 -0
- package/dist/window/host.d.ts +31 -0
- package/dist/window/host.d.ts.map +1 -0
- package/dist/window/host.js +270 -0
- package/dist/window/hub.d.ts +41 -0
- package/dist/window/hub.d.ts.map +1 -0
- package/dist/window/hub.js +100 -0
- package/dist/window/index.d.ts +15 -0
- package/dist/window/index.d.ts.map +1 -0
- package/dist/window/index.js +10 -0
- package/dist/window/lifecycle/mount.d.ts +47 -0
- package/dist/window/lifecycle/mount.d.ts.map +1 -0
- package/dist/window/lifecycle/mount.js +92 -0
- package/dist/window/lifecycle/states.d.ts +33 -0
- package/dist/window/lifecycle/states.d.ts.map +1 -0
- package/dist/window/lifecycle/states.js +7 -0
- package/dist/window/placement.d.ts +33 -0
- package/dist/window/placement.d.ts.map +1 -0
- package/dist/window/placement.js +57 -0
- package/dist/window/stage.d.ts +3 -0
- package/dist/window/stage.d.ts.map +1 -0
- package/dist/window/stage.js +41 -0
- package/package.json +59 -0
- package/src/application/apps/app-host.tsx +113 -0
- package/src/application/apps/app-logo.tsx +56 -0
- package/src/application/apps/apps.hook.ts +81 -0
- package/src/application/apps/open-app.hook.ts +18 -0
- package/src/application/index.ts +22 -0
- package/src/application/roles.hook.ts +41 -0
- package/src/application/spaces/current-space.hook.ts +43 -0
- package/src/application/spaces/current-space.store.ts +110 -0
- package/src/application/spaces/space.hook.ts +41 -0
- package/src/application/spaces/spaces.hook.ts +113 -0
- package/src/application/user/user.hook.ts +27 -0
- package/src/application/user/user.store.ts +85 -0
- package/src/auth/act-as.context.tsx +124 -0
- package/src/auth/auth.hook.ts +36 -0
- package/src/auth/can.hook.ts +149 -0
- package/src/auth/index.ts +6 -0
- package/src/auth/self.hook.ts +14 -0
- package/src/auth/session-kernel.ts +24 -0
- package/src/graph/action.ts +127 -0
- package/src/graph/async.ts +87 -0
- package/src/graph/call/call.hook.ts +42 -0
- package/src/graph/call/stream.hook.ts +200 -0
- package/src/graph/graph.context.ts +14 -0
- package/src/graph/guards.error.ts +58 -0
- package/src/graph/index.ts +20 -0
- package/src/graph/memory/base.ts +50 -0
- package/src/graph/memory/read/envelope.ts +98 -0
- package/src/graph/memory/read/idle.ts +24 -0
- package/src/graph/memory/read/read.ts +103 -0
- package/src/graph/memory/scope.ts +29 -0
- package/src/graph/mutate/move.hook.ts +70 -0
- package/src/graph/mutate/mutate.hook.ts +69 -0
- package/src/graph/query/children.hook.ts +136 -0
- package/src/graph/query/graph.hook.ts +13 -0
- package/src/graph/query/neighbors.hook.ts +124 -0
- package/src/graph/query/node.hook.ts +83 -0
- package/src/graph/query/query.hook.ts +42 -0
- package/src/index.ts +202 -0
- package/src/intents/envelope.ts +52 -0
- package/src/intents/index.ts +6 -0
- package/src/intents/listen-intent.hook.ts +92 -0
- package/src/intents/reply.ts +24 -0
- package/src/intents/send-intent.hook.ts +111 -0
- package/src/navigation/adapters/adapter.ts +13 -0
- package/src/navigation/adapters/memory.adapter.ts +22 -0
- package/src/navigation/adapters/url.adapter.ts +61 -0
- package/src/navigation/history.ts +170 -0
- package/src/navigation/hooks/ancestors.hook.ts +71 -0
- package/src/navigation/hooks/location.hook.ts +21 -0
- package/src/navigation/hooks/navigate.hook.ts +43 -0
- package/src/navigation/hooks/scope.hook.ts +34 -0
- package/src/navigation/index.ts +17 -0
- package/src/navigation/link.tsx +110 -0
- package/src/navigation/location.ts +122 -0
- package/src/navigation/scope.context.tsx +267 -0
- package/src/navigation/snapshot.ts +79 -0
- package/src/schema/bind-read.ts +319 -0
- package/src/schema/binding.ts +91 -0
- package/src/schema/domain.hook.ts +16 -0
- package/src/schema/function.hook.ts +68 -0
- package/src/schema/index.ts +25 -0
- package/src/schema/kernel.hook.ts +17 -0
- package/src/schema/method.hook.ts +103 -0
- package/src/schema/tag.ts +19 -0
- package/src/schema/types.ts +150 -0
- package/src/schema/write.ts +80 -0
- package/src/selection/index.ts +5 -0
- package/src/selection/live.ts +142 -0
- package/src/selection/scope.context.tsx +151 -0
- package/src/selection/selection.hook.ts +18 -0
- package/src/session/boot/boot.ts +57 -0
- package/src/session/boot/ownership.ts +54 -0
- package/src/session/boot/status.ts +32 -0
- package/src/session/connection/connection.hook.ts +16 -0
- package/src/session/connection/connection.store.ts +58 -0
- package/src/session/index.ts +8 -0
- package/src/session/kernel-client.hook.ts +13 -0
- package/src/session/kernel-instance.hook.ts +22 -0
- package/src/session/provider.tsx +205 -0
- package/src/session/session.context.ts +27 -0
- package/src/session/shell.hook.ts +19 -0
- package/src/window/adopt.ts +57 -0
- package/src/window/hooks/close-guard.hook.ts +100 -0
- package/src/window/hooks/target-node.hook.ts +94 -0
- package/src/window/hooks/views-for.hook.ts +82 -0
- package/src/window/hooks/window.hook.ts +18 -0
- package/src/window/hooks/windows.hook.ts +40 -0
- package/src/window/host.tsx +347 -0
- package/src/window/hub.ts +156 -0
- package/src/window/index.ts +17 -0
- package/src/window/lifecycle/mount.ts +134 -0
- package/src/window/lifecycle/states.ts +23 -0
- package/src/window/placement.ts +84 -0
- package/src/window/stage.tsx +46 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { BindTypeMismatchError, normalizeRef, } from '@astrale-os/kernel-client';
|
|
2
|
+
import { shapeInputToAST, stableStringify, stripCursors } from '@astrale-os/kernel-client/store';
|
|
3
|
+
import { compileDomain } from '@astrale-os/kernel-core/domain';
|
|
4
|
+
/**
|
|
5
|
+
* Binder-over-memory composition (API §6, §1.7) — consumed by the `graph/query/`
|
|
6
|
+
* overloads. Binds wire `Node`s from the shared memory to stable `BoundNode`s
|
|
7
|
+
* (an unchanged wire node re-binds to the SAME instance), and composes those
|
|
8
|
+
* binders with a `useSyncExternalStore` read substrate (`useShape`) into the typed
|
|
9
|
+
* `useNode`/`useChildren` reads. A typed read and its untyped twin ride the SAME
|
|
10
|
+
* memory shape, so they are one cache entry, one liveness, one overlay.
|
|
11
|
+
*/
|
|
12
|
+
import { useCallback, useMemo, useRef, useSyncExternalStore } from 'react';
|
|
13
|
+
import { useSessionKernel } from '../auth/session-kernel';
|
|
14
|
+
import { idleReadState, isIdleInput } from '../graph/memory/read/idle';
|
|
15
|
+
import { useMemory } from '../graph/memory/scope';
|
|
16
|
+
import { bindingFor } from './binding';
|
|
17
|
+
import { schemaOf, tagSchema } from './tag';
|
|
18
|
+
/** Bind one wire node as `type`; stable while the wire node, binding, and type hold. */
|
|
19
|
+
export function useBoundNode(binding, type, wire) {
|
|
20
|
+
const ref = useRef(null);
|
|
21
|
+
const node = wire ?? null;
|
|
22
|
+
let entry = ref.current;
|
|
23
|
+
if (entry === null || entry.wire !== node || entry.binding !== binding || entry.type !== type) {
|
|
24
|
+
entry = {
|
|
25
|
+
wire: node,
|
|
26
|
+
binding,
|
|
27
|
+
type,
|
|
28
|
+
bound: node === null ? null : binding.bind(type, node),
|
|
29
|
+
};
|
|
30
|
+
ref.current = entry;
|
|
31
|
+
}
|
|
32
|
+
return entry.bound;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Bind many wire nodes as `type`; per-node identity + a stable array on no
|
|
36
|
+
* change. `skipMismatch` drops nodes whose class is not `type` (a mixed-class
|
|
37
|
+
* child set) instead of throwing.
|
|
38
|
+
*/
|
|
39
|
+
export function useBoundNodes(binding, type, wires, skipMismatch = false) {
|
|
40
|
+
const ref = useRef(null);
|
|
41
|
+
if (ref.current === null || ref.current.binding !== binding || ref.current.type !== type) {
|
|
42
|
+
ref.current = { binding, type, perNode: new WeakMap(), last: [] };
|
|
43
|
+
}
|
|
44
|
+
const cache = ref.current;
|
|
45
|
+
const next = [];
|
|
46
|
+
for (const w of wires) {
|
|
47
|
+
let b = cache.perNode.get(w);
|
|
48
|
+
if (b === undefined) {
|
|
49
|
+
try {
|
|
50
|
+
b = binding.bind(type, w);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (skipMismatch && error instanceof BindTypeMismatchError)
|
|
54
|
+
continue;
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
cache.perNode.set(w, b);
|
|
58
|
+
}
|
|
59
|
+
next.push(b);
|
|
60
|
+
}
|
|
61
|
+
if (sameArray(cache.last, next))
|
|
62
|
+
return cache.last;
|
|
63
|
+
cache.last = next;
|
|
64
|
+
return next;
|
|
65
|
+
}
|
|
66
|
+
/** Bind many wire nodes classlessly (traversal endpoints); per-node + stable array. */
|
|
67
|
+
export function useBoundEndpoints(binding, wires) {
|
|
68
|
+
const ref = useRef(null);
|
|
69
|
+
if (ref.current === null || ref.current.binding !== binding) {
|
|
70
|
+
ref.current = { binding, perNode: new WeakMap(), last: [] };
|
|
71
|
+
}
|
|
72
|
+
const cache = ref.current;
|
|
73
|
+
const next = wires.map((w) => {
|
|
74
|
+
let b = cache.perNode.get(w);
|
|
75
|
+
if (b === undefined) {
|
|
76
|
+
b = binding.bindAny(w);
|
|
77
|
+
cache.perNode.set(w, b);
|
|
78
|
+
}
|
|
79
|
+
return b;
|
|
80
|
+
});
|
|
81
|
+
if (sameArray(cache.last, next))
|
|
82
|
+
return cache.last;
|
|
83
|
+
cache.last = next;
|
|
84
|
+
return next;
|
|
85
|
+
}
|
|
86
|
+
function sameArray(a, b) {
|
|
87
|
+
return a.length === b.length && a.every((x, i) => x === b[i]);
|
|
88
|
+
}
|
|
89
|
+
/** Store-facing options — render-time concerns (`suspend`/`keepPrevious`) stay here. */
|
|
90
|
+
function toStoreOptions(opts) {
|
|
91
|
+
if (opts === undefined)
|
|
92
|
+
return undefined;
|
|
93
|
+
const out = {};
|
|
94
|
+
if (opts.live !== undefined)
|
|
95
|
+
out.live = opts.live;
|
|
96
|
+
if (opts.window !== undefined)
|
|
97
|
+
out.window = opts.window;
|
|
98
|
+
if (opts.with !== undefined)
|
|
99
|
+
out.with = opts.with;
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
/** A stable string identity for a (shape, options) pair — the subscription key. */
|
|
103
|
+
function keyOf(shape, opts) {
|
|
104
|
+
const ast = stripCursors(shapeInputToAST(shape));
|
|
105
|
+
return `${stableStringify(ast)}|${opts?.live === false ? '0' : '1'}|${opts?.window ?? ''}|${opts?.with ?? ''}`;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Subscribe to a memory shape. `null` shape → idle (`null`, no I/O). A cold
|
|
109
|
+
* shape suspends unless `suspend: false`. The returned `LiveResult` is the
|
|
110
|
+
* unified read envelope — callers project `node`/`children`/`nodes`.
|
|
111
|
+
*/
|
|
112
|
+
export function useShape(shape, opts) {
|
|
113
|
+
const memory = useMemory();
|
|
114
|
+
const storeOpts = toStoreOptions(opts);
|
|
115
|
+
const key = isIdleInput(shape) ? null : keyOf(shape, opts);
|
|
116
|
+
const subscribe = useCallback((onChange) => {
|
|
117
|
+
if (isIdleInput(shape))
|
|
118
|
+
return () => { };
|
|
119
|
+
return memory.subscribe(shape, onChange, storeOpts);
|
|
120
|
+
},
|
|
121
|
+
// The shape's canonical identity is `key`; the captured `shape` is equivalent.
|
|
122
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
123
|
+
[memory, key]);
|
|
124
|
+
const getSnapshot = useCallback(() => (isIdleInput(shape) ? null : memory.getSnapshot(shape, storeOpts)),
|
|
125
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
126
|
+
[memory, key]);
|
|
127
|
+
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
128
|
+
if (!isIdleInput(shape) && opts?.suspend !== false && memory.peek(shape, storeOpts) === null) {
|
|
129
|
+
// Cold FAILURE (§1.4): a rejected fetch with no data throws to the boundary;
|
|
130
|
+
// re-throwing the promise would re-arm a fetch each retry (infinite loop).
|
|
131
|
+
if (snapshot !== null && snapshot.error !== undefined)
|
|
132
|
+
throw snapshot.error;
|
|
133
|
+
throw memory.promise(shape, storeOpts);
|
|
134
|
+
}
|
|
135
|
+
return snapshot;
|
|
136
|
+
}
|
|
137
|
+
// ── typed reads (schema-first useNode, BoundNode-first useChildren) ──────────────
|
|
138
|
+
export function useNode(schema, type, ref, opts) {
|
|
139
|
+
const binding = bindingFor(useSessionKernel(), schema, useMemory());
|
|
140
|
+
const shape = isIdleInput(ref) ? null : normalizeRef(ref);
|
|
141
|
+
const snap = useShape(shape, opts);
|
|
142
|
+
const wire = snap?.node ?? null;
|
|
143
|
+
const bound = useBoundNode(binding, type, wire);
|
|
144
|
+
if (bound !== null)
|
|
145
|
+
tagSchema(bound, schema);
|
|
146
|
+
const live = snap === null ? idleReadState() : readStateOf(snap);
|
|
147
|
+
return useMemo(() => ({ ...live, node: bound }), [bound, live.pending, live.error, live.live, live.seq]);
|
|
148
|
+
}
|
|
149
|
+
export function useChildren(parent, opts) {
|
|
150
|
+
const kernel = useSessionKernel();
|
|
151
|
+
const memory = useMemory();
|
|
152
|
+
const schema = isIdleInput(parent) ? null : requireSchema(parent);
|
|
153
|
+
const binding = schema === null ? null : bindingFor(kernel, schema, memory);
|
|
154
|
+
const parentRef = isIdleInput(parent) ? null : `@${parent.id}`;
|
|
155
|
+
const classRef = schema === null ? undefined : classRefFor(schema, opts.type);
|
|
156
|
+
const shape = parentRef === null
|
|
157
|
+
? null
|
|
158
|
+
: (q) => q.from(parentRef).children({
|
|
159
|
+
...(classRef !== undefined ? { classes: [classRef] } : {}),
|
|
160
|
+
...(opts.order !== undefined ? { order: opts.order } : {}),
|
|
161
|
+
...(opts.limit !== undefined ? { limit: opts.limit } : {}),
|
|
162
|
+
});
|
|
163
|
+
const snap = useShape(shape, opts);
|
|
164
|
+
const wires = snap?.children ?? EMPTY;
|
|
165
|
+
const bound = useBoundNodes((binding ?? UNBOUND), opts.type, binding === null ? EMPTY : wires, true);
|
|
166
|
+
if (schema !== null)
|
|
167
|
+
for (const b of bound)
|
|
168
|
+
tagSchema(b, schema);
|
|
169
|
+
const live = snap === null ? idleReadState() : readStateOf(snap);
|
|
170
|
+
const more = snap?.more ?? IDLE_MORE;
|
|
171
|
+
return useMemo(() => ({ ...live, more, children: bound }), [bound, more, live.pending, live.error, live.live, live.seq]);
|
|
172
|
+
}
|
|
173
|
+
// ── helpers ──────────────────────────────────────────────────────────────────
|
|
174
|
+
const EMPTY = Object.freeze([]);
|
|
175
|
+
const IDLE_MORE = { has: false, load: () => Promise.resolve(), pending: false };
|
|
176
|
+
const UNBOUND = {};
|
|
177
|
+
function readStateOf(snap) {
|
|
178
|
+
return {
|
|
179
|
+
pending: snap.pending,
|
|
180
|
+
error: snap.error,
|
|
181
|
+
live: snap.live,
|
|
182
|
+
seq: snap.seq,
|
|
183
|
+
refetch: snap.refetch,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/** Recover the schema a BoundNode was bound under; a clear error if it is untagged. */
|
|
187
|
+
export function requireSchema(node) {
|
|
188
|
+
const schema = schemaOf(node);
|
|
189
|
+
if (schema === undefined) {
|
|
190
|
+
throw new Error('useChildren: the parent was not produced by a shell-react typed binding — ' +
|
|
191
|
+
'obtain it from useNode / useDomain(schema).bind() so its schema is known.');
|
|
192
|
+
}
|
|
193
|
+
return schema;
|
|
194
|
+
}
|
|
195
|
+
const compiledCache = new WeakMap();
|
|
196
|
+
/** The descent class ref for a type name (class or interface), or undefined. */
|
|
197
|
+
function classRefFor(schema, type) {
|
|
198
|
+
let compiled = compiledCache.get(schema);
|
|
199
|
+
if (compiled === undefined) {
|
|
200
|
+
compiled = compileDomain(schema);
|
|
201
|
+
compiledCache.set(schema, compiled);
|
|
202
|
+
}
|
|
203
|
+
const accessor = compiled.$;
|
|
204
|
+
return accessor.c(type)?.path?.class?.raw ?? accessor.i(type)?.path?.class?.raw;
|
|
205
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bindingFor(kernel, schema) — memoized `withSchema` handles (API §6). The
|
|
3
|
+
* `withSchema` handle is a *binding*, never a "view". Memoizes
|
|
4
|
+
* `createSchemaBoundView` per (session, schema) so a binding — and the BoundNodes
|
|
5
|
+
* it mints — keep referential identity across renders. Each binding is wrapped so
|
|
6
|
+
* every BoundNode it hands back is schema-tagged (the traversal hooks read it
|
|
7
|
+
* back) and its `id → tree path` recorded (the write capability's index).
|
|
8
|
+
*/
|
|
9
|
+
import type { FnMap, NodeRefInput, SchemaBoundView } from '@astrale-os/kernel-client';
|
|
10
|
+
import type { GraphMemory } from '@astrale-os/kernel-client/store';
|
|
11
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
12
|
+
import type { SessionView } from '../auth/act-as.context';
|
|
13
|
+
/**
|
|
14
|
+
* Resolve (and memoize) the tagged schema-bound handle for `schema` on `kernel`.
|
|
15
|
+
* `kernel` is the EFFECTIVE dispatch kernel (root or `<ActAs>` — §4); the cache is
|
|
16
|
+
* keyed on it, so an acted-as subtree gets its own memoized bindings for free.
|
|
17
|
+
* `memory` is the SAME scoped memory the read hooks use (1:1 with `kernel`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function bindingFor<S extends Schema>(kernel: SessionView, schema: S, memory: GraphMemory): SchemaBoundView<S, FnMap>;
|
|
20
|
+
export type { NodeRefInput };
|
|
21
|
+
//# sourceMappingURL=binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../src/schema/binding.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAElE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAUzD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EACzC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,WAAW,GAClB,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC,CAa3B;AA0CD,YAAY,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createSchemaBoundView } from '@astrale-os/kernel-client';
|
|
2
|
+
import { tagSchema } from './tag';
|
|
3
|
+
import { recordPath, writableFor } from './write';
|
|
4
|
+
/** One tagged binding per (kernel, schema) — shared across the whole tree. */
|
|
5
|
+
const bindingCache = new WeakMap();
|
|
6
|
+
/**
|
|
7
|
+
* Resolve (and memoize) the tagged schema-bound handle for `schema` on `kernel`.
|
|
8
|
+
* `kernel` is the EFFECTIVE dispatch kernel (root or `<ActAs>` — §4); the cache is
|
|
9
|
+
* keyed on it, so an acted-as subtree gets its own memoized bindings for free.
|
|
10
|
+
* `memory` is the SAME scoped memory the read hooks use (1:1 with `kernel`).
|
|
11
|
+
*/
|
|
12
|
+
export function bindingFor(kernel, schema, memory) {
|
|
13
|
+
let bySchema = bindingCache.get(kernel);
|
|
14
|
+
if (bySchema === undefined) {
|
|
15
|
+
bySchema = new WeakMap();
|
|
16
|
+
bindingCache.set(kernel, bySchema);
|
|
17
|
+
}
|
|
18
|
+
let binding = bySchema.get(schema);
|
|
19
|
+
if (binding === undefined) {
|
|
20
|
+
const { writable, pathIndex } = writableFor(kernel, memory);
|
|
21
|
+
binding = tagBinding(createSchemaBoundView(writable, schema), schema, pathIndex);
|
|
22
|
+
bySchema.set(schema, binding);
|
|
23
|
+
}
|
|
24
|
+
return binding;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Wrap a binding so `bind`/`bindAny`/`as` outputs carry a schema tag, and every
|
|
28
|
+
* bound wire node's `id → tree path` is recorded (the write cap's index); the
|
|
29
|
+
* bare-call dispatch and every other member pass straight through.
|
|
30
|
+
*/
|
|
31
|
+
function tagBinding(binding, schema, pathIndex) {
|
|
32
|
+
const handler = {
|
|
33
|
+
apply: (target, _thisArg, args) => target(...args),
|
|
34
|
+
get: (target, prop, receiver) => {
|
|
35
|
+
const value = Reflect.get(target, prop, receiver);
|
|
36
|
+
if (prop === 'bind') {
|
|
37
|
+
return (type, node, opts) => {
|
|
38
|
+
recordPath(pathIndex, node);
|
|
39
|
+
return tagSchema(value(type, node, opts), schema);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (prop === 'bindAny') {
|
|
43
|
+
return (node) => {
|
|
44
|
+
recordPath(pathIndex, node);
|
|
45
|
+
return tagSchema(value(node), schema);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (prop === 'as') {
|
|
49
|
+
return (credential) => tagBinding(value(credential), schema, pathIndex);
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
return new Proxy(binding, handler);
|
|
55
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useDomain(schema) (API §6) — the typed domain binding, `kernel.withSchema(schema)`,
|
|
3
|
+
* memoized per (effective session, schema). The BoundNodes it mints ride the
|
|
4
|
+
* shared scoped memory, so typed writes are optimistic and revalidate (§6).
|
|
5
|
+
*/
|
|
6
|
+
import type { FnMap, SchemaBoundView } from '@astrale-os/kernel-client';
|
|
7
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
8
|
+
/** The typed domain binding — `kernel.withSchema(schema)`, memoized per (session, schema). */
|
|
9
|
+
export declare function useDomain<S extends Schema>(schema: S): SchemaBoundView<S, FnMap>;
|
|
10
|
+
//# sourceMappingURL=domain.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain.hook.d.ts","sourceRoot":"","sources":["../../src/schema/domain.hook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAMpD,8FAA8F;AAC9F,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC,CAEhF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useSessionKernel } from '../auth/session-kernel';
|
|
2
|
+
import { useMemory } from '../graph/memory/scope';
|
|
3
|
+
import { bindingFor } from './binding';
|
|
4
|
+
/** The typed domain binding — `kernel.withSchema(schema)`, memoized per (session, schema). */
|
|
5
|
+
export function useDomain(schema) {
|
|
6
|
+
return bindingFor(useSessionKernel(), schema, useMemory());
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
2
|
+
import type { Action } from '../graph/action';
|
|
3
|
+
import type { FunctionNames, FunctionParams, FunctionResult } from './types';
|
|
4
|
+
export interface FunctionOptions {
|
|
5
|
+
/** Extra failure channel; the action still rejects and records `.error`. */
|
|
6
|
+
onError?: (error: unknown) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function useFunction<S extends Schema, F extends FunctionNames<S>>(schema: S, fn: F, opts?: FunctionOptions): Action<[FunctionParams<S, F>], FunctionResult<S, F>>;
|
|
9
|
+
//# sourceMappingURL=function.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.hook.d.ts","sourceRoot":"","sources":["../../src/schema/function.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAWpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAK5E,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CACnC;AAoBD,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,EACtE,MAAM,EAAE,CAAC,EACT,EAAE,EAAE,CAAC,EACL,IAAI,CAAC,EAAE,eAAe,GACrB,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAuBtD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { compileDomain } from '@astrale-os/kernel-core/domain';
|
|
2
|
+
/**
|
|
3
|
+
* `useFunction` (API §6) — `useMethod`'s sibling for a domain's top-level
|
|
4
|
+
* standalone functions (the `functions` map of `defineSchema`). Dispatched by the
|
|
5
|
+
* compiled FunctionPath from the compiled-domain accessor, never string-built.
|
|
6
|
+
* Dispatch is correct but not compile-time typed (see the note in schema/types.ts).
|
|
7
|
+
*/
|
|
8
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
9
|
+
import { useAction } from '../graph/action';
|
|
10
|
+
import { useDomain } from './domain.hook';
|
|
11
|
+
const compiledCache = new WeakMap();
|
|
12
|
+
/** The dispatch path for a standalone function, from the compiled accessor. */
|
|
13
|
+
function functionPathOf(schema, name) {
|
|
14
|
+
let compiled = compiledCache.get(schema);
|
|
15
|
+
if (compiled === undefined) {
|
|
16
|
+
compiled = compileDomain(schema);
|
|
17
|
+
compiledCache.set(schema, compiled);
|
|
18
|
+
}
|
|
19
|
+
const entry = compiled.$.f(name);
|
|
20
|
+
if (entry === undefined) {
|
|
21
|
+
throw new Error(`Unknown function '${name}' in schema '${schema.domain}'`);
|
|
22
|
+
}
|
|
23
|
+
return entry.path.domain.raw;
|
|
24
|
+
}
|
|
25
|
+
export function useFunction(schema, fn, opts) {
|
|
26
|
+
const binding = useDomain(schema);
|
|
27
|
+
const path = useMemo(() => functionPathOf(schema, String(fn)), [schema, fn]);
|
|
28
|
+
const onErrorRef = useRef(opts?.onError);
|
|
29
|
+
onErrorRef.current = opts?.onError;
|
|
30
|
+
const call = useCallback(async (params) => {
|
|
31
|
+
try {
|
|
32
|
+
return (await binding.raw.call(path, params));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
onErrorRef.current?.(error);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}, [binding, path]);
|
|
39
|
+
return useAction(call);
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { useKernel } from './kernel.hook';
|
|
2
|
+
export { useDomain } from './domain.hook';
|
|
3
|
+
export { useNode, useChildren, useBoundNode, useBoundNodes, useBoundEndpoints } from './bind-read';
|
|
4
|
+
export { useOut, useIn } from '../graph/query/neighbors.hook';
|
|
5
|
+
export { useMethod } from './method.hook';
|
|
6
|
+
export type { MethodOptions } from './method.hook';
|
|
7
|
+
export { useFunction } from './function.hook';
|
|
8
|
+
export type { FunctionOptions } from './function.hook';
|
|
9
|
+
export type { AutoMethodAction, BoundMethodAction, EndpointResult, FunctionNames, FunctionParams, FunctionResult, MethodIsStatic, MethodNames, MethodParams, MethodResult, TargetedMethodAction, TypedChildrenResult, TypedNodeResult, } from './types';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAClG,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,GAChB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// schema — the typing substrate (API §6). Typed kernel/domain bindings, typed
|
|
2
|
+
// reads, method/function dispatch. See SHELL_REACT_API.md.
|
|
3
|
+
export { useKernel } from './kernel.hook';
|
|
4
|
+
export { useDomain } from './domain.hook';
|
|
5
|
+
export { useNode, useChildren, useBoundNode, useBoundNodes, useBoundEndpoints } from './bind-read';
|
|
6
|
+
export { useOut, useIn } from '../graph/query/neighbors.hook';
|
|
7
|
+
export { useMethod } from './method.hook';
|
|
8
|
+
export { useFunction } from './function.hook';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useKernel (API §6) — the typed kernel, `kernel.withSchema(KernelSchema)`,
|
|
3
|
+
* memoized per (effective) session. The kernel's own schema baked in; dispatch
|
|
4
|
+
* and reads run as the subtree's principal over its scoped memory (§4).
|
|
5
|
+
*/
|
|
6
|
+
import type { FnMap, SchemaBoundView } from '@astrale-os/kernel-client';
|
|
7
|
+
import { KernelSchema } from '@astrale-os/kernel-core';
|
|
8
|
+
/** The typed kernel — `kernel.withSchema(KernelSchema)`, memoized (§4-scoped). */
|
|
9
|
+
export declare function useKernel(): SchemaBoundView<typeof KernelSchema, FnMap>;
|
|
10
|
+
//# sourceMappingURL=kernel.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel.hook.d.ts","sourceRoot":"","sources":["../../src/schema/kernel.hook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAMtD,kFAAkF;AAClF,wBAAgB,SAAS,IAAI,eAAe,CAAC,OAAO,YAAY,EAAE,KAAK,CAAC,CAEvE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { KernelSchema } from '@astrale-os/kernel-core';
|
|
2
|
+
import { useSessionKernel } from '../auth/session-kernel';
|
|
3
|
+
import { useMemory } from '../graph/memory/scope';
|
|
4
|
+
import { bindingFor } from './binding';
|
|
5
|
+
/** The typed kernel — `kernel.withSchema(KernelSchema)`, memoized (§4-scoped). */
|
|
6
|
+
export function useKernel() {
|
|
7
|
+
return bindingFor(useSessionKernel(), KernelSchema, useMemory());
|
|
8
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NodeRefInput, TypeNames } from '@astrale-os/kernel-client';
|
|
2
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
3
|
+
import type { AutoMethodAction, BoundMethodAction, MethodNames } from './types';
|
|
4
|
+
export interface MethodOptions {
|
|
5
|
+
/** Bind the action to this node — dispatch as `action(params)`. */
|
|
6
|
+
on?: NodeRefInput;
|
|
7
|
+
/** Extra failure channel; the action still rejects and records `.error`. */
|
|
8
|
+
onError?: (error: unknown) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function useMethod<S extends Schema, T extends TypeNames<S>, M extends MethodNames<S, T>>(schema: S, type: T, method: M, opts: MethodOptions & {
|
|
11
|
+
on: NodeRefInput;
|
|
12
|
+
}): BoundMethodAction<S, T, M>;
|
|
13
|
+
export declare function useMethod<S extends Schema, T extends TypeNames<S>, M extends MethodNames<S, T>>(schema: S, type: T, method: M, opts?: MethodOptions): AutoMethodAction<S, T, M>;
|
|
14
|
+
//# sourceMappingURL=method.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method.hook.d.ts","sourceRoot":"","sources":["../../src/schema/method.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAcpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAK/E,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,EAAE,CAAC,EAAE,YAAY,CAAA;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CACnC;AAID,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC7F,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,aAAa,GAAG;IAAE,EAAE,EAAE,YAAY,CAAA;CAAE,GACzC,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AAC7B,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC7F,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,CAAC,EACT,IAAI,CAAC,EAAE,aAAa,GACnB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { resolveAllMethods } from '@astrale-os/kernel-dsl';
|
|
2
|
+
/**
|
|
3
|
+
* `useMethod` (API §6) — typed method dispatch with call state. Three forms,
|
|
4
|
+
* selected by the method's static-ness and whether `on` is given:
|
|
5
|
+
* static → action(params)
|
|
6
|
+
* instance + on → action(params) (bound to that node)
|
|
7
|
+
* instance, no on → action(ref, params)
|
|
8
|
+
* Params/result come from the method's Zod contracts.
|
|
9
|
+
*/
|
|
10
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
11
|
+
import { useAction } from '../graph/action';
|
|
12
|
+
import { useDomain } from './domain.hook';
|
|
13
|
+
export function useMethod(schema, type, method, opts) {
|
|
14
|
+
const binding = useDomain(schema);
|
|
15
|
+
const on = opts?.on;
|
|
16
|
+
const isStatic = useMemo(() => detectStatic(schema, type, String(method)), [schema, type, method]);
|
|
17
|
+
const onErrorRef = useRef(opts?.onError);
|
|
18
|
+
onErrorRef.current = opts?.onError;
|
|
19
|
+
const call = useCallback(async (...args) => {
|
|
20
|
+
const name = String(method);
|
|
21
|
+
try {
|
|
22
|
+
if (on !== undefined)
|
|
23
|
+
return await instance(binding, type, on, name, args[0]);
|
|
24
|
+
if (isStatic)
|
|
25
|
+
return await staticCall(binding, type, name, args[0]);
|
|
26
|
+
return await instance(binding, type, args[0], name, args[1]);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
onErrorRef.current?.(error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}, [binding, type, method, on, isStatic]);
|
|
33
|
+
return useAction(call);
|
|
34
|
+
}
|
|
35
|
+
function staticCall(binding, type, method, params) {
|
|
36
|
+
return binding(type)[method](params);
|
|
37
|
+
}
|
|
38
|
+
function instance(binding, type, ref, method, params) {
|
|
39
|
+
return binding(type, ref)[method](params);
|
|
40
|
+
}
|
|
41
|
+
/** Read the method's `static` flag from the schema (own + inherited). */
|
|
42
|
+
function detectStatic(schema, type, method) {
|
|
43
|
+
const def = schema.classes[type] ??
|
|
44
|
+
schema.interfaces[type];
|
|
45
|
+
if (def === undefined)
|
|
46
|
+
return false;
|
|
47
|
+
const methods = resolveAllMethods(def);
|
|
48
|
+
return methods[method]?.config.static === true;
|
|
49
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-tagging of raw nodes (API §6, the bindAny bridge). A module-level tag
|
|
3
|
+
* records the schema each BoundNode was bound under, so the traversal hooks can
|
|
4
|
+
* recover it from the node alone (`useChildren`/`useOut`/`useIn` re-bind endpoints).
|
|
5
|
+
*/
|
|
6
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
7
|
+
/** Record the schema a BoundNode was bound under; returns the node unchanged. */
|
|
8
|
+
export declare function tagSchema<N>(node: N, schema: Schema): N;
|
|
9
|
+
/** The schema a BoundNode was bound under, if it came from a shell-react binding. */
|
|
10
|
+
export declare function schemaOf(node: object): Schema | undefined;
|
|
11
|
+
//# sourceMappingURL=tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/schema/tag.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAGvD;AAED,qFAAqF;AACrF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEzD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const schemaOfNode = new WeakMap();
|
|
2
|
+
/** Record the schema a BoundNode was bound under; returns the node unchanged. */
|
|
3
|
+
export function tagSchema(node, schema) {
|
|
4
|
+
if (node !== null && typeof node === 'object')
|
|
5
|
+
schemaOfNode.set(node, schema);
|
|
6
|
+
return node;
|
|
7
|
+
}
|
|
8
|
+
/** The schema a BoundNode was bound under, if it came from a shell-react binding. */
|
|
9
|
+
export function schemaOf(node) {
|
|
10
|
+
return schemaOfNode.get(node);
|
|
11
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-level surface for the schema module (API §6): the read envelopes
|
|
3
|
+
* (`TypedNodeResult`/`TypedChildrenResult`/`EndpointResult`) and the method /
|
|
4
|
+
* function contract projections. Param inference mirrors the client's proxy
|
|
5
|
+
* types (Zod optionality preserved), re-derived here because it is not exported.
|
|
6
|
+
*/
|
|
7
|
+
import type { AnyBoundNode, BoundNode, DefOf, EdgeNames, EndpointsOf, NodeRefInput, TypeNames } from '@astrale-os/kernel-client';
|
|
8
|
+
import type { z } from '@astrale-os/kernel-core';
|
|
9
|
+
import type { AllMethods, ExtractMethodNames, ExtractMethodParams, ExtractMethodReturnValue, Schema } from '@astrale-os/kernel-dsl';
|
|
10
|
+
import type { Action } from '../graph/action';
|
|
11
|
+
import type { ReadState, Windowed } from '../graph/memory/read/envelope';
|
|
12
|
+
export interface TypedNodeResult<S extends Schema, T extends TypeNames<S>> extends ReadState {
|
|
13
|
+
readonly node: BoundNode<DefOf<S, T>, S> | null;
|
|
14
|
+
}
|
|
15
|
+
export interface TypedChildrenResult<S extends Schema, T extends TypeNames<S>> extends ReadState, Windowed {
|
|
16
|
+
readonly children: readonly BoundNode<DefOf<S, T>, S>[];
|
|
17
|
+
}
|
|
18
|
+
/** Cardinality decides the envelope key: single|null for `1`/`0..1`, array otherwise. */
|
|
19
|
+
export type EndpointResult<S extends Schema, E extends EdgeNames<S>, Side extends 'from' | 'to'> = EndpointsOf<S, E, Side> extends readonly unknown[] ? ReadState & {
|
|
20
|
+
readonly nodes: EndpointsOf<S, E, Side>;
|
|
21
|
+
} : ReadState & {
|
|
22
|
+
readonly node: EndpointsOf<S, E, Side>;
|
|
23
|
+
};
|
|
24
|
+
/** Untyped traversal fallback — mirrors the raw `neighbors` shorthand. */
|
|
25
|
+
export interface UntypedEndpointResult<S extends Schema> extends ReadState, Windowed {
|
|
26
|
+
readonly nodes: readonly AnyBoundNode<S>[];
|
|
27
|
+
}
|
|
28
|
+
/** Dispatchable method names on `type` (own + inherited). */
|
|
29
|
+
export type MethodNames<S extends Schema, T extends TypeNames<S>> = ExtractMethodNames<DefOf<S, T>>;
|
|
30
|
+
type OptionalKeys<P> = {
|
|
31
|
+
[K in keyof P]: P[K] extends z.ZodOptional<any> | z.ZodDefault<any> ? K : never;
|
|
32
|
+
}[keyof P];
|
|
33
|
+
type RequiredKeys<P> = Exclude<keyof P, OptionalKeys<P>>;
|
|
34
|
+
type InferParams<P> = {
|
|
35
|
+
[K in RequiredKeys<P>]: P[K] extends z.ZodType<infer T> ? T : never;
|
|
36
|
+
} & {
|
|
37
|
+
[K in OptionalKeys<P>]?: P[K] extends z.ZodType<infer T> ? T : never;
|
|
38
|
+
};
|
|
39
|
+
type Simplify<T> = {
|
|
40
|
+
[K in keyof T]: T[K];
|
|
41
|
+
};
|
|
42
|
+
/** Runtime params object for method `M` on `type`. */
|
|
43
|
+
export type MethodParams<S extends Schema, T extends TypeNames<S>, M extends MethodNames<S, T>> = Simplify<InferParams<ExtractMethodParams<DefOf<S, T>, M & string>>>;
|
|
44
|
+
/** Resolved return value of method `M` on `type`. */
|
|
45
|
+
export type MethodResult<S extends Schema, T extends TypeNames<S>, M extends MethodNames<S, T>> = ExtractMethodReturnValue<DefOf<S, T>, M & string>;
|
|
46
|
+
/** True when method `M` on `type` is static. */
|
|
47
|
+
export type MethodIsStatic<S extends Schema, T extends TypeNames<S>, M extends MethodNames<S, T>> = M extends keyof AllMethods<DefOf<S, T>> ? AllMethods<DefOf<S, T>>[M] extends {
|
|
48
|
+
config: {
|
|
49
|
+
static: true;
|
|
50
|
+
};
|
|
51
|
+
} ? true : false : false;
|
|
52
|
+
/** Action for a `on`-bound or static method: `action(params)`. */
|
|
53
|
+
export type BoundMethodAction<S extends Schema, T extends TypeNames<S>, M extends MethodNames<S, T>> = Action<[MethodParams<S, T, M>], MethodResult<S, T, M>>;
|
|
54
|
+
/** Action for an unbound instance method: `action(ref, params)`. */
|
|
55
|
+
export type TargetedMethodAction<S extends Schema, T extends TypeNames<S>, M extends MethodNames<S, T>> = Action<[ref: NodeRefInput, params: MethodParams<S, T, M>], MethodResult<S, T, M>>;
|
|
56
|
+
/** Static → `action(params)`; instance → `action(ref, params)` (no `on`). */
|
|
57
|
+
export type AutoMethodAction<S extends Schema, T extends TypeNames<S>, M extends MethodNames<S, T>> = MethodIsStatic<S, T, M> extends true ? BoundMethodAction<S, T, M> : TargetedMethodAction<S, T, M>;
|
|
58
|
+
/** Standalone top-level function names of the schema (widens to `string` today — see above). */
|
|
59
|
+
export type FunctionNames<S extends Schema> = keyof S['functions'] & string;
|
|
60
|
+
/** Input value of standalone function `F` (`unknown` for a widened `FuncDef` — see above). */
|
|
61
|
+
export type FunctionParams<S extends Schema, F extends FunctionNames<S>> = S['functions'][F] extends {
|
|
62
|
+
config: {
|
|
63
|
+
input: infer I;
|
|
64
|
+
};
|
|
65
|
+
} ? I extends z.ZodType ? z.infer<I> : never : never;
|
|
66
|
+
/** Output value of standalone function `F` (`unknown` for a widened `FuncDef` — see above). */
|
|
67
|
+
export type FunctionResult<S extends Schema, F extends FunctionNames<S>> = S['functions'][F] extends {
|
|
68
|
+
config: {
|
|
69
|
+
output: infer O;
|
|
70
|
+
};
|
|
71
|
+
} ? O extends z.ZodType ? z.infer<O> : never : never;
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
|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KAAE,CAAA;CAAE,GACxD,CAAC,SAAS,CAAC,CAAC,OAAO,GACjB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GACV,KAAK,GACP,KAAK,CAAA;AAET,+FAA+F;AAC/F,MAAM,MAAM,cAAc,CACxB,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,IACxB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAA;CAAE,GACzD,CAAC,SAAS,CAAC,CAAC,OAAO,GACjB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GACV,KAAK,GACP,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GraphMemory } from '@astrale-os/kernel-client/store';
|
|
2
|
+
import type { SessionView } from '../auth/act-as.context';
|
|
3
|
+
/**
|
|
4
|
+
* One memory-backed writable kernel per (effective) session view, plus the
|
|
5
|
+
* bind-time `id → tree-path` index it consults. Shared across every schema binding
|
|
6
|
+
* over the same session so a node bound under any schema resolves for a write.
|
|
7
|
+
*/
|
|
8
|
+
export interface WritableKernel {
|
|
9
|
+
readonly writable: SessionView;
|
|
10
|
+
readonly pathIndex: Map<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export declare function writableFor(kernel: SessionView, memory: GraphMemory): WritableKernel;
|
|
13
|
+
/** Record a bound node's `id → tree path` so the write cap can address it. */
|
|
14
|
+
export declare function recordPath(pathIndex: Map<string, string>, node: unknown): void;
|
|
15
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/schema/write.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACxC;AAGD,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,cAAc,CAQpF;AAwCD,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAK9E"}
|