elegance-js 2.0.18 → 2.1.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/build.mjs +23 -974
- package/dist/client/client.mjs +20 -13
- package/dist/compile_docs.mjs +29 -980
- package/dist/global.d.ts +18 -5
- package/dist/index.mjs +9 -6
- package/dist/page_compiler.d.ts +5 -0
- package/dist/page_compiler.mjs +658 -109
- package/dist/server/generateHTMLTemplate.d.ts +1 -1
- package/dist/server/generateHTMLTemplate.mjs +5 -4
- package/dist/server/server.mjs +874 -317
- package/dist/server/state.d.ts +17 -0
- package/dist/server/state.mjs +9 -6
- package/package.json +2 -2
- package/scripts/prod.js +1 -0
- package/dist/components/Breakpoint.d.ts +0 -3
- package/dist/components/Breakpoint.mjs +0 -20
- package/dist/dynamic_page.d.ts +0 -2
- package/dist/dynamic_page.mjs +0 -591
- package/dist/server/createReference.d.ts +0 -6
- package/dist/server/createReference.mjs +0 -18
- package/dist/server/createState.d.ts +0 -64
- package/dist/server/createState.mjs +0 -65
- package/dist/server/packModule.d.ts +0 -4
- package/dist/server/packModule.mjs +0 -30
package/dist/client/client.mjs
CHANGED
|
@@ -146,8 +146,8 @@ Object.assign(globalThis, childrenlessElements);
|
|
|
146
146
|
|
|
147
147
|
// src/client/client.ts
|
|
148
148
|
console.log("Elegance.JS is loading..");
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
var pd = {};
|
|
150
|
+
var ld = {};
|
|
151
151
|
Object.assign(window, {
|
|
152
152
|
observe: (subjects, updateCallback) => {
|
|
153
153
|
return {
|
|
@@ -330,7 +330,7 @@ var initPageData = (data, currentPage2, previousPage, bindLevel) => {
|
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
};
|
|
333
|
-
var loadPage = (previousPage = null) => {
|
|
333
|
+
var loadPage = async (previousPage = null) => {
|
|
334
334
|
const fixedUrl = new URL(loc.href);
|
|
335
335
|
fixedUrl.pathname = sanitizePathname(fixedUrl.pathname);
|
|
336
336
|
const pathname = fixedUrl.pathname;
|
|
@@ -341,13 +341,14 @@ var loadPage = (previousPage = null) => {
|
|
|
341
341
|
);
|
|
342
342
|
history.replaceState(null, "", fixedUrl.href);
|
|
343
343
|
{
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
344
|
+
const pageDataScript = document.head.querySelector(`script[data-page="true"][data-pathname="${sanitizePathname(pathname)}"]`);
|
|
345
|
+
const { data } = await import(pageDataScript.src);
|
|
346
|
+
if (!pd[pathname]) pd[pathname] = data;
|
|
347
|
+
{
|
|
348
|
+
const dataScript = document.querySelector(`script[data-hook="true"][data-pathname="${sanitizePathname(pathname)}"]`);
|
|
349
|
+
if (dataScript) dataScript.remove();
|
|
348
350
|
}
|
|
349
|
-
;
|
|
350
|
-
initPageData(pageData, currentPage, previousPage, 1 /* STRICT */);
|
|
351
|
+
initPageData(pd[pathname], currentPage, previousPage, 1 /* STRICT */);
|
|
351
352
|
}
|
|
352
353
|
{
|
|
353
354
|
const parts = window.location.pathname.split("/").filter(Boolean);
|
|
@@ -356,11 +357,17 @@ var loadPage = (previousPage = null) => {
|
|
|
356
357
|
"/"
|
|
357
358
|
];
|
|
358
359
|
for (const path of paths) {
|
|
359
|
-
const
|
|
360
|
-
if (!
|
|
360
|
+
const layoutDataScript = document.querySelector(`script[data-layout="true"][data-pathname="${path}"]`);
|
|
361
|
+
if (!layoutDataScript) {
|
|
361
362
|
continue;
|
|
362
363
|
}
|
|
363
|
-
|
|
364
|
+
const { data } = await import(layoutDataScript.src);
|
|
365
|
+
if (!ld[pathname]) ld[pathname] = data;
|
|
366
|
+
{
|
|
367
|
+
const dataScript = document.querySelector(`script[data-hook="true"][data-pathname="${sanitizePathname(pathname)}"]`);
|
|
368
|
+
if (dataScript) dataScript.remove();
|
|
369
|
+
}
|
|
370
|
+
initPageData(ld[pathname], path, previousPage, 2 /* SCOPED */);
|
|
364
371
|
}
|
|
365
372
|
}
|
|
366
373
|
console.info(
|
|
@@ -481,7 +488,7 @@ var navigateLocally = async (target, pushState = true) => {
|
|
|
481
488
|
update(oldTags, newTags, (node) => node.remove());
|
|
482
489
|
}
|
|
483
490
|
if (pushState) history.pushState(null, "", targetURL.href);
|
|
484
|
-
loadPage(currentPage);
|
|
491
|
+
await loadPage(currentPage);
|
|
485
492
|
currentPage = pathname;
|
|
486
493
|
if (targetURL.hash) {
|
|
487
494
|
doc.getElementById(targetURL.hash.slice(1))?.scrollIntoView();
|