coily 0.7.3 → 0.8.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/dist/api.cjs CHANGED
@@ -234,6 +234,9 @@ class Solver {
234
234
  set position(value) {
235
235
  __privateGet$2(this, _state).position = value;
236
236
  __privateSet$2(this, _needsReset, true);
237
+ if (!__privateGet$2(this, _state).resting) {
238
+ __privateGet$2(this, _emitter).emit("start");
239
+ }
237
240
  }
238
241
  get velocity() {
239
242
  return __privateGet$2(this, _state).velocity;
@@ -269,22 +272,20 @@ class Solver {
269
272
  __privateGet$2(this, _currentSolver).reset();
270
273
  __privateSet$2(this, _needsReset, false);
271
274
  }
272
- const previousPosition = __privateGet$2(this, _state).position;
273
- const previousVelocity = __privateGet$2(this, _state).velocity;
274
- const previousResting = __privateGet$2(this, _state).resting;
275
275
  __privateGet$2(this, _currentSolver).tick(dt);
276
- if (__privateGet$2(this, _state).position !== previousPosition || __privateGet$2(this, _state).velocity !== previousVelocity) {
277
- __privateGet$2(this, _emitter).emit("update");
278
- }
279
- if (__privateGet$2(this, _state).resting !== previousResting) {
280
- __privateGet$2(this, _emitter).emit("rest");
276
+ __privateGet$2(this, _emitter).emit("update");
277
+ if (__privateGet$2(this, _state).resting) {
278
+ __privateGet$2(this, _emitter).emit("stop");
281
279
  }
282
280
  }
283
281
  onUpdate(callback) {
284
282
  return __privateGet$2(this, _emitter).on("update", callback);
285
283
  }
286
- onRest(callback) {
287
- return __privateGet$2(this, _emitter).on("rest", callback);
284
+ onStart(callback) {
285
+ return __privateGet$2(this, _emitter).on("start", callback);
286
+ }
287
+ onStop(callback) {
288
+ return __privateGet$2(this, _emitter).on("stop", callback);
288
289
  }
289
290
  }
290
291
  _mass = new WeakMap();
@@ -443,13 +444,13 @@ var __privateSet$1 = (obj, member, value, setter) => {
443
444
  setter ? setter.call(obj, value) : member.set(obj, value);
444
445
  return value;
445
446
  };
446
- var _target, _solver, _scheduler$1, _newTarget;
447
+ var _target, _solver, _scheduler$1;
447
448
  class Spring {
449
+ // #newTarget: number
448
450
  constructor(scheduler, options) {
449
451
  __privateAdd$1(this, _target, void 0);
450
452
  __privateAdd$1(this, _solver, void 0);
451
453
  __privateAdd$1(this, _scheduler$1, void 0);
452
- __privateAdd$1(this, _newTarget, void 0);
453
454
  invariant(options.mass > 0, "Mass must be greater than 0");
454
455
  invariant(options.tension > 0, "Tension must be greater than 0");
455
456
  invariant(
@@ -470,7 +471,6 @@ class Spring {
470
471
  precision: options.precision ?? 2
471
472
  }));
472
473
  __privateSet$1(this, _scheduler$1, scheduler);
473
- __privateSet$1(this, _newTarget, __privateGet$1(this, _target));
474
474
  if (!__privateGet$1(this, _solver).resting) {
475
475
  __privateGet$1(this, _scheduler$1).add(__privateGet$1(this, _solver));
476
476
  }
@@ -552,14 +552,16 @@ class Spring {
552
552
  onUpdate(callback) {
553
553
  return __privateGet$1(this, _solver).onUpdate(callback);
554
554
  }
555
- onRest(callback) {
556
- return __privateGet$1(this, _solver).onRest(callback);
555
+ onStart(callback) {
556
+ return __privateGet$1(this, _solver).onStart(callback);
557
+ }
558
+ onStop(callback) {
559
+ return __privateGet$1(this, _solver).onStop(callback);
557
560
  }
558
561
  }
559
562
  _target = new WeakMap();
560
563
  _solver = new WeakMap();
561
564
  _scheduler$1 = new WeakMap();
562
- _newTarget = new WeakMap();
563
565
 
564
566
  var __accessCheck = (obj, member, msg) => {
565
567
  if (!member.has(obj))
package/dist/api.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SpringSystem } from './shared/coily.7c365057.cjs';
2
- export { a as Spring } from './shared/coily.7c365057.cjs';
1
+ import { S as SpringSystem } from './shared/coily.c7e32732.cjs';
2
+ export { a as Spring } from './shared/coily.c7e32732.cjs';
3
3
 
4
4
  declare function createSpringSystem(): SpringSystem;
5
5
 
package/dist/api.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SpringSystem } from './shared/coily.7c365057.mjs';
2
- export { a as Spring } from './shared/coily.7c365057.mjs';
1
+ import { S as SpringSystem } from './shared/coily.c7e32732.mjs';
2
+ export { a as Spring } from './shared/coily.c7e32732.mjs';
3
3
 
4
4
  declare function createSpringSystem(): SpringSystem;
5
5
 
package/dist/api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SpringSystem } from './shared/coily.7c365057.js';
2
- export { a as Spring } from './shared/coily.7c365057.js';
1
+ import { S as SpringSystem } from './shared/coily.c7e32732.js';
2
+ export { a as Spring } from './shared/coily.c7e32732.js';
3
3
 
4
4
  declare function createSpringSystem(): SpringSystem;
5
5
 
package/dist/api.mjs CHANGED
@@ -232,6 +232,9 @@ class Solver {
232
232
  set position(value) {
233
233
  __privateGet$2(this, _state).position = value;
234
234
  __privateSet$2(this, _needsReset, true);
235
+ if (!__privateGet$2(this, _state).resting) {
236
+ __privateGet$2(this, _emitter).emit("start");
237
+ }
235
238
  }
236
239
  get velocity() {
237
240
  return __privateGet$2(this, _state).velocity;
@@ -267,22 +270,20 @@ class Solver {
267
270
  __privateGet$2(this, _currentSolver).reset();
268
271
  __privateSet$2(this, _needsReset, false);
269
272
  }
270
- const previousPosition = __privateGet$2(this, _state).position;
271
- const previousVelocity = __privateGet$2(this, _state).velocity;
272
- const previousResting = __privateGet$2(this, _state).resting;
273
273
  __privateGet$2(this, _currentSolver).tick(dt);
274
- if (__privateGet$2(this, _state).position !== previousPosition || __privateGet$2(this, _state).velocity !== previousVelocity) {
275
- __privateGet$2(this, _emitter).emit("update");
276
- }
277
- if (__privateGet$2(this, _state).resting !== previousResting) {
278
- __privateGet$2(this, _emitter).emit("rest");
274
+ __privateGet$2(this, _emitter).emit("update");
275
+ if (__privateGet$2(this, _state).resting) {
276
+ __privateGet$2(this, _emitter).emit("stop");
279
277
  }
280
278
  }
281
279
  onUpdate(callback) {
282
280
  return __privateGet$2(this, _emitter).on("update", callback);
283
281
  }
284
- onRest(callback) {
285
- return __privateGet$2(this, _emitter).on("rest", callback);
282
+ onStart(callback) {
283
+ return __privateGet$2(this, _emitter).on("start", callback);
284
+ }
285
+ onStop(callback) {
286
+ return __privateGet$2(this, _emitter).on("stop", callback);
286
287
  }
287
288
  }
288
289
  _mass = new WeakMap();
@@ -441,13 +442,13 @@ var __privateSet$1 = (obj, member, value, setter) => {
441
442
  setter ? setter.call(obj, value) : member.set(obj, value);
442
443
  return value;
443
444
  };
444
- var _target, _solver, _scheduler$1, _newTarget;
445
+ var _target, _solver, _scheduler$1;
445
446
  class Spring {
447
+ // #newTarget: number
446
448
  constructor(scheduler, options) {
447
449
  __privateAdd$1(this, _target, void 0);
448
450
  __privateAdd$1(this, _solver, void 0);
449
451
  __privateAdd$1(this, _scheduler$1, void 0);
450
- __privateAdd$1(this, _newTarget, void 0);
451
452
  invariant(options.mass > 0, "Mass must be greater than 0");
452
453
  invariant(options.tension > 0, "Tension must be greater than 0");
453
454
  invariant(
@@ -468,7 +469,6 @@ class Spring {
468
469
  precision: options.precision ?? 2
469
470
  }));
470
471
  __privateSet$1(this, _scheduler$1, scheduler);
471
- __privateSet$1(this, _newTarget, __privateGet$1(this, _target));
472
472
  if (!__privateGet$1(this, _solver).resting) {
473
473
  __privateGet$1(this, _scheduler$1).add(__privateGet$1(this, _solver));
474
474
  }
@@ -550,14 +550,16 @@ class Spring {
550
550
  onUpdate(callback) {
551
551
  return __privateGet$1(this, _solver).onUpdate(callback);
552
552
  }
553
- onRest(callback) {
554
- return __privateGet$1(this, _solver).onRest(callback);
553
+ onStart(callback) {
554
+ return __privateGet$1(this, _solver).onStart(callback);
555
+ }
556
+ onStop(callback) {
557
+ return __privateGet$1(this, _solver).onStop(callback);
555
558
  }
556
559
  }
557
560
  _target = new WeakMap();
558
561
  _solver = new WeakMap();
559
562
  _scheduler$1 = new WeakMap();
560
- _newTarget = new WeakMap();
561
563
 
562
564
  var __accessCheck = (obj, member, msg) => {
563
565
  if (!member.has(obj))
package/dist/loop.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as SpringSystem } from './shared/coily.7c365057.cjs';
1
+ import { S as SpringSystem } from './shared/coily.c7e32732.cjs';
2
2
 
3
3
  declare function start(system: SpringSystem): () => void;
4
4
 
package/dist/loop.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as SpringSystem } from './shared/coily.7c365057.mjs';
1
+ import { S as SpringSystem } from './shared/coily.c7e32732.mjs';
2
2
 
3
3
  declare function start(system: SpringSystem): () => void;
4
4
 
package/dist/loop.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as SpringSystem } from './shared/coily.7c365057.js';
1
+ import { S as SpringSystem } from './shared/coily.c7e32732.js';
2
2
 
3
3
  declare function start(system: SpringSystem): () => void;
4
4
 
@@ -27,7 +27,8 @@ declare class Solver {
27
27
  get dampingRatio(): number;
28
28
  tick(dt: number): void;
29
29
  onUpdate(callback: () => void): () => void;
30
- onRest(callback: () => void): () => void;
30
+ onStart(callback: () => void): () => void;
31
+ onStop(callback: () => void): () => void;
31
32
  }
32
33
 
33
34
  declare class Scheduler {
@@ -65,7 +66,8 @@ declare class Spring {
65
66
  set precision(value: number);
66
67
  get resting(): boolean;
67
68
  onUpdate(callback: () => void): () => void;
68
- onRest(callback: () => void): () => void;
69
+ onStart(callback: () => void): () => void;
70
+ onStop(callback: () => void): () => void;
69
71
  }
70
72
 
71
73
  interface SpringOptions {
@@ -27,7 +27,8 @@ declare class Solver {
27
27
  get dampingRatio(): number;
28
28
  tick(dt: number): void;
29
29
  onUpdate(callback: () => void): () => void;
30
- onRest(callback: () => void): () => void;
30
+ onStart(callback: () => void): () => void;
31
+ onStop(callback: () => void): () => void;
31
32
  }
32
33
 
33
34
  declare class Scheduler {
@@ -65,7 +66,8 @@ declare class Spring {
65
66
  set precision(value: number);
66
67
  get resting(): boolean;
67
68
  onUpdate(callback: () => void): () => void;
68
- onRest(callback: () => void): () => void;
69
+ onStart(callback: () => void): () => void;
70
+ onStop(callback: () => void): () => void;
69
71
  }
70
72
 
71
73
  interface SpringOptions {
@@ -27,7 +27,8 @@ declare class Solver {
27
27
  get dampingRatio(): number;
28
28
  tick(dt: number): void;
29
29
  onUpdate(callback: () => void): () => void;
30
- onRest(callback: () => void): () => void;
30
+ onStart(callback: () => void): () => void;
31
+ onStop(callback: () => void): () => void;
31
32
  }
32
33
 
33
34
  declare class Scheduler {
@@ -65,7 +66,8 @@ declare class Spring {
65
66
  set precision(value: number);
66
67
  get resting(): boolean;
67
68
  onUpdate(callback: () => void): () => void;
68
- onRest(callback: () => void): () => void;
69
+ onStart(callback: () => void): () => void;
70
+ onStop(callback: () => void): () => void;
69
71
  }
70
72
 
71
73
  interface SpringOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coily",
3
- "version": "0.7.3",
3
+ "version": "0.8.0",
4
4
  "description": "Simulate values using spring physics",
5
5
  "author": "Tim Morris <timthewebguy@gmail.com>",
6
6
  "homepage": "https://github.com/tkofh/coily#readme",
@@ -36,17 +36,15 @@
36
36
  "url": "https://github.com/tkofh/coily/issues"
37
37
  },
38
38
  "devDependencies": {
39
- "@vitest/coverage-v8": "^2.0.4",
40
- "@vitest/ui": "^2.0.4",
41
39
  "unbuild": "^2.0.0",
42
- "vitest": "^2.0.4"
40
+ "vitest": "^2.1.4"
43
41
  },
44
42
  "dependencies": {
45
43
  "tickloop": "^0.5.0"
46
44
  },
47
45
  "scripts": {
48
46
  "build": "unbuild",
49
- "test": "vitest",
47
+ "test": "vitest run",
50
48
  "prepublish": "bun run build"
51
49
  }
52
50
  }