ziko 0.65.0 → 0.67.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/dist/ziko.cjs +61 -107
- package/dist/ziko.js +61 -107
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +61 -107
- package/package.json +2 -2
- package/src/events/custom-events-registry/click-away.js +0 -1
- package/src/exp-events/controller/index.js +41 -0
- package/src/exp-events/custom-events-registry/click-away.js +39 -0
- package/src/exp-events/custom-events-registry/index.js +3 -0
- package/src/exp-events/custom-events-registry/swipe.js +76 -0
- package/src/exp-events/custom-events-registry/view.js +74 -0
- package/src/exp-events/details-setter/index.js +4 -0
- package/src/exp-events/details-setter/key.js +14 -0
- package/src/exp-events/details-setter/mouse.js +35 -0
- package/src/exp-events/details-setter/pointer.js +35 -0
- package/src/exp-events/details-setter/touch.js +37 -0
- package/src/exp-events/index.js +1 -0
- package/src/hooks/index.d.ts +11 -0
- package/src/hooks/use-derived.d.ts +14 -0
- package/src/hooks/use-event-emitter.d.ts +46 -0
- package/src/hooks/use-favicon.d.ts +41 -0
- package/src/hooks/use-ipc.d.ts +12 -0
- package/src/hooks/use-media-query.d.ts +24 -0
- package/src/hooks/use-reactive.d.ts +14 -0
- package/src/hooks/use-root.d.ts +15 -0
- package/src/hooks/use-state.d.ts +25 -0
- package/src/hooks/use-storage.d.ts +47 -0
- package/src/hooks/use-thread.d.ts +33 -0
- package/src/hooks/use-title.d.ts +37 -0
- package/src/index.d.ts +5 -0
- package/src/math/complex/index.d.ts +54 -0
- package/src/math/functions/index.d.ts +140 -0
- package/src/math/functions/logic/index.d.ts +11 -0
- package/src/math/functions/mapfun/index.d.ts +87 -0
- package/src/math/functions/utils/index.d.ts +1 -0
- package/src/math/functions/utils/mapfun.d.ts +43 -0
- package/src/math/index.d.ts +5 -0
- package/src/time/clocks/clock.d.ts +28 -0
- package/src/time/clocks/index.d.ts +3 -0
- package/src/time/clocks/scheduler.d.ts +42 -0
- package/src/time/clocks/tick.d.ts +26 -0
- package/src/time/decorators/index.d.ts +9 -0
- package/src/time/delay/index.d.ts +12 -0
- package/src/time/ease/index.d.ts +103 -0
- package/src/time/index.d.ts +4 -0
- package/src/time/loop/index.d.ts +50 -0
- package/src/ui/constructors/UIElement.js +19 -93
- package/src/ui/constructors/UIElementCore.d.ts +59 -0
- package/src/ui/constructors/UIElementCore.js +0 -9
- package/src/ui/constructors/UINode.d.ts +11 -0
- package/src/ui/constructors/UINode.js +1 -1
- package/src/ui/{__methods__ → constructors/mixins}/dom.js +1 -1
- package/src/ui/{__methods__ → constructors/mixins}/events.js +3 -3
- package/src/ui/{__methods__ → constructors/mixins}/style.js +1 -1
- package/src/ui/{__methods__ → constructors/mixins}/utils/index.js +4 -4
- package/src/ui/web-component/index.d.ts +14 -0
- package/src/ui/web-component/index.js +2 -2
- package/README.dep.md +0 -137
- package/src/--reactivity-deprecated/events/Input.js +0 -62
- package/src/--reactivity-deprecated/events/ZikoEvent.js +0 -92
- package/src/--reactivity-deprecated/events/__note__ +0 -1
- package/src/--reactivity-deprecated/events/custom-event.js +0 -57
- package/src/--reactivity-deprecated/events/hash.js +0 -47
- package/src/--reactivity-deprecated/events/index.js +0 -12
- package/src/--reactivity-deprecated/events/media.js +0 -1
- package/src/--reactivity-deprecated/events/mouse.js +0 -233
- package/src/--reactivity-deprecated/events/swipe.js +0 -149
- package/src/--reactivity-deprecated/events/touch.js +0 -0
- package/src/--reactivity-deprecated/hooks/Contexte/index.js +0 -1
- package/src/--reactivity-deprecated/hooks/Contexte/useSuccesifKeys.js +0 -14
- package/src/--reactivity-deprecated/hooks/UI/index.js +0 -6
- package/src/--reactivity-deprecated/hooks/UI/useCssLink.js +0 -0
- package/src/--reactivity-deprecated/hooks/UI/useLinearGradient.js +0 -0
- package/src/--reactivity-deprecated/hooks/UI/useMediaQuery.js +0 -43
- package/src/--reactivity-deprecated/hooks/UI/useRadialGradient.js +0 -0
- package/src/--reactivity-deprecated/hooks/UI/useRoot.js +0 -39
- package/src/--reactivity-deprecated/hooks/UI/useStyle.js +0 -79
- package/src/--reactivity-deprecated/hooks/UI/useTheme.js +0 -62
- package/src/--reactivity-deprecated/hooks/head/_useCssText.js +0 -21
- package/src/--reactivity-deprecated/hooks/head/index.js +0 -5
- package/src/--reactivity-deprecated/hooks/head/useFavIcon.js +0 -38
- package/src/--reactivity-deprecated/hooks/head/useHead.js +0 -28
- package/src/--reactivity-deprecated/hooks/head/useMeta.js +0 -52
- package/src/--reactivity-deprecated/hooks/head/useTitle.js +0 -30
- package/src/--reactivity-deprecated/hooks/index.js +0 -8
- package/src/--reactivity-deprecated/hooks/todo.md +0 -26
- package/src/--reactivity-deprecated/idea +0 -1
- package/src/--reactivity-deprecated/index.js +0 -3
- package/src/--reactivity-deprecated/observer/attributes.js +0 -28
- package/src/--reactivity-deprecated/observer/children.js +0 -37
- package/src/--reactivity-deprecated/observer/index.js +0 -6
- package/src/--reactivity-deprecated/observer/intersection.js +0 -44
- package/src/--reactivity-deprecated/observer/mutation.js +0 -113
- package/src/--reactivity-deprecated/observer/resize.js +0 -47
- package/src/--reactivity-deprecated/observer/screen.js +0 -45
- package/src/--reactivity-deprecated/observer/screen.js.txt +0 -84
- package/src/--reactivity-deprecated/observer/screen.txt +0 -13
- package/src/--use-deprecated/index.js +0 -11
- package/src/--use-deprecated/use-channel.js.txt +0 -61
- package/src/--use-deprecated/use-event-emmiter.js.txt +0 -64
- package/src/--use-deprecated/use-favicon.js +0 -0
- package/src/--use-deprecated/use-link.js +0 -0
- package/src/--use-deprecated/use-meta.js +0 -0
- package/src/--use-deprecated/use-root.js +0 -77
- package/src/--use-deprecated/use-storage.js.txt +0 -73
- package/src/--use-deprecated/use-thread.js +0 -44
- package/src/--use-deprecated/use-title.js +0 -0
- package/src/ui/constructors/_m.js.txt +0 -96
- package/src/ui/constructors/style/index.js +0 -506
- /package/src/ui/{__methods__ → constructors/mixins}/attrs.js +0 -0
- /package/src/ui/{__methods__ → constructors/mixins}/index.js +0 -0
- /package/src/ui/{__methods__ → constructors/mixins}/indexing.js +0 -0
- /package/src/ui/{__methods__ → constructors/mixins}/lifecycle.js +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ZikoMutationObserver } from "./mutation";
|
|
2
|
-
class ZikoWatchChildren extends ZikoMutationObserver{
|
|
3
|
-
constructor(targetUIElement,callback){
|
|
4
|
-
super(targetUIElement,{ attributes: false, childList: true, subtree: false });
|
|
5
|
-
Object.assign(this.cache,{
|
|
6
|
-
observeCallback : (mutationsList, observer) =>{
|
|
7
|
-
for (const mutation of mutationsList) {
|
|
8
|
-
if(mutation.addedNodes)this.cache.lastMutation = {
|
|
9
|
-
type : "add",
|
|
10
|
-
item : this.target.find(n=>n.element === mutation.addedNodes[0])[0],
|
|
11
|
-
previous : this.target.find(n=>n.element === mutation.previousSibling)[0]
|
|
12
|
-
}
|
|
13
|
-
else if(mutation.addedNodes)this.cache.lastMutation = {
|
|
14
|
-
type : "remove",
|
|
15
|
-
item : this.target.find(n=>n.element === mutation.removedNodes[0])[0],
|
|
16
|
-
previous : this.target.find(n=>n.element === mutation.previousSibling)[0]
|
|
17
|
-
}
|
|
18
|
-
if (this.cache.streamingEnabled) this.cache.mutationHistory.children.push(this.cache.lastMutation)
|
|
19
|
-
}
|
|
20
|
-
if (this.callback) this.callback(mutationsList, observer);
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
this.cache.mutationHistory.children = []
|
|
24
|
-
if(callback)this.observe(callback);
|
|
25
|
-
}
|
|
26
|
-
get item(){
|
|
27
|
-
return this.cache.lastMutation.item;
|
|
28
|
-
}
|
|
29
|
-
get history(){
|
|
30
|
-
return this.cache.mutationHistory.children;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const watchChildren=(targetUIElement, callback)=>new ZikoWatchChildren(targetUIElement, callback);
|
|
35
|
-
export{
|
|
36
|
-
watchChildren
|
|
37
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
class ZikoIntersectionObserver{
|
|
2
|
-
constructor(UIElement,callback,{threshold=0,margin=0}={}){
|
|
3
|
-
this.target=UIElement;
|
|
4
|
-
this.config={
|
|
5
|
-
threshold,
|
|
6
|
-
margin
|
|
7
|
-
}
|
|
8
|
-
if(!globalThis.IntersectionObserver){
|
|
9
|
-
console.log("IntersectionObserver Not Supported")
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
this.observer=new IntersectionObserver((entries)=>{
|
|
13
|
-
this.entrie=entries[0];
|
|
14
|
-
callback(this)
|
|
15
|
-
},{
|
|
16
|
-
threshold:this.threshold,
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
get ratio(){
|
|
20
|
-
return this.entrie.intersectionRatio;
|
|
21
|
-
}
|
|
22
|
-
get isIntersecting(){
|
|
23
|
-
return this.entrie.isIntersecting;
|
|
24
|
-
}
|
|
25
|
-
setThreshould(threshold){
|
|
26
|
-
this.config.threshold=threshold;
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
setMargin(margin){
|
|
30
|
-
margin=(typeof margin === "number")?margin+"px":margin;
|
|
31
|
-
this.config.margin=margin;
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
start(){
|
|
35
|
-
this.observer.observe(this.target.element);
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
stop(){
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const watchIntersection=(UI,callback,config)=>new ZikoIntersectionObserver(UI,callback,config);
|
|
44
|
-
export {watchIntersection}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
class ZikoMutationObserver {
|
|
2
|
-
constructor(targetUIElement, options) {
|
|
3
|
-
this.target = targetUIElement;
|
|
4
|
-
this.observer = null;
|
|
5
|
-
this.cache = {
|
|
6
|
-
options : options || { attributes: true, childList: true, subtree: true },
|
|
7
|
-
streamingEnabled : true,
|
|
8
|
-
lastMutation : null,
|
|
9
|
-
mutationHistory : {
|
|
10
|
-
// attributes: [],
|
|
11
|
-
// childList: [],
|
|
12
|
-
// subtree: [],
|
|
13
|
-
},
|
|
14
|
-
}
|
|
15
|
-
// children to Items : a.items.filter(n=>n.element === a[0].element)
|
|
16
|
-
this.observeCallback = (mutationsList, observer) => {
|
|
17
|
-
// if(this.cache.lastUpdatedAttr){
|
|
18
|
-
// this.cache.lastUpdatedAttr = mutation.target.getAttribute(mutation.attributeName)
|
|
19
|
-
// }
|
|
20
|
-
if (this.cache.streamingEnabled) {
|
|
21
|
-
for (const mutation of mutationsList) {
|
|
22
|
-
switch(mutation.type){
|
|
23
|
-
case 'attributes':this.cache.mutationHistory.attributes.push(mutation.target.getAttribute(mutation.attributeName));break;
|
|
24
|
-
case 'childList':this.cache.mutationHistory.childList.push(mutation);break;
|
|
25
|
-
case 'subtree':this.cache.mutationHistory.subtree.push(mutation);break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (this.callback) {
|
|
30
|
-
this.callback(mutationsList, observer);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
observe(callback) {
|
|
36
|
-
if(!this.observer) {
|
|
37
|
-
if(!globalThis.MutationObserver) {
|
|
38
|
-
console.log("MutationObserver Nor Supported")
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
this.observer = new MutationObserver(this.cache.observeCallback);
|
|
42
|
-
this.observer.observe(this.target.element, this.cache.options);
|
|
43
|
-
// this.callback = ([e]) => callback.call(e,this.target);
|
|
44
|
-
this.callback = ([e]) => callback.call(e, this);
|
|
45
|
-
this.cache.streamingEnabled = true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
pause(options) {
|
|
50
|
-
if (this.observer) {
|
|
51
|
-
this.observer.disconnect();
|
|
52
|
-
if (options) {
|
|
53
|
-
this.observer.observe(this.target, options);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
reset(options) {
|
|
59
|
-
if (this.observer) {
|
|
60
|
-
this.observer.disconnect();
|
|
61
|
-
this.observer.observe(this.target, options || this.cache.options);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
clear() {
|
|
66
|
-
if (this.observer) {
|
|
67
|
-
this.observer.disconnect();
|
|
68
|
-
this.observer = null;
|
|
69
|
-
this.cache.mutationHistory = {
|
|
70
|
-
attributes: [],
|
|
71
|
-
childList: [],
|
|
72
|
-
subtree: [],
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
this.cache.streamingEnabled = false;
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
getMutationHistory() {
|
|
80
|
-
return this.cache.mutationHistory;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
enableStreaming() {
|
|
84
|
-
this.cache.streamingEnabled = true;
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
disableStreaming() {
|
|
89
|
-
this.cache.streamingEnabled = false;
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const watch=(targetUIElement,options={},callback=null)=>{
|
|
97
|
-
const Observer= new ZikoMutationObserver(targetUIElement,options);
|
|
98
|
-
if(callback)Observer.observe(callback);
|
|
99
|
-
return Observer
|
|
100
|
-
}
|
|
101
|
-
// const watchAttr = (targetUIElement, callback = null) => {
|
|
102
|
-
// const options = { attributes: true, childList: false, subtree: false };
|
|
103
|
-
// return watch(targetUIElement, options, ([e])=>callback.call(e,targetUIElement));
|
|
104
|
-
// };
|
|
105
|
-
// const watchAttr = (targetUIElement, callback = null) => {
|
|
106
|
-
// const options = { attributes: true, childList: false, subtree: false };
|
|
107
|
-
// return watch(targetUIElement, options, callback);
|
|
108
|
-
// };
|
|
109
|
-
|
|
110
|
-
export {
|
|
111
|
-
ZikoMutationObserver,
|
|
112
|
-
watch,
|
|
113
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
class ZikoResizeObserver{
|
|
2
|
-
constructor(UIElement,callback){
|
|
3
|
-
this.target=UIElement;
|
|
4
|
-
this.contentRect=null;
|
|
5
|
-
this.observer=new ResizeObserver(()=>{
|
|
6
|
-
callback(this)
|
|
7
|
-
})
|
|
8
|
-
}
|
|
9
|
-
get BoundingRect(){
|
|
10
|
-
return this.target.element.getBoundingClientRect();
|
|
11
|
-
}
|
|
12
|
-
get width(){
|
|
13
|
-
return this.BoundingRect.width;
|
|
14
|
-
}
|
|
15
|
-
get height(){
|
|
16
|
-
return this.BoundingRect.height;
|
|
17
|
-
}
|
|
18
|
-
get top(){
|
|
19
|
-
return this.BoundingRect.top;
|
|
20
|
-
}
|
|
21
|
-
get bottom(){
|
|
22
|
-
return this.BoundingRect.bottom;
|
|
23
|
-
}
|
|
24
|
-
get right(){
|
|
25
|
-
return this.BoundingRect.right;
|
|
26
|
-
}
|
|
27
|
-
get left(){
|
|
28
|
-
return this.BoundingRect.left;
|
|
29
|
-
}
|
|
30
|
-
get x(){
|
|
31
|
-
return this.BoundingRect.x;
|
|
32
|
-
}
|
|
33
|
-
get y(){
|
|
34
|
-
return this.BoundingRect.y;
|
|
35
|
-
}
|
|
36
|
-
start(){
|
|
37
|
-
this.observer.observe(this.target.element);
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
stop(){
|
|
41
|
-
this.observer.unobserve(this.target.element);
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const watchSize=(UI,callback)=>new ZikoResizeObserver(UI,callback)
|
|
47
|
-
export {watchSize}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { map } from "../../math/utils/index.js"
|
|
2
|
-
class ZikoScreenObserver {
|
|
3
|
-
constructor(callback=e=>console.log({x:e.x,y:e.y})) {
|
|
4
|
-
this.cache={};
|
|
5
|
-
this.previousX = globalThis?.screenX;
|
|
6
|
-
this.previousY = globalThis?.screenY;
|
|
7
|
-
}
|
|
8
|
-
update(){
|
|
9
|
-
Object.assign(this.cache,{
|
|
10
|
-
screenXLeft : globalThis?.screenX, // CORRECT
|
|
11
|
-
screenXRight : globalThis?.screen.availWidth - globalThis?.screenX, // CORRECT
|
|
12
|
-
screenYTop : globalThis?.screenY, // CORRECT
|
|
13
|
-
screenYBottom : globalThis?.screen.availHeight - globalThis?.screenY - globalThis?.outerHeight, // TO TEST
|
|
14
|
-
screenCenterX : globalThis?.screen.availWidth/2, // CORRECT
|
|
15
|
-
screenCenterY : globalThis?.screen.availHeight/2,// CORRECT
|
|
16
|
-
windowCenterX : globalThis?.outerWidth/2+globalThis?.screenX, // CORRECT
|
|
17
|
-
windowCenterY : globalThis?.outerHeight/2+ globalThis?.screenY, // FALSE
|
|
18
|
-
deltaCenterX : globalThis?.screen.availWidth/2-globalThis?.outerWidth/2+globalThis?.screenX, // CORRECT
|
|
19
|
-
deltaCenterY : null //
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
get x0(){
|
|
23
|
-
return map(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
24
|
-
}
|
|
25
|
-
get y0(){
|
|
26
|
-
return - map(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
27
|
-
}
|
|
28
|
-
get x1(){
|
|
29
|
-
return map(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
30
|
-
}
|
|
31
|
-
get y1(){
|
|
32
|
-
return - map(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
33
|
-
}
|
|
34
|
-
get cx(){
|
|
35
|
-
return map(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
36
|
-
}
|
|
37
|
-
get cy(){
|
|
38
|
-
return - map(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const watchScreen=(callback)=>new ZikoScreenObserver(callback);
|
|
43
|
-
export{
|
|
44
|
-
watchScreen
|
|
45
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { useTimeLoop } from "../../Time";
|
|
2
|
-
import {
|
|
3
|
-
map,
|
|
4
|
-
complex,
|
|
5
|
-
} from "../../Math";
|
|
6
|
-
class ZikoScreenObserver {
|
|
7
|
-
constructor(callback=e=>console.log({x:e.x,y:e.y})) {
|
|
8
|
-
this.previousX = globalThis?.screenX;
|
|
9
|
-
this.previousY = globalThis?.screenY;
|
|
10
|
-
this.view=[-1,-1,1,1];
|
|
11
|
-
this.start(callback);
|
|
12
|
-
}
|
|
13
|
-
get xMin(){
|
|
14
|
-
return this.view[0];
|
|
15
|
-
}
|
|
16
|
-
get yMin(){
|
|
17
|
-
return this.view[1];
|
|
18
|
-
}
|
|
19
|
-
get xMax(){
|
|
20
|
-
return this.view[2];
|
|
21
|
-
}
|
|
22
|
-
get yMax(){
|
|
23
|
-
return this.view[3];
|
|
24
|
-
}
|
|
25
|
-
get x(){
|
|
26
|
-
return globalThis?.screenX;
|
|
27
|
-
}
|
|
28
|
-
get y(){
|
|
29
|
-
return globalThis?.screenY;
|
|
30
|
-
}
|
|
31
|
-
get scx(){
|
|
32
|
-
return screen.availWidth/2;
|
|
33
|
-
}
|
|
34
|
-
get scy(){
|
|
35
|
-
return screen.availHeight/2;
|
|
36
|
-
}
|
|
37
|
-
get wcx(){
|
|
38
|
-
return screenX+globalThis?.innerWidth/2;
|
|
39
|
-
}
|
|
40
|
-
get wcx_v(){
|
|
41
|
-
return map(this.wcx,0,screen.availWidth,this.view[0],this.view[2]);
|
|
42
|
-
}
|
|
43
|
-
get wcy(){
|
|
44
|
-
return screenY+globalThis?.innerHeight/2;
|
|
45
|
-
}
|
|
46
|
-
get wcy_v(){
|
|
47
|
-
return -map(this.wcy,0,screen.availHeight,this.view[1],this.view[3]);
|
|
48
|
-
}
|
|
49
|
-
get dx(){
|
|
50
|
-
return map(this.x,0,screen.availWidth,this.xMin,this.xMax);
|
|
51
|
-
}
|
|
52
|
-
get dy(){
|
|
53
|
-
return map(this.y,0,screen.availHeight,this.yMin,this.yMax);
|
|
54
|
-
}
|
|
55
|
-
start(callback){
|
|
56
|
-
this.loop = useTimeLoop(()=>{
|
|
57
|
-
let currentX = globalThis?.screenX;
|
|
58
|
-
let currentY = globalThis?.screenY;
|
|
59
|
-
if (this.previousX !== currentX || this.previousY !== currentY) {
|
|
60
|
-
callback(this)
|
|
61
|
-
this.previousX = currentX;
|
|
62
|
-
this.previousY = currentY;
|
|
63
|
-
}
|
|
64
|
-
},1000/60,0,Infinity,true);
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const watchScreen=(callback)=>new ZikoScreenObserver(callback);
|
|
69
|
-
// globalThis.watchScreen=watchScreen;
|
|
70
|
-
export{
|
|
71
|
-
watchScreen
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/*
|
|
75
|
-
a=ul("x","y","dx","dy","wcx","wxy")
|
|
76
|
-
watchScreen(e=>{
|
|
77
|
-
a[0].setValue("x : "+e.x)
|
|
78
|
-
a[1].setValue("y : "+e.y)
|
|
79
|
-
a[2].setValue("dx : "+e.dx)
|
|
80
|
-
a[3].setValue("dy : "+e.dy)
|
|
81
|
-
a[4].setValue("wCx : "+e.wcx)
|
|
82
|
-
a[5].setValue("wCy : "+e.wcy)
|
|
83
|
-
})
|
|
84
|
-
*/
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
screenXLeft = screenX
|
|
2
|
-
screenXRight = screen.availWidth - screenX
|
|
3
|
-
|
|
4
|
-
screenYTop = screenY
|
|
5
|
-
screenYBottom = screen.availHeight - screenY - outerHeight
|
|
6
|
-
|
|
7
|
-
screenCenterX = screen.availWidth/2;
|
|
8
|
-
screenCenterX = screen.availHeight/2;
|
|
9
|
-
|
|
10
|
-
windowCenterX = outerWidth/2+screenX;
|
|
11
|
-
windowCenterX = outerHeight/2+0;
|
|
12
|
-
|
|
13
|
-
deltaCenterX = screenCenterX-windowCenterX
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// export * from './use-channel.js';
|
|
2
|
-
// export * from './use-event-emmiter.js';
|
|
3
|
-
export * from './use-thread.js';
|
|
4
|
-
|
|
5
|
-
export * from './use-root.js';
|
|
6
|
-
// export * from './use-title.js'
|
|
7
|
-
export * from './use-favicon.js'
|
|
8
|
-
// export * from './use-link.js'
|
|
9
|
-
// export * from 'use-meta.js'
|
|
10
|
-
|
|
11
|
-
// export * from './use-storage.js'
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Random } from "../math/random/index.js";
|
|
2
|
-
|
|
3
|
-
class UseChannel {
|
|
4
|
-
constructor(name = "") {
|
|
5
|
-
this.channel = new BroadcastChannel(name);
|
|
6
|
-
this.eventData = new Map();
|
|
7
|
-
this.handlers = new Map();
|
|
8
|
-
this.uuid = "ziko-channel:" + Random.string(10);
|
|
9
|
-
this.subscribers = new Set([this.uuid]);
|
|
10
|
-
|
|
11
|
-
this.channel.addEventListener("message", (e) => {
|
|
12
|
-
const { last_sent_event, userId, eventData } = e.data;
|
|
13
|
-
|
|
14
|
-
// ignore own events
|
|
15
|
-
if (userId === this.uuid) return;
|
|
16
|
-
|
|
17
|
-
this.subscribers.add(userId);
|
|
18
|
-
|
|
19
|
-
// sync data
|
|
20
|
-
this.eventData = new Map(eventData);
|
|
21
|
-
|
|
22
|
-
const data = this.eventData.get(last_sent_event);
|
|
23
|
-
const handlers = this.handlers.get(last_sent_event);
|
|
24
|
-
|
|
25
|
-
if (handlers) {
|
|
26
|
-
handlers.forEach(fn => fn(data));
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
emit(event, data) {
|
|
32
|
-
this.eventData.set(event, data);
|
|
33
|
-
|
|
34
|
-
this.channel.postMessage({
|
|
35
|
-
eventData: this.eventData,
|
|
36
|
-
last_sent_event: event,
|
|
37
|
-
userId: this.uuid
|
|
38
|
-
});
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
on(event, handler = console.log) {
|
|
43
|
-
if (!this.handlers.has(event)) {
|
|
44
|
-
this.handlers.set(event, []);
|
|
45
|
-
}
|
|
46
|
-
this.handlers.get(event).push(handler);
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
close() {
|
|
51
|
-
this.channel.close();
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get broadcast() {
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const useChannel = (name) => new UseChannel(name);
|
|
61
|
-
export { useChannel };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
class UseEventEmitter {
|
|
2
|
-
constructor(maxListeners = 10) {
|
|
3
|
-
this.events = {};
|
|
4
|
-
this.maxListeners = maxListeners;
|
|
5
|
-
}
|
|
6
|
-
on(event, listener) {
|
|
7
|
-
if (!this.events[event]) {
|
|
8
|
-
this.events[event] = [];
|
|
9
|
-
}
|
|
10
|
-
this.events[event].push(listener);
|
|
11
|
-
if (this.events[event].length > this.maxListeners) {
|
|
12
|
-
console.warn(`Warning: Possible memory leak. Event '${event}' has more than ${this.maxListeners} listeners.`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
once(event, listener) {
|
|
16
|
-
const onceListener = (data) => {
|
|
17
|
-
this.off(event, onceListener); // Remove the listener after it's been called
|
|
18
|
-
listener(data);
|
|
19
|
-
};
|
|
20
|
-
this.on(event, onceListener);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
off(event, listener) {
|
|
24
|
-
const listeners = this.events[event];
|
|
25
|
-
if (listeners) {
|
|
26
|
-
const index = listeners.indexOf(listener);
|
|
27
|
-
if (index !== -1) {
|
|
28
|
-
listeners.splice(index, 1);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
emit(event, data) {
|
|
34
|
-
const listeners = this.events[event];
|
|
35
|
-
if (listeners) {
|
|
36
|
-
listeners.forEach(listener => {
|
|
37
|
-
listener(data);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
clear(event) {
|
|
43
|
-
if (event) {
|
|
44
|
-
delete this.events[event];
|
|
45
|
-
} else {
|
|
46
|
-
this.events = {};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
setMaxListener(event, max) {
|
|
51
|
-
this.maxListeners = max;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
removeAllListeners(event) {
|
|
55
|
-
if (event) {
|
|
56
|
-
this.events[event] = [];
|
|
57
|
-
} else {
|
|
58
|
-
this.events = {};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const useEventEmitter=(maxListeners)=>new UseEventEmitter(maxListeners)
|
|
64
|
-
export{useEventEmitter}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
class UseRoot {
|
|
2
|
-
constructor(PropsMap, {namespace = 'Ziko', register, ValidateCssProps = false} = {}){
|
|
3
|
-
this.currentPropsMap = PropsMap;
|
|
4
|
-
this.namespace = namespace;
|
|
5
|
-
this.ValidateCssProps = ValidateCssProps;
|
|
6
|
-
// this.pairs = {};
|
|
7
|
-
// this.#maintain()
|
|
8
|
-
this.use(PropsMap)
|
|
9
|
-
}
|
|
10
|
-
use(PropsMap){
|
|
11
|
-
if(this.ValidateCssProps) ValidateCssProps(PropsMap)
|
|
12
|
-
this.currentPropsMap = PropsMap;
|
|
13
|
-
this.#maintain()
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
#maintain(){
|
|
17
|
-
const root = globalThis?.document?.documentElement?.style
|
|
18
|
-
for(let prop in this.currentPropsMap){
|
|
19
|
-
const cssProp = this.namespace ? `--${this.namespace}-${prop}` : `--${prop}`
|
|
20
|
-
root.setProperty(
|
|
21
|
-
cssProp,
|
|
22
|
-
this.currentPropsMap[prop]
|
|
23
|
-
);
|
|
24
|
-
// Object.assign(this.pairs, {
|
|
25
|
-
// [prop] : `var(--${this.namespace}-${prop})`
|
|
26
|
-
// })
|
|
27
|
-
Object.defineProperty(this, prop, {
|
|
28
|
-
value: `var(${cssProp})`,
|
|
29
|
-
writable: true,
|
|
30
|
-
configurable: true,
|
|
31
|
-
enumerable: false
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function ValidateCssProps(PropsMap){
|
|
38
|
-
const validProps = new Set(Object.keys(document.documentElement.style));
|
|
39
|
-
for (let key in PropsMap) {
|
|
40
|
-
if (!validProps.has(key)) {
|
|
41
|
-
throw new Error(`Invalid CSS property: "${key}"`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const useRoot = (PropsMap, {namespace, register, ValidateCssProps} = {}) => new UseRoot(PropsMap, {namespace, register, ValidateCssProps});
|
|
47
|
-
|
|
48
|
-
export{
|
|
49
|
-
UseRoot,
|
|
50
|
-
useRoot
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Usage
|
|
54
|
-
|
|
55
|
-
/*
|
|
56
|
-
const Styles = {
|
|
57
|
-
S1 : {
|
|
58
|
-
background : 'white',
|
|
59
|
-
color : 'darkblue'
|
|
60
|
-
border : '2px darkblue solid"'
|
|
61
|
-
},
|
|
62
|
-
S2 : {
|
|
63
|
-
background : 'darkblue',
|
|
64
|
-
color : 'white'
|
|
65
|
-
border : '2px green solid"'
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const {use, border, background, color} = useRoot(Style.S1)
|
|
69
|
-
|
|
70
|
-
tags.p("Test useRoot ").style({
|
|
71
|
-
border,
|
|
72
|
-
color,
|
|
73
|
-
background,
|
|
74
|
-
padding : '10px'
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
*/
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// To do : remove old items
|
|
2
|
-
import { useChannel } from "./use-channel.js";
|
|
3
|
-
class UseStorage{
|
|
4
|
-
constructor(storage, globalKey, initialValue){
|
|
5
|
-
this.cache={
|
|
6
|
-
storage,
|
|
7
|
-
globalKey,
|
|
8
|
-
channel:useChannel(`Ziko:useStorage-${globalKey}`),
|
|
9
|
-
oldItemKeys:new Set()
|
|
10
|
-
}
|
|
11
|
-
this.#init(initialValue);
|
|
12
|
-
this.#maintain();
|
|
13
|
-
}
|
|
14
|
-
get items(){
|
|
15
|
-
return JSON.parse(this.cache.storage[this.cache.globalKey]??null);
|
|
16
|
-
}
|
|
17
|
-
#maintain() {
|
|
18
|
-
for(let i in this.items)Object.assign(this, { [[i]]: this.items[i] });
|
|
19
|
-
}
|
|
20
|
-
#init(initialValue){
|
|
21
|
-
this.cache.channel=useChannel(`Ziko:useStorage-${this.cache.globalKey}`);
|
|
22
|
-
this.cache.channel.on("Ziko-Storage-Updated",()=>this.#maintain());
|
|
23
|
-
if(!initialValue)return;
|
|
24
|
-
if(this.cache.storage[this.cache.globalKey]){
|
|
25
|
-
Object.keys(this.items).forEach(key=>this.cache.oldItemKeys.add(key));
|
|
26
|
-
// console.group("Ziko:useStorage")
|
|
27
|
-
// console.warn(`Storage key '${this.cache.globalKey}' already exists. we will not overwrite it.`);
|
|
28
|
-
// console.info(`%cWe'll keep the existing data.`,"background-color:#2222dd; color:gold;");
|
|
29
|
-
// console.group("")
|
|
30
|
-
}
|
|
31
|
-
else this.set(initialValue);
|
|
32
|
-
}
|
|
33
|
-
set(data){
|
|
34
|
-
this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(data));
|
|
35
|
-
this.cache.channel.emit("Ziko-Storage-Updated",{});
|
|
36
|
-
Object.keys(data).forEach(key=>this.cache.oldItemKeys.add(key));
|
|
37
|
-
this.#maintain();
|
|
38
|
-
return this
|
|
39
|
-
}
|
|
40
|
-
add(data){
|
|
41
|
-
const db={
|
|
42
|
-
...this.items,
|
|
43
|
-
...data
|
|
44
|
-
}
|
|
45
|
-
this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(db));
|
|
46
|
-
this.#maintain();
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
remove(...keys){
|
|
50
|
-
const db={...this.items};
|
|
51
|
-
for(let i=0;i<keys.length;i++){
|
|
52
|
-
delete db[keys[i]];
|
|
53
|
-
delete this[keys[i]];
|
|
54
|
-
}
|
|
55
|
-
this.set(db);
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
get(key){
|
|
59
|
-
return this.items[key];
|
|
60
|
-
}
|
|
61
|
-
clear(){
|
|
62
|
-
this.cache.storage.removeItem(this.cache.globalKey);
|
|
63
|
-
this.#maintain();
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
const useLocaleStorage=(key,initialValue)=>new UseStorage(localStorage,key,initialValue);
|
|
69
|
-
const useSessionStorage=(key,initialValue)=>new UseStorage(sessionStorage,key,initialValue);
|
|
70
|
-
export{
|
|
71
|
-
useLocaleStorage,
|
|
72
|
-
useSessionStorage
|
|
73
|
-
}
|