@pactor-app/runtime 0.1.0 → 1.1.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.
- package/dist/index.cjs +402 -40
- package/dist/index.d.cts +92 -27
- package/dist/index.d.ts +92 -27
- package/dist/index.js +384 -24
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PermissionConfig, Registry, ActionConfig, DataSourceConfig, PageMeta, I18nContext,
|
|
1
|
+
import { PermissionConfig, Registry, ActionConfig, DataSourceConfig, DslSourceRef, PageMeta, DslNode, I18nContext, DslChildren, PageDsl, LifecycleEventName } from '@pactor-app/core';
|
|
2
2
|
import { ExpressionScope } from '@pactor-app/expression';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { ReactNode, ComponentType } from 'react';
|
|
5
5
|
import { DslValidationError } from '@pactor-app/schema';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -125,6 +125,11 @@ declare class DataStore {
|
|
|
125
125
|
getData(name: string): unknown;
|
|
126
126
|
/** 各数据源当前数据,供表达式作用域的 `data` 键使用 */
|
|
127
127
|
getAllData(): Record<string, unknown>;
|
|
128
|
+
/** 各数据源的加载状态(loading / error),供表达式作用域的 `dataStatus` 键使用 */
|
|
129
|
+
getAllStatus(): Record<string, {
|
|
130
|
+
loading: boolean;
|
|
131
|
+
error?: Error;
|
|
132
|
+
}>;
|
|
128
133
|
subscribe(listener: () => void): () => void;
|
|
129
134
|
/** 版本号,供 `useSyncExternalStore` 的 getSnapshot 使用 */
|
|
130
135
|
getVersion(): number;
|
|
@@ -147,6 +152,29 @@ declare class DataStore {
|
|
|
147
152
|
private update;
|
|
148
153
|
}
|
|
149
154
|
|
|
155
|
+
interface DslSourceResolverDeps {
|
|
156
|
+
services: ServiceRegistry;
|
|
157
|
+
http: HttpAdapter;
|
|
158
|
+
/** 加载前取当前表达式作用域(params 求值用) */
|
|
159
|
+
getScope: () => ExpressionScope;
|
|
160
|
+
}
|
|
161
|
+
/** 缓存 key:按固定字段序拼接引用原文(避免字段顺序差异导致重复请求) */
|
|
162
|
+
declare function dslSourceKey(ref: DslSourceRef): string;
|
|
163
|
+
/**
|
|
164
|
+
* DslSourceResolver(spec: dsl-renderer 动态引用解析):
|
|
165
|
+
* 按 `source.type` 分派——service 经 ServiceRegistry、http 经 HttpAdapter;
|
|
166
|
+
* `params` 表达式按**首次解析时**作用域求值一次(不做联动重载)。
|
|
167
|
+
* 结果按引用原文缓存于页面运行时生命周期(Promise 级去重:并发渲染
|
|
168
|
+
* 同一引用共享一次请求;失败同样缓存,随运行时销毁清理)。
|
|
169
|
+
*/
|
|
170
|
+
declare class DslSourceResolver {
|
|
171
|
+
private readonly deps;
|
|
172
|
+
private readonly cache;
|
|
173
|
+
constructor(deps: DslSourceResolverDeps);
|
|
174
|
+
resolve(ref: DslSourceRef): Promise<unknown>;
|
|
175
|
+
private load;
|
|
176
|
+
}
|
|
177
|
+
|
|
150
178
|
/**
|
|
151
179
|
* StateStore:框架无关的最小状态容器(设计文档第 15 节,决策 D1)。
|
|
152
180
|
*
|
|
@@ -235,10 +263,22 @@ interface RuntimeContext {
|
|
|
235
263
|
* destroy 时清理。
|
|
236
264
|
*/
|
|
237
265
|
actionResults: Record<string, unknown>;
|
|
266
|
+
/**
|
|
267
|
+
* 页面级命名动作定义(PageDsl.actions):动作名 → 单个或多个动作,
|
|
268
|
+
* 供内置 `call` 动作按名引用复用;缺省为空对象
|
|
269
|
+
*/
|
|
270
|
+
namedActions: Record<string, ActionConfig | ActionConfig[]>;
|
|
271
|
+
/**
|
|
272
|
+
* 页面级命名组件定义(PageDsl.components):组件名 → DslNode 子树
|
|
273
|
+
* 或 DslSourceRef 动态引用,供 `component` 引用节点按名渲染;缺省为空对象
|
|
274
|
+
*/
|
|
275
|
+
pageComponents: Record<string, DslNode | DslSourceRef>;
|
|
238
276
|
permission: PermissionAdapter;
|
|
239
277
|
capabilities: CapabilityRegistry;
|
|
240
278
|
/** HTTP 出口适配器(DataSource / request 动作共用) */
|
|
241
279
|
http: HttpAdapter;
|
|
280
|
+
/** 动态 DSL 引用解析器(service/http 分派 + 页面级缓存) */
|
|
281
|
+
dslSources: DslSourceResolver;
|
|
242
282
|
/** 当前语言代码(如 'zh-CN') */
|
|
243
283
|
locale: string;
|
|
244
284
|
/** i18n 上下文:提供 `t(key, params?)` 翻译函数 */
|
|
@@ -250,6 +290,10 @@ interface CreateRuntimeContextOptions {
|
|
|
250
290
|
/** 页面初始 state */
|
|
251
291
|
state?: Record<string, unknown>;
|
|
252
292
|
dataSources?: Record<string, DataSourceConfig>;
|
|
293
|
+
/** 页面级命名动作定义(PageDsl.actions),供 `call` 动作按名引用 */
|
|
294
|
+
namedActions?: Record<string, ActionConfig | ActionConfig[]>;
|
|
295
|
+
/** 页面级命名组件定义(PageDsl.components),供 `component` 引用节点按名渲染 */
|
|
296
|
+
pageComponents?: Record<string, DslNode | DslSourceRef>;
|
|
253
297
|
route?: {
|
|
254
298
|
params?: Record<string, unknown>;
|
|
255
299
|
query?: Record<string, unknown>;
|
|
@@ -285,6 +329,7 @@ type LocalScope = ExpressionScope;
|
|
|
285
329
|
* 组装表达式求值作用域(设计文档第 15、16 节,决策 D2):
|
|
286
330
|
*
|
|
287
331
|
* - `state` / `data` 取 Store 当前值快照
|
|
332
|
+
* - `dataStatus` 为各数据源的 `{ loading, error }` 状态(加载态/错误态展示用)
|
|
288
333
|
* - `form` 为 state 的 `form` 路径别名(Form 提交写入 `state.form`,
|
|
289
334
|
* 使 `${form.<field>}` 可用,设计文档第 15 节 form 作用域层级)
|
|
290
335
|
* - 另含 `app` / `page` / `route` / `user` / `params`(route.params 的别名)
|
|
@@ -307,6 +352,32 @@ declare function useI18n(): I18nContext;
|
|
|
307
352
|
*/
|
|
308
353
|
declare function registerBuiltinActions(registry: ActionRegistry): void;
|
|
309
354
|
|
|
355
|
+
/** Renderer 经 React Context 透传给被渲染组件的能力 */
|
|
356
|
+
interface RendererContextValue {
|
|
357
|
+
context: RuntimeContext;
|
|
358
|
+
engine: ActionEngine;
|
|
359
|
+
/** 当前局部作用域(row / rowIndex / event / item 等) */
|
|
360
|
+
scope: ExpressionScope;
|
|
361
|
+
/** 内部:命名组件引用链(PageDsl.components 的循环引用守卫) */
|
|
362
|
+
referenceStack?: string[];
|
|
363
|
+
/**
|
|
364
|
+
* 渲染 DSL 子节点(内联数组或 DslSourceRef 动态引用——引用形态经
|
|
365
|
+
* DslSourceBoundary 异步解析渲染);`extraScope` 注入的局部作用域
|
|
366
|
+
* 覆盖同名全局键,且仅作用于该子树(Table 行、Repeat 项等场景,
|
|
367
|
+
* 设计文档第 21 节)。
|
|
368
|
+
*/
|
|
369
|
+
renderChildren(children: DslChildren | undefined, extraScope?: ExpressionScope): ReactNode;
|
|
370
|
+
}
|
|
371
|
+
/** 在被渲染组件内获取 Renderer 能力(renderChildren / engine / context) */
|
|
372
|
+
declare function useRenderer(): RendererContextValue;
|
|
373
|
+
/**
|
|
374
|
+
* 订阅 StateStore(决策 D5)。`path` 为点路径;缺省返回整个 state。
|
|
375
|
+
* 基于 `useSyncExternalStore`,state 变化时组件重渲染。
|
|
376
|
+
*/
|
|
377
|
+
declare function useRuntimeState<T = unknown>(path?: string): T;
|
|
378
|
+
/** 订阅指定数据源的 `{ loading, error, data }` 状态 */
|
|
379
|
+
declare function useDataSource(name: string): DataSourceStatus;
|
|
380
|
+
|
|
310
381
|
type AnyComponent = ComponentType<any>;
|
|
311
382
|
/**
|
|
312
383
|
* 组件注册条目:直接注册组件,或以 `{ component, withScope: true }`
|
|
@@ -341,28 +412,6 @@ interface DslRendererProps {
|
|
|
341
412
|
*/
|
|
342
413
|
declare function DslRenderer({ context, node, engine, children }: DslRendererProps): react.JSX.Element;
|
|
343
414
|
|
|
344
|
-
/** Renderer 经 React Context 透传给被渲染组件的能力 */
|
|
345
|
-
interface RendererContextValue {
|
|
346
|
-
context: RuntimeContext;
|
|
347
|
-
engine: ActionEngine;
|
|
348
|
-
/** 当前局部作用域(row / rowIndex / event / item 等) */
|
|
349
|
-
scope: ExpressionScope;
|
|
350
|
-
/**
|
|
351
|
-
* 渲染 DSL 子节点;`extraScope` 注入的局部作用域覆盖同名全局键,
|
|
352
|
-
* 且仅作用于该子树(Table 行、Repeat 项等场景,设计文档第 21 节)。
|
|
353
|
-
*/
|
|
354
|
-
renderChildren(children: DslNode[] | undefined, extraScope?: ExpressionScope): ReactNode;
|
|
355
|
-
}
|
|
356
|
-
/** 在被渲染组件内获取 Renderer 能力(renderChildren / engine / context) */
|
|
357
|
-
declare function useRenderer(): RendererContextValue;
|
|
358
|
-
/**
|
|
359
|
-
* 订阅 StateStore(决策 D5)。`path` 为点路径;缺省返回整个 state。
|
|
360
|
-
* 基于 `useSyncExternalStore`,state 变化时组件重渲染。
|
|
361
|
-
*/
|
|
362
|
-
declare function useRuntimeState<T = unknown>(path?: string): T;
|
|
363
|
-
/** 订阅指定数据源的 `{ loading, error, data }` 状态 */
|
|
364
|
-
declare function useDataSource(name: string): DataSourceStatus;
|
|
365
|
-
|
|
366
415
|
/**
|
|
367
416
|
* 未注册组件的占位渲染(决策 D5):展示类型名,dev 友好,
|
|
368
417
|
* 不抛错也不渲染空白。
|
|
@@ -371,6 +420,22 @@ declare function UnsupportedComponent({ type }: {
|
|
|
371
420
|
type: string;
|
|
372
421
|
}): react.JSX.Element;
|
|
373
422
|
|
|
423
|
+
interface DslSourceBoundaryProps {
|
|
424
|
+
context: RuntimeContext;
|
|
425
|
+
sourceRef: DslSourceRef;
|
|
426
|
+
/** 解析中渲染的内容(调用方预渲染 placeholder 子树;缺省为空) */
|
|
427
|
+
placeholder?: ReactNode;
|
|
428
|
+
/** 渲染解析结果(调用方负责形态校验与降级) */
|
|
429
|
+
children: (content: unknown) => ReactNode;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* 动态 DSL 引用渲染边界(spec: dsl-renderer,renderer 内部组件,
|
|
433
|
+
* 非 DSL 组件类型):解析中渲染 placeholder(缺省空)、成功交给
|
|
434
|
+
* 调用方渲染、失败告警并渲染空——MUST NOT 抛错击穿渲染层。
|
|
435
|
+
* 解析经 `context.dslSources`(Promise 级缓存去重)。
|
|
436
|
+
*/
|
|
437
|
+
declare function DslSourceBoundary({ context, sourceRef, placeholder, children, }: DslSourceBoundaryProps): react.JSX.Element | null;
|
|
438
|
+
|
|
374
439
|
/** Page DSL 校验失败错误:内含结构化错误列表 */
|
|
375
440
|
declare class PageRuntimeError extends Error {
|
|
376
441
|
readonly errors: DslValidationError[];
|
|
@@ -389,7 +454,7 @@ interface PageRuntime {
|
|
|
389
454
|
readonly initialized: Promise<void>;
|
|
390
455
|
/** 是否已销毁 */
|
|
391
456
|
readonly destroyed: boolean;
|
|
392
|
-
/** 渲染 body
|
|
457
|
+
/** 渲染 UI 树根(body 或根级 children);两者皆无时渲染空内容 */
|
|
393
458
|
render(): ReactNode;
|
|
394
459
|
/** 宿主(Router)触发生命周期:onReady */
|
|
395
460
|
ready(): Promise<void>;
|
|
@@ -423,7 +488,7 @@ declare function createPageRuntime(pageDsl: PageDsl, options?: CreateRuntimeCont
|
|
|
423
488
|
declare function PageRuntimeView({ runtime, children, }: {
|
|
424
489
|
runtime: PageRuntime;
|
|
425
490
|
children?: ReactNode;
|
|
426
|
-
}):
|
|
491
|
+
}): ReactNode;
|
|
427
492
|
|
|
428
493
|
interface ResolveDeepOptions {
|
|
429
494
|
/**
|
|
@@ -444,4 +509,4 @@ interface ResolveDeepOptions {
|
|
|
444
509
|
*/
|
|
445
510
|
declare function resolveDeep(value: unknown, scope: ExpressionScope, options?: ResolveDeepOptions): unknown;
|
|
446
511
|
|
|
447
|
-
export { type ActionContext, ActionEngine, type ActionHandler, type ActionRegistry, type ActionResult, type CapabilityRegistry, type ComponentEntry, type ComponentRegistry, type CreateRuntimeContextOptions, type DataSourceStatus, DataStore, type DataStoreDeps, DslRenderer, type DslRendererProps, type FormHandle, type FormRegistry, type HttpAdapter, type HttpRequestConfig, I18nContextProvider, type LocalScope, type PageRuntime, PageRuntimeError, PageRuntimeView, type PermissionAdapter, type RendererContextValue, type RouteContext, type RouterAdapter, type RuntimeContext, type ScopedComponentEntry, type ServiceHandler, type ServiceRegistry, StateStore, UnsupportedComponent, buildScope, createDefaultPermissionAdapter, createDefaultRouterAdapter, createFetchHttpAdapter, createPageRuntime, createRuntimeContext, registerBuiltinActions, resolveDeep, useDataSource, useI18n, useRenderer, useRuntimeState };
|
|
512
|
+
export { type ActionContext, ActionEngine, type ActionHandler, type ActionRegistry, type ActionResult, type CapabilityRegistry, type ComponentEntry, type ComponentRegistry, type CreateRuntimeContextOptions, type DataSourceStatus, DataStore, type DataStoreDeps, DslRenderer, type DslRendererProps, DslSourceBoundary, type DslSourceBoundaryProps, DslSourceResolver, type DslSourceResolverDeps, type FormHandle, type FormRegistry, type HttpAdapter, type HttpRequestConfig, I18nContextProvider, type LocalScope, type PageRuntime, PageRuntimeError, PageRuntimeView, type PermissionAdapter, type RendererContextValue, type RouteContext, type RouterAdapter, type RuntimeContext, type ScopedComponentEntry, type ServiceHandler, type ServiceRegistry, StateStore, UnsupportedComponent, buildScope, createDefaultPermissionAdapter, createDefaultRouterAdapter, createFetchHttpAdapter, createPageRuntime, createRuntimeContext, dslSourceKey, registerBuiltinActions, resolveDeep, useDataSource, useI18n, useRenderer, useRuntimeState };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PermissionConfig, Registry, ActionConfig, DataSourceConfig, PageMeta, I18nContext,
|
|
1
|
+
import { PermissionConfig, Registry, ActionConfig, DataSourceConfig, DslSourceRef, PageMeta, DslNode, I18nContext, DslChildren, PageDsl, LifecycleEventName } from '@pactor-app/core';
|
|
2
2
|
import { ExpressionScope } from '@pactor-app/expression';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { ReactNode, ComponentType } from 'react';
|
|
5
5
|
import { DslValidationError } from '@pactor-app/schema';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -125,6 +125,11 @@ declare class DataStore {
|
|
|
125
125
|
getData(name: string): unknown;
|
|
126
126
|
/** 各数据源当前数据,供表达式作用域的 `data` 键使用 */
|
|
127
127
|
getAllData(): Record<string, unknown>;
|
|
128
|
+
/** 各数据源的加载状态(loading / error),供表达式作用域的 `dataStatus` 键使用 */
|
|
129
|
+
getAllStatus(): Record<string, {
|
|
130
|
+
loading: boolean;
|
|
131
|
+
error?: Error;
|
|
132
|
+
}>;
|
|
128
133
|
subscribe(listener: () => void): () => void;
|
|
129
134
|
/** 版本号,供 `useSyncExternalStore` 的 getSnapshot 使用 */
|
|
130
135
|
getVersion(): number;
|
|
@@ -147,6 +152,29 @@ declare class DataStore {
|
|
|
147
152
|
private update;
|
|
148
153
|
}
|
|
149
154
|
|
|
155
|
+
interface DslSourceResolverDeps {
|
|
156
|
+
services: ServiceRegistry;
|
|
157
|
+
http: HttpAdapter;
|
|
158
|
+
/** 加载前取当前表达式作用域(params 求值用) */
|
|
159
|
+
getScope: () => ExpressionScope;
|
|
160
|
+
}
|
|
161
|
+
/** 缓存 key:按固定字段序拼接引用原文(避免字段顺序差异导致重复请求) */
|
|
162
|
+
declare function dslSourceKey(ref: DslSourceRef): string;
|
|
163
|
+
/**
|
|
164
|
+
* DslSourceResolver(spec: dsl-renderer 动态引用解析):
|
|
165
|
+
* 按 `source.type` 分派——service 经 ServiceRegistry、http 经 HttpAdapter;
|
|
166
|
+
* `params` 表达式按**首次解析时**作用域求值一次(不做联动重载)。
|
|
167
|
+
* 结果按引用原文缓存于页面运行时生命周期(Promise 级去重:并发渲染
|
|
168
|
+
* 同一引用共享一次请求;失败同样缓存,随运行时销毁清理)。
|
|
169
|
+
*/
|
|
170
|
+
declare class DslSourceResolver {
|
|
171
|
+
private readonly deps;
|
|
172
|
+
private readonly cache;
|
|
173
|
+
constructor(deps: DslSourceResolverDeps);
|
|
174
|
+
resolve(ref: DslSourceRef): Promise<unknown>;
|
|
175
|
+
private load;
|
|
176
|
+
}
|
|
177
|
+
|
|
150
178
|
/**
|
|
151
179
|
* StateStore:框架无关的最小状态容器(设计文档第 15 节,决策 D1)。
|
|
152
180
|
*
|
|
@@ -235,10 +263,22 @@ interface RuntimeContext {
|
|
|
235
263
|
* destroy 时清理。
|
|
236
264
|
*/
|
|
237
265
|
actionResults: Record<string, unknown>;
|
|
266
|
+
/**
|
|
267
|
+
* 页面级命名动作定义(PageDsl.actions):动作名 → 单个或多个动作,
|
|
268
|
+
* 供内置 `call` 动作按名引用复用;缺省为空对象
|
|
269
|
+
*/
|
|
270
|
+
namedActions: Record<string, ActionConfig | ActionConfig[]>;
|
|
271
|
+
/**
|
|
272
|
+
* 页面级命名组件定义(PageDsl.components):组件名 → DslNode 子树
|
|
273
|
+
* 或 DslSourceRef 动态引用,供 `component` 引用节点按名渲染;缺省为空对象
|
|
274
|
+
*/
|
|
275
|
+
pageComponents: Record<string, DslNode | DslSourceRef>;
|
|
238
276
|
permission: PermissionAdapter;
|
|
239
277
|
capabilities: CapabilityRegistry;
|
|
240
278
|
/** HTTP 出口适配器(DataSource / request 动作共用) */
|
|
241
279
|
http: HttpAdapter;
|
|
280
|
+
/** 动态 DSL 引用解析器(service/http 分派 + 页面级缓存) */
|
|
281
|
+
dslSources: DslSourceResolver;
|
|
242
282
|
/** 当前语言代码(如 'zh-CN') */
|
|
243
283
|
locale: string;
|
|
244
284
|
/** i18n 上下文:提供 `t(key, params?)` 翻译函数 */
|
|
@@ -250,6 +290,10 @@ interface CreateRuntimeContextOptions {
|
|
|
250
290
|
/** 页面初始 state */
|
|
251
291
|
state?: Record<string, unknown>;
|
|
252
292
|
dataSources?: Record<string, DataSourceConfig>;
|
|
293
|
+
/** 页面级命名动作定义(PageDsl.actions),供 `call` 动作按名引用 */
|
|
294
|
+
namedActions?: Record<string, ActionConfig | ActionConfig[]>;
|
|
295
|
+
/** 页面级命名组件定义(PageDsl.components),供 `component` 引用节点按名渲染 */
|
|
296
|
+
pageComponents?: Record<string, DslNode | DslSourceRef>;
|
|
253
297
|
route?: {
|
|
254
298
|
params?: Record<string, unknown>;
|
|
255
299
|
query?: Record<string, unknown>;
|
|
@@ -285,6 +329,7 @@ type LocalScope = ExpressionScope;
|
|
|
285
329
|
* 组装表达式求值作用域(设计文档第 15、16 节,决策 D2):
|
|
286
330
|
*
|
|
287
331
|
* - `state` / `data` 取 Store 当前值快照
|
|
332
|
+
* - `dataStatus` 为各数据源的 `{ loading, error }` 状态(加载态/错误态展示用)
|
|
288
333
|
* - `form` 为 state 的 `form` 路径别名(Form 提交写入 `state.form`,
|
|
289
334
|
* 使 `${form.<field>}` 可用,设计文档第 15 节 form 作用域层级)
|
|
290
335
|
* - 另含 `app` / `page` / `route` / `user` / `params`(route.params 的别名)
|
|
@@ -307,6 +352,32 @@ declare function useI18n(): I18nContext;
|
|
|
307
352
|
*/
|
|
308
353
|
declare function registerBuiltinActions(registry: ActionRegistry): void;
|
|
309
354
|
|
|
355
|
+
/** Renderer 经 React Context 透传给被渲染组件的能力 */
|
|
356
|
+
interface RendererContextValue {
|
|
357
|
+
context: RuntimeContext;
|
|
358
|
+
engine: ActionEngine;
|
|
359
|
+
/** 当前局部作用域(row / rowIndex / event / item 等) */
|
|
360
|
+
scope: ExpressionScope;
|
|
361
|
+
/** 内部:命名组件引用链(PageDsl.components 的循环引用守卫) */
|
|
362
|
+
referenceStack?: string[];
|
|
363
|
+
/**
|
|
364
|
+
* 渲染 DSL 子节点(内联数组或 DslSourceRef 动态引用——引用形态经
|
|
365
|
+
* DslSourceBoundary 异步解析渲染);`extraScope` 注入的局部作用域
|
|
366
|
+
* 覆盖同名全局键,且仅作用于该子树(Table 行、Repeat 项等场景,
|
|
367
|
+
* 设计文档第 21 节)。
|
|
368
|
+
*/
|
|
369
|
+
renderChildren(children: DslChildren | undefined, extraScope?: ExpressionScope): ReactNode;
|
|
370
|
+
}
|
|
371
|
+
/** 在被渲染组件内获取 Renderer 能力(renderChildren / engine / context) */
|
|
372
|
+
declare function useRenderer(): RendererContextValue;
|
|
373
|
+
/**
|
|
374
|
+
* 订阅 StateStore(决策 D5)。`path` 为点路径;缺省返回整个 state。
|
|
375
|
+
* 基于 `useSyncExternalStore`,state 变化时组件重渲染。
|
|
376
|
+
*/
|
|
377
|
+
declare function useRuntimeState<T = unknown>(path?: string): T;
|
|
378
|
+
/** 订阅指定数据源的 `{ loading, error, data }` 状态 */
|
|
379
|
+
declare function useDataSource(name: string): DataSourceStatus;
|
|
380
|
+
|
|
310
381
|
type AnyComponent = ComponentType<any>;
|
|
311
382
|
/**
|
|
312
383
|
* 组件注册条目:直接注册组件,或以 `{ component, withScope: true }`
|
|
@@ -341,28 +412,6 @@ interface DslRendererProps {
|
|
|
341
412
|
*/
|
|
342
413
|
declare function DslRenderer({ context, node, engine, children }: DslRendererProps): react.JSX.Element;
|
|
343
414
|
|
|
344
|
-
/** Renderer 经 React Context 透传给被渲染组件的能力 */
|
|
345
|
-
interface RendererContextValue {
|
|
346
|
-
context: RuntimeContext;
|
|
347
|
-
engine: ActionEngine;
|
|
348
|
-
/** 当前局部作用域(row / rowIndex / event / item 等) */
|
|
349
|
-
scope: ExpressionScope;
|
|
350
|
-
/**
|
|
351
|
-
* 渲染 DSL 子节点;`extraScope` 注入的局部作用域覆盖同名全局键,
|
|
352
|
-
* 且仅作用于该子树(Table 行、Repeat 项等场景,设计文档第 21 节)。
|
|
353
|
-
*/
|
|
354
|
-
renderChildren(children: DslNode[] | undefined, extraScope?: ExpressionScope): ReactNode;
|
|
355
|
-
}
|
|
356
|
-
/** 在被渲染组件内获取 Renderer 能力(renderChildren / engine / context) */
|
|
357
|
-
declare function useRenderer(): RendererContextValue;
|
|
358
|
-
/**
|
|
359
|
-
* 订阅 StateStore(决策 D5)。`path` 为点路径;缺省返回整个 state。
|
|
360
|
-
* 基于 `useSyncExternalStore`,state 变化时组件重渲染。
|
|
361
|
-
*/
|
|
362
|
-
declare function useRuntimeState<T = unknown>(path?: string): T;
|
|
363
|
-
/** 订阅指定数据源的 `{ loading, error, data }` 状态 */
|
|
364
|
-
declare function useDataSource(name: string): DataSourceStatus;
|
|
365
|
-
|
|
366
415
|
/**
|
|
367
416
|
* 未注册组件的占位渲染(决策 D5):展示类型名,dev 友好,
|
|
368
417
|
* 不抛错也不渲染空白。
|
|
@@ -371,6 +420,22 @@ declare function UnsupportedComponent({ type }: {
|
|
|
371
420
|
type: string;
|
|
372
421
|
}): react.JSX.Element;
|
|
373
422
|
|
|
423
|
+
interface DslSourceBoundaryProps {
|
|
424
|
+
context: RuntimeContext;
|
|
425
|
+
sourceRef: DslSourceRef;
|
|
426
|
+
/** 解析中渲染的内容(调用方预渲染 placeholder 子树;缺省为空) */
|
|
427
|
+
placeholder?: ReactNode;
|
|
428
|
+
/** 渲染解析结果(调用方负责形态校验与降级) */
|
|
429
|
+
children: (content: unknown) => ReactNode;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* 动态 DSL 引用渲染边界(spec: dsl-renderer,renderer 内部组件,
|
|
433
|
+
* 非 DSL 组件类型):解析中渲染 placeholder(缺省空)、成功交给
|
|
434
|
+
* 调用方渲染、失败告警并渲染空——MUST NOT 抛错击穿渲染层。
|
|
435
|
+
* 解析经 `context.dslSources`(Promise 级缓存去重)。
|
|
436
|
+
*/
|
|
437
|
+
declare function DslSourceBoundary({ context, sourceRef, placeholder, children, }: DslSourceBoundaryProps): react.JSX.Element | null;
|
|
438
|
+
|
|
374
439
|
/** Page DSL 校验失败错误:内含结构化错误列表 */
|
|
375
440
|
declare class PageRuntimeError extends Error {
|
|
376
441
|
readonly errors: DslValidationError[];
|
|
@@ -389,7 +454,7 @@ interface PageRuntime {
|
|
|
389
454
|
readonly initialized: Promise<void>;
|
|
390
455
|
/** 是否已销毁 */
|
|
391
456
|
readonly destroyed: boolean;
|
|
392
|
-
/** 渲染 body
|
|
457
|
+
/** 渲染 UI 树根(body 或根级 children);两者皆无时渲染空内容 */
|
|
393
458
|
render(): ReactNode;
|
|
394
459
|
/** 宿主(Router)触发生命周期:onReady */
|
|
395
460
|
ready(): Promise<void>;
|
|
@@ -423,7 +488,7 @@ declare function createPageRuntime(pageDsl: PageDsl, options?: CreateRuntimeCont
|
|
|
423
488
|
declare function PageRuntimeView({ runtime, children, }: {
|
|
424
489
|
runtime: PageRuntime;
|
|
425
490
|
children?: ReactNode;
|
|
426
|
-
}):
|
|
491
|
+
}): ReactNode;
|
|
427
492
|
|
|
428
493
|
interface ResolveDeepOptions {
|
|
429
494
|
/**
|
|
@@ -444,4 +509,4 @@ interface ResolveDeepOptions {
|
|
|
444
509
|
*/
|
|
445
510
|
declare function resolveDeep(value: unknown, scope: ExpressionScope, options?: ResolveDeepOptions): unknown;
|
|
446
511
|
|
|
447
|
-
export { type ActionContext, ActionEngine, type ActionHandler, type ActionRegistry, type ActionResult, type CapabilityRegistry, type ComponentEntry, type ComponentRegistry, type CreateRuntimeContextOptions, type DataSourceStatus, DataStore, type DataStoreDeps, DslRenderer, type DslRendererProps, type FormHandle, type FormRegistry, type HttpAdapter, type HttpRequestConfig, I18nContextProvider, type LocalScope, type PageRuntime, PageRuntimeError, PageRuntimeView, type PermissionAdapter, type RendererContextValue, type RouteContext, type RouterAdapter, type RuntimeContext, type ScopedComponentEntry, type ServiceHandler, type ServiceRegistry, StateStore, UnsupportedComponent, buildScope, createDefaultPermissionAdapter, createDefaultRouterAdapter, createFetchHttpAdapter, createPageRuntime, createRuntimeContext, registerBuiltinActions, resolveDeep, useDataSource, useI18n, useRenderer, useRuntimeState };
|
|
512
|
+
export { type ActionContext, ActionEngine, type ActionHandler, type ActionRegistry, type ActionResult, type CapabilityRegistry, type ComponentEntry, type ComponentRegistry, type CreateRuntimeContextOptions, type DataSourceStatus, DataStore, type DataStoreDeps, DslRenderer, type DslRendererProps, DslSourceBoundary, type DslSourceBoundaryProps, DslSourceResolver, type DslSourceResolverDeps, type FormHandle, type FormRegistry, type HttpAdapter, type HttpRequestConfig, I18nContextProvider, type LocalScope, type PageRuntime, PageRuntimeError, PageRuntimeView, type PermissionAdapter, type RendererContextValue, type RouteContext, type RouterAdapter, type RuntimeContext, type ScopedComponentEntry, type ServiceHandler, type ServiceRegistry, StateStore, UnsupportedComponent, buildScope, createDefaultPermissionAdapter, createDefaultRouterAdapter, createFetchHttpAdapter, createPageRuntime, createRuntimeContext, dslSourceKey, registerBuiltinActions, resolveDeep, useDataSource, useI18n, useRenderer, useRuntimeState };
|