@zhin.js/pagemanager 0.0.0

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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/lib/node/consoleApiRouter.d.ts +5 -0
  3. package/lib/node/consoleApiRouter.d.ts.map +1 -0
  4. package/lib/node/consoleApiRouter.js +86 -0
  5. package/lib/node/consoleApiRouter.js.map +1 -0
  6. package/lib/node/consoleServerOptions.d.ts +49 -0
  7. package/lib/node/consoleServerOptions.d.ts.map +1 -0
  8. package/lib/node/consoleServerOptions.js +2 -0
  9. package/lib/node/consoleServerOptions.js.map +1 -0
  10. package/lib/node/entries-handler.d.ts +9 -0
  11. package/lib/node/entries-handler.d.ts.map +1 -0
  12. package/lib/node/entries-handler.js +12 -0
  13. package/lib/node/entries-handler.js.map +1 -0
  14. package/lib/node/entryStore.d.ts +7 -0
  15. package/lib/node/entryStore.d.ts.map +1 -0
  16. package/lib/node/entryStore.js +12 -0
  17. package/lib/node/entryStore.js.map +1 -0
  18. package/lib/node/env.d.ts +3 -0
  19. package/lib/node/env.d.ts.map +1 -0
  20. package/lib/node/env.js +4 -0
  21. package/lib/node/env.js.map +1 -0
  22. package/lib/node/esmForBrowser.d.ts +8 -0
  23. package/lib/node/esmForBrowser.d.ts.map +1 -0
  24. package/lib/node/esmForBrowser.js +163 -0
  25. package/lib/node/esmForBrowser.js.map +1 -0
  26. package/lib/node/index.d.ts +10 -0
  27. package/lib/node/index.d.ts.map +1 -0
  28. package/lib/node/index.js +7 -0
  29. package/lib/node/index.js.map +1 -0
  30. package/lib/node/pageManager.d.ts +19 -0
  31. package/lib/node/pageManager.d.ts.map +1 -0
  32. package/lib/node/pageManager.js +114 -0
  33. package/lib/node/pageManager.js.map +1 -0
  34. package/lib/node/pluginEntryBundle.d.ts +2 -0
  35. package/lib/node/pluginEntryBundle.d.ts.map +1 -0
  36. package/lib/node/pluginEntryBundle.js +42 -0
  37. package/lib/node/pluginEntryBundle.js.map +1 -0
  38. package/lib/node/resolveClientEntries.d.ts +9 -0
  39. package/lib/node/resolveClientEntries.d.ts.map +1 -0
  40. package/lib/node/resolveClientEntries.js +26 -0
  41. package/lib/node/resolveClientEntries.js.map +1 -0
  42. package/lib/node/startHost.d.ts +4 -0
  43. package/lib/node/startHost.d.ts.map +1 -0
  44. package/lib/node/startHost.js +79 -0
  45. package/lib/node/startHost.js.map +1 -0
  46. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 凉菜
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ import Router from "@koa/router";
2
+ import type { EntryStore } from "./entryStore.js";
3
+ import type { ConsoleServerOptions } from "./consoleServerOptions.js";
4
+ export declare function registerConsoleApiRoutes(router: Router, entryStore: EntryStore, options: ConsoleServerOptions): void;
5
+ //# sourceMappingURL=consoleApiRouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consoleApiRouter.d.ts","sourceRoot":"","sources":["../../src/node/consoleApiRouter.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAWjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAQtE,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,oBAAoB,GAC5B,IAAI,CA4EN"}
@@ -0,0 +1,86 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { DEFAULT_CONSOLE_BASE_PATH } from "@zhin.js/contract";
3
+ import { ALLOWED_ESM_CANONICAL, decodeSpecifierSegment, getOrBuildCanonicalEsmBundle, rewriteBareImportsForBrowser, } from "./esmForBrowser.js";
4
+ import { bundleEntryToTempFile } from "./pluginEntryBundle.js";
5
+ function effectivePublicOrigin(ctx) {
6
+ const proto = ctx.get("x-forwarded-proto") || ctx.protocol;
7
+ const host = ctx.get("x-forwarded-host") || ctx.host;
8
+ return `${proto}://${host}`;
9
+ }
10
+ export function registerConsoleApiRoutes(router, entryStore, options) {
11
+ const basePath = options.path ?? DEFAULT_CONSOLE_BASE_PATH;
12
+ const resolveDir = options.clientPackageRoot;
13
+ router.get("/esm/:enc.mjs", async (ctx) => {
14
+ let canonical;
15
+ try {
16
+ canonical = decodeSpecifierSegment(String(ctx.params.enc ?? ""));
17
+ }
18
+ catch {
19
+ ctx.status = 400;
20
+ ctx.body = { message: "Invalid esm enc" };
21
+ return;
22
+ }
23
+ if (!ALLOWED_ESM_CANONICAL.has(canonical)) {
24
+ ctx.status = 403;
25
+ ctx.body = { message: "ESM canonical not allowed" };
26
+ return;
27
+ }
28
+ try {
29
+ const code = await getOrBuildCanonicalEsmBundle(canonical, resolveDir, basePath);
30
+ ctx.set("content-type", "text/javascript; charset=utf-8");
31
+ ctx.set("cache-control", "public, max-age=3600");
32
+ ctx.body = code;
33
+ }
34
+ catch (err) {
35
+ ctx.status = 500;
36
+ ctx.body = { message: err instanceof Error ? err.message : "Failed to build ESM" };
37
+ }
38
+ });
39
+ const sendPluginBody = async (ctx, absSource, cacheKey) => {
40
+ const origin = effectivePublicOrigin(ctx);
41
+ const outfile = await bundleEntryToTempFile(cacheKey, absSource, resolveDir);
42
+ const raw = await readFile(outfile, "utf8");
43
+ const code = rewriteBareImportsForBrowser(raw, basePath, origin);
44
+ ctx.set("content-type", "text/javascript; charset=utf-8");
45
+ ctx.set("cache-control", "no-store");
46
+ ctx.body = code;
47
+ };
48
+ router.get("/@dev/:id.mjs", async (ctx) => {
49
+ const id = String(ctx.params.id ?? "");
50
+ const entry = entryStore.list().find((e) => e.id === id);
51
+ if (!entry?.paths) {
52
+ ctx.status = 404;
53
+ ctx.body = { message: "Unknown entry or not a filesystem entry" };
54
+ return;
55
+ }
56
+ try {
57
+ await sendPluginBody(ctx, entry.paths.development, `dev:${id}:${entry.paths.development}`);
58
+ }
59
+ catch (err) {
60
+ ctx.status = 500;
61
+ ctx.body = { message: err instanceof Error ? err.message : "Failed to serve dev plugin" };
62
+ }
63
+ });
64
+ router.get("/@assets/:id.mjs", async (ctx) => {
65
+ const id = String(ctx.params.id ?? "");
66
+ const entry = entryStore.list().find((e) => e.id === id);
67
+ if (!entry) {
68
+ ctx.status = 404;
69
+ ctx.body = { message: "Unknown entry" };
70
+ return;
71
+ }
72
+ try {
73
+ if (entry.paths) {
74
+ await sendPluginBody(ctx, entry.paths.production, `prod:${id}:${entry.paths.production}`);
75
+ return;
76
+ }
77
+ ctx.status = 500;
78
+ ctx.body = { message: "Entry has no paths configured" };
79
+ }
80
+ catch (err) {
81
+ ctx.status = 500;
82
+ ctx.body = { message: err instanceof Error ? err.message : "Failed to serve plugin asset" };
83
+ }
84
+ });
85
+ }
86
+ //# sourceMappingURL=consoleApiRouter.js.map
@@ -0,0 +1 @@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CAAC;QACzD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;YACjB,GAAG,CAAC,IAAI,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;YACxC,OAAO;QACT,CAAC;QACD,IAAI,CAAC;YACH,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChB,MAAM,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;gBAC1F,OAAO;YACT,CAAC;YACD,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;YACjB,GAAG,CAAC,IAAI,GAAG,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC;QAC1D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;YACjB,GAAG,CAAC,IAAI,GAAG,EAAE,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,8BAA8B,EAAE,CAAC;QAC9F,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type Router from "@koa/router";
2
+ import type Koa from "koa";
3
+ import type { RuntimeEnv } from "@zhin.js/contract";
4
+ import type { EntryStore } from "./entryStore.js";
5
+ export type PluginServerRegisterHostApi = {
6
+ router: Router;
7
+ entryStore: EntryStore;
8
+ basePath: string;
9
+ runtimeEnvHint?: RuntimeEnv;
10
+ };
11
+ export type PluginServerRegister = (api: PluginServerRegisterHostApi) => void | Promise<void>;
12
+ export type ConsoleServerRouteRegistrar = (ctx: PluginServerRegisterHostApi) => void | Promise<void>;
13
+ export type ConsoleServerOptions = {
14
+ path?: string;
15
+ router?: Router;
16
+ entryStore?: EntryStore;
17
+ runtimeEnvHint?: RuntimeEnv;
18
+ clientPackageRoot: string;
19
+ koa: Koa;
20
+ farmConfigPath?: string;
21
+ mode?: "development" | "production";
22
+ logger?: {
23
+ info: (...args: unknown[]) => void;
24
+ error: (...args: unknown[]) => void;
25
+ warn: (...args: unknown[]) => void;
26
+ };
27
+ serverRouteRegistrars?: ConsoleServerRouteRegistrar[];
28
+ port?: number;
29
+ farmServerPort?: number;
30
+ farmStrictPort?: boolean;
31
+ /** Mount Farm/static UI on Host Koa. Remote-only deployments should set false. */
32
+ serveClientHost?: boolean;
33
+ };
34
+ export type ConsoleClientHostAttachOptions = {
35
+ clientPackageRoot: string;
36
+ farmConfigPath?: string;
37
+ mode?: "development" | "production";
38
+ farmLogger?: unknown;
39
+ port?: number;
40
+ farmServerPort?: number;
41
+ farmStrictPort?: boolean;
42
+ consoleBasePath?: string;
43
+ };
44
+ export type ConsoleClientHostAttachment = {
45
+ bindDevWebSocket(server: import("node:http").Server): void;
46
+ prepareListen(): Promise<void>;
47
+ close(): Promise<void>;
48
+ };
49
+ //# sourceMappingURL=consoleServerOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consoleServerOptions.d.ts","sourceRoot":"","sources":["../../src/node/consoleServerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,UAAU,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,2BAA2B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AA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AC1B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,gBAAgB,CAAC,MAAM,EAAE,OAAO,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3D,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=consoleServerOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consoleServerOptions.js","sourceRoot":"","sources":["../../src/node/consoleServerOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { ConsoleClientEntry } from "@zhin.js/contract";
2
+ import type { EntryStore } from "./entryStore.js";
3
+ import { serverRuntimeEnv } from "./env.js";
4
+ export type EntriesResponseBody = {
5
+ entries: ConsoleClientEntry[];
6
+ runtimeEnvHint: ReturnType<typeof serverRuntimeEnv>;
7
+ };
8
+ export declare function buildEntriesResponse(entryStore: EntryStore, basePath: string, runtimeEnvHint?: ReturnType<typeof serverRuntimeEnv>): EntriesResponseBody;
9
+ //# sourceMappingURL=entries-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries-handler.d.ts","sourceRoot":"","sources":["../../src/node/entries-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,cAAc,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;CACrD,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GACnD,mBAAmB,CASrB"}
@@ -0,0 +1,12 @@
1
+ import { serverRuntimeEnv } from "./env.js";
2
+ import { rewriteEntriesForClient } from "./resolveClientEntries.js";
3
+ export function buildEntriesResponse(entryStore, basePath, runtimeEnvHint) {
4
+ const list = entryStore
5
+ .list()
6
+ .filter((e) => e.enabled !== false)
7
+ .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
8
+ const serverEnv = runtimeEnvHint ?? serverRuntimeEnv();
9
+ const entries = rewriteEntriesForClient({ entries: list, serverEnv, basePath });
10
+ return { entries, runtimeEnvHint: serverEnv };
11
+ }
12
+ //# sourceMappingURL=entries-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entries-handler.js","sourceRoot":"","sources":["../../src/node/entries-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAOpE,MAAM,UAAU,oBAAoB,CAClC,UAAsB,EACtB,QAAgB,EAChB,cAAoD;IAEpD,MAAM,IAAI,GAAG,UAAU;SACpB,IAAI,EAAE;SACN,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,CAAC;SAClC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;IAEnD,MAAM,SAAS,GAAG,cAAc,IAAI,gBAAgB,EAAE,CAAC;IACvD,MAAM,OAAO,GAAG,uBAAuB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChF,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ConsoleEntry } from "@zhin.js/contract";
2
+ export type EntryStore = {
3
+ add(entry: ConsoleEntry): void;
4
+ list(): ConsoleEntry[];
5
+ };
6
+ export declare function createInMemoryEntryStore(): EntryStore;
7
+ //# sourceMappingURL=entryStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entryStore.d.ts","sourceRoot":"","sources":["../../src/node/entryStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAC/B,IAAI,IAAI,YAAY,EAAE,CAAC;CACxB,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,UAAU,CAUrD"}
@@ -0,0 +1,12 @@
1
+ export function createInMemoryEntryStore() {
2
+ const entries = [];
3
+ return {
4
+ add(entry) {
5
+ entries.push(entry);
6
+ },
7
+ list() {
8
+ return [...entries];
9
+ },
10
+ };
11
+ }
12
+ //# sourceMappingURL=entryStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entryStore.js","sourceRoot":"","sources":["../../src/node/entryStore.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,wBAAwB;IACtC,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,OAAO;QACL,GAAG,CAAC,KAAK;YACP,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;QACD,IAAI;YACF,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { RuntimeEnv } from "@zhin.js/contract";
2
+ export declare function serverRuntimeEnv(): RuntimeEnv;
3
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/node/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wBAAgB,gBAAgB,IAAI,UAAU,CAE7C"}
@@ -0,0 +1,4 @@
1
+ export function serverRuntimeEnv() {
2
+ return process.env.NODE_ENV === "production" ? "production" : "development";
3
+ }
4
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/node/env.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB;IAC9B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const ALLOWED_ESM_CANONICAL: Set<string>;
2
+ /** `basePath` `/` must not become `//esm/...` (browser resolves to `http://esm/...`). */
3
+ export declare function joinConsolePublicPath(basePath: string, subpath: string): string;
4
+ export declare function encodeSpecifierSegment(specifier: string): string;
5
+ export declare function decodeSpecifierSegment(enc: string): string;
6
+ export declare function getOrBuildCanonicalEsmBundle(canonical: string, resolveDir: string, basePath: string): Promise<string>;
7
+ export declare function rewriteBareImportsForBrowser(code: string, basePath: string, _origin: string): string;
8
+ //# sourceMappingURL=esmForBrowser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esmForBrowser.d.ts","sourceRoot":"","sources":["../../src/node/esmForBrowser.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,qBAAqB,aAQhC,CAAC;AAsDH,yFAAyF;AACzF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAO/E;AAGD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1D;AA6CD,wBAAsB,4BAA4B,CAChD,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAuCjB;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,MAAM,CAWR"}
@@ -0,0 +1,163 @@
1
+ import { build } from "esbuild";
2
+ import * as path from "node:path";
3
+ import * as os from "node:os";
4
+ import { existsSync, mkdirSync, readFileSync } from "node:fs";
5
+ import { createHash } from "node:crypto";
6
+ import { createRequire } from "node:module";
7
+ import { CONSOLE_SHARED_MODULES_KEY } from "@zhin.js/contract";
8
+ export const ALLOWED_ESM_CANONICAL = new Set([
9
+ "react",
10
+ "react-dom",
11
+ "react-dom/client",
12
+ "react/jsx-runtime",
13
+ "react/jsx-dev-runtime",
14
+ "react-router",
15
+ "react-router-dom",
16
+ ]);
17
+ const HOST_PROXIED_MODULES = new Set([
18
+ "react",
19
+ "react-dom",
20
+ "react-dom/client",
21
+ "react/jsx-runtime",
22
+ "react/jsx-dev-runtime",
23
+ "react-router",
24
+ "react-router-dom",
25
+ ]);
26
+ /** discoverCjsExports 失败时的兜底(须与 Host Console 注册的 CJS 导出一致) */
27
+ const KNOWN_NAMED_EXPORTS = {
28
+ "react/jsx-runtime": ["Fragment", "jsx", "jsxs"],
29
+ "react/jsx-dev-runtime": ["Fragment", "jsx", "jsxs", "jsxDEV"],
30
+ react: [
31
+ "Children",
32
+ "Component",
33
+ "Fragment",
34
+ "Profiler",
35
+ "PureComponent",
36
+ "StrictMode",
37
+ "Suspense",
38
+ "cloneElement",
39
+ "createContext",
40
+ "createElement",
41
+ "createFactory",
42
+ "createRef",
43
+ "forwardRef",
44
+ "isValidElement",
45
+ "lazy",
46
+ "memo",
47
+ "startTransition",
48
+ "useCallback",
49
+ "useContext",
50
+ "useDebugValue",
51
+ "useDeferredValue",
52
+ "useEffect",
53
+ "useId",
54
+ "useImperativeHandle",
55
+ "useInsertionEffect",
56
+ "useLayoutEffect",
57
+ "useMemo",
58
+ "useReducer",
59
+ "useRef",
60
+ "useState",
61
+ "version",
62
+ ],
63
+ };
64
+ const esmCache = new Map();
65
+ const tmpDir = path.join(os.tmpdir(), "zhin-console-esm");
66
+ /** `basePath` `/` must not become `//esm/...` (browser resolves to `http://esm/...`). */
67
+ export function joinConsolePublicPath(basePath, subpath) {
68
+ const base = basePath === "/" || basePath === ""
69
+ ? ""
70
+ : basePath.replace(/\/$/, "").replace(/^\/+/, "");
71
+ const rest = subpath.replace(/^\/+/, "");
72
+ return base ? `/${base}/${rest}` : `/${rest}`;
73
+ }
74
+ const esmVersionTag = Date.now().toString(36);
75
+ export function encodeSpecifierSegment(specifier) {
76
+ return encodeURIComponent(specifier).replace(/%2F/g, "~");
77
+ }
78
+ export function decodeSpecifierSegment(enc) {
79
+ return decodeURIComponent(enc.replace(/~/g, "%2F"));
80
+ }
81
+ function discoverCjsExports(canonical, resolveDir) {
82
+ const req = createRequire(path.join(resolveDir, "_virtual.js"));
83
+ try {
84
+ const mod = req(canonical);
85
+ if (mod && typeof mod === "object") {
86
+ return Object.keys(mod).filter((k) => k !== "default" && k !== "__esModule" && /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(k));
87
+ }
88
+ }
89
+ catch { /* resolve failed */ }
90
+ return [];
91
+ }
92
+ function resolveNamedExports(canonical, resolveDir) {
93
+ const discovered = discoverCjsExports(canonical, resolveDir);
94
+ const known = KNOWN_NAMED_EXPORTS[canonical] ?? [];
95
+ return [...new Set([...discovered, ...known])];
96
+ }
97
+ function buildHostProxyModule(canonical, namedExports) {
98
+ const lines = [
99
+ `const _m = globalThis[${JSON.stringify(CONSOLE_SHARED_MODULES_KEY)}]?.get(${JSON.stringify(canonical)});`,
100
+ `if (!_m) throw new Error("[zhin-console] Host module not registered: ${canonical}");`,
101
+ `export default _m;`,
102
+ ...namedExports.map((n) => `export const ${n} = _m.${n};`),
103
+ ];
104
+ return lines.join("\n");
105
+ }
106
+ function buildEsbuildEntrySource(canonical, namedExports) {
107
+ if (namedExports.length === 0) {
108
+ return [
109
+ `export * from ${JSON.stringify(canonical)};`,
110
+ `export { default } from ${JSON.stringify(canonical)};`,
111
+ ].join("\n");
112
+ }
113
+ return [
114
+ `import _cjsMod from ${JSON.stringify(canonical)};`,
115
+ `export default _cjsMod;`,
116
+ ...namedExports.map((n) => `export const ${n} = _cjsMod.${n};`),
117
+ ].join("\n");
118
+ }
119
+ export async function getOrBuildCanonicalEsmBundle(canonical, resolveDir, basePath) {
120
+ const cached = esmCache.get(canonical);
121
+ if (cached)
122
+ return cached;
123
+ const namedExports = resolveNamedExports(canonical, resolveDir);
124
+ if (HOST_PROXIED_MODULES.has(canonical)) {
125
+ const code = buildHostProxyModule(canonical, namedExports);
126
+ esmCache.set(canonical, code);
127
+ return code;
128
+ }
129
+ if (!existsSync(tmpDir))
130
+ mkdirSync(tmpDir, { recursive: true });
131
+ const hash = createHash("sha256").update(canonical).digest("hex").slice(0, 12);
132
+ const outfile = path.join(tmpDir, `${hash}.mjs`);
133
+ const reactExternals = [...HOST_PROXIED_MODULES];
134
+ const entrySource = buildEsbuildEntrySource(canonical, namedExports);
135
+ await build({
136
+ stdin: {
137
+ contents: entrySource,
138
+ resolveDir,
139
+ loader: "js",
140
+ },
141
+ outfile,
142
+ bundle: true,
143
+ format: "esm",
144
+ platform: "browser",
145
+ target: "es2022",
146
+ logLevel: "warning",
147
+ external: reactExternals,
148
+ });
149
+ let code = readFileSync(outfile, "utf8");
150
+ code = rewriteBareImportsForBrowser(code, basePath, "");
151
+ esmCache.set(canonical, code);
152
+ return code;
153
+ }
154
+ export function rewriteBareImportsForBrowser(code, basePath, _origin) {
155
+ for (const canonical of ALLOWED_ESM_CANONICAL) {
156
+ const enc = encodeSpecifierSegment(canonical);
157
+ const esmUrl = `${joinConsolePublicPath(basePath, `esm/${enc}.mjs`)}?v=${esmVersionTag}`;
158
+ const pattern = new RegExp(`from\\s*["']${canonical.replace(/[.*+?^${}()|[\]\\\/]/g, "\\$&")}["']`, "g");
159
+ code = code.replace(pattern, `from "${esmUrl}"`);
160
+ }
161
+ return code;
162
+ }
163
+ //# sourceMappingURL=esmForBrowser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esmForBrowser.js","sourceRoot":"","sources":["../../src/node/esmForBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IAC3C,OAAO;IACP,WAAW;IACX,kBAAkB;IAClB,mBAAmB;IACnB,uBAAuB;IACvB,cAAc;IACd,kBAAkB;CACnB,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,OAAO;IACP,WAAW;IACX,kBAAkB;IAClB,mBAAmB;IACnB,uBAAuB;IACvB,cAAc;IACd,kBAAkB;CACnB,CAAC,CAAC;AAEH,8DAA8D;AAC9D,MAAM,mBAAmB,GAA6B;IACpD,mBAAmB,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC;IAChD,uBAAuB,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC;IAC9D,KAAK,EAAE;QACL,UAAU;QACV,WAAW;QACX,UAAU;QACV,UAAU;QACV,eAAe;QACf,YAAY;QACZ,UAAU;QACV,cAAc;QACd,eAAe;QACf,eAAe;Q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,GAAG,CACJ,CAAC;QACF,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,MAAM,GAAG,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,10 @@
1
+ export type { ConsoleServerOptions, ConsoleClientHostAttachOptions, ConsoleClientHostAttachment, PluginServerRegisterHostApi, PluginServerRegister, ConsoleServerRouteRegistrar, } from "./consoleServerOptions.js";
2
+ export { rewriteEntriesForClient } from "./resolveClientEntries.js";
3
+ export { buildEntriesResponse } from "./entries-handler.js";
4
+ export type { EntriesResponseBody } from "./entries-handler.js";
5
+ export { serverRuntimeEnv } from "./env.js";
6
+ export { attachConsoleClientHost } from "./startHost.js";
7
+ export type { EntryStore } from "./entryStore.js";
8
+ export { createInMemoryEntryStore } from "./entryStore.js";
9
+ export { PageManager, mountConsoleRouter } from "./pageManager.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { rewriteEntriesForClient } from "./resolveClientEntries.js";
2
+ export { buildEntriesResponse } from "./entries-handler.js";
3
+ export { serverRuntimeEnv } from "./env.js";
4
+ export { attachConsoleClientHost } from "./startHost.js";
5
+ export { createInMemoryEntryStore } from "./entryStore.js";
6
+ export { PageManager, mountConsoleRouter } from "./pageManager.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import Router from "@koa/router";
2
+ import type Koa from "koa";
3
+ import type { ConsoleFileAddEntryInput } from "@zhin.js/contract";
4
+ import { type EntryStore } from "./entryStore.js";
5
+ import type { ConsoleServerOptions, ConsoleClientHostAttachment } from "./consoleServerOptions.js";
6
+ export declare function mountConsoleRouter(router: Router): Koa.Middleware;
7
+ export declare class PageManager {
8
+ readonly router: Router;
9
+ readonly entryStore: EntryStore;
10
+ private readonly _apiRouter;
11
+ private readonly serverOptions;
12
+ constructor(options: ConsoleServerOptions);
13
+ private pluginServerRouteContext;
14
+ private registerEntryServerPlugins;
15
+ private runServerRouteRegistrars;
16
+ start(): Promise<ConsoleClientHostAttachment>;
17
+ addEntry(input: ConsoleFileAddEntryInput): void;
18
+ }
19
+ //# sourceMappingURL=pageManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageManager.d.ts","sourceRoot":"","sources":["../../src/node/pageManager.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAK3B,OAAO,KAAK,EAAgB,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAEhF,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EACV,oBAAoB,EAEpB,2BAA2B,EAC5B,MAAM,2BAA2B,CAAC;AAInC,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,UAAU,CAEjE;AAED,qBAAa,WAAW;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAuB;gBAEzC,OAAO,EAAE,oBAAoB;IAmBzC,OAAO,CAAC,wBAAwB;YAUlB,0BAA0B;YA0B1B,wBAAwB;IAOhC,KAAK,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAgCnD,QAAQ,CAAC,KAAK,EAAE,wBAAwB;CAqBzC"}
@@ -0,0 +1,114 @@
1
+ import Router from "@koa/router";
2
+ import compose from "koa-compose";
3
+ import { createHash } from "node:crypto";
4
+ import * as path from "node:path";
5
+ import { DEFAULT_CONSOLE_BASE_PATH } from "@zhin.js/contract";
6
+ import { createInMemoryEntryStore } from "./entryStore.js";
7
+ import { registerConsoleApiRoutes } from "./consoleApiRouter.js";
8
+ import { attachConsoleClientHost } from "./startHost.js";
9
+ export function mountConsoleRouter(router) {
10
+ return compose([router.routes(), router.allowedMethods()]);
11
+ }
12
+ export class PageManager {
13
+ router;
14
+ entryStore;
15
+ _apiRouter;
16
+ serverOptions;
17
+ constructor(options) {
18
+ this.serverOptions = options;
19
+ this.entryStore = options.entryStore ?? createInMemoryEntryStore();
20
+ const basePath = options.path ?? DEFAULT_CONSOLE_BASE_PATH;
21
+ const api = basePath === "/" || basePath === ""
22
+ ? new Router()
23
+ : new Router({ prefix: basePath });
24
+ this._apiRouter = api;
25
+ registerConsoleApiRoutes(api, this.entryStore, options);
26
+ if (options.router) {
27
+ options.router.use(api.routes());
28
+ options.router.use(api.allowedMethods());
29
+ this.router = options.router;
30
+ }
31
+ else {
32
+ this.router = api;
33
+ }
34
+ }
35
+ pluginServerRouteContext() {
36
+ const basePath = this.serverOptions.path ?? DEFAULT_CONSOLE_BASE_PATH;
37
+ return {
38
+ router: this._apiRouter,
39
+ entryStore: this.entryStore,
40
+ basePath,
41
+ runtimeEnvHint: this.serverOptions.runtimeEnvHint,
42
+ };
43
+ }
44
+ async registerEntryServerPlugins() {
45
+ const runtimeMode = this.serverOptions.mode ??
46
+ (process.env.NODE_ENV === "production" ? "production" : "development");
47
+ const mode = runtimeMode === "production" ? "production" : "development";
48
+ const { pathToFileURL } = await import("node:url");
49
+ for (const e of this.entryStore.list()) {
50
+ if (!e.serverPaths)
51
+ continue;
52
+ const abs = mode === "production" ? e.serverPaths.production : e.serverPaths.development;
53
+ const href = pathToFileURL(abs).href;
54
+ const mod = (await import(href));
55
+ const register = mod.register ?? mod.default?.register;
56
+ if (typeof register !== "function") {
57
+ throw new Error(`[zhin-console] Entry "${e.id}" server module must export register(api) (${abs})`);
58
+ }
59
+ await Promise.resolve(register(this.pluginServerRouteContext()));
60
+ }
61
+ }
62
+ async runServerRouteRegistrars() {
63
+ const ctx = this.pluginServerRouteContext();
64
+ for (const reg of this.serverOptions.serverRouteRegistrars ?? []) {
65
+ await Promise.resolve(reg(ctx));
66
+ }
67
+ }
68
+ async start() {
69
+ await this.registerEntryServerPlugins();
70
+ await this.runServerRouteRegistrars();
71
+ const clientPackageRoot = this.serverOptions.clientPackageRoot;
72
+ const consoleBasePath = this.serverOptions.path ?? DEFAULT_CONSOLE_BASE_PATH;
73
+ const mode = this.serverOptions.mode ??
74
+ (process.env.NODE_ENV === "production" ? "production" : "development");
75
+ const farmConfigPath = this.serverOptions.farmConfigPath ?? path.join(clientPackageRoot, "farm.config.ts");
76
+ const port = this.serverOptions.port ?? Number(process.env.PORT ?? 3001);
77
+ if (this.serverOptions.serveClientHost === false) {
78
+ return {
79
+ bindDevWebSocket() { },
80
+ prepareListen: async () => { },
81
+ close: async () => { },
82
+ };
83
+ }
84
+ return attachConsoleClientHost(this.serverOptions.koa, {
85
+ clientPackageRoot,
86
+ farmConfigPath,
87
+ mode,
88
+ port,
89
+ farmServerPort: this.serverOptions.farmServerPort,
90
+ farmStrictPort: this.serverOptions.farmStrictPort,
91
+ consoleBasePath,
92
+ });
93
+ }
94
+ addEntry(input) {
95
+ const id = input.id ??
96
+ `${path.basename(input.production, path.extname(input.production))}-${createHash("sha256").update(input.production).digest("hex").slice(0, 8)}`;
97
+ const entry = {
98
+ id,
99
+ paths: { development: input.development, production: input.production },
100
+ order: input.order,
101
+ enabled: input.enabled,
102
+ meta: input.meta,
103
+ requiredPermissions: input.requiredPermissions,
104
+ };
105
+ if (input.serverDevelopment != null && input.serverProduction != null) {
106
+ entry.serverPaths = {
107
+ development: input.serverDevelopment,
108
+ production: input.serverProduction,
109
+ };
110
+ }
111
+ this.entryStore.add(entry);
112
+ }
113
+ }
114
+ //# sourceMappingURL=pageManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageManager.js","sourceRoot":"","sources":["../../src/node/pageManager.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAmB,MAAM,iBAAiB,CAAC;AAM5E,OAAO,EAAE,wBA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 +1,2 @@
1
+ export declare function bundleEntryToTempFile(cacheKey: string, absSource: string, resolveDir: string): Promise<string>;
2
+ //# sourceMappingURL=pluginEntryBundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginEntryBundle.d.ts","sourceRoot":"","sources":["../../src/node/pluginEntryBundle.ts"],"names":[],"mappings":"AAkBA,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CA2BjB"}
@@ -0,0 +1,42 @@
1
+ import { build } from "esbuild";
2
+ import { existsSync, mkdirSync, statSync } from "node:fs";
3
+ import { createHash } from "node:crypto";
4
+ import * as path from "node:path";
5
+ import * as os from "node:os";
6
+ const bundleCache = new Map();
7
+ const tmpDir = path.join(os.tmpdir(), "zhin-console-plugin-bundles");
8
+ function cacheKeyWithMtime(cacheKey, absSource) {
9
+ try {
10
+ return `${cacheKey}:${statSync(absSource).mtimeMs}`;
11
+ }
12
+ catch {
13
+ return cacheKey;
14
+ }
15
+ }
16
+ export async function bundleEntryToTempFile(cacheKey, absSource, resolveDir) {
17
+ const keyed = cacheKeyWithMtime(cacheKey, absSource);
18
+ const cached = bundleCache.get(keyed);
19
+ if (cached && existsSync(cached))
20
+ return cached;
21
+ if (!existsSync(tmpDir))
22
+ mkdirSync(tmpDir, { recursive: true });
23
+ const hash = createHash("sha256").update(keyed).digest("hex").slice(0, 12);
24
+ const outfile = path.join(tmpDir, `${hash}.mjs`);
25
+ await build({
26
+ entryPoints: [absSource],
27
+ outfile,
28
+ bundle: true,
29
+ format: "esm",
30
+ platform: "browser",
31
+ target: "es2022",
32
+ sourcemap: false,
33
+ minify: false,
34
+ external: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime", "react-router", "react-router-dom"],
35
+ resolveExtensions: [".tsx", ".ts", ".jsx", ".js", ".mjs"],
36
+ absWorkingDir: resolveDir,
37
+ logLevel: "warning",
38
+ });
39
+ bundleCache.set(keyed, outfile);
40
+ return outfile;
41
+ }
42
+ //# sourceMappingURL=pluginEntryBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginEntryBundle.js","sourceRoot":"","sources":["../../src/node/pluginEntryBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE9C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,6BAA6B,CAAC,CAAC;AAErE,SAAS,iBAAiB,CAAC,QAAgB,EAAE,SAAiB;IAC5D,IAAI,CAAC;QACH,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;IACtD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,QAAgB,EAChB,SAAiB,EACjB,UAAkB;IAElB,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAEhD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhE,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC;IAEjD,MAAM,KAAK,CAAC;QACV,WAAW,EAAE,CAAC,SAAS,CAAC;QACxB,OAAO;QACP,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,SAAS;QACnB,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,cAAc,EAAE,kBAAkB,CAAC;QAClH,iBAAiB,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;QACzD,aAAa,EAAE,UAAU;QACzB,QAAQ,EAAE,SAAS;KACpB,CAAC,CAAC;IAEH,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ConsoleClientEntry, ConsoleEntry, EntryModuleSpec, RuntimeEnv } from "@zhin.js/contract";
2
+ export declare function chooseModule(spec: EntryModuleSpec, runtime: RuntimeEnv): string;
3
+ export declare function chooseFsPath(paths: NonNullable<ConsoleEntry["paths"]>, runtime: RuntimeEnv): string;
4
+ export declare function rewriteEntriesForClient(options: {
5
+ entries: ConsoleEntry[];
6
+ serverEnv: RuntimeEnv;
7
+ basePath: string;
8
+ }): ConsoleClientEntry[];
9
+ //# sourceMappingURL=resolveClientEntries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveClientEntries.d.ts","sourceRoot":"","sources":["../../src/node/resolveClientEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,UAAU,EACX,MAAM,mBAAmB,CAAC;AAG3B,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,CAI/E;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EACzC,OAAO,EAAE,UAAU,GAClB,MAAM,CAER;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC/C,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,kBAAkB,EAAE,CAgBvB"}
@@ -0,0 +1,26 @@
1
+ import { joinConsolePublicPath } from "./esmForBrowser.js";
2
+ export function chooseModule(spec, runtime) {
3
+ if (typeof spec === "string")
4
+ return spec;
5
+ if (runtime === "development")
6
+ return spec.dev;
7
+ return spec.prod ?? spec.dev;
8
+ }
9
+ export function chooseFsPath(paths, runtime) {
10
+ return runtime === "development" ? paths.development : paths.production;
11
+ }
12
+ export function rewriteEntriesForClient(options) {
13
+ const { entries, serverEnv, basePath } = options;
14
+ return entries.map((e) => {
15
+ const { serverPaths: _serverPaths, ...eForClient } = e;
16
+ if (e.paths) {
17
+ const resolvedModule = serverEnv === "development"
18
+ ? joinConsolePublicPath(basePath, `@dev/${e.id}.mjs`)
19
+ : joinConsolePublicPath(basePath, `@assets/${e.id}.mjs`);
20
+ return { ...eForClient, packageEntry: undefined, resolvedModule };
21
+ }
22
+ const chosen = chooseModule(e.module, serverEnv);
23
+ return { ...eForClient, resolvedModule: chosen };
24
+ });
25
+ }
26
+ //# sourceMappingURL=resolveClientEntries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveClientEntries.js","sourceRoot":"","sources":["../../src/node/resolveClientEntries.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AE,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type Koa from "koa";
2
+ import type { ConsoleClientHostAttachOptions, ConsoleClientHostAttachment } from "./consoleServerOptions.js";
3
+ export declare function attachConsoleClientHost(koaApp: Koa, options: ConsoleClientHostAttachOptions): Promise<ConsoleClientHostAttachment>;
4
+ //# sourceMappingURL=startHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startHost.d.ts","sourceRoot":"","sources":["../../src/node/startHost.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAI3B,OAAO,KAAK,EACV,8BAA8B,EAC9B,2BAA2B,EAC5B,MAAM,2BAA2B,CAAC;AAwCnC,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,2BAA2B,CAAC,CAoBtC"}
@@ -0,0 +1,79 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import * as path from "node:path";
3
+ import serve from "koa-static";
4
+ import { DEFAULT_CONSOLE_BASE_PATH } from "@zhin.js/contract";
5
+ function isConsoleApiPath(ctxPath, basePath) {
6
+ const base = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
7
+ if (!ctxPath.startsWith(`${base}/`) && ctxPath !== base)
8
+ return false;
9
+ const rest = ctxPath === base ? "/" : ctxPath.slice(base.length);
10
+ return (rest === "/entries" ||
11
+ rest.startsWith("/entries/") ||
12
+ rest === "/me" ||
13
+ rest.startsWith("/me/") ||
14
+ rest.startsWith("/@dev/") ||
15
+ rest.startsWith("/@assets/") ||
16
+ rest.startsWith("/esm/"));
17
+ }
18
+ function isConsoleSpaCandidate(ctxPath, consoleBasePath) {
19
+ const base = consoleBasePath.endsWith("/") ? consoleBasePath.slice(0, -1) : consoleBasePath;
20
+ if (ctxPath !== base && !ctxPath.startsWith(`${base}/`))
21
+ return false;
22
+ if (isConsoleApiPath(ctxPath, consoleBasePath))
23
+ return false;
24
+ const ext = path.extname(ctxPath);
25
+ return !ext || ext === ".html";
26
+ }
27
+ function createSpaFallbackMiddleware(getHtml, consoleBasePath) {
28
+ return async (ctx, next) => {
29
+ await next();
30
+ if (ctx.status !== 404)
31
+ return;
32
+ if (ctx.method !== "GET" && ctx.method !== "HEAD")
33
+ return;
34
+ if (!isConsoleSpaCandidate(ctx.path, consoleBasePath))
35
+ return;
36
+ ctx.type = "html";
37
+ ctx.status = 200;
38
+ ctx.body = getHtml();
39
+ };
40
+ }
41
+ export async function attachConsoleClientHost(koaApp, options) {
42
+ const { clientPackageRoot, mode = process.env.NODE_ENV === "production" ? "production" : "development", consoleBasePath = DEFAULT_CONSOLE_BASE_PATH, } = options;
43
+ if (mode === "production") {
44
+ await attachProductionClientHost(koaApp, clientPackageRoot, consoleBasePath);
45
+ return {
46
+ bindDevWebSocket() { },
47
+ prepareListen: async () => { },
48
+ close: async () => { },
49
+ };
50
+ }
51
+ return attachDevelopmentClientHost(koaApp, clientPackageRoot, {
52
+ ...options,
53
+ consoleBasePath,
54
+ });
55
+ }
56
+ async function attachProductionClientHost(koaApp, clientRoot, consoleBasePath) {
57
+ const browserDist = path.join(clientRoot, "dist");
58
+ const indexHtmlPath = path.join(browserDist, "index.html");
59
+ if (!existsSync(indexHtmlPath)) {
60
+ console.error(`[zhin-console] Missing static: ${indexHtmlPath}. Build Remote Console UI (zhin-console) or enable serveClientHost with a dist.`);
61
+ return;
62
+ }
63
+ let htmlCache = null;
64
+ const getHtml = () => (htmlCache ??= readFileSync(indexHtmlPath, "utf8"));
65
+ const spaMw = createSpaFallbackMiddleware(getHtml, consoleBasePath);
66
+ koaApp.middleware.unshift(spaMw);
67
+ koaApp.use(serve(browserDist, { index: false }));
68
+ }
69
+ async function attachDevelopmentClientHost(koaApp, clientRoot, devOptions) {
70
+ void koaApp;
71
+ void devOptions;
72
+ console.warn("[zhin-console] Embedded Farm dev UI was removed. Use Remote Console (zhin-console) or serveClientHost with a prebuilt dist.", { clientRoot });
73
+ return {
74
+ bindDevWebSocket() { },
75
+ prepareListen: async () => { },
76
+ close: async () => { },
77
+ };
78
+ }
79
+ //# sourceMappingURL=startHost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startHost.js","sourceRoot":"","sources":["../../src/node/startHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAM9D,SAAS,gBAAgB,CAAC,OAAe,EAAE,QAAgB;IACzD,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACvE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACtE,MAAM,IAAI,GAAG,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,OAAO,CACL,IAAI,KAAK,UAAU;QACnB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QAC5B,IAAI,KAAK,KAAK;QACd,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QAC5B,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CACzB,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,OAAe,EAAE,eAAuB;IACrE,MAAM,IA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CAAC;IACZ,KAAK,UAAU,CAAC;IAChB,OAAO,CAAC,IAAI,CACV,6HAA6H,EAC7H,EAAE,UAAU,EAAE,CACf,CAAC;IACF,OAAO;QACL,gBAAgB,KAAI,CAAC;QACrB,aAAa,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;QAC7B,KAAK,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;KACtB,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@zhin.js/pagemanager",
3
+ "version": "0.0.0",
4
+ "description": "Zhin PageManager Host runtime: entries, esbuild pipeline (no UI; contract in @zhin.js/contract)",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./lib/node/index.d.ts",
9
+ "import": "./lib/node/index.js",
10
+ "default": "./lib/node/index.js"
11
+ },
12
+ "./node": {
13
+ "types": "./lib/node/index.d.ts",
14
+ "import": "./lib/node/index.js",
15
+ "default": "./lib/node/index.js"
16
+ }
17
+ },
18
+ "dependencies": {
19
+ "@koa/router": "^15.6.0",
20
+ "esbuild": "^0.28.0",
21
+ "koa": "^3.2.1",
22
+ "koa-compose": "^4.1.0",
23
+ "koa-static": "^5.0.0",
24
+ "@zhin.js/contract": "1.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/koa": "^3.0.3",
28
+ "@types/koa-compose": "^3.2.9",
29
+ "@types/koa-static": "^4.0.4",
30
+ "@types/koa__router": "^12.0.4",
31
+ "@types/node": "^25.9.1",
32
+ "rimraf": "^6.0.1",
33
+ "typescript": "^6.0.2"
34
+ },
35
+ "files": [
36
+ "lib"
37
+ ],
38
+ "license": "MIT",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/zhinjs/zhin.git",
42
+ "directory": "packages/console/pagemanager"
43
+ },
44
+ "scripts": {
45
+ "build": "tsc -p tsconfig.json",
46
+ "build:node": "tsc -p tsconfig.json",
47
+ "typecheck": "tsc -p tsconfig.json --noEmit",
48
+ "clean": "rimraf dist lib"
49
+ }
50
+ }