@vvfx/artis 0.0.1-alpha.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/LICENSE +22 -0
- package/dist/artis/artis.d.ts +44 -0
- package/dist/artis/base-artis.d.ts +520 -0
- package/dist/artis/canvas-layer-order.d.ts +19 -0
- package/dist/artis/create-info-to-schema.d.ts +21 -0
- package/dist/artis/index.d.ts +15 -0
- package/dist/artis/operations/index.d.ts +3 -0
- package/dist/artis/operations/operations.d.ts +362 -0
- package/dist/artis/operations/scene-operations.d.ts +26 -0
- package/dist/artis/operations/types.d.ts +39 -0
- package/dist/artis/scene-artis.d.ts +386 -0
- package/dist/artis/screenshot-service.d.ts +83 -0
- package/dist/artis/types.d.ts +130 -0
- package/dist/artis/wiring/index.d.ts +17 -0
- package/dist/artis/wiring/register-commands.d.ts +44 -0
- package/dist/artis/wiring/setup-commands.d.ts +5 -0
- package/dist/artis/wiring/setup-event-bindings.d.ts +16 -0
- package/dist/artis/wiring/setup-keybindings.d.ts +38 -0
- package/dist/artis/wiring/setup-plugins.d.ts +5 -0
- package/dist/artis/wiring/wiring-context.d.ts +34 -0
- package/dist/artis-sdk/artis-sdk.d.ts +1117 -0
- package/dist/artis-sdk/index.d.ts +1 -0
- package/dist/core/asset/asset-manager.d.ts +288 -0
- package/dist/core/asset/index.d.ts +3 -0
- package/dist/core/command/command-service.d.ts +315 -0
- package/dist/core/command/commands/composite-command.d.ts +45 -0
- package/dist/core/command/commands/frame-layout-command.d.ts +81 -0
- package/dist/core/command/commands/frame-layout-mode-command.d.ts +55 -0
- package/dist/core/command/commands/frame-move-in-command.d.ts +54 -0
- package/dist/core/command/commands/frame-move-out-command.d.ts +54 -0
- package/dist/core/command/commands/group-children-detach-command.d.ts +28 -0
- package/dist/core/command/commands/index.d.ts +98 -0
- package/dist/core/command/commands/item-align-command.d.ts +52 -0
- package/dist/core/command/commands/item-create-command.d.ts +66 -0
- package/dist/core/command/commands/item-delete-command.d.ts +40 -0
- package/dist/core/command/commands/item-distribute-command.d.ts +53 -0
- package/dist/core/command/commands/item-group-command.d.ts +41 -0
- package/dist/core/command/commands/item-reorder-command.d.ts +41 -0
- package/dist/core/command/commands/item-replace-source-command.d.ts +48 -0
- package/dist/core/command/commands/item-set-font-family-command.d.ts +46 -0
- package/dist/core/command/commands/item-set-generator-resource-command.d.ts +40 -0
- package/dist/core/command/commands/item-transform-command.d.ts +51 -0
- package/dist/core/command/commands/item-ungroup-command.d.ts +34 -0
- package/dist/core/command/commands/item-update-property-by-create-info-command.d.ts +41 -0
- package/dist/core/command/commands/item-update-property-command.d.ts +82 -0
- package/dist/core/command/commands/mask-commit-command.d.ts +53 -0
- package/dist/core/command/commands/page-auto-layout-command.d.ts +53 -0
- package/dist/core/command/commands/picture-cut-commit-command.d.ts +43 -0
- package/dist/core/command/commands/picture-expand-commit-command.d.ts +35 -0
- package/dist/core/command/commands/scene-switch-command.d.ts +35 -0
- package/dist/core/command/commands/selection-set-command.d.ts +38 -0
- package/dist/core/command/commands/sprite-image-command.d.ts +36 -0
- package/dist/core/command/commands/sprite-text-edit-commit-command.d.ts +43 -0
- package/dist/core/command/commands/state-hand-command.d.ts +14 -0
- package/dist/core/command/commands/state-image-cut-command.d.ts +14 -0
- package/dist/core/command/commands/state-image-expand-command.d.ts +14 -0
- package/dist/core/command/commands/state-image-mask-command.d.ts +15 -0
- package/dist/core/command/commands/state-image-text-edit-command.d.ts +14 -0
- package/dist/core/command/commands/state-item-create-command.d.ts +34 -0
- package/dist/core/command/commands/state-move-command.d.ts +14 -0
- package/dist/core/command/commands/state-switch-command-base.d.ts +41 -0
- package/dist/core/command/commands/text-move-command.d.ts +47 -0
- package/dist/core/command/commands/text-rotate-command.d.ts +52 -0
- package/dist/core/command/commands/text-scale-command.d.ts +56 -0
- package/dist/core/command/commands/text-update-content-command.d.ts +51 -0
- package/dist/core/command/commands/transform-move-command.d.ts +56 -0
- package/dist/core/command/commands/transform-move-with-frame-change-command.d.ts +80 -0
- package/dist/core/command/commands/transform-move-with-layout-command.d.ts +56 -0
- package/dist/core/command/commands/transform-rotate-command.d.ts +51 -0
- package/dist/core/command/commands/transform-scale-command.d.ts +54 -0
- package/dist/core/command/commands/video-play-command.d.ts +28 -0
- package/dist/core/command/commands/video-source-command.d.ts +39 -0
- package/dist/core/command/commands/viewport-fit-to-box-command.d.ts +37 -0
- package/dist/core/command/commands/viewport-fit-to-items-command.d.ts +43 -0
- package/dist/core/command/commands/viewport-move-command.d.ts +34 -0
- package/dist/core/command/commands/viewport-zoom-command.d.ts +35 -0
- package/dist/core/command/index.d.ts +5 -0
- package/dist/core/command/registry.d.ts +246 -0
- package/dist/core/command/types.d.ts +124 -0
- package/dist/core/element-registry/element-facade.d.ts +35 -0
- package/dist/core/element-registry/element-identity-strategy.d.ts +75 -0
- package/dist/core/element-registry/element-registry.d.ts +72 -0
- package/dist/core/element-registry/index.d.ts +5 -0
- package/dist/core/element-registry/types.d.ts +15 -0
- package/dist/core/gizmo/gizmo-bootstrap.d.ts +70 -0
- package/dist/core/gizmo/gizmo-command-binder.d.ts +55 -0
- package/dist/core/gizmo/gizmo-config-override.d.ts +24 -0
- package/dist/core/gizmo/gizmo-registry.d.ts +39 -0
- package/dist/core/gizmo/index.d.ts +19 -0
- package/dist/core/gizmo/register-gizmo-command-bindings.d.ts +20 -0
- package/dist/core/gizmo/state-gizmo-controller.d.ts +20 -0
- package/dist/core/history/history-manager.d.ts +174 -0
- package/dist/core/history/index.d.ts +1 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/item/base-item.d.ts +154 -0
- package/dist/core/item/card-item.d.ts +91 -0
- package/dist/core/item/default-item-schema.d.ts +20 -0
- package/dist/core/item/effects-item.d.ts +99 -0
- package/dist/core/item/frame-item.d.ts +153 -0
- package/dist/core/item/generator-item.d.ts +114 -0
- package/dist/core/item/group-item.d.ts +51 -0
- package/dist/core/item/index.d.ts +25 -0
- package/dist/core/item/sprite-item.d.ts +80 -0
- package/dist/core/item/text-item.d.ts +171 -0
- package/dist/core/item/types.d.ts +158 -0
- package/dist/core/item/video-item.d.ts +120 -0
- package/dist/core/keybinding/index.d.ts +11 -0
- package/dist/core/keybinding/key-binding-controller.d.ts +44 -0
- package/dist/core/keybinding/key-binding-registry.d.ts +92 -0
- package/dist/core/keybinding/key-binding-store.d.ts +29 -0
- package/dist/core/keybinding/key-matcher.d.ts +24 -0
- package/dist/core/keybinding/types.d.ts +84 -0
- package/dist/core/plugin/index.d.ts +3 -0
- package/dist/core/plugin/io-plugin.d.ts +167 -0
- package/dist/core/plugin/plugin-system.d.ts +77 -0
- package/dist/core/predict/align-predict.d.ts +20 -0
- package/dist/core/predict/base/box-ops.d.ts +40 -0
- package/dist/core/predict/base/index.d.ts +14 -0
- package/dist/core/predict/base/parent-coord.d.ts +29 -0
- package/dist/core/predict/base/schema-box.d.ts +21 -0
- package/dist/core/predict/distribute-predict.d.ts +19 -0
- package/dist/core/predict/frame-layout-predict.d.ts +24 -0
- package/dist/core/predict/index.d.ts +12 -0
- package/dist/core/preferences/index.d.ts +2 -0
- package/dist/core/preferences/user-preferences-manager.d.ts +130 -0
- package/dist/core/quality/error-monitor/error-monitor-facade.d.ts +73 -0
- package/dist/core/quality/error-monitor/error-monitor.d.ts +106 -0
- package/dist/core/quality/error-monitor/index.d.ts +4 -0
- package/dist/core/quality/error-monitor/types.d.ts +198 -0
- package/dist/core/quality/index.d.ts +3 -0
- package/dist/core/quality/perf-monitor/index.d.ts +5 -0
- package/dist/core/quality/perf-monitor/perf-monitor-facade.d.ts +45 -0
- package/dist/core/quality/perf-monitor/perf-monitor.d.ts +60 -0
- package/dist/core/quality/perf-monitor/types.d.ts +66 -0
- package/dist/core/quality/stability-monitor/index.d.ts +5 -0
- package/dist/core/quality/stability-monitor/stability-monitor-facade.d.ts +50 -0
- package/dist/core/quality/stability-monitor/stability-monitor.d.ts +61 -0
- package/dist/core/quality/stability-monitor/types.d.ts +69 -0
- package/dist/core/renderer/background-controller.d.ts +56 -0
- package/dist/core/renderer/index.d.ts +5 -0
- package/dist/core/renderer/player-adapter.d.ts +129 -0
- package/dist/core/renderer/renderer.d.ts +134 -0
- package/dist/core/service/frame-service.d.ts +116 -0
- package/dist/core/service/index.d.ts +9 -0
- package/dist/core/service/interaction-providers.d.ts +20 -0
- package/dist/core/service/interaction-service.d.ts +211 -0
- package/dist/core/service/item-asset-service.d.ts +120 -0
- package/dist/core/service/item-creator-service.d.ts +211 -0
- package/dist/core/service/item-service.d.ts +641 -0
- package/dist/core/service/item-sync-service.d.ts +66 -0
- package/dist/core/service/json-scene-sync-service.d.ts +140 -0
- package/dist/core/service/refresh-animation-base-service.d.ts +1 -0
- package/dist/core/service/scene-data-assembler.d.ts +166 -0
- package/dist/core/service/view-service.d.ts +202 -0
- package/dist/core/state/base-state.d.ts +28 -0
- package/dist/core/state/index.d.ts +6 -0
- package/dist/core/state/presets.d.ts +25 -0
- package/dist/core/state/state-manager.d.ts +50 -0
- package/dist/core/state/types.d.ts +52 -0
- package/dist/core/store/index.d.ts +3 -0
- package/dist/core/store/scene-store.d.ts +194 -0
- package/dist/core/store/store.d.ts +36 -0
- package/dist/core/types/artis-config.d.ts +186 -0
- package/dist/core/types/artis-events.d.ts +101 -0
- package/dist/core/types/frame.d.ts +3 -0
- package/dist/core/types/generator.d.ts +28 -0
- package/dist/core/types/index.d.ts +15 -0
- package/dist/core/types/item-create-info.d.ts +205 -0
- package/dist/core/types/item-property.d.ts +149 -0
- package/dist/core/types/item-reorder.d.ts +12 -0
- package/dist/core/types/item-schema.d.ts +263 -0
- package/dist/core/types/item-set-property.d.ts +48 -0
- package/dist/core/types/page.d.ts +40 -0
- package/dist/core/types/sdk.d.ts +28 -0
- package/dist/core/types/view.d.ts +39 -0
- package/dist/helper/exporter/config.d.ts +18 -0
- package/dist/helper/exporter/const.d.ts +71 -0
- package/dist/helper/exporter/export-media.d.ts +189 -0
- package/dist/helper/exporter/exporter.d.ts +58 -0
- package/dist/helper/exporter/index.d.ts +2 -0
- package/dist/helper/exporter/types.d.ts +194 -0
- package/dist/helper/exporter/utils.d.ts +71 -0
- package/dist/helper/exporter/wav-audio.d.ts +35 -0
- package/dist/helper/html-overlay/anchor-navigation-runtime.d.ts +1 -0
- package/dist/helper/html-overlay/auto-height-layout.d.ts +16 -0
- package/dist/helper/html-overlay/auto-height-runtime.d.ts +40 -0
- package/dist/helper/html-overlay/document-runtime.d.ts +18 -0
- package/dist/helper/html-overlay/document-transform.d.ts +46 -0
- package/dist/helper/html-overlay/dom-order.d.ts +5 -0
- package/dist/helper/html-overlay/host-message-runtime.d.ts +15 -0
- package/dist/helper/html-overlay/html-capture-runtime.d.ts +12 -0
- package/dist/helper/html-overlay/html-card-service.d.ts +287 -0
- package/dist/helper/html-overlay/html-viewport-style.d.ts +6 -0
- package/dist/helper/html-overlay/index.d.ts +1 -0
- package/dist/helper/html-overlay/inline-script-json.d.ts +1 -0
- package/dist/helper/html-overlay/mime-utils.d.ts +13 -0
- package/dist/helper/html-overlay/overlay-transform.d.ts +30 -0
- package/dist/helper/html-overlay/path-utils.d.ts +34 -0
- package/dist/helper/html-overlay/runtime-context.d.ts +2 -0
- package/dist/helper/html-overlay/shell-runtime.d.ts +13 -0
- package/dist/helper/index.d.ts +5 -0
- package/dist/helper/scene-builder.d.ts +111 -0
- package/dist/helper/screen-shot.d.ts +51 -0
- package/dist/helper/size-adapt.d.ts +88 -0
- package/dist/index.cjs +69350 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.mjs +68963 -0
- package/dist/index.mjs.map +1 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/player.d.ts +9 -0
- package/dist/utils/background-manager.d.ts +76 -0
- package/dist/utils/common-utils.d.ts +39 -0
- package/dist/utils/container-size.d.ts +7 -0
- package/dist/utils/find-player-item.d.ts +9 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/json-data-utils.d.ts +198 -0
- package/dist/utils/layout-utils.d.ts +144 -0
- package/dist/utils/pixel-box-utils.d.ts +26 -0
- package/dist/utils/player-data-utils.d.ts +9 -0
- package/dist/utils/player-utils.d.ts +42 -0
- package/dist/utils/replay-utils.d.ts +22 -0
- package/dist/utils/types.d.ts +130 -0
- package/package.json +66 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { spec } from '../../shared';
|
|
2
|
+
import { type Store } from '../store';
|
|
3
|
+
import { type AssetManager } from '../asset';
|
|
4
|
+
import { type ArtisPlugin } from './plugin-system';
|
|
5
|
+
import { Renderer } from '../renderer';
|
|
6
|
+
import { type ViewService } from '../service';
|
|
7
|
+
/**
|
|
8
|
+
* IOPlugin - JSON 序列化/反序列化插件
|
|
9
|
+
*
|
|
10
|
+
* 职责:
|
|
11
|
+
* 1. 从 Store.items + AssetManager + Player VFXItems → 生成完整 JSONScene(exportScene)
|
|
12
|
+
* 2. 单个 item 序列化(用于复制粘贴等场景)
|
|
13
|
+
*
|
|
14
|
+
* ItemService 不再直接操作 Scene JSON,所有 JSON 的生成统一在此处完成。
|
|
15
|
+
*/
|
|
16
|
+
export declare class IOPlugin implements ArtisPlugin {
|
|
17
|
+
/** 插件 ID 常量(供非实例处引用,如 SceneArtis 通过 pluginSystem.getPlugin 取实例) */
|
|
18
|
+
static readonly pluginId = "io-plugin";
|
|
19
|
+
readonly id = "io-plugin";
|
|
20
|
+
readonly name = "IO Plugin";
|
|
21
|
+
readonly version = "1.0.0";
|
|
22
|
+
readonly description = "Handles JSON scene serialization/deserialization";
|
|
23
|
+
private _store;
|
|
24
|
+
private _assetManager;
|
|
25
|
+
private _renderer;
|
|
26
|
+
private _viewService;
|
|
27
|
+
/**
|
|
28
|
+
* 激活插件,注入 Store / AssetManager / Renderer / ViewService 依赖
|
|
29
|
+
*
|
|
30
|
+
* @param host 宿主提供的依赖集合
|
|
31
|
+
*/
|
|
32
|
+
activate(host: {
|
|
33
|
+
store: Store;
|
|
34
|
+
assetManager: AssetManager;
|
|
35
|
+
renderer: Renderer;
|
|
36
|
+
viewService: ViewService;
|
|
37
|
+
}): void;
|
|
38
|
+
/** 停用插件,清空所有依赖引用 */
|
|
39
|
+
deactivate(): void;
|
|
40
|
+
/**
|
|
41
|
+
* 从 Store + AssetManager + Renderer 状态导出完整的 JSONScene
|
|
42
|
+
*
|
|
43
|
+
* 遍历 Store.items,结合 AssetManager 中的资源信息和 Renderer 中的 VFXItem 变换数据,
|
|
44
|
+
* 生成标准的 spec.JSONScene 结构。
|
|
45
|
+
*
|
|
46
|
+
* @returns 完整的 JSONScene 数据
|
|
47
|
+
*/
|
|
48
|
+
exportScene(): spec.JSONScene;
|
|
49
|
+
/**
|
|
50
|
+
* 序列化单个 item 为 JSON 数据(用于复制粘贴)
|
|
51
|
+
*
|
|
52
|
+
* @param id 目标元素 ID
|
|
53
|
+
* @returns 元素 JSON 与组件数据,未激活/无合成/无元素时返回 undefined
|
|
54
|
+
*/
|
|
55
|
+
serializeItem(id: string): {
|
|
56
|
+
item: spec.VFXItemData;
|
|
57
|
+
components: spec.ComponentData[];
|
|
58
|
+
} | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* 序列化单个 item 为 **含资源** 的完整 JSON 片段(item + components + images/videos/textures)。
|
|
61
|
+
*
|
|
62
|
+
* 与 {@link serializeItem} 的区别:后者只返回 item+components、丢弃资源数组;
|
|
63
|
+
* 本方法把资源数组一并返回,供 {@link JsonSceneSyncService} 会话内新建元素 insert 时
|
|
64
|
+
* 联动并入 scene.images/videos/textures,保证 reload 后图/视频资源可复建。
|
|
65
|
+
*
|
|
66
|
+
* @param id 目标元素 ID
|
|
67
|
+
* @returns item+components+resources;未激活/无合成/无元素时返回 undefined
|
|
68
|
+
*/
|
|
69
|
+
serializeItemWithAssets(id: string): {
|
|
70
|
+
item: spec.VFXItemData;
|
|
71
|
+
components: spec.ComponentData[];
|
|
72
|
+
images: spec.ImageSource[];
|
|
73
|
+
videos: spec.VideoInfo[];
|
|
74
|
+
textures: spec.SerializedTextureSource[];
|
|
75
|
+
} | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* 序列化单个元素为 JSON 数据(含图片/视频/纹理资源收集)。
|
|
78
|
+
*
|
|
79
|
+
* 不再读 playerItem.transform——世界坐标口径由调用方通过 {@link SerializeItemTransform} 传入:
|
|
80
|
+
* - exportScene / serializeItem / serializeItemWithAssets 透传 playerItem.transform(local 口径)
|
|
81
|
+
* - createSceneByItemIds 用 artisItem 绝对像素 + interactionService 换算
|
|
82
|
+
*
|
|
83
|
+
* @param artisItem 业务层元素
|
|
84
|
+
* @param transform 已算好的世界坐标 transform(见 {@link SerializeItemTransform})
|
|
85
|
+
* @param assetManager 资源管理器
|
|
86
|
+
* @param images 输出:图片资源列表
|
|
87
|
+
* @param videos 输出:视频资源列表
|
|
88
|
+
* @param textures 输出:纹理资源列表
|
|
89
|
+
* @param itemSnapshotUrls 元素 ID 到图片快照 URL 的映射;命中时优先序列化为 Sprite
|
|
90
|
+
* @returns 元素 JSON 信息,类型不支持时返回 undefined
|
|
91
|
+
*/
|
|
92
|
+
private serializeItemToJSON;
|
|
93
|
+
/**
|
|
94
|
+
* 从 playerItem.transform 透传构造序列化 transform(local 口径)。
|
|
95
|
+
*
|
|
96
|
+
* 供 exportScene / serializeItem / serializeItemWithAssets 维持原"读 playerItem.transform"行为:
|
|
97
|
+
* 这些场景导出整个场景或单元素快照,元素仍处于原 parent 下的 local transform。
|
|
98
|
+
*/
|
|
99
|
+
private _playerItemTransformToSerialize;
|
|
100
|
+
/**
|
|
101
|
+
* 根据 ArtisItem ID 列表创建 spec.JSONScene
|
|
102
|
+
*
|
|
103
|
+
* 三步流程:
|
|
104
|
+
* 1. 取元素 → 算所选元素基准像素 unionBox → previewSize → 建基础场景取相机,算 world-per-pixel 比例
|
|
105
|
+
* 2. 逐元素按「像素属性 + VP 矩阵比例」算世界坐标 transform → 序列化为 ItemJSON
|
|
106
|
+
* 3. 组装 JSONScene 导出
|
|
107
|
+
*
|
|
108
|
+
* 坐标口径:不依赖 InteractionService(其相机/视口参数取自源场景,与新场景不一致)。改为结合新场景
|
|
109
|
+
* 尺寸(previewSize)+ 新场景相机 + 元素像素属性:用 getBasicScene(previewSize).camera 建 VP 矩阵,
|
|
110
|
+
* unproject 得 world-per-pixel 比例 (xRatio, yRatio);元素世界尺寸 = 像素尺寸 × 比例,元素世界位置 =
|
|
111
|
+
*(盒心 - union 盒心)× (xRatio, -yRatio)(union 盒心对应新场景世界原点,Y 翻转)。
|
|
112
|
+
* 原生支持 SPRITE/TEXT/VIDEO 序列化;提供图片快照的元素会以 Sprite 替身导出,
|
|
113
|
+
* 其余类型跳过(GROUP/Frame 仍参与 unionBox 计算)。
|
|
114
|
+
*
|
|
115
|
+
* @param ids 要导出的 ArtisItem ID(单个或多个)
|
|
116
|
+
* @param options 可选参数
|
|
117
|
+
* @param options.sceneSize 场景预览尺寸,不传则根据元素包围盒自动计算
|
|
118
|
+
* @param options.name 合成名称
|
|
119
|
+
* @param options.itemSnapshotUrls 元素 ID 到图片快照 URL 的映射;命中时以 Sprite 替代原元素序列化
|
|
120
|
+
*/
|
|
121
|
+
createSceneByItemIds(ids: string | string[], options?: {
|
|
122
|
+
sceneSize?: [number, number];
|
|
123
|
+
name?: string;
|
|
124
|
+
itemSnapshotUrls?: ReadonlyMap<string, string>;
|
|
125
|
+
}): spec.JSONScene;
|
|
126
|
+
/**
|
|
127
|
+
* 按新场景相机 VP 矩阵算 world-per-pixel 比例 (xRatio, yRatio)。
|
|
128
|
+
*
|
|
129
|
+
* 用 camera.position 建 viewMatrix(仅平移、旋转/缩放单位)、camera.fov+previewSize 比例 建 perspective,
|
|
130
|
+
* 组成 vpMatrix 后 unproject NDC (0,0,z)~(2,2,z)(z 为世界原点投影后的 NDC z)得到世界两点,
|
|
131
|
+
* 其差 / previewSize 即每像素对应的世界单位(z=0 平面)。与 json-data-utils.calcWorldSizeByCamera 同口径,
|
|
132
|
+
* 但输出比例供逐元素复用。perspective 第 5 参(clipMode===1 → portrait)与 interaction-service 一致。
|
|
133
|
+
*
|
|
134
|
+
* @param camera 合成相机配置(spec.CameraOptions,含 fov/near/far/clipMode/position)
|
|
135
|
+
* @param previewSize 合成预览尺寸(像素),其宽高比作 aspect
|
|
136
|
+
* @returns { xRatio, yRatio } 每像素对应的世界单位
|
|
137
|
+
*/
|
|
138
|
+
private _computeWorldPixelRatios;
|
|
139
|
+
/**
|
|
140
|
+
* 按 artisItem 像素属性 + (xRatio, yRatio) 换算导出用世界坐标 transform。
|
|
141
|
+
*
|
|
142
|
+
* - position:(itemBox.center - unionBox.center) × (xRatio, -yRatio)。unionBox 中心对应新场景世界原点,
|
|
143
|
+
* Y 取负(场景 Y 朝上、像素 Y 朝下)。落在 z=0 平面(VP 比例的计算平面)。
|
|
144
|
+
* - size:像素尺寸 (width, height) × (xRatio, yRatio)(TEXT 高度缺省取 lineHeight)。不含 scale。
|
|
145
|
+
* - rotation:Z 轴取负(与 createItemCore 一致)
|
|
146
|
+
* - scale:直接取 property.scale
|
|
147
|
+
*
|
|
148
|
+
* GROUP 等空节点 / 缺宽高元素返回 undefined(serializeItemToJSON 也会跳过)。
|
|
149
|
+
*
|
|
150
|
+
* @param artisItem 业务层元素
|
|
151
|
+
* @param unionBox 所选元素并集盒(中心对应新场景世界原点)
|
|
152
|
+
* @param xRatio / yRatio world-per-pixel 比例(由 _computeWorldPixelRatios 算出)
|
|
153
|
+
* @returns 世界坐标 transform;空节点/缺尺寸返回 undefined
|
|
154
|
+
*/
|
|
155
|
+
private _computeExportTransform;
|
|
156
|
+
/**
|
|
157
|
+
* 按所选元素的基准设计像素包裹盒求并集。
|
|
158
|
+
*
|
|
159
|
+
* 直接从 Store 取 artisItem 还原为 ItemSchema(toSchema),再调纯函数 `getPixelBoxBySchemas`
|
|
160
|
+
* (utils/pixel-box-utils)按元素实际数据(position + width/height 补乘 scale + rotation)算盒
|
|
161
|
+
* (GROUP 等空节点按子元素 union),最后对结果取并集。返回空盒表示无有效元素(由上层走 previewSize 兜底)。
|
|
162
|
+
*
|
|
163
|
+
* @param itemIds 所选元素 id 列表
|
|
164
|
+
* @returns 并集基准设计像素包围盒;无有效元素时返回空盒
|
|
165
|
+
*/
|
|
166
|
+
private _computeSelectedItemsPixelBox;
|
|
167
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Disposable } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* ArtisPlugin - 插件接口
|
|
4
|
+
* activate/deactivate 接收宿主实例(使用泛型避免循环依赖)
|
|
5
|
+
*/
|
|
6
|
+
export type ArtisPlugin<Host = unknown> = {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
dependencies?: string[];
|
|
12
|
+
activate(host: Host): void | Promise<void>;
|
|
13
|
+
deactivate(): void | Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* PluginSystem - 插件管理器
|
|
17
|
+
*/
|
|
18
|
+
export declare class PluginSystem<Host = unknown> implements Disposable {
|
|
19
|
+
private _plugins;
|
|
20
|
+
private _activePlugins;
|
|
21
|
+
/**
|
|
22
|
+
* 注册插件
|
|
23
|
+
*
|
|
24
|
+
* @param plugin 插件对象
|
|
25
|
+
* 边界:同 id 的插件会覆盖旧注册项,不会触发激活
|
|
26
|
+
*/
|
|
27
|
+
registerPlugin(plugin: ArtisPlugin<Host>): void;
|
|
28
|
+
/**
|
|
29
|
+
* 注销插件
|
|
30
|
+
*
|
|
31
|
+
* @param pluginId 插件 ID
|
|
32
|
+
* 边界:若该插件已激活,会先调用其 deactivate 再移除
|
|
33
|
+
*/
|
|
34
|
+
unregisterPlugin(pluginId: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* 激活插件,调用插件 activate 并将其加入已激活集合
|
|
37
|
+
*
|
|
38
|
+
* @param pluginId 插件 ID
|
|
39
|
+
* @param host 宿主实例,透传给插件 activate
|
|
40
|
+
* @returns 激活完成的 Promise
|
|
41
|
+
* 边界:插件不存在时抛错;activate 抛错则不会被标记为已激活
|
|
42
|
+
*/
|
|
43
|
+
activatePlugin(pluginId: string, host: Host): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* 停用插件,调用插件 deactivate 并将其移出已激活集合
|
|
46
|
+
*
|
|
47
|
+
* @param pluginId 插件 ID
|
|
48
|
+
* @returns 停用完成的 Promise
|
|
49
|
+
* 边界:插件不存在或未激活时直接返回,不抛错
|
|
50
|
+
*/
|
|
51
|
+
deactivatePlugin(pluginId: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* 按 ID 获取插件。
|
|
54
|
+
*
|
|
55
|
+
* @param pluginId 插件 ID
|
|
56
|
+
* @returns 插件对象;未注册返回 undefined
|
|
57
|
+
*/
|
|
58
|
+
getPlugin(pluginId: string): ArtisPlugin<Host> | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* 获取所有已注册插件(含未激活)。
|
|
61
|
+
*
|
|
62
|
+
* @returns 全部已注册插件数组
|
|
63
|
+
*/
|
|
64
|
+
getAllPlugins(): ArtisPlugin<Host>[];
|
|
65
|
+
/**
|
|
66
|
+
* 获取当前已激活的插件列表。
|
|
67
|
+
*
|
|
68
|
+
* @returns 已激活插件数组
|
|
69
|
+
*/
|
|
70
|
+
getActivePlugins(): ArtisPlugin<Host>[];
|
|
71
|
+
/**
|
|
72
|
+
* 销毁插件系统
|
|
73
|
+
*
|
|
74
|
+
* 边界:先依次停用所有已激活插件,再清空注册表
|
|
75
|
+
*/
|
|
76
|
+
dispose(): Promise<void>;
|
|
77
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Box2 } from '@vvfx/gizmo';
|
|
2
|
+
import type { AlignType } from '../../utils/types';
|
|
3
|
+
/**
|
|
4
|
+
* item.align 的离线预测算法(在 {@link ItemAlignCommand} 内的同源实现)。
|
|
5
|
+
*
|
|
6
|
+
* 以所有元素像素包围盒的并集为基准,每个元素按对齐类型沿单一轴向平移,使其包围盒对应边/中线
|
|
7
|
+
* 与整体并集对齐(另一轴向保持不变)。纯函数、无 Player 依赖——Command 实现(执行真相)与
|
|
8
|
+
* Agent predictor(预测真相)共用本函数,避免两份几何发散。
|
|
9
|
+
*/
|
|
10
|
+
export type BoxInput = {
|
|
11
|
+
id: string;
|
|
12
|
+
box: Box2;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* 计算各元素对齐后的中心位置。
|
|
16
|
+
* @param inputs 元素 ID + 像素包围盒列表
|
|
17
|
+
* @param alignType 对齐类型(left/right/horizontal-center/top/bottom/vertical-center)
|
|
18
|
+
* @returns 元素 ID → 对齐后中心 [x, y];元素数少于 2 时返回空映射(与命令 execute 守卫一致)
|
|
19
|
+
*/
|
|
20
|
+
export declare function computeAlignedPositions(inputs: BoxInput[], alignType: AlignType): Map<string, [number, number]>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Box2 } from '@vvfx/gizmo';
|
|
2
|
+
/**
|
|
3
|
+
* 原子包围盒运算基础方法(box-ops)。
|
|
4
|
+
*
|
|
5
|
+
* 语义薄包装层——权威盒运算在 @vvfx/gizmo 的 Box2,此处不重写 union/rotate 等几何,
|
|
6
|
+
* 只把「命令实现 / Agent 预测」反复重抄的盒运算收敛成统一语义入口,使执行真相与预测真相同源。
|
|
7
|
+
*
|
|
8
|
+
* 纯函数、无 Player / Store / 命令依赖,可离线单测。
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 计算多个包围盒的并集。
|
|
12
|
+
*
|
|
13
|
+
* 收编此前散落在 {@link ItemAlignCommand._computeUnionBox}(item-align-command.ts:154)等命令内
|
|
14
|
+
* 的重抄实现。空数组返回空盒(与 Box2 默认一致)。
|
|
15
|
+
* @param boxes 参与并集的包围盒
|
|
16
|
+
* @returns 并集包围盒(新实例,不污染入参)
|
|
17
|
+
*/
|
|
18
|
+
export declare function unionBoxes(boxes: Box2[]): Box2;
|
|
19
|
+
/**
|
|
20
|
+
* 取包围盒中心 [x, y]。空盒返回 [0, 0](与 Box2.getCenter 空盒语义一致)。
|
|
21
|
+
*/
|
|
22
|
+
export declare function boxCenter(box: Box2): [number, number];
|
|
23
|
+
/**
|
|
24
|
+
* 取包围盒尺寸 [width, height]。空盒返回 [0, 0]。
|
|
25
|
+
*/
|
|
26
|
+
export declare function boxSize(box: Box2): [number, number];
|
|
27
|
+
/**
|
|
28
|
+
* 按新中心位置 / 旋转 / 缩放重算包围盒。
|
|
29
|
+
*
|
|
30
|
+
* 以入参 box 的尺寸为基础(width/height),先乘 scale,再以 pos 为中心、rot(角度)旋转,
|
|
31
|
+
* 得到变换后包围盒。复用 {@link Box2.setFromCenterAndSize} + {@link Box2.rotate} 的口径,
|
|
32
|
+
* 与 `getPixelBoxBySchema`(utils/pixel-box-utils.ts:32)保持一致,避免两份变换真相。
|
|
33
|
+
*
|
|
34
|
+
* @param box 基础尺寸盒(仅取其 width/height,不关心其当前位置/旋转)
|
|
35
|
+
* @param pos 新中心位置
|
|
36
|
+
* @param rot 旋转角度(度),缺省 0
|
|
37
|
+
* @param scale [sx, sy] 缩放,缺省 [1, 1]
|
|
38
|
+
* @returns 变换后包围盒(新实例)
|
|
39
|
+
*/
|
|
40
|
+
export declare function transformBox(box: Box2, pos: [number, number], rot?: number, scale?: [number, number]): Box2;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 基础计算方法层 base —— 原子几何收敛入口。
|
|
3
|
+
*
|
|
4
|
+
* 包围盒运算、schema↔box 映射、父级坐标换算等被命令实现 / Agent 预测反复使用的原子计算
|
|
5
|
+
* 收敛于此。层级自底向上:base(原子)→ `core/predict/*-predict`(算法组合)→
|
|
6
|
+
* 同时被 Command 实现(算几何后写副作用)与 Agent predictor(纯预测)消费,
|
|
7
|
+
* 使执行真相 = 预测真相,无需事后对账。
|
|
8
|
+
*
|
|
9
|
+
* 全部纯函数、无 Player / Store / 命令依赖,可离线单测。
|
|
10
|
+
*/
|
|
11
|
+
export { unionBoxes, boxCenter, boxSize, transformBox, } from './box-ops';
|
|
12
|
+
export { getPixelBoxBySchema, getPixelBoxBySchemas, schemaToBoxMap, } from './schema-box';
|
|
13
|
+
export type {} from './schema-box';
|
|
14
|
+
export { worldToLocalBox, localToWorldBox } from './parent-coord';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Box2 } from '@vvfx/gizmo';
|
|
2
|
+
/**
|
|
3
|
+
* 父级局部坐标换算基础方法。
|
|
4
|
+
*
|
|
5
|
+
* 供 group / ungroup / frame.moveIn / frame.moveOut 等命令的离线预测:元素在进出父级
|
|
6
|
+
* (Frame / Group)时,其世界包围盒需换算到父级局部空间或反之,以保持视觉位置不变
|
|
7
|
+
* (与运行时 `getItemTransformUnderParent` 的「Frame reparent 变换保持」语义对齐)。
|
|
8
|
+
*
|
|
9
|
+
* 本轮只提供基于包围盒的换算(非矩阵精确变换);精确父子变换保持仍由运行时
|
|
10
|
+
* ItemService / Player 路径承担,此处仅服务于 Agent 的包围盒级 dry-run 预测。纯函数、可离线单测。
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* 父级局部坐标基于其包围盒中心换算:把子元素的世界盒换算为以父级中心为原点的局部盒。
|
|
14
|
+
*
|
|
15
|
+
* 即 `childBox.translate(-parentCenter)`。父级空盒时原样返回子盒(无父级信息可依)。
|
|
16
|
+
* @param childBox 子元素世界包围盒
|
|
17
|
+
* @param parentBox 父级包围盒(取其中心作为局部原点)
|
|
18
|
+
* @returns 父级局部空间下的子盒(新实例)
|
|
19
|
+
*/
|
|
20
|
+
export declare function worldToLocalBox(childBox: Box2, parentBox: Box2): Box2;
|
|
21
|
+
/**
|
|
22
|
+
* 局部坐标反算回世界:把父级局部空间下的子盒换算回世界空间。
|
|
23
|
+
*
|
|
24
|
+
* 即 `childBox.translate(+parentCenter)`。父级空盒时原样返回。
|
|
25
|
+
* @param childBox 父级局部空间下的子盒
|
|
26
|
+
* @param parentBox 父级包围盒(取其中心作为局部原点)
|
|
27
|
+
* @returns 世界空间下的子盒(新实例)
|
|
28
|
+
*/
|
|
29
|
+
export declare function localToWorldBox(childBox: Box2, parentBox: Box2): Box2;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Box2 } from '@vvfx/gizmo';
|
|
2
|
+
import { getPixelBoxBySchema, getPixelBoxBySchemas } from '../../../utils/pixel-box-utils';
|
|
3
|
+
import type { ItemSchema } from '../../types';
|
|
4
|
+
/**
|
|
5
|
+
* ItemSchema ↔ 像素包围盒映射的基础方法入口。
|
|
6
|
+
*
|
|
7
|
+
* 本轮收敛 + 重导出现有的纯计算器(utils/pixel-box-utils),让 `core/predict/base` 成为统一入口;
|
|
8
|
+
* 旧 utils 文件不删,留待后续轮次迁移。权威实现仍在像素盒计算器处,base 不重写算法。
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 按单个 ItemSchema 计算像素包围盒(离线、无 Player)。重导出便于统一入口。
|
|
12
|
+
* @see utils/pixel-box-utils.ts:getPixelBoxBySchema
|
|
13
|
+
*/
|
|
14
|
+
export { getPixelBoxBySchema, getPixelBoxBySchemas };
|
|
15
|
+
/**
|
|
16
|
+
* 批量按 ItemSchema 算包围盒,返回 元素ID → Box2 映射。
|
|
17
|
+
*
|
|
18
|
+
* 复用 {@link getPixelBoxBySchemas}(含 GROUP 空节点按 children union 收敛、环防护),
|
|
19
|
+
* 作为 base 的便捷封装:predictor 与命令算法都经此取盒,保证口径一致。
|
|
20
|
+
*/
|
|
21
|
+
export declare function schemaToBoxMap(schemas: ItemSchema[]): Map<string, Box2>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DistributeType } from '../../utils/types';
|
|
2
|
+
/**
|
|
3
|
+
* item.distribute 的离线预测算法(在 {@link ItemDistributeCommand} 内的同源实现)。
|
|
4
|
+
*
|
|
5
|
+
* 沿分布方向按元素中心排序,固定首尾两个元素,将中间元素的中心点等间距铺开;与分布方向正交的
|
|
6
|
+
* 轴保持不变。纯函数、无 Player 依赖——Command 实现(执行真相)与 Agent predictor(预测真相)
|
|
7
|
+
* 共用本函数,避免两份几何发散。
|
|
8
|
+
*/
|
|
9
|
+
export type CenterInput = {
|
|
10
|
+
id: string;
|
|
11
|
+
center: [number, number];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 计算各元素分布后的中心位置。
|
|
15
|
+
* @param inputs 元素 ID + 当前中心 [x, y] 列表
|
|
16
|
+
* @param distributeType 分布类型(horizontal-spacing / vertical-spacing)
|
|
17
|
+
* @returns 元素 ID → 分布后中心 [x, y];空列表返回空映射
|
|
18
|
+
*/
|
|
19
|
+
export declare function computeDistributedPositions(inputs: CenterInput[], distributeType: DistributeType): Map<string, [number, number]>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FrameLayoutItem, FrameAutoLayoutOptions, FrameAutoLayoutResult } from '@vvfx/gizmo';
|
|
2
|
+
import { computeFrameAutoLayout } from '@vvfx/gizmo';
|
|
3
|
+
import type { ItemSchema, FrameItemSchema } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* frame.autoLayout 的离线预测入口。
|
|
6
|
+
*
|
|
7
|
+
* 布局算法本体(`computeFrameAutoLayout`)已在 @vvfx/gizmo/frame-auto-layout 内为纯函数,
|
|
8
|
+
* 此处直接 re-export 暴露为 Artis 侧统一入口,并补一个把子元素 ItemSchema + Frame schema
|
|
9
|
+
* 组装成纯布局输入的适配器。不重写算法,避免两份布局真相。
|
|
10
|
+
*
|
|
11
|
+
* Command 实现(FrameService → FrameModule.computeAutoLayout)与 Agent predictor 经此入口
|
|
12
|
+
* 调同一份 gizmo 纯算法。
|
|
13
|
+
*/
|
|
14
|
+
export { computeFrameAutoLayout, type FrameLayoutItem, type FrameAutoLayoutOptions, type FrameAutoLayoutResult, };
|
|
15
|
+
/**
|
|
16
|
+
* 从子元素 ItemSchema + 画板 schema 组装离线布局输入。
|
|
17
|
+
* @param childrenSchemas 画板子元素 schema 列表
|
|
18
|
+
* @param frame 画板 schema(取其 autoLayoutConfig 作为布局配置)
|
|
19
|
+
* @returns { items: 含包围盒的布局项, options: padding/gap/config }
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildFrameLayoutInput(childrenSchemas: ItemSchema[], frame: FrameItemSchema): {
|
|
22
|
+
items: FrameLayoutItem[];
|
|
23
|
+
options?: FrameAutoLayoutOptions;
|
|
24
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 离线计算方法层(base 原子 + *-predict 算法组合)。
|
|
3
|
+
*
|
|
4
|
+
* - `base/`:原子几何(盒运算 / schema↔box / 父级坐标),纯函数。
|
|
5
|
+
* - `*-predict`:在 base 之上的算法组合(align / distribute / frame-layout)。
|
|
6
|
+
*
|
|
7
|
+
* 两者同时被 Command 实现(执行真相)与 Agent predictor(预测真相)消费——同源即一致。
|
|
8
|
+
*/
|
|
9
|
+
export * from './base';
|
|
10
|
+
export * from './align-predict';
|
|
11
|
+
export * from './distribute-predict';
|
|
12
|
+
export * from './frame-layout-predict';
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { EventEmitter } from '../../shared';
|
|
2
|
+
import type { UserPreferences, ItemPreferences, ExportPreferences, ScreenshotPreferences, SizeAdaptPreferences, AsyncLoadPreferences, CardTypeConfig, PagePreferences } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* UserPreferencesManager 事件
|
|
5
|
+
*
|
|
6
|
+
* 本管理器只管终端用户个人偏好(page/item/export/screenshot/sizeAdapt/asyncLoad),
|
|
7
|
+
*/
|
|
8
|
+
export type UserPreferencesEvents = Record<string, never>;
|
|
9
|
+
/**
|
|
10
|
+
* UserPreferencesManager - 个人偏好管理器
|
|
11
|
+
*
|
|
12
|
+
* 仅管理终端用户个人偏好(页面/元素/导出/截图等终端用户功能开关),不再持有 Gizmo 配置。
|
|
13
|
+
*/
|
|
14
|
+
export declare class UserPreferencesManager extends EventEmitter<UserPreferencesEvents> {
|
|
15
|
+
private _preferences;
|
|
16
|
+
/** 已注册的卡片类型列表(对应原 SDKConfig.itemConfig.cardConfig.cardTypes) */
|
|
17
|
+
private _cardTypes;
|
|
18
|
+
/**
|
|
19
|
+
* 初始化配置管理器。卡片类型由业务或 Demo 显式注册。
|
|
20
|
+
*
|
|
21
|
+
* @param initial 初始偏好片段(可选,未传则全量使用默认值)
|
|
22
|
+
*/
|
|
23
|
+
constructor(initial?: Partial<UserPreferences>);
|
|
24
|
+
/** 页面级偏好(静态预览/缩放/分组可见等) */
|
|
25
|
+
get page(): PagePreferences;
|
|
26
|
+
/**
|
|
27
|
+
* 局部更新页面偏好,与现有值浅合并。
|
|
28
|
+
*
|
|
29
|
+
* @param config 待合并的字段
|
|
30
|
+
*/
|
|
31
|
+
setPage(config: Partial<PagePreferences>): void;
|
|
32
|
+
/** 元素(frame/card)相关偏好 */
|
|
33
|
+
get item(): ItemPreferences;
|
|
34
|
+
/**
|
|
35
|
+
* 局部更新元素偏好,frame 与 card 分别浅合并。
|
|
36
|
+
*
|
|
37
|
+
* @param config 待合并的元素偏好片段
|
|
38
|
+
*/
|
|
39
|
+
setItem(config: Partial<ItemPreferences>): void;
|
|
40
|
+
/** 导出功能偏好 */
|
|
41
|
+
get export(): ExportPreferences;
|
|
42
|
+
/**
|
|
43
|
+
* 局部更新导出偏好,与现有值浅合并。
|
|
44
|
+
*
|
|
45
|
+
* @param config 待合并的字段
|
|
46
|
+
*/
|
|
47
|
+
setExport(config: Partial<ExportPreferences>): void;
|
|
48
|
+
/** 截图功能偏好 */
|
|
49
|
+
get screenshot(): ScreenshotPreferences;
|
|
50
|
+
/**
|
|
51
|
+
* 局部更新截图偏好,与现有值浅合并。
|
|
52
|
+
*
|
|
53
|
+
* @param config 待合并的字段
|
|
54
|
+
*/
|
|
55
|
+
setScreenshot(config: Partial<ScreenshotPreferences>): void;
|
|
56
|
+
/** 尺寸自适应偏好 */
|
|
57
|
+
get sizeAdapt(): SizeAdaptPreferences;
|
|
58
|
+
/**
|
|
59
|
+
* 局部更新尺寸自适应偏好,与现有值浅合并。
|
|
60
|
+
*
|
|
61
|
+
* @param config 待合并的字段
|
|
62
|
+
*/
|
|
63
|
+
setSizeAdapt(config: Partial<SizeAdaptPreferences>): void;
|
|
64
|
+
/** 异步加载偏好 */
|
|
65
|
+
get asyncLoad(): AsyncLoadPreferences;
|
|
66
|
+
/**
|
|
67
|
+
* 局部更新异步加载偏好,与现有值浅合并。
|
|
68
|
+
*
|
|
69
|
+
* @param config 待合并的字段
|
|
70
|
+
*/
|
|
71
|
+
setAsyncLoad(config: Partial<AsyncLoadPreferences>): void;
|
|
72
|
+
/**
|
|
73
|
+
* 注册单个卡片类型(已存在则忽略)。
|
|
74
|
+
*
|
|
75
|
+
* @param cardTypeConfig 卡片类型配置
|
|
76
|
+
* @returns 是否注册成功(type 已存在时返回 false)
|
|
77
|
+
*/
|
|
78
|
+
registerCardType(cardTypeConfig: CardTypeConfig): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* 批量注册卡片类型。
|
|
81
|
+
*
|
|
82
|
+
* @param configs 卡片类型配置数组
|
|
83
|
+
* @returns 成功注册的数量
|
|
84
|
+
*/
|
|
85
|
+
registerCardTypes(configs: CardTypeConfig[]): number;
|
|
86
|
+
/**
|
|
87
|
+
* 注销卡片类型。
|
|
88
|
+
*
|
|
89
|
+
* @param type 卡片类型标识
|
|
90
|
+
* @returns 是否注销成功(type 不存在时返回 false)
|
|
91
|
+
*/
|
|
92
|
+
unregisterCardType(type: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* 获取所有已注册的卡片类型(只读副本)。
|
|
95
|
+
*
|
|
96
|
+
* @returns 卡片类型配置数组的浅拷贝
|
|
97
|
+
*/
|
|
98
|
+
getRegisteredCardTypes(): CardTypeConfig[];
|
|
99
|
+
/**
|
|
100
|
+
* 判断卡片类型是否已注册。
|
|
101
|
+
*
|
|
102
|
+
* @param type 卡片类型标识
|
|
103
|
+
* @returns 是否已注册
|
|
104
|
+
*/
|
|
105
|
+
isCardTypeRegistered(type: string): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* 获取完整偏好设置。
|
|
108
|
+
*
|
|
109
|
+
* @returns 当前全量偏好对象
|
|
110
|
+
*/
|
|
111
|
+
getPreferences(): UserPreferences;
|
|
112
|
+
/**
|
|
113
|
+
* 批量更新偏好设置,在现有偏好基础上重新合并默认值。
|
|
114
|
+
*
|
|
115
|
+
* @param preferences 待合并的偏好片段
|
|
116
|
+
*/
|
|
117
|
+
setPreferences(preferences: Partial<UserPreferences>): void;
|
|
118
|
+
/**
|
|
119
|
+
* 重置为默认配置
|
|
120
|
+
*/
|
|
121
|
+
reset(): void;
|
|
122
|
+
/**
|
|
123
|
+
* 将局部偏好与默认值合并,未传字段回退到默认。
|
|
124
|
+
*
|
|
125
|
+
* @param partial 局部偏好片段(可选)
|
|
126
|
+
* @param base 合并基底(可选,缺省时使用深拷贝的默认偏好)
|
|
127
|
+
* @returns 合并后的完整偏好
|
|
128
|
+
*/
|
|
129
|
+
private mergeDefaults;
|
|
130
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ErrorMonitor } from './error-monitor';
|
|
2
|
+
import type { ErrorMonitorCallback, VariantErrorSnapshot } from './types';
|
|
3
|
+
import type { HistoryManager } from '../../history';
|
|
4
|
+
import type { CommandService } from '../../command';
|
|
5
|
+
import type { Selection } from '@vvfx/gizmo';
|
|
6
|
+
import type { ViewService } from '../../service';
|
|
7
|
+
import type { ItemService } from '../../service';
|
|
8
|
+
import type { Renderer } from '../../renderer';
|
|
9
|
+
import type { GestureHandler } from '@vvfx/gizmo';
|
|
10
|
+
/**
|
|
11
|
+
* 被监控实例的最小结构:可按方法名读取/覆写方法(用于高阶函数包装)。
|
|
12
|
+
* BaseArtis 实例结构化兼容,传入时显式 cast 即可。
|
|
13
|
+
*/
|
|
14
|
+
export type ErrorMonitorFacadeTarget = Record<string, ((...args: any[]) => unknown) | undefined>;
|
|
15
|
+
/**
|
|
16
|
+
* ErrorMonitorFacade 装配所需的最小上下文:核心只读服务 + 被监控实例。
|
|
17
|
+
*
|
|
18
|
+
* selection 由 GizmoManager 装配后才存在,且 enableErrorMonitor 可在 run 之前调用,
|
|
19
|
+
* 故以 getter 注入(在读取选中态时按需求值,避免提前访问未装配的 GizmoManager)。
|
|
20
|
+
*/
|
|
21
|
+
export type ErrorMonitorContext = {
|
|
22
|
+
readonly historyManager: HistoryManager;
|
|
23
|
+
readonly commandService: CommandService;
|
|
24
|
+
readonly getSelection: () => Selection | undefined;
|
|
25
|
+
readonly viewService: ViewService;
|
|
26
|
+
readonly itemService: ItemService;
|
|
27
|
+
readonly container: HTMLElement;
|
|
28
|
+
readonly renderer: Renderer;
|
|
29
|
+
readonly gestureHandler: GestureHandler;
|
|
30
|
+
readonly target: ErrorMonitorFacadeTarget;
|
|
31
|
+
/**
|
|
32
|
+
* 取变体专属错误快照(variant tag + 对应形态 snapshot),由 Artis / SceneArtis 上下文注入。
|
|
33
|
+
* 基类不注入。供 ErrorMonitor 在 capture 时按 tag 合并出含子类专属字段的完整快照。
|
|
34
|
+
* 失败 / 缺省时返回 undefined,artisVariant 兜底为 'Artis'、变体字段缺省。
|
|
35
|
+
*/
|
|
36
|
+
readonly getArtisErrorSnapshot?: () => VariantErrorSnapshot | undefined;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* ErrorMonitorFacade - 错误监控门面协作者。
|
|
40
|
+
*
|
|
41
|
+
* 从 BaseArtis 抽离,承载 ErrorMonitor 的创建、注入、渲染错误监听与公开方法包装。
|
|
42
|
+
* 重复 enable 只更新回调,不重复注入监控器 / 不重复包装方法。
|
|
43
|
+
*/
|
|
44
|
+
export declare class ErrorMonitorFacade {
|
|
45
|
+
private readonly ctx;
|
|
46
|
+
private _monitor?;
|
|
47
|
+
private _methodsWrapped;
|
|
48
|
+
constructor(ctx: ErrorMonitorContext);
|
|
49
|
+
/** 底层 ErrorMonitor(供 StabilityFacade 注入节流前错误钩子;未开启时为 undefined) */
|
|
50
|
+
get monitor(): ErrorMonitor | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* 开启错误监控:创建 ErrorMonitor → 注入 CommandService/GestureHandler →
|
|
53
|
+
* 绑定渲染错误监听 → 包装门面层公开方法。重复调用仅更新回调。
|
|
54
|
+
* @param callback 错误上报回调
|
|
55
|
+
*/
|
|
56
|
+
enable(callback: ErrorMonitorCallback): void;
|
|
57
|
+
/**
|
|
58
|
+
* 尝试绑定 Player 渲染错误监听。
|
|
59
|
+
* 在 enable 与 run(renderer 就绪)阶段各调一次,确保两种调用顺序都能正确绑定。
|
|
60
|
+
*/
|
|
61
|
+
tryBindRendererErrorListener(): void;
|
|
62
|
+
/**
|
|
63
|
+
* 销毁监控器(清除节流记录与回调引用)。
|
|
64
|
+
*/
|
|
65
|
+
dispose(): void;
|
|
66
|
+
/** 若监控器与 Player 已就绪,则绑定渲染错误监听;否则安全跳过。 */
|
|
67
|
+
private _tryBindRendererErrorListener;
|
|
68
|
+
/**
|
|
69
|
+
* 使用高阶函数包装门面层公开方法,报错时自动上报 ErrorMonitor。
|
|
70
|
+
* 包装后方法行为不变(错误继续向上抛),仅额外触发 monitor.report。
|
|
71
|
+
*/
|
|
72
|
+
private _wrapPublicMethods;
|
|
73
|
+
}
|