ziko 0.49.3 → 0.49.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ziko.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Tue Nov 25 2025 19:11:53 GMT+0100 (UTC+01:00)
5
+ Date : Wed Nov 26 2025 11:58:54 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
@@ -44,8 +44,6 @@ Fixed = new Proxy(Fixed, {
44
44
  }
45
45
  });
46
46
 
47
- class ZikoMath {}
48
-
49
47
  // To generalise
50
48
 
51
49
  const mapfun$1=(fun,...X)=>{
@@ -1181,57 +1179,67 @@ const __CACHE__ = {
1181
1179
  }
1182
1180
  };
1183
1181
 
1184
- class ZikoUseChannel{
1185
- constructor(name = ""){
1182
+ class UseChannel {
1183
+ constructor(name = "") {
1186
1184
  this.channel = new BroadcastChannel(name);
1187
- this.EVENTS_DATAS_PAIRS = new Map();
1188
- this.EVENTS_HANDLERS_PAIRS = new Map();
1189
- this.LAST_RECEIVED_EVENT = "";
1190
- this.UUID="ziko-channel"+Random.string(10);
1191
- this.SUBSCRIBERS = new Set([this.UUID]);
1192
- }
1193
- get broadcast(){
1194
- // update receiver
1195
- return this;
1185
+ this.eventData = new Map();
1186
+ this.handlers = new Map();
1187
+ this.uuid = "ziko-channel:" + Random.string(10);
1188
+ this.subscribers = new Set([this.uuid]);
1189
+
1190
+ this.channel.addEventListener("message", (e) => {
1191
+ const { last_sent_event, userId, eventData } = e.data;
1192
+
1193
+ // ignore own events
1194
+ if (userId === this.uuid) return;
1195
+
1196
+ this.subscribers.add(userId);
1197
+
1198
+ // sync data
1199
+ this.eventData = new Map(eventData);
1200
+
1201
+ const data = this.eventData.get(last_sent_event);
1202
+ const handlers = this.handlers.get(last_sent_event);
1203
+
1204
+ if (handlers) {
1205
+ handlers.forEach(fn => fn(data));
1206
+ }
1207
+ });
1196
1208
  }
1197
- emit(event, data){
1198
- this.EVENTS_DATAS_PAIRS.set(event,data);
1199
- this.#maintainEmit(event);
1209
+
1210
+ emit(event, data) {
1211
+ this.eventData.set(event, data);
1212
+
1213
+ this.channel.postMessage({
1214
+ eventData: this.eventData,
1215
+ last_sent_event: event,
1216
+ userId: this.uuid
1217
+ });
1200
1218
  return this;
1201
1219
  }
1202
- on(event,handler=console.log){
1203
- this.EVENTS_HANDLERS_PAIRS.set(event,handler);
1204
- this.#maintainOn();
1220
+
1221
+ on(event, handler = console.log) {
1222
+ if (!this.handlers.has(event)) {
1223
+ this.handlers.set(event, []);
1224
+ }
1225
+ this.handlers.get(event).push(handler);
1205
1226
  return this;
1206
1227
  }
1207
- #maintainOn(){
1208
- this.channel.onmessage = (e) => {
1209
- this.LAST_RECEIVED_EVENT=e.data.last_sended_event;
1210
- const USER_ID=e.data.userId;
1211
- this.SUBSCRIBERS.add(USER_ID);
1212
- const Data=e.data.EVENTS_DATAS_PAIRS.get(this.LAST_RECEIVED_EVENT);
1213
- const Handler=this.EVENTS_HANDLERS_PAIRS.get(this.LAST_RECEIVED_EVENT);
1214
- if(Data && Handler)Handler(Data);
1215
- };
1216
- return this;
1217
- }
1218
- #maintainEmit(event){
1219
- this.channel.postMessage({
1220
- EVENTS_DATAS_PAIRS:this.EVENTS_DATAS_PAIRS,
1221
- last_sended_event:event,
1222
- userId:this.UUID
1223
- });
1228
+
1229
+ close() {
1230
+ this.channel.close();
1224
1231
  return this;
1225
1232
  }
1226
- close(){
1227
- this.channel.close();
1233
+
1234
+ get broadcast() {
1228
1235
  return this;
1229
1236
  }
1230
1237
  }
1231
- const useChannel = name => new ZikoUseChannel(name);
1238
+
1239
+ const useChannel = (name) => new UseChannel(name);
1232
1240
 
1233
1241
  // To do : remove old items
1234
- class ZikoUseStorage{
1242
+ class UseStorage{
1235
1243
  constructor(storage, globalKey, initialValue){
1236
1244
  this.cache={
1237
1245
  storage,
@@ -1296,8 +1304,8 @@ class ZikoUseStorage{
1296
1304
  }
1297
1305
 
1298
1306
  }
1299
- const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
1300
- const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
1307
+ const useLocaleStorage=(key,initialValue)=>new UseStorage(localStorage,key,initialValue);
1308
+ const useSessionStorage=(key,initialValue)=>new UseStorage(sessionStorage,key,initialValue);
1301
1309
 
1302
1310
  const __State__ = {
1303
1311
  store : new Map(),
@@ -3227,9 +3235,8 @@ function trimKeys(obj) {
3227
3235
  }, Array.isArray(obj) ? [] : {});
3228
3236
  }
3229
3237
 
3230
- class Matrix extends ZikoMath{
3238
+ class Matrix{
3231
3239
  constructor(rows, cols, element = [] ) {
3232
- super();
3233
3240
  if(rows instanceof Matrix){
3234
3241
  this.arr=rows.arr;
3235
3242
  this.rows=rows.rows;
@@ -3894,9 +3901,8 @@ const matrix2=(...element)=>new Matrix(2, 2, element);
3894
3901
  const matrix3=(...element)=>new Matrix(3, 3, element);
3895
3902
  const matrix4=(...element)=>new Matrix(4, 4, element);
3896
3903
 
3897
- class Complex extends ZikoMath{
3904
+ class Complex{
3898
3905
  constructor(a = 0, b = 0) {
3899
- super();
3900
3906
  if(a instanceof Complex){
3901
3907
  this.a=a.a;
3902
3908
  this.b=a.b;
@@ -4072,12 +4078,6 @@ const complex=(a,b)=>{
4072
4078
  return new Complex(a,b)
4073
4079
  };
4074
4080
 
4075
- // import {
4076
- // gamma,
4077
- // bessel,
4078
- // beta
4079
- // } from "../calculus/index.js";
4080
-
4081
4081
  const abs=(...x)=>mapfun$1(Math.abs,...x);
4082
4082
  const sqrt$2=(...x)=>mapfun$1(Math.sqrt,...x);
4083
4083
  const pow$1=(x,n)=>{
@@ -4756,7 +4756,7 @@ const timeTaken = callback => {
4756
4756
  return r;
4757
4757
  };
4758
4758
 
4759
- class ZikoUseEventEmitter {
4759
+ class UseEventEmitter {
4760
4760
  constructor() {
4761
4761
  this.events = {};
4762
4762
  this.maxListeners = 10;
@@ -4818,7 +4818,7 @@ class ZikoUseEventEmitter {
4818
4818
  }
4819
4819
  }
4820
4820
 
4821
- const useEventEmitter=()=>new ZikoUseEventEmitter();
4821
+ const useEventEmitter=()=>new UseEventEmitter();
4822
4822
 
4823
4823
  class ZikoUseFavIcon{
4824
4824
  constructor(FavIcon,useEventEmitter=true){
@@ -5201,7 +5201,6 @@ function useDerived(deriveFn, sources) {
5201
5201
  const useReactive = (nested_value) => mapfun$1(
5202
5202
  n => {
5203
5203
  const state = useState(n);
5204
- // console.log(state)
5205
5204
  return {
5206
5205
  get : state[0],
5207
5206
  set : state[1],
@@ -5210,7 +5209,7 @@ const useReactive = (nested_value) => mapfun$1(
5210
5209
  nested_value
5211
5210
  );
5212
5211
 
5213
- class ZikoUseThreed {
5212
+ class UseThreed {
5214
5213
  #workerContent;
5215
5214
  constructor() {
5216
5215
  this.#workerContent = (
@@ -5246,14 +5245,14 @@ class ZikoUseThreed {
5246
5245
  }
5247
5246
 
5248
5247
  const useThread = (func, callback , close) => {
5249
- const T = new ZikoUseThreed();
5248
+ const T = new UseThreed();
5250
5249
  if (func) {
5251
5250
  T.call(func, callback , close);
5252
5251
  }
5253
5252
  return T;
5254
5253
  };
5255
5254
 
5256
- class ZikoUseRoot {
5255
+ class UseRoot {
5257
5256
  constructor(PropsMap, {namespace = 'Ziko', register, ValidateCssProps = false} = {}){
5258
5257
  this.currentPropsMap = PropsMap;
5259
5258
  this.namespace = namespace;
@@ -5298,7 +5297,7 @@ function ValidateCssProps(PropsMap){
5298
5297
  }
5299
5298
  }
5300
5299
 
5301
- const useRoot = (PropsMap, {namespace, register, ValidateCssProps} = {}) => new ZikoUseRoot(PropsMap, {namespace, register, ValidateCssProps});
5300
+ const useRoot = (PropsMap, {namespace, register, ValidateCssProps} = {}) => new UseRoot(PropsMap, {namespace, register, ValidateCssProps});
5302
5301
 
5303
5302
  // Usage
5304
5303
 
@@ -5419,6 +5418,7 @@ exports.UINode = UINode;
5419
5418
  exports.UISVGWrapper = UISVGWrapper;
5420
5419
  exports.UISwitch = UISwitch;
5421
5420
  exports.UIView = UIView;
5421
+ exports.UseRoot = UseRoot;
5422
5422
  exports.Utils = Utils;
5423
5423
  exports.View = View;
5424
5424
  exports.ZikoApp = ZikoApp;
@@ -5437,7 +5437,6 @@ exports.ZikoSPA = ZikoSPA;
5437
5437
  exports.ZikoUIFlex = ZikoUIFlex;
5438
5438
  exports.ZikoUISuspense = ZikoUISuspense;
5439
5439
  exports.ZikoUIText = ZikoUIText;
5440
- exports.ZikoUseRoot = ZikoUseRoot;
5441
5440
  exports.__ZikoEvent__ = __ZikoEvent__;
5442
5441
  exports.abs = abs;
5443
5442
  exports.accum = accum;
@@ -5591,7 +5590,6 @@ exports.tick = tick;
5591
5590
  exports.timeTaken = timeTaken;
5592
5591
  exports.time_memory_Taken = time_memory_Taken;
5593
5592
  exports.timeout = timeout;
5594
- exports.useChannel = useChannel;
5595
5593
  exports.useDerived = useDerived;
5596
5594
  exports.useEventEmitter = useEventEmitter;
5597
5595
  exports.useLocaleStorage = useLocaleStorage;
package/dist/ziko.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Tue Nov 25 2025 19:11:53 GMT+0100 (UTC+01:00)
5
+ Date : Wed Nov 26 2025 11:58:54 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
@@ -48,8 +48,6 @@
48
48
  }
49
49
  });
50
50
 
51
- class ZikoMath {}
52
-
53
51
  // To generalise
54
52
 
55
53
  const mapfun$1=(fun,...X)=>{
@@ -1185,57 +1183,67 @@
1185
1183
  }
1186
1184
  };
1187
1185
 
1188
- class ZikoUseChannel{
1189
- constructor(name = ""){
1186
+ class UseChannel {
1187
+ constructor(name = "") {
1190
1188
  this.channel = new BroadcastChannel(name);
1191
- this.EVENTS_DATAS_PAIRS = new Map();
1192
- this.EVENTS_HANDLERS_PAIRS = new Map();
1193
- this.LAST_RECEIVED_EVENT = "";
1194
- this.UUID="ziko-channel"+Random.string(10);
1195
- this.SUBSCRIBERS = new Set([this.UUID]);
1196
- }
1197
- get broadcast(){
1198
- // update receiver
1199
- return this;
1189
+ this.eventData = new Map();
1190
+ this.handlers = new Map();
1191
+ this.uuid = "ziko-channel:" + Random.string(10);
1192
+ this.subscribers = new Set([this.uuid]);
1193
+
1194
+ this.channel.addEventListener("message", (e) => {
1195
+ const { last_sent_event, userId, eventData } = e.data;
1196
+
1197
+ // ignore own events
1198
+ if (userId === this.uuid) return;
1199
+
1200
+ this.subscribers.add(userId);
1201
+
1202
+ // sync data
1203
+ this.eventData = new Map(eventData);
1204
+
1205
+ const data = this.eventData.get(last_sent_event);
1206
+ const handlers = this.handlers.get(last_sent_event);
1207
+
1208
+ if (handlers) {
1209
+ handlers.forEach(fn => fn(data));
1210
+ }
1211
+ });
1200
1212
  }
1201
- emit(event, data){
1202
- this.EVENTS_DATAS_PAIRS.set(event,data);
1203
- this.#maintainEmit(event);
1213
+
1214
+ emit(event, data) {
1215
+ this.eventData.set(event, data);
1216
+
1217
+ this.channel.postMessage({
1218
+ eventData: this.eventData,
1219
+ last_sent_event: event,
1220
+ userId: this.uuid
1221
+ });
1204
1222
  return this;
1205
1223
  }
1206
- on(event,handler=console.log){
1207
- this.EVENTS_HANDLERS_PAIRS.set(event,handler);
1208
- this.#maintainOn();
1224
+
1225
+ on(event, handler = console.log) {
1226
+ if (!this.handlers.has(event)) {
1227
+ this.handlers.set(event, []);
1228
+ }
1229
+ this.handlers.get(event).push(handler);
1209
1230
  return this;
1210
1231
  }
1211
- #maintainOn(){
1212
- this.channel.onmessage = (e) => {
1213
- this.LAST_RECEIVED_EVENT=e.data.last_sended_event;
1214
- const USER_ID=e.data.userId;
1215
- this.SUBSCRIBERS.add(USER_ID);
1216
- const Data=e.data.EVENTS_DATAS_PAIRS.get(this.LAST_RECEIVED_EVENT);
1217
- const Handler=this.EVENTS_HANDLERS_PAIRS.get(this.LAST_RECEIVED_EVENT);
1218
- if(Data && Handler)Handler(Data);
1219
- };
1220
- return this;
1221
- }
1222
- #maintainEmit(event){
1223
- this.channel.postMessage({
1224
- EVENTS_DATAS_PAIRS:this.EVENTS_DATAS_PAIRS,
1225
- last_sended_event:event,
1226
- userId:this.UUID
1227
- });
1232
+
1233
+ close() {
1234
+ this.channel.close();
1228
1235
  return this;
1229
1236
  }
1230
- close(){
1231
- this.channel.close();
1237
+
1238
+ get broadcast() {
1232
1239
  return this;
1233
1240
  }
1234
1241
  }
1235
- const useChannel = name => new ZikoUseChannel(name);
1242
+
1243
+ const useChannel = (name) => new UseChannel(name);
1236
1244
 
1237
1245
  // To do : remove old items
1238
- class ZikoUseStorage{
1246
+ class UseStorage{
1239
1247
  constructor(storage, globalKey, initialValue){
1240
1248
  this.cache={
1241
1249
  storage,
@@ -1300,8 +1308,8 @@
1300
1308
  }
1301
1309
 
1302
1310
  }
1303
- const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
1304
- const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
1311
+ const useLocaleStorage=(key,initialValue)=>new UseStorage(localStorage,key,initialValue);
1312
+ const useSessionStorage=(key,initialValue)=>new UseStorage(sessionStorage,key,initialValue);
1305
1313
 
1306
1314
  const __State__ = {
1307
1315
  store : new Map(),
@@ -3231,9 +3239,8 @@
3231
3239
  }, Array.isArray(obj) ? [] : {});
3232
3240
  }
3233
3241
 
3234
- class Matrix extends ZikoMath{
3242
+ class Matrix{
3235
3243
  constructor(rows, cols, element = [] ) {
3236
- super();
3237
3244
  if(rows instanceof Matrix){
3238
3245
  this.arr=rows.arr;
3239
3246
  this.rows=rows.rows;
@@ -3898,9 +3905,8 @@
3898
3905
  const matrix3=(...element)=>new Matrix(3, 3, element);
3899
3906
  const matrix4=(...element)=>new Matrix(4, 4, element);
3900
3907
 
3901
- class Complex extends ZikoMath{
3908
+ class Complex{
3902
3909
  constructor(a = 0, b = 0) {
3903
- super();
3904
3910
  if(a instanceof Complex){
3905
3911
  this.a=a.a;
3906
3912
  this.b=a.b;
@@ -4076,12 +4082,6 @@
4076
4082
  return new Complex(a,b)
4077
4083
  };
4078
4084
 
4079
- // import {
4080
- // gamma,
4081
- // bessel,
4082
- // beta
4083
- // } from "../calculus/index.js";
4084
-
4085
4085
  const abs=(...x)=>mapfun$1(Math.abs,...x);
4086
4086
  const sqrt$2=(...x)=>mapfun$1(Math.sqrt,...x);
4087
4087
  const pow$1=(x,n)=>{
@@ -4760,7 +4760,7 @@
4760
4760
  return r;
4761
4761
  };
4762
4762
 
4763
- class ZikoUseEventEmitter {
4763
+ class UseEventEmitter {
4764
4764
  constructor() {
4765
4765
  this.events = {};
4766
4766
  this.maxListeners = 10;
@@ -4822,7 +4822,7 @@
4822
4822
  }
4823
4823
  }
4824
4824
 
4825
- const useEventEmitter=()=>new ZikoUseEventEmitter();
4825
+ const useEventEmitter=()=>new UseEventEmitter();
4826
4826
 
4827
4827
  class ZikoUseFavIcon{
4828
4828
  constructor(FavIcon,useEventEmitter=true){
@@ -5205,7 +5205,6 @@
5205
5205
  const useReactive = (nested_value) => mapfun$1(
5206
5206
  n => {
5207
5207
  const state = useState(n);
5208
- // console.log(state)
5209
5208
  return {
5210
5209
  get : state[0],
5211
5210
  set : state[1],
@@ -5214,7 +5213,7 @@
5214
5213
  nested_value
5215
5214
  );
5216
5215
 
5217
- class ZikoUseThreed {
5216
+ class UseThreed {
5218
5217
  #workerContent;
5219
5218
  constructor() {
5220
5219
  this.#workerContent = (
@@ -5250,14 +5249,14 @@
5250
5249
  }
5251
5250
 
5252
5251
  const useThread = (func, callback , close) => {
5253
- const T = new ZikoUseThreed();
5252
+ const T = new UseThreed();
5254
5253
  if (func) {
5255
5254
  T.call(func, callback , close);
5256
5255
  }
5257
5256
  return T;
5258
5257
  };
5259
5258
 
5260
- class ZikoUseRoot {
5259
+ class UseRoot {
5261
5260
  constructor(PropsMap, {namespace = 'Ziko', register, ValidateCssProps = false} = {}){
5262
5261
  this.currentPropsMap = PropsMap;
5263
5262
  this.namespace = namespace;
@@ -5302,7 +5301,7 @@
5302
5301
  }
5303
5302
  }
5304
5303
 
5305
- const useRoot = (PropsMap, {namespace, register, ValidateCssProps} = {}) => new ZikoUseRoot(PropsMap, {namespace, register, ValidateCssProps});
5304
+ const useRoot = (PropsMap, {namespace, register, ValidateCssProps} = {}) => new UseRoot(PropsMap, {namespace, register, ValidateCssProps});
5306
5305
 
5307
5306
  // Usage
5308
5307
 
@@ -5423,6 +5422,7 @@
5423
5422
  exports.UISVGWrapper = UISVGWrapper;
5424
5423
  exports.UISwitch = UISwitch;
5425
5424
  exports.UIView = UIView;
5425
+ exports.UseRoot = UseRoot;
5426
5426
  exports.Utils = Utils;
5427
5427
  exports.View = View;
5428
5428
  exports.ZikoApp = ZikoApp;
@@ -5441,7 +5441,6 @@
5441
5441
  exports.ZikoUIFlex = ZikoUIFlex;
5442
5442
  exports.ZikoUISuspense = ZikoUISuspense;
5443
5443
  exports.ZikoUIText = ZikoUIText;
5444
- exports.ZikoUseRoot = ZikoUseRoot;
5445
5444
  exports.__ZikoEvent__ = __ZikoEvent__;
5446
5445
  exports.abs = abs;
5447
5446
  exports.accum = accum;
@@ -5595,7 +5594,6 @@
5595
5594
  exports.timeTaken = timeTaken;
5596
5595
  exports.time_memory_Taken = time_memory_Taken;
5597
5596
  exports.timeout = timeout;
5598
- exports.useChannel = useChannel;
5599
5597
  exports.useDerived = useDerived;
5600
5598
  exports.useEventEmitter = useEventEmitter;
5601
5599
  exports.useLocaleStorage = useLocaleStorage;