ziko 0.0.7 → 0.0.9

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.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Mon May 20 2024 19:37:06 GMT+0100 (UTC+01:00)
5
+ Date : Thu Jun 13 2024 19:22:25 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -3236,7 +3236,7 @@ class ZikoEventPointer extends ZikoEvent{
3236
3236
  // if(up)this.handleUp()
3237
3237
  // }
3238
3238
  }
3239
- var Pointer=target=>new ZikoEventPointer(target);
3239
+ var usePointerEvent=target=>new ZikoEventPointer(target);
3240
3240
 
3241
3241
  class ZikoEventMouse extends ZikoEvent{
3242
3242
  constructor(target){
@@ -3465,7 +3465,7 @@ function mouseover_controller(e){
3465
3465
  null
3466
3466
  );
3467
3467
  }
3468
- const Mouse=target=>new ZikoEventMouse(target);
3468
+ const useMouseEvent=target=>new ZikoEventMouse(target);
3469
3469
 
3470
3470
  function wheel_controller(e){
3471
3471
  EVENT_CONTROLLER.call(this,e,"wheel",null,null);
@@ -3508,7 +3508,7 @@ class ZikoEventWheel extends ZikoEvent{
3508
3508
  return this;
3509
3509
  }
3510
3510
  }
3511
- const Wheel=Target=>new ZikoEventWheel(Target);
3511
+ const useWheelEventnent=Target=>new ZikoEventWheel(Target);
3512
3512
 
3513
3513
  function keydown_controller(e){
3514
3514
  EVENT_CONTROLLER.call(
@@ -3605,7 +3605,7 @@ class ZikoEventKey extends ZikoEvent{
3605
3605
 
3606
3606
  }
3607
3607
 
3608
- var Key=Target=>new ZikoEventKey(Target);
3608
+ var useKeyEvenent=Target=>new ZikoEventKey(Target);
3609
3609
 
3610
3610
  function dragstart_controller(e){
3611
3611
  EVENT_CONTROLLER(this,e,"start",null);
@@ -3740,8 +3740,8 @@ class ZikoEventDrop extends ZikoEvent{
3740
3740
  return this;
3741
3741
  }
3742
3742
  }
3743
- const Drag=Target=>new ZikoEventDrag(Target);
3744
- const Drop=Target=>new ZikoEventDrop(Target);
3743
+ const useDragEvent=Target=>new ZikoEventDrag(Target);
3744
+ const useDropEvent=Target=>new ZikoEventDrop(Target);
3745
3745
 
3746
3746
  function click_controller(e){
3747
3747
  EVENT_CONTROLLER.call(this,e,"click",null,null);
@@ -3796,7 +3796,7 @@ class ZikoEventClick extends ZikoEvent{
3796
3796
  return this;
3797
3797
  }
3798
3798
  }
3799
- const Click=Target=>new ZikoEventClick(Target);
3799
+ const useClickEventnt=Target=>new ZikoEventClick(Target);
3800
3800
 
3801
3801
  function copy_controller(e){
3802
3802
  EVENT_CONTROLLER.call(this,e,"copy",null,null);
@@ -3879,7 +3879,7 @@ class ZikoEventClipboard extends ZikoEvent{
3879
3879
  return this;
3880
3880
  }
3881
3881
  }
3882
- const Clipboard=Target=>new ZikoEventClipboard(Target);
3882
+ const useClipboardEvent=Target=>new ZikoEventClipboard(Target);
3883
3883
 
3884
3884
  function focus_controller(e){
3885
3885
  EVENT_CONTROLLER.call(this,e,"focus",null,null);
@@ -3934,7 +3934,7 @@ class ZikoEventFocus extends ZikoEvent{
3934
3934
  return this;
3935
3935
  }
3936
3936
  }
3937
- const Focus=Target=>new ZikoEventFocus(Target);
3937
+ const useFocusEvent=Target=>new ZikoEventFocus(Target);
3938
3938
 
3939
3939
  function input_controller(e){
3940
3940
  EVENT_CONTROLLER.call(this,e,"input",null,null);
@@ -3992,7 +3992,7 @@ class ZikoEventInput extends ZikoEvent{
3992
3992
  return this;
3993
3993
  }
3994
3994
  }
3995
- const Input$1=Target=>new ZikoEventInput(Target);
3995
+ const useInputEvent=Target=>new ZikoEventInput(Target);
3996
3996
 
3997
3997
  function hashchange_controller(e){
3998
3998
  EVENT_CONTROLLER.call(this,e,"hashchange",null,null);
@@ -4035,7 +4035,7 @@ class ZikoEventHash extends ZikoEvent{
4035
4035
  return this;
4036
4036
  }
4037
4037
  }
4038
- const HashEvent=Target=>new ZikoEventHash(Target);
4038
+ const useHashEvent=Target=>new ZikoEventHash(Target);
4039
4039
 
4040
4040
  const custom_event_controller=event_name=>function(e){
4041
4041
  EVENT_CONTROLLER.call(this,e,event_name,null,null);
@@ -4087,21 +4087,21 @@ class ZikoCustomEvent extends ZikoEvent{
4087
4087
  return this;
4088
4088
  }
4089
4089
  }
4090
- const customEvent=Target=>new ZikoCustomEvent(Target);
4090
+ const useCustomEvent=Target=>new ZikoCustomEvent(Target);
4091
4091
 
4092
4092
  const Events={
4093
- Pointer,
4094
- Mouse,
4095
- Wheel,
4096
- Key,
4097
- Drag,
4098
- Drop,
4099
- Click,
4100
- Clipboard,
4101
- Focus,
4102
- Input: Input$1,
4103
- HashEvent,
4104
- customEvent,
4093
+ usePointerEvent,
4094
+ useMouseEvent,
4095
+ useWheelEvent: useWheelEventnent,
4096
+ useKeyEvent: useKeyEvenent,
4097
+ useDragEvent,
4098
+ useDropEvent,
4099
+ useClickEvent: useClickEventnt,
4100
+ useClipboardEvent,
4101
+ useFocusEvent,
4102
+ useInputEvent,
4103
+ useHashEvent,
4104
+ useCustomEvent,
4105
4105
  ExtractAll: function () {
4106
4106
  const keys = Object.keys(this);
4107
4107
  for (let i = 0; i < keys.length; i++) {
@@ -4162,7 +4162,104 @@ class ZikoIntersectionObserver{
4162
4162
  }
4163
4163
  }
4164
4164
 
4165
- const WatchIntersection=(UI,callback,config)=>new ZikoIntersectionObserver(UI,callback,config);
4165
+ const watchIntersection=(UI,callback,config)=>new ZikoIntersectionObserver(UI,callback,config);
4166
+
4167
+ class ZikoMutationObserver {
4168
+ constructor(UIElement, options) {
4169
+ this.UIElement = UIElement;
4170
+ this.options = options || { attributes: true, childList: true, subtree: true };
4171
+ this.observer = null;
4172
+ this.streamingEnabled = true;
4173
+ this.mutationHistory = {
4174
+ attributes: [],
4175
+ childList: [],
4176
+ subtree: [],
4177
+ };
4178
+
4179
+ this.observeCallback = (mutationsList, observer) => {
4180
+ if (this.streamingEnabled) {
4181
+ for (const mutation of mutationsList) {
4182
+ switch(mutation.type){
4183
+ case 'attributes':this.mutationHistory.attributes.push(mutation.target.getAttribute(mutation.attributeName));break;
4184
+ case 'childList':this.mutationHistory.childList.push(mutation);break;
4185
+ case 'subtree':this.mutationHistory.subtree.push(mutation);break;
4186
+ }
4187
+ }
4188
+ }
4189
+ if (this.callback) {
4190
+ this.callback(mutationsList, observer);
4191
+ }
4192
+ };
4193
+ }
4194
+
4195
+ observe(callback) {
4196
+ if(!this.observer) {
4197
+ this.observer = new MutationObserver(this.observeCallback);
4198
+ this.observer.observe(this.UIElement.element, this.options);
4199
+ this.callback = callback;
4200
+ this.streamingEnabled = true;
4201
+ }
4202
+ }
4203
+
4204
+ pause(options) {
4205
+ if (this.observer) {
4206
+ this.observer.disconnect();
4207
+ if (options) {
4208
+ this.observer.observe(this.UIElement, options);
4209
+ }
4210
+ }
4211
+ }
4212
+
4213
+ reset(options) {
4214
+ if (this.observer) {
4215
+ this.observer.disconnect();
4216
+ this.observer.observe(this.UIElement, options || this.options);
4217
+ }
4218
+ }
4219
+
4220
+ clear() {
4221
+ if (this.observer) {
4222
+ this.observer.disconnect();
4223
+ this.observer = null;
4224
+ this.mutationHistory = {
4225
+ attributes: [],
4226
+ childList: [],
4227
+ subtree: [],
4228
+ };
4229
+ }
4230
+ this.streamingEnabled = false;
4231
+ return this;
4232
+ }
4233
+
4234
+ getMutationHistory() {
4235
+ return this.mutationHistory;
4236
+ }
4237
+
4238
+ enableStreaming() {
4239
+ this.streamingEnabled = true;
4240
+ return this;
4241
+ }
4242
+
4243
+ disableStreaming() {
4244
+ this.streamingEnabled = false;
4245
+ return this;
4246
+ }
4247
+ }
4248
+
4249
+ const watch=(UIElement,options={},callback=null)=>{
4250
+ const Observer= new ZikoMutationObserver(UIElement,options);
4251
+ if(callback)Observer.observe(callback);
4252
+ return Observer
4253
+ };
4254
+ const watchAttr = (UIElement, callback = null) => {
4255
+ const options = { attributes: true, childList: false, subtree: false };
4256
+ return watch(UIElement, options, ([e])=>callback(e));
4257
+ };
4258
+
4259
+ const watchChildren = (UIElement, callback = null) => {
4260
+ const options = { attributes: false, childList: true, subtree: false };
4261
+ return watch(UIElement, options, ([e])=>callback(e));
4262
+ };
4166
4263
 
4167
4264
  class ZikoResizeObserver{
4168
4265
  constructor(UIElement,callback){
@@ -4209,601 +4306,1103 @@ class ZikoResizeObserver{
4209
4306
  }
4210
4307
  }
4211
4308
 
4212
- const WatchSize=(UI,callback)=>new ZikoResizeObserver(UI,callback);
4309
+ const watchSize=(UI,callback)=>new ZikoResizeObserver(UI,callback);
4213
4310
 
4214
- class ZikoUseStyle{
4215
- constructor(style,id=0){
4216
- this.id="Ziko-Style-"+id;
4217
- this.use(style);
4218
- this.keys=new Set();
4219
- this.styles={
4220
- default:{
4221
- fontSize:"1em"
4222
- }
4223
- };
4224
- }
4225
- get current(){
4226
- return [...this.keys].reduce((key, value) => {
4227
- key[value] = `var(--${value}-${this.id})`;
4228
- return key;
4229
- }, {});
4311
+ class ZikoTimeLoop {
4312
+ constructor(callback, {fps,step,t=[0,null],start=true}={}) {
4313
+ this.callback = callback;
4314
+ this.cache = {
4315
+ isRunning: false,
4316
+ AnimationId : null,
4317
+ startTime : null,
4318
+ step,
4319
+ fps,
4320
+ t,
4321
+ started:start
4322
+ };
4323
+ this.adjust();
4324
+ this.i=0;
4325
+ }
4326
+ adjust(){
4327
+ if(this.cache.step && this.cache.fps){
4328
+ console.warn(`Fps will be adjusted from ${this.cache.fps} to ${1000/this.cache.step} to ensure a smoother animation`);
4329
+ this.cache.fps=1000/this.cache.step;
4230
4330
  }
4231
- add(name,style={}){
4232
- if(name instanceof Object)Object.assign(this.styles,name);
4233
- else Object.assign(this.styles,{[name]:style});
4234
- return this;
4331
+ if(this.cache.started){
4332
+ const t=this.cache.t;
4333
+ t[0]?this.startAfter(t[0]):this.start();
4334
+ if(t[1]&&t[1]!==Infinity)this.stopAfter(t[1]);
4235
4335
  }
4236
- #useStyleIndex(index){
4237
- const keys=Object.keys(this.styles);
4238
- for(let a in this.styles[keys[index]]){
4239
- document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[keys[index]][a]);
4240
- this.keys.add(a);
4241
- }
4242
-
4243
- return this;
4336
+ return this;
4337
+ }
4338
+ get TIME_STEP() {
4339
+ return this.cache.step?this.cache.step:1000 / this.cache.fps;
4340
+ }
4341
+ start() {
4342
+ if (!this.cache.isRunning) {
4343
+ this.i=0;
4344
+ this.cache.isRunning = true;
4345
+ this.cache.startTime = Date.now();
4346
+ this.animate();
4244
4347
  }
4245
- #useStyleName(name){
4246
- for(let a in this.styles[name]){
4247
- document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[name][a]);
4248
- this.keys.add(a);
4249
- }
4250
- return this;
4348
+ return this;
4349
+ }
4350
+ pause() {
4351
+ if (this.cache.isRunning) {
4352
+ clearTimeout(this.cache.AnimationId);
4353
+ this.cache.isRunning = false;
4251
4354
  }
4252
- #useStyleObject(Style){
4253
- for(let a in Style){
4254
- document.documentElement.style.setProperty(`--${a}-${this.id}`, Style[a]);
4255
- this.keys.add(a);
4355
+ return this;
4356
+ }
4357
+ stop(){
4358
+ this.pause();
4359
+ this.i=0;
4360
+ return this;
4361
+ }
4362
+ resume(){
4363
+ this.cache.isRunning=true;
4364
+ this.animate();
4365
+ return this;
4366
+ }
4367
+ startAfter(t=1000){
4368
+ setTimeout(this.start.bind(this),t);
4369
+ return this;
4370
+ }
4371
+ stopAfter(t=1000){
4372
+ setTimeout(this.stop.bind(this),t);
4373
+ return this;
4374
+ }
4375
+ animate = () => {
4376
+ if (this.cache.isRunning) {
4377
+ const now = Date.now();
4378
+ const delta = now - this.cache.startTime;
4379
+ if (delta > this.TIME_STEP) {
4380
+ this.callback(this);
4381
+ this.i++;
4382
+ this.cache.startTime = now - (delta % this.TIME_STEP);
4256
4383
  }
4257
- return this;
4258
- }
4259
- use(style){
4260
- if(typeof style === "number")this.#useStyleIndex(style);
4261
- if(typeof style === "string")this.#useStyleName(style);
4262
- if(style instanceof Object)this.#useStyleObject(style);
4263
- return this;
4264
- }
4265
- }
4266
- const useStyle=id=>style=>new ZikoUseStyle(style,id);
4384
+ this.cache.AnimationId = setTimeout(this.animate, 0);
4385
+ } }
4386
+ }
4387
+
4388
+ const loop = (callback, options) => new ZikoTimeLoop(callback, options);
4267
4389
 
4268
- const LightThemes={
4269
- cozyCottonCandy: {
4270
- background: "#FCE4EC",
4271
- currentLine: "#F8BBD0",
4272
- selection: "#FFCDD2",
4273
- foreground: "#673AB7",
4274
- comment: "#9575CD",
4275
- cyan: "#00BCD4",
4276
- green: "#4CAF50",
4277
- orange: "#FF9800",
4278
- pink: "#E91E63",
4279
- purple: "#9C27B0",
4280
- red: "#F44336",
4281
- yellow: "#FFEB3B"
4390
+ const Ease={
4391
+ Linear:function(t){
4392
+ return t;
4282
4393
  },
4283
- crystalClear: {
4284
- background: "#F6F8FA",
4285
- currentLine: "#E8F0F5",
4286
- selection: "#D4E9F7",
4287
- foreground: "#485766",
4288
- comment: "#8492A6",
4289
- cyan: "#00ACC1",
4290
- green: "#8BC34A",
4291
- orange: "#FFA726",
4292
- pink: "#FF4081",
4293
- purple: "#7E57C2",
4294
- red: "#EF5350",
4295
- yellow: "#FFD740"
4394
+ InSin(t){
4395
+ return 1 - Math.cos((t * Math.PI) / 2);
4296
4396
  },
4297
- lightdreamyDusk: {
4298
- background: "#F5F5F5",
4299
- currentLine: "#E8E8E8",
4300
- selection: "#DADADA",
4301
- foreground: "#555555",
4302
- comment: "#999999",
4303
- cyan: "#5FB3B3",
4304
- green: "#68C386",
4305
- orange: "#FFB67A",
4306
- pink: "#FF94B0",
4307
- purple: "#B78BC3",
4308
- red: "#FF6666",
4309
- yellow: "#FFD666"
4397
+ OutSin(t){
4398
+ return Math.sin((t * Math.PI) / 2);
4310
4399
  },
4311
- luminousLavender: {
4312
- background: "#F3E5F5",
4313
- currentLine: "#E1BEE7",
4314
- selection: "#CE93D8",
4315
- foreground: "#311B92",
4316
- comment: "#673AB7",
4317
- cyan: "#00BCD4",
4318
- green: "#8BC34A",
4319
- orange: "#FF9800",
4320
- pink: "#E91E63",
4321
- purple: "#9C27B0",
4322
- red: "#F44336",
4323
- yellow: "#FFEB3B"
4400
+ InOutSin(t){
4401
+ return -(Math.cos(Math.PI * t) - 1) / 2;
4324
4402
  },
4325
- meadowMornings: {
4326
- background: "#F3E5F5",
4327
- currentLine: "#E1BEE7",
4328
- selection: "#CE93D8",
4329
- foreground: "#311B92",
4330
- comment: "#673AB7",
4331
- cyan: "#00BCD4",
4332
- green: "#8BC34A",
4333
- orange: "#FF9800",
4334
- pink: "#E91E63",
4335
- purple: "#9C27B0",
4336
- red: "#F44336",
4337
- yellow: "#FFEB3B"
4403
+ InQuad(t){
4404
+ return t**2;
4338
4405
  },
4339
- moonlitMauve: {
4340
- background: "#F3E5F5",
4341
- currentLine: "#E1BEE7",
4342
- selection: "#CE93D8",
4343
- foreground: "#311B92",
4344
- comment: "#673AB7",
4345
- cyan: "#00BCD4",
4346
- green: "#8BC34A",
4347
- orange: "#FF9800",
4348
- pink: "#E91E63",
4349
- purple: "#9C27B0",
4350
- red: "#F44336",
4351
- yellow: "#FFEB3B"
4406
+ OutQuad(t){
4407
+ return 1 - Math.pow((1 - t),2)
4352
4408
  },
4353
- morningMist: {
4354
- background: "#F6F6F6",
4355
- currentLine: "#EAEAEA",
4356
- selection: "#D8D8D8",
4357
- foreground: "#333333",
4358
- comment: "#808080",
4359
- cyan: "#00A6A6",
4360
- green: "#4CAF50",
4361
- orange: "#FFA726",
4362
- pink: "#FF4081",
4363
- purple: "#9C27B0",
4364
- red: "#FF5252",
4365
- yellow: "#FFD740"
4409
+ InOutQuad(t){
4410
+ return t < 0.5 ? 2 * Math.pow(t,2) : 1 - Math.pow(-2 * t + 2, 2) / 2;
4366
4411
  },
4367
- oceanBreeze: {
4368
- background: "#ECF1F4",
4369
- currentLine: "#DDE8ED",
4370
- selection: "#BFD3C1",
4371
- foreground: "#37474F",
4372
- comment: "#607D8B",
4373
- cyan: "#00BCD4",
4374
- green: "#8BC34A",
4375
- orange: "#FF9800",
4376
- pink: "#E91E63",
4377
- purple: "#673AB7",
4378
- red: "#F44336",
4379
- yellow: "#FFEB3B"
4412
+ InCubic(t){
4413
+ return t**3;
4380
4414
  },
4381
- pastelParadise: {
4382
- background: "#F5F5F5",
4383
- currentLine: "#E8E8E8",
4384
- selection: "#DADADA",
4385
- foreground: "#555555",
4386
- comment: "#999999",
4387
- cyan: "#5FB3B3",
4388
- green: "#68C386",
4389
- orange: "#FFB67A",
4390
- pink: "#FF94B0",
4391
- purple: "#B78BC3",
4392
- red: "#FF6666",
4393
- yellow: "#FFD666"
4415
+ OutCubic(t){
4416
+ return 1 - Math.pow((1 - t),3)
4394
4417
  },
4395
- pastelPetals: {
4396
- background: "#FCE4EC",
4397
- currentLine: "#F8BBD0",
4398
- selection: "#FFCDD2",
4399
- foreground: "#673AB7",
4400
- comment: "#9575CD",
4401
- cyan: "#00BCD4",
4402
- green: "#4CAF50",
4403
- orange: "#FF9800",
4404
- pink: "#E91E63",
4405
- purple: "#9C27B0",
4406
- red: "#F44336",
4407
- yellow: "#FFEB3B"
4418
+ InOutCubic(t){
4419
+ return t < 0.5 ? 4 * Math.pow(t,3) : 1 - Math.pow(-2 * t + 2, 3) / 2;
4408
4420
  },
4409
- sereneSnowfall: {
4410
- background: "#F9F9F9",
4411
- currentLine: "#EDEDED",
4412
- selection: "#D8D8D8",
4413
- foreground: "#454545",
4414
- comment: "#888888",
4415
- cyan: "#5FA5A5",
4416
- green: "#5BC47E",
4417
- orange: "#FFBC8D",
4418
- pink: "#FFA7BF",
4419
- purple: "#B88AAE",
4420
- red: "#FF7575",
4421
- yellow: "#FFD98F"
4421
+ InQuart(t){
4422
+ return t**4;
4422
4423
  },
4423
- softSherbet: {
4424
- background: "#FDF8F3",
4425
- currentLine: "#FAF1EB",
4426
- selection: "#FFEBEE",
4427
- foreground: "#6D4C41",
4428
- comment: "#A1887F",
4429
- cyan: "#00BCD4",
4430
- green: "#689F38",
4431
- orange: "#FFA000",
4432
- pink: "#EC407A",
4433
- purple: "#8E24AA",
4434
- red: "#E53935",
4435
- yellow: "#FFC107"
4424
+ OutQuart(t){
4425
+ return 1 - Math.pow((1 - t),4);
4436
4426
  },
4437
- subtleSerenity: {
4438
- background: "#F3F5F7",
4439
- currentLine: "#E8EDF2",
4440
- selection: "#D1D9E6",
4441
- foreground: "#2C3E50",
4442
- comment: "#95A5A6",
4443
- cyan: "#3498DB",
4444
- green: "#2ECC71",
4445
- orange: "#F39C12",
4446
- pink: "#E74C3C",
4447
- purple: "#9B59B6",
4448
- red: "#C0392B",
4449
- yellow: "#F1C40F"
4427
+ InOutQuart(t){
4428
+ return t < 0.5 ? 8 * Math.pow(t,4) : 1 - Math.pow(-2 * t + 2, 4) / 2;
4450
4429
  },
4451
- summerSunset: {
4452
- background: "#FCE4EC",
4453
- currentLine: "#F8BBD0",
4454
- selection: "#FFCDD2",
4455
- foreground: "#4E342E",
4456
- comment: "#795548",
4457
- cyan: "#009688",
4458
- green: "#43A047",
4459
- orange: "#FF5722",
4460
- pink: "#E91E63",
4461
- purple: "#9C27B0",
4462
- red: "#F44336",
4463
- yellow: "#FFEB3B"
4430
+ InQuint(t){
4431
+ return t**5;
4464
4432
  },
4465
- sunnyDay: {
4466
- background: "#FFF8E1",
4467
- currentLine: "#FFF3E0",
4468
- selection: "#FFE0B2",
4469
- foreground: "#4E342E",
4470
- comment: "#795548",
4471
- cyan: "#00BCD4",
4472
- green: "#8BC34A",
4473
- orange: "#FF9800",
4474
- pink: "#E91E63",
4475
- purple: "#673AB7",
4476
- red: "#F44336",
4477
- yellow: "#FFEB3B"
4433
+ OutQuint(t){
4434
+ return 1 - Math.pow((1 - t),5);
4478
4435
  },
4479
- tranquilTwilight: {
4480
- background: "#F9F9F9",
4481
- currentLine: "#EDEDED",
4482
- selection: "#D8D8D8",
4483
- foreground: "#454545",
4484
- comment: "#888888",
4485
- cyan: "#5FA5A5",
4486
- green: "#5BC47E",
4487
- orange: "#FFBC8D",
4488
- pink: "#FFA7BF",
4489
- purple: "#B88AAE",
4490
- red: "#FF7575",
4491
- yellow: "#FFD98F"
4436
+ InOutQuint(t){
4437
+ return t < 0.5 ? 16 * Math.pow(t,5) : 1 - Math.pow(-2 * t + 2, 5) / 2;
4492
4438
  },
4493
- tranquilWaves: {
4494
- background: "#F9F9F9",
4495
- currentLine: "#E4E4E4",
4496
- selection: "#D4D4D4",
4497
- foreground: "#2C3E50",
4498
- comment: "#7F8C8D",
4499
- cyan: "#3498DB",
4500
- green: "#2ECC71",
4501
- orange: "#F39C12",
4502
- pink: "#E74C3C",
4503
- purple: "#9B59B6",
4504
- red: "#C0392B",
4505
- yellow: "#F1C40F"
4439
+ InExpo(t){
4440
+ return t === 0 ? 0 : Math.pow(2, 10 * t - 10);
4506
4441
  },
4507
- whisperingWillow: {
4508
- background: "#F6F8FA",
4509
- currentLine: "#E8F0F5",
4510
- selection: "#D4E9F7",
4511
- foreground: "#485766",
4512
- comment: "#8492A6",
4513
- cyan: "#00ACC1",
4514
- green: "#8BC34A",
4515
- orange: "#FFA726",
4516
- pink: "#FF4081",
4517
- purple: "#7E57C2",
4518
- red: "#EF5350",
4519
- yellow: "#FFD740"
4520
- }
4521
- };
4522
-
4523
- const DarkThemes = {
4524
- antiqueRose: {
4525
- background: "#1C1014",
4526
- currentLine: "#2B1B21",
4527
- selection: "#443034",
4528
- foreground: "#D8B5B5",
4529
- comment: "#7F5E5E",
4530
- cyan: "#6FA2A2",
4531
- green: "#66A66F",
4532
- orange: "#FFB97A",
4533
- pink: "#FFA8BD",
4534
- purple: "#B78DA5",
4535
- red: "#FF6C6C",
4536
- yellow: "#FFD579"
4442
+ OutExpo(t){
4443
+ return t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
4537
4444
  },
4538
- auroraBorealis: {
4539
- background: "#1D1426",
4540
- currentLine: "#2B1E35",
4541
- selection: "#432D4E",
4542
- foreground: "#C2AABF",
4543
- comment: "#7F6E8E",
4544
- cyan: "#7EA5D3",
4545
- green: "#77C992",
4546
- orange: "#FFC476",
4547
- pink: "#FFA8B3",
4548
- purple: "#AE9AC3",
4549
- red: "#FF6C6C",
4550
- yellow: "#FFD576"
4445
+ InOutExpo(t){
4446
+ return t === 0? 0: t === 1? 1: t < 0.5 ? Math.pow(2, 20 * t - 10) / 2: (2 - Math.pow(2, -20 * t + 10)) / 2;
4551
4447
  },
4552
- autumnHarvest: {
4553
- background: "#291C10",
4554
- currentLine: "#3A2A1E",
4555
- selection: "#573C2C",
4556
- foreground: "#D4C3A2",
4557
- comment: "#7F6F52",
4558
- cyan: "#82B4BF",
4559
- green: "#7FB074",
4560
- orange: "#FFAB6E",
4561
- pink: "#FF8196",
4562
- purple: "#B394A9",
4563
- red: "#FF6565",
4564
- yellow: "#FFD270"
4448
+ InCirc(t){
4449
+ return 1 - Math.sqrt(1 - Math.pow(t, 2));
4565
4450
  },
4566
- aylin: {
4567
- background: "#13161E",
4568
- currentLine: "#161A28",
4569
- selection: "#222B3E",
4570
- foreground: "#D2D8E0",
4571
- comment: "#697098",
4572
- cyan: "#78D1E1",
4573
- green: "#98C379",
4574
- orange: "#EBCB8B",
4575
- pink: "#D16D9E",
4576
- purple: "#C678DD",
4577
- red: "#E88388",
4578
- yellow: "#EBCB8B"
4451
+ OutCirc(t){
4452
+ return Math.sqrt(1 - Math.pow(t - 1, 2));
4579
4453
  },
4580
- azureBlue: {
4581
- background: "#001B29",
4582
- currentLine: "#002C3E",
4583
- selection: "#004E6B",
4584
- foreground: "#C3D7E2",
4585
- comment: "#5F7C92",
4586
- cyan: "#75B7D1",
4587
- green: "#70C8A7",
4588
- orange: "#FFB476",
4589
- pink: "#FF92B0",
4590
- purple: "#B88BC3",
4591
- red: "#FF6666",
4592
- yellow: "#FFD666"
4454
+ InOutCic(t){
4455
+ return t < 0.5? (1 - Math.sqrt(1 - Math.pow(2 * t, 2))) / 2: (Math.sqrt(1 - Math.pow(-2 * t + 2, 2)) + 1) / 2;
4593
4456
  },
4594
- cobalt2: {
4595
- background: "#193549",
4596
- currentLine: "#1F4662",
4597
- selection: "#193549",
4598
- foreground: "#B9BED0",
4599
- comment: "#627D98",
4600
- cyan: "#4DB5BD",
4601
- green: "#86B300",
4602
- orange: "#FFB86C",
4603
- pink: "#FF7F7B",
4604
- purple: "#9B64FB",
4605
- red: "#FF6672",
4606
- yellow: "#FFCC99"
4607
- },
4608
- cobaltMaterialTheme: {
4609
- background: "#263238",
4610
- currentLine: "#37474F",
4611
- selection: "#80CBC4",
4612
- foreground: "#CFD8DC",
4613
- comment: "#78909C",
4614
- cyan: "#80CBC4",
4615
- green: "#A5D6A7",
4616
- orange: "#FFD54F",
4617
- pink: "#FF80AB",
4618
- purple: "#CE93D8",
4619
- red: "#EF5350",
4620
- yellow: "#FFEE58"
4621
- },
4622
- cosmicBlue: {
4623
- background: "#1B2836",
4624
- currentLine: "#223348",
4625
- selection: "#39516D",
4626
- foreground: "#C0D4E5",
4627
- comment: "#728CAB",
4628
- cyan: "#75A6FF",
4629
- green: "#5ED99F",
4630
- orange: "#FFAD6F",
4631
- pink: "#FF90B6",
4632
- purple: "#A889C5",
4633
- red: "#FF6E6E",
4634
- yellow: "#FCD256"
4635
- },
4636
- cosmicSunset: {
4637
- background: "#1B1921",
4638
- currentLine: "#272530",
4639
- selection: "#3C3948",
4640
- foreground: "#B8B4CB",
4641
- comment: "#7A738B",
4642
- cyan: "#77B4D8",
4643
- green: "#6CC09E",
4644
- orange: "#FFA677",
4645
- pink: "#FF95B2",
4646
- purple: "#B48FC1",
4647
- red: "#FF6565",
4648
- yellow: "#FFD566"
4649
- },
4650
- cyberForest: {
4651
- background: "#0D151D",
4652
- currentLine: "#18262F",
4653
- selection: "#2B3B47",
4654
- foreground: "#CDD7E0",
4655
- comment: "#667B8B",
4656
- cyan: "#7EC4CF",
4657
- green: "#68CC96",
4658
- orange: "#FFAC6C",
4659
- pink: "#FF89B4",
4660
- purple: "#A889C5",
4661
- red: "#FF6565",
4662
- yellow: "#FFCB6B"
4457
+ Arc(t){
4458
+ return 1 - Math.sin(Math.acos(t));
4663
4459
  },
4664
- cyberPunkCity: {
4665
- background: "#000000",
4666
- currentLine: "#121212",
4667
- selection: "#1F1F1F",
4668
- foreground: "#DADADA",
4669
- comment: "#626262",
4670
- cyan: "#71B7FF",
4671
- green: "#50D890",
4672
- orange: "#FFB86C",
4673
- pink: "#FF79C6",
4674
- purple: "#BB86FC",
4675
- red: "#FF5454",
4676
- yellow: "#FDD663"
4460
+ Back(t){
4461
+ // To Be Changed
4462
+ let x=1;
4463
+ return Math.pow(t, 2) * ((x + 1) * t - x);
4677
4464
  },
4678
- cyberpunkNeon: {
4679
- background: "#121212",
4680
- currentLine: "#1B1B1B",
4681
- selection: "#262626",
4682
- foreground: "#DADADA",
4683
- comment: "#6C6C6C",
4684
- cyan: "#69AEDB",
4685
- green: "#4ECCA3",
4686
- orange: "#FFB86C",
4687
- pink: "#FF79C6",
4688
- purple: "#D08EFF",
4689
- red: "#FF5454",
4690
- yellow: "#FDD663"
4465
+ Elastic(t){
4466
+ return -2*Math.pow(2, 10 * (t - 1)) * Math.cos(20 * Math.PI * t / 3 * t);
4691
4467
  },
4692
- darkDesert: {
4693
- background: "#1E2022",
4694
- currentLine: "#282A2E",
4695
- selection: "#393D42",
4696
- foreground: "#C0C5CE",
4697
- comment: "#5C6368",
4698
- cyan: "#6FB3E0",
4699
- green: "#88C076",
4700
- orange: "#FFB454",
4701
- pink: "#FF7F90",
4702
- purple: "#B48EAD",
4703
- red: "#FF6666",
4704
- yellow: "#FFCC66"
4468
+ InBack(t){
4469
+ const c1 = 1.70158;
4470
+ const c3 = c1 + 1;
4471
+ return c3 *Math.pow(t,3)- c1 * (t**2);
4705
4472
  },
4706
- darkMint: {
4707
- background: "#11161A",
4708
- currentLine: "#1B2128",
4709
- selection: "#3D4853",
4710
- foreground: "#D9DEE5",
4711
- comment: "#65737E",
4712
- cyan: "#88C0D0",
4713
- green: "#98C379",
4714
- orange: "#FFB86C",
4715
- pink: "#FF7F8B",
4716
- purple: "#C594C5",
4717
- red: "#FF6561",
4718
- yellow: "#FAD07B"
4473
+ OutBack(t){
4474
+ const c1 = 1.70158;
4475
+ const c3 = c1 + 1;
4476
+ return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
4719
4477
  },
4720
- deepOcean: {
4721
- background: "#121C2C",
4722
- currentLine: "#182236",
4723
- selection: "#2B3E50",
4724
- foreground: "#BDC3C7",
4725
- comment: "#6C7A89",
4726
- cyan: "#59ABE3",
4727
- green: "#26A65B",
4728
- orange: "#F9690E",
4729
- pink: "#EB3B5A",
4730
- purple: "#D2527F",
4731
- red: "#E74C3C",
4732
- yellow: "#F5AB35"
4478
+ InOutBack(t){
4479
+ const c1 = 1.70158;
4480
+ const c2 = c1 * 1.525;
4481
+ return t < 0.5
4482
+ ? (Math.pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2
4483
+ : (Math.pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2;
4733
4484
  },
4734
- deepOceanBlue: {
4735
- background: "#1B2F40",
4736
- currentLine: "#263B53",
4737
- selection: "#3A536E",
4738
- foreground: "#BFC9D4",
4739
- comment: "#657C8E",
4740
- cyan: "#6CB5FF",
4741
- green: "#65C287",
4742
- orange: "#FFA974",
4743
- pink: "#FF87B4",
4744
- purple: "#AE9BFF",
4745
- red: "#FF6666",
4746
- yellow: "#FFD67B"
4485
+ InElastic(t){
4486
+ const c4 = (2 * Math.PI) / 3;return t === 0
4487
+ ? 0
4488
+ : t === 1
4489
+ ? 1
4490
+ : -Math.pow(2, 10 * t - 10) * Math.sin((t * 10 - 10.75) * c4);
4747
4491
  },
4748
- deepOceanSunset: {
4749
- background: "#151D2A",
4750
- currentLine: "#1D2735",
4751
- selection: "#31405B",
4752
- foreground: "#D5D9E0",
4753
- comment: "#6C7B8B",
4754
- cyan: "#6FAAD4",
4755
- green: "#66C295",
4756
- orange: "#FFA476",
4757
- pink: "#FF94B0",
4758
- purple: "#B08FC0",
4759
- red: "#FF6565",
4760
- yellow: "#FFD466"
4492
+ OutElastic(t){
4493
+ const c4 = (2 * Math.PI) / 3;
4494
+ return t === 0
4495
+ ? 0
4496
+ : t === 1
4497
+ ? 1
4498
+ : Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1;
4761
4499
  },
4762
- deepSpace: {
4763
- background: "#0F1419",
4764
- currentLine: "#1A232D",
4765
- selection: "#3A4758",
4766
- foreground: "#CDD9E5",
4767
- comment: "#657C96",
4768
- cyan: "#6CB6FF",
4769
- green: "#4CAF50",
4770
- orange: "#FFB454",
4771
- pink: "#FF75B5",
4772
- purple: "#9A76FF",
4773
- red: "#FF5555",
4774
- yellow: "#FFC857"
4500
+ InOutElastic(t){
4501
+ const c5 = (2 * Math.PI) / 4.5;
4502
+ return t === 0
4503
+ ? 0
4504
+ : t === 1
4505
+ ? 1
4506
+ : t < 0.5
4507
+ ? -(Math.pow(2, 20 * t - 10) * Math.sin((20 * t - 11.125) * c5)) / 2
4508
+ : (Math.pow(2, -20 * t + 10) * Math.sin((20 * t - 11.125) * c5)) / 2 + 1;
4775
4509
  },
4776
- dracula: {
4777
- background: "#282a36",
4778
- currentLine: "#44475a",
4779
- selection: "#44475a",
4780
- foreground: "#f8f8f2",
4781
- comment: "#6272a4",
4782
- cyan: "#8be9fd",
4783
- green: "#50fa7b",
4784
- orange: "#ffb86c",
4785
- pink: "#ff79c6",
4786
- purple: "#bd93f9",
4787
- red: "#ff5555",
4788
- yellow: "#f1fa8c"
4510
+ InBounce(t){
4511
+ return 1 - Ease.OutBounce(1-t);
4789
4512
  },
4790
- dreamyDusk: {
4791
- background: "#22243D",
4792
- currentLine: "#313558",
4793
- selection: "#4C4F6D",
4794
- foreground: "#A5A7C5",
4795
- comment: "#6F728E",
4796
- cyan: "#81A2BE",
4797
- green: "#7FB074",
4798
- orange: "#FFB476",
4799
- pink: "#FF91A4",
4800
- purple: "#AE8DC2",
4801
- red: "#FF7272",
4802
- yellow: "#FFD67A"
4513
+ OutBounce(t){
4514
+ const n1 = 7.5625;
4515
+ const d1 = 2.75;
4516
+ if (t < 1 / d1) {
4517
+ return n1 * t * t;
4518
+ } else if (t < 2 / d1) {
4519
+ return n1 * (t -= 1.5 / d1) * t + 0.75;
4520
+ } else if (t < 2.5 / d1) {
4521
+ return n1 * (t -= 2.25 / d1) * t + 0.9375;
4522
+ } else {
4523
+ return n1 * (t -= 2.625 / d1) * t + 0.984375;
4524
+ }
4525
+
4803
4526
  },
4804
- electricLagoon: {
4805
- background: "#15232B",
4806
- currentLine: "#20323E",
4527
+ InOutBounce(t){
4528
+ return t < 0.5
4529
+ ? (1 - Ease.OutBounce(1 - 2 * t)) / 2
4530
+ : (1 + Ease.OutBounce(2 * t - 1)) / 2;
4531
+ }
4532
+ };
4533
+
4534
+ const useDebounce=(fn,delay=1000)=>{
4535
+ let id;
4536
+ return (...args)=>id?clearTimeout(id):setTimeout(()=>fn(...args),delay)
4537
+ };
4538
+ const useThrottle=(fn,delay)=>{
4539
+ let lastTime=0;
4540
+ return (...args)=>{
4541
+ const now=new Date().getTime();
4542
+ if(now-lastTime<delay)return;
4543
+ lastTime=now;
4544
+ fn(...args);
4545
+ }
4546
+ };
4547
+
4548
+ const time_memory_Taken = (callback) => {
4549
+ const t0 = Date.now();
4550
+ const m0 = performance.memory.usedJSHeapSize;
4551
+ const result = callback();
4552
+ const t1 = Date.now();
4553
+ const m1 = performance.memory.usedJSHeapSize;
4554
+ const elapsedTime = t1 - t0;
4555
+ const usedMemory = m1 - m0;
4556
+ return {
4557
+ elapsedTime,
4558
+ usedMemory,
4559
+ result
4560
+ };
4561
+ };
4562
+
4563
+ const waitForUIElm=(UIElement)=>{
4564
+ return new Promise(resolve => {
4565
+ if (UIElement.element) {
4566
+ return resolve(UIElement.element);
4567
+ }
4568
+
4569
+ const observer = new MutationObserver(() => {
4570
+ if (UIElement.element) {
4571
+ resolve(UIElement.element);
4572
+ observer.disconnect();
4573
+ }
4574
+ });
4575
+
4576
+ observer.observe(document.body, {
4577
+ childList: true,
4578
+ subtree: true
4579
+ });
4580
+ });
4581
+ };
4582
+ const waitForUIElmSync=(UIElement,timeout=2000)=>{
4583
+ const t0=Date.now();
4584
+ while(Date.now()-t0<timeout){
4585
+ if(UIElement.element)return UIElement.element
4586
+ }
4587
+ };
4588
+
4589
+ const wait=(delayInMS)=>{
4590
+ return new Promise((resolve) => setTimeout(resolve, delayInMS));
4591
+ };
4592
+ const timeTaken = callback => {
4593
+ console.time('timeTaken');
4594
+ const r = callback();
4595
+ console.timeEnd('timeTaken');
4596
+ return r;
4597
+ };
4598
+
4599
+ class ZikoTimeAnimation{
4600
+ constructor(callback,{ease=Ease.Linear,step=50,t=[0,null],start=true,duration=3000}={}){
4601
+ this.cache={
4602
+ isRunning:false,
4603
+ AnimationId:null,
4604
+ startTime:null,
4605
+ ease,
4606
+ step,
4607
+ intervall:t,
4608
+ started:start,
4609
+ duration
4610
+ };
4611
+ this.t=0;
4612
+ this.tx=0;
4613
+ this.ty=0;
4614
+ this.i=0;
4615
+ this.callback=callback;
4616
+ }
4617
+ #animation_handler(){
4618
+ this.t+=this.cache.step;
4619
+ this.i++;
4620
+ this.tx=map(this.t,0,this.cache.duration,0,1);
4621
+ this.ty=this.cache.ease(this.tx);
4622
+ this.callback(this);
4623
+ if(this.t>=this.cache.duration){
4624
+ clearInterval(this.cache.AnimationId);
4625
+ this.cache.isRunning=false;
4626
+ }
4627
+ }
4628
+ reset(restart=true){
4629
+ this.t=0;
4630
+ this.tx=0;
4631
+ this.ty=0;
4632
+ this.i=0;
4633
+ if(restart)this.start();
4634
+ return this;
4635
+ }
4636
+ #animate(reset=true){
4637
+ if(!this.cache.isRunning){
4638
+ if(reset)this.reset(false);
4639
+ this.cache.isRunning=true;
4640
+ this.cache.startTime = Date.now();
4641
+ this.cache.AnimationId=setInterval(this.#animation_handler.bind(this),this.cache.step);
4642
+ }
4643
+ return this;
4644
+ }
4645
+ start(){
4646
+ this.#animate(true);
4647
+ return this;
4648
+ }
4649
+ pause(){
4650
+ if (this.cache.isRunning) {
4651
+ clearTimeout(this.cache.AnimationId);
4652
+ this.cache.isRunning = false;
4653
+ }
4654
+ return this;
4655
+ }
4656
+ resume(){
4657
+ this.#animate(false);
4658
+ return this;
4659
+ }
4660
+ stop(){
4661
+ this.pause();
4662
+ this.reset(false);
4663
+ return this;
4664
+ }
4665
+ // clear(){
4666
+ // }
4667
+ // stream(){
4668
+ // }
4669
+ }
4670
+
4671
+ const animation=(callback,config)=>new ZikoTimeAnimation(callback,config);
4672
+
4673
+ const Time={
4674
+ wait,
4675
+ timeTaken,
4676
+ useThrottle,
4677
+ useDebounce,
4678
+ Ease,
4679
+ time_memory_Taken,
4680
+ loop,
4681
+ animation,
4682
+ waitForUIElm,
4683
+ waitForUIElmSync,
4684
+ ExtractAll: function () {
4685
+ const keys = Object.keys(this);
4686
+ for (let i = 0; i < keys.length; i++) {
4687
+ const key = keys[i];
4688
+ if (key !== 'ExtractAll' && key !== 'RemoveAll') {
4689
+ globalThis[key] = this[key];
4690
+ }
4691
+ }
4692
+ return this;
4693
+ },
4694
+ RemoveAll: function () {
4695
+ const keys = Object.keys(this);
4696
+ for (let i = 0; i < keys.length; i++) {
4697
+ const key = keys[i];
4698
+ if (key !== 'RemoveAll') {
4699
+ delete globalThis[key];
4700
+ }
4701
+ }
4702
+ return this;
4703
+ }
4704
+ };
4705
+
4706
+ class ZikoScreenObserver {
4707
+ constructor(callback=e=>console.log({x:e.x,y:e.y})) {
4708
+ this.previousX = globalThis?.screenX;
4709
+ this.previousY = globalThis?.screenY;
4710
+ this.view=[-1,-1,1,1];
4711
+ this.start(callback);
4712
+ }
4713
+ get xMin(){
4714
+ return this.view[0];
4715
+ }
4716
+ get yMin(){
4717
+ return this.view[1];
4718
+ }
4719
+ get xMax(){
4720
+ return this.view[2];
4721
+ }
4722
+ get yMax(){
4723
+ return this.view[3];
4724
+ }
4725
+ get x(){
4726
+ return globalThis?.screenX;
4727
+ }
4728
+ get y(){
4729
+ return globalThis?.screenY;
4730
+ }
4731
+ get scx(){
4732
+ return screen.availWidth/2;
4733
+ }
4734
+ get scy(){
4735
+ return screen.availHeight/2;
4736
+ }
4737
+ get wcx(){
4738
+ return screenX+globalThis?.innerWidth/2;
4739
+ }
4740
+ get wcx_v(){
4741
+ return map(this.wcx,0,screen.availWidth,this.view[0],this.view[2]);
4742
+ }
4743
+ get wcy(){
4744
+ return screenY+globalThis?.innerHeight/2;
4745
+ }
4746
+ get wcy_v(){
4747
+ return -map(this.wcy,0,screen.availHeight,this.view[1],this.view[3]);
4748
+ }
4749
+ get dx(){
4750
+ return map(this.x,0,screen.availWidth,this.xMin,this.xMax);
4751
+ }
4752
+ get dy(){
4753
+ return map(this.y,0,screen.availHeight,this.yMin,this.yMax);
4754
+ }
4755
+ start(callback){
4756
+ this.loop = loop(()=>{
4757
+ let currentX = globalThis?.screenX;
4758
+ let currentY = globalThis?.screenY;
4759
+ if (this.previousX !== currentX || this.previousY !== currentY) {
4760
+ callback(this);
4761
+ this.previousX = currentX;
4762
+ this.previousY = currentY;
4763
+ }
4764
+ },
4765
+ {fps:10,t:[0,Infinity],start:true});
4766
+ return this;
4767
+ }
4768
+ }
4769
+ const watchScreen=(callback)=>new ZikoScreenObserver(callback);
4770
+ globalThis.watchScreen=watchScreen;
4771
+
4772
+ /*
4773
+ a=ul("x","y","dx","dy","wcx","wxy")
4774
+ watchScreen(e=>{
4775
+ a[0].setValue("x : "+e.x)
4776
+ a[1].setValue("y : "+e.y)
4777
+ a[2].setValue("dx : "+e.dx)
4778
+ a[3].setValue("dy : "+e.dy)
4779
+ a[4].setValue("wCx : "+e.wcx)
4780
+ a[5].setValue("wCy : "+e.wcy)
4781
+ })
4782
+ */
4783
+
4784
+ const Observer={
4785
+ watch,
4786
+ watchAttr,
4787
+ watchChildren,
4788
+ watchIntersection,
4789
+ watchSize,
4790
+ watchScreen,
4791
+ ExtractAll: function () {
4792
+ const keys = Object.keys(this);
4793
+ for (let i = 0; i < keys.length; i++) {
4794
+ const key = keys[i];
4795
+ if (key !== 'ExtractAll' && key !== 'RemoveAll') {
4796
+ globalThis[key] = this[key];
4797
+ }
4798
+ }
4799
+ return this;
4800
+ },
4801
+ RemoveAll: function () {
4802
+ const keys = Object.keys(this);
4803
+ for (let i = 0; i < keys.length; i++) {
4804
+ const key = keys[i];
4805
+ if (key !== 'RemoveAll') {
4806
+ delete globalThis[key];
4807
+ }
4808
+ }
4809
+ return this;
4810
+ }
4811
+ };
4812
+
4813
+ class ZikoUseStyle{
4814
+ constructor(style,id=0){
4815
+ this.id="Ziko-Style-"+id;
4816
+ this.use(style);
4817
+ this.keys=new Set();
4818
+ this.styles={
4819
+ default:{
4820
+ fontSize:"1em"
4821
+ }
4822
+ };
4823
+ }
4824
+ get current(){
4825
+ return [...this.keys].reduce((key, value) => {
4826
+ key[value] = `var(--${value}-${this.id})`;
4827
+ return key;
4828
+ }, {});
4829
+ }
4830
+ add(name,style={}){
4831
+ if(name instanceof Object)Object.assign(this.styles,name);
4832
+ else Object.assign(this.styles,{[name]:style});
4833
+ return this;
4834
+ }
4835
+ #useStyleIndex(index){
4836
+ const keys=Object.keys(this.styles);
4837
+ for(let a in this.styles[keys[index]]){
4838
+ document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[keys[index]][a]);
4839
+ this.keys.add(a);
4840
+ }
4841
+
4842
+ return this;
4843
+ }
4844
+ #useStyleName(name){
4845
+ for(let a in this.styles[name]){
4846
+ document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[name][a]);
4847
+ this.keys.add(a);
4848
+ }
4849
+ return this;
4850
+ }
4851
+ #useStyleObject(Style){
4852
+ for(let a in Style){
4853
+ document.documentElement.style.setProperty(`--${a}-${this.id}`, Style[a]);
4854
+ this.keys.add(a);
4855
+ }
4856
+ return this;
4857
+ }
4858
+ use(style){
4859
+ if(typeof style === "number")this.#useStyleIndex(style);
4860
+ if(typeof style === "string")this.#useStyleName(style);
4861
+ if(style instanceof Object)this.#useStyleObject(style);
4862
+ return this;
4863
+ }
4864
+ }
4865
+ const useStyle=id=>style=>new ZikoUseStyle(style,id);
4866
+
4867
+ const LightThemes={
4868
+ cozyCottonCandy: {
4869
+ background: "#FCE4EC",
4870
+ currentLine: "#F8BBD0",
4871
+ selection: "#FFCDD2",
4872
+ foreground: "#673AB7",
4873
+ comment: "#9575CD",
4874
+ cyan: "#00BCD4",
4875
+ green: "#4CAF50",
4876
+ orange: "#FF9800",
4877
+ pink: "#E91E63",
4878
+ purple: "#9C27B0",
4879
+ red: "#F44336",
4880
+ yellow: "#FFEB3B"
4881
+ },
4882
+ crystalClear: {
4883
+ background: "#F6F8FA",
4884
+ currentLine: "#E8F0F5",
4885
+ selection: "#D4E9F7",
4886
+ foreground: "#485766",
4887
+ comment: "#8492A6",
4888
+ cyan: "#00ACC1",
4889
+ green: "#8BC34A",
4890
+ orange: "#FFA726",
4891
+ pink: "#FF4081",
4892
+ purple: "#7E57C2",
4893
+ red: "#EF5350",
4894
+ yellow: "#FFD740"
4895
+ },
4896
+ lightdreamyDusk: {
4897
+ background: "#F5F5F5",
4898
+ currentLine: "#E8E8E8",
4899
+ selection: "#DADADA",
4900
+ foreground: "#555555",
4901
+ comment: "#999999",
4902
+ cyan: "#5FB3B3",
4903
+ green: "#68C386",
4904
+ orange: "#FFB67A",
4905
+ pink: "#FF94B0",
4906
+ purple: "#B78BC3",
4907
+ red: "#FF6666",
4908
+ yellow: "#FFD666"
4909
+ },
4910
+ luminousLavender: {
4911
+ background: "#F3E5F5",
4912
+ currentLine: "#E1BEE7",
4913
+ selection: "#CE93D8",
4914
+ foreground: "#311B92",
4915
+ comment: "#673AB7",
4916
+ cyan: "#00BCD4",
4917
+ green: "#8BC34A",
4918
+ orange: "#FF9800",
4919
+ pink: "#E91E63",
4920
+ purple: "#9C27B0",
4921
+ red: "#F44336",
4922
+ yellow: "#FFEB3B"
4923
+ },
4924
+ meadowMornings: {
4925
+ background: "#F3E5F5",
4926
+ currentLine: "#E1BEE7",
4927
+ selection: "#CE93D8",
4928
+ foreground: "#311B92",
4929
+ comment: "#673AB7",
4930
+ cyan: "#00BCD4",
4931
+ green: "#8BC34A",
4932
+ orange: "#FF9800",
4933
+ pink: "#E91E63",
4934
+ purple: "#9C27B0",
4935
+ red: "#F44336",
4936
+ yellow: "#FFEB3B"
4937
+ },
4938
+ moonlitMauve: {
4939
+ background: "#F3E5F5",
4940
+ currentLine: "#E1BEE7",
4941
+ selection: "#CE93D8",
4942
+ foreground: "#311B92",
4943
+ comment: "#673AB7",
4944
+ cyan: "#00BCD4",
4945
+ green: "#8BC34A",
4946
+ orange: "#FF9800",
4947
+ pink: "#E91E63",
4948
+ purple: "#9C27B0",
4949
+ red: "#F44336",
4950
+ yellow: "#FFEB3B"
4951
+ },
4952
+ morningMist: {
4953
+ background: "#F6F6F6",
4954
+ currentLine: "#EAEAEA",
4955
+ selection: "#D8D8D8",
4956
+ foreground: "#333333",
4957
+ comment: "#808080",
4958
+ cyan: "#00A6A6",
4959
+ green: "#4CAF50",
4960
+ orange: "#FFA726",
4961
+ pink: "#FF4081",
4962
+ purple: "#9C27B0",
4963
+ red: "#FF5252",
4964
+ yellow: "#FFD740"
4965
+ },
4966
+ oceanBreeze: {
4967
+ background: "#ECF1F4",
4968
+ currentLine: "#DDE8ED",
4969
+ selection: "#BFD3C1",
4970
+ foreground: "#37474F",
4971
+ comment: "#607D8B",
4972
+ cyan: "#00BCD4",
4973
+ green: "#8BC34A",
4974
+ orange: "#FF9800",
4975
+ pink: "#E91E63",
4976
+ purple: "#673AB7",
4977
+ red: "#F44336",
4978
+ yellow: "#FFEB3B"
4979
+ },
4980
+ pastelParadise: {
4981
+ background: "#F5F5F5",
4982
+ currentLine: "#E8E8E8",
4983
+ selection: "#DADADA",
4984
+ foreground: "#555555",
4985
+ comment: "#999999",
4986
+ cyan: "#5FB3B3",
4987
+ green: "#68C386",
4988
+ orange: "#FFB67A",
4989
+ pink: "#FF94B0",
4990
+ purple: "#B78BC3",
4991
+ red: "#FF6666",
4992
+ yellow: "#FFD666"
4993
+ },
4994
+ pastelPetals: {
4995
+ background: "#FCE4EC",
4996
+ currentLine: "#F8BBD0",
4997
+ selection: "#FFCDD2",
4998
+ foreground: "#673AB7",
4999
+ comment: "#9575CD",
5000
+ cyan: "#00BCD4",
5001
+ green: "#4CAF50",
5002
+ orange: "#FF9800",
5003
+ pink: "#E91E63",
5004
+ purple: "#9C27B0",
5005
+ red: "#F44336",
5006
+ yellow: "#FFEB3B"
5007
+ },
5008
+ sereneSnowfall: {
5009
+ background: "#F9F9F9",
5010
+ currentLine: "#EDEDED",
5011
+ selection: "#D8D8D8",
5012
+ foreground: "#454545",
5013
+ comment: "#888888",
5014
+ cyan: "#5FA5A5",
5015
+ green: "#5BC47E",
5016
+ orange: "#FFBC8D",
5017
+ pink: "#FFA7BF",
5018
+ purple: "#B88AAE",
5019
+ red: "#FF7575",
5020
+ yellow: "#FFD98F"
5021
+ },
5022
+ softSherbet: {
5023
+ background: "#FDF8F3",
5024
+ currentLine: "#FAF1EB",
5025
+ selection: "#FFEBEE",
5026
+ foreground: "#6D4C41",
5027
+ comment: "#A1887F",
5028
+ cyan: "#00BCD4",
5029
+ green: "#689F38",
5030
+ orange: "#FFA000",
5031
+ pink: "#EC407A",
5032
+ purple: "#8E24AA",
5033
+ red: "#E53935",
5034
+ yellow: "#FFC107"
5035
+ },
5036
+ subtleSerenity: {
5037
+ background: "#F3F5F7",
5038
+ currentLine: "#E8EDF2",
5039
+ selection: "#D1D9E6",
5040
+ foreground: "#2C3E50",
5041
+ comment: "#95A5A6",
5042
+ cyan: "#3498DB",
5043
+ green: "#2ECC71",
5044
+ orange: "#F39C12",
5045
+ pink: "#E74C3C",
5046
+ purple: "#9B59B6",
5047
+ red: "#C0392B",
5048
+ yellow: "#F1C40F"
5049
+ },
5050
+ summerSunset: {
5051
+ background: "#FCE4EC",
5052
+ currentLine: "#F8BBD0",
5053
+ selection: "#FFCDD2",
5054
+ foreground: "#4E342E",
5055
+ comment: "#795548",
5056
+ cyan: "#009688",
5057
+ green: "#43A047",
5058
+ orange: "#FF5722",
5059
+ pink: "#E91E63",
5060
+ purple: "#9C27B0",
5061
+ red: "#F44336",
5062
+ yellow: "#FFEB3B"
5063
+ },
5064
+ sunnyDay: {
5065
+ background: "#FFF8E1",
5066
+ currentLine: "#FFF3E0",
5067
+ selection: "#FFE0B2",
5068
+ foreground: "#4E342E",
5069
+ comment: "#795548",
5070
+ cyan: "#00BCD4",
5071
+ green: "#8BC34A",
5072
+ orange: "#FF9800",
5073
+ pink: "#E91E63",
5074
+ purple: "#673AB7",
5075
+ red: "#F44336",
5076
+ yellow: "#FFEB3B"
5077
+ },
5078
+ tranquilTwilight: {
5079
+ background: "#F9F9F9",
5080
+ currentLine: "#EDEDED",
5081
+ selection: "#D8D8D8",
5082
+ foreground: "#454545",
5083
+ comment: "#888888",
5084
+ cyan: "#5FA5A5",
5085
+ green: "#5BC47E",
5086
+ orange: "#FFBC8D",
5087
+ pink: "#FFA7BF",
5088
+ purple: "#B88AAE",
5089
+ red: "#FF7575",
5090
+ yellow: "#FFD98F"
5091
+ },
5092
+ tranquilWaves: {
5093
+ background: "#F9F9F9",
5094
+ currentLine: "#E4E4E4",
5095
+ selection: "#D4D4D4",
5096
+ foreground: "#2C3E50",
5097
+ comment: "#7F8C8D",
5098
+ cyan: "#3498DB",
5099
+ green: "#2ECC71",
5100
+ orange: "#F39C12",
5101
+ pink: "#E74C3C",
5102
+ purple: "#9B59B6",
5103
+ red: "#C0392B",
5104
+ yellow: "#F1C40F"
5105
+ },
5106
+ whisperingWillow: {
5107
+ background: "#F6F8FA",
5108
+ currentLine: "#E8F0F5",
5109
+ selection: "#D4E9F7",
5110
+ foreground: "#485766",
5111
+ comment: "#8492A6",
5112
+ cyan: "#00ACC1",
5113
+ green: "#8BC34A",
5114
+ orange: "#FFA726",
5115
+ pink: "#FF4081",
5116
+ purple: "#7E57C2",
5117
+ red: "#EF5350",
5118
+ yellow: "#FFD740"
5119
+ }
5120
+ };
5121
+
5122
+ const DarkThemes = {
5123
+ antiqueRose: {
5124
+ background: "#1C1014",
5125
+ currentLine: "#2B1B21",
5126
+ selection: "#443034",
5127
+ foreground: "#D8B5B5",
5128
+ comment: "#7F5E5E",
5129
+ cyan: "#6FA2A2",
5130
+ green: "#66A66F",
5131
+ orange: "#FFB97A",
5132
+ pink: "#FFA8BD",
5133
+ purple: "#B78DA5",
5134
+ red: "#FF6C6C",
5135
+ yellow: "#FFD579"
5136
+ },
5137
+ auroraBorealis: {
5138
+ background: "#1D1426",
5139
+ currentLine: "#2B1E35",
5140
+ selection: "#432D4E",
5141
+ foreground: "#C2AABF",
5142
+ comment: "#7F6E8E",
5143
+ cyan: "#7EA5D3",
5144
+ green: "#77C992",
5145
+ orange: "#FFC476",
5146
+ pink: "#FFA8B3",
5147
+ purple: "#AE9AC3",
5148
+ red: "#FF6C6C",
5149
+ yellow: "#FFD576"
5150
+ },
5151
+ autumnHarvest: {
5152
+ background: "#291C10",
5153
+ currentLine: "#3A2A1E",
5154
+ selection: "#573C2C",
5155
+ foreground: "#D4C3A2",
5156
+ comment: "#7F6F52",
5157
+ cyan: "#82B4BF",
5158
+ green: "#7FB074",
5159
+ orange: "#FFAB6E",
5160
+ pink: "#FF8196",
5161
+ purple: "#B394A9",
5162
+ red: "#FF6565",
5163
+ yellow: "#FFD270"
5164
+ },
5165
+ aylin: {
5166
+ background: "#13161E",
5167
+ currentLine: "#161A28",
5168
+ selection: "#222B3E",
5169
+ foreground: "#D2D8E0",
5170
+ comment: "#697098",
5171
+ cyan: "#78D1E1",
5172
+ green: "#98C379",
5173
+ orange: "#EBCB8B",
5174
+ pink: "#D16D9E",
5175
+ purple: "#C678DD",
5176
+ red: "#E88388",
5177
+ yellow: "#EBCB8B"
5178
+ },
5179
+ azureBlue: {
5180
+ background: "#001B29",
5181
+ currentLine: "#002C3E",
5182
+ selection: "#004E6B",
5183
+ foreground: "#C3D7E2",
5184
+ comment: "#5F7C92",
5185
+ cyan: "#75B7D1",
5186
+ green: "#70C8A7",
5187
+ orange: "#FFB476",
5188
+ pink: "#FF92B0",
5189
+ purple: "#B88BC3",
5190
+ red: "#FF6666",
5191
+ yellow: "#FFD666"
5192
+ },
5193
+ cobalt2: {
5194
+ background: "#193549",
5195
+ currentLine: "#1F4662",
5196
+ selection: "#193549",
5197
+ foreground: "#B9BED0",
5198
+ comment: "#627D98",
5199
+ cyan: "#4DB5BD",
5200
+ green: "#86B300",
5201
+ orange: "#FFB86C",
5202
+ pink: "#FF7F7B",
5203
+ purple: "#9B64FB",
5204
+ red: "#FF6672",
5205
+ yellow: "#FFCC99"
5206
+ },
5207
+ cobaltMaterialTheme: {
5208
+ background: "#263238",
5209
+ currentLine: "#37474F",
5210
+ selection: "#80CBC4",
5211
+ foreground: "#CFD8DC",
5212
+ comment: "#78909C",
5213
+ cyan: "#80CBC4",
5214
+ green: "#A5D6A7",
5215
+ orange: "#FFD54F",
5216
+ pink: "#FF80AB",
5217
+ purple: "#CE93D8",
5218
+ red: "#EF5350",
5219
+ yellow: "#FFEE58"
5220
+ },
5221
+ cosmicBlue: {
5222
+ background: "#1B2836",
5223
+ currentLine: "#223348",
5224
+ selection: "#39516D",
5225
+ foreground: "#C0D4E5",
5226
+ comment: "#728CAB",
5227
+ cyan: "#75A6FF",
5228
+ green: "#5ED99F",
5229
+ orange: "#FFAD6F",
5230
+ pink: "#FF90B6",
5231
+ purple: "#A889C5",
5232
+ red: "#FF6E6E",
5233
+ yellow: "#FCD256"
5234
+ },
5235
+ cosmicSunset: {
5236
+ background: "#1B1921",
5237
+ currentLine: "#272530",
5238
+ selection: "#3C3948",
5239
+ foreground: "#B8B4CB",
5240
+ comment: "#7A738B",
5241
+ cyan: "#77B4D8",
5242
+ green: "#6CC09E",
5243
+ orange: "#FFA677",
5244
+ pink: "#FF95B2",
5245
+ purple: "#B48FC1",
5246
+ red: "#FF6565",
5247
+ yellow: "#FFD566"
5248
+ },
5249
+ cyberForest: {
5250
+ background: "#0D151D",
5251
+ currentLine: "#18262F",
5252
+ selection: "#2B3B47",
5253
+ foreground: "#CDD7E0",
5254
+ comment: "#667B8B",
5255
+ cyan: "#7EC4CF",
5256
+ green: "#68CC96",
5257
+ orange: "#FFAC6C",
5258
+ pink: "#FF89B4",
5259
+ purple: "#A889C5",
5260
+ red: "#FF6565",
5261
+ yellow: "#FFCB6B"
5262
+ },
5263
+ cyberPunkCity: {
5264
+ background: "#000000",
5265
+ currentLine: "#121212",
5266
+ selection: "#1F1F1F",
5267
+ foreground: "#DADADA",
5268
+ comment: "#626262",
5269
+ cyan: "#71B7FF",
5270
+ green: "#50D890",
5271
+ orange: "#FFB86C",
5272
+ pink: "#FF79C6",
5273
+ purple: "#BB86FC",
5274
+ red: "#FF5454",
5275
+ yellow: "#FDD663"
5276
+ },
5277
+ cyberpunkNeon: {
5278
+ background: "#121212",
5279
+ currentLine: "#1B1B1B",
5280
+ selection: "#262626",
5281
+ foreground: "#DADADA",
5282
+ comment: "#6C6C6C",
5283
+ cyan: "#69AEDB",
5284
+ green: "#4ECCA3",
5285
+ orange: "#FFB86C",
5286
+ pink: "#FF79C6",
5287
+ purple: "#D08EFF",
5288
+ red: "#FF5454",
5289
+ yellow: "#FDD663"
5290
+ },
5291
+ darkDesert: {
5292
+ background: "#1E2022",
5293
+ currentLine: "#282A2E",
5294
+ selection: "#393D42",
5295
+ foreground: "#C0C5CE",
5296
+ comment: "#5C6368",
5297
+ cyan: "#6FB3E0",
5298
+ green: "#88C076",
5299
+ orange: "#FFB454",
5300
+ pink: "#FF7F90",
5301
+ purple: "#B48EAD",
5302
+ red: "#FF6666",
5303
+ yellow: "#FFCC66"
5304
+ },
5305
+ darkMint: {
5306
+ background: "#11161A",
5307
+ currentLine: "#1B2128",
5308
+ selection: "#3D4853",
5309
+ foreground: "#D9DEE5",
5310
+ comment: "#65737E",
5311
+ cyan: "#88C0D0",
5312
+ green: "#98C379",
5313
+ orange: "#FFB86C",
5314
+ pink: "#FF7F8B",
5315
+ purple: "#C594C5",
5316
+ red: "#FF6561",
5317
+ yellow: "#FAD07B"
5318
+ },
5319
+ deepOcean: {
5320
+ background: "#121C2C",
5321
+ currentLine: "#182236",
5322
+ selection: "#2B3E50",
5323
+ foreground: "#BDC3C7",
5324
+ comment: "#6C7A89",
5325
+ cyan: "#59ABE3",
5326
+ green: "#26A65B",
5327
+ orange: "#F9690E",
5328
+ pink: "#EB3B5A",
5329
+ purple: "#D2527F",
5330
+ red: "#E74C3C",
5331
+ yellow: "#F5AB35"
5332
+ },
5333
+ deepOceanBlue: {
5334
+ background: "#1B2F40",
5335
+ currentLine: "#263B53",
5336
+ selection: "#3A536E",
5337
+ foreground: "#BFC9D4",
5338
+ comment: "#657C8E",
5339
+ cyan: "#6CB5FF",
5340
+ green: "#65C287",
5341
+ orange: "#FFA974",
5342
+ pink: "#FF87B4",
5343
+ purple: "#AE9BFF",
5344
+ red: "#FF6666",
5345
+ yellow: "#FFD67B"
5346
+ },
5347
+ deepOceanSunset: {
5348
+ background: "#151D2A",
5349
+ currentLine: "#1D2735",
5350
+ selection: "#31405B",
5351
+ foreground: "#D5D9E0",
5352
+ comment: "#6C7B8B",
5353
+ cyan: "#6FAAD4",
5354
+ green: "#66C295",
5355
+ orange: "#FFA476",
5356
+ pink: "#FF94B0",
5357
+ purple: "#B08FC0",
5358
+ red: "#FF6565",
5359
+ yellow: "#FFD466"
5360
+ },
5361
+ deepSpace: {
5362
+ background: "#0F1419",
5363
+ currentLine: "#1A232D",
5364
+ selection: "#3A4758",
5365
+ foreground: "#CDD9E5",
5366
+ comment: "#657C96",
5367
+ cyan: "#6CB6FF",
5368
+ green: "#4CAF50",
5369
+ orange: "#FFB454",
5370
+ pink: "#FF75B5",
5371
+ purple: "#9A76FF",
5372
+ red: "#FF5555",
5373
+ yellow: "#FFC857"
5374
+ },
5375
+ dracula: {
5376
+ background: "#282a36",
5377
+ currentLine: "#44475a",
5378
+ selection: "#44475a",
5379
+ foreground: "#f8f8f2",
5380
+ comment: "#6272a4",
5381
+ cyan: "#8be9fd",
5382
+ green: "#50fa7b",
5383
+ orange: "#ffb86c",
5384
+ pink: "#ff79c6",
5385
+ purple: "#bd93f9",
5386
+ red: "#ff5555",
5387
+ yellow: "#f1fa8c"
5388
+ },
5389
+ dreamyDusk: {
5390
+ background: "#22243D",
5391
+ currentLine: "#313558",
5392
+ selection: "#4C4F6D",
5393
+ foreground: "#A5A7C5",
5394
+ comment: "#6F728E",
5395
+ cyan: "#81A2BE",
5396
+ green: "#7FB074",
5397
+ orange: "#FFB476",
5398
+ pink: "#FF91A4",
5399
+ purple: "#AE8DC2",
5400
+ red: "#FF7272",
5401
+ yellow: "#FFD67A"
5402
+ },
5403
+ electricLagoon: {
5404
+ background: "#15232B",
5405
+ currentLine: "#20323E",
4807
5406
  selection: "#344E5F",
4808
5407
  foreground: "#A6C0B9",
4809
5408
  comment: "#6C8F81",
@@ -5582,606 +6181,252 @@ class ZikoUseFavIcon{
5582
6181
  return this;
5583
6182
  }
5584
6183
  get current(){
5585
- return document.__FavIcon__.href;
5586
- }
5587
- onChange(callback){
5588
- if(this.cache.Emitter)this.cache.Emitter.on("ziko:favicon-changed",callback);
5589
- return this;
5590
- }
5591
- useEventEmitter(){
5592
- this.cache.Emitter=useEventEmitter();
5593
- return this;
5594
- }
5595
-
5596
- }
5597
- const useFavIcon=(FavIcon,useEventEmitter)=>new ZikoUseFavIcon(FavIcon,useEventEmitter);
5598
-
5599
- class ZikoUseChannel{
5600
- constructor(name=""){
5601
- this.channel=new BroadcastChannel(name);
5602
- this.EVENTS_DATAS_PAIRS=new Map();
5603
- this.EVENTS_HANDLERS_PAIRS=new Map();
5604
- this.LAST_RECEIVED_EVENT="";
5605
- this.UUID="ziko-channel"+Random.string(10);
5606
- this.SUBSCRIBERS=new Set([this.UUID]);
5607
- }
5608
- get broadcast(){
5609
- // update receiver
5610
- return this;
5611
- }
5612
- emit(event, data){
5613
- this.EVENTS_DATAS_PAIRS.set(event,data);
5614
- this.#maintainEmit(event);
5615
- return this;
5616
- }
5617
- on(event,handler=console.log){
5618
- this.EVENTS_HANDLERS_PAIRS.set(event,handler);
5619
- this.#maintainOn();
5620
- return this;
5621
- }
5622
- #maintainOn(){
5623
- this.channel.onmessage = (e) => {
5624
- this.LAST_RECEIVED_EVENT=e.data.last_sended_event;
5625
- const USER_ID=e.data.userId;
5626
- this.SUBSCRIBERS.add(USER_ID);
5627
- const Data=e.data.EVENTS_DATAS_PAIRS.get(this.LAST_RECEIVED_EVENT);
5628
- const Handler=this.EVENTS_HANDLERS_PAIRS.get(this.LAST_RECEIVED_EVENT);
5629
- if(Data && Handler)Handler(Data);
5630
- };
5631
- return this;
5632
- }
5633
- #maintainEmit(event){
5634
- this.channel.postMessage({
5635
- EVENTS_DATAS_PAIRS:this.EVENTS_DATAS_PAIRS,
5636
- last_sended_event:event,
5637
- userId:this.UUID
5638
- });
5639
- return this;
5640
- }
5641
- close(){
5642
- this.channel.close();
5643
- return this;
5644
- }
5645
- }
5646
- const useChannel=name=>new ZikoUseChannel(name);
5647
-
5648
- class ZikoUseThreed {
5649
- #workerContent;
5650
- constructor() {
5651
- this.#workerContent = (
5652
- function (msg) {
5653
- try {
5654
- const func = new Function("return " + msg.data.fun)();
5655
- let result = func();
5656
- postMessage({ result });
5657
- } catch (error) {
5658
- postMessage({ error: error.message });
5659
- } finally {
5660
- if (msg.data.close) self.close();
5661
- }
5662
- }
5663
- ).toString();
5664
- this.blob = new Blob(["this.onmessage = " + this.#workerContent], { type: "text/javascript" });
5665
- this.worker = new Worker(window.URL.createObjectURL(this.blob));
5666
- }
5667
- call(func, callback, close = true) {
5668
- this.worker.postMessage({
5669
- fun: func.toString(),
5670
- close
5671
- });
5672
- this.worker.onmessage = function (e) {
5673
- if (e.data.error) {
5674
- console.error(e.data.error);
5675
- } else {
5676
- callback(e.data.result);
5677
- }
5678
- };
5679
- return this;
5680
- }
5681
- }
5682
-
5683
- const useThread = (func, callback , close) => {
5684
- const T = new ZikoUseThreed();
5685
- if (func) {
5686
- T.call(func, callback , close);
5687
- }
5688
- return T;
5689
- };
5690
-
5691
- class ZikoUseBluetooth{
5692
- constructor(options={acceptAllDevices:true}){
5693
- this.options=options;
5694
- this.__Emitter__=useEventEmitter();
5695
- if(this.isSupported)this.#init();
5696
- }
5697
- async #init(){
5698
- this.promise=navigator.bluetooth.requestDevice(this.options).then(device=>this.device=device);
5699
- }
5700
- get isSupported(){
5701
- return !!navigator.bluetooth;
5702
- }
5703
- get current(){
5704
- // Synchrouns Code
5705
- return this.device;
5706
- }
5707
- connect(){
5708
- this.server=this.device.gatt.connect();
5709
- this.__Emitter__.emit("ziko:bluetooth-connected");
5710
- return this;
5711
- }
5712
- disconnect(){
5713
- this.device.gatt.disconnect();
5714
- this.__Emitter__.emit("ziko:bluetooth-disconnected");
5715
- return this;
5716
- }
5717
- onConnect(callback){
5718
- this.__Emitter__.on("ziko:bluetooth-connected",callback);
5719
- return this;
5720
- }
5721
- onDisconnect(callback){
5722
- this.__Emitter__.on("ziko:bluetooth-disconnected",callback);
5723
- return this;
5724
- }
5725
- dispose(){
5726
-
5727
- }
5728
- async battery(callback){
5729
- const batteryService = await this.server.getPrimaryService("battery_service");
5730
- const batteryLevelCharacteristic = await batteryService.getCharacteristic("battery_level");
5731
- const batteryLevel = await batteryLevelCharacteristic.readValue();
5732
- const batteryPercent = await batteryLevel.getUint8(0);
5733
- callback(batteryPercent);
5734
- }
5735
- }
5736
- const useBluetooth=(options)=>new ZikoUseBluetooth(options);
5737
-
5738
- class ZikoUseBattery{
5739
- constructor(){
5740
- if(this.isSupported)this.#init();
5741
- }
5742
- async #init(){
5743
- this.__Battery__=await navigator.getBattery();
5744
- }
5745
- get isSupported(){
5746
- return !!navigator.getBattery;
5747
- }
5748
- get current(){
5749
- // Synchrouns Code
5750
- const {
5751
- level,
5752
- charging,
5753
- chargingTime,
5754
- dischargingTime
5755
- }=this.__Battery__;
5756
- return {
5757
- level,
5758
- charging,
5759
- chargingTime,
5760
- dischargingTime
5761
- }
5762
- }
5763
- onChargingChange(callback){
5764
- this.__Battery__.addEventListener("chargingchange",callback);
5765
- return this;
5766
- }
5767
- onLevelChange(callback){
5768
- this.__Battery__.addEventListener("levelchange",callback);
5769
- return this;
5770
- }
5771
- }
5772
- const useBattery=()=>new ZikoUseBattery();
5773
-
5774
- class ZikoUseGeolocation{
5775
- constructor(){
5776
- if(this.isSupported)this.#init();
5777
- }
5778
- async #init(){
5779
- navigator.geolocation.getCurrentPosition(e=>this.__Geolocation__=e);
5780
- }
5781
- get isSupported(){
5782
- return !!navigator.geolocation;
5783
- }
5784
- get current(){
5785
- // Synchrouns Code
5786
- return this.__Geolocation__;
6184
+ return document.__FavIcon__.href;
5787
6185
  }
5788
- }
5789
- const useGeolocation=()=>new ZikoUseGeolocation();
5790
-
5791
- class ZikoTimeLoop {
5792
- constructor(callback, {fps,step,t=[0,null],start=true}={}) {
5793
- this.callback = callback;
5794
- this.cache = {
5795
- isRunning: false,
5796
- AnimationId : null,
5797
- startTime : null,
5798
- step,
5799
- fps,
5800
- t,
5801
- started:start
5802
- };
5803
- this.adjust();
5804
- this.i=0;
5805
- }
5806
- adjust(){
5807
- if(this.cache.step && this.cache.fps){
5808
- console.warn(`Fps will be adjusted from ${this.cache.fps} to ${1000/this.cache.step} to ensure a smoother animation`);
5809
- this.cache.fps=1000/this.cache.step;
6186
+ onChange(callback){
6187
+ if(this.cache.Emitter)this.cache.Emitter.on("ziko:favicon-changed",callback);
6188
+ return this;
5810
6189
  }
5811
- if(this.cache.started){
5812
- const t=this.cache.t;
5813
- t[0]?this.startAfter(t[0]):this.start();
5814
- if(t[1])this.stopAfter(t[1]);
6190
+ useEventEmitter(){
6191
+ this.cache.Emitter=useEventEmitter();
6192
+ return this;
5815
6193
  }
5816
- return this;
5817
- }
5818
- get TIME_STEP() {
5819
- return this.cache.step?this.cache.step:1000 / this.cache.fps;
5820
- }
5821
- start() {
5822
- if (!this.cache.isRunning) {
5823
- this.i=0;
5824
- this.cache.isRunning = true;
5825
- this.cache.startTime = Date.now();
5826
- this.animate();
6194
+
6195
+ }
6196
+ const useFavIcon=(FavIcon,useEventEmitter)=>new ZikoUseFavIcon(FavIcon,useEventEmitter);
6197
+
6198
+ /*
6199
+ [
6200
+ {
6201
+ query: '(min-width: 600px)',
6202
+ callback: () => console.log(1)
6203
+ },
6204
+ {
6205
+ query: '(max-width: 300px)',
6206
+ callback: () => console.log(2)
6207
+ }
6208
+ ]
6209
+ */
6210
+ class ZikoUseMediaQuery {
6211
+ constructor(mediaQueryRules=[],fallback=()=>{}) {
6212
+ this.mediaQueryRules = mediaQueryRules;
6213
+ this.fallback = fallback;
6214
+ this.lastCalledCallback = null;
6215
+ this.init();
5827
6216
  }
5828
- return this;
5829
- }
5830
- pause() {
5831
- if (this.cache.isRunning) {
5832
- clearTimeout(this.cache.AnimationId);
5833
- this.cache.isRunning = false;
6217
+
6218
+ init() {
6219
+ this.mediaQueryRules.forEach(({ query, callback }) => {
6220
+ const mediaQueryList = globalThis.matchMedia(query);
6221
+ const checkMatches = () => {
6222
+ const anyMatch = this.mediaQueryRules.some(({ query }) => globalThis.matchMedia(query).matches);
6223
+ if (mediaQueryList.matches) {
6224
+ callback();
6225
+ this.lastCalledCallback = callback;
6226
+ } else if (!anyMatch && this.lastCalledCallback !== this.fallback) {
6227
+ this.fallback();
6228
+ this.lastCalledCallback = this.fallback;
6229
+ }
6230
+ };
6231
+ checkMatches();
6232
+ mediaQueryList.addListener(checkMatches);
6233
+ });
5834
6234
  }
5835
- return this;
5836
- }
5837
- stop(){
5838
- this.pause();
5839
- this.i=0;
5840
- return this;
5841
- }
5842
- resume(){
5843
- this.cache.isRunning=true;
5844
- this.animate();
5845
- return this;
5846
- }
5847
- startAfter(t=1000){
5848
- setTimeout(this.start.bind(this),t);
5849
- return this;
5850
- }
5851
- stopAfter(t=1000){
5852
- setTimeout(this.stop.bind(this),t);
5853
- return this;
5854
- }
5855
- animate = () => {
5856
- if (this.cache.isRunning) {
5857
- const now = Date.now();
5858
- const delta = now - this.cache.startTime;
5859
- if (delta > this.TIME_STEP) {
5860
- this.callback(this);
5861
- this.i++;
5862
- this.cache.startTime = now - (delta % this.TIME_STEP);
5863
- }
5864
- this.cache.AnimationId = setTimeout(this.animate, 0);
5865
- } }
5866
6235
  }
5867
6236
 
5868
- const loop = (callback, options) => new ZikoTimeLoop(callback, options);
6237
+ const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
5869
6238
 
5870
- const Ease={
5871
- Linear:function(t){
5872
- return t;
5873
- },
5874
- InSin(t){
5875
- return 1 - Math.cos((t * Math.PI) / 2);
5876
- },
5877
- OutSin(t){
5878
- return Math.sin((t * Math.PI) / 2);
5879
- },
5880
- InOutSin(t){
5881
- return -(Math.cos(Math.PI * t) - 1) / 2;
5882
- },
5883
- InQuad(t){
5884
- return t**2;
5885
- },
5886
- OutQuad(t){
5887
- return 1 - Math.pow((1 - t),2)
5888
- },
5889
- InOutQuad(t){
5890
- return t < 0.5 ? 2 * Math.pow(t,2) : 1 - Math.pow(-2 * t + 2, 2) / 2;
5891
- },
5892
- InCubic(t){
5893
- return t**3;
5894
- },
5895
- OutCubic(t){
5896
- return 1 - Math.pow((1 - t),3)
5897
- },
5898
- InOutCubic(t){
5899
- return t < 0.5 ? 4 * Math.pow(t,3) : 1 - Math.pow(-2 * t + 2, 3) / 2;
5900
- },
5901
- InQuart(t){
5902
- return t**4;
5903
- },
5904
- OutQuart(t){
5905
- return 1 - Math.pow((1 - t),4);
5906
- },
5907
- InOutQuart(t){
5908
- return t < 0.5 ? 8 * Math.pow(t,4) : 1 - Math.pow(-2 * t + 2, 4) / 2;
5909
- },
5910
- InQuint(t){
5911
- return t**5;
5912
- },
5913
- OutQuint(t){
5914
- return 1 - Math.pow((1 - t),5);
5915
- },
5916
- InOutQuint(t){
5917
- return t < 0.5 ? 16 * Math.pow(t,5) : 1 - Math.pow(-2 * t + 2, 5) / 2;
5918
- },
5919
- InExpo(t){
5920
- return t === 0 ? 0 : Math.pow(2, 10 * t - 10);
5921
- },
5922
- OutExpo(t){
5923
- return t === 1 ? 1 : 1 - Math.pow(2, -10 * t);
5924
- },
5925
- InOutExpo(t){
5926
- return t === 0? 0: t === 1? 1: t < 0.5 ? Math.pow(2, 20 * t - 10) / 2: (2 - Math.pow(2, -20 * t + 10)) / 2;
5927
- },
5928
- InCirc(t){
5929
- return 1 - Math.sqrt(1 - Math.pow(t, 2));
5930
- },
5931
- OutCirc(t){
5932
- return Math.sqrt(1 - Math.pow(t - 1, 2));
5933
- },
5934
- InOutCic(t){
5935
- return t < 0.5? (1 - Math.sqrt(1 - Math.pow(2 * t, 2))) / 2: (Math.sqrt(1 - Math.pow(-2 * t + 2, 2)) + 1) / 2;
5936
- },
5937
- Arc(t){
5938
- return 1 - Math.sin(Math.acos(t));
5939
- },
5940
- Back(t){
5941
- // To Be Changed
5942
- let x=1;
5943
- return Math.pow(t, 2) * ((x + 1) * t - x);
5944
- },
5945
- Elastic(t){
5946
- return -2*Math.pow(2, 10 * (t - 1)) * Math.cos(20 * Math.PI * t / 3 * t);
5947
- },
5948
- InBack(t){
5949
- const c1 = 1.70158;
5950
- const c3 = c1 + 1;
5951
- return c3 *Math.pow(t,3)- c1 * (t**2);
5952
- },
5953
- OutBack(t){
5954
- const c1 = 1.70158;
5955
- const c3 = c1 + 1;
5956
- return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
5957
- },
5958
- InOutBack(t){
5959
- const c1 = 1.70158;
5960
- const c2 = c1 * 1.525;
5961
- return t < 0.5
5962
- ? (Math.pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2
5963
- : (Math.pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2;
5964
- },
5965
- InElastic(t){
5966
- const c4 = (2 * Math.PI) / 3;return t === 0
5967
- ? 0
5968
- : t === 1
5969
- ? 1
5970
- : -Math.pow(2, 10 * t - 10) * Math.sin((t * 10 - 10.75) * c4);
5971
- },
5972
- OutElastic(t){
5973
- const c4 = (2 * Math.PI) / 3;
5974
- return t === 0
5975
- ? 0
5976
- : t === 1
5977
- ? 1
5978
- : Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1;
5979
- },
5980
- InOutElastic(t){
5981
- const c5 = (2 * Math.PI) / 4.5;
5982
- return t === 0
5983
- ? 0
5984
- : t === 1
5985
- ? 1
5986
- : t < 0.5
5987
- ? -(Math.pow(2, 20 * t - 10) * Math.sin((20 * t - 11.125) * c5)) / 2
5988
- : (Math.pow(2, -20 * t + 10) * Math.sin((20 * t - 11.125) * c5)) / 2 + 1;
5989
- },
5990
- InBounce(t){
5991
- return 1 - Ease.OutBounce(1-t);
5992
- },
5993
- OutBounce(t){
5994
- const n1 = 7.5625;
5995
- const d1 = 2.75;
5996
- if (t < 1 / d1) {
5997
- return n1 * t * t;
5998
- } else if (t < 2 / d1) {
5999
- return n1 * (t -= 1.5 / d1) * t + 0.75;
6000
- } else if (t < 2.5 / d1) {
6001
- return n1 * (t -= 2.25 / d1) * t + 0.9375;
6002
- } else {
6003
- return n1 * (t -= 2.625 / d1) * t + 0.984375;
6004
- }
6005
-
6006
- },
6007
- InOutBounce(t){
6008
- return t < 0.5
6009
- ? (1 - Ease.OutBounce(1 - 2 * t)) / 2
6010
- : (1 + Ease.OutBounce(2 * t - 1)) / 2;
6239
+ class ZikoUseChannel{
6240
+ constructor(name=""){
6241
+ this.channel=new BroadcastChannel(name);
6242
+ this.EVENTS_DATAS_PAIRS=new Map();
6243
+ this.EVENTS_HANDLERS_PAIRS=new Map();
6244
+ this.LAST_RECEIVED_EVENT="";
6245
+ this.UUID="ziko-channel"+Random.string(10);
6246
+ this.SUBSCRIBERS=new Set([this.UUID]);
6247
+ }
6248
+ get broadcast(){
6249
+ // update receiver
6250
+ return this;
6251
+ }
6252
+ emit(event, data){
6253
+ this.EVENTS_DATAS_PAIRS.set(event,data);
6254
+ this.#maintainEmit(event);
6255
+ return this;
6256
+ }
6257
+ on(event,handler=console.log){
6258
+ this.EVENTS_HANDLERS_PAIRS.set(event,handler);
6259
+ this.#maintainOn();
6260
+ return this;
6011
6261
  }
6012
- };
6013
-
6014
- const useDebounce=(fn,delay=1000)=>{
6015
- let id;
6016
- return (...args)=>id?clearTimeout(id):setTimeout(()=>fn(...args),delay)
6017
- };
6018
- const useThrottle=(fn,delay)=>{
6019
- let lastTime=0;
6020
- return (...args)=>{
6021
- const now=new Date().getTime();
6022
- if(now-lastTime<delay)return;
6023
- lastTime=now;
6024
- fn(...args);
6262
+ #maintainOn(){
6263
+ this.channel.onmessage = (e) => {
6264
+ this.LAST_RECEIVED_EVENT=e.data.last_sended_event;
6265
+ const USER_ID=e.data.userId;
6266
+ this.SUBSCRIBERS.add(USER_ID);
6267
+ const Data=e.data.EVENTS_DATAS_PAIRS.get(this.LAST_RECEIVED_EVENT);
6268
+ const Handler=this.EVENTS_HANDLERS_PAIRS.get(this.LAST_RECEIVED_EVENT);
6269
+ if(Data && Handler)Handler(Data);
6270
+ };
6271
+ return this;
6025
6272
  }
6026
- };
6027
-
6028
- const time_memory_Taken = (callback) => {
6029
- const t0 = Date.now();
6030
- const m0 = performance.memory.usedJSHeapSize;
6031
- const result = callback();
6032
- const t1 = Date.now();
6033
- const m1 = performance.memory.usedJSHeapSize;
6034
- const elapsedTime = t1 - t0;
6035
- const usedMemory = m1 - m0;
6036
- return {
6037
- elapsedTime,
6038
- usedMemory,
6039
- result
6040
- };
6041
- };
6273
+ #maintainEmit(event){
6274
+ this.channel.postMessage({
6275
+ EVENTS_DATAS_PAIRS:this.EVENTS_DATAS_PAIRS,
6276
+ last_sended_event:event,
6277
+ userId:this.UUID
6278
+ });
6279
+ return this;
6280
+ }
6281
+ close(){
6282
+ this.channel.close();
6283
+ return this;
6284
+ }
6285
+ }
6286
+ const useChannel=name=>new ZikoUseChannel(name);
6042
6287
 
6043
- const waitForUIElm=(UIElement)=>{
6044
- return new Promise(resolve => {
6045
- if (UIElement.element) {
6046
- return resolve(UIElement.element);
6047
- }
6048
-
6049
- const observer = new MutationObserver(() => {
6050
- if (UIElement.element) {
6051
- resolve(UIElement.element);
6052
- observer.disconnect();
6288
+ class ZikoUseThreed {
6289
+ #workerContent;
6290
+ constructor() {
6291
+ this.#workerContent = (
6292
+ function (msg) {
6293
+ try {
6294
+ const func = new Function("return " + msg.data.fun)();
6295
+ let result = func();
6296
+ postMessage({ result });
6297
+ } catch (error) {
6298
+ postMessage({ error: error.message });
6299
+ } finally {
6300
+ if (msg.data.close) self.close();
6301
+ }
6053
6302
  }
6303
+ ).toString();
6304
+ this.blob = new Blob(["this.onmessage = " + this.#workerContent], { type: "text/javascript" });
6305
+ this.worker = new Worker(window.URL.createObjectURL(this.blob));
6306
+ }
6307
+ call(func, callback, close = true) {
6308
+ this.worker.postMessage({
6309
+ fun: func.toString(),
6310
+ close
6054
6311
  });
6055
-
6056
- observer.observe(document.body, {
6057
- childList: true,
6058
- subtree: true
6059
- });
6060
- });
6061
- };
6062
- const waitForUIElmSync=(UIElement,timeout=2000)=>{
6063
- const t0=Date.now();
6064
- while(Date.now()-t0<timeout){
6065
- if(UIElement.element)return UIElement.element
6312
+ this.worker.onmessage = function (e) {
6313
+ if (e.data.error) {
6314
+ console.error(e.data.error);
6315
+ } else {
6316
+ callback(e.data.result);
6317
+ }
6318
+ };
6319
+ return this;
6066
6320
  }
6067
- };
6068
-
6069
- const wait=(delayInMS)=>{
6070
- return new Promise((resolve) => setTimeout(resolve, delayInMS));
6071
- };
6072
- const timeTaken = callback => {
6073
- console.time('timeTaken');
6074
- const r = callback();
6075
- console.timeEnd('timeTaken');
6076
- return r;
6321
+ }
6322
+
6323
+ const useThread = (func, callback , close) => {
6324
+ const T = new ZikoUseThreed();
6325
+ if (func) {
6326
+ T.call(func, callback , close);
6327
+ }
6328
+ return T;
6077
6329
  };
6078
6330
 
6079
- class ZikoTimeAnimation{
6080
- constructor(callback,{ease=Ease.Linear,step=50,t=[0,null],start=true,duration=3000}={}){
6081
- this.cache={
6082
- isRunning:false,
6083
- AnimationId:null,
6084
- startTime:null,
6085
- ease,
6086
- step,
6087
- intervall:t,
6088
- started:start,
6089
- duration
6090
- };
6091
- this.t=0;
6092
- this.tx=0;
6093
- this.ty=0;
6094
- this.i=0;
6095
- this.callback=callback;
6331
+ class ZikoUseBluetooth{
6332
+ constructor(options={acceptAllDevices:true}){
6333
+ this.options=options;
6334
+ this.__Emitter__=useEventEmitter();
6335
+ if(this.isSupported)this.#init();
6336
+ }
6337
+ async #init(){
6338
+ this.promise=navigator.bluetooth.requestDevice(this.options).then(device=>this.device=device);
6096
6339
  }
6097
- #animation_handler(){
6098
- this.t+=this.cache.step;
6099
- this.i++;
6100
- this.tx=map(this.t,0,this.cache.duration,0,1);
6101
- this.ty=this.cache.ease(this.tx);
6102
- this.callback(this);
6103
- if(this.t>=this.cache.duration){
6104
- clearInterval(this.cache.AnimationId);
6105
- this.cache.isRunning=false;
6106
- }
6340
+ get isSupported(){
6341
+ return !!navigator.bluetooth;
6107
6342
  }
6108
- reset(restart=true){
6109
- this.t=0;
6110
- this.tx=0;
6111
- this.ty=0;
6112
- this.i=0;
6113
- if(restart)this.start();
6114
- return this;
6343
+ get current(){
6344
+ // Synchrouns Code
6345
+ return this.device;
6115
6346
  }
6116
- #animate(reset=true){
6117
- if(!this.cache.isRunning){
6118
- if(reset)this.reset(false);
6119
- this.cache.isRunning=true;
6120
- this.cache.startTime = Date.now();
6121
- this.cache.AnimationId=setInterval(this.#animation_handler.bind(this),this.cache.step);
6122
- }
6347
+ connect(){
6348
+ this.server=this.device.gatt.connect();
6349
+ this.__Emitter__.emit("ziko:bluetooth-connected");
6123
6350
  return this;
6124
6351
  }
6125
- start(){
6126
- this.#animate(true);
6352
+ disconnect(){
6353
+ this.device.gatt.disconnect();
6354
+ this.__Emitter__.emit("ziko:bluetooth-disconnected");
6127
6355
  return this;
6128
6356
  }
6129
- pause(){
6130
- if (this.cache.isRunning) {
6131
- clearTimeout(this.cache.AnimationId);
6132
- this.cache.isRunning = false;
6133
- }
6357
+ onConnect(callback){
6358
+ this.__Emitter__.on("ziko:bluetooth-connected",callback);
6134
6359
  return this;
6135
6360
  }
6136
- resume(){
6137
- this.#animate(false);
6361
+ onDisconnect(callback){
6362
+ this.__Emitter__.on("ziko:bluetooth-disconnected",callback);
6138
6363
  return this;
6139
6364
  }
6140
- stop(){
6141
- this.pause();
6142
- this.reset(false);
6143
- return this;
6365
+ dispose(){
6366
+
6367
+ }
6368
+ async battery(callback){
6369
+ const batteryService = await this.server.getPrimaryService("battery_service");
6370
+ const batteryLevelCharacteristic = await batteryService.getCharacteristic("battery_level");
6371
+ const batteryLevel = await batteryLevelCharacteristic.readValue();
6372
+ const batteryPercent = await batteryLevel.getUint8(0);
6373
+ callback(batteryPercent);
6144
6374
  }
6145
- // clear(){
6146
- // }
6147
- // stream(){
6148
- // }
6149
6375
  }
6150
-
6151
- const animation=(callback,config)=>new ZikoTimeAnimation(callback,config);
6376
+ const useBluetooth=(options)=>new ZikoUseBluetooth(options);
6152
6377
 
6153
- const Time={
6154
- wait,
6155
- timeTaken,
6156
- useThrottle,
6157
- useDebounce,
6158
- Ease,
6159
- time_memory_Taken,
6160
- loop,
6161
- animation,
6162
- waitForUIElm,
6163
- waitForUIElmSync,
6164
- ExtractAll: function () {
6165
- const keys = Object.keys(this);
6166
- for (let i = 0; i < keys.length; i++) {
6167
- const key = keys[i];
6168
- if (key !== 'ExtractAll' && key !== 'RemoveAll') {
6169
- globalThis[key] = this[key];
6170
- }
6378
+ class ZikoUseBattery{
6379
+ constructor(){
6380
+ if(this.isSupported)this.#init();
6381
+ }
6382
+ async #init(){
6383
+ this.__Battery__=await navigator.getBattery();
6384
+ }
6385
+ get isSupported(){
6386
+ return !!navigator.getBattery;
6387
+ }
6388
+ get current(){
6389
+ // Synchrouns Code
6390
+ const {
6391
+ level,
6392
+ charging,
6393
+ chargingTime,
6394
+ dischargingTime
6395
+ }=this.__Battery__;
6396
+ return {
6397
+ level,
6398
+ charging,
6399
+ chargingTime,
6400
+ dischargingTime
6171
6401
  }
6402
+ }
6403
+ onChargingChange(callback){
6404
+ this.__Battery__.addEventListener("chargingchange",callback);
6172
6405
  return this;
6173
- },
6174
- RemoveAll: function () {
6175
- const keys = Object.keys(this);
6176
- for (let i = 0; i < keys.length; i++) {
6177
- const key = keys[i];
6178
- if (key !== 'RemoveAll') {
6179
- delete globalThis[key];
6180
- }
6181
- }
6406
+ }
6407
+ onLevelChange(callback){
6408
+ this.__Battery__.addEventListener("levelchange",callback);
6182
6409
  return this;
6183
6410
  }
6184
- };
6411
+ }
6412
+ const useBattery=()=>new ZikoUseBattery();
6413
+
6414
+ class ZikoUseGeolocation{
6415
+ constructor(){
6416
+ if(this.isSupported)this.#init();
6417
+ }
6418
+ async #init(){
6419
+ navigator.geolocation.getCurrentPosition(e=>this.__Geolocation__=e);
6420
+ }
6421
+ get isSupported(){
6422
+ return !!navigator.geolocation;
6423
+ }
6424
+ get current(){
6425
+ // Synchrouns Code
6426
+ return this.__Geolocation__;
6427
+ }
6428
+ }
6429
+ const useGeolocation=()=>new ZikoUseGeolocation();
6185
6430
 
6186
6431
  // To do : remove old items
6187
6432
  class ZikoUseStorage{
@@ -6268,6 +6513,7 @@ const useSuccesifKeys=(self,keys=[],callback=()=>{})=>{
6268
6513
  const Use={
6269
6514
  useStyle,
6270
6515
  useTheme,
6516
+ useMediaQuery,
6271
6517
  useBattery,
6272
6518
  useGeolocation,
6273
6519
  useEventEmitter,
@@ -6303,6 +6549,22 @@ const Use={
6303
6549
  }
6304
6550
  };
6305
6551
 
6552
+ const Reactivity={
6553
+ Events,
6554
+ Observer,
6555
+ Use,
6556
+ ExtractAll: function () {
6557
+ this.Events.ExtractAll();
6558
+ this.Observer.ExtractAll();
6559
+ this.Use.ExtractAll();
6560
+ },
6561
+ RemoveAll: function () {
6562
+ this.Events.RemoveAll();
6563
+ this.Observer.RemoveAll();
6564
+ this.Use.RemoveAll();
6565
+ }
6566
+ };
6567
+
6306
6568
  class ZikoUIElement {
6307
6569
  constructor(element,name="") {
6308
6570
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis.document.body;
@@ -6525,15 +6787,18 @@ class ZikoUIElement {
6525
6787
  const [names,values]=[Object.keys(name),Object.values(name)];
6526
6788
  for(let i=0;i<names.length;i++){
6527
6789
  if(values[i] instanceof Array)value[i] = values[i].join(" ");
6528
- this.element.setAttribute(names[i], values[i]);
6529
- Object.assign(this.cache.attributes, Object.fromEntries([[names[i], values[i]]]));
6790
+ if(this?.attr[name[i]]!==value[i]){
6791
+ this.element.setAttribute(names[i], values[i]);
6792
+ Object.assign(this.cache.attributes, Object.fromEntries([[names[i], values[i]]]));
6793
+ }
6530
6794
  }
6531
6795
  }
6532
6796
  else {
6533
6797
  if(value instanceof Array)value = value.join(" ");
6534
- this.element.setAttribute(name, value);
6535
- Object.assign(this.cache.attributes, Object.fromEntries([[name, value]]));
6536
-
6798
+ if(this?.attr[name]!==value){
6799
+ this.element.setAttribute(name, value);
6800
+ Object.assign(this.cache.attributes, Object.fromEntries([[name, value]]));
6801
+ }
6537
6802
  }
6538
6803
  return this;
6539
6804
  }
@@ -6564,7 +6829,7 @@ class ZikoUIElement {
6564
6829
  return this;*/
6565
6830
  }
6566
6831
  setId(id) {
6567
- this.element.setAttribute("id", id);
6832
+ this.setAttr("id", id);
6568
6833
  return this;
6569
6834
  }
6570
6835
  get id() {
@@ -6614,173 +6879,175 @@ class ZikoUIElement {
6614
6879
  return this;
6615
6880
  }
6616
6881
  onPtrMove(...callbacks){
6617
- if(!this.events.ptr)this.events.ptr = Pointer(this);
6882
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
6618
6883
  this.events.ptr.onMove(...callbacks);
6619
6884
  return this;
6620
6885
  }
6621
6886
  onPtrDown(...callbacks){
6622
- if(!this.events.ptr)this.events.ptr = Pointer(this);
6887
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
6623
6888
  this.events.ptr.onDown(...callbacks);
6624
6889
  return this;
6625
6890
  }
6626
6891
  onPtrUp(...callbacks){
6627
- if(!this.events.ptr)this.events.ptr = Pointer(this);
6892
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
6628
6893
  this.events.ptr.onUp(...callbacks);
6629
6894
  return this;
6630
6895
  }
6631
6896
  onPtrEnter(...callbacks){
6632
- if(!this.events.ptr)this.events.ptr = Pointer(this);
6897
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
6633
6898
  this.events.ptr.onEnter(...callbacks);
6634
6899
  return this;
6635
6900
  }
6636
6901
  onPtrLeave(...callbacks){
6637
- if(!this.events.ptr)this.events.ptr = Pointer(this);
6902
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
6638
6903
  this.events.ptr.onLeave(...callbacks);
6639
6904
  return this;
6640
6905
  }
6641
6906
  onPtrOut(...callbacks){
6642
- if(!this.events.ptr)this.events.ptr = Pointer(this);
6907
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
6643
6908
  this.events.ptr.onOut(...callbacks);
6644
6909
  return this;
6645
6910
  }
6646
6911
  onMouseMove(...callbacks){
6647
- if(!this.events.mouse)this.events.mouse = Mouse(this);
6912
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
6648
6913
  this.events.mouse.onMove(...callbacks);
6649
6914
  return this;
6650
6915
  }
6651
6916
  onMouseDown(...callbacks){
6652
- if(!this.events.mouse)this.events.mouse = Mouse(this);
6917
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
6653
6918
  this.events.mouse.onDown(...callbacks);
6654
6919
  return this;
6655
6920
  }
6656
6921
  onMouseUp(...callbacks){
6657
- if(!this.events.mouse)this.events.mouse = Mouse(this);
6922
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
6658
6923
  this.events.mouse.onUp(...callbacks);
6659
6924
  return this;
6660
6925
  }
6661
6926
  onMouseEnter(...callbacks){
6662
- if(!this.events.mouse)this.events.mouse = Mouse(this);
6927
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
6663
6928
  this.events.mouse.onEnter(...callbacks);
6664
6929
  return this;
6665
6930
  }
6666
6931
  onMouseLeave(...callbacks){
6667
- if(!this.events.mouse)this.events.mouse = Mouse(this);
6932
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
6668
6933
  this.events.mouse.onLeave(...callbacks);
6669
6934
  return this;
6670
6935
  }
6671
6936
  onMouseOut(...callbacks){
6672
- if(!this.events.mouse)this.events.mouse = Mouse(this);
6937
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
6673
6938
  this.events.mouse.onOut(...callbacks);
6674
6939
  return this;
6675
6940
  }
6676
6941
  onWheel(...callbacks){
6677
- if(!this.events.wheel)this.events.wheel = Wheel(this);
6942
+ if(!this.events.wheel)this.events.wheel = useWheelEventnent(this);
6678
6943
  this.events.wheel.onWheel(...callbacks);
6679
6944
  return this;
6680
6945
  }
6681
6946
  onKeyDown(...callbacks){
6682
- if(!this.events.key)this.events.key = Key(this);
6947
+ if(!this.events.key)this.events.key = useKeyEvenent(this);
6683
6948
  this.events.key.onDown(...callbacks);
6684
6949
  return this;
6685
6950
  }
6686
6951
  onKeyPress(...callbacks){
6687
- if(!this.events.key)this.events.key = Key(this);
6952
+ if(!this.events.key)this.events.key = useKeyEvenent(this);
6688
6953
  this.events.key.onPress(...callbacks);
6689
6954
  return this;
6690
6955
  }
6691
6956
  onKeyUp(...callbacks){
6692
- if(!this.events.key)this.events.key = Key(this);
6957
+ if(!this.events.key)this.events.key = useKeyEvenent(this);
6693
6958
  this.events.key.onUp(...callbacks);
6694
6959
  return this;
6695
6960
  }
6696
6961
  onKeysDown({keys=[],callback}={}){
6697
- if(!this.events.key)this.events.key = Key(this);
6962
+ if(!this.events.key)this.events.key = useKeyEvenent(this);
6698
6963
  this.events.key.handleSuccessifKeys({keys,callback});
6699
6964
  return this;
6700
6965
  }
6701
6966
  onDragStart(...callbacks){
6702
- if(!this.events.drag)this.events.drag = Drag(this);
6967
+ if(!this.events.drag)this.events.drag = useDragEvent(this);
6703
6968
  this.events.drag.onStart(...callbacks);
6704
6969
  return this;
6705
6970
  }
6706
6971
  onDrag(...callbacks){
6707
- if(!this.events.drag)this.events.drag = Drag(this);
6972
+ if(!this.events.drag)this.events.drag = useDragEvent(this);
6708
6973
  this.events.drag.onDrag(...callbacks);
6709
6974
  return this;
6710
6975
  }
6711
6976
  onDragEnd(...callbacks){
6712
- if(!this.events.drag)this.events.drag = Drag(this);
6977
+ if(!this.events.drag)this.events.drag = useDragEvent(this);
6713
6978
  this.events.drag.onEnd(...callbacks);
6714
6979
  return this;
6715
6980
  }
6716
6981
  onDrop(...callbacks){
6717
- if(!this.events.drop)this.events.drop = Drop(this);
6982
+ if(!this.events.drop)this.events.drop = useDropEvent(this);
6718
6983
  this.events.drop.onDrop(...callbacks);
6719
6984
  return this;
6720
6985
  }
6721
6986
  onClick(...callbacks){
6722
- if(!this.events.click)this.events.click = Click(this);
6987
+ if(!this.events.click)this.events.click = useClickEventnt(this);
6723
6988
  this.events.click.onClick(...callbacks);
6724
6989
  return this;
6725
6990
  }
6726
6991
  onDbClick(...callbacks){
6727
- if(!this.events.click)this.events.click = Click(this);
6992
+ if(!this.events.click)this.events.click = useClickEventnt(this);
6728
6993
  this.events.click.onDbClick(...callbacks);
6729
6994
  return this;
6730
6995
  }
6731
6996
  onCopy(...callbacks){
6732
- if(!this.events.clipboard)this.events.clipboard = Clipboard(this);
6997
+ if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
6733
6998
  this.events.clipboard.onCopy(...callbacks);
6734
6999
  return this;
6735
7000
  }
6736
7001
  onCut(...callbacks){
6737
- if(!this.events.clipboard)this.events.clipboard = Clipboard(this);
7002
+ if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
6738
7003
  this.events.clipboard.onCut(...callbacks);
6739
7004
  return this;
6740
7005
  }
6741
7006
  onPaste(...callbacks){
6742
- if(!this.events.clipboard)this.events.clipboard = Clipboard(this);
7007
+ if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
6743
7008
  this.events.clipboard.onPaste(...callbacks);
6744
7009
  return this;
6745
7010
  }
6746
7011
  onSelect(...callbacks){
6747
- if(!this.events.clipboard)this.events.clipboard = Clipboard(this);
7012
+ if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
6748
7013
  this.events.clipboard.onSelect(...callbacks);
6749
7014
  return this;
6750
7015
  }
6751
7016
  onFocus(...callbacks){
6752
- if(!this.events.focus)this.events.focus = Focus(this);
7017
+ if(!this.events.focus)this.events.focus = useFocusEvent(this);
6753
7018
  this.events.focus.onFocus(...callbacks);
6754
7019
  return this;
6755
7020
  }
6756
7021
  onBlur(...callbacks){
6757
- if(!this.events.focus)this.events.focus = Focus(this);
7022
+ if(!this.events.focus)this.events.focus = useFocusEvent(this);
6758
7023
  this.events.focus.onFocus(...callbacks);
6759
7024
  return this;
6760
7025
  }
6761
7026
  on(event_name,...callbacks){
6762
- if(!this.events.custom)this.events.custom = customEvent(this);
7027
+ if(!this.events.custom)this.events.custom = useCustomEvent(this);
6763
7028
  this.events.custom.on(event_name,...callbacks);
6764
7029
  return this;
6765
7030
  }
6766
7031
  emit(event_name,detail={}){
6767
- if(!this.events.custom)this.events.custom = customEvent(this);
7032
+ if(!this.events.custom)this.events.custom = useCustomEvent(this);
6768
7033
  this.events.custom.emit(event_name,detail);
6769
7034
  return this;
6770
7035
  }
6771
- watchAttr(){
6772
-
7036
+ watchAttr(callback){
7037
+ if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
7038
+ return this;
6773
7039
  }
6774
- watchChildren(){
6775
-
7040
+ watchChildren(callback){
7041
+ if(!this.observer.children)this.observer.children = watchChildren(this,callback);
7042
+ return this;
6776
7043
  }
6777
7044
  watchSize(callback){
6778
- if(!this.observer.resize)this.observer.resize = WatchSize(this,callback);
7045
+ if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
6779
7046
  this.observer.resize.start();
6780
7047
  return this;
6781
7048
  }
6782
7049
  watchIntersection(callback,config){
6783
- if(!this.observer.intersection)this.observer.intersection = WatchIntersection(this,callback,config);
7050
+ if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
6784
7051
  this.observer.intersection.start();
6785
7052
  return this;
6786
7053
  }
@@ -7186,20 +7453,20 @@ class ZikoUITextArea extends ZikoUIElement {
7186
7453
  //import { debounce,throttle} from "../../Data/decorators.js";
7187
7454
 
7188
7455
  class ZikoUIInput extends ZikoUIElement {
7189
- constructor(value = "",datalist) {
7190
- super();
7456
+ constructor(name , value = "",datalist) {
7457
+ super("input",name);
7191
7458
  this.element = document.createElement("input");
7192
7459
  Object.assign(this.events,{input:null});
7193
7460
  this.setValue(value);
7194
7461
  if(datalist)this.linkDatalist(datalist);
7195
7462
  }
7196
7463
  onInput(...callbacks){
7197
- if(!this.events.input)this.events.input = Input$1(this);
7464
+ if(!this.events.input)this.events.input = useInputEvent(this);
7198
7465
  this.events.input.onInput(...callbacks);
7199
7466
  return this;
7200
7467
  }
7201
7468
  onChange(...callbacks){
7202
- if(!this.events.input)this.events.input = Input$1(this);
7469
+ if(!this.events.input)this.events.input = useInputEvent(this);
7203
7470
  this.events.input.onChange(...callbacks);
7204
7471
  return this;
7205
7472
  }
@@ -7262,7 +7529,7 @@ class ZikoUIInput extends ZikoUIElement {
7262
7529
  }
7263
7530
  class ZikoUIInputSearch extends ZikoUIInput {
7264
7531
  constructor() {
7265
- super();
7532
+ super("inputSearch");
7266
7533
  this._setType("search");
7267
7534
  this.Length = 0;
7268
7535
  }
@@ -7299,7 +7566,7 @@ class ZikoUIInputSearch extends ZikoUIInput {
7299
7566
  }
7300
7567
  class ZikoUIInputNumber extends ZikoUIInput {
7301
7568
  constructor(min, max ,step = 1) {
7302
- super();
7569
+ super("inpuNumber");
7303
7570
  this._setType("number");
7304
7571
  this.setMin(min).setMax(max).setStep(step);
7305
7572
  }
@@ -7321,14 +7588,14 @@ class ZikoUIInputNumber extends ZikoUIInput {
7321
7588
  }
7322
7589
  class ZikoUIInputSlider extends ZikoUIInputNumber {
7323
7590
  constructor(val = 0, min = 0, max = 10, step = 1) {
7324
- super();
7591
+ super("inputSlider");
7325
7592
  this._setType("range");
7326
7593
  this.setMin(min).setMax(max).setValue(val).setStep(step);
7327
7594
  }
7328
7595
  }
7329
7596
  class ZikoUIInputColor extends ZikoUIInput {
7330
7597
  constructor() {
7331
- super();
7598
+ super("inputColor");
7332
7599
  this._setType("color");
7333
7600
  this.background(this.value);
7334
7601
  this.onInput(() => this.background(this.value));
@@ -7336,37 +7603,37 @@ class ZikoUIInputColor extends ZikoUIInput {
7336
7603
  }
7337
7604
  class ZikoUIInputPassword extends ZikoUIInput {
7338
7605
  constructor() {
7339
- super();
7606
+ super("inputPassword");
7340
7607
  this._setType("password");
7341
7608
  }
7342
7609
  }
7343
7610
  class ZikoUIInputEmail extends ZikoUIInput {
7344
7611
  constructor() {
7345
- super();
7612
+ super("inputEmail");
7346
7613
  this._setType("email");
7347
7614
  }
7348
7615
  }
7349
7616
  class ZikoUIInputTime extends ZikoUIInput {
7350
7617
  constructor() {
7351
- super();
7618
+ super("inputTime");
7352
7619
  this._setType("time");
7353
7620
  }
7354
7621
  }
7355
7622
  class ZikoUIInputDate extends ZikoUIInput {
7356
7623
  constructor() {
7357
- super();
7624
+ super("inputDate");
7358
7625
  this._setType("date");
7359
7626
  }
7360
7627
  }
7361
7628
  class ZikoUIInputDateTime extends ZikoUIInput {
7362
7629
  constructor() {
7363
- super();
7630
+ super("inputDateTime");
7364
7631
  this._setType("datetime-local");
7365
7632
  }
7366
7633
  }
7367
7634
  class ZikoUIInputCheckbox extends ZikoUIInput {
7368
7635
  constructor() {
7369
- super();
7636
+ super("inputCheckbox");
7370
7637
  this._setType("checkbox");
7371
7638
  this.cursor("pointer");
7372
7639
  }
@@ -7384,7 +7651,7 @@ class ZikoUIInputCheckbox extends ZikoUIInput {
7384
7651
  }
7385
7652
  class ZikoUIInputRadio extends ZikoUIInput {
7386
7653
  constructor() {
7387
- super();
7654
+ super("inputRadio");
7388
7655
  this._setType("radio");
7389
7656
  this.cursor("pointer");
7390
7657
  }
@@ -7404,7 +7671,7 @@ class ZikoUIInputRadio extends ZikoUIInput {
7404
7671
 
7405
7672
  class ZikoUIInputImage extends ZikoUIElement {
7406
7673
  constructor(text = "File") {
7407
- super();
7674
+ super("inputImage");
7408
7675
  this._aux_element = btn(text).setTarget(this.Target);
7409
7676
  this.element = document.createElement("input");
7410
7677
  this.element.setAttribute("type", "file");
@@ -8923,69 +9190,361 @@ const preload=(url)=>{
8923
9190
  } else {
8924
9191
  throw new Error(`Failed to fetch data from ${url}. Status: ${xhr.status}`);
8925
9192
  }
8926
- };
8927
-
8928
- async function fetchdom(url='https://github.com/zakarialaoui10'){
8929
- const data=await fetch(url);
8930
- const html=await data.text();
8931
- const dom= new DOMParser().parseFromString(html,'text/xml');
8932
- return dom.documentElement
8933
- }
8934
- function fetchdomSync(url='https://github.com/zakarialaoui10'){
8935
- const data=preload(url);
8936
- const dom= new DOMParser().parseFromString(data,'text/xml');
8937
- return dom.documentElement;
8938
- }
8939
-
8940
- globalThis.fetchdom=fetchdom;
8941
- globalThis.fetchdomSync=fetchdomSync;
8942
-
8943
- const Data={
8944
- parseXML,
8945
- preload,
8946
- markdown2html,
8947
- adoc2html,
8948
- csv2arr,
8949
- csv2matrix,
8950
- csv2object,
8951
- csv2json,
8952
- csv2sql,
8953
- json2arr,
8954
- json2csv,
8955
- json2csvFile,
8956
- json2yml,
8957
- json2ymlFile,
8958
- json2xml,
8959
- json2xmlFile,
8960
- svg2str,
8961
- svg2ascii,
8962
- svg2imgUrl,
8963
- svg2img,
8964
- ExtractAll: function () {
8965
- const keys = Object.keys(this);
8966
- for (let i = 0; i < keys.length; i++) {
8967
- const key = keys[i];
8968
- if (key !== 'ExtractAll' && key !== 'RemoveAll') {
8969
- globalThis[key] = this[key];
8970
- }
8971
- }
8972
- return this;
8973
- },
8974
- RemoveAll: function () {
8975
- const keys = Object.keys(this);
8976
- for (let i = 0; i < keys.length; i++) {
8977
- const key = keys[i];
8978
- if (key !== 'RemoveAll') {
8979
- delete globalThis[key];
8980
- }
8981
- }
8982
- return this;
9193
+ };
9194
+
9195
+ async function fetchdom(url='https://github.com/zakarialaoui10'){
9196
+ const data=await fetch(url);
9197
+ const html=await data.text();
9198
+ const dom= new DOMParser().parseFromString(html,'text/xml');
9199
+ return dom.documentElement
9200
+ }
9201
+ function fetchdomSync(url='https://github.com/zakarialaoui10'){
9202
+ const data=preload(url);
9203
+ const dom= new DOMParser().parseFromString(data,'text/xml');
9204
+ return dom.documentElement;
9205
+ }
9206
+
9207
+ globalThis.fetchdom=fetchdom;
9208
+ globalThis.fetchdomSync=fetchdomSync;
9209
+
9210
+ const Patterns={
9211
+ isDigit: /^\d+$/,
9212
+ isEmail: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
9213
+ isURL: /^(https?:\/\/)?([\w\-]+\.)+[\w\-]+(\/[\w\-./?%&=]*)?$/,
9214
+ isHexColor: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,
9215
+ isIPv4: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
9216
+ isMACAddress: /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/,
9217
+ isDate: /^\d{4}-\d{2}-\d{2}$/,
9218
+ };
9219
+
9220
+ class Str{
9221
+ constructor(string){
9222
+ this.string=string;
9223
+ }
9224
+ isDigit() {
9225
+ return Patterns.isDigit.test(this.string);
9226
+ }
9227
+ static isDigit(string){
9228
+ return new Str(string).isDigit();
9229
+ }
9230
+ isNumber() {
9231
+ return !isNaN(this.string);
9232
+ }
9233
+ static isNumber(string){
9234
+ return new Str(string).isNumber();
9235
+ }
9236
+ isUrl(){
9237
+ return Patterns.isURL.test(this.string);
9238
+ }
9239
+ static isUrl(string){
9240
+ return new Str(string).isUrl();
9241
+ }
9242
+ isHexColor(){
9243
+ return Patterns.isHexColor.test(this.string);
9244
+ }
9245
+ static isHexColor(string){
9246
+ return new Str(string).isHexColor();
9247
+ }
9248
+ isIPv4(){
9249
+ return Patterns.isIPv4.test(this.string);
9250
+ }
9251
+ static isIPv4(string){
9252
+ return new Str(string).isIPv4();
9253
+ }
9254
+ isDate(){
9255
+ return Patterns.isDate.test(this.string);
9256
+ }
9257
+ static isDate(string){
9258
+ return new Str(string).isDate();
9259
+ }
9260
+ isMACAddress(){
9261
+ return Patterns.isMACAddress.test(this.string);
9262
+ }
9263
+ static isMACAddress(string){
9264
+ return new Str(string).isMACAddress();
9265
+ }
9266
+ isPascalCase(){
9267
+ if (this.string.length === 0) return false;
9268
+ const PascalCasePattern = /^[A-Z][a-zA-Z0-9]*$/;
9269
+ return PascalCasePattern.test(this.string);
9270
+ }
9271
+ static isPascalCase(string){
9272
+ return new Str(string).isPascalCase();
9273
+ }
9274
+ isCamelCase() {
9275
+ if (this.string.length === 0) return false;
9276
+ const camelCasePattern = /^[a-z][a-zA-Z0-9]*$/;
9277
+ return camelCasePattern.test(this.string);
9278
+ }
9279
+ static isCamelCase(string){
9280
+ return new Str(string).isCamelCase();
9281
+ }
9282
+ isHyphenCase(){
9283
+ return this.string.split('-').length > 1;
9284
+ }
9285
+ static isHyphenCase(string){
9286
+ return new Str(string).isHyphenCase();
9287
+ }
9288
+ isSnakeCase(){
9289
+ return this.string.split('_').length > 1;
9290
+ }
9291
+ static isSnakeCase(string){
9292
+ return new Str(string).isSnakeCase();
9293
+ }
9294
+ isPalindrome(){
9295
+ const str=this.string.toLocaleLowerCase();
9296
+ let l=str.length,i;
9297
+ for(i=0;i<l/2;i++)if(str[i]!=str[l-i-1])return false;
9298
+ return true;
9299
+ }
9300
+ static isPalindrome(string){
9301
+ return new Str(string).isPalindrome();
9302
+ }
9303
+ static isAnagrams(word,words){
9304
+ word=word.split("").sort();
9305
+ words=words.split("").sort();
9306
+ return JSON.stringify(word)===JSON.stringify(words);
9307
+ }
9308
+ isIsogram(){
9309
+ return [...new Set(this.string.toLowerCase())].length===this.string.length;
9310
+ }
9311
+ static isIsogram(string){
9312
+ return new Str(string).isIsogram();
9313
+ }
9314
+ static camel2hyphencase(text) {
9315
+ return text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
9316
+ }
9317
+ static camel2snakecase(text) {
9318
+ return text.replace(/[A-Z]/g, match => '_' + match.toLowerCase());
9319
+ }
9320
+ static camel2pascalcase(text) {
9321
+ return text.charAt(0).toUpperCase() + text.slice(1);
9322
+ }
9323
+ static camel2constantcase(text) {
9324
+ return text.replace(/[A-Z]/g, match => '_' + match).toUpperCase();
9325
+ }
9326
+ static pascal2snakecase(text) {
9327
+ return text.replace(/([A-Z])/g, (match, offset) => offset ? '_' + match.toLowerCase() : match.toLowerCase());
9328
+ }
9329
+ static pascal2hyphencase(text) {
9330
+ return text.replace(/([A-Z])/g, (match, offset) => offset ? '-' + match.toLowerCase() : match.toLowerCase());
9331
+ }
9332
+ static pascal2camelcase(text) {
9333
+ return text.charAt(0).toLowerCase() + text.slice(1);
9334
+ }
9335
+ static pascal2constantcase(text) {
9336
+ return text.replace(/([A-Z])/g, (match, offset) => offset ? '_' + match : match).toUpperCase();
9337
+ }
9338
+ static snake2camelcase(text) {
9339
+ return text.replace(/(_\w)/g, match => match[1].toUpperCase());
9340
+ }
9341
+ static snake2hyphencase(text) {
9342
+ return text.replace(/_/g, "-");
9343
+ }
9344
+ static snake2pascalcase(text) {
9345
+ return text.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('');
9346
+ }
9347
+ static snake2constantcase(text) {
9348
+ return text.toUpperCase();
9349
+ }
9350
+ static hyphen2camelcase(text) {
9351
+ return text.replace(/-([a-z])/g, match => match[1].toUpperCase());
9352
+ }
9353
+ static hyphen2snakecase(text) {
9354
+ return text.replace(/-/g, '_');
9355
+ }
9356
+ static hyphen2pascalcase(text) {
9357
+ return text.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('');
9358
+ }
9359
+ static hyphen2constantcase(text) {
9360
+ return text.replace(/-/g, '_').toUpperCase();
9361
+ }
9362
+ static constant2camelcase(text) {
9363
+ return text.toLowerCase().replace(/_([a-z])/g, match => match[1].toUpperCase());
9364
+ }
9365
+ static constant2snakecase(text) {
9366
+ return text.toLowerCase();
9367
+ }
9368
+ static constant2pascalcase(text) {
9369
+ return text.toLowerCase().split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('');
9370
+ }
9371
+ static constant2hyphencase(text) {
9372
+ return text.toLowerCase().replace(/_/g, '-');
9373
+ }
9374
+ }
9375
+ const removeExtraSpace=str=>str.replace(/\s+/g,' ');
9376
+ const count=(str,value)=>str.split("").filter(x => x==value).length;
9377
+ const countWords=(str,value)=>str.split(" ").filter(x => x==value).length;
9378
+ const str=string=>new Str(string);
9379
+
9380
+ const Data={
9381
+ str,
9382
+ Str,
9383
+ parseXML,
9384
+ preload,
9385
+ markdown2html,
9386
+ adoc2html,
9387
+ csv2arr,
9388
+ csv2matrix,
9389
+ csv2object,
9390
+ csv2json,
9391
+ csv2sql,
9392
+ json2arr,
9393
+ json2csv,
9394
+ json2csvFile,
9395
+ json2yml,
9396
+ json2ymlFile,
9397
+ json2xml,
9398
+ json2xmlFile,
9399
+ svg2str,
9400
+ svg2ascii,
9401
+ svg2imgUrl,
9402
+ svg2img,
9403
+ ExtractAll: function () {
9404
+ const keys = Object.keys(this);
9405
+ for (let i = 0; i < keys.length; i++) {
9406
+ const key = keys[i];
9407
+ if (key !== 'ExtractAll' && key !== 'RemoveAll') {
9408
+ globalThis[key] = this[key];
9409
+ }
9410
+ }
9411
+ return this;
9412
+ },
9413
+ RemoveAll: function () {
9414
+ const keys = Object.keys(this);
9415
+ for (let i = 0; i < keys.length; i++) {
9416
+ const key = keys[i];
9417
+ if (key !== 'RemoveAll') {
9418
+ delete globalThis[key];
9419
+ }
9420
+ }
9421
+ return this;
9422
+ }
9423
+ };
9424
+
9425
+ // import svgRect from "./Elements/rect.js";
9426
+ // import svgCircle from "./Elements/circle.js";
9427
+ // import svgEllipse from "./Elements/ellipse.js";
9428
+ // import svgLine from "./Elements/line.js";
9429
+ // //import svgPath from "./Elements/path.js";
9430
+ // import svgPolygon from "./Elements/polygon.js";
9431
+ // import svgImage from "./Elements/image.js";
9432
+ // import svgText from "./Elements/text.js";
9433
+ // import svgGroupe from "./Elements/groupe.js";
9434
+ // import svgLink from "./Elements/link.js";
9435
+ // //import svgObject from "./Elements/foreignObject.js";
9436
+ // //import svgGrid from "./Elements/grid.js";
9437
+
9438
+ class ZikoUISvg extends ZikoUIElement {
9439
+ constructor(w=360,h=300) {
9440
+ super("svg","svg");
9441
+ //this.cache={};
9442
+ this.setAttr("width",w);
9443
+ this.setAttr("height",h);
9444
+ this.style({border:"1px black solid"});
9445
+ //this.view(-w/2,-h/2,w/2,h/2)
9446
+ this.view(-10,-10,10,10);
9447
+ }
9448
+ view(x1,y1,x2,y2){
9449
+ let width=Math.abs(x2-x1);
9450
+ let height=Math.abs(y2-y1);
9451
+ this.setAttr("viewBox",[x1,y1,width,height].join(" "));
9452
+ this.st.scaleY(-1);
9453
+ return this;
9454
+ }
9455
+ add(...svgElement){
9456
+ for(let i=0;i<svgElement.length;i++){
9457
+ this.element.appendChild(svgElement[i].element);
9458
+ this.items.push(svgElement[i]);
9459
+ }
9460
+ this.maintain();
9461
+ return this;
9462
+ }
9463
+ remove(...svgElement){
9464
+ for(let i=0;i<svgElement.length;i++){
9465
+ this.element.removeChild(svgElement[i].element);
9466
+ this.items=this.items.filter(n=>!svgElement);
9467
+ }
9468
+ this.maintain();
9469
+ return this;
9470
+ }
9471
+ // text(text,x,y){
9472
+ // let item=svgText(text,x,y);
9473
+ // this.element.appendChild(item.element);
9474
+ // item.x(x-item.element.getComputedTextLength()/2);
9475
+ // return item;
9476
+ // }
9477
+ // rect(x,y,w,h){
9478
+ // let item=svgRect(x,y,w,h);
9479
+ // this.add(item);
9480
+ // return item;
9481
+ // }
9482
+ // line(x1,y1,x2,y2){
9483
+ // let item=svgLine(x1,y1,x2,y2);
9484
+ // this.element.appendChild(item.element);
9485
+ // return item;
9486
+ // }
9487
+ // circle(cx,cy,r){
9488
+ // let item=svgCircle(cx,cy,r);
9489
+ // this.element.appendChild(item.element);
9490
+ // return item;
9491
+ // }
9492
+ // ellipse(cx,cy,rx,ry){
9493
+ // let item=svgEllipse(cx,cy,rx,ry);
9494
+ // this.element.appendChild(item.element);
9495
+ // return item;
9496
+ // }
9497
+ // polygon(X,Y){
9498
+ // let item=svgPolygon(X,Y);
9499
+ // this.element.appendChild(item.element);
9500
+ // item.addPoints(X,Y)
9501
+ // return item;
9502
+ // }
9503
+ // image(src,w,h,x,y){
9504
+ // let item=svgImage(src,w,h,x,y);
9505
+ // this.element.appendChild(item.element);
9506
+ // return item;
9507
+ // }
9508
+ mask(){
9509
+
9510
+ }
9511
+ toString(){
9512
+ return (new XMLSerializer()).serializeToString(this.element);
9513
+ }
9514
+ btoa(){
9515
+ return btoa(this.toString())
9516
+ }
9517
+ toImg(){
9518
+ return 'data:image/svg+xml;base64,'+this.btoa()
8983
9519
  }
8984
- };
9520
+ toImg2(){
9521
+ return "data:image/svg+xml;charset=utf8,"+this.toString().replaceAll("<","%3C").replaceAll(">","%3E").replaceAll("#","%23").replaceAll('"',"'");
9522
+ }
9523
+ }
9524
+
9525
+ const Svg =(w,h)=>new ZikoUISvg(w,h);
8985
9526
 
8986
9527
  class ZikoSvgElement {
8987
- constructor() {
8988
- this.cache = {};
9528
+ constructor(type) {
9529
+ this.cache = {
9530
+ type
9531
+ };
9532
+ }
9533
+ pos(x,y){
9534
+ return this.posX(x).posY(y);
9535
+ }
9536
+ posX(x){
9537
+ if(["circle","ellipse"].includes(this.cache.type))this.element.cx.baseVal.value=x;
9538
+ else this.element.x.baseVal.value=x;
9539
+ return this;
9540
+ }
9541
+ posY(y){
9542
+ if(["circle","ellipse"].includes(this.cache.type))this.element.cy.baseVal.value=y;
9543
+ else this.element.y.baseVal.value=y;
9544
+ return this;
9545
+ }
9546
+ translate(x,y){
9547
+ return this;
8989
9548
  }
8990
9549
  color({ stroke, fill }) {
8991
9550
  this.element.setAttribute("stroke", stroke);
@@ -9054,32 +9613,24 @@ class ZikoSvgRectangle extends ZikoSvgElement{
9054
9613
 
9055
9614
  class ZikoSvgCircle extends ZikoSvgElement{
9056
9615
  constructor(cx,cy,r){
9057
- super();
9616
+ super("circle");
9058
9617
  this.element=document.createElementNS(
9059
9618
  "http://www.w3.org/2000/svg",
9060
9619
  "circle",
9061
9620
  );
9062
- this.cx(cx).cy(cy).r(r);
9063
- }
9064
- cx(cx){
9065
- this.element.cx.baseVal.value=cx;
9066
- return this;
9067
- }
9068
- cy(cy){
9069
- this.element.cy.baseVal.value=cy;
9070
- return this;
9621
+ this.pos(cx,cy).setR(r);
9071
9622
  }
9072
- r(r){
9623
+ setR(r){
9073
9624
  this.element.r.baseVal.value=r;
9074
9625
  return this;
9075
9626
  }
9076
- get R(){
9627
+ get r(){
9077
9628
  return this.element.r.baseVal.value;
9078
9629
  }
9079
- get Cx(){
9630
+ get cx(){
9080
9631
  return this.element.cx.baseVal.value;
9081
9632
  }
9082
- get Cy(){
9633
+ get cy(){
9083
9634
  return this.element.cy.baseVal.value;
9084
9635
  }
9085
9636
  }
@@ -9087,26 +9638,18 @@ const svgCircle=(x,y,r)=>new ZikoSvgCircle(x,y,r);
9087
9638
 
9088
9639
  class ZikoSvgEllipse extends ZikoSvgElement{
9089
9640
  constructor(cx,cy,rx,ry){
9090
- super();
9641
+ super("ellipse");
9091
9642
  this.element=document.createElementNS(
9092
9643
  "http://www.w3.org/2000/svg",
9093
9644
  "ellipse",
9094
9645
  );
9095
- this.cx(cx).cy(cy).rx(rx).ry(ry);
9096
- }
9097
- cx(cx){
9098
- this.element.cx.baseVal.value=cx;
9099
- return this;
9646
+ this.pos(cx,cy).setRx(rx).setRy(ry);
9100
9647
  }
9101
- cy(cy){
9102
- this.element.cy.baseVal.value=cy;
9103
- return this;
9104
- }
9105
- rx(rx){
9648
+ setRx(rx){
9106
9649
  this.element.rx.baseVal.value=rx;
9107
9650
  return this;
9108
9651
  }
9109
- ry(ry){
9652
+ setRy(ry){
9110
9653
  this.element.ry.baseVal.value=ry;
9111
9654
  return this;
9112
9655
  }
@@ -9141,6 +9684,67 @@ class ZikoSvgLine extends ZikoSvgElement{
9141
9684
  }
9142
9685
  const svgLine=(x1,y1,x2,y2)=>new ZikoSvgLine(x1,y1,x2,y2);
9143
9686
 
9687
+ class ZikoSvgPolyLine extends ZikoSvgElement{}
9688
+ const svgPolyLine=(X,Y)=>new ZikoSvgPolyLine(X,Y);
9689
+
9690
+ class ZikoSvgPath extends ZikoSvgElement{
9691
+ constructor(){
9692
+ super();
9693
+ this.element=document.createElementNS(
9694
+ "http://www.w3.org/2000/svg",
9695
+ "path",
9696
+ );
9697
+ this.path="";
9698
+
9699
+ }
9700
+ setPath(){
9701
+ this.element.setAttribute("d",this.path);
9702
+ return this;
9703
+ }
9704
+ clear(){
9705
+ this.path="";
9706
+ this.setPath();
9707
+ return this;
9708
+ }
9709
+ moveTo(x,y){
9710
+ this.path+=`M${x} ${y} `;
9711
+ this.setPath();
9712
+ return this;
9713
+ }
9714
+ lineTo(x,y){
9715
+ this.path+=`L${x} ${y} `;
9716
+ this.setPath();
9717
+ return this;
9718
+ }
9719
+ hr(x){
9720
+ this.path+=`H${x} `;
9721
+ this.setPath();
9722
+ return this;
9723
+ }
9724
+ vr(y){
9725
+ this.path+=`V${y} `;
9726
+ this.setPath();
9727
+ return this;
9728
+ }
9729
+ bezier(x1,y1,x2,y2,x,y){
9730
+ this.path+=`C ${x1} ${y1},${x2} ${y2},${x} ${y} `;
9731
+ this.setPath();
9732
+ return this;
9733
+ }
9734
+ quadratic(x1,y1,x,y){
9735
+ this.path+=`Q ${x1} ${y1} ${x} ${y} `;
9736
+ this.setPath();
9737
+ return this;
9738
+ }
9739
+ close(){
9740
+ this.path+="Z";
9741
+ this.setPath();
9742
+ return this;
9743
+ }
9744
+ }
9745
+
9746
+ const svgPath=()=>new ZikoSvgPath();
9747
+
9144
9748
  class ZikoSvgPolygon extends ZikoSvgElement{
9145
9749
  constructor(X=[],Y=[]){
9146
9750
  super();
@@ -9151,6 +9755,7 @@ class ZikoSvgPolygon extends ZikoSvgElement{
9151
9755
  "polygon",
9152
9756
  );
9153
9757
  this.element.setAttribute("points","");
9758
+ this.addPoints(X,Y);
9154
9759
  }
9155
9760
  addPoint(x,y){
9156
9761
  let p=this.element.parentElement.createSVGPoint();
@@ -9171,6 +9776,31 @@ class ZikoSvgPolygon extends ZikoSvgElement{
9171
9776
  }
9172
9777
  const svgPolygon=(X,Y)=>new ZikoSvgPolygon(X,Y);
9173
9778
 
9779
+ class ZikoSvgText extends ZikoSvgElement{
9780
+ constructor(text,x,y){
9781
+ super();
9782
+ this.element=document.createElementNS(
9783
+ "http://www.w3.org/2000/svg",
9784
+ "text",
9785
+ );
9786
+ this.setText(text);
9787
+ this.x(x).y(y);
9788
+ }
9789
+ x(x){
9790
+ this.element.setAttribute("x",x);
9791
+ return this;
9792
+ }
9793
+ y(y){
9794
+ this.element.setAttribute("y",y);
9795
+ return this;
9796
+ }
9797
+ setText(text=""){
9798
+ this.element.textContent=text;
9799
+ return this;
9800
+ }
9801
+ }
9802
+ const svgText=(text,x,y)=>new ZikoSvgText(text,x,y);
9803
+
9174
9804
  class ZikoSvgImage extends ZikoSvgElement{
9175
9805
  constructor(src="",w="100%",h="100%",x=0,y=0){
9176
9806
  super();
@@ -9203,30 +9833,36 @@ class ZikoSvgImage extends ZikoSvgElement{
9203
9833
  }
9204
9834
  const svgImage=(src,w,h,x,y)=>new ZikoSvgImage(src,w,h,x,y);
9205
9835
 
9206
- class ZikoSvgText extends ZikoSvgElement{
9207
- constructor(text,x,y){
9208
- super();
9836
+ class ZikoSvgForeignObject extends ZikoSvgElement{
9837
+ constructor(x=0,y=0,w="100%",h="100%",...ZikoUIElement){
9838
+ super("foreignObject");
9839
+ this.items=[];
9209
9840
  this.element=document.createElementNS(
9210
9841
  "http://www.w3.org/2000/svg",
9211
- "text",
9842
+ "foreignObject",
9212
9843
  );
9213
- this.setText(text);
9214
- this.x(x).y(y);
9215
- }
9216
- x(x){
9217
- this.element.setAttribute("x",x);
9218
- return this;
9844
+ this.container=Flex().setTarget(this.element).vertical(0,0).size("auto","auto");
9845
+ this.container.st.scaleY(-1);
9846
+ this.posX(x).posY(y).width(w).height(h);
9847
+ }
9848
+ width(w){
9849
+ this.element.setAttribute("width",w);
9850
+ return this;
9219
9851
  }
9220
- y(y){
9221
- this.element.setAttribute("y",y);
9222
- return this;
9852
+ height(h){
9853
+ this.element.setAttribute("height",h);
9854
+ return this;
9223
9855
  }
9224
- setText(text=""){
9225
- this.element.textContent=text;
9856
+ add(...ZikoUIElement){
9857
+ this.container.append(...ZikoUIElement);
9226
9858
  return this;
9227
- }
9859
+ }
9860
+ remove(...ZikoUIElement){
9861
+ this.container.append(...ZikoUIElement);
9862
+ return this;
9863
+ }
9228
9864
  }
9229
- const svgText=(text,x,y)=>new ZikoSvgText(text,x,y);
9865
+ const svgObject=(x,y,r)=>new ZikoSvgForeignObject(x,y,r);
9230
9866
 
9231
9867
  class ZikoSvgGroupe extends ZikoSvgElement{
9232
9868
  constructor(...svgElement){
@@ -9249,108 +9885,49 @@ class ZikoSvgGroupe extends ZikoSvgElement{
9249
9885
  remove(...svgElement){
9250
9886
  for(let i=0;i<svgElement.length;i++){
9251
9887
  this.element.removeChild(svgElement[i].element);
9252
- this.items=this.items.filter(n=>!svgElement);
9888
+ this.items=this.items.filter(n=>n!=svgElement);
9253
9889
  }
9254
9890
  return this;
9255
9891
  }
9256
9892
  }
9257
9893
  const svgGroupe=(...svgElement)=>new ZikoSvgGroupe(...svgElement);
9258
9894
 
9259
- //import svgObject from "./Elements/foreignObject.js";
9260
- //import svgGrid from "./Elements/grid.js";
9261
-
9262
- class ZikoUISvg extends ZikoUIElement {
9263
- constructor(w=360,h=300) {
9264
- super("svg","svg");
9265
- // this.element=document.createElementNS("http://www.w3.org/2000/svg", "svg");
9266
- //this.cache={};
9267
- this.setAttr("width",w);
9268
- this.setAttr("height",h);
9269
- this.style({border:"1px black solid"});
9270
- //this.view(-w/2,-h/2,w/2,h/2)
9271
- //this.view(-10,-10,10,10);
9272
- //this.render();
9273
- }
9274
- view(x1,y1,x2,y2){
9275
- let width=Math.abs(x2-x1);
9276
- let height=Math.abs(y2-y1);
9277
- //this.element.style.transform="scale("+Math.sign(x2-x1)+","+(-Math.sign(y2-y1))+")";
9278
- this.setAttr("viewBox",[x1,y1,width,height].join(" "));
9279
- //console.log({width:width,height:height})
9280
- return this;
9281
-
9895
+ class ZikoSvgLink extends ZikoSvgElement{
9896
+ constructor(href,...svgElement){
9897
+ super();
9898
+ this.items=[];
9899
+ this.element=document.createElementNS(
9900
+ "http://www.w3.org/2000/svg",
9901
+ "a",
9902
+ );
9903
+ this.element.setAttribute("href",href);
9904
+ this.add(...svgElement);
9282
9905
  }
9283
9906
  add(...svgElement){
9284
9907
  for(let i=0;i<svgElement.length;i++){
9285
9908
  this.element.appendChild(svgElement[i].element);
9286
9909
  this.items.push(svgElement[i]);
9287
9910
  }
9288
- this.maintain();
9289
- return this;
9911
+ if(svgElement.length===1)return svgElement[0]
9912
+ return svgElement;
9290
9913
  }
9291
9914
  remove(...svgElement){
9292
9915
  for(let i=0;i<svgElement.length;i++){
9293
9916
  this.element.removeChild(svgElement[i].element);
9294
- this.items=this.items.filter(n=>!svgElement);
9917
+ this.items=this.items.filter(n=>n!=svgElement);
9295
9918
  }
9296
- this.maintain();
9297
9919
  return this;
9298
9920
  }
9299
- // text(text,x,y){
9300
- // let item=svgText(text,x,y);
9301
- // this.element.appendChild(item.element);
9302
- // item.x(x-item.element.getComputedTextLength()/2);
9303
- // return item;
9304
- // }
9305
- // rect(x,y,w,h){
9306
- // let item=svgRect(x,y,w,h);
9307
- // this.add(item);
9308
- // return item;
9309
- // }
9310
- // line(x1,y1,x2,y2){
9311
- // let item=svgLine(x1,y1,x2,y2);
9312
- // this.element.appendChild(item.element);
9313
- // return item;
9314
- // }
9315
- // circle(cx,cy,r){
9316
- // let item=svgCircle(cx,cy,r);
9317
- // this.element.appendChild(item.element);
9318
- // return item;
9319
- // }
9320
- // ellipse(cx,cy,rx,ry){
9321
- // let item=svgEllipse(cx,cy,rx,ry);
9322
- // this.element.appendChild(item.element);
9323
- // return item;
9324
- // }
9325
- // polygon(X,Y){
9326
- // let item=svgPolygon(X,Y);
9327
- // this.element.appendChild(item.element);
9328
- // item.addPoints(X,Y)
9329
- // return item;
9330
- // }
9331
- // image(src,w,h,x,y){
9332
- // let item=svgImage(src,w,h,x,y);
9333
- // this.element.appendChild(item.element);
9334
- // return item;
9335
- // }
9336
- mask(){
9337
-
9338
- }
9339
- toString(){
9340
- return (new XMLSerializer()).serializeToString(this.element);
9341
- }
9342
- btoa(){
9343
- return btoa(this.toString())
9344
- }
9345
- toImg(){
9346
- return 'data:image/svg+xml;base64,'+this.btoa()
9347
- }
9348
- toImg2(){
9349
- return "data:image/svg+xml;charset=utf8,"+this.toString().replaceAll("<","%3C").replaceAll(">","%3E").replaceAll("#","%23").replaceAll('"',"'");
9350
- }
9351
- }
9352
-
9353
- const Svg =(w,h)=>new ZikoUISvg(w,h);
9921
+ }
9922
+ const svgLink=(href,...svgElement)=>new ZikoSvgLink(href,...svgElement);
9923
+
9924
+ const svgGrid=(w,h,r=10,c=10)=>{
9925
+ let path=svgPath().fill("none").stroke("coral").strokeWidth(0.6);
9926
+ console.log({x:w/r,y:h/c});
9927
+ for(let i=0;i<w;i++) path.moveTo(0,i*w/r).hr(w);
9928
+ for(let j=0;j<h;j++) path.moveTo(j*h/c,0).vr(h);
9929
+ return path
9930
+ };
9354
9931
 
9355
9932
  class ZikoUICanvas extends ZikoUIElement{
9356
9933
  constructor(w,h){
@@ -9818,6 +10395,10 @@ const Graphics={
9818
10395
  svgRect,
9819
10396
  svgText,
9820
10397
  svgGroupe,
10398
+ svgLink,
10399
+ svgGrid,
10400
+ svgObject,
10401
+ svgPath,
9821
10402
  Canvas,
9822
10403
  canvasArc,
9823
10404
  canvasCircle,
@@ -9913,7 +10494,10 @@ const __UI__={};
9913
10494
  const __Config__={
9914
10495
  default:{
9915
10496
  target:null,
9916
- render:true
10497
+ render:true,
10498
+ math:{
10499
+ mode:"deg"
10500
+ }
9917
10501
  },
9918
10502
  setDefault:function(pairs){
9919
10503
  const keys=Object.keys(pairs);
@@ -10035,7 +10619,7 @@ class ZikoUIApp extends ZikoUIFlex{
10035
10619
 
10036
10620
  }
10037
10621
  onHashChange(...callbacks){
10038
- if(!this.events.hash)this.events.hash = HashEvent(this);
10622
+ if(!this.events.hash)this.events.hash = useHashEvent(this);
10039
10623
  this.events.hash.onChange(...callbacks);
10040
10624
  return this;
10041
10625
  }
@@ -10048,8 +10632,7 @@ const Ziko={
10048
10632
  UI: UI$1,
10049
10633
  Time,
10050
10634
  Graphics,
10051
- Events,
10052
- Use,
10635
+ Reactivity,
10053
10636
  Data,
10054
10637
  SPA,
10055
10638
  };
@@ -10072,8 +10655,7 @@ function ExtractAll(){
10072
10655
  UI$1.ExtractAll();
10073
10656
  Math$1.ExtractAll();
10074
10657
  Time.ExtractAll();
10075
- Events.ExtractAll();
10076
- Use.ExtractAll();
10658
+ Reactivity.ExtractAll();
10077
10659
  Graphics.ExtractAll();
10078
10660
  Data.ExtractAll();
10079
10661
  return this;
@@ -10082,10 +10664,9 @@ function RemoveAll(){
10082
10664
  UI$1.RemoveAll();
10083
10665
  Math$1.RemoveAll();
10084
10666
  Time.RemoveAll();
10085
- Events.RemoveAll();
10086
- Use.RemoveAll();
10667
+ Reactivity.RemoveAll();
10087
10668
  Graphics.RemoveAll();
10088
10669
  Data.RemoveAll();
10089
10670
  }
10090
10671
 
10091
- export { Accordion, App, Article, Aside, Base, Canvas, Carousel, CodeCell, CodeNote, Combinaison, Complex, DarkThemes, Data, E, EPSILON, Ease, Events, ExtractAll, Fixed, Flex, Footer, Graphics, Grid$1 as Grid, Header, LightThemes, LinearSystem, Logic$1 as Logic, Main, Math$1 as Math, Matrix, Nav, PI, Permutation, Random, RemoveAll, SPA, Section$1 as Section, Signal, Svg, Table, Tabs, Themes, Time, UI$1 as UI, Utils, ZikoUIArticle, ZikoUIAside, ZikoUIAudio, ZikoUIBr, ZikoUICanvas, ZikoUICodeNote, ZikoUIComponent, ZikoUIElement, ZikoUIFigure, ZikoUIFooter, ZikoUIHeader, ZikoUIHr, ZikoUIHtmlTag, ZikoUIImage, ZikoUILink, ZikoUIMain, ZikoUINav, ZikoUISection, ZikoUISvg, ZikoUIVideo, __Config__, abs, accum, acos, acosh, acot, add, adoc2html, animation, arange, asin, asinh, atan, atan2, atanh, audio, bessel, beta, br, brs, btn, canvasArc, canvasCircle, canvasLine, canvasPoints, canvasRect, cartesianProduct, ceil, checkbox, choleskyDecomposition, clamp, complex, cos, cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, datalist, Ziko as default, deg2rad, div, e, fact, figure, floor, gamma, geomspace, h1, h2, h3, h4, h5, h6, hr, hrs, html, hypot, image, inRange, input, inputCamera, inputColor, inputDate, inputDateTime, inputEmail, inputImage, inputNumber, inputPassword, inputTime, isApproximatlyEqual, json2arr, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, li, link, linspace, ln, logspace, loop, luDecomposition, map, mapfun$1 as mapfun, markdown2html, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, ol, ones, p, pgcd, pow, powerSet, ppcm, prod, qrDecomposition, rad2deg, radio, round, search, sec, select, sig, sign, sin, sinc, sinh, slider, sqrt, sqrtn, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, svgCircle, svgEllipse, svgGroupe, svgImage, svgLine, svgPolygon, svgRect, svgText, tan, tanh, text$1 as text, textarea, timeTaken, time_memory_Taken, ul, useDebounce, useThrottle, video, wait, waitForUIElm, waitForUIElmSync, zeros };
10672
+ export { Accordion, App, Article, Aside, Base, Canvas, Carousel, CodeCell, CodeNote, Combinaison, Complex, DarkThemes, Data, E, EPSILON, Ease, ExtractAll, Fixed, Flex, Footer, Graphics, Grid$1 as Grid, Header, LightThemes, LinearSystem, Logic$1 as Logic, Main, Math$1 as Math, Matrix, Nav, PI, Permutation, Random, Reactivity, RemoveAll, SPA, Section$1 as Section, Signal, Str, Svg, Table, Tabs, Themes, Time, UI$1 as UI, Utils, ZikoUIArticle, ZikoUIAside, ZikoUIAudio, ZikoUIBr, ZikoUICanvas, ZikoUICodeNote, ZikoUIComponent, ZikoUIElement, ZikoUIFigure, ZikoUIFooter, ZikoUIHeader, ZikoUIHr, ZikoUIHtmlTag, ZikoUIImage, ZikoUILink, ZikoUIMain, ZikoUINav, ZikoUISection, ZikoUISvg, ZikoUIVideo, __Config__, abs, accum, acos, acosh, acot, add, adoc2html, animation, arange, asin, asinh, atan, atan2, atanh, audio, bessel, beta, br, brs, btn, canvasArc, canvasCircle, canvasLine, canvasPoints, canvasRect, cartesianProduct, ceil, checkbox, choleskyDecomposition, clamp, complex, cos, cosh, cot, coth, count, countWords, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, datalist, Ziko as default, deg2rad, div, e, fact, figure, floor, gamma, geomspace, h1, h2, h3, h4, h5, h6, hr, hrs, html, hypot, image, inRange, input, inputCamera, inputColor, inputDate, inputDateTime, inputEmail, inputImage, inputNumber, inputPassword, inputTime, isApproximatlyEqual, json2arr, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, li, link, linspace, ln, logspace, loop, luDecomposition, map, mapfun$1 as mapfun, markdown2html, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, ol, ones, p, pgcd, pow, powerSet, ppcm, prod, qrDecomposition, rad2deg, radio, removeExtraSpace, round, search, sec, select, sig, sign, sin, sinc, sinh, slider, sqrt, sqrtn, str, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, svgCircle, svgEllipse, svgGrid, svgGroupe, svgImage, svgLine, svgLink, svgObject, svgPath, svgPolyLine, svgPolygon, svgRect, svgText, tan, tanh, text$1 as text, textarea, timeTaken, time_memory_Taken, ul, useBattery, useBluetooth, useChannel, useClickEventnt as useClickEvent, useClipboardEvent, useCustomEvent, useDebounce, useDragEvent, useDropEvent, useEventEmitter, useFavIcon, useFocusEvent, useGeolocation, useHashEvent, useInputEvent, useKeyEvenent as useKeyEvent, useLocaleStorage, useMediaQuery, useMouseEvent, usePointerEvent, useSessionStorage, useStyle, useSuccesifKeys, useTheme, useThread, useThrottle, useTitle, useWheelEventnent as useWheelEvent, video, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };