ziko 0.0.15 → 0.0.16
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 +111 -17
- package/dist/ziko.js +111 -17
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +106 -18
- package/package.json +1 -1
- package/src/app/index.js +3 -2
- package/src/app/params.js +5 -5
- package/src/app/spa-file-based-routing.js +74 -0
- package/src/app/spa.js +1 -2
- package/src/app/ziko-app.js +2 -2
- package/src/index.js +2 -1
- package/src/ui/elements/primitives/misc/index.js +1 -0
- package/src/ui/elements/primitives/misc/xml-wrapper.js +37 -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 : Sun Oct 13 2024 15:43:24 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
|
|
@@ -3881,7 +3881,7 @@ class ZikoHead{
|
|
|
3881
3881
|
}
|
|
3882
3882
|
}
|
|
3883
3883
|
|
|
3884
|
-
const useHead
|
|
3884
|
+
const useHead=({ title, lang, icon, meta, noscript })=>new ZikoHead({ title, lang, icon, meta, noscript });
|
|
3885
3885
|
|
|
3886
3886
|
const LightThemes={
|
|
3887
3887
|
cozyCottonCandy: {
|
|
@@ -5798,7 +5798,7 @@ const Hooks={
|
|
|
5798
5798
|
useTitle,
|
|
5799
5799
|
useFavIcon,
|
|
5800
5800
|
useMeta,
|
|
5801
|
-
useHead
|
|
5801
|
+
useHead,
|
|
5802
5802
|
useThrottle,
|
|
5803
5803
|
useDebounce,
|
|
5804
5804
|
useLocaleStorage,
|
|
@@ -7062,6 +7062,35 @@ class ZikoUIInputDateTime extends ZikoUIInput {
|
|
|
7062
7062
|
}
|
|
7063
7063
|
const inputDateTime = () => new ZikoUIInputDateTime();
|
|
7064
7064
|
|
|
7065
|
+
class ZikoUIXMLWrapper extends ZikoUIElement$1{
|
|
7066
|
+
constructor(XMLContent, type){
|
|
7067
|
+
super("div", "");
|
|
7068
|
+
this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent));
|
|
7069
|
+
}
|
|
7070
|
+
}
|
|
7071
|
+
function html2dom(htmlString) {
|
|
7072
|
+
const parser = new DOMParser();
|
|
7073
|
+
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
7074
|
+
return doc.body.firstChild;
|
|
7075
|
+
}
|
|
7076
|
+
function svg2dom(svgString) {
|
|
7077
|
+
const parser = new DOMParser();
|
|
7078
|
+
const doc = parser.parseFromString(svgString, 'image/svg+xml');
|
|
7079
|
+
return doc.documentElement; // SVG elements are usually at the root
|
|
7080
|
+
}
|
|
7081
|
+
class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
|
|
7082
|
+
constructor(HTMLContent){
|
|
7083
|
+
super(HTMLContent, "html");
|
|
7084
|
+
}
|
|
7085
|
+
}
|
|
7086
|
+
class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
|
|
7087
|
+
constructor(SVGContent){
|
|
7088
|
+
super(SVGContent, "svg");
|
|
7089
|
+
}
|
|
7090
|
+
}
|
|
7091
|
+
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
7092
|
+
const SVGWrapper = (SVGContent) => new ZikoUIHTMLWrapper(SVGContent);
|
|
7093
|
+
|
|
7065
7094
|
class ZikoUIHtmlTag extends ZikoUIContainerElement {
|
|
7066
7095
|
constructor(element) {
|
|
7067
7096
|
super(element,"html");
|
|
@@ -7150,10 +7179,15 @@ class ZikoUIBr extends ZikoUIElement$1 {
|
|
|
7150
7179
|
|
|
7151
7180
|
var Misc = /*#__PURE__*/Object.freeze({
|
|
7152
7181
|
__proto__: null,
|
|
7182
|
+
HTMLWrapper: HTMLWrapper,
|
|
7183
|
+
SVGWrapper: SVGWrapper,
|
|
7153
7184
|
ZikoUIBr: ZikoUIBr,
|
|
7185
|
+
ZikoUIHTMLWrapper: ZikoUIHTMLWrapper,
|
|
7154
7186
|
ZikoUIHr: ZikoUIHr,
|
|
7155
7187
|
ZikoUIHtmlTag: ZikoUIHtmlTag,
|
|
7156
7188
|
ZikoUILink: ZikoUILink,
|
|
7189
|
+
ZikoUISVGWrapper: ZikoUISVGWrapper,
|
|
7190
|
+
ZikoUIXMLWrapper: ZikoUIXMLWrapper,
|
|
7157
7191
|
br: br,
|
|
7158
7192
|
brs: brs,
|
|
7159
7193
|
btn: btn,
|
|
@@ -13277,7 +13311,7 @@ class ZikoApp {
|
|
|
13277
13311
|
this.head && this.setHead(this.head);
|
|
13278
13312
|
this.wrapper && this.setWrapper(this.wrapper);
|
|
13279
13313
|
this.target && this.setTarget(this.target);
|
|
13280
|
-
this.wrapper.render(this.target);
|
|
13314
|
+
if(this.wrapper && this.target)this.wrapper.render(this.target);
|
|
13281
13315
|
}
|
|
13282
13316
|
setTarget(target){
|
|
13283
13317
|
if(target instanceof HTMLElement) this.target = target;
|
|
@@ -13420,8 +13454,6 @@ function isDynamic(path) {
|
|
|
13420
13454
|
class ZikoSPA extends ZikoApp{
|
|
13421
13455
|
constructor({head, wrapper, target, routes}){
|
|
13422
13456
|
super({head, wrapper, target});
|
|
13423
|
-
// this.wrapper=wrapper;
|
|
13424
|
-
console.log(target);
|
|
13425
13457
|
this.routes=new Map([
|
|
13426
13458
|
["404",text$1("Error 404")],
|
|
13427
13459
|
...Object.entries(routes)
|
|
@@ -13448,6 +13480,7 @@ class ZikoSPA extends ZikoApp{
|
|
|
13448
13480
|
if(typeof callback === "function") element = callback();
|
|
13449
13481
|
}
|
|
13450
13482
|
if(element?.isZikoUIElement) element.render(this.wrapper);
|
|
13483
|
+
// if(element?.isZikoApp) element.render(this.wrapper);
|
|
13451
13484
|
if(element instanceof Promise){
|
|
13452
13485
|
element.then(e=>e.render(this.wrapper));
|
|
13453
13486
|
}
|
|
@@ -13472,7 +13505,7 @@ var Spa = /*#__PURE__*/Object.freeze({
|
|
|
13472
13505
|
ZikoSPA: ZikoSPA
|
|
13473
13506
|
});
|
|
13474
13507
|
|
|
13475
|
-
function
|
|
13508
|
+
function parseQueryParams(queryString) {
|
|
13476
13509
|
const params = {};
|
|
13477
13510
|
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
13478
13511
|
const [key, value] = match.split('=');
|
|
@@ -13481,19 +13514,19 @@ function parseParams(queryString) {
|
|
|
13481
13514
|
return params;
|
|
13482
13515
|
}
|
|
13483
13516
|
|
|
13484
|
-
function defineParamsGetter(target
|
|
13517
|
+
function defineParamsGetter(target ){
|
|
13485
13518
|
Object.defineProperties(target, {
|
|
13486
13519
|
'QueryParams': {
|
|
13487
13520
|
get: function() {
|
|
13488
|
-
return
|
|
13521
|
+
return parseQueryParams(globalThis.location.search.substring(1));
|
|
13489
13522
|
},
|
|
13490
13523
|
configurable: false,
|
|
13491
13524
|
enumerable: true
|
|
13492
13525
|
},
|
|
13493
13526
|
'HashParams': {
|
|
13494
13527
|
get: function() {
|
|
13495
|
-
const hash =
|
|
13496
|
-
return
|
|
13528
|
+
const hash = globalThis.location.hash.substring(1);
|
|
13529
|
+
return hash.split("#");
|
|
13497
13530
|
},
|
|
13498
13531
|
configurable: false,
|
|
13499
13532
|
enumerable: true
|
|
@@ -13501,11 +13534,6 @@ function defineParamsGetter(target = globalThis){
|
|
|
13501
13534
|
});
|
|
13502
13535
|
}
|
|
13503
13536
|
|
|
13504
|
-
var Params = /*#__PURE__*/Object.freeze({
|
|
13505
|
-
__proto__: null,
|
|
13506
|
-
defineParamsGetter: defineParamsGetter
|
|
13507
|
-
});
|
|
13508
|
-
|
|
13509
13537
|
const __UI__={};
|
|
13510
13538
|
const __Config__={
|
|
13511
13539
|
default:{
|
|
@@ -13529,12 +13557,71 @@ var Global = /*#__PURE__*/Object.freeze({
|
|
|
13529
13557
|
__UI__: __UI__
|
|
13530
13558
|
});
|
|
13531
13559
|
|
|
13560
|
+
// import.meta.glob('./src/pages/**/*.js')
|
|
13561
|
+
async function FileBasedRouting(pages /* use import.meta.glob */){
|
|
13562
|
+
const routes = Object.keys(pages);
|
|
13563
|
+
const root = findCommonPath(routes);
|
|
13564
|
+
// console.log({root})
|
|
13565
|
+
const pairs = {};
|
|
13566
|
+
for(let i=0; i<routes.length; i++){
|
|
13567
|
+
const module = await pages[routes[i]]();
|
|
13568
|
+
const component = await module.default;
|
|
13569
|
+
Object.assign(pairs,{[customPath(routes[i], root)]:component});
|
|
13570
|
+
}
|
|
13571
|
+
return SPA({
|
|
13572
|
+
target : document.body,
|
|
13573
|
+
routes : {
|
|
13574
|
+
"/" : ()=>{},
|
|
13575
|
+
...pairs
|
|
13576
|
+
},
|
|
13577
|
+
wrapper : Section()
|
|
13578
|
+
})
|
|
13579
|
+
}
|
|
13580
|
+
function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts']) {
|
|
13581
|
+
if(root.at(-1)==="/") root = root.slice(0, -1);
|
|
13582
|
+
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
13583
|
+
const parts = normalizedPath.split('/');
|
|
13584
|
+
const rootParts = root.split('/');
|
|
13585
|
+
const rootIndex = parts.indexOf(rootParts[rootParts.length - 1]);
|
|
13586
|
+
if (rootIndex !== -1) {
|
|
13587
|
+
const subsequentParts = parts.slice(rootIndex + 1);
|
|
13588
|
+
const lastPart = subsequentParts[subsequentParts.length - 1];
|
|
13589
|
+
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
13590
|
+
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
13591
|
+
if (isIndexFile) {
|
|
13592
|
+
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
|
13593
|
+
}
|
|
13594
|
+
if (hasValidExtension) {
|
|
13595
|
+
return '/' + subsequentParts.join('/').replace(/\.(js|ts)$/, '');
|
|
13596
|
+
}
|
|
13597
|
+
}
|
|
13598
|
+
return '';
|
|
13599
|
+
}
|
|
13600
|
+
function findCommonPath(paths) {
|
|
13601
|
+
if (paths.length === 0) return '';
|
|
13602
|
+
const splitPaths = paths.map(path => path.split('/'));
|
|
13603
|
+
const minLength = Math.min(...splitPaths.map(parts => parts.length));
|
|
13604
|
+
let commonParts = [];
|
|
13605
|
+
for (let i = 0; i < minLength; i++) {
|
|
13606
|
+
const part = splitPaths[0][i];
|
|
13607
|
+
if (splitPaths.every(parts => parts[i] === part || parts[i].startsWith('['))) {
|
|
13608
|
+
commonParts.push(part);
|
|
13609
|
+
} else {
|
|
13610
|
+
break;
|
|
13611
|
+
}
|
|
13612
|
+
}
|
|
13613
|
+
const commonPath = commonParts.join('/') + (commonParts.length ? '/' : '');
|
|
13614
|
+
return commonPath;
|
|
13615
|
+
}
|
|
13616
|
+
|
|
13617
|
+
// import * as Params from "./params"
|
|
13618
|
+
|
|
13532
13619
|
const App={
|
|
13533
13620
|
...__App__,
|
|
13534
13621
|
...JsonStyleSheet,
|
|
13535
13622
|
...Spa,
|
|
13536
13623
|
...Global,
|
|
13537
|
-
...Params
|
|
13624
|
+
// ...Params
|
|
13538
13625
|
};
|
|
13539
13626
|
|
|
13540
13627
|
[
|
|
@@ -13570,6 +13657,7 @@ if ( globalThis.__Ziko__ ) {
|
|
|
13570
13657
|
ExtractAll,
|
|
13571
13658
|
RemoveAll
|
|
13572
13659
|
};
|
|
13660
|
+
defineParamsGetter(__Ziko__);
|
|
13573
13661
|
}
|
|
13574
13662
|
// globalThis.__Ziko__={
|
|
13575
13663
|
// ...Ziko,
|
|
@@ -13615,10 +13703,12 @@ exports.Complex = Complex;
|
|
|
13615
13703
|
exports.E = E;
|
|
13616
13704
|
exports.EPSILON = EPSILON;
|
|
13617
13705
|
exports.Ease = Ease;
|
|
13706
|
+
exports.FileBasedRouting = FileBasedRouting;
|
|
13618
13707
|
exports.Flex = Flex$1;
|
|
13619
13708
|
exports.Footer = Footer;
|
|
13620
13709
|
exports.Form = Form;
|
|
13621
13710
|
exports.Grid = Grid$1;
|
|
13711
|
+
exports.HTMLWrapper = HTMLWrapper;
|
|
13622
13712
|
exports.Header = Header;
|
|
13623
13713
|
exports.LinearSystem = LinearSystem;
|
|
13624
13714
|
exports.Logic = Logic$1;
|
|
@@ -13630,6 +13720,7 @@ exports.PI = PI;
|
|
|
13630
13720
|
exports.Permutation = Permutation;
|
|
13631
13721
|
exports.Random = Random;
|
|
13632
13722
|
exports.SPA = SPA;
|
|
13723
|
+
exports.SVGWrapper = SVGWrapper;
|
|
13633
13724
|
exports.Section = Section;
|
|
13634
13725
|
exports.Signal = Signal;
|
|
13635
13726
|
exports.Slider = Slider;
|
|
@@ -13660,6 +13751,7 @@ exports.ZikoUIFlex = ZikoUIFlex$1;
|
|
|
13660
13751
|
exports.ZikoUIFooter = ZikoUIFooter;
|
|
13661
13752
|
exports.ZikoUIForm = ZikoUIForm;
|
|
13662
13753
|
exports.ZikoUIGrid = ZikoUIGrid;
|
|
13754
|
+
exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
|
|
13663
13755
|
exports.ZikoUIHeader = ZikoUIHeader;
|
|
13664
13756
|
exports.ZikoUIHeading = ZikoUIHeading;
|
|
13665
13757
|
exports.ZikoUIHorizontalSlider = ZikoUIHorizontalSlider;
|
|
@@ -13690,6 +13782,7 @@ exports.ZikoUIModal = ZikoUIModal;
|
|
|
13690
13782
|
exports.ZikoUINav = ZikoUINav;
|
|
13691
13783
|
exports.ZikoUIParagraphe = ZikoUIParagraphe;
|
|
13692
13784
|
exports.ZikoUIQuote = ZikoUIQuote;
|
|
13785
|
+
exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
|
|
13693
13786
|
exports.ZikoUISection = ZikoUISection;
|
|
13694
13787
|
exports.ZikoUISelect = ZikoUISelect;
|
|
13695
13788
|
exports.ZikoUISubText = ZikoUISubText;
|
|
@@ -13700,6 +13793,7 @@ exports.ZikoUITextArea = ZikoUITextArea;
|
|
|
13700
13793
|
exports.ZikoUIVerticalSlider = ZikoUIVerticalSlider;
|
|
13701
13794
|
exports.ZikoUIVerticalSplitter = ZikoUIVerticalSplitter;
|
|
13702
13795
|
exports.ZikoUIVideo = ZikoUIVideo;
|
|
13796
|
+
exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
|
|
13703
13797
|
exports.__Config__ = __Config__;
|
|
13704
13798
|
exports.__UI__ = __UI__;
|
|
13705
13799
|
exports.abbrText = abbrText;
|
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 : Sun Oct 13 2024 15:43:24 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
|
|
@@ -3883,7 +3883,7 @@
|
|
|
3883
3883
|
}
|
|
3884
3884
|
}
|
|
3885
3885
|
|
|
3886
|
-
const useHead
|
|
3886
|
+
const useHead=({ title, lang, icon, meta, noscript })=>new ZikoHead({ title, lang, icon, meta, noscript });
|
|
3887
3887
|
|
|
3888
3888
|
const LightThemes={
|
|
3889
3889
|
cozyCottonCandy: {
|
|
@@ -5800,7 +5800,7 @@
|
|
|
5800
5800
|
useTitle,
|
|
5801
5801
|
useFavIcon,
|
|
5802
5802
|
useMeta,
|
|
5803
|
-
useHead
|
|
5803
|
+
useHead,
|
|
5804
5804
|
useThrottle,
|
|
5805
5805
|
useDebounce,
|
|
5806
5806
|
useLocaleStorage,
|
|
@@ -7064,6 +7064,35 @@
|
|
|
7064
7064
|
}
|
|
7065
7065
|
const inputDateTime = () => new ZikoUIInputDateTime();
|
|
7066
7066
|
|
|
7067
|
+
class ZikoUIXMLWrapper extends ZikoUIElement$1{
|
|
7068
|
+
constructor(XMLContent, type){
|
|
7069
|
+
super("div", "");
|
|
7070
|
+
this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent));
|
|
7071
|
+
}
|
|
7072
|
+
}
|
|
7073
|
+
function html2dom(htmlString) {
|
|
7074
|
+
const parser = new DOMParser();
|
|
7075
|
+
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
7076
|
+
return doc.body.firstChild;
|
|
7077
|
+
}
|
|
7078
|
+
function svg2dom(svgString) {
|
|
7079
|
+
const parser = new DOMParser();
|
|
7080
|
+
const doc = parser.parseFromString(svgString, 'image/svg+xml');
|
|
7081
|
+
return doc.documentElement; // SVG elements are usually at the root
|
|
7082
|
+
}
|
|
7083
|
+
class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
|
|
7084
|
+
constructor(HTMLContent){
|
|
7085
|
+
super(HTMLContent, "html");
|
|
7086
|
+
}
|
|
7087
|
+
}
|
|
7088
|
+
class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
|
|
7089
|
+
constructor(SVGContent){
|
|
7090
|
+
super(SVGContent, "svg");
|
|
7091
|
+
}
|
|
7092
|
+
}
|
|
7093
|
+
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
7094
|
+
const SVGWrapper = (SVGContent) => new ZikoUIHTMLWrapper(SVGContent);
|
|
7095
|
+
|
|
7067
7096
|
class ZikoUIHtmlTag extends ZikoUIContainerElement {
|
|
7068
7097
|
constructor(element) {
|
|
7069
7098
|
super(element,"html");
|
|
@@ -7152,10 +7181,15 @@
|
|
|
7152
7181
|
|
|
7153
7182
|
var Misc = /*#__PURE__*/Object.freeze({
|
|
7154
7183
|
__proto__: null,
|
|
7184
|
+
HTMLWrapper: HTMLWrapper,
|
|
7185
|
+
SVGWrapper: SVGWrapper,
|
|
7155
7186
|
ZikoUIBr: ZikoUIBr,
|
|
7187
|
+
ZikoUIHTMLWrapper: ZikoUIHTMLWrapper,
|
|
7156
7188
|
ZikoUIHr: ZikoUIHr,
|
|
7157
7189
|
ZikoUIHtmlTag: ZikoUIHtmlTag,
|
|
7158
7190
|
ZikoUILink: ZikoUILink,
|
|
7191
|
+
ZikoUISVGWrapper: ZikoUISVGWrapper,
|
|
7192
|
+
ZikoUIXMLWrapper: ZikoUIXMLWrapper,
|
|
7159
7193
|
br: br,
|
|
7160
7194
|
brs: brs,
|
|
7161
7195
|
btn: btn,
|
|
@@ -13279,7 +13313,7 @@
|
|
|
13279
13313
|
this.head && this.setHead(this.head);
|
|
13280
13314
|
this.wrapper && this.setWrapper(this.wrapper);
|
|
13281
13315
|
this.target && this.setTarget(this.target);
|
|
13282
|
-
this.wrapper.render(this.target);
|
|
13316
|
+
if(this.wrapper && this.target)this.wrapper.render(this.target);
|
|
13283
13317
|
}
|
|
13284
13318
|
setTarget(target){
|
|
13285
13319
|
if(target instanceof HTMLElement) this.target = target;
|
|
@@ -13422,8 +13456,6 @@
|
|
|
13422
13456
|
class ZikoSPA extends ZikoApp{
|
|
13423
13457
|
constructor({head, wrapper, target, routes}){
|
|
13424
13458
|
super({head, wrapper, target});
|
|
13425
|
-
// this.wrapper=wrapper;
|
|
13426
|
-
console.log(target);
|
|
13427
13459
|
this.routes=new Map([
|
|
13428
13460
|
["404",text$1("Error 404")],
|
|
13429
13461
|
...Object.entries(routes)
|
|
@@ -13450,6 +13482,7 @@
|
|
|
13450
13482
|
if(typeof callback === "function") element = callback();
|
|
13451
13483
|
}
|
|
13452
13484
|
if(element?.isZikoUIElement) element.render(this.wrapper);
|
|
13485
|
+
// if(element?.isZikoApp) element.render(this.wrapper);
|
|
13453
13486
|
if(element instanceof Promise){
|
|
13454
13487
|
element.then(e=>e.render(this.wrapper));
|
|
13455
13488
|
}
|
|
@@ -13474,7 +13507,7 @@
|
|
|
13474
13507
|
ZikoSPA: ZikoSPA
|
|
13475
13508
|
});
|
|
13476
13509
|
|
|
13477
|
-
function
|
|
13510
|
+
function parseQueryParams(queryString) {
|
|
13478
13511
|
const params = {};
|
|
13479
13512
|
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
13480
13513
|
const [key, value] = match.split('=');
|
|
@@ -13483,19 +13516,19 @@
|
|
|
13483
13516
|
return params;
|
|
13484
13517
|
}
|
|
13485
13518
|
|
|
13486
|
-
function defineParamsGetter(target
|
|
13519
|
+
function defineParamsGetter(target ){
|
|
13487
13520
|
Object.defineProperties(target, {
|
|
13488
13521
|
'QueryParams': {
|
|
13489
13522
|
get: function() {
|
|
13490
|
-
return
|
|
13523
|
+
return parseQueryParams(globalThis.location.search.substring(1));
|
|
13491
13524
|
},
|
|
13492
13525
|
configurable: false,
|
|
13493
13526
|
enumerable: true
|
|
13494
13527
|
},
|
|
13495
13528
|
'HashParams': {
|
|
13496
13529
|
get: function() {
|
|
13497
|
-
const hash =
|
|
13498
|
-
return
|
|
13530
|
+
const hash = globalThis.location.hash.substring(1);
|
|
13531
|
+
return hash.split("#");
|
|
13499
13532
|
},
|
|
13500
13533
|
configurable: false,
|
|
13501
13534
|
enumerable: true
|
|
@@ -13503,11 +13536,6 @@
|
|
|
13503
13536
|
});
|
|
13504
13537
|
}
|
|
13505
13538
|
|
|
13506
|
-
var Params = /*#__PURE__*/Object.freeze({
|
|
13507
|
-
__proto__: null,
|
|
13508
|
-
defineParamsGetter: defineParamsGetter
|
|
13509
|
-
});
|
|
13510
|
-
|
|
13511
13539
|
const __UI__={};
|
|
13512
13540
|
const __Config__={
|
|
13513
13541
|
default:{
|
|
@@ -13531,12 +13559,71 @@
|
|
|
13531
13559
|
__UI__: __UI__
|
|
13532
13560
|
});
|
|
13533
13561
|
|
|
13562
|
+
// import.meta.glob('./src/pages/**/*.js')
|
|
13563
|
+
async function FileBasedRouting(pages /* use import.meta.glob */){
|
|
13564
|
+
const routes = Object.keys(pages);
|
|
13565
|
+
const root = findCommonPath(routes);
|
|
13566
|
+
// console.log({root})
|
|
13567
|
+
const pairs = {};
|
|
13568
|
+
for(let i=0; i<routes.length; i++){
|
|
13569
|
+
const module = await pages[routes[i]]();
|
|
13570
|
+
const component = await module.default;
|
|
13571
|
+
Object.assign(pairs,{[customPath(routes[i], root)]:component});
|
|
13572
|
+
}
|
|
13573
|
+
return SPA({
|
|
13574
|
+
target : document.body,
|
|
13575
|
+
routes : {
|
|
13576
|
+
"/" : ()=>{},
|
|
13577
|
+
...pairs
|
|
13578
|
+
},
|
|
13579
|
+
wrapper : Section()
|
|
13580
|
+
})
|
|
13581
|
+
}
|
|
13582
|
+
function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts']) {
|
|
13583
|
+
if(root.at(-1)==="/") root = root.slice(0, -1);
|
|
13584
|
+
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
13585
|
+
const parts = normalizedPath.split('/');
|
|
13586
|
+
const rootParts = root.split('/');
|
|
13587
|
+
const rootIndex = parts.indexOf(rootParts[rootParts.length - 1]);
|
|
13588
|
+
if (rootIndex !== -1) {
|
|
13589
|
+
const subsequentParts = parts.slice(rootIndex + 1);
|
|
13590
|
+
const lastPart = subsequentParts[subsequentParts.length - 1];
|
|
13591
|
+
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
13592
|
+
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
13593
|
+
if (isIndexFile) {
|
|
13594
|
+
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
|
13595
|
+
}
|
|
13596
|
+
if (hasValidExtension) {
|
|
13597
|
+
return '/' + subsequentParts.join('/').replace(/\.(js|ts)$/, '');
|
|
13598
|
+
}
|
|
13599
|
+
}
|
|
13600
|
+
return '';
|
|
13601
|
+
}
|
|
13602
|
+
function findCommonPath(paths) {
|
|
13603
|
+
if (paths.length === 0) return '';
|
|
13604
|
+
const splitPaths = paths.map(path => path.split('/'));
|
|
13605
|
+
const minLength = Math.min(...splitPaths.map(parts => parts.length));
|
|
13606
|
+
let commonParts = [];
|
|
13607
|
+
for (let i = 0; i < minLength; i++) {
|
|
13608
|
+
const part = splitPaths[0][i];
|
|
13609
|
+
if (splitPaths.every(parts => parts[i] === part || parts[i].startsWith('['))) {
|
|
13610
|
+
commonParts.push(part);
|
|
13611
|
+
} else {
|
|
13612
|
+
break;
|
|
13613
|
+
}
|
|
13614
|
+
}
|
|
13615
|
+
const commonPath = commonParts.join('/') + (commonParts.length ? '/' : '');
|
|
13616
|
+
return commonPath;
|
|
13617
|
+
}
|
|
13618
|
+
|
|
13619
|
+
// import * as Params from "./params"
|
|
13620
|
+
|
|
13534
13621
|
const App={
|
|
13535
13622
|
...__App__,
|
|
13536
13623
|
...JsonStyleSheet,
|
|
13537
13624
|
...Spa,
|
|
13538
13625
|
...Global,
|
|
13539
|
-
...Params
|
|
13626
|
+
// ...Params
|
|
13540
13627
|
};
|
|
13541
13628
|
|
|
13542
13629
|
[
|
|
@@ -13572,6 +13659,7 @@
|
|
|
13572
13659
|
ExtractAll,
|
|
13573
13660
|
RemoveAll
|
|
13574
13661
|
};
|
|
13662
|
+
defineParamsGetter(__Ziko__);
|
|
13575
13663
|
}
|
|
13576
13664
|
// globalThis.__Ziko__={
|
|
13577
13665
|
// ...Ziko,
|
|
@@ -13617,10 +13705,12 @@
|
|
|
13617
13705
|
exports.E = E;
|
|
13618
13706
|
exports.EPSILON = EPSILON;
|
|
13619
13707
|
exports.Ease = Ease;
|
|
13708
|
+
exports.FileBasedRouting = FileBasedRouting;
|
|
13620
13709
|
exports.Flex = Flex$1;
|
|
13621
13710
|
exports.Footer = Footer;
|
|
13622
13711
|
exports.Form = Form;
|
|
13623
13712
|
exports.Grid = Grid$1;
|
|
13713
|
+
exports.HTMLWrapper = HTMLWrapper;
|
|
13624
13714
|
exports.Header = Header;
|
|
13625
13715
|
exports.LinearSystem = LinearSystem;
|
|
13626
13716
|
exports.Logic = Logic$1;
|
|
@@ -13632,6 +13722,7 @@
|
|
|
13632
13722
|
exports.Permutation = Permutation;
|
|
13633
13723
|
exports.Random = Random;
|
|
13634
13724
|
exports.SPA = SPA;
|
|
13725
|
+
exports.SVGWrapper = SVGWrapper;
|
|
13635
13726
|
exports.Section = Section;
|
|
13636
13727
|
exports.Signal = Signal;
|
|
13637
13728
|
exports.Slider = Slider;
|
|
@@ -13662,6 +13753,7 @@
|
|
|
13662
13753
|
exports.ZikoUIFooter = ZikoUIFooter;
|
|
13663
13754
|
exports.ZikoUIForm = ZikoUIForm;
|
|
13664
13755
|
exports.ZikoUIGrid = ZikoUIGrid;
|
|
13756
|
+
exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
|
|
13665
13757
|
exports.ZikoUIHeader = ZikoUIHeader;
|
|
13666
13758
|
exports.ZikoUIHeading = ZikoUIHeading;
|
|
13667
13759
|
exports.ZikoUIHorizontalSlider = ZikoUIHorizontalSlider;
|
|
@@ -13692,6 +13784,7 @@
|
|
|
13692
13784
|
exports.ZikoUINav = ZikoUINav;
|
|
13693
13785
|
exports.ZikoUIParagraphe = ZikoUIParagraphe;
|
|
13694
13786
|
exports.ZikoUIQuote = ZikoUIQuote;
|
|
13787
|
+
exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
|
|
13695
13788
|
exports.ZikoUISection = ZikoUISection;
|
|
13696
13789
|
exports.ZikoUISelect = ZikoUISelect;
|
|
13697
13790
|
exports.ZikoUISubText = ZikoUISubText;
|
|
@@ -13702,6 +13795,7 @@
|
|
|
13702
13795
|
exports.ZikoUIVerticalSlider = ZikoUIVerticalSlider;
|
|
13703
13796
|
exports.ZikoUIVerticalSplitter = ZikoUIVerticalSplitter;
|
|
13704
13797
|
exports.ZikoUIVideo = ZikoUIVideo;
|
|
13798
|
+
exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
|
|
13705
13799
|
exports.__Config__ = __Config__;
|
|
13706
13800
|
exports.__UI__ = __UI__;
|
|
13707
13801
|
exports.abbrText = abbrText;
|