universal-physics-tensor 8.0.0 → 9.0.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 (322) hide show
  1. package/README.md +8 -6
  2. package/data/atlas/atlas.json +21 -21
  3. package/data/atlas/atlas.jsonld +1 -1
  4. package/data/atlas/diffusion.json +5 -5
  5. package/data/atlas/oscillators.json +7 -7
  6. package/data/atlas/waves.json +11 -11
  7. package/data/bridge-catalog.json +490 -338
  8. package/data/bridge-catalog.schema.json +566 -40
  9. package/data/quantities.json +230 -218
  10. package/data/quantities.schema.json +52 -0
  11. package/data/units.json +1149 -0
  12. package/data/units.schema.json +124 -0
  13. package/dist/atlas/association.d.ts +1 -1
  14. package/dist/atlas/benchmark/hybrid-retrieval.d.ts.map +1 -1
  15. package/dist/atlas/benchmark/hybrid-retrieval.js +2 -5
  16. package/dist/atlas/benchmark/hybrid-retrieval.js.map +1 -1
  17. package/dist/atlas/physjs-entries.generated.d.ts +1601 -220
  18. package/dist/atlas/physjs-entries.generated.d.ts.map +1 -1
  19. package/dist/atlas/physjs-entries.generated.js +1854 -345
  20. package/dist/atlas/physjs-entries.generated.js.map +1 -1
  21. package/dist/atlas/physjs-ref.d.ts +89 -89
  22. package/dist/atlas/physjs-ref.d.ts.map +1 -1
  23. package/dist/atlas/physjs-ref.js +128 -176
  24. package/dist/atlas/physjs-ref.js.map +1 -1
  25. package/dist/atlas/proof-target.d.ts +16 -8
  26. package/dist/atlas/proof-target.d.ts.map +1 -1
  27. package/dist/atlas/proof-target.js +34 -31
  28. package/dist/atlas/proof-target.js.map +1 -1
  29. package/dist/bridges/catalog-adapter.d.ts.map +1 -1
  30. package/dist/bridges/catalog-adapter.js +5 -5
  31. package/dist/bridges/catalog-adapter.js.map +1 -1
  32. package/dist/bridges/catalog-load.d.ts +7 -0
  33. package/dist/bridges/catalog-load.d.ts.map +1 -1
  34. package/dist/bridges/catalog-load.js +69 -13
  35. package/dist/bridges/catalog-load.js.map +1 -1
  36. package/dist/bridges/catalog-types.d.ts +51 -6
  37. package/dist/bridges/catalog-types.d.ts.map +1 -1
  38. package/dist/bridges/evaluation-errors.d.ts +76 -0
  39. package/dist/bridges/evaluation-errors.d.ts.map +1 -0
  40. package/dist/bridges/evaluation-errors.js +118 -0
  41. package/dist/bridges/evaluation-errors.js.map +1 -0
  42. package/dist/bridges/evaluator-inputs.d.ts +5 -3
  43. package/dist/bridges/evaluator-inputs.d.ts.map +1 -1
  44. package/dist/bridges/evaluator-inputs.js +24 -24
  45. package/dist/bridges/evaluator-inputs.js.map +1 -1
  46. package/dist/bridges/evaluators.d.ts +32 -7
  47. package/dist/bridges/evaluators.d.ts.map +1 -1
  48. package/dist/bridges/evaluators.js +131 -29
  49. package/dist/bridges/evaluators.js.map +1 -1
  50. package/dist/bridges/expr-parse.d.ts +11 -3
  51. package/dist/bridges/expr-parse.d.ts.map +1 -1
  52. package/dist/bridges/expr-parse.js +46 -153
  53. package/dist/bridges/expr-parse.js.map +1 -1
  54. package/dist/bridges/holds.d.ts +11 -7
  55. package/dist/bridges/holds.d.ts.map +1 -1
  56. package/dist/bridges/holds.js +113 -234
  57. package/dist/bridges/holds.js.map +1 -1
  58. package/dist/bridges/input-contract.d.ts +65 -0
  59. package/dist/bridges/input-contract.d.ts.map +1 -0
  60. package/dist/bridges/input-contract.js +97 -0
  61. package/dist/bridges/input-contract.js.map +1 -0
  62. package/dist/bridges/notices.d.ts +11 -0
  63. package/dist/bridges/notices.d.ts.map +1 -0
  64. package/dist/bridges/notices.js +22 -0
  65. package/dist/bridges/notices.js.map +1 -0
  66. package/dist/canonical/canonical-equation.d.ts +31 -0
  67. package/dist/canonical/canonical-equation.d.ts.map +1 -1
  68. package/dist/canonical/entries/atomic.d.ts.map +1 -1
  69. package/dist/canonical/entries/atomic.js +11 -1
  70. package/dist/canonical/entries/atomic.js.map +1 -1
  71. package/dist/canonical/entries/condensed-matter.d.ts.map +1 -1
  72. package/dist/canonical/entries/condensed-matter.js +3 -0
  73. package/dist/canonical/entries/condensed-matter.js.map +1 -1
  74. package/dist/canonical/entries/dimensional-classics.d.ts.map +1 -1
  75. package/dist/canonical/entries/dimensional-classics.js +48 -0
  76. package/dist/canonical/entries/dimensional-classics.js.map +1 -1
  77. package/dist/canonical/entries/electromagnetism.d.ts.map +1 -1
  78. package/dist/canonical/entries/electromagnetism.js +30 -0
  79. package/dist/canonical/entries/electromagnetism.js.map +1 -1
  80. package/dist/canonical/entries/fluids-waves.d.ts.map +1 -1
  81. package/dist/canonical/entries/fluids-waves.js +34 -0
  82. package/dist/canonical/entries/fluids-waves.js.map +1 -1
  83. package/dist/canonical/entries/mechanics.d.ts.map +1 -1
  84. package/dist/canonical/entries/mechanics.js +24 -0
  85. package/dist/canonical/entries/mechanics.js.map +1 -1
  86. package/dist/canonical/entries/nonmonomial.d.ts.map +1 -1
  87. package/dist/canonical/entries/nonmonomial.js +15 -4
  88. package/dist/canonical/entries/nonmonomial.js.map +1 -1
  89. package/dist/canonical/entries/relativity.d.ts.map +1 -1
  90. package/dist/canonical/entries/relativity.js +6 -0
  91. package/dist/canonical/entries/relativity.js.map +1 -1
  92. package/dist/canonical/entries/statistical-mechanics.d.ts.map +1 -1
  93. package/dist/canonical/entries/statistical-mechanics.js +19 -0
  94. package/dist/canonical/entries/statistical-mechanics.js.map +1 -1
  95. package/dist/canonical/entries/thermo-nuclear-cosmo.d.ts.map +1 -1
  96. package/dist/canonical/entries/thermo-nuclear-cosmo.js +15 -0
  97. package/dist/canonical/entries/thermo-nuclear-cosmo.js.map +1 -1
  98. package/dist/cases/index.d.ts +9 -2
  99. package/dist/cases/index.d.ts.map +1 -1
  100. package/dist/cases/index.js +26 -7
  101. package/dist/cases/index.js.map +1 -1
  102. package/dist/cases/kepler-rv.js +6 -6
  103. package/dist/cases/kepler-rv.js.map +1 -1
  104. package/dist/cli/commands/_discovery-opts.d.ts +2 -1
  105. package/dist/cli/commands/_discovery-opts.d.ts.map +1 -1
  106. package/dist/cli/commands/_discovery-opts.js +7 -12
  107. package/dist/cli/commands/_discovery-opts.js.map +1 -1
  108. package/dist/cli/commands/atlas.d.ts.map +1 -1
  109. package/dist/cli/commands/atlas.js +6 -9
  110. package/dist/cli/commands/atlas.js.map +1 -1
  111. package/dist/cli/commands/audit.d.ts.map +1 -1
  112. package/dist/cli/commands/audit.js +1 -2
  113. package/dist/cli/commands/audit.js.map +1 -1
  114. package/dist/cli/commands/connectors.d.ts.map +1 -1
  115. package/dist/cli/commands/connectors.js +8 -9
  116. package/dist/cli/commands/connectors.js.map +1 -1
  117. package/dist/cli/commands/derive.js +9 -10
  118. package/dist/cli/commands/derive.js.map +1 -1
  119. package/dist/cli/commands/discover.d.ts.map +1 -1
  120. package/dist/cli/commands/discover.js +3 -4
  121. package/dist/cli/commands/discover.js.map +1 -1
  122. package/dist/cli/commands/eval.d.ts.map +1 -1
  123. package/dist/cli/commands/eval.js +17 -17
  124. package/dist/cli/commands/eval.js.map +1 -1
  125. package/dist/cli/commands/evaluate.d.ts +1 -35
  126. package/dist/cli/commands/evaluate.d.ts.map +1 -1
  127. package/dist/cli/commands/evaluate.js +56 -187
  128. package/dist/cli/commands/evaluate.js.map +1 -1
  129. package/dist/cli/commands/explain.d.ts.map +1 -1
  130. package/dist/cli/commands/explain.js +43 -38
  131. package/dist/cli/commands/explain.js.map +1 -1
  132. package/dist/cli/commands/ground.js +1 -1
  133. package/dist/cli/commands/ground.js.map +1 -1
  134. package/dist/cli/commands/map.js +3 -4
  135. package/dist/cli/commands/map.js.map +1 -1
  136. package/dist/cli/commands/metric.d.ts.map +1 -1
  137. package/dist/cli/commands/metric.js +3 -0
  138. package/dist/cli/commands/metric.js.map +1 -1
  139. package/dist/cli/commands/regime.js +1 -1
  140. package/dist/cli/commands/regime.js.map +1 -1
  141. package/dist/cli/commands/symbolic.d.ts.map +1 -1
  142. package/dist/cli/commands/symbolic.js +5 -2
  143. package/dist/cli/commands/symbolic.js.map +1 -1
  144. package/dist/cli/commands/testplan.js +3 -3
  145. package/dist/cli/commands/testplan.js.map +1 -1
  146. package/dist/cli/conventions.d.ts +6 -7
  147. package/dist/cli/conventions.d.ts.map +1 -1
  148. package/dist/cli/conventions.js +19 -28
  149. package/dist/cli/conventions.js.map +1 -1
  150. package/dist/cli/euler-guard.d.ts +13 -2
  151. package/dist/cli/euler-guard.d.ts.map +1 -1
  152. package/dist/cli/euler-guard.js +17 -3
  153. package/dist/cli/euler-guard.js.map +1 -1
  154. package/dist/cli/eval-numbers.d.ts +4 -9
  155. package/dist/cli/eval-numbers.d.ts.map +1 -1
  156. package/dist/cli/eval-numbers.js +11 -41
  157. package/dist/cli/eval-numbers.js.map +1 -1
  158. package/dist/cli/published-url.d.ts +2 -0
  159. package/dist/cli/published-url.d.ts.map +1 -1
  160. package/dist/cli/published-url.js +5 -0
  161. package/dist/cli/published-url.js.map +1 -1
  162. package/dist/cli/record-tables.d.ts +2 -1
  163. package/dist/cli/record-tables.d.ts.map +1 -1
  164. package/dist/cli/record-tables.js +8 -3
  165. package/dist/cli/record-tables.js.map +1 -1
  166. package/dist/cli-api.d.ts +45 -12
  167. package/dist/cli-api.d.ts.map +1 -1
  168. package/dist/cli-api.js +38 -11
  169. package/dist/cli-api.js.map +1 -1
  170. package/dist/composition/adjudication.d.ts +8 -30
  171. package/dist/composition/adjudication.d.ts.map +1 -1
  172. package/dist/composition/adjudication.js +15 -67
  173. package/dist/composition/adjudication.js.map +1 -1
  174. package/dist/composition/aliases.d.ts +1 -1
  175. package/dist/composition/aliases.d.ts.map +1 -1
  176. package/dist/composition/aliases.js +10 -20
  177. package/dist/composition/aliases.js.map +1 -1
  178. package/dist/composition/bridge-analysis.d.ts +4 -0
  179. package/dist/composition/bridge-analysis.d.ts.map +1 -1
  180. package/dist/composition/bridge-analysis.js +13 -14
  181. package/dist/composition/bridge-analysis.js.map +1 -1
  182. package/dist/composition/canonical-graph.d.ts +7 -9
  183. package/dist/composition/canonical-graph.d.ts.map +1 -1
  184. package/dist/composition/canonical-graph.js +35 -19
  185. package/dist/composition/canonical-graph.js.map +1 -1
  186. package/dist/composition/canonical-prefactors.d.ts +10 -29
  187. package/dist/composition/canonical-prefactors.d.ts.map +1 -1
  188. package/dist/composition/canonical-prefactors.js +15 -202
  189. package/dist/composition/canonical-prefactors.js.map +1 -1
  190. package/dist/composition/compose.js +2 -1
  191. package/dist/composition/compose.js.map +1 -1
  192. package/dist/composition/discovery.d.ts +50 -0
  193. package/dist/composition/discovery.d.ts.map +1 -1
  194. package/dist/composition/discovery.js +2 -2
  195. package/dist/composition/discovery.js.map +1 -1
  196. package/dist/composition/edge.d.ts +0 -14
  197. package/dist/composition/edge.d.ts.map +1 -1
  198. package/dist/composition/edge.js +1 -17
  199. package/dist/composition/edge.js.map +1 -1
  200. package/dist/composition/evaluate-relation.d.ts +29 -5
  201. package/dist/composition/evaluate-relation.d.ts.map +1 -1
  202. package/dist/composition/evaluate-relation.js +100 -72
  203. package/dist/composition/evaluate-relation.js.map +1 -1
  204. package/dist/composition/explain.d.ts +5 -0
  205. package/dist/composition/explain.d.ts.map +1 -1
  206. package/dist/composition/explain.js +9 -8
  207. package/dist/composition/explain.js.map +1 -1
  208. package/dist/composition/expr-eval.d.ts.map +1 -1
  209. package/dist/composition/expr-eval.js +2 -1
  210. package/dist/composition/expr-eval.js.map +1 -1
  211. package/dist/composition/index.d.ts +3 -1
  212. package/dist/composition/index.d.ts.map +1 -1
  213. package/dist/composition/index.js +3 -1
  214. package/dist/composition/index.js.map +1 -1
  215. package/dist/composition/proposed-bridges.d.ts.map +1 -1
  216. package/dist/composition/proposed-bridges.js +3 -2
  217. package/dist/composition/proposed-bridges.js.map +1 -1
  218. package/dist/composition/retrodiction.d.ts +8 -0
  219. package/dist/composition/retrodiction.d.ts.map +1 -1
  220. package/dist/composition/retrodiction.js +5 -0
  221. package/dist/composition/retrodiction.js.map +1 -1
  222. package/dist/composition/user-equation.d.ts +11 -7
  223. package/dist/composition/user-equation.d.ts.map +1 -1
  224. package/dist/composition/user-equation.js +24 -26
  225. package/dist/composition/user-equation.js.map +1 -1
  226. package/dist/core/constants.d.ts +27 -4
  227. package/dist/core/constants.d.ts.map +1 -1
  228. package/dist/core/constants.js +38 -5
  229. package/dist/core/constants.js.map +1 -1
  230. package/dist/core/data-file.d.ts +27 -0
  231. package/dist/core/data-file.d.ts.map +1 -0
  232. package/dist/core/data-file.js +48 -0
  233. package/dist/core/data-file.js.map +1 -0
  234. package/dist/core/json-schema.d.ts +27 -0
  235. package/dist/core/json-schema.d.ts.map +1 -0
  236. package/dist/core/json-schema.js +153 -0
  237. package/dist/core/json-schema.js.map +1 -0
  238. package/dist/core/types.d.ts +3 -2
  239. package/dist/core/types.d.ts.map +1 -1
  240. package/dist/core/types.js +16 -14
  241. package/dist/core/types.js.map +1 -1
  242. package/dist/diff/bridge-ast-gradient.d.ts.map +1 -1
  243. package/dist/diff/bridge-ast-gradient.js +6 -17
  244. package/dist/diff/bridge-ast-gradient.js.map +1 -1
  245. package/dist/diff/bridge-specs.d.ts +2 -1
  246. package/dist/diff/bridge-specs.d.ts.map +1 -1
  247. package/dist/diff/bridge-specs.js +1 -1
  248. package/dist/diff/bridge-specs.js.map +1 -1
  249. package/dist/dimensional/bridge-check.d.ts.map +1 -1
  250. package/dist/dimensional/bridge-check.js +3 -5
  251. package/dist/dimensional/bridge-check.js.map +1 -1
  252. package/dist/dimensional/constant-rows.d.ts +54 -0
  253. package/dist/dimensional/constant-rows.d.ts.map +1 -0
  254. package/dist/dimensional/constant-rows.js +111 -0
  255. package/dist/dimensional/constant-rows.js.map +1 -0
  256. package/dist/dimensional/constants.d.ts +4 -13
  257. package/dist/dimensional/constants.d.ts.map +1 -1
  258. package/dist/dimensional/constants.js +11 -19
  259. package/dist/dimensional/constants.js.map +1 -1
  260. package/dist/dimensional/dimension-spec.d.ts +12 -3
  261. package/dist/dimensional/dimension-spec.d.ts.map +1 -1
  262. package/dist/dimensional/dimension-spec.js +114 -150
  263. package/dist/dimensional/dimension-spec.js.map +1 -1
  264. package/dist/dimensional/exact-scale.d.ts +79 -0
  265. package/dist/dimensional/exact-scale.d.ts.map +1 -0
  266. package/dist/dimensional/exact-scale.js +222 -0
  267. package/dist/dimensional/exact-scale.js.map +1 -0
  268. package/dist/dimensional/formula-names.d.ts +13 -12
  269. package/dist/dimensional/formula-names.d.ts.map +1 -1
  270. package/dist/dimensional/formula-names.js +28 -51
  271. package/dist/dimensional/formula-names.js.map +1 -1
  272. package/dist/dimensional/quantity-registry.d.ts +10 -1
  273. package/dist/dimensional/quantity-registry.d.ts.map +1 -1
  274. package/dist/dimensional/quantity-registry.js +45 -16
  275. package/dist/dimensional/quantity-registry.js.map +1 -1
  276. package/dist/dimensional/symbolic-constants.d.ts +63 -19
  277. package/dist/dimensional/symbolic-constants.d.ts.map +1 -1
  278. package/dist/dimensional/symbolic-constants.js +109 -92
  279. package/dist/dimensional/symbolic-constants.js.map +1 -1
  280. package/dist/dimensional/unit-data.d.ts +70 -0
  281. package/dist/dimensional/unit-data.d.ts.map +1 -0
  282. package/dist/dimensional/unit-data.js +135 -0
  283. package/dist/dimensional/unit-data.js.map +1 -0
  284. package/dist/dimensional/units.d.ts +87 -24
  285. package/dist/dimensional/units.d.ts.map +1 -1
  286. package/dist/dimensional/units.js +253 -276
  287. package/dist/dimensional/units.js.map +1 -1
  288. package/dist/index.d.ts +15 -13
  289. package/dist/index.d.ts.map +1 -1
  290. package/dist/index.js +7 -4
  291. package/dist/index.js.map +1 -1
  292. package/dist/numerical/binding-value.d.ts +21 -1
  293. package/dist/numerical/binding-value.d.ts.map +1 -1
  294. package/dist/numerical/binding-value.js +123 -118
  295. package/dist/numerical/binding-value.js.map +1 -1
  296. package/dist/numerical/evaluator-uncertainty.d.ts +34 -0
  297. package/dist/numerical/evaluator-uncertainty.d.ts.map +1 -0
  298. package/dist/numerical/evaluator-uncertainty.js +117 -0
  299. package/dist/numerical/evaluator-uncertainty.js.map +1 -0
  300. package/dist/numerical/formula-contract.d.ts +4 -0
  301. package/dist/numerical/formula-contract.d.ts.map +1 -1
  302. package/dist/numerical/formula-contract.js +7 -0
  303. package/dist/numerical/formula-contract.js.map +1 -1
  304. package/dist/numerical/formula-dimension.d.ts +9 -0
  305. package/dist/numerical/formula-dimension.d.ts.map +1 -1
  306. package/dist/numerical/formula-dimension.js +64 -10
  307. package/dist/numerical/formula-dimension.js.map +1 -1
  308. package/dist/numerical/formula-mathts.d.ts.map +1 -1
  309. package/dist/numerical/formula-mathts.js +6 -2
  310. package/dist/numerical/formula-mathts.js.map +1 -1
  311. package/dist/numerical/gl4-integrator.d.ts.map +1 -1
  312. package/dist/numerical/gl4-integrator.js +3 -3
  313. package/dist/numerical/gl4-integrator.js.map +1 -1
  314. package/dist/numerical/spacetime-metrics.d.ts +4 -0
  315. package/dist/numerical/spacetime-metrics.d.ts.map +1 -1
  316. package/dist/numerical/spacetime-metrics.js +34 -4
  317. package/dist/numerical/spacetime-metrics.js.map +1 -1
  318. package/dist/relations/types.d.ts +8 -1
  319. package/dist/relations/types.d.ts.map +1 -1
  320. package/dist/relations/types.js +10 -0
  321. package/dist/relations/types.js.map +1 -1
  322. package/package.json +1 -1
@@ -1,42 +1,89 @@
1
1
  /**
2
- * Symbolic-composition constant registry (v0.12 symbolic composition).
2
+ * The constant registry: one row per physical constant a formula may name.
3
3
  *
4
- * The physical constants and named numeric factors that a bridge's
5
- * `symbolic` ExprNode may reference as leaf symbols, with the SI value AND
6
- * the SI dimension. SI VALUES import from `core/constants.js` — the single
7
- * source the bridge evaluators also resolve to — so a symbolic form and its
8
- * numeric evaluator agree bit-for-bit (the drift guard binds this end-to-end;
9
- * Adam A-7 / Eve EVE-3).
4
+ * A row (written in `constant-rows.ts`) holds the formula name, its other
5
+ * exact-case spellings, the SI value (imported from `core/constants.js`, the
6
+ * one owner of every value), the SI unit in `parseUnit` syntax, the meaning
7
+ * and the source. The dimension is derived from the unit once, here; no second
8
+ * table states it. The rows sit in their own module because the unit table
9
+ * names constants by these spellings, and this module imports the unit parser. Every other
10
+ * constant table in the library ({@link CONSTANTS}, `FORMULA_NAMED`,
11
+ * `CONSTANT_SPELLINGS`, {@link CONSTANT_PROVENANCE}, `CANONICAL_CONSTANTS`,
12
+ * the `upt eval` scope, the binding scope, the gradient constants) is a
13
+ * projection of this array, so a spelling, a value and a dimension cannot
14
+ * disagree between two files. A constant that is also a quantity names its
15
+ * `data/quantities.json` row in `quantity`; the quantity registry derives that
16
+ * row's aliases from here, so the file states no constant spelling.
10
17
  *
11
- * Numeric-literal leaves (`'2'`, `'3'`) are NOT registered here — `evalExpr`
18
+ * `canonical` marks a universal constant a canonical equation's `governing`
19
+ * list may bake as a leaf. A row that is an overlay for `upt eval` and the
20
+ * dimensional assignment only (`m_p`, `N_A`, the GRW parameters) is not
21
+ * canonical, so the canonical graph does not bake it.
22
+ *
23
+ * Numeric-literal leaves (`'2'`, `'3'`) are NOT registered — `evalExpr`
12
24
  * resolves them via `Number(name)` and they are implicitly dimensionless.
13
- * Non-base-10 tokens (`'8pi'`, `'4pi'`, `'ln2'`) MUST be here (Adam A-1 —
14
- * `Number('8pi')` is `NaN`).
25
+ * Non-base-10 tokens (`'8pi'`, `'4pi'`, `'ln2'`) MUST be here (`Number('8pi')`
26
+ * is `NaN`).
15
27
  *
16
28
  * INTERNAL — not on the public surface.
17
29
  *
18
30
  * @module dimensional/symbolic-constants
19
31
  */
20
32
  import type { Dimension } from './types.js';
33
+ import { type ConstantRow } from './constant-rows.js';
34
+ /** One registered constant: its row, with the dimension derived from its unit. @internal */
35
+ export interface ConstantRecord extends ConstantRow {
36
+ readonly dim: Dimension;
37
+ }
38
+ /**
39
+ * Every registered constant, the rows of `constant-rows.ts` with each
40
+ * dimension derived once from its unit. Order is the order the tables print.
41
+ * @internal
42
+ */
43
+ export declare const CONSTANT_REGISTRY: readonly ConstantRecord[];
44
+ /** The registered constant `spelling` names, or undefined. @internal */
45
+ export declare function constantRecord(spelling: string): ConstantRecord | undefined;
46
+ /** A stated value for a registered constant disagrees with the registry. The equations use the registered value. @internal */
47
+ export declare class ConstantDisagreementError extends Error {
48
+ readonly key: string;
49
+ readonly constant: string;
50
+ readonly registered: number;
51
+ readonly given: number;
52
+ constructor(key: string, constant: string, registered: number, given: number);
53
+ }
54
+ /**
55
+ * The registered constant `key` names when `value` agrees with it within
56
+ * {@link CONSTANT_AGREEMENT}, or null when `key` names no constant. A value
57
+ * that disagrees throws {@link ConstantDisagreementError}: a constant is not
58
+ * a graph quantity, so a stated value is checked, never bound.
59
+ * @internal
60
+ */
61
+ export declare function constantAgreement(key: string, value: number): string | null;
62
+ /** The notes of the registered constants among `names`, each once, in registry order. @internal */
63
+ export declare function constantNotes(names: Iterable<string>): string[];
64
+ /** Every spelling → SI value, for a numeric scope. `pi` and `tau` are added. @internal */
65
+ export declare function constantScope(): Record<string, number>;
21
66
  /** A registered constant leaf: SI value + SI dimension. @internal */
22
- interface NamedConstantValue {
67
+ export interface NamedConstantValue {
23
68
  readonly value: number;
24
69
  readonly dim: Dimension;
25
70
  }
26
71
  /**
27
- * Constant leaves a `symbolic` ExprNode may reference. Keys are the leaf
28
- * symbol `name`s; values carry the SI magnitude and dimension. `ln2`/`8pi`/
29
- * `4pi` reproduce the evaluators' `Math.LN2` / `8*Math.PI` / `4*Math.PI`
30
- * exactly (same IEEE-754 primitives).
72
+ * Constant leaves a `symbolic` ExprNode may reference, keyed by formula name:
73
+ * the canonical rows of {@link CONSTANT_REGISTRY}. `ln2`/`8pi`/`4pi`
74
+ * reproduce the evaluators' `Math.LN2` / `8*Math.PI` / `4*Math.PI` exactly
75
+ * (same IEEE-754 primitives).
31
76
  */
32
77
  export declare const CONSTANTS: Readonly<Record<string, NamedConstantValue>>;
33
78
  /** What a registered constant is, its SI unit, and where its value comes from (audit I10). @internal */
34
79
  export interface ConstantProvenance {
35
80
  readonly meaning: string;
36
- /** The SI unit, in the syntax `parseUnit` reads; a test checks it against the registered dimension. */
81
+ /** The SI unit, in the syntax `parseUnit` reads; the registered dimension is derived from it. */
37
82
  readonly unit: string;
38
83
  readonly source: string;
39
84
  }
85
+ /** One row per {@link CONSTANT_REGISTRY} name. @internal */
86
+ export declare const CONSTANT_PROVENANCE: Readonly<Record<string, ConstantProvenance>>;
40
87
  /**
41
88
  * A spelled-out multiple of π written as one symbol (`pi`, `6pi`). `2pi`,
42
89
  * `4pi` and `8pi` are also registered in {@link CONSTANTS}; this covers the
@@ -47,7 +94,4 @@ export interface ConstantProvenance {
47
94
  * @internal
48
95
  */
49
96
  export declare function piMultipleValue(name: string): number | undefined;
50
- /** One row per {@link CONSTANTS} key; a test holds the two key sets equal. @internal */
51
- export declare const CONSTANT_PROVENANCE: Readonly<Record<string, ConstantProvenance>>;
52
- export {};
53
97
  //# sourceMappingURL=symbolic-constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"symbolic-constants.d.ts","sourceRoot":"","sources":["../../src/dimensional/symbolic-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAiC5C,qEAAqE;AACrE,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAuBlE,CAAC;AAEF,wGAAwG;AACxG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uGAAuG;IACvG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMhE;AAED,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,EAAE,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kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAKlE,CAAC;AAEF,wGAAwG;AACxG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iGAAiG;IACjG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAK5E,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMhE"}
@@ -1,75 +1,123 @@
1
1
  /**
2
- * Symbolic-composition constant registry (v0.12 symbolic composition).
2
+ * The constant registry: one row per physical constant a formula may name.
3
3
  *
4
- * The physical constants and named numeric factors that a bridge's
5
- * `symbolic` ExprNode may reference as leaf symbols, with the SI value AND
6
- * the SI dimension. SI VALUES import from `core/constants.js` — the single
7
- * source the bridge evaluators also resolve to — so a symbolic form and its
8
- * numeric evaluator agree bit-for-bit (the drift guard binds this end-to-end;
9
- * Adam A-7 / Eve EVE-3).
4
+ * A row (written in `constant-rows.ts`) holds the formula name, its other
5
+ * exact-case spellings, the SI value (imported from `core/constants.js`, the
6
+ * one owner of every value), the SI unit in `parseUnit` syntax, the meaning
7
+ * and the source. The dimension is derived from the unit once, here; no second
8
+ * table states it. The rows sit in their own module because the unit table
9
+ * names constants by these spellings, and this module imports the unit parser. Every other
10
+ * constant table in the library ({@link CONSTANTS}, `FORMULA_NAMED`,
11
+ * `CONSTANT_SPELLINGS`, {@link CONSTANT_PROVENANCE}, `CANONICAL_CONSTANTS`,
12
+ * the `upt eval` scope, the binding scope, the gradient constants) is a
13
+ * projection of this array, so a spelling, a value and a dimension cannot
14
+ * disagree between two files. A constant that is also a quantity names its
15
+ * `data/quantities.json` row in `quantity`; the quantity registry derives that
16
+ * row's aliases from here, so the file states no constant spelling.
10
17
  *
11
- * Numeric-literal leaves (`'2'`, `'3'`) are NOT registered here — `evalExpr`
18
+ * `canonical` marks a universal constant a canonical equation's `governing`
19
+ * list may bake as a leaf. A row that is an overlay for `upt eval` and the
20
+ * dimensional assignment only (`m_p`, `N_A`, the GRW parameters) is not
21
+ * canonical, so the canonical graph does not bake it.
22
+ *
23
+ * Numeric-literal leaves (`'2'`, `'3'`) are NOT registered — `evalExpr`
12
24
  * resolves them via `Number(name)` and they are implicitly dimensionless.
13
- * Non-base-10 tokens (`'8pi'`, `'4pi'`, `'ln2'`) MUST be here (Adam A-1 —
14
- * `Number('8pi')` is `NaN`).
25
+ * Non-base-10 tokens (`'8pi'`, `'4pi'`, `'ln2'`) MUST be here (`Number('8pi')`
26
+ * is `NaN`).
15
27
  *
16
28
  * INTERNAL — not on the public surface.
17
29
  *
18
30
  * @module dimensional/symbolic-constants
19
31
  */
20
- import { ACTION, CHARGE, DIMENSIONLESS, MASS, VELOCITY, } from './types.js';
21
- import { C_SI, E_SI, G_SI, GM_SUN_SI, HBAR_SI, H_SI, K_B_SI, B_WIEN_SI, M_U_SI } from '../core/constants.js';
22
- const dim = (L = 0, M = 0, T = 0, Theta = 0) => ({
23
- L,
24
- M,
25
- T,
26
- I: 0,
27
- Theta,
28
- N: 0,
29
- J: 0,
30
- });
31
- /** Newton's constant G — [L³ M⁻¹ T⁻²]. */
32
- const GRAV = dim(3, -1, -2);
33
- /** Boltzmann constant k_B — [L² M T⁻² Θ⁻¹] (energy / temperature). */
34
- const BOLTZMANN = dim(2, 1, -2, -1);
35
- /** Vacuum permittivity ε₀ — [I² T⁴ M⁻¹ L⁻³] (F/m). Carries a current
36
- * dimension, so it cannot use the (L,M,T,Θ) `dim` helper. */
37
- const PERMITTIVITY = { L: -3, M: -1, T: 4, I: 2, Theta: 0, N: 0, J: 0 };
38
- /** Stefan–Boltzmann σ — [M T⁻³ Θ⁻⁴] (W m⁻² K⁻⁴). Derived:
39
- * σ = 2π⁵k_B⁴ / (15 c² h³). */
40
- const STEFAN_BOLTZMANN = dim(0, 1, -3, -4);
41
- /** Wien displacement constant b — [L·Θ] (m·K). */
42
- const WIEN = dim(1, 0, 0, 1);
32
+ import { parseUnit } from './units.js';
33
+ import { CONSTANT_ROWS, constantRow } from './constant-rows.js';
34
+ /**
35
+ * Every registered constant, the rows of `constant-rows.ts` with each
36
+ * dimension derived once from its unit. Order is the order the tables print.
37
+ * @internal
38
+ */
39
+ export const CONSTANT_REGISTRY = CONSTANT_ROWS.map((constant) => ({
40
+ ...constant,
41
+ dim: parseUnit(constant.unit).dim,
42
+ }));
43
+ const RECORD_OF_ROW = new Map(CONSTANT_ROWS.map((constant, i) => [constant, CONSTANT_REGISTRY[i]]));
44
+ /** Every spelling → its record; `constant-rows.ts` refuses a spelling written twice. */
45
+ const BY_SPELLING = new Map(CONSTANT_REGISTRY.flatMap((record) => [record.name, ...record.spellings].map((spelling) => [spelling, record])));
46
+ /** The registered constant `spelling` names, or undefined. @internal */
47
+ export function constantRecord(spelling) {
48
+ const constant = constantRow(spelling);
49
+ return constant === undefined ? undefined : RECORD_OF_ROW.get(constant);
50
+ }
51
+ /**
52
+ * Relative tolerance within which a stated constant agrees with the registered
53
+ * value. Textbook roundings such as `b = 2.9e-3` pass.
54
+ * @internal
55
+ */
56
+ const CONSTANT_AGREEMENT = 5e-3;
57
+ /** A stated value for a registered constant disagrees with the registry. The equations use the registered value. @internal */
58
+ export class ConstantDisagreementError extends Error {
59
+ key;
60
+ constant;
61
+ registered;
62
+ given;
63
+ constructor(key, constant, registered, given) {
64
+ super(`'${key}' is the registered constant ${constant} = ${registered}; ` +
65
+ `${given} disagrees, and the equations use the registered value, so it cannot be rebound.`);
66
+ this.key = key;
67
+ this.constant = constant;
68
+ this.registered = registered;
69
+ this.given = given;
70
+ this.name = 'ConstantDisagreementError';
71
+ }
72
+ }
73
+ /**
74
+ * The registered constant `key` names when `value` agrees with it within
75
+ * {@link CONSTANT_AGREEMENT}, or null when `key` names no constant. A value
76
+ * that disagrees throws {@link ConstantDisagreementError}: a constant is not
77
+ * a graph quantity, so a stated value is checked, never bound.
78
+ * @internal
79
+ */
80
+ export function constantAgreement(key, value) {
81
+ const record = BY_SPELLING.get(key);
82
+ if (record === undefined)
83
+ return null;
84
+ if (Math.abs(value - record.value) > CONSTANT_AGREEMENT * Math.abs(record.value)) {
85
+ throw new ConstantDisagreementError(key, record.name, record.value, value);
86
+ }
87
+ return record.name;
88
+ }
89
+ /** The notes of the registered constants among `names`, each once, in registry order. @internal */
90
+ export function constantNotes(names) {
91
+ const seen = new Set();
92
+ for (const name of names) {
93
+ const record = BY_SPELLING.get(name);
94
+ if (record?.note !== undefined)
95
+ seen.add(record);
96
+ }
97
+ return CONSTANT_REGISTRY.filter((record) => seen.has(record)).map((record) => record.note);
98
+ }
99
+ /** Every spelling → SI value, for a numeric scope. `pi` and `tau` are added. @internal */
100
+ export function constantScope() {
101
+ const scope = { pi: Math.PI, tau: 2 * Math.PI };
102
+ for (const [spelling, record] of BY_SPELLING)
103
+ scope[spelling] = record.value;
104
+ return scope;
105
+ }
43
106
  /**
44
- * Constant leaves a `symbolic` ExprNode may reference. Keys are the leaf
45
- * symbol `name`s; values carry the SI magnitude and dimension. `ln2`/`8pi`/
46
- * `4pi` reproduce the evaluators' `Math.LN2` / `8*Math.PI` / `4*Math.PI`
47
- * exactly (same IEEE-754 primitives).
107
+ * Constant leaves a `symbolic` ExprNode may reference, keyed by formula name:
108
+ * the canonical rows of {@link CONSTANT_REGISTRY}. `ln2`/`8pi`/`4pi`
109
+ * reproduce the evaluators' `Math.LN2` / `8*Math.PI` / `4*Math.PI` exactly
110
+ * (same IEEE-754 primitives).
48
111
  */
49
- export const CONSTANTS = {
50
- hbar: { value: HBAR_SI, dim: ACTION },
51
- h: { value: H_SI, dim: ACTION },
52
- c: { value: C_SI, dim: VELOCITY },
53
- G: { value: G_SI, dim: GRAV },
54
- k_B: { value: K_B_SI, dim: BOLTZMANN },
55
- ln2: { value: Math.LN2, dim: DIMENSIONLESS },
56
- '8pi': { value: 8 * Math.PI, dim: DIMENSIONLESS },
57
- '4pi': { value: 4 * Math.PI, dim: DIMENSIONLESS },
58
- '2pi': { value: 2 * Math.PI, dim: DIMENSIONLESS },
59
- // Extension constants for the canonical-equation L1 entries (Coulomb, Bohr,
60
- // Stefan–Boltzmann). CODATA 2018 values.
61
- // ISO 80000 / CODATA: a bare e is the elementary charge. Eccentricity is
62
- // one_minus_e_sq. The canonical dimension guard still refuses to bake a
63
- // dimensionless governing name e.
64
- e: { value: E_SI, dim: CHARGE },
65
- epsilon_0: { value: 8.8541878128e-12, dim: PERMITTIVITY },
66
- sigma_sb: { value: 5.670374419e-8, dim: STEFAN_BOLTZMANN },
67
- b: { value: B_WIEN_SI, dim: WIEN },
68
- // IAU 2015 nominal solar parameter. M_sun in eval stays the rounded kilogram M_SUN_SI.
69
- GM_sun: { value: GM_SUN_SI, dim: dim(3, 0, -2) },
70
- Msun_iau: { value: GM_SUN_SI / G_SI, dim: dim(0, 1, 0) },
71
- m_u: { value: M_U_SI, dim: MASS },
72
- };
112
+ export const CONSTANTS = Object.fromEntries(CONSTANT_REGISTRY.filter((record) => record.canonical).map((record) => [
113
+ record.name,
114
+ { value: record.value, dim: record.dim },
115
+ ]));
116
+ /** One row per {@link CONSTANT_REGISTRY} name. @internal */
117
+ export const CONSTANT_PROVENANCE = Object.fromEntries(CONSTANT_REGISTRY.map((record) => [
118
+ record.name,
119
+ { meaning: record.meaning, unit: record.unit, source: record.source },
120
+ ]));
73
121
  /**
74
122
  * A spelled-out multiple of π written as one symbol (`pi`, `6pi`). `2pi`,
75
123
  * `4pi` and `8pi` are also registered in {@link CONSTANTS}; this covers the
@@ -88,35 +136,4 @@ export function piMultipleValue(name) {
88
136
  return undefined;
89
137
  return n * Math.PI;
90
138
  }
91
- /** One row per {@link CONSTANTS} key; a test holds the two key sets equal. @internal */
92
- export const CONSTANT_PROVENANCE = {
93
- hbar: { meaning: 'reduced Planck constant h/(2π)', unit: 'J*s', source: 'exact H_SI/(2π) (core/constants.ts HBAR_SI)' },
94
- h: { meaning: 'Planck constant', unit: 'J*s', source: 'exact SI, 2019 redefinition (core/constants.ts H_SI)' },
95
- c: { meaning: 'speed of light in vacuum', unit: 'm/s', source: 'exact SI (core/constants.ts C_SI)' },
96
- G: { meaning: 'Newtonian gravitational constant', unit: 'm^3/(kg*s^2)', source: 'CODATA 2018 (core/constants.ts G_SI)' },
97
- k_B: { meaning: 'Boltzmann constant', unit: 'J/K', source: 'exact SI, 2019 redefinition (core/constants.ts K_B_SI)' },
98
- ln2: { meaning: 'natural logarithm of 2', unit: '1', source: 'mathematical constant (Math.LN2)' },
99
- '8pi': { meaning: '8π', unit: '1', source: 'mathematical constant (8·Math.PI)' },
100
- '4pi': { meaning: '4π', unit: '1', source: 'mathematical constant (4·Math.PI)' },
101
- '2pi': { meaning: '2π', unit: '1', source: 'mathematical constant (2·Math.PI)' },
102
- e: { meaning: 'elementary charge', unit: 'C', source: 'exact SI, 2019 redefinition (core/constants.ts E_SI)' },
103
- epsilon_0: { meaning: 'vacuum permittivity', unit: 'F/m', source: 'CODATA 2018 (this table)' },
104
- sigma_sb: { meaning: 'Stefan–Boltzmann constant', unit: 'W/(m^2*K^4)', source: 'CODATA 2018 (this table)' },
105
- b: { meaning: 'Wien displacement constant', unit: 'm*K', source: 'CODATA 2018 (core/constants.ts B_WIEN_SI)' },
106
- GM_sun: {
107
- meaning: 'IAU nominal solar gravitational parameter (GM)☉',
108
- unit: 'm^3/s^2',
109
- source: 'IAU 2015 Resolution B3 (core/constants.ts GM_SUN_SI)',
110
- },
111
- Msun_iau: {
112
- meaning: 'IAU solar mass (GM)☉/G, the mass that reproduces GM_sun with G_SI',
113
- unit: 'kg',
114
- source: 'GM_SUN_SI/G_SI (core/constants.ts)',
115
- },
116
- m_u: {
117
- meaning: 'unified atomic mass unit (atomic mass constant)',
118
- unit: 'kg',
119
- source: 'CODATA 2018 (core/constants.ts M_U_SI)',
120
- },
121
- };
122
139
  //# sourceMappingURL=symbolic-constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"symbolic-constants.js","sourceRoot":"","sources":["../../src/dimensional/symbolic-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,IAAI,EACJ,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE7G,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAa,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC,EAAE,CAAC;IACJ,KAAK;IACL,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;CACL,CAAC,CAAC;AAEH,0CAA0C;AAC1C,MAAM,IAAI,GAAc,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,sEAAsE;AACtE,MAAM,SAAS,GAAc,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/C;8DAC8D;AAC9D,MAAM,YAAY,GAAc,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAA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C,MAAM,EAAE,EAAE,CAAC;IAChC,MAAM,CAAC,IAAI;IACX,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;CACtE,CAAC,CACH,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACjC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACpD,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AACrB,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The unit table, loaded from `data/units.json` and validated once.
3
+ *
4
+ * The file is checked against `data/units.schema.json` when this module
5
+ * loads (`core/data-file`), then against the rules a schema cannot state:
6
+ * every scale expression reads, a symbol is spelled by one row, a refused
7
+ * spelling and an affine spelling are not also a unit, every prefix letter is
8
+ * both a prefix and a unit, and every `{NAME}` in a note is a constant. A
9
+ * file that breaks one throws here, so `units.ts` never reads a half-valid table.
10
+ *
11
+ * A scale is an exact expression, read by `exact-scale.ts`. A name in it is a
12
+ * shared scale from the file's `scales`, `pi`, or a constant under its registry
13
+ * spelling (`c`, `e`, `m_u`, `M_sun`, `Msun_iau`, `ln2`; `constant-rows.ts`),
14
+ * the same spelling a `{NAME}` note placeholder uses. A constant is read through
15
+ * its shortest decimal (`scaleOf`), or as the irrational factor when its row is
16
+ * `irrational`. A shared scale may not reuse a constant's spelling, so a name
17
+ * has one meaning. The raw rows are strings and integer exponents, so another
18
+ * exact reader (MathTS) replaces this loader without touching the file.
19
+ *
20
+ * @module dimensional/unit-data
21
+ */
22
+ import type { JsonSchema } from '../core/json-schema.js';
23
+ import type { Dimension } from './types.js';
24
+ import { type ExactScale } from './exact-scale.js';
25
+ /** One unit symbol, read exactly. @internal */
26
+ export interface UnitRow {
27
+ /** Exact scale to SI base units. */
28
+ readonly scale: ExactScale;
29
+ readonly dim: Dimension;
30
+ /** Takes an SI prefix. */
31
+ readonly prefixable: boolean;
32
+ /**
33
+ * The unit counts cycles (turns), not radians. An angular-frequency input in
34
+ * rad/s takes 2π per cycle; the radian itself does not.
35
+ */
36
+ readonly cycles?: true;
37
+ }
38
+ /** One affine temperature scale, read exactly. @internal */
39
+ export interface AffineRow {
40
+ readonly id: string;
41
+ /** Kelvin per degree, exactly. */
42
+ readonly scale: ExactScale;
43
+ /** The reading at the ice point (0 °C, 273.15 K), exactly. */
44
+ readonly icePoint: ExactScale;
45
+ readonly symbols: readonly string[];
46
+ }
47
+ /** The unit table `units.ts` reads. @internal */
48
+ export interface UnitTableData {
49
+ readonly units: ReadonlyMap<string, UnitRow>;
50
+ readonly prefixes: ReadonlyMap<string, ExactScale>;
51
+ /** Refused spelling → the message it prints. */
52
+ readonly refused: ReadonlyMap<string, string>;
53
+ readonly prefixLetterUnits: ReadonlySet<string>;
54
+ /** Kelvin at 0 °C, exactly. */
55
+ readonly iceKelvin: ExactScale;
56
+ readonly affine: readonly AffineRow[];
57
+ /** Spelling → its note, with every `{NAME}` replaced by that constant. */
58
+ readonly spellingNotes: ReadonlyMap<string, string>;
59
+ /** SHA-256 of `data/units.json` with line endings as LF, for the CLI record fingerprint. */
60
+ readonly sha256: string;
61
+ }
62
+ /**
63
+ * Validate and read `text`, the contents of `data/units.json`, against `schema`.
64
+ * Throws on a file the schema or the table rules reject. A test passes a broken copy.
65
+ * @internal
66
+ */
67
+ export declare function readUnitFile(text: string, schema: JsonSchema): UnitTableData;
68
+ /** The unit table, read once from `data/units.json`. @internal */
69
+ export declare const UNIT_DATA: UnitTableData;
70
+ //# sourceMappingURL=unit-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit-data.d.ts","sourceRoot":"","sources":["../../src/dimensional/unit-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAA+D,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA6BhH,+CAA+C;AAC/C,MAAM,WAAW,OAAO;IACtB,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,0BAA0B;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;CACxB;AAED,4DAA4D;AAC5D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,iDAAiD;AACjD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnD,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,+BAA+B;IAC/B,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,4FAA4F;IAC5F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAoBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,aAAa,CA8E5E;AAED,kEAAkE;AAClE,eAAO,MAAM,SAAS,EAAE,aAA8E,CAAC"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * The unit table, loaded from `data/units.json` and validated once.
3
+ *
4
+ * The file is checked against `data/units.schema.json` when this module
5
+ * loads (`core/data-file`), then against the rules a schema cannot state:
6
+ * every scale expression reads, a symbol is spelled by one row, a refused
7
+ * spelling and an affine spelling are not also a unit, every prefix letter is
8
+ * both a prefix and a unit, and every `{NAME}` in a note is a constant. A
9
+ * file that breaks one throws here, so `units.ts` never reads a half-valid table.
10
+ *
11
+ * A scale is an exact expression, read by `exact-scale.ts`. A name in it is a
12
+ * shared scale from the file's `scales`, `pi`, or a constant under its registry
13
+ * spelling (`c`, `e`, `m_u`, `M_sun`, `Msun_iau`, `ln2`; `constant-rows.ts`),
14
+ * the same spelling a `{NAME}` note placeholder uses. A constant is read through
15
+ * its shortest decimal (`scaleOf`), or as the irrational factor when its row is
16
+ * `irrational`. A shared scale may not reuse a constant's spelling, so a name
17
+ * has one meaning. The raw rows are strings and integer exponents, so another
18
+ * exact reader (MathTS) replaces this loader without touching the file.
19
+ *
20
+ * @module dimensional/unit-data
21
+ */
22
+ import { createHash } from 'node:crypto';
23
+ import { dataSchema, dataText, parseDataFile } from '../core/data-file.js';
24
+ import { constantRow } from './constant-rows.js';
25
+ import { decimalScale, irrationalScale, readScaleExpression, scaleOf } from './exact-scale.js';
26
+ const BASES = ['L', 'M', 'T', 'I', 'Theta', 'N', 'J'];
27
+ /** π, which the registry does not spell (a formula scope adds `pi` itself), as the irrational factor. */
28
+ const PI = 'pi';
29
+ const PI_SCALE = irrationalScale(Math.PI);
30
+ /** The registered constant `name` spells, exactly: its irrational factor or its shortest decimal; undefined when no constant has that spelling. */
31
+ function constantScale(name) {
32
+ const constant = constantRow(name);
33
+ if (constant === undefined)
34
+ return undefined;
35
+ return constant.irrational === true ? irrationalScale(constant.value) : scaleOf(constant.value);
36
+ }
37
+ function dimension(d) {
38
+ const out = {};
39
+ for (const base of BASES)
40
+ out[base] = d[base] ?? 0;
41
+ return out;
42
+ }
43
+ /**
44
+ * Validate and read `text`, the contents of `data/units.json`, against `schema`.
45
+ * Throws on a file the schema or the table rules reject. A test passes a broken copy.
46
+ * @internal
47
+ */
48
+ export function readUnitFile(text, schema) {
49
+ const file = parseDataFile('units.json', text, schema);
50
+ for (const name of Object.keys(file.scales)) {
51
+ if (name === PI || constantRow(name) !== undefined) {
52
+ throw new Error(`data/units.json: shared scale '${name}' is also ${name === PI ? 'π' : 'a registered constant'}; a name has one meaning`);
53
+ }
54
+ }
55
+ const named = new Map();
56
+ const reading = new Set();
57
+ const resolve = (name) => {
58
+ if (name === PI)
59
+ return PI_SCALE;
60
+ const shared = file.scales[name];
61
+ if (shared !== undefined) {
62
+ const done = named.get(name);
63
+ if (done !== undefined)
64
+ return done;
65
+ if (reading.has(name))
66
+ throw new Error(`data/units.json: scale '${name}' is defined in terms of itself`);
67
+ reading.add(name);
68
+ const scale = readScaleExpression(shared, resolve);
69
+ reading.delete(name);
70
+ named.set(name, scale);
71
+ return scale;
72
+ }
73
+ return constantScale(name);
74
+ };
75
+ const read = (text, where) => {
76
+ try {
77
+ return readScaleExpression(text, resolve);
78
+ }
79
+ catch (error) {
80
+ throw new Error(`data/units.json ${where}: ${error.message}`);
81
+ }
82
+ };
83
+ const prefixes = new Map(Object.entries(file.prefixes).map(([prefix, text]) => [prefix, decimalScale(text)]));
84
+ const units = new Map();
85
+ for (const row of file.units) {
86
+ const scale = read(row.scale, `unit ${row.symbols[0]}`);
87
+ const unit = { scale, dim: dimension(row.dimension), prefixable: row.prefixable, ...(row.cycles ? { cycles: true } : {}) };
88
+ for (const symbol of row.symbols) {
89
+ if (units.has(symbol))
90
+ throw new Error(`data/units.json: unit '${symbol}' is spelled by two rows`);
91
+ units.set(symbol, unit);
92
+ }
93
+ }
94
+ const refused = new Map();
95
+ for (const { symbol, reason } of file.refused) {
96
+ if (units.has(symbol) || refused.has(symbol))
97
+ throw new Error(`data/units.json: refused '${symbol}' is also a unit or refused twice`);
98
+ refused.set(symbol, reason);
99
+ }
100
+ for (const letter of file.prefixLetterUnits.letters) {
101
+ if (!prefixes.has(letter) || !units.has(letter)) {
102
+ throw new Error(`data/units.json: prefix letter '${letter}' is not both a prefix and a unit`);
103
+ }
104
+ }
105
+ const affine = file.affine.scales.map((row) => {
106
+ for (const symbol of row.symbols) {
107
+ if (units.has(symbol) || refused.has(symbol))
108
+ throw new Error(`data/units.json: affine '${symbol}' is also a unit or refused`);
109
+ }
110
+ return { id: row.id, scale: read(row.scale, `affine ${row.id}`), icePoint: read(row.icePoint, `affine ${row.id}`), symbols: row.symbols };
111
+ });
112
+ const spellingNotes = new Map();
113
+ for (const { spelling, note } of file.spellingNotes) {
114
+ const filled = note.replace(/\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_, name) => {
115
+ const constant = constantRow(name);
116
+ if (constant === undefined)
117
+ throw new Error(`data/units.json: note for '${spelling}' names '${name}', which is not a registered constant`);
118
+ return String(constant.value);
119
+ });
120
+ spellingNotes.set(spelling, filled);
121
+ }
122
+ return {
123
+ units,
124
+ prefixes,
125
+ refused,
126
+ prefixLetterUnits: new Set(file.prefixLetterUnits.letters),
127
+ iceKelvin: read(file.affine.iceKelvin, 'affine iceKelvin'),
128
+ affine,
129
+ spellingNotes,
130
+ sha256: createHash('sha256').update(text.replace(/\r\n/g, '\n')).digest('hex'),
131
+ };
132
+ }
133
+ /** The unit table, read once from `data/units.json`. @internal */
134
+ export const UNIT_DATA = readUnitFile(dataText('units.json'), dataSchema('units.json'));
135
+ //# sourceMappingURL=unit-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit-data.js","sourceRoot":"","sources":["../../src/dimensional/unit-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAC;AAqEhH,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAC/D,yGAAyG;AACzG,MAAM,EAAE,GAAG,IAAI,CAAC;AAChB,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAE1C,mJAAmJ;AACnJ,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,OAAO,QAAQ,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAClG,CAAC;AAED,SAAS,SAAS,CAAC,CAAgB;IACjC,MAAM,GAAG,GAA2B,EA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