@stacksjs/stx 0.2.385 → 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-864b6wcd.js → chunk-0d400env.js} +2 -2
- package/dist/{chunk-sr3f7gk2.js → chunk-0svt5qe9.js} +1 -1
- package/dist/{chunk-pefddsqn.js → chunk-1f4p4q5f.js} +1 -1
- package/dist/{chunk-7e31d2d9.js → chunk-1s62yrgf.js} +1 -1
- package/dist/{chunk-9tsdve0c.js → chunk-1wwq2hf7.js} +1 -1
- package/dist/{chunk-hgwwpgkn.js → chunk-1yp16bqa.js} +1 -1
- package/dist/{chunk-4wr5khha.js → chunk-27b1p4am.js} +1 -1
- package/dist/{chunk-xvp7ye5d.js → chunk-30ztgrwg.js} +1 -1
- package/dist/{chunk-6en9gsg5.js → chunk-3d5vd5tb.js} +1 -1
- package/dist/chunk-3p1fn3gp.js +2 -0
- package/dist/{chunk-hr42tde6.js → chunk-45hf0h2b.js} +1 -1
- package/dist/{chunk-x9xcmaef.js → chunk-4aybdnf2.js} +1 -1
- package/dist/{chunk-eexraz9d.js → chunk-5gevk3y3.js} +2 -2
- package/dist/{chunk-6tsepxj2.js → chunk-5pr1epbz.js} +1 -1
- package/dist/{chunk-kmbt6knb.js → chunk-63t789rf.js} +1 -1
- package/dist/{chunk-5rxfqxw1.js → chunk-6pqqa8dw.js} +1 -1
- package/dist/{chunk-2gtwsyyc.js → chunk-6wr606dw.js} +1 -1
- package/dist/{chunk-vsjx1fe3.js → chunk-71121ca9.js} +1 -1
- package/dist/{chunk-pr1spkdp.js → chunk-7jjqgqcz.js} +1 -1
- package/dist/{chunk-2qqc4btz.js → chunk-96f7et3b.js} +1 -1
- package/dist/{chunk-er75fpqj.js → chunk-970w2yaz.js} +1 -1
- package/dist/{chunk-51v42enn.js → chunk-97k1c7kg.js} +1 -1
- package/dist/{chunk-c30z8jtq.js → chunk-9bmr64zw.js} +2 -2
- package/dist/{chunk-k4f1jwfy.js → chunk-9t1dpe62.js} +1 -1
- package/dist/{chunk-kddj8m3q.js → chunk-9yjsfgbn.js} +2 -2
- package/dist/{chunk-ndnk50mc.js → chunk-arw934yt.js} +1 -1
- package/dist/{chunk-4a8wet24.js → chunk-b1w2m1qy.js} +102 -5
- package/dist/{chunk-tj7wpqnm.js → chunk-d0dyfx38.js} +1 -1
- package/dist/{chunk-vj19hasp.js → chunk-djhvf50g.js} +16 -16
- package/dist/{chunk-dpk10wzg.js → chunk-e51gdw0s.js} +1 -1
- package/dist/{chunk-y2zrdxg3.js → chunk-exg9jgpk.js} +1 -1
- package/dist/chunk-f2996efp.js +2 -0
- package/dist/{chunk-x3j8w3g8.js → chunk-f71yx41s.js} +1 -1
- package/dist/{chunk-7zwkhc9z.js → chunk-fkwajrwx.js} +1 -1
- package/dist/{chunk-dwk6afax.js → chunk-gg703928.js} +1 -1
- package/dist/{chunk-3mvs006a.js → chunk-jvyyhrq7.js} +1 -1
- package/dist/{chunk-jz660eaa.js → chunk-kyxnw5hb.js} +1 -1
- package/dist/{chunk-74pnrjrh.js → chunk-me0x7cvh.js} +1 -1
- package/dist/{chunk-0bsr2bc9.js → chunk-mnsn7mk4.js} +1 -1
- package/dist/{chunk-trnwjst0.js → chunk-n2pfwy0k.js} +1 -1
- package/dist/{chunk-2egh74rh.js → chunk-n4vrkfw7.js} +1 -1
- package/dist/{chunk-s8wvhby3.js → chunk-nd1xhe46.js} +1 -1
- package/dist/{chunk-xr9cxkxp.js → chunk-npxkvbmw.js} +1 -1
- package/dist/chunk-rz60f61k.js +2 -0
- package/dist/{chunk-yswz2ze7.js → chunk-sng4nsy9.js} +1 -1
- package/dist/{chunk-wp8273q0.js → chunk-vqyy141z.js} +33 -12
- package/dist/{chunk-gaghjpf3.js → chunk-vrtjh8yz.js} +1 -1
- package/dist/{chunk-yx5ct9vx.js → chunk-w26jfks1.js} +1 -1
- package/dist/{chunk-daqc7qct.js → chunk-x403abp4.js} +1 -1
- package/dist/{chunk-d5h4fq9g.js → chunk-xjaz254t.js} +1 -1
- package/dist/{chunk-0k1g666f.js → chunk-xv8t5mk1.js} +1 -1
- package/dist/{chunk-rck90601.js → chunk-z7nvh4mk.js} +1 -1
- package/dist/{chunk-x05ycjc4.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-e686ewmg.js +0 -2
- package/dist/chunk-kf7mza0j.js +0 -2
- package/dist/chunk-xn3pwe6e.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
|
|
@@ -1281,7 +1358,7 @@ else {
|
|
|
1281
1358
|
if(hasImport){
|
|
1282
1359
|
ns.type='module';
|
|
1283
1360
|
}
|
|
1284
|
-
ns.textContent=(hasImport||isAlreadyScoped)?code:'{'+code+'}';
|
|
1361
|
+
ns.textContent=markRan((hasImport||isAlreadyScoped)?code:'{'+code+'}');
|
|
1285
1362
|
ns.setAttribute('data-stx-page','');
|
|
1286
1363
|
if(placeholder&&placeholder.parentNode){
|
|
1287
1364
|
ns.setAttribute('data-stx-positioned','');
|
|
@@ -1322,7 +1399,9 @@ else {
|
|
|
1322
1399
|
resolve(true);
|
|
1323
1400
|
}catch(err){reject(err)}
|
|
1324
1401
|
}
|
|
1325
|
-
if(
|
|
1402
|
+
if(instantNav&&swapRunsInOneTask(html,url)){runInOneTask(completeFragSwap)}
|
|
1403
|
+
else if(instantNav&&runInstantSwap(completeFragSwap)){}
|
|
1404
|
+
else if(runViewTransition(completeFragSwap)){}
|
|
1326
1405
|
else if(instantNav){completeFragSwap()}
|
|
1327
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)}
|
|
1328
1407
|
});
|
|
@@ -1738,7 +1817,7 @@ else {
|
|
|
1738
1817
|
// ESM, and top-level 'import' is illegal inside a block, which
|
|
1739
1818
|
// would throw SyntaxError before the script ever runs.
|
|
1740
1819
|
var alreadyScoped=runsAlways(typeof entry==='string'?'':entry.run,text);
|
|
1741
|
-
ns.textContent=(hasImport||alreadyScoped)?text:'{'+text+republishTopLevel(text)+'}';
|
|
1820
|
+
ns.textContent=markRan((hasImport||alreadyScoped)?text:'{'+text+republishTopLevel(text)+'}');
|
|
1742
1821
|
ns.setAttribute('data-stx-page','');
|
|
1743
1822
|
var placeholder=entry.slot?qs('script[data-stx-route-script="'+entry.slot+'"]'):null;
|
|
1744
1823
|
if(placeholder&&placeholder.parentNode){
|
|
@@ -1772,7 +1851,9 @@ else {
|
|
|
1772
1851
|
resolve(true);
|
|
1773
1852
|
}catch(err){reject(err)}
|
|
1774
1853
|
}
|
|
1775
|
-
if(
|
|
1854
|
+
if(instantNav&&runInstantSwap(completeSwap)){
|
|
1855
|
+
}
|
|
1856
|
+
else if(runViewTransition(completeSwap)){
|
|
1776
1857
|
}
|
|
1777
1858
|
else if(instantNav){
|
|
1778
1859
|
// A tab: swap at once, no fade either way.
|
|
@@ -2067,9 +2148,25 @@ else {
|
|
|
2067
2148
|
return readPrefetchResponse(r,wantsFragment);
|
|
2068
2149
|
}).then(function(result){
|
|
2069
2150
|
if(result&&o.cache)setCache(key,result.html,result.layout,result.layoutGroup,result.title,result.containerAttrs);
|
|
2151
|
+
if(result)loadModuleRegistries(result.html,href);
|
|
2070
2152
|
}).catch(function(){}).finally(function(){delete prefetching[key]});
|
|
2071
2153
|
}
|
|
2072
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
|
+
|
|
2073
2170
|
// Links marked data-stx-prefetch="eager", fetched once the page is idle, so
|
|
2074
2171
|
// even their first tap is served from the cache: the way a phone's tab bar
|
|
2075
2172
|
// switches instantly. Not on a connection that asked to save data.
|
|
@@ -2264,7 +2361,7 @@ else {
|
|
|
2264
2361
|
// The container the router focuses after a navigation is not a
|
|
2265
2362
|
// control, so it draws no focus ring: Safari drew one around the whole
|
|
2266
2363
|
// page, a blue line along its bottom edge on every screen.
|
|
2267
|
-
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}';
|
|
2268
2365
|
if(o.viewTransitions&&'startViewTransition' in document){
|
|
2269
2366
|
var dur=(o.viewTransitionDuration||220)+'ms';
|
|
2270
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};
|