bun-plugin-stx 0.2.118 → 0.2.120
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.
|
@@ -1000,8 +1000,13 @@ else {
|
|
|
1000
1000
|
var cleanFrag=html.replace(new RegExp('<scr'+'ipt\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/scr'+'ipt>','gi'),function(m,attrs,code){
|
|
1001
1001
|
if(code&&code.trim()&&!isSignalsRuntimeScript({hasAttribute:function(name){return name==='data-stx-runtime'&&attrs.indexOf('data-stx-runtime')!==-1}},code)){
|
|
1002
1002
|
var slot='fragment-'+(++fragScriptId);
|
|
1003
|
-
|
|
1004
|
-
|
|
1003
|
+
var scoped=/(?:^|\\s)data-stx-scoped(?:\\s|=|$)/i.test(attrs);
|
|
1004
|
+
fragScripts.push({text:code,slot:slot,setupName:generatedSetupName(code),scoped:scoped});
|
|
1005
|
+
// Retain scoped setup code in its inert placeholder. A placeholder
|
|
1006
|
+
// inside template.content is unreachable through document, so the
|
|
1007
|
+
// repeated component runtime must execute it for each clone.
|
|
1008
|
+
return '<scr'+'ipt type="application/stx-pending" data-stx-route-script="'+slot+'"'
|
|
1009
|
+
+(scoped?' data-stx-scoped':'')+'>'+code+'<\\/scr'+'ipt>';
|
|
1005
1010
|
}
|
|
1006
1011
|
return '';
|
|
1007
1012
|
});
|
|
@@ -1055,6 +1060,29 @@ else {
|
|
|
1055
1060
|
fragScripts.forEach(function(entry){
|
|
1056
1061
|
var code=entry.text;
|
|
1057
1062
|
log('[router] exec script len:', code.length, 'has __stx_setup:', code.indexOf('__stx_setup')>-1);
|
|
1063
|
+
var placeholder=document.querySelector('script[data-stx-route-script="'+entry.slot+'"]');
|
|
1064
|
+
var nestedScopedTemplate=false;
|
|
1065
|
+
var scopedLoopSetup=false;
|
|
1066
|
+
if(entry.scoped&&placeholder){
|
|
1067
|
+
document.querySelectorAll('template').forEach(function(template){
|
|
1068
|
+
if(template.contains(placeholder)||(template.content&&template.content.contains(placeholder)))
|
|
1069
|
+
nestedScopedTemplate=true;
|
|
1070
|
+
});
|
|
1071
|
+
var loopRoot=placeholder.previousSibling;
|
|
1072
|
+
while(loopRoot&&(
|
|
1073
|
+
(loopRoot.nodeType===Node.TEXT_NODE&&!(loopRoot.textContent||'').trim())
|
|
1074
|
+
||loopRoot.nodeType===Node.COMMENT_NODE
|
|
1075
|
+
))loopRoot=loopRoot.previousSibling;
|
|
1076
|
+
if(loopRoot&&loopRoot.nodeType===Node.ELEMENT_NODE&&loopRoot.hasAttribute('data-stx-scope')
|
|
1077
|
+
&&(loopRoot.hasAttribute(':for')||loopRoot.hasAttribute('@for')||loopRoot.hasAttribute('x-for'))){
|
|
1078
|
+
var loopScopeId=loopRoot.getAttribute('data-stx-scope');
|
|
1079
|
+
scopedLoopSetup=!!loopScopeId&&code.indexOf(loopScopeId)!==-1;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
if(entry.scoped&&(!placeholder||!placeholder.parentNode||nestedScopedTemplate||scopedLoopSetup)){
|
|
1083
|
+
log('[router] leaving loop-scoped script for component hydration');
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1058
1086
|
// Skip scripts that were already executed (layout-level partials
|
|
1059
1087
|
// like theme.stx, stores.stx, nav.stx). Their top-level const/let
|
|
1060
1088
|
// declarations would throw "Identifier has already been declared"
|
|
@@ -1085,7 +1113,6 @@ else {
|
|
|
1085
1113
|
}
|
|
1086
1114
|
ns.textContent=(hasImport||isAlreadyScoped)?code:'{'+code+'}';
|
|
1087
1115
|
ns.setAttribute('data-stx-page','');
|
|
1088
|
-
var placeholder=document.querySelector('script[data-stx-route-script="'+entry.slot+'"]');
|
|
1089
1116
|
if(placeholder&&placeholder.parentNode){
|
|
1090
1117
|
ns.setAttribute('data-stx-positioned','');
|
|
1091
1118
|
placeholder.parentNode.replaceChild(ns,placeholder);
|
package/dist/serve.js
CHANGED
|
@@ -9325,7 +9325,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9325
9325
|
pageMiddlewarePatterns.length = 0;
|
|
9326
9326
|
await Promise.all(files.map((f) => detectPageMiddleware(f)));
|
|
9327
9327
|
try {
|
|
9328
|
-
const { Router } = await import("./chunk-
|
|
9328
|
+
const { Router } = await import("./chunk-5hbpzwtx.js");
|
|
9329
9329
|
const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
|
|
9330
9330
|
const router = new Router(process19.cwd(), { pagesDirs, stateDir: stateDirName() });
|
|
9331
9331
|
if (!options.quiet)
|
|
@@ -9523,10 +9523,10 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9523
9523
|
const { serverScripts, templateContent } = extractServerScriptsFromTemplate(content);
|
|
9524
9524
|
const context = {
|
|
9525
9525
|
__filename: filePath,
|
|
9526
|
-
__dirname: nodePath.dirname(filePath)
|
|
9526
|
+
__dirname: nodePath.dirname(filePath),
|
|
9527
|
+
__stx_runtime_head: {}
|
|
9527
9528
|
};
|
|
9528
|
-
const { processDirectives, extractVariables, defaultConfig: defaultConfig4, generateSpaShell, injectRouterScript
|
|
9529
|
-
resetHead();
|
|
9529
|
+
const { processDirectives, extractVariables, defaultConfig: defaultConfig4, generateSpaShell, injectRouterScript } = await stxModule;
|
|
9530
9530
|
injectServeLocaleContext(context);
|
|
9531
9531
|
injectServeRequestContext(context, reqCtx);
|
|
9532
9532
|
context.params = reqCtx?.params ?? {};
|
|
@@ -9685,7 +9685,8 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9685
9685
|
const context = {
|
|
9686
9686
|
__filename: filePath,
|
|
9687
9687
|
__dirname: nodePath.dirname(filePath),
|
|
9688
|
-
__route: routePath
|
|
9688
|
+
__route: routePath,
|
|
9689
|
+
__stx_runtime_head: {}
|
|
9689
9690
|
};
|
|
9690
9691
|
const paramsObj = {};
|
|
9691
9692
|
for (let i = 0;i < paramNames.length; i++) {
|
|
@@ -9701,8 +9702,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9701
9702
|
context.params = paramsObj;
|
|
9702
9703
|
if (reqCtx)
|
|
9703
9704
|
reqCtx.params = paramsObj;
|
|
9704
|
-
const { processDirectives, extractVariables, defaultConfig: defaultConfig4, injectRouterScript: injectRouter
|
|
9705
|
-
resetHeadDyn();
|
|
9705
|
+
const { processDirectives, extractVariables, defaultConfig: defaultConfig4, injectRouterScript: injectRouter } = await stxModule;
|
|
9706
9706
|
injectServeLocaleContext(context);
|
|
9707
9707
|
injectServeRequestContext(context, reqCtx);
|
|
9708
9708
|
for (const scriptBody of dynServerScripts) {
|
package/package.json
CHANGED