ziko 0.49.7 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ziko.cjs +123 -156
- package/dist/ziko.js +519 -848
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +514 -833
- package/package.json +4 -1
- package/src/{reactivity → --reactivity-deprecated}/hooks/index.js +3 -3
- package/src/{reactivity → --reactivity-deprecated}/index.js +1 -1
- package/src/__ziko__/__state__.js +1 -1
- package/src/app/ziko-app.js +6 -6
- package/src/events/binders/custom-event.js +11 -7
- package/src/events/binders/index.js +69 -13
- package/src/events/details-setter/index.js +2 -0
- package/src/events/details-setter/key.js +14 -0
- package/src/events/{binders → details-setter}/pointer.js +1 -15
- package/src/events/{__Events__.js → events-map/index.js} +7 -3
- package/src/events/index.js +1 -1
- package/src/events/types/__Shared__.d.ts +3 -3
- package/src/events/types/clipboard.d.ts +2 -2
- package/src/events/types/focus.d.ts +2 -2
- package/src/events/types/pointer.d.ts +2 -2
- package/src/events/{__ZikoEvent__.js → ziko-event.js} +17 -16
- package/src/hooks/index.js +1 -1
- package/src/hooks/{use-channel.js → use-ipc.js} +3 -3
- package/src/hooks/use-storage.js +2 -2
- package/src/index.js +1 -1
- package/src/ui/__methods__/events.js +19 -5
- package/src/ui/constructors/UIElement.js +14 -12
- package/src/ui/constructors/UIElementCore.js +3 -136
- package/types/hooks/index.d.ts +1 -1
- package/types/hooks/{use-channel.d.ts → use-ipc.d.ts} +2 -2
- package/src/events/binders/click.js +0 -20
- package/src/events/binders/clipboard.js +0 -16
- package/src/events/binders/drag.js +0 -16
- package/src/events/binders/focus.js +0 -16
- package/src/events/binders/hash.js +0 -16
- package/src/events/binders/key.js +0 -27
- package/src/events/binders/mouse.js +0 -16
- package/src/events/binders/touch.js +0 -16
- package/src/events/binders/wheel.js +0 -16
- package/src/events/index.d.ts.txt +0 -3
- /package/src/{reactivity → --reactivity-deprecated}/events/Input.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/ZikoEvent.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/__note__ +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/custom-event.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/hash.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/media.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/mouse.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/swipe.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/events/touch.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/Contexte/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/Contexte/useSuccesifKeys.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useCssLink.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useLinearGradient.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useMediaQuery.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useRadialGradient.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useRoot.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useStyle.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/UI/useTheme.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/_useCssText.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useFavIcon.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useHead.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useMeta.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/head/useTitle.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/hooks/todo.md +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/idea +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/attributes.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/children.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/index.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/intersection.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/mutation.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/resize.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/screen.js +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/screen.js.txt +0 -0
- /package/src/{reactivity → --reactivity-deprecated}/observer/screen.txt +0 -0
- /package/src/{use → --use-deprecated}/index.js +0 -0
- /package/src/{use → --use-deprecated}/use-channel.js.txt +0 -0
- /package/src/{use → --use-deprecated}/use-event-emmiter.js.txt +0 -0
- /package/src/{use → --use-deprecated}/use-favicon.js +0 -0
- /package/src/{use → --use-deprecated}/use-link.js +0 -0
- /package/src/{use → --use-deprecated}/use-meta.js +0 -0
- /package/src/{use → --use-deprecated}/use-root.js +0 -0
- /package/src/{use → --use-deprecated}/use-storage.js.txt +0 -0
- /package/src/{use → --use-deprecated}/use-thread.js +0 -0
- /package/src/{use → --use-deprecated}/use-title.js +0 -0
- /package/src/events/{custom-events → custom-events-registry}/click-away.js +0 -0
- /package/src/events/{custom-events → custom-events-registry}/index.js +0 -0
- /package/src/events/{custom-events → custom-events-registry}/swipe.js +0 -0
- /package/src/events/{custom-events → custom-events-registry}/view.js +0 -0
package/dist/ziko.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Tue Dec 02 2025 16:28:22 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
|
|
@@ -1072,35 +1072,6 @@ class UINode {
|
|
|
1072
1072
|
|
|
1073
1073
|
// globalThis.node = (node) => new UINode(node);
|
|
1074
1074
|
|
|
1075
|
-
function parseQueryParams$1(queryString) {
|
|
1076
|
-
const params = {};
|
|
1077
|
-
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
1078
|
-
const [key, value] = match.split('=');
|
|
1079
|
-
params[key] = value;
|
|
1080
|
-
});
|
|
1081
|
-
return params;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
function defineParamsGetter$1(target ){
|
|
1085
|
-
Object.defineProperties(target, {
|
|
1086
|
-
'QueryParams': {
|
|
1087
|
-
get: function() {
|
|
1088
|
-
return parseQueryParams$1(globalThis.location.search.substring(1));
|
|
1089
|
-
},
|
|
1090
|
-
configurable: false,
|
|
1091
|
-
enumerable: true
|
|
1092
|
-
},
|
|
1093
|
-
'HashParams': {
|
|
1094
|
-
get: function() {
|
|
1095
|
-
const hash = globalThis.location.hash.substring(1);
|
|
1096
|
-
return hash.split("#");
|
|
1097
|
-
},
|
|
1098
|
-
configurable: false,
|
|
1099
|
-
enumerable: true
|
|
1100
|
-
}
|
|
1101
|
-
});
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
1075
|
class UIStore extends Array {
|
|
1105
1076
|
constructor(...args) {
|
|
1106
1077
|
super(...args);
|
|
@@ -1134,6 +1105,141 @@ class UIStore extends Array {
|
|
|
1134
1105
|
// create the singleton
|
|
1135
1106
|
const __UI__ = new UIStore();
|
|
1136
1107
|
|
|
1108
|
+
// __init__global__()
|
|
1109
|
+
class UIElementCore extends UINode{
|
|
1110
|
+
constructor(){
|
|
1111
|
+
super();
|
|
1112
|
+
}
|
|
1113
|
+
init(element, name, type, render){
|
|
1114
|
+
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1115
|
+
if(typeof element === "string") {
|
|
1116
|
+
switch(type){
|
|
1117
|
+
case "html" : {
|
|
1118
|
+
element = globalThis?.document?.createElement(element);
|
|
1119
|
+
// console.log('1')
|
|
1120
|
+
} break;
|
|
1121
|
+
case "svg" : {
|
|
1122
|
+
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1123
|
+
// console.log('2')
|
|
1124
|
+
} break;
|
|
1125
|
+
default : throw Error("Not supported")
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
else this.target = element?.parentElement;
|
|
1129
|
+
Object.assign(this.cache, {
|
|
1130
|
+
name,
|
|
1131
|
+
isInteractive : false,
|
|
1132
|
+
parent:null,
|
|
1133
|
+
isBody:false,
|
|
1134
|
+
isRoot:false,
|
|
1135
|
+
isHidden: false,
|
|
1136
|
+
isFrozzen:false,
|
|
1137
|
+
legacyParent : null,
|
|
1138
|
+
attributes: {},
|
|
1139
|
+
filters: {},
|
|
1140
|
+
temp:{}
|
|
1141
|
+
});
|
|
1142
|
+
this.events = {
|
|
1143
|
+
ptr:null,
|
|
1144
|
+
mouse:null,
|
|
1145
|
+
wheel:null,
|
|
1146
|
+
key:null,
|
|
1147
|
+
drag:null,
|
|
1148
|
+
drop:null,
|
|
1149
|
+
click:null,
|
|
1150
|
+
clipboard:null,
|
|
1151
|
+
focus:null,
|
|
1152
|
+
swipe:null,
|
|
1153
|
+
custom:null,
|
|
1154
|
+
};
|
|
1155
|
+
this.observer={
|
|
1156
|
+
resize:null,
|
|
1157
|
+
intersection:null
|
|
1158
|
+
};
|
|
1159
|
+
if(element) Object.assign(this.cache,{element});
|
|
1160
|
+
// useDefaultStyle && this.style({
|
|
1161
|
+
// position: "relative",
|
|
1162
|
+
// boxSizing:"border-box",
|
|
1163
|
+
// margin:0,
|
|
1164
|
+
// padding:0,
|
|
1165
|
+
// width : "auto",
|
|
1166
|
+
// height : "auto"
|
|
1167
|
+
// });
|
|
1168
|
+
this.items = new UIStore();
|
|
1169
|
+
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1170
|
+
element && render && this?.render?.();
|
|
1171
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
1172
|
+
}
|
|
1173
|
+
get element(){
|
|
1174
|
+
return this.cache.element;
|
|
1175
|
+
}
|
|
1176
|
+
[Symbol.iterator]() {
|
|
1177
|
+
return this.items[Symbol.iterator]();
|
|
1178
|
+
}
|
|
1179
|
+
maintain() {
|
|
1180
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1181
|
+
Object.defineProperty(this, i, {
|
|
1182
|
+
value: this.items[i],
|
|
1183
|
+
writable: true,
|
|
1184
|
+
configurable: true,
|
|
1185
|
+
enumerable: false
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
isInteractive(){
|
|
1190
|
+
return this.cache.isInteractive;
|
|
1191
|
+
}
|
|
1192
|
+
isUIElement(){
|
|
1193
|
+
return true;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
function register_to_class(target, ...mixins){
|
|
1198
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1199
|
+
}
|
|
1200
|
+
function _register_to_class_(target, mixin) {
|
|
1201
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1202
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1203
|
+
const desc = descriptors[key];
|
|
1204
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1205
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1206
|
+
} else if (typeof desc.value === 'function') {
|
|
1207
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1208
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
function parseQueryParams$1(queryString) {
|
|
1215
|
+
const params = {};
|
|
1216
|
+
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
1217
|
+
const [key, value] = match.split('=');
|
|
1218
|
+
params[key] = value;
|
|
1219
|
+
});
|
|
1220
|
+
return params;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
function defineParamsGetter$1(target ){
|
|
1224
|
+
Object.defineProperties(target, {
|
|
1225
|
+
'QueryParams': {
|
|
1226
|
+
get: function() {
|
|
1227
|
+
return parseQueryParams$1(globalThis.location.search.substring(1));
|
|
1228
|
+
},
|
|
1229
|
+
configurable: false,
|
|
1230
|
+
enumerable: true
|
|
1231
|
+
},
|
|
1232
|
+
'HashParams': {
|
|
1233
|
+
get: function() {
|
|
1234
|
+
const hash = globalThis.location.hash.substring(1);
|
|
1235
|
+
return hash.split("#");
|
|
1236
|
+
},
|
|
1237
|
+
configurable: false,
|
|
1238
|
+
enumerable: true
|
|
1239
|
+
}
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1137
1243
|
const __Config__ = {
|
|
1138
1244
|
default:{
|
|
1139
1245
|
target:null,
|
|
@@ -1177,7 +1283,7 @@ const __CACHE__ = {
|
|
|
1177
1283
|
}
|
|
1178
1284
|
};
|
|
1179
1285
|
|
|
1180
|
-
class
|
|
1286
|
+
class UseIPC {
|
|
1181
1287
|
#channel;
|
|
1182
1288
|
#eventData;
|
|
1183
1289
|
#handlers;
|
|
@@ -1258,14 +1364,14 @@ class UseChannel {
|
|
|
1258
1364
|
}
|
|
1259
1365
|
}
|
|
1260
1366
|
|
|
1261
|
-
const
|
|
1367
|
+
const useIPC = (name) => new UseIPC(name);
|
|
1262
1368
|
|
|
1263
1369
|
class UseStorage {
|
|
1264
1370
|
constructor(storage, globalKey, initialValue, use_channel = true) {
|
|
1265
1371
|
this.cache = {
|
|
1266
1372
|
storage,
|
|
1267
1373
|
globalKey,
|
|
1268
|
-
channel: use_channel ?
|
|
1374
|
+
channel: use_channel ? useIPC(`Ziko:useStorage-${globalKey}`) : null,
|
|
1269
1375
|
oldItemKeys: new Set()
|
|
1270
1376
|
};
|
|
1271
1377
|
|
|
@@ -1348,283 +1454,43 @@ class UseStorage {
|
|
|
1348
1454
|
|
|
1349
1455
|
// factory functions
|
|
1350
1456
|
const useLocaleStorage = (key, initialValue, use_channel = true) =>
|
|
1351
|
-
new UseStorage(localStorage, key, initialValue, use_channel);
|
|
1352
|
-
|
|
1353
|
-
const useSessionStorage = (key, initialValue, use_channel = true) =>
|
|
1354
|
-
new UseStorage(sessionStorage, key, initialValue, use_channel);
|
|
1355
|
-
|
|
1356
|
-
const __State__ = {
|
|
1357
|
-
store : new Map(),
|
|
1358
|
-
index : 0,
|
|
1359
|
-
session_storage : null,
|
|
1360
|
-
register: function(state){
|
|
1361
|
-
if(!import.meta.env.SSR && import.meta.env.DEV){
|
|
1362
|
-
if(!this.session) this.session_storage = useSessionStorage('ziko-state', {});
|
|
1363
|
-
const savedValue = this.session_storage.get(this.index);
|
|
1364
|
-
if(!savedValue) this.session_storage.add({[this.index] : state.value});
|
|
1365
|
-
else state.value = savedValue;
|
|
1366
|
-
}
|
|
1367
|
-
this.store.set(this.index++, state);
|
|
1368
|
-
},
|
|
1369
|
-
update: function(index, value){
|
|
1370
|
-
if(!import.meta.env.SSR && import.meta.env.DEV){
|
|
1371
|
-
this.session_storage.add({[index] : value});
|
|
1372
|
-
}
|
|
1373
|
-
},
|
|
1374
|
-
|
|
1375
|
-
};
|
|
1376
|
-
|
|
1377
|
-
function __init__global__(){
|
|
1378
|
-
if ( !globalThis?.__Ziko__ ){
|
|
1379
|
-
globalThis.__Ziko__ = {
|
|
1380
|
-
__UI__,
|
|
1381
|
-
__HYDRATION__,
|
|
1382
|
-
__State__,
|
|
1383
|
-
__Config__,
|
|
1384
|
-
__CACHE__,
|
|
1385
|
-
};
|
|
1386
|
-
defineParamsGetter$1(__Ziko__);
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
__init__global__();
|
|
1391
|
-
class UIElementCore extends UINode{
|
|
1392
|
-
constructor(){
|
|
1393
|
-
super();
|
|
1394
|
-
}
|
|
1395
|
-
init(element, name, type, render){
|
|
1396
|
-
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1397
|
-
if(typeof element === "string") {
|
|
1398
|
-
switch(type){
|
|
1399
|
-
case "html" : {
|
|
1400
|
-
element = globalThis?.document?.createElement(element);
|
|
1401
|
-
// console.log('1')
|
|
1402
|
-
} break;
|
|
1403
|
-
case "svg" : {
|
|
1404
|
-
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1405
|
-
// console.log('2')
|
|
1406
|
-
} break;
|
|
1407
|
-
default : throw Error("Not supported")
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
else this.target = element?.parentElement;
|
|
1411
|
-
Object.assign(this.cache, {
|
|
1412
|
-
name,
|
|
1413
|
-
isInteractive : false,
|
|
1414
|
-
parent:null,
|
|
1415
|
-
isBody:false,
|
|
1416
|
-
isRoot:false,
|
|
1417
|
-
isHidden: false,
|
|
1418
|
-
isFrozzen:false,
|
|
1419
|
-
legacyParent : null,
|
|
1420
|
-
attributes: {},
|
|
1421
|
-
filters: {},
|
|
1422
|
-
temp:{}
|
|
1423
|
-
});
|
|
1424
|
-
this.events = {
|
|
1425
|
-
ptr:null,
|
|
1426
|
-
mouse:null,
|
|
1427
|
-
wheel:null,
|
|
1428
|
-
key:null,
|
|
1429
|
-
drag:null,
|
|
1430
|
-
drop:null,
|
|
1431
|
-
click:null,
|
|
1432
|
-
clipboard:null,
|
|
1433
|
-
focus:null,
|
|
1434
|
-
swipe:null,
|
|
1435
|
-
custom:null,
|
|
1436
|
-
};
|
|
1437
|
-
this.observer={
|
|
1438
|
-
resize:null,
|
|
1439
|
-
intersection:null
|
|
1440
|
-
};
|
|
1441
|
-
if(element) Object.assign(this.cache,{element});
|
|
1442
|
-
// useDefaultStyle && this.style({
|
|
1443
|
-
// position: "relative",
|
|
1444
|
-
// boxSizing:"border-box",
|
|
1445
|
-
// margin:0,
|
|
1446
|
-
// padding:0,
|
|
1447
|
-
// width : "auto",
|
|
1448
|
-
// height : "auto"
|
|
1449
|
-
// });
|
|
1450
|
-
this.items = new UIStore();
|
|
1451
|
-
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1452
|
-
element && render && this?.render?.();
|
|
1453
|
-
globalThis.__Ziko__.__UI__.push(this);
|
|
1454
|
-
}
|
|
1455
|
-
get element(){
|
|
1456
|
-
return this.cache.element;
|
|
1457
|
-
}
|
|
1458
|
-
[Symbol.iterator]() {
|
|
1459
|
-
return this.items[Symbol.iterator]();
|
|
1460
|
-
}
|
|
1461
|
-
maintain() {
|
|
1462
|
-
for (let i = 0; i < this.items.length; i++) {
|
|
1463
|
-
Object.defineProperty(this, i, {
|
|
1464
|
-
value: this.items[i],
|
|
1465
|
-
writable: true,
|
|
1466
|
-
configurable: true,
|
|
1467
|
-
enumerable: false
|
|
1468
|
-
});
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
isInteractive(){
|
|
1472
|
-
return this.cache.isInteractive;
|
|
1473
|
-
}
|
|
1474
|
-
isUIElement(){
|
|
1475
|
-
return true;
|
|
1476
|
-
}
|
|
1477
|
-
// get st(){
|
|
1478
|
-
// return this.cache.style;
|
|
1479
|
-
// }
|
|
1480
|
-
// get attr(){
|
|
1481
|
-
// return this.cache.attributes;
|
|
1482
|
-
// }
|
|
1483
|
-
// get evt(){
|
|
1484
|
-
// return this.events;
|
|
1485
|
-
// }
|
|
1486
|
-
// get html(){
|
|
1487
|
-
// return this.element.innerHTML;
|
|
1488
|
-
// }
|
|
1489
|
-
// get text(){
|
|
1490
|
-
// return this.element.textContent;
|
|
1491
|
-
// }
|
|
1492
|
-
// get isBody(){
|
|
1493
|
-
// return this.element === globalThis?.document.body;
|
|
1494
|
-
// }
|
|
1495
|
-
// get parent(){
|
|
1496
|
-
// return this.cache.parent;
|
|
1497
|
-
// }
|
|
1498
|
-
// get width(){
|
|
1499
|
-
// return this.element.getBoundingClientRect().width;
|
|
1500
|
-
// }
|
|
1501
|
-
// get height(){
|
|
1502
|
-
// return this.element.getBoundingClientRect().height;
|
|
1503
|
-
// }
|
|
1504
|
-
// get top(){
|
|
1505
|
-
// return this.element.getBoundingClientRect().top;
|
|
1506
|
-
// }
|
|
1507
|
-
// get right(){
|
|
1508
|
-
// return this.element.getBoundingClientRect().right;
|
|
1509
|
-
// }
|
|
1510
|
-
// get bottom(){
|
|
1511
|
-
// return this.element.getBoundingClientRect().bottom;
|
|
1512
|
-
// }
|
|
1513
|
-
// get left(){
|
|
1514
|
-
// return this.element.getBoundingClientRect().left;
|
|
1515
|
-
// }
|
|
1516
|
-
// clone(render=false) {
|
|
1517
|
-
// // UI.__proto__=this.__proto__;
|
|
1518
|
-
// // if(this.items.length){
|
|
1519
|
-
// // const items = [...this.items].map(n=>n.clone());
|
|
1520
|
-
// // UI.append(...items);
|
|
1521
|
-
// // }
|
|
1522
|
-
// // else UI.element=this.element.cloneNode(true);
|
|
1523
|
-
// // return UI.mount(render);
|
|
1524
|
-
// }
|
|
1525
|
-
|
|
1526
|
-
// freeze(freeze){
|
|
1527
|
-
// this.cache.isFrozzen=freeze;
|
|
1528
|
-
// return this;
|
|
1529
|
-
// }
|
|
1530
|
-
// setTarget(tg) {
|
|
1531
|
-
// if(this.isBody) return ;
|
|
1532
|
-
// if (tg?.isUIElement) tg = tg.element;
|
|
1533
|
-
// this.unmount();
|
|
1534
|
-
// this.target = tg;
|
|
1535
|
-
// this.mount();
|
|
1536
|
-
// return this;
|
|
1537
|
-
// }
|
|
1538
|
-
// describe(label){
|
|
1539
|
-
// if(label)this.setAttr("aria-label",label)
|
|
1540
|
-
// }
|
|
1541
|
-
// get children() {
|
|
1542
|
-
// return [...this.element.children];
|
|
1543
|
-
// }
|
|
1544
|
-
// get cloneElement() {
|
|
1545
|
-
// return this.element.cloneNode(true);
|
|
1546
|
-
// }
|
|
1547
|
-
// setClasses(...value) {
|
|
1548
|
-
// this.setAttr("class", value.join(" "));
|
|
1549
|
-
// return this;
|
|
1550
|
-
// }
|
|
1551
|
-
// get classes(){
|
|
1552
|
-
// const classes=this.element.getAttribute("class");
|
|
1553
|
-
// return classes===null?[]:classes.split(" ");
|
|
1554
|
-
// }
|
|
1555
|
-
// addClass() {
|
|
1556
|
-
// /*this.setAttr("class", value);
|
|
1557
|
-
// return this;*/
|
|
1558
|
-
// }
|
|
1559
|
-
// setId(id) {
|
|
1560
|
-
// this.setAttr("id", id);
|
|
1561
|
-
// return this;
|
|
1562
|
-
// }
|
|
1563
|
-
// get id() {
|
|
1564
|
-
// return this.element.getAttribute("id");
|
|
1565
|
-
// }
|
|
1566
|
-
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
1567
|
-
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
1568
|
-
// this.events.swipe.onSwipe(...callbacks);
|
|
1569
|
-
// return this;
|
|
1570
|
-
// }
|
|
1571
|
-
// To Fix
|
|
1572
|
-
// onKeysDown({keys=[],callback}={}){
|
|
1573
|
-
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
1574
|
-
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
1575
|
-
// return this;
|
|
1576
|
-
// }
|
|
1577
|
-
// onSelect(...callbacks){
|
|
1578
|
-
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
1579
|
-
// this.events.clipboard.onSelect(...callbacks);
|
|
1580
|
-
// return this;
|
|
1581
|
-
// }
|
|
1582
|
-
// on(event_name,...callbacks){
|
|
1583
|
-
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1584
|
-
// this.events.custom.on(event_name,...callbacks);
|
|
1585
|
-
// return this;
|
|
1586
|
-
// }
|
|
1587
|
-
// emit(event_name,detail={}){
|
|
1588
|
-
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1589
|
-
// this.events.custom.emit(event_name,detail);
|
|
1590
|
-
// return this;
|
|
1591
|
-
// }
|
|
1592
|
-
// watchAttr(callback){
|
|
1593
|
-
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
1594
|
-
// return this;
|
|
1595
|
-
// }
|
|
1596
|
-
// watchChildren(callback){
|
|
1597
|
-
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
1598
|
-
// return this;
|
|
1599
|
-
// }
|
|
1600
|
-
// watchSize(callback){
|
|
1601
|
-
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
1602
|
-
// this.observer.resize.start();
|
|
1603
|
-
// return this;
|
|
1604
|
-
// }
|
|
1605
|
-
// watchIntersection(callback,config){
|
|
1606
|
-
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
1607
|
-
// this.observer.intersection.start();
|
|
1608
|
-
// return this;
|
|
1609
|
-
// }
|
|
1457
|
+
new UseStorage(localStorage, key, initialValue, use_channel);
|
|
1610
1458
|
|
|
1611
|
-
|
|
1459
|
+
const useSessionStorage = (key, initialValue, use_channel = true) =>
|
|
1460
|
+
new UseStorage(sessionStorage, key, initialValue, use_channel);
|
|
1612
1461
|
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1462
|
+
var __State__ = {
|
|
1463
|
+
store : new Map(),
|
|
1464
|
+
index : 0,
|
|
1465
|
+
session_storage : null,
|
|
1466
|
+
register: function(state){
|
|
1467
|
+
if(!import.meta.env.SSR && import.meta.env.DEV){
|
|
1468
|
+
if(!this.session) this.session_storage = useSessionStorage('ziko-state', {});
|
|
1469
|
+
const savedValue = this.session_storage.get(this.index);
|
|
1470
|
+
if(!savedValue) this.session_storage.add({[this.index] : state.value});
|
|
1471
|
+
else state.value = savedValue;
|
|
1472
|
+
}
|
|
1473
|
+
this.store.set(this.index++, state);
|
|
1474
|
+
},
|
|
1475
|
+
update: function(index, value){
|
|
1476
|
+
if(!import.meta.env.SSR && import.meta.env.DEV){
|
|
1477
|
+
this.session_storage.add({[index] : value});
|
|
1478
|
+
}
|
|
1479
|
+
},
|
|
1480
|
+
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
function __init__global__(){
|
|
1484
|
+
if ( !globalThis?.__Ziko__ ){
|
|
1485
|
+
globalThis.__Ziko__ = {
|
|
1486
|
+
__UI__,
|
|
1487
|
+
__HYDRATION__,
|
|
1488
|
+
__State__,
|
|
1489
|
+
__Config__,
|
|
1490
|
+
__CACHE__,
|
|
1491
|
+
};
|
|
1492
|
+
defineParamsGetter$1(__Ziko__);
|
|
1626
1493
|
}
|
|
1627
|
-
}
|
|
1628
1494
|
}
|
|
1629
1495
|
|
|
1630
1496
|
if(!globalThis.__Ziko__) __init__global__();
|
|
@@ -1887,7 +1753,11 @@ var DomMethods = /*#__PURE__*/Object.freeze({
|
|
|
1887
1753
|
unrenderAfter: unrenderAfter
|
|
1888
1754
|
});
|
|
1889
1755
|
|
|
1890
|
-
const
|
|
1756
|
+
const EventsMap = {
|
|
1757
|
+
'Custom' : [
|
|
1758
|
+
'emit',
|
|
1759
|
+
'on'
|
|
1760
|
+
],
|
|
1891
1761
|
'Click' : [
|
|
1892
1762
|
'Click',
|
|
1893
1763
|
'DblClick',
|
|
@@ -1947,21 +1817,7 @@ const getEvent=(event = "")=>{
|
|
|
1947
1817
|
return event.toLowerCase()
|
|
1948
1818
|
};
|
|
1949
1819
|
|
|
1950
|
-
|
|
1951
|
-
this.cache.currentEvent = event_name;
|
|
1952
|
-
this.cache.event = e;
|
|
1953
|
-
details_setter?.call(this);
|
|
1954
|
-
customizer?.hasOwnProperty("prototype") ? customizer?.call(this) : customizer?.call(null, this);
|
|
1955
|
-
// if(customizer?.hasOwnProperty("prototype")) customizer?.call(this)
|
|
1956
|
-
// else customizer?.call(null, this)
|
|
1957
|
-
if(this.cache.preventDefault[event_name]) e.preventDefault();
|
|
1958
|
-
if(this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
1959
|
-
if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
1960
|
-
|
|
1961
|
-
if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
|
|
1962
|
-
this.cache.callbacks[event_name]?.map(n=>n(this));
|
|
1963
|
-
}
|
|
1964
|
-
class __ZikoEvent__ {
|
|
1820
|
+
class ZikoEvent {
|
|
1965
1821
|
constructor(target = null, Events = [], details_setter, customizer){
|
|
1966
1822
|
this.target = target;
|
|
1967
1823
|
this.cache = {
|
|
@@ -2105,92 +1961,24 @@ class __ZikoEvent__ {
|
|
|
2105
1961
|
|
|
2106
1962
|
return this;
|
|
2107
1963
|
}
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
|
-
// import { register_click_away_event } from "./custom-events/click-away.js";
|
|
2111
|
-
class ZikoEventClick extends __ZikoEvent__{
|
|
2112
|
-
constructor(target, customizer){
|
|
2113
|
-
super(target, Events.Click, details_setter$a, customizer);
|
|
2114
|
-
// register_click_away_event(target.element)
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
function details_setter$a(){
|
|
2118
|
-
if(this.currentEvent==="click") this.dx = 0;
|
|
2119
|
-
else this.dx = 1;
|
|
2120
|
-
// console.log(this.currentEvent)
|
|
2121
|
-
}
|
|
2122
|
-
const bind_click_event = (target, customizer) => new ZikoEventClick(target, customizer);
|
|
2123
|
-
|
|
2124
|
-
class ZikoEventClipboard extends __ZikoEvent__{
|
|
2125
|
-
constructor(target, customizer){
|
|
2126
|
-
super(target, Events.Clipboard, details_setter$9, customizer);
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
function details_setter$9(){
|
|
2130
|
-
|
|
2131
|
-
}
|
|
2132
|
-
const bind_clipboard_event = (target, customizer) => new ZikoEventClipboard(target, customizer);
|
|
2133
|
-
|
|
2134
|
-
class ZikoEventCustom extends __ZikoEvent__{
|
|
2135
|
-
constructor(target, events, customizer){
|
|
2136
|
-
super(target, events, details_setter$8, customizer);
|
|
2137
|
-
}
|
|
2138
|
-
_register_events(events){
|
|
2139
|
-
super._register_events(events, null, null, false);
|
|
2140
|
-
return this;
|
|
2141
|
-
}
|
|
2142
|
-
emit(event_name, details = {}){
|
|
2143
|
-
const event=new Event(event_name);
|
|
2144
|
-
this.targetElement.dispatchEvent(event);
|
|
2145
|
-
return this;
|
|
2146
|
-
}
|
|
2147
|
-
on(event_name, ...callbacks){
|
|
2148
|
-
if(!this.cache.options.hasOwnProperty(event_name)) this._register_events([event_name]);
|
|
2149
|
-
this.__onEvent(event_name, this.cache.options[event_name], {}, ...callbacks);
|
|
2150
|
-
return this;
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
function details_setter$8(){
|
|
2154
|
-
|
|
2155
|
-
}
|
|
2156
|
-
const bindCustomEvent = (target, events, customizer) => new ZikoEventCustom(target, events, customizer);
|
|
2157
|
-
|
|
2158
|
-
class ZikoEventDrag extends __ZikoEvent__{
|
|
2159
|
-
constructor(target, customizer){
|
|
2160
|
-
super(target, Events.Drag, details_setter$7, customizer);
|
|
2161
|
-
}
|
|
2162
|
-
}
|
|
2163
|
-
function details_setter$7(){
|
|
2164
|
-
|
|
2165
|
-
}
|
|
2166
|
-
const bind_drag_event = (target, customizer) => new ZikoEventDrag(target, customizer);
|
|
2167
|
-
|
|
2168
|
-
class ZikoEventFocus extends __ZikoEvent__{
|
|
2169
|
-
constructor(target, customizer){
|
|
2170
|
-
super(target, Events.Focus, details_setter$6, customizer);
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
function details_setter$6(){
|
|
2174
|
-
|
|
2175
|
-
}
|
|
2176
|
-
const bind_focus_event = (target, customizer) => new ZikoEventFocus(target, customizer);
|
|
2177
|
-
|
|
2178
|
-
class ZikoEventHash extends __ZikoEvent__{
|
|
2179
|
-
constructor(target, customizer){
|
|
2180
|
-
super(target, Events.Hash, details_setter$5, customizer);
|
|
2181
|
-
}
|
|
2182
1964
|
}
|
|
2183
|
-
function details_setter$5(){
|
|
2184
1965
|
|
|
2185
|
-
|
|
2186
|
-
|
|
1966
|
+
function event_controller(e, event_name, details_setter, customizer, push_object){
|
|
1967
|
+
this.cache.currentEvent = event_name;
|
|
1968
|
+
this.cache.event = e;
|
|
1969
|
+
details_setter?.call(this);
|
|
1970
|
+
customizer?.hasOwnProperty("prototype") ? customizer?.call(this) : customizer?.call(null, this);
|
|
1971
|
+
// if(customizer?.hasOwnProperty("prototype")) customizer?.call(this)
|
|
1972
|
+
// else customizer?.call(null, this)
|
|
1973
|
+
if(this.cache.preventDefault[event_name]) e.preventDefault();
|
|
1974
|
+
if(this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
1975
|
+
if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
1976
|
+
|
|
1977
|
+
if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
|
|
1978
|
+
this.cache.callbacks[event_name]?.map(n=>n(this));
|
|
1979
|
+
}
|
|
2187
1980
|
|
|
2188
|
-
|
|
2189
|
-
constructor(target, customizer){
|
|
2190
|
-
super(target, Events.Key, details_setter$4, customizer);
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
function details_setter$4(){
|
|
1981
|
+
function key_details_setter(){
|
|
2194
1982
|
switch(this.currentEvent){
|
|
2195
1983
|
case "keydown" : {
|
|
2196
1984
|
this.kd = this.event.key;
|
|
@@ -2203,26 +1991,9 @@ function details_setter$4(){
|
|
|
2203
1991
|
} break;
|
|
2204
1992
|
|
|
2205
1993
|
}
|
|
2206
|
-
}
|
|
2207
|
-
const bind_key_event = (target, customizer) => new ZikoEventKey(target, customizer);
|
|
2208
|
-
|
|
2209
|
-
class ZikoEventMouse extends __ZikoEvent__{
|
|
2210
|
-
constructor(target, customizer){
|
|
2211
|
-
super(target, Events.Mouse, details_setter$3, customizer);
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
function details_setter$3(){
|
|
2215
|
-
|
|
2216
|
-
}
|
|
2217
|
-
const bind_mouse_event = (target, customizer) => new ZikoEventMouse(target, customizer);
|
|
1994
|
+
}
|
|
2218
1995
|
|
|
2219
|
-
|
|
2220
|
-
constructor(target, customizer){
|
|
2221
|
-
super(target, Events.Ptr, details_setter$2, customizer);
|
|
2222
|
-
this.isDown = false;
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
function details_setter$2(){
|
|
1996
|
+
function ptr_details_setter(){
|
|
2226
1997
|
switch(this.currentEvent){
|
|
2227
1998
|
case "pointerdown" : {
|
|
2228
1999
|
this.dx = parseInt(this.event.offsetX);
|
|
@@ -2254,28 +2025,135 @@ function details_setter$2(){
|
|
|
2254
2025
|
// if(this.currentEvent==="click") this.dx = 0
|
|
2255
2026
|
// else this.dx = 1
|
|
2256
2027
|
// console.log(this.currentEvent)
|
|
2257
|
-
}
|
|
2258
|
-
const bind_pointer_event = (target, customizer) => new ZikoEventPointer(target, customizer);
|
|
2028
|
+
}
|
|
2259
2029
|
|
|
2260
|
-
class
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2030
|
+
class ClickAwayEvent extends Event {
|
|
2031
|
+
constructor(originalEvent, targetElement) {
|
|
2032
|
+
super("clickaway", { bubbles: true, cancelable: true });
|
|
2033
|
+
this.originalEvent = originalEvent;
|
|
2034
|
+
this.targetElement = targetElement;
|
|
2035
|
+
}
|
|
2264
2036
|
}
|
|
2265
|
-
function details_setter$1(){
|
|
2266
2037
|
|
|
2038
|
+
function register_click_away_event(element) {
|
|
2039
|
+
console.log(element);
|
|
2040
|
+
function handler(e) {
|
|
2041
|
+
if (!element.contains(e.target)) {
|
|
2042
|
+
const clickAwayEvent = new ClickAwayEvent(e, element);
|
|
2043
|
+
element.dispatchEvent(clickAwayEvent);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
globalThis?.document?.addEventListener("click", handler);
|
|
2048
|
+
|
|
2049
|
+
return () => globalThis?.document?.removeEventListener("click", handler);
|
|
2050
|
+
|
|
2267
2051
|
}
|
|
2268
|
-
|
|
2052
|
+
|
|
2053
|
+
// // Example usage
|
|
2054
|
+
// const box = document.querySelector("#my-box");
|
|
2055
|
+
|
|
2056
|
+
// const stop = listenClickAway(box);
|
|
2057
|
+
|
|
2058
|
+
// box.addEventListener("clickaway", (e) => {
|
|
2059
|
+
// console.log("Clicked outside box!", e);
|
|
2060
|
+
// });
|
|
2061
|
+
|
|
2062
|
+
// // later, you can stop listening:
|
|
2063
|
+
// // stop();
|
|
2269
2064
|
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2065
|
+
const bind_click_event = (target, customizer) => {
|
|
2066
|
+
register_click_away_event(target.element);
|
|
2067
|
+
return new ZikoEvent(
|
|
2068
|
+
target,
|
|
2069
|
+
EventsMap.Click,
|
|
2070
|
+
null,
|
|
2071
|
+
customizer
|
|
2072
|
+
);
|
|
2073
|
+
};
|
|
2074
|
+
const bind_clipboard_event = (target, customizer) => new ZikoEvent(
|
|
2075
|
+
target,
|
|
2076
|
+
EventsMap.Clipboard,
|
|
2077
|
+
null,
|
|
2078
|
+
customizer
|
|
2079
|
+
);
|
|
2080
|
+
const bind_drag_event = (target, customizer) => new ZikoEvent(
|
|
2081
|
+
target,
|
|
2082
|
+
EventsMap.Drag,
|
|
2083
|
+
null,
|
|
2084
|
+
customizer
|
|
2085
|
+
);
|
|
2086
|
+
const bind_focus_event = (target, customizer) => new ZikoEvent(
|
|
2087
|
+
target,
|
|
2088
|
+
EventsMap.Focus,
|
|
2089
|
+
null,
|
|
2090
|
+
customizer
|
|
2091
|
+
);
|
|
2092
|
+
const bind_key_event = (target, customizer) => new ZikoEvent(
|
|
2093
|
+
target,
|
|
2094
|
+
EventsMap.Key,
|
|
2095
|
+
key_details_setter,
|
|
2096
|
+
customizer
|
|
2097
|
+
);
|
|
2098
|
+
const bind_mouse_event = (target, customizer) => new ZikoEvent(
|
|
2099
|
+
target,
|
|
2100
|
+
EventsMap.Mouse,
|
|
2101
|
+
null,
|
|
2102
|
+
customizer
|
|
2103
|
+
);
|
|
2104
|
+
const bind_pointer_event = (target, customizer) => new ZikoEvent(
|
|
2105
|
+
target,
|
|
2106
|
+
EventsMap.Ptr,
|
|
2107
|
+
ptr_details_setter,
|
|
2108
|
+
customizer
|
|
2109
|
+
);
|
|
2110
|
+
const bind_touch_event = (target, customizer) => new ZikoEvent(
|
|
2111
|
+
target,
|
|
2112
|
+
EventsMap.Touch,
|
|
2113
|
+
null,
|
|
2114
|
+
customizer
|
|
2115
|
+
);
|
|
2116
|
+
const bind_wheel_event = (target, customizer) => new ZikoEvent(
|
|
2117
|
+
target,
|
|
2118
|
+
EventsMap.Wheel,
|
|
2119
|
+
null,
|
|
2120
|
+
customizer
|
|
2121
|
+
);
|
|
2122
|
+
|
|
2123
|
+
|
|
2124
|
+
// function details_setter(){
|
|
2125
|
+
// if(this.currentEvent==="click") this.dx = 0
|
|
2126
|
+
// else this.dx = 1
|
|
2127
|
+
// // console.log(this.currentEvent)
|
|
2128
|
+
// }
|
|
2129
|
+
|
|
2130
|
+
class ZikoCustomEvent extends ZikoEvent{
|
|
2131
|
+
constructor(target, events, customizer){
|
|
2132
|
+
super(target, events, details_setter, customizer);
|
|
2133
|
+
}
|
|
2134
|
+
_register_events(events){
|
|
2135
|
+
super._register_events(events, null, null, false);
|
|
2136
|
+
return this;
|
|
2137
|
+
}
|
|
2138
|
+
emit(event_name, detail = {}){
|
|
2139
|
+
const event = new CustomEvent(event_name, {
|
|
2140
|
+
detail,
|
|
2141
|
+
bubbles: true,
|
|
2142
|
+
cancelable: true
|
|
2143
|
+
});
|
|
2144
|
+
this.targetElement.dispatchEvent(event);
|
|
2145
|
+
return this;
|
|
2146
|
+
}
|
|
2147
|
+
on(event_name, ...callbacks){
|
|
2148
|
+
if(!this.cache.options.hasOwnProperty(event_name)) this._register_events([event_name]);
|
|
2149
|
+
this.__onEvent(event_name, this.cache.options[event_name], {}, ...callbacks);
|
|
2150
|
+
return this;
|
|
2273
2151
|
}
|
|
2274
2152
|
}
|
|
2275
2153
|
function details_setter(){
|
|
2276
2154
|
|
|
2277
2155
|
}
|
|
2278
|
-
const
|
|
2156
|
+
const bind_custom_event = (target, events, customizer) => new ZikoCustomEvent(target, events, customizer);
|
|
2279
2157
|
|
|
2280
2158
|
const binderMap = {
|
|
2281
2159
|
ptr: bind_pointer_event,
|
|
@@ -2288,14 +2166,26 @@ const binderMap = {
|
|
|
2288
2166
|
wheel : bind_wheel_event
|
|
2289
2167
|
};
|
|
2290
2168
|
|
|
2291
|
-
const EventsMethodes = {
|
|
2169
|
+
const EventsMethodes = {
|
|
2170
|
+
on(event_name,...callbacks){
|
|
2171
|
+
if(!this.events.custom)this.events.custom = bind_custom_event(this);
|
|
2172
|
+
this.events.custom.on(event_name,...callbacks);
|
|
2173
|
+
return this;
|
|
2174
|
+
},
|
|
2175
|
+
emit(event_name,detail={}){
|
|
2176
|
+
if(!this.events.custom)this.events.custom = bind_custom_event(this);
|
|
2177
|
+
this.events.custom.emit(event_name,detail);
|
|
2178
|
+
return this;
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2292
2181
|
|
|
2293
|
-
Object.entries(
|
|
2182
|
+
Object.entries(EventsMap).forEach(([name, eventList]) => {
|
|
2183
|
+
const lname = name.toLowerCase();
|
|
2294
2184
|
eventList.forEach(event => {
|
|
2295
2185
|
const methodName = `on${event}`;
|
|
2296
2186
|
EventsMethodes[methodName] = function (...callbacks) {
|
|
2297
|
-
if (!this.events[
|
|
2298
|
-
this.events[
|
|
2187
|
+
if (!this.events[lname]) this.events[lname] = binderMap[lname](this);
|
|
2188
|
+
this.events[lname][methodName](...callbacks);
|
|
2299
2189
|
return this;
|
|
2300
2190
|
};
|
|
2301
2191
|
});
|
|
@@ -2337,177 +2227,33 @@ function style(styles){
|
|
|
2337
2227
|
},
|
|
2338
2228
|
// this
|
|
2339
2229
|
);
|
|
2340
|
-
}
|
|
2341
|
-
else Object.assign(this.element.style, {[key] : value});
|
|
2342
|
-
}
|
|
2343
|
-
return this;
|
|
2344
|
-
}
|
|
2345
|
-
function size(width, height){
|
|
2346
|
-
return this.style({width, height})
|
|
2347
|
-
}
|
|
2348
|
-
function hide(){
|
|
2349
|
-
|
|
2350
|
-
}
|
|
2351
|
-
function show(){
|
|
2352
|
-
|
|
2353
|
-
}
|
|
2354
|
-
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2355
|
-
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2356
|
-
return this;
|
|
2357
|
-
}
|
|
2358
|
-
|
|
2359
|
-
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2360
|
-
__proto__: null,
|
|
2361
|
-
animate: animate,
|
|
2362
|
-
hide: hide,
|
|
2363
|
-
show: show,
|
|
2364
|
-
size: size,
|
|
2365
|
-
style: style
|
|
2366
|
-
});
|
|
2367
|
-
|
|
2368
|
-
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
2369
|
-
this.event=e;
|
|
2370
|
-
if(this.cache.preventDefault[EVENT])e.preventDefault();
|
|
2371
|
-
console.log({setter});
|
|
2372
|
-
if(setter)setter();
|
|
2373
|
-
if(this.cache.stream.enabled[EVENT]&&push_object)this.cache.stream.history[EVENT].push(push_object);
|
|
2374
|
-
this.cache.callbacks[EVENT].map(n=>n(this));
|
|
2375
|
-
return this;
|
|
2376
|
-
}
|
|
2377
|
-
class ZikoEvent{
|
|
2378
|
-
constructor(target){
|
|
2379
|
-
this.target=null;
|
|
2380
|
-
this.setTarget(target);
|
|
2381
|
-
this.__dispose=this.dispose.bind(this);
|
|
2382
|
-
// this.EventIndex=Garbage.Pointer.data.length;
|
|
2383
|
-
// Garbage.Pointer.data.push({event:this,index:this.EventIndex});
|
|
2384
|
-
}
|
|
2385
|
-
get targetElement(){
|
|
2386
|
-
return this.target.element
|
|
2387
|
-
}
|
|
2388
|
-
setTarget(UI){
|
|
2389
|
-
this.target=UI;
|
|
2390
|
-
return this;
|
|
2391
|
-
}
|
|
2392
|
-
__handle(event,handler,dispose){
|
|
2393
|
-
const EVENT=(event==="drag")?event:`${this.cache.prefixe}${event}`;
|
|
2394
|
-
this.dispose(dispose);
|
|
2395
|
-
this.targetElement?.addEventListener(EVENT,handler);
|
|
2396
|
-
return this;
|
|
2397
|
-
}
|
|
2398
|
-
__onEvent(event,dispose,...callbacks){
|
|
2399
|
-
if(callbacks.length===0){
|
|
2400
|
-
if(this.cache.callbacks.length>1){
|
|
2401
|
-
this.cache.callbacks.map(n=>e=>n.call(this,e));
|
|
2402
|
-
}
|
|
2403
|
-
else {
|
|
2404
|
-
return this;
|
|
2405
|
-
}
|
|
2406
|
-
}
|
|
2407
|
-
else this.cache.callbacks[event]=callbacks.map(n=>e=>n.call(this,e));
|
|
2408
|
-
this.__handle(event,this.__controller[event],dispose);
|
|
2409
|
-
return this;
|
|
2410
|
-
}
|
|
2411
|
-
preventDefault(config={}){
|
|
2412
|
-
Object.assign(this.cache.preventDefault,config);
|
|
2413
|
-
return this;
|
|
2414
|
-
}
|
|
2415
|
-
pause(config={}){
|
|
2416
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]));
|
|
2417
|
-
config={...all,...config};
|
|
2418
|
-
for(let key in config){
|
|
2419
|
-
if(config[key]){
|
|
2420
|
-
this.targetElement?.removeEventListener(`${this.cache.prefixe}${key}`,this.__controller[`${this.cache.prefixe}${key}`]);
|
|
2421
|
-
this.cache.paused[`${this.cache.prefixe}${key}`]=true;
|
|
2422
|
-
}
|
|
2423
|
-
}
|
|
2424
|
-
return this;
|
|
2425
|
-
}
|
|
2426
|
-
resume(config={}){
|
|
2427
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]));
|
|
2428
|
-
config={...all,...config};
|
|
2429
|
-
for(let key in config){
|
|
2430
|
-
if(config[key]){
|
|
2431
|
-
this.targetElement?.addEventListener(`${this.cache.prefixe}${key}`,this.__controller[`${this.cache.prefixe}${key}`]);
|
|
2432
|
-
this.cache.paused[`${this.cache.prefixe}${key}`]=false;
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
return this;
|
|
2436
|
-
}
|
|
2437
|
-
dispose(config={}){
|
|
2438
|
-
this.pause(config);
|
|
2439
|
-
return this;
|
|
2440
|
-
}
|
|
2441
|
-
stream(config={}){
|
|
2442
|
-
this.cache.stream.t0=Date.now();
|
|
2443
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]));
|
|
2444
|
-
config={...all,...config};
|
|
2445
|
-
Object.assign(this.cache.stream.enabled,config);
|
|
2446
|
-
return this;
|
|
2447
|
-
}
|
|
2448
|
-
clear(config={}){
|
|
2449
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.clear).map(n=>[n,true]));
|
|
2450
|
-
config={...all,...config};
|
|
2451
|
-
for(let key in config){
|
|
2452
|
-
if(config[key]){
|
|
2453
|
-
this.cache.stream.history[key]=[];
|
|
2454
|
-
}
|
|
2455
|
-
}
|
|
2456
|
-
return this;
|
|
2457
|
-
}
|
|
2458
|
-
}
|
|
2459
|
-
|
|
2460
|
-
const custom_event_controller=event_name=>function(e){
|
|
2461
|
-
EVENT_CONTROLLER.call(this,e,event_name,null,null);
|
|
2462
|
-
};
|
|
2463
|
-
class ZikoCustomEvent extends ZikoEvent{
|
|
2464
|
-
constructor(target){
|
|
2465
|
-
super(target);
|
|
2466
|
-
this.event=null;
|
|
2467
|
-
this.cache={
|
|
2468
|
-
prefixe:"",
|
|
2469
|
-
preventDefault:{
|
|
2470
|
-
},
|
|
2471
|
-
paused:{
|
|
2472
|
-
},
|
|
2473
|
-
stream:{
|
|
2474
|
-
enabled:{
|
|
2475
|
-
},
|
|
2476
|
-
clear:{
|
|
2477
|
-
},
|
|
2478
|
-
history:{
|
|
2479
|
-
}
|
|
2480
|
-
},
|
|
2481
|
-
callbacks:{
|
|
2482
|
-
}
|
|
2483
|
-
};
|
|
2484
|
-
this.__controller={
|
|
2485
|
-
};
|
|
2486
|
-
}
|
|
2487
|
-
#init(event_name){
|
|
2488
|
-
this.cache.preventDefault[event_name]=false;
|
|
2489
|
-
this.cache.paused[event_name]=false;
|
|
2490
|
-
this.cache.stream.enabled=false;
|
|
2491
|
-
this.cache.stream.clear=false;
|
|
2492
|
-
this.cache.stream.history=[];
|
|
2493
|
-
this.cache.callbacks[event_name]=[];
|
|
2494
|
-
this.__controller[event_name]=custom_event_controller(event_name).bind(this);
|
|
2495
|
-
return this;
|
|
2496
|
-
}
|
|
2497
|
-
on(event_name,...callbacks){
|
|
2498
|
-
if(!(this.__controller[event_name]))this.#init(event_name);
|
|
2499
|
-
this.__onEvent(event_name,{},...callbacks);
|
|
2500
|
-
return this;
|
|
2501
|
-
}
|
|
2502
|
-
emit(event_name,detail={}){
|
|
2503
|
-
if(!(this.__controller[event_name]))this.#init(event_name);
|
|
2504
|
-
this.detail=detail;
|
|
2505
|
-
const event=new Event(event_name);
|
|
2506
|
-
this.targetElement.dispatchEvent(event);
|
|
2507
|
-
return this;
|
|
2230
|
+
}
|
|
2231
|
+
else Object.assign(this.element.style, {[key] : value});
|
|
2508
2232
|
}
|
|
2233
|
+
return this;
|
|
2234
|
+
}
|
|
2235
|
+
function size(width, height){
|
|
2236
|
+
return this.style({width, height})
|
|
2237
|
+
}
|
|
2238
|
+
function hide(){
|
|
2239
|
+
|
|
2240
|
+
}
|
|
2241
|
+
function show(){
|
|
2242
|
+
|
|
2509
2243
|
}
|
|
2510
|
-
|
|
2244
|
+
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2245
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2246
|
+
return this;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2250
|
+
__proto__: null,
|
|
2251
|
+
animate: animate,
|
|
2252
|
+
hide: hide,
|
|
2253
|
+
show: show,
|
|
2254
|
+
size: size,
|
|
2255
|
+
style: style
|
|
2256
|
+
});
|
|
2511
2257
|
|
|
2512
2258
|
let UIElement$1 = class UIElement extends UIElementCore{
|
|
2513
2259
|
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
@@ -2522,6 +2268,8 @@ let UIElement$1 = class UIElement extends UIElementCore{
|
|
|
2522
2268
|
IndexingMethods,
|
|
2523
2269
|
EventsMethodes
|
|
2524
2270
|
);
|
|
2271
|
+
|
|
2272
|
+
// console.log(EventsMethodes)
|
|
2525
2273
|
if(element)this.init(element, name, type, render);
|
|
2526
2274
|
}
|
|
2527
2275
|
get element(){
|
|
@@ -2659,16 +2407,16 @@ let UIElement$1 = class UIElement extends UIElementCore{
|
|
|
2659
2407
|
// this.events.clipboard.onSelect(...callbacks);
|
|
2660
2408
|
// return this;
|
|
2661
2409
|
// }
|
|
2662
|
-
on(event_name,...callbacks){
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
}
|
|
2667
|
-
emit(event_name,detail={}){
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
}
|
|
2410
|
+
// on(event_name,...callbacks){
|
|
2411
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
2412
|
+
// this.events.custom.on(event_name,...callbacks);
|
|
2413
|
+
// return this;
|
|
2414
|
+
// }
|
|
2415
|
+
// emit(event_name,detail={}){
|
|
2416
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
2417
|
+
// this.events.custom.emit(event_name,detail);
|
|
2418
|
+
// return this;
|
|
2419
|
+
// }
|
|
2672
2420
|
// watchAttr(callback){
|
|
2673
2421
|
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
2674
2422
|
// return this;
|
|
@@ -4802,212 +4550,7 @@ const timeTaken = callback => {
|
|
|
4802
4550
|
return r;
|
|
4803
4551
|
};
|
|
4804
4552
|
|
|
4805
|
-
|
|
4806
|
-
constructor(maxListeners = 10) {
|
|
4807
|
-
this.events = {};
|
|
4808
|
-
this.maxListeners = maxListeners;
|
|
4809
|
-
}
|
|
4810
|
-
|
|
4811
|
-
on(event, listener) {
|
|
4812
|
-
if (!this.events[event]) this.events[event] = [];
|
|
4813
|
-
this.events[event].push(listener);
|
|
4814
|
-
if (this.events[event].length > this.maxListeners) {
|
|
4815
|
-
console.warn(`Warning: Possible memory leak. Event '${event}' has more than ${this.maxListeners} listeners.`);
|
|
4816
|
-
}
|
|
4817
|
-
return this;
|
|
4818
|
-
}
|
|
4819
|
-
|
|
4820
|
-
once(event, listener) {
|
|
4821
|
-
const wrapper = (...args) => {
|
|
4822
|
-
this.off(event, wrapper);
|
|
4823
|
-
listener(...args);
|
|
4824
|
-
};
|
|
4825
|
-
return this.on(event, wrapper);
|
|
4826
|
-
}
|
|
4827
|
-
|
|
4828
|
-
off(event, listener) {
|
|
4829
|
-
const listeners = this.events[event];
|
|
4830
|
-
if (!listeners) return this;
|
|
4831
|
-
|
|
4832
|
-
const index = listeners.indexOf(listener);
|
|
4833
|
-
if (index !== -1) {
|
|
4834
|
-
listeners.splice(index, 1);
|
|
4835
|
-
}
|
|
4836
|
-
|
|
4837
|
-
return this;
|
|
4838
|
-
}
|
|
4839
|
-
|
|
4840
|
-
emit(event, data) {
|
|
4841
|
-
const listeners = this.events[event];
|
|
4842
|
-
if (!listeners) return false;
|
|
4843
|
-
|
|
4844
|
-
// Make a copy so removing listeners inside callbacks doesn't affect iteration
|
|
4845
|
-
[...listeners].forEach(listener => {
|
|
4846
|
-
try {
|
|
4847
|
-
listener(data);
|
|
4848
|
-
} catch (e) {
|
|
4849
|
-
console.error(`Error in listener for '${event}':`, e);
|
|
4850
|
-
}
|
|
4851
|
-
});
|
|
4852
|
-
|
|
4853
|
-
return true;
|
|
4854
|
-
}
|
|
4855
|
-
remove(event){
|
|
4856
|
-
delete this.events[event];
|
|
4857
|
-
return this;
|
|
4858
|
-
}
|
|
4859
|
-
clear() {
|
|
4860
|
-
this.events = {};
|
|
4861
|
-
return this;
|
|
4862
|
-
}
|
|
4863
|
-
|
|
4864
|
-
setMaxListeners(max) {
|
|
4865
|
-
this.maxListeners = max;
|
|
4866
|
-
return this;
|
|
4867
|
-
}
|
|
4868
|
-
}
|
|
4869
|
-
|
|
4870
|
-
const useEventEmitter = (maxListeners) => new UseEventEmitter(maxListeners);
|
|
4871
|
-
|
|
4872
|
-
class ZikoUseFavIcon{
|
|
4873
|
-
constructor(FavIcon,withEmitter=true){
|
|
4874
|
-
this.#init();
|
|
4875
|
-
this.cache={
|
|
4876
|
-
Emitter:null
|
|
4877
|
-
};
|
|
4878
|
-
if(withEmitter)this.useEventEmitter();
|
|
4879
|
-
this.set(FavIcon);
|
|
4880
|
-
}
|
|
4881
|
-
#init(){
|
|
4882
|
-
this.__FavIcon__ = document.querySelector("link[rel*='icon']") || document?.createElement('link');
|
|
4883
|
-
this.__FavIcon__.type = 'image/x-icon';
|
|
4884
|
-
this.__FavIcon__.rel = 'shortcut icon';
|
|
4885
|
-
return this;
|
|
4886
|
-
}
|
|
4887
|
-
set(href){
|
|
4888
|
-
if(href!==this.__FavIcon__.href){
|
|
4889
|
-
this.__FavIcon__.href=href;
|
|
4890
|
-
if(this.cache.Emitter)this.cache.Emitter.emit("ziko:favicon-changed");
|
|
4891
|
-
}
|
|
4892
|
-
return this;
|
|
4893
|
-
}
|
|
4894
|
-
get current(){
|
|
4895
|
-
return document.__FavIcon__.href;
|
|
4896
|
-
}
|
|
4897
|
-
onChange(callback){
|
|
4898
|
-
if(this.cache.Emitter)this.cache.Emitter.on("ziko:favicon-changed",callback);
|
|
4899
|
-
return this;
|
|
4900
|
-
}
|
|
4901
|
-
useEventEmitter(){
|
|
4902
|
-
this.cache.Emitter=useEventEmitter();
|
|
4903
|
-
return this;
|
|
4904
|
-
}
|
|
4905
|
-
|
|
4906
|
-
}
|
|
4907
|
-
const useFavIcon=(FavIcon,withEmitter)=>new ZikoUseFavIcon(FavIcon,withEmitter);
|
|
4908
|
-
|
|
4909
|
-
class ZikoMeta{
|
|
4910
|
-
constructor({viewport,charset,description,author,keywords}){
|
|
4911
|
-
this.document = globalThis?.document;
|
|
4912
|
-
this.meta={};
|
|
4913
|
-
this.init({viewport,charset,description,author,keywords});
|
|
4914
|
-
}
|
|
4915
|
-
init({viewport,charset,description,author,keywords}){
|
|
4916
|
-
viewport && this.setViewport(viewport);
|
|
4917
|
-
charset && this.setCharset(charset);
|
|
4918
|
-
description && this.describe(description);
|
|
4919
|
-
author && this.setAuthor(author);
|
|
4920
|
-
keywords && this.setKeywords(keywords);
|
|
4921
|
-
}
|
|
4922
|
-
set(key,value){
|
|
4923
|
-
key = key.toLowerCase();
|
|
4924
|
-
const isCharset = (key === "charset");
|
|
4925
|
-
const meta = isCharset ? document.querySelector("meta[charset]"):document.querySelector(`meta[name=${key}]`);
|
|
4926
|
-
this.meta=meta?? document?.createElement("meta");
|
|
4927
|
-
if(isCharset) this.meta.setAttribute("charset",value);
|
|
4928
|
-
else {
|
|
4929
|
-
this.meta.setAttribute("name",key);
|
|
4930
|
-
this.meta.setAttribute("content",value);
|
|
4931
|
-
}
|
|
4932
|
-
if(!meta)this.document.head.append(this.meta);
|
|
4933
|
-
return this;
|
|
4934
|
-
}
|
|
4935
|
-
setCharset(charset="utf-8"){
|
|
4936
|
-
this.set("charset",charset);
|
|
4937
|
-
return this;
|
|
4938
|
-
}
|
|
4939
|
-
describe(description){
|
|
4940
|
-
this.set("description",description);
|
|
4941
|
-
return this;
|
|
4942
|
-
}
|
|
4943
|
-
setViewport(viewport="width=device-width, initial-scale=1.0"){
|
|
4944
|
-
this.set("viewport",viewport);
|
|
4945
|
-
return this;
|
|
4946
|
-
}
|
|
4947
|
-
setKeywords(...keywords){
|
|
4948
|
-
// keywords.push("zikojs");
|
|
4949
|
-
keywords=[...new Set(keywords)].join(", ");
|
|
4950
|
-
this.set("keywords",keywords);
|
|
4951
|
-
return this;
|
|
4952
|
-
}
|
|
4953
|
-
setAuthor(author){
|
|
4954
|
-
this.set("author",author);
|
|
4955
|
-
return this;
|
|
4956
|
-
}
|
|
4957
|
-
}
|
|
4958
|
-
const useMeta=({viewport,charset,description,author,keywords})=>new ZikoMeta({viewport,charset,description,author,keywords});
|
|
4959
|
-
|
|
4960
|
-
class ZikoUseTitle{
|
|
4961
|
-
constructor(title=document.title,useEventEmitter=true){
|
|
4962
|
-
this.cache={
|
|
4963
|
-
Emitter:null
|
|
4964
|
-
};
|
|
4965
|
-
if(useEventEmitter)this.useEventEmitter();
|
|
4966
|
-
this.set(title);
|
|
4967
|
-
}
|
|
4968
|
-
useEventEmitter(){
|
|
4969
|
-
this.cache.Emitter=useEventEmitter();
|
|
4970
|
-
return this;
|
|
4971
|
-
}
|
|
4972
|
-
set(title){
|
|
4973
|
-
if(title!==document.title){
|
|
4974
|
-
document.title=title;
|
|
4975
|
-
if(this.cache.Emitter)this.cache.Emitter.emit("ziko:title-changed");
|
|
4976
|
-
}
|
|
4977
|
-
return this;
|
|
4978
|
-
}
|
|
4979
|
-
get current(){
|
|
4980
|
-
return document.title;
|
|
4981
|
-
}
|
|
4982
|
-
onChange(callback){
|
|
4983
|
-
if(this.cache.Emitter)this.cache.Emitter.on("ziko:title-changed",callback);
|
|
4984
|
-
return this;
|
|
4985
|
-
}
|
|
4986
|
-
}
|
|
4987
|
-
const useTitle$1=(title, useEventEmitter)=>new ZikoUseTitle(title, useEventEmitter);
|
|
4988
|
-
|
|
4989
|
-
// import {useLink} from "./";
|
|
4990
|
-
class ZikoHead{
|
|
4991
|
-
constructor({title,lang,icon,meta,noscript}){
|
|
4992
|
-
this.html = globalThis?.document?.documentElement;
|
|
4993
|
-
this.head = globalThis?.document?.head;
|
|
4994
|
-
|
|
4995
|
-
title && useTitle$1(title);
|
|
4996
|
-
lang && this.setLang(lang);
|
|
4997
|
-
icon && useFavIcon(icon);
|
|
4998
|
-
meta && useMeta(meta);
|
|
4999
|
-
noscript && this.setNoScript();
|
|
5000
|
-
}
|
|
5001
|
-
setLang(lang){
|
|
5002
|
-
this.html.setAttribute("lang",lang);
|
|
5003
|
-
}
|
|
5004
|
-
setNoScript(content){
|
|
5005
|
-
|
|
5006
|
-
}
|
|
5007
|
-
}
|
|
5008
|
-
|
|
5009
|
-
const useHead=({ title, lang, icon, meta, noscript })=>new ZikoHead({ title, lang, icon, meta, noscript });
|
|
5010
|
-
|
|
4553
|
+
// import { ZikoHead , useHead} from "../reactivity/hooks/head/index.js";
|
|
5011
4554
|
class ZikoApp {
|
|
5012
4555
|
constructor({head = null, wrapper = null, target = null}){
|
|
5013
4556
|
this.head = head;
|
|
@@ -5034,11 +4577,11 @@ class ZikoApp {
|
|
|
5034
4577
|
else if(typeof wrapper === "function") this.wrapper = wrapper();
|
|
5035
4578
|
return this;
|
|
5036
4579
|
}
|
|
5037
|
-
setHead(head){
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
}
|
|
4580
|
+
// setHead(head){
|
|
4581
|
+
// if(head instanceof ZikoHead) this.head = head;
|
|
4582
|
+
// else this.head = useHead(head);
|
|
4583
|
+
// return this;
|
|
4584
|
+
// }
|
|
5042
4585
|
|
|
5043
4586
|
}
|
|
5044
4587
|
const App = ({head, wrapper, target}) => new ZikoApp({head, wrapper, target});
|
|
@@ -5308,7 +4851,76 @@ class UseThread {
|
|
|
5308
4851
|
terminate() {
|
|
5309
4852
|
this.#worker.terminate();
|
|
5310
4853
|
}
|
|
5311
|
-
}
|
|
4854
|
+
}
|
|
4855
|
+
|
|
4856
|
+
const useThread = (func, callback, args = [], close = true) => new UseThread().call(func, callback, args, close);
|
|
4857
|
+
|
|
4858
|
+
class UseEventEmitter {
|
|
4859
|
+
constructor(maxListeners = 10) {
|
|
4860
|
+
this.events = {};
|
|
4861
|
+
this.maxListeners = maxListeners;
|
|
4862
|
+
}
|
|
4863
|
+
|
|
4864
|
+
on(event, listener) {
|
|
4865
|
+
if (!this.events[event]) this.events[event] = [];
|
|
4866
|
+
this.events[event].push(listener);
|
|
4867
|
+
if (this.events[event].length > this.maxListeners) {
|
|
4868
|
+
console.warn(`Warning: Possible memory leak. Event '${event}' has more than ${this.maxListeners} listeners.`);
|
|
4869
|
+
}
|
|
4870
|
+
return this;
|
|
4871
|
+
}
|
|
4872
|
+
|
|
4873
|
+
once(event, listener) {
|
|
4874
|
+
const wrapper = (...args) => {
|
|
4875
|
+
this.off(event, wrapper);
|
|
4876
|
+
listener(...args);
|
|
4877
|
+
};
|
|
4878
|
+
return this.on(event, wrapper);
|
|
4879
|
+
}
|
|
4880
|
+
|
|
4881
|
+
off(event, listener) {
|
|
4882
|
+
const listeners = this.events[event];
|
|
4883
|
+
if (!listeners) return this;
|
|
4884
|
+
|
|
4885
|
+
const index = listeners.indexOf(listener);
|
|
4886
|
+
if (index !== -1) {
|
|
4887
|
+
listeners.splice(index, 1);
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
return this;
|
|
4891
|
+
}
|
|
4892
|
+
|
|
4893
|
+
emit(event, data) {
|
|
4894
|
+
const listeners = this.events[event];
|
|
4895
|
+
if (!listeners) return false;
|
|
4896
|
+
|
|
4897
|
+
// Make a copy so removing listeners inside callbacks doesn't affect iteration
|
|
4898
|
+
[...listeners].forEach(listener => {
|
|
4899
|
+
try {
|
|
4900
|
+
listener(data);
|
|
4901
|
+
} catch (e) {
|
|
4902
|
+
console.error(`Error in listener for '${event}':`, e);
|
|
4903
|
+
}
|
|
4904
|
+
});
|
|
4905
|
+
|
|
4906
|
+
return true;
|
|
4907
|
+
}
|
|
4908
|
+
remove(event){
|
|
4909
|
+
delete this.events[event];
|
|
4910
|
+
return this;
|
|
4911
|
+
}
|
|
4912
|
+
clear() {
|
|
4913
|
+
this.events = {};
|
|
4914
|
+
return this;
|
|
4915
|
+
}
|
|
4916
|
+
|
|
4917
|
+
setMaxListeners(max) {
|
|
4918
|
+
this.maxListeners = max;
|
|
4919
|
+
return this;
|
|
4920
|
+
}
|
|
4921
|
+
}
|
|
4922
|
+
|
|
4923
|
+
const useEventEmitter = (maxListeners) => new UseEventEmitter(maxListeners);
|
|
5312
4924
|
|
|
5313
4925
|
/*
|
|
5314
4926
|
[
|
|
@@ -5408,6 +5020,75 @@ class UseTitle {
|
|
|
5408
5020
|
|
|
5409
5021
|
const useTitle = (title, withEmitter = true) => new UseTitle(title, withEmitter);
|
|
5410
5022
|
|
|
5023
|
+
class UseRoot {
|
|
5024
|
+
constructor(PropsMap, { namespace = 'Ziko', ValidateCssProps = false } = {}) {
|
|
5025
|
+
this.currentPropsMap = PropsMap;
|
|
5026
|
+
this.namespace = namespace;
|
|
5027
|
+
this.ValidateCssProps = ValidateCssProps;
|
|
5028
|
+
this.use(PropsMap);
|
|
5029
|
+
}
|
|
5030
|
+
|
|
5031
|
+
use(PropsMap) {
|
|
5032
|
+
if (this.ValidateCssProps) ValidateCssPropsFn(PropsMap);
|
|
5033
|
+
this.currentPropsMap = PropsMap;
|
|
5034
|
+
this.#maintain();
|
|
5035
|
+
return this;
|
|
5036
|
+
}
|
|
5037
|
+
|
|
5038
|
+
#maintain() {
|
|
5039
|
+
const root = globalThis?.document?.documentElement?.style;
|
|
5040
|
+
for (const prop in this.currentPropsMap) {
|
|
5041
|
+
const cssProp = this.namespace ? `--${this.namespace}-${prop}` : `--${prop}`;
|
|
5042
|
+
root.setProperty(cssProp, this.currentPropsMap[prop]);
|
|
5043
|
+
|
|
5044
|
+
Object.defineProperty(this, prop, {
|
|
5045
|
+
value: `var(${cssProp})`,
|
|
5046
|
+
writable: true,
|
|
5047
|
+
configurable: true,
|
|
5048
|
+
enumerable: false
|
|
5049
|
+
});
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
|
|
5054
|
+
function ValidateCssPropsFn(PropsMap) {
|
|
5055
|
+
const validProps = new Set(Object.keys(document.documentElement.style));
|
|
5056
|
+
for (const key in PropsMap) {
|
|
5057
|
+
if (!validProps.has(key)) {
|
|
5058
|
+
throw new Error(`Invalid CSS property: "${key}"`);
|
|
5059
|
+
}
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5062
|
+
|
|
5063
|
+
const useRoot = (PropsMap, options = {}) => new UseRoot(PropsMap, options);
|
|
5064
|
+
|
|
5065
|
+
|
|
5066
|
+
// Usage
|
|
5067
|
+
|
|
5068
|
+
/*
|
|
5069
|
+
const Styles = {
|
|
5070
|
+
S1 : {
|
|
5071
|
+
background : 'white',
|
|
5072
|
+
color : 'darkblue'
|
|
5073
|
+
border : '2px darkblue solid"'
|
|
5074
|
+
},
|
|
5075
|
+
S2 : {
|
|
5076
|
+
background : 'darkblue',
|
|
5077
|
+
color : 'white'
|
|
5078
|
+
border : '2px green solid"'
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
const {use, border, background, color} = useRoot(Style.S1)
|
|
5082
|
+
|
|
5083
|
+
tags.p("Test useRoot ").style({
|
|
5084
|
+
border,
|
|
5085
|
+
color,
|
|
5086
|
+
background,
|
|
5087
|
+
padding : '10px'
|
|
5088
|
+
})
|
|
5089
|
+
|
|
5090
|
+
*/
|
|
5091
|
+
|
|
5411
5092
|
let {sqrt, cos, sin, exp, log, cosh, sinh} = Math;
|
|
5412
5093
|
// Math.abs = new Proxy(Math.abs, {
|
|
5413
5094
|
// apply(target, thisArg, args) {
|
|
@@ -5471,4 +5152,4 @@ if(globalThis?.document){
|
|
|
5471
5152
|
document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
|
|
5472
5153
|
}
|
|
5473
5154
|
|
|
5474
|
-
export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseThread, Utils, View, ZikoApp,
|
|
5155
|
+
export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, Utils, View, ZikoApp, ZikoEvent, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_touch_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, e, elastic, fact, floor, geomspace, getEvent, hypot, inRange, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, zeros };
|