ziko 1.10.0 → 2.0.0-beta.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.
Files changed (232) hide show
  1. package/dist/ziko.cjs +1271 -5264
  2. package/dist/ziko.js +1322 -5315
  3. package/dist/ziko.min.js +2 -2
  4. package/dist/ziko.mjs +1242 -5057
  5. package/package.json +62 -97
  6. package/src/__ziko__/__config__.js +3 -3
  7. package/src/__ziko__/__state__.js +0 -1
  8. package/src/{dom/components → components}/Fragment/index.js +1 -1
  9. package/src/{dom/components/wrappers → components}/HTMLWrapper/index.js +3 -7
  10. package/src/{dom/components/wrappers → components}/SVGWrapper/index.js +3 -15
  11. package/src/{dom/components → components}/Suspense/index.js +1 -1
  12. package/src/{dom/components → components}/Swap/index.js +2 -2
  13. package/src/{dom/components → components}/Switch/index.js +1 -2
  14. package/src/components/View/index.js +11 -0
  15. package/src/{dom/components → components}/index.js +2 -3
  16. package/src/dom/{constructors/UIElement.js → UIElement/index.js} +6 -6
  17. package/src/dom/index.js +2 -6
  18. package/src/dom/{utils → internal-utils}/call_with_optional_props.js +1 -1
  19. package/src/dom/{utils/is_ui_item.js → internal-utils/checkers.js} +1 -0
  20. package/src/dom/internal-utils/is_ui_item.js +10 -0
  21. package/src/dom/tags/index.js +3 -3
  22. package/src/events/custom-events-registry/view.js +1 -1
  23. package/src/hooks/index.d.ts +0 -8
  24. package/src/hooks/index.js +1 -12
  25. package/src/hooks/use-derived.js +18 -14
  26. package/src/hooks/use-effect.js +7 -15
  27. package/src/hooks/use-reactive.d.ts +1 -1
  28. package/src/hooks/use-reactive.js +1 -1
  29. package/src/hooks/use-state.js +1 -7
  30. package/src/index.d.ts +0 -1
  31. package/src/index.js +7 -11
  32. package/src/{helpers → internal-utils}/checkers/index.js +1 -1
  33. package/src/math/index.d.ts +4 -4
  34. package/src/math/index.js +7 -10
  35. package/src/math/{functions/mapfun → mapfun}/index.js +1 -1
  36. package/src/math/{functions/utils → utils}/index.d.ts +1 -1
  37. package/src/math/utils/index.js +42 -103
  38. package/src/{dom/constructors/UIElementCore.d.ts → mini-dom/UIElement/index.d.ts} +1 -1
  39. package/src/{dom/constructors/UIElementCore.js → mini-dom/UIElement/index.js} +5 -14
  40. package/src/{dom/constructors/UINode.js → mini-dom/UINode/index.js} +1 -3
  41. package/src/{dom/constructors → mini-dom}/mixins/attrs.js +6 -6
  42. package/src/{dom/constructors → mini-dom}/mixins/dom.js +2 -16
  43. package/src/mini-dom/mixins/lifecycle.js +32 -0
  44. package/src/{dom/constructors → mini-dom}/mixins/style.js +1 -1
  45. package/src/mini-dom/parse_props.js +26 -0
  46. package/src/{dom → mini-dom}/text/index.js +4 -4
  47. package/src/router/file-based-router/index.js +1 -1
  48. package/src/router/index.d.ts +1 -1
  49. package/src/router/index.js +1 -1
  50. package/src/router/internal-utils/index.d.ts +5 -0
  51. package/src/{hooks/use-query-params.js → router/useQueryParams/index.js} +0 -1
  52. package/src/time/{clocks/clock.js → clock/index.js} +1 -1
  53. package/src/time/{clocks/clock.d.ts → clock/index.ts} +1 -1
  54. package/src/time/debounce/index.d.ts +4 -0
  55. package/src/time/debounce/index.js +4 -0
  56. package/src/time/index.d.ts +7 -5
  57. package/src/time/index.js +7 -8
  58. package/src/time/sleep/index.d.ts +1 -0
  59. package/src/time/sleep/index.js +1 -0
  60. package/src/time/throttle/index.d.ts +4 -0
  61. package/src/time/throttle/index.js +9 -0
  62. package/src/time/{clocks/tick.js → tick/index.js} +2 -7
  63. package/src/time/{delay → timeout}/index.d.ts +0 -2
  64. package/src/time/{delay → timeout}/index.js +0 -1
  65. package/src/app/globals.js +0 -76
  66. package/src/app/index.js +0 -18
  67. package/src/app/params.js +0 -37
  68. package/src/app/routes.js +0 -57
  69. package/src/app/spa-file-based-routing.js +0 -74
  70. package/src/app/spa.js +0 -55
  71. package/src/app/ziko-app.js +0 -39
  72. package/src/data/api/fetchdom.js +0 -30
  73. package/src/data/api/index.js +0 -4
  74. package/src/data/api/preload.js +0 -11
  75. package/src/data/converter/__(To Be Moved)adoc.js +0 -130
  76. package/src/data/converter/__(To Be Moved)markdown.js +0 -95
  77. package/src/data/converter/array.js +0 -43
  78. package/src/data/converter/canvas.js +0 -25
  79. package/src/data/converter/css.js +0 -37
  80. package/src/data/converter/csv.js +0 -35
  81. package/src/data/converter/idea.txt +0 -10
  82. package/src/data/converter/index.js +0 -33
  83. package/src/data/converter/json.js +0 -80
  84. package/src/data/converter/object.js +0 -74
  85. package/src/data/converter/svg.js +0 -11
  86. package/src/data/datatypes/color.js +0 -11
  87. package/src/data/decorators.js +0 -0
  88. package/src/data/index.js +0 -17
  89. package/src/data/parser/index.d.ts +0 -41
  90. package/src/data/parser/index.js +0 -28
  91. package/src/data/string-dep/index.js +0 -1
  92. package/src/data/string-dep/patterns.js +0 -12
  93. package/src/data/string-dep/string.js +0 -170
  94. package/src/dom/components/Flex/index.js +0 -89
  95. package/src/dom/components/Flex/utils/index.js +0 -20
  96. package/src/dom/components/View/index.js +0 -9
  97. package/src/dom/components/graphics/Canvas/index.js +0 -175
  98. package/src/dom/components/graphics/Svg/index.js +0 -69
  99. package/src/dom/components/graphics/index.js +0 -2
  100. package/src/dom/components/wrappers/index.js +0 -2
  101. package/src/dom/constructors/mixins/lifecycle.js +0 -54
  102. package/src/dom/grid/index.js +0 -33
  103. package/src/dom/mini/UIElement.js +0 -10
  104. package/src/dom/utils/checkers.js +0 -1
  105. package/src/dom/utils/getters.js +0 -0
  106. package/src/hooks/use-favicon.d.ts +0 -41
  107. package/src/hooks/use-favicon.js +0 -59
  108. package/src/hooks/use-ipc.d.ts +0 -12
  109. package/src/hooks/use-ipc.js +0 -83
  110. package/src/hooks/use-media-query.d.ts +0 -24
  111. package/src/hooks/use-media-query.js +0 -59
  112. package/src/hooks/use-root.d.ts +0 -15
  113. package/src/hooks/use-root.js +0 -73
  114. package/src/hooks/use-storage.d.ts +0 -47
  115. package/src/hooks/use-storage.js +0 -118
  116. package/src/hooks/use-thread.d.ts +0 -33
  117. package/src/hooks/use-thread.js +0 -55
  118. package/src/hooks/use-title.d.ts +0 -37
  119. package/src/hooks/use-title.js +0 -43
  120. package/src/lite.js +0 -2
  121. package/src/math/--discret/Set/index.js +0 -2
  122. package/src/math/--discret/Set/power-set.js +0 -15
  123. package/src/math/--discret/Set/sub-set.js +0 -10
  124. package/src/math/--discret/index.js +0 -12
  125. package/src/math/complex/helpers/constructor.js +0 -38
  126. package/src/math/complex/helpers/index.js +0 -1
  127. package/src/math/complex/index.d.ts +0 -231
  128. package/src/math/complex/index.js +0 -193
  129. package/src/math/functions/conversions/index.d.ts +0 -101
  130. package/src/math/functions/conversions/index.js +0 -61
  131. package/src/math/functions/helper.js +0 -81
  132. package/src/math/functions/index.d.ts +0 -147
  133. package/src/math/functions/index.js +0 -43
  134. package/src/math/functions/logic/index.d.ts +0 -53
  135. package/src/math/functions/logic/index.js +0 -54
  136. package/src/math/functions/proxy.js +0 -58
  137. package/src/math/functions/signal/index.d.ts +0 -146
  138. package/src/math/functions/signal/index.js +0 -104
  139. package/src/math/functions/stats/index.js +0 -61
  140. package/src/math/functions/ufunc/index.d.ts +0 -96
  141. package/src/math/functions/ufunc/index.js +0 -372
  142. package/src/math/functions/utils/index.js +0 -47
  143. package/src/math/matrix/AbstractMatrix.js +0 -0
  144. package/src/math/matrix/helpers/constructor.js +0 -31
  145. package/src/math/matrix/helpers/det.js +0 -36
  146. package/src/math/matrix/helpers/index.js +0 -5
  147. package/src/math/matrix/helpers/inverse.js +0 -52
  148. package/src/math/matrix/helpers/maintain.js +0 -13
  149. package/src/math/matrix/helpers/stack.js +0 -24
  150. package/src/math/matrix/index.js +0 -557
  151. package/src/math/random/index.d.ts +0 -162
  152. package/src/math/random/index.js +0 -125
  153. package/src/math/signal/functions.js +0 -84
  154. package/src/math/signal/index.js +0 -1
  155. package/src/math/stats/accum/index.d.ts +0 -43
  156. package/src/math/stats/accum/index.js +0 -39
  157. package/src/math/stats/average/index.d.ts +0 -123
  158. package/src/math/stats/average/index.js +0 -75
  159. package/src/math/stats/index.d.ts +0 -5
  160. package/src/math/stats/index.js +0 -14
  161. package/src/math/stats/percentile/index.d.ts +0 -66
  162. package/src/math/stats/percentile/index.js +0 -18
  163. package/src/math/stats/rolling/index.d.ts +0 -47
  164. package/src/math/stats/rolling/index.js +0 -34
  165. package/src/math/stats/variability/index.d.ts +0 -93
  166. package/src/math/stats/variability/index.js +0 -37
  167. package/src/math/utils/arithmetic.js +0 -137
  168. package/src/math/utils/checkers.js +0 -29
  169. package/src/math/utils/comparaison.js +0 -1
  170. package/src/math/utils/conversions.js +0 -19
  171. package/src/math/utils/discret.js +0 -51
  172. package/src/math/utils/mapfun.js +0 -42
  173. package/src/no-module.js +0 -32
  174. package/src/provider/index.js +0 -7
  175. package/src/router/utils/index.d.ts +0 -5
  176. package/src/time/animation/index.d.ts +0 -189
  177. package/src/time/animation/index.js +0 -94
  178. package/src/time/clocks/index.d.ts +0 -3
  179. package/src/time/clocks/index.js +0 -3
  180. package/src/time/converters/index.js +0 -1
  181. package/src/time/decorators/index.d.ts +0 -9
  182. package/src/time/decorators/index.js +0 -17
  183. package/src/time/ease/index.d.ts +0 -103
  184. package/src/time/ease/index.js +0 -118
  185. package/src/time/loop/index.d.ts +0 -50
  186. package/src/time/loop/index.js +0 -103
  187. package/src/time/utils/index.js +0 -17
  188. package/src/time/utils/performance.js +0 -16
  189. package/src/time/utils/ui.js +0 -26
  190. /package/src/{dom/components → components}/For/index.js +0 -0
  191. /package/src/{dom/components → components}/Fragment/index.d.ts +0 -0
  192. /package/src/{dom/components → components}/Swap/index.d.ts +0 -0
  193. /package/src/{dom/components → components}/index.d.ts +0 -0
  194. /package/src/dom/{utils → internal-utils}/index.js +0 -0
  195. /package/src/dom/{utils → internal-utils}/parse_props.js +0 -0
  196. /package/src/{helpers → internal-utils}/index.js +0 -0
  197. /package/src/{helpers → internal-utils}/register/index.js +0 -0
  198. /package/src/{helpers → internal-utils}/register/register-to-class.js +0 -0
  199. /package/src/{helpers → internal-utils}/register/register-to-instance.js +0 -0
  200. /package/src/{symbols → internal-utils/symbols}/index.d.ts +0 -0
  201. /package/src/{symbols → internal-utils/symbols}/index.js +0 -0
  202. /package/src/math/{functions/arithmetic → arithmetic}/index.d.ts +0 -0
  203. /package/src/math/{functions/arithmetic → arithmetic}/index.js +0 -0
  204. /package/src/math/{const.js → const/index.js} +0 -0
  205. /package/src/math/{functions/mapfun → mapfun}/index.d.ts +0 -0
  206. /package/src/math/{functions/mapfun → mapfun}/index.d.ts.txt +0 -0
  207. /package/src/math/{functions/utils → utils}/mapfun.d.ts.txt +0 -0
  208. /package/src/{dom/constructors/UINode.d.ts → mini-dom/UINode/index.d.ts} +0 -0
  209. /package/src/{dom/constructors → mini-dom}/mixins/index.js +0 -0
  210. /package/src/{dom/constructors → mini-dom}/mixins/indexing.js +0 -0
  211. /package/src/router/{utils → internal-utils}/dynamic-routes-parser.d.ts +0 -0
  212. /package/src/router/{utils → internal-utils}/dynamic-routes-parser.js +0 -0
  213. /package/src/router/{utils → internal-utils}/get-root.d.ts +0 -0
  214. /package/src/router/{utils → internal-utils}/get-root.js +0 -0
  215. /package/src/router/{utils → internal-utils}/index.js +0 -0
  216. /package/src/router/{utils → internal-utils}/normalize-path.d.ts +0 -0
  217. /package/src/router/{utils → internal-utils}/normalize-path.js +0 -0
  218. /package/src/router/{utils → internal-utils}/renderer.js +0 -0
  219. /package/src/router/{utils → internal-utils}/routes-grouper.d.ts +0 -0
  220. /package/src/router/{utils → internal-utils}/routes-grouper.js +0 -0
  221. /package/src/router/{utils → internal-utils}/routes-matcher.d.ts +0 -0
  222. /package/src/router/{utils → internal-utils}/routes-matcher.js +0 -0
  223. /package/src/{hooks/use-query-params.d.ts → router/useQueryParams/index.d.ts} +0 -0
  224. /package/src/{data/string → string}/checkers/index.d.ts +0 -0
  225. /package/src/{data/string → string}/checkers/index.js +0 -0
  226. /package/src/{data/string → string}/converters/index.d.ts +0 -0
  227. /package/src/{data/string → string}/converters/index.js +0 -0
  228. /package/src/{data/string → string}/index.d.ts +0 -0
  229. /package/src/{data/string → string}/index.js +0 -0
  230. /package/src/time/{clocks/scheduler.js → schedular/index.js} +0 -0
  231. /package/src/time/{clocks/scheduler.d.ts → schedular/index.ts} +0 -0
  232. /package/src/time/{clocks/tick.d.ts → tick/index.ts} +0 -0
package/src/app/routes.js DELETED
@@ -1,57 +0,0 @@
1
- function routesMatcher(mask, route) {
2
- const maskSegments = mask.split('/');
3
- const routeSegments = route.split('/');
4
- if (maskSegments.length !== routeSegments.length) {
5
- return false;
6
- }
7
- for (let i = 0; i < maskSegments.length; i++) {
8
- const maskSegment = maskSegments[i];
9
- const routeSegment = routeSegments[i];
10
- if (maskSegment.startsWith(':')) {
11
- continue;
12
- } else if (maskSegment !== routeSegment) {
13
- return false;
14
- }
15
- }
16
- return true;
17
- }
18
- function dynamicRoutesParser(mask, route) {
19
- const maskSegments = mask.split('/');
20
- const routeSegments = route.split('/');
21
- const params = {};
22
- if (maskSegments.length !== routeSegments.length) {
23
- return params;
24
- }
25
- for (let i = 0; i < maskSegments.length; i++) {
26
- const maskSegment = maskSegments[i];
27
- const routeSegment = routeSegments[i];
28
- if (maskSegment.startsWith(':')) {
29
- const paramName = maskSegment.slice(1);
30
- params[paramName] = routeSegment;
31
- } else if (maskSegment !== routeSegment) {
32
- return {};
33
- }
34
- }
35
- return params;
36
- }
37
-
38
- function isDynamic(path) {
39
- const DynamicPattern = /:\w+/;
40
- return DynamicPattern.test(path);
41
- }
42
-
43
- // // Example usage:
44
- // const mask = "/:id/id/:lang/lang";
45
- // const route = "/id/5/lang/fr";
46
- // console.log(DynamicRouteMatcher(mask, route)); // Should return true
47
-
48
- export {
49
- routesMatcher,
50
- dynamicRoutesParser,
51
- isDynamic
52
- }
53
-
54
- // // Example usage:
55
- // const mask = "app/lang/:lang/id/:id";
56
- // const route = "app/lang/en/id/7";
57
- // console.log(dynamicRoutesParser(mask, route)); // Should return { lang: "en", id: "7" }
@@ -1,74 +0,0 @@
1
- import { SPA } from "./spa.js";
2
- import { tags } from "../dom/index.js";
3
- // import.meta.glob('./src/pages/**/*.js')
4
- async function FileBasedRouting(pages /* use import.meta.glob */){
5
- const routes = Object.keys(pages)
6
- const root = findCommonPath(routes)
7
- const pairs = {}
8
- for(let i=0; i<routes.length; i++){
9
- const module = await pages[routes[i]]()
10
- const component = await module.default
11
- Object.assign(pairs,{[customPath(routes[i], root)]:component})
12
- }
13
- return SPA({
14
- target : document.body,
15
- routes : {
16
- "/" : ()=>{},
17
- ...pairs
18
- },
19
- wrapper : tags.section()
20
- })
21
- }
22
- function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts']) {
23
- if(root.at(-1)==="/") root = root.slice(0, -1)
24
- const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
25
- const parts = normalizedPath.split('/');
26
- const rootParts = root.split('/');
27
- const rootIndex = parts.indexOf(rootParts.at(-1));
28
- if (rootIndex !== -1) {
29
- const subsequentParts = parts.slice(rootIndex + 1);
30
- const lastPart = parts.at(-1);
31
- const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
32
- // console.log({extensions, subsequentParts, lastPart, isIndexFile, rootParts, rootIndex, parts})
33
- const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
34
- if (isIndexFile) {
35
- return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
36
- }
37
- if (hasValidExtension) {
38
- return '/' + subsequentParts.join('/').replace(/\.(js|ts)$/, '');
39
- }
40
- }
41
- return '';
42
- }
43
- function findCommonPath(paths) {
44
- if (paths.length === 0) return '';
45
- const splitPaths = paths.map(path => path.split('/'));
46
- const minLength = Math.min(...splitPaths.map(parts => parts.length));
47
- let commonParts = [];
48
- for (let i = 0; i < minLength; i++) {
49
- const part = splitPaths[0][i];
50
- if (splitPaths.every(parts => parts[i] === part || parts[i].startsWith('['))) {
51
- commonParts.push(part);
52
- } else {
53
- break;
54
- }
55
- }
56
- const commonPath = commonParts.join('/') + (commonParts.length ? '/' : '');
57
- return commonPath;
58
- }
59
-
60
- // // Example usage
61
- // const inputPaths = [
62
- // './src/pages/[blog]/[lang]/index.js',
63
- // './src/pages/[blog]/index.js',
64
- // './src/pages/about.js',
65
- // './src/pages/articles/[data]/[color]/index.js',
66
- // './src/pages/articles/a1.js',
67
- // './src/pages/index.js',
68
- // './src/pages/me.js'
69
- // ];
70
-
71
- // console.log(findCommonPath(inputPaths)); // Output: './src/pages/'
72
- export{
73
- FileBasedRouting,
74
- }
package/src/app/spa.js DELETED
@@ -1,55 +0,0 @@
1
- import { text } from "../dom/index.js";
2
- import { dynamicRoutesParser,routesMatcher,isDynamic } from "./routes.js";
3
- import { ZikoApp } from "./ziko-app.js";
4
- class ZikoSPA extends ZikoApp{
5
- constructor({head, wrapper, target, routes}){
6
- super({head, wrapper, target})
7
- this.routes=new Map([
8
- ["404",text("Error 404")],
9
- ...Object.entries(routes)
10
- ]);
11
- this.clear();
12
- globalThis.onpopstate = this.mount(location.pathname);
13
- }
14
- clear(){
15
- [...this.routes].forEach(n=>{
16
- !isDynamic(n[0]) && n[1]?.isUIElement && n[1].unmount()
17
- })
18
- // this.wrapper.clear();
19
- return this;
20
- }
21
- mount(path){
22
- const [mask, callback] = [...this.routes].find(route=>routesMatcher(route[0],path));
23
- let element ;
24
- if(isDynamic(mask)){
25
- const params = dynamicRoutesParser(mask, path)
26
- element = callback.call(this,params)
27
- }
28
- else {
29
- callback?.isUIElement && callback.mount(this.wrapper);
30
- if(typeof callback === "function") element = callback();
31
- }
32
- if(element?.isUIElement) element.mount(this.wrapper);
33
- // if(element?.isZikoApp) element.mount(this.wrapper);
34
- if(element instanceof Promise){
35
- element.then(e=>e.mount(this.wrapper))
36
- }
37
- globalThis.history.pushState({}, "", path);
38
- return this;
39
- }
40
- }
41
- const SPA=({head, wrapper, target, routes})=>new ZikoSPA({head, wrapper, target, routes});
42
-
43
- export {
44
- ZikoSPA,
45
- SPA
46
- }
47
-
48
-
49
- /*
50
- // Static
51
- S.get("/url",wrapper)
52
- // Dynamique
53
- s.get("/url/name/:name/id/:id",(path,name,id)=>handler())
54
- // regEx
55
- */
@@ -1,39 +0,0 @@
1
- // import { ZikoHead , useHead} from "../reactivity/hooks/head/index.js";
2
- class ZikoApp {
3
- constructor({head = null, wrapper = null, target = null}){
4
- this.head = head;
5
- this.wrapper = wrapper;
6
- this.target = target;
7
- this.init()
8
- }
9
- get isZikoApp(){
10
- return true;
11
- }
12
- init(){
13
- this.head && this.setHead(this.head);
14
- this.wrapper && this.setWrapper(this.wrapper);
15
- this.target && this.setTarget(this.target);
16
- if(this.wrapper && this.target)this.wrapper.mount(this.target);
17
- }
18
- setTarget(target){
19
- if(target instanceof HTMLElement) this.target = target;
20
- else if (typeof target === "string") this.target = globalThis?.document?.querySelector(target);
21
- return this;
22
- }
23
- setWrapper(wrapper){
24
- if(wrapper?.isUIElement) this.wrapper = wrapper;
25
- else if(typeof wrapper === "function") this.wrapper = wrapper();
26
- return this;
27
- }
28
- // setHead(head){
29
- // if(head instanceof ZikoHead) this.head = head;
30
- // else this.head = useHead(head);
31
- // return this;
32
- // }
33
-
34
- }
35
- const App = ({head, wrapper, target}) => new ZikoApp({head, wrapper, target})
36
- export{
37
- ZikoApp,
38
- App
39
- }
@@ -1,30 +0,0 @@
1
- // import { preload } from "./preload";
2
-
3
- // async function fetchdom(url='https://github.com/zakarialaoui10') {
4
- // try {
5
- // const response = await fetch(url);
6
- // if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
7
- // const html = await response.text();
8
- // const dom = new DOMParser().parseFromString(html, 'text/html');
9
- // return dom.documentElement;
10
- // } catch (err) {
11
- // console.error('Failed to fetch DOM:', err);
12
- // throw err;
13
- // }
14
- // }
15
-
16
- // function fetchdomSync(url='https://github.com/zakarialaoui10') {
17
- // try {
18
- // const data = preload(url);
19
- // const dom = new DOMParser().parseFromString(data, 'text/html');
20
- // return dom.documentElement;
21
- // } catch (err) {
22
- // console.error('Failed to fetch DOM synchronously:', err);
23
- // throw err;
24
- // }
25
- // }
26
-
27
- // export {
28
- // fetchdom,
29
- // fetchdomSync
30
- // };
@@ -1,4 +0,0 @@
1
- // export { preload } from "./preload";
2
- // import { fetchdom ,fetchdomSync } from "./fetchdom";
3
- // globalThis.fetchdom=fetchdom
4
- // globalThis.fetchdomSync=fetchdomSync
@@ -1,11 +0,0 @@
1
- const preload=(url)=>{
2
- const xhr = new XMLHttpRequest();
3
- xhr.open("GET", url, false);
4
- xhr.send();
5
- if (xhr.status === 200) {
6
- return xhr.responseText;
7
- } else {
8
- throw new Error(`Failed to fetch data from ${url}. Status: ${xhr.status}`);
9
- }
10
- }
11
- export {preload}
@@ -1,130 +0,0 @@
1
- const parseInlineElements = text => {
2
- return text
3
- .replace(/\*(.*?)\*/g, '_$1_') // Emphasis
4
- .replace(/\*\*(.*?)\*\*/g, '*$1*') // Strong
5
- .replace(/\[(.*?)\]\((.*?)\)/g, 'link:$2[$1]') // Links
6
- .replace(/!\[(.*?)\]\((.*?)\)/g, 'image::$2[$1]') // Images
7
- .replace(/`([^`]+)`/g, '``$1``') // Inline Code
8
- .replace(/^\*\s/, ''); // Remove list item marker at the beginning of the line
9
- };
10
-
11
- const parseTable = line => {
12
- const cells = line.split('|').map(cell => cell.trim()).filter(cell => cell !== '');
13
- const tableRow = cells.map(cell => `<td>${parseInlineElements(cell)}</td>`).join('');
14
- return `<tr>${tableRow}</tr>\n`;
15
- };
16
-
17
- const parseCodeBlock = (lines, language) => {
18
- const codeContent = lines.join('\n'); // No need to exclude the triple backticks
19
- const highlightedCode = language ? `<pre><code data-language="${language}">${codeContent}</code></pre>` : `<pre><code>${codeContent}</code></pre>`;
20
- return `${highlightedCode}\n`;
21
- };
22
-
23
- const parseList = line => {
24
- const OL_PATTERN = /^(\d+)\.\s/;
25
- const OL_PATTERN_WITHOUT_START = /^[.]\s/;
26
- const UL_PATTERN = /^[*]\s/;
27
-
28
- if (line.match(OL_PATTERN)) {
29
- const start = line.match(OL_PATTERN)[1];
30
- return `<ol start="${start}"><li>${parseInlineElements(line.replace(OL_PATTERN, ''))}</li></ol>\n`;
31
- }
32
- if (line.match(OL_PATTERN_WITHOUT_START)) {
33
- return `<ol><li>${parseInlineElements(line.replace(OL_PATTERN_WITHOUT_START, ''))}</li></ol>\n`;
34
- }
35
- if (line.match(UL_PATTERN)) {
36
- return `<ul><li>${parseInlineElements(line.replace(UL_PATTERN, ''))}</li></ul>\n`;
37
- }
38
-
39
- // If neither ordered nor unordered list pattern matches, treat it as a paragraph
40
- return `<p>${parseInlineElements(line)}</p>\n`;
41
- };
42
-
43
-
44
-
45
-
46
- const parseBlockquote = line => {
47
- return `<blockquote>${parseInlineElements(line.slice(2))}</blockquote>\n`;
48
- };
49
-
50
- const parseHorizontalRule = () => {
51
- return '<hr>\n';
52
- };
53
-
54
- const parseAttributes = line => {
55
- const attrs = line.match(/\[(.*?)\]/);
56
- return attrs ? attrs[1].split(',').map(attr => `[${attr.trim()}]`).join('') : '';
57
- };
58
-
59
- const adoc2html = adocText => {
60
- const lines = adocText.split('\n');
61
- let htmlOutput = '';
62
- let inTable = false;
63
- let inCodeBlock = false;
64
- let codeBlockLines = [];
65
- let codeBlockLanguage = '';
66
- for (let i = 0; i < lines.length; i++) {
67
- let line = lines[i];
68
- // Table
69
- if (line.startsWith('|')) {
70
- if (!inTable) {
71
- inTable = true;
72
- htmlOutput += '<table>\n';
73
- }
74
- htmlOutput += parseTable(line);
75
- continue;
76
- } else if (inTable) {
77
- inTable = false;
78
- htmlOutput += '</table>\n';
79
- }
80
- // Code block
81
- if (line.startsWith('```')) {
82
- if (!inCodeBlock) {
83
- inCodeBlock = true;
84
- codeBlockLines = [];
85
- codeBlockLanguage = line.slice(3).trim();
86
- } else {
87
- inCodeBlock = false;
88
- htmlOutput += parseCodeBlock(codeBlockLines, codeBlockLanguage);
89
- }
90
- continue;
91
- } else if (inCodeBlock) {
92
- codeBlockLines.push(line);
93
- continue;
94
- }
95
- // Headings
96
- if (line.startsWith('=')) {
97
- const headingLevel = (line.match(/=/g) || []).length;
98
- const headingText = line.replace(/=/g, '').trim();
99
- htmlOutput += `<h${headingLevel}>${parseInlineElements(headingText)}</h${headingLevel}>\n`;
100
- continue;
101
- }
102
- // Lists
103
- if (line.match(/^(\d+)\.\s/) || line.match(/^[*\.]\s/)) {
104
- htmlOutput += parseList(line);
105
- continue;
106
- }
107
- // Blockquote
108
- if (line.startsWith('> ')) {
109
- htmlOutput += parseBlockquote(line);
110
- continue;
111
- }
112
- // Horizontal Rule
113
- if (line.trim() === '---') {
114
- htmlOutput += parseHorizontalRule();
115
- continue;
116
- }
117
- // Attributes
118
- if (line.startsWith('[')) {
119
- htmlOutput += parseAttributes(line);
120
- continue;
121
- }
122
- // Other paragraphs
123
- if (line.trim() !== '') { // Exclude empty lines
124
- htmlOutput += `<p>${parseInlineElements(line)}</p>\n`;
125
- }
126
- }
127
- return htmlOutput;
128
- };
129
-
130
- export { adoc2html };
@@ -1,95 +0,0 @@
1
- const parseInlineElements = text => {
2
- return text
3
- .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
4
- .replace(/\*(.*?)\*/g, '<em>$1</em>')
5
- .replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2">$1</a>')
6
- .replace(/!\[(.*?)\]\((.*?)\)/g, '<img src="$2" alt="$1">')
7
- .replace(/`([^`]+)`/g, '<code>$1</code>'); // Inline Code
8
- };
9
-
10
- const parseTable = line => {
11
- const cells = line.split('|').map(cell => cell.trim()).filter(cell => cell !== '');
12
- const tableRow = cells.map(cell => `<td>${parseInlineElements(cell)}</td>`).join('');
13
- return `<tr>${tableRow}</tr>\n`;
14
- };
15
-
16
- const parseCodeBlock = (lines, language) => {
17
- const codeContent = lines.join('\n'); // No need to exclude the triple backticks
18
- const highlightedCode = language ? `<pre><code data-language="${language}">${codeContent}</code></pre>` : `<pre><code>${codeContent}</code></pre>`;
19
- return `${highlightedCode}\n`;
20
- };
21
-
22
- const parseList = line => {
23
- const DIGIT_FOLLOWED_BY_A_DOT_AND_SPACE = /^\d+\.\s/;
24
- const match = line.match(DIGIT_FOLLOWED_BY_A_DOT_AND_SPACE);
25
- if (match) {
26
- let start = +match[1];
27
- return `<ol${start===1?"":` start="${start}"`}>${parseInlineElements(line.slice(match[0].length))}</ol>\n`;
28
- }
29
- return `<ul>${parseInlineElements(line)}</ul>\n`;
30
- };
31
-
32
- const parseHorizontalRule = () => {
33
- return '<hr>\n';
34
- };
35
-
36
- const markdown2html = markdownText => {
37
- const lines = markdownText.split('\n');
38
- let htmlOutput = '';
39
- let inTable = false;
40
- let inCodeBlock = false;
41
- let codeBlockLines = [];
42
- let codeBlockLanguage = '';
43
- for (let i = 0; i < lines.length; i++) {
44
- let line = lines[i];
45
- // Table
46
- if (line.startsWith('|')) {
47
- if (!inTable) {
48
- inTable = true;
49
- htmlOutput += '<table>\n';
50
- }
51
- htmlOutput += parseTable(line);
52
- continue;
53
- } else if (inTable) {
54
- inTable = false;
55
- htmlOutput += '</table>\n';
56
- }
57
- // Code block
58
- if (line.startsWith('```')) {
59
- if (!inCodeBlock) {
60
- inCodeBlock = true;
61
- codeBlockLines = [];
62
- codeBlockLanguage = line.slice(3).trim();
63
- } else {
64
- inCodeBlock = false;
65
- htmlOutput += parseCodeBlock(codeBlockLines, codeBlockLanguage);
66
- }
67
- continue;
68
- } else if (inCodeBlock) {
69
- codeBlockLines.push(line);
70
- continue;
71
- }
72
- // Headings
73
- if (line.startsWith('# ')) {
74
- const headingLevel = line.indexOf(' ');
75
- const headingText = line.slice(headingLevel + 1);
76
- htmlOutput += `<h${headingLevel}>${parseInlineElements(headingText)}</h${headingLevel}>\n`;
77
- continue;
78
- }
79
- // Lists
80
- if (line.startsWith('- ') || line.startsWith('* ') || line.match(/^\d+\.\s/)) {
81
- htmlOutput += parseList(line);
82
- continue;
83
- }
84
- // Horizontal Rule
85
- if (line.trim() === '---') {
86
- htmlOutput += parseHorizontalRule();
87
- continue;
88
- }
89
- // Other paragraphs
90
- htmlOutput += `<p>${parseInlineElements(line)}</p>\n`;
91
- }
92
- return htmlOutput;
93
- };
94
-
95
- export { markdown2html };
@@ -1,43 +0,0 @@
1
- import { obj2str } from "./object.js";
2
- import { Complex } from "../../math/complex/index.js";
3
- const getMaxDepth = arr=> {
4
- if (!Array.isArray(arr)) return 0;
5
- let maxDepth = 1;
6
- for (const element of arr) {
7
- if (Array.isArray(element)) {
8
- const depth = getMaxDepth(element);
9
- if (depth + 1 > maxDepth) {
10
- maxDepth = depth + 1;
11
- }
12
- }
13
- }
14
- return maxDepth;
15
- }
16
- const arr2str = (arr) => {
17
- let level = 0;
18
- function arrStringify(arr) {
19
- let max = getMaxDepth(arr);
20
- let useIdentation = 0;
21
- if (arr.some((n) => Array.isArray(n))) {
22
- level++;
23
- useIdentation = 1;
24
- }
25
- return (
26
- "[" +
27
- arr.map((n, i) => {
28
- if (["number", "string", "boolean", "bigint"].includes(typeof n))
29
- return String(n);
30
- if (n instanceof Complex) return n.toString();
31
- if (n instanceof Array) {
32
- return `\n${" ".repeat(level)}${arrStringify(n)}${i === arr.length - 1 ? "\n" : ""}`;
33
- }
34
- if( n instanceof Object) return obj2str(n);
35
- })
36
- + `${" ".repeat((max+level+1) * useIdentation)}]`
37
- );
38
- }
39
- return arrStringify(arr);
40
- };
41
- export{
42
- arr2str
43
- }
@@ -1,25 +0,0 @@
1
- const canvas2image = (canvas,format) => {}
2
- class Canvas2Video {
3
- constructor(canvas,mimeType="video/webm") {
4
- this.canvas = canvas;
5
- this.videoSrc=null;
6
- this.mediaRecorder = new MediaRecorder(this.canvas.captureStream(), { mimeType: mimeType });
7
- this.chunks = [];
8
- this.mediaRecorder.ondataavailable = (e) => {
9
- this.chunks.push(e.data);
10
- };
11
- this.mediaRecorder.onstop = (e) => {
12
- const blob = new Blob(this.chunks, { type: mimeType });
13
- this.videoSrc = URL.createObjectURL(blob);
14
- };
15
- }
16
- start() {
17
- this.mediaRecorder.start();
18
- return this;
19
- }
20
- stop() {
21
- this.mediaRecorder.stop();
22
- return this;
23
- }
24
- }
25
- const canvas2video=(canvas)=>new Canvas2Video(canvas)
@@ -1,37 +0,0 @@
1
- const json2css=(json, indentLevel = 0)=>{
2
- json = trimKeys(json);
3
- let cssText = '';
4
- const indent = ' '.repeat(indentLevel);
5
-
6
- for (let selector in json) {
7
- if (typeof json[selector] === 'object') {
8
- cssText += `${indent}${selector} {\n`;
9
- const properties = json[selector];
10
- for (let property in properties) {
11
- if (typeof properties[property] === 'object') {
12
- cssText += json2css({ [property]: properties[property] }, indentLevel + 1);
13
- } else {
14
- cssText += `${indent} ${property.replace(/[A-Z]/g, match => '-' + match.toLowerCase())}: ${properties[property]};\n`;
15
- }
16
- }
17
-
18
- cssText += `${indent}}\n`;
19
- }
20
- }
21
-
22
- return cssText;
23
- }
24
- function trimKeys(obj) {
25
- if (typeof obj !== 'object' || obj === null) {
26
- return obj;
27
- }
28
-
29
- return Object.keys(obj).reduce((acc, key) => {
30
- const trimmedKey = key.trim();
31
- acc[trimmedKey] = trimKeys(obj[key]);
32
- return acc;
33
- }, Array.isArray(obj) ? [] : {});
34
- }
35
- export{
36
- json2css
37
- }
@@ -1,35 +0,0 @@
1
- import { Matrix } from "../../math/matrix/index.js"
2
- const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
3
- const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
4
- const csv2object = (csv, delimiter = ",") => {
5
- const [header, ...rows] = csv2arr(csv,delimiter);
6
- const result = rows.map(row => {
7
- const obj = {};
8
- header.forEach((key, index) => {
9
- obj[key] = row[index];
10
- });
11
- return obj;
12
- });
13
- return result;
14
- };
15
- const csv2json = (csv, delimiter = ",") => JSON.stringify(csv2object(csv,delimiter));
16
- const csv2sql=(csv, Table)=>{
17
- const sanitizeId = s => s.trim().replace(/[^a-zA-Z0-9_]/g, '');
18
- const escapeVal = s => "'" + s.trim().replace(/'/g, "''") + "'";
19
- const lines = csv.trim().trimEnd().split('\n').filter(n=>n);
20
- const columns = lines[0].split(',').map(sanitizeId);
21
- let sqlQuery = "INSERT INTO " + sanitizeId(Table) + " (" + columns.join(', ') + ") Values ";
22
- let sqlValues = []
23
- for (let i = 1; i < lines.length; i++) {
24
- const values = lines[i].split(',').map(escapeVal);
25
- sqlValues.push("(" + values.join(', ') + ")")
26
- }
27
- return sqlQuery+sqlValues.join(",\n");
28
- }
29
- export{
30
- csv2arr,
31
- csv2matrix,
32
- csv2object,
33
- csv2json,
34
- csv2sql
35
- }
@@ -1,10 +0,0 @@
1
- a={
2
- a:complex(1,1),
3
- b:complex(2,2),
4
- c:{
5
- d:complex(1,2)
6
- }
7
- }
8
- d=mapfun(a=>a.toString(),a)
9
- t=JSON.stringify(d,""," ").replace(/"([^"]+)":/g, '$1:')
10
- text(t)