@wardic/dom 1.3.1 → 1.4.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.
Files changed (143) hide show
  1. package/dist/MeasuredPair.d.ts +14 -1
  2. package/dist/MeasuredPair.d.ts.map +1 -1
  3. package/dist/MeasuredPair.js +11 -13
  4. package/dist/MeasuredPair.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +5 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal/appear.d.ts +6 -0
  10. package/dist/internal/appear.d.ts.map +1 -1
  11. package/dist/internal/appear.js +20 -2
  12. package/dist/internal/appear.js.map +1 -1
  13. package/dist/internal/batch-handoff.d.ts.map +1 -1
  14. package/dist/internal/batch-handoff.js +25 -15
  15. package/dist/internal/batch-handoff.js.map +1 -1
  16. package/dist/internal/batch-writer.d.ts +1 -1
  17. package/dist/internal/batch-writer.d.ts.map +1 -1
  18. package/dist/internal/batch-writer.js +32 -16
  19. package/dist/internal/batch-writer.js.map +1 -1
  20. package/dist/internal/clock.d.ts +6 -0
  21. package/dist/internal/clock.d.ts.map +1 -1
  22. package/dist/internal/clock.js +27 -0
  23. package/dist/internal/clock.js.map +1 -1
  24. package/dist/internal/default-transition.d.ts +3 -2
  25. package/dist/internal/default-transition.d.ts.map +1 -1
  26. package/dist/internal/default-transition.js +28 -3
  27. package/dist/internal/default-transition.js.map +1 -1
  28. package/dist/internal/failing.d.ts +9 -0
  29. package/dist/internal/failing.d.ts.map +1 -0
  30. package/dist/internal/failing.js +33 -0
  31. package/dist/internal/failing.js.map +1 -0
  32. package/dist/internal/length-keys.d.ts +19 -0
  33. package/dist/internal/length-keys.d.ts.map +1 -0
  34. package/dist/internal/length-keys.js +77 -0
  35. package/dist/internal/length-keys.js.map +1 -0
  36. package/dist/internal/measured-pairs.d.ts +3 -2
  37. package/dist/internal/measured-pairs.d.ts.map +1 -1
  38. package/dist/internal/measured-pairs.js +60 -23
  39. package/dist/internal/measured-pairs.js.map +1 -1
  40. package/dist/internal/own-values.d.ts.map +1 -1
  41. package/dist/internal/own-values.js +2 -2
  42. package/dist/internal/own-values.js.map +1 -1
  43. package/dist/internal/positional-keys.d.ts +1 -1
  44. package/dist/internal/positional-keys.d.ts.map +1 -1
  45. package/dist/internal/positional-keys.js +4 -2
  46. package/dist/internal/positional-keys.js.map +1 -1
  47. package/dist/internal/projection.d.ts.map +1 -1
  48. package/dist/internal/projection.js +180 -46
  49. package/dist/internal/projection.js.map +1 -1
  50. package/dist/internal/renderer.d.ts +59 -27
  51. package/dist/internal/renderer.d.ts.map +1 -1
  52. package/dist/internal/renderer.js +241 -207
  53. package/dist/internal/renderer.js.map +1 -1
  54. package/dist/internal/scroll.d.ts.map +1 -1
  55. package/dist/internal/scroll.js +26 -2
  56. package/dist/internal/scroll.js.map +1 -1
  57. package/dist/internal/starting-style.js +5 -5
  58. package/dist/internal/transform-keys.d.ts +23 -0
  59. package/dist/internal/transform-keys.d.ts.map +1 -0
  60. package/dist/internal/transform-keys.js +55 -0
  61. package/dist/internal/transform-keys.js.map +1 -0
  62. package/dist/unstable/AppearAnimations.d.ts +2 -1
  63. package/dist/unstable/AppearAnimations.d.ts.map +1 -1
  64. package/dist/unstable/AppearAnimations.js +73 -22
  65. package/dist/unstable/AppearAnimations.js.map +1 -1
  66. package/dist/unstable/BatchMembers.d.ts +2 -2
  67. package/dist/unstable/BatchMembers.d.ts.map +1 -1
  68. package/dist/unstable/BatchMembers.js +30 -7
  69. package/dist/unstable/BatchMembers.js.map +1 -1
  70. package/dist/unstable/DomValues.js +1 -1
  71. package/dist/unstable/DomValues.js.map +1 -1
  72. package/dist/unstable/DragTrack.d.ts +2 -2
  73. package/dist/unstable/DragTrack.d.ts.map +1 -1
  74. package/dist/unstable/DragTrack.js +37 -10
  75. package/dist/unstable/DragTrack.js.map +1 -1
  76. package/dist/unstable/ElementSetup.d.ts.map +1 -1
  77. package/dist/unstable/ElementSetup.js +3 -2
  78. package/dist/unstable/ElementSetup.js.map +1 -1
  79. package/dist/unstable/GestureFeatures.d.ts +8 -2
  80. package/dist/unstable/GestureFeatures.d.ts.map +1 -1
  81. package/dist/unstable/GestureFeatures.js +26 -40
  82. package/dist/unstable/GestureFeatures.js.map +1 -1
  83. package/dist/unstable/GestureInfo.d.ts +11 -0
  84. package/dist/unstable/GestureInfo.d.ts.map +1 -1
  85. package/dist/unstable/GestureInfo.js +8 -0
  86. package/dist/unstable/GestureInfo.js.map +1 -1
  87. package/dist/unstable/Imperative.d.ts +1 -1
  88. package/dist/unstable/Imperative.d.ts.map +1 -1
  89. package/dist/unstable/Imperative.js.map +1 -1
  90. package/dist/unstable/LiveStyle.d.ts +28 -2
  91. package/dist/unstable/LiveStyle.d.ts.map +1 -1
  92. package/dist/unstable/LiveStyle.js +8 -32
  93. package/dist/unstable/LiveStyle.js.map +1 -1
  94. package/dist/unstable/MemberHold.js +3 -3
  95. package/dist/unstable/MemberHold.js.map +1 -1
  96. package/dist/unstable/PointerValues.d.ts.map +1 -1
  97. package/dist/unstable/PointerValues.js +82 -8
  98. package/dist/unstable/PointerValues.js.map +1 -1
  99. package/dist/unstable/PresenceController.d.ts +5 -2
  100. package/dist/unstable/PresenceController.d.ts.map +1 -1
  101. package/dist/unstable/PresenceController.js +82 -55
  102. package/dist/unstable/PresenceController.js.map +1 -1
  103. package/dist/unstable/ReorderInput.d.ts +2 -2
  104. package/dist/unstable/ReorderInput.js +2 -2
  105. package/dist/unstable/WardConfig.d.ts +18 -9
  106. package/dist/unstable/WardConfig.d.ts.map +1 -1
  107. package/dist/unstable/WardConfig.js.map +1 -1
  108. package/dist/unstable/features/TimelineKeys.d.ts.map +1 -1
  109. package/dist/unstable/features/TimelineKeys.js +19 -3
  110. package/dist/unstable/features/TimelineKeys.js.map +1 -1
  111. package/package.json +3 -3
  112. package/src/MeasuredPair.ts +21 -1
  113. package/src/index.ts +4 -1
  114. package/src/internal/appear.ts +20 -2
  115. package/src/internal/batch-handoff.ts +19 -11
  116. package/src/internal/batch-writer.ts +32 -16
  117. package/src/internal/clock.ts +28 -0
  118. package/src/internal/default-transition.ts +28 -4
  119. package/src/internal/failing.ts +37 -0
  120. package/src/internal/length-keys.ts +80 -0
  121. package/src/internal/measured-pairs.ts +58 -22
  122. package/src/internal/own-values.ts +2 -2
  123. package/src/internal/positional-keys.ts +4 -2
  124. package/src/internal/projection.ts +190 -44
  125. package/src/internal/renderer.ts +272 -198
  126. package/src/internal/scroll.ts +24 -2
  127. package/src/internal/starting-style.ts +5 -5
  128. package/src/internal/transform-keys.ts +59 -0
  129. package/src/unstable/AppearAnimations.ts +73 -24
  130. package/src/unstable/BatchMembers.ts +33 -9
  131. package/src/unstable/DomValues.ts +1 -1
  132. package/src/unstable/DragTrack.ts +49 -14
  133. package/src/unstable/ElementSetup.ts +3 -2
  134. package/src/unstable/GestureFeatures.ts +38 -47
  135. package/src/unstable/GestureInfo.ts +24 -0
  136. package/src/unstable/Imperative.ts +1 -0
  137. package/src/unstable/LiveStyle.ts +12 -8
  138. package/src/unstable/MemberHold.ts +3 -3
  139. package/src/unstable/PointerValues.ts +73 -8
  140. package/src/unstable/PresenceController.ts +80 -54
  141. package/src/unstable/ReorderInput.ts +2 -2
  142. package/src/unstable/WardConfig.ts +22 -10
  143. package/src/unstable/features/TimelineKeys.ts +20 -3
@@ -88,6 +88,7 @@ import type * as WardicServices from "@wardic/core/unstable/WardicServices"
88
88
  import type * as WardConfig from "./WardConfig.ts"
89
89
  import * as DragControls from "./DragControls.ts"
90
90
  import * as DragTransition from "./DragTransition.ts"
91
+ import * as Failing from "../internal/failing.ts"
91
92
  import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue"
92
93
 
93
94
 
@@ -170,8 +171,8 @@ export type TrackServices = WardicServices.WardicServices | InputSource.InputSou
170
171
  export interface DragTrackOptions {
171
172
  /**
172
173
  * Runs the track in the element's watch Scope: its watches subscribed now, with no
173
- * fiber, until the element goes and the Scope closes, which stops a running release. A throw from a
174
- * watch's fold goes to the `onDefect` it's given (#209: each binding owns the Scope).
174
+ * fiber, until the element goes and the Scope closes, which stops a running release. A run of throws
175
+ * from a watch's fold goes to the `onDefect` it's given, at its first (#209: each binding owns the Scope).
175
176
  */
176
177
  readonly watch: (track: (onDefect: InputFeed.OnDefect) => Effect.Effect<void, never, Scope.Scope | TrackServices>) => void
177
178
  /**
@@ -292,6 +293,17 @@ interface DragTrackState {
292
293
  /** The track's one cell, written by its handlers and by its release's sink, never at once. */
293
294
  type TrackState = MutableRef.MutableRef<DragTrackState>
294
295
 
296
+ /** A track's kinds of failure, each with its own run: a response at each sample, a measure, a release. */
297
+ // #979 group I, row 28 (ADR-0074 decision 3): each was reported at every throw.
298
+ type TrackFailure = "release" | "measuring" | "response"
299
+
300
+ /** `report`, at the start of a run of `kind`'s failures on the track: nothing while one is on. */
301
+ const atRunStart = (failing: Failing.Failing<TrackFailure>, kind: TrackFailure, report: Effect.Effect<void>): Effect.Effect<void> =>
302
+ Effect.suspend(() => {
303
+ if (Failing.firstThrowOf(failing, kind)) return report
304
+ return Effect.void
305
+ })
306
+
295
307
  const ORIGIN: Point.Point = { x: 0, y: 0 }
296
308
 
297
309
  /**
@@ -559,6 +571,7 @@ const release = (
559
571
  position: Point.Point,
560
572
  velocity: Point.Point,
561
573
  taken: Deferred.Deferred<void>,
574
+ failing: Failing.Failing<TrackFailure>,
562
575
  ): Effect.Effect<void, never, FrameLoop.FrameLoop> => {
563
576
  const cfg = opts.config
564
577
 
@@ -580,6 +593,11 @@ const release = (
580
593
  opts.setDragging(false)
581
594
  UndefinedOr.map(opts.onReleaseEnd, (ended) => opts.gate.afterFlush(ended))
582
595
  })
596
+ // A release that dies is reported at the first of the track's run of them, and rests where it was
597
+ // dropped; one that lands ends the run.
598
+ const failed = (defect: unknown): Effect.Effect<void> =>
599
+ atRunStart(failing, "release", Report.failure("wardic.drag: a release failed", Cause.die(defect))).pipe(Effect.andThen(Effect.sync(() => tapFrame(position, ORIGIN))))
600
+ const landed = Effect.sync(() => Failing.endRunOf(failing, "release"))
583
601
  const { axis, bounds } = MutableRef.get(state)
584
602
  const edges = edgesOf(cfg, bounds)
585
603
  const v = releaseVelocity(cfg, velocity)
@@ -608,7 +626,8 @@ const release = (
608
626
  keepVelocity(opts, ORIGIN)
609
627
  if (MutableRef.get(state).releasing) directSet(opts, restOfRelease(position, v, axis, edges, transition))
610
628
  }).pipe(
611
- Effect.catchDefect((defect) => Report.failure("wardic.drag: a release failed", Cause.die(defect)).pipe(Effect.andThen(Effect.sync(() => tapFrame(position, ORIGIN))))),
629
+ Effect.andThen(landed),
630
+ Effect.catchDefect(failed),
612
631
  Effect.andThen(Microtask.next),
613
632
  Effect.andThen(done),
614
633
  ),
@@ -626,8 +645,8 @@ const release = (
626
645
  Machine.run((frame) => tapFrame({ x: position.x, y: frame.value }, { x: 0, y: frame.velocity })),
627
646
  )),
628
647
  Match.orElse(() => Machine.inertiaVec(position, v, { ...transition, ...edges }).pipe(Machine.run((frame) => tapFrame(frame.value, frame.velocity)))),
629
- Effect.catchDefect((defect) =>
630
- Report.failure("wardic.drag: a release failed", Cause.die(defect)).pipe(Effect.andThen(Effect.sync(() => tapFrame(position, ORIGIN))))),
648
+ Effect.andThen(landed),
649
+ Effect.catchDefect(failed),
631
650
  Effect.andThen(done),
632
651
  ),
633
652
  )
@@ -724,13 +743,18 @@ export const driveDragTrack = (opts: DragTrackOptions): DragTrack => {
724
743
  const watching = yield* FiberHandle.make<void>()
725
744
  let watched: Element | undefined = undefined
726
745
  let warned = false
746
+ const failing: Failing.Failing<TrackFailure> = { failing: undefined }
727
747
  const setBounds = (bounds: Drag.Bounds | undefined): void => {
728
748
  MutableRef.update(state, (st) => ({ ...st, bounds }))
729
749
  }
730
750
  /** The bounds measured against `container`'s `box`; none, reported, if measuring throws (an app's `onMeasureDragConstraints`). */
731
751
  const measured = (container: DragConstraints.DragContainer, box: Element): Effect.Effect<Drag.Bounds | undefined> =>
732
- Effect.sync((): Drag.Bounds | undefined => container.bounds(box)).pipe(
733
- Effect.catchDefect((defect) => Report.failure("wardic.drag: measuring dragConstraints failed", Cause.die(defect)).pipe(Effect.as(undefined))),
752
+ Effect.sync((): Drag.Bounds | undefined => {
753
+ const bounds = container.bounds(box)
754
+ Failing.endRunOf(failing, "measuring")
755
+ return bounds
756
+ }).pipe(
757
+ Effect.catchDefect((defect) => atRunStart(failing, "measuring", Report.failure("wardic.drag: measuring dragConstraints failed", Cause.die(defect))).pipe(Effect.as(undefined))),
734
758
  )
735
759
  /**
736
760
  * A resize of the element or its container: the bounds measured again. The first measure only
@@ -827,7 +851,7 @@ export const driveDragTrack = (opts: DragTrackOptions): DragTrack => {
827
851
  taken = Deferred.makeUnsafe<void>()
828
852
  return taken
829
853
  }).pipe(
830
- Effect.flatMap((ended) => FiberHandle.run(releasing, release(opts, state, position, velocity, ended))),
854
+ Effect.flatMap((ended) => FiberHandle.run(releasing, release(opts, state, position, velocity, ended, failing))),
831
855
  Effect.asVoid,
832
856
  )
833
857
 
@@ -854,9 +878,10 @@ export const driveDragTrack = (opts: DragTrackOptions): DragTrack => {
854
878
  FiberHandle.clear(releasing).pipe(Effect.andThen(measureAtStart), Effect.andThen(Effect.sync(() => follow(sample, state, opts))))),
855
879
  Match.when("move", () =>
856
880
  FiberHandle.clear(releasing).pipe(Effect.andThen(Effect.sync(() => follow(sample, state, opts))))),
857
- // A cancelled end (#431) stays where it is: no release, `x`/`y` handed back.
881
+ // An end drag controls cancelled (#431) stays where it is: no release, `x`/`y` handed back. Any
882
+ // other is released, a pointer's cancel too, which carries no velocity and so doesn't fling (#1042).
858
883
  Match.when("end", () =>
859
- Bool.match(sample.cancelled === true, {
884
+ Bool.match(sample.endedBy === "controls", {
860
885
  onTrue: () => Effect.sync(() => UndefinedOr.match(opts.projection, { onUndefined: () => opts.setDragging(false), onDefined: constVoid })),
861
886
  onFalse: () => releaseFrom(sample),
862
887
  }).pipe(Effect.andThen(Effect.sync(() => reportSample(opts, sample))))),
@@ -911,11 +936,21 @@ export const driveDragTrack = (opts: DragTrackOptions): DragTrack => {
911
936
  })
912
937
 
913
938
  /**
914
- * A response, run inside its event (`opts.fork`): one that fails is reported, and the next
915
- * event's runs (ADR-0055 *Amendment (#379)*, Q4). A release reports its own (#66).
939
+ * A response, run inside its event (`opts.fork`): one that fails is reported at the first of a run
940
+ * of them, and the next event's runs (ADR-0055 *Amendment (#379)*, Q4). A release reports its own (#66).
916
941
  */
917
- const respond = (response: Effect.Effect<void, never, FrameLoop.FrameLoop>): void =>
918
- opts.fork(response.pipe(Effect.catchCause((cause) => Report.failure("wardic.drag: a response failed", cause))))
942
+ // Made once a track: a sample's response allocates nothing more than its fold. An interruption
943
+ // neither starts a run nor ends one.
944
+ const responded = Effect.sync(() => Failing.endRunOf(failing, "response"))
945
+ const responseExits = {
946
+ onSuccess: () => responded,
947
+ onFailure: (cause: Cause.Cause<never>): Effect.Effect<void> =>
948
+ Bool.match(Cause.hasInterruptsOnly(cause), {
949
+ onTrue: () => Effect.void,
950
+ onFalse: () => atRunStart(failing, "response", Report.failure("wardic.drag: a response failed", cause)),
951
+ }),
952
+ }
953
+ const respond = (response: Effect.Effect<void, never, FrameLoop.FrameLoop>): void => opts.fork(Effect.matchCauseEffect(response, responseExits))
919
954
 
920
955
  // Subscribed in this order, so the samples hear an event before the grabs. The constraints
921
956
  // bound the element's x/y, so they're applied where the gesture's offset meets its base, in
@@ -43,6 +43,7 @@ import * as LiveStyle from "./LiveStyle.ts"
43
43
  import * as Spine from "@wardic/core/unstable/Spine"
44
44
  import * as VariantTree from "@wardic/core/unstable/VariantTree"
45
45
  import * as VariantTarget from "@wardic/core/unstable/VariantTarget"
46
+ import * as TransformKeys from "../internal/transform-keys.ts"
46
47
 
47
48
  /**
48
49
  * A mounted element's Base-value links (ADR-0022): a key with no value starts from its `style`
@@ -92,7 +93,7 @@ export const restingOf = (key: string, initial: Values.Values, style: object | s
92
93
  Option.getOrUndefined(
93
94
  Option.fromUndefinedOr(initial[key]).pipe(
94
95
  Option.orElse((): Option.Option<unknown> => Option.flatMap(OwnValues.styleValueOf(style, key), (raw) => Option.fromNullishOr(read(raw)))),
95
- Option.orElse((): Option.Option<unknown> => BaseValue.transformIdentity(key)),
96
+ Option.orElse((): Option.Option<unknown> => TransformKeys.transformIdentity(key)),
96
97
  ),
97
98
  )
98
99
 
@@ -238,7 +239,7 @@ const filled = new WeakMap<ValueReads, ElementValueReads>()
238
239
  * nothing.
239
240
  */
240
241
  export const valueReadsOf = (given: ValueReads): ElementValueReads => {
241
- // Per element at mount (#540): statements. `DomLive` gives none: the DOM's, with no lookup.
242
+ // Per Subject at mount (#540): statements. `DomLive` gives none: the DOM's, with no lookup.
242
243
  if (Bool.and(Predicate.isUndefined(given.ownValues), Bool.and(Predicate.isUndefined(given.measuredPairs), Predicate.isUndefined(given.variableValues)))) return DOM_VALUE_READS
243
244
  const kept = filled.get(given)
244
245
  if (Predicate.isNotUndefined(kept)) return kept
@@ -18,9 +18,9 @@ import * as Context from "effect/Context"
18
18
  import * as Match from "effect/Match"
19
19
  import * as Option from "effect/Option"
20
20
  import * as Predicate from "effect/Predicate"
21
- import { constUndefined, identity } from "effect/Function"
22
- import * as MutableRef from "effect/MutableRef"
21
+ import { constUndefined } from "effect/Function"
23
22
  import * as UndefinedOr from "effect/UndefinedOr"
23
+ import * as Failing from "../internal/failing.ts"
24
24
  import * as GestureInfo from "./GestureInfo.ts"
25
25
 
26
26
  /** `key`'s service among `services`, or `undefined` when they hold none: its Feature isn't there. */
@@ -176,15 +176,28 @@ export interface Telling {
176
176
  readonly invoke: (handler: unknown, args: ReadonlyArray<unknown>) => void
177
177
  /** Report that the callback `name` threw `defect`. */
178
178
  readonly report: (name: GestureCallbackName, defect: unknown) => void
179
+ /**
180
+ * Whether a drag's and a pan's end callbacks are told how it ended, as `endedBy` (#1042): Solid 1's
181
+ * are. Absent, their info is a move's, as Foldkit's is.
182
+ */
183
+ readonly tellsEndedBy?: boolean | undefined
179
184
  }
180
185
 
186
+ /** A drag's or a pan's sample's info: an end's with how it ended, where its binding tells it (#1042). */
187
+ const movementInfoOf = (tellsEndedBy: boolean, sample: Drag.Sample): GestureInfo.WardicDragInfo =>
188
+ Bool.match(Bool.and(tellsEndedBy, sample.phase === "end"), {
189
+ onTrue: (): GestureInfo.WardicDragInfo => GestureInfo.dragEndInfoOf(sample),
190
+ onFalse: () => GestureInfo.dragInfoOf(sample),
191
+ })
192
+
181
193
  /**
182
194
  * What tells an element's gestures to its config's callbacks, for every binding (#273, ADR-0047):
183
195
  * Motion's `(event, info)`, the platform's own event carried through (`raw`), then the info
184
196
  * (`GestureInfo`), in Motion's order: a locked drag's `onDirectionLock` before its `onDragStart`, a
185
197
  * pan's `onPanSessionStart` at the down with the point alone, `onDrag` and `onPan` at the start and
186
198
  * each move after. A drag its controls cancelled ends untold (#431). A callback that throws is reported
187
- * by name and the gesture goes on; `onDrag`'s and `onPan`'s run of throws at its first (#257 item 4).
199
+ * by name at the first of a run of throws, its next clean call ending the run, and the gesture goes on
200
+ * (#257 item 4).
188
201
  */
189
202
  export interface GestureTeller {
190
203
  readonly hovered: (edge: Recognizer.Edge) => void
@@ -202,13 +215,13 @@ type MovementCallback = "onDragStart" | "onDragEnd" | "onPanStart" | "onPanEnd"
202
215
 
203
216
  /** A {@link GestureTeller} over `telling`'s config, invoking and reporting as the binding says. */
204
217
  // #793 (PR 2): solid's `gestureCallbacksOf`, moved to dom for both bindings: each gives how a handler is invoked.
205
- export const gestureTellerOf = ({ config, invoke, report }: Telling): GestureTeller => {
218
+ export const gestureTellerOf = ({ config, invoke, report, tellsEndedBy }: Telling): GestureTeller => {
206
219
  const guard = callbackGuard(report)
207
- /** Tell the config's `name`, if it has one, `args`: reported if it throws. */
220
+ /** Tell the config's `name`, if it has one, `args`: reported at a run of throws' first. */
208
221
  const tell = (name: GestureCallbackName, ...args: ReadonlyArray<unknown>): void => {
209
222
  const handler = config()[name]
210
223
  if (Predicate.isUndefined(handler)) return
211
- guard.once(name, () => invoke(handler, args))
224
+ guard(name, () => invoke(handler, args))
212
225
  }
213
226
  /**
214
227
  * A drag's or a pan's sample, past a pan's session's start: its start's or its end's callback
@@ -221,9 +234,9 @@ export const gestureTellerOf = ({ config, invoke, report }: Telling): GestureTel
221
234
  const each = Bool.match(sample.phase !== "end", { onTrue: () => c[every], onFalse: constUndefined })
222
235
  if (Bool.and(Predicate.isUndefined(own), Predicate.isUndefined(each))) return
223
236
  const raw = sample.raw as PointerEvent
224
- const info = GestureInfo.dragInfoOf(sample)
225
- UndefinedOr.map(named, (key) => UndefinedOr.map(own, (handler) => guard.once(key, () => invoke(handler, [raw, info]))))
226
- UndefinedOr.map(each, (handler) => guard.perMove(every, () => invoke(handler, [raw, info])))
237
+ const info = movementInfoOf(tellsEndedBy === true, sample)
238
+ UndefinedOr.map(named, (key) => UndefinedOr.map(own, (handler) => guard(key, () => invoke(handler, [raw, info]))))
239
+ UndefinedOr.map(each, (handler) => guard(every, () => invoke(handler, [raw, info])))
227
240
  }
228
241
  return {
229
242
  hovered: (edge) => {
@@ -237,7 +250,7 @@ export const gestureTellerOf = ({ config, invoke, report }: Telling): GestureTel
237
250
  },
238
251
  dragged: (sample) => {
239
252
  // A drag its controls cancelled (#431) ends untold, as Motion's `cancel` tells no `onDragEnd`.
240
- if (sample.cancelled === true) return
253
+ if (sample.endedBy === "controls") return
241
254
  // A direction-locked drag's lock, at its start, before `onDragStart` (Motion's order).
242
255
  if (Bool.and(sample.phase === "start", config().dragDirectionLock === true)) tell("onDirectionLock", sample.axis as "x" | "y")
243
256
  moved(DRAG_CALLBACK[sample.phase], "onDrag", sample)
@@ -259,48 +272,26 @@ export const gestureTellerOf = ({ config, invoke, report }: Telling): GestureTel
259
272
  }
260
273
 
261
274
  /**
262
- * A guard around an element's gesture callbacks (#257 item 4): `once` runs `call` and reports what it
263
- * throws; `perMove`, for `onDrag` and `onPan`, reports a run of throws at its first, so one that throws
264
- * at every move logs once, and a call that returns ends the run. The gesture goes on either way.
275
+ * A guard around an element's gesture callbacks (#257 item 4): runs `call`, and reports a run of its
276
+ * throws at the first, so one that throws at every move, or at every hover, logs once, and a call that
277
+ * returns ends the run. Each callback name has its own run, and the gesture goes on either way.
265
278
  */
266
- interface CallbackGuard {
267
- readonly once: (name: GestureCallbackName, call: () => void) => void
268
- readonly perMove: (name: GestureCallbackName, call: () => void) => void
269
- }
279
+ type CallbackGuard = (name: GestureCallbackName, call: () => void) => void
270
280
 
271
281
  /** A {@link CallbackGuard} reporting through `report`, told the callback's name and what it threw. */
272
282
  // #793 (PR 2): solid's `gesture-callbacks.ts`'s `call` and `callPerMove`, moved to dom with the teller.
283
+ // #979 group I, row 26 (ADR-0074 decision 3): the two were one-throw-a-report (`once`) and once a run
284
+ // (`perMove`, for `onDrag` and `onPan`); a hover's or a tap's callback is called again at each, so both
285
+ // are once a run now, one guard.
273
286
  const callbackGuard = (report: Telling["report"]): CallbackGuard => {
274
- // The per-move callbacks whose last call threw, made at the first throw: most elements never see one.
275
- const failing = MutableRef.make<Set<string> | undefined>(undefined)
276
- const failingNow = (): Set<string> =>
277
- UndefinedOr.match(MutableRef.get(failing), {
278
- onUndefined: () => {
279
- const made = new Set<string>()
280
- MutableRef.set(failing, made)
281
- return made
282
- },
283
- onDefined: identity,
284
- })
285
- return {
286
- once: (name, call) => {
287
- try {
288
- call()
289
- } catch (defect) {
290
- report(name, defect)
291
- }
292
- },
293
- perMove: (name, call) => {
294
- try {
295
- call()
296
- UndefinedOr.map(MutableRef.get(failing), (names) => names.delete(name))
297
- } catch (defect) {
298
- const names = failingNow()
299
- if (names.has(name)) return
300
- names.add(name)
301
- report(name, defect)
302
- }
303
- },
287
+ const runs: Failing.Failing<GestureCallbackName> = { failing: undefined }
288
+ return (name, call) => {
289
+ try {
290
+ call()
291
+ Failing.endRunOf(runs, name)
292
+ } catch (defect) {
293
+ if (Failing.firstThrowOf(runs, name)) report(name, defect)
294
+ }
304
295
  }
305
296
  }
306
297
 
@@ -13,6 +13,7 @@
13
13
  import type * as Drag from "@wardic/core/Drag"
14
14
  import type * as InputSource from "@wardic/core/InputSource"
15
15
  import type * as Recognizer from "@wardic/core/Recognizer"
16
+ import * as Match from "effect/Match"
16
17
 
17
18
  /** A point in the viewport. */
18
19
  export interface WardicPoint {
@@ -38,6 +39,16 @@ export interface WardicDragInfo {
38
39
  readonly velocity: WardicPoint
39
40
  }
40
41
 
42
+ /** A drag's or a pan's end (Motion's `PanInfo` at `onDragEnd`): its {@link WardicDragInfo}, and how it ended (#1042). */
43
+ export interface WardicDragEndInfo extends WardicDragInfo {
44
+ /**
45
+ * How it ended: `"release"`, let go; `"cancel"`, the platform took the pointer away (a `pointercancel`:
46
+ * the page scrolled under a touch), which doesn't fling; `"lost"`, its release never came (a **Stale
47
+ * gesture**). A drag its controls cancelled tells no end.
48
+ */
49
+ readonly endedBy: Exclude<Drag.EndedBy, "controls">
50
+ }
51
+
41
52
  /** How a press was made: by a pointer, or a **Keyboard press**. */
42
53
  export type WardicPressInput = "pointer" | "keyboard"
43
54
 
@@ -71,6 +82,19 @@ export const pointInfoOf = (event: InputSource.PointerLikeEvent): WardicPointInf
71
82
  /** What a drag's or a pan's sample carries for its info. */
72
83
  type Sampled = Pick<Drag.Sample, "point" | "scroll" | "offset" | "delta" | "velocity">
73
84
 
85
+ /**
86
+ * How a told end ended (#1042): a pointer's cancel, a lost release, or a release. Drag controls' cancel
87
+ * is never told, and a pan has none. Built once, at module load.
88
+ */
89
+ const endedByOf: (sample: Pick<Drag.Sample, "endedBy">) => WardicDragEndInfo["endedBy"] = /*#__PURE__*/ Match.type<Pick<Drag.Sample, "endedBy">>().pipe(
90
+ Match.when({ endedBy: "cancel" }, (): WardicDragEndInfo["endedBy"] => "cancel"),
91
+ Match.when({ endedBy: "lost" }, (): WardicDragEndInfo["endedBy"] => "lost"),
92
+ Match.orElse((): WardicDragEndInfo["endedBy"] => "release"),
93
+ )
94
+
95
+ /** A drag's or a pan's end sample's info: {@link dragInfoOf}'s, and how it ended (#1042). */
96
+ export const dragEndInfoOf = (sample: Sampled & Pick<Drag.Sample, "endedBy">): WardicDragEndInfo => ({ ...dragInfoOf(sample), endedBy: endedByOf(sample) })
97
+
74
98
  /** A drag sample's info: its point less the scroll its hold counted into it, and its own offset, delta and velocity. */
75
99
  export const dragInfoOf = (sample: Sampled): WardicDragInfo => ({
76
100
  point: { x: sample.point.x - sample.scroll.x, y: sample.point.y - sample.scroll.y },
@@ -41,6 +41,7 @@ export type {
41
41
  AnimateEnv,
42
42
  AnimationWatch,
43
43
  WardicAnimateOptions,
44
+ WardicAnimationEnd,
44
45
  WardicFunctionSegment,
45
46
  WardicPlaybackControls,
46
47
  WardicPlayState,
@@ -3,8 +3,9 @@
3
3
  * flush gate, what each is now, and when one changes.
4
4
  *
5
5
  * A key is **routed** when its value is live (an `effect/reactivity` Atom, or an accessor: a signal,
6
- * a memo, `createTransform`'s) or when it's a transform key (`x`, `scale`, `rotate`…), live or not
7
- * (decisions 2 and 4). A routed key is the key's `style` link, followed while no entry of the
6
+ * a memo, `createTransform`'s), when it's a transform key (`x`, `scale`, `rotate`…), live or not
7
+ * (decisions 2 and 4), or when it's a bare number on a length (`width: 200`), which the renderer
8
+ * draws in px and a binding's own `style` would write as it is. A routed key is the key's `style` link, followed while no entry of the
8
9
  * Override stack sets it (decision 1), and Wardic writes it: the gate composes the transform keys
9
10
  * into `transform` with its own, and commits the rest once a frame. So the binding's `style` never
10
11
  * carries one. A user's own `transform` string applies while no transform key is set; with one,
@@ -25,7 +26,6 @@
25
26
  */
26
27
  // Unstable: ADR-0071, decision 5. #672 (PR3-Q1): solid's `live-style.ts`, the DOM's `style` prop, moved
27
28
  // to dom for every DOM binding; the spine reads it through its LiveRoutes.
28
- import * as BaseValue from "@wardic/core/BaseValue"
29
29
  import type * as InterpolatorRegistry from "@wardic/core/InterpolatorRegistry"
30
30
  import * as LiveValue from "@wardic/core/LiveValue"
31
31
  import type * as Values from "@wardic/core/Values"
@@ -45,6 +45,8 @@ import type * as Config from "@wardic/core/unstable/Config"
45
45
  import type * as Reactivity from "@wardic/core/unstable/Reactivity"
46
46
  import type * as RetargetLegs from "@wardic/core/unstable/RetargetLegs"
47
47
  import type * as WardicServices from "@wardic/core/unstable/WardicServices"
48
+ import { LENGTH_KEY_SET } from "../internal/length-keys.ts"
49
+ import * as TransformKeys from "../internal/transform-keys.ts"
48
50
 
49
51
  /**
50
52
  * A live value as a binding takes it: an accessor, such as a signal, a memo or another live value, or an
@@ -170,8 +172,8 @@ export const rangesOf = (
170
172
  ): Effect.Effect<Atom.Atom<unknown>, never, InterpolatorRegistry.InterpolatorRegistry> =>
171
173
  LiveValue.transform(source as Atom.Atom<number>, input, output as ReadonlyArray<number | string>, options as LiveValue.TransformOptions | undefined)
172
174
 
173
- /** Whether `key` is a transform key, composed into `transform` (`x`, `scale`, `rotate`…). */
174
- export const isTransformKey = (key: string): boolean => Option.isSome(BaseValue.transformIdentity(key))
175
+ /** Whether `key` is one of the DOM's transform keys, composed into `transform` (`x`, `scale`, `rotate`, `transformPerspective`…). */
176
+ export const isTransformKey: (key: string) => boolean = TransformKeys.isTransformKey
175
177
 
176
178
  /** A style value, read now: an Atom (or the one an accessor carries) through `registry`, an accessor untracked, anything else as it is. */
177
179
  export const readLive = (value: unknown, registry: () => AtomRegistry.AtomRegistry, untrack: Reactivity.Reactivity["untrack"]): unknown => {
@@ -181,15 +183,17 @@ export const readLive = (value: unknown, registry: () => AtomRegistry.AtomRegist
181
183
  return value
182
184
  }
183
185
 
184
- /** Whether a style's `key` is routed: its value is live, or it's a transform key with a value. */
186
+ /** Whether a style's `key` is routed: its value is live, it's a transform key with a value, or a number on a length. */
187
+ // #887 (ADR-0073, *Amendment (#887)*): `style={{ width: 200 }}` typechecks (#522), but Solid writes "200",
188
+ // which a browser drops, so nothing was drawn; the renderer writes "200px".
185
189
  const isRouted = (value: unknown, key: string): boolean =>
186
- Bool.and(Predicate.isNotNullish(value), Bool.or(isLive(value), isTransformKey(key)))
190
+ Bool.and(Predicate.isNotNullish(value), Bool.or(Bool.or(isLive(value), isTransformKey(key)), Bool.and(Predicate.isNumber(value), LENGTH_KEY_SET.has(key))))
187
191
 
188
192
  /** A user's style split: what its binding's `style` carries, and the routed keys' sources. */
189
193
  export interface Split {
190
194
  /** The style without the routed keys. The user's own when nothing is routed. */
191
195
  readonly css: StyleInput
192
- /** Each routed key's value as given: an Atom, an accessor, or a transform key's plain value. */
196
+ /** Each routed key's value as given: an Atom, an accessor, a transform key's plain value, or a number on a length. */
193
197
  readonly routed: Readonly<Record<string, unknown>>
194
198
  /** Whether a `transform` string was dropped for the transform keys. */
195
199
  readonly droppedTransform: boolean
@@ -12,7 +12,6 @@
12
12
  // ADR-0070, *Amendment (#665)*: only members pay. A spine reads one module slot a Retarget while no
13
13
  // Batch has been made, and a WeakMap after; this module's code is reached through `provideBatchHolds`,
14
14
  // which only `createBatch` calls.
15
- import * as BaseValue from "@wardic/core/BaseValue"
16
15
  import * as Arr from "effect/Array"
17
16
  import { constFalse } from "effect/Function"
18
17
  import * as Iter from "effect/Iterable"
@@ -20,6 +19,7 @@ import * as Predicate from "effect/Predicate"
20
19
  import * as Rec from "effect/Record"
21
20
  import * as BatchMembers from "./BatchMembers.ts"
22
21
  import * as Spine from "@wardic/core/unstable/Spine"
22
+ import * as TransformKeys from "../internal/transform-keys.ts"
23
23
 
24
24
  // What a hold works its spine with (#746): here, not in the spine, so an app with no Batch ships none
25
25
  // of it (ADR-0070's *Note (#746)*). Functions over the host, not closures: a hold makes none of its own.
@@ -61,7 +61,7 @@ export const provideBatchHolds = (): void => Spine.provideMemberHolds(BATCH_HOLD
61
61
 
62
62
  /** A Batch member's element's {@link Spine.MemberHold}. */
63
63
  const makeMemberHold = (host: Spine.HoldHost): Spine.MemberHold => {
64
- const { element, gate, id, snapshot } = host
64
+ const { subject: element, gate, id, snapshot } = host
65
65
  // The groups it holds now, each with the Batch's keys in it; the member it took them from; and whether
66
66
  // a drag holds `x`/`y`, from its first read or write to its hand-back.
67
67
  const held = new Map<BatchMembers.BatchGroup, ReadonlyArray<string>>()
@@ -81,7 +81,7 @@ const makeMemberHold = (host: Spine.HoldHost): Spine.MemberHold => {
81
81
  if (anyRunning(host, undrawn)) return true
82
82
  return Arr.some(Rec.keys(snapshot.values), (key) => {
83
83
  if (!undrawn(key)) return false
84
- return snapshot.values[key] !== BaseValue.TRANSFORM_IDENTITY[key]
84
+ return snapshot.values[key] !== TransformKeys.TRANSFORM_IDENTITY[key]
85
85
  })
86
86
  }
87
87
 
@@ -12,8 +12,10 @@
12
12
  // Unstable: ADR-0071, decision 5. #833: the storefront's spotlight and magnifier each listened to the pointer
13
13
  // and did the arithmetic themselves, where the Solid ward's `when("hover")` is its own per-move listener; core's
14
14
  // recognizer knows hover's edges alone, and a per-move Message on Foldkit would render per move (decision 23).
15
+ import * as Report from "@wardic/core/unstable/Report"
15
16
  import * as Arr from "effect/Array"
16
17
  import * as Bool from "effect/Boolean"
18
+ import * as Cause from "effect/Cause"
17
19
  import * as Effect from "effect/Effect"
18
20
  import { identity } from "effect/Function"
19
21
  import * as Num from "effect/Number"
@@ -55,6 +57,10 @@ const PLACING: ReadonlyArray<string> = ["pointerenter", "pointermove", "pointerd
55
57
 
56
58
  const UNIT = { minimum: 0, maximum: 1 } as const
57
59
 
60
+ /** A value whose dependent threw as it was set: an app's Atom over the pointer, say. */
61
+ const DEPENDENT_FAILED = "wardic.pointer: its dependent failed"
62
+
63
+
58
64
  /** `offset` as progress across `length`: 0 for a box with none. */
59
65
  const progressOf = (offset: number, length: number): number => {
60
66
  if (length <= 0) return 0
@@ -69,6 +75,8 @@ const progressOf = (offset: number, length: number): number => {
69
75
  export const pointer: (element: Element, options?: Options) => Effect.Effect<PointerValues, never, AtomRegistry.AtomRegistry | Scope.Scope> = Effect.fnUntraced(
70
76
  function* (element: Element, options: Options = {}) {
71
77
  const registry = yield* AtomRegistry.AtomRegistry
78
+ // Where a value's failure is reported (#979, row 14): what the pointer is read in, a provider's runtime.
79
+ const context = yield* Effect.context<never>()
72
80
  const types = UndefinedOr.match(options.types, { onUndefined: () => MOUSE_AND_PEN, onDefined: identity })
73
81
  const x = Atom.make(0)
74
82
  const y = Atom.make(0)
@@ -80,23 +88,80 @@ export const pointer: (element: Element, options?: Options) => Effect.Effect<Poi
80
88
  // Mounted while read, not kept alive, as the scroll reader's Atom is: a kept-alive Atom's node never leaves the registry.
81
89
  const unmounts = [registry.mount(x), registry.mount(y), registry.mount(xProgress), registry.mount(yProgress), registry.mount(width), registry.mount(height), registry.mount(inside)]
82
90
  const counts = (event: Event): boolean => Arr.contains(types, (event as PointerEvent).pointerType as PointerType)
91
+ // #979, row 14 (ADR-0074): a value whose dependent throws, an app's Atom over it, is its own: every value
92
+ // is set at each event. Before, a throw at `x` left the rest unset, uncaught, every move. Reported once a
93
+ // run of events that threw, at the run's first, with its key; a clean event ends the run.
94
+ // A run of events whose sets threw, reported at its first throw, and whether this event's did.
95
+ let failing = false
96
+ let eventThrew = false
97
+ /** The value `key`'s set threw: reported at a run's first throw. Its failure path alone. */
98
+ const valueFailed = (key: string, defect: unknown): void => {
99
+ if (Bool.not(Bool.or(eventThrew, failing))) Report.failureOn(context, DEPENDENT_FAILED, Cause.die(defect), { key })
100
+ eventThrew = true
101
+ }
83
102
  const place = (event: Event): void => {
84
103
  if (Bool.not(counts(event))) return
85
104
  const { clientX, clientY } = event as PointerEvent
86
105
  const box = element.getBoundingClientRect()
87
106
  const left = clientX - box.left
88
107
  const top = clientY - box.top
89
- registry.set(x, left)
90
- registry.set(y, top)
91
- registry.set(xProgress, progressOf(left, box.width))
92
- registry.set(yProgress, progressOf(top, box.height))
93
- registry.set(width, box.width)
94
- registry.set(height, box.height)
95
- registry.set(inside, true)
108
+ // Per event, a try at each set, written in place: an event's sets done, a run that threw goes on, or a
109
+ // clean event ends it.
110
+ try {
111
+ registry.set(x, left)
112
+ } catch (defect) {
113
+ valueFailed("x", defect)
114
+ }
115
+ try {
116
+ registry.set(y, top)
117
+ } catch (defect) {
118
+ valueFailed("y", defect)
119
+ }
120
+ try {
121
+ registry.set(xProgress, progressOf(left, box.width))
122
+ } catch (defect) {
123
+ valueFailed("xProgress", defect)
124
+ }
125
+ try {
126
+ registry.set(yProgress, progressOf(top, box.height))
127
+ } catch (defect) {
128
+ valueFailed("yProgress", defect)
129
+ }
130
+ try {
131
+ registry.set(width, box.width)
132
+ } catch (defect) {
133
+ valueFailed("width", defect)
134
+ }
135
+ try {
136
+ registry.set(height, box.height)
137
+ } catch (defect) {
138
+ valueFailed("height", defect)
139
+ }
140
+ try {
141
+ registry.set(inside, true)
142
+ } catch (defect) {
143
+ valueFailed("inside", defect)
144
+ }
145
+ if (eventThrew) {
146
+ eventThrew = false
147
+ failing = true
148
+ return
149
+ }
150
+ if (failing) failing = false
96
151
  }
97
152
  const leave = (event: Event): void => {
98
153
  if (Bool.not(counts(event))) return
99
- registry.set(inside, false)
154
+ try {
155
+ registry.set(inside, false)
156
+ } catch (defect) {
157
+ valueFailed("inside", defect)
158
+ }
159
+ if (eventThrew) {
160
+ eventThrew = false
161
+ failing = true
162
+ return
163
+ }
164
+ if (failing) failing = false
100
165
  }
101
166
  yield* Effect.acquireRelease(
102
167
  Effect.sync(() => {