@astrale-os/shell-react 0.3.1 → 0.3.2-beta.1
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/dist/application/apps/app-host.d.ts +0 -1
- package/dist/application/apps/app-logo.d.ts +0 -1
- package/dist/application/apps/apps.hook.d.ts +0 -1
- package/dist/application/apps/open-app.hook.d.ts +0 -1
- package/dist/application/index.d.ts +0 -1
- package/dist/application/spaces/current-space.hook.d.ts +0 -1
- package/dist/application/spaces/current-space.store.d.ts +0 -1
- package/dist/application/spaces/space.hook.d.ts +0 -1
- package/dist/application/spaces/spaces.hook.d.ts +0 -1
- package/dist/application/user/user.hook.d.ts +0 -1
- package/dist/application/user/user.store.d.ts +0 -1
- package/dist/auth/act-as.context.d.ts +0 -1
- package/dist/auth/auth.hook.d.ts +0 -1
- package/dist/auth/can.hook.d.ts +0 -1
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/self.hook.d.ts +0 -1
- package/dist/auth/session-kernel.d.ts +0 -1
- package/dist/components/astrale.d.ts +0 -1
- package/dist/components/boundaries.d.ts +0 -1
- package/dist/components/can.d.ts +0 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/graph/action.d.ts +0 -1
- package/dist/graph/async.d.ts +0 -1
- package/dist/graph/call/call.hook.d.ts +0 -1
- package/dist/graph/call/stream.hook.d.ts +0 -1
- package/dist/graph/graph.context.d.ts +0 -1
- package/dist/graph/guards.error.d.ts +0 -1
- package/dist/graph/index.d.ts +0 -1
- package/dist/graph/memory/read/envelope.d.ts +0 -1
- package/dist/graph/memory/read/idle.d.ts +0 -1
- package/dist/graph/query-definition.hook.d.ts +2 -2
- package/dist/graph/query-definition.hook.js +18 -4
- package/dist/graph/resource.d.ts +0 -1
- package/dist/graph/store.d.ts +0 -1
- package/dist/host/actions.hook.d.ts +0 -1
- package/dist/host/components.d.ts +0 -1
- package/dist/host/index.d.ts +0 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/intents/emit-intent.hook.d.ts +0 -1
- package/dist/intents/envelope.d.ts +0 -1
- package/dist/intents/index.d.ts +0 -1
- package/dist/intents/listen-intent.hook.d.ts +0 -1
- package/dist/intents/reply.d.ts +0 -1
- package/dist/intents/resolve-intent-target.d.ts +0 -1
- package/dist/intents/send-intent.hook.d.ts +0 -1
- package/dist/navigation/adapters/adapter.d.ts +0 -1
- package/dist/navigation/adapters/memory.adapter.d.ts +0 -1
- package/dist/navigation/adapters/url.adapter.d.ts +0 -1
- package/dist/navigation/codec.d.ts +0 -1
- package/dist/navigation/history.d.ts +0 -1
- package/dist/navigation/hooks/ancestors.hook.d.ts +0 -1
- package/dist/navigation/hooks/location.hook.d.ts +0 -1
- package/dist/navigation/hooks/navigate.hook.d.ts +0 -1
- package/dist/navigation/hooks/scope.hook.d.ts +0 -1
- package/dist/navigation/index.d.ts +0 -1
- package/dist/navigation/link.d.ts +0 -1
- package/dist/navigation/location.d.ts +0 -1
- package/dist/navigation/scope.context.d.ts +0 -1
- package/dist/navigation/snapshot.d.ts +0 -1
- package/dist/navigation/view-key.d.ts +0 -1
- package/dist/schema/action.hook.d.ts +4 -12
- package/dist/schema/action.hook.js +21 -5
- package/dist/schema/domain.context.d.ts +10 -0
- package/dist/schema/domain.context.js +17 -0
- package/dist/schema/domain.hook.d.ts +0 -1
- package/dist/schema/index.d.ts +2 -1
- package/dist/schema/index.js +1 -0
- package/dist/schema/kernel.hook.d.ts +0 -1
- package/dist/schema/mutation.hook.d.ts +2 -2
- package/dist/schema/mutation.hook.js +6 -3
- package/dist/schema/object.hook.d.ts +0 -1
- package/dist/schema/relation.hook.d.ts +0 -1
- package/dist/selection/index.d.ts +0 -1
- package/dist/selection/live.d.ts +0 -1
- package/dist/selection/scope.context.d.ts +0 -1
- package/dist/selection/selection.hook.d.ts +0 -1
- package/dist/session/boot/boot.d.ts +0 -1
- package/dist/session/boot/ownership.d.ts +0 -1
- package/dist/session/boot/status.d.ts +0 -1
- package/dist/session/connection/connection.hook.d.ts +0 -1
- package/dist/session/connection/connection.store.d.ts +0 -1
- package/dist/session/index.d.ts +0 -1
- package/dist/session/kernel-client.hook.d.ts +0 -1
- package/dist/session/kernel-instance.hook.d.ts +0 -1
- package/dist/session/provider.d.ts +0 -1
- package/dist/session/session.context.d.ts +0 -1
- package/dist/session/shell.hook.d.ts +0 -1
- package/dist/window/adopt.d.ts +0 -1
- package/dist/window/hooks/close-guard.hook.d.ts +0 -1
- package/dist/window/hooks/target-node.hook.d.ts +0 -1
- package/dist/window/hooks/views-for.hook.d.ts +0 -1
- package/dist/window/hooks/window.hook.d.ts +0 -1
- package/dist/window/hooks/windows.hook.d.ts +0 -1
- package/dist/window/host.d.ts +0 -1
- package/dist/window/hub.d.ts +0 -1
- package/dist/window/index.d.ts +0 -1
- package/dist/window/lifecycle/mount.d.ts +0 -1
- package/dist/window/lifecycle/states.d.ts +0 -1
- package/dist/window/placement.d.ts +0 -1
- package/dist/window/stage.d.ts +0 -1
- package/package.json +16 -18
- package/src/graph/query-definition.hook.ts +29 -10
- package/src/index.ts +2 -0
- package/src/schema/action.hook.ts +26 -15
- package/src/schema/domain.context.tsx +31 -0
- package/src/schema/index.ts +2 -0
- package/src/schema/mutation.hook.ts +9 -4
- package/dist/application/apps/app-host.d.ts.map +0 -1
- package/dist/application/apps/app-logo.d.ts.map +0 -1
- package/dist/application/apps/apps.hook.d.ts.map +0 -1
- package/dist/application/apps/open-app.hook.d.ts.map +0 -1
- package/dist/application/index.d.ts.map +0 -1
- package/dist/application/spaces/current-space.hook.d.ts.map +0 -1
- package/dist/application/spaces/current-space.store.d.ts.map +0 -1
- package/dist/application/spaces/space.hook.d.ts.map +0 -1
- package/dist/application/spaces/spaces.hook.d.ts.map +0 -1
- package/dist/application/user/user.hook.d.ts.map +0 -1
- package/dist/application/user/user.store.d.ts.map +0 -1
- package/dist/auth/act-as.context.d.ts.map +0 -1
- package/dist/auth/auth.hook.d.ts.map +0 -1
- package/dist/auth/can.hook.d.ts.map +0 -1
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/self.hook.d.ts.map +0 -1
- package/dist/auth/session-kernel.d.ts.map +0 -1
- package/dist/components/astrale.d.ts.map +0 -1
- package/dist/components/boundaries.d.ts.map +0 -1
- package/dist/components/can.d.ts.map +0 -1
- package/dist/components/index.d.ts.map +0 -1
- package/dist/graph/action.d.ts.map +0 -1
- package/dist/graph/async.d.ts.map +0 -1
- package/dist/graph/call/call.hook.d.ts.map +0 -1
- package/dist/graph/call/stream.hook.d.ts.map +0 -1
- package/dist/graph/graph.context.d.ts.map +0 -1
- package/dist/graph/guards.error.d.ts.map +0 -1
- package/dist/graph/index.d.ts.map +0 -1
- package/dist/graph/memory/read/envelope.d.ts.map +0 -1
- package/dist/graph/memory/read/idle.d.ts.map +0 -1
- package/dist/graph/query-definition.hook.d.ts.map +0 -1
- package/dist/graph/resource.d.ts.map +0 -1
- package/dist/graph/store.d.ts.map +0 -1
- package/dist/host/actions.hook.d.ts.map +0 -1
- package/dist/host/components.d.ts.map +0 -1
- package/dist/host/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/intents/emit-intent.hook.d.ts.map +0 -1
- package/dist/intents/envelope.d.ts.map +0 -1
- package/dist/intents/index.d.ts.map +0 -1
- package/dist/intents/listen-intent.hook.d.ts.map +0 -1
- package/dist/intents/reply.d.ts.map +0 -1
- package/dist/intents/resolve-intent-target.d.ts.map +0 -1
- package/dist/intents/send-intent.hook.d.ts.map +0 -1
- package/dist/navigation/adapters/adapter.d.ts.map +0 -1
- package/dist/navigation/adapters/memory.adapter.d.ts.map +0 -1
- package/dist/navigation/adapters/url.adapter.d.ts.map +0 -1
- package/dist/navigation/codec.d.ts.map +0 -1
- package/dist/navigation/history.d.ts.map +0 -1
- package/dist/navigation/hooks/ancestors.hook.d.ts.map +0 -1
- package/dist/navigation/hooks/location.hook.d.ts.map +0 -1
- package/dist/navigation/hooks/navigate.hook.d.ts.map +0 -1
- package/dist/navigation/hooks/scope.hook.d.ts.map +0 -1
- package/dist/navigation/index.d.ts.map +0 -1
- package/dist/navigation/link.d.ts.map +0 -1
- package/dist/navigation/location.d.ts.map +0 -1
- package/dist/navigation/scope.context.d.ts.map +0 -1
- package/dist/navigation/snapshot.d.ts.map +0 -1
- package/dist/navigation/view-key.d.ts.map +0 -1
- package/dist/schema/action.hook.d.ts.map +0 -1
- package/dist/schema/domain.hook.d.ts.map +0 -1
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/kernel.hook.d.ts.map +0 -1
- package/dist/schema/mutation.hook.d.ts.map +0 -1
- package/dist/schema/object.hook.d.ts.map +0 -1
- package/dist/schema/relation.hook.d.ts.map +0 -1
- package/dist/selection/index.d.ts.map +0 -1
- package/dist/selection/live.d.ts.map +0 -1
- package/dist/selection/scope.context.d.ts.map +0 -1
- package/dist/selection/selection.hook.d.ts.map +0 -1
- package/dist/session/boot/boot.d.ts.map +0 -1
- package/dist/session/boot/ownership.d.ts.map +0 -1
- package/dist/session/boot/status.d.ts.map +0 -1
- package/dist/session/connection/connection.hook.d.ts.map +0 -1
- package/dist/session/connection/connection.store.d.ts.map +0 -1
- package/dist/session/index.d.ts.map +0 -1
- package/dist/session/kernel-client.hook.d.ts.map +0 -1
- package/dist/session/kernel-instance.hook.d.ts.map +0 -1
- package/dist/session/provider.d.ts.map +0 -1
- package/dist/session/session.context.d.ts.map +0 -1
- package/dist/session/shell.hook.d.ts.map +0 -1
- package/dist/window/adopt.d.ts.map +0 -1
- package/dist/window/hooks/close-guard.hook.d.ts.map +0 -1
- package/dist/window/hooks/target-node.hook.d.ts.map +0 -1
- package/dist/window/hooks/views-for.hook.d.ts.map +0 -1
- package/dist/window/hooks/window.hook.d.ts.map +0 -1
- package/dist/window/hooks/windows.hook.d.ts.map +0 -1
- package/dist/window/host.d.ts.map +0 -1
- package/dist/window/hub.d.ts.map +0 -1
- package/dist/window/index.d.ts.map +0 -1
- package/dist/window/lifecycle/mount.d.ts.map +0 -1
- package/dist/window/lifecycle/states.d.ts.map +0 -1
- package/dist/window/placement.d.ts.map +0 -1
- package/dist/window/stage.d.ts.map +0 -1
|
@@ -20,4 +20,3 @@ export interface AppHostProps {
|
|
|
20
20
|
}
|
|
21
21
|
/** Resolve and mount an installed Domain through the ordinary Shell View lifecycle. */
|
|
22
22
|
export declare const AppHost: import("react").ForwardRefExoticComponent<AppHostProps & import("react").RefAttributes<ViewHostHandle>>;
|
|
23
|
-
//# sourceMappingURL=app-host.d.ts.map
|
|
@@ -3,4 +3,3 @@ import type { App, ResolvedView } from '@astrale-os/shell';
|
|
|
3
3
|
import type { Action } from '../../graph/action.js';
|
|
4
4
|
/** Resolve one installed Domain's ordinary entry View. */
|
|
5
5
|
export declare function useOpenApp(): Action<[App | Key.Origin], ResolvedView | null>;
|
|
6
|
-
//# sourceMappingURL=open-app.hook.d.ts.map
|
|
@@ -13,4 +13,3 @@ export type { AppHostFallbackState, AppHostProps } from './apps/app-host.js';
|
|
|
13
13
|
export { AppLogo } from './apps/app-logo.js';
|
|
14
14
|
export type { AppLogoProps } from './apps/app-logo.js';
|
|
15
15
|
export type { App, NodeTarget, ResolvedView, SpaceNode, UserNode } from '@astrale-os/shell';
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,4 +2,3 @@ import type { NodeTarget } from '@astrale-os/shell';
|
|
|
2
2
|
import type { CurrentSpaceResult } from './current-space.hook.js';
|
|
3
3
|
export type SpaceResult = CurrentSpaceResult;
|
|
4
4
|
export declare function useSpace(ref: NodeTarget | null | undefined): SpaceResult;
|
|
5
|
-
//# sourceMappingURL=space.hook.d.ts.map
|
|
@@ -32,4 +32,3 @@ export declare function isOsPlaneAvailable(shell: Shell): boolean;
|
|
|
32
32
|
export declare function primeUser(shell: Shell): Promise<void>;
|
|
33
33
|
/** Kick off `me()` lazily (a shell that was never primed) and cache a suspense cell. */
|
|
34
34
|
export declare function loadUser(shell: Shell): UserEntry;
|
|
35
|
-
//# sourceMappingURL=user.store.d.ts.map
|
package/dist/auth/auth.hook.d.ts
CHANGED
package/dist/auth/can.hook.d.ts
CHANGED
|
@@ -9,4 +9,3 @@ export type PolicyObject = NodeId | {
|
|
|
9
9
|
* invoked callable remains the authorization enforcement point.
|
|
10
10
|
*/
|
|
11
11
|
export declare function useCan(policy: PathLike | PolicyRef | null | undefined, object: PolicyObject | null | undefined): boolean | undefined;
|
|
12
|
-
//# sourceMappingURL=can.hook.d.ts.map
|
package/dist/auth/index.d.ts
CHANGED
package/dist/auth/self.hook.d.ts
CHANGED
package/dist/components/can.d.ts
CHANGED
|
@@ -3,4 +3,3 @@ export { ConnectionBoundary, CredentialBoundary, defaultViewError, defaultViewLo
|
|
|
3
3
|
export type { ViewErrorBoundaryProps } from './boundaries.js';
|
|
4
4
|
export { Astrale } from './astrale.js';
|
|
5
5
|
export type { AstraleProps } from './astrale.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/graph/action.d.ts
CHANGED
|
@@ -19,4 +19,3 @@ export interface Action<A extends unknown[], R> {
|
|
|
19
19
|
* fields are re-stamped each render, so reads stay current across settlements.
|
|
20
20
|
*/
|
|
21
21
|
export declare function useAction<A extends unknown[], R>(fn: (...args: A) => Promise<R>): Action<A, R>;
|
|
22
|
-
//# sourceMappingURL=action.d.ts.map
|
package/dist/graph/async.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ export interface AsyncResource<T> extends ReadState {
|
|
|
8
8
|
* retained through a pending refetch or a failure (§1.1).
|
|
9
9
|
*/
|
|
10
10
|
export declare function useAsyncResource<T>(load: (() => Promise<T>) | null, empty: T, deps: readonly unknown[]): AsyncResource<T>;
|
|
11
|
-
//# sourceMappingURL=async.d.ts.map
|
|
@@ -8,4 +8,3 @@ export interface CallOptions extends SessionRequestOptions {
|
|
|
8
8
|
export type CallResult = Value;
|
|
9
9
|
export declare function useCall(call: Call | null, options?: CallOptions): Action<[], CallResult>;
|
|
10
10
|
export declare function useCall<A extends unknown[]>(author: ((...args: A) => Call) | null, options?: CallOptions): Action<A, CallResult>;
|
|
11
|
-
//# sourceMappingURL=call.hook.d.ts.map
|
|
@@ -17,4 +17,3 @@ export interface StreamHandle<A extends unknown[] = unknown[], T = StreamItem> {
|
|
|
17
17
|
cancel(): void;
|
|
18
18
|
}
|
|
19
19
|
export declare function useStream<A extends unknown[] = []>(author: CallAuthor<A> | null, options?: StreamOptions): StreamHandle<A, StreamItem>;
|
|
20
|
-
//# sourceMappingURL=stream.hook.d.ts.map
|
|
@@ -2,4 +2,3 @@ import type { GraphStore } from '@astrale-os/sdk/client/store';
|
|
|
2
2
|
/** Optional exact Client GraphStore supplied by an injected Shell adapter. */
|
|
3
3
|
export declare const GraphContext: import("react").Context<GraphStore | null>;
|
|
4
4
|
export type { GraphStore };
|
|
5
|
-
//# sourceMappingURL=graph.context.d.ts.map
|
|
@@ -5,4 +5,3 @@ import { ClientError } from '@astrale-os/sdk/client';
|
|
|
5
5
|
import { NodeUnavailableError } from '@astrale-os/sdk/client';
|
|
6
6
|
export declare function isClientError(error: unknown): error is ClientError;
|
|
7
7
|
export declare function isNodeUnavailableError(error: unknown): error is NodeUnavailableError;
|
|
8
|
-
//# sourceMappingURL=guards.error.d.ts.map
|
package/dist/graph/index.d.ts
CHANGED
|
@@ -9,4 +9,3 @@ export type { CallAuthor, KernelStream, StreamHandle, StreamItem, StreamOptions,
|
|
|
9
9
|
export type { Action } from './action.js';
|
|
10
10
|
export type { GraphStore } from './graph.context.js';
|
|
11
11
|
export { ClientError, NodeUnavailableError, ProtocolError, ResponseError, StaleRouteError, TransportError, isClientError, isNodeUnavailableError, } from './guards.error.js';
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { QueryDefinition } from '@astrale-os/sdk/query';
|
|
2
|
+
import type { Domain } from '@astrale-os/sdk/schema';
|
|
2
3
|
import type { GraphResource } from './resource.js';
|
|
3
4
|
export interface QueryResourceOptions {
|
|
4
5
|
readonly keepPrevious?: boolean;
|
|
@@ -6,5 +7,4 @@ export interface QueryResourceOptions {
|
|
|
6
7
|
readonly refreshWhen?: 'always' | 'visible';
|
|
7
8
|
}
|
|
8
9
|
/** Execute one named SDK Query definition exclusively through the current GraphStore. */
|
|
9
|
-
export declare function useQuery<Input, Output>(definition: QueryDefinition<Input, Output> | null, input: Input, options?: QueryResourceOptions): GraphResource<Output>;
|
|
10
|
-
//# sourceMappingURL=query-definition.hook.d.ts.map
|
|
10
|
+
export declare function useQuery<DomainValue extends Domain, Input, Output>(definition: QueryDefinition<DomainValue, Input, Output> | null, input: Input, options?: QueryResourceOptions): GraphResource<Output>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { executeQuery } from '@astrale-os/sdk/query';
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from 'react';
|
|
3
|
+
import { useExecutionDomain } from '../schema/domain.context.js';
|
|
3
4
|
import { retainRefreshScheduler } from './resource.js';
|
|
4
5
|
import { useGraphStore } from './store.js';
|
|
5
6
|
class DefinitionObserver {
|
|
6
7
|
store;
|
|
8
|
+
domain;
|
|
7
9
|
definition;
|
|
8
10
|
input;
|
|
9
11
|
listeners = new Set();
|
|
@@ -14,8 +16,9 @@ class DefinitionObserver {
|
|
|
14
16
|
pending = null;
|
|
15
17
|
started = false;
|
|
16
18
|
rerunQueued = false;
|
|
17
|
-
constructor(store, definition, input) {
|
|
19
|
+
constructor(store, domain, definition, input) {
|
|
18
20
|
this.store = store;
|
|
21
|
+
this.domain = domain;
|
|
19
22
|
this.definition = definition;
|
|
20
23
|
this.input = input;
|
|
21
24
|
}
|
|
@@ -50,7 +53,7 @@ class DefinitionObserver {
|
|
|
50
53
|
touched.push(Object.freeze({ ast, options }));
|
|
51
54
|
return this.store.read(ast, { ...options, freshness });
|
|
52
55
|
};
|
|
53
|
-
const running = executeQuery({ query: execute }, this.definition, this.input)
|
|
56
|
+
const running = executeQuery({ query: execute }, this.domain, this.definition, this.input)
|
|
54
57
|
.then((data) => {
|
|
55
58
|
if (!this.started || generation !== this.generation)
|
|
56
59
|
return;
|
|
@@ -114,14 +117,15 @@ class DefinitionObserver {
|
|
|
114
117
|
/** Execute one named SDK Query definition exclusively through the current GraphStore. */
|
|
115
118
|
export function useQuery(definition, input, options = {}) {
|
|
116
119
|
const store = useGraphStore();
|
|
120
|
+
const domain = useExecutionDomain();
|
|
117
121
|
const inputIdentity = stableIdentity(input);
|
|
118
|
-
const observer = useMemo(() => (definition === null ? null : new DefinitionObserver(store, definition, input)), [store, definition, inputIdentity]);
|
|
122
|
+
const observer = useMemo(() => (definition === null ? null : new DefinitionObserver(store, domain, definition, input)), [store, domain, definition, inputIdentity]);
|
|
119
123
|
const idle = useMemo(() => Object.freeze({ state: 'idle' }), []);
|
|
120
124
|
const subscribe = useCallback((listener) => observer?.subscribe(listener) ?? (() => { }), [observer]);
|
|
121
125
|
const snapshot = useCallback(() => observer?.getSnapshot() ?? idle, [observer, idle]);
|
|
122
126
|
const current = useSyncExternalStore(subscribe, snapshot, snapshot);
|
|
123
127
|
useEffect(() => observer?.start(), [observer]);
|
|
124
|
-
const identity = definition === null ? 'idle' : `${definition
|
|
128
|
+
const identity = definition === null ? 'idle' : `${definitionIdentity(definition)}\u0000${inputIdentity}`;
|
|
125
129
|
useEffect(() => {
|
|
126
130
|
if (observer === null || options.refreshInterval === undefined)
|
|
127
131
|
return;
|
|
@@ -148,6 +152,16 @@ export function useQuery(definition, input, options = {}) {
|
|
|
148
152
|
more: Object.freeze({ has: false, pending: false, load: () => Promise.resolve() }),
|
|
149
153
|
}), [current, previous, observer]);
|
|
150
154
|
}
|
|
155
|
+
const definitionIdentities = new WeakMap();
|
|
156
|
+
let nextDefinitionIdentity = 1;
|
|
157
|
+
function definitionIdentity(definition) {
|
|
158
|
+
const retained = definitionIdentities.get(definition);
|
|
159
|
+
if (retained !== undefined)
|
|
160
|
+
return retained;
|
|
161
|
+
const created = nextDefinitionIdentity++;
|
|
162
|
+
definitionIdentities.set(definition, created);
|
|
163
|
+
return created;
|
|
164
|
+
}
|
|
151
165
|
function dedupeShapes(input) {
|
|
152
166
|
const seen = new Set();
|
|
153
167
|
return Object.freeze(input.filter(({ ast, options }) => {
|
package/dist/graph/resource.d.ts
CHANGED
|
@@ -31,4 +31,3 @@ export interface StoreResourceOptions<Output> {
|
|
|
31
31
|
/** Adapt exact Store pages into a tear-free React resource without a parallel entity cache. */
|
|
32
32
|
export declare function useStoreResource<Query extends QueryAST, Output>(query: Query | null, pageSize: number, project: (response: StoreQueryResponse<Query>) => Output, options?: StoreResourceOptions<Output>): GraphResource<Output>;
|
|
33
33
|
export declare function retainRefreshScheduler(store: GraphStore, identity: string, refresh: () => Promise<void>, interval: number, when: 'always' | 'visible'): () => void;
|
|
34
|
-
//# sourceMappingURL=resource.d.ts.map
|
package/dist/graph/store.d.ts
CHANGED
package/dist/host/index.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ export { useExternalOpen, useHostCapabilities, useHostDialog, useNotify, useOpen
|
|
|
2
2
|
export type { ExternalOpenApi, HostDialogApi, NotifyApi, OpenViewApi, RequestAccessApi, } from './actions.hook.js';
|
|
3
3
|
export { HostDialog, NestedView, Notify, RequestAccess } from './components.js';
|
|
4
4
|
export { HostCapabilityUnavailableError } from './actions.hook.js';
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { ActAs, useAuth, useCan, useSelf } from './auth/index.js';
|
|
|
5
5
|
export type { ActAsProps, PolicyObject } from './auth/index.js';
|
|
6
6
|
export { ClientError, NodeUnavailableError, ProtocolError, ResponseError, StaleRouteError, TransportError, isClientError, isNodeUnavailableError, useCall, useGraphStore, useQuery, useStream, } from './graph/index.js';
|
|
7
7
|
export type { CallOptions, GraphResource, GraphResourceState, GraphStore, QueryResourceOptions, StreamHandle, StreamOptions, } from './graph/index.js';
|
|
8
|
-
export { RelationUnavailableError, queryRefresh, useAction, useDomain, useDomains, useDynamicDomain, useDynamicObject, useKernel, useMutation, useObject, useRelation, } from './schema/index.js';
|
|
9
|
-
export type { ActionOptions, ActionRefresh, DomainAction, MutationOptions, QueryRefresh, RelationOptions, RelationResource, RelationUnavailable, RichReadOptions, } from './schema/index.js';
|
|
8
|
+
export { DomainProvider, RelationUnavailableError, queryRefresh, useAction, useDomain, useDomains, useDynamicDomain, useDynamicObject, useKernel, useMutation, useObject, useRelation, } from './schema/index.js';
|
|
9
|
+
export type { ActionOptions, ActionRefresh, DomainProviderProps, DomainAction, MutationOptions, QueryRefresh, RelationOptions, RelationResource, RelationUnavailable, RichReadOptions, } from './schema/index.js';
|
|
10
10
|
export { Link, NavigationScope, NavScope, NodeLink, pathParam, ViewLink, defineNavigation, enumParam, location, memoryAdapter, urlAdapter, useAncestors, useLocation, useNavigate, useNavigation, useNavScope, } from './navigation/index.js';
|
|
11
11
|
export type { LinkProps, LocationDefinition, MissingPolicy, NavAdapter, NavLocation, NavScopeHandle, NavScopeProps, NavSnapshot, NavTarget, NavigationDefinition, NavigationParam, NavigationParams, NavigationRoutes, NavigationTarget, NodeLinkProps, Navigate, SerializedLocation, ViewLinkProps, } from './navigation/index.js';
|
|
12
12
|
export { SelectionScope, useSelection } from './selection/index.js';
|
|
@@ -29,4 +29,3 @@ export type { PathLike } from '@astrale-os/sdk/graph/path';
|
|
|
29
29
|
export type { AuthApi, Identity, PolicyDecisionInput } from '@astrale-os/sdk/auth';
|
|
30
30
|
export type { DomainBinding } from '@astrale-os/shell';
|
|
31
31
|
export type { App, CloseResult, CredentialSnapshot, HostCapabilities, IntentRegistry, KernelClient, MountCredential, NodeTarget, Shell, ShellConfig, SpaceNode, UserNode, ViewLocation, ViewPresentation, ViewPresentationRequest, Window, } from '@astrale-os/shell';
|
|
32
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { ActAs, useAuth, useCan, useSelf } from './auth/index.js';
|
|
|
5
5
|
// One Store path and named SDK definitions. Raw Query/Mutation builders are intentionally absent.
|
|
6
6
|
export { ClientError, NodeUnavailableError, ProtocolError, ResponseError, StaleRouteError, TransportError, isClientError, isNodeUnavailableError, useCall, useGraphStore, useQuery, useStream, } from './graph/index.js';
|
|
7
7
|
// Rich exact Domain bindings.
|
|
8
|
-
export { RelationUnavailableError, queryRefresh, useAction, useDomain, useDomains, useDynamicDomain, useDynamicObject, useKernel, useMutation, useObject, useRelation, } from './schema/index.js';
|
|
8
|
+
export { DomainProvider, RelationUnavailableError, queryRefresh, useAction, useDomain, useDomains, useDynamicDomain, useDynamicObject, useKernel, useMutation, useObject, useRelation, } from './schema/index.js';
|
|
9
9
|
// Typed navigation and selection.
|
|
10
10
|
export { Link, NavigationScope, NavScope, NodeLink, pathParam, ViewLink, defineNavigation, enumParam, location, memoryAdapter, urlAdapter, useAncestors, useLocation, useNavigate, useNavigation, useNavScope, } from './navigation/index.js';
|
|
11
11
|
export { SelectionScope, useSelection } from './selection/index.js';
|
package/dist/intents/index.d.ts
CHANGED
|
@@ -5,4 +5,3 @@ export type { EmitIntent } from './emit-intent.hook.js';
|
|
|
5
5
|
export { useSendIntent } from './send-intent.hook.js';
|
|
6
6
|
export type { SendIntent } from './send-intent.hook.js';
|
|
7
7
|
export type { IntentPayload, IntentReply } from './envelope.js';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -13,4 +13,3 @@ export interface IntentCtx<K extends keyof IntentRegistry> {
|
|
|
13
13
|
* answers a correlated request once.
|
|
14
14
|
*/
|
|
15
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
|
package/dist/intents/reply.d.ts
CHANGED
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
import type { Shell } from '@astrale-os/shell';
|
|
7
7
|
/** Deliver a reply to whichever channel the request arrived on. Best-effort. */
|
|
8
8
|
export declare function sendReply(shell: Shell, sender: string, correlationId: string, result: unknown): void;
|
|
9
|
-
//# sourceMappingURL=reply.d.ts.map
|
|
@@ -6,4 +6,3 @@ import type { SerializedLocation } from '../history.js';
|
|
|
6
6
|
import type { NavAdapter } from './adapter.js';
|
|
7
7
|
/** In-memory adapter — the default scope backing (per-pane state, no URL). */
|
|
8
8
|
export declare function memoryAdapter(initial?: SerializedLocation): NavAdapter;
|
|
9
|
-
//# sourceMappingURL=memory.adapter.d.ts.map
|
|
@@ -57,4 +57,3 @@ export declare function useNavigation<Routes extends NavigationRoutes>(navigatio
|
|
|
57
57
|
}>;
|
|
58
58
|
export type NavigationTarget<Definition> = Definition extends NavigationDefinition<infer Routes> ? RouteTarget<Routes> : never;
|
|
59
59
|
export {};
|
|
60
|
-
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -15,4 +15,3 @@ export type { NavAdapter } from './adapters/adapter.js';
|
|
|
15
15
|
export type { NavLocation } from './location.js';
|
|
16
16
|
export type { NavSnapshot, SerializedLocation } from './history.js';
|
|
17
17
|
export type { NavTarget } from './snapshot.js';
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -18,4 +18,3 @@ export interface NavLocation {
|
|
|
18
18
|
export declare const IDLE_LOCATION: NavLocation;
|
|
19
19
|
export declare function buildLocation(entry: SerializedLocation | null, result: PointResult | null): NavLocation;
|
|
20
20
|
export type { Node, NodeId };
|
|
21
|
-
//# sourceMappingURL=location.d.ts.map
|
|
@@ -14,4 +14,3 @@ export type NavTarget = PathLike | Node | {
|
|
|
14
14
|
export declare function serializeTarget(target: NavTarget): SerializedLocation;
|
|
15
15
|
/** Drop restored entries that no longer resolve under the authenticated Graph capability. */
|
|
16
16
|
export declare function revalidateAndPrune(history: NavHistory, store: GraphStore, shell: Shell): Promise<boolean>;
|
|
17
|
-
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BoundNodeFor } from '@astrale-os/sdk/client';
|
|
2
2
|
import type { SessionRequestOptions } from '@astrale-os/sdk/client/session';
|
|
3
|
-
import type { QueryAST } from '@astrale-os/sdk/query';
|
|
3
|
+
import type { QueryAST, QueryDefinition } from '@astrale-os/sdk/query';
|
|
4
|
+
import type { Domain } from '@astrale-os/sdk/schema';
|
|
4
5
|
import type { CallableInputOf, CallableResultOf, MethodOwnerKeyOf, MethodInheritance, ResolvedFunction, ResolvedMethod } from '@astrale-os/sdk/schema';
|
|
5
6
|
type ExecutableInheritance = Exclude<MethodInheritance, 'abstract'>;
|
|
6
7
|
type InstanceMethod = ResolvedMethod<unknown, unknown, false, ExecutableInheritance>;
|
|
@@ -10,23 +11,15 @@ type MethodReceiver<C extends InstanceMethod> = BoundNodeFor<MethodOwnerKeyOf<C>
|
|
|
10
11
|
declare const QUERY_REFRESH: unique symbol;
|
|
11
12
|
export interface QueryRefresh {
|
|
12
13
|
readonly id: string;
|
|
13
|
-
readonly [QUERY_REFRESH]: () => {
|
|
14
|
+
readonly [QUERY_REFRESH]: (domain: Domain) => {
|
|
14
15
|
readonly ast: QueryAST;
|
|
15
16
|
readonly page: Readonly<{
|
|
16
17
|
readonly size: number;
|
|
17
18
|
}>;
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
type RefreshableQuery<Input, Query extends QueryAST> = {
|
|
21
|
-
readonly id: string;
|
|
22
|
-
readonly page: Readonly<{
|
|
23
|
-
readonly size: number;
|
|
24
|
-
}>;
|
|
25
|
-
prepare?(input: Input): Input;
|
|
26
|
-
build(input: Input): Query;
|
|
27
|
-
};
|
|
28
21
|
/** Pair one exact named Query definition with its admitted input for targeted invalidation. */
|
|
29
|
-
export declare function queryRefresh<Input,
|
|
22
|
+
export declare function queryRefresh<DomainValue extends Domain, Input, Output>(definition: QueryDefinition<DomainValue, Input, Output>, input: Input): QueryRefresh;
|
|
30
23
|
export type ActionRefresh = 'all' | 'none' | {
|
|
31
24
|
readonly queries: readonly QueryRefresh[];
|
|
32
25
|
};
|
|
@@ -45,4 +38,3 @@ export interface DomainAction<Args extends unknown[], Result> {
|
|
|
45
38
|
/** Invoke one schema-declared Function or Method and invalidate Store by explicit policy. */
|
|
46
39
|
export declare function useAction<C extends Callable>(callable: C, options?: ActionOptions): DomainAction<ActionArgs<C>, CallableResultOf<C>>;
|
|
47
40
|
export {};
|
|
48
|
-
//# sourceMappingURL=action.hook.d.ts.map
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { reference } from '@astrale-os/sdk/client/session';
|
|
2
2
|
import { Path } from '@astrale-os/sdk/graph/path';
|
|
3
|
+
import { realizeQuery } from '@astrale-os/sdk/query';
|
|
3
4
|
import { useCallback, useMemo, useRef } from 'react';
|
|
4
5
|
import { useSessionKernel } from '../auth/session-kernel.js';
|
|
5
6
|
import { useAction as useAsyncAction } from '../graph/action.js';
|
|
6
7
|
import { useGraphStore } from '../graph/store.js';
|
|
7
8
|
import { bindingFor } from './domain.hook.js';
|
|
8
9
|
const QUERY_REFRESH = Symbol('shell-react.query-refresh');
|
|
10
|
+
const queryRefreshIdentities = new WeakMap();
|
|
11
|
+
let nextQueryRefreshIdentity = 0;
|
|
9
12
|
/** Pair one exact named Query definition with its admitted input for targeted invalidation. */
|
|
10
13
|
export function queryRefresh(definition, input) {
|
|
14
|
+
const id = queryRefreshIdentity(definition);
|
|
11
15
|
return Object.freeze({
|
|
12
|
-
id
|
|
13
|
-
[QUERY_REFRESH]: () => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
+
id,
|
|
17
|
+
[QUERY_REFRESH]: (domain) => {
|
|
18
|
+
const realized = realizeQuery(definition, domain);
|
|
19
|
+
if (realized.kind !== 'single') {
|
|
20
|
+
throw new TypeError('Targeted refresh requires a single Query recipe.');
|
|
21
|
+
}
|
|
22
|
+
const prepared = realized.prepare?.(input) ?? input;
|
|
23
|
+
return Object.freeze({ ast: realized.build(prepared), page: realized.page });
|
|
16
24
|
},
|
|
17
25
|
});
|
|
18
26
|
}
|
|
@@ -40,7 +48,7 @@ export function useAction(callable, options = {}) {
|
|
|
40
48
|
store.invalidate();
|
|
41
49
|
else if (refresh !== 'none') {
|
|
42
50
|
refresh.queries.forEach((query) => {
|
|
43
|
-
const target = query[QUERY_REFRESH]();
|
|
51
|
+
const target = query[QUERY_REFRESH](bindingRef.current.domain);
|
|
44
52
|
store.invalidate(target.ast, { page: target.page });
|
|
45
53
|
});
|
|
46
54
|
}
|
|
@@ -75,3 +83,11 @@ function isInstanceMethod(callable) {
|
|
|
75
83
|
function receiverPath(receiver) {
|
|
76
84
|
return Path.id(receiver.id);
|
|
77
85
|
}
|
|
86
|
+
function queryRefreshIdentity(definition) {
|
|
87
|
+
const current = queryRefreshIdentities.get(definition);
|
|
88
|
+
if (current !== undefined)
|
|
89
|
+
return current;
|
|
90
|
+
const created = `query-${++nextQueryRefreshIdentity}`;
|
|
91
|
+
queryRefreshIdentities.set(definition, created);
|
|
92
|
+
return created;
|
|
93
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Domain } from '@astrale-os/sdk/schema';
|
|
2
|
+
import type { schema } from '@astrale-os/sdk/schema';
|
|
3
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
4
|
+
export interface DomainProviderProps<Schema extends schema.DomainSchema> {
|
|
5
|
+
readonly schema: Schema;
|
|
6
|
+
readonly children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/** Resolve one exact installed Domain for every projected recipe in the React subtree. */
|
|
9
|
+
export declare function DomainProvider<const Schema extends schema.DomainSchema>(props: DomainProviderProps<Schema>): ReactElement;
|
|
10
|
+
export declare function useExecutionDomain<DomainValue extends Domain>(): DomainValue;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
import { useDomain } from './domain.hook.js';
|
|
4
|
+
const DomainContext = createContext(null);
|
|
5
|
+
DomainContext.displayName = 'AstraleDomainContext';
|
|
6
|
+
/** Resolve one exact installed Domain for every projected recipe in the React subtree. */
|
|
7
|
+
export function DomainProvider(props) {
|
|
8
|
+
const binding = useDomain(props.schema);
|
|
9
|
+
return _jsx(DomainContext.Provider, { value: binding.domain, children: props.children });
|
|
10
|
+
}
|
|
11
|
+
export function useExecutionDomain() {
|
|
12
|
+
const domain = useContext(DomainContext);
|
|
13
|
+
if (domain === null) {
|
|
14
|
+
throw new Error('Projected Query and Mutation hooks require a surrounding DomainProvider.');
|
|
15
|
+
}
|
|
16
|
+
return domain;
|
|
17
|
+
}
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { useKernel } from './kernel.hook.js';
|
|
2
2
|
export { useDomain, useDomains, useDynamicDomain } from './domain.hook.js';
|
|
3
|
+
export { DomainProvider } from './domain.context.js';
|
|
4
|
+
export type { DomainProviderProps } from './domain.context.js';
|
|
3
5
|
export { queryRefresh, useAction } from './action.hook.js';
|
|
4
6
|
export type { ActionOptions, ActionRefresh, DomainAction, QueryRefresh } from './action.hook.js';
|
|
5
7
|
export { useMutation } from './mutation.hook.js';
|
|
@@ -8,4 +10,3 @@ export { useDynamicObject, useObject } from './object.hook.js';
|
|
|
8
10
|
export type { RichReadOptions } from './object.hook.js';
|
|
9
11
|
export { RelationUnavailableError, useRelation } from './relation.hook.js';
|
|
10
12
|
export type { RelationOptions, RelationResource, RelationUnavailable } from './relation.hook.js';
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|