tensum 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/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/README.md +340 -0
- package/dist/coupled-system.d.ts +50 -0
- package/dist/coupled-system.d.ts.map +1 -0
- package/dist/coupled-system.js +269 -0
- package/dist/coupled-system.js.map +1 -0
- package/dist/coupled.d.ts +3 -0
- package/dist/coupled.d.ts.map +1 -0
- package/dist/coupled.js +2 -0
- package/dist/coupled.js.map +1 -0
- package/dist/css-linear.d.ts +20 -0
- package/dist/css-linear.d.ts.map +1 -0
- package/dist/css-linear.js +95 -0
- package/dist/css-linear.js.map +1 -0
- package/dist/css.d.ts +3 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/css.js +2 -0
- package/dist/css.js.map +1 -0
- package/dist/gsap/active-tracks.d.ts +32 -0
- package/dist/gsap/active-tracks.d.ts.map +1 -0
- package/dist/gsap/active-tracks.js +177 -0
- package/dist/gsap/active-tracks.js.map +1 -0
- package/dist/gsap/gsap-time.d.ts +10 -0
- package/dist/gsap/gsap-time.d.ts.map +1 -0
- package/dist/gsap/gsap-time.js +62 -0
- package/dist/gsap/gsap-time.js.map +1 -0
- package/dist/gsap/plugin-tween-coordinator.d.ts +30 -0
- package/dist/gsap/plugin-tween-coordinator.d.ts.map +1 -0
- package/dist/gsap/plugin-tween-coordinator.js +72 -0
- package/dist/gsap/plugin-tween-coordinator.js.map +1 -0
- package/dist/gsap/plugin.d.ts +84 -0
- package/dist/gsap/plugin.d.ts.map +1 -0
- package/dist/gsap/plugin.js +552 -0
- package/dist/gsap/plugin.js.map +1 -0
- package/dist/gsap/spring-to.d.ts +93 -0
- package/dist/gsap/spring-to.d.ts.map +1 -0
- package/dist/gsap/spring-to.js +569 -0
- package/dist/gsap/spring-to.js.map +1 -0
- package/dist/gsap/spring-track-policy.d.ts +24 -0
- package/dist/gsap/spring-track-policy.d.ts.map +1 -0
- package/dist/gsap/spring-track-policy.js +76 -0
- package/dist/gsap/spring-track-policy.js.map +1 -0
- package/dist/gsap/track-lifecycle.d.ts +16 -0
- package/dist/gsap/track-lifecycle.d.ts.map +1 -0
- package/dist/gsap/track-lifecycle.js +33 -0
- package/dist/gsap/track-lifecycle.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/math.d.ts +9 -0
- package/dist/math.d.ts.map +1 -0
- package/dist/math.js +38 -0
- package/dist/math.js.map +1 -0
- package/dist/model.d.ts +14 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +38 -0
- package/dist/model.js.map +1 -0
- package/dist/motion-compatibility.d.ts +18 -0
- package/dist/motion-compatibility.d.ts.map +1 -0
- package/dist/motion-compatibility.js +83 -0
- package/dist/motion-compatibility.js.map +1 -0
- package/dist/parameters.d.ts +52 -0
- package/dist/parameters.d.ts.map +1 -0
- package/dist/parameters.js +124 -0
- package/dist/parameters.js.map +1 -0
- package/dist/settling.d.ts +12 -0
- package/dist/settling.d.ts.map +1 -0
- package/dist/settling.js +107 -0
- package/dist/settling.js.map +1 -0
- package/dist/solver.d.ts +17 -0
- package/dist/solver.d.ts.map +1 -0
- package/dist/solver.js +190 -0
- package/dist/solver.js.map +1 -0
- package/dist/spring.d.ts +9 -0
- package/dist/spring.d.ts.map +1 -0
- package/dist/spring.js +91 -0
- package/dist/spring.js.map +1 -0
- package/dist/support/additive-spring-value.d.ts +39 -0
- package/dist/support/additive-spring-value.d.ts.map +1 -0
- package/dist/support/additive-spring-value.js +281 -0
- package/dist/support/additive-spring-value.js.map +1 -0
- package/dist/support/inertia.d.ts +34 -0
- package/dist/support/inertia.d.ts.map +1 -0
- package/dist/support/inertia.js +293 -0
- package/dist/support/inertia.js.map +1 -0
- package/dist/support/keyframes.d.ts +34 -0
- package/dist/support/keyframes.d.ts.map +1 -0
- package/dist/support/keyframes.js +117 -0
- package/dist/support/keyframes.js.map +1 -0
- package/dist/support/spring-value.d.ts +38 -0
- package/dist/support/spring-value.d.ts.map +1 -0
- package/dist/support/spring-value.js +289 -0
- package/dist/support/spring-value.js.map +1 -0
- package/dist/support/velocity.d.ts +14 -0
- package/dist/support/velocity.d.ts.map +1 -0
- package/dist/support/velocity.js +75 -0
- package/dist/support/velocity.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vector.d.ts +32 -0
- package/dist/vector.d.ts.map +1 -0
- package/dist/vector.js +121 -0
- package/dist/vector.js.map +1 -0
- package/package.json +68 -0
- package/src/coupled-system.ts +383 -0
- package/src/coupled.ts +10 -0
- package/src/css-linear.ts +148 -0
- package/src/css.ts +6 -0
- package/src/gsap/active-tracks.ts +244 -0
- package/src/gsap/gsap-time.ts +91 -0
- package/src/gsap/plugin-tween-coordinator.ts +112 -0
- package/src/gsap/plugin.ts +861 -0
- package/src/gsap/spring-to.ts +836 -0
- package/src/gsap/spring-track-policy.ts +133 -0
- package/src/gsap/track-lifecycle.ts +53 -0
- package/src/index.ts +130 -0
- package/src/math.ts +46 -0
- package/src/model.ts +70 -0
- package/src/motion-compatibility.ts +131 -0
- package/src/parameters.ts +226 -0
- package/src/settling.ts +141 -0
- package/src/solver.ts +262 -0
- package/src/spring.ts +119 -0
- package/src/support/additive-spring-value.ts +343 -0
- package/src/support/inertia.ts +367 -0
- package/src/support/keyframes.ts +188 -0
- package/src/support/spring-value.ts +399 -0
- package/src/support/velocity.ts +119 -0
- package/src/types.ts +70 -0
- package/src/vector.ts +191 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface SpringParameters {
|
|
2
|
+
mass: number;
|
|
3
|
+
stiffness: number;
|
|
4
|
+
damping: number;
|
|
5
|
+
}
|
|
6
|
+
export interface SpringState {
|
|
7
|
+
position: number;
|
|
8
|
+
velocity: number;
|
|
9
|
+
}
|
|
10
|
+
export interface SpringInitialState extends SpringState {
|
|
11
|
+
target: number;
|
|
12
|
+
}
|
|
13
|
+
export interface SpringSettlingOptions {
|
|
14
|
+
positionEpsilon: number;
|
|
15
|
+
velocityEpsilon: number;
|
|
16
|
+
maxDuration: number;
|
|
17
|
+
refinementIterations: number;
|
|
18
|
+
}
|
|
19
|
+
export interface SpringSettleInput {
|
|
20
|
+
position?: number;
|
|
21
|
+
velocity?: number;
|
|
22
|
+
maxDuration?: number;
|
|
23
|
+
refinementIterations?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface SpringTimingInput {
|
|
26
|
+
perceptualDuration?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface SpringTiming {
|
|
29
|
+
perceptualDuration: number;
|
|
30
|
+
settlingDuration: number;
|
|
31
|
+
settled: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type SpringRegime = 'underdamped' | 'critical' | 'overdamped';
|
|
34
|
+
export interface SpringOptions extends SpringParameters {
|
|
35
|
+
from: number;
|
|
36
|
+
to: number;
|
|
37
|
+
velocity?: number;
|
|
38
|
+
settle?: SpringSettleInput;
|
|
39
|
+
timing?: SpringTimingInput;
|
|
40
|
+
}
|
|
41
|
+
export interface SettlingResult {
|
|
42
|
+
duration: number;
|
|
43
|
+
iterations: number;
|
|
44
|
+
settled: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface SpringSolution {
|
|
47
|
+
readonly dampingRatio: number;
|
|
48
|
+
readonly angularFrequency: number;
|
|
49
|
+
readonly regime: SpringRegime;
|
|
50
|
+
readonly parameters: Readonly<SpringParameters>;
|
|
51
|
+
readonly initialState: Readonly<SpringInitialState>;
|
|
52
|
+
readonly settling: Readonly<SpringSettlingOptions>;
|
|
53
|
+
readonly timing: Readonly<SpringTiming>;
|
|
54
|
+
positionAt(time: number): number;
|
|
55
|
+
velocityAt(time: number): number;
|
|
56
|
+
stateAt(time: number): SpringState;
|
|
57
|
+
getSettlingDuration(): number;
|
|
58
|
+
getSettlingResult(): SettlingResult;
|
|
59
|
+
retarget(target: number, time: number): SpringSolution;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,UAAU,GAAG,YAAY,CAAC;AAErE,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAChD,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IACpD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IACnC,mBAAmB,IAAI,MAAM,CAAC;IAC9B,iBAAiB,IAAI,cAAc,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC;CACxD"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/vector.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SettlingResult, SpringParameters, SpringSettleInput, SpringSolution, SpringTiming, SpringTimingInput } from './types.js';
|
|
2
|
+
export interface VectorSpringOptions {
|
|
3
|
+
from: readonly number[];
|
|
4
|
+
to: readonly number[];
|
|
5
|
+
velocity?: readonly number[];
|
|
6
|
+
parameters: SpringParameters;
|
|
7
|
+
settle?: SpringSettleInput | readonly SpringSettleInput[];
|
|
8
|
+
timing?: SpringTimingInput;
|
|
9
|
+
}
|
|
10
|
+
export interface VectorSpringState {
|
|
11
|
+
position: readonly number[];
|
|
12
|
+
velocity: readonly number[];
|
|
13
|
+
}
|
|
14
|
+
export interface MutableVectorSpringState {
|
|
15
|
+
position: number[];
|
|
16
|
+
velocity: number[];
|
|
17
|
+
}
|
|
18
|
+
export interface VectorSpringSolution {
|
|
19
|
+
readonly dimension: number;
|
|
20
|
+
readonly springs: readonly SpringSolution[];
|
|
21
|
+
readonly timing: Readonly<SpringTiming>;
|
|
22
|
+
readonly settlingResults: readonly Readonly<SettlingResult>[];
|
|
23
|
+
positionAt(time: number): readonly number[];
|
|
24
|
+
velocityAt(time: number): readonly number[];
|
|
25
|
+
stateAt(time: number): VectorSpringState;
|
|
26
|
+
stateAtInto(time: number, output: MutableVectorSpringState): MutableVectorSpringState;
|
|
27
|
+
getSettlingDuration(): number;
|
|
28
|
+
getSettlingResult(): SettlingResult;
|
|
29
|
+
retarget(target: readonly number[], time: number): VectorSpringSolution;
|
|
30
|
+
}
|
|
31
|
+
export declare function createVectorSpring(options: VectorSpringOptions): VectorSpringSolution;
|
|
32
|
+
//# sourceMappingURL=vector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../src/vector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EAEd,YAAY,EACZ,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,SAAS,MAAM,EAA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math.js';
|
|
2
|
+
import { createSpring } from './spring.js';
|
|
3
|
+
function assertDimension(name, value, dimension) {
|
|
4
|
+
if (value.length !== dimension) {
|
|
5
|
+
throw new RangeError(`${name} must contain exactly ${dimension} components`);
|
|
6
|
+
}
|
|
7
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
8
|
+
assertFinite(`${name}[${index}]`, value[index]);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function settleFor(settle, index) {
|
|
12
|
+
if (Array.isArray(settle)) {
|
|
13
|
+
return settle[index];
|
|
14
|
+
}
|
|
15
|
+
return settle;
|
|
16
|
+
}
|
|
17
|
+
function resolvedSettleFor(spring) {
|
|
18
|
+
return {
|
|
19
|
+
position: spring.settling.positionEpsilon,
|
|
20
|
+
velocity: spring.settling.velocityEpsilon,
|
|
21
|
+
maxDuration: spring.settling.maxDuration,
|
|
22
|
+
refinementIterations: spring.settling.refinementIterations,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function createVectorSpring(options) {
|
|
26
|
+
const dimension = options.from.length;
|
|
27
|
+
if (dimension === 0) {
|
|
28
|
+
throw new RangeError('vector springs require at least one component');
|
|
29
|
+
}
|
|
30
|
+
assertDimension('from', options.from, dimension);
|
|
31
|
+
assertDimension('to', options.to, dimension);
|
|
32
|
+
if (options.velocity !== undefined) {
|
|
33
|
+
assertDimension('velocity', options.velocity, dimension);
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(options.settle) && options.settle.length !== dimension) {
|
|
36
|
+
throw new RangeError(`settle must contain exactly ${dimension} component options`);
|
|
37
|
+
}
|
|
38
|
+
const springs = Object.freeze(Array.from({ length: dimension }, (_, index) => {
|
|
39
|
+
const settle = settleFor(options.settle, index);
|
|
40
|
+
return createSpring({
|
|
41
|
+
from: options.from[index],
|
|
42
|
+
to: options.to[index],
|
|
43
|
+
velocity: options.velocity === undefined ? 0 : options.velocity[index],
|
|
44
|
+
...options.parameters,
|
|
45
|
+
...(settle === undefined ? {} : { settle }),
|
|
46
|
+
...(options.timing === undefined ? {} : { timing: options.timing }),
|
|
47
|
+
});
|
|
48
|
+
}));
|
|
49
|
+
const settlingResults = Object.freeze(springs.map((spring) => Object.freeze(spring.getSettlingResult())));
|
|
50
|
+
const parameterSnapshot = springs[0].parameters;
|
|
51
|
+
const timingSnapshot = Object.freeze({
|
|
52
|
+
perceptualDuration: springs[0].timing.perceptualDuration,
|
|
53
|
+
});
|
|
54
|
+
const duration = Math.max(...settlingResults.map((result) => result.duration));
|
|
55
|
+
const settled = settlingResults.every((result) => result.settled);
|
|
56
|
+
const timing = Object.freeze({
|
|
57
|
+
perceptualDuration: Math.max(...springs.map((spring) => spring.timing.perceptualDuration)),
|
|
58
|
+
settlingDuration: duration,
|
|
59
|
+
settled,
|
|
60
|
+
});
|
|
61
|
+
const stateAtInto = (time, output) => {
|
|
62
|
+
if (output.position.length < dimension || output.velocity.length < dimension) {
|
|
63
|
+
throw new RangeError(`output buffers must contain at least ${dimension} components`);
|
|
64
|
+
}
|
|
65
|
+
for (let index = 0; index < dimension; index += 1) {
|
|
66
|
+
const state = springs[index].stateAt(time);
|
|
67
|
+
output.position[index] = state.position;
|
|
68
|
+
output.velocity[index] = state.velocity;
|
|
69
|
+
}
|
|
70
|
+
return output;
|
|
71
|
+
};
|
|
72
|
+
return Object.freeze({
|
|
73
|
+
dimension,
|
|
74
|
+
springs,
|
|
75
|
+
timing,
|
|
76
|
+
settlingResults,
|
|
77
|
+
positionAt(time) {
|
|
78
|
+
return Object.freeze(springs.map((spring) => spring.positionAt(time)));
|
|
79
|
+
},
|
|
80
|
+
velocityAt(time) {
|
|
81
|
+
return Object.freeze(springs.map((spring) => spring.velocityAt(time)));
|
|
82
|
+
},
|
|
83
|
+
stateAt(time) {
|
|
84
|
+
const output = stateAtInto(time, {
|
|
85
|
+
position: Array(dimension),
|
|
86
|
+
velocity: Array(dimension),
|
|
87
|
+
});
|
|
88
|
+
return Object.freeze({
|
|
89
|
+
position: Object.freeze(output.position),
|
|
90
|
+
velocity: Object.freeze(output.velocity),
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
stateAtInto,
|
|
94
|
+
getSettlingDuration() {
|
|
95
|
+
return duration;
|
|
96
|
+
},
|
|
97
|
+
getSettlingResult() {
|
|
98
|
+
return {
|
|
99
|
+
duration,
|
|
100
|
+
iterations: settlingResults.reduce((total, result) => total + result.iterations, 0),
|
|
101
|
+
settled,
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
retarget(target, time) {
|
|
105
|
+
assertDimension('target', target, dimension);
|
|
106
|
+
const current = stateAtInto(time, {
|
|
107
|
+
position: Array(dimension),
|
|
108
|
+
velocity: Array(dimension),
|
|
109
|
+
});
|
|
110
|
+
return createVectorSpring({
|
|
111
|
+
from: current.position,
|
|
112
|
+
to: target,
|
|
113
|
+
velocity: current.velocity,
|
|
114
|
+
parameters: parameterSnapshot,
|
|
115
|
+
settle: springs.map(resolvedSettleFor),
|
|
116
|
+
timing: timingSnapshot,
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=vector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector.js","sourceRoot":"","sources":["../src/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA4C3C,SAAS,eAAe,CACtB,IAAY,EACZ,KAAwB,EACxB,SAAiB;IAEjB,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,yBAAyB,SAAS,aAAa,CAAC,CAAC;IAC/E,CAAC;IACD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,YAAY,CAAC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,CAAC;YACH,OAAO,kBAAkB,CAAC;gBACxB,IAAI,EAAE,OAAO,CAAC,QAAQ;gBACtB,EAAE,EAAE,MAAM;gBACV,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,UAAU,EAAE,iBAAiB;gBAC7B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;gBACtC,MAAM,EAAE,cAAc;aACvB,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tensum",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Analytical spring physics for JavaScript and GSAP",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Motion Core",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"animation",
|
|
9
|
+
"gsap",
|
|
10
|
+
"physics",
|
|
11
|
+
"spring"
|
|
12
|
+
],
|
|
13
|
+
"private": false,
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"src",
|
|
19
|
+
"CHANGELOG.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./css": {
|
|
30
|
+
"types": "./dist/css.d.ts",
|
|
31
|
+
"import": "./dist/css.js"
|
|
32
|
+
},
|
|
33
|
+
"./coupled": {
|
|
34
|
+
"types": "./dist/coupled.d.ts",
|
|
35
|
+
"import": "./dist/coupled.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"registry": "https://registry.npmjs.org/",
|
|
44
|
+
"tag": "latest"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"clean": "node --eval \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true });\"",
|
|
48
|
+
"build": "pnpm clean && tsc -p tsconfig.build.json",
|
|
49
|
+
"benchmark": "pnpm build && pnpm benchmark:physics && pnpm benchmark:gsap",
|
|
50
|
+
"benchmark:physics": "node benchmarks/physics/spring.mjs",
|
|
51
|
+
"benchmark:gsap": "node benchmarks/gsap/adapter.mjs",
|
|
52
|
+
"check": "tsc -p tsconfig.json",
|
|
53
|
+
"lint": "tsc -p tsconfig.json",
|
|
54
|
+
"prepack": "pnpm build",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:browser": "vitest run --config vitest.browser.config.ts"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"gsap": "^3.15.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@vitest/browser-playwright": "4.1.10",
|
|
63
|
+
"gsap": "^3.15.0",
|
|
64
|
+
"playwright": "1.62.1",
|
|
65
|
+
"typescript": "^6.0.3",
|
|
66
|
+
"vitest": "^4.1.8"
|
|
67
|
+
}
|
|
68
|
+
}
|