@vielzeug/ore 1.0.3

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 (294) hide show
  1. package/README.md +73 -0
  2. package/dist/_dev.cjs +2 -0
  3. package/dist/_dev.cjs.map +1 -0
  4. package/dist/_dev.d.ts +2 -0
  5. package/dist/_dev.d.ts.map +1 -0
  6. package/dist/_dev.js +2 -0
  7. package/dist/_dev.js.map +1 -0
  8. package/dist/aria.cjs +2 -0
  9. package/dist/aria.cjs.map +1 -0
  10. package/dist/aria.d.ts +12 -0
  11. package/dist/aria.d.ts.map +1 -0
  12. package/dist/aria.js +2 -0
  13. package/dist/aria.js.map +1 -0
  14. package/dist/base-element.cjs +2 -0
  15. package/dist/base-element.cjs.map +1 -0
  16. package/dist/base-element.d.ts +22 -0
  17. package/dist/base-element.d.ts.map +1 -0
  18. package/dist/base-element.js +2 -0
  19. package/dist/base-element.js.map +1 -0
  20. package/dist/component-types.d.ts +104 -0
  21. package/dist/component-types.d.ts.map +1 -0
  22. package/dist/context-bag.cjs +2 -0
  23. package/dist/context-bag.cjs.map +1 -0
  24. package/dist/context-bag.d.ts +12 -0
  25. package/dist/context-bag.d.ts.map +1 -0
  26. package/dist/context-bag.js +2 -0
  27. package/dist/context-bag.js.map +1 -0
  28. package/dist/context.cjs +2 -0
  29. package/dist/context.cjs.map +1 -0
  30. package/dist/context.d.ts +15 -0
  31. package/dist/context.d.ts.map +1 -0
  32. package/dist/context.js +2 -0
  33. package/dist/context.js.map +1 -0
  34. package/dist/define.cjs +2 -0
  35. package/dist/define.cjs.map +1 -0
  36. package/dist/define.d.ts +33 -0
  37. package/dist/define.d.ts.map +1 -0
  38. package/dist/define.js +2 -0
  39. package/dist/define.js.map +1 -0
  40. package/dist/devtools.cjs +2 -0
  41. package/dist/devtools.cjs.map +1 -0
  42. package/dist/devtools.d.ts +32 -0
  43. package/dist/devtools.d.ts.map +1 -0
  44. package/dist/devtools.js +2 -0
  45. package/dist/devtools.js.map +1 -0
  46. package/dist/directives/classMap.cjs +2 -0
  47. package/dist/directives/classMap.cjs.map +1 -0
  48. package/dist/directives/classMap.d.ts +19 -0
  49. package/dist/directives/classMap.d.ts.map +1 -0
  50. package/dist/directives/classMap.js +2 -0
  51. package/dist/directives/classMap.js.map +1 -0
  52. package/dist/directives/each.cjs +2 -0
  53. package/dist/directives/each.cjs.map +1 -0
  54. package/dist/directives/each.d.ts +25 -0
  55. package/dist/directives/each.d.ts.map +1 -0
  56. package/dist/directives/each.js +2 -0
  57. package/dist/directives/each.js.map +1 -0
  58. package/dist/directives/index.d.ts +8 -0
  59. package/dist/directives/index.d.ts.map +1 -0
  60. package/dist/directives/live.cjs +2 -0
  61. package/dist/directives/live.cjs.map +1 -0
  62. package/dist/directives/live.d.ts +25 -0
  63. package/dist/directives/live.d.ts.map +1 -0
  64. package/dist/directives/live.js +2 -0
  65. package/dist/directives/live.js.map +1 -0
  66. package/dist/directives/model.cjs +2 -0
  67. package/dist/directives/model.cjs.map +1 -0
  68. package/dist/directives/model.d.ts +28 -0
  69. package/dist/directives/model.d.ts.map +1 -0
  70. package/dist/directives/model.js +2 -0
  71. package/dist/directives/model.js.map +1 -0
  72. package/dist/directives/raw.cjs +2 -0
  73. package/dist/directives/raw.cjs.map +1 -0
  74. package/dist/directives/raw.d.ts +16 -0
  75. package/dist/directives/raw.d.ts.map +1 -0
  76. package/dist/directives/raw.js +2 -0
  77. package/dist/directives/raw.js.map +1 -0
  78. package/dist/directives/styleMap.cjs +2 -0
  79. package/dist/directives/styleMap.cjs.map +1 -0
  80. package/dist/directives/styleMap.d.ts +25 -0
  81. package/dist/directives/styleMap.d.ts.map +1 -0
  82. package/dist/directives/styleMap.js +2 -0
  83. package/dist/directives/styleMap.js.map +1 -0
  84. package/dist/directives/when.cjs +2 -0
  85. package/dist/directives/when.cjs.map +1 -0
  86. package/dist/directives/when.d.ts +19 -0
  87. package/dist/directives/when.d.ts.map +1 -0
  88. package/dist/directives/when.js +2 -0
  89. package/dist/directives/when.js.map +1 -0
  90. package/dist/directives.cjs +1 -0
  91. package/dist/directives.js +1 -0
  92. package/dist/errors.cjs +3 -0
  93. package/dist/errors.cjs.map +1 -0
  94. package/dist/errors.d.ts +47 -0
  95. package/dist/errors.d.ts.map +1 -0
  96. package/dist/errors.js +3 -0
  97. package/dist/errors.js.map +1 -0
  98. package/dist/form-context.cjs +2 -0
  99. package/dist/form-context.cjs.map +1 -0
  100. package/dist/form-context.d.ts +56 -0
  101. package/dist/form-context.d.ts.map +1 -0
  102. package/dist/form-context.js +2 -0
  103. package/dist/form-context.js.map +1 -0
  104. package/dist/form-field.cjs +2 -0
  105. package/dist/form-field.cjs.map +1 -0
  106. package/dist/form-field.d.ts +31 -0
  107. package/dist/form-field.d.ts.map +1 -0
  108. package/dist/form-field.js +2 -0
  109. package/dist/form-field.js.map +1 -0
  110. package/dist/host-bind.cjs +2 -0
  111. package/dist/host-bind.cjs.map +1 -0
  112. package/dist/host-bind.d.ts +37 -0
  113. package/dist/host-bind.d.ts.map +1 -0
  114. package/dist/host-bind.js +2 -0
  115. package/dist/host-bind.js.map +1 -0
  116. package/dist/index.cjs +1 -0
  117. package/dist/index.d.ts +15 -0
  118. package/dist/index.d.ts.map +1 -0
  119. package/dist/index.js +1 -0
  120. package/dist/observers/index.d.ts +5 -0
  121. package/dist/observers/index.d.ts.map +1 -0
  122. package/dist/observers/intersection-observe.cjs +2 -0
  123. package/dist/observers/intersection-observe.cjs.map +1 -0
  124. package/dist/observers/intersection-observe.d.ts +9 -0
  125. package/dist/observers/intersection-observe.d.ts.map +1 -0
  126. package/dist/observers/intersection-observe.js +2 -0
  127. package/dist/observers/intersection-observe.js.map +1 -0
  128. package/dist/observers/media-observe.cjs +2 -0
  129. package/dist/observers/media-observe.cjs.map +1 -0
  130. package/dist/observers/media-observe.d.ts +8 -0
  131. package/dist/observers/media-observe.d.ts.map +1 -0
  132. package/dist/observers/media-observe.js +2 -0
  133. package/dist/observers/media-observe.js.map +1 -0
  134. package/dist/observers/mutation-observe.cjs +2 -0
  135. package/dist/observers/mutation-observe.cjs.map +1 -0
  136. package/dist/observers/mutation-observe.d.ts +10 -0
  137. package/dist/observers/mutation-observe.d.ts.map +1 -0
  138. package/dist/observers/mutation-observe.js +2 -0
  139. package/dist/observers/mutation-observe.js.map +1 -0
  140. package/dist/observers/resize-observe.cjs +2 -0
  141. package/dist/observers/resize-observe.cjs.map +1 -0
  142. package/dist/observers/resize-observe.d.ts +11 -0
  143. package/dist/observers/resize-observe.d.ts.map +1 -0
  144. package/dist/observers/resize-observe.js +2 -0
  145. package/dist/observers/resize-observe.js.map +1 -0
  146. package/dist/observers.cjs +1 -0
  147. package/dist/observers.js +1 -0
  148. package/dist/ore.cjs +3 -0
  149. package/dist/ore.cjs.map +1 -0
  150. package/dist/ore.iife.js +3 -0
  151. package/dist/ore.iife.js.map +1 -0
  152. package/dist/ore.js +3 -0
  153. package/dist/ore.js.map +1 -0
  154. package/dist/props.cjs +2 -0
  155. package/dist/props.cjs.map +1 -0
  156. package/dist/props.d.ts +76 -0
  157. package/dist/props.d.ts.map +1 -0
  158. package/dist/props.js +2 -0
  159. package/dist/props.js.map +1 -0
  160. package/dist/runtime.cjs +2 -0
  161. package/dist/runtime.cjs.map +1 -0
  162. package/dist/runtime.d.ts +34 -0
  163. package/dist/runtime.d.ts.map +1 -0
  164. package/dist/runtime.js +2 -0
  165. package/dist/runtime.js.map +1 -0
  166. package/dist/slots.cjs +2 -0
  167. package/dist/slots.cjs.map +1 -0
  168. package/dist/slots.d.ts +13 -0
  169. package/dist/slots.d.ts.map +1 -0
  170. package/dist/slots.js +2 -0
  171. package/dist/slots.js.map +1 -0
  172. package/dist/template/bindings.cjs +2 -0
  173. package/dist/template/bindings.cjs.map +1 -0
  174. package/dist/template/bindings.d.ts +17 -0
  175. package/dist/template/bindings.d.ts.map +1 -0
  176. package/dist/template/bindings.js +2 -0
  177. package/dist/template/bindings.js.map +1 -0
  178. package/dist/template/compiler.cjs +2 -0
  179. package/dist/template/compiler.cjs.map +1 -0
  180. package/dist/template/compiler.d.ts +27 -0
  181. package/dist/template/compiler.d.ts.map +1 -0
  182. package/dist/template/compiler.js +2 -0
  183. package/dist/template/compiler.js.map +1 -0
  184. package/dist/template/instantiator.cjs +2 -0
  185. package/dist/template/instantiator.cjs.map +1 -0
  186. package/dist/template/instantiator.d.ts +16 -0
  187. package/dist/template/instantiator.d.ts.map +1 -0
  188. package/dist/template/instantiator.js +2 -0
  189. package/dist/template/instantiator.js.map +1 -0
  190. package/dist/template.cjs +1 -0
  191. package/dist/template.d.ts +4 -0
  192. package/dist/template.d.ts.map +1 -0
  193. package/dist/template.js +1 -0
  194. package/dist/testing/events.cjs +2 -0
  195. package/dist/testing/events.cjs.map +1 -0
  196. package/dist/testing/events.d.ts +37 -0
  197. package/dist/testing/events.d.ts.map +1 -0
  198. package/dist/testing/events.js +2 -0
  199. package/dist/testing/events.js.map +1 -0
  200. package/dist/testing/flush.cjs +2 -0
  201. package/dist/testing/flush.cjs.map +1 -0
  202. package/dist/testing/flush.d.ts +55 -0
  203. package/dist/testing/flush.d.ts.map +1 -0
  204. package/dist/testing/flush.js +2 -0
  205. package/dist/testing/flush.js.map +1 -0
  206. package/dist/testing/index.d.ts +2 -0
  207. package/dist/testing/index.d.ts.map +1 -0
  208. package/dist/testing/interactions.cjs +2 -0
  209. package/dist/testing/interactions.cjs.map +1 -0
  210. package/dist/testing/interactions.d.ts +27 -0
  211. package/dist/testing/interactions.d.ts.map +1 -0
  212. package/dist/testing/interactions.js +2 -0
  213. package/dist/testing/interactions.js.map +1 -0
  214. package/dist/testing/mount.cjs +2 -0
  215. package/dist/testing/mount.cjs.map +1 -0
  216. package/dist/testing/mount.d.ts +107 -0
  217. package/dist/testing/mount.d.ts.map +1 -0
  218. package/dist/testing/mount.js +2 -0
  219. package/dist/testing/mount.js.map +1 -0
  220. package/dist/testing/query.cjs +2 -0
  221. package/dist/testing/query.cjs.map +1 -0
  222. package/dist/testing/query.d.ts +24 -0
  223. package/dist/testing/query.d.ts.map +1 -0
  224. package/dist/testing/query.js +2 -0
  225. package/dist/testing/query.js.map +1 -0
  226. package/dist/testing/render-hook.cjs +2 -0
  227. package/dist/testing/render-hook.cjs.map +1 -0
  228. package/dist/testing/render-hook.d.ts +44 -0
  229. package/dist/testing/render-hook.d.ts.map +1 -0
  230. package/dist/testing/render-hook.js +2 -0
  231. package/dist/testing/render-hook.js.map +1 -0
  232. package/dist/testing/testing.cjs +2 -0
  233. package/dist/testing/testing.cjs.map +1 -0
  234. package/dist/testing/testing.d.ts +26 -0
  235. package/dist/testing/testing.d.ts.map +1 -0
  236. package/dist/testing/testing.js +2 -0
  237. package/dist/testing/testing.js.map +1 -0
  238. package/dist/testing/wait.cjs +2 -0
  239. package/dist/testing/wait.cjs.map +1 -0
  240. package/dist/testing/wait.d.ts +35 -0
  241. package/dist/testing/wait.d.ts.map +1 -0
  242. package/dist/testing/wait.js +2 -0
  243. package/dist/testing/wait.js.map +1 -0
  244. package/dist/testing.cjs +1 -0
  245. package/dist/testing.js +1 -0
  246. package/dist/types/bindings.cjs +2 -0
  247. package/dist/types/bindings.cjs.map +1 -0
  248. package/dist/types/bindings.d.ts +125 -0
  249. package/dist/types/bindings.d.ts.map +1 -0
  250. package/dist/types/bindings.js +2 -0
  251. package/dist/types/bindings.js.map +1 -0
  252. package/dist/types.cjs +2 -0
  253. package/dist/types.cjs.map +1 -0
  254. package/dist/types.d.ts +19 -0
  255. package/dist/types.d.ts.map +1 -0
  256. package/dist/types.js +2 -0
  257. package/dist/types.js.map +1 -0
  258. package/dist/utils/aria.cjs +2 -0
  259. package/dist/utils/aria.cjs.map +1 -0
  260. package/dist/utils/aria.d.ts +16 -0
  261. package/dist/utils/aria.d.ts.map +1 -0
  262. package/dist/utils/aria.js +2 -0
  263. package/dist/utils/aria.js.map +1 -0
  264. package/dist/utils/css.cjs +2 -0
  265. package/dist/utils/css.cjs.map +1 -0
  266. package/dist/utils/css.d.ts +11 -0
  267. package/dist/utils/css.d.ts.map +1 -0
  268. package/dist/utils/css.js +2 -0
  269. package/dist/utils/css.js.map +1 -0
  270. package/dist/utils/dom.cjs +2 -0
  271. package/dist/utils/dom.cjs.map +1 -0
  272. package/dist/utils/dom.d.ts +10 -0
  273. package/dist/utils/dom.d.ts.map +1 -0
  274. package/dist/utils/dom.js +2 -0
  275. package/dist/utils/dom.js.map +1 -0
  276. package/dist/utils/emit.cjs +2 -0
  277. package/dist/utils/emit.cjs.map +1 -0
  278. package/dist/utils/emit.d.ts +16 -0
  279. package/dist/utils/emit.d.ts.map +1 -0
  280. package/dist/utils/emit.js +2 -0
  281. package/dist/utils/emit.js.map +1 -0
  282. package/dist/utils/event-modifiers.cjs +2 -0
  283. package/dist/utils/event-modifiers.cjs.map +1 -0
  284. package/dist/utils/event-modifiers.d.ts +11 -0
  285. package/dist/utils/event-modifiers.d.ts.map +1 -0
  286. package/dist/utils/event-modifiers.js +2 -0
  287. package/dist/utils/event-modifiers.js.map +1 -0
  288. package/dist/utils/id.cjs +2 -0
  289. package/dist/utils/id.cjs.map +1 -0
  290. package/dist/utils/id.d.ts +18 -0
  291. package/dist/utils/id.d.ts.map +1 -0
  292. package/dist/utils/id.js +2 -0
  293. package/dist/utils/id.js.map +1 -0
  294. package/package.json +68 -0
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @vielzeug/ore
2
+
3
+ > Functional custom-element authoring with typed props, reactive templates, lifecycle helpers, observers, and testing utilities.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@vielzeug/ore)](https://www.npmjs.com/package/@vielzeug/ore) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ <details>
8
+ <summary>Quick Reference</summary>
9
+
10
+ **Package:** `@vielzeug/ore` &nbsp;·&nbsp; **Category:** UI Primitives
11
+
12
+ **Key exports:** `define`, `html`, `css`, `prop`, `ref`, `signal`, `computed`, `watch`, `each`, `when`, `model`, `live`, `provide`, `inject`, `defineField`, `withAria`
13
+
14
+ **When to use:** Functional custom-element authoring with typed props, reactive templates, lifecycle helpers, observers, and testing utilities.
15
+
16
+ **Related:** [@vielzeug/ripple](https://vielzeug.dev/ripple/) · [@vielzeug/refine](https://vielzeug.dev/refine/) · [@vielzeug/orbit](https://vielzeug.dev/orbit/)
17
+
18
+ </details>
19
+
20
+ `@vielzeug/ore` is part of Vielzeug and ships as a zero-dependency TypeScript package with ESM+CJS output.
21
+
22
+ ## Installation
23
+
24
+ ```sh
25
+ pnpm add @vielzeug/ore
26
+ npm install @vielzeug/ore
27
+ yarn add @vielzeug/ore
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ```ts
33
+ import { computed, css, define, html, prop, signal } from '@vielzeug/ore';
34
+
35
+ define('my-counter', {
36
+ props: {
37
+ label: prop.string('Count'),
38
+ step: prop.number(1),
39
+ },
40
+ styles: [
41
+ css`
42
+ :host {
43
+ display: inline-grid;
44
+ gap: 0.5rem;
45
+ }
46
+ `,
47
+ ],
48
+ setup(props, { bind, onMounted }) {
49
+ const count = signal(0);
50
+ const doubled = computed(() => count.value * 2);
51
+
52
+ bind({ class: { 'is-positive': () => count.value > 0 } });
53
+
54
+ onMounted(() => console.log('mounted'));
55
+
56
+ return html`
57
+ <button @click=${() => (count.value += props.step.value)}>${props.label}: ${count}</button>
58
+ <p>Doubled: ${doubled}</p>
59
+ `;
60
+ },
61
+ });
62
+ ```
63
+
64
+ ## Documentation
65
+
66
+ - [Overview](https://vielzeug.dev/ore/)
67
+ - [Usage Guide](https://vielzeug.dev/ore/usage)
68
+ - [API Reference](https://vielzeug.dev/ore/api)
69
+ - [Examples](https://vielzeug.dev/ore/examples)
70
+
71
+ ## License
72
+
73
+ MIT © [Helmuth Saatkamp](https://github.com/helmuthdu) — part of the [Vielzeug](https://github.com/helmuthdu/vielzeug) monorepo.
package/dist/_dev.cjs ADDED
@@ -0,0 +1,2 @@
1
+ var e=!globalThis.__ORE_PROD__;function t(t){e&&console.warn(`[@vielzeug/ore] ${t}`)}function n(t,...n){e&&console.error(`[@vielzeug/ore] ${t}`,...n)}function r(t){e&&t()}exports.devOnly=r,exports.error=n,exports.warn=t;
2
+ //# sourceMappingURL=_dev.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["const isDev = !(globalThis as { __ORE_PROD__?: boolean }).__ORE_PROD__;\n\n/** @internal @security Messages may include user-supplied data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/ore] ${msg}`);\n}\n\n/** @internal */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/ore] ${msg}`, ...args);\n}\n\n/** @internal — Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":"AAAA,IAAM,EAAQ,CAAE,WAA0C,aAG1D,SAAgB,EAAK,EAAmB,CAClC,GAAO,QAAQ,KAAK,mBAAmB,GAAK,CAClD,CAGA,SAAgB,EAAM,EAAa,GAAG,EAAuB,CACvD,GAAO,QAAQ,MAAM,mBAAmB,IAAO,GAAG,CAAI,CAC5D,CAGA,SAAgB,EAAQ,EAAsB,CACxC,GAAO,EAAG,CAChB"}
package/dist/_dev.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=_dev.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dev.d.ts","sourceRoot":"","sources":["../src/_dev.ts"],"names":[],"mappings":""}
package/dist/_dev.js ADDED
@@ -0,0 +1,2 @@
1
+ var e=!globalThis.__ORE_PROD__;function t(t){e&&console.warn(`[@vielzeug/ore] ${t}`)}function n(t,...n){e&&console.error(`[@vielzeug/ore] ${t}`,...n)}function r(t){e&&t()}export{r as devOnly,n as error,t as warn};
2
+ //# sourceMappingURL=_dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["const isDev = !(globalThis as { __ORE_PROD__?: boolean }).__ORE_PROD__;\n\n/** @internal @security Messages may include user-supplied data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/ore] ${msg}`);\n}\n\n/** @internal */\nexport function error(msg: string, ...args: unknown[]): void {\n if (isDev) console.error(`[@vielzeug/ore] ${msg}`, ...args);\n}\n\n/** @internal — Run fn only in dev builds. Use when dev-only logic goes beyond a single warn() / error() call. */\nexport function devOnly(fn: () => void): void {\n if (isDev) fn();\n}\n"],"mappings":"AAAA,IAAM,EAAQ,CAAE,WAA0C,aAG1D,SAAgB,EAAK,EAAmB,CAClC,GAAO,QAAQ,KAAK,mBAAmB,GAAK,CAClD,CAGA,SAAgB,EAAM,EAAa,GAAG,EAAuB,CACvD,GAAO,QAAQ,MAAM,mBAAmB,IAAO,GAAG,CAAI,CAC5D,CAGA,SAAgB,EAAQ,EAAsB,CACxC,GAAO,EAAG,CAChB"}
package/dist/aria.cjs ADDED
@@ -0,0 +1,2 @@
1
+ const e=require("./runtime.cjs"),t=require("./utils/aria.cjs");let n=require("@vielzeug/ripple");var r=(e,t,n)=>{if(n==null||n===!1){e.removeAttribute(t);return}e.setAttribute(t,n===!0?`true`:String(n))},i=(e,i)=>{let a=[];for(let[o,s]of Object.entries(i)){let i=t.normalizeAriaKey(o);if(typeof s==`function`){let t=(0,n.effect)(()=>r(e,i,s()));a.push(()=>t.dispose());continue}if((0,n.isReactive)(s)){let t=(0,n.effect)(()=>r(e,i,s.value));a.push(()=>t.dispose());continue}r(e,i,s)}return()=>{for(;a.length>0;)a.pop()?.()}},a=()=>(t,n)=>{let r=i(t,n);return e.tryRegisterCleanup(r),r};exports.createAriaFn=a;
2
+ //# sourceMappingURL=aria.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria.cjs","names":[],"sources":["../src/aria.ts"],"sourcesContent":["/**\n * Reactive ARIA attribute sync — internal implementation.\n *\n * Public surface: `ctx.aria(target, config)` on the SetupContextBag.\n * For off-component usage (e.g. floating trigger callbacks), use `ctx.bind({ attr: {...} }, { target: el })`.\n */\n\nimport { effect as rawEffect, isReactive, type Readable } from '@vielzeug/ripple';\n\nimport { tryRegisterCleanup } from './runtime';\nimport { normalizeAriaKey } from './utils/aria';\n\ntype AriaScalar = string | number | boolean | null | undefined;\ntype AriaValue = AriaScalar | (() => AriaScalar) | Readable<AriaScalar>;\n\nexport type AriaConfig = Record<string, AriaValue>;\n\nconst setA11yAttr = (target: Element, key: string, value: string | number | boolean | null | undefined): void => {\n if (value == null || value === false) {\n target.removeAttribute(key);\n\n return;\n }\n\n target.setAttribute(key, value === true ? 'true' : String(value));\n};\n\n/** @internal Apply aria config to a target element, returning a cleanup fn. */\nconst applyAriaConfig = (target: Element, config: AriaConfig): (() => void) => {\n const disposers: Array<() => void> = [];\n\n for (const [rawKey, rawValue] of Object.entries(config)) {\n const key = normalizeAriaKey(rawKey);\n\n if (typeof rawValue === 'function') {\n const sub = rawEffect(() => setA11yAttr(target, key, rawValue()));\n\n disposers.push(() => sub.dispose());\n\n continue;\n }\n\n if (isReactive(rawValue)) {\n const sub = rawEffect(() => setA11yAttr(target, key, rawValue.value as AriaScalar));\n\n disposers.push(() => sub.dispose());\n\n continue;\n }\n\n setA11yAttr(target, key, rawValue);\n }\n\n return () => {\n while (disposers.length > 0) disposers.pop()?.();\n };\n};\n\n/**\n * Create an `aria()` function scoped to a component's lifecycle.\n * Cleanup is auto-registered with `onCleanup` when inside a setup context.\n * @internal — consumed by context-bag.ts to produce `ctx.aria(target, config)`.\n */\nexport const createAriaFn =\n () =>\n (target: Element, config: AriaConfig): (() => void) => {\n const cleanup = applyAriaConfig(target, config);\n\n tryRegisterCleanup(cleanup);\n\n return cleanup;\n };\n"],"mappings":"iGAiBA,IAAM,GAAe,EAAiB,EAAa,IAA8D,CAC/G,GAAI,GAAS,MAAQ,IAAU,GAAO,CACpC,EAAO,gBAAgB,CAAG,EAE1B,MACF,CAEA,EAAO,aAAa,EAAK,IAAU,GAAO,OAAS,OAAO,CAAK,CAAC,CAClE,EAGM,GAAmB,EAAiB,IAAqC,CAC7E,IAAM,EAA+B,CAAC,EAEtC,IAAK,GAAM,CAAC,EAAQ,KAAa,OAAO,QAAQ,CAAM,EAAG,CACvD,IAAM,EAAM,EAAA,iBAAiB,CAAM,EAEnC,GAAI,OAAO,GAAa,WAAY,CAClC,IAAM,GAAA,EAAA,EAAA,OAAA,KAAsB,EAAY,EAAQ,EAAK,EAAS,CAAC,CAAC,EAEhE,EAAU,SAAW,EAAI,QAAQ,CAAC,EAElC,QACF,CAEA,IAAA,EAAA,EAAA,WAAA,CAAe,CAAQ,EAAG,CACxB,IAAM,GAAA,EAAA,EAAA,OAAA,KAAsB,EAAY,EAAQ,EAAK,EAAS,KAAmB,CAAC,EAElF,EAAU,SAAW,EAAI,QAAQ,CAAC,EAElC,QACF,CAEA,EAAY,EAAQ,EAAK,CAAQ,CACnC,CAEA,UAAa,CACX,KAAO,EAAU,OAAS,GAAG,EAAU,IAAI,CAAC,GAAG,CACjD,CACF,EAOa,OAEV,EAAiB,IAAqC,CACrD,IAAM,EAAU,EAAgB,EAAQ,CAAM,EAI9C,OAFA,EAAA,mBAAmB,CAAO,EAEnB,CACT"}
package/dist/aria.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Reactive ARIA attribute sync — internal implementation.
3
+ *
4
+ * Public surface: `ctx.aria(target, config)` on the SetupContextBag.
5
+ * For off-component usage (e.g. floating trigger callbacks), use `ctx.bind({ attr: {...} }, { target: el })`.
6
+ */
7
+ import { type Readable } from '@vielzeug/ripple';
8
+ type AriaScalar = string | number | boolean | null | undefined;
9
+ type AriaValue = AriaScalar | (() => AriaScalar) | Readable<AriaScalar>;
10
+ export type AriaConfig = Record<string, AriaValue>;
11
+ export {};
12
+ //# sourceMappingURL=aria.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria.d.ts","sourceRoot":"","sources":["../src/aria.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAmC,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKlF,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAC/D,KAAK,SAAS,GAAG,UAAU,GAAG,CAAC,MAAM,UAAU,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAExE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC"}
package/dist/aria.js ADDED
@@ -0,0 +1,2 @@
1
+ import{tryRegisterCleanup as e}from"./runtime.js";import{normalizeAriaKey as t}from"./utils/aria.js";import{effect as n,isReactive as r}from"@vielzeug/ripple";var i=(e,t,n)=>{if(n==null||n===!1){e.removeAttribute(t);return}e.setAttribute(t,n===!0?`true`:String(n))},a=(e,a)=>{let o=[];for(let[s,c]of Object.entries(a)){let a=t(s);if(typeof c==`function`){let t=n(()=>i(e,a,c()));o.push(()=>t.dispose());continue}if(r(c)){let t=n(()=>i(e,a,c.value));o.push(()=>t.dispose());continue}i(e,a,c)}return()=>{for(;o.length>0;)o.pop()?.()}},o=()=>(t,n)=>{let r=a(t,n);return e(r),r};export{o as createAriaFn};
2
+ //# sourceMappingURL=aria.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aria.js","names":[],"sources":["../src/aria.ts"],"sourcesContent":["/**\n * Reactive ARIA attribute sync — internal implementation.\n *\n * Public surface: `ctx.aria(target, config)` on the SetupContextBag.\n * For off-component usage (e.g. floating trigger callbacks), use `ctx.bind({ attr: {...} }, { target: el })`.\n */\n\nimport { effect as rawEffect, isReactive, type Readable } from '@vielzeug/ripple';\n\nimport { tryRegisterCleanup } from './runtime';\nimport { normalizeAriaKey } from './utils/aria';\n\ntype AriaScalar = string | number | boolean | null | undefined;\ntype AriaValue = AriaScalar | (() => AriaScalar) | Readable<AriaScalar>;\n\nexport type AriaConfig = Record<string, AriaValue>;\n\nconst setA11yAttr = (target: Element, key: string, value: string | number | boolean | null | undefined): void => {\n if (value == null || value === false) {\n target.removeAttribute(key);\n\n return;\n }\n\n target.setAttribute(key, value === true ? 'true' : String(value));\n};\n\n/** @internal Apply aria config to a target element, returning a cleanup fn. */\nconst applyAriaConfig = (target: Element, config: AriaConfig): (() => void) => {\n const disposers: Array<() => void> = [];\n\n for (const [rawKey, rawValue] of Object.entries(config)) {\n const key = normalizeAriaKey(rawKey);\n\n if (typeof rawValue === 'function') {\n const sub = rawEffect(() => setA11yAttr(target, key, rawValue()));\n\n disposers.push(() => sub.dispose());\n\n continue;\n }\n\n if (isReactive(rawValue)) {\n const sub = rawEffect(() => setA11yAttr(target, key, rawValue.value as AriaScalar));\n\n disposers.push(() => sub.dispose());\n\n continue;\n }\n\n setA11yAttr(target, key, rawValue);\n }\n\n return () => {\n while (disposers.length > 0) disposers.pop()?.();\n };\n};\n\n/**\n * Create an `aria()` function scoped to a component's lifecycle.\n * Cleanup is auto-registered with `onCleanup` when inside a setup context.\n * @internal — consumed by context-bag.ts to produce `ctx.aria(target, config)`.\n */\nexport const createAriaFn =\n () =>\n (target: Element, config: AriaConfig): (() => void) => {\n const cleanup = applyAriaConfig(target, config);\n\n tryRegisterCleanup(cleanup);\n\n return cleanup;\n };\n"],"mappings":"+JAiBA,IAAM,GAAe,EAAiB,EAAa,IAA8D,CAC/G,GAAI,GAAS,MAAQ,IAAU,GAAO,CACpC,EAAO,gBAAgB,CAAG,EAE1B,MACF,CAEA,EAAO,aAAa,EAAK,IAAU,GAAO,OAAS,OAAO,CAAK,CAAC,CAClE,EAGM,GAAmB,EAAiB,IAAqC,CAC7E,IAAM,EAA+B,CAAC,EAEtC,IAAK,GAAM,CAAC,EAAQ,KAAa,OAAO,QAAQ,CAAM,EAAG,CACvD,IAAM,EAAM,EAAiB,CAAM,EAEnC,GAAI,OAAO,GAAa,WAAY,CAClC,IAAM,EAAM,MAAgB,EAAY,EAAQ,EAAK,EAAS,CAAC,CAAC,EAEhE,EAAU,SAAW,EAAI,QAAQ,CAAC,EAElC,QACF,CAEA,GAAI,EAAW,CAAQ,EAAG,CACxB,IAAM,EAAM,MAAgB,EAAY,EAAQ,EAAK,EAAS,KAAmB,CAAC,EAElF,EAAU,SAAW,EAAI,QAAQ,CAAC,EAElC,QACF,CAEA,EAAY,EAAQ,EAAK,CAAQ,CACnC,CAEA,UAAa,CACX,KAAO,EAAU,OAAS,GAAG,EAAU,IAAI,CAAC,GAAG,CACjD,CACF,EAOa,OAEV,EAAiB,IAAqC,CACrD,IAAM,EAAU,EAAgB,EAAQ,CAAM,EAI9C,OAFA,EAAmB,CAAO,EAEnB,CACT"}
@@ -0,0 +1,2 @@
1
+ const e=require("./_dev.cjs"),t=require("./errors.cjs");require("./types/bindings.cjs");const n=require("./runtime.cjs"),r=require("./context-bag.cjs"),i=require("./props.cjs"),a=require("./types.cjs"),o=require("./utils/css.cjs");let s=require("@vielzeug/ripple");var c=()=>({generation:0,mountCallbacks:[],phase:a.ComponentPhase.UNINITIALIZED,scope:(0,s.scope)(),templateResult:null}),l=class extends HTMLElement{static _definition;static _normalizedPropDefs;static formAssociated=!1;static observedAttributes=[];_component;constructor(){super();let e=this.constructor._definition;e?.shadow!==!1&&this.attachShadow({mode:`open`,...e?.shadow}),this._component=c()}connectedCallback(){(0,s.untrack)(()=>{this._component.phase===a.ComponentPhase.UNINITIALIZED&&this._runSetup(),this._init()}),this.dispatchEvent(new CustomEvent(a.LIFECYCLE_EVENTS.CONNECT,{bubbles:!1,composed:!1}))}attributeChangedCallback(e,t,n){if(t===n)return;let r=i.getPropMeta(this,e);if(!r)return;let a=r.parse(n);Object.is((0,s.untrack)(()=>r.signal.value),a)||(r.signal.value=a)}disconnectedCallback(){this._component.generation++,this._component.phase=a.ComponentPhase.UNMOUNTED,this.dispatchEvent(new CustomEvent(a.LIFECYCLE_EVENTS.DISCONNECT,{bubbles:!1,composed:!1})),this._component.scope.dispose(),this._component.mountCallbacks=[],this._component.phase=a.ComponentPhase.UNINITIALIZED,this._component.scope=(0,s.scope)(),this._component.templateResult=null}_handleSetupError(e,n=`setup`){let r=e instanceof Error?e:Error(String(e)),i=new t.OreLifecycleError(`<${this.localName}> failed during ${this._component.phase} (${n})`,{cause:r,component:this.localName,phase:n}),a=this.constructor._definition;if(a?.onError)try{return a.onError(i,this)}catch{}t.reportRuntimeError(i,this)}_runSetup(){this._component.phase=a.ComponentPhase.SETUP_RUNNING;let e=this.constructor._definition,t=this.constructor._normalizedPropDefs,o={element:this,mountCallbacks:[]};try{let s;if(this._component.scope.run(()=>{s=n.runWithContext(o,()=>{let n=t?i.createProps(this,t):{},a=r.createContextBag(this);return e.setup(n,a)})}),this._component.mountCallbacks.push(...o.mountCallbacks),s!=null&&typeof s.then==`function`){let t=this._component.mountCallbacks.splice(0);this._component.phase=a.ComponentPhase.LOADING,e.loading&&(this._component.templateResult=e.loading()),this._runSetupAsync(s,t,this._component.generation)}else this._component.templateResult=s??null,this._component.phase=a.ComponentPhase.SETUP_DONE}catch(e){let t=this._handleSetupError(e);if(t)this._component.templateResult=t,this._component.phase=a.ComponentPhase.SETUP_DONE;else throw this._component.phase=a.ComponentPhase.UNINITIALIZED,e}}async _runSetupAsync(t,n,r){try{let i=await t;if(this._component.generation!==r||!this.isConnected){e.warn(`<${this.localName}> async setup result discarded — element disconnected before setup resolved.`);return}this._component.templateResult=i??null,this._component.phase=a.ComponentPhase.SETUP_DONE,this._component.mountCallbacks.push(...n),i&&this._applyResult(i),this._scheduleMountCallbacks()}catch(t){if(this._component.generation!==r||!this.isConnected){e.warn(`<${this.localName}> async setup error discarded — element disconnected before setup resolved.`);return}let n=this._handleSetupError(t,`async-setup`);n?(this._component.templateResult=n,this._component.phase=a.ComponentPhase.SETUP_DONE,this._applyResult(n)):this._component.phase=a.ComponentPhase.UNINITIALIZED}}_applyResult(e){e&&((this.shadowRoot??this).replaceChildren(e.fragment),this._component.scope.run(()=>{e.apply(n.onCleanup)}))}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===a.ComponentPhase.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(o.loadStylesheet))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation;queueMicrotask(()=>{if(!this.isConnected||e!==this._component.generation)return;let t=this._component.mountCallbacks.splice(0);for(let e of t)try{let t={element:this,mountCallbacks:[]};this._component.scope.run(()=>{n.runWithContext(t,()=>{let t=e();typeof t==`function`&&n.onCleanup(t)})}),t.mountCallbacks.length>0&&this._component.mountCallbacks.push(...t.mountCallbacks)}catch(e){this._handleSetupError(e,`mounted`)}this._component.mountCallbacks.length>0&&this._scheduleMountCallbacks()})}};exports.BaseElement=l;
2
+ //# sourceMappingURL=base-element.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-element.cjs","names":[],"sources":["../src/base-element.ts"],"sourcesContent":["import { scope as _scope, type Scope, untrack } from '@vielzeug/ripple';\n\nimport type { ComponentDefinition } from './component-types';\n\nimport { warn } from './_dev';\nimport { createContextBag } from './context-bag';\nimport { type OreErrorPhase, OreLifecycleError, reportRuntimeError } from './errors';\nimport { createProps, getPropMeta, type InferProps, type PropInputDefs, type PropsDef } from './props';\nimport { type OnMountedCallback, onCleanup, type RuntimeContext, runWithContext } from './runtime';\nimport { ComponentPhase, LIFECYCLE_EVENTS } from './types';\nimport { type HTMLResult } from './types/bindings';\nimport { loadStylesheet } from './utils/css';\n\n// ─── Internal component state ─────────────────────────────────────────────────\n\ntype ComponentState = {\n /** Incremented on every disconnect — guards both mount callbacks and async setup results. */\n generation: number;\n mountCallbacks: OnMountedCallback[];\n phase: ComponentPhase;\n scope: Scope;\n templateResult: HTMLResult | null;\n};\n\nconst createComponentState = (): ComponentState => ({\n generation: 0,\n mountCallbacks: [],\n phase: ComponentPhase.UNINITIALIZED,\n scope: _scope(),\n templateResult: null,\n});\n\n// ─── BaseElement ──────────────────────────────────────────────────────────────\n\nexport class BaseElement extends HTMLElement {\n static _definition: ComponentDefinition<any, any, any>;\n static _normalizedPropDefs: PropsDef<Record<never, never>> | undefined;\n static formAssociated = false;\n static observedAttributes: string[] = [];\n\n private _component: ComponentState;\n\n constructor() {\n super();\n\n const def = (this.constructor as typeof BaseElement)._definition;\n\n if (def?.shadow !== false) {\n this.attachShadow({ mode: 'open', ...(def?.shadow as Partial<ShadowRootInit> | undefined) });\n }\n\n this._component = createComponentState();\n }\n\n connectedCallback(): void {\n untrack(() => {\n if (this._component.phase === ComponentPhase.UNINITIALIZED) this._runSetup();\n\n this._init();\n });\n this.dispatchEvent(new CustomEvent(LIFECYCLE_EVENTS.CONNECT, { bubbles: false, composed: false }));\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n\n const propMeta = getPropMeta(this, name);\n\n if (!propMeta) return;\n\n const parsed = propMeta.parse(newValue);\n\n if (\n !Object.is(\n untrack(() => propMeta.signal.value),\n parsed,\n )\n )\n propMeta.signal.value = parsed as never;\n }\n\n disconnectedCallback(): void {\n this._component.generation++;\n this._component.phase = ComponentPhase.UNMOUNTED;\n this.dispatchEvent(new CustomEvent(LIFECYCLE_EVENTS.DISCONNECT, { bubbles: false, composed: false }));\n this._component.scope.dispose();\n // Reset mutable fields for next connect, keeping the same object for stable references\n this._component.mountCallbacks = [];\n this._component.phase = ComponentPhase.UNINITIALIZED;\n this._component.scope = _scope();\n this._component.templateResult = null;\n }\n\n private _handleSetupError(error: unknown, phase: OreErrorPhase = 'setup'): HTMLResult | void {\n const err = error instanceof Error ? error : new Error(String(error));\n const oreError = new OreLifecycleError(`<${this.localName}> failed during ${this._component.phase} (${phase})`, {\n cause: err,\n component: this.localName,\n phase,\n });\n const def = (this.constructor as typeof BaseElement)._definition;\n\n if (def?.onError) {\n try {\n return def.onError(oreError, this);\n } catch {\n /* fall through */\n }\n }\n\n reportRuntimeError(oreError, this);\n }\n\n private _runSetup(): void {\n this._component.phase = ComponentPhase.SETUP_RUNNING;\n\n const def = (this.constructor as typeof BaseElement)._definition;\n const normalizedPropDefs = (this.constructor as typeof BaseElement)._normalizedPropDefs;\n const ctx: RuntimeContext = { element: this, mountCallbacks: [] };\n\n try {\n let setupResult: HTMLResult | null | Promise<HTMLResult | null> | undefined;\n\n this._component.scope.run(() => {\n setupResult = runWithContext(ctx, () => {\n const setupProps = normalizedPropDefs\n ? createProps(this, normalizedPropDefs)\n : ({} as InferProps<PropInputDefs>);\n const contextBag = createContextBag(this);\n\n return def.setup(setupProps as InferProps<PropInputDefs>, contextBag);\n });\n });\n this._component.mountCallbacks.push(...ctx.mountCallbacks);\n\n if (setupResult != null && typeof (setupResult as Promise<HTMLResult | null>).then === 'function') {\n // Async setup: show loading template immediately, swap when resolved.\n // Store captured mount callbacks; they will be scheduled after the real template mounts.\n const pendingCallbacks = this._component.mountCallbacks.splice(0);\n\n this._component.phase = ComponentPhase.LOADING;\n\n if (def.loading) {\n this._component.templateResult = def.loading();\n }\n\n // Capture the current generation so the async handler can detect staleness:\n // if the element disconnects+reconnects before the promise resolves, generation is\n // incremented and the old promise result must be discarded.\n void this._runSetupAsync(\n setupResult as Promise<HTMLResult | null>,\n pendingCallbacks,\n this._component.generation,\n );\n } else {\n this._component.templateResult = (setupResult as HTMLResult | null) ?? null;\n this._component.phase = ComponentPhase.SETUP_DONE;\n }\n } catch (error) {\n const recoveryTemplate = this._handleSetupError(error);\n\n if (recoveryTemplate) {\n this._component.templateResult = recoveryTemplate;\n this._component.phase = ComponentPhase.SETUP_DONE;\n } else {\n this._component.phase = ComponentPhase.UNINITIALIZED;\n throw error;\n }\n }\n }\n\n private async _runSetupAsync(\n promise: Promise<HTMLResult | null>,\n pendingCallbacks: OnMountedCallback[],\n capturedGeneration: number,\n ): Promise<void> {\n try {\n const result = await promise;\n\n // Discard stale results: element disconnected+reconnected since this setup started.\n if (this._component.generation !== capturedGeneration || !this.isConnected) {\n warn(`<${this.localName}> async setup result discarded — element disconnected before setup resolved.`);\n\n return;\n }\n\n this._component.templateResult = result ?? null;\n this._component.phase = ComponentPhase.SETUP_DONE;\n this._component.mountCallbacks.push(...pendingCallbacks);\n\n if (result) this._applyResult(result);\n\n this._scheduleMountCallbacks();\n } catch (error) {\n if (this._component.generation !== capturedGeneration || !this.isConnected) {\n warn(`<${this.localName}> async setup error discarded — element disconnected before setup resolved.`);\n\n return;\n }\n\n const recovery = this._handleSetupError(error, 'async-setup');\n\n if (recovery) {\n this._component.templateResult = recovery;\n this._component.phase = ComponentPhase.SETUP_DONE;\n this._applyResult(recovery);\n } else {\n this._component.phase = ComponentPhase.UNINITIALIZED;\n }\n }\n }\n\n private _applyResult(result: HTMLResult | null): void {\n if (!result) return;\n\n const host: Element | ShadowRoot = this.shadowRoot ?? this;\n\n host.replaceChildren(result.fragment);\n this._component.scope.run(() => {\n result.apply(onCleanup);\n });\n }\n\n private _init(): void {\n this._applyStyles();\n this._mountTemplate();\n\n // Only schedule mount callbacks once setup is fully complete (not in LOADING state)\n if (this._component.phase === ComponentPhase.SETUP_DONE) this._scheduleMountCallbacks();\n }\n\n private _applyStyles(): void {\n const def = (this.constructor as typeof BaseElement)._definition;\n\n if (this.shadowRoot && def?.styles?.length) {\n this.shadowRoot.adoptedStyleSheets = def.styles.map(loadStylesheet);\n }\n }\n\n private _mountTemplate(): void {\n const result = this._component.templateResult;\n\n if (!result) return;\n\n this._applyResult(result);\n }\n\n private _scheduleMountCallbacks(): void {\n if (this._component.mountCallbacks.length === 0) return;\n\n const capturedGeneration = this._component.generation;\n\n queueMicrotask(() => {\n if (!this.isConnected || capturedGeneration !== this._component.generation) return;\n\n // Snapshot callbacks so in-loop registrations don't extend this iteration.\n const batch = this._component.mountCallbacks.splice(0);\n\n for (const callback of batch) {\n try {\n const nestedCtx = { element: this, mountCallbacks: [] as typeof this._component.mountCallbacks };\n\n this._component.scope.run(() => {\n runWithContext(nestedCtx, () => {\n const cleanup = callback();\n\n if (typeof cleanup === 'function') onCleanup(cleanup);\n });\n });\n\n if (nestedCtx.mountCallbacks.length > 0) {\n this._component.mountCallbacks.push(...nestedCtx.mountCallbacks);\n }\n } catch (error) {\n this._handleSetupError(error, 'mounted');\n }\n }\n\n // If nested onMounted calls registered new callbacks, schedule them with\n // a fresh token check in the next microtask.\n if (this._component.mountCallbacks.length > 0) {\n this._scheduleMountCallbacks();\n }\n });\n }\n}\n"],"mappings":"yQAwBA,IAAM,OAA8C,CAClD,WAAY,EACZ,eAAgB,CAAC,EACjB,MAAO,EAAA,eAAe,cACtB,OAAA,EAAA,EAAA,MAAA,CAAc,EACd,eAAgB,IAClB,GAIa,EAAb,cAAiC,WAAY,CAC3C,OAAO,YACP,OAAO,oBACP,OAAO,eAAiB,GACxB,OAAO,mBAA+B,CAAC,EAEvC,WAEA,aAAc,CACZ,MAAM,EAEN,IAAM,EAAO,KAAK,YAAmC,YAEjD,GAAK,SAAW,IAClB,KAAK,aAAa,CAAE,KAAM,OAAQ,GAAI,GAAK,MAA+C,CAAC,EAG7F,KAAK,WAAa,EAAqB,CACzC,CAEA,mBAA0B,EACxB,EAAA,EAAA,QAAA,KAAc,CACR,KAAK,WAAW,QAAU,EAAA,eAAe,eAAe,KAAK,UAAU,EAE3E,KAAK,MAAM,CACb,CAAC,EACD,KAAK,cAAc,IAAI,YAAY,EAAA,iBAAiB,QAAS,CAAE,QAAS,GAAO,SAAU,EAAM,CAAC,CAAC,CACnG,CAEA,yBAAyB,EAAc,EAAyB,EAA+B,CAC7F,GAAI,IAAa,EAAU,OAE3B,IAAM,EAAW,EAAA,YAAY,KAAM,CAAI,EAEvC,GAAI,CAAC,EAAU,OAEf,IAAM,EAAS,EAAS,MAAM,CAAQ,EAGnC,OAAO,IAAA,EAAA,EAAA,QAAA,KACQ,EAAS,OAAO,KAAK,EACnC,CACF,IAEA,EAAS,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,WAAW,MAAM,QAAU,CAC9B,EAAO,MAAM,EAAA,SAAS,CACxB,CAAC,EACH,CAEA,OAAsB,CACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EAGhB,KAAK,WAAW,QAAU,EAAA,eAAe,YAAY,KAAK,wBAAwB,CACxF,CAEA,cAA6B,CAC3B,IAAM,EAAO,KAAK,YAAmC,YAEjD,KAAK,YAAc,GAAK,QAAQ,SAClC,KAAK,WAAW,mBAAqB,EAAI,OAAO,IAAI,EAAA,cAAc,EAEtE,CAEA,gBAA+B,CAC7B,IAAM,EAAS,KAAK,WAAW,eAE1B,GAEL,KAAK,aAAa,CAAM,CAC1B,CAEA,yBAAwC,CACtC,GAAI,KAAK,WAAW,eAAe,SAAW,EAAG,OAEjD,IAAM,EAAqB,KAAK,WAAW,WAE3C,mBAAqB,CACnB,GAAI,CAAC,KAAK,aAAe,IAAuB,KAAK,WAAW,WAAY,OAG5E,IAAM,EAAQ,KAAK,WAAW,eAAe,OAAO,CAAC,EAErD,IAAK,IAAM,KAAY,EACrB,GAAI,CACF,IAAM,EAAY,CAAE,QAAS,KAAM,eAAgB,CAAC,CAA2C,EAE/F,KAAK,WAAW,MAAM,QAAU,CAC9B,EAAA,eAAe,MAAiB,CAC9B,IAAM,EAAU,EAAS,EAErB,OAAO,GAAY,YAAY,EAAA,UAAU,CAAO,CACtD,CAAC,CACH,CAAC,EAEG,EAAU,eAAe,OAAS,GACpC,KAAK,WAAW,eAAe,KAAK,GAAG,EAAU,cAAc,CAEnE,OAAS,EAAO,CACd,KAAK,kBAAkB,EAAO,SAAS,CACzC,CAKE,KAAK,WAAW,eAAe,OAAS,GAC1C,KAAK,wBAAwB,CAEjC,CAAC,CACH,CACF"}
@@ -0,0 +1,22 @@
1
+ import type { ComponentDefinition } from './component-types';
2
+ import { type PropsDef } from './props';
3
+ export declare class BaseElement extends HTMLElement {
4
+ static _definition: ComponentDefinition<any, any, any>;
5
+ static _normalizedPropDefs: PropsDef<Record<never, never>> | undefined;
6
+ static formAssociated: boolean;
7
+ static observedAttributes: string[];
8
+ private _component;
9
+ constructor();
10
+ connectedCallback(): void;
11
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
12
+ disconnectedCallback(): void;
13
+ private _handleSetupError;
14
+ private _runSetup;
15
+ private _runSetupAsync;
16
+ private _applyResult;
17
+ private _init;
18
+ private _applyStyles;
19
+ private _mountTemplate;
20
+ private _scheduleMountCallbacks;
21
+ }
22
+ //# sourceMappingURL=base-element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-element.d.ts","sourceRoot":"","sources":["../src/base-element.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAK7D,OAAO,EAAiE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AA2BvG,qBAAa,WAAY,SAAQ,WAAW;IAC1C,MAAM,CAAC,WAAW,EAAE,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACvD,MAAM,CAAC,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC;IACvE,MAAM,CAAC,cAAc,UAAS;IAC9B,MAAM,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAM;IAEzC,OAAO,CAAC,UAAU,CAAiB;;IAcnC,iBAAiB,IAAI,IAAI;IASzB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAkB9F,oBAAoB,IAAI,IAAI;IAY5B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,SAAS;YA0DH,cAAc;IAyC5B,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,KAAK;IAQb,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,uBAAuB;CAsChC"}
@@ -0,0 +1,2 @@
1
+ import{warn as e}from"./_dev.js";import{OreLifecycleError as t,reportRuntimeError as n}from"./errors.js";import"./types/bindings.js";import{onCleanup as r,runWithContext as i}from"./runtime.js";import{createContextBag as a}from"./context-bag.js";import{createProps as o,getPropMeta as s}from"./props.js";import{ComponentPhase as c,LIFECYCLE_EVENTS as l}from"./types.js";import{loadStylesheet as u}from"./utils/css.js";import{scope as d,untrack as f}from"@vielzeug/ripple";var p=()=>({generation:0,mountCallbacks:[],phase:c.UNINITIALIZED,scope:d(),templateResult:null}),m=class extends HTMLElement{static _definition;static _normalizedPropDefs;static formAssociated=!1;static observedAttributes=[];_component;constructor(){super();let e=this.constructor._definition;e?.shadow!==!1&&this.attachShadow({mode:`open`,...e?.shadow}),this._component=p()}connectedCallback(){f(()=>{this._component.phase===c.UNINITIALIZED&&this._runSetup(),this._init()}),this.dispatchEvent(new CustomEvent(l.CONNECT,{bubbles:!1,composed:!1}))}attributeChangedCallback(e,t,n){if(t===n)return;let r=s(this,e);if(!r)return;let i=r.parse(n);Object.is(f(()=>r.signal.value),i)||(r.signal.value=i)}disconnectedCallback(){this._component.generation++,this._component.phase=c.UNMOUNTED,this.dispatchEvent(new CustomEvent(l.DISCONNECT,{bubbles:!1,composed:!1})),this._component.scope.dispose(),this._component.mountCallbacks=[],this._component.phase=c.UNINITIALIZED,this._component.scope=d(),this._component.templateResult=null}_handleSetupError(e,r=`setup`){let i=e instanceof Error?e:Error(String(e)),a=new t(`<${this.localName}> failed during ${this._component.phase} (${r})`,{cause:i,component:this.localName,phase:r}),o=this.constructor._definition;if(o?.onError)try{return o.onError(a,this)}catch{}n(a,this)}_runSetup(){this._component.phase=c.SETUP_RUNNING;let e=this.constructor._definition,t=this.constructor._normalizedPropDefs,n={element:this,mountCallbacks:[]};try{let r;if(this._component.scope.run(()=>{r=i(n,()=>{let n=t?o(this,t):{},r=a(this);return e.setup(n,r)})}),this._component.mountCallbacks.push(...n.mountCallbacks),r!=null&&typeof r.then==`function`){let t=this._component.mountCallbacks.splice(0);this._component.phase=c.LOADING,e.loading&&(this._component.templateResult=e.loading()),this._runSetupAsync(r,t,this._component.generation)}else this._component.templateResult=r??null,this._component.phase=c.SETUP_DONE}catch(e){let t=this._handleSetupError(e);if(t)this._component.templateResult=t,this._component.phase=c.SETUP_DONE;else throw this._component.phase=c.UNINITIALIZED,e}}async _runSetupAsync(t,n,r){try{let i=await t;if(this._component.generation!==r||!this.isConnected){e(`<${this.localName}> async setup result discarded — element disconnected before setup resolved.`);return}this._component.templateResult=i??null,this._component.phase=c.SETUP_DONE,this._component.mountCallbacks.push(...n),i&&this._applyResult(i),this._scheduleMountCallbacks()}catch(t){if(this._component.generation!==r||!this.isConnected){e(`<${this.localName}> async setup error discarded — element disconnected before setup resolved.`);return}let n=this._handleSetupError(t,`async-setup`);n?(this._component.templateResult=n,this._component.phase=c.SETUP_DONE,this._applyResult(n)):this._component.phase=c.UNINITIALIZED}}_applyResult(e){e&&((this.shadowRoot??this).replaceChildren(e.fragment),this._component.scope.run(()=>{e.apply(r)}))}_init(){this._applyStyles(),this._mountTemplate(),this._component.phase===c.SETUP_DONE&&this._scheduleMountCallbacks()}_applyStyles(){let e=this.constructor._definition;this.shadowRoot&&e?.styles?.length&&(this.shadowRoot.adoptedStyleSheets=e.styles.map(u))}_mountTemplate(){let e=this._component.templateResult;e&&this._applyResult(e)}_scheduleMountCallbacks(){if(this._component.mountCallbacks.length===0)return;let e=this._component.generation;queueMicrotask(()=>{if(!this.isConnected||e!==this._component.generation)return;let t=this._component.mountCallbacks.splice(0);for(let e of t)try{let t={element:this,mountCallbacks:[]};this._component.scope.run(()=>{i(t,()=>{let t=e();typeof t==`function`&&r(t)})}),t.mountCallbacks.length>0&&this._component.mountCallbacks.push(...t.mountCallbacks)}catch(e){this._handleSetupError(e,`mounted`)}this._component.mountCallbacks.length>0&&this._scheduleMountCallbacks()})}};export{m as BaseElement};
2
+ //# sourceMappingURL=base-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-element.js","names":[],"sources":["../src/base-element.ts"],"sourcesContent":["import { scope as _scope, type Scope, untrack } from '@vielzeug/ripple';\n\nimport type { ComponentDefinition } from './component-types';\n\nimport { warn } from './_dev';\nimport { createContextBag } from './context-bag';\nimport { type OreErrorPhase, OreLifecycleError, reportRuntimeError } from './errors';\nimport { createProps, getPropMeta, type InferProps, type PropInputDefs, type PropsDef } from './props';\nimport { type OnMountedCallback, onCleanup, type RuntimeContext, runWithContext } from './runtime';\nimport { ComponentPhase, LIFECYCLE_EVENTS } from './types';\nimport { type HTMLResult } from './types/bindings';\nimport { loadStylesheet } from './utils/css';\n\n// ─── Internal component state ─────────────────────────────────────────────────\n\ntype ComponentState = {\n /** Incremented on every disconnect — guards both mount callbacks and async setup results. */\n generation: number;\n mountCallbacks: OnMountedCallback[];\n phase: ComponentPhase;\n scope: Scope;\n templateResult: HTMLResult | null;\n};\n\nconst createComponentState = (): ComponentState => ({\n generation: 0,\n mountCallbacks: [],\n phase: ComponentPhase.UNINITIALIZED,\n scope: _scope(),\n templateResult: null,\n});\n\n// ─── BaseElement ──────────────────────────────────────────────────────────────\n\nexport class BaseElement extends HTMLElement {\n static _definition: ComponentDefinition<any, any, any>;\n static _normalizedPropDefs: PropsDef<Record<never, never>> | undefined;\n static formAssociated = false;\n static observedAttributes: string[] = [];\n\n private _component: ComponentState;\n\n constructor() {\n super();\n\n const def = (this.constructor as typeof BaseElement)._definition;\n\n if (def?.shadow !== false) {\n this.attachShadow({ mode: 'open', ...(def?.shadow as Partial<ShadowRootInit> | undefined) });\n }\n\n this._component = createComponentState();\n }\n\n connectedCallback(): void {\n untrack(() => {\n if (this._component.phase === ComponentPhase.UNINITIALIZED) this._runSetup();\n\n this._init();\n });\n this.dispatchEvent(new CustomEvent(LIFECYCLE_EVENTS.CONNECT, { bubbles: false, composed: false }));\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n\n const propMeta = getPropMeta(this, name);\n\n if (!propMeta) return;\n\n const parsed = propMeta.parse(newValue);\n\n if (\n !Object.is(\n untrack(() => propMeta.signal.value),\n parsed,\n )\n )\n propMeta.signal.value = parsed as never;\n }\n\n disconnectedCallback(): void {\n this._component.generation++;\n this._component.phase = ComponentPhase.UNMOUNTED;\n this.dispatchEvent(new CustomEvent(LIFECYCLE_EVENTS.DISCONNECT, { bubbles: false, composed: false }));\n this._component.scope.dispose();\n // Reset mutable fields for next connect, keeping the same object for stable references\n this._component.mountCallbacks = [];\n this._component.phase = ComponentPhase.UNINITIALIZED;\n this._component.scope = _scope();\n this._component.templateResult = null;\n }\n\n private _handleSetupError(error: unknown, phase: OreErrorPhase = 'setup'): HTMLResult | void {\n const err = error instanceof Error ? error : new Error(String(error));\n const oreError = new OreLifecycleError(`<${this.localName}> failed during ${this._component.phase} (${phase})`, {\n cause: err,\n component: this.localName,\n phase,\n });\n const def = (this.constructor as typeof BaseElement)._definition;\n\n if (def?.onError) {\n try {\n return def.onError(oreError, this);\n } catch {\n /* fall through */\n }\n }\n\n reportRuntimeError(oreError, this);\n }\n\n private _runSetup(): void {\n this._component.phase = ComponentPhase.SETUP_RUNNING;\n\n const def = (this.constructor as typeof BaseElement)._definition;\n const normalizedPropDefs = (this.constructor as typeof BaseElement)._normalizedPropDefs;\n const ctx: RuntimeContext = { element: this, mountCallbacks: [] };\n\n try {\n let setupResult: HTMLResult | null | Promise<HTMLResult | null> | undefined;\n\n this._component.scope.run(() => {\n setupResult = runWithContext(ctx, () => {\n const setupProps = normalizedPropDefs\n ? createProps(this, normalizedPropDefs)\n : ({} as InferProps<PropInputDefs>);\n const contextBag = createContextBag(this);\n\n return def.setup(setupProps as InferProps<PropInputDefs>, contextBag);\n });\n });\n this._component.mountCallbacks.push(...ctx.mountCallbacks);\n\n if (setupResult != null && typeof (setupResult as Promise<HTMLResult | null>).then === 'function') {\n // Async setup: show loading template immediately, swap when resolved.\n // Store captured mount callbacks; they will be scheduled after the real template mounts.\n const pendingCallbacks = this._component.mountCallbacks.splice(0);\n\n this._component.phase = ComponentPhase.LOADING;\n\n if (def.loading) {\n this._component.templateResult = def.loading();\n }\n\n // Capture the current generation so the async handler can detect staleness:\n // if the element disconnects+reconnects before the promise resolves, generation is\n // incremented and the old promise result must be discarded.\n void this._runSetupAsync(\n setupResult as Promise<HTMLResult | null>,\n pendingCallbacks,\n this._component.generation,\n );\n } else {\n this._component.templateResult = (setupResult as HTMLResult | null) ?? null;\n this._component.phase = ComponentPhase.SETUP_DONE;\n }\n } catch (error) {\n const recoveryTemplate = this._handleSetupError(error);\n\n if (recoveryTemplate) {\n this._component.templateResult = recoveryTemplate;\n this._component.phase = ComponentPhase.SETUP_DONE;\n } else {\n this._component.phase = ComponentPhase.UNINITIALIZED;\n throw error;\n }\n }\n }\n\n private async _runSetupAsync(\n promise: Promise<HTMLResult | null>,\n pendingCallbacks: OnMountedCallback[],\n capturedGeneration: number,\n ): Promise<void> {\n try {\n const result = await promise;\n\n // Discard stale results: element disconnected+reconnected since this setup started.\n if (this._component.generation !== capturedGeneration || !this.isConnected) {\n warn(`<${this.localName}> async setup result discarded — element disconnected before setup resolved.`);\n\n return;\n }\n\n this._component.templateResult = result ?? null;\n this._component.phase = ComponentPhase.SETUP_DONE;\n this._component.mountCallbacks.push(...pendingCallbacks);\n\n if (result) this._applyResult(result);\n\n this._scheduleMountCallbacks();\n } catch (error) {\n if (this._component.generation !== capturedGeneration || !this.isConnected) {\n warn(`<${this.localName}> async setup error discarded — element disconnected before setup resolved.`);\n\n return;\n }\n\n const recovery = this._handleSetupError(error, 'async-setup');\n\n if (recovery) {\n this._component.templateResult = recovery;\n this._component.phase = ComponentPhase.SETUP_DONE;\n this._applyResult(recovery);\n } else {\n this._component.phase = ComponentPhase.UNINITIALIZED;\n }\n }\n }\n\n private _applyResult(result: HTMLResult | null): void {\n if (!result) return;\n\n const host: Element | ShadowRoot = this.shadowRoot ?? this;\n\n host.replaceChildren(result.fragment);\n this._component.scope.run(() => {\n result.apply(onCleanup);\n });\n }\n\n private _init(): void {\n this._applyStyles();\n this._mountTemplate();\n\n // Only schedule mount callbacks once setup is fully complete (not in LOADING state)\n if (this._component.phase === ComponentPhase.SETUP_DONE) this._scheduleMountCallbacks();\n }\n\n private _applyStyles(): void {\n const def = (this.constructor as typeof BaseElement)._definition;\n\n if (this.shadowRoot && def?.styles?.length) {\n this.shadowRoot.adoptedStyleSheets = def.styles.map(loadStylesheet);\n }\n }\n\n private _mountTemplate(): void {\n const result = this._component.templateResult;\n\n if (!result) return;\n\n this._applyResult(result);\n }\n\n private _scheduleMountCallbacks(): void {\n if (this._component.mountCallbacks.length === 0) return;\n\n const capturedGeneration = this._component.generation;\n\n queueMicrotask(() => {\n if (!this.isConnected || capturedGeneration !== this._component.generation) return;\n\n // Snapshot callbacks so in-loop registrations don't extend this iteration.\n const batch = this._component.mountCallbacks.splice(0);\n\n for (const callback of batch) {\n try {\n const nestedCtx = { element: this, mountCallbacks: [] as typeof this._component.mountCallbacks };\n\n this._component.scope.run(() => {\n runWithContext(nestedCtx, () => {\n const cleanup = callback();\n\n if (typeof cleanup === 'function') onCleanup(cleanup);\n });\n });\n\n if (nestedCtx.mountCallbacks.length > 0) {\n this._component.mountCallbacks.push(...nestedCtx.mountCallbacks);\n }\n } catch (error) {\n this._handleSetupError(error, 'mounted');\n }\n }\n\n // If nested onMounted calls registered new callbacks, schedule them with\n // a fresh token check in the next microtask.\n if (this._component.mountCallbacks.length > 0) {\n this._scheduleMountCallbacks();\n }\n });\n }\n}\n"],"mappings":"wdAwBA,IAAM,OAA8C,CAClD,WAAY,EACZ,eAAgB,CAAC,EACjB,MAAO,EAAe,cACtB,MAAO,EAAO,EACd,eAAgB,IAClB,GAIa,EAAb,cAAiC,WAAY,CAC3C,OAAO,YACP,OAAO,oBACP,OAAO,eAAiB,GACxB,OAAO,mBAA+B,CAAC,EAEvC,WAEA,aAAc,CACZ,MAAM,EAEN,IAAM,EAAO,KAAK,YAAm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EAEG,EAAU,eAAe,OAAS,GACpC,KAAK,WAAW,eAAe,KAAK,GAAG,EAAU,cAAc,CAEnE,OAAS,EAAO,CACd,KAAK,kBAAkB,EAAO,SAAS,CACzC,CAKE,KAAK,WAAW,eAAe,OAAS,GAC1C,KAAK,wBAAwB,CAEjC,CAAC,CACH,CACF"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Public component definition types for ore web components.
3
+ * These are the types consumers interact with when calling define().
4
+ */
5
+ import type { CleanupFn, EffectCallback, Readable } from '@vielzeug/ripple';
6
+ import type { AriaConfig } from './aria';
7
+ import type { InjectionKey } from './context';
8
+ import type { OreLifecycleError } from './errors';
9
+ import type { BindOptions, HostBindConfig } from './host-bind';
10
+ import type { InferProps, PropsDef } from './props';
11
+ import type { OnMountedCallback } from './runtime';
12
+ import type { ComponentSlots } from './slots';
13
+ import type { HTMLResult } from './types/bindings';
14
+ import type { CSSResult } from './utils/css';
15
+ import type { EmitFn } from './utils/emit';
16
+ /**
17
+ * The context bag passed as the second argument to `setup()`.
18
+ * Contains everything you need to build a component — bindings, lifecycle hooks,
19
+ * context injection, and slot signals — all in one place.
20
+ */
21
+ export type SetupContextBag<Emits extends Record<string, unknown> = Record<string, never>, SlotNames extends string = string> = {
22
+ /**
23
+ * Reactively sync ARIA attributes on any element, auto-cleanup on component disconnect.
24
+ * Returns a cleanup function that removes all reactive ARIA bindings.
25
+ */
26
+ aria: (target: Element, config: AriaConfig) => () => void;
27
+ /**
28
+ * Apply reactive or static bindings to an element's attributes, classes, styles, and events.
29
+ * Defaults to the host element. Pass `options.target` to bind to any other element
30
+ * (e.g. a slotted trigger, an internally-referenced child).
31
+ */
32
+ bind: (config: HostBindConfig, options?: BindOptions) => () => void;
33
+ /** The component's host element. */
34
+ el: HTMLElement;
35
+ /** Dispatch a typed custom event from the host element. */
36
+ emit: EmitFn<Emits>;
37
+ /**
38
+ * Resolve an injected context value from a providing ancestor.
39
+ * Walks the DOM tree (including shadow boundaries) to find the nearest
40
+ * element that called `ctx.provide()` with the given key.
41
+ */
42
+ inject: {
43
+ <T>(key: InjectionKey<T>): T | undefined;
44
+ <T>(key: InjectionKey<T>, fallback: T): T;
45
+ };
46
+ /**
47
+ * Register a cleanup function to run on component disconnect.
48
+ * All registered functions run when the element leaves the DOM.
49
+ */
50
+ onCleanup: (fn: CleanupFn) => void;
51
+ /**
52
+ * Watch a ref signal and run a callback when it resolves to a non-null element.
53
+ * The callback's return value is used as a cleanup function.
54
+ */
55
+ onElement: <T extends HTMLElement>(ref: Readable<T | null>, callback: (el: T) => CleanupFn | undefined | void) => () => void;
56
+ /**
57
+ * Attach a scoped event listener that is automatically removed on component disconnect.
58
+ * Silently no-ops when `target` is `null` or `undefined`.
59
+ */
60
+ onEvent: {
61
+ <K extends keyof HTMLElementEventMap>(target: EventTarget | null | undefined, event: K, listener: (e: HTMLElementEventMap[K]) => void, options?: AddEventListenerOptions): void;
62
+ (target: EventTarget | null | undefined, event: string, listener: EventListener, options?: AddEventListenerOptions): void;
63
+ };
64
+ /**
65
+ * Register work to run after the component template mounts to the DOM.
66
+ * Multiple callbacks run in registration order.
67
+ */
68
+ onMounted: (fn: OnMountedCallback) => void;
69
+ /**
70
+ * Register a context value on the host element, making it available to
71
+ * descendant components via `ctx.inject(key)`.
72
+ */
73
+ provide: <T>(key: InjectionKey<T>, value: T) => void;
74
+ /** Reactive slot presence / element signals. */
75
+ slots: ComponentSlots<SlotNames>;
76
+ /**
77
+ * Create a reactive effect scoped to the component lifecycle.
78
+ * Automatically cleaned up on component disconnect.
79
+ * Returns a stop function that disposes the effect immediately.
80
+ */
81
+ watch: (fn: EffectCallback) => () => void;
82
+ };
83
+ export type ComponentDefinition<Props extends Record<string, unknown> = Record<never, never>, Emits extends Record<string, unknown> = Record<string, never>, SlotNames extends string = string> = {
84
+ formAssociated?: boolean;
85
+ /**
86
+ * Rendered while async `setup()` is still pending.
87
+ * Only used when `setup` returns a `Promise`.
88
+ */
89
+ loading?: () => HTMLResult;
90
+ /**
91
+ * Error handler called when setup throws.
92
+ * If a recovery HTMLResult is returned, it replaces the failed template.
93
+ */
94
+ onError?: (error: OreLifecycleError, element: HTMLElement) => HTMLResult | void;
95
+ props?: PropsDef<Props>;
96
+ setup: (props: InferProps<PropsDef<Props>>, ctx: SetupContextBag<Emits, SlotNames>) => HTMLResult | null | Promise<HTMLResult | null>;
97
+ /**
98
+ * Shadow DOM configuration. `mode` defaults to `'open'`.
99
+ * Set to `false` to opt out of shadow DOM entirely (light DOM rendering).
100
+ */
101
+ shadow?: Partial<ShadowRootInit> | false;
102
+ styles?: (string | CSSStyleSheet | CSSResult)[];
103
+ };
104
+ //# sourceMappingURL=component-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-types.d.ts","sourceRoot":"","sources":["../src/component-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;;GAIG;AACH,MAAM,MAAM,eAAe,CACz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AG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACpD;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC;IACzC,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC;CACjD,CAAC"}
@@ -0,0 +1,2 @@
1
+ const e=require("./runtime.cjs"),t=require("./aria.cjs"),n=require("./context.cjs"),r=require("./host-bind.cjs"),i=require("./slots.cjs"),a=require("./utils/emit.cjs");var o=o=>{let s=i.createSlots(o),c=r.createBind(o);return{aria:t.createAriaFn(),bind:c,el:o,emit:a.createEmitFn(o),inject:n.inject,onCleanup:e.onCleanup,onElement:e.onElement,onEvent:e.onEvent,onMounted:e.onMounted,provide:(e,t)=>n.provideOnElement(o,e,t),slots:s,watch:e.effect}};exports.createContextBag=o;
2
+ //# sourceMappingURL=context-bag.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-bag.cjs","names":[],"sources":["../src/context-bag.ts"],"sourcesContent":["/**\n * Factory for the SetupContextBag — shared between BaseElement and renderHook.\n * Keeps the real component lifecycle and the test harness in sync automatically.\n */\n\nimport type { SetupContextBag } from './component-types';\nimport type { InjectionKey } from './context';\n\nimport { createAriaFn } from './aria';\nimport { inject, provideOnElement } from './context';\nimport { createBind } from './host-bind';\nimport { effect, onCleanup, onElement, onEvent, onMounted, type OnMountedCallback } from './runtime';\nimport { type ComponentSlots, createSlots } from './slots';\nimport { createEmitFn } from './utils/emit';\n\nexport type ContextBagInit = {\n el: HTMLElement;\n mountCallbacks: OnMountedCallback[];\n};\n\nexport const createContextBag = (el: HTMLElement): SetupContextBag<Record<string, never>, string> => {\n const slots = createSlots(el) as ComponentSlots<string>;\n\n const bind = createBind(el);\n\n return {\n aria: createAriaFn(),\n bind,\n el,\n emit: createEmitFn(el),\n inject,\n onCleanup,\n onElement,\n onEvent,\n onMounted,\n provide: <T>(key: InjectionKey<T>, value: T) => provideOnElement(el, key, value),\n slots,\n watch: effect,\n };\n};\n"],"mappings":"wKAoBA,IAAa,EAAoB,GAAoE,CACnG,IAAM,EAAQ,EAAA,YAAY,CAAE,EAEtB,EAAO,EAAA,WAAW,CAAE,EAE1B,MAAO,CACL,KAAM,EAAA,aAAa,EACnB,OACA,KACA,KAAM,EAAA,aAAa,CAAE,EACrB,OAAA,EAAA,OACA,UAAA,EAAA,UACA,UAAA,EAAA,UACA,QAAA,EAAA,QACA,UAAA,EAAA,UACA,SAAa,EAAsB,IAAa,EAAA,iBAAiB,EAAI,EAAK,CAAK,EAC/E,QACA,MAAO,EAAA,MACT,CACF"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Factory for the SetupContextBag — shared between BaseElement and renderHook.
3
+ * Keeps the real component lifecycle and the test harness in sync automatically.
4
+ */
5
+ import type { SetupContextBag } from './component-types';
6
+ import { type OnMountedCallback } from './runtime';
7
+ export type ContextBagInit = {
8
+ el: HTMLElement;
9
+ mountCallbacks: OnMountedCallback[];
10
+ };
11
+ export declare const createContextBag: (el: HTMLElement) => SetupContextBag<Record<string, never>, string>;
12
+ //# sourceMappingURL=context-bag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-bag.d.ts","sourceRoot":"","sources":["../src/context-bag.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMzD,OAAO,EAAoD,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAIrG,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,WAAW,CAAC;IAChB,cAAc,EAAE,iBAAiB,EAAE,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,IAAI,WAAW,KAAG,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAmB/F,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{effect as e,onCleanup as t,onElement as n,onEvent as r,onMounted as i}from"./runtime.js";import{createAriaFn as a}from"./aria.js";import{inject as o,provideOnElement as s}from"./context.js";import{createBind as c}from"./host-bind.js";import{createSlots as l}from"./slots.js";import{createEmitFn as u}from"./utils/emit.js";var d=d=>{let f=l(d),p=c(d);return{aria:a(),bind:p,el:d,emit:u(d),inject:o,onCleanup:t,onElement:n,onEvent:r,onMounted:i,provide:(e,t)=>s(d,e,t),slots:f,watch:e}};export{d as createContextBag};
2
+ //# sourceMappingURL=context-bag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-bag.js","names":[],"sources":["../src/context-bag.ts"],"sourcesContent":["/**\n * Factory for the SetupContextBag — shared between BaseElement and renderHook.\n * Keeps the real component lifecycle and the test harness in sync automatically.\n */\n\nimport type { SetupContextBag } from './component-types';\nimport type { InjectionKey } from './context';\n\nimport { createAriaFn } from './aria';\nimport { inject, provideOnElement } from './context';\nimport { createBind } from './host-bind';\nimport { effect, onCleanup, onElement, onEvent, onMounted, type OnMountedCallback } from './runtime';\nimport { type ComponentSlots, createSlots } from './slots';\nimport { createEmitFn } from './utils/emit';\n\nexport type ContextBagInit = {\n el: HTMLElement;\n mountCallbacks: OnMountedCallback[];\n};\n\nexport const createContextBag = (el: HTMLElement): SetupContextBag<Record<string, never>, string> => {\n const slots = createSlots(el) as ComponentSlots<string>;\n\n const bind = createBind(el);\n\n return {\n aria: createAriaFn(),\n bind,\n el,\n emit: createEmitFn(el),\n inject,\n onCleanup,\n onElement,\n onEvent,\n onMounted,\n provide: <T>(key: InjectionKey<T>, value: T) => provideOnElement(el, key, value),\n slots,\n watch: effect,\n };\n};\n"],"mappings":"yUAoBA,IAAa,EAAoB,GAAoE,CACnG,IAAM,EAAQ,EAAY,CAAE,EAEtB,EAAO,EAAW,CAAE,EAE1B,MAAO,CACL,KAAM,EAAa,EACnB,OACA,KACA,KAAM,EAAa,CAAE,EACrB,SACA,YACA,YACA,UACA,YACA,SAAa,EAAsB,IAAa,EAAiB,EAAI,EAAK,CAAK,EAC/E,QACA,MAAO,CACT,CACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("./errors.cjs"),t=require("./runtime.cjs");var n=new WeakMap,r=e=>{let t=[],n=e;for(;n;){n instanceof HTMLElement&&t.push(n);let e=n.getRootNode();n=n.parentElement??(e instanceof ShadowRoot?e.host:null)}return t},i=(e,t,r)=>{n.has(e)||n.set(e,new Map),n.get(e).set(t,r)},a=Symbol(`inject.not_found`),o=new WeakMap,s=(e,t)=>{let i=r(e);for(let e of i){let r=n.get(e);if(r?.has(t))return r.get(t)}return a};function c(n,...r){let i=t.getSetupContext();if(!i)throw new e.OreApiError(e.ORE_ERRORS.lifecycleOutsideSetup);let c=o.get(i);c||(c=new Map,o.set(i,c));let l=n;if(c.has(l)){let e=c.get(l);return e===a?r.length>0?r[0]:void 0:e}let u=s(i.element,n);return c.set(l,u),u===a?r.length>0?r[0]:void 0:u}var l=n=>{let r=c(n,a);if(r!==a)return r;let i=t.getCurrentElement();throw new e.OreApiError(e.ORE_ERRORS.injectStrictFailed(String(n),i.localName))};function u(e){return Symbol(e)}exports.createContext=u,exports.inject=c,exports.injectStrict=l,exports.provideOnElement=i;
2
+ //# sourceMappingURL=context.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.cjs","names":[],"sources":["../src/context.ts"],"sourcesContent":["/**\n * Component context injection API — `inject` / `injectStrict` / `createContext`.\n *\n * Context values are stored on the providing element via a WeakMap registry and\n * resolved by walking up the DOM tree (including through shadow boundaries).\n * Providing is done via `ctx.provide(key, value)` inside `setup()`.\n */\n\nimport { OreApiError, ORE_ERRORS } from './errors';\nimport { getSetupContext, getCurrentElement } from './runtime';\n\nconst contextRegistry = new WeakMap<HTMLElement, Map<InjectionKey<unknown>, unknown>>();\n\nexport type InjectionKey<T> = symbol & {\n readonly __ore_injection_key?: T;\n};\n\n/** @internal Build a linear ancestor chain (including shadow host boundaries). */\nconst buildAncestorChain = (start: HTMLElement): HTMLElement[] => {\n const chain: HTMLElement[] = [];\n let node: Node | null = start;\n\n while (node) {\n if (node instanceof HTMLElement) chain.push(node);\n\n const root = node.getRootNode() as Node;\n\n node = (node as HTMLElement).parentElement ?? (root instanceof ShadowRoot ? root.host : null);\n }\n\n return chain;\n};\n\n/**\n * Register a context value on a specific element.\n * @internal Used by ctx.provide() — do not call directly.\n */\nexport const provideOnElement = <T>(el: HTMLElement, key: InjectionKey<T>, value: T): void => {\n if (!contextRegistry.has(el)) contextRegistry.set(el, new Map());\n\n contextRegistry.get(el)!.set(key, value);\n};\n\nconst NOT_FOUND_SENTINEL = Symbol('inject.not_found');\n\n/** Per-setup-context cache: avoids repeated ancestor walks for the same key. */\nconst resolvedCache = new WeakMap<object, Map<InjectionKey<unknown>, unknown>>();\n\nconst walkAndFind = <T>(element: HTMLElement, key: InjectionKey<T>): T | typeof NOT_FOUND_SENTINEL => {\n const chain = buildAncestorChain(element);\n\n for (const node of chain) {\n const map = contextRegistry.get(node);\n\n if (map?.has(key)) return map.get(key) as T;\n }\n\n return NOT_FOUND_SENTINEL;\n};\n\nexport function inject<T>(key: InjectionKey<T>): T | undefined;\nexport function inject<T>(key: InjectionKey<T>, fallback: T): T;\nexport function inject<T>(key: InjectionKey<T>, ...rest: [T?]): T | undefined {\n const ctx = getSetupContext();\n\n if (!ctx) throw new OreApiError(ORE_ERRORS.lifecycleOutsideSetup);\n\n let cache = resolvedCache.get(ctx);\n\n if (!cache) {\n cache = new Map();\n resolvedCache.set(ctx, cache);\n }\n\n const cacheKey = key as InjectionKey<unknown>;\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey);\n\n if (cached === NOT_FOUND_SENTINEL) return rest.length > 0 ? rest[0] : undefined;\n\n return cached as T;\n }\n\n const found = walkAndFind(ctx.element, key);\n\n cache.set(cacheKey, found);\n\n if (found === NOT_FOUND_SENTINEL) return rest.length > 0 ? rest[0] : undefined;\n\n return found;\n}\n\nexport const injectStrict = <T>(key: InjectionKey<T>): T => {\n const resolved = inject<T>(key, NOT_FOUND_SENTINEL as unknown as T);\n\n if (resolved !== (NOT_FOUND_SENTINEL as unknown)) return resolved;\n\n const host = getCurrentElement();\n\n throw new OreApiError(ORE_ERRORS.injectStrictFailed(String(key), host.localName));\n};\n\nexport function createContext<T>(description?: string): InjectionKey<T> {\n return Symbol(description) as InjectionKey<T>;\n}\n"],"mappings":"2DAWA,IAAM,EAAkB,IAAI,QAOtB,EAAsB,GAAsC,CAChE,IAAM,EAAuB,CAAC,EAC1B,EAAoB,EAExB,KAAO,GAAM,CACP,aAAgB,aAAa,EAAM,KAAK,CAAI,EAEhD,IAAM,EAAO,EAAK,YAAY,EAE9B,EAAQ,EAAqB,gBAAkB,aAAgB,WAAa,EAAK,KAAO,KAC1F,CAEA,OAAO,CACT,EAMa,GAAuB,EAAiB,EAAsB,IAAmB,CACvF,EAAgB,IAAI,CAAE,GAAG,EAAgB,IAAI,EAAI,IAAI,GAAK,EAE/D,EAAgB,IAAI,CAAE,CAAC,CAAE,IAAI,EAAK,CAAK,CACzC,EAEM,EAAqB,OAAO,kBAAkB,EAG9C,EAAgB,IAAI,QAEpB,GAAkB,EAAsB,IAAwD,CACpG,IAAM,EAAQ,EAAmB,CAAO,EAExC,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAM,EAAgB,IAAI,CAAI,EAEpC,GAAI,GAAK,IAAI,CAAG,EAAG,OAAO,EAAI,IAAI,CAAG,CACvC,CAEA,OAAO,CACT,EAIA,SAAgB,EAAU,EAAsB,GAAG,EAA2B,CAC5E,IAAM,EAAM,EAAA,gBAAgB,EAE5B,GAAI,CAAC,EAAK,MAAM,IAAI,EAAA,YAAY,EAAA,WAAW,qBAAqB,EAEhE,IAAI,EAAQ,EAAc,IAAI,CAAG,EAE5B,IACH,EAAQ,IAAI,IACZ,EAAc,IAAI,EAAK,CAAK,GAG9B,IAAM,EAAW,EAEjB,GAAI,EAAM,IAAI,CAAQ,EAAG,CACvB,IAAM,EAAS,EAAM,IAAI,CAAQ,EAIjC,OAFI,IAAW,EAA2B,EAAK,OAAS,EAAI,EAAK,GAAK,IAAA,GAE/D,CACT,CAEA,IAAM,EAAQ,EAAY,EAAI,QAAS,CAAG,EAM1C,OAJA,EAAM,IAAI,EAAU,CAAK,EAErB,IAAU,EAA2B,EAAK,OAAS,EAAI,EAAK,GAAK,IAAA,GAE9D,CACT,CAEA,IAAa,EAAmB,GAA4B,CAC1D,IAAM,EAAW,EAAU,EAAK,CAAkC,EAElE,GAAI,IAAc,EAAgC,OAAO,EAEzD,IAAM,EAAO,EAAA,kBAAkB,EAE/B,MAAM,IAAI,EAAA,YAAY,EAAA,WAAW,mBAAmB,OAAO,CAAG,EAAG,EAAK,SAAS,CAAC,CAClF,EAEA,SAAgB,EAAiB,EAAuC,CACtE,OAAO,OAAO,CAAW,CAC3B"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Component context injection API — `inject` / `injectStrict` / `createContext`.
3
+ *
4
+ * Context values are stored on the providing element via a WeakMap registry and
5
+ * resolved by walking up the DOM tree (including through shadow boundaries).
6
+ * Providing is done via `ctx.provide(key, value)` inside `setup()`.
7
+ */
8
+ export type InjectionKey<T> = symbol & {
9
+ readonly __ore_injection_key?: T;
10
+ };
11
+ export declare function inject<T>(key: InjectionKey<T>): T | undefined;
12
+ export declare function inject<T>(key: InjectionKey<T>, fallback: T): T;
13
+ export declare const injectStrict: <T>(key: InjectionKey<T>) => T;
14
+ export declare function createContext<T>(description?: string): InjectionKey<T>;
15
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,MAAM,GAAG;IACrC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;CAClC,CAAC;AA6CF,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;AAC/D,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;AAgChE,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,KAAK,YAAY,CAAC,CAAC,CAAC,KAAG,CAQtD,CAAC;AAEF,wBAAgB,aAAa,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAEtE"}
@@ -0,0 +1,2 @@
1
+ import{ORE_ERRORS as e,OreApiError as t}from"./errors.js";import{getCurrentElement as n,getSetupContext as r}from"./runtime.js";var i=new WeakMap,a=e=>{let t=[],n=e;for(;n;){n instanceof HTMLElement&&t.push(n);let e=n.getRootNode();n=n.parentElement??(e instanceof ShadowRoot?e.host:null)}return t},o=(e,t,n)=>{i.has(e)||i.set(e,new Map),i.get(e).set(t,n)},s=Symbol(`inject.not_found`),c=new WeakMap,l=(e,t)=>{let n=a(e);for(let e of n){let n=i.get(e);if(n?.has(t))return n.get(t)}return s};function u(n,...i){let a=r();if(!a)throw new t(e.lifecycleOutsideSetup);let o=c.get(a);o||(o=new Map,c.set(a,o));let u=n;if(o.has(u)){let e=o.get(u);return e===s?i.length>0?i[0]:void 0:e}let d=l(a.element,n);return o.set(u,d),d===s?i.length>0?i[0]:void 0:d}var d=r=>{let i=u(r,s);if(i!==s)return i;let a=n();throw new t(e.injectStrictFailed(String(r),a.localName))};function f(e){return Symbol(e)}export{f as createContext,u as inject,d as injectStrict,o as provideOnElement};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","names":[],"sources":["../src/context.ts"],"sourcesContent":["/**\n * Component context injection API — `inject` / `injectStrict` / `createContext`.\n *\n * Context values are stored on the providing element via a WeakMap registry and\n * resolved by walking up the DOM tree (including through shadow boundaries).\n * Providing is done via `ctx.provide(key, value)` inside `setup()`.\n */\n\nimport { OreApiError, ORE_ERRORS } from './errors';\nimport { getSetupContext, getCurrentElement } from './runtime';\n\nconst contextRegistry = new WeakMap<HTMLElement, Map<InjectionKey<unknown>, unknown>>();\n\nexport type InjectionKey<T> = symbol & {\n readonly __ore_injection_key?: T;\n};\n\n/** @internal Build a linear ancestor chain (including shadow host boundaries). */\nconst buildAncestorChain = (start: HTMLElement): HTMLElement[] => {\n const chain: HTMLElement[] = [];\n let node: Node | null = start;\n\n while (node) {\n if (node instanceof HTMLElement) chain.push(node);\n\n const root = node.getRootNode() as Node;\n\n node = (node as HTMLElement).parentElement ?? (root instanceof ShadowRoot ? root.host : null);\n }\n\n return chain;\n};\n\n/**\n * Register a context value on a specific element.\n * @internal Used by ctx.provide() — do not call directly.\n */\nexport const provideOnElement = <T>(el: HTMLElement, key: InjectionKey<T>, value: T): void => {\n if (!contextRegistry.has(el)) contextRegistry.set(el, new Map());\n\n contextRegistry.get(el)!.set(key, value);\n};\n\nconst NOT_FOUND_SENTINEL = Symbol('inject.not_found');\n\n/** Per-setup-context cache: avoids repeated ancestor walks for the same key. */\nconst resolvedCache = new WeakMap<object, Map<InjectionKey<unknown>, unknown>>();\n\nconst walkAndFind = <T>(element: HTMLElement, key: InjectionKey<T>): T | typeof NOT_FOUND_SENTINEL => {\n const chain = buildAncestorChain(element);\n\n for (const node of chain) {\n const map = contextRegistry.get(node);\n\n if (map?.has(key)) return map.get(key) as T;\n }\n\n return NOT_FOUND_SENTINEL;\n};\n\nexport function inject<T>(key: InjectionKey<T>): T | undefined;\nexport function inject<T>(key: InjectionKey<T>, fallback: T): T;\nexport function inject<T>(key: InjectionKey<T>, ...rest: [T?]): T | undefined {\n const ctx = getSetupContext();\n\n if (!ctx) throw new OreApiError(ORE_ERRORS.lifecycleOutsideSetup);\n\n let cache = resolvedCache.get(ctx);\n\n if (!cache) {\n cache = new Map();\n resolvedCache.set(ctx, cache);\n }\n\n const cacheKey = key as InjectionKey<unknown>;\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey);\n\n if (cached === NOT_FOUND_SENTINEL) return rest.length > 0 ? rest[0] : undefined;\n\n return cached as T;\n }\n\n const found = walkAndFind(ctx.element, key);\n\n cache.set(cacheKey, found);\n\n if (found === NOT_FOUND_SENTINEL) return rest.length > 0 ? rest[0] : undefined;\n\n return found;\n}\n\nexport const injectStrict = <T>(key: InjectionKey<T>): T => {\n const resolved = inject<T>(key, NOT_FOUND_SENTINEL as unknown as T);\n\n if (resolved !== (NOT_FOUND_SENTINEL as unknown)) return resolved;\n\n const host = getCurrentElement();\n\n throw new OreApiError(ORE_ERRORS.injectStrictFailed(String(key), host.localName));\n};\n\nexport function createContext<T>(description?: string): InjectionKey<T> {\n return Symbol(description) as InjectionKey<T>;\n}\n"],"mappings":"gIAWA,IAAM,EAAkB,IAAI,QAOtB,EAAsB,GAAsC,CAChE,IAAM,EAAuB,CAAC,EAC1B,EAAoB,EAExB,KAAO,GAAM,CACP,aAAgB,aAAa,EAAM,KAAK,CAAI,EAEhD,IAAM,EAAO,EAAK,YAAY,EAE9B,EAAQ,EAAqB,gBAAkB,aAAgB,WAAa,EAAK,KAAO,KAC1F,CAEA,OAAO,CACT,EAMa,GAAuB,EAAiB,EAAsB,IAAmB,CACvF,EAAgB,IAAI,CAAE,GAAG,EAAgB,IAAI,EAAI,IAAI,GAAK,EAE/D,EAAgB,IAAI,CAAE,CAAC,CAAE,IAAI,EAAK,CAAK,CACzC,EAEM,EAAqB,OAAO,kBAAkB,EAG9C,EAAgB,IAAI,QAEpB,GAAkB,EAAsB,IAAwD,CACpG,IAAM,EAAQ,EAAmB,CAAO,EAExC,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAM,EAAgB,IAAI,CAAI,EAEpC,GAAI,GAAK,IAAI,CAAG,EAAG,OAAO,EAAI,IAAI,CAAG,CACvC,CAEA,OAAO,CACT,EAIA,SAAgB,EAAU,EAAsB,GAAG,EAA2B,CAC5E,IAAM,EAAM,EAAgB,EAE5B,GAAI,CAAC,EAAK,MAAM,IAAI,EAAY,EAAW,qBAAqB,EAEhE,IAAI,EAAQ,EAAc,IAAI,CAAG,EAE5B,IACH,EAAQ,IAAI,IACZ,EAAc,IAAI,EAAK,CAAK,GAG9B,IAAM,EAAW,EAEjB,GAAI,EAAM,IAAI,CAAQ,EAAG,CACvB,IAAM,EAAS,EAAM,IAAI,CAAQ,EAIjC,OAFI,IAAW,EAA2B,EAAK,OAAS,EAAI,EAAK,GAAK,IAAA,GAE/D,CACT,CAEA,IAAM,EAAQ,EAAY,EAAI,QAAS,CAAG,EAM1C,OAJA,EAAM,IAAI,EAAU,CAAK,EAErB,IAAU,EAA2B,EAAK,OAAS,EAAI,EAAK,GAAK,IAAA,GAE9D,CACT,CAEA,IAAa,EAAmB,GAA4B,CAC1D,IAAM,EAAW,EAAU,EAAK,CAAkC,EAElE,GAAI,IAAc,EAAgC,OAAO,EAEzD,IAAM,EAAO,EAAkB,EAE/B,MAAM,IAAI,EAAY,EAAW,mBAAmB,OAAO,CAAG,EAAG,EAAK,SAAS,CAAC,CAClF,EAEA,SAAgB,EAAiB,EAAuC,CACtE,OAAO,OAAO,CAAW,CAC3B"}
@@ -0,0 +1,2 @@
1
+ const e=require("./errors.cjs"),t=require("./utils/dom.cjs"),n=require("./props.cjs"),r=require("./base-element.cjs");function i(i,a){if(!i)throw new e.OreApiError(e.ORE_ERRORS.defineRequiresTag);if(customElements.get(i))throw new e.OreApiError(e.ORE_ERRORS.defineDuplicate(i));let{props:o}=a,s=(()=>{if(!o)return;let t=n.validatePropDefs(o);if(t.length>0)throw new e.OreApiError(e.ORE_ERRORS.validationFailed(i,t));let r={};for(let[e,t]of Object.entries(o))r[e]=n.normalizePropDefinition(t,e);return r})(),c=s?Object.keys(s).map(t.toKebab):[],l=class extends r.BaseElement{static _definition=a;static _normalizedPropDefs=s;static formAssociated=a.formAssociated??!1;static observedAttributes=c};Object.defineProperty(l,"name",{value:i}),customElements.define(i,l)}exports.define=i,exports.prop=n.prop;
2
+ //# sourceMappingURL=define.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.cjs","names":[],"sources":["../src/define.ts"],"sourcesContent":["import type { ComponentDefinition } from './component-types';\n\nimport { BaseElement } from './base-element';\nimport { OreApiError, ORE_ERRORS } from './errors';\nimport {\n type InferProps,\n normalizePropDefinition,\n prop,\n type PropDef,\n type PropInputDefs,\n type PropsDef,\n validatePropDefs,\n} from './props';\nimport { toKebab } from './utils/dom';\n\nexport { prop };\nexport type { InferProps, PropDef, PropInputDefs, PropsDef };\nexport type { HostBindFn } from './host-bind';\n\n/**\n * Define and register a web component.\n *\n * The `setup` function runs once per instance on first connect and returns an\n * `HTMLResult`. All reactive behaviour is expressed through reactive directives\n * inside the template — not by re-evaluating setup itself.\n *\n * Pass a `SlotNames` type parameter to get typed `ctx.slots` access:\n * ```ts\n * define<Record<never, never>, Record<never, never>, 'header' | 'footer'>('my-card', {\n * setup(_props, { slots }) {\n * const hasHeader = slots.has('header'); // typed ✓\n * },\n * });\n * ```\n *\n * @example\n * ```ts\n * define('my-counter', {\n * props: { count: prop.number(0) },\n * setup(props) {\n * return html`<button @click=${() => props.count.value++}>${props.count}</button>`;\n * },\n * });\n * ```\n */\nexport function define<\n Props extends Record<string, unknown> = Record<never, never>,\n Emits extends Record<string, unknown> = Record<string, never>,\n const SlotNames extends string = string,\n>(tag: string, definition: ComponentDefinition<Props, Emits, SlotNames>): void {\n if (!tag) throw new OreApiError(ORE_ERRORS.defineRequiresTag);\n\n if (customElements.get(tag)) throw new OreApiError(ORE_ERRORS.defineDuplicate(tag));\n\n const { props: propDefs } = definition;\n\n const normalizedPropDefs: PropsDef<Props> | undefined = (() => {\n if (!propDefs) return undefined;\n\n const errors = validatePropDefs(propDefs as Record<string, unknown>);\n\n if (errors.length > 0) throw new OreApiError(ORE_ERRORS.validationFailed(tag, errors));\n\n const normalized: PropInputDefs = {};\n\n for (const [key, def] of Object.entries(propDefs)) {\n normalized[key] = normalizePropDefinition(def, key);\n }\n\n return normalized as PropsDef<Props>;\n })();\n\n const observedAttrs = normalizedPropDefs ? Object.keys(normalizedPropDefs).map(toKebab) : [];\n\n // Named class for DevTools and error messages\n const ComponentClass = class extends BaseElement {\n static override _definition = definition as ComponentDefinition<any, any, any>;\n static override _normalizedPropDefs = normalizedPropDefs as PropsDef<Record<never, never>> | undefined;\n static override formAssociated = definition.formAssociated ?? false;\n static override observedAttributes = observedAttrs;\n };\n\n Object.defineProperty(ComponentClass, 'name', { value: tag });\n customElements.define(tag, ComponentClass);\n}\n"],"mappings":"sHA6CA,SAAgB,EAId,EAAa,EAAgE,CAC7E,GAAI,CAAC,EAAK,MAAM,IAAI,EAAA,YAAY,EAAA,WAAW,iBAAiB,EAE5D,GAAI,eAAe,IAAI,CAAG,EAAG,MAAM,IAAI,EAAA,YAAY,EAAA,WAAW,gBAAgB,CAAG,CAAC,EAElF,GAAM,CAAE,MAAO,GAAa,EAEtB,OAAyD,CAC7D,GAAI,CAAC,EAAU,OAEf,IAAM,EAAS,EAAA,iBAAiB,CAAmC,EAEnE,GAAI,EAAO,OAAS,EAAG,MAAM,IAAI,EAAA,YAAY,EAAA,WAAW,iBAAiB,EAAK,CAAM,CAAC,EAErF,IAAM,EAA4B,CAAC,EAEnC,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAQ,EAC9C,EAAW,GAAO,EAAA,wBAAwB,EAAK,CAAG,EAGpD,OAAO,CACT,EAAA,CAAG,EAEG,EAAgB,EAAqB,OAAO,KAAK,CAAkB,CAAC,CAAC,IAAI,EAAA,OAAO,EAAI,CAAC,EAGrF,EAAiB,cAAc,EAAA,WAAY,CAC/C,OAAgB,YAAc,EAC9B,OAAgB,oBAAsB,EACtC,OAAgB,eAAiB,EAAW,gBAAkB,GAC9D,OAAgB,mBAAqB,CACvC,EAEA,OAAO,eAAe,EAAgB,OAAQ,CAAE,MAAO,CAAI,CAAC,EAC5D,eAAe,OAAO,EAAK,CAAc,CAC3C"}
@@ -0,0 +1,33 @@
1
+ import type { ComponentDefinition } from './component-types';
2
+ import { type InferProps, prop, type PropDef, type PropInputDefs, type PropsDef } from './props';
3
+ export { prop };
4
+ export type { InferProps, PropDef, PropInputDefs, PropsDef };
5
+ export type { HostBindFn } from './host-bind';
6
+ /**
7
+ * Define and register a web component.
8
+ *
9
+ * The `setup` function runs once per instance on first connect and returns an
10
+ * `HTMLResult`. All reactive behaviour is expressed through reactive directives
11
+ * inside the template — not by re-evaluating setup itself.
12
+ *
13
+ * Pass a `SlotNames` type parameter to get typed `ctx.slots` access:
14
+ * ```ts
15
+ * define<Record<never, never>, Record<never, never>, 'header' | 'footer'>('my-card', {
16
+ * setup(_props, { slots }) {
17
+ * const hasHeader = slots.has('header'); // typed ✓
18
+ * },
19
+ * });
20
+ * ```
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * define('my-counter', {
25
+ * props: { count: prop.number(0) },
26
+ * setup(props) {
27
+ * return html`<button @click=${() => props.count.value++}>${props.count}</button>`;
28
+ * },
29
+ * });
30
+ * ```
31
+ */
32
+ export declare function define<Props extends Record<string, unknown> = Record<never, never>, Emits extends Record<string, unknown> = Record<string, never>, const SlotNames extends string = string>(tag: string, definition: ComponentDefinition<Props, Emits, SlotNames>): void;
33
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAI7D,OAAO,EACL,KAAK,UAAU,EAEf,IAAI,EACJ,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,QAAQ,EAEd,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,MAAM,CACpB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC5D,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC7D,KAAK,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,EACvC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG,IAAI,CAmC7E"}
package/dist/define.js ADDED
@@ -0,0 +1,2 @@
1
+ import{ORE_ERRORS as e,OreApiError as t}from"./errors.js";import{toKebab as n}from"./utils/dom.js";import{normalizePropDefinition as r,prop as i,validatePropDefs as a}from"./props.js";import{BaseElement as o}from"./base-element.js";function s(i,s){if(!i)throw new t(e.defineRequiresTag);if(customElements.get(i))throw new t(e.defineDuplicate(i));let{props:c}=s,l=(()=>{if(!c)return;let n=a(c);if(n.length>0)throw new t(e.validationFailed(i,n));let o={};for(let[e,t]of Object.entries(c))o[e]=r(t,e);return o})(),u=l?Object.keys(l).map(n):[],d=class extends o{static _definition=s;static _normalizedPropDefs=l;static formAssociated=s.formAssociated??!1;static observedAttributes=u};Object.defineProperty(d,"name",{value:i}),customElements.define(i,d)}export{s as define,i as prop};
2
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","names":[],"sources":["../src/define.ts"],"sourcesContent":["import type { ComponentDefinition } from './component-types';\n\nimport { BaseElement } from './base-element';\nimport { OreApiError, ORE_ERRORS } from './errors';\nimport {\n type InferProps,\n normalizePropDefinition,\n prop,\n type PropDef,\n type PropInputDefs,\n type PropsDef,\n validatePropDefs,\n} from './props';\nimport { toKebab } from './utils/dom';\n\nexport { prop };\nexport type { InferProps, PropDef, PropInputDefs, PropsDef };\nexport type { HostBindFn } from './host-bind';\n\n/**\n * Define and register a web component.\n *\n * The `setup` function runs once per instance on first connect and returns an\n * `HTMLResult`. All reactive behaviour is expressed through reactive directives\n * inside the template — not by re-evaluating setup itself.\n *\n * Pass a `SlotNames` type parameter to get typed `ctx.slots` access:\n * ```ts\n * define<Record<never, never>, Record<never, never>, 'header' | 'footer'>('my-card', {\n * setup(_props, { slots }) {\n * const hasHeader = slots.has('header'); // typed ✓\n * },\n * });\n * ```\n *\n * @example\n * ```ts\n * define('my-counter', {\n * props: { count: prop.number(0) },\n * setup(props) {\n * return html`<button @click=${() => props.count.value++}>${props.count}</button>`;\n * },\n * });\n * ```\n */\nexport function define<\n Props extends Record<string, unknown> = Record<never, never>,\n Emits extends Record<string, unknown> = Record<string, never>,\n const SlotNames extends string = string,\n>(tag: string, definition: ComponentDefinition<Props, Emits, SlotNames>): void {\n if (!tag) throw new OreApiError(ORE_ERRORS.defineRequiresTag);\n\n if (customElements.get(tag)) throw new OreApiError(ORE_ERRORS.defineDuplicate(tag));\n\n const { props: propDefs } = definition;\n\n const normalizedPropDefs: PropsDef<Props> | undefined = (() => {\n if (!propDefs) return undefined;\n\n const errors = validatePropDefs(propDefs as Record<string, unknown>);\n\n if (errors.length > 0) throw new OreApiError(ORE_ERRORS.validationFailed(tag, errors));\n\n const normalized: PropInputDefs = {};\n\n for (const [key, def] of Object.entries(propDefs)) {\n normalized[key] = normalizePropDefinition(def, key);\n }\n\n return normalized as PropsDef<Props>;\n })();\n\n const observedAttrs = normalizedPropDefs ? Object.keys(normalizedPropDefs).map(toKebab) : [];\n\n // Named class for DevTools and error messages\n const ComponentClass = class extends BaseElement {\n static override _definition = definition as ComponentDefinition<any, any, any>;\n static override _normalizedPropDefs = normalizedPropDefs as PropsDef<Record<never, never>> | undefined;\n static override formAssociated = definition.formAssociated ?? false;\n static override observedAttributes = observedAttrs;\n };\n\n Object.defineProperty(ComponentClass, 'name', { value: tag });\n customElements.define(tag, ComponentClass);\n}\n"],"mappings":"wOA6CA,SAAgB,EAId,EAAa,EAAgE,CAC7E,GAAI,CAAC,EAAK,MAAM,IAAI,EAAY,EAAW,iBAAiB,EAE5D,GAAI,eAAe,IAAI,CAAG,EAAG,MAAM,IAAI,EAAY,EAAW,gBAAgB,CAAG,CAAC,EAElF,GAAM,CAAE,MAAO,GAAa,EAEtB,OAAyD,CAC7D,GAAI,CAAC,EAAU,OAEf,IAAM,EAAS,EAAiB,CAAmC,EAEnE,GAAI,EAAO,OAAS,EAAG,MAAM,IAAI,EAAY,EAAW,iBAAiB,EAAK,CAAM,CAAC,EAErF,IAAM,EAA4B,CAAC,EAEnC,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAQ,EAC9C,EAAW,GAAO,EAAwB,EAAK,CAAG,EAGpD,OAAO,CACT,EAAA,CAAG,EAEG,EAAgB,EAAqB,OAAO,KAAK,CAAkB,CAAC,CAAC,IAAI,CAAO,EAAI,CAAC,EAGrF,EAAiB,cAAc,CAAY,CAC/C,OAAgB,YAAc,EAC9B,OAAgB,oBAAsB,EACtC,OAAgB,eAAiB,EAAW,gBAAkB,GAC9D,OAAgB,mBAAqB,CACvC,EAEA,OAAO,eAAe,EAAgB,OAAQ,CAAE,MAAO,CAAI,CAAC,EAC5D,eAAe,OAAO,EAAK,CAAc,CAC3C"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./testing/flush.cjs");async function t(t){return e.flush({...t,logger:console.debug})}exports.debugFlush=t;
2
+ //# sourceMappingURL=devtools.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools.cjs","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["/**\n * @vielzeug/ore — debug utilities for component update visualisation.\n *\n * Import from the dedicated sub-path so it is tree-shaken from production bundles:\n * ```ts\n * import { debugFlush } from '@vielzeug/ore/devtools';\n * ```\n */\n\nimport type { FlushOptions } from './testing/flush';\n\nimport { flush } from './testing/flush';\n\n/**\n * Flushes pending reactive updates with debug logging pre-wired to `console.debug`.\n *\n * Equivalent to `flush({ ...options, logger: console.debug })` but imported from a\n * dedicated sub-path so the `console.debug` reference is tree-shaken from production\n * bundles when this sub-path is not imported.\n *\n * Logs each turn and timing phase to `console.debug` so you can diagnose\n * unexpected update order or timing issues.\n *\n * @example\n * ```ts\n * import { debugFlush } from '@vielzeug/ore/devtools';\n *\n * // in a test\n * await debugFlush();\n * // [flush] starting with maxTurns=5\n * // [flush] microtask turn 1/5\n * // ...\n * ```\n */\nexport async function debugFlush(options?: Omit<FlushOptions, 'logger'>): Promise<void> {\n return flush({ ...options, logger: console.debug });\n}\n"],"mappings":"0GAkCA,eAAsB,EAAW,EAAuD,CACtF,OAAO,EAAA,MAAM,CAAE,GAAG,EAAS,OAAQ,QAAQ,KAAM,CAAC,CACpD"}