@studiometa/js-toolkit 4.0.0-alpha.1 → 4.0.0-alpha.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 (455) hide show
  1. package/README.md +10 -0
  2. package/dist/Base.d.ts +0 -2
  3. package/dist/Base.js +1 -2
  4. package/dist/Base.js.map +1 -1
  5. package/dist/attribute-namespaces.d.ts +0 -2
  6. package/dist/attribute-namespaces.js +1 -2
  7. package/dist/attributes.d.ts +0 -2
  8. package/dist/attributes.js +1 -2
  9. package/dist/children-watchers.d.ts +0 -2
  10. package/dist/children-watchers.js +1 -2
  11. package/dist/component-brand.d.ts +0 -2
  12. package/dist/component-brand.js +1 -2
  13. package/dist/component-declarations.d.ts +0 -2
  14. package/dist/component-declarations.js +1 -2
  15. package/dist/context-subscription.d.ts +0 -2
  16. package/dist/context-subscription.js +1 -2
  17. package/dist/context.d.ts +0 -2
  18. package/dist/context.js +1 -2
  19. package/dist/decorators.d.ts +0 -2
  20. package/dist/decorators.js +1 -2
  21. package/dist/diagnostic-contract.d.ts +0 -2
  22. package/dist/diagnostic-contract.js +1 -2
  23. package/dist/diagnostics.d.ts +0 -2
  24. package/dist/diagnostics.js +1 -2
  25. package/dist/document-order.d.ts +0 -2
  26. package/dist/document-order.js +1 -2
  27. package/dist/dom-mutations.d.ts +0 -2
  28. package/dist/dom-mutations.js +1 -2
  29. package/dist/events.d.ts +0 -2
  30. package/dist/events.js +1 -2
  31. package/dist/group.d.ts +0 -2
  32. package/dist/group.js +1 -2
  33. package/dist/instances.d.ts +0 -2
  34. package/dist/instances.js +1 -2
  35. package/dist/manifest.d.ts +0 -2
  36. package/dist/manifest.js +1 -2
  37. package/dist/mount-strategies.d.ts +0 -2
  38. package/dist/mount-strategies.js +1 -2
  39. package/dist/negotiated-events.d.ts +0 -2
  40. package/dist/negotiated-events.js +1 -2
  41. package/dist/protocol-symbols.d.ts +0 -2
  42. package/dist/protocol-symbols.js +1 -2
  43. package/dist/registry.d.ts +0 -2
  44. package/dist/registry.js +1 -2
  45. package/dist/responsive-options.d.ts +0 -2
  46. package/dist/responsive-options.js +1 -2
  47. package/dist/scheduler.d.ts +0 -2
  48. package/dist/scheduler.js +1 -2
  49. package/dist/scheduler.js.map +1 -1
  50. package/dist/services/breakpoint.d.ts +0 -2
  51. package/dist/services/breakpoint.js +1 -2
  52. package/dist/services/drag.d.ts +0 -2
  53. package/dist/services/drag.js +1 -2
  54. package/dist/services/in-view.d.ts +0 -2
  55. package/dist/services/in-view.js +1 -2
  56. package/dist/services/key.d.ts +0 -2
  57. package/dist/services/key.js +1 -2
  58. package/dist/services/media.d.ts +0 -2
  59. package/dist/services/media.js +1 -2
  60. package/dist/services/mixin.d.ts +0 -2
  61. package/dist/services/mixin.js +1 -2
  62. package/dist/services/mutation.d.ts +0 -2
  63. package/dist/services/mutation.js +1 -2
  64. package/dist/services/pointer.d.ts +0 -2
  65. package/dist/services/pointer.js +1 -2
  66. package/dist/services/raf.d.ts +0 -2
  67. package/dist/services/raf.js +1 -2
  68. package/dist/services/resize.d.ts +0 -2
  69. package/dist/services/resize.js +1 -2
  70. package/dist/services/scroll-progress-offset.d.ts +0 -2
  71. package/dist/services/scroll-progress-offset.js +1 -2
  72. package/dist/services/scroll-progress.d.ts +0 -2
  73. package/dist/services/scroll-progress.js +1 -2
  74. package/dist/services/scroll.d.ts +0 -2
  75. package/dist/services/scroll.js +1 -2
  76. package/dist/services/service.d.ts +0 -2
  77. package/dist/services/service.js +1 -2
  78. package/dist/services/toggle.d.ts +0 -2
  79. package/dist/services/toggle.js +1 -2
  80. package/dist/services/until.d.ts +0 -2
  81. package/dist/services/until.js +1 -2
  82. package/dist/shared-runtime.d.ts +0 -2
  83. package/dist/shared-runtime.js +1 -2
  84. package/dist/storage/createStorage.d.ts +0 -2
  85. package/dist/storage/createStorage.js +1 -2
  86. package/dist/storage/index.d.ts +0 -2
  87. package/dist/storage/index.js +1 -2
  88. package/dist/storage/providers.d.ts +0 -2
  89. package/dist/storage/providers.js +1 -2
  90. package/dist/storage/serializers.d.ts +0 -2
  91. package/dist/storage/serializers.js +1 -2
  92. package/dist/storage/sync.d.ts +0 -2
  93. package/dist/storage/sync.js +1 -2
  94. package/dist/storage/types.d.ts +0 -2
  95. package/dist/subpaths/BREAKPOINTS.js +1 -2
  96. package/dist/subpaths/Base.js +1 -2
  97. package/dist/subpaths/DIAGNOSTICS.js +1 -2
  98. package/dist/subpaths/DRAG_MODES.js +1 -2
  99. package/dist/subpaths/EVENTS.js +1 -2
  100. package/dist/subpaths/MOUNT_ATTRIBUTE.js +1 -2
  101. package/dist/subpaths/SWAP_MODES.js +1 -2
  102. package/dist/subpaths/children.js +1 -2
  103. package/dist/subpaths/component.js +1 -2
  104. package/dist/subpaths/createContext.js +1 -2
  105. package/dist/subpaths/createFallbackProvider.js +1 -2
  106. package/dist/subpaths/createGroup.js +1 -2
  107. package/dist/subpaths/createLocalStorage.js +1 -2
  108. package/dist/subpaths/createMemoryStorageProvider.js +1 -2
  109. package/dist/subpaths/createService.js +1 -2
  110. package/dist/subpaths/createServiceMixin.js +1 -2
  111. package/dist/subpaths/createSessionStorage.js +1 -2
  112. package/dist/subpaths/createStorage.js +1 -2
  113. package/dist/subpaths/createUrlSearchParamsInHashProvider.js +1 -2
  114. package/dist/subpaths/createUrlSearchParamsInHashStorage.js +1 -2
  115. package/dist/subpaths/createUrlSearchParamsProvider.js +1 -2
  116. package/dist/subpaths/createUrlSearchParamsStorage.js +1 -2
  117. package/dist/subpaths/defaultScheduler.js +1 -2
  118. package/dist/subpaths/defineManifest.js +1 -2
  119. package/dist/subpaths/domUpdate.js +1 -2
  120. package/dist/subpaths/emitExtendable.js +1 -2
  121. package/dist/subpaths/fromMetaGlob.js +1 -2
  122. package/dist/subpaths/fromWebpackContext.js +1 -2
  123. package/dist/subpaths/getBreakpoints.js +1 -2
  124. package/dist/subpaths/getInstance.js +1 -2
  125. package/dist/subpaths/getInstances.js +1 -2
  126. package/dist/subpaths/getMountedInstances.js +1 -2
  127. package/dist/subpaths/getUnmountedInstances.js +1 -2
  128. package/dist/subpaths/inject.js +1 -2
  129. package/dist/subpaths/injectContext.js +1 -2
  130. package/dist/subpaths/injectContextSync.js +1 -2
  131. package/dist/subpaths/jsonSerializer.js +1 -2
  132. package/dist/subpaths/localStorageProvider.js +1 -2
  133. package/dist/subpaths/memoryStorageProvider.js +1 -2
  134. package/dist/subpaths/namespaceQualifier.js +1 -2
  135. package/dist/subpaths/nextFrame.js +1 -2
  136. package/dist/subpaths/on.js +1 -2
  137. package/dist/subpaths/perTarget.js +1 -2
  138. package/dist/subpaths/provide.js +1 -2
  139. package/dist/subpaths/provideContext.js +1 -2
  140. package/dist/subpaths/provideRootContext.js +1 -2
  141. package/dist/subpaths/read.js +1 -2
  142. package/dist/subpaths/registerComponent.js +1 -2
  143. package/dist/subpaths/registerComponents.js +1 -2
  144. package/dist/subpaths/registerManifest.js +1 -2
  145. package/dist/subpaths/reportDiagnostic.js +1 -2
  146. package/dist/subpaths/sessionStorageProvider.js +1 -2
  147. package/dist/subpaths/setBreakpoints.js +1 -2
  148. package/dist/subpaths/signal.js +1 -2
  149. package/dist/subpaths/subscribeContext.js +1 -2
  150. package/dist/subpaths/swap.js +1 -2
  151. package/dist/subpaths/toggle.js +1 -2
  152. package/dist/subpaths/until.js +1 -2
  153. package/dist/subpaths/urlSearchParamsInHashProvider.js +1 -2
  154. package/dist/subpaths/urlSearchParamsProvider.js +1 -2
  155. package/dist/subpaths/useBreakpoint.js +1 -2
  156. package/dist/subpaths/useDrag.js +1 -2
  157. package/dist/subpaths/useInView.js +1 -2
  158. package/dist/subpaths/useKey.js +1 -2
  159. package/dist/subpaths/useMediaQuery.js +1 -2
  160. package/dist/subpaths/useMutation.js +1 -2
  161. package/dist/subpaths/usePointer.js +1 -2
  162. package/dist/subpaths/usePrefersReducedMotion.js +1 -2
  163. package/dist/subpaths/useRaf.js +1 -2
  164. package/dist/subpaths/useResize.js +1 -2
  165. package/dist/subpaths/useScroll.js +1 -2
  166. package/dist/subpaths/useScrollProgress.js +1 -2
  167. package/dist/subpaths/useWindowScroll.js +1 -2
  168. package/dist/subpaths/useWindowSize.js +1 -2
  169. package/dist/subpaths/utils/DEFAULT_DAMP_FACTOR.js +1 -2
  170. package/dist/subpaths/utils/INERTIA_FRAME.js +1 -2
  171. package/dist/subpaths/utils/MAX_SPRING_RATIO.js +1 -2
  172. package/dist/subpaths/utils/SCROLL_ALIGNMENTS.js +1 -2
  173. package/dist/subpaths/utils/SCROLL_AXES.js +1 -2
  174. package/dist/subpaths/utils/TRANSFORM_PROPS.js +1 -2
  175. package/dist/subpaths/utils/TRANSITION_OPTIONS.js +1 -2
  176. package/dist/subpaths/utils/camelCase.js +1 -2
  177. package/dist/subpaths/utils/capitalize.js +1 -2
  178. package/dist/subpaths/utils/clamp.js +1 -2
  179. package/dist/subpaths/utils/clamp01.js +1 -2
  180. package/dist/subpaths/utils/clampDampFactor.js +1 -2
  181. package/dist/subpaths/utils/createEaseInOut.js +1 -2
  182. package/dist/subpaths/utils/createEaseOut.js +1 -2
  183. package/dist/subpaths/utils/createElement.js +1 -2
  184. package/dist/subpaths/utils/createRange.js +1 -2
  185. package/dist/subpaths/utils/damp.js +1 -2
  186. package/dist/subpaths/utils/debounce.js +1 -2
  187. package/dist/subpaths/utils/decayOver.js +1 -2
  188. package/dist/subpaths/utils/deepmerge.js +1 -2
  189. package/dist/subpaths/utils/easeInCirc.js +1 -2
  190. package/dist/subpaths/utils/easeInCubic.js +1 -2
  191. package/dist/subpaths/utils/easeInExpo.js +1 -2
  192. package/dist/subpaths/utils/easeInOutCirc.js +1 -2
  193. package/dist/subpaths/utils/easeInOutCubic.js +1 -2
  194. package/dist/subpaths/utils/easeInOutExpo.js +1 -2
  195. package/dist/subpaths/utils/easeInOutQuad.js +1 -2
  196. package/dist/subpaths/utils/easeInOutQuart.js +1 -2
  197. package/dist/subpaths/utils/easeInOutQuint.js +1 -2
  198. package/dist/subpaths/utils/easeInOutSine.js +1 -2
  199. package/dist/subpaths/utils/easeInQuad.js +1 -2
  200. package/dist/subpaths/utils/easeInQuart.js +1 -2
  201. package/dist/subpaths/utils/easeInQuint.js +1 -2
  202. package/dist/subpaths/utils/easeInSine.js +1 -2
  203. package/dist/subpaths/utils/easeLinear.js +1 -2
  204. package/dist/subpaths/utils/easeOutCirc.js +1 -2
  205. package/dist/subpaths/utils/easeOutCubic.js +1 -2
  206. package/dist/subpaths/utils/easeOutExpo.js +1 -2
  207. package/dist/subpaths/utils/easeOutQuad.js +1 -2
  208. package/dist/subpaths/utils/easeOutQuart.js +1 -2
  209. package/dist/subpaths/utils/easeOutQuint.js +1 -2
  210. package/dist/subpaths/utils/easeOutSine.js +1 -2
  211. package/dist/subpaths/utils/enterTransition.js +1 -2
  212. package/dist/subpaths/utils/fold.js +1 -2
  213. package/dist/subpaths/utils/getOffsetSizes.js +1 -2
  214. package/dist/subpaths/utils/historyPush.js +1 -2
  215. package/dist/subpaths/utils/historyReplace.js +1 -2
  216. package/dist/subpaths/utils/inertiaDecay.js +1 -2
  217. package/dist/subpaths/utils/inertiaFinalValue.js +1 -2
  218. package/dist/subpaths/utils/inertiaStep.js +1 -2
  219. package/dist/subpaths/utils/inertiaTimeConstant.js +1 -2
  220. package/dist/subpaths/utils/isBoolean.js +1 -2
  221. package/dist/subpaths/utils/isDefined.js +1 -2
  222. package/dist/subpaths/utils/isFunction.js +1 -2
  223. package/dist/subpaths/utils/isNull.js +1 -2
  224. package/dist/subpaths/utils/isNumber.js +1 -2
  225. package/dist/subpaths/utils/isObject.js +1 -2
  226. package/dist/subpaths/utils/isString.js +1 -2
  227. package/dist/subpaths/utils/kebabCase.js +1 -2
  228. package/dist/subpaths/utils/leaveTransition.js +1 -2
  229. package/dist/subpaths/utils/lerp.js +1 -2
  230. package/dist/subpaths/utils/loadImage.js +1 -2
  231. package/dist/subpaths/utils/loadLink.js +1 -2
  232. package/dist/subpaths/utils/loadScript.js +1 -2
  233. package/dist/subpaths/utils/lockScroll.js +1 -2
  234. package/dist/subpaths/utils/lowerCase.js +1 -2
  235. package/dist/subpaths/utils/map.js +1 -2
  236. package/dist/subpaths/utils/matrix.js +1 -2
  237. package/dist/subpaths/utils/mean.js +1 -2
  238. package/dist/subpaths/utils/memo.js +1 -2
  239. package/dist/subpaths/utils/noop.js +1 -2
  240. package/dist/subpaths/utils/noopValue.js +1 -2
  241. package/dist/subpaths/utils/objectToURLSearchParams.js +1 -2
  242. package/dist/subpaths/utils/pascalCase.js +1 -2
  243. package/dist/subpaths/utils/random.js +1 -2
  244. package/dist/subpaths/utils/randomInt.js +1 -2
  245. package/dist/subpaths/utils/randomItem.js +1 -2
  246. package/dist/subpaths/utils/round.js +1 -2
  247. package/dist/subpaths/utils/saveActiveElement.js +1 -2
  248. package/dist/subpaths/utils/scrollPosition.js +1 -2
  249. package/dist/subpaths/utils/scrollTo.js +1 -2
  250. package/dist/subpaths/utils/selectorFor.js +1 -2
  251. package/dist/subpaths/utils/setClassesOrStyles.js +1 -2
  252. package/dist/subpaths/utils/smoothTo.js +1 -2
  253. package/dist/subpaths/utils/snakeCase.js +1 -2
  254. package/dist/subpaths/utils/spring.js +1 -2
  255. package/dist/subpaths/utils/throttle.js +1 -2
  256. package/dist/subpaths/utils/transform.js +1 -2
  257. package/dist/subpaths/utils/transition.js +1 -2
  258. package/dist/subpaths/utils/trapFocus.js +1 -2
  259. package/dist/subpaths/utils/untrapFocus.js +1 -2
  260. package/dist/subpaths/utils/upperCase.js +1 -2
  261. package/dist/subpaths/utils/wait.js +1 -2
  262. package/dist/subpaths/utils/withLeadingCharacters.js +1 -2
  263. package/dist/subpaths/utils/withLeadingSlash.js +1 -2
  264. package/dist/subpaths/utils/withTrailingCharacters.js +1 -2
  265. package/dist/subpaths/utils/withTrailingSlash.js +1 -2
  266. package/dist/subpaths/utils/withoutLeadingCharacters.js +1 -2
  267. package/dist/subpaths/utils/withoutLeadingCharactersRecursive.js +1 -2
  268. package/dist/subpaths/utils/withoutLeadingSlash.js +1 -2
  269. package/dist/subpaths/utils/withoutTrailingCharacters.js +1 -2
  270. package/dist/subpaths/utils/withoutTrailingCharactersRecursive.js +1 -2
  271. package/dist/subpaths/utils/withoutTrailingSlash.js +1 -2
  272. package/dist/subpaths/utils/wrap.js +1 -2
  273. package/dist/subpaths/viewTransition.js +1 -2
  274. package/dist/subpaths/warn.js +1 -2
  275. package/dist/subpaths/watchAttributeNamespace.js +1 -2
  276. package/dist/subpaths/watchAttributes.js +1 -2
  277. package/dist/subpaths/whenDOMSettled.js +1 -2
  278. package/dist/subpaths/withDrag.js +1 -2
  279. package/dist/subpaths/withInView.js +1 -2
  280. package/dist/subpaths/withKey.js +1 -2
  281. package/dist/subpaths/withMutation.js +1 -2
  282. package/dist/subpaths/withPointer.js +1 -2
  283. package/dist/subpaths/withRaf.js +1 -2
  284. package/dist/subpaths/withResize.js +1 -2
  285. package/dist/subpaths/withScroll.js +1 -2
  286. package/dist/subpaths/withScrollProgress.js +1 -2
  287. package/dist/subpaths/write.js +1 -2
  288. package/dist/swap.d.ts +0 -2
  289. package/dist/swap.js +1 -2
  290. package/dist/test/index.d.ts +0 -2
  291. package/dist/test/index.js +1 -2
  292. package/dist/utils/deepmerge.d.ts +0 -2
  293. package/dist/utils/deepmerge.js +1 -2
  294. package/dist/utils/dom.d.ts +0 -2
  295. package/dist/utils/dom.js +1 -2
  296. package/dist/utils/easings.d.ts +0 -2
  297. package/dist/utils/easings.js +1 -2
  298. package/dist/utils/focus.d.ts +0 -2
  299. package/dist/utils/focus.js +1 -2
  300. package/dist/utils/history.d.ts +0 -2
  301. package/dist/utils/history.js +1 -2
  302. package/dist/utils/is.d.ts +0 -2
  303. package/dist/utils/is.js +1 -2
  304. package/dist/utils/load.d.ts +0 -2
  305. package/dist/utils/load.js +1 -2
  306. package/dist/utils/maths.d.ts +0 -2
  307. package/dist/utils/maths.js +1 -2
  308. package/dist/utils/memo.d.ts +0 -2
  309. package/dist/utils/memo.js +1 -2
  310. package/dist/utils/noop.d.ts +0 -2
  311. package/dist/utils/noop.js +1 -2
  312. package/dist/utils/random.d.ts +0 -2
  313. package/dist/utils/random.js +1 -2
  314. package/dist/utils/scroll-lock.d.ts +0 -2
  315. package/dist/utils/scroll-lock.js +1 -2
  316. package/dist/utils/scrollTo.d.ts +0 -2
  317. package/dist/utils/scrollTo.js +1 -2
  318. package/dist/utils/selectors.d.ts +0 -2
  319. package/dist/utils/selectors.js +1 -2
  320. package/dist/utils/smoothTo.d.ts +0 -2
  321. package/dist/utils/smoothTo.js +1 -2
  322. package/dist/utils/strings.d.ts +0 -2
  323. package/dist/utils/strings.js +1 -2
  324. package/dist/utils/timing.d.ts +0 -2
  325. package/dist/utils/timing.js +1 -2
  326. package/dist/utils/transform.d.ts +0 -2
  327. package/dist/utils/transform.js +1 -2
  328. package/dist/utils/transition.d.ts +0 -2
  329. package/dist/utils/transition.js +1 -2
  330. package/dist/viewTransition.d.ts +0 -2
  331. package/dist/viewTransition.js +1 -2
  332. package/package.json +6 -3
  333. package/skills/studiometa-js-toolkit/SKILL.md +87 -0
  334. package/skills/studiometa-js-toolkit/references/api/configuration.md +169 -0
  335. package/skills/studiometa-js-toolkit/references/api/context/createContext.md +46 -0
  336. package/skills/studiometa-js-toolkit/references/api/context/createGroup.md +67 -0
  337. package/skills/studiometa-js-toolkit/references/api/context/index.md +69 -0
  338. package/skills/studiometa-js-toolkit/references/api/context/injectContext.md +58 -0
  339. package/skills/studiometa-js-toolkit/references/api/context/injectContextSync.md +44 -0
  340. package/skills/studiometa-js-toolkit/references/api/context/provideContext.md +61 -0
  341. package/skills/studiometa-js-toolkit/references/api/context/provideRootContext.md +42 -0
  342. package/skills/studiometa-js-toolkit/references/api/context/signal.md +85 -0
  343. package/skills/studiometa-js-toolkit/references/api/context/subscribeContext.md +71 -0
  344. package/skills/studiometa-js-toolkit/references/api/decorators/children.md +92 -0
  345. package/skills/studiometa-js-toolkit/references/api/decorators/component.md +75 -0
  346. package/skills/studiometa-js-toolkit/references/api/decorators/index.md +41 -0
  347. package/skills/studiometa-js-toolkit/references/api/decorators/inject.md +73 -0
  348. package/skills/studiometa-js-toolkit/references/api/decorators/on.md +149 -0
  349. package/skills/studiometa-js-toolkit/references/api/decorators/provide.md +77 -0
  350. package/skills/studiometa-js-toolkit/references/api/decorators/read-write.md +93 -0
  351. package/skills/studiometa-js-toolkit/references/api/diagnostics/DIAGNOSTICS.md +137 -0
  352. package/skills/studiometa-js-toolkit/references/api/diagnostics/EVENTS.md +45 -0
  353. package/skills/studiometa-js-toolkit/references/api/diagnostics/index.md +58 -0
  354. package/skills/studiometa-js-toolkit/references/api/diagnostics/reportDiagnostic.md +67 -0
  355. package/skills/studiometa-js-toolkit/references/api/diagnostics/warn.md +54 -0
  356. package/skills/studiometa-js-toolkit/references/api/dom/breakpoints.md +81 -0
  357. package/skills/studiometa-js-toolkit/references/api/dom/domUpdate.md +70 -0
  358. package/skills/studiometa-js-toolkit/references/api/dom/emitExtendable.md +68 -0
  359. package/skills/studiometa-js-toolkit/references/api/dom/index.md +26 -0
  360. package/skills/studiometa-js-toolkit/references/api/dom/swap.md +105 -0
  361. package/skills/studiometa-js-toolkit/references/api/dom/watchAttributeNamespace.md +96 -0
  362. package/skills/studiometa-js-toolkit/references/api/dom/watchAttributes.md +56 -0
  363. package/skills/studiometa-js-toolkit/references/api/dom/whenDOMSettled.md +41 -0
  364. package/skills/studiometa-js-toolkit/references/api/html/data-component.md +105 -0
  365. package/skills/studiometa-js-toolkit/references/api/html/data-mount.md +69 -0
  366. package/skills/studiometa-js-toolkit/references/api/html/data-option.md +106 -0
  367. package/skills/studiometa-js-toolkit/references/api/html/data-ref.md +63 -0
  368. package/skills/studiometa-js-toolkit/references/api/html/index.md +32 -0
  369. package/skills/studiometa-js-toolkit/references/api/index.md +73 -0
  370. package/skills/studiometa-js-toolkit/references/api/instance-events.md +75 -0
  371. package/skills/studiometa-js-toolkit/references/api/instance-methods.md +267 -0
  372. package/skills/studiometa-js-toolkit/references/api/instance-properties.md +90 -0
  373. package/skills/studiometa-js-toolkit/references/api/methods-hooks-events.md +149 -0
  374. package/skills/studiometa-js-toolkit/references/api/methods-hooks-lifecycle.md +90 -0
  375. package/skills/studiometa-js-toolkit/references/api/methods-hooks-options.md +96 -0
  376. package/skills/studiometa-js-toolkit/references/api/methods-hooks-services.md +164 -0
  377. package/skills/studiometa-js-toolkit/references/api/registry/defineManifest.md +57 -0
  378. package/skills/studiometa-js-toolkit/references/api/registry/fromMetaGlob.md +33 -0
  379. package/skills/studiometa-js-toolkit/references/api/registry/fromWebpackContext.md +37 -0
  380. package/skills/studiometa-js-toolkit/references/api/registry/getInstance.md +52 -0
  381. package/skills/studiometa-js-toolkit/references/api/registry/getInstances.md +48 -0
  382. package/skills/studiometa-js-toolkit/references/api/registry/getMountedInstances.md +39 -0
  383. package/skills/studiometa-js-toolkit/references/api/registry/getUnmountedInstances.md +46 -0
  384. package/skills/studiometa-js-toolkit/references/api/registry/index.md +49 -0
  385. package/skills/studiometa-js-toolkit/references/api/registry/registerComponent.md +93 -0
  386. package/skills/studiometa-js-toolkit/references/api/registry/registerComponents.md +37 -0
  387. package/skills/studiometa-js-toolkit/references/api/registry/registerManifest.md +72 -0
  388. package/skills/studiometa-js-toolkit/references/api/scheduler/defaultScheduler.md +104 -0
  389. package/skills/studiometa-js-toolkit/references/api/scheduler/index.md +27 -0
  390. package/skills/studiometa-js-toolkit/references/api/scheduler/nextFrame.md +31 -0
  391. package/skills/studiometa-js-toolkit/references/api/scheduler/viewTransition.md +53 -0
  392. package/skills/studiometa-js-toolkit/references/api/services/createService.md +95 -0
  393. package/skills/studiometa-js-toolkit/references/api/services/createServiceMixin.md +81 -0
  394. package/skills/studiometa-js-toolkit/references/api/services/index.md +94 -0
  395. package/skills/studiometa-js-toolkit/references/api/services/mixins.md +148 -0
  396. package/skills/studiometa-js-toolkit/references/api/services/perTarget.md +65 -0
  397. package/skills/studiometa-js-toolkit/references/api/services/toggle.md +80 -0
  398. package/skills/studiometa-js-toolkit/references/api/services/until.md +44 -0
  399. package/skills/studiometa-js-toolkit/references/api/services/useBreakpoint.md +42 -0
  400. package/skills/studiometa-js-toolkit/references/api/services/useDrag.md +119 -0
  401. package/skills/studiometa-js-toolkit/references/api/services/useInView.md +64 -0
  402. package/skills/studiometa-js-toolkit/references/api/services/useKey.md +105 -0
  403. package/skills/studiometa-js-toolkit/references/api/services/useMediaQuery.md +45 -0
  404. package/skills/studiometa-js-toolkit/references/api/services/useMutation.md +69 -0
  405. package/skills/studiometa-js-toolkit/references/api/services/usePointer.md +91 -0
  406. package/skills/studiometa-js-toolkit/references/api/services/usePrefersReducedMotion.md +42 -0
  407. package/skills/studiometa-js-toolkit/references/api/services/useRaf.md +91 -0
  408. package/skills/studiometa-js-toolkit/references/api/services/useResize.md +60 -0
  409. package/skills/studiometa-js-toolkit/references/api/services/useScroll.md +88 -0
  410. package/skills/studiometa-js-toolkit/references/api/services/useScrollProgress.md +88 -0
  411. package/skills/studiometa-js-toolkit/references/api/services/useWindowScroll.md +25 -0
  412. package/skills/studiometa-js-toolkit/references/api/services/useWindowSize.md +25 -0
  413. package/skills/studiometa-js-toolkit/references/api/storage/createStorage.md +126 -0
  414. package/skills/studiometa-js-toolkit/references/api/storage/index.md +33 -0
  415. package/skills/studiometa-js-toolkit/references/api/storage/presets.md +58 -0
  416. package/skills/studiometa-js-toolkit/references/api/storage/providers.md +109 -0
  417. package/skills/studiometa-js-toolkit/references/api/test/index.md +214 -0
  418. package/skills/studiometa-js-toolkit/references/guide/concepts/attribute-grammar.md +93 -0
  419. package/skills/studiometa-js-toolkit/references/guide/concepts/mutation-engine.md +71 -0
  420. package/skills/studiometa-js-toolkit/references/guide/concepts/philosophy.md +78 -0
  421. package/skills/studiometa-js-toolkit/references/guide/concepts/the-registry.md +110 -0
  422. package/skills/studiometa-js-toolkit/references/guide/going-further/autoloading.md +104 -0
  423. package/skills/studiometa-js-toolkit/references/guide/going-further/handling-diagnostics.md +104 -0
  424. package/skills/studiometa-js-toolkit/references/guide/going-further/mount-strategies.md +95 -0
  425. package/skills/studiometa-js-toolkit/references/guide/going-further/scheduling-work.md +124 -0
  426. package/skills/studiometa-js-toolkit/references/guide/going-further/sharing-state.md +218 -0
  427. package/skills/studiometa-js-toolkit/references/guide/going-further/swapping-content.md +92 -0
  428. package/skills/studiometa-js-toolkit/references/guide/going-further/testing-components.md +137 -0
  429. package/skills/studiometa-js-toolkit/references/guide/going-further/typing-components.md +190 -0
  430. package/skills/studiometa-js-toolkit/references/guide/going-further/using-decorators.md +168 -0
  431. package/skills/studiometa-js-toolkit/references/guide/going-further/using-storage.md +125 -0
  432. package/skills/studiometa-js-toolkit/references/guide/index.md +163 -0
  433. package/skills/studiometa-js-toolkit/references/guide/introduction/installation.md +144 -0
  434. package/skills/studiometa-js-toolkit/references/guide/introduction/lifecycle-hooks.md +174 -0
  435. package/skills/studiometa-js-toolkit/references/guide/introduction/managing-components.md +229 -0
  436. package/skills/studiometa-js-toolkit/references/guide/introduction/managing-options.md +235 -0
  437. package/skills/studiometa-js-toolkit/references/guide/introduction/managing-refs.md +174 -0
  438. package/skills/studiometa-js-toolkit/references/guide/introduction/using-services.md +218 -0
  439. package/skills/studiometa-js-toolkit/references/guide/introduction/working-with-events.md +251 -0
  440. package/skills/studiometa-js-toolkit/references/guide/migration/v3-to-v4.md +373 -0
  441. package/skills/studiometa-js-toolkit/references/utils/css.md +98 -0
  442. package/skills/studiometa-js-toolkit/references/utils/dom.md +54 -0
  443. package/skills/studiometa-js-toolkit/references/utils/easings.md +217 -0
  444. package/skills/studiometa-js-toolkit/references/utils/focus.md +84 -0
  445. package/skills/studiometa-js-toolkit/references/utils/history.md +69 -0
  446. package/skills/studiometa-js-toolkit/references/utils/index.md +53 -0
  447. package/skills/studiometa-js-toolkit/references/utils/is.md +84 -0
  448. package/skills/studiometa-js-toolkit/references/utils/load.md +59 -0
  449. package/skills/studiometa-js-toolkit/references/utils/math.md +129 -0
  450. package/skills/studiometa-js-toolkit/references/utils/motion.md +218 -0
  451. package/skills/studiometa-js-toolkit/references/utils/objects.md +68 -0
  452. package/skills/studiometa-js-toolkit/references/utils/scroll.md +128 -0
  453. package/skills/studiometa-js-toolkit/references/utils/strings.md +176 -0
  454. package/skills/studiometa-js-toolkit/references/utils/timing.md +111 -0
  455. package/skills/studiometa-js-toolkit/references/utils/transitions.md +122 -0
@@ -0,0 +1,32 @@
1
+ # HTML
2
+
3
+ Four attributes are the whole markup surface of the framework.
4
+
5
+ | Attribute | Declares |
6
+ | ------------------------------------------ | ------------------------------------------------ |
7
+ | [`data-component`](data-component.md) | which components this element runs |
8
+ | [`data-mount`](data-mount.md) | when they mount |
9
+ | [`data-ref`](data-ref.md) | that this element is a named part of a component |
10
+ | [`data-option-<name>`](data-option.md) | the value of one declared option |
11
+
12
+ Every one of them follows the same grammar:
13
+
14
+ ```
15
+ data-<namespace>[:<qualifier>[.<part>…]]
16
+ ```
17
+
18
+ **The colon selects one member of the vocabulary the namespace declares**, which is why an attribute the framework reads holds at most one colon. See [The attribute grammar](../../guide/concepts/attribute-grammar.md).
19
+
20
+ ## What is not an attribute
21
+
22
+ - `data-load` — the mount and the import are one decision, so `data-mount` says it.
23
+ - `<tk-name>` tag sugar and lowercase arbitrary-selector registrations — removed.
24
+ - A breakpoint **list** suffix such as `:xxs:xs:s` — a suffix names one breakpoint and cascades.
25
+ - A range form or a breakpoint-list form — neither exists.
26
+
27
+ ## Watching your own
28
+
29
+ `attributeFilter` takes exact names and the DOM has no wildcard, so the engine cannot see an attribute the framework cannot name. Two opt-ins cover the rest:
30
+
31
+ - [`watchAttributes()`](../dom/watchAttributes.md) — every attribute of one element.
32
+ - [`watchAttributeNamespace()`](../dom/watchAttributeNamespace.md) — a namespace whose names cannot be enumerated, with keyed bindings.
@@ -0,0 +1,73 @@
1
+ # Base class
2
+
3
+ Every component extends `Base`. It carries the element, the live views over its markup, the lifecycle, the event conventions and the scheduling handles — and nothing else. `Base` knows nothing about services, view transitions or storage.
4
+
5
+ ```js
6
+ import { Base } from '@studiometa/js-toolkit';
7
+
8
+ class Component extends Base {
9
+ static config = {
10
+ name: 'Component',
11
+ };
12
+ }
13
+ ```
14
+
15
+ ## Sections
16
+
17
+ - [Configuration](configuration.md) — `static config` and how it merges
18
+ - [Lifecycle hooks](methods-hooks-lifecycle.md) — `mounted()` and `unmounted()`
19
+ - [Options hooks](methods-hooks-options.md) — `option<Name>Changed()`
20
+ - [Events hooks](methods-hooks-events.md) — `on<Event>`, `on<Ref><Event>`, `on<Child><Event>`, `onWindow<Event>`, `onDocument<Event>`
21
+ - [Services hooks](methods-hooks-services.md) — `ticked()`, `scrolled()`, `resized()` and the rest
22
+ - [Instance properties](instance-properties.md) — `$el`, `$id`, `$refs`, `$options`, `$config`, `$isMounted`
23
+ - [Instance methods](instance-methods.md) — `$mount()`, `$emit()`, `$query()`, `$provide()`, `$read()` and the rest
24
+ - [Instance events](instance-events.md) — what an instance dispatches
25
+
26
+ ## The constructor
27
+
28
+ ```ts
29
+ new Base(el: HTMLElement)
30
+ ```
31
+
32
+ **Do not call it.** The registry is the only code that constructs an instance, and an instance built by hand is not in the element's instance map, so nothing finds it and nothing unmounts it.
33
+
34
+ A component's own constructor is a legitimate place for field initializers, and two registrations belong there because they are **instance-scoped** rather than unmount-scoped:
35
+
36
+ ```js
37
+ import { Base, createContext } from '@studiometa/js-toolkit';
38
+
39
+ const Ctx = createContext('ctx');
40
+ class Slider extends Base {
41
+ static config = { name: 'Slider', components: {} };
42
+
43
+ // Never released. Both die with the element.
44
+ api = this.$provide(Ctx, { goNext: () => {} });
45
+ items = this.$watchChildren('SliderItem');
46
+ }
47
+ ```
48
+
49
+ ## Fixed properties
50
+
51
+ `$el`, `$id`, `$options` and `$refs` are **fixed properties of the instance**, not fields it happens to hold. They are defined non-writable in the constructor, so an assignment throws in a module rather than replacing what every other part of the framework reads.
52
+
53
+ `readonly` states it for a reader with a build step; the property descriptor states it for everyone else. They stay enumerable, so an instance still reads as one.
54
+
55
+ ## The typed surface
56
+
57
+ `Base` takes an optional props type with four optional keys — `$el`, `$refs`, `$options` and `$emits`. See [TypeScript](../guide/going-further/typing-components.md).
58
+
59
+ ```ts
60
+ import { Base } from '@studiometa/js-toolkit';
61
+
62
+ class Slider extends Base<{
63
+ $refs: { next: HTMLButtonElement };
64
+ $options: { speed: number };
65
+ $emits: { goto: { index: number }; stop: void };
66
+ }> {
67
+ static config = {
68
+ name: 'Slider',
69
+ refs: ['next'],
70
+ options: { speed: { type: Number, default: 1 } },
71
+ };
72
+ }
73
+ ```
@@ -0,0 +1,75 @@
1
+ # Instance events
2
+
3
+ Everything an instance dispatches is a real DOM event, so a plain `addEventListener` hears all of it.
4
+
5
+ ## Component events
6
+
7
+ `$emit(name, payload?)` dispatches on `$el`:
8
+
9
+ | Property | Value |
10
+ | ------------ | ----------------------------- |
11
+ | `bubbles` | `true` |
12
+ | `cancelable` | `true` |
13
+ | `detail` | the payload object, or `null` |
14
+
15
+ Names are typed lower-kebab string literals declared through the props type's `$emits` key. There is no namespace: a component event is `open`, not `js-toolkit:open`.
16
+
17
+ ```js
18
+ el.addEventListener('goto', (event) => {
19
+ console.log(event.detail.index);
20
+ });
21
+ ```
22
+
23
+ ## Lifecycle announcements
24
+
25
+ Every instance announces its own mount and unmount, carrying itself in the payload:
26
+
27
+ ```ts
28
+ interface LifecycleEventDetail {
29
+ instance: Base;
30
+ }
31
+ ```
32
+
33
+ | Event | Constant | Dispatched from |
34
+ | -------------------------------- | ---------------------------- | ------------------------- |
35
+ | `js-toolkit:component:mounted` | `EVENTS.component.mounted` | the element — **bubbles** |
36
+ | `js-toolkit:component:unmounted` | `EVENTS.component.unmounted` | `document` |
37
+
38
+ ```ts
39
+ import { EVENTS, type LifecycleEventDetail } from '@studiometa/js-toolkit';
40
+
41
+ document.addEventListener(EVENTS.component.mounted, (rawEvent) => {
42
+ const event = rawEvent as CustomEvent<LifecycleEventDetail>;
43
+ console.log(`${event.detail.instance.$id} mounted`);
44
+ });
45
+ ```
46
+
47
+ The unmount event dispatches from `document` because the element can already be detached. That is also what lets one lazy, realm-shared listener serve every [`$watchChildren()`](instance-methods.md#watchchildren) watcher while the document holds nothing but weak references to them — a listener per watcher would make every watching component immortal.
48
+
49
+ **An instance that is scheduled but not mounted announces nothing.**
50
+
51
+ ## Diagnostics
52
+
53
+ `js-toolkit:diagnostic` — `EVENTS.diagnostic` — starts on the relevant connected element, or on `document` when there is none, with `{ bubbles: true, composed: true, cancelable: true }`.
54
+
55
+ `preventDefault()` suppresses the default console output only. See [Diagnostics](diagnostics/index.md).
56
+
57
+ ## Negotiated events
58
+
59
+ `js-toolkit:dom:update` — `EVENTS.dom.update` — is dispatched by [`domUpdate()`](dom/domUpdate.md), and [`emitExtendable()`](dom/emitExtendable.md) dispatches the name its caller gives.
60
+
61
+ Both are bubbling and **non-cancelable**: the step is announced, not proposed. Their detail carries a `wrap()` or a `waitUntil()` valid only while the event dispatches.
62
+
63
+ They have **no `Base` path** and are absent from `$emits`, so the negotiation code and the optional view-transition import stay out of the `Base` graph. Plain DOM code uses the same functions with no instance.
64
+
65
+ ## Private transports
66
+
67
+ The context request is a bubbling, **module-private** event and is deliberately not part of public `EVENTS`. Framework internals that need a transport use module-local namespaced constants; only what a consumer can usefully listen to is exported.
68
+
69
+ ## The convention, in full
70
+
71
+ - Public framework events use the deeply frozen `EVENTS` object and the `js-toolkit:` namespace.
72
+ - Private framework transports use module-local constants and do not join `EVENTS`.
73
+ - Component events use typed lower-kebab string literals from `$emits`.
74
+ - A payload is **one object** in `CustomEvent.detail`, or the platform value `null`.
75
+ - Diagnostic events are cancelable, so monitoring can suppress the default output only.
@@ -0,0 +1,267 @@
1
+ # Instance methods
2
+
3
+ ## `$mount()`
4
+
5
+ ```ts
6
+ $mount(): this
7
+ ```
8
+
9
+ Starts a mount cycle. On a page the registry calls it; calling it yourself is legitimate but nearly always a sign that a [mount strategy](../guide/going-further/mount-strategies.md) is the answer instead.
10
+
11
+ ## `$unmount()`
12
+
13
+ ```ts
14
+ $unmount(): this
15
+ ```
16
+
17
+ The reversible opposite of mount. It unbinds the cycle's listeners, runs the `mounted()` cleanups, cancels the instance's scheduled tasks, calls `unmounted()` and announces the change.
18
+
19
+ **The instance stays on its element**, so `$mount()` can start a new cycle with the same identity.
20
+
21
+ ## `$emit()` {#emit}
22
+
23
+ ```ts
24
+ $emit<K extends EmitName<T>>(event: K, ...payload: EmitArgs<T, K>): CustomEvent<EmitDetail<T, K>>
25
+ ```
26
+
27
+ Dispatches a bubbling, cancelable `CustomEvent` on `$el`, with the payload as `detail`.
28
+
29
+ ```js
30
+ import { Base } from '@studiometa/js-toolkit';
31
+
32
+ class Dialog extends Base {
33
+ static config = { name: 'Dialog' };
34
+
35
+ close() {
36
+ const event = this.$emit('close');
37
+ if (event.defaultPrevented) return;
38
+ this.$el.removeAttribute('data-option-open');
39
+ }
40
+
41
+ goto(index) {
42
+ this.$emit('goto', { index });
43
+ }
44
+ }
45
+ ```
46
+
47
+ - The payload is **one object**, or nothing. An omitted payload leaves `detail` at the platform value `null`.
48
+ - A value that is not an object is refused by the type and reported as `event.invalid-emit-payload`. The event still dispatches.
49
+ - Nothing in the framework is gated on cancellation.
50
+
51
+ Declare the names and payloads through the props type's `$emits` key. See [Events](../guide/introduction/working-with-events.md).
52
+
53
+ ## `$on()` {#on}
54
+
55
+ ```ts
56
+ $on(type: string, listener: EventListener, options?: AddEventListenerOptions): () => void
57
+ ```
58
+
59
+ Adds a listener on `$el` and **returns its own remover**, which makes it a `mounted()` cleanup as it is:
60
+
61
+ ```js
62
+ mounted() {
63
+ return this.$on('transitionend', this.handleEnd, { once: true });
64
+ }
65
+ ```
66
+
67
+ Reach for it when the event name is data rather than a method name, or when you need listener options.
68
+
69
+ ## `$off()`
70
+
71
+ ```ts
72
+ $off(type: string, listener: EventListener, options?: AddEventListenerOptions): void
73
+ ```
74
+
75
+ ## `$query()` {#query}
76
+
77
+ ```ts
78
+ $query<T extends Base = Base>(name: string): T[]
79
+ ```
80
+
81
+ Every **mounted** instance of `name` among the descendants of `$el`, in document order. A flat array at any depth, not a keyed object.
82
+
83
+ ```js
84
+ import { Base } from '@studiometa/js-toolkit';
85
+
86
+ class Slider extends Base {
87
+ static config = { name: 'Slider' };
88
+
89
+ reset() {
90
+ for (const item of this.$query('SliderItem')) {
91
+ item.$el.removeAttribute('data-option-active');
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ For a collection kept over time rather than queried each time, prefer [`$watchChildren()`](#watchchildren).
98
+
99
+ ## `$closest()` {#closest}
100
+
101
+ ```ts
102
+ $closest<T extends Base = Base>(name: string): T | null
103
+ ```
104
+
105
+ The nearest ancestor instance of `name`, or `null`.
106
+
107
+ **Always guard it**
108
+
109
+ It is resolved on every access and returns `null` when no matching ancestor instance has been constructed. Whether an ancestor is resolvable from a child's own `mounted()` depends on mount order, so never dereference it unguarded there.
110
+
111
+ ```js
112
+ this.$closest('Slider')?.goNext();
113
+ ```
114
+
115
+ A child that reaches for its parent is usually a child that should `$emit()` instead.
116
+
117
+ ## `$watchChildren()` {#watchchildren}
118
+
119
+ ```ts
120
+ $watchChildren<T extends Base>(name: string, callbacks?: WatchChildrenCallbacks<T>): ChildrenCollection<T>
121
+ $watchChildren<T extends BaseConstructor>(ComponentClass: T, callbacks?: WatchChildrenCallbacks<InstanceType<T>>): ChildrenCollection<InstanceType<T>>
122
+ ```
123
+
124
+ A **live collection** of descendant instances, in document order whatever the mount order is.
125
+
126
+ ```js
127
+ import { Base } from '@studiometa/js-toolkit';
128
+
129
+ class SliderItem extends Base {
130
+ static config = { name: 'SliderItem' };
131
+ }
132
+
133
+ class Slider extends Base {
134
+ static config = { name: 'Slider', components: { SliderItem } };
135
+
136
+ // Exact `config.name`.
137
+ items = this.$watchChildren('SliderItem', {
138
+ added(item) {},
139
+ removed(item) {},
140
+ });
141
+
142
+ // Also every named subclass, through `instanceof`.
143
+ allItems = this.$watchChildren(SliderItem);
144
+ }
145
+ ```
146
+
147
+ ```ts
148
+ interface ChildrenCollection<T extends Base = Base> extends Iterable<T> {
149
+ readonly size: number;
150
+ readonly items: T[];
151
+ }
152
+ ```
153
+
154
+ - **The string overload** looks up the exact `config.name`.
155
+ - **The constructor overload** walks the descendant elements in document order, reads their instance maps, keeps the instances where `instance instanceof ComponentClass`, excludes the watching instance, and removes duplicates.
156
+ - Callbacks passed to the decorator form are bound to the instance.
157
+
158
+ **It is instance-scoped, not unmount-scoped**
159
+
160
+ The subscription stays active through unmount and mount cycles, for the whole life of the watching instance, which is why the call belongs in a field initializer. It is never released and dies with the element.
161
+
162
+ The initial sweep is deferred to a microtask, because the call is usually a field initializer; the announcement listeners attach at once, so nothing is missed. No global instance registry is added — unmounted instances announce from `document`, so one lazy, realm-shared listener serves every watcher and the document holds nothing but weak references.
163
+
164
+ ## `$provide()`
165
+
166
+ ```ts
167
+ $provide<V>(key: ContextKey<V>, value: V): V
168
+ ```
169
+
170
+ Provides a value to the subtree and returns it, so the call is a field initializer. **The value is provided as it is** — nothing is wrapped.
171
+
172
+ ```js
173
+ import { Base, createContext, signal } from '@studiometa/js-toolkit';
174
+
175
+ const SliderContext = createContext('slider');
176
+ class Slider extends Base {
177
+ static config = { name: 'Slider' };
178
+
179
+ api = this.$provide(SliderContext, {
180
+ state: signal({ index: 0 }),
181
+ goNext: () => {},
182
+ });
183
+ }
184
+ ```
185
+
186
+ Instance-scoped: never released, and it dies with the element. A component whose declaration is withdrawn keeps providing until its element goes.
187
+
188
+ ## `$inject()`
189
+
190
+ ```ts
191
+ $inject<V>(key: ContextKey<V>): Promise<V>
192
+ ```
193
+
194
+ Resolves with the nearest provided value. **When nothing provides, it never settles** — a missing provider means "not yet", not "no".
195
+
196
+ ```js
197
+ async mounted() {
198
+ const api = await this.$inject(SliderContext);
199
+ return api.state.subscribe((state) => this.render(state));
200
+ }
201
+ ```
202
+
203
+ The pending request is **unmount-scoped**: `$unmount()` cancels it, and a new mount runs `mounted()` again and asks again.
204
+
205
+ ## `$injectSync()`
206
+
207
+ ```ts
208
+ $injectSync<V>(key: ContextKey<V>): V | undefined
209
+ ```
210
+
211
+ The value, synchronously, or `undefined`. For the case where the answer is optional and the caller has a fallback.
212
+
213
+ ## `$read()` and `$write()`
214
+
215
+ ```ts
216
+ $read<T>(fn: () => T): ScheduledTask<T>
217
+ $write<T>(fn: () => T): ScheduledTask<T>
218
+ ```
219
+
220
+ Schedules a layout read or a DOM write in the frame's matching phase, tied to this instance. `$unmount()` cancels the pending ones.
221
+
222
+ ```js
223
+ import { Base } from '@studiometa/js-toolkit';
224
+
225
+ class Reveal extends Base {
226
+ static config = { name: 'Reveal' };
227
+
228
+ async mounted() {
229
+ const box = await this.$read(() => this.$el.getBoundingClientRect()).promise;
230
+ this.$write(() => {
231
+ this.$el.style.setProperty('--height', `${box?.height}px`);
232
+ });
233
+ }
234
+ }
235
+ ```
236
+
237
+ ```ts
238
+ interface ScheduledTask<T = unknown> {
239
+ promise: Promise<T | undefined>;
240
+ cancel(): void;
241
+ }
242
+ ```
243
+
244
+ Every read runs before every write, once, before paint. A `read` scheduled from a `write` runs in the next frame; a `write` scheduled from a `read` runs in the same frame. See [The scheduler](../guide/going-further/scheduling-work.md).
245
+
246
+ ## `$warn()` and `$error()`
247
+
248
+ ```ts
249
+ $warn(code: ToolkitDiagnosticCode, message: string): void
250
+ $error(code: ToolkitDiagnosticCode, message: string, error: unknown): void
251
+ ```
252
+
253
+ Report on the [diagnostic channel](../guide/going-further/handling-diagnostics.md) with this component's name filled in.
254
+
255
+ ```js
256
+ this.$warn('carousel.no-slides', 'A Carousel with no slide does nothing.');
257
+ ```
258
+
259
+ ## What does not exist
260
+
261
+ | Not in v4 | Use instead |
262
+ | -------------- | ---------------------------------------- |
263
+ | `$parent` | `$closest(name)` |
264
+ | `$children` | `$watchChildren(name)` or `$query(name)` |
265
+ | `$root` | `$closest(name)` with the real name |
266
+ | `$update()` | nothing — refs are live |
267
+ | `$terminate()` | nothing — there is no permanent state |
@@ -0,0 +1,90 @@
1
+ # Instance properties
2
+
3
+ ## `$el`
4
+
5
+ ```ts
6
+ readonly $el: HTMLElement
7
+ ```
8
+
9
+ The element the instance is bound to. Typed by the props type's `$el` key.
10
+
11
+ ## `$id` {#id}
12
+
13
+ ```ts
14
+ readonly $id: string
15
+ ```
16
+
17
+ `<ComponentName>-<sequence>`, where the name comes from the resolved config and the sequence increases once for each constructed instance.
18
+
19
+ The id exists **before the field initializers of derived classes run**, and it does not change through unmount and mount cycles. Core never copies it to a DOM `id`.
20
+
21
+ ```js
22
+ // 'Slider-3'
23
+ ```
24
+
25
+ ## `$refs`
26
+
27
+ ```ts
28
+ readonly $refs: Refs<T>
29
+ ```
30
+
31
+ A live view over the declared refs. **Each property reads the DOM on access**, so markup put into the component is found with no refresh and no detached element stays in a list. There is no `$update()`.
32
+
33
+ A single declaration gives the first match; a `name[]` declaration gives an array. The property name never carries the suffix.
34
+
35
+ Lookups are cached, and the cache is invalidated by a counter the framework's MutationObserver increases; reading that counter drains the pending records with `takeRecords()`. Detached elements are never cached.
36
+
37
+ See [Refs](../guide/introduction/managing-refs.md).
38
+
39
+ ## `$options`
40
+
41
+ ```ts
42
+ readonly $options: Readonly<Options<T>>
43
+ ```
44
+
45
+ A **read-only view** over the declared options. Every property is defined with a getter and no setter, so the value is derived from the element and the viewport on each access, and an assignment throws:
46
+
47
+ ```js
48
+ this.$options.open = true;
49
+ // TypeError: Cannot set property open of #<Object> which has only a getter
50
+ ```
51
+
52
+ Every option is responsive, resolved by walking from the active breakpoint down to the base value.
53
+
54
+ The one exception to "nothing is stored": a **default** built by a factory lives on the instance, so mutating it sticks for that instance. Replacing the option itself still throws.
55
+
56
+ See [Options](../guide/introduction/managing-options.md).
57
+
58
+ ## `$config`
59
+
60
+ ```ts
61
+ get $config(): BaseConfig
62
+ ```
63
+
64
+ The merged config, walked along the prototype chain. `refs`, `options` and `components` merge; scalar keys are the most derived class's.
65
+
66
+ See [Configuration](configuration.md).
67
+
68
+ ## `$isMounted`
69
+
70
+ ```ts
71
+ get $isMounted(): boolean
72
+ ```
73
+
74
+ `true` between `mounted()` and the next `$unmount()`.
75
+
76
+ There is deliberately no `getMountedInstance()`: a caller holding one instance reads this instead.
77
+
78
+ ## `$services`
79
+
80
+ ```ts
81
+ readonly $services: { readonly [K in Hook]: Toggle }
82
+ ```
83
+
84
+ Present only on a class built with a [service mixin](methods-hooks-services.md). One [`Toggle`](services/toggle.md) per bound hook, which is what `{ manual: true }` is for. Stacked mixins accumulate their keys.
85
+
86
+ ## Fixed, not fields
87
+
88
+ `$el`, `$id`, `$options` and `$refs` are **fixed properties**, defined non-writable in the constructor. An assignment throws in a module rather than replacing what every other part of the framework reads: the element, the id, and the two live views.
89
+
90
+ `readonly` states it for a reader with a build step; the property descriptor states it for everyone else. They stay enumerable, so an instance still reads as one in a console or a `JSON.stringify`.
@@ -0,0 +1,149 @@
1
+ # Events hooks
2
+
3
+ Five naming conventions bind a method to an event source. All five are bound for the **mount cycle** and removed by `$unmount()`.
4
+
5
+ | Method name | Listens to | Payload |
6
+ | ------------------- | --------------------------------------------- | ---------------------------- |
7
+ | `on<Event>` | the component's own element | the raw event |
8
+ | `on<Ref><Event>` | a declared ref, delegated | `{ event, target, index }` |
9
+ | `on<Child><Event>` | a component in `config.components`, delegated | `{ event, target, payload }` |
10
+ | `onWindow<Event>` | `window` | `{ event, target }` |
11
+ | `onDocument<Event>` | `document` | `{ event, target }` |
12
+
13
+ ## Resolution order
14
+
15
+ `onWindow` and `onDocument` are **reserved prefixes** and match first. After them a name is resolved **children-first**, then refs.
16
+
17
+ `onWindowResize` binds to `window` even in a component whose `config.components` holds a `Window`. To reach a child with that name, use `@on('Window', 'resize')`.
18
+
19
+ The rule is about method names only. `onClick` and `onDocumentClick` are different names and both can exist on one component; a click on the element fires both.
20
+
21
+ ## `on<Event>`
22
+
23
+ ```js
24
+ import { Base } from '@studiometa/js-toolkit';
25
+
26
+ class Toggle extends Base {
27
+ static config = { name: 'Toggle' };
28
+
29
+ onClick(event) {
30
+ event.preventDefault();
31
+ }
32
+ }
33
+ ```
34
+
35
+ The event name is the method name after `on`, in lower case: `onPointerDown` is `pointerdown`.
36
+
37
+ ## `on<Ref><Event>`
38
+
39
+ ```ts
40
+ import { Base, type RefEvent } from '@studiometa/js-toolkit';
41
+
42
+ class Tabs extends Base {
43
+ static config = { name: 'Tabs', refs: ['tabs[]'] };
44
+
45
+ onTabsClick({ event, target, index }: RefEvent<HTMLButtonElement>) {
46
+ console.log(index, target.textContent);
47
+ }
48
+ }
49
+ ```
50
+
51
+ ```ts
52
+ interface RefEvent<T extends HTMLElement = HTMLElement> {
53
+ event: Event;
54
+ target: T;
55
+ index: number;
56
+ }
57
+ ```
58
+
59
+ `target` is the **ref element** the handler matched, not `event.target`. `index` is the position in a list ref, or `0` for a single ref.
60
+
61
+ The ref is named as it is **declared**: `onTabsClick` for `config.refs: ['tabs[]']`.
62
+
63
+ ## `on<Child><Event>`
64
+
65
+ ```ts
66
+ import { Base, type DelegatedEvent } from '@studiometa/js-toolkit';
67
+
68
+ class AccordionItem extends Base<{ $emits: { open: { height: number } } }> {
69
+ static config = { name: 'AccordionItem' };
70
+ }
71
+
72
+ class Accordion extends Base {
73
+ static config = { name: 'Accordion', components: { AccordionItem } };
74
+
75
+ onAccordionItemOpen({ event, target, payload }: DelegatedEvent<AccordionItem, 'open'>) {
76
+ console.log(target.$id, payload.height);
77
+ }
78
+ }
79
+ ```
80
+
81
+ ```ts
82
+ interface DelegatedEvent<T extends Base = Base, K extends string = string> {
83
+ event: Event;
84
+ target: T;
85
+ payload: EmitDetail<PropsOf<T>, K>;
86
+ }
87
+ ```
88
+
89
+ `target` is the child **instance**. `payload` is `event.detail`, typed from the child's `$emits`.
90
+
91
+ **`config.components` is what disambiguates the name**
92
+
93
+ `onSliderDragStart` is `SliderDrag` + `start`, or `Slider` + `drag-start`. The name set from `config.components` decides. A child that is not declared there is not resolved.
94
+
95
+ A lazy child works the same way, because the key is the name and nothing has to be downloaded to resolve a handler.
96
+
97
+ ## `onWindow<Event>` and `onDocument<Event>`
98
+
99
+ ```ts
100
+ import { Base, type GlobalEvent } from '@studiometa/js-toolkit';
101
+
102
+ class ClickOutside extends Base {
103
+ static config = { name: 'ClickOutside' };
104
+
105
+ onDocumentClick({ event }: GlobalEvent<MouseEvent>) {
106
+ if (!event.composedPath().includes(this.$el)) {
107
+ this.$el.removeAttribute('data-option-open');
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ ```ts
114
+ interface GlobalEvent<T extends Event = Event> {
115
+ event: T;
116
+ target: Window | Document;
117
+ }
118
+ ```
119
+
120
+ - **Phase: bubble, always.** `onDocumentClick` hears what `document.addEventListener('click', …)` hears. To hear a descendant's non-bubbling event, use `on<Ref><Event>`.
121
+ - `target` is the global the handler names. There is no `payload` and no `index`.
122
+ - Listener options such as `once` and `passive` are not part of this. Use [`$on()`](instance-methods.md#on) for those.
123
+
124
+ ## Delegation
125
+
126
+ Ref and child handlers are delegated from `this.$el`:
127
+
128
+ - **One listener per event type** on the root element.
129
+ - The handler walks from `event.target` up to `this.$el`, reads the instance map of each element, and calls `on<Name><Event>` for the first **mounted** instance that matches.
130
+ - A ref or a child inserted later needs **no new binding**.
131
+ - Events that do not bubble — `focus`, `blur`, `scroll`, `mouseenter`, `mouseleave` — are delegated from the **capture** phase.
132
+
133
+ ## Typing
134
+
135
+ A method named by convention is **not typed by convention**: the name is resolved at runtime, so annotate the payload with `RefEvent`, `DelegatedEvent` or `GlobalEvent`.
136
+
137
+ The [`@on` decorator](decorators/on.md) checks that annotation against a real target instead of leaving it unverified.
138
+
139
+ ## Dynamic sets of events
140
+
141
+ A handler name belongs to the class. When the set of events is **data** — one subscription per markup declaration, with its own modifiers — bind it yourself and own the cleanup:
142
+
143
+ ```js
144
+ mounted() {
145
+ return this.$options.events.map((type) => this.$on(type, this.handle));
146
+ }
147
+ ```
148
+
149
+ That is the intended path, not a workaround.