@flighthq/spring 0.5.1-edge.1471.4e82419 → 0.5.1-edge.1685.dc0e23a
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/README.md +2 -2
- package/dist/contract.d.ts +0 -1
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +0 -1
- package/dist/contract.js.map +1 -1
- package/dist/springConfig.d.ts +3 -5
- package/dist/springConfig.d.ts.map +1 -1
- package/dist/springConfig.js +12 -37
- package/dist/springConfig.js.map +1 -1
- package/package.json +4 -4
- package/src/springConfig.test.ts +0 -13
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/spring`. The `@fligh
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/spring@0.5.1-edge.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/spring@0.5.1-edge.1685.dc0e23a](https://github.com/flighthq/flight/tree/dc0e23a17453ec75c20ccbf07058a57b5ef10c4c/packages/spring)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/dc0e23a17453ec75c20ccbf07058a57b5ef10c4c/LICENSE.md)
|
package/dist/contract.d.ts
CHANGED
|
@@ -5,5 +5,4 @@ export * from './springConfig';
|
|
|
5
5
|
export { initializeSpring3D } from './spring3D';
|
|
6
6
|
export { initializeSpring2D } from './spring2D';
|
|
7
7
|
export { initializeSpring } from './spring';
|
|
8
|
-
export { initializeSpringConfig, initializeSpringConfigFromPhysical } from './springConfig';
|
|
9
8
|
//# sourceMappingURL=contract.d.ts.map
|
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/contract.js
CHANGED
|
@@ -5,5 +5,4 @@ export * from './springConfig';
|
|
|
5
5
|
export { initializeSpring3D } from './spring3D';
|
|
6
6
|
export { initializeSpring2D } from './spring2D';
|
|
7
7
|
export { initializeSpring } from './spring';
|
|
8
|
-
export { initializeSpringConfig, initializeSpringConfigFromPhysical } from './springConfig';
|
|
9
8
|
//# sourceMappingURL=contract.js.map
|
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/springConfig.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NonEntityCreateResult, SpringConfig } from '@flighthq/types/contract';
|
|
2
2
|
export declare const SpringPresetBouncy: Readonly<SpringConfig>;
|
|
3
3
|
export declare const SpringPresetGentle: Readonly<SpringConfig>;
|
|
4
4
|
export declare const SpringPresetStiff: Readonly<SpringConfig>;
|
|
5
|
-
export declare function createSpringConfig(frequency: number, dampingRatio: number): SpringConfig
|
|
6
|
-
export declare function createSpringConfigFromPhysical(stiffness: number, damping: number, mass: number): SpringConfig
|
|
7
|
-
export declare function initializeSpringConfig(out: EntityConstruction<SpringConfig>, frequency: number, dampingRatio: number): void;
|
|
8
|
-
export declare function initializeSpringConfigFromPhysical(out: EntityConstruction<SpringConfig>, stiffness: number, damping: number, mass: number): void;
|
|
5
|
+
export declare function createSpringConfig(frequency: number, dampingRatio: number): NonEntityCreateResult<SpringConfig, 'options'>;
|
|
6
|
+
export declare function createSpringConfigFromPhysical(stiffness: number, damping: number, mass: number): NonEntityCreateResult<SpringConfig, 'options'>;
|
|
9
7
|
//# sourceMappingURL=springConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"springConfig.d.ts","sourceRoot":"","sources":["../src/springConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"springConfig.d.ts","sourceRoot":"","sources":["../src/springConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIpF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,YAAY,CAAuD,CAAC;AAG9G,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,YAAY,CAAwD,CAAC;AAG/G,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,YAAY,CAAoD,CAAC;AAK1G,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,qBAAqB,CAAC,YAAY,EAAE,SAAS,CAAC,CAEhD;AAMD,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACX,qBAAqB,CAAC,YAAY,EAAE,SAAS,CAAC,CAKhD"}
|
package/dist/springConfig.js
CHANGED
|
@@ -1,50 +1,25 @@
|
|
|
1
|
-
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
1
|
import { TAU } from '@flighthq/math/contract';
|
|
3
2
|
// Frozen plain-data presets: spread one into a mutable object to customize it without changing the
|
|
4
3
|
// shared profile. Bouncy is quick and underdamped for visible overshoot.
|
|
5
|
-
export const SpringPresetBouncy = Object.freeze(
|
|
6
|
-
const out = allocateEntity();
|
|
7
|
-
out.dampingRatio = 0.35;
|
|
8
|
-
out.frequency = 2;
|
|
9
|
-
return finishEntity(out);
|
|
10
|
-
})());
|
|
4
|
+
export const SpringPresetBouncy = Object.freeze({ dampingRatio: 0.35, frequency: 2 });
|
|
11
5
|
// A slower, well-damped profile for soft UI movement with only a restrained overshoot.
|
|
12
|
-
export const SpringPresetGentle = Object.freeze(
|
|
13
|
-
const out = allocateEntity();
|
|
14
|
-
out.dampingRatio = 0.8;
|
|
15
|
-
out.frequency = 1.5;
|
|
16
|
-
return finishEntity(out);
|
|
17
|
-
})());
|
|
6
|
+
export const SpringPresetGentle = Object.freeze({ dampingRatio: 0.8, frequency: 1.5 });
|
|
18
7
|
// A high-frequency critical profile for a fast response without overshoot.
|
|
19
|
-
export const SpringPresetStiff = Object.freeze(
|
|
20
|
-
|
|
21
|
-
out.dampingRatio = 1;
|
|
22
|
-
out.frequency = 4;
|
|
23
|
-
return finishEntity(out);
|
|
24
|
-
})());
|
|
25
|
-
export function createSpringConfig(frequency, dampingRatio) {
|
|
26
|
-
const out = allocateEntity();
|
|
27
|
-
initializeSpringConfig(out, frequency, dampingRatio);
|
|
28
|
-
return finishEntity(out);
|
|
29
|
-
}
|
|
30
|
-
export function createSpringConfigFromPhysical(stiffness, damping, mass) {
|
|
31
|
-
const out = allocateEntity();
|
|
32
|
-
initializeSpringConfigFromPhysical(out, stiffness, damping, mass);
|
|
33
|
-
return finishEntity(out);
|
|
34
|
-
}
|
|
35
|
-
// Allocate a `SpringConfig` from the designer-intuitive `frequency` (Hz) and `dampingRatio`
|
|
8
|
+
export const SpringPresetStiff = Object.freeze({ dampingRatio: 1, frequency: 4 });
|
|
9
|
+
// Builds a `SpringConfig` from the designer-intuitive `frequency` (Hz) and `dampingRatio`
|
|
36
10
|
// (0 undamped, <1 underdamped/overshoots, 1 critical/fastest-no-overshoot, >1 overdamped). This is
|
|
37
11
|
// the primary constructor; use `createSpringConfigFromPhysical` when starting from raw physics.
|
|
38
|
-
export function
|
|
39
|
-
|
|
40
|
-
out.frequency = frequency;
|
|
12
|
+
export function createSpringConfig(frequency, dampingRatio) {
|
|
13
|
+
return { dampingRatio, frequency };
|
|
41
14
|
}
|
|
42
|
-
//
|
|
15
|
+
// Builds a `SpringConfig` from a physical spring: `stiffness` (k), `damping` (c), and `mass` (m).
|
|
43
16
|
// Converts to the mass-independent form via `frequency = sqrt(k / m) / (2 * PI)` and
|
|
44
17
|
// `dampingRatio = c / (2 * sqrt(k * m))`, the standard undamped-natural-frequency and
|
|
45
18
|
// damping-ratio identities. Expects positive `stiffness` and `mass`.
|
|
46
|
-
export function
|
|
47
|
-
|
|
48
|
-
|
|
19
|
+
export function createSpringConfigFromPhysical(stiffness, damping, mass) {
|
|
20
|
+
return {
|
|
21
|
+
dampingRatio: damping / (2 * Math.sqrt(stiffness * mass)),
|
|
22
|
+
frequency: Math.sqrt(stiffness / mass) / TAU,
|
|
23
|
+
};
|
|
49
24
|
}
|
|
50
25
|
//# sourceMappingURL=springConfig.js.map
|
package/dist/springConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"springConfig.js","sourceRoot":"","sources":["../src/springConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"springConfig.js","sourceRoot":"","sources":["../src/springConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAG9C,mGAAmG;AACnG,yEAAyE;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAA2B,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AAE9G,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAA2B,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;AAE/G,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAA2B,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;AAE1G,0FAA0F;AAC1F,mGAAmG;AACnG,gGAAgG;AAChG,MAAM,UAAU,kBAAkB,CAChC,SAAiB,EACjB,YAAoB;IAEpB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AACrC,CAAC;AAED,kGAAkG;AAClG,qFAAqF;AACrF,sFAAsF;AACtF,qEAAqE;AACrE,MAAM,UAAU,8BAA8B,CAC5C,SAAiB,EACjB,OAAe,EACf,IAAY;IAEZ,OAAO;QACL,YAAY,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;QACzD,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,GAAG;KAC7C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/spring",
|
|
3
|
-
"version": "0.5.1-edge.
|
|
3
|
+
"version": "0.5.1-edge.1685.dc0e23a",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-edge.
|
|
42
|
-
"@flighthq/math": "0.5.1-edge.
|
|
43
|
-
"@flighthq/types": "0.5.1-edge.
|
|
41
|
+
"@flighthq/entity": "0.5.1-edge.1685.dc0e23a",
|
|
42
|
+
"@flighthq/math": "0.5.1-edge.1685.dc0e23a",
|
|
43
|
+
"@flighthq/types": "0.5.1-edge.1685.dc0e23a"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^5.3.0"
|
package/src/springConfig.test.ts
CHANGED
|
@@ -7,8 +7,6 @@ import {
|
|
|
7
7
|
SpringPresetStiff,
|
|
8
8
|
createSpringConfig,
|
|
9
9
|
createSpringConfigFromPhysical,
|
|
10
|
-
initializeSpringConfig,
|
|
11
|
-
initializeSpringConfigFromPhysical,
|
|
12
10
|
} from './springConfig';
|
|
13
11
|
|
|
14
12
|
describe('createSpringConfig', () => {
|
|
@@ -34,17 +32,6 @@ describe('createSpringConfigFromPhysical', () => {
|
|
|
34
32
|
});
|
|
35
33
|
});
|
|
36
34
|
|
|
37
|
-
describe('initializeSpringConfig', () => {
|
|
38
|
-
it('is the construction initializer of createSpringConfig', () => {
|
|
39
|
-
expect(typeof initializeSpringConfig).toBe('function');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe('initializeSpringConfigFromPhysical', () => {
|
|
43
|
-
it('is the construction initializer of createSpringConfigFromPhysical', () => {
|
|
44
|
-
expect(typeof initializeSpringConfigFromPhysical).toBe('function');
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
35
|
describe('spring presets', () => {
|
|
49
36
|
it('exports frozen plain-data configs that can be customized by spreading', () => {
|
|
50
37
|
expect(Object.isFrozen(SpringPresetBouncy)).toBe(true);
|