@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 @@
1
+ {"version":3,"file":"memory.adapter.d.ts","sourceRoot":"","sources":["../../../src/navigation/adapters/memory.adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,UAAU,CAatE"}
@@ -0,0 +1,15 @@
1
+ /** In-memory adapter — the default scope backing (per-pane state, no URL). */
2
+ export function memoryAdapter(initial) {
3
+ let current = initial ?? null;
4
+ const listeners = new Set();
5
+ return {
6
+ read: () => current,
7
+ write: (loc) => {
8
+ current = loc;
9
+ },
10
+ subscribe: (cb) => {
11
+ listeners.add(cb);
12
+ return () => listeners.delete(cb);
13
+ },
14
+ };
15
+ }
@@ -0,0 +1,6 @@
1
+ import type { NavAdapter } from './adapter';
2
+ /** History-API adapter — the location lives in the query string. */
3
+ export declare function urlAdapter(opts?: {
4
+ param?: string;
5
+ }): NavAdapter;
6
+ //# sourceMappingURL=url.adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.adapter.d.ts","sourceRoot":"","sources":["../../../src/navigation/adapters/url.adapter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAI3C,oEAAoE;AACpE,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAiDhE"}
@@ -0,0 +1,59 @@
1
+ const VIEW_KEY = 'view';
2
+ /** History-API adapter — the location lives in the query string. */
3
+ export function urlAdapter(opts) {
4
+ const param = opts?.param ?? 'node';
5
+ const hasWindow = () => typeof window !== 'undefined';
6
+ const build = (loc) => {
7
+ const url = new URL(window.location.href);
8
+ const sp = new URLSearchParams();
9
+ sp.set(param, loc.node);
10
+ if (loc.view !== undefined)
11
+ sp.set(VIEW_KEY, loc.view);
12
+ for (const [k, v] of Object.entries(loc.params ?? {})) {
13
+ if (k !== param && k !== VIEW_KEY)
14
+ sp.set(k, v);
15
+ }
16
+ url.search = sp.toString();
17
+ return `${url.pathname}${url.search}${url.hash}`;
18
+ };
19
+ return {
20
+ read() {
21
+ if (!hasWindow())
22
+ return null;
23
+ const sp = new URL(window.location.href).searchParams;
24
+ const node = sp.get(param);
25
+ if (node === null)
26
+ return null;
27
+ const view = sp.get(VIEW_KEY) ?? undefined;
28
+ const params = {};
29
+ for (const [k, v] of sp) {
30
+ if (k !== param && k !== VIEW_KEY)
31
+ params[k] = v;
32
+ }
33
+ return {
34
+ node,
35
+ ...(view !== undefined ? { view } : {}),
36
+ ...(Object.keys(params).length > 0 ? { params } : {}),
37
+ };
38
+ },
39
+ write(loc, { replace }) {
40
+ if (!hasWindow())
41
+ return;
42
+ const href = build(loc);
43
+ if (replace)
44
+ window.history.replaceState(null, '', href);
45
+ else
46
+ window.history.pushState(null, '', href);
47
+ },
48
+ subscribe(cb) {
49
+ if (!hasWindow())
50
+ return () => undefined;
51
+ const handler = () => cb();
52
+ window.addEventListener('popstate', handler);
53
+ return () => window.removeEventListener('popstate', handler);
54
+ },
55
+ href(loc) {
56
+ return hasWindow() ? build(loc) : loc.node;
57
+ },
58
+ };
59
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The per-scope history model (API §8.2) — a framework-free entries+cursor stack
3
+ * with a version counter for `useSyncExternalStore`, its serialized entry shape
4
+ * (`SerializedLocation`/`NavSnapshot` + equality/clone), and the seed precedence.
5
+ * Source of truth for back/forward; the adapter is a projection sink around it.
6
+ */
7
+ /** The serializable projection persisted in history / URLs / snapshots. */
8
+ export interface SerializedLocation {
9
+ node: string;
10
+ view?: string;
11
+ params?: Record<string, string>;
12
+ }
13
+ /** A versioned history snapshot — round-trips through `NavScope.restore`. */
14
+ export interface NavSnapshot {
15
+ v: 1;
16
+ entries: SerializedLocation[];
17
+ cursor: number;
18
+ }
19
+ /** Structural equality of two serialized locations (node + view + params). */
20
+ export declare function sameLocation(a: SerializedLocation, b: SerializedLocation): boolean;
21
+ /** A deep-enough clone for a serialized entry (params copied). */
22
+ export declare function cloneLocation(loc: SerializedLocation): SerializedLocation;
23
+ export declare class NavHistory {
24
+ private entries;
25
+ private cursor;
26
+ private version;
27
+ private readonly listeners;
28
+ constructor(entries: SerializedLocation[], cursor: number);
29
+ subscribe(listener: () => void): () => void;
30
+ getVersion(): number;
31
+ get current(): SerializedLocation | null;
32
+ get canBack(): boolean;
33
+ get canForward(): boolean;
34
+ snapshot(): NavSnapshot;
35
+ /** Push (or replace the current entry with) a location. No-op on same location. */
36
+ push(loc: SerializedLocation, replace: boolean): boolean;
37
+ back(): boolean;
38
+ forward(): boolean;
39
+ /**
40
+ * Reconcile an externally-observed location (browser back/forward, URL edit):
41
+ * step the cursor when it matches an adjacent entry, else push it fresh.
42
+ */
43
+ syncExternal(loc: SerializedLocation): boolean;
44
+ /** Replace the whole stack (restore revalidation prune). */
45
+ reset(entries: SerializedLocation[], cursor: number): void;
46
+ private emit;
47
+ }
48
+ /**
49
+ * Seed the initial entries+cursor from the three sources, in precedence order:
50
+ * a `restore` snapshot (revalidated later against the memory), then the
51
+ * adapter's current read, then `initial`; empty (idle) when none yields one.
52
+ * A live adapter read that disagrees with a restored cursor is appended as the
53
+ * current entry (a deep link overrides the saved position but keeps its back
54
+ * history).
55
+ */
56
+ export declare function seedEntries(fromAdapter: SerializedLocation | null, restore: {
57
+ entries: SerializedLocation[];
58
+ cursor: number;
59
+ } | undefined, initialSerialized: SerializedLocation | null): {
60
+ entries: SerializedLocation[];
61
+ cursor: number;
62
+ };
63
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/navigation/history.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2EAA2E;AAC3E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,CAAC,CAAA;IACJ,OAAO,EAAE,kBAAkB,EAAE,CAAA;IAC7B,MAAM,EAAE,MAAM,CAAA;CACf;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAElF;AAUD,kEAAkE;AAClE,wBAAgB,aAAa,CAAC,GAAG,EAAE,kBAAkB,GAAG,kBAAkB,CAMzE;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwB;IAElD,YAAY,OAAO,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,MAAM,EAGxD;IAED,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAG1C;IAED,UAAU,IAAI,MAAM,CAEnB;IAED,IAAI,OAAO,IAAI,kBAAkB,GAAG,IAAI,CAEvC;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,QAAQ,IAAI,WAAW,CAEtB;IAED,mFAAmF;IACnF,IAAI,CAAC,GAAG,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAYvD;IAED,IAAI,IAAI,OAAO,CAKd;IAED,OAAO,IAAI,OAAO,CAKjB;IAED;;;OAGG;IACH,YAAY,CAAC,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAgB7C;IAED,4DAA4D;IAC5D,KAAK,CAAC,OAAO,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAIzD;IAED,OAAO,CAAC,IAAI;CAIb;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,WAAW,EAAE,kBAAkB,GAAG,IAAI,EACtC,OAAO,EAAE;IAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,EACtE,iBAAiB,EAAE,kBAAkB,GAAG,IAAI,GAC3C;IAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAcnD"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * The per-scope history model (API §8.2) — a framework-free entries+cursor stack
3
+ * with a version counter for `useSyncExternalStore`, its serialized entry shape
4
+ * (`SerializedLocation`/`NavSnapshot` + equality/clone), and the seed precedence.
5
+ * Source of truth for back/forward; the adapter is a projection sink around it.
6
+ */
7
+ /** Structural equality of two serialized locations (node + view + params). */
8
+ export function sameLocation(a, b) {
9
+ return a.node === b.node && a.view === b.view && sameParams(a.params, b.params);
10
+ }
11
+ function sameParams(a, b) {
12
+ if (a === b)
13
+ return true;
14
+ const ak = a ? Object.keys(a) : [];
15
+ const bk = b ? Object.keys(b) : [];
16
+ if (ak.length !== bk.length)
17
+ return false;
18
+ return ak.every((k) => a?.[k] === b?.[k]);
19
+ }
20
+ /** A deep-enough clone for a serialized entry (params copied). */
21
+ export function cloneLocation(loc) {
22
+ return {
23
+ node: loc.node,
24
+ ...(loc.view !== undefined ? { view: loc.view } : {}),
25
+ ...(loc.params !== undefined ? { params: { ...loc.params } } : {}),
26
+ };
27
+ }
28
+ export class NavHistory {
29
+ entries;
30
+ cursor;
31
+ version = 0;
32
+ listeners = new Set();
33
+ constructor(entries, cursor) {
34
+ this.entries = entries;
35
+ this.cursor = cursor;
36
+ }
37
+ subscribe(listener) {
38
+ this.listeners.add(listener);
39
+ return () => this.listeners.delete(listener);
40
+ }
41
+ getVersion() {
42
+ return this.version;
43
+ }
44
+ get current() {
45
+ return this.entries[this.cursor] ?? null;
46
+ }
47
+ get canBack() {
48
+ return this.cursor > 0;
49
+ }
50
+ get canForward() {
51
+ return this.cursor >= 0 && this.cursor < this.entries.length - 1;
52
+ }
53
+ snapshot() {
54
+ return { v: 1, entries: this.entries.map(cloneLocation), cursor: this.cursor };
55
+ }
56
+ /** Push (or replace the current entry with) a location. No-op on same location. */
57
+ push(loc, replace) {
58
+ const cur = this.current;
59
+ if (cur !== null && sameLocation(cur, loc))
60
+ return false;
61
+ if (replace && cur !== null) {
62
+ this.entries = [...this.entries];
63
+ this.entries[this.cursor] = loc;
64
+ }
65
+ else {
66
+ this.entries = [...this.entries.slice(0, this.cursor + 1), loc];
67
+ this.cursor = this.entries.length - 1;
68
+ }
69
+ this.emit();
70
+ return true;
71
+ }
72
+ back() {
73
+ if (!this.canBack)
74
+ return false;
75
+ this.cursor--;
76
+ this.emit();
77
+ return true;
78
+ }
79
+ forward() {
80
+ if (!this.canForward)
81
+ return false;
82
+ this.cursor++;
83
+ this.emit();
84
+ return true;
85
+ }
86
+ /**
87
+ * Reconcile an externally-observed location (browser back/forward, URL edit):
88
+ * step the cursor when it matches an adjacent entry, else push it fresh.
89
+ */
90
+ syncExternal(loc) {
91
+ const cur = this.current;
92
+ if (cur !== null && sameLocation(cur, loc))
93
+ return false;
94
+ const back = this.entries[this.cursor - 1];
95
+ if (back !== undefined && sameLocation(back, loc)) {
96
+ this.cursor--;
97
+ this.emit();
98
+ return true;
99
+ }
100
+ const fwd = this.entries[this.cursor + 1];
101
+ if (fwd !== undefined && sameLocation(fwd, loc)) {
102
+ this.cursor++;
103
+ this.emit();
104
+ return true;
105
+ }
106
+ return this.push(loc, false);
107
+ }
108
+ /** Replace the whole stack (restore revalidation prune). */
109
+ reset(entries, cursor) {
110
+ this.entries = entries;
111
+ this.cursor = cursor;
112
+ this.emit();
113
+ }
114
+ emit() {
115
+ this.version++;
116
+ for (const listener of this.listeners)
117
+ listener();
118
+ }
119
+ }
120
+ /**
121
+ * Seed the initial entries+cursor from the three sources, in precedence order:
122
+ * a `restore` snapshot (revalidated later against the memory), then the
123
+ * adapter's current read, then `initial`; empty (idle) when none yields one.
124
+ * A live adapter read that disagrees with a restored cursor is appended as the
125
+ * current entry (a deep link overrides the saved position but keeps its back
126
+ * history).
127
+ */
128
+ export function seedEntries(fromAdapter, restore, initialSerialized) {
129
+ if (restore !== undefined && restore.entries.length > 0) {
130
+ const entries = restore.entries.map(cloneLocation);
131
+ let cursor = Math.min(Math.max(restore.cursor, 0), entries.length - 1);
132
+ if (fromAdapter !== null && !sameLocation(fromAdapter, entries[cursor])) {
133
+ entries.splice(cursor + 1);
134
+ entries.push(cloneLocation(fromAdapter));
135
+ cursor = entries.length - 1;
136
+ }
137
+ return { entries, cursor };
138
+ }
139
+ if (fromAdapter !== null)
140
+ return { entries: [cloneLocation(fromAdapter)], cursor: 0 };
141
+ if (initialSerialized !== null)
142
+ return { entries: [initialSerialized], cursor: 0 };
143
+ return { entries: [], cursor: -1 };
144
+ }
@@ -0,0 +1,13 @@
1
+ import type { PathLike } from '@astrale-os/kernel-client/graph';
2
+ import type { ReadState } from '../../graph/memory/read/envelope';
3
+ import type { Node } from '../location';
4
+ /**
5
+ * The root-first ancestor chain (inclusive of the node itself), live: a move
6
+ * re-renders it. `node` defaults to the nearest scope's location node; passing a
7
+ * node/path makes it usable outside a scope. The chain drops any ancestor whose
8
+ * record is masked/absent.
9
+ */
10
+ export declare function useAncestors(node?: Node | PathLike): ReadState & {
11
+ readonly chain: readonly Node[];
12
+ };
13
+ //# sourceMappingURL=ancestors.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ancestors.hook.d.ts","sourceRoot":"","sources":["../../../src/navigation/hooks/ancestors.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAU/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAQvC;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,IAAI,CAAC,EAAE,IAAI,GAAG,QAAQ,GACrB,SAAS,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAA;CAAE,CA6BjD"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * useAncestors (API §8.2) — the live, inclusive root-first ancestor chain of a
3
+ * node (a move re-renders it). Defaults to the nearest scope's location node;
4
+ * passing a node/path makes it usable outside a scope. Drops any masked ancestor.
5
+ */
6
+ import { useMemo } from 'react';
7
+ import { idleReadState } from '../../graph/memory/read/idle';
8
+ import { useMemory } from '../../graph/memory/scope';
9
+ import { chainPaths, pathHint, pathOf } from '../location';
10
+ import { useHistoryVersion, useOptionalNavCtx, useMemoryShape } from '../scope.context';
11
+ import { serializeTarget } from '../snapshot';
12
+ /**
13
+ * The root-first ancestor chain (inclusive of the node itself), live: a move
14
+ * re-renders it. `node` defaults to the nearest scope's location node; passing a
15
+ * node/path makes it usable outside a scope. The chain drops any ancestor whose
16
+ * record is masked/absent.
17
+ */
18
+ export function useAncestors(node) {
19
+ const memory = useMemory();
20
+ const ctx = useOptionalNavCtx();
21
+ useHistoryVersion(ctx?.history ?? null);
22
+ const baseRef = node !== undefined ? serializeTarget(node).node : (ctx?.history.current?.node ?? null);
23
+ const baseResult = useMemoryShape(memory, baseRef);
24
+ const basePath = baseResult?.node ? pathOf(baseResult.node) : pathHint(baseRef ?? '');
25
+ const paths = useMemo(() => (basePath !== '' ? chainPaths(basePath) : EMPTY_PATHS), [basePath]);
26
+ const shape = useMemo(() => (basePath !== '' ? (q) => q.from(...chainPaths(basePath)) : null), [basePath]);
27
+ const chainResult = useMemoryShape(memory, shape);
28
+ const chain = useMemo(() => {
29
+ if (chainResult === null)
30
+ return EMPTY_CHAIN;
31
+ const byPath = new Map();
32
+ for (const n of chainResult.roots)
33
+ byPath.set(pathOf(n), n);
34
+ const out = [];
35
+ for (const p of paths) {
36
+ const hit = byPath.get(p);
37
+ if (hit !== undefined)
38
+ out.push(hit);
39
+ }
40
+ return out;
41
+ }, [paths, chainResult]);
42
+ return { ...readStateOf(chainResult), chain };
43
+ }
44
+ const EMPTY_PATHS = Object.freeze([]);
45
+ const EMPTY_CHAIN = Object.freeze([]);
46
+ function readStateOf(result) {
47
+ if (result === null)
48
+ return idleReadState();
49
+ return {
50
+ pending: result.pending,
51
+ error: result.error,
52
+ live: result.live,
53
+ seq: result.seq,
54
+ refetch: result.refetch,
55
+ };
56
+ }
@@ -0,0 +1,4 @@
1
+ import type { NavLocation } from '../location';
2
+ /** The nearest scope's live location. Throws outside any {@link NavScope}. */
3
+ export declare function useLocation(): NavLocation;
4
+ //# sourceMappingURL=location.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.hook.d.ts","sourceRoot":"","sources":["../../../src/navigation/hooks/location.hook.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAK9C,8EAA8E;AAC9E,wBAAgB,WAAW,IAAI,WAAW,CAQzC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * useLocation (API §8.2) — the nearest scope's live, id-anchored location (live
3
+ * path/node, missing flag). Throws outside any {@link NavScope}.
4
+ */
5
+ import { useMemo } from 'react';
6
+ import { buildLocation, useSettled } from '../location';
7
+ import { useHistoryVersion, useNavCtx, useMemoryShape } from '../scope.context';
8
+ /** The nearest scope's live location. Throws outside any {@link NavScope}. */
9
+ export function useLocation() {
10
+ const ctx = useNavCtx();
11
+ useHistoryVersion(ctx.history);
12
+ const entry = ctx.history.current;
13
+ const shape = entry?.node ?? null;
14
+ const result = useMemoryShape(ctx.memory, shape);
15
+ const settled = useSettled(result, shape);
16
+ return useMemo(() => buildLocation(entry, result, settled), [entry, result, settled]);
17
+ }
@@ -0,0 +1,12 @@
1
+ import type { NavCtx, Navigate } from '../scope.context';
2
+ /** The nearest scope's imperative navigation surface. Throws outside a scope. */
3
+ export declare function useNavigate(): Navigate;
4
+ /**
5
+ * A per-consumer navigate handle with fresh `canBack`/`canForward`, delegating to
6
+ * the scope's ONE stable callable. Render-pure: it never mutates the shared
7
+ * callable during render (a concurrent render could otherwise read flags from a
8
+ * newer history version than its own snapshot). The wrapper's identity changes
9
+ * only when navigation availability changes.
10
+ */
11
+ export declare function useNavigateHandle(ctx: NavCtx): Navigate;
12
+ //# sourceMappingURL=navigate.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigate.hook.d.ts","sourceRoot":"","sources":["../../../src/navigation/hooks/navigate.hook.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAmB,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAIzE,iFAAiF;AACjF,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAQvD"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * useNavigate (API §8.2) — the nearest scope's imperative navigation surface
3
+ * (back/forward/up + live canBack/canForward, wrapped in transitions). A
4
+ * per-consumer handle that delegates to the scope's ONE stable callable.
5
+ */
6
+ import { useMemo } from 'react';
7
+ import { useHistoryVersion, useNavCtx } from '../scope.context';
8
+ /** The nearest scope's imperative navigation surface. Throws outside a scope. */
9
+ export function useNavigate() {
10
+ return useNavigateHandle(useNavCtx());
11
+ }
12
+ /**
13
+ * A per-consumer navigate handle with fresh `canBack`/`canForward`, delegating to
14
+ * the scope's ONE stable callable. Render-pure: it never mutates the shared
15
+ * callable during render (a concurrent render could otherwise read flags from a
16
+ * newer history version than its own snapshot). The wrapper's identity changes
17
+ * only when navigation availability changes.
18
+ */
19
+ export function useNavigateHandle(ctx) {
20
+ useHistoryVersion(ctx.history);
21
+ const canBack = ctx.history.canBack;
22
+ const canForward = ctx.history.canForward;
23
+ return useMemo(() => wrapNavigate(ctx.navigate, canBack, canForward), [ctx.navigate, canBack, canForward]);
24
+ }
25
+ function wrapNavigate(base, canBack, canForward) {
26
+ const fn = ((to, opts) => base(to, opts));
27
+ fn.back = base.back;
28
+ fn.forward = base.forward;
29
+ fn.up = base.up;
30
+ fn.canBack = canBack;
31
+ fn.canForward = canForward;
32
+ return fn;
33
+ }
@@ -0,0 +1,12 @@
1
+ import type { NavSnapshot } from '../history';
2
+ import type { NavLocation } from '../location';
3
+ import type { Navigate } from '../scope.context';
4
+ /** The nearest scope, for chrome/persistence (API §8.2). */
5
+ export interface NavScopeHandle {
6
+ readonly location: NavLocation;
7
+ snapshot(): NavSnapshot;
8
+ navigate: Navigate;
9
+ }
10
+ /** The nearest scope, for chrome/persistence (API §8.2). Throws outside a scope. */
11
+ export declare function useNavScope(): NavScopeHandle;
12
+ //# sourceMappingURL=scope.hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.hook.d.ts","sourceRoot":"","sources":["../../../src/navigation/hooks/scope.hook.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAMhD,4DAA4D;AAC5D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,IAAI,WAAW,CAAA;IACvB,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,oFAAoF;AACpF,wBAAgB,WAAW,IAAI,cAAc,CAU5C"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * useNavScope (API §8.2) — the nearest scope, for chrome/persistence: the live
3
+ * location, a `snapshot()` handle, and the imperative navigate. Throws outside a
4
+ * scope.
5
+ */
6
+ import { useCallback, useMemo } from 'react';
7
+ import { buildLocation, useSettled } from '../location';
8
+ import { useNavCtx, useMemoryShape } from '../scope.context';
9
+ import { useNavigateHandle } from './navigate.hook';
10
+ /** The nearest scope, for chrome/persistence (API §8.2). Throws outside a scope. */
11
+ export function useNavScope() {
12
+ const ctx = useNavCtx();
13
+ const navigate = useNavigateHandle(ctx);
14
+ const entry = ctx.history.current;
15
+ const shape = entry?.node ?? null;
16
+ const result = useMemoryShape(ctx.memory, shape);
17
+ const settled = useSettled(result, shape);
18
+ const location = useMemo(() => buildLocation(entry, result, settled), [entry, result, settled]);
19
+ const snapshot = useCallback(() => ctx.history.snapshot(), [ctx.history]);
20
+ return { location, snapshot, navigate };
21
+ }
@@ -0,0 +1,16 @@
1
+ export { NavScope } from './scope.context';
2
+ export type { MissingPolicy, NavScopeProps, Navigate } from './scope.context';
3
+ export { useLocation } from './hooks/location.hook';
4
+ export { useNavigate } from './hooks/navigate.hook';
5
+ export { useAncestors } from './hooks/ancestors.hook';
6
+ export { useNavScope } from './hooks/scope.hook';
7
+ export type { NavScopeHandle } from './hooks/scope.hook';
8
+ export { Link } from './link';
9
+ export type { LinkProps } from './link';
10
+ export { memoryAdapter } from './adapters/memory.adapter';
11
+ export { urlAdapter } from './adapters/url.adapter';
12
+ export type { NavAdapter } from './adapters/adapter';
13
+ export type { NavLocation } from './location';
14
+ export type { NavSnapshot, SerializedLocation } from './history';
15
+ export type { NavTarget } from './snapshot';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAChE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,10 @@
1
+ // navigation — API §8 (NavScope, useLocation, useNavigate, Link, useAncestors,
2
+ // useNavScope, adapters). See SHELL_REACT_API.md.
3
+ export { NavScope } from './scope.context';
4
+ export { useLocation } from './hooks/location.hook';
5
+ export { useNavigate } from './hooks/navigate.hook';
6
+ export { useAncestors } from './hooks/ancestors.hook';
7
+ export { useNavScope } from './hooks/scope.hook';
8
+ export { Link } from './link';
9
+ export { memoryAdapter } from './adapters/memory.adapter';
10
+ export { urlAdapter } from './adapters/url.adapter';
@@ -0,0 +1,11 @@
1
+ import type { AnchorHTMLAttributes, ReactElement, ReactNode } from 'react';
2
+ import type { NavTarget } from './snapshot';
3
+ export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
4
+ to: NavTarget;
5
+ replace?: boolean;
6
+ /** Warm the target shape ahead of navigation. Default `'intent'`. */
7
+ prefetch?: 'intent' | 'render' | false;
8
+ children: ReactNode;
9
+ }
10
+ export declare function Link(props: LinkProps): ReactElement;
11
+ //# sourceMappingURL=link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/navigation/link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAKpB,YAAY,EACZ,SAAS,EACV,MAAM,OAAO,CAAA;AAUd,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAK3C,MAAM,WAAW,SAAU,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACxE,EAAE,EAAE,SAAS,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAA;IACtC,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,CA8EnD"}
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Link (API §8.2) — navigates the nearest scope. Renders `<a href>` when the
4
+ * scope's adapter exposes a URL form (cmd/ctrl/middle-click then falls through
5
+ * to the browser), else an href-less `<a role="link">` with identical behavior.
6
+ * Default prefetch `'intent'` warms the target shape on hover/pointer-down/focus.
7
+ */
8
+ import { useCallback, useEffect } from 'react';
9
+ import { useNavCtx } from './scope.context';
10
+ import { serializeTarget } from './snapshot';
11
+ export function Link(props) {
12
+ const { to, replace, prefetch = 'intent', children, onClick, onPointerEnter, onPointerDown, onFocus, onKeyDown, ...rest } = props;
13
+ const ctx = useNavCtx();
14
+ const target = serializeTarget(to);
15
+ const href = ctx.adapter.href?.(target);
16
+ const nodeRef = target.node;
17
+ const preload = useCallback(() => {
18
+ void ctx.memory?.preload(nodeRef);
19
+ }, [ctx.memory, nodeRef]);
20
+ useEffect(() => {
21
+ if (prefetch === 'render')
22
+ preload();
23
+ }, [prefetch, preload]);
24
+ const intent = useCallback(() => {
25
+ if (prefetch === 'intent')
26
+ preload();
27
+ }, [prefetch, preload]);
28
+ const go = useCallback(() => ctx.navigate(to, { replace }), [ctx, to, replace]);
29
+ const handleClick = (e) => {
30
+ onClick?.(e);
31
+ if (e.defaultPrevented)
32
+ return;
33
+ const modified = e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0;
34
+ if (href !== undefined && modified)
35
+ return; // let the browser open it (new tab / window)
36
+ e.preventDefault();
37
+ go();
38
+ };
39
+ const handleKeyDown = (e) => {
40
+ onKeyDown?.(e);
41
+ if (e.defaultPrevented || href !== undefined)
42
+ return; // a real anchor handles Enter itself
43
+ if (e.key === 'Enter' || e.key === ' ') {
44
+ e.preventDefault();
45
+ go();
46
+ }
47
+ };
48
+ const handlePointerEnter = (e) => {
49
+ onPointerEnter?.(e);
50
+ intent();
51
+ };
52
+ const handlePointerDown = (e) => {
53
+ onPointerDown?.(e);
54
+ intent();
55
+ };
56
+ const handleFocus = (e) => {
57
+ onFocus?.(e);
58
+ intent();
59
+ };
60
+ const linkRole = href !== undefined ? { href } : { role: 'link', tabIndex: rest.tabIndex ?? 0 };
61
+ return (_jsx("a", { ...rest, ...linkRole, onClick: handleClick, onKeyDown: handleKeyDown, onPointerEnter: handlePointerEnter, onPointerDown: handlePointerDown, onFocus: handleFocus, children: children }));
62
+ }