bun-plugin-stx 0.2.315 → 0.2.317
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.
|
@@ -242,9 +242,11 @@ class Router {
|
|
|
242
242
|
return bSegments - aSegments;
|
|
243
243
|
return a.pattern.localeCompare(b.pattern);
|
|
244
244
|
});
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
if (config.emit !== false) {
|
|
246
|
+
const stxDir = path4.resolve(baseDir, config.stateDir || process.env.STX_DIR?.trim() || ".stx");
|
|
247
|
+
generateRouteTypes(this.routes, stxDir);
|
|
248
|
+
generateRouteManifest(this.routes, stxDir, this.pagesDir);
|
|
249
|
+
}
|
|
248
250
|
}
|
|
249
251
|
match(pathname) {
|
|
250
252
|
const normalizedPath = pathname === "" ? "/" : pathname;
|
|
@@ -962,6 +964,15 @@ function getRouterScript() {
|
|
|
962
964
|
// navigation, leaking a listener and an observer each time and resetting the
|
|
963
965
|
// instance registry \u2014 trading a silent missing component for a silent leak.
|
|
964
966
|
var REGISTERS_SCOPE=/window\\.stx\\.mount|_scopes\\s*\\[|\\.initScope\\s*\\(|__stxComponentFactories\\s*\\[/;
|
|
967
|
+
// The page's module registry (#1957): the bundle every component that
|
|
968
|
+
// imports a local module reads from, so on navigation it has to run before
|
|
969
|
+
// any of them. Marked data-stx-modules; the text test also finds it where
|
|
970
|
+
// only a script's text survives. Its wrapper names __stxModuleBundles, which
|
|
971
|
+
// no component script does -- they read __stxModules.
|
|
972
|
+
var REGISTRY_TEXT=/__stxModuleBundles/;
|
|
973
|
+
function isModuleRegistryScript(s){
|
|
974
|
+
return !!s&&((s.hasAttribute&&s.hasAttribute('data-stx-modules'))||REGISTRY_TEXT.test(s.textContent||''));
|
|
975
|
+
}
|
|
965
976
|
function runsAlways(declared, code){
|
|
966
977
|
if(declared==='always')return true;
|
|
967
978
|
if(declared==='once')return false;
|
|
@@ -1966,7 +1977,7 @@ else {
|
|
|
1966
1977
|
var slot='document-'+(++routedBodyScriptId);
|
|
1967
1978
|
var setupName=generatedSetupName(text);
|
|
1968
1979
|
if(setupName)incomingSetupName=setupName;
|
|
1969
|
-
routedBodyScripts.push({text:text,runAlways:true,slot:slot,setupName:setupName,run:s.getAttribute('data-stx-run')||'',owner:s.getAttribute('data-stx-owner')||''});
|
|
1980
|
+
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)});
|
|
1970
1981
|
s.textContent='';
|
|
1971
1982
|
s.setAttribute('type','application/stx-pending');
|
|
1972
1983
|
s.setAttribute('data-stx-route-script',slot);
|
|
@@ -2048,16 +2059,24 @@ else {
|
|
|
2048
2059
|
|
|
2049
2060
|
var scripts=routedBodyScripts.slice();
|
|
2050
2061
|
function addScript(text, runAlways, slot, owner){
|
|
2051
|
-
scripts.push({text:text,runAlways:!!runAlways,slot:slot||'',owner:owner||''});
|
|
2062
|
+
scripts.push({text:text,runAlways:!!runAlways,slot:slot||'',owner:owner||'',registry:REGISTRY_TEXT.test(text)});
|
|
2052
2063
|
}
|
|
2053
2064
|
if(isLayoutChange){
|
|
2054
|
-
// Also collect setup functions from <head
|
|
2065
|
+
// Also collect setup functions from <head>, and the page's module
|
|
2066
|
+
// registry (#1957). The registry is anchored to the signals runtime,
|
|
2067
|
+
// and a layout with its own <head> script (analytics, say) pulls the
|
|
2068
|
+
// runtime -- and the registry with it -- into <head>. Collecting only
|
|
2069
|
+
// setups there dropped it, so every component that imports a local
|
|
2070
|
+
// module threw "is not registered on this page" and its template
|
|
2071
|
+
// hydrated against globals: an <input id="email"> bound to
|
|
2072
|
+
// :model="email" showed "[object HTMLInputElement]".
|
|
2055
2073
|
doc.querySelectorAll('head script').forEach(function(s){
|
|
2056
2074
|
var text=s.textContent||'';
|
|
2057
2075
|
if(s.hasAttribute('src'))return;
|
|
2058
2076
|
if(!text.trim())return;
|
|
2059
2077
|
if(isSignalsRuntimeScript(s,text))return;
|
|
2060
|
-
if(
|
|
2078
|
+
if(isModuleRegistryScript(s))addScript(text,true,'','');
|
|
2079
|
+
else if(text.indexOf('__stx_setup_')!==-1)addScript(text,true);
|
|
2061
2080
|
});
|
|
2062
2081
|
} else {
|
|
2063
2082
|
// Collect page scripts from <head> AND <body> (outside container).
|
|
@@ -2105,6 +2124,12 @@ else {
|
|
|
2105
2124
|
return aPage-bPage;
|
|
2106
2125
|
});
|
|
2107
2126
|
}
|
|
2127
|
+
// The module registry runs before anything that reads it (#1957). The
|
|
2128
|
+
// container's own scripts are collected first and head scripts after,
|
|
2129
|
+
// so without this a component in the page body could run ahead of the
|
|
2130
|
+
// registry it imports from. Stable: the order within each group holds.
|
|
2131
|
+
var registryFirst=scripts.filter(function(e){return e.registry});
|
|
2132
|
+
if(registryFirst.length)scripts=registryFirst.concat(scripts.filter(function(e){return !e.registry}));
|
|
2108
2133
|
|
|
2109
2134
|
// Push history state (before active link updates so location.pathname is current)
|
|
2110
2135
|
if(pushState!==false)writeHistory(pushState,url+(hash||''));
|
package/dist/serve.js
CHANGED
|
@@ -9724,7 +9724,7 @@ function __stxOverlay(errs){
|
|
|
9724
9724
|
pageMiddlewarePatterns.length = 0;
|
|
9725
9725
|
await Promise.all(files.map((f) => detectPageMiddleware(f)));
|
|
9726
9726
|
try {
|
|
9727
|
-
const { Router } = await import("./chunk-
|
|
9727
|
+
const { Router } = await import("./chunk-9gb1t22q.js");
|
|
9728
9728
|
const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
|
|
9729
9729
|
const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName() });
|
|
9730
9730
|
if (!options.quiet)
|
package/package.json
CHANGED