@astrale-os/shell-react 0.2.8 → 0.2.10-beta.2

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.
Files changed (342) hide show
  1. package/dist/application/apps/app-host.d.ts +7 -15
  2. package/dist/application/apps/app-host.d.ts.map +1 -1
  3. package/dist/application/apps/app-host.js +3 -2
  4. package/dist/application/apps/apps.hook.d.ts +7 -4
  5. package/dist/application/apps/apps.hook.d.ts.map +1 -1
  6. package/dist/application/apps/apps.hook.js +10 -2
  7. package/dist/application/apps/domains.hook.d.ts +1 -1
  8. package/dist/application/apps/domains.hook.d.ts.map +1 -1
  9. package/dist/application/apps/domains.hook.js +1 -1
  10. package/dist/application/apps/open-app.hook.d.ts +2 -3
  11. package/dist/application/apps/open-app.hook.d.ts.map +1 -1
  12. package/dist/application/index.d.ts +2 -4
  13. package/dist/application/index.d.ts.map +1 -1
  14. package/dist/application/index.js +2 -3
  15. package/dist/application/spaces/space.hook.d.ts +2 -2
  16. package/dist/application/spaces/space.hook.d.ts.map +1 -1
  17. package/dist/application/spaces/space.hook.js +2 -2
  18. package/dist/application/spaces/spaces.hook.d.ts +2 -3
  19. package/dist/application/spaces/spaces.hook.d.ts.map +1 -1
  20. package/dist/application/spaces/spaces.hook.js +10 -3
  21. package/dist/auth/act-as.context.d.ts +15 -32
  22. package/dist/auth/act-as.context.d.ts.map +1 -1
  23. package/dist/auth/act-as.context.js +22 -66
  24. package/dist/auth/auth.hook.d.ts +1 -0
  25. package/dist/auth/auth.hook.d.ts.map +1 -1
  26. package/dist/auth/auth.hook.js +2 -22
  27. package/dist/auth/can.hook.d.ts +10 -38
  28. package/dist/auth/can.hook.d.ts.map +1 -1
  29. package/dist/auth/can.hook.js +35 -110
  30. package/dist/auth/index.d.ts +1 -0
  31. package/dist/auth/index.d.ts.map +1 -1
  32. package/dist/auth/self.hook.d.ts +2 -2
  33. package/dist/auth/self.hook.d.ts.map +1 -1
  34. package/dist/auth/self.hook.js +0 -7
  35. package/dist/auth/session-kernel.d.ts +2 -3
  36. package/dist/auth/session-kernel.d.ts.map +1 -1
  37. package/dist/auth/session-kernel.js +4 -13
  38. package/dist/components/boundaries.d.ts +47 -0
  39. package/dist/components/boundaries.d.ts.map +1 -0
  40. package/dist/components/boundaries.js +55 -0
  41. package/dist/components/can.d.ts +11 -0
  42. package/dist/components/can.d.ts.map +1 -0
  43. package/dist/components/can.js +5 -0
  44. package/dist/components/index.d.ts +7 -0
  45. package/dist/components/index.d.ts.map +1 -0
  46. package/dist/components/index.js +4 -0
  47. package/dist/components/mount-domain-frontend.d.ts +22 -0
  48. package/dist/components/mount-domain-frontend.d.ts.map +1 -0
  49. package/dist/components/mount-domain-frontend.js +85 -0
  50. package/dist/components/view-app.d.ts +16 -0
  51. package/dist/components/view-app.d.ts.map +1 -0
  52. package/dist/components/view-app.js +16 -0
  53. package/dist/graph/call/call.hook.d.ts +8 -18
  54. package/dist/graph/call/call.hook.d.ts.map +1 -1
  55. package/dist/graph/call/call.hook.js +7 -13
  56. package/dist/graph/call/stream.hook.d.ts +12 -20
  57. package/dist/graph/call/stream.hook.d.ts.map +1 -1
  58. package/dist/graph/call/stream.hook.js +55 -111
  59. package/dist/graph/graph.context.d.ts +4 -3
  60. package/dist/graph/graph.context.d.ts.map +1 -1
  61. package/dist/graph/graph.context.js +2 -8
  62. package/dist/graph/guards.error.d.ts +7 -8
  63. package/dist/graph/guards.error.d.ts.map +1 -1
  64. package/dist/graph/guards.error.js +11 -7
  65. package/dist/graph/index.d.ts +8 -16
  66. package/dist/graph/index.d.ts.map +1 -1
  67. package/dist/graph/index.js +3 -7
  68. package/dist/graph/memory/read/envelope.d.ts +22 -54
  69. package/dist/graph/memory/read/envelope.d.ts.map +1 -1
  70. package/dist/graph/memory/read/envelope.js +26 -20
  71. package/dist/graph/memory/read/idle.d.ts +1 -15
  72. package/dist/graph/memory/read/idle.d.ts.map +1 -1
  73. package/dist/graph/memory/read/idle.js +4 -13
  74. package/dist/graph/query-definition.hook.d.ts +11 -0
  75. package/dist/graph/query-definition.hook.d.ts.map +1 -0
  76. package/dist/graph/query-definition.hook.js +205 -0
  77. package/dist/graph/resource.d.ts +34 -0
  78. package/dist/graph/resource.d.ts.map +1 -0
  79. package/dist/graph/resource.js +244 -0
  80. package/dist/graph/store.d.ts +25 -0
  81. package/dist/graph/store.d.ts.map +1 -0
  82. package/dist/graph/store.js +69 -0
  83. package/dist/host/actions.hook.d.ts +34 -0
  84. package/dist/host/actions.hook.d.ts.map +1 -0
  85. package/dist/host/actions.hook.js +125 -0
  86. package/dist/host/components.d.ts +15 -0
  87. package/dist/host/components.d.ts.map +1 -0
  88. package/dist/host/components.js +14 -0
  89. package/dist/host/index.d.ts +5 -0
  90. package/dist/host/index.d.ts.map +1 -0
  91. package/dist/host/index.js +3 -0
  92. package/dist/index.d.ts +26 -37
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +20 -31
  95. package/dist/intents/envelope.d.ts +7 -19
  96. package/dist/intents/envelope.d.ts.map +1 -1
  97. package/dist/intents/envelope.js +2 -3
  98. package/dist/intents/send-intent.hook.d.ts +5 -7
  99. package/dist/intents/send-intent.hook.d.ts.map +1 -1
  100. package/dist/intents/send-intent.hook.js +17 -75
  101. package/dist/navigation/adapters/adapter.d.ts +5 -0
  102. package/dist/navigation/adapters/adapter.d.ts.map +1 -1
  103. package/dist/navigation/adapters/memory.adapter.d.ts.map +1 -1
  104. package/dist/navigation/adapters/memory.adapter.js +4 -0
  105. package/dist/navigation/adapters/url.adapter.d.ts.map +1 -1
  106. package/dist/navigation/adapters/url.adapter.js +57 -10
  107. package/dist/navigation/codec.d.ts +60 -0
  108. package/dist/navigation/codec.d.ts.map +1 -0
  109. package/dist/navigation/codec.js +121 -0
  110. package/dist/navigation/history.d.ts +11 -9
  111. package/dist/navigation/history.d.ts.map +1 -1
  112. package/dist/navigation/history.js +6 -8
  113. package/dist/navigation/hooks/ancestors.hook.d.ts +5 -7
  114. package/dist/navigation/hooks/ancestors.hook.d.ts.map +1 -1
  115. package/dist/navigation/hooks/ancestors.hook.js +7 -51
  116. package/dist/navigation/hooks/location.hook.d.ts.map +1 -1
  117. package/dist/navigation/hooks/location.hook.js +4 -6
  118. package/dist/navigation/hooks/scope.hook.d.ts.map +1 -1
  119. package/dist/navigation/hooks/scope.hook.js +4 -6
  120. package/dist/navigation/index.d.ts +4 -2
  121. package/dist/navigation/index.d.ts.map +1 -1
  122. package/dist/navigation/index.js +2 -1
  123. package/dist/navigation/link.d.ts +12 -0
  124. package/dist/navigation/link.d.ts.map +1 -1
  125. package/dist/navigation/link.js +13 -2
  126. package/dist/navigation/location.d.ts +13 -40
  127. package/dist/navigation/location.d.ts.map +1 -1
  128. package/dist/navigation/location.js +14 -76
  129. package/dist/navigation/scope.context.d.ts +17 -26
  130. package/dist/navigation/scope.context.d.ts.map +1 -1
  131. package/dist/navigation/scope.context.js +140 -108
  132. package/dist/navigation/snapshot.d.ts +14 -19
  133. package/dist/navigation/snapshot.d.ts.map +1 -1
  134. package/dist/navigation/snapshot.js +48 -44
  135. package/dist/schema/action.hook.d.ts +44 -0
  136. package/dist/schema/action.hook.d.ts.map +1 -0
  137. package/dist/schema/action.hook.js +72 -0
  138. package/dist/schema/domain.hook.d.ts +12 -7
  139. package/dist/schema/domain.hook.d.ts.map +1 -1
  140. package/dist/schema/domain.hook.js +101 -4
  141. package/dist/schema/index.d.ts +9 -8
  142. package/dist/schema/index.d.ts.map +1 -1
  143. package/dist/schema/index.js +5 -7
  144. package/dist/schema/kernel.hook.d.ts +4 -9
  145. package/dist/schema/kernel.hook.d.ts.map +1 -1
  146. package/dist/schema/kernel.hook.js +4 -6
  147. package/dist/schema/mutation.hook.d.ts +9 -0
  148. package/dist/schema/mutation.hook.d.ts.map +1 -0
  149. package/dist/schema/mutation.hook.js +41 -0
  150. package/dist/schema/object.hook.d.ts +16 -0
  151. package/dist/schema/object.hook.d.ts.map +1 -0
  152. package/dist/schema/object.hook.js +46 -0
  153. package/dist/schema/relation.hook.d.ts +46 -0
  154. package/dist/schema/relation.hook.d.ts.map +1 -0
  155. package/dist/schema/relation.hook.js +136 -0
  156. package/dist/selection/live.d.ts +9 -17
  157. package/dist/selection/live.d.ts.map +1 -1
  158. package/dist/selection/live.js +65 -112
  159. package/dist/selection/scope.context.js +5 -4
  160. package/dist/session/boot/boot.d.ts +1 -13
  161. package/dist/session/boot/boot.d.ts.map +1 -1
  162. package/dist/session/boot/boot.js +9 -27
  163. package/dist/session/index.d.ts +1 -0
  164. package/dist/session/index.d.ts.map +1 -1
  165. package/dist/session/kernel-instance.hook.d.ts +1 -4
  166. package/dist/session/kernel-instance.hook.d.ts.map +1 -1
  167. package/dist/session/kernel-instance.hook.js +1 -5
  168. package/dist/session/provider.d.ts +9 -23
  169. package/dist/session/provider.d.ts.map +1 -1
  170. package/dist/session/provider.js +29 -75
  171. package/dist/session/session.context.d.ts +5 -0
  172. package/dist/session/session.context.d.ts.map +1 -1
  173. package/dist/window/adopt.d.ts +0 -1
  174. package/dist/window/adopt.d.ts.map +1 -1
  175. package/dist/window/hooks/target-node.hook.d.ts +10 -6
  176. package/dist/window/hooks/target-node.hook.d.ts.map +1 -1
  177. package/dist/window/hooks/target-node.hook.js +14 -72
  178. package/dist/window/hooks/views-for.hook.d.ts +4 -3
  179. package/dist/window/hooks/views-for.hook.d.ts.map +1 -1
  180. package/dist/window/hooks/views-for.hook.js +6 -22
  181. package/dist/window/hooks/windows.hook.d.ts.map +1 -1
  182. package/dist/window/hooks/windows.hook.js +3 -4
  183. package/dist/window/host.d.ts +11 -11
  184. package/dist/window/host.d.ts.map +1 -1
  185. package/dist/window/host.js +38 -54
  186. package/dist/window/hub.d.ts +2 -0
  187. package/dist/window/hub.d.ts.map +1 -1
  188. package/dist/window/hub.js +33 -0
  189. package/dist/window/index.d.ts +3 -3
  190. package/dist/window/index.d.ts.map +1 -1
  191. package/dist/window/index.js +2 -2
  192. package/dist/window/lifecycle/mount.d.ts +5 -44
  193. package/dist/window/lifecycle/mount.d.ts.map +1 -1
  194. package/dist/window/lifecycle/mount.js +14 -120
  195. package/dist/window/lifecycle/states.d.ts +0 -5
  196. package/dist/window/lifecycle/states.d.ts.map +1 -1
  197. package/dist/window/stage.d.ts.map +1 -1
  198. package/dist/window/stage.js +1 -0
  199. package/package.json +9 -8
  200. package/src/application/apps/app-host.tsx +17 -18
  201. package/src/application/apps/apps.hook.ts +13 -6
  202. package/src/application/apps/domains.hook.ts +1 -1
  203. package/src/application/apps/open-app.hook.ts +3 -4
  204. package/src/application/index.ts +4 -6
  205. package/src/application/spaces/space.hook.ts +5 -6
  206. package/src/application/spaces/spaces.hook.ts +14 -9
  207. package/src/auth/act-as.context.tsx +37 -91
  208. package/src/auth/auth.hook.ts +2 -30
  209. package/src/auth/can.hook.ts +44 -135
  210. package/src/auth/index.ts +1 -0
  211. package/src/auth/self.hook.ts +2 -9
  212. package/src/auth/session-kernel.ts +6 -16
  213. package/src/components/boundaries.tsx +113 -0
  214. package/src/components/can.tsx +16 -0
  215. package/src/components/index.ts +14 -0
  216. package/src/components/mount-domain-frontend.tsx +158 -0
  217. package/src/components/view-app.tsx +49 -0
  218. package/src/graph/call/call.hook.ts +22 -27
  219. package/src/graph/call/stream.hook.ts +66 -143
  220. package/src/graph/graph.context.ts +6 -11
  221. package/src/graph/guards.error.ts +17 -55
  222. package/src/graph/index.ts +23 -17
  223. package/src/graph/memory/read/envelope.ts +40 -65
  224. package/src/graph/memory/read/idle.ts +5 -18
  225. package/src/graph/query-definition.hook.ts +270 -0
  226. package/src/graph/resource.ts +358 -0
  227. package/src/graph/store.ts +97 -0
  228. package/src/host/actions.hook.ts +165 -0
  229. package/src/host/components.tsx +29 -0
  230. package/src/host/index.ts +17 -0
  231. package/src/index.ts +137 -123
  232. package/src/intents/envelope.ts +7 -23
  233. package/src/intents/send-intent.hook.ts +24 -79
  234. package/src/navigation/adapters/adapter.ts +3 -0
  235. package/src/navigation/adapters/memory.adapter.ts +4 -0
  236. package/src/navigation/adapters/url.adapter.ts +48 -8
  237. package/src/navigation/codec.ts +190 -0
  238. package/src/navigation/history.ts +20 -11
  239. package/src/navigation/hooks/ancestors.hook.ts +10 -60
  240. package/src/navigation/hooks/location.hook.ts +4 -6
  241. package/src/navigation/hooks/scope.hook.ts +4 -6
  242. package/src/navigation/index.ts +18 -2
  243. package/src/navigation/link.tsx +27 -2
  244. package/src/navigation/location.ts +26 -93
  245. package/src/navigation/scope.context.tsx +151 -136
  246. package/src/navigation/snapshot.ts +69 -50
  247. package/src/schema/action.hook.ts +146 -0
  248. package/src/schema/domain.hook.ts +127 -11
  249. package/src/schema/index.ts +9 -30
  250. package/src/schema/kernel.hook.ts +6 -13
  251. package/src/schema/mutation.hook.ts +63 -0
  252. package/src/schema/object.hook.ts +85 -0
  253. package/src/schema/relation.hook.ts +253 -0
  254. package/src/selection/live.ts +75 -125
  255. package/src/selection/scope.context.tsx +4 -4
  256. package/src/session/boot/boot.ts +8 -33
  257. package/src/session/index.ts +1 -0
  258. package/src/session/kernel-instance.hook.ts +2 -11
  259. package/src/session/provider.tsx +34 -103
  260. package/src/session/session.context.ts +6 -0
  261. package/src/window/adopt.ts +0 -1
  262. package/src/window/hooks/target-node.hook.ts +20 -85
  263. package/src/window/hooks/views-for.hook.ts +12 -25
  264. package/src/window/hooks/windows.hook.ts +3 -4
  265. package/src/window/host.tsx +51 -68
  266. package/src/window/hub.ts +33 -0
  267. package/src/window/index.ts +4 -4
  268. package/src/window/lifecycle/mount.ts +15 -160
  269. package/src/window/lifecycle/states.ts +1 -5
  270. package/src/window/stage.tsx +1 -0
  271. package/dist/application/roles.hook.d.ts +0 -7
  272. package/dist/application/roles.hook.d.ts.map +0 -1
  273. package/dist/application/roles.hook.js +0 -23
  274. package/dist/graph/memory/base.d.ts +0 -21
  275. package/dist/graph/memory/base.d.ts.map +0 -1
  276. package/dist/graph/memory/base.js +0 -33
  277. package/dist/graph/memory/read/read.d.ts +0 -9
  278. package/dist/graph/memory/read/read.d.ts.map +0 -1
  279. package/dist/graph/memory/read/read.js +0 -87
  280. package/dist/graph/memory/scope.d.ts +0 -7
  281. package/dist/graph/memory/scope.d.ts.map +0 -1
  282. package/dist/graph/memory/scope.js +0 -25
  283. package/dist/graph/mutate/move.hook.d.ts +0 -7
  284. package/dist/graph/mutate/move.hook.d.ts.map +0 -1
  285. package/dist/graph/mutate/move.hook.js +0 -49
  286. package/dist/graph/mutate/mutate.hook.d.ts +0 -17
  287. package/dist/graph/mutate/mutate.hook.d.ts.map +0 -1
  288. package/dist/graph/mutate/mutate.hook.js +0 -45
  289. package/dist/graph/query/children.hook.d.ts +0 -29
  290. package/dist/graph/query/children.hook.d.ts.map +0 -1
  291. package/dist/graph/query/children.hook.js +0 -64
  292. package/dist/graph/query/graph.hook.d.ts +0 -9
  293. package/dist/graph/query/graph.hook.d.ts.map +0 -1
  294. package/dist/graph/query/graph.hook.js +0 -5
  295. package/dist/graph/query/neighbors.hook.d.ts +0 -7
  296. package/dist/graph/query/neighbors.hook.d.ts.map +0 -1
  297. package/dist/graph/query/neighbors.hook.js +0 -104
  298. package/dist/graph/query/node.hook.d.ts +0 -14
  299. package/dist/graph/query/node.hook.d.ts.map +0 -1
  300. package/dist/graph/query/node.hook.js +0 -43
  301. package/dist/graph/query/query.hook.d.ts +0 -14
  302. package/dist/graph/query/query.hook.d.ts.map +0 -1
  303. package/dist/graph/query/query.hook.js +0 -23
  304. package/dist/schema/bind-read.d.ts +0 -37
  305. package/dist/schema/bind-read.d.ts.map +0 -1
  306. package/dist/schema/bind-read.js +0 -205
  307. package/dist/schema/binding.d.ts +0 -21
  308. package/dist/schema/binding.d.ts.map +0 -1
  309. package/dist/schema/binding.js +0 -99
  310. package/dist/schema/function.hook.d.ts +0 -9
  311. package/dist/schema/function.hook.d.ts.map +0 -1
  312. package/dist/schema/function.hook.js +0 -40
  313. package/dist/schema/method.hook.d.ts +0 -14
  314. package/dist/schema/method.hook.d.ts.map +0 -1
  315. package/dist/schema/method.hook.js +0 -49
  316. package/dist/schema/tag.d.ts +0 -11
  317. package/dist/schema/tag.d.ts.map +0 -1
  318. package/dist/schema/tag.js +0 -11
  319. package/dist/schema/types.d.ts +0 -73
  320. package/dist/schema/types.d.ts.map +0 -1
  321. package/dist/schema/types.js +0 -1
  322. package/dist/schema/write.d.ts +0 -16
  323. package/dist/schema/write.d.ts.map +0 -1
  324. package/dist/schema/write.js +0 -56
  325. package/src/application/roles.hook.ts +0 -41
  326. package/src/graph/memory/base.ts +0 -50
  327. package/src/graph/memory/read/read.ts +0 -103
  328. package/src/graph/memory/scope.ts +0 -29
  329. package/src/graph/mutate/move.hook.ts +0 -70
  330. package/src/graph/mutate/mutate.hook.ts +0 -69
  331. package/src/graph/query/children.hook.ts +0 -136
  332. package/src/graph/query/graph.hook.ts +0 -13
  333. package/src/graph/query/neighbors.hook.ts +0 -159
  334. package/src/graph/query/node.hook.ts +0 -83
  335. package/src/graph/query/query.hook.ts +0 -42
  336. package/src/schema/bind-read.ts +0 -319
  337. package/src/schema/binding.ts +0 -146
  338. package/src/schema/function.hook.ts +0 -68
  339. package/src/schema/method.hook.ts +0 -103
  340. package/src/schema/tag.ts +0 -19
  341. package/src/schema/types.ts +0 -150
  342. package/src/schema/write.ts +0 -96
@@ -1,28 +1,20 @@
1
- import type { FnMap, StreamFns } from '@astrale-os/kernel-client';
2
- export interface StreamOptions<T> {
3
- /** Notified per chunk as it arrives (in addition to `chunks` accumulation). */
4
- onChunk?(chunk: T): void;
1
+ import type { Call } from '@astrale-os/kernel-client';
2
+ import type { SessionRequestOptions } from '@astrale-os/kernel-client/session';
3
+ import type { Value } from '@astrale-os/sdk/value';
4
+ import type { KernelClient } from '@astrale-os/shell';
5
+ export type KernelStream = Awaited<ReturnType<KernelClient['stream']>>;
6
+ export type StreamItem = Value;
7
+ export type CallAuthor<A extends unknown[]> = Call | ((...args: A) => Call);
8
+ export interface StreamOptions<T = StreamItem> extends SessionRequestOptions {
9
+ readonly onChunk?: (chunk: T) => void;
5
10
  }
6
- export interface StreamHandle<T> {
7
- /** Begin a run: resets chunks, then resolves when the stream ends / rejects on failure. */
8
- start(params: unknown): Promise<void>;
9
- /** Chunks accumulated in the current run; reset on the next `start`. */
11
+ export interface StreamHandle<A extends unknown[] = unknown[], T = StreamItem> {
12
+ start(...args: A): Promise<void>;
10
13
  readonly chunks: readonly T[];
11
- /** The most recent chunk, or null before the first. */
12
14
  readonly last: T | null;
13
- /** A run is in flight. */
14
15
  readonly streaming: boolean;
15
- /** Last run failure; retained until the next `start`. */
16
16
  readonly error: unknown;
17
- /** Close the stream (returns the iterator); a later `start` begins fresh. */
18
17
  cancel(): void;
19
18
  }
20
- /**
21
- * Streaming domain-function dispatch. `start(params)` opens a run over
22
- * `kernel.stream`; chunks accumulate on `chunks`; `cancel()` closes the iterator
23
- * and a later `start` begins fresh. A superseding `start` (or unmount) closes the
24
- * prior run and discards its late chunks/errors — only the current run drives
25
- * state. Never live; the handle keeps one identity for the hook's lifetime.
26
- */
27
- export declare function useStream<K extends StreamFns<FnMap>>(method: K | null, opts?: StreamOptions<FnMap[K]['result']>): StreamHandle<FnMap[K]['result']>;
19
+ export declare function useStream<A extends unknown[] = []>(author: CallAuthor<A> | null, options?: StreamOptions): StreamHandle<A, StreamItem>;
28
20
  //# sourceMappingURL=stream.hook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.hook.d.ts","sourceRoot":"","sources":["../../../src/graph/call/stream.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAYjE,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,+EAA+E;IAC/E,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;CACzB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,2FAA2F;IAC3F,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,wEAAw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qB;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CACtC;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE,CAAC,GAAG,UAAU;IAC3E,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAA;IAC7B,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,MAAM,IAAI,IAAI,CAAA;CACf;AAmCD,wBAAgB,SAAS,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE,EAChD,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,EAC5B,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAAC,CAAC,EAAE,UAAU,CAAC,CA4D7B"}
@@ -1,18 +1,6 @@
1
- /**
2
- * useStream (API §7) — streaming domain-function dispatch over `kernel.stream`,
3
- * an AsyncIterable driven by an explicit start/cancel handle. A superseding
4
- * `start` (or unmount) closes the prior run and discards its late chunks/errors;
5
- * never live. Dispatch is a graph operation (rule 2).
6
- */
7
1
  import { useCallback, useEffect, useReducer, useRef } from 'react';
8
2
  import { useSessionKernel } from '../../auth/session-kernel.js';
9
- const IDLE_STREAM = {
10
- chunks: [],
11
- last: null,
12
- streaming: false,
13
- error: undefined,
14
- };
15
- function streamReducer(state, event) {
3
+ function reducer(state, event) {
16
4
  switch (event.type) {
17
5
  case 'start':
18
6
  return { chunks: [], last: null, streaming: true, error: undefined };
@@ -24,114 +12,70 @@ function streamReducer(state, event) {
24
12
  error: undefined,
25
13
  };
26
14
  case 'end':
15
+ case 'cancel':
27
16
  return { ...state, streaming: false };
28
17
  case 'error':
29
- // Chunks accumulated before the failure are preserved.
30
18
  return { ...state, streaming: false, error: event.error };
31
- case 'cancel':
32
- return { ...state, streaming: false };
33
19
  }
34
20
  }
35
- /**
36
- * Streaming domain-function dispatch. `start(params)` opens a run over
37
- * `kernel.stream`; chunks accumulate on `chunks`; `cancel()` closes the iterator
38
- * and a later `start` begins fresh. A superseding `start` (or unmount) closes the
39
- * prior run and discards its late chunks/errors — only the current run drives
40
- * state. Never live; the handle keeps one identity for the hook's lifetime.
41
- */
42
- export function useStream(method, opts) {
21
+ export function useStream(author, options) {
43
22
  const kernel = useSessionKernel();
44
- // Latest-closure refs so the stable start/cancel dispatch the current inputs.
45
23
  const kernelRef = useRef(kernel);
46
24
  kernelRef.current = kernel;
47
- const methodRef = useRef(method);
48
- methodRef.current = method;
49
- const optsRef = useRef(opts);
50
- optsRef.current = opts;
51
- const [snapshot, dispatch] = useReducer(streamReducer, IDLE_STREAM);
52
- // `runId` supersession token; only the run whose id is still current drives state.
53
- const runIdRef = useRef(0);
54
- const currentRef = useRef(null);
55
- const alive = useRef(true);
56
- const stop = useCallback(() => {
57
- const run = currentRef.current;
58
- if (run !== null) {
59
- run.controller.abort();
60
- void run.iterator?.return?.(undefined);
61
- currentRef.current = null;
62
- }
63
- }, []);
64
- useEffect(() => {
65
- alive.current = true;
66
- return () => {
67
- alive.current = false;
68
- stop();
69
- };
70
- }, [stop]);
25
+ const authorRef = useRef(author);
26
+ authorRef.current = author;
27
+ const optionsRef = useRef(options);
28
+ optionsRef.current = options;
29
+ const [snapshot, dispatch] = useReducer(reducer, {
30
+ chunks: [],
31
+ last: null,
32
+ streaming: false,
33
+ error: undefined,
34
+ });
35
+ const runId = useRef(0);
36
+ const controller = useRef(null);
71
37
  const cancel = useCallback(() => {
72
- runIdRef.current += 1;
73
- stop();
74
- if (alive.current)
75
- dispatch({ type: 'cancel' });
76
- }, [stop]);
77
- const start = useCallback((params) => {
78
- const method_ = methodRef.current;
79
- if (method_ === null) {
80
- return Promise.reject(new Error('useStream: method is null (idle handle started)'));
81
- }
82
- runIdRef.current += 1;
83
- const runId = runIdRef.current;
84
- stop(); // close any prior run before opening the new one
38
+ runId.current += 1;
39
+ controller.current?.abort();
40
+ controller.current = null;
41
+ dispatch({ type: 'cancel' });
42
+ }, []);
43
+ useEffect(() => cancel, [cancel]);
44
+ const start = useCallback(async (...args) => {
45
+ const current = authorRef.current;
46
+ if (current === null)
47
+ throw new Error('useStream: idle handle started');
48
+ cancel();
49
+ const id = ++runId.current;
50
+ const abort = new AbortController();
51
+ controller.current = abort;
85
52
  dispatch({ type: 'start' });
86
- const controller = new AbortController();
87
- const run = { controller, iterator: null };
88
- currentRef.current = run;
89
- const current = () => runIdRef.current === runId;
90
- return (async () => {
91
- try {
92
- const iterable = await kernelRef.current.stream(method_, params, {
93
- signal: controller.signal,
94
- });
95
- if (!current())
53
+ const call = typeof current === 'function' ? current(...args) : current;
54
+ try {
55
+ const { onChunk: _onChunk, ...requestOptions } = optionsRef.current ?? {};
56
+ const stream = await kernelRef.current.stream(call, {
57
+ ...requestOptions,
58
+ signal: abort.signal,
59
+ });
60
+ for await (const chunk of stream) {
61
+ if (id !== runId.current)
96
62
  return;
97
- const iterator = iterable[Symbol.asyncIterator]();
98
- run.iterator = iterator;
99
- for (;;) {
100
- const next = await iterator.next();
101
- if (!current())
102
- return;
103
- if (next.done === true)
104
- break;
105
- if (alive.current)
106
- dispatch({ type: 'chunk', value: next.value });
107
- optsRef.current?.onChunk?.(next.value);
108
- }
109
- if (current()) {
110
- currentRef.current = null;
111
- if (alive.current)
112
- dispatch({ type: 'end' });
113
- }
114
- }
115
- catch (error) {
116
- if (!current())
117
- return; // a superseded/cancelled run's failure is discarded
118
- currentRef.current = null;
119
- if (alive.current)
120
- dispatch({ type: 'error', error });
121
- throw error;
63
+ dispatch({ type: 'chunk', value: chunk });
64
+ optionsRef.current?.onChunk?.(chunk);
122
65
  }
123
- })();
124
- }, [stop]);
125
- // One render-stable handle: built once (start/cancel are stable), then its
126
- // snapshot fields re-stamped each render so reads stay current across chunks.
127
- const handleRef = useRef(null);
128
- if (handleRef.current === null) {
129
- handleRef.current = { start, cancel };
130
- }
131
- const handle = handleRef.current;
132
- handle.chunks = snapshot.chunks;
133
- handle.last = snapshot.last;
134
- handle.streaming = snapshot.streaming;
135
- handle.error = snapshot.error;
136
- return handle;
66
+ if (id === runId.current)
67
+ dispatch({ type: 'end' });
68
+ }
69
+ catch (error) {
70
+ if (id !== runId.current)
71
+ return;
72
+ dispatch({ type: 'error', error });
73
+ throw error;
74
+ }
75
+ finally {
76
+ if (id === runId.current)
77
+ controller.current = null;
78
+ }
79
+ }, [cancel]);
80
+ return { start, cancel, ...snapshot };
137
81
  }
@@ -1,4 +1,5 @@
1
- import type { GraphMemory } from '@astrale-os/kernel-client/store';
2
- export type { GraphMemory };
3
- export declare const GraphContext: import("react").Context<GraphMemory | null>;
1
+ import type { GraphStore } from '@astrale-os/kernel-client/store';
2
+ /** Optional exact Client GraphStore supplied by an injected Shell adapter. */
3
+ export declare const GraphContext: import("react").Context<GraphStore | null>;
4
+ export type { GraphStore };
4
5
  //# sourceMappingURL=graph.context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph.context.d.ts","sourceRoot":"","sources":["../../src/graph/graph.context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAWlE,YAAY,EAAE,WAAW,EAAE,CAAA;AAC3B,eAAO,MAAM,YAAY,6CAA0C,CAAA"}
1
+ {"version":3,"file":"graph.context.d.ts","sourceRoot":"","sources":["../../src/graph/graph.context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAIjE,8EAA8E;AAC9E,eAAO,MAAM,YAAY,4CAAyC,CAAA;AAGlE,YAAY,EAAE,UAAU,EAAE,CAAA"}
@@ -1,10 +1,4 @@
1
- /**
2
- * GraphContext (ex MemoryContext) — the root of the graph plane. Seats the base
3
- * (default-scope) memory the provider builds; the SAME handle the graph/schema/
4
- * nav hooks read through `memory/scope.ts`, and selection's liveness source.
5
- * Under `<ActAs>` the read hooks re-scope via `forScope`; selection reads the
6
- * base scope here.
7
- */
8
1
  import { createContext } from 'react';
2
+ /** Optional exact Client GraphStore supplied by an injected Shell adapter. */
9
3
  export const GraphContext = createContext(null);
10
- GraphContext.displayName = 'AstraleGraphContext';
4
+ GraphContext.displayName = 'AstraleGraphStoreContext';
@@ -1,9 +1,8 @@
1
- /**
2
- * Error taxonomy (API §1.4) — re-exported from kernel-client so shell-react
3
- * consumers narrow dispatch failures through the single import surface. The
4
- * dispatched kernel call stays the source of truth; these guards drive UI
5
- * affordances (retry, request-access, toast). Names match kernel-client exactly.
6
- */
7
- export { AuthBatchError, AuthenticationError, ClientSessionError, ConnectionError, DisconnectedError, InvalidTransportError, InvariantViolationError, KernelError, NodeUnavailableError, NotFoundError, PermissionDeniedError, TimeoutError, UnsupportedTransportError, ValidationError, WebOSError, classifyKernelError, isAuthBatchError, isAuthenticationError, isClientSessionError, isDelegationMintError, isDelegationPolicyError, isDelegationRefusedError, isHopLimitExceededError, isIdentityError, isInternalKernelError, isInvalidRequestError, isInvalidTransportError, isInvariantViolationError, isKernelError, isNodeUnavailableError, isNotFoundError, isParseError, isPermissionDeniedError, isPersistenceLoadFailedError, isPoolClosedError, isRedirectPolicyError, isRedirectRefusedError, isRegistryWriteFailedError, isSchemaOwnershipConflictError, isTransportError, isUnsupportedTransportError, isValidationError, isWebOSError, } from '@astrale-os/kernel-client';
8
- export type { AuthReason, ClientErrorDetails, IdentityError, KernelErrorKind, TransportError, } from '@astrale-os/kernel-client';
1
+ export { ClientError, ProtocolError, ResponseError, StaleRouteError, TransportError, } from '@astrale-os/kernel-client';
2
+ export { NodeUnavailableError } from '@astrale-os/kernel-client/graph';
3
+ export { UnsupportedFeatureError } from './memory/read/envelope.js';
4
+ import { ClientError } from '@astrale-os/kernel-client';
5
+ import { NodeUnavailableError } from '@astrale-os/kernel-client/graph';
6
+ export declare function isClientError(error: unknown): error is ClientError;
7
+ export declare function isNodeUnavailableError(error: unknown): error is NodeUnavailableError;
9
8
  //# sourceMappingURL=guards.error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"guards.error.d.ts","sourceRoot":"","sources":["../../src/graph/guards.error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,yBAAyB,EACzB,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EACzB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,uBAAuB,EACvB,4BAA4B,EAC5B,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,8BAA8B,EAC9B,gBAAgB,EAChB,2BAA2B,EAC3B,iBAAiB,EACjB,YAAY,GACb,MAAM,2BAA2B,CAAA;AAClC,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,2BAA2B,CAAA"}
1
+ {"version":3,"file":"guards.error.d.ts","sourceRoot":"","sources":["../../src/graph/guards.error.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAEtE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAEpF"}
@@ -1,7 +1,11 @@
1
- /**
2
- * Error taxonomy (API §1.4) — re-exported from kernel-client so shell-react
3
- * consumers narrow dispatch failures through the single import surface. The
4
- * dispatched kernel call stays the source of truth; these guards drive UI
5
- * affordances (retry, request-access, toast). Names match kernel-client exactly.
6
- */
7
- export { AuthBatchError, AuthenticationError, ClientSessionError, ConnectionError, DisconnectedError, InvalidTransportError, InvariantViolationError, KernelError, NodeUnavailableError, NotFoundError, PermissionDeniedError, TimeoutError, UnsupportedTransportError, ValidationError, WebOSError, classifyKernelError, isAuthBatchError, isAuthenticationError, isClientSessionError, isDelegationMintError, isDelegationPolicyError, isDelegationRefusedError, isHopLimitExceededError, isIdentityError, isInternalKernelError, isInvalidRequestError, isInvalidTransportError, isInvariantViolationError, isKernelError, isNodeUnavailableError, isNotFoundError, isParseError, isPermissionDeniedError, isPersistenceLoadFailedError, isPoolClosedError, isRedirectPolicyError, isRedirectRefusedError, isRegistryWriteFailedError, isSchemaOwnershipConflictError, isTransportError, isUnsupportedTransportError, isValidationError, isWebOSError, } from '@astrale-os/kernel-client';
1
+ export { ClientError, ProtocolError, ResponseError, StaleRouteError, TransportError, } from '@astrale-os/kernel-client';
2
+ export { NodeUnavailableError } from '@astrale-os/kernel-client/graph';
3
+ export { UnsupportedFeatureError } from './memory/read/envelope.js';
4
+ import { ClientError } from '@astrale-os/kernel-client';
5
+ import { NodeUnavailableError } from '@astrale-os/kernel-client/graph';
6
+ export function isClientError(error) {
7
+ return error instanceof ClientError;
8
+ }
9
+ export function isNodeUnavailableError(error) {
10
+ return error instanceof NodeUnavailableError;
11
+ }
@@ -1,20 +1,12 @@
1
- export { useNode } from './query/node.hook.js';
2
- export type { NodeResult } from './query/node.hook.js';
3
- export { useChildren } from './query/children.hook.js';
4
- export type { ChildrenOptions, ChildrenResult } from './query/children.hook.js';
5
- export { useQuery } from './query/query.hook.js';
6
- export type { QueryResult } from './query/query.hook.js';
7
- export { useGraph } from './query/graph.hook.js';
8
- export { useMutate } from './mutate/mutate.hook.js';
9
- export type { UseMutateOptions } from './mutate/mutate.hook.js';
10
- export { useMove } from './mutate/move.hook.js';
11
- export type { MoveAction } from './mutate/move.hook.js';
1
+ export { useGraphStore } from './store.js';
2
+ export { useQuery } from './query-definition.hook.js';
3
+ export type { QueryResourceOptions } from './query-definition.hook.js';
4
+ export type { GraphResource, GraphResourceState } from './resource.js';
12
5
  export { useCall } from './call/call.hook.js';
13
- export type { CallOptions } from './call/call.hook.js';
6
+ export type { CallOptions, CallResult } from './call/call.hook.js';
14
7
  export { useStream } from './call/stream.hook.js';
15
- export type { StreamHandle, StreamOptions } from './call/stream.hook.js';
8
+ export type { CallAuthor, KernelStream, StreamHandle, StreamItem, StreamOptions, } from './call/stream.hook.js';
16
9
  export type { Action } from './action.js';
17
- export type { ReadState, ReadOptions, Windowed, Node } from './memory/read/envelope.js';
18
- export type { GraphMemory } from './graph.context.js';
19
- export type { ShapeInput } from '@astrale-os/kernel-client/store';
10
+ export type { GraphStore } from './graph.context.js';
11
+ export { ClientError, NodeUnavailableError, ProtocolError, ResponseError, StaleRouteError, TransportError, isClientError, isNodeUnavailableError, } from './guards.error.js';
20
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAA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BAAqB,CAAA;AAC7C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,aAAa,EACb,sBAAsB,GACvB,MAAM,mBAAmB,CAAA"}
@@ -1,9 +1,5 @@
1
- // graph — the graph plane (API §5 + §7). Merged read hooks, writes, dispatch.
2
- export { useNode } from './query/node.hook.js';
3
- export { useChildren } from './query/children.hook.js';
4
- export { useQuery } from './query/query.hook.js';
5
- export { useGraph } from './query/graph.hook.js';
6
- export { useMutate } from './mutate/mutate.hook.js';
7
- export { useMove } from './mutate/move.hook.js';
1
+ export { useGraphStore } from './store.js';
2
+ export { useQuery } from './query-definition.hook.js';
8
3
  export { useCall } from './call/call.hook.js';
9
4
  export { useStream } from './call/stream.hook.js';
5
+ export { ClientError, NodeUnavailableError, ProtocolError, ResponseError, StaleRouteError, TransportError, isClientError, isNodeUnavailableError, } from './guards.error.js';
@@ -1,71 +1,39 @@
1
- /**
2
- * The read envelope (API §1.1, §1.5) — the shape every read hook's result
3
- * extends (`ReadState` + `Windowed`), the `ReadOptions` accepted by every read,
4
- * and the assembly of the unified `RawRead` projection over a memory shape
5
- * (empty/idle/keep-previous builders). Dependency-light so every context can
6
- * consume it without a cycle.
7
- */
8
- import type { LiveResult } from '@astrale-os/kernel-client/store';
9
- /** Base of every read hook's result — stale-while-revalidate + liveness + seq. */
1
+ import type { Node as KernelNode } from '@astrale-os/sdk/graph/node';
2
+ /** Common result state for Shell React reads. */
10
3
  export interface ReadState {
11
- /** A (re)validation is in flight; data shown alongside is last-good. */
4
+ /** A request is in flight. Last-good data may still be present. */
12
5
  readonly pending: boolean;
13
- /** Last refresh failure; last-good data is retained. Cleared on next success. */
6
+ /** Last request failure. Cleared when the next request begins. */
14
7
  readonly error: unknown;
15
- /** A watch subscription is active for this shape (Tier ≥ 1), or Tier-0 only. */
8
+ /** True only when an upstream subscription is active. */
16
9
  readonly live: boolean;
17
- /** Journal position this result reflects (FRONTEND spec §6.1). 0 until known. */
10
+ /** Reserved journal position. Direct Graph reads report zero. */
18
11
  readonly seq: number;
19
- /** Manual revalidate. Rarely needed; kept for tooling and non-live reads. */
20
12
  refetch(): Promise<void>;
21
13
  }
22
- /** Windowed reads add a cursor-fold `more`. */
23
14
  export interface Windowed {
24
15
  readonly more: {
25
16
  readonly has: boolean;
26
- load(): Promise<void>;
27
17
  readonly pending: boolean;
18
+ load(): Promise<void>;
28
19
  };
29
20
  }
30
- /** Options accepted by every read hook (§1.5). */
21
+ /** Options shared by point, Query, and neighbor reads. */
31
22
  export interface ReadOptions {
32
- /** default true; false = one-shot snapshot. */
33
- live?: boolean;
34
- /** default true; false → pending-without-data on cold. */
35
- suspend?: boolean;
36
- /** default false; show previous shape's data while a new one confirms. */
37
- keepPrevious?: boolean;
38
- /** Visibility permission on the underlying AST — a kernel permission bitmask. */
39
- with?: number;
23
+ readonly signal?: AbortSignal;
24
+ readonly timeoutMs?: number;
25
+ /** Retain the previous successful value while the next request is pending. */
26
+ readonly keepPrevious?: boolean;
40
27
  }
41
- /** A graph node — derived from the memory result so no direct kernel-core import is needed. */
42
- export type Node = NonNullable<LiveResult['node']>;
43
- /** Read options plus the windowing lever `useChildren`/`useQuery` add. */
44
- export type CoreReadOptions = ReadOptions & {
45
- window?: 'append' | 'paged';
46
- };
47
- /**
48
- * The unified read projection: every data arm the memory materializes, over
49
- * the shell-react read envelope (`ReadState` + `Windowed`). Each hook narrows
50
- * to the arms it exposes. The store's `LiveResult` is a structural superset, so
51
- * the warm path returns it directly (stable ref).
52
- */
53
- export interface RawRead extends ReadState, Windowed {
54
- readonly nodes: readonly Node[];
55
- readonly roots: readonly Node[];
56
- readonly first: Node | null;
57
- readonly children: readonly Node[];
58
- gathered(alias: string): {
59
- readonly nodes: readonly Node[];
60
- readonly first: Node | null;
61
- };
28
+ export type Node = KernelNode;
29
+ export declare const EMPTY_NODES: readonly Node[];
30
+ export declare const NO_MORE: Windowed['more'];
31
+ /** Stable failure for a retained hook whose required Kernel capability does not exist. */
32
+ export declare class UnsupportedFeatureError extends Error {
33
+ readonly code: 'SHELL_REACT_UNSUPPORTED';
34
+ readonly feature: string;
35
+ constructor(feature: string);
62
36
  }
63
- export declare const EMPTY: readonly Node[];
64
- export declare function emptyRead(pending: boolean): RawRead;
65
- /** The result for a null/undefined subject (§1.3) — settled, empty, no I/O. */
66
- export declare const IDLE_READ: RawRead;
67
- /** Cold shape with `suspend:false` (§1.4) — empty data, pending true. */
68
- export declare const EMPTY_PENDING: RawRead;
69
- /** Previous shape's data while a new one confirms (§1.5 `keepPrevious`). */
70
- export declare function withPending(prev: LiveResult): RawRead;
37
+ export declare function idleReadState(): ReadState;
38
+ export declare function unsupportedReadState(feature: string): ReadState;
71
39
  //# sourceMappingURL=envelope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../../../src/graph/memory/read/envelope.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAIjE,kFAAkF;AAClF,MAAM,WAAW,SAAS;IACxB,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,gFAAgF;IAChF,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,iFAAiF;IACjF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;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,eAAO,MAAM,WAAW,EAAE,SAAS,IAAI,EAAsB,CAAA;AAE7D,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,MAAM,CAInC,CAAA;AAEF,0FAA0F;AAC1F,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAG,yBAAyB,CAAS;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAExB,YAAY,OAAO,EAAE,MAAM,EAI1B;CACF;AAED,wBAAgB,aAAa,IAAI,SAAS,CAQzC;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAS/D"}
@@ -1,29 +1,35 @@
1
- export const EMPTY = [];
2
- const idleGathered = () => ({
3
- nodes: EMPTY,
4
- first: null,
1
+ export const EMPTY_NODES = Object.freeze([]);
2
+ export const NO_MORE = Object.freeze({
3
+ has: false,
4
+ pending: false,
5
+ load: () => Promise.resolve(),
5
6
  });
6
- const idleMore = { has: false, pending: false, load: () => Promise.resolve() };
7
- export function emptyRead(pending) {
7
+ /** Stable failure for a retained hook whose required Kernel capability does not exist. */
8
+ export class UnsupportedFeatureError extends Error {
9
+ code = 'SHELL_REACT_UNSUPPORTED';
10
+ feature;
11
+ constructor(feature) {
12
+ super(`${feature} is not supported by the current Kernel Graph contract.`);
13
+ this.name = 'UnsupportedFeatureError';
14
+ this.feature = feature;
15
+ }
16
+ }
17
+ export function idleReadState() {
8
18
  return {
9
- nodes: EMPTY,
10
- roots: EMPTY,
11
- first: null,
12
- children: EMPTY,
13
- gathered: idleGathered,
14
- pending,
19
+ pending: false,
15
20
  error: undefined,
16
21
  live: false,
17
22
  seq: 0,
18
- more: idleMore,
19
23
  refetch: () => Promise.resolve(),
20
24
  };
21
25
  }
22
- /** The result for a null/undefined subject (§1.3) — settled, empty, no I/O. */
23
- export const IDLE_READ = emptyRead(false);
24
- /** Cold shape with `suspend:false` (§1.4) — empty data, pending true. */
25
- export const EMPTY_PENDING = emptyRead(true);
26
- /** Previous shape's data while a new one confirms (§1.5 `keepPrevious`). */
27
- export function withPending(prev) {
28
- return { ...prev, pending: true };
26
+ export function unsupportedReadState(feature) {
27
+ const error = new UnsupportedFeatureError(feature);
28
+ return {
29
+ pending: false,
30
+ error,
31
+ live: false,
32
+ seq: 0,
33
+ refetch: () => Promise.reject(error),
34
+ };
29
35
  }
@@ -1,18 +1,4 @@
1
- /**
2
- * The idle-input rule (API §1.3). A read hook's `null | undefined` subject is
3
- * inert: `isIdleInput` is the one gate every read branches on, and
4
- * `idleReadState` is the settled, not-live, seq-0 envelope it returns.
5
- */
6
1
  import type { ReadState } from './envelope.js';
7
- /**
8
- * The chaining rule: every read hook accepts `null | undefined` for its subject
9
- * and returns an *idle* result (empty data, no I/O). This predicate is the one
10
- * gate — read hooks branch on it before touching the memory.
11
- */
12
- export declare function isIdleInput(subject: unknown): subject is null | undefined;
13
- /**
14
- * The idle `ReadState` a read hook returns for a `null`/`undefined` subject:
15
- * settled, not live, seq 0, `refetch` a resolved no-op.
16
- */
2
+ export declare function isIdleInput(value: unknown): value is null | undefined;
17
3
  export declare function idleReadState(): ReadState;
18
4
  //# sourceMappingURL=idle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"idle.d.ts","sourceRoot":"","sources":["../../../../src/graph/memory/read/idle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,IAAI,GAAG,SAAS,CAEzE;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,SAAS,CAEzC"}
1
+ {"version":3,"file":"idle.d.ts","sourceRoot":"","sources":["../../../../src/graph/memory/read/idle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI9C,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,SAAS,CAErE;AAED,wBAAgB,aAAa,IAAI,SAAS,CAEzC"}
@@ -1,16 +1,7 @@
1
- /**
2
- * The chaining rule: every read hook accepts `null | undefined` for its subject
3
- * and returns an *idle* result (empty data, no I/O). This predicate is the one
4
- * gate — read hooks branch on it before touching the memory.
5
- */
6
- export function isIdleInput(subject) {
7
- return subject === null || subject === undefined;
1
+ import { idleReadState as idle } from './envelope.js';
2
+ export function isIdleInput(value) {
3
+ return value === null || value === undefined;
8
4
  }
9
- /**
10
- * The idle `ReadState` a read hook returns for a `null`/`undefined` subject:
11
- * settled, not live, seq 0, `refetch` a resolved no-op.
12
- */
13
5
  export function idleReadState() {
14
- return { pending: false, error: undefined, live: false, seq: 0, refetch: idleRefetch };
6
+ return idle();
15
7
  }
16
- const idleRefetch = () => Promise.resolve();
@@ -0,0 +1,11 @@
1
+ import type { QueryDefinition } from '@astrale-os/sdk/query';
2
+ import type { QueryAST } from '@astrale-os/sdk/query';
3
+ import type { GraphResource } from './resource.js';
4
+ export interface QueryResourceOptions {
5
+ readonly keepPrevious?: boolean;
6
+ readonly refreshInterval?: number;
7
+ readonly refreshWhen?: 'always' | 'visible';
8
+ }
9
+ /** Execute one named SDK Query definition exclusively through the current GraphStore. */
10
+ export declare function useQuery<Input, Output, Query extends QueryAST>(definition: QueryDefinition<Input, Output, Query> | null, input: Input, options?: QueryResourceOptions): GraphResource<Output>;
11
+ //# sourceMappingURL=query-definition.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-definition.hook.d.ts","sourceRoot":"","sources":["../../src/graph/query-definition.hook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAMrD,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,eAAe,CAAA;AAMtE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;IAC/B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;CAC5C;AAwID,yFAAyF;AACzF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAS,QAAQ,EAC5D,UAAU,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,EACxD,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,oBAAyB,GACjC,aAAa,CAAC,MAAM,CAAC,CAyDvB"}