stx-router 0.2.281 → 0.2.284

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 (2) hide show
  1. package/dist/client.js +33 -33
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -259,7 +259,7 @@ export function getRouterScript() {
259
259
  return blocks;
260
260
  }
261
261
 
262
- function mergeCrosswindCSS(existing,incoming){
262
+ function mergeCss(existing,incoming){
263
263
  var blocks=extractCssBlocks(incoming);
264
264
  var newBlocks=[];
265
265
  for(var bi=0;bi<blocks.length;bi++){
@@ -789,8 +789,8 @@ else {
789
789
  var fragScripts=[];
790
790
  var fragScriptId=0;
791
791
  var fragStyles=[];
792
- var fragCrosswindHrefs=[];
793
- var fragCrosswindCSS=null;
792
+ var fragCssHrefs=[];
793
+ var fragCss=null;
794
794
  var fragExternalScripts=[];
795
795
  var cleanFrag=html.replace(new RegExp('<scr'+'ipt\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/scr'+'ipt>','gi'),function(m,attrs,code){
796
796
  // A data block is not code, and everything below this line assumes it
@@ -831,43 +831,43 @@ else {
831
831
  return '';
832
832
  });
833
833
  cleanFrag=cleanFrag.replace(new RegExp('<sty'+'le\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/sty'+'le>','gi'),function(m,attrs,css){
834
- if(attrs.indexOf('data-crosswind')!==-1){
835
- fragCrosswindCSS=css;
834
+ if(attrs.indexOf('data-css')!==-1){
835
+ fragCss=css;
836
836
  }else{
837
837
  fragStyles.push({attrs:attrs,css:css});
838
838
  }
839
839
  return '';
840
840
  });
841
841
  cleanFrag=cleanFrag.replace(new RegExp('<link\\\\b([^>]*)>','gi'),function(m,attrs){
842
- if(attrs.indexOf('data-crosswind')===-1)return m;
842
+ if(attrs.indexOf('data-css')===-1)return m;
843
843
  var hrefMatch=attrs.match(/\\bhref=(["'])(.*?)\\1/i);
844
- if(hrefMatch&&hrefMatch[2])fragCrosswindHrefs.push(hrefMatch[2]);
844
+ if(hrefMatch&&hrefMatch[2])fragCssHrefs.push(hrefMatch[2]);
845
845
  return '';
846
846
  });
847
- // Remove old page styles (not crosswind \u2014 that gets merged)
847
+ // Remove old page styles (not css \u2014 that gets merged)
848
848
  document.querySelectorAll('style[data-stx-page]').forEach(function(s){s.remove()});
849
- // Merge crosswind CSS from fragment into existing crosswind style
850
- if(fragCrosswindCSS){
851
- var curCrosswind=document.querySelector('head style[data-crosswind]');
852
- if(curCrosswind){
853
- var merged=mergeCrosswindCSS(curCrosswind.textContent||'',fragCrosswindCSS);
854
- if(merged)curCrosswind.textContent=merged;
849
+ // Merge css CSS from fragment into existing css style
850
+ if(fragCss){
851
+ var curCss=document.querySelector('head style[data-css]');
852
+ if(curCss){
853
+ var merged=mergeCss(curCss.textContent||'',fragCss);
854
+ if(merged)curCss.textContent=merged;
855
855
  }else{
856
856
  var cw=document.createElement('style');
857
- cw.setAttribute('data-crosswind','generated');
858
- cw.textContent=fragCrosswindCSS;
857
+ cw.setAttribute('data-css','generated');
858
+ cw.textContent=fragCss;
859
859
  document.head.appendChild(cw);
860
860
  }
861
861
  }
862
- fragCrosswindHrefs.forEach(function(href){
862
+ fragCssHrefs.forEach(function(href){
863
863
  var absolute=new URL(href,location.href).href;
864
864
  var exists=false;
865
- document.querySelectorAll('head link[data-crosswind][href]').forEach(function(link){
865
+ document.querySelectorAll('head link[data-css][href]').forEach(function(link){
866
866
  if(new URL(link.getAttribute('href'),location.href).href===absolute)exists=true;
867
867
  });
868
868
  if(exists)return;
869
869
  var link=document.createElement('link');
870
- link.setAttribute('data-crosswind','generated');
870
+ link.setAttribute('data-css','generated');
871
871
  link.setAttribute('rel','stylesheet');
872
872
  link.setAttribute('href',href);
873
873
  document.head.appendChild(link);
@@ -1037,20 +1037,20 @@ else {
1037
1037
  var curStyles=document.querySelectorAll('head style');
1038
1038
  var newStyles=doc.querySelectorAll('head style');
1039
1039
 
1040
- // Merge crosswind styles instead of replacing \u2014 persistent elements
1040
+ // Merge css styles instead of replacing \u2014 persistent elements
1041
1041
  // (nav, footer) outside <main> still need their utility classes
1042
- var curCrosswind=document.querySelector('head style[data-crosswind]');
1043
- var newCrosswind=null;
1044
- newStyles.forEach(function(s){if(s.getAttribute('data-crosswind'))newCrosswind=s});
1042
+ var curCss=document.querySelector('head style[data-css]');
1043
+ var newCss=null;
1044
+ newStyles.forEach(function(s){if(s.getAttribute('data-css'))newCss=s});
1045
1045
 
1046
- if(curCrosswind&&newCrosswind){
1047
- var merged=mergeCrosswindCSS(curCrosswind.textContent||'',newCrosswind.textContent||'');
1048
- if(merged)curCrosswind.textContent=merged;
1046
+ if(curCss&&newCss){
1047
+ var merged=mergeCss(curCss.textContent||'',newCss.textContent||'');
1048
+ if(merged)curCss.textContent=merged;
1049
1049
  }
1050
1050
 
1051
1051
  var incoming=[];
1052
1052
  newStyles.forEach(function(s){
1053
- if(!keepIds[s.id]&&!s.getAttribute('data-crosswind')){
1053
+ if(!keepIds[s.id]&&!s.getAttribute('data-css')){
1054
1054
  var ns=document.createElement('style');
1055
1055
  ns.textContent=s.textContent;
1056
1056
  ns.setAttribute('data-stx-incoming','');
@@ -1059,17 +1059,17 @@ else {
1059
1059
  }
1060
1060
  });
1061
1061
 
1062
- // If no existing crosswind but new page has one, add it
1063
- if(!curCrosswind&&newCrosswind){
1062
+ // If no existing css but new page has one, add it
1063
+ if(!curCss&&newCss){
1064
1064
  var ns=document.createElement('style');
1065
- ns.textContent=newCrosswind.textContent;
1066
- ns.setAttribute('data-crosswind',newCrosswind.getAttribute('data-crosswind'));
1065
+ ns.textContent=newCss.textContent;
1066
+ ns.setAttribute('data-css',newCss.getAttribute('data-css'));
1067
1067
  document.head.appendChild(ns);
1068
1068
  }
1069
1069
 
1070
- // Remove old styles (except persistent ones, crosswind, and incoming)
1070
+ // Remove old styles (except persistent ones, css, and incoming)
1071
1071
  curStyles.forEach(function(s){
1072
- if(!keepIds[s.id]&&!s.hasAttribute('data-stx-incoming')&&!s.hasAttribute('data-crosswind'))s.remove();
1072
+ if(!keepIds[s.id]&&!s.hasAttribute('data-stx-incoming')&&!s.hasAttribute('data-css'))s.remove();
1073
1073
  });
1074
1074
 
1075
1075
  incoming.forEach(function(s){s.removeAttribute('data-stx-incoming')});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stx-router",
3
3
  "type": "module",
4
- "version": "0.2.281",
4
+ "version": "0.2.284",
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",