@astrale-os/shell-react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/LICENSE +202 -0
  2. package/dist/application/apps/app-host.d.ts +31 -0
  3. package/dist/application/apps/app-host.d.ts.map +1 -0
  4. package/dist/application/apps/app-host.js +59 -0
  5. package/dist/application/apps/app-logo.d.ts +19 -0
  6. package/dist/application/apps/app-logo.d.ts.map +1 -0
  7. package/dist/application/apps/app-logo.js +31 -0
  8. package/dist/application/apps/apps.hook.d.ts +12 -0
  9. package/dist/application/apps/apps.hook.d.ts.map +1 -0
  10. package/dist/application/apps/apps.hook.js +51 -0
  11. package/dist/application/apps/open-app.hook.d.ts +10 -0
  12. package/dist/application/apps/open-app.hook.d.ts.map +1 -0
  13. package/dist/application/apps/open-app.hook.js +7 -0
  14. package/dist/application/index.d.ts +18 -0
  15. package/dist/application/index.d.ts.map +1 -0
  16. package/dist/application/index.js +12 -0
  17. package/dist/application/roles.hook.d.ts +7 -0
  18. package/dist/application/roles.hook.d.ts.map +1 -0
  19. package/dist/application/roles.hook.js +23 -0
  20. package/dist/application/spaces/current-space.hook.d.ts +7 -0
  21. package/dist/application/spaces/current-space.hook.d.ts.map +1 -0
  22. package/dist/application/spaces/current-space.hook.js +27 -0
  23. package/dist/application/spaces/current-space.store.d.ts +32 -0
  24. package/dist/application/spaces/current-space.store.d.ts.map +1 -0
  25. package/dist/application/spaces/current-space.store.js +79 -0
  26. package/dist/application/spaces/space.hook.d.ts +5 -0
  27. package/dist/application/spaces/space.hook.d.ts.map +1 -0
  28. package/dist/application/spaces/space.hook.js +25 -0
  29. package/dist/application/spaces/spaces.hook.d.ts +14 -0
  30. package/dist/application/spaces/spaces.hook.d.ts.map +1 -0
  31. package/dist/application/spaces/spaces.hook.js +82 -0
  32. package/dist/application/user/user.hook.d.ts +10 -0
  33. package/dist/application/user/user.hook.d.ts.map +1 -0
  34. package/dist/application/user/user.hook.js +19 -0
  35. package/dist/application/user/user.store.d.ts +35 -0
  36. package/dist/application/user/user.store.d.ts.map +1 -0
  37. package/dist/application/user/user.store.js +51 -0
  38. package/dist/auth/act-as.context.d.ts +40 -0
  39. package/dist/auth/act-as.context.d.ts.map +1 -0
  40. package/dist/auth/act-as.context.js +84 -0
  41. package/dist/auth/auth.hook.d.ts +3 -0
  42. package/dist/auth/auth.hook.d.ts.map +1 -0
  43. package/dist/auth/auth.hook.js +25 -0
  44. package/dist/auth/can.hook.d.ts +40 -0
  45. package/dist/auth/can.hook.d.ts.map +1 -0
  46. package/dist/auth/can.hook.js +119 -0
  47. package/dist/auth/index.d.ts +6 -0
  48. package/dist/auth/index.d.ts.map +1 -0
  49. package/dist/auth/index.js +5 -0
  50. package/dist/auth/self.hook.d.ts +3 -0
  51. package/dist/auth/self.hook.d.ts.map +1 -0
  52. package/dist/auth/self.hook.js +11 -0
  53. package/dist/auth/session-kernel.d.ts +4 -0
  54. package/dist/auth/session-kernel.d.ts.map +1 -0
  55. package/dist/auth/session-kernel.js +21 -0
  56. package/dist/graph/action.d.ts +22 -0
  57. package/dist/graph/action.d.ts.map +1 -0
  58. package/dist/graph/action.js +85 -0
  59. package/dist/graph/async.d.ts +11 -0
  60. package/dist/graph/async.d.ts.map +1 -0
  61. package/dist/graph/async.js +60 -0
  62. package/dist/graph/call/call.hook.d.ts +21 -0
  63. package/dist/graph/call/call.hook.d.ts.map +1 -0
  64. package/dist/graph/call/call.hook.js +23 -0
  65. package/dist/graph/call/stream.hook.d.ts +28 -0
  66. package/dist/graph/call/stream.hook.d.ts.map +1 -0
  67. package/dist/graph/call/stream.hook.js +137 -0
  68. package/dist/graph/graph.context.d.ts +4 -0
  69. package/dist/graph/graph.context.d.ts.map +1 -0
  70. package/dist/graph/graph.context.js +10 -0
  71. package/dist/graph/guards.error.d.ts +9 -0
  72. package/dist/graph/guards.error.d.ts.map +1 -0
  73. package/dist/graph/guards.error.js +7 -0
  74. package/dist/graph/index.d.ts +20 -0
  75. package/dist/graph/index.d.ts.map +1 -0
  76. package/dist/graph/index.js +9 -0
  77. package/dist/graph/memory/base.d.ts +21 -0
  78. package/dist/graph/memory/base.d.ts.map +1 -0
  79. package/dist/graph/memory/base.js +33 -0
  80. package/dist/graph/memory/read/envelope.d.ts +71 -0
  81. package/dist/graph/memory/read/envelope.d.ts.map +1 -0
  82. package/dist/graph/memory/read/envelope.js +29 -0
  83. package/dist/graph/memory/read/idle.d.ts +18 -0
  84. package/dist/graph/memory/read/idle.d.ts.map +1 -0
  85. package/dist/graph/memory/read/idle.js +16 -0
  86. package/dist/graph/memory/read/read.d.ts +9 -0
  87. package/dist/graph/memory/read/read.d.ts.map +1 -0
  88. package/dist/graph/memory/read/read.js +87 -0
  89. package/dist/graph/memory/scope.d.ts +7 -0
  90. package/dist/graph/memory/scope.d.ts.map +1 -0
  91. package/dist/graph/memory/scope.js +25 -0
  92. package/dist/graph/mutate/move.hook.d.ts +7 -0
  93. package/dist/graph/mutate/move.hook.d.ts.map +1 -0
  94. package/dist/graph/mutate/move.hook.js +49 -0
  95. package/dist/graph/mutate/mutate.hook.d.ts +17 -0
  96. package/dist/graph/mutate/mutate.hook.d.ts.map +1 -0
  97. package/dist/graph/mutate/mutate.hook.js +45 -0
  98. package/dist/graph/query/children.hook.d.ts +29 -0
  99. package/dist/graph/query/children.hook.d.ts.map +1 -0
  100. package/dist/graph/query/children.hook.js +64 -0
  101. package/dist/graph/query/graph.hook.d.ts +9 -0
  102. package/dist/graph/query/graph.hook.d.ts.map +1 -0
  103. package/dist/graph/query/graph.hook.js +5 -0
  104. package/dist/graph/query/neighbors.hook.d.ts +7 -0
  105. package/dist/graph/query/neighbors.hook.d.ts.map +1 -0
  106. package/dist/graph/query/neighbors.hook.js +79 -0
  107. package/dist/graph/query/node.hook.d.ts +14 -0
  108. package/dist/graph/query/node.hook.d.ts.map +1 -0
  109. package/dist/graph/query/node.hook.js +43 -0
  110. package/dist/graph/query/query.hook.d.ts +14 -0
  111. package/dist/graph/query/query.hook.d.ts.map +1 -0
  112. package/dist/graph/query/query.hook.js +23 -0
  113. package/dist/index.d.ts +43 -0
  114. package/dist/index.d.ts.map +1 -0
  115. package/dist/index.js +34 -0
  116. package/dist/intents/envelope.d.ts +33 -0
  117. package/dist/intents/envelope.d.ts.map +1 -0
  118. package/dist/intents/envelope.js +19 -0
  119. package/dist/intents/index.d.ts +6 -0
  120. package/dist/intents/index.d.ts.map +1 -0
  121. package/dist/intents/index.js +3 -0
  122. package/dist/intents/listen-intent.hook.d.ts +16 -0
  123. package/dist/intents/listen-intent.hook.d.ts.map +1 -0
  124. package/dist/intents/listen-intent.hook.js +75 -0
  125. package/dist/intents/reply.d.ts +9 -0
  126. package/dist/intents/reply.d.ts.map +1 -0
  127. package/dist/intents/reply.js +14 -0
  128. package/dist/intents/send-intent.hook.d.ts +12 -0
  129. package/dist/intents/send-intent.hook.d.ts.map +1 -0
  130. package/dist/intents/send-intent.hook.js +86 -0
  131. package/dist/navigation/adapters/adapter.d.ts +15 -0
  132. package/dist/navigation/adapters/adapter.d.ts.map +1 -0
  133. package/dist/navigation/adapters/adapter.js +1 -0
  134. package/dist/navigation/adapters/memory.adapter.d.ts +9 -0
  135. package/dist/navigation/adapters/memory.adapter.d.ts.map +1 -0
  136. package/dist/navigation/adapters/memory.adapter.js +15 -0
  137. package/dist/navigation/adapters/url.adapter.d.ts +6 -0
  138. package/dist/navigation/adapters/url.adapter.d.ts.map +1 -0
  139. package/dist/navigation/adapters/url.adapter.js +59 -0
  140. package/dist/navigation/history.d.ts +63 -0
  141. package/dist/navigation/history.d.ts.map +1 -0
  142. package/dist/navigation/history.js +144 -0
  143. package/dist/navigation/hooks/ancestors.hook.d.ts +13 -0
  144. package/dist/navigation/hooks/ancestors.hook.d.ts.map +1 -0
  145. package/dist/navigation/hooks/ancestors.hook.js +56 -0
  146. package/dist/navigation/hooks/location.hook.d.ts +4 -0
  147. package/dist/navigation/hooks/location.hook.d.ts.map +1 -0
  148. package/dist/navigation/hooks/location.hook.js +17 -0
  149. package/dist/navigation/hooks/navigate.hook.d.ts +12 -0
  150. package/dist/navigation/hooks/navigate.hook.d.ts.map +1 -0
  151. package/dist/navigation/hooks/navigate.hook.js +33 -0
  152. package/dist/navigation/hooks/scope.hook.d.ts +12 -0
  153. package/dist/navigation/hooks/scope.hook.d.ts.map +1 -0
  154. package/dist/navigation/hooks/scope.hook.js +21 -0
  155. package/dist/navigation/index.d.ts +16 -0
  156. package/dist/navigation/index.d.ts.map +1 -0
  157. package/dist/navigation/index.js +10 -0
  158. package/dist/navigation/link.d.ts +11 -0
  159. package/dist/navigation/link.d.ts.map +1 -0
  160. package/dist/navigation/link.js +62 -0
  161. package/dist/navigation/location.d.ts +48 -0
  162. package/dist/navigation/location.d.ts.map +1 -0
  163. package/dist/navigation/location.js +88 -0
  164. package/dist/navigation/scope.context.d.ts +64 -0
  165. package/dist/navigation/scope.context.d.ts.map +1 -0
  166. package/dist/navigation/scope.context.js +178 -0
  167. package/dist/navigation/snapshot.d.ts +22 -0
  168. package/dist/navigation/snapshot.d.ts.map +1 -0
  169. package/dist/navigation/snapshot.js +65 -0
  170. package/dist/schema/bind-read.d.ts +37 -0
  171. package/dist/schema/bind-read.d.ts.map +1 -0
  172. package/dist/schema/bind-read.js +205 -0
  173. package/dist/schema/binding.d.ts +21 -0
  174. package/dist/schema/binding.d.ts.map +1 -0
  175. package/dist/schema/binding.js +55 -0
  176. package/dist/schema/domain.hook.d.ts +10 -0
  177. package/dist/schema/domain.hook.d.ts.map +1 -0
  178. package/dist/schema/domain.hook.js +7 -0
  179. package/dist/schema/function.hook.d.ts +9 -0
  180. package/dist/schema/function.hook.d.ts.map +1 -0
  181. package/dist/schema/function.hook.js +40 -0
  182. package/dist/schema/index.d.ts +10 -0
  183. package/dist/schema/index.d.ts.map +1 -0
  184. package/dist/schema/index.js +8 -0
  185. package/dist/schema/kernel.hook.d.ts +10 -0
  186. package/dist/schema/kernel.hook.d.ts.map +1 -0
  187. package/dist/schema/kernel.hook.js +8 -0
  188. package/dist/schema/method.hook.d.ts +14 -0
  189. package/dist/schema/method.hook.d.ts.map +1 -0
  190. package/dist/schema/method.hook.js +49 -0
  191. package/dist/schema/tag.d.ts +11 -0
  192. package/dist/schema/tag.d.ts.map +1 -0
  193. package/dist/schema/tag.js +11 -0
  194. package/dist/schema/types.d.ts +73 -0
  195. package/dist/schema/types.d.ts.map +1 -0
  196. package/dist/schema/types.js +1 -0
  197. package/dist/schema/write.d.ts +15 -0
  198. package/dist/schema/write.d.ts.map +1 -0
  199. package/dist/schema/write.js +45 -0
  200. package/dist/selection/index.d.ts +4 -0
  201. package/dist/selection/index.d.ts.map +1 -0
  202. package/dist/selection/index.js +4 -0
  203. package/dist/selection/live.d.ts +21 -0
  204. package/dist/selection/live.d.ts.map +1 -0
  205. package/dist/selection/live.js +116 -0
  206. package/dist/selection/scope.context.d.ts +26 -0
  207. package/dist/selection/scope.context.d.ts.map +1 -0
  208. package/dist/selection/scope.context.js +100 -0
  209. package/dist/selection/selection.hook.d.ts +4 -0
  210. package/dist/selection/selection.hook.d.ts.map +1 -0
  211. package/dist/selection/selection.hook.js +14 -0
  212. package/dist/session/boot/boot.d.ts +19 -0
  213. package/dist/session/boot/boot.d.ts.map +1 -0
  214. package/dist/session/boot/boot.js +45 -0
  215. package/dist/session/boot/ownership.d.ts +18 -0
  216. package/dist/session/boot/ownership.d.ts.map +1 -0
  217. package/dist/session/boot/ownership.js +39 -0
  218. package/dist/session/boot/status.d.ts +24 -0
  219. package/dist/session/boot/status.d.ts.map +1 -0
  220. package/dist/session/boot/status.js +11 -0
  221. package/dist/session/connection/connection.hook.d.ts +3 -0
  222. package/dist/session/connection/connection.hook.d.ts.map +1 -0
  223. package/dist/session/connection/connection.hook.js +12 -0
  224. package/dist/session/connection/connection.store.d.ts +24 -0
  225. package/dist/session/connection/connection.store.d.ts.map +1 -0
  226. package/dist/session/connection/connection.store.js +31 -0
  227. package/dist/session/index.d.ts +8 -0
  228. package/dist/session/index.d.ts.map +1 -0
  229. package/dist/session/index.js +6 -0
  230. package/dist/session/kernel-client.hook.d.ts +9 -0
  231. package/dist/session/kernel-client.hook.d.ts.map +1 -0
  232. package/dist/session/kernel-client.hook.js +5 -0
  233. package/dist/session/kernel-instance.hook.d.ts +9 -0
  234. package/dist/session/kernel-instance.hook.d.ts.map +1 -0
  235. package/dist/session/kernel-instance.hook.js +10 -0
  236. package/dist/session/provider.d.ts +31 -0
  237. package/dist/session/provider.d.ts.map +1 -0
  238. package/dist/session/provider.js +165 -0
  239. package/dist/session/session.context.d.ts +18 -0
  240. package/dist/session/session.context.d.ts.map +1 -0
  241. package/dist/session/session.context.js +8 -0
  242. package/dist/session/shell.hook.d.ts +4 -0
  243. package/dist/session/shell.hook.d.ts.map +1 -0
  244. package/dist/session/shell.hook.js +15 -0
  245. package/dist/window/adopt.d.ts +27 -0
  246. package/dist/window/adopt.d.ts.map +1 -0
  247. package/dist/window/adopt.js +27 -0
  248. package/dist/window/hooks/close-guard.hook.d.ts +6 -0
  249. package/dist/window/hooks/close-guard.hook.d.ts.map +1 -0
  250. package/dist/window/hooks/close-guard.hook.js +90 -0
  251. package/dist/window/hooks/target-node.hook.d.ts +7 -0
  252. package/dist/window/hooks/target-node.hook.d.ts.map +1 -0
  253. package/dist/window/hooks/target-node.hook.js +77 -0
  254. package/dist/window/hooks/views-for.hook.d.ts +8 -0
  255. package/dist/window/hooks/views-for.hook.d.ts.map +1 -0
  256. package/dist/window/hooks/views-for.hook.js +51 -0
  257. package/dist/window/hooks/window.hook.d.ts +4 -0
  258. package/dist/window/hooks/window.hook.d.ts.map +1 -0
  259. package/dist/window/hooks/window.hook.js +14 -0
  260. package/dist/window/hooks/windows.hook.d.ts +15 -0
  261. package/dist/window/hooks/windows.hook.d.ts.map +1 -0
  262. package/dist/window/hooks/windows.hook.js +25 -0
  263. package/dist/window/host.d.ts +31 -0
  264. package/dist/window/host.d.ts.map +1 -0
  265. package/dist/window/host.js +270 -0
  266. package/dist/window/hub.d.ts +41 -0
  267. package/dist/window/hub.d.ts.map +1 -0
  268. package/dist/window/hub.js +100 -0
  269. package/dist/window/index.d.ts +15 -0
  270. package/dist/window/index.d.ts.map +1 -0
  271. package/dist/window/index.js +10 -0
  272. package/dist/window/lifecycle/mount.d.ts +47 -0
  273. package/dist/window/lifecycle/mount.d.ts.map +1 -0
  274. package/dist/window/lifecycle/mount.js +92 -0
  275. package/dist/window/lifecycle/states.d.ts +33 -0
  276. package/dist/window/lifecycle/states.d.ts.map +1 -0
  277. package/dist/window/lifecycle/states.js +7 -0
  278. package/dist/window/placement.d.ts +33 -0
  279. package/dist/window/placement.d.ts.map +1 -0
  280. package/dist/window/placement.js +57 -0
  281. package/dist/window/stage.d.ts +3 -0
  282. package/dist/window/stage.d.ts.map +1 -0
  283. package/dist/window/stage.js +41 -0
  284. package/package.json +59 -0
  285. package/src/application/apps/app-host.tsx +113 -0
  286. package/src/application/apps/app-logo.tsx +56 -0
  287. package/src/application/apps/apps.hook.ts +81 -0
  288. package/src/application/apps/open-app.hook.ts +18 -0
  289. package/src/application/index.ts +22 -0
  290. package/src/application/roles.hook.ts +41 -0
  291. package/src/application/spaces/current-space.hook.ts +43 -0
  292. package/src/application/spaces/current-space.store.ts +110 -0
  293. package/src/application/spaces/space.hook.ts +41 -0
  294. package/src/application/spaces/spaces.hook.ts +113 -0
  295. package/src/application/user/user.hook.ts +27 -0
  296. package/src/application/user/user.store.ts +85 -0
  297. package/src/auth/act-as.context.tsx +124 -0
  298. package/src/auth/auth.hook.ts +36 -0
  299. package/src/auth/can.hook.ts +149 -0
  300. package/src/auth/index.ts +6 -0
  301. package/src/auth/self.hook.ts +14 -0
  302. package/src/auth/session-kernel.ts +24 -0
  303. package/src/graph/action.ts +127 -0
  304. package/src/graph/async.ts +87 -0
  305. package/src/graph/call/call.hook.ts +42 -0
  306. package/src/graph/call/stream.hook.ts +200 -0
  307. package/src/graph/graph.context.ts +14 -0
  308. package/src/graph/guards.error.ts +58 -0
  309. package/src/graph/index.ts +20 -0
  310. package/src/graph/memory/base.ts +50 -0
  311. package/src/graph/memory/read/envelope.ts +98 -0
  312. package/src/graph/memory/read/idle.ts +24 -0
  313. package/src/graph/memory/read/read.ts +103 -0
  314. package/src/graph/memory/scope.ts +29 -0
  315. package/src/graph/mutate/move.hook.ts +70 -0
  316. package/src/graph/mutate/mutate.hook.ts +69 -0
  317. package/src/graph/query/children.hook.ts +136 -0
  318. package/src/graph/query/graph.hook.ts +13 -0
  319. package/src/graph/query/neighbors.hook.ts +124 -0
  320. package/src/graph/query/node.hook.ts +83 -0
  321. package/src/graph/query/query.hook.ts +42 -0
  322. package/src/index.ts +202 -0
  323. package/src/intents/envelope.ts +52 -0
  324. package/src/intents/index.ts +6 -0
  325. package/src/intents/listen-intent.hook.ts +92 -0
  326. package/src/intents/reply.ts +24 -0
  327. package/src/intents/send-intent.hook.ts +111 -0
  328. package/src/navigation/adapters/adapter.ts +13 -0
  329. package/src/navigation/adapters/memory.adapter.ts +22 -0
  330. package/src/navigation/adapters/url.adapter.ts +61 -0
  331. package/src/navigation/history.ts +170 -0
  332. package/src/navigation/hooks/ancestors.hook.ts +71 -0
  333. package/src/navigation/hooks/location.hook.ts +21 -0
  334. package/src/navigation/hooks/navigate.hook.ts +43 -0
  335. package/src/navigation/hooks/scope.hook.ts +34 -0
  336. package/src/navigation/index.ts +17 -0
  337. package/src/navigation/link.tsx +110 -0
  338. package/src/navigation/location.ts +122 -0
  339. package/src/navigation/scope.context.tsx +267 -0
  340. package/src/navigation/snapshot.ts +79 -0
  341. package/src/schema/bind-read.ts +319 -0
  342. package/src/schema/binding.ts +91 -0
  343. package/src/schema/domain.hook.ts +16 -0
  344. package/src/schema/function.hook.ts +68 -0
  345. package/src/schema/index.ts +25 -0
  346. package/src/schema/kernel.hook.ts +17 -0
  347. package/src/schema/method.hook.ts +103 -0
  348. package/src/schema/tag.ts +19 -0
  349. package/src/schema/types.ts +150 -0
  350. package/src/schema/write.ts +80 -0
  351. package/src/selection/index.ts +5 -0
  352. package/src/selection/live.ts +142 -0
  353. package/src/selection/scope.context.tsx +151 -0
  354. package/src/selection/selection.hook.ts +18 -0
  355. package/src/session/boot/boot.ts +57 -0
  356. package/src/session/boot/ownership.ts +54 -0
  357. package/src/session/boot/status.ts +32 -0
  358. package/src/session/connection/connection.hook.ts +16 -0
  359. package/src/session/connection/connection.store.ts +58 -0
  360. package/src/session/index.ts +8 -0
  361. package/src/session/kernel-client.hook.ts +13 -0
  362. package/src/session/kernel-instance.hook.ts +22 -0
  363. package/src/session/provider.tsx +205 -0
  364. package/src/session/session.context.ts +27 -0
  365. package/src/session/shell.hook.ts +19 -0
  366. package/src/window/adopt.ts +57 -0
  367. package/src/window/hooks/close-guard.hook.ts +100 -0
  368. package/src/window/hooks/target-node.hook.ts +94 -0
  369. package/src/window/hooks/views-for.hook.ts +82 -0
  370. package/src/window/hooks/window.hook.ts +18 -0
  371. package/src/window/hooks/windows.hook.ts +40 -0
  372. package/src/window/host.tsx +347 -0
  373. package/src/window/hub.ts +156 -0
  374. package/src/window/index.ts +17 -0
  375. package/src/window/lifecycle/mount.ts +134 -0
  376. package/src/window/lifecycle/states.ts +23 -0
  377. package/src/window/placement.ts +84 -0
  378. package/src/window/stage.tsx +46 -0
@@ -0,0 +1,9 @@
1
+ /**
2
+ * useKernelClient (API §3) — `shell.kernel`, the raw bound kernel view, untouched
3
+ * (the untyped floor). The TYPED handles `useKernel()`/`useDomain(schema)` live in
4
+ * the schema module (§6).
5
+ */
6
+ import type { KernelClient } from '@astrale-os/shell';
7
+ /** `shell.kernel` — the raw bound kernel view, untouched (untyped floor). */
8
+ export declare function useKernelClient(): KernelClient;
9
+ //# sourceMappingURL=kernel-client.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernel-client.hook.d.ts","sourceRoot":"","sources":["../../src/session/kernel-client.hook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIrD,6EAA6E;AAC7E,wBAAgB,eAAe,IAAI,YAAY,CAE9C"}
@@ -0,0 +1,5 @@
1
+ import { useShell } from './shell.hook';
2
+ /** `shell.kernel` — the raw bound kernel view, untouched (untyped floor). */
3
+ export function useKernelClient() {
4
+ return useShell().kernel;
5
+ }
@@ -0,0 +1,9 @@
1
+ export interface KernelInstance {
2
+ /** Kernel envelope endpoint this shell is bound to. */
3
+ readonly url: string;
4
+ /** Current kernel credential. Never cache; read per request. */
5
+ token(): string;
6
+ }
7
+ /** Low-level access for direct kernel-envelope calls and token exchange code. */
8
+ export declare function useKernelInstance(): KernelInstance;
9
+ //# sourceMappingURL=kernel-instance.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kernel-instance.hook.d.ts","sourceRoot":"","sources":["../../src/session/kernel-instance.hook.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IACvD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,gEAAgE;IAChE,KAAK,IAAI,MAAM,CAAA;CAChB;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,IAAI,cAAc,CASlD"}
@@ -0,0 +1,10 @@
1
+ import { useMemo } from 'react';
2
+ import { useKernelClient } from './kernel-client.hook';
3
+ /** Low-level access for direct kernel-envelope calls and token exchange code. */
4
+ export function useKernelInstance() {
5
+ const kernel = useKernelClient();
6
+ return useMemo(() => ({
7
+ url: kernel.url,
8
+ token: () => kernel.authToken(),
9
+ }), [kernel]);
10
+ }
@@ -0,0 +1,31 @@
1
+ import type { Shell, ShellConfig } from '@astrale-os/shell';
2
+ import type { ReactElement, ReactNode } from 'react';
3
+ /** Global error channel payload (API §2). */
4
+ export type ShellError = {
5
+ kind: 'refresh';
6
+ shape: unknown;
7
+ error: unknown;
8
+ } | {
9
+ kind: 'mutation';
10
+ mutationId: string;
11
+ error: unknown;
12
+ } | {
13
+ kind: 'connection';
14
+ error: unknown;
15
+ };
16
+ export interface ShellProviderProps {
17
+ /**
18
+ * Shell config — or a prebuilt Shell (tests, storybook). Keyed by identity: a
19
+ * config change disposes and reboots.
20
+ */
21
+ config: ShellConfig | Shell;
22
+ /** Rendered until status === 'ready'. Default: null. */
23
+ fallback?: ReactNode;
24
+ /** Rendered when boot fails; `retry` re-runs init. Default: rethrow to the nearest boundary. */
25
+ errorFallback?: (error: unknown, retry: () => void) => ReactNode;
26
+ /** Global error channel: warm-read refresh failures, rolled-back mutations, watch drops. */
27
+ onError?: (error: ShellError) => void;
28
+ children: ReactNode;
29
+ }
30
+ export declare function ShellProvider(props: ShellProviderProps): ReactElement | null;
31
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/session/provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AA0BpD,6CAA6C;AAC7C,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAE1C,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,MAAM,EAAE,WAAW,GAAG,KAAK,CAAA;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,gGAAgG;IAChG,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,SAAS,CAAA;IAChE,4FAA4F;IAC5F,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC,QAAQ,EAAE,SAAS,CAAA;CACpB;AAmBD,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI,CA0I5E"}
@@ -0,0 +1,165 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { createShell } from '@astrale-os/shell';
3
+ /**
4
+ * ShellProvider — the composition root (API §2, SPEC §5): owns the shell boot
5
+ * state machine (a config OR a prebuilt Shell; `createShell → init → whoami →
6
+ * ready`), seats `ShellContext` and `GraphContext`, and registers its boot-retry
7
+ * into the per-shell connection store. One live shell per mounted provider,
8
+ * StrictMode/HMR-safe (deferred teardown), keyed on config identity. Children
9
+ * render only at `ready`, so useShell/useSelf are synchronous below.
10
+ */
11
+ import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
12
+ import { primeUser } from '../application/user/user.store';
13
+ import { GraphContext } from '../graph/graph.context';
14
+ import { baseMemoryFor, setMemoryErrorSink } from '../graph/memory/base';
15
+ import { configIdentity, isShellConfig, resolveSelf } from './boot/boot';
16
+ import { cancelTeardown, disposeShell, scheduleTeardown } from './boot/ownership';
17
+ import { bootReducer, INITIAL_BOOT } from './boot/status';
18
+ import { connectionStore } from './connection/connection.store';
19
+ import { ShellContext } from './session.context';
20
+ /**
21
+ * Map a memory event to the documented `ShellError` union (API §2). `refresh`
22
+ * (warm-read revalidation failure) and `mutation` (rolled-back write) are the
23
+ * two the channel promises; `divergence`/`invariant` are Tier-0/dev tripwires
24
+ * outside the union and are not bridged here.
25
+ */
26
+ function toShellError(event) {
27
+ switch (event.kind) {
28
+ case 'refresh':
29
+ return { kind: 'refresh', shape: event.shape, error: event.error };
30
+ case 'mutation':
31
+ return { kind: 'mutation', mutationId: event.mutationId, error: event.error };
32
+ default:
33
+ return null;
34
+ }
35
+ }
36
+ export function ShellProvider(props) {
37
+ const { config, fallback, errorFallback, onError, children } = props;
38
+ const [state, dispatch] = useReducer(bootReducer, INITIAL_BOOT);
39
+ const [attempt, setAttempt] = useState(0);
40
+ const bootRef = useRef({ key: null, shell: null, generation: 0 });
41
+ const configRef = useRef(config);
42
+ configRef.current = config;
43
+ const onErrorRef = useRef(onError);
44
+ onErrorRef.current = onError;
45
+ const configKey = configIdentity(config);
46
+ const startBoot = useCallback((ref) => {
47
+ const generation = (ref.generation += 1);
48
+ dispatch({ type: 'connecting' });
49
+ let shell;
50
+ const current = configRef.current;
51
+ try {
52
+ shell = isShellConfig(current) ? createShell(current) : current;
53
+ }
54
+ catch (err) {
55
+ dispatch({ type: 'error', error: err });
56
+ onErrorRef.current?.({ kind: 'connection', error: err });
57
+ return;
58
+ }
59
+ ref.shell = shell;
60
+ void (async () => {
61
+ try {
62
+ await shell.init();
63
+ if (generation !== ref.generation)
64
+ return;
65
+ const self = await resolveSelf(shell);
66
+ if (generation !== ref.generation)
67
+ return;
68
+ // Pre-resolve the OS-plane user binding (API §2/§12.2) — NON-FATAL: a
69
+ // missing OS plane marks it unavailable without failing boot (whoami above
70
+ // stays the fatal gate). Seeds the user store so `useUser` is synchronous.
71
+ await primeUser(shell);
72
+ if (generation !== ref.generation)
73
+ return;
74
+ dispatch({ type: 'ready', runtime: { shell, self } });
75
+ }
76
+ catch (err) {
77
+ if (generation !== ref.generation)
78
+ return;
79
+ dispatch({ type: 'error', error: err });
80
+ onErrorRef.current?.({ kind: 'connection', error: err });
81
+ }
82
+ })();
83
+ }, []);
84
+ useEffect(() => {
85
+ const ref = bootRef.current;
86
+ // The shell this provider will run with once the effect settles: a prebuilt
87
+ // Shell is the config object itself; a config-built one is whatever this
88
+ // instance already booted (adopted on a StrictMode/HMR re-setup). Cancel any
89
+ // pending deferred teardown for it before deciding — this also cancels a
90
+ // teardown another provider scheduled for the SAME prebuilt Shell.
91
+ const current = configRef.current;
92
+ const adopting = isShellConfig(current) ? ref.shell : current;
93
+ if (adopting !== null)
94
+ cancelTeardown(adopting);
95
+ if (ref.key !== configKey) {
96
+ // First boot, config change, or a retry that cleared the key: reboot fresh.
97
+ if (ref.shell !== null) {
98
+ cancelTeardown(ref.shell);
99
+ disposeShell(ref.shell);
100
+ }
101
+ ref.key = configKey;
102
+ ref.shell = null;
103
+ startBoot(ref);
104
+ }
105
+ // Same key already booting/booted → adopt (StrictMode's second setup).
106
+ return () => {
107
+ // Defer teardown one macrotask; a synchronous re-setup (StrictMode/HMR or a
108
+ // different provider adopting the same prebuilt Shell) cancels it first and
109
+ // keeps the same live shell.
110
+ if (ref.shell !== null)
111
+ scheduleTeardown(ref.shell, ref);
112
+ else
113
+ ref.key = null;
114
+ };
115
+ }, [configKey, attempt, startBoot]);
116
+ const retry = useCallback(() => {
117
+ const ref = bootRef.current;
118
+ ref.generation += 1;
119
+ if (ref.shell !== null) {
120
+ disposeShell(ref.shell);
121
+ ref.shell = null;
122
+ }
123
+ ref.key = null;
124
+ dispatch({ type: 'connecting' });
125
+ setAttempt((a) => a + 1);
126
+ }, []);
127
+ // The base (default-scope) memory for the booted Shell — the SAME instance
128
+ // the graph/schema/nav hooks read through `graph/memory/scope.ts`. Seated in
129
+ // `GraphContext` so selection's liveness has a source; null until ready.
130
+ const shell = state.runtime?.shell ?? null;
131
+ const memory = useMemo(() => (shell === null ? null : baseMemoryFor(shell)), [shell]);
132
+ // Bridge the memory's event channel onto the provider `onError` (API §2/§8):
133
+ // warm-refresh failures and rolled-back mutations surface here rather than being
134
+ // swallowed. Registered while the booted shell is live; cleared on teardown.
135
+ useEffect(() => {
136
+ if (shell === null)
137
+ return;
138
+ setMemoryErrorSink(shell, (event) => {
139
+ const mapped = toShellError(event);
140
+ if (mapped !== null)
141
+ onErrorRef.current?.(mapped);
142
+ });
143
+ return () => setMemoryErrorSink(shell, null);
144
+ }, [shell]);
145
+ // Register this provider's boot-retry into the shell's connection store (rule 3),
146
+ // so `useConnection().retry` re-runs boot. Status/seq stay a stub ('ready'/0)
147
+ // until the transport-status + result-`seq` feed lands, with no surface change.
148
+ useEffect(() => {
149
+ if (shell === null)
150
+ return;
151
+ connectionStore(shell).setRetry(retry);
152
+ }, [shell, retry]);
153
+ if (state.status === 'error') {
154
+ // Wrapped in a fragment so the component's declared return type stays
155
+ // `ReactElement | null` — valid JSX under @types/react 18 AND 19 (the react
156
+ // peer range is >=18), even though `errorFallback`/`fallback` yield ReactNode.
157
+ if (errorFallback !== undefined)
158
+ return _jsx(_Fragment, { children: errorFallback(state.error, retry) });
159
+ throw state.error;
160
+ }
161
+ if (state.status !== 'ready' || state.runtime === null) {
162
+ return fallback !== undefined ? _jsx(_Fragment, { children: fallback }) : null;
163
+ }
164
+ return (_jsx(ShellContext.Provider, { value: state.runtime, children: _jsx(GraphContext.Provider, { value: memory, children: children }) }));
165
+ }
@@ -0,0 +1,18 @@
1
+ import type { KernelClient, Shell } from '@astrale-os/shell';
2
+ /**
3
+ * whoami's node type, derived from the auth surface so shell-react needs no
4
+ * direct `@astrale-os/kernel-core` dependency (`Node` is not yet re-exported by
5
+ * kernel-client — API §14 G8). Swap for the blessed re-export when it lands.
6
+ */
7
+ export type SelfNode = Awaited<ReturnType<KernelClient['auth']['whoami']>>;
8
+ /** The live shell for a provider subtree (and, later, an `<ActAs>` subtree). */
9
+ export interface ShellRuntime {
10
+ readonly shell: Shell;
11
+ /**
12
+ * whoami resolved at boot; the auth module (`useSelf`) reads it. Null when the
13
+ * bound kernel exposes no auth surface (a bare prebuilt Shell in tests).
14
+ */
15
+ readonly self: SelfNode | null;
16
+ }
17
+ export declare const ShellContext: import("react").Context<ShellRuntime | null>;
18
+ //# sourceMappingURL=session.context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.context.d.ts","sourceRoot":"","sources":["../../src/session/session.context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAS5D;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AAE1E,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAA;CAC/B;AACD,eAAO,MAAM,YAAY,8CAA2C,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * ShellContext — the shell session seat. Holds ONLY the stable `Shell` for a
3
+ * provider subtree (plus the whoami resolved once at boot). Connection state is
4
+ * NOT here: it is a provider-owned store read via `useConnection` (rule 3).
5
+ */
6
+ import { createContext } from 'react';
7
+ export const ShellContext = createContext(null);
8
+ ShellContext.displayName = 'AstraleShellContext';
@@ -0,0 +1,4 @@
1
+ import type { Shell } from '@astrale-os/shell';
2
+ /** The live shell for this subtree. Throws outside a `<ShellProvider>`. */
3
+ export declare function useShell(): Shell;
4
+ //# sourceMappingURL=shell.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.hook.d.ts","sourceRoot":"","sources":["../../src/session/shell.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAW9C,2EAA2E;AAC3E,wBAAgB,QAAQ,IAAI,KAAK,CAMhC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * useShell (API §3) — the live shell for this subtree, read from ShellContext.
3
+ * Throws outside a `<ShellProvider>`. The imperative floor every other session
4
+ * hook builds on.
5
+ */
6
+ import { useContext } from 'react';
7
+ import { ShellContext } from './session.context';
8
+ /** The live shell for this subtree. Throws outside a `<ShellProvider>`. */
9
+ export function useShell() {
10
+ const runtime = useContext(ShellContext);
11
+ if (runtime === null) {
12
+ throw new Error('useShell must be used within a <ShellProvider>');
13
+ }
14
+ return runtime.shell;
15
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Stash/adopt across re-key / re-parent (API §10). A live window handed off across
3
+ * an unmount so a remount can ADOPT it instead of closing + reloading it. Mirrors
4
+ * ShellProvider's deferred-teardown pattern: the unmounting host stashes the
5
+ * record, and either the remount takes it (one macrotask) or it disposes.
6
+ */
7
+ import type { Window } from '@astrale-os/shell';
8
+ import type { WindowState } from './lifecycle/states';
9
+ import type { StageSlot } from './placement';
10
+ export interface AdoptRecord {
11
+ readonly windowId: string;
12
+ readonly window: Window;
13
+ readonly slot: StageSlot;
14
+ readonly state: WindowState;
15
+ readonly targetId: string | undefined;
16
+ /** Close the window, release its slot, drop it from the registry (fired if unadopted). */
17
+ dispose(): void;
18
+ }
19
+ export interface AdoptStash {
20
+ /** Stash an unmounting host's live window; disposes after one macrotask if unadopted. */
21
+ stash(key: string, record: AdoptRecord): void;
22
+ /** Reclaim a stashed window for a remount of the same source, cancelling its dispose. */
23
+ take(key: string): AdoptRecord | null;
24
+ }
25
+ /** The pending-adoption registry — one per stage hub. */
26
+ export declare function createAdoptStash(): AdoptStash;
27
+ //# sourceMappingURL=adopt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adopt.d.ts","sourceRoot":"","sources":["../../src/window/adopt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,0FAA0F;IAC1F,OAAO,IAAI,IAAI,CAAA;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,yFAAyF;IACzF,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;IAC7C,yFAAyF;IACzF,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAA;CACtC;AAED,yDAAyD;AACzD,wBAAgB,gBAAgB,IAAI,UAAU,CA2B7C"}
@@ -0,0 +1,27 @@
1
+ /** The pending-adoption registry — one per stage hub. */
2
+ export function createAdoptStash() {
3
+ const pendingAdopt = new Map();
4
+ return {
5
+ stash(key, record) {
6
+ // Rapid same-key churn: an unclaimed prior stash disposes now.
7
+ const prior = pendingAdopt.get(key);
8
+ if (prior !== undefined) {
9
+ clearTimeout(prior.timer);
10
+ prior.record.dispose();
11
+ }
12
+ const timer = setTimeout(() => {
13
+ pendingAdopt.delete(key);
14
+ record.dispose();
15
+ }, 0);
16
+ pendingAdopt.set(key, { record, timer });
17
+ },
18
+ take(key) {
19
+ const entry = pendingAdopt.get(key);
20
+ if (entry === undefined)
21
+ return null;
22
+ clearTimeout(entry.timer);
23
+ pendingAdopt.delete(key);
24
+ return entry.record;
25
+ },
26
+ };
27
+ }
@@ -0,0 +1,6 @@
1
+ export type CloseVerdict = 'ack' | 'refuse' | {
2
+ readonly refuse: string;
3
+ };
4
+ export type CloseGuard = () => CloseVerdict | Promise<CloseVerdict>;
5
+ export declare function useCloseGuard(guard: CloseGuard): void;
6
+ //# sourceMappingURL=close-guard.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"close-guard.hook.d.ts","sourceRoot":"","sources":["../../../src/window/hooks/close-guard.hook.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AACzE,MAAM,MAAM,UAAU,GAAG,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AA0EnE,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAWrD"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * useCloseGuard (API §10) — child-side willClose negotiation. The parent sends a
3
+ * `willClose` intent before closing; the guard answers `closeAck` (allow) or
4
+ * `closeRefuse` (veto, with reason). Guards stack per shell and the last-mounted
5
+ * one wins; a single shared subscription owns the reply so a `willClose` is
6
+ * answered exactly once regardless of how many guards are mounted.
7
+ */
8
+ import { useEffect, useRef } from 'react';
9
+ import { useShell } from '../../session/shell.hook';
10
+ function sendAck(parent) {
11
+ parent.send({
12
+ type: 'intent',
13
+ version: 1,
14
+ envelope: { name: 'closeAck', payload: {}, sender: { windowId: 'self' } },
15
+ });
16
+ }
17
+ function sendRefuse(parent, reason) {
18
+ parent.send({
19
+ type: 'intent',
20
+ version: 1,
21
+ envelope: { name: 'closeRefuse', payload: { reason }, sender: { windowId: 'self' } },
22
+ });
23
+ }
24
+ const HUBS = new WeakMap();
25
+ function getCloseGuardHub(shell) {
26
+ const existing = HUBS.get(shell);
27
+ if (existing !== undefined)
28
+ return existing;
29
+ const stack = [];
30
+ let off = null;
31
+ function ensureSubscribed() {
32
+ if (off !== null)
33
+ return;
34
+ const parent = shell.parent;
35
+ if (parent === null)
36
+ return;
37
+ off = parent.on('intent', (message) => {
38
+ if (message.envelope.name !== 'willClose')
39
+ return;
40
+ const guard = stack[stack.length - 1];
41
+ if (guard === undefined)
42
+ return;
43
+ void answer(parent, guard);
44
+ });
45
+ }
46
+ async function answer(parent, guard) {
47
+ let verdict;
48
+ try {
49
+ verdict = await guard();
50
+ }
51
+ catch {
52
+ // A throwing guard must not trap the user in the window — allow the close.
53
+ verdict = 'ack';
54
+ }
55
+ if (verdict === 'ack')
56
+ sendAck(parent);
57
+ else if (verdict === 'refuse')
58
+ sendRefuse(parent, '');
59
+ else
60
+ sendRefuse(parent, verdict.refuse);
61
+ }
62
+ const hub = {
63
+ push(guard) {
64
+ stack.push(guard);
65
+ ensureSubscribed();
66
+ return () => {
67
+ const i = stack.lastIndexOf(guard);
68
+ if (i >= 0)
69
+ stack.splice(i, 1);
70
+ if (stack.length === 0 && off !== null) {
71
+ off();
72
+ off = null;
73
+ }
74
+ };
75
+ },
76
+ };
77
+ HUBS.set(shell, hub);
78
+ return hub;
79
+ }
80
+ export function useCloseGuard(guard) {
81
+ const shell = useShell();
82
+ const guardRef = useRef(guard);
83
+ guardRef.current = guard;
84
+ useEffect(() => {
85
+ const hub = getCloseGuardHub(shell);
86
+ // Push a stable wrapper so a changed guard closure never re-registers
87
+ // (latest-handler semantics; unmount pops this exact entry).
88
+ return hub.push(() => guardRef.current());
89
+ }, [shell]);
90
+ }
@@ -0,0 +1,7 @@
1
+ import type { ReadState } from '../../graph/memory/read/envelope';
2
+ import type { Node } from '../lifecycle/mount';
3
+ export interface NodeResult extends ReadState {
4
+ readonly node: Node | null;
5
+ }
6
+ export declare function useTargetNode(): NodeResult;
7
+ //# sourceMappingURL=target-node.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target-node.hook.d.ts","sourceRoot":"","sources":["../../../src/window/hooks/target-node.hook.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAK9C,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;CAC3B;AAeD,wBAAgB,aAAa,IAAI,UAAU,CAe1C"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * useTargetNode (API §10) — inside a sandboxed view, the node it was opened on.
3
+ * The id starts from `shell.targetNodeId` (handshake) and a host `setTarget`
4
+ * intent retargets it; the id resolves to a live `Node` through the shell kernel.
5
+ *
6
+ * Honest subset (flagged): the read is a one-shot `kernel.get` re-run on id
7
+ * change, not a memory watch, so `live` is false. Once composed with `useNode(id)`
8
+ * it becomes real stale-while-revalidate liveness with no consumer change.
9
+ */
10
+ import { useCallback, useEffect, useRef, useState } from 'react';
11
+ import { idleReadState } from '../../graph/memory/read/idle';
12
+ import { useShell } from '../../session/shell.hook';
13
+ /** Address a bare node id by graph id (`@<id>`); pass paths/anchors through. */
14
+ function toRef(id) {
15
+ return id.startsWith('/') || id.startsWith('@') ? id : `@${id}`;
16
+ }
17
+ const IDLE_READ = { node: null, pending: false, error: undefined };
18
+ export function useTargetNode() {
19
+ const shell = useShell();
20
+ const [id, setId] = useState(() => shell.targetNodeId ?? null);
21
+ useEffect(() => {
22
+ const parent = shell.parent;
23
+ if (parent === null)
24
+ return;
25
+ return parent.on('intent', (message) => {
26
+ if (message.envelope.name !== 'setTarget')
27
+ return;
28
+ const nodeId = message.envelope.payload.nodeId;
29
+ if (typeof nodeId === 'string')
30
+ setId(nodeId);
31
+ });
32
+ }, [shell]);
33
+ return useNodeRead(shell.kernel, id);
34
+ }
35
+ /** One-shot get + refetch, in the read envelope. The graph-module seam. */
36
+ function useNodeRead(kernel, id) {
37
+ const [snap, setSnap] = useState(IDLE_READ);
38
+ const aliveRef = useRef(true);
39
+ useEffect(() => {
40
+ aliveRef.current = true;
41
+ return () => {
42
+ aliveRef.current = false;
43
+ };
44
+ }, []);
45
+ const load = useCallback(async () => {
46
+ if (id === null) {
47
+ if (aliveRef.current)
48
+ setSnap(IDLE_READ);
49
+ return;
50
+ }
51
+ if (aliveRef.current)
52
+ setSnap((s) => ({ node: s.node, pending: true, error: undefined }));
53
+ try {
54
+ const node = await kernel.get(toRef(id));
55
+ if (aliveRef.current)
56
+ setSnap({ node: node ?? null, pending: false, error: undefined });
57
+ }
58
+ catch (error) {
59
+ if (aliveRef.current)
60
+ setSnap((s) => ({ node: s.node, pending: false, error }));
61
+ }
62
+ }, [kernel, id]);
63
+ useEffect(() => {
64
+ void load();
65
+ }, [load]);
66
+ if (id === null) {
67
+ return { ...idleReadState(), node: null };
68
+ }
69
+ return {
70
+ node: snap.node,
71
+ pending: snap.pending,
72
+ error: snap.error,
73
+ live: false,
74
+ seq: 0,
75
+ refetch: load,
76
+ };
77
+ }
@@ -0,0 +1,8 @@
1
+ import type { PathLike } from '@astrale-os/kernel-client/graph';
2
+ import type { ReadState } from '../../graph/memory/read/envelope';
3
+ import type { Node, ViewDescriptor } from '../lifecycle/mount';
4
+ export interface ViewsForResult extends ReadState {
5
+ readonly views: readonly ViewDescriptor[];
6
+ }
7
+ export declare function useViewsFor(node: Node | PathLike | null | undefined): ViewsForResult;
8
+ //# sourceMappingURL=views-for.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views-for.hook.d.ts","sourceRoot":"","sources":["../../../src/window/hooks/views-for.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAW/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAK9D,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAA;CAC1C;AAiBD,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc,CAqBpF"}
@@ -0,0 +1,51 @@
1
+ import { K } from '@astrale-os/kernel-core';
2
+ /**
3
+ * useViewsFor (API §10) — "what Views can render this node", as mountable
4
+ * `ViewDescriptor`s for the open-with menu. Backed one-shot (`live:false`) by the
5
+ * kernel `View.resolve` syscall, which derives the node's class and returns the
6
+ * caller-visible Views (USE-visibility enforced kernel-side), each with mount url.
7
+ */
8
+ import { useMemo } from 'react';
9
+ import { useAsyncResource } from '../../graph/async';
10
+ import { useKernelClient } from '../../session/kernel-client.hook';
11
+ /** The `View.resolve` wire address — the qualified static-method slug from the schema. */
12
+ const VIEW_RESOLVE_METHOD = K.View.resolve.path.method.raw;
13
+ const NO_VIEWS = Object.freeze([]);
14
+ export function useViewsFor(node) {
15
+ const kernel = useKernelClient();
16
+ const target = resolvePath(node);
17
+ const res = useAsyncResource(target === null ? null : () => resolveViews(kernel, target), NO_VIEWS, [kernel, target]);
18
+ return useMemo(() => ({
19
+ views: res.data,
20
+ pending: res.pending,
21
+ error: res.error,
22
+ live: false,
23
+ seq: 0,
24
+ refetch: res.refetch,
25
+ }), [res.data, res.pending, res.error, res.refetch]);
26
+ }
27
+ /** Dispatch `View.resolve` and project its rows to mountable `ViewDescriptor`s. */
28
+ async function resolveViews(kernel, node) {
29
+ const rows = (await kernel.call(VIEW_RESOLVE_METHOD, { node }));
30
+ if (rows === null || rows === undefined || rows.length === 0)
31
+ return NO_VIEWS;
32
+ return rows.map((r) => ({ id: r.id, path: r.path, url: r.url, handshake: r.handshake }));
33
+ }
34
+ /** A path/`@id` the kernel read surface accepts, or `null` for an idle subject. */
35
+ function resolvePath(node) {
36
+ if (node === null || node === undefined)
37
+ return null;
38
+ if (typeof node === 'string') {
39
+ if (node.length === 0)
40
+ return null;
41
+ return node.startsWith('/') || node.startsWith('@') ? node : `@${node}`;
42
+ }
43
+ const obj = node;
44
+ if (typeof obj.path?.raw === 'string')
45
+ return obj.path.raw;
46
+ if (typeof obj.id === 'string')
47
+ return `@${obj.id}`;
48
+ if (typeof obj.raw === 'string')
49
+ return obj.raw;
50
+ return null;
51
+ }
@@ -0,0 +1,4 @@
1
+ import type { WindowView } from '../hub';
2
+ /** One window's live phase + shell `Window` (null id / unknown id → no window). */
3
+ export declare function useWindow(windowId: string | null): WindowView;
4
+ //# sourceMappingURL=window.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"window.hook.d.ts","sourceRoot":"","sources":["../../../src/window/hooks/window.hook.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAKxC,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,CAK7D"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * useWindow(id) (API §10) — one window's live phase + shell `Window` (null id /
3
+ * unknown id → a stable "no window"), reactive over the per-shell hub registry.
4
+ */
5
+ import { useMemo, useSyncExternalStore } from 'react';
6
+ import { useShell } from '../../session/shell.hook';
7
+ import { getStageHub } from '../hub';
8
+ /** One window's live phase + shell `Window` (null id / unknown id → no window). */
9
+ export function useWindow(windowId) {
10
+ const shell = useShell();
11
+ const hub = useMemo(() => getStageHub(shell), [shell]);
12
+ const snapshot = useMemo(() => () => hub.registry.select(windowId), [hub, windowId]);
13
+ return useSyncExternalStore(hub.registry.subscribe, snapshot, snapshot);
14
+ }