@wardic/solid 2.1.1 → 2.2.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 (234) hide show
  1. package/dist/browser/batch-gestures.js +16 -2
  2. package/dist/browser/batch-gestures.js.map +1 -1
  3. package/dist/browser/batch-reorder-places.js +3 -3
  4. package/dist/browser/batch-reorder.js +17 -8
  5. package/dist/browser/batch-reorder.js.map +1 -1
  6. package/dist/browser/create-animation-controls.js +22 -0
  7. package/dist/browser/create-animation-controls.js.map +1 -0
  8. package/dist/browser/frame-effect.js +14 -3
  9. package/dist/browser/frame-effect.js.map +1 -1
  10. package/dist/browser/gesture-callbacks.js +3 -1
  11. package/dist/browser/gesture-callbacks.js.map +1 -1
  12. package/dist/browser/index.js +1 -1
  13. package/dist/browser/index.js.map +1 -1
  14. package/dist/browser/kept-transform.js +53 -0
  15. package/dist/browser/kept-transform.js.map +1 -0
  16. package/dist/browser/lifecycle.js +22 -13
  17. package/dist/browser/lifecycle.js.map +1 -1
  18. package/dist/browser/live-value.js +37 -5
  19. package/dist/browser/live-value.js.map +1 -1
  20. package/dist/browser/motion-props.js +1 -1
  21. package/dist/browser/presence-hooks.js +1 -1
  22. package/dist/browser/presence-hooks.js.map +1 -1
  23. package/dist/browser/presence.js +18 -3
  24. package/dist/browser/presence.js.map +1 -1
  25. package/dist/browser/provider.js +4 -0
  26. package/dist/browser/provider.js.map +1 -1
  27. package/dist/browser/sensors.js +6 -4
  28. package/dist/browser/sensors.js.map +1 -1
  29. package/dist/browser/stage-ward.js +28 -8
  30. package/dist/browser/stage-ward.js.map +1 -1
  31. package/dist/browser/stage.js.map +1 -1
  32. package/dist/browser/unstable/v2/index.js.map +1 -1
  33. package/dist/browser/v1/batch-reorder-group.js +4 -4
  34. package/dist/browser/v1/create-batch.js +30 -2
  35. package/dist/browser/v1/create-batch.js.map +1 -1
  36. package/dist/browser/v1/create-ward.js +22 -8
  37. package/dist/browser/v1/create-ward.js.map +1 -1
  38. package/dist/browser/v1/directive.js +7 -2
  39. package/dist/browser/v1/directive.js.map +1 -1
  40. package/dist/browser/v1/index.js +1 -1
  41. package/dist/browser/v1/index.js.map +1 -1
  42. package/dist/browser/v1/live-value.js +8 -3
  43. package/dist/browser/v1/live-value.js.map +1 -1
  44. package/dist/browser/v1/presence.js +1 -1
  45. package/dist/browser/v1/presence.js.map +1 -1
  46. package/dist/browser/v1/provider.js +4 -0
  47. package/dist/browser/v1/provider.js.map +1 -1
  48. package/dist/browser/v1/reorder.js +5 -1
  49. package/dist/browser/v1/reorder.js.map +1 -1
  50. package/dist/browser/v1/variant-node.js +10 -7
  51. package/dist/browser/v1/variant-node.js.map +1 -1
  52. package/dist/browser/variant-node.js +10 -7
  53. package/dist/browser/variant-node.js.map +1 -1
  54. package/dist/browser/ward.js +19 -9
  55. package/dist/browser/ward.js.map +1 -1
  56. package/dist/server/batch-gestures.js +16 -2
  57. package/dist/server/batch-gestures.js.map +1 -1
  58. package/dist/server/batch-reorder-places.js +3 -3
  59. package/dist/server/batch-reorder.js +17 -8
  60. package/dist/server/batch-reorder.js.map +1 -1
  61. package/dist/server/create-animation-controls.js +22 -0
  62. package/dist/server/create-animation-controls.js.map +1 -0
  63. package/dist/server/frame-effect.js +14 -3
  64. package/dist/server/frame-effect.js.map +1 -1
  65. package/dist/server/gesture-callbacks.js +3 -1
  66. package/dist/server/gesture-callbacks.js.map +1 -1
  67. package/dist/server/index.js +1 -1
  68. package/dist/server/index.js.map +1 -1
  69. package/dist/server/kept-transform.js +53 -0
  70. package/dist/server/kept-transform.js.map +1 -0
  71. package/dist/server/lifecycle.js +22 -13
  72. package/dist/server/lifecycle.js.map +1 -1
  73. package/dist/server/live-value.js +37 -5
  74. package/dist/server/live-value.js.map +1 -1
  75. package/dist/server/motion-props.js +1 -1
  76. package/dist/server/presence-hooks.js +1 -1
  77. package/dist/server/presence-hooks.js.map +1 -1
  78. package/dist/server/presence.js +18 -3
  79. package/dist/server/presence.js.map +1 -1
  80. package/dist/server/provider.js +4 -0
  81. package/dist/server/provider.js.map +1 -1
  82. package/dist/server/sensors.js +6 -4
  83. package/dist/server/sensors.js.map +1 -1
  84. package/dist/server/stage-ward.js +28 -8
  85. package/dist/server/stage-ward.js.map +1 -1
  86. package/dist/server/stage.js.map +1 -1
  87. package/dist/server/unstable/v2/index.js.map +1 -1
  88. package/dist/server/v1/batch-reorder-group.js +4 -4
  89. package/dist/server/v1/create-batch.js +30 -2
  90. package/dist/server/v1/create-batch.js.map +1 -1
  91. package/dist/server/v1/create-ward.js +22 -8
  92. package/dist/server/v1/create-ward.js.map +1 -1
  93. package/dist/server/v1/directive.js +7 -2
  94. package/dist/server/v1/directive.js.map +1 -1
  95. package/dist/server/v1/index.js +1 -1
  96. package/dist/server/v1/index.js.map +1 -1
  97. package/dist/server/v1/live-value.js +8 -3
  98. package/dist/server/v1/live-value.js.map +1 -1
  99. package/dist/server/v1/presence.js +1 -1
  100. package/dist/server/v1/presence.js.map +1 -1
  101. package/dist/server/v1/provider.js +4 -0
  102. package/dist/server/v1/provider.js.map +1 -1
  103. package/dist/server/v1/reorder.js +5 -1
  104. package/dist/server/v1/reorder.js.map +1 -1
  105. package/dist/server/v1/variant-node.js +10 -7
  106. package/dist/server/v1/variant-node.js.map +1 -1
  107. package/dist/server/variant-node.js +10 -7
  108. package/dist/server/variant-node.js.map +1 -1
  109. package/dist/server/ward.js +19 -9
  110. package/dist/server/ward.js.map +1 -1
  111. package/dist/solid/batch-gestures.d.ts.map +1 -1
  112. package/dist/solid/batch-gestures.js +18 -2
  113. package/dist/solid/batch-gestures.js.map +1 -1
  114. package/dist/solid/batch-reorder-places.js +3 -3
  115. package/dist/solid/batch-reorder.d.ts.map +1 -1
  116. package/dist/solid/batch-reorder.js +18 -8
  117. package/dist/solid/batch-reorder.js.map +1 -1
  118. package/dist/solid/create-animation-controls.d.ts +20 -0
  119. package/dist/solid/create-animation-controls.d.ts.map +1 -0
  120. package/dist/solid/create-animation-controls.js +22 -0
  121. package/dist/solid/create-animation-controls.js.map +1 -0
  122. package/dist/solid/frame-effect.d.ts.map +1 -1
  123. package/dist/solid/frame-effect.jsx +19 -5
  124. package/dist/solid/frame-effect.jsx.map +1 -1
  125. package/dist/solid/gesture-callbacks.d.ts.map +1 -1
  126. package/dist/solid/gesture-callbacks.js +2 -0
  127. package/dist/solid/gesture-callbacks.js.map +1 -1
  128. package/dist/solid/index.d.ts +4 -3
  129. package/dist/solid/index.d.ts.map +1 -1
  130. package/dist/solid/index.jsx +1 -1
  131. package/dist/solid/index.jsx.map +1 -1
  132. package/dist/solid/kept-transform.d.ts +15 -0
  133. package/dist/solid/kept-transform.d.ts.map +1 -0
  134. package/dist/solid/kept-transform.js +57 -0
  135. package/dist/solid/kept-transform.js.map +1 -0
  136. package/dist/solid/lifecycle.d.ts +13 -5
  137. package/dist/solid/lifecycle.d.ts.map +1 -1
  138. package/dist/solid/lifecycle.js +20 -21
  139. package/dist/solid/lifecycle.js.map +1 -1
  140. package/dist/solid/live-value.d.ts +2 -0
  141. package/dist/solid/live-value.d.ts.map +1 -1
  142. package/dist/solid/live-value.jsx +39 -5
  143. package/dist/solid/live-value.jsx.map +1 -1
  144. package/dist/solid/motion-props.js +1 -1
  145. package/dist/solid/presence-hooks.jsx +1 -1
  146. package/dist/solid/presence.d.ts.map +1 -1
  147. package/dist/solid/presence.jsx +19 -3
  148. package/dist/solid/presence.jsx.map +1 -1
  149. package/dist/solid/provider.d.ts +2 -0
  150. package/dist/solid/provider.d.ts.map +1 -1
  151. package/dist/solid/provider.jsx +4 -0
  152. package/dist/solid/provider.jsx.map +1 -1
  153. package/dist/solid/sensors.d.ts.map +1 -1
  154. package/dist/solid/sensors.jsx +6 -4
  155. package/dist/solid/sensors.jsx.map +1 -1
  156. package/dist/solid/stage-ward.d.ts +4 -1
  157. package/dist/solid/stage-ward.d.ts.map +1 -1
  158. package/dist/solid/stage-ward.jsx +28 -7
  159. package/dist/solid/stage-ward.jsx.map +1 -1
  160. package/dist/solid/stage.d.ts +4 -1
  161. package/dist/solid/stage.d.ts.map +1 -1
  162. package/dist/solid/stage.js.map +1 -1
  163. package/dist/solid/unstable/v2/index.d.ts +4 -0
  164. package/dist/solid/unstable/v2/index.d.ts.map +1 -1
  165. package/dist/solid/unstable/v2/index.jsx.map +1 -1
  166. package/dist/solid/v1/batch-reorder-group.jsx +4 -4
  167. package/dist/solid/v1/create-batch.d.ts.map +1 -1
  168. package/dist/solid/v1/create-batch.jsx +32 -2
  169. package/dist/solid/v1/create-batch.jsx.map +1 -1
  170. package/dist/solid/v1/create-ward.d.ts +2 -0
  171. package/dist/solid/v1/create-ward.d.ts.map +1 -1
  172. package/dist/solid/v1/create-ward.jsx +22 -8
  173. package/dist/solid/v1/create-ward.jsx.map +1 -1
  174. package/dist/solid/v1/directive.d.ts.map +1 -1
  175. package/dist/solid/v1/directive.jsx +7 -2
  176. package/dist/solid/v1/directive.jsx.map +1 -1
  177. package/dist/solid/v1/index.d.ts +3 -1
  178. package/dist/solid/v1/index.d.ts.map +1 -1
  179. package/dist/solid/v1/index.jsx +1 -1
  180. package/dist/solid/v1/index.jsx.map +1 -1
  181. package/dist/solid/v1/live-value.d.ts +2 -0
  182. package/dist/solid/v1/live-value.d.ts.map +1 -1
  183. package/dist/solid/v1/live-value.jsx +10 -3
  184. package/dist/solid/v1/live-value.jsx.map +1 -1
  185. package/dist/solid/v1/presence.jsx +1 -1
  186. package/dist/solid/v1/provider.d.ts +2 -0
  187. package/dist/solid/v1/provider.d.ts.map +1 -1
  188. package/dist/solid/v1/provider.jsx +4 -0
  189. package/dist/solid/v1/provider.jsx.map +1 -1
  190. package/dist/solid/v1/reorder.d.ts.map +1 -1
  191. package/dist/solid/v1/reorder.jsx +5 -1
  192. package/dist/solid/v1/reorder.jsx.map +1 -1
  193. package/dist/solid/v1/variant-node.d.ts +2 -1
  194. package/dist/solid/v1/variant-node.d.ts.map +1 -1
  195. package/dist/solid/v1/variant-node.js +10 -7
  196. package/dist/solid/v1/variant-node.js.map +1 -1
  197. package/dist/solid/variant-node.d.ts +2 -1
  198. package/dist/solid/variant-node.d.ts.map +1 -1
  199. package/dist/solid/variant-node.js +10 -7
  200. package/dist/solid/variant-node.js.map +1 -1
  201. package/dist/solid/ward.d.ts.map +1 -1
  202. package/dist/solid/ward.jsx +20 -9
  203. package/dist/solid/ward.jsx.map +1 -1
  204. package/package.json +5 -5
  205. package/src/batch-gestures.ts +16 -3
  206. package/src/batch-reorder-places.ts +3 -3
  207. package/src/batch-reorder.ts +17 -8
  208. package/src/create-animation-controls.ts +22 -0
  209. package/src/frame-effect.tsx +14 -3
  210. package/src/gesture-callbacks.ts +2 -0
  211. package/src/index.tsx +4 -2
  212. package/src/kept-transform.ts +57 -0
  213. package/src/lifecycle.ts +32 -24
  214. package/src/live-value.tsx +37 -5
  215. package/src/motion-props.ts +1 -1
  216. package/src/presence-hooks.tsx +1 -1
  217. package/src/presence.tsx +19 -3
  218. package/src/provider.tsx +5 -0
  219. package/src/sensors.tsx +6 -4
  220. package/src/stage-ward.tsx +32 -10
  221. package/src/stage.ts +4 -1
  222. package/src/unstable/v2/index.tsx +4 -0
  223. package/src/v1/batch-reorder-group.tsx +4 -4
  224. package/src/v1/create-batch.tsx +34 -2
  225. package/src/v1/create-ward.tsx +24 -9
  226. package/src/v1/directive.tsx +7 -2
  227. package/src/v1/index.tsx +3 -1
  228. package/src/v1/live-value.tsx +10 -3
  229. package/src/v1/presence.tsx +1 -1
  230. package/src/v1/provider.tsx +5 -0
  231. package/src/v1/reorder.tsx +5 -1
  232. package/src/v1/variant-node.ts +10 -5
  233. package/src/variant-node.ts +10 -5
  234. package/src/ward.tsx +21 -10
@@ -266,6 +266,8 @@ export interface RunSpineOptions {
266
266
  readonly valueReads?: ElementSetup.ElementValueReads | undefined
267
267
  /** The provider runtime the spine forks its fibers on. */
268
268
  readonly runtime: WardicRuntime
269
+ /** Its element's dynamic variants that throw (#979): made with its variant node, which reports to them too. */
270
+ readonly variantFailures: Spine.VariantFailures
269
271
  /** The provider-owned flush gate (ADR-0006). */
270
272
  readonly gate: FlushGate.Shape
271
273
  /** SSR/hydration-stable gate id for this element's entry. */
@@ -433,7 +435,7 @@ const valueReadsIn = (given: ElementSetup.ElementValueReads | undefined): Elemen
433
435
  }
434
436
 
435
437
  export function runSpine(opts: RunSpineOptions): void {
436
- const { bindGestures, byName, canStart, cfg, controls, defaultsInProps, el, entersFresh, extraDelay, gate, hydrating, id, internal = NO_INTERNALS, live, makeSink, onFrame, parent, restartStyle, runtime, styleOf, tag } = opts
438
+ const { bindGestures, byName, canStart, cfg, controls, defaultsInProps, el, entersFresh, extraDelay, gate, hydrating, id, internal = NO_INTERNALS, live, makeSink, onFrame, parent, restartStyle, runtime, styleOf, tag, variantFailures } = opts
437
439
  // Its Features (#511, ADR-0067): its section's, and those it brings.
438
440
  const features = UndefinedOr.match(opts.features, { onDefined: identity, onUndefined: () => useElementFeatures(internal) })
439
441
  // Its section's projection system, the `layout` Feature's (#511): `undefined` without it. Read now,
@@ -473,6 +475,10 @@ export function runSpine(opts: RunSpineOptions): void {
473
475
  // name for a Variant child that has none (#50). Seeds the spring `from` Snapshot so
474
476
  // frame 1 flows continuously out of it (no snap).
475
477
  const start = Spine.startOf(untrack(cfg), parent, PresenceRecord.presenceBlocksInitial(presence), untrack)
478
+ // A variant whose resolver throws is this element's alone: reported once until it resolves, the element
479
+ // keeping its last target, and nothing thrown into Solid's update, which would freeze every element in
480
+ // it (#979; ADR-0074).
481
+ Spine.reportStart(variantFailures, start)
476
482
  const snapshot = Spine.snapshotOf(start)
477
483
  const reuse = Spine.makeReuse()
478
484
  // Where an element starts (#414): the ward's start, or, for one that comes after the last left the
@@ -482,6 +488,7 @@ export function runSpine(opts: RunSpineOptions): void {
482
488
  if (Predicate.isUndefined(entersFresh)) return start
483
489
  if (Bool.not(entersFresh(element))) return start
484
490
  const fresh = Spine.startOf(untrack(cfg), parent, false, untrack)
491
+ Spine.reportStart(variantFailures, fresh)
485
492
  snapshot.values = { ...fresh.initialValues }
486
493
  snapshot.velocities = {}
487
494
  snapshot.drawnAt = {}
@@ -864,7 +871,7 @@ export function runSpine(opts: RunSpineOptions): void {
864
871
  // change, a recognizer's flip or the drag's recomputes it, and only one that resolves a new
865
872
  // target drives a Retarget. A `transition`, a callback or an option alone tells nothing, as
866
873
  // Motion's doesn't.
867
- const target = createMemo((): Spine.Resolution => Spine.resolutionOf(cfg(), parent, begin.initialLink, active(), snapshot, ownChange()), undefined, { equals: Spine.sameResolution })
874
+ const target = createMemo((): Spine.Resolution => Spine.keptOf(variantFailures, Spine.resolutionOf(cfg(), parent, begin.initialLink, active(), snapshot, ownChange())), undefined, { equals: Spine.sameResolution })
868
875
  // A colour only the `colors` Feature reads, on a Slim element without it (#511, decision 7): said
869
876
  // once per provider, in development only, and not while a lazy load is on its way.
870
877
  if (DEV && internal.complete !== true) warnUnreadColors(useFeatureRegistry(), features, () => target().resolved)
@@ -874,11 +881,11 @@ export function runSpine(opts: RunSpineOptions): void {
874
881
 
875
882
  // The spine (core's `unstable/Spine`): on each target change, end the running legs and reseed a fresh
876
883
  // primitive from the Snapshot (velocity-preserving), into the gate.
877
- const spineOptions: Spine.ElementSpineOptions = {
884
+ const spineOptions: Spine.SubjectSpineOptions = {
878
885
  runtime,
879
886
  gate,
880
887
  id,
881
- element,
888
+ subject: element,
882
889
  tag,
883
890
  config: configNow,
884
891
  parent,
@@ -922,12 +929,12 @@ export function runSpine(opts: RunSpineOptions): void {
922
929
  UndefinedOr.match(held.track, { onUndefined: () => Predicate.isNotUndefined(layoutNodeOf(nodeAtMount, nodeLater)), onDefined: () => held.projected }),
923
930
  })
924
931
  }
925
- const spine = Spine.makeElementSpine(spineOptions)
932
+ const spine = Spine.makeSubjectSpine(spineOptions)
926
933
  onCleanup(spine.dispose)
927
934
  // Its Imperative animations (#433) go through its spine while it's mounted.
928
935
  onCleanup(Imperative.registerAnimatable(element, spine))
929
936
  // Its Animation controls (#433) reach it while it's mounted.
930
- UndefinedOr.map(controls, (c) => onCleanup(AnimationControls.subscribe(c.controls, AnimationControls.controlledElement(c.set, { custom: () => untrack(cfg).custom, snapshot }, spine.stop))))
937
+ UndefinedOr.map(controls, (c) => onCleanup(AnimationControls.subscribe(c.controls, AnimationControls.controlledSubject(c.set, { custom: () => untrack(cfg).custom, snapshot }, spine.stop))))
931
938
  // A child back under its key starts where its leaver is drawn (#286), before its first Retarget.
932
939
  if (Predicate.isNotUndefined(taken)) spine.seed(taken)
933
940
 
@@ -1023,7 +1030,10 @@ export function createWardWith(config: WardConfig.WardConfig | Accessor<WardConf
1023
1030
  // Its place in variant orchestration (ADR-0007, #50): what it hands its children, and,
1024
1031
  // as a Variant child, the ancestor it inherits from and joins (its stagger slot, its
1025
1032
  // `when`). Read at hook-call time (component body owner), for this instance's lifetime.
1026
- const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change))
1033
+ // A variant that throws is this element's alone (#979): its failures, which its spine keeps and its
1034
+ // orchestration reports to, once.
1035
+ const variantFailures = Spine.variantFailuresOf(runtime)
1036
+ const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change), variantFailures)
1027
1037
 
1028
1038
  // The Renderer's PURE project (ADR-0003: synchronous, no engine), read once by the provider (#618, M1).
1029
1039
  const { project } = useWardicRenderer()
@@ -1102,6 +1112,7 @@ export function createWardWith(config: WardConfig.WardConfig | Accessor<WardConf
1102
1112
  runSpine({
1103
1113
  valueReads,
1104
1114
  runtime,
1115
+ variantFailures,
1105
1116
  gate,
1106
1117
  id,
1107
1118
  el,
@@ -1199,9 +1210,13 @@ const serverWard = (config: WardConfig.WardConfig | Accessor<WardConfig.WardConf
1199
1210
  // (#50); a Variant child's Starting style starts from its ancestor's `initial` name.
1200
1211
  const node = VariantTree.serverVariantNode(c, useVariantContext())
1201
1212
  const layoutNode = Spine.isLayoutNode(c)
1202
- const seed = Style.starting(internal.tag, ElementSetup.drawnAtRest(VariantTree.startingValuesOf(c, node.inherited, PresenceRecord.presenceBlocksInitial(usePresenceContext()), untrack), layoutNode, c.transformTemplate))
1213
+ // Its start, resolved once: the seed and the Appear animation's initial values read it. A variant that
1214
+ // throws leaves its values out of the markup, logged on the server (#979).
1215
+ const starting = VariantTree.startingOf(c, node.inherited, PresenceRecord.presenceBlocksInitial(usePresenceContext()), untrack)
1216
+ if (Option.isSome(starting.failure)) Spine.variantFailedOnServer(starting.failure.value)
1217
+ const initialValues = starting.values
1218
+ const seed = Style.starting(internal.tag, ElementSetup.drawnAtRest(initialValues, layoutNode, c.transformTemplate))
1203
1219
  const dragDefaults = DragDefaults.dragDefaultsOf(c, internal)
1204
- const initialValues = VariantTree.startingValuesOf(c, node.inherited, PresenceRecord.presenceBlocksInitial(usePresenceContext()), untrack)
1205
1220
  // Its Appear animation (#48, ADR-0044): its slot in the render's, and the group its Variant
1206
1221
  // children join when it leads one.
1207
1222
  const appear = serverAppearOf(c, internal.tag, initialValues, node, VariantTree.startsQuiet(c, node.inherited, PresenceRecord.presenceBlocksInitial(usePresenceContext()), untrack))
@@ -53,12 +53,17 @@ export const runDirective = (el: HTMLElement, value: Accessor<WardConfig.WardCon
53
53
  // provides none.
54
54
  // Animation controls for its `animate` (#433): each change they make is its entry.
55
55
  const { cfg, controls } = controlledOf(value)
56
- const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change))
56
+ const runtime = useWardicRuntime()
57
+ // A variant that throws is this element's alone (#979): its failures, which its spine keeps and its
58
+ // orchestration reports to, once.
59
+ const variantFailures = Spine.variantFailuresOf(runtime)
60
+ const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change), variantFailures)
57
61
  // Under a presence, its element is told to it (#286): its `key`, and whether it's a twin.
58
62
  const presence = usePresenceContext()
59
63
  if (Predicate.isNotUndefined(presence)) Spine.madeWith(presence, constVoid, untrack(cfg))(el)
60
64
  runSpine({
61
- runtime: useWardicRuntime(),
65
+ runtime,
66
+ variantFailures,
62
67
  gate: useWardicGate(),
63
68
  id: createUniqueId(),
64
69
  el: () => el,
package/src/v1/index.tsx CHANGED
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * @deprecated Solid 1's binding, deprecated and frozen: it goes at Wardic's next major. Solid 2's is `@wardic/solid` (#566).
19
19
  */
20
- export const VERSION = "2.1.1"
20
+ export const VERSION = "2.2.0"
21
21
 
22
22
  /**
23
23
  * `WardicProvider` (one Effect runtime + `AtomRegistry` per ADR-0006), the
@@ -184,6 +184,8 @@ export {
184
184
  streamToSignal,
185
185
  } from "./bridge.tsx"
186
186
  export type {
187
+ /** @deprecated Solid 1's binding, deprecated and frozen: it goes at Wardic's next major. Solid 2's is `@wardic/solid` (#566). */
188
+ WardicDragEndInfo,
187
189
  /** @deprecated Solid 1's binding, deprecated and frozen: it goes at Wardic's next major. Solid 2's is `@wardic/solid` (#566). */
188
190
  WardicDragInfo,
189
191
  /** @deprecated Solid 1's binding, deprecated and frozen: it goes at Wardic's next major. Solid 2's is `@wardic/solid` (#566). */
@@ -34,7 +34,8 @@ import { eachFrameOf } from "../animation-frame.ts"
34
34
  import { fromAtom } from "./bridge.tsx"
35
35
  import * as LiveStyle from "@wardic/dom/unstable/LiveStyle"
36
36
  import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
37
- import { useWardicRuntime, useWardicSkipAnimations } from "./provider.tsx"
37
+ import { FUNCTION_FAILED, keptComputeOf, MIXER_FAILED } from "../kept-transform.ts"
38
+ import { useProvidedRuntime, useWardicRuntime, useWardicSkipAnimations } from "./provider.tsx"
38
39
  import type { WardicRuntime, WardicServices } from "../runtime.ts"
39
40
  import { isServer } from "./server.ts"
40
41
  import * as ServerInterpolators from "@wardic/dom/unstable/ServerInterpolators"
@@ -58,6 +59,8 @@ const atomAccessorOf = <A,>(atom: Atom.Atom<A>): Accessor<A> => {
58
59
  * two stops blends their outputs, numbers, units and colours alike. `input` is as long as `output`,
59
60
  * ascending or descending; outside it the ends hold, unless `clamp: false`. `ease` eases each stretch,
60
61
  * one for all or one each, and a `mixer`, `(from, to) => (t) => value`, blends outputs of any type. The function form needs no `WardicProvider` when its source is a signal.
62
+ * A function or a `mixer` that throws keeps the value it gave last, and is logged once until it returns;
63
+ * one that throws for its first value throws to whatever reads it first.
61
64
  * Through ranges from a `createScroll` value, the browser draws it with the scroll where it can.
62
65
  * Motion's `useTransform`.
63
66
  *
@@ -82,9 +85,12 @@ export function createTransform(
82
85
  output?: ReadonlyArray<unknown>,
83
86
  options?: LiveValue.TransformOptions<unknown>,
84
87
  ): Accessor<unknown> {
88
+ // An app's function, or a `mixer` in its ranges, that throws: its last value kept, reported, and Solid's
89
+ // update it runs in goes on (#979).
85
90
  if (Predicate.isFunction(fnOrInput)) {
86
91
  const read = accessorOf(source)
87
- return createMemo(() => fnOrInput(read()))
92
+ if (isServer) return createMemo(() => fnOrInput(read()))
93
+ return createMemo(keptComputeOf(read, fnOrInput, useProvidedRuntime(), FUNCTION_FAILED))
88
94
  }
89
95
  // On an Atom, its own or the one it carries: derived on it by core, so it's set where its source is,
90
96
  // and one from a scroll is described for a Timeline value (#240).
@@ -94,7 +100,8 @@ export function createTransform(
94
100
  }
95
101
  const read = accessorOf(source)
96
102
  const map = interpolatorOf(fnOrInput as ReadonlyArray<number>, output as ReadonlyArray<unknown>, options)
97
- return createMemo(() => map(read() as number))
103
+ if (isServer) return createMemo(() => map(read() as number))
104
+ return createMemo(keptComputeOf(read as Accessor<number>, map, useProvidedRuntime(), MIXER_FAILED))
98
105
  }
99
106
 
100
107
  /**
@@ -208,7 +208,7 @@ const watchOf = (target: unknown, holds: boolean, onLeave: (safeToRemove: () =>
208
208
  UndefinedOr.map(usePresenceContext(), (presence) =>
209
209
  UndefinedOr.map(presence.watch, (watch) =>
210
210
  watch({
211
- element: () => elementOf(target),
211
+ subject: () => elementOf(target),
212
212
  holds,
213
213
  leave: (custom, release) => {
214
214
  setPresent(false)
@@ -338,6 +338,11 @@ export function useWardicRuntime(): WardicRuntime {
338
338
  return fromContext(useContext(WardicContext), "useWardicRuntime", (value) => value.runtime)
339
339
  }
340
340
 
341
+ /** The nearest provider's runtime, or none outside one: where a transform's failure is reported (#979). */
342
+ export function useProvidedRuntime(): WardicRuntime | undefined {
343
+ return UndefinedOr.map(useContext(WardicContext), (value) => value.runtime)
344
+ }
345
+
341
346
  /**
342
347
  * The nearest `WardicProvider`'s flush gate: what a binding registers its elements with, and writes
343
348
  * their values into, committed once a frame. For building an element of your own on Wardic's
@@ -467,8 +467,11 @@ export function reorderItem(el: HTMLElement, value: Accessor<ReorderItemDirectiv
467
467
  return { ...rest, layout: itemLayoutOf(rest.layout) }
468
468
  })
469
469
  // As `use:wardic`: a Variant child joins the nearest variant context; it provides none (#50).
470
- const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change))
471
470
  const runtime = useWardicRuntime()
471
+ // A variant that throws is this element's alone (#979): its failures, which its spine keeps and its
472
+ // orchestration reports to, once.
473
+ const variantFailures = Spine.variantFailuresOf(runtime)
474
+ const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change), variantFailures)
472
475
  const group = first.group as ItemGroup<unknown>
473
476
  // The keyboard reorder's tab stop and instructions (ADR-0037), on the element itself: the app's
474
477
  // own `tabindex` wins, and its `aria-describedby` ids are kept.
@@ -481,6 +484,7 @@ export function reorderItem(el: HTMLElement, value: Accessor<ReorderItemDirectiv
481
484
  })
482
485
  runSpine({
483
486
  runtime,
487
+ variantFailures,
484
488
  gate: useWardicGate(),
485
489
  id: createUniqueId(),
486
490
  el: () => el,
@@ -14,6 +14,7 @@ import { type Accessor, createEffect, createMemo, createSignal, on, onCleanup, u
14
14
  import type * as AnimationControls from "@wardic/core/unstable/AnimationControls"
15
15
  import type * as WardConfig from "@wardic/dom/unstable/WardConfig"
16
16
  import * as VariantTree from "@wardic/core/unstable/VariantTree"
17
+ import * as Spine from "@wardic/core/unstable/Spine"
17
18
  import * as VariantTarget from "@wardic/core/unstable/VariantTarget"
18
19
 
19
20
  /** An element's place in variant orchestration, on the client. */
@@ -70,7 +71,10 @@ const ownOrchestration = (
70
71
  parent: VariantTree.WardicVariantContextValue | undefined,
71
72
  inherited: VariantTree.WardicVariantContextValue | undefined,
72
73
  change: Accessor<AnimationControls.ControlsChange | undefined>,
74
+ failures: Spine.VariantFailures | undefined,
73
75
  ): OwnOrchestration => {
76
+ // What it resolves, told to its element's failures (#979): made here, as only an element that orchestrates has one.
77
+ const orchestrated = UndefinedOr.map(failures, Spine.orchestrationOf)
74
78
  const config = untrack(cfg)
75
79
  // Children in mount order (a Set keeps insertion order); the effect below snapshots that
76
80
  // order at each trigger. Kept with a count of the unsettled ones rather than a signal of the
@@ -165,8 +169,8 @@ const ownOrchestration = (
165
169
  VariantTree.orchestrationAt(at(), () => {
166
170
  const c = cfg()
167
171
  const own = UndefinedOr.match(VariantTree.topGestureName(VariantTree.activeNamesOf(gestures())), {
168
- onDefined: (name) => VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom),
169
- onUndefined: () => VariantTarget.ownTransitionOf(c.animate, variant(), c.variants, c.custom),
172
+ onDefined: (name) => VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom, orchestrated),
173
+ onUndefined: () => VariantTarget.ownTransitionOf(c.animate, variant(), c.variants, c.custom, orchestrated),
170
174
  })
171
175
  return VariantTarget.transitionOfTarget(own, c.transition)
172
176
  }))
@@ -205,7 +209,7 @@ const ownOrchestration = (
205
209
  const kept = known.get(name)
206
210
  if (Predicate.isNotUndefined(kept)) return kept
207
211
  const c = untrack(cfg)
208
- const made = VariantTree.nameConfigOf(VariantTarget.transitionOfTarget(VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom), c.transition))
212
+ const made = VariantTree.nameConfigOf(VariantTarget.transitionOfTarget(VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom, orchestrated), c.transition))
209
213
  known.set(name, made)
210
214
  return made
211
215
  }
@@ -268,6 +272,7 @@ export const createVariantNode = (
268
272
  cfg: Accessor<VariantTree.VariantConfig>,
269
273
  parent: VariantTree.WardicVariantContextValue | undefined,
270
274
  controls?: Accessor<AnimationControls.ControlsChange | undefined>,
275
+ failures?: Spine.VariantFailures,
271
276
  ): VariantNode => {
272
277
  const config = untrack(cfg)
273
278
  const inherited = VariantTree.inheritedContext(config, parent)
@@ -278,7 +283,7 @@ export const createVariantNode = (
278
283
  if (Predicate.isNotUndefined(joined)) onCleanup(joined.registration.dispose)
279
284
  const own = Bool.match(VariantTree.hasOwnVariants(config), {
280
285
  onFalse: constUndefined,
281
- onTrue: () => ownOrchestration(cfg, parent, inherited, change),
286
+ onTrue: () => ownOrchestration(cfg, parent, inherited, change, failures),
282
287
  })
283
288
  // The spine reports on every frame (the per-frame path, docs/agents/effect-first.md): both
284
289
  // reports are resolved here, once, so a frame makes two plain calls and allocates nothing.
@@ -293,7 +298,7 @@ export const createVariantNode = (
293
298
  extraDelay: UndefinedOr.map(joined, ({ context, registration }) => (name: string | undefined) => {
294
299
  const s = VariantTree.staggerOfName(context, name)
295
300
  const n = registration.total()
296
- return VariantTree.childDelayOf(s, registration.index(), n)
301
+ return VariantTree.childDelayOf(s, registration.index(), n, failures)
297
302
  }),
298
303
  canStart: () =>
299
304
  UndefinedOr.match(inherited, { onUndefined: constTrue, onDefined: (context) => context.childrenMayStart() }) &&
@@ -28,6 +28,7 @@ import type * as AnimationControls from "@wardic/core/unstable/AnimationControls
28
28
  import type * as WardConfig from "@wardic/dom/unstable/WardConfig"
29
29
  import * as VariantTree from "@wardic/core/unstable/VariantTree"
30
30
  import { CLIENT_ONLY, CLIENT_ONLY_SYNC } from "./solid-reactivity.ts"
31
+ import * as Spine from "@wardic/core/unstable/Spine"
31
32
  import * as VariantTarget from "@wardic/core/unstable/VariantTarget"
32
33
 
33
34
  /**
@@ -111,7 +112,10 @@ const ownOrchestration = (
111
112
  parent: VariantTree.WardicVariantContextValue | undefined,
112
113
  inherited: VariantTree.WardicVariantContextValue | undefined,
113
114
  change: Accessor<AnimationControls.ControlsChange | undefined>,
115
+ failures: Spine.VariantFailures | undefined,
114
116
  ): OwnOrchestration => {
117
+ // What it resolves, told to its element's failures (#979): made here, as only an element that orchestrates has one.
118
+ const orchestrated = UndefinedOr.map(failures, Spine.orchestrationOf)
115
119
  // Children in mount order (a Set keeps insertion order), snapshotted at each trigger. Kept with a
116
120
  // count of the unsettled ones rather than a signal of the records, so a child's mount, unmount or
117
121
  // settle costs the same at 1,000 children as at 1. The count is plain, and the signal its copy:
@@ -225,8 +229,8 @@ const ownOrchestration = (
225
229
  VariantTree.orchestrationAt(at(), () => {
226
230
  const c = cfg()
227
231
  const own = UndefinedOr.match(VariantTree.topGestureName(VariantTree.activeNamesOf(gestures())), {
228
- onDefined: (name) => VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom),
229
- onUndefined: () => VariantTarget.ownTransitionOf(c.animate, variant(), c.variants, c.custom),
232
+ onDefined: (name) => VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom, orchestrated),
233
+ onUndefined: () => VariantTarget.ownTransitionOf(c.animate, variant(), c.variants, c.custom, orchestrated),
230
234
  })
231
235
  return VariantTarget.transitionOfTarget(own, c.transition)
232
236
  }),
@@ -260,7 +264,7 @@ const ownOrchestration = (
260
264
  const kept = known.get(name)
261
265
  if (Predicate.isNotUndefined(kept)) return kept
262
266
  const c = untrack(cfg)
263
- const made = untrack(() => VariantTree.nameConfigOf(VariantTarget.transitionOfTarget(VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom), c.transition)))
267
+ const made = untrack(() => VariantTree.nameConfigOf(VariantTarget.transitionOfTarget(VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom, orchestrated), c.transition)))
264
268
  known.set(name, made)
265
269
  return made
266
270
  }
@@ -328,6 +332,7 @@ export const createVariantNode = (
328
332
  config: VariantTree.VariantConfig,
329
333
  parent: VariantTree.WardicVariantContextValue | undefined,
330
334
  controls?: Accessor<AnimationControls.ControlsChange | undefined>,
335
+ failures?: Spine.VariantFailures,
331
336
  ): VariantNode => {
332
337
  if (Bool.and(Predicate.isUndefined(config.variants), Bool.not(VariantTree.namesOwnVariants(config)))) return plainNode(config, parent)
333
338
  const inherited = VariantTree.inheritedContext(config, parent)
@@ -338,7 +343,7 @@ export const createVariantNode = (
338
343
  if (Predicate.isNotUndefined(joined)) onCleanup(joined.registration.dispose)
339
344
  const own = Bool.match(VariantTree.hasOwnVariants(config), {
340
345
  onFalse: constUndefined,
341
- onTrue: () => ownOrchestration(cfg, config, parent, inherited, change),
346
+ onTrue: () => ownOrchestration(cfg, config, parent, inherited, change, failures),
342
347
  })
343
348
  // The spine reports on every frame (the per-frame path, docs/agents/effect-first.md): both
344
349
  // reports are resolved here, once, so a frame makes two plain calls and allocates nothing.
@@ -353,7 +358,7 @@ export const createVariantNode = (
353
358
  extraDelay: UndefinedOr.map(joined, ({ context, registration }) => (name: string | undefined) => {
354
359
  const s = VariantTree.staggerOfName(context, name)
355
360
  const n = registration.total()
356
- return VariantTree.childDelayOf(s, registration.index(), n)
361
+ return VariantTree.childDelayOf(s, registration.index(), n, failures)
357
362
  }),
358
363
  canStart: () =>
359
364
  UndefinedOr.match(inherited, { onUndefined: constTrue, onDefined: (context) => context.childrenMayStart() }) &&
package/src/ward.tsx CHANGED
@@ -824,6 +824,7 @@ const nodeFor = (
824
824
  config: WardConfigValues,
825
825
  parent: VariantTree.WardicVariantContextValue | undefined,
826
826
  change: Accessor<AnimationControls.ControlsChange | undefined> | undefined,
827
+ failures: Spine.VariantFailures,
827
828
  ): VariantNode => {
828
829
  if (Predicate.isNotUndefined(share)) {
829
830
  const node = share.node
@@ -831,7 +832,7 @@ const nodeFor = (
831
832
  if (share.carries) return node
832
833
  }
833
834
  }
834
- return createVariantNode(cfg, config, parent, change)
835
+ return createVariantNode(cfg, config, parent, change, failures)
835
836
  }
836
837
 
837
838
  /** A ward's **Animation controls** (#433): the controls, its view with each change as its entry, and the change in effect. */
@@ -1006,7 +1007,10 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1006
1007
  // Its place in variant orchestration (ADR-0007, #50): where it's made, its given parent's (#349),
1007
1008
  // or its given ward's.
1008
1009
  const parent = variantParentOf(internal)
1009
- const node = nodeFor(share, cfg, initialConfig, parent, UndefinedOr.map(controls, (c) => c.change))
1010
+ // A variant that throws is this element's alone (#979): its failures, which its spine keeps and its
1011
+ // orchestration reports to, once.
1012
+ const variantFailures = Spine.variantFailuresOf(runtime)
1013
+ const node = nodeFor(share, cfg, initialConfig, parent, UndefinedOr.map(controls, (c) => c.change), variantFailures)
1010
1014
 
1011
1015
  // The nearest <AnimatePresence> (ADR-0007), or none.
1012
1016
  const presence = usePresenceContext()
@@ -1018,6 +1022,9 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1018
1022
  const presenceBlocks = PresenceRecord.presenceBlocksInitial(presence)
1019
1023
  if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(initialConfig, node.inherited, presenceBlocks))) throw new Error(STARTS_AT_PENDING)
1020
1024
  const start = Spine.startOf(initialConfig, node.inherited, presenceBlocks, untrack)
1025
+ // A variant whose resolver throws is this element's alone: reported once until it resolves, the element
1026
+ // keeping its last target (#979; ADR-0074).
1027
+ Spine.reportStart(variantFailures, start)
1021
1028
  // Read once by the provider (#618, M1).
1022
1029
  const { project } = useWardicRenderer()
1023
1030
 
@@ -1073,6 +1080,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1073
1080
  // The config now, a plain copy read untracked, as setup reads it: this runs in the mount effect.
1074
1081
  const now = WARD_VIEW.setupOf(view).config
1075
1082
  begun = Spine.startOf(now, node.inherited, false, untrack)
1083
+ Spine.reportStart(variantFailures, begun)
1076
1084
  snapshot.values = { ...begun.initialValues }
1077
1085
  snapshot.velocities = {}
1078
1086
  snapshot.drawnAt = {}
@@ -1154,7 +1162,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1154
1162
  const target = createMemo<Spine.Resolution>(
1155
1163
  () => {
1156
1164
  const g = gestures()
1157
- return Spine.resolutionOf(
1165
+ return Spine.keptOf(variantFailures, Spine.resolutionOf(
1158
1166
  cfg(),
1159
1167
  node.inherited,
1160
1168
  start.initialLink,
@@ -1168,7 +1176,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1168
1176
  },
1169
1177
  snapshot,
1170
1178
  ownChange(),
1171
- )
1179
+ ))
1172
1180
  },
1173
1181
  { equals: sameTarget, transparent: true },
1174
1182
  )
@@ -1223,7 +1231,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1223
1231
  // to run a watch in its watch Scope (#318, #379): its gesture watches and its drag track.
1224
1232
  interface Mounted {
1225
1233
  readonly element: HTMLElement
1226
- readonly spine: Spine.ElementSpine
1234
+ readonly spine: Spine.SubjectSpine
1227
1235
  /** Its layout node: made at mount, or as `layout` arrives (#582), which writes it here. */
1228
1236
  layout: ProjectionSystem.NodeHandle | undefined
1229
1237
  /** Makes its layout node on a `layout` that arrived after it mounted (#582); absent unless one was on its way. */
@@ -1549,11 +1557,11 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1549
1557
  })
1550
1558
  }
1551
1559
  let dragTrack = UndefinedOr.map(dragGesture, driveDrag)
1552
- const spineOptions: Spine.ElementSpineOptions = {
1560
+ const spineOptions: Spine.SubjectSpineOptions = {
1553
1561
  runtime,
1554
1562
  gate,
1555
1563
  id,
1556
- element: el,
1564
+ subject: el,
1557
1565
  tag: internal.tag,
1558
1566
  config: configNow,
1559
1567
  parent: node.inherited,
@@ -1598,7 +1606,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1598
1606
  if (Predicate.isUndefined(dragTrack)) dragTrack = driveDrag(gesture)
1599
1607
  }
1600
1608
  }
1601
- const spine = Spine.makeElementSpine(spineOptions)
1609
+ const spine = Spine.makeSubjectSpine(spineOptions)
1602
1610
  // A child back under its key starts where its leaver is drawn (#286), before its first Retarget.
1603
1611
  if (Predicate.isNotUndefined(taken)) spine.seed(taken)
1604
1612
  // Live values in `style` (#130, ADR-0043): followed from the first routed key on.
@@ -1607,7 +1615,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1607
1615
  const unregisterAnimatable = Imperative.registerAnimatable(el, spine)
1608
1616
  const unsubscribe = UndefinedOr.match(controls, {
1609
1617
  onUndefined: () => constVoid,
1610
- onDefined: (c) => AnimationControls.subscribe(c.controls, AnimationControls.controlledElement(c.set, { custom: () => untrack(() => view.custom), snapshot }, spine.stop)),
1618
+ onDefined: (c) => AnimationControls.subscribe(c.controls, AnimationControls.controlledSubject(c.set, { custom: () => untrack(() => view.custom), snapshot }, spine.stop)),
1611
1619
  })
1612
1620
  const m: Mounted = {
1613
1621
  element: el,
@@ -2051,7 +2059,10 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
2051
2059
  if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(atSetup, VariantTree.inheritedContext(atSetup, parent), presenceBlocks))) throw new Error(STARTS_AT_PENDING)
2052
2060
  const c = AnimationControls.uncontrolledOf(WARD_VIEW.snapshotOf(view))
2053
2061
  const node = VariantTree.serverVariantNode(c, parent)
2054
- const initialValues = Spine.startOf(c, node.inherited, presenceBlocks, untrack).initialValues
2062
+ const serverStart = Spine.startOf(c, node.inherited, presenceBlocks, untrack)
2063
+ // A variant that throws leaves its values out of the markup, logged on the server (#979).
2064
+ if (Option.isSome(serverStart.failure)) Spine.variantFailedOnServer(serverStart.failure.value)
2065
+ const initialValues = serverStart.initialValues
2055
2066
  const layoutNode = Spine.isLayoutNode(c)
2056
2067
  const seed = Style.starting(internal.tag, ElementSetup.drawnAtRest(initialValues, layoutNode, c.transformTemplate))
2057
2068
  // Its Appear animation (#48, ADR-0044): its slot in the render's, and the group its Variant