stx-router 0.2.529 → 0.2.531

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 +8 -4
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -722,10 +722,12 @@ function routerSource() {
722
722
  // globals its templates call. Each page ships the ones it reaches, so the
723
723
  // next page can need one the first never loaded: it runs right after the
724
724
  // registry, before anything that calls into it. Guarded per bundle, so a
725
- // repeat is a no-op.
725
+ // repeat is a no-op. The framework's composables (useOnline, useForm, \u2026,
726
+ // data-stx-framework-composables) are the same kind of script and run in
727
+ // the same place: after a component that calls one, it was too late.
726
728
  var COMPOSABLES_TEXT=/__stxComposableBundles/;
727
729
  function isComposablesScript(s){
728
- return !!s&&((s.hasAttribute&&s.hasAttribute('data-stx-composables'))||COMPOSABLES_TEXT.test(s.textContent||''));
730
+ return !!s&&((s.hasAttribute&&(s.hasAttribute('data-stx-composables')||s.hasAttribute('data-stx-framework-composables')))||COMPOSABLES_TEXT.test(s.textContent||''));
729
731
  }
730
732
  /*
731
733
  * What the block wrap below would otherwise hide (stacksjs/stx#2041).
@@ -1483,7 +1485,9 @@ else {
1483
1485
  var seq=++announceSeq,started=Date.now(),bound=!awaitBind,timer=null;
1484
1486
  function onLoad(){bound=true;schedule(20)}
1485
1487
  function stop(){if(timer)clearTimeout(timer);timer=null;window.removeEventListener('stx:load',onLoad)}
1486
- function schedule(ms){if(timer)clearTimeout(timer);timer=setTimeout(attempt,ms)}
1488
+ // Guarded: it runs on a timer, so it can outlive the document it was
1489
+ // scheduled for (a test's window torn down, a whole-document swap).
1490
+ function schedule(ms){if(timer)clearTimeout(timer);timer=setTimeout(function(){try{attempt()}catch(e){stop()}},ms)}
1487
1491
  function attempt(){
1488
1492
  timer=null;
1489
1493
  if(seq!==announceSeq){stop();return}
@@ -1702,7 +1706,7 @@ else {
1702
1706
  var runDecl=(attrs.match(/data-stx-run\\s*=\\s*["']?(always|once)["']?/i)||[])[1];
1703
1707
  var ownerDecl=(attrs.match(/data-stx-owner\\s*=\\s*["']([^"']+)["']/i)||[])[1]||'';
1704
1708
  var registry=/(?:^|\\s)data-stx-modules(?:\\s|=|$)/i.test(attrs)||REGISTRY_TEXT.test(code);
1705
- var composables=/(?:^|\\s)data-stx-composables(?:\\s|=|$)/i.test(attrs)||COMPOSABLES_TEXT.test(code);
1709
+ var composables=/(?:^|\\s)data-stx-(?:framework-)?composables(?:\\s|=|$)/i.test(attrs)||COMPOSABLES_TEXT.test(code);
1706
1710
  fragScripts.push({text:code,slot:slot,setupName:generatedSetupName(code),scoped:scoped,run:runDecl?runDecl.toLowerCase():'',owner:ownerDecl,registry:registry,composables:composables});
1707
1711
  // Retain scoped setup code in its inert placeholder. A placeholder
1708
1712
  // inside template.content is unreachable through document, so the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stx-router",
3
3
  "type": "module",
4
- "version": "0.2.529",
4
+ "version": "0.2.531",
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",