@vvfx/sdk 0.2.8 → 0.2.9

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 (107) hide show
  1. package/dist/config.js +231 -0
  2. package/dist/exporter/config.js +18 -0
  3. package/dist/exporter/const.js +71 -0
  4. package/dist/exporter/export-media.js +878 -0
  5. package/dist/exporter/exporter.js +121 -0
  6. package/dist/exporter/index.js +1 -0
  7. package/dist/exporter/types.js +1 -0
  8. package/dist/exporter/utils.js +190 -0
  9. package/dist/exporter/wav-audio.js +50 -0
  10. package/dist/gesture-handler/gizmo/adsorption-gizmo.js +227 -0
  11. package/dist/gesture-handler/gizmo/control-gizmo.js +149 -0
  12. package/dist/gesture-handler/gizmo/gizmo.js +17 -0
  13. package/dist/gesture-handler/gizmo/icon-gizmo.js +189 -0
  14. package/dist/gesture-handler/gizmo/index.js +6 -0
  15. package/dist/gesture-handler/gizmo/item-create-gizmo.js +256 -0
  16. package/dist/gesture-handler/gizmo/loading-gizmo.js +320 -0
  17. package/dist/gesture-handler/gizmo/mask-gizmo.js +648 -0
  18. package/dist/gesture-handler/gizmo/picture-cut-gizmo.js +550 -0
  19. package/dist/gesture-handler/gizmo/picture-expand-gizmo.js +491 -0
  20. package/dist/gesture-handler/gizmo/preference-gizmo.js +148 -0
  21. package/dist/gesture-handler/gizmo/selector-gizmo.d.ts +1 -1
  22. package/dist/gesture-handler/gizmo/selector-gizmo.js +468 -0
  23. package/dist/gesture-handler/gizmo/sprite-text-edit-gizmo.js +247 -0
  24. package/dist/gesture-handler/gizmo/text-gizmo.js +1033 -0
  25. package/dist/gesture-handler/gizmo/transform-gizmo.js +1199 -0
  26. package/dist/gesture-handler/gizmo/type.js +18 -0
  27. package/dist/gesture-handler/index.js +3 -0
  28. package/dist/gesture-handler/src/gesture-handler.js +770 -0
  29. package/dist/gesture-handler/src/icons.js +24 -0
  30. package/dist/gesture-handler/utils.js +40 -0
  31. package/dist/html-overlay/anchor-navigation-runtime.js +27 -0
  32. package/dist/html-overlay/auto-height-runtime.js +132 -0
  33. package/dist/html-overlay/document-runtime.js +71 -0
  34. package/dist/html-overlay/document-transform.js +96 -0
  35. package/dist/html-overlay/dom-order.js +8 -0
  36. package/dist/html-overlay/host-message-runtime.js +24 -0
  37. package/dist/html-overlay/html-capture-runtime.js +282 -0
  38. package/dist/html-overlay/html-viewport-style.js +10 -0
  39. package/dist/html-overlay/index.js +1 -0
  40. package/dist/html-overlay/manager.js +1663 -0
  41. package/dist/html-overlay/mime-utils.js +21 -0
  42. package/dist/html-overlay/overlay-transform.js +57 -0
  43. package/dist/html-overlay/path-utils.js +35 -0
  44. package/dist/html-overlay/shell-runtime.js +12 -0
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.js +13 -75311
  48. package/dist/index.mjs +75311 -0
  49. package/dist/{index.js.map → index.mjs.map} +1 -1
  50. package/dist/layer-order.js +8 -0
  51. package/dist/math/box2.js +396 -0
  52. package/dist/math/circle.js +131 -0
  53. package/dist/math/euler.js +35 -0
  54. package/dist/math/index.js +13 -0
  55. package/dist/math/line2.js +153 -0
  56. package/dist/math/line3.js +36 -0
  57. package/dist/math/matrix4.js +207 -0
  58. package/dist/math/plane.js +52 -0
  59. package/dist/math/quaternion.js +3 -0
  60. package/dist/math/ray-caster.js +25 -0
  61. package/dist/math/ray.js +47 -0
  62. package/dist/math/type.js +1 -0
  63. package/dist/math/utils.js +77 -0
  64. package/dist/math/vector2.js +70 -0
  65. package/dist/math/vector3.js +60 -0
  66. package/dist/screen-shot/index.js +1 -0
  67. package/dist/screen-shot/screen-shot.js +113 -0
  68. package/dist/sdk-item/base-item.js +160 -0
  69. package/dist/sdk-item/card-item.js +131 -0
  70. package/dist/sdk-item/effects-item.js +144 -0
  71. package/dist/sdk-item/frame-item.js +217 -0
  72. package/dist/sdk-item/generator-item.js +188 -0
  73. package/dist/sdk-item/group-item.js +116 -0
  74. package/dist/sdk-item/index.js +39 -0
  75. package/dist/sdk-item/sprite-item.js +147 -0
  76. package/dist/sdk-item/text-item.js +223 -0
  77. package/dist/sdk-item/types.d.ts +1 -1
  78. package/dist/sdk-item/types.js +15 -0
  79. package/dist/sdk-item/video-item.js +174 -0
  80. package/dist/sdk.js +1903 -0
  81. package/dist/service/UndoRedo.js +79 -0
  82. package/dist/shared/index.d.ts +1 -0
  83. package/dist/shared/index.js +2 -0
  84. package/dist/shared/player.d.ts +1 -1
  85. package/dist/shared/player.js +9 -0
  86. package/dist/shared/spec.d.ts +1 -0
  87. package/dist/shared/spec.js +1 -0
  88. package/dist/size-adapte/index.js +1 -0
  89. package/dist/size-adapte/size-adapt.js +395 -0
  90. package/dist/types.d.ts +5 -1
  91. package/dist/types.js +17 -0
  92. package/dist/utils/background-manager.js +189 -0
  93. package/dist/utils/common-utils.js +183 -0
  94. package/dist/utils/index.js +8 -0
  95. package/dist/utils/interaction-utils.js +205 -0
  96. package/dist/utils/json-data-utils.js +1529 -0
  97. package/dist/utils/layout-utils.js +1217 -0
  98. package/dist/utils/page-data-utils.js +5397 -0
  99. package/dist/utils/player-data-utils.js +48 -0
  100. package/dist/utils/types.js +8 -0
  101. package/dist/wireframe/common/box.js +18 -0
  102. package/dist/wireframe/common/dashed-line.js +21 -0
  103. package/dist/wireframe/common/line.js +17 -0
  104. package/dist/wireframe/common/pixi-ext.js +1 -0
  105. package/dist/wireframe/common/pixi.js +31 -0
  106. package/dist/wireframe/index.js +4 -0
  107. package/package.json +10 -3
@@ -0,0 +1,223 @@
1
+ import { generateGUID, spec } from '../shared';
2
+ import { SDKItemType } from './types';
3
+ import { BaseItem } from './base-item';
4
+ import { deepClone } from '../utils/common-utils';
5
+ /**
6
+ * @description 文本元素 SDKItem 类
7
+ * @description 支持属性扩展
8
+ */
9
+ export class TextItem extends BaseItem {
10
+ /**
11
+ * @description 元素类型
12
+ */
13
+ type = SDKItemType.TEXT;
14
+ /**
15
+ * @description 元素属性
16
+ */
17
+ property;
18
+ constructor(options) {
19
+ super(options);
20
+ // 初始化属性,设置默认值
21
+ this.property = {
22
+ position: options.property?.position ?? [0, 0],
23
+ rotation: options.property?.rotation ?? [0, 0, 0],
24
+ width: options.property?.width ?? 0,
25
+ height: options.property?.height ?? 0,
26
+ scale: options.property?.scale ?? [1, 1],
27
+ fontFamily: options.property?.fontFamily ?? '',
28
+ color: options.property?.color ?? [0, 0, 0, 1],
29
+ fontWeight: options.property?.fontWeight ?? spec.TextWeight.normal,
30
+ text: options.property?.text ?? '',
31
+ textAlign: options.property?.textAlign ?? spec.TextAlignment.left,
32
+ fontSize: options.property?.fontSize ?? 24,
33
+ fontStyle: options.property?.fontStyle ?? spec.FontStyle.normal,
34
+ lineHeight: options.property?.lineHeight ?? 24,
35
+ outlineColor: options.property?.outlineColor,
36
+ outlineWidth: options.property?.outlineWidth,
37
+ outlineEnabled: options.property?.outlineEnabled ?? false,
38
+ fontUrl: options.property?.fontUrl,
39
+ letterSpacing: options.property?.letterSpacing ?? 0
40
+ };
41
+ }
42
+ // ==================== 便捷访问器 ====================
43
+ get pixelWidth() {
44
+ return this.width;
45
+ }
46
+ get pixelHeight() {
47
+ return this.height;
48
+ }
49
+ /**
50
+ * @description 文本内容
51
+ */
52
+ get text() {
53
+ return this.property.text;
54
+ }
55
+ set text(value) {
56
+ this.property.text = value;
57
+ }
58
+ /**
59
+ * @description 字体名称
60
+ */
61
+ get fontFamily() {
62
+ return this.property.fontFamily;
63
+ }
64
+ set fontFamily(value) {
65
+ this.property.fontFamily = value;
66
+ }
67
+ /**
68
+ * @description 字号
69
+ */
70
+ get fontSize() {
71
+ return this.property.fontSize;
72
+ }
73
+ set fontSize(value) {
74
+ this.property.fontSize = value;
75
+ }
76
+ /**
77
+ * @description 字重
78
+ */
79
+ get fontWeight() {
80
+ return this.property.fontWeight;
81
+ }
82
+ set fontWeight(value) {
83
+ this.property.fontWeight = value;
84
+ }
85
+ /**
86
+ * @description 字体样式
87
+ */
88
+ get fontStyle() {
89
+ return this.property.fontStyle;
90
+ }
91
+ set fontStyle(value) {
92
+ this.property.fontStyle = value;
93
+ }
94
+ /**
95
+ * @description 文本对齐方式
96
+ */
97
+ get textAlign() {
98
+ return this.property.textAlign;
99
+ }
100
+ set textAlign(value) {
101
+ this.property.textAlign = value;
102
+ }
103
+ /**
104
+ * @description 文本颜色 [r, g, b, a]
105
+ */
106
+ get color() {
107
+ return this.property.color;
108
+ }
109
+ set color(value) {
110
+ this.property.color = value;
111
+ }
112
+ /**
113
+ * @description 文本宽度
114
+ */
115
+ get width() {
116
+ return this.property.width;
117
+ }
118
+ set width(value) {
119
+ this.property.width = value;
120
+ }
121
+ /**
122
+ * @description 行高
123
+ */
124
+ get lineHeight() {
125
+ return this.property.lineHeight;
126
+ }
127
+ set lineHeight(value) {
128
+ this.property.lineHeight = value;
129
+ }
130
+ /**
131
+ * @description 文本高度
132
+ */
133
+ get height() {
134
+ return this.property.height;
135
+ }
136
+ set height(value) {
137
+ this.property.height = value;
138
+ }
139
+ /**
140
+ * @description 描边颜色
141
+ */
142
+ get outlineColor() {
143
+ return this.property.outlineColor;
144
+ }
145
+ set outlineColor(value) {
146
+ this.property.outlineColor = value;
147
+ }
148
+ /**
149
+ * @description 描边宽度
150
+ */
151
+ get outlineWidth() {
152
+ return this.property.outlineWidth;
153
+ }
154
+ set outlineWidth(value) {
155
+ this.property.outlineWidth = value;
156
+ }
157
+ /**
158
+ * @description 描边开关
159
+ */
160
+ get outlineEnabled() {
161
+ return this.property.outlineEnabled ?? false;
162
+ }
163
+ set outlineEnabled(value) {
164
+ this.property.outlineEnabled = value;
165
+ }
166
+ /**
167
+ * @description 位置
168
+ */
169
+ get position() {
170
+ return this.property.position;
171
+ }
172
+ set position(value) {
173
+ this.property.position = value;
174
+ }
175
+ /**
176
+ * @description 旋转(二维旋转角度)
177
+ */
178
+ get rotation() {
179
+ return this.property.rotation[2];
180
+ }
181
+ set rotation(value) {
182
+ this.property.rotation[2] = value;
183
+ }
184
+ // ==================== 实现抽象方法 ====================
185
+ /**
186
+ * @description 转换为 CreateInfo
187
+ * @param withParent 是否包含父节点ID
188
+ */
189
+ toCreateInfo(withParent) {
190
+ const extension = this.getAllExtension();
191
+ return {
192
+ type: SDKItemType.TEXT,
193
+ id: this.id,
194
+ name: this.name,
195
+ parentId: withParent ? this.parentId : undefined,
196
+ extension: Object.keys(extension).length > 0 ? extension : undefined,
197
+ property: deepClone(this.property)
198
+ };
199
+ }
200
+ /**
201
+ * @description 克隆 SDKItem
202
+ */
203
+ clone() {
204
+ return new TextItem({
205
+ id: generateGUID(),
206
+ name: this.name,
207
+ parentId: this.parentId,
208
+ duration: this.duration,
209
+ delay: this.delay,
210
+ endBehavior: this.endBehavior,
211
+ isLocked: this.isLocked,
212
+ isCoreEditable: this.isCoreEditable,
213
+ property: deepClone(this.property),
214
+ extension: this.getAllExtension()
215
+ });
216
+ }
217
+ }
218
+ /**
219
+ * @description 类型守卫:检查是否是 TextItem
220
+ */
221
+ export function isTextItem(obj) {
222
+ return obj instanceof TextItem;
223
+ }
@@ -1,5 +1,5 @@
1
1
  import type { SpriteItemProperty, TextItemProperty, VideoItemProperty, GeneratorItemProperty, GroupItemProperty, EffectsItemProperty, FrameItemProperty, CardItemProperty } from '../types';
2
- import type { spec } from '../shared';
2
+ import { spec } from '../shared/spec';
3
3
  /**
4
4
  * @description SDKItem 基础选项接口
5
5
  * @description 支持扩展属性,允许添加任意额外属性
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @description SDKItem 类型(独立于 spec.ItemType)
3
+ * @description 包含所有 SDK 层级的元素类型,包括虚拟类型如 generator
4
+ */
5
+ export var SDKItemType;
6
+ (function (SDKItemType) {
7
+ SDKItemType["SPRITE"] = "sprite";
8
+ SDKItemType["TEXT"] = "text";
9
+ SDKItemType["VIDEO"] = "video";
10
+ SDKItemType["GROUP"] = "group";
11
+ SDKItemType["GENERATOR"] = "generator";
12
+ SDKItemType["EFFECTS"] = "effects";
13
+ SDKItemType["FRAME"] = "frame";
14
+ SDKItemType["CARD"] = "card";
15
+ })(SDKItemType || (SDKItemType = {}));
@@ -0,0 +1,174 @@
1
+ import { generateGUID } from '../shared';
2
+ import { SDKItemType } from './types';
3
+ import { BaseItem } from './base-item';
4
+ import { deepClone } from '../utils/common-utils';
5
+ /**
6
+ * @description 视频元素 SDKItem 类
7
+ * @description 支持属性扩展
8
+ */
9
+ export class VideoItem extends BaseItem {
10
+ /**
11
+ * @description 元素类型
12
+ */
13
+ type = SDKItemType.VIDEO;
14
+ /**
15
+ * @description 元素属性
16
+ */
17
+ property;
18
+ constructor(options) {
19
+ super(options);
20
+ // 初始化属性
21
+ this.property = {
22
+ position: options.property?.position ?? [0, 0],
23
+ rotation: options.property?.rotation ?? [0, 0, 0],
24
+ width: options.property?.width ?? 0,
25
+ height: options.property?.height ?? 0,
26
+ scale: options.property?.scale ?? [1, 1],
27
+ video: options.property?.video ?? '',
28
+ muted: options.property?.muted ?? true,
29
+ transparent: options.property?.transparent ?? true,
30
+ playbackRate: options.property?.playbackRate ?? 1,
31
+ volume: options.property?.volume ?? 0,
32
+ };
33
+ }
34
+ // ==================== 便捷访问器 ====================
35
+ /**
36
+ * @description 视频地址
37
+ */
38
+ get video() {
39
+ return this.property.video;
40
+ }
41
+ set video(value) {
42
+ this.property.video = value;
43
+ }
44
+ /**
45
+ * @description 位置
46
+ */
47
+ get position() {
48
+ return this.property.position;
49
+ }
50
+ set position(value) {
51
+ this.property.position = value;
52
+ }
53
+ /**
54
+ * @description 宽度
55
+ */
56
+ get width() {
57
+ return this.property.width;
58
+ }
59
+ set width(value) {
60
+ this.property.width = value;
61
+ }
62
+ /**
63
+ * @description 高度
64
+ */
65
+ get height() {
66
+ return this.property.height;
67
+ }
68
+ set height(value) {
69
+ this.property.height = value;
70
+ }
71
+ /**
72
+ * @description 旋转(二维旋转角度)
73
+ */
74
+ get rotation() {
75
+ return this.property.rotation[2];
76
+ }
77
+ set rotation(value) {
78
+ this.property.rotation[2] = value;
79
+ }
80
+ /**
81
+ * @description 完整旋转(包含 x, y, z)
82
+ */
83
+ get fullRotation() {
84
+ return this.property.rotation;
85
+ }
86
+ set fullRotation(value) {
87
+ this.property.rotation = value;
88
+ }
89
+ /**
90
+ * @description 是否正在编辑关键属性
91
+ * @deprecated 该属性即将废弃,使用 isCoreEditable 代替
92
+ */
93
+ get keyPropertyEditing() {
94
+ return this.isCoreEditable;
95
+ }
96
+ set keyPropertyEditing(value) {
97
+ this.isCoreEditable = value;
98
+ }
99
+ /**
100
+ * @description 是否静音
101
+ */
102
+ get muted() {
103
+ return this.property.muted ?? true;
104
+ }
105
+ set muted(state) {
106
+ this.property.muted = state;
107
+ }
108
+ /**
109
+ * @description 是否为透明视频
110
+ */
111
+ get transparent() {
112
+ return this.property.transparent ?? true;
113
+ }
114
+ set transparent(state) {
115
+ this.property.transparent = state;
116
+ }
117
+ /**
118
+ * @description 播放音量
119
+ */
120
+ get volume() {
121
+ return this.property.volume ?? 0;
122
+ }
123
+ set volume(value) {
124
+ this.property.volume = value;
125
+ }
126
+ /**
127
+ * @description 播放速率
128
+ */
129
+ get playbackRate() {
130
+ return this.property.playbackRate ?? 1;
131
+ }
132
+ set playbackRate(value) {
133
+ this.property.playbackRate = value;
134
+ }
135
+ // ==================== 实现抽象方法 ====================
136
+ /**
137
+ * @description 转换为 CreateInfo
138
+ * @param withParent 是否包含父节点ID
139
+ */
140
+ toCreateInfo(withParent) {
141
+ const extension = this.getAllExtension();
142
+ return {
143
+ type: SDKItemType.VIDEO,
144
+ id: this.id,
145
+ name: this.name,
146
+ parentId: withParent ? this.parentId : undefined,
147
+ extension: Object.keys(extension).length > 0 ? extension : undefined,
148
+ property: deepClone(this.property)
149
+ };
150
+ }
151
+ /**
152
+ * @description 克隆 SDKItem
153
+ */
154
+ clone() {
155
+ return new VideoItem({
156
+ id: generateGUID(),
157
+ name: this.name,
158
+ parentId: this.parentId,
159
+ duration: this.duration,
160
+ delay: this.delay,
161
+ endBehavior: this.endBehavior,
162
+ isLocked: this.isLocked,
163
+ isCoreEditable: this.isCoreEditable,
164
+ property: deepClone(this.property),
165
+ extension: this.getAllExtension()
166
+ });
167
+ }
168
+ }
169
+ /**
170
+ * @description 类型守卫:检查是否是 VideoItem
171
+ */
172
+ export function isVideoItem(obj) {
173
+ return obj instanceof VideoItem;
174
+ }