@flighthq/easing 0.3.0-next.1220.6982c21 → 0.3.0-next.1272.222de94
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/dist/easeSteps.d.ts +2 -1
- package/dist/easeSteps.d.ts.map +1 -1
- package/dist/easeSteps.js +15 -4
- package/dist/easeSteps.js.map +1 -1
- package/package.json +2 -2
- package/src/easeStepsGuard.test.ts +34 -0
package/dist/easeSteps.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { EasingFunction, StepPosition } from '@flighthq/types/contract';
|
|
1
|
+
import type { EasingFunction, EasingStepsGuard, StepPosition } from '@flighthq/types/contract';
|
|
2
2
|
export declare function easeSteps(count: number, position?: StepPosition): EasingFunction;
|
|
3
|
+
export declare function setEasingStepsGuard(guard: EasingStepsGuard | null): void;
|
|
3
4
|
//# sourceMappingURL=easeSteps.d.ts.map
|
package/dist/easeSteps.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"easeSteps.d.ts","sourceRoot":"","sources":["../src/easeSteps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"easeSteps.d.ts","sourceRoot":"","sources":["../src/easeSteps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAe/F,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,YAAwB,GAAG,cAAc,CAe3F;AAMD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAExE"}
|
package/dist/easeSteps.js
CHANGED
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
// jumpBoth - jump at both edges; count+1 levels from 0 to 1 inclusive.
|
|
7
7
|
// Follows the CSS Easing Level 1 step algorithm.
|
|
8
8
|
//
|
|
9
|
-
// Sharp edge: easeSteps(1, 'jumpNone') has jumps = count - 1 = 0, so the returned
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
9
|
+
// Sharp edge: easeSteps(1, 'jumpNone') has jumps = count - 1 = 0, so the returned function divides by
|
|
10
|
+
// zero and yields NaN for every input. This mirrors the CSS spec, which forbids steps(1, jump-none) for
|
|
11
|
+
// the same reason; `count >= 2` is required with 'jumpNone', while every other position is well-defined
|
|
12
|
+
// for count >= 1. The failure is SILENT — NaN propagates into whatever the easing drives — so the
|
|
13
|
+
// degenerate call routes through the guard seam below, which enableEasingGuards turns into a warning.
|
|
13
14
|
export function easeSteps(count, position = 'jumpEnd') {
|
|
15
|
+
if (position === 'jumpNone' && count < 2)
|
|
16
|
+
_stepsGuard?.(count, position);
|
|
14
17
|
const jumps = position === 'jumpNone' ? count - 1 : position === 'jumpBoth' ? count + 1 : count;
|
|
15
18
|
const startOffset = position === 'jumpStart' || position === 'jumpBoth' ? 1 : 0;
|
|
16
19
|
return (t) => {
|
|
@@ -24,4 +27,12 @@ export function easeSteps(count, position = 'jumpEnd') {
|
|
|
24
27
|
return step / jumps;
|
|
25
28
|
};
|
|
26
29
|
}
|
|
30
|
+
// The diagnostics seam for the degenerate `easeSteps` call, not the caller-facing entry point — use
|
|
31
|
+
// `enableEasingGuards`, which installs the @flighthq/log reporter through here. Null uninstalls it, and a
|
|
32
|
+
// null slot is what production sees: the check above is one comparison and the message text plus the
|
|
33
|
+
// @flighthq/log dependency live only in the separately-imported guard module.
|
|
34
|
+
export function setEasingStepsGuard(guard) {
|
|
35
|
+
_stepsGuard = guard;
|
|
36
|
+
}
|
|
37
|
+
let _stepsGuard = null;
|
|
27
38
|
//# sourceMappingURL=easeSteps.js.map
|
package/dist/easeSteps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"easeSteps.js","sourceRoot":"","s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C;QACD,OAAO,IAAI,GAAG,KAAK,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,0GAA0G;AAC1G,qGAAqG;AACrG,8EAA8E;AAC9E,MAAM,UAAU,mBAAmB,CAAC,KAA8B;IAChE,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC;AAED,IAAI,WAAW,GAA4B,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/easing",
|
|
3
|
-
"version": "0.3.0-next.
|
|
3
|
+
"version": "0.3.0-next.1272.222de94",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@flighthq/types": "0.3.0-next.
|
|
39
|
+
"@flighthq/types": "0.3.0-next.1272.222de94"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"typescript": "^5.3.0"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { StepPosition } from '@flighthq/types/contract';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { easeSteps, setEasingStepsGuard } from './easeSteps';
|
|
5
|
+
|
|
6
|
+
describe('setEasingStepsGuard', () => {
|
|
7
|
+
it('reports the degenerate jumpNone call that silently returns NaN', () => {
|
|
8
|
+
const seen: [number, StepPosition][] = [];
|
|
9
|
+
setEasingStepsGuard((count, position) => seen.push([count, position]));
|
|
10
|
+
try {
|
|
11
|
+
// The failure being reported: one step with no edge jump leaves zero jumps to divide by.
|
|
12
|
+
expect(Number.isNaN(easeSteps(1, 'jumpNone')(0.5))).toBe(true);
|
|
13
|
+
} finally {
|
|
14
|
+
setEasingStepsGuard(null);
|
|
15
|
+
}
|
|
16
|
+
expect(seen).toEqual([[1, 'jumpNone']]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('stays silent for well-defined calls, and when no guard is installed', () => {
|
|
20
|
+
const seen: number[] = [];
|
|
21
|
+
setEasingStepsGuard((count) => seen.push(count));
|
|
22
|
+
try {
|
|
23
|
+
easeSteps(2, 'jumpNone')(0.5); // count >= 2 is the documented minimum for jumpNone
|
|
24
|
+
easeSteps(1, 'jumpEnd')(0.5); // every edge-jumping position is defined for count >= 1
|
|
25
|
+
easeSteps(1, 'jumpStart')(0.5);
|
|
26
|
+
easeSteps(1, 'jumpBoth')(0.5);
|
|
27
|
+
} finally {
|
|
28
|
+
setEasingStepsGuard(null);
|
|
29
|
+
}
|
|
30
|
+
expect(seen).toEqual([]);
|
|
31
|
+
// Production default: still NaN, but nothing is reported.
|
|
32
|
+
expect(Number.isNaN(easeSteps(1, 'jumpNone')(0.5))).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
});
|