@_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
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { TemplateCoreRuntime } from "../../packages/core/index";
|
|
2
2
|
import type { ComponentType } from "react";
|
|
3
|
-
import type { SSRPageMetaValue, SSRPropsContext } from "./types";
|
|
3
|
+
import type { SSRLayout, SSRPageHeadValue, SSRPageMetaValue, SSRPageResult, SSRPropsContext, SSRResolvedProps } from "./types";
|
|
4
4
|
import type { SSRManifest } from "./manifest";
|
|
5
5
|
import { FrontendDevelopment } from "../frontend-development";
|
|
6
|
-
export type SSRResolvedProps = Record<string, unknown>;
|
|
7
6
|
interface SSRServerModule {
|
|
8
7
|
default: ComponentType<SSRResolvedProps>;
|
|
9
|
-
|
|
8
|
+
layout?: SSRLayout;
|
|
9
|
+
getServerProps?: (context: SSRPropsContext) => SSRPageResult | Promise<SSRPageResult>;
|
|
10
10
|
pageTitle?: SSRPageMetaValue;
|
|
11
11
|
pageDescription?: SSRPageMetaValue;
|
|
12
|
+
pageHead?: SSRPageHeadValue;
|
|
12
13
|
}
|
|
13
14
|
/** Each application keeps its own private bundle and manifest lookup caches. */
|
|
14
15
|
export declare class SSRArtifacts {
|
|
@@ -19,6 +20,8 @@ export declare class SSRArtifacts {
|
|
|
19
20
|
constructor(runtime: TemplateCoreRuntime, development: FrontendDevelopment);
|
|
20
21
|
loadPage(page: string): Promise<SSRServerModule | null>;
|
|
21
22
|
readManifest(): SSRManifest | null;
|
|
23
|
+
/** Read the browser build identity used to reject stale client navigation data. */
|
|
24
|
+
readBuildKey(): string | null;
|
|
22
25
|
private resolvePrivateDirectory;
|
|
23
26
|
private isInside;
|
|
24
27
|
}
|
package/types/app/ssr/html.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StartOptions } from "../../packages/core/index";
|
|
2
|
+
import type { SSRPageHead } from "./types";
|
|
2
3
|
export { escapeHtml, escapeHtmlAttr, serializeForHtmlScript } from "../html/shell";
|
|
3
4
|
type ReactModule = typeof import('react');
|
|
4
5
|
type ReactElement = import('react').ReactElement;
|
|
@@ -8,6 +9,8 @@ export interface SSRHtmlApplication {
|
|
|
8
9
|
options: StartOptions;
|
|
9
10
|
config: {
|
|
10
11
|
signKey?: unknown;
|
|
12
|
+
apiSignVerify?: unknown;
|
|
13
|
+
html?: unknown;
|
|
11
14
|
ssr?: {
|
|
12
15
|
exposeErrorDetails?: boolean;
|
|
13
16
|
};
|
|
@@ -19,6 +22,7 @@ export interface SSRHtmlApplication {
|
|
|
19
22
|
export interface SSRHtmlContext {
|
|
20
23
|
query: Record<string, unknown>;
|
|
21
24
|
projectKey?: string;
|
|
25
|
+
language?: string;
|
|
22
26
|
}
|
|
23
27
|
export interface SSRHtmlShellOptions {
|
|
24
28
|
app: SSRHtmlApplication;
|
|
@@ -26,6 +30,8 @@ export interface SSRHtmlShellOptions {
|
|
|
26
30
|
page: string;
|
|
27
31
|
title: string;
|
|
28
32
|
description?: string;
|
|
33
|
+
head?: SSRPageHead;
|
|
34
|
+
nonce?: string;
|
|
29
35
|
appHtml: string;
|
|
30
36
|
preloadLinks?: string;
|
|
31
37
|
hydrationScript?: string;
|
|
@@ -51,6 +57,7 @@ export interface SSRErrorHtmlOptions {
|
|
|
51
57
|
title: string;
|
|
52
58
|
message: string;
|
|
53
59
|
error?: unknown;
|
|
60
|
+
nonce?: string;
|
|
54
61
|
}
|
|
55
62
|
/**
|
|
56
63
|
* 渲染 SSR 页面 HTML shell 两侧片段,用于流式写入 React app HTML。
|
|
@@ -2,4 +2,4 @@ import type { Response } from "express";
|
|
|
2
2
|
import type { SSRDocument } from "./html";
|
|
3
3
|
import type { SSRRenderSession } from "./session";
|
|
4
4
|
/** React writes to the native response as soon as its shell can be rendered. */
|
|
5
|
-
export declare function streamSSRDocument(document: SSRDocument, response: Response, session: SSRRenderSession, bootstrapModule?: string): Promise<void>;
|
|
5
|
+
export declare function streamSSRDocument(document: SSRDocument, response: Response, session: SSRRenderSession, bootstrapModule?: string, status?: number, nonce?: string): Promise<void>;
|
package/types/app/ssr/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { INestApplication } from "@nestjs/common";
|
|
2
|
+
import type { ComponentType, ReactNode } from "react";
|
|
2
3
|
import type { TemplateCoreHttpContext } from "../http/context";
|
|
4
|
+
export type SSRResolvedProps = Record<string, unknown>;
|
|
3
5
|
export interface SSRPropsContext {
|
|
4
6
|
params: Record<string, string>;
|
|
5
7
|
query: Record<string, unknown>;
|
|
@@ -12,3 +14,57 @@ export interface SSRPageMetaContext<Props = Record<string, unknown>> extends SSR
|
|
|
12
14
|
}
|
|
13
15
|
export type SSRPageMetaResolver<Props = Record<string, unknown>> = (context: SSRPageMetaContext<Props>) => string | null | undefined | Promise<string | null | undefined>;
|
|
14
16
|
export type SSRPageMetaValue<Props = Record<string, unknown>> = string | null | undefined | SSRPageMetaResolver<Props>;
|
|
17
|
+
export interface SSRRedirectResult {
|
|
18
|
+
type: 'redirect';
|
|
19
|
+
redirect: {
|
|
20
|
+
location: string;
|
|
21
|
+
status: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface SSRStatusResult<Props extends SSRResolvedProps = SSRResolvedProps> {
|
|
25
|
+
type: 'status';
|
|
26
|
+
status: number;
|
|
27
|
+
props: Props;
|
|
28
|
+
}
|
|
29
|
+
export type SSRPageResult<Props extends SSRResolvedProps = SSRResolvedProps> = Props | SSRRedirectResult | SSRStatusResult<Props>;
|
|
30
|
+
export interface SSRLayoutProps {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
page: string;
|
|
33
|
+
path: string;
|
|
34
|
+
query: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
export type SSRLayout = ComponentType<SSRLayoutProps>;
|
|
37
|
+
export type SSRPageHeadAttributeValue = string | number | boolean | null | undefined;
|
|
38
|
+
export type SSRPageHeadAttributes = Record<string, SSRPageHeadAttributeValue>;
|
|
39
|
+
export interface SSRPageHead {
|
|
40
|
+
meta?: SSRPageHeadAttributes[];
|
|
41
|
+
link?: SSRPageHeadAttributes[];
|
|
42
|
+
jsonLd?: unknown[];
|
|
43
|
+
}
|
|
44
|
+
/** Metadata and asset identity returned by the SSR data navigation endpoint. */
|
|
45
|
+
export interface SSRPageDataPage<Props extends SSRResolvedProps = SSRResolvedProps> {
|
|
46
|
+
type: 'page';
|
|
47
|
+
page: string;
|
|
48
|
+
props: Props;
|
|
49
|
+
title: string;
|
|
50
|
+
description: string;
|
|
51
|
+
head?: SSRPageHead;
|
|
52
|
+
status: number;
|
|
53
|
+
buildKey: string | null;
|
|
54
|
+
entry: string | null;
|
|
55
|
+
}
|
|
56
|
+
/** A successful navigation response that preserves a non-200 page status. */
|
|
57
|
+
export interface SSRPageDataStatus<Props extends SSRResolvedProps = SSRResolvedProps> extends Omit<SSRPageDataPage<Props>, 'type'> {
|
|
58
|
+
type: 'status';
|
|
59
|
+
}
|
|
60
|
+
/** A navigation response for an SSR redirect returned by the page or middleware. */
|
|
61
|
+
export interface SSRPageDataRedirect {
|
|
62
|
+
type: 'redirect';
|
|
63
|
+
page: string;
|
|
64
|
+
location: string;
|
|
65
|
+
status: number;
|
|
66
|
+
buildKey: string | null;
|
|
67
|
+
}
|
|
68
|
+
export type SSRPageDataResponse<Props extends SSRResolvedProps = SSRResolvedProps> = SSRPageDataPage<Props> | SSRPageDataStatus<Props> | SSRPageDataRedirect;
|
|
69
|
+
export type SSRPageHeadResolver<Props = Record<string, unknown>> = (context: SSRPageMetaContext<Props>) => SSRPageHead | null | undefined | Promise<SSRPageHead | null | undefined>;
|
|
70
|
+
export type SSRPageHeadValue<Props = Record<string, unknown>> = SSRPageHead | null | undefined | SSRPageHeadResolver<Props>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { FSWatcher } from "chokidar";
|
|
2
2
|
import { type ResolveFEOutDirOptions } from "../ssrSharedData/outputPaths";
|
|
3
3
|
import type { SSREntriesConfig, SSREntriesMode } from "./entryCollect";
|
|
4
|
-
|
|
4
|
+
import { type BuildFEOptions } from "./state";
|
|
5
|
+
export interface BuildSSROptions extends ResolveFEOutDirOptions, Pick<BuildFEOptions, 'codeSplitting'> {
|
|
5
6
|
/**
|
|
6
7
|
* Additional or replacement SSR entry map.
|
|
7
8
|
*
|
package/types/bundler/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export { resolveFEOutDir } from "./utils";
|
|
|
7
7
|
export type { FEOutDirOutput, ResolveFEOutDirOptions } from "./utils";
|
|
8
8
|
export { createFrontendDevSession } from "./dev-session";
|
|
9
9
|
export type { CreateFrontendDevSessionOptions, FrontendDevOptions, FrontendDevSession } from "./dev-session";
|
|
10
|
-
export type { BuildFEOptions } from "./state";
|
|
10
|
+
export type { BuildFEOptions, FECodeSplittingGroup, FECodeSplittingOptions } from "./state";
|
|
11
11
|
export type { FEWatchSession } from "./utils";
|
package/types/bundler/state.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { type ResolveFEOutDirOptions } from "../ssrSharedData/outputPaths";
|
|
2
|
+
export interface FECodeSplittingGroup {
|
|
3
|
+
name: string;
|
|
4
|
+
test: (moduleId: string) => boolean;
|
|
5
|
+
maxSize?: number;
|
|
6
|
+
minShareCount?: number;
|
|
7
|
+
priority?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface FECodeSplittingOptions {
|
|
10
|
+
/** Replace the default groups. An empty array disables configured code-splitting groups. */
|
|
11
|
+
groups?: FECodeSplittingGroup[];
|
|
12
|
+
}
|
|
2
13
|
export interface BuildFEOptions extends ResolveFEOutDirOptions {
|
|
3
14
|
/**
|
|
4
15
|
* - frame
|
|
@@ -15,6 +26,8 @@ export interface BuildFEOptions extends ResolveFEOutDirOptions {
|
|
|
15
26
|
* Compress the html content emitted by Vite before writing final `.tpl` / `.html` files.
|
|
16
27
|
*/
|
|
17
28
|
minifyHtml?: boolean;
|
|
29
|
+
/** Frontend output chunking policy. */
|
|
30
|
+
codeSplitting?: FECodeSplittingOptions;
|
|
18
31
|
}
|
|
19
32
|
/** Snapshot options before asynchronous work; no process-global build configuration. */
|
|
20
33
|
export declare function normalizeBuildFEOptions<T extends BuildFEOptions>(options?: T): T & BuildFEOptions;
|
package/types/bundler/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
import { resolveRunPath, type ResolveFEOutDirOptions } from "../ssrSharedData/outputPaths";
|
|
3
|
-
import { type BuildFEOptions } from "./state";
|
|
3
|
+
import { type BuildFEOptions, type FECodeSplittingGroup } from "./state";
|
|
4
4
|
export type { FEOutDirOutput, ResolveFEOutDirOptions } from "../ssrSharedData/outputPaths";
|
|
5
5
|
export { resolveRunPath };
|
|
6
6
|
/**
|
|
@@ -32,19 +32,8 @@ export declare function generateBuildKeyPlugin(options?: BuildFEOptions): Plugin
|
|
|
32
32
|
/**
|
|
33
33
|
* 创建 CSR/SSR 复用的 FE chunk 分组规则。
|
|
34
34
|
*/
|
|
35
|
-
export declare const createFECodeSplittingGroups: () =>
|
|
36
|
-
|
|
37
|
-
test: (moduleId: string) => boolean;
|
|
38
|
-
maxSize: number;
|
|
39
|
-
priority: number;
|
|
40
|
-
minShareCount?: undefined;
|
|
41
|
-
} | {
|
|
42
|
-
name: string;
|
|
43
|
-
test: (moduleId: string) => boolean;
|
|
44
|
-
maxSize: number;
|
|
45
|
-
minShareCount: number;
|
|
46
|
-
priority: number;
|
|
47
|
-
})[];
|
|
35
|
+
export declare const createFECodeSplittingGroups: () => FECodeSplittingGroup[];
|
|
36
|
+
export declare const resolveFECodeSplittingGroups: (options?: BuildFEOptions) => FECodeSplittingGroup[];
|
|
48
37
|
export interface VBuildFEOptions extends BuildFEOptions {
|
|
49
38
|
/**
|
|
50
39
|
* SSR hydration entries to include in the same browser build.
|
|
@@ -22,6 +22,7 @@ export interface DefaultDBConfig {
|
|
|
22
22
|
}
|
|
23
23
|
export interface DefaultAppConfig {
|
|
24
24
|
frameName: string;
|
|
25
|
+
html?: import('../packages/core/index').HtmlShellOptions;
|
|
25
26
|
port?: number;
|
|
26
27
|
host?: string;
|
|
27
28
|
env?: string;
|
|
@@ -33,10 +34,9 @@ export interface DefaultAppConfig {
|
|
|
33
34
|
* SQLite 数据库路径或配置。等价于 db.sqlite。
|
|
34
35
|
*/
|
|
35
36
|
sqlite?: string | DefaultSQLiteConfig;
|
|
37
|
+
/** Server signing key. Only shared mode publishes it to browsers. */
|
|
36
38
|
signKey: string;
|
|
37
|
-
apiSignVerify?:
|
|
38
|
-
whiteList?: string[];
|
|
39
|
-
};
|
|
39
|
+
apiSignVerify?: import('../app/http/api-signing').ApiSignVerifyOptions;
|
|
40
40
|
viewsPath?: string;
|
|
41
41
|
nunjucks?: import('nunjucks').ConfigureOptions;
|
|
42
42
|
notFoundRedirectCount?: number;
|
|
@@ -45,6 +45,10 @@ export interface DefaultAppConfig {
|
|
|
45
45
|
* @default 5 * 60 * 1000
|
|
46
46
|
*/
|
|
47
47
|
resourceCacheTimeMs?: number;
|
|
48
|
+
/** Request-specific head metadata for CSR documents. */
|
|
49
|
+
csr?: {
|
|
50
|
+
head?: import('../app/csr/types').CSRPageHeadResolver;
|
|
51
|
+
};
|
|
48
52
|
/**
|
|
49
53
|
* SSR 运行时配置。
|
|
50
54
|
*/
|
|
@@ -64,6 +68,8 @@ export interface DefaultAppConfig {
|
|
|
64
68
|
* @default 30_000
|
|
65
69
|
*/
|
|
66
70
|
streamTimeoutMs?: number;
|
|
71
|
+
/** Resolve a request-scoped CSP nonce for SSR and CSR inline scripts. */
|
|
72
|
+
cspNonce?: (request: import('express').Request, response: import('express').Response) => string | undefined | Promise<string | undefined>;
|
|
67
73
|
};
|
|
68
74
|
/**
|
|
69
75
|
* 登陆验证相关
|
package/types/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { guardrailBlocked, outputContainsAny, outputNotEmpty, runAssertions, ste
|
|
|
16
16
|
export type { RunAssertionResult, RunAssertionSpec } from "./app/ai/eval/assertions";
|
|
17
17
|
export type { FrameworkLogger } from "./app/extends/logger";
|
|
18
18
|
export type { NodeFetch } from "./app/extends/$fetch";
|
|
19
|
+
export type { HtmlShellOptions, HtmlHeadAttributes, HtmlBodyOptions, HtmlThemeDefault, HtmlThemeOptions, RequestBodyParserErrorCategory, RequestBodyParserMalformedJsonAction, RequestBodyParserMethod, RequestBodyParserOptions, RequestBodyParserRoutePolicy, } from "./packages/core/index";
|
|
20
|
+
export type { CSRPageHead, CSRPageHeadResolver } from "./app/csr/types";
|
|
19
21
|
export type { DB, DBDataOptions, DBDataRecord, DBRunResult, FrameworkDB, ListDBDataOptions, SQLiteParams, SQLiteValue, } from "./app/extends/db";
|
|
20
22
|
export interface StartOptions extends CoreStartOptions {
|
|
21
23
|
/** Explicitly enable same-origin Vite and React Fast Refresh. Off by default. */
|
|
@@ -38,9 +40,10 @@ export { TemplateCoreController } from "./app/http/controller";
|
|
|
38
40
|
export type { TemplateCoreResponseBody, TemplateCoreResponseResult } from "./app/http/response";
|
|
39
41
|
export { TemplateCoreError, createTemplateCoreError } from "./app/http/errors";
|
|
40
42
|
export type { TemplateCoreErrorOptions } from "./app/http/errors";
|
|
43
|
+
export type { ApiSignVerifyOptions } from "./app/http/api-signing";
|
|
41
44
|
export type { TemplateCoreHtmlEtagCache, TemplateCoreTemplateEnvironment, TemplateCoreViewRenderer, } from "./app/providers/csr";
|
|
42
45
|
export { TemplateCoreContext } from "./app/http/context";
|
|
43
46
|
export type { TemplateCoreHttpContext } from "./app/http/context";
|
|
44
47
|
export { RequestSchema, TemplateCoreRequestSchemaPipe } from "./app/http/request-schema.pipe";
|
|
45
48
|
export type { TemplateCoreRequestSchema } from "./app/http/request-schema.pipe";
|
|
46
|
-
export type {
|
|
49
|
+
export type { SSRPageDataPage, SSRPageDataRedirect, SSRPageDataResponse, SSRPageDataStatus, SSRPageHead, SSRPageHeadAttributes, SSRPageHeadResolver, SSRPageHeadValue, SSRLayout, SSRLayoutProps, SSRPageMetaContext, SSRPageMetaResolver, SSRPageMetaValue, SSRPageResult, SSRPropsContext, SSRRedirectResult, SSRResolvedProps, SSRStatusResult, } from "./app/ssr/types";
|
|
@@ -29,6 +29,19 @@ export interface SSRPageMeta {
|
|
|
29
29
|
renderedAt: number;
|
|
30
30
|
/** 请求路径 */
|
|
31
31
|
pathname: string;
|
|
32
|
+
/** SSR page name used by the client navigation runtime. */
|
|
33
|
+
page?: string;
|
|
34
|
+
/** Current browser bundle identity used to detect stale navigation data. */
|
|
35
|
+
buildKey?: string | null;
|
|
36
|
+
/** Current SSR hydration entry URL, when one is available. */
|
|
37
|
+
entry?: string | null;
|
|
38
|
+
/** Page-owned head entries used to reconcile metadata during navigation. */
|
|
39
|
+
head?: SSRHydrationHead;
|
|
40
|
+
}
|
|
41
|
+
export interface SSRHydrationHead {
|
|
42
|
+
meta?: Record<string, string | number | boolean | null | undefined>[];
|
|
43
|
+
link?: Record<string, string | number | boolean | null | undefined>[];
|
|
44
|
+
jsonLd?: unknown[];
|
|
32
45
|
}
|
|
33
46
|
/**
|
|
34
47
|
* 全局注水数据的 key
|
|
@@ -2,7 +2,7 @@ export { start } from "./bootstrap";
|
|
|
2
2
|
export { ConfigService } from "./config-service";
|
|
3
3
|
export { normalizeRouteBasePath } from "./paths";
|
|
4
4
|
export { closeStartupResources, assertStartupResourcesOpen, resolveStartupOptions, StartupConfiguration, TemplateCoreRuntime, trackStartupPromise, trackStartupResource, runStartupFactory, } from "./startup";
|
|
5
|
-
export type { ProviderOverride, ResolvedApplicationOptions, StartOptions } from "./startup";
|
|
5
|
+
export type { ProviderOverride, RequestBodyParserErrorCategory, RequestBodyParserMalformedJsonAction, RequestBodyParserMethod, RequestBodyParserOptions, RequestBodyParserRoutePolicy, ResolvedApplicationOptions, StartOptions, HtmlHeadAttributes, HtmlBodyOptions, HtmlShellOptions, HtmlThemeDefault, HtmlThemeOptions, } from "./startup";
|
|
6
6
|
export * from "./tokens";
|
|
7
7
|
export { default as loaderModel } from "./loader/model";
|
|
8
8
|
export type { ModelConfig, ModelItem, ModelLoaderOptions } from "./loader/model";
|
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
import type { ClassProvider, DynamicModule, ExistingProvider, FactoryProvider, INestApplication, Type, ValueProvider } from "@nestjs/common";
|
|
2
2
|
export type ProviderOverride = ValueProvider | ClassProvider | FactoryProvider | ExistingProvider;
|
|
3
|
+
export type RequestBodyParserMethod = 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE';
|
|
4
|
+
export type RequestBodyParserErrorCategory = 'malformed-json' | 'body-size' | 'other';
|
|
5
|
+
export type RequestBodyParserMalformedJsonAction = 'status-500-empty';
|
|
6
|
+
export interface RequestBodyParserRoutePolicy {
|
|
7
|
+
method: RequestBodyParserMethod;
|
|
8
|
+
path: string;
|
|
9
|
+
onMalformedJson: RequestBodyParserMalformedJsonAction;
|
|
10
|
+
}
|
|
11
|
+
export interface RequestBodyParserOptions {
|
|
12
|
+
policies?: RequestBodyParserRoutePolicy[];
|
|
13
|
+
}
|
|
14
|
+
export type HtmlThemeDefault = 'light' | 'dark' | 'system';
|
|
15
|
+
export interface HtmlThemeOptions {
|
|
16
|
+
/** Initial theme mode. Defaults to `dark` for compatibility. */
|
|
17
|
+
default?: HtmlThemeDefault;
|
|
18
|
+
/** localStorage key used by the shell theme bootstrap. Defaults to `tc_theme`. */
|
|
19
|
+
storageKey?: string;
|
|
20
|
+
/** Dot-separated path for structured JSON storage values, such as `state.theme`. */
|
|
21
|
+
storageValuePath?: string;
|
|
22
|
+
}
|
|
23
|
+
export type HtmlHeadAttributes = Record<string, unknown>;
|
|
24
|
+
export interface HtmlBodyOptions {
|
|
25
|
+
class?: string;
|
|
26
|
+
style?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface HtmlShellOptions {
|
|
29
|
+
/** Document language. When omitted, the request language is used. */
|
|
30
|
+
lang?: string;
|
|
31
|
+
theme?: HtmlThemeOptions;
|
|
32
|
+
/** Viewport meta content. Defaults to `width=device-width, initial-scale=1.0`. */
|
|
33
|
+
viewportContent?: string;
|
|
34
|
+
/** Additional default meta tags shared by SSR and CSR documents. */
|
|
35
|
+
meta?: HtmlHeadAttributes[];
|
|
36
|
+
/** Additional default link tags shared by SSR and CSR documents. */
|
|
37
|
+
link?: HtmlHeadAttributes[];
|
|
38
|
+
/** Attributes added to the document body. */
|
|
39
|
+
body?: HtmlBodyOptions;
|
|
40
|
+
}
|
|
3
41
|
export declare function trackStartupResource<T>(startup: StartupConfiguration, value: T): T;
|
|
4
42
|
export declare function trackStartupPromise(startup: StartupConfiguration, value: Promise<unknown>): Promise<unknown>;
|
|
5
43
|
export declare function assertStartupResourcesOpen(startup: StartupConfiguration): void;
|
|
@@ -18,10 +56,13 @@ export interface StartOptions {
|
|
|
18
56
|
additionalPublicPaths?: string | string[];
|
|
19
57
|
/** Built-in API and request-policy prefix. Defaults to `/api`. */
|
|
20
58
|
apiPrefix?: string;
|
|
59
|
+
requestBodyParser?: RequestBodyParserOptions;
|
|
21
60
|
/** CSR page prefix. Defaults to `/`. */
|
|
22
61
|
pageBasePath?: string;
|
|
23
62
|
/** SSR page prefix. Defaults to `/fessr`. */
|
|
24
63
|
ssrPageBasePath?: string;
|
|
64
|
+
/** Shared SSR/CSR document shell configuration. */
|
|
65
|
+
html?: HtmlShellOptions;
|
|
25
66
|
/** Explicit business Nest modules; omitted or empty registers framework features only. */
|
|
26
67
|
businessModules?: Array<Type<unknown> | DynamicModule>;
|
|
27
68
|
/** Replacements for the documented mutable foundation tokens. */
|