bun-plugin-stx 0.2.230 → 0.2.232
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-8ysn9mf6.js → chunk-anqecs1e.js} +12 -7
- package/dist/index.js +1 -1
- package/dist/preload.js +1 -1
- package/dist/serve.d.ts +12 -0
- package/dist/serve.js +3 -12
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/index.ts
|
|
3
3
|
import path2 from "path";
|
|
4
|
-
import { buildWebComponents, cacheTemplate, checkCache, classifyAllScripts, defaultConfig, extractVariables, processClientScript, processDirectives, readMarkdownFile } from "@stacksjs/stx";
|
|
4
|
+
import { buildWebComponents, cacheTemplate, checkCache, classifyAllScripts, defaultConfig, extractVariables, loadStxConfig, processClientScript, processDirectives, readMarkdownFile } from "@stacksjs/stx";
|
|
5
5
|
|
|
6
6
|
// src/watch.ts
|
|
7
7
|
import fs from "fs";
|
|
8
8
|
import path from "path";
|
|
9
|
-
import
|
|
9
|
+
import process2 from "process";
|
|
10
10
|
function debounce(fn, delay) {
|
|
11
11
|
let timeoutId = null;
|
|
12
12
|
return (...args) => {
|
|
@@ -37,7 +37,7 @@ function createWatcher(options = {}) {
|
|
|
37
37
|
const watchedPaths = new Set;
|
|
38
38
|
const watchers = new Map;
|
|
39
39
|
let isActive = true;
|
|
40
|
-
const paths = options.paths || [
|
|
40
|
+
const paths = options.paths || [process2.cwd()];
|
|
41
41
|
const debounceDelay = options.debounce ?? 100;
|
|
42
42
|
const pendingChanges = [];
|
|
43
43
|
const handleChanges = debounce(() => {
|
|
@@ -234,15 +234,15 @@ async function startWatchMode(args) {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
});
|
|
237
|
-
|
|
237
|
+
process2.once("SIGINT", () => {
|
|
238
238
|
console.log(`
|
|
239
239
|
\x1B[36m[stx]\x1B[0m Stopping watch mode...`);
|
|
240
240
|
watcher.close();
|
|
241
|
-
|
|
241
|
+
process2.exit(0);
|
|
242
242
|
});
|
|
243
|
-
|
|
243
|
+
process2.once("SIGTERM", () => {
|
|
244
244
|
watcher.close();
|
|
245
|
-
|
|
245
|
+
process2.exit(0);
|
|
246
246
|
});
|
|
247
247
|
return watcher;
|
|
248
248
|
}
|
|
@@ -277,8 +277,13 @@ function stxPlugin(userOptions) {
|
|
|
277
277
|
return {
|
|
278
278
|
name: "bun-plugin-stx",
|
|
279
279
|
async setup(build) {
|
|
280
|
+
let projectConfig = {};
|
|
281
|
+
try {
|
|
282
|
+
projectConfig = await loadStxConfig(process.cwd());
|
|
283
|
+
} catch {}
|
|
280
284
|
const options = {
|
|
281
285
|
...defaultConfig,
|
|
286
|
+
...projectConfig,
|
|
282
287
|
...userOptions
|
|
283
288
|
};
|
|
284
289
|
const allDependencies = new Set;
|
package/dist/index.js
CHANGED
package/dist/preload.js
CHANGED
package/dist/serve.d.ts
CHANGED
|
@@ -260,6 +260,18 @@ export declare interface MiddlewareContext {
|
|
|
260
260
|
cookies: Record<string, string>
|
|
261
261
|
redirect: (to: string, status?: number) => Response
|
|
262
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* The slice of Crosswind this server calls, taken from the package's own types
|
|
265
|
+
* rather than restated here.
|
|
266
|
+
*
|
|
267
|
+
* `CSSGenerator` has to be a constructor type, because it is `new`-ed below.
|
|
268
|
+
* Widening it to `unknown` satisfies the no-explicit-any rule and still fails to
|
|
269
|
+
* compile (`new (unknown)` is TS18046) — that is how d84349dd74 turned main red.
|
|
270
|
+
* Restating the shape by hand is the other trap: a stale hand-written copy is
|
|
271
|
+
* what made this hard to see in the first place (see the deleted
|
|
272
|
+
* `cwcss-crosswind.d.ts`). `typeof import` cannot drift from the real engine.
|
|
273
|
+
*/
|
|
274
|
+
declare type CrosswindEngine = Pick<typeof import('@cwcss/crosswind'), 'CSSGenerator' | 'config'>;
|
|
263
275
|
/**
|
|
264
276
|
* Middleware handler — a Laravel-style gate that either passes through
|
|
265
277
|
* (returns `void`/`null`/`undefined`) or terminates the pipeline by
|
package/dist/serve.js
CHANGED
|
@@ -10134,17 +10134,8 @@ ${block}`;
|
|
|
10134
10134
|
html = /<\/body>/i.test(html) ? html.replace(/<\/body>/i, `${pickerScript}
|
|
10135
10135
|
</body>`) : html + pickerScript;
|
|
10136
10136
|
}
|
|
10137
|
-
if (i18nConfig)
|
|
10138
|
-
|
|
10139
|
-
if (/<meta name="stx-layout-group"[^>]*>/i.test(html))
|
|
10140
|
-
html = html.replace(/<meta name="stx-layout-group"[^>]*>/i, groupMeta);
|
|
10141
|
-
else if (/<\/head>/i.test(html))
|
|
10142
|
-
html = html.replace(/<\/head>/i, `${groupMeta}
|
|
10143
|
-
</head>`);
|
|
10144
|
-
else
|
|
10145
|
-
html = `${groupMeta}
|
|
10146
|
-
${html}`;
|
|
10147
|
-
}
|
|
10137
|
+
if (i18nConfig && stx.stampLocaleLayoutGroup)
|
|
10138
|
+
html = stx.stampLocaleLayoutGroup(html, locale);
|
|
10148
10139
|
const knownPaths = discoveredPagePaths ?? new Set;
|
|
10149
10140
|
if (i18nConfig && locale !== i18nConfig.defaultLocale && knownPaths.size > 0) {
|
|
10150
10141
|
html = html.replace(/<a\b([^>]*?)\bhref="(\/[^"]*)"([^>]*)>/gi, (full, before, href, after) => {
|
|
@@ -10510,7 +10501,7 @@ ${html}`;
|
|
|
10510
10501
|
}
|
|
10511
10502
|
const content = await getRoute(path, reqCtx);
|
|
10512
10503
|
if (reqCtx.actionRedirect) {
|
|
10513
|
-
const redirectResponse = actionRedirectResponse(reqCtx.actionRedirect, reqCtx.actionCookies);
|
|
10504
|
+
const redirectResponse = actionRedirectResponse(reqCtx.actionRedirect, reqCtx.actionCookies, reqCtx.responseHeaders);
|
|
10514
10505
|
for (const [key, value] of Object.entries(corsHeaders))
|
|
10515
10506
|
redirectResponse.headers.set(key, value);
|
|
10516
10507
|
return redirectResponse;
|
package/package.json
CHANGED