bun-plugin-stx 0.2.553 → 0.2.554
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/serve.js +90 -71
- package/package.json +3 -3
package/dist/serve.js
CHANGED
|
@@ -9455,6 +9455,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
9455
9455
|
let discoveredPagePaths = null;
|
|
9456
9456
|
let assetsInitialized = false;
|
|
9457
9457
|
const htmlCache = boundedCache(options.renderCacheLimit ?? 512);
|
|
9458
|
+
const pendingShellRenders = new Map;
|
|
9458
9459
|
const ENABLE_HTML_CACHE = options.renderCache === true;
|
|
9459
9460
|
const RENDER_CACHE_VARY = options.renderCacheVary ?? "request";
|
|
9460
9461
|
const cssCssCache = boundedCache(options.cssCacheLimit ?? 512);
|
|
@@ -10353,82 +10354,100 @@ function __stxOverlay(errs){
|
|
|
10353
10354
|
return fillRouteParams(cachedEntry.html, paramsObj);
|
|
10354
10355
|
}
|
|
10355
10356
|
}
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
const { processDirectives, extractVariables, defaultConfig, injectRouterScript: injectRouter } = await stxModule;
|
|
10367
|
-
injectServeLocaleContext(context);
|
|
10368
|
-
injectServeRequestContext(context, reqCtx);
|
|
10369
|
-
context.__stx_options = stxConfig;
|
|
10370
|
-
for (const scriptBody of dynServerScripts) {
|
|
10371
|
-
await extractVariables(scriptBody, context, filePath);
|
|
10357
|
+
let releaseShell;
|
|
10358
|
+
if (cacheShell) {
|
|
10359
|
+
const pending = pendingShellRenders.get(filePath);
|
|
10360
|
+
if (pending) {
|
|
10361
|
+
await pending;
|
|
10362
|
+
return processTemplateDynamic(filePath, paramNames, paramValues, routePath, reqCtx);
|
|
10363
|
+
}
|
|
10364
|
+
pendingShellRenders.set(filePath, new Promise((resolve) => {
|
|
10365
|
+
releaseShell = resolve;
|
|
10366
|
+
}));
|
|
10372
10367
|
}
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
|
|
10400
|
-
|
|
10401
|
-
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10368
|
+
try {
|
|
10369
|
+
const context = {
|
|
10370
|
+
__filename: filePath,
|
|
10371
|
+
__dirname: nodePath.dirname(filePath),
|
|
10372
|
+
__route: routePath,
|
|
10373
|
+
__stx_runtime_head: {}
|
|
10374
|
+
};
|
|
10375
|
+
for (const name of paramNames) {
|
|
10376
|
+
context[name] = paramsObj[name];
|
|
10377
|
+
}
|
|
10378
|
+
context.params = paramsObj;
|
|
10379
|
+
const { processDirectives, extractVariables, defaultConfig, injectRouterScript: injectRouter } = await stxModule;
|
|
10380
|
+
injectServeLocaleContext(context);
|
|
10381
|
+
injectServeRequestContext(context, reqCtx);
|
|
10382
|
+
context.__stx_options = stxConfig;
|
|
10383
|
+
for (const scriptBody of dynServerScripts) {
|
|
10384
|
+
await extractVariables(scriptBody, context, filePath);
|
|
10385
|
+
}
|
|
10386
|
+
context.__stx_head_preset = true;
|
|
10387
|
+
const config = {
|
|
10388
|
+
...defaultConfig,
|
|
10389
|
+
root: process19.cwd(),
|
|
10390
|
+
...componentsDir && { componentsDir },
|
|
10391
|
+
...layoutsDir && { layoutsDir },
|
|
10392
|
+
...fallbackLayoutsDir && { fallbackLayoutsDir },
|
|
10393
|
+
...fallbackComponentsDir && { fallbackComponentsDir },
|
|
10394
|
+
...partialsDir && { partialsDir },
|
|
10395
|
+
autoShell: true,
|
|
10396
|
+
buildMode: "serve",
|
|
10397
|
+
ssr: stxConfig.ssr ?? defaultStxConfig.ssr ?? true,
|
|
10398
|
+
app: stxConfig.app || {},
|
|
10399
|
+
runtimeConfig: stxConfig.runtimeConfig,
|
|
10400
|
+
..."strict" in stxConfig && { strict: stxConfig.strict },
|
|
10401
|
+
..."router" in stxConfig && { router: stxConfig.router },
|
|
10402
|
+
..."debug" in stxConfig && { debug: stxConfig.debug },
|
|
10403
|
+
..."skipDefaultSeoTags" in stxConfig && { skipDefaultSeoTags: stxConfig.skipDefaultSeoTags },
|
|
10404
|
+
..."defaultTitle" in stxConfig && { defaultTitle: stxConfig.defaultTitle },
|
|
10405
|
+
..."defaultDescription" in stxConfig && { defaultDescription: stxConfig.defaultDescription },
|
|
10406
|
+
..."defaultImage" in stxConfig && { defaultImage: stxConfig.defaultImage },
|
|
10407
|
+
..."seo" in stxConfig && { seo: stxConfig.seo },
|
|
10408
|
+
..."analytics" in stxConfig && { analytics: stxConfig.analytics },
|
|
10409
|
+
..."offline" in stxConfig && { offline: stxConfig.offline },
|
|
10410
|
+
..."_pluginComponentDirs" in stxConfig && { _pluginComponentDirs: stxConfig._pluginComponentDirs },
|
|
10411
|
+
..."_pluginPageDirs" in stxConfig && { _pluginPageDirs: stxConfig._pluginPageDirs }
|
|
10412
|
+
};
|
|
10413
|
+
let output = templateContent;
|
|
10414
|
+
const dependencies = new Set;
|
|
10415
|
+
output = await processDirectives(output, context, filePath, config, dependencies);
|
|
10416
|
+
applyRecordedResponse(context, reqCtx);
|
|
10417
|
+
if (paramNames.length > 0) {
|
|
10418
|
+
const serializedParams = cacheShell ? ROUTE_PARAMS_PLACEHOLDER : serializeRouteParams(paramsObj);
|
|
10419
|
+
const paramsScript = `<script data-stx-route-params>(function(){var p=${serializedParams};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;
|
|
10420
|
+
if (output.includes("</head>")) {
|
|
10421
|
+
output = output.replace("</head>", `${paramsScript}
|
|
10409
10422
|
</head>`);
|
|
10410
|
-
|
|
10411
|
-
|
|
10423
|
+
} else {
|
|
10424
|
+
output = `${paramsScript}
|
|
10412
10425
|
${output}`;
|
|
10426
|
+
}
|
|
10427
|
+
}
|
|
10428
|
+
output = await injectRouter(output, getRouterInjectOptions());
|
|
10429
|
+
const directiveTemplateRe2 = REACTIVE_TEMPLATE_DIRECTIVE_RE;
|
|
10430
|
+
output = output.replace(/<template(?:\s[^>]*)?>|<\/template>/gi, (match) => {
|
|
10431
|
+
if (directiveTemplateRe2.test(match))
|
|
10432
|
+
return match;
|
|
10433
|
+
if (match === "</template>")
|
|
10434
|
+
return match;
|
|
10435
|
+
return "";
|
|
10436
|
+
});
|
|
10437
|
+
if (!cacheShell)
|
|
10438
|
+
return output;
|
|
10439
|
+
const recordedResponse = readResponseStatus(context) !== undefined || !!readResponseHeaders(context);
|
|
10440
|
+
if (!context.__stx_skip_cache && !recordedResponse && isRenderableCacheCandidate(output) && placeholdersAreReady) {
|
|
10441
|
+
const signature = await buildTemplateSignature(filePath, dependencies);
|
|
10442
|
+
htmlCache.remember(filePath, { html: output, signature, status: reqCtx?.responseStatus ?? 200, headers: reqCtx?.responseHeaders });
|
|
10443
|
+
}
|
|
10444
|
+
return fillRouteParams(output, paramsObj);
|
|
10445
|
+
} finally {
|
|
10446
|
+
if (releaseShell) {
|
|
10447
|
+
pendingShellRenders.delete(filePath);
|
|
10448
|
+
releaseShell();
|
|
10413
10449
|
}
|
|
10414
10450
|
}
|
|
10415
|
-
output = await injectRouter(output, getRouterInjectOptions());
|
|
10416
|
-
const directiveTemplateRe2 = REACTIVE_TEMPLATE_DIRECTIVE_RE;
|
|
10417
|
-
output = output.replace(/<template(?:\s[^>]*)?>|<\/template>/gi, (match) => {
|
|
10418
|
-
if (directiveTemplateRe2.test(match))
|
|
10419
|
-
return match;
|
|
10420
|
-
if (match === "</template>")
|
|
10421
|
-
return match;
|
|
10422
|
-
return "";
|
|
10423
|
-
});
|
|
10424
|
-
if (!cacheShell)
|
|
10425
|
-
return output;
|
|
10426
|
-
const recordedResponse = readResponseStatus(context) !== undefined || !!readResponseHeaders(context);
|
|
10427
|
-
if (!context.__stx_skip_cache && !recordedResponse && isRenderableCacheCandidate(output) && placeholdersAreReady) {
|
|
10428
|
-
const signature = await buildTemplateSignature(filePath, dependencies);
|
|
10429
|
-
htmlCache.remember(filePath, { html: output, signature, status: reqCtx?.responseStatus ?? 200, headers: reqCtx?.responseHeaders });
|
|
10430
|
-
}
|
|
10431
|
-
return fillRouteParams(output, paramsObj);
|
|
10432
10451
|
}
|
|
10433
10452
|
const startTime = performance.now();
|
|
10434
10453
|
await discoverFiles();
|
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.554",
|
|
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",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typecheck": "bun tsc --noEmit"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@stacksjs/stx": "0.2.
|
|
78
|
-
"stx-router": "0.2.
|
|
77
|
+
"@stacksjs/stx": "0.2.554",
|
|
78
|
+
"stx-router": "0.2.554"
|
|
79
79
|
}
|
|
80
80
|
}
|