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.js
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
|
|
@@ -1078,35 +1078,6 @@
|
|
|
1078
1078
|
|
|
1079
1079
|
// globalThis.node = (node) => new UINode(node);
|
|
1080
1080
|
|
|
1081
|
-
function parseQueryParams$1(queryString) {
|
|
1082
|
-
const params = {};
|
|
1083
|
-
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
1084
|
-
const [key, value] = match.split('=');
|
|
1085
|
-
params[key] = value;
|
|
1086
|
-
});
|
|
1087
|
-
return params;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
function defineParamsGetter$1(target ){
|
|
1091
|
-
Object.defineProperties(target, {
|
|
1092
|
-
'QueryParams': {
|
|
1093
|
-
get: function() {
|
|
1094
|
-
return parseQueryParams$1(globalThis.location.search.substring(1));
|
|
1095
|
-
},
|
|
1096
|
-
configurable: false,
|
|
1097
|
-
enumerable: true
|
|
1098
|
-
},
|
|
1099
|
-
'HashParams': {
|
|
1100
|
-
get: function() {
|
|
1101
|
-
const hash = globalThis.location.hash.substring(1);
|
|
1102
|
-
return hash.split("#");
|
|
1103
|
-
},
|
|
1104
|
-
configurable: false,
|
|
1105
|
-
enumerable: true
|
|
1106
|
-
}
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
1081
|
class UIStore extends Array {
|
|
1111
1082
|
constructor(...args) {
|
|
1112
1083
|
super(...args);
|
|
@@ -1140,6 +1111,141 @@
|
|
|
1140
1111
|
// create the singleton
|
|
1141
1112
|
const __UI__ = new UIStore();
|
|
1142
1113
|
|
|
1114
|
+
// __init__global__()
|
|
1115
|
+
class UIElementCore extends UINode{
|
|
1116
|
+
constructor(){
|
|
1117
|
+
super();
|
|
1118
|
+
}
|
|
1119
|
+
init(element, name, type, render){
|
|
1120
|
+
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1121
|
+
if(typeof element === "string") {
|
|
1122
|
+
switch(type){
|
|
1123
|
+
case "html" : {
|
|
1124
|
+
element = globalThis?.document?.createElement(element);
|
|
1125
|
+
// console.log('1')
|
|
1126
|
+
} break;
|
|
1127
|
+
case "svg" : {
|
|
1128
|
+
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1129
|
+
// console.log('2')
|
|
1130
|
+
} break;
|
|
1131
|
+
default : throw Error("Not supported")
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
else this.target = element?.parentElement;
|
|
1135
|
+
Object.assign(this.cache, {
|
|
1136
|
+
name,
|
|
1137
|
+
isInteractive : false,
|
|
1138
|
+
parent:null,
|
|
1139
|
+
isBody:false,
|
|
1140
|
+
isRoot:false,
|
|
1141
|
+
isHidden: false,
|
|
1142
|
+
isFrozzen:false,
|
|
1143
|
+
legacyParent : null,
|
|
1144
|
+
attributes: {},
|
|
1145
|
+
filters: {},
|
|
1146
|
+
temp:{}
|
|
1147
|
+
});
|
|
1148
|
+
this.events = {
|
|
1149
|
+
ptr:null,
|
|
1150
|
+
mouse:null,
|
|
1151
|
+
wheel:null,
|
|
1152
|
+
key:null,
|
|
1153
|
+
drag:null,
|
|
1154
|
+
drop:null,
|
|
1155
|
+
click:null,
|
|
1156
|
+
clipboard:null,
|
|
1157
|
+
focus:null,
|
|
1158
|
+
swipe:null,
|
|
1159
|
+
custom:null,
|
|
1160
|
+
};
|
|
1161
|
+
this.observer={
|
|
1162
|
+
resize:null,
|
|
1163
|
+
intersection:null
|
|
1164
|
+
};
|
|
1165
|
+
if(element) Object.assign(this.cache,{element});
|
|
1166
|
+
// useDefaultStyle && this.style({
|
|
1167
|
+
// position: "relative",
|
|
1168
|
+
// boxSizing:"border-box",
|
|
1169
|
+
// margin:0,
|
|
1170
|
+
// padding:0,
|
|
1171
|
+
// width : "auto",
|
|
1172
|
+
// height : "auto"
|
|
1173
|
+
// });
|
|
1174
|
+
this.items = new UIStore();
|
|
1175
|
+
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1176
|
+
element && render && this?.render?.();
|
|
1177
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
1178
|
+
}
|
|
1179
|
+
get element(){
|
|
1180
|
+
return this.cache.element;
|
|
1181
|
+
}
|
|
1182
|
+
[Symbol.iterator]() {
|
|
1183
|
+
return this.items[Symbol.iterator]();
|
|
1184
|
+
}
|
|
1185
|
+
maintain() {
|
|
1186
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1187
|
+
Object.defineProperty(this, i, {
|
|
1188
|
+
value: this.items[i],
|
|
1189
|
+
writable: true,
|
|
1190
|
+
configurable: true,
|
|
1191
|
+
enumerable: false
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
isInteractive(){
|
|
1196
|
+
return this.cache.isInteractive;
|
|
1197
|
+
}
|
|
1198
|
+
isUIElement(){
|
|
1199
|
+
return true;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
function register_to_class(target, ...mixins){
|
|
1204
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1205
|
+
}
|
|
1206
|
+
function _register_to_class_(target, mixin) {
|
|
1207
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1208
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1209
|
+
const desc = descriptors[key];
|
|
1210
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1211
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1212
|
+
} else if (typeof desc.value === 'function') {
|
|
1213
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1214
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
function parseQueryParams$1(queryString) {
|
|
1221
|
+
const params = {};
|
|
1222
|
+
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
1223
|
+
const [key, value] = match.split('=');
|
|
1224
|
+
params[key] = value;
|
|
1225
|
+
});
|
|
1226
|
+
return params;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
function defineParamsGetter$1(target ){
|
|
1230
|
+
Object.defineProperties(target, {
|
|
1231
|
+
'QueryParams': {
|
|
1232
|
+
get: function() {
|
|
1233
|
+
return parseQueryParams$1(globalThis.location.search.substring(1));
|
|
1234
|
+
},
|
|
1235
|
+
configurable: false,
|
|
1236
|
+
enumerable: true
|
|
1237
|
+
},
|
|
1238
|
+
'HashParams': {
|
|
1239
|
+
get: function() {
|
|
1240
|
+
const hash = globalThis.location.hash.substring(1);
|
|
1241
|
+
return hash.split("#");
|
|
1242
|
+
},
|
|
1243
|
+
configurable: false,
|
|
1244
|
+
enumerable: true
|
|
1245
|
+
}
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1143
1249
|
const __Config__ = {
|
|
1144
1250
|
default:{
|
|
1145
1251
|
target:null,
|
|
@@ -1183,7 +1289,7 @@
|
|
|
1183
1289
|
}
|
|
1184
1290
|
};
|
|
1185
1291
|
|
|
1186
|
-
class
|
|
1292
|
+
class UseIPC {
|
|
1187
1293
|
#channel;
|
|
1188
1294
|
#eventData;
|
|
1189
1295
|
#handlers;
|
|
@@ -1264,14 +1370,14 @@
|
|
|
1264
1370
|
}
|
|
1265
1371
|
}
|
|
1266
1372
|
|
|
1267
|
-
const
|
|
1373
|
+
const useIPC = (name) => new UseIPC(name);
|
|
1268
1374
|
|
|
1269
1375
|
class UseStorage {
|
|
1270
1376
|
constructor(storage, globalKey, initialValue, use_channel = true) {
|
|
1271
1377
|
this.cache = {
|
|
1272
1378
|
storage,
|
|
1273
1379
|
globalKey,
|
|
1274
|
-
channel: use_channel ?
|
|
1380
|
+
channel: use_channel ? useIPC(`Ziko:useStorage-${globalKey}`) : null,
|
|
1275
1381
|
oldItemKeys: new Set()
|
|
1276
1382
|
};
|
|
1277
1383
|
|
|
@@ -1354,283 +1460,43 @@
|
|
|
1354
1460
|
|
|
1355
1461
|
// factory functions
|
|
1356
1462
|
const useLocaleStorage = (key, initialValue, use_channel = true) =>
|
|
1357
|
-
new UseStorage(localStorage, key, initialValue, use_channel);
|
|
1358
|
-
|
|
1359
|
-
const useSessionStorage = (key, initialValue, use_channel = true) =>
|
|
1360
|
-
new UseStorage(sessionStorage, key, initialValue, use_channel);
|
|
1361
|
-
|
|
1362
|
-
const __State__ = {
|
|
1363
|
-
store : new Map(),
|
|
1364
|
-
index : 0,
|
|
1365
|
-
session_storage : null,
|
|
1366
|
-
register: function(state){
|
|
1367
|
-
if(!undefined.SSR && undefined.DEV){
|
|
1368
|
-
if(!this.session) this.session_storage = useSessionStorage('ziko-state', {});
|
|
1369
|
-
const savedValue = this.session_storage.get(this.index);
|
|
1370
|
-
if(!savedValue) this.session_storage.add({[this.index] : state.value});
|
|
1371
|
-
else state.value = savedValue;
|
|
1372
|
-
}
|
|
1373
|
-
this.store.set(this.index++, state);
|
|
1374
|
-
},
|
|
1375
|
-
update: function(index, value){
|
|
1376
|
-
if(!undefined.SSR && undefined.DEV){
|
|
1377
|
-
this.session_storage.add({[index] : value});
|
|
1378
|
-
}
|
|
1379
|
-
},
|
|
1380
|
-
|
|
1381
|
-
};
|
|
1382
|
-
|
|
1383
|
-
function __init__global__(){
|
|
1384
|
-
if ( !globalThis?.__Ziko__ ){
|
|
1385
|
-
globalThis.__Ziko__ = {
|
|
1386
|
-
__UI__,
|
|
1387
|
-
__HYDRATION__,
|
|
1388
|
-
__State__,
|
|
1389
|
-
__Config__,
|
|
1390
|
-
__CACHE__,
|
|
1391
|
-
};
|
|
1392
|
-
defineParamsGetter$1(__Ziko__);
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
__init__global__();
|
|
1397
|
-
class UIElementCore extends UINode{
|
|
1398
|
-
constructor(){
|
|
1399
|
-
super();
|
|
1400
|
-
}
|
|
1401
|
-
init(element, name, type, render){
|
|
1402
|
-
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1403
|
-
if(typeof element === "string") {
|
|
1404
|
-
switch(type){
|
|
1405
|
-
case "html" : {
|
|
1406
|
-
element = globalThis?.document?.createElement(element);
|
|
1407
|
-
// console.log('1')
|
|
1408
|
-
} break;
|
|
1409
|
-
case "svg" : {
|
|
1410
|
-
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1411
|
-
// console.log('2')
|
|
1412
|
-
} break;
|
|
1413
|
-
default : throw Error("Not supported")
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
else this.target = element?.parentElement;
|
|
1417
|
-
Object.assign(this.cache, {
|
|
1418
|
-
name,
|
|
1419
|
-
isInteractive : false,
|
|
1420
|
-
parent:null,
|
|
1421
|
-
isBody:false,
|
|
1422
|
-
isRoot:false,
|
|
1423
|
-
isHidden: false,
|
|
1424
|
-
isFrozzen:false,
|
|
1425
|
-
legacyParent : null,
|
|
1426
|
-
attributes: {},
|
|
1427
|
-
filters: {},
|
|
1428
|
-
temp:{}
|
|
1429
|
-
});
|
|
1430
|
-
this.events = {
|
|
1431
|
-
ptr:null,
|
|
1432
|
-
mouse:null,
|
|
1433
|
-
wheel:null,
|
|
1434
|
-
key:null,
|
|
1435
|
-
drag:null,
|
|
1436
|
-
drop:null,
|
|
1437
|
-
click:null,
|
|
1438
|
-
clipboard:null,
|
|
1439
|
-
focus:null,
|
|
1440
|
-
swipe:null,
|
|
1441
|
-
custom:null,
|
|
1442
|
-
};
|
|
1443
|
-
this.observer={
|
|
1444
|
-
resize:null,
|
|
1445
|
-
intersection:null
|
|
1446
|
-
};
|
|
1447
|
-
if(element) Object.assign(this.cache,{element});
|
|
1448
|
-
// useDefaultStyle && this.style({
|
|
1449
|
-
// position: "relative",
|
|
1450
|
-
// boxSizing:"border-box",
|
|
1451
|
-
// margin:0,
|
|
1452
|
-
// padding:0,
|
|
1453
|
-
// width : "auto",
|
|
1454
|
-
// height : "auto"
|
|
1455
|
-
// });
|
|
1456
|
-
this.items = new UIStore();
|
|
1457
|
-
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1458
|
-
element && render && this?.render?.();
|
|
1459
|
-
globalThis.__Ziko__.__UI__.push(this);
|
|
1460
|
-
}
|
|
1461
|
-
get element(){
|
|
1462
|
-
return this.cache.element;
|
|
1463
|
-
}
|
|
1464
|
-
[Symbol.iterator]() {
|
|
1465
|
-
return this.items[Symbol.iterator]();
|
|
1466
|
-
}
|
|
1467
|
-
maintain() {
|
|
1468
|
-
for (let i = 0; i < this.items.length; i++) {
|
|
1469
|
-
Object.defineProperty(this, i, {
|
|
1470
|
-
value: this.items[i],
|
|
1471
|
-
writable: true,
|
|
1472
|
-
configurable: true,
|
|
1473
|
-
enumerable: false
|
|
1474
|
-
});
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
isInteractive(){
|
|
1478
|
-
return this.cache.isInteractive;
|
|
1479
|
-
}
|
|
1480
|
-
isUIElement(){
|
|
1481
|
-
return true;
|
|
1482
|
-
}
|
|
1483
|
-
// get st(){
|
|
1484
|
-
// return this.cache.style;
|
|
1485
|
-
// }
|
|
1486
|
-
// get attr(){
|
|
1487
|
-
// return this.cache.attributes;
|
|
1488
|
-
// }
|
|
1489
|
-
// get evt(){
|
|
1490
|
-
// return this.events;
|
|
1491
|
-
// }
|
|
1492
|
-
// get html(){
|
|
1493
|
-
// return this.element.innerHTML;
|
|
1494
|
-
// }
|
|
1495
|
-
// get text(){
|
|
1496
|
-
// return this.element.textContent;
|
|
1497
|
-
// }
|
|
1498
|
-
// get isBody(){
|
|
1499
|
-
// return this.element === globalThis?.document.body;
|
|
1500
|
-
// }
|
|
1501
|
-
// get parent(){
|
|
1502
|
-
// return this.cache.parent;
|
|
1503
|
-
// }
|
|
1504
|
-
// get width(){
|
|
1505
|
-
// return this.element.getBoundingClientRect().width;
|
|
1506
|
-
// }
|
|
1507
|
-
// get height(){
|
|
1508
|
-
// return this.element.getBoundingClientRect().height;
|
|
1509
|
-
// }
|
|
1510
|
-
// get top(){
|
|
1511
|
-
// return this.element.getBoundingClientRect().top;
|
|
1512
|
-
// }
|
|
1513
|
-
// get right(){
|
|
1514
|
-
// return this.element.getBoundingClientRect().right;
|
|
1515
|
-
// }
|
|
1516
|
-
// get bottom(){
|
|
1517
|
-
// return this.element.getBoundingClientRect().bottom;
|
|
1518
|
-
// }
|
|
1519
|
-
// get left(){
|
|
1520
|
-
// return this.element.getBoundingClientRect().left;
|
|
1521
|
-
// }
|
|
1522
|
-
// clone(render=false) {
|
|
1523
|
-
// // UI.__proto__=this.__proto__;
|
|
1524
|
-
// // if(this.items.length){
|
|
1525
|
-
// // const items = [...this.items].map(n=>n.clone());
|
|
1526
|
-
// // UI.append(...items);
|
|
1527
|
-
// // }
|
|
1528
|
-
// // else UI.element=this.element.cloneNode(true);
|
|
1529
|
-
// // return UI.mount(render);
|
|
1530
|
-
// }
|
|
1531
|
-
|
|
1532
|
-
// freeze(freeze){
|
|
1533
|
-
// this.cache.isFrozzen=freeze;
|
|
1534
|
-
// return this;
|
|
1535
|
-
// }
|
|
1536
|
-
// setTarget(tg) {
|
|
1537
|
-
// if(this.isBody) return ;
|
|
1538
|
-
// if (tg?.isUIElement) tg = tg.element;
|
|
1539
|
-
// this.unmount();
|
|
1540
|
-
// this.target = tg;
|
|
1541
|
-
// this.mount();
|
|
1542
|
-
// return this;
|
|
1543
|
-
// }
|
|
1544
|
-
// describe(label){
|
|
1545
|
-
// if(label)this.setAttr("aria-label",label)
|
|
1546
|
-
// }
|
|
1547
|
-
// get children() {
|
|
1548
|
-
// return [...this.element.children];
|
|
1549
|
-
// }
|
|
1550
|
-
// get cloneElement() {
|
|
1551
|
-
// return this.element.cloneNode(true);
|
|
1552
|
-
// }
|
|
1553
|
-
// setClasses(...value) {
|
|
1554
|
-
// this.setAttr("class", value.join(" "));
|
|
1555
|
-
// return this;
|
|
1556
|
-
// }
|
|
1557
|
-
// get classes(){
|
|
1558
|
-
// const classes=this.element.getAttribute("class");
|
|
1559
|
-
// return classes===null?[]:classes.split(" ");
|
|
1560
|
-
// }
|
|
1561
|
-
// addClass() {
|
|
1562
|
-
// /*this.setAttr("class", value);
|
|
1563
|
-
// return this;*/
|
|
1564
|
-
// }
|
|
1565
|
-
// setId(id) {
|
|
1566
|
-
// this.setAttr("id", id);
|
|
1567
|
-
// return this;
|
|
1568
|
-
// }
|
|
1569
|
-
// get id() {
|
|
1570
|
-
// return this.element.getAttribute("id");
|
|
1571
|
-
// }
|
|
1572
|
-
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
1573
|
-
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
1574
|
-
// this.events.swipe.onSwipe(...callbacks);
|
|
1575
|
-
// return this;
|
|
1576
|
-
// }
|
|
1577
|
-
// To Fix
|
|
1578
|
-
// onKeysDown({keys=[],callback}={}){
|
|
1579
|
-
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
1580
|
-
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
1581
|
-
// return this;
|
|
1582
|
-
// }
|
|
1583
|
-
// onSelect(...callbacks){
|
|
1584
|
-
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
1585
|
-
// this.events.clipboard.onSelect(...callbacks);
|
|
1586
|
-
// return this;
|
|
1587
|
-
// }
|
|
1588
|
-
// on(event_name,...callbacks){
|
|
1589
|
-
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1590
|
-
// this.events.custom.on(event_name,...callbacks);
|
|
1591
|
-
// return this;
|
|
1592
|
-
// }
|
|
1593
|
-
// emit(event_name,detail={}){
|
|
1594
|
-
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1595
|
-
// this.events.custom.emit(event_name,detail);
|
|
1596
|
-
// return this;
|
|
1597
|
-
// }
|
|
1598
|
-
// watchAttr(callback){
|
|
1599
|
-
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
1600
|
-
// return this;
|
|
1601
|
-
// }
|
|
1602
|
-
// watchChildren(callback){
|
|
1603
|
-
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
1604
|
-
// return this;
|
|
1605
|
-
// }
|
|
1606
|
-
// watchSize(callback){
|
|
1607
|
-
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
1608
|
-
// this.observer.resize.start();
|
|
1609
|
-
// return this;
|
|
1610
|
-
// }
|
|
1611
|
-
// watchIntersection(callback,config){
|
|
1612
|
-
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
1613
|
-
// this.observer.intersection.start();
|
|
1614
|
-
// return this;
|
|
1615
|
-
// }
|
|
1463
|
+
new UseStorage(localStorage, key, initialValue, use_channel);
|
|
1616
1464
|
|
|
1617
|
-
|
|
1465
|
+
const useSessionStorage = (key, initialValue, use_channel = true) =>
|
|
1466
|
+
new UseStorage(sessionStorage, key, initialValue, use_channel);
|
|
1618
1467
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1468
|
+
var __State__ = {
|
|
1469
|
+
store : new Map(),
|
|
1470
|
+
index : 0,
|
|
1471
|
+
session_storage : null,
|
|
1472
|
+
register: function(state){
|
|
1473
|
+
if(!undefined.SSR && undefined.DEV){
|
|
1474
|
+
if(!this.session) this.session_storage = useSessionStorage('ziko-state', {});
|
|
1475
|
+
const savedValue = this.session_storage.get(this.index);
|
|
1476
|
+
if(!savedValue) this.session_storage.add({[this.index] : state.value});
|
|
1477
|
+
else state.value = savedValue;
|
|
1478
|
+
}
|
|
1479
|
+
this.store.set(this.index++, state);
|
|
1480
|
+
},
|
|
1481
|
+
update: function(index, value){
|
|
1482
|
+
if(!undefined.SSR && undefined.DEV){
|
|
1483
|
+
this.session_storage.add({[index] : value});
|
|
1484
|
+
}
|
|
1485
|
+
},
|
|
1486
|
+
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
function __init__global__(){
|
|
1490
|
+
if ( !globalThis?.__Ziko__ ){
|
|
1491
|
+
globalThis.__Ziko__ = {
|
|
1492
|
+
__UI__,
|
|
1493
|
+
__HYDRATION__,
|
|
1494
|
+
__State__,
|
|
1495
|
+
__Config__,
|
|
1496
|
+
__CACHE__,
|
|
1497
|
+
};
|
|
1498
|
+
defineParamsGetter$1(__Ziko__);
|
|
1632
1499
|
}
|
|
1633
|
-
}
|
|
1634
1500
|
}
|
|
1635
1501
|
|
|
1636
1502
|
if(!globalThis.__Ziko__) __init__global__();
|
|
@@ -1893,7 +1759,11 @@
|
|
|
1893
1759
|
unrenderAfter: unrenderAfter
|
|
1894
1760
|
});
|
|
1895
1761
|
|
|
1896
|
-
const
|
|
1762
|
+
const EventsMap = {
|
|
1763
|
+
'Custom' : [
|
|
1764
|
+
'emit',
|
|
1765
|
+
'on'
|
|
1766
|
+
],
|
|
1897
1767
|
'Click' : [
|
|
1898
1768
|
'Click',
|
|
1899
1769
|
'DblClick',
|
|
@@ -1953,21 +1823,7 @@
|
|
|
1953
1823
|
return event.toLowerCase()
|
|
1954
1824
|
};
|
|
1955
1825
|
|
|
1956
|
-
|
|
1957
|
-
this.cache.currentEvent = event_name;
|
|
1958
|
-
this.cache.event = e;
|
|
1959
|
-
details_setter?.call(this);
|
|
1960
|
-
customizer?.hasOwnProperty("prototype") ? customizer?.call(this) : customizer?.call(null, this);
|
|
1961
|
-
// if(customizer?.hasOwnProperty("prototype")) customizer?.call(this)
|
|
1962
|
-
// else customizer?.call(null, this)
|
|
1963
|
-
if(this.cache.preventDefault[event_name]) e.preventDefault();
|
|
1964
|
-
if(this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
1965
|
-
if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
1966
|
-
|
|
1967
|
-
if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
|
|
1968
|
-
this.cache.callbacks[event_name]?.map(n=>n(this));
|
|
1969
|
-
}
|
|
1970
|
-
class __ZikoEvent__ {
|
|
1826
|
+
class ZikoEvent {
|
|
1971
1827
|
constructor(target = null, Events = [], details_setter, customizer){
|
|
1972
1828
|
this.target = target;
|
|
1973
1829
|
this.cache = {
|
|
@@ -2111,92 +1967,24 @@
|
|
|
2111
1967
|
|
|
2112
1968
|
return this;
|
|
2113
1969
|
}
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
// import { register_click_away_event } from "./custom-events/click-away.js";
|
|
2117
|
-
class ZikoEventClick extends __ZikoEvent__{
|
|
2118
|
-
constructor(target, customizer){
|
|
2119
|
-
super(target, Events.Click, details_setter$a, customizer);
|
|
2120
|
-
// register_click_away_event(target.element)
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
function details_setter$a(){
|
|
2124
|
-
if(this.currentEvent==="click") this.dx = 0;
|
|
2125
|
-
else this.dx = 1;
|
|
2126
|
-
// console.log(this.currentEvent)
|
|
2127
|
-
}
|
|
2128
|
-
const bind_click_event = (target, customizer) => new ZikoEventClick(target, customizer);
|
|
2129
|
-
|
|
2130
|
-
class ZikoEventClipboard extends __ZikoEvent__{
|
|
2131
|
-
constructor(target, customizer){
|
|
2132
|
-
super(target, Events.Clipboard, details_setter$9, customizer);
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
function details_setter$9(){
|
|
2136
|
-
|
|
2137
|
-
}
|
|
2138
|
-
const bind_clipboard_event = (target, customizer) => new ZikoEventClipboard(target, customizer);
|
|
2139
|
-
|
|
2140
|
-
class ZikoEventCustom extends __ZikoEvent__{
|
|
2141
|
-
constructor(target, events, customizer){
|
|
2142
|
-
super(target, events, details_setter$8, customizer);
|
|
2143
|
-
}
|
|
2144
|
-
_register_events(events){
|
|
2145
|
-
super._register_events(events, null, null, false);
|
|
2146
|
-
return this;
|
|
2147
|
-
}
|
|
2148
|
-
emit(event_name, details = {}){
|
|
2149
|
-
const event=new Event(event_name);
|
|
2150
|
-
this.targetElement.dispatchEvent(event);
|
|
2151
|
-
return this;
|
|
2152
|
-
}
|
|
2153
|
-
on(event_name, ...callbacks){
|
|
2154
|
-
if(!this.cache.options.hasOwnProperty(event_name)) this._register_events([event_name]);
|
|
2155
|
-
this.__onEvent(event_name, this.cache.options[event_name], {}, ...callbacks);
|
|
2156
|
-
return this;
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
function details_setter$8(){
|
|
2160
|
-
|
|
2161
|
-
}
|
|
2162
|
-
const bindCustomEvent = (target, events, customizer) => new ZikoEventCustom(target, events, customizer);
|
|
2163
|
-
|
|
2164
|
-
class ZikoEventDrag extends __ZikoEvent__{
|
|
2165
|
-
constructor(target, customizer){
|
|
2166
|
-
super(target, Events.Drag, details_setter$7, customizer);
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
function details_setter$7(){
|
|
2170
|
-
|
|
2171
|
-
}
|
|
2172
|
-
const bind_drag_event = (target, customizer) => new ZikoEventDrag(target, customizer);
|
|
2173
|
-
|
|
2174
|
-
class ZikoEventFocus extends __ZikoEvent__{
|
|
2175
|
-
constructor(target, customizer){
|
|
2176
|
-
super(target, Events.Focus, details_setter$6, customizer);
|
|
2177
|
-
}
|
|
2178
|
-
}
|
|
2179
|
-
function details_setter$6(){
|
|
2180
|
-
|
|
2181
|
-
}
|
|
2182
|
-
const bind_focus_event = (target, customizer) => new ZikoEventFocus(target, customizer);
|
|
2183
|
-
|
|
2184
|
-
class ZikoEventHash extends __ZikoEvent__{
|
|
2185
|
-
constructor(target, customizer){
|
|
2186
|
-
super(target, Events.Hash, details_setter$5, customizer);
|
|
2187
|
-
}
|
|
2188
1970
|
}
|
|
2189
|
-
function details_setter$5(){
|
|
2190
1971
|
|
|
2191
|
-
|
|
2192
|
-
|
|
1972
|
+
function event_controller(e, event_name, details_setter, customizer, push_object){
|
|
1973
|
+
this.cache.currentEvent = event_name;
|
|
1974
|
+
this.cache.event = e;
|
|
1975
|
+
details_setter?.call(this);
|
|
1976
|
+
customizer?.hasOwnProperty("prototype") ? customizer?.call(this) : customizer?.call(null, this);
|
|
1977
|
+
// if(customizer?.hasOwnProperty("prototype")) customizer?.call(this)
|
|
1978
|
+
// else customizer?.call(null, this)
|
|
1979
|
+
if(this.cache.preventDefault[event_name]) e.preventDefault();
|
|
1980
|
+
if(this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
1981
|
+
if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
1982
|
+
|
|
1983
|
+
if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
|
|
1984
|
+
this.cache.callbacks[event_name]?.map(n=>n(this));
|
|
1985
|
+
}
|
|
2193
1986
|
|
|
2194
|
-
|
|
2195
|
-
constructor(target, customizer){
|
|
2196
|
-
super(target, Events.Key, details_setter$4, customizer);
|
|
2197
|
-
}
|
|
2198
|
-
}
|
|
2199
|
-
function details_setter$4(){
|
|
1987
|
+
function key_details_setter(){
|
|
2200
1988
|
switch(this.currentEvent){
|
|
2201
1989
|
case "keydown" : {
|
|
2202
1990
|
this.kd = this.event.key;
|
|
@@ -2209,26 +1997,9 @@
|
|
|
2209
1997
|
} break;
|
|
2210
1998
|
|
|
2211
1999
|
}
|
|
2212
|
-
}
|
|
2213
|
-
const bind_key_event = (target, customizer) => new ZikoEventKey(target, customizer);
|
|
2214
|
-
|
|
2215
|
-
class ZikoEventMouse extends __ZikoEvent__{
|
|
2216
|
-
constructor(target, customizer){
|
|
2217
|
-
super(target, Events.Mouse, details_setter$3, customizer);
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
function details_setter$3(){
|
|
2221
|
-
|
|
2222
|
-
}
|
|
2223
|
-
const bind_mouse_event = (target, customizer) => new ZikoEventMouse(target, customizer);
|
|
2000
|
+
}
|
|
2224
2001
|
|
|
2225
|
-
|
|
2226
|
-
constructor(target, customizer){
|
|
2227
|
-
super(target, Events.Ptr, details_setter$2, customizer);
|
|
2228
|
-
this.isDown = false;
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
function details_setter$2(){
|
|
2002
|
+
function ptr_details_setter(){
|
|
2232
2003
|
switch(this.currentEvent){
|
|
2233
2004
|
case "pointerdown" : {
|
|
2234
2005
|
this.dx = parseInt(this.event.offsetX);
|
|
@@ -2260,28 +2031,135 @@
|
|
|
2260
2031
|
// if(this.currentEvent==="click") this.dx = 0
|
|
2261
2032
|
// else this.dx = 1
|
|
2262
2033
|
// console.log(this.currentEvent)
|
|
2263
|
-
}
|
|
2264
|
-
const bind_pointer_event = (target, customizer) => new ZikoEventPointer(target, customizer);
|
|
2034
|
+
}
|
|
2265
2035
|
|
|
2266
|
-
class
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2036
|
+
class ClickAwayEvent extends Event {
|
|
2037
|
+
constructor(originalEvent, targetElement) {
|
|
2038
|
+
super("clickaway", { bubbles: true, cancelable: true });
|
|
2039
|
+
this.originalEvent = originalEvent;
|
|
2040
|
+
this.targetElement = targetElement;
|
|
2041
|
+
}
|
|
2270
2042
|
}
|
|
2271
|
-
function details_setter$1(){
|
|
2272
2043
|
|
|
2044
|
+
function register_click_away_event(element) {
|
|
2045
|
+
console.log(element);
|
|
2046
|
+
function handler(e) {
|
|
2047
|
+
if (!element.contains(e.target)) {
|
|
2048
|
+
const clickAwayEvent = new ClickAwayEvent(e, element);
|
|
2049
|
+
element.dispatchEvent(clickAwayEvent);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
globalThis?.document?.addEventListener("click", handler);
|
|
2054
|
+
|
|
2055
|
+
return () => globalThis?.document?.removeEventListener("click", handler);
|
|
2056
|
+
|
|
2273
2057
|
}
|
|
2274
|
-
|
|
2058
|
+
|
|
2059
|
+
// // Example usage
|
|
2060
|
+
// const box = document.querySelector("#my-box");
|
|
2061
|
+
|
|
2062
|
+
// const stop = listenClickAway(box);
|
|
2063
|
+
|
|
2064
|
+
// box.addEventListener("clickaway", (e) => {
|
|
2065
|
+
// console.log("Clicked outside box!", e);
|
|
2066
|
+
// });
|
|
2067
|
+
|
|
2068
|
+
// // later, you can stop listening:
|
|
2069
|
+
// // stop();
|
|
2275
2070
|
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2071
|
+
const bind_click_event = (target, customizer) => {
|
|
2072
|
+
register_click_away_event(target.element);
|
|
2073
|
+
return new ZikoEvent(
|
|
2074
|
+
target,
|
|
2075
|
+
EventsMap.Click,
|
|
2076
|
+
null,
|
|
2077
|
+
customizer
|
|
2078
|
+
);
|
|
2079
|
+
};
|
|
2080
|
+
const bind_clipboard_event = (target, customizer) => new ZikoEvent(
|
|
2081
|
+
target,
|
|
2082
|
+
EventsMap.Clipboard,
|
|
2083
|
+
null,
|
|
2084
|
+
customizer
|
|
2085
|
+
);
|
|
2086
|
+
const bind_drag_event = (target, customizer) => new ZikoEvent(
|
|
2087
|
+
target,
|
|
2088
|
+
EventsMap.Drag,
|
|
2089
|
+
null,
|
|
2090
|
+
customizer
|
|
2091
|
+
);
|
|
2092
|
+
const bind_focus_event = (target, customizer) => new ZikoEvent(
|
|
2093
|
+
target,
|
|
2094
|
+
EventsMap.Focus,
|
|
2095
|
+
null,
|
|
2096
|
+
customizer
|
|
2097
|
+
);
|
|
2098
|
+
const bind_key_event = (target, customizer) => new ZikoEvent(
|
|
2099
|
+
target,
|
|
2100
|
+
EventsMap.Key,
|
|
2101
|
+
key_details_setter,
|
|
2102
|
+
customizer
|
|
2103
|
+
);
|
|
2104
|
+
const bind_mouse_event = (target, customizer) => new ZikoEvent(
|
|
2105
|
+
target,
|
|
2106
|
+
EventsMap.Mouse,
|
|
2107
|
+
null,
|
|
2108
|
+
customizer
|
|
2109
|
+
);
|
|
2110
|
+
const bind_pointer_event = (target, customizer) => new ZikoEvent(
|
|
2111
|
+
target,
|
|
2112
|
+
EventsMap.Ptr,
|
|
2113
|
+
ptr_details_setter,
|
|
2114
|
+
customizer
|
|
2115
|
+
);
|
|
2116
|
+
const bind_touch_event = (target, customizer) => new ZikoEvent(
|
|
2117
|
+
target,
|
|
2118
|
+
EventsMap.Touch,
|
|
2119
|
+
null,
|
|
2120
|
+
customizer
|
|
2121
|
+
);
|
|
2122
|
+
const bind_wheel_event = (target, customizer) => new ZikoEvent(
|
|
2123
|
+
target,
|
|
2124
|
+
EventsMap.Wheel,
|
|
2125
|
+
null,
|
|
2126
|
+
customizer
|
|
2127
|
+
);
|
|
2128
|
+
|
|
2129
|
+
|
|
2130
|
+
// function details_setter(){
|
|
2131
|
+
// if(this.currentEvent==="click") this.dx = 0
|
|
2132
|
+
// else this.dx = 1
|
|
2133
|
+
// // console.log(this.currentEvent)
|
|
2134
|
+
// }
|
|
2135
|
+
|
|
2136
|
+
class ZikoCustomEvent extends ZikoEvent{
|
|
2137
|
+
constructor(target, events, customizer){
|
|
2138
|
+
super(target, events, details_setter, customizer);
|
|
2139
|
+
}
|
|
2140
|
+
_register_events(events){
|
|
2141
|
+
super._register_events(events, null, null, false);
|
|
2142
|
+
return this;
|
|
2143
|
+
}
|
|
2144
|
+
emit(event_name, detail = {}){
|
|
2145
|
+
const event = new CustomEvent(event_name, {
|
|
2146
|
+
detail,
|
|
2147
|
+
bubbles: true,
|
|
2148
|
+
cancelable: true
|
|
2149
|
+
});
|
|
2150
|
+
this.targetElement.dispatchEvent(event);
|
|
2151
|
+
return this;
|
|
2152
|
+
}
|
|
2153
|
+
on(event_name, ...callbacks){
|
|
2154
|
+
if(!this.cache.options.hasOwnProperty(event_name)) this._register_events([event_name]);
|
|
2155
|
+
this.__onEvent(event_name, this.cache.options[event_name], {}, ...callbacks);
|
|
2156
|
+
return this;
|
|
2279
2157
|
}
|
|
2280
2158
|
}
|
|
2281
2159
|
function details_setter(){
|
|
2282
2160
|
|
|
2283
2161
|
}
|
|
2284
|
-
const
|
|
2162
|
+
const bind_custom_event = (target, events, customizer) => new ZikoCustomEvent(target, events, customizer);
|
|
2285
2163
|
|
|
2286
2164
|
const binderMap = {
|
|
2287
2165
|
ptr: bind_pointer_event,
|
|
@@ -2294,14 +2172,26 @@
|
|
|
2294
2172
|
wheel : bind_wheel_event
|
|
2295
2173
|
};
|
|
2296
2174
|
|
|
2297
|
-
const EventsMethodes = {
|
|
2175
|
+
const EventsMethodes = {
|
|
2176
|
+
on(event_name,...callbacks){
|
|
2177
|
+
if(!this.events.custom)this.events.custom = bind_custom_event(this);
|
|
2178
|
+
this.events.custom.on(event_name,...callbacks);
|
|
2179
|
+
return this;
|
|
2180
|
+
},
|
|
2181
|
+
emit(event_name,detail={}){
|
|
2182
|
+
if(!this.events.custom)this.events.custom = bind_custom_event(this);
|
|
2183
|
+
this.events.custom.emit(event_name,detail);
|
|
2184
|
+
return this;
|
|
2185
|
+
}
|
|
2186
|
+
};
|
|
2298
2187
|
|
|
2299
|
-
Object.entries(
|
|
2188
|
+
Object.entries(EventsMap).forEach(([name, eventList]) => {
|
|
2189
|
+
const lname = name.toLowerCase();
|
|
2300
2190
|
eventList.forEach(event => {
|
|
2301
2191
|
const methodName = `on${event}`;
|
|
2302
2192
|
EventsMethodes[methodName] = function (...callbacks) {
|
|
2303
|
-
if (!this.events[
|
|
2304
|
-
this.events[
|
|
2193
|
+
if (!this.events[lname]) this.events[lname] = binderMap[lname](this);
|
|
2194
|
+
this.events[lname][methodName](...callbacks);
|
|
2305
2195
|
return this;
|
|
2306
2196
|
};
|
|
2307
2197
|
});
|
|
@@ -2343,177 +2233,33 @@
|
|
|
2343
2233
|
},
|
|
2344
2234
|
// this
|
|
2345
2235
|
);
|
|
2346
|
-
}
|
|
2347
|
-
else Object.assign(this.element.style, {[key] : value});
|
|
2348
|
-
}
|
|
2349
|
-
return this;
|
|
2350
|
-
}
|
|
2351
|
-
function size(width, height){
|
|
2352
|
-
return this.style({width, height})
|
|
2353
|
-
}
|
|
2354
|
-
function hide(){
|
|
2355
|
-
|
|
2356
|
-
}
|
|
2357
|
-
function show(){
|
|
2358
|
-
|
|
2359
|
-
}
|
|
2360
|
-
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2361
|
-
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2362
|
-
return this;
|
|
2363
|
-
}
|
|
2364
|
-
|
|
2365
|
-
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2366
|
-
__proto__: null,
|
|
2367
|
-
animate: animate,
|
|
2368
|
-
hide: hide,
|
|
2369
|
-
show: show,
|
|
2370
|
-
size: size,
|
|
2371
|
-
style: style
|
|
2372
|
-
});
|
|
2373
|
-
|
|
2374
|
-
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
2375
|
-
this.event=e;
|
|
2376
|
-
if(this.cache.preventDefault[EVENT])e.preventDefault();
|
|
2377
|
-
console.log({setter});
|
|
2378
|
-
if(setter)setter();
|
|
2379
|
-
if(this.cache.stream.enabled[EVENT]&&push_object)this.cache.stream.history[EVENT].push(push_object);
|
|
2380
|
-
this.cache.callbacks[EVENT].map(n=>n(this));
|
|
2381
|
-
return this;
|
|
2382
|
-
}
|
|
2383
|
-
class ZikoEvent{
|
|
2384
|
-
constructor(target){
|
|
2385
|
-
this.target=null;
|
|
2386
|
-
this.setTarget(target);
|
|
2387
|
-
this.__dispose=this.dispose.bind(this);
|
|
2388
|
-
// this.EventIndex=Garbage.Pointer.data.length;
|
|
2389
|
-
// Garbage.Pointer.data.push({event:this,index:this.EventIndex});
|
|
2390
|
-
}
|
|
2391
|
-
get targetElement(){
|
|
2392
|
-
return this.target.element
|
|
2393
|
-
}
|
|
2394
|
-
setTarget(UI){
|
|
2395
|
-
this.target=UI;
|
|
2396
|
-
return this;
|
|
2397
|
-
}
|
|
2398
|
-
__handle(event,handler,dispose){
|
|
2399
|
-
const EVENT=(event==="drag")?event:`${this.cache.prefixe}${event}`;
|
|
2400
|
-
this.dispose(dispose);
|
|
2401
|
-
this.targetElement?.addEventListener(EVENT,handler);
|
|
2402
|
-
return this;
|
|
2403
|
-
}
|
|
2404
|
-
__onEvent(event,dispose,...callbacks){
|
|
2405
|
-
if(callbacks.length===0){
|
|
2406
|
-
if(this.cache.callbacks.length>1){
|
|
2407
|
-
this.cache.callbacks.map(n=>e=>n.call(this,e));
|
|
2408
|
-
}
|
|
2409
|
-
else {
|
|
2410
|
-
return this;
|
|
2411
|
-
}
|
|
2412
|
-
}
|
|
2413
|
-
else this.cache.callbacks[event]=callbacks.map(n=>e=>n.call(this,e));
|
|
2414
|
-
this.__handle(event,this.__controller[event],dispose);
|
|
2415
|
-
return this;
|
|
2416
|
-
}
|
|
2417
|
-
preventDefault(config={}){
|
|
2418
|
-
Object.assign(this.cache.preventDefault,config);
|
|
2419
|
-
return this;
|
|
2420
|
-
}
|
|
2421
|
-
pause(config={}){
|
|
2422
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]));
|
|
2423
|
-
config={...all,...config};
|
|
2424
|
-
for(let key in config){
|
|
2425
|
-
if(config[key]){
|
|
2426
|
-
this.targetElement?.removeEventListener(`${this.cache.prefixe}${key}`,this.__controller[`${this.cache.prefixe}${key}`]);
|
|
2427
|
-
this.cache.paused[`${this.cache.prefixe}${key}`]=true;
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
return this;
|
|
2431
|
-
}
|
|
2432
|
-
resume(config={}){
|
|
2433
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]));
|
|
2434
|
-
config={...all,...config};
|
|
2435
|
-
for(let key in config){
|
|
2436
|
-
if(config[key]){
|
|
2437
|
-
this.targetElement?.addEventListener(`${this.cache.prefixe}${key}`,this.__controller[`${this.cache.prefixe}${key}`]);
|
|
2438
|
-
this.cache.paused[`${this.cache.prefixe}${key}`]=false;
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
return this;
|
|
2442
|
-
}
|
|
2443
|
-
dispose(config={}){
|
|
2444
|
-
this.pause(config);
|
|
2445
|
-
return this;
|
|
2446
|
-
}
|
|
2447
|
-
stream(config={}){
|
|
2448
|
-
this.cache.stream.t0=Date.now();
|
|
2449
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,true]));
|
|
2450
|
-
config={...all,...config};
|
|
2451
|
-
Object.assign(this.cache.stream.enabled,config);
|
|
2452
|
-
return this;
|
|
2453
|
-
}
|
|
2454
|
-
clear(config={}){
|
|
2455
|
-
const all=Object.fromEntries(Object.keys(this.cache.stream.clear).map(n=>[n,true]));
|
|
2456
|
-
config={...all,...config};
|
|
2457
|
-
for(let key in config){
|
|
2458
|
-
if(config[key]){
|
|
2459
|
-
this.cache.stream.history[key]=[];
|
|
2460
|
-
}
|
|
2461
|
-
}
|
|
2462
|
-
return this;
|
|
2463
|
-
}
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
|
-
const custom_event_controller=event_name=>function(e){
|
|
2467
|
-
EVENT_CONTROLLER.call(this,e,event_name,null,null);
|
|
2468
|
-
};
|
|
2469
|
-
class ZikoCustomEvent extends ZikoEvent{
|
|
2470
|
-
constructor(target){
|
|
2471
|
-
super(target);
|
|
2472
|
-
this.event=null;
|
|
2473
|
-
this.cache={
|
|
2474
|
-
prefixe:"",
|
|
2475
|
-
preventDefault:{
|
|
2476
|
-
},
|
|
2477
|
-
paused:{
|
|
2478
|
-
},
|
|
2479
|
-
stream:{
|
|
2480
|
-
enabled:{
|
|
2481
|
-
},
|
|
2482
|
-
clear:{
|
|
2483
|
-
},
|
|
2484
|
-
history:{
|
|
2485
|
-
}
|
|
2486
|
-
},
|
|
2487
|
-
callbacks:{
|
|
2488
|
-
}
|
|
2489
|
-
};
|
|
2490
|
-
this.__controller={
|
|
2491
|
-
};
|
|
2492
|
-
}
|
|
2493
|
-
#init(event_name){
|
|
2494
|
-
this.cache.preventDefault[event_name]=false;
|
|
2495
|
-
this.cache.paused[event_name]=false;
|
|
2496
|
-
this.cache.stream.enabled=false;
|
|
2497
|
-
this.cache.stream.clear=false;
|
|
2498
|
-
this.cache.stream.history=[];
|
|
2499
|
-
this.cache.callbacks[event_name]=[];
|
|
2500
|
-
this.__controller[event_name]=custom_event_controller(event_name).bind(this);
|
|
2501
|
-
return this;
|
|
2502
|
-
}
|
|
2503
|
-
on(event_name,...callbacks){
|
|
2504
|
-
if(!(this.__controller[event_name]))this.#init(event_name);
|
|
2505
|
-
this.__onEvent(event_name,{},...callbacks);
|
|
2506
|
-
return this;
|
|
2507
|
-
}
|
|
2508
|
-
emit(event_name,detail={}){
|
|
2509
|
-
if(!(this.__controller[event_name]))this.#init(event_name);
|
|
2510
|
-
this.detail=detail;
|
|
2511
|
-
const event=new Event(event_name);
|
|
2512
|
-
this.targetElement.dispatchEvent(event);
|
|
2513
|
-
return this;
|
|
2236
|
+
}
|
|
2237
|
+
else Object.assign(this.element.style, {[key] : value});
|
|
2514
2238
|
}
|
|
2239
|
+
return this;
|
|
2240
|
+
}
|
|
2241
|
+
function size(width, height){
|
|
2242
|
+
return this.style({width, height})
|
|
2243
|
+
}
|
|
2244
|
+
function hide(){
|
|
2245
|
+
|
|
2246
|
+
}
|
|
2247
|
+
function show(){
|
|
2248
|
+
|
|
2515
2249
|
}
|
|
2516
|
-
|
|
2250
|
+
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2251
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2252
|
+
return this;
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2256
|
+
__proto__: null,
|
|
2257
|
+
animate: animate,
|
|
2258
|
+
hide: hide,
|
|
2259
|
+
show: show,
|
|
2260
|
+
size: size,
|
|
2261
|
+
style: style
|
|
2262
|
+
});
|
|
2517
2263
|
|
|
2518
2264
|
let UIElement$1 = class UIElement extends UIElementCore{
|
|
2519
2265
|
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
@@ -2528,6 +2274,8 @@
|
|
|
2528
2274
|
IndexingMethods,
|
|
2529
2275
|
EventsMethodes
|
|
2530
2276
|
);
|
|
2277
|
+
|
|
2278
|
+
// console.log(EventsMethodes)
|
|
2531
2279
|
if(element)this.init(element, name, type, render);
|
|
2532
2280
|
}
|
|
2533
2281
|
get element(){
|
|
@@ -2665,16 +2413,16 @@
|
|
|
2665
2413
|
// this.events.clipboard.onSelect(...callbacks);
|
|
2666
2414
|
// return this;
|
|
2667
2415
|
// }
|
|
2668
|
-
on(event_name,...callbacks){
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
}
|
|
2673
|
-
emit(event_name,detail={}){
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
}
|
|
2416
|
+
// on(event_name,...callbacks){
|
|
2417
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
2418
|
+
// this.events.custom.on(event_name,...callbacks);
|
|
2419
|
+
// return this;
|
|
2420
|
+
// }
|
|
2421
|
+
// emit(event_name,detail={}){
|
|
2422
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
2423
|
+
// this.events.custom.emit(event_name,detail);
|
|
2424
|
+
// return this;
|
|
2425
|
+
// }
|
|
2678
2426
|
// watchAttr(callback){
|
|
2679
2427
|
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
2680
2428
|
// return this;
|
|
@@ -4808,212 +4556,7 @@
|
|
|
4808
4556
|
return r;
|
|
4809
4557
|
};
|
|
4810
4558
|
|
|
4811
|
-
|
|
4812
|
-
constructor(maxListeners = 10) {
|
|
4813
|
-
this.events = {};
|
|
4814
|
-
this.maxListeners = maxListeners;
|
|
4815
|
-
}
|
|
4816
|
-
|
|
4817
|
-
on(event, listener) {
|
|
4818
|
-
if (!this.events[event]) this.events[event] = [];
|
|
4819
|
-
this.events[event].push(listener);
|
|
4820
|
-
if (this.events[event].length > this.maxListeners) {
|
|
4821
|
-
console.warn(`Warning: Possible memory leak. Event '${event}' has more than ${this.maxListeners} listeners.`);
|
|
4822
|
-
}
|
|
4823
|
-
return this;
|
|
4824
|
-
}
|
|
4825
|
-
|
|
4826
|
-
once(event, listener) {
|
|
4827
|
-
const wrapper = (...args) => {
|
|
4828
|
-
this.off(event, wrapper);
|
|
4829
|
-
listener(...args);
|
|
4830
|
-
};
|
|
4831
|
-
return this.on(event, wrapper);
|
|
4832
|
-
}
|
|
4833
|
-
|
|
4834
|
-
off(event, listener) {
|
|
4835
|
-
const listeners = this.events[event];
|
|
4836
|
-
if (!listeners) return this;
|
|
4837
|
-
|
|
4838
|
-
const index = listeners.indexOf(listener);
|
|
4839
|
-
if (index !== -1) {
|
|
4840
|
-
listeners.splice(index, 1);
|
|
4841
|
-
}
|
|
4842
|
-
|
|
4843
|
-
return this;
|
|
4844
|
-
}
|
|
4845
|
-
|
|
4846
|
-
emit(event, data) {
|
|
4847
|
-
const listeners = this.events[event];
|
|
4848
|
-
if (!listeners) return false;
|
|
4849
|
-
|
|
4850
|
-
// Make a copy so removing listeners inside callbacks doesn't affect iteration
|
|
4851
|
-
[...listeners].forEach(listener => {
|
|
4852
|
-
try {
|
|
4853
|
-
listener(data);
|
|
4854
|
-
} catch (e) {
|
|
4855
|
-
console.error(`Error in listener for '${event}':`, e);
|
|
4856
|
-
}
|
|
4857
|
-
});
|
|
4858
|
-
|
|
4859
|
-
return true;
|
|
4860
|
-
}
|
|
4861
|
-
remove(event){
|
|
4862
|
-
delete this.events[event];
|
|
4863
|
-
return this;
|
|
4864
|
-
}
|
|
4865
|
-
clear() {
|
|
4866
|
-
this.events = {};
|
|
4867
|
-
return this;
|
|
4868
|
-
}
|
|
4869
|
-
|
|
4870
|
-
setMaxListeners(max) {
|
|
4871
|
-
this.maxListeners = max;
|
|
4872
|
-
return this;
|
|
4873
|
-
}
|
|
4874
|
-
}
|
|
4875
|
-
|
|
4876
|
-
const useEventEmitter = (maxListeners) => new UseEventEmitter(maxListeners);
|
|
4877
|
-
|
|
4878
|
-
class ZikoUseFavIcon{
|
|
4879
|
-
constructor(FavIcon,withEmitter=true){
|
|
4880
|
-
this.#init();
|
|
4881
|
-
this.cache={
|
|
4882
|
-
Emitter:null
|
|
4883
|
-
};
|
|
4884
|
-
if(withEmitter)this.useEventEmitter();
|
|
4885
|
-
this.set(FavIcon);
|
|
4886
|
-
}
|
|
4887
|
-
#init(){
|
|
4888
|
-
this.__FavIcon__ = document.querySelector("link[rel*='icon']") || document?.createElement('link');
|
|
4889
|
-
this.__FavIcon__.type = 'image/x-icon';
|
|
4890
|
-
this.__FavIcon__.rel = 'shortcut icon';
|
|
4891
|
-
return this;
|
|
4892
|
-
}
|
|
4893
|
-
set(href){
|
|
4894
|
-
if(href!==this.__FavIcon__.href){
|
|
4895
|
-
this.__FavIcon__.href=href;
|
|
4896
|
-
if(this.cache.Emitter)this.cache.Emitter.emit("ziko:favicon-changed");
|
|
4897
|
-
}
|
|
4898
|
-
return this;
|
|
4899
|
-
}
|
|
4900
|
-
get current(){
|
|
4901
|
-
return document.__FavIcon__.href;
|
|
4902
|
-
}
|
|
4903
|
-
onChange(callback){
|
|
4904
|
-
if(this.cache.Emitter)this.cache.Emitter.on("ziko:favicon-changed",callback);
|
|
4905
|
-
return this;
|
|
4906
|
-
}
|
|
4907
|
-
useEventEmitter(){
|
|
4908
|
-
this.cache.Emitter=useEventEmitter();
|
|
4909
|
-
return this;
|
|
4910
|
-
}
|
|
4911
|
-
|
|
4912
|
-
}
|
|
4913
|
-
const useFavIcon=(FavIcon,withEmitter)=>new ZikoUseFavIcon(FavIcon,withEmitter);
|
|
4914
|
-
|
|
4915
|
-
class ZikoMeta{
|
|
4916
|
-
constructor({viewport,charset,description,author,keywords}){
|
|
4917
|
-
this.document = globalThis?.document;
|
|
4918
|
-
this.meta={};
|
|
4919
|
-
this.init({viewport,charset,description,author,keywords});
|
|
4920
|
-
}
|
|
4921
|
-
init({viewport,charset,description,author,keywords}){
|
|
4922
|
-
viewport && this.setViewport(viewport);
|
|
4923
|
-
charset && this.setCharset(charset);
|
|
4924
|
-
description && this.describe(description);
|
|
4925
|
-
author && this.setAuthor(author);
|
|
4926
|
-
keywords && this.setKeywords(keywords);
|
|
4927
|
-
}
|
|
4928
|
-
set(key,value){
|
|
4929
|
-
key = key.toLowerCase();
|
|
4930
|
-
const isCharset = (key === "charset");
|
|
4931
|
-
const meta = isCharset ? document.querySelector("meta[charset]"):document.querySelector(`meta[name=${key}]`);
|
|
4932
|
-
this.meta=meta?? document?.createElement("meta");
|
|
4933
|
-
if(isCharset) this.meta.setAttribute("charset",value);
|
|
4934
|
-
else {
|
|
4935
|
-
this.meta.setAttribute("name",key);
|
|
4936
|
-
this.meta.setAttribute("content",value);
|
|
4937
|
-
}
|
|
4938
|
-
if(!meta)this.document.head.append(this.meta);
|
|
4939
|
-
return this;
|
|
4940
|
-
}
|
|
4941
|
-
setCharset(charset="utf-8"){
|
|
4942
|
-
this.set("charset",charset);
|
|
4943
|
-
return this;
|
|
4944
|
-
}
|
|
4945
|
-
describe(description){
|
|
4946
|
-
this.set("description",description);
|
|
4947
|
-
return this;
|
|
4948
|
-
}
|
|
4949
|
-
setViewport(viewport="width=device-width, initial-scale=1.0"){
|
|
4950
|
-
this.set("viewport",viewport);
|
|
4951
|
-
return this;
|
|
4952
|
-
}
|
|
4953
|
-
setKeywords(...keywords){
|
|
4954
|
-
// keywords.push("zikojs");
|
|
4955
|
-
keywords=[...new Set(keywords)].join(", ");
|
|
4956
|
-
this.set("keywords",keywords);
|
|
4957
|
-
return this;
|
|
4958
|
-
}
|
|
4959
|
-
setAuthor(author){
|
|
4960
|
-
this.set("author",author);
|
|
4961
|
-
return this;
|
|
4962
|
-
}
|
|
4963
|
-
}
|
|
4964
|
-
const useMeta=({viewport,charset,description,author,keywords})=>new ZikoMeta({viewport,charset,description,author,keywords});
|
|
4965
|
-
|
|
4966
|
-
class ZikoUseTitle{
|
|
4967
|
-
constructor(title=document.title,useEventEmitter=true){
|
|
4968
|
-
this.cache={
|
|
4969
|
-
Emitter:null
|
|
4970
|
-
};
|
|
4971
|
-
if(useEventEmitter)this.useEventEmitter();
|
|
4972
|
-
this.set(title);
|
|
4973
|
-
}
|
|
4974
|
-
useEventEmitter(){
|
|
4975
|
-
this.cache.Emitter=useEventEmitter();
|
|
4976
|
-
return this;
|
|
4977
|
-
}
|
|
4978
|
-
set(title){
|
|
4979
|
-
if(title!==document.title){
|
|
4980
|
-
document.title=title;
|
|
4981
|
-
if(this.cache.Emitter)this.cache.Emitter.emit("ziko:title-changed");
|
|
4982
|
-
}
|
|
4983
|
-
return this;
|
|
4984
|
-
}
|
|
4985
|
-
get current(){
|
|
4986
|
-
return document.title;
|
|
4987
|
-
}
|
|
4988
|
-
onChange(callback){
|
|
4989
|
-
if(this.cache.Emitter)this.cache.Emitter.on("ziko:title-changed",callback);
|
|
4990
|
-
return this;
|
|
4991
|
-
}
|
|
4992
|
-
}
|
|
4993
|
-
const useTitle$1=(title, useEventEmitter)=>new ZikoUseTitle(title, useEventEmitter);
|
|
4994
|
-
|
|
4995
|
-
// import {useLink} from "./";
|
|
4996
|
-
class ZikoHead{
|
|
4997
|
-
constructor({title,lang,icon,meta,noscript}){
|
|
4998
|
-
this.html = globalThis?.document?.documentElement;
|
|
4999
|
-
this.head = globalThis?.document?.head;
|
|
5000
|
-
|
|
5001
|
-
title && useTitle$1(title);
|
|
5002
|
-
lang && this.setLang(lang);
|
|
5003
|
-
icon && useFavIcon(icon);
|
|
5004
|
-
meta && useMeta(meta);
|
|
5005
|
-
noscript && this.setNoScript();
|
|
5006
|
-
}
|
|
5007
|
-
setLang(lang){
|
|
5008
|
-
this.html.setAttribute("lang",lang);
|
|
5009
|
-
}
|
|
5010
|
-
setNoScript(content){
|
|
5011
|
-
|
|
5012
|
-
}
|
|
5013
|
-
}
|
|
5014
|
-
|
|
5015
|
-
const useHead=({ title, lang, icon, meta, noscript })=>new ZikoHead({ title, lang, icon, meta, noscript });
|
|
5016
|
-
|
|
4559
|
+
// import { ZikoHead , useHead} from "../reactivity/hooks/head/index.js";
|
|
5017
4560
|
class ZikoApp {
|
|
5018
4561
|
constructor({head = null, wrapper = null, target = null}){
|
|
5019
4562
|
this.head = head;
|
|
@@ -5040,11 +4583,11 @@
|
|
|
5040
4583
|
else if(typeof wrapper === "function") this.wrapper = wrapper();
|
|
5041
4584
|
return this;
|
|
5042
4585
|
}
|
|
5043
|
-
setHead(head){
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
}
|
|
4586
|
+
// setHead(head){
|
|
4587
|
+
// if(head instanceof ZikoHead) this.head = head;
|
|
4588
|
+
// else this.head = useHead(head);
|
|
4589
|
+
// return this;
|
|
4590
|
+
// }
|
|
5048
4591
|
|
|
5049
4592
|
}
|
|
5050
4593
|
const App = ({head, wrapper, target}) => new ZikoApp({head, wrapper, target});
|
|
@@ -5314,7 +4857,76 @@
|
|
|
5314
4857
|
terminate() {
|
|
5315
4858
|
this.#worker.terminate();
|
|
5316
4859
|
}
|
|
5317
|
-
}
|
|
4860
|
+
}
|
|
4861
|
+
|
|
4862
|
+
const useThread = (func, callback, args = [], close = true) => new UseThread().call(func, callback, args, close);
|
|
4863
|
+
|
|
4864
|
+
class UseEventEmitter {
|
|
4865
|
+
constructor(maxListeners = 10) {
|
|
4866
|
+
this.events = {};
|
|
4867
|
+
this.maxListeners = maxListeners;
|
|
4868
|
+
}
|
|
4869
|
+
|
|
4870
|
+
on(event, listener) {
|
|
4871
|
+
if (!this.events[event]) this.events[event] = [];
|
|
4872
|
+
this.events[event].push(listener);
|
|
4873
|
+
if (this.events[event].length > this.maxListeners) {
|
|
4874
|
+
console.warn(`Warning: Possible memory leak. Event '${event}' has more than ${this.maxListeners} listeners.`);
|
|
4875
|
+
}
|
|
4876
|
+
return this;
|
|
4877
|
+
}
|
|
4878
|
+
|
|
4879
|
+
once(event, listener) {
|
|
4880
|
+
const wrapper = (...args) => {
|
|
4881
|
+
this.off(event, wrapper);
|
|
4882
|
+
listener(...args);
|
|
4883
|
+
};
|
|
4884
|
+
return this.on(event, wrapper);
|
|
4885
|
+
}
|
|
4886
|
+
|
|
4887
|
+
off(event, listener) {
|
|
4888
|
+
const listeners = this.events[event];
|
|
4889
|
+
if (!listeners) return this;
|
|
4890
|
+
|
|
4891
|
+
const index = listeners.indexOf(listener);
|
|
4892
|
+
if (index !== -1) {
|
|
4893
|
+
listeners.splice(index, 1);
|
|
4894
|
+
}
|
|
4895
|
+
|
|
4896
|
+
return this;
|
|
4897
|
+
}
|
|
4898
|
+
|
|
4899
|
+
emit(event, data) {
|
|
4900
|
+
const listeners = this.events[event];
|
|
4901
|
+
if (!listeners) return false;
|
|
4902
|
+
|
|
4903
|
+
// Make a copy so removing listeners inside callbacks doesn't affect iteration
|
|
4904
|
+
[...listeners].forEach(listener => {
|
|
4905
|
+
try {
|
|
4906
|
+
listener(data);
|
|
4907
|
+
} catch (e) {
|
|
4908
|
+
console.error(`Error in listener for '${event}':`, e);
|
|
4909
|
+
}
|
|
4910
|
+
});
|
|
4911
|
+
|
|
4912
|
+
return true;
|
|
4913
|
+
}
|
|
4914
|
+
remove(event){
|
|
4915
|
+
delete this.events[event];
|
|
4916
|
+
return this;
|
|
4917
|
+
}
|
|
4918
|
+
clear() {
|
|
4919
|
+
this.events = {};
|
|
4920
|
+
return this;
|
|
4921
|
+
}
|
|
4922
|
+
|
|
4923
|
+
setMaxListeners(max) {
|
|
4924
|
+
this.maxListeners = max;
|
|
4925
|
+
return this;
|
|
4926
|
+
}
|
|
4927
|
+
}
|
|
4928
|
+
|
|
4929
|
+
const useEventEmitter = (maxListeners) => new UseEventEmitter(maxListeners);
|
|
5318
4930
|
|
|
5319
4931
|
/*
|
|
5320
4932
|
[
|
|
@@ -5414,6 +5026,75 @@
|
|
|
5414
5026
|
|
|
5415
5027
|
const useTitle = (title, withEmitter = true) => new UseTitle(title, withEmitter);
|
|
5416
5028
|
|
|
5029
|
+
class UseRoot {
|
|
5030
|
+
constructor(PropsMap, { namespace = 'Ziko', ValidateCssProps = false } = {}) {
|
|
5031
|
+
this.currentPropsMap = PropsMap;
|
|
5032
|
+
this.namespace = namespace;
|
|
5033
|
+
this.ValidateCssProps = ValidateCssProps;
|
|
5034
|
+
this.use(PropsMap);
|
|
5035
|
+
}
|
|
5036
|
+
|
|
5037
|
+
use(PropsMap) {
|
|
5038
|
+
if (this.ValidateCssProps) ValidateCssPropsFn(PropsMap);
|
|
5039
|
+
this.currentPropsMap = PropsMap;
|
|
5040
|
+
this.#maintain();
|
|
5041
|
+
return this;
|
|
5042
|
+
}
|
|
5043
|
+
|
|
5044
|
+
#maintain() {
|
|
5045
|
+
const root = globalThis?.document?.documentElement?.style;
|
|
5046
|
+
for (const prop in this.currentPropsMap) {
|
|
5047
|
+
const cssProp = this.namespace ? `--${this.namespace}-${prop}` : `--${prop}`;
|
|
5048
|
+
root.setProperty(cssProp, this.currentPropsMap[prop]);
|
|
5049
|
+
|
|
5050
|
+
Object.defineProperty(this, prop, {
|
|
5051
|
+
value: `var(${cssProp})`,
|
|
5052
|
+
writable: true,
|
|
5053
|
+
configurable: true,
|
|
5054
|
+
enumerable: false
|
|
5055
|
+
});
|
|
5056
|
+
}
|
|
5057
|
+
}
|
|
5058
|
+
}
|
|
5059
|
+
|
|
5060
|
+
function ValidateCssPropsFn(PropsMap) {
|
|
5061
|
+
const validProps = new Set(Object.keys(document.documentElement.style));
|
|
5062
|
+
for (const key in PropsMap) {
|
|
5063
|
+
if (!validProps.has(key)) {
|
|
5064
|
+
throw new Error(`Invalid CSS property: "${key}"`);
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
}
|
|
5068
|
+
|
|
5069
|
+
const useRoot = (PropsMap, options = {}) => new UseRoot(PropsMap, options);
|
|
5070
|
+
|
|
5071
|
+
|
|
5072
|
+
// Usage
|
|
5073
|
+
|
|
5074
|
+
/*
|
|
5075
|
+
const Styles = {
|
|
5076
|
+
S1 : {
|
|
5077
|
+
background : 'white',
|
|
5078
|
+
color : 'darkblue'
|
|
5079
|
+
border : '2px darkblue solid"'
|
|
5080
|
+
},
|
|
5081
|
+
S2 : {
|
|
5082
|
+
background : 'darkblue',
|
|
5083
|
+
color : 'white'
|
|
5084
|
+
border : '2px green solid"'
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
const {use, border, background, color} = useRoot(Style.S1)
|
|
5088
|
+
|
|
5089
|
+
tags.p("Test useRoot ").style({
|
|
5090
|
+
border,
|
|
5091
|
+
color,
|
|
5092
|
+
background,
|
|
5093
|
+
padding : '10px'
|
|
5094
|
+
})
|
|
5095
|
+
|
|
5096
|
+
*/
|
|
5097
|
+
|
|
5417
5098
|
let {sqrt, cos, sin, exp, log, cosh, sinh} = Math;
|
|
5418
5099
|
// Math.abs = new Proxy(Math.abs, {
|
|
5419
5100
|
// apply(target, thisArg, args) {
|
|
@@ -5507,26 +5188,16 @@
|
|
|
5507
5188
|
exports.UISVGWrapper = UISVGWrapper;
|
|
5508
5189
|
exports.UISwitch = UISwitch;
|
|
5509
5190
|
exports.UIView = UIView;
|
|
5191
|
+
exports.UseRoot = UseRoot;
|
|
5510
5192
|
exports.UseThread = UseThread;
|
|
5511
5193
|
exports.Utils = Utils;
|
|
5512
5194
|
exports.View = View;
|
|
5513
5195
|
exports.ZikoApp = ZikoApp;
|
|
5514
|
-
exports.
|
|
5515
|
-
exports.ZikoEventClipboard = ZikoEventClipboard;
|
|
5516
|
-
exports.ZikoEventCustom = ZikoEventCustom;
|
|
5517
|
-
exports.ZikoEventDrag = ZikoEventDrag;
|
|
5518
|
-
exports.ZikoEventFocus = ZikoEventFocus;
|
|
5519
|
-
exports.ZikoEventHash = ZikoEventHash;
|
|
5520
|
-
exports.ZikoEventKey = ZikoEventKey;
|
|
5521
|
-
exports.ZikoEventMouse = ZikoEventMouse;
|
|
5522
|
-
exports.ZikoEventPointer = ZikoEventPointer;
|
|
5523
|
-
exports.ZikoEventTouch = ZikoEventTouch;
|
|
5524
|
-
exports.ZikoEventWheel = ZikoEventWheel;
|
|
5196
|
+
exports.ZikoEvent = ZikoEvent;
|
|
5525
5197
|
exports.ZikoSPA = ZikoSPA;
|
|
5526
5198
|
exports.ZikoUIFlex = ZikoUIFlex;
|
|
5527
5199
|
exports.ZikoUISuspense = ZikoUISuspense;
|
|
5528
5200
|
exports.ZikoUIText = ZikoUIText;
|
|
5529
|
-
exports.__ZikoEvent__ = __ZikoEvent__;
|
|
5530
5201
|
exports.abs = abs;
|
|
5531
5202
|
exports.accum = accum;
|
|
5532
5203
|
exports.acos = acos$1;
|
|
@@ -5543,9 +5214,6 @@
|
|
|
5543
5214
|
exports.atan2 = atan2;
|
|
5544
5215
|
exports.atanh = atanh;
|
|
5545
5216
|
exports.back = back;
|
|
5546
|
-
exports.bindCustomEvent = bindCustomEvent;
|
|
5547
|
-
exports.bindHashEvent = bindHashEvent;
|
|
5548
|
-
exports.bindTouchEvent = bindTouchEvent;
|
|
5549
5217
|
exports.bind_click_event = bind_click_event;
|
|
5550
5218
|
exports.bind_clipboard_event = bind_clipboard_event;
|
|
5551
5219
|
exports.bind_drag_event = bind_drag_event;
|
|
@@ -5553,6 +5221,7 @@
|
|
|
5553
5221
|
exports.bind_key_event = bind_key_event;
|
|
5554
5222
|
exports.bind_mouse_event = bind_mouse_event;
|
|
5555
5223
|
exports.bind_pointer_event = bind_pointer_event;
|
|
5224
|
+
exports.bind_touch_event = bind_touch_event;
|
|
5556
5225
|
exports.bind_wheel_event = bind_wheel_event;
|
|
5557
5226
|
exports.cartesianProduct = cartesianProduct;
|
|
5558
5227
|
exports.ceil = ceil;
|
|
@@ -5679,14 +5348,16 @@
|
|
|
5679
5348
|
exports.timeTaken = timeTaken;
|
|
5680
5349
|
exports.time_memory_Taken = time_memory_Taken;
|
|
5681
5350
|
exports.timeout = timeout;
|
|
5682
|
-
exports.useChannel = useChannel;
|
|
5683
5351
|
exports.useDerived = useDerived;
|
|
5684
5352
|
exports.useEventEmitter = useEventEmitter;
|
|
5353
|
+
exports.useIPC = useIPC;
|
|
5685
5354
|
exports.useLocaleStorage = useLocaleStorage;
|
|
5686
5355
|
exports.useMediaQuery = useMediaQuery;
|
|
5687
5356
|
exports.useReactive = useReactive;
|
|
5357
|
+
exports.useRoot = useRoot;
|
|
5688
5358
|
exports.useSessionStorage = useSessionStorage;
|
|
5689
5359
|
exports.useState = useState;
|
|
5360
|
+
exports.useThread = useThread;
|
|
5690
5361
|
exports.useTitle = useTitle;
|
|
5691
5362
|
exports.wait = wait;
|
|
5692
5363
|
exports.waitForUIElm = waitForUIElm;
|