@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.
Files changed (224) hide show
  1. package/LICENSE +22 -0
  2. package/dist/artis/artis.d.ts +44 -0
  3. package/dist/artis/base-artis.d.ts +520 -0
  4. package/dist/artis/canvas-layer-order.d.ts +19 -0
  5. package/dist/artis/create-info-to-schema.d.ts +21 -0
  6. package/dist/artis/index.d.ts +15 -0
  7. package/dist/artis/operations/index.d.ts +3 -0
  8. package/dist/artis/operations/operations.d.ts +362 -0
  9. package/dist/artis/operations/scene-operations.d.ts +26 -0
  10. package/dist/artis/operations/types.d.ts +39 -0
  11. package/dist/artis/scene-artis.d.ts +386 -0
  12. package/dist/artis/screenshot-service.d.ts +83 -0
  13. package/dist/artis/types.d.ts +130 -0
  14. package/dist/artis/wiring/index.d.ts +17 -0
  15. package/dist/artis/wiring/register-commands.d.ts +44 -0
  16. package/dist/artis/wiring/setup-commands.d.ts +5 -0
  17. package/dist/artis/wiring/setup-event-bindings.d.ts +16 -0
  18. package/dist/artis/wiring/setup-keybindings.d.ts +38 -0
  19. package/dist/artis/wiring/setup-plugins.d.ts +5 -0
  20. package/dist/artis/wiring/wiring-context.d.ts +34 -0
  21. package/dist/artis-sdk/artis-sdk.d.ts +1117 -0
  22. package/dist/artis-sdk/index.d.ts +1 -0
  23. package/dist/core/asset/asset-manager.d.ts +288 -0
  24. package/dist/core/asset/index.d.ts +3 -0
  25. package/dist/core/command/command-service.d.ts +315 -0
  26. package/dist/core/command/commands/composite-command.d.ts +45 -0
  27. package/dist/core/command/commands/frame-layout-command.d.ts +81 -0
  28. package/dist/core/command/commands/frame-layout-mode-command.d.ts +55 -0
  29. package/dist/core/command/commands/frame-move-in-command.d.ts +54 -0
  30. package/dist/core/command/commands/frame-move-out-command.d.ts +54 -0
  31. package/dist/core/command/commands/group-children-detach-command.d.ts +28 -0
  32. package/dist/core/command/commands/index.d.ts +98 -0
  33. package/dist/core/command/commands/item-align-command.d.ts +52 -0
  34. package/dist/core/command/commands/item-create-command.d.ts +66 -0
  35. package/dist/core/command/commands/item-delete-command.d.ts +40 -0
  36. package/dist/core/command/commands/item-distribute-command.d.ts +53 -0
  37. package/dist/core/command/commands/item-group-command.d.ts +41 -0
  38. package/dist/core/command/commands/item-reorder-command.d.ts +41 -0
  39. package/dist/core/command/commands/item-replace-source-command.d.ts +48 -0
  40. package/dist/core/command/commands/item-set-font-family-command.d.ts +46 -0
  41. package/dist/core/command/commands/item-set-generator-resource-command.d.ts +40 -0
  42. package/dist/core/command/commands/item-transform-command.d.ts +51 -0
  43. package/dist/core/command/commands/item-ungroup-command.d.ts +34 -0
  44. package/dist/core/command/commands/item-update-property-by-create-info-command.d.ts +41 -0
  45. package/dist/core/command/commands/item-update-property-command.d.ts +82 -0
  46. package/dist/core/command/commands/mask-commit-command.d.ts +53 -0
  47. package/dist/core/command/commands/page-auto-layout-command.d.ts +53 -0
  48. package/dist/core/command/commands/picture-cut-commit-command.d.ts +43 -0
  49. package/dist/core/command/commands/picture-expand-commit-command.d.ts +35 -0
  50. package/dist/core/command/commands/scene-switch-command.d.ts +35 -0
  51. package/dist/core/command/commands/selection-set-command.d.ts +38 -0
  52. package/dist/core/command/commands/sprite-image-command.d.ts +36 -0
  53. package/dist/core/command/commands/sprite-text-edit-commit-command.d.ts +43 -0
  54. package/dist/core/command/commands/state-hand-command.d.ts +14 -0
  55. package/dist/core/command/commands/state-image-cut-command.d.ts +14 -0
  56. package/dist/core/command/commands/state-image-expand-command.d.ts +14 -0
  57. package/dist/core/command/commands/state-image-mask-command.d.ts +15 -0
  58. package/dist/core/command/commands/state-image-text-edit-command.d.ts +14 -0
  59. package/dist/core/command/commands/state-item-create-command.d.ts +34 -0
  60. package/dist/core/command/commands/state-move-command.d.ts +14 -0
  61. package/dist/core/command/commands/state-switch-command-base.d.ts +41 -0
  62. package/dist/core/command/commands/text-move-command.d.ts +47 -0
  63. package/dist/core/command/commands/text-rotate-command.d.ts +52 -0
  64. package/dist/core/command/commands/text-scale-command.d.ts +56 -0
  65. package/dist/core/command/commands/text-update-content-command.d.ts +51 -0
  66. package/dist/core/command/commands/transform-move-command.d.ts +56 -0
  67. package/dist/core/command/commands/transform-move-with-frame-change-command.d.ts +80 -0
  68. package/dist/core/command/commands/transform-move-with-layout-command.d.ts +56 -0
  69. package/dist/core/command/commands/transform-rotate-command.d.ts +51 -0
  70. package/dist/core/command/commands/transform-scale-command.d.ts +54 -0
  71. package/dist/core/command/commands/video-play-command.d.ts +28 -0
  72. package/dist/core/command/commands/video-source-command.d.ts +39 -0
  73. package/dist/core/command/commands/viewport-fit-to-box-command.d.ts +37 -0
  74. package/dist/core/command/commands/viewport-fit-to-items-command.d.ts +43 -0
  75. package/dist/core/command/commands/viewport-move-command.d.ts +34 -0
  76. package/dist/core/command/commands/viewport-zoom-command.d.ts +35 -0
  77. package/dist/core/command/index.d.ts +5 -0
  78. package/dist/core/command/registry.d.ts +246 -0
  79. package/dist/core/command/types.d.ts +124 -0
  80. package/dist/core/element-registry/element-facade.d.ts +35 -0
  81. package/dist/core/element-registry/element-identity-strategy.d.ts +75 -0
  82. package/dist/core/element-registry/element-registry.d.ts +72 -0
  83. package/dist/core/element-registry/index.d.ts +5 -0
  84. package/dist/core/element-registry/types.d.ts +15 -0
  85. package/dist/core/gizmo/gizmo-bootstrap.d.ts +70 -0
  86. package/dist/core/gizmo/gizmo-command-binder.d.ts +55 -0
  87. package/dist/core/gizmo/gizmo-config-override.d.ts +24 -0
  88. package/dist/core/gizmo/gizmo-registry.d.ts +39 -0
  89. package/dist/core/gizmo/index.d.ts +19 -0
  90. package/dist/core/gizmo/register-gizmo-command-bindings.d.ts +20 -0
  91. package/dist/core/gizmo/state-gizmo-controller.d.ts +20 -0
  92. package/dist/core/history/history-manager.d.ts +174 -0
  93. package/dist/core/history/index.d.ts +1 -0
  94. package/dist/core/index.d.ts +25 -0
  95. package/dist/core/item/base-item.d.ts +154 -0
  96. package/dist/core/item/card-item.d.ts +91 -0
  97. package/dist/core/item/default-item-schema.d.ts +20 -0
  98. package/dist/core/item/effects-item.d.ts +99 -0
  99. package/dist/core/item/frame-item.d.ts +153 -0
  100. package/dist/core/item/generator-item.d.ts +114 -0
  101. package/dist/core/item/group-item.d.ts +51 -0
  102. package/dist/core/item/index.d.ts +25 -0
  103. package/dist/core/item/sprite-item.d.ts +80 -0
  104. package/dist/core/item/text-item.d.ts +171 -0
  105. package/dist/core/item/types.d.ts +158 -0
  106. package/dist/core/item/video-item.d.ts +120 -0
  107. package/dist/core/keybinding/index.d.ts +11 -0
  108. package/dist/core/keybinding/key-binding-controller.d.ts +44 -0
  109. package/dist/core/keybinding/key-binding-registry.d.ts +92 -0
  110. package/dist/core/keybinding/key-binding-store.d.ts +29 -0
  111. package/dist/core/keybinding/key-matcher.d.ts +24 -0
  112. package/dist/core/keybinding/types.d.ts +84 -0
  113. package/dist/core/plugin/index.d.ts +3 -0
  114. package/dist/core/plugin/io-plugin.d.ts +167 -0
  115. package/dist/core/plugin/plugin-system.d.ts +77 -0
  116. package/dist/core/predict/align-predict.d.ts +20 -0
  117. package/dist/core/predict/base/box-ops.d.ts +40 -0
  118. package/dist/core/predict/base/index.d.ts +14 -0
  119. package/dist/core/predict/base/parent-coord.d.ts +29 -0
  120. package/dist/core/predict/base/schema-box.d.ts +21 -0
  121. package/dist/core/predict/distribute-predict.d.ts +19 -0
  122. package/dist/core/predict/frame-layout-predict.d.ts +24 -0
  123. package/dist/core/predict/index.d.ts +12 -0
  124. package/dist/core/preferences/index.d.ts +2 -0
  125. package/dist/core/preferences/user-preferences-manager.d.ts +130 -0
  126. package/dist/core/quality/error-monitor/error-monitor-facade.d.ts +73 -0
  127. package/dist/core/quality/error-monitor/error-monitor.d.ts +106 -0
  128. package/dist/core/quality/error-monitor/index.d.ts +4 -0
  129. package/dist/core/quality/error-monitor/types.d.ts +198 -0
  130. package/dist/core/quality/index.d.ts +3 -0
  131. package/dist/core/quality/perf-monitor/index.d.ts +5 -0
  132. package/dist/core/quality/perf-monitor/perf-monitor-facade.d.ts +45 -0
  133. package/dist/core/quality/perf-monitor/perf-monitor.d.ts +60 -0
  134. package/dist/core/quality/perf-monitor/types.d.ts +66 -0
  135. package/dist/core/quality/stability-monitor/index.d.ts +5 -0
  136. package/dist/core/quality/stability-monitor/stability-monitor-facade.d.ts +50 -0
  137. package/dist/core/quality/stability-monitor/stability-monitor.d.ts +61 -0
  138. package/dist/core/quality/stability-monitor/types.d.ts +69 -0
  139. package/dist/core/renderer/background-controller.d.ts +56 -0
  140. package/dist/core/renderer/index.d.ts +5 -0
  141. package/dist/core/renderer/player-adapter.d.ts +129 -0
  142. package/dist/core/renderer/renderer.d.ts +134 -0
  143. package/dist/core/service/frame-service.d.ts +116 -0
  144. package/dist/core/service/index.d.ts +9 -0
  145. package/dist/core/service/interaction-providers.d.ts +20 -0
  146. package/dist/core/service/interaction-service.d.ts +211 -0
  147. package/dist/core/service/item-asset-service.d.ts +120 -0
  148. package/dist/core/service/item-creator-service.d.ts +211 -0
  149. package/dist/core/service/item-service.d.ts +641 -0
  150. package/dist/core/service/item-sync-service.d.ts +66 -0
  151. package/dist/core/service/json-scene-sync-service.d.ts +140 -0
  152. package/dist/core/service/refresh-animation-base-service.d.ts +1 -0
  153. package/dist/core/service/scene-data-assembler.d.ts +166 -0
  154. package/dist/core/service/view-service.d.ts +202 -0
  155. package/dist/core/state/base-state.d.ts +28 -0
  156. package/dist/core/state/index.d.ts +6 -0
  157. package/dist/core/state/presets.d.ts +25 -0
  158. package/dist/core/state/state-manager.d.ts +50 -0
  159. package/dist/core/state/types.d.ts +52 -0
  160. package/dist/core/store/index.d.ts +3 -0
  161. package/dist/core/store/scene-store.d.ts +194 -0
  162. package/dist/core/store/store.d.ts +36 -0
  163. package/dist/core/types/artis-config.d.ts +186 -0
  164. package/dist/core/types/artis-events.d.ts +101 -0
  165. package/dist/core/types/frame.d.ts +3 -0
  166. package/dist/core/types/generator.d.ts +28 -0
  167. package/dist/core/types/index.d.ts +15 -0
  168. package/dist/core/types/item-create-info.d.ts +205 -0
  169. package/dist/core/types/item-property.d.ts +149 -0
  170. package/dist/core/types/item-reorder.d.ts +12 -0
  171. package/dist/core/types/item-schema.d.ts +263 -0
  172. package/dist/core/types/item-set-property.d.ts +48 -0
  173. package/dist/core/types/page.d.ts +40 -0
  174. package/dist/core/types/sdk.d.ts +28 -0
  175. package/dist/core/types/view.d.ts +39 -0
  176. package/dist/helper/exporter/config.d.ts +18 -0
  177. package/dist/helper/exporter/const.d.ts +71 -0
  178. package/dist/helper/exporter/export-media.d.ts +189 -0
  179. package/dist/helper/exporter/exporter.d.ts +58 -0
  180. package/dist/helper/exporter/index.d.ts +2 -0
  181. package/dist/helper/exporter/types.d.ts +194 -0
  182. package/dist/helper/exporter/utils.d.ts +71 -0
  183. package/dist/helper/exporter/wav-audio.d.ts +35 -0
  184. package/dist/helper/html-overlay/anchor-navigation-runtime.d.ts +1 -0
  185. package/dist/helper/html-overlay/auto-height-layout.d.ts +16 -0
  186. package/dist/helper/html-overlay/auto-height-runtime.d.ts +40 -0
  187. package/dist/helper/html-overlay/document-runtime.d.ts +18 -0
  188. package/dist/helper/html-overlay/document-transform.d.ts +46 -0
  189. package/dist/helper/html-overlay/dom-order.d.ts +5 -0
  190. package/dist/helper/html-overlay/host-message-runtime.d.ts +15 -0
  191. package/dist/helper/html-overlay/html-capture-runtime.d.ts +12 -0
  192. package/dist/helper/html-overlay/html-card-service.d.ts +287 -0
  193. package/dist/helper/html-overlay/html-viewport-style.d.ts +6 -0
  194. package/dist/helper/html-overlay/index.d.ts +1 -0
  195. package/dist/helper/html-overlay/inline-script-json.d.ts +1 -0
  196. package/dist/helper/html-overlay/mime-utils.d.ts +13 -0
  197. package/dist/helper/html-overlay/overlay-transform.d.ts +30 -0
  198. package/dist/helper/html-overlay/path-utils.d.ts +34 -0
  199. package/dist/helper/html-overlay/runtime-context.d.ts +2 -0
  200. package/dist/helper/html-overlay/shell-runtime.d.ts +13 -0
  201. package/dist/helper/index.d.ts +5 -0
  202. package/dist/helper/scene-builder.d.ts +111 -0
  203. package/dist/helper/screen-shot.d.ts +51 -0
  204. package/dist/helper/size-adapt.d.ts +88 -0
  205. package/dist/index.cjs +69350 -0
  206. package/dist/index.cjs.map +1 -0
  207. package/dist/index.d.ts +19 -0
  208. package/dist/index.mjs +68963 -0
  209. package/dist/index.mjs.map +1 -0
  210. package/dist/shared/index.d.ts +1 -0
  211. package/dist/shared/player.d.ts +9 -0
  212. package/dist/utils/background-manager.d.ts +76 -0
  213. package/dist/utils/common-utils.d.ts +39 -0
  214. package/dist/utils/container-size.d.ts +7 -0
  215. package/dist/utils/find-player-item.d.ts +9 -0
  216. package/dist/utils/index.d.ts +11 -0
  217. package/dist/utils/json-data-utils.d.ts +198 -0
  218. package/dist/utils/layout-utils.d.ts +144 -0
  219. package/dist/utils/pixel-box-utils.d.ts +26 -0
  220. package/dist/utils/player-data-utils.d.ts +9 -0
  221. package/dist/utils/player-utils.d.ts +42 -0
  222. package/dist/utils/replay-utils.d.ts +22 -0
  223. package/dist/utils/types.d.ts +130 -0
  224. package/package.json +66 -0
@@ -0,0 +1 @@
1
+ export { ArtisSDK } from './artis-sdk';
@@ -0,0 +1,288 @@
1
+ import type { Texture } from '../../shared';
2
+ import { spec } from '../../shared';
3
+ import type { Disposable } from '../types';
4
+ /**
5
+ * 资源类型标识
6
+ */
7
+ export declare enum AssetType {
8
+ IMAGE = "image",
9
+ VIDEO = "video",
10
+ AUDIO = "audio",
11
+ FONT = "font",
12
+ EFFECT = "effect"
13
+ }
14
+ /**
15
+ * 资源加载状态
16
+ */
17
+ export declare enum AssetLoadState {
18
+ PENDING = "pending",
19
+ LOADING = "loading",
20
+ LOADED = "loaded",
21
+ ERROR = "error"
22
+ }
23
+ /**
24
+ * 资源条目基础字段
25
+ */
26
+ export type BaseAssetEntry = {
27
+ /** 资源唯一 ID */
28
+ id: string;
29
+ /** 资源名称 */
30
+ name: string;
31
+ /** 资源 URL */
32
+ url: string;
33
+ /** 加载状态 */
34
+ state: AssetLoadState;
35
+ /** 引用该资源的元素 ID 列表 */
36
+ users: string[];
37
+ };
38
+ /**
39
+ * 图片资源条目
40
+ * texture 对应 Player 初始化的 GPU ImageTexture
41
+ */
42
+ export type ImageAssetEntry = BaseAssetEntry & {
43
+ type: 'image';
44
+ /** 图片宽度 */
45
+ width: number;
46
+ /** 图片高度 */
47
+ height: number;
48
+ /** GPU ImageTexture(Player 层创建) */
49
+ texture: Texture | null;
50
+ };
51
+ /**
52
+ * 视频资源条目
53
+ * gpuAsset 对应 Player 初始化的 GPU VideoTexture
54
+ */
55
+ export type VideoAssetEntry = BaseAssetEntry & {
56
+ type: 'video';
57
+ /** 视频宽度 */
58
+ width: number;
59
+ /** 视频高度 */
60
+ height: number;
61
+ /** 视频时长(秒) */
62
+ duration: number;
63
+ /** GPU VideoTexture(Player 层创建) */
64
+ gpuAsset: Texture | null;
65
+ };
66
+ /**
67
+ * 音频资源条目
68
+ */
69
+ export type AudioAssetEntry = BaseAssetEntry & {
70
+ type: 'audio';
71
+ /** 音频时长(秒) */
72
+ duration: number;
73
+ };
74
+ /**
75
+ * 字体资源条目
76
+ */
77
+ export type FontAssetEntry = BaseAssetEntry & {
78
+ type: 'font';
79
+ /** 字体家族名 */
80
+ family: string;
81
+ /** 字体是否已注册到文档 */
82
+ registered: boolean;
83
+ };
84
+ /**
85
+ * 特效资源条目
86
+ */
87
+ export type EffectAssetEntry = BaseAssetEntry & {
88
+ type: 'effect';
89
+ /** 特效 JSON 数据(已 patch 主合成 endBehavior 的 JSONScene) */
90
+ effectData: unknown;
91
+ /** 特效主合成尺寸 [w,h](来自解析后 JSON 的主合成 previewSize,兜底 [750,1624]) */
92
+ mainCompositionSize: [number, number];
93
+ };
94
+ /**
95
+ * 资源条目(联合类型,通过 type 区分)
96
+ */
97
+ export type AssetEntry = ImageAssetEntry | VideoAssetEntry | AudioAssetEntry | FontAssetEntry | EffectAssetEntry;
98
+ /**
99
+ * 加载资源的选项
100
+ */
101
+ export type LoadAssetOptions = {
102
+ /** 资源名称(不传则从 URL 推断) */
103
+ name?: string;
104
+ /** 资源类型(不传则从 URL 后缀推断) */
105
+ type?: AssetType;
106
+ /** 图片/视频尺寸 */
107
+ width?: number;
108
+ /** 图片/视频尺寸 */
109
+ height?: number;
110
+ /** 视频/音频时长 */
111
+ duration?: number;
112
+ /** 字体家族名 */
113
+ fontFamily?: string;
114
+ /** 特效 JSON 数据 */
115
+ effectData?: unknown;
116
+ /** 特效主合成尺寸 */
117
+ mainCompositionSize?: [number, number];
118
+ /** GPU Texture(由 Player 层传入) */
119
+ texture?: Texture;
120
+ };
121
+ /**
122
+ * AssetManager - 资源管理器
123
+ *
124
+ * 职责:
125
+ * 1. 资源的注册/加载/卸载生命周期管理
126
+ * 2. 资源与元素的绑定关系维护
127
+ * 3. 引用计数,无引用时可选自动卸载
128
+ * 4. GPU Texture 的持有与释放
129
+ */
130
+ export declare class AssetManager implements Disposable {
131
+ private _assets;
132
+ private _elementBindings;
133
+ /**
134
+ * 注册并加载资源,按类型构造条目并写入资源表。
135
+ *
136
+ * @param url 资源 URL
137
+ * @param options 加载选项(类型/尺寸/Texture 等,缺省时按 URL 推断类型)
138
+ * @returns 新建的资源 ID
139
+ */
140
+ registerAsset(url: string, options?: LoadAssetOptions): string;
141
+ /**
142
+ * 加载特效资源(URL → fetch → 解析 → patch 主合成 endBehavior → 缓存)。
143
+ *
144
+ * - URL 命中已 LOADED 条目则直接复用(切换同 URL 不重复 fetch)。
145
+ * - 否则 fetch + json 解析:取主合成 previewSize 作 mainCompositionSize;
146
+ * patch 主合成 endBehavior(forward 无限 / restart 重播 不动;destroy / freeze → restart)。
147
+ * - patch 存于条目 effectData;patch 幂等(forward/restart 不变),多元素共享同 URL 安全。
148
+ * - 状态机推进:LOADING → LOADED(成功)/ ERROR(失败,抛出且不残留半成品条目)。
149
+ *
150
+ * @param url 特效文件 URL
151
+ * @returns 已加载的特效资源条目(effectData 为 patched JSONScene,mainCompositionSize 为主合成尺寸)
152
+ */
153
+ loadEffectAsset(url: string): Promise<EffectAssetEntry>;
154
+ /**
155
+ * 按 URL 查找已加载(LOADED)的特效资源。
156
+ *
157
+ * 与 {@link findLoadedAssetByUrl} 对齐,补 effect 分支,供 loadEffectAsset 命中复用。
158
+ * @param url 特效文件 URL
159
+ * @returns 命中的特效条目;未命中或仍在加载中返回 undefined
160
+ */
161
+ findLoadedEffectByUrl(url: string): EffectAssetEntry | undefined;
162
+ /**
163
+ * 取特效 JSONScene 的主合成尺寸 [w,h]。
164
+ *
165
+ * 主合成 = compositionId 命中或 compositions[0];尺寸取其 previewSize。
166
+ * 无有效 previewSize 时兜底 [750,1624](对齐 artis-sdk.ts 的 previewSize 兜底)。
167
+ * @param scene 特效 JSONScene
168
+ * @returns [width, height]
169
+ */
170
+ getMainCompositionSize(scene: spec.JSONScene): [number, number];
171
+ /**
172
+ * 解析主合成:compositionId 命中或 compositions[0]。
173
+ */
174
+ private _findMainComposition;
175
+ /**
176
+ * 卸载资源,释放其持有的 GPU Texture 并清理与元素的绑定关系
177
+ *
178
+ * @param assetId 资源 ID
179
+ * 边界:资源不存在时直接返回
180
+ */
181
+ unloadAsset(assetId: string): void;
182
+ /**
183
+ * 按 ID 获取资源条目。
184
+ *
185
+ * @param assetId 资源 ID
186
+ * @returns 资源条目;未找到返回 undefined
187
+ */
188
+ getAsset(assetId: string): AssetEntry | undefined;
189
+ /**
190
+ * 按 URL 查找已加载且持有 GPU Texture 的资源
191
+ *
192
+ * 用于资源复用:创建/修改带资源的元素时,若相同 URL 的 Texture 已存在,
193
+ * 可直接复用,避免重复加载。
194
+ *
195
+ * @param url 资源 URL
196
+ * @param type 资源类型(image / video)
197
+ * @returns 命中的资源条目;未命中返回 undefined
198
+ */
199
+ findLoadedAssetByUrl(url: string, type: 'image' | 'video'): ImageAssetEntry | VideoAssetEntry | undefined;
200
+ /**
201
+ * 获取指定类型的全部资源
202
+ *
203
+ * @param type 资源类型
204
+ * @returns 该类型对应的资源条目数组(类型收窄到对应联合分支)
205
+ */
206
+ getAssetsByType<T extends AssetType>(type: T): Extract<AssetEntry, {
207
+ type: T;
208
+ }>[];
209
+ /**
210
+ * 获取所有资源条目(含已加载与加载中)。
211
+ *
212
+ * @returns 全部资源条目数组
213
+ */
214
+ getAllAssets(): AssetEntry[];
215
+ /**
216
+ * 绑定资源到元素,建立 element→asset 引用关系
217
+ *
218
+ * @param assetId 资源 ID
219
+ * @param elementId 元素 ID
220
+ * 边界:重复绑定不会重复添加 users;资源不存在时只记录绑定关系
221
+ */
222
+ bindAssetToElement(assetId: string, elementId: string): void;
223
+ /**
224
+ * 解绑元素的所有资源,移除该元素的全部绑定关系
225
+ *
226
+ * @param elementId 元素 ID
227
+ */
228
+ unbindElement(elementId: string): void;
229
+ /**
230
+ * 解绑元素的指定资源
231
+ *
232
+ * @param assetId 资源 ID
233
+ * @param elementId 元素 ID
234
+ * 边界:绑定集合清空后会移除该元素的绑定条目
235
+ */
236
+ unbindAssetFromElement(assetId: string, elementId: string): void;
237
+ /**
238
+ * 获取元素绑定的所有资源
239
+ *
240
+ * @param elementId 元素 ID
241
+ * @returns 资源条目数组;元素无绑定时返回空数组
242
+ */
243
+ getAssetsByElementId(elementId: string): AssetEntry[];
244
+ /**
245
+ * 获取无引用的资源列表(users 为空,可用于手动清理)。
246
+ *
247
+ * @returns 无引用资源条目数组
248
+ */
249
+ getUnusedAssets(): AssetEntry[];
250
+ /**
251
+ * 清理无引用的资源(释放 GPU Texture 并移除条目)。
252
+ *
253
+ * @param type 可选资源类型过滤;传 EFFECT 时仅释放特效 JSON 缓存,不触碰 image/video 纹理。
254
+ * 元素删除时按类型 purge,避免误伤仍可能被外部引用的纹理。
255
+ */
256
+ purgeUnused(type?: AssetType): void;
257
+ /**
258
+ * 更新资源的 GPU Texture(Player 重建场景后需要重新绑定)
259
+ *
260
+ * @param assetId 资源 ID
261
+ * @param texture 新的 Texture
262
+ * 边界:仅 image / video 类型生效;资源不存在时直接返回
263
+ */
264
+ updateTexture(assetId: string, texture: Texture): void;
265
+ /**
266
+ * 销毁,释放所有资源
267
+ */
268
+ dispose(): void;
269
+ /**
270
+ * 释放资源持有的 GPU Texture,仅对 image / video 类型生效。
271
+ *
272
+ * @param asset 资源条目
273
+ */
274
+ private releaseGpuResource;
275
+ /**
276
+ * 生成唯一资源 ID。
277
+ *
278
+ * @returns 形如 asset_<timestamp>_<rand> 的 ID 字符串
279
+ */
280
+ private generateId;
281
+ /**
282
+ * 根据 URL 后缀推断资源类型,无法识别时回退为 EFFECT。
283
+ *
284
+ * @param url 资源 URL
285
+ * @returns 推断出的资源类型
286
+ */
287
+ private inferType;
288
+ }
@@ -0,0 +1,3 @@
1
+ export { AssetManager } from './asset-manager';
2
+ export { AssetType, AssetLoadState } from './asset-manager';
3
+ export type { BaseAssetEntry, ImageAssetEntry, VideoAssetEntry, AudioAssetEntry, FontAssetEntry, EffectAssetEntry, AssetEntry, LoadAssetOptions, } from './asset-manager';
@@ -0,0 +1,315 @@
1
+ import type { HistoryManager } from '../history';
2
+ import type { Command, CommandFactory, CommandLifecycleEvent } from './types';
3
+ import type { CommandRegistry } from './registry';
4
+ import type { AnyArtisErrorInfo, ErrorMonitor, ErrorPhase } from '../quality/error-monitor';
5
+ /**
6
+ * Command 执行前置守卫:(commandId, args) => void;抛错即拒绝执行。
7
+ * 供 artis 注入「忽略交互」等前置校验,在 Command 创建并执行前调用。
8
+ *
9
+ * args 为<b>单参对象</b>(与执行/注册入口同源,形状由 CommandRegistry 反推),守卫侧按具名字段
10
+ * 提取目标元素 id 等(如 args.itemId / args.itemIds)。
11
+ */
12
+ export type CommandGuard = (commandId: string, args: unknown) => void;
13
+ /** Command 失败事件出口;返回已捕获载荷供 ErrorMonitor 复用,避免重复抓取快照。 */
14
+ export type CommandErrorEventHandler = (error: unknown, phase: ErrorPhase, ctx: {
15
+ commandId: string;
16
+ }) => AnyArtisErrorInfo | undefined;
17
+ /**
18
+ * CommandService - 指令服务中心
19
+ *
20
+ * 所有数据修改必须通过指令执行,支持:
21
+ * 1. 注册/注销 Command 工厂
22
+ * 2. 执行 Command 并自动注入 History
23
+ * 3. 交互态(beginInteraction / updateInteraction / endInteraction):
24
+ * 拖拽过程中持续修改同一个 Command,交互结束后才加入 History
25
+ * 4. 批量态(beginBatch / endBatch / cancelBatch):
26
+ * 单次交互产生的多个 record 子 Command 聚合为一个历史条目,统一 undo/redo
27
+ */
28
+ export declare class CommandService {
29
+ private _factories;
30
+ private _historyManager;
31
+ /** 交互态中的 Command(尚未入 History) */
32
+ private _interactionCommand;
33
+ /** 是否正在交互态中 */
34
+ private _isInInteraction;
35
+ /** Command 执行后的回调集合(用于刷新 Store 数据等) */
36
+ private _afterExecuteCallbacks;
37
+ /**
38
+ * Command 生命周期事件订阅集合(中央监听,多订阅)。
39
+ *
40
+ * 统一覆盖 execute/undo/redo 三时机:execute 侧由 {@link _triggerAfterExecute} 同点发,
41
+ * undo/redo 侧桥接 {@link HistoryManager.addOnChange}(command-service 构造时订阅)。
42
+ * 横切订阅者(埋点/自动保存/UI 刷新)经此一处即可,无需分别订 afterExecute + history。
43
+ */
44
+ private _lifecycleListeners;
45
+ /** 桥接 history change → lifecycle 的订阅 dispose(dispose 时移除,避免泄漏) */
46
+ private _disposeHistoryBridge;
47
+ /** 是否正在批量态中(record 的子命令会被缓冲,endBatch 时统一入 History) */
48
+ private _isInBatch;
49
+ /** 批量态缓冲的子 Command */
50
+ private _batchBuffer;
51
+ /**
52
+ * 批量态是否挂起了 afterExecute 回调。
53
+ *
54
+ * 批量态下各子命令不再逐个触发 afterExecute(此前 N 个 record 让 syncAllItemsFromPlayer /
55
+ * JSON 回写同帧跑 N 次——D5),改为在 endBatch 时用聚合后的代表命令(composite 或单子)
56
+ * 触发一次。安全性:批内数据新鲜度由调用方在子命令间的手动 syncAllItemsFromPlayer 保证
57
+ * (见 register-gizmo-command-bindings onMouseUp),不依赖 afterExecute;现有 afterExecute
58
+ * 订阅者(wiring 同步 / SceneArtis JSON 回写)均忽略 command 入参,为纯 flush,聚合安全。
59
+ */
60
+ private _batchNeedsAfterExecuteFlush;
61
+ /** 错误监控器(按需注入,未注入时不生效) */
62
+ private _errorMonitor?;
63
+ /** 业务错误事件出口(BaseArtis 注入,默认无需 enableErrorMonitor 即可工作) */
64
+ private _errorEventHandler?;
65
+ /** 执行前置守卫(按需注入;创建并执行 Command 前调用,抛错即拒绝执行) */
66
+ private _guard?;
67
+ /** 可编辑守卫(第二前置守卫槽,SceneArtis PlayState 拦编辑类命令;S7) */
68
+ private _editableGuard?;
69
+ /**
70
+ * 构造 CommandService,绑定历史管理器
71
+ *
72
+ * @param historyManager 历史记录管理器,用于 push/undo/redo Command
73
+ */
74
+ constructor(historyManager: HistoryManager);
75
+ /**
76
+ * 设置 Command 执行后的回调(替换式,向后兼容)
77
+ *
78
+ * 会清空已注册的所有 afterExecute 回调,仅保留传入的这一个。
79
+ * 新调用方建议改用 {@link addAfterExecute} / {@link removeAfterExecute} 进行多订阅,
80
+ * 避免新回调无意覆盖既有订阅。
81
+ *
82
+ * 在 execute / endInteraction / record 后触发,用于根据 playerItem 刷新 store 数据。
83
+ *
84
+ * @param callback 执行后回调函数,入参为刚执行的 Command
85
+ */
86
+ setAfterExecute(callback: (command: Command) => void): void;
87
+ /**
88
+ * 追加一个 Command 执行后的回调(多回调中继点)
89
+ *
90
+ * 多个回调按注册顺序依次触发,互不覆盖。返回一个 dispose 函数用于注销该回调,
91
+ * 便于子模块在 dispose 时精确移除自身订阅。
92
+ *
93
+ * @param callback 执行后回调函数,入参为刚执行的 Command
94
+ * @returns 注销函数,调用后移除该回调
95
+ */
96
+ addAfterExecute(callback: (command: Command) => void): () => void;
97
+ /**
98
+ * 移除一个 Command 执行后的回调
99
+ *
100
+ * @param callback 要移除的回调函数
101
+ */
102
+ removeAfterExecute(callback: (command: Command) => void): void;
103
+ /**
104
+ * 订阅 Command 生命周期事件(中央监听,多订阅)。
105
+ *
106
+ * 统一覆盖 execute / undo / redo 三时机,横切订阅者(埋点/自动保存/UI 刷新触发)经此一处即可。
107
+ * execute 侧与 afterExecute 同点触发(含 batch endBatch 聚合后的代表命令);
108
+ * undo/redo 侧桥接 history change。payload 取 {@link Command.eventPayload}(Command 自填)。
109
+ *
110
+ * 与 afterExecute 分轨:afterExecute 驱动内部数据回写管线(syncAllItemsFromPlayer +
111
+ * Player→Store 同步),lifecycle 供外部横切订阅,两者职责不重叠;Gizmo 由原生 pre-render 刷新。
112
+ *
113
+ * @param listener 生命周期事件监听器
114
+ * @returns 注销函数,调用后移除该监听器
115
+ */
116
+ onCommandLifecycle(listener: (event: CommandLifecycleEvent) => void): () => void;
117
+ /** 按 phase 发 lifecycle 事件给全部订阅者,payload 取 command.eventPayload */
118
+ private _emitLifecycle;
119
+ /**
120
+ * 触发所有 afterExecute 回调(按注册顺序)
121
+ *
122
+ * @param command 刚执行/入史的 Command
123
+ */
124
+ private _triggerAfterExecute;
125
+ /**
126
+ * 注入错误监控器(由 Artis.enableErrorMonitor() 调用,未注入时不影响现有行为)
127
+ *
128
+ * @param monitor 错误监控器实例
129
+ */
130
+ setErrorMonitor(monitor?: ErrorMonitor): void;
131
+ /** 注入 Command 业务错误事件出口;与 ErrorMonitor 共用其返回的错误快照。 */
132
+ setErrorEventHandler(handler?: CommandErrorEventHandler): void;
133
+ /**
134
+ * 释放资源:移除构造时桥接 history change → lifecycle 的订阅,避免泄漏。
135
+ *
136
+ * 供 Artis dispose 阶段调用。未调用则在 CommandService 与 HistoryManager 同生命周期
137
+ * 场景下随实例一并回收,无遗留泄漏。
138
+ */
139
+ dispose(): void;
140
+ /**
141
+ * 注入执行前置守卫。守卫在 execute / beginInteraction / updateInteraction 创建并执行
142
+ * Command 前调用,抛错即拒绝执行对应 Command。未注入时不影响现有行为。
143
+ *
144
+ * @param guard 守卫函数,入参为 commandId 与透传给工厂的 args
145
+ */
146
+ setCommandGuard(guard?: CommandGuard): void;
147
+ /**
148
+ * 统一执行前置守卫链:先可编辑守卫(拦截非编辑态的编辑类命令),再命令守卫(ignoredInteraction)。
149
+ * 用于 execute / beginInteraction / updateInteraction 三入口;record 故意不走(post-execution)。
150
+ */
151
+ private _runGuards;
152
+ /**
153
+ * 命令执行异常是否应进入业务错误事件与 errorMonitor。
154
+ *
155
+ * IgnoredInteractionError(code='IGNORED_INTERACTION')是 guard 抛出的业务级「忽略」而非真错误——
156
+ * 上报会污染错误指标,使合法拒绝淹没真异常,故跳过。鸭子判别 code 字段,避免 core 反向
157
+ * import artis 的 IgnoredInteractionError 类。
158
+ */
159
+ private _isReportableCommandError;
160
+ /** 统一发散 Command 真异常:业务事件逐条发,监控通道复用同一快照后自行节流。 */
161
+ private _reportCommandError;
162
+ /**
163
+ * 注入可编辑守卫(第二前置守卫槽,与 setCommandGuard 独立共存)。
164
+ *
165
+ * 同样在 execute / beginInteraction / updateInteraction 三入口创建并执行 Command 前调用
166
+ * (先于 _guard),抛错即拒绝。专供 SceneArtis 在 PlayState 等非编辑态拦截编辑类命令
167
+ * (S7)。**故意不覆盖 record**:record 接收的是 gizmo 已执行完毕的命令,post-execution
168
+ * 守卫无法阻止且抛错会破坏已发生变更。
169
+ *
170
+ * @param guard 可编辑守卫函数;传 undefined 清空(dispose 用)
171
+ */
172
+ setEditableGuard(guard?: CommandGuard): void;
173
+ /**
174
+ * 唯一咽喉:把 Command 入历史栈前统一标注可重放信息。
175
+ *
176
+ * 所有入 History 的路径(execute / endInteraction / record / endBatch 单条与复合)
177
+ * 都经此方法,确保每个进入历史的 Command 都带上 replay 供 ErrorMonitor 快照使用。
178
+ * - Command 实现了 {@link Command.serializeReplay} → 用其纯数据结果(命令最懂自己
179
+ * 累加合并后的真实状态,优先级高于 execute 时按工厂 args 推得的结果)
180
+ * - 否则保留 execute 时按工厂 args 推得的 replay;若两者皆无 → replayable=false
181
+ *
182
+ * @param command 待入历史栈的 Command
183
+ */
184
+ private _pushToHistory;
185
+ /**
186
+ * 注册 Command 工厂(三套强类型入口并存)
187
+ *
188
+ * ① 内置命令走 `<K extends keyof CommandRegistry>` 重载:commandId 经 {@link CommandRegistry}
189
+ * 反推 args 对象形状,factory 收到强类型单参对象;result 也强类型。注册与执行侧均强类型。
190
+ * ② 外部自定义命令走 `<A = unknown>` 泛型重载:`registerCommand<MyArgs>('x', fn)` 或由 TS 从
191
+ * factory 实参反推 `A`,factory 即得强类型入参;不标注时 A 用缺省 `unknown`。**仅约束注册侧**,
192
+ * 执行侧 `execute('x', ...)` 仍兜底 unknown(需 `declare module` 增强 Registry 才两端强类型)。
193
+ * ③ 对外公共命令走 `declare module '@vvfx/artis' { interface CommandRegistry {...} }` 合并:
194
+ * 注册与执行侧均强类型,适合对外暴露给多调用方(见 {@link ./registry.ts} 头部示例)。
195
+ *
196
+ * @param commandId Command 类型 ID
197
+ * @param factory 创建 Command 实例的工厂函数,入参为单参对象
198
+ */
199
+ registerCommand<K extends keyof CommandRegistry>(commandId: K, factory: CommandFactory<CommandRegistry[K]['args']>): void;
200
+ registerCommand<A = unknown>(commandId: string, factory: CommandFactory<A>): void;
201
+ /**
202
+ * 注销 Command
203
+ *
204
+ * @param commandId 要注销的 Command 类型 ID
205
+ */
206
+ unregisterCommand(commandId: string): void;
207
+ /**
208
+ * 执行 Command:创建实例 → execute() → 入 History
209
+ *
210
+ * 批量态下不直接入 History,而是缓冲到 _batchBuffer,
211
+ * 待 endBatch 时聚合为一个历史条目(execute 仍会立即执行以修改数据)。
212
+ *
213
+ * 内置命令走强类型重载:commandId 经 {@link CommandRegistry} 反推 args 对象形状与 result 类型,
214
+ * 调用方获得编译期校验 + IDE 具名提示。外部/动态派发命中 string 兜底重载(args 为 unknown)。
215
+ *
216
+ * @param commandId Command 类型 ID
217
+ * @param args 透传给工厂函数的单参对象
218
+ * @returns 创建并执行后的 Command 实例
219
+ */
220
+ execute<K extends string>(commandId: K, args: K extends keyof CommandRegistry ? CommandRegistry[K]['args'] : unknown): K extends keyof CommandRegistry ? CommandRegistry[K]['result'] : Command;
221
+ /**
222
+ * 开始交互态
223
+ * 创建 Command 并立即执行,但不入 History(等 endInteraction 时再入)
224
+ *
225
+ * 内置命令走强类型重载(commandId 反推 args 对象形状);外部命中 string 兜底。
226
+ *
227
+ * @param commandId Command 类型 ID
228
+ * @param args 透传给工厂函数的单参对象
229
+ * @returns 创建并执行后的交互 Command 实例
230
+ */
231
+ beginInteraction<K extends string>(commandId: K, args: K extends keyof CommandRegistry ? CommandRegistry[K]['args'] : unknown): K extends keyof CommandRegistry ? CommandRegistry[K]['result'] : Command;
232
+ /**
233
+ * 交互态中更新:创建新 Command 尝试合并到当前交互 Command
234
+ * 如果不支持合并,则替换为新 Command
235
+ *
236
+ * 内置命令走强类型重载(commandId 反推 args 对象形状);外部命中 string 兜底。
237
+ *
238
+ * @param commandId Command 类型 ID
239
+ * @param args 透传给工厂函数的单参对象
240
+ * @returns 合并或替换后的交互 Command;非交互态或工厂未注册时返回 undefined
241
+ */
242
+ updateInteraction<K extends string>(commandId: K, args: K extends keyof CommandRegistry ? CommandRegistry[K]['args'] : unknown): (K extends keyof CommandRegistry ? CommandRegistry[K]['result'] : Command) | undefined;
243
+ /**
244
+ * 取消当前交互态(不入 History,撤销已执行的变更)
245
+ * 用于交互中 Command 类型切换场景:先 cancel 旧的,再 begin 新的
246
+ *
247
+ * @returns 被取消的 Command(可用于提取旧数据继承到新 Command),如果无交互态则返回 undefined
248
+ */
249
+ cancelInteraction(): Command | undefined;
250
+ /**
251
+ * 结束交互态,将最终 Command 入 History
252
+ *
253
+ * @returns 入 History 的交互 Command;非交互态时返回 undefined
254
+ */
255
+ endInteraction(): Command | undefined;
256
+ /**
257
+ * 记录已执行的 Command 到 History(不调用 execute)
258
+ *
259
+ * 用于 Gizmo 交互场景:Gizmo 自身已完成数据修改,
260
+ * 此处只需将 Command(含 old/new 快照)入 History 以支持 undo/redo。
261
+ *
262
+ * 批量态下不直接入 History,而是缓冲到 _batchBuffer,
263
+ * 待 endBatch 时聚合为一个历史条目。
264
+ *
265
+ * @param command 已执行完毕、待入历史的 Command
266
+ */
267
+ record(command: Command): void;
268
+ /**
269
+ * 开始批量态
270
+ *
271
+ * 开启后,期间所有 record 的子 Command 会被缓冲,不立即入 History。
272
+ * 调用方需保证最终调用 endBatch 或 cancelBatch 收尾。
273
+ */
274
+ beginBatch(): void;
275
+ /**
276
+ * 结束批量态,将缓冲的子 Command 聚合入 History
277
+ *
278
+ * - 0 个子命令:不入 History
279
+ * - 1 个子命令:直接入该子命令(历史更干净,不包裹 Composite)
280
+ * - 多个子命令:包成 CompositeCommand 入 History
281
+ *
282
+ * @param commandId 可选的复合命令显示 ID(仅多子命令时生效)
283
+ * @returns 入 History 的 Command;无子命令时返回 undefined
284
+ */
285
+ endBatch(commandId?: string): Command | undefined;
286
+ /**
287
+ * 取消批量态:丢弃缓冲的子 Command(不入 History)
288
+ *
289
+ * 注意:子命令的数据变更已经发生,此处不做回滚,仅放弃历史记录。
290
+ * 如需回滚请由调用方自行处理。
291
+ */
292
+ cancelBatch(): void;
293
+ /**
294
+ * 收尾所有未完成的交互态 / 批量态。
295
+ *
296
+ * 用于独立功能状态隔离(pushSession)前调用:确保挂起主栈前,
297
+ * 任何进行中的交互态(拖拽未结束)或批量态(batch 未关闭)先正常入 History,
298
+ * 避免快照里混入半成品 Command。
299
+ */
300
+ flush(): void;
301
+ /**
302
+ * 是否正在交互态中
303
+ */
304
+ get isInInteraction(): boolean;
305
+ /**
306
+ * 是否正在批量态中
307
+ */
308
+ get isInBatch(): boolean;
309
+ /**
310
+ * 获取所有已注册的 Command ID
311
+ *
312
+ * @returns 已注册 Command ID 的数组(拷贝)
313
+ */
314
+ getRegisteredCommands(): string[];
315
+ }
@@ -0,0 +1,45 @@
1
+ import type { Command } from '../types';
2
+ export type CompositeCommandArgs = {
3
+ /** 子 Command 列表(按执行先后顺序排列) */
4
+ children: Command[];
5
+ /** 可选的复合命令显示 ID(如 'transform.frameMove'),默认 'composite' */
6
+ commandId?: string;
7
+ };
8
+ /**
9
+ * CompositeCommand - 复合命令
10
+ *
11
+ * 将单次交互产生的多个子 Command 聚合为一个历史条目,使其在 History 中
12
+ * 表现为「一次操作」:撤销一次即可还原全部子操作。
13
+ *
14
+ * 顺序约定:
15
+ * - children 按执行先后顺序排列(先发生的在前)
16
+ * - execute / redo:正序遍历(先发生的先执行)
17
+ * - undo:逆序遍历(后发生的先撤销),保证依赖关系正确
18
+ * 例如「自动布局重排(layout) → 元素移动(move)」,撤销时必须先撤 move 再撤 layout。
19
+ *
20
+ * 注意:在 Gizmo 交互场景中,子 Command 进入复合命令前通常已被各自 execute 过
21
+ * (配合 CommandService.record 语义)。CompositeCommand 入 History 时不重复执行,
22
+ * 仅在后续 undo / redo 时统一驱动子命令。
23
+ */
24
+ export declare class CompositeCommand implements Command {
25
+ readonly id: string;
26
+ readonly commandId: string;
27
+ private _children;
28
+ /**
29
+ * 初始化复合命令,拷贝子命令列表并生成命令 ID
30
+ * @param args 子命令列表与可选 commandId
31
+ */
32
+ constructor(args: CompositeCommandArgs);
33
+ /** 子命令数量 */
34
+ get size(): number;
35
+ /** 是否不含任何子命令 */
36
+ get isEmpty(): boolean;
37
+ /** 子命令列表(只读副本) */
38
+ get children(): Command[];
39
+ /** 正序执行所有子命令 */
40
+ execute(): void;
41
+ /** 逆序撤销所有子命令,保证依赖关系正确还原 */
42
+ undo(): void;
43
+ /** 正序重做所有子命令 */
44
+ redo(): void;
45
+ }