ziko 1.0.0 → 1.1.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 +169 -358
- package/dist/ziko.js +169 -358
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +167 -343
- package/package.json +1 -1
- package/src/app/params.js +3 -6
- package/src/app/spa-file-based-routing.js +1 -1
- package/src/app/spa.js +1 -1
- package/src/data/converter/index.js +6 -6
- package/src/data/converter/object.js +6 -2
- package/src/data/converter/svg.js +1 -1
- package/src/hooks/index.d.ts +2 -1
- package/src/hooks/index.js +3 -1
- package/src/hooks/use-query-params.d.ts +31 -0
- package/src/hooks/use-query-params.js +71 -0
- package/src/hooks/use-reactive.js +1 -1
- package/src/index.js +1 -1
- package/src/math/functions/mapfun/index.d.ts +1 -1
- package/src/math/index.d.ts.txt +5 -0
- package/src/math/index.js +4 -4
- package/src/math/utils/index.js +100 -94
- package/src/math/utils/mapfun.js +1 -2
- package/src/math/index.d.ts +0 -5
- /package/src/math/functions/utils/{mapfun.d.ts → mapfun.d.ts.txt} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"front-end",
|
package/src/app/params.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
function parseQueryParams(queryString) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
params[key] = value;
|
|
6
|
-
});
|
|
7
|
-
return params;
|
|
2
|
+
return Object.fromEntries(
|
|
3
|
+
new URLSearchParams(location.search)
|
|
4
|
+
);
|
|
8
5
|
}
|
|
9
6
|
|
|
10
7
|
function defineParamsGetter(target ){
|
package/src/app/spa.js
CHANGED
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
svg2imgUrl,
|
|
23
23
|
svg2img
|
|
24
24
|
} from "./svg.js";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
// export{
|
|
26
|
+
// obj2str
|
|
27
|
+
// } from "./object.js"
|
|
28
|
+
// export{
|
|
29
|
+
// arr2str
|
|
30
|
+
// } from "./array.js"
|
|
31
31
|
export{
|
|
32
32
|
json2css
|
|
33
33
|
} from "./css.js"
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { arr2str } from "../index.js";
|
|
2
|
-
import { Complex, mapfun, Matrix } from "../../math/index.js";
|
|
1
|
+
// import { arr2str } from "../index.js";
|
|
2
|
+
// import { Complex, mapfun, Matrix } from "../../math/index.js";
|
|
3
|
+
|
|
4
|
+
import { Complex } from "../../math/complex/index.js";
|
|
5
|
+
import { Matrix } from "../../math/matrix/index.js";
|
|
6
|
+
import { mapfun } from "../../math/functions/utils/mapfun.js";
|
|
3
7
|
|
|
4
8
|
// const obj2str=(object)=>{
|
|
5
9
|
// const recursiveToString = (obj) => {
|
package/src/hooks/index.d.ts
CHANGED
|
@@ -8,4 +8,5 @@ export type * from './use-event-emitter.d.ts'
|
|
|
8
8
|
export type * from './use-media-query.d.ts'
|
|
9
9
|
export type * from './use-title.d.ts'
|
|
10
10
|
export type * from './use-favicon.d.ts'
|
|
11
|
-
export type * from './use-root.d.ts'
|
|
11
|
+
export type * from './use-root.d.ts'
|
|
12
|
+
export type * from './use-query-params.d.ts'
|
package/src/hooks/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type QueryParams = Record<string, string>;
|
|
2
|
+
|
|
3
|
+
export type SetQueryParams = (
|
|
4
|
+
updates:
|
|
5
|
+
| QueryParams
|
|
6
|
+
| ((current: QueryParams) => QueryParams),
|
|
7
|
+
merge?: boolean
|
|
8
|
+
) => void;
|
|
9
|
+
|
|
10
|
+
export type GetQueryParams = () => QueryParams;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Reactive query params hook-like utility
|
|
14
|
+
* Returns:
|
|
15
|
+
* - getParams: function that returns current query params
|
|
16
|
+
* - setParams: function to update query params
|
|
17
|
+
*/
|
|
18
|
+
export function useQueryParams(): [
|
|
19
|
+
GetQueryParams,
|
|
20
|
+
SetQueryParams
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Watches URL query parameters changes.
|
|
25
|
+
* Calls callback only when params actually change.
|
|
26
|
+
*
|
|
27
|
+
* Returns an unsubscribe function.
|
|
28
|
+
*/
|
|
29
|
+
export function watchQueryParams(
|
|
30
|
+
callback: (params: QueryParams) => void
|
|
31
|
+
): () => void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useState } from "./use-state.js";
|
|
2
|
+
const parseQueryParams = queryString => Object.fromEntries(new URLSearchParams(globalThis?.location?.search))
|
|
3
|
+
|
|
4
|
+
export function useQueryParams() {
|
|
5
|
+
const getParams = () =>
|
|
6
|
+
parseQueryParams(window.location.search);
|
|
7
|
+
|
|
8
|
+
const setParams = (updates, merge = true) => {
|
|
9
|
+
const current = getParams();
|
|
10
|
+
|
|
11
|
+
const next =
|
|
12
|
+
typeof updates === "function"
|
|
13
|
+
? updates(current)
|
|
14
|
+
: updates;
|
|
15
|
+
|
|
16
|
+
const finalParams = merge
|
|
17
|
+
? { ...current, ...next }
|
|
18
|
+
: next;
|
|
19
|
+
|
|
20
|
+
const search = new URLSearchParams(finalParams).toString();
|
|
21
|
+
|
|
22
|
+
window.history.pushState(
|
|
23
|
+
{},
|
|
24
|
+
"",
|
|
25
|
+
`${window.location.pathname}${search ? `?${search}` : ""}`
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
window.dispatchEvent(
|
|
29
|
+
new CustomEvent("queryparamschange", {
|
|
30
|
+
detail: finalParams
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return [getParams, setParams];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function watchQueryParams(callback) {
|
|
39
|
+
let previousSearch = location.search;
|
|
40
|
+
|
|
41
|
+
const notify = () => {
|
|
42
|
+
const currentSearch = location.search;
|
|
43
|
+
|
|
44
|
+
if (currentSearch === previousSearch) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
previousSearch = currentSearch;
|
|
49
|
+
callback(parseQueryParams(currentSearch));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
window.addEventListener("popstate", notify);
|
|
53
|
+
|
|
54
|
+
const pushState = history.pushState;
|
|
55
|
+
history.pushState = function (...args) {
|
|
56
|
+
pushState.apply(this, args);
|
|
57
|
+
notify();
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const replaceState = history.replaceState;
|
|
61
|
+
history.replaceState = function (...args) {
|
|
62
|
+
replaceState.apply(this, args);
|
|
63
|
+
notify();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
callback(parseQueryParams(location.search));
|
|
67
|
+
|
|
68
|
+
return () => {
|
|
69
|
+
window.removeEventListener("popstate", notify);
|
|
70
|
+
};
|
|
71
|
+
}
|
package/src/index.js
CHANGED
package/src/math/index.js
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
// }
|
|
17
17
|
export * from "./const.js"
|
|
18
18
|
export * from "./functions/index.js"
|
|
19
|
-
export * from "./complex"
|
|
20
|
-
export * from "./matrix"
|
|
19
|
+
export * from "./complex/index.js"
|
|
20
|
+
export * from "./matrix/index.js"
|
|
21
21
|
// export * from "./discret"
|
|
22
|
-
export * from "./random"
|
|
23
|
-
export * from "./utils"
|
|
22
|
+
export * from "./random/index.js"
|
|
23
|
+
// export * from "./utils/index.js" // To Check
|
|
24
24
|
// export * from "./statistics"
|
|
25
25
|
// export default Math;
|
|
26
26
|
|
package/src/math/utils/index.js
CHANGED
|
@@ -1,102 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// map,
|
|
16
|
-
// clamp,
|
|
17
|
-
arange,
|
|
18
|
-
linspace,
|
|
19
|
-
logspace,
|
|
20
|
-
geomspace
|
|
21
|
-
} from "../signal/functions.js"
|
|
1
|
+
export * from './arithmetic.js'
|
|
2
|
+
export * from './checkers.js'
|
|
3
|
+
export * from './comparaison.js'
|
|
4
|
+
export * from './conversions.js'
|
|
5
|
+
export * from './discret.js'
|
|
6
|
+
// export * from './mapfun.js'
|
|
7
|
+
// // import { mapfun } from "../mapfun/index.js";
|
|
8
|
+
// // import {
|
|
9
|
+
// // add,
|
|
10
|
+
// // sub,
|
|
11
|
+
// // mul,
|
|
12
|
+
// // div,
|
|
13
|
+
// // modulo
|
|
14
|
+
// // } from "./arithmetic.js";
|
|
22
15
|
// import {
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
16
|
+
// zeros,
|
|
17
|
+
// ones,
|
|
18
|
+
// nums,
|
|
19
|
+
// // norm,
|
|
20
|
+
// // lerp,
|
|
21
|
+
// // map,
|
|
22
|
+
// // clamp,
|
|
23
|
+
// arange,
|
|
24
|
+
// linspace,
|
|
25
|
+
// logspace,
|
|
26
|
+
// geomspace
|
|
27
|
+
// } from "../signal/functions.js"
|
|
28
|
+
// // import {
|
|
29
|
+
// // deg2rad,
|
|
30
|
+
// // rad2deg
|
|
31
|
+
// // } from "./conversions.js"
|
|
32
|
+
// // import{
|
|
33
|
+
// // sum,
|
|
34
|
+
// // prod,
|
|
35
|
+
// // accum
|
|
36
|
+
// // } from "../statistics/index.js"
|
|
26
37
|
// import{
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} from "./
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// add,
|
|
42
|
-
// sub,
|
|
43
|
-
// mul,
|
|
44
|
-
// div,
|
|
45
|
-
// modulo,
|
|
38
|
+
// inRange,
|
|
39
|
+
// isApproximatlyEqual
|
|
40
|
+
// } from "./checkers.js"
|
|
41
|
+
// import{
|
|
42
|
+
// cartesianProduct,
|
|
43
|
+
// ppcm,
|
|
44
|
+
// pgcd
|
|
45
|
+
// } from "./discret.js"
|
|
46
|
+
// const Utils={
|
|
47
|
+
// // add,
|
|
48
|
+
// // sub,
|
|
49
|
+
// // mul,
|
|
50
|
+
// // div,
|
|
51
|
+
// // modulo,
|
|
46
52
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
// zeros,
|
|
54
|
+
// ones,
|
|
55
|
+
// nums,
|
|
56
|
+
// // norm,
|
|
57
|
+
// // lerp,
|
|
58
|
+
// // map,
|
|
59
|
+
// // clamp,
|
|
60
|
+
// arange,
|
|
61
|
+
// linspace,
|
|
62
|
+
// logspace,
|
|
63
|
+
// geomspace,
|
|
58
64
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
// // sum,
|
|
66
|
+
// // prod,
|
|
67
|
+
// // accum,
|
|
62
68
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
// cartesianProduct,
|
|
70
|
+
// ppcm,
|
|
71
|
+
// pgcd,
|
|
66
72
|
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
// // deg2rad,
|
|
74
|
+
// // rad2deg,
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
76
|
+
// inRange,
|
|
77
|
+
// isApproximatlyEqual
|
|
78
|
+
// }
|
|
79
|
+
// export {
|
|
80
|
+
// // mapfun,
|
|
81
|
+
// Utils,
|
|
82
|
+
// zeros,
|
|
83
|
+
// ones,
|
|
84
|
+
// nums,
|
|
85
|
+
// // sum,
|
|
86
|
+
// // prod,
|
|
87
|
+
// // add,
|
|
88
|
+
// // mul,
|
|
89
|
+
// // sub,
|
|
90
|
+
// // div,
|
|
91
|
+
// // modulo,
|
|
92
|
+
// // rad2deg,
|
|
93
|
+
// // deg2rad,
|
|
94
|
+
// arange,
|
|
95
|
+
// linspace,
|
|
96
|
+
// logspace,
|
|
97
|
+
// geomspace,
|
|
98
|
+
// // norm,
|
|
99
|
+
// // lerp,
|
|
100
|
+
// // map,
|
|
101
|
+
// // clamp,
|
|
102
|
+
// pgcd,
|
|
103
|
+
// ppcm,
|
|
104
|
+
// isApproximatlyEqual,
|
|
105
|
+
// inRange,
|
|
106
|
+
// cartesianProduct,
|
|
107
|
+
// };
|
|
102
108
|
|
package/src/math/utils/mapfun.js
CHANGED
package/src/math/index.d.ts
DELETED
|
File without changes
|