@bino-bi/bn-template-engine 1.0.0-next.29 → 1.0.0-next.30

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 (238) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-69dfa165.entry.js → p-132ad556.entry.js} +1 -1
  3. package/dist/bn-template-engine/{p-5e66d1d0.entry.js → p-17d71782.entry.js} +1 -1
  4. package/dist/bn-template-engine/{p-f10950e8.entry.js → p-40ba7f43.entry.js} +1 -1
  5. package/dist/bn-template-engine/p-467871f3.entry.js +1 -0
  6. package/dist/bn-template-engine/p-64803a42.entry.js +1 -0
  7. package/dist/bn-template-engine/p-B8AjeKja.js +1 -0
  8. package/dist/bn-template-engine/p-CrT83eO4.js +1 -0
  9. package/dist/bn-template-engine/p-D_DzKxRV.js +1 -0
  10. package/dist/bn-template-engine/p-Z2rUaSh_.js +1 -0
  11. package/dist/bn-template-engine/{p-12c8c444.entry.js → p-c41c0a1b.entry.js} +1 -1
  12. package/dist/bn-template-engine/p-yc69rwuH.js +1 -0
  13. package/dist/cjs/{bn-asset_28.cjs.entry.js → bn-annotation-layer_30.cjs.entry.js} +1200 -233
  14. package/dist/cjs/bn-grid.cjs.entry.js +4 -4
  15. package/dist/cjs/bn-image.cjs.entry.js +3 -3
  16. package/dist/cjs/bn-internationalization.cjs.entry.js +3 -3
  17. package/dist/cjs/bn-ruleset.cjs.entry.js +3 -3
  18. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  19. package/dist/cjs/bn-text.cjs.entry.js +10 -10
  20. package/dist/cjs/{diagnostics-DMmUPOsm.js → diagnostics-C4Ggts3w.js} +49 -1
  21. package/dist/cjs/loader.cjs.js +1 -1
  22. package/dist/cjs/{withBodyObserver-CrSp_FfF.js → withBodyObserver-BK4idxqG.js} +1 -1
  23. package/dist/cjs/{withHasError-DpogV-4f.js → withHasError-CqvcS23z.js} +513 -507
  24. package/dist/cjs/{withStyled-TQ67jCAV.js → withStyled-70D4Isgt.js} +3 -2
  25. package/dist/cjs/{sanitizeHtml-Cr0jVSJ_.js → withTranslation-C6Pye2CM.js} +98 -98
  26. package/dist/collection/collection-manifest.json +2 -0
  27. package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.css +24 -0
  28. package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +430 -0
  29. package/dist/collection/components/bn-annotation-layer/utils/marks.js +161 -0
  30. package/dist/collection/components/bn-annotation-layer/utils/matchPoint.js +25 -0
  31. package/dist/collection/components/bn-annotation-list/bn-annotation-list.css +46 -0
  32. package/dist/collection/components/bn-annotation-list/bn-annotation-list.js +112 -0
  33. package/dist/collection/components/bn-asset/bn-asset.js +1 -1
  34. package/dist/collection/components/bn-body/bn-body.js +1 -1
  35. package/dist/collection/components/bn-card/bn-card.js +1 -1
  36. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +1 -1
  37. package/dist/collection/components/bn-chart-bubble/utils/BubbleChart.js +29 -21
  38. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.js +1 -1
  39. package/dist/collection/components/bn-chart-bullet/utils/BulletChart.js +18 -9
  40. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +1 -1
  41. package/dist/collection/components/bn-chart-scatter/utils/ScatterChart.js +21 -13
  42. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +1 -1
  43. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +26 -9
  44. package/dist/collection/components/bn-chart-structure/utils/elements/Bar.js +5 -1
  45. package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +11 -0
  46. package/dist/collection/components/bn-chart-structure/utils/elements/Marker.js +5 -1
  47. package/dist/collection/components/bn-chart-structure/utils/elements/Needle.js +4 -1
  48. package/dist/collection/components/bn-chart-structure/utils/elements/StackedBar.js +6 -2
  49. package/dist/collection/components/bn-chart-time/bn-chart-time.js +1 -1
  50. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +28 -2
  51. package/dist/collection/components/bn-chart-time/utils/elements/Column.js +5 -1
  52. package/dist/collection/components/bn-chart-time/utils/elements/Label.js +14 -0
  53. package/dist/collection/components/bn-chart-time/utils/elements/LineSeries.js +12 -9
  54. package/dist/collection/components/bn-chart-time/utils/elements/Marker.js +5 -1
  55. package/dist/collection/components/bn-chart-time/utils/elements/Needle.js +4 -1
  56. package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +6 -2
  57. package/dist/collection/components/bn-component-style/bn-component-style.js +1 -1
  58. package/dist/collection/components/bn-context/bn-context.js +2 -2
  59. package/dist/collection/components/bn-dataset/bn-dataset.js +1 -1
  60. package/dist/collection/components/bn-datasource/bn-datasource.js +1 -1
  61. package/dist/collection/components/bn-footer/bn-footer.js +1 -1
  62. package/dist/collection/components/bn-grid/bn-grid.js +1 -1
  63. package/dist/collection/components/bn-image/bn-image.js +1 -1
  64. package/dist/collection/components/bn-internationalization/bn-internationalization.js +1 -1
  65. package/dist/collection/components/bn-layout-card/bn-layout-card.js +1 -1
  66. package/dist/collection/components/bn-layout-page/bn-layout-page.js +1 -1
  67. package/dist/collection/components/bn-message/bn-message.js +1 -1
  68. package/dist/collection/components/bn-page/bn-page.js +1 -1
  69. package/dist/collection/components/bn-ruleset/bn-ruleset.js +1 -1
  70. package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +1 -1
  71. package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +16 -3
  72. package/dist/collection/components/bn-table/bn-table.js +1 -1
  73. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +26 -1
  74. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +3 -1
  75. package/dist/collection/components/bn-text/bn-text.js +1 -1
  76. package/dist/collection/components/bn-title/bn-title-renderer/bn-title-renderer.js +1 -1
  77. package/dist/collection/components/bn-title/bn-title.js +1 -1
  78. package/dist/collection/stores/componentStyles.js +4 -0
  79. package/dist/collection/stores/createScopedStores.js +3 -1
  80. package/dist/collection/utils/annotations.js +66 -0
  81. package/dist/collection/utils/layoutState/dataPoint.js +59 -0
  82. package/dist/collection/utils/layoutState/geometry.js +46 -0
  83. package/dist/collection/utils/layoutState/index.js +1 -0
  84. package/dist/collection/utils/layoutState/svgChartElements.js +113 -11
  85. package/dist/collection/utils/withComponentStyle.js +2 -1
  86. package/dist/collection/utils/xy/pointKey.js +10 -0
  87. package/dist/components/bn-annotation-layer.d.ts +11 -0
  88. package/dist/components/bn-annotation-layer.js +1 -0
  89. package/dist/components/bn-annotation-list.d.ts +11 -0
  90. package/dist/components/bn-annotation-list.js +1 -0
  91. package/dist/components/bn-asset.js +1 -1
  92. package/dist/components/bn-body.js +1 -1
  93. package/dist/components/bn-card.js +1 -1
  94. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  95. package/dist/components/bn-chart-bubble.js +1 -1
  96. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  97. package/dist/components/bn-chart-bullet.js +1 -1
  98. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  99. package/dist/components/bn-chart-scatter.js +1 -1
  100. package/dist/components/bn-chart-structure-renderer.js +1 -1
  101. package/dist/components/bn-chart-structure.js +1 -1
  102. package/dist/components/bn-chart-time-renderer.js +1 -1
  103. package/dist/components/bn-chart-time.js +1 -1
  104. package/dist/components/bn-component-style.js +1 -1
  105. package/dist/components/bn-context.js +1 -1
  106. package/dist/components/bn-dataset.js +1 -1
  107. package/dist/components/bn-datasource.js +1 -1
  108. package/dist/components/bn-footer.js +1 -1
  109. package/dist/components/bn-grid.js +1 -1
  110. package/dist/components/bn-image.js +1 -1
  111. package/dist/components/bn-internationalization.js +1 -1
  112. package/dist/components/bn-layout-card.js +1 -1
  113. package/dist/components/bn-layout-page.js +1 -1
  114. package/dist/components/bn-message.js +1 -1
  115. package/dist/components/bn-page.js +1 -1
  116. package/dist/components/bn-ruleset.js +1 -1
  117. package/dist/components/bn-scaling-group.js +1 -1
  118. package/dist/components/bn-table-renderer.js +1 -1
  119. package/dist/components/bn-table.js +1 -1
  120. package/dist/components/bn-text.js +1 -1
  121. package/dist/components/bn-title-renderer.js +1 -1
  122. package/dist/components/bn-title.js +1 -1
  123. package/dist/components/bn-tree.js +1 -1
  124. package/dist/components/p-B1nL0yOa.js +1 -0
  125. package/dist/components/p-B7uwck1J.js +1 -0
  126. package/dist/components/{p-Dd6b8E_1.js → p-BDS_jiow.js} +1 -1
  127. package/dist/components/p-BIIDTtcR.js +1 -0
  128. package/dist/components/{p-DCja-Yov.js → p-BQMKgvEC.js} +1 -1
  129. package/dist/components/{p-DynTmVfI.js → p-BSV_vyqs.js} +1 -1
  130. package/dist/components/p-BVKLCz2k.js +1 -0
  131. package/dist/components/{p-BN7PtJVV.js → p-BWBHlztH.js} +1 -1
  132. package/dist/components/{p-BI5orga2.js → p-BXrPfAvP.js} +1 -1
  133. package/dist/components/p-Ba9PUiBp.js +1 -0
  134. package/dist/components/{p-iJCxRAmO.js → p-BpCL2bfw.js} +1 -1
  135. package/dist/components/p-BpsXOtoW.js +1 -0
  136. package/dist/components/{p-DcfgLtdU.js → p-Bs-YxJEt.js} +1 -1
  137. package/dist/components/p-CGI6XIaK.js +1 -0
  138. package/dist/components/{p-Igh8PJUo.js → p-CMM8vtHW.js} +1 -1
  139. package/dist/components/p-COqIkH1M.js +1 -0
  140. package/dist/components/p-CkW23yp2.js +1 -0
  141. package/dist/components/{p-BgWfMdDE.js → p-CtBM3KFY.js} +1 -1
  142. package/dist/components/p-CurWSJkH.js +1 -0
  143. package/dist/components/{p-BhOssNAI.js → p-CxPSvrcF.js} +1 -1
  144. package/dist/components/{p-B7GzUuM1.js → p-D5-dYgK_.js} +1 -1
  145. package/dist/components/p-DEHnizot.js +1 -0
  146. package/dist/components/p-DIyUaSBg.js +1 -0
  147. package/dist/components/p-DPLcGhVt.js +1 -0
  148. package/dist/components/p-DUHp_9X-.js +1 -0
  149. package/dist/components/p-DYG9FH_u.js +1 -0
  150. package/dist/components/{p-DrN6R99a.js → p-DdGnuNtc.js} +1 -1
  151. package/dist/components/{p-C3Lz_w4H.js → p-Dlb4ncGF.js} +1 -1
  152. package/dist/components/p-Dm55bMs2.js +1 -0
  153. package/dist/components/p-Dq1AzGKX.js +1 -0
  154. package/dist/components/{p-BZe4T2ta.js → p-DsOaqeTN.js} +1 -1
  155. package/dist/components/p-Ds_BSK8v.js +1 -0
  156. package/dist/components/{p--cxUP_so.js → p-LZ9lAY8T.js} +1 -1
  157. package/dist/components/{p-DJijh10F.js → p-U3zkcEJZ.js} +1 -1
  158. package/dist/components/p-WzaayhTX.js +1 -0
  159. package/dist/components/p-X9hpquOX.js +1 -0
  160. package/dist/components/p-ey23VlID.js +1 -0
  161. package/dist/components/p-jbp6YiHf.js +1 -0
  162. package/dist/components/p-oJjMz8JF.js +1 -0
  163. package/dist/components/{p-CwzAQJSz.js → p-xhiPDAZa.js} +1 -1
  164. package/dist/components/{p-BcQv74MZ.js → p-xpguaboj.js} +1 -1
  165. package/dist/esm/{bn-asset_28.entry.js → bn-annotation-layer_30.entry.js} +1080 -115
  166. package/dist/esm/bn-grid.entry.js +4 -4
  167. package/dist/esm/bn-image.entry.js +3 -3
  168. package/dist/esm/bn-internationalization.entry.js +3 -3
  169. package/dist/esm/bn-ruleset.entry.js +3 -3
  170. package/dist/esm/bn-template-engine.js +1 -1
  171. package/dist/esm/bn-text.entry.js +4 -4
  172. package/dist/esm/{diagnostics-BaXhpaAg.js → diagnostics-Cyqy1zDT.js} +48 -2
  173. package/dist/esm/loader.js +1 -1
  174. package/dist/esm/{withBodyObserver-1IBghfa8.js → withBodyObserver-JcRB9OPQ.js} +1 -1
  175. package/dist/esm/{withHasError-C8f_AGmT.js → withHasError-l3cMN-oP.js} +915 -909
  176. package/dist/esm/{withStyled-DS6G7yrL.js → withStyled-DGOiR00Q.js} +3 -2
  177. package/dist/esm/{sanitizeHtml-BpBu47OE.js → withTranslation-BpO8BC5B.js} +98 -98
  178. package/dist/schemas/theme.schema.json +21 -0
  179. package/dist/types/components/bn-annotation-layer/bn-annotation-layer.d.ts +81 -0
  180. package/dist/types/components/bn-annotation-layer/utils/marks.d.ts +69 -0
  181. package/dist/types/components/bn-annotation-layer/utils/matchPoint.d.ts +17 -0
  182. package/dist/types/components/bn-annotation-list/bn-annotation-list.d.ts +35 -0
  183. package/dist/types/components/bn-chart-bullet/utils/BulletChart.d.ts +2 -0
  184. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +2 -0
  185. package/dist/types/components/bn-chart-structure/utils/elements/Label.d.ts +5 -0
  186. package/dist/types/components/bn-chart-structure/utils/elements/Marker.d.ts +1 -0
  187. package/dist/types/components/bn-chart-structure/utils/elements/StackedBar.d.ts +2 -1
  188. package/dist/types/components/bn-chart-structure/utils/model/DataPoint.d.ts +3 -0
  189. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +2 -0
  190. package/dist/types/components/bn-chart-time/utils/elements/Label.d.ts +5 -0
  191. package/dist/types/components/bn-chart-time/utils/elements/Marker.d.ts +1 -0
  192. package/dist/types/components/bn-chart-time/utils/elements/StackedColumn.d.ts +2 -1
  193. package/dist/types/components/bn-chart-time/utils/model/DataPoint.d.ts +3 -0
  194. package/dist/types/components/bn-table/utils/elements/Cell.d.ts +2 -0
  195. package/dist/types/components/bn-table/utils/elements/TableRow.d.ts +3 -0
  196. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +4 -0
  197. package/dist/types/components.d.ts +174 -0
  198. package/dist/types/context/context-protocol.d.ts +2 -0
  199. package/dist/types/stores/componentStyles.d.ts +8 -0
  200. package/dist/types/stores/createScopedStores.d.ts +1 -0
  201. package/dist/types/utils/annotations.d.ts +45 -0
  202. package/dist/types/utils/layoutState/dataPoint.d.ts +13 -0
  203. package/dist/types/utils/layoutState/geometry.d.ts +12 -0
  204. package/dist/types/utils/layoutState/index.d.ts +1 -0
  205. package/dist/types/utils/layoutState/svgChartElements.d.ts +9 -6
  206. package/dist/types/utils/layoutState/types.d.ts +29 -0
  207. package/dist/types/utils/xy/pointKey.d.ts +9 -0
  208. package/package.json +2 -2
  209. package/readme.md +2 -0
  210. package/dist/bn-template-engine/p-2cbccbe7.entry.js +0 -1
  211. package/dist/bn-template-engine/p-Bo7_IopT.js +0 -1
  212. package/dist/bn-template-engine/p-ByoAF_Qe.js +0 -1
  213. package/dist/bn-template-engine/p-CsupHyLQ.js +0 -1
  214. package/dist/bn-template-engine/p-D0qTf1_a.js +0 -1
  215. package/dist/bn-template-engine/p-b09430b6.entry.js +0 -1
  216. package/dist/bn-template-engine/p-qcLonXCz.js +0 -1
  217. package/dist/components/p-BFUNrRAN.js +0 -1
  218. package/dist/components/p-BN8vBcMD.js +0 -1
  219. package/dist/components/p-BbS6qL8Z.js +0 -1
  220. package/dist/components/p-BvuJFY7b.js +0 -1
  221. package/dist/components/p-CD39zcHF.js +0 -1
  222. package/dist/components/p-CYurh604.js +0 -1
  223. package/dist/components/p-CfBqQljd.js +0 -1
  224. package/dist/components/p-Ci4wYt6s.js +0 -1
  225. package/dist/components/p-ClvHVwGH.js +0 -1
  226. package/dist/components/p-Co1dDaxy.js +0 -1
  227. package/dist/components/p-Cq5MNEMN.js +0 -1
  228. package/dist/components/p-CtiP8VJ_.js +0 -1
  229. package/dist/components/p-D413xjVu.js +0 -1
  230. package/dist/components/p-D4lSYFwX.js +0 -1
  231. package/dist/components/p-DZ3ub5DV.js +0 -1
  232. package/dist/components/p-Di57x1j-.js +0 -1
  233. package/dist/components/p-DtBFwIVs.js +0 -1
  234. package/dist/components/p-e6lZYVYf.js +0 -1
  235. package/dist/components/p-g4dh_F-M.js +0 -1
  236. package/dist/components/p-kGB4WKet.js +0 -1
  237. package/dist/components/p-pH6_06qq.js +0 -1
  238. package/dist/components/p-xJ1DeaDY.js +0 -1
@@ -2,490 +2,137 @@
2
2
 
3
3
  var index = require('./index-DGis1BzT.js');
4
4
 
5
- /** Concatenates name parts with spaces, skipping falsy segments. */
6
- /**
7
- * Safely invokes `fn` if it is a function; otherwise does nothing.
8
- *
9
- * Used by every mixin to call the original lifecycle hook (e.g. `connectedCallback`)
10
- * that may or may not exist on the component before the mixin wrapped it.
11
- *
12
- * @param fn - The value to invoke (only called if `typeof fn === 'function'`)
13
- * @param context - Optional `this` context to bind before invocation
14
- */
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- const runIfExisits = (fn, context = undefined) => {
17
- if (typeof fn === "function") {
18
- if (context) {
19
- fn.bind(context)();
20
- }
21
- else {
22
- fn();
23
- }
5
+ const appendToMap = (map, propName, value) => {
6
+ let refs = map.get(propName);
7
+ if (!refs) {
8
+ refs = [];
9
+ map.set(propName, refs);
10
+ }
11
+ if (!refs.some((ref) => ref.deref() === value)) {
12
+ refs.push(new WeakRef(value));
24
13
  }
25
14
  };
26
- /**
27
- * Generates a v4-style UUID using a combination of `Date.now()` and
28
- * `performance.now()` for entropy. Used by {@link withComponentStatus}
29
- * to assign a stable identifier to each component instance.
30
- */
31
- function generateUUID() {
32
- let d = new Date().getTime(), d2 = (performance && performance.now && performance.now() * 1000) || 0;
33
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
34
- let r = Math.random() * 16;
35
- if (d > 0) {
36
- r = ((d + r) % 16) | 0;
37
- d = Math.floor(d / 16);
38
- }
39
- else {
40
- r = ((d2 + r) % 16) | 0;
41
- d2 = Math.floor(d2 / 16);
15
+ const debounce = (fn, ms) => {
16
+ let timeoutId;
17
+ return (...args) => {
18
+ if (timeoutId) {
19
+ clearTimeout(timeoutId);
42
20
  }
43
- return (c === "x" ? r : (r & 0x7) | 0x8).toString(16);
44
- });
45
- }
21
+ timeoutId = setTimeout(() => {
22
+ timeoutId = 0;
23
+ fn(...args);
24
+ }, ms);
25
+ };
26
+ };
27
+
46
28
  /**
47
- * Creates a reactive reference -- a lightweight value holder that fires an
48
- * `onChange` callback whenever the stored value changes (by reference equality).
29
+ * Check if a possible element isConnected.
30
+ * The property might not be there, so we check for it.
49
31
  *
50
- * Provides `get`, `set`, `modify` (read-modify-write), and `getAndSet` (swap)
51
- * accessors. Used by {@link withHasError} to keep the host element's `has-error`
52
- * attribute in sync with the internal error list.
32
+ * We want it to return true if isConnected is not a property,
33
+ * otherwise we would remove these elements and would not update.
53
34
  *
54
- * @param value - The initial value
55
- * @param onChange - Callback fired after each change with the new value
35
+ * Better leak in Edge than to be useless.
56
36
  */
57
- const ref = (value, onChange) => {
58
- let current = value;
59
- const get = () => current;
60
- const set = (value) => {
61
- const old = current;
62
- current = value;
63
- if (old !== value)
64
- onChange(current);
65
- };
66
- const setAndGet = (value) => {
67
- set(value);
68
- };
69
- const getAndSet = (value) => {
70
- const old = get();
71
- set(value);
72
- return old;
73
- };
74
- const modify = (handler) => {
75
- set(handler(get()));
76
- };
37
+ const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
38
+ const cleanupElements = debounce((map) => {
39
+ for (let key of map.keys()) {
40
+ const refs = map.get(key).filter((ref) => {
41
+ const elm = ref.deref();
42
+ return elm && isConnected(elm);
43
+ });
44
+ map.set(key, refs);
45
+ }
46
+ }, 2_000);
47
+ const core = index.StencilCore;
48
+ const forceUpdate = core.forceUpdate;
49
+ const getRenderingRef = core.getRenderingRef;
50
+ const stencilSubscription = () => {
51
+ if (typeof getRenderingRef !== 'function' || typeof forceUpdate !== 'function') {
52
+ // If we are not in a stencil project, we do nothing.
53
+ // This function is not really exported by @stencil/core.
54
+ return {};
55
+ }
56
+ const ensureForceUpdate = forceUpdate;
57
+ const ensureGetRenderingRef = getRenderingRef;
58
+ const elmsToUpdate = new Map();
77
59
  return {
78
- get,
79
- set,
80
- setAndGet,
81
- getAndSet,
82
- modify,
60
+ dispose: () => elmsToUpdate.clear(),
61
+ get: (propName) => {
62
+ const elm = ensureGetRenderingRef();
63
+ if (elm) {
64
+ appendToMap(elmsToUpdate, propName, elm);
65
+ }
66
+ },
67
+ set: (propName) => {
68
+ const refs = elmsToUpdate.get(propName);
69
+ if (refs) {
70
+ const nextRefs = refs.filter((ref) => {
71
+ const elm = ref.deref();
72
+ if (!elm)
73
+ return false;
74
+ return ensureForceUpdate(elm);
75
+ });
76
+ elmsToUpdate.set(propName, nextRefs);
77
+ }
78
+ cleanupElements(elmsToUpdate);
79
+ },
80
+ reset: () => {
81
+ elmsToUpdate.forEach((refs) => {
82
+ refs.forEach((ref) => {
83
+ const elm = ref.deref();
84
+ if (elm)
85
+ ensureForceUpdate(elm);
86
+ });
87
+ });
88
+ cleanupElements(elmsToUpdate);
89
+ },
83
90
  };
84
91
  };
85
92
 
86
- /** Lifecycle state of a tracked component instance. */
87
- var ComponentStatus;
88
- (function (ComponentStatus) {
89
- ComponentStatus[ComponentStatus["RUNNING"] = 0] = "RUNNING";
90
- ComponentStatus[ComponentStatus["SUCCESSFUL"] = 1] = "SUCCESSFUL";
91
- ComponentStatus[ComponentStatus["ERROR"] = 2] = "ERROR";
92
- })(ComponentStatus || (ComponentStatus = {}));
93
- /**
94
- * Singleton registry that tracks the render status of all bn-* component instances.
95
- *
96
- * Each component registers itself via {@link withComponentStatus} and reports
97
- * `RUNNING` / `SUCCESSFUL` / `ERROR` transitions. After 500 ms of inactivity
98
- * (no status updates), the aggregate result is written to
99
- * `window.componentRegisterIsRenderedResult` as a boolean, and the failed
100
- * components to `window.componentRegisterFailures`. External tools
101
- * (e.g. headless screenshot renderers) poll these values to detect when
102
- * the entire page has finished rendering.
103
- *
104
- * A reader sees one of three states: the flag is `true` (all rendered), the
105
- * failures list is not empty (settled, but a component failed), or neither
106
- * (still working).
107
- *
108
- * The 500 ms debounce prevents premature "rendered" signals during rapid
109
- * successive re-renders.
110
- *
111
- * Status counts are maintained incrementally - `updateStatus` adjusts running
112
- * counters instead of iterating all entries, making it O(1) per update.
113
- */
114
- var ComponentRegister;
115
- (function (ComponentRegister) {
116
- let currentTimeOutId = undefined;
117
- const componentRegister = new Map();
118
- const failures = new Map();
119
- const statusCounts = { running: 0, successful: 0, error: 0 };
120
- const countKey = (status) => {
121
- switch (status) {
122
- case ComponentStatus.RUNNING:
123
- return "running";
124
- case ComponentStatus.SUCCESSFUL:
125
- return "successful";
126
- default:
127
- return "error";
93
+ const unwrap = (val) => (typeof val === 'function' ? val() : val);
94
+ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
95
+ const resolveDefaultState = () => (unwrap(defaultState) ?? {});
96
+ const initialState = resolveDefaultState();
97
+ let states = new Map(Object.entries(initialState));
98
+ const proxyAvailable = typeof Proxy !== 'undefined';
99
+ const plainState = proxyAvailable ? null : {};
100
+ const handlers = {
101
+ dispose: [],
102
+ get: [],
103
+ set: [],
104
+ reset: [],
105
+ };
106
+ // Track onChange listeners to enable removeListener functionality
107
+ const changeListeners = new Map();
108
+ const reset = () => {
109
+ // When resetting the state, the default state may be a function - unwrap it to invoke it.
110
+ // otherwise, the state won't be properly reset
111
+ states = new Map(Object.entries(resolveDefaultState()));
112
+ if (!proxyAvailable) {
113
+ syncPlainStateKeys();
128
114
  }
115
+ handlers.reset.forEach((cb) => cb());
129
116
  };
130
- const publish = () => {
131
- // @ts-ignore
132
- window.componentRegisterFailures = ComponentRegister.componentRegisterFailures();
133
- // @ts-ignore
134
- window.componentRegisterIsRenderedResult = ComponentRegister.componentRegisterIsRendered();
135
- // @ts-ignore
136
- // eslint-disable-next-line no-console
137
- console.log("componentRegisterIsRendered:", window.componentRegisterIsRenderedResult);
117
+ const dispose = () => {
118
+ // Call first dispose as resetting the state would
119
+ // cause less updates ;)
120
+ handlers.dispose.forEach((cb) => cb());
121
+ reset();
138
122
  };
139
- /** Restarts the 500 ms quiet period that ends with the published result. */
140
- const schedule = () => {
141
- if (currentTimeOutId) {
142
- window.clearTimeout(currentTimeOutId);
143
- }
144
- // window.setTimeout, not the bare global: in spec tests this is the timer the test window clears when a test ends
145
- currentTimeOutId = window.setTimeout(() => {
146
- const fonts = document.fonts;
147
- if ((fonts === null || fonts === void 0 ? void 0 : fonts.status) === "loading") {
148
- // text is measured again once the fonts are there: wait for them, then for a new quiet period
149
- fonts.ready.then(schedule);
150
- return;
123
+ const get = (propName) => {
124
+ handlers.get.forEach((cb) => cb(propName));
125
+ return states.get(propName);
126
+ };
127
+ const set = (propName, value) => {
128
+ const oldValue = states.get(propName);
129
+ if (shouldUpdate(value, oldValue, propName)) {
130
+ states.set(propName, value);
131
+ if (!proxyAvailable) {
132
+ ensurePlainProperty(propName);
151
133
  }
152
- publish();
153
- }, 500);
154
- };
155
- /**
156
- * Records a status change for the component identified by `uuid` and
157
- * resets the 500 ms debounce timer. When the timer fires, the aggregate
158
- * "all rendered" boolean is published to `window.componentRegisterIsRenderedResult`.
159
- * `failure` describes an `ERROR` status.
160
- */
161
- ComponentRegister.updateStatus = (uuid, status, failure) => {
162
- const prev = componentRegister.get(uuid);
163
- if (prev !== undefined) {
164
- statusCounts[countKey(prev)]--;
165
- }
166
- statusCounts[countKey(status)]++;
167
- componentRegister.set(uuid, status);
168
- if (status === ComponentStatus.ERROR && failure) {
169
- failures.set(uuid, failure);
170
- }
171
- else {
172
- failures.delete(uuid);
173
- }
174
- schedule();
175
- };
176
- /** Forgets a component that left the document. */
177
- ComponentRegister.remove = (uuid) => {
178
- const prev = componentRegister.get(uuid);
179
- if (prev === undefined) {
180
- return;
181
- }
182
- statusCounts[countKey(prev)]--;
183
- componentRegister.delete(uuid);
184
- failures.delete(uuid);
185
- schedule();
186
- };
187
- /** Returns `true` when no component is in `RUNNING` or `ERROR` state. */
188
- ComponentRegister.componentRegisterIsRendered = () => {
189
- return statusCounts.running === 0 && statusCounts.error === 0;
190
- };
191
- /** The failed components. Empty while a component is still running: only a settled page has a final list. */
192
- ComponentRegister.componentRegisterFailures = () => {
193
- return statusCounts.running === 0 ? [...failures.values()] : [];
194
- };
195
- /** Returns a summary count of components in each status category. */
196
- ComponentRegister.componentRegisterStatus = () => {
197
- return Object.assign({}, statusCounts);
198
- };
199
- })(ComponentRegister || (ComponentRegister = {}));
200
-
201
- // Stencil calls these once per instance, so a failure in them is never repaired by a later render.
202
- const LOAD_HOOKS = ["componentWillLoad", "componentDidLoad"];
203
- // The hooks of every render cycle. componentWillUpdate is the first one of an update.
204
- const CYCLE_HOOKS = [
205
- "componentWillUpdate",
206
- "componentWillRender",
207
- "render",
208
- "componentDidRender",
209
- "componentDidUpdate",
210
- ];
211
- // The hooks a cycle starts with: the component is rendering from here on.
212
- const START_HOOKS = ["componentWillLoad", "componentWillUpdate", "componentWillRender"];
213
- const describeFailure = (element, message) => {
214
- var _a, _b, _c, _d;
215
- return ({
216
- tag: (_a = element === null || element === void 0 ? void 0 : element.localName) !== null && _a !== void 0 ? _a : "",
217
- // an inner renderer has no id of its own: name the component it is drawn for
218
- id: (element === null || element === void 0 ? void 0 : element.id) || ((_d = (_c = (_b = element === null || element === void 0 ? void 0 : element.getRootNode) === null || _b === void 0 ? void 0 : _b.call(element)) === null || _c === void 0 ? void 0 : _c.host) === null || _d === void 0 ? void 0 : _d.id) || "",
219
- message,
220
- });
221
- };
222
- /**
223
- * Mixin that tracks a component's render lifecycle in the global {@link ComponentRegister}.
224
- *
225
- * Assigns a stable UUID to the component instance and reports status transitions:
226
- * - `RUNNING` from `connectedCallback` (only before the first render: a re-attach does not render again)
227
- * or from the first hook of a render cycle, until `componentDidRender`
228
- * - `ERROR` when `render`, a lifecycle hook or `connectedCallback` threw. Stencil catches such
229
- * an exception and goes on, so without this the component would count as rendered.
230
- * - `SUCCESSFUL` otherwise
231
- *
232
- * A component that leaves the document is removed from the register.
233
- *
234
- * Returns a hold function: the component stays `RUNNING` until the promise
235
- * passed to it has settled, whatever the outcome.
236
- *
237
- * External tools (e.g. screenshot/PDF renderers) poll
238
- * `window.componentRegisterIsRenderedResult` to determine when all components
239
- * have finished rendering.
240
- *
241
- * @param component - The Stencil component instance
242
- */
243
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
244
- const withComponentStatus = (component) => {
245
- const uuid = generateUUID();
246
- let pending = 0;
247
- let rendered = false;
248
- let rendering = false;
249
- let loadFailure;
250
- let cycleFailure;
251
- let connectFailure;
252
- const publish = () => {
253
- var _a;
254
- // read here, not tracked in connectedCallback: not every build calls that wrapper
255
- const element = index.getElement(component);
256
- if (element && !element.isConnected)
257
- return;
258
- const message = (_a = connectFailure !== null && connectFailure !== void 0 ? connectFailure : loadFailure) !== null && _a !== void 0 ? _a : cycleFailure;
259
- if (rendering || pending > 0) {
260
- ComponentRegister.updateStatus(uuid, ComponentStatus.RUNNING);
261
- }
262
- else if (message !== undefined) {
263
- ComponentRegister.updateStatus(uuid, ComponentStatus.ERROR, describeFailure(element, message));
264
- }
265
- else {
266
- ComponentRegister.updateStatus(uuid, ComponentStatus.SUCCESSFUL);
267
- }
268
- };
269
- const fail = (hook, e) => {
270
- const message = e instanceof Error ? e.message : String(e);
271
- if (LOAD_HOOKS.includes(hook)) {
272
- loadFailure = message;
273
- }
274
- else {
275
- cycleFailure = message;
276
- }
277
- publish();
278
- };
279
- const connectedCallback = component["connectedCallback"];
280
- let connect = () => {
281
- if (!rendered)
282
- rendering = true;
283
- publish();
284
- runIfExisits(connectedCallback, component);
285
- };
286
- // The mixins that are applied after this one wrap connectedCallback again, outside of the wrapper above.
287
- // The accessor keeps a guard around whatever they assign, so a throw in any of them is seen here too.
288
- const guarded = (fn) => () => {
289
- connectFailure = undefined;
290
- try {
291
- fn();
292
- }
293
- catch (e) {
294
- connectFailure = e instanceof Error ? e.message : String(e);
295
- publish();
296
- // Stencil logs it and goes on with the first render
297
- throw e;
298
- }
299
- };
300
- Object.defineProperty(component, "connectedCallback", {
301
- configurable: true,
302
- enumerable: true,
303
- get: () => guarded(connect),
304
- set: (fn) => {
305
- connect = fn;
306
- },
307
- });
308
- const disconnectedCallback = component["disconnectedCallback"];
309
- component["disconnectedCallback"] = () => {
310
- ComponentRegister.remove(uuid);
311
- runIfExisits(disconnectedCallback, component);
312
- };
313
- for (const hook of [...LOAD_HOOKS, ...CYCLE_HOOKS]) {
314
- const original = component[hook];
315
- component[hook] = (...args) => {
316
- if (hook === "componentWillUpdate")
317
- cycleFailure = undefined;
318
- if (START_HOOKS.includes(hook)) {
319
- rendering = true;
320
- publish();
321
- }
322
- try {
323
- const result = typeof original === "function" ? original.apply(component, args) : undefined;
324
- if (typeof (result === null || result === void 0 ? void 0 : result.then) === "function") {
325
- // an async hook: Stencil waits for the returned promise, so the failure must stay in it
326
- return result.then((value) => value, (e) => {
327
- fail(hook, e);
328
- throw e;
329
- });
330
- }
331
- return result;
332
- }
333
- catch (e) {
334
- fail(hook, e);
335
- // Stencil logs it and goes on with the next hook
336
- throw e;
337
- }
338
- finally {
339
- if (hook === "componentDidRender") {
340
- rendered = true;
341
- rendering = false;
342
- publish();
343
- }
344
- }
345
- };
346
- }
347
- return (work) => {
348
- pending++;
349
- publish();
350
- const done = () => {
351
- pending--;
352
- publish();
353
- };
354
- work.then(done, done);
355
- };
356
- };
357
-
358
- const appendToMap = (map, propName, value) => {
359
- let refs = map.get(propName);
360
- if (!refs) {
361
- refs = [];
362
- map.set(propName, refs);
363
- }
364
- if (!refs.some((ref) => ref.deref() === value)) {
365
- refs.push(new WeakRef(value));
366
- }
367
- };
368
- const debounce = (fn, ms) => {
369
- let timeoutId;
370
- return (...args) => {
371
- if (timeoutId) {
372
- clearTimeout(timeoutId);
373
- }
374
- timeoutId = setTimeout(() => {
375
- timeoutId = 0;
376
- fn(...args);
377
- }, ms);
378
- };
379
- };
380
-
381
- /**
382
- * Check if a possible element isConnected.
383
- * The property might not be there, so we check for it.
384
- *
385
- * We want it to return true if isConnected is not a property,
386
- * otherwise we would remove these elements and would not update.
387
- *
388
- * Better leak in Edge than to be useless.
389
- */
390
- const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
391
- const cleanupElements = debounce((map) => {
392
- for (let key of map.keys()) {
393
- const refs = map.get(key).filter((ref) => {
394
- const elm = ref.deref();
395
- return elm && isConnected(elm);
396
- });
397
- map.set(key, refs);
398
- }
399
- }, 2_000);
400
- const core = index.StencilCore;
401
- const forceUpdate = core.forceUpdate;
402
- const getRenderingRef = core.getRenderingRef;
403
- const stencilSubscription = () => {
404
- if (typeof getRenderingRef !== 'function' || typeof forceUpdate !== 'function') {
405
- // If we are not in a stencil project, we do nothing.
406
- // This function is not really exported by @stencil/core.
407
- return {};
408
- }
409
- const ensureForceUpdate = forceUpdate;
410
- const ensureGetRenderingRef = getRenderingRef;
411
- const elmsToUpdate = new Map();
412
- return {
413
- dispose: () => elmsToUpdate.clear(),
414
- get: (propName) => {
415
- const elm = ensureGetRenderingRef();
416
- if (elm) {
417
- appendToMap(elmsToUpdate, propName, elm);
418
- }
419
- },
420
- set: (propName) => {
421
- const refs = elmsToUpdate.get(propName);
422
- if (refs) {
423
- const nextRefs = refs.filter((ref) => {
424
- const elm = ref.deref();
425
- if (!elm)
426
- return false;
427
- return ensureForceUpdate(elm);
428
- });
429
- elmsToUpdate.set(propName, nextRefs);
430
- }
431
- cleanupElements(elmsToUpdate);
432
- },
433
- reset: () => {
434
- elmsToUpdate.forEach((refs) => {
435
- refs.forEach((ref) => {
436
- const elm = ref.deref();
437
- if (elm)
438
- ensureForceUpdate(elm);
439
- });
440
- });
441
- cleanupElements(elmsToUpdate);
442
- },
443
- };
444
- };
445
-
446
- const unwrap = (val) => (typeof val === 'function' ? val() : val);
447
- const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
448
- const resolveDefaultState = () => (unwrap(defaultState) ?? {});
449
- const initialState = resolveDefaultState();
450
- let states = new Map(Object.entries(initialState));
451
- const proxyAvailable = typeof Proxy !== 'undefined';
452
- const plainState = proxyAvailable ? null : {};
453
- const handlers = {
454
- dispose: [],
455
- get: [],
456
- set: [],
457
- reset: [],
458
- };
459
- // Track onChange listeners to enable removeListener functionality
460
- const changeListeners = new Map();
461
- const reset = () => {
462
- // When resetting the state, the default state may be a function - unwrap it to invoke it.
463
- // otherwise, the state won't be properly reset
464
- states = new Map(Object.entries(resolveDefaultState()));
465
- if (!proxyAvailable) {
466
- syncPlainStateKeys();
467
- }
468
- handlers.reset.forEach((cb) => cb());
469
- };
470
- const dispose = () => {
471
- // Call first dispose as resetting the state would
472
- // cause less updates ;)
473
- handlers.dispose.forEach((cb) => cb());
474
- reset();
475
- };
476
- const get = (propName) => {
477
- handlers.get.forEach((cb) => cb(propName));
478
- return states.get(propName);
479
- };
480
- const set = (propName, value) => {
481
- const oldValue = states.get(propName);
482
- if (shouldUpdate(value, oldValue, propName)) {
483
- states.set(propName, value);
484
- if (!proxyAvailable) {
485
- ensurePlainProperty(propName);
486
- }
487
- handlers.set.forEach((cb) => cb(propName, value, oldValue));
488
- }
134
+ handlers.set.forEach((cb) => cb(propName, value, oldValue));
135
+ }
489
136
  };
490
137
  const state = (proxyAvailable
491
138
  ? new Proxy(initialState, {
@@ -884,6 +531,10 @@ const SYSTEM_STYLE_DEFAULTS = {
884
531
  borderWidth: 1,
885
532
  cellPadding: 4,
886
533
  },
534
+ "bn-annotation": {
535
+ color: "#0070c0",
536
+ colors: { negative: "#ff0000", positive: "#008f96" },
537
+ },
887
538
  };
888
539
  /** `bn-text` keys. All are optional, so the defaults do not list them. */
889
540
  const TEXT_STYLE_KEYS = ["fontFamily", "fontSizePx", "fontColor", "fontBackgroundColor", "leading"];
@@ -9814,7 +9465,7 @@ function createScopedDb() {
9814
9465
  }
9815
9466
 
9816
9467
  /**
9817
- * Factory that creates a fresh set of all 9 `@stencil/store` instances.
9468
+ * Factory that creates a fresh set of all 8 `@stencil/store` instances.
9818
9469
  *
9819
9470
  * Called once per `<bn-context>` element so that each context owns isolated
9820
9471
  * reactive state. The returned object satisfies the {@link ScopedStores} interface.
@@ -9834,6 +9485,7 @@ function createScopedStores() {
9834
9485
  const ruleSets = createStore({
9835
9486
  _system: SYSTEM_RULESET_DEFAULTS,
9836
9487
  });
9488
+ const annotationsUnplaced = createStore({});
9837
9489
  return {
9838
9490
  db,
9839
9491
  datasetsMeta,
@@ -9843,6 +9495,7 @@ function createScopedStores() {
9843
9495
  context,
9844
9496
  scalingGroups,
9845
9497
  ruleSets,
9498
+ annotationsUnplaced,
9846
9499
  };
9847
9500
  }
9848
9501
 
@@ -9879,56 +9532,409 @@ function getOrCreateStores(contextElement) {
9879
9532
  }
9880
9533
  const storesCache = new WeakMap();
9881
9534
  /**
9882
- * Walks up the DOM tree (crossing shadow boundaries) to find the nearest
9883
- * `<bn-context>` ancestor element.
9535
+ * Walks up the DOM tree (crossing shadow boundaries) to find the nearest
9536
+ * `<bn-context>` ancestor element.
9537
+ */
9538
+ function findContextElement(element) {
9539
+ var _a;
9540
+ let current = element.parentNode;
9541
+ while (current) {
9542
+ if (current instanceof HTMLElement && ((_a = current.nodeName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "bn-context") {
9543
+ return current;
9544
+ }
9545
+ if (current.parentNode) {
9546
+ current = current.parentNode;
9547
+ }
9548
+ else if (current instanceof ShadowRoot) {
9549
+ current = current.host;
9550
+ }
9551
+ else {
9552
+ break;
9553
+ }
9554
+ }
9555
+ return undefined;
9556
+ }
9557
+ /**
9558
+ * Resolves scoped stores from the nearest `<bn-context>` ancestor.
9559
+ *
9560
+ * Walks the DOM tree to find the nearest `<bn-context>` element, then
9561
+ * returns (or lazily creates) the stores for it. This works regardless
9562
+ * of Stencil component initialization order because it only depends on
9563
+ * the native DOM tree being in place.
9564
+ *
9565
+ * Results are cached per element in a WeakMap.
9566
+ *
9567
+ * @throws Error if no `<bn-context>` ancestor is found in the DOM
9568
+ */
9569
+ function getStores(element) {
9570
+ const cached = storesCache.get(element);
9571
+ if (cached)
9572
+ return cached;
9573
+ const contextEl = findContextElement(element);
9574
+ if (!contextEl) {
9575
+ throw new Error(`[bn] <${element.localName}> must be inside a <bn-context>. No ancestor <bn-context> found.`);
9576
+ }
9577
+ const stores = getOrCreateStores(contextEl);
9578
+ storesCache.set(element, stores);
9579
+ return stores;
9580
+ }
9581
+ /** Removes the cached stores entry for an element (call in `disconnectedCallback`). */
9582
+ function clearStoresCache(element) {
9583
+ storesCache.delete(element);
9584
+ }
9585
+
9586
+ /** Lifecycle state of a tracked component instance. */
9587
+ var ComponentStatus;
9588
+ (function (ComponentStatus) {
9589
+ ComponentStatus[ComponentStatus["RUNNING"] = 0] = "RUNNING";
9590
+ ComponentStatus[ComponentStatus["SUCCESSFUL"] = 1] = "SUCCESSFUL";
9591
+ ComponentStatus[ComponentStatus["ERROR"] = 2] = "ERROR";
9592
+ })(ComponentStatus || (ComponentStatus = {}));
9593
+ /**
9594
+ * Singleton registry that tracks the render status of all bn-* component instances.
9595
+ *
9596
+ * Each component registers itself via {@link withComponentStatus} and reports
9597
+ * `RUNNING` / `SUCCESSFUL` / `ERROR` transitions. After 500 ms of inactivity
9598
+ * (no status updates), the aggregate result is written to
9599
+ * `window.componentRegisterIsRenderedResult` as a boolean, and the failed
9600
+ * components to `window.componentRegisterFailures`. External tools
9601
+ * (e.g. headless screenshot renderers) poll these values to detect when
9602
+ * the entire page has finished rendering.
9603
+ *
9604
+ * A reader sees one of three states: the flag is `true` (all rendered), the
9605
+ * failures list is not empty (settled, but a component failed), or neither
9606
+ * (still working).
9607
+ *
9608
+ * The 500 ms debounce prevents premature "rendered" signals during rapid
9609
+ * successive re-renders.
9610
+ *
9611
+ * Status counts are maintained incrementally - `updateStatus` adjusts running
9612
+ * counters instead of iterating all entries, making it O(1) per update.
9613
+ */
9614
+ exports.ComponentRegister = void 0;
9615
+ (function (ComponentRegister) {
9616
+ let currentTimeOutId = undefined;
9617
+ const componentRegister = new Map();
9618
+ const failures = new Map();
9619
+ const statusCounts = { running: 0, successful: 0, error: 0 };
9620
+ const countKey = (status) => {
9621
+ switch (status) {
9622
+ case ComponentStatus.RUNNING:
9623
+ return "running";
9624
+ case ComponentStatus.SUCCESSFUL:
9625
+ return "successful";
9626
+ default:
9627
+ return "error";
9628
+ }
9629
+ };
9630
+ const publish = () => {
9631
+ // @ts-ignore
9632
+ window.componentRegisterFailures = ComponentRegister.componentRegisterFailures();
9633
+ // @ts-ignore
9634
+ window.componentRegisterIsRenderedResult = ComponentRegister.componentRegisterIsRendered();
9635
+ // @ts-ignore
9636
+ // eslint-disable-next-line no-console
9637
+ console.log("componentRegisterIsRendered:", window.componentRegisterIsRenderedResult);
9638
+ };
9639
+ /** Restarts the 500 ms quiet period that ends with the published result. */
9640
+ const schedule = () => {
9641
+ if (currentTimeOutId) {
9642
+ window.clearTimeout(currentTimeOutId);
9643
+ }
9644
+ // window.setTimeout, not the bare global: in spec tests this is the timer the test window clears when a test ends
9645
+ currentTimeOutId = window.setTimeout(() => {
9646
+ const fonts = document.fonts;
9647
+ if ((fonts === null || fonts === void 0 ? void 0 : fonts.status) === "loading") {
9648
+ // text is measured again once the fonts are there: wait for them, then for a new quiet period
9649
+ fonts.ready.then(schedule);
9650
+ return;
9651
+ }
9652
+ publish();
9653
+ }, 500);
9654
+ };
9655
+ /**
9656
+ * Records a status change for the component identified by `uuid` and
9657
+ * resets the 500 ms debounce timer. When the timer fires, the aggregate
9658
+ * "all rendered" boolean is published to `window.componentRegisterIsRenderedResult`.
9659
+ * `failure` describes an `ERROR` status.
9660
+ */
9661
+ ComponentRegister.updateStatus = (uuid, status, failure) => {
9662
+ const prev = componentRegister.get(uuid);
9663
+ if (prev !== undefined) {
9664
+ statusCounts[countKey(prev)]--;
9665
+ }
9666
+ statusCounts[countKey(status)]++;
9667
+ componentRegister.set(uuid, status);
9668
+ if (status === ComponentStatus.ERROR && failure) {
9669
+ failures.set(uuid, failure);
9670
+ }
9671
+ else {
9672
+ failures.delete(uuid);
9673
+ }
9674
+ schedule();
9675
+ };
9676
+ /** Forgets a component that left the document. */
9677
+ ComponentRegister.remove = (uuid) => {
9678
+ const prev = componentRegister.get(uuid);
9679
+ if (prev === undefined) {
9680
+ return;
9681
+ }
9682
+ statusCounts[countKey(prev)]--;
9683
+ componentRegister.delete(uuid);
9684
+ failures.delete(uuid);
9685
+ schedule();
9686
+ };
9687
+ /** Returns `true` when no component is in `RUNNING` or `ERROR` state. */
9688
+ ComponentRegister.componentRegisterIsRendered = () => {
9689
+ return statusCounts.running === 0 && statusCounts.error === 0;
9690
+ };
9691
+ /** The failed components. Empty while a component is still running: only a settled page has a final list. */
9692
+ ComponentRegister.componentRegisterFailures = () => {
9693
+ return statusCounts.running === 0 ? [...failures.values()] : [];
9694
+ };
9695
+ /** Returns a summary count of components in each status category. */
9696
+ ComponentRegister.componentRegisterStatus = () => {
9697
+ return Object.assign({}, statusCounts);
9698
+ };
9699
+ })(exports.ComponentRegister || (exports.ComponentRegister = {}));
9700
+
9701
+ /** Concatenates name parts with spaces, skipping falsy segments. */
9702
+ /**
9703
+ * Safely invokes `fn` if it is a function; otherwise does nothing.
9704
+ *
9705
+ * Used by every mixin to call the original lifecycle hook (e.g. `connectedCallback`)
9706
+ * that may or may not exist on the component before the mixin wrapped it.
9707
+ *
9708
+ * @param fn - The value to invoke (only called if `typeof fn === 'function'`)
9709
+ * @param context - Optional `this` context to bind before invocation
9884
9710
  */
9885
- function findContextElement(element) {
9886
- var _a;
9887
- let current = element.parentNode;
9888
- while (current) {
9889
- if (current instanceof HTMLElement && ((_a = current.nodeName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "bn-context") {
9890
- return current;
9711
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9712
+ const runIfExisits = (fn, context = undefined) => {
9713
+ if (typeof fn === "function") {
9714
+ if (context) {
9715
+ fn.bind(context)();
9891
9716
  }
9892
- if (current.parentNode) {
9893
- current = current.parentNode;
9717
+ else {
9718
+ fn();
9894
9719
  }
9895
- else if (current instanceof ShadowRoot) {
9896
- current = current.host;
9720
+ }
9721
+ };
9722
+ /**
9723
+ * Generates a v4-style UUID using a combination of `Date.now()` and
9724
+ * `performance.now()` for entropy. Used by {@link withComponentStatus}
9725
+ * to assign a stable identifier to each component instance.
9726
+ */
9727
+ function generateUUID() {
9728
+ let d = new Date().getTime(), d2 = (performance && performance.now && performance.now() * 1000) || 0;
9729
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
9730
+ let r = Math.random() * 16;
9731
+ if (d > 0) {
9732
+ r = ((d + r) % 16) | 0;
9733
+ d = Math.floor(d / 16);
9897
9734
  }
9898
9735
  else {
9899
- break;
9736
+ r = ((d2 + r) % 16) | 0;
9737
+ d2 = Math.floor(d2 / 16);
9900
9738
  }
9901
- }
9902
- return undefined;
9739
+ return (c === "x" ? r : (r & 0x7) | 0x8).toString(16);
9740
+ });
9903
9741
  }
9904
9742
  /**
9905
- * Resolves scoped stores from the nearest `<bn-context>` ancestor.
9743
+ * Creates a reactive reference -- a lightweight value holder that fires an
9744
+ * `onChange` callback whenever the stored value changes (by reference equality).
9906
9745
  *
9907
- * Walks the DOM tree to find the nearest `<bn-context>` element, then
9908
- * returns (or lazily creates) the stores for it. This works regardless
9909
- * of Stencil component initialization order because it only depends on
9910
- * the native DOM tree being in place.
9746
+ * Provides `get`, `set`, `modify` (read-modify-write), and `getAndSet` (swap)
9747
+ * accessors. Used by {@link withHasError} to keep the host element's `has-error`
9748
+ * attribute in sync with the internal error list.
9911
9749
  *
9912
- * Results are cached per element in a WeakMap.
9750
+ * @param value - The initial value
9751
+ * @param onChange - Callback fired after each change with the new value
9752
+ */
9753
+ const ref = (value, onChange) => {
9754
+ let current = value;
9755
+ const get = () => current;
9756
+ const set = (value) => {
9757
+ const old = current;
9758
+ current = value;
9759
+ if (old !== value)
9760
+ onChange(current);
9761
+ };
9762
+ const setAndGet = (value) => {
9763
+ set(value);
9764
+ };
9765
+ const getAndSet = (value) => {
9766
+ const old = get();
9767
+ set(value);
9768
+ return old;
9769
+ };
9770
+ const modify = (handler) => {
9771
+ set(handler(get()));
9772
+ };
9773
+ return {
9774
+ get,
9775
+ set,
9776
+ setAndGet,
9777
+ getAndSet,
9778
+ modify,
9779
+ };
9780
+ };
9781
+
9782
+ // Stencil calls these once per instance, so a failure in them is never repaired by a later render.
9783
+ const LOAD_HOOKS = ["componentWillLoad", "componentDidLoad"];
9784
+ // The hooks of every render cycle. componentWillUpdate is the first one of an update.
9785
+ const CYCLE_HOOKS = [
9786
+ "componentWillUpdate",
9787
+ "componentWillRender",
9788
+ "render",
9789
+ "componentDidRender",
9790
+ "componentDidUpdate",
9791
+ ];
9792
+ // The hooks a cycle starts with: the component is rendering from here on.
9793
+ const START_HOOKS = ["componentWillLoad", "componentWillUpdate", "componentWillRender"];
9794
+ const describeFailure = (element, message) => {
9795
+ var _a, _b, _c, _d;
9796
+ return ({
9797
+ tag: (_a = element === null || element === void 0 ? void 0 : element.localName) !== null && _a !== void 0 ? _a : "",
9798
+ // an inner renderer has no id of its own: name the component it is drawn for
9799
+ id: (element === null || element === void 0 ? void 0 : element.id) || ((_d = (_c = (_b = element === null || element === void 0 ? void 0 : element.getRootNode) === null || _b === void 0 ? void 0 : _b.call(element)) === null || _c === void 0 ? void 0 : _c.host) === null || _d === void 0 ? void 0 : _d.id) || "",
9800
+ message,
9801
+ });
9802
+ };
9803
+ /**
9804
+ * Mixin that tracks a component's render lifecycle in the global {@link ComponentRegister}.
9913
9805
  *
9914
- * @throws Error if no `<bn-context>` ancestor is found in the DOM
9806
+ * Assigns a stable UUID to the component instance and reports status transitions:
9807
+ * - `RUNNING` from `connectedCallback` (only before the first render: a re-attach does not render again)
9808
+ * or from the first hook of a render cycle, until `componentDidRender`
9809
+ * - `ERROR` when `render`, a lifecycle hook or `connectedCallback` threw. Stencil catches such
9810
+ * an exception and goes on, so without this the component would count as rendered.
9811
+ * - `SUCCESSFUL` otherwise
9812
+ *
9813
+ * A component that leaves the document is removed from the register.
9814
+ *
9815
+ * Returns a hold function: the component stays `RUNNING` until the promise
9816
+ * passed to it has settled, whatever the outcome.
9817
+ *
9818
+ * External tools (e.g. screenshot/PDF renderers) poll
9819
+ * `window.componentRegisterIsRenderedResult` to determine when all components
9820
+ * have finished rendering.
9821
+ *
9822
+ * @param component - The Stencil component instance
9915
9823
  */
9916
- function getStores(element) {
9917
- const cached = storesCache.get(element);
9918
- if (cached)
9919
- return cached;
9920
- const contextEl = findContextElement(element);
9921
- if (!contextEl) {
9922
- throw new Error(`[bn] <${element.localName}> must be inside a <bn-context>. No ancestor <bn-context> found.`);
9824
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9825
+ const withComponentStatus = (component) => {
9826
+ const uuid = generateUUID();
9827
+ let pending = 0;
9828
+ let rendered = false;
9829
+ let rendering = false;
9830
+ let loadFailure;
9831
+ let cycleFailure;
9832
+ let connectFailure;
9833
+ const publish = () => {
9834
+ var _a;
9835
+ // read here, not tracked in connectedCallback: not every build calls that wrapper
9836
+ const element = index.getElement(component);
9837
+ if (element && !element.isConnected)
9838
+ return;
9839
+ const message = (_a = connectFailure !== null && connectFailure !== void 0 ? connectFailure : loadFailure) !== null && _a !== void 0 ? _a : cycleFailure;
9840
+ if (rendering || pending > 0) {
9841
+ exports.ComponentRegister.updateStatus(uuid, ComponentStatus.RUNNING);
9842
+ }
9843
+ else if (message !== undefined) {
9844
+ exports.ComponentRegister.updateStatus(uuid, ComponentStatus.ERROR, describeFailure(element, message));
9845
+ }
9846
+ else {
9847
+ exports.ComponentRegister.updateStatus(uuid, ComponentStatus.SUCCESSFUL);
9848
+ }
9849
+ };
9850
+ const fail = (hook, e) => {
9851
+ const message = e instanceof Error ? e.message : String(e);
9852
+ if (LOAD_HOOKS.includes(hook)) {
9853
+ loadFailure = message;
9854
+ }
9855
+ else {
9856
+ cycleFailure = message;
9857
+ }
9858
+ publish();
9859
+ };
9860
+ const connectedCallback = component["connectedCallback"];
9861
+ let connect = () => {
9862
+ if (!rendered)
9863
+ rendering = true;
9864
+ publish();
9865
+ runIfExisits(connectedCallback, component);
9866
+ };
9867
+ // The mixins that are applied after this one wrap connectedCallback again, outside of the wrapper above.
9868
+ // The accessor keeps a guard around whatever they assign, so a throw in any of them is seen here too.
9869
+ const guarded = (fn) => () => {
9870
+ connectFailure = undefined;
9871
+ try {
9872
+ fn();
9873
+ }
9874
+ catch (e) {
9875
+ connectFailure = e instanceof Error ? e.message : String(e);
9876
+ publish();
9877
+ // Stencil logs it and goes on with the first render
9878
+ throw e;
9879
+ }
9880
+ };
9881
+ Object.defineProperty(component, "connectedCallback", {
9882
+ configurable: true,
9883
+ enumerable: true,
9884
+ get: () => guarded(connect),
9885
+ set: (fn) => {
9886
+ connect = fn;
9887
+ },
9888
+ });
9889
+ const disconnectedCallback = component["disconnectedCallback"];
9890
+ component["disconnectedCallback"] = () => {
9891
+ exports.ComponentRegister.remove(uuid);
9892
+ runIfExisits(disconnectedCallback, component);
9893
+ };
9894
+ for (const hook of [...LOAD_HOOKS, ...CYCLE_HOOKS]) {
9895
+ const original = component[hook];
9896
+ component[hook] = (...args) => {
9897
+ if (hook === "componentWillUpdate")
9898
+ cycleFailure = undefined;
9899
+ if (START_HOOKS.includes(hook)) {
9900
+ rendering = true;
9901
+ publish();
9902
+ }
9903
+ try {
9904
+ const result = typeof original === "function" ? original.apply(component, args) : undefined;
9905
+ if (typeof (result === null || result === void 0 ? void 0 : result.then) === "function") {
9906
+ // an async hook: Stencil waits for the returned promise, so the failure must stay in it
9907
+ return result.then((value) => value, (e) => {
9908
+ fail(hook, e);
9909
+ throw e;
9910
+ });
9911
+ }
9912
+ return result;
9913
+ }
9914
+ catch (e) {
9915
+ fail(hook, e);
9916
+ // Stencil logs it and goes on with the next hook
9917
+ throw e;
9918
+ }
9919
+ finally {
9920
+ if (hook === "componentDidRender") {
9921
+ rendered = true;
9922
+ rendering = false;
9923
+ publish();
9924
+ }
9925
+ }
9926
+ };
9923
9927
  }
9924
- const stores = getOrCreateStores(contextEl);
9925
- storesCache.set(element, stores);
9926
- return stores;
9927
- }
9928
- /** Removes the cached stores entry for an element (call in `disconnectedCallback`). */
9929
- function clearStoresCache(element) {
9930
- storesCache.delete(element);
9931
- }
9928
+ return (work) => {
9929
+ pending++;
9930
+ publish();
9931
+ const done = () => {
9932
+ pending--;
9933
+ publish();
9934
+ };
9935
+ work.then(done, done);
9936
+ };
9937
+ };
9932
9938
 
9933
9939
  const urlAlphabet =
9934
9940
  'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';