stx-router 0.2.133 → 0.2.134
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/client.js +20 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -425,6 +425,7 @@ else {
|
|
|
425
425
|
var fragScripts=[];
|
|
426
426
|
var fragScriptId=0;
|
|
427
427
|
var fragStyles=[];
|
|
428
|
+
var fragCrosswindHrefs=[];
|
|
428
429
|
var fragCrosswindCSS=null;
|
|
429
430
|
var cleanFrag=html.replace(new RegExp('<scr'+'ipt\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/scr'+'ipt>','gi'),function(m,attrs,code){
|
|
430
431
|
if(code&&code.trim()&&!isSignalsRuntimeScript({hasAttribute:function(name){return name==='data-stx-runtime'&&attrs.indexOf('data-stx-runtime')!==-1}},code)){
|
|
@@ -447,6 +448,12 @@ else {
|
|
|
447
448
|
}
|
|
448
449
|
return '';
|
|
449
450
|
});
|
|
451
|
+
cleanFrag=cleanFrag.replace(new RegExp('<link\\\\b([^>]*)>','gi'),function(m,attrs){
|
|
452
|
+
if(attrs.indexOf('data-crosswind')===-1)return m;
|
|
453
|
+
var hrefMatch=attrs.match(/\\bhref=(["'])(.*?)\\1/i);
|
|
454
|
+
if(hrefMatch&&hrefMatch[2])fragCrosswindHrefs.push(hrefMatch[2]);
|
|
455
|
+
return '';
|
|
456
|
+
});
|
|
450
457
|
// Remove old page styles (not crosswind \u2014 that gets merged)
|
|
451
458
|
document.querySelectorAll('style[data-stx-page]').forEach(function(s){s.remove()});
|
|
452
459
|
// Merge crosswind CSS from fragment into existing crosswind style
|
|
@@ -462,6 +469,19 @@ else {
|
|
|
462
469
|
document.head.appendChild(cw);
|
|
463
470
|
}
|
|
464
471
|
}
|
|
472
|
+
fragCrosswindHrefs.forEach(function(href){
|
|
473
|
+
var absolute=new URL(href,location.href).href;
|
|
474
|
+
var exists=false;
|
|
475
|
+
document.querySelectorAll('head link[data-crosswind][href]').forEach(function(link){
|
|
476
|
+
if(new URL(link.getAttribute('href'),location.href).href===absolute)exists=true;
|
|
477
|
+
});
|
|
478
|
+
if(exists)return;
|
|
479
|
+
var link=document.createElement('link');
|
|
480
|
+
link.setAttribute('data-crosswind','generated');
|
|
481
|
+
link.setAttribute('rel','stylesheet');
|
|
482
|
+
link.setAttribute('href',href);
|
|
483
|
+
document.head.appendChild(link);
|
|
484
|
+
});
|
|
465
485
|
// Add new page styles
|
|
466
486
|
fragStyles.forEach(function(s){
|
|
467
487
|
var el=document.createElement('style');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stx-router",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.134",
|
|
5
5
|
"description": "File-based router for STX — .stx template discovery, nested layouts, typed route params, middleware, and client-side SPA navigation.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|