bun-plugin-stx 0.2.54 → 0.2.57
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-nznv3e0m.js → chunk-ap5bhr00.js} +27 -6
- package/dist/serve.d.ts +5 -1
- package/dist/serve.js +17 -3
- package/package.json +3 -3
|
@@ -591,6 +591,19 @@ function getRouterScript() {
|
|
|
591
591
|
var containerSel=o.container;
|
|
592
592
|
var debug=!!o.debug;
|
|
593
593
|
function log(){if(debug&&typeof console!=='undefined'&&console.log)console.log.apply(console,arguments)}
|
|
594
|
+
function runViewTransition(callback){
|
|
595
|
+
if(!o.viewTransitions||!document.startViewTransition)return false;
|
|
596
|
+
try{
|
|
597
|
+
var transition=document.startViewTransition(callback);
|
|
598
|
+
var onAbort=function(err){log('[router] view transition aborted:',err&&err.message?err.message:err)};
|
|
599
|
+
if(transition&&transition.finished&&transition.finished.catch)transition.finished.catch(onAbort);
|
|
600
|
+
if(transition&&transition.updateCallbackDone&&transition.updateCallbackDone.catch)transition.updateCallbackDone.catch(onAbort);
|
|
601
|
+
return true;
|
|
602
|
+
}catch(err){
|
|
603
|
+
log('[router] view transition unavailable:',err&&err.message?err.message:err);
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
594
607
|
|
|
595
608
|
// \u2500\u2500 Progress bar (0\u2192100% at top of viewport) \u2500\u2500
|
|
596
609
|
// Native loading indicator baked into the router. Starts when navigation
|
|
@@ -906,12 +919,18 @@ else {
|
|
|
906
919
|
}
|
|
907
920
|
executedScriptHashes[h]=1;
|
|
908
921
|
var ns=document.createElement('script');
|
|
922
|
+
var hasImport=code.indexOf('import ')!==-1;
|
|
923
|
+
if(hasImport){
|
|
924
|
+
ns.type='module';
|
|
925
|
+
}
|
|
909
926
|
// Wrap in block scope to prevent const/let collisions on re-navigation.
|
|
910
927
|
// Without this, navigating away and back throws "Identifier has already
|
|
911
928
|
// been declared" because the previous page's top-level const/let are
|
|
912
|
-
// still in the global scope.
|
|
929
|
+
// still in the global scope. Skip the wrap for module scripts \u2014
|
|
930
|
+
// they get their own scope from ESM, and top-level 'import' is
|
|
931
|
+
// illegal inside a block, which would throw SyntaxError.
|
|
913
932
|
var isAlreadyScoped=code.trimStart().charAt(0)==='('||code.trimStart().charAt(0)===';'||code.indexOf('window.stx.mount')>-1;
|
|
914
|
-
ns.textContent=isAlreadyScoped?code:'{'+code+'}';
|
|
933
|
+
ns.textContent=(hasImport||isAlreadyScoped)?code:'{'+code+'}';
|
|
915
934
|
ns.setAttribute('data-stx-page','');
|
|
916
935
|
document.body.appendChild(ns);
|
|
917
936
|
});
|
|
@@ -919,7 +938,7 @@ else {
|
|
|
919
938
|
// THEN fire stx:load \u2014 now _latestSetup is set and processElement has the right scope
|
|
920
939
|
window.dispatchEvent(new Event('stx:load'));
|
|
921
940
|
}
|
|
922
|
-
if(
|
|
941
|
+
if(runViewTransition(doFragSwap)){}
|
|
923
942
|
else{currentContent.style.transition='opacity 0.12s ease-out';currentContent.style.opacity='0';setTimeout(function(){doFragSwap();currentContent.style.opacity='1';setTimeout(function(){currentContent.style.transition=''},150)},120)}
|
|
924
943
|
return;
|
|
925
944
|
}
|
|
@@ -1142,8 +1161,11 @@ else {
|
|
|
1142
1161
|
// Wrap in block scope to prevent const/let collisions on re-navigation.
|
|
1143
1162
|
// Top-level const/let in <script> tags are global-scoped in browsers
|
|
1144
1163
|
// and throw "Identifier has already been declared" on re-execution.
|
|
1164
|
+
// Skip the wrap for module scripts \u2014 they get their own scope from
|
|
1165
|
+
// ESM, and top-level 'import' is illegal inside a block, which
|
|
1166
|
+
// would throw SyntaxError before the script ever runs.
|
|
1145
1167
|
var alreadyScoped=text.trimStart().charAt(0)==='('||text.trimStart().charAt(0)===';'||text.indexOf('window.stx.mount')>-1;
|
|
1146
|
-
ns.textContent=alreadyScoped?text:'{'+text+'}';
|
|
1168
|
+
ns.textContent=(hasImport||alreadyScoped)?text:'{'+text+'}';
|
|
1147
1169
|
ns.setAttribute('data-stx-page','');
|
|
1148
1170
|
document.body.appendChild(ns);
|
|
1149
1171
|
});
|
|
@@ -1159,8 +1181,7 @@ else {
|
|
|
1159
1181
|
}
|
|
1160
1182
|
}
|
|
1161
1183
|
|
|
1162
|
-
if(
|
|
1163
|
-
document.startViewTransition(doSwap);
|
|
1184
|
+
if(runViewTransition(doSwap)){
|
|
1164
1185
|
}
|
|
1165
1186
|
else {
|
|
1166
1187
|
// Fallback fade for browsers without View Transitions API
|
package/dist/serve.d.ts
CHANGED
|
@@ -13,7 +13,11 @@ export declare interface ServeOptions {
|
|
|
13
13
|
quiet?: boolean
|
|
14
14
|
stxModule?: typeof import('@stacksjs/stx') | Promise<typeof import('@stacksjs/stx')>
|
|
15
15
|
routes?: Record<string, (req: Request) => Response | Promise<Response>>
|
|
16
|
-
onRequest?: (req: Request) =>
|
|
16
|
+
onRequest?: (req: Request) =>
|
|
17
|
+
| Response
|
|
18
|
+
| null
|
|
19
|
+
| undefined
|
|
20
|
+
| Promise<Response | null | undefined>
|
|
17
21
|
middleware?: Record<string, MiddlewareHandler>
|
|
18
22
|
globalMiddleware?: string[]
|
|
19
23
|
middlewareGroups?: Record<string, string[]>
|
package/dist/serve.js
CHANGED
|
@@ -8736,6 +8736,16 @@ async function serve(options) {
|
|
|
8736
8736
|
cwd: process19.cwd(),
|
|
8737
8737
|
defaultConfig: defaultStxConfig
|
|
8738
8738
|
});
|
|
8739
|
+
try {
|
|
8740
|
+
const stxMod = options.stxModule ? options.stxModule : await defaultStxModule;
|
|
8741
|
+
if (stxMod && typeof stxMod.loadStxConfig === "function") {
|
|
8742
|
+
const pluginLoaded = await stxMod.loadStxConfig();
|
|
8743
|
+
if (pluginLoaded?._pluginComponentDirs)
|
|
8744
|
+
stxConfig._pluginComponentDirs = pluginLoaded._pluginComponentDirs;
|
|
8745
|
+
if (pluginLoaded?._pluginPageDirs)
|
|
8746
|
+
stxConfig._pluginPageDirs = pluginLoaded._pluginPageDirs;
|
|
8747
|
+
}
|
|
8748
|
+
} catch {}
|
|
8739
8749
|
const componentsDir = options.componentsDir ?? stxConfig.componentsDir ?? defaultStxConfig.componentsDir;
|
|
8740
8750
|
const layoutsDir = options.layoutsDir ?? stxConfig.layoutsDir ?? defaultStxConfig.layoutsDir;
|
|
8741
8751
|
const partialsDir = options.partialsDir ?? stxConfig.partialsDir ?? defaultStxConfig.partialsDir;
|
|
@@ -8959,7 +8969,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
8959
8969
|
pageMiddlewarePatterns.length = 0;
|
|
8960
8970
|
await Promise.all(files.map((f) => detectPageMiddleware(f)));
|
|
8961
8971
|
try {
|
|
8962
|
-
const { Router } = await import("./chunk-
|
|
8972
|
+
const { Router } = await import("./chunk-ap5bhr00.js");
|
|
8963
8973
|
const pagesDirs = patterns.map((p) => p.replace(/\/$/, "")).filter(Boolean);
|
|
8964
8974
|
const router = new Router(process19.cwd(), { pagesDirs });
|
|
8965
8975
|
console.log(`[stx] Generated ${router.routes.length} routes \u2192 .stx/routes.ts`);
|
|
@@ -9162,7 +9172,9 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9162
9172
|
..."defaultTitle" in stxConfig && { defaultTitle: stxConfig.defaultTitle },
|
|
9163
9173
|
..."defaultDescription" in stxConfig && { defaultDescription: stxConfig.defaultDescription },
|
|
9164
9174
|
..."defaultImage" in stxConfig && { defaultImage: stxConfig.defaultImage },
|
|
9165
|
-
..."seo" in stxConfig && { seo: stxConfig.seo }
|
|
9175
|
+
..."seo" in stxConfig && { seo: stxConfig.seo },
|
|
9176
|
+
..."_pluginComponentDirs" in stxConfig && { _pluginComponentDirs: stxConfig._pluginComponentDirs },
|
|
9177
|
+
..."_pluginPageDirs" in stxConfig && { _pluginPageDirs: stxConfig._pluginPageDirs }
|
|
9166
9178
|
};
|
|
9167
9179
|
if (config5.ssr === false || stxConfig.ssr === false) {
|
|
9168
9180
|
return generateSpaShell({
|
|
@@ -9332,7 +9344,9 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9332
9344
|
..."defaultTitle" in stxConfig && { defaultTitle: stxConfig.defaultTitle },
|
|
9333
9345
|
..."defaultDescription" in stxConfig && { defaultDescription: stxConfig.defaultDescription },
|
|
9334
9346
|
..."defaultImage" in stxConfig && { defaultImage: stxConfig.defaultImage },
|
|
9335
|
-
..."seo" in stxConfig && { seo: stxConfig.seo }
|
|
9347
|
+
..."seo" in stxConfig && { seo: stxConfig.seo },
|
|
9348
|
+
..."_pluginComponentDirs" in stxConfig && { _pluginComponentDirs: stxConfig._pluginComponentDirs },
|
|
9349
|
+
..."_pluginPageDirs" in stxConfig && { _pluginPageDirs: stxConfig._pluginPageDirs }
|
|
9336
9350
|
};
|
|
9337
9351
|
let output = templateContent;
|
|
9338
9352
|
const dependencies = new Set;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-plugin-stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.57",
|
|
5
5
|
"description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"typecheck": "bun tsc --noEmit"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@stacksjs/stx": "0.2.
|
|
77
|
-
"stx-router": "0.2.
|
|
76
|
+
"@stacksjs/stx": "0.2.57",
|
|
77
|
+
"stx-router": "0.2.57"
|
|
78
78
|
}
|
|
79
79
|
}
|