ziko 0.37.0 → 0.38.0
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 +1160 -3365
- package/dist/ziko.js +6179 -8384
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +1153 -3251
- package/package.json +15 -13
- package/readme.md +79 -5
- package/src/__ziko__/__cache__.js +6 -0
- package/src/__ziko__/__config__.js +19 -0
- package/src/__ziko__/__hydration__.js +8 -0
- package/src/__ziko__/__ui__.js +22 -0
- package/src/__ziko__/index.js +16 -0
- package/src/__ziko__/params.js +40 -0
- package/src/app/globals.js +14 -0
- package/src/app/index.js +4 -4
- package/src/app/spa-file-based-routing.js +2 -2
- package/src/app/ziko-app.js +1 -1
- package/src/data/converter/svg.js +2 -2
- package/src/hooks/index.js +3 -0
- package/src/hooks/use-derived.js +61 -0
- package/src/hooks/use-reactive.js +7 -0
- package/src/hooks/use-state.js +47 -0
- package/src/index.js +1 -78
- package/src/math/complex/index.js +3 -0
- package/src/math/functions/index.js +23 -23
- package/src/math/functions/proxy.js +58 -0
- package/src/math/utils/mapfun.js +17 -21
- package/src/no-module.js +32 -0
- package/src/time/{animation.js → animation/index.js} +2 -2
- package/src/time/decorators/index.js +17 -0
- package/src/time/index.js +11 -12
- package/src/time/utils/index.js +0 -1
- package/src/ui/{methods → __methods__}/dom.js +15 -14
- package/src/ui/{utils → __utils__}/index.js +1 -1
- package/src/ui/constructors/{ziko-ui-element.js → ZikoUIElement.js} +9 -98
- package/src/ui/constructors/ZikoUIElementMethodesToBeMoved.js +96 -0
- package/src/ui/{style → constructors/style}/index.js +3 -3
- package/src/ui/{elements/flex → flex}/index.js +1 -1
- package/src/{graphics/canvas/index.js → ui/graphics/canvas.js} +4 -5
- package/src/ui/graphics/index.js +2 -0
- package/src/{graphics/svg/index.js → ui/graphics/svg.js} +1 -1
- package/src/ui/{elements/grid → grid}/index.js +1 -1
- package/src/ui/index.js +9 -40
- package/src/ui/{elements/misc/suspense.js → suspense/index.js} +1 -15
- package/src/ui/tags/index.js +3 -3
- package/src/ui/text/index.js +15 -0
- package/src/ui/{elements/misc/xml-wrapper.js → wrapper/index.js} +1 -1
- package/src/use/index.js +3 -7
- package/src/graphics/canvas/_canvas_offscreen +0 -0
- package/src/graphics/canvas/utils/color.js +0 -8
- package/src/graphics/canvas/utils/floodFill.js +0 -57
- package/src/graphics/index.js +0 -10
- package/src/time/utils/decorators.js +0 -17
- package/src/ui/elements/embaded/html.js +0 -20
- package/src/ui/elements/embaded/index.js +0 -3
- package/src/ui/elements/embaded/pdf.js +0 -17
- package/src/ui/elements/embaded/youtube.js +0 -24
- package/src/ui/elements/hydrate.js +0 -0
- package/src/ui/elements/index.js +0 -10
- package/src/ui/elements/io/Form/index.js +0 -42
- package/src/ui/elements/io/Form/index.js.txt +0 -104
- package/src/ui/elements/io/Inputs/__helpers__.js +0 -52
- package/src/ui/elements/io/Inputs/index.js +0 -12
- package/src/ui/elements/io/Inputs/input/index.js +0 -99
- package/src/ui/elements/io/Inputs/input-camera/index.js +0 -26
- package/src/ui/elements/io/Inputs/input-checkbox/index.js +0 -26
- package/src/ui/elements/io/Inputs/input-color/index.js +0 -16
- package/src/ui/elements/io/Inputs/input-date-time/index.js +0 -3
- package/src/ui/elements/io/Inputs/input-date-time/input-date-time.js +0 -14
- package/src/ui/elements/io/Inputs/input-date-time/input-date.js +0 -14
- package/src/ui/elements/io/Inputs/input-date-time/input-time.js +0 -14
- package/src/ui/elements/io/Inputs/input-email-password/index.js +0 -2
- package/src/ui/elements/io/Inputs/input-email-password/input-email.js +0 -15
- package/src/ui/elements/io/Inputs/input-email-password/input-password.js +0 -14
- package/src/ui/elements/io/Inputs/input-file/index.js +0 -1
- package/src/ui/elements/io/Inputs/input-file/input-file.js +0 -0
- package/src/ui/elements/io/Inputs/input-file/input-image.js +0 -43
- package/src/ui/elements/io/Inputs/input-number/index.js +0 -37
- package/src/ui/elements/io/Inputs/input-radio/index.js +0 -26
- package/src/ui/elements/io/Inputs/input-search/index.js +0 -45
- package/src/ui/elements/io/Inputs/input-slider/index.js +0 -34
- package/src/ui/elements/io/Select/index.js +0 -20
- package/src/ui/elements/io/Textarea/index.js +0 -18
- package/src/ui/elements/io/index.js +0 -4
- package/src/ui/elements/list/elements.js +0 -0
- package/src/ui/elements/list/index.js +0 -138
- package/src/ui/elements/media/Audio/index.js +0 -17
- package/src/ui/elements/media/Image/figure.js +0 -19
- package/src/ui/elements/media/Image/image.js +0 -37
- package/src/ui/elements/media/Image/index.js +0 -2
- package/src/ui/elements/media/Video/index.js +0 -27
- package/src/ui/elements/media/__ZikoUIDynamicMediaELement__.js +0 -47
- package/src/ui/elements/media/index.js +0 -3
- package/src/ui/elements/misc/hyperscript.js +0 -144
- package/src/ui/elements/misc/index.js +0 -101
- package/src/ui/elements/semantic/index.js +0 -42
- package/src/ui/elements/table/elements.js +0 -94
- package/src/ui/elements/table/index.js +0 -3
- package/src/ui/elements/table/table.js +0 -115
- package/src/ui/elements/table/utils.js +0 -12
- package/src/ui/elements/text/__ZikoUIText__.js +0 -70
- package/src/ui/elements/text/heading.js +0 -36
- package/src/ui/elements/text/index.js +0 -3
- package/src/ui/elements/text/p.js +0 -26
- package/src/ui/elements/text/pre.js +0 -0
- package/src/ui/elements/text/text.js +0 -81
- package/src/use/use-debounce.js +0 -4
- package/src/use/use-state.js +0 -22
- package/src/use/use-throttle.js +0 -9
- /package/src/reactivity/hooks/{Head → head}/_useCssText.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/index.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/useFavIcon.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/useHead.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/useMeta.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/useTitle.js +0 -0
- /package/src/time/{loop.js → loop/index.js} +0 -0
- /package/src/ui/{methods → __methods__}/events.js +0 -0
- /package/src/ui/{methods → __methods__}/indexing.js +0 -0
- /package/src/ui/{methods → __methods__}/observer.js +0 -0
- /package/src/ui/{methods → __methods__}/style.js +0 -0
- /package/src/ui/constructors/{ziko-ui-node.js → ZikoUINode.js} +0 -0
- /package/src/ui/tags/{tags.js → tags-list.js} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
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",
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"LICENCE"
|
|
25
25
|
],
|
|
26
26
|
"exports": {
|
|
27
|
-
"./*"
|
|
27
|
+
"./*": "./src/*",
|
|
28
28
|
".": {
|
|
29
29
|
"import": "./dist/ziko.mjs",
|
|
30
30
|
"require": "./dist/ziko.cjs"
|
|
31
31
|
},
|
|
32
32
|
"./math": {
|
|
33
|
-
"import"
|
|
33
|
+
"import": "./src/math/index.js"
|
|
34
34
|
},
|
|
35
35
|
"./helpers": {
|
|
36
|
-
"import"
|
|
36
|
+
"import": "./src/__helpers__.js"
|
|
37
37
|
},
|
|
38
38
|
"./events": {
|
|
39
39
|
"import": "./src/events/index.js"
|
|
@@ -44,11 +44,14 @@
|
|
|
44
44
|
"./use": {
|
|
45
45
|
"import": "./src/use/index.js"
|
|
46
46
|
},
|
|
47
|
-
"./
|
|
47
|
+
"./hooks": {
|
|
48
|
+
"import": "./src/hooks/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./ui": {
|
|
48
51
|
"import": "./src/ui/index.js",
|
|
49
52
|
"type": "./src/ui/index.d.ts"
|
|
50
53
|
},
|
|
51
|
-
"./tags":{
|
|
54
|
+
"./tags": {
|
|
52
55
|
"import": "./src/tags/index.js"
|
|
53
56
|
},
|
|
54
57
|
"./src": "./src/index.js",
|
|
@@ -56,13 +59,12 @@
|
|
|
56
59
|
"./app": {},
|
|
57
60
|
"./time": {},
|
|
58
61
|
"./components": {}
|
|
59
|
-
|
|
60
62
|
},
|
|
61
63
|
"bin": {
|
|
62
64
|
"create-ziko-app": "starter/bin/index.js"
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
|
-
"test": "npx
|
|
67
|
+
"test": "npx vitest",
|
|
66
68
|
"test-link": "node _link/index.js",
|
|
67
69
|
"lint": "eslint src/*/*/*",
|
|
68
70
|
"dev": "cross-env NODE_ENV=development rollup --config rollup.config.js",
|
|
@@ -83,13 +85,13 @@
|
|
|
83
85
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
84
86
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
85
87
|
"@rollup/plugin-terser": "^0.4.4",
|
|
88
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
86
89
|
"cross-env": "^7.0.3",
|
|
87
90
|
"eslint": "^8.57.1",
|
|
88
|
-
"
|
|
89
|
-
"eslint-plugin-spellcheck": "^0.0.20",
|
|
90
|
-
"jasmine": "^5.3.0",
|
|
91
|
+
"jsdom": "^26.1.0",
|
|
91
92
|
"rollup": "^4.1.5",
|
|
92
93
|
"rollup-plugin-livereload": "^2.0.5",
|
|
93
|
-
"rollup-plugin-serve": "^1.1.1"
|
|
94
|
+
"rollup-plugin-serve": "^1.1.1",
|
|
95
|
+
"vitest": "^3.2.4"
|
|
94
96
|
}
|
|
95
|
-
}
|
|
97
|
+
}
|
package/readme.md
CHANGED
|
@@ -21,22 +21,96 @@ Composition
|
|
|
21
21
|
- 🚫 Zero Dependency
|
|
22
22
|
- 🌳 Partial Tree Shaking
|
|
23
23
|
- 🔢 Rich Math Functions and Utilities
|
|
24
|
+
- <details>
|
|
25
|
+
<summary>Flexible Math Functions</summary>
|
|
26
|
+
ZikoJS offers flexible math utilities, such as the `mapfun` function, which allows mapping standard mathematical operations to complex and nested data structures.
|
|
27
|
+
For example, the `cos` function in ZikoJS is built on top of mapfun, enabling it to handle multiple arguments with diverse types (numbers, arrays, objects).
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { cos, PI } from "ziko";
|
|
31
|
+
const result = cos(PI, PI / 2, PI / 4, [PI / 6, PI / 3], {
|
|
32
|
+
x: PI / 2,
|
|
33
|
+
y: PI / 4,
|
|
34
|
+
z: [0, PI / 12],
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
/*
|
|
38
|
+
result =>
|
|
39
|
+
[
|
|
40
|
+
-1,
|
|
41
|
+
0,
|
|
42
|
+
0.707106781186548,
|
|
43
|
+
[0.866025403784439, 0.5],
|
|
44
|
+
{
|
|
45
|
+
x: 0,
|
|
46
|
+
y: 0.707106781186548,
|
|
47
|
+
z: [1, 0.965925826289068],
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
*/
|
|
51
|
+
// console.log(result)
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
You can also built your own flexible Math function using this mapfun util :
|
|
55
|
+
```js
|
|
56
|
+
import { mapfun } from "ziko";
|
|
57
|
+
const parabolic_func = (a, b, c, x) => a * x ** 2 + b * x + c;
|
|
58
|
+
const map_parabolic_func =
|
|
59
|
+
(a, b, c) =>
|
|
60
|
+
(...X) =>
|
|
61
|
+
mapfun((n) => parabolic_func(a, b, c, n), ...X);
|
|
62
|
+
const a = -1.5,
|
|
63
|
+
b = 2,
|
|
64
|
+
c = 3;
|
|
65
|
+
const X = [0, 1, 2, 3];
|
|
66
|
+
console.log(parabolic_func(a, b, c)(X));
|
|
67
|
+
// [3,3,1,3]
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
</details>
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
24
74
|
<!-- - The Math Module supports a new Paradigm -->
|
|
25
75
|
- ✨ Hyperscript-Based Declarative UI (No Template Engines needed)
|
|
76
|
+
```js
|
|
77
|
+
import {p, text, Random} from 'ziko'
|
|
78
|
+
const Hello = name => p(
|
|
79
|
+
text("Hello ", name)
|
|
80
|
+
).onClick(e => e.target.style({color : Random.color()}))
|
|
81
|
+
```
|
|
82
|
+
- 🔄 Built in State Mangement :
|
|
83
|
+
```js
|
|
84
|
+
import { tags } from 'ziko/ui'
|
|
85
|
+
import {useState, useDerived} from 'ziko/hooks'
|
|
86
|
+
const [timer, setTimer] = useState(0);
|
|
87
|
+
const converToHMS = seconds => `${Math.floor(seconds / 3600)} : ${Math.floor((seconds % 3600) / 60)} : ${seconds % 60} `
|
|
88
|
+
const [time] = useDerived(t => converToHMS(t) , [timer] )
|
|
89
|
+
tags.p('Elapsed Time : ', time)
|
|
90
|
+
let i = 1;
|
|
91
|
+
setInterval(()=>{
|
|
92
|
+
setTimer(i);
|
|
93
|
+
i++
|
|
94
|
+
}, 1000)
|
|
95
|
+
```
|
|
26
96
|
- 📱 Single Page Application With File Based Routing
|
|
97
|
+
```js
|
|
98
|
+
import { FileBasedRouting } from "ziko";
|
|
99
|
+
FileBasedRouting(import.meta.glob("./src/pages/**/*.js"))
|
|
100
|
+
```
|
|
27
101
|
- 🤝 One Way Interleaving With [Vanjs]()
|
|
28
102
|
- ⏰ Time loop and animations support
|
|
29
103
|
|
|
30
104
|
### 🚀 External :
|
|
31
|
-
- 🧩 Extra UI Components : [Zextra]()
|
|
32
|
-
- 🖥️ Server Side Rendering With File Based Routing and Client Side Hydration : [ziko-server]()
|
|
33
|
-
- 📝 Mdx-Like Markdown Preprocessor : [Mdz]()
|
|
34
|
-
- 🔌 Flexible Integration with Popular Frameworks/Libraries : [Ziko-wrapper]()
|
|
105
|
+
- 🧩 Extra UI Components : [Zextra](https://github.com/zakarialaoui10/zextra)
|
|
106
|
+
- 🖥️ Server Side Rendering With File Based Routing and Client Side Hydration : [ziko-server](https://github.com/zakarialaoui10/ziko-server)
|
|
107
|
+
- 📝 Mdx-Like Markdown Preprocessor : [Mdz](https://github.com/zakarialaoui10/mdz)
|
|
108
|
+
- 🔌 Flexible Integration with Popular Frameworks/Libraries : [Ziko-wrapper](https://github.com/zakarialaoui10/ziko-wrapper)
|
|
35
109
|
- 🔄 Bi-directional : `React`, `Preact`, `Solid`, `Svelte`, `Vue` , `Vanjs`
|
|
36
110
|
- ➡️ Uni-directional (ZikoJS → X) :
|
|
37
111
|
- `Astro` : (SSR + Client Hydration)
|
|
38
112
|
- 📦 Growing Add-On Ecosystem :
|
|
39
|
-
- Ziko-Gl : WebGL/3D Graphics, Built on Top of [Threejs]()
|
|
113
|
+
- Ziko-Gl : WebGL/3D Graphics, Built on Top of [Threejs](https://github.com/zakarialaoui10/ziko-gl)
|
|
40
114
|
- Ziko-Chart
|
|
41
115
|
- Ziko-Code
|
|
42
116
|
- Ziko-Lottie
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const __Config__ = {
|
|
2
|
+
default:{
|
|
3
|
+
target:null,
|
|
4
|
+
render:true,
|
|
5
|
+
math:{
|
|
6
|
+
mode:"deg"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
setDefault:function(pairs){
|
|
10
|
+
const keys=Object.keys(pairs);
|
|
11
|
+
const values=Object.values(pairs);
|
|
12
|
+
for(let i=0; i<keys.length; i++) this.default[keys[i]]=values[i];
|
|
13
|
+
},
|
|
14
|
+
init:()=>{
|
|
15
|
+
// document.documentElement.setAttribute("data-engine","zikojs")
|
|
16
|
+
},
|
|
17
|
+
renderingMode :"spa",
|
|
18
|
+
isSSC : false,
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const __UI__={
|
|
2
|
+
__all__(){
|
|
3
|
+
return Object.values(this)
|
|
4
|
+
.filter(Array.isArray)
|
|
5
|
+
.flat();
|
|
6
|
+
},
|
|
7
|
+
querySelectorAll(){
|
|
8
|
+
return this.__all__().filter(n=>n)
|
|
9
|
+
},
|
|
10
|
+
getElementByIndex(index){
|
|
11
|
+
return this.__all__().find(n=>n.ui_index===index);
|
|
12
|
+
},
|
|
13
|
+
getElementById(id){
|
|
14
|
+
return null;
|
|
15
|
+
},
|
|
16
|
+
getElementsByClass(){
|
|
17
|
+
|
|
18
|
+
},
|
|
19
|
+
getElementsByTagName(){
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineParamsGetter } from './params.js';
|
|
2
|
+
import { __UI__ } from './__ui__.js';
|
|
3
|
+
import { __Config__ } from './__config__.js';
|
|
4
|
+
import { __HYDRATION__, __HYDRATION_MAP__ } from './__hydration__.js';
|
|
5
|
+
import { __CACHE__ } from './__cache__.js';
|
|
6
|
+
|
|
7
|
+
if ( !globalThis?.__Ziko__ ){
|
|
8
|
+
globalThis.__Ziko__ = {
|
|
9
|
+
__UI__,
|
|
10
|
+
__HYDRATION__,
|
|
11
|
+
__HYDRATION_MAP__,
|
|
12
|
+
__Config__,
|
|
13
|
+
__CACHE__,
|
|
14
|
+
};
|
|
15
|
+
defineParamsGetter(__Ziko__)
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function parseQueryParams(queryString) {
|
|
2
|
+
const params = {};
|
|
3
|
+
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
4
|
+
const [key, value] = match.split('=');
|
|
5
|
+
params[key] = value;
|
|
6
|
+
});
|
|
7
|
+
return params;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function defineParamsGetter(target ){
|
|
11
|
+
Object.defineProperties(target, {
|
|
12
|
+
'QueryParams': {
|
|
13
|
+
get: function() {
|
|
14
|
+
return parseQueryParams(globalThis.location.search.substring(1));
|
|
15
|
+
},
|
|
16
|
+
configurable: false,
|
|
17
|
+
enumerable: true
|
|
18
|
+
},
|
|
19
|
+
'HashParams': {
|
|
20
|
+
get: function() {
|
|
21
|
+
const hash = globalThis.location.hash.substring(1);
|
|
22
|
+
return hash.split("#");
|
|
23
|
+
},
|
|
24
|
+
configurable: false,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
|
|
33
|
+
/users?name=ziko&age=26
|
|
34
|
+
/users#name=ziko
|
|
35
|
+
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
export{
|
|
39
|
+
defineParamsGetter
|
|
40
|
+
}
|
package/src/app/globals.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineParamsGetter } from './params.js'
|
|
1
2
|
const __UI__={
|
|
2
3
|
__all__(){
|
|
3
4
|
return Object.values(this)
|
|
@@ -53,6 +54,19 @@ const __CACHE__ = {
|
|
|
53
54
|
return this.ui_index ++
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
if ( !globalThis?.__Ziko__ ){
|
|
58
|
+
globalThis.__Ziko__ = {
|
|
59
|
+
// ...Ziko,
|
|
60
|
+
__UI__,
|
|
61
|
+
__HYDRATION__,
|
|
62
|
+
__HYDRATION_MAP__,
|
|
63
|
+
__Config__,
|
|
64
|
+
__CACHE__,
|
|
65
|
+
// ExtractAll,
|
|
66
|
+
// RemoveAll
|
|
67
|
+
};
|
|
68
|
+
defineParamsGetter(__Ziko__)
|
|
69
|
+
}
|
|
56
70
|
export {
|
|
57
71
|
__UI__,
|
|
58
72
|
__HYDRATION_MAP__,
|
package/src/app/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export * from "./ziko-app.js";
|
|
2
2
|
export * from "./spa.js"
|
|
3
3
|
export * from "./params.js"
|
|
4
|
-
export * from "./globals.js"
|
|
4
|
+
// export * from "./globals.js"
|
|
5
5
|
export * from "./spa-file-based-routing.js"
|
|
6
6
|
|
|
7
7
|
import * as __App__ from "./ziko-app.js"
|
|
8
8
|
import * as Spa from "./spa.js"
|
|
9
|
-
import * as Global from "./globals.js"
|
|
9
|
+
// import * as Global from "./globals.js"
|
|
10
10
|
// import * as Params from "./params"
|
|
11
11
|
|
|
12
|
-
const App={
|
|
12
|
+
const App = {
|
|
13
13
|
...__App__,
|
|
14
14
|
...Spa,
|
|
15
|
-
...Global,
|
|
15
|
+
// ...Global,
|
|
16
16
|
// ...Params
|
|
17
17
|
}
|
|
18
18
|
export default App
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SPA } from "./spa.js";
|
|
2
|
-
import {
|
|
2
|
+
import { tags } from "../ui/index.js";
|
|
3
3
|
// import.meta.glob('./src/pages/**/*.js')
|
|
4
4
|
async function FileBasedRouting(pages /* use import.meta.glob */){
|
|
5
5
|
const routes = Object.keys(pages)
|
|
@@ -16,7 +16,7 @@ async function FileBasedRouting(pages /* use import.meta.glob */){
|
|
|
16
16
|
"/" : ()=>{},
|
|
17
17
|
...pairs
|
|
18
18
|
},
|
|
19
|
-
wrapper :
|
|
19
|
+
wrapper : tags.section()
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts']) {
|
package/src/app/ziko-app.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tags } from "../../ui"
|
|
2
2
|
const svg2str=svg=>(new XMLSerializer()).serializeToString(svg);
|
|
3
3
|
const svg2ascii=svg=>btoa(svg2str(svg));
|
|
4
4
|
const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
|
|
5
|
-
const svg2img=(svg,render=true)=>
|
|
5
|
+
const svg2img=(svg,render=true)=>tags.img(svg2imgUrl(svg)).render(render);
|
|
6
6
|
export{
|
|
7
7
|
svg2str,
|
|
8
8
|
svg2ascii,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export function useDerived(deriveFn, sources) {
|
|
2
|
+
let value = deriveFn(...sources.map(s => s().value));
|
|
3
|
+
const subscribers = new Set();
|
|
4
|
+
let paused = false;
|
|
5
|
+
|
|
6
|
+
function getValue() {
|
|
7
|
+
return {
|
|
8
|
+
value,
|
|
9
|
+
isStateGetter: () => true,
|
|
10
|
+
_subscribe: (fn, UIElement) => {
|
|
11
|
+
subscribers.add(fn);
|
|
12
|
+
|
|
13
|
+
const observer = new MutationObserver(() => {
|
|
14
|
+
if (!document.body.contains(UIElement.element)) {
|
|
15
|
+
subscribers.delete(fn);
|
|
16
|
+
observer.disconnect();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function setValue(newValue) {
|
|
26
|
+
if (paused) return;
|
|
27
|
+
if (typeof newValue === "function") newValue = newValue(value);
|
|
28
|
+
if (newValue !== value) {
|
|
29
|
+
value = newValue;
|
|
30
|
+
subscribers.forEach(fn => fn(value));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const controller = {
|
|
35
|
+
pause: () => { paused = true; },
|
|
36
|
+
resume: () => { paused = false; },
|
|
37
|
+
clear: () => { subscribers.clear(); },
|
|
38
|
+
force: (newValue) => {
|
|
39
|
+
if (typeof newValue === "function") newValue = newValue(value);
|
|
40
|
+
value = newValue;
|
|
41
|
+
subscribers.forEach(fn => fn(value));
|
|
42
|
+
},
|
|
43
|
+
getSubscribers: () => new Set(subscribers),
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Subscribe to source states
|
|
47
|
+
sources.forEach(source => {
|
|
48
|
+
const srcValue = source(); // getValue()
|
|
49
|
+
srcValue._subscribe(() => {
|
|
50
|
+
if (!paused) {
|
|
51
|
+
const newVal = deriveFn(...sources.map(s => s().value));
|
|
52
|
+
if (newVal !== value) {
|
|
53
|
+
value = newVal;
|
|
54
|
+
subscribers.forEach(fn => fn(value));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, { element: document.body }); // dummy UIElement
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return [getValue, setValue, controller];
|
|
61
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function useState(initialValue) {
|
|
2
|
+
let value = initialValue;
|
|
3
|
+
const subscribers = new Set();
|
|
4
|
+
let paused = false;
|
|
5
|
+
|
|
6
|
+
function getValue() {
|
|
7
|
+
return {
|
|
8
|
+
value,
|
|
9
|
+
isStateGetter: () => true,
|
|
10
|
+
_subscribe: (fn, UIElement) => {
|
|
11
|
+
subscribers.add(fn);
|
|
12
|
+
|
|
13
|
+
const observer = new MutationObserver(() => {
|
|
14
|
+
if (!document.body.contains(UIElement.element)) {
|
|
15
|
+
subscribers.delete(fn);
|
|
16
|
+
observer.disconnect();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function setValue(newValue) {
|
|
26
|
+
if (paused) return;
|
|
27
|
+
if (typeof newValue === "function") newValue = newValue(value);
|
|
28
|
+
if (newValue !== value) {
|
|
29
|
+
value = newValue;
|
|
30
|
+
subscribers.forEach(fn => fn(value));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const controller = {
|
|
35
|
+
pause: () => { paused = true; },
|
|
36
|
+
resume: () => { paused = false; },
|
|
37
|
+
clear: () => { subscribers.clear(); },
|
|
38
|
+
force: (newValue) => { // force update even if paused
|
|
39
|
+
if (typeof newValue === "function") newValue = newValue(value);
|
|
40
|
+
value = newValue;
|
|
41
|
+
subscribers.forEach(fn => fn(value));
|
|
42
|
+
},
|
|
43
|
+
getSubscribers: () => new Set(subscribers),
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return [getValue, setValue, controller];
|
|
47
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,94 +1,17 @@
|
|
|
1
|
-
import { __ExtractAll__,__RemoveAll__ } from "./__helpers__/index.js";
|
|
2
|
-
import Math from "./math/index.js";
|
|
3
|
-
import UI from "./ui/index.js";
|
|
4
|
-
import Time from "./time/index.js";
|
|
5
|
-
import Data from "./data/index.js";
|
|
6
|
-
import Reactivity from "./reactivity/index.js";
|
|
7
|
-
import Graphics from "./graphics/index.js";
|
|
8
|
-
|
|
9
|
-
// import * as Events from "./events/index.js"
|
|
10
|
-
// import * as Use from "./use/index.js"
|
|
11
|
-
|
|
12
|
-
import App,{__UI__,__HYDRATION_MAP__, __Config__, __CACHE__, defineParamsGetter, __HYDRATION__} from "./app";
|
|
13
|
-
|
|
14
1
|
export * from "./math/index.js";
|
|
15
2
|
export * from "./ui/index.js";
|
|
16
3
|
export * from "./time/index.js";
|
|
17
4
|
export * from "./data/index.js";
|
|
18
5
|
export * from "./reactivity/index.js"
|
|
19
|
-
export * from "./graphics/index.js";
|
|
20
6
|
export * from "./app/index.js";
|
|
21
7
|
|
|
22
8
|
export * from "./events/index.js";
|
|
23
9
|
export * from "./use/index.js";
|
|
24
10
|
|
|
25
|
-
[
|
|
26
|
-
App,
|
|
27
|
-
Math,
|
|
28
|
-
UI,
|
|
29
|
-
Time,
|
|
30
|
-
Data,
|
|
31
|
-
Reactivity,
|
|
32
|
-
Graphics,
|
|
33
|
-
].forEach(n=>Object.assign(n,{
|
|
34
|
-
ExtractAll:()=>__ExtractAll__(n),
|
|
35
|
-
RemoveAll:()=>__RemoveAll__(n)
|
|
36
|
-
}))
|
|
37
|
-
|
|
38
|
-
const Ziko={
|
|
39
|
-
App,
|
|
40
|
-
Math,
|
|
41
|
-
UI,
|
|
42
|
-
Time,
|
|
43
|
-
Data,
|
|
44
|
-
Reactivity,
|
|
45
|
-
Graphics
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if ( globalThis.__Ziko__ ) {
|
|
49
|
-
console.warn( 'WARNING: Multiple instances of Ziko.js being imported.' );
|
|
50
|
-
} else {
|
|
51
|
-
globalThis.__Ziko__={
|
|
52
|
-
...Ziko,
|
|
53
|
-
__UI__,
|
|
54
|
-
__HYDRATION__,
|
|
55
|
-
__HYDRATION_MAP__,
|
|
56
|
-
__Config__,
|
|
57
|
-
__CACHE__,
|
|
58
|
-
ExtractAll,
|
|
59
|
-
RemoveAll
|
|
60
|
-
};
|
|
61
|
-
defineParamsGetter(__Ziko__)
|
|
62
|
-
}
|
|
63
|
-
// globalThis.__Ziko__={
|
|
64
|
-
// ...Ziko,
|
|
65
|
-
// __UI__,
|
|
66
|
-
// __Config__,
|
|
67
|
-
// ExtractAll,
|
|
68
|
-
// RemoveAll
|
|
69
|
-
// };
|
|
70
11
|
if(globalThis?.document){
|
|
71
12
|
document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
|
|
72
13
|
}
|
|
73
|
-
function ExtractAll(){
|
|
74
|
-
UI.ExtractAll();
|
|
75
|
-
Math.ExtractAll();
|
|
76
|
-
Time.ExtractAll();
|
|
77
|
-
Reactivity.ExtractAll();
|
|
78
|
-
Graphics.ExtractAll();
|
|
79
|
-
Data.ExtractAll()
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
function RemoveAll(){
|
|
83
|
-
UI.RemoveAll();
|
|
84
|
-
Math.RemoveAll();
|
|
85
|
-
Time.RemoveAll();
|
|
86
|
-
Reactivity.RemoveAll();
|
|
87
|
-
Graphics.RemoveAll();
|
|
88
|
-
Data.RemoveAll()
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export default Ziko;
|
|
92
14
|
|
|
15
|
+
import './math/functions/proxy.js'
|
|
93
16
|
|
|
94
17
|
|
|
@@ -58,29 +58,29 @@ const sqrtn=(x,n)=>{
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
const e=(...x)=>mapfun(Math.exp,...x);
|
|
62
|
-
const ln=(...x)=>mapfun(Math.log,...x);
|
|
63
|
-
const cos=(...x)=>mapfun(Fixed.cos,...x);
|
|
64
|
-
const sin=(...x)=>mapfun(Fixed.sin,...x);
|
|
65
|
-
const tan=(...x)=>mapfun(Fixed.tan,...x);
|
|
66
|
-
const sec=(...x)=>mapfun(Fixed.sec,...x);
|
|
67
|
-
const sinc=(...x)=>mapfun(Fixed.sinc,...x)
|
|
68
|
-
const csc=(...x)=>mapfun(Fixed.csc,...x);
|
|
69
|
-
const cot=(...x)=>mapfun(Fixed.cot,...x);
|
|
70
|
-
const acos=(...x)=>mapfun(Fixed.acos,...x);
|
|
71
|
-
const asin=(...x)=>mapfun(Fixed.asin,...x);
|
|
72
|
-
const atan=(...x)=>mapfun(Fixed.atan,...x);
|
|
73
|
-
const acot=(...x)=>mapfun(Fixed.acot,...x);
|
|
74
|
-
const cosh=(...x)=>mapfun(Fixed.cosh,...x);
|
|
75
|
-
const sinh=(...x)=>mapfun(Fixed.sinh,...x);
|
|
76
|
-
const tanh=(...x)=>mapfun(Fixed.tanh,...x);
|
|
77
|
-
const coth=(...x)=>mapfun(Fixed.coth,...x);
|
|
78
|
-
const acosh=(...x)=>mapfun(Fixed.acosh,...x);
|
|
79
|
-
const asinh=(...x)=>mapfun(Fixed.asinh,...x);
|
|
80
|
-
const atanh=(...x)=>mapfun(Fixed.atanh,...x);
|
|
81
|
-
const ceil=(...x)=>mapfun(Math.ceil,...x);
|
|
82
|
-
const floor=(...x)=>mapfun(Math.floor,...x);
|
|
83
|
-
const round=(...x)=>mapfun(Math.round,...x);
|
|
61
|
+
const e=(...x) => mapfun(Math.exp,...x);
|
|
62
|
+
const ln=(...x) => mapfun(Math.log,...x);
|
|
63
|
+
const cos=(...x) => mapfun(Fixed.cos,...x);
|
|
64
|
+
const sin=(...x) => mapfun(Fixed.sin,...x);
|
|
65
|
+
const tan=(...x) => mapfun(Fixed.tan,...x);
|
|
66
|
+
const sec=(...x) => mapfun(Fixed.sec,...x);
|
|
67
|
+
const sinc=(...x) => mapfun(Fixed.sinc,...x)
|
|
68
|
+
const csc=(...x) => mapfun(Fixed.csc,...x);
|
|
69
|
+
const cot=(...x) => mapfun(Fixed.cot,...x);
|
|
70
|
+
const acos=(...x) => mapfun(Fixed.acos,...x);
|
|
71
|
+
const asin=(...x) => mapfun(Fixed.asin,...x);
|
|
72
|
+
const atan=(...x) => mapfun(Fixed.atan,...x);
|
|
73
|
+
const acot=(...x) => mapfun(Fixed.acot,...x);
|
|
74
|
+
const cosh=(...x) => mapfun(Fixed.cosh,...x);
|
|
75
|
+
const sinh=(...x) => mapfun(Fixed.sinh,...x);
|
|
76
|
+
const tanh=(...x) => mapfun(Fixed.tanh,...x);
|
|
77
|
+
const coth=(...x) => mapfun(Fixed.coth,...x);
|
|
78
|
+
const acosh=(...x) => mapfun(Fixed.acosh,...x);
|
|
79
|
+
const asinh=(...x) => mapfun(Fixed.asinh,...x);
|
|
80
|
+
const atanh=(...x) => mapfun(Fixed.atanh,...x);
|
|
81
|
+
const ceil=(...x) => mapfun(Math.ceil,...x);
|
|
82
|
+
const floor=(...x) => mapfun(Math.floor,...x);
|
|
83
|
+
const round=(...x) => mapfun(Math.round,...x);
|
|
84
84
|
const atan2=(x,y,rad=true)=>{
|
|
85
85
|
if(typeof x === "number"){
|
|
86
86
|
if(typeof y === "number")return rad?Math.atan2(x,y):Math.atan2(x,y)*180/Math.PI;
|