siderust-js 0.1.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.
- package/.github/workflows/ci.yml +166 -0
- package/.gitmodules +9 -0
- package/CHANGELOG.md +26 -0
- package/LICENSE +661 -0
- package/README.md +138 -0
- package/package.json +12 -0
- package/qtty-js/.github/workflows/ci.yml +151 -0
- package/qtty-js/.gitmodules +3 -0
- package/qtty-js/CHANGELOG.md +31 -0
- package/qtty-js/LICENSE +661 -0
- package/qtty-js/README.md +132 -0
- package/qtty-js/package.json +20 -0
- package/qtty-js/qtty/.github/workflows/ci.yml +155 -0
- package/qtty-js/qtty/CHANGELOG.md +120 -0
- package/qtty-js/qtty/Cargo.lock +1462 -0
- package/qtty-js/qtty/Cargo.toml +12 -0
- package/qtty-js/qtty/LICENSE +661 -0
- package/qtty-js/qtty/README.md +9 -0
- package/qtty-js/qtty/qtty/Cargo.toml +41 -0
- package/qtty-js/qtty/qtty/README.md +8 -0
- package/qtty-js/qtty/qtty/examples/angles.rs +14 -0
- package/qtty-js/qtty/qtty/examples/astronomy.rs +17 -0
- package/qtty-js/qtty/qtty/examples/dimensional_arithmetic.rs +83 -0
- package/qtty-js/qtty/qtty/examples/python_integration.rs +61 -0
- package/qtty-js/qtty/qtty/examples/quickstart.rs +15 -0
- package/qtty-js/qtty/qtty/examples/ratios.rs +12 -0
- package/qtty-js/qtty/qtty/examples/serde_with_unit.rs +234 -0
- package/qtty-js/qtty/qtty/examples/serialization.rs +141 -0
- package/qtty-js/qtty/qtty/examples/serialization_advanced.rs +155 -0
- package/qtty-js/qtty/qtty/src/f32.rs +108 -0
- package/qtty-js/qtty/qtty/src/f64.rs +30 -0
- package/qtty-js/qtty/qtty/src/i128.rs +111 -0
- package/qtty-js/qtty/qtty/src/i16.rs +111 -0
- package/qtty-js/qtty/qtty/src/i32.rs +111 -0
- package/qtty-js/qtty/qtty/src/i64.rs +111 -0
- package/qtty-js/qtty/qtty/src/i8.rs +111 -0
- package/qtty-js/qtty/qtty/src/lib.rs +238 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/src/lib.rs +7 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/src/lib.rs +7 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/src/lib.rs +5 -0
- package/qtty-js/qtty/qtty/tests/integration_tests.rs +529 -0
- package/qtty-js/qtty/qtty/tests/qtty_vec_feature_matrix.rs +58 -0
- package/qtty-js/qtty/qtty-core/Cargo.toml +41 -0
- package/qtty-js/qtty/qtty-core/README.md +8 -0
- package/qtty-js/qtty/qtty-core/examples/diesel_integration.rs +145 -0
- package/qtty-js/qtty/qtty-core/examples/quantity_db_serde.rs +215 -0
- package/qtty-js/qtty/qtty-core/src/dimension.rs +249 -0
- package/qtty-js/qtty/qtty-core/src/feature_diesel.rs +318 -0
- package/qtty-js/qtty/qtty-core/src/feature_pyo3.rs +27 -0
- package/qtty-js/qtty/qtty-core/src/feature_serde.rs +203 -0
- package/qtty-js/qtty/qtty-core/src/feature_tiberius.rs +28 -0
- package/qtty-js/qtty/qtty-core/src/lib.rs +744 -0
- package/qtty-js/qtty/qtty-core/src/macros.rs +93 -0
- package/qtty-js/qtty/qtty-core/src/quantity.rs +810 -0
- package/qtty-js/qtty/qtty-core/src/scalar.rs +1742 -0
- package/qtty-js/qtty/qtty-core/src/unit.rs +332 -0
- package/qtty-js/qtty/qtty-core/src/units/angular.rs +1228 -0
- package/qtty-js/qtty/qtty-core/src/units/area.rs +243 -0
- package/qtty-js/qtty/qtty-core/src/units/frequency.rs +179 -0
- package/qtty-js/qtty/qtty-core/src/units/length.rs +1270 -0
- package/qtty-js/qtty/qtty-core/src/units/mass.rs +488 -0
- package/qtty-js/qtty/qtty-core/src/units/mod.rs +26 -0
- package/qtty-js/qtty/qtty-core/src/units/power.rs +324 -0
- package/qtty-js/qtty/qtty-core/src/units/time.rs +667 -0
- package/qtty-js/qtty/qtty-core/src/units/unitless.rs +212 -0
- package/qtty-js/qtty/qtty-core/src/units/velocity.rs +210 -0
- package/qtty-js/qtty/qtty-core/src/units/volume.rs +269 -0
- package/qtty-js/qtty/qtty-core/tests/core.rs +628 -0
- package/qtty-js/qtty/qtty-core/tests/diesel.rs +461 -0
- package/qtty-js/qtty/qtty-core/tests/integers.rs +632 -0
- package/qtty-js/qtty/qtty-core/tests/no_cross_unit_ops.rs +35 -0
- package/qtty-js/qtty/qtty-core/tests/pyo3.rs +334 -0
- package/qtty-js/qtty/qtty-core/tests/quantity_f32.rs +276 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_decimal.rs +258 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_f32.rs +286 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_f64_real.rs +287 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_rational.rs +260 -0
- package/qtty-js/qtty/qtty-core/tests/serde.rs +256 -0
- package/qtty-js/qtty/qtty-core/tests/tiberius.rs +208 -0
- package/qtty-js/qtty/qtty-derive/Cargo.toml +23 -0
- package/qtty-js/qtty/qtty-derive/README.md +8 -0
- package/qtty-js/qtty/qtty-derive/src/lib.rs +340 -0
- package/qtty-js/qtty/qtty-ffi/ARCHITECTURE.md +3 -0
- package/qtty-js/qtty/qtty-ffi/Cargo.toml +31 -0
- package/qtty-js/qtty/qtty-ffi/README.md +9 -0
- package/qtty-js/qtty/qtty-ffi/build.rs +326 -0
- package/qtty-js/qtty/qtty-ffi/cbindgen.toml +105 -0
- package/qtty-js/qtty/qtty-ffi/include/qtty_ffi.h +1126 -0
- package/qtty-js/qtty/qtty-ffi/src/ffi.rs +1251 -0
- package/qtty-js/qtty/qtty-ffi/src/ffi_serde.rs +294 -0
- package/qtty-js/qtty/qtty-ffi/src/helpers.rs +310 -0
- package/qtty-js/qtty/qtty-ffi/src/lib.rs +229 -0
- package/qtty-js/qtty/qtty-ffi/src/macros.rs +121 -0
- package/qtty-js/qtty/qtty-ffi/src/registry.rs +274 -0
- package/qtty-js/qtty/qtty-ffi/src/types.rs +620 -0
- package/qtty-js/qtty/qtty-ffi/tests/integration_tests.rs +842 -0
- package/qtty-js/qtty/qtty-ffi/units.csv +156 -0
- package/qtty-js/qtty/qtty-ffi/units.csv.md +3 -0
- package/qtty-js/qtty-node/.prettierignore +6 -0
- package/qtty-js/qtty-node/.prettierrc.json +6 -0
- package/qtty-js/qtty-node/README.md +250 -0
- package/qtty-js/qtty-node/c8.config.json +11 -0
- package/qtty-js/qtty-node/eslint.config.js +31 -0
- package/qtty-js/qtty-node/examples/arithmetic.mjs +64 -0
- package/qtty-js/qtty-node/examples/astronomy.mjs +90 -0
- package/qtty-js/qtty-node/examples/quickstart.mjs +36 -0
- package/qtty-js/qtty-node/examples/serialization.mjs +125 -0
- package/qtty-js/qtty-node/examples/unit_factories.mjs +74 -0
- package/qtty-js/qtty-node/index.d.ts +219 -0
- package/qtty-js/qtty-node/index.js +323 -0
- package/qtty-js/qtty-node/lib/DerivedQuantity.js +122 -0
- package/qtty-js/qtty-node/lib/Quantity.js +151 -0
- package/qtty-js/qtty-node/lib/backend.js +25 -0
- package/qtty-js/qtty-node/native.cjs +306 -0
- package/qtty-js/qtty-node/package-lock.json +3223 -0
- package/qtty-js/qtty-node/package.json +70 -0
- package/qtty-js/qtty-node/units.d.ts +299 -0
- package/qtty-js/qtty-node/units.js +210 -0
- package/qtty-js/qtty-web/Cargo.lock +767 -0
- package/qtty-js/qtty-web/Cargo.toml +21 -0
- package/qtty-js/qtty-web/index.d.ts +140 -0
- package/qtty-js/qtty-web/index.js +20 -0
- package/qtty-js/qtty-web/lib/DerivedQuantity.js +58 -0
- package/qtty-js/qtty-web/lib/Quantity.js +75 -0
- package/qtty-js/qtty-web/lib/backend.js +80 -0
- package/qtty-js/qtty-web/package.json +45 -0
- package/qtty-js/qtty-web/src/lib.rs +111 -0
- package/qtty-js/scripts/ci.sh +73 -0
- package/scripts/ci.sh +123 -0
- package/siderust-core/Cargo.lock +787 -0
- package/siderust-core/Cargo.toml +18 -0
- package/siderust-core/DEDUPLICATION.md +124 -0
- package/siderust-core/src/body.rs +120 -0
- package/siderust-core/src/events.rs +184 -0
- package/siderust-core/src/lib.rs +20 -0
- package/siderust-core/src/observer.rs +55 -0
- package/siderust-core/src/position.rs +213 -0
- package/siderust-node/.prettierignore +7 -0
- package/siderust-node/.prettierrc.json +6 -0
- package/siderust-node/Cargo.lock +906 -0
- package/siderust-node/Cargo.toml +29 -0
- package/siderust-node/README.md +109 -0
- package/siderust-node/__test__/index.test.mjs +248 -0
- package/siderust-node/build.rs +5 -0
- package/siderust-node/c8.config.json +3 -0
- package/siderust-node/eslint.config.js +31 -0
- package/siderust-node/examples/01_basic_coordinates.mjs +24 -0
- package/siderust-node/examples/02_coordinate_transformations.mjs +25 -0
- package/siderust-node/examples/03_all_frames_conversions.mjs +26 -0
- package/siderust-node/examples/04_all_center_conversions.mjs +24 -0
- package/siderust-node/examples/05_target_tracking.mjs +22 -0
- package/siderust-node/examples/06_night_events.mjs +18 -0
- package/siderust-node/examples/07_moon_properties.mjs +21 -0
- package/siderust-node/examples/08_solar_system.mjs +19 -0
- package/siderust-node/examples/09_star_observability.mjs +22 -0
- package/siderust-node/examples/10_time_periods.mjs +9 -0
- package/siderust-node/examples/11_serialization.mjs +31 -0
- package/siderust-node/examples/12_runtime_ephemeris.mjs +27 -0
- package/siderust-node/examples/13_coordinate_operations.mjs +20 -0
- package/siderust-node/index.d.ts +623 -0
- package/siderust-node/index.js +79 -0
- package/siderust-node/lib/Observer.js +112 -0
- package/siderust-node/lib/Star.js +118 -0
- package/siderust-node/lib/backend.js +63 -0
- package/siderust-node/lib/wrappers.js +566 -0
- package/siderust-node/main.js +20 -0
- package/siderust-node/native.cjs +360 -0
- package/siderust-node/package-lock.json +3261 -0
- package/siderust-node/package.json +71 -0
- package/siderust-node/src/body.rs +74 -0
- package/siderust-node/src/coordinates.rs +372 -0
- package/siderust-node/src/ephemeris.rs +462 -0
- package/siderust-node/src/events.rs +577 -0
- package/siderust-node/src/lib.rs +43 -0
- package/siderust-node/src/observer.rs +132 -0
- package/siderust-node/src/phase.rs +218 -0
- package/siderust-node/src/position.rs +292 -0
- package/siderust-node/src/star.rs +200 -0
- package/siderust-web/Cargo.lock +855 -0
- package/siderust-web/Cargo.toml +34 -0
- package/siderust-web/README.md +100 -0
- package/siderust-web/__test__/index.test.mjs +118 -0
- package/siderust-web/examples/github-pages/README.md +31 -0
- package/siderust-web/examples/github-pages/index.html +135 -0
- package/siderust-web/index.d.ts +311 -0
- package/siderust-web/index.js +66 -0
- package/siderust-web/lib/Observer.js +103 -0
- package/siderust-web/lib/Star.js +116 -0
- package/siderust-web/lib/backend.js +400 -0
- package/siderust-web/lib/wrappers.js +512 -0
- package/siderust-web/package.json +55 -0
- package/siderust-web/src/body.rs +69 -0
- package/siderust-web/src/coordinates.rs +302 -0
- package/siderust-web/src/ephemeris.rs +456 -0
- package/siderust-web/src/events.rs +520 -0
- package/siderust-web/src/lib.rs +51 -0
- package/siderust-web/src/observer.rs +117 -0
- package/siderust-web/src/phase.rs +190 -0
- package/siderust-web/src/position.rs +291 -0
- package/siderust-web/src/star.rs +178 -0
- package/tempoch-js/.github/workflows/ci.yml +142 -0
- package/tempoch-js/.gitmodules +3 -0
- package/tempoch-js/CHANGELOG.md +25 -0
- package/tempoch-js/LICENSE +661 -0
- package/tempoch-js/README.md +126 -0
- package/tempoch-js/package.json +20 -0
- package/tempoch-js/scripts/ci.sh +73 -0
- package/tempoch-js/tempoch/.github/workflows/ci.yml +113 -0
- package/tempoch-js/tempoch/CHANGELOG.md +82 -0
- package/tempoch-js/tempoch/Cargo.lock +947 -0
- package/tempoch-js/tempoch/Cargo.toml +3 -0
- package/tempoch-js/tempoch/LICENSE +661 -0
- package/tempoch-js/tempoch/README.md +76 -0
- package/tempoch-js/tempoch/tempoch/Cargo.toml +27 -0
- package/tempoch-js/tempoch/tempoch/examples/periods.rs +45 -0
- package/tempoch-js/tempoch/tempoch/examples/quickstart.rs +13 -0
- package/tempoch-js/tempoch/tempoch/src/lib.rs +49 -0
- package/tempoch-js/tempoch/tempoch/tests/integration.rs +57 -0
- package/tempoch-js/tempoch/tempoch-core/Cargo.toml +24 -0
- package/tempoch-js/tempoch/tempoch-core/src/delta_t.rs +345 -0
- package/tempoch-js/tempoch/tempoch-core/src/instant.rs +811 -0
- package/tempoch-js/tempoch/tempoch-core/src/julian_date_ext.rs +142 -0
- package/tempoch-js/tempoch/tempoch-core/src/lib.rs +81 -0
- package/tempoch-js/tempoch/tempoch-core/src/period.rs +1168 -0
- package/tempoch-js/tempoch/tempoch-core/src/scales.rs +779 -0
- package/tempoch-js/tempoch/tempoch-ffi/Cargo.lock +889 -0
- package/tempoch-js/tempoch/tempoch-ffi/Cargo.toml +26 -0
- package/tempoch-js/tempoch/tempoch-ffi/build.rs +24 -0
- package/tempoch-js/tempoch/tempoch-ffi/cbindgen.toml +30 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/error.rs +19 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/lib.rs +82 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/period.rs +101 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/time.rs +711 -0
- package/tempoch-js/tempoch/tempoch-ffi/tests/ffi.rs +265 -0
- package/tempoch-js/tempoch-node/.prettierignore +6 -0
- package/tempoch-js/tempoch-node/.prettierrc.json +6 -0
- package/tempoch-js/tempoch-node/Cargo.lock +496 -0
- package/tempoch-js/tempoch-node/Cargo.toml +29 -0
- package/tempoch-js/tempoch-node/README.md +265 -0
- package/tempoch-js/tempoch-node/__test__/index.test.mjs +598 -0
- package/tempoch-js/tempoch-node/build.rs +5 -0
- package/tempoch-js/tempoch-node/c8.config.json +3 -0
- package/tempoch-js/tempoch-node/eslint.config.js +31 -0
- package/tempoch-js/tempoch-node/examples/periods.mjs +79 -0
- package/tempoch-js/tempoch-node/examples/quickstart.mjs +71 -0
- package/tempoch-js/tempoch-node/examples/timescales.mjs +92 -0
- package/tempoch-js/tempoch-node/index.d.ts +280 -0
- package/tempoch-js/tempoch-node/index.js +32 -0
- package/tempoch-js/tempoch-node/lib/JulianDate.js +176 -0
- package/tempoch-js/tempoch-node/lib/ModifiedJulianDate.js +156 -0
- package/tempoch-js/tempoch-node/lib/Period.js +133 -0
- package/tempoch-js/tempoch-node/lib/backend.js +38 -0
- package/tempoch-js/tempoch-node/lib/qttyCompat.js +92 -0
- package/tempoch-js/tempoch-node/native.cjs +317 -0
- package/tempoch-js/tempoch-node/package-lock.json +3223 -0
- package/tempoch-js/tempoch-node/package.json +56 -0
- package/tempoch-js/tempoch-node/src/lib.rs +573 -0
- package/tempoch-js/tempoch-web/Cargo.toml +23 -0
- package/tempoch-js/tempoch-web/index.d.ts +95 -0
- package/tempoch-js/tempoch-web/index.js +27 -0
- package/tempoch-js/tempoch-web/lib/JulianDate.js +170 -0
- package/tempoch-js/tempoch-web/lib/ModifiedJulianDate.js +145 -0
- package/tempoch-js/tempoch-web/lib/Period.js +121 -0
- package/tempoch-js/tempoch-web/lib/backend.js +118 -0
- package/tempoch-js/tempoch-web/package.json +46 -0
- package/tempoch-js/tempoch-web/src/lib.rs +184 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# qtty-js workspace
|
|
2
|
+
|
|
3
|
+
JavaScript and WebAssembly bindings for
|
|
4
|
+
[qtty](./qtty/README.md), the Siderust physical quantities and unit conversion
|
|
5
|
+
library.
|
|
6
|
+
|
|
7
|
+
This repository is the publishable JS workspace. It contains the npm packages,
|
|
8
|
+
the thin Rust transport layers for Node and Web, and the vendored `qtty`
|
|
9
|
+
submodule that provides the canonical conversion registry and unit model.
|
|
10
|
+
|
|
11
|
+
## Packages
|
|
12
|
+
|
|
13
|
+
| Package | Target | Status | Notes |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| [`@siderust/qtty`](./qtty-node/README.md) | Node.js | `0.1.0` | Native addon built with `napi-rs`; includes `@siderust/qtty/units` factories. |
|
|
16
|
+
| `@siderust/qtty-web` | Browsers / bundlers | `0.1.0` | WebAssembly build with `wasm-bindgen`; requires `await init()` before use. |
|
|
17
|
+
|
|
18
|
+
The Rust crates under `qtty-node/` and `qtty-web/` are transport layers only.
|
|
19
|
+
All unit metadata and conversion semantics come from the [`qtty`](./qtty)
|
|
20
|
+
submodule through `qtty-ffi`.
|
|
21
|
+
|
|
22
|
+
## Repository layout
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
qtty-js/
|
|
26
|
+
├── qtty/ Vendored Rust workspace (canonical units, FFI, docs)
|
|
27
|
+
├── qtty-node/ Node package: @siderust/qtty
|
|
28
|
+
├── qtty-web/ Browser package: @siderust/qtty-web
|
|
29
|
+
└── scripts/ CI helpers for the Node package
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## What ships in 0.1.0
|
|
33
|
+
|
|
34
|
+
- A Node package with `Quantity`, `DerivedQuantity`, conversion helpers,
|
|
35
|
+
compatibility checks, JSON-friendly serialization helpers, and a typed `Unit`
|
|
36
|
+
map.
|
|
37
|
+
- Node-side unit factories under `@siderust/qtty/units` for arithmetic-style
|
|
38
|
+
construction such as `Kilometers(3.2)` or `Degrees(180)`.
|
|
39
|
+
- A browser/WASM package exposing the same core quantity model with explicit
|
|
40
|
+
asynchronous initialization via `init()`.
|
|
41
|
+
- TypeScript declarations for both packages matching the current runtime
|
|
42
|
+
surface.
|
|
43
|
+
- Node examples, tests, and CI for format, lint, build, test, and coverage.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
### Node.js
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install @siderust/qtty
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const { Quantity, convert, Unit } = require('@siderust/qtty');
|
|
55
|
+
|
|
56
|
+
const distance = new Quantity(1500, Unit.Meter);
|
|
57
|
+
console.log(distance.to(Unit.Kilometer).value); // 1.5
|
|
58
|
+
console.log(convert(2, Unit.Hour, Unit.Minute)); // 120
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Browser / WebAssembly
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm install @siderust/qtty-web
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import { init, Quantity, Unit } from '@siderust/qtty-web';
|
|
69
|
+
|
|
70
|
+
await init();
|
|
71
|
+
|
|
72
|
+
const angle = new Quantity(180, Unit.Degree);
|
|
73
|
+
console.log(angle.to(Unit.Radian).value);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
Clone the repository with submodules so the vendored Rust workspace is present:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git clone --recurse-submodules git@github.com:Siderust/qtty-js.git
|
|
82
|
+
cd qtty-js
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
If you already cloned without submodules:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
git submodule update --init --recursive
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Node package workflow
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
cd qtty-node
|
|
95
|
+
npm ci
|
|
96
|
+
npm run build:debug
|
|
97
|
+
npm test
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The repository also exposes CI helpers:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
./scripts/ci.sh all
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Web package workflow
|
|
107
|
+
|
|
108
|
+
`qtty-web` uses `wasm-pack`:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
cd qtty-web
|
|
112
|
+
wasm-pack build --target web --out-dir pkg --release --scope siderust
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Versioning notes
|
|
116
|
+
|
|
117
|
+
The npm packages in this repository start at `0.1.0`, while the Rust transport
|
|
118
|
+
crate inside [`qtty-node`](./qtty-node/Cargo.toml) still tracks the native layer
|
|
119
|
+
version (`0.4.0`). That is intentional: the JavaScript public release line and
|
|
120
|
+
the internal Rust crate line are versioned independently.
|
|
121
|
+
|
|
122
|
+
## Related documentation
|
|
123
|
+
|
|
124
|
+
- [`qtty-node/README.md`](./qtty-node/README.md) for the Node package API and
|
|
125
|
+
examples.
|
|
126
|
+
- [`qtty/README.md`](./qtty/README.md) for the vendored Rust workspace.
|
|
127
|
+
- [`qtty/CHANGELOG.md`](./qtty/CHANGELOG.md) for backend/library changes that
|
|
128
|
+
feed these bindings.
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
AGPL-3.0. See [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "qtty-js",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Typesafe unit measurments",
|
|
5
|
+
"homepage": "https://github.com/Siderust/qtty-js#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/Siderust/qtty-js/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Siderust/qtty-js.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "AGPL-3.0-or-later",
|
|
14
|
+
"author": "VPRamon",
|
|
15
|
+
"type": "commonjs",
|
|
16
|
+
"main": "index.js",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
name: qtty CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
types: [opened, synchronize, reopened, ready_for_review]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
checks: write
|
|
12
|
+
pull-requests: write # needed to post PR comments
|
|
13
|
+
|
|
14
|
+
concurrency:
|
|
15
|
+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
16
|
+
cancel-in-progress: true
|
|
17
|
+
|
|
18
|
+
env:
|
|
19
|
+
CARGO_TERM_COLOR: always
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
check:
|
|
23
|
+
name: Check
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
28
|
+
- run: cargo check --all-targets
|
|
29
|
+
|
|
30
|
+
fmt:
|
|
31
|
+
name: Format
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
36
|
+
with:
|
|
37
|
+
components: rustfmt
|
|
38
|
+
- run: cargo fmt --check
|
|
39
|
+
|
|
40
|
+
clippy:
|
|
41
|
+
name: Clippy
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
46
|
+
with:
|
|
47
|
+
components: clippy
|
|
48
|
+
- run: cargo clippy --all-targets -- -D warnings
|
|
49
|
+
|
|
50
|
+
test:
|
|
51
|
+
name: Test
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@v4
|
|
55
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
56
|
+
- run: cargo test --all-targets
|
|
57
|
+
- run: cargo test --doc
|
|
58
|
+
|
|
59
|
+
no-cross-unit-ops:
|
|
60
|
+
name: No Cross-Unit Ops
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
steps:
|
|
63
|
+
- uses: actions/checkout@v4
|
|
64
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
65
|
+
- name: Validate conversions and eq_unit/cmp_unit in reduced mode
|
|
66
|
+
run: cargo test -p qtty-core --test core --test no_cross_unit_ops --no-default-features --features std
|
|
67
|
+
- name: Ensure direct cross-unit operators are disabled in reduced mode
|
|
68
|
+
run: |
|
|
69
|
+
tmpdir="$(mktemp -d)"
|
|
70
|
+
cat > "$tmpdir/Cargo.toml" <<EOF
|
|
71
|
+
[package]
|
|
72
|
+
name = "no-cross-unit-ops-check"
|
|
73
|
+
version = "0.0.0"
|
|
74
|
+
edition = "2021"
|
|
75
|
+
|
|
76
|
+
[dependencies]
|
|
77
|
+
qtty-core = { path = "$PWD/qtty-core", default-features = false, features = ["std"] }
|
|
78
|
+
EOF
|
|
79
|
+
mkdir -p "$tmpdir/src"
|
|
80
|
+
cat > "$tmpdir/src/main.rs" <<'EOF'
|
|
81
|
+
use qtty_core::length::{Kilometers, Meters};
|
|
82
|
+
|
|
83
|
+
fn main() {
|
|
84
|
+
let km = Kilometers::new(1.0);
|
|
85
|
+
let m = Meters::new(500.0);
|
|
86
|
+
let _ = km > m;
|
|
87
|
+
}
|
|
88
|
+
EOF
|
|
89
|
+
|
|
90
|
+
if cargo check --manifest-path "$tmpdir/Cargo.toml"; then
|
|
91
|
+
echo "cross-unit operators unexpectedly compiled with cross-unit-ops disabled"
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
coverage:
|
|
96
|
+
name: Test & Coverage
|
|
97
|
+
if: ${{ github.event_name == 'push' || github.event.pull_request.draft == false }}
|
|
98
|
+
runs-on: ubuntu-latest
|
|
99
|
+
|
|
100
|
+
steps:
|
|
101
|
+
- uses: actions/checkout@v4
|
|
102
|
+
|
|
103
|
+
- name: Set up Rust (nightly + llvm-tools)
|
|
104
|
+
uses: dtolnay/rust-toolchain@v1
|
|
105
|
+
with:
|
|
106
|
+
toolchain: nightly
|
|
107
|
+
components: llvm-tools-preview
|
|
108
|
+
|
|
109
|
+
- name: Install cargo-llvm-cov
|
|
110
|
+
uses: taiki-e/install-action@v2
|
|
111
|
+
with:
|
|
112
|
+
tool: cargo-llvm-cov
|
|
113
|
+
|
|
114
|
+
# Run tests once and collect coverage data (no report yet)
|
|
115
|
+
- name: Coverage (run, no report)
|
|
116
|
+
run: cargo +nightly llvm-cov --workspace --all-features --doctests --no-report
|
|
117
|
+
|
|
118
|
+
# Produce machine-readable + human-readable reports
|
|
119
|
+
- name: Coverage (Cobertura XML)
|
|
120
|
+
run: cargo +nightly llvm-cov report --cobertura --output-path coverage.xml
|
|
121
|
+
|
|
122
|
+
- name: Coverage (HTML)
|
|
123
|
+
run: cargo +nightly llvm-cov report --html --output-dir coverage_html
|
|
124
|
+
|
|
125
|
+
# Put a nice table + badge into the PR Checks "Summary" tab
|
|
126
|
+
- name: Build coverage summary (Markdown)
|
|
127
|
+
uses: irongut/CodeCoverageSummary@v1.3.0
|
|
128
|
+
with:
|
|
129
|
+
filename: coverage.xml
|
|
130
|
+
badge: true
|
|
131
|
+
format: markdown
|
|
132
|
+
output: file
|
|
133
|
+
|
|
134
|
+
- name: Publish to Job Summary
|
|
135
|
+
run: cat code-coverage-results.md >> "$GITHUB_STEP_SUMMARY"
|
|
136
|
+
|
|
137
|
+
- name: Post coverage as PR comment
|
|
138
|
+
if: github.event_name == 'pull_request'
|
|
139
|
+
uses: mshick/add-pr-comment@v2
|
|
140
|
+
with:
|
|
141
|
+
message-path: code-coverage-results.md
|
|
142
|
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
143
|
+
|
|
144
|
+
# Gate: fail if total LINE coverage < 95% (no extra test run needed)
|
|
145
|
+
# feature_diesel.rs requires a live SQL backend and intentionally excluded from coverage
|
|
146
|
+
- name: Coverage gate (≥95% lines)
|
|
147
|
+
run: cargo +nightly llvm-cov --workspace --all-features --doctests --no-run --ignore-filename-regex "feature_diesel" --fail-under-lines 95
|
|
148
|
+
|
|
149
|
+
- name: Upload coverage HTML
|
|
150
|
+
if: always()
|
|
151
|
+
uses: actions/upload-artifact@v4
|
|
152
|
+
with:
|
|
153
|
+
name: coverage-html
|
|
154
|
+
path: coverage_html
|
|
155
|
+
retention-days: 7
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the vendored Rust workspace are documented here.
|
|
4
|
+
|
|
5
|
+
Documentation references live under [`../doc/developers/changelog.md`](../doc/developers/changelog.md).
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## [0.4.0] - 2026-02-26
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Implemented `Display`, `LowerExp`, and `UpperExp` delegation for `Quantity<U, S>` so standard Rust format annotations (precision, scientific notation) are respected by all unit types.
|
|
12
|
+
- Exposed a new FFI function `qtty_quantity_format(qtty_quantity_t, precision, flags, buf, buf_len)` plus format flag constants `QTTY_FMT_DEFAULT`, `QTTY_FMT_LOWER_EXP`, and `QTTY_FMT_UPPER_EXP` for C consumers to format quantities from Rust with the same options as Rust's formatters.
|
|
13
|
+
- Added C++ convenience: `qtty::Quantity<UnitTag>::format(int precision, uint32_t flags)` that calls the FFI formatter, and a C++20 `std::formatter` specialization to integrate with `std::format` when available.
|
|
14
|
+
- Added comprehensive C++ tests covering streaming `operator<<`, `format()`, and scientific/precision formatting modes.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- cbindgen/header generation: `qtty-ffi` build now gracefully skips automatic cbindgen expansion on stable toolchains (nightly required for macro expansion); the shipped `qtty_ffi.h` is updated to include the new formatter API and constants.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- Corrected `Display` implementations to delegate formatting to the inner scalar so `{:.N}`, `{:e}`, and related annotations behave as expected for `Quantity` values.
|
|
21
|
+
- Adjusted C++ helpers and tests to match C++ stream precision semantics and to ensure `format()` mirrors specified precision/flags.
|
|
22
|
+
|
|
23
|
+
## [0.3.1] - 2026-02-24
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- New `qtty` crate feature `alloc` for heap-backed helpers in `no_std` builds. (see #10)
|
|
27
|
+
- Integration compile checks for `qtty::qtty_vec!` across `std`, `no_std + alloc`, and pure `no_std` modes. (see #10)
|
|
28
|
+
- New integer scalar facade modules `qtty::i8`, `qtty::i16`, and `qtty::i128`, mirroring the unit aliases available in `qtty::i32`. (see #11)
|
|
29
|
+
- New `cross-unit-ops` feature in `qtty-core` and `qtty` (enabled by default) to gate generation of direct cross-unit comparison operator impls (`==`, `<`, etc.). (see #15)
|
|
30
|
+
- New reduced-mode CI profile (`No Cross-Unit Ops`) plus targeted compile checks validating `eq_unit`/`cmp_unit` and ensuring direct cross-unit operators are disabled when the feature is off. (see #15)
|
|
31
|
+
- Documented compile-time benchmark commands (`cargo +nightly -Z timings`) for comparing default and reduced-mode builds. (see #15)
|
|
32
|
+
- FFI JSON serialization: New FFI functions for serializing and deserializing `QttyQuantity`/`QttyDerivedQuantity` to/from JSON:
|
|
33
|
+
- `qtty_quantity_to_json_value` / `qtty_quantity_from_json_value`
|
|
34
|
+
- `qtty_quantity_to_json` / `qtty_quantity_from_json`
|
|
35
|
+
- `qtty_derived_to_json` / `qtty_derived_from_json`
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [0.3.0] - 2026-02-09
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
- Added support for operations with Rust built-in numeric types, improving ergonomics when combining `Quantity` values with primitive scalars.
|
|
42
|
+
- Added `Iterator::sum` support for `Quantity`, including ergonomic accumulation into `f64` from iterators of `Quantity<_, f64>` (owned or borrowed items).
|
|
43
|
+
- Full dimensional arithmetic support using compile-time exponent math (`Dim`, `DimMul`, `DimDiv`) powered by `typenum`.
|
|
44
|
+
- New product unit type `Prod<A, B>` to represent unit multiplication (`Length * Length`, `Area * Length`, etc.).
|
|
45
|
+
- New `area` unit module with metric, land, and imperial/US units (for example `SquareMeter`, `Hectare`, `Acre`).
|
|
46
|
+
- New `volume` unit module with metric cubic units, liter-family units, and imperial/US units (for example `CubicMeter`, `Liter`, `UsGallon`).
|
|
47
|
+
- New `qtty` example `dimensional_arithmetic` demonstrating compile-time dimensional composition and conversions.
|
|
48
|
+
- `Quantity::eq_unit` and `Quantity::cmp_unit` helpers for comparing values across different units in the same dimension.
|
|
49
|
+
- Cross-unit comparison operator support (`==`, `!=`, `<`, `>`, `<=`, `>=`) via `impl_unit_conversions!`, with unit conversion applied before comparison.
|
|
50
|
+
- Expanded `qtty-core` comparison tests covering same-unit ordering, scalar ordering, cross-unit comparisons, NaN behavior, and integer `Eq`/`Ord` use cases.
|
|
51
|
+
- `Quantity::mean` helper to compute the arithmetic midpoint between two values of the same quantity type (including integer scalar support).
|
|
52
|
+
- New exported `qtty::qtty_vec!` macro for building typed quantity arrays and `Vec`s directly from scalar literals.
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
- Division and multiplication now compose dimensions generically at the type level, so multiplied quantities produce `Quantity<Prod<...>>` and can be converted to named units with `.to()`.
|
|
56
|
+
- Core/base dimensions are now unified under the new generic `Dim<...>` model, with backward-compatible aliases for `DivDim` and new `MulDim`.
|
|
57
|
+
- Public exports now include area/volume modules and additional dimension aliases from `qtty-core` and the `qtty` facade.
|
|
58
|
+
- `Quantity` ordering/equality trait implementations were refined: `PartialOrd` is now implemented explicitly (same-unit and scalar comparisons), and `Eq`/`Ord` are enabled when the scalar type supports total equality/ordering.
|
|
59
|
+
- Unit display symbols were standardized to canonical scientific notation across affected units (for example `Degree` now renders as `°`, `Radian` as `rad`, and SI symbols like `km`/`μm` are used consistently).
|
|
60
|
+
|
|
61
|
+
## [0.2.2] - 2026-01-13
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
- `qtty-core` optional `diesel` feature with `Quantity` SQL mapping, query integration, and examples.
|
|
65
|
+
- `qtty-core` optional `tiberius` feature with SQL Server `ToSql`/`FromSql` support for `Quantity`.
|
|
66
|
+
- `qtty-core` optional `pyo3` feature with `Quantity` conversions to/from Python floats.
|
|
67
|
+
- `qtty_core::serde_with_unit` helper for serializing quantities with unit symbols.
|
|
68
|
+
- New `qtty-core` tests covering core, Diesel, PyO3, Serde, and Tiberius integrations.
|
|
69
|
+
|
|
70
|
+
### Changed
|
|
71
|
+
- `qtty-core` internals split into feature-gated modules with updated docs and examples.
|
|
72
|
+
|
|
73
|
+
## [0.2.1] - 2025-12-22
|
|
74
|
+
|
|
75
|
+
### Added
|
|
76
|
+
- Optional `python` feature for `qtty-ffi` that exposes `UnitId` as a PyO3 `pyclass` with pickle support, enabling Python consumers alongside C.
|
|
77
|
+
- Generated unit symbol lookups and new `UnitId::symbol()` accessor for retrieving canonical unit symbols from FFI.
|
|
78
|
+
- Convenience APIs on `QttyQuantity` for dimension/compatibility queries, conversions, and basic arithmetic on FFI quantities.
|
|
79
|
+
- `QttyDerivedQuantity` FFI type for compound quantities (numerator/denominator) with conversion and scalar helpers (e.g., velocities).
|
|
80
|
+
|
|
81
|
+
### Changed
|
|
82
|
+
- `qtty-ffi` build tooling now emits symbol tables and uses the updated cbindgen (0.29.2) plus parser deps to support Python-aware builds.
|
|
83
|
+
|
|
84
|
+
## [0.2.0] - 2025-12-14
|
|
85
|
+
|
|
86
|
+
### Added
|
|
87
|
+
- Workspace split into crates: `qtty` (facade), `qtty-core` (types + units), `qtty-derive` (proc-macro).
|
|
88
|
+
- Feature flags: `std` (default) and optional `serde` for `Quantity<U>`.
|
|
89
|
+
- `no_std` support in `qtty-core` (uses `libm` for floating-point math not in `core`).
|
|
90
|
+
- Predefined unit modules under `qtty-core::units` (angular, time, length, mass, power, velocity, frequency, unitless).
|
|
91
|
+
- **Serde with unit information**: New `qtty_core::serde_with_unit` helper module for serializing quantities with unit symbols. Use `#[serde(with = "qtty_core::serde_with_unit")]` on fields to preserve unit information in JSON/serialized data (e.g., `{"value": 100.0, "unit": "m"}`). Includes unit validation on deserialization. Default serialization remains compact (bare `f64` value).
|
|
92
|
+
- **Length**: Extensive new SI-prefixed meter units (yoctometer through yottameter) and additional units (fathom, nautical mile, light year, parsec, etc.).
|
|
93
|
+
- **Mass**: Full SI prefix ladder for gram (yoctogram through yottagram), additional units (ton, metric ton, tonne), and nominal astronomical masses (Earth, Jupiter, Sun).
|
|
94
|
+
- **Power**: Complete SI prefix ladder for watt (yoctowatt through yottawatt), erg per second, metric horsepower, electric horsepower, and solar luminosity.
|
|
95
|
+
- **Time**: Full SI submultiples (attosecond through decisecond) and multiples (decasecond through terasecond), additional civil units (fortnight, decade, millennium), Julian conventions, and astronomical mean units (sidereal day/year, synodic month).
|
|
96
|
+
- **Velocity**: Generic `Velocity<Length, Time>` type for composing any length/time unit pair.
|
|
97
|
+
- **Frequency**: Generic `Frequency<Angle, Time>` type for composing any angle/time unit pair.
|
|
98
|
+
|
|
99
|
+
### Changed
|
|
100
|
+
- Documentation rewrite for docs.rs (crate docs, READMEs, examples).
|
|
101
|
+
- **Time module**: Canonical scaling unit changed from `Day` to `Second` (SI base unit). All time units now express ratios in seconds.
|
|
102
|
+
- **Unit symbols**: Updated for consistency (e.g., `Second::SYMBOL` changed from `"sec"` to `"s"`).
|
|
103
|
+
- **Velocity and Frequency**: Refactored to use generic parameterized types instead of specific aliases (e.g., `Velocity<Kilometer, Second>` instead of `KilometersPerSecond`).
|
|
104
|
+
- Import organization in examples for improved clarity and consistency.
|
|
105
|
+
- Conversion constants and ratios updated across all unit modules for accuracy and consistency.
|
|
106
|
+
- **Unitless refactor**: `Unitless` changed from a `pub type Unitless = f64` alias to a proper zero-sized marker type (`pub struct Unitless;`). The `Unit` impl for `Unitless` remains (`RATIO = 1.0`, `Dim = Dimensionless`, `SYMBOL = ""`) while removing the implicit `Unit` implementation for `f64`. API ergonomics preserved: `Quantity<Unitless>` display/From conversions/Simplify behavior unchanged. Updated docs, tests, and examples accordingly.
|
|
107
|
+
|
|
108
|
+
### Deprecated
|
|
109
|
+
- `define_unit!` is retained for internal use and backward compatibility; new units in `qtty-core` use `#[derive(Unit)]`.
|
|
110
|
+
- Specific velocity type aliases (e.g., `MetersPerSecond`, `KilometersPerSecond`) in favor of generic `Velocity<N, D>` type.
|
|
111
|
+
- Specific frequency type aliases (e.g., `RadiansPerSecond`, `DegreesPerDay`) in favor of generic `Frequency<N, D>` type.
|
|
112
|
+
|
|
113
|
+
### Fixed
|
|
114
|
+
- `qtty` feature flags now correctly control `qtty-core` defaults (including `no_std` builds).
|
|
115
|
+
- Improved type safety and consistency across velocity and frequency unit definitions.
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## [0.0.0] - 2025-09-01
|
|
119
|
+
|
|
120
|
+
- Migration from Siderust
|