@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,7 @@
|
|
|
1
|
+
import type { AnyBoundNode, EdgeNames } from '@astrale-os/kernel-client';
|
|
2
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
3
|
+
import type { EndpointResult } from '../../schema/types';
|
|
4
|
+
import type { ReadOptions } from '../memory/read/envelope';
|
|
5
|
+
export declare function useOut<S extends Schema, E extends EdgeNames<S>>(node: AnyBoundNode<S> | null | undefined, edge: E, opts?: ReadOptions): EndpointResult<S, E, 'to'>;
|
|
6
|
+
export declare function useIn<S extends Schema, E extends EdgeNames<S>>(node: AnyBoundNode<S> | null | undefined, edge: E, opts?: ReadOptions): EndpointResult<S, E, 'from'>;
|
|
7
|
+
//# sourceMappingURL=neighbors.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neighbors.hook.d.ts","sourceRoot":"","sources":["../../../src/graph/query/neighbors.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AASpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAKrE,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAC7D,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EACxC,IAAI,EAAE,CAAC,EACP,IAAI,CAAC,EAAE,WAAW,GACjB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAE5B;AAED,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAC5D,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EACxC,IAAI,EAAE,CAAC,EACP,IAAI,CAAC,EAAE,WAAW,GACjB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAE9B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useOut / useIn (API §6) — the public typed traversal read hooks. Resolve
|
|
3
|
+
* endpoints one-shot through `BoundNode.out/in` (`live: false`); become live with
|
|
4
|
+
* no surface change once edge-endpoint ids land. Deviations tracked in API §6/G6.
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import { schemaOf, tagSchema } from '../../schema/tag';
|
|
8
|
+
import { isIdleInput } from '../memory/read/idle';
|
|
9
|
+
export function useOut(node, edge, opts) {
|
|
10
|
+
return useEndpoint(node, edge, 'out', opts);
|
|
11
|
+
}
|
|
12
|
+
export function useIn(node, edge, opts) {
|
|
13
|
+
return useEndpoint(node, edge, 'in', opts);
|
|
14
|
+
}
|
|
15
|
+
function useEndpoint(node, edge, side, _opts) {
|
|
16
|
+
const schema = isIdleInput(node) ? undefined : schemaOf(node);
|
|
17
|
+
const run = useCallback(async () => {
|
|
18
|
+
if (isIdleInput(node))
|
|
19
|
+
return null;
|
|
20
|
+
// AnyBoundNode omits traversal at the type level; the runtime node (bindAny
|
|
21
|
+
// → createBoundNode) carries out/in. The edge name is typed by the caller.
|
|
22
|
+
const t = node;
|
|
23
|
+
const result = await (side === 'out' ? t.out(edge) : t.in(edge));
|
|
24
|
+
if (schema !== undefined)
|
|
25
|
+
tagEndpoints(result, schema);
|
|
26
|
+
return result;
|
|
27
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
+
}, [node?.id, edge, side]);
|
|
29
|
+
const { data, pending, error, refetch } = useAsyncRead(isIdleInput(node) ? null : run, [
|
|
30
|
+
node?.id ?? null,
|
|
31
|
+
edge,
|
|
32
|
+
side,
|
|
33
|
+
]);
|
|
34
|
+
return useMemo(() => {
|
|
35
|
+
const live = { pending, error, live: false, seq: 0, refetch };
|
|
36
|
+
if (isIdleInput(node))
|
|
37
|
+
return { ...live, node: null, nodes: EMPTY };
|
|
38
|
+
if (Array.isArray(data))
|
|
39
|
+
return { ...live, nodes: data };
|
|
40
|
+
return { ...live, node: (data ?? null) };
|
|
41
|
+
}, [node, data, pending, error, refetch]);
|
|
42
|
+
}
|
|
43
|
+
// ── helpers ──────────────────────────────────────────────────────────────────
|
|
44
|
+
const EMPTY = Object.freeze([]);
|
|
45
|
+
function tagEndpoints(result, schema) {
|
|
46
|
+
if (Array.isArray(result))
|
|
47
|
+
for (const r of result)
|
|
48
|
+
tagSchema(r, schema);
|
|
49
|
+
else if (result !== null && result !== undefined)
|
|
50
|
+
tagSchema(result, schema);
|
|
51
|
+
}
|
|
52
|
+
/** One-shot async read with pending/error/refetch and stale-response guarding. */
|
|
53
|
+
function useAsyncRead(run, deps) {
|
|
54
|
+
const [state, setState] = useState({ pending: run !== null, error: undefined });
|
|
55
|
+
const runRef = useRef(run);
|
|
56
|
+
runRef.current = run;
|
|
57
|
+
const seq = useRef(0);
|
|
58
|
+
const refetch = useCallback(() => {
|
|
59
|
+
const current = runRef.current;
|
|
60
|
+
if (current === null) {
|
|
61
|
+
setState({ pending: false, error: undefined, data: undefined });
|
|
62
|
+
return Promise.resolve();
|
|
63
|
+
}
|
|
64
|
+
const my = ++seq.current;
|
|
65
|
+
setState((s) => ({ ...s, pending: true, error: undefined }));
|
|
66
|
+
return current().then((data) => {
|
|
67
|
+
if (my === seq.current)
|
|
68
|
+
setState({ data, pending: false, error: undefined });
|
|
69
|
+
}, (error) => {
|
|
70
|
+
if (my === seq.current)
|
|
71
|
+
setState((s) => ({ data: s.data, pending: false, error }));
|
|
72
|
+
});
|
|
73
|
+
}, []);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
void refetch();
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
}, deps);
|
|
78
|
+
return { ...state, refetch };
|
|
79
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NodeRefInput, TypeNames } from '@astrale-os/kernel-client';
|
|
2
|
+
import type { PathLike } from '@astrale-os/kernel-client/graph';
|
|
3
|
+
import type { Schema } from '@astrale-os/kernel-dsl';
|
|
4
|
+
import type { TypedNodeResult } from '../../schema/types';
|
|
5
|
+
import type { ReadState, Node, ReadOptions } from '../memory/read/envelope';
|
|
6
|
+
export interface NodeResult extends ReadState {
|
|
7
|
+
/** The node, or `null` when missing ≡ masked (never throws NOT_FOUND). */
|
|
8
|
+
readonly node: Node | null;
|
|
9
|
+
}
|
|
10
|
+
/** Typed: one node bound under `schema` as `type`. */
|
|
11
|
+
export declare function useNode<S extends Schema, T extends TypeNames<S>>(schema: S, type: T, ref: NodeRefInput | null | undefined, opts?: ReadOptions): TypedNodeResult<S, T>;
|
|
12
|
+
/** Untyped: one node by ref — `null` ref is idle (§1.3). */
|
|
13
|
+
export declare function useNode(ref: PathLike | null | undefined, opts?: ReadOptions): NodeResult;
|
|
14
|
+
//# sourceMappingURL=node.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.hook.d.ts","sourceRoot":"","sources":["../../../src/graph/query/node.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAWpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAK3E,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;CAC3B;AAiCD,sDAAsD;AACtD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAC9D,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,EACpC,IAAI,CAAC,EAAE,WAAW,GACjB,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACxB,4DAA4D;AAC5D,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useNode (API §5 + §6) — ONE public symbol, overloaded: pass a `Schema` (+ type)
|
|
3
|
+
* for the typed `BoundNode` result, or a bare ref for the untyped `Node` result.
|
|
4
|
+
* Both forms ride the SAME memory shape — a typed read and its untyped twin are
|
|
5
|
+
* one cache entry, one liveness, one overlay. The runtime dispatches on the first
|
|
6
|
+
* argument; a given call site is always one form, so hook order is stable.
|
|
7
|
+
*/
|
|
8
|
+
import { useMemo } from 'react';
|
|
9
|
+
import { useNode as useNodeTyped } from '../../schema/bind-read';
|
|
10
|
+
import { useRead } from '../memory/read/read';
|
|
11
|
+
/**
|
|
12
|
+
* A `Schema` (from `defineSchema`) — its shape (`domain`/`classes`/`interfaces`)
|
|
13
|
+
* is disjoint from a `PathLike` (`string | Path`), so this cleanly routes the
|
|
14
|
+
* typed vs untyped overload at runtime.
|
|
15
|
+
*/
|
|
16
|
+
function isSchema(value) {
|
|
17
|
+
return (typeof value === 'object' &&
|
|
18
|
+
value !== null &&
|
|
19
|
+
'domain' in value &&
|
|
20
|
+
'classes' in value &&
|
|
21
|
+
'interfaces' in value);
|
|
22
|
+
}
|
|
23
|
+
/** One node by path — live, suspense-first; `null` ref is idle (§1.3). */
|
|
24
|
+
function useNodeUntyped(ref, opts) {
|
|
25
|
+
const r = useRead(ref, opts);
|
|
26
|
+
return useMemo(() => ({
|
|
27
|
+
pending: r.pending,
|
|
28
|
+
error: r.error,
|
|
29
|
+
live: r.live,
|
|
30
|
+
seq: r.seq,
|
|
31
|
+
refetch: r.refetch,
|
|
32
|
+
node: r.first,
|
|
33
|
+
}), [r]);
|
|
34
|
+
}
|
|
35
|
+
// The implementation signature returns an erased supertype of both result
|
|
36
|
+
// shapes — every overload above is assignable to it regardless of `BoundNode`
|
|
37
|
+
// variance; callers only ever see the precise overload return types.
|
|
38
|
+
export function useNode(a, b, c, d) {
|
|
39
|
+
if (isSchema(a)) {
|
|
40
|
+
return useNodeTyped(a, b, c, d);
|
|
41
|
+
}
|
|
42
|
+
return useNodeUntyped(a, b);
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GatherBuilder, QueryASTInput, QuerySource } from '@astrale-os/kernel-client/graph';
|
|
2
|
+
import type { ReadState, Node, ReadOptions, Windowed } from '../memory/read/envelope';
|
|
3
|
+
export interface QueryResult extends ReadState, Windowed {
|
|
4
|
+
readonly nodes: readonly Node[];
|
|
5
|
+
readonly roots: readonly Node[];
|
|
6
|
+
readonly first: Node | null;
|
|
7
|
+
gathered(alias: string): {
|
|
8
|
+
readonly nodes: readonly Node[];
|
|
9
|
+
readonly first: Node | null;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/** A structured read — builder callback or AST value; `null` is idle (§1.3). */
|
|
13
|
+
export declare function useQuery(build: ((q: QuerySource) => GatherBuilder) | QueryASTInput | null | undefined, opts?: ReadOptions): QueryResult;
|
|
14
|
+
//# sourceMappingURL=query.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.hook.d.ts","sourceRoot":"","sources":["../../../src/graph/query/query.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAShG,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAIrF,MAAM,WAAW,WAAY,SAAQ,SAAS,EAAE,QAAQ;IACtD,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,CAAA;CAC1F;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CACtB,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,aAAa,CAAC,GAAG,aAAa,GAAG,IAAI,GAAG,SAAS,EAC7E,IAAI,CAAC,EAAE,WAAW,GACjB,WAAW,CAiBb"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useQuery (API §5) — a structured read: a builder callback or an AST value;
|
|
3
|
+
* `null` is idle (§1.3). Rides the §1 envelope over the shared memory, projecting
|
|
4
|
+
* roots/first/nodes and the gathered-alias arms.
|
|
5
|
+
*/
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
import { useRead } from '../memory/read/read';
|
|
8
|
+
/** A structured read — builder callback or AST value; `null` is idle (§1.3). */
|
|
9
|
+
export function useQuery(build, opts) {
|
|
10
|
+
const r = useRead(build ?? null, opts);
|
|
11
|
+
return useMemo(() => ({
|
|
12
|
+
pending: r.pending,
|
|
13
|
+
error: r.error,
|
|
14
|
+
live: r.live,
|
|
15
|
+
seq: r.seq,
|
|
16
|
+
refetch: r.refetch,
|
|
17
|
+
nodes: r.nodes,
|
|
18
|
+
roots: r.roots,
|
|
19
|
+
first: r.first,
|
|
20
|
+
gathered: r.gathered,
|
|
21
|
+
more: r.more,
|
|
22
|
+
}), [r]);
|
|
23
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @astrale-os/shell-react — the React face of the shell (SHELL_REACT_API.md §0).
|
|
3
|
+
* One package, one import surface (SPEC §4.2); the bounded-context directories are
|
|
4
|
+
* the module structure, not subpaths. This public barrel composes the context
|
|
5
|
+
* barrels. Settled naming (§0): useKernelClient = the raw handle (session);
|
|
6
|
+
* useKernel() = the TYPED kernel (schema, no arg); useDomain(schema) = a typed
|
|
7
|
+
* domain binding. `useNode`/`useChildren` are single overloaded symbols (untyped
|
|
8
|
+
* floor + typed overloads) exported from the graph plane.
|
|
9
|
+
*/
|
|
10
|
+
export { ShellProvider } from './session';
|
|
11
|
+
export type { ShellError, ShellProviderProps } from './session';
|
|
12
|
+
export { useConnection, useKernelClient, useKernelInstance, useShell } from './session';
|
|
13
|
+
export type { KernelInstance } from './session';
|
|
14
|
+
export { ActAs, useAuth, useCan, useSelf } from './auth';
|
|
15
|
+
export type { ActAsProps } from './auth';
|
|
16
|
+
export { useCall, useChildren, useGraph, useMove, useMutate, useNode, useQuery, useStream, } from './graph';
|
|
17
|
+
export type { ChildrenOptions, ChildrenResult, GraphMemory, MoveAction, Node, NodeResult, QueryResult, ShapeInput, UseMutateOptions, } from './graph';
|
|
18
|
+
export type { CallOptions, StreamHandle, StreamOptions } from './graph';
|
|
19
|
+
export { useDomain, useFunction, useIn, useKernel, useMethod, useOut } from './schema';
|
|
20
|
+
export type { FunctionOptions } from './schema';
|
|
21
|
+
export type { MethodOptions } from './schema';
|
|
22
|
+
export type { AutoMethodAction, BoundMethodAction, EndpointResult, FunctionNames, FunctionParams, FunctionResult, MethodIsStatic, MethodNames, MethodParams, MethodResult, TargetedMethodAction, TypedChildrenResult, TypedNodeResult, } from './schema';
|
|
23
|
+
export { Link, NavScope, memoryAdapter, urlAdapter, useAncestors, useLocation, useNavScope, useNavigate, } from './navigation';
|
|
24
|
+
export type { LinkProps, MissingPolicy, NavAdapter, NavLocation, NavScopeHandle, NavScopeProps, NavSnapshot, NavTarget, Navigate, SerializedLocation, } from './navigation';
|
|
25
|
+
export { SelectionScope, useSelection } from './selection';
|
|
26
|
+
export type { Selection, SelectionScopeProps } from './selection';
|
|
27
|
+
export { useCloseGuard, useTargetNode, useViewsFor, useWindow, useWindowList, useWindows, ViewHost, ViewStage, } from './window';
|
|
28
|
+
export type { CloseGuard, CloseVerdict, ViewDescriptor, ViewHostProps, ViewSource, ViewHostHandle, ViewsForResult, WindowListEntry, WindowState, WindowView, } from './window';
|
|
29
|
+
export { useIntent, useSendIntent } from './intents';
|
|
30
|
+
export type { IntentCtx, IntentPayload, IntentReply, SendIntent } from './intents';
|
|
31
|
+
export { AppHost, AppLogo, useApps, useCurrentSpace, useOpenApp, useRoles, useSpace, useSpaces, useUser, } from './application';
|
|
32
|
+
export type { AppHostFallbackState, AppHostProps, AppLogoProps, AppsResult, CurrentSpaceResult, RolesResult, SpaceResult, SpacesResult, } from './application';
|
|
33
|
+
export type { ApplicationNode, AppSession, RoleNode, SpaceNode, UserNode } from '@astrale-os/shell';
|
|
34
|
+
export type { Action, ReadState, ReadOptions, Windowed } from './graph';
|
|
35
|
+
export * from './graph/guards.error';
|
|
36
|
+
export { DESCRIPTION_KEY, NAME_KEY, STATUS_KEY, descriptionOf, nameOf, normalizeRef, statusOf, } from '@astrale-os/kernel-client';
|
|
37
|
+
export type { AnyBoundNode, BoundNode, CreatableClassNames, CreateProps, CredentialInput, DefOf, EdgeNames, EndpointsOf, FnMap, NamedNodeLike, NodeRefInput, SchemaBoundView, TypeNames, } from '@astrale-os/kernel-client';
|
|
38
|
+
export type { EdgeIdentity, GatherBuilder, OrderInput, PatchBuilder, PatchInput, PathLike, Properties, QueryASTInput, QuerySource, } from '@astrale-os/kernel-client/graph';
|
|
39
|
+
export type { AuthApi, Perms } from '@astrale-os/kernel-client/auth';
|
|
40
|
+
export type { Schema } from '@astrale-os/kernel-dsl';
|
|
41
|
+
export type { CloseResult, KernelClient, MountCredential, Shell, ShellConfig, Window, } from '@astrale-os/shell';
|
|
42
|
+
export type { IntentRegistry } from '@astrale-os/shell';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @astrale-os/shell-react — the React face of the shell (SHELL_REACT_API.md §0).
|
|
3
|
+
* One package, one import surface (SPEC §4.2); the bounded-context directories are
|
|
4
|
+
* the module structure, not subpaths. This public barrel composes the context
|
|
5
|
+
* barrels. Settled naming (§0): useKernelClient = the raw handle (session);
|
|
6
|
+
* useKernel() = the TYPED kernel (schema, no arg); useDomain(schema) = a typed
|
|
7
|
+
* domain binding. `useNode`/`useChildren` are single overloaded symbols (untyped
|
|
8
|
+
* floor + typed overloads) exported from the graph plane.
|
|
9
|
+
*/
|
|
10
|
+
// ─── session (§2 provider + §3) ──────────────────────────────────────────────
|
|
11
|
+
export { ShellProvider } from './session';
|
|
12
|
+
export { useConnection, useKernelClient, useKernelInstance, useShell } from './session';
|
|
13
|
+
// ─── auth (§4) ───────────────────────────────────────────────────────────────
|
|
14
|
+
export { ActAs, useAuth, useCan, useSelf } from './auth';
|
|
15
|
+
// ─── graph — the untyped floor + writes + dispatch (§5, §7) ──────────────────
|
|
16
|
+
// `useNode`/`useChildren` are single symbols merging the untyped floor + typed
|
|
17
|
+
// overloads.
|
|
18
|
+
export { useCall, useChildren, useGraph, useMove, useMutate, useNode, useQuery, useStream, } from './graph';
|
|
19
|
+
// ─── schema — the typed substrate (§6) ───────────────────────────────────────
|
|
20
|
+
export { useDomain, useFunction, useIn, useKernel, useMethod, useOut } from './schema';
|
|
21
|
+
// ─── navigation (§8) ─────────────────────────────────────────────────────────
|
|
22
|
+
export { Link, NavScope, memoryAdapter, urlAdapter, useAncestors, useLocation, useNavScope, useNavigate, } from './navigation';
|
|
23
|
+
// ─── selection (§9) ──────────────────────────────────────────────────────────
|
|
24
|
+
export { SelectionScope, useSelection } from './selection';
|
|
25
|
+
// ─── window (§10) ────────────────────────────────────────────────────────────
|
|
26
|
+
export { useCloseGuard, useTargetNode, useViewsFor, useWindow, useWindowList, useWindows, ViewHost, ViewStage, } from './window';
|
|
27
|
+
// ─── intents (§11) ───────────────────────────────────────────────────────────
|
|
28
|
+
export { useIntent, useSendIntent } from './intents';
|
|
29
|
+
// ─── application — the OS plane (§12) ────────────────────────────────────────
|
|
30
|
+
export { AppHost, AppLogo, useApps, useCurrentSpace, useOpenApp, useRoles, useSpace, useSpaces, useUser, } from './application';
|
|
31
|
+
// ─── error taxonomy (§1.4) — guards + classes, re-exported from kernel-client ─
|
|
32
|
+
export * from './graph/guards.error';
|
|
33
|
+
// ─── re-exported kernel-client types (one import surface, §0 preamble) ───────
|
|
34
|
+
export { DESCRIPTION_KEY, NAME_KEY, STATUS_KEY, descriptionOf, nameOf, normalizeRef, statusOf, } from '@astrale-os/kernel-client';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intent envelope construction (API §11). The typed payload/reply projections of
|
|
3
|
+
* a registry entry, the wire constants, and `intentMessage` — the single builder
|
|
4
|
+
* both directions (send + reply) share.
|
|
5
|
+
*/
|
|
6
|
+
import type { IntentMessage, IntentRegistry } from '@astrale-os/shell';
|
|
7
|
+
/**
|
|
8
|
+
* Payload of a registry entry: the `{ payload }` field for the wrapped shape,
|
|
9
|
+
* else the whole entry (a legacy bare-payload augmentation). Robust to both, so
|
|
10
|
+
* bare augmentations keep compiling unchanged.
|
|
11
|
+
*/
|
|
12
|
+
export type IntentPayload<K extends keyof IntentRegistry> = IntentRegistry[K] extends {
|
|
13
|
+
payload: infer P;
|
|
14
|
+
} ? P : IntentRegistry[K];
|
|
15
|
+
/**
|
|
16
|
+
* Reply of a registry entry: the `{ reply }` field when declared, else `void`
|
|
17
|
+
* (bare-payload and today's reply-less entries — forward-compatible with G4).
|
|
18
|
+
*/
|
|
19
|
+
export type IntentReply<K extends keyof IntentRegistry> = IntentRegistry[K] extends {
|
|
20
|
+
reply: infer R;
|
|
21
|
+
} ? R : void;
|
|
22
|
+
/** Sentinel `ctx.sender` carries for a parent-delivered intent (the shell stamps it). */
|
|
23
|
+
export declare const PARENT_SENDER = "<parent>";
|
|
24
|
+
/** Correlated-reply channel name (the shell's fire-and-forget reply protocol). */
|
|
25
|
+
export declare const INTENT_REPLY = "intentReply";
|
|
26
|
+
export declare const NOOP: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Build an intent wire message. Bare-vs-wrapped payload variance (§11 pin) is
|
|
29
|
+
* erased on the wire — the receiver reads `envelope.payload` verbatim; the cast
|
|
30
|
+
* bridges the correlated name↔payload the union type cannot express.
|
|
31
|
+
*/
|
|
32
|
+
export declare function intentMessage(name: string, payload: unknown, correlationId?: string): IntentMessage;
|
|
33
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/intents/envelope.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEtE;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,cAAc,IAAI,cAAc,CAAC,CAAC,CAAC,SAAS;IACpF,OAAO,EAAE,MAAM,CAAC,CAAA;CACjB,GACG,CAAC,GACD,cAAc,CAAC,CAAC,CAAC,CAAA;AAErB;;;GAGG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,cAAc,IAAI,cAAc,CAAC,CAAC,CAAC,SAAS;IAClF,KAAK,EAAE,MAAM,CAAC,CAAA;CACf,GACG,CAAC,GACD,IAAI,CAAA;AAER,yFAAyF;AACzF,eAAO,MAAM,aAAa,aAAa,CAAA;AAGvC,kFAAkF;AAClF,eAAO,MAAM,YAAY,gBAAgB,CAAA;AACzC,eAAO,MAAM,IAAI,QAAO,IAAU,CAAA;AAElC;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,EAChB,aAAa,CAAC,EAAE,MAAM,GACrB,aAAa,CAMf"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Sentinel `ctx.sender` carries for a parent-delivered intent (the shell stamps it). */
|
|
2
|
+
export const PARENT_SENDER = '<parent>';
|
|
3
|
+
/** Outbound `sender.windowId`; the receiver re-stamps it with the trusted id. */
|
|
4
|
+
const SELF_SENDER = 'self';
|
|
5
|
+
/** Correlated-reply channel name (the shell's fire-and-forget reply protocol). */
|
|
6
|
+
export const INTENT_REPLY = 'intentReply';
|
|
7
|
+
export const NOOP = () => { };
|
|
8
|
+
/**
|
|
9
|
+
* Build an intent wire message. Bare-vs-wrapped payload variance (§11 pin) is
|
|
10
|
+
* erased on the wire — the receiver reads `envelope.payload` verbatim; the cast
|
|
11
|
+
* bridges the correlated name↔payload the union type cannot express.
|
|
12
|
+
*/
|
|
13
|
+
export function intentMessage(name, payload, correlationId) {
|
|
14
|
+
return {
|
|
15
|
+
type: 'intent',
|
|
16
|
+
version: 1,
|
|
17
|
+
envelope: { name, payload, sender: { windowId: SELF_SENDER }, correlationId },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { useIntent } from './listen-intent.hook';
|
|
2
|
+
export type { IntentCtx } from './listen-intent.hook';
|
|
3
|
+
export { useSendIntent } from './send-intent.hook';
|
|
4
|
+
export type { SendIntent } from './send-intent.hook';
|
|
5
|
+
export type { IntentPayload, IntentReply } from './envelope';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intents/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IntentRegistry } from '@astrale-os/shell';
|
|
2
|
+
import type { IntentPayload, IntentReply } from './envelope';
|
|
3
|
+
/** Delivery context passed alongside an inbound intent's payload. */
|
|
4
|
+
export interface IntentCtx<K extends keyof IntentRegistry> {
|
|
5
|
+
/** REAL source windowId; the `'<parent>'` sentinel for a parent-delivered intent. */
|
|
6
|
+
readonly sender: string;
|
|
7
|
+
/** Reply to the sender's pending request — exactly-once; dropped if it died. */
|
|
8
|
+
reply(result: IntentReply<K>): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Subscribe `handler` to inbound `name` intents. `ctx.sender` is the REAL
|
|
12
|
+
* windowId (the channel-authenticated id, or `'<parent>'` upstream); `ctx.reply`
|
|
13
|
+
* answers a correlated request once.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useIntent<K extends keyof IntentRegistry>(name: K, handler: (payload: IntentPayload<K>, ctx: IntentCtx<K>) => void | Promise<void>): void;
|
|
16
|
+
//# sourceMappingURL=listen-intent.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listen-intent.hook.d.ts","sourceRoot":"","sources":["../../src/intents/listen-intent.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAYtE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAM5D,qEAAqE;AACrE,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,MAAM,cAAc;IACvD,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,gFAAgF;IAChF,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;CACpC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,cAAc,EACtD,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC9E,IAAI,CAyDN"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useIntent (API §11) — subscribe ONE handler to inbound intents (post-middleware,
|
|
3
|
+
* via shell.onIntent) with the REAL sender windowId and an exactly-once,
|
|
4
|
+
* unmount-safe `ctx.reply`. The subscription identity is independent of the
|
|
5
|
+
* handler closure (latest-handler ref), so re-renders never re-register. Reply
|
|
6
|
+
* obligations are tracked per sender window so a child close drops ours before a
|
|
7
|
+
* late async handler can aim a reply at a gone counterparty.
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useRef } from 'react';
|
|
10
|
+
import { useShell } from '../session/shell.hook';
|
|
11
|
+
import { NOOP } from './envelope';
|
|
12
|
+
import { sendReply } from './reply';
|
|
13
|
+
/**
|
|
14
|
+
* Subscribe `handler` to inbound `name` intents. `ctx.sender` is the REAL
|
|
15
|
+
* windowId (the channel-authenticated id, or `'<parent>'` upstream); `ctx.reply`
|
|
16
|
+
* answers a correlated request once.
|
|
17
|
+
*/
|
|
18
|
+
export function useIntent(name, handler) {
|
|
19
|
+
const shell = useShell();
|
|
20
|
+
const handlerRef = useRef(handler);
|
|
21
|
+
handlerRef.current = handler;
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
let alive = true;
|
|
24
|
+
// Open reply obligations by sender window, so a child close drops ours
|
|
25
|
+
// before a late async handler can aim a reply at a gone counterparty.
|
|
26
|
+
const bySender = new Map();
|
|
27
|
+
const track = (sender, drop) => {
|
|
28
|
+
let set = bySender.get(sender);
|
|
29
|
+
if (set === undefined) {
|
|
30
|
+
set = new Set();
|
|
31
|
+
bySender.set(sender, set);
|
|
32
|
+
}
|
|
33
|
+
set.add(drop);
|
|
34
|
+
return () => set.delete(drop);
|
|
35
|
+
};
|
|
36
|
+
const offClose = shell.children.onClose((windowId) => {
|
|
37
|
+
const set = bySender.get(windowId);
|
|
38
|
+
if (set === undefined)
|
|
39
|
+
return;
|
|
40
|
+
for (const drop of set)
|
|
41
|
+
drop();
|
|
42
|
+
bySender.delete(windowId);
|
|
43
|
+
});
|
|
44
|
+
const off = shell.onIntent(name, (message) => {
|
|
45
|
+
const { payload, correlationId } = message.envelope;
|
|
46
|
+
const sender = message.envelope.sender.windowId;
|
|
47
|
+
let settled = false;
|
|
48
|
+
const untrack = correlationId === undefined
|
|
49
|
+
? NOOP
|
|
50
|
+
: track(sender, () => {
|
|
51
|
+
settled = true;
|
|
52
|
+
});
|
|
53
|
+
const ctx = {
|
|
54
|
+
sender,
|
|
55
|
+
reply(result) {
|
|
56
|
+
if (settled || !alive)
|
|
57
|
+
return;
|
|
58
|
+
settled = true;
|
|
59
|
+
untrack();
|
|
60
|
+
if (correlationId === undefined)
|
|
61
|
+
return;
|
|
62
|
+
sendReply(shell, sender, correlationId, result);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
void Promise.resolve(handlerRef.current(payload, ctx))
|
|
66
|
+
.catch(NOOP)
|
|
67
|
+
.finally(untrack);
|
|
68
|
+
});
|
|
69
|
+
return () => {
|
|
70
|
+
alive = false;
|
|
71
|
+
off();
|
|
72
|
+
offClose();
|
|
73
|
+
};
|
|
74
|
+
}, [shell, name]);
|
|
75
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reply delivery (API §11) — route a correlated reply to whichever channel the
|
|
3
|
+
* request arrived on (parent vs a child window). Best-effort: a gone counterparty
|
|
4
|
+
* drops the reply safely (counterparty-death cleanup).
|
|
5
|
+
*/
|
|
6
|
+
import type { Shell } from '@astrale-os/shell';
|
|
7
|
+
/** Deliver a reply to whichever channel the request arrived on. Best-effort. */
|
|
8
|
+
export declare function sendReply(shell: Shell, sender: string, correlationId: string, result: unknown): void;
|
|
9
|
+
//# sourceMappingURL=reply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../src/intents/reply.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAI9C,gFAAgF;AAChF,wBAAgB,SAAS,CACvB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,OAAO,GACd,IAAI,CAQN"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { INTENT_REPLY, PARENT_SENDER, intentMessage } from './envelope';
|
|
2
|
+
/** Deliver a reply to whichever channel the request arrived on. Best-effort. */
|
|
3
|
+
export function sendReply(shell, sender, correlationId, result) {
|
|
4
|
+
const message = intentMessage(INTENT_REPLY, { correlationId, result });
|
|
5
|
+
try {
|
|
6
|
+
if (sender === PARENT_SENDER)
|
|
7
|
+
shell.parent?.send(message);
|
|
8
|
+
else
|
|
9
|
+
shell.children.send(sender, message); // no-op if the child has detached
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
// Counterparty gone — the reply is safely dropped.
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IntentRegistry } from '@astrale-os/shell';
|
|
2
|
+
import type { IntentPayload, IntentReply } from './envelope';
|
|
3
|
+
/** The typed sender returned by {@link useSendIntent}. */
|
|
4
|
+
export interface SendIntent {
|
|
5
|
+
<K extends keyof IntentRegistry>(name: K, payload: IntentPayload<K>,
|
|
6
|
+
/** `to`: `'parent'` (reserved) or a child windowId. Default: the parent, if any. */
|
|
7
|
+
opts?: {
|
|
8
|
+
to?: 'parent' | string;
|
|
9
|
+
}): Promise<IntentReply<K> | void>;
|
|
10
|
+
}
|
|
11
|
+
export declare function useSendIntent(): SendIntent;
|
|
12
|
+
//# sourceMappingURL=send-intent.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-intent.hook.d.ts","sourceRoot":"","sources":["../../src/intents/send-intent.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,cAAc,EAAS,MAAM,mBAAmB,CAAA;AAW7E,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAK5D,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,CAAC,CAAC,SAAS,MAAM,cAAc,EAC7B,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;IACzB,oFAAoF;IACpF,IAAI,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;KAAE,GAChC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;CAClC;AAqBD,wBAAgB,aAAa,IAAI,UAAU,CAiE1C"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useSendIntent (API §11) — a stable typed sender. Each call attaches a
|
|
3
|
+
* `correlationId`, subscribes for the matching `intentReply` on the origin channel
|
|
4
|
+
* BEFORE sending, then resolves with the reply's result. The promise also resolves
|
|
5
|
+
* (`void`) if the target window closes or this hook unmounts — a pending reply
|
|
6
|
+
* never strands.
|
|
7
|
+
*/
|
|
8
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
9
|
+
import { useShell } from '../session/shell.hook';
|
|
10
|
+
import { INTENT_REPLY, NOOP, intentMessage } from './envelope';
|
|
11
|
+
function resolveTarget(shell, to) {
|
|
12
|
+
if (to === undefined) {
|
|
13
|
+
return shell.parent !== null
|
|
14
|
+
? { kind: 'parent' }
|
|
15
|
+
: { kind: 'invalid', reason: 'no target — pass opts.to (a child windowId) from a root shell' };
|
|
16
|
+
}
|
|
17
|
+
if (to === 'parent') {
|
|
18
|
+
return shell.parent !== null
|
|
19
|
+
? { kind: 'parent' }
|
|
20
|
+
: { kind: 'invalid', reason: "opts.to 'parent' but this shell has no parent channel" };
|
|
21
|
+
}
|
|
22
|
+
return { kind: 'child', windowId: to };
|
|
23
|
+
}
|
|
24
|
+
export function useSendIntent() {
|
|
25
|
+
const shell = useShell();
|
|
26
|
+
// Unmount settlers for in-flight sends, so a pending reply resolves on teardown.
|
|
27
|
+
const pendingRef = useRef(new Set());
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const pending = pendingRef.current;
|
|
30
|
+
return () => {
|
|
31
|
+
for (const settle of pending)
|
|
32
|
+
settle();
|
|
33
|
+
pending.clear();
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
return useCallback((name, payload, opts) => {
|
|
37
|
+
const target = resolveTarget(shell, opts?.to);
|
|
38
|
+
if (target.kind === 'invalid') {
|
|
39
|
+
return Promise.reject(new Error(`useSendIntent: ${target.reason}`));
|
|
40
|
+
}
|
|
41
|
+
const correlationId = crypto.randomUUID();
|
|
42
|
+
const message = intentMessage(name, payload, correlationId);
|
|
43
|
+
const pending = pendingRef.current;
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
let done = false;
|
|
46
|
+
let offReply = NOOP;
|
|
47
|
+
let offClose = NOOP;
|
|
48
|
+
const onUnmount = () => settle(undefined);
|
|
49
|
+
function settle(value) {
|
|
50
|
+
if (done)
|
|
51
|
+
return;
|
|
52
|
+
done = true;
|
|
53
|
+
offReply();
|
|
54
|
+
offClose();
|
|
55
|
+
pending.delete(onUnmount);
|
|
56
|
+
resolve(value);
|
|
57
|
+
}
|
|
58
|
+
const onReply = (m) => {
|
|
59
|
+
if (m.envelope.name !== INTENT_REPLY)
|
|
60
|
+
return;
|
|
61
|
+
const reply = m.envelope.payload;
|
|
62
|
+
if (reply.correlationId !== correlationId)
|
|
63
|
+
return;
|
|
64
|
+
settle(reply.result);
|
|
65
|
+
};
|
|
66
|
+
pending.add(onUnmount);
|
|
67
|
+
if (target.kind === 'parent') {
|
|
68
|
+
const parent = shell.parent;
|
|
69
|
+
offReply = parent.on('intent', onReply);
|
|
70
|
+
parent.send(message);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const { windowId } = target;
|
|
74
|
+
offReply = shell.children.on('intent', (wid, m) => {
|
|
75
|
+
if (wid === windowId)
|
|
76
|
+
onReply(m);
|
|
77
|
+
});
|
|
78
|
+
offClose = shell.children.onClose((wid) => {
|
|
79
|
+
if (wid === windowId)
|
|
80
|
+
settle(undefined);
|
|
81
|
+
});
|
|
82
|
+
shell.children.send(windowId, message);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}, [shell]);
|
|
86
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The nav persistence port (API §8.1). The pluggable seam a `NavScope` mirrors its
|
|
3
|
+
* location through. `href` is the URL-form probe `<Link>` needs: present → an
|
|
4
|
+
* `<a href>` (cmd/ctrl-click falls through); absent → `role="link"`.
|
|
5
|
+
*/
|
|
6
|
+
import type { SerializedLocation } from '../history';
|
|
7
|
+
export interface NavAdapter {
|
|
8
|
+
read(): SerializedLocation | null;
|
|
9
|
+
write(loc: SerializedLocation, opts: {
|
|
10
|
+
replace: boolean;
|
|
11
|
+
}): void;
|
|
12
|
+
subscribe(onExternalChange: () => void): () => void;
|
|
13
|
+
href?(loc: SerializedLocation): string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/navigation/adapters/adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,MAAM,WAAW,UAAU;IACzB,IAAI,IAAI,kBAAkB,GAAG,IAAI,CAAA;IACjC,KAAK,CAAC,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAA;IAChE,SAAS,CAAC,gBAAgB,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;IACnD,IAAI,CAAC,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,CAAA;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memoryAdapter (API §8.1) — the default scope backing: holds one location in a
|
|
3
|
+
* closure (per-pane state, no URL form → Link renders `role="link"`).
|
|
4
|
+
*/
|
|
5
|
+
import type { SerializedLocation } from '../history';
|
|
6
|
+
import type { NavAdapter } from './adapter';
|
|
7
|
+
/** In-memory adapter — the default scope backing (per-pane state, no URL). */
|
|
8
|
+
export declare function memoryAdapter(initial?: SerializedLocation): NavAdapter;
|
|
9
|
+
//# sourceMappingURL=memory.adapter.d.ts.map
|