@geekron/hono 0.0.6 → 0.0.8
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/contract.d.ts +1 -1
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +10 -1
- package/dist/route/setup.d.ts +13 -2
- package/dist/route/setup.d.ts.map +1 -1
- package/dist/route/setup.js +14 -2
- package/dist/route/slot.d.ts +1 -1
- package/dist/route/slot.js +1 -1
- package/dist/strapi/cms/site.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/contract.d.ts
CHANGED
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,OAAO,QAAsB,CAAA;AAE1C,eAAO,MAAM,SAAS,QAAmC,CAAA;AASzD,eAAO,MAAM,SAAS,QAAwB,CAAA;AAC9C,eAAO,MAAM,UAAU,QAAoC,CAAA"}
|
package/dist/contract.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
// 检查 CMS_URL 是否存在
|
|
2
|
+
if (!process.env.CMS_URL) {
|
|
3
|
+
throw new Error('CMS_URL is required but not provided in environment variables');
|
|
4
|
+
}
|
|
5
|
+
export const CMS_URL = process.env.CMS_URL;
|
|
6
|
+
// MEDIA_URL 可选,如果未提供则使用 CMS_URL
|
|
2
7
|
export const MEDIA_URL = process.env.MEDIA_URL || CMS_URL;
|
|
8
|
+
// 检查 CMS_TOKEN 是否存在
|
|
9
|
+
if (!process.env.CMS_TOKEN) {
|
|
10
|
+
throw new Error('CMS_TOKEN is required but not provided in environment variables');
|
|
11
|
+
}
|
|
3
12
|
export const CMS_TOKEN = process.env.CMS_TOKEN;
|
|
4
13
|
export const URL_SUFFIX = process.env.URL_SUFFIX || '.html';
|
package/dist/route/setup.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { Hono } from 'hono';
|
|
2
2
|
import type { Child } from 'hono/jsx';
|
|
3
3
|
import type { RouteItem, RouteItemHandler } from '../route/interfaces';
|
|
4
|
+
declare const providers: {
|
|
5
|
+
strapi: {
|
|
6
|
+
routeItemHandler: RouteItemHandler;
|
|
7
|
+
checkCmsStatus: () => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
4
10
|
export type AppInstance = Hono<{
|
|
5
11
|
Variables: Variables;
|
|
6
12
|
}>;
|
|
@@ -9,10 +15,15 @@ export interface Variables {
|
|
|
9
15
|
slots: Map<string, Child[]>;
|
|
10
16
|
route: RouteItem;
|
|
11
17
|
}
|
|
12
|
-
export interface
|
|
18
|
+
export interface SetupRoutesSetup {
|
|
13
19
|
app: AppInstance;
|
|
20
|
+
cms: keyof typeof providers;
|
|
14
21
|
routeItemHandler: RouteItemHandler;
|
|
15
22
|
}
|
|
16
|
-
export
|
|
23
|
+
export interface SetupRoutesOption extends Partial<SetupRoutesSetup> {
|
|
24
|
+
app: AppInstance;
|
|
25
|
+
}
|
|
26
|
+
export declare const setup: SetupRoutesSetup;
|
|
17
27
|
export declare const setupRoutes: (paths: string | string[], option: SetupRoutesOption) => Promise<void>;
|
|
28
|
+
export {};
|
|
18
29
|
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/route/setup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/route/setup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAKrE,QAAA,MAAM,SAAS;;;;;CAKd,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC,CAAA;AAExD,MAAM,WAAW,SAAS;IACzB,GAAG,EAAE,WAAW,CAAA;IAChB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IAC3B,KAAK,EAAE,SAAS,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAChC,GAAG,EAAE,WAAW,CAAA;IAChB,GAAG,EAAE,MAAM,OAAO,SAAS,CAAA;IAC3B,gBAAgB,EAAE,gBAAgB,CAAA;CAClC;AAED,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAAC,gBAAgB,CAAC;IACnE,GAAG,EAAE,WAAW,CAAA;CAChB;AAED,eAAO,MAAM,KAAK,EAAS,gBAAgB,CAAA;AAC3C,eAAO,MAAM,WAAW,GACvB,OAAO,MAAM,GAAG,MAAM,EAAE,EACxB,QAAQ,iBAAiB,kBAYzB,CAAA"}
|
package/dist/route/setup.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
|
+
import { checkCmsStatus as strapiCheckCmsStatus } from '../strapi/cms';
|
|
3
|
+
// 导入默认的 routeItemHandler
|
|
4
|
+
import { routeItemHandler as strapiRouteItemHandler } from '../strapi/route';
|
|
5
|
+
const providers = {
|
|
6
|
+
strapi: {
|
|
7
|
+
routeItemHandler: strapiRouteItemHandler,
|
|
8
|
+
checkCmsStatus: strapiCheckCmsStatus,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
2
11
|
export const setup = {};
|
|
3
12
|
export const setupRoutes = async (paths, option) => {
|
|
4
|
-
const { app } = option;
|
|
13
|
+
const { app, routeItemHandler, cms = 'strapi' } = option;
|
|
14
|
+
const provider = providers[cms];
|
|
15
|
+
setup.routeItemHandler = routeItemHandler || provider.routeItemHandler;
|
|
5
16
|
setup.app = app;
|
|
6
|
-
setup.
|
|
17
|
+
setup.cms = cms;
|
|
18
|
+
await provider.checkCmsStatus();
|
|
7
19
|
const files = fs.globSync(paths);
|
|
8
20
|
files.forEach((file) => {
|
|
9
21
|
require(file);
|
package/dist/route/slot.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const useSlot: <SlotName extends string>(ctx: Context<{
|
|
|
8
8
|
parse: (render: (ctx: Context<{
|
|
9
9
|
Variables: Variables;
|
|
10
10
|
}>) => Promise<Child> | Child) => Promise<{
|
|
11
|
-
content: string
|
|
11
|
+
content: string;
|
|
12
12
|
slots: Map<SlotName, Child[]>;
|
|
13
13
|
}>;
|
|
14
14
|
};
|
package/dist/route/slot.js
CHANGED
|
@@ -19,7 +19,7 @@ export const useSlot = (ctx) => {
|
|
|
19
19
|
const preContent = await render(ctx);
|
|
20
20
|
// 使用 toString() 方法强制渲染(支持异步组件)
|
|
21
21
|
// 这会触发所有子组件执行,slot.append 生效
|
|
22
|
-
const content = await preContent?.toString();
|
|
22
|
+
const content = (await preContent?.toString()) || '';
|
|
23
23
|
// 【第二阶段】获取已收集的 slots
|
|
24
24
|
const slots = (ctx.get('slots') || new Map());
|
|
25
25
|
return { content, slots };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../../../src/strapi/cms/site.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAGtE,eAAO,MAAM,OAAO,GAAI,MAAM,IAAI,SAEjC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,CAAC,GAAG,IAAI,OAKhB,CACf,CAAA;AAED,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../../../src/strapi/cms/site.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAGtE,eAAO,MAAM,OAAO,GAAI,MAAM,IAAI,SAEjC,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,CAAC,GAAG,IAAI,OAKhB,CACf,CAAA;AAED,eAAO,MAAM,SAAS,GACrB,WAAU,YAAkB,EAC5B,iBAAe,kBAGf,CAAA;AAED,eAAO,MAAM,QAAQ,GACpB,WAAU,YAAkB,EAC5B,iBAAc,kBAcd,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekron/hono",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"format": "bunx biome format --write",
|
|
7
7
|
"lint": "bunx biome lint --write",
|
|
8
8
|
"check": "bunx biome check --write",
|
|
9
|
-
"build": "
|
|
10
|
-
"prepublishOnly": "
|
|
9
|
+
"build": "./shell/build.sh",
|
|
10
|
+
"prepublishOnly": "./shell/build.sh"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
"./strapi": {
|
|
@@ -39,4 +39,4 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|