chiplet 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/README.md +2 -5
  2. package/dist/assets/positioning.css.ts.vanilla-BLJ90UCF.css +60 -0
  3. package/dist/component/button/Button.js +5 -5
  4. package/dist/component/button/Button.js.map +1 -1
  5. package/dist/component/button/IconButton.js +1 -1
  6. package/dist/component/button/IconButton.js.map +1 -1
  7. package/dist/component/button/Interactive.js +2 -17
  8. package/dist/component/button/Interactive.js.map +1 -1
  9. package/dist/component/button/LinkButton.js +7 -5
  10. package/dist/component/button/LinkButton.js.map +1 -1
  11. package/dist/component/button/index.js +1 -0
  12. package/dist/component/button/index.js.map +1 -1
  13. package/dist/component/button/style/{index.css.vanilla.js → index.css.js} +5 -5
  14. package/dist/component/button/style/index.css.js.map +1 -0
  15. package/dist/component/checkbox/Checkbox.js +9 -19
  16. package/dist/component/checkbox/Checkbox.js.map +1 -1
  17. package/dist/component/checkbox/CheckboxGroup.js +2 -17
  18. package/dist/component/checkbox/CheckboxGroup.js.map +1 -1
  19. package/dist/component/checkbox/Radio.js +7 -18
  20. package/dist/component/checkbox/Radio.js.map +1 -1
  21. package/dist/component/checkbox/RadioGroup.js +2 -17
  22. package/dist/component/checkbox/RadioGroup.js.map +1 -1
  23. package/dist/component/checkbox/Switch.js +2 -2
  24. package/dist/component/checkbox/Switch.js.map +1 -1
  25. package/dist/component/checkbox/icon/index.js +0 -29
  26. package/dist/component/checkbox/icon/index.js.map +1 -1
  27. package/dist/component/checkbox/style/{index.css.vanilla.js → index.css.js} +4 -5
  28. package/dist/component/checkbox/style/index.css.js.map +1 -0
  29. package/dist/component/header/Header.js +2 -2
  30. package/dist/component/header/Header.js.map +1 -1
  31. package/dist/component/header/style/index.css.js +7 -0
  32. package/dist/component/header/style/index.css.js.map +1 -0
  33. package/dist/component/index.js +21 -19
  34. package/dist/component/index.js.map +1 -1
  35. package/dist/component/input/Input.js +7 -18
  36. package/dist/component/input/Input.js.map +1 -1
  37. package/dist/component/input/SearchInput.js +7 -13
  38. package/dist/component/input/SearchInput.js.map +1 -1
  39. package/dist/component/input/style/{index.css.vanilla.js → index.css.js} +5 -5
  40. package/dist/component/input/style/index.css.js.map +1 -0
  41. package/dist/component/menu/Menu.js +2 -28
  42. package/dist/component/menu/Menu.js.map +1 -1
  43. package/dist/component/menu/MenuButton.js +1 -3
  44. package/dist/component/menu/MenuButton.js.map +1 -1
  45. package/dist/component/menu/MenuItem.js +2 -18
  46. package/dist/component/menu/MenuItem.js.map +1 -1
  47. package/dist/component/menu/MenuItemCheckbox.js +4 -31
  48. package/dist/component/menu/MenuItemCheckbox.js.map +1 -1
  49. package/dist/component/menu/MenuItemRadio.js +5 -32
  50. package/dist/component/menu/MenuItemRadio.js.map +1 -1
  51. package/dist/component/menu/renderMenuItem.js +6 -2
  52. package/dist/component/menu/renderMenuItem.js.map +1 -1
  53. package/dist/component/popover/Dialog.js +2 -17
  54. package/dist/component/popover/Dialog.js.map +1 -1
  55. package/dist/component/popover/DismissButton.js +2 -19
  56. package/dist/component/popover/DismissButton.js.map +1 -1
  57. package/dist/component/popover/Popover.js +2 -17
  58. package/dist/component/popover/Popover.js.map +1 -1
  59. package/dist/component/popover/ShadowRoot.js +34 -0
  60. package/dist/component/popover/ShadowRoot.js.map +1 -0
  61. package/dist/component/popover/Tooltip.js +4 -18
  62. package/dist/component/popover/Tooltip.js.map +1 -1
  63. package/dist/component/popover/index.js +1 -0
  64. package/dist/component/popover/index.js.map +1 -1
  65. package/dist/component/popover/style/{index.css.vanilla.js → index.css.js} +5 -5
  66. package/dist/component/popover/style/index.css.js.map +1 -0
  67. package/dist/component/progress/Spinner.js +1 -1
  68. package/dist/component/progress/style/{index.css.vanilla.js → index.css.js} +4 -5
  69. package/dist/component/progress/style/index.css.js.map +1 -0
  70. package/dist/component/select/AutoComplete.js +7 -30
  71. package/dist/component/select/AutoComplete.js.map +1 -1
  72. package/dist/component/select/Group.js +3 -18
  73. package/dist/component/select/Group.js.map +1 -1
  74. package/dist/component/select/Option.js +7 -22
  75. package/dist/component/select/Option.js.map +1 -1
  76. package/dist/component/select/Select.js +6 -29
  77. package/dist/component/select/Select.js.map +1 -1
  78. package/dist/component/select/Separator.js +1 -1
  79. package/dist/component/select/style/{index.css.vanilla.js → index.css.js} +5 -5
  80. package/dist/component/select/style/index.css.js.map +1 -0
  81. package/dist/component/style/article.css.js +6 -0
  82. package/dist/component/style/article.css.js.map +1 -0
  83. package/dist/component/style/index.js +1 -1
  84. package/dist/component/typography/Body1.js +1 -1
  85. package/dist/component/typography/Body2.js +1 -1
  86. package/dist/component/typography/Body3.js +1 -1
  87. package/dist/component/typography/Caption1.js +1 -1
  88. package/dist/component/typography/Caption2.js +1 -1
  89. package/dist/component/typography/Heading1.js +1 -1
  90. package/dist/component/typography/Heading2.js +1 -1
  91. package/dist/component/typography/Heading3.js +1 -1
  92. package/dist/component/typography/Heading4.js +1 -1
  93. package/dist/component/typography/style/{index.css.vanilla.js → index.css.js} +4 -5
  94. package/dist/component/typography/style/index.css.js.map +1 -0
  95. package/dist/hook/accessibility/keyboard/Keyboard.js +6 -18
  96. package/dist/hook/accessibility/keyboard/Keyboard.js.map +1 -1
  97. package/dist/hook/accessibility/keyboard/Roving.js +0 -15
  98. package/dist/hook/accessibility/keyboard/Roving.js.map +1 -1
  99. package/dist/hook/accessibility/keyboard/context/index.js.map +1 -1
  100. package/dist/hook/accessibility/keyboard/hook/useLastFocused.js +1 -4
  101. package/dist/hook/accessibility/keyboard/hook/useLastFocused.js.map +1 -1
  102. package/dist/hook/accessibility/keyboard/hook/useNavigate.js.map +1 -1
  103. package/dist/hook/accessibility/keyboard/resolve.js +1 -4
  104. package/dist/hook/accessibility/keyboard/resolve.js.map +1 -1
  105. package/dist/hook/accessibility/keyboard/sort.js +0 -3
  106. package/dist/hook/accessibility/keyboard/sort.js.map +1 -1
  107. package/dist/hook/accessibility/keyboard/tree.js +1 -4
  108. package/dist/hook/accessibility/keyboard/tree.js.map +1 -1
  109. package/dist/hook/accessibility/keyboard/useController.js +2 -15
  110. package/dist/hook/accessibility/keyboard/useController.js.map +1 -1
  111. package/dist/hook/accessibility/keyboard/useKeyboard.js +2 -16
  112. package/dist/hook/accessibility/keyboard/useKeyboard.js.map +1 -1
  113. package/dist/hook/document/useHighlight.js +1 -6
  114. package/dist/hook/document/useHighlight.js.map +1 -1
  115. package/dist/hook/form/context/index.js.map +1 -1
  116. package/dist/hook/form/useAutoComplete.js +2 -16
  117. package/dist/hook/form/useAutoComplete.js.map +1 -1
  118. package/dist/hook/form/useChange.js.map +1 -1
  119. package/dist/hook/form/useCheckbox.js +0 -16
  120. package/dist/hook/form/useCheckbox.js.map +1 -1
  121. package/dist/hook/form/useChecked.js +1 -14
  122. package/dist/hook/form/useChecked.js.map +1 -1
  123. package/dist/hook/form/useForm.js +1 -15
  124. package/dist/hook/form/useForm.js.map +1 -1
  125. package/dist/hook/form/useGroup.js +18 -30
  126. package/dist/hook/form/useGroup.js.map +1 -1
  127. package/dist/hook/form/useName.js.map +1 -1
  128. package/dist/hook/form/useOption.js +0 -16
  129. package/dist/hook/form/useOption.js.map +1 -1
  130. package/dist/hook/form/useRadio.js +0 -16
  131. package/dist/hook/form/useRadio.js.map +1 -1
  132. package/dist/hook/form/useSelect.js +0 -16
  133. package/dist/hook/form/useSelect.js.map +1 -1
  134. package/dist/hook/form/useValue.js +0 -15
  135. package/dist/hook/form/useValue.js.map +1 -1
  136. package/dist/hook/index.js +22 -21
  137. package/dist/hook/index.js.map +1 -1
  138. package/dist/hook/observable/useObservable.js +6 -1
  139. package/dist/hook/observable/useObservable.js.map +1 -1
  140. package/dist/hook/popover/context/index.js.map +1 -1
  141. package/dist/hook/popover/index.js +2 -1
  142. package/dist/hook/popover/index.js.map +1 -1
  143. package/dist/hook/popover/style/positioning.css.js +13 -0
  144. package/dist/hook/popover/style/positioning.css.js.map +1 -0
  145. package/dist/hook/popover/useAnchorPositioning.js +6 -88
  146. package/dist/hook/popover/useAnchorPositioning.js.map +1 -1
  147. package/dist/hook/popover/useDialog.js +1 -15
  148. package/dist/hook/popover/useDialog.js.map +1 -1
  149. package/dist/hook/popover/useLightDismiss.js +16 -4
  150. package/dist/hook/popover/useLightDismiss.js.map +1 -1
  151. package/dist/hook/popover/useOverlay.js +8 -20
  152. package/dist/hook/popover/useOverlay.js.map +1 -1
  153. package/dist/hook/popover/usePopover.js +12 -23
  154. package/dist/hook/popover/usePopover.js.map +1 -1
  155. package/dist/hook/popover/usePositioning.js +10 -16
  156. package/dist/hook/popover/usePositioning.js.map +1 -1
  157. package/dist/hook/popover/useReturnFocus.js.map +1 -1
  158. package/dist/hook/popover/useTooltip.js +4 -15
  159. package/dist/hook/popover/useTooltip.js.map +1 -1
  160. package/dist/hook/promise/usePromise.js +1 -1
  161. package/dist/hook/promise/usePromise.js.map +1 -1
  162. package/dist/hook/react/refValue.js +0 -3
  163. package/dist/hook/react/refValue.js.map +1 -1
  164. package/dist/hook/react/useActivate.js +4 -4
  165. package/dist/hook/react/useActivate.js.map +1 -1
  166. package/dist/hook/react/useConst.js +3 -2
  167. package/dist/hook/react/useConst.js.map +1 -1
  168. package/dist/hook/react/useInteractive.js +1 -4
  169. package/dist/hook/react/useInteractive.js.map +1 -1
  170. package/dist/hook/react/useRefCallback.js.map +1 -1
  171. package/dist/hook/react/useUniqueId.js +1 -4
  172. package/dist/hook/react/useUniqueId.js.map +1 -1
  173. package/dist/index.js +112 -109
  174. package/dist/index.js.map +1 -1
  175. package/dist/infra/index.js +1 -1
  176. package/dist/infra/logging/logger.js +13 -10
  177. package/dist/infra/logging/logger.js.map +1 -1
  178. package/dist/theme/defineTheme.js +0 -3
  179. package/dist/theme/defineTheme.js.map +1 -1
  180. package/dist/theme/{global.css.vanilla.js → global.css.js} +4 -4
  181. package/dist/theme/global.css.js.map +1 -0
  182. package/dist/theme/index.js +5 -3
  183. package/dist/theme/index.js.map +1 -1
  184. package/dist/theme/{theme.css.vanilla.js → theme.css.js} +3 -3
  185. package/dist/theme/theme.css.js.map +1 -0
  186. package/dist/theme/{token.css.vanilla.js → token.css.js} +2 -2
  187. package/dist/theme/token.css.js.map +1 -0
  188. package/dist/theme/useSystemColorScheme.js +16 -16
  189. package/dist/theme/useSystemColorScheme.js.map +1 -1
  190. package/dist/util/array/index.js +0 -1
  191. package/dist/util/array/index.js.map +1 -1
  192. package/dist/util/document/{accessibility.css.vanilla.js → accessibility.css.js} +1 -1
  193. package/dist/util/document/accessibility.css.js.map +1 -0
  194. package/dist/util/document/index.js +1 -1
  195. package/dist/util/file/readAsDataURL.js +15 -4
  196. package/dist/util/file/readAsDataURL.js.map +1 -1
  197. package/dist/util/index.js +28 -30
  198. package/dist/util/index.js.map +1 -1
  199. package/dist/util/linked-list/buildLinkedList.js.map +1 -1
  200. package/dist/util/lock/lock.js +0 -2
  201. package/dist/util/lock/lock.js.map +1 -1
  202. package/dist/util/random/index.js +0 -1
  203. package/dist/util/random/index.js.map +1 -1
  204. package/dist/util/tree/addTreeNode.js.map +1 -1
  205. package/dist/util/tree/attachChild.js +7 -1
  206. package/dist/util/tree/attachChild.js.map +1 -1
  207. package/dist/util/tree/buildTree.js.map +1 -1
  208. package/dist/util/tree/detachChild.js +3 -0
  209. package/dist/util/tree/detachChild.js.map +1 -1
  210. package/dist/util/tree/iterateChildren.js.map +1 -1
  211. package/dist/util/tree/iterateTree.js.map +1 -1
  212. package/package.json +49 -47
  213. package/src/component/button/Button.tsx +4 -5
  214. package/src/component/button/IconButton.tsx +1 -1
  215. package/src/component/button/LinkButton.tsx +14 -6
  216. package/src/component/button/index.ts +1 -0
  217. package/src/component/checkbox/Checkbox.tsx +8 -1
  218. package/src/component/checkbox/Radio.tsx +5 -1
  219. package/src/component/checkbox/Switch.tsx +1 -1
  220. package/src/component/checkbox/icon/index.ts +1 -1
  221. package/src/component/header/Header.tsx +1 -1
  222. package/src/component/input/Input.tsx +5 -1
  223. package/src/component/input/SearchInput.tsx +10 -9
  224. package/src/component/menu/Menu.tsx +1 -1
  225. package/src/component/menu/MenuItemCheckbox.tsx +1 -1
  226. package/src/component/menu/MenuItemRadio.tsx +1 -1
  227. package/src/component/menu/renderMenuItem.tsx +5 -1
  228. package/src/component/popover/ShadowRoot.tsx +42 -0
  229. package/src/component/popover/Tooltip.tsx +2 -2
  230. package/src/component/popover/index.ts +1 -0
  231. package/src/component/select/AutoComplete.tsx +3 -7
  232. package/src/component/select/Group.tsx +1 -1
  233. package/src/component/select/Option.tsx +1 -1
  234. package/src/component/select/Select.tsx +3 -7
  235. package/src/hook/accessibility/keyboard/Keyboard.tsx +1 -1
  236. package/src/hook/accessibility/keyboard/Roving.tsx +1 -1
  237. package/src/hook/accessibility/keyboard/context/index.ts +2 -2
  238. package/src/hook/accessibility/keyboard/hook/useLastFocused.ts +7 -1
  239. package/src/hook/accessibility/keyboard/hook/useNavigate.ts +1 -1
  240. package/src/hook/accessibility/keyboard/resolve.ts +1 -1
  241. package/src/hook/accessibility/keyboard/useController.ts +3 -2
  242. package/src/hook/accessibility/keyboard/useKeyboard.ts +3 -2
  243. package/src/hook/document/useHighlight.ts +5 -4
  244. package/src/hook/form/context/index.ts +1 -1
  245. package/src/hook/form/useAutoComplete.ts +14 -14
  246. package/src/hook/form/useChange.ts +1 -1
  247. package/src/hook/form/useCheckbox.ts +2 -2
  248. package/src/hook/form/useChecked.ts +3 -2
  249. package/src/hook/form/useForm.ts +1 -1
  250. package/src/hook/form/useGroup.ts +20 -21
  251. package/src/hook/form/useName.ts +1 -1
  252. package/src/hook/form/useOption.ts +2 -2
  253. package/src/hook/form/useRadio.ts +2 -2
  254. package/src/hook/form/useSelect.ts +15 -12
  255. package/src/hook/form/useValue.ts +3 -2
  256. package/src/hook/observable/useObservable.ts +14 -1
  257. package/src/hook/popover/context/index.ts +1 -1
  258. package/src/hook/popover/style/positioning.css.ts +112 -0
  259. package/src/hook/popover/useAnchorPositioning.ts +16 -105
  260. package/src/hook/popover/useDialog.ts +5 -4
  261. package/src/hook/popover/useLightDismiss.ts +27 -0
  262. package/src/hook/popover/useOverlay.ts +17 -8
  263. package/src/hook/popover/usePopover.ts +22 -24
  264. package/src/hook/popover/usePositioning.ts +17 -20
  265. package/src/hook/popover/useReturnFocus.ts +12 -3
  266. package/src/hook/popover/useTooltip.ts +10 -9
  267. package/src/hook/promise/usePromise.ts +4 -1
  268. package/src/hook/react/useActivate.ts +8 -1
  269. package/src/hook/react/useConst.ts +3 -3
  270. package/src/hook/react/useRefCallback.ts +3 -1
  271. package/src/infra/logging/logger.ts +43 -19
  272. package/src/theme/global.css.ts +1 -28
  273. package/src/theme/index.ts +4 -0
  274. package/src/theme/useSystemColorScheme.ts +22 -20
  275. package/src/util/array/index.ts +0 -1
  276. package/src/util/document/accessibility.css.ts +1 -1
  277. package/src/util/file/readAsDataURL.ts +17 -4
  278. package/src/util/linked-list/buildLinkedList.ts +1 -1
  279. package/src/util/number/index.ts +2 -0
  280. package/src/util/random/index.ts +4 -1
  281. package/src/util/tree/addTreeNode.ts +1 -1
  282. package/src/util/tree/attachChild.ts +13 -2
  283. package/src/util/tree/buildTree.ts +1 -1
  284. package/src/util/tree/detachChild.ts +7 -1
  285. package/src/util/tree/iterateChildren.ts +1 -1
  286. package/src/util/tree/iterateTree.ts +1 -1
  287. package/dist/component/button/style/index.css.vanilla.js.map +0 -1
  288. package/dist/component/checkbox/style/index.css.vanilla.js.map +0 -1
  289. package/dist/component/header/style/index.css.vanilla.js +0 -7
  290. package/dist/component/header/style/index.css.vanilla.js.map +0 -1
  291. package/dist/component/input/style/index.css.vanilla.js.map +0 -1
  292. package/dist/component/popover/style/index.css.vanilla.js.map +0 -1
  293. package/dist/component/progress/style/index.css.vanilla.js.map +0 -1
  294. package/dist/component/select/style/index.css.vanilla.js.map +0 -1
  295. package/dist/component/style/article.css.vanilla.js +0 -6
  296. package/dist/component/style/article.css.vanilla.js.map +0 -1
  297. package/dist/component/typography/style/index.css.vanilla.js.map +0 -1
  298. package/dist/theme/global.css.vanilla.js.map +0 -1
  299. package/dist/theme/theme.css.vanilla.js.map +0 -1
  300. package/dist/theme/token.css.vanilla.js.map +0 -1
  301. package/dist/util/array/fromAsync.js +0 -11
  302. package/dist/util/array/fromAsync.js.map +0 -1
  303. package/dist/util/document/accessibility.css.vanilla.js.map +0 -1
  304. package/src/util/array/fromAsync.ts +0 -11
  305. /package/dist/{article.css → assets/article.css.ts.vanilla-s_HEpsy3.css} +0 -0
  306. /package/dist/{global.css → assets/global.css.ts.vanilla-CTwjHiaM.css} +0 -0
  307. /package/dist/{index8.css → assets/index.css.ts.vanilla-9qGDrdgn.css} +0 -0
  308. /package/dist/{index6.css → assets/index.css.ts.vanilla-BsBngo8U.css} +0 -0
  309. /package/dist/{index2.css → assets/index.css.ts.vanilla-CVNLkHc9.css} +0 -0
  310. /package/dist/{index3.css → assets/index.css.ts.vanilla-C_RzxiYH.css} +0 -0
  311. /package/dist/{index5.css → assets/index.css.ts.vanilla-CvQQLJ-M.css} +0 -0
  312. /package/dist/{index.css → assets/index.css.ts.vanilla-DGmHFJbF.css} +0 -0
  313. /package/dist/{index4.css → assets/index.css.ts.vanilla-VHSAjLub.css} +0 -0
  314. /package/dist/{index7.css → assets/index.css.ts.vanilla-kgyRRvgH.css} +0 -0
  315. /package/dist/{theme.css → assets/theme.css.ts.vanilla-Bjn8sb_B.css} +0 -0
  316. /package/dist/{token.css → assets/token.css.ts.vanilla-B3LtFaO7.css} +0 -0
@@ -4,11 +4,15 @@ import {
4
4
  SpanStatusCode,
5
5
  trace,
6
6
  type Attributes,
7
- type AttributeValue,
8
7
  type MetricOptions,
9
8
  type Span,
10
9
  } from '@opentelemetry/api'
11
- import { logs, SeverityNumber } from '@opentelemetry/api-logs'
10
+ import {
11
+ logs,
12
+ SeverityNumber,
13
+ type LogAttributes,
14
+ type LogBody,
15
+ } from '@opentelemetry/api-logs'
12
16
  import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web'
13
17
  import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http'
14
18
  import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'
@@ -114,7 +118,7 @@ class Logger {
114
118
 
115
119
  #meter = metrics.getMeter(this.#name)
116
120
 
117
- #attributes: Attributes = {}
121
+ #attributes: LogAttributes = {}
118
122
 
119
123
  async configure(config?: {
120
124
  debug?: boolean | undefined
@@ -123,7 +127,7 @@ class Logger {
123
127
  traceProcessors?: readonly SpanProcessor[] | undefined
124
128
  metricReaders?: readonly IMetricReader[] | undefined
125
129
  resource?: Resource | undefined
126
- attributes?: Attributes | undefined
130
+ attributes?: LogAttributes | undefined
127
131
  }) {
128
132
  await this.dispose()
129
133
 
@@ -142,15 +146,17 @@ class Logger {
142
146
  processors: compact<LogRecordProcessor>([
143
147
  ...(config?.logProcessors ?? []),
144
148
  config?.collector
145
- ? new BatchLogRecordProcessor(
146
- new OTLPLogExporter({
149
+ ? new BatchLogRecordProcessor({
150
+ exporter: new OTLPLogExporter({
147
151
  url: config.collector.url,
148
152
  headers: { ...config.collector.headers },
149
- })
150
- )
153
+ }),
154
+ })
151
155
  : null,
152
156
  config?.debug && isDev
153
- ? new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())
157
+ ? new SimpleLogRecordProcessor({
158
+ exporter: new ConsoleLogRecordExporter(),
159
+ })
154
160
  : null,
155
161
  ]),
156
162
  })
@@ -273,8 +279,8 @@ class Logger {
273
279
  private collect(
274
280
  level: SeverityNumber,
275
281
  event: string,
276
- body?: AttributeValue | Attributes,
277
- attributes?: Attributes
282
+ body?: LogBody,
283
+ attributes?: LogAttributes
278
284
  ) {
279
285
  this.#logger.emit({
280
286
  eventName: event,
@@ -288,23 +294,27 @@ class Logger {
288
294
  })
289
295
  }
290
296
 
291
- trace = (event: string, message?: string, attributes?: Attributes) => {
297
+ trace = (event: string, message?: string, attributes?: LogAttributes) => {
292
298
  this.collect(SeverityNumber.TRACE, event, message, attributes)
293
299
  }
294
300
 
295
- debug = (event: string, message?: string, attributes?: Attributes) => {
301
+ debug = (event: string, message?: string, attributes?: LogAttributes) => {
296
302
  this.collect(SeverityNumber.DEBUG, event, message, attributes)
297
303
  }
298
304
 
299
- info = (event: string, message?: string, attributes?: Attributes) => {
305
+ info = (event: string, message?: string, attributes?: LogAttributes) => {
300
306
  this.collect(SeverityNumber.INFO, event, message, attributes)
301
307
  }
302
308
 
303
- warn = (event: string, message?: string, attributes?: Attributes) => {
309
+ warn = (event: string, message?: string, attributes?: LogAttributes) => {
304
310
  this.collect(SeverityNumber.WARN, event, message, attributes)
305
311
  }
306
312
 
307
- error = (event: string, error?: Error | string, attributes?: Attributes) => {
313
+ error = (
314
+ event: string,
315
+ error?: Error | string,
316
+ attributes?: LogAttributes
317
+ ) => {
308
318
  this.collect(
309
319
  SeverityNumber.ERROR,
310
320
  event,
@@ -313,7 +323,11 @@ class Logger {
313
323
  )
314
324
  }
315
325
 
316
- fatal = (event: string, error?: Error | string, attributes?: Attributes) => {
326
+ fatal = (
327
+ event: string,
328
+ error?: Error | string,
329
+ attributes?: LogAttributes
330
+ ) => {
317
331
  this.collect(
318
332
  SeverityNumber.FATAL,
319
333
  event,
@@ -322,7 +336,10 @@ class Logger {
322
336
  )
323
337
  }
324
338
 
325
- private parseError(error: unknown): Attributes | undefined {
339
+ private parseError(
340
+ error: unknown,
341
+ seen: Set<unknown> = new Set()
342
+ ): LogAttributes | undefined {
326
343
  if (typeof error === 'string') {
327
344
  return {
328
345
  [ATTR_EXCEPTION_MESSAGE]: error,
@@ -330,7 +347,14 @@ class Logger {
330
347
  }
331
348
 
332
349
  if (isError(error)) {
333
- const cause = this.parseError(error.cause)
350
+ // Guard against circular 'cause' chains, which would otherwise recurse
351
+ // until the stack overflows.
352
+ let cause: LogAttributes | undefined
353
+
354
+ if (!seen.has(error)) {
355
+ seen.add(error)
356
+ cause = this.parseError(error.cause, seen)
357
+ }
334
358
 
335
359
  return {
336
360
  [ATTR_EXCEPTION_TYPE]: error.name,
@@ -1,5 +1,4 @@
1
1
  import {
2
- generateDeterministicId,
3
2
  VirtualActiveSelector,
4
3
  VirtualDisabledSelector,
5
4
  VirtualFocusSelector,
@@ -10,6 +9,7 @@ import {
10
9
  style,
11
10
  type StyleRule,
12
11
  } from '@vanilla-extract/css'
12
+ import { generateDeterministicId } from '../util/random/generateDeterministicId'
13
13
  import { theme, themeClass } from './theme.css'
14
14
  import { tokenClass } from './token.css'
15
15
 
@@ -67,30 +67,3 @@ export const SquircleStyle = style({
67
67
  export const CircleStyle = style({
68
68
  borderRadius: '100vmax',
69
69
  })
70
-
71
- declare module 'csstype' {
72
- export interface StandardShorthandProperties<
73
- TLength = (string & {}) | 0,
74
- TTime = string & {},
75
- > {
76
- /**
77
- * The corner-shape shorthand CSS property specifies the shape of a box's corners, within the area specified by its border-radius property value.
78
- *
79
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/corner-shape
80
- */
81
- cornerShape?: Property.CornerShape | undefined
82
- }
83
-
84
- export namespace Property {
85
- export type CornerShape =
86
- | Globals
87
- | 'round'
88
- | 'scoop'
89
- | 'bevel'
90
- | 'notch'
91
- | 'square'
92
- | 'squircle'
93
- | `superellipse(${number})`
94
- | (string & {})
95
- }
96
- }
@@ -1,9 +1,13 @@
1
1
  export * from './ColorScheme'
2
2
 
3
+ export * from './defineTheme'
4
+
3
5
  export * from './palette'
4
6
 
5
7
  export * from './typography'
6
8
 
9
+ export * from './useSystemColorScheme'
10
+
7
11
  export * from './token.css'
8
12
 
9
13
  export * from './theme.css'
@@ -1,29 +1,31 @@
1
- import { useEffect, useState } from 'react'
1
+ import { useConst } from '#hook'
2
+ import { useRef, useSyncExternalStore } from 'react'
2
3
 
3
- export function useSystemColorScheme() {
4
- const [query] = useState(() =>
5
- typeof window !== 'undefined'
6
- ? window.matchMedia('(prefers-color-scheme: dark)')
7
- : null
8
- )
4
+ const QUERY = '(prefers-color-scheme: dark)'
9
5
 
10
- const [isDarkMode, setIsDarkMode] = useState(query?.matches)
11
-
12
- useEffect(() => {
13
- if (!query) {
14
- return
15
- }
6
+ export function useSystemColorScheme() {
7
+ // Reuse one lazily created MediaQueryList per hook instance for both
8
+ // subscribing and snapshot reads; 'getSnapshot' runs on every render, so
9
+ // it must not allocate a fresh query each time.
10
+ const queryRef = useRef<MediaQueryList | null>(null)
16
11
 
17
- const onChange = (event: MediaQueryListEvent) => {
18
- setIsDarkMode(event.matches)
19
- }
12
+ const subscribe = useConst(() => (onStoreChange: () => void) => {
13
+ const query = (queryRef.current ??= window.matchMedia(QUERY))
20
14
 
21
- query.addEventListener('change', onChange)
15
+ query.addEventListener('change', onStoreChange)
22
16
 
23
17
  return () => {
24
- query.removeEventListener('change', onChange)
18
+ query.removeEventListener('change', onStoreChange)
25
19
  }
26
- }, [query])
20
+ })
27
21
 
28
- return isDarkMode ? 'dark' : 'light'
22
+ return useSyncExternalStore(
23
+ subscribe,
24
+ () => (queryRef.current ??= window.matchMedia(QUERY)).matches,
25
+ // Server rendering assumes the default 'light' preference so hydration
26
+ // matches; the client re-renders with the actual value after hydration.
27
+ () => false
28
+ )
29
+ ? 'dark'
30
+ : 'light'
29
31
  }
@@ -1,2 +1 @@
1
- export * from './fromAsync'
2
1
  export * from './toggle'
@@ -1,4 +1,4 @@
1
- import { generateDeterministicId } from '../random'
1
+ import { generateDeterministicId } from '../random/generateDeterministicId'
2
2
 
3
3
  export const VirtualFocus = generateDeterministicId('data-focus-visible-')
4
4
  export const VirtualFocusSelector = `[${VirtualFocus}="true"]` as const
@@ -7,13 +7,26 @@ export function readAsDataURL(blob: Blob, signal?: AbortSignal | undefined) {
7
7
  return new Promise<string>((resolve, reject) => {
8
8
  const reader = new FileReader()
9
9
 
10
- reader.onabort = () => reject(AbortError())
10
+ const onAbort = () => reader.abort()
11
11
 
12
- reader.onerror = () => reject(reader.error)
12
+ const cleanup = () => signal?.removeEventListener('abort', onAbort)
13
13
 
14
- reader.onload = () => resolve(reader.result as string)
14
+ reader.onabort = () => {
15
+ cleanup()
16
+ reject(AbortError())
17
+ }
15
18
 
16
- signal?.addEventListener('abort', () => reader.abort(), { once: true })
19
+ reader.onerror = () => {
20
+ cleanup()
21
+ reject(reader.error)
22
+ }
23
+
24
+ reader.onload = () => {
25
+ cleanup()
26
+ resolve(reader.result as string)
27
+ }
28
+
29
+ signal?.addEventListener('abort', onAbort, { once: true })
17
30
 
18
31
  reader.readAsDataURL(blob)
19
32
 
@@ -1,4 +1,4 @@
1
- import { LinkedListNode } from '.'
1
+ import { LinkedListNode } from './node'
2
2
 
3
3
  export function buildLinkedList<T>(arr: Iterable<T>) {
4
4
  const head = LinkedListNode(null as T)
@@ -1 +1,3 @@
1
1
  export * from './isNumber'
2
+
3
+ export type * from './range'
@@ -1,4 +1,7 @@
1
- export * from './generateDeterministicId'
1
+ // 'generateDeterministicId' is deliberately not exported from this barrel:
2
+ // it imports '@vanilla-extract/css', which has side effects, so re-exporting
3
+ // it would pull them into every '#util' consumer. Import it by direct
4
+ // relative path instead.
2
5
  export * from './generateDigest'
3
6
  export * from './generateUniqueId'
4
7
  export * from './toHex'
@@ -1,6 +1,6 @@
1
1
  import { attachChild } from './attachChild'
2
2
  import { iterateChildren } from './iterateChildren'
3
- import type { TreeNode } from '.'
3
+ import type { TreeNode } from './node'
4
4
 
5
5
  export function addTreeNode<T extends TreeNode<unknown>>(
6
6
  root: T | null | undefined,
@@ -1,13 +1,24 @@
1
- import type { TreeNode } from '.'
1
+ import { detachChild } from './detachChild'
2
+ import type { TreeNode } from './node'
2
3
 
3
4
  export function attachChild<T extends TreeNode<unknown>>(parent: T, child: T) {
5
+ // Detach a child that is still attached to a tree first so re-attaching
6
+ // cannot leave stale or self-referential links behind.
7
+ if (child.parent != null) {
8
+ detachChild(child.parent, child)
9
+ }
10
+
11
+ // Reset the child's sibling links so a node previously attached elsewhere
12
+ // cannot keep stale links into its former tree.
13
+ child.previousSibling = parent.lastChild ?? null
14
+ child.nextSibling = null
15
+
4
16
  if (parent.firstChild == null) {
5
17
  parent.firstChild = child
6
18
  }
7
19
 
8
20
  if (parent.lastChild) {
9
21
  parent.lastChild.nextSibling = child
10
- child.previousSibling = parent.lastChild
11
22
  }
12
23
 
13
24
  parent.lastChild = child
@@ -1,5 +1,5 @@
1
1
  import { attachChild } from './attachChild'
2
- import type { TreeNode } from '.'
2
+ import type { TreeNode } from './node'
3
3
 
4
4
  export function buildTree<T extends TreeNode<unknown>>(
5
5
  iterable: Iterable<T>,
@@ -1,4 +1,4 @@
1
- import type { TreeNode } from '.'
1
+ import type { TreeNode } from './node'
2
2
 
3
3
  export function detachChild<T extends TreeNode<unknown>>(parent: T, child: T) {
4
4
  if (parent.firstChild === child) {
@@ -17,5 +17,11 @@ export function detachChild<T extends TreeNode<unknown>>(parent: T, child: T) {
17
17
  child.nextSibling.previousSibling = child.previousSibling ?? null
18
18
  }
19
19
 
20
+ // Detach the child's own links so it cannot reach back into the tree it
21
+ // was removed from.
22
+ child.parent = null
23
+ child.previousSibling = null
24
+ child.nextSibling = null
25
+
20
26
  return parent
21
27
  }
@@ -1,4 +1,4 @@
1
- import type { TreeNode } from '.'
1
+ import type { TreeNode } from './node'
2
2
 
3
3
  export function* iterateChildren<T extends TreeNode<unknown>>(
4
4
  parent: T | null | undefined
@@ -1,4 +1,4 @@
1
- import type { TreeNode } from '.'
1
+ import type { TreeNode } from './node'
2
2
 
3
3
  export function* iterateTree<T extends TreeNode<unknown>>(
4
4
  root: T | null | undefined
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
@@ -1,7 +0,0 @@
1
- import './../../../index2.css';
2
-
3
- var HeaderStyle = '_1c43omu0';
4
- var NavStyle = '_1c43omu1';
5
-
6
- export { HeaderStyle, NavStyle };
7
- //# sourceMappingURL=index.css.vanilla.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
@@ -1,6 +0,0 @@
1
- import './../../article.css';
2
-
3
- var ArticleStyle = '_274mrm4';
4
-
5
- export { ArticleStyle };
6
- //# sourceMappingURL=article.css.vanilla.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"article.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"global.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"theme.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"token.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -1,11 +0,0 @@
1
- 'use strict';
2
- async function fromAsync(iterator) {
3
- const array = [];
4
- for await (const item of iterator) {
5
- array.push(item);
6
- }
7
- return array;
8
- }
9
-
10
- export { fromAsync };
11
- //# sourceMappingURL=fromAsync.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fromAsync.js","sources":["../../../src/util/array/fromAsync.ts"],"sourcesContent":["export async function fromAsync<T>(\n iterator: AsyncIteratorObject<T> | IteratorObject<T>\n) {\n const array: T[] = []\n\n for await (const item of iterator) {\n array.push(item)\n }\n\n return array\n}\n"],"names":[],"mappings":";AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EACpB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACA;AACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,IAAa,CAAA,CAAC;AAEpB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB,CAAA,CAAA,CAAA,KAAQ,QAAA,CAAA,CAAU;AACjC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,EAAK,IAAI,CAAA;AAAA,CAAA,CACjB;AAEA,CAAA,CAAA,OAAO,CAAA,CAAA,CAAA,CAAA,CAAA;AACT;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"accessibility.css.vanilla.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -1,11 +0,0 @@
1
- export async function fromAsync<T>(
2
- iterator: AsyncIteratorObject<T> | IteratorObject<T>
3
- ) {
4
- const array: T[] = []
5
-
6
- for await (const item of iterator) {
7
- array.push(item)
8
- }
9
-
10
- return array
11
- }