@astrale-os/shell-react 0.2.9 → 0.2.10-beta.3
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 +4 -15
- package/dist/application/apps/app-host.d.ts.map +1 -1
- package/dist/application/apps/app-host.js +1 -1
- package/dist/application/apps/apps.hook.d.ts +7 -4
- package/dist/application/apps/apps.hook.d.ts.map +1 -1
- package/dist/application/apps/apps.hook.js +10 -2
- package/dist/application/apps/domains.hook.d.ts +1 -1
- package/dist/application/apps/domains.hook.d.ts.map +1 -1
- package/dist/application/apps/domains.hook.js +1 -1
- package/dist/application/apps/open-app.hook.d.ts +2 -3
- package/dist/application/apps/open-app.hook.d.ts.map +1 -1
- package/dist/application/index.d.ts +2 -4
- package/dist/application/index.d.ts.map +1 -1
- package/dist/application/index.js +2 -3
- package/dist/application/spaces/space.hook.d.ts +2 -2
- package/dist/application/spaces/space.hook.d.ts.map +1 -1
- package/dist/application/spaces/space.hook.js +2 -2
- package/dist/application/spaces/spaces.hook.d.ts +2 -3
- package/dist/application/spaces/spaces.hook.d.ts.map +1 -1
- package/dist/application/spaces/spaces.hook.js +10 -3
- package/dist/auth/act-as.context.d.ts +15 -32
- package/dist/auth/act-as.context.d.ts.map +1 -1
- package/dist/auth/act-as.context.js +22 -66
- package/dist/auth/auth.hook.d.ts +1 -0
- package/dist/auth/auth.hook.d.ts.map +1 -1
- package/dist/auth/auth.hook.js +2 -22
- package/dist/auth/can.hook.d.ts +10 -38
- package/dist/auth/can.hook.d.ts.map +1 -1
- package/dist/auth/can.hook.js +35 -110
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/self.hook.d.ts +2 -2
- package/dist/auth/self.hook.d.ts.map +1 -1
- package/dist/auth/self.hook.js +0 -7
- package/dist/auth/session-kernel.d.ts +2 -3
- package/dist/auth/session-kernel.d.ts.map +1 -1
- package/dist/auth/session-kernel.js +4 -13
- package/dist/components/astrale.d.ts +14 -0
- package/dist/components/astrale.d.ts.map +1 -0
- package/dist/components/astrale.js +12 -0
- package/dist/components/boundaries.d.ts +47 -0
- package/dist/components/boundaries.d.ts.map +1 -0
- package/dist/components/boundaries.js +55 -0
- package/dist/components/can.d.ts +11 -0
- package/dist/components/can.d.ts.map +1 -0
- package/dist/components/can.js +5 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/graph/call/call.hook.d.ts +8 -18
- package/dist/graph/call/call.hook.d.ts.map +1 -1
- package/dist/graph/call/call.hook.js +7 -13
- package/dist/graph/call/stream.hook.d.ts +12 -20
- package/dist/graph/call/stream.hook.d.ts.map +1 -1
- package/dist/graph/call/stream.hook.js +55 -111
- package/dist/graph/graph.context.d.ts +4 -3
- package/dist/graph/graph.context.d.ts.map +1 -1
- package/dist/graph/graph.context.js +2 -8
- package/dist/graph/guards.error.d.ts +7 -8
- package/dist/graph/guards.error.d.ts.map +1 -1
- package/dist/graph/guards.error.js +11 -7
- package/dist/graph/index.d.ts +8 -16
- package/dist/graph/index.d.ts.map +1 -1
- package/dist/graph/index.js +3 -7
- package/dist/graph/memory/read/envelope.d.ts +22 -54
- package/dist/graph/memory/read/envelope.d.ts.map +1 -1
- package/dist/graph/memory/read/envelope.js +26 -20
- package/dist/graph/memory/read/idle.d.ts +1 -15
- package/dist/graph/memory/read/idle.d.ts.map +1 -1
- package/dist/graph/memory/read/idle.js +4 -13
- package/dist/graph/query-definition.hook.d.ts +11 -0
- package/dist/graph/query-definition.hook.d.ts.map +1 -0
- package/dist/graph/query-definition.hook.js +205 -0
- package/dist/graph/resource.d.ts +34 -0
- package/dist/graph/resource.d.ts.map +1 -0
- package/dist/graph/resource.js +244 -0
- package/dist/graph/store.d.ts +25 -0
- package/dist/graph/store.d.ts.map +1 -0
- package/dist/graph/store.js +69 -0
- package/dist/host/actions.hook.d.ts +34 -0
- package/dist/host/actions.hook.d.ts.map +1 -0
- package/dist/host/actions.hook.js +125 -0
- package/dist/host/components.d.ts +15 -0
- package/dist/host/components.d.ts.map +1 -0
- package/dist/host/components.js +14 -0
- package/dist/host/index.d.ts +5 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +3 -0
- package/dist/index.d.ts +26 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -31
- package/dist/intents/envelope.d.ts +7 -19
- package/dist/intents/envelope.d.ts.map +1 -1
- package/dist/intents/envelope.js +2 -3
- package/dist/intents/send-intent.hook.d.ts +5 -7
- package/dist/intents/send-intent.hook.d.ts.map +1 -1
- package/dist/intents/send-intent.hook.js +17 -75
- package/dist/navigation/adapters/adapter.d.ts +5 -0
- package/dist/navigation/adapters/adapter.d.ts.map +1 -1
- package/dist/navigation/adapters/memory.adapter.d.ts.map +1 -1
- package/dist/navigation/adapters/memory.adapter.js +4 -0
- package/dist/navigation/adapters/url.adapter.d.ts.map +1 -1
- package/dist/navigation/adapters/url.adapter.js +57 -10
- package/dist/navigation/codec.d.ts +60 -0
- package/dist/navigation/codec.d.ts.map +1 -0
- package/dist/navigation/codec.js +121 -0
- package/dist/navigation/history.d.ts +11 -9
- package/dist/navigation/history.d.ts.map +1 -1
- package/dist/navigation/history.js +6 -8
- package/dist/navigation/hooks/ancestors.hook.d.ts +5 -7
- package/dist/navigation/hooks/ancestors.hook.d.ts.map +1 -1
- package/dist/navigation/hooks/ancestors.hook.js +7 -51
- package/dist/navigation/hooks/location.hook.d.ts.map +1 -1
- package/dist/navigation/hooks/location.hook.js +4 -6
- package/dist/navigation/hooks/scope.hook.d.ts.map +1 -1
- package/dist/navigation/hooks/scope.hook.js +4 -6
- package/dist/navigation/index.d.ts +4 -2
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +2 -1
- package/dist/navigation/link.d.ts +12 -0
- package/dist/navigation/link.d.ts.map +1 -1
- package/dist/navigation/link.js +13 -2
- package/dist/navigation/location.d.ts +13 -40
- package/dist/navigation/location.d.ts.map +1 -1
- package/dist/navigation/location.js +14 -76
- package/dist/navigation/scope.context.d.ts +17 -26
- package/dist/navigation/scope.context.d.ts.map +1 -1
- package/dist/navigation/scope.context.js +140 -108
- package/dist/navigation/snapshot.d.ts +14 -19
- package/dist/navigation/snapshot.d.ts.map +1 -1
- package/dist/navigation/snapshot.js +48 -44
- package/dist/schema/action.hook.d.ts +44 -0
- package/dist/schema/action.hook.d.ts.map +1 -0
- package/dist/schema/action.hook.js +72 -0
- package/dist/schema/domain.hook.d.ts +12 -7
- package/dist/schema/domain.hook.d.ts.map +1 -1
- package/dist/schema/domain.hook.js +101 -4
- package/dist/schema/index.d.ts +9 -8
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +5 -7
- package/dist/schema/kernel.hook.d.ts +4 -9
- package/dist/schema/kernel.hook.d.ts.map +1 -1
- package/dist/schema/kernel.hook.js +4 -6
- package/dist/schema/mutation.hook.d.ts +9 -0
- package/dist/schema/mutation.hook.d.ts.map +1 -0
- package/dist/schema/mutation.hook.js +41 -0
- package/dist/schema/object.hook.d.ts +16 -0
- package/dist/schema/object.hook.d.ts.map +1 -0
- package/dist/schema/object.hook.js +46 -0
- package/dist/schema/relation.hook.d.ts +46 -0
- package/dist/schema/relation.hook.d.ts.map +1 -0
- package/dist/schema/relation.hook.js +136 -0
- package/dist/selection/live.d.ts +9 -17
- package/dist/selection/live.d.ts.map +1 -1
- package/dist/selection/live.js +65 -112
- package/dist/selection/scope.context.js +5 -4
- package/dist/session/boot/boot.d.ts +1 -13
- package/dist/session/boot/boot.d.ts.map +1 -1
- package/dist/session/boot/boot.js +9 -27
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/kernel-instance.hook.d.ts +1 -4
- package/dist/session/kernel-instance.hook.d.ts.map +1 -1
- package/dist/session/kernel-instance.hook.js +1 -5
- package/dist/session/provider.d.ts +9 -23
- package/dist/session/provider.d.ts.map +1 -1
- package/dist/session/provider.js +29 -75
- package/dist/session/session.context.d.ts +5 -0
- package/dist/session/session.context.d.ts.map +1 -1
- package/dist/window/adopt.d.ts +0 -1
- package/dist/window/adopt.d.ts.map +1 -1
- package/dist/window/hooks/target-node.hook.d.ts +10 -6
- package/dist/window/hooks/target-node.hook.d.ts.map +1 -1
- package/dist/window/hooks/target-node.hook.js +14 -72
- package/dist/window/hooks/views-for.hook.d.ts +4 -3
- package/dist/window/hooks/views-for.hook.d.ts.map +1 -1
- package/dist/window/hooks/views-for.hook.js +6 -22
- package/dist/window/hooks/windows.hook.d.ts.map +1 -1
- package/dist/window/hooks/windows.hook.js +3 -4
- package/dist/window/host.d.ts +9 -11
- package/dist/window/host.d.ts.map +1 -1
- package/dist/window/host.js +26 -62
- package/dist/window/hub.d.ts +2 -0
- package/dist/window/hub.d.ts.map +1 -1
- package/dist/window/hub.js +33 -0
- package/dist/window/index.d.ts +2 -2
- package/dist/window/index.d.ts.map +1 -1
- package/dist/window/index.js +2 -2
- package/dist/window/lifecycle/mount.d.ts +5 -44
- package/dist/window/lifecycle/mount.d.ts.map +1 -1
- package/dist/window/lifecycle/mount.js +14 -120
- package/dist/window/lifecycle/states.d.ts +0 -5
- package/dist/window/lifecycle/states.d.ts.map +1 -1
- package/package.json +20 -8
- package/src/application/apps/app-host.tsx +11 -15
- package/src/application/apps/apps.hook.ts +13 -6
- package/src/application/apps/domains.hook.ts +1 -1
- package/src/application/apps/open-app.hook.ts +3 -4
- package/src/application/index.ts +4 -6
- package/src/application/spaces/space.hook.ts +5 -6
- package/src/application/spaces/spaces.hook.ts +14 -9
- package/src/auth/act-as.context.tsx +37 -91
- package/src/auth/auth.hook.ts +2 -30
- package/src/auth/can.hook.ts +44 -135
- package/src/auth/index.ts +1 -0
- package/src/auth/self.hook.ts +2 -9
- package/src/auth/session-kernel.ts +6 -16
- package/src/components/astrale.tsx +40 -0
- package/src/components/boundaries.tsx +113 -0
- package/src/components/can.tsx +16 -0
- package/src/components/index.ts +13 -0
- package/src/graph/call/call.hook.ts +22 -27
- package/src/graph/call/stream.hook.ts +66 -143
- package/src/graph/graph.context.ts +6 -11
- package/src/graph/guards.error.ts +17 -55
- package/src/graph/index.ts +23 -17
- package/src/graph/memory/read/envelope.ts +40 -65
- package/src/graph/memory/read/idle.ts +5 -18
- package/src/graph/query-definition.hook.ts +270 -0
- package/src/graph/resource.ts +358 -0
- package/src/graph/store.ts +97 -0
- package/src/host/actions.hook.ts +165 -0
- package/src/host/components.tsx +29 -0
- package/src/host/index.ts +17 -0
- package/src/index.ts +131 -124
- package/src/intents/envelope.ts +7 -23
- package/src/intents/send-intent.hook.ts +24 -79
- package/src/navigation/adapters/adapter.ts +3 -0
- package/src/navigation/adapters/memory.adapter.ts +4 -0
- package/src/navigation/adapters/url.adapter.ts +48 -8
- package/src/navigation/codec.ts +190 -0
- package/src/navigation/history.ts +20 -11
- package/src/navigation/hooks/ancestors.hook.ts +10 -60
- package/src/navigation/hooks/location.hook.ts +4 -6
- package/src/navigation/hooks/scope.hook.ts +4 -6
- package/src/navigation/index.ts +18 -2
- package/src/navigation/link.tsx +27 -2
- package/src/navigation/location.ts +26 -93
- package/src/navigation/scope.context.tsx +151 -136
- package/src/navigation/snapshot.ts +69 -50
- package/src/schema/action.hook.ts +146 -0
- package/src/schema/domain.hook.ts +127 -11
- package/src/schema/index.ts +9 -30
- package/src/schema/kernel.hook.ts +6 -13
- package/src/schema/mutation.hook.ts +63 -0
- package/src/schema/object.hook.ts +85 -0
- package/src/schema/relation.hook.ts +253 -0
- package/src/selection/live.ts +75 -125
- package/src/selection/scope.context.tsx +4 -4
- package/src/session/boot/boot.ts +8 -33
- package/src/session/index.ts +1 -0
- package/src/session/kernel-instance.hook.ts +2 -11
- package/src/session/provider.tsx +34 -103
- package/src/session/session.context.ts +6 -0
- package/src/window/adopt.ts +0 -1
- package/src/window/hooks/target-node.hook.ts +20 -85
- package/src/window/hooks/views-for.hook.ts +12 -25
- package/src/window/hooks/windows.hook.ts +3 -4
- package/src/window/host.tsx +35 -77
- package/src/window/hub.ts +33 -0
- package/src/window/index.ts +3 -3
- package/src/window/lifecycle/mount.ts +15 -160
- package/src/window/lifecycle/states.ts +1 -5
- package/dist/application/roles.hook.d.ts +0 -7
- package/dist/application/roles.hook.d.ts.map +0 -1
- package/dist/application/roles.hook.js +0 -23
- package/dist/graph/memory/base.d.ts +0 -21
- package/dist/graph/memory/base.d.ts.map +0 -1
- package/dist/graph/memory/base.js +0 -33
- package/dist/graph/memory/read/read.d.ts +0 -9
- package/dist/graph/memory/read/read.d.ts.map +0 -1
- package/dist/graph/memory/read/read.js +0 -87
- package/dist/graph/memory/scope.d.ts +0 -7
- package/dist/graph/memory/scope.d.ts.map +0 -1
- package/dist/graph/memory/scope.js +0 -25
- package/dist/graph/mutate/move.hook.d.ts +0 -7
- package/dist/graph/mutate/move.hook.d.ts.map +0 -1
- package/dist/graph/mutate/move.hook.js +0 -49
- package/dist/graph/mutate/mutate.hook.d.ts +0 -17
- package/dist/graph/mutate/mutate.hook.d.ts.map +0 -1
- package/dist/graph/mutate/mutate.hook.js +0 -45
- package/dist/graph/query/children.hook.d.ts +0 -29
- package/dist/graph/query/children.hook.d.ts.map +0 -1
- package/dist/graph/query/children.hook.js +0 -64
- package/dist/graph/query/graph.hook.d.ts +0 -9
- package/dist/graph/query/graph.hook.d.ts.map +0 -1
- package/dist/graph/query/graph.hook.js +0 -5
- package/dist/graph/query/neighbors.hook.d.ts +0 -7
- package/dist/graph/query/neighbors.hook.d.ts.map +0 -1
- package/dist/graph/query/neighbors.hook.js +0 -104
- package/dist/graph/query/node.hook.d.ts +0 -14
- package/dist/graph/query/node.hook.d.ts.map +0 -1
- package/dist/graph/query/node.hook.js +0 -43
- package/dist/graph/query/query.hook.d.ts +0 -14
- package/dist/graph/query/query.hook.d.ts.map +0 -1
- package/dist/graph/query/query.hook.js +0 -23
- package/dist/schema/bind-read.d.ts +0 -37
- package/dist/schema/bind-read.d.ts.map +0 -1
- package/dist/schema/bind-read.js +0 -205
- package/dist/schema/binding.d.ts +0 -21
- package/dist/schema/binding.d.ts.map +0 -1
- package/dist/schema/binding.js +0 -99
- package/dist/schema/function.hook.d.ts +0 -9
- package/dist/schema/function.hook.d.ts.map +0 -1
- package/dist/schema/function.hook.js +0 -40
- package/dist/schema/method.hook.d.ts +0 -14
- package/dist/schema/method.hook.d.ts.map +0 -1
- package/dist/schema/method.hook.js +0 -49
- package/dist/schema/tag.d.ts +0 -11
- package/dist/schema/tag.d.ts.map +0 -1
- package/dist/schema/tag.js +0 -11
- package/dist/schema/types.d.ts +0 -73
- package/dist/schema/types.d.ts.map +0 -1
- package/dist/schema/types.js +0 -1
- package/dist/schema/write.d.ts +0 -16
- package/dist/schema/write.d.ts.map +0 -1
- package/dist/schema/write.js +0 -56
- package/src/application/roles.hook.ts +0 -41
- package/src/graph/memory/base.ts +0 -50
- package/src/graph/memory/read/read.ts +0 -103
- package/src/graph/memory/scope.ts +0 -29
- package/src/graph/mutate/move.hook.ts +0 -70
- package/src/graph/mutate/mutate.hook.ts +0 -69
- package/src/graph/query/children.hook.ts +0 -136
- package/src/graph/query/graph.hook.ts +0 -13
- package/src/graph/query/neighbors.hook.ts +0 -159
- package/src/graph/query/node.hook.ts +0 -83
- package/src/graph/query/query.hook.ts +0 -42
- package/src/schema/bind-read.ts +0 -319
- package/src/schema/binding.ts +0 -146
- package/src/schema/function.hook.ts +0 -68
- package/src/schema/method.hook.ts +0 -103
- package/src/schema/tag.ts +0 -19
- package/src/schema/types.ts +0 -150
- package/src/schema/write.ts +0 -96
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ApplicationNode, AppSession, IntentRegistry } from '@astrale-os/shell';
|
|
1
|
+
import type { ApplicationNode, AppSession, HostCapabilities, NodeTarget, ResolvedView } from '@astrale-os/shell';
|
|
3
2
|
import type { CSSProperties, ReactNode } from 'react';
|
|
4
3
|
import type { SandboxPolicy, ViewHostHandle } from '../../window/host.js';
|
|
5
|
-
import type { ViewDescriptor } from '../../window/lifecycle/mount.js';
|
|
6
4
|
import type { WindowState } from '../../window/lifecycle/states.js';
|
|
7
5
|
/** The states `AppHost`'s fallback answers — the frame's, plus the two OS phases. */
|
|
8
6
|
export type AppHostFallbackState = WindowState | {
|
|
@@ -11,19 +9,10 @@ export type AppHostFallbackState = WindowState | {
|
|
|
11
9
|
readonly phase: 'no-view';
|
|
12
10
|
};
|
|
13
11
|
export interface AppHostProps {
|
|
14
|
-
app: ApplicationNode |
|
|
12
|
+
app: ApplicationNode | NodeTarget;
|
|
15
13
|
/** Override the entry View while keeping the application's delegated session alive. */
|
|
16
|
-
view?:
|
|
17
|
-
|
|
18
|
-
* Default target node delivered to the app's view as `targetNodeId` (API §12.2).
|
|
19
|
-
* Container-anchored apps need one — the dock passes the current space. A deeper
|
|
20
|
-
* fix (an install-time app data container + `app::open` returning a default
|
|
21
|
-
* target) is a tracked domain-modeling question; until then the host supplies it.
|
|
22
|
-
*/
|
|
23
|
-
node?: NodeRefInput;
|
|
24
|
-
capabilities?: {
|
|
25
|
-
intents: readonly (keyof IntentRegistry)[];
|
|
26
|
-
};
|
|
14
|
+
view?: ResolvedView;
|
|
15
|
+
capabilities?: HostCapabilities;
|
|
27
16
|
sandbox?: SandboxPolicy;
|
|
28
17
|
fallback?: (state: AppHostFallbackState) => ReactNode;
|
|
29
18
|
onSession?: (session: AppSession) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-host.d.ts","sourceRoot":"","sources":["../../../src/application/apps/app-host.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"app-host.d.ts","sourceRoot":"","sources":["../../../src/application/apps/app-host.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,YAAY,EACb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAA;AAWnE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAMnE,qFAAqF;AACrF,MAAM,MAAM,oBAAoB,GAC5B,WAAW,GACX;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAA;AAEjC,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,eAAe,GAAG,UAAU,CAAA;IACjC,uFAAuF;IACvF,IAAI,CAAC,EAAE,YAAY,CAAA;IACnB,YAAY,CAAC,EAAE,gBAAgB,CAAA;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAAA;IACrD,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,CAAA;IACzC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB;AAED,eAAO,MAAM,OAAO,yGAoEnB,CAAA"}
|
|
@@ -56,5 +56,5 @@ export const AppHost = forwardRef(function AppHost(props, ref) {
|
|
|
56
56
|
const view = props.view ?? session.view;
|
|
57
57
|
if (view === null)
|
|
58
58
|
return box(fallback?.({ phase: 'no-view' }) ?? null);
|
|
59
|
-
return (_jsx(ViewHost, { ref: ref, view: view,
|
|
59
|
+
return (_jsx(ViewHost, { ref: ref, view: view, credential: session.credential, capabilities: props.capabilities, sandbox: props.sandbox, fallback: fallback ? (s) => fallback(s) : undefined, className: className, style: style }));
|
|
60
60
|
});
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ApplicationNode, SpaceNode } from '@astrale-os/shell';
|
|
1
|
+
import type { ApplicationNode, NodeTarget, SpaceNode } from '@astrale-os/shell';
|
|
3
2
|
import type { ReadState } from '../../graph/memory/read/envelope.js';
|
|
4
3
|
export interface AppsResult extends ReadState {
|
|
5
4
|
readonly apps: readonly ApplicationNode[];
|
|
6
5
|
}
|
|
7
|
-
export declare function useApps(space?: SpaceNode |
|
|
6
|
+
export declare function useApps(space?: SpaceNode | NodeTarget | null): AppsResult;
|
|
8
7
|
/** An `@id` ref for a bound node, else the normalized ref of a raw subject. */
|
|
9
|
-
export declare function toRef(x:
|
|
8
|
+
export declare function toRef(x: NodeTarget | {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
}): NodeTarget;
|
|
11
|
+
/** Stable dependency identity for one Shell node target. */
|
|
12
|
+
export declare function targetKey(x: NodeTarget | {
|
|
10
13
|
readonly id: string;
|
|
11
14
|
}): string;
|
|
12
15
|
//# sourceMappingURL=apps.hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps.hook.d.ts","sourceRoot":"","sources":["../../../src/application/apps/apps.hook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apps.hook.d.ts","sourceRoot":"","sources":["../../../src/application/apps/apps.hook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAY/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAWpE,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,QAAQ,CAAC,IAAI,EAAE,SAAS,eAAe,EAAE,CAAA;CAC1C;AAED,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI,GAAG,UAAU,CA0CzE;AAOD,+EAA+E;AAC/E,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAEzE;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAIzE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Path } from '@astrale-os/sdk/graph/path';
|
|
2
2
|
/**
|
|
3
3
|
* useApps(space?) (API §12.2) — the apps installed in a space (`installed_in`
|
|
4
4
|
* in-edges). No arg targets the CURRENT space (shared store, so a switch anywhere
|
|
@@ -47,5 +47,13 @@ function hasId(x) {
|
|
|
47
47
|
}
|
|
48
48
|
/** An `@id` ref for a bound node, else the normalized ref of a raw subject. */
|
|
49
49
|
export function toRef(x) {
|
|
50
|
-
return hasId(x) ?
|
|
50
|
+
return hasId(x) ? x.id : x;
|
|
51
|
+
}
|
|
52
|
+
/** Stable dependency identity for one Shell node target. */
|
|
53
|
+
export function targetKey(x) {
|
|
54
|
+
if (hasId(x))
|
|
55
|
+
return `id:${x.id}`;
|
|
56
|
+
if (typeof x === 'string')
|
|
57
|
+
return `text:${x}`;
|
|
58
|
+
return `path:${Path.from(x).raw}`;
|
|
51
59
|
}
|
|
@@ -3,5 +3,5 @@ import type { ReadState } from '../../graph/memory/read/envelope.js';
|
|
|
3
3
|
export interface DomainsResult extends ReadState {
|
|
4
4
|
readonly domains: readonly DomainSearchResult[];
|
|
5
5
|
}
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function useInstalledDomains(): DomainsResult;
|
|
7
7
|
//# sourceMappingURL=domains.hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domains.hook.d.ts","sourceRoot":"","sources":["../../../src/application/apps/domains.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAI3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAQpE,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAA;CAChD;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"domains.hook.d.ts","sourceRoot":"","sources":["../../../src/application/apps/domains.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAI3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAQpE,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAA;CAChD;AAED,wBAAgB,mBAAmB,IAAI,aAAa,CAoBnD"}
|
|
@@ -3,7 +3,7 @@ import { useAsyncResource } from '../../graph/async.js';
|
|
|
3
3
|
import { useShell } from '../../session/shell.hook.js';
|
|
4
4
|
import { isOsPlaneAvailable } from '../user/user.store.js';
|
|
5
5
|
const NO_DOMAINS = [];
|
|
6
|
-
export function
|
|
6
|
+
export function useInstalledDomains() {
|
|
7
7
|
const shell = useShell();
|
|
8
8
|
const available = isOsPlaneAvailable(shell);
|
|
9
9
|
const result = useAsyncResource(available ? () => shell.apps.searchDomains() : null, NO_DOMAINS, [shell, available]);
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* app-open protocol lives in the shell package). Resolves to the session; disposal
|
|
4
4
|
* is the caller's (AppHost disposes it with the window).
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
7
|
-
import type { ApplicationNode, AppSession } from '@astrale-os/shell';
|
|
6
|
+
import type { ApplicationNode, AppSession, NodeTarget } from '@astrale-os/shell';
|
|
8
7
|
import type { Action } from '../../graph/action.js';
|
|
9
|
-
export declare function useOpenApp(): Action<[ApplicationNode |
|
|
8
|
+
export declare function useOpenApp(): Action<[ApplicationNode | NodeTarget], AppSession>;
|
|
10
9
|
//# sourceMappingURL=open-app.hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-app.hook.d.ts","sourceRoot":"","sources":["../../../src/application/apps/open-app.hook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"open-app.hook.d.ts","sourceRoot":"","sources":["../../../src/application/apps/open-app.hook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEhF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAMnD,wBAAgB,UAAU,IAAI,MAAM,CAAC,CAAC,eAAe,GAAG,UAAU,CAAC,EAAE,UAAU,CAAC,CAG/E"}
|
|
@@ -7,14 +7,12 @@ export { useSpace } from './spaces/space.hook.js';
|
|
|
7
7
|
export type { SpaceResult } from './spaces/space.hook.js';
|
|
8
8
|
export { useApps } from './apps/apps.hook.js';
|
|
9
9
|
export type { AppsResult } from './apps/apps.hook.js';
|
|
10
|
-
export {
|
|
10
|
+
export { useInstalledDomains } from './apps/domains.hook.js';
|
|
11
11
|
export type { DomainsResult } from './apps/domains.hook.js';
|
|
12
12
|
export { useOpenApp } from './apps/open-app.hook.js';
|
|
13
13
|
export { AppHost } from './apps/app-host.js';
|
|
14
14
|
export type { AppHostFallbackState, AppHostProps } from './apps/app-host.js';
|
|
15
15
|
export { AppLogo } from './apps/app-logo.js';
|
|
16
16
|
export type { AppLogoProps } from './apps/app-logo.js';
|
|
17
|
-
export {
|
|
18
|
-
export type { RolesResult } from './roles.hook.js';
|
|
19
|
-
export type { ApplicationNode, AppSession, DomainSearchResult, RoleNode, SpaceNode, UserNode, } from '@astrale-os/shell';
|
|
17
|
+
export type { ApplicationNode, AppSession, DomainSearchResult, NodeTarget, ResolvedView, SpaceNode, UserNode, } from '@astrale-os/shell';
|
|
20
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,YAAY,EACV,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,GACT,MAAM,mBAAmB,CAAA"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
// application — API §12.2. The OS-plane hooks over the shell package's
|
|
2
2
|
// `shell.user/spaces/apps` namespaces + the window module: useUser, useSpaces,
|
|
3
|
-
// useCurrentSpace, useSpace, useApps,
|
|
3
|
+
// useCurrentSpace, useSpace, useApps, useInstalledDomains, useOpenApp,
|
|
4
4
|
// AppHost, AppLogo.
|
|
5
5
|
export { useUser } from './user/user.hook.js';
|
|
6
6
|
export { useSpaces } from './spaces/spaces.hook.js';
|
|
7
7
|
export { useCurrentSpace } from './spaces/current-space.hook.js';
|
|
8
8
|
export { useSpace } from './spaces/space.hook.js';
|
|
9
9
|
export { useApps } from './apps/apps.hook.js';
|
|
10
|
-
export {
|
|
10
|
+
export { useInstalledDomains } from './apps/domains.hook.js';
|
|
11
11
|
export { useOpenApp } from './apps/open-app.hook.js';
|
|
12
12
|
export { AppHost } from './apps/app-host.js';
|
|
13
13
|
export { AppLogo } from './apps/app-logo.js';
|
|
14
|
-
export { useRoles } from './roles.hook.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NodeTarget } from '@astrale-os/shell';
|
|
2
2
|
import type { CurrentSpaceResult } from './current-space.hook.js';
|
|
3
3
|
export type SpaceResult = CurrentSpaceResult;
|
|
4
|
-
export declare function useSpace(ref:
|
|
4
|
+
export declare function useSpace(ref: NodeTarget | null | undefined): SpaceResult;
|
|
5
5
|
//# sourceMappingURL=space.hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"space.hook.d.ts","sourceRoot":"","sources":["../../../src/application/spaces/space.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"space.hook.d.ts","sourceRoot":"","sources":["../../../src/application/spaces/space.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,mBAAmB,CAAA;AAQ9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAQjE,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAA;AAE5C,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,CAqBxE"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { normalizeRef } from '@astrale-os/kernel-client';
|
|
2
1
|
/**
|
|
3
2
|
* useSpace(ref) (API §12.2) — a single space by ref; `null`/`undefined` (or an
|
|
4
3
|
* unavailable OS plane) is idle (§1.3). One-shot today (§12 flag).
|
|
@@ -7,12 +6,13 @@ import { useMemo } from 'react';
|
|
|
7
6
|
import { useAsyncResource } from '../../graph/async.js';
|
|
8
7
|
import { isIdleInput } from '../../graph/memory/read/idle.js';
|
|
9
8
|
import { useShell } from '../../session/shell.hook.js';
|
|
9
|
+
import { targetKey } from '../apps/apps.hook.js';
|
|
10
10
|
import { isOsPlaneAvailable } from '../user/user.store.js';
|
|
11
11
|
export function useSpace(ref) {
|
|
12
12
|
const shell = useShell();
|
|
13
13
|
const idle = isIdleInput(ref) || !isOsPlaneAvailable(shell);
|
|
14
14
|
// The inline guard (not the stored `idle`) narrows `ref` to non-null below.
|
|
15
|
-
const key = idle ? null :
|
|
15
|
+
const key = idle ? null : targetKey(ref);
|
|
16
16
|
const res = useAsyncResource(idle ? null : () => shell.spaces.get(ref), null, [shell, key]);
|
|
17
17
|
return useMemo(() => ({
|
|
18
18
|
space: idle ? null : res.data,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { SpaceNode } from '@astrale-os/shell';
|
|
1
|
+
import type { NodeTarget, SpaceNode } from '@astrale-os/shell';
|
|
3
2
|
import type { Action } from '../../graph/action.js';
|
|
4
3
|
import type { ReadState } from '../../graph/memory/read/envelope.js';
|
|
5
4
|
export interface SpacesResult extends ReadState {
|
|
@@ -8,7 +7,7 @@ export interface SpacesResult extends ReadState {
|
|
|
8
7
|
/** The `selected_space` target — optimistically ahead during a `switch`. */
|
|
9
8
|
readonly selected: SpaceNode | null;
|
|
10
9
|
/** `user::switchSpace` with a manual optimistic overlay (§1.6). */
|
|
11
|
-
readonly switch: Action<[
|
|
10
|
+
readonly switch: Action<[NodeTarget], void>;
|
|
12
11
|
}
|
|
13
12
|
export declare function useSpaces(): SpacesResult;
|
|
14
13
|
//# sourceMappingURL=spaces.hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spaces.hook.d.ts","sourceRoot":"","sources":["../../../src/application/spaces/spaces.hook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spaces.hook.d.ts","sourceRoot":"","sources":["../../../src/application/spaces/spaces.hook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAY9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAUpE,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAA;IACrC,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAA;IACnC,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAA;CAC5C;AAED,wBAAgB,SAAS,IAAI,YAAY,CA4DxC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Path } from '@astrale-os/sdk/graph/path';
|
|
2
2
|
/**
|
|
3
3
|
* useSpaces (API §12.2) — the spaces list, the selected space, and a `switch`
|
|
4
4
|
* Action that repoints the `selected_space` edge. Reads the SAME per-Shell
|
|
@@ -77,6 +77,13 @@ function hasId(x) {
|
|
|
77
77
|
function refIdOf(x) {
|
|
78
78
|
if (hasId(x))
|
|
79
79
|
return x.id;
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if (typeof x === 'string' && !x.startsWith('@') && !x.startsWith('/'))
|
|
81
|
+
return x;
|
|
82
|
+
try {
|
|
83
|
+
const path = Path.from(x);
|
|
84
|
+
return path.ast.anchor.kind === 'id' && path.ast.steps.length === 0 ? path.ast.anchor.id : null;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
82
89
|
}
|
|
@@ -1,40 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { Identity } from '@astrale-os/kernel-client/auth';
|
|
2
|
+
import type { KernelClient } from '@astrale-os/shell';
|
|
3
3
|
import type { ReactElement, ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export type SessionView = BoundClientSessionView<FnMap>;
|
|
7
|
-
/** A whoami-shaped identity/graph node (kernel-client does not yet re-export `Node` — G8). */
|
|
8
|
-
export type NodeValue = SelfNode;
|
|
9
|
-
/** The root scope key — the memory's own default scope (`createMemory` default). */
|
|
10
|
-
export declare const ROOT_SCOPE = "default";
|
|
11
|
-
/**
|
|
12
|
-
* The principal a subtree acts as (API §4). `scope` is the memory isolation key
|
|
13
|
-
* (§5.4): the graph plane scopes its memory by `memory.forScope(scope)` so an
|
|
14
|
-
* <ActAs> subtree never shares cached results with another principal.
|
|
15
|
-
*/
|
|
4
|
+
export type NodeValue = Identity;
|
|
5
|
+
export type SessionView = KernelClient;
|
|
16
6
|
export interface IdentityBinding {
|
|
17
|
-
readonly kernel:
|
|
18
|
-
readonly self:
|
|
19
|
-
readonly scope: string;
|
|
7
|
+
readonly kernel: KernelClient;
|
|
8
|
+
readonly self: Identity;
|
|
20
9
|
}
|
|
21
10
|
export declare const IdentityContext: import("react").Context<IdentityBinding | null>;
|
|
22
|
-
/**
|
|
23
|
-
* The principal this subtree dispatches as. An <ActAs> value wins; otherwise the
|
|
24
|
-
* root binding off ShellContext. Throws outside a provider, or when the bound
|
|
25
|
-
* kernel resolved no identity (a bare prebuilt Shell with no auth surface).
|
|
26
|
-
*/
|
|
27
11
|
export declare function useIdentityBinding(): IdentityBinding;
|
|
28
12
|
export interface ActAsProps {
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
/**
|
|
14
|
+
* A separately authenticated Kernel capability. Raw credentials are deliberately not accepted;
|
|
15
|
+
* construct the delegated Client Session at the trust boundary that owns credential resolution.
|
|
16
|
+
*/
|
|
17
|
+
readonly client: KernelClient;
|
|
18
|
+
readonly fallback?: ReactNode;
|
|
19
|
+
readonly children: ReactNode;
|
|
32
20
|
}
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
* resolves whoami, and provides a fresh identity binding with a DISTINCT memory
|
|
36
|
-
* scope (`as:<id>`). Nestable — it rebinds from the current effective principal. A
|
|
37
|
-
* brief nested boot holds the subtree (renders null) until whoami resolves.
|
|
38
|
-
*/
|
|
39
|
-
export declare function ActAs({ credential, children }: ActAsProps): ReactElement | null;
|
|
21
|
+
/** Bind a subtree to an explicitly supplied authenticated Kernel capability. */
|
|
22
|
+
export declare function ActAs({ client, fallback, children }: ActAsProps): ReactElement | null;
|
|
40
23
|
//# sourceMappingURL=act-as.context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act-as.context.d.ts","sourceRoot":"","sources":["../../src/auth/act-as.context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"act-as.context.d.ts","sourceRoot":"","sources":["../../src/auth/act-as.context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMpD,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAA;AAChC,MAAM,MAAM,WAAW,GAAG,YAAY,CAAA;AAEtC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CACxB;AAED,eAAO,MAAM,eAAe,iDAA8C,CAAA;AAG1E,wBAAgB,kBAAkB,IAAI,eAAe,CAOpD;AAED,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAC7B;AAED,gFAAgF;AAChF,wBAAgB,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,UAAU,GAAG,YAAY,GAAG,IAAI,CA8BrF"}
|
|
@@ -1,84 +1,40 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* The acting-principal binding (API §4). `IdentityContext` seats the effective
|
|
4
|
-
* principal a subtree dispatches as — its bound kernel view + whoami + memory
|
|
5
|
-
* scope; `useIdentityBinding` resolves it (an `<ActAs>` override, else the root
|
|
6
|
-
* off ShellContext). `<ActAs>` rebinds a subtree to another principal with a
|
|
7
|
-
* DISTINCT memory scope so results never leak across principals (§5.4).
|
|
8
|
-
*/
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
9
2
|
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
|
10
3
|
import { ShellContext } from '../session/session.context.js';
|
|
11
|
-
/** The root scope key — the memory's own default scope (`createMemory` default). */
|
|
12
|
-
export const ROOT_SCOPE = 'default';
|
|
13
4
|
export const IdentityContext = createContext(null);
|
|
14
5
|
IdentityContext.displayName = 'AstraleIdentityContext';
|
|
15
|
-
/**
|
|
16
|
-
* The principal this subtree dispatches as. An <ActAs> value wins; otherwise the
|
|
17
|
-
* root binding off ShellContext. Throws outside a provider, or when the bound
|
|
18
|
-
* kernel resolved no identity (a bare prebuilt Shell with no auth surface).
|
|
19
|
-
*/
|
|
20
6
|
export function useIdentityBinding() {
|
|
21
7
|
const override = useContext(IdentityContext);
|
|
22
8
|
if (override !== null)
|
|
23
9
|
return override;
|
|
24
10
|
const runtime = useContext(ShellContext);
|
|
25
|
-
if (runtime === null)
|
|
11
|
+
if (runtime === null)
|
|
26
12
|
throw new Error('identity hooks must be used within a <ShellProvider>');
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'resolved nothing at boot');
|
|
31
|
-
}
|
|
32
|
-
// The root binding reads stable fields (self, shell.kernel), so a fresh object
|
|
33
|
-
// per render is inert — consumers key off `kernel`/`self`, both stable.
|
|
34
|
-
return { kernel: runtime.shell.kernel, self: runtime.self, scope: ROOT_SCOPE };
|
|
13
|
+
if (runtime.self === null)
|
|
14
|
+
throw new Error('the active Shell has no authenticated identity');
|
|
15
|
+
return { kernel: runtime.shell.kernel, self: runtime.self };
|
|
35
16
|
}
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* scope (`as:<id>`). Nestable — it rebinds from the current effective principal. A
|
|
40
|
-
* brief nested boot holds the subtree (renders null) until whoami resolves.
|
|
41
|
-
*/
|
|
42
|
-
export function ActAs({ credential, children }) {
|
|
43
|
-
const parent = useIdentityBinding();
|
|
44
|
-
// Key the rebind on a STABLE credential identity (like `configIdentity` does),
|
|
45
|
-
// so an inline object credential (`credential={{ … }}`) does not re-mint the
|
|
46
|
-
// session view — and re-run whoami, unmounting the subtree — every parent
|
|
47
|
-
// render. A thunk still keys by reference: pass a stable thunk to avoid churn.
|
|
48
|
-
const credKey = credentialIdentity(credential);
|
|
49
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
-
const kernel = useMemo(() => parent.kernel.as(credential), [parent.kernel, credKey]);
|
|
51
|
-
const [self, setSelf] = useState(null);
|
|
17
|
+
/** Bind a subtree to an explicitly supplied authenticated Kernel capability. */
|
|
18
|
+
export function ActAs({ client, fallback, children }) {
|
|
19
|
+
const [state, setState] = useState({ status: 'pending' });
|
|
52
20
|
useEffect(() => {
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
void
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
}, () => {
|
|
59
|
-
|
|
21
|
+
let active = true;
|
|
22
|
+
setState({ status: 'pending' });
|
|
23
|
+
void client.auth.whoami().then((self) => {
|
|
24
|
+
if (active)
|
|
25
|
+
setState({ status: 'ready', self });
|
|
26
|
+
}, (error) => {
|
|
27
|
+
if (active)
|
|
28
|
+
setState({ status: 'failed', error });
|
|
60
29
|
});
|
|
61
30
|
return () => {
|
|
62
|
-
|
|
31
|
+
active = false;
|
|
63
32
|
};
|
|
64
|
-
}, [
|
|
65
|
-
const value = useMemo(() => (
|
|
33
|
+
}, [client]);
|
|
34
|
+
const value = useMemo(() => (state.status === 'ready' ? { kernel: client, self: state.self } : null), [client, state]);
|
|
35
|
+
if (state.status === 'failed')
|
|
36
|
+
throw state.error;
|
|
66
37
|
if (value === null)
|
|
67
|
-
return null;
|
|
38
|
+
return fallback === undefined ? null : _jsx(_Fragment, { children: fallback });
|
|
68
39
|
return _jsx(IdentityContext.Provider, { value: value, children: children });
|
|
69
40
|
}
|
|
70
|
-
/**
|
|
71
|
-
* A stable identity for a credential: the thunk by reference, a string as itself,
|
|
72
|
-
* and an object by a serialized form — so an equal inline object does not churn
|
|
73
|
-
* the memo (worst case a serialize failure falls back to reference identity).
|
|
74
|
-
*/
|
|
75
|
-
function credentialIdentity(credential) {
|
|
76
|
-
if (typeof credential === 'function' || typeof credential === 'string')
|
|
77
|
-
return credential;
|
|
78
|
-
try {
|
|
79
|
-
return `cred:${JSON.stringify(credential)}`;
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
return credential;
|
|
83
|
-
}
|
|
84
|
-
}
|
package/dist/auth/auth.hook.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.hook.d.ts","sourceRoot":"","sources":["../../src/auth/auth.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"auth.hook.d.ts","sourceRoot":"","sources":["../../src/auth/auth.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAI7D,4EAA4E;AAC5E,wBAAgB,OAAO,IAAI,OAAO,CAEjC"}
|
package/dist/auth/auth.hook.js
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useAuth (API §4) — the imperative AuthApi of the effective principal
|
|
3
|
-
* (whoami/credential/mint/delegate/check/grant/revoke/bind/unbind). Grant and
|
|
4
|
-
* revoke additionally nudge the principal's useCan ledger on success, delivering
|
|
5
|
-
* the Tier-0 local re-check (SPEC §11.3). DEVIATION: API §4 describes a pure
|
|
6
|
-
* passthrough; the wrap is the only way to surface a local grant/revoke today,
|
|
7
|
-
* since permissions dispatch as identity methods rather than graph patches.
|
|
8
|
-
* Cross-client liveness still awaits the watch tiers (G7).
|
|
9
|
-
*/
|
|
10
|
-
import { useMemo } from 'react';
|
|
11
1
|
import { useIdentityBinding } from './act-as.context.js';
|
|
12
|
-
|
|
2
|
+
/** The exact Client Auth capability for the effective subtree principal. */
|
|
13
3
|
export function useAuth() {
|
|
14
|
-
|
|
15
|
-
return useMemo(() => withLedgerNudge(kernel), [kernel]);
|
|
16
|
-
}
|
|
17
|
-
/** Wrap grant/revoke so a successful local change re-checks the principal's cells. */
|
|
18
|
-
function withLedgerNudge(kernel) {
|
|
19
|
-
const auth = kernel.auth;
|
|
20
|
-
const ledger = ledgerFor(kernel);
|
|
21
|
-
const invalidate = () => ledger.invalidateAll();
|
|
22
|
-
const grant = ((arg) => Promise.resolve(auth.grant(arg)).then(invalidate));
|
|
23
|
-
const revoke = ((arg) => Promise.resolve(auth.revoke(arg)).then(invalidate));
|
|
24
|
-
return { ...auth, grant, revoke };
|
|
4
|
+
return useIdentityBinding().kernel.auth;
|
|
25
5
|
}
|
package/dist/auth/can.hook.d.ts
CHANGED
|
@@ -1,40 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { PathLike
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** Normalize a `useCan` subject to a dispatchable `Ref` plus a stable dedup key. */
|
|
7
|
-
export declare function toRef(on: NodeValue | PathLike): {
|
|
8
|
-
ref: Ref;
|
|
9
|
-
key: string;
|
|
1
|
+
import type { NodeId } from '@astrale-os/sdk/graph/node';
|
|
2
|
+
import type { PathLike } from '@astrale-os/sdk/graph/path';
|
|
3
|
+
import type { schema } from '@astrale-os/sdk/schema';
|
|
4
|
+
export type PolicyObject = NodeId | {
|
|
5
|
+
readonly id: NodeId;
|
|
10
6
|
};
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
value: boolean | undefined;
|
|
17
|
-
private inFlight;
|
|
18
|
-
private readonly listeners;
|
|
19
|
-
constructor(auth: AuthApi, perms: Perms, on: Ref);
|
|
20
|
-
subscribe: (onChange: () => void) => (() => void);
|
|
21
|
-
getSnapshot: () => boolean | undefined;
|
|
22
|
-
/** Run the check once when the value is unknown and nothing is in flight. */
|
|
23
|
-
ensure(): void;
|
|
24
|
-
/** Force a re-check (local grant/revoke on this principal). */
|
|
25
|
-
invalidate(): void;
|
|
26
|
-
private run;
|
|
27
|
-
}
|
|
28
|
-
/** Per-principal cell registry — dedup across the whole tree for one kernel handle. */
|
|
29
|
-
export declare class CheckLedger {
|
|
30
|
-
private readonly auth;
|
|
31
|
-
private readonly cells;
|
|
32
|
-
constructor(auth: AuthApi);
|
|
33
|
-
cell(key: string, perms: Perms, on: Ref): CheckCell;
|
|
34
|
-
/** Re-check every observed cell — conservative Tier-0 sweep after a local grant/revoke. */
|
|
35
|
-
invalidateAll(): void;
|
|
36
|
-
}
|
|
37
|
-
export declare function ledgerFor(kernel: SessionView): CheckLedger;
|
|
38
|
-
export declare function useCan(perms: Perms, on: NodeValue | PathLike | null | undefined): boolean | undefined;
|
|
39
|
-
export {};
|
|
7
|
+
/**
|
|
8
|
+
* Evaluate one declared Kernel policy for one exact graph object. This is a UI affordance; the
|
|
9
|
+
* invoked callable remains the authorization enforcement point.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useCan(policy: PathLike | schema.PolicyRef | null | undefined, object: PolicyObject | null | undefined): boolean | undefined;
|
|
40
12
|
//# sourceMappingURL=can.hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"can.hook.d.ts","sourceRoot":"","sources":["../../src/auth/can.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"can.hook.d.ts","sourceRoot":"","sources":["../../src/auth/can.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAOpD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3D;;;GAGG;AACH,wBAAgB,MAAM,CACpB,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC,SAAS,GAAG,IAAI,GAAG,SAAS,EACtD,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GACtC,OAAO,GAAG,SAAS,CA2BrB"}
|