ziko 0.0.12 → 0.0.13
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 +2896 -2290
- package/dist/ziko.js +2896 -2290
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +2888 -2290
- package/package.json +39 -12
- package/src/__helpers__/index.js +41 -0
- package/src/app/accessibility/index.js +0 -0
- package/src/app/app.js +46 -0
- package/src/app/component/index.js +38 -0
- package/src/app/globals/index.js +20 -0
- package/src/app/index.js +12 -0
- package/src/app/params/index.js +40 -0
- package/src/app/router/index.js +67 -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/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/adoc.js +130 -0
- package/src/data/converter/array.js +43 -0
- package/src/data/converter/canvas.js +25 -0
- package/src/data/converter/csv.js +33 -0
- package/src/data/converter/idea.txt +10 -0
- package/src/data/converter/index.js +34 -0
- package/src/data/converter/json.js +80 -0
- package/src/data/converter/markdown.js +95 -0
- package/src/data/converter/object.js +70 -0
- package/src/data/converter/svg.js +11 -0
- package/src/data/decorators.js +0 -0
- package/src/data/index.js +74 -0
- package/src/data/parser/markdown.js +0 -0
- package/src/data/parser/xml.js +47 -0
- package/src/data/string/index.js +1 -0
- package/src/data/string/patterns.js +12 -0
- package/src/data/string/string.js +170 -0
- package/src/graphics/canvas/_canvas_offscreen +0 -0
- package/src/graphics/canvas/canvas.js +189 -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/index.js +15 -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/index.js +69 -0
- package/src/graphics/svg/Elements/Basic/circle.js +26 -0
- package/src/graphics/svg/Elements/Basic/ellipse.js +21 -0
- package/src/graphics/svg/Elements/Basic/foreignObject.js +33 -0
- package/src/graphics/svg/Elements/Basic/groupe.js +29 -0
- package/src/graphics/svg/Elements/Basic/image.js +33 -0
- package/src/graphics/svg/Elements/Basic/line.js +29 -0
- package/src/graphics/svg/Elements/Basic/link.js +30 -0
- package/src/graphics/svg/Elements/Basic/path.js +59 -0
- package/src/graphics/svg/Elements/Basic/polygon.js +32 -0
- package/src/graphics/svg/Elements/Basic/polyline.js +4 -0
- package/src/graphics/svg/Elements/Basic/rect.js +43 -0
- package/src/graphics/svg/Elements/Basic/text.js +26 -0
- package/src/graphics/svg/Elements/Derived/grid.js +9 -0
- package/src/graphics/svg/Elements/ZikoSvgElement.js +46 -0
- package/src/graphics/svg/Elements/index.js +14 -0
- package/src/graphics/svg/index.js +2 -0
- package/src/graphics/svg/svg.js +115 -0
- package/src/index.js +88 -0
- package/src/math/absract.js +1 -0
- package/src/math/calculus/index.js +1 -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/complex/Fractals/julia.js +0 -0
- package/src/math/complex/index.js +203 -0
- package/src/math/const.js +3 -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/power-set.js +15 -0
- package/src/math/discret/Set/sub-set.js +10 -0
- package/src/math/discret/index.js +23 -0
- package/src/math/functions/index.js +182 -0
- package/src/math/index.js +189 -0
- package/src/math/matrix/Decomposition.js +90 -0
- package/src/math/matrix/LinearSystem.js +10 -0
- package/src/math/matrix/Matrix.js +717 -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 +29 -0
- package/src/math/utils/comparaison.js +1 -0
- package/src/math/utils/conversions.js +19 -0
- package/src/math/utils/discret.js +51 -0
- package/src/math/utils/index.js +102 -0
- package/src/math/utils/mapfun.js +50 -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/Mouse.js +230 -0
- package/src/reactivity/events/Global/Pointer.js +234 -0
- package/src/reactivity/events/Global/Swipe.js +147 -0
- package/src/reactivity/events/Global/Touch.js +0 -0
- package/src/reactivity/events/Global/Wheel.js +44 -0
- package/src/reactivity/events/Partiel/Hash.js +44 -0
- package/src/reactivity/events/Partiel/Input.js +59 -0
- package/src/reactivity/events/Partiel/Media.js +1 -0
- package/src/reactivity/events/ZikoEvent.js +91 -0
- package/src/reactivity/events/index.js +63 -0
- package/src/reactivity/hooks/Contexte/index.js +1 -0
- package/src/reactivity/hooks/Contexte/useSuccesifKeys.js +14 -0
- package/src/reactivity/hooks/Decorators/index.js +6 -0
- package/src/reactivity/hooks/Decorators/time.js +17 -0
- package/src/reactivity/hooks/Decorators/type.js +88 -0
- package/src/reactivity/hooks/Interactions/index.js +4 -0
- package/src/reactivity/hooks/Interactions/useBluetooth.js +48 -0
- package/src/reactivity/hooks/Interactions/useChannel.js +50 -0
- package/src/reactivity/hooks/Interactions/useEventEmmiter.js +64 -0
- package/src/reactivity/hooks/Interactions/useSerial.js +0 -0
- package/src/reactivity/hooks/Interactions/useThread.js +44 -0
- package/src/reactivity/hooks/Interactions/useUsb.js +0 -0
- package/src/reactivity/hooks/Sensors/index.js +2 -0
- package/src/reactivity/hooks/Sensors/useBattery.js +36 -0
- package/src/reactivity/hooks/Sensors/useCamera.js +0 -0
- package/src/reactivity/hooks/Sensors/useGeolocation.js +17 -0
- package/src/reactivity/hooks/Sensors/useMicro.js +0 -0
- package/src/reactivity/hooks/Sensors/useOrientation.js +0 -0
- package/src/reactivity/hooks/Storage/index.js +1 -0
- package/src/reactivity/hooks/Storage/useCookie.js +0 -0
- package/src/reactivity/hooks/Storage/useIndexedDb.js +0 -0
- package/src/reactivity/hooks/Storage/useStorage.js +73 -0
- package/src/reactivity/hooks/UI/index.js +5 -0
- package/src/reactivity/hooks/UI/useCssLink.js +0 -0
- package/src/reactivity/hooks/UI/useCssText.js +21 -0
- package/src/reactivity/hooks/UI/useFavIcon.js +38 -0
- package/src/reactivity/hooks/UI/useLinearGradient.js +0 -0
- package/src/reactivity/hooks/UI/useMediaQuery.js +43 -0
- package/src/reactivity/hooks/UI/useRadialGradient.js +0 -0
- package/src/reactivity/hooks/UI/useStyle.js +79 -0
- package/src/reactivity/hooks/UI/useTheme.js +62 -0
- package/src/reactivity/hooks/UI/useTitle.js +30 -0
- package/src/reactivity/hooks/index.js +85 -0
- package/src/reactivity/hooks/todo.md +26 -0
- package/src/reactivity/idea +2 -0
- package/src/reactivity/index.js +22 -0
- package/src/reactivity/observer/attributes.js +28 -0
- package/src/reactivity/observer/children.js +37 -0
- package/src/reactivity/observer/index.js +44 -0
- package/src/reactivity/observer/intersection.js +44 -0
- package/src/reactivity/observer/mutation.js +113 -0
- package/src/reactivity/observer/resize.js +47 -0
- package/src/reactivity/observer/screen.js +45 -0
- package/src/reactivity/observer/screen.js.txt +84 -0
- package/src/reactivity/observer/screen.txt +13 -0
- package/src/time/animation.js +76 -0
- package/src/time/index.js +54 -0
- package/src/time/loop.js +87 -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/user-interface/elements/derived/Flex.js +103 -0
- package/src/user-interface/elements/derived/Grid.js +33 -0
- package/src/user-interface/elements/derived/elements/Notification.js +0 -0
- package/src/user-interface/elements/derived/elements/Popover.js +0 -0
- package/src/user-interface/elements/derived/elements/Popup.js +0 -0
- package/src/user-interface/elements/derived/elements/Swipper.js +4 -0
- package/src/user-interface/elements/derived/elements/Timeline.js +0 -0
- package/src/user-interface/elements/derived/elements/Toast.js +0 -0
- package/src/user-interface/elements/derived/elements/Treeview.js +0 -0
- package/src/user-interface/elements/derived/elements/accordion/accordion.js +45 -0
- package/src/user-interface/elements/derived/elements/accordion/collapsible.js +82 -0
- package/src/user-interface/elements/derived/elements/accordion/index.js +2 -0
- package/src/user-interface/elements/derived/elements/alert/alert.js +80 -0
- package/src/user-interface/elements/derived/elements/alert/index.js +1 -0
- package/src/user-interface/elements/derived/elements/alert/palette.js +52 -0
- package/src/user-interface/elements/derived/elements/carousel/index.js +50 -0
- package/src/user-interface/elements/derived/elements/code-note/SubElements.js.txt +105 -0
- package/src/user-interface/elements/derived/elements/code-note/code-cell.js +195 -0
- package/src/user-interface/elements/derived/elements/code-note/code-note.js +72 -0
- package/src/user-interface/elements/derived/elements/code-note/index.js +2 -0
- package/src/user-interface/elements/derived/elements/code-note/sub-elements.js +67 -0
- package/src/user-interface/elements/derived/elements/columns.js +1 -0
- package/src/user-interface/elements/derived/elements/fab.js +0 -0
- package/src/user-interface/elements/derived/elements/index.js +9 -0
- package/src/user-interface/elements/derived/elements/menu/index.js +1 -0
- package/src/user-interface/elements/derived/elements/menu/menu3d.js +260 -0
- package/src/user-interface/elements/derived/elements/modal/index.js +92 -0
- package/src/user-interface/elements/derived/elements/pagination/breadcrumbs.js +54 -0
- package/src/user-interface/elements/derived/elements/pagination/index.js +1 -0
- package/src/user-interface/elements/derived/elements/splitter/__ZikoUISplitter__.js +62 -0
- package/src/user-interface/elements/derived/elements/splitter/hsplitter.js +40 -0
- package/src/user-interface/elements/derived/elements/splitter/index.js +2 -0
- package/src/user-interface/elements/derived/elements/splitter/vsplitter.js +40 -0
- package/src/user-interface/elements/derived/elements/tabs/index.js +180 -0
- package/src/user-interface/elements/derived/index.js +3 -0
- package/src/user-interface/elements/primitives/ZikoUIContainerElement.js +127 -0
- package/src/user-interface/elements/primitives/ZikoUIElement.js +478 -0
- package/src/user-interface/elements/primitives/embaded/index.js +1 -0
- package/src/user-interface/elements/primitives/index.js +8 -0
- package/src/user-interface/elements/primitives/io/Form/index.js +42 -0
- package/src/user-interface/elements/primitives/io/Form/index.js.txt +104 -0
- package/src/user-interface/elements/primitives/io/Inputs/__helpers__.js +52 -0
- package/src/user-interface/elements/primitives/io/Inputs/index.js +12 -0
- package/src/user-interface/elements/primitives/io/Inputs/input/index.js +98 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-camera/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-checkbox/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-color/index.js +16 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/index.js +3 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-date-time.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-date.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-time.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/index.js +2 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/input-email.js +15 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/input-password.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/index.js +1 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/input-file.js +0 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/input-image.js +43 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-number/index.js +37 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-radio/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-search/index.js +45 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-slider/index.js +34 -0
- package/src/user-interface/elements/primitives/io/Select/index.js +20 -0
- package/src/user-interface/elements/primitives/io/Textarea/index.js +18 -0
- package/src/user-interface/elements/primitives/io/index.js +4 -0
- package/src/user-interface/elements/primitives/list/elements.js +0 -0
- package/src/user-interface/elements/primitives/list/index.js +139 -0
- package/src/user-interface/elements/primitives/media/Audio/index.js +17 -0
- package/src/user-interface/elements/primitives/media/Image/figure.js +19 -0
- package/src/user-interface/elements/primitives/media/Image/image.js +36 -0
- package/src/user-interface/elements/primitives/media/Image/index.js +2 -0
- package/src/user-interface/elements/primitives/media/Video/index.js +27 -0
- package/src/user-interface/elements/primitives/media/__ZikoUIDynamicMediaELement__.js +47 -0
- package/src/user-interface/elements/primitives/media/index.js +3 -0
- package/src/user-interface/elements/primitives/misc/index.js +99 -0
- package/src/user-interface/elements/primitives/semantic/index.js +82 -0
- package/src/user-interface/elements/primitives/table/elements.js +94 -0
- package/src/user-interface/elements/primitives/table/index.js +3 -0
- package/src/user-interface/elements/primitives/table/table.js +115 -0
- package/src/user-interface/elements/primitives/table/utils.js +12 -0
- package/src/user-interface/elements/primitives/text/__ZikoUIText__.js +71 -0
- package/src/user-interface/elements/primitives/text/heading.js +36 -0
- package/src/user-interface/elements/primitives/text/index.js +3 -0
- package/src/user-interface/elements/primitives/text/p.js +26 -0
- package/src/user-interface/elements/primitives/text/pre.js +0 -0
- package/src/user-interface/elements/primitives/text/text.js +81 -0
- package/src/user-interface/index.js +188 -0
- package/src/user-interface/style/index.js +510 -0
- package/src/user-interface/utils/index.js +70 -0
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const useDebounce=(fn,delay=1000)=>{
|
|
2
|
+
let id;
|
|
3
|
+
return(...args)=>id?clearTimeout(id):setTimeout(()=>fn(...args),delay)
|
|
4
|
+
}
|
|
5
|
+
const useThrottle=(fn,delay)=>{
|
|
6
|
+
let lastTime=0;
|
|
7
|
+
return (...args)=>{
|
|
8
|
+
const now=new Date().getTime()
|
|
9
|
+
if(now-lastTime<delay)return;
|
|
10
|
+
lastTime=now;
|
|
11
|
+
fn(...args);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export{
|
|
15
|
+
useDebounce,
|
|
16
|
+
useThrottle
|
|
17
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
function useType(func, ...expectedTypes) {
|
|
2
|
+
const argNames = func.toString()
|
|
3
|
+
.match(/\(([^)]*)\)/)[1]
|
|
4
|
+
.split(',')
|
|
5
|
+
.map(arg => arg.trim());
|
|
6
|
+
return function(...args) {
|
|
7
|
+
const lastExpectedType = expectedTypes[expectedTypes.length - 1];
|
|
8
|
+
for (let i = 0; i < args.length; i++) {
|
|
9
|
+
const isRestParam = i >= expectedTypes.length;
|
|
10
|
+
const expectedType = isRestParam ? lastExpectedType : expectedTypes[i];
|
|
11
|
+
const arg = args[i];
|
|
12
|
+
const argName = isRestParam ? `${argNames[argNames.length - 1]}[${i - expectedTypes.length + 1}]` : argNames[i] || `Argument ${i + 1}`;
|
|
13
|
+
let isValid = false;
|
|
14
|
+
if(typeof expectedType === "object"){
|
|
15
|
+
if (expectedType.or) {
|
|
16
|
+
for (const type of expectedType.types) {
|
|
17
|
+
if (checkTypeOrInstance(type, arg)) {
|
|
18
|
+
isValid = true;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (expectedType.nor) {
|
|
24
|
+
for (const type of expectedType.types) {
|
|
25
|
+
if (checkTypeOrInstance(type, arg)) {
|
|
26
|
+
isValid = false;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
isValid = true
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (expectedType.not) isValid = !checkTypeOrInstance(expectedType.type, arg);
|
|
33
|
+
}
|
|
34
|
+
else isValid = checkTypeOrInstance(expectedType, arg);
|
|
35
|
+
// Should Fix Nor error Message
|
|
36
|
+
if (!isValid) {
|
|
37
|
+
// const expectedTypeName = typeof expectedType === 'object'
|
|
38
|
+
// ? expectedType.or
|
|
39
|
+
// ? expectedType.types.map(type => (typeof type === 'string' ? type : type.name)).join(' or ')
|
|
40
|
+
// : expectedType.not
|
|
41
|
+
// ? `not ${typeof expectedType.type === 'string' ? expectedType.type : expectedType.type.name}`
|
|
42
|
+
// : Array.isArray(expectedType)
|
|
43
|
+
// ? `[${expectedType.map(type => (typeof type === 'string' ? type : type.name)).join(', ')}]`
|
|
44
|
+
// : `{${Object.entries(expectedType).map(([key, type]) => `${key}: ${typeof type === 'string' ? type : type.name}`).join(', ')}}`
|
|
45
|
+
// : typeof expectedType === 'string'
|
|
46
|
+
// ? expectedType
|
|
47
|
+
// : expectedType.name;
|
|
48
|
+
// throw new TypeError(`${argName} should be of type ${expectedTypeName}`);
|
|
49
|
+
throw new TypeError("jjj")
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return func(...args);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function useOr(...types) {
|
|
57
|
+
return { or: true, types };
|
|
58
|
+
}
|
|
59
|
+
function useNot(type) {
|
|
60
|
+
return { not: true, type };
|
|
61
|
+
}
|
|
62
|
+
function useNor(...types){
|
|
63
|
+
return { nor: true, types}
|
|
64
|
+
}
|
|
65
|
+
const checkTypeOrInstance = (type, arg) => {
|
|
66
|
+
if (typeof type === 'string') return typeof arg === type;
|
|
67
|
+
else if (type instanceof Function) return arg instanceof type;
|
|
68
|
+
else if (Array.isArray(type))
|
|
69
|
+
return (!Array.isArray(arg) || arg.length !== type.length)? false: arg.every((item, index) => checkTypeOrInstance(type[index], item));
|
|
70
|
+
else if (typeof type === 'object' && !Array.isArray(type))
|
|
71
|
+
return (typeof arg !== 'object' || arg === null)? false : Object.keys(type).every(key => key in arg && checkTypeOrInstance(type[key], arg[key]))
|
|
72
|
+
return false;
|
|
73
|
+
};
|
|
74
|
+
// globalThis.useType = useType
|
|
75
|
+
// globalThis.useNot = useNot
|
|
76
|
+
// globalThis.useOr = useOr
|
|
77
|
+
|
|
78
|
+
// function add(a, b = 0){
|
|
79
|
+
// return a+b
|
|
80
|
+
// }
|
|
81
|
+
|
|
82
|
+
// add = useType(add,"number",useNor("string","number"))
|
|
83
|
+
|
|
84
|
+
// console.log(add(1))
|
|
85
|
+
|
|
86
|
+
export{
|
|
87
|
+
useType
|
|
88
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useEventEmitter } from "./useEventEmmiter";
|
|
2
|
+
class ZikoUseBluetooth{
|
|
3
|
+
constructor(options={acceptAllDevices:true}){
|
|
4
|
+
this.options=options;
|
|
5
|
+
this.__Emitter__=useEventEmitter();
|
|
6
|
+
if(this.isSupported)this.#init();
|
|
7
|
+
}
|
|
8
|
+
async #init(){
|
|
9
|
+
this.promise=navigator.bluetooth.requestDevice(this.options).then(device=>this.device=device)
|
|
10
|
+
}
|
|
11
|
+
get isSupported(){
|
|
12
|
+
return !!navigator.bluetooth;
|
|
13
|
+
}
|
|
14
|
+
get current(){
|
|
15
|
+
// Synchrouns Code
|
|
16
|
+
return this.device;
|
|
17
|
+
}
|
|
18
|
+
connect(){
|
|
19
|
+
this.server=this.device.gatt.connect();
|
|
20
|
+
this.__Emitter__.emit("ziko:bluetooth-connected");
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
disconnect(){
|
|
24
|
+
this.device.gatt.disconnect();
|
|
25
|
+
this.__Emitter__.emit("ziko:bluetooth-disconnected");
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
onConnect(callback){
|
|
29
|
+
this.__Emitter__.on("ziko:bluetooth-connected",callback);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
onDisconnect(callback){
|
|
33
|
+
this.__Emitter__.on("ziko:bluetooth-disconnected",callback);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
dispose(){
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
async battery(callback){
|
|
40
|
+
const batteryService = await this.server.getPrimaryService("battery_service");
|
|
41
|
+
const batteryLevelCharacteristic = await batteryService.getCharacteristic("battery_level");
|
|
42
|
+
const batteryLevel = await batteryLevelCharacteristic.readValue();
|
|
43
|
+
const batteryPercent = await batteryLevel.getUint8(0);
|
|
44
|
+
callback(batteryPercent)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const useBluetooth=(options)=>new ZikoUseBluetooth(options);
|
|
48
|
+
export{ useBluetooth }
|
|
@@ -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,73 @@
|
|
|
1
|
+
// To do : remove old items
|
|
2
|
+
import { useChannel } from "../Interactions";
|
|
3
|
+
class ZikoUseStorage{
|
|
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 ZikoUseStorage(localStorage,key,initialValue);
|
|
69
|
+
const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
|
|
70
|
+
export{
|
|
71
|
+
useLocaleStorage,
|
|
72
|
+
useSessionStorage
|
|
73
|
+
}
|
|
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?.createElementt('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,43 @@
|
|
|
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 ZikoUseMediaQuery {
|
|
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 ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
41
|
+
export {
|
|
42
|
+
useMediaQuery
|
|
43
|
+
};
|
|
File without changes
|