@penner/smart-primitive 0.0.1 → 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.
Files changed (81) hide show
  1. package/README.md +215 -180
  2. package/dist/SmartPrimitive.d.ts +87 -37
  3. package/dist/SmartPrimitive.d.ts.map +1 -1
  4. package/dist/SmartPrimitive.test-d.d.ts.map +1 -0
  5. package/dist/SmartPrimitiveConfig.test-d.d.ts +2 -0
  6. package/dist/SmartPrimitiveConfig.test-d.d.ts.map +1 -0
  7. package/dist/convert.cjs.js +2 -0
  8. package/dist/convert.cjs.js.map +1 -0
  9. package/dist/convert.d.ts +136 -0
  10. package/dist/convert.d.ts.map +1 -0
  11. package/dist/convert.es.js +51 -0
  12. package/dist/convert.es.js.map +1 -0
  13. package/dist/convert.test-d.d.ts +2 -0
  14. package/dist/convert.test-d.d.ts.map +1 -0
  15. package/dist/index.cjs.js +1 -1
  16. package/dist/index.cjs.js.map +1 -1
  17. package/dist/index.d.ts +7 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.es.js +65 -2
  20. package/dist/index.es.js.map +1 -1
  21. package/dist/strings/css.d.ts +143 -0
  22. package/dist/strings/css.d.ts.map +1 -0
  23. package/dist/strings/data.d.ts +140 -0
  24. package/dist/strings/data.d.ts.map +1 -0
  25. package/dist/strings/index.cjs.js +2 -0
  26. package/dist/strings/index.cjs.js.map +1 -0
  27. package/dist/strings/index.d.ts +14 -0
  28. package/dist/strings/index.d.ts.map +1 -0
  29. package/dist/strings/index.es.js +2 -0
  30. package/dist/strings/index.es.js.map +1 -0
  31. package/dist/strings/web.d.ts +55 -0
  32. package/dist/strings/web.d.ts.map +1 -0
  33. package/dist/trait-utils.d.ts +107 -0
  34. package/dist/trait-utils.d.ts.map +1 -0
  35. package/dist/traits.d.ts +14 -0
  36. package/dist/traits.d.ts.map +1 -0
  37. package/dist/traits.examples.d.ts +7 -0
  38. package/dist/traits.examples.d.ts.map +1 -0
  39. package/dist/traits.test-d.d.ts +5 -0
  40. package/dist/traits.test-d.d.ts.map +1 -0
  41. package/dist/units/angle.d.ts +43 -0
  42. package/dist/units/angle.d.ts.map +1 -0
  43. package/dist/units/angle.test-d.d.ts +2 -0
  44. package/dist/units/angle.test-d.d.ts.map +1 -0
  45. package/dist/units/color.d.ts +35 -0
  46. package/dist/units/color.d.ts.map +1 -0
  47. package/dist/units/color.test-d.d.ts +2 -0
  48. package/dist/units/color.test-d.d.ts.map +1 -0
  49. package/dist/units/index.cjs.js +2 -0
  50. package/dist/units/index.cjs.js.map +1 -0
  51. package/dist/units/index.d.ts +19 -0
  52. package/dist/units/index.d.ts.map +1 -0
  53. package/dist/units/index.es.js +86 -0
  54. package/dist/units/index.es.js.map +1 -0
  55. package/dist/units/integer.d.ts +12 -0
  56. package/dist/units/integer.d.ts.map +1 -0
  57. package/dist/units/integer.test-d.d.ts +2 -0
  58. package/dist/units/integer.test-d.d.ts.map +1 -0
  59. package/dist/units/length.d.ts +101 -0
  60. package/dist/units/length.d.ts.map +1 -0
  61. package/dist/units/length.test-d.d.ts +2 -0
  62. package/dist/units/length.test-d.d.ts.map +1 -0
  63. package/dist/units/normalized.d.ts +111 -0
  64. package/dist/units/normalized.d.ts.map +1 -0
  65. package/dist/units/normalized.test-d.d.ts +2 -0
  66. package/dist/units/normalized.test-d.d.ts.map +1 -0
  67. package/dist/units/temperature.d.ts +16 -0
  68. package/dist/units/temperature.d.ts.map +1 -0
  69. package/dist/units/temperature.test-d.d.ts +2 -0
  70. package/dist/units/temperature.test-d.d.ts.map +1 -0
  71. package/dist/units/time.d.ts +38 -0
  72. package/dist/units/time.d.ts.map +1 -0
  73. package/dist/units/time.test-d.d.ts +2 -0
  74. package/dist/units/time.test-d.d.ts.map +1 -0
  75. package/dist/units/velocity.d.ts +78 -0
  76. package/dist/units/velocity.d.ts.map +1 -0
  77. package/dist/units/velocity.test-d.d.ts +2 -0
  78. package/dist/units/velocity.test-d.d.ts.map +1 -0
  79. package/package.json +39 -21
  80. package/dist/__tests__/SmartPrimitive.test-d.d.ts.map +0 -1
  81. /package/dist/{__tests__/SmartPrimitive.test-d.d.ts → SmartPrimitive.test-d.d.ts} +0 -0
@@ -0,0 +1,111 @@
1
+ import { WithRange, WithUnit, WithKind, WithClamped } from '../trait-utils';
2
+ /**
3
+ * A value normalized to the range [0, 1], unclamped.
4
+ * Can exceed these bounds.
5
+ */
6
+ export type Normalized = WithRange<0, 1>;
7
+ /**
8
+ * A clamped normalized value in the range [0, 1].
9
+ * Constrained to not exceed these bounds.
10
+ */
11
+ export type ClampedNormalized = Normalized & WithClamped;
12
+ /**
13
+ * A value normalized to the range [-1, 1], unclamped.
14
+ * Can exceed these bounds.
15
+ */
16
+ export type SignedNormalized = WithRange<-1, 1>;
17
+ /**
18
+ * A percentage value based on the range [0, 100], unclamped.
19
+ */
20
+ export type Percentage = WithRange<0, 100> & WithUnit<'percent'>;
21
+ /**
22
+ * An alpha/opacity value in the range [0, 1].
23
+ */
24
+ export type Alpha = WithRange<0, 1> & WithKind<'opacity'>;
25
+ /**
26
+ * A ratio value (typically positive).
27
+ */
28
+ export type Ratio = number;
29
+ /**
30
+ * A factor/multiplier value (could be positive or negative).
31
+ */
32
+ export type Factor = number;
33
+ /**
34
+ * Normalized time [0, 1] within an animation segment.
35
+ * Used as the input to easing functions (horizontal/time axis).
36
+ * STRICTLY BOUNDED to [0, 1] - cannot overshoot.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const joinTime: NormalizedTime = 0.6;
41
+ * const bezierX1: NormalizedTime = 0.42; // Bezier X coordinates use time
42
+ * ```
43
+ */
44
+ export type NormalizedTime = ClampedNormalized & WithKind<'time'>;
45
+ /**
46
+ * Normalized progress [0, 1] of an animation.
47
+ * Used as the output of easing functions (vertical/progress axis).
48
+ * CAN OVERSHOOT [0, 1] during back/elastic effects (e.g., 1.2 or -0.1).
49
+ *
50
+ * The "normalized" refers to the scale (0-1 reference), not the bounds.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const position: NormalizedProgress = 1.2; // Can overshoot
55
+ * const bezierY1: NormalizedProgress = 1.5; // Bezier Y coordinates use progress
56
+ * const restitution: NormalizedProgress = 0.8; // Ratios also use progress
57
+ * ```
58
+ */
59
+ export type NormalizedProgress = Normalized & WithKind<'progress'>;
60
+ /**
61
+ * Progress expressed as a percentage [0, 100].
62
+ * Used for API parameters and user-facing values.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const decay: PercentProgress = 90; // 90% decay
67
+ * const overshoot: PercentProgress = 30; // 30% overshoot
68
+ * ```
69
+ */
70
+ export type PercentProgress = Percentage & WithKind<'progress'>;
71
+ /** Normalized → Percentage (0-1 → 0-100) */
72
+ export declare const normalizedToPercentage: (n: Normalized) => Percentage;
73
+ /** Percentage → Normalized (0-100 → 0-1) */
74
+ export declare const percentageToNormalized: (p: Percentage) => Normalized;
75
+ /** NormalizedProgress → PercentProgress (0-1 → 0-100) */
76
+ export declare const normalizedProgressToPercent: (n: NormalizedProgress) => PercentProgress;
77
+ /** PercentProgress → NormalizedProgress (0-100 → 0-1) */
78
+ export declare const percentToNormalizedProgress: (p: PercentProgress) => NormalizedProgress;
79
+ /**
80
+ * Clamp a normalized value to [0, 1].
81
+ * NaN is clamped to 0.
82
+ * Preserves branded traits from the input type.
83
+ *
84
+ * @example
85
+ * clampNormalized(0.5) // 0.5 — in range, unchanged
86
+ * clampNormalized(1.5) // 1 — above 1
87
+ * clampNormalized(-0.5) // 0 — below 0
88
+ * clampNormalized(NaN) // 0 — NaN clamped to 0
89
+ *
90
+ * // Branded traits (e.g. from Smart Primitive) are preserved in the output type:
91
+ *
92
+ * // input is NormalizedProgress, different from NormalizedTime
93
+ * const p: NormalizedProgress = 1.2;
94
+ *
95
+ * // output is NormalizedProgress & ClampedNormalized, not just number & ClampedNormalized
96
+ * const clamped = clampNormalized(p);
97
+ */
98
+ export declare function clampNormalized<T extends number>(n: T): T & ClampedNormalized;
99
+ /**
100
+ * Clamp a normalized value to [-1, 1].
101
+ */
102
+ export declare function clampSignedNormalized(n: SignedNormalized): SignedNormalized;
103
+ /**
104
+ * Clamp a percentage value to [0, 100].
105
+ */
106
+ export declare function clampPercentage(p: Percentage): Percentage;
107
+ /**
108
+ * Clamp an alpha value to [0, 1].
109
+ */
110
+ export declare function clampAlpha(a: Alpha): Alpha;
111
+ //# sourceMappingURL=normalized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalized.d.ts","sourceRoot":"","sources":["../../src/units/normalized.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAMxB;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEzC;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAAW,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAM5B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAElE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAMhE,4CAA4C;AAC5C,eAAO,MAAM,sBAAsB,GAAI,GAAG,UAAU,KAAG,UAAqB,CAAC;AAE7E,4CAA4C;AAC5C,eAAO,MAAM,sBAAsB,GAAI,GAAG,UAAU,KAAG,UAAqB,CAAC;AAE7E,yDAAyD;AACzD,eAAO,MAAM,2BAA2B,GACtC,GAAG,kBAAkB,KACpB,eAA0B,CAAC;AAE9B,yDAAyD;AACzD,eAAO,MAAM,2BAA2B,GACtC,GAAG,eAAe,KACjB,kBAA6B,CAAC;AAMjC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAI7E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAE3E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAEzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,CAE1C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=normalized.test-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalized.test-d.d.ts","sourceRoot":"","sources":["../../src/units/normalized.test-d.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { WithUnit, WithKind } from '../trait-utils';
2
+ /**
3
+ * Temperature in Celsius.
4
+ * All temperature types share the 'temperature' kind.
5
+ */
6
+ export type Celsius = WithUnit<'celsius'> & WithKind<'temperature'>;
7
+ /**
8
+ * Temperature in Fahrenheit.
9
+ * All temperature types share the 'temperature' kind.
10
+ */
11
+ export type Fahrenheit = WithUnit<'fahrenheit'> & WithKind<'temperature'>;
12
+ /** Celsius → Fahrenheit */
13
+ export declare const celsiusToFahrenheit: (c: Celsius) => Fahrenheit;
14
+ /** Fahrenheit → Celsius */
15
+ export declare const fahrenheitToCelsius: (f: Fahrenheit) => Celsius;
16
+ //# sourceMappingURL=temperature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../src/units/temperature.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAMzD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAM1E,2BAA2B;AAC3B,eAAO,MAAM,mBAAmB,GAAI,GAAG,OAAO,KAAG,UAA8B,CAAC;AAEhF,2BAA2B;AAC3B,eAAO,MAAM,mBAAmB,GAAI,GAAG,UAAU,KAAG,OAChC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=temperature.test-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temperature.test-d.d.ts","sourceRoot":"","sources":["../../src/units/temperature.test-d.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import { WithUnit, WithKind } from '../trait-utils';
2
+ /**
3
+ * Time in seconds.
4
+ * All time types share the 'time' kind.
5
+ */
6
+ export type Seconds = WithUnit<'s'> & WithKind<'time'>;
7
+ /**
8
+ * Time in milliseconds.
9
+ * All time types share the 'time' kind.
10
+ */
11
+ export type Milliseconds = WithUnit<'ms'> & WithKind<'time'>;
12
+ /**
13
+ * Time in minutes.
14
+ * All time types share the 'time' kind.
15
+ */
16
+ export type Minutes = WithUnit<'min'> & WithKind<'time'>;
17
+ /**
18
+ * Time in hours.
19
+ * All time types share the 'time' kind.
20
+ */
21
+ export type Hours = WithUnit<'h'> & WithKind<'time'>;
22
+ /** Seconds → Milliseconds (1s = 1000ms) */
23
+ export declare const secondsToMilliseconds: (s: Seconds) => Milliseconds;
24
+ /** Milliseconds → Seconds */
25
+ export declare const millisecondsToSeconds: (ms: Milliseconds) => Seconds;
26
+ /** Minutes → Seconds (1min = 60s) */
27
+ export declare const minutesToSeconds: (m: Minutes) => Seconds;
28
+ /** Seconds → Minutes */
29
+ export declare const secondsToMinutes: (s: Seconds) => Minutes;
30
+ /** Hours → Minutes (1h = 60min) */
31
+ export declare const hoursToMinutes: (h: Hours) => Minutes;
32
+ /** Minutes → Hours */
33
+ export declare const minutesToHours: (m: Minutes) => Hours;
34
+ /** Any time unit */
35
+ export type TimeUnit = Seconds | Milliseconds | Minutes | Hours;
36
+ /** Common animation time units (seconds or milliseconds) */
37
+ export type AnimationTimeUnit = Seconds | Milliseconds;
38
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/units/time.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAMzD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AAMrD,2CAA2C;AAC3C,eAAO,MAAM,qBAAqB,GAAI,GAAG,OAAO,KAAG,YACvB,CAAC;AAE7B,6BAA6B;AAC7B,eAAO,MAAM,qBAAqB,GAAI,IAAI,YAAY,KAAG,OACjC,CAAC;AAEzB,qCAAqC;AACrC,eAAO,MAAM,gBAAgB,GAAI,GAAG,OAAO,KAAG,OAAiB,CAAC;AAEhE,wBAAwB;AACxB,eAAO,MAAM,gBAAgB,GAAI,GAAG,OAAO,KAAG,OAAiB,CAAC;AAEhE,mCAAmC;AACnC,eAAO,MAAM,cAAc,GAAI,GAAG,KAAK,KAAG,OAAiB,CAAC;AAE5D,sBAAsB;AACtB,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,KAAG,KAAe,CAAC;AAM5D,oBAAoB;AACpB,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,OAAO,GAAG,KAAK,CAAC;AAEhE,4DAA4D;AAC5D,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=time.test-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.test-d.d.ts","sourceRoot":"","sources":["../../src/units/time.test-d.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ import { WithUnit, WithKind, UnitOf, KindOf } from '../trait-utils';
2
+ import { Pixels } from './length';
3
+ import { Seconds, Milliseconds } from './time';
4
+ import { Degrees, Radians, Turns } from './angle';
5
+ import { NormalizedProgress, NormalizedTime } from './normalized';
6
+ /**
7
+ * A velocity type that dynamically combines distance and time types.
8
+ * Extracts units from both types and creates a compound unit.
9
+ *
10
+ * The kind is determined by the distance type's kind:
11
+ * - 'angle' kind → 'angular-velocity'
12
+ * - other kinds → 'velocity'
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * type PixelsPerSecond = Velocity<Pixels, Seconds>;
17
+ * // Result: number & WithUnit<'px/s'> & WithKind<'velocity'>
18
+ *
19
+ * type DegreesPerSecond = Velocity<Degrees, Seconds>;
20
+ * // Result: number & WithUnit<'deg/s'> & WithKind<'angular-velocity'>
21
+ * ```
22
+ */
23
+ export type Velocity<TDistance, TTime> = WithUnit<`${UnitOf<TDistance>}/${UnitOf<TTime>}`> & (KindOf<TDistance> extends 'angle' ? WithKind<'angular-velocity'> : WithKind<'velocity'>);
24
+ export type PixelsPerSecond = Velocity<Pixels, Seconds>;
25
+ export type PixelsPerMillisecond = Velocity<Pixels, Milliseconds>;
26
+ export type DegreesPerSecond = Velocity<Degrees, Seconds>;
27
+ export type DegreesPerMillisecond = Velocity<Degrees, Milliseconds>;
28
+ export type RadiansPerSecond = Velocity<Radians, Seconds>;
29
+ export type RadiansPerMillisecond = Velocity<Radians, Milliseconds>;
30
+ export type TurnsPerSecond = Velocity<Turns, Seconds>;
31
+ export type TurnsPerMillisecond = Velocity<Turns, Milliseconds>;
32
+ /**
33
+ * Velocity of normalized progress with respect to normalized time.
34
+ * Used for easing function derivatives (dProgress/dTime).
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const velocity: NormalizedVelocity = 2.5; // Progress changes 2.5 per time unit
39
+ * ```
40
+ */
41
+ export type NormalizedVelocity = Velocity<NormalizedProgress, NormalizedTime>;
42
+ /**
43
+ * Calculate velocity from distance and time values.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * const distance: Pixels = 100;
48
+ * const time: Seconds = 2;
49
+ * const speed = velocityFromValues(distance, time); // 50 px/s
50
+ * ```
51
+ */
52
+ export declare function velocityFromValues<TDistance, TTime>(distance: TDistance, time: TTime): Velocity<TDistance, TTime>;
53
+ /**
54
+ * Apply velocity over time to get distance.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const speed: PixelsPerSecond = 100;
59
+ * const time: Seconds = 2;
60
+ * const distance = applyVelocity(speed, time); // 200 Pixels
61
+ * ```
62
+ */
63
+ export declare function applyVelocity<TDistance, TTime>(velocity: Velocity<TDistance, TTime>, time: TTime): TDistance;
64
+ /**
65
+ * Convert velocity from per-second to per-millisecond.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * const pxPerSec: PixelsPerSecond = 1000;
70
+ * const pxPerMs = velocitySecondsToMilliseconds(pxPerSec); // 1 px/ms
71
+ * ```
72
+ */
73
+ export declare function velocitySecondsToMilliseconds<TDistance>(velocity: Velocity<TDistance, Seconds>): Velocity<TDistance, Milliseconds>;
74
+ /**
75
+ * Convert velocity from per-millisecond to per-second.
76
+ */
77
+ export declare function velocityMillisecondsToSeconds<TDistance>(velocity: Velocity<TDistance, Milliseconds>): Velocity<TDistance, Seconds>;
78
+ //# sourceMappingURL=velocity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"velocity.d.ts","sourceRoot":"","sources":["../../src/units/velocity.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMvD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,QAAQ,CAAC,SAAS,EAAE,KAAK,IACnC,QAAQ,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,GAC/C,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,OAAO,GAC9B,QAAQ,CAAC,kBAAkB,CAAC,GAC5B,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AAO9B,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACxD,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAGlE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC1D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC1D,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACpE,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACtD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAIhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEvE;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;AAM9E;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,KAAK,EACjD,QAAQ,EAAE,SAAS,EACnB,IAAI,EAAE,KAAK,GACV,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAE5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,KAAK,EAC5C,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,EACpC,IAAI,EAAE,KAAK,GACV,SAAS,CAEX;AAED;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EACrD,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,GACrC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,CAEnC;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EACrD,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,GAC1C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAE9B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=velocity.test-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"velocity.test-d.d.ts","sourceRoot":"","sources":["../../src/units/velocity.test-d.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@penner/smart-primitive",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Type-safe branded primitives with zero runtime overhead - prevent bugs by distinguishing different kinds of numbers, strings, and booleans",
5
5
  "author": "Robert Penner <robert@robertpenner.com> (https://robertpenner.com)",
6
6
  "homepage": "https://github.com/robertpenner/penner",
@@ -10,7 +10,7 @@
10
10
  "access": "public"
11
11
  },
12
12
  "engines": {
13
- "node": ">=20.17"
13
+ "node": ">=20.19.0"
14
14
  },
15
15
  "keywords": [
16
16
  "typescript",
@@ -28,6 +28,41 @@
28
28
  "module": "dist/index.es.js",
29
29
  "types": "dist/index.d.ts",
30
30
  "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.es.js",
35
+ "require": "./dist/index.cjs.js"
36
+ },
37
+ "./units": {
38
+ "types": "./dist/units/index.d.ts",
39
+ "import": "./dist/units/index.es.js",
40
+ "require": "./dist/units/index.cjs.js"
41
+ },
42
+ "./strings": {
43
+ "types": "./dist/strings/index.d.ts",
44
+ "import": "./dist/strings/index.es.js",
45
+ "require": "./dist/strings/index.cjs.js"
46
+ },
47
+ "./convert": {
48
+ "types": "./dist/convert.d.ts",
49
+ "import": "./dist/convert.es.js",
50
+ "require": "./dist/convert.cjs.js"
51
+ }
52
+ },
53
+ "typesVersions": {
54
+ "*": {
55
+ "units": [
56
+ "dist/units/index.d.ts"
57
+ ],
58
+ "strings": [
59
+ "dist/strings/index.d.ts"
60
+ ],
61
+ "convert": [
62
+ "dist/convert.d.ts"
63
+ ]
64
+ }
65
+ },
31
66
  "files": [
32
67
  "dist",
33
68
  "README.md",
@@ -39,26 +74,9 @@
39
74
  "build:types": "dts-bundle-generator --config ./dts-bundle-generator.config.ts",
40
75
  "lint:scripts": "eslint ./src --ext .ts",
41
76
  "format:scripts": "prettier ./src --write",
42
- "test": "vitest run --typecheck",
77
+ "test": "vitest run",
43
78
  "test:watch": "vitest"
44
79
  },
45
80
  "dependencies": {},
46
- "devDependencies": {
47
- "@types/node": "^22.8.1",
48
- "@typescript-eslint/eslint-plugin": "^8.11.0",
49
- "@typescript-eslint/parser": "^8.11.0",
50
- "@vitest/coverage-v8": "^3.2.2",
51
- "dts-bundle-generator": "^9.5.1",
52
- "eslint": "^9.13.0",
53
- "eslint-config-prettier": "^9.1.0",
54
- "eslint-plugin-prettier": "^5.2.1",
55
- "prettier": "^3.3.3",
56
- "tslib": "^2.8.0",
57
- "tsx": "^4.20.3",
58
- "typescript": "^5.8.3",
59
- "vite": "^5.4.10",
60
- "vite-plugin-dts": "^4.3.0",
61
- "vite-tsconfig-paths": "^5.1.4",
62
- "vitest": "^3.2.2"
63
- }
81
+ "devDependencies": {}
64
82
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"SmartPrimitive.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/SmartPrimitive.test-d.ts"],"names":[],"mappings":""}