ctx-core 6.7.1 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/all/atob/index.browser.js +12 -1
- package/all/btoa/index.browser.js +12 -1
- package/all/btoa/index.js +1 -1
- package/all/wanimato/index.browser.d.ts +1 -0
- package/all/wanimato/index.browser.js +1 -0
- package/all/wanimato/index.d.ts +15 -0
- package/all/wanimato/index.js +128 -0
- package/package.json +13 -1
- package/web_animation/index.browser.d.ts +1 -0
- package/web_animation/index.browser.js +1 -0
- package/web_animation/index.d.ts +2 -0
- package/web_animation/index.js +2 -0
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
The ctx-core library is a 0 dependency library with several exports to support general app development. This library has several exports to limit what is loaded into memory & to make tree-shaking less intensive. Some of the underlying functions are in multiple exports. The full list of exports is below. There is varying comprehensiveness & usage for these functions.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
5
|
## Development Monorepo
|
|
8
6
|
|
|
9
7
|
The [development monorepo](https://github.com/ctx-core/dev) used to have the ctx-core/ctx-core project name but has been moved to make room for this package.
|
|
@@ -117,3 +115,5 @@ The docs for rmemo are in https://github.com/ctx-core/rmemo. Since the source fo
|
|
|
117
115
|
## ctx-core/uri
|
|
118
116
|
|
|
119
117
|
## ctx-core/uuid
|
|
118
|
+
|
|
119
|
+
## ctx-core/web_animation
|
package/all/btoa/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.js'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { nullish } from '../nullish/index.js'
|
|
2
|
+
import type { sig_T } from '../rmemo/index.js'
|
|
3
|
+
export declare function wanimato__new<E extends Element>(
|
|
4
|
+
$:sig_T<wanimato_T|nullish>,
|
|
5
|
+
el:E,
|
|
6
|
+
animation_:(el:E)=>Animation
|
|
7
|
+
):wanimato_T
|
|
8
|
+
export type wanimato_T = {
|
|
9
|
+
animation:Animation
|
|
10
|
+
el:Element
|
|
11
|
+
is_play:boolean
|
|
12
|
+
is_finish:boolean
|
|
13
|
+
finish_currentTime:number|null
|
|
14
|
+
is_remove:boolean
|
|
15
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {sig_T<wanimato_T|nullish>}$
|
|
3
|
+
* @param {Element}el
|
|
4
|
+
* @param {(el:Element)=>Animation}animation_
|
|
5
|
+
* @returns {wanimato_T}
|
|
6
|
+
*/
|
|
7
|
+
export function wanimato__new($, el, animation_) {
|
|
8
|
+
if ($.val?.el === el) return $.val
|
|
9
|
+
let _animation = animation_(el)
|
|
10
|
+
_animation.addEventListener('finish', ()=>{
|
|
11
|
+
$._ = {
|
|
12
|
+
...$(),
|
|
13
|
+
is_finish: true,
|
|
14
|
+
finish_currentTime: $().animation.currentTime
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
_animation.addEventListener('remove', ()=>{
|
|
18
|
+
$._ = {
|
|
19
|
+
...$(),
|
|
20
|
+
is_remove: true
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
let play_state__ensure = ()=>{
|
|
24
|
+
if ($().is_play !== true || $().is_finish !== false) {
|
|
25
|
+
$._ = {
|
|
26
|
+
...$(),
|
|
27
|
+
is_play: true,
|
|
28
|
+
is_finish: false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
let begin_state__ensure__setTimeout = ()=>{
|
|
33
|
+
setTimeout(
|
|
34
|
+
()=>{
|
|
35
|
+
if ($().is_play !== !!_animation.currentTime || $().is_finish !== false) {
|
|
36
|
+
$._ = {
|
|
37
|
+
...$(),
|
|
38
|
+
is_play: !!_animation.currentTime,
|
|
39
|
+
is_finish: false,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
_animation.currentTime / -_animation.playbackRate)
|
|
44
|
+
}
|
|
45
|
+
let animation_mixin = {
|
|
46
|
+
play() {
|
|
47
|
+
if (_animation.playbackRate < 0) {
|
|
48
|
+
this.reverse()
|
|
49
|
+
} else {
|
|
50
|
+
_animation.play()
|
|
51
|
+
play_state__ensure()
|
|
52
|
+
if (_animation.playbackRate < 0) {
|
|
53
|
+
begin_state__ensure__setTimeout()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
reverse() {
|
|
58
|
+
_animation.reverse()
|
|
59
|
+
play_state__ensure()
|
|
60
|
+
begin_state__ensure__setTimeout()
|
|
61
|
+
},
|
|
62
|
+
finish() {
|
|
63
|
+
_animation.finish()
|
|
64
|
+
if ($().is_play !== false || $().is_finish !== !!_animation.currentTime) {
|
|
65
|
+
$._ = {
|
|
66
|
+
...$(),
|
|
67
|
+
is_play: false,
|
|
68
|
+
is_finish: !!_animation.currentTime
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
cancel() {
|
|
73
|
+
_animation.cancel()
|
|
74
|
+
if ($().is_play !== false || $().is_finish !== false) {
|
|
75
|
+
$._ = {
|
|
76
|
+
...$(),
|
|
77
|
+
is_play: false,
|
|
78
|
+
is_finish: false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
updatePlaybackRate(playbackRate) {
|
|
83
|
+
_animation.updatePlaybackRate(playbackRate)
|
|
84
|
+
_animation.ready
|
|
85
|
+
.then(()=>{
|
|
86
|
+
if (_animation.playbackRate < 0) {
|
|
87
|
+
begin_state__ensure__setTimeout()
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
},
|
|
91
|
+
addEventListener(...arg_a) {
|
|
92
|
+
_animation.addEventListener(...arg_a)
|
|
93
|
+
},
|
|
94
|
+
removeEventListener(...arg_a) {
|
|
95
|
+
_animation.removeEventListener(...arg_a)
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
el,
|
|
100
|
+
animation: new Proxy(_animation, {
|
|
101
|
+
get(_animation, /** @type {keyof Animation} */prop) {
|
|
102
|
+
return animation_mixin[prop] ?? _animation[prop]
|
|
103
|
+
},
|
|
104
|
+
set(
|
|
105
|
+
_animation,
|
|
106
|
+
/** @type {keyof Omit<Animation, 'finished'|'pending'|'playState'|'ready'|'replaceState'>} */
|
|
107
|
+
prop,
|
|
108
|
+
val
|
|
109
|
+
) {
|
|
110
|
+
if (prop === 'playbackRate') {
|
|
111
|
+
if (_animation[prop] === val) return false
|
|
112
|
+
_animation[prop] = val
|
|
113
|
+
if (val < 0) {
|
|
114
|
+
begin_state__ensure__setTimeout()
|
|
115
|
+
}
|
|
116
|
+
return true
|
|
117
|
+
}
|
|
118
|
+
if (_animation[prop] === val) return false
|
|
119
|
+
_animation[prop] = val
|
|
120
|
+
return true
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
is_play: true,
|
|
124
|
+
is_finish: false,
|
|
125
|
+
finish_currentTime: null,
|
|
126
|
+
is_remove: false,
|
|
127
|
+
}
|
|
128
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ctx-core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.0",
|
|
4
4
|
"description": "ctx-core core library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"types",
|
|
83
83
|
"uri",
|
|
84
84
|
"uuid",
|
|
85
|
+
"web_animation",
|
|
85
86
|
"package.json"
|
|
86
87
|
],
|
|
87
88
|
"exports": {
|
|
@@ -298,6 +299,10 @@
|
|
|
298
299
|
"browser": "./uuid/index.browser.js",
|
|
299
300
|
"default": "./uuid/index.js"
|
|
300
301
|
},
|
|
302
|
+
"./web_animation": {
|
|
303
|
+
"browser": "./web_animation/index.browser.js",
|
|
304
|
+
"default": "./web_animation/index.js"
|
|
305
|
+
},
|
|
301
306
|
"./package.json": "./package.json"
|
|
302
307
|
},
|
|
303
308
|
"devDependencies": {
|
|
@@ -419,6 +424,13 @@
|
|
|
419
424
|
"./uuid": "{ uuid__compact }"
|
|
420
425
|
},
|
|
421
426
|
"limit": "107 B"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"name": "web_animation",
|
|
430
|
+
"import": {
|
|
431
|
+
"./web_animation": "{ memo_, wanimato__new }"
|
|
432
|
+
},
|
|
433
|
+
"limit": "733 B"
|
|
422
434
|
}
|
|
423
435
|
],
|
|
424
436
|
"scripts": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../all/wanimato/index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../all/wanimato/index.js'
|