@stacksjs/stx 0.2.384 → 0.2.386
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/{chunk-d4wkjmb8.js → chunk-0d400env.js} +2 -2
- package/dist/{chunk-bmcgsygy.js → chunk-0svt5qe9.js} +1 -1
- package/dist/{chunk-f1a2pb7x.js → chunk-1f4p4q5f.js} +1 -1
- package/dist/{chunk-7eqxp3hm.js → chunk-1s62yrgf.js} +1 -1
- package/dist/{chunk-12c6gm3p.js → chunk-1wwq2hf7.js} +1 -1
- package/dist/{chunk-qf1rvd48.js → chunk-1yp16bqa.js} +1 -1
- package/dist/{chunk-b5nw27h7.js → chunk-27b1p4am.js} +1 -1
- package/dist/{chunk-c2ky58f1.js → chunk-30ztgrwg.js} +1 -1
- package/dist/{chunk-vsrta1w7.js → chunk-3d5vd5tb.js} +1 -1
- package/dist/chunk-3p1fn3gp.js +2 -0
- package/dist/{chunk-mv255z6w.js → chunk-45hf0h2b.js} +1 -1
- package/dist/{chunk-hhc11ha9.js → chunk-4aybdnf2.js} +1 -1
- package/dist/{chunk-8g18996a.js → chunk-5gevk3y3.js} +2 -2
- package/dist/{chunk-by2s9dvk.js → chunk-5pr1epbz.js} +1 -1
- package/dist/{chunk-pmgzmqhy.js → chunk-63t789rf.js} +1 -1
- package/dist/{chunk-t3bjr1wh.js → chunk-6pqqa8dw.js} +1 -1
- package/dist/{chunk-p3xzhb15.js → chunk-6wr606dw.js} +1 -1
- package/dist/{chunk-4mmyz73s.js → chunk-71121ca9.js} +1 -1
- package/dist/{chunk-s59ahgcg.js → chunk-7jjqgqcz.js} +1 -1
- package/dist/{chunk-vgcf8qvv.js → chunk-96f7et3b.js} +1 -1
- package/dist/{chunk-gdtx3v0s.js → chunk-970w2yaz.js} +1 -1
- package/dist/{chunk-7r9dydtp.js → chunk-97k1c7kg.js} +1 -1
- package/dist/{chunk-twfk678s.js → chunk-9bmr64zw.js} +2 -2
- package/dist/{chunk-q5k9214r.js → chunk-9t1dpe62.js} +1 -1
- package/dist/{chunk-0xj0p6sr.js → chunk-9yjsfgbn.js} +2 -2
- package/dist/{chunk-ejttbtk0.js → chunk-arw934yt.js} +1 -1
- package/dist/{chunk-me3ckktd.js → chunk-b1w2m1qy.js} +108 -17
- package/dist/{chunk-948tpfj7.js → chunk-d0dyfx38.js} +1 -1
- package/dist/{chunk-9mtve1jh.js → chunk-djhvf50g.js} +16 -16
- package/dist/{chunk-6t1z916a.js → chunk-e51gdw0s.js} +1 -1
- package/dist/{chunk-0v19p6qk.js → chunk-exg9jgpk.js} +1 -1
- package/dist/chunk-f2996efp.js +2 -0
- package/dist/{chunk-tgkh15zz.js → chunk-f71yx41s.js} +1 -1
- package/dist/{chunk-5vhb0dbh.js → chunk-fkwajrwx.js} +1 -1
- package/dist/{chunk-7agb0vmc.js → chunk-gg703928.js} +1 -1
- package/dist/{chunk-3mvs006a.js → chunk-jvyyhrq7.js} +1 -1
- package/dist/{chunk-8257mrss.js → chunk-kyxnw5hb.js} +1 -1
- package/dist/{chunk-p1fpngfn.js → chunk-me0x7cvh.js} +1 -1
- package/dist/{chunk-242gvseq.js → chunk-mnsn7mk4.js} +1 -1
- package/dist/{chunk-36e7ynm5.js → chunk-n2pfwy0k.js} +1 -1
- package/dist/{chunk-h5qkswtz.js → chunk-n4vrkfw7.js} +1 -1
- package/dist/{chunk-rj2afzv3.js → chunk-nd1xhe46.js} +1 -1
- package/dist/{chunk-e4dd299a.js → chunk-npxkvbmw.js} +1 -1
- package/dist/chunk-rz60f61k.js +2 -0
- package/dist/{chunk-gm9hevee.js → chunk-sng4nsy9.js} +1 -1
- package/dist/{chunk-wp8273q0.js → chunk-vqyy141z.js} +33 -12
- package/dist/{chunk-h9h1vxjb.js → chunk-vrtjh8yz.js} +1 -1
- package/dist/{chunk-7qkxzm0y.js → chunk-w26jfks1.js} +1 -1
- package/dist/{chunk-2j121dxj.js → chunk-x403abp4.js} +1 -1
- package/dist/{chunk-13vyr570.js → chunk-xjaz254t.js} +1 -1
- package/dist/{chunk-fezzf9ez.js → chunk-xv8t5mk1.js} +1 -1
- package/dist/{chunk-4nkvsqq5.js → chunk-z7nvh4mk.js} +1 -1
- package/dist/{chunk-66t6dd2q.js → chunk-zxr949mk.js} +9 -9
- package/dist/cli.js +8 -8
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/signals.js +33 -12
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-19cpd0b3.js +0 -2
- package/dist/chunk-5yp1xzk6.js +0 -2
- package/dist/chunk-wp1j4qrh.js +0 -2
|
@@ -156,6 +156,83 @@ import{Tw as v$,Uw as G}from"./chunk-wjbfget1.js";function y($){return $.split(/
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
// \u2500\u2500 Instant navigation: one frame, already filled \u2500\u2500
|
|
160
|
+
// A tab swap used to paint the new screen before its scripts had run: a page
|
|
161
|
+
// script with an import is a module, and a module runs after the task that
|
|
162
|
+
// inserted it, so for a few frames the screen showed its bare markup and then
|
|
163
|
+
// filled in, on every visit. Each inserted page script now reports when it
|
|
164
|
+
// has run, and an instant navigation holds the old frame (a View Transition
|
|
165
|
+
// with no animation) until they all have, capped so it can never hang.
|
|
166
|
+
var scriptsPending=0;
|
|
167
|
+
var hydrateWaiters=[];
|
|
168
|
+
window.__stxScriptRan=function(){
|
|
169
|
+
if(scriptsPending>0)scriptsPending--;
|
|
170
|
+
if(!scriptsPending){var w=hydrateWaiters;hydrateWaiters=[];w.forEach(function(f){f()})}
|
|
171
|
+
};
|
|
172
|
+
function markRan(code){scriptsPending++;return code+String.fromCharCode(10)+';window.__stxScriptRan&&window.__stxScriptRan();'}
|
|
173
|
+
function whenHydrated(capMs){
|
|
174
|
+
return new Promise(function(resolve){
|
|
175
|
+
var done=false;
|
|
176
|
+
function finish(){if(done)return;done=true;setTimeout(resolve,0)}
|
|
177
|
+
if(!scriptsPending){done=true;resolve();return}
|
|
178
|
+
hydrateWaiters.push(finish);
|
|
179
|
+
setTimeout(finish,capMs);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
// Whether a fragment's scripts all run inside the swap's own task: none is
|
|
183
|
+
// a module, and every file it names is already loaded. Then an instant
|
|
184
|
+
// navigation needs no held frame at all: swapped, run and bound before the
|
|
185
|
+
// browser next paints, it shows the new screen whole in the first frame.
|
|
186
|
+
function swapRunsInOneTask(html,base){
|
|
187
|
+
var sync=true;
|
|
188
|
+
html.replace(new RegExp('<scr'+'ipt\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/scr'+'ipt>','gi'),function(m,attrs,code){
|
|
189
|
+
if(!sync)return m;
|
|
190
|
+
var typeMatch=attrs.match(/\\btype\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))/i);
|
|
191
|
+
var scriptType=((typeMatch&&(typeMatch[1]||typeMatch[2]||typeMatch[3]))||'').trim().toLowerCase();
|
|
192
|
+
if(scriptType==='module'){sync=false;return m}
|
|
193
|
+
if(scriptType&&scriptType!=='text/javascript'&&scriptType!=='application/javascript')return m;
|
|
194
|
+
var srcMatch=attrs.match(/\\bsrc\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))/i);
|
|
195
|
+
var src=srcMatch&&(srcMatch[1]||srcMatch[2]||srcMatch[3]);
|
|
196
|
+
if(src){
|
|
197
|
+
if(!isSharedClientScriptAttrs(attrs)){var key=externalScriptKey(src,base);if(key&&!loadedExternalScripts[key])sync=false}
|
|
198
|
+
return m;
|
|
199
|
+
}
|
|
200
|
+
if(code&&hasStaticImport(code))sync=false;
|
|
201
|
+
return m;
|
|
202
|
+
});
|
|
203
|
+
return sync;
|
|
204
|
+
}
|
|
205
|
+
function runInOneTask(complete){
|
|
206
|
+
// The runtime binds on stx:load after a debounce; bind now, in this task.
|
|
207
|
+
function flush(){if(window.stx&&typeof window.stx._flushLoad==='function')window.stx._flushLoad()}
|
|
208
|
+
window.addEventListener('stx:load',flush,{once:true});
|
|
209
|
+
try{complete()}finally{window.removeEventListener('stx:load',flush)}
|
|
210
|
+
}
|
|
211
|
+
function runInstantSwap(complete){
|
|
212
|
+
if(!document.startViewTransition)return false;
|
|
213
|
+
var root=document.documentElement;
|
|
214
|
+
root.classList.add('stx-instant');
|
|
215
|
+
var clear=function(){root.classList.remove('stx-instant')};
|
|
216
|
+
try{
|
|
217
|
+
var transition=document.startViewTransition(function(){
|
|
218
|
+
scriptsPending=0;
|
|
219
|
+
// The runtime binds the page on stx:load after a short debounce; run
|
|
220
|
+
// it now, so the frame this reveals is bound rather than showing its
|
|
221
|
+
// {{ }} for a frame before they fill in.
|
|
222
|
+
var loaded=new Promise(function(resolve){window.addEventListener('stx:load',function(){if(window.stx&&typeof window.stx._flushLoad==='function')window.stx._flushLoad();resolve()},{once:true});setTimeout(resolve,300)});
|
|
223
|
+
complete();
|
|
224
|
+
return loaded.then(function(){return whenHydrated(300)});
|
|
225
|
+
});
|
|
226
|
+
if(transition&&transition.finished&&transition.finished.then)transition.finished.then(clear,clear);else clear();
|
|
227
|
+
if(transition&&transition.ready&&transition.ready.catch)transition.ready.catch(function(){});
|
|
228
|
+
return true;
|
|
229
|
+
}catch(err){
|
|
230
|
+
clear();
|
|
231
|
+
log('[router] instant transition unavailable:',err&&err.message?err.message:err);
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
159
236
|
// \u2500\u2500 Progress bar (0\u2192100% at top of viewport) \u2500\u2500
|
|
160
237
|
// Native loading indicator baked into the router. Starts when navigation
|
|
161
238
|
// begins, trickles up to ~90% during fetch, snaps to 100% + fades on
|
|
@@ -467,19 +544,13 @@ import{Tw as v$,Uw as G}from"./chunk-wjbfget1.js";function y($){return $.split(/
|
|
|
467
544
|
* Column-anchored: a declaration nested inside a function is indented, and
|
|
468
545
|
* is not in scope at the end of the block anyway.
|
|
469
546
|
*/
|
|
470
|
-
var
|
|
547
|
+
var TLD=/^(?:export\\s+)?(?:async\\s+)?(?:function\\s*\\*?|class|const|let|var)\\s+([$\\w]+)/gm;
|
|
471
548
|
function republishTopLevel(src){
|
|
472
|
-
var
|
|
473
|
-
|
|
474
|
-
while((m=
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
if(!names.length)return '';
|
|
478
|
-
var out='\\n;';
|
|
479
|
-
for(var i=0;i<names.length;i++){
|
|
480
|
-
out+='try{if(typeof '+names[i]+'==="function")window.'+names[i]+'='+names[i]+'}catch(e){}';
|
|
481
|
-
}
|
|
482
|
-
return out;
|
|
549
|
+
var n=[],m,o='',i;
|
|
550
|
+
TLD.lastIndex=0;
|
|
551
|
+
while((m=TLD.exec(src))!==null)if(n.indexOf(m[1])<0)n.push(m[1]);
|
|
552
|
+
for(i=0;i<n.length;i++)o+='try{typeof '+n[i]+'=="function"&&(window.'+n[i]+'='+n[i]+')}catch(e){}';
|
|
553
|
+
return o?'\\n;'+o:'';
|
|
483
554
|
}
|
|
484
555
|
function runsAlways(declared, code){
|
|
485
556
|
if(declared==='always')return true;
|
|
@@ -1287,7 +1358,7 @@ else {
|
|
|
1287
1358
|
if(hasImport){
|
|
1288
1359
|
ns.type='module';
|
|
1289
1360
|
}
|
|
1290
|
-
ns.textContent=(hasImport||isAlreadyScoped)?code:'{'+code+'}';
|
|
1361
|
+
ns.textContent=markRan((hasImport||isAlreadyScoped)?code:'{'+code+'}');
|
|
1291
1362
|
ns.setAttribute('data-stx-page','');
|
|
1292
1363
|
if(placeholder&&placeholder.parentNode){
|
|
1293
1364
|
ns.setAttribute('data-stx-positioned','');
|
|
@@ -1328,7 +1399,9 @@ else {
|
|
|
1328
1399
|
resolve(true);
|
|
1329
1400
|
}catch(err){reject(err)}
|
|
1330
1401
|
}
|
|
1331
|
-
if(
|
|
1402
|
+
if(instantNav&&swapRunsInOneTask(html,url)){runInOneTask(completeFragSwap)}
|
|
1403
|
+
else if(instantNav&&runInstantSwap(completeFragSwap)){}
|
|
1404
|
+
else if(runViewTransition(completeFragSwap)){}
|
|
1332
1405
|
else if(instantNav){completeFragSwap()}
|
|
1333
1406
|
else{currentContent.style.transition='opacity 0.12s ease-out';currentContent.style.opacity='0';setTimeout(function(){completeFragSwap();currentContent.style.opacity='1';setTimeout(function(){currentContent.style.transition=''},150)},120)}
|
|
1334
1407
|
});
|
|
@@ -1744,7 +1817,7 @@ else {
|
|
|
1744
1817
|
// ESM, and top-level 'import' is illegal inside a block, which
|
|
1745
1818
|
// would throw SyntaxError before the script ever runs.
|
|
1746
1819
|
var alreadyScoped=runsAlways(typeof entry==='string'?'':entry.run,text);
|
|
1747
|
-
ns.textContent=(hasImport||alreadyScoped)?text:'{'+text+republishTopLevel(text)+'}';
|
|
1820
|
+
ns.textContent=markRan((hasImport||alreadyScoped)?text:'{'+text+republishTopLevel(text)+'}');
|
|
1748
1821
|
ns.setAttribute('data-stx-page','');
|
|
1749
1822
|
var placeholder=entry.slot?qs('script[data-stx-route-script="'+entry.slot+'"]'):null;
|
|
1750
1823
|
if(placeholder&&placeholder.parentNode){
|
|
@@ -1778,7 +1851,9 @@ else {
|
|
|
1778
1851
|
resolve(true);
|
|
1779
1852
|
}catch(err){reject(err)}
|
|
1780
1853
|
}
|
|
1781
|
-
if(
|
|
1854
|
+
if(instantNav&&runInstantSwap(completeSwap)){
|
|
1855
|
+
}
|
|
1856
|
+
else if(runViewTransition(completeSwap)){
|
|
1782
1857
|
}
|
|
1783
1858
|
else if(instantNav){
|
|
1784
1859
|
// A tab: swap at once, no fade either way.
|
|
@@ -2073,9 +2148,25 @@ else {
|
|
|
2073
2148
|
return readPrefetchResponse(r,wantsFragment);
|
|
2074
2149
|
}).then(function(result){
|
|
2075
2150
|
if(result&&o.cache)setCache(key,result.html,result.layout,result.layoutGroup,result.title,result.containerAttrs);
|
|
2151
|
+
if(result)loadModuleRegistries(result.html,href);
|
|
2076
2152
|
}).catch(function(){}).finally(function(){delete prefetching[key]});
|
|
2077
2153
|
}
|
|
2078
2154
|
|
|
2155
|
+
// A prefetched page's module registry (the file its imports are bundled
|
|
2156
|
+
// into, one per page) is loaded with the prefetch, not on the tap. It only
|
|
2157
|
+
// registers modules, once, so loading it early changes nothing but timing,
|
|
2158
|
+
// and the tap then finds every script it needs already here: the swap runs
|
|
2159
|
+
// in one task and the first visit to a tab paints whole, like the second.
|
|
2160
|
+
function loadModuleRegistries(html,base){
|
|
2161
|
+
html.replace(new RegExp('<scr'+'ipt\\\\b([^>]*)>','gi'),function(m,attrs){
|
|
2162
|
+
if(!/(?:^|\\s)data-stx-modules(?:[\\s=]|$)/i.test(attrs))return m;
|
|
2163
|
+
var srcMatch=attrs.match(/\\bsrc\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))/i);
|
|
2164
|
+
var src=srcMatch&&(srcMatch[1]||srcMatch[2]||srcMatch[3]);
|
|
2165
|
+
if(src)loadExternalScript(src,base);
|
|
2166
|
+
return m;
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2079
2170
|
// Links marked data-stx-prefetch="eager", fetched once the page is idle, so
|
|
2080
2171
|
// even their first tap is served from the cache: the way a phone's tab bar
|
|
2081
2172
|
// switches instantly. Not on a connection that asked to save data.
|
|
@@ -2270,7 +2361,7 @@ else {
|
|
|
2270
2361
|
// The container the router focuses after a navigation is not a
|
|
2271
2362
|
// control, so it draws no focus ring: Safari drew one around the whole
|
|
2272
2363
|
// page, a blue line along its bottom edge on every screen.
|
|
2273
|
-
var css='[data-stx-route-focus]:focus{outline:none}.stx-navigating{cursor:wait}.stx-navigating a,.stx-navigating button{pointer-events:none}#stx-router-progress{position:fixed;top:0;left:0;right:0;height:'+ph+';background:'+pc+';box-shadow:0 0 8px '+pc+',0 0 4px '+pc+';transform:scaleX(0);transform-origin:left;transition:transform .18s ease-out,opacity .26s ease;opacity:0;pointer-events:none;z-index:999999}';
|
|
2364
|
+
var css='[data-stx-route-focus]:focus{outline:none}.stx-navigating{cursor:wait}.stx-navigating a,.stx-navigating button{pointer-events:none}#stx-router-progress{position:fixed;top:0;left:0;right:0;height:'+ph+';background:'+pc+';box-shadow:0 0 8px '+pc+',0 0 4px '+pc+';transform:scaleX(0);transform-origin:left;transition:transform .18s ease-out,opacity .26s ease;opacity:0;pointer-events:none;z-index:999999}html.stx-instant::view-transition-group(*),html.stx-instant::view-transition-old(*),html.stx-instant::view-transition-new(*){animation:none!important}';
|
|
2274
2365
|
if(o.viewTransitions&&'startViewTransition' in document){
|
|
2275
2366
|
var dur=(o.viewTransitionDuration||220)+'ms';
|
|
2276
2367
|
var ease=o.viewTransitionEasing||'cubic-bezier(0.16, 1, 0.3, 1)';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Vw as H}from"./chunk-wjbfget1.js";import P from"path";var $=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function G(...w){let v=new Set;for(let q of w){if(!q||!q.includes("__stxModules["))continue;for(let z of q.matchAll($))try{v.add(JSON.parse(`"${z[1]}"`))}catch{}}return[...v].sort()}async function T(w,v={}){if(w.length===0)return null;let q=process.cwd(),z=[],J=[];w.forEach((j,X)=>{let Z=j.startsWith("npm:")?j.slice(4):P.resolve(q,j),N=`__stxRegistered${X}`,O=JSON.stringify(j);z.push(`import * as ${N} from ${JSON.stringify(Z)};`),J.push(`if (!globalThis.__stxModules[${O}]) globalThis.__stxModules[${O}] = ${N};`)});let L=[...z,"globalThis.__stxModules = globalThis.__stxModules || {};",...J].join(`
|
|
3
|
-
`),B;try{let{bundleClientScript:j}=await import("./chunk-
|
|
3
|
+
`),B;try{let{bundleClientScript:j}=await import("./chunk-0svt5qe9.js");B=await j(L,P.join(q,".stx-module-registry.ts"),{projectRoot:q,minify:v.minify,externalizeUserModules:!1,collectInputs:v.collectInputs})}catch(j){return console.warn("[stx] could not build the page module registry (#1957):",j),null}let{transformAutoImports:Q,generateAutoImportDestructuring:U}=await import("./chunk-kyxnw5hb.js"),F=Q(B),V=U(F.stxImports,F.browserImports),{transformStoreImports:W}=await import("./chunk-v6xz3fkh.js");B=W(F.code);let M=JSON.stringify(new Bun.CryptoHasher("md5").update(L).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${M}]) return;`,` __stxBundles[${M}] = true;`,V,B,"})();"].join(`
|
|
4
4
|
`)}export{G as registeredModuleIdsIn,T as buildModuleRegistryScript};
|