css-calipers 0.13.0 → 0.15.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 (293) hide show
  1. package/README.md +21 -25
  2. package/dist/cjs/factory.js +0 -3
  3. package/dist/cjs/internal/createCoreApi.js +30 -9
  4. package/dist/esm/core.d.ts +21 -17
  5. package/dist/esm/core.d.ts.map +1 -1
  6. package/dist/esm/factory.d.ts +0 -2
  7. package/dist/esm/factory.d.ts.map +1 -1
  8. package/dist/esm/factory.js +0 -3
  9. package/dist/esm/internal/createCoreApi.d.ts +7 -11
  10. package/dist/esm/internal/createCoreApi.d.ts.map +1 -1
  11. package/dist/esm/internal/createCoreApi.js +30 -9
  12. package/package.json +11 -24
  13. package/RELEASING.md +0 -62
  14. package/dist/cjs/comparisons/index.js +0 -25
  15. package/dist/cjs/containerQueries/containerQueries.js +0 -115
  16. package/dist/cjs/containerQueries/factory.js +0 -123
  17. package/dist/cjs/containerQueries/helpers.js +0 -95
  18. package/dist/cjs/containerQueries/index.js +0 -16
  19. package/dist/cjs/containerQueries/linting/aspectRatio.js +0 -24
  20. package/dist/cjs/containerQueries/linting/block.js +0 -23
  21. package/dist/cjs/containerQueries/linting/core.js +0 -25
  22. package/dist/cjs/containerQueries/linting/custom.js +0 -11
  23. package/dist/cjs/containerQueries/linting/inline.js +0 -23
  24. package/dist/cjs/containerQueries/linting/resolution.js +0 -12
  25. package/dist/cjs/containerQueries/linting/style.js +0 -28
  26. package/dist/cjs/containerQueries/linting.js +0 -24
  27. package/dist/cjs/containerQueries/moduleRegistry.js +0 -5
  28. package/dist/cjs/containerQueries/modules/aspectRatio.js +0 -51
  29. package/dist/cjs/containerQueries/modules/block.js +0 -53
  30. package/dist/cjs/containerQueries/modules/custom.js +0 -43
  31. package/dist/cjs/containerQueries/modules/index.js +0 -21
  32. package/dist/cjs/containerQueries/modules/inline.js +0 -53
  33. package/dist/cjs/containerQueries/modules/size.js +0 -2
  34. package/dist/cjs/containerQueries/modules/style.js +0 -36
  35. package/dist/cjs/containerQueries/types.js +0 -2
  36. package/dist/cjs/containerQueries/validation.js +0 -191
  37. package/dist/cjs/fraction.js +0 -139
  38. package/dist/cjs/internal/createComponentQueriesApi.js +0 -56
  39. package/dist/cjs/internal/createMediaQueriesApi.js +0 -74
  40. package/dist/cjs/internal/normalizeToArray.js +0 -9
  41. package/dist/cjs/libraryHelpers/vanilla-extract.js +0 -11
  42. package/dist/cjs/logicalOperators/index.js +0 -18
  43. package/dist/cjs/mediaQueries/factory.js +0 -187
  44. package/dist/cjs/mediaQueries/helpers.js +0 -97
  45. package/dist/cjs/mediaQueries/index.js +0 -23
  46. package/dist/cjs/mediaQueries/libraryHelpers/vanilla-extract.js +0 -77
  47. package/dist/cjs/mediaQueries/linting/core.js +0 -19
  48. package/dist/cjs/mediaQueries/linting/resolution.js +0 -11
  49. package/dist/cjs/mediaQueries/linting.js +0 -24
  50. package/dist/cjs/mediaQueries/mediaQueries.js +0 -53
  51. package/dist/cjs/mediaQueries/mediaQueryFactory.js +0 -120
  52. package/dist/cjs/mediaQueries/moduleRegistry.js +0 -5
  53. package/dist/cjs/mediaQueries/modules/custom.js +0 -26
  54. package/dist/cjs/mediaQueries/modules/dimensions.js +0 -61
  55. package/dist/cjs/mediaQueries/modules/display.js +0 -20
  56. package/dist/cjs/mediaQueries/modules/environment.js +0 -20
  57. package/dist/cjs/mediaQueries/modules/index.js +0 -23
  58. package/dist/cjs/mediaQueries/modules/interaction.js +0 -26
  59. package/dist/cjs/mediaQueries/modules/preferences.js +0 -26
  60. package/dist/cjs/mediaQueries/modules/resolution.js +0 -31
  61. package/dist/cjs/mediaQueries/types.js +0 -2
  62. package/dist/cjs/mediaQueries/validation.js +0 -131
  63. package/dist/cjs/types.js +0 -2
  64. package/dist/cjs/validation.js +0 -20
  65. package/dist/esm/comparisons/index.d.ts +0 -23
  66. package/dist/esm/comparisons/index.d.ts.map +0 -1
  67. package/dist/esm/comparisons/index.js +0 -22
  68. package/dist/esm/containerQueries/containerQueries.d.ts +0 -36
  69. package/dist/esm/containerQueries/containerQueries.d.ts.map +0 -1
  70. package/dist/esm/containerQueries/containerQueries.js +0 -109
  71. package/dist/esm/containerQueries/factory.d.ts +0 -20
  72. package/dist/esm/containerQueries/factory.d.ts.map +0 -1
  73. package/dist/esm/containerQueries/factory.js +0 -119
  74. package/dist/esm/containerQueries/helpers.d.ts +0 -53
  75. package/dist/esm/containerQueries/helpers.d.ts.map +0 -1
  76. package/dist/esm/containerQueries/helpers.js +0 -82
  77. package/dist/esm/containerQueries/index.d.ts +0 -10
  78. package/dist/esm/containerQueries/index.d.ts.map +0 -1
  79. package/dist/esm/containerQueries/index.js +0 -4
  80. package/dist/esm/containerQueries/linting/aspectRatio.d.ts +0 -4
  81. package/dist/esm/containerQueries/linting/aspectRatio.d.ts.map +0 -1
  82. package/dist/esm/containerQueries/linting/aspectRatio.js +0 -19
  83. package/dist/esm/containerQueries/linting/block.d.ts +0 -4
  84. package/dist/esm/containerQueries/linting/block.d.ts.map +0 -1
  85. package/dist/esm/containerQueries/linting/block.js +0 -18
  86. package/dist/esm/containerQueries/linting/core.d.ts +0 -4
  87. package/dist/esm/containerQueries/linting/core.d.ts.map +0 -1
  88. package/dist/esm/containerQueries/linting/core.js +0 -20
  89. package/dist/esm/containerQueries/linting/custom.d.ts +0 -3
  90. package/dist/esm/containerQueries/linting/custom.d.ts.map +0 -1
  91. package/dist/esm/containerQueries/linting/custom.js +0 -7
  92. package/dist/esm/containerQueries/linting/inline.d.ts +0 -4
  93. package/dist/esm/containerQueries/linting/inline.d.ts.map +0 -1
  94. package/dist/esm/containerQueries/linting/inline.js +0 -18
  95. package/dist/esm/containerQueries/linting/resolution.d.ts +0 -1
  96. package/dist/esm/containerQueries/linting/resolution.d.ts.map +0 -1
  97. package/dist/esm/containerQueries/linting/resolution.js +0 -12
  98. package/dist/esm/containerQueries/linting/style.d.ts +0 -3
  99. package/dist/esm/containerQueries/linting/style.d.ts.map +0 -1
  100. package/dist/esm/containerQueries/linting/style.js +0 -24
  101. package/dist/esm/containerQueries/linting.d.ts +0 -4
  102. package/dist/esm/containerQueries/linting.d.ts.map +0 -1
  103. package/dist/esm/containerQueries/linting.js +0 -20
  104. package/dist/esm/containerQueries/moduleRegistry.d.ts +0 -25
  105. package/dist/esm/containerQueries/moduleRegistry.d.ts.map +0 -1
  106. package/dist/esm/containerQueries/moduleRegistry.js +0 -1
  107. package/dist/esm/containerQueries/modules/aspectRatio.d.ts +0 -17
  108. package/dist/esm/containerQueries/modules/aspectRatio.d.ts.map +0 -1
  109. package/dist/esm/containerQueries/modules/aspectRatio.js +0 -47
  110. package/dist/esm/containerQueries/modules/block.d.ts +0 -20
  111. package/dist/esm/containerQueries/modules/block.d.ts.map +0 -1
  112. package/dist/esm/containerQueries/modules/block.js +0 -49
  113. package/dist/esm/containerQueries/modules/custom.d.ts +0 -13
  114. package/dist/esm/containerQueries/modules/custom.d.ts.map +0 -1
  115. package/dist/esm/containerQueries/modules/custom.js +0 -39
  116. package/dist/esm/containerQueries/modules/index.d.ts +0 -6
  117. package/dist/esm/containerQueries/modules/index.d.ts.map +0 -1
  118. package/dist/esm/containerQueries/modules/index.js +0 -5
  119. package/dist/esm/containerQueries/modules/inline.d.ts +0 -20
  120. package/dist/esm/containerQueries/modules/inline.d.ts.map +0 -1
  121. package/dist/esm/containerQueries/modules/inline.js +0 -49
  122. package/dist/esm/containerQueries/modules/size.d.ts +0 -41
  123. package/dist/esm/containerQueries/modules/size.d.ts.map +0 -1
  124. package/dist/esm/containerQueries/modules/size.js +0 -1
  125. package/dist/esm/containerQueries/modules/style.d.ts +0 -11
  126. package/dist/esm/containerQueries/modules/style.d.ts.map +0 -1
  127. package/dist/esm/containerQueries/modules/style.js +0 -32
  128. package/dist/esm/containerQueries/types.d.ts +0 -81
  129. package/dist/esm/containerQueries/types.d.ts.map +0 -1
  130. package/dist/esm/containerQueries/types.js +0 -1
  131. package/dist/esm/containerQueries/validation.d.ts +0 -41
  132. package/dist/esm/containerQueries/validation.d.ts.map +0 -1
  133. package/dist/esm/containerQueries/validation.js +0 -187
  134. package/dist/esm/fraction.d.ts +0 -23
  135. package/dist/esm/fraction.d.ts.map +0 -1
  136. package/dist/esm/fraction.js +0 -129
  137. package/dist/esm/internal/createComponentQueriesApi.d.ts +0 -34
  138. package/dist/esm/internal/createComponentQueriesApi.d.ts.map +0 -1
  139. package/dist/esm/internal/createComponentQueriesApi.js +0 -52
  140. package/dist/esm/internal/createMediaQueriesApi.d.ts +0 -35
  141. package/dist/esm/internal/createMediaQueriesApi.d.ts.map +0 -1
  142. package/dist/esm/internal/createMediaQueriesApi.js +0 -70
  143. package/dist/esm/internal/normalizeToArray.d.ts +0 -2
  144. package/dist/esm/internal/normalizeToArray.d.ts.map +0 -1
  145. package/dist/esm/internal/normalizeToArray.js +0 -5
  146. package/dist/esm/libraryHelpers/vanilla-extract.d.ts +0 -4
  147. package/dist/esm/libraryHelpers/vanilla-extract.d.ts.map +0 -1
  148. package/dist/esm/libraryHelpers/vanilla-extract.js +0 -6
  149. package/dist/esm/logicalOperators/index.d.ts +0 -2
  150. package/dist/esm/logicalOperators/index.d.ts.map +0 -1
  151. package/dist/esm/logicalOperators/index.js +0 -17
  152. package/dist/esm/mediaQueries/factory.d.ts +0 -45
  153. package/dist/esm/mediaQueries/factory.d.ts.map +0 -1
  154. package/dist/esm/mediaQueries/factory.js +0 -183
  155. package/dist/esm/mediaQueries/helpers.d.ts +0 -40
  156. package/dist/esm/mediaQueries/helpers.d.ts.map +0 -1
  157. package/dist/esm/mediaQueries/helpers.js +0 -87
  158. package/dist/esm/mediaQueries/index.d.ts +0 -8
  159. package/dist/esm/mediaQueries/index.d.ts.map +0 -1
  160. package/dist/esm/mediaQueries/index.js +0 -7
  161. package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts +0 -5
  162. package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.d.ts.map +0 -1
  163. package/dist/esm/mediaQueries/libraryHelpers/vanilla-extract.js +0 -71
  164. package/dist/esm/mediaQueries/linting/core.d.ts +0 -5
  165. package/dist/esm/mediaQueries/linting/core.d.ts.map +0 -1
  166. package/dist/esm/mediaQueries/linting/core.js +0 -14
  167. package/dist/esm/mediaQueries/linting/resolution.d.ts +0 -3
  168. package/dist/esm/mediaQueries/linting/resolution.d.ts.map +0 -1
  169. package/dist/esm/mediaQueries/linting/resolution.js +0 -7
  170. package/dist/esm/mediaQueries/linting.d.ts +0 -4
  171. package/dist/esm/mediaQueries/linting.d.ts.map +0 -1
  172. package/dist/esm/mediaQueries/linting.js +0 -20
  173. package/dist/esm/mediaQueries/mediaQueries.d.ts +0 -23
  174. package/dist/esm/mediaQueries/mediaQueries.d.ts.map +0 -1
  175. package/dist/esm/mediaQueries/mediaQueries.js +0 -48
  176. package/dist/esm/mediaQueries/moduleRegistry.d.ts +0 -27
  177. package/dist/esm/mediaQueries/moduleRegistry.d.ts.map +0 -1
  178. package/dist/esm/mediaQueries/moduleRegistry.js +0 -1
  179. package/dist/esm/mediaQueries/modules/custom.d.ts +0 -10
  180. package/dist/esm/mediaQueries/modules/custom.d.ts.map +0 -1
  181. package/dist/esm/mediaQueries/modules/custom.js +0 -22
  182. package/dist/esm/mediaQueries/modules/dimensions.d.ts +0 -19
  183. package/dist/esm/mediaQueries/modules/dimensions.d.ts.map +0 -1
  184. package/dist/esm/mediaQueries/modules/dimensions.js +0 -57
  185. package/dist/esm/mediaQueries/modules/display.d.ts +0 -9
  186. package/dist/esm/mediaQueries/modules/display.d.ts.map +0 -1
  187. package/dist/esm/mediaQueries/modules/display.js +0 -16
  188. package/dist/esm/mediaQueries/modules/environment.d.ts +0 -9
  189. package/dist/esm/mediaQueries/modules/environment.d.ts.map +0 -1
  190. package/dist/esm/mediaQueries/modules/environment.js +0 -16
  191. package/dist/esm/mediaQueries/modules/index.d.ts +0 -8
  192. package/dist/esm/mediaQueries/modules/index.d.ts.map +0 -1
  193. package/dist/esm/mediaQueries/modules/index.js +0 -7
  194. package/dist/esm/mediaQueries/modules/interaction.d.ts +0 -11
  195. package/dist/esm/mediaQueries/modules/interaction.d.ts.map +0 -1
  196. package/dist/esm/mediaQueries/modules/interaction.js +0 -22
  197. package/dist/esm/mediaQueries/modules/preferences.d.ts +0 -11
  198. package/dist/esm/mediaQueries/modules/preferences.d.ts.map +0 -1
  199. package/dist/esm/mediaQueries/modules/preferences.js +0 -22
  200. package/dist/esm/mediaQueries/modules/resolution.d.ts +0 -12
  201. package/dist/esm/mediaQueries/modules/resolution.d.ts.map +0 -1
  202. package/dist/esm/mediaQueries/modules/resolution.js +0 -27
  203. package/dist/esm/mediaQueries/types.d.ts +0 -117
  204. package/dist/esm/mediaQueries/types.d.ts.map +0 -1
  205. package/dist/esm/mediaQueries/types.js +0 -1
  206. package/dist/esm/mediaQueries/validation.d.ts +0 -34
  207. package/dist/esm/mediaQueries/validation.d.ts.map +0 -1
  208. package/dist/esm/mediaQueries/validation.js +0 -127
  209. package/dist/esm/types.d.ts +0 -35
  210. package/dist/esm/types.d.ts.map +0 -1
  211. package/dist/esm/types.js +0 -1
  212. package/dist/esm/validation.d.ts +0 -10
  213. package/dist/esm/validation.d.ts.map +0 -1
  214. package/dist/esm/validation.js +0 -15
  215. package/dist/examples/containerQueries.example.js +0 -54
  216. package/dist/examples/examples/containerQueries.example.js +0 -54
  217. package/dist/examples/examples/factory-wrapper.example.js +0 -33
  218. package/dist/examples/examples/lineHeight-normalizer.example.js +0 -81
  219. package/dist/examples/examples/mediaQueries-multipleInstances.example.js +0 -127
  220. package/dist/examples/examples/mixedQueries.example.js +0 -55
  221. package/dist/examples/examples/validation-and-runtime-checks.example.js +0 -85
  222. package/dist/examples/examples/validation-unit-tests.example.js +0 -35
  223. package/dist/examples/factory-wrapper.example.js +0 -33
  224. package/dist/examples/lineHeight-normalizer.example.js +0 -81
  225. package/dist/examples/mediaQueries-multipleInstances.example.js +0 -127
  226. package/dist/examples/mixedQueries.example.js +0 -60
  227. package/dist/examples/src/comparisons/index.js +0 -25
  228. package/dist/examples/src/containerQueries/containerQueries.js +0 -96
  229. package/dist/examples/src/containerQueries/factory.js +0 -123
  230. package/dist/examples/src/containerQueries/helpers.js +0 -94
  231. package/dist/examples/src/containerQueries/index.js +0 -16
  232. package/dist/examples/src/containerQueries/linting/aspectRatio.js +0 -20
  233. package/dist/examples/src/containerQueries/linting/block.js +0 -20
  234. package/dist/examples/src/containerQueries/linting/core.js +0 -19
  235. package/dist/examples/src/containerQueries/linting/custom.js +0 -11
  236. package/dist/examples/src/containerQueries/linting/inline.js +0 -20
  237. package/dist/examples/src/containerQueries/linting/style.js +0 -28
  238. package/dist/examples/src/containerQueries/linting.js +0 -24
  239. package/dist/examples/src/containerQueries/moduleRegistry.js +0 -5
  240. package/dist/examples/src/containerQueries/modules/aspectRatio.js +0 -33
  241. package/dist/examples/src/containerQueries/modules/block.js +0 -44
  242. package/dist/examples/src/containerQueries/modules/custom.js +0 -31
  243. package/dist/examples/src/containerQueries/modules/index.js +0 -21
  244. package/dist/examples/src/containerQueries/modules/inline.js +0 -44
  245. package/dist/examples/src/containerQueries/modules/style.js +0 -36
  246. package/dist/examples/src/containerQueries/types.js +0 -2
  247. package/dist/examples/src/containerQueries/validation.js +0 -177
  248. package/dist/examples/src/core.js +0 -16
  249. package/dist/examples/src/factory.js +0 -21
  250. package/dist/examples/src/index.js +0 -30
  251. package/dist/examples/src/internal/buildMeasurementCreationError.js +0 -16
  252. package/dist/examples/src/internal/createCoreApi.js +0 -336
  253. package/dist/examples/src/internal/createMediaQueriesApi.js +0 -74
  254. package/dist/examples/src/internal/createUnitsApi.js +0 -18
  255. package/dist/examples/src/internal/errors.js +0 -130
  256. package/dist/examples/src/libraryHelpers/vanilla-extract.js +0 -11
  257. package/dist/examples/src/mediaQueries/factory.js +0 -163
  258. package/dist/examples/src/mediaQueries/helpers.js +0 -88
  259. package/dist/examples/src/mediaQueries/index.js +0 -23
  260. package/dist/examples/src/mediaQueries/linting/core.js +0 -19
  261. package/dist/examples/src/mediaQueries/linting/resolution.js +0 -11
  262. package/dist/examples/src/mediaQueries/linting.js +0 -24
  263. package/dist/examples/src/mediaQueries/mediaQueries.js +0 -53
  264. package/dist/examples/src/mediaQueries/moduleRegistry.js +0 -5
  265. package/dist/examples/src/mediaQueries/modules/custom.js +0 -26
  266. package/dist/examples/src/mediaQueries/modules/dimensions.js +0 -61
  267. package/dist/examples/src/mediaQueries/modules/display.js +0 -20
  268. package/dist/examples/src/mediaQueries/modules/environment.js +0 -20
  269. package/dist/examples/src/mediaQueries/modules/index.js +0 -23
  270. package/dist/examples/src/mediaQueries/modules/interaction.js +0 -26
  271. package/dist/examples/src/mediaQueries/modules/preferences.js +0 -26
  272. package/dist/examples/src/mediaQueries/modules/resolution.js +0 -31
  273. package/dist/examples/src/mediaQueries/types.js +0 -2
  274. package/dist/examples/src/mediaQueries/validation.js +0 -128
  275. package/dist/examples/src/ratio.js +0 -141
  276. package/dist/examples/src/types.js +0 -2
  277. package/dist/examples/src/unitDefinitions.js +0 -67
  278. package/dist/examples/src/units/absolute.js +0 -11
  279. package/dist/examples/src/units/angle.js +0 -8
  280. package/dist/examples/src/units/container.js +0 -10
  281. package/dist/examples/src/units/font-relative.js +0 -16
  282. package/dist/examples/src/units/frequency.js +0 -6
  283. package/dist/examples/src/units/grid.js +0 -5
  284. package/dist/examples/src/units/percent.js +0 -7
  285. package/dist/examples/src/units/resolution.js +0 -7
  286. package/dist/examples/src/units/time.js +0 -6
  287. package/dist/examples/src/units/viewport-dynamic.js +0 -10
  288. package/dist/examples/src/units/viewport-large.js +0 -10
  289. package/dist/examples/src/units/viewport-small.js +0 -10
  290. package/dist/examples/src/units/viewport.js +0 -10
  291. package/dist/examples/src/validation.js +0 -20
  292. package/dist/examples/validation-and-runtime-checks.example.js +0 -85
  293. package/dist/examples/validation-unit-tests.example.js +0 -35
package/README.md CHANGED
@@ -67,34 +67,31 @@ If you prefer, you can also import unit helpers from dedicated subpaths. For exa
67
67
  - Status: early `0.x` release. Backwards compatibility is not guaranteed until `1.0.0`.
68
68
  - Questions or bugs: open an issue on GitHub (see the repository link at the top of this page or in `package.json`).
69
69
  - Tooling: tested primarily with TypeScript 5.6+ on Node 18+.
70
+ - Support: this is a solo, early-stage project. If it saves you time, you can [buy me a coffee](https://buymeacoffee.com/slafleche) to support continued work.
70
71
 
71
72
  ---
72
73
 
73
74
  ## Media queries
74
75
 
75
- ```ts
76
- import { m } from "css-calipers";
77
- import { mediaQueryFactory } from "css-calipers/mediaQueries";
78
-
79
- const media = mediaQueryFactory({
80
- queries: {
81
- mobile: { maxWidth: m(639) },
82
- desktop: { minWidth: m(640) },
83
- },
84
- config: {
85
- label: "layout",
86
- },
87
- });
76
+ Media queries have moved out of CSS-Calipers. From `0.15` on, CSS-Calipers is
77
+ purely the measurement layer.
88
78
 
89
- const styles = {
90
- ...media({
91
- mobile: { gridTemplateColumns: "1fr" },
92
- desktop: { gridTemplateColumns: "repeat(4, 1fr)" },
93
- }),
94
- };
95
- ```
79
+ CSS-Calipers itself is part of
80
+ [CSS-Bookends](https://github.com/slafleche/css-bookends): it is the measurement
81
+ lexicon at the centre of the umbrella. The first CSS-Bookends beta gives you
82
+ exactly what `css-calipers@0.14` does today, the same measurement layer and the
83
+ same media query helper, just split into two installable pieces (`css-calipers`
84
+ plus `@css-bookends/media-queries`). Nothing is lost.
85
+
86
+ If you use the media query helper:
87
+
88
+ - **Switch to CSS-Bookends** and add `@css-bookends/media-queries` alongside
89
+ `css-calipers`. Same helper, now maintained in the umbrella.
90
+ - **Or stay on `css-calipers@0.14`**, which still bundles the media query helper
91
+ and remains the `latest` release for now.
96
92
 
97
- See README_MEDIAQUERIES.md for the full media queries guide.
93
+ CSS-Bookends is the long-term home for everything beyond measurement (spacing,
94
+ colours, borders, and more), so moving over is the recommended path.
98
95
 
99
96
  ---
100
97
 
@@ -354,8 +351,7 @@ setErrorConfig({ stackHints: "on" });
354
351
  ## Factory entrypoint (optional)
355
352
 
356
353
  If you want instance-scoped configuration and a single re-export surface, use
357
- the factory entrypoint. The instance includes core helpers, unit helpers, and
358
- mediaQueries.
354
+ the factory entrypoint. The instance includes core helpers and unit helpers.
359
355
 
360
356
  ```
361
357
  import { createCalipers } from "css-calipers/factory";
@@ -364,7 +360,7 @@ const calipers = createCalipers({
364
360
  errorConfig: { stackHints: "on" },
365
361
  });
366
362
 
367
- export const { m, mPx, mediaQueries, units } = calipers;
363
+ export const { m, mPx, units } = calipers;
368
364
  ```
369
365
 
370
366
  See [examples/factory-wrapper.example.ts](examples/factory-wrapper.example.ts)
@@ -478,7 +474,7 @@ parts inside a broader styling solution.
478
474
  Deeper guides live alongside this README:
479
475
 
480
476
  - Measurements core: [README_MEASUREMENT.md](README_MEASUREMENT.md)
481
- - Media queries: [README_MEDIAQUERIES.md](README_MEDIAQUERIES.md)
477
+ - Media queries: now in [`@css-bookends/media-queries`](https://github.com/slafleche/css-bookends)
482
478
 
483
479
  ### Further examples in this repo
484
480
 
@@ -4,17 +4,14 @@ exports.createCalipers = void 0;
4
4
  const errors_1 = require("./internal/errors");
5
5
  const createCoreApi_1 = require("./internal/createCoreApi");
6
6
  const createUnitsApi_1 = require("./internal/createUnitsApi");
7
- const createMediaQueriesApi_1 = require("./internal/createMediaQueriesApi");
8
7
  const createCalipers = (config = {}) => {
9
8
  var _a;
10
9
  const errorStore = (0, errors_1.createErrorConfigStore)((_a = config.errorConfig) !== null && _a !== void 0 ? _a : {});
11
10
  const core = (0, createCoreApi_1.createCoreApi)(errorStore);
12
11
  const units = (0, createUnitsApi_1.createUnitsApi)(core);
13
- const mediaQueries = (0, createMediaQueriesApi_1.createMediaQueriesApi)(core);
14
12
  return {
15
13
  ...core,
16
14
  ...units,
17
- mediaQueries,
18
15
  units,
19
16
  };
20
17
  };
@@ -15,6 +15,32 @@ exports.createCoreApi = void 0;
15
15
  const unitDefinitions_1 = require("../unitDefinitions");
16
16
  const buildMeasurementCreationError_1 = require("./buildMeasurementCreationError");
17
17
  const errors_1 = require("./errors");
18
+ // JS stringifies numbers in exponential form once the magnitude is >= 1e21 or
19
+ // < 1e-6 (e.g. "1e+21", "1e-7"). CSS output must never contain that, so we
20
+ // expand the exponent into a plain decimal by shifting the decimal point on the
21
+ // digit string. This is string manipulation on the same digits, so it does not
22
+ // re-introduce floating-point error.
23
+ const toPlainDecimal = (value) => {
24
+ const text = `${value}`;
25
+ if (!text.includes('e') && !text.includes('E')) {
26
+ return text;
27
+ }
28
+ const [mantissa, exponentText] = text.toLowerCase().split('e');
29
+ const exponent = Number(exponentText);
30
+ const negative = mantissa.startsWith('-');
31
+ const unsigned = negative ? mantissa.slice(1) : mantissa;
32
+ const [intDigits, fracDigits = ''] = unsigned.split('.');
33
+ const digits = intDigits + fracDigits;
34
+ const pointFromLeft = intDigits.length + exponent;
35
+ const sign = negative ? '-' : '';
36
+ if (pointFromLeft <= 0) {
37
+ return `${sign}0.${'0'.repeat(-pointFromLeft)}${digits}`;
38
+ }
39
+ if (pointFromLeft >= digits.length) {
40
+ return `${sign}${digits}${'0'.repeat(pointFromLeft - digits.length)}`;
41
+ }
42
+ return `${sign}${digits.slice(0, pointFromLeft)}.${digits.slice(pointFromLeft)}`;
43
+ };
18
44
  const createCoreApi = (errorStore) => {
19
45
  var _Measurement_instances, _a, _Measurement_value, _Measurement_unit, _Measurement_clone;
20
46
  const { throwHelperError, throwMeasurementMethodError } = (0, errors_1.createErrorHelpers)(errorStore);
@@ -50,18 +76,11 @@ const createCoreApi = (errorStore) => {
50
76
  details: { code: 'CALIPERS_E_NONFINITE' },
51
77
  });
52
78
  }
53
- const normalizedUnit = unit.toLowerCase();
54
79
  __classPrivateFieldSet(this, _Measurement_value, value, "f");
55
- __classPrivateFieldSet(this, _Measurement_unit, normalizedUnit, "f");
56
- Object.defineProperty(this, '__unitBrand', {
57
- value: normalizedUnit,
58
- enumerable: false,
59
- configurable: false,
60
- writable: false,
61
- });
80
+ __classPrivateFieldSet(this, _Measurement_unit, unit.toLowerCase(), "f");
62
81
  }
63
82
  css() {
64
- return `${__classPrivateFieldGet(this, _Measurement_value, "f")}${__classPrivateFieldGet(this, _Measurement_unit, "f")}`;
83
+ return `${toPlainDecimal(__classPrivateFieldGet(this, _Measurement_value, "f"))}${__classPrivateFieldGet(this, _Measurement_unit, "f")}`;
65
84
  }
66
85
  toString() {
67
86
  return this.css();
@@ -223,6 +242,8 @@ const createCoreApi = (errorStore) => {
223
242
  _a = Measurement, _Measurement_clone = function _Measurement_clone(value) {
224
243
  return new _a(value, __classPrivateFieldGet(this, _Measurement_unit, "f"));
225
244
  };
245
+ // Single controlled point where the unit brand is asserted onto a freshly
246
+ // created measurement (the brand is a compile-time-only phantom).
226
247
  const createMeasurement = (value, unit) => new Measurement(value, unit);
227
248
  const isMeasurement = (x) => x instanceof Measurement;
228
249
  function m(value, unitOrOptions = 'px', context) {
@@ -3,8 +3,9 @@ import { type ErrorConfig, type ErrorCode } from './internal/errors';
3
3
  import { r, isRatio, normalizeRatio, parseRatio, ratioToFloat, toFloat, reduceRatio, simplifyRatio, type IRatio, type RatioParts } from './ratio';
4
4
  type UnitSymbol = UnitDefinitionRecord[keyof UnitDefinitionRecord]['unit'];
5
5
  export type MeasurementString<Unit extends string = UnitSymbol> = `${number}${Unit}`;
6
+ declare const unitBrand: unique symbol;
6
7
  type UnitBrand<Unit extends string> = {
7
- readonly __unitBrand: Unit;
8
+ readonly [unitBrand]: Unit;
8
9
  };
9
10
  export interface IMeasurement<Unit extends string = string> {
10
11
  css: () => string;
@@ -16,10 +17,12 @@ export interface IMeasurement<Unit extends string = string> {
16
17
  isUnit: (unit: string) => boolean;
17
18
  assertUnit: (unit: string, context?: string) => void;
18
19
  assert: (predicate: (measurement: IMeasurement<Unit>) => boolean, message: string) => void;
19
- equals: (other: IMeasurement<string>) => boolean;
20
- compare: (other: IMeasurement<string>) => number;
21
- add: (delta: number | IMeasurement<string>) => IMeasurement<Unit>;
22
- subtract: (delta: number | IMeasurement<string>) => IMeasurement<Unit>;
20
+ equals(other: IMeasurement<Unit>, strict?: boolean): boolean;
21
+ equals(other: IMeasurement<string>, strict: false): boolean;
22
+ compare(other: IMeasurement<Unit>, strict?: boolean): number;
23
+ compare(other: IMeasurement<string>, strict: false): number;
24
+ add(delta: number | IMeasurement<Unit>): IMeasurement<Unit>;
25
+ subtract(delta: number | IMeasurement<Unit>): IMeasurement<Unit>;
23
26
  multiply: (factor: number) => IMeasurement<Unit>;
24
27
  divide: (divisor: number) => IMeasurement<Unit>;
25
28
  double: () => IMeasurement<Unit>;
@@ -29,30 +32,31 @@ export interface IMeasurement<Unit extends string = string> {
29
32
  round: (precision?: number) => IMeasurement<Unit>;
30
33
  floor: () => IMeasurement<Unit>;
31
34
  ceil: () => IMeasurement<Unit>;
32
- clamp: (min: IMeasurement<string>, max: IMeasurement<string>) => IMeasurement<Unit>;
35
+ clamp(min: IMeasurement<Unit>, max: IMeasurement<Unit>): IMeasurement<Unit>;
33
36
  }
34
- export type BrandedMeasurement<Unit extends string> = IMeasurement<Unit> & UnitBrand<Unit>;
35
- export type UnitHelper<Unit extends string = string> = ((value: number, context?: string) => BrandedMeasurement<Unit>) & {
37
+ export type InscribedMeasurement<Unit extends string> = IMeasurement<Unit> & UnitBrand<Unit>;
38
+ /**
39
+ * @deprecated Renamed to `InscribedMeasurement`. This alias is kept for one
40
+ * release for backwards compatibility and will be removed in a future version.
41
+ */
42
+ export type BrandedMeasurement<Unit extends string> = InscribedMeasurement<Unit>;
43
+ export type UnitHelper<Unit extends string = string> = ((value: number, context?: string) => InscribedMeasurement<Unit>) & {
36
44
  unit: Unit;
37
45
  };
38
46
  export type MeasurementOf<T extends UnitHelper> = ReturnType<T>;
39
47
  export type UnitGuard<T extends UnitHelper> = (value: unknown) => value is MeasurementOf<T>;
40
48
  export type UnitAssertion<T extends UnitHelper> = (value: unknown, context?: string) => asserts value is MeasurementOf<T>;
41
49
  export declare const m: {
42
- (value: number): BrandedMeasurement<"px">;
50
+ (value: number): InscribedMeasurement<"px">;
43
51
  (value: number, options: {
44
52
  context?: string;
45
- }): BrandedMeasurement<"px">;
46
- <Unit extends string>(value: number, unit: Unit, context?: string): IMeasurement<Lowercase<Unit>> & {
47
- readonly __unitBrand: Lowercase<Unit>;
48
- };
53
+ }): InscribedMeasurement<"px">;
54
+ <Unit extends string>(value: number, unit: Unit, context?: string): InscribedMeasurement<Lowercase<Unit>>;
49
55
  <Unit extends string>(value: number, options: {
50
56
  unit?: Unit | undefined;
51
57
  context?: string;
52
- }): IMeasurement<Lowercase<Unit>> & {
53
- readonly __unitBrand: Lowercase<Unit>;
54
- };
55
- }, isMeasurement: (x: unknown) => x is IMeasurement<string>, assertMatchingUnits: <Unit extends string>(left: IMeasurement<Unit>, right: IMeasurement<Unit>, context: string) => void, measurementMin: <Unit extends string>(a: IMeasurement<Unit>, b: IMeasurement<Unit>) => IMeasurement<Unit>, measurementMax: <Unit extends string>(a: IMeasurement<Unit>, b: IMeasurement<Unit>) => IMeasurement<Unit>, measurementUnitMetadata: {
58
+ }): InscribedMeasurement<Lowercase<Unit>>;
59
+ }, isMeasurement: (x: unknown) => x is IMeasurement<string>, assertMatchingUnits: <Unit extends string>(left: IMeasurement<Unit>, right: IMeasurement<Unit>, context: string) => void, measurementMin: <Unit extends string>(a: IMeasurement<Unit>, b: IMeasurement<NoInfer<Unit>>) => IMeasurement<Unit>, measurementMax: <Unit extends string>(a: IMeasurement<Unit>, b: IMeasurement<NoInfer<Unit>>) => IMeasurement<Unit>, measurementUnitMetadata: {
56
60
  readonly mPercent: {
57
61
  readonly unit: "%";
58
62
  readonly category: "percent";
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,E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GACd,cAAc,sGACd,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GACvB,cAAc,yDACd,4BAA4B,sFAwB2jQ,0BAA0B,WAvBjnQ,aAAa,qDACb,cAAc,yDACd,YAAY;;GACZ,UAAU,0GACV,eAAe,mEACf,cAAc,+BACd,cAAc,6BACL,CAAC;AAEZ,MAAM,MAAM,yBAAyB,GAAG,cAAc,CAAC;AACvD,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC;AACnD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,CAAC;AAC5C,OAAO,EACL,CAAC,EACD,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,OAAO,EACP,WAAW,EACX,aAAa,GACd,CAAC;AACF,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC"}
@@ -1,12 +1,10 @@
1
1
  import { type ErrorConfig } from './internal/errors';
2
2
  import { type CoreApi } from './internal/createCoreApi';
3
3
  import { type UnitsApi } from './internal/createUnitsApi';
4
- import { type MediaQueriesApi } from './internal/createMediaQueriesApi';
5
4
  export type CalipersFactoryConfig = {
6
5
  errorConfig?: ErrorConfig;
7
6
  };
8
7
  export type CalipersInstance = CoreApi & UnitsApi & {
9
- mediaQueries: MediaQueriesApi;
10
8
  units: UnitsApi;
11
9
  };
12
10
  export declare const createCalipers: (config?: CalipersFactoryConfig) => CalipersInstance;
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,OAAO,GACpC,QAAQ,GAAG;IACT,YAAY,EAAE,eAAe,CAAC;IAC9B,KAAK,EAAE,QAAQ,CAAC;CACjB,CAAC;AAEJ,eAAO,MAAM,cAAc,GACzB,SAAQ,qBAA0B,KACjC,gBAcF,CAAC"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1E,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,OAAO,GACpC,QAAQ,GAAG;IACT,KAAK,EAAE,QAAQ,CAAC;CACjB,CAAC;AAEJ,eAAO,MAAM,cAAc,GACzB,SAAQ,qBAA0B,KACjC,gBAYF,CAAC"}
@@ -1,17 +1,14 @@
1
1
  import { createErrorConfigStore } from './internal/errors';
2
2
  import { createCoreApi } from './internal/createCoreApi';
3
3
  import { createUnitsApi } from './internal/createUnitsApi';
4
- import { createMediaQueriesApi, } from './internal/createMediaQueriesApi';
5
4
  export const createCalipers = (config = {}) => {
6
5
  var _a;
7
6
  const errorStore = createErrorConfigStore((_a = config.errorConfig) !== null && _a !== void 0 ? _a : {});
8
7
  const core = createCoreApi(errorStore);
9
8
  const units = createUnitsApi(core);
10
- const mediaQueries = createMediaQueriesApi(core);
11
9
  return {
12
10
  ...core,
13
11
  ...units,
14
- mediaQueries,
15
12
  units,
16
13
  };
17
14
  };
@@ -1,27 +1,23 @@
1
1
  import { type UnitDefinitionRecord, type UnitHelperName } from '../unitDefinitions';
2
2
  import { type ErrorConfigStore } from './errors';
3
- import type { BrandedMeasurement, IMeasurement, UnitAssertion, UnitGuard, UnitHelper } from '../core';
3
+ import type { InscribedMeasurement, IMeasurement, UnitAssertion, UnitGuard, UnitHelper } from '../core';
4
4
  type MeasurementCreateOptions<Unit extends string> = {
5
5
  unit?: Unit;
6
6
  context?: string;
7
7
  };
8
8
  export declare const createCoreApi: (errorStore: ErrorConfigStore) => {
9
9
  readonly m: {
10
- (value: number): BrandedMeasurement<"px">;
10
+ (value: number): InscribedMeasurement<"px">;
11
11
  (value: number, options: {
12
12
  context?: string;
13
- }): BrandedMeasurement<"px">;
14
- <Unit extends string>(value: number, unit: Unit, context?: string): IMeasurement<Lowercase<Unit>> & {
15
- readonly __unitBrand: Lowercase<Unit>;
16
- };
17
- <Unit extends string>(value: number, options: MeasurementCreateOptions<Unit>): IMeasurement<Lowercase<Unit>> & {
18
- readonly __unitBrand: Lowercase<Unit>;
19
- };
13
+ }): InscribedMeasurement<"px">;
14
+ <Unit extends string>(value: number, unit: Unit, context?: string): InscribedMeasurement<Lowercase<Unit>>;
15
+ <Unit extends string>(value: number, options: MeasurementCreateOptions<Unit>): InscribedMeasurement<Lowercase<Unit>>;
20
16
  };
21
17
  readonly isMeasurement: (x: unknown) => x is IMeasurement<string>;
22
18
  readonly assertMatchingUnits: <Unit extends string>(left: IMeasurement<Unit>, right: IMeasurement<Unit>, context: string) => void;
23
- readonly measurementMin: <Unit extends string>(a: IMeasurement<Unit>, b: IMeasurement<Unit>) => IMeasurement<Unit>;
24
- readonly measurementMax: <Unit extends string>(a: IMeasurement<Unit>, b: IMeasurement<Unit>) => IMeasurement<Unit>;
19
+ readonly measurementMin: <Unit extends string>(a: IMeasurement<Unit>, b: IMeasurement<NoInfer<Unit>>) => IMeasurement<Unit>;
20
+ readonly measurementMax: <Unit extends string>(a: IMeasurement<Unit>, b: IMeasurement<NoInfer<Unit>>) => IMeasurement<Unit>;
25
21
  readonly measurementUnitMetadata: {
26
22
  readonly mPercent: {
27
23
  readonly unit: "%";
@@ -1 +1 @@
1
- {"version":3,"file":"createCoreApi.d.ts","sourceRoot":"","sources":["../../../src/internal/createCoreApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,EACX,MAAM,SAAS,CAAC;AAGjB,KAAK,wBAAwB,CAAC,IAAI,SAAS,MAAM,IAAI;IACnD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,YAAY,gBAAgB;;gBAqRtC,MAAM,GAAG,kBAAkB,CAAC,IAAI,CAAC;gBAE1C,MAAM,WACJ;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,GAC5B,kBAAkB,CAAC,IAAI,CAAC;SAChB,IAAI,SAAS,MAAM,SACrB,MAAM,QACP,IAAI,YACA,MAAM,GACf,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG;YACjC,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;SACvC;SACU,IAAI,SAAS,MAAM,SACrB,MAAM,WACJ,wBAAwB,CAAC,IAAI,CAAC,GACtC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG;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efinitions';
13
13
  import { buildMeasurementCreationError } from './buildMeasurementCreationError';
14
14
  import { createErrorHelpers, } from './errors';
15
+ // JS stringifies numbers in exponential form once the magnitude is >= 1e21 or
16
+ // < 1e-6 (e.g. "1e+21", "1e-7"). CSS output must never contain that, so we
17
+ // expand the exponent into a plain decimal by shifting the decimal point on the
18
+ // digit string. This is string manipulation on the same digits, so it does not
19
+ // re-introduce floating-point error.
20
+ const toPlainDecimal = (value) => {
21
+ const text = `${value}`;
22
+ if (!text.includes('e') && !text.includes('E')) {
23
+ return text;
24
+ }
25
+ const [mantissa, exponentText] = text.toLowerCase().split('e');
26
+ const exponent = Number(exponentText);
27
+ const negative = mantissa.startsWith('-');
28
+ const unsigned = negative ? mantissa.slice(1) : mantissa;
29
+ const [intDigits, fracDigits = ''] = unsigned.split('.');
30
+ const digits = intDigits + fracDigits;
31
+ const pointFromLeft = intDigits.length + exponent;
32
+ const sign = negative ? '-' : '';
33
+ if (pointFromLeft <= 0) {
34
+ return `${sign}0.${'0'.repeat(-pointFromLeft)}${digits}`;
35
+ }
36
+ if (pointFromLeft >= digits.length) {
37
+ return `${sign}${digits}${'0'.repeat(pointFromLeft - digits.length)}`;
38
+ }
39
+ return `${sign}${digits.slice(0, pointFromLeft)}.${digits.slice(pointFromLeft)}`;
40
+ };
15
41
  export const createCoreApi = (errorStore) => {
16
42
  var _Measurement_instances, _a, _Measurement_value, _Measurement_unit, _Measurement_clone;
17
43
  const { throwHelperError, throwMeasurementMethodError } = createErrorHelpers(errorStore);
@@ -47,18 +73,11 @@ export const createCoreApi = (errorStore) => {
47
73
  details: { code: 'CALIPERS_E_NONFINITE' },
48
74
  });
49
75
  }
50
- const normalizedUnit = unit.toLowerCase();
51
76
  __classPrivateFieldSet(this, _Measurement_value, value, "f");
52
- __classPrivateFieldSet(this, _Measurement_unit, normalizedUnit, "f");
53
- Object.defineProperty(this, '__unitBrand', {
54
- value: normalizedUnit,
55
- enumerable: false,
56
- configurable: false,
57
- writable: false,
58
- });
77
+ __classPrivateFieldSet(this, _Measurement_unit, unit.toLowerCase(), "f");
59
78
  }
60
79
  css() {
61
- return `${__classPrivateFieldGet(this, _Measurement_value, "f")}${__classPrivateFieldGet(this, _Measurement_unit, "f")}`;
80
+ return `${toPlainDecimal(__classPrivateFieldGet(this, _Measurement_value, "f"))}${__classPrivateFieldGet(this, _Measurement_unit, "f")}`;
62
81
  }
63
82
  toString() {
64
83
  return this.css();
@@ -220,6 +239,8 @@ export const createCoreApi = (errorStore) => {
220
239
  _a = Measurement, _Measurement_clone = function _Measurement_clone(value) {
221
240
  return new _a(value, __classPrivateFieldGet(this, _Measurement_unit, "f"));
222
241
  };
242
+ // Single controlled point where the unit brand is asserted onto a freshly
243
+ // created measurement (the brand is a compile-time-only phantom).
223
244
  const createMeasurement = (value, unit) => new Measurement(value, unit);
224
245
  const isMeasurement = (x) => x instanceof Measurement;
225
246
  function m(value, unitOrOptions = 'px', context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-calipers",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "Compile-time unit safety for numeric, unit-bearing CSS values via typed measurements.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,8 +28,7 @@
28
28
  "files": [
29
29
  "dist",
30
30
  "README.md",
31
- "LICENSE.txt",
32
- "RELEASING.md"
31
+ "LICENSE.txt"
33
32
  ],
34
33
  "sideEffects": false,
35
34
  "type": "commonjs",
@@ -42,11 +41,6 @@
42
41
  "import": "./dist/esm/index.js",
43
42
  "require": "./dist/cjs/index.js"
44
43
  },
45
- "./mediaQueries": {
46
- "types": "./dist/esm/mediaQueries/index.d.ts",
47
- "import": "./dist/esm/mediaQueries/index.js",
48
- "require": "./dist/cjs/mediaQueries/index.js"
49
- },
50
44
  "./factory": {
51
45
  "types": "./dist/esm/factory.d.ts",
52
46
  "import": "./dist/esm/factory.js",
@@ -70,14 +64,14 @@
70
64
  "devDependencies": {
71
65
  "@eslint/js": "^9.39.2",
72
66
  "@types/node": "^24.10.1",
73
- "@typescript-eslint/eslint-plugin": "^8.50.1",
74
- "@typescript-eslint/parser": "^8.50.1",
75
- "@vanilla-extract/css": "^1.18.0",
76
- "@vitest/coverage-v8": "^4.0.14",
67
+ "@typescript-eslint/eslint-plugin": "^8.60.0",
68
+ "@typescript-eslint/parser": "^8.60.0",
69
+ "@vanilla-extract/css": "^1.20.1",
70
+ "@vitest/coverage-v8": "^4.1.7",
77
71
  "eslint": "^9.39.2",
78
- "tsd": "^0.31.0",
72
+ "tsd": "^0.33.0",
79
73
  "typescript": "^5.6.3",
80
- "vitest": "^4.0.14"
74
+ "vitest": "^4.1.7"
81
75
  },
82
76
  "scripts": {
83
77
  "build": "npm run build:cjs && npm run build:esm && npm run build:examples",
@@ -86,14 +80,7 @@
86
80
  "build:examples": "tsc -p tsconfig.examples.json --noEmit",
87
81
  "build:test": "npm run build && npm run test",
88
82
  "build:delete": "node -e \"const { existsSync, rmSync } = require('fs'); const paths = ['dist/cjs', 'dist/esm']; for (const p of paths) { console.log('Scanning', p + '...'); if (existsSync(p)) { console.log('Found', p + ', deleting...'); rmSync(p, { recursive: true, force: true }); console.log('Deleted', p); } else { console.log(p + ' not found, skipping.'); } }\"",
89
- "prepublishOnly": "node -e \"if (!process.env.CSS_CALIPERS_RELEASE) { console.error('Direct npm publish is disabled; use \\\"npm run release\\\" instead.'); process.exit(1); }\" && npm run test:internal",
90
- "release": "node scripts/release.mjs",
91
- "release:dry": "node scripts/release.mjs --dry-run",
92
- "test": "npm run build && npm run test:core && npm run test:ratio && npm run test:mediaQueries && npm run test:factory && npm run test:dist && npm run test:types && npm run test:tsc && npm run lint && npm run test:internal",
93
- "test:mediaQueries": "vitest run tests/runtime/mediaQueries/mediaQueries.src.test.ts",
94
- "test:mediaQueries:cjs": "vitest run tests/runtime/mediaQueries/mediaQueries.cjs.test.ts tests/runtime/api-surface/mediaQueries.api-surface.cjs.test.ts",
95
- "test:mediaQueries:esm": "vitest run tests/runtime/mediaQueries/mediaQueries.esm.test.ts tests/runtime/api-surface/mediaQueries.api-surface.esm.test.ts",
96
- "test:mediaQueries:dist": "npm run test:mediaQueries:cjs && npm run test:mediaQueries:esm",
83
+ "test": "npm run build && npm run test:core && npm run test:ratio && npm run test:factory && npm run test:dist && npm run test:types && npm run test:tsc && npm run lint && npm run test:internal",
97
84
  "test:core": "vitest run tests/runtime/core/core.src.test.ts",
98
85
  "test:ratio": "vitest run tests/runtime/ratio/ratio.src.test.ts",
99
86
  "test:core:cjs": "vitest run tests/runtime/core/core.cjs.test.ts tests/runtime/api-surface/api-surface.cjs.test.ts",
@@ -103,11 +90,11 @@
103
90
  "test:lint": "npm run lint",
104
91
  "test:types": "echo \"\n 🧪 Starting tsd type checks...\n\" && tsd --files tests/types/**/*.test-d.ts && echo \"✅ tsd type checks passed!\n\"",
105
92
  "test:tsc": "tsc -p tsconfig.json --noEmit",
106
- "test:dist": "npm run test:core:dist && npm run test:mediaQueries:dist && npm run test:factory:dist",
93
+ "test:dist": "npm run test:core:dist && npm run test:factory:dist",
107
94
  "test:factory": "vitest run tests/runtime/factory/factory.src.test.ts",
108
95
  "test:factory:cjs": "vitest run tests/runtime/factory/factory.cjs.test.ts tests/runtime/api-surface/factory.api-surface.cjs.test.ts",
109
96
  "test:factory:esm": "vitest run tests/runtime/factory/factory.esm.test.ts tests/runtime/api-surface/factory.api-surface.esm.test.ts",
110
97
  "test:factory:dist": "npm run test:factory:cjs && npm run test:factory:esm",
111
98
  "test:internal": "tsc -p tsconfig.internal.json --noEmit"
112
99
  }
113
- }
100
+ }
package/RELEASING.md DELETED
@@ -1,62 +0,0 @@
1
- # Releasing CSS-Calipers
2
-
3
- This document describes how to publish a new version of `css-calipers` to npm
4
- using the local release script.
5
-
6
- ## Prerequisites
7
-
8
- - You have push access to the `main` branch of the repository.
9
- - You are logged in to npm with an account that can publish the
10
- `css-calipers` package (`npm whoami` should work).
11
- - If your npm account uses 2FA, be ready to enter your OTP during
12
- `npm publish`.
13
- - The supported runtime target for published builds is Node 18 or newer.
14
-
15
- ## Release flow (local, scripted)
16
-
17
- Releases should be performed via the `release` script rather than calling
18
- `npm publish` directly.
19
-
20
- 1. Ensure your local `main` branch is up to date.
21
- 2. From the project root, run `npm run release`.
22
-
23
- 3. The script will:
24
- - Verify that the current branch is `main` (abort otherwise).
25
- - Warn if there are uncommitted changes and ask whether to continue.
26
- - Run the core tests (`npm run test:core`).
27
- - Run the build (`npm run build`) to produce `dist/cjs` and `dist/esm`.
28
- - Check that the expected build outputs exist.
29
- - Run the dist tests (`npm run test:dist`) against both CJS and ESM outputs.
30
- - Run the type tests (`npm run test:types`).
31
- - Prompt you to choose the version bump (`patch`, `minor`, or `major`).
32
- - Run `npm version <type>` to bump the version and create a tag.
33
- - Show the new version and ask for final confirmation before publishing.
34
- - On confirmation, run `npm publish` (with a special environment variable
35
- set), which also triggers the `prepublishOnly` hook and publishes under
36
- the default `latest` dist-tag.
37
-
38
- If any step fails (tests, build, or publish), the script will exit with a
39
- non-zero status and print an error message.
40
-
41
- ## prepublishOnly safety net
42
-
43
- The `prepublishOnly` npm script is configured to refuse direct `npm publish`
44
- unless the `CSS_CALIPERS_RELEASE` environment variable is set. It does not
45
- re-run tests or builds; those are handled by the release script.
46
-
47
- The `prepublishOnly` hook runs automatically on every `npm publish` and will
48
- block publishing if the environment guard fails.
49
-
50
- ## Dist-tag strategy
51
-
52
- - All releases are currently published with npm’s default `latest` dist-tag.
53
- - There is no separate `next`/`beta` channel yet; if that changes, both this
54
- document and the release script should be updated to reflect the new
55
- tagging behavior.
56
-
57
- ## Notes and future improvements
58
-
59
- - Direct `npm publish` is discouraged; prefer `npm run release` so all checks
60
- run consistently.
61
- - In the future, publishing can be moved to CI (for example, from tags on
62
- `main`) without changing the core expectations described here.
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compare = void 0;
4
- exports.compare = {
5
- eq: (value) => ({
6
- operator: "=",
7
- value,
8
- }),
9
- lt: (value) => ({
10
- operator: "<",
11
- value,
12
- }),
13
- lte: (value) => ({
14
- operator: "<=",
15
- value,
16
- }),
17
- gt: (value) => ({
18
- operator: ">",
19
- value,
20
- }),
21
- gte: (value) => ({
22
- operator: ">=",
23
- value,
24
- }),
25
- };