ziko 0.33.0 → 0.34.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/dist/ziko.cjs +2440 -3447
- package/dist/ziko.js +8192 -9199
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +2423 -3424
- package/package.json +4 -6
- package/src/__helpers__/index.js +19 -18
- package/src/app/index.js +0 -3
- package/src/events/__Events__.js +18 -8
- package/src/events/pointer.js +1 -1
- package/src/index.js +9 -3
- package/src/math/functions/index.js +6 -9
- package/src/math/index.js +0 -7
- package/src/math/matrix/Matrix.js +1 -50
- package/src/math/matrix/index.js +1 -3
- package/src/math/signal/index.js +1 -110
- package/src/math/statistics/index.js +2 -2
- package/src/reactivity/events/index.js +8 -8
- package/src/reactivity/hooks/Head/useFavIcon.js +2 -2
- package/src/reactivity/hooks/Head/useTitle.js +1 -1
- package/src/reactivity/hooks/index.js +3 -3
- package/src/ui/elements/ZikoUIElement.js +34 -176
- package/src/ui/elements/semantic/index.js +33 -73
- package/src/ui/methods/events.js +39 -0
- package/src/use/decorators/index.js +2 -0
- package/src/use/decorators/use-debounce.js +4 -0
- package/src/use/decorators/use-throttle.js +9 -0
- package/src/use/index.js +3 -0
- package/src/use/interactions/index.js +3 -0
- package/src/{reactivity/hooks/Interactions/useChannel.js → use/interactions/use-channel.js} +8 -8
- package/src/{reactivity/hooks/Storage/useStorage.js → use/storage/index.js} +2 -2
- package/src/app/json-style-sheet.js +0 -64
- package/src/compose.js +0 -89
- package/src/math/calculus/derivation/index.js +0 -7
- package/src/math/calculus/index.js +0 -2
- package/src/math/calculus/special-functions/bessel.js +0 -31
- package/src/math/calculus/special-functions/beta.js +0 -38
- package/src/math/calculus/special-functions/gamma.js +0 -30
- package/src/math/calculus/special-functions/index.js +0 -4
- package/src/math/matrix/Decomposition.js +0 -90
- package/src/math/matrix/LinearSystem.js +0 -10
- package/src/math/signal/__np.py.txt +0 -40
- package/src/math/signal/conv.js +0 -175
- package/src/math/signal/fft.js +0 -55
- package/src/math/signal/filter.js +0 -39
- package/src/reactivity/events/Pointer.js +0 -232
- package/src/reactivity/events/click.js +0 -102
- package/src/reactivity/events/clipboard.js +0 -88
- package/src/reactivity/events/drag.js +0 -137
- package/src/reactivity/events/focus.js +0 -59
- package/src/reactivity/events/key.js +0 -102
- package/src/reactivity/events/wheel.js +0 -47
- package/src/reactivity/hooks/Decorators/index.js +0 -6
- package/src/reactivity/hooks/Decorators/time.js +0 -17
- package/src/reactivity/hooks/Decorators/type.js +0 -88
- package/src/reactivity/hooks/Interactions/_useBluetooth.js +0 -48
- package/src/reactivity/hooks/Interactions/index.js +0 -4
- package/src/reactivity/hooks/Sensors ( To Be Moved )/index.js +0 -2
- package/src/reactivity/hooks/Sensors ( To Be Moved )/useBattery.js +0 -36
- package/src/reactivity/hooks/Sensors ( To Be Moved )/useGeolocation.js +0 -17
- package/src/reactivity/hooks/Storage/index.js +0 -1
- package/src/reactivity/hooks/Storage/useCookie.js +0 -0
- package/src/reactivity/hooks/Storage/useIndexedDb.js +0 -0
- /package/src/events/{index.d.ts → index.d.ts.txt} +0 -0
- /package/src/math/statistics/{Functions → functions}/index.js +0 -0
- /package/src/{math/numeric → use/app}/index.js +0 -0
- /package/src/{reactivity/hooks/Interactions/useUsb.js → use/app/use-favicon.js} +0 -0
- /package/src/{reactivity/hooks/Sensors ( To Be Moved )/useCamera.js → use/app/use-link.js} +0 -0
- /package/src/{reactivity/hooks/Sensors ( To Be Moved )/useMicro.js → use/app/use-meta.js} +0 -0
- /package/src/{reactivity/hooks/Sensors ( To Be Moved )/useOrientation.js → use/app/use-title.js} +0 -0
- /package/src/{reactivity/hooks/Interactions/useEventEmmiter.js → use/interactions/use-event-emmiter.js} +0 -0
- /package/src/{reactivity/hooks/Interactions/useThread.js → use/interactions/use-thread.js} +0 -0
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import { compose } from "../../__helpers__/index.js";
|
|
2
2
|
import { DomMethods } from "../methods/dom.js";
|
|
3
3
|
import { IndexingMethods } from "../methods/indexing.js";
|
|
4
|
+
import { EventsMethodes } from "../methods/events.js";
|
|
4
5
|
import { ZikoUseStyle } from "../../reactivity/hooks/UI/useStyle.js";
|
|
5
6
|
import { ZikoUIElementStyle } from "../style/index.js";
|
|
6
7
|
import {
|
|
7
|
-
usePointerEvent,
|
|
8
|
-
useMouseEvent,
|
|
9
|
-
useWheelEvent,
|
|
10
|
-
useKeyEvent,
|
|
11
|
-
useDragEvent ,
|
|
12
|
-
useDropEvent,
|
|
13
|
-
useClickEvent ,
|
|
14
|
-
useClipboardEvent ,
|
|
15
|
-
useFocusEvent,
|
|
16
8
|
useCustomEvent,
|
|
17
9
|
useSwipeEvent,
|
|
18
10
|
watchIntersection,
|
|
@@ -22,7 +14,6 @@ import {
|
|
|
22
14
|
} from "../../reactivity/index.js"
|
|
23
15
|
import { Random } from "../../math/index.js";
|
|
24
16
|
import { Str } from "../../data/index.js";
|
|
25
|
-
// import { text } from "./text/text.js";
|
|
26
17
|
class ZikoUIElement {
|
|
27
18
|
constructor(element, name="", {el_type="html", useDefaultStyle=false}={}){
|
|
28
19
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
@@ -40,8 +31,14 @@ class ZikoUIElement {
|
|
|
40
31
|
compose(
|
|
41
32
|
this,
|
|
42
33
|
DomMethods,
|
|
43
|
-
IndexingMethods
|
|
34
|
+
IndexingMethods,
|
|
35
|
+
EventsMethodes
|
|
44
36
|
)
|
|
37
|
+
// if(false){
|
|
38
|
+
// import("../methods/tree.js").then(({ default: ExternalMethods }) => {
|
|
39
|
+
// compose(this, ExternalMethods);
|
|
40
|
+
// });
|
|
41
|
+
// }
|
|
45
42
|
this.cache = {
|
|
46
43
|
name,
|
|
47
44
|
parent:null,
|
|
@@ -85,7 +82,7 @@ class ZikoUIElement {
|
|
|
85
82
|
});
|
|
86
83
|
this.items = [];
|
|
87
84
|
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
88
|
-
element && globalThis.__Ziko__.__Config__.default.render && this
|
|
85
|
+
element && globalThis.__Ziko__.__Config__.default.render && this?.render?.()
|
|
89
86
|
if(
|
|
90
87
|
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
91
88
|
// &&
|
|
@@ -327,161 +324,22 @@ class ZikoUIElement {
|
|
|
327
324
|
get id() {
|
|
328
325
|
return this.element.getAttribute("id");
|
|
329
326
|
}
|
|
330
|
-
onPtrMove(...callbacks){
|
|
331
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
332
|
-
this.events.ptr.onMove(...callbacks);
|
|
333
|
-
return this;
|
|
334
|
-
}
|
|
335
|
-
onPtrDown(...callbacks){
|
|
336
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
337
|
-
this.events.ptr.onDown(...callbacks);
|
|
338
|
-
return this;
|
|
339
|
-
}
|
|
340
|
-
onPtrUp(...callbacks){
|
|
341
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
342
|
-
this.events.ptr.onUp(...callbacks);
|
|
343
|
-
return this;
|
|
344
|
-
}
|
|
345
|
-
onPtrEnter(...callbacks){
|
|
346
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
347
|
-
this.events.ptr.onEnter(...callbacks);
|
|
348
|
-
return this;
|
|
349
|
-
}
|
|
350
|
-
onPtrLeave(...callbacks){
|
|
351
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
352
|
-
this.events.ptr.onLeave(...callbacks);
|
|
353
|
-
return this;
|
|
354
|
-
}
|
|
355
|
-
onPtrOut(...callbacks){
|
|
356
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
357
|
-
this.events.ptr.onOut(...callbacks);
|
|
358
|
-
return this;
|
|
359
|
-
}
|
|
360
|
-
onPtrCancel(...callbacks){
|
|
361
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
362
|
-
this.events.ptr.onCancel(...callbacks);
|
|
363
|
-
return this;
|
|
364
|
-
}
|
|
365
327
|
onSwipe(width_threshold, height_threshold,...callbacks){
|
|
366
328
|
if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
367
329
|
this.events.swipe.onSwipe(...callbacks);
|
|
368
330
|
return this;
|
|
369
331
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
|
|
382
|
-
this.events.mouse.onUp(...callbacks);
|
|
383
|
-
return this;
|
|
384
|
-
}
|
|
385
|
-
onMouseEnter(...callbacks){
|
|
386
|
-
if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
|
|
387
|
-
this.events.mouse.onEnter(...callbacks);
|
|
388
|
-
return this;
|
|
389
|
-
}
|
|
390
|
-
onMouseLeave(...callbacks){
|
|
391
|
-
if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
|
|
392
|
-
this.events.mouse.onLeave(...callbacks);
|
|
393
|
-
return this;
|
|
394
|
-
}
|
|
395
|
-
onMouseOut(...callbacks){
|
|
396
|
-
if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
|
|
397
|
-
this.events.mouse.onOut(...callbacks);
|
|
398
|
-
return this;
|
|
399
|
-
}
|
|
400
|
-
onWheel(...callbacks){
|
|
401
|
-
if(!this.events.wheel)this.events.wheel = useWheelEvent(this);
|
|
402
|
-
this.events.wheel.onWheel(...callbacks);
|
|
403
|
-
return this;
|
|
404
|
-
}
|
|
405
|
-
onKeyDown(...callbacks){
|
|
406
|
-
if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
407
|
-
this.events.key.onDown(...callbacks);
|
|
408
|
-
return this;
|
|
409
|
-
}
|
|
410
|
-
onKeyPress(...callbacks){
|
|
411
|
-
if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
412
|
-
this.events.key.onPress(...callbacks);
|
|
413
|
-
return this;
|
|
414
|
-
}
|
|
415
|
-
onKeyUp(...callbacks){
|
|
416
|
-
if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
417
|
-
this.events.key.onUp(...callbacks);
|
|
418
|
-
return this;
|
|
419
|
-
}
|
|
420
|
-
onKeysDown({keys=[],callback}={}){
|
|
421
|
-
if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
422
|
-
this.events.key.handleSuccessifKeys({keys,callback});
|
|
423
|
-
return this;
|
|
424
|
-
}
|
|
425
|
-
onDragStart(...callbacks){
|
|
426
|
-
if(!this.events.drag)this.events.drag = useDragEvent(this);
|
|
427
|
-
this.events.drag.onStart(...callbacks);
|
|
428
|
-
return this;
|
|
429
|
-
}
|
|
430
|
-
onDrag(...callbacks){
|
|
431
|
-
if(!this.events.drag)this.events.drag = useDragEvent(this);
|
|
432
|
-
this.events.drag.onDrag(...callbacks);
|
|
433
|
-
return this;
|
|
434
|
-
}
|
|
435
|
-
onDragEnd(...callbacks){
|
|
436
|
-
if(!this.events.drag)this.events.drag = useDragEvent(this);
|
|
437
|
-
this.events.drag.onEnd(...callbacks);
|
|
438
|
-
return this;
|
|
439
|
-
}
|
|
440
|
-
onDrop(...callbacks){
|
|
441
|
-
if(!this.events.drop)this.events.drop = useDropEvent(this);
|
|
442
|
-
this.events.drop.onDrop(...callbacks);
|
|
443
|
-
return this;
|
|
444
|
-
}
|
|
445
|
-
onClick(...callbacks){
|
|
446
|
-
if(!this.events.click)this.events.click = useClickEvent(this);
|
|
447
|
-
this.events.click.onClick(...callbacks);
|
|
448
|
-
return this;
|
|
449
|
-
}
|
|
450
|
-
onDbClick(...callbacks){
|
|
451
|
-
if(!this.events.click)this.events.click = useClickEvent(this);
|
|
452
|
-
this.events.click.onDbClick(...callbacks);
|
|
453
|
-
return this;
|
|
454
|
-
}
|
|
455
|
-
onCopy(...callbacks){
|
|
456
|
-
if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
457
|
-
this.events.clipboard.onCopy(...callbacks);
|
|
458
|
-
return this;
|
|
459
|
-
}
|
|
460
|
-
onCut(...callbacks){
|
|
461
|
-
if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
462
|
-
this.events.clipboard.onCut(...callbacks);
|
|
463
|
-
return this;
|
|
464
|
-
}
|
|
465
|
-
onPaste(...callbacks){
|
|
466
|
-
if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
467
|
-
this.events.clipboard.onPaste(...callbacks);
|
|
468
|
-
return this;
|
|
469
|
-
}
|
|
470
|
-
onSelect(...callbacks){
|
|
471
|
-
if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
472
|
-
this.events.clipboard.onSelect(...callbacks);
|
|
473
|
-
return this;
|
|
474
|
-
}
|
|
475
|
-
onFocus(...callbacks){
|
|
476
|
-
if(!this.events.focus)this.events.focus = useFocusEvent(this);
|
|
477
|
-
this.events.focus.onFocus(...callbacks);
|
|
478
|
-
return this;
|
|
479
|
-
}
|
|
480
|
-
onBlur(...callbacks){
|
|
481
|
-
if(!this.events.focus)this.events.focus = useFocusEvent(this);
|
|
482
|
-
this.events.focus.onFocus(...callbacks);
|
|
483
|
-
return this;
|
|
484
|
-
}
|
|
332
|
+
// To Fix
|
|
333
|
+
// onKeysDown({keys=[],callback}={}){
|
|
334
|
+
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
335
|
+
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
336
|
+
// return this;
|
|
337
|
+
// }
|
|
338
|
+
// onSelect(...callbacks){
|
|
339
|
+
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
340
|
+
// this.events.clipboard.onSelect(...callbacks);
|
|
341
|
+
// return this;
|
|
342
|
+
// }
|
|
485
343
|
on(event_name,...callbacks){
|
|
486
344
|
if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
487
345
|
this.events.custom.on(event_name,...callbacks);
|
|
@@ -510,19 +368,19 @@ class ZikoUIElement {
|
|
|
510
368
|
this.observer.intersection.start();
|
|
511
369
|
return this;
|
|
512
370
|
}
|
|
513
|
-
setFullScreen(set = true, e) {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
toggleFullScreen(e) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
371
|
+
// setFullScreen(set = true, e) {
|
|
372
|
+
// if(!this.element.requestFullscreen){
|
|
373
|
+
// console.error("Fullscreen API is not supported in this browser.");
|
|
374
|
+
// return this;
|
|
375
|
+
// }
|
|
376
|
+
// if (set) this.element.requestFullscreen(e);
|
|
377
|
+
// else globalThis.document.exitFullscreen();
|
|
378
|
+
// return this;
|
|
379
|
+
// }
|
|
380
|
+
// toggleFullScreen(e) {
|
|
381
|
+
// if (!globalThis.document.fullscreenElement) this.element.requestFullscreen(e);
|
|
382
|
+
// else globalThis.document.exitFullscreen();
|
|
383
|
+
// return this;
|
|
384
|
+
// }
|
|
527
385
|
}
|
|
528
386
|
export default ZikoUIElement;
|
|
@@ -1,82 +1,42 @@
|
|
|
1
|
-
import ZikoUIElement from "../ZikoUIElement";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class
|
|
11
|
-
constructor(){
|
|
12
|
-
super(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
class ZikoUISection extends ZikoUIElement{
|
|
27
|
-
constructor(){
|
|
28
|
-
super("section","Section");
|
|
29
|
-
this.style({position:"relative"})
|
|
30
|
-
}
|
|
31
|
-
get isSection(){
|
|
32
|
-
return true
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
class ZikoUIArticle extends ZikoUIElement{
|
|
36
|
-
constructor(){
|
|
37
|
-
super("article","Article");
|
|
38
|
-
}
|
|
39
|
-
get isArticle(){
|
|
40
|
-
return true
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
class ZikoUIAside extends ZikoUIElement{
|
|
44
|
-
constructor(){
|
|
45
|
-
super("aside","Aside");
|
|
46
|
-
}
|
|
47
|
-
get isAside(){
|
|
48
|
-
return true
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
class ZikoUIFooter extends ZikoUIElement{
|
|
52
|
-
constructor(){
|
|
53
|
-
super("footer","Footer");
|
|
54
|
-
this.element=document?.createElement("footer");
|
|
55
|
-
}
|
|
56
|
-
get isFooter(){
|
|
57
|
-
return true
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const Section = (...ZikoUIElement) => new ZikoUISection().append(...ZikoUIElement);
|
|
61
|
-
const Article = (...ZikoUIElement) => new ZikoUIArticle().append(...ZikoUIElement);
|
|
62
|
-
const Main = (...ZikoUIElement) => new ZikoUIMain().append(...ZikoUIElement);
|
|
63
|
-
const Header = (...ZikoUIElement) => new ZikoUIHeader().append(...ZikoUIElement);
|
|
64
|
-
const Footer = (...ZikoUIElement) => new ZikoUIFooter().append(...ZikoUIElement);
|
|
65
|
-
const Nav = (...ZikoUIElement) => new ZikoUINav().append(...ZikoUIElement);
|
|
66
|
-
const Aside = (...ZikoUIElement) => new ZikoUIAside().append(...ZikoUIElement);
|
|
67
|
-
export{
|
|
68
|
-
Header,
|
|
1
|
+
import ZikoUIElement from "../ZikoUIElement.js";
|
|
2
|
+
const elements = ['Main', 'Header', 'Nav', 'Section', 'Article', 'Aside', 'Footer']
|
|
3
|
+
|
|
4
|
+
// Storage for Classes and component functions
|
|
5
|
+
const Classes = {};
|
|
6
|
+
const Components = {};
|
|
7
|
+
|
|
8
|
+
// Auto-generate Classes and factory functions
|
|
9
|
+
for (let i=0; i<elements.length; i++) {
|
|
10
|
+
Classes[`ZikoUI${elements[i]}`] = class extends ZikoUIElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(elements[i].toLowerCase());
|
|
13
|
+
this.style({ position: "relative" });
|
|
14
|
+
}
|
|
15
|
+
get [`is${elements[i]}`]() {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
Components[elements[i]] = (...children) =>
|
|
21
|
+
new Classes[`ZikoUI${elements[i]}`]().append(...children);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const {
|
|
69
25
|
Main,
|
|
26
|
+
Header,
|
|
27
|
+
Nav,
|
|
70
28
|
Section,
|
|
71
29
|
Article,
|
|
72
30
|
Aside,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
31
|
+
Footer
|
|
32
|
+
} = Components;
|
|
33
|
+
|
|
34
|
+
export const {
|
|
76
35
|
ZikoUIMain,
|
|
36
|
+
ZikoUIHeader,
|
|
37
|
+
ZikoUINav,
|
|
77
38
|
ZikoUISection,
|
|
78
39
|
ZikoUIArticle,
|
|
79
40
|
ZikoUIAside,
|
|
80
|
-
ZikoUINav,
|
|
81
41
|
ZikoUIFooter
|
|
82
|
-
}
|
|
42
|
+
} = Classes;
|
package/src/ui/methods/events.js
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Events } from "../../events/__Events__";
|
|
2
|
+
import {
|
|
3
|
+
bindPointerEvent,
|
|
4
|
+
bindMouseEvent,
|
|
5
|
+
bindKeyEvent,
|
|
6
|
+
bindClickEvent,
|
|
7
|
+
bindDragEvent,
|
|
8
|
+
bindClipboardEvent,
|
|
9
|
+
bindFocusEvent,
|
|
10
|
+
bindWheelEvent
|
|
11
|
+
} from "../../events/index.js";
|
|
12
|
+
|
|
13
|
+
const binderMap = {
|
|
14
|
+
ptr: bindPointerEvent,
|
|
15
|
+
mouse : bindMouseEvent,
|
|
16
|
+
key: bindKeyEvent,
|
|
17
|
+
click : bindClickEvent,
|
|
18
|
+
drag : bindDragEvent,
|
|
19
|
+
clipboard : bindClipboardEvent,
|
|
20
|
+
focus : bindFocusEvent,
|
|
21
|
+
wheel : bindWheelEvent
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const EventsMethodes = {};
|
|
25
|
+
|
|
26
|
+
Object.entries(Events).forEach(([name, eventList]) => {
|
|
27
|
+
eventList.forEach(event => {
|
|
28
|
+
const methodName = `on${event}`;
|
|
29
|
+
EventsMethodes[methodName] = function (...callbacks) {
|
|
30
|
+
if (!this.events[name]) this.events[name] = binderMap[name.toLowerCase()](this);
|
|
31
|
+
this.events[name][methodName](...callbacks);
|
|
32
|
+
return this;
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export {EventsMethodes}
|
package/src/use/index.js
ADDED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Random } from "
|
|
1
|
+
import { Random } from "../../math/random/index.js";
|
|
2
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="";
|
|
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
8
|
this.UUID="ziko-channel"+Random.string(10);
|
|
9
|
-
this.SUBSCRIBERS=new Set([this.UUID]);
|
|
9
|
+
this.SUBSCRIBERS = new Set([this.UUID]);
|
|
10
10
|
}
|
|
11
11
|
get broadcast(){
|
|
12
12
|
// update receiver
|
|
@@ -46,5 +46,5 @@ class ZikoUseChannel{
|
|
|
46
46
|
return this;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
const useChannel=name=>new ZikoUseChannel(name);
|
|
49
|
+
const useChannel = name => new ZikoUseChannel(name);
|
|
50
50
|
export{ useChannel }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// To do : remove old items
|
|
2
|
-
import { useChannel } from "../
|
|
2
|
+
import { useChannel } from "../interactions/use-channel.js";
|
|
3
3
|
class ZikoUseStorage{
|
|
4
|
-
constructor(storage,globalKey,initialValue){
|
|
4
|
+
constructor(storage, globalKey, initialValue){
|
|
5
5
|
this.cache={
|
|
6
6
|
storage,
|
|
7
7
|
globalKey,
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { json2css } from "../data/index.js";
|
|
2
|
-
class ZikoJsonStyleSheet{
|
|
3
|
-
constructor(JsonStyle={}){
|
|
4
|
-
this.cache={
|
|
5
|
-
JsonStyle,
|
|
6
|
-
isRenderd : false
|
|
7
|
-
}
|
|
8
|
-
this.target = globalThis?.document?.head;
|
|
9
|
-
this.element = document.createElement("style");
|
|
10
|
-
this.element.setAttribute("data-generator","zikojs");
|
|
11
|
-
this.write();
|
|
12
|
-
this.render()
|
|
13
|
-
}
|
|
14
|
-
get CssText(){
|
|
15
|
-
return json2css(this.cache.JsonStyle);
|
|
16
|
-
}
|
|
17
|
-
render(){
|
|
18
|
-
this.target.append(this.element);
|
|
19
|
-
this.cache.isRenderd = true;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
unrender(){
|
|
23
|
-
if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
24
|
-
this.cache.isRenderd = false;
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
write(){
|
|
28
|
-
this.element.textContent = this.CssText;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
style(styles, overwrite = false){
|
|
32
|
-
if(overwrite) this.clear();
|
|
33
|
-
Object.assign(this.cache.JsonStyle,styles);
|
|
34
|
-
this.write();
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
clear(){
|
|
38
|
-
this.cache.JsonStyle = {}
|
|
39
|
-
this.write();
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
// overrideGlobal(style){
|
|
43
|
-
// if(this.cache.JsonStyle["*"]){
|
|
44
|
-
// Object.assign(this.cache.JsonStyle["*"],style);
|
|
45
|
-
// }
|
|
46
|
-
// else Object.assign();
|
|
47
|
-
// this.write();
|
|
48
|
-
// return this;
|
|
49
|
-
// }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const jsonStyleSheet = JsonStyle =>new ZikoJsonStyleSheet(JsonStyle);
|
|
53
|
-
export {
|
|
54
|
-
jsonStyleSheet,
|
|
55
|
-
ZikoJsonStyleSheet
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// p().style({color:"red"})
|
|
60
|
-
// jsonStyleSheet({
|
|
61
|
-
// p:{
|
|
62
|
-
// color : "green !important"
|
|
63
|
-
// }
|
|
64
|
-
// })
|
package/src/compose.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
function composeInstance(instance, mixin) {
|
|
2
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
3
|
-
|
|
4
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
5
|
-
const desc = descriptors[key];
|
|
6
|
-
|
|
7
|
-
if ('get' in desc || 'set' in desc) {
|
|
8
|
-
Object.defineProperty(instance, key, desc);
|
|
9
|
-
} else if (typeof desc.value === 'function') {
|
|
10
|
-
instance[key] = desc.value.bind(instance); // override-safe
|
|
11
|
-
} else {
|
|
12
|
-
instance[key] = desc.value;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function composeClass(Base, mixin) {
|
|
18
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
19
|
-
|
|
20
|
-
return class extends Base {
|
|
21
|
-
constructor(...args) {
|
|
22
|
-
super(...args);
|
|
23
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
24
|
-
const desc = descriptors[key];
|
|
25
|
-
if (typeof desc.value === 'function') {
|
|
26
|
-
this[key] = desc.value.bind(this); // override-safe
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function defineAccessorsAndData(proto, mixin) {
|
|
35
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
36
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
37
|
-
const desc = descriptors[key];
|
|
38
|
-
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
39
|
-
Object.defineProperty(proto, key, desc);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function compose(target, mixin) {
|
|
46
|
-
if (typeof target === 'function') {
|
|
47
|
-
const Composed = composeClass(target, mixin);
|
|
48
|
-
defineAccessorsAndData(Composed.prototype, mixin); // this order ensures overriding
|
|
49
|
-
return Composed;
|
|
50
|
-
} else if (typeof target === 'object' && target !== null) {
|
|
51
|
-
composeInstance(target, mixin);
|
|
52
|
-
} else {
|
|
53
|
-
throw new TypeError("compose: target must be a class or instance");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const mixin = {
|
|
57
|
-
greet() { return `Hello from mixin, ${this.name}`; },
|
|
58
|
-
get upperName() { return this.name.toUpperCase(); }
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
class Person {
|
|
62
|
-
constructor(name) {
|
|
63
|
-
this.name = name;
|
|
64
|
-
}
|
|
65
|
-
greet() {
|
|
66
|
-
return `Hello from class, ${this.name}`;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// CLASS MODE
|
|
71
|
-
const ComposedPerson = compose(Person, mixin);
|
|
72
|
-
const p1 = new ComposedPerson("Zak");
|
|
73
|
-
console.log(p1.greet()); // Hello from mixin, Zak
|
|
74
|
-
console.log(p1.upperName); // ZAK
|
|
75
|
-
|
|
76
|
-
// INSTANCE MODE
|
|
77
|
-
class Animal {
|
|
78
|
-
constructor(name) {
|
|
79
|
-
this.name = name;
|
|
80
|
-
compose(this, mixin);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
greet() {
|
|
84
|
-
return `Animal says hi, ${this.name}`;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const a = new Animal("Milo");
|
|
88
|
-
console.log(a.greet()); // Hello from mixin, Milo
|
|
89
|
-
console.log(a.upperName); // MILO
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { mapfun } from "../../utils/index.js";
|
|
2
|
-
import { fact } from "../../functions/index.js";
|
|
3
|
-
const _bessel=(n, x)=>{
|
|
4
|
-
const maxTerms = 100;
|
|
5
|
-
let result = 0;
|
|
6
|
-
for (let k = 0; k < maxTerms; k++) {
|
|
7
|
-
const numerator = Math.pow(-1, k) * Math.pow(x / 2, n + 2 * k);
|
|
8
|
-
const denominator = fact(k) * fact(n + k);
|
|
9
|
-
result += numerator / denominator;
|
|
10
|
-
}
|
|
11
|
-
return result;
|
|
12
|
-
}
|
|
13
|
-
const bessel=(n,x)=>{
|
|
14
|
-
if(typeof n === "number"){
|
|
15
|
-
if(typeof n === "number")return _bessel(n,x);
|
|
16
|
-
else console.warn("Not supported yet")
|
|
17
|
-
}
|
|
18
|
-
else if(n instanceof Array){
|
|
19
|
-
if(typeof x === "number") return mapfun(a=>_bessel(a,x),...n);
|
|
20
|
-
else if(x instanceof Array){
|
|
21
|
-
const Y=[];
|
|
22
|
-
for(let i=0;i<n.length;i++){
|
|
23
|
-
Y.push(mapfun(a=>_bessel(n[i],a),...x))
|
|
24
|
-
}
|
|
25
|
-
return Y;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export{
|
|
30
|
-
bessel
|
|
31
|
-
}
|