@wardic/core 0.0.0-stage → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -2
- package/THIRD_PARTY_NOTICES.md +145 -0
- package/dist/Announcer.d.ts +24 -0
- package/dist/Announcer.d.ts.map +1 -0
- package/dist/Announcer.js +23 -0
- package/dist/Announcer.js.map +1 -0
- package/dist/Arc.d.ts +43 -0
- package/dist/Arc.d.ts.map +1 -0
- package/dist/Arc.js +98 -0
- package/dist/Arc.js.map +1 -0
- package/dist/AutoScroll.d.ts +45 -0
- package/dist/AutoScroll.d.ts.map +1 -0
- package/dist/AutoScroll.js +82 -0
- package/dist/AutoScroll.js.map +1 -0
- package/dist/BaseValue.d.ts +64 -0
- package/dist/BaseValue.d.ts.map +1 -0
- package/dist/BaseValue.js +63 -0
- package/dist/BaseValue.js.map +1 -0
- package/dist/Box.d.ts +39 -0
- package/dist/Box.d.ts.map +1 -0
- package/dist/Box.js +39 -0
- package/dist/Box.js.map +1 -0
- package/dist/Clock.d.ts +53 -0
- package/dist/Clock.d.ts.map +1 -0
- package/dist/Clock.js +238 -0
- package/dist/Clock.js.map +1 -0
- package/dist/DefaultTransition.d.ts +54 -0
- package/dist/DefaultTransition.d.ts.map +1 -0
- package/dist/DefaultTransition.js +38 -0
- package/dist/DefaultTransition.js.map +1 -0
- package/dist/Drag.d.ts +129 -0
- package/dist/Drag.d.ts.map +1 -0
- package/dist/Drag.js +126 -0
- package/dist/Drag.js.map +1 -0
- package/dist/DragActivity.d.ts +22 -0
- package/dist/DragActivity.d.ts.map +1 -0
- package/dist/DragActivity.js +90 -0
- package/dist/DragActivity.js.map +1 -0
- package/dist/DragRecognizer.d.ts +137 -0
- package/dist/DragRecognizer.d.ts.map +1 -0
- package/dist/DragRecognizer.js +543 -0
- package/dist/DragRecognizer.js.map +1 -0
- package/dist/Easing.d.ts +167 -0
- package/dist/Easing.d.ts.map +1 -0
- package/dist/Easing.js +346 -0
- package/dist/Easing.js.map +1 -0
- package/dist/Frame.d.ts +21 -0
- package/dist/Frame.d.ts.map +1 -0
- package/dist/Frame.js +22 -0
- package/dist/Frame.js.map +1 -0
- package/dist/FrameLoop.d.ts +33 -0
- package/dist/FrameLoop.d.ts.map +1 -0
- package/dist/FrameLoop.js +33 -0
- package/dist/FrameLoop.js.map +1 -0
- package/dist/Inertia.d.ts +77 -0
- package/dist/Inertia.d.ts.map +1 -0
- package/dist/Inertia.js +197 -0
- package/dist/Inertia.js.map +1 -0
- package/dist/InputFeed.d.ts +71 -0
- package/dist/InputFeed.d.ts.map +1 -0
- package/dist/InputFeed.js +189 -0
- package/dist/InputFeed.js.map +1 -0
- package/dist/InputSource.d.ts +251 -0
- package/dist/InputSource.d.ts.map +1 -0
- package/dist/InputSource.js +290 -0
- package/dist/InputSource.js.map +1 -0
- package/dist/Interpolator.d.ts +133 -0
- package/dist/Interpolator.d.ts.map +1 -0
- package/dist/Interpolator.js +303 -0
- package/dist/Interpolator.js.map +1 -0
- package/dist/InterpolatorRegistry.d.ts +100 -0
- package/dist/InterpolatorRegistry.d.ts.map +1 -0
- package/dist/InterpolatorRegistry.js +208 -0
- package/dist/InterpolatorRegistry.js.map +1 -0
- package/dist/LiveValue.d.ts +210 -0
- package/dist/LiveValue.d.ts.map +1 -0
- package/dist/LiveValue.js +489 -0
- package/dist/LiveValue.js.map +1 -0
- package/dist/Machine.d.ts +540 -0
- package/dist/Machine.d.ts.map +1 -0
- package/dist/Machine.js +1199 -0
- package/dist/Machine.js.map +1 -0
- package/dist/Microtask.d.ts +17 -0
- package/dist/Microtask.d.ts.map +1 -0
- package/dist/Microtask.js +33 -0
- package/dist/Microtask.js.map +1 -0
- package/dist/Override.d.ts +15 -0
- package/dist/Override.d.ts.map +1 -0
- package/dist/Override.js +34 -0
- package/dist/Override.js.map +1 -0
- package/dist/Playback.d.ts +69 -0
- package/dist/Playback.d.ts.map +1 -0
- package/dist/Playback.js +165 -0
- package/dist/Playback.js.map +1 -0
- package/dist/Point.d.ts +14 -0
- package/dist/Point.d.ts.map +1 -0
- package/dist/Point.js +21 -0
- package/dist/Point.js.map +1 -0
- package/dist/PressClaims.d.ts +29 -0
- package/dist/PressClaims.d.ts.map +1 -0
- package/dist/PressClaims.js +63 -0
- package/dist/PressClaims.js.map +1 -0
- package/dist/Probe.d.ts +127 -0
- package/dist/Probe.d.ts.map +1 -0
- package/dist/Probe.js +20 -0
- package/dist/Probe.js.map +1 -0
- package/dist/Projection.d.ts +141 -0
- package/dist/Projection.d.ts.map +1 -0
- package/dist/Projection.js +210 -0
- package/dist/Projection.js.map +1 -0
- package/dist/Recognizer.d.ts +150 -0
- package/dist/Recognizer.d.ts.map +1 -0
- package/dist/Recognizer.js +458 -0
- package/dist/Recognizer.js.map +1 -0
- package/dist/ReducedMotion.d.ts +64 -0
- package/dist/ReducedMotion.d.ts.map +1 -0
- package/dist/ReducedMotion.js +101 -0
- package/dist/ReducedMotion.js.map +1 -0
- package/dist/RefreshFrameSource.d.ts +51 -0
- package/dist/RefreshFrameSource.d.ts.map +1 -0
- package/dist/RefreshFrameSource.js +26 -0
- package/dist/RefreshFrameSource.js.map +1 -0
- package/dist/Renderer.d.ts +48 -0
- package/dist/Renderer.d.ts.map +1 -0
- package/dist/Renderer.js +51 -0
- package/dist/Renderer.js.map +1 -0
- package/dist/Reorder.d.ts +285 -0
- package/dist/Reorder.d.ts.map +1 -0
- package/dist/Reorder.js +496 -0
- package/dist/Reorder.js.map +1 -0
- package/dist/Scalar.d.ts +47 -0
- package/dist/Scalar.d.ts.map +1 -0
- package/dist/Scalar.js +82 -0
- package/dist/Scalar.js.map +1 -0
- package/dist/Sequence.d.ts +76 -0
- package/dist/Sequence.d.ts.map +1 -0
- package/dist/Sequence.js +279 -0
- package/dist/Sequence.js.map +1 -0
- package/dist/SharedSource.d.ts +34 -0
- package/dist/SharedSource.d.ts.map +1 -0
- package/dist/SharedSource.js +158 -0
- package/dist/SharedSource.js.map +1 -0
- package/dist/Spring.d.ts +152 -0
- package/dist/Spring.d.ts.map +1 -0
- package/dist/Spring.js +346 -0
- package/dist/Spring.js.map +1 -0
- package/dist/Stagger.d.ts +25 -0
- package/dist/Stagger.d.ts.map +1 -0
- package/dist/Stagger.js +42 -0
- package/dist/Stagger.js.map +1 -0
- package/dist/Supersede.d.ts +37 -0
- package/dist/Supersede.d.ts.map +1 -0
- package/dist/Supersede.js +71 -0
- package/dist/Supersede.js.map +1 -0
- package/dist/Values.d.ts +30 -0
- package/dist/Values.d.ts.map +1 -0
- package/dist/Values.js +46 -0
- package/dist/Values.js.map +1 -0
- package/dist/Velocity.d.ts +28 -0
- package/dist/Velocity.d.ts.map +1 -0
- package/dist/Velocity.js +65 -0
- package/dist/Velocity.js.map +1 -0
- package/dist/Wave.d.ts +24 -0
- package/dist/Wave.d.ts.map +1 -0
- package/dist/Wave.js +57 -0
- package/dist/Wave.js.map +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/complexTokens.d.ts +20 -0
- package/dist/internal/complexTokens.d.ts.map +1 -0
- package/dist/internal/complexTokens.js +37 -0
- package/dist/internal/complexTokens.js.map +1 -0
- package/dist/internal/driven.d.ts +5 -0
- package/dist/internal/driven.d.ts.map +1 -0
- package/dist/internal/driven.js +16 -0
- package/dist/internal/driven.js.map +1 -0
- package/dist/internal/dual.d.ts +11 -0
- package/dist/internal/dual.d.ts.map +1 -0
- package/dist/internal/dual.js +52 -0
- package/dist/internal/dual.js.map +1 -0
- package/dist/internal/frameLoop.d.ts +78 -0
- package/dist/internal/frameLoop.d.ts.map +1 -0
- package/dist/internal/frameLoop.js +373 -0
- package/dist/internal/frameLoop.js.map +1 -0
- package/dist/internal/options.d.ts +125 -0
- package/dist/internal/options.d.ts.map +1 -0
- package/dist/internal/options.js +247 -0
- package/dist/internal/options.js.map +1 -0
- package/dist/internal/outbox.d.ts +6 -0
- package/dist/internal/outbox.d.ts.map +1 -0
- package/dist/internal/outbox.js +41 -0
- package/dist/internal/outbox.js.map +1 -0
- package/dist/internal/stepper.d.ts +161 -0
- package/dist/internal/stepper.d.ts.map +1 -0
- package/dist/internal/stepper.js +185 -0
- package/dist/internal/stepper.js.map +1 -0
- package/dist/internal/tracing.d.ts +22 -0
- package/dist/internal/tracing.d.ts.map +1 -0
- package/dist/internal/tracing.js +41 -0
- package/dist/internal/tracing.js.map +1 -0
- package/dist/internal/watch.d.ts +22 -0
- package/dist/internal/watch.d.ts.map +1 -0
- package/dist/internal/watch.js +34 -0
- package/dist/internal/watch.js.map +1 -0
- package/package.json +65 -4
- package/src/Announcer.ts +26 -0
- package/src/Arc.ts +151 -0
- package/src/AutoScroll.ts +129 -0
- package/src/BaseValue.ts +117 -0
- package/src/Box.ts +75 -0
- package/src/Clock.ts +296 -0
- package/src/DefaultTransition.ts +61 -0
- package/src/Drag.ts +252 -0
- package/src/DragActivity.ts +127 -0
- package/src/DragRecognizer.ts +770 -0
- package/src/Easing.ts +421 -0
- package/src/Frame.ts +41 -0
- package/src/FrameLoop.ts +43 -0
- package/src/Inertia.ts +273 -0
- package/src/InputFeed.ts +266 -0
- package/src/InputSource.ts +597 -0
- package/src/Interpolator.ts +492 -0
- package/src/InterpolatorRegistry.ts +356 -0
- package/src/LiveValue.ts +693 -0
- package/src/Machine.ts +1700 -0
- package/src/Microtask.ts +38 -0
- package/src/Override.ts +47 -0
- package/src/Playback.ts +208 -0
- package/src/Point.ts +31 -0
- package/src/PressClaims.ts +95 -0
- package/src/Probe.ts +140 -0
- package/src/Projection.ts +325 -0
- package/src/Recognizer.ts +690 -0
- package/src/ReducedMotion.ts +134 -0
- package/src/RefreshFrameSource.ts +58 -0
- package/src/Renderer.ts +73 -0
- package/src/Reorder.ts +896 -0
- package/src/Scalar.ts +90 -0
- package/src/Sequence.ts +406 -0
- package/src/SharedSource.ts +217 -0
- package/src/Spring.ts +475 -0
- package/src/Stagger.ts +67 -0
- package/src/Supersede.ts +99 -0
- package/src/Values.ts +69 -0
- package/src/Velocity.ts +82 -0
- package/src/Wave.ts +61 -0
- package/src/index.ts +57 -0
- package/src/internal/complexTokens.ts +55 -0
- package/src/internal/driven.ts +19 -0
- package/src/internal/dual.ts +61 -0
- package/src/internal/frameLoop.ts +483 -0
- package/src/internal/options.ts +312 -0
- package/src/internal/outbox.ts +45 -0
- package/src/internal/stepper.ts +300 -0
- package/src/internal/tracing.ts +60 -0
- package/src/internal/watch.ts +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 the Wardic contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @wardic/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Wardic's animation engine, on [Effect](https://effect.website): springs, tweens, inertia and keyframes, variants, the projection geometry behind layout animations, and the services an environment provides (a clock, a renderer, input, a probe).
|
|
4
|
+
|
|
5
|
+
Most apps don't install it directly: they use a binding, [`@wardic/solid`](https://www.npmjs.com/package/@wardic/solid), which brings it. It's for building an environment or a binding of your own.
|
|
6
|
+
|
|
7
|
+
- Docs: https://wardic.dev
|
|
8
|
+
- Source: https://github.com/wardiclabs/wardic/tree/main/packages/core
|
|
9
|
+
- Licence: MIT
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Wardic follows the API of [Motion](https://motion.dev) for React, and parts of its source are ported from Motion's: rewritten in Wardic's own style, keeping Motion's algorithms, formulas and constants so the results match. Motion is MIT licensed, and its notice follows.
|
|
4
|
+
|
|
5
|
+
## Motion
|
|
6
|
+
|
|
7
|
+
https://github.com/motiondivision/motion
|
|
8
|
+
|
|
9
|
+
Ported from Motion's source:
|
|
10
|
+
|
|
11
|
+
- `@wardic/core`:
|
|
12
|
+
- `Box` and `Projection`: the projection geometry (`motion-dom`'s `projection/geometry`: `models`, `delta-calc`, `delta-apply`, `applyTreeDeltas`);
|
|
13
|
+
- `Spring`: the solver for a spring's stiffness and damping from its duration and bounce (`findSpring`);
|
|
14
|
+
- `Velocity`: a gesture's velocity from its points (`getVelocity`);
|
|
15
|
+
- `Reorder`: moving an item, and the axis a list runs on (`moveItem`, `detectAxis`);
|
|
16
|
+
- `AutoScroll`: scrolling a container while an item is dragged near its edge (`autoScrollIfNeeded`).
|
|
17
|
+
- `@wardic/dom`:
|
|
18
|
+
- the projection transform (`buildProjectionTransform`);
|
|
19
|
+
- the scroll offsets (`render/dom/scroll/offsets`).
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
The MIT License (MIT)
|
|
23
|
+
|
|
24
|
+
Copyright (c) 2024 [Motion](https://motion.dev) B.V.
|
|
25
|
+
|
|
26
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
27
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
28
|
+
in the Software without restriction, including without limitation the rights
|
|
29
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
30
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
31
|
+
furnished to do so, subject to the following conditions:
|
|
32
|
+
|
|
33
|
+
The above copyright notice and this permission notice shall be included in all
|
|
34
|
+
copies or substantial portions of the Software.
|
|
35
|
+
|
|
36
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
37
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
38
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
39
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
40
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
41
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
42
|
+
SOFTWARE.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Manrope
|
|
46
|
+
|
|
47
|
+
https://github.com/googlefonts/manrope
|
|
48
|
+
|
|
49
|
+
The docs site serves Manrope for its headings (`site/public/fonts/manrope-latin.woff2`, its variable weights 600 to 800, Latin only, with its licence beside it as `OFL.txt`), and Wardic's wordmark is "wardic" set in Manrope ExtraBold and outlined (`brand/`, and the docs header's logo, `site/src/components/logo-paths.ts`). Manrope is licensed under the SIL Open Font License, Version 1.1.
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
Copyright 2018 The Manrope Project Authors (https://github.com/googlefonts/manrope)
|
|
53
|
+
|
|
54
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
55
|
+
This license is copied below, and is also available with a FAQ at:
|
|
56
|
+
http://scripts.sil.org/OFL
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
-----------------------------------------------------------
|
|
60
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
61
|
+
-----------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
PREAMBLE
|
|
64
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
65
|
+
development of collaborative font projects, to support the font creation
|
|
66
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
67
|
+
open framework in which fonts may be shared and improved in partnership
|
|
68
|
+
with others.
|
|
69
|
+
|
|
70
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
71
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
72
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
73
|
+
redistributed and/or sold with any software provided that any reserved
|
|
74
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
75
|
+
however, cannot be released under any other type of license. The
|
|
76
|
+
requirement for fonts to remain under this license does not apply
|
|
77
|
+
to any document created using the fonts or their derivatives.
|
|
78
|
+
|
|
79
|
+
DEFINITIONS
|
|
80
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
81
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
82
|
+
include source files, build scripts and documentation.
|
|
83
|
+
|
|
84
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
85
|
+
copyright statement(s).
|
|
86
|
+
|
|
87
|
+
"Original Version" refers to the collection of Font Software components as
|
|
88
|
+
distributed by the Copyright Holder(s).
|
|
89
|
+
|
|
90
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
91
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
92
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
93
|
+
new environment.
|
|
94
|
+
|
|
95
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
96
|
+
writer or other person who contributed to the Font Software.
|
|
97
|
+
|
|
98
|
+
PERMISSION & CONDITIONS
|
|
99
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
100
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
101
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
102
|
+
Software, subject to the following conditions:
|
|
103
|
+
|
|
104
|
+
1) Neither the Font Software nor any of its individual components,
|
|
105
|
+
in Original or Modified Versions, may be sold by itself.
|
|
106
|
+
|
|
107
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
108
|
+
redistributed and/or sold with any software, provided that each copy
|
|
109
|
+
contains the above copyright notice and this license. These can be
|
|
110
|
+
included either as stand-alone text files, human-readable headers or
|
|
111
|
+
in the appropriate machine-readable metadata fields within text or
|
|
112
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
113
|
+
|
|
114
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
115
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
116
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
117
|
+
presented to the users.
|
|
118
|
+
|
|
119
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
120
|
+
Software shall not be used to promote, endorse or advertise any
|
|
121
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
122
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
123
|
+
permission.
|
|
124
|
+
|
|
125
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
126
|
+
must be distributed entirely under this license, and must not be
|
|
127
|
+
distributed under any other license. The requirement for fonts to
|
|
128
|
+
remain under this license does not apply to any document created
|
|
129
|
+
using the Font Software.
|
|
130
|
+
|
|
131
|
+
TERMINATION
|
|
132
|
+
This license becomes null and void if any of the above conditions are
|
|
133
|
+
not met.
|
|
134
|
+
|
|
135
|
+
DISCLAIMER
|
|
136
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
137
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
138
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
139
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
140
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
141
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
142
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
143
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
144
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
145
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Announcer: how an Environment speaks a message to assistive technology, a screen reader, say.
|
|
3
|
+
* Core words what's said, as a Reorder group's announcements, and the Environment delivers it through
|
|
4
|
+
* its platform's own channel, as `@wardic/dom` does. Each announcement replaces the last.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import * as Announcer from "@wardic/core/Announcer"
|
|
8
|
+
*
|
|
9
|
+
* const announcer = yield* Announcer.Announcer
|
|
10
|
+
* announcer.announce("Picked up Milk, position 2 of 5.")
|
|
11
|
+
*/
|
|
12
|
+
import * as Context from "effect/Context";
|
|
13
|
+
import * as Layer from "effect/Layer";
|
|
14
|
+
declare const Announcer_base: Context.ServiceClass<Announcer, "@wardic/core/Announcer", {
|
|
15
|
+
/** Speaks `message`, replacing the last announcement. */
|
|
16
|
+
readonly announce: (message: string) => void;
|
|
17
|
+
}>;
|
|
18
|
+
/** An Environment's channel to assistive technology. */
|
|
19
|
+
export declare class Announcer extends Announcer_base {
|
|
20
|
+
}
|
|
21
|
+
/** An Announcer that says nothing, for an Environment with no assistive technology to reach, as the test Environment's. */
|
|
22
|
+
export declare const layerSilent: Layer.Layer<Announcer>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=Announcer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Announcer.d.ts","sourceRoot":"","sources":["../src/Announcer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;;IAInC,yDAAyD;uBACtC,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI;;AAH9C,wDAAwD;AACxD,qBAAa,SAAU,SAAQ,cAGD;CAAG;AAEjC,2HAA2H;AAC3H,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAoD,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Announcer: how an Environment speaks a message to assistive technology, a screen reader, say.
|
|
3
|
+
* Core words what's said, as a Reorder group's announcements, and the Environment delivers it through
|
|
4
|
+
* its platform's own channel, as `@wardic/dom` does. Each announcement replaces the last.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import * as Announcer from "@wardic/core/Announcer"
|
|
8
|
+
*
|
|
9
|
+
* const announcer = yield* Announcer.Announcer
|
|
10
|
+
* announcer.announce("Picked up Milk, position 2 of 5.")
|
|
11
|
+
*/
|
|
12
|
+
// An **Announcement** (ADR-0037); `@wardic/dom`'s `DomAnnouncer.layer`. A Context service, as
|
|
13
|
+
// `ReducedMotion.PositionalKeys` is: core names the contract and no Environment's syntax (ADR-0036). A
|
|
14
|
+
// plain call: an announcement answers a key just pressed, on no frame's path. Tier 2 (ADR-0008): for
|
|
15
|
+
// Environment and binding authors.
|
|
16
|
+
import * as Context from "effect/Context";
|
|
17
|
+
import * as Layer from "effect/Layer";
|
|
18
|
+
/** An Environment's channel to assistive technology. */
|
|
19
|
+
export class Announcer extends Context.Service()("@wardic/core/Announcer") {
|
|
20
|
+
}
|
|
21
|
+
/** An Announcer that says nothing, for an Environment with no assistive technology to reach, as the test Environment's. */
|
|
22
|
+
export const layerSilent = Layer.succeed(Announcer, { announce: () => { } });
|
|
23
|
+
//# sourceMappingURL=Announcer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Announcer.js","sourceRoot":"","sources":["../src/Announcer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,8FAA8F;AAC9F,uGAAuG;AACvG,qGAAqG;AACrG,mCAAmC;AACnC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,wDAAwD;AACxD,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAG1C,CAAC,wBAAwB,CAAC;CAAG;AAEjC,2HAA2H;AAC3H,MAAM,CAAC,MAAM,WAAW,GAA2B,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAA"}
|
package/dist/Arc.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type * as Point from "./Point.ts";
|
|
2
|
+
/** A point along a path: `x` and `y`, and, for a path that turns the element, `rotate` in degrees. */
|
|
3
|
+
export interface PathPoint extends Point.Point {
|
|
4
|
+
readonly rotate?: number | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A path for `x` and `y`: given where they start and end, the point at each progress `t`, 0 at the start
|
|
8
|
+
* and 1 at the end. `make` makes one; any function of this shape is one.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // A hop: a straight line that lifts 40 px at its middle.
|
|
12
|
+
* const hop: Arc.Path = (from, to) => (t) => ({
|
|
13
|
+
* x: from.x + (to.x - from.x) * t,
|
|
14
|
+
* y: from.y + (to.y - from.y) * t - Math.sin(Math.PI * t) * 40,
|
|
15
|
+
* })
|
|
16
|
+
*/
|
|
17
|
+
export type Path = (from: Point.Point, to: Point.Point) => (t: number) => PathPoint;
|
|
18
|
+
/** An arc's options, Motion's `arc`'s. */
|
|
19
|
+
export interface Options {
|
|
20
|
+
/**
|
|
21
|
+
* How far the arc bulges off the straight line, as a share of the distance it travels: `1` peaks
|
|
22
|
+
* at the whole distance. Default `0.5`.
|
|
23
|
+
*/
|
|
24
|
+
readonly strength?: number | undefined;
|
|
25
|
+
/** Where along the way (0–1) the arc is at its highest. Default `0.5`. */
|
|
26
|
+
readonly peak?: number | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The side it bulges to, turning with the direction of travel: `"cw"` or `"ccw"`. Left out, it
|
|
29
|
+
* keeps to one side of the screen across the paths one arc makes.
|
|
30
|
+
*/
|
|
31
|
+
readonly direction?: "cw" | "ccw" | undefined;
|
|
32
|
+
/** Whether it turns the element to follow the curve: `true` all the way, a number 0–1 that share of it. */
|
|
33
|
+
readonly rotate?: boolean | number | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A curved path, Motion's `arc()`. Make one and keep it: with no `direction`, it remembers the side of
|
|
37
|
+
* the screen it bulged to, and keeps to it when the direction of travel turns.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const path = Arc.make({ strength: 0.4, rotate: true }) // a binding's transition={{ path }}
|
|
41
|
+
*/
|
|
42
|
+
export declare const make: (options?: Options) => Path;
|
|
43
|
+
//# sourceMappingURL=Arc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Arc.d.ts","sourceRoot":"","sources":["../src/Arc.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AAExC,sGAAsG;AACtG,MAAM,WAAW,SAAU,SAAQ,KAAK,CAAC,KAAK;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACrC;AAED;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,MAAM,KAAK,SAAS,CAAA;AAEnF,0CAA0C;AAC1C,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS,CAAA;IAC7C,2GAA2G;IAC3G,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;CAC/C;AAuDD;;;;;;GAMG;AAEH,eAAO,MAAM,IAAI,aAAa,OAAO,KAAQ,IAiC5C,CAAA"}
|
package/dist/Arc.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curved paths between two points, for a transition's `path`: `x` and `y` travel along the curve
|
|
3
|
+
* together, rather than each on a straight line. `make` makes Motion's `arc()`, a curve that bulges off
|
|
4
|
+
* the straight line between them; any function of `Path`'s shape is a path too.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import * as Arc from "@wardic/core/Arc"
|
|
8
|
+
*
|
|
9
|
+
* const at = Arc.make({ strength: 0.3 })({ x: 0, y: 0 }, { x: 200, y: 80 })
|
|
10
|
+
* at(0.5) // the curve's middle: { x, y }
|
|
11
|
+
*/
|
|
12
|
+
// #438: an arc is a quadratic Bézier.
|
|
13
|
+
import * as Bool from "effect/Boolean";
|
|
14
|
+
import { identity } from "effect/Function";
|
|
15
|
+
import * as Match from "effect/Match";
|
|
16
|
+
import * as Predicate from "effect/Predicate";
|
|
17
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
18
|
+
/** `value` wrapped into `[min, max)`, motion-utils' `wrap`. */
|
|
19
|
+
const wrap = (min, max, value) => {
|
|
20
|
+
const range = max - min;
|
|
21
|
+
return ((((value - min) % range) + range) % range) + min;
|
|
22
|
+
};
|
|
23
|
+
/** A quadratic Bézier's coordinate at `t`. */
|
|
24
|
+
const bezierAt = (t, origin, control, target) => {
|
|
25
|
+
const inv = 1 - t;
|
|
26
|
+
return inv * inv * origin + 2 * inv * t * control + t * t * target;
|
|
27
|
+
};
|
|
28
|
+
/** The angle (degrees) of a quadratic Bézier's tangent at `t`. */
|
|
29
|
+
const tangentAt = (t, from, control, to) => {
|
|
30
|
+
const dx = 2 * (1 - t) * (control.x - from.x) + 2 * t * (to.x - control.x);
|
|
31
|
+
const dy = 2 * (1 - t) * (control.y - from.y) + 2 * t * (to.y - control.y);
|
|
32
|
+
return Math.atan2(dy, dx) * (180 / Math.PI);
|
|
33
|
+
};
|
|
34
|
+
/** The arc's control point: `peak` along the straight line, `strength` of its length off it, to its left. */
|
|
35
|
+
const controlOf = (from, to, strength, peak) => {
|
|
36
|
+
const dx = to.x - from.x;
|
|
37
|
+
const dy = to.y - from.y;
|
|
38
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
39
|
+
if (distance === 0)
|
|
40
|
+
return from;
|
|
41
|
+
const height = strength * distance;
|
|
42
|
+
return { x: from.x + dx * peak - (dy / distance) * height, y: from.y + dy * peak + (dx / distance) * height };
|
|
43
|
+
};
|
|
44
|
+
/** How much of the tangent an arc turns the element by. */
|
|
45
|
+
const rotationOf = (rotate) => Match.value(rotate).pipe(Match.when(true, () => 1), Match.when(Match.number, (share) => share), Match.orElse(() => 0));
|
|
46
|
+
/**
|
|
47
|
+
* An arc's signed strength for a move from its `dx` and `dy`, chosen once, at `make`, by its
|
|
48
|
+
* `direction`: a fixed side, or the screen side that keeps the dominant axis's travel turning the same way.
|
|
49
|
+
*/
|
|
50
|
+
// #618 (H1): `make`'s path built this matcher at every flight's start.
|
|
51
|
+
const signedOf = (direction, strength) => Match.value(direction).pipe(Match.when("cw", () => () => -strength), Match.when("ccw", () => () => strength), Match.orElse(() => (dx, dy) => Bool.match(Bool.match(Math.abs(dx) >= Math.abs(dy), { onTrue: () => dx, onFalse: () => dy }) < 0, {
|
|
52
|
+
onTrue: () => -strength,
|
|
53
|
+
onFalse: () => strength,
|
|
54
|
+
})));
|
|
55
|
+
/**
|
|
56
|
+
* A curved path, Motion's `arc()`. Make one and keep it: with no `direction`, it remembers the side of
|
|
57
|
+
* the screen it bulged to, and keeps to it when the direction of travel turns.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* const path = Arc.make({ strength: 0.4, rotate: true }) // a binding's transition={{ path }}
|
|
61
|
+
*/
|
|
62
|
+
// #438.
|
|
63
|
+
export const make = (options = {}) => {
|
|
64
|
+
const strength = UndefinedOr.match(options.strength, { onUndefined: () => 0.5, onDefined: identity });
|
|
65
|
+
const peak = UndefinedOr.match(options.peak, { onUndefined: () => 0.5, onDefined: identity });
|
|
66
|
+
const direction = options.direction;
|
|
67
|
+
const signedFor = signedOf(direction, strength);
|
|
68
|
+
const rotation = rotationOf(options.rotate);
|
|
69
|
+
// With no direction: the side of the screen the last arc bulged to, across the paths this one makes.
|
|
70
|
+
let lastSide;
|
|
71
|
+
return (from, to) => {
|
|
72
|
+
const dx = to.x - from.x;
|
|
73
|
+
const dy = to.y - from.y;
|
|
74
|
+
const signed = signedFor(dx, dy);
|
|
75
|
+
let control = controlOf(from, to, signed, peak);
|
|
76
|
+
if (Predicate.isUndefined(direction)) {
|
|
77
|
+
// Which side of the straight line it bulges to, across the dominant axis.
|
|
78
|
+
const side = Math.sign(Bool.match(Math.abs(dx) < Math.abs(dy), { onTrue: () => control.x - (from.x + dx * peak), onFalse: () => control.y - (from.y + dy * peak) }));
|
|
79
|
+
// The other side from the last arc's: turned back onto it.
|
|
80
|
+
const turned = Bool.and(Bool.and(Predicate.isNotUndefined(lastSide), side !== 0), side !== lastSide);
|
|
81
|
+
if (turned)
|
|
82
|
+
control = controlOf(from, to, -signed, peak);
|
|
83
|
+
if (Bool.and(side !== 0, Bool.not(turned)))
|
|
84
|
+
lastSide = side;
|
|
85
|
+
}
|
|
86
|
+
if (rotation === 0)
|
|
87
|
+
return (t) => ({ x: bezierAt(t, from.x, control.x, to.x), y: bezierAt(t, from.y, control.y, to.y) });
|
|
88
|
+
// The turn is measured from the straight turn between the tangents at the ends, so it's 0 at both.
|
|
89
|
+
const start = tangentAt(0, from, control, to);
|
|
90
|
+
const turn = wrap(-180, 180, tangentAt(1, from, control, to) - start);
|
|
91
|
+
return (t) => ({
|
|
92
|
+
x: bezierAt(t, from.x, control.x, to.x),
|
|
93
|
+
y: bezierAt(t, from.y, control.y, to.y),
|
|
94
|
+
rotate: wrap(-180, 180, tangentAt(t, from, control, to) - (start + turn * t)) * rotation,
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=Arc.js.map
|
package/dist/Arc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Arc.js","sourceRoot":"","sources":["../src/Arc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,sCAAsC;AACtC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AAwCjD,+DAA+D;AAC/D,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,KAAa,EAAU,EAAE;IAC/D,MAAM,KAAK,GAAG,GAAG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"./Reorder.ts";
|
|
4
|
+
/** How near a scroller's visible edge, in px, the pointer starts it scrolling: 50, as Motion's. */
|
|
5
|
+
export declare const THRESHOLD = 50;
|
|
6
|
+
/** The most a scroller scrolls in one update, in px, with the pointer at its edge: 25, as Motion's. */
|
|
7
|
+
export declare const MAX_SPEED = 25;
|
|
8
|
+
/** The edge a scroller is scrolling toward, between one `step` and the next. */
|
|
9
|
+
export interface State {
|
|
10
|
+
/** The edge: `"start"` at the top or left, `"end"` at the bottom or right. */
|
|
11
|
+
readonly edge: "start" | "end";
|
|
12
|
+
/**
|
|
13
|
+
* The scroll range when it started toward that edge: it never scrolls past it, so content that grows
|
|
14
|
+
* while it scrolls doesn't keep it scrolling.
|
|
15
|
+
*/
|
|
16
|
+
readonly limit: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* One update on one axis: how far to scroll, negative toward the start, and the state for the next.
|
|
20
|
+
* `pointer`, `start` and `end` are in the viewport's px: the pointer, and the scroller's visible edges,
|
|
21
|
+
* held within the viewport. Within `THRESHOLD` of an edge it scrolls `MAX_SPEED` × (1 − distance ÷
|
|
22
|
+
* `THRESHOLD`)² toward it.
|
|
23
|
+
* - **It starts** only while the pointer moves toward that edge (`velocity`), and reads `maxScroll()`
|
|
24
|
+
* then, the only time it's read.
|
|
25
|
+
* - **It keeps on** while the pointer stays near the edge, and stops at the end at the range it read.
|
|
26
|
+
* `scroll` is how far the scroller is scrolled.
|
|
27
|
+
* - **Away from both edges** there's no state.
|
|
28
|
+
*/
|
|
29
|
+
export declare const step: (state: Option.Option<State>, input: {
|
|
30
|
+
readonly pointer: number;
|
|
31
|
+
readonly start: number;
|
|
32
|
+
readonly end: number;
|
|
33
|
+
readonly velocity: number;
|
|
34
|
+
readonly scroll: number;
|
|
35
|
+
readonly maxScroll: () => number;
|
|
36
|
+
}) => {
|
|
37
|
+
readonly amount: number;
|
|
38
|
+
readonly state: Option.Option<State>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The axis Auto-scroll follows: a one-axis group's own, and in a grid the one the pointer moves faster
|
|
42
|
+
* on, `y` on a tie, as Motion's.
|
|
43
|
+
*/
|
|
44
|
+
export declare const axis: (axis: Reorder.Axis, velocity: Point.Point) => "x" | "y";
|
|
45
|
+
//# sourceMappingURL=AutoScroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoScroll.d.ts","sourceRoot":"","sources":["../src/AutoScroll.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAA;AAE5C,mGAAmG;AAEnG,eAAO,MAAM,SAAS,KAAK,CAAA;AAE3B,uGAAuG;AAEvG,eAAO,MAAM,SAAS,KAAK,CAAA;AAE3B,gFAAgF;AAChF,MAAM,WAAW,KAAK;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,KAAK,CAAA;IAC9B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;;GAUG;AAGH,eAAO,MAAM,IAAI,UACR,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SACpB;IACL,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,MAAM,CAAA;CACjC,KACA;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;CAqBjE,CAAA;AAyBD;;;GAGG;AAEH,eAAO,MAAM,IAAI,SAAU,OAAO,CAAC,IAAI,YAAY,KAAK,CAAC,KAAK,KAAG,GAAG,GAAG,GAMpE,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-scroll for a Reorder group, as Motion's: while an item is dragged near a scroller's edge, the
|
|
3
|
+
* scroller scrolls toward it, faster the nearer. This is its math, one update on one axis at a time; the
|
|
4
|
+
* binding measures the scroller, calls `step` at each move of the drag, and scrolls by what it says.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* import * as AutoScroll from "@wardic/core/AutoScroll"
|
|
8
|
+
*
|
|
9
|
+
* let state = Option.none<AutoScroll.State>()
|
|
10
|
+
* // At each move of the drag:
|
|
11
|
+
* const next = AutoScroll.step(state, {
|
|
12
|
+
* pointer: point.y,
|
|
13
|
+
* start: visible.top,
|
|
14
|
+
* end: visible.bottom,
|
|
15
|
+
* velocity: velocity.y,
|
|
16
|
+
* scroll: offset,
|
|
17
|
+
* maxScroll: () => range,
|
|
18
|
+
* })
|
|
19
|
+
* scrollBy(next.amount)
|
|
20
|
+
* state = next.state
|
|
21
|
+
*/
|
|
22
|
+
// ADR-0020: Motion's `autoScrollIfNeeded`, ported (Reorder/utils/auto-scroll.ts @ 16c6122). Effect-free
|
|
23
|
+
// and DOM-free. Tier 2 (ADR-0008): for binding and Environment authors.
|
|
24
|
+
import * as Bool from "effect/Boolean";
|
|
25
|
+
import * as Match from "effect/Match";
|
|
26
|
+
import * as Option from "effect/Option";
|
|
27
|
+
/** How near a scroller's visible edge, in px, the pointer starts it scrolling: 50, as Motion's. */
|
|
28
|
+
// Motion's `threshold` (Reorder/utils/auto-scroll.ts:1 @ 16c6122).
|
|
29
|
+
export const THRESHOLD = 50;
|
|
30
|
+
/** The most a scroller scrolls in one update, in px, with the pointer at its edge: 25, as Motion's. */
|
|
31
|
+
// Motion's `maxSpeed` (Reorder/utils/auto-scroll.ts:2 @ 16c6122).
|
|
32
|
+
export const MAX_SPEED = 25;
|
|
33
|
+
/**
|
|
34
|
+
* One update on one axis: how far to scroll, negative toward the start, and the state for the next.
|
|
35
|
+
* `pointer`, `start` and `end` are in the viewport's px: the pointer, and the scroller's visible edges,
|
|
36
|
+
* held within the viewport. Within `THRESHOLD` of an edge it scrolls `MAX_SPEED` × (1 − distance ÷
|
|
37
|
+
* `THRESHOLD`)² toward it.
|
|
38
|
+
* - **It starts** only while the pointer moves toward that edge (`velocity`), and reads `maxScroll()`
|
|
39
|
+
* then, the only time it's read.
|
|
40
|
+
* - **It keeps on** while the pointer stays near the edge, and stops at the end at the range it read.
|
|
41
|
+
* `scroll` is how far the scroller is scrolled.
|
|
42
|
+
* - **Away from both edges** there's no state.
|
|
43
|
+
*/
|
|
44
|
+
// Motion's algorithm, as a pure step:
|
|
45
|
+
// https://github.com/motiondivision/motion/blob/16c61222c4166bbef5ff6ab0051192faa79fa8c8/packages/framer-motion/src/components/Reorder/utils/auto-scroll.ts
|
|
46
|
+
export const step = (state, input) => {
|
|
47
|
+
/** A step that scrolls `amount` toward `next`'s edge, stopping at its limit. */
|
|
48
|
+
const scrollWithin = (next, amount) => Bool.match(Bool.and(amount > 0, input.scroll >= next.limit), {
|
|
49
|
+
onTrue: () => ({ amount: 0, state: Option.some(next) }),
|
|
50
|
+
onFalse: () => ({ amount, state: Option.some(next) }),
|
|
51
|
+
});
|
|
52
|
+
return Option.match(nearEdge(input.pointer - input.start, input.end - input.pointer), {
|
|
53
|
+
onNone: () => ({ amount: 0, state: Option.none() }),
|
|
54
|
+
onSome: ([edge, amount]) => Option.match(Option.filter(state, (current) => current.edge === edge), {
|
|
55
|
+
onSome: (current) => scrollWithin(current, amount),
|
|
56
|
+
// A start at an edge, or a switch to the other one, needs motion toward it; the limit
|
|
57
|
+
// is read once, at the start.
|
|
58
|
+
onNone: () => Bool.match(movingToward(edge, input.velocity), {
|
|
59
|
+
onTrue: () => scrollWithin({ edge, limit: input.maxScroll() }, amount),
|
|
60
|
+
onFalse: () => ({ amount: 0, state }),
|
|
61
|
+
}),
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
/** Scroll toward an edge within the threshold: faster the nearer, as the square of the closeness. */
|
|
66
|
+
const toward = (distance) => {
|
|
67
|
+
const intensity = 1 - distance / THRESHOLD;
|
|
68
|
+
return MAX_SPEED * intensity * intensity;
|
|
69
|
+
};
|
|
70
|
+
/** The edge the pointer is within {@link THRESHOLD} of, the start first, and the scroll toward it. */
|
|
71
|
+
const nearEdge = (fromStart, fromEnd) => Option.map(Option.liftPredicate(fromStart, isNear), (d) => ["start", -toward(d)]).pipe(Option.orElse(() => Option.map(Option.liftPredicate(fromEnd, isNear), (d) => ["end", toward(d)])));
|
|
72
|
+
/** Nearer an edge than {@link THRESHOLD}. */
|
|
73
|
+
const isNear = (distance) => distance < THRESHOLD;
|
|
74
|
+
/** A pointer moving toward `edge`. */
|
|
75
|
+
const movingToward = (edge, velocity) => Match.value(edge).pipe(Match.when("start", () => velocity < 0), Match.when("end", () => velocity > 0), Match.exhaustive);
|
|
76
|
+
/**
|
|
77
|
+
* The axis Auto-scroll follows: a one-axis group's own, and in a grid the one the pointer moves faster
|
|
78
|
+
* on, `y` on a tie, as Motion's.
|
|
79
|
+
*/
|
|
80
|
+
// Motion's `>` (Reorder/Item.tsx @ 16c6122).
|
|
81
|
+
export const axis = (axis, velocity) => Match.value(axis).pipe(Match.when("xy", () => Bool.match(Math.abs(velocity.x) > Math.abs(velocity.y), { onTrue: () => "x", onFalse: () => "y" })), Match.orElse((single) => single));
|
|
82
|
+
//# sourceMappingURL=AutoScroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoScroll.js","sourceRoot":"","sources":["../src/AutoScroll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wGAAwG;AACxG,wEAAwE;AACxE,OAAO,KAAK,IAAI,MAAM,gB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AAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAU,CAAC,CAAC,CAC3G,CAAA;AAEH,6CAA6C;AAC7C,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAW,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAA;AAElE,sCAAsC;AACtC,MAAM,YAAY,GAAG,CAAC,IAAqB,EAAE,QAAgB,EAAW,EAAE,CACxE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CACpB,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,EACvC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,EACrC,KAAK,CAAC,UAAU,CACjB,CAAA;AAEH;;;GAGG;AACH,6CAA6C;AAC7C,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAkB,EAAE,QAAqB,EAAa,EAAE,CAC3E,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CACpB,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,GAAc,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,GAAc,EAAE,CAAC,GAAG,EAAE,CAAC,CACzH,EACD,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CACjC,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a key starts, and where it returns: an element's Base value for a key is the first of its base
|
|
3
|
+
* target (its `animate`, else an inherited variant, else its `initial`), its `initial`, its own `style`,
|
|
4
|
+
* the values it started at, and its Own value, which its Environment reads off it. `of` finds it, and
|
|
5
|
+
* `start` finds where a key with no value yet starts. Pure, and shared by every binding and Environment.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* import * as BaseValue from "@wardic/core/BaseValue"
|
|
9
|
+
*
|
|
10
|
+
* BaseValue.of("opacity", { base: {}, initial: { opacity: 0 }, style: () => Option.none(), own: readOwn })
|
|
11
|
+
* // Option.some({ value: 0, source: "initial" }): where opacity returns once nothing sets it
|
|
12
|
+
*/
|
|
13
|
+
import * as Option from "effect/Option";
|
|
14
|
+
import type * as Values from "./Values.ts";
|
|
15
|
+
/**
|
|
16
|
+
* Each transform key's identity: the value that leaves an element untransformed, 1 for a scale and 0 for
|
|
17
|
+
* a translation, rotation or skew. A transform key's Own value is its identity, as Motion's is. These are
|
|
18
|
+
* the keys an Environment builds one `transform` from.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TRANSFORM_IDENTITY: Readonly<Record<string, number>>;
|
|
21
|
+
/** A transform key's identity (see {@link TRANSFORM_IDENTITY}), or `None` for any other key, prototype names included. */
|
|
22
|
+
export declare const transformIdentity: (key: string) => Option.Option<number>;
|
|
23
|
+
/** Which link of the chain a Base value came from. */
|
|
24
|
+
export type BaseSource = "base" | "initial" | "style" | "started" | "own";
|
|
25
|
+
/** A Base value and the link it came from. */
|
|
26
|
+
export interface BaseValue {
|
|
27
|
+
readonly value: number | string;
|
|
28
|
+
readonly source: BaseSource;
|
|
29
|
+
}
|
|
30
|
+
/** A per-key lookup: a value, or `None` for none. */
|
|
31
|
+
export type ValueLookup = (key: string) => Option.Option<number | string>;
|
|
32
|
+
/**
|
|
33
|
+
* The links of a key's chain, in order.
|
|
34
|
+
*
|
|
35
|
+
* - `base`: the base of the element's Override stack: its own `animate`, else an inherited variant,
|
|
36
|
+
* else its `initial`.
|
|
37
|
+
* - `initial`: the element's `initial` values, an inherited `initial` among them.
|
|
38
|
+
* - `style`: the element's user style for the key, coerced to the key's shape; a surface
|
|
39
|
+
* with no style link passes `() => Option.none()`.
|
|
40
|
+
* - `started`: the values an element with `initial={false}` started at, its `animate` at mount, as
|
|
41
|
+
* Motion's `baseTarget`; such an element passes an empty `initial`. Optional: left out, no value.
|
|
42
|
+
* - `own`: the element's Own value, read by its Environment; asked only when every earlier
|
|
43
|
+
* link misses.
|
|
44
|
+
*/
|
|
45
|
+
export interface BaseSources {
|
|
46
|
+
readonly base: Values.Values;
|
|
47
|
+
readonly initial: Values.Values;
|
|
48
|
+
readonly style: ValueLookup;
|
|
49
|
+
readonly started?: Values.Values | undefined;
|
|
50
|
+
readonly own: ValueLookup;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A key's Base value: where it returns once no layer sets it. The first link that has the
|
|
54
|
+
* key wins: `base`, then `initial`, then `style`, then `started`, then `own`. A later link
|
|
55
|
+
* is never asked once one hits. `None` means no link has it, so the key doesn't return (it
|
|
56
|
+
* stays where it is).
|
|
57
|
+
*/
|
|
58
|
+
export declare const of: (key: string, sources: BaseSources) => Option.Option<BaseValue>;
|
|
59
|
+
/**
|
|
60
|
+
* Where a key with no value yet starts: its `style` value, else its Own value. `None` when neither has
|
|
61
|
+
* one: start the key at its target, with no motion, as Motion does.
|
|
62
|
+
*/
|
|
63
|
+
export declare const start: (key: string, sources: Pick<BaseSources, "style" | "own">) => Option.Option<BaseValue>;
|
|
64
|
+
//# sourceMappingURL=BaseValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseValue.d.ts","sourceRoot":"","sources":["../src/BaseValue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAA;AAE1C;;;;GAIG;AAIH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB9D,CAAA;AAEF,0HAA0H;AAC1H,eAAO,MAAM,iBAAiB,Q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