wildpig 1.1.0 → 1.1.2
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/README.md +3 -3
- package/package.json +3 -3
- package/public/index.html +6 -1
- package/public/render.js +2 -16
- package/public/render.js.br +0 -0
- package/router/react-router.ts +1 -0
- package/scripts/WildPig.ts +18 -8
- package/scripts/prepareRoutes.ts +1 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wildpig",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"author": "eriktse",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"react": "^19.2.3",
|
|
12
12
|
"react-dom": "^19.2.3"
|
|
13
13
|
},
|
|
14
|
-
"description": "A strong and fast fullstack framework base Bun.",
|
|
14
|
+
"description": "A strong and fast fullstack framework base on Bun, react, react-router, typescript, tailwindcss.",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"fullstack",
|
|
17
17
|
"web",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"dev": "export NODE_ENV=development && bun run test.ts",
|
|
22
|
+
"dev": "export NODE_ENV=development && bun run --hot test.ts",
|
|
23
23
|
"prebuild": "bun run scripts/run-prebuild.ts",
|
|
24
24
|
"build": "export NODE_ENV=production && bun run prebuild && bun build --compile ./test.ts --outfile dist/wildpig",
|
|
25
25
|
"build-linux-musl": "export NODE_ENV=production && bun build --compile --target=bun-linux-x64-musl ./test.ts --outfile dist/wildpig",
|
package/public/index.html
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<
|
|
6
|
+
<meta name="wildpig-environment" content="production">
|
|
7
|
+
|
|
7
8
|
<title>{{TITLE}}</title>
|
|
9
|
+
<meta name="description" content="{{DESCRIPTION}}">
|
|
10
|
+
<meta name="keywords" content="{{KEYWORDS}}">
|
|
11
|
+
|
|
12
|
+
<script src="/render.js" type="module"></script>
|
|
8
13
|
</head>
|
|
9
14
|
<body>
|
|
10
15
|
<div id="root"></div>
|
package/public/render.js
CHANGED
|
@@ -22344,26 +22344,12 @@ function useViewTransitionState(to, { relative } = {}) {
|
|
|
22344
22344
|
|
|
22345
22345
|
// node_modules/react-router/dist/development/index.mjs
|
|
22346
22346
|
"use client";
|
|
22347
|
-
|
|
22348
22347
|
// src/page/layout.tsx
|
|
22349
22348
|
var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
|
|
22350
22349
|
var MainLayout = () => {
|
|
22351
22350
|
return /* @__PURE__ */ jsx_dev_runtime.jsxDEV("div", {
|
|
22352
|
-
children:
|
|
22353
|
-
|
|
22354
|
-
type: "text",
|
|
22355
|
-
placeholder: "Search"
|
|
22356
|
-
}, undefined, false, undefined, this),
|
|
22357
|
-
/* @__PURE__ */ jsx_dev_runtime.jsxDEV("button", {
|
|
22358
|
-
children: "Search"
|
|
22359
|
-
}, undefined, false, undefined, this),
|
|
22360
|
-
/* @__PURE__ */ jsx_dev_runtime.jsxDEV("div", {
|
|
22361
|
-
className: "text-red-500",
|
|
22362
|
-
children: "红红红"
|
|
22363
|
-
}, undefined, false, undefined, this),
|
|
22364
|
-
/* @__PURE__ */ jsx_dev_runtime.jsxDEV(Outlet, {}, undefined, false, undefined, this)
|
|
22365
|
-
]
|
|
22366
|
-
}, undefined, true, undefined, this);
|
|
22351
|
+
children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Outlet, {}, undefined, false, undefined, this)
|
|
22352
|
+
}, undefined, false, undefined, this);
|
|
22367
22353
|
};
|
|
22368
22354
|
|
|
22369
22355
|
// src/router/index.tsx
|
package/public/render.js.br
CHANGED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "react-router";
|
package/scripts/WildPig.ts
CHANGED
|
@@ -7,6 +7,8 @@ import devIndexHtml from "#/public/devIndex.html"
|
|
|
7
7
|
const env = process.env;
|
|
8
8
|
const isDev = env.NODE_ENV === "development";
|
|
9
9
|
|
|
10
|
+
console.log(metaRoutes);
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
export const startServer = () => {
|
|
12
14
|
Bun.serve({
|
|
@@ -27,17 +29,25 @@ export const startServer = () => {
|
|
|
27
29
|
"Cache-Control": isDev ? "no-cache" : "public, max-age=31536000, immutable"
|
|
28
30
|
}
|
|
29
31
|
}),
|
|
30
|
-
"/*":
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const pathname = "/_WILDPIG_META_API" + url.split("?")[0];
|
|
34
|
-
let
|
|
32
|
+
"/*":
|
|
33
|
+
isDev ? devIndexHtml :
|
|
34
|
+
async (request: Request) => {
|
|
35
|
+
const pathname = "/_WILDPIG_META_API/" + (request.url.split("/")[3].split("?")[0] || "");
|
|
36
|
+
let resHtml = htmlString;
|
|
35
37
|
|
|
36
38
|
if(pathname in metaRoutes){
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
try{
|
|
40
|
+
const metaResponse = await metaRoutes[pathname](request);
|
|
41
|
+
const meta = await metaResponse.json();
|
|
42
|
+
if(meta.title)resHtml = resHtml.replace("{{TITLE}}", meta.title);
|
|
43
|
+
if(meta.description)resHtml = resHtml.replace("{{DESCRIPTION}}", meta.description);
|
|
44
|
+
if(meta.keywords)resHtml = resHtml.replace("{{KEYWORDS}}", meta.keywords.join(", "));
|
|
45
|
+
}catch(e){
|
|
46
|
+
console.error("获取meta信息失败,请检查是否设置了meta信息", e);
|
|
47
|
+
}
|
|
39
48
|
}
|
|
40
|
-
|
|
49
|
+
|
|
50
|
+
return new Response(resHtml, {
|
|
41
51
|
headers: {
|
|
42
52
|
"content-type": "text/html; charset=utf-8",
|
|
43
53
|
"Access-Control-Allow-Origin": "*",
|
package/scripts/prepareRoutes.ts
CHANGED
|
@@ -6,7 +6,7 @@ const isDev = process.env.NODE_ENV === "development";
|
|
|
6
6
|
|
|
7
7
|
// 准备服务端路由表
|
|
8
8
|
let routes = {};
|
|
9
|
-
let metaRoutes: Record<string, () => Promise<Response>> = {};
|
|
9
|
+
let metaRoutes: Record<string, (req: Request) => Promise<Response>> = {};
|
|
10
10
|
if(isDev){
|
|
11
11
|
// 引入,用于监听
|
|
12
12
|
setTimeout(() => import("@/App").catch(() => {}), 1000);
|