bun-plugin-stx 0.2.331 → 0.2.332

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.
@@ -988,6 +988,15 @@ function getRouterScript() {
988
988
  function isModuleRegistryScript(s){
989
989
  return !!s&&((s.hasAttribute&&s.hasAttribute('data-stx-modules'))||REGISTRY_TEXT.test(s.textContent||''));
990
990
  }
991
+ // The page's composables (resources/functions and friends), published as
992
+ // globals its templates call. Each page ships the ones it reaches, so the
993
+ // next page can need one the first never loaded: it runs right after the
994
+ // registry, before anything that calls into it. Guarded per bundle, so a
995
+ // repeat is a no-op.
996
+ var COMPOSABLES_TEXT=/__stxComposableBundles/;
997
+ function isComposablesScript(s){
998
+ return !!s&&((s.hasAttribute&&s.hasAttribute('data-stx-composables'))||COMPOSABLES_TEXT.test(s.textContent||''));
999
+ }
991
1000
  function runsAlways(declared, code){
992
1001
  if(declared==='always')return true;
993
1002
  if(declared==='once')return false;
@@ -1642,7 +1651,8 @@ else {
1642
1651
  var runDecl=(attrs.match(/data-stx-run\\s*=\\s*["']?(always|once)["']?/i)||[])[1];
1643
1652
  var ownerDecl=(attrs.match(/data-stx-owner\\s*=\\s*["']([^"']+)["']/i)||[])[1]||'';
1644
1653
  var registry=/(?:^|\\s)data-stx-modules(?:\\s|=|$)/i.test(attrs)||REGISTRY_TEXT.test(code);
1645
- fragScripts.push({text:code,slot:slot,setupName:generatedSetupName(code),scoped:scoped,run:runDecl?runDecl.toLowerCase():'',owner:ownerDecl,registry:registry});
1654
+ var composables=/(?:^|\\s)data-stx-composables(?:\\s|=|$)/i.test(attrs)||COMPOSABLES_TEXT.test(code);
1655
+ fragScripts.push({text:code,slot:slot,setupName:generatedSetupName(code),scoped:scoped,run:runDecl?runDecl.toLowerCase():'',owner:ownerDecl,registry:registry,composables:composables});
1646
1656
  // Retain scoped setup code in its inert placeholder. A placeholder
1647
1657
  // inside template.content is unreachable through document, so the
1648
1658
  // repeated component runtime must execute it for each clone.
@@ -1718,7 +1728,7 @@ else {
1718
1728
  // after the content it serves: a component that imports a package ran
1719
1729
  // ahead of it and threw "is not registered on this page". The full
1720
1730
  // document path orders them the same way (registryFirst, below).
1721
- function fragOrder(entry){return entry.registry?0:entry.setupName?2:1}
1731
+ function fragOrder(entry){return entry.registry?0:entry.composables?1:entry.setupName?3:2}
1722
1732
  fragScripts.sort(function(a,b){return fragOrder(a)-fragOrder(b)});
1723
1733
  function runFragScripts(){
1724
1734
  fragScripts.forEach(function(entry){
@@ -1998,7 +2008,7 @@ else {
1998
2008
  var slot='document-'+(++routedBodyScriptId);
1999
2009
  var setupName=generatedSetupName(text);
2000
2010
  if(setupName)incomingSetupName=setupName;
2001
- routedBodyScripts.push({text:text,runAlways:true,slot:slot,setupName:setupName,run:s.getAttribute('data-stx-run')||'',owner:s.getAttribute('data-stx-owner')||'',registry:isModuleRegistryScript(s)});
2011
+ routedBodyScripts.push({text:text,runAlways:true,slot:slot,setupName:setupName,run:s.getAttribute('data-stx-run')||'',owner:s.getAttribute('data-stx-owner')||'',registry:isModuleRegistryScript(s),composables:isComposablesScript(s)});
2002
2012
  s.textContent='';
2003
2013
  s.setAttribute('type','application/stx-pending');
2004
2014
  s.setAttribute('data-stx-route-script',slot);
@@ -2080,7 +2090,7 @@ else {
2080
2090
 
2081
2091
  var scripts=routedBodyScripts.slice();
2082
2092
  function addScript(text, runAlways, slot, owner){
2083
- scripts.push({text:text,runAlways:!!runAlways,slot:slot||'',owner:owner||'',registry:REGISTRY_TEXT.test(text)});
2093
+ scripts.push({text:text,runAlways:!!runAlways,slot:slot||'',owner:owner||'',registry:REGISTRY_TEXT.test(text),composables:COMPOSABLES_TEXT.test(text)});
2084
2094
  }
2085
2095
  if(isLayoutChange){
2086
2096
  // Also collect setup functions from <head>, and the page's module
@@ -2096,7 +2106,7 @@ else {
2096
2106
  if(s.hasAttribute('src'))return;
2097
2107
  if(!text.trim())return;
2098
2108
  if(isSignalsRuntimeScript(s,text))return;
2099
- if(isModuleRegistryScript(s))addScript(text,true,'','');
2109
+ if(isModuleRegistryScript(s)||isComposablesScript(s))addScript(text,true,'','');
2100
2110
  else if(text.indexOf('__stx_setup_')!==-1)addScript(text,true);
2101
2111
  });
2102
2112
  } else {
@@ -2150,7 +2160,8 @@ else {
2150
2160
  // so without this a component in the page body could run ahead of the
2151
2161
  // registry it imports from. Stable: the order within each group holds.
2152
2162
  var registryFirst=scripts.filter(function(e){return e.registry});
2153
- if(registryFirst.length)scripts=registryFirst.concat(scripts.filter(function(e){return !e.registry}));
2163
+ var composablesNext=scripts.filter(function(e){return !e.registry&&e.composables});
2164
+ if(registryFirst.length||composablesNext.length)scripts=registryFirst.concat(composablesNext,scripts.filter(function(e){return !e.registry&&!e.composables}));
2154
2165
 
2155
2166
  // Push history state (before active link updates so location.pathname is current)
2156
2167
  if(pushState!==false)writeHistory(pushState,url+(hash||''));
package/dist/serve.js CHANGED
@@ -9791,7 +9791,7 @@ function __stxOverlay(errs){
9791
9791
  rebuildDiscoveredPagePaths(kept);
9792
9792
  await indexPageMiddleware(kept);
9793
9793
  try {
9794
- const { Router } = await import("./chunk-0p4k422w.js");
9794
+ const { Router } = await import("./chunk-q16hhp48.js");
9795
9795
  const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
9796
9796
  const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName(), exclude: options.exclude });
9797
9797
  if (!options.quiet)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-stx",
3
3
  "type": "module",
4
- "version": "0.2.331",
4
+ "version": "0.2.332",
5
5
  "description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -74,7 +74,7 @@
74
74
  "typecheck": "bun tsc --noEmit"
75
75
  },
76
76
  "dependencies": {
77
- "@stacksjs/stx": "0.2.331",
78
- "stx-router": "0.2.331"
77
+ "@stacksjs/stx": "0.2.332",
78
+ "stx-router": "0.2.332"
79
79
  }
80
80
  }