@wardic/dom 1.3.1 → 1.3.2

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 (132) 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 +26 -6
  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 +9 -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 +14 -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 +138 -39
  49. package/dist/internal/projection.js.map +1 -1
  50. package/dist/internal/renderer.d.ts +26 -16
  51. package/dist/internal/renderer.d.ts.map +1 -1
  52. package/dist/internal/renderer.js +45 -106
  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/transform-keys.d.ts +22 -0
  58. package/dist/internal/transform-keys.d.ts.map +1 -0
  59. package/dist/internal/transform-keys.js +43 -0
  60. package/dist/internal/transform-keys.js.map +1 -0
  61. package/dist/unstable/AppearAnimations.d.ts +2 -1
  62. package/dist/unstable/AppearAnimations.d.ts.map +1 -1
  63. package/dist/unstable/AppearAnimations.js +73 -22
  64. package/dist/unstable/AppearAnimations.js.map +1 -1
  65. package/dist/unstable/BatchMembers.d.ts +2 -2
  66. package/dist/unstable/BatchMembers.d.ts.map +1 -1
  67. package/dist/unstable/BatchMembers.js +29 -6
  68. package/dist/unstable/BatchMembers.js.map +1 -1
  69. package/dist/unstable/DomValues.js +1 -1
  70. package/dist/unstable/DomValues.js.map +1 -1
  71. package/dist/unstable/DragTrack.d.ts +2 -2
  72. package/dist/unstable/DragTrack.d.ts.map +1 -1
  73. package/dist/unstable/DragTrack.js +34 -8
  74. package/dist/unstable/DragTrack.js.map +1 -1
  75. package/dist/unstable/ElementSetup.d.ts.map +1 -1
  76. package/dist/unstable/ElementSetup.js +2 -1
  77. package/dist/unstable/ElementSetup.js.map +1 -1
  78. package/dist/unstable/GestureFeatures.d.ts +2 -1
  79. package/dist/unstable/GestureFeatures.d.ts.map +1 -1
  80. package/dist/unstable/GestureFeatures.js +18 -37
  81. package/dist/unstable/GestureFeatures.js.map +1 -1
  82. package/dist/unstable/LiveStyle.d.ts +28 -2
  83. package/dist/unstable/LiveStyle.d.ts.map +1 -1
  84. package/dist/unstable/LiveStyle.js +8 -32
  85. package/dist/unstable/LiveStyle.js.map +1 -1
  86. package/dist/unstable/MemberHold.js +2 -2
  87. package/dist/unstable/MemberHold.js.map +1 -1
  88. package/dist/unstable/PointerValues.d.ts.map +1 -1
  89. package/dist/unstable/PointerValues.js +82 -8
  90. package/dist/unstable/PointerValues.js.map +1 -1
  91. package/dist/unstable/PresenceController.d.ts +5 -2
  92. package/dist/unstable/PresenceController.d.ts.map +1 -1
  93. package/dist/unstable/PresenceController.js +68 -41
  94. package/dist/unstable/PresenceController.js.map +1 -1
  95. package/dist/unstable/ReorderInput.d.ts +2 -2
  96. package/dist/unstable/ReorderInput.js +2 -2
  97. package/dist/unstable/WardConfig.d.ts +13 -4
  98. package/dist/unstable/WardConfig.d.ts.map +1 -1
  99. package/dist/unstable/WardConfig.js.map +1 -1
  100. package/dist/unstable/features/TimelineKeys.d.ts.map +1 -1
  101. package/dist/unstable/features/TimelineKeys.js +18 -2
  102. package/dist/unstable/features/TimelineKeys.js.map +1 -1
  103. package/package.json +3 -3
  104. package/src/MeasuredPair.ts +21 -1
  105. package/src/index.ts +4 -1
  106. package/src/internal/appear.ts +20 -2
  107. package/src/internal/batch-handoff.ts +19 -11
  108. package/src/internal/batch-writer.ts +27 -6
  109. package/src/internal/clock.ts +10 -0
  110. package/src/internal/default-transition.ts +14 -4
  111. package/src/internal/failing.ts +37 -0
  112. package/src/internal/length-keys.ts +80 -0
  113. package/src/internal/measured-pairs.ts +58 -22
  114. package/src/internal/own-values.ts +2 -2
  115. package/src/internal/positional-keys.ts +4 -2
  116. package/src/internal/projection.ts +141 -37
  117. package/src/internal/renderer.ts +45 -92
  118. package/src/internal/scroll.ts +24 -2
  119. package/src/internal/transform-keys.ts +47 -0
  120. package/src/unstable/AppearAnimations.ts +73 -24
  121. package/src/unstable/BatchMembers.ts +32 -8
  122. package/src/unstable/DomValues.ts +1 -1
  123. package/src/unstable/DragTrack.ts +46 -12
  124. package/src/unstable/ElementSetup.ts +2 -1
  125. package/src/unstable/GestureFeatures.ts +23 -44
  126. package/src/unstable/LiveStyle.ts +12 -8
  127. package/src/unstable/MemberHold.ts +2 -2
  128. package/src/unstable/PointerValues.ts +73 -8
  129. package/src/unstable/PresenceController.ts +66 -40
  130. package/src/unstable/ReorderInput.ts +2 -2
  131. package/src/unstable/WardConfig.ts +17 -5
  132. package/src/unstable/features/TimelineKeys.ts +19 -2
@@ -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. */
@@ -184,7 +184,8 @@ export interface Telling {
184
184
  * (`GestureInfo`), in Motion's order: a locked drag's `onDirectionLock` before its `onDragStart`, a
185
185
  * pan's `onPanSessionStart` at the down with the point alone, `onDrag` and `onPan` at the start and
186
186
  * 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).
187
+ * by name at the first of a run of throws, its next clean call ending the run, and the gesture goes on
188
+ * (#257 item 4).
188
189
  */
189
190
  export interface GestureTeller {
190
191
  readonly hovered: (edge: Recognizer.Edge) => void
@@ -204,11 +205,11 @@ type MovementCallback = "onDragStart" | "onDragEnd" | "onPanStart" | "onPanEnd"
204
205
  // #793 (PR 2): solid's `gestureCallbacksOf`, moved to dom for both bindings: each gives how a handler is invoked.
205
206
  export const gestureTellerOf = ({ config, invoke, report }: Telling): GestureTeller => {
206
207
  const guard = callbackGuard(report)
207
- /** Tell the config's `name`, if it has one, `args`: reported if it throws. */
208
+ /** Tell the config's `name`, if it has one, `args`: reported at a run of throws' first. */
208
209
  const tell = (name: GestureCallbackName, ...args: ReadonlyArray<unknown>): void => {
209
210
  const handler = config()[name]
210
211
  if (Predicate.isUndefined(handler)) return
211
- guard.once(name, () => invoke(handler, args))
212
+ guard(name, () => invoke(handler, args))
212
213
  }
213
214
  /**
214
215
  * A drag's or a pan's sample, past a pan's session's start: its start's or its end's callback
@@ -222,8 +223,8 @@ export const gestureTellerOf = ({ config, invoke, report }: Telling): GestureTel
222
223
  if (Bool.and(Predicate.isUndefined(own), Predicate.isUndefined(each))) return
223
224
  const raw = sample.raw as PointerEvent
224
225
  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])))
226
+ UndefinedOr.map(named, (key) => UndefinedOr.map(own, (handler) => guard(key, () => invoke(handler, [raw, info]))))
227
+ UndefinedOr.map(each, (handler) => guard(every, () => invoke(handler, [raw, info])))
227
228
  }
228
229
  return {
229
230
  hovered: (edge) => {
@@ -259,48 +260,26 @@ export const gestureTellerOf = ({ config, invoke, report }: Telling): GestureTel
259
260
  }
260
261
 
261
262
  /**
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.
263
+ * A guard around an element's gesture callbacks (#257 item 4): runs `call`, and reports a run of its
264
+ * throws at the first, so one that throws at every move, or at every hover, logs once, and a call that
265
+ * returns ends the run. Each callback name has its own run, and the gesture goes on either way.
265
266
  */
266
- interface CallbackGuard {
267
- readonly once: (name: GestureCallbackName, call: () => void) => void
268
- readonly perMove: (name: GestureCallbackName, call: () => void) => void
269
- }
267
+ type CallbackGuard = (name: GestureCallbackName, call: () => void) => void
270
268
 
271
269
  /** A {@link CallbackGuard} reporting through `report`, told the callback's name and what it threw. */
272
270
  // #793 (PR 2): solid's `gesture-callbacks.ts`'s `call` and `callPerMove`, moved to dom with the teller.
271
+ // #979 group I, row 26 (ADR-0074 decision 3): the two were one-throw-a-report (`once`) and once a run
272
+ // (`perMove`, for `onDrag` and `onPan`); a hover's or a tap's callback is called again at each, so both
273
+ // are once a run now, one guard.
273
274
  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
- },
275
+ const runs: Failing.Failing<GestureCallbackName> = { failing: undefined }
276
+ return (name, call) => {
277
+ try {
278
+ call()
279
+ Failing.endRunOf(runs, name)
280
+ } catch (defect) {
281
+ if (Failing.firstThrowOf(runs, name)) report(name, defect)
282
+ }
304
283
  }
305
284
  }
306
285
 
@@ -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.
@@ -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(() => {
@@ -57,6 +57,7 @@ import type * as WardConfig from "./WardConfig.ts"
57
57
  import type * as CorePresenceRecord from "@wardic/core/unstable/PresenceRecord"
58
58
  import * as RetargetLegs from "@wardic/core/unstable/RetargetLegs"
59
59
  import type * as WardicServices from "@wardic/core/unstable/WardicServices"
60
+ import * as Spine from "@wardic/core/unstable/Spine"
60
61
  import * as VariantTree from "@wardic/core/unstable/VariantTree"
61
62
 
62
63
  // #672 (PR5-Q3): the DOM's presence types, core's protocol over Element, here with the DOM's presence:
@@ -236,12 +237,13 @@ interface PreparedExit {
236
237
  /**
237
238
  * An exit's Measured pairs (#430): each key whose start and target differ in type, asked of the
238
239
  * end-of-task batch, but a key with Keyframes of more than two stops (`stops`, #460). `undefined` with
239
- * none, nearly every exit.
240
+ * none, nearly every exit. `failed` is told when the batch can't take them (a Transform template
241
+ * that throws): they switch, as pairs it couldn't read do.
240
242
  */
241
- const exitMeasuredOf = (element: Element, from: Values.Values, to: Values.Values, stops: RetargetLegs.StopsByKey | undefined): RetargetLegs.MeasuredPairs | undefined => {
243
+ const exitMeasuredOf = (element: Element, from: Values.Values, to: Values.Values, stops: RetargetLegs.StopsByKey | undefined, failed: (defect: unknown) => void): RetargetLegs.MeasuredPairs | undefined => {
242
244
  const pairs = Rec.filter(to, (target, key) => Bool.and(Bool.and(Object.hasOwn(from, key), Bool.not(RetargetLegs.hasManyStops(stops, key))), keepsMeasured(key, from[key], target)))
243
245
  if (Rec.isEmptyRecord(pairs)) return undefined
244
- return DomValues.measuredPairs.measure(castForDom(element), Rec.map(pairs, (target, key) => ({ from: UndefinedOr.getOrThrow(from[key]), to: target })), from)
246
+ return DomValues.measuredPairs.measure(castForDom(element), Rec.map(pairs, (target, key) => ({ from: UndefinedOr.getOrThrow(from[key]), to: target })), from, failed)
245
247
  }
246
248
 
247
249
  /** Whether a start and a target make a Measured pair (#430). */
@@ -618,8 +620,11 @@ export interface PresenceOptions {
618
620
  readonly presenceAffectsLayout?: (() => boolean | undefined) | undefined
619
621
  /**
620
622
  * The children `mode="wait"` held may go on the page now: the binding renders its children again,
621
- * through {@link PresenceController.shown}. Left out, a held child stays held.
623
+ * through {@link PresenceController.shown}. Left out, a held child stays held. It can be called inside
624
+ * {@link PresenceController.present}: a leaver with nothing to play goes at once there, so a binding
625
+ * that can't render again inside its own update defers it.
622
626
  */
627
+ // #987 (ADR-0048, *Amendment (#987)*): Solid 2's binding defers a release made there a microtask; Foldkit's defers every one.
623
628
  readonly release?: (() => void) | undefined
624
629
  }
625
630
 
@@ -682,21 +687,29 @@ export interface PresenceController {
682
687
 
683
688
  /**
684
689
  * {@link PresenceEvents} as Motion's (#257, Solid 1's): only its `onExitComplete`, read when it's called. One
685
- * that throws is reported (`wardic.presence: onExitComplete failed`), and the presence goes on.
690
+ * that throws is reported (`wardic.presence: onExitComplete failed`) at the first of a run of throws, its
691
+ * next clean call ending the run, and the presence goes on.
686
692
  */
687
- export const exitCompleteEvents = (runtime: WardicServices.Runner<WardicServices.WardicServices>, onExitComplete: () => (() => void) | undefined): PresenceEvents => ({
688
- exitStart: constVoid,
689
- exiting: constVoid,
690
- exitComplete: () => {
691
- const callback = onExitComplete()
692
- if (Predicate.isUndefined(callback)) return
693
- try {
694
- callback()
695
- } catch (defect) {
696
- runtime.runFork(Report.failure("wardic.presence: onExitComplete failed", Cause.die(defect)))
697
- }
698
- },
699
- })
693
+ export const exitCompleteEvents = (runtime: WardicServices.Runner<WardicServices.WardicServices>, onExitComplete: () => (() => void) | undefined): PresenceEvents => {
694
+ // #979 group I, row 29 (ADR-0074 decision 3): called at each exit's end, so a run is its throws there.
695
+ let failing = false
696
+ return {
697
+ exitStart: constVoid,
698
+ exiting: constVoid,
699
+ exitComplete: () => {
700
+ const callback = onExitComplete()
701
+ if (Predicate.isUndefined(callback)) return
702
+ try {
703
+ callback()
704
+ if (failing) failing = false
705
+ } catch (defect) {
706
+ if (failing) return
707
+ failing = true
708
+ runtime.runFork(Report.failure("wardic.presence: onExitComplete failed", Cause.die(defect)))
709
+ }
710
+ },
711
+ }
712
+ }
700
713
 
701
714
  /** A projection method that takes an HTML element first, taking any element. */
702
715
  type TakingAnyElement<F> = F extends (...args: infer P) => infer A ? P extends [HTMLElement, ...infer R] ? (el: Element, ...rest: R) => A : F : F
@@ -743,6 +756,9 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
743
756
  * the wrong one — is diagnosable. The per-frame commit stays silent.
744
757
  */
745
758
  const debug = Report.debugOf(runtime, "wardic.presence")
759
+ const exitFailed = Spine.exitVariantFailedOn(runtime)
760
+ // An exit's Measured pairs the batch couldn't take (its Transform template threw), reported each time (#979, row 8).
761
+ const exitMeasuredFailed = Spine.exitMeasuredFailedOn(runtime)
746
762
 
747
763
  // The registry of live child records, keyed by their DOM element. Filled by
748
764
  // register() (called from the child's spine on mount), drained as children
@@ -830,7 +846,9 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
830
846
 
831
847
  /**
832
848
  * A child's exit ended: with the last, `exiting` turns off, a completion is told, and the children
833
- * `mode="wait"` held go on the page (#277), as Motion renders them after its `onExitComplete`.
849
+ * `mode="wait"` held go on the page (#277), as Motion renders them after its `onExitComplete`. A
850
+ * release that throws (a held child's start, on a binding that starts it at once) is reported, and the
851
+ * presence goes on.
834
852
  */
835
853
  const leaveEnds = (el: Element, completed: boolean): void => {
836
854
  if (Bool.not(leaving.delete(el))) return
@@ -841,7 +859,13 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
841
859
  })
842
860
  // `propagate` (#277's PR 5c): the last child that left lets the parent's child go.
843
861
  allLeft()
844
- if (held.length > 0) UndefinedOr.map(options.release, (release) => release())
862
+ if (held.length === 0) return
863
+ // Its own: a throw here came out of the exit's fiber unlogged, and on Solid 1 out of the release (#983).
864
+ try {
865
+ UndefinedOr.map(options.release, (release) => release())
866
+ } catch (defect) {
867
+ runtime.runFork(Report.failure(`wardic.presence: mode="wait"'s release failed`, Cause.die(defect)))
868
+ }
845
869
  }
846
870
 
847
871
  // What `leaveAll` calls once none is left (#277's PR 5c), and where its children last were.
@@ -1072,6 +1096,8 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
1072
1096
  const joinersOf = (provider: PresenceRecord): ReadonlyArray<PresenceRecord> => Arr.filter(parts, (part) => joinsTo.get(part) === provider)
1073
1097
  const nodeOf = (node: PresenceRecord, inherited: WardConfig.WardicVariantLabels | undefined): ExitNode => {
1074
1098
  const exit = node.exitOf(custom, inherited)
1099
+ // An exit whose resolver threw has no values: it leaves without it, reported each time (#979).
1100
+ if (Option.isSome(exit.failure)) exitFailed(exit.failure.value)
1075
1101
  return { rec: node, exit, kids: Arr.map(joinersOf(node), (kid) => nodeOf(kid, exit.name)) }
1076
1102
  }
1077
1103
  // The child's own tree, if it's a Wardic element, and each element inside it that joins nothing
@@ -1088,7 +1114,8 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
1088
1114
  // One `wardic.presence.exit` span spans the whole exit, from the leave to the last part's end.
1089
1115
  // A failed run is logged and reported (ADR-0030, decision 4); the node is removed either way.
1090
1116
  const fiber = runtime.runFork(
1091
- Effect.all(Arr.map(roots, (root) => runOf(root, NO_DELAY)), { concurrency: "unbounded", discard: true }).pipe(
1117
+ // Its stagger's `delayChildren` function that throws, reported once this exit (#979).
1118
+ Effect.all(Arr.map(roots, (root) => runOf(root, NO_DELAY, VariantTree.eventDelayFailuresOf(runtime))), { concurrency: "unbounded", discard: true }).pipe(
1092
1119
  Effect.tapCause((cause) => Report.failure("wardic.presence: an exit failed", cause)),
1093
1120
  Effect.ensuring(Effect.sync(() => partDone(el))),
1094
1121
  // The app's to give, with no call-site stack (#746; ADR-0040, decision 2).
@@ -1102,25 +1129,21 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
1102
1129
  * A node's exit and its Variant children's (#290), Motion's `animateVariant`: with `when`, one after
1103
1130
  * the other, the children's delays from 0; else together, the children's from `delay`.
1104
1131
  */
1105
- const runOf = (node: ExitNode, delay: DelayOf): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
1132
+ const runOf = (node: ExitNode, delay: DelayOf, delays: VariantTree.DelayFailures): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
1106
1133
  // A list's names each run on their own (#297's PR 2): each name's keys and its children's, in that
1107
1134
  // name's own `when`.
1108
1135
  const groups = node.exit.groups
1109
1136
  if (Predicate.isNotUndefined(groups)) {
1110
1137
  const first = UndefinedOr.match(groups[0], { onUndefined: constUndefined, onDefined: (group) => group.name })
1111
- return Effect.all(Arr.map(groups, (group) => runName(node, group.name, delay, group.name === first)), { concurrency: "unbounded", discard: true })
1138
+ return Effect.all(Arr.map(groups, (group) => runName(node, group.name, delay, group.name === first, delays)), { concurrency: "unbounded", discard: true })
1112
1139
  }
1113
1140
  const own = exitOf(node.rec, node.exit, delay)
1114
1141
  if (node.kids.length === 0) return own
1115
- const n = node.kids.length
1116
1142
  // Each name orchestrates the children's keys of that name (#297, Motion's `animateVariant` a name):
1117
1143
  // its own transition's delay and stagger, else the exit's.
1118
- const slot = (i: number) => (name: string | undefined): number => {
1119
- const s = VariantTree.staggerOf(transitionOfName(node.exit, name))
1120
- return VariantTree.childDelayOf(s, i, n)
1121
- }
1144
+ const slot = slotsOf(node, delays)
1122
1145
  const kidsFrom = (from: DelayOf): Effect.Effect<unknown, never, WardicServices.WardicServices> =>
1123
- Effect.all(Arr.map(node.kids, (kid, i) => runOf(kid, (name) => from(name) + slot(i)(name))), { concurrency: "unbounded", discard: true })
1146
+ Effect.all(Arr.map(node.kids, (kid, i) => runOf(kid, (name) => from(name) + slot(i)(name), delays)), { concurrency: "unbounded", discard: true })
1124
1147
  // `when` for a list as a whole, meanwhile (#297's PR 1): the exit's, its last name's that sets it.
1125
1148
  const when = UndefinedOr.map(node.exit.transition, (t) => t.when)
1126
1149
  if (when === "beforeChildren") return Effect.andThen(own, kidsFrom(NO_DELAY))
@@ -1128,25 +1151,27 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
1128
1151
  return Effect.all([own, kidsFrom(delay)], { concurrency: "unbounded", discard: true })
1129
1152
  }
1130
1153
 
1154
+ /** Each of `node`'s children's place in its exit's stagger, by the name it exits under: its delay. */
1155
+ const slotsOf = (node: ExitNode, delays: VariantTree.DelayFailures) => {
1156
+ const n = node.kids.length
1157
+ return (i: number) => (name: string | undefined): number => VariantTree.childDelayOf(VariantTree.staggerOf(transitionOfName(node.exit, name)), i, n, delays)
1158
+ }
1159
+
1131
1160
  /**
1132
1161
  * One name of a list's exit (#297's PR 2, Motion's `animateVariant` a name): the element's keys of that
1133
1162
  * name, and its Variant children's, one after the other with that name's `when`, else together. A
1134
1163
  * child whose exit isn't the list runs it whole, under the list's first name.
1135
1164
  */
1136
- const runName = (node: ExitNode, name: string, delay: DelayOf, first: boolean): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
1165
+ const runName = (node: ExitNode, name: string, delay: DelayOf, first: boolean, delays: VariantTree.DelayFailures): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
1137
1166
  const own = exitOf(node.rec, node.exit, delay, name)
1138
- const n = node.kids.length
1139
- if (n === 0) return own
1140
- const slot = (i: number) => (of: string | undefined): number => {
1141
- const s = VariantTree.staggerOf(transitionOfName(node.exit, of))
1142
- return VariantTree.childDelayOf(s, i, n)
1143
- }
1167
+ if (node.kids.length === 0) return own
1168
+ const slot = slotsOf(node, delays)
1144
1169
  const kidsFrom = (from: DelayOf): Effect.Effect<unknown, never, WardicServices.WardicServices> =>
1145
1170
  Effect.all(
1146
1171
  Arr.map(node.kids, (kid, i) => {
1147
1172
  const at: DelayOf = (of) => from(of) + slot(i)(of)
1148
- if (Predicate.isNotUndefined(kid.exit.groups)) return runName(kid, name, at, first)
1149
- if (first) return runOf(kid, at)
1173
+ if (Predicate.isNotUndefined(kid.exit.groups)) return runName(kid, name, at, first, delays)
1174
+ if (first) return runOf(kid, at, delays)
1150
1175
  return Effect.void
1151
1176
  }),
1152
1177
  { concurrency: "unbounded", discard: true },
@@ -1176,7 +1201,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
1176
1201
  const skipped = UndefinedOr.match(rec.skipAnimations, { onUndefined: constFalse, onDefined: (own) => own() })
1177
1202
  // Measured pairs (#430): an exit from `auto` to 0 measures both ends, as a Retarget does, unless
1178
1203
  // reduced motion snaps them or the exit is skipped.
1179
- const measured = Bool.match(Bool.or(reduce, skipped), { onTrue: constUndefined, onFalse: () => exitMeasuredOf(el, from, to, stops) })
1204
+ const measured = Bool.match(Bool.or(reduce, skipped), { onTrue: constUndefined, onFalse: () => exitMeasuredOf(el, from, to, stops, exitMeasuredFailed) })
1180
1205
  const legs = UndefinedOr.match(exit.groups, {
1181
1206
  onUndefined: () => RetargetLegs.legsOf(from, to, RetargetLegs.delayedBy(exit.transition, delay(singleNameOf(exit.name))), reduce, skipped, positionalKeys, defaultTransition, moving, undefined, stops, measured),
1182
1207
  onDefined: (groups) =>
@@ -1759,9 +1784,10 @@ export const propagateTo = (parent: PresenceContextValue | undefined, propagate:
1759
1784
  holds: true,
1760
1785
  leave: (_custom, release) => {
1761
1786
  leaving = true
1787
+ // Its own teardown first, then the parent's child let go, whose chain can reach the app's code (#983).
1762
1788
  presence.leaveAll(() => {
1763
- release()
1764
1789
  tear()
1790
+ release()
1765
1791
  })
1766
1792
  },
1767
1793
  gone: () => {
@@ -29,8 +29,8 @@ const isPress = (event: InputSource.PointerLikeEvent): boolean => Bool.and(event
29
29
  * keys inside their dispatch, so the reorder's `handle()` (the page's `preventDefault`) counts. A blur
30
30
  * is judged after this task's own work, one scheduler hop on (#318): a reorder can blur the node it
31
31
  * moves and puts focus back after (the driver's `keepFocus`). So `fork` runs that hop on the provider
32
- * runtime, only when a blur happens, and a blur whose judging fails is reported. A throw from the
33
- * driver inside an event goes to `onDefect`.
32
+ * runtime, only when a blur happens, and a blur whose judging fails is reported. A run of throws from
33
+ * the driver inside an event goes to `onDefect` at its first.
34
34
  */
35
35
  export const watchItemInput = (
36
36
  el: HTMLElement,
@@ -49,6 +49,11 @@ export interface CSSProperties extends CSS.PropertiesHyphen {
49
49
  * is used verbatim).
50
50
  */
51
51
  export interface WardicTransformShorthands {
52
+ /**
53
+ * The element's own depth, Motion's `transformPerspective`: a `perspective()` at the head of its
54
+ * transform, a bare number in px. Its children's depth is the `perspective` property's.
55
+ */
56
+ readonly transformPerspective?: number | string
52
57
  readonly x?: number | string
53
58
  readonly y?: number | string
54
59
  readonly z?: number | string
@@ -58,6 +63,9 @@ export interface WardicTransformShorthands {
58
63
  readonly scale?: number | string
59
64
  readonly scaleX?: number | string
60
65
  readonly scaleY?: number | string
66
+ /** The scale along the element's depth, CSS's `scaleZ()`: seen only beside a turn out of its plane. */
67
+ // #883 drew it, #887 typed it.
68
+ readonly scaleZ?: number | string
61
69
  readonly rotate?: number | string
62
70
  readonly rotateX?: number | string
63
71
  readonly rotateY?: number | string
@@ -116,9 +124,10 @@ export type WardicValues =
116
124
  /**
117
125
  * The CSS lengths a value takes a bare number on, drawn in `px` (#522, Motion's `animate={{ height: 200 }}`):
118
126
  * the DOM renderer's `LENGTH_KEYS`, so a number typechecks only where it's drawn as a length. Every
119
- * other length takes `csstype`'s value, `0` or a string. `style` keeps Solid's own types: Solid writes a
120
- * number there as it is.
127
+ * other length takes `csstype`'s value, `0` or a string. In an element's `style`, a number on one of these
128
+ * is drawn by Wardic too, in px, so `style={{ width: 200 }}` is 200px.
121
129
  */
130
+ // #887: the style's number routed to the renderer (`LiveStyle`), where before a binding wrote it as it is.
122
131
  export type WardicLengths = { readonly [K in DomRenderer.LengthKey]?: number | CSSProperties[K] }
123
132
 
124
133
  /** The DOM's keys and their values fill core's {@link Config.ValueKeys}, typing every config type built on it. */
@@ -301,7 +310,7 @@ export interface WardBaseConfig {
301
310
  // Dynamic variants: #277. Orchestration: ADR-0007.
302
311
  readonly variants?: Config.WardicVariants
303
312
  /**
304
- * The value passed to this element's function variants. When it changes, they're resolved again,
313
+ * The value passed to this element's dynamic variants. When it changes, they're resolved again,
305
314
  * and the element animates to what they give. A leaving element uses `<AnimatePresence custom>`
306
315
  * instead, if given.
307
316
  */
@@ -335,13 +344,16 @@ export interface WardBaseConfig {
335
344
  readonly transition?: WardicTransition
336
345
  /**
337
346
  * Where the element animates as it leaves an `<AnimatePresence>`: values or a `variants` name. The
338
- * element stays on the page until it has played.
347
+ * element stays on the page until it has played. A dynamic variant that throws as the element
348
+ * leaves, alone or in a list, is reported, and the element leaves at once, without its exit; the
349
+ * others leaving beside it exit.
339
350
  *
340
351
  * @example <w.div exit={{ opacity: 0, scale: 0.9 }} />
341
352
  */
342
353
  // ADR-0007: the child doesn't drive it (it's disposed); its spine publishes the exit into the
343
354
  // presence registration, and the presence runs it on the retained node. A dynamic variant resolves
344
- // as it leaves (#277); its own transition, else the element's.
355
+ // as it leaves (#277); its own transition, else the element's. One that throws: #979, reported by the
356
+ // presence's `nodeOf` each time.
345
357
  readonly exit?: WardicVariant | Config.WardicVariantLabels
346
358
  /**
347
359
  * Called when an animation of the element starts, with what it animates to: the variant name, or