weifuwu 0.18.10 → 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 +23 -24
- package/dist/tailwind.d.ts +2 -2
- package/package.json +1 -1
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) {
|
|
@@ -5478,17 +5479,6 @@ function ssr(path2) {
|
|
|
5478
5479
|
return r;
|
|
5479
5480
|
}
|
|
5480
5481
|
|
|
5481
|
-
// layout.ts
|
|
5482
|
-
function layout(path2) {
|
|
5483
|
-
return async (req, ctx, next) => {
|
|
5484
|
-
const mod = await compileTsx(path2);
|
|
5485
|
-
const Component = mod.default;
|
|
5486
|
-
if (!Component) throw new Error(`Layout ${path2} has no default export`);
|
|
5487
|
-
ctx.layoutStack = [...ctx.layoutStack || [], { path: path2, component: Component }];
|
|
5488
|
-
return next(req, ctx);
|
|
5489
|
-
};
|
|
5490
|
-
}
|
|
5491
|
-
|
|
5492
5482
|
// tailwind.ts
|
|
5493
5483
|
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "node:fs";
|
|
5494
5484
|
import { join as join3, relative, resolve as resolve5 } from "node:path";
|
|
@@ -5533,23 +5523,14 @@ function liveReload(opts) {
|
|
|
5533
5523
|
// tailwind.ts
|
|
5534
5524
|
var isDev2 = process.env.NODE_ENV !== "production";
|
|
5535
5525
|
var extraSources = /* @__PURE__ */ new Set();
|
|
5536
|
-
function addTailwindSource(dir) {
|
|
5537
|
-
extraSources.add(resolve5(dir));
|
|
5538
|
-
}
|
|
5539
5526
|
function tailwind(dir) {
|
|
5540
5527
|
const cssDir = resolve5(dir);
|
|
5541
5528
|
const cssPath = join3(cssDir, "app.css");
|
|
5542
5529
|
let compiledCss = "";
|
|
5543
5530
|
let twWatcher = null;
|
|
5544
|
-
|
|
5545
|
-
|
|
5531
|
+
const r = new Router();
|
|
5532
|
+
r.use(async (req, ctx, next) => {
|
|
5546
5533
|
if (!compiledCss) compiledCss = await compile(cssPath, cssDir);
|
|
5547
|
-
const stylePath = (ctx.mountPath || "") + "/__wfw/style.css";
|
|
5548
|
-
if (url.pathname === stylePath) {
|
|
5549
|
-
return new Response(compiledCss || "", {
|
|
5550
|
-
headers: { "content-type": "text/css; charset=utf-8" }
|
|
5551
|
-
});
|
|
5552
|
-
}
|
|
5553
5534
|
ctx.compiledTailwindCss = compiledCss;
|
|
5554
5535
|
if (isDev2 && !twWatcher) {
|
|
5555
5536
|
twWatcher = watchFile(cssPath, () => {
|
|
@@ -5558,7 +5539,14 @@ function tailwind(dir) {
|
|
|
5558
5539
|
});
|
|
5559
5540
|
}
|
|
5560
5541
|
return next(req, ctx);
|
|
5561
|
-
};
|
|
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;
|
|
5562
5550
|
}
|
|
5563
5551
|
async function compile(cssPath, cssDir) {
|
|
5564
5552
|
try {
|
|
@@ -5592,6 +5580,17 @@ function watchFile(path2, onChange) {
|
|
|
5592
5580
|
return watcher;
|
|
5593
5581
|
}
|
|
5594
5582
|
|
|
5583
|
+
// layout.ts
|
|
5584
|
+
function layout(path2) {
|
|
5585
|
+
return async (req, ctx, next) => {
|
|
5586
|
+
const mod = await compileTsx(path2);
|
|
5587
|
+
const Component = mod.default;
|
|
5588
|
+
if (!Component) throw new Error(`Layout ${path2} has no default export`);
|
|
5589
|
+
ctx.layoutStack = [...ctx.layoutStack || [], { path: path2, component: Component }];
|
|
5590
|
+
return next(req, ctx);
|
|
5591
|
+
};
|
|
5592
|
+
}
|
|
5593
|
+
|
|
5595
5594
|
// opencode/session.ts
|
|
5596
5595
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
5597
5596
|
import { join as join4 } from "node:path";
|
|
@@ -6227,7 +6226,7 @@ async function buildRouter4(deps) {
|
|
|
6227
6226
|
});
|
|
6228
6227
|
try {
|
|
6229
6228
|
const uiDir = new URL("../opencode/ui/", import.meta.url).pathname;
|
|
6230
|
-
|
|
6229
|
+
router.use(tailwind(uiDir));
|
|
6231
6230
|
router.use(layout(join5(uiDir, "layout.tsx")));
|
|
6232
6231
|
router.get("/", ssr(join5(uiDir, "page.tsx")));
|
|
6233
6232
|
} catch (e) {
|
package/dist/tailwind.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Router } from './router.ts';
|
|
2
2
|
export declare function addTailwindSource(dir: string): void;
|
|
3
|
-
export declare function tailwind(dir: string):
|
|
3
|
+
export declare function tailwind(dir: string): Router;
|