@wardic/dom 1.3.0 → 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.
- package/dist/MeasuredPair.d.ts +14 -1
- package/dist/MeasuredPair.d.ts.map +1 -1
- package/dist/MeasuredPair.js +11 -13
- package/dist/MeasuredPair.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/appear.d.ts +6 -0
- package/dist/internal/appear.d.ts.map +1 -1
- package/dist/internal/appear.js +20 -2
- package/dist/internal/appear.js.map +1 -1
- package/dist/internal/batch-handoff.d.ts.map +1 -1
- package/dist/internal/batch-handoff.js +25 -15
- package/dist/internal/batch-handoff.js.map +1 -1
- package/dist/internal/batch-writer.d.ts +1 -1
- package/dist/internal/batch-writer.d.ts.map +1 -1
- package/dist/internal/batch-writer.js +26 -6
- package/dist/internal/batch-writer.js.map +1 -1
- package/dist/internal/clock.d.ts +6 -0
- package/dist/internal/clock.d.ts.map +1 -1
- package/dist/internal/clock.js +9 -0
- package/dist/internal/clock.js.map +1 -1
- package/dist/internal/default-transition.d.ts +3 -2
- package/dist/internal/default-transition.d.ts.map +1 -1
- package/dist/internal/default-transition.js +14 -3
- package/dist/internal/default-transition.js.map +1 -1
- package/dist/internal/failing.d.ts +9 -0
- package/dist/internal/failing.d.ts.map +1 -0
- package/dist/internal/failing.js +33 -0
- package/dist/internal/failing.js.map +1 -0
- package/dist/internal/length-keys.d.ts +19 -0
- package/dist/internal/length-keys.d.ts.map +1 -0
- package/dist/internal/length-keys.js +77 -0
- package/dist/internal/length-keys.js.map +1 -0
- package/dist/internal/measured-pairs.d.ts +3 -2
- package/dist/internal/measured-pairs.d.ts.map +1 -1
- package/dist/internal/measured-pairs.js +60 -23
- package/dist/internal/measured-pairs.js.map +1 -1
- package/dist/internal/own-values.d.ts.map +1 -1
- package/dist/internal/own-values.js +2 -2
- package/dist/internal/own-values.js.map +1 -1
- package/dist/internal/positional-keys.d.ts +1 -1
- package/dist/internal/positional-keys.d.ts.map +1 -1
- package/dist/internal/positional-keys.js +4 -2
- package/dist/internal/positional-keys.js.map +1 -1
- package/dist/internal/projection.d.ts.map +1 -1
- package/dist/internal/projection.js +138 -39
- package/dist/internal/projection.js.map +1 -1
- package/dist/internal/renderer.d.ts +26 -16
- package/dist/internal/renderer.d.ts.map +1 -1
- package/dist/internal/renderer.js +45 -106
- package/dist/internal/renderer.js.map +1 -1
- package/dist/internal/scroll.d.ts.map +1 -1
- package/dist/internal/scroll.js +26 -2
- package/dist/internal/scroll.js.map +1 -1
- package/dist/internal/transform-keys.d.ts +22 -0
- package/dist/internal/transform-keys.d.ts.map +1 -0
- package/dist/internal/transform-keys.js +43 -0
- package/dist/internal/transform-keys.js.map +1 -0
- package/dist/unstable/AppearAnimations.d.ts +2 -1
- package/dist/unstable/AppearAnimations.d.ts.map +1 -1
- package/dist/unstable/AppearAnimations.js +73 -22
- package/dist/unstable/AppearAnimations.js.map +1 -1
- package/dist/unstable/BatchMembers.d.ts +6 -2
- package/dist/unstable/BatchMembers.d.ts.map +1 -1
- package/dist/unstable/BatchMembers.js +30 -7
- package/dist/unstable/BatchMembers.js.map +1 -1
- package/dist/unstable/DomValues.js +1 -1
- package/dist/unstable/DomValues.js.map +1 -1
- package/dist/unstable/DragTrack.d.ts +2 -2
- package/dist/unstable/DragTrack.d.ts.map +1 -1
- package/dist/unstable/DragTrack.js +34 -8
- package/dist/unstable/DragTrack.js.map +1 -1
- package/dist/unstable/ElementSetup.d.ts.map +1 -1
- package/dist/unstable/ElementSetup.js +2 -1
- package/dist/unstable/ElementSetup.js.map +1 -1
- package/dist/unstable/GestureFeatures.d.ts +2 -1
- package/dist/unstable/GestureFeatures.d.ts.map +1 -1
- package/dist/unstable/GestureFeatures.js +18 -37
- package/dist/unstable/GestureFeatures.js.map +1 -1
- package/dist/unstable/Imperative.d.ts +2 -1
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/LiveStyle.d.ts +28 -2
- package/dist/unstable/LiveStyle.d.ts.map +1 -1
- package/dist/unstable/LiveStyle.js +8 -32
- package/dist/unstable/LiveStyle.js.map +1 -1
- package/dist/unstable/MemberHold.js +2 -2
- package/dist/unstable/MemberHold.js.map +1 -1
- package/dist/unstable/PointerValues.d.ts.map +1 -1
- package/dist/unstable/PointerValues.js +82 -8
- package/dist/unstable/PointerValues.js.map +1 -1
- package/dist/unstable/PresenceController.d.ts +5 -2
- package/dist/unstable/PresenceController.d.ts.map +1 -1
- package/dist/unstable/PresenceController.js +68 -41
- package/dist/unstable/PresenceController.js.map +1 -1
- package/dist/unstable/ReorderInput.d.ts +2 -2
- package/dist/unstable/ReorderInput.js +2 -2
- package/dist/unstable/WardConfig.d.ts +13 -4
- package/dist/unstable/WardConfig.d.ts.map +1 -1
- package/dist/unstable/WardConfig.js.map +1 -1
- package/dist/unstable/features/TimelineKeys.d.ts.map +1 -1
- package/dist/unstable/features/TimelineKeys.js +18 -2
- package/dist/unstable/features/TimelineKeys.js.map +1 -1
- package/package.json +3 -3
- package/src/MeasuredPair.ts +21 -1
- package/src/index.ts +4 -1
- package/src/internal/appear.ts +20 -2
- package/src/internal/batch-handoff.ts +19 -11
- package/src/internal/batch-writer.ts +27 -6
- package/src/internal/clock.ts +10 -0
- package/src/internal/default-transition.ts +14 -4
- package/src/internal/failing.ts +37 -0
- package/src/internal/length-keys.ts +80 -0
- package/src/internal/measured-pairs.ts +58 -22
- package/src/internal/own-values.ts +2 -2
- package/src/internal/positional-keys.ts +4 -2
- package/src/internal/projection.ts +141 -37
- package/src/internal/renderer.ts +45 -92
- package/src/internal/scroll.ts +24 -2
- package/src/internal/transform-keys.ts +47 -0
- package/src/unstable/AppearAnimations.ts +73 -24
- package/src/unstable/BatchMembers.ts +38 -10
- package/src/unstable/DomValues.ts +1 -1
- package/src/unstable/DragTrack.ts +46 -12
- package/src/unstable/ElementSetup.ts +2 -1
- package/src/unstable/GestureFeatures.ts +23 -44
- package/src/unstable/Imperative.ts +2 -1
- package/src/unstable/LiveStyle.ts +12 -8
- package/src/unstable/MemberHold.ts +2 -2
- package/src/unstable/PointerValues.ts +73 -8
- package/src/unstable/PresenceController.ts +66 -40
- package/src/unstable/ReorderInput.ts +2 -2
- package/src/unstable/WardConfig.ts +17 -5
- package/src/unstable/features/TimelineKeys.ts +19 -2
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
// ADR-0070 decisions 10–15 and *Amendment (#665)*. The DOM's writer, imported here so an app that never
|
|
25
25
|
// makes a Batch ships none of it (ADR-0070, *Amendment (#665)*).
|
|
26
26
|
import * as Batch from "@wardic/core/Batch"
|
|
27
|
-
import * as BaseValue from "@wardic/core/BaseValue"
|
|
28
27
|
import type * as DefaultTransition from "@wardic/core/DefaultTransition"
|
|
29
28
|
import * as Playback from "@wardic/core/Playback"
|
|
30
29
|
import * as ReducedMotion from "@wardic/core/ReducedMotion"
|
|
@@ -58,16 +57,19 @@ import * as BatchCalls from "@wardic/core/unstable/BatchCalls"
|
|
|
58
57
|
import { delayedBy, INSTANT, isFirstStop, isPair, type KeyPlan, memberTransitionsOf, staggerOf, unstaggered } from "@wardic/core/unstable/BatchCalls"
|
|
59
58
|
import type * as WardicServices from "@wardic/core/unstable/WardicServices"
|
|
60
59
|
import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue"
|
|
60
|
+
import * as TransformKeys from "../internal/transform-keys.ts"
|
|
61
61
|
|
|
62
62
|
/** The keys a Batch's members animate on the DOM: the transforms and `opacity`, as numbers. */
|
|
63
|
+
// #887: the element's own depth, and `scaleZ`, which #883 drew but never typed.
|
|
63
64
|
export type WardicBatchKey =
|
|
65
|
+
| "transformPerspective"
|
|
64
66
|
| "x" | "y" | "z" | "translateX" | "translateY" | "translateZ"
|
|
65
|
-
| "scale" | "scaleX" | "scaleY"
|
|
67
|
+
| "scale" | "scaleX" | "scaleY" | "scaleZ"
|
|
66
68
|
| "rotate" | "rotateX" | "rotateY" | "rotateZ"
|
|
67
69
|
| "skewX" | "skewY"
|
|
68
70
|
| "opacity"
|
|
69
71
|
|
|
70
|
-
/** A member's values: numbers on its keys, in `px` for a move, degrees for a turn, unitless for a scale and `opacity`. */
|
|
72
|
+
/** A member's values: numbers on its keys, in `px` for a move and a depth, degrees for a turn, unitless for a scale and `opacity`. */
|
|
71
73
|
export type WardicBatchValues = { readonly [K in WardicBatchKey]?: number }
|
|
72
74
|
|
|
73
75
|
/**
|
|
@@ -394,6 +396,8 @@ export interface BatchCall {
|
|
|
394
396
|
readonly skipAnimations: boolean
|
|
395
397
|
readonly head: Playback.Playhead
|
|
396
398
|
readonly settled: () => void
|
|
399
|
+
/** It ended with a key a later change took, never landing (#951). */
|
|
400
|
+
readonly taken: () => void
|
|
397
401
|
/** The members it moves, in order: every member when left out. */
|
|
398
402
|
readonly members: ReadonlyArray<number> | undefined
|
|
399
403
|
}
|
|
@@ -412,6 +416,8 @@ export interface BatchSequenceCall {
|
|
|
412
416
|
readonly skipAnimations: boolean
|
|
413
417
|
readonly head: Playback.Playhead
|
|
414
418
|
readonly settled: () => void
|
|
419
|
+
/** It ended with a key a later change took, never landing (#951). */
|
|
420
|
+
readonly taken: () => void
|
|
415
421
|
}
|
|
416
422
|
|
|
417
423
|
/**
|
|
@@ -446,7 +452,7 @@ export type BatchGroup = "transform" | "opacity"
|
|
|
446
452
|
/** The group `key` is drawn in on the DOM: a transform key's `transform`, `opacity`'s own, or none. */
|
|
447
453
|
export const batchGroupOf = (key: string): BatchGroup | undefined => {
|
|
448
454
|
if (key === "opacity") return "opacity"
|
|
449
|
-
if (Predicate.isNotUndefined(
|
|
455
|
+
if (Predicate.isNotUndefined(TransformKeys.TRANSFORM_IDENTITY[key])) return "transform"
|
|
450
456
|
return undefined
|
|
451
457
|
}
|
|
452
458
|
|
|
@@ -659,7 +665,7 @@ const noMember = (i: number, count: number): never => fail(`it has no member ${i
|
|
|
659
665
|
/** Each key's identity: a transform's, and `opacity`'s 1, an element's own with no style of its own. */
|
|
660
666
|
// Per member per key at mount (#540): statements.
|
|
661
667
|
export const identityOf = (key: string): number => {
|
|
662
|
-
const identity =
|
|
668
|
+
const identity = TransformKeys.TRANSFORM_IDENTITY[key]
|
|
663
669
|
if (Predicate.isUndefined(identity)) return 1
|
|
664
670
|
return identity
|
|
665
671
|
}
|
|
@@ -869,6 +875,10 @@ export const markLayoutElement = (element: Element): void => {
|
|
|
869
875
|
LAYOUT_ELEMENTS.add(element)
|
|
870
876
|
}
|
|
871
877
|
|
|
878
|
+
/** The error for a member's element with no inline style: one of a foreign namespace. */
|
|
879
|
+
const stylelessMember = (element: Element): string =>
|
|
880
|
+
`a member's element (${elementName(element)}) has no inline style for the Batch to draw its \`transform\` and \`opacity\` on: give it an HTML, SVG or MathML element`
|
|
881
|
+
|
|
872
882
|
/** The error for a layout node on a Batch member's element. */
|
|
873
883
|
const layoutOnMember = (element: Element): string =>
|
|
874
884
|
`a member's element (${elementName(element)}) has \`layout\` or \`layoutId\`: the Batch draws its transform, under which the projection measures it. Give its Wardic element no layout, or leave it out of the Batch`
|
|
@@ -1811,13 +1821,19 @@ export const bindBatch = (env: BatchEnv, config: BatchConfig | KeyedBatchConfig<
|
|
|
1811
1821
|
if (disposed) return Arr.forEach(going, cutExit)
|
|
1812
1822
|
const exitTargets = new Float64Array(capacity * stride).fill(Number.NaN)
|
|
1813
1823
|
const moving: Array<number> = []
|
|
1814
|
-
// Per leaver at its exit (#665): statements. An exit that fails
|
|
1824
|
+
// Per leaver at its exit (#665): statements. An exit that fails lets its element go, and is reported
|
|
1825
|
+
// once for this task's leavers: one exit function called for each (#979 group I, row 29; ADR-0074
|
|
1826
|
+
// decision 3, an event's run, as an exit's stagger is).
|
|
1827
|
+
let reported = false
|
|
1815
1828
|
Arr.forEach(going, (i) => {
|
|
1816
1829
|
try {
|
|
1817
1830
|
targetsInto(exitTargets, i, exitValuesOf(i, UndefinedOr.getOrThrow(exits[i]).custom))
|
|
1818
1831
|
moving.push(i)
|
|
1819
1832
|
} catch (defect) {
|
|
1820
|
-
|
|
1833
|
+
if (!reported) {
|
|
1834
|
+
reported = true
|
|
1835
|
+
env.runtime.runFork(Report.failure("createBatch: a member's exit failed", Cause.die(defect)))
|
|
1836
|
+
}
|
|
1821
1837
|
cutExit(i)
|
|
1822
1838
|
if (unlisted.has(i)) leaveBatch(i)
|
|
1823
1839
|
}
|
|
@@ -2205,7 +2221,17 @@ export const bindBatch = (env: BatchEnv, config: BatchConfig | KeyedBatchConfig<
|
|
|
2205
2221
|
* them, one a change didn't move among them, or each one the Handoff's code never came for.
|
|
2206
2222
|
*/
|
|
2207
2223
|
const releaseAppearing = (): void => {
|
|
2208
|
-
|
|
2224
|
+
// Each member's own: one that throws leaves the others let go, reported once a release (#977).
|
|
2225
|
+
let failed = false
|
|
2226
|
+
Iter.forEach(appearing, (slot) => {
|
|
2227
|
+
try {
|
|
2228
|
+
UndefinedOr.map(elementOf[memberOf[slot] as number] as (Element & ElementCSSInlineStyle) | undefined, Appear.release)
|
|
2229
|
+
} catch (defect) {
|
|
2230
|
+
if (failed) return
|
|
2231
|
+
failed = true
|
|
2232
|
+
env.runtime.runFork(Report.failure("wardic.batch: a member's Appear release failed", Cause.die(defect)))
|
|
2233
|
+
}
|
|
2234
|
+
})
|
|
2209
2235
|
appearing.clear()
|
|
2210
2236
|
handoffAt = undefined
|
|
2211
2237
|
}
|
|
@@ -2642,6 +2668,8 @@ export const bindBatch = (env: BatchEnv, config: BatchConfig | KeyedBatchConfig<
|
|
|
2642
2668
|
// can't be a member: the projection measures it under the transform the Batch draws.
|
|
2643
2669
|
if (drawnByAnother(el)) return fail(`an element (${elementName(el)}) is a member of two Batches: one Batch draws an element's \`transform\` and \`opacity\``)
|
|
2644
2670
|
if (LAYOUT_ELEMENTS.has(el)) return fail(layoutOnMember(el))
|
|
2671
|
+
// Its inline style is what the Batch draws: one with none is refused before it's entered (#977, Q6).
|
|
2672
|
+
if (Predicate.isUndefined((el as Partial<ElementCSSInlineStyle>).style)) return fail(stylelessMember(el))
|
|
2645
2673
|
const was = elementOf[i]
|
|
2646
2674
|
if (Predicate.isNotUndefined(was)) forget(was, i)
|
|
2647
2675
|
elementOf[i] = el
|
|
@@ -2710,7 +2738,7 @@ export const bindBatch = (env: BatchEnv, config: BatchConfig | KeyedBatchConfig<
|
|
|
2710
2738
|
slots: ReadonlyArray<number>,
|
|
2711
2739
|
targetOf: (slot: number, k: number) => number,
|
|
2712
2740
|
fromOf: ((slot: number, k: number) => number) | undefined,
|
|
2713
|
-
call: Pick<BatchCall, "transition" | "reducedMotion" | "skipAnimations" | "head" | "settled"> & { readonly onMemberLanded?: (slot: number) => void },
|
|
2741
|
+
call: Pick<BatchCall, "transition" | "reducedMotion" | "skipAnimations" | "head" | "settled"> & { readonly taken?: () => void; readonly onMemberLanded?: (slot: number) => void },
|
|
2714
2742
|
): BatchTrack => controlsOf(Batch.animate(made(), slots, targetOf, BatchCalls.animateOptions(planningNow(), call, targetOf, fromOf)))
|
|
2715
2743
|
|
|
2716
2744
|
/** Whether member `i`'s element has arrived. */
|
|
@@ -2755,7 +2783,7 @@ export const bindBatch = (env: BatchEnv, config: BatchConfig | KeyedBatchConfig<
|
|
|
2755
2783
|
retakeFor(slots, givesGroup((slot, k) => Predicate.isNotUndefined(UndefinedOr.getOrThrow(animations[slot]).keyframes[keys[k]])))
|
|
2756
2784
|
// Each member's key's stops, once at its first play (core's).
|
|
2757
2785
|
const keyframesOf = BatchCalls.keyframesFor(planningNow(), call, (slot) => UndefinedOr.getOrThrow(animations[slot]))
|
|
2758
|
-
return controlsOf(Batch.keyframes(made(), slots, keyframesOf,
|
|
2786
|
+
return controlsOf(Batch.keyframes(made(), slots, keyframesOf, BatchCalls.keyframesOptions(call)))
|
|
2759
2787
|
}
|
|
2760
2788
|
|
|
2761
2789
|
/** A driven change's controls, as an `animate` call's track: played, it wakes the Batch's run. */
|
|
@@ -36,7 +36,7 @@ const withRead = (pair: Requested): MeasuredPairs.Requested => ({ ...pair, measu
|
|
|
36
36
|
/** The DOM's Measured pairs: a pair whose units don't blend, measured on its element at the end of the task. */
|
|
37
37
|
export const measuredPairs: MeasuredPairs.Shape = {
|
|
38
38
|
needs,
|
|
39
|
-
measure: (subject, pairs, values) => Rec.map(measure(subject as HTMLElement, pairs, values), withRead),
|
|
39
|
+
measure: (subject, pairs, values, failed) => Rec.map(measure(subject as HTMLElement, pairs, values, failed), withRead),
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/** The DOM's Variable values: a `var(--x)`, resolved on its element as each leg starts. */
|
|
@@ -88,6 +88,7 @@ import type * as WardicServices from "@wardic/core/unstable/WardicServices"
|
|
|
88
88
|
import type * as WardConfig from "./WardConfig.ts"
|
|
89
89
|
import * as DragControls from "./DragControls.ts"
|
|
90
90
|
import * as DragTransition from "./DragTransition.ts"
|
|
91
|
+
import * as Failing from "../internal/failing.ts"
|
|
91
92
|
import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue"
|
|
92
93
|
|
|
93
94
|
|
|
@@ -170,8 +171,8 @@ export type TrackServices = WardicServices.WardicServices | InputSource.InputSou
|
|
|
170
171
|
export interface DragTrackOptions {
|
|
171
172
|
/**
|
|
172
173
|
* Runs the track in the element's watch Scope: its watches subscribed now, with no
|
|
173
|
-
* fiber, until the element goes and the Scope closes, which stops a running release. A
|
|
174
|
-
* watch's fold goes to the `onDefect` it's given (#209: each binding owns the Scope).
|
|
174
|
+
* fiber, until the element goes and the Scope closes, which stops a running release. A run of throws
|
|
175
|
+
* from a watch's fold goes to the `onDefect` it's given, at its first (#209: each binding owns the Scope).
|
|
175
176
|
*/
|
|
176
177
|
readonly watch: (track: (onDefect: InputFeed.OnDefect) => Effect.Effect<void, never, Scope.Scope | TrackServices>) => void
|
|
177
178
|
/**
|
|
@@ -292,6 +293,17 @@ interface DragTrackState {
|
|
|
292
293
|
/** The track's one cell, written by its handlers and by its release's sink, never at once. */
|
|
293
294
|
type TrackState = MutableRef.MutableRef<DragTrackState>
|
|
294
295
|
|
|
296
|
+
/** A track's kinds of failure, each with its own run: a response at each sample, a measure, a release. */
|
|
297
|
+
// #979 group I, row 28 (ADR-0074 decision 3): each was reported at every throw.
|
|
298
|
+
type TrackFailure = "release" | "measuring" | "response"
|
|
299
|
+
|
|
300
|
+
/** `report`, at the start of a run of `kind`'s failures on the track: nothing while one is on. */
|
|
301
|
+
const atRunStart = (failing: Failing.Failing<TrackFailure>, kind: TrackFailure, report: Effect.Effect<void>): Effect.Effect<void> =>
|
|
302
|
+
Effect.suspend(() => {
|
|
303
|
+
if (Failing.firstThrowOf(failing, kind)) return report
|
|
304
|
+
return Effect.void
|
|
305
|
+
})
|
|
306
|
+
|
|
295
307
|
const ORIGIN: Point.Point = { x: 0, y: 0 }
|
|
296
308
|
|
|
297
309
|
/**
|
|
@@ -559,6 +571,7 @@ const release = (
|
|
|
559
571
|
position: Point.Point,
|
|
560
572
|
velocity: Point.Point,
|
|
561
573
|
taken: Deferred.Deferred<void>,
|
|
574
|
+
failing: Failing.Failing<TrackFailure>,
|
|
562
575
|
): Effect.Effect<void, never, FrameLoop.FrameLoop> => {
|
|
563
576
|
const cfg = opts.config
|
|
564
577
|
|
|
@@ -580,6 +593,11 @@ const release = (
|
|
|
580
593
|
opts.setDragging(false)
|
|
581
594
|
UndefinedOr.map(opts.onReleaseEnd, (ended) => opts.gate.afterFlush(ended))
|
|
582
595
|
})
|
|
596
|
+
// A release that dies is reported at the first of the track's run of them, and rests where it was
|
|
597
|
+
// dropped; one that lands ends the run.
|
|
598
|
+
const failed = (defect: unknown): Effect.Effect<void> =>
|
|
599
|
+
atRunStart(failing, "release", Report.failure("wardic.drag: a release failed", Cause.die(defect))).pipe(Effect.andThen(Effect.sync(() => tapFrame(position, ORIGIN))))
|
|
600
|
+
const landed = Effect.sync(() => Failing.endRunOf(failing, "release"))
|
|
583
601
|
const { axis, bounds } = MutableRef.get(state)
|
|
584
602
|
const edges = edgesOf(cfg, bounds)
|
|
585
603
|
const v = releaseVelocity(cfg, velocity)
|
|
@@ -608,7 +626,8 @@ const release = (
|
|
|
608
626
|
keepVelocity(opts, ORIGIN)
|
|
609
627
|
if (MutableRef.get(state).releasing) directSet(opts, restOfRelease(position, v, axis, edges, transition))
|
|
610
628
|
}).pipe(
|
|
611
|
-
Effect.
|
|
629
|
+
Effect.andThen(landed),
|
|
630
|
+
Effect.catchDefect(failed),
|
|
612
631
|
Effect.andThen(Microtask.next),
|
|
613
632
|
Effect.andThen(done),
|
|
614
633
|
),
|
|
@@ -626,8 +645,8 @@ const release = (
|
|
|
626
645
|
Machine.run((frame) => tapFrame({ x: position.x, y: frame.value }, { x: 0, y: frame.velocity })),
|
|
627
646
|
)),
|
|
628
647
|
Match.orElse(() => Machine.inertiaVec(position, v, { ...transition, ...edges }).pipe(Machine.run((frame) => tapFrame(frame.value, frame.velocity)))),
|
|
629
|
-
Effect.
|
|
630
|
-
|
|
648
|
+
Effect.andThen(landed),
|
|
649
|
+
Effect.catchDefect(failed),
|
|
631
650
|
Effect.andThen(done),
|
|
632
651
|
),
|
|
633
652
|
)
|
|
@@ -724,13 +743,18 @@ export const driveDragTrack = (opts: DragTrackOptions): DragTrack => {
|
|
|
724
743
|
const watching = yield* FiberHandle.make<void>()
|
|
725
744
|
let watched: Element | undefined = undefined
|
|
726
745
|
let warned = false
|
|
746
|
+
const failing: Failing.Failing<TrackFailure> = { failing: undefined }
|
|
727
747
|
const setBounds = (bounds: Drag.Bounds | undefined): void => {
|
|
728
748
|
MutableRef.update(state, (st) => ({ ...st, bounds }))
|
|
729
749
|
}
|
|
730
750
|
/** The bounds measured against `container`'s `box`; none, reported, if measuring throws (an app's `onMeasureDragConstraints`). */
|
|
731
751
|
const measured = (container: DragConstraints.DragContainer, box: Element): Effect.Effect<Drag.Bounds | undefined> =>
|
|
732
|
-
Effect.sync((): Drag.Bounds | undefined =>
|
|
733
|
-
|
|
752
|
+
Effect.sync((): Drag.Bounds | undefined => {
|
|
753
|
+
const bounds = container.bounds(box)
|
|
754
|
+
Failing.endRunOf(failing, "measuring")
|
|
755
|
+
return bounds
|
|
756
|
+
}).pipe(
|
|
757
|
+
Effect.catchDefect((defect) => atRunStart(failing, "measuring", Report.failure("wardic.drag: measuring dragConstraints failed", Cause.die(defect))).pipe(Effect.as(undefined))),
|
|
734
758
|
)
|
|
735
759
|
/**
|
|
736
760
|
* A resize of the element or its container: the bounds measured again. The first measure only
|
|
@@ -827,7 +851,7 @@ export const driveDragTrack = (opts: DragTrackOptions): DragTrack => {
|
|
|
827
851
|
taken = Deferred.makeUnsafe<void>()
|
|
828
852
|
return taken
|
|
829
853
|
}).pipe(
|
|
830
|
-
Effect.flatMap((ended) => FiberHandle.run(releasing, release(opts, state, position, velocity, ended))),
|
|
854
|
+
Effect.flatMap((ended) => FiberHandle.run(releasing, release(opts, state, position, velocity, ended, failing))),
|
|
831
855
|
Effect.asVoid,
|
|
832
856
|
)
|
|
833
857
|
|
|
@@ -911,11 +935,21 @@ export const driveDragTrack = (opts: DragTrackOptions): DragTrack => {
|
|
|
911
935
|
})
|
|
912
936
|
|
|
913
937
|
/**
|
|
914
|
-
* A response, run inside its event (`opts.fork`): one that fails is reported
|
|
915
|
-
* event's runs (ADR-0055 *Amendment (#379)*, Q4). A release reports its own (#66).
|
|
938
|
+
* A response, run inside its event (`opts.fork`): one that fails is reported at the first of a run
|
|
939
|
+
* of them, and the next event's runs (ADR-0055 *Amendment (#379)*, Q4). A release reports its own (#66).
|
|
916
940
|
*/
|
|
917
|
-
|
|
918
|
-
|
|
941
|
+
// Made once a track: a sample's response allocates nothing more than its fold. An interruption
|
|
942
|
+
// neither starts a run nor ends one.
|
|
943
|
+
const responded = Effect.sync(() => Failing.endRunOf(failing, "response"))
|
|
944
|
+
const responseExits = {
|
|
945
|
+
onSuccess: () => responded,
|
|
946
|
+
onFailure: (cause: Cause.Cause<never>): Effect.Effect<void> =>
|
|
947
|
+
Bool.match(Cause.hasInterruptsOnly(cause), {
|
|
948
|
+
onTrue: () => Effect.void,
|
|
949
|
+
onFalse: () => atRunStart(failing, "response", Report.failure("wardic.drag: a response failed", cause)),
|
|
950
|
+
}),
|
|
951
|
+
}
|
|
952
|
+
const respond = (response: Effect.Effect<void, never, FrameLoop.FrameLoop>): void => opts.fork(Effect.matchCauseEffect(response, responseExits))
|
|
919
953
|
|
|
920
954
|
// Subscribed in this order, so the samples hear an event before the grabs. The constraints
|
|
921
955
|
// bound the element's x/y, so they're applied where the gesture's offset meets its base, in
|
|
@@ -43,6 +43,7 @@ import * as LiveStyle from "./LiveStyle.ts"
|
|
|
43
43
|
import * as Spine from "@wardic/core/unstable/Spine"
|
|
44
44
|
import * as VariantTree from "@wardic/core/unstable/VariantTree"
|
|
45
45
|
import * as VariantTarget from "@wardic/core/unstable/VariantTarget"
|
|
46
|
+
import * as TransformKeys from "../internal/transform-keys.ts"
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* A mounted element's Base-value links (ADR-0022): a key with no value starts from its `style`
|
|
@@ -92,7 +93,7 @@ export const restingOf = (key: string, initial: Values.Values, style: object | s
|
|
|
92
93
|
Option.getOrUndefined(
|
|
93
94
|
Option.fromUndefinedOr(initial[key]).pipe(
|
|
94
95
|
Option.orElse((): Option.Option<unknown> => Option.flatMap(OwnValues.styleValueOf(style, key), (raw) => Option.fromNullishOr(read(raw)))),
|
|
95
|
-
Option.orElse((): Option.Option<unknown> =>
|
|
96
|
+
Option.orElse((): Option.Option<unknown> => TransformKeys.transformIdentity(key)),
|
|
96
97
|
),
|
|
97
98
|
)
|
|
98
99
|
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
226
|
-
UndefinedOr.map(each, (handler) => guard
|
|
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):
|
|
263
|
-
* throws
|
|
264
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
|
|
@@ -100,7 +100,8 @@ export type WardicAnimationSequence = ReadonlyArray<WardicSegment>
|
|
|
100
100
|
/**
|
|
101
101
|
* A scope's `animate`: `animate(subject, target, options?)` animates the subject's elements to
|
|
102
102
|
* `target`, and `animate(sequence, options?)` plays a sequence. Either returns its playback controls.
|
|
103
|
-
* Motion's `animate`, as `useAnimate` gives it.
|
|
103
|
+
* Motion's `animate`, as `useAnimate` gives it. A target's own `transition` runs, the options' fields
|
|
104
|
+
* laid over it, and its `transitionEnd` is set on each element once that element lands.
|
|
104
105
|
*/
|
|
105
106
|
// #433: through one Playhead.
|
|
106
107
|
export interface WardicAnimate {
|
|
@@ -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)
|
|
7
|
-
* (decisions 2 and 4)
|
|
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
|
|
174
|
-
export const isTransformKey
|
|
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,
|
|
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,
|
|
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] !==
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
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(() => {
|