@wardic/core 1.0.0-rc.9 → 1.0.1

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 (63) hide show
  1. package/dist/Batch.d.ts +244 -0
  2. package/dist/Batch.d.ts.map +1 -0
  3. package/dist/Batch.js +1862 -0
  4. package/dist/Batch.js.map +1 -0
  5. package/dist/DragRecognizer.d.ts +16 -1
  6. package/dist/DragRecognizer.d.ts.map +1 -1
  7. package/dist/DragRecognizer.js +87 -1
  8. package/dist/DragRecognizer.js.map +1 -1
  9. package/dist/InputSource.d.ts +21 -0
  10. package/dist/InputSource.d.ts.map +1 -1
  11. package/dist/InputSource.js.map +1 -1
  12. package/dist/Machine.d.ts.map +1 -1
  13. package/dist/Machine.js +4 -67
  14. package/dist/Machine.js.map +1 -1
  15. package/dist/Playback.d.ts.map +1 -1
  16. package/dist/Playback.js +7 -6
  17. package/dist/Playback.js.map +1 -1
  18. package/dist/Recognizer.d.ts +35 -2
  19. package/dist/Recognizer.d.ts.map +1 -1
  20. package/dist/Recognizer.js +211 -16
  21. package/dist/Recognizer.js.map +1 -1
  22. package/dist/Reorder.d.ts +7 -5
  23. package/dist/Reorder.d.ts.map +1 -1
  24. package/dist/Reorder.js +60 -23
  25. package/dist/Reorder.js.map +1 -1
  26. package/dist/Sequence.d.ts +7 -2
  27. package/dist/Sequence.d.ts.map +1 -1
  28. package/dist/Sequence.js +8 -2
  29. package/dist/Sequence.js.map +1 -1
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +1 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/internal/keyframes.d.ts +40 -0
  35. package/dist/internal/keyframes.d.ts.map +1 -0
  36. package/dist/internal/keyframes.js +70 -0
  37. package/dist/internal/keyframes.js.map +1 -0
  38. package/dist/internal/playhead.d.ts +16 -0
  39. package/dist/internal/playhead.d.ts.map +1 -0
  40. package/dist/internal/playhead.js +6 -0
  41. package/dist/internal/playhead.js.map +1 -0
  42. package/dist/internal/stepper.d.ts +6 -0
  43. package/dist/internal/stepper.d.ts.map +1 -1
  44. package/dist/internal/stepper.js +16 -0
  45. package/dist/internal/stepper.js.map +1 -1
  46. package/dist/internal/watch.d.ts +6 -0
  47. package/dist/internal/watch.d.ts.map +1 -1
  48. package/dist/internal/watch.js +7 -0
  49. package/dist/internal/watch.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/Batch.ts +2128 -0
  52. package/src/DragRecognizer.ts +97 -2
  53. package/src/InputSource.ts +25 -0
  54. package/src/Machine.ts +4 -93
  55. package/src/Playback.ts +7 -13
  56. package/src/Recognizer.ts +242 -17
  57. package/src/Reorder.ts +83 -27
  58. package/src/Sequence.ts +20 -5
  59. package/src/index.ts +1 -0
  60. package/src/internal/keyframes.ts +98 -0
  61. package/src/internal/playhead.ts +19 -0
  62. package/src/internal/stepper.ts +16 -0
  63. package/src/internal/watch.ts +15 -0
@@ -242,6 +242,22 @@ export const intervalProgress = (time: number, stopTimes: ReadonlyArray<number>,
242
242
  return Scalar.clamp((time - start) / length, 0, 1)
243
243
  }
244
244
 
245
+ /**
246
+ * A keyframes run's value at `pass` (#429): the Interval its time is in, eased whole, between its two
247
+ * stops, read from last to first in a flipped pass. `Machine.keyframes` and a Batch's keyframes (#665)
248
+ * read it. Per frame (ADR-0025).
249
+ */
250
+ export const keyframeAt = (stops: ArrayLike<number>, stopTimes: ReadonlyArray<number>, eases: ReadonlyArray<Easing.Easing>, pass: Pass, duration: number): number => {
251
+ // Read before the ease runs: it's the app's code, and may step another run, which writes a shared pass (#618).
252
+ const flipped = pass.flipped
253
+ const time = timeIn(pass, duration)
254
+ const i = intervalAt(time, stopTimes)
255
+ const eased = eases[i % eases.length](intervalProgress(time, stopTimes, i))
256
+ const last = stops.length - 1
257
+ if (flipped) return Scalar.lerp(stops[last - i], stops[last - i - 1], eased)
258
+ return Scalar.lerp(stops[i], stops[i + 1], eased)
259
+ }
260
+
245
261
  // --- Decay -------------------------------------------------------------------
246
262
 
247
263
  export interface DecayState {
@@ -7,6 +7,7 @@ import { constFalse } from "effect/Function"
7
7
  import * as Queue from "effect/Queue"
8
8
  import type * as Scope from "effect/Scope"
9
9
  import * as Stream from "effect/Stream"
10
+ import * as UndefinedOr from "effect/UndefinedOr"
10
11
  import * as InputFeed from "../InputFeed.ts"
11
12
  import { tracedScoped } from "./tracing.ts"
12
13
 
@@ -53,3 +54,17 @@ export const streamOf = <A, R>(
53
54
  },
54
55
  })
55
56
  )
57
+
58
+ /** An InputSource's feed over many targets, or a defect naming it: an Environment without one can't watch many targets as one. */
59
+ // #665's PR 5; shared by the hover's, the press's and the drag's watches over many targets (#712).
60
+ export const amongFeed = <A>(feed: A | undefined, name: string): Effect.Effect<A> =>
61
+ UndefinedOr.match(feed, {
62
+ onUndefined: () => Effect.die(new Error(`wardic: the Environment's InputSource has no \`${name}\`, which a gesture over many targets needs`)),
63
+ onDefined: Effect.succeed,
64
+ })
65
+
66
+ /** A watch's handlers over many targets: `on`, each target's start and end, with the target. */
67
+ // #665's PR 5 (Q56).
68
+ export interface AmongHandlers<A> extends Pick<InputFeed.Handlers<never>, "onDefect" | "onEnd" | "onStop"> {
69
+ readonly on: (target: unknown, value: A) => void
70
+ }