@jimka/typescript-ui 0.2.0 → 0.4.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 (251) hide show
  1. package/README.md +4 -0
  2. package/THIRD-PARTY-NOTICES.md +7 -3
  3. package/dist/lib/{AbstractBooleanInput-BGesvIZy.js → AbstractBooleanInput-DSwKBAic.js} +2 -2
  4. package/dist/lib/{AbstractBooleanInput-BGesvIZy.js.map → AbstractBooleanInput-DSwKBAic.js.map} +1 -1
  5. package/dist/lib/{AbstractInput-BxOtFrER.js → AbstractInput-BmWGJTs1.js} +2 -2
  6. package/dist/lib/{AbstractInput-BxOtFrER.js.map → AbstractInput-BmWGJTs1.js.map} +1 -1
  7. package/dist/lib/AnchorConstraints-CVrMP9rz.js +2 -0
  8. package/dist/lib/AnchorConstraints-CVrMP9rz.js.map +1 -0
  9. package/dist/lib/{AnimatedDropdown-CZQEqQi-.js → AnimatedDropdown-DKas40B-.js} +2 -2
  10. package/dist/lib/{AnimatedDropdown-CZQEqQi-.js.map → AnimatedDropdown-DKas40B-.js.map} +1 -1
  11. package/dist/lib/Border-Bz29z-_7.js +2 -0
  12. package/dist/lib/Border-Bz29z-_7.js.map +1 -0
  13. package/dist/lib/Button-bjpWruNc.js +2 -0
  14. package/dist/lib/{Button-U1rsP4v8.js.map → Button-bjpWruNc.js.map} +1 -1
  15. package/dist/lib/{Card-BVwOS8AG.js → Card-BdfbvOD_.js} +2 -2
  16. package/dist/lib/{Card-BVwOS8AG.js.map → Card-BdfbvOD_.js.map} +1 -1
  17. package/dist/lib/ComboBox-CBw2VLLN.js +2 -0
  18. package/dist/lib/ComboBox-CBw2VLLN.js.map +1 -0
  19. package/dist/lib/Component-DHqrPwAw.js +2 -0
  20. package/dist/lib/Component-DHqrPwAw.js.map +1 -0
  21. package/dist/lib/Container-CAQpj4yb.js +2 -0
  22. package/dist/lib/{Container-D5H8VxJK.js.map → Container-CAQpj4yb.js.map} +1 -1
  23. package/dist/lib/DOM-67StIm5G.js +2 -0
  24. package/dist/lib/DOM-67StIm5G.js.map +1 -0
  25. package/dist/lib/DragChain-CYGuT7OA.js +2 -0
  26. package/dist/lib/DragChain-CYGuT7OA.js.map +1 -0
  27. package/dist/lib/DragManager-CHWCe3-8.js +2 -0
  28. package/dist/lib/DragManager-CHWCe3-8.js.map +1 -0
  29. package/dist/lib/{FieldDecorator-CJs9gwqH.js → FieldDecorator-CgAGcqCk.js} +2 -2
  30. package/dist/lib/{FieldDecorator-CJs9gwqH.js.map → FieldDecorator-CgAGcqCk.js.map} +1 -1
  31. package/dist/lib/{Fit-DjRsiwlg.js → Fit-DIYt2aQB.js} +2 -2
  32. package/dist/lib/{Fit-DjRsiwlg.js.map → Fit-DIYt2aQB.js.map} +1 -1
  33. package/dist/lib/Glyph-CeAIWyPB.js +2 -0
  34. package/dist/lib/Glyph-CeAIWyPB.js.map +1 -0
  35. package/dist/lib/{Grid-DdL9TVeJ.js → Grid-ViA0joow.js} +2 -2
  36. package/dist/lib/{Grid-DdL9TVeJ.js.map → Grid-ViA0joow.js.map} +1 -1
  37. package/dist/lib/GridConstraints-B1rxCw9B.js +2 -0
  38. package/dist/lib/GridConstraints-B1rxCw9B.js.map +1 -0
  39. package/dist/lib/Header-mKaqgfat.js +2 -0
  40. package/dist/lib/Header-mKaqgfat.js.map +1 -0
  41. package/dist/lib/IconText-BqwXA82-.js +2 -0
  42. package/dist/lib/IconText-BqwXA82-.js.map +1 -0
  43. package/dist/lib/{LayoutSerialization-BT66TY83.js → LayoutSerialization-D82UtnDD.js} +2 -2
  44. package/dist/lib/{LayoutSerialization-BT66TY83.js.map → LayoutSerialization-D82UtnDD.js.map} +1 -1
  45. package/dist/lib/LayoutSizes-DG9aW9k6.js +2 -0
  46. package/dist/lib/LayoutSizes-DG9aW9k6.js.map +1 -0
  47. package/dist/lib/List-CUntS8ux.js +2 -0
  48. package/dist/lib/List-CUntS8ux.js.map +1 -0
  49. package/dist/lib/MemoryStore-DT6iWWco.js +2 -0
  50. package/dist/lib/MemoryStore-DT6iWWco.js.map +1 -0
  51. package/dist/lib/Menu-B_-SQj72.js +2 -0
  52. package/dist/lib/Menu-B_-SQj72.js.map +1 -0
  53. package/dist/lib/{MenuButton-VJ5uC3c1.js → MenuButton-C79l8Ysf.js} +2 -2
  54. package/dist/lib/{MenuButton-VJ5uC3c1.js.map → MenuButton-C79l8Ysf.js.map} +1 -1
  55. package/dist/lib/{Panel-DzWdYwq1.js → Panel-D2X33qR6.js} +2 -2
  56. package/dist/lib/{Panel-DzWdYwq1.js.map → Panel-D2X33qR6.js.map} +1 -1
  57. package/dist/lib/Position-Ck_KD4cR.js +2 -0
  58. package/dist/lib/Position-Ck_KD4cR.js.map +1 -0
  59. package/dist/lib/{ProgressSpinner-zJKtGyNJ.js → ProgressSpinner-DCyq02pd.js} +2 -2
  60. package/dist/lib/{ProgressSpinner-zJKtGyNJ.js.map → ProgressSpinner-DCyq02pd.js.map} +1 -1
  61. package/dist/lib/{RadioButton-CYSSv4nV.js → RadioButton-BJIAQkII.js} +2 -2
  62. package/dist/lib/{RadioButton-CYSSv4nV.js.map → RadioButton-BJIAQkII.js.map} +1 -1
  63. package/dist/lib/{RovingTabIndex-BSZ31Vp5.js → RovingTabIndex-DFJyoveq.js} +2 -2
  64. package/dist/lib/{RovingTabIndex-BSZ31Vp5.js.map → RovingTabIndex-DFJyoveq.js.map} +1 -1
  65. package/dist/lib/Scrollbar-CSFK-Y57.js +2 -0
  66. package/dist/lib/Scrollbar-CSFK-Y57.js.map +1 -0
  67. package/dist/lib/Slider-C-kQQYCj.js +2 -0
  68. package/dist/lib/Slider-C-kQQYCj.js.map +1 -0
  69. package/dist/lib/{Spacer-D9NGW4QG.js → Spacer-D159iJy9.js} +2 -2
  70. package/dist/lib/{Spacer-D9NGW4QG.js.map → Spacer-D159iJy9.js.map} +1 -1
  71. package/dist/lib/TabButton-CHkXBgCj.js +2 -0
  72. package/dist/lib/TabButton-CHkXBgCj.js.map +1 -0
  73. package/dist/lib/Text-D5pg7taZ.js +2 -0
  74. package/dist/lib/Text-D5pg7taZ.js.map +1 -0
  75. package/dist/lib/Tooltip-DzK6LxUt.js +3 -0
  76. package/dist/lib/{Tooltip-tkXDk5Bo.js.map → Tooltip-DzK6LxUt.js.map} +1 -1
  77. package/dist/lib/VBox-BNegDPs_.js +2 -0
  78. package/dist/lib/VBox-BNegDPs_.js.map +1 -0
  79. package/dist/lib/VirtualScroller-zQr-vKrO.js +2 -0
  80. package/dist/lib/VirtualScroller-zQr-vKrO.js.map +1 -0
  81. package/dist/lib/component/button.es.js +1 -1
  82. package/dist/lib/component/chart.es.js +1 -1
  83. package/dist/lib/component/chart.es.js.map +1 -1
  84. package/dist/lib/component/container.es.js +1 -1
  85. package/dist/lib/component/container.es.js.map +1 -1
  86. package/dist/lib/component/diagram.es.js +1 -1
  87. package/dist/lib/component/diagram.es.js.map +1 -1
  88. package/dist/lib/component/display.es.js +1 -1
  89. package/dist/lib/component/display.es.js.map +1 -1
  90. package/dist/lib/component/editor.es.js +3 -3
  91. package/dist/lib/component/editor.es.js.map +1 -1
  92. package/dist/lib/component/input.es.js +1 -1
  93. package/dist/lib/component/input.es.js.map +1 -1
  94. package/dist/lib/component/list.es.js +1 -1
  95. package/dist/lib/component/list.es.js.map +1 -1
  96. package/dist/lib/component/menubar.es.js +1 -1
  97. package/dist/lib/component/menubar.es.js.map +1 -1
  98. package/dist/lib/component/table.es.js +2 -2
  99. package/dist/lib/component/table.es.js.map +1 -1
  100. package/dist/lib/component/tree.es.js +1 -1
  101. package/dist/lib/component/tree.es.js.map +1 -1
  102. package/dist/lib/core.es.js +1 -1
  103. package/dist/lib/core.es.js.map +1 -1
  104. package/dist/lib/data.es.js +1 -1
  105. package/dist/lib/data.es.js.map +1 -1
  106. package/dist/lib/glyphs/solid/index.es.js +1 -1
  107. package/dist/lib/layout.es.js +1 -1
  108. package/dist/lib/layout.es.js.map +1 -1
  109. package/dist/lib/overlay.es.js +1 -1
  110. package/dist/lib/overlay.es.js.map +1 -1
  111. package/dist/lib/primitive.es.js +1 -1
  112. package/dist/lib/router.es.js +1 -1
  113. package/dist/lib/router.es.js.map +1 -1
  114. package/dist/lib/selectionsEqual-4r5R7pTK.js +2 -0
  115. package/dist/lib/selectionsEqual-4r5R7pTK.js.map +1 -0
  116. package/dist/lib/types/component/button/TabCloseButton.d.ts +1 -1
  117. package/dist/lib/types/component/container/CollapseButton.d.ts +1 -1
  118. package/dist/lib/types/component/container/DialogBackdrop.d.ts +1 -1
  119. package/dist/lib/types/component/container/MenuItem.d.ts +4 -0
  120. package/dist/lib/types/component/container/MenuSeparator.d.ts +1 -1
  121. package/dist/lib/types/component/container/Scrollbar.d.ts +1 -0
  122. package/dist/lib/types/component/container/SplitGutter.d.ts +2 -2
  123. package/dist/lib/types/component/container/StatusBar.d.ts +1 -1
  124. package/dist/lib/types/component/container/VirtualScroller.d.ts +1 -0
  125. package/dist/lib/types/component/container/WindowBorder.d.ts +1 -1
  126. package/dist/lib/types/component/diagram/DiagramEdgeLayer.d.ts +14 -1
  127. package/dist/lib/types/component/diagram/DiagramModel.d.ts +1 -0
  128. package/dist/lib/types/component/diagram/DiagramNode.d.ts +5 -1
  129. package/dist/lib/types/component/diagram/DiagramView.d.ts +76 -5
  130. package/dist/lib/types/component/diagram/ElkLayoutEngine.d.ts +14 -1
  131. package/dist/lib/types/component/diagram/index.d.ts +2 -2
  132. package/dist/lib/types/component/display/Canvas.d.ts +8 -2
  133. package/dist/lib/types/component/display/Glyph.d.ts +2 -1
  134. package/dist/lib/types/component/display/Header.d.ts +1 -1
  135. package/dist/lib/types/component/display/IconLabel.d.ts +1 -1
  136. package/dist/lib/types/component/display/IconText.d.ts +1 -1
  137. package/dist/lib/types/component/display/Image.d.ts +1 -1
  138. package/dist/lib/types/component/display/Video.d.ts +1 -1
  139. package/dist/lib/types/component/display/WebGLCanvas.d.ts +8 -2
  140. package/dist/lib/types/component/editor/CodeEditor.d.ts +4 -3
  141. package/dist/lib/types/component/input/AbstractPickerField.d.ts +1 -1
  142. package/dist/lib/types/component/input/AutoCompleteDropdown.d.ts +1 -1
  143. package/dist/lib/types/component/input/Link.d.ts +1 -1
  144. package/dist/lib/types/component/input/NumberSpinner.d.ts +1 -1
  145. package/dist/lib/types/component/input/PasswordField.d.ts +1 -1
  146. package/dist/lib/types/component/input/SpinButton.d.ts +1 -1
  147. package/dist/lib/types/component/input/Text.d.ts +3 -1
  148. package/dist/lib/types/component/input/TextArea.d.ts +1 -1
  149. package/dist/lib/types/component/input/TextField.d.ts +3 -1
  150. package/dist/lib/types/component/input/UsernameField.d.ts +1 -1
  151. package/dist/lib/types/component/list/AbstractMarkerList.d.ts +9 -1
  152. package/dist/lib/types/component/list/BulletedList.d.ts +1 -0
  153. package/dist/lib/types/component/list/ListItem.d.ts +10 -4
  154. package/dist/lib/types/component/list/NumberedList.d.ts +1 -0
  155. package/dist/lib/types/component/menubar/MenuBarButton.d.ts +1 -1
  156. package/dist/lib/types/component/menubar/ToolBar.d.ts +1 -1
  157. package/dist/lib/types/component/menubar/ToolBarSeparator.d.ts +1 -1
  158. package/dist/lib/types/component/shared/VirtualRowView.d.ts +13 -1
  159. package/dist/lib/types/component/shared/selectionsEqual.d.ts +1 -0
  160. package/dist/lib/types/component/table/Body.d.ts +15 -2
  161. package/dist/lib/types/component/table/CellGeometry.d.ts +6 -0
  162. package/dist/lib/types/component/table/Column.d.ts +6 -0
  163. package/dist/lib/types/component/table/ColumnConfig.d.ts +4 -0
  164. package/dist/lib/types/component/table/Header.d.ts +25 -2
  165. package/dist/lib/types/component/table/Row.d.ts +13 -2
  166. package/dist/lib/types/component/table/Table.d.ts +45 -4
  167. package/dist/lib/types/component/table/TableExporter.d.ts +1 -1
  168. package/dist/lib/types/component/table/TablePanel.d.ts +2 -1
  169. package/dist/lib/types/component/table/cell/Cell.d.ts +1 -1
  170. package/dist/lib/types/component/table/cell/Header.d.ts +4 -0
  171. package/dist/lib/types/component/table/index.d.ts +2 -2
  172. package/dist/lib/types/component/tree/Tree.d.ts +2 -0
  173. package/dist/lib/types/core/Aria.d.ts +1 -3
  174. package/dist/lib/types/core/Body.d.ts +9 -2
  175. package/dist/lib/types/core/ClassStyleRules.d.ts +17 -0
  176. package/dist/lib/types/core/Component.d.ts +16 -2
  177. package/dist/lib/types/core/ComponentDefaults.d.ts +1 -0
  178. package/dist/lib/types/core/DOM.d.ts +15 -2
  179. package/dist/lib/types/core/DragChain.d.ts +3 -0
  180. package/dist/lib/types/core/ElementAttributes.d.ts +15 -0
  181. package/dist/lib/types/core/Favicon.d.ts +7 -0
  182. package/dist/lib/types/core/FirstLayoutGate.d.ts +5 -0
  183. package/dist/lib/types/core/PendingTransitions.d.ts +4 -0
  184. package/dist/lib/types/core/StyleTarget.d.ts +1 -0
  185. package/dist/lib/types/core/Theme.d.ts +1 -0
  186. package/dist/lib/types/core/Util.d.ts +3 -0
  187. package/dist/lib/types/core/index.d.ts +3 -0
  188. package/dist/lib/types/layout/Accordion.d.ts +0 -1
  189. package/dist/lib/types/layout/Border.d.ts +1 -0
  190. package/dist/lib/types/layout/FlowLayout.d.ts +4 -0
  191. package/dist/lib/types/layout/HFlow.d.ts +3 -0
  192. package/dist/lib/types/layout/Tab.d.ts +4 -1
  193. package/dist/lib/types/layout/Table.d.ts +1 -0
  194. package/dist/lib/types/layout/VFlow.d.ts +1 -0
  195. package/dist/lib/types/overlay/AbstractWindow.d.ts +2 -1
  196. package/dist/lib/types/overlay/Dock.d.ts +1 -0
  197. package/dist/lib/types/overlay/DropZoneOverlay.d.ts +1 -0
  198. package/dist/lib/types/overlay/Popover.d.ts +1 -1
  199. package/dist/lib/types/router/RoutePattern.d.ts +7 -0
  200. package/dist/lib/types/router/Router.d.ts +13 -2
  201. package/dist/lib/types/router/index.d.ts +1 -1
  202. package/dist/lib/validation.es.js +1 -1
  203. package/llms.txt +2 -1
  204. package/package.json +5 -9
  205. package/dist/lib/Border-BgaZkc1R.js +0 -2
  206. package/dist/lib/Border-BgaZkc1R.js.map +0 -1
  207. package/dist/lib/BoxLayout-DrKGfsup.js +0 -2
  208. package/dist/lib/BoxLayout-DrKGfsup.js.map +0 -1
  209. package/dist/lib/Button-U1rsP4v8.js +0 -2
  210. package/dist/lib/ComboBox-B9EDPu6T.js +0 -2
  211. package/dist/lib/ComboBox-B9EDPu6T.js.map +0 -1
  212. package/dist/lib/Component-DXf5a3g0.js +0 -2
  213. package/dist/lib/Component-DXf5a3g0.js.map +0 -1
  214. package/dist/lib/Container-D5H8VxJK.js +0 -2
  215. package/dist/lib/DOM-CGn7xyTw.js +0 -2
  216. package/dist/lib/DOM-CGn7xyTw.js.map +0 -1
  217. package/dist/lib/DragManager-CI4mZQFy.js +0 -2
  218. package/dist/lib/DragManager-CI4mZQFy.js.map +0 -1
  219. package/dist/lib/Glyph-KEf4nIv2.js +0 -2
  220. package/dist/lib/Glyph-KEf4nIv2.js.map +0 -1
  221. package/dist/lib/GridConstraints-DkLueyrf.js +0 -2
  222. package/dist/lib/GridConstraints-DkLueyrf.js.map +0 -1
  223. package/dist/lib/HBox-Ce0GTCJP.js +0 -2
  224. package/dist/lib/HBox-Ce0GTCJP.js.map +0 -1
  225. package/dist/lib/Header-BQIVpBte.js +0 -2
  226. package/dist/lib/Header-BQIVpBte.js.map +0 -1
  227. package/dist/lib/IconText-Bo4Qcnot.js +0 -2
  228. package/dist/lib/IconText-Bo4Qcnot.js.map +0 -1
  229. package/dist/lib/LayoutSizes-DU3qSq0w.js +0 -2
  230. package/dist/lib/LayoutSizes-DU3qSq0w.js.map +0 -1
  231. package/dist/lib/List-DtTVTyWW.js +0 -2
  232. package/dist/lib/List-DtTVTyWW.js.map +0 -1
  233. package/dist/lib/Menu-Dz4L7EKJ.js +0 -2
  234. package/dist/lib/Menu-Dz4L7EKJ.js.map +0 -1
  235. package/dist/lib/Position-A39T7-_1.js +0 -2
  236. package/dist/lib/Position-A39T7-_1.js.map +0 -1
  237. package/dist/lib/Scrollbar-BhtOjqkG.js +0 -2
  238. package/dist/lib/Scrollbar-BhtOjqkG.js.map +0 -1
  239. package/dist/lib/Slider-CdXm7E64.js +0 -2
  240. package/dist/lib/Slider-CdXm7E64.js.map +0 -1
  241. package/dist/lib/TabButton-CThevdY_.js +0 -2
  242. package/dist/lib/TabButton-CThevdY_.js.map +0 -1
  243. package/dist/lib/Text-gz6qjFfP.js +0 -2
  244. package/dist/lib/Text-gz6qjFfP.js.map +0 -1
  245. package/dist/lib/Tooltip-tkXDk5Bo.js +0 -3
  246. package/dist/lib/VBox-EIqw85Rh.js +0 -2
  247. package/dist/lib/VBox-EIqw85Rh.js.map +0 -1
  248. package/dist/lib/VirtualRowView-BxpHQ_u8.js +0 -2
  249. package/dist/lib/VirtualRowView-BxpHQ_u8.js.map +0 -1
  250. package/dist/lib/VirtualScroller-DwEEJE1_.js +0 -2
  251. package/dist/lib/VirtualScroller-DwEEJE1_.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./Position-A39T7-_1.js";import{t as c}from"./Placement-7kqdaK4Z.js";var Point=class extends t{_x;_y;constructor(e,t){super(),this._x=e??0,this._y=t??0}getX(){return this._x??0}getY(){return this._y??0}render(){return this.getX()+` `+this.getY()}};export{r as Insets,c as Placement,Point,s as Position,e as UNBOUNDED,a as borderSideWidth,n as borderToStyle,i as isUnbounded,o as saturate};
1
+ import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./Position-Ck_KD4cR.js";import{t as c}from"./Placement-7kqdaK4Z.js";var Point=class extends t{_x;_y;constructor(e,t){super(),this._x=e??0,this._y=t??0}getX(){return this._x??0}getY(){return this._y??0}render(){return this.getX()+` `+this.getY()}};export{r as Insets,c as Placement,Point,s as Position,e as UNBOUNDED,a as borderSideWidth,n as borderToStyle,i as isUnbounded,o as saturate};
2
2
  //# sourceMappingURL=primitive.es.js.map
@@ -1,2 +1,2 @@
1
- import{t as e}from"./DOM-CGn7xyTw.js";import{t}from"./ListenerBag-WPdKuuds.js";function normalizePath(e){let t=e.startsWith(`#`)?e.slice(1):e,n=t.indexOf(`?`);return n>=0&&(t=t.slice(0,n)),`/`+splitPath(t).join(`/`)}function splitPath(e){return e.split(`/`).filter(e=>e.length>0)}function compilePattern(e){let t=normalizePath(e),n=splitPath(t),r=n.map((t,r)=>{if(t===`*`){if(r!==n.length-1)throw Error(`RoutePattern: "*" is only valid as the final segment of "${e}"`);return{kind:`catchAll`,value:``}}return t.startsWith(`:`)?{kind:`param`,value:t.slice(1)}:{kind:`static`,value:t}});return{pattern:t,key:r.map(e=>e.kind===`static`?e.value:e.kind===`param`?`:`:`*`).join(`/`),segments:r}}function matchPattern(e,t){let n=e.segments,r=n.length>0&&n.at(-1).kind===`catchAll`,i=r?n.length-1:n.length;if(r?t.length<i:t.length!==i)return null;let a={};for(let e=0;e<i;e+=1){let r=n[e],i=t[e];if(r.kind===`static`){if(r.value!==i)return null}else r.kind===`param`&&(a[r.value]=decodeSegment(i))}return a}function decodeSegment(e){try{return decodeURIComponent(e)}catch{return e}}var n={static:2,param:1,catchAll:0};function rankAt(e,t){return t>=e.length?3:n[e[t].kind]}function selectPattern(e,t){let n=splitPath(t),r=null,i=null;for(let t of e){let e=matchPattern(t,n);e!==null&&(r===null||isMoreSpecific(t.segments,r.segments))&&(r=t,i=e)}return r===null?null:{compiled:r,params:i}}function isMoreSpecific(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r+=1){let n=rankAt(e,r),i=rankAt(t,r);if(n!==i)return n>i}return!1}var Router=class{_routes=new Map;_listeners=new t;_started=!1;_onHashChange=()=>this.handleHashChange();constructor(e){this.applyOptions(e??{})}register(e,t){let n=compilePattern(e),r=this._routes.get(n.key);return r!==void 0&&r.pattern!==n.pattern&&console.warn(`Router: "${r.pattern}" and "${n.pattern}" have the same specificity; "${n.pattern}" replaces it.`),this._routes.set(n.key,{...n,handler:t}),this}start(){return this._started?(console.warn(`Router: start() called on an already-started router; ignoring.`),this):(this._started=!0,this.applyCurrentRoute(),e.sink.addListener(e.source.getWindow(),`hashchange`,this._onHashChange),this)}stop(){return this._started?(e.sink.removeListener(e.source.getWindow(),`hashchange`,this._onHashChange),this._started=!1,this):this}navigate(t,n){let r=`#/`+splitPath(normalizePath(t)).map(e=>encodeURIComponent(e)).join(`/`);return n?.replace===!0?e.sink.replaceLocationHash(r):e.sink.setLocationHash(r),this}getPath(){return normalizePath(e.source.getLocationHash())}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,t){this._listeners.fire(e,t)}applyCurrentRoute(){let e=this.getPath(),t=selectPattern(Array.from(this._routes.values()),e);if(t===null){this.emit(`nomatch`,e);return}let n={pattern:t.compiled.pattern,params:t.params,path:e};t.compiled.handler(t.params,e),this.emit(`navigate`,n)}applyOptions(e){if(e.routes!==void 0)for(let t of Object.keys(e.routes))this.register(t,e.routes[t]);if(e.listeners!==void 0)for(let t of Object.keys(e.listeners)){let n=e.listeners[t];n!==void 0&&this._listeners.add(t,n)}}handleHashChange(){this.applyCurrentRoute()}};export{Router};
1
+ import{t as e}from"./DOM-67StIm5G.js";import{t}from"./ListenerBag-WPdKuuds.js";function normalizePath(e){let t=e.startsWith(`#`)?e.slice(1):e,n=t.indexOf(`?`);return n>=0&&(t=t.slice(0,n)),`/`+splitPath(t).join(`/`)}function splitPath(e){return e.split(`/`).filter(e=>e.length>0)}function splitFragment(e){let t=e.indexOf(`#`);return t===-1?{path:e,fragment:``}:{path:e.slice(0,t),fragment:e.slice(t+1)}}function normalizeBase(e){let t=splitPath(e);return t.length===0?`/`:`/`+t.join(`/`)+`/`}function stripBase(e,t){let n=normalizeBase(e).slice(0,-1);return n!==``&&(t===n||t.startsWith(n+`/`))?normalizePath(t.slice(n.length)):normalizePath(t)}function joinBase(e,t){let n=normalizeBase(e),r=normalizePath(t);return r===`/`?n:n.slice(0,-1)+r}function compilePattern(e){let t=normalizePath(e),n=splitPath(t),r=n.map((t,r)=>{if(t===`*`){if(r!==n.length-1)throw Error(`RoutePattern: "*" is only valid as the final segment of "${e}"`);return{kind:`catchAll`,value:``}}return t.startsWith(`:`)?{kind:`param`,value:t.slice(1)}:{kind:`static`,value:t}});return{pattern:t,key:r.map(e=>e.kind===`static`?e.value:e.kind===`param`?`:`:`*`).join(`/`),segments:r}}function matchPattern(e,t){let n=e.segments,r=n.length>0&&n.at(-1).kind===`catchAll`,i=r?n.length-1:n.length;if(r?t.length<i:t.length!==i)return null;let a={};for(let e=0;e<i;e+=1){let r=n[e],i=t[e];if(r.kind===`static`){if(r.value!==i)return null}else r.kind===`param`&&(a[r.value]=decodeSegment(i))}return a}function decodeSegment(e){try{return decodeURIComponent(e)}catch{return e}}var n={static:2,param:1,catchAll:0};function rankAt(e,t){return t>=e.length?3:n[e[t].kind]}function selectPattern(e,t){let n=splitPath(t),r=null,i=null;for(let t of e){let e=matchPattern(t,n);e!==null&&(r===null||isMoreSpecific(t.segments,r.segments))&&(r=t,i=e)}return r===null?null:{compiled:r,params:i}}function isMoreSpecific(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r+=1){let n=rankAt(e,r),i=rankAt(t,r);if(n!==i)return n>i}return!1}var Router=class{_routes=new Map;_listeners=new t;_started=!1;_mode;_base;_onHashChange=()=>this.handleHashChange();_onPopState=()=>this.handlePopState();constructor(e){this.applyOptions(e??{})}register(e,t){let n=compilePattern(e),r=this._routes.get(n.key);return r!==void 0&&r.pattern!==n.pattern&&console.warn(`Router: "${r.pattern}" and "${n.pattern}" have the same specificity; "${n.pattern}" replaces it.`),this._routes.set(n.key,{...n,handler:t}),this}start(){return this._started?(console.warn(`Router: start() called on an already-started router; ignoring.`),this):(this._started=!0,this.applyCurrentRoute(),this._mode===`history`?e.sink.addListener(e.source.getWindow(),`popstate`,this._onPopState):e.sink.addListener(e.source.getWindow(),`hashchange`,this._onHashChange),this)}stop(){return this._started?(this._mode===`history`?e.sink.removeListener(e.source.getWindow(),`popstate`,this._onPopState):e.sink.removeListener(e.source.getWindow(),`hashchange`,this._onHashChange),this._started=!1,this):this}navigate(t,n){let r=splitFragment(t);if(this._mode===`hash`){let t=`#/`+splitPath(normalizePath(r.path)).map(e=>encodeURIComponent(e)).join(`/`);return n?.replace===!0?e.sink.replaceLocationHash(t):e.sink.setLocationHash(t),this}let i=normalizePath(r.path),a=r.fragment;if(i===this.getPath()&&a===this.getFragment())return this;let o=this.getHref(a===``?i:`${i}#${a}`);return n?.replace===!0?e.sink.replaceHistoryPath(o):e.sink.pushHistoryPath(o),this.applyCurrentRoute(),this}getHref(e){let t=splitFragment(e),n=`/`+splitPath(normalizePath(t.path)).map(e=>encodeURIComponent(e)).join(`/`);if(this._mode===`hash`)return`#`+n;let r=joinBase(this._base,n);return t.fragment===``?r:`${r}#${t.fragment}`}getPath(t){if(this._mode===`hash`){let n=t??e.source.getLocationHash();return this.decodePath(normalizePath(n))}let n=t??e.source.getLocationPathname();return this.decodePath(stripBase(this._base,splitFragment(n).path))}getFragment(t){if(this._mode===`hash`)return``;if(t!==void 0)return splitFragment(t).fragment;let n=e.source.getLocationHash();return n.startsWith(`#`)?n.slice(1):n}decodePath(e){return`/`+splitPath(e).map(e=>{try{return decodeURIComponent(e)}catch{return e}}).join(`/`)}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,t){this._listeners.fire(e,t)}applyCurrentRoute(){let e=this.getPath(),t=this.getFragment(),n=selectPattern(Array.from(this._routes.values()),e);if(n===null){this.emit(`nomatch`,e);return}let r={pattern:n.compiled.pattern,params:n.params,path:e,fragment:t};n.compiled.handler(n.params,e,t),this.emit(`navigate`,r)}applyOptions(e){if(this._mode=e.mode??`hash`,this._base=normalizeBase(e.base??`/`),e.routes!==void 0)for(let t of Object.keys(e.routes))this.register(t,e.routes[t]);if(e.listeners!==void 0)for(let t of Object.keys(e.listeners)){let n=e.listeners[t];n!==void 0&&this._listeners.add(t,n)}}handleHashChange(){this.applyCurrentRoute()}handlePopState(){this.applyCurrentRoute()}};export{Router};
2
2
  //# sourceMappingURL=router.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.es.js","names":[],"sources":["../../src/typescript/lib/router/RoutePattern.ts","../../src/typescript/lib/router/Router.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\n// Pure route-pattern mechanics behind Router: normalizing a hash/path,\n// compiling a registered pattern into segments + an ambiguity key, matching a\n// path against a compiled pattern, and picking the most specific match. No\n// DOM seam involved — internal to router/, not exported from the barrel.\n\n/** The kind of a single pattern segment. */\nexport type SegmentKind = \"static\" | \"param\" | \"catchAll\";\n\n/** One segment of a compiled pattern. */\nexport interface RouteSegment {\n kind: SegmentKind;\n /** Literal text for \"static\", the parameter name for \"param\", \"\" for \"catchAll\". */\n value: string;\n}\n\n/** A pattern parsed into segments, plus its ambiguity key. */\nexport interface CompiledPattern {\n /** The pattern string as registered, after normalization (e.g. \"/data/:id\"). */\n pattern: string;\n /** Ambiguity key: static segments by literal, \"param\" as \":\", \"catchAll\" as \"*\". */\n key: string;\n segments: RouteSegment[];\n}\n\n/**\n * Normalizes a hash or path to a leading-slash, no-trailing-slash path: strips\n * a leading `\"#\"`, discards everything from the first `\"?\"` onward, and\n * collapses empty segments (so a doubled `\"//\"` and a trailing `\"/\"` both\n * disappear). `\"\"`, `\"#\"`, and `\"#/\"` all normalize to `\"/\"`.\n *\n * @param input - The raw hash (with or without its leading `\"#\"`) or path.\n * @returns The normalized path.\n */\nexport function normalizePath(input: string): string {\n let path = input.startsWith(\"#\") ? input.slice(1) : input;\n const queryIndex = path.indexOf(\"?\");\n\n if (queryIndex >= 0) {\n path = path.slice(0, queryIndex);\n }\n\n return \"/\" + splitPath(path).join(\"/\");\n}\n\n/**\n * Splits a normalized path into its non-empty segments.\n *\n * @param path - The path to split.\n * @returns The segments, in order.\n */\nexport function splitPath(path: string): string[] {\n return path.split(\"/\").filter((segment) => segment.length > 0);\n}\n\n/**\n * Parses a registered pattern into {@link RouteSegment}s and derives its\n * ambiguity key.\n *\n * @param pattern - The pattern string, e.g. `\"/data/rows/:sel\"`.\n * @returns The compiled pattern.\n * @throws If `\"*\"` appears anywhere but the final segment.\n */\nexport function compilePattern(pattern: string): CompiledPattern {\n const normalized = normalizePath(pattern);\n const rawSegments = splitPath(normalized);\n\n const segments: RouteSegment[] = rawSegments.map((raw, i) => {\n if (raw === \"*\") {\n if (i !== rawSegments.length - 1) {\n throw new Error(`RoutePattern: \"*\" is only valid as the final segment of \"${pattern}\"`);\n }\n\n return { kind: \"catchAll\", value: \"\" };\n }\n\n if (raw.startsWith(\":\")) {\n return { kind: \"param\", value: raw.slice(1) };\n }\n\n return { kind: \"static\", value: raw };\n });\n\n const key = segments\n .map((segment) => segment.kind === \"static\" ? segment.value : segment.kind === \"param\" ? \":\" : \"*\")\n .join(\"/\");\n\n return { pattern: normalized, key, segments };\n}\n\n/**\n * Returns the extracted params when `segments` match `compiled`, or `null`\n * when they don't. A trailing `catchAll` segment matches zero or more\n * remaining segments; every other kind requires an exact segment count.\n * Captured `:param` values run through `decodeURIComponent`, falling back to\n * the raw segment text on a malformed escape.\n *\n * @param compiled - The compiled pattern to match against.\n * @param segments - The candidate path's segments (from {@link splitPath}).\n * @returns The extracted params, or `null` when there is no match.\n */\nexport function matchPattern(compiled: CompiledPattern, segments: string[]): Record<string, string> | null {\n const patternSegments = compiled.segments;\n const isCatchAll = patternSegments.length > 0 && patternSegments.at(-1)!.kind === \"catchAll\";\n const staticLength = isCatchAll ? patternSegments.length - 1 : patternSegments.length;\n\n if (isCatchAll ? segments.length < staticLength : segments.length !== staticLength) {\n return null;\n }\n\n const params: Record<string, string> = {};\n\n for (let i = 0; i < staticLength; i += 1) {\n const patternSegment = patternSegments[i];\n const value = segments[i];\n\n if (patternSegment.kind === \"static\") {\n if (patternSegment.value !== value) {\n return null;\n }\n } else if (patternSegment.kind === \"param\") {\n params[patternSegment.value] = decodeSegment(value);\n }\n }\n\n return params;\n}\n\n/**\n * Decodes a captured path segment, falling back to the raw text when it\n * carries a malformed percent-escape.\n *\n * @param value - The raw segment text.\n * @returns The decoded value, or `value` unchanged on a decode failure.\n */\nfunction decodeSegment(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/** Rank of each real segment kind: higher wins a specificity tie-break. */\nconst KIND_RANK: Record<SegmentKind, number> = { static: 2, param: 1, catchAll: 0 };\n\n/**\n * Rank of position `i` in `segments`. Reaching the end of the pattern (`i` at\n * or past its length) outranks every real segment kind — see\n * {@link selectPattern}.\n *\n * @param segments - The pattern's segments.\n * @param i - The position to rank.\n * @returns The rank at that position.\n */\nfunction rankAt(segments: readonly RouteSegment[], i: number): number {\n return i >= segments.length ? 3 : KIND_RANK[segments[i].kind];\n}\n\n/**\n * Returns the highest-ranked pattern in `compiled` that matches `path`, or\n * `null` when none match. Patterns are compared segment by segment from the\n * left via {@link rankAt}; the first position where two matching patterns\n * differ decides the winner. Two patterns can never tie on every position —\n * that would mean identical ambiguity keys, which the route table (see\n * `Router`) forbids. Registration order never affects the result.\n *\n * @param compiled - The candidate compiled patterns.\n * @param path - The normalized path to match.\n * @returns The winning pattern and its extracted params, or `null`.\n */\nexport function selectPattern<T extends CompiledPattern>(\n compiled: readonly T[],\n path: string,\n): { compiled: T; params: Record<string, string> } | null {\n const segments = splitPath(path);\n\n let best: T | null = null;\n let bestParams: Record<string, string> | null = null;\n\n for (const candidate of compiled) {\n const params = matchPattern(candidate, segments);\n\n if (params === null) {\n continue;\n }\n\n if (best === null || isMoreSpecific(candidate.segments, best.segments)) {\n best = candidate;\n bestParams = params;\n }\n }\n\n return best === null ? null : { compiled: best, params: bestParams! };\n}\n\n/**\n * Whether `a` outranks `b` by {@link rankAt} at the first position where they\n * differ.\n *\n * @param a - The candidate pattern's segments.\n * @param b - The current best pattern's segments.\n * @returns `true` when `a` is more specific than `b`.\n */\nfunction isMoreSpecific(a: readonly RouteSegment[], b: readonly RouteSegment[]): boolean {\n const length = Math.max(a.length, b.length);\n\n for (let i = 0; i < length; i += 1) {\n const rankA = rankAt(a, i);\n const rankB = rankAt(b, i);\n\n if (rankA !== rankB) {\n return rankA > rankB;\n }\n }\n\n return false;\n}\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { DOM } from '~/core/DOM.js';\nimport { ListenerBag } from '~/core/ListenerBag.js';\nimport { compilePattern, normalizePath, splitPath, selectPattern, type CompiledPattern } from '~/router/RoutePattern.js';\n\n/** Params extracted from a matched pattern's `:name` segments. */\nexport type RouteParams = Record<string, string>;\n\n/** A registered route's callback: drives whatever it fronts, never builds it. */\nexport type RouteHandler = (params: RouteParams, path: string) => void;\n\n/** The events a {@link Router} emits. */\nexport type RouterEvent = \"navigate\" | \"nomatch\";\n\n/** The pattern and params a navigation resolved to. */\nexport interface RouteMatch {\n /** The pattern that won, as registered. */\n pattern: string;\n params: RouteParams;\n /** The normalized path that was matched. */\n path: string;\n}\n\n/** Construction options for {@link Router}. */\nexport interface RouterOptions {\n /** Patterns to `register` at construction, keyed by pattern string. */\n routes?: Record<string, RouteHandler>;\n listeners?: Partial<{\n navigate: (match: RouteMatch) => void;\n nomatch: (path: string) => void;\n }>;\n}\n\n/** A registered route: its compiled pattern plus the handler it drives. */\ntype CompiledRoute = CompiledPattern & { handler: RouteHandler };\n\n/**\n * Maps the URL hash to a single top-level app section. Patterns are\n * registered with {@link register} (e.g. `\"/data/rows/:sel\"`); on a\n * navigation, the router selects the most specific matching pattern, extracts\n * its `:param` values, and calls that pattern's handler — the handler drives\n * components that already exist, it never builds them.\n *\n * {@link start} reads the current hash, applies the matching route\n * synchronously, then installs the `hashchange` listener; call it once the\n * app has built its component tree and before the first layout pass runs, so\n * the routed section is already selected when that pass runs. {@link stop}\n * removes the listener.\n *\n * It is a plain class (no DOM element, so not `callable()`-wrapped) — it\n * follows the shape of a data store: an options bag, a private listener bag,\n * and typed `on` / `off` / `emit` forwarders.\n *\n * @category Core\n */\nexport class Router {\n\n private _routes: Map<string, CompiledRoute> = new Map();\n private _listeners: ListenerBag<RouterEvent> = new ListenerBag<RouterEvent>();\n private _started: boolean = false;\n\n // Stable reference so add/remove pair up; delegates to a named method.\n private readonly _onHashChange: () => void = () => this.handleHashChange();\n\n /**\n * @param options - Routes and listeners to register at construction.\n */\n constructor(options?: RouterOptions) {\n this.applyOptions(options ?? {});\n }\n\n /**\n * Registers a pattern's handler. Re-registering the exact same pattern\n * string replaces its handler silently. Registering a *different*\n * pattern string that collides with an already-registered one on\n * specificity (e.g. `\"/users/:id\"` and `\"/users/:name\"`) replaces it too,\n * but logs a warning naming both patterns — that collision usually\n * signals an authoring mistake.\n *\n * @param pattern - The route pattern, e.g. `\"/data/rows/:sel\"`.\n * @param handler - Called with the extracted params and the normalized\n * path when this pattern wins a navigation.\n * @returns This router, for chaining.\n */\n register(pattern: string, handler: RouteHandler): this {\n const compiled = compilePattern(pattern);\n const existing = this._routes.get(compiled.key);\n\n if (existing !== undefined && existing.pattern !== compiled.pattern) {\n console.warn(`Router: \"${existing.pattern}\" and \"${compiled.pattern}\" have the same specificity; \"${compiled.pattern}\" replaces it.`);\n }\n\n this._routes.set(compiled.key, { ...compiled, handler });\n\n return this;\n }\n\n /**\n * Reads the current hash, applies the matching route synchronously, then\n * installs the `hashchange` listener. Calling `start()` again on an\n * already-started router logs a warning and is otherwise a no-op — it\n * does not install a second listener.\n *\n * @returns This router, for chaining.\n */\n start(): this {\n if (this._started) {\n console.warn(`Router: start() called on an already-started router; ignoring.`);\n\n return this;\n }\n\n this._started = true;\n this.applyCurrentRoute();\n DOM.sink.addListener(DOM.source.getWindow(), \"hashchange\", this._onHashChange);\n\n return this;\n }\n\n /**\n * Removes the `hashchange` listener. Safe to call when never started, or\n * more than once.\n *\n * @returns This router, for chaining.\n */\n stop(): this {\n if (!this._started) {\n return this;\n }\n\n DOM.sink.removeListener(DOM.source.getWindow(), \"hashchange\", this._onHashChange);\n this._started = false;\n\n return this;\n }\n\n /**\n * Writes `path` into the hash — pushing a history entry, or replacing the\n * current one when `options.replace` is `true`. Each segment is\n * percent-encoded. Writing the path already in the hash is a same-value\n * write: it fires no `hashchange` and re-runs no handler.\n *\n * @param path - The path to navigate to, e.g. `\"/settings\"`.\n * @param options - `replace` to replace the current history entry instead\n * of pushing a new one.\n * @returns This router, for chaining.\n */\n navigate(path: string, options?: { replace?: boolean }): this {\n const segments = splitPath(normalizePath(path));\n const hash = \"#/\" + segments.map((segment) => encodeURIComponent(segment)).join(\"/\");\n\n if (options?.replace === true) {\n DOM.sink.replaceLocationHash(hash);\n } else {\n DOM.sink.setLocationHash(hash);\n }\n\n return this;\n }\n\n /**\n * The normalized path currently in the hash.\n *\n * @returns The current path.\n */\n getPath(): string {\n return normalizePath(DOM.source.getLocationHash());\n }\n\n on(event: \"navigate\", listener: (match: RouteMatch) => void): this;\n on(event: \"nomatch\", listener: (path: string) => void): this;\n\n /**\n * Subscribes a listener to a router event. Listeners fire in\n * registration order.\n *\n * @param event - The event to listen for.\n * @param listener - The callback to invoke.\n * @returns This router, for chaining.\n */\n on(event: RouterEvent, listener: Function): this {\n this._listeners.add(event, listener);\n\n return this;\n }\n\n /**\n * Removes a previously registered listener. No-op if it was never\n * registered for that event.\n *\n * @param event - The event the listener was registered for.\n * @param listener - The exact callback reference to remove.\n * @returns This router, for chaining.\n */\n off(event: RouterEvent, listener: Function): this {\n this._listeners.remove(event, listener);\n\n return this;\n }\n\n /**\n * Notifies all listeners registered for an event, in registration order.\n *\n * @param event - The event to emit.\n * @param payload - The value passed to each listener.\n */\n protected emit(event: RouterEvent, payload: unknown): void {\n this._listeners.fire(event, payload);\n }\n\n /**\n * Reads the current hash and calls the most specific matching pattern's\n * handler, emitting `\"navigate\"` — or emits `\"nomatch\"` when nothing\n * matches. Shared by {@link start} and the `hashchange` listener.\n */\n private applyCurrentRoute(): void {\n const path = this.getPath();\n const result = selectPattern(Array.from(this._routes.values()), path);\n\n if (result === null) {\n this.emit(\"nomatch\", path);\n\n return;\n }\n\n const match: RouteMatch = { pattern: result.compiled.pattern, params: result.params, path };\n\n result.compiled.handler(result.params, path);\n this.emit(\"navigate\", match);\n }\n\n /**\n * Applies an {@link RouterOptions} bag: registers `routes`, then wires\n * `listeners`. Called from the constructor body, after every field\n * initializer has run.\n *\n * @param options - The options bag to apply.\n */\n protected applyOptions(options: RouterOptions): void {\n if (options.routes !== undefined) {\n for (const pattern of Object.keys(options.routes)) {\n this.register(pattern, options.routes[pattern]);\n }\n }\n\n if (options.listeners !== undefined) {\n for (const event of Object.keys(options.listeners) as RouterEvent[]) {\n const listener = options.listeners[event];\n\n if (listener !== undefined) {\n this._listeners.add(event, listener);\n }\n }\n }\n }\n\n private handleHashChange(): void {\n this.applyCurrentRoute();\n }\n}\n"],"mappings":"+EAmCA,SAAgB,cAAc,EAAuB,CACjD,IAAI,EAAO,EAAM,WAAW,GAAG,EAAI,EAAM,MAAM,CAAC,EAAI,EAC9C,EAAa,EAAK,QAAQ,GAAG,EAMnC,OAJI,GAAc,IACd,EAAO,EAAK,MAAM,EAAG,CAAU,GAG5B,IAAM,UAAU,CAAI,CAAC,CAAC,KAAK,GAAG,CACzC,CAQA,SAAgB,UAAU,EAAwB,CAC9C,OAAO,EAAK,MAAM,GAAG,CAAC,CAAC,OAAQ,GAAY,EAAQ,OAAS,CAAC,CACjE,CAUA,SAAgB,eAAe,EAAkC,CAC7D,IAAM,EAAa,cAAc,CAAO,EAClC,EAAc,UAAU,CAAU,EAElC,EAA2B,EAAY,KAAK,EAAK,IAAM,CACzD,GAAI,IAAQ,IAAK,CACb,GAAI,IAAM,EAAY,OAAS,EAC3B,MAAU,MAAM,4DAA4D,EAAQ,EAAE,EAG1F,MAAO,CAAE,KAAM,WAAY,MAAO,EAAG,CACzC,CAMA,OAJI,EAAI,WAAW,GAAG,EACX,CAAE,KAAM,QAAS,MAAO,EAAI,MAAM,CAAC,CAAE,EAGzC,CAAE,KAAM,SAAU,MAAO,CAAI,CACxC,CAAC,EAMD,MAAO,CAAE,QAAS,EAAY,IAJlB,EACP,IAA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CAAI,EAEjC,EAAI,KAAK,gBAAgB,CAAI,EAG1B,IACX,CAOA,SAAkB,CACd,OAAO,cAAc,EAAI,OAAO,gBAAgB,CAAC,CACrD,CAaA,GAAG,EAAoB,EAA0B,CAG7C,OAFA,KAAK,WAAW,IAAI,EAAO,CAAQ,EAE5B,IACX,CAUA,IAAI,EAAoB,EAA0B,CAG9C,OAFA,KAAK,WAAW,OAAO,EAAO,CAAQ,EAE/B,IACX,CAQA,KAAe,EAAoB,EAAwB,CACvD,KAAK,WAAW,KAAK,EAAO,CAAO,CACvC,CAOA,mBAAkC,CAC9B,IAAM,EAAS,KAAK,QAAQ,EACtB,EAAS,cAAc,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC,EAAG,CAAI,EAEpE,GAAI,IAAW,KAAM,CACjB,KAAK,KAAK,UAAW,CAAI,EAEzB,MACJ,CAEA,IAAM,EAAoB,CAAE,QAAS,EAAO,SAAS,QAAS,OAAQ,EAAO,OAAQ,MAAK,EAE1F,EAAO,SAAS,QAAQ,EAAO,OAAQ,CAAI,EAC3C,KAAK,KAAK,WAAY,CAAK,CAC/B,CASA,aAAuB,EAA8B,CACjD,GAAI,EAAQ,SAAW,IAAA,GACnB,IAAK,IAAM,KAAW,OAAO,KAAK,EAAQ,MAAM,EAC5C,KAAK,SAAS,EAAS,EAAQ,OAAO,EAAQ,EAItD,GAAI,EAAQ,YAAc,IAAA,GACtB,IAAK,IAAM,KAAS,OAAO,KAAK,EAAQ,SAAS,EAAoB,CACjE,IAAM,EAAW,EAAQ,UAAU,GAE/B,IAAa,IAAA,IACb,KAAK,WAAW,IAAI,EAAO,CAAQ,CAE3C,CAER,CAEA,kBAAiC,CAC7B,KAAK,kBAAkB,CAC3B,CACJ"}
1
+ {"version":3,"file":"router.es.js","names":[],"sources":["../../src/typescript/lib/router/RoutePattern.ts","../../src/typescript/lib/router/Router.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\n// Pure route-pattern mechanics behind Router: normalizing a hash/path,\n// compiling a registered pattern into segments + an ambiguity key, matching a\n// path against a compiled pattern, and picking the most specific match. No\n// DOM seam involved — internal to router/, not exported from the barrel.\n\n/** The kind of a single pattern segment. */\nexport type SegmentKind = \"static\" | \"param\" | \"catchAll\";\n\n/** One segment of a compiled pattern. */\nexport interface RouteSegment {\n kind: SegmentKind;\n /** Literal text for \"static\", the parameter name for \"param\", \"\" for \"catchAll\". */\n value: string;\n}\n\n/** A pattern parsed into segments, plus its ambiguity key. */\nexport interface CompiledPattern {\n /** The pattern string as registered, after normalization (e.g. \"/data/:id\"). */\n pattern: string;\n /** Ambiguity key: static segments by literal, \"param\" as \":\", \"catchAll\" as \"*\". */\n key: string;\n segments: RouteSegment[];\n}\n\n/**\n * Normalizes a hash or path to a leading-slash, no-trailing-slash path: strips\n * a leading `\"#\"`, discards everything from the first `\"?\"` onward, and\n * collapses empty segments (so a doubled `\"//\"` and a trailing `\"/\"` both\n * disappear). `\"\"`, `\"#\"`, and `\"#/\"` all normalize to `\"/\"`.\n *\n * @param input - The raw hash (with or without its leading `\"#\"`) or path.\n * @returns The normalized path.\n */\nexport function normalizePath(input: string): string {\n let path = input.startsWith(\"#\") ? input.slice(1) : input;\n const queryIndex = path.indexOf(\"?\");\n\n if (queryIndex >= 0) {\n path = path.slice(0, queryIndex);\n }\n\n return \"/\" + splitPath(path).join(\"/\");\n}\n\n/**\n * Splits a normalized path into its non-empty segments.\n *\n * @param path - The path to split.\n * @returns The segments, in order.\n */\nexport function splitPath(path: string): string[] {\n return path.split(\"/\").filter((segment) => segment.length > 0);\n}\n\n/**\n * Splits a URL-ish string at its first `\"#\"`: the part before, and the\n * fragment without its `\"#\"`. Everything after the first `\"#\"` is the\n * fragment verbatim — a second `\"#\"` in the input stays part of it. Never\n * normalizes either half; the caller runs `path` through {@link normalizePath}.\n *\n * @param input - The raw href or path, with or without a fragment.\n * @returns The part before the first `\"#\"`, and the fragment without it.\n */\nexport function splitFragment(input: string): { path: string; fragment: string } {\n const hashIndex = input.indexOf(\"#\");\n\n if (hashIndex === -1) {\n return { path: input, fragment: \"\" };\n }\n\n return { path: input.slice(0, hashIndex), fragment: input.slice(hashIndex + 1) };\n}\n\n/**\n * Normalizes a base to leading-and-trailing-slash form, so\n * {@link stripBase} and {@link joinBase} can both assume that shape.\n * `\"\"`, `\"/\"`, `\"x\"`, `\"/x\"`, and `\"/x/\"` all become `\"/\"` or `\"/x/\"`.\n *\n * @param base - The raw base path.\n * @returns The normalized base.\n */\nexport function normalizeBase(base: string): string {\n const segments = splitPath(base);\n\n return segments.length === 0 ? \"/\" : \"/\" + segments.join(\"/\") + \"/\";\n}\n\n/**\n * Removes `base` from the front of `pathname`, then normalizes what is\n * left through {@link normalizePath}. A `pathname` that does not start with\n * `base` is normalized as-is rather than rejected.\n *\n * @param base - The site base, in any shape {@link normalizeBase} accepts.\n * @param pathname - The URL path to strip the base from.\n * @returns The normalized path with `base` removed.\n */\nexport function stripBase(base: string, pathname: string): string {\n const normalizedBase = normalizeBase(base);\n // Base without its trailing slash, e.g. \"/typescript-ui\" (\"\" at the root).\n const basePrefix = normalizedBase.slice(0, -1);\n\n if (basePrefix !== \"\" && (pathname === basePrefix || pathname.startsWith(basePrefix + \"/\"))) {\n return normalizePath(pathname.slice(basePrefix.length));\n }\n\n return normalizePath(pathname);\n}\n\n/**\n * Joins a normalized base and a normalized path into a URL path — the\n * inverse of {@link stripBase}.\n *\n * @param base - The site base, in any shape {@link normalizeBase} accepts.\n * @param path - The route path, in any shape {@link normalizePath} accepts.\n * @returns The joined URL path.\n */\nexport function joinBase(base: string, path: string): string {\n const normalizedBase = normalizeBase(base);\n const normalizedPath = normalizePath(path);\n\n if (normalizedPath === \"/\") {\n return normalizedBase;\n }\n\n return normalizedBase.slice(0, -1) + normalizedPath;\n}\n\n/**\n * Parses a registered pattern into {@link RouteSegment}s and derives its\n * ambiguity key.\n *\n * @param pattern - The pattern string, e.g. `\"/data/rows/:sel\"`.\n * @returns The compiled pattern.\n * @throws If `\"*\"` appears anywhere but the final segment.\n */\nexport function compilePattern(pattern: string): CompiledPattern {\n const normalized = normalizePath(pattern);\n const rawSegments = splitPath(normalized);\n\n const segments: RouteSegment[] = rawSegments.map((raw, i) => {\n if (raw === \"*\") {\n if (i !== rawSegments.length - 1) {\n throw new Error(`RoutePattern: \"*\" is only valid as the final segment of \"${pattern}\"`);\n }\n\n return { kind: \"catchAll\", value: \"\" };\n }\n\n if (raw.startsWith(\":\")) {\n return { kind: \"param\", value: raw.slice(1) };\n }\n\n return { kind: \"static\", value: raw };\n });\n\n const key = segments\n .map((segment) => segment.kind === \"static\" ? segment.value : segment.kind === \"param\" ? \":\" : \"*\")\n .join(\"/\");\n\n return { pattern: normalized, key, segments };\n}\n\n/**\n * Returns the extracted params when `segments` match `compiled`, or `null`\n * when they don't. A trailing `catchAll` segment matches zero or more\n * remaining segments; every other kind requires an exact segment count.\n * Captured `:param` values run through `decodeURIComponent`, falling back to\n * the raw segment text on a malformed escape.\n *\n * @param compiled - The compiled pattern to match against.\n * @param segments - The candidate path's segments (from {@link splitPath}).\n * @returns The extracted params, or `null` when there is no match.\n */\nexport function matchPattern(compiled: CompiledPattern, segments: string[]): Record<string, string> | null {\n const patternSegments = compiled.segments;\n const isCatchAll = patternSegments.length > 0 && patternSegments.at(-1)!.kind === \"catchAll\";\n const staticLength = isCatchAll ? patternSegments.length - 1 : patternSegments.length;\n\n if (isCatchAll ? segments.length < staticLength : segments.length !== staticLength) {\n return null;\n }\n\n const params: Record<string, string> = {};\n\n for (let i = 0; i < staticLength; i += 1) {\n const patternSegment = patternSegments[i];\n const value = segments[i];\n\n if (patternSegment.kind === \"static\") {\n if (patternSegment.value !== value) {\n return null;\n }\n } else if (patternSegment.kind === \"param\") {\n params[patternSegment.value] = decodeSegment(value);\n }\n }\n\n return params;\n}\n\n/**\n * Decodes a captured path segment, falling back to the raw text when it\n * carries a malformed percent-escape.\n *\n * @param value - The raw segment text.\n * @returns The decoded value, or `value` unchanged on a decode failure.\n */\nfunction decodeSegment(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/** Rank of each real segment kind: higher wins a specificity tie-break. */\nconst KIND_RANK: Record<SegmentKind, number> = { static: 2, param: 1, catchAll: 0 };\n\n/**\n * Rank of position `i` in `segments`. Reaching the end of the pattern (`i` at\n * or past its length) outranks every real segment kind — see\n * {@link selectPattern}.\n *\n * @param segments - The pattern's segments.\n * @param i - The position to rank.\n * @returns The rank at that position.\n */\nfunction rankAt(segments: readonly RouteSegment[], i: number): number {\n return i >= segments.length ? 3 : KIND_RANK[segments[i].kind];\n}\n\n/**\n * Returns the highest-ranked pattern in `compiled` that matches `path`, or\n * `null` when none match. Patterns are compared segment by segment from the\n * left via {@link rankAt}; the first position where two matching patterns\n * differ decides the winner. Two patterns can never tie on every position —\n * that would mean identical ambiguity keys, which the route table (see\n * `Router`) forbids. Registration order never affects the result.\n *\n * @param compiled - The candidate compiled patterns.\n * @param path - The normalized path to match.\n * @returns The winning pattern and its extracted params, or `null`.\n */\nexport function selectPattern<T extends CompiledPattern>(\n compiled: readonly T[],\n path: string,\n): { compiled: T; params: Record<string, string> } | null {\n const segments = splitPath(path);\n\n let best: T | null = null;\n let bestParams: Record<string, string> | null = null;\n\n for (const candidate of compiled) {\n const params = matchPattern(candidate, segments);\n\n if (params === null) {\n continue;\n }\n\n if (best === null || isMoreSpecific(candidate.segments, best.segments)) {\n best = candidate;\n bestParams = params;\n }\n }\n\n return best === null ? null : { compiled: best, params: bestParams! };\n}\n\n/**\n * Whether `a` outranks `b` by {@link rankAt} at the first position where they\n * differ.\n *\n * @param a - The candidate pattern's segments.\n * @param b - The current best pattern's segments.\n * @returns `true` when `a` is more specific than `b`.\n */\nfunction isMoreSpecific(a: readonly RouteSegment[], b: readonly RouteSegment[]): boolean {\n const length = Math.max(a.length, b.length);\n\n for (let i = 0; i < length; i += 1) {\n const rankA = rankAt(a, i);\n const rankB = rankAt(b, i);\n\n if (rankA !== rankB) {\n return rankA > rankB;\n }\n }\n\n return false;\n}\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { DOM } from '~/core/DOM.js';\nimport { ListenerBag } from '~/core/ListenerBag.js';\nimport { compilePattern, normalizePath, splitPath, splitFragment, selectPattern, normalizeBase, stripBase, joinBase, type CompiledPattern } from '~/router/RoutePattern.js';\n\n/** Params extracted from a matched pattern's `:name` segments. */\nexport type RouteParams = Record<string, string>;\n\n/** A registered route's callback: drives whatever it fronts, never builds it. */\nexport type RouteHandler = (params: RouteParams, path: string, fragment: string) => void;\n\n/** The events a {@link Router} emits. */\nexport type RouterEvent = \"navigate\" | \"nomatch\";\n\n/** Where a {@link Router} reads and writes the route: the URL hash, or the path. */\nexport type RouterMode = \"hash\" | \"history\";\n\n/** The pattern and params a navigation resolved to. */\nexport interface RouteMatch {\n /** The pattern that won, as registered. */\n pattern: string;\n params: RouteParams;\n /** The normalized path that was matched. */\n path: string;\n /** The URL fragment without its `\"#\"`, or `\"\"` when there is none. Always `\"\"` in hash mode. */\n fragment: string;\n}\n\n/** Construction options for {@link Router}. */\nexport interface RouterOptions {\n /** Defaults to `\"hash\"`. */\n mode?: RouterMode;\n /** Path prefix the site is served under, e.g. `\"/typescript-ui/\"`. History mode only; defaults to `\"/\"`. */\n base?: string;\n /** Patterns to `register` at construction, keyed by pattern string. */\n routes?: Record<string, RouteHandler>;\n listeners?: Partial<{\n navigate: (match: RouteMatch) => void;\n nomatch: (path: string) => void;\n }>;\n}\n\n/** A registered route: its compiled pattern plus the handler it drives. */\ntype CompiledRoute = CompiledPattern & { handler: RouteHandler };\n\n/**\n * Maps the URL hash or path to a single top-level app section. Patterns are\n * registered with {@link register} (e.g. `\"/data/rows/:sel\"`); on a\n * navigation, the router selects the most specific matching pattern, extracts\n * its `:param` values, and calls that pattern's handler — the handler drives\n * components that already exist, it never builds them.\n *\n * {@link start} reads the current hash or path, applies the matching route\n * synchronously, then installs the `hashchange` (or, in History mode,\n * `popstate`) listener; call it once the app has built its component tree\n * and before the first layout pass runs, so the routed section is already\n * selected when that pass runs. {@link stop} removes the listener.\n *\n * It is a plain class (no DOM element, so not `callable()`-wrapped) — it\n * follows the shape of a data store: an options bag, a private listener bag,\n * and typed `on` / `off` / `emit` forwarders.\n *\n * @category Core\n */\nexport class Router {\n\n private _routes: Map<string, CompiledRoute> = new Map();\n private _listeners: ListenerBag<RouterEvent> = new ListenerBag<RouterEvent>();\n private _started: boolean = false;\n // Set once in applyOptions and never reassigned after — construction-only,\n // like the compiled route table. Not `readonly`: strictPropertyInitialization\n // rejects a readonly field assigned from a method the constructor merely calls.\n private _mode!: RouterMode;\n private _base!: string;\n\n // Stable references so add/remove pair up; each delegates to a named method.\n private readonly _onHashChange: () => void = () => this.handleHashChange();\n private readonly _onPopState: () => void = () => this.handlePopState();\n\n /**\n * @param options - Routes and listeners to register at construction.\n */\n constructor(options?: RouterOptions) {\n this.applyOptions(options ?? {});\n }\n\n /**\n * Registers a pattern's handler. Re-registering the exact same pattern\n * string replaces its handler silently. Registering a *different*\n * pattern string that collides with an already-registered one on\n * specificity (e.g. `\"/users/:id\"` and `\"/users/:name\"`) replaces it too,\n * but logs a warning naming both patterns — that collision usually\n * signals an authoring mistake.\n *\n * @param pattern - The route pattern, e.g. `\"/data/rows/:sel\"`.\n * @param handler - Called with the extracted params and the normalized\n * path when this pattern wins a navigation.\n * @returns This router, for chaining.\n */\n register(pattern: string, handler: RouteHandler): this {\n const compiled = compilePattern(pattern);\n const existing = this._routes.get(compiled.key);\n\n if (existing !== undefined && existing.pattern !== compiled.pattern) {\n console.warn(`Router: \"${existing.pattern}\" and \"${compiled.pattern}\" have the same specificity; \"${compiled.pattern}\" replaces it.`);\n }\n\n this._routes.set(compiled.key, { ...compiled, handler });\n\n return this;\n }\n\n /**\n * Reads the current hash or path, applies the matching route\n * synchronously, then installs the `hashchange` (hash mode) or\n * `popstate` (History mode) listener. Calling `start()` again on an\n * already-started router logs a warning and is otherwise a no-op — it\n * does not install a second listener.\n *\n * @returns This router, for chaining.\n */\n start(): this {\n if (this._started) {\n console.warn(`Router: start() called on an already-started router; ignoring.`);\n\n return this;\n }\n\n this._started = true;\n this.applyCurrentRoute();\n\n if (this._mode === \"history\") {\n DOM.sink.addListener(DOM.source.getWindow(), \"popstate\", this._onPopState);\n } else {\n DOM.sink.addListener(DOM.source.getWindow(), \"hashchange\", this._onHashChange);\n }\n\n return this;\n }\n\n /**\n * Removes the `hashchange` (hash mode) or `popstate` (History mode)\n * listener. Safe to call when never started, or more than once.\n *\n * @returns This router, for chaining.\n */\n stop(): this {\n if (!this._started) {\n return this;\n }\n\n if (this._mode === \"history\") {\n DOM.sink.removeListener(DOM.source.getWindow(), \"popstate\", this._onPopState);\n } else {\n DOM.sink.removeListener(DOM.source.getWindow(), \"hashchange\", this._onHashChange);\n }\n\n this._started = false;\n\n return this;\n }\n\n /**\n * Navigates to `path` — pushing a history entry, or replacing the\n * current one when `options.replace` is `true`. In hash mode this writes\n * the hash, discarding any `#fragment` in `path` (the `#` is already\n * spent on the route); in History mode this writes `location.pathname`\n * and `location.hash` via `pushState` / `replaceState` and — since\n * neither fires an event — applies the matching route itself. Either\n * way, navigating to the path (and, in History mode, fragment) already\n * current is a same-value write: no history entry is written and no\n * handler re-runs.\n *\n * @param path - The path to navigate to, e.g. `\"/settings\"` or, in\n * History mode, `\"/settings#section\"`.\n * @param options - `replace` to replace the current history entry instead\n * of pushing a new one.\n * @returns This router, for chaining.\n */\n navigate(path: string, options?: { replace?: boolean }): this {\n const split = splitFragment(path);\n\n if (this._mode === \"hash\") {\n const segments = splitPath(normalizePath(split.path));\n const hash = \"#/\" + segments.map((segment) => encodeURIComponent(segment)).join(\"/\");\n\n if (options?.replace === true) {\n DOM.sink.replaceLocationHash(hash);\n } else {\n DOM.sink.setLocationHash(hash);\n }\n\n return this;\n }\n\n const target = normalizePath(split.path);\n const fragment = split.fragment;\n\n if (target === this.getPath() && fragment === this.getFragment()) {\n return this;\n }\n\n const url = this.getHref(fragment === \"\" ? target : `${target}#${fragment}`);\n\n if (options?.replace === true) {\n DOM.sink.replaceHistoryPath(url);\n } else {\n DOM.sink.pushHistoryPath(url);\n }\n\n this.applyCurrentRoute(); // pushState/replaceState fire no event; apply it ourselves\n\n return this;\n }\n\n /**\n * The href an `<a>` for `path` should carry, in this router's mode and\n * base: a `\"#/…\"` fragment in hash mode, a base-joined path in History\n * mode. Each segment is percent-encoded. A `#fragment` in `path` is\n * dropped first and, in History mode only, re-appended verbatim\n * (unencoded, so it keeps matching a heading `id`) after the encoded\n * path — hash mode has nowhere to put it, since its own `#` is already\n * spent on the route.\n *\n * @param path - The route path to format, e.g. `\"/guide/installation\"`\n * or, in History mode, `\"/guide/installation#section\"`.\n * @returns The formatted href.\n */\n getHref(path: string): string {\n const split = splitFragment(path);\n const segments = splitPath(normalizePath(split.path)).map((segment) => encodeURIComponent(segment));\n const encodedPath = \"/\" + segments.join(\"/\");\n\n if (this._mode === \"hash\") {\n return \"#\" + encodedPath;\n }\n\n const href = joinBase(this._base, encodedPath);\n\n return split.fragment === \"\" ? href : `${href}#${split.fragment}`;\n }\n\n /**\n * The route path for `href`, or — with no argument — for the current\n * URL. The inverse of {@link getHref}: percent-encoded segments are\n * decoded, and in History mode the base is stripped first and any\n * `#fragment` is split off before normalizing (see {@link getFragment}\n * to read it).\n *\n * @param href - The href to parse; defaults to the current hash (hash\n * mode) or `location.pathname` (History mode), read through the DOM seam.\n * @returns The normalized, decoded path, without a fragment.\n */\n getPath(href?: string): string {\n if (this._mode === \"hash\") {\n const raw = href ?? DOM.source.getLocationHash();\n\n return this.decodePath(normalizePath(raw));\n }\n\n const raw = href ?? DOM.source.getLocationPathname();\n\n return this.decodePath(stripBase(this._base, splitFragment(raw).path));\n }\n\n /**\n * The fragment for `href`, or — with no argument — for the current URL,\n * without its leading `\"#\"`. Always `\"\"` in hash mode, since the `#`\n * there is already spent on the route.\n *\n * @param href - The href to parse; defaults to the current\n * `location.hash`, read through the DOM seam.\n * @returns The fragment, or `\"\"` when there is none.\n */\n getFragment(href?: string): string {\n if (this._mode === \"hash\") {\n return \"\";\n }\n\n if (href !== undefined) {\n return splitFragment(href).fragment;\n }\n\n const hash = DOM.source.getLocationHash();\n\n return hash.startsWith(\"#\") ? hash.slice(1) : hash;\n }\n\n /**\n * Decodes each percent-encoded segment of an already-normalized path,\n * falling back to the raw segment text on a malformed escape.\n *\n * @param path - The normalized path to decode.\n * @returns The decoded path.\n */\n private decodePath(path: string): string {\n const segments = splitPath(path).map((segment) => {\n try {\n return decodeURIComponent(segment);\n } catch {\n return segment;\n }\n });\n\n return \"/\" + segments.join(\"/\");\n }\n\n on(event: \"navigate\", listener: (match: RouteMatch) => void): this;\n on(event: \"nomatch\", listener: (path: string) => void): this;\n\n /**\n * Subscribes a listener to a router event. Listeners fire in\n * registration order.\n *\n * @param event - The event to listen for.\n * @param listener - The callback to invoke.\n * @returns This router, for chaining.\n */\n on(event: RouterEvent, listener: Function): this {\n this._listeners.add(event, listener);\n\n return this;\n }\n\n /**\n * Removes a previously registered listener. No-op if it was never\n * registered for that event.\n *\n * @param event - The event the listener was registered for.\n * @param listener - The exact callback reference to remove.\n * @returns This router, for chaining.\n */\n off(event: RouterEvent, listener: Function): this {\n this._listeners.remove(event, listener);\n\n return this;\n }\n\n /**\n * Notifies all listeners registered for an event, in registration order.\n *\n * @param event - The event to emit.\n * @param payload - The value passed to each listener.\n */\n protected emit(event: RouterEvent, payload: unknown): void {\n this._listeners.fire(event, payload);\n }\n\n /**\n * Reads the current hash or path and calls the most specific matching\n * pattern's handler, emitting `\"navigate\"` — or emits `\"nomatch\"` when\n * nothing matches. Shared by {@link start}, the `hashchange` listener,\n * the `popstate` listener, and History-mode {@link navigate}.\n */\n private applyCurrentRoute(): void {\n const path = this.getPath();\n const fragment = this.getFragment();\n const result = selectPattern(Array.from(this._routes.values()), path);\n\n if (result === null) {\n this.emit(\"nomatch\", path);\n\n return;\n }\n\n const match: RouteMatch = { pattern: result.compiled.pattern, params: result.params, path, fragment };\n\n result.compiled.handler(result.params, path, fragment);\n this.emit(\"navigate\", match);\n }\n\n /**\n * Applies an {@link RouterOptions} bag: sets `mode` and `base`, registers\n * `routes`, then wires `listeners`. Called from the constructor body,\n * after every field initializer has run.\n *\n * @param options - The options bag to apply.\n */\n protected applyOptions(options: RouterOptions): void {\n this._mode = options.mode ?? \"hash\";\n this._base = normalizeBase(options.base ?? \"/\");\n\n if (options.routes !== undefined) {\n for (const pattern of Object.keys(options.routes)) {\n this.register(pattern, options.routes[pattern]);\n }\n }\n\n if (options.listeners !== undefined) {\n for (const event of Object.keys(options.listeners) as RouterEvent[]) {\n const listener = options.listeners[event];\n\n if (listener !== undefined) {\n this._listeners.add(event, listener);\n }\n }\n }\n }\n\n private handleHashChange(): void {\n this.applyCurrentRoute();\n }\n\n private handlePopState(): void {\n this.applyCurrentRoute();\n }\n}\n"],"mappings":"+EAmCA,SAAgB,cAAc,EAAuB,CACjD,IAAI,EAAO,EAAM,WAAW,GAAG,EAAI,EAAM,MAAM,CAAC,EAAI,EAC9C,EAAa,EAAK,QAAQ,GAAG,EAMnC,OAJI,GAAc,IACd,EAAO,EAAK,MAAM,EAAG,CAAU,GAG5B,IAAM,UAAU,CAAI,CAAC,CAAC,KAAK,GAAG,CACzC,CAQA,SAAgB,UAAU,EAAwB,CAC9C,OAAO,EAAK,MAAM,GAAG,CAAC,CAAC,OAAQ,GAAY,EAAQ,OAAS,CAAC,CACjE,CAWA,SAAgB,cAAc,EAAmD,CAC7E,IAAM,EAAY,EAAM,QAAQ,GAAG,EAMnC,OAJI,IAAc,GACP,CAAE,KAAM,EAAO,SAAU,EAAG,EAGhC,CAAE,KAAM,EAAM,MAAM,EAAG,CAAS,EAAG,SAAU,EAAM,MAAM,EAAY,CAAC,CAAE,CACnF,CAUA,SAAgB,cAAc,EAAsB,CAChD,IAAM,EAAW,UAAU,CAAI,EAE/B,OAAO,EAAS,SAAW,EAAI,IAAM,IAAM,EAAS,KAAK,GAAG,EAA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PwAw.js";import{t as r}from"./VirtualScroller-zQr-vKrO.js";var i=2,VirtualRowView=class extends t{_rowPool=[];_boundIndices=[];_rowGeom=[];_rowDisplayed=[];_scroller=null;_renderDeferred=!1;_renderResumed=!1;_pendingScrollX=null;_pendingScrollY=null;_pendingScrollRow=null;initScroller(e){this._scroller=new r(this,e,()=>this.onScrollerTick());for(let e of this._scroller.ownedHandles())this.trackHandle(e)}onScrollerTick(){this.renderWindow()}destructor(){for(let e of this._rowPool)e.dispose();this._scroller?.dispose(),super.destructor()}setScrollX(e){return this._scroller?.resetWheelEase(),this.holdScrollWhileFirstLayoutHeld(`x`,e)||this._scroller?.setScrollX(e),this}setScrollY(e){return this._scroller?.resetWheelEase(),this.holdScrollWhileFirstLayoutHeld(`y`,e)||this._scroller?.setScrollY(e),this}holdScrollWhileFirstLayoutHeld(e,t){return n()?(e===`x`?this._pendingScrollX=t:(this._pendingScrollY=t,this._pendingScrollRow=null),!0):(e===`x`?this._pendingScrollX=null:(this._pendingScrollY=null,this._pendingScrollRow=null),!1)}applyPendingScroll(){let e=this._pendingScrollX,t=this._pendingScrollY,n=this._pendingScrollRow;this._pendingScrollX=null,this._pendingScrollY=null,this._pendingScrollRow=null,e!==null&&this.setScrollX(e),t!==null&&this.setScrollY(t),n!==null&&this.scrollRowIntoView(n)}computeVisibleWindow(e,t,n){let r=this.getRowHeight(),a=Math.max(0,Math.floor(e/r)-i),o=Math.min(n-1,Math.ceil((e+t)/r)+i);return{firstRow:a,lastRow:o,windowSize:o-a+1>0?o-a+1:0}}computePoolTarget(e,t,n){return Math.min(n,Math.max(e,Math.ceil(t/this.getRowHeight())+2*i+2))}computePageSize(){let e=this.getRowHeight();return Math.max(1,Math.floor((this.getHeight()||e)/e))}growRowPool(t){if(!this._scroller||this._rowPool.length>=t)return;let n=this._scroller.getRowsContainer(),r=e.sink.createDocumentFragment();for(;this._rowPool.length<t;){let t=this.createPoolRow(),n=t.getElement(!0);e.sink.appendChild(r,n),t.setY(0),t.setWillChange(`transform`),this._rowPool.push(t),this._boundIndices.push(-1),this._rowGeom.push(null),this._rowDisplayed.push(!1)}e.sink.appendChild(n,r),e.sink.release(r)}positionRow(e,t,n){let r=this._rowPool[e],i=this.getRowHeight(),a=this._rowGeom[e],o=!a||a.ty!==t||a.w!==n||a.h!==i;return o&&(r.setAutoCommitStyle(!1),r.setX(0),r.setTranslate(0,t),r.setWidth(n),r.setHeight(i),r.setAutoCommitStyle(!0),this._rowGeom[e]={ty:t,w:n,h:i}),this._rowDisplayed[e]||(r.setDisplayed(!0),this._rowDisplayed[e]=!0),o}hideExcessPoolRows(e){for(let t=e;t<this._rowPool.length;t++)this._rowDisplayed[t]&&(this._rowPool[t].setDisplayed(!1),this._rowDisplayed[t]=!1),this._boundIndices[t]=-1,this._rowGeom[t]=null}invalidateGeom(){for(let e=0;e<this._rowGeom.length;e++)this._rowGeom[e]=null}deferRenderWhileFirstLayoutHeld(){return n()?(this._renderDeferred=!0,this.scheduleLayout(),!0):(this._renderResumed=this._renderDeferred,this._renderDeferred=!1,!1)}wasRenderDeferred(){return this._renderDeferred}finishResumedRender(){let e=this._renderResumed;return this._renderResumed=!1,this.applyPendingScroll(),e}renderWindowIfDeferred(){return!this._renderDeferred||this.isLayoutPaused()?!1:(this.renderWindow(),!0)}onThemeReflow(){this._boundIndices.fill(-1),this.invalidateGeom(),this.renderWindow()}scrollRowIntoView(e){if(e<0||!this._scroller)return;if(n()){this._pendingScrollRow=e;return}let t=this.getRowHeight(),r=e*t,i=r+t,a=this._scroller.getScrollY(),o=this.getHeight(),s=a+o,c=a;r<a?c=r:i>s&&(c=i-o),c!==a&&this.setScrollY(c)}};function selectionsEqual(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}export{VirtualRowView as n,selectionsEqual as t};
2
+ //# sourceMappingURL=selectionsEqual-4r5R7pTK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectionsEqual-4r5R7pTK.js","names":[],"sources":["../../src/typescript/lib/component/shared/VirtualRowView.ts","../../src/typescript/lib/component/shared/selectionsEqual.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Component, ComponentOptions } from \"~/core/Component.js\";\nimport { DOM } from \"~/core/DOM.js\";\nimport type { Handle } from \"~/core/DOM.js\";\nimport { VirtualScroller } from \"~/component/container/VirtualScroller.js\";\nimport { isFirstLayoutHeld } from \"~/core/FirstLayoutGate.js\";\n\n/** Number of off-screen rows to render above and below the visible viewport. */\nconst SCROLL_BUFFER = 2;\n\n/**\n * Shared transform-windowed virtual-scroll base for the data views —\n * `table/Body` and `tree/Tree` are its only two subclasses. It owns the\n * recycled row pool (`_rowPool` and the parallel `_boundIndices` / `_rowGeom` /\n * `_rowDisplayed` bookkeeping arrays), the {@link VirtualScroller} wiring, and\n * the window / pool-growth / geometry reconciliation primitives each subclass's\n * render pass composes.\n *\n * Only two things genuinely diverge between the two consumers, so only those\n * are hooks:\n *\n * - **Row height** — `Body` derives it live from the theme line box; `Tree`\n * uses a fixed constant. Read through {@link getRowHeight} on every call so a\n * live theme change is honoured.\n * - **Row construction** — the pool-row scaffolding (fragment batching, `setY(0)`\n * pin, `will-change` promotion, parallel-array bookkeeping) is identical; only\n * the row object each subclass builds differs. {@link createPoolRow} returns a\n * fully-constructed, un-appended row and the base owns the rest.\n *\n * The per-frame render pass itself ({@link renderWindow}) stays subclass-specific\n * because the content-width derivation genuinely diverges; the base exposes the\n * shared primitives it calls ({@link computeVisibleWindow},\n * {@link computePoolTarget}, {@link growRowPool}, {@link positionRow},\n * {@link hideExcessPoolRows}).\n *\n * @typeParam TRow - The concrete pooled row component type.\n * @typeParam TOptions - The subclass's options bag.\n *\n * @internal Not barrel-exported; the two subclasses are the only consumers.\n */\nabstract class VirtualRowView<\n TRow extends Component,\n TOptions extends ComponentOptions = ComponentOptions,\n> extends Component<TOptions> {\n\n protected _rowPool : TRow[] = [];\n protected _boundIndices : number[] = [];\n protected _rowGeom : Array<{ ty: number, w: number, h: number } | null> = [];\n protected _rowDisplayed : boolean[] = [];\n protected _scroller : VirtualScroller | null = null;\n\n /** Whether the startup font gate skipped a render pass that still owes a run. */\n private _renderDeferred: boolean = false;\n /** Whether the render now in flight is the one a skipped pass left pending. */\n private _renderResumed : boolean = false;\n /** Scroll offsets the gate held back, applied once a render pass has run. */\n private _pendingScrollX: number | null = null;\n private _pendingScrollY: number | null = null;\n /** A row reveal the gate held back, recomputed once a render pass has run. */\n private _pendingScrollRow: number | null = null;\n\n /**\n * Returns the height in pixels of a single row. Read on every window /\n * geometry calculation, so a subclass that recomputes it (e.g. on a theme\n * change) reflects the new value immediately.\n */\n protected abstract getRowHeight(): number;\n\n /**\n * Constructs one pool row, fully wired but not yet appended to the\n * rows container — the base's {@link growRowPool} owns the append, the\n * `setY(0)` pin, the `will-change` promotion, and the parallel-array\n * bookkeeping.\n */\n protected abstract createPoolRow(): TRow;\n\n /**\n * Recomputes and reconciles the visible row window against the current\n * scroll position and dataset. Subclass-specific because the content-width\n * derivation diverges; both implementations compose the shared primitives\n * on this base.\n */\n protected abstract renderWindow(): void;\n\n /**\n * Constructs the {@link VirtualScroller} for this view and tracks its\n * container handles so they are released with the component. The scroller's\n * onScroll hook is routed through {@link onScrollerTick}.\n *\n * @param element - This view's initialised element handle.\n */\n protected initScroller(element: Handle): void {\n this._scroller = new VirtualScroller(this, element, () => this.onScrollerTick());\n\n // Track the scroller's created container handles so they are released\n // with this view (on destructor or GC); the scroller is not a Component.\n for (const handle of this._scroller.ownedHandles()) {\n this.trackHandle(handle);\n }\n }\n\n /**\n * Invoked on every scroller tick. Default behaviour re-renders the window;\n * `Body` overrides it to additionally emit its scroll events.\n */\n protected onScrollerTick(): void {\n this.renderWindow();\n }\n\n /**\n * Destroys the pooled rows and the scroller's overlay scrollbars before the\n * inherited teardown runs.\n *\n * {@link growRowPool} appends each row's element straight to the rows\n * container and keeps the row only in `_rowPool`, so a pooled row is never\n * registered as a child component and the base destructor's recursion over\n * `_components` cannot reach it. Without this override neither the rows nor\n * their cells (which *are* registered on their row) release their\n * per-instance stylesheet rules, so the shared sheet grows by roughly the\n * view's whole cell count on every teardown. The scroller's two\n * `Scrollbar` overlays are raw-appended the same way, so they need the\n * same explicit disposal.\n */\n protected destructor(): void {\n for (const row of this._rowPool) {\n row.dispose();\n }\n\n this._scroller?.dispose();\n\n super.destructor();\n }\n\n /**\n * Sets the JS-controlled horizontal scroll position. Delegates to the\n * underlying {@link VirtualScroller}.\n *\n * @param x - The new scroll position in pixels.\n */\n setScrollX(x: number): this {\n // Ahead of the hold: a programmatic scroll cancels an in-flight wheel\n // ease whether or not the offset itself has to wait.\n this._scroller?.resetWheelEase();\n\n if (this.holdScrollWhileFirstLayoutHeld(\"x\", x)) {\n return this;\n }\n\n this._scroller?.setScrollX(x);\n\n return this;\n }\n\n /**\n * Sets the JS-controlled vertical scroll position. Delegates to the\n * underlying {@link VirtualScroller}.\n *\n * @param y - The new scroll position in pixels.\n */\n setScrollY(y: number): this {\n // Ahead of the hold: a programmatic scroll cancels an in-flight wheel\n // ease whether or not the offset itself has to wait.\n this._scroller?.resetWheelEase();\n\n if (this.holdScrollWhileFirstLayoutHeld(\"y\", y)) {\n return this;\n }\n\n this._scroller?.setScrollY(y);\n\n return this;\n }\n\n /**\n * Holds a scroll offset set while the startup font gate is holding this\n * view's render pass, for {@link applyPendingScroll} to apply once the pass\n * has run.\n *\n * @param axis - Which offset is being set.\n * @param offset - The requested offset in pixels.\n *\n * @returns `true` when the caller must return without scrolling.\n *\n * @remarks The scroller clamps every offset against a content extent that\n * only the render pass publishes, so an offset set while that pass is\n * deferred clamps to 0 and the request is lost — a row revealed during\n * startup would end up selected but off-screen. This guards the offsets\n * that are viewport-independent and so can be replayed verbatim: the\n * table's `scrollToRecord`, and a consumer restoring a saved offset.\n * `scrollRowIntoView` is held one level higher instead, by row index, since\n * its target depends on a height the gate is also holding. The table's\n * `scrollColumnIntoView` has that same width dependence but fires only from\n * a pooled cell's editor, which cannot exist while the pass is deferred.\n */\n private holdScrollWhileFirstLayoutHeld(axis: \"x\" | \"y\", offset: number): boolean {\n if (!isFirstLayoutHeld()) {\n // This offset is being applied for real, so it supersedes anything\n // held for the same axis — otherwise the held one would replay on\n // the next render and revert it. A held row reveal is a vertical\n // request too, so it goes with the Y offset.\n if (axis === \"x\") {\n this._pendingScrollX = null;\n } else {\n this._pendingScrollY = null;\n this._pendingScrollRow = null;\n }\n\n return false;\n }\n\n if (axis === \"x\") {\n this._pendingScrollX = offset;\n } else {\n this._pendingScrollY = offset;\n this._pendingScrollRow = null;\n }\n\n return true;\n }\n\n /**\n * Applies the scroll offsets {@link holdScrollWhileFirstLayoutHeld} held\n * back, now that a render pass has published the content extent they clamp\n * against. A no-op once they are applied.\n */\n private applyPendingScroll(): void {\n const x = this._pendingScrollX;\n const y = this._pendingScrollY;\n const row = this._pendingScrollRow;\n\n this._pendingScrollX = null;\n this._pendingScrollY = null;\n this._pendingScrollRow = null;\n\n if (x !== null) {\n this.setScrollX(x);\n }\n\n if (y !== null) {\n this.setScrollY(y);\n }\n\n // Applied after the offsets, which is what makes a reveal win over a\n // raw offset held before it. The reverse order is handled the other\n // way: a raw offset set later clears the reveal outright, so the two\n // vertical requests always resolve to whichever came last.\n if (row !== null) {\n this.scrollRowIntoView(row);\n }\n }\n\n /**\n * Computes the `[firstRow, lastRow]` data-index window visible in the\n * current viewport, padded by `SCROLL_BUFFER` on each side and clamped to\n * the dataset bounds.\n *\n * @param scrollY - The current scroll offset in pixels.\n * @param visibleHeight - The viewport height in pixels.\n * @param totalRows - The total number of rows in the dataset.\n * @returns The `firstRow` / `lastRow` data indices and the number of rows in the window.\n */\n protected computeVisibleWindow(scrollY: number, visibleHeight: number, totalRows: number): { firstRow: number, lastRow: number, windowSize: number } {\n const rowHeight = this.getRowHeight();\n const firstRow = Math.max(0, Math.floor(scrollY / rowHeight) - SCROLL_BUFFER);\n const lastRow = Math.min(\n totalRows - 1,\n Math.ceil((scrollY + visibleHeight) / rowHeight) + SCROLL_BUFFER\n );\n const windowSize = lastRow - firstRow + 1 > 0 ? lastRow - firstRow + 1 : 0;\n\n return { firstRow, lastRow, windowSize };\n }\n\n /**\n * Computes the row-pool target size: the max possible window for the\n * current viewport, not just the current windowSize. windowSize shrinks\n * near the top/bottom edges of the dataset because firstRow clamps to 0\n * (and lastRow to totalRows-1); growing only to windowSize would force\n * regrowth mid-scroll once the user passes a viewport-edge boundary. Pre-\n * growing pays the per-row first-layout cost once.\n *\n * @param windowSize - The current visible-window size.\n * @param visibleHeight - The viewport height in pixels.\n * @param totalRows - The total number of rows in the dataset.\n * @returns The pool target size.\n */\n protected computePoolTarget(windowSize: number, visibleHeight: number, totalRows: number): number {\n return Math.min(\n totalRows,\n Math.max(\n windowSize,\n Math.ceil(visibleHeight / this.getRowHeight()) + 2 * SCROLL_BUFFER + 2\n )\n );\n }\n\n /**\n * Computes the number of whole rows a page-nav keystroke should move by:\n * one viewport height, floored to at least one row.\n *\n * @returns The page size in rows.\n */\n protected computePageSize(): number {\n const rowHeight = this.getRowHeight();\n\n return Math.max(1, Math.floor((this.getHeight() || rowHeight) / rowHeight));\n }\n\n /**\n * Grows the row pool up to `poolTarget`, batching new row elements through\n * a {@link DocumentFragment} so the live rows container sees a single\n * append instead of N. Each new slot pins its static top to 0, promotes it\n * to its own compositor layer, and extends the parallel bookkeeping arrays\n * in lockstep.\n *\n * @param poolTarget - The target pool size.\n */\n protected growRowPool(poolTarget: number): void {\n if (!this._scroller || this._rowPool.length >= poolTarget) {\n return;\n }\n\n const rowsContainer = this._scroller.getRowsContainer();\n const growFragment = DOM.sink.createDocumentFragment();\n\n while (this._rowPool.length < poolTarget) {\n const row = this.createPoolRow();\n const rowEl = row.getElement(true)!;\n\n DOM.sink.appendChild(growFragment, rowEl);\n\n // Pin row's static top to 0 once. Per-frame Y offset comes from\n // translateY, which is composite-only (avoids layout/paint per\n // scroll tick).\n row.setY(0);\n\n // Pre-promote pooled rows to their own compositor layer so the first\n // scroll-driven translate doesn't pay a layer-creation cost.\n row.setWillChange(\"transform\");\n\n this._rowPool.push(row);\n this._boundIndices.push(-1);\n this._rowGeom.push(null);\n this._rowDisplayed.push(false);\n }\n\n DOM.sink.appendChild(rowsContainer, growFragment);\n DOM.sink.release(growFragment);\n }\n\n /**\n * Positions the pool slot at `slot` to `targetY` and sizes it to `rowWidth`,\n * writing the translate/size only when the cached geometry differs from the\n * target, and toggling the row displayed on the false→true edge.\n *\n * @param slot - The pool-slot index.\n * @param targetY - The row's translate-Y offset in pixels.\n * @param rowWidth - The row's width in pixels.\n * @returns `true` when the geometry changed (the subclass may need to re-lay\n * out the row's children), `false` when it was already at the target.\n */\n protected positionRow(slot: number, targetY: number, rowWidth: number): boolean {\n const row = this._rowPool[slot];\n const rowHeight = this.getRowHeight();\n const prev = this._rowGeom[slot];\n const geomChanged = !prev || prev.ty !== targetY || prev.w !== rowWidth || prev.h !== rowHeight;\n\n if (geomChanged) {\n row.setAutoCommitStyle(false);\n row.setX(0);\n row.setTranslate(0, targetY);\n row.setWidth(rowWidth);\n row.setHeight(rowHeight);\n row.setAutoCommitStyle(true);\n this._rowGeom[slot] = { ty: targetY, w: rowWidth, h: rowHeight };\n }\n\n if (!this._rowDisplayed[slot]) {\n row.setDisplayed(true);\n this._rowDisplayed[slot] = true;\n }\n\n return geomChanged;\n }\n\n /**\n * Hides pool slots whose index falls outside the visible window and\n * clears their cached binding so the next bind triggers a full rebuild.\n *\n * @param windowSize - The number of pool slots currently in use.\n */\n protected hideExcessPoolRows(windowSize: number): void {\n for (let i = windowSize; i < this._rowPool.length; i++) {\n if (this._rowDisplayed[i]) {\n this._rowPool[i].setDisplayed(false);\n this._rowDisplayed[i] = false;\n }\n this._boundIndices[i] = -1;\n this._rowGeom[i] = null;\n }\n }\n\n /**\n * Clears the cached row geometry so the next render re-applies positions and\n * sizes for every slot. `Body` overrides this to additionally clear its\n * per-cell geometry cache.\n */\n protected invalidateGeom(): void {\n for (let i = 0; i < this._rowGeom.length; i++) {\n this._rowGeom[i] = null;\n }\n }\n\n /**\n * Skips a render pass while the startup font gate is held, arranging for it\n * to run once the gate opens.\n *\n * @returns `true` when the caller must return without rendering.\n *\n * @remarks Both subclasses call {@link renderWindow} from many synchronous\n * entry points — `init`, a data change, a selection move — so a row's\n * geometry is routinely committed outside the coalesced layout queue, and\n * `init` in particular commits it the moment the element exists. Holding the\n * queue therefore does not hold these views; they have to check the gate\n * themselves. Deferring at this one choke point covers every entry point at\n * once, rather than guarding each caller.\n */\n protected deferRenderWhileFirstLayoutHeld(): boolean {\n if (!isFirstLayoutHeld()) {\n // This render is going ahead, which satisfies anything a held pass\n // left pending — clearing it keeps a later layout from replaying a\n // startup-era pass over the fresher state this one just committed.\n // Note that it also took over that pass's unfinished business, so\n // flag it for `finishResumedRender` to pick up once it has rendered.\n this._renderResumed = this._renderDeferred;\n this._renderDeferred = false;\n\n return false;\n }\n\n this._renderDeferred = true;\n this.scheduleLayout();\n\n return true;\n }\n\n /**\n * Whether the last render pass on this view was skipped by the startup font\n * gate and is still waiting to run.\n *\n * @returns `true` while a pass is pending.\n */\n protected wasRenderDeferred(): boolean {\n return this._renderDeferred;\n }\n\n /**\n * Reports, once, that the render now finishing is the one a held pass left\n * pending — so the caller can redo the post-render work that pass skipped.\n *\n * @returns `true` exactly once per resumed pass, at the end of the render\n * that resumed it.\n *\n * @remarks Called at the tail of {@link renderWindow} rather than from a\n * layout hook because a render resumes from whichever entry point reaches\n * it first, and for the table body that is the parent table layout calling\n * `renderWindow` directly rather than anything going through `doLayout`.\n */\n protected finishResumedRender(): boolean {\n // Read and clear before applying the scroll: applying it re-enters\n // `renderWindow` through the scroller's onScroll hook, and that nested\n // pass resets this flag. Reading it afterwards would lose the caller's\n // post-render work on exactly the passes that carry both.\n const resumed = this._renderResumed;\n\n this._renderResumed = false;\n\n // This pass has published the content extent, so any held offset can be\n // applied now — whether or not the pass is itself the deferred one.\n this.applyPendingScroll();\n\n return resumed;\n }\n\n /**\n * Runs the render pass the startup font gate deferred, if one is pending.\n * Each subclass calls this from its own `doLayout`, which is what picks the\n * pass back up once the gate opens.\n *\n * @returns `true` when a deferred pass ran, so the caller can skip a render\n * of its own and refresh whatever it keeps in step with the rendered rows.\n *\n * @remarks A paused view keeps its pass pending rather than running it: a\n * parent's layout recursion reaches `Body.doLayout` regardless of the\n * child's pause state, so rendering here would defeat a `pauseLayout` the\n * caller asked for. (`Tree.doLayout` already returns early when paused, so\n * the guard only binds for the body.) `resumeLayout` runs a layout of its\n * own, which picks the pass up.\n */\n protected renderWindowIfDeferred(): boolean {\n if (!this._renderDeferred || this.isLayoutPaused()) {\n return false;\n }\n\n // The pending flag is left for `renderWindow`'s own gate check to\n // consume: that is what marks this render as the resumed one, which\n // `finishResumedRender` reads at the end of the pass.\n this.renderWindow();\n\n return true;\n }\n\n /**\n * Re-binds and re-renders every pooled row after a text-metrics reflow —\n * a theme change, or the web font swapping in over the fallback face.\n *\n * @remarks Pooled rows do not ride `ThemeManager`'s reflow for free. Both\n * subclasses render through renderers whose `Text` runs with\n * `setAutoMeasure(false)`, so a bound row only re-measures inside the\n * renderer's `update()` — which {@link renderWindow} skips for a slot that\n * is already bound to its data index. Without the `_boundIndices` reset a\n * visible row therefore keeps the width it measured against whichever font\n * was active when it was bound, clipping the wider glyphs of the real face\n * once it arrives. Subclasses that cache metrics-derived state of their own\n * (row height, content width) override this to refresh it, then chain up.\n */\n protected onThemeReflow(): void {\n this._boundIndices.fill(-1);\n this.invalidateGeom();\n this.renderWindow();\n }\n\n /**\n * Scrolls the view so the row at `index` is fully visible, without moving\n * the viewport unless necessary. Delegates through {@link VirtualScroller}\n * so the header translate + scrollbar thumb stay in sync.\n *\n * @param index - The data index of the row to reveal. A negative index is a\n * no-op (the row is not in the current view).\n */\n protected scrollRowIntoView(index: number): void {\n if (index < 0 || !this._scroller) {\n return;\n }\n\n // Hold the row, not a target. The target depends on this view's height,\n // and at startup that height arrives from the very layout the gate is\n // holding — so computing it now would either read an unset height and\n // reveal nothing, or read 0 and scroll the row just out of view.\n if (isFirstLayoutHeld()) {\n this._pendingScrollRow = index;\n\n return;\n }\n\n const rowHeight = this.getRowHeight();\n const top = index * rowHeight;\n const bottom = top + rowHeight;\n const scrollTop = this._scroller.getScrollY();\n const viewportHeight = this.getHeight();\n const visibleBottom = scrollTop + viewportHeight;\n\n let target = scrollTop;\n if (top < scrollTop) {\n target = top;\n } else if (bottom > visibleBottom) {\n target = bottom - viewportHeight;\n }\n if (target !== scrollTop) {\n this.setScrollY(target);\n }\n }\n}\n\nexport { VirtualRowView };\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\n/**\n * Compares two selection sets by membership only — size and element\n * identity, regardless of insertion order.\n *\n * Pure; no DOM, no component state.\n *\n * @typeParam T - The selection identity type.\n * @param a - One selection set.\n * @param b - The other selection set.\n * @returns `true` when both sets have the same size and every member of\n * `a` is present in `b`.\n *\n * @internal Shared by `Tree` and `Body`; not barrel-exported.\n */\nexport function selectionsEqual<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean {\n if (a.size !== b.size) {\n return false;\n }\n\n for (const item of a) {\n if (!b.has(item)) {\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":"sIASA,IAAM,EAAgB,EAgCP,eAAf,cAGU,CAAoB,CAE1B,SAAgF,CAAC,EACjF,cAA+E,CAAC,EAChF,SAA+E,CAAC,EAChF,cAA+E,CAAC,EAChF,UAA+E,KAG/E,gBAAmC,GAEnC,eAAmC,GAEnC,gBAAyC,KACzC,gBAAyC,KAEzC,kBAA2C,KAgC3C,aAAuB,EAAuB,CAC1C,KAAK,UAAY,IAAI,EAAgB,KAAM,MAAe,KAAK,eAAe,CAAC,EAI/E,IAAK,IAAM,KAAU,KAAK,UAAU,aAAa,EAC7C,KAAK,YAAY,CAAM,CAE/B,CAMA,gBAAiC,CAC7B,KAAK,aAAa,CACtB,CAgBA,YAA6B,CACzB,IAAK,IAAM,KAAO,KAAK,SACnB,EAAI,QAAQ,EAGhB,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EACf,GAAI,CAAC,EAAE,IAAI,CAAI,EACX,MAAO,GAIf,MAAO,EACX"}
@@ -2,7 +2,7 @@ import { Button, ButtonOptions } from "../../component/button/Button.js";
2
2
  export interface TabCloseButtonOptions extends ButtonOptions {
3
3
  }
4
4
  declare class TabCloseButton extends Button<TabCloseButtonOptions> {
5
- constructor(options?: TabCloseButtonOptions);
5
+ constructor(options?: TabCloseButtonOptions, subclassDefaults?: Partial<TabCloseButtonOptions>);
6
6
  }
7
7
  declare const TabCloseButtonCallable: import("../../core/Callable.js").Callable<typeof TabCloseButton>;
8
8
  type TabCloseButtonCallable = TabCloseButton;
@@ -23,7 +23,7 @@ declare class CollapseButton extends Component<CollapseButtonOptions> {
23
23
  protected emit(event: CollapseButtonEvent): void;
24
24
  private onDoubleClick;
25
25
  private onMouseDown;
26
- destroy(): void;
26
+ protected destructor(): void;
27
27
  }
28
28
  declare const CollapseButtonCallable: import("../../core/Callable.js").Callable<typeof CollapseButton>;
29
29
  type CollapseButtonCallable = CollapseButton;
@@ -3,7 +3,7 @@ import { Event } from "../../core/Event.js";
3
3
  interface DialogBackdropOptions extends ComponentOptions {
4
4
  }
5
5
  declare class DialogBackdrop extends Component<DialogBackdropOptions> {
6
- constructor(options?: DialogBackdropOptions);
6
+ constructor(options?: DialogBackdropOptions, subclassDefaults?: Partial<DialogBackdropOptions>);
7
7
  addClickListener(listener: Event.Listener): this;
8
8
  resize(): void;
9
9
  destroy(): void;
@@ -1,4 +1,5 @@
1
1
  import { Component, ComponentOptions } from "../../core/Component.js";
2
+ import { BorderOptions } from "../../primitive/Border.js";
2
3
  export interface MenuItemOptions extends ComponentOptions {
3
4
  text?: string;
4
5
  enabled?: boolean;
@@ -58,6 +59,9 @@ declare class MenuItem extends Component {
58
59
  activate(): void;
59
60
  protected destructor(): void;
60
61
  getBaseline(): number | null;
62
+ private updateLabelHeights;
63
+ setBorder(options: BorderOptions | string): this;
64
+ clearBorder(): this;
61
65
  doLayout(): this;
62
66
  }
63
67
  declare const MenuItemCallable: import("../../core/Callable.js").Callable<typeof MenuItem>;
@@ -4,7 +4,7 @@ export interface MenuSeparatorOptions extends ComponentOptions {
4
4
  }
5
5
  declare class MenuSeparator extends Component<MenuSeparatorOptions> {
6
6
  static readonly HEIGHT: number;
7
- constructor(cssVarPrefix?: MenuItemCSSVarPrefix, options?: MenuSeparatorOptions);
7
+ constructor(cssVarPrefix?: MenuItemCSSVarPrefix, options?: MenuSeparatorOptions, subclassDefaults?: Partial<MenuSeparatorOptions>);
8
8
  }
9
9
  declare const MenuSeparatorCallable: import("../../core/Callable.js").Callable<typeof MenuSeparator>;
10
10
  type MenuSeparatorCallable = MenuSeparator;
@@ -45,6 +45,7 @@ declare class Scrollbar extends Component<ScrollbarOptions> {
45
45
  getArrowStep(): number;
46
46
  setArrowStep(px: number): this;
47
47
  private isVertical;
48
+ private axisBox;
48
49
  private getTrackLength;
49
50
  private getTrackOrigin;
50
51
  private setThumbSize;
@@ -27,7 +27,7 @@ declare class SplitGutter extends Component<SplitGutterOptions> {
27
27
  private _expandedBackground;
28
28
  private _tooltipText;
29
29
  private _listeners;
30
- constructor(direction: String, options?: SplitGutterOptions);
30
+ constructor(direction: String, options?: SplitGutterOptions, subclassDefaults?: Partial<SplitGutterOptions>);
31
31
  protected init(element?: Handle): this;
32
32
  isCollapsible(): boolean;
33
33
  setCollapsible(value: boolean): this;
@@ -50,7 +50,7 @@ declare class SplitGutter extends Component<SplitGutterOptions> {
50
50
  protected emit(event: "drag", position: number): void;
51
51
  protected emit(event: "dragend"): void;
52
52
  protected emit(event: "collapse"): void;
53
- destroy(): void;
53
+ protected destructor(): void;
54
54
  private _dispatchDrag;
55
55
  onDragStart(evnt: MouseEvent): void;
56
56
  onDragStop(): Event.ListenerResult;
@@ -11,7 +11,7 @@ declare class StatusBar extends Container<StatusBarOptions> {
11
11
  private _messageTimer;
12
12
  private _messageText;
13
13
  private _spacer;
14
- constructor(options?: StatusBarOptions);
14
+ constructor(options?: StatusBarOptions, subclassDefaults?: Partial<StatusBarOptions>);
15
15
  protected applyOptions(options: StatusBarOptions): this;
16
16
  addLeft(component: Component): this;
17
17
  addRight(component: Component): this;
@@ -16,6 +16,7 @@ export declare class VirtualScroller {
16
16
  private _shadowOverlay;
17
17
  private _shadowEdges;
18
18
  constructor(owner: Component, element: Handle, onScroll: VirtualScrollerOnScroll);
19
+ dispose(): void;
19
20
  ownedHandles(): readonly Handle[];
20
21
  getRowsContainer(): Handle;
21
22
  getScrollY(): number;
@@ -25,7 +25,7 @@ declare class WindowBorder extends Component<WindowBorderOptions> {
25
25
  private _snapTarget;
26
26
  private _snapTargetStyleRule?;
27
27
  private get snapTargetStyleRule();
28
- constructor(direction: Direction, options?: WindowBorderOptions);
28
+ constructor(direction: Direction, options?: WindowBorderOptions, subclassDefaults?: Partial<WindowBorderOptions>);
29
29
  getDirection(): Direction;
30
30
  setDirection(direction: Direction): this;
31
31
  on(event: "drag", listener: (border: WindowBorder, e: MouseEvent) => void): this;
@@ -2,6 +2,7 @@ import { Component, ComponentOptions } from "../../core/Component.js";
2
2
  import type { Handle } from "../../core/DOM.js";
3
3
  import type { ElkEdgeSection } from "../../component/diagram/ElkLayoutEngine.js";
4
4
  import type { DiagramEdgeStyle } from "../../component/diagram/DiagramModel.js";
5
+ export declare const EDGE_MARKER_EXTENT: number;
5
6
  export interface DiagramEdgeRoute {
6
7
  id: string;
7
8
  sections: ElkEdgeSection[];
@@ -9,17 +10,29 @@ export interface DiagramEdgeRoute {
9
10
  }
10
11
  declare class DiagramEdgeLayer extends Component<ComponentOptions> {
11
12
  private _edges;
12
- private _pathHandles;
13
+ private _drawn;
14
+ private _edgeEmphasis;
15
+ private _dimLayer;
16
+ private _normalLayer;
13
17
  private readonly _markerId;
14
18
  private readonly _crowsFootMarkerIds;
15
19
  constructor(options?: ComponentOptions);
16
20
  private markerUrl;
17
21
  setEdges(edges: DiagramEdgeRoute[]): this;
22
+ setEdgeEmphasis(ids: readonly string[] | null): this;
23
+ getEdgeEmphasis(): string[];
24
+ edgeIdAt(target: EventTarget | null): string | null;
25
+ edgesNear(x: number, y: number): DiagramEdgeRoute[];
26
+ private groupFor;
18
27
  protected createRootElement(): Handle;
28
+ private createEdgeGroup;
19
29
  private createArrowMarker;
20
30
  private createCrowsFootMarker;
21
31
  protected render(): Handle;
22
32
  private rebuildPaths;
33
+ private drawHitPath;
34
+ private drawVisiblePath;
35
+ private releaseDrawnEdge;
23
36
  private drawLabel;
24
37
  }
25
38
  declare const DiagramEdgeLayerCallable: import("../../core/Callable.js").Callable<typeof DiagramEdgeLayer>;
@@ -10,6 +10,7 @@ export interface DiagramNodeData {
10
10
  id: string;
11
11
  label?: string;
12
12
  glyph?: string;
13
+ badge?: string;
13
14
  width?: number;
14
15
  height?: number;
15
16
  layoutOptions?: Record<string, string>;
@@ -3,17 +3,21 @@ import type { Handle } from "../../core/DOM.js";
3
3
  export interface DiagramNodeOptions extends PanelOptions {
4
4
  label?: string;
5
5
  glyph?: string;
6
+ badge?: string;
6
7
  selected?: boolean;
7
8
  }
8
9
  declare class DiagramNode extends Panel<DiagramNodeOptions> {
10
+ private _label;
9
11
  private _content;
12
+ private _badge?;
10
13
  private _selectedStyleRule?;
11
14
  private get selectedStyleRule();
12
- constructor(options?: DiagramNodeOptions);
15
+ constructor(options?: DiagramNodeOptions, subclassDefaults?: Partial<DiagramNodeOptions>);
13
16
  protected applyOptions(options: DiagramNodeOptions): this;
14
17
  private buildContent;
15
18
  setLabel(value: string): this;
16
19
  getLabel(): string | null;
20
+ getBadge(): string | null;
17
21
  setSelected(value: boolean): this;
18
22
  isSelected(): boolean;
19
23
  protected init(element?: Handle): this;
@@ -1,23 +1,29 @@
1
1
  import { Panel, PanelOptions } from "../../core/Panel.js";
2
2
  import { Component } from "../../core/Component.js";
3
3
  import type { Handle } from "../../core/DOM.js";
4
- import { DiagramData, DiagramNodeData } from "../../component/diagram/DiagramModel.js";
4
+ import { DiagramData, DiagramEdgeData, DiagramNodeData } from "../../component/diagram/DiagramModel.js";
5
5
  import { ElkLayoutEngine } from "../../component/diagram/ElkLayoutEngine.js";
6
6
  export type DiagramNodeRenderer = (data: DiagramNodeData) => Component;
7
- export type DiagramViewEvent = "selection" | "activate" | "layout";
7
+ export type DiagramViewEvent = "selection" | "activate" | "layout" | "contextmenu" | "edgehover" | "edgeleave";
8
8
  export interface DiagramViewOptions extends PanelOptions {
9
9
  data?: DiagramData;
10
10
  nodeRenderer?: DiagramNodeRenderer;
11
11
  groupRenderer?: DiagramNodeRenderer;
12
12
  layoutOptions?: Record<string, string>;
13
13
  elkWorkerUrl?: string;
14
+ elkWorkerFactory?: () => Worker;
14
15
  minZoom?: number;
15
16
  maxZoom?: number;
16
17
  zoom?: number;
18
+ controls?: boolean;
19
+ initialFocusNode?: string;
17
20
  listeners?: {
18
21
  selection?: (nodes: DiagramNodeData[]) => void;
19
22
  activate?: (node: DiagramNodeData) => void;
20
23
  layout?: () => void;
24
+ contextmenu?: (node: DiagramNodeData, event: MouseEvent) => void;
25
+ edgehover?: (edges: DiagramEdgeData[], event: MouseEvent) => void;
26
+ edgeleave?: () => void;
21
27
  };
22
28
  }
23
29
  declare class DiagramView extends Panel<DiagramViewOptions> {
@@ -27,53 +33,118 @@ declare class DiagramView extends Panel<DiagramViewOptions> {
27
33
  private _nodeComponents;
28
34
  private _nodeData;
29
35
  private _containerIds;
36
+ private _incomingComponents;
37
+ private _incomingData;
38
+ private _incomingContainerIds;
30
39
  private _selection;
40
+ private _nodeEmphasis;
31
41
  private _layoutGeneration;
42
+ private _layoutSettled;
43
+ private _busySpinner;
32
44
  private _graphWidth;
33
45
  private _graphHeight;
34
46
  private _listeners;
47
+ private _hoveredEdgeKey;
35
48
  private _panning;
36
49
  private _panStartX;
37
50
  private _panStartY;
38
- private _panScrollLeft;
39
- private _panScrollTop;
51
+ private _pressX;
52
+ private _pressY;
53
+ private _pointerMoved;
54
+ private _panOriginX;
55
+ private _panOriginY;
56
+ private _panX;
57
+ private _panY;
58
+ private _needsInitialCentre;
59
+ private _focusNodeId;
60
+ private _lastViewportWidth;
61
+ private _lastViewportHeight;
62
+ private _controls;
63
+ private _zoomInBtn;
64
+ private _zoomOutBtn;
65
+ private _fitBtn;
66
+ private _resetBtn;
67
+ private readonly _onZoomIn;
68
+ private readonly _onZoomOut;
69
+ private readonly _onFit;
70
+ private readonly _onReset;
40
71
  constructor(options?: DiagramViewOptions);
41
72
  protected createEngine(): ElkLayoutEngine;
73
+ protected destructor(): void;
42
74
  protected applyOptions(options: DiagramViewOptions): this;
43
75
  setData(data: DiagramData): this;
44
76
  getData(): DiagramData | null;
45
77
  private rebuildNodes;
78
+ private discardIncomingNodes;
79
+ private promoteIncomingNodes;
46
80
  private relayout;
81
+ private armLayoutSettled;
82
+ private settleLayout;
83
+ private syncBusyIndicator;
84
+ whenLaidOut(): Promise<void>;
47
85
  private collectNodeSizes;
48
86
  private applyLayout;
49
87
  private applyContainerZIndex;
50
88
  private joinEdgeStyles;
51
89
  private handleLayoutFailure;
52
- private applyZoomToHost;
90
+ private applyTransformToHost;
53
91
  getZoom(): number;
54
92
  setZoom(zoom: number): this;
55
93
  zoomToFit(): this;
94
+ resetView(): this;
95
+ zoomIn(): this;
96
+ zoomOut(): this;
97
+ private tryInitialCentre;
98
+ private centreGraph;
99
+ private zoomAboutViewportPoint;
100
+ private effectiveMinZoom;
56
101
  private clampZoom;
102
+ private zoomFittingNode;
57
103
  getSelection(): DiagramNodeData[];
58
104
  selectNode(id: string | null): this;
105
+ setEdgeEmphasis(ids: readonly string[] | null): this;
106
+ getEdgeEmphasis(): string[];
107
+ setNodeEmphasis(ids: readonly string[] | null): this;
108
+ getNodeEmphasis(): string[];
109
+ private applyNodeEmphasis;
59
110
  revealNode(id: string): this;
111
+ private centreNode;
112
+ focusNode(id: string): this;
60
113
  private setSelection;
61
114
  private applySelectedVisual;
62
115
  on(event: "selection", listener: (nodes: DiagramNodeData[]) => void): this;
63
116
  on(event: "activate", listener: (node: DiagramNodeData) => void): this;
64
117
  on(event: "layout", listener: () => void): this;
118
+ on(event: "contextmenu", listener: (node: DiagramNodeData, event: MouseEvent) => void): this;
119
+ on(event: "edgehover", listener: (edges: DiagramEdgeData[], event: MouseEvent) => void): this;
120
+ on(event: "edgeleave", listener: () => void): this;
65
121
  off(event: DiagramViewEvent, listener: Function): this;
66
122
  protected emit(event: "selection", nodes: DiagramNodeData[]): void;
67
123
  protected emit(event: "activate", node: DiagramNodeData): void;
68
124
  protected emit(event: "layout"): void;
125
+ protected emit(event: "contextmenu", node: DiagramNodeData, mouseEvent: MouseEvent): void;
126
+ protected emit(event: "edgehover", edges: DiagramEdgeData[], mouseEvent: MouseEvent): void;
127
+ protected emit(event: "edgeleave"): void;
128
+ doLayout(): this;
129
+ private anchorCentreAcrossResize;
69
130
  protected init(element?: Handle): this;
70
131
  private _handleClick;
71
132
  private _handleDoubleClick;
72
133
  private nodeIdAt;
134
+ private _handleEdgeMouseMove;
135
+ private _handleEdgeMouseOut;
136
+ private leaveEdges;
137
+ private _handleContextMenu;
138
+ private isControlsTarget;
73
139
  private _handleWheel;
74
140
  private _handlePointerDown;
75
141
  private _handlePointerMove;
76
142
  private _handlePointerUp;
143
+ private buildControls;
144
+ private makeControlButton;
145
+ private wireControlListeners;
146
+ isControlsVisible(): boolean;
147
+ setControlsVisible(value: boolean): this;
77
148
  }
78
149
  declare const DiagramViewCallable: import("../../core/Callable.js").Callable<typeof DiagramView>;
79
150
  type DiagramViewCallable = DiagramView;
@@ -54,14 +54,27 @@ export declare function buildElkGraph(data: DiagramData, sizes: Map<string, {
54
54
  height: number;
55
55
  }>, defaults?: Record<string, string>): ElkNode;
56
56
  export declare function mapElkResult(result: ElkNode): DiagramLayoutResult;
57
+ export interface ElkLayoutEngineOptions {
58
+ workerFactory?: () => Worker;
59
+ workerUrl?: string;
60
+ }
57
61
  export declare class ElkLayoutEngine {
58
62
  private _elk;
63
+ private readonly _workerFactory?;
59
64
  private readonly _workerUrl?;
60
- constructor(workerUrl?: string);
65
+ private _workerBacked;
66
+ private _disposed;
67
+ private _ownsWorker;
68
+ private _building;
69
+ constructor(options?: ElkLayoutEngineOptions);
61
70
  layout(data: DiagramData, sizes: Map<string, {
62
71
  width: number;
63
72
  height: number;
64
73
  }>, defaults?: Record<string, string>): Promise<DiagramLayoutResult>;
74
+ dispose(): void;
65
75
  private ensureElk;
76
+ private terminateOwnedWorker;
77
+ private createElk;
78
+ private createMainThreadElk;
66
79
  }
67
80
  export {};