bun-plugin-stx 0.2.4 → 0.2.6
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-ymdk9x8z.js → chunk-j0k3wkwg.js} +8 -6
- package/dist/client.d.ts +2 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -1
- package/dist/preload.d.ts +1 -0
- package/dist/preload.js +1 -1
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +26 -6
- package/dist/watch.d.ts +1 -1
- package/package.json +2 -2
|
@@ -295,12 +295,13 @@ function stxPlugin(userOptions) {
|
|
|
295
295
|
console.error("Failed to build web components:", error);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
build.onLoad({ filter: /\.md$/ }, async (
|
|
298
|
+
build.onLoad({ filter: /\.md$/ }, async (args) => {
|
|
299
|
+
const filePath = args.path;
|
|
299
300
|
try {
|
|
300
301
|
const { content: htmlContent, data: frontmatter } = await readMarkdownFile(filePath, options);
|
|
301
302
|
const jsContent = `// ${filePath}
|
|
302
|
-
|
|
303
|
-
|
|
303
|
+
const content = ${JSON.stringify(htmlContent)};
|
|
304
|
+
const data = ${JSON.stringify(frontmatter)};
|
|
304
305
|
|
|
305
306
|
export { content, data };
|
|
306
307
|
export { content as default };
|
|
@@ -313,8 +314,8 @@ export { content as default };
|
|
|
313
314
|
console.error("Markdown Processing Error:", error);
|
|
314
315
|
const errorContent = generateErrorPage("Markdown Processing Error", error.message || "Unknown error", filePath);
|
|
315
316
|
const jsContent = `// ${filePath}
|
|
316
|
-
|
|
317
|
-
|
|
317
|
+
const content = ${JSON.stringify(errorContent)};
|
|
318
|
+
const data = {};
|
|
318
319
|
|
|
319
320
|
export { content, data };
|
|
320
321
|
export { content as default };
|
|
@@ -325,7 +326,8 @@ export { content as default };
|
|
|
325
326
|
};
|
|
326
327
|
}
|
|
327
328
|
});
|
|
328
|
-
build.onLoad({ filter: /\.(jsx|tsx)$/ }, async (
|
|
329
|
+
build.onLoad({ filter: /\.(jsx|tsx)$/ }, async (args) => {
|
|
330
|
+
const filePath = args.path;
|
|
329
331
|
try {
|
|
330
332
|
const source = await Bun.file(filePath).text();
|
|
331
333
|
const loader = filePath.endsWith(".tsx") ? "tsx" : "jsx";
|
package/dist/client.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export declare interface HydrationConfig {
|
|
|
26
26
|
/**
|
|
27
27
|
* Island handler registry
|
|
28
28
|
*/
|
|
29
|
-
export type IslandHandlers = Record<string, () => Promise<any
|
|
29
|
+
export type IslandHandlers = Record<string, () => Promise<any>>;
|
|
30
30
|
/**
|
|
31
31
|
* Island hydration function type
|
|
32
32
|
*/
|
|
33
|
-
export type HydrationFunction = (
|
|
33
|
+
export type HydrationFunction = (_element: HTMLElement, _props: any) => void | Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,9 @@ export type { CustomDirective, CustomDirectiveHandler, ServeOptions, ServeResult
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
export declare function stxPlugin(userOptions?: StxOptions): BunPlugin;
|
|
32
|
+
// Export watch functionality
|
|
32
33
|
export { createWatcher, startWatchMode, watchAndBuild } from './watch';
|
|
34
|
+
// Re-export functions and types that consumers might need
|
|
35
|
+
// Note: serve is exported from ./serve.ts, not here (to avoid duplicate export names when bundled)
|
|
33
36
|
export { createMiddleware, createRoute, readMarkdownFile } from '@stacksjs/stx';
|
|
34
|
-
export default stxPlugin;
|
|
37
|
+
export default stxPlugin;
|
package/dist/index.js
CHANGED
package/dist/preload.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/preload.js
CHANGED
package/dist/serve.d.ts
CHANGED
package/dist/serve.js
CHANGED
|
@@ -5063,7 +5063,9 @@ var defaultGeneratedDir3 = resolve7(process12.cwd(), "src/generated");
|
|
|
5063
5063
|
var defaultStxConfig = {
|
|
5064
5064
|
partialsDir: "partials",
|
|
5065
5065
|
componentsDir: "components",
|
|
5066
|
-
layoutsDir: "layouts"
|
|
5066
|
+
layoutsDir: "layouts",
|
|
5067
|
+
ssr: true,
|
|
5068
|
+
defaultTitle: "stx App"
|
|
5067
5069
|
};
|
|
5068
5070
|
async function serve(options) {
|
|
5069
5071
|
const stxConfig = await loadConfig5({
|
|
@@ -5198,7 +5200,7 @@ After installing: bun add bun-plugin-stx`);
|
|
|
5198
5200
|
__filename: filePath,
|
|
5199
5201
|
__dirname: path.dirname(filePath)
|
|
5200
5202
|
};
|
|
5201
|
-
const { processDirectives, extractVariables, defaultConfig: defaultConfig3 } = await import("@stacksjs/stx");
|
|
5203
|
+
const { processDirectives, extractVariables, defaultConfig: defaultConfig3, generateSpaShell } = await import("@stacksjs/stx");
|
|
5202
5204
|
await extractVariables(scriptContent, context, filePath);
|
|
5203
5205
|
const config3 = {
|
|
5204
5206
|
...defaultConfig3,
|
|
@@ -5206,10 +5208,28 @@ After installing: bun add bun-plugin-stx`);
|
|
|
5206
5208
|
...layoutsDir && { layoutsDir },
|
|
5207
5209
|
...partialsDir && { partialsDir }
|
|
5208
5210
|
};
|
|
5211
|
+
if (config3.ssr === false || stxConfig.ssr === false) {
|
|
5212
|
+
return generateSpaShell({
|
|
5213
|
+
template: templateContent,
|
|
5214
|
+
context,
|
|
5215
|
+
title: stxConfig.defaultTitle ?? "stx App"
|
|
5216
|
+
});
|
|
5217
|
+
}
|
|
5209
5218
|
let output = templateContent;
|
|
5210
5219
|
const dependencies = new Set;
|
|
5211
5220
|
output = await processDirectives(output, context, filePath, config3, dependencies);
|
|
5212
|
-
|
|
5221
|
+
const hasDirectiveTemplates = /<template\s[^>]*(?:@for|:for|@if|:if)/.test(output);
|
|
5222
|
+
if (hasDirectiveTemplates) {
|
|
5223
|
+
output = output.replace(/<template(?:\s[^>]*)?>|<\/template>/gi, (match) => {
|
|
5224
|
+
if (/@for|:for|@if|:if/.test(match))
|
|
5225
|
+
return match;
|
|
5226
|
+
if (match === "</template>")
|
|
5227
|
+
return match;
|
|
5228
|
+
return "";
|
|
5229
|
+
});
|
|
5230
|
+
} else {
|
|
5231
|
+
output = output.replace(/<template[^>]*>/gi, "").replace(/<\/template>/gi, "");
|
|
5232
|
+
}
|
|
5213
5233
|
const crosswindCSS = await generateCrosswindCSS(output);
|
|
5214
5234
|
if (crosswindCSS) {
|
|
5215
5235
|
const styleTag = `<style>/* crosswind css */
|
|
@@ -5267,7 +5287,7 @@ ${crosswindCSS}</style>`;
|
|
|
5267
5287
|
let relativeFilePath = normalizedFilePath;
|
|
5268
5288
|
for (const pattern of patterns) {
|
|
5269
5289
|
const normalizedPattern = pattern.replace(/\\/g, "/").replace(/\/$/, "");
|
|
5270
|
-
if (normalizedFilePath.startsWith(normalizedPattern
|
|
5290
|
+
if (normalizedFilePath.startsWith(`${normalizedPattern}/`)) {
|
|
5271
5291
|
relativeFilePath = normalizedFilePath.slice(normalizedPattern.length + 1);
|
|
5272
5292
|
break;
|
|
5273
5293
|
}
|
|
@@ -5296,7 +5316,7 @@ ${crosswindCSS}</style>`;
|
|
|
5296
5316
|
let relativeFilePath = normalizedFilePath;
|
|
5297
5317
|
for (const pattern of patterns) {
|
|
5298
5318
|
const normalizedPattern = pattern.replace(/\\/g, "/").replace(/\/$/, "");
|
|
5299
|
-
if (normalizedFilePath.startsWith(normalizedPattern
|
|
5319
|
+
if (normalizedFilePath.startsWith(`${normalizedPattern}/`)) {
|
|
5300
5320
|
relativeFilePath = normalizedFilePath.slice(normalizedPattern.length + 1);
|
|
5301
5321
|
break;
|
|
5302
5322
|
}
|
|
@@ -5581,7 +5601,7 @@ ${crosswindCSS}</style>`;
|
|
|
5581
5601
|
let normalizedPath = filePath.replace(/^\.\//, "").replace(/\\/g, "/");
|
|
5582
5602
|
for (const pattern of patterns) {
|
|
5583
5603
|
const normalizedPattern = pattern.replace(/\\/g, "/").replace(/\/$/, "");
|
|
5584
|
-
if (normalizedPath.startsWith(normalizedPattern
|
|
5604
|
+
if (normalizedPath.startsWith(`${normalizedPattern}/`)) {
|
|
5585
5605
|
normalizedPath = normalizedPath.slice(normalizedPattern.length + 1);
|
|
5586
5606
|
break;
|
|
5587
5607
|
}
|
package/dist/watch.d.ts
CHANGED
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.6",
|
|
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",
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
"typecheck": "bun tsc --noEmit"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@stacksjs/stx": "0.2.
|
|
70
|
+
"@stacksjs/stx": "0.2.6"
|
|
71
71
|
}
|
|
72
72
|
}
|