@ccslabs/xtend 0.1.0-rc.1

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 (664) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/LICENSE +201 -0
  3. package/README.md +184 -0
  4. package/a11y/motion-contrast-policy.d.ts +32 -0
  5. package/a11y/motion-contrast-policy.js +261 -0
  6. package/a11y/runtime-a11y-contract.d.ts +44 -0
  7. package/a11y/runtime-a11y-contract.js +385 -0
  8. package/a11y/screenreader-signals.d.ts +32 -0
  9. package/a11y/screenreader-signals.js +372 -0
  10. package/api.d.ts +168 -0
  11. package/api.js +864 -0
  12. package/catalog/catalog-public-types.d.ts +66 -0
  13. package/catalog/component-catalog-coverage.d.ts +20 -0
  14. package/catalog/component-catalog-coverage.js +377 -0
  15. package/catalog/component-long-tail-migration.d.ts +18 -0
  16. package/catalog/component-long-tail-migration.js +305 -0
  17. package/catalog/component-regression-priority.d.ts +20 -0
  18. package/catalog/component-regression-priority.js +305 -0
  19. package/catalog/enterprise-component-flex-release-handoff.d.ts +32 -0
  20. package/catalog/enterprise-component-flex-release-handoff.js +437 -0
  21. package/catalog/enterprise-component-style-audit.d.ts +22 -0
  22. package/catalog/enterprise-component-style-audit.js +353 -0
  23. package/catalog/enterprise-form-control-theme-a11y.d.ts +19 -0
  24. package/catalog/enterprise-form-control-theme-a11y.js +220 -0
  25. package/catalog/enterprise-icon-control-audit.d.ts +21 -0
  26. package/catalog/enterprise-icon-control-audit.js +258 -0
  27. package/catalog/enterprise-layout-display-media-tokenization.d.ts +20 -0
  28. package/catalog/enterprise-layout-display-media-tokenization.js +237 -0
  29. package/catalog/enterprise-navigation-routing-state-hardening.d.ts +20 -0
  30. package/catalog/enterprise-navigation-routing-state-hardening.js +255 -0
  31. package/catalog/enterprise-overlay-mode-token-parity.d.ts +15 -0
  32. package/catalog/enterprise-overlay-mode-token-parity.js +178 -0
  33. package/catalog/enterprise-third-party-authoring-guide.d.ts +23 -0
  34. package/catalog/enterprise-third-party-authoring-guide.js +310 -0
  35. package/catalog/enterprise-visual-dom-snapshot-matrix.d.ts +31 -0
  36. package/catalog/enterprise-visual-dom-snapshot-matrix.js +357 -0
  37. package/catalog/epic10-existing-component-metadata.d.ts +25 -0
  38. package/catalog/epic10-existing-component-metadata.js +534 -0
  39. package/catalog/epic10-p0-component-wave.d.ts +28 -0
  40. package/catalog/epic10-p0-component-wave.js +688 -0
  41. package/catalog/epic10-platform-gates.d.ts +31 -0
  42. package/catalog/epic10-platform-gates.js +425 -0
  43. package/catalog/epic10-release-handoff.d.ts +30 -0
  44. package/catalog/epic10-release-handoff.js +195 -0
  45. package/catalog/epic11-enterprise-ux-handoff.d.ts +29 -0
  46. package/catalog/epic11-enterprise-ux-handoff.js +403 -0
  47. package/catalog/epic12-docs-adoption.d.ts +29 -0
  48. package/catalog/epic12-docs-adoption.js +183 -0
  49. package/catalog/epic12-rc0-gate-matrix.d.ts +36 -0
  50. package/catalog/epic12-rc0-gate-matrix.js +439 -0
  51. package/catalog/epic12-rc0-handoff.d.ts +30 -0
  52. package/catalog/epic12-rc0-handoff.js +385 -0
  53. package/catalog/epic13-conditional-network-evidence-ci.d.ts +35 -0
  54. package/catalog/epic13-conditional-network-evidence-ci.js +278 -0
  55. package/catalog/epic13-conditional-network-evidence.d.ts +34 -0
  56. package/catalog/epic13-conditional-network-evidence.js +280 -0
  57. package/catalog/epic13-docs-rmt-production-hardening.d.ts +39 -0
  58. package/catalog/epic13-docs-rmt-production-hardening.js +286 -0
  59. package/catalog/epic13-hydration-performance-closure.d.ts +33 -0
  60. package/catalog/epic13-hydration-performance-closure.js +234 -0
  61. package/catalog/epic13-known-residual-triage.d.ts +32 -0
  62. package/catalog/epic13-known-residual-triage.js +339 -0
  63. package/catalog/epic13-package-export-lock.d.ts +41 -0
  64. package/catalog/epic13-package-export-lock.js +604 -0
  65. package/catalog/epic13-prod-browser-csp-smoke.d.ts +35 -0
  66. package/catalog/epic13-prod-browser-csp-smoke.js +218 -0
  67. package/catalog/epic13-rc1-gate-matrix-ci-handoff.d.ts +36 -0
  68. package/catalog/epic13-rc1-gate-matrix-ci-handoff.js +418 -0
  69. package/catalog/epic13-rc1-migration-notes.d.ts +36 -0
  70. package/catalog/epic13-rc1-migration-notes.js +271 -0
  71. package/catalog/epic13-rc1-readiness.d.ts +33 -0
  72. package/catalog/epic13-rc1-readiness.js +487 -0
  73. package/catalog/epic13-release-owner-acceptance.d.ts +33 -0
  74. package/catalog/epic13-release-owner-acceptance.js +354 -0
  75. package/catalog/epic13-release-report-pack-dry-run-evidence.d.ts +36 -0
  76. package/catalog/epic13-release-report-pack-dry-run-evidence.js +253 -0
  77. package/catalog/epic13-rmt-production-readiness.d.ts +35 -0
  78. package/catalog/epic13-rmt-production-readiness.js +314 -0
  79. package/catalog/epic13-trusted-dom-boundary.d.ts +36 -0
  80. package/catalog/epic13-trusted-dom-boundary.js +230 -0
  81. package/catalog/epic13-visual-owner-artifact.d.ts +35 -0
  82. package/catalog/epic13-visual-owner-artifact.js +233 -0
  83. package/catalog/epic14-lsp-handoff.d.ts +28 -0
  84. package/catalog/epic14-lsp-handoff.js +312 -0
  85. package/catalog/epic14-rmt-tooling.d.ts +33 -0
  86. package/catalog/epic14-rmt-tooling.js +282 -0
  87. package/catalog/surface-manager-adapter-runtime.d.ts +37 -0
  88. package/catalog/surface-manager-adapter-runtime.js +203 -0
  89. package/catalog/surface-manager-browser-lab.d.ts +39 -0
  90. package/catalog/surface-manager-browser-lab.js +225 -0
  91. package/catalog/surface-manager-controller.d.ts +43 -0
  92. package/catalog/surface-manager-controller.js +290 -0
  93. package/catalog/surface-manager-layout-engines.d.ts +32 -0
  94. package/catalog/surface-manager-layout-engines.js +161 -0
  95. package/catalog/surface-manager-lazy-loading.d.ts +35 -0
  96. package/catalog/surface-manager-lazy-loading.js +173 -0
  97. package/catalog/surface-manager-materialization.d.ts +37 -0
  98. package/catalog/surface-manager-materialization.js +202 -0
  99. package/catalog/surface-manager-native-rmt-surfaces.d.ts +48 -0
  100. package/catalog/surface-manager-native-rmt-surfaces.js +325 -0
  101. package/catalog/surface-manager-overlay-bridge.d.ts +42 -0
  102. package/catalog/surface-manager-overlay-bridge.js +247 -0
  103. package/catalog/surface-manager-persistence.d.ts +37 -0
  104. package/catalog/surface-manager-persistence.js +178 -0
  105. package/catalog/surface-manager-quality-gates.d.ts +48 -0
  106. package/catalog/surface-manager-quality-gates.js +324 -0
  107. package/catalog/surface-manager-release-handoff.d.ts +47 -0
  108. package/catalog/surface-manager-release-handoff.js +274 -0
  109. package/catalog/surface-manager-remote-policy.d.ts +34 -0
  110. package/catalog/surface-manager-remote-policy.js +199 -0
  111. package/catalog/surface-manager-rmt-authoring.d.ts +44 -0
  112. package/catalog/surface-manager-rmt-authoring.js +368 -0
  113. package/catalog/surface-manager-route-lifecycle.d.ts +32 -0
  114. package/catalog/surface-manager-route-lifecycle.js +162 -0
  115. package/catalog/surface-manager-runtime-release-handoff.d.ts +36 -0
  116. package/catalog/surface-manager-runtime-release-handoff.js +245 -0
  117. package/catalog/surface-manager-side-panel-runtime.d.ts +46 -0
  118. package/catalog/surface-manager-side-panel-runtime.js +307 -0
  119. package/catalog/surface-manager-stack-policy.d.ts +32 -0
  120. package/catalog/surface-manager-stack-policy.js +169 -0
  121. package/catalog/surface-manager-window-runtime.d.ts +45 -0
  122. package/catalog/surface-manager-window-runtime.js +285 -0
  123. package/catalog/surface-manager-workbench-fixture.d.ts +50 -0
  124. package/catalog/surface-manager-workbench-fixture.js +315 -0
  125. package/catalog/type-exports-api.js +236 -0
  126. package/catalog/type-exports-builder.js +405 -0
  127. package/catalog/type-exports-catalog.js +394 -0
  128. package/catalog/type-exports-loader.js +266 -0
  129. package/catalog/type-exports-policy.js +461 -0
  130. package/catalog/type-exports-rmt.js +407 -0
  131. package/catalog/type-exports-vendor.js +365 -0
  132. package/catalog/type-exports.js +574 -0
  133. package/components/icon-packs/core.js +154 -0
  134. package/components/icon-packs/lucide.js +136 -0
  135. package/components/manifest.json +44 -0
  136. package/components/prism.d.ts +73 -0
  137. package/components/prism.js +300 -0
  138. package/components/turndown.d.ts +34 -0
  139. package/components/turndown.js +107 -0
  140. package/components/x-rmt-lifecycle-demo-build.d.ts +78 -0
  141. package/components/x-rmt-lifecycle-demo-build.js +1175 -0
  142. package/components/x-rmt-lifecycle-demo.d.ts +83 -0
  143. package/components/x-rmt-lifecycle-demo.js +1175 -0
  144. package/components/xalert.d.ts +42 -0
  145. package/components/xalert.js +538 -0
  146. package/components/xbutton.d.ts +127 -0
  147. package/components/xbutton.js +612 -0
  148. package/components/xcalendar.d.ts +39 -0
  149. package/components/xcalendar.js +338 -0
  150. package/components/xcards.d.ts +34 -0
  151. package/components/xcards.js +253 -0
  152. package/components/xcheckbox.d.ts +48 -0
  153. package/components/xcheckbox.js +448 -0
  154. package/components/xcode.d.ts +35 -0
  155. package/components/xcode.js +370 -0
  156. package/components/xdialog.d.ts +48 -0
  157. package/components/xdialog.js +763 -0
  158. package/components/xdrawer.d.ts +61 -0
  159. package/components/xdrawer.js +654 -0
  160. package/components/xfooter.d.ts +41 -0
  161. package/components/xfooter.js +351 -0
  162. package/components/xform.d.ts +43 -0
  163. package/components/xform.js +456 -0
  164. package/components/xheader.d.ts +68 -0
  165. package/components/xheader.js +1253 -0
  166. package/components/xhero.d.ts +42 -0
  167. package/components/xhero.js +475 -0
  168. package/components/xicon.d.ts +146 -0
  169. package/components/xicon.js +688 -0
  170. package/components/xinput.d.ts +37 -0
  171. package/components/xinput.js +444 -0
  172. package/components/xlightbox.d.ts +48 -0
  173. package/components/xlightbox.js +571 -0
  174. package/components/xlink.d.ts +63 -0
  175. package/components/xlink.js +565 -0
  176. package/components/xmasonry.d.ts +35 -0
  177. package/components/xmasonry.js +666 -0
  178. package/components/xmenu.d.ts +118 -0
  179. package/components/xmenu.js +1005 -0
  180. package/components/xmodal.d.ts +64 -0
  181. package/components/xmodal.js +831 -0
  182. package/components/xplayer.d.ts +57 -0
  183. package/components/xplayer.js +1748 -0
  184. package/components/xpopover.d.ts +54 -0
  185. package/components/xpopover.js +466 -0
  186. package/components/xprogress.d.ts +40 -0
  187. package/components/xprogress.js +345 -0
  188. package/components/xradio.d.ts +50 -0
  189. package/components/xradio.js +474 -0
  190. package/components/xrouter.d.ts +244 -0
  191. package/components/xrouter.js +1841 -0
  192. package/components/xsection.d.ts +34 -0
  193. package/components/xsection.js +253 -0
  194. package/components/xselect.d.ts +46 -0
  195. package/components/xselect.js +463 -0
  196. package/components/xsidepanel.d.ts +56 -0
  197. package/components/xsidepanel.js +728 -0
  198. package/components/xspinner.d.ts +38 -0
  199. package/components/xspinner.js +388 -0
  200. package/components/xstate.d.ts +137 -0
  201. package/components/xstate.js +493 -0
  202. package/components/xstatus.d.ts +41 -0
  203. package/components/xstatus.js +381 -0
  204. package/components/xsummary.d.ts +43 -0
  205. package/components/xsummary.js +293 -0
  206. package/components/xsurfacemanager-controller.d.ts +130 -0
  207. package/components/xsurfacemanager-controller.js +699 -0
  208. package/components/xsurfacemanager.d.ts +452 -0
  209. package/components/xsurfacemanager.js +3775 -0
  210. package/components/xsurfaceoverlay-bridge.d.ts +43 -0
  211. package/components/xsurfaceoverlay-bridge.js +238 -0
  212. package/components/xsurfacewindow.d.ts +50 -0
  213. package/components/xsurfacewindow.js +576 -0
  214. package/components/xtabs.d.ts +73 -0
  215. package/components/xtabs.js +611 -0
  216. package/components/xtend-public-types.d.ts +208 -0
  217. package/components/xtextarea.d.ts +46 -0
  218. package/components/xtextarea.js +451 -0
  219. package/components/xtheme.d.ts +253 -0
  220. package/components/xtheme.js +1438 -0
  221. package/components/xtoast.d.ts +39 -0
  222. package/components/xtoast.js +389 -0
  223. package/components/xtooltip.d.ts +53 -0
  224. package/components/xtooltip.js +432 -0
  225. package/components/xtype.d.ts +42 -0
  226. package/components/xtype.js +244 -0
  227. package/components/xutils.d.ts +164 -0
  228. package/components/xutils.js +496 -0
  229. package/components/xwriter.d.ts +67 -0
  230. package/components/xwriter.js +854 -0
  231. package/design-tokens/themes/enterprise-light.json +40 -0
  232. package/design-tokens/themes/xtend-signature.json +126 -0
  233. package/design-tokens/xtend-design-tokens.d.ts +95 -0
  234. package/design-tokens/xtend-design-tokens.js +395 -0
  235. package/design-tokens/xtheme-token-alias-layer.d.ts +84 -0
  236. package/design-tokens/xtheme-token-alias-layer.js +423 -0
  237. package/docs/.htaccess +51 -0
  238. package/docs/README.md +340 -0
  239. package/docs/XTend-ADR.md +221 -0
  240. package/docs/a11y-keyboard-smokes.md +62 -0
  241. package/docs/about.md +18 -0
  242. package/docs/api.md +157 -0
  243. package/docs/best-practices.md +76 -0
  244. package/docs/component-catalog-coverage.md +58 -0
  245. package/docs/component-lab.md +103 -0
  246. package/docs/component-long-tail-migration.md +41 -0
  247. package/docs/component-platform.md +159 -0
  248. package/docs/component-ux-app-authoring.md +130 -0
  249. package/docs/component-ux-authoring.md +96 -0
  250. package/docs/component-ux-gates.md +45 -0
  251. package/docs/components/x-rmt-lifecycle-demo-build.md +60 -0
  252. package/docs/components/xalert.md +81 -0
  253. package/docs/components/xbutton.md +103 -0
  254. package/docs/components/xcalendar.md +82 -0
  255. package/docs/components/xcards.md +128 -0
  256. package/docs/components/xcheckbox.md +102 -0
  257. package/docs/components/xcode.md +126 -0
  258. package/docs/components/xdialog.md +92 -0
  259. package/docs/components/xdrawer.md +84 -0
  260. package/docs/components/xfooter.md +126 -0
  261. package/docs/components/xform.md +128 -0
  262. package/docs/components/xheader.md +308 -0
  263. package/docs/components/xhero.md +142 -0
  264. package/docs/components/xicon.md +125 -0
  265. package/docs/components/xinput.md +129 -0
  266. package/docs/components/xlightbox.md +98 -0
  267. package/docs/components/xlink.md +109 -0
  268. package/docs/components/xmasonry.md +124 -0
  269. package/docs/components/xmenu.md +158 -0
  270. package/docs/components/xmodal.md +82 -0
  271. package/docs/components/xplayer.md +104 -0
  272. package/docs/components/xpopover.md +67 -0
  273. package/docs/components/xprogress.md +56 -0
  274. package/docs/components/xradio.md +103 -0
  275. package/docs/components/xrouter.md +260 -0
  276. package/docs/components/xsection.md +125 -0
  277. package/docs/components/xselect.md +105 -0
  278. package/docs/components/xsidepanel.md +30 -0
  279. package/docs/components/xspinner.md +102 -0
  280. package/docs/components/xstate.md +148 -0
  281. package/docs/components/xstatus.md +55 -0
  282. package/docs/components/xsummary.md +78 -0
  283. package/docs/components/xsurfacemanager.md +27 -0
  284. package/docs/components/xsurfacewindow.md +21 -0
  285. package/docs/components/xtabs.md +160 -0
  286. package/docs/components/xtextarea.md +98 -0
  287. package/docs/components/xtheme.md +167 -0
  288. package/docs/components/xtoast.md +62 -0
  289. package/docs/components/xtooltip.md +66 -0
  290. package/docs/components/xtype.md +82 -0
  291. package/docs/components/xutils.md +144 -0
  292. package/docs/components/xwriter.md +94 -0
  293. package/docs/components.md +117 -0
  294. package/docs/conditional-network-evidence-ci.md +38 -0
  295. package/docs/conditional-network-evidence.md +50 -0
  296. package/docs/core-migration-guide.md +110 -0
  297. package/docs/design-tokens.md +116 -0
  298. package/docs/docs-rmt-production-hardening.md +31 -0
  299. package/docs/enterprise-adoption.md +411 -0
  300. package/docs/enterprise-component-flex-release-handoff.md +129 -0
  301. package/docs/epic10-platform-gates.md +62 -0
  302. package/docs/epic10-release-handoff.md +81 -0
  303. package/docs/epic11-enterprise-ux-handoff.md +70 -0
  304. package/docs/epic12-rc0-handoff.md +61 -0
  305. package/docs/existing-component-metadata.md +67 -0
  306. package/docs/hydration-performance-closure.md +34 -0
  307. package/docs/hydration-policies.md +71 -0
  308. package/docs/index.php +1625 -0
  309. package/docs/known-residual-triage.md +22 -0
  310. package/docs/manifest-import-policy.md +79 -0
  311. package/docs/manifest.md +106 -0
  312. package/docs/menu.json +1190 -0
  313. package/docs/motion-contrast.md +67 -0
  314. package/docs/package-export-lock.md +44 -0
  315. package/docs/performance-measurements.md +106 -0
  316. package/docs/performance-regression.md +89 -0
  317. package/docs/performance.md +94 -0
  318. package/docs/previews/README.md +17 -0
  319. package/docs/prod-browser-csp-smokes.md +40 -0
  320. package/docs/public-component-types.md +79 -0
  321. package/docs/quick-start-guide.md +152 -0
  322. package/docs/rc0-adoption-guide.md +102 -0
  323. package/docs/rc0-gate-matrix.md +58 -0
  324. package/docs/rc1-gate-matrix-ci-handoff.md +56 -0
  325. package/docs/rc1-migration-notes.md +69 -0
  326. package/docs/rc1-readiness.md +46 -0
  327. package/docs/release-owner-acceptance.md +56 -0
  328. package/docs/release-report-pack-dry-run-evidence.md +39 -0
  329. package/docs/rmt-dsl-authoring-polish.md +122 -0
  330. package/docs/rmt-first-demo-app.md +77 -0
  331. package/docs/rmt-first-xtend-apps.md +105 -0
  332. package/docs/rmt-kernel-panic-recovery-incident-handoff.md +61 -0
  333. package/docs/rmt-kernel-security-hardening-migration.md +50 -0
  334. package/docs/rmt-kernel-trusted-output-authoring.md +69 -0
  335. package/docs/rmt-language-server.md +177 -0
  336. package/docs/rmt-lifecycle-demo.md +25 -0
  337. package/docs/rmt-linter.md +140 -0
  338. package/docs/rmt-production-readiness.md +63 -0
  339. package/docs/rmt-tooling-release-gates.md +77 -0
  340. package/docs/rmt-vnext-authoring.md +60 -0
  341. package/docs/rmt-vnext-cross-surface-events.md +68 -0
  342. package/docs/rmt-vnext-enterprise-mfe-handoff.md +70 -0
  343. package/docs/rmt-vnext-migration-notes.md +62 -0
  344. package/docs/rmt-vnext-release-handoff.md +69 -0
  345. package/docs/rmt-vnext-remote-surfaces.md +90 -0
  346. package/docs/rmt-vnext-surface-registry-enterprise.md +76 -0
  347. package/docs/screenreader-signals.md +56 -0
  348. package/docs/supply-chain-gates.md +100 -0
  349. package/docs/surface-manager-authoring-guide.md +94 -0
  350. package/docs/surface-manager-browser-lab.md +45 -0
  351. package/docs/surface-manager-component-lab.md +43 -0
  352. package/docs/surface-manager-controller.md +66 -0
  353. package/docs/surface-manager-layout-engines.md +32 -0
  354. package/docs/surface-manager-lazy-hydration.md +63 -0
  355. package/docs/surface-manager-migration-guide.md +94 -0
  356. package/docs/surface-manager-native-rmt-surfaces.md +38 -0
  357. package/docs/surface-manager-overlay-bridge.md +53 -0
  358. package/docs/surface-manager-persistence.md +30 -0
  359. package/docs/surface-manager-quality-gates.md +51 -0
  360. package/docs/surface-manager-release-handoff.md +68 -0
  361. package/docs/surface-manager-remote-policy.md +54 -0
  362. package/docs/surface-manager-rmt-authoring.md +86 -0
  363. package/docs/surface-manager-route-lifecycle.md +59 -0
  364. package/docs/surface-manager-runtime-release-handoff.md +69 -0
  365. package/docs/surface-manager-side-panel-runtime.md +36 -0
  366. package/docs/surface-manager-stack-policy.md +39 -0
  367. package/docs/surface-manager-window-runtime.md +47 -0
  368. package/docs/surface-manager-workbench-fixture.md +43 -0
  369. package/docs/third-party-design-authoring.md +406 -0
  370. package/docs/trusted-dom-boundary-browser-proof.md +32 -0
  371. package/docs/trusted-dom-sanitizing.md +110 -0
  372. package/docs/type-exports.md +61 -0
  373. package/docs/typescript-components.md +63 -0
  374. package/docs/utils/fabric-runtime.js +650 -0
  375. package/docs/utils/pageloader.js +2823 -0
  376. package/docs/utils/parsedown.php +298 -0
  377. package/docs/visual-browser-regression.md +83 -0
  378. package/docs/visual-owner-artifacts.md +46 -0
  379. package/docs/visual-snapshot-automation.md +87 -0
  380. package/docs/xtend-api-types.md +55 -0
  381. package/docs/xtend-builder-types.md +55 -0
  382. package/docs/xtend-catalog-types.md +44 -0
  383. package/docs/xtend-fabric-rmt-lane-mapping.md +143 -0
  384. package/docs/xtend-fabric.md +474 -0
  385. package/docs/xtend-loader-types.md +58 -0
  386. package/docs/xtend-loader.md +265 -0
  387. package/docs/xtend-policy-types.md +38 -0
  388. package/docs/xtend-rmt-types.md +39 -0
  389. package/docs/xtend-vendor-types.md +36 -0
  390. package/docs/xtendrmt-app-dsl.md +269 -0
  391. package/docs/xtendrmt-migration-guide.md +235 -0
  392. package/docs/xtendrmt-native-authoring.md +337 -0
  393. package/docs/xtendrmt-overview.md +89 -0
  394. package/docs/xtendrmt-parsedown-docs.rmt +956 -0
  395. package/docs/xtendrmt-parsedown-scheduling.md +301 -0
  396. package/docs/xtendrmt-runtime-bridge.md +155 -0
  397. package/fabric/hydration-policy.d.ts +27 -0
  398. package/fabric/hydration-policy.js +306 -0
  399. package/fabric/package.json +58 -0
  400. package/fabric/rmt-lane-mapping.d.ts +47 -0
  401. package/fabric/rmt-lane-mapping.js +504 -0
  402. package/fabric/xtend-fabric.d.ts +81 -0
  403. package/fabric/xtend-fabric.js +2669 -0
  404. package/fabric/xtend-policy-public-types.d.ts +135 -0
  405. package/package.json +8225 -0
  406. package/security/README.md +54 -0
  407. package/security/manifest-import-policy.d.ts +43 -0
  408. package/security/manifest-import-policy.js +260 -0
  409. package/security/supply-chain-gate-policy.d.ts +45 -0
  410. package/security/supply-chain-gate-policy.js +249 -0
  411. package/security/trusted-dom-policy.d.ts +36 -0
  412. package/security/trusted-dom-policy.js +316 -0
  413. package/tools/package.json +77 -0
  414. package/tools/rmt-editor/vscode/README.md +33 -0
  415. package/tools/rmt-editor/vscode/extension.d.ts +9 -0
  416. package/tools/rmt-editor/vscode/extension.js +55 -0
  417. package/tools/rmt-editor/vscode/language-configuration.json +28 -0
  418. package/tools/rmt-editor/vscode/package.json +83 -0
  419. package/tools/rmt-editor/vscode/snippets/rmt.code-snippets +243 -0
  420. package/tools/rmt-editor/vscode/syntaxes/rmt.tmLanguage.json +13 -0
  421. package/tools/rmt-editor/vscode/xtend-rmt-language-0.0.0-enterprise-readiness.vsix +0 -0
  422. package/tools/rmt-language/code-actions.d.ts +15 -0
  423. package/tools/rmt-language/code-actions.js +566 -0
  424. package/tools/rmt-language/completions.d.ts +22 -0
  425. package/tools/rmt-language/completions.js +475 -0
  426. package/tools/rmt-language/definitions.d.ts +13 -0
  427. package/tools/rmt-language/definitions.js +212 -0
  428. package/tools/rmt-language/diagnostics.d.ts +23 -0
  429. package/tools/rmt-language/diagnostics.js +486 -0
  430. package/tools/rmt-language/format-adapter.d.ts +16 -0
  431. package/tools/rmt-language/format-adapter.js +270 -0
  432. package/tools/rmt-language/hover.d.ts +12 -0
  433. package/tools/rmt-language/hover.js +326 -0
  434. package/tools/rmt-language/kernel-escalation.d.ts +122 -0
  435. package/tools/rmt-language/kernel-escalation.js +427 -0
  436. package/tools/rmt-language/kernel-panic-monitor.d.ts +176 -0
  437. package/tools/rmt-language/kernel-panic-monitor.js +674 -0
  438. package/tools/rmt-language/kernel-policy-parity.d.ts +142 -0
  439. package/tools/rmt-language/kernel-policy-parity.js +629 -0
  440. package/tools/rmt-language/kernel-recovery.d.ts +173 -0
  441. package/tools/rmt-language/kernel-recovery.js +666 -0
  442. package/tools/rmt-language/kernel-scheduler-failure.d.ts +136 -0
  443. package/tools/rmt-language/kernel-scheduler-failure.js +486 -0
  444. package/tools/rmt-language/kernel-security-regression.d.ts +154 -0
  445. package/tools/rmt-language/kernel-security-regression.js +465 -0
  446. package/tools/rmt-language/kernel-trust-authority.d.ts +120 -0
  447. package/tools/rmt-language/kernel-trust-authority.js +549 -0
  448. package/tools/rmt-language/parser.d.ts +14 -0
  449. package/tools/rmt-language/parser.js +111 -0
  450. package/tools/rmt-language/rmt-tooling-public-types.d.ts +179 -0
  451. package/tools/rmt-language/rules/boundary-policy.js +81 -0
  452. package/tools/rmt-language/rules/document-policy.js +65 -0
  453. package/tools/rmt-language/rules/index.js +29 -0
  454. package/tools/rmt-language/rules/route-policy.js +81 -0
  455. package/tools/rmt-language/rules/scheduler-policy.js +66 -0
  456. package/tools/rmt-language/rules/template-policy.js +130 -0
  457. package/tools/rmt-language/semantic-graph.d.ts +18 -0
  458. package/tools/rmt-language/semantic-graph.js +827 -0
  459. package/tools/rmt-language/snippets/README.md +17 -0
  460. package/tools/rmt-language/snippets/index.d.ts +17 -0
  461. package/tools/rmt-language/snippets/index.js +417 -0
  462. package/tools/rmt-language/snippets/rmt.code-snippets +243 -0
  463. package/tools/rmt-language/source-model.d.ts +14 -0
  464. package/tools/rmt-language/source-model.js +731 -0
  465. package/tools/rmt-language/symbols.d.ts +13 -0
  466. package/tools/rmt-language/symbols.js +183 -0
  467. package/tools/rmt-language/vnext-compatibility.d.ts +28 -0
  468. package/tools/rmt-language/vnext-compatibility.js +675 -0
  469. package/tools/rmt-language/vnext-compiler.d.ts +17 -0
  470. package/tools/rmt-language/vnext-compiler.js +716 -0
  471. package/tools/rmt-language/vnext-composition.d.ts +30 -0
  472. package/tools/rmt-language/vnext-composition.js +595 -0
  473. package/tools/rmt-language/vnext-conditions.d.ts +25 -0
  474. package/tools/rmt-language/vnext-conditions.js +474 -0
  475. package/tools/rmt-language/vnext-cross-surface-events.d.ts +30 -0
  476. package/tools/rmt-language/vnext-cross-surface-events.js +607 -0
  477. package/tools/rmt-language/vnext-degradation.d.ts +23 -0
  478. package/tools/rmt-language/vnext-degradation.js +428 -0
  479. package/tools/rmt-language/vnext-enterprise-fixtures.d.ts +28 -0
  480. package/tools/rmt-language/vnext-enterprise-fixtures.js +487 -0
  481. package/tools/rmt-language/vnext-enterprise-registry.d.ts +21 -0
  482. package/tools/rmt-language/vnext-enterprise-registry.js +495 -0
  483. package/tools/rmt-language/vnext-enterprise-release.d.ts +44 -0
  484. package/tools/rmt-language/vnext-enterprise-release.js +472 -0
  485. package/tools/rmt-language/vnext-event-governance.d.ts +29 -0
  486. package/tools/rmt-language/vnext-event-governance.js +488 -0
  487. package/tools/rmt-language/vnext-events.d.ts +44 -0
  488. package/tools/rmt-language/vnext-events.js +680 -0
  489. package/tools/rmt-language/vnext-import-resolver.d.ts +28 -0
  490. package/tools/rmt-language/vnext-import-resolver.js +642 -0
  491. package/tools/rmt-language/vnext-lifecycle.d.ts +22 -0
  492. package/tools/rmt-language/vnext-lifecycle.js +404 -0
  493. package/tools/rmt-language/vnext-parser.d.ts +21 -0
  494. package/tools/rmt-language/vnext-parser.js +1391 -0
  495. package/tools/rmt-language/vnext-regression.d.ts +25 -0
  496. package/tools/rmt-language/vnext-regression.js +394 -0
  497. package/tools/rmt-language/vnext-release.d.ts +29 -0
  498. package/tools/rmt-language/vnext-release.js +293 -0
  499. package/tools/rmt-language/vnext-remote-compatibility.d.ts +33 -0
  500. package/tools/rmt-language/vnext-remote-compatibility.js +892 -0
  501. package/tools/rmt-language/vnext-remote-compiler.d.ts +14 -0
  502. package/tools/rmt-language/vnext-remote-compiler.js +520 -0
  503. package/tools/rmt-language/vnext-remote-manifest.d.ts +33 -0
  504. package/tools/rmt-language/vnext-remote-manifest.js +538 -0
  505. package/tools/rmt-language/vnext-remote-security.d.ts +27 -0
  506. package/tools/rmt-language/vnext-remote-security.js +380 -0
  507. package/tools/rmt-language/vnext-remote-tooling.d.ts +25 -0
  508. package/tools/rmt-language/vnext-remote-tooling.js +805 -0
  509. package/tools/rmt-language/vnext-scheduler.d.ts +24 -0
  510. package/tools/rmt-language/vnext-scheduler.js +469 -0
  511. package/tools/rmt-language/vnext-security.d.ts +28 -0
  512. package/tools/rmt-language/vnext-security.js +597 -0
  513. package/tools/rmt-language/vnext-streaming.d.ts +28 -0
  514. package/tools/rmt-language/vnext-streaming.js +593 -0
  515. package/tools/rmt-language/vnext-surfaces.d.ts +24 -0
  516. package/tools/rmt-language/vnext-surfaces.js +406 -0
  517. package/tools/rmt-language/vnext-tooling.d.ts +25 -0
  518. package/tools/rmt-language/vnext-tooling.js +728 -0
  519. package/tools/rmt-language-server/protocol.d.ts +22 -0
  520. package/tools/rmt-language-server/protocol.js +352 -0
  521. package/tools/rmt-language-server/server.d.ts +15 -0
  522. package/tools/rmt-language-server/server.js +622 -0
  523. package/tools/rmt-linter/cli.d.ts +14 -0
  524. package/tools/rmt-linter/cli.js +450 -0
  525. package/tools/rmt-linter/reporter.d.ts +16 -0
  526. package/tools/rmt-linter/reporter.js +472 -0
  527. package/xtend-builder/README.md +83 -0
  528. package/xtend-builder/a11y/README.md +42 -0
  529. package/xtend-builder/a11y/component-a11y-profile.d.ts +14 -0
  530. package/xtend-builder/a11y/component-a11y-profile.js +314 -0
  531. package/xtend-builder/blueprints/README.md +105 -0
  532. package/xtend-builder/blueprints/component-blueprint.contract.d.ts +16 -0
  533. package/xtend-builder/blueprints/component-blueprint.contract.js +343 -0
  534. package/xtend-builder/builder-public-types.d.ts +234 -0
  535. package/xtend-builder/extensions/README.md +26 -0
  536. package/xtend-builder/extensions/component-extension-points.d.ts +11 -0
  537. package/xtend-builder/extensions/component-extension-points.js +277 -0
  538. package/xtend-builder/generators/README.md +149 -0
  539. package/xtend-builder/generators/component-files.d.ts +5 -0
  540. package/xtend-builder/generators/component-files.js +769 -0
  541. package/xtend-builder/generators/component-plan.d.ts +4 -0
  542. package/xtend-builder/generators/component-plan.js +104 -0
  543. package/xtend-builder/generators/registry.d.ts +6 -0
  544. package/xtend-builder/generators/registry.js +118 -0
  545. package/xtend-builder/generators/rmt-build.js +738 -0
  546. package/xtend-builder/generators/rmt-lifecycle-demo.js +922 -0
  547. package/xtend-builder/lib/cli.d.ts +9 -0
  548. package/xtend-builder/lib/cli.js +543 -0
  549. package/xtend-builder/lib/layout.d.ts +6 -0
  550. package/xtend-builder/lib/layout.js +153 -0
  551. package/xtend-builder/lib/package-resolver.js +25 -0
  552. package/xtend-builder/package.json +90 -0
  553. package/xtend-builder/performance/README.md +31 -0
  554. package/xtend-builder/performance/component-performance-profile.d.ts +11 -0
  555. package/xtend-builder/performance/component-performance-profile.js +347 -0
  556. package/xtend-builder/performance/component-ux-performance-contract.d.ts +27 -0
  557. package/xtend-builder/performance/component-ux-performance-contract.js +424 -0
  558. package/xtend-builder/preview/README.md +61 -0
  559. package/xtend-builder/preview/component-lab-ux-inspector.d.ts +20 -0
  560. package/xtend-builder/preview/component-lab-ux-inspector.js +448 -0
  561. package/xtend-builder/preview/component-lab.d.ts +14 -0
  562. package/xtend-builder/preview/component-lab.js +278 -0
  563. package/xtend-builder/preview/component-preview.d.ts +5 -0
  564. package/xtend-builder/preview/component-preview.js +160 -0
  565. package/xtend-builder/scaffold.config.d.ts +4 -0
  566. package/xtend-builder/scaffold.config.js +2056 -0
  567. package/xtend-builder/scaffold.d.ts +3 -0
  568. package/xtend-builder/scaffold.js +11 -0
  569. package/xtend-builder/templates/README.md +33 -0
  570. package/xtend-builder/templates/component/a11y.template.ts +11 -0
  571. package/xtend-builder/templates/component/component-suite.template.d.ts +2 -0
  572. package/xtend-builder/templates/component/component-suite.template.js +108 -0
  573. package/xtend-builder/templates/component/contract.template.ts +10 -0
  574. package/xtend-builder/templates/component/demo-plan.template.md +73 -0
  575. package/xtend-builder/templates/component/docs.template.md +301 -0
  576. package/xtend-builder/templates/component/fixture-data.template.ts +28 -0
  577. package/xtend-builder/templates/component/fixture.template.html +37 -0
  578. package/xtend-builder/templates/component/manifest-plan.template.json +22 -0
  579. package/xtend-builder/templates/component/performance.template.ts +13 -0
  580. package/xtend-builder/templates/component/rmt.template.ts +12 -0
  581. package/xtend-builder/templates/component/source.template.d.ts +2 -0
  582. package/xtend-builder/templates/component/source.template.js +137 -0
  583. package/xtend-builder/templates/component/source.template.ts +110 -0
  584. package/xtend-builder/templates/component/types.template.d.ts +423 -0
  585. package/xtend-builder/templates/loader.d.ts +4 -0
  586. package/xtend-builder/templates/loader.js +51 -0
  587. package/xtend-builder/templates/registry.d.ts +6 -0
  588. package/xtend-builder/templates/registry.js +119 -0
  589. package/xtend-builder/typing/README.md +130 -0
  590. package/xtend-builder/typing/component-contract-v2.d.ts +15 -0
  591. package/xtend-builder/typing/component-contract-v2.js +248 -0
  592. package/xtend-builder/typing/component-network-contract.d.ts +22 -0
  593. package/xtend-builder/typing/component-network-contract.js +478 -0
  594. package/xtend-builder/typing/component-shell-contract.d.ts +21 -0
  595. package/xtend-builder/typing/component-shell-contract.js +312 -0
  596. package/xtend-builder/typing/component-styling-contract.d.ts +22 -0
  597. package/xtend-builder/typing/component-styling-contract.js +301 -0
  598. package/xtend-builder/typing/component-types.d.ts +10 -0
  599. package/xtend-builder/typing/component-types.js +551 -0
  600. package/xtend-builder/typing/enterprise-component-flex-hardening-contract.d.ts +20 -0
  601. package/xtend-builder/typing/enterprise-component-flex-hardening-contract.js +332 -0
  602. package/xtend-builder/typing/feedback-status-ux-contract.d.ts +25 -0
  603. package/xtend-builder/typing/feedback-status-ux-contract.js +347 -0
  604. package/xtend-builder/typing/form-controls-ux-contract.d.ts +25 -0
  605. package/xtend-builder/typing/form-controls-ux-contract.js +357 -0
  606. package/xtend-builder/typing/layout-display-media-ux-contract.d.ts +25 -0
  607. package/xtend-builder/typing/layout-display-media-ux-contract.js +420 -0
  608. package/xtend-builder/typing/navigation-routing-ux-contract.d.ts +17 -0
  609. package/xtend-builder/typing/navigation-routing-ux-contract.js +297 -0
  610. package/xtend-builder/typing/overlay-interaction-ux-contract.d.ts +25 -0
  611. package/xtend-builder/typing/overlay-interaction-ux-contract.js +383 -0
  612. package/xtend-builder/typing/rmt-dsl-authoring-polish.d.ts +27 -0
  613. package/xtend-builder/typing/rmt-dsl-authoring-polish.js +419 -0
  614. package/xtend-builder/typing/rmt-shell-authoring-contract.d.ts +26 -0
  615. package/xtend-builder/typing/rmt-shell-authoring-contract.js +315 -0
  616. package/xtend-builder/utils/README.md +8 -0
  617. package/xtend-builder/utils/naming.d.ts +7 -0
  618. package/xtend-builder/utils/naming.js +36 -0
  619. package/xtend-builder/utils/validation.d.ts +5 -0
  620. package/xtend-builder/utils/validation.js +95 -0
  621. package/xtend-builder/wiring/README.md +46 -0
  622. package/xtend-builder/wiring/features.d.ts +5 -0
  623. package/xtend-builder/wiring/features.js +165 -0
  624. package/xtend-builder/wiring/hydration.d.ts +4 -0
  625. package/xtend-builder/wiring/hydration.js +44 -0
  626. package/xtend-builder/wiring/manifest.d.ts +5 -0
  627. package/xtend-builder/wiring/manifest.js +48 -0
  628. package/xtend-builder/workflows/README.md +47 -0
  629. package/xtend-builder/workflows/developer-workflow.d.ts +6 -0
  630. package/xtend-builder/workflows/developer-workflow.js +125 -0
  631. package/xtend-builder/writing/manifest-patcher.d.ts +49 -0
  632. package/xtend-builder/writing/manifest-patcher.js +391 -0
  633. package/xtend-builder/writing/write-plan.d.ts +148 -0
  634. package/xtend-builder/writing/write-plan.js +646 -0
  635. package/xtend-dev.d.ts +23 -0
  636. package/xtend-dev.js +4 -0
  637. package/xtend-loader.d.ts +201 -0
  638. package/xtend-loader.js +1704 -0
  639. package/xtend.css +402 -0
  640. package/xtendrmt/package.json +64 -0
  641. package/xtendrmt/rmt-core.d.ts +4452 -0
  642. package/xtendrmt/rmt-core.esm.js +25793 -0
  643. package/xtendrmt/rmt-first-demo-app.js +265 -0
  644. package/xtendrmt/rmt-first-demo-app.rmt +737 -0
  645. package/xtendrmt/rmt-lifecycle-demo.app.js +493 -0
  646. package/xtendrmt/rmt-lifecycle-demo.core.json +810 -0
  647. package/xtendrmt/rmt-lifecycle-demo.rmt +35 -0
  648. package/xtendrmt/rmt-lifecycle-demo.rmt-build.app.js +153 -0
  649. package/xtendrmt/rmt-lifecycle-demo.rmt-build.core.json +810 -0
  650. package/xtendrmt/rmt-lifecycle-demo.rmt-build.scaffold.json +202 -0
  651. package/xtendrmt/rmt-lifecycle-demo.scaffold.json +187 -0
  652. package/xtendrmt/rmt-manifest.json +548 -0
  653. package/xtendrmt/rmt-runtime.browser.js +26183 -0
  654. package/xtendrmt/rmt-runtime.esm.js +26214 -0
  655. package/xtendrmt/rmt-vnext-enterprise-mfe-demo.core.json +849 -0
  656. package/xtendrmt/rmt-vnext-enterprise-mfe-demo.rmt +50 -0
  657. package/xtendrmt/rmt-vnext-reference-demo.core.json +1069 -0
  658. package/xtendrmt/rmt-vnext-reference-demo.rmt +50 -0
  659. package/xtendrmt/rmt.schema.json +3145 -0
  660. package/xtendrmt/surface-workbench.js +316 -0
  661. package/xtendrmt/surface-workbench.rmt +762 -0
  662. package/xtendrmt/xtendrmt-bestcase-demo.core.json +1187 -0
  663. package/xtendrmt/xtendrmt-bestcase-demo.js +1728 -0
  664. package/xtendrmt/xtendrmt-bestcase-demo.rmt +57 -0
@@ -0,0 +1,1841 @@
1
+ import { xstate } from './xstate.js';
2
+
3
+ /**
4
+ * @class XRoute
5
+ * Definiert eine einzelne Route innerhalb des Routers.
6
+ * @property {string} path - Das URL-Muster (z.B. /home, /users/:id).
7
+ * @property {string} component - Der Tag-Name der Komponente, die gerendert werden soll.
8
+ */
9
+ class XRoute extends HTMLElement {
10
+ static get observedAttributes() {
11
+ return ['path', 'component', 'import', 'title', 'document-title', 'title-template', 'meta-description', 'meta-keywords', 'skeleton', 'skeleton-lines', 'skeleton-min-height', 'hydrate-schedule'];
12
+ }
13
+ get path() { return this.getAttribute('path'); }
14
+ get component() { return this.getAttribute('component'); }
15
+ get importUrl() { return this.getAttribute('import'); }
16
+ get title() { return this.getAttribute('title'); }
17
+ get documentTitle() { return this.getAttribute('document-title'); }
18
+ get skeleton() { return this.getAttribute('skeleton'); }
19
+ get skeletonLines() { return this.getAttribute('skeleton-lines'); }
20
+ get skeletonMinHeight() { return this.getAttribute('skeleton-min-height'); }
21
+ get hydrateSchedule() { return this.getAttribute('hydrate-schedule') || this.getAttribute('data-rmt-hydrate-schedule'); }
22
+ }
23
+ customElements.define('x-route', XRoute);
24
+
25
+ /**
26
+ * @class XRouter
27
+ * Haupt-Router-Komponente, die die Navigation verwaltet.
28
+ */
29
+ class XRouter extends HTMLElement {
30
+ static get observedAttributes() { return ['mode', 'routesrc', 'reuse-component', 'skeleton', 'skeleton-lines', 'skeleton-min-height']; }
31
+
32
+ static get xtendComponentContract() {
33
+ return {
34
+ schema: 'xtend.component.contract.v2',
35
+ tag: 'x-router',
36
+ maturity: 'stable',
37
+ source: {
38
+ strategy: 'xtend.legacy-esm.component-source',
39
+ state: 'js-runtime',
40
+ sourcePath: 'components/xrouter.js'
41
+ },
42
+ runtime: {
43
+ format: 'esm',
44
+ artifact: 'components/xrouter.js',
45
+ declaration: 'components/xrouter.d.ts',
46
+ localOnly: true,
47
+ cdnAllowed: false
48
+ },
49
+ rmt: {
50
+ adapter: 'xtend.xrouter',
51
+ kernelBoundary: 'no-rmt-kernel-import-of-xtend-types'
52
+ },
53
+ fabric: {
54
+ api: '@xtend-fabric',
55
+ defaultLane: 'transition'
56
+ }
57
+ };
58
+ }
59
+
60
+ static get xtendRmtMetadata() {
61
+ return {
62
+ schema: 'xtend.rmt.component-contract.v1',
63
+ adapter: 'xtend.xrouter',
64
+ tag: 'x-router',
65
+ schedules: ['component.visible.mount', 'route.visible.render', 'route.transition.render', 'route.focus.restore', 'component.dynamic.hydrate', 'a11y.announce', 'diagnostics.snapshot'],
66
+ hydration: { policy: 'visible', lane: 'transition' },
67
+ routeContext: 'xtend.router.current',
68
+ kernelBoundary: 'no-rmt-kernel-import-of-xtend-types'
69
+ };
70
+ }
71
+
72
+ static get xtendComponentLifecycleTelemetry() {
73
+ return {
74
+ schema: 'xtend.component.lifecycle-telemetry.v1',
75
+ componentRef: 'x-router',
76
+ operations: ['mount', 'hydrate', 'navigate', 'render', 'announce', 'focus', 'unmount'],
77
+ snapshotPath: 'snapshot.componentTelemetry'
78
+ };
79
+ }
80
+
81
+ static get xtendScaffoldA11yProfile() {
82
+ return {
83
+ schema: 'xtend.a11y.profile.v1',
84
+ componentRef: 'x-router',
85
+ role: 'main',
86
+ accessibleName: 'optional',
87
+ liveRegion: 'polite',
88
+ screenreader: {
89
+ signalContract: XRouter.xtendScreenreaderSignals
90
+ },
91
+ motionContrast: {
92
+ policy: XRouter.xtendMotionContrastPolicy
93
+ }
94
+ };
95
+ }
96
+
97
+ static get xtendScaffoldPerformanceProfile() {
98
+ return {
99
+ schema: 'xtend.performance.component-profile.v1',
100
+ componentRef: 'x-router',
101
+ budgetClass: 'routing',
102
+ lane: 'transition',
103
+ hydrationPolicy: 'visible',
104
+ criticalMeasurements: ['navigate', 'render', 'announce', 'focus'],
105
+ cleanup: ['window-listeners', 'document-listeners', 'xstate-subscription']
106
+ };
107
+ }
108
+
109
+ static get xtendNavigationRoutingUxProfile() {
110
+ return {
111
+ schema: 'xtend.component.navigation-routing-ux-profile.v1',
112
+ componentRef: 'x-router',
113
+ family: 'router-outlet',
114
+ role: 'main',
115
+ navigationMode: 'hash-or-history',
116
+ activeState: 'route-context-with-aria-current-links',
117
+ focusRestore: 'outlet-focus-after-render',
118
+ routeAnnouncement: 'polite-live-region',
119
+ keyboardNavigation: 'delegated-to-x-link',
120
+ events: ['xrouter-before-navigate', 'route-changed', 'routechange', 'xrouter-after-navigate', 'route-announced', 'xrouter-routes-registered', 'xrouter-route-reused', 'xrouter-skeleton-shown', 'xrouter-skeleton-hidden', 'xrouter-route-hydrated', 'xrouter-scroll-boundary-normalized', 'xrouter-navigation-overlays-closed', 'xrouter-title-updated'],
121
+ commands: ['navigate', 'register-routes', 'focus-route', 'announce-route', 'rewrite-document-title', 'show-route-skeleton', 'hydrate-route-component', 'reuse-route-component', 'normalize-scroll-boundary', 'close-navigation-overlays', 'snapshot'],
122
+ stateKey: 'xtend.router.current',
123
+ schedule: 'route.visible.render',
124
+ fabric: {
125
+ lane: 'transition',
126
+ a11yLane: 'a11y',
127
+ diagnosticsLane: 'diagnostics'
128
+ },
129
+ rmt: XRouter.xtendRmtMetadata,
130
+ statusSemantics: {
131
+ feedbackStatusCompatible: true,
132
+ announcementStateKey: 'xtend.router.announcement',
133
+ documentMetaStateKey: 'xtend.router.documentMeta'
134
+ },
135
+ stateSemantics: {
136
+ states: ['active', 'current', 'selected', 'hover', 'focus', 'disabled'],
137
+ current: 'aria-current=page-delegated-to-links-and-menus',
138
+ selected: 'aria-selected=true-supported-for-route-tabs',
139
+ disabled: 'delegated-to-navigation-controls'
140
+ },
141
+ signatureDesign: {
142
+ note: 'Enterprise router outlet with calm route focus, readable announcements and tokenized skeleton/navigation bridge states.',
143
+ tokenStrategy: 'shared --xtend-nav-* tokens align router announcements, route focus and navigation components.',
144
+ themeExpectation: 'third-party themes can replace route focus, skeleton, active route and announcement surfaces from CSS.'
145
+ },
146
+ themeTokens: [
147
+ '--xtend-nav-surface',
148
+ '--xtend-nav-text',
149
+ '--xtend-nav-border-color',
150
+ '--xtend-nav-radius',
151
+ '--xtend-nav-gap',
152
+ '--xtend-nav-font-family',
153
+ '--xtend-nav-font-size',
154
+ '--xtend-nav-active-surface',
155
+ '--xtend-nav-active-text',
156
+ '--xtend-nav-current-indicator',
157
+ '--xtend-nav-hover-surface',
158
+ '--xtend-nav-focus-ring',
159
+ '--xtend-nav-disabled-opacity'
160
+ ],
161
+ overflowPolicy: 'route-outlet-allows-long-label-navigation-contexts-to-wrap'
162
+ };
163
+ }
164
+
165
+ static get xtendScreenreaderSignals() {
166
+ return {
167
+ schema: 'xtend.a11y.screenreader-signals.v1',
168
+ componentRef: 'x-router',
169
+ liveRegion: 'polite',
170
+ signals: ['route-announcement', 'focus-restore'],
171
+ statusRegions: ['role=status', 'aria-live=polite', 'aria-atomic=true'],
172
+ errorRegions: ['role=alert'],
173
+ fabric: {
174
+ lane: 'a11y',
175
+ fiberKind: 'a11y.announce',
176
+ scheduleRef: 'a11y.user-blocking.announce'
177
+ }
178
+ };
179
+ }
180
+
181
+ static get xtendMotionContrastPolicy() {
182
+ return {
183
+ schema: 'xtend.a11y.motion-contrast-policy.v1',
184
+ componentRef: 'x-router',
185
+ motion: {
186
+ schema: 'xtend.a11y.motion-policy.v1',
187
+ mediaQuery: '(prefers-reduced-motion: reduce)',
188
+ reducedMotion: 'required',
189
+ animationPolicy: 'route-announcement-without-motion-dependency',
190
+ noMotionOnlyState: true
191
+ },
192
+ contrast: {
193
+ schema: 'xtend.a11y.contrast-policy.v1',
194
+ mediaQuery: '(forced-colors: active)',
195
+ highContrast: 'required',
196
+ forcedColorAdjust: 'auto',
197
+ focusVisible: 'required',
198
+ nonColorStatus: 'required'
199
+ },
200
+ fabric: {
201
+ lane: 'a11y',
202
+ fiberKind: 'a11y.preference',
203
+ scheduleRef: 'a11y.user-blocking.preference'
204
+ }
205
+ };
206
+ }
207
+
208
+ /**
209
+ * SSR/Prerendering: Exportiert alle Routen als JSON (rekursiv)
210
+ * @param {HTMLElement} rootElement - <x-router> Element oder Array von Routenobjekten
211
+ * @returns {Array} Array von Routenobjekten
212
+ */
213
+ static exportRoutesToJSON(rootElement) {
214
+ // rootElement: <x-router> oder Array von Routenobjekten
215
+ const extract = (el) => {
216
+ if (Array.isArray(el)) return el.map(extract);
217
+ if (el.tagName === 'X-ROUTE' || el.tagName === 'x-route') {
218
+ const obj = {};
219
+ for (const attr of el.getAttributeNames()) {
220
+ obj[attr] = el.getAttribute(attr);
221
+ }
222
+ // Kinder rekursiv
223
+ const children = Array.from(el.children).filter(c => c.tagName === 'X-ROUTE');
224
+ if (children.length) obj.children = children.map(extract);
225
+ return obj;
226
+ }
227
+ // Falls schon ein Objekt
228
+ if (typeof el === 'object' && el.path) {
229
+ const obj = { ...el };
230
+ if (Array.isArray(obj.children)) obj.children = obj.children.map(extract);
231
+ return obj;
232
+ }
233
+ return null;
234
+ };
235
+ if (!rootElement) return [];
236
+ if (rootElement.tagName === 'X-ROUTER' || rootElement.tagName === 'x-router') {
237
+ return Array.from(rootElement.querySelectorAll(':scope > x-route')).map(extract);
238
+ }
239
+ if (Array.isArray(rootElement)) return rootElement.map(extract);
240
+ return [];
241
+ }
242
+
243
+ /**
244
+ * SSR/Prerendering: Liefert für einen Pfad die Zielroute und ein HTML-Stub (Platzhalter)
245
+ * @param {string} path - Zielpfad
246
+ * @param {Array|HTMLElement} routes - Array von Routenobjekten oder <x-router>
247
+ * @returns {Object} { html, route, params, meta }
248
+ */
249
+ static renderRouteToString(path, routes) {
250
+ // Nutzt die gleiche Logik wie _matchRoute, aber serverseitig
251
+ const matchRoute = (path, routes) => {
252
+ const pathSegments = path.split('/').filter(Boolean);
253
+ for (const route of routes) {
254
+ const routePath = route.path;
255
+ const aliases = route.alias ? route.alias.split(',').map(a => a.trim()).filter(Boolean) : [];
256
+ const allPaths = [routePath, ...aliases];
257
+ for (const testPath of allPaths) {
258
+ if (testPath === '*') continue;
259
+ const routeSegments = testPath.split('/').filter(Boolean);
260
+ if (pathSegments.length < routeSegments.length) continue;
261
+ const params = {};
262
+ let isMatch = true;
263
+ for (let i = 0; i < routeSegments.length; i++) {
264
+ const segment = routeSegments[i];
265
+ if (segment.startsWith(':')) {
266
+ params[segment.substring(1)] = pathSegments[i];
267
+ } else if (segment !== pathSegments[i]) {
268
+ isMatch = false;
269
+ break;
270
+ }
271
+ }
272
+ if (isMatch) {
273
+ // Nested
274
+ if (route.children && pathSegments.length > routeSegments.length) {
275
+ const restPath = '/' + pathSegments.slice(routeSegments.length).join('/');
276
+ const childMatch = matchRoute(restPath, route.children);
277
+ if (childMatch) {
278
+ return { route, params, child: childMatch };
279
+ }
280
+ }
281
+ return { route, params };
282
+ }
283
+ }
284
+ }
285
+ const notFoundRoute = routes.find(r => r.path === '*');
286
+ return notFoundRoute ? { route: notFoundRoute, params: {} } : null;
287
+ };
288
+ // Routenstruktur extrahieren
289
+ let routeArr = routes;
290
+ if (routes && routes.tagName === 'X-ROUTER') {
291
+ routeArr = XRouter.exportRoutesToJSON(routes);
292
+ }
293
+ routeArr = Array.isArray(routeArr) ? routeArr : [];
294
+ const match = matchRoute(path, routeArr);
295
+ if (!match) {
296
+ return { html: '<div>404 - Not Found</div>', route: null, params: {}, meta: {} };
297
+ }
298
+ // SSR: HTML-Stub für die Komponente (echtes Rendern ist clientseitig)
299
+ const buildHtml = (match) => {
300
+ const { route, params, child } = match;
301
+ let html = `<${route.component || 'div'}${Object.keys(params).length ? ' data-params="' + encodeURIComponent(JSON.stringify(params)) + '"' : ''}></${route.component || 'div'}>`;
302
+ if (child) {
303
+ html = html.replace(`</${route.component || 'div'}>`, `${buildHtml(child)}</${route.component || 'div'}>`);
304
+ }
305
+ return html;
306
+ };
307
+ // Meta-Infos
308
+ const meta = XRouter.getMetaForPath(path, routeArr);
309
+ return { html: buildHtml(match), route: match.route, params: match.params, meta };
310
+ }
311
+
312
+ /**
313
+ * SSR/Prerendering: Liefert Meta-Infos (title, description, keywords) für einen Pfad
314
+ * @param {string} path
315
+ * @param {Array|HTMLElement} routes
316
+ * @returns {Object} { title, description, keywords }
317
+ */
318
+ static getMetaForPath(path, routes) {
319
+ // Nutzt die gleiche Logik wie renderRouteToString
320
+ let routeArr = routes;
321
+ if (routes && routes.tagName === 'X-ROUTER') {
322
+ routeArr = XRouter.exportRoutesToJSON(routes);
323
+ }
324
+ const readMetaValue = (route, keys) => {
325
+ const metadata = route && route.metadata && typeof route.metadata === 'object' ? route.metadata : {};
326
+ const seo = metadata.seo && typeof metadata.seo === 'object' ? metadata.seo : {};
327
+ for (const key of keys) {
328
+ const routeValue = route ? route[key] : '';
329
+ if (routeValue !== undefined && routeValue !== null && String(routeValue).trim()) return routeValue;
330
+ const attrValue = route ? route[key.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)] : '';
331
+ if (attrValue !== undefined && attrValue !== null && String(attrValue).trim()) return attrValue;
332
+ const metadataValue = metadata[key];
333
+ if (metadataValue !== undefined && metadataValue !== null && String(metadataValue).trim()) return metadataValue;
334
+ const seoValue = seo[key];
335
+ if (seoValue !== undefined && seoValue !== null && String(seoValue).trim()) return seoValue;
336
+ }
337
+ return '';
338
+ };
339
+ const normalizeMetaValue = (value) => Array.isArray(value)
340
+ ? value.map(item => String(item).trim()).filter(Boolean).join(', ')
341
+ : (value === undefined || value === null ? '' : String(value).trim());
342
+ const findMeta = (path, routes) => {
343
+ const pathSegments = path.split('/').filter(Boolean);
344
+ for (const route of routes) {
345
+ const routePath = route.path;
346
+ const aliases = route.alias ? route.alias.split(',').map(a => a.trim()).filter(Boolean) : [];
347
+ const allPaths = [routePath, ...aliases];
348
+ for (const testPath of allPaths) {
349
+ if (testPath === '*') continue;
350
+ const routeSegments = testPath.split('/').filter(Boolean);
351
+ if (pathSegments.length < routeSegments.length) continue;
352
+ let isMatch = true;
353
+ for (let i = 0; i < routeSegments.length; i++) {
354
+ const segment = routeSegments[i];
355
+ if (segment.startsWith(':')) continue;
356
+ if (segment !== pathSegments[i]) {
357
+ isMatch = false;
358
+ break;
359
+ }
360
+ }
361
+ if (isMatch) {
362
+ // Nested
363
+ if (route.children && pathSegments.length > routeSegments.length) {
364
+ const restPath = '/' + pathSegments.slice(routeSegments.length).join('/');
365
+ return findMeta(restPath, route.children);
366
+ }
367
+ const title = normalizeMetaValue(readMetaValue(route, ['title']));
368
+ const documentTitle = normalizeMetaValue(readMetaValue(route, ['documentTitle', 'document_title'])) || title;
369
+ return {
370
+ title,
371
+ documentTitle,
372
+ description: normalizeMetaValue(readMetaValue(route, ['metaDescription', 'description'])),
373
+ keywords: normalizeMetaValue(readMetaValue(route, ['metaKeywords', 'keywords']))
374
+ };
375
+ }
376
+ }
377
+ }
378
+ return {};
379
+ };
380
+ return findMeta(path, routeArr);
381
+ }
382
+
383
+ static normalizeRmtRouteRecord(routeRecord = {}) {
384
+ const source = routeRecord && typeof routeRecord === 'object'
385
+ ? (routeRecord.record && typeof routeRecord.record === 'object' ? routeRecord.record : routeRecord)
386
+ : {};
387
+ const metadata = source.metadata && typeof source.metadata === 'object' ? source.metadata : {};
388
+ const seo = metadata.seo && typeof metadata.seo === 'object' ? metadata.seo : {};
389
+ const routeId = routeRecord.id || source.id || '';
390
+ return {
391
+ id: routeId,
392
+ path: routeRecord.path || source.path || '',
393
+ component: routeRecord.component || routeRecord.componentId || source.component || source.tag || '',
394
+ title: routeRecord.title || source.title || metadata.title || seo.title || '',
395
+ documentTitle: routeRecord.documentTitle || routeRecord.document_title || source.documentTitle || source.document_title || metadata.documentTitle || metadata.document_title || seo.documentTitle || seo.document_title || '',
396
+ titleTemplate: routeRecord.titleTemplate || routeRecord.documentTitleTemplate || source.titleTemplate || source.documentTitleTemplate || metadata.titleTemplate || metadata.documentTitleTemplate || seo.titleTemplate || seo.documentTitleTemplate || '',
397
+ metaDescription: routeRecord.metaDescription || routeRecord.description || source.metaDescription || source.description || metadata.metaDescription || metadata.description || seo.metaDescription || seo.description || '',
398
+ metaKeywords: routeRecord.metaKeywords || routeRecord.keywords || source.metaKeywords || source.keywords || metadata.metaKeywords || metadata.keywords || seo.metaKeywords || seo.keywords || '',
399
+ redirect: routeRecord.redirect || source.redirect || '',
400
+ template: routeRecord.template || routeRecord.templateRef || source.template || '',
401
+ schedule: routeRecord.schedule || routeRecord.scheduleRef || source.schedule || '',
402
+ router: routeRecord.router || routeRecord.routerId || source.router || 'xtend.xrouter',
403
+ import: routeRecord.import || source.import || source.importUrl || source.moduleRef || metadata.import || metadata.importUrl || '',
404
+ skeleton: routeRecord.skeleton || source.skeleton || metadata.skeleton || '',
405
+ skeletonLines: routeRecord.skeletonLines || routeRecord.skeleton_lines || source.skeletonLines || source.skeleton_lines || metadata.skeletonLines || metadata.skeleton_lines || '',
406
+ skeletonMinHeight: routeRecord.skeletonMinHeight || routeRecord.skeleton_min_height || source.skeletonMinHeight || source.skeleton_min_height || metadata.skeletonMinHeight || metadata.skeleton_min_height || '',
407
+ hydration: routeRecord.hydration || source.hydration || metadata.hydration || {},
408
+ params: routeRecord.params || source.params || {},
409
+ query: routeRecord.query || source.query || {},
410
+ metadata,
411
+ lifecycle: routeRecord.lifecycle || source.lifecycle || {},
412
+ children: Array.isArray(routeRecord.children)
413
+ ? routeRecord.children
414
+ : (Array.isArray(source.children) ? source.children : [])
415
+ };
416
+ }
417
+
418
+ static createRouteElementFromRecord(routeRecord = {}, documentTarget = document) {
419
+ const route = XRouter.normalizeRmtRouteRecord(routeRecord);
420
+ const element = documentTarget.createElement('x-route');
421
+ const setAttribute = (name, value) => {
422
+ if (value !== undefined && value !== null && String(value).trim()) {
423
+ element.setAttribute(name, String(value));
424
+ }
425
+ };
426
+ setAttribute('path', route.path);
427
+ setAttribute('component', route.component);
428
+ setAttribute('title', route.title);
429
+ setAttribute('document-title', route.documentTitle);
430
+ setAttribute('title-template', route.titleTemplate);
431
+ setAttribute('meta-description', route.metaDescription);
432
+ setAttribute('meta-keywords', route.metaKeywords);
433
+ setAttribute('redirect', route.redirect);
434
+ setAttribute('import', route.import);
435
+ setAttribute('skeleton', route.skeleton);
436
+ setAttribute('skeleton-lines', route.skeletonLines);
437
+ setAttribute('skeleton-min-height', route.skeletonMinHeight);
438
+ setAttribute('data-rmt-route-id', route.id);
439
+ setAttribute('data-rmt-router', route.router);
440
+ setAttribute('data-rmt-template', route.template);
441
+ setAttribute('data-rmt-schedule', typeof route.schedule === 'string' ? route.schedule : (route.schedule && route.schedule.id) || '');
442
+ setAttribute('data-rmt-hydrate-schedule', route.hydration && (route.hydration.schedule || route.hydration.scheduleRef) || '');
443
+ if (route.params && Object.keys(route.params).length) {
444
+ element.setAttribute('data-rmt-params', JSON.stringify(route.params));
445
+ }
446
+ if (route.query && Object.keys(route.query).length) {
447
+ element.setAttribute('data-rmt-query', JSON.stringify(route.query));
448
+ }
449
+ if (route.metadata && Object.keys(route.metadata).length) {
450
+ element.setAttribute('data-rmt-metadata', JSON.stringify(route.metadata));
451
+ }
452
+ if (route.lifecycle && route.lifecycle.beforeEnter && typeof route.lifecycle.beforeEnter === 'object') {
453
+ setAttribute('before-enter', route.lifecycle.beforeEnter.commandName || route.lifecycle.beforeEnter.handler || '');
454
+ }
455
+ route.children.forEach((childRoute) => {
456
+ element.appendChild(XRouter.createRouteElementFromRecord(childRoute, documentTarget));
457
+ });
458
+ return element;
459
+ }
460
+
461
+ constructor() {
462
+ super();
463
+ this.attachShadow({ mode: 'open' });
464
+ this.shadowRoot.innerHTML = `
465
+ <style>
466
+ :host {
467
+ display: block;
468
+ --xtend-nav-surface: transparent;
469
+ --xtend-nav-text: var(--xtend-text-primary, var(--xtend-text, CanvasText));
470
+ --xtend-nav-border-color: transparent;
471
+ --xtend-nav-radius: var(--xtend-radius-panel, var(--xtend-radius, 0.75rem));
472
+ --xtend-nav-gap: var(--xtend-space-2, 0.5rem);
473
+ --xtend-nav-font-family: var(--xtend-font-family-body, var(--xtend-font-family, system-ui, sans-serif));
474
+ --xtend-nav-font-size: var(--xtend-font-size-body, 1rem);
475
+ --xtend-nav-active-surface: var(--xtend-color-action-subtle, transparent);
476
+ --xtend-nav-active-text: var(--xtend-color-action, LinkText);
477
+ --xtend-nav-current-indicator: var(--xtend-color-action, Highlight);
478
+ --xtend-nav-hover-surface: var(--xtend-color-action-subtle, transparent);
479
+ --xtend-nav-focus-ring: var(--xtend-focus-ring, 2px solid Highlight);
480
+ --xtend-nav-disabled-opacity: var(--xtend-disabled-opacity, 0.48);
481
+ --xtend-router-focus: var(--xtend-nav-focus-ring);
482
+ --xtend-router-surface: var(--xtend-nav-surface);
483
+ --xtend-router-text: var(--xtend-nav-text);
484
+ }
485
+ #outlet {
486
+ min-height: 1px;
487
+ outline: none;
488
+ color: var(--xtend-router-text);
489
+ background: var(--xtend-router-surface);
490
+ overflow-wrap: anywhere;
491
+ }
492
+ #outlet[data-xtend-skeleton-active="true"] {
493
+ display: block;
494
+ }
495
+ [data-xtend-skeleton-loader] {
496
+ display: grid;
497
+ gap: 0.68rem;
498
+ width: var(--xtend-skeleton-width, 100%);
499
+ max-width: var(--xtend-skeleton-max-width, 100%);
500
+ margin-inline: var(--xtend-skeleton-margin-inline, 0);
501
+ min-width: 0;
502
+ box-sizing: border-box;
503
+ min-height: var(--xtend-router-skeleton-min-height, 12rem);
504
+ padding: var(--xtend-skeleton-padding, 1rem);
505
+ border-radius: var(--xtend-skeleton-radius, 8px);
506
+ background: var(--xtend-skeleton-surface, rgba(148, 163, 184, 0.12));
507
+ overflow: hidden;
508
+ contain: layout paint;
509
+ }
510
+ [data-xtend-skeleton-line] {
511
+ display: block;
512
+ height: 0.82rem;
513
+ border-radius: 999px;
514
+ background: var(--xtend-skeleton-line-bg, rgba(148, 163, 184, 0.24));
515
+ }
516
+ [data-xtend-skeleton-line]:first-child {
517
+ height: 1.35rem;
518
+ }
519
+ #outlet:focus-visible {
520
+ outline: var(--xtend-router-focus);
521
+ outline-offset: 4px;
522
+ }
523
+ .route-announcer {
524
+ position: absolute;
525
+ width: 1px;
526
+ height: 1px;
527
+ margin: -1px;
528
+ padding: 0;
529
+ overflow: hidden;
530
+ clip: rect(0, 0, 0, 0);
531
+ white-space: nowrap;
532
+ border: 0;
533
+ }
534
+ @media (prefers-reduced-motion: reduce) {
535
+ #outlet {
536
+ scroll-behavior: auto;
537
+ }
538
+ }
539
+ @media (forced-colors: active) {
540
+ #outlet:focus-visible {
541
+ outline: 2px solid CanvasText;
542
+ }
543
+ }
544
+ </style>
545
+ <div id="outlet" part="root outlet" role="main" tabindex="-1" aria-busy="false"></div>
546
+ <div id="route-announcer" class="route-announcer" part="announcer" role="status" aria-live="polite" aria-atomic="true"></div>
547
+ <slot style="display: none;"></slot>
548
+ `;
549
+ this._outlet = this.shadowRoot.querySelector('#outlet');
550
+ this._announcer = this.shadowRoot.querySelector('#route-announcer');
551
+ this._onNavigate = this._handleNavigation.bind(this);
552
+ this._onLinkClick = this._handleLinkClick.bind(this);
553
+ this._unsubscribeXStateNav = null;
554
+ this._mode = this.getAttribute('mode') || 'hash';
555
+ this._lastRouteDetail = null;
556
+ this._previousScrollRestoration = null;
557
+ this._scrollBoundaryToken = null;
558
+ this._scrollBoundaryFrame = null;
559
+ this._scrollBoundarySecondFrame = null;
560
+ this._scrollBoundaryTimer = null;
561
+ this._scrollBoundarySettleTimer = null;
562
+ this._routeSkeleton = null;
563
+ this._initialDocumentTitle = typeof document !== 'undefined' ? document.title : '';
564
+ this._initialDocumentMeta = this._snapshotDocumentMeta();
565
+ if (this._mode === 'history' && !window.history.pushState) {
566
+ this._mode = 'hash'; // Fallback
567
+ }
568
+ }
569
+
570
+ attributeChangedCallback(name, oldValue, newValue) {
571
+ if (name === 'mode') {
572
+ this._mode = newValue || 'hash';
573
+ }
574
+ if (name === 'reuse-component') {
575
+ xstate.set('xtend.router.reuseComponent', this._shouldReuseRouteComponents());
576
+ }
577
+ if (name === 'routesrc' && newValue && newValue !== oldValue) {
578
+ this._loadRoutesFromSrc(newValue).then(() => this._handleNavigation());
579
+ }
580
+ }
581
+
582
+ connectedCallback() {
583
+ this._enableManualScrollRestoration();
584
+ if (this._mode === 'history') {
585
+ window.addEventListener('popstate', this._onNavigate);
586
+ } else {
587
+ window.addEventListener('hashchange', this._onNavigate);
588
+ }
589
+ document.body.addEventListener('x-navigate', this._onNavigate);
590
+ document.body.addEventListener('click', this._onLinkClick, true);
591
+ // xstate -> Router: Navigation per xstate.set('router-navigate', '/ziel')
592
+ if (typeof xstate.subscribe === 'function') {
593
+ this._unsubscribeXStateNav = xstate.subscribe((key, value) => {
594
+ if (key === 'router-navigate' && typeof value === 'string') {
595
+ this._navigateTo(value);
596
+ }
597
+ }, 'router-navigate');
598
+ }
599
+ // Wenn routesrc gesetzt ist, lade die Routen
600
+ const src = this.getAttribute('routesrc');
601
+ const initialRouteLoad = src
602
+ ? this._loadRoutesFromSrc(src)
603
+ : Promise.resolve();
604
+ // HMR Support (nur im Dev-Modus, wenn vorhanden)
605
+ if (window.__xtendHMR && typeof window.__xtendHMR.on === 'function') {
606
+ // Routen-HMR
607
+ window.__xtendHMR.on('route-change', () => {
608
+ const src = this.getAttribute('routesrc');
609
+ const reloadPromise = src ? this._loadRoutesFromSrc(src) : Promise.resolve();
610
+ reloadPromise.then(() => this._handleNavigation());
611
+ });
612
+ // Komponenten-HMR
613
+ window.__xtendHMR.on('component-change', tag => {
614
+ if (typeof tag === 'string' && customElements.get(tag)) {
615
+ // Entferne alle Instanzen aus dem DOM
616
+ document.querySelectorAll(tag).forEach(el => el.remove());
617
+ // Lösche das Custom Element (geht nur im Dev-Modus, nicht in allen Browsern)
618
+ // @ts-ignore
619
+ if (customElements.get(tag) && customElements._definitions) {
620
+ delete customElements._definitions[tag];
621
+ }
622
+ // Versuche, das Modul neu zu importieren (nur wenn importUrl bekannt)
623
+ const route = Array.from(this.querySelectorAll('x-route')).find(r => r.component === tag);
624
+ const importUrl = route ? this._getRouteImportUrl(route) : null;
625
+ if (importUrl) {
626
+ import(importUrl + '?t=' + Date.now()).then(() => {
627
+ this._handleNavigation();
628
+ });
629
+ } else {
630
+ this._handleNavigation();
631
+ }
632
+ }
633
+ });
634
+ }
635
+ initialRouteLoad.then(() => this._handleNavigation({ focus: false, source: 'initial-load' }));
636
+ }
637
+
638
+ disconnectedCallback() {
639
+ if (this._mode === 'history') {
640
+ window.removeEventListener('popstate', this._onNavigate);
641
+ } else {
642
+ window.removeEventListener('hashchange', this._onNavigate);
643
+ }
644
+ document.body.removeEventListener('x-navigate', this._onNavigate);
645
+ document.body.removeEventListener('click', this._onLinkClick, true);
646
+ if (typeof this._unsubscribeXStateNav === 'function') {
647
+ this._unsubscribeXStateNav();
648
+ this._unsubscribeXStateNav = null;
649
+ }
650
+ this._clearScrollBoundaryChecks();
651
+ this._restoreScrollRestoration();
652
+ }
653
+
654
+ _getCurrentPath() {
655
+ if (this._mode === 'history') {
656
+ return window.location.pathname + window.location.search;
657
+ } else {
658
+ const hash = window.location.hash.replace(/^#\/?/, '/');
659
+ const search = window.location.search;
660
+ // Falls Hash-Mode, aber Query-String vorhanden (z.B. index.html#/foo?bar=baz)
661
+ if (hash.includes('?')) return hash;
662
+ if (search && hash) return hash + search;
663
+ return hash;
664
+ }
665
+ }
666
+
667
+ _parsePathAndQuery(path) {
668
+ // Gibt { path, query, queryObj } zurück
669
+ const [purePath, query = ''] = path.split('?');
670
+ const queryObj = {};
671
+ if (query) {
672
+ for (const part of query.split('&')) {
673
+ const [k, v] = part.split('=');
674
+ if (k) queryObj[decodeURIComponent(k)] = v ? decodeURIComponent(v) : '';
675
+ }
676
+ }
677
+ return { path: purePath, query, queryObj };
678
+ }
679
+
680
+ _navigateTo(path, state = undefined) {
681
+ const normalizedPath = path.startsWith('/') ? path : '/' + path;
682
+ const currentPath = this._getCurrentPath();
683
+
684
+ if (!this._emitBeforeNavigate(normalizedPath, state)) {
685
+ return;
686
+ }
687
+
688
+ if (normalizedPath === currentPath) {
689
+ this._handleNavigation();
690
+ return;
691
+ }
692
+
693
+ // path kann Query enthalten
694
+ if (this._mode === 'history') {
695
+ window.history.pushState(state || {}, '', normalizedPath);
696
+ this._handleNavigation();
697
+ } else {
698
+ window.location.hash = normalizedPath;
699
+ }
700
+
701
+ xstate.set('router-navigated', normalizedPath);
702
+ xstate.set('xtend.router.lastNavigated', normalizedPath);
703
+ }
704
+
705
+ _emitBeforeNavigate(path, state = undefined) {
706
+ const detail = {
707
+ path,
708
+ mode: this._mode,
709
+ state,
710
+ source: 'x-router',
711
+ stateKey: 'xtend.router.current',
712
+ scheduleRef: 'ui.user-blocking.navigation'
713
+ };
714
+ return this.dispatchEvent(new CustomEvent('xrouter-before-navigate', {
715
+ detail,
716
+ cancelable: true,
717
+ bubbles: true,
718
+ composed: true
719
+ }));
720
+ }
721
+
722
+ _handleLinkClick(e) {
723
+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
724
+ return;
725
+ }
726
+
727
+ const path = typeof e.composedPath === 'function' ? e.composedPath() : [];
728
+ const linkCandidate = path.find((node) => {
729
+ if (!node || !node.tagName) return false;
730
+ return (
731
+ node.tagName === 'X-LINK' ||
732
+ (node.tagName === 'A' && typeof node.hasAttribute === 'function' && node.hasAttribute('is-x-link'))
733
+ );
734
+ });
735
+
736
+ if (!linkCandidate) return;
737
+
738
+ const href = linkCandidate.getAttribute('href');
739
+ const target = linkCandidate.getAttribute('target');
740
+ if (!href || href.startsWith('http') || href.startsWith('mailto:') || href.startsWith('tel:')) {
741
+ return;
742
+ }
743
+ if (target && target !== '_self') {
744
+ return;
745
+ }
746
+
747
+ e.preventDefault();
748
+ this._navigateTo(href.replace(/^#\/?/, '/'));
749
+ }
750
+
751
+ _collectParams(match, target = {}) {
752
+ if (!match) return target;
753
+ Object.assign(target, match.params || {});
754
+ if (match.child) {
755
+ return this._collectParams(match.child, target);
756
+ }
757
+ return target;
758
+ }
759
+
760
+ _getLeafMatch(match) {
761
+ let current = match;
762
+ while (current && current.child) {
763
+ current = current.child;
764
+ }
765
+ return current;
766
+ }
767
+
768
+ _shouldReuseRouteComponents(route = null) {
769
+ return this.hasAttribute('reuse-component') ||
770
+ this.hasAttribute('data-reuse-component') ||
771
+ Boolean(route && route.hasAttribute && (route.hasAttribute('reuse-component') || route.hasAttribute('data-reuse-component')));
772
+ }
773
+
774
+ async _tryReuseRouteComponent(match, context = {}) {
775
+ if (!match || !this._outlet || !this._shouldReuseRouteComponents(match.route)) return false;
776
+ const current = this._outlet.firstElementChild;
777
+ if (!current || match.child) return false;
778
+
779
+ const leaf = this._getLeafMatch(match);
780
+ const route = leaf && leaf.route ? leaf.route : match.route;
781
+ const componentTag = this._getRouteComponent(route);
782
+ if (!componentTag || current.localName !== String(componentTag).toLowerCase()) return false;
783
+
784
+ const update = typeof current.updateRoute === 'function'
785
+ ? current.updateRoute.bind(current)
786
+ : (typeof current.routeChangedCallback === 'function' ? current.routeChangedCallback.bind(current) : null);
787
+ if (!update) return false;
788
+
789
+ current.params = match.params || {};
790
+ current.query = context.queryObj || {};
791
+ current.queryString = context.query || '';
792
+ if (this._mode === 'history' && window.history.state) {
793
+ current.state = window.history.state;
794
+ }
795
+
796
+ const detail = {
797
+ path: context.path,
798
+ route,
799
+ match,
800
+ params: this._collectParams(match),
801
+ query: context.query || '',
802
+ queryObj: context.queryObj || {},
803
+ documentMeta: context.documentMeta || null,
804
+ router: this,
805
+ reused: true
806
+ };
807
+
808
+ try {
809
+ const result = await update(detail);
810
+ if (result === false) return false;
811
+ const reuseDetail = {
812
+ ...detail,
813
+ mode: this._mode,
814
+ component: componentTag,
815
+ routeId: this._getRouteValue(route, 'id', 'data-rmt-route-id') || null,
816
+ template: this._getRouteValue(route, 'template', 'data-rmt-template') || null,
817
+ scheduleRef: this._getRouteValue(route, 'schedule', 'data-rmt-schedule') || null,
818
+ query: context.queryObj || {},
819
+ metadata: this._readRouteJsonAttribute(route, 'data-rmt-metadata'),
820
+ title: context.documentMeta ? context.documentMeta.title : '',
821
+ documentTitle: context.documentMeta ? context.documentMeta.documentTitle : '',
822
+ meta: context.documentMeta || null,
823
+ source: 'x-router',
824
+ stateKey: 'xtend.router.current'
825
+ };
826
+ xstate.set('xtend.router.routeReused', reuseDetail);
827
+ this.dispatchEvent(new CustomEvent('xrouter-route-reused', {
828
+ detail: reuseDetail,
829
+ bubbles: true,
830
+ composed: true
831
+ }));
832
+ return true;
833
+ } catch (error) {
834
+ console.error(`Router: Fehler beim Wiederverwenden von <${componentTag}>:`, error);
835
+ this._outlet.innerHTML = this._renderError(500, `Fehler beim Aktualisieren von <strong>${componentTag}</strong>\n${error.message}`);
836
+ return true;
837
+ }
838
+ }
839
+
840
+ _buildRouteDetail(path, match, queryObj = {}, documentMeta = null) {
841
+ if (!match) {
842
+ return {
843
+ path,
844
+ component: null,
845
+ params: {},
846
+ query: queryObj,
847
+ title: documentMeta ? documentMeta.title : '',
848
+ documentTitle: documentMeta ? documentMeta.documentTitle : '',
849
+ meta: documentMeta || null
850
+ };
851
+ }
852
+
853
+ const leaf = this._getLeafMatch(match);
854
+ const route = leaf && leaf.route ? leaf.route : null;
855
+ const routeMeta = documentMeta || this._resolveDocumentMeta(route, {
856
+ path,
857
+ params: this._collectParams(match),
858
+ query: queryObj
859
+ });
860
+ return {
861
+ path,
862
+ routeId: this._getRouteValue(route, 'id', 'data-rmt-route-id') || null,
863
+ mode: this._mode,
864
+ component: route ? this._getRouteComponent(route) || null : null,
865
+ template: this._getRouteValue(route, 'template', 'data-rmt-template') || null,
866
+ scheduleRef: this._getRouteValue(route, 'schedule', 'data-rmt-schedule') || null,
867
+ params: this._collectParams(match),
868
+ query: queryObj,
869
+ metadata: this._readRouteJsonAttribute(route, 'data-rmt-metadata'),
870
+ title: routeMeta.title || '',
871
+ documentTitle: routeMeta.documentTitle || '',
872
+ meta: routeMeta,
873
+ source: 'x-router',
874
+ stateKey: 'xtend.router.current'
875
+ };
876
+ }
877
+
878
+ _emitRouteChange(detail, options = {}) {
879
+ const enrichedDetail = {
880
+ ...detail,
881
+ announcement: this._getRouteAnnouncement(detail),
882
+ source: detail.source || 'x-router',
883
+ stateKey: detail.stateKey || 'xtend.router.current'
884
+ };
885
+ this._lastRouteDetail = enrichedDetail;
886
+
887
+ xstate.set('router-current', enrichedDetail);
888
+ xstate.set('xtend.router.current', enrichedDetail);
889
+ xstate.set('router-rendered', enrichedDetail);
890
+ xstate.set('xtend.router.lastRendered', enrichedDetail);
891
+ xstate.set('xtend.router.announcement', enrichedDetail.announcement);
892
+
893
+ const routeChangedEvent = new CustomEvent('route-changed', {
894
+ detail: enrichedDetail,
895
+ bubbles: true,
896
+ composed: true
897
+ });
898
+ const legacyRouteChangeEvent = new CustomEvent('routechange', {
899
+ detail: enrichedDetail,
900
+ bubbles: true,
901
+ composed: true
902
+ });
903
+
904
+ this.dispatchEvent(routeChangedEvent);
905
+ this.dispatchEvent(legacyRouteChangeEvent);
906
+ window.dispatchEvent(new CustomEvent('xrouter-after-navigate', { detail: enrichedDetail }));
907
+ this.announceRoute(enrichedDetail);
908
+ if (options.focus === false) {
909
+ if (this._outlet) this._outlet.setAttribute('aria-busy', 'false');
910
+ return;
911
+ }
912
+ this.focusRoute(enrichedDetail);
913
+ }
914
+
915
+ _enableManualScrollRestoration() {
916
+ if (typeof window === 'undefined' || !window.history || !('scrollRestoration' in window.history)) {
917
+ return;
918
+ }
919
+ if (this._previousScrollRestoration === null) {
920
+ this._previousScrollRestoration = window.history.scrollRestoration;
921
+ }
922
+ window.history.scrollRestoration = 'manual';
923
+ }
924
+
925
+ _restoreScrollRestoration() {
926
+ if (
927
+ typeof window === 'undefined' ||
928
+ !window.history ||
929
+ !('scrollRestoration' in window.history) ||
930
+ this._previousScrollRestoration === null
931
+ ) {
932
+ return;
933
+ }
934
+ window.history.scrollRestoration = this._previousScrollRestoration;
935
+ this._previousScrollRestoration = null;
936
+ }
937
+
938
+ _clearScrollBoundaryChecks() {
939
+ this._scrollBoundaryToken = null;
940
+ if (this._scrollBoundaryFrame !== null && typeof window !== 'undefined' && typeof window.cancelAnimationFrame === 'function') {
941
+ window.cancelAnimationFrame(this._scrollBoundaryFrame);
942
+ }
943
+ if (this._scrollBoundarySecondFrame !== null && typeof window !== 'undefined' && typeof window.cancelAnimationFrame === 'function') {
944
+ window.cancelAnimationFrame(this._scrollBoundarySecondFrame);
945
+ }
946
+ if (this._scrollBoundaryTimer !== null && typeof window !== 'undefined') {
947
+ window.clearTimeout(this._scrollBoundaryTimer);
948
+ }
949
+ if (this._scrollBoundarySettleTimer !== null && typeof window !== 'undefined') {
950
+ window.clearTimeout(this._scrollBoundarySettleTimer);
951
+ }
952
+ this._scrollBoundaryFrame = null;
953
+ this._scrollBoundarySecondFrame = null;
954
+ this._scrollBoundaryTimer = null;
955
+ this._scrollBoundarySettleTimer = null;
956
+ }
957
+
958
+ _getRouteAnnouncement(detail) {
959
+ if (!detail) return 'Route geladen';
960
+ const metadata = detail.metadata || {};
961
+ return metadata.announcement || metadata.title || detail.routeId || detail.path || 'Route geladen';
962
+ }
963
+
964
+ focusRoute(detail = this._lastRouteDetail) {
965
+ if (!this._outlet || !this.isConnected) return false;
966
+ this._outlet.setAttribute('aria-busy', 'false');
967
+ this._outlet.focus({ preventScroll: true });
968
+ xstate.set('xtend.router.focusRestored', {
969
+ ...(detail || {}),
970
+ source: 'x-router',
971
+ stateKey: 'xtend.router.current',
972
+ scheduleRef: 'route.focus.restore'
973
+ });
974
+ return true;
975
+ }
976
+
977
+ announceRoute(detail = this._lastRouteDetail) {
978
+ const announcement = this._getRouteAnnouncement(detail);
979
+ if (this._announcer) {
980
+ this._announcer.textContent = '';
981
+ queueMicrotask(() => {
982
+ this._announcer.textContent = announcement;
983
+ });
984
+ }
985
+ const eventDetail = {
986
+ ...(detail || {}),
987
+ announcement,
988
+ source: 'x-router',
989
+ stateKey: 'xtend.router.announcement',
990
+ scheduleRef: 'a11y.announce'
991
+ };
992
+ this.dispatchEvent(new CustomEvent('route-announced', {
993
+ detail: eventDetail,
994
+ bubbles: true,
995
+ composed: true
996
+ }));
997
+ return eventDetail;
998
+ }
999
+
1000
+ snapshot() {
1001
+ return {
1002
+ schema: 'xtend.component.navigation-routing-snapshot.v1',
1003
+ source: 'x-router',
1004
+ stateKey: 'xtend.router.current',
1005
+ mode: this._mode,
1006
+ current: this._lastRouteDetail,
1007
+ routeCount: this._getRoutes().length,
1008
+ scheduleRef: 'diagnostics.snapshot'
1009
+ };
1010
+ }
1011
+
1012
+ _getTopLevelChildRoutes(node) {
1013
+ return Array.from(node.children).filter((child) => child.tagName === 'X-ROUTE');
1014
+ }
1015
+
1016
+ _getRouteImportUrl(route) {
1017
+ return typeof route.importUrl === 'string'
1018
+ ? route.importUrl
1019
+ : route.getAttribute && route.getAttribute('import');
1020
+ }
1021
+
1022
+ _getRouteComponent(route) {
1023
+ return typeof route.component === 'string'
1024
+ ? route.component
1025
+ : route.getAttribute && route.getAttribute('component');
1026
+ }
1027
+
1028
+ _getRoutePath(route) {
1029
+ return typeof route.path === 'string'
1030
+ ? route.path
1031
+ : route.getAttribute && route.getAttribute('path');
1032
+ }
1033
+
1034
+ _getRouteValue(route, propertyName, attributeName = propertyName) {
1035
+ if (!route) return '';
1036
+ if (typeof route[propertyName] === 'string') return route[propertyName];
1037
+ return route.getAttribute && route.getAttribute(attributeName) || '';
1038
+ }
1039
+
1040
+ _readRouteJsonAttribute(route, attributeName) {
1041
+ const value = this._getRouteValue(route, attributeName, attributeName);
1042
+ if (!value) return {};
1043
+ try {
1044
+ return JSON.parse(value);
1045
+ } catch (_error) {
1046
+ return {};
1047
+ }
1048
+ }
1049
+
1050
+ _readRouteNumber(route, attributeName, fallback) {
1051
+ const raw = route && route.getAttribute && route.getAttribute(attributeName);
1052
+ const value = Number(raw || fallback);
1053
+ return Number.isFinite(value) && value > 0 ? value : fallback;
1054
+ }
1055
+
1056
+ _routeSkeletonEnabled(route) {
1057
+ if (!route) return this.hasAttribute('skeleton') || this.hasAttribute('data-xtend-skeleton');
1058
+ const value = this._getRouteValue(route, 'skeleton', 'skeleton') ||
1059
+ this._getRouteValue(route, 'data-xtend-skeleton', 'data-xtend-skeleton') ||
1060
+ this.getAttribute('skeleton') ||
1061
+ this.getAttribute('data-xtend-skeleton') ||
1062
+ '';
1063
+ if (value === '') return this.hasAttribute('skeleton') || this.hasAttribute('data-xtend-skeleton');
1064
+ return !['false', '0', 'off', 'none'].includes(String(value).trim().toLowerCase());
1065
+ }
1066
+
1067
+ _getRouteHydrateSchedule(route) {
1068
+ return this._getRouteValue(route, 'hydrateSchedule', 'hydrate-schedule') ||
1069
+ this._getRouteValue(route, 'data-rmt-hydrate-schedule', 'data-rmt-hydrate-schedule') ||
1070
+ this.getAttribute('hydrate-schedule') ||
1071
+ this.getAttribute('data-rmt-hydrate-schedule') ||
1072
+ 'component.dynamic.hydrate';
1073
+ }
1074
+
1075
+ _getRouteSkeletonOptions(route, context = {}) {
1076
+ const routeLines = this._readRouteNumber(route, 'skeleton-lines', 0);
1077
+ const routerLines = Number(this.getAttribute('skeleton-lines') || 0);
1078
+ const lines = routeLines || (Number.isFinite(routerLines) && routerLines > 0 ? routerLines : 6);
1079
+ return {
1080
+ variant: this._getRouteValue(route, 'skeleton', 'skeleton') || this.getAttribute('skeleton') || 'route',
1081
+ lines,
1082
+ minHeight: this._getRouteValue(route, 'skeletonMinHeight', 'skeleton-min-height') ||
1083
+ this.getAttribute('skeleton-min-height') ||
1084
+ this.style.getPropertyValue('--xtend-router-skeleton-min-height') ||
1085
+ '12rem',
1086
+ label: this.getAttribute('skeleton-label') || 'Route wird geladen',
1087
+ source: 'x-router',
1088
+ schedule: this._getRouteValue(route, 'schedule', 'data-rmt-schedule') || 'route.visible.render',
1089
+ routeId: this._getRouteValue(route, 'id', 'data-rmt-route-id') || null,
1090
+ path: context.path || this._getCurrentPath()
1091
+ };
1092
+ }
1093
+
1094
+ _showRouteSkeleton(route, context = {}) {
1095
+ if (!this._outlet || !this._routeSkeletonEnabled(route)) return null;
1096
+ const options = this._getRouteSkeletonOptions(route, context);
1097
+ const loader = typeof window !== 'undefined' && window.XTendLoader;
1098
+ const skeleton = loader && typeof loader.showSkeleton === 'function'
1099
+ ? loader.showSkeleton(this._outlet, options)
1100
+ : this._createFallbackRouteSkeleton(options);
1101
+ this._routeSkeleton = skeleton;
1102
+ const detail = {
1103
+ schema: 'xtend.router.skeleton-loader.v1',
1104
+ source: 'x-router',
1105
+ stateKey: 'xtend.router.skeleton',
1106
+ scheduleRef: options.schedule,
1107
+ routeId: options.routeId,
1108
+ path: options.path,
1109
+ active: true
1110
+ };
1111
+ xstate.set('xtend.router.skeleton', detail);
1112
+ this.dispatchEvent(new CustomEvent('xrouter-skeleton-shown', {
1113
+ detail,
1114
+ bubbles: true,
1115
+ composed: true
1116
+ }));
1117
+ return skeleton;
1118
+ }
1119
+
1120
+ _createFallbackRouteSkeleton(options = {}) {
1121
+ const skeleton = document.createElement('div');
1122
+ skeleton.setAttribute('data-xtend-skeleton-loader', '');
1123
+ skeleton.setAttribute('data-xtend-skeleton-source', 'x-router');
1124
+ skeleton.setAttribute('role', 'status');
1125
+ skeleton.setAttribute('aria-label', options.label || 'Route wird geladen');
1126
+ if (options.minHeight) skeleton.style.minHeight = options.minHeight;
1127
+ const lines = Math.max(1, Math.min(24, Number(options.lines || 6)));
1128
+ const widths = ['72%', '94%', '84%', '58%', '88%', '66%'];
1129
+ for (let index = 0; index < lines; index += 1) {
1130
+ const line = document.createElement('span');
1131
+ line.setAttribute('data-xtend-skeleton-line', '');
1132
+ line.style.width = widths[index % widths.length];
1133
+ skeleton.appendChild(line);
1134
+ }
1135
+ this._outlet.setAttribute('data-xtend-skeleton-active', 'true');
1136
+ this._outlet.appendChild(skeleton);
1137
+ return skeleton;
1138
+ }
1139
+
1140
+ _clearRouteSkeleton(route, context = {}) {
1141
+ if (!this._outlet) return;
1142
+ const loader = typeof window !== 'undefined' && window.XTendLoader;
1143
+ if (loader && typeof loader.hideSkeleton === 'function') {
1144
+ loader.hideSkeleton(this._outlet, { preserveBusy: true });
1145
+ } else {
1146
+ Array.from(this._outlet.children || [])
1147
+ .filter((child) => child && child.hasAttribute && child.hasAttribute('data-xtend-skeleton-loader'))
1148
+ .forEach((skeleton) => skeleton.remove());
1149
+ this._outlet.removeAttribute('data-xtend-skeleton-active');
1150
+ }
1151
+ this._routeSkeleton = null;
1152
+ const detail = {
1153
+ schema: 'xtend.router.skeleton-loader.v1',
1154
+ source: 'x-router',
1155
+ stateKey: 'xtend.router.skeleton',
1156
+ scheduleRef: this._getRouteValue(route, 'schedule', 'data-rmt-schedule') || 'route.visible.render',
1157
+ routeId: this._getRouteValue(route, 'id', 'data-rmt-route-id') || null,
1158
+ path: context.path || this._getCurrentPath(),
1159
+ active: false
1160
+ };
1161
+ xstate.set('xtend.router.skeleton', detail);
1162
+ this.dispatchEvent(new CustomEvent('xrouter-skeleton-hidden', {
1163
+ detail,
1164
+ bubbles: true,
1165
+ composed: true
1166
+ }));
1167
+ }
1168
+
1169
+ async _ensureRouteComponent(componentTag, importUrl, route = null) {
1170
+ if (!componentTag) return false;
1171
+ if (customElements.get(componentTag)) return true;
1172
+ if (importUrl) {
1173
+ await import(importUrl);
1174
+ } else if (window.XTendLoader && typeof window.XTendLoader.ensureComponent === 'function') {
1175
+ await window.XTendLoader.ensureComponent(componentTag, {
1176
+ source: 'x-router',
1177
+ reason: 'route-component',
1178
+ schedule: this._getRouteValue(route, 'schedule', 'data-rmt-schedule') || 'route.visible.render'
1179
+ });
1180
+ }
1181
+ return Boolean(customElements.get(componentTag));
1182
+ }
1183
+
1184
+ async _hydrateRouteTree(component, route) {
1185
+ if (!component || !component.isConnected) return null;
1186
+ const schedule = this._getRouteHydrateSchedule(route);
1187
+ let detail = null;
1188
+ if (window.XTendLoader && typeof window.XTendLoader.hydrateTree === 'function') {
1189
+ detail = await window.XTendLoader.hydrateTree(component, {
1190
+ tags: [component.localName],
1191
+ source: 'x-router',
1192
+ reason: 'route-render',
1193
+ schedule
1194
+ });
1195
+ } else if (typeof component.hydrate === 'function') {
1196
+ component.hydrate();
1197
+ detail = {
1198
+ schema: 'xtend.router.route-hydration.v1',
1199
+ source: 'x-router',
1200
+ schedule,
1201
+ hydrated: 1
1202
+ };
1203
+ }
1204
+ if (detail) {
1205
+ this.dispatchEvent(new CustomEvent('xrouter-route-hydrated', {
1206
+ detail: {
1207
+ ...detail,
1208
+ routeId: this._getRouteValue(route, 'id', 'data-rmt-route-id') || null,
1209
+ scheduleRef: schedule
1210
+ },
1211
+ bubbles: true,
1212
+ composed: true
1213
+ }));
1214
+ }
1215
+ return detail;
1216
+ }
1217
+
1218
+ _snapshotDocumentMeta() {
1219
+ if (typeof document === 'undefined') return {};
1220
+ const read = (name) => {
1221
+ const meta = document.querySelector(`meta[name="${name}"]`);
1222
+ return meta ? meta.getAttribute('content') || '' : '';
1223
+ };
1224
+ return {
1225
+ description: read('description'),
1226
+ keywords: read('keywords')
1227
+ };
1228
+ }
1229
+
1230
+ _readObjectPath(source, path) {
1231
+ if (!source || !path) return undefined;
1232
+ return String(path).split('.').reduce((value, segment) => {
1233
+ if (value === undefined || value === null) return undefined;
1234
+ return Object.prototype.hasOwnProperty.call(Object(value), segment)
1235
+ ? value[segment]
1236
+ : undefined;
1237
+ }, source);
1238
+ }
1239
+
1240
+ _interpolateTitleTemplate(template, context = {}) {
1241
+ if (!template) return '';
1242
+ return String(template).replace(/\{\{\s*([a-zA-Z0-9_.-]+)\s*\}\}/g, (_match, key) => {
1243
+ const value = this._readObjectPath(context, key);
1244
+ return value === undefined || value === null ? '' : String(value);
1245
+ }).trim();
1246
+ }
1247
+
1248
+ _readRouteMetadata(route) {
1249
+ return this._readRouteJsonAttribute(route, 'data-rmt-metadata');
1250
+ }
1251
+
1252
+ _readMetadataValue(metadata = {}, keys = []) {
1253
+ const seo = metadata.seo && typeof metadata.seo === 'object' ? metadata.seo : {};
1254
+ for (const key of keys) {
1255
+ const value = this._readObjectPath(metadata, key);
1256
+ if (value !== undefined && value !== null && String(value).trim()) return value;
1257
+ const seoValue = this._readObjectPath(seo, key);
1258
+ if (seoValue !== undefined && seoValue !== null && String(seoValue).trim()) return seoValue;
1259
+ }
1260
+ return '';
1261
+ }
1262
+
1263
+ _normalizeMetaContent(value) {
1264
+ if (Array.isArray(value)) return value.map(item => String(item).trim()).filter(Boolean).join(', ');
1265
+ return value === undefined || value === null ? '' : String(value).trim();
1266
+ }
1267
+
1268
+ _getMetaTag(name) {
1269
+ if (typeof document === 'undefined') return null;
1270
+ let meta = document.querySelector(`meta[name="${name}"]`);
1271
+ if (!meta) {
1272
+ meta = document.createElement('meta');
1273
+ meta.name = name;
1274
+ document.head.appendChild(meta);
1275
+ }
1276
+ return meta;
1277
+ }
1278
+
1279
+ _setMetaTag(name, value) {
1280
+ if (typeof document === 'undefined') return;
1281
+ const normalized = this._normalizeMetaContent(value);
1282
+ const fallback = this._initialDocumentMeta && this._initialDocumentMeta[name]
1283
+ ? this._initialDocumentMeta[name]
1284
+ : '';
1285
+ const content = normalized || fallback;
1286
+ const existing = document.querySelector(`meta[name="${name}"]`);
1287
+ if (!content) {
1288
+ if (existing) existing.remove();
1289
+ return;
1290
+ }
1291
+ const meta = existing || this._getMetaTag(name);
1292
+ if (meta) meta.content = content;
1293
+ }
1294
+
1295
+ _resolveDocumentMeta(route, context = {}) {
1296
+ const metadata = this._readRouteMetadata(route);
1297
+ const params = context.params || {};
1298
+ const query = context.query || {};
1299
+ const routeTitle = this._normalizeMetaContent(
1300
+ this._getRouteValue(route, 'title', 'title') ||
1301
+ this._readMetadataValue(metadata, ['title'])
1302
+ );
1303
+ const explicitDocumentTitle = this._normalizeMetaContent(
1304
+ this._getRouteValue(route, 'documentTitle', 'document-title') ||
1305
+ this._getRouteValue(route, 'document-title', 'document-title') ||
1306
+ this._readMetadataValue(metadata, ['documentTitle', 'document_title'])
1307
+ );
1308
+ const rawTitle = explicitDocumentTitle || routeTitle || this._normalizeMetaContent(context.fallbackTitle);
1309
+ const titleTemplate =
1310
+ this._getRouteValue(route, 'documentTitleTemplate', 'document-title-template') ||
1311
+ this._getRouteValue(route, 'titleTemplate', 'title-template') ||
1312
+ this._getRouteValue(route, 'data-rmt-title-template', 'data-rmt-title-template') ||
1313
+ this._readMetadataValue(metadata, ['documentTitleTemplate', 'titleTemplate', 'document_title_template', 'title_template']) ||
1314
+ this.getAttribute('document-title-template') ||
1315
+ this.getAttribute('title-template') ||
1316
+ '';
1317
+ const templateContext = {
1318
+ title: rawTitle,
1319
+ routeTitle,
1320
+ documentTitle: explicitDocumentTitle || rawTitle,
1321
+ path: context.path || this._getCurrentPath(),
1322
+ routeId: this._getRouteValue(route, 'id', 'data-rmt-route-id') || '',
1323
+ component: route ? this._getRouteComponent(route) || '' : '',
1324
+ params,
1325
+ query,
1326
+ metadata
1327
+ };
1328
+ const templatedTitle = titleTemplate
1329
+ ? this._interpolateTitleTemplate(titleTemplate, templateContext)
1330
+ : '';
1331
+ const prefix = this.getAttribute('title-prefix') || '';
1332
+ const suffix = this.getAttribute('title-suffix') || '';
1333
+ const defaultTitle = this.getAttribute('default-title') || this._initialDocumentTitle || '';
1334
+ const documentTitle = templatedTitle || (rawTitle ? `${prefix}${rawTitle}${suffix}` : defaultTitle);
1335
+ const description = this._normalizeMetaContent(
1336
+ this._getRouteValue(route, 'metaDescription', 'meta-description') ||
1337
+ this._readMetadataValue(metadata, ['metaDescription', 'description'])
1338
+ );
1339
+ const keywords = this._normalizeMetaContent(
1340
+ this._getRouteValue(route, 'metaKeywords', 'meta-keywords') ||
1341
+ this._readMetadataValue(metadata, ['metaKeywords', 'keywords'])
1342
+ );
1343
+
1344
+ return {
1345
+ schema: 'xtend.router.document-meta.v1',
1346
+ source: 'x-router',
1347
+ stateKey: 'xtend.router.documentMeta',
1348
+ scheduleRef: 'route.document.title.rewrite',
1349
+ path: templateContext.path,
1350
+ routeId: templateContext.routeId || null,
1351
+ title: routeTitle || rawTitle,
1352
+ documentTitle,
1353
+ description,
1354
+ keywords,
1355
+ titleTemplate: titleTemplate || null,
1356
+ metadata
1357
+ };
1358
+ }
1359
+
1360
+ registerRoutes(routes = [], options = {}) {
1361
+ const routeRecords = Array.isArray(routes)
1362
+ ? routes
1363
+ : (routes && Array.isArray(routes.routes) ? routes.routes : []);
1364
+ if (options.replace !== false) {
1365
+ this._getTopLevelChildRoutes(this).forEach(route => route.remove());
1366
+ }
1367
+ routeRecords.forEach((routeRecord) => {
1368
+ this.appendChild(XRouter.createRouteElementFromRecord(routeRecord, this.ownerDocument || document));
1369
+ });
1370
+ this._routesFromJson = null;
1371
+ const detail = {
1372
+ adapterId: options.adapterId || 'xtend.xrouter',
1373
+ source: options.source || 'runtime',
1374
+ routeCount: routeRecords.length
1375
+ };
1376
+ this.dispatchEvent(new CustomEvent('xrouter-routes-registered', {
1377
+ detail,
1378
+ bubbles: true,
1379
+ composed: true
1380
+ }));
1381
+ if (options.render !== false) {
1382
+ this._handleNavigation();
1383
+ }
1384
+ return detail;
1385
+ }
1386
+
1387
+ navigate(to, options = {}) {
1388
+ const rawTarget = to && typeof to === 'object' ? to : { path: to };
1389
+ const routeId = rawTarget.routeId || rawTarget.id || rawTarget.route || '';
1390
+ let targetPath = rawTarget.path || rawTarget.to || rawTarget.href || '';
1391
+ if (!targetPath && routeId) {
1392
+ const route = this._getRoutes().find(candidate => this._getRouteValue(candidate, 'id', 'data-rmt-route-id') === routeId);
1393
+ targetPath = route ? this._getRoutePath(route) : '';
1394
+ }
1395
+ if (!targetPath) return false;
1396
+ this._navigateTo(targetPath, {
1397
+ routeId,
1398
+ params: rawTarget.params || {},
1399
+ query: rawTarget.query || {},
1400
+ metadata: rawTarget.metadata || {},
1401
+ source: options.source || 'rmt'
1402
+ });
1403
+ return true;
1404
+ }
1405
+
1406
+ /**
1407
+ * Rekursive Suche nach passender Route inkl. Nested Routes, Aliases und Redirects
1408
+ */
1409
+ _matchRoute(path, routes = null) {
1410
+ routes = routes || this._getRoutes();
1411
+ const pathSegments = path.split('/').filter(Boolean);
1412
+ for (const route of routes) {
1413
+ // Aliases: route kann ein alias-Attribut (Komma-separiert) haben
1414
+ const routePath = this._getRoutePath(route);
1415
+ const aliases = (route.getAttribute && route.getAttribute('alias'))
1416
+ ? route.getAttribute('alias').split(',').map(a => a.trim()).filter(Boolean)
1417
+ : [];
1418
+ const allPaths = [routePath, ...aliases];
1419
+ for (const testPath of allPaths) {
1420
+ if (testPath === '*') continue;
1421
+ const routeSegments = testPath.split('/').filter(Boolean);
1422
+ if (pathSegments.length < routeSegments.length) continue;
1423
+ const params = {};
1424
+ let isMatch = true;
1425
+ for (let i = 0; i < routeSegments.length; i++) {
1426
+ const segment = routeSegments[i];
1427
+ if (segment.startsWith(':')) {
1428
+ params[segment.substring(1)] = pathSegments[i];
1429
+ } else if (segment !== pathSegments[i]) {
1430
+ isMatch = false;
1431
+ break;
1432
+ }
1433
+ }
1434
+ if (isMatch) {
1435
+ // Redirect: route kann ein redirect-Attribut haben
1436
+ const redirect = route.getAttribute && route.getAttribute('redirect');
1437
+ if (redirect) {
1438
+ // Sofortige Weiterleitung
1439
+ this._navigateTo(redirect);
1440
+ return null;
1441
+ }
1442
+ // Prüfe auf Nested Routes
1443
+ const childRoutes = this._getTopLevelChildRoutes(route);
1444
+ if (childRoutes.length && pathSegments.length > routeSegments.length) {
1445
+ const restPath = '/' + pathSegments.slice(routeSegments.length).join('/');
1446
+ const childMatch = this._matchRoute(restPath, childRoutes);
1447
+ if (childMatch) {
1448
+ return { route, params, child: childMatch };
1449
+ }
1450
+ }
1451
+ return { route, params };
1452
+ }
1453
+ }
1454
+ }
1455
+
1456
+ const notFoundRoute = (routes || []).find(r => r.path === '*');
1457
+ return notFoundRoute ? { route: notFoundRoute, params: {} } : null;
1458
+ }
1459
+
1460
+ _renderError(status = 500, details = '') {
1461
+ const messages = {
1462
+ 404: { title: '404 - Seite nicht gefunden', desc: 'Die angeforderte Seite existiert nicht oder wurde verschoben.' },
1463
+ 500: { title: '500 - Interner Fehler', desc: 'Ein unerwarteter Fehler ist aufgetreten.' },
1464
+ 401: { title: '401 - Nicht autorisiert', desc: 'Sie sind für diese Seite nicht angemeldet.' },
1465
+ 403: { title: '403 - Zugriff verweigert', desc: 'Sie haben keine Berechtigung, diese Seite zu sehen.' },
1466
+ 503: { title: '503 - Dienst nicht verfügbar', desc: 'Der Dienst ist vorübergehend nicht erreichbar.' },
1467
+ };
1468
+ const msg = messages[status] || messages[500];
1469
+ return `<div style="padding:2em;text-align:center"><h2>${msg.title}</h2><p>${msg.desc}</p>${details ? `<pre style='color:#b00'>${details}</pre>` : ''}</div>`;
1470
+ }
1471
+
1472
+ async _handleNavigation(options = {}) {
1473
+ const raw = this._getCurrentPath();
1474
+ const { path, query, queryObj } = this._parsePathAndQuery(raw);
1475
+ const match = this._matchRoute(path);
1476
+ this._outlet.setAttribute('aria-busy', 'true');
1477
+ // Animations-Hook: beforeRouteLeave (für aktuelle Komponente)
1478
+ if (this._outlet.firstElementChild && typeof this._outlet.firstElementChild.beforeRouteLeave === 'function') {
1479
+ const leaveResult = await this._outlet.firstElementChild.beforeRouteLeave();
1480
+ if (leaveResult === false) {
1481
+ this._outlet.setAttribute('aria-busy', 'false');
1482
+ return; // Abbruch möglich
1483
+ }
1484
+ }
1485
+ this._closeRouteNavigationOverlays({ path: raw, source: 'x-router-route-change' });
1486
+ // Animations-Hook: beforeRouteEnter (für Zielroute)
1487
+ if (match) {
1488
+ // Route Guard: beforeEnter
1489
+ const allow = await this._runBeforeEnter(match);
1490
+ if (!allow) {
1491
+ this._outlet.innerHTML = this._renderError(403, 'Navigation durch Guard abgebrochen.');
1492
+ this._outlet.setAttribute('aria-busy', 'false');
1493
+ return;
1494
+ }
1495
+ // Animations-Hook: beforeRouteEnter (als static Methode am Ziel-ComponentTag)
1496
+ const leaf = this._getLeafMatch(match);
1497
+ const route = leaf && leaf.route ? leaf.route : match.route;
1498
+ const componentTag = this._getRouteComponent(route);
1499
+ if (componentTag && customElements.get(componentTag)) {
1500
+ const ctor = customElements.get(componentTag);
1501
+ if (typeof ctor.beforeRouteEnter === 'function') {
1502
+ const enterResult = await ctor.beforeRouteEnter();
1503
+ if (enterResult === false) {
1504
+ this._outlet.setAttribute('aria-busy', 'false');
1505
+ return;
1506
+ }
1507
+ }
1508
+ }
1509
+ // Query-Objekt an Komponente übergeben
1510
+ match.query = query;
1511
+ match.queryObj = queryObj;
1512
+ // Seitentitel und Meta-Tags setzen
1513
+ const documentMeta = this._setDocumentMeta(route, {
1514
+ path: raw,
1515
+ params: this._collectParams(match),
1516
+ query: queryObj
1517
+ });
1518
+ const reused = await this._tryReuseRouteComponent(match, {
1519
+ path: raw,
1520
+ query,
1521
+ queryObj,
1522
+ documentMeta
1523
+ });
1524
+ if (!reused) {
1525
+ this._outlet.innerHTML = '';
1526
+ this._showRouteSkeleton(route, { path: raw });
1527
+ try {
1528
+ await this._renderRoute(match, this._outlet);
1529
+ } finally {
1530
+ this._clearRouteSkeleton(route, { path: raw });
1531
+ }
1532
+ }
1533
+ const routeDetail = this._buildRouteDetail(raw, match, queryObj, documentMeta);
1534
+ if (reused) routeDetail.reused = true;
1535
+ this._emitRouteChange(routeDetail, options);
1536
+ // Scroll-Verhalten nach erfolgreichem Rendern
1537
+ const scrollIntent = this._handleScrollAfterNavigation(route);
1538
+ this._scheduleScrollBoundaryCheck(scrollIntent, routeDetail);
1539
+ } else {
1540
+ this._outlet.innerHTML = this._renderError(404);
1541
+ const documentMeta = this._setDocumentMeta(null, {
1542
+ path: raw,
1543
+ params: {},
1544
+ query: queryObj,
1545
+ fallbackTitle: '404'
1546
+ });
1547
+ const routeDetail = this._buildRouteDetail(raw, null, queryObj, documentMeta);
1548
+ this._emitRouteChange(routeDetail, options);
1549
+ const scrollIntent = this._handleScrollAfterNavigation(null);
1550
+ this._scheduleScrollBoundaryCheck(scrollIntent, routeDetail);
1551
+ }
1552
+ }
1553
+
1554
+ /**
1555
+ * Setzt Seitentitel und Meta-Tags anhand der Route-Attribute
1556
+ */
1557
+ _setDocumentMeta(route, context = {}) {
1558
+ const meta = this._resolveDocumentMeta(route, context);
1559
+ if (meta.documentTitle && typeof document !== 'undefined') {
1560
+ document.title = meta.documentTitle;
1561
+ }
1562
+ this._setMetaTag('description', meta.description);
1563
+ this._setMetaTag('keywords', meta.keywords);
1564
+
1565
+ xstate.set('router-document-meta', meta);
1566
+ xstate.set('xtend.router.documentMeta', meta);
1567
+ this.dispatchEvent(new CustomEvent('xrouter-title-updated', {
1568
+ detail: meta,
1569
+ bubbles: true,
1570
+ composed: true
1571
+ }));
1572
+ return meta;
1573
+ }
1574
+
1575
+ /**
1576
+ * Scrollt nach Navigation zum Seitenanfang oder zu einem Anker (ID)
1577
+ */
1578
+ _handleScrollAfterNavigation(route) {
1579
+ const scrollTo = route && route.getAttribute && route.getAttribute('scroll-to');
1580
+ if (scrollTo) {
1581
+ const el = document.getElementById(scrollTo);
1582
+ if (el) {
1583
+ el.scrollIntoView({ behavior: 'auto', block: 'start' });
1584
+ return {
1585
+ schema: 'xtend.router.scroll-intent.v1',
1586
+ strategy: 'element',
1587
+ targetId: scrollTo,
1588
+ scheduleRef: 'route.scroll.boundary'
1589
+ };
1590
+ }
1591
+ }
1592
+ // Standard: Seitenanfang
1593
+ window.scrollTo(0, 0);
1594
+ return {
1595
+ schema: 'xtend.router.scroll-intent.v1',
1596
+ strategy: scrollTo ? 'missing-target' : 'top',
1597
+ targetId: scrollTo || null,
1598
+ scheduleRef: 'route.scroll.boundary'
1599
+ };
1600
+ }
1601
+
1602
+ _closeRouteNavigationOverlays(detail = {}) {
1603
+ if (typeof document === 'undefined') return [];
1604
+ const closedOverlays = [];
1605
+ document.querySelectorAll('x-header').forEach((header) => {
1606
+ const isOpen = typeof header.isMenuOpen === 'function' ? header.isMenuOpen() : false;
1607
+ if (!isOpen || typeof header.toggleMenu !== 'function') return;
1608
+ header.toggleMenu(false, { source: detail.source || 'x-router-route-change' });
1609
+ closedOverlays.push({
1610
+ tag: 'x-header',
1611
+ id: header.id || null
1612
+ });
1613
+ });
1614
+ if (!closedOverlays.length) return closedOverlays;
1615
+ const snapshot = {
1616
+ schema: 'xtend.router.closed-navigation-overlays.v1',
1617
+ source: 'x-router',
1618
+ stateKey: 'xtend.router.closedNavigationOverlays',
1619
+ scheduleRef: 'route.navigation.overlay.close',
1620
+ path: detail.path || this._getCurrentPath(),
1621
+ overlays: closedOverlays,
1622
+ count: closedOverlays.length
1623
+ };
1624
+ xstate.set('router-closed-navigation-overlays', snapshot);
1625
+ xstate.set('xtend.router.closedNavigationOverlays', snapshot);
1626
+ this.dispatchEvent(new CustomEvent('xrouter-navigation-overlays-closed', {
1627
+ detail: snapshot,
1628
+ bubbles: true,
1629
+ composed: true
1630
+ }));
1631
+ return closedOverlays;
1632
+ }
1633
+
1634
+ _scheduleScrollBoundaryCheck(scrollIntent = {}, detail = {}) {
1635
+ if (typeof window === 'undefined') return;
1636
+ this._clearScrollBoundaryChecks();
1637
+ const token = Symbol('xrouter-scroll-boundary');
1638
+ this._scrollBoundaryToken = token;
1639
+ const run = (phase) => {
1640
+ if (this._scrollBoundaryToken !== token) return;
1641
+ this._normalizeScrollBoundary(scrollIntent, detail, phase);
1642
+ };
1643
+
1644
+ if (typeof queueMicrotask === 'function') {
1645
+ queueMicrotask(() => run('microtask'));
1646
+ }
1647
+
1648
+ if (typeof window.requestAnimationFrame === 'function') {
1649
+ this._scrollBoundaryFrame = window.requestAnimationFrame(() => {
1650
+ this._scrollBoundaryFrame = null;
1651
+ run('frame');
1652
+ this._scrollBoundarySecondFrame = window.requestAnimationFrame(() => {
1653
+ this._scrollBoundarySecondFrame = null;
1654
+ run('settled-frame');
1655
+ });
1656
+ });
1657
+ } else {
1658
+ this._scrollBoundaryTimer = window.setTimeout(() => {
1659
+ this._scrollBoundaryTimer = null;
1660
+ run('timer');
1661
+ }, 0);
1662
+ }
1663
+
1664
+ this._scrollBoundarySettleTimer = window.setTimeout(() => {
1665
+ this._scrollBoundarySettleTimer = null;
1666
+ run('settled-timeout');
1667
+ }, 220);
1668
+ }
1669
+
1670
+ _normalizeScrollBoundary(scrollIntent = {}, detail = {}, phase = 'settled-frame') {
1671
+ if (typeof window === 'undefined' || !this.isConnected) return null;
1672
+ const doc = this.ownerDocument || document;
1673
+ const root = doc.documentElement;
1674
+ const body = doc.body;
1675
+ const scrollingElement = doc.scrollingElement || root;
1676
+ if (!scrollingElement || !root) return null;
1677
+
1678
+ const viewportHeight = window.innerHeight || root.clientHeight || scrollingElement.clientHeight || 0;
1679
+ const scrollHeight = Math.max(
1680
+ scrollingElement.scrollHeight || 0,
1681
+ root.scrollHeight || 0,
1682
+ body ? body.scrollHeight || 0 : 0
1683
+ );
1684
+ const maxScrollTop = Math.max(0, scrollHeight - viewportHeight);
1685
+ const currentTop = typeof window.scrollY === 'number'
1686
+ ? window.scrollY
1687
+ : (scrollingElement.scrollTop || 0);
1688
+ const currentLeft = typeof window.scrollX === 'number'
1689
+ ? window.scrollX
1690
+ : (scrollingElement.scrollLeft || 0);
1691
+ const expectsTop = !scrollIntent || scrollIntent.strategy === 'top' || scrollIntent.strategy === 'missing-target';
1692
+ const deadzoneDetected = currentTop > maxScrollTop + 1;
1693
+ const staleTopDetected = expectsTop && currentTop > 1;
1694
+ const shouldNormalize = deadzoneDetected || staleTopDetected;
1695
+ const normalizedTop = shouldNormalize
1696
+ ? (expectsTop ? 0 : maxScrollTop)
1697
+ : currentTop;
1698
+
1699
+ if (shouldNormalize) {
1700
+ window.scrollTo({ top: normalizedTop, left: currentLeft, behavior: 'auto' });
1701
+ }
1702
+
1703
+ const snapshot = {
1704
+ schema: 'xtend.router.scroll-boundary.v1',
1705
+ source: 'x-router',
1706
+ stateKey: 'xtend.router.scrollBoundary',
1707
+ scheduleRef: 'route.scroll.boundary',
1708
+ path: detail && detail.path ? detail.path : this._getCurrentPath(),
1709
+ phase,
1710
+ strategy: scrollIntent.strategy || 'top',
1711
+ targetId: scrollIntent.targetId || null,
1712
+ viewportHeight,
1713
+ scrollHeight,
1714
+ maxScrollTop,
1715
+ previousTop: currentTop,
1716
+ normalizedTop,
1717
+ normalized: shouldNormalize,
1718
+ deadzoneDetected
1719
+ };
1720
+
1721
+ xstate.set('router-scroll-boundary', snapshot);
1722
+ xstate.set('xtend.router.scrollBoundary', snapshot);
1723
+
1724
+ if (shouldNormalize) {
1725
+ this.dispatchEvent(new CustomEvent('xrouter-scroll-boundary-normalized', {
1726
+ detail: snapshot,
1727
+ bubbles: true,
1728
+ composed: true
1729
+ }));
1730
+ }
1731
+
1732
+ return snapshot;
1733
+ }
1734
+
1735
+ /**
1736
+ * Route Guard: beforeEnter (rekursiv für Nested Routes)
1737
+ */
1738
+ async _runBeforeEnter(match) {
1739
+ if (!match) return true;
1740
+ const { route, params, child } = match;
1741
+ let guard = route.beforeEnter;
1742
+ if (!guard && route.getAttribute && route.getAttribute('before-enter')) {
1743
+ const fn = window[route.getAttribute('before-enter')];
1744
+ if (typeof fn === 'function') guard = fn;
1745
+ }
1746
+ if (guard) {
1747
+ const result = await guard(params, route);
1748
+ if (result === false) return false;
1749
+ }
1750
+ if (child) {
1751
+ return await this._runBeforeEnter(child);
1752
+ }
1753
+ return true;
1754
+ }
1755
+
1756
+ /**
1757
+ * Rendert eine Route (und ggf. Kind-Route) rekursiv in den gegebenen Container
1758
+ */
1759
+ async _renderRoute(match, container) {
1760
+ const { route, params, child, query, queryObj } = match;
1761
+ const componentTag = this._getRouteComponent(route);
1762
+ const importUrl = this._getRouteImportUrl(route);
1763
+ if (!componentTag) {
1764
+ container.innerHTML = this._renderError(500, 'Route definiert keine Komponente.');
1765
+ return;
1766
+ }
1767
+ try {
1768
+ await this._ensureRouteComponent(componentTag, importUrl, route);
1769
+ } catch (e) {
1770
+ console.error(`Router: Fehler beim dynamischen Import von ${importUrl || componentTag}:`, e);
1771
+ container.innerHTML = this._renderError(500, `Fehler beim Laden von <strong>${importUrl || componentTag}</strong>\n${e.message}`);
1772
+ return;
1773
+ }
1774
+ if (customElements.get(componentTag)) {
1775
+ let component;
1776
+ try {
1777
+ component = document.createElement(componentTag);
1778
+ component.params = params;
1779
+ if (queryObj) component.query = queryObj;
1780
+ if (query) component.queryString = query;
1781
+ // Übergabe von State-Objekt (History-API)
1782
+ if (this._mode === 'history' && window.history.state) {
1783
+ component.state = window.history.state;
1784
+ }
1785
+ } catch (e) {
1786
+ container.innerHTML = this._renderError(500, `Fehler beim Erzeugen von <strong>${componentTag}</strong>\n${e.message}`);
1787
+ return;
1788
+ }
1789
+ // Animations-Hook: afterRouteEnter (Instanz-Methode)
1790
+ if (typeof component.afterRouteEnter === 'function') {
1791
+ setTimeout(() => component.afterRouteEnter(), 0);
1792
+ }
1793
+ // Wenn es eine Kind-Route gibt, rendere sie in ein Outlet
1794
+ if (child) {
1795
+ let outlet = component.querySelector('[slot="child"]');
1796
+ if (!outlet) {
1797
+ outlet = document.createElement('div');
1798
+ outlet.setAttribute('slot', 'child');
1799
+ component.appendChild(outlet);
1800
+ }
1801
+ await this._renderRoute(child, outlet);
1802
+ }
1803
+ container.appendChild(component);
1804
+ await this._hydrateRouteTree(component, route);
1805
+ } else {
1806
+ container.innerHTML = this._renderError(500, `Komponente <strong>${componentTag}</strong> ist nicht definiert oder konnte nicht geladen werden.`);
1807
+ console.warn(`Router: Komponente "${componentTag}" für den Pfad "${route.path}" ist nicht definiert oder noch nicht geladen.`);
1808
+ }
1809
+ }
1810
+
1811
+ async _loadRoutesFromSrc(src) {
1812
+ try {
1813
+ const resp = await fetch(src, { cache: 'no-store' });
1814
+ if (!resp.ok) throw new Error('Routen-JSON konnte nicht geladen werden');
1815
+ const data = await resp.json();
1816
+ this._routesFromJson = Array.isArray(data) ? data : (data.routes || []);
1817
+ this._rebuildRoutesFromJson();
1818
+ } catch (e) {
1819
+ console.error('Fehler beim Laden der Routen aus JSON:', e);
1820
+ }
1821
+ }
1822
+
1823
+ _rebuildRoutesFromJson() {
1824
+ // Entferne alle bisherigen x-route
1825
+ Array.from(this.querySelectorAll('x-route')).forEach(r => r.remove());
1826
+ // Baue neue x-route Elemente aus JSON
1827
+ const build = (routes, parent) => {
1828
+ for (const r of routes) {
1829
+ const el = XRouter.createRouteElementFromRecord(r, this.ownerDocument || document);
1830
+ parent.appendChild(el);
1831
+ }
1832
+ };
1833
+ build(this._routesFromJson, this);
1834
+ }
1835
+
1836
+ _getRoutes() {
1837
+ // Wenn Routen aus JSON geladen wurden, nutze die DOM-Struktur
1838
+ return this._getTopLevelChildRoutes(this);
1839
+ }
1840
+ }
1841
+ customElements.define('x-router', XRouter);