@vvfx/sdk 0.2.2 → 0.2.4

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.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.2
6
+ * Version: v0.2.4
7
7
  */
8
8
 
9
9
  'use strict';
@@ -47185,7 +47185,7 @@ var SelectorGizmo = /*#__PURE__*/ function(Gizmo) {
47185
47185
  var preSelectedItem = this.pageDataUtils.getPreSelectedItem();
47186
47186
  var preSelectedItemBox = this.pageDataUtils.getViewBoxById((_ref = preSelectedItem == null ? void 0 : preSelectedItem.id) != null ? _ref : '');
47187
47187
  var _SDK_config_gestureHandlerConfig_selectorGizmoConfig = SDK.config.gestureHandlerConfig.selectorGizmoConfig, regionBoxColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionBoxColor, regionBoxAlpha = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionBoxAlpha, preSelectedWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedWidth, preSelectedColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedColor, regionWireframeWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionWireframeWidth, regionWireframeColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionWireframeColor, regionWireframeAlpha = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionWireframeAlpha;
47188
- if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty())) {
47188
+ if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty()) && !isCardItem(preSelectedItem)) {
47189
47189
  this.graphics.lineStyle(preSelectedWidth, preSelectedColor);
47190
47190
  this.graphics.drawBox(preSelectedItemBox);
47191
47191
  }
@@ -55371,7 +55371,9 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55371
55371
  return;
55372
55372
  }
55373
55373
  var selectedItem = (_selectedItems_ = selectedItems[0]) != null ? _selectedItems_ : undefined;
55374
- var isShfitLockScale = selectedItem && selectedItems.length === 1 && isFrameItem(selectedItem) ? !this.isShiftDown : this.isShiftDown;
55374
+ // html卡片内容在非自动缩放的情况下,拖动的时候内容自适应,因此与智能画板一样,需要默认是自由缩放(即自由改大小)
55375
+ var isSingleAutoFitContentCardItem = selectedItems.length === 1 && selectedItem && isCardItem(selectedItem) && !selectedItem.isAutoScale;
55376
+ var isShiftLockScale = selectedItem && selectedItems.length === 1 && (isFrameItem(selectedItem) || isSingleAutoFitContentCardItem) ? !this.isShiftDown : this.isShiftDown;
55375
55377
  var farthestCorner = this.scaleParam.farthestCorner;
55376
55378
  var isValidScale = (scaleCorner.x - farthestCorner.x) * (this.cursorPoint.x - farthestCorner.x) > 0 && (scaleCorner.y - farthestCorner.y) * (this.cursorPoint.y - farthestCorner.y) > 0;
55377
55379
  if (!isValidScale && this.isLockScale && !this.isShiftDown) {
@@ -55388,7 +55390,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55388
55390
  var currentStartScale = startScale.clone().multiply(lastScalar);
55389
55391
  var currentScale = worldPosition1.clone().subtract(cornerShift).subtract(center1).applyMatrix(rotationMatrix);
55390
55392
  var scalar = new Vector3(1, 1, 1);
55391
- if (!this.isLockScale || isShfitLockScale) {
55393
+ if (!this.isLockScale || isShiftLockScale) {
55392
55394
  scalar.x = isEqual$1(currentStartScale.x, 0) ? 1 : currentScale.x / currentStartScale.x;
55393
55395
  scalar.y = isEqual$1(currentStartScale.y, 0) ? 1 : currentScale.y / currentStartScale.y;
55394
55396
  scalar.z = isEqual$1(currentStartScale.z, 0) ? 1 : currentScale.z / currentStartScale.z;
@@ -55445,6 +55447,23 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55445
55447
  newWidth,
55446
55448
  newHeight
55447
55449
  ], translation1);
55450
+ } else if (isSingleAutoFitContentCardItem && selectedItem && isCardItem(selectedItem)) {
55451
+ var currentWidth1 = selectedItem.pixelWidth;
55452
+ var currentHeight1 = selectedItem.pixelHeight;
55453
+ var newWidth1 = currentWidth1 * resultScalar1.x;
55454
+ var newHeight1 = currentHeight1 * resultScalar1.y;
55455
+ this._pageDataUtils.resizeCardItem(selectedItem.id, [
55456
+ newWidth1,
55457
+ newHeight1
55458
+ ], translation1);
55459
+ void this._pageDataUtils.setItemProperty({
55460
+ itemId: selectedItem.id,
55461
+ type: SDKItemType.CARD,
55462
+ property: {
55463
+ width: newWidth1,
55464
+ height: newHeight1
55465
+ }
55466
+ });
55448
55467
  } else {
55449
55468
  // 普通元素的缩放逻辑
55450
55469
  selectedItems.forEach(function(item) {
@@ -55769,6 +55788,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55769
55788
  var selectedItems = this._pageDataUtils.getSelectedItems();
55770
55789
  var isTemplateMode = SDK.config.mode === 'template';
55771
55790
  var selectedItem = selectedItems.length === 1 ? selectedItems[0] : undefined;
55791
+ var isSingleCardItem = isCardItem(selectedItem);
55772
55792
  var isGeneratorItem = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.GENERATOR;
55773
55793
  var isAutoLayoutFrame = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.FRAME && (selectedItem == null ? void 0 : selectedItem.layoutMode) === FrameLayoutMode.AUTO;
55774
55794
  var canScale = selectedItems.length === 1 && (selectedItem == null ? void 0 : selectedItem.type) !== SDKItemType.GROUP && !isAutoLayoutFrame && !isGeneratorItem;
@@ -55808,9 +55828,11 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55808
55828
  this.wireframe.totalBox.copyFrom(box).expandByScalar(totalBoxExpandScalar);
55809
55829
  // 根据box获取边缘线
55810
55830
  var corners = this.wireframe.box.corners;
55811
- corners.forEach(function(corner, i) {
55812
- _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55813
- });
55831
+ if (!isSingleCardItem) {
55832
+ corners.forEach(function(corner, i) {
55833
+ _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55834
+ });
55835
+ }
55814
55836
  var _SDK_config_gestureHandlerConfig_transformGizmoConfig = SDK.config.gestureHandlerConfig.transformGizmoConfig, scaleCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.scaleCircleSize, rotationCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.rotationCircleSize;
55815
55837
  // 成组暂不支持缩放
55816
55838
  if (selectedItems.length === 1) {
@@ -56603,6 +56625,10 @@ var cursorMap = {
56603
56625
  type: 'preset',
56604
56626
  content: 'crosshair'
56605
56627
  },
56628
+ 'box-select': {
56629
+ type: 'preset',
56630
+ content: 'crosshair'
56631
+ },
56606
56632
  'text-rotation': {
56607
56633
  type: 'svg',
56608
56634
  content: 'default',
@@ -59661,12 +59687,6 @@ var MAX_ITEM_DISTANCE_THRESHOLD = 100000;
59661
59687
  /**
59662
59688
  * @description SDKItem position 属性的数字精度(保留小数位数)
59663
59689
  */ var POSITION_PRECISION = 4;
59664
- function isCardHTMLContentValue(value) {
59665
- return (value == null ? void 0 : value.kind) === 'inline' || (value == null ? void 0 : value.kind) === 'dom' || (value == null ? void 0 : value.kind) === 'document';
59666
- }
59667
- function isCardHTMLValue(value) {
59668
- return isCardHTMLContentValue(value == null ? void 0 : value.content);
59669
- }
59670
59690
  var PageDataUtils = /*#__PURE__*/ function() {
59671
59691
  function PageDataUtils(player, container, emitter, sdk) {
59672
59692
  this.player = player;
@@ -60429,6 +60449,8 @@ var PageDataUtils = /*#__PURE__*/ function() {
60429
60449
  }
60430
60450
  }
60431
60451
  var isLocked = (_this_getSDKItem = this.getSDKItem(playerItem.getInstanceId())) == null ? void 0 : _this_getSDKItem.isLocked;
60452
+ // 优先通过 ID 查找现有 SDKItem,获取其 SDKItemType
60453
+ var existingSDKItem = this.getSDKItem(playerItem.getInstanceId());
60432
60454
  // 创建基础选项
60433
60455
  var baseOptions = {
60434
60456
  id: playerItem.getInstanceId(),
@@ -60440,12 +60462,11 @@ var PageDataUtils = /*#__PURE__*/ function() {
60440
60462
  endBehavior: playerItem.endBehavior,
60441
60463
  visible: isVisible,
60442
60464
  isLocked: isLocked,
60443
- isCoreEditable: isCoreEditable
60465
+ isCoreEditable: isCoreEditable,
60466
+ extension: existingSDKItem == null ? void 0 : existingSDKItem.extension
60444
60467
  };
60445
60468
  // 根据类型创建对应的 SDKItem 类实例
60446
60469
  var sdkItem;
60447
- // 优先通过 ID 查找现有 SDKItem,获取其 SDKItemType
60448
- var existingSDKItem = this.getSDKItem(playerItem.getInstanceId());
60449
60470
  // 如果找到了现有 SDKItem,根据 SDKItemType 创建
60450
60471
  // 将类型转换为 string 进行比较
60451
60472
  if ((existingSDKItem == null ? void 0 : existingSDKItem.type) === SDKItemType.GENERATOR) {
@@ -60484,11 +60505,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
60484
60505
  property: property
60485
60506
  }));
60486
60507
  } else if ((existingSDKItem == null ? void 0 : existingSDKItem.type) == SDKItemType.CARD) {
60487
- var cardType = existingSDKItem.cardType, html = existingSDKItem.html;
60508
+ var cardType = existingSDKItem.cardType;
60488
60509
  sdkItem = new CardItem(_extends({}, baseOptions, {
60489
60510
  property: _extends({}, property, {
60490
- cardType: cardType,
60491
- html: html
60511
+ cardType: cardType
60492
60512
  })
60493
60513
  }));
60494
60514
  } else {
@@ -60715,6 +60735,19 @@ var PageDataUtils = /*#__PURE__*/ function() {
60715
60735
  }).call(this);
60716
60736
  };
60717
60737
  /**
60738
+ * @description 设置元素extension字段
60739
+ */ _proto.setItemExtension = function setItemExtension(itemId, extension) {
60740
+ var item = this.getSDKItem(itemId);
60741
+ if (!item) {
60742
+ console.warn('setItemExtension: item not found');
60743
+ return;
60744
+ }
60745
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.entries(extension)), _step; !(_step = _iterator()).done;){
60746
+ var _step_value = _step.value, key = _step_value[0], value = _step_value[1];
60747
+ item.extension.set(key, value);
60748
+ }
60749
+ };
60750
+ /**
60718
60751
  * @description 场景 1: 设置单个元素的单个属性
60719
60752
  */ _proto.setSingleItemSingleProperty = function setSingleItemSingleProperty(param) {
60720
60753
  return _async_to_generator(function() {
@@ -60971,7 +61004,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
60971
61004
  * @description 更新 PlayerItem 的 Property 属性
60972
61005
  */ _proto.updatePlayerItemPropertyAttribute = function updatePlayerItemPropertyAttribute(playerItem, targetItem, propertyName, propertyValue) {
60973
61006
  return _async_to_generator(function() {
60974
- var _this, _playerItem_getComponent, _playerItem_getComponent1, color, _array_, array, family, textComponent, textComponent1, lineCount, textHeight, _playerItem_getComponent2, textComponent2, textHeight1, textComponent3, outlineColor, textComponent4, textComponent5, textComponent6, originFontSize, lineCount1, textHeight2, textComponent7, textHeight3, viewSize, worldSizeX, originSize, originChildBoxes, originBox, worldScaleX, originScale, originWidth, currentWidth, ratio, originScale1, textComponent8, originChildBoxes1, originBox1, worldScaleY, originScale2, originHeight, currentHeight, ratio1, originScale3, viewSize1, worldSizeY, originSize1, textComponent9, textHeight4, _playerItem_getComponent3, _, _playerItem_getComponent4, _1, _propertyValue_compositions_find, _ref, subCompositionItem, compositionId, mainComposition, effectsSize, viewSize2, worldSize, compositionItem, component, videoComponent, videoComponent1, videoComponent2, pixelTranslation, viewTranslation, translation, rotation, currentScale, scaleRatio, frameComponent, _SDK_config_itemConfig_frameConfig, freeLayoutBackgroundColor, autoLayoutBackgroundColor, color1, childrenItem, time;
61007
+ var _this, _playerItem_getComponent, _playerItem_getComponent1, color, _array_, array, family, textComponent, textComponent1, lineCount, textHeight, _playerItem_getComponent2, textComponent2, textHeight1, textComponent3, outlineColor, textComponent4, textComponent5, textComponent6, originFontSize, lineCount1, textHeight2, textComponent7, textHeight3, viewSize, worldSizeX, originSize, originChildBoxes, originBox, worldScaleX, originScale, originWidth, currentWidth, ratio, originScale1, textComponent8, originChildBoxes1, originBox1, worldScaleY, originScale2, originHeight, currentHeight, ratio1, originScale3, viewSize1, worldSizeY, originSize1, textComponent9, textHeight4, _playerItem_getComponent3, _, _playerItem_getComponent4, _1, _propertyValue_compositions_find, _ref, subCompositionItem, compositionId, mainComposition, effectsSize, viewSize2, worldSize, compositionItem, component, videoPlayStates, videoComponent, videoComponent1, videoComponent2, pixelTranslation, viewTranslation, translation, rotation, currentScale, scaleRatio, frameComponent, _SDK_config_itemConfig_frameConfig, freeLayoutBackgroundColor, autoLayoutBackgroundColor, color1, childrenItem, time, videoPlayStates1;
60975
61008
  return _ts_generator(this, function(_state) {
60976
61009
  switch(_state.label){
60977
61010
  case 0:
@@ -61072,40 +61105,35 @@ var PageDataUtils = /*#__PURE__*/ function() {
61072
61105
  3,
61073
61106
  31
61074
61107
  ];
61075
- case 'html':
61076
- return [
61077
- 3,
61078
- 32
61079
- ];
61080
61108
  case 'position':
61081
61109
  return [
61082
61110
  3,
61083
- 33
61111
+ 32
61084
61112
  ];
61085
61113
  case 'rotation':
61086
61114
  return [
61087
61115
  3,
61088
- 34
61116
+ 33
61089
61117
  ];
61090
61118
  case 'scale':
61091
61119
  return [
61092
61120
  3,
61093
- 35
61121
+ 34
61094
61122
  ];
61095
61123
  case 'layoutMode':
61096
61124
  return [
61097
61125
  3,
61098
- 36
61126
+ 35
61099
61127
  ];
61100
61128
  case 'visible':
61101
61129
  return [
61102
61130
  3,
61103
- 37
61131
+ 36
61104
61132
  ];
61105
61133
  }
61106
61134
  return [
61107
61135
  3,
61108
- 38
61136
+ 37
61109
61137
  ];
61110
61138
  case 1:
61111
61139
  {
@@ -61118,7 +61146,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61118
61146
  }
61119
61147
  return [
61120
61148
  3,
61121
- 39
61149
+ 38
61122
61150
  ];
61123
61151
  }
61124
61152
  case 2:
@@ -61129,7 +61157,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61129
61157
  }
61130
61158
  return [
61131
61159
  3,
61132
- 39
61160
+ 38
61133
61161
  ];
61134
61162
  }
61135
61163
  case 3:
@@ -61161,7 +61189,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61161
61189
  case 5:
61162
61190
  return [
61163
61191
  3,
61164
- 39
61192
+ 38
61165
61193
  ];
61166
61194
  case 6:
61167
61195
  {
@@ -61178,7 +61206,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61178
61206
  }
61179
61207
  return [
61180
61208
  3,
61181
- 39
61209
+ 38
61182
61210
  ];
61183
61211
  }
61184
61212
  case 7:
@@ -61192,7 +61220,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61192
61220
  }
61193
61221
  return [
61194
61222
  3,
61195
- 39
61223
+ 38
61196
61224
  ];
61197
61225
  }
61198
61226
  case 8:
@@ -61205,7 +61233,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61205
61233
  }
61206
61234
  return [
61207
61235
  3,
61208
- 39
61236
+ 38
61209
61237
  ];
61210
61238
  }
61211
61239
  case 9:
@@ -61219,7 +61247,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61219
61247
  }
61220
61248
  return [
61221
61249
  3,
61222
- 39
61250
+ 38
61223
61251
  ];
61224
61252
  }
61225
61253
  case 10:
@@ -61232,7 +61260,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61232
61260
  }
61233
61261
  return [
61234
61262
  3,
61235
- 39
61263
+ 38
61236
61264
  ];
61237
61265
  }
61238
61266
  case 11:
@@ -61245,7 +61273,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61245
61273
  }
61246
61274
  return [
61247
61275
  3,
61248
- 39
61276
+ 38
61249
61277
  ];
61250
61278
  }
61251
61279
  case 12:
@@ -61265,7 +61293,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61265
61293
  }
61266
61294
  return [
61267
61295
  3,
61268
- 39
61296
+ 38
61269
61297
  ];
61270
61298
  }
61271
61299
  case 13:
@@ -61307,7 +61335,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61307
61335
  }
61308
61336
  return [
61309
61337
  3,
61310
- 39
61338
+ 38
61311
61339
  ];
61312
61340
  }
61313
61341
  case 14:
@@ -61342,7 +61370,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61342
61370
  }
61343
61371
  return [
61344
61372
  3,
61345
- 39
61373
+ 38
61346
61374
  ];
61347
61375
  }
61348
61376
  case 15:
@@ -61356,7 +61384,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61356
61384
  }
61357
61385
  return [
61358
61386
  3,
61359
- 39
61387
+ 38
61360
61388
  ];
61361
61389
  }
61362
61390
  case 16:
@@ -61388,7 +61416,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61388
61416
  case 20:
61389
61417
  return [
61390
61418
  3,
61391
- 39
61419
+ 38
61392
61420
  ];
61393
61421
  case 21:
61394
61422
  if (!(typeof propertyValue === 'string' && playerItem.type === EFFECTS.spec.ItemType.video)) return [
@@ -61419,7 +61447,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61419
61447
  case 25:
61420
61448
  return [
61421
61449
  3,
61422
- 39
61450
+ 38
61423
61451
  ];
61424
61452
  case 26:
61425
61453
  if (!(playerItem.type === EFFECTS.spec.ItemType.null)) return [
@@ -61459,12 +61487,15 @@ var PageDataUtils = /*#__PURE__*/ function() {
61459
61487
  compositionItem.parentId = playerItem.getInstanceId();
61460
61488
  component = compositionItem.components[0];
61461
61489
  component == null ? void 0 : component.pause();
61490
+ // 刷新前快照视频播放态,刷新后恢复,避免更换特效导致全量视频被自动播放
61491
+ videoPlayStates = this.snapshotVideoPlayStates();
61462
61492
  this.sdk.player.gotoAndPlay(0);
61493
+ this.restoreVideoPlayStates(videoPlayStates);
61463
61494
  _state.label = 28;
61464
61495
  case 28:
61465
61496
  return [
61466
61497
  3,
61467
- 39
61498
+ 38
61468
61499
  ];
61469
61500
  case 29:
61470
61501
  {
@@ -61476,7 +61507,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61476
61507
  }
61477
61508
  return [
61478
61509
  3,
61479
- 39
61510
+ 38
61480
61511
  ];
61481
61512
  }
61482
61513
  case 30:
@@ -61489,7 +61520,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61489
61520
  }
61490
61521
  return [
61491
61522
  3,
61492
- 39
61523
+ 38
61493
61524
  ];
61494
61525
  }
61495
61526
  case 31:
@@ -61502,20 +61533,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61502
61533
  }
61503
61534
  return [
61504
61535
  3,
61505
- 39
61536
+ 38
61506
61537
  ];
61507
61538
  }
61508
61539
  case 32:
61509
- {
61510
- if (isCardItem(targetItem)) {
61511
- targetItem.html = isCardHTMLValue(propertyValue) ? propertyValue : undefined;
61512
- }
61513
- return [
61514
- 3,
61515
- 39
61516
- ];
61517
- }
61518
- case 33:
61519
61540
  {
61520
61541
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61521
61542
  pixelTranslation = propertyValue.map(function(v, i) {
@@ -61528,10 +61549,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61528
61549
  }
61529
61550
  return [
61530
61551
  3,
61531
- 39
61552
+ 38
61532
61553
  ];
61533
61554
  }
61534
- case 34:
61555
+ case 33:
61535
61556
  {
61536
61557
  if (Array.isArray(propertyValue) && propertyValue.length === 3) {
61537
61558
  rotation = propertyValue.map(function(v, i) {
@@ -61542,10 +61563,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61542
61563
  }
61543
61564
  return [
61544
61565
  3,
61545
- 39
61566
+ 38
61546
61567
  ];
61547
61568
  }
61548
- case 35:
61569
+ case 34:
61549
61570
  {
61550
61571
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61551
61572
  currentScale = targetItem.property.scale;
@@ -61559,10 +61580,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61559
61580
  }
61560
61581
  return [
61561
61582
  3,
61562
- 39
61583
+ 38
61563
61584
  ];
61564
61585
  }
61565
- case 36:
61586
+ case 35:
61566
61587
  {
61567
61588
  if (propertyValue === FrameLayoutMode.AUTO || propertyValue === FrameLayoutMode.FREE) {
61568
61589
  frameComponent = playerItem.getComponent(EFFECTS.FrameComponent);
@@ -61572,10 +61593,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61572
61593
  }
61573
61594
  return [
61574
61595
  3,
61575
- 39
61596
+ 38
61576
61597
  ];
61577
61598
  }
61578
- case 37:
61599
+ case 36:
61579
61600
  {
61580
61601
  if (typeof propertyValue === 'boolean') {
61581
61602
  playerItem.setVisible(propertyValue);
@@ -61588,10 +61609,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61588
61609
  }
61589
61610
  return [
61590
61611
  3,
61591
- 39
61612
+ 38
61592
61613
  ];
61593
61614
  }
61594
- case 38:
61615
+ case 37:
61595
61616
  {
61596
61617
  console.log('ignore property name ', propertyName);
61597
61618
  // 对于未明确处理的属性,尝试直接设置到 property 对象
@@ -61599,8 +61620,8 @@ var PageDataUtils = /*#__PURE__*/ function() {
61599
61620
  targetItem.property[propertyName] = propertyValue;
61600
61621
  }
61601
61622
  }
61602
- _state.label = 39;
61603
- case 39:
61623
+ _state.label = 38;
61624
+ case 38:
61604
61625
  // 非位置属性需要刷新播放器
61605
61626
  // template 模式下保持暂停态以避免播放器自动播放,editor 模式继续推进
61606
61627
  if (![
@@ -61609,11 +61630,14 @@ var PageDataUtils = /*#__PURE__*/ function() {
61609
61630
  'size'
61610
61631
  ].includes(propertyName)) {
61611
61632
  time = this.sdk.pageData.time;
61633
+ // 刷新前快照视频播放态,刷新后恢复,避免设置属性导致全量视频被自动播放
61634
+ videoPlayStates1 = this.snapshotVideoPlayStates();
61612
61635
  if (SDK.config.mode === 'editor') {
61613
61636
  this.player.gotoAndPlay(time);
61614
61637
  } else {
61615
61638
  this.player.gotoAndStop(time);
61616
61639
  }
61640
+ this.restoreVideoPlayStates(videoPlayStates1);
61617
61641
  }
61618
61642
  return [
61619
61643
  2
@@ -62480,6 +62504,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
62480
62504
  }
62481
62505
  break;
62482
62506
  }
62507
+ case 'cardType':
62508
+ {
62509
+ break;
62510
+ }
62483
62511
  default:
62484
62512
  {
62485
62513
  console.warn("Target property " + propertyName + " can not be changed.");
@@ -63072,12 +63100,15 @@ var PageDataUtils = /*#__PURE__*/ function() {
63072
63100
  var _cardInfo_name = cardInfo.name, name = _cardInfo_name === void 0 ? '卡片' : _cardInfo_name, _cardInfo_property = cardInfo.property, width = _cardInfo_property.width, height = _cardInfo_property.height, _cardInfo_property_scale = _cardInfo_property.scale, scale = _cardInfo_property_scale === void 0 ? [
63073
63101
  1,
63074
63102
  1
63075
- ] : _cardInfo_property_scale, cardType = _cardInfo_property.cardType, tmp = _cardInfo_property.rotation, sourceRotation = tmp === void 0 ? 0 : tmp, sourcePosition = _cardInfo_property.position, autoHeight = _cardInfo_property.autoHeight, html = _cardInfo_property.html, parentId = cardInfo.parentId, _cardInfo_id = cardInfo.id, id = _cardInfo_id === void 0 ? EFFECTS.generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63103
+ ] : _cardInfo_property_scale, cardType = _cardInfo_property.cardType, tmp = _cardInfo_property.rotation, sourceRotation = tmp === void 0 ? 0 : tmp, sourcePosition = _cardInfo_property.position, parentId = cardInfo.parentId, _cardInfo_id = cardInfo.id, id = _cardInfo_id === void 0 ? EFFECTS.generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63076
63104
  // 校验 cardType 是否已在配置中注册
63105
+ var cardTypeConfig = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
63106
+ return t.type === cardType;
63107
+ });
63077
63108
  var registeredTypes = SDK.config.itemConfig.cardConfig.cardTypes.map(function(t) {
63078
63109
  return t.type;
63079
63110
  });
63080
- if (!registeredTypes.includes(cardType)) {
63111
+ if (!cardTypeConfig) {
63081
63112
  console.warn('CardItem cardType "' + cardType + '" is not registered. Registered types: ' + registeredTypes.join(', '));
63082
63113
  return;
63083
63114
  }
@@ -63121,9 +63152,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
63121
63152
  width: width,
63122
63153
  height: height,
63123
63154
  scale: [].concat(scale),
63124
- cardType: cardType,
63125
- autoHeight: autoHeight,
63126
- html: html
63155
+ cardType: cardType
63127
63156
  },
63128
63157
  extension: extension
63129
63158
  });
@@ -64505,8 +64534,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
64505
64534
  scalar.y
64506
64535
  ],
64507
64536
  rotation: [].concat(rotation),
64508
- position: [].concat(resultPosition),
64509
- html: sdkItem.html
64537
+ position: [].concat(resultPosition)
64510
64538
  },
64511
64539
  extension: extension
64512
64540
  };
@@ -65552,7 +65580,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
65552
65580
  _this = this;
65553
65581
  changeProeprty = function changeProeprty(targetCreateInfo) {
65554
65582
  return _async_to_generator(function() {
65555
- var currentCreateInfo;
65583
+ var currentCreateInfo, itemId;
65556
65584
  return _ts_generator(this, function(_state) {
65557
65585
  switch(_state.label){
65558
65586
  case 0:
@@ -65563,16 +65591,20 @@ var PageDataUtils = /*#__PURE__*/ function() {
65563
65591
  2
65564
65592
  ];
65565
65593
  }
65594
+ itemId = targetCreateInfo.id;
65566
65595
  return [
65567
65596
  4,
65568
65597
  this.setItemProperty({
65569
- itemId: currentCreateInfo.id,
65598
+ itemId: itemId,
65570
65599
  type: currentCreateInfo.type,
65571
65600
  property: targetCreateInfo.property
65572
65601
  })
65573
65602
  ];
65574
65603
  case 1:
65575
65604
  _state.sent();
65605
+ if (targetCreateInfo.extension) {
65606
+ this.setItemExtension(itemId, targetCreateInfo.extension);
65607
+ }
65576
65608
  return [
65577
65609
  2
65578
65610
  ];
@@ -65628,6 +65660,51 @@ var PageDataUtils = /*#__PURE__*/ function() {
65628
65660
  var result = box.clone().scale(scale, center).translate(translation);
65629
65661
  return result;
65630
65662
  };
65663
+ /**
65664
+ * @description 快照当前所有视频元素的播放状态(播放/暂停 + 当前播放进度),用于属性刷新后恢复,
65665
+ * 避免设置属性导致全量视频被自动播放或进度被重置回 0s
65666
+ */ _proto.snapshotVideoPlayStates = function snapshotVideoPlayStates() {
65667
+ var states = new Map();
65668
+ var composition = this.getCurrentComposition();
65669
+ for(var _iterator = _create_for_of_iterator_helper_loose(composition.items), _step; !(_step = _iterator()).done;){
65670
+ var item = _step.value;
65671
+ if (item.type === EFFECTS.spec.ItemType.video) {
65672
+ var videoComponent = item.getComponent(VideoComponent);
65673
+ if (!videoComponent) {
65674
+ continue;
65675
+ }
65676
+ //@ts-expect-error @赤芍 played 字段未在类型中声明,参见 rebuildCompositionItems 处用法
65677
+ var played = !!videoComponent.played;
65678
+ var time = videoComponent.getCurrentTime();
65679
+ states.set(item.getInstanceId(), {
65680
+ played: played,
65681
+ time: time
65682
+ });
65683
+ }
65684
+ }
65685
+ return states;
65686
+ };
65687
+ /**
65688
+ * @description 按快照恢复视频元素的播放状态(先 pause 再 seek,最后按原状态 play/pause,避免进度抖动)
65689
+ */ _proto.restoreVideoPlayStates = function restoreVideoPlayStates(states) {
65690
+ for(var _iterator = _create_for_of_iterator_helper_loose(states), _step; !(_step = _iterator()).done;){
65691
+ var _step_value = _step.value, id = _step_value[0], _step_value_ = _step_value[1], played = _step_value_.played, time = _step_value_.time;
65692
+ var playerItem = this.getPlayerItemById(id);
65693
+ if ((playerItem == null ? void 0 : playerItem.type) !== EFFECTS.spec.ItemType.video) {
65694
+ continue;
65695
+ }
65696
+ var videoComponent = playerItem.getComponent(VideoComponent);
65697
+ if (!videoComponent) {
65698
+ continue;
65699
+ }
65700
+ // 先暂停再 seek,避免播放状态下 seek 导致画面抖动
65701
+ videoComponent.pauseVideo();
65702
+ videoComponent.setCurrentTime(time);
65703
+ if (played) {
65704
+ videoComponent.playVideo();
65705
+ }
65706
+ }
65707
+ };
65631
65708
  _proto.playVideoItem = function playVideoItem(id) {
65632
65709
  var playerItem = this.getPlayerItemById(id);
65633
65710
  if ((playerItem == null ? void 0 : playerItem.type) !== EFFECTS.spec.ItemType.video) {
@@ -65890,35 +65967,56 @@ var PageDataUtils = /*#__PURE__*/ function() {
65890
65967
  };
65891
65968
  _proto.asyncAddItemByCreateInfos = function asyncAddItemByCreateInfos(createInfos) {
65892
65969
  return _async_to_generator(function() {
65893
- var _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, createInfo, id, type, url, textureId, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65970
+ var _loop, _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65894
65971
  return _ts_generator(this, function(_state) {
65895
65972
  switch(_state.label){
65896
65973
  case 0:
65897
- _this = this;
65898
- createInfoWithIds = createInfos.map(function(createInfo) {
65899
- return Object.assign({}, createInfo, createInfo.id ? {} : {
65900
- id: EFFECTS.generateGUID()
65901
- });
65902
- });
65903
- itemToTextureInfo = new Map();
65904
- // 预处理所有 createInfo,分配 textureId
65905
- for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;){
65906
- createInfo = _step.value;
65907
- id = createInfo.id;
65908
- type = createInfo.type;
65909
- url = type === SDKItemType.SPRITE ? createInfo.property.image : type === SDKItemType.VIDEO ? createInfo.property.video : undefined;
65910
- if ((type === SDKItemType.SPRITE || type === SDKItemType.VIDEO) && url) {
65911
- textureId = EFFECTS.generateGUID();
65912
- itemToTextureInfo.set(id, {
65974
+ _loop = function() {
65975
+ var createInfo = _step.value;
65976
+ var _ref = function() {
65977
+ switch(createInfo.type){
65978
+ case SDKItemType.SPRITE:
65979
+ {
65980
+ return {
65981
+ url: createInfo.property.image,
65982
+ type: 'image'
65983
+ };
65984
+ }
65985
+ case SDKItemType.VIDEO:
65986
+ {
65987
+ return {
65988
+ url: createInfo.property.video,
65989
+ type: 'video'
65990
+ };
65991
+ }
65992
+ default:
65993
+ {
65994
+ return {};
65995
+ }
65996
+ }
65997
+ }(), url = _ref.url, type = _ref.type;
65998
+ if (url && type) {
65999
+ var textureId = EFFECTS.generateGUID();
66000
+ itemToTextureInfo.set(createInfo.id, {
65913
66001
  id: textureId,
65914
66002
  url: url,
65915
- type: type === SDKItemType.SPRITE ? 'image' : 'video'
66003
+ type: type
65916
66004
  });
65917
66005
  Object.assign(createInfo, {
65918
66006
  textureId: textureId
65919
66007
  });
65920
66008
  }
65921
- }
66009
+ };
66010
+ _this = this;
66011
+ createInfoWithIds = createInfos.map(function(createInfo) {
66012
+ var _createInfo_id;
66013
+ return Object.assign({}, createInfo, {
66014
+ id: (_createInfo_id = createInfo.id) != null ? _createInfo_id : EFFECTS.generateGUID()
66015
+ });
66016
+ });
66017
+ itemToTextureInfo = new Map();
66018
+ // 预处理所有 createInfo,分配 textureId
66019
+ for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;)_loop();
65922
66020
  // 并行创建所有 item
65923
66021
  toAddedCreateInfo = createInfoWithIds.filter(function(createInfo) {
65924
66022
  return ![
@@ -66887,6 +66985,51 @@ var PageDataUtils = /*#__PURE__*/ function() {
66887
66985
  * @param id 元素id
66888
66986
  * @param size 目标大小 [width, height]
66889
66987
  * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66988
+ */ _proto.resizeCardItem = function resizeCardItem(id, size, translation) {
66989
+ var _frameController_children;
66990
+ var frameItem = this.getSDKItem(id);
66991
+ if (!frameItem) {
66992
+ return;
66993
+ }
66994
+ var newWidth = size[0], newHeight = size[1];
66995
+ // const originalWidth = frameItem.property.width
66996
+ // 计算世界尺寸(供后续使用)
66997
+ var viewSize = this.interactionUtils.getViewSizeByPixelSize(new Vector2(newWidth, newHeight));
66998
+ var worldSize = this.interactionUtils.getWorldSizeByViewSize(viewSize).abs();
66999
+ // 1 更新 Player 层的预合成和子元素
67000
+ // 1.1 更新 Player Item(空节点控制器)的大小
67001
+ var frameController = this.getPlayerItemById(id);
67002
+ if (frameController) {
67003
+ frameController.transform.setSize(worldSize.x, worldSize.y);
67004
+ // 如果有位移,更新位置
67005
+ if (translation && (translation.x !== 0 || translation.y !== 0)) {
67006
+ var currentPosition = frameController.transform.position;
67007
+ frameController.setPosition(currentPosition.x + translation.x, currentPosition.y + translation.y, currentPosition.z);
67008
+ }
67009
+ }
67010
+ // 1.2 更新 Player Children Item 的大小
67011
+ var subCompositionItem = frameController == null ? void 0 : (_frameController_children = frameController.children) == null ? void 0 : _frameController_children[0];
67012
+ if (subCompositionItem && translation) {
67013
+ // 更新子元素
67014
+ subCompositionItem.children.forEach(function(item) {
67015
+ var _item;
67016
+ var _item_transform_getParentMatrix;
67017
+ var parentMatrix = new Matrix4().copyFrom((_item_transform_getParentMatrix = item.transform.getParentMatrix()) != null ? _item_transform_getParentMatrix : new Matrix4());
67018
+ parentMatrix.setPosition(new Vector3());
67019
+ var result = translation.clone().applyMatrix(parentMatrix.invert()).negate();
67020
+ (_item = item).translate.apply(_item, [].concat(result.toArray()));
67021
+ item.transform.updateLocalMatrix();
67022
+ });
67023
+ }
67024
+ // 2: 刷新 SDKItem 数据
67025
+ // 更新 FrameItem 的 property
67026
+ this.refreshSDKItem(frameItem.id);
67027
+ };
67028
+ /**
67029
+ * @description 修改画板元素大小
67030
+ * @param id 元素id
67031
+ * @param size 目标大小 [width, height]
67032
+ * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66890
67033
  */ _proto.resizeFrameItem = function resizeFrameItem(id, size, translation) {
66891
67034
  var _this = this;
66892
67035
  var _frameController_children;
@@ -67193,7 +67336,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
67193
67336
  };
67194
67337
  _proto.autoLayoutPage = function autoLayoutPage() {
67195
67338
  return _async_to_generator(function(param) {
67196
- var _this, pageData, _param_mode, mode, ids, _param_focus, focus, _param_gap, gap, isPartialLayout, targetItems, layoutElements, moveInfos, anchor, _iterator, _step, moveInfo, sdkItem;
67339
+ var _this, pageData, _param_mode, mode, ids, _param_focus, focus, _param_gap, gap, shift, isPartialLayout, targetItems, layoutElements, moveInfos, anchor, _iterator, _step, moveInfo, sdkItem;
67197
67340
  return _ts_generator(this, function(_state) {
67198
67341
  switch(_state.label){
67199
67342
  case 0:
@@ -67208,7 +67351,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
67208
67351
  2
67209
67352
  ];
67210
67353
  }
67211
- _param_mode = param.mode, mode = _param_mode === void 0 ? SDK.config.pageConfig.autoLayoutDefaultMode : _param_mode, ids = param.ids, _param_focus = param.focus, focus = _param_focus === void 0 ? true : _param_focus, _param_gap = param.gap, gap = _param_gap === void 0 ? SDK.config.pageConfig.autoLayoutDefaultGap : _param_gap;
67354
+ _param_mode = param.mode, mode = _param_mode === void 0 ? SDK.config.pageConfig.autoLayoutDefaultMode : _param_mode, ids = param.ids, _param_focus = param.focus, focus = _param_focus === void 0 ? true : _param_focus, _param_gap = param.gap, gap = _param_gap === void 0 ? SDK.config.pageConfig.autoLayoutDefaultGap : _param_gap, shift = param.shift;
67212
67355
  isPartialLayout = !!(ids == null ? void 0 : ids.length);
67213
67356
  // 1. 确定参与排布的顶层元素(过滤子元素)
67214
67357
  targetItems = pageData.items.filter(function(item) {
@@ -67237,7 +67380,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
67237
67380
  // 4. 计算锚点偏移
67238
67381
  // - 选中元素排布:以原始包围盒左上角为锚点
67239
67382
  // - 全量排布:以视口中心为锚点
67240
- anchor = isPartialLayout ? this.getPartialLayoutAnchor(layoutElements, moveInfos.boundingBox) : this.getGlobalLayoutAnchor(moveInfos.boundingBox);
67383
+ anchor = isPartialLayout ? this.getPartialLayoutAnchor(layoutElements, moveInfos.boundingBox) : this.getGlobalLayoutAnchor(moveInfos.boundingBox, shift);
67241
67384
  _iterator = _create_for_of_iterator_helper_loose(moveInfos.items);
67242
67385
  _state.label = 1;
67243
67386
  case 1:
@@ -67280,7 +67423,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
67280
67423
  if (focus) {
67281
67424
  this.setPageZoom(1, undefined, true);
67282
67425
  this.setPageMove(new Vector2());
67283
- this.viewportFit(undefined, moveInfos.boundingBox.translate(anchor));
67426
+ this.viewportFit(shift, moveInfos.boundingBox.translate(anchor));
67284
67427
  }
67285
67428
  return [
67286
67429
  2
@@ -67304,8 +67447,9 @@ var PageDataUtils = /*#__PURE__*/ function() {
67304
67447
  /**
67305
67448
  * @description 计算全量排布的锚点偏移:以视口中心为锚点
67306
67449
  * @param layoutBoundingBox 排布算法输出的包围盒
67307
- */ _proto.getGlobalLayoutAnchor = function getGlobalLayoutAnchor(layoutBoundingBox) {
67308
- var viewCenter = new Vector2(this.sdk._container.offsetWidth / 2, this.sdk._container.offsetHeight / 2);
67450
+ */ _proto.getGlobalLayoutAnchor = function getGlobalLayoutAnchor(layoutBoundingBox, shift) {
67451
+ var _ref = shift != null ? shift : {}, _ref_top = _ref.top, top = _ref_top === void 0 ? 0 : _ref_top, _ref_bottom = _ref.bottom, bottom = _ref_bottom === void 0 ? 0 : _ref_bottom, _ref_left = _ref.left, left = _ref_left === void 0 ? 0 : _ref_left, _ref_right = _ref.right, right = _ref_right === void 0 ? 0 : _ref_right;
67452
+ var viewCenter = new Vector2(this.sdk._container.offsetWidth / 2 + left - right, this.sdk._container.offsetHeight / 2 + top - bottom);
67309
67453
  var boundCenter = layoutBoundingBox.getCenter();
67310
67454
  return new Vector2(viewCenter.x - boundCenter.x, viewCenter.y - boundCenter.y);
67311
67455
  };
@@ -68907,6 +69051,8 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
68907
69051
  */ _this.maskSprite = null, _this._config = {}, _this.boxGraphics = new Graphics(), _this.type = 'mask', _this.mode = 'paint', /**
68908
69052
  * 蒙版工具独立的撤销重做实例
68909
69053
  */ _this._undoRedo = new GizmoUndoRedo(), /**
69054
+ * 框选擦除进行中标记(按下到松开之间),用于实时选框描边的显示控制
69055
+ */ _this._isBoxErasing = false, /**
68910
69056
  * 鼠标状态绘制结果
68911
69057
  */ _this.cursorResult = {
68912
69058
  type: 'normal',
@@ -68923,10 +69069,22 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
68923
69069
  var _proto = MaskGizmo.prototype;
68924
69070
  /**
68925
69071
  * 设置模式
68926
- * @param mode 模式类型:'paint' 表示涂抹,'erase' 表示擦除
69072
+ * @param mode 模式类型:'paint' 笔刷涂抹、'erase' 笔刷逐笔擦除、'box-erase' 框选擦除、'box-paint' 框选涂抹
68927
69073
  */ _proto.setMode = function setMode(mode) {
68928
69074
  this.mode = mode;
68929
69075
  };
69076
+ /**
69077
+ * @description 判断点是否在包围盒内
69078
+ */ _proto._isPointInBox = function _isPointInBox(p, box) {
69079
+ return p.x >= box.min.x && p.x <= box.max.x && p.y >= box.min.y && p.y <= box.max.y;
69080
+ };
69081
+ /**
69082
+ * @description 将屏幕坐标转换为包围盒内的归一化坐标 [0,1](钳制在范围内)
69083
+ */ _proto._toNormalized = function _toNormalized(p, box) {
69084
+ var x = Math.max(0, Math.min(1, (p.x - box.min.x) / (box.max.x - box.min.x)));
69085
+ var y = Math.max(0, Math.min(1, (p.y - box.min.y) / (box.max.y - box.min.y)));
69086
+ return new Vector2(x, y);
69087
+ };
68930
69088
  _proto.initialize = function initialize() {};
68931
69089
  _proto.preparationAction = function preparationAction(event) {
68932
69090
  if (!this.interactive) {
@@ -68945,6 +69103,26 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
68945
69103
  };
68946
69104
  // 更新鼠标位置
68947
69105
  this.result.point = new Vector2(event.offsetX, event.offsetY);
69106
+ // 框选模式(框选擦除 / 框选涂抹):仅在元素包围盒内按下才触发
69107
+ if (this.mode === 'box-erase' || this.mode === 'box-paint') {
69108
+ var box = this.result.box;
69109
+ if (!box || !this._isPointInBox(this.result.point, box)) {
69110
+ // 包围盒外按下:不触发框选,交由其它 gizmo
69111
+ return undefined;
69112
+ }
69113
+ var start = this._toNormalized(this.result.point, box);
69114
+ this.result.lines.push({
69115
+ type: this.mode === 'box-paint' ? 'paint' : 'erase',
69116
+ shape: 'rect',
69117
+ brushSize: 0,
69118
+ points: [
69119
+ start,
69120
+ start.clone()
69121
+ ]
69122
+ });
69123
+ this._isBoxErasing = true;
69124
+ return this.type;
69125
+ }
68948
69126
  // 开启新画笔
68949
69127
  this.result.lines.push({
68950
69128
  type: this.mode,
@@ -68954,32 +69132,61 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
68954
69132
  return this.type;
68955
69133
  };
68956
69134
  _proto.action = function action(event) {
68957
- var // 记录鼠标划线位置
68958
- _this_result_lines_;
68959
69135
  if (!this.interactive || this.result.status === 'init') {
68960
69136
  return;
68961
69137
  }
68962
69138
  // 更新鼠标位置
68963
69139
  var box = this.result.box;
68964
- var point = new Vector2((event.offsetX - box.min.x) / (box.max.x - box.min.x), (event.offsetY - box.min.y) / (box.max.y - box.min.y));
68965
- (_this_result_lines_ = this.result.lines[this.result.lines.length - 1]) == null ? void 0 : _this_result_lines_.points.push(point);
69140
+ var point = new Vector2(event.offsetX, event.offsetY);
69141
+ this.result.point = point;
69142
+ var lastLine = this.result.lines[this.result.lines.length - 1];
69143
+ // 框选擦除:更新框选终点(钳制到包围盒内)
69144
+ if ((lastLine == null ? void 0 : lastLine.shape) === 'rect') {
69145
+ lastLine.points[1] = this._toNormalized(point, box);
69146
+ return;
69147
+ }
69148
+ // 记录鼠标划线位置(笔刷模式)
69149
+ var np = new Vector2((event.offsetX - box.min.x) / (box.max.x - box.min.x), (event.offsetY - box.min.y) / (box.max.y - box.min.y));
69150
+ lastLine == null ? void 0 : lastLine.points.push(np);
68966
69151
  };
68967
69152
  _proto.endAction = function endAction() {
68968
69153
  if (!this.interactive) {
68969
69154
  return undefined;
68970
69155
  }
68971
- // 记录操作到 undoRedo(仅当画线有实际点时才记录)
68972
69156
  var lastLine = this.result.lines[this.result.lines.length - 1];
69157
+ // 框选擦除:起点==终点视为空框选,移除;否则提交 undoRedo
69158
+ if ((lastLine == null ? void 0 : lastLine.shape) === 'rect') {
69159
+ this._isBoxErasing = false;
69160
+ var _lastLine_points = lastLine.points, a = _lastLine_points[0], b = _lastLine_points[1];
69161
+ var isEmpty = !!a && !!b && a.x === b.x && a.y === b.y;
69162
+ if (this._oldLines && !isEmpty) {
69163
+ var operation = {
69164
+ type: 'update',
69165
+ oldData: this._oldLines,
69166
+ newData: {
69167
+ lines: JSON.parse(JSON.stringify(this.result.lines))
69168
+ }
69169
+ };
69170
+ this._undoRedo.push(operation);
69171
+ this._eventEmitter.emit('maskGizmoUndoRedoChange', operation);
69172
+ } else {
69173
+ // 空框选移除
69174
+ this.result.lines.pop();
69175
+ }
69176
+ this._oldLines = undefined;
69177
+ return this.type;
69178
+ }
69179
+ // 记录操作到 undoRedo(仅当画线有实际点时才记录)
68973
69180
  if (this._oldLines && lastLine && lastLine.points.length > 0) {
68974
- var operation = {
69181
+ var operation1 = {
68975
69182
  type: 'update',
68976
69183
  oldData: this._oldLines,
68977
69184
  newData: {
68978
69185
  lines: JSON.parse(JSON.stringify(this.result.lines))
68979
69186
  }
68980
69187
  };
68981
- this._undoRedo.push(operation);
68982
- this._eventEmitter.emit('maskGizmoUndoRedoChange', operation);
69188
+ this._undoRedo.push(operation1);
69189
+ this._eventEmitter.emit('maskGizmoUndoRedoChange', operation1);
68983
69190
  } else if ((lastLine == null ? void 0 : lastLine.points.length) === 0) {
68984
69191
  // 如果没有实际绘制点,移除空的线条
68985
69192
  this.result.lines.pop();
@@ -69104,6 +69311,17 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
69104
69311
  this.boxGraphics.lineStyle(boxLineWidth, boxLineColor, boxLineAlpha);
69105
69312
  this.boxGraphics.drawBox(box);
69106
69313
  this.boxGraphics.endFill();
69314
+ // 框选擦除进行中:叠加当前拖动矩形的可视描边
69315
+ var lastLine = this.result.lines[this.result.lines.length - 1];
69316
+ if (this._isBoxErasing && (lastLine == null ? void 0 : lastLine.shape) === 'rect' && lastLine.points.length >= 2) {
69317
+ var _lastLine_points = lastLine.points, a = _lastLine_points[0], b = _lastLine_points[1];
69318
+ if (a && b) {
69319
+ var selBox = new Box2(new Vector2(box.min.x + Math.min(a.x, b.x) * (box.max.x - box.min.x), box.min.y + Math.min(a.y, b.y) * (box.max.y - box.min.y)), new Vector2(box.min.x + Math.max(a.x, b.x) * (box.max.x - box.min.x), box.min.y + Math.max(a.y, b.y) * (box.max.y - box.min.y)));
69320
+ this.boxGraphics.lineStyle(boxLineWidth, boxLineColor, boxLineAlpha);
69321
+ this.boxGraphics.drawBox(selBox);
69322
+ this.boxGraphics.endFill();
69323
+ }
69324
+ }
69107
69325
  // 1. 画线形(只用于遮罩,不直接显示
69108
69326
  for(var _iterator = _create_for_of_iterator_helper_loose(this.result.lines), _step; !(_step = _iterator()).done;){
69109
69327
  var line = _step.value;
@@ -69111,6 +69329,32 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
69111
69329
  continue;
69112
69330
  }
69113
69331
  var lineGraphics = new Graphics();
69332
+ // 矩形框选:填充矩形,paint 用 NORMAL 叠加,erase 用 DST_OUT 抠除
69333
+ if (line.shape === 'rect') {
69334
+ var a1 = line.points[0];
69335
+ var b1 = line.points[1];
69336
+ if (a1 && b1) {
69337
+ var w = box.max.x - box.min.x;
69338
+ var h = box.max.y - box.min.y;
69339
+ var x0 = Math.min(a1.x, b1.x) * w;
69340
+ var y0 = Math.min(a1.y, b1.y) * h;
69341
+ var x1 = Math.max(a1.x, b1.x) * w;
69342
+ var y1 = Math.max(a1.y, b1.y) * h;
69343
+ // 太小(纯点击)不渲染,避免 1px 擦除/涂抹点
69344
+ if (x1 - x0 > 0.5 || y1 - y0 > 0.5) {
69345
+ lineGraphics.beginFill(brushColor);
69346
+ lineGraphics.drawRect(x0, y0, x1 - x0, y1 - y0);
69347
+ lineGraphics.endFill();
69348
+ lineGraphics.blendMode = line.type === 'paint' ? BLEND_MODES.NORMAL : BLEND_MODES.DST_OUT;
69349
+ this._app.renderer.render(lineGraphics, {
69350
+ renderTexture: this.maskRenderTexture,
69351
+ clear: false
69352
+ });
69353
+ }
69354
+ }
69355
+ lineGraphics.destroy();
69356
+ continue;
69357
+ }
69114
69358
  lineGraphics.blendMode = line.type === 'paint' ? BLEND_MODES.NORMAL : BLEND_MODES.DST_OUT;
69115
69359
  lineGraphics.lineStyle({
69116
69360
  width: line.brushSize * viewportParam.scale,
@@ -69154,14 +69398,24 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
69154
69398
  if (!point || !box) {
69155
69399
  return;
69156
69400
  }
69157
- if (point.x >= box.min.x && point.x <= box.max.x && point.y >= box.min.y && point.y <= box.max.y) {
69158
- var viewportParam = this._pageDataUtils.interactionUtils.viewportParam;
69401
+ var inside = point.x >= box.min.x && point.x <= box.max.x && point.y >= box.min.y && point.y <= box.max.y;
69402
+ if (!inside) {
69403
+ return;
69404
+ }
69405
+ // 框选模式(框选擦除 / 框选涂抹):crosshair
69406
+ if (this.mode === 'box-erase' || this.mode === 'box-paint') {
69159
69407
  this.cursorResult = {
69160
- type: 'circle',
69161
- angle: 0,
69162
- radius: this.config.brushSize * viewportParam.scale / 2
69408
+ type: 'box-select',
69409
+ angle: 0
69163
69410
  };
69411
+ return;
69164
69412
  }
69413
+ var viewportParam = this._pageDataUtils.interactionUtils.viewportParam;
69414
+ this.cursorResult = {
69415
+ type: 'circle',
69416
+ angle: 0,
69417
+ radius: this.config.brushSize * viewportParam.scale / 2
69418
+ };
69165
69419
  };
69166
69420
  _proto.close = function close() {
69167
69421
  this._config.maskImage = undefined;
@@ -69309,6 +69563,21 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
69309
69563
  if (!line || line.points.length === 0) {
69310
69564
  continue;
69311
69565
  }
69566
+ // 矩形框选:填充矩形
69567
+ if (line.shape === 'rect') {
69568
+ var _line_points = line.points, a = _line_points[0], b1 = _line_points[1];
69569
+ if (!a || !b1) {
69570
+ continue;
69571
+ }
69572
+ var x0 = Math.min(a.x, b1.x) * width;
69573
+ var y0 = Math.min(a.y, b1.y) * height;
69574
+ var x1 = Math.max(a.x, b1.x) * width;
69575
+ var y1 = Math.max(a.y, b1.y) * height;
69576
+ ctx.globalCompositeOperation = 'source-over';
69577
+ ctx.fillStyle = line.type === 'paint' ? maskHexColor : maskBackgroundHexColor;
69578
+ ctx.fillRect(x0, y0, Math.max(1, x1 - x0), Math.max(1, y1 - y0));
69579
+ continue;
69580
+ }
69312
69581
  ctx.lineWidth = line.brushSize * scale;
69313
69582
  ctx.lineCap = 'round';
69314
69583
  ctx.lineJoin = 'round';
@@ -71314,7 +71583,8 @@ var GestureHandler = /*#__PURE__*/ function() {
71314
71583
  'active-hand',
71315
71584
  'pointer',
71316
71585
  'text-create',
71317
- 'frame-create'
71586
+ 'frame-create',
71587
+ 'box-select'
71318
71588
  ].includes(result.type)) {
71319
71589
  var cursor = cursorMap[result.type];
71320
71590
  if (cursor.type === 'svg') {
@@ -71486,6 +71756,7 @@ var GestureHandler = /*#__PURE__*/ function() {
71486
71756
  return;
71487
71757
  }
71488
71758
  this.maskGizmo.setMode(mode);
71759
+ this.render();
71489
71760
  };
71490
71761
  _proto.openLoadingGizmo = function openLoadingGizmo(id, options) {
71491
71762
  var _this__emitter;
@@ -83091,43 +83362,12 @@ var BaseConfig = {
83091
83362
  },
83092
83363
  cardConfig: {
83093
83364
  backgroundColor: [
83094
- 0.6,
83095
- 0.6,
83096
- 0.6,
83097
- 0.12
83365
+ 1,
83366
+ 1,
83367
+ 1,
83368
+ 0
83098
83369
  ],
83099
- cardTypes: [
83100
- {
83101
- type: 'character',
83102
- label: '角色图',
83103
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83104
- },
83105
- {
83106
- type: 'environment',
83107
- label: '环境图',
83108
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83109
- },
83110
- {
83111
- type: 'storyboard',
83112
- label: '分镜图',
83113
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83114
- },
83115
- {
83116
- type: 'scene-clip',
83117
- label: '场景剪辑',
83118
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83119
- },
83120
- {
83121
- type: 'video-compose',
83122
- label: '视频合成',
83123
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83124
- },
83125
- {
83126
- type: 'video-generate',
83127
- label: '生成视频',
83128
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83129
- }
83130
- ]
83370
+ cardTypes: []
83131
83371
  }
83132
83372
  }
83133
83373
  };
@@ -91456,11 +91696,18 @@ function isCardHTMLAutoHeightMessage(data, id) {
91456
91696
  var message = data;
91457
91697
  return message.source === 'vvfx-card-html-auto-height' && message.id === id && typeof message.height === 'number';
91458
91698
  }
91699
+ function requestCardHTMLAutoHeight(iframe, id) {
91700
+ var _iframe_contentWindow;
91701
+ (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage({
91702
+ source: 'vvfx-card-html-auto-height-request',
91703
+ id: id
91704
+ }, '*');
91705
+ }
91459
91706
  function withCardHTMLAutoHeightBridge(html, id) {
91460
91707
  if (!id) {
91461
91708
  return html;
91462
91709
  }
91463
- var script = "\n<script data-vvfx-card-html-auto-height>\n(() => {\n const id = " + JSON.stringify(id) + ";\n let frame = 0;\n const getChildrenHeight = (element) => {\n if (!element) return 0;\n return Array.from(element.children).reduce((height, child) => {\n const rect = child.getBoundingClientRect();\n return Math.max(height, rect.bottom + window.scrollY);\n }, 0);\n };\n const getHeight = () => {\n const body = document.body;\n const root = document.documentElement;\n const childHeight = getChildrenHeight(body);\n const scrollHeight = Math.max(root.scrollHeight, body ? body.scrollHeight : 0);\n return Math.ceil(Math.max(childHeight, scrollHeight));\n };\n const postHeight = () => {\n frame = 0;\n window.parent.postMessage({\n source: 'vvfx-card-html-auto-height',\n id,\n height: getHeight(),\n }, '*');\n };\n const schedule = () => {\n if (frame) return;\n frame = requestAnimationFrame(postHeight);\n };\n window.addEventListener('load', schedule);\n window.addEventListener('resize', schedule);\n new ResizeObserver(schedule).observe(document.documentElement);\n if (document.body) {\n new ResizeObserver(schedule).observe(document.body);\n new MutationObserver(schedule).observe(document.body, {\n attributes: true,\n childList: true,\n subtree: true,\n characterData: true,\n });\n }\n schedule();\n})();\n</script>";
91710
+ var script = "\n<script data-vvfx-card-html-auto-height>\n(() => {\n const id = " + JSON.stringify(id) + ";\n let frame = 0;\n const getNodeHeight = (node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const rect = node.getBoundingClientRect();\n return rect.bottom + window.scrollY;\n }\n if (node.nodeType === Node.TEXT_NODE && node.textContent.trim()) {\n const range = document.createRange();\n range.selectNodeContents(node);\n const rects = Array.from(range.getClientRects());\n range.detach();\n return rects.reduce((height, rect) => Math.max(height, rect.bottom + window.scrollY), 0);\n }\n\n return 0;\n };\n const getContentHeight = (element) => {\n if (!element) return 0;\n return Array.from(element.childNodes).reduce((height, child) => {\n return Math.max(height, getNodeHeight(child));\n }, 0);\n };\n const getHeight = () => {\n const body = document.body;\n const root = document.documentElement;\n const contentHeight = getContentHeight(body);\n const scrollHeight = Math.max(root.scrollHeight, body ? body.scrollHeight : 0);\n return Math.ceil(contentHeight > 0 ? contentHeight : scrollHeight);\n };\n const postHeight = () => {\n frame = 0;\n window.parent.postMessage({\n source: 'vvfx-card-html-auto-height',\n id,\n height: getHeight(),\n }, '*');\n };\n const schedule = () => {\n if (frame) return;\n frame = requestAnimationFrame(postHeight);\n };\n window.addEventListener('message', (event) => {\n const message = event.data;\n if (!message || message.source !== 'vvfx-card-html-auto-height-request' || message.id !== id) {\n return;\n }\n\n schedule();\n });\n window.addEventListener('load', schedule);\n window.addEventListener('resize', schedule);\n new ResizeObserver(schedule).observe(document.documentElement);\n if (document.body) {\n new ResizeObserver(schedule).observe(document.body);\n new MutationObserver(schedule).observe(document.body, {\n attributes: true,\n childList: true,\n subtree: true,\n characterData: true,\n });\n }\n schedule();\n})();\n</script>";
91464
91711
  if (/<\/body>/i.test(html)) {
91465
91712
  return html.replace(/<\/body>/i, "" + script + "</body>");
91466
91713
  }
@@ -91658,6 +91905,17 @@ function withCardHTMLViewportStyle(html) {
91658
91905
  return "<!doctype html><html><head>" + viewportStyle + "</head><body>" + html + "</body></html>";
91659
91906
  }
91660
91907
 
91908
+ function withCardHTMLAnchorNavigationGuard(html, allowAnchorNavigation) {
91909
+ if (allowAnchorNavigation === true) {
91910
+ return html;
91911
+ }
91912
+ var script = "\n<script data-vvfx-card-html-anchor-navigation-guard>\n(() => {\n document.addEventListener('click', event => {\n const target = event.target;\n if (!(target instanceof Element)) {\n return;\n }\n\n const anchor = target.closest('a[href]');\n if (!anchor) {\n return;\n }\n\n event.preventDefault();\n }, true);\n})();\n</script>";
91913
+ if (/<\/body>/i.test(html)) {
91914
+ return html.replace(/<\/body>/i, "" + script + "</body>");
91915
+ }
91916
+ return "" + html + script;
91917
+ }
91918
+
91661
91919
  function renderDocumentContent(overlay, content, options) {
91662
91920
  var _files_get;
91663
91921
  var iframe = document.createElement('iframe');
@@ -91676,7 +91934,7 @@ function renderDocumentContent(overlay, content, options) {
91676
91934
  iframe.setAttribute('sandbox', content.sandbox);
91677
91935
  }
91678
91936
  var entryHtml = (_files_get = files.get(entry)) != null ? _files_get : '';
91679
- iframe.srcdoc = withCardHTMLAutoHeightBridge(withCardHTMLViewportStyle(transformHTMLDocument(entry, entryHtml, createFileUrl)), options == null ? void 0 : options.autoHeightId);
91937
+ iframe.srcdoc = withCardHTMLAutoHeightBridge(withCardHTMLAnchorNavigationGuard(withCardHTMLViewportStyle(transformHTMLDocument(entry, entryHtml, createFileUrl)), content.allowAnchorNavigation), options == null ? void 0 : options.autoHeightId);
91680
91938
  overlay.appendChild(iframe);
91681
91939
  return function() {
91682
91940
  messageCleanup();
@@ -91733,30 +91991,38 @@ function syncElementStackOrder(_container, elements) {
91733
91991
  });
91734
91992
  }
91735
91993
 
91736
- function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY) {
91994
+ function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
91737
91995
  if (offsetX === void 0) offsetX = 0;
91738
91996
  if (offsetY === void 0) offsetY = 0;
91739
91997
  if (box.corners.length === 4 && width > 0 && height > 0) {
91740
91998
  var _box_corners = box.corners, rightTop = _box_corners[0], leftBottom = _box_corners[2], leftTop = _box_corners[3];
91741
- var a = (rightTop.x - leftTop.x) / width;
91742
- var b = (rightTop.y - leftTop.y) / width;
91743
- var c = (leftBottom.x - leftTop.x) / height;
91744
- var d = (leftBottom.y - leftTop.y) / height;
91999
+ var contentWidth = width;
92000
+ var contentHeight = height;
92001
+ var a = (rightTop.x - leftTop.x) / contentWidth;
92002
+ var b = (rightTop.y - leftTop.y) / contentWidth;
92003
+ var c = (leftBottom.x - leftTop.x) / contentHeight;
92004
+ var d = (leftBottom.y - leftTop.y) / contentHeight;
91745
92005
  var e = leftTop.x - offsetX;
91746
92006
  var f = leftTop.y - offsetY;
91747
92007
  return {
91748
92008
  left: '0px',
91749
92009
  top: '0px',
91750
- width: "" + width + "px",
91751
- height: "" + height + "px",
92010
+ width: "" + formatPixelNumber(contentWidth) + "px",
92011
+ height: "" + formatPixelNumber(contentHeight) + "px",
92012
+ contentWidth: contentWidth,
92013
+ contentHeight: contentHeight,
91752
92014
  transform: "matrix(" + formatMatrixNumber(a) + ", " + formatMatrixNumber(b) + ", " + formatMatrixNumber(c) + ", " + formatMatrixNumber(d) + ", " + formatMatrixNumber(e) + ", " + formatMatrixNumber(f) + ")"
91753
92015
  };
91754
92016
  }
92017
+ var contentWidth1 = box.max.x - box.min.x;
92018
+ var contentHeight1 = box.max.y - box.min.y;
91755
92019
  return {
91756
92020
  left: "" + (box.min.x - offsetX) + "px",
91757
92021
  top: "" + (box.min.y - offsetY) + "px",
91758
- width: "" + (box.max.x - box.min.x) + "px",
91759
- height: "" + (box.max.y - box.min.y) + "px",
92022
+ width: "" + contentWidth1 + "px",
92023
+ height: "" + contentHeight1 + "px",
92024
+ contentWidth: contentWidth1,
92025
+ contentHeight: contentHeight1,
91760
92026
  transform: ''
91761
92027
  };
91762
92028
  }
@@ -91779,6 +92045,10 @@ function formatMatrixNumber(value) {
91779
92045
  var normalized = Object.is(value, -0) ? 0 : value;
91780
92046
  return Number(normalized.toFixed(6)).toString();
91781
92047
  }
92048
+ function formatPixelNumber(value) {
92049
+ var normalized = Object.is(value, -0) ? 0 : value;
92050
+ return Number(normalized.toFixed(6)).toString();
92051
+ }
91782
92052
 
91783
92053
  function mountHTMLShell(container, content, shell) {
91784
92054
  if (!shell) {
@@ -91799,23 +92069,73 @@ function mountHTMLShell(container, content, shell) {
91799
92069
 
91800
92070
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91801
92071
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
92072
+ var CONTENT_INTERACTIVE_SELECTOR = [
92073
+ '[data-vvfx-html-interaction-zone="self"]',
92074
+ '[data-vvfx-html-interaction-zone="subtree"]',
92075
+ 'a[href]',
92076
+ 'button:not([disabled])',
92077
+ 'input:not([disabled])',
92078
+ 'textarea:not([disabled])',
92079
+ 'select:not([disabled])',
92080
+ 'summary',
92081
+ 'video[controls]',
92082
+ 'audio[controls]',
92083
+ '[contenteditable]:not([contenteditable="false"])',
92084
+ '[role="button"]',
92085
+ '[role="link"]',
92086
+ '[role="textbox"]',
92087
+ '[tabindex]:not([tabindex="-1"])'
92088
+ ].join(', ');
92089
+ var CONTENT_INTERACTION_NONE_SELECTOR = [
92090
+ '[data-vvfx-html-interaction-zone="none"]'
92091
+ ].join(', ');
91802
92092
  var EDITING_VIEWPORT_PADDING = 48;
91803
92093
  var EDITING_VIEWPORT_BOX_SCALE = 1.1;
91804
92094
  var AUTO_HEIGHT_EPSILON = 0.5;
91805
92095
  var CARD_RASTERIZE_READY_TIMEOUT = 3000;
92096
+ var CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
92097
+ var requestHTMLOverlayFrame = function requestHTMLOverlayFrame(callback) {
92098
+ if (typeof requestAnimationFrame === 'function') {
92099
+ try {
92100
+ return requestAnimationFrame(callback);
92101
+ } catch (unused) {
92102
+ // Some non-browser test runtimes install a RAF polyfill that depends on window.
92103
+ }
92104
+ }
92105
+ return setTimeout(function() {
92106
+ callback(Date.now());
92107
+ }, 16);
92108
+ };
92109
+ var cancelHTMLOverlayFrame = function cancelHTMLOverlayFrame(frame) {
92110
+ if (typeof cancelAnimationFrame === 'function') {
92111
+ try {
92112
+ cancelAnimationFrame(frame);
92113
+ return;
92114
+ } catch (unused) {
92115
+ // Fall back to clearTimeout for frames created by requestHTMLOverlayFrame.
92116
+ }
92117
+ }
92118
+ clearTimeout(frame);
92119
+ };
91806
92120
  var HTMLOverlayManager = /*#__PURE__*/ function() {
91807
92121
  function HTMLOverlayManager(options) {
91808
92122
  var _this = this;
91809
92123
  this.options = options;
91810
92124
  this.eventCleanups = [];
92125
+ this.htmlRootConfigCleanups = new WeakMap();
91811
92126
  this.state = {
91812
92127
  frameElements: new Map(),
91813
92128
  elements: new Map(),
92129
+ selectionElements: new Map(),
91814
92130
  contentScaleElements: new Map(),
91815
92131
  contentElements: new Map(),
91816
92132
  contentMountElements: new Map(),
92133
+ contentInteractionZones: new Map(),
92134
+ contentInteractionZoneCleanups: new Map(),
92135
+ contentInteractionResizeCleanups: new Map(),
91817
92136
  contents: new Map(),
91818
92137
  cleanups: new Map(),
92138
+ autoHeightModes: new Map(),
91819
92139
  autoHeightCleanups: new Map(),
91820
92140
  autoHeightFrames: new Map()
91821
92141
  };
@@ -91832,12 +92152,18 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91832
92152
  }
91833
92153
  return;
91834
92154
  }
92155
+ if (!_this.isEditableCard(targetId)) {
92156
+ return;
92157
+ }
91835
92158
  event.preventDefault();
91836
92159
  event.stopPropagation();
91837
92160
  _this.enterEditing(targetId);
91838
92161
  };
91839
92162
  this.handleContainerMouseDown = function(event) {
91840
92163
  var _this_state_editing;
92164
+ if (event.button === 0) {
92165
+ _this.selectHTMLInteractionCard(event);
92166
+ }
91841
92167
  var editingId = (_this_state_editing = _this.state.editing) == null ? void 0 : _this_state_editing.id;
91842
92168
  if (!editingId || _this.isEventInsideOverlay(editingId, event)) {
91843
92169
  return;
@@ -91847,6 +92173,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91847
92173
  _this.exitEditing();
91848
92174
  };
91849
92175
  this.handleContainerMouseMove = function(event) {
92176
+ _this.scheduleActiveContentInteractionSync(event);
91850
92177
  var hoverShellInteractiveId = _this.getHoverShellInteractiveIdByEvent(event);
91851
92178
  if (_this.state.hoverShellInteractiveId === hoverShellInteractiveId) {
91852
92179
  return;
@@ -91860,7 +92187,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91860
92187
  _this.syncContentInteraction(hoverShellInteractiveId);
91861
92188
  }
91862
92189
  };
91863
- this.handleContainerMouseLeave = function() {
92190
+ this.handleContainerMouseLeave = function(event) {
92191
+ if (_this.isMouseLeaveWithinContainer(event)) {
92192
+ return;
92193
+ }
92194
+ if (_this.contentInteractionFrame !== undefined) {
92195
+ cancelHTMLOverlayFrame(_this.contentInteractionFrame);
92196
+ _this.contentInteractionFrame = undefined;
92197
+ }
92198
+ _this.pendingContentInteractionEvent = undefined;
92199
+ _this.setActiveContentInteraction(undefined);
91864
92200
  var previousId = _this.state.hoverShellInteractiveId;
91865
92201
  if (!previousId) {
91866
92202
  return;
@@ -91868,6 +92204,33 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91868
92204
  _this.state.hoverShellInteractiveId = undefined;
91869
92205
  _this.syncContentInteraction(previousId);
91870
92206
  };
92207
+ this.handleContainerContextMenu = function(event) {
92208
+ var activeInteraction = _this.state.activeContentInteraction;
92209
+ if (!activeInteraction || !_this.isEventInsideOverlay(activeInteraction.id, event) || _this.isHTMLContextMenuEvent(event)) {
92210
+ return;
92211
+ }
92212
+ var canvas = _this.options.getCanvasEventTarget == null ? void 0 : _this.options.getCanvasEventTarget.call(_this.options);
92213
+ if (!canvas) {
92214
+ return;
92215
+ }
92216
+ event.preventDefault();
92217
+ event.stopPropagation();
92218
+ _this.setActiveContentInteraction(undefined);
92219
+ canvas.dispatchEvent(new MouseEvent('contextmenu', {
92220
+ bubbles: true,
92221
+ cancelable: true,
92222
+ clientX: event.clientX,
92223
+ clientY: event.clientY,
92224
+ screenX: event.screenX,
92225
+ screenY: event.screenY,
92226
+ button: event.button,
92227
+ buttons: event.buttons,
92228
+ ctrlKey: event.ctrlKey,
92229
+ shiftKey: event.shiftKey,
92230
+ altKey: event.altKey,
92231
+ metaKey: event.metaKey
92232
+ }));
92233
+ };
91871
92234
  this.isAutoHeightMessage = isCardHTMLAutoHeightMessage;
91872
92235
  }
91873
92236
  var _proto = HTMLOverlayManager.prototype;
@@ -91881,7 +92244,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91881
92244
  layer.style.position = 'absolute';
91882
92245
  layer.style.inset = '0';
91883
92246
  layer.style.pointerEvents = 'none';
91884
- layer.style.zIndex = '1';
91885
92247
  container.appendChild(layer);
91886
92248
  this.state.layer = layer;
91887
92249
  this.initDOMEvents();
@@ -91891,25 +92253,41 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91891
92253
  _proto.dispose = function dispose() {
91892
92254
  var _this_state_layer;
91893
92255
  if (this.state.updateFrame !== undefined) {
91894
- cancelAnimationFrame(this.state.updateFrame);
92256
+ cancelHTMLOverlayFrame(this.state.updateFrame);
91895
92257
  this.state.updateFrame = undefined;
91896
92258
  }
92259
+ if (this.contentInteractionFrame !== undefined) {
92260
+ cancelHTMLOverlayFrame(this.contentInteractionFrame);
92261
+ this.contentInteractionFrame = undefined;
92262
+ }
92263
+ this.pendingContentInteractionEvent = undefined;
91897
92264
  this.state.cleanups.forEach(function(cleanup) {
91898
92265
  cleanup();
91899
92266
  });
91900
92267
  this.state.frameElements.clear();
91901
92268
  this.state.elements.clear();
92269
+ this.state.selectionElements.clear();
91902
92270
  this.state.contentScaleElements.clear();
91903
92271
  this.state.contentElements.clear();
91904
92272
  this.state.contentMountElements.clear();
92273
+ this.state.contentInteractionZones.clear();
92274
+ this.state.contentInteractionZoneCleanups.forEach(function(cleanup) {
92275
+ cleanup();
92276
+ });
92277
+ this.state.contentInteractionZoneCleanups.clear();
92278
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92279
+ cleanup();
92280
+ });
92281
+ this.state.contentInteractionResizeCleanups.clear();
91905
92282
  this.state.contents.clear();
91906
92283
  this.state.cleanups.clear();
92284
+ this.state.autoHeightModes.clear();
91907
92285
  this.state.autoHeightCleanups.forEach(function(cleanup) {
91908
92286
  cleanup();
91909
92287
  });
91910
92288
  this.state.autoHeightCleanups.clear();
91911
92289
  this.state.autoHeightFrames.forEach(function(frame) {
91912
- cancelAnimationFrame(frame);
92290
+ cancelHTMLOverlayFrame(frame);
91913
92291
  });
91914
92292
  this.state.autoHeightFrames.clear();
91915
92293
  this.eventCleanups.forEach(function(cleanup) {
@@ -91918,21 +92296,61 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91918
92296
  this.eventCleanups = [];
91919
92297
  (_this_state_layer = this.state.layer) == null ? void 0 : _this_state_layer.remove();
91920
92298
  this.state.layer = undefined;
92299
+ this.state.selectionLayer = undefined;
91921
92300
  this.options.container.removeEventListener('dblclick', this.handleContainerDoubleClick, true);
91922
92301
  this.options.container.removeEventListener('mousedown', this.handleContainerMouseDown, true);
91923
92302
  this.options.container.removeEventListener('mousemove', this.handleContainerMouseMove, true);
91924
92303
  this.options.container.removeEventListener('mouseleave', this.handleContainerMouseLeave, true);
92304
+ this.options.container.removeEventListener('contextmenu', this.handleContainerContextMenu, true);
91925
92305
  };
91926
92306
  _proto.scheduleRender = function scheduleRender() {
91927
92307
  var _this = this;
91928
92308
  if (this.state.updateFrame !== undefined) {
91929
- cancelAnimationFrame(this.state.updateFrame);
92309
+ cancelHTMLOverlayFrame(this.state.updateFrame);
91930
92310
  }
91931
- this.state.updateFrame = requestAnimationFrame(function() {
92311
+ this.state.updateFrame = requestHTMLOverlayFrame(function() {
91932
92312
  _this.state.updateFrame = undefined;
91933
92313
  _this.render();
91934
92314
  });
91935
92315
  };
92316
+ _proto.invalidateCardHTML = function invalidateCardHTML(id) {
92317
+ this.cleanupOverlayContent(id);
92318
+ this.invalidateContentInteractionZones(id);
92319
+ };
92320
+ _proto.getHtmlCardWindow = function getHtmlCardWindow(id) {
92321
+ var contentOverlay = this.state.contentElements.get(id);
92322
+ var iframe = contentOverlay == null ? void 0 : contentOverlay.querySelector('iframe');
92323
+ return iframe == null ? void 0 : iframe.contentWindow;
92324
+ };
92325
+ _proto.patchCardHTML = function patchCardHTML(id, patch) {
92326
+ var html = this.state.contents.get(id);
92327
+ if (!html) {
92328
+ return false;
92329
+ }
92330
+ var patchHandler = html.content.patch;
92331
+ if (!patchHandler) {
92332
+ return false;
92333
+ }
92334
+ var context = this.createPatchContext(id, html);
92335
+ return patchHandler(patch, context) !== false;
92336
+ };
92337
+ _proto.dispatchHtmlCardEvent = function dispatchHtmlCardEvent(id, type, detail) {
92338
+ var targetWindow = this.getHtmlCardWindow(id);
92339
+ try {
92340
+ if (!targetWindow || typeof targetWindow.postMessage !== 'function') {
92341
+ return false;
92342
+ }
92343
+ targetWindow.postMessage({
92344
+ detail: detail,
92345
+ payload: detail,
92346
+ source: CARD_HTML_EVENT_MESSAGE_SOURCE,
92347
+ type: type
92348
+ }, '*');
92349
+ return true;
92350
+ } catch (unused) {
92351
+ return false;
92352
+ }
92353
+ };
91936
92354
  _proto.rasterizeCard = function rasterizeCard(id, options) {
91937
92355
  return _async_to_generator(function() {
91938
92356
  var contentOverlay, capture, _ref, _options_pixelRatio, image, error;
@@ -91940,7 +92358,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91940
92358
  switch(_state.label){
91941
92359
  case 0:
91942
92360
  if (this.state.updateFrame !== undefined) {
91943
- cancelAnimationFrame(this.state.updateFrame);
92361
+ cancelHTMLOverlayFrame(this.state.updateFrame);
91944
92362
  this.state.updateFrame = undefined;
91945
92363
  }
91946
92364
  this.render();
@@ -92025,6 +92443,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92025
92443
  var events = [
92026
92444
  'pageDataChange',
92027
92445
  'selectedItemChange',
92446
+ 'preSelectedItemChange',
92028
92447
  'itemPropertyChange',
92029
92448
  'viewportTransform',
92030
92449
  'viewRebuildFinish'
@@ -92034,6 +92453,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92034
92453
  if (event === 'viewportTransform') {
92035
92454
  _this.handleViewportTransform();
92036
92455
  }
92456
+ _this.invalidateContentInteractionZones();
92037
92457
  _this.scheduleRender();
92038
92458
  });
92039
92459
  });
@@ -92043,6 +92463,33 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92043
92463
  this.options.container.addEventListener('mousedown', this.handleContainerMouseDown, true);
92044
92464
  this.options.container.addEventListener('mousemove', this.handleContainerMouseMove, true);
92045
92465
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92466
+ this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92467
+ };
92468
+ _proto.selectHTMLInteractionCard = function selectHTMLInteractionCard(event) {
92469
+ var decision = this.resolveHTMLInteractionTarget(event);
92470
+ if (decision.kind !== 'html') {
92471
+ return;
92472
+ }
92473
+ this.options.setSelectedItemIds([
92474
+ decision.interaction.id
92475
+ ]);
92476
+ };
92477
+ _proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
92478
+ var relatedTarget = event.relatedTarget;
92479
+ if (!relatedTarget) {
92480
+ return false;
92481
+ }
92482
+ try {
92483
+ return this.options.container.contains(relatedTarget);
92484
+ } catch (unused) {
92485
+ return false;
92486
+ }
92487
+ };
92488
+ _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92489
+ if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92490
+ return false;
92491
+ }
92492
+ return !!event.target.closest('[data-interaction-contextmenu="self"], [data-vvfx-html-contextmenu="self"]');
92046
92493
  };
92047
92494
  _proto.handleViewportTransform = function handleViewportTransform() {
92048
92495
  var editing = this.state.editing;
@@ -92062,11 +92509,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92062
92509
  }
92063
92510
  var items = this.options.getItems();
92064
92511
  var frameByChildId = this.renderFrameOverlays(items, layer);
92512
+ var selectionLayer = this.getOrCreateSelectionLayer(layer);
92065
92513
  var visibleCardIds = new Set();
92066
92514
  var editingVisible = false;
92067
92515
  items.forEach(function(item) {
92068
92516
  var _this_state_editing;
92069
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92517
+ if (!isCardItem(item) || !item.visible) {
92518
+ return;
92519
+ }
92520
+ var html = _this.options.resolveCardHTML(item);
92521
+ if (html === undefined) {
92070
92522
  return;
92071
92523
  }
92072
92524
  var itemBox = _this.options.getViewBoxById(item.id);
@@ -92081,21 +92533,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92081
92533
  var frameBox = frameId ? _this.options.getViewBoxById(frameId) : undefined;
92082
92534
  var overlay = _this.getOrCreateOverlay(item.id, parentOverlay, elements);
92083
92535
  var contentOverlay = _this.getOrCreateContentOverlay(item.id, overlay);
92084
- var html = item.html;
92085
- if (html && _this.state.contents.get(item.id) !== html) {
92086
- _this.renderOverlayHTML(item.id, contentOverlay, html);
92087
- }
92536
+ var selectionOverlay = _this.getOrCreateSelectionOverlay(item.id, selectionLayer);
92088
92537
  var offsetX = frameBox && !frameBox.isEmpty() ? frameBox.min.x : 0;
92089
92538
  var offsetY = frameBox && !frameBox.isEmpty() ? frameBox.min.y : 0;
92090
- var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY);
92539
+ var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, _this.isAutoScaleEnabled(item));
92540
+ _this.applyHTMLRootConfig(overlay, html);
92091
92541
  overlay.style.left = boxStyle.left;
92092
92542
  overlay.style.top = boxStyle.top;
92093
92543
  overlay.style.width = boxStyle.width;
92094
92544
  overlay.style.height = boxStyle.height;
92095
92545
  overlay.style.transform = boxStyle.transform;
92096
92546
  overlay.style.transformOrigin = '0 0';
92097
- _this.syncContentScale(item.id, item.property.width, item.property.height);
92098
- _this.syncAutoHeight(item.id, item.property.autoHeight === true);
92547
+ var selectionBoxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, 0, 0, _this.isAutoScaleEnabled(item));
92548
+ selectionOverlay.style.left = selectionBoxStyle.left;
92549
+ selectionOverlay.style.top = selectionBoxStyle.top;
92550
+ selectionOverlay.style.width = selectionBoxStyle.width;
92551
+ selectionOverlay.style.height = selectionBoxStyle.height;
92552
+ selectionOverlay.style.transform = selectionBoxStyle.transform;
92553
+ selectionOverlay.style.transformOrigin = '0 0';
92554
+ _this.applyHTMLRootConfig(selectionOverlay, html);
92555
+ _this.makeSelectionOverlayTransparent(selectionOverlay);
92556
+ _this.syncOverlaySelection(item.id, overlay, selectionOverlay);
92557
+ _this.syncContentScale(item.id, boxStyle.contentWidth, boxStyle.contentHeight);
92558
+ if (!_this.state.contents.has(item.id)) {
92559
+ _this.renderOverlayHTML(item.id, contentOverlay, html);
92560
+ }
92561
+ _this.syncAutoHeight(item.id, _this.isAutoHeightEnabled(item));
92099
92562
  _this.syncContentInteraction(item.id);
92100
92563
  });
92101
92564
  elements.forEach(function(_overlay, id) {
@@ -92134,6 +92597,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92134
92597
  }
92135
92598
  }
92136
92599
  syncElementStackOrder(layer, rootElements);
92600
+ if (this.state.selectionLayer) {
92601
+ this.state.selectionLayer.style.zIndex = "" + (rootElements.length + 1);
92602
+ }
92137
92603
  this.state.frameElements.forEach(function(frameOverlay, frameId) {
92138
92604
  var frameElements = [];
92139
92605
  for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
@@ -92149,6 +92615,28 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92149
92615
  syncElementStackOrder(frameOverlay, frameElements);
92150
92616
  });
92151
92617
  };
92618
+ _proto.getOrCreateSelectionLayer = function getOrCreateSelectionLayer(layer) {
92619
+ var _layer_ownerDocument;
92620
+ if (this.state.selectionLayer) {
92621
+ if (this.state.selectionLayer.parentElement !== layer) {
92622
+ layer.appendChild(this.state.selectionLayer);
92623
+ }
92624
+ return this.state.selectionLayer;
92625
+ }
92626
+ var ownerDocument = (_layer_ownerDocument = layer.ownerDocument) != null ? _layer_ownerDocument : typeof document === 'undefined' ? undefined : document;
92627
+ if (!ownerDocument) {
92628
+ return layer;
92629
+ }
92630
+ var selectionLayer = ownerDocument.createElement('div');
92631
+ selectionLayer.className = 'vvfx-card-html-overlay-selection-layer';
92632
+ selectionLayer.style.position = 'absolute';
92633
+ selectionLayer.style.inset = '0';
92634
+ selectionLayer.style.pointerEvents = 'none';
92635
+ selectionLayer.style.zIndex = '1';
92636
+ layer.appendChild(selectionLayer);
92637
+ this.state.selectionLayer = selectionLayer;
92638
+ return selectionLayer;
92639
+ };
92152
92640
  _proto.renderFrameOverlays = function renderFrameOverlays(items, layer) {
92153
92641
  var _this = this;
92154
92642
  var visibleFrameIds = new Set();
@@ -92213,6 +92701,41 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92213
92701
  elements.set(id, overlay);
92214
92702
  return overlay;
92215
92703
  };
92704
+ _proto.getOrCreateSelectionOverlay = function getOrCreateSelectionOverlay(id, parent) {
92705
+ var selectionOverlay = this.state.selectionElements.get(id);
92706
+ if (selectionOverlay) {
92707
+ if (selectionOverlay.parentElement !== parent) {
92708
+ parent.appendChild(selectionOverlay);
92709
+ }
92710
+ return selectionOverlay;
92711
+ }
92712
+ selectionOverlay = document.createElement('div');
92713
+ selectionOverlay.className = 'vvfx-card-html-overlay-selection';
92714
+ selectionOverlay.dataset.itemId = id;
92715
+ selectionOverlay.style.position = 'absolute';
92716
+ selectionOverlay.style.pointerEvents = 'none';
92717
+ selectionOverlay.style.zIndex = '1';
92718
+ parent.appendChild(selectionOverlay);
92719
+ this.state.selectionElements.set(id, selectionOverlay);
92720
+ return selectionOverlay;
92721
+ };
92722
+ _proto.syncOverlaySelection = function syncOverlaySelection(id, overlay, selectionOverlay) {
92723
+ var isSelected = this.options.getSelectedItemIds().includes(id);
92724
+ var isPreSelected = !isSelected && this.options.getPreSelectedItemId() === id;
92725
+ overlay.dataset.selected = isSelected ? 'true' : 'false';
92726
+ overlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92727
+ selectionOverlay.dataset.selected = isSelected ? 'true' : 'false';
92728
+ selectionOverlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92729
+ selectionOverlay.style.boxShadow = isSelected ? this.getSelectionBoxShadow() : isPreSelected ? this.getPreSelectionBoxShadow() : '';
92730
+ };
92731
+ _proto.getSelectionBoxShadow = function getSelectionBoxShadow() {
92732
+ var _this_options_getSelectionEdgeStyle = this.options.getSelectionEdgeStyle(), color = _this_options_getSelectionEdgeStyle.color, alpha = _this_options_getSelectionEdgeStyle.alpha, width = _this_options_getSelectionEdgeStyle.width;
92733
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92734
+ };
92735
+ _proto.getPreSelectionBoxShadow = function getPreSelectionBoxShadow() {
92736
+ var _this_options_getPreSelectionEdgeStyle = this.options.getPreSelectionEdgeStyle(), color = _this_options_getPreSelectionEdgeStyle.color, alpha = _this_options_getPreSelectionEdgeStyle.alpha, width = _this_options_getPreSelectionEdgeStyle.width;
92737
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92738
+ };
92216
92739
  _proto.getHTMLCardIdByEvent = function getHTMLCardIdByEvent(event) {
92217
92740
  var layer = this.state.layer;
92218
92741
  if (!layer) {
@@ -92222,7 +92745,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92222
92745
  var items = this.options.getItems();
92223
92746
  for(var i = items.length - 1; i >= 0; i--){
92224
92747
  var item = items[i];
92225
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92748
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92226
92749
  continue;
92227
92750
  }
92228
92751
  var box = this.options.getViewBoxById(item.id);
@@ -92241,7 +92764,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92241
92764
  var items = this.options.getItems();
92242
92765
  for(var i = items.length - 1; i >= 0; i--){
92243
92766
  var item = items[i];
92244
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92767
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92245
92768
  continue;
92246
92769
  }
92247
92770
  var box = this.options.getViewBoxById(item.id);
@@ -92251,13 +92774,212 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92251
92774
  var contentOverlay = this.state.contentElements.get(item.id);
92252
92775
  var interactiveElements = contentOverlay ? Array.from(contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR)) : [];
92253
92776
  var isHoveringShellInteractive = interactiveElements.some(function(element) {
92254
- var rect = element.getBoundingClientRect();
92255
- return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
92777
+ return isMouseEventInsideRect(event, element.getBoundingClientRect());
92256
92778
  });
92257
92779
  return isHoveringShellInteractive ? item.id : undefined;
92258
92780
  }
92259
92781
  return undefined;
92260
92782
  };
92783
+ _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92784
+ var decision = this.resolveHTMLInteractionTarget(event);
92785
+ if (decision.kind === 'canvas' && this.shouldKeepActiveContentInteractionForFocusedElement()) {
92786
+ return;
92787
+ }
92788
+ this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
92789
+ };
92790
+ _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92791
+ var _this = this;
92792
+ if (typeof requestAnimationFrame !== 'function') {
92793
+ this.syncActiveContentInteraction(event);
92794
+ return;
92795
+ }
92796
+ this.pendingContentInteractionEvent = event;
92797
+ if (this.contentInteractionFrame !== undefined) {
92798
+ return;
92799
+ }
92800
+ try {
92801
+ this.contentInteractionFrame = requestAnimationFrame(function() {
92802
+ _this.contentInteractionFrame = undefined;
92803
+ var pendingEvent = _this.pendingContentInteractionEvent;
92804
+ _this.pendingContentInteractionEvent = undefined;
92805
+ if (pendingEvent) {
92806
+ _this.syncActiveContentInteraction(pendingEvent);
92807
+ }
92808
+ });
92809
+ } catch (unused) {
92810
+ this.contentInteractionFrame = undefined;
92811
+ this.pendingContentInteractionEvent = undefined;
92812
+ this.syncActiveContentInteraction(event);
92813
+ }
92814
+ };
92815
+ _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92816
+ var _this = this;
92817
+ var previous = this.state.activeContentInteraction;
92818
+ if ((previous == null ? void 0 : previous.id) === (zone == null ? void 0 : zone.id) && (previous == null ? void 0 : previous.element) === (zone == null ? void 0 : zone.element) && (previous == null ? void 0 : previous.zone) === (zone == null ? void 0 : zone.zone)) {
92819
+ return;
92820
+ }
92821
+ this.state.activeContentInteraction = zone;
92822
+ var changedIds = new Set();
92823
+ if (previous) {
92824
+ changedIds.add(previous.id);
92825
+ }
92826
+ if (zone) {
92827
+ changedIds.add(zone.id);
92828
+ }
92829
+ changedIds.forEach(function(id) {
92830
+ _this.syncContentInteraction(id);
92831
+ });
92832
+ };
92833
+ _proto.shouldKeepActiveContentInteractionForFocusedElement = function shouldKeepActiveContentInteractionForFocusedElement() {
92834
+ var activeInteraction = this.state.activeContentInteraction;
92835
+ if (!activeInteraction || typeof document === 'undefined') {
92836
+ return false;
92837
+ }
92838
+ var activeElement = document.activeElement;
92839
+ if (!activeElement || activeElement === document.body) {
92840
+ return false;
92841
+ }
92842
+ var interactionElement = activeInteraction.element;
92843
+ return interactionElement === activeElement || typeof interactionElement.contains === 'function' && interactionElement.contains(activeElement);
92844
+ };
92845
+ _proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
92846
+ var id = this.getHTMLCardIdByEvent(event);
92847
+ if (!id || this.isEditableCard(id)) {
92848
+ return {
92849
+ kind: 'canvas',
92850
+ id: id
92851
+ };
92852
+ }
92853
+ var contentOverlay = this.state.contentElements.get(id);
92854
+ if (!contentOverlay) {
92855
+ return {
92856
+ kind: 'canvas',
92857
+ id: id
92858
+ };
92859
+ }
92860
+ var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
92861
+ if (activeSubtree) {
92862
+ return {
92863
+ kind: 'html',
92864
+ interaction: activeSubtree
92865
+ };
92866
+ }
92867
+ var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
92868
+ return isMouseEventInsideRect(event, zone.rect);
92869
+ });
92870
+ var zone = this.resolveContentInteractionZone(matchedZones);
92871
+ if (zone) {
92872
+ return {
92873
+ kind: 'html',
92874
+ interaction: {
92875
+ id: id,
92876
+ element: zone.element,
92877
+ zone: zone.zone
92878
+ }
92879
+ };
92880
+ }
92881
+ return {
92882
+ kind: 'canvas',
92883
+ id: id
92884
+ };
92885
+ };
92886
+ _proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
92887
+ var activeInteraction = this.state.activeContentInteraction;
92888
+ if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
92889
+ return undefined;
92890
+ }
92891
+ var rect = activeInteraction.element.getBoundingClientRect();
92892
+ return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
92893
+ };
92894
+ _proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
92895
+ if (zones.length <= 1) {
92896
+ return zones[0];
92897
+ }
92898
+ var subtreeRoot = zones.find(function(candidate) {
92899
+ return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
92900
+ return zone.element !== candidate.element && candidate.element.contains(zone.element);
92901
+ });
92902
+ });
92903
+ return subtreeRoot != null ? subtreeRoot : zones[0];
92904
+ };
92905
+ _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92906
+ var _this = this;
92907
+ var cachedZones = this.state.contentInteractionZones.get(id);
92908
+ if (cachedZones) {
92909
+ return cachedZones;
92910
+ }
92911
+ var zones = Array.from(contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id))).filter(function(element) {
92912
+ return !_this.isContentInteractionDisabled(element);
92913
+ }).map(function(element) {
92914
+ return {
92915
+ element: element,
92916
+ rect: element.getBoundingClientRect(),
92917
+ zone: _this.getContentInteractionZoneMode(element)
92918
+ };
92919
+ });
92920
+ this.state.contentInteractionZones.set(id, zones);
92921
+ this.observeContentInteractionZoneResizes(id, zones);
92922
+ return zones;
92923
+ };
92924
+ _proto.getContentInteractiveSelector = function getContentInteractiveSelector(id) {
92925
+ var _ref;
92926
+ var _this_options_resolveCardTypeConfig_htmlInteractionSelectors, _this_options_resolveCardTypeConfig;
92927
+ var item = this.options.getItems().find(function(item) {
92928
+ return item.id === id;
92929
+ });
92930
+ if (!item) {
92931
+ return CONTENT_INTERACTIVE_SELECTOR;
92932
+ }
92933
+ var selectors = (_ref = (_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : (_this_options_resolveCardTypeConfig_htmlInteractionSelectors = _this_options_resolveCardTypeConfig.htmlInteractionSelectors) == null ? void 0 : _this_options_resolveCardTypeConfig_htmlInteractionSelectors.filter(Boolean)) != null ? _ref : [];
92934
+ if (selectors.length === 0) {
92935
+ return CONTENT_INTERACTIVE_SELECTOR;
92936
+ }
92937
+ return [].concat([
92938
+ CONTENT_INTERACTIVE_SELECTOR
92939
+ ], selectors).join(', ');
92940
+ };
92941
+ _proto.isContentInteractionDisabled = function isContentInteractionDisabled(element) {
92942
+ if (typeof element.closest !== 'function') {
92943
+ return false;
92944
+ }
92945
+ return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92946
+ };
92947
+ _proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
92948
+ var zone = element.dataset.vvfxHtmlInteractionZone;
92949
+ return zone === 'subtree' ? 'subtree' : 'self';
92950
+ };
92951
+ _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92952
+ if (id) {
92953
+ var _this_state_contentInteractionResizeCleanups_get;
92954
+ this.state.contentInteractionZones.delete(id);
92955
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92956
+ this.state.contentInteractionResizeCleanups.delete(id);
92957
+ return;
92958
+ }
92959
+ this.state.contentInteractionZones.clear();
92960
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92961
+ cleanup();
92962
+ });
92963
+ this.state.contentInteractionResizeCleanups.clear();
92964
+ };
92965
+ _proto.observeContentInteractionZoneResizes = function observeContentInteractionZoneResizes(id, zones) {
92966
+ var _this = this;
92967
+ var _this_state_contentInteractionResizeCleanups_get;
92968
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92969
+ this.state.contentInteractionResizeCleanups.delete(id);
92970
+ if (zones.length === 0 || typeof ResizeObserver !== 'function') {
92971
+ return;
92972
+ }
92973
+ var observer = new ResizeObserver(function() {
92974
+ _this.invalidateContentInteractionZones(id);
92975
+ });
92976
+ zones.forEach(function(zone) {
92977
+ observer.observe(zone.element);
92978
+ });
92979
+ this.state.contentInteractionResizeCleanups.set(id, function() {
92980
+ observer.disconnect();
92981
+ });
92982
+ };
92261
92983
  _proto.getLayerPoint = function getLayerPoint(event) {
92262
92984
  var rect = this.options.container.getBoundingClientRect();
92263
92985
  return {
@@ -92314,19 +93036,35 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92314
93036
  if (!scaleOverlay || !contentOverlay || width <= 0 || height <= 0) {
92315
93037
  return;
92316
93038
  }
92317
- scaleOverlay.style.width = "" + width + "px";
92318
- scaleOverlay.style.height = "" + height + "px";
93039
+ var nextWidth = "" + width + "px";
93040
+ var nextHeight = "" + height + "px";
93041
+ var sizeChanged = scaleOverlay.style.width !== nextWidth || scaleOverlay.style.height !== nextHeight;
93042
+ scaleOverlay.style.width = nextWidth;
93043
+ scaleOverlay.style.height = nextHeight;
92319
93044
  scaleOverlay.style.transform = 'none';
92320
- contentOverlay.style.width = "" + width + "px";
92321
- contentOverlay.style.height = "" + height + "px";
93045
+ contentOverlay.style.width = nextWidth;
93046
+ contentOverlay.style.height = nextHeight;
93047
+ if (sizeChanged && this.state.autoHeightModes.get(id) === 'message') {
93048
+ this.requestAutoHeightFromIframes(id, contentOverlay);
93049
+ }
93050
+ if (sizeChanged) {
93051
+ this.invalidateContentInteractionZones(id);
93052
+ }
93053
+ };
93054
+ _proto.requestAutoHeightFromIframes = function requestAutoHeightFromIframes(id, contentOverlay) {
93055
+ contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
93056
+ requestCardHTMLAutoHeight(iframe, id);
93057
+ });
92322
93058
  };
92323
93059
  _proto.syncContentInteraction = function syncContentInteraction(id) {
92324
- var _this_state_editing;
93060
+ var _this_state_editing, _this_state_activeContentInteraction;
92325
93061
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
93062
+ var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
92326
93063
  var overlay = this.state.elements.get(id);
92327
93064
  var scaleOverlay = this.state.contentScaleElements.get(id);
92328
93065
  var contentOverlay = this.state.contentElements.get(id);
92329
93066
  var contentMount = this.state.contentMountElements.get(id);
93067
+ var isInteractive = isEditing || !!activeInteraction;
92330
93068
  if (overlay) {
92331
93069
  overlay.dataset.editing = isEditing ? 'true' : 'false';
92332
93070
  overlay.style.pointerEvents = 'none';
@@ -92337,34 +93075,62 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92337
93075
  }
92338
93076
  if (contentOverlay) {
92339
93077
  contentOverlay.dataset.editing = isEditing ? 'true' : 'false';
92340
- contentOverlay.style.pointerEvents = 'none';
93078
+ contentOverlay.style.pointerEvents = isInteractive ? 'auto' : 'none';
92341
93079
  contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92342
- iframe.style.pointerEvents = isEditing ? 'auto' : 'none';
92343
- iframe.tabIndex = isEditing ? 0 : -1;
93080
+ var isActiveIframe = isEditing || (activeInteraction == null ? void 0 : activeInteraction.element) === iframe;
93081
+ iframe.style.pointerEvents = isActiveIframe ? 'auto' : 'none';
93082
+ iframe.tabIndex = isActiveIframe ? 0 : -1;
92344
93083
  });
92345
- this.syncShellInteraction(id, contentOverlay, isEditing);
93084
+ this.syncShellInteraction(id, contentOverlay, isInteractive);
93085
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
92346
93086
  }
92347
93087
  if (contentMount) {
92348
93088
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
92349
- contentMount.style.pointerEvents = isEditing ? 'auto' : 'none';
92350
- contentMount.inert = !isEditing;
92351
- if (isEditing) {
93089
+ contentMount.style.pointerEvents = isInteractive ? 'auto' : 'none';
93090
+ contentMount.inert = !isInteractive;
93091
+ if (isInteractive) {
92352
93092
  contentMount.removeAttribute('aria-hidden');
92353
93093
  } else {
92354
93094
  contentMount.setAttribute('aria-hidden', 'true');
92355
93095
  }
92356
93096
  }
92357
93097
  };
92358
- _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isEditing) {
93098
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
93099
+ var _this = this;
93100
+ var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
93101
+ contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
93102
+ if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
93103
+ _this.clearContentInteractionState(element);
93104
+ return;
93105
+ }
93106
+ if (!isInteractive) {
93107
+ _this.clearContentInteractionState(element);
93108
+ return;
93109
+ }
93110
+ if (_this.isContentInteractionDisabled(element)) {
93111
+ element.dataset.vvfxHtmlInteractionActive = 'false';
93112
+ element.style.pointerEvents = 'none';
93113
+ return;
93114
+ }
93115
+ var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
93116
+ element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
93117
+ element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
93118
+ });
93119
+ };
93120
+ _proto.clearContentInteractionState = function clearContentInteractionState(element) {
93121
+ delete element.dataset.vvfxHtmlInteractionActive;
93122
+ element.style.pointerEvents = '';
93123
+ };
93124
+ _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92359
93125
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92360
- var isShellInteractiveActive = isEditing || isHoveringShellInteractive;
93126
+ var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
92361
93127
  contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR).forEach(function(element) {
92362
93128
  element.dataset.vvfxHtmlShellInteractiveHover = isHoveringShellInteractive ? 'true' : 'false';
92363
93129
  element.dataset.vvfxHtmlShellInteractiveActive = isShellInteractiveActive ? 'true' : 'false';
92364
93130
  element.style.pointerEvents = isShellInteractiveActive ? 'auto' : 'none';
92365
93131
  });
92366
93132
  contentOverlay.querySelectorAll(EDITING_INTERACTIVE_SELECTOR).forEach(function(element) {
92367
- element.style.pointerEvents = isEditing ? 'auto' : 'none';
93133
+ element.style.pointerEvents = isInteractive ? 'auto' : 'none';
92368
93134
  });
92369
93135
  };
92370
93136
  _proto.enterEditing = function enterEditing(id) {
@@ -92372,6 +93138,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92372
93138
  if (((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id) {
92373
93139
  return;
92374
93140
  }
93141
+ if (!this.isEditableCard(id)) {
93142
+ return;
93143
+ }
92375
93144
  var box = this.options.getViewBoxById(id);
92376
93145
  if (box.isEmpty()) {
92377
93146
  return;
@@ -92415,6 +93184,13 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92415
93184
  this.options.setViewport(editing.restoreViewport);
92416
93185
  this.scheduleRender();
92417
93186
  };
93187
+ _proto.isEditableCard = function isEditableCard(id) {
93188
+ var _this_options_resolveCardTypeConfig;
93189
+ var item = this.options.getItems().find(function(item) {
93190
+ return item.id === id;
93191
+ });
93192
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.editable) !== false;
93193
+ };
92418
93194
  _proto.getEditingFitZoom = function getEditingFitZoom(box, currentZoom) {
92419
93195
  var viewportElement = this.options.container.parentElement;
92420
93196
  if (!viewportElement) {
@@ -92439,6 +93215,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92439
93215
  };
92440
93216
  _proto.renderOverlayHTML = function renderOverlayHTML(id, overlay, html) {
92441
93217
  this.cleanupOverlayContent(id);
93218
+ this.invalidateContentInteractionZones(id);
92442
93219
  overlay.innerHTML = '';
92443
93220
  var shell = mountHTMLShell(overlay, html.content, html.shell);
92444
93221
  var autoHeightMeasureElement = shell.contentContainer.isConnected ? shell.contentContainer : overlay;
@@ -92448,18 +93225,99 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92448
93225
  });
92449
93226
  var contentCleanup = this.renderOverlayContent(shell.contentContainer, html.content, {
92450
93227
  id: id,
92451
- autoHeight: isCardItem(item) && item.property.autoHeight === true
93228
+ autoHeight: this.isAutoHeightEnabled(item)
92452
93229
  });
93230
+ this.observeContentInteractionZones(id, shell.contentContainer);
92453
93231
  this.state.cleanups.set(id, function() {
92454
93232
  contentCleanup == null ? void 0 : contentCleanup();
92455
93233
  shell.cleanup == null ? void 0 : shell.cleanup.call(shell);
92456
93234
  });
92457
93235
  this.state.contents.set(id, html);
92458
93236
  };
93237
+ _proto.createPatchContext = function createPatchContext(id, html) {
93238
+ var _this = this;
93239
+ return {
93240
+ id: id,
93241
+ html: html,
93242
+ content: html.content,
93243
+ container: this.state.contentMountElements.get(id),
93244
+ contentWindow: this.getHtmlCardWindow(id),
93245
+ refresh: function refresh() {
93246
+ _this.invalidateCardHTML(id);
93247
+ _this.scheduleRender();
93248
+ }
93249
+ };
93250
+ };
93251
+ _proto.observeContentInteractionZones = function observeContentInteractionZones(id, contentContainer) {
93252
+ var _this = this;
93253
+ var _this_state_contentInteractionZoneCleanups_get;
93254
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
93255
+ this.state.contentInteractionZoneCleanups.delete(id);
93256
+ if (typeof MutationObserver !== 'function') {
93257
+ return;
93258
+ }
93259
+ var observer = new MutationObserver(function() {
93260
+ _this.invalidateContentInteractionZones(id);
93261
+ });
93262
+ observer.observe(contentContainer, {
93263
+ attributes: true,
93264
+ childList: true,
93265
+ subtree: true
93266
+ });
93267
+ this.state.contentInteractionZoneCleanups.set(id, function() {
93268
+ observer.disconnect();
93269
+ });
93270
+ };
93271
+ _proto.applyHTMLRootConfig = function applyHTMLRootConfig(root, html) {
93272
+ var _ref, _config_style;
93273
+ var _this_htmlRootConfigCleanups_get, _config_className;
93274
+ (_this_htmlRootConfigCleanups_get = this.htmlRootConfigCleanups.get(root)) == null ? void 0 : _this_htmlRootConfigCleanups_get();
93275
+ this.htmlRootConfigCleanups.delete(root);
93276
+ var config = html.root;
93277
+ if (!config) {
93278
+ return;
93279
+ }
93280
+ var classNames = (_ref = (_config_className = config.className) == null ? void 0 : _config_className.split(/\s+/).filter(Boolean)) != null ? _ref : [];
93281
+ var styleProperties = [];
93282
+ classNames.forEach(function(className) {
93283
+ root.classList.add(className);
93284
+ });
93285
+ Object.entries((_config_style = config.style) != null ? _config_style : {}).forEach(function(param) {
93286
+ var property = param[0], value = param[1];
93287
+ if (value === undefined) {
93288
+ return;
93289
+ }
93290
+ styleProperties.push(property);
93291
+ if (property.startsWith('--') || property.includes('-')) {
93292
+ root.style.setProperty(property, String(value));
93293
+ return;
93294
+ }
93295
+ root.style[property] = String(value);
93296
+ });
93297
+ this.htmlRootConfigCleanups.set(root, function() {
93298
+ classNames.forEach(function(className) {
93299
+ root.classList.remove(className);
93300
+ });
93301
+ styleProperties.forEach(function(property) {
93302
+ if (property.startsWith('--') || property.includes('-')) {
93303
+ root.style.removeProperty(property);
93304
+ return;
93305
+ }
93306
+ root.style[property] = '';
93307
+ });
93308
+ });
93309
+ };
93310
+ _proto.makeSelectionOverlayTransparent = function makeSelectionOverlayTransparent(selectionOverlay) {
93311
+ selectionOverlay.style.background = 'transparent';
93312
+ selectionOverlay.style.backgroundColor = 'transparent';
93313
+ };
92459
93314
  _proto.renderOverlayContent = function renderOverlayContent(overlay, content, options) {
92460
93315
  var _this = this;
92461
93316
  switch(content.kind){
92462
93317
  case 'inline':
93318
+ if (options == null ? void 0 : options.autoHeight) {
93319
+ this.state.autoHeightModes.set(options.id, 'message');
93320
+ }
92463
93321
  return this.chainCleanups(function() {
92464
93322
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92465
93323
  }, renderDocumentContent(overlay, {
@@ -92467,7 +93325,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92467
93325
  entry: 'index.html',
92468
93326
  files: {
92469
93327
  'index.html': content.html
92470
- }
93328
+ },
93329
+ allowAnchorNavigation: content.allowAnchorNavigation,
93330
+ sandbox: content.sandbox
92471
93331
  }, {
92472
93332
  autoHeightId: (options == null ? void 0 : options.autoHeight) ? options.id : undefined,
92473
93333
  onAutoHeight: (options == null ? void 0 : options.autoHeight) ? function(height) {
@@ -92476,6 +93336,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92476
93336
  }));
92477
93337
  case 'dom':
92478
93338
  {
93339
+ if (options == null ? void 0 : options.autoHeight) {
93340
+ this.state.autoHeightModes.set(options.id, 'measure');
93341
+ }
92479
93342
  if (content.target === 'iframe') {
92480
93343
  return renderDOMContentInIframe(overlay, content.render, content.cleanup);
92481
93344
  }
@@ -92485,6 +93348,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92485
93348
  } : undefined;
92486
93349
  }
92487
93350
  case 'document':
93351
+ if (options == null ? void 0 : options.autoHeight) {
93352
+ this.state.autoHeightModes.set(options.id, 'message');
93353
+ }
92488
93354
  return this.chainCleanups(function() {
92489
93355
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92490
93356
  }, renderDocumentContent(overlay, content, {
@@ -92512,6 +93378,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92512
93378
  };
92513
93379
  };
92514
93380
  _proto.cleanupOverlayContent = function cleanupOverlayContent(id) {
93381
+ var _this_state_contentInteractionZoneCleanups_get;
92515
93382
  var cleanup = this.state.cleanups.get(id);
92516
93383
  if (cleanup) {
92517
93384
  cleanup();
@@ -92519,13 +93386,19 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92519
93386
  }
92520
93387
  this.state.contents.delete(id);
92521
93388
  this.state.contentMountElements.delete(id);
93389
+ this.state.autoHeightModes.delete(id);
93390
+ this.invalidateContentInteractionZones(id);
93391
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
93392
+ this.state.contentInteractionZoneCleanups.delete(id);
92522
93393
  this.cleanupAutoHeight(id);
92523
93394
  };
92524
93395
  _proto.removeOverlay = function removeOverlay(id) {
92525
- var _this_state_elements_get;
93396
+ var _this_state_elements_get, _this_state_selectionElements_get;
92526
93397
  this.cleanupOverlayContent(id);
92527
93398
  (_this_state_elements_get = this.state.elements.get(id)) == null ? void 0 : _this_state_elements_get.remove();
93399
+ (_this_state_selectionElements_get = this.state.selectionElements.get(id)) == null ? void 0 : _this_state_selectionElements_get.remove();
92528
93400
  this.state.elements.delete(id);
93401
+ this.state.selectionElements.delete(id);
92529
93402
  this.state.contentScaleElements.delete(id);
92530
93403
  this.state.contentElements.delete(id);
92531
93404
  };
@@ -92534,11 +93407,27 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92534
93407
  this.cleanupAutoHeight(id);
92535
93408
  return;
92536
93409
  }
93410
+ this.ensureAutoHeightMode(id);
93411
+ if (this.state.autoHeightModes.get(id) === 'message') {
93412
+ this.cleanupAutoHeight(id);
93413
+ return;
93414
+ }
92537
93415
  if (!this.state.autoHeightCleanups.has(id)) {
92538
93416
  this.state.autoHeightCleanups.set(id, this.createAutoHeightObserver(id));
92539
93417
  }
92540
93418
  this.scheduleAutoHeightMeasure(id);
92541
93419
  };
93420
+ _proto.ensureAutoHeightMode = function ensureAutoHeightMode(id) {
93421
+ var _this_state_contents_get;
93422
+ if (this.state.autoHeightModes.has(id)) {
93423
+ return;
93424
+ }
93425
+ var content = (_this_state_contents_get = this.state.contents.get(id)) == null ? void 0 : _this_state_contents_get.content;
93426
+ if (!content) {
93427
+ return;
93428
+ }
93429
+ this.state.autoHeightModes.set(id, content.kind === 'inline' || content.kind === 'document' ? 'message' : 'measure');
93430
+ };
92542
93431
  _proto.createAutoHeightObserver = function createAutoHeightObserver(id) {
92543
93432
  var _this = this;
92544
93433
  var cleanupFns = [];
@@ -92616,7 +93505,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92616
93505
  if (this.state.autoHeightFrames.has(id)) {
92617
93506
  return;
92618
93507
  }
92619
- var frame = requestAnimationFrame(function() {
93508
+ var frame = requestHTMLOverlayFrame(function() {
92620
93509
  _this.state.autoHeightFrames.delete(id);
92621
93510
  _this.measureAutoHeight(id);
92622
93511
  });
@@ -92626,7 +93515,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92626
93515
  var item = this.options.getItems().find(function(candidate) {
92627
93516
  return candidate.id === id;
92628
93517
  });
92629
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93518
+ if (!this.isAutoHeightEnabled(item)) {
92630
93519
  this.cleanupAutoHeight(id);
92631
93520
  return;
92632
93521
  }
@@ -92645,7 +93534,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92645
93534
  }).filter(function(height) {
92646
93535
  return typeof height === 'number' && Number.isFinite(height) && height > 0;
92647
93536
  });
92648
- var childHeight = this.getChildrenNaturalHeight(element);
93537
+ var childHeight = this.getChildrenNaturalHeight(element, {
93538
+ includeIframes: iframeHeights.length === 0
93539
+ });
92649
93540
  var naturalHeight = (_Math = Math).max.apply(_Math, [].concat([
92650
93541
  childHeight
92651
93542
  ], iframeHeights));
@@ -92665,10 +93556,29 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92665
93556
  }
92666
93557
  return Math.max(documentElement.scrollHeight, (_ref = body == null ? void 0 : body.scrollHeight) != null ? _ref : 0);
92667
93558
  };
92668
- _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element) {
92669
- return Array.from(element.children).reduce(function(height, child) {
92670
- var childElement = child;
92671
- return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93559
+ _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element, options) {
93560
+ var _ref;
93561
+ var includeIframes = (_ref = options == null ? void 0 : options.includeIframes) != null ? _ref : true;
93562
+ return Array.from(element.childNodes).reduce(function(height, child) {
93563
+ var _child_textContent;
93564
+ if (child.nodeType === Node.ELEMENT_NODE) {
93565
+ var childElement = child;
93566
+ if (!includeIframes && childElement.tagName === 'IFRAME') {
93567
+ return height;
93568
+ }
93569
+ return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93570
+ }
93571
+ if (child.nodeType === Node.TEXT_NODE && ((_child_textContent = child.textContent) == null ? void 0 : _child_textContent.trim())) {
93572
+ var range = element.ownerDocument.createRange();
93573
+ range.selectNodeContents(child);
93574
+ var rects = Array.from(range.getClientRects());
93575
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
93576
+ range.detach();
93577
+ return rects.reduce(function(textHeight, rect) {
93578
+ return Math.max(textHeight, rect.bottom - element.getBoundingClientRect().top);
93579
+ }, height);
93580
+ }
93581
+ return height;
92672
93582
  }, 0);
92673
93583
  };
92674
93584
  _proto.cleanupAutoHeight = function cleanupAutoHeight(id) {
@@ -92679,7 +93589,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92679
93589
  }
92680
93590
  var frame = this.state.autoHeightFrames.get(id);
92681
93591
  if (frame !== undefined) {
92682
- cancelAnimationFrame(frame);
93592
+ cancelHTMLOverlayFrame(frame);
92683
93593
  this.state.autoHeightFrames.delete(id);
92684
93594
  }
92685
93595
  };
@@ -92687,14 +93597,59 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92687
93597
  var item = this.options.getItems().find(function(candidate) {
92688
93598
  return candidate.id === id;
92689
93599
  });
92690
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93600
+ if (!isCardItem(item) || !this.isAutoHeightEnabled(item)) {
93601
+ return;
93602
+ }
93603
+ if (!Number.isFinite(height) || height <= 0) {
92691
93604
  return;
92692
93605
  }
92693
- if (!Number.isFinite(height) || height <= 0 || Math.abs(height - item.property.height) <= AUTO_HEIGHT_EPSILON) {
93606
+ var nextHeight = Math.ceil(this.getAutoHeightItemHeight(item, height));
93607
+ if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
92694
93608
  return;
92695
93609
  }
92696
- this.options.setCardItemHeight(id, Math.ceil(height));
93610
+ this.options.setCardItemHeight(id, nextHeight, {
93611
+ anchor: this.getAutoHeightAnchor(item),
93612
+ previousHeight: item.property.height
93613
+ });
93614
+ };
93615
+ _proto.getAutoHeightAnchor = function getAutoHeightAnchor(item) {
93616
+ var _ref;
93617
+ var _this_options_resolveCardTypeConfig;
93618
+ if (!isCardItem(item)) {
93619
+ return 'top';
93620
+ }
93621
+ return (_ref = (_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeightAnchor) != null ? _ref : 'top';
93622
+ };
93623
+ _proto.getAutoHeightItemHeight = function getAutoHeightItemHeight(item, contentHeight) {
93624
+ if (!isCardItem(item) || this.isAutoScaleEnabled(item)) {
93625
+ return contentHeight;
93626
+ }
93627
+ var scaleOverlay = this.state.contentScaleElements.get(item.id);
93628
+ var displayedHeight = scaleOverlay ? Number.parseFloat(scaleOverlay.style.height) : 0;
93629
+ if (!Number.isFinite(displayedHeight) || displayedHeight <= 0 || item.property.height <= 0) {
93630
+ return contentHeight;
93631
+ }
93632
+ return contentHeight / displayedHeight * item.property.height;
93633
+ };
93634
+ _proto.isAutoHeightEnabled = function isAutoHeightEnabled(item) {
93635
+ var _this_options_resolveCardTypeConfig;
93636
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeight) === true;
93637
+ };
93638
+ _proto.isAutoScaleEnabled = function isAutoScaleEnabled(item) {
93639
+ var _this_options_resolveCardTypeConfig;
93640
+ if (!isCardItem(item)) {
93641
+ return true;
93642
+ }
93643
+ return ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoScale) !== false;
92697
93644
  };
93645
+ _create_class(HTMLOverlayManager, [
93646
+ {
93647
+ key: "layerElement",
93648
+ get: function get() {
93649
+ return this.state.layer;
93650
+ }
93651
+ }
93652
+ ]);
92698
93653
  return HTMLOverlayManager;
92699
93654
  }();
92700
93655
  function waitForCardCaptureReady(root) {
@@ -92736,9 +93691,20 @@ function waitForCardCaptureReady(root) {
92736
93691
  });
92737
93692
  })();
92738
93693
  }
93694
+ function formatCssColor(color, alpha) {
93695
+ var normalizedColor = Math.max(0, Math.min(0xFFFFFF, Math.round(color)));
93696
+ var red = normalizedColor >> 16 & 0xFF;
93697
+ var green = normalizedColor >> 8 & 0xFF;
93698
+ var blue = normalizedColor & 0xFF;
93699
+ return "rgba(" + red + ", " + green + ", " + blue + ", " + formatCssNumber(alpha) + ")";
93700
+ }
93701
+ function formatCssNumber(value) {
93702
+ var normalized = Number.isFinite(value) ? value : 0;
93703
+ return Number(normalized.toFixed(6)).toString();
93704
+ }
92739
93705
  function nextAnimationFrame() {
92740
93706
  return new Promise(function(resolve) {
92741
- requestAnimationFrame(function() {
93707
+ requestHTMLOverlayFrame(function() {
92742
93708
  resolve();
92743
93709
  });
92744
93710
  });
@@ -93154,6 +94120,9 @@ function createFlattenedContent(target, frameStyle, ownerDocument) {
93154
94120
  });
93155
94121
  return replacement;
93156
94122
  }
94123
+ function isMouseEventInsideRect(event, rect) {
94124
+ return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
94125
+ }
93157
94126
  function createFlattenedIframeContent(iframe) {
93158
94127
  var doc = iframe.contentDocument;
93159
94128
  if (!doc) {
@@ -93193,6 +94162,19 @@ function withTimeout(promise, timeout) {
93193
94162
  });
93194
94163
  }
93195
94164
 
94165
+ function orderSDKCanvasLayers(param) {
94166
+ var container = param.container, playerContainer = param.playerContainer, htmlOverlayLayer = param.htmlOverlayLayer, gestureCanvas = param.gestureCanvas;
94167
+ [
94168
+ playerContainer,
94169
+ htmlOverlayLayer,
94170
+ gestureCanvas
94171
+ ].forEach(function(layer) {
94172
+ if ((layer == null ? void 0 : layer.parentElement) === container) {
94173
+ container.appendChild(layer);
94174
+ }
94175
+ });
94176
+ }
94177
+
93196
94178
  var HTML_CARD_EDITING_VIEWPORT_PADDING = 48;
93197
94179
  var SDK = /*#__PURE__*/ function() {
93198
94180
  function SDK(container, mode) {
@@ -93291,16 +94273,72 @@ var SDK = /*#__PURE__*/ function() {
93291
94273
  bottom: HTML_CARD_EDITING_VIEWPORT_PADDING
93292
94274
  }, box);
93293
94275
  },
93294
- setCardItemHeight: function setCardItemHeight(id, height) {
94276
+ setCardItemHeight: function setCardItemHeight(id, height, options) {
94277
+ var item = _this.getSDKItem(id);
94278
+ if (!isCardItem(item) || options.anchor === 'center') {
94279
+ void _this.setItemProperty({
94280
+ itemId: id,
94281
+ type: SDKItemType.CARD,
94282
+ propertyName: 'height',
94283
+ propertyValue: height
94284
+ });
94285
+ return;
94286
+ }
94287
+ var _item_property_position = item.property.position, x = _item_property_position[0], y = _item_property_position[1];
94288
+ var deltaY = (height - options.previousHeight) / 2;
93295
94289
  void _this.setItemProperty({
93296
94290
  itemId: id,
93297
94291
  type: SDKItemType.CARD,
93298
- propertyName: 'height',
93299
- propertyValue: height
94292
+ property: {
94293
+ height: height,
94294
+ position: [
94295
+ x,
94296
+ y + deltaY
94297
+ ]
94298
+ }
93300
94299
  });
94300
+ },
94301
+ getSelectedItemIds: function getSelectedItemIds() {
94302
+ var _ref;
94303
+ var _this__pageData;
94304
+ return (_ref = (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.selectedItems) != null ? _ref : [];
94305
+ },
94306
+ setSelectedItemIds: function setSelectedItemIds(ids) {
94307
+ _this.setSelectedItems(ids);
94308
+ },
94309
+ getPreSelectedItemId: function getPreSelectedItemId() {
94310
+ var _this__pageData;
94311
+ return (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.preSelectedItem;
94312
+ },
94313
+ getSelectionEdgeStyle: function getSelectionEdgeStyle() {
94314
+ var _SDK_config_gestureHandlerConfig_transformGizmoConfig = SDK.config.gestureHandlerConfig.transformGizmoConfig, wireframeColor = _SDK_config_gestureHandlerConfig_transformGizmoConfig.wireframeColor, wireframeAlpha = _SDK_config_gestureHandlerConfig_transformGizmoConfig.wireframeAlpha, wireframeWidth = _SDK_config_gestureHandlerConfig_transformGizmoConfig.wireframeWidth;
94315
+ return {
94316
+ color: wireframeColor,
94317
+ alpha: wireframeAlpha,
94318
+ width: wireframeWidth
94319
+ };
94320
+ },
94321
+ getPreSelectionEdgeStyle: function getPreSelectionEdgeStyle() {
94322
+ var _SDK_config_gestureHandlerConfig_selectorGizmoConfig = SDK.config.gestureHandlerConfig.selectorGizmoConfig, preSelectedColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedColor, preSelectedWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedWidth;
94323
+ return {
94324
+ color: preSelectedColor,
94325
+ alpha: 1,
94326
+ width: preSelectedWidth
94327
+ };
94328
+ },
94329
+ getCanvasEventTarget: function getCanvasEventTarget() {
94330
+ var _this__gestureHandler;
94331
+ return (_this__gestureHandler = _this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view;
94332
+ },
94333
+ resolveCardHTML: function resolveCardHTML(item) {
94334
+ return isCardItem(item) ? _this.resolveCardHTML(item) : undefined;
94335
+ },
94336
+ resolveCardTypeConfig: function resolveCardTypeConfig(item) {
94337
+ return isCardItem(item) ? _this.resolveCardTypeConfig(item) : undefined;
93301
94338
  }
93302
94339
  });
93303
94340
  this._htmlOverlayManager.attach();
94341
+ this.syncCanvasLayerOrder();
93304
94342
  }
93305
94343
  var _proto = SDK.prototype;
93306
94344
  _proto.dispose = function dispose() {
@@ -93320,18 +94358,22 @@ var SDK = /*#__PURE__*/ function() {
93320
94358
  _proto.initPlayer = function initPlayer(mode) {
93321
94359
  var _this = this;
93322
94360
  var playerContainer = document.createElement('div');
93323
- var _ref = mode === 'editor' ? [
93324
- this._container.clientWidth,
93325
- this._container.clientHeight
93326
- ] : [
94361
+ var _ref = mode === 'template' ? [
93327
94362
  this._container.offsetWidth,
93328
94363
  this._container.offsetHeight
94364
+ ] : [
94365
+ document.documentElement.clientWidth,
94366
+ document.documentElement.clientHeight
93329
94367
  ], width = _ref[0], height = _ref[1];
93330
94368
  this._playerContainer = playerContainer;
93331
94369
  this._playerContainer.id = 'player-container';
93332
94370
  this._playerContainer.style.position = 'absolute';
93333
94371
  this._playerContainer.style.width = "" + width + "px";
93334
94372
  this._playerContainer.style.height = "" + height + "px";
94373
+ if (mode === 'editor') {
94374
+ this._playerContainer.style.left = '0px';
94375
+ this._playerContainer.style.top = '0px';
94376
+ }
93335
94377
  this._container.appendChild(playerContainer);
93336
94378
  this.player = new EFFECTS.Player({
93337
94379
  container: this._playerContainer,
@@ -93390,18 +94432,48 @@ var SDK = /*#__PURE__*/ function() {
93390
94432
  _this._gestureHandler.dispose();
93391
94433
  setTimeout(function() {
93392
94434
  return _async_to_generator(function() {
94435
+ var itemExtension, _this_pageData, _this_pageData1, createInfos;
93393
94436
  return _ts_generator(this, function(_state) {
93394
94437
  switch(_state.label){
93395
94438
  case 0:
93396
94439
  this.initPlayer(SDK.config.mode);
93397
94440
  this._pageDataUtils = new PageDataUtils(this.player, this._playerContainer, this._eventEmitter, this);
93398
94441
  this._gestureHandler = new GestureHandler(this._container);
94442
+ this.syncCanvasLayerOrder();
94443
+ itemExtension = {};
94444
+ if (!(SDK.config.mode === 'template')) return [
94445
+ 3,
94446
+ 2
94447
+ ];
94448
+ (_this_pageData = this.pageData) == null ? void 0 : _this_pageData.items.forEach(function(item) {
94449
+ itemExtension[item.id] = item.getAllExtension();
94450
+ });
93399
94451
  return [
93400
94452
  4,
93401
94453
  this.runByPageData(this.pageData)
93402
94454
  ];
93403
94455
  case 1:
93404
94456
  _state.sent();
94457
+ (_this_pageData1 = this.pageData) == null ? void 0 : _this_pageData1.items.forEach(function(item) {
94458
+ var extension = itemExtension[item.id];
94459
+ if (extension) {
94460
+ item.setExtensions(extension);
94461
+ }
94462
+ });
94463
+ return [
94464
+ 3,
94465
+ 4
94466
+ ];
94467
+ case 2:
94468
+ createInfos = this.getItemCreateInfos();
94469
+ return [
94470
+ 4,
94471
+ this.runByCreateInfos(createInfos)
94472
+ ];
94473
+ case 3:
94474
+ _state.sent();
94475
+ _state.label = 4;
94476
+ case 4:
93405
94477
  this._eventEmitter.emit('viewRebuildFinish');
93406
94478
  return [
93407
94479
  2
@@ -93445,6 +94517,16 @@ var SDK = /*#__PURE__*/ function() {
93445
94517
  env: 'editor'
93446
94518
  });
93447
94519
  this.player.resize();
94520
+ this.syncCanvasLayerOrder();
94521
+ };
94522
+ _proto.syncCanvasLayerOrder = function syncCanvasLayerOrder() {
94523
+ var _this__htmlOverlayManager, _this__gestureHandler;
94524
+ orderSDKCanvasLayers({
94525
+ container: this._container,
94526
+ playerContainer: this._playerContainer,
94527
+ htmlOverlayLayer: (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.layerElement,
94528
+ gestureCanvas: (_this__gestureHandler = this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view
94529
+ });
93448
94530
  };
93449
94531
  _proto.getInitParam = function getInitParam(param) {
93450
94532
  return _async_to_generator(function() {
@@ -94241,6 +95323,55 @@ var SDK = /*#__PURE__*/ function() {
94241
95323
  });
94242
95324
  }).call(this);
94243
95325
  };
95326
+ _proto.runByCreateInfos = function runByCreateInfos(createInfos) {
95327
+ return _async_to_generator(function() {
95328
+ var _this__pageData_activeData_view, _this__pageData_activeData_view1, viewSize, scene, targetViewProperty;
95329
+ return _ts_generator(this, function(_state) {
95330
+ switch(_state.label){
95331
+ case 0:
95332
+ EFFECTS.assertExist(this._pageData, 'You must call SDK#run() first');
95333
+ this._pageData.property.zoom = 1;
95334
+ this._pageData.property.translation = [
95335
+ 0,
95336
+ 0
95337
+ ];
95338
+ this._pageDataUtils.init();
95339
+ return [
95340
+ 4,
95341
+ this._gestureHandler.init(this._pageDataUtils, this._eventEmitter)
95342
+ ];
95343
+ case 1:
95344
+ _state.sent();
95345
+ viewSize = [
95346
+ this._playerContainer.offsetWidth,
95347
+ this._playerContainer.offsetHeight
95348
+ ];
95349
+ scene = getBasicScene(viewSize);
95350
+ targetViewProperty = this.getViewProperty((_this__pageData_activeData_view = this._pageData.activeData.view) != null ? _this__pageData_activeData_view : 0);
95351
+ if (targetViewProperty) {
95352
+ targetViewProperty.scene = scene;
95353
+ }
95354
+ return [
95355
+ 4,
95356
+ this._pageDataUtils.loadScene((_this__pageData_activeData_view1 = this._pageData.activeData.view) != null ? _this__pageData_activeData_view1 : 0)
95357
+ ];
95358
+ case 2:
95359
+ _state.sent();
95360
+ return [
95361
+ 4,
95362
+ this.addItemByCreateInfos(createInfos)
95363
+ ];
95364
+ case 3:
95365
+ _state.sent();
95366
+ this._pageDataUtils.refreshPageTime(this._pageData.time);
95367
+ this._eventEmitter.emit('pageDataChange', this.pageData);
95368
+ return [
95369
+ 2
95370
+ ];
95371
+ }
95372
+ });
95373
+ }).call(this);
95374
+ };
94244
95375
  _proto.reloadPageDataByScene = function reloadPageDataByScene(scene) {
94245
95376
  return _async_to_generator(function() {
94246
95377
  var _ref, _this__pageData_activeData_view, _ref1, _ref2, _loadScene_compositions_find, _this_player_getCompositions_, _this_player_getCompositions_1, loadScene, response, error;
@@ -94539,8 +95670,7 @@ var SDK = /*#__PURE__*/ function() {
94539
95670
  * @param ignoreClamp 是否忽视约束
94540
95671
  */ _proto.setPageZoom = function setPageZoom(zoom, center, ignoreClamp) {
94541
95672
  EFFECTS.assertExist(this._pageData);
94542
- this._pageData.property.zoom = zoom;
94543
- this._pageDataUtils.setPageZoom(this._pageData.property.zoom, center, ignoreClamp);
95673
+ this._pageDataUtils.setPageZoom(zoom, center, ignoreClamp);
94544
95674
  this._gestureHandler.render();
94545
95675
  };
94546
95676
  /**
@@ -94780,7 +95910,7 @@ var SDK = /*#__PURE__*/ function() {
94780
95910
  };
94781
95911
  /**
94782
95912
  * @description 设置蒙版工具模式
94783
- * @param mode 模式类型:'paint' 表示涂抹,'erase' 表示擦除
95913
+ * @param mode 模式类型:'paint' 笔刷涂抹、'erase' 笔刷逐笔擦除、'box-erase' 框选擦除、'box-paint' 框选涂抹
94784
95914
  */ _proto.setMaskGizmoMode = function setMaskGizmoMode(mode) {
94785
95915
  this._gestureHandler.setMaskGizmoMode(mode);
94786
95916
  };
@@ -94936,7 +96066,11 @@ var SDK = /*#__PURE__*/ function() {
94936
96066
  return item.id;
94937
96067
  })) != null ? _ref : [];
94938
96068
  ids.forEach(function(id) {
94939
- var createInfo = _this._pageDataUtils.getItemCreateInfo(id, true);
96069
+ var _this__pageDataUtils_getItemCreateInfo;
96070
+ var _this_pageData_items_find, _this_pageData;
96071
+ var createInfo = (_this__pageDataUtils_getItemCreateInfo = _this._pageDataUtils.getItemCreateInfo(id, true)) != null ? _this__pageDataUtils_getItemCreateInfo : (_this_pageData = _this.pageData) == null ? void 0 : (_this_pageData_items_find = _this_pageData.items.find(function(item) {
96072
+ return item.id === id;
96073
+ })) == null ? void 0 : _this_pageData_items_find.toCreateInfo(true);
94940
96074
  if (createInfo) {
94941
96075
  createInfos.push(createInfo);
94942
96076
  }
@@ -95436,6 +96570,76 @@ var SDK = /*#__PURE__*/ function() {
95436
96570
  });
95437
96571
  };
95438
96572
  /**
96573
+ * @description 按 cardType 从注册表解析卡片的 HTML 渲染配置。
96574
+ * @param item 卡片元素
96575
+ * @returns HTML 渲染配置
96576
+ */ _proto.resolveCardHTML = function resolveCardHTML(item) {
96577
+ var _cardTypeConfig_html;
96578
+ var cardTypeConfig = this.resolveCardTypeConfig(item);
96579
+ return cardTypeConfig == null ? void 0 : (_cardTypeConfig_html = cardTypeConfig.html) == null ? void 0 : _cardTypeConfig_html.call(cardTypeConfig, item);
96580
+ };
96581
+ /**
96582
+ * @description 按 cardType 从注册表解析卡片类型配置。
96583
+ * @param item 卡片元素
96584
+ * @returns 卡片类型配置
96585
+ */ _proto.resolveCardTypeConfig = function resolveCardTypeConfig(item) {
96586
+ return SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96587
+ return t.type === item.cardType;
96588
+ });
96589
+ };
96590
+ /**
96591
+ * @description 重新解析并挂载指定卡片的 HTML 内容。
96592
+ * @description 当 inline/document 内容依赖 extension 或外部状态变化时,可调用此方法刷新 DOM。
96593
+ * @param id 卡片元素 ID
96594
+ * @returns 是否成功触发刷新
96595
+ */ _proto.refreshCardHTML = function refreshCardHTML(id) {
96596
+ var _this__htmlOverlayManager, _this__htmlOverlayManager1;
96597
+ var item = this.getSDKItem(id);
96598
+ if (!isCardItem(item)) {
96599
+ console.warn('CardItem "' + id + '" not found.');
96600
+ return false;
96601
+ }
96602
+ if (!this.resolveCardHTML(item)) {
96603
+ console.warn('CardItem "' + id + '" has no registered HTML renderer.');
96604
+ return false;
96605
+ }
96606
+ (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.invalidateCardHTML(id);
96607
+ (_this__htmlOverlayManager1 = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager1.scheduleRender();
96608
+ return true;
96609
+ };
96610
+ /**
96611
+ * @description 获取指定 HTML 卡片当前 iframe 的 window。
96612
+ * @description 仅 inline/document 或自行渲染 iframe 的 DOM 内容会返回 window。
96613
+ * @param id 卡片元素 ID
96614
+ * @returns HTML iframe window
96615
+ */ _proto.getHtmlCardWindow = function getHtmlCardWindow(id) {
96616
+ var _this__htmlOverlayManager;
96617
+ return (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.getHtmlCardWindow(id);
96618
+ };
96619
+ /**
96620
+ * @description 向指定 HTML 卡片发送增量 patch。
96621
+ * @description 当卡片内容配置了 CardHTMLPatchHandler 时,可用于局部更新 HTML,而不必整卡 refresh。
96622
+ * @param id 卡片元素 ID
96623
+ * @param patch patch 负载,由卡片内容自己的 patch handler 解释
96624
+ * @returns 是否被 patch handler 处理
96625
+ */ _proto.patchCardHTML = function patchCardHTML(id, patch) {
96626
+ var _ref;
96627
+ var _this__htmlOverlayManager;
96628
+ return (_ref = (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.patchCardHTML(id, patch)) != null ? _ref : false;
96629
+ };
96630
+ /**
96631
+ * @description 向指定 HTML 卡片 iframe 派发事件。
96632
+ * @description 通过 postMessage 投递事件,跨源/同源行为一致,消息 source 为 vvfx-card-html-event。
96633
+ * @param id 卡片元素 ID
96634
+ * @param type 事件名称
96635
+ * @param detail 事件 detail
96636
+ * @returns 是否成功派发或投递
96637
+ */ _proto.dispatchHtmlCardEvent = function dispatchHtmlCardEvent(id, type, detail) {
96638
+ var _ref;
96639
+ var _this__htmlOverlayManager;
96640
+ return (_ref = (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.dispatchHtmlCardEvent(id, type, detail)) != null ? _ref : false;
96641
+ };
96642
+ /**
95439
96643
  * @description 创建卡片元素
95440
96644
  * @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
95441
96645
  * @param createInfo 卡片创建信息
@@ -95730,8 +96934,8 @@ SDK.config = BaseConfig;
95730
96934
  _inherits(CardItem, BaseItem);
95731
96935
  function CardItem(options) {
95732
96936
  var _this;
95733
- var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
95734
- var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5, _SDK_config_itemConfig_cardConfig_cardTypes_, _options_property6, _options_property7;
96937
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
96938
+ var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5;
95735
96939
  _this = BaseItem.call(this, options) || this, /**
95736
96940
  * @description 元素类型
95737
96941
  */ _this.type = SDKItemType.CARD;
@@ -95752,9 +96956,7 @@ SDK.config = BaseConfig;
95752
96956
  1,
95753
96957
  1
95754
96958
  ],
95755
- cardType: (_ref5 = (_ref6 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref6 : (_SDK_config_itemConfig_cardConfig_cardTypes_ = SDK.config.itemConfig.cardConfig.cardTypes[0]) == null ? void 0 : _SDK_config_itemConfig_cardConfig_cardTypes_.type) != null ? _ref5 : '',
95756
- autoHeight: (_options_property6 = options.property) == null ? void 0 : _options_property6.autoHeight,
95757
- html: (_options_property7 = options.property) == null ? void 0 : _options_property7.html
96959
+ cardType: (_ref5 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref5 : 'unknown'
95758
96960
  };
95759
96961
  return _this;
95760
96962
  }
@@ -95765,22 +96967,18 @@ SDK.config = BaseConfig;
95765
96967
  * @param withParent 是否包含父节点ID
95766
96968
  */ _proto.toCreateInfo = function toCreateInfo(withParent) {
95767
96969
  var extension = this.getAllExtension();
95768
- var property = deepClone(this.property);
95769
- property.html = this.html;
95770
96970
  return {
95771
96971
  type: SDKItemType.CARD,
95772
96972
  id: this.id,
95773
96973
  name: this.name,
95774
96974
  parentId: withParent ? this.parentId : undefined,
95775
96975
  extension: Object.keys(extension).length > 0 ? extension : undefined,
95776
- property: property
96976
+ property: deepClone(this.property)
95777
96977
  };
95778
96978
  };
95779
96979
  /**
95780
96980
  * @description 克隆 SDKItem
95781
96981
  */ _proto.clone = function clone() {
95782
- var property = deepClone(this.property);
95783
- property.html = this.html;
95784
96982
  return new CardItem({
95785
96983
  id: EFFECTS.generateGUID(),
95786
96984
  name: this.name,
@@ -95790,7 +96988,7 @@ SDK.config = BaseConfig;
95790
96988
  endBehavior: this.endBehavior,
95791
96989
  isLocked: this.isLocked,
95792
96990
  isCoreEditable: this.isCoreEditable,
95793
- property: property,
96991
+ property: deepClone(this.property),
95794
96992
  extension: this.getAllExtension()
95795
96993
  });
95796
96994
  };
@@ -95807,17 +97005,6 @@ SDK.config = BaseConfig;
95807
97005
  this.property.cardType = value;
95808
97006
  }
95809
97007
  },
95810
- {
95811
- key: "html",
95812
- get: /**
95813
- * @description HTML 覆盖层配置
95814
- */ function get() {
95815
- return this.property.html;
95816
- },
95817
- set: function set(value) {
95818
- this.property.html = value;
95819
- }
95820
- },
95821
97008
  {
95822
97009
  key: "position",
95823
97010
  get: // ==================== 便捷访问器 ====================
@@ -95830,6 +97017,16 @@ SDK.config = BaseConfig;
95830
97017
  this.property.position = value;
95831
97018
  }
95832
97019
  },
97020
+ {
97021
+ key: "isAutoScale",
97022
+ get: function get() {
97023
+ var _this = this;
97024
+ var config = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
97025
+ return t.type === _this.cardType;
97026
+ });
97027
+ return (config == null ? void 0 : config.autoScale) !== false;
97028
+ }
97029
+ },
95833
97030
  {
95834
97031
  key: "width",
95835
97032
  get: /**