@wardic/solid 1.0.0-rc.7 → 1.0.0-rc.8

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.
Files changed (57) hide show
  1. package/dist/browser/animation-controls.js +1 -1
  2. package/dist/browser/animation-controls.js.map +1 -1
  3. package/dist/browser/index.js +1 -1
  4. package/dist/browser/presence-controller.js +12 -1
  5. package/dist/browser/presence-controller.js.map +1 -1
  6. package/dist/browser/retarget-legs.js +6 -3
  7. package/dist/browser/retarget-legs.js.map +1 -1
  8. package/dist/browser/spine.js +33 -6
  9. package/dist/browser/spine.js.map +1 -1
  10. package/dist/browser/unstable/v2/ward.js +8 -1
  11. package/dist/browser/unstable/v2/ward.js.map +1 -1
  12. package/dist/browser/variant-target.js +6 -1
  13. package/dist/browser/variant-target.js.map +1 -1
  14. package/dist/server/animation-controls.js +1 -1
  15. package/dist/server/animation-controls.js.map +1 -1
  16. package/dist/server/index.js +1 -1
  17. package/dist/server/presence-controller.js +12 -1
  18. package/dist/server/presence-controller.js.map +1 -1
  19. package/dist/server/retarget-legs.js +6 -3
  20. package/dist/server/retarget-legs.js.map +1 -1
  21. package/dist/server/spine.js +33 -6
  22. package/dist/server/spine.js.map +1 -1
  23. package/dist/server/unstable/v2/ward.js +8 -1
  24. package/dist/server/unstable/v2/ward.js.map +1 -1
  25. package/dist/server/variant-target.js +6 -1
  26. package/dist/server/variant-target.js.map +1 -1
  27. package/dist/solid/animation-controls.d.ts +3 -4
  28. package/dist/solid/animation-controls.d.ts.map +1 -1
  29. package/dist/solid/animation-controls.js +1 -1
  30. package/dist/solid/animation-controls.js.map +1 -1
  31. package/dist/solid/index.d.ts +1 -1
  32. package/dist/solid/index.js +1 -1
  33. package/dist/solid/presence-controller.d.ts.map +1 -1
  34. package/dist/solid/presence-controller.js +12 -1
  35. package/dist/solid/presence-controller.js.map +1 -1
  36. package/dist/solid/retarget-legs.d.ts.map +1 -1
  37. package/dist/solid/retarget-legs.js +4 -3
  38. package/dist/solid/retarget-legs.js.map +1 -1
  39. package/dist/solid/spine.d.ts +12 -2
  40. package/dist/solid/spine.d.ts.map +1 -1
  41. package/dist/solid/spine.js +34 -5
  42. package/dist/solid/spine.js.map +1 -1
  43. package/dist/solid/unstable/v2/ward.d.ts.map +1 -1
  44. package/dist/solid/unstable/v2/ward.jsx +8 -1
  45. package/dist/solid/unstable/v2/ward.jsx.map +1 -1
  46. package/dist/solid/variant-target.d.ts +2 -0
  47. package/dist/solid/variant-target.d.ts.map +1 -1
  48. package/dist/solid/variant-target.js +3 -1
  49. package/dist/solid/variant-target.js.map +1 -1
  50. package/package.json +4 -4
  51. package/src/animation-controls.ts +4 -2
  52. package/src/index.ts +1 -1
  53. package/src/presence-controller.ts +13 -2
  54. package/src/retarget-legs.ts +4 -3
  55. package/src/spine.ts +43 -8
  56. package/src/unstable/v2/ward.tsx +8 -1
  57. package/src/variant-target.ts +7 -1
@@ -15,6 +15,7 @@
15
15
  * @module
16
16
  */
17
17
  import * as BaseValue from "@wardic/core/BaseValue";
18
+ import * as Frame from "@wardic/core/Frame";
18
19
  import * as InterpolatorRegistry from "@wardic/core/InterpolatorRegistry";
19
20
  import * as Machine from "@wardic/core/Machine";
20
21
  import * as Override from "@wardic/core/Override";
@@ -484,7 +485,6 @@ const runningOf = (to, resolution, landing, kind) => ({
484
485
  resolution,
485
486
  count: 0,
486
487
  values: identity,
487
- velocities: identity,
488
488
  done: false,
489
489
  losing: false,
490
490
  fiber: undefined,
@@ -497,7 +497,8 @@ const runningOf = (to, resolution, landing, kind) => ({
497
497
  lastAt: Number.NEGATIVE_INFINITY,
498
498
  last: undefined,
499
499
  before: undefined,
500
- beforeAt: Number.NEGATIVE_INFINITY
500
+ beforeAt: Number.NEGATIVE_INFINITY,
501
+ physics: undefined
501
502
  });
502
503
  /**
503
504
  * A Blend leg's velocity for `key` (#464, Motion's `getVelocity`): its last two frames' change over
@@ -1318,15 +1319,34 @@ export const emptySnapshotOf = values => ({
1318
1319
  velocities: {},
1319
1320
  drawnAt: {},
1320
1321
  owners: undefined,
1321
- now: frameNow
1322
+ now: frameNow,
1323
+ velocitiesNow: velocitiesNowOf
1322
1324
  });
1323
1325
  // --- Velocities (#464) ---------------------------------------------------------------------------
1324
1326
  /** A leg's velocity for `key`: a Blend leg's from its frames, a Snap's none, a spring's or a follow's as it wrote it. */
1325
1327
  const legVelocityOf = (snapshot, running, key) => {
1326
1328
  if (running.kind === "Blend") return blendVelocityOf(running, key);
1327
1329
  if (running.kind === "Snap") return 0;
1330
+ if (running.kind === "Numbers") return numbersVelocityOf(snapshot, running, key);
1328
1331
  return velocityOf(snapshot, key);
1329
1332
  };
1333
+ /**
1334
+ * A Numbers leg's velocity for `key` (#663): its last Frame's, as it drew it, by index from a spring's
1335
+ * (whose velocity record it doesn't write), from the record of an inertia's; the Snapshot's before its
1336
+ * first frame, or for a key its Frame doesn't have. Per key, per Retarget: guards.
1337
+ */
1338
+ const numbersVelocityOf = (snapshot, running, key) => {
1339
+ const last = running.physics;
1340
+ if (Predicate.isUndefined(last)) return velocityOf(snapshot, key);
1341
+ if (Frame.isSpringValues(last)) {
1342
+ const at = last.keys.indexOf(key);
1343
+ if (at < 0) return velocityOf(snapshot, key);
1344
+ return UndefinedOr.getOrThrow(last.velocities[at]);
1345
+ }
1346
+ const velocity = last.velocity[key];
1347
+ if (Predicate.isUndefined(velocity)) return velocityOf(snapshot, key);
1348
+ return velocity;
1349
+ };
1330
1350
  /**
1331
1351
  * `key`'s velocity at `now` (#464, Motion's `getVelocity`): the leg drawing it, once it has drawn a
1332
1352
  * frame, else what the Snapshot holds for it (the last leg to let it go left it, a drag or a seed set
@@ -1718,7 +1738,6 @@ export const makeElementSpine = options => {
1718
1738
  if (running.count === 0) return;
1719
1739
  const kept = Arr.filter(Rec.keys(running.targets), key => owners.get(key) === running);
1720
1740
  running.values = keepingOnly(kept);
1721
- running.velocities = keepingOnly(kept);
1722
1741
  });
1723
1742
  losing.length = 0;
1724
1743
  };
@@ -1786,11 +1805,19 @@ export const makeElementSpine = options => {
1786
1805
  // whatever keeps one copies it or reads it at once.
1787
1806
  const value = running.values(frame.value);
1788
1807
  Object.assign(snapshot.values, value);
1789
- Object.assign(snapshot.velocities, running.velocities(frame.velocity));
1808
+ // Its velocities stay on its Frame (#663), read by index when one is asked for: copied into
1809
+ // the Snapshot each frame, they cost a boxed number a key a frame that only a Retarget read.
1810
+ running.physics = frame;
1790
1811
  gate.write(id, value);
1791
1812
  recordFrame(value);
1792
1813
  drew(running, frame.done, snapshot.now());
1793
- if (frame.done) landEndsOf(waiting);
1814
+ if (frame.done) {
1815
+ // Landed, its keys are at rest: the Snapshot says so for whatever reads it after it's gone.
1816
+ Arr.forEach(Rec.keys(value), key => {
1817
+ snapshot.velocities[key] = 0;
1818
+ });
1819
+ landEndsOf(waiting);
1820
+ }
1794
1821
  return undefined;
1795
1822
  }, running));
1796
1823
  }