weifuwu 0.18.11 → 0.18.12

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/index.js CHANGED
@@ -404,6 +404,7 @@ var Router = class _Router {
404
404
  ctx.mountPath = (ctx.mountPath || "") + base;
405
405
  return next(req, ctx);
406
406
  };
407
+ this.globalMws.push(...sub.globalMws);
407
408
  const routes = [];
408
409
  this._collect(sub.root, "", routes, []);
409
410
  for (const { method, path: path2, handler, middlewares } of routes) {
@@ -5527,15 +5528,9 @@ function tailwind(dir) {
5527
5528
  const cssPath = join3(cssDir, "app.css");
5528
5529
  let compiledCss = "";
5529
5530
  let twWatcher = null;
5530
- return async (req, ctx, next) => {
5531
- const url = new URL(req.url);
5531
+ const r = new Router();
5532
+ r.use(async (req, ctx, next) => {
5532
5533
  if (!compiledCss) compiledCss = await compile(cssPath, cssDir);
5533
- const stylePath = (ctx.mountPath || "") + "/__wfw/style.css";
5534
- if (url.pathname === stylePath) {
5535
- return new Response(compiledCss || "", {
5536
- headers: { "content-type": "text/css; charset=utf-8" }
5537
- });
5538
- }
5539
5534
  ctx.compiledTailwindCss = compiledCss;
5540
5535
  if (isDev2 && !twWatcher) {
5541
5536
  twWatcher = watchFile(cssPath, () => {
@@ -5544,7 +5539,14 @@ function tailwind(dir) {
5544
5539
  });
5545
5540
  }
5546
5541
  return next(req, ctx);
5547
- };
5542
+ });
5543
+ r.get("/__wfw/style.css", async (req, ctx) => {
5544
+ if (!compiledCss) compiledCss = await compile(cssPath, cssDir);
5545
+ return new Response(compiledCss || "", {
5546
+ headers: { "content-type": "text/css; charset=utf-8" }
5547
+ });
5548
+ });
5549
+ return r;
5548
5550
  }
5549
5551
  async function compile(cssPath, cssDir) {
5550
5552
  try {
@@ -1,3 +1,3 @@
1
- import type { Middleware } from './types.ts';
1
+ import { Router } from './router.ts';
2
2
  export declare function addTailwindSource(dir: string): void;
3
- export declare function tailwind(dir: string): Middleware;
3
+ export declare function tailwind(dir: string): Router;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weifuwu",
3
- "version": "0.18.11",
3
+ "version": "0.18.12",
4
4
  "description": "Web-standard HTTP framework for Node.js — (req, ctx) => Response",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",