@wardic/core 1.4.0 → 1.5.0-next.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 (75) hide show
  1. package/dist/DragRecognizer.d.ts +3 -2
  2. package/dist/DragRecognizer.d.ts.map +1 -1
  3. package/dist/DragRecognizer.js +14 -2
  4. package/dist/DragRecognizer.js.map +1 -1
  5. package/dist/InputSource.d.ts +6 -0
  6. package/dist/InputSource.d.ts.map +1 -1
  7. package/dist/InputSource.js.map +1 -1
  8. package/dist/InterpolatorRegistry.d.ts.map +1 -1
  9. package/dist/InterpolatorRegistry.js +12 -2
  10. package/dist/InterpolatorRegistry.js.map +1 -1
  11. package/dist/LiveValue.d.ts.map +1 -1
  12. package/dist/LiveValue.js +9 -7
  13. package/dist/LiveValue.js.map +1 -1
  14. package/dist/Projection.d.ts +1 -12
  15. package/dist/Projection.d.ts.map +1 -1
  16. package/dist/Projection.js +3 -19
  17. package/dist/Projection.js.map +1 -1
  18. package/dist/Recognizer.d.ts.map +1 -1
  19. package/dist/Recognizer.js +16 -1
  20. package/dist/Recognizer.js.map +1 -1
  21. package/dist/Reorder.d.ts +11 -1
  22. package/dist/Reorder.d.ts.map +1 -1
  23. package/dist/Reorder.js +63 -36
  24. package/dist/Reorder.js.map +1 -1
  25. package/dist/internal/diagnostic-codes.d.ts +10 -0
  26. package/dist/internal/diagnostic-codes.d.ts.map +1 -0
  27. package/dist/internal/diagnostic-codes.js +19 -0
  28. package/dist/internal/diagnostic-codes.js.map +1 -0
  29. package/dist/internal/guarded.js +1 -1
  30. package/dist/internal/guarded.js.map +1 -1
  31. package/dist/internal/projectionRest.d.ts +22 -0
  32. package/dist/internal/projectionRest.d.ts.map +1 -0
  33. package/dist/internal/projectionRest.js +20 -0
  34. package/dist/internal/projectionRest.js.map +1 -0
  35. package/dist/unstable/Diagnostic.d.ts +49 -0
  36. package/dist/unstable/Diagnostic.d.ts.map +1 -0
  37. package/dist/unstable/Diagnostic.js +26 -0
  38. package/dist/unstable/Diagnostic.js.map +1 -0
  39. package/dist/unstable/FlushGate.d.ts.map +1 -1
  40. package/dist/unstable/FlushGate.js +3 -2
  41. package/dist/unstable/FlushGate.js.map +1 -1
  42. package/dist/unstable/Imperative.js +4 -4
  43. package/dist/unstable/Imperative.js.map +1 -1
  44. package/dist/unstable/PresenceRecord.d.ts +5 -1
  45. package/dist/unstable/PresenceRecord.d.ts.map +1 -1
  46. package/dist/unstable/PresenceRecord.js.map +1 -1
  47. package/dist/unstable/Report.d.ts +15 -4
  48. package/dist/unstable/Report.d.ts.map +1 -1
  49. package/dist/unstable/Report.js +21 -6
  50. package/dist/unstable/Report.js.map +1 -1
  51. package/dist/unstable/Spine.d.ts.map +1 -1
  52. package/dist/unstable/Spine.js +21 -16
  53. package/dist/unstable/Spine.js.map +1 -1
  54. package/dist/unstable/VariantTree.d.ts +8 -1
  55. package/dist/unstable/VariantTree.d.ts.map +1 -1
  56. package/dist/unstable/VariantTree.js +4 -4
  57. package/dist/unstable/VariantTree.js.map +1 -1
  58. package/package.json +1 -1
  59. package/src/DragRecognizer.ts +24 -7
  60. package/src/InputSource.ts +7 -0
  61. package/src/InterpolatorRegistry.ts +16 -2
  62. package/src/LiveValue.ts +11 -7
  63. package/src/Projection.ts +3 -21
  64. package/src/Recognizer.ts +17 -1
  65. package/src/Reorder.ts +81 -36
  66. package/src/internal/diagnostic-codes.ts +27 -0
  67. package/src/internal/guarded.ts +1 -1
  68. package/src/internal/projectionRest.ts +31 -0
  69. package/src/unstable/Diagnostic.ts +58 -0
  70. package/src/unstable/FlushGate.ts +3 -2
  71. package/src/unstable/Imperative.ts +4 -4
  72. package/src/unstable/PresenceRecord.ts +5 -1
  73. package/src/unstable/Report.ts +33 -6
  74. package/src/unstable/Spine.ts +22 -15
  75. package/src/unstable/VariantTree.ts +11 -4
@@ -0,0 +1,27 @@
1
+ /**
2
+ * core's coded diagnostics (solid-next, the skill grill's Q12, Q18): each code core reports
3
+ * (`Diagnostic.report`), with what the docs and the `wardic-diagnostics` skill say of it, both generated
4
+ * from here by `scripts/diagnostics.ts`. Imported by nothing an app runs.
5
+ *
6
+ * @module
7
+ */
8
+ import type * as Diagnostic from "../unstable/Diagnostic.ts"
9
+
10
+ export const CODES: ReadonlyArray<Diagnostic.Entry> = [
11
+ {
12
+ code: "WARDIC_CANT_BLEND",
13
+ group: "Style",
14
+ summary: "Two values an animation moves between can't be blended, so the value switches to the target at the first frame instead of moving.",
15
+ why: "An animation moves through the values between its two ends. `10px` and `2em`, or two lists of different lengths, are read by the same interpolator but have no values between them, so Wardic switches at the first frame, as Motion does for values too different to mix.",
16
+ repair: "Give both ends the same unit (`10px` to `20px`) and the same shape: as many numbers, in the same order.",
17
+ notes: ["ADR-0026 decision 4"],
18
+ },
19
+ {
20
+ code: "WARDIC_CALLBACK_THREW",
21
+ group: "App callbacks",
22
+ summary: "A function the app gave Wardic threw: a callback (`onComplete`, `onExitComplete`, a gesture's), a function variant or delay, a Live value's mixer or dependent, an easing, or an effect run for the app.",
23
+ why: "Wardic catches it so the animation, and everything else, goes on. It logs it at Error with its cause and hands the cause to the app's `ErrorReporter`s. The label after the code names the function that threw; the cause under it is the app's own error. A function that throws on each call is reported once for the run of throws, and again after a call that returns.",
24
+ repair: "Fix the function the label names: the cause's stack points into the app's code.",
25
+ notes: ["ADR-0030 decision 4, ADR-0074 decision 3"],
26
+ },
27
+ ]
@@ -36,7 +36,7 @@ export const contextFor = (onDefect: OnDefect | undefined): Effect.Effect<Contex
36
36
  export const guarded = <A>(handle: (event: A) => void, onDefect: OnDefect | undefined, context: Context.Context<never> | undefined): ((event: A) => void) => {
37
37
  const tell = UndefinedOr.match(onDefect, {
38
38
  onDefined: (defect) => (error: unknown) => defect(Cause.die(error)),
39
- onUndefined: () => (error: unknown) => Report.failureOn(context, HANDLER_FAILED, Cause.die(error)),
39
+ onUndefined: () => (error: unknown) => Report.callbackFailedOn(context, HANDLER_FAILED, Cause.die(error)),
40
40
  })
41
41
  let failing = false
42
42
  return (event: A): void => {
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `Projection`'s key and its value at rest, in a module of their own (probe: hooks-first), apart from
3
+ * `Projection.ts`'s box maths. Every app's renderer reads these two; the maths is the layout
4
+ * Feature's alone. A bundler splits by module, not by function: with both in one module, an app that
5
+ * might fetch the layout Feature later carried the maths in its first chunk.
6
+ *
7
+ * @module
8
+ */
9
+ import type { AxisDelta, Value } from "../Projection.ts"
10
+
11
+ /**
12
+ * The key a projection pass writes each node's `Value` under, each frame, for its Environment's renderer
13
+ * to draw as one transform with the Subject's own rotation and skew. Namespaced, `@projection`, so it
14
+ * never collides with an animated key.
15
+ */
16
+ // ADR-0009. `@wardic/dom`'s renderer's `project()` reads it in place of its normal transform grouping.
17
+ // The contract between the binding's coordinator (the writer) and the renderer (the reader); it lives in
18
+ // core because that is their only shared dependency.
19
+ export const KEY = "@projection"
20
+
21
+ /** An axis with nothing to project: no shift, no scale. */
22
+ const REST_AXIS: AxisDelta = { translate: 0, scale: 1, origin: 0.5, originPoint: 0 }
23
+
24
+ /**
25
+ * A node drawn at its own box: no delta, no ancestors' scale. The renderer draws it with the Subject's
26
+ * own rotation, skew and scale, and leaves its own move out, as it draws a layout node at rest. What a
27
+ * server, which measures nothing, draws a layout node's starting style and mount animation with.
28
+ */
29
+ // #245; the projection owns its translate (ADR-0016); ADR-0021 (the server measures nothing): the
30
+ // Starting style and the Appear animation.
31
+ export const AT_REST: Value = { delta: { x: REST_AXIS, y: REST_AXIS }, treeScale: { x: 1, y: 1 } }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * A coded diagnostic: a rule an app broke, reported with a stable code, `WARDIC_` and what happened
3
+ * (`WARDIC_FEATURE_MISSING`), so a binding can put it where its framework reports its own, and a reader
4
+ * or a coding agent can look the code up. Core gives the way to report one; each package keeps its own
5
+ * codes, and each binding provides a `Reporter` that forwards a report to its framework's channel. With
6
+ * none provided, a report is a warning in the log, its code first.
7
+ *
8
+ * Unstable, for Wardic's own packages: public, with no semver promise.
9
+ *
10
+ * @module
11
+ */
12
+ // solid-next: the skill grill's Q6, Q17, Q18 and Q21. A Context.Reference with its default, as
13
+ // `UnitScale` and `PressClaims` are, read from the runtime a report runs on, so no caller passes it.
14
+ import * as Context from "effect/Context"
15
+ import * as Effect from "effect/Effect"
16
+
17
+ /** A diagnostic's code: `WARDIC_` and what happened, in Solid's style (`WARDIC_FEATURE_MISSING`). */
18
+ export type Code = `WARDIC_${string}`
19
+
20
+ /**
21
+ * A code's entry in its package's registry: what the docs and the `wardic-diagnostics` skill say of
22
+ * it, both generated from it. The message a report prints is the call site's own; the entry explains
23
+ * it.
24
+ */
25
+ export interface Entry {
26
+ readonly code: Code
27
+ /** Its group on the docs' index: "Features", "Presence", … */
28
+ readonly group: string
29
+ /** What happened, in a line: the title the docs give it. */
30
+ readonly summary: string
31
+ /** Why it's a problem. */
32
+ readonly why: string
33
+ /** How to fix it. */
34
+ readonly repair: string
35
+ /** A small before and after, where one shows the repair better than words. */
36
+ readonly example?: { readonly before: string; readonly after: string } | undefined
37
+ /** Where it came from (issues, ADRs): kept here, out of the message a reader sees. */
38
+ readonly notes?: ReadonlyArray<string> | undefined
39
+ }
40
+
41
+ /** Where a coded report goes: a binding's own forwards it to its framework's channel. */
42
+ export interface Reporter {
43
+ readonly report: (code: Code, message: string) => Effect.Effect<void>
44
+ }
45
+
46
+ /** A report's first line, and a thrown misuse's message: its code, then what happened and its fix. */
47
+ export const line = (code: Code, message: string): string => `[${code}] ${message}`
48
+
49
+ /** With no binding's: a warning in the log, its code first. */
50
+ const LOGGED: Reporter = { report: (code, message) => Effect.logWarning(line(code, message)) }
51
+
52
+ /** The Environment's reporter: the log's, unless a binding's Layer gives its own. */
53
+ export const Reporter: Context.Reference<Reporter> = /*#__PURE__*/ Context.Reference<Reporter>("@wardic/core/unstable/Diagnostic/Reporter", {
54
+ defaultValue: () => LOGGED,
55
+ })
56
+
57
+ /** Reports `code` on the Environment's reporter, `message` saying what happened and how to fix it. */
58
+ export const report = (code: Code, message: string): Effect.Effect<void> => Effect.flatMap(Effect.service(Reporter), (reporter) => reporter.report(code, message))
@@ -544,7 +544,8 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
544
544
  } catch (defect) {
545
545
  if (entry.onCommitFailing) continue
546
546
  entry.onCommitFailing = true
547
- runtime.runFork(Report.failure("wardic.gate: an onCommit failed", Cause.die(defect)))
547
+ // An app's own function: a binding's sink commits through the app's `onUpdate` (`Spine.withOnUpdate`).
548
+ runtime.runFork(Report.callbackFailed("wardic.gate: an onCommit failed", Cause.die(defect)))
548
549
  }
549
550
  }
550
551
  committedSince.clear()
@@ -578,7 +579,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
578
579
  registry.set(output.atom, value)
579
580
  if (output.failing) output.failing = false
580
581
  } catch (defect) {
581
- if (!output.failing) runtime.runFork(Effect.annotateLogs(Report.failure("wardic.gate: an output failed", Cause.die(defect)), { id, key }))
582
+ if (!output.failing) runtime.runFork(Effect.annotateLogs(Report.callbackFailed("wardic.gate: an output failed", Cause.die(defect)), { id, key }))
582
583
  output.failing = true
583
584
  }
584
585
  }
@@ -1014,7 +1014,7 @@ const controlsOf = (
1014
1014
  try {
1015
1015
  complete()
1016
1016
  } catch (defect) {
1017
- runtime.runFork(Report.failure("wardic.animate: an onComplete failed", Cause.die(defect)))
1017
+ runtime.runFork(Report.callbackFailed("wardic.animate: an onComplete failed", Cause.die(defect)))
1018
1018
  }
1019
1019
  })
1020
1020
  }
@@ -1377,7 +1377,7 @@ const callbackTrackOf = (env: AnimateEnv, callback: Callback, animation: Sequenc
1377
1377
  const landed = (exit: Exit.Exit<unknown>): Effect.Effect<void> =>
1378
1378
  Exit.match(exit, {
1379
1379
  onSuccess: () => Effect.sync(() => settled(true)),
1380
- onFailure: (cause) => Bool.match(Cause.hasInterruptsOnly(cause), { onTrue: () => Effect.void, onFalse: () => Report.failure(SEGMENT_FAILED, cause) }),
1380
+ onFailure: (cause) => Bool.match(Cause.hasInterruptsOnly(cause), { onTrue: () => Effect.void, onFalse: () => Report.callbackFailed(SEGMENT_FAILED, cause) }),
1381
1381
  })
1382
1382
  const run = (): void => {
1383
1383
  end()
@@ -1395,7 +1395,7 @@ const callbackTrackOf = (env: AnimateEnv, callback: Callback, animation: Sequenc
1395
1395
  } catch (defect) {
1396
1396
  if (!failing) {
1397
1397
  failing = true
1398
- env.runtime.runFork(Report.failure(SEGMENT_FAILED, Cause.die(defect)))
1398
+ env.runtime.runFork(Report.callbackFailed(SEGMENT_FAILED, Cause.die(defect)))
1399
1399
  }
1400
1400
  }
1401
1401
  return undefined
@@ -1414,7 +1414,7 @@ const callbackTrackOf = (env: AnimateEnv, callback: Callback, animation: Sequenc
1414
1414
  try {
1415
1415
  callback.call(first)
1416
1416
  } catch (defect) {
1417
- env.runtime.runFork(Report.failure("wardic.animate: a function Segment's cancel failed", Cause.die(defect)))
1417
+ env.runtime.runFork(Report.callbackFailed("wardic.animate: a function Segment's cancel failed", Cause.die(defect)))
1418
1418
  }
1419
1419
  },
1420
1420
  duration: () => Machine.durationOf(env.runtime.runSync(machine)),
@@ -179,8 +179,10 @@ export interface PresenceWatch<E extends Subject.Subject = Subject.Subject> {
179
179
  * Its child left: called once, with the node back in place (or popped, `mode="popLayout"`), with
180
180
  * the presence's `custom`, and `release`, which lets the child go once it holds it. `release(false)`
181
181
  * cuts the child's exit short: it goes at once, uncompleted, as a child taken over does (#286).
182
+ * And `hold`, for a hook that didn't say it holds: it holds the child from then on, one more part
183
+ * of its exit, until the release it hands back is called (once). Nothing once the child has gone.
182
184
  */
183
- readonly leave: (custom: unknown, release: (completed?: boolean) => void) => void
185
+ readonly leave: (custom: unknown, release: (completed?: boolean) => void, hold: () => () => void) => void
184
186
  /** Its child went some other way, or the presence did: it's dropped, with no leave. */
185
187
  readonly gone: () => void
186
188
  /**
@@ -189,6 +191,8 @@ export interface PresenceWatch<E extends Subject.Subject = Subject.Subject> {
189
191
  */
190
192
  // #665, Q46: a keyed Batch's member mid-exit stops waiting on it.
191
193
  readonly interrupted?: () => void
194
+ /** Its child, told it left, has gone, its exit completed. Optional: left out, it isn't told. */
195
+ readonly ended?: () => void
192
196
  }
193
197
 
194
198
  /** Whether `presence` holds a Subject setting up now at its `animate` ({@link PresenceContextValue.blocksInitial}). */
@@ -29,33 +29,60 @@ import * as LogLevel from "effect/LogLevel"
29
29
  import * as Predicate from "effect/Predicate"
30
30
  import * as References from "effect/References"
31
31
  import * as UndefinedOr from "effect/UndefinedOr"
32
+ import * as Diagnostic from "./Diagnostic.ts"
33
+
34
+ /** `message`, with `code` before it when there's one (`Diagnostic.line`). */
35
+ const codedOrNot = (message: string, code: Diagnostic.Code | undefined): string =>
36
+ UndefinedOr.match(code, { onUndefined: () => message, onDefined: (given) => Diagnostic.line(given, message) })
32
37
 
33
38
  /**
34
39
  * `cause` logged at Error as `message`, with the cause, and handed to the Environment's
35
40
  * `ErrorReporter`s. An interruption is neither: it's how a run is removed, by a retarget, an unmount or a
36
- * dispose. Annotate the log by piping `Effect.annotateLogs` onto it.
41
+ * dispose. Annotate the log by piping `Effect.annotateLogs` onto it. With `code`, the message is logged
42
+ * after it, `[CODE] message` (solid-next): what an app's callback that threw is logged with.
37
43
  */
38
- export const failure = (message: string, cause: Cause.Cause<unknown>): Effect.Effect<void> =>
44
+ export const failure = (message: string, cause: Cause.Cause<unknown>, code?: Diagnostic.Code): Effect.Effect<void> =>
39
45
  Bool.match(Cause.hasInterruptsOnly(cause), {
40
46
  onTrue: () => Effect.void,
41
- onFalse: () => Effect.logError(message, cause).pipe(Effect.andThen(ErrorReporter.report(cause))),
47
+ onFalse: () => Effect.logError(codedOrNot(message, code), cause).pipe(Effect.andThen(ErrorReporter.report(cause))),
42
48
  })
43
49
 
44
50
  /**
45
51
  * {@link failure}, run where no fiber of a binding's is there to see it: on `context`, what the failing
46
52
  * code was built or started in, so an app's logger and reporters hear it, else on Effect's default
47
- * runtime. Forked, off the path that failed, with `annotations` on its log when given.
53
+ * runtime. Forked, off the path that failed, with `annotations` on its log when given, and its
54
+ * message after `code` when given, as {@link failure}'s.
48
55
  */
49
56
  // #979 (ADR-0030, *Amendment (#979, groups D and G)*): a Live value's run, a scroll's reader, a pointer's
50
57
  // value and a watch with no onDefect, each captured its context once and calls this only at a failure.
51
- export const failureOn = (context: Context.Context<never> | undefined, message: string, cause: Cause.Cause<unknown>, annotations?: Readonly<Record<string, unknown>>): void => {
52
- const report = UndefinedOr.match(annotations, { onUndefined: () => failure(message, cause), onDefined: (given) => Effect.annotateLogs(failure(message, cause), given) })
58
+ export const failureOn = (
59
+ context: Context.Context<never> | undefined,
60
+ message: string,
61
+ cause: Cause.Cause<unknown>,
62
+ annotations?: Readonly<Record<string, unknown>>,
63
+ code?: Diagnostic.Code,
64
+ ): void => {
65
+ const report = UndefinedOr.match(annotations, { onUndefined: () => failure(message, cause, code), onDefined: (given) => Effect.annotateLogs(failure(message, cause, code), given) })
53
66
  UndefinedOr.match(context, {
54
67
  onUndefined: () => void Effect.runFork(report),
55
68
  onDefined: (given) => void Effect.runForkWith(given)(report),
56
69
  })
57
70
  }
58
71
 
72
+ /** The code of an app's function that threw (solid-next): its label is logged after it. */
73
+ const CALLBACK_THREW: Diagnostic.Code = "WARDIC_CALLBACK_THREW"
74
+
75
+ /**
76
+ * {@link failure} for a function the app gave Wardic that threw (a callback, a mixer, an easing, a
77
+ * function variant): logged as `[WARDIC_CALLBACK_THREW] message`, with its cause, and handed to the
78
+ * Environment's `ErrorReporter`s. Wardic's own failures are {@link failure}'s, uncoded.
79
+ */
80
+ export const callbackFailed = (message: string, cause: Cause.Cause<unknown>): Effect.Effect<void> => failure(message, cause, CALLBACK_THREW)
81
+
82
+ /** {@link callbackFailed}, run where no fiber of a binding's is there to see it, as {@link failureOn} is. */
83
+ export const callbackFailedOn = (context: Context.Context<never> | undefined, message: string, cause: Cause.Cause<unknown>, annotations?: Readonly<Record<string, unknown>>): void =>
84
+ failureOn(context, message, cause, annotations, CALLBACK_THREW)
85
+
59
86
  /**
60
87
  * Whether a Debug log would be kept, as Effect's `MinimumLogLevel` says. Run it once (a runtime, a
61
88
  * build) and keep the answer, not once a log.
@@ -1441,7 +1441,7 @@ export const animationCallbacks = (runtime: WardicServices.Runner<WardicServices
1441
1441
  callback(definition)
1442
1442
  return false
1443
1443
  } catch (defect) {
1444
- if (!failing) runtime.runFork(Report.failure(`wardic.spine: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })))
1444
+ if (!failing) runtime.runFork(Report.callbackFailed(`wardic.spine: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })))
1445
1445
  return true
1446
1446
  }
1447
1447
  }
@@ -1529,6 +1529,9 @@ export const resolutionOf = (
1529
1529
  ): Resolution => {
1530
1530
  // The Controls change in effect (#433): its own controls', else its provider's, read here so a new one Retargets.
1531
1531
  const change = changeIn(own, parent)
1532
+ // Each key read once (#460, compose once): a binding's config can be a view that works a key out at
1533
+ // each read, a key several of a ward's parts give merged at each (probe: hooks-first), and this
1534
+ // read `animate` up to four times, and `custom` once for the base and once for each gesture.
1532
1535
  const variants = c.variants
1533
1536
  // Base target resolution priority (ADR-0007):
1534
1537
  // (1) local `animate` (a Values map or a variant name) — overrides any
@@ -1539,18 +1542,21 @@ export const resolutionOf = (
1539
1542
  // recomputes the memo and retargets;
1540
1543
  // (3) else the SSR-seeded `initial`.
1541
1544
  // Per Retarget, per Subject (#460, compose once): statements.
1542
- const variant = variantOf(c.animate, parent)
1545
+ const animate = c.animate
1546
+ const variant = variantOf(animate, parent)
1547
+ // Read after `animate`, as it was: a key still loading throws at the first of them read.
1548
+ const custom = c.custom
1543
1549
  // A list of names (#297, Motion's `VariantLabels`): a base entry a name, in order, so the last name
1544
1550
  // that sets a key drives it. A single name or a values map takes the path below, as before.
1545
- if (Arr.isArray(c.animate) || (Predicate.isUndefined(c.animate) && Arr.isArray(variant))) {
1546
- const targets = VariantTarget.resolveTargets(variant as ReadonlyArray<string>, variants, c.custom, state)
1551
+ if (Arr.isArray(animate) || (Predicate.isUndefined(animate) && Arr.isArray(variant))) {
1552
+ const targets = VariantTarget.resolveTargets(variant as ReadonlyArray<string>, variants, custom, state)
1547
1553
  const merged = VariantTarget.mergedOf(targets)
1548
1554
  const listLayers: Array<OverrideEntry> = Arr.map(targets, namedLayerOf)
1549
- return withGestures(c, parent, listLayers, merged.values, variant, active, merged.transition, state, change)
1555
+ return withGestures(c, variants, custom, parent, listLayers, merged.values, variant, active, merged.transition, state, change)
1550
1556
  }
1551
1557
  // A dynamic variant resolves with this Subject's own `custom` (#277), as Motion's each child's.
1552
1558
  // Animation controls never reach here: its binding reads them once, each change its entry (#433).
1553
- const target = baseTargetOf(c.animate as VariantTarget.Entry | undefined, variant, variants, c.custom, state, initialLink)
1559
+ const target = baseTargetOf(animate as VariantTarget.Entry | undefined, variant, variants, custom, state, initialLink)
1554
1560
  const base = target.values
1555
1561
  const baseLayer: OverrideEntry = layerOf(target, variant as string | undefined)
1556
1562
  // A Variant child's gestures are on while its provider's are (#291, Motion's `setActive`), each on
@@ -1562,7 +1568,7 @@ export const resolutionOf = (
1562
1568
  const { resolved, ends, keyframes } = resolvedOf(alone)
1563
1569
  return { resolved, base, dragging: active.dragging, variant, active, transition: target.transition, layers: alone, names: VariantTree.NO_GESTURE_NAMES, layersOn: VariantTree.NO_GESTURE_STATES, ends, keyframes, change }
1564
1570
  }
1565
- return withGestures(c, parent, [baseLayer], base, variant, active, target.transition, state, change)
1571
+ return withGestures(c, variants, custom, parent, [baseLayer], base, variant, active, target.transition, state, change)
1566
1572
  }
1567
1573
 
1568
1574
  /** The **Controls change** in effect for a Subject (#433): its own, else its provider's; per Retarget, a guard. */
@@ -1592,10 +1598,12 @@ const overriddenOf = (resolution: Resolution, override: Config.WardicTransition)
1592
1598
  /**
1593
1599
  * A resolution from its base entries (one, or one a name of a list, #297) and its gesture layers on
1594
1600
  * top (#291), each gesture's an entry a name too: the Override stack resolved, and the names its
1595
- * active gestures resolved.
1601
+ * active gestures resolved. `variants` and `custom` are `c`'s, read once by the caller.
1596
1602
  */
1597
1603
  const withGestures = (
1598
1604
  c: Config.SpineConfig,
1605
+ variants: Config.SpineConfig["variants"],
1606
+ custom: Config.SpineConfig["custom"],
1599
1607
  parent: VariantTree.WardicVariantContextValue | undefined,
1600
1608
  layers: Array<OverrideEntry>,
1601
1609
  base: Values.Values,
@@ -1605,7 +1613,6 @@ const withGestures = (
1605
1613
  state: VariantTarget.VariantState,
1606
1614
  change: AnimationControls.ControlsChange | undefined,
1607
1615
  ): Resolution => {
1608
- const variants = c.variants
1609
1616
  const above = VariantTree.handDownFrom(parent)
1610
1617
  if (Bool.and(above === VariantTree.NO_HAND_DOWN, Bool.not(anyOn(active)))) {
1611
1618
  const { resolved, ends, keyframes } = resolvedOf(layers)
@@ -1615,14 +1622,14 @@ const withGestures = (
1615
1622
  const labels = above.names
1616
1623
  // In Motion's priority, lowest first: a literal's fields are evaluated in order.
1617
1624
  const layersOn: VariantTree.GestureStates = {
1618
- inView: gestureLayersInto(layers, c.whileInView, on.inView, labels.inView, variants, c.custom, state),
1619
- focused: gestureLayersInto(layers, c.whileFocus, on.focused, labels.focused, variants, c.custom, state),
1620
- hovered: gestureLayersInto(layers, c.whileHover, on.hovered, labels.hovered, variants, c.custom, state),
1621
- pressed: gestureLayersInto(layers, c.whileTap, on.pressed, labels.pressed, variants, c.custom, state),
1625
+ inView: gestureLayersInto(layers, c.whileInView, on.inView, labels.inView, variants, custom, state),
1626
+ focused: gestureLayersInto(layers, c.whileFocus, on.focused, labels.focused, variants, custom, state),
1627
+ hovered: gestureLayersInto(layers, c.whileHover, on.hovered, labels.hovered, variants, custom, state),
1628
+ pressed: gestureLayersInto(layers, c.whileTap, on.pressed, labels.pressed, variants, custom, state),
1622
1629
  // whileDrag sits ABOVE tap (highest priority) — driven by the spring,
1623
1630
  // NOT stripped, so e.g. `scale: 1.1` animates while held and returns
1624
1631
  // after release.
1625
- dragged: gestureLayersInto(layers, c.whileDrag, on.dragged, labels.dragged, variants, c.custom, state),
1632
+ dragged: gestureLayersInto(layers, c.whileDrag, on.dragged, labels.dragged, variants, custom, state),
1626
1633
  }
1627
1634
  const { resolved, ends, keyframes } = resolvedOf(layers)
1628
1635
  const names = activeNamesFor(c, on, labels)
@@ -1678,7 +1685,7 @@ const failedOn =
1678
1685
  (message: string) =>
1679
1686
  (runtime: Pick<WardicServices.Runner<never>, "runFork">) =>
1680
1687
  (failure: VariantTarget.VariantFailure): void => {
1681
- runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(failure.defect)), { variant: failure.name }))
1688
+ runtime.runFork(Effect.annotateLogs(Report.callbackFailed(message, Cause.die(failure.defect)), { variant: failure.name }))
1682
1689
  }
1683
1690
 
1684
1691
  /** How a Subject's variant that throws is reported, on its runtime. */
@@ -361,6 +361,13 @@ export interface VariantConfig extends GestureConfig {
361
361
  * entry is, as Motion's `isControllingVariants`, so it hands down the names its controls set.
362
362
  */
363
363
  readonly controlled?: boolean | undefined
364
+ /**
365
+ * Whether it's a **Variant child** by its own word (probe: hooks-first, the gap grill's Q26): one
366
+ * that names gesture variants of its own is one all the same, joining its nearest ancestor with
367
+ * variants and handing its own gesture names down with the ones it takes. Left out, Motion's rule
368
+ * alone decides, as today.
369
+ */
370
+ readonly variantChild?: boolean | undefined
364
371
  }
365
372
 
366
373
  /** An `initial` a Subject hands its children: a variant name or list (#297), `false` (#134), or `undefined` for a values map or nothing. */
@@ -417,9 +424,9 @@ export const controlsChangeOf = (
417
424
  return change
418
425
  }
419
426
 
420
- /** Whether a Subject is a **Variant child** (CONTEXT.md). */
427
+ /** Whether a Subject is a **Variant child** (CONTEXT.md): by Motion's rule, or by its own word ({@link VariantConfig.variantChild}). */
421
428
  export const isVariantChild = (config: VariantConfig): boolean =>
422
- Predicate.isNotUndefined(config.variants) && !namesOwnVariants(config) && config.inherit !== false
429
+ Predicate.isNotUndefined(config.variants) && (config.variantChild === true || !namesOwnVariants(config)) && config.inherit !== false
423
430
 
424
431
  /** The context a Subject inherits names and its default transition from: its parent's, for a Variant child. */
425
432
  export const inheritedContext = (
@@ -637,10 +644,10 @@ const calledDelayOf = (delayChildren: Config.WardicStagger, index: number, total
637
644
  return delay
638
645
  } catch (defect) {
639
646
  if (Predicate.isUndefined(failures)) {
640
- Report.failureOn(undefined, DELAY_FAILED, Cause.die(defect), { index })
647
+ Report.callbackFailedOn(undefined, DELAY_FAILED, Cause.die(defect), { index })
641
648
  return 0
642
649
  }
643
- if (!failures.delayFailing) failures.runtime.runFork(Report.failure(DELAY_FAILED, Cause.die(defect)).pipe(Effect.annotateLogs({ index })))
650
+ if (!failures.delayFailing) failures.runtime.runFork(Report.callbackFailed(DELAY_FAILED, Cause.die(defect)).pipe(Effect.annotateLogs({ index })))
644
651
  failures.delayFailing = true
645
652
  return 0
646
653
  }