@wardic/dom 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +2 -2
- package/dist/unstable/BatchMembers.d.ts.map +1 -1
- package/dist/unstable/BatchMembers.js +29 -6
- 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/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 +32 -8
- 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/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
|
@@ -125,6 +125,7 @@ import { pending as appearRuns } from "./appear-slot.ts"
|
|
|
125
125
|
import * as Report from "@wardic/core/unstable/Report"
|
|
126
126
|
import { blendRadius, borderRadiusCorrector, isUnitScale, SCALE_CORRECTORS, type ScaleCorrector, type ScaleCorrectorEntry, scaleRadius, ZERO_RADIUS } from "./scale-correction.ts"
|
|
127
127
|
import { dashCase } from "./svg.ts"
|
|
128
|
+
import * as Failing from "./failing.ts"
|
|
128
129
|
|
|
129
130
|
/**
|
|
130
131
|
* What the engine writes each node's projection through: a `FlushGate` is one, so the engine never
|
|
@@ -1247,6 +1248,9 @@ interface NodeState {
|
|
|
1247
1248
|
/** Called as a Measure pass that measures it begins, and with its box after the read (#443); most nodes have neither. */
|
|
1248
1249
|
readonly onBeforeMeasure: (() => void) | undefined
|
|
1249
1250
|
readonly onMeasure: ((box: Box.Box, prev: Option.Option<Box.Box>) => void) | undefined
|
|
1251
|
+
/** The names of the app's callbacks on it whose last call threw, made at the first throw: most nodes never see one. */
|
|
1252
|
+
// #979 group I, row 29 (ADR-0074 decision 3).
|
|
1253
|
+
failing: Set<LayoutCallbackName> | undefined
|
|
1250
1254
|
/**
|
|
1251
1255
|
* What the node's handover blends from (ADR-0010 *Amendment (#166)*): the twin's radius, rotation
|
|
1252
1256
|
* and, for a Switch, opacity, as they were drawn as it began. Eased into the node's own over the
|
|
@@ -1418,6 +1422,17 @@ interface NodeState {
|
|
|
1418
1422
|
customBases: Readonly<Record<string, string>> | undefined
|
|
1419
1423
|
/** Whether an app's corrector's value is written corrected now (so it's put back once at rest). */
|
|
1420
1424
|
customCorrected: boolean
|
|
1425
|
+
// --- the app's code, its own (#979, row 5; ADR-0074): each reported once a run of throws ---
|
|
1426
|
+
/** Whether its layout animation's ease threw at its last call. */
|
|
1427
|
+
easeFailing: boolean
|
|
1428
|
+
/** The app's correctors that threw for it at their last call: made at the first throw. */
|
|
1429
|
+
failingCorrectors: Set<CustomCorrector> | undefined
|
|
1430
|
+
/** Whether its write threw at its last call, as a leaving node writes straight onto its element. */
|
|
1431
|
+
writeFailing: boolean
|
|
1432
|
+
/** Whether its Transform template threw as a Measure pass held it for the read. */
|
|
1433
|
+
heldFailing: boolean
|
|
1434
|
+
/** Its Transform template's last result, which a pass holds it at when the template throws: `none` before one. */
|
|
1435
|
+
lastHeld: string
|
|
1421
1436
|
// --- drag (ADR-0016) ---
|
|
1422
1437
|
/** Whether this node is being dragged: its target follows the pointer (no spring), held active. */
|
|
1423
1438
|
dragging: boolean
|
|
@@ -1479,6 +1494,8 @@ interface LastPass {
|
|
|
1479
1494
|
* `handleLeave` brought it back.
|
|
1480
1495
|
*/
|
|
1481
1496
|
interface Leaver {
|
|
1497
|
+
/** Its node's id: a node it comes back as is reported by it (#979, row 5). */
|
|
1498
|
+
readonly id: string
|
|
1482
1499
|
readonly element: HTMLElement
|
|
1483
1500
|
/** Its last pass; `undefined` when it never had one, and then it can't come back. */
|
|
1484
1501
|
readonly last: LastPass | undefined
|
|
@@ -1552,17 +1569,6 @@ const NO_OWN_TRANSLATE = (): Point.Point => NO_TRANSLATE
|
|
|
1552
1569
|
/** No values registered for an element (#443): an app's corrector reads its base then. */
|
|
1553
1570
|
const NO_VALUES: Readonly<Record<string, unknown>> = {}
|
|
1554
1571
|
|
|
1555
|
-
/**
|
|
1556
|
-
* The transform a Measure pass holds `node` at (#443): its Transform template's, `none` for a node
|
|
1557
|
-
* with none (Motion's `resetTransform`), which is what an at-rest node already draws (#674). Per pass
|
|
1558
|
-
* per node: a field read and an early return.
|
|
1559
|
-
*/
|
|
1560
|
-
const heldTransformFor = (node: { readonly heldTransform: (() => string) | undefined }): string => {
|
|
1561
|
-
const held = node.heldTransform
|
|
1562
|
-
if (Predicate.isUndefined(held)) return "none"
|
|
1563
|
-
return held()
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
1572
|
/** No own rotation or opacity of its own: a node the binding gives none, or a leaving one (*Amendment (#166)*). */
|
|
1567
1573
|
const NO_OWN_ROTATE = (): number => 0
|
|
1568
1574
|
const NO_OWN_OPACITY = (): number => 1
|
|
@@ -1599,6 +1605,10 @@ const SIZE_EPSILON = 0.01
|
|
|
1599
1605
|
|
|
1600
1606
|
/** No layout animation callback: a node the binding gives none (#191). */
|
|
1601
1607
|
const NO_CALLBACK = (): Option.Option<() => void> => Option.none()
|
|
1608
|
+
|
|
1609
|
+
/** An app's callback on a layout node, by the name its report gives it. */
|
|
1610
|
+
type LayoutCallbackName = "onLayoutAnimationStart" | "onLayoutAnimationComplete" | "onDragTransitionEnd" | "onBeforeLayoutMeasure" | "onLayoutMeasure"
|
|
1611
|
+
|
|
1602
1612
|
/** A call with no options. */
|
|
1603
1613
|
const NO_ANIMATE_LAYOUT_OPTIONS: AnimateLayoutOptions = {}
|
|
1604
1614
|
|
|
@@ -1991,7 +2001,16 @@ export const makeProjectionSystem = (
|
|
|
1991
2001
|
const patch = projectionPatchOf(value, corrected)
|
|
1992
2002
|
// A leaving node is driven directly: its gate registration is gone.
|
|
1993
2003
|
if (node.leaving) {
|
|
1994
|
-
|
|
2004
|
+
// #979, row 5 (ADR-0074): as the gate takes each element's write on its own (#969), a leaver's
|
|
2005
|
+
// write that throws (its Transform template's, say) leaves it as it was drawn, and every other
|
|
2006
|
+
// node goes on: before, it failed the coordinator's run, so every layout animation stopped.
|
|
2007
|
+
try {
|
|
2008
|
+
renderer.commit(node.element, renderer.project(withExitValues(node, patch)))
|
|
2009
|
+
if (node.writeFailing) node.writeFailing = false
|
|
2010
|
+
} catch (defect) {
|
|
2011
|
+
if (!node.writeFailing) runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a leaving node's write failed", Cause.die(defect)), { id: node.id }))
|
|
2012
|
+
node.writeFailing = true
|
|
2013
|
+
}
|
|
1995
2014
|
return
|
|
1996
2015
|
}
|
|
1997
2016
|
sink.write(node.id, patch)
|
|
@@ -2053,12 +2072,35 @@ export const makeProjectionSystem = (
|
|
|
2053
2072
|
for (const key of corrector.writes) out[key] = String(latest)
|
|
2054
2073
|
continue
|
|
2055
2074
|
}
|
|
2056
|
-
|
|
2075
|
+
// #979, row 5 (ADR-0074): the app's corrector is its node's own. One that throws leaves its keys
|
|
2076
|
+
// at their last value this frame, and the node's other keys and every other node go on: before,
|
|
2077
|
+
// it failed the coordinator's run, or the Measure pass that seeded it, so nothing moved.
|
|
2078
|
+
let corrected: string
|
|
2079
|
+
try {
|
|
2080
|
+
corrected = String(corrector.correct(latest, { target: node.lastTarget as Box.Box, treeScale, projectionDelta: node.lastDelta }))
|
|
2081
|
+
const failing = node.failingCorrectors
|
|
2082
|
+
if (Predicate.isNotUndefined(failing)) failing.delete(corrector)
|
|
2083
|
+
} catch (defect) {
|
|
2084
|
+
correctorFailed(node, corrector, defect)
|
|
2085
|
+
continue
|
|
2086
|
+
}
|
|
2057
2087
|
for (const key of corrector.writes) out[key] = corrected
|
|
2058
2088
|
}
|
|
2059
2089
|
return out
|
|
2060
2090
|
}
|
|
2061
2091
|
|
|
2092
|
+
/** `corrector` threw for `node`: reported at its first throw of a run, until a clean call. */
|
|
2093
|
+
const correctorFailed = (node: NodeState, corrector: CustomCorrector, defect: unknown): void => {
|
|
2094
|
+
let failing = node.failingCorrectors
|
|
2095
|
+
if (Predicate.isUndefined(failing)) {
|
|
2096
|
+
failing = new Set()
|
|
2097
|
+
node.failingCorrectors = failing
|
|
2098
|
+
}
|
|
2099
|
+
if (failing.has(corrector)) return
|
|
2100
|
+
failing.add(corrector)
|
|
2101
|
+
runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a scale corrector failed", Cause.die(defect)), { id: node.id, key: corrector.key }))
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2062
2104
|
/** An app's corrector's value for `node` (#443): its own for the key, a number or a string, else its base, else none. */
|
|
2063
2105
|
const latestFor = (node: NodeState, corrector: CustomCorrector, values: Readonly<Record<string, unknown>>): string | number | undefined => {
|
|
2064
2106
|
const own = values[corrector.key]
|
|
@@ -3597,7 +3639,7 @@ export const makeProjectionSystem = (
|
|
|
3597
3639
|
UndefinedOr.match(wrapperLinkOf(child, twin.shift), { onUndefined: () => links, onDefined: (link) => withLink(links, link, child) }),
|
|
3598
3640
|
),
|
|
3599
3641
|
})
|
|
3600
|
-
const follower = makeLeavingNode(leaver.element, layoutId, last, undefined, undefined, chain)
|
|
3642
|
+
const follower = makeLeavingNode(leaver.id, leaver.element, layoutId, last, undefined, undefined, chain)
|
|
3601
3643
|
follower.fade = readOpacity(leaver.element)
|
|
3602
3644
|
addNode(follower)
|
|
3603
3645
|
elementToNode.set(leaver.element, follower)
|
|
@@ -3629,7 +3671,7 @@ export const makeProjectionSystem = (
|
|
|
3629
3671
|
const holdNode = (node: NodeState): void => {
|
|
3630
3672
|
const last = lastPassOf(node)
|
|
3631
3673
|
if (Predicate.isUndefined(last)) return
|
|
3632
|
-
hold({ element: node.element, last, layoutAnchor: node.layoutAnchor, twin: undefined, reintroduced: false, pastTask: false })
|
|
3674
|
+
hold({ id: node.id, element: node.element, last, layoutAnchor: node.layoutAnchor, twin: undefined, reintroduced: false, pastTask: false })
|
|
3633
3675
|
}
|
|
3634
3676
|
|
|
3635
3677
|
/**
|
|
@@ -3648,7 +3690,7 @@ export const makeProjectionSystem = (
|
|
|
3648
3690
|
// Seen as it goes, at the page's scroll now (#480): a scroll after, a router's at a navigation, comes out.
|
|
3649
3691
|
const seed = UndefinedOr.map(seedBox, (box) => seedOf(node, layoutId, box, look, measureDocumentScroll()))
|
|
3650
3692
|
if (Predicate.isUndefined(last) && Predicate.isUndefined(seedBox)) return
|
|
3651
|
-
hold({ element: node.element, last, layoutAnchor: node.layoutAnchor, twin: { layoutId, chain: node.paintChain, shift, seed }, reintroduced: false, pastTask: false })
|
|
3693
|
+
hold({ id: node.id, element: node.element, last, layoutAnchor: node.layoutAnchor, twin: { layoutId, chain: node.paintChain, shift, seed }, reintroduced: false, pastTask: false })
|
|
3652
3694
|
}
|
|
3653
3695
|
|
|
3654
3696
|
/**
|
|
@@ -3764,12 +3806,13 @@ export const makeProjectionSystem = (
|
|
|
3764
3806
|
/** The nodes a Measure round measured that have an `onLayoutMeasure` (#443), told at its end. Reused: most rounds tell none. */
|
|
3765
3807
|
const measuredNow: Array<{ readonly node: NodeState; readonly box: Box.Box; readonly prev: Box.Box | undefined }> = []
|
|
3766
3808
|
|
|
3767
|
-
/** Call
|
|
3768
|
-
const callMeasureHook = (hook: () => void, name:
|
|
3809
|
+
/** Call `node`'s measure hook `name` (#443): a throw is reported at its run's first, and the pass goes on. */
|
|
3810
|
+
const callMeasureHook = (node: NodeState, hook: () => void, name: "onBeforeLayoutMeasure" | "onLayoutMeasure"): void => {
|
|
3769
3811
|
try {
|
|
3770
3812
|
hook()
|
|
3813
|
+
Failing.endRunOf(node, name)
|
|
3771
3814
|
} catch (defect) {
|
|
3772
|
-
runtime.runFork(Report.failure(`wardic.projection: an ${name} failed`, Cause.die(defect)))
|
|
3815
|
+
if (Failing.firstThrowOf(node, name)) runtime.runFork(Report.failure(`wardic.projection: an ${name} failed`, Cause.die(defect)))
|
|
3773
3816
|
}
|
|
3774
3817
|
}
|
|
3775
3818
|
|
|
@@ -3812,9 +3855,26 @@ export const makeProjectionSystem = (
|
|
|
3812
3855
|
const savedTransforms: Array<string | undefined> = []
|
|
3813
3856
|
for (const node of ordered) {
|
|
3814
3857
|
// Its app's `onBeforeLayoutMeasure` (#443), before its transform is held for the read.
|
|
3815
|
-
if (Predicate.isNotUndefined(node.onBeforeMeasure)) callMeasureHook(node.onBeforeMeasure, "onBeforeLayoutMeasure")
|
|
3858
|
+
if (Predicate.isNotUndefined(node.onBeforeMeasure)) callMeasureHook(node, node.onBeforeMeasure, "onBeforeLayoutMeasure")
|
|
3816
3859
|
const own = node.element.style.transform
|
|
3817
|
-
|
|
3860
|
+
// Its Transform template's, `none` for a node with none (Motion's `resetTransform`), which is
|
|
3861
|
+
// what an at-rest node already draws (#674). Per pass per node: a field read.
|
|
3862
|
+
let held = "none"
|
|
3863
|
+
const template = node.heldTransform
|
|
3864
|
+
// #979, row 13 (ADR-0074): the app's template is its node's own. One that throws holds its node
|
|
3865
|
+
// where its last call did, so a static part of it is still measured, and the pass goes on:
|
|
3866
|
+
// before, the throw ended it here, every node held before it left held and nothing seeded.
|
|
3867
|
+
if (Predicate.isNotUndefined(template)) {
|
|
3868
|
+
try {
|
|
3869
|
+
held = template()
|
|
3870
|
+
node.lastHeld = held
|
|
3871
|
+
if (node.heldFailing) node.heldFailing = false
|
|
3872
|
+
} catch (defect) {
|
|
3873
|
+
if (!node.heldFailing) runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a transformTemplate failed at a Measure pass", Cause.die(defect)), { id: node.id }))
|
|
3874
|
+
node.heldFailing = true
|
|
3875
|
+
held = node.lastHeld
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3818
3878
|
// A server's Appear animation not yet handed off (#245, ADR-0044 *Amendment (#245)*): its CSS
|
|
3819
3879
|
// transform beats an inline one, but not an important one. Its timeline runs on; the restore
|
|
3820
3880
|
// below gives the old value back, at its own priority.
|
|
@@ -4011,6 +4071,11 @@ export const makeProjectionSystem = (
|
|
|
4011
4071
|
// --- WRITE: FLIP detection + seeding, on the already-measured boxes. ------
|
|
4012
4072
|
for (let i = 0; i < ordered.length; i++) {
|
|
4013
4073
|
const node = ordered[i]
|
|
4074
|
+
// A node never measured whose element isn't on the page yet (#1024): held off it by a boundary
|
|
4075
|
+
// that waits, as a Solid 2 `<Loading>` holds an element whose ward was made outside it, it reads
|
|
4076
|
+
// 0x0 at the viewport's origin, and a later pass would grow it from there. It's left unmeasured:
|
|
4077
|
+
// its first box is the one a pass reads once it's on the page, which doesn't animate.
|
|
4078
|
+
if (Bool.and(Predicate.isUndefined(node.retained), Bool.not(node.element.isConnected))) continue
|
|
4014
4079
|
// A `display: contents` element has no box (ADR-0009 *Amendment (#9)*): its rect is 0x0 at
|
|
4015
4080
|
// the viewport's origin, which a scroll would read as a move. It never animates or carries a
|
|
4016
4081
|
// delta, and what it holds projects as if it weren't there.
|
|
@@ -4268,7 +4333,7 @@ export const makeProjectionSystem = (
|
|
|
4268
4333
|
if (measuredNow.length > 0) {
|
|
4269
4334
|
for (const { node, box, prev } of measuredNow.splice(0)) {
|
|
4270
4335
|
const tell = node.onMeasure
|
|
4271
|
-
if (Predicate.isNotUndefined(tell)) callMeasureHook(() => tell(box, Option.fromUndefinedOr(prev)), "onLayoutMeasure")
|
|
4336
|
+
if (Predicate.isNotUndefined(tell)) callMeasureHook(node, () => tell(box, Option.fromUndefinedOr(prev)), "onLayoutMeasure")
|
|
4272
4337
|
}
|
|
4273
4338
|
}
|
|
4274
4339
|
deriveGroup(groupOf(changed))
|
|
@@ -4400,7 +4465,7 @@ export const makeProjectionSystem = (
|
|
|
4400
4465
|
inAfterTickStep = false
|
|
4401
4466
|
}
|
|
4402
4467
|
if (Arr.isArrayNonEmpty(flightStarts)) {
|
|
4403
|
-
for (const node of flightStarts.splice(0)) callAppIfAny(node.onLayoutAnimationStart
|
|
4468
|
+
for (const node of flightStarts.splice(0)) callAppIfAny(node, node.onLayoutAnimationStart, "onLayoutAnimationStart")
|
|
4404
4469
|
}
|
|
4405
4470
|
return stepped.size
|
|
4406
4471
|
}
|
|
@@ -4437,6 +4502,7 @@ export const makeProjectionSystem = (
|
|
|
4437
4502
|
}
|
|
4438
4503
|
|
|
4439
4504
|
/** Call an app's `callback` (#191): one that throws is reported, and the engine goes on. */
|
|
4505
|
+
// Each time: an `onSettled` is called once (#979 group I, ADR-0074 decision 3).
|
|
4440
4506
|
const callApp = (callback: () => void, name: string): void => {
|
|
4441
4507
|
try {
|
|
4442
4508
|
callback()
|
|
@@ -4445,9 +4511,22 @@ export const makeProjectionSystem = (
|
|
|
4445
4511
|
}
|
|
4446
4512
|
}
|
|
4447
4513
|
|
|
4448
|
-
/**
|
|
4449
|
-
|
|
4450
|
-
|
|
4514
|
+
/**
|
|
4515
|
+
* `node`'s app callback `name`, read from `callbackOf` and called if it gave one: a throw from either is
|
|
4516
|
+
* reported at the first of a run of its throws, its next clean call ending the run, and the engine goes on.
|
|
4517
|
+
*/
|
|
4518
|
+
// #191; once a run, #979 group I (row 29). The read in the try too (ADR-0074's open list): a binding's
|
|
4519
|
+
// getter can be the app's config (Solid 1's `createWard` accessor), and one that threw came out of the
|
|
4520
|
+
// tick's hook, the nodes after it in the tick's list missing their callbacks.
|
|
4521
|
+
const callAppIfAny = (node: NodeState, callbackOf: () => Option.Option<() => void>, name: LayoutCallbackName): void => {
|
|
4522
|
+
try {
|
|
4523
|
+
const callback = callbackOf()
|
|
4524
|
+
if (Option.isNone(callback)) return
|
|
4525
|
+
callback.value()
|
|
4526
|
+
Failing.endRunOf(node, name)
|
|
4527
|
+
} catch (defect) {
|
|
4528
|
+
if (Failing.firstThrowOf(node, name)) runtime.runFork(Report.failure(`wardic.projection: ${name} failed`, Cause.die(defect)))
|
|
4529
|
+
}
|
|
4451
4530
|
}
|
|
4452
4531
|
|
|
4453
4532
|
/** Whether `flight` still runs on `node`: not landed, not replaced by a restart, not cut short, not unmounted. */
|
|
@@ -4497,13 +4576,13 @@ export const makeProjectionSystem = (
|
|
|
4497
4576
|
tickFrame = frameTime()
|
|
4498
4577
|
tickDt = dt
|
|
4499
4578
|
if (Arr.isArrayNonEmpty(flightStarts)) {
|
|
4500
|
-
for (const node of flightStarts.splice(0)) callAppIfAny(node.onLayoutAnimationStart
|
|
4579
|
+
for (const node of flightStarts.splice(0)) callAppIfAny(node, node.onLayoutAnimationStart, "onLayoutAnimationStart")
|
|
4501
4580
|
}
|
|
4502
4581
|
if (Arr.isArrayNonEmpty(flightLands)) {
|
|
4503
|
-
for (const node of flightLands.splice(0)) callAppIfAny(node.onLayoutAnimationComplete
|
|
4582
|
+
for (const node of flightLands.splice(0)) callAppIfAny(node, node.onLayoutAnimationComplete, "onLayoutAnimationComplete")
|
|
4504
4583
|
}
|
|
4505
4584
|
if (Arr.isArrayNonEmpty(releaseEnds)) {
|
|
4506
|
-
for (const node of releaseEnds.splice(0)) callAppIfAny(node.onReleaseEnd
|
|
4585
|
+
for (const node of releaseEnds.splice(0)) callAppIfAny(node, node.onReleaseEnd, "onDragTransitionEnd")
|
|
4507
4586
|
}
|
|
4508
4587
|
checkSettlings()
|
|
4509
4588
|
return undefined
|
|
@@ -4780,7 +4859,17 @@ export const makeProjectionSystem = (
|
|
|
4780
4859
|
const active = flight.elapsed - timing.delay
|
|
4781
4860
|
if (active < 0) return false
|
|
4782
4861
|
const t = Math.min(1, active / timing.duration)
|
|
4783
|
-
|
|
4862
|
+
// #979, row 5 (ADR-0074): the app's ease is its node's own. One that throws leaves the node where
|
|
4863
|
+
// its last ease put it, landing on its target on time, and the coordinator's other nodes go on:
|
|
4864
|
+
// before, it failed the coordinator's run, so every layout animation stopped.
|
|
4865
|
+
try {
|
|
4866
|
+
flight.position = timing.ease(t)
|
|
4867
|
+
if (node.easeFailing) node.easeFailing = false
|
|
4868
|
+
} catch (defect) {
|
|
4869
|
+
if (!node.easeFailing) runtime.runFork(Effect.annotateLogs(Report.failure("wardic.projection: a layout animation's ease failed", Cause.die(defect)), { id: node.id }))
|
|
4870
|
+
node.easeFailing = true
|
|
4871
|
+
if (t >= 1) flight.position = 1
|
|
4872
|
+
}
|
|
4784
4873
|
return t >= 1
|
|
4785
4874
|
}
|
|
4786
4875
|
|
|
@@ -5156,9 +5245,10 @@ export const makeProjectionSystem = (
|
|
|
5156
5245
|
/**
|
|
5157
5246
|
* The coordinator's end, told apart (ADR-0027, decision 7): a settle, or an
|
|
5158
5247
|
* interruption (a stop outside its step, the system's dispose), is nothing; anything
|
|
5159
|
-
* else (a step
|
|
5248
|
+
* else (a step whose own code threw, the Frame loop's own failure) is logged and reported
|
|
5160
5249
|
* (`Report.failure`, ADR-0030 decision 4). Its nodes then wait where the last step left
|
|
5161
|
-
* them, and the next trigger starts a fresh run.
|
|
5250
|
+
* them, and the next trigger starts a fresh run. An app's code on the step is its node's
|
|
5251
|
+
* own, caught where it's called (#979, row 5), so it never ends the run.
|
|
5162
5252
|
*/
|
|
5163
5253
|
const coordinatorEnded = (exit: Exit.Exit<unknown>): Effect.Effect<void> =>
|
|
5164
5254
|
Exit.match(exit, {
|
|
@@ -5300,6 +5390,7 @@ export const makeProjectionSystem = (
|
|
|
5300
5390
|
* its last pass.
|
|
5301
5391
|
*/
|
|
5302
5392
|
const makeLeavingNode = (
|
|
5393
|
+
id: string,
|
|
5303
5394
|
el: HTMLElement,
|
|
5304
5395
|
layoutId: string | undefined,
|
|
5305
5396
|
recent: LastPass,
|
|
@@ -5307,7 +5398,8 @@ export const makeProjectionSystem = (
|
|
|
5307
5398
|
layoutAnchor: Point.Point | false | undefined,
|
|
5308
5399
|
chain: ReadonlyArray<PaintLink> | undefined,
|
|
5309
5400
|
): NodeState => ({
|
|
5310
|
-
|
|
5401
|
+
// Driven through the Renderer, not the gate: its id names it in its reports alone.
|
|
5402
|
+
id,
|
|
5311
5403
|
element: el,
|
|
5312
5404
|
transition: Option.none,
|
|
5313
5405
|
path: Option.none,
|
|
@@ -5327,6 +5419,7 @@ export const makeProjectionSystem = (
|
|
|
5327
5419
|
heldTransform: undefined,
|
|
5328
5420
|
onBeforeMeasure: undefined,
|
|
5329
5421
|
onMeasure: undefined,
|
|
5422
|
+
failing: undefined,
|
|
5330
5423
|
blend: undefined,
|
|
5331
5424
|
seedBlend: undefined,
|
|
5332
5425
|
seedScroll: undefined,
|
|
@@ -5360,6 +5453,11 @@ export const makeProjectionSystem = (
|
|
|
5360
5453
|
corrected: false,
|
|
5361
5454
|
customBases: readCustomBases(el),
|
|
5362
5455
|
customCorrected: false,
|
|
5456
|
+
easeFailing: false,
|
|
5457
|
+
failingCorrectors: undefined,
|
|
5458
|
+
writeFailing: false,
|
|
5459
|
+
heldFailing: false,
|
|
5460
|
+
lastHeld: "none",
|
|
5363
5461
|
isScroll: false,
|
|
5364
5462
|
scroll: { x: 0, y: 0 },
|
|
5365
5463
|
isScrollRoot: false,
|
|
@@ -5441,7 +5539,7 @@ export const makeProjectionSystem = (
|
|
|
5441
5539
|
if (Predicate.isUndefined(last)) return false
|
|
5442
5540
|
const stack = stacks.get(layoutId)
|
|
5443
5541
|
if (Predicate.isUndefined(stack)) return false
|
|
5444
|
-
const follower = makeLeavingNode(el, layoutId, last, onDone, undefined, undefined)
|
|
5542
|
+
const follower = makeLeavingNode(recent.id, el, layoutId, last, onDone, undefined, undefined)
|
|
5445
5543
|
recent.reintroduced = true
|
|
5446
5544
|
addNode(follower)
|
|
5447
5545
|
elementToNode.set(el, follower)
|
|
@@ -5516,7 +5614,7 @@ export const makeProjectionSystem = (
|
|
|
5516
5614
|
// Not onto a Lead that is leaving itself (#682): it has no handover to ride.
|
|
5517
5615
|
if (lead.leaving) return
|
|
5518
5616
|
if (Bool.not(takesOver(lead))) return
|
|
5519
|
-
const twin = makeLeavingNode(inner, held.layoutId, last, () => undefined, undefined, chainOf(held))
|
|
5617
|
+
const twin = makeLeavingNode(recent.id, inner, held.layoutId, last, () => undefined, undefined, chainOf(held))
|
|
5520
5618
|
recent.reintroduced = true
|
|
5521
5619
|
addNode(twin)
|
|
5522
5620
|
elementToNode.set(inner, twin)
|
|
@@ -5539,7 +5637,7 @@ export const makeProjectionSystem = (
|
|
|
5539
5637
|
if (recent.reintroduced) return
|
|
5540
5638
|
if (Bool.not(contains(container, inner))) return
|
|
5541
5639
|
recent.reintroduced = true
|
|
5542
|
-
const node = makeLeavingNode(inner, undefined, last, undefined, recent.layoutAnchor, undefined)
|
|
5640
|
+
const node = makeLeavingNode(recent.id, inner, undefined, last, undefined, recent.layoutAnchor, undefined)
|
|
5543
5641
|
addNode(node)
|
|
5544
5642
|
elementToNode.set(inner, node)
|
|
5545
5643
|
carried.push(node)
|
|
@@ -5870,6 +5968,7 @@ export const makeProjectionSystem = (
|
|
|
5870
5968
|
heldTransform: opts.heldTransform,
|
|
5871
5969
|
onBeforeMeasure: opts.onBeforeMeasure,
|
|
5872
5970
|
onMeasure: opts.onMeasure,
|
|
5971
|
+
failing: undefined,
|
|
5873
5972
|
blend: undefined,
|
|
5874
5973
|
seedBlend: undefined,
|
|
5875
5974
|
seedScroll: undefined,
|
|
@@ -5903,6 +6002,11 @@ export const makeProjectionSystem = (
|
|
|
5903
6002
|
corrected: false,
|
|
5904
6003
|
customBases: undefined,
|
|
5905
6004
|
customCorrected: false,
|
|
6005
|
+
easeFailing: false,
|
|
6006
|
+
failingCorrectors: undefined,
|
|
6007
|
+
writeFailing: false,
|
|
6008
|
+
heldFailing: false,
|
|
6009
|
+
lastHeld: "none",
|
|
5906
6010
|
isScroll: opts.layoutScroll === true,
|
|
5907
6011
|
scroll: { x: 0, y: 0 },
|
|
5908
6012
|
isScrollRoot: false,
|
|
@@ -6069,7 +6173,7 @@ export const makeProjectionSystem = (
|
|
|
6069
6173
|
if (active.size === 0) stopTicking()
|
|
6070
6174
|
// No release runs, so it has ended (#273): told from a microtask, as Motion's instant one resolves.
|
|
6071
6175
|
queueMicrotask(() => {
|
|
6072
|
-
if (nodes.has(node)) callAppIfAny(node.onReleaseEnd
|
|
6176
|
+
if (nodes.has(node)) callAppIfAny(node, node.onReleaseEnd, "onDragTransitionEnd")
|
|
6073
6177
|
})
|
|
6074
6178
|
return
|
|
6075
6179
|
}
|
package/src/internal/renderer.ts
CHANGED
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
* per-frame hot path, so — exactly like core's `applyTo` per-frame writes and
|
|
18
18
|
* the Clock's `tick` — they stay quiet (no span, no per-call log).
|
|
19
19
|
*/
|
|
20
|
-
import * as BaseValue from "@wardic/core/BaseValue"
|
|
21
20
|
import type * as Point from "@wardic/core/Point"
|
|
22
21
|
import * as Projection from "@wardic/core/Projection"
|
|
23
22
|
import * as Renderer from "@wardic/core/Renderer"
|
|
24
23
|
import { dashCase, isSvgInner, setSvgAttrs, splitPatch } from "./svg.ts"
|
|
24
|
+
import { LENGTH_KEY_SET } from "./length-keys.ts"
|
|
25
|
+
import * as TransformKeys from "./transform-keys.ts"
|
|
25
26
|
import * as Arr from "effect/Array"
|
|
26
27
|
import * as Bool from "effect/Boolean"
|
|
27
28
|
import * as Layer from "effect/Layer"
|
|
@@ -30,18 +31,21 @@ import * as Predicate from "effect/Predicate"
|
|
|
30
31
|
import * as UndefinedOr from "effect/UndefinedOr"
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
* CSS transform functions in their canonical emission order:
|
|
34
|
-
* then scale, then rotate, then skew. `project` walks this list and emits a
|
|
34
|
+
* CSS transform functions in their canonical emission order: the element's own
|
|
35
|
+
* depth, then the translate group, then scale, then rotate, then skew. `project` walks this list and emits a
|
|
35
36
|
* func for each key that is present in `values` and not at its identity, so the
|
|
36
37
|
* resulting `transform` string is always grouped in this order regardless of
|
|
37
38
|
* input key order.
|
|
38
39
|
*
|
|
39
40
|
* `key` is the property name accepted on engine values (shorthands `x`/`y`/`z`
|
|
40
|
-
* included); `fn` is the CSS function name it renders as; `identity` is
|
|
41
|
-
* (ADR-0022), the value at which `project` leaves the key out (ADR-0023).
|
|
41
|
+
* included); `fn` is the CSS function name it renders as; `identity` is the DOM's
|
|
42
|
+
* (core's, ADR-0022, and the DOM's own), the value at which `project` leaves the key out (ADR-0023).
|
|
43
|
+
* The element's own depth is left out below it too (`TransformKeys.drawsDepth`).
|
|
42
44
|
*/
|
|
43
45
|
// Exported for the Batch writer (#665), which draws a member's transform in the same order.
|
|
44
46
|
export const TRANSFORM_FUNCS: ReadonlyArray<{ readonly key: string; readonly fn: string; readonly identity: number }> = [
|
|
47
|
+
// The element's own depth (#887), Motion's `transformPerspective`: first, so it projects what follows.
|
|
48
|
+
{ key: TransformKeys.PERSPECTIVE, fn: "perspective" },
|
|
45
49
|
// translate group — shorthands x/y/z map onto translateX/Y/Z
|
|
46
50
|
{ key: "x", fn: "translateX" },
|
|
47
51
|
{ key: "y", fn: "translateY" },
|
|
@@ -64,7 +68,15 @@ export const TRANSFORM_FUNCS: ReadonlyArray<{ readonly key: string; readonly fn:
|
|
|
64
68
|
// skew group
|
|
65
69
|
{ key: "skewX", fn: "skewX" },
|
|
66
70
|
{ key: "skewY", fn: "skewY" },
|
|
67
|
-
].map((f) => ({ ...f, identity: UndefinedOr.getOrThrow(
|
|
71
|
+
].map((f) => ({ ...f, identity: UndefinedOr.getOrThrow(TransformKeys.TRANSFORM_IDENTITY[f.key]) }))
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* What a plain render walks: every transform function but the element's own depth, which it draws ahead
|
|
75
|
+
* of them in a statement of its own.
|
|
76
|
+
*/
|
|
77
|
+
// #887 (ADR-0073, *Amendment (#887)*, Q8): one more step in the walk cost an element at rest 13% in Maglev,
|
|
78
|
+
// 4% in Bun; a read ahead of it, nothing (the cost gate's variants).
|
|
79
|
+
const WALKED_FUNCS = TRANSFORM_FUNCS.filter((f) => f.key !== TransformKeys.PERSPECTIVE)
|
|
68
80
|
|
|
69
81
|
/**
|
|
70
82
|
* Whether a transform value is at its identity (ADR-0023), Motion's test
|
|
@@ -79,14 +91,15 @@ const isIdentity = (value: unknown, identity: number): boolean => {
|
|
|
79
91
|
}
|
|
80
92
|
|
|
81
93
|
/**
|
|
82
|
-
* Whether `key`'s `value` adds to the element's `transform` (#240): a transform key
|
|
94
|
+
* Whether `key`'s `value` adds to the element's `transform` (#240): a transform key it draws, a
|
|
83
95
|
* `transform` string, the projection's value or a Transform template. A Timeline value drawing
|
|
84
96
|
* `transform` runs only while nothing else does. Per frame: statements.
|
|
85
97
|
*/
|
|
86
98
|
export const addsToTransform = (key: string, value: unknown): boolean => {
|
|
87
99
|
if (key === Projection.KEY || key === TEMPLATE_KEY || key === "transform") return true
|
|
88
|
-
const identity =
|
|
100
|
+
const identity = TransformKeys.TRANSFORM_IDENTITY[key]
|
|
89
101
|
if (Predicate.isUndefined(identity)) return false
|
|
102
|
+
if (key === TransformKeys.PERSPECTIVE) return TransformKeys.drawsDepth(value)
|
|
90
103
|
return !isIdentity(value, identity)
|
|
91
104
|
}
|
|
92
105
|
|
|
@@ -101,11 +114,12 @@ type TransformUnit = "px" | "deg" | ""
|
|
|
101
114
|
|
|
102
115
|
/**
|
|
103
116
|
* Default-unit map for transform values: translate (and the x/y/z shorthands)
|
|
104
|
-
* are lengths → `px
|
|
117
|
+
* are lengths → `px`, as is the element's own depth; rotate/skew are angles → `deg`; scale* are unitless.
|
|
105
118
|
* A value that is already a string is used verbatim (explicit units honoured),
|
|
106
119
|
* so this map only drives the formatting of bare numbers.
|
|
107
120
|
*/
|
|
108
121
|
const TRANSFORM_UNITS: Record<string, TransformUnit> = {
|
|
122
|
+
[TransformKeys.PERSPECTIVE]: "px",
|
|
109
123
|
x: "px",
|
|
110
124
|
y: "px",
|
|
111
125
|
z: "px",
|
|
@@ -125,84 +139,10 @@ const TRANSFORM_UNITS: Record<string, TransformUnit> = {
|
|
|
125
139
|
skewY: "deg",
|
|
126
140
|
}
|
|
127
141
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const TRANSFORM_KEYS: ReadonlySet<string> = new Set(Object.keys(BaseValue.TRANSFORM_IDENTITY))
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* The CSS properties a bare number on is a length, drawn in `px`, spelled as Wardic's keys are
|
|
136
|
-
* (`margin-top`): Motion's, and `min-width`, `min-height`, the gaps and `letter-spacing`. The Solid
|
|
137
|
-
* bindings' value types take a number on these and on no other length, so a number never draws CSS a
|
|
138
|
-
* browser drops. `line-height` isn't one: CSS reads its bare number as a multiple. A number on any other
|
|
139
|
-
* key, `opacity`, `z-index`, a custom property, is drawn as it is; a string always is.
|
|
140
|
-
*/
|
|
141
|
-
// #522: Motion's `numberValueTypes`' `px` keys; the bindings' `WardicValues`.
|
|
142
|
-
export const LENGTH_KEYS = [
|
|
143
|
-
"border-width",
|
|
144
|
-
"border-top-width",
|
|
145
|
-
"border-right-width",
|
|
146
|
-
"border-bottom-width",
|
|
147
|
-
"border-left-width",
|
|
148
|
-
"border-radius",
|
|
149
|
-
"border-top-left-radius",
|
|
150
|
-
"border-top-right-radius",
|
|
151
|
-
"border-bottom-right-radius",
|
|
152
|
-
"border-bottom-left-radius",
|
|
153
|
-
"width",
|
|
154
|
-
"min-width",
|
|
155
|
-
"max-width",
|
|
156
|
-
"height",
|
|
157
|
-
"min-height",
|
|
158
|
-
"max-height",
|
|
159
|
-
"top",
|
|
160
|
-
"right",
|
|
161
|
-
"bottom",
|
|
162
|
-
"left",
|
|
163
|
-
"inset",
|
|
164
|
-
"inset-block",
|
|
165
|
-
"inset-block-start",
|
|
166
|
-
"inset-block-end",
|
|
167
|
-
"inset-inline",
|
|
168
|
-
"inset-inline-start",
|
|
169
|
-
"inset-inline-end",
|
|
170
|
-
"padding",
|
|
171
|
-
"padding-top",
|
|
172
|
-
"padding-right",
|
|
173
|
-
"padding-bottom",
|
|
174
|
-
"padding-left",
|
|
175
|
-
"padding-block",
|
|
176
|
-
"padding-block-start",
|
|
177
|
-
"padding-block-end",
|
|
178
|
-
"padding-inline",
|
|
179
|
-
"padding-inline-start",
|
|
180
|
-
"padding-inline-end",
|
|
181
|
-
"margin",
|
|
182
|
-
"margin-top",
|
|
183
|
-
"margin-right",
|
|
184
|
-
"margin-bottom",
|
|
185
|
-
"margin-left",
|
|
186
|
-
"margin-block",
|
|
187
|
-
"margin-block-start",
|
|
188
|
-
"margin-block-end",
|
|
189
|
-
"margin-inline",
|
|
190
|
-
"margin-inline-start",
|
|
191
|
-
"margin-inline-end",
|
|
192
|
-
"gap",
|
|
193
|
-
"row-gap",
|
|
194
|
-
"column-gap",
|
|
195
|
-
"font-size",
|
|
196
|
-
"letter-spacing",
|
|
197
|
-
"background-position-x",
|
|
198
|
-
"background-position-y",
|
|
199
|
-
] as const
|
|
200
|
-
|
|
201
|
-
/** One of `LENGTH_KEYS`: a CSS property a bare number on is drawn in `px`. */
|
|
202
|
-
export type LengthKey = (typeof LENGTH_KEYS)[number]
|
|
203
|
-
|
|
204
|
-
/** {@link LENGTH_KEYS}, for a membership test a frame can make. */
|
|
205
|
-
const LENGTH_KEY_SET: ReadonlySet<string> = new Set(LENGTH_KEYS)
|
|
142
|
+
|
|
143
|
+
// The lengths a bare number on is drawn in px: a module of their own, which `LiveStyle` reads too without
|
|
144
|
+
// bringing the renderer (#887; a three Stage's apps ship `LiveStyle`, not the renderer).
|
|
145
|
+
export { LENGTH_KEYS, type LengthKey } from "./length-keys.ts"
|
|
206
146
|
|
|
207
147
|
/**
|
|
208
148
|
* Format one transform value into its CSS func argument. Strings pass through
|
|
@@ -411,6 +351,10 @@ const buildProjectionTransform = (
|
|
|
411
351
|
const translateByUnit = otherUnitTranslate(latest["translateX"], latest["translateY"])
|
|
412
352
|
if (translateByUnit !== "") funcs.unshift(translateByUnit)
|
|
413
353
|
if (ownByUnit !== "") funcs.unshift(ownByUnit)
|
|
354
|
+
// The element's own depth heads it all, as Motion's `buildProjectionTransform` puts it, so it projects
|
|
355
|
+
// what follows (#887).
|
|
356
|
+
const depth = latest[TransformKeys.PERSPECTIVE]
|
|
357
|
+
if (Predicate.isNotUndefined(depth) && TransformKeys.drawsDepth(depth)) funcs.unshift(`perspective(${formatTransformValue(TransformKeys.PERSPECTIVE, depth)})`)
|
|
414
358
|
if (funcs.length === 0) return "none"
|
|
415
359
|
return funcs.join(" ")
|
|
416
360
|
}
|
|
@@ -498,14 +442,23 @@ const projectsNothing = (projection: Projection.Value): boolean => {
|
|
|
498
442
|
|
|
499
443
|
/**
|
|
500
444
|
* The transform keys a plain render draws (ADR-0023): each one present and not at its identity, in
|
|
501
|
-
* the canonical order; `""` when every one present is at its identity;
|
|
502
|
-
* by concatenation, not an array joined (ADR-0034): this runs per element
|
|
445
|
+
* the canonical order, the element's own depth first; `""` when every one present is at its identity;
|
|
446
|
+
* `undefined` with none. Built by concatenation, not an array joined (ADR-0034): this runs per element
|
|
447
|
+
* per frame.
|
|
503
448
|
*/
|
|
504
449
|
const plainTransformOf = (values: Record<string, unknown>): string | undefined => {
|
|
505
450
|
let transform = ""
|
|
506
451
|
let separator = ""
|
|
507
452
|
let present = false
|
|
508
|
-
|
|
453
|
+
const depth = values[TransformKeys.PERSPECTIVE]
|
|
454
|
+
if (Predicate.isNotUndefined(depth)) {
|
|
455
|
+
present = true
|
|
456
|
+
if (TransformKeys.drawsDepth(depth)) {
|
|
457
|
+
transform = `perspective(${formatTransformValue(TransformKeys.PERSPECTIVE, depth)})`
|
|
458
|
+
separator = " "
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
for (const { key, fn, identity } of WALKED_FUNCS) {
|
|
509
462
|
if (!Object.hasOwn(values, key)) continue
|
|
510
463
|
present = true
|
|
511
464
|
const value = values[key]
|
|
@@ -609,7 +562,7 @@ export const project = (values: Readonly<Record<string, unknown>>): Renderer.Pat
|
|
|
609
562
|
// Copy non-transform style keys (transform keys are consumed by the weave /
|
|
610
563
|
// owned by the projection; the reserved keys never render).
|
|
611
564
|
for (const key in values) {
|
|
612
|
-
if (key === Projection.KEY || key === TEMPLATE_KEY || TRANSFORM_KEYS.has(key)) continue
|
|
565
|
+
if (key === Projection.KEY || key === TEMPLATE_KEY || TransformKeys.TRANSFORM_KEYS.has(key)) continue
|
|
613
566
|
patch[key] = formatStyleValue(key, values[key])
|
|
614
567
|
}
|
|
615
568
|
// Shared-element crossfade (ADR-0010): compose the crossfade factor with the
|
|
@@ -635,7 +588,7 @@ export const project = (values: Readonly<Record<string, unknown>>): Renderer.Pat
|
|
|
635
588
|
|
|
636
589
|
// Non-transform keys: copy across with default-unit handling.
|
|
637
590
|
for (const key in values) {
|
|
638
|
-
if (key === TEMPLATE_KEY || TRANSFORM_KEYS.has(key)) continue
|
|
591
|
+
if (key === TEMPLATE_KEY || TransformKeys.TRANSFORM_KEYS.has(key)) continue
|
|
639
592
|
patch[key] = formatStyleValue(key, values[key])
|
|
640
593
|
}
|
|
641
594
|
|