coily 0.6.0 → 0.7.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Tim Morris
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/api.cjs CHANGED
@@ -190,7 +190,7 @@ var __privateMethod = (obj, member, method) => {
190
190
  __accessCheck$2(obj, member, "access private method");
191
191
  return method;
192
192
  };
193
- var _mass, _tension, _damping, _state, _underdampedSolver, _criticallyDampedSolver, _overdampedSolver, _currentSolver, _solverNeedsUpdate, _solverNeedsReset, _emitter, _updateSolver, updateSolver_fn, _solver$1, _state2, _dampedFrequency, _t, _c1, _c2, _solver2, _state3, _t2, _c12, _c22, _solver3, _state4, _dampedFrequency2, _t3, _c13, _c23;
193
+ var _mass, _tension, _damping, _state, _underdampedSolver, _criticallyDampedSolver, _overdampedSolver, _currentSolver, _needsUpdate, _needsReset, _emitter, _updateSolver, updateSolver_fn, _solver$1, _state2, _dampedFrequency, _t, _c1, _c2, _solver2, _state3, _t2, _c12, _c22, _solver3, _state4, _dampedFrequency2, _t3, _c13, _c23;
194
194
  class Solver {
195
195
  constructor(options) {
196
196
  __privateAdd$2(this, _updateSolver);
@@ -202,8 +202,8 @@ class Solver {
202
202
  __privateAdd$2(this, _criticallyDampedSolver, null);
203
203
  __privateAdd$2(this, _overdampedSolver, null);
204
204
  __privateAdd$2(this, _currentSolver, void 0);
205
- __privateAdd$2(this, _solverNeedsUpdate, false);
206
- __privateAdd$2(this, _solverNeedsReset, false);
205
+ __privateAdd$2(this, _needsUpdate, false);
206
+ __privateAdd$2(this, _needsReset, false);
207
207
  __privateAdd$2(this, _emitter, void 0);
208
208
  __privateSet$2(this, _mass, options.mass);
209
209
  __privateSet$2(this, _tension, options.tension);
@@ -221,35 +221,35 @@ class Solver {
221
221
  }
222
222
  set mass(value) {
223
223
  __privateSet$2(this, _mass, value);
224
- __privateSet$2(this, _solverNeedsUpdate, true);
224
+ __privateSet$2(this, _needsUpdate, true);
225
225
  }
226
226
  get tension() {
227
227
  return __privateGet$2(this, _tension);
228
228
  }
229
229
  set tension(value) {
230
230
  __privateSet$2(this, _tension, value);
231
- __privateSet$2(this, _solverNeedsUpdate, true);
231
+ __privateSet$2(this, _needsUpdate, true);
232
232
  }
233
233
  get damping() {
234
234
  return __privateGet$2(this, _damping);
235
235
  }
236
236
  set damping(value) {
237
237
  __privateSet$2(this, _damping, value);
238
- __privateSet$2(this, _solverNeedsUpdate, true);
238
+ __privateSet$2(this, _needsUpdate, true);
239
239
  }
240
240
  get position() {
241
241
  return __privateGet$2(this, _state).position;
242
242
  }
243
243
  set position(value) {
244
244
  __privateGet$2(this, _state).position = value;
245
- __privateSet$2(this, _solverNeedsReset, true);
245
+ __privateSet$2(this, _needsReset, true);
246
246
  }
247
247
  get velocity() {
248
248
  return __privateGet$2(this, _state).velocity;
249
249
  }
250
250
  set velocity(value) {
251
251
  __privateGet$2(this, _state).velocity = value;
252
- __privateSet$2(this, _solverNeedsReset, true);
252
+ __privateSet$2(this, _needsReset, true);
253
253
  }
254
254
  get precision() {
255
255
  return __privateGet$2(this, _state).precision;
@@ -270,24 +270,31 @@ class Solver {
270
270
  return __privateGet$2(this, _damping) / this.criticalDamping;
271
271
  }
272
272
  tick(dt) {
273
- if (__privateGet$2(this, _solverNeedsUpdate)) {
273
+ if (__privateGet$2(this, _needsUpdate)) {
274
274
  __privateMethod(this, _updateSolver, updateSolver_fn).call(this);
275
- __privateSet$2(this, _solverNeedsUpdate, false);
275
+ __privateSet$2(this, _needsUpdate, false);
276
276
  }
277
- if (__privateGet$2(this, _solverNeedsReset)) {
277
+ if (__privateGet$2(this, _needsReset)) {
278
278
  __privateGet$2(this, _currentSolver).reset();
279
- __privateSet$2(this, _solverNeedsReset, false);
279
+ __privateSet$2(this, _needsReset, false);
280
280
  }
281
281
  const previousPosition = __privateGet$2(this, _state).position;
282
282
  const previousVelocity = __privateGet$2(this, _state).velocity;
283
+ const previousResting = __privateGet$2(this, _state).resting;
283
284
  __privateGet$2(this, _currentSolver).tick(dt);
284
285
  if (__privateGet$2(this, _state).position !== previousPosition || __privateGet$2(this, _state).velocity !== previousVelocity) {
285
286
  __privateGet$2(this, _emitter).emit("update");
286
287
  }
288
+ if (__privateGet$2(this, _state).resting !== previousResting) {
289
+ __privateGet$2(this, _emitter).emit("rest");
290
+ }
287
291
  }
288
292
  onUpdate(callback) {
289
293
  return __privateGet$2(this, _emitter).on("update", callback);
290
294
  }
295
+ onRest(callback) {
296
+ return __privateGet$2(this, _emitter).on("rest", callback);
297
+ }
291
298
  }
292
299
  _mass = new WeakMap();
293
300
  _tension = new WeakMap();
@@ -297,8 +304,8 @@ _underdampedSolver = new WeakMap();
297
304
  _criticallyDampedSolver = new WeakMap();
298
305
  _overdampedSolver = new WeakMap();
299
306
  _currentSolver = new WeakMap();
300
- _solverNeedsUpdate = new WeakMap();
301
- _solverNeedsReset = new WeakMap();
307
+ _needsUpdate = new WeakMap();
308
+ _needsReset = new WeakMap();
302
309
  _emitter = new WeakMap();
303
310
  _updateSolver = new WeakSet();
304
311
  updateSolver_fn = function() {
@@ -557,6 +564,9 @@ class Spring {
557
564
  onUpdate(callback) {
558
565
  return __privateGet$1(this, _solver).onUpdate(callback);
559
566
  }
567
+ onRest(callback) {
568
+ return __privateGet$1(this, _solver).onRest(callback);
569
+ }
560
570
  }
561
571
  _target = new WeakMap();
562
572
  _solver = new WeakMap();
package/dist/api.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SpringSystem } from './shared/coily.86bacb03.cjs';
2
- export { a as Spring } from './shared/coily.86bacb03.cjs';
1
+ import { S as SpringSystem } from './shared/coily.29d66c44.cjs';
2
+ export { a as Spring } from './shared/coily.29d66c44.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.86bacb03.mjs';
2
- export { a as Spring } from './shared/coily.86bacb03.mjs';
1
+ import { S as SpringSystem } from './shared/coily.29d66c44.mjs';
2
+ export { a as Spring } from './shared/coily.29d66c44.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.86bacb03.js';
2
- export { a as Spring } from './shared/coily.86bacb03.js';
1
+ import { S as SpringSystem } from './shared/coily.29d66c44.js';
2
+ export { a as Spring } from './shared/coily.29d66c44.js';
3
3
 
4
4
  declare function createSpringSystem(): SpringSystem;
5
5
 
package/dist/api.mjs CHANGED
@@ -188,7 +188,7 @@ var __privateMethod = (obj, member, method) => {
188
188
  __accessCheck$2(obj, member, "access private method");
189
189
  return method;
190
190
  };
191
- var _mass, _tension, _damping, _state, _underdampedSolver, _criticallyDampedSolver, _overdampedSolver, _currentSolver, _solverNeedsUpdate, _solverNeedsReset, _emitter, _updateSolver, updateSolver_fn, _solver$1, _state2, _dampedFrequency, _t, _c1, _c2, _solver2, _state3, _t2, _c12, _c22, _solver3, _state4, _dampedFrequency2, _t3, _c13, _c23;
191
+ var _mass, _tension, _damping, _state, _underdampedSolver, _criticallyDampedSolver, _overdampedSolver, _currentSolver, _needsUpdate, _needsReset, _emitter, _updateSolver, updateSolver_fn, _solver$1, _state2, _dampedFrequency, _t, _c1, _c2, _solver2, _state3, _t2, _c12, _c22, _solver3, _state4, _dampedFrequency2, _t3, _c13, _c23;
192
192
  class Solver {
193
193
  constructor(options) {
194
194
  __privateAdd$2(this, _updateSolver);
@@ -200,8 +200,8 @@ class Solver {
200
200
  __privateAdd$2(this, _criticallyDampedSolver, null);
201
201
  __privateAdd$2(this, _overdampedSolver, null);
202
202
  __privateAdd$2(this, _currentSolver, void 0);
203
- __privateAdd$2(this, _solverNeedsUpdate, false);
204
- __privateAdd$2(this, _solverNeedsReset, false);
203
+ __privateAdd$2(this, _needsUpdate, false);
204
+ __privateAdd$2(this, _needsReset, false);
205
205
  __privateAdd$2(this, _emitter, void 0);
206
206
  __privateSet$2(this, _mass, options.mass);
207
207
  __privateSet$2(this, _tension, options.tension);
@@ -219,35 +219,35 @@ class Solver {
219
219
  }
220
220
  set mass(value) {
221
221
  __privateSet$2(this, _mass, value);
222
- __privateSet$2(this, _solverNeedsUpdate, true);
222
+ __privateSet$2(this, _needsUpdate, true);
223
223
  }
224
224
  get tension() {
225
225
  return __privateGet$2(this, _tension);
226
226
  }
227
227
  set tension(value) {
228
228
  __privateSet$2(this, _tension, value);
229
- __privateSet$2(this, _solverNeedsUpdate, true);
229
+ __privateSet$2(this, _needsUpdate, true);
230
230
  }
231
231
  get damping() {
232
232
  return __privateGet$2(this, _damping);
233
233
  }
234
234
  set damping(value) {
235
235
  __privateSet$2(this, _damping, value);
236
- __privateSet$2(this, _solverNeedsUpdate, true);
236
+ __privateSet$2(this, _needsUpdate, true);
237
237
  }
238
238
  get position() {
239
239
  return __privateGet$2(this, _state).position;
240
240
  }
241
241
  set position(value) {
242
242
  __privateGet$2(this, _state).position = value;
243
- __privateSet$2(this, _solverNeedsReset, true);
243
+ __privateSet$2(this, _needsReset, true);
244
244
  }
245
245
  get velocity() {
246
246
  return __privateGet$2(this, _state).velocity;
247
247
  }
248
248
  set velocity(value) {
249
249
  __privateGet$2(this, _state).velocity = value;
250
- __privateSet$2(this, _solverNeedsReset, true);
250
+ __privateSet$2(this, _needsReset, true);
251
251
  }
252
252
  get precision() {
253
253
  return __privateGet$2(this, _state).precision;
@@ -268,24 +268,31 @@ class Solver {
268
268
  return __privateGet$2(this, _damping) / this.criticalDamping;
269
269
  }
270
270
  tick(dt) {
271
- if (__privateGet$2(this, _solverNeedsUpdate)) {
271
+ if (__privateGet$2(this, _needsUpdate)) {
272
272
  __privateMethod(this, _updateSolver, updateSolver_fn).call(this);
273
- __privateSet$2(this, _solverNeedsUpdate, false);
273
+ __privateSet$2(this, _needsUpdate, false);
274
274
  }
275
- if (__privateGet$2(this, _solverNeedsReset)) {
275
+ if (__privateGet$2(this, _needsReset)) {
276
276
  __privateGet$2(this, _currentSolver).reset();
277
- __privateSet$2(this, _solverNeedsReset, false);
277
+ __privateSet$2(this, _needsReset, false);
278
278
  }
279
279
  const previousPosition = __privateGet$2(this, _state).position;
280
280
  const previousVelocity = __privateGet$2(this, _state).velocity;
281
+ const previousResting = __privateGet$2(this, _state).resting;
281
282
  __privateGet$2(this, _currentSolver).tick(dt);
282
283
  if (__privateGet$2(this, _state).position !== previousPosition || __privateGet$2(this, _state).velocity !== previousVelocity) {
283
284
  __privateGet$2(this, _emitter).emit("update");
284
285
  }
286
+ if (__privateGet$2(this, _state).resting !== previousResting) {
287
+ __privateGet$2(this, _emitter).emit("rest");
288
+ }
285
289
  }
286
290
  onUpdate(callback) {
287
291
  return __privateGet$2(this, _emitter).on("update", callback);
288
292
  }
293
+ onRest(callback) {
294
+ return __privateGet$2(this, _emitter).on("rest", callback);
295
+ }
289
296
  }
290
297
  _mass = new WeakMap();
291
298
  _tension = new WeakMap();
@@ -295,8 +302,8 @@ _underdampedSolver = new WeakMap();
295
302
  _criticallyDampedSolver = new WeakMap();
296
303
  _overdampedSolver = new WeakMap();
297
304
  _currentSolver = new WeakMap();
298
- _solverNeedsUpdate = new WeakMap();
299
- _solverNeedsReset = new WeakMap();
305
+ _needsUpdate = new WeakMap();
306
+ _needsReset = new WeakMap();
300
307
  _emitter = new WeakMap();
301
308
  _updateSolver = new WeakSet();
302
309
  updateSolver_fn = function() {
@@ -555,6 +562,9 @@ class Spring {
555
562
  onUpdate(callback) {
556
563
  return __privateGet$1(this, _solver).onUpdate(callback);
557
564
  }
565
+ onRest(callback) {
566
+ return __privateGet$1(this, _solver).onRest(callback);
567
+ }
558
568
  }
559
569
  _target = new WeakMap();
560
570
  _solver = new WeakMap();
package/dist/loop.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as SpringSystem } from './shared/coily.86bacb03.cjs';
1
+ import { S as SpringSystem } from './shared/coily.29d66c44.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.86bacb03.mjs';
1
+ import { S as SpringSystem } from './shared/coily.29d66c44.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.86bacb03.js';
1
+ import { S as SpringSystem } from './shared/coily.29d66c44.js';
2
2
 
3
3
  declare function start(system: SpringSystem): () => void;
4
4
 
@@ -27,6 +27,7 @@ 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
31
  }
31
32
 
32
33
  type TickCallback = (delta: number) => void;
@@ -66,6 +67,7 @@ declare class Spring {
66
67
  set precision(value: number);
67
68
  get resting(): boolean;
68
69
  onUpdate(callback: () => void): () => void;
70
+ onRest(callback: () => void): () => void;
69
71
  }
70
72
 
71
73
  interface SpringOptions {
@@ -27,6 +27,7 @@ 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
31
  }
31
32
 
32
33
  type TickCallback = (delta: number) => void;
@@ -66,6 +67,7 @@ declare class Spring {
66
67
  set precision(value: number);
67
68
  get resting(): boolean;
68
69
  onUpdate(callback: () => void): () => void;
70
+ onRest(callback: () => void): () => void;
69
71
  }
70
72
 
71
73
  interface SpringOptions {
@@ -27,6 +27,7 @@ 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
31
  }
31
32
 
32
33
  type TickCallback = (delta: number) => void;
@@ -66,6 +67,7 @@ declare class Spring {
66
67
  set precision(value: number);
67
68
  get resting(): boolean;
68
69
  onUpdate(callback: () => void): () => void;
70
+ onRest(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.6.0",
3
+ "version": "0.7.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",
@@ -32,10 +32,6 @@
32
32
  "type": "git",
33
33
  "url": "git+https://github.com/tkofh/coily.git"
34
34
  },
35
- "scripts": {
36
- "build": "unbuild",
37
- "prepublish": "bun run build"
38
- },
39
35
  "bugs": {
40
36
  "url": "https://github.com/tkofh/coily/issues"
41
37
  },
@@ -45,8 +41,11 @@
45
41
  "unbuild": "^2.0.0",
46
42
  "vitest": "^1.3.1"
47
43
  },
48
- "gitHead": "96019bee6135f93006c3fd52d23846afd6271c66",
49
44
  "dependencies": {
50
45
  "tickloop": "^0.5.0"
46
+ },
47
+ "scripts": {
48
+ "build": "unbuild",
49
+ "prepublish": "bun run build"
51
50
  }
52
- }
51
+ }