ziko 0.36.1 → 0.36.2
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 +118 -81
- package/dist/ziko.js +118 -81
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +119 -81
- package/package.json +4 -2
- package/readme.md +19 -13
- package/src/reactivity/hooks/Head/useFavIcon.js +1 -1
- package/src/reactivity/hooks/Head/useTitle.js +1 -1
- package/src/reactivity/hooks/UI/index.js +1 -1
- package/src/use/index.js +14 -3
- package/src/use/{interactions/use-channel.js → use-channel.js} +1 -1
- package/src/use/use-root.js +78 -0
- package/src/use/{storage/index.js → use-storage.js} +1 -1
- package/src/use/app/index.js +0 -0
- package/src/use/decorators/index.js +0 -2
- package/src/use/interactions/index.js +0 -3
- /package/src/use/{decorators/use-debounce.js → use-debounce.js} +0 -0
- /package/src/use/{interactions/use-event-emmiter.js → use-event-emmiter.js} +0 -0
- /package/src/use/{app/use-favicon.js → use-favicon.js} +0 -0
- /package/src/use/{app/use-link.js → use-link.js} +0 -0
- /package/src/use/{app/use-meta.js → use-meta.js} +0 -0
- /package/src/use/{interactions/use-thread.js → use-thread.js} +0 -0
- /package/src/use/{decorators/use-throttle.js → use-throttle.js} +0 -0
- /package/src/use/{app/use-title.js → use-title.js} +0 -0
package/dist/ziko.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Thu Aug 14 2025 10:09:49 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
|
|
@@ -3293,52 +3293,16 @@ class ZikoUseMediaQuery {
|
|
|
3293
3293
|
|
|
3294
3294
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
3295
3295
|
|
|
3296
|
-
class ZikoUseRoot{
|
|
3297
|
-
constructor(props){
|
|
3298
|
-
this.props={};
|
|
3299
|
-
props && this.set(props);
|
|
3300
|
-
}
|
|
3301
|
-
get(prop){
|
|
3302
|
-
return this.props[prop]
|
|
3303
|
-
}
|
|
3304
|
-
// getStaticValue(){
|
|
3305
|
-
// return document.documentElement.style.getPropertyValue("--primary-col")
|
|
3306
|
-
// }
|
|
3307
|
-
set(props){
|
|
3308
|
-
Object.entries(props).forEach(([key,value])=>this.#setOneProp(key, value));
|
|
3309
|
-
return this;
|
|
3310
|
-
}
|
|
3311
|
-
#setOneProp(prop, value){
|
|
3312
|
-
const CssProp = `--${Str.camel2hyphencase(prop)}`;
|
|
3313
|
-
document.documentElement.style.setProperty(CssProp,value);
|
|
3314
|
-
Object.assign(this.props, {[prop]: `var(${CssProp})`});
|
|
3315
|
-
Object.assign(this, {[prop] : `var(${CssProp})`});
|
|
3316
|
-
}
|
|
3317
|
-
}
|
|
3318
|
-
|
|
3319
|
-
const useRootValue=CssVar=>{
|
|
3320
|
-
if(!CssVar.startsWith("--")) CssVar = `--${Str.camel2hyphencase(CssVar)}`;
|
|
3321
|
-
return `var(${CssVar})`
|
|
3322
|
-
};
|
|
3323
|
-
// const useRootStaticValue=CssVar=>{
|
|
3324
|
-
// if(!CssVar.startsWith("--")) CssVar = `--${Str.camel2hyphencase(CssVar)}`
|
|
3325
|
-
// return globalThis.document.documentElement.style.getPropertyValue(CssVar)
|
|
3326
|
-
// }
|
|
3327
|
-
const useRoot=(props)=>new ZikoUseRoot(props);
|
|
3328
|
-
|
|
3329
3296
|
// export * from "./window"
|
|
3330
3297
|
|
|
3331
3298
|
var Hooks = /*#__PURE__*/Object.freeze({
|
|
3332
3299
|
__proto__: null,
|
|
3333
3300
|
ZikoHead: ZikoHead$1,
|
|
3334
|
-
ZikoUseRoot: ZikoUseRoot,
|
|
3335
3301
|
ZikoUseStyle: ZikoUseStyle,
|
|
3336
3302
|
useFavIcon: useFavIcon$1,
|
|
3337
3303
|
useHead: useHead$1,
|
|
3338
3304
|
useMediaQuery: useMediaQuery,
|
|
3339
3305
|
useMeta: useMeta$1,
|
|
3340
|
-
useRoot: useRoot,
|
|
3341
|
-
useRootValue: useRootValue,
|
|
3342
3306
|
useStyle: useStyle,
|
|
3343
3307
|
useSuccesifKeys: useSuccesifKeys,
|
|
3344
3308
|
useTitle: useTitle$1
|
|
@@ -8119,6 +8083,123 @@ class ZikoUseChannel{
|
|
|
8119
8083
|
}
|
|
8120
8084
|
const useChannel = name => new ZikoUseChannel(name);
|
|
8121
8085
|
|
|
8086
|
+
class ZikoUseThreed {
|
|
8087
|
+
#workerContent;
|
|
8088
|
+
constructor() {
|
|
8089
|
+
this.#workerContent = (
|
|
8090
|
+
function (msg) {
|
|
8091
|
+
try {
|
|
8092
|
+
const func = new Function("return " + msg.data.fun)();
|
|
8093
|
+
let result = func();
|
|
8094
|
+
postMessage({ result });
|
|
8095
|
+
} catch (error) {
|
|
8096
|
+
postMessage({ error: error.message });
|
|
8097
|
+
} finally {
|
|
8098
|
+
if (msg.data.close) self.close();
|
|
8099
|
+
}
|
|
8100
|
+
}
|
|
8101
|
+
).toString();
|
|
8102
|
+
this.blob = new Blob(["this.onmessage = " + this.#workerContent], { type: "text/javascript" });
|
|
8103
|
+
this.worker = new Worker(window.URL.createObjectURL(this.blob));
|
|
8104
|
+
}
|
|
8105
|
+
call(func, callback, close = true) {
|
|
8106
|
+
this.worker.postMessage({
|
|
8107
|
+
fun: func.toString(),
|
|
8108
|
+
close
|
|
8109
|
+
});
|
|
8110
|
+
this.worker.onmessage = function (e) {
|
|
8111
|
+
if (e.data.error) {
|
|
8112
|
+
console.error(e.data.error);
|
|
8113
|
+
} else {
|
|
8114
|
+
callback(e.data.result);
|
|
8115
|
+
}
|
|
8116
|
+
};
|
|
8117
|
+
return this;
|
|
8118
|
+
}
|
|
8119
|
+
}
|
|
8120
|
+
|
|
8121
|
+
const useThread = (func, callback , close) => {
|
|
8122
|
+
const T = new ZikoUseThreed();
|
|
8123
|
+
if (func) {
|
|
8124
|
+
T.call(func, callback , close);
|
|
8125
|
+
}
|
|
8126
|
+
return T;
|
|
8127
|
+
};
|
|
8128
|
+
|
|
8129
|
+
class ZikoUseRoot {
|
|
8130
|
+
constructor(PropsMap, {namespace = 'Ziko', register, ValidateCssProps = false} = {}){
|
|
8131
|
+
this.currentPropsMap = PropsMap;
|
|
8132
|
+
this.namespace = namespace;
|
|
8133
|
+
this.ValidateCssProps = ValidateCssProps;
|
|
8134
|
+
// this.pairs = {};
|
|
8135
|
+
// this.#maintain()
|
|
8136
|
+
this.use(PropsMap);
|
|
8137
|
+
}
|
|
8138
|
+
use(PropsMap){
|
|
8139
|
+
if(this.ValidateCssProps) ValidateCssProps(PropsMap);
|
|
8140
|
+
this.currentPropsMap = PropsMap;
|
|
8141
|
+
this.#maintain();
|
|
8142
|
+
return this;
|
|
8143
|
+
}
|
|
8144
|
+
#maintain(){
|
|
8145
|
+
const root = globalThis?.document?.documentElement?.style;
|
|
8146
|
+
for(let prop in this.currentPropsMap){
|
|
8147
|
+
const cssProp = this.namespace ? `--${this.namespace}-${prop}` : `--${prop}`;
|
|
8148
|
+
root.setProperty(
|
|
8149
|
+
cssProp,
|
|
8150
|
+
this.currentPropsMap[prop]
|
|
8151
|
+
);
|
|
8152
|
+
console.log({cssProp});
|
|
8153
|
+
// Object.assign(this.pairs, {
|
|
8154
|
+
// [prop] : `var(--${this.namespace}-${prop})`
|
|
8155
|
+
// })
|
|
8156
|
+
Object.defineProperty(this, prop, {
|
|
8157
|
+
value: `var(${cssProp})`,
|
|
8158
|
+
writable: true,
|
|
8159
|
+
configurable: true,
|
|
8160
|
+
enumerable: false
|
|
8161
|
+
});
|
|
8162
|
+
}
|
|
8163
|
+
}
|
|
8164
|
+
}
|
|
8165
|
+
|
|
8166
|
+
function ValidateCssProps(PropsMap){
|
|
8167
|
+
const validProps = new Set(Object.keys(document.documentElement.style));
|
|
8168
|
+
for (let key in PropsMap) {
|
|
8169
|
+
if (!validProps.has(key)) {
|
|
8170
|
+
throw new Error(`Invalid CSS property: "${key}"`);
|
|
8171
|
+
}
|
|
8172
|
+
}
|
|
8173
|
+
}
|
|
8174
|
+
|
|
8175
|
+
const useRoot = (PropsMap, {namespace, register, ValidateCssProps} = {}) => new ZikoUseRoot(PropsMap, {namespace, register, ValidateCssProps});
|
|
8176
|
+
|
|
8177
|
+
// Usage
|
|
8178
|
+
|
|
8179
|
+
/*
|
|
8180
|
+
const Styles = {
|
|
8181
|
+
S1 : {
|
|
8182
|
+
background : 'white',
|
|
8183
|
+
color : 'darkblue'
|
|
8184
|
+
border : '2px darkblue solid"'
|
|
8185
|
+
},
|
|
8186
|
+
S2 : {
|
|
8187
|
+
background : 'darkblue',
|
|
8188
|
+
color : 'white'
|
|
8189
|
+
border : '2px green solid"'
|
|
8190
|
+
}
|
|
8191
|
+
}
|
|
8192
|
+
const {use, border, background, color} = useRoot(Style.S1)
|
|
8193
|
+
|
|
8194
|
+
tags.p("Test useRoot ").style({
|
|
8195
|
+
border,
|
|
8196
|
+
color,
|
|
8197
|
+
background,
|
|
8198
|
+
padding : '10px'
|
|
8199
|
+
})
|
|
8200
|
+
|
|
8201
|
+
*/
|
|
8202
|
+
|
|
8122
8203
|
// To do : remove old items
|
|
8123
8204
|
class ZikoUseStorage{
|
|
8124
8205
|
constructor(storage, globalKey, initialValue){
|
|
@@ -8188,49 +8269,6 @@ class ZikoUseStorage{
|
|
|
8188
8269
|
const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
|
|
8189
8270
|
const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
|
|
8190
8271
|
|
|
8191
|
-
class ZikoUseThreed {
|
|
8192
|
-
#workerContent;
|
|
8193
|
-
constructor() {
|
|
8194
|
-
this.#workerContent = (
|
|
8195
|
-
function (msg) {
|
|
8196
|
-
try {
|
|
8197
|
-
const func = new Function("return " + msg.data.fun)();
|
|
8198
|
-
let result = func();
|
|
8199
|
-
postMessage({ result });
|
|
8200
|
-
} catch (error) {
|
|
8201
|
-
postMessage({ error: error.message });
|
|
8202
|
-
} finally {
|
|
8203
|
-
if (msg.data.close) self.close();
|
|
8204
|
-
}
|
|
8205
|
-
}
|
|
8206
|
-
).toString();
|
|
8207
|
-
this.blob = new Blob(["this.onmessage = " + this.#workerContent], { type: "text/javascript" });
|
|
8208
|
-
this.worker = new Worker(window.URL.createObjectURL(this.blob));
|
|
8209
|
-
}
|
|
8210
|
-
call(func, callback, close = true) {
|
|
8211
|
-
this.worker.postMessage({
|
|
8212
|
-
fun: func.toString(),
|
|
8213
|
-
close
|
|
8214
|
-
});
|
|
8215
|
-
this.worker.onmessage = function (e) {
|
|
8216
|
-
if (e.data.error) {
|
|
8217
|
-
console.error(e.data.error);
|
|
8218
|
-
} else {
|
|
8219
|
-
callback(e.data.result);
|
|
8220
|
-
}
|
|
8221
|
-
};
|
|
8222
|
-
return this;
|
|
8223
|
-
}
|
|
8224
|
-
}
|
|
8225
|
-
|
|
8226
|
-
const useThread = (func, callback , close) => {
|
|
8227
|
-
const T = new ZikoUseThreed();
|
|
8228
|
-
if (func) {
|
|
8229
|
-
T.call(func, callback , close);
|
|
8230
|
-
}
|
|
8231
|
-
return T;
|
|
8232
|
-
};
|
|
8233
|
-
|
|
8234
8272
|
[
|
|
8235
8273
|
App,
|
|
8236
8274
|
Math$1,
|
|
@@ -8578,7 +8616,6 @@ exports.useLocaleStorage = useLocaleStorage;
|
|
|
8578
8616
|
exports.useMediaQuery = useMediaQuery;
|
|
8579
8617
|
exports.useMeta = useMeta$1;
|
|
8580
8618
|
exports.useRoot = useRoot;
|
|
8581
|
-
exports.useRootValue = useRootValue;
|
|
8582
8619
|
exports.useSessionStorage = useSessionStorage;
|
|
8583
8620
|
exports.useStyle = useStyle;
|
|
8584
8621
|
exports.useSuccesifKeys = useSuccesifKeys;
|
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 : Thu Aug 14 2025 10:09:49 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
|
|
@@ -3295,52 +3295,16 @@
|
|
|
3295
3295
|
|
|
3296
3296
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
3297
3297
|
|
|
3298
|
-
class ZikoUseRoot{
|
|
3299
|
-
constructor(props){
|
|
3300
|
-
this.props={};
|
|
3301
|
-
props && this.set(props);
|
|
3302
|
-
}
|
|
3303
|
-
get(prop){
|
|
3304
|
-
return this.props[prop]
|
|
3305
|
-
}
|
|
3306
|
-
// getStaticValue(){
|
|
3307
|
-
// return document.documentElement.style.getPropertyValue("--primary-col")
|
|
3308
|
-
// }
|
|
3309
|
-
set(props){
|
|
3310
|
-
Object.entries(props).forEach(([key,value])=>this.#setOneProp(key, value));
|
|
3311
|
-
return this;
|
|
3312
|
-
}
|
|
3313
|
-
#setOneProp(prop, value){
|
|
3314
|
-
const CssProp = `--${Str.camel2hyphencase(prop)}`;
|
|
3315
|
-
document.documentElement.style.setProperty(CssProp,value);
|
|
3316
|
-
Object.assign(this.props, {[prop]: `var(${CssProp})`});
|
|
3317
|
-
Object.assign(this, {[prop] : `var(${CssProp})`});
|
|
3318
|
-
}
|
|
3319
|
-
}
|
|
3320
|
-
|
|
3321
|
-
const useRootValue=CssVar=>{
|
|
3322
|
-
if(!CssVar.startsWith("--")) CssVar = `--${Str.camel2hyphencase(CssVar)}`;
|
|
3323
|
-
return `var(${CssVar})`
|
|
3324
|
-
};
|
|
3325
|
-
// const useRootStaticValue=CssVar=>{
|
|
3326
|
-
// if(!CssVar.startsWith("--")) CssVar = `--${Str.camel2hyphencase(CssVar)}`
|
|
3327
|
-
// return globalThis.document.documentElement.style.getPropertyValue(CssVar)
|
|
3328
|
-
// }
|
|
3329
|
-
const useRoot=(props)=>new ZikoUseRoot(props);
|
|
3330
|
-
|
|
3331
3298
|
// export * from "./window"
|
|
3332
3299
|
|
|
3333
3300
|
var Hooks = /*#__PURE__*/Object.freeze({
|
|
3334
3301
|
__proto__: null,
|
|
3335
3302
|
ZikoHead: ZikoHead$1,
|
|
3336
|
-
ZikoUseRoot: ZikoUseRoot,
|
|
3337
3303
|
ZikoUseStyle: ZikoUseStyle,
|
|
3338
3304
|
useFavIcon: useFavIcon$1,
|
|
3339
3305
|
useHead: useHead$1,
|
|
3340
3306
|
useMediaQuery: useMediaQuery,
|
|
3341
3307
|
useMeta: useMeta$1,
|
|
3342
|
-
useRoot: useRoot,
|
|
3343
|
-
useRootValue: useRootValue,
|
|
3344
3308
|
useStyle: useStyle,
|
|
3345
3309
|
useSuccesifKeys: useSuccesifKeys,
|
|
3346
3310
|
useTitle: useTitle$1
|
|
@@ -8121,6 +8085,123 @@
|
|
|
8121
8085
|
}
|
|
8122
8086
|
const useChannel = name => new ZikoUseChannel(name);
|
|
8123
8087
|
|
|
8088
|
+
class ZikoUseThreed {
|
|
8089
|
+
#workerContent;
|
|
8090
|
+
constructor() {
|
|
8091
|
+
this.#workerContent = (
|
|
8092
|
+
function (msg) {
|
|
8093
|
+
try {
|
|
8094
|
+
const func = new Function("return " + msg.data.fun)();
|
|
8095
|
+
let result = func();
|
|
8096
|
+
postMessage({ result });
|
|
8097
|
+
} catch (error) {
|
|
8098
|
+
postMessage({ error: error.message });
|
|
8099
|
+
} finally {
|
|
8100
|
+
if (msg.data.close) self.close();
|
|
8101
|
+
}
|
|
8102
|
+
}
|
|
8103
|
+
).toString();
|
|
8104
|
+
this.blob = new Blob(["this.onmessage = " + this.#workerContent], { type: "text/javascript" });
|
|
8105
|
+
this.worker = new Worker(window.URL.createObjectURL(this.blob));
|
|
8106
|
+
}
|
|
8107
|
+
call(func, callback, close = true) {
|
|
8108
|
+
this.worker.postMessage({
|
|
8109
|
+
fun: func.toString(),
|
|
8110
|
+
close
|
|
8111
|
+
});
|
|
8112
|
+
this.worker.onmessage = function (e) {
|
|
8113
|
+
if (e.data.error) {
|
|
8114
|
+
console.error(e.data.error);
|
|
8115
|
+
} else {
|
|
8116
|
+
callback(e.data.result);
|
|
8117
|
+
}
|
|
8118
|
+
};
|
|
8119
|
+
return this;
|
|
8120
|
+
}
|
|
8121
|
+
}
|
|
8122
|
+
|
|
8123
|
+
const useThread = (func, callback , close) => {
|
|
8124
|
+
const T = new ZikoUseThreed();
|
|
8125
|
+
if (func) {
|
|
8126
|
+
T.call(func, callback , close);
|
|
8127
|
+
}
|
|
8128
|
+
return T;
|
|
8129
|
+
};
|
|
8130
|
+
|
|
8131
|
+
class ZikoUseRoot {
|
|
8132
|
+
constructor(PropsMap, {namespace = 'Ziko', register, ValidateCssProps = false} = {}){
|
|
8133
|
+
this.currentPropsMap = PropsMap;
|
|
8134
|
+
this.namespace = namespace;
|
|
8135
|
+
this.ValidateCssProps = ValidateCssProps;
|
|
8136
|
+
// this.pairs = {};
|
|
8137
|
+
// this.#maintain()
|
|
8138
|
+
this.use(PropsMap);
|
|
8139
|
+
}
|
|
8140
|
+
use(PropsMap){
|
|
8141
|
+
if(this.ValidateCssProps) ValidateCssProps(PropsMap);
|
|
8142
|
+
this.currentPropsMap = PropsMap;
|
|
8143
|
+
this.#maintain();
|
|
8144
|
+
return this;
|
|
8145
|
+
}
|
|
8146
|
+
#maintain(){
|
|
8147
|
+
const root = globalThis?.document?.documentElement?.style;
|
|
8148
|
+
for(let prop in this.currentPropsMap){
|
|
8149
|
+
const cssProp = this.namespace ? `--${this.namespace}-${prop}` : `--${prop}`;
|
|
8150
|
+
root.setProperty(
|
|
8151
|
+
cssProp,
|
|
8152
|
+
this.currentPropsMap[prop]
|
|
8153
|
+
);
|
|
8154
|
+
console.log({cssProp});
|
|
8155
|
+
// Object.assign(this.pairs, {
|
|
8156
|
+
// [prop] : `var(--${this.namespace}-${prop})`
|
|
8157
|
+
// })
|
|
8158
|
+
Object.defineProperty(this, prop, {
|
|
8159
|
+
value: `var(${cssProp})`,
|
|
8160
|
+
writable: true,
|
|
8161
|
+
configurable: true,
|
|
8162
|
+
enumerable: false
|
|
8163
|
+
});
|
|
8164
|
+
}
|
|
8165
|
+
}
|
|
8166
|
+
}
|
|
8167
|
+
|
|
8168
|
+
function ValidateCssProps(PropsMap){
|
|
8169
|
+
const validProps = new Set(Object.keys(document.documentElement.style));
|
|
8170
|
+
for (let key in PropsMap) {
|
|
8171
|
+
if (!validProps.has(key)) {
|
|
8172
|
+
throw new Error(`Invalid CSS property: "${key}"`);
|
|
8173
|
+
}
|
|
8174
|
+
}
|
|
8175
|
+
}
|
|
8176
|
+
|
|
8177
|
+
const useRoot = (PropsMap, {namespace, register, ValidateCssProps} = {}) => new ZikoUseRoot(PropsMap, {namespace, register, ValidateCssProps});
|
|
8178
|
+
|
|
8179
|
+
// Usage
|
|
8180
|
+
|
|
8181
|
+
/*
|
|
8182
|
+
const Styles = {
|
|
8183
|
+
S1 : {
|
|
8184
|
+
background : 'white',
|
|
8185
|
+
color : 'darkblue'
|
|
8186
|
+
border : '2px darkblue solid"'
|
|
8187
|
+
},
|
|
8188
|
+
S2 : {
|
|
8189
|
+
background : 'darkblue',
|
|
8190
|
+
color : 'white'
|
|
8191
|
+
border : '2px green solid"'
|
|
8192
|
+
}
|
|
8193
|
+
}
|
|
8194
|
+
const {use, border, background, color} = useRoot(Style.S1)
|
|
8195
|
+
|
|
8196
|
+
tags.p("Test useRoot ").style({
|
|
8197
|
+
border,
|
|
8198
|
+
color,
|
|
8199
|
+
background,
|
|
8200
|
+
padding : '10px'
|
|
8201
|
+
})
|
|
8202
|
+
|
|
8203
|
+
*/
|
|
8204
|
+
|
|
8124
8205
|
// To do : remove old items
|
|
8125
8206
|
class ZikoUseStorage{
|
|
8126
8207
|
constructor(storage, globalKey, initialValue){
|
|
@@ -8190,49 +8271,6 @@
|
|
|
8190
8271
|
const useLocaleStorage=(key,initialValue)=>new ZikoUseStorage(localStorage,key,initialValue);
|
|
8191
8272
|
const useSessionStorage=(key,initialValue)=>new ZikoUseStorage(sessionStorage,key,initialValue);
|
|
8192
8273
|
|
|
8193
|
-
class ZikoUseThreed {
|
|
8194
|
-
#workerContent;
|
|
8195
|
-
constructor() {
|
|
8196
|
-
this.#workerContent = (
|
|
8197
|
-
function (msg) {
|
|
8198
|
-
try {
|
|
8199
|
-
const func = new Function("return " + msg.data.fun)();
|
|
8200
|
-
let result = func();
|
|
8201
|
-
postMessage({ result });
|
|
8202
|
-
} catch (error) {
|
|
8203
|
-
postMessage({ error: error.message });
|
|
8204
|
-
} finally {
|
|
8205
|
-
if (msg.data.close) self.close();
|
|
8206
|
-
}
|
|
8207
|
-
}
|
|
8208
|
-
).toString();
|
|
8209
|
-
this.blob = new Blob(["this.onmessage = " + this.#workerContent], { type: "text/javascript" });
|
|
8210
|
-
this.worker = new Worker(window.URL.createObjectURL(this.blob));
|
|
8211
|
-
}
|
|
8212
|
-
call(func, callback, close = true) {
|
|
8213
|
-
this.worker.postMessage({
|
|
8214
|
-
fun: func.toString(),
|
|
8215
|
-
close
|
|
8216
|
-
});
|
|
8217
|
-
this.worker.onmessage = function (e) {
|
|
8218
|
-
if (e.data.error) {
|
|
8219
|
-
console.error(e.data.error);
|
|
8220
|
-
} else {
|
|
8221
|
-
callback(e.data.result);
|
|
8222
|
-
}
|
|
8223
|
-
};
|
|
8224
|
-
return this;
|
|
8225
|
-
}
|
|
8226
|
-
}
|
|
8227
|
-
|
|
8228
|
-
const useThread = (func, callback , close) => {
|
|
8229
|
-
const T = new ZikoUseThreed();
|
|
8230
|
-
if (func) {
|
|
8231
|
-
T.call(func, callback , close);
|
|
8232
|
-
}
|
|
8233
|
-
return T;
|
|
8234
|
-
};
|
|
8235
|
-
|
|
8236
8274
|
[
|
|
8237
8275
|
App,
|
|
8238
8276
|
Math$1,
|
|
@@ -8580,7 +8618,6 @@
|
|
|
8580
8618
|
exports.useMediaQuery = useMediaQuery;
|
|
8581
8619
|
exports.useMeta = useMeta$1;
|
|
8582
8620
|
exports.useRoot = useRoot;
|
|
8583
|
-
exports.useRootValue = useRootValue;
|
|
8584
8621
|
exports.useSessionStorage = useSessionStorage;
|
|
8585
8622
|
exports.useStyle = useStyle;
|
|
8586
8623
|
exports.useSuccesifKeys = useSuccesifKeys;
|