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,149 +0,0 @@
|
|
|
1
|
-
import { ZikoEvent, EVENT_CONTROLLER } from "./ZikoEvent.js";
|
|
2
|
-
import { norm, lerp, abs, sign } from "../../math/index.js";
|
|
3
|
-
class ZikoEventSwipe extends ZikoEvent {
|
|
4
|
-
constructor(target, width_threshold = 0.3, height_threshold = 0.3) {
|
|
5
|
-
super(target);
|
|
6
|
-
const { removeListener, setWidthThreshold, setHeightThreshold } = init_swipe_event_handler(
|
|
7
|
-
this.target?.element,
|
|
8
|
-
width_threshold,
|
|
9
|
-
height_threshold,
|
|
10
|
-
this.target.width,
|
|
11
|
-
this.target.height,
|
|
12
|
-
);
|
|
13
|
-
this.cache = {
|
|
14
|
-
width_threshold,
|
|
15
|
-
height_threshold,
|
|
16
|
-
removeListener,
|
|
17
|
-
setWidthThreshold,
|
|
18
|
-
setHeightThreshold,
|
|
19
|
-
legacyTouchAction : globalThis?.document?.body?.style?.touchAction,
|
|
20
|
-
prefixe: "",
|
|
21
|
-
preventDefault: {
|
|
22
|
-
swipe: false,
|
|
23
|
-
},
|
|
24
|
-
paused: {
|
|
25
|
-
swipe: false,
|
|
26
|
-
},
|
|
27
|
-
stream: {
|
|
28
|
-
enabled: {
|
|
29
|
-
swipe: false,
|
|
30
|
-
},
|
|
31
|
-
clear: {
|
|
32
|
-
swipe: false,
|
|
33
|
-
},
|
|
34
|
-
history: {
|
|
35
|
-
swipe: [],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
callbacks: {
|
|
39
|
-
swipe: [],
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
this.__controller = {
|
|
43
|
-
swipe: swipe_controller.bind(this),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
onSwipe(...callbacks) {
|
|
47
|
-
Object.assign(globalThis?.document?.body?.style,{touchAction:"none"})
|
|
48
|
-
this.__onEvent("swipe", {}, ...callbacks);
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
updateThresholds(width_threshold = this.cache.width_threshold, height_threshold = this.cache.height_threshold) {
|
|
52
|
-
if (width_threshold !== undefined) {
|
|
53
|
-
this.cache.setWidthThreshold(width_threshold);
|
|
54
|
-
}
|
|
55
|
-
if (height_threshold !== undefined) {
|
|
56
|
-
this.cache.setHeightThreshold(height_threshold);
|
|
57
|
-
}
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
destroy() {
|
|
61
|
-
this.cache.removeListener();
|
|
62
|
-
Object.assign(globalThis?.document?.body?.style,{touchAction:this.cache.legacyTouchAction})
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function init_swipe_event_handler(element, width_threshold = 0.50, height_threshold = 0.5, width, height) {
|
|
67
|
-
let Interpolated_width_threshold = lerp(width_threshold, 0, width);
|
|
68
|
-
let Interpolated_height_threshold = lerp(height_threshold, 0, height);
|
|
69
|
-
let startX = 0, startY = 0, endX = 0, endY = 0;
|
|
70
|
-
const pointerDownHandler = (event) => {
|
|
71
|
-
startX = event.clientX;
|
|
72
|
-
startY = event.clientY;
|
|
73
|
-
};
|
|
74
|
-
const pointerUpHandler = (event) => {
|
|
75
|
-
endX = event.clientX;
|
|
76
|
-
endY = event.clientY;
|
|
77
|
-
handleSwipe();
|
|
78
|
-
};
|
|
79
|
-
element?.addEventListener('pointerdown', pointerDownHandler);
|
|
80
|
-
element?.addEventListener('pointerup', pointerUpHandler);
|
|
81
|
-
function handleSwipe() {
|
|
82
|
-
const deltaX = endX - startX;
|
|
83
|
-
const deltaY = endY - startY;
|
|
84
|
-
if (Math.abs(deltaX) > Interpolated_width_threshold || Math.abs(deltaY) > Interpolated_height_threshold) {
|
|
85
|
-
dispatchSwipeEvent(deltaX, deltaY);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function dispatchSwipeEvent(deltaX, deltaY) {
|
|
89
|
-
const event = globalThis?.CustomEvent ? new CustomEvent('swipe', {
|
|
90
|
-
detail: {
|
|
91
|
-
deltaX: abs(deltaX) < Interpolated_width_threshold ? 0 : sign(deltaX) * norm(abs(deltaX), 0, width),
|
|
92
|
-
deltaY: abs(deltaY) < Interpolated_height_threshold ? 0 : sign(deltaY) * norm(abs(deltaY), 0, height),
|
|
93
|
-
direction: {
|
|
94
|
-
x : abs(deltaX) < Interpolated_width_threshold ? "none" : deltaX > 0 ? "right" : "left",
|
|
95
|
-
y : abs(deltaY) < Interpolated_height_threshold ? "none" : deltaY > 0 ? 'down' : 'up',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
}) : null;
|
|
99
|
-
element?.dispatchEvent(event);
|
|
100
|
-
}
|
|
101
|
-
function setWidthThreshold(new_width_threshold) {
|
|
102
|
-
Interpolated_width_threshold = lerp(new_width_threshold, 0, width);
|
|
103
|
-
}
|
|
104
|
-
function setHeightThreshold(new_height_threshold) {
|
|
105
|
-
Interpolated_height_threshold = lerp(new_height_threshold, 0, height);
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
removeListener() {
|
|
109
|
-
element?.removeEventListener('pointerdown', pointerDownHandler);
|
|
110
|
-
element?.removeEventListener('pointerup', pointerUpHandler);
|
|
111
|
-
console.log('Swipe event listeners removed');
|
|
112
|
-
},
|
|
113
|
-
setWidthThreshold,
|
|
114
|
-
setHeightThreshold,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function swipe_controller(e) {
|
|
118
|
-
EVENT_CONTROLLER.call(this, e, "swipe", null, null);
|
|
119
|
-
}
|
|
120
|
-
const useSwipeEvent = (target, width_threshold, height_threshold) => new ZikoEventSwipe(target, width_threshold, height_threshold);
|
|
121
|
-
export{
|
|
122
|
-
useSwipeEvent,
|
|
123
|
-
ZikoEventSwipe
|
|
124
|
-
}
|
|
125
|
-
/*
|
|
126
|
-
a=p("ALLL").size("300px","300px").style({background:"red",userSelect:"none"})
|
|
127
|
-
t=text("")
|
|
128
|
-
ev=useSwipeEvent(a, .1, .3)
|
|
129
|
-
ev.onSwipe(e=>{
|
|
130
|
-
// t.setValue(`
|
|
131
|
-
// vertical direction : ${e.event.detail.direction.y}
|
|
132
|
-
// horizontal direction : ${e.event.detail.direction.x}
|
|
133
|
-
// deltaX : ${e.event.detail.deltaX}
|
|
134
|
-
// deltaY : ${e.event.detail.deltaY}
|
|
135
|
-
// `)
|
|
136
|
-
e.target.st.translate(e.event.detail.deltaX * 200, e.event.detail.deltaY * 200,0, 500)
|
|
137
|
-
})
|
|
138
|
-
*/
|
|
139
|
-
/*
|
|
140
|
-
a=p("ALLL")
|
|
141
|
-
.size("300px","300px")
|
|
142
|
-
.style({background:"red",userSelect:"none"})
|
|
143
|
-
.onSwipe(
|
|
144
|
-
.3,
|
|
145
|
-
.3,
|
|
146
|
-
e=>{
|
|
147
|
-
e.target.st.translate(e.event.detail.deltaX * 200, e.event.detail.deltaY * 200,0, 500)
|
|
148
|
-
})
|
|
149
|
-
*/
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./useSuccesifKeys"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const useSuccesifKeys=(self,keys=[],callback=()=>{})=>{
|
|
2
|
-
self.cache.stream.enabled.down=true;
|
|
3
|
-
const length=keys.length;
|
|
4
|
-
const LastKeysDown=self.cache.stream.history.down.slice(-length).map(n=>n.key);
|
|
5
|
-
|
|
6
|
-
if(keys.join("")===LastKeysDown.join("")){
|
|
7
|
-
self.event.preventDefault();
|
|
8
|
-
callback.call(self,self);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
useSuccesifKeys
|
|
14
|
-
}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
[
|
|
3
|
-
{
|
|
4
|
-
query: '(min-width: 600px)',
|
|
5
|
-
callback: () => console.log(1)
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
query: '(max-width: 300px)',
|
|
9
|
-
callback: () => console.log(2)
|
|
10
|
-
}
|
|
11
|
-
]
|
|
12
|
-
*/
|
|
13
|
-
class UseMediaQuery {
|
|
14
|
-
constructor(mediaQueryRules=[],fallback=()=>{}) {
|
|
15
|
-
this.mediaQueryRules = mediaQueryRules;
|
|
16
|
-
this.fallback = fallback;
|
|
17
|
-
this.lastCalledCallback = null;
|
|
18
|
-
this.init();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
init() {
|
|
22
|
-
this.mediaQueryRules.forEach(({ query, callback }) => {
|
|
23
|
-
const mediaQueryList = globalThis.matchMedia(query);
|
|
24
|
-
const checkMatches = () => {
|
|
25
|
-
const anyMatch = this.mediaQueryRules.some(({ query }) => globalThis.matchMedia(query).matches);
|
|
26
|
-
if (mediaQueryList.matches) {
|
|
27
|
-
callback();
|
|
28
|
-
this.lastCalledCallback = callback;
|
|
29
|
-
} else if (!anyMatch && this.lastCalledCallback !== this.fallback) {
|
|
30
|
-
this.fallback();
|
|
31
|
-
this.lastCalledCallback = this.fallback;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
checkMatches()
|
|
35
|
-
mediaQueryList.addListener(checkMatches);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const useMediaQuery = (mediaQueryRules,fallback) => new UseMediaQuery(mediaQueryRules,fallback);
|
|
41
|
-
export {
|
|
42
|
-
useMediaQuery
|
|
43
|
-
};
|
|
File without changes
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { camel2hyphencase } from "../../../data/converter/string/index.js";
|
|
2
|
-
class ZikoUseRoot{
|
|
3
|
-
constructor(props){
|
|
4
|
-
this.props={};
|
|
5
|
-
props && this.set(props)
|
|
6
|
-
}
|
|
7
|
-
get(prop){
|
|
8
|
-
return this.props[prop]
|
|
9
|
-
}
|
|
10
|
-
// getStaticValue(){
|
|
11
|
-
// return document.documentElement.style.getPropertyValue("--primary-col")
|
|
12
|
-
// }
|
|
13
|
-
set(props){
|
|
14
|
-
Object.entries(props).forEach(([key,value])=>this.#setOneProp(key, value));
|
|
15
|
-
return this;
|
|
16
|
-
}
|
|
17
|
-
#setOneProp(prop, value){
|
|
18
|
-
const CssProp = `--${camel2hyphencase(prop)}`
|
|
19
|
-
document.documentElement.style.setProperty(CssProp,value);
|
|
20
|
-
Object.assign(this.props, {[prop]: `var(${CssProp})`})
|
|
21
|
-
Object.assign(this, {[prop] : `var(${CssProp})`})
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const useRootValue=CssVar=>{
|
|
26
|
-
if(!CssVar.startsWith("--")) CssVar = `--${camel2hyphencase(CssVar)}`
|
|
27
|
-
return `var(${CssVar})`
|
|
28
|
-
}
|
|
29
|
-
// const useRootStaticValue=CssVar=>{
|
|
30
|
-
// if(!CssVar.startsWith("--")) CssVar = `--${Str.camel2hyphencase(CssVar)}`
|
|
31
|
-
// return globalThis.document.documentElement.style.getPropertyValue(CssVar)
|
|
32
|
-
// }
|
|
33
|
-
const useRoot=(props)=>new ZikoUseRoot(props)
|
|
34
|
-
export{
|
|
35
|
-
ZikoUseRoot,
|
|
36
|
-
useRoot,
|
|
37
|
-
useRootValue,
|
|
38
|
-
// useRootStaticValue
|
|
39
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
class UseStyle {
|
|
2
|
-
constructor(style = {}, use = style.hasOwnProperty("default")? "default" : Object.keys(style)[0], id = 0) {
|
|
3
|
-
this.id = "Ziko-Style-" + id;
|
|
4
|
-
this.keys = new Set();
|
|
5
|
-
this.styles = {
|
|
6
|
-
default: {
|
|
7
|
-
fontSize: "1em",
|
|
8
|
-
color : "green"
|
|
9
|
-
},
|
|
10
|
-
other: {
|
|
11
|
-
fontSize : "2em",
|
|
12
|
-
color : "cyan"
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
style && this.add(style);
|
|
16
|
-
use && this.use(use);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get current() {
|
|
20
|
-
return [...this.keys].reduce((key, value) => {
|
|
21
|
-
key[value] = `var(--${value}-${this.id})`;
|
|
22
|
-
return key;
|
|
23
|
-
}, {});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
add(name, style = {}) {
|
|
27
|
-
if (name && typeof name === 'object' && !Array.isArray(name)) {
|
|
28
|
-
Object.assign(this.styles, name);
|
|
29
|
-
} else if (typeof name === 'string') {
|
|
30
|
-
Object.assign(this.styles, { [name]: style });
|
|
31
|
-
}
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
#useStyleIndex(index) {
|
|
36
|
-
const keys = Object.keys(this.styles);
|
|
37
|
-
for (let a in this.styles[keys[index]]) {
|
|
38
|
-
if (Object.prototype.hasOwnProperty.call(this.styles[keys[index]], a)) {
|
|
39
|
-
document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[keys[index]][a]);
|
|
40
|
-
this.keys.add(a);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
#useStyleName(name) {
|
|
47
|
-
if (!this.styles[name]) return this;
|
|
48
|
-
for (let a in this.styles[name]) {
|
|
49
|
-
if (Object.prototype.hasOwnProperty.call(this.styles[name], a)) {
|
|
50
|
-
document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[name][a]);
|
|
51
|
-
this.keys.add(a);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
#useStyleObject(style) {
|
|
58
|
-
for (let a in style) {
|
|
59
|
-
if (Object.prototype.hasOwnProperty.call(style, a)) {
|
|
60
|
-
document.documentElement.style.setProperty(`--${a}-${this.id}`, style[a]);
|
|
61
|
-
this.keys.add(a);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
use(style) {
|
|
68
|
-
if (typeof style === "number") return this.#useStyleIndex(style);
|
|
69
|
-
if (typeof style === "string") return this.#useStyleName(style);
|
|
70
|
-
if (style && typeof style === "object") return this.#useStyleObject(style);
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const useStyle = (styles, use, id) => new UseStyle(styles, use, id)
|
|
76
|
-
export {
|
|
77
|
-
useStyle,
|
|
78
|
-
UseStyle
|
|
79
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Themes } from "../../../global/themes";
|
|
2
|
-
class UseTheme{
|
|
3
|
-
constructor(theme,id=0){
|
|
4
|
-
this.id="Ziko-Theme-"+id;
|
|
5
|
-
this.use(theme)
|
|
6
|
-
}
|
|
7
|
-
get current(){
|
|
8
|
-
const colorNames = [
|
|
9
|
-
'background',
|
|
10
|
-
'currentLine',
|
|
11
|
-
'selection',
|
|
12
|
-
'foreground',
|
|
13
|
-
'comment',
|
|
14
|
-
'cyan',
|
|
15
|
-
'green',
|
|
16
|
-
'orange',
|
|
17
|
-
'pink',
|
|
18
|
-
'purple',
|
|
19
|
-
'red',
|
|
20
|
-
'yellow',
|
|
21
|
-
];
|
|
22
|
-
return colorNames.reduce((theme, color) => {
|
|
23
|
-
theme[color] = `var(--${color}-${this.id})`;
|
|
24
|
-
return theme;
|
|
25
|
-
}, {});
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
useThemeIndex(index){
|
|
29
|
-
const keys=Object.keys(Themes);
|
|
30
|
-
for(let a in Themes[keys[index]]){
|
|
31
|
-
document.documentElement.style.setProperty(`--${a}-${this.id}`, Themes[keys[index]][a]);
|
|
32
|
-
}
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
useThemeName(str){
|
|
36
|
-
str=str.toLowerCase()
|
|
37
|
-
const Themes_With_Lower_Case=Object.fromEntries(Object.entries(Themes).map(n=>[n[0].toLowerCase(),n[1]]))
|
|
38
|
-
for(let a in Themes_With_Lower_Case[str]){
|
|
39
|
-
document.documentElement.style.setProperty(`--${a}-${this.id}`, Themes_With_Lower_Case[str][a]);
|
|
40
|
-
}
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
useThemeObject(Theme){
|
|
44
|
-
for(let a in Theme){
|
|
45
|
-
document.documentElement.style.setProperty(`--${a}-${this.id}`, Theme[a]);
|
|
46
|
-
}
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
use(theme){
|
|
50
|
-
if(typeof theme === "number")this.useThemeIndex(theme);
|
|
51
|
-
if(typeof theme === "string")this.useThemeName(theme);
|
|
52
|
-
if(theme instanceof Object)this.useThemeObject(theme);
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const useTheme=(theme, id=0)=>new UseTheme(theme,id)
|
|
57
|
-
export {
|
|
58
|
-
useTheme,
|
|
59
|
-
// Themes,
|
|
60
|
-
// LightThemes,
|
|
61
|
-
// DarkThemes,
|
|
62
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
class ZikoUseCssText{
|
|
2
|
-
constructor(css){
|
|
3
|
-
this.#init();
|
|
4
|
-
this.set(css);
|
|
5
|
-
}
|
|
6
|
-
#init(){
|
|
7
|
-
// this.__FavIcon__=document.querySelector("link[rel*='icon']") || document?.createElement('link');
|
|
8
|
-
// this.__FavIcon__.type = 'image/x-icon';
|
|
9
|
-
// this.__FavIcon__.rel = 'shortcut icon';
|
|
10
|
-
return this;
|
|
11
|
-
}
|
|
12
|
-
set(cssText){
|
|
13
|
-
// if(href!==this.__FavIcon__.href){
|
|
14
|
-
// this.__FavIcon__.href=href;
|
|
15
|
-
// if(this.cache.Emitter)this.cache.Emitter.emit("ziko:favicon-changed");
|
|
16
|
-
// }
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const useCss=(FavIcon,useEventEmitter)=>new ZikoUseCssText(FavIcon,useEventEmitter);
|
|
21
|
-
export{ useCss }
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useEventEmitter } from "../../../hooks/use-event-emitter.js";
|
|
2
|
-
class ZikoUseFavIcon{
|
|
3
|
-
constructor(FavIcon,withEmitter=true){
|
|
4
|
-
this.#init();
|
|
5
|
-
this.cache={
|
|
6
|
-
Emitter:null
|
|
7
|
-
}
|
|
8
|
-
if(withEmitter)this.useEventEmitter();
|
|
9
|
-
this.set(FavIcon);
|
|
10
|
-
}
|
|
11
|
-
#init(){
|
|
12
|
-
this.__FavIcon__ = document.querySelector("link[rel*='icon']") || document?.createElement('link');
|
|
13
|
-
this.__FavIcon__.type = 'image/x-icon';
|
|
14
|
-
this.__FavIcon__.rel = 'shortcut icon';
|
|
15
|
-
return this;
|
|
16
|
-
}
|
|
17
|
-
set(href){
|
|
18
|
-
if(href!==this.__FavIcon__.href){
|
|
19
|
-
this.__FavIcon__.href=href;
|
|
20
|
-
if(this.cache.Emitter)this.cache.Emitter.emit("ziko:favicon-changed");
|
|
21
|
-
}
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
get current(){
|
|
25
|
-
return document.__FavIcon__.href;
|
|
26
|
-
}
|
|
27
|
-
onChange(callback){
|
|
28
|
-
if(this.cache.Emitter)this.cache.Emitter.on("ziko:favicon-changed",callback);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
useEventEmitter(){
|
|
32
|
-
this.cache.Emitter=useEventEmitter();
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
const useFavIcon=(FavIcon,withEmitter)=>new ZikoUseFavIcon(FavIcon,withEmitter);
|
|
38
|
-
export{ useFavIcon }
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useTitle } from "./useTitle.js";
|
|
2
|
-
import { useFavIcon } from "./useFavIcon.js";
|
|
3
|
-
import {useMeta} from "./useMeta.js";
|
|
4
|
-
// import {useLink} from "./";
|
|
5
|
-
class ZikoHead{
|
|
6
|
-
constructor({title,lang,icon,meta,noscript}){
|
|
7
|
-
this.html = globalThis?.document?.documentElement;
|
|
8
|
-
this.head = globalThis?.document?.head;
|
|
9
|
-
|
|
10
|
-
title && useTitle(title);
|
|
11
|
-
lang && this.setLang(lang)
|
|
12
|
-
icon && useFavIcon(icon);
|
|
13
|
-
meta && useMeta(meta);
|
|
14
|
-
noscript && this.setNoScript()
|
|
15
|
-
}
|
|
16
|
-
setLang(lang){
|
|
17
|
-
this.html.setAttribute("lang",lang)
|
|
18
|
-
}
|
|
19
|
-
setNoScript(content){
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const useHead=({ title, lang, icon, meta, noscript })=>new ZikoHead({ title, lang, icon, meta, noscript });
|
|
25
|
-
export{
|
|
26
|
-
useHead,
|
|
27
|
-
ZikoHead
|
|
28
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
class ZikoMeta{
|
|
2
|
-
constructor({viewport,charset,description,author,keywords}){
|
|
3
|
-
this.document = globalThis?.document
|
|
4
|
-
this.meta={};
|
|
5
|
-
this.init({viewport,charset,description,author,keywords})
|
|
6
|
-
}
|
|
7
|
-
init({viewport,charset,description,author,keywords}){
|
|
8
|
-
viewport && this.setViewport(viewport);
|
|
9
|
-
charset && this.setCharset(charset);
|
|
10
|
-
description && this.describe(description);
|
|
11
|
-
author && this.setAuthor(author);
|
|
12
|
-
keywords && this.setKeywords(keywords);
|
|
13
|
-
}
|
|
14
|
-
set(key,value){
|
|
15
|
-
key = key.toLowerCase();
|
|
16
|
-
const isCharset = (key === "charset")
|
|
17
|
-
const meta = isCharset ? document.querySelector("meta[charset]"):document.querySelector(`meta[name=${key}]`);
|
|
18
|
-
this.meta=meta?? document?.createElement("meta");
|
|
19
|
-
if(isCharset) this.meta.setAttribute("charset",value);
|
|
20
|
-
else{
|
|
21
|
-
this.meta.setAttribute("name",key);
|
|
22
|
-
this.meta.setAttribute("content",value);
|
|
23
|
-
}
|
|
24
|
-
if(!meta)this.document.head.append(this.meta);
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
setCharset(charset="utf-8"){
|
|
28
|
-
this.set("charset",charset)
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
describe(description){
|
|
32
|
-
this.set("description",description);
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
setViewport(viewport="width=device-width, initial-scale=1.0"){
|
|
36
|
-
this.set("viewport",viewport);
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
setKeywords(...keywords){
|
|
40
|
-
// keywords.push("zikojs");
|
|
41
|
-
keywords=[...new Set(keywords)].join(", ");
|
|
42
|
-
this.set("keywords",keywords);
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
setAuthor(author){
|
|
46
|
-
this.set("author",author);
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const useMeta=({viewport,charset,description,author,keywords})=>new ZikoMeta({viewport,charset,description,author,keywords});
|
|
51
|
-
export{useMeta}
|
|
52
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useEventEmitter } from "../../../hooks/use-event-emitter.js";
|
|
2
|
-
class ZikoUseTitle{
|
|
3
|
-
constructor(title=document.title,useEventEmitter=true){
|
|
4
|
-
this.cache={
|
|
5
|
-
Emitter:null
|
|
6
|
-
}
|
|
7
|
-
if(useEventEmitter)this.useEventEmitter();
|
|
8
|
-
this.set(title);
|
|
9
|
-
}
|
|
10
|
-
useEventEmitter(){
|
|
11
|
-
this.cache.Emitter=useEventEmitter();
|
|
12
|
-
return this;
|
|
13
|
-
}
|
|
14
|
-
set(title){
|
|
15
|
-
if(title!==document.title){
|
|
16
|
-
document.title=title;
|
|
17
|
-
if(this.cache.Emitter)this.cache.Emitter.emit("ziko:title-changed");
|
|
18
|
-
}
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
get current(){
|
|
22
|
-
return document.title;
|
|
23
|
-
}
|
|
24
|
-
onChange(callback){
|
|
25
|
-
if(this.cache.Emitter)this.cache.Emitter.on("ziko:title-changed",callback);
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const useTitle=(title, useEventEmitter)=>new ZikoUseTitle(title, useEventEmitter);
|
|
30
|
-
export{ useTitle }
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
- Device :
|
|
2
|
-
- useBattery
|
|
3
|
-
- useGeolocation
|
|
4
|
-
- useFullScrean
|
|
5
|
-
- useOrientation
|
|
6
|
-
- useNotification
|
|
7
|
-
- UI
|
|
8
|
-
- useTheme
|
|
9
|
-
- useStyle
|
|
10
|
-
- useCss
|
|
11
|
-
- useTitle
|
|
12
|
-
- useFavIcon
|
|
13
|
-
- Interactions
|
|
14
|
-
- useEventEmitter
|
|
15
|
-
- useChannel
|
|
16
|
-
- useBluetooth
|
|
17
|
-
- useSerial
|
|
18
|
-
- useUsb
|
|
19
|
-
- useSocket
|
|
20
|
-
- Storage
|
|
21
|
-
- useSessionStorage
|
|
22
|
-
- useLocalStorage
|
|
23
|
-
- Timing
|
|
24
|
-
- useDebounce
|
|
25
|
-
- useThrottle
|
|
26
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
useTypeWritter
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ZikoMutationObserver } from "./mutation";
|
|
2
|
-
class ZikoWatchAttr extends ZikoMutationObserver{
|
|
3
|
-
constructor(targetUIElement,callback){
|
|
4
|
-
super(targetUIElement,{ attributes: true, childList: false, subtree: false });
|
|
5
|
-
Object.assign(this.cache,{
|
|
6
|
-
observeCallback : (mutationsList, observer) =>{
|
|
7
|
-
for (const mutation of mutationsList) {
|
|
8
|
-
this.cache.lastMutation = {
|
|
9
|
-
name : mutation.attributeName,
|
|
10
|
-
value : mutation.target.getAttribute(mutation.attributeName)
|
|
11
|
-
}
|
|
12
|
-
if (this.cache.streamingEnabled) this.cache.mutationHistory.attributes.push(this.cache.lastMutation)
|
|
13
|
-
}
|
|
14
|
-
if (this.callback) this.callback(mutationsList, observer);
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
this.cache.mutationHistory.attributes = []
|
|
18
|
-
if(callback)this.observe(callback);
|
|
19
|
-
}
|
|
20
|
-
get history(){
|
|
21
|
-
return this.cache.mutationHistory.attributes;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const watchAttr=(targetUIElement, callback)=>new ZikoWatchAttr(targetUIElement, callback);
|
|
25
|
-
export{
|
|
26
|
-
watchAttr
|
|
27
|
-
}
|
|
28
|
-
|