@_tc/template-core 0.4.0 → 0.4.1
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/.skills/tc-component-usage-skills/reference/component-api.md +27 -0
- package/.skills/tc-generator/SKILL.md +1 -1
- package/.skills/tc-generator/reference/project-template/ssr/apps/hello/hello.entry.tsx +6 -1
- package/.skills/tc-generator/reference/runtime-extensions.md +10 -0
- package/AGENT_README.md +8 -2
- package/CHANGE.md +27 -0
- package/README.md +157 -8
- package/cjs/app/ai/agent/agent-scanner.service.js +1 -1
- package/cjs/app/ai/agent/agent.module.js +1 -1
- package/cjs/app/ai/ai-config.module.js +1 -1
- package/cjs/app/ai/ai-config.service.js +1 -1
- package/cjs/app/ai/ai.controller.js +1 -1
- package/cjs/app/ai/ai.module.js +1 -1
- package/cjs/app/ai/guardrail/guardrail.module.js +1 -1
- package/cjs/app/ai/guardrail/guardrail.service.js +1 -1
- package/cjs/app/ai/index.js +1 -0
- package/cjs/app/ai/mcp/internal/read-sse-response.js +2 -0
- package/cjs/app/ai/mcp/internal/stdio-process.js +1 -0
- package/cjs/app/ai/mcp/mcp-registry.service.js +2 -2
- package/cjs/app/ai/mcp/mcp.client.js +2 -3
- package/cjs/app/ai/mcp/mcp.loader.js +1 -1
- package/cjs/app/ai/mcp/mcp.module.js +1 -1
- package/cjs/app/ai/memory/checkpoint.service.js +1 -1
- package/cjs/app/ai/memory/memory.module.js +1 -1
- package/cjs/app/ai/memory/thread.service.js +1 -1
- package/cjs/app/ai/models/chat-sse.js +4 -0
- package/cjs/app/ai/models/chat.js +1 -0
- package/cjs/app/ai/models/http.js +1 -0
- package/cjs/app/ai/models/image.js +1 -0
- package/cjs/app/ai/models/video.js +1 -0
- package/cjs/app/ai/nest-service-provider.js +1 -0
- package/cjs/app/ai/rag/rag.module.js +1 -1
- package/cjs/app/ai/rag/retriever.service.js +1 -1
- package/cjs/app/ai/retention/conversation-retention.service.js +1 -1
- package/cjs/app/ai/runtime/ai-runtime-startup.validator.js +1 -1
- package/cjs/app/ai/runtime/ai-runtime.js +1 -0
- package/cjs/app/ai/runtime/internal/context-compaction.service.js +3 -3
- package/cjs/app/ai/runtime/internal/declaration-snapshot.js +1 -0
- package/cjs/app/ai/runtime/internal/owned-runtime-resources.js +1 -0
- package/cjs/app/ai/runtime/langchain/langchain-planner.service.js +1 -1
- package/cjs/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +1 -1
- package/cjs/app/ai/runtime/runtime.module.js +1 -1
- package/cjs/app/ai/skill/skill-scanner.service.js +1 -1
- package/cjs/app/ai/skill/skill.module.js +1 -1
- package/cjs/app/ai/snapshot-data.js +1 -0
- package/cjs/app/ai/store/internal/create-vector-store.js +1 -0
- package/cjs/app/ai/store/store.module.js +1 -1
- package/cjs/app/ai/tool/builtin/index.js +1 -1
- package/cjs/app/ai/tool/builtin/invoke-agent.tool.js +1 -1
- package/cjs/app/ai/tool/builtin/retrieve.tool.js +1 -1
- package/cjs/app/ai/tool/executor.service.js +1 -1
- package/cjs/app/ai/tool/tool-registry.service.js +1 -1
- package/cjs/app/ai/tool/tool.module.js +1 -1
- package/cjs/app/ai/trace/trace.service.js +1 -1
- package/cjs/app/csr/controller.js +1 -1
- package/cjs/app/csr/types.js +0 -0
- package/cjs/app/html/browser-options.js +1 -1
- package/cjs/app/html/shell.js +31 -16
- package/cjs/app/http/api-signing.js +1 -0
- package/cjs/app/http/body-parser.middleware.js +1 -1
- package/cjs/app/http/csp-nonce.js +1 -0
- package/cjs/app/http/error-response.js +1 -1
- package/cjs/app/http/exception-filter.js +1 -1
- package/cjs/app/http/request-body-parser-policy.js +1 -0
- package/cjs/app/http/security.guard.js +1 -1
- package/cjs/app/project/controller.js +1 -1
- package/cjs/app/project/service.js +1 -1
- package/cjs/app/providers/foundation.js +1 -1
- package/cjs/app/ssr/artifacts.js +1 -1
- package/cjs/app/ssr/controller.js +1 -1
- package/cjs/app/ssr/html.js +17 -17
- package/cjs/app/ssr/stream.js +1 -1
- package/cjs/app/static-assets.middleware.js +1 -1
- package/cjs/app/template-core.module.js +1 -1
- package/cjs/app/view/entry.tpl +2 -2
- package/cjs/bundler/buildSSR.js +1 -1
- package/cjs/bundler/entryCollect.js +1 -1
- package/cjs/bundler/feSharedConfig.js +1 -1
- package/cjs/bundler/utils.js +3 -3
- package/cjs/config/config.default.js +1 -1
- package/cjs/packages/common/index.js +1 -1
- package/cjs/packages/core/bootstrap.js +1 -1
- package/cjs/packages/core/startup.js +1 -1
- package/esm/app/ai/agent/agent-scanner.service.js +33 -36
- package/esm/app/ai/agent/agent.module.js +9 -7
- package/esm/app/ai/ai-config.module.js +14 -7
- package/esm/app/ai/ai-config.service.js +24 -20
- package/esm/app/ai/ai.controller.js +41 -41
- package/esm/app/ai/ai.module.js +15 -15
- package/esm/app/ai/guardrail/guardrail.module.js +11 -9
- package/esm/app/ai/guardrail/guardrail.service.js +5 -10
- package/esm/app/ai/index.js +2 -0
- package/esm/app/ai/mcp/internal/read-sse-response.js +35 -0
- package/esm/app/ai/mcp/internal/stdio-process.js +59 -0
- package/esm/app/ai/mcp/mcp-registry.service.js +10 -15
- package/esm/app/ai/mcp/mcp.client.js +77 -78
- package/esm/app/ai/mcp/mcp.loader.js +64 -42
- package/esm/app/ai/mcp/mcp.module.js +62 -22
- package/esm/app/ai/memory/checkpoint.service.js +18 -28
- package/esm/app/ai/memory/memory.module.js +15 -12
- package/esm/app/ai/memory/thread.service.js +21 -26
- package/esm/app/ai/models/chat-sse.js +44 -0
- package/esm/app/ai/models/chat.js +60 -0
- package/esm/app/ai/models/http.js +52 -0
- package/esm/app/ai/models/image.js +37 -0
- package/esm/app/ai/models/video.js +32 -0
- package/esm/app/ai/nest-service-provider.js +10 -0
- package/esm/app/ai/rag/rag.module.js +24 -15
- package/esm/app/ai/rag/retriever.service.js +37 -54
- package/esm/app/ai/retention/conversation-retention.service.js +16 -34
- package/esm/app/ai/runtime/ai-runtime-startup.validator.js +2 -19
- package/esm/app/ai/runtime/ai-runtime.js +104 -0
- package/esm/app/ai/runtime/internal/context-compaction.service.js +139 -145
- package/esm/app/ai/runtime/internal/declaration-snapshot.js +32 -0
- package/esm/app/ai/runtime/internal/owned-runtime-resources.js +21 -0
- package/esm/app/ai/runtime/langchain/langchain-planner.service.js +43 -49
- package/esm/app/ai/runtime/langgraph/langgraph-orchestrator.service.js +273 -225
- package/esm/app/ai/runtime/runtime.module.js +56 -35
- package/esm/app/ai/skill/skill-scanner.service.js +11 -16
- package/esm/app/ai/skill/skill.module.js +11 -9
- package/esm/app/ai/snapshot-data.js +24 -0
- package/esm/app/ai/store/internal/create-vector-store.js +10 -0
- package/esm/app/ai/store/store.module.js +9 -13
- package/esm/app/ai/tool/builtin/index.js +16 -4
- package/esm/app/ai/tool/builtin/invoke-agent.tool.js +30 -34
- package/esm/app/ai/tool/builtin/retrieve.tool.js +9 -13
- package/esm/app/ai/tool/executor.service.js +22 -29
- package/esm/app/ai/tool/tool-registry.service.js +6 -16
- package/esm/app/ai/tool/tool.module.js +26 -12
- package/esm/app/ai/trace/trace.service.js +15 -28
- package/esm/app/csr/controller.js +114 -63
- package/esm/app/csr/types.js +0 -0
- package/esm/app/html/browser-options.js +2 -2
- package/esm/app/html/shell.js +173 -32
- package/esm/app/http/api-signing.js +13 -0
- package/esm/app/http/body-parser.middleware.js +47 -27
- package/esm/app/http/csp-nonce.js +13 -0
- package/esm/app/http/error-response.js +8 -5
- package/esm/app/http/exception-filter.js +4 -4
- package/esm/app/http/request-body-parser-policy.js +46 -0
- package/esm/app/http/security.guard.js +23 -21
- package/esm/app/project/controller.js +15 -15
- package/esm/app/project/service.js +3 -3
- package/esm/app/providers/foundation.js +5 -5
- package/esm/app/ssr/artifacts.js +25 -21
- package/esm/app/ssr/controller.js +148 -75
- package/esm/app/ssr/html.js +49 -44
- package/esm/app/ssr/stream.js +25 -24
- package/esm/app/static-assets.middleware.js +4 -4
- package/esm/app/template-core.module.js +57 -52
- package/esm/app/view/entry.tpl +2 -2
- package/esm/bundler/buildSSR.js +1 -1
- package/esm/bundler/entryCollect.js +9 -9
- package/esm/bundler/feSharedConfig.js +42 -42
- package/esm/bundler/utils.js +78 -90
- package/esm/config/config.default.js +4 -3
- package/esm/packages/common/index.js +6 -6
- package/esm/packages/core/bootstrap.js +5 -5
- package/esm/packages/core/startup.js +69 -46
- package/fe/frontend/src/common/request.js +5 -2
- package/fe/frontend/src/hooks/useRouterParams.d.ts +4 -2
- package/fe/packages/common/ssr/hydration.d.ts +9 -0
- package/fe/packages/react/core/Label/Label.d.ts +1 -0
- package/fe/packages/react/core/Label/Label.js +3 -1
- package/fe/packages/react/core/internal/i18n/default.d.ts +13 -0
- package/fe/packages/react/core/internal/i18n/default.js +16 -1
- package/fe/packages/react/core/internal/i18n/en-US.d.ts +13 -0
- package/fe/packages/react/core/internal/i18n/en-US.js +16 -1
- package/fe/packages/react/forms/DataTable/index.d.ts +2 -0
- package/fe/packages/react/forms/DataTable/index.js +43 -29
- package/fe/packages/react/forms/Form/FormItem.js +39 -12
- package/fe/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
- package/fe/packages/react/forms/MultiSelect/MultiSelect.js +218 -0
- package/fe/packages/react/forms/MultiSelect/index.d.ts +1 -0
- package/fe/packages/react/forms/MultiSelect/index.js +2 -0
- package/fe/packages/react/forms/Pagination/Pagination.d.ts +6 -1
- package/fe/packages/react/forms/Pagination/Pagination.js +13 -4
- package/fe/packages/react/forms/Select/Select.d.ts +11 -0
- package/fe/packages/react/forms/Select/Select.js +20 -7
- package/fe/packages/react/forms/index.d.ts +1 -0
- package/fe/packages/react/forms/index.js +3 -1
- package/fe/packages/react/i18n/getUiReactLocale.d.ts +26 -0
- package/fe/packages/react/index.js +2 -1
- package/fe/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
- package/fe/packages/react/overlays/Drawer/Drawer.js +16 -2
- package/fe/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
- package/fe/packages/react/overlays/Dropdown/Dropdown.js +27 -14
- package/fe/packages/react/overlays/Modal/Modal.d.ts +11 -3
- package/fe/packages/react/overlays/Modal/Modal.js +26 -2
- package/fe/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
- package/fe/packages/react/overlays/Modal/ModalManager.js +15 -5
- package/fe/packages/react/overlays/Modal/index.d.ts +1 -0
- package/fe/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
- package/fe/packages/react/overlays/Overlay/Overlay.js +31 -14
- package/fe/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
- package/fe/packages/react/overlays/Overlay/focusTypes.js +0 -0
- package/fe/packages/react/overlays/Overlay/index.d.ts +1 -0
- package/fe/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
- package/fe/packages/react/overlays/Overlay/overlayStack.js +290 -0
- package/fe/packages/react/overlays/Popup/Popup.d.ts +5 -4
- package/fe/packages/react/overlays/Popup/Popup.js +28 -11
- package/fe/packages/react/ui/components/index.js +2 -1
- package/fe/packages/react/ui/index.js +2 -1
- package/fe/ssr/components/StreamingRender/StreamingCache.d.ts +1 -0
- package/fe/ssr/components/StreamingRender/StreamingCache.js +5 -1
- package/fe/ssr/components/StreamingRender/StreamingRender.js +1 -1
- package/fe/ssr/components/StreamingRender/StreamingScript.d.ts +1 -0
- package/fe/ssr/components/StreamingRender/StreamingScript.js +9 -1
- package/fe/ssr/createSSREntry.d.ts +9 -3
- package/fe/ssr/createSSREntry.js +43 -19
- package/fe/ssr/index.d.ts +4 -1
- package/fe/ssr/index.js +2 -1
- package/fe/ssr/router.d.ts +76 -0
- package/fe/ssr/router.js +349 -0
- package/fe/ssr/types.d.ts +1 -1
- package/models/packages/common/ssr/hydration.d.ts +9 -0
- package/models/packages/react/core/Label/Label.d.ts +1 -0
- package/models/packages/react/core/internal/i18n/default.d.ts +13 -0
- package/models/packages/react/core/internal/i18n/en-US.d.ts +13 -0
- package/models/packages/react/forms/DataTable/index.d.ts +2 -0
- package/models/packages/react/forms/MultiSelect/MultiSelect.d.ts +26 -0
- package/models/packages/react/forms/MultiSelect/index.d.ts +1 -0
- package/models/packages/react/forms/Pagination/Pagination.d.ts +6 -1
- package/models/packages/react/forms/Select/Select.d.ts +11 -0
- package/models/packages/react/forms/index.d.ts +1 -0
- package/models/packages/react/i18n/getUiReactLocale.d.ts +26 -0
- package/models/packages/react/overlays/Drawer/Drawer.d.ts +3 -2
- package/models/packages/react/overlays/Dropdown/Dropdown.d.ts +12 -2
- package/models/packages/react/overlays/Modal/Modal.d.ts +11 -3
- package/models/packages/react/overlays/Modal/ModalManager.d.ts +13 -12
- package/models/packages/react/overlays/Modal/index.d.ts +1 -0
- package/models/packages/react/overlays/Overlay/Overlay.d.ts +6 -2
- package/models/packages/react/overlays/Overlay/focusTypes.d.ts +8 -0
- package/models/packages/react/overlays/Overlay/index.d.ts +1 -0
- package/models/packages/react/overlays/Overlay/overlayStack.d.ts +16 -0
- package/models/packages/react/overlays/Popup/Popup.d.ts +5 -4
- package/package.json +26 -1
- package/types/app/ai/agent/agent-scanner.service.d.ts +4 -4
- package/types/app/ai/ai-config.service.d.ts +7 -3
- package/types/app/ai/guardrail/guardrail.service.d.ts +2 -2
- package/types/app/ai/index.d.ts +9 -0
- package/types/app/ai/mcp/internal/load-mcp-config.d.ts +2 -2
- package/types/app/ai/mcp/internal/read-sse-response.d.ts +2 -0
- package/types/app/ai/mcp/internal/stdio-process.d.ts +5 -0
- package/types/app/ai/mcp/mcp-registry.service.d.ts +5 -3
- package/types/app/ai/mcp/mcp.client.d.ts +7 -4
- package/types/app/ai/mcp/mcp.loader.d.ts +11 -11
- package/types/app/ai/mcp/mcp.module.d.ts +5 -5
- package/types/app/ai/memory/thread.service.d.ts +3 -3
- package/types/app/ai/models/chat-sse.d.ts +5 -0
- package/types/app/ai/models/chat.d.ts +22 -0
- package/types/app/ai/models/http.d.ts +20 -0
- package/types/app/ai/models/image.d.ts +69 -0
- package/types/app/ai/models/video.d.ts +99 -0
- package/types/app/ai/nest-service-provider.d.ts +6 -0
- package/types/app/ai/retention/conversation-retention.service.d.ts +3 -4
- package/types/app/ai/runtime/ai-runtime-startup.validator.d.ts +2 -3
- package/types/app/ai/runtime/ai-runtime.d.ts +46 -0
- package/types/app/ai/runtime/internal/agent-run-context.d.ts +4 -0
- package/types/app/ai/runtime/internal/context-compaction.service.d.ts +2 -2
- package/types/app/ai/runtime/internal/declaration-snapshot.d.ts +8 -0
- package/types/app/ai/runtime/internal/owned-runtime-resources.d.ts +5 -0
- package/types/app/ai/runtime/langchain/langchain-planner.service.d.ts +1 -1
- package/types/app/ai/runtime/langgraph/langgraph-orchestrator.service.d.ts +33 -16
- package/types/app/ai/skill/skill-scanner.service.d.ts +3 -4
- package/types/app/ai/snapshot-data.d.ts +1 -0
- package/types/app/ai/store/internal/create-vector-store.d.ts +4 -0
- package/types/app/ai/tool/builtin/index.d.ts +1 -1
- package/types/app/ai/tool/builtin/invoke-agent.tool.d.ts +10 -3
- package/types/app/ai/tool/builtin/retrieve.tool.d.ts +4 -3
- package/types/app/ai/tool/executor.service.d.ts +3 -3
- package/types/app/ai/tool/tool-registry.service.d.ts +2 -7
- package/types/app/ai/tool/tool.interface.d.ts +1 -1
- package/types/app/ai/tool/tool.module.d.ts +8 -1
- package/types/app/ai/trace/trace.service.d.ts +4 -5
- package/types/app/csr/types.d.ts +10 -0
- package/types/app/html/browser-options.d.ts +1 -1
- package/types/app/html/shell.d.ts +37 -10
- package/types/app/http/api-signing.d.ts +16 -0
- package/types/app/http/body-parser.middleware.d.ts +6 -2
- package/types/app/http/csp-nonce.d.ts +3 -0
- package/types/app/http/error-response.d.ts +1 -0
- package/types/app/http/request-body-parser-policy.d.ts +8 -0
- package/types/app/http/security.guard.d.ts +1 -0
- package/types/app/ssr/artifacts.d.ts +6 -3
- package/types/app/ssr/html.d.ts +7 -0
- package/types/app/ssr/stream.d.ts +1 -1
- package/types/app/ssr/types.d.ts +56 -0
- package/types/bundler/buildSSR.d.ts +2 -1
- package/types/bundler/index.d.ts +1 -1
- package/types/bundler/state.d.ts +13 -0
- package/types/bundler/utils.d.ts +3 -14
- package/types/config/config.default.d.ts +9 -3
- package/types/index.d.ts +4 -1
- package/types/packages/common/ssr/hydration.d.ts +13 -0
- package/types/packages/core/index.d.ts +1 -1
- package/types/packages/core/startup.d.ts +41 -0
|
@@ -2,119 +2,192 @@ import { TC_LOGGER as e } from "../../packages/core/tokens.js";
|
|
|
2
2
|
import { TemplateCoreRuntime as t } from "../../packages/core/startup.js";
|
|
3
3
|
import "../../packages/core/index.js";
|
|
4
4
|
import { FrontendDevelopment as n } from "../frontend-development.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import b from "@
|
|
5
|
+
import { resolveCspNonce as r } from "../http/csp-nonce.js";
|
|
6
|
+
import { createTemplateCoreHttpContext as i } from "../http/context.js";
|
|
7
|
+
import { ssrClientAssetUrl as a } from "../../ssrSharedData/outputPaths.js";
|
|
8
|
+
import { SSRArtifacts as o } from "./artifacts.js";
|
|
9
|
+
import { createHydrationData as s, serializeHydrationDataScriptContent as c } from "../../packages/common/ssr/hydration.js";
|
|
10
|
+
import { createSSRDocument as l, renderSSRErrorHtml as u } from "./html.js";
|
|
11
|
+
import { findSSRClientEntry as d, generateSSRPreloadLinks as f } from "./manifest.js";
|
|
12
|
+
import { streamSSRDocument as p } from "./stream.js";
|
|
13
|
+
import { SSRRenderInterruptedError as m, SSRRenderSessionRegistry as h } from "./session.js";
|
|
14
|
+
import { Controller as g, Get as _, Inject as v, Req as y, Res as b } from "@nestjs/common";
|
|
15
15
|
import x from "@oxc-project/runtime/helpers/decorate";
|
|
16
|
-
import S from "@oxc-project/runtime/helpers/
|
|
17
|
-
import
|
|
16
|
+
import S from "@oxc-project/runtime/helpers/decorateMetadata";
|
|
17
|
+
import C from "@oxc-project/runtime/helpers/decorateParam";
|
|
18
|
+
import * as w from "react";
|
|
18
19
|
//#region app/ssr/controller.ts
|
|
19
|
-
var
|
|
20
|
-
|
|
20
|
+
var T = /^[A-Za-z0-9_-]+$/, E = "x-tc-ssr-data";
|
|
21
|
+
function D(e) {
|
|
22
|
+
let t = e.headers[E];
|
|
23
|
+
return Array.isArray(t) ? t.some((e) => e === "1") : t === "1";
|
|
24
|
+
}
|
|
25
|
+
function O(e, t, n = 200) {
|
|
26
|
+
e.status(n).setHeader("Cache-Control", "private, no-store").type("json").json(t);
|
|
27
|
+
}
|
|
28
|
+
function k(e, t, n, r, i, a) {
|
|
29
|
+
let o = w.createElement(e, n);
|
|
30
|
+
return t ? w.createElement(t, {
|
|
31
|
+
children: o,
|
|
32
|
+
page: r,
|
|
33
|
+
path: i,
|
|
34
|
+
query: a
|
|
35
|
+
}) : o;
|
|
36
|
+
}
|
|
37
|
+
async function A(e, t, n) {
|
|
21
38
|
let r = typeof e == "function" ? await e(t) : e;
|
|
22
39
|
return r == null ? n : String(r);
|
|
23
40
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
async function j(e, t) {
|
|
42
|
+
return (typeof e == "function" ? await e(t) : e) ?? void 0;
|
|
43
|
+
}
|
|
44
|
+
function M(e) {
|
|
45
|
+
if (!e || typeof e != "object" || !("redirect" in e) || e.type !== "redirect") return !1;
|
|
46
|
+
let t = e.redirect;
|
|
47
|
+
return Object.keys(e).length === 2 && !!t && typeof t == "object" && Object.keys(t).length === 2 && "location" in t && "status" in t;
|
|
48
|
+
}
|
|
49
|
+
function N(e) {
|
|
50
|
+
return !!e && typeof e == "object" && "status" in e && "props" in e && Object.keys(e).length === 3 && e.type === "status" && typeof e.status == "number" && !!e.props && typeof e.props == "object";
|
|
51
|
+
}
|
|
52
|
+
function P(E) {
|
|
53
|
+
var P, F, I, L;
|
|
54
|
+
let R = class {
|
|
27
55
|
constructor(e, t, n, r, i) {
|
|
28
56
|
this.runtime = e, this.artifacts = t, this.sessions = n, this.development = r, this.logger = i;
|
|
29
57
|
}
|
|
30
58
|
async render(e, t) {
|
|
31
|
-
let n = String(e.params.page ?? ""),
|
|
59
|
+
let n = String(e.params.page ?? ""), o = D(e), h = i(e, t), g = this.runtime.config.ssr, _ = g && typeof g == "object" && "exposeErrorDetails" in g ? !!g.exposeErrorDetails : void 0, v = {
|
|
32
60
|
options: this.runtime.options,
|
|
33
61
|
config: {
|
|
34
62
|
signKey: this.runtime.config.signKey,
|
|
35
|
-
|
|
63
|
+
apiSignVerify: this.runtime.config.apiSignVerify,
|
|
64
|
+
html: this.runtime.config.html,
|
|
65
|
+
ssr: { exposeErrorDetails: _ }
|
|
36
66
|
},
|
|
37
67
|
envs: { isLocal: () => this.runtime.environment === "local" }
|
|
38
|
-
},
|
|
68
|
+
}, y = {
|
|
39
69
|
query: e.query,
|
|
40
|
-
projectKey:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
70
|
+
projectKey: h.projectKey,
|
|
71
|
+
language: h.language
|
|
72
|
+
}, b, x = this.sessions.create(t, g, (e) => this.logger.error(`[SSR] Failed to render ${n}`, e)), S = (e, r, i, a) => {
|
|
73
|
+
t.destroyed || t.headersSent || t.writableEnded || t.status(e).type("html").send(u({
|
|
74
|
+
app: v,
|
|
75
|
+
ctx: y,
|
|
45
76
|
page: n,
|
|
46
77
|
status: e,
|
|
47
78
|
title: r,
|
|
48
79
|
message: i,
|
|
49
|
-
error: a
|
|
80
|
+
error: a,
|
|
81
|
+
nonce: b
|
|
50
82
|
}));
|
|
51
83
|
};
|
|
52
84
|
try {
|
|
53
|
-
await
|
|
54
|
-
if (!
|
|
55
|
-
|
|
85
|
+
await x.run(async () => {
|
|
86
|
+
if (b = await r(e, t, this.runtime.config), x.assertActive(), !T.test(n)) {
|
|
87
|
+
S(404, "SSR page not found", "The requested SSR page is not registered.");
|
|
56
88
|
return;
|
|
57
89
|
}
|
|
58
|
-
let
|
|
59
|
-
if (
|
|
60
|
-
|
|
90
|
+
let i = await this.artifacts.loadPage(n);
|
|
91
|
+
if (x.assertActive(), !i) {
|
|
92
|
+
S(404, "SSR bundle not found", `No server bundle was found for "${n}".`);
|
|
61
93
|
return;
|
|
62
94
|
}
|
|
63
|
-
let
|
|
95
|
+
let u = {
|
|
64
96
|
params: Object.fromEntries(Object.entries(e.params).map(([e, t]) => [e, Array.isArray(t) ? t.join("/") : String(t)])),
|
|
65
97
|
query: e.query,
|
|
66
98
|
path: e.path,
|
|
67
99
|
app: this.runtime.application,
|
|
68
|
-
ctx:
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
ctx: h
|
|
101
|
+
}, m = await i.getServerProps?.(u) ?? {};
|
|
102
|
+
if (M(m)) {
|
|
103
|
+
let { location: e, status: r } = m.redirect;
|
|
104
|
+
if (typeof e != "string" || !Number.isInteger(r) || r < 300 || r > 399) throw Error("[SSR] Invalid redirect result");
|
|
105
|
+
if (o) {
|
|
106
|
+
O(t, {
|
|
107
|
+
type: "redirect",
|
|
108
|
+
page: n,
|
|
109
|
+
location: e,
|
|
110
|
+
status: r,
|
|
111
|
+
buildKey: this.artifacts.readBuildKey()
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
t.redirect(r, e);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let g = N(m) ? m.status : 200, _ = N(m) ? m.props : m;
|
|
119
|
+
if (!Number.isInteger(g) || g < 100 || g > 599) throw Error("[SSR] Invalid response status");
|
|
120
|
+
x.assertActive();
|
|
121
|
+
let C = {
|
|
122
|
+
...u,
|
|
123
|
+
props: _
|
|
124
|
+
}, E = await A(i.pageTitle, C, n);
|
|
125
|
+
x.assertActive();
|
|
126
|
+
let D = await A(i.pageDescription, C, "");
|
|
127
|
+
x.assertActive();
|
|
128
|
+
let P = await j(i.pageHead, C);
|
|
129
|
+
x.assertActive();
|
|
130
|
+
let F = this.development.session, I = F ? null : this.artifacts.readManifest(), L = d(I, n), R = this.artifacts.readBuildKey(), z = L?.file ? a(L.file) : null;
|
|
131
|
+
if (o) {
|
|
132
|
+
O(t, {
|
|
133
|
+
type: N(m) ? "status" : "page",
|
|
134
|
+
page: n,
|
|
135
|
+
props: _,
|
|
136
|
+
title: E,
|
|
137
|
+
description: D,
|
|
138
|
+
head: P,
|
|
139
|
+
status: g,
|
|
140
|
+
buildKey: R,
|
|
141
|
+
entry: z
|
|
142
|
+
}, g);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
let B = s(_, {
|
|
146
|
+
title: E,
|
|
147
|
+
description: D,
|
|
148
|
+
pathname: e.path,
|
|
149
|
+
page: n,
|
|
150
|
+
buildKey: R,
|
|
151
|
+
entry: z,
|
|
152
|
+
head: P
|
|
153
|
+
}), V = l(w, {
|
|
154
|
+
app: v,
|
|
155
|
+
ctx: y,
|
|
85
156
|
page: n,
|
|
86
|
-
title:
|
|
87
|
-
description:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
157
|
+
title: E,
|
|
158
|
+
description: D,
|
|
159
|
+
head: P,
|
|
160
|
+
nonce: b,
|
|
161
|
+
preloadLinks: F ? await F.renderSSRHead(n) : f(I, L),
|
|
162
|
+
hydrationScriptContent: c(B),
|
|
163
|
+
appNode: k(i.default, i.layout, _, n, e.path, e.query)
|
|
164
|
+
}), H = z ?? void 0;
|
|
165
|
+
F && t.setHeader("Cache-Control", "no-store"), await p(V, t, x, H, g, b);
|
|
93
166
|
});
|
|
94
167
|
} catch (e) {
|
|
95
|
-
if (e instanceof
|
|
96
|
-
|
|
168
|
+
if (e instanceof m || (x.report(e), t.writableFinished) || t.headersSent || t.destroyed || t.writableEnded) return;
|
|
169
|
+
S(500, "SSR render error", "The SSR page failed while loading data or rendering.", e);
|
|
97
170
|
}
|
|
98
171
|
}
|
|
99
172
|
};
|
|
100
173
|
return x([
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
],
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
typeof (
|
|
112
|
-
typeof (
|
|
113
|
-
typeof (
|
|
114
|
-
typeof (
|
|
174
|
+
_([":page", ":page/{*rest}"]),
|
|
175
|
+
C(0, y()),
|
|
176
|
+
C(1, b()),
|
|
177
|
+
S("design:type", Function),
|
|
178
|
+
S("design:paramtypes", [Object, Object]),
|
|
179
|
+
S("design:returntype", Promise)
|
|
180
|
+
], R.prototype, "render", null), R = x([
|
|
181
|
+
g(E),
|
|
182
|
+
C(4, v(e)),
|
|
183
|
+
S("design:paramtypes", [
|
|
184
|
+
typeof (P = t !== void 0 && t) == "function" ? P : Object,
|
|
185
|
+
typeof (F = o !== void 0 && o) == "function" ? F : Object,
|
|
186
|
+
typeof (I = h !== void 0 && h) == "function" ? I : Object,
|
|
187
|
+
typeof (L = n !== void 0 && n) == "function" ? L : Object,
|
|
115
188
|
Object
|
|
116
189
|
])
|
|
117
|
-
],
|
|
190
|
+
], R), R;
|
|
118
191
|
}
|
|
119
192
|
//#endregion
|
|
120
|
-
export {
|
|
193
|
+
export { P as createSSRPageController };
|
package/esm/app/ssr/html.js
CHANGED
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
import { normalizeRouteBasePath as e } from "../../packages/core/paths.js";
|
|
2
2
|
import "../../packages/core/index.js";
|
|
3
3
|
import { projectBrowserOptions as t } from "../html/browser-options.js";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveBrowserSignKey as n } from "../http/api-signing.js";
|
|
5
|
+
import { escapeHtml as r, escapeHtmlAttr as i, renderDocumentHeadHtml as a, renderHtmlBodyAttributes as o, renderHtmlDocumentStart as s, renderHtmlHeadContent as c, renderRuntimeContextScriptsFromExpressions as l, renderScriptNonceAttribute as u, renderThemeScriptContent as d, resolveHtmlShellOptions as f, serializeForHtmlScript as p } from "../html/shell.js";
|
|
5
6
|
//#region app/ssr/html.ts
|
|
6
|
-
function
|
|
7
|
+
function m(...e) {
|
|
7
8
|
return `/${e.filter(Boolean).map((e) => e.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/")}`;
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
+
function h(e) {
|
|
10
11
|
if (e.projectKey !== void 0) return e.projectKey;
|
|
11
12
|
let t = e.query.projk;
|
|
12
13
|
return Array.isArray(t) ? t.join("") : String(t ?? "");
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
let
|
|
15
|
+
function g(r, i, a, o) {
|
|
16
|
+
let s = e(r.options.pageBasePath) || "/", c = m(e(r.options.ssrPageBasePath, "/fessr") || "/fessr", a), l = h(i);
|
|
16
17
|
return {
|
|
17
|
-
basePathExpression:
|
|
18
|
-
feBasePageExpression:
|
|
19
|
-
projKeyExpression:
|
|
20
|
-
signKeyExpression:
|
|
21
|
-
renderModeExpression:
|
|
22
|
-
optionsJsonHtml:
|
|
18
|
+
basePathExpression: p(c),
|
|
19
|
+
feBasePageExpression: p(s),
|
|
20
|
+
projKeyExpression: p(l),
|
|
21
|
+
signKeyExpression: p(n(r.config)),
|
|
22
|
+
renderModeExpression: p("ssr"),
|
|
23
|
+
optionsJsonHtml: p(t(r.options)),
|
|
24
|
+
nonceAttr: u(o)
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
27
|
+
function _(e, t, n, r) {
|
|
28
|
+
return l(g(e, t, n, r));
|
|
27
29
|
}
|
|
28
|
-
function
|
|
29
|
-
let { app: t, ctx: n, page: r, hydrationScript: i = "", clientScript: a = "" } = e;
|
|
30
|
+
function v(e) {
|
|
31
|
+
let { app: t, ctx: n, page: r, hydrationScript: i = "", clientScript: a = "" } = e, c = f(t.options.html, t.config.html, n.language);
|
|
30
32
|
return {
|
|
31
33
|
beforeAppHtml: `<!DOCTYPE html>
|
|
32
|
-
|
|
34
|
+
${s(c)}
|
|
33
35
|
<head>
|
|
34
|
-
${
|
|
36
|
+
${b(e, c)}
|
|
35
37
|
</head>
|
|
36
|
-
${
|
|
37
|
-
<body>
|
|
38
|
+
${_(t, n, r, e.nonce)}
|
|
39
|
+
<body${o(c.body)}>
|
|
38
40
|
<div id="root">`,
|
|
39
41
|
afterAppHtml: `</div>
|
|
40
42
|
${i}
|
|
@@ -43,57 +45,60 @@ ${u(t, n, r)}
|
|
|
43
45
|
</html>`
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
function
|
|
47
|
-
let { app: t, ctx: n, page: r, hydrationScript: i = "" } = e;
|
|
48
|
+
function y(e) {
|
|
49
|
+
let { app: t, ctx: n, page: r, hydrationScript: i = "" } = e, a = f(t.options.html, t.config.html, n.language);
|
|
48
50
|
return {
|
|
49
51
|
beforeAppHtml: `<!DOCTYPE html>
|
|
50
|
-
|
|
52
|
+
${s(a)}
|
|
51
53
|
<head>
|
|
52
|
-
${
|
|
54
|
+
${b(e, a)}
|
|
53
55
|
</head>
|
|
54
|
-
<body>
|
|
55
|
-
${
|
|
56
|
+
<body${o(a.body)}>
|
|
57
|
+
${_(t, n, r, e.nonce)}
|
|
56
58
|
${i}`,
|
|
57
59
|
afterAppHtml: "</body>\n</html>"
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
|
-
function
|
|
61
|
-
let { title:
|
|
62
|
-
return
|
|
63
|
-
titleHtml: n
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
function b(e, t = f(e.app.options.html, e.app.config.html, e.ctx.language)) {
|
|
63
|
+
let { title: n, description: i = "", preloadLinks: o = "", head: s, nonce: l } = e;
|
|
64
|
+
return a({
|
|
65
|
+
titleHtml: r(n),
|
|
66
|
+
preloadLinks: o,
|
|
67
|
+
extraHeadHtml: c(t, s, i, l),
|
|
68
|
+
nonceAttr: u(l),
|
|
69
|
+
themeScriptContent: d(t)
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
|
-
function
|
|
72
|
+
function x(e, t) {
|
|
69
73
|
let { appNode: n, hydrationScriptContent: r = "" } = t;
|
|
70
74
|
return {
|
|
71
|
-
...
|
|
75
|
+
...y({
|
|
72
76
|
...t,
|
|
73
|
-
hydrationScript: r ? `<script>${r}<\/script>` : ""
|
|
77
|
+
hydrationScript: r ? `<script${u(t.nonce)}>${r}<\/script>` : ""
|
|
74
78
|
}),
|
|
75
79
|
element: e.createElement("div", { id: "root" }, n)
|
|
76
80
|
};
|
|
77
81
|
}
|
|
78
|
-
function
|
|
79
|
-
let { appHtml: t, ...n } = e, { beforeAppHtml: r, afterAppHtml: i } =
|
|
82
|
+
function S(e) {
|
|
83
|
+
let { appHtml: t, ...n } = e, { beforeAppHtml: r, afterAppHtml: i } = v(n);
|
|
80
84
|
return `${r}${t}${i}`;
|
|
81
85
|
}
|
|
82
|
-
function
|
|
83
|
-
let { app: t, ctx:
|
|
84
|
-
return
|
|
86
|
+
function C(e) {
|
|
87
|
+
let { app: t, ctx: n, page: i, status: a, title: o, message: s, error: c, nonce: l } = e, u = t.config.ssr?.exposeErrorDetails ?? t.envs.isLocal(), d = c instanceof Error ? c.stack || c.message : String(c ?? ""), f = u && d ? `<pre style="white-space:pre-wrap;margin-top:16px;padding:12px;border:1px solid #d8dee4;background:#f6f8fa;color:#24292f;overflow:auto">${r(d)}</pre>` : "";
|
|
88
|
+
return S({
|
|
85
89
|
app: t,
|
|
86
|
-
ctx:
|
|
90
|
+
ctx: n,
|
|
87
91
|
page: i,
|
|
88
92
|
title: o,
|
|
89
93
|
description: s,
|
|
94
|
+
nonce: l,
|
|
90
95
|
appHtml: `<main style="font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;max-width:720px;margin:72px auto;padding:0 24px;line-height:1.5;color:#24292f">
|
|
91
96
|
<p style="margin:0 0 8px;color:#57606a;font-size:14px">SSR ${a}</p>
|
|
92
|
-
<h1 style="margin:0 0 12px;font-size:28px;line-height:1.2">${
|
|
93
|
-
<p style="margin:0;color:#57606a">${
|
|
94
|
-
${
|
|
97
|
+
<h1 style="margin:0 0 12px;font-size:28px;line-height:1.2">${r(o)}</h1>
|
|
98
|
+
<p style="margin:0;color:#57606a">${r(s)}</p>
|
|
99
|
+
${f}
|
|
95
100
|
</main>`
|
|
96
101
|
});
|
|
97
102
|
}
|
|
98
103
|
//#endregion
|
|
99
|
-
export {
|
|
104
|
+
export { x as createSSRDocument, r as escapeHtml, i as escapeHtmlAttr, C as renderSSRErrorHtml, S as renderSSRHtmlShell, v as renderSSRHtmlShellParts, p as serializeForHtmlScript };
|
package/esm/app/ssr/stream.js
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
1
|
import { PassThrough as e } from "node:stream";
|
|
2
2
|
import { renderToPipeableStream as t } from "react-dom/server";
|
|
3
3
|
//#region app/ssr/stream.ts
|
|
4
|
-
function n(n, r, i, a) {
|
|
5
|
-
return new Promise((
|
|
6
|
-
let
|
|
7
|
-
r.removeListener("finish",
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
r.writableFinished ||
|
|
12
|
-
},
|
|
13
|
-
i.report(e), i.cancel(e, !0),
|
|
14
|
-
},
|
|
4
|
+
function n(n, r, i, a, o = 200, s) {
|
|
5
|
+
return new Promise((c, l) => {
|
|
6
|
+
let u = !1, d, f = !1, p, m = () => void 0, h = new e(), g = () => {
|
|
7
|
+
r.removeListener("finish", v), r.removeListener("close", y), r.removeListener("error", b), h.removeListener("end", x), h.removeListener("error", b), h.unpipe(r), h.destroy(), m();
|
|
8
|
+
}, _ = (e) => {
|
|
9
|
+
f || (f = !0, g(), e === void 0 ? c() : l(e));
|
|
10
|
+
}, v = () => _(), y = () => {
|
|
11
|
+
r.writableFinished || _(/* @__PURE__ */ Error("SSR response closed before the stream finished"));
|
|
12
|
+
}, b = (e) => {
|
|
13
|
+
i.report(e), i.cancel(e, !0), _(e);
|
|
14
|
+
}, x = () => {
|
|
15
15
|
r.destroyed || r.writableEnded || r.end(n.afterAppHtml);
|
|
16
16
|
};
|
|
17
|
-
if (r.once("finish",
|
|
18
|
-
|
|
19
|
-
}), !
|
|
20
|
-
|
|
17
|
+
if (r.once("finish", v), r.once("close", y), r.once("error", b), h.once("error", b), h.once("end", x), m = i.onAbort((e) => {
|
|
18
|
+
_(e), p?.abort(e);
|
|
19
|
+
}), !f) try {
|
|
20
|
+
p = t(n.element, {
|
|
21
21
|
bootstrapModules: a ? [a] : void 0,
|
|
22
|
+
nonce: s,
|
|
22
23
|
onShellReady() {
|
|
23
|
-
if (
|
|
24
|
-
|
|
24
|
+
if (d) {
|
|
25
|
+
p?.abort(d), _(d);
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
28
|
try {
|
|
28
|
-
i.markStreaming(),
|
|
29
|
+
i.markStreaming(), u = !0, r.status(o).type("html"), r.setHeader("Cache-Control", "no-transform"), r.flushHeaders(), r.write(n.beforeAppHtml), h.pipe(r, { end: !1 }), p?.pipe(h);
|
|
29
30
|
} catch (e) {
|
|
30
|
-
i.cancel(e instanceof Error ? e : Error(String(e)), r.headersSent),
|
|
31
|
+
i.cancel(e instanceof Error ? e : Error(String(e)), r.headersSent), _(e);
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
34
|
onShellError(e) {
|
|
34
|
-
|
|
35
|
+
p?.abort(e), _(e);
|
|
35
36
|
},
|
|
36
37
|
onError(e) {
|
|
37
|
-
if (!
|
|
38
|
-
|
|
38
|
+
if (!u) {
|
|
39
|
+
d = e;
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
|
-
i.report(e), i.cancel(e instanceof Error ? e : Error(String(e)), !0),
|
|
42
|
+
i.report(e), i.cancel(e instanceof Error ? e : Error(String(e)), !0), _(e);
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
} catch (e) {
|
|
45
|
-
|
|
46
|
+
_(e);
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
}
|
|
@@ -4,8 +4,8 @@ import { TemplateCoreRuntime as n } from "../packages/core/startup.js";
|
|
|
4
4
|
import "../packages/core/index.js";
|
|
5
5
|
import { SSR_SERVER_OUT_DIR as r } from "../ssrSharedData/outputPaths.js";
|
|
6
6
|
import { Inject as i, Injectable as a } from "@nestjs/common";
|
|
7
|
-
import o from "@oxc-project/runtime/helpers/
|
|
8
|
-
import s from "@oxc-project/runtime/helpers/
|
|
7
|
+
import o from "@oxc-project/runtime/helpers/decorate";
|
|
8
|
+
import s from "@oxc-project/runtime/helpers/decorateMetadata";
|
|
9
9
|
import c from "@oxc-project/runtime/helpers/decorateParam";
|
|
10
10
|
import l from "express";
|
|
11
11
|
//#region app/static-assets.middleware.ts
|
|
@@ -59,10 +59,10 @@ var h = class {
|
|
|
59
59
|
a(0);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
h =
|
|
62
|
+
h = o([
|
|
63
63
|
a(),
|
|
64
64
|
c(1, i(t)),
|
|
65
|
-
|
|
65
|
+
s("design:paramtypes", [typeof (u = n !== void 0 && n) == "function" ? u : Object, typeof (d = e !== void 0 && e) == "function" ? d : Object])
|
|
66
66
|
], h);
|
|
67
67
|
//#endregion
|
|
68
68
|
export { h as StaticAssetsMiddleware };
|