ziko 0.0.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 +316 -0
- package/dist/ziko.cjs +9786 -0
- package/dist/ziko.js +9792 -0
- package/dist/ziko.min.js +9 -0
- package/dist/ziko.mjs +9567 -0
- package/package.json +55 -0
- package/src/App/Accessibility/index.js +0 -0
- package/src/App/Globals/__Target__.js +3 -0
- package/src/App/Globals/__UI__.js +38 -0
- package/src/App/Globals/__init__.js +8 -0
- package/src/App/Globals/index.js +3 -0
- package/src/App/Router/index.js +40 -0
- package/src/App/Seo/index.js +43 -0
- package/src/App/Themes/dark.js +885 -0
- package/src/App/Themes/index.js +11 -0
- package/src/App/Themes/light.js +255 -0
- package/src/App/app.js +37 -0
- package/src/App/index.js +11 -0
- package/src/Data/Api/fetchdom.js +14 -0
- package/src/Data/Api/index.js +4 -0
- package/src/Data/Api/preload.js +11 -0
- package/src/Data/Converter/canvas.js +25 -0
- package/src/Data/Converter/csv.js +33 -0
- package/src/Data/Converter/index.js +25 -0
- package/src/Data/Converter/json.js +80 -0
- package/src/Data/Converter/markdown.js +83 -0
- package/src/Data/Converter/svg.js +11 -0
- package/src/Data/Parser/markdown.js +0 -0
- package/src/Data/Parser/xml.js +47 -0
- package/src/Data/Strings/index.js +26 -0
- package/src/Data/decorators.js +0 -0
- package/src/Data/index.js +64 -0
- package/src/Graphics/Canvas/Elements/Basic/arc.js +43 -0
- package/src/Graphics/Canvas/Elements/Basic/image.js +0 -0
- package/src/Graphics/Canvas/Elements/Basic/line.js +26 -0
- package/src/Graphics/Canvas/Elements/Basic/path.js +0 -0
- package/src/Graphics/Canvas/Elements/Basic/points.js +48 -0
- package/src/Graphics/Canvas/Elements/Basic/polygon.js +7 -0
- package/src/Graphics/Canvas/Elements/Basic/polyline.js +0 -0
- package/src/Graphics/Canvas/Elements/Basic/rect.js +46 -0
- package/src/Graphics/Canvas/Elements/Basic/text.js +0 -0
- package/src/Graphics/Canvas/Elements/Chart/histogram.js +0 -0
- package/src/Graphics/Canvas/Elements/Chart/plot.js +0 -0
- package/src/Graphics/Canvas/Elements/Chart/scatter.js +2 -0
- package/src/Graphics/Canvas/Elements/Chart/stem.js +0 -0
- package/src/Graphics/Canvas/Elements/Element.js +115 -0
- package/src/Graphics/Canvas/Elements/Groupe.js +0 -0
- package/src/Graphics/Canvas/Elements/grid.js +0 -0
- package/src/Graphics/Canvas/Elements/index.js +13 -0
- package/src/Graphics/Canvas/Filter/index.js +0 -0
- package/src/Graphics/Canvas/Paint/index.js +0 -0
- package/src/Graphics/Canvas/Utils/color.js +8 -0
- package/src/Graphics/Canvas/Utils/floodFill.js +58 -0
- package/src/Graphics/Canvas/_canvas_offscreen +0 -0
- package/src/Graphics/Canvas/canvas.js +189 -0
- package/src/Graphics/Canvas/index.js +15 -0
- package/src/Graphics/Svg/Elements/ZikoSvgElement.js +28 -0
- package/src/Graphics/Svg/Elements/circle.js +34 -0
- package/src/Graphics/Svg/Elements/ellipse.js +29 -0
- package/src/Graphics/Svg/Elements/foreignObject.js +46 -0
- package/src/Graphics/Svg/Elements/grid.js +9 -0
- package/src/Graphics/Svg/Elements/groupe.js +29 -0
- package/src/Graphics/Svg/Elements/image.js +33 -0
- package/src/Graphics/Svg/Elements/line.js +29 -0
- package/src/Graphics/Svg/Elements/path.js +59 -0
- package/src/Graphics/Svg/Elements/polygon.js +31 -0
- package/src/Graphics/Svg/Elements/polyline.js +4 -0
- package/src/Graphics/Svg/Elements/rect.js +43 -0
- package/src/Graphics/Svg/Elements/text.js +26 -0
- package/src/Graphics/Svg/index.js +1 -0
- package/src/Graphics/Svg/svg.js +117 -0
- package/src/Graphics/index.js +61 -0
- package/src/Math/Calculus/Special Functions/bessel.js +31 -0
- package/src/Math/Calculus/Special Functions/beta.js +38 -0
- package/src/Math/Calculus/Special Functions/gamma.js +30 -0
- package/src/Math/Calculus/Special Functions/index.js +4 -0
- package/src/Math/Calculus/index.js +1 -0
- package/src/Math/Complex/Fractals/julia.js +0 -0
- package/src/Math/Complex/index.js +191 -0
- package/src/Math/Discret/Combinaison/index.js +34 -0
- package/src/Math/Discret/Conversion/index.js +86 -0
- package/src/Math/Discret/Logic/index.js +46 -0
- package/src/Math/Discret/Permutation/index.js +31 -0
- package/src/Math/Discret/Set/index.js +2 -0
- package/src/Math/Discret/Set/powerSet.js +15 -0
- package/src/Math/Discret/Set/subSet.js +10 -0
- package/src/Math/Discret/index.js +23 -0
- package/src/Math/Functions/index.js +182 -0
- package/src/Math/Matrix/Decomposition.js +90 -0
- package/src/Math/Matrix/LinearSystem.js +10 -0
- package/src/Math/Matrix/Matrix.js +712 -0
- package/src/Math/Matrix/index.js +3 -0
- package/src/Math/Numeric/index.js +0 -0
- package/src/Math/Random/index.js +173 -0
- package/src/Math/Signal/__np.py.txt +40 -0
- package/src/Math/Signal/conv.js +175 -0
- package/src/Math/Signal/fft.js +55 -0
- package/src/Math/Signal/filter.js +39 -0
- package/src/Math/Signal/functions.js +146 -0
- package/src/Math/Signal/index.js +110 -0
- package/src/Math/Statistics/Functions/index.js +100 -0
- package/src/Math/Statistics/index.js +16 -0
- package/src/Math/Utils/arithmetic.js +139 -0
- package/src/Math/Utils/checkers.js +11 -0
- package/src/Math/Utils/comparaison.js +1 -0
- package/src/Math/Utils/conversions.js +7 -0
- package/src/Math/Utils/discret.js +28 -0
- package/src/Math/Utils/index.js +102 -0
- package/src/Math/Utils/mapfun.js +43 -0
- package/src/Math/absract.js +1 -0
- package/src/Math/const.js +3 -0
- package/src/Math/index.js +193 -0
- package/src/Reactivity/Events/Global/Click.js +56 -0
- package/src/Reactivity/Events/Global/Clipboard.js +84 -0
- package/src/Reactivity/Events/Global/CustomEvent.js +53 -0
- package/src/Reactivity/Events/Global/Drag.js +137 -0
- package/src/Reactivity/Events/Global/Focus.js +56 -0
- package/src/Reactivity/Events/Global/Key.js +104 -0
- package/src/Reactivity/Events/Global/Pointer.js +214 -0
- package/src/Reactivity/Events/Partiel/Input.js +59 -0
- package/src/Reactivity/Events/ZikoEvent.js +91 -0
- package/src/Reactivity/Events/index.js +51 -0
- package/src/Reactivity/Observer/index.js +3 -0
- package/src/Reactivity/Observer/intersection.js +40 -0
- package/src/Reactivity/Observer/mutation.js +90 -0
- package/src/Reactivity/Observer/resize.js +47 -0
- package/src/Reactivity/Use/Contexte/index.js +1 -0
- package/src/Reactivity/Use/Contexte/useSuccesifKeys.js +14 -0
- package/src/Reactivity/Use/Decorators/index.js +4 -0
- package/src/Reactivity/Use/Interactions/index.js +4 -0
- package/src/Reactivity/Use/Interactions/useBluetooth.js +48 -0
- package/src/Reactivity/Use/Interactions/useChannel.js +50 -0
- package/src/Reactivity/Use/Interactions/useEventEmmiter.js +64 -0
- package/src/Reactivity/Use/Interactions/useSerial.js +0 -0
- package/src/Reactivity/Use/Interactions/useThread.js +44 -0
- package/src/Reactivity/Use/Interactions/useUsb.js +0 -0
- package/src/Reactivity/Use/Sensors/index.js +2 -0
- package/src/Reactivity/Use/Sensors/useBattery.js +36 -0
- package/src/Reactivity/Use/Sensors/useCamera.js +0 -0
- package/src/Reactivity/Use/Sensors/useGeolocation.js +17 -0
- package/src/Reactivity/Use/Sensors/useMicro.js +0 -0
- package/src/Reactivity/Use/Sensors/useOrientation.js +0 -0
- package/src/Reactivity/Use/Storage/index.js +1 -0
- package/src/Reactivity/Use/Storage/useCookie.js +0 -0
- package/src/Reactivity/Use/Storage/useIndexedDb.js +0 -0
- package/src/Reactivity/Use/Storage/useStorage.js +74 -0
- package/src/Reactivity/Use/UI/index.js +4 -0
- package/src/Reactivity/Use/UI/useCssLink.js +0 -0
- package/src/Reactivity/Use/UI/useCssText.js +21 -0
- package/src/Reactivity/Use/UI/useFavIcon.js +38 -0
- package/src/Reactivity/Use/UI/useLinearGradient.js +0 -0
- package/src/Reactivity/Use/UI/useMediaQuery.js +1 -0
- package/src/Reactivity/Use/UI/useRadialGradient.js +0 -0
- package/src/Reactivity/Use/UI/useStyle.js +54 -0
- package/src/Reactivity/Use/UI/useTheme.js +62 -0
- package/src/Reactivity/Use/UI/useTitle.js +30 -0
- package/src/Reactivity/Use/index.js +82 -0
- package/src/Reactivity/Use/todo.md +26 -0
- package/src/Reactivity/index.js +3 -0
- package/src/Time/animation.js +76 -0
- package/src/Time/index.js +54 -0
- package/src/Time/loop.js +83 -0
- package/src/Time/utils/decorators.js +17 -0
- package/src/Time/utils/ease.js +144 -0
- package/src/Time/utils/index.js +18 -0
- package/src/Time/utils/performance.js +16 -0
- package/src/Time/utils/ui.js +26 -0
- package/src/UI/CustomElement/Elements/Accordion/index.js +62 -0
- package/src/UI/CustomElement/Elements/Carousel/index.js +47 -0
- package/src/UI/CustomElement/Elements/CodeNote/CodeCell.js +176 -0
- package/src/UI/CustomElement/Elements/CodeNote/CodeNote.js +69 -0
- package/src/UI/CustomElement/Elements/CodeNote/SubElements.js +64 -0
- package/src/UI/CustomElement/Elements/CodeNote/index.js +2 -0
- package/src/UI/CustomElement/Elements/Columns.js +1 -0
- package/src/UI/CustomElement/Elements/FAB.js +0 -0
- package/src/UI/CustomElement/Elements/Menu.js +0 -0
- package/src/UI/CustomElement/Elements/Notification.js +0 -0
- package/src/UI/CustomElement/Elements/Popover.js +0 -0
- package/src/UI/CustomElement/Elements/Popup.js +0 -0
- package/src/UI/CustomElement/Elements/Swipper.js +4 -0
- package/src/UI/CustomElement/Elements/Tabs/index.js +111 -0
- package/src/UI/CustomElement/Elements/Timeline.js +0 -0
- package/src/UI/CustomElement/Elements/Toast.js +0 -0
- package/src/UI/CustomElement/Elements/Treeview.js +0 -0
- package/src/UI/CustomElement/Elements/index.js +4 -0
- package/src/UI/CustomElement/Flex.js +97 -0
- package/src/UI/CustomElement/Grid.js +30 -0
- package/src/UI/CustomElement/index.js +3 -0
- package/src/UI/Embaded/index.js +1 -0
- package/src/UI/Inputs/Primitives/btn.js +31 -0
- package/src/UI/Inputs/Primitives/elements.js +28 -0
- package/src/UI/Inputs/Primitives/inputs.js +334 -0
- package/src/UI/Inputs/Primitives/select.js +15 -0
- package/src/UI/Inputs/Primitives/textarea.js +16 -0
- package/src/UI/Inputs/camera.js +23 -0
- package/src/UI/Inputs/index.js +20 -0
- package/src/UI/List/elements.js +0 -0
- package/src/UI/List/index.js +130 -0
- package/src/UI/Media/Audio/index.js +26 -0
- package/src/UI/Media/Image/figure.js +17 -0
- package/src/UI/Media/Image/image.js +34 -0
- package/src/UI/Media/Image/index.js +2 -0
- package/src/UI/Media/Video/index.js +37 -0
- package/src/UI/Media/index.js +3 -0
- package/src/UI/Misc/index.js +49 -0
- package/src/UI/Semantic/index.js +68 -0
- package/src/UI/Style/index.js +499 -0
- package/src/UI/Table/elements.js +94 -0
- package/src/UI/Table/index.js +3 -0
- package/src/UI/Table/table.js +113 -0
- package/src/UI/Table/utils.js +12 -0
- package/src/UI/Text/heading.js +35 -0
- package/src/UI/Text/index.js +3 -0
- package/src/UI/Text/p.js +37 -0
- package/src/UI/Text/pre.js +0 -0
- package/src/UI/Text/text.js +66 -0
- package/src/UI/Utils/index.js +70 -0
- package/src/UI/ZikoUIElement.js +478 -0
- package/src/UI/index.js +154 -0
- package/src/__proto__/Array.js +74 -0
- package/src/__proto__/Function.js +0 -0
- package/src/__proto__/Number.js +76 -0
- package/src/__proto__/Object.js +0 -0
- package/src/__proto__/String.js +0 -0
- package/src/index.js +69 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Random } from "../../../Math/Random";
|
|
2
|
+
class ZikoUseChannel{
|
|
3
|
+
constructor(name=""){
|
|
4
|
+
this.channel=new BroadcastChannel(name);
|
|
5
|
+
this.EVENTS_DATAS_PAIRS=new Map();
|
|
6
|
+
this.EVENTS_HANDLERS_PAIRS=new Map();
|
|
7
|
+
this.LAST_RECEIVED_EVENT="";
|
|
8
|
+
this.UUID="ziko-channel"+Random.string(10);
|
|
9
|
+
this.SUBSCRIBERS=new Set([this.UUID]);
|
|
10
|
+
}
|
|
11
|
+
get broadcast(){
|
|
12
|
+
// update receiver
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
emit(event, data){
|
|
16
|
+
this.EVENTS_DATAS_PAIRS.set(event,data)
|
|
17
|
+
this.#maintainEmit(event);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
on(event,handler=console.log){
|
|
21
|
+
this.EVENTS_HANDLERS_PAIRS.set(event,handler);
|
|
22
|
+
this.#maintainOn()
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
#maintainOn(){
|
|
26
|
+
this.channel.onmessage = (e) => {
|
|
27
|
+
this.LAST_RECEIVED_EVENT=e.data.last_sended_event;
|
|
28
|
+
const USER_ID=e.data.userId;
|
|
29
|
+
this.SUBSCRIBERS.add(USER_ID)
|
|
30
|
+
const Data=e.data.EVENTS_DATAS_PAIRS.get(this.LAST_RECEIVED_EVENT)
|
|
31
|
+
const Handler=this.EVENTS_HANDLERS_PAIRS.get(this.LAST_RECEIVED_EVENT)
|
|
32
|
+
if(Data && Handler)Handler(Data)
|
|
33
|
+
};
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
#maintainEmit(event){
|
|
37
|
+
this.channel.postMessage({
|
|
38
|
+
EVENTS_DATAS_PAIRS:this.EVENTS_DATAS_PAIRS,
|
|
39
|
+
last_sended_event:event,
|
|
40
|
+
userId:this.UUID
|
|
41
|
+
});
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
close(){
|
|
45
|
+
this.channel.close();
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const useChannel=name=>new ZikoUseChannel(name);
|
|
50
|
+
export{ useChannel }
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
class ZikoUseEventEmitter {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.events = {};
|
|
4
|
+
this.maxListeners = 10;
|
|
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=()=>new ZikoUseEventEmitter()
|
|
64
|
+
export{useEventEmitter}
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
class ZikoUseThreed {
|
|
2
|
+
#workerContent;
|
|
3
|
+
constructor() {
|
|
4
|
+
this.#workerContent = (
|
|
5
|
+
function (msg) {
|
|
6
|
+
try {
|
|
7
|
+
const func = new Function("return " + msg.data.fun)();
|
|
8
|
+
let result = func();
|
|
9
|
+
postMessage({ result });
|
|
10
|
+
} catch (error) {
|
|
11
|
+
postMessage({ error: error.message });
|
|
12
|
+
} finally {
|
|
13
|
+
if (msg.data.close) self.close();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
).toString();
|
|
17
|
+
this.blob = new Blob(["this.onmessage = " + this.#workerContent], { type: "text/javascript" });
|
|
18
|
+
this.worker = new Worker(window.URL.createObjectURL(this.blob));
|
|
19
|
+
}
|
|
20
|
+
call(func, callback, close = true) {
|
|
21
|
+
this.worker.postMessage({
|
|
22
|
+
fun: func.toString(),
|
|
23
|
+
close
|
|
24
|
+
});
|
|
25
|
+
this.worker.onmessage = function (e) {
|
|
26
|
+
if (e.data.error) {
|
|
27
|
+
console.error(e.data.error);
|
|
28
|
+
} else {
|
|
29
|
+
callback(e.data.result);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const useThread = (func, callback , close) => {
|
|
37
|
+
const T = new ZikoUseThreed();
|
|
38
|
+
if (func) {
|
|
39
|
+
T.call(func, callback , close);
|
|
40
|
+
}
|
|
41
|
+
return T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { useThread };
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
class ZikoUseBattery{
|
|
2
|
+
constructor(){
|
|
3
|
+
if(this.isSupported)this.#init();
|
|
4
|
+
}
|
|
5
|
+
async #init(){
|
|
6
|
+
this.__Battery__=await navigator.getBattery();
|
|
7
|
+
}
|
|
8
|
+
get isSupported(){
|
|
9
|
+
return !!navigator.getBattery;
|
|
10
|
+
}
|
|
11
|
+
get current(){
|
|
12
|
+
// Synchrouns Code
|
|
13
|
+
const {
|
|
14
|
+
level,
|
|
15
|
+
charging,
|
|
16
|
+
chargingTime,
|
|
17
|
+
dischargingTime
|
|
18
|
+
}=this.__Battery__;
|
|
19
|
+
return{
|
|
20
|
+
level,
|
|
21
|
+
charging,
|
|
22
|
+
chargingTime,
|
|
23
|
+
dischargingTime
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
onChargingChange(callback){
|
|
27
|
+
this.__Battery__.addEventListener("chargingchange",callback);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
onLevelChange(callback){
|
|
31
|
+
this.__Battery__.addEventListener("levelchange",callback);
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const useBattery=()=>new ZikoUseBattery();
|
|
36
|
+
export{ useBattery }
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class ZikoUseGeolocation{
|
|
2
|
+
constructor(){
|
|
3
|
+
if(this.isSupported)this.#init();
|
|
4
|
+
}
|
|
5
|
+
async #init(){
|
|
6
|
+
navigator.geolocation.getCurrentPosition(e=>this.__Geolocation__=e)
|
|
7
|
+
}
|
|
8
|
+
get isSupported(){
|
|
9
|
+
return !!navigator.geolocation;
|
|
10
|
+
}
|
|
11
|
+
get current(){
|
|
12
|
+
// Synchrouns Code
|
|
13
|
+
return this.__Geolocation__;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const useGeolocation=()=>new ZikoUseGeolocation();
|
|
17
|
+
export{ useGeolocation }
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useStorage";
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// To do : remove old items
|
|
2
|
+
import { useChannel } from "../Interactions";
|
|
3
|
+
class ZikoUseStorage{
|
|
4
|
+
#CACHE
|
|
5
|
+
constructor(storage,globalKey,initialValue){
|
|
6
|
+
this.#CACHE={
|
|
7
|
+
storage,
|
|
8
|
+
globalKey,
|
|
9
|
+
channel:useChannel(`Ziko:useStorage-${globalKey}`),
|
|
10
|
+
oldItemKeys:new Set()
|
|
11
|
+
}
|
|
12
|
+
this.#init(initialValue);
|
|
13
|
+
this.#maintain();
|
|
14
|
+
}
|
|
15
|
+
get items(){
|
|
16
|
+
return JSON.parse(this.#CACHE.storage[this.#CACHE.globalKey]??null);
|
|
17
|
+
}
|
|
18
|
+
#maintain() {
|
|
19
|
+
for(let i in this.items)Object.assign(this, { [[i]]: this.items[i] });
|
|
20
|
+
}
|
|
21
|
+
#init(initialValue){
|
|
22
|
+
this.#CACHE.channel=useChannel(`Ziko:useStorage-${this.#CACHE.globalKey}`);
|
|
23
|
+
this.#CACHE.channel.on("Ziko-Storage-Updated",()=>this.#maintain());
|
|
24
|
+
if(!initialValue)return;
|
|
25
|
+
if(this.#CACHE.storage[this.#CACHE.globalKey]){
|
|
26
|
+
Object.keys(this.items).forEach(key=>this.#CACHE.oldItemKeys.add(key));
|
|
27
|
+
console.group("Ziko:useStorage")
|
|
28
|
+
console.warn(`Storage key '${this.#CACHE.globalKey}' already exists. we will not overwrite it.`);
|
|
29
|
+
console.info(`%cWe'll keep the existing data.`,"background-color:#2222dd; color:gold;");
|
|
30
|
+
console.group("")
|
|
31
|
+
}
|
|
32
|
+
else this.set(initialValue);
|
|
33
|
+
}
|
|
34
|
+
set(data){
|
|
35
|
+
this.#CACHE.storage.setItem(this.#CACHE.globalKey,JSON.stringify(data));
|
|
36
|
+
this.#CACHE.channel.emit("Ziko-Storage-Updated",{});
|
|
37
|
+
Object.keys(data).forEach(key=>this.#CACHE.oldItemKeys.add(key));
|
|
38
|
+
this.#maintain();
|
|
39
|
+
return this
|
|
40
|
+
}
|
|
41
|
+
add(data){
|
|
42
|
+
const db={
|
|
43
|
+
...this.items,
|
|
44
|
+
...data
|
|
45
|
+
}
|
|
46
|
+
this.#CACHE.storage.setItem(this.#CACHE.globalKey,JSON.stringify(db));
|
|
47
|
+
this.#maintain();
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
remove(...keys){
|
|
51
|
+
const db={...this.items};
|
|
52
|
+
for(let i=0;i<keys.length;i++){
|
|
53
|
+
delete db[keys[i]];
|
|
54
|
+
delete this[keys[i]];
|
|
55
|
+
}
|
|
56
|
+
this.set(db);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
get(key){
|
|
60
|
+
return this.items[key];
|
|
61
|
+
}
|
|
62
|
+
clear(){
|
|
63
|
+
this.#CACHE.storage.removeItem(this.#CACHE.globalKey);
|
|
64
|
+
this.#maintain();
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
|
|
70
|
+
const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
|
|
71
|
+
export{
|
|
72
|
+
useLocaleStorage,
|
|
73
|
+
useSessionStorage
|
|
74
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
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 useFavIcon=(FavIcon,useEventEmitter)=>new ZikoUseFavIcon(FavIcon,useEventEmitter);
|
|
21
|
+
export{ useFavIcon }
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEventEmitter } from "../Interactions/useEventEmmiter";
|
|
2
|
+
class ZikoUseFavIcon{
|
|
3
|
+
constructor(FavIcon,useEventEmitter=true){
|
|
4
|
+
this.#init();
|
|
5
|
+
this.cache={
|
|
6
|
+
Emitter:null
|
|
7
|
+
}
|
|
8
|
+
if(useEventEmitter)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,useEventEmitter)=>new ZikoUseFavIcon(FavIcon,useEventEmitter);
|
|
38
|
+
export{ useFavIcon }
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//window.matchMedia('(max-width: 600px)');
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
class ZikoUseStyle{
|
|
2
|
+
constructor(style,id=0){
|
|
3
|
+
this.id="Ziko-Style-"+id;
|
|
4
|
+
this.use(style);
|
|
5
|
+
this.keys=new Set();
|
|
6
|
+
this.styles={
|
|
7
|
+
default:{
|
|
8
|
+
fontSize:"1em"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
get current(){
|
|
13
|
+
return [...this.keys].reduce((key, value) => {
|
|
14
|
+
key[value] = `var(--${value}-${this.id})`;
|
|
15
|
+
return key;
|
|
16
|
+
}, {});
|
|
17
|
+
}
|
|
18
|
+
add(name,style={}){
|
|
19
|
+
if(name instanceof Object)Object.assign(this.styles,name)
|
|
20
|
+
else Object.assign(this.styles,{[name]:style});
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
#useStyleIndex(index){
|
|
24
|
+
const keys=Object.keys(this.styles);
|
|
25
|
+
for(let a in this.styles[keys[index]]){
|
|
26
|
+
document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[keys[index]][a]);
|
|
27
|
+
this.keys.add(a);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
#useStyleName(name){
|
|
33
|
+
for(let a in this.styles[name]){
|
|
34
|
+
document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[name][a]);
|
|
35
|
+
this.keys.add(a);
|
|
36
|
+
}
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
#useStyleObject(Style){
|
|
40
|
+
for(let a in Style){
|
|
41
|
+
document.documentElement.style.setProperty(`--${a}-${this.id}`, Style[a]);
|
|
42
|
+
this.keys.add(a);
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
use(style){
|
|
47
|
+
if(typeof style === "number")this.#useStyleIndex(style);
|
|
48
|
+
if(typeof style === "string")this.#useStyleName(style);
|
|
49
|
+
if(style instanceof Object)this.#useStyleObject(style);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const useStyle=id=>style=>new ZikoUseStyle(style,id)
|
|
54
|
+
export {useStyle}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Themes } from "../../../App/Themes";
|
|
2
|
+
class ZikoUseTheme{
|
|
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=(id=0)=>(theme=0)=>new ZikoUseTheme(theme,id)
|
|
57
|
+
export {
|
|
58
|
+
useTheme,
|
|
59
|
+
// Themes,
|
|
60
|
+
// LightThemes,
|
|
61
|
+
// DarkThemes,
|
|
62
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEventEmitter } from "../Interactions/useEventEmmiter";
|
|
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 }
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useStyle,
|
|
3
|
+
useTheme,
|
|
4
|
+
useTitle,
|
|
5
|
+
useFavIcon
|
|
6
|
+
} from "./UI";
|
|
7
|
+
import {
|
|
8
|
+
useEventEmitter,
|
|
9
|
+
useChannel,
|
|
10
|
+
useThread,
|
|
11
|
+
useBluetooth
|
|
12
|
+
} from "./Interactions";
|
|
13
|
+
import {
|
|
14
|
+
useBattery,
|
|
15
|
+
useGeolocation
|
|
16
|
+
} from "./Sensors";
|
|
17
|
+
import {
|
|
18
|
+
useThrottle,
|
|
19
|
+
useDebounce
|
|
20
|
+
} from "./Decorators";
|
|
21
|
+
import {
|
|
22
|
+
useLocaleStorage,
|
|
23
|
+
useSessionStorage
|
|
24
|
+
} from "./Storage"
|
|
25
|
+
import {
|
|
26
|
+
useSuccesifKeys
|
|
27
|
+
} from "./Contexte";
|
|
28
|
+
const Use={
|
|
29
|
+
useStyle,
|
|
30
|
+
useTheme,
|
|
31
|
+
useBattery,
|
|
32
|
+
useGeolocation,
|
|
33
|
+
useEventEmitter,
|
|
34
|
+
useChannel,
|
|
35
|
+
useThread,
|
|
36
|
+
useBluetooth,
|
|
37
|
+
useTitle,
|
|
38
|
+
useFavIcon,
|
|
39
|
+
useThrottle,
|
|
40
|
+
useDebounce,
|
|
41
|
+
useLocaleStorage,
|
|
42
|
+
useSessionStorage,
|
|
43
|
+
useSuccesifKeys,
|
|
44
|
+
ExtractAll: function () {
|
|
45
|
+
const keys = Object.keys(this);
|
|
46
|
+
for (let i = 0; i < keys.length; i++) {
|
|
47
|
+
const key = keys[i];
|
|
48
|
+
if (key !== 'ExtractAll' && key !== 'RemoveAll') {
|
|
49
|
+
globalThis[key] = this[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
},
|
|
54
|
+
RemoveAll: function () {
|
|
55
|
+
const keys = Object.keys(this);
|
|
56
|
+
for (let i = 0; i < keys.length; i++) {
|
|
57
|
+
const key = keys[i];
|
|
58
|
+
if (key !== 'RemoveAll') {
|
|
59
|
+
delete globalThis[key];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export default Use;
|
|
66
|
+
export{
|
|
67
|
+
useStyle,
|
|
68
|
+
useTheme,
|
|
69
|
+
useTitle,
|
|
70
|
+
useFavIcon,
|
|
71
|
+
useBattery,
|
|
72
|
+
useGeolocation,
|
|
73
|
+
useEventEmitter,
|
|
74
|
+
useChannel,
|
|
75
|
+
useThread,
|
|
76
|
+
useBluetooth,
|
|
77
|
+
useThrottle,
|
|
78
|
+
useDebounce,
|
|
79
|
+
useLocaleStorage,
|
|
80
|
+
useSessionStorage,
|
|
81
|
+
useSuccesifKeys
|
|
82
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|