@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.js 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
  import * as EFFECTS from '@galacean/effects';
@@ -47166,7 +47166,7 @@ var SelectorGizmo = /*#__PURE__*/ function(Gizmo) {
47166
47166
  var preSelectedItem = this.pageDataUtils.getPreSelectedItem();
47167
47167
  var preSelectedItemBox = this.pageDataUtils.getViewBoxById((_ref = preSelectedItem == null ? void 0 : preSelectedItem.id) != null ? _ref : '');
47168
47168
  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;
47169
- if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty())) {
47169
+ if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty()) && !isCardItem(preSelectedItem)) {
47170
47170
  this.graphics.lineStyle(preSelectedWidth, preSelectedColor);
47171
47171
  this.graphics.drawBox(preSelectedItemBox);
47172
47172
  }
@@ -55352,7 +55352,9 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55352
55352
  return;
55353
55353
  }
55354
55354
  var selectedItem = (_selectedItems_ = selectedItems[0]) != null ? _selectedItems_ : undefined;
55355
- var isShfitLockScale = selectedItem && selectedItems.length === 1 && isFrameItem(selectedItem) ? !this.isShiftDown : this.isShiftDown;
55355
+ // html卡片内容在非自动缩放的情况下,拖动的时候内容自适应,因此与智能画板一样,需要默认是自由缩放(即自由改大小)
55356
+ var isSingleAutoFitContentCardItem = selectedItems.length === 1 && selectedItem && isCardItem(selectedItem) && !selectedItem.isAutoScale;
55357
+ var isShiftLockScale = selectedItem && selectedItems.length === 1 && (isFrameItem(selectedItem) || isSingleAutoFitContentCardItem) ? !this.isShiftDown : this.isShiftDown;
55356
55358
  var farthestCorner = this.scaleParam.farthestCorner;
55357
55359
  var isValidScale = (scaleCorner.x - farthestCorner.x) * (this.cursorPoint.x - farthestCorner.x) > 0 && (scaleCorner.y - farthestCorner.y) * (this.cursorPoint.y - farthestCorner.y) > 0;
55358
55360
  if (!isValidScale && this.isLockScale && !this.isShiftDown) {
@@ -55369,7 +55371,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55369
55371
  var currentStartScale = startScale.clone().multiply(lastScalar);
55370
55372
  var currentScale = worldPosition1.clone().subtract(cornerShift).subtract(center1).applyMatrix(rotationMatrix);
55371
55373
  var scalar = new Vector3(1, 1, 1);
55372
- if (!this.isLockScale || isShfitLockScale) {
55374
+ if (!this.isLockScale || isShiftLockScale) {
55373
55375
  scalar.x = isEqual$1(currentStartScale.x, 0) ? 1 : currentScale.x / currentStartScale.x;
55374
55376
  scalar.y = isEqual$1(currentStartScale.y, 0) ? 1 : currentScale.y / currentStartScale.y;
55375
55377
  scalar.z = isEqual$1(currentStartScale.z, 0) ? 1 : currentScale.z / currentStartScale.z;
@@ -55426,6 +55428,23 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55426
55428
  newWidth,
55427
55429
  newHeight
55428
55430
  ], translation1);
55431
+ } else if (isSingleAutoFitContentCardItem && selectedItem && isCardItem(selectedItem)) {
55432
+ var currentWidth1 = selectedItem.pixelWidth;
55433
+ var currentHeight1 = selectedItem.pixelHeight;
55434
+ var newWidth1 = currentWidth1 * resultScalar1.x;
55435
+ var newHeight1 = currentHeight1 * resultScalar1.y;
55436
+ this._pageDataUtils.resizeCardItem(selectedItem.id, [
55437
+ newWidth1,
55438
+ newHeight1
55439
+ ], translation1);
55440
+ void this._pageDataUtils.setItemProperty({
55441
+ itemId: selectedItem.id,
55442
+ type: SDKItemType.CARD,
55443
+ property: {
55444
+ width: newWidth1,
55445
+ height: newHeight1
55446
+ }
55447
+ });
55429
55448
  } else {
55430
55449
  // 普通元素的缩放逻辑
55431
55450
  selectedItems.forEach(function(item) {
@@ -55750,6 +55769,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55750
55769
  var selectedItems = this._pageDataUtils.getSelectedItems();
55751
55770
  var isTemplateMode = SDK.config.mode === 'template';
55752
55771
  var selectedItem = selectedItems.length === 1 ? selectedItems[0] : undefined;
55772
+ var isSingleCardItem = isCardItem(selectedItem);
55753
55773
  var isGeneratorItem = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.GENERATOR;
55754
55774
  var isAutoLayoutFrame = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.FRAME && (selectedItem == null ? void 0 : selectedItem.layoutMode) === FrameLayoutMode.AUTO;
55755
55775
  var canScale = selectedItems.length === 1 && (selectedItem == null ? void 0 : selectedItem.type) !== SDKItemType.GROUP && !isAutoLayoutFrame && !isGeneratorItem;
@@ -55789,9 +55809,11 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55789
55809
  this.wireframe.totalBox.copyFrom(box).expandByScalar(totalBoxExpandScalar);
55790
55810
  // 根据box获取边缘线
55791
55811
  var corners = this.wireframe.box.corners;
55792
- corners.forEach(function(corner, i) {
55793
- _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55794
- });
55812
+ if (!isSingleCardItem) {
55813
+ corners.forEach(function(corner, i) {
55814
+ _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55815
+ });
55816
+ }
55795
55817
  var _SDK_config_gestureHandlerConfig_transformGizmoConfig = SDK.config.gestureHandlerConfig.transformGizmoConfig, scaleCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.scaleCircleSize, rotationCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.rotationCircleSize;
55796
55818
  // 成组暂不支持缩放
55797
55819
  if (selectedItems.length === 1) {
@@ -56584,6 +56606,10 @@ var cursorMap = {
56584
56606
  type: 'preset',
56585
56607
  content: 'crosshair'
56586
56608
  },
56609
+ 'box-select': {
56610
+ type: 'preset',
56611
+ content: 'crosshair'
56612
+ },
56587
56613
  'text-rotation': {
56588
56614
  type: 'svg',
56589
56615
  content: 'default',
@@ -59642,12 +59668,6 @@ var MAX_ITEM_DISTANCE_THRESHOLD = 100000;
59642
59668
  /**
59643
59669
  * @description SDKItem position 属性的数字精度(保留小数位数)
59644
59670
  */ var POSITION_PRECISION = 4;
59645
- function isCardHTMLContentValue(value) {
59646
- return (value == null ? void 0 : value.kind) === 'inline' || (value == null ? void 0 : value.kind) === 'dom' || (value == null ? void 0 : value.kind) === 'document';
59647
- }
59648
- function isCardHTMLValue(value) {
59649
- return isCardHTMLContentValue(value == null ? void 0 : value.content);
59650
- }
59651
59671
  var PageDataUtils = /*#__PURE__*/ function() {
59652
59672
  function PageDataUtils(player, container, emitter, sdk) {
59653
59673
  this.player = player;
@@ -60410,6 +60430,8 @@ var PageDataUtils = /*#__PURE__*/ function() {
60410
60430
  }
60411
60431
  }
60412
60432
  var isLocked = (_this_getSDKItem = this.getSDKItem(playerItem.getInstanceId())) == null ? void 0 : _this_getSDKItem.isLocked;
60433
+ // 优先通过 ID 查找现有 SDKItem,获取其 SDKItemType
60434
+ var existingSDKItem = this.getSDKItem(playerItem.getInstanceId());
60413
60435
  // 创建基础选项
60414
60436
  var baseOptions = {
60415
60437
  id: playerItem.getInstanceId(),
@@ -60421,12 +60443,11 @@ var PageDataUtils = /*#__PURE__*/ function() {
60421
60443
  endBehavior: playerItem.endBehavior,
60422
60444
  visible: isVisible,
60423
60445
  isLocked: isLocked,
60424
- isCoreEditable: isCoreEditable
60446
+ isCoreEditable: isCoreEditable,
60447
+ extension: existingSDKItem == null ? void 0 : existingSDKItem.extension
60425
60448
  };
60426
60449
  // 根据类型创建对应的 SDKItem 类实例
60427
60450
  var sdkItem;
60428
- // 优先通过 ID 查找现有 SDKItem,获取其 SDKItemType
60429
- var existingSDKItem = this.getSDKItem(playerItem.getInstanceId());
60430
60451
  // 如果找到了现有 SDKItem,根据 SDKItemType 创建
60431
60452
  // 将类型转换为 string 进行比较
60432
60453
  if ((existingSDKItem == null ? void 0 : existingSDKItem.type) === SDKItemType.GENERATOR) {
@@ -60465,11 +60486,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
60465
60486
  property: property
60466
60487
  }));
60467
60488
  } else if ((existingSDKItem == null ? void 0 : existingSDKItem.type) == SDKItemType.CARD) {
60468
- var cardType = existingSDKItem.cardType, html = existingSDKItem.html;
60489
+ var cardType = existingSDKItem.cardType;
60469
60490
  sdkItem = new CardItem(_extends({}, baseOptions, {
60470
60491
  property: _extends({}, property, {
60471
- cardType: cardType,
60472
- html: html
60492
+ cardType: cardType
60473
60493
  })
60474
60494
  }));
60475
60495
  } else {
@@ -60696,6 +60716,19 @@ var PageDataUtils = /*#__PURE__*/ function() {
60696
60716
  }).call(this);
60697
60717
  };
60698
60718
  /**
60719
+ * @description 设置元素extension字段
60720
+ */ _proto.setItemExtension = function setItemExtension(itemId, extension) {
60721
+ var item = this.getSDKItem(itemId);
60722
+ if (!item) {
60723
+ console.warn('setItemExtension: item not found');
60724
+ return;
60725
+ }
60726
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.entries(extension)), _step; !(_step = _iterator()).done;){
60727
+ var _step_value = _step.value, key = _step_value[0], value = _step_value[1];
60728
+ item.extension.set(key, value);
60729
+ }
60730
+ };
60731
+ /**
60699
60732
  * @description 场景 1: 设置单个元素的单个属性
60700
60733
  */ _proto.setSingleItemSingleProperty = function setSingleItemSingleProperty(param) {
60701
60734
  return _async_to_generator(function() {
@@ -60952,7 +60985,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
60952
60985
  * @description 更新 PlayerItem 的 Property 属性
60953
60986
  */ _proto.updatePlayerItemPropertyAttribute = function updatePlayerItemPropertyAttribute(playerItem, targetItem, propertyName, propertyValue) {
60954
60987
  return _async_to_generator(function() {
60955
- 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;
60988
+ 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;
60956
60989
  return _ts_generator(this, function(_state) {
60957
60990
  switch(_state.label){
60958
60991
  case 0:
@@ -61053,40 +61086,35 @@ var PageDataUtils = /*#__PURE__*/ function() {
61053
61086
  3,
61054
61087
  31
61055
61088
  ];
61056
- case 'html':
61057
- return [
61058
- 3,
61059
- 32
61060
- ];
61061
61089
  case 'position':
61062
61090
  return [
61063
61091
  3,
61064
- 33
61092
+ 32
61065
61093
  ];
61066
61094
  case 'rotation':
61067
61095
  return [
61068
61096
  3,
61069
- 34
61097
+ 33
61070
61098
  ];
61071
61099
  case 'scale':
61072
61100
  return [
61073
61101
  3,
61074
- 35
61102
+ 34
61075
61103
  ];
61076
61104
  case 'layoutMode':
61077
61105
  return [
61078
61106
  3,
61079
- 36
61107
+ 35
61080
61108
  ];
61081
61109
  case 'visible':
61082
61110
  return [
61083
61111
  3,
61084
- 37
61112
+ 36
61085
61113
  ];
61086
61114
  }
61087
61115
  return [
61088
61116
  3,
61089
- 38
61117
+ 37
61090
61118
  ];
61091
61119
  case 1:
61092
61120
  {
@@ -61099,7 +61127,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61099
61127
  }
61100
61128
  return [
61101
61129
  3,
61102
- 39
61130
+ 38
61103
61131
  ];
61104
61132
  }
61105
61133
  case 2:
@@ -61110,7 +61138,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61110
61138
  }
61111
61139
  return [
61112
61140
  3,
61113
- 39
61141
+ 38
61114
61142
  ];
61115
61143
  }
61116
61144
  case 3:
@@ -61142,7 +61170,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61142
61170
  case 5:
61143
61171
  return [
61144
61172
  3,
61145
- 39
61173
+ 38
61146
61174
  ];
61147
61175
  case 6:
61148
61176
  {
@@ -61159,7 +61187,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61159
61187
  }
61160
61188
  return [
61161
61189
  3,
61162
- 39
61190
+ 38
61163
61191
  ];
61164
61192
  }
61165
61193
  case 7:
@@ -61173,7 +61201,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61173
61201
  }
61174
61202
  return [
61175
61203
  3,
61176
- 39
61204
+ 38
61177
61205
  ];
61178
61206
  }
61179
61207
  case 8:
@@ -61186,7 +61214,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61186
61214
  }
61187
61215
  return [
61188
61216
  3,
61189
- 39
61217
+ 38
61190
61218
  ];
61191
61219
  }
61192
61220
  case 9:
@@ -61200,7 +61228,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61200
61228
  }
61201
61229
  return [
61202
61230
  3,
61203
- 39
61231
+ 38
61204
61232
  ];
61205
61233
  }
61206
61234
  case 10:
@@ -61213,7 +61241,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61213
61241
  }
61214
61242
  return [
61215
61243
  3,
61216
- 39
61244
+ 38
61217
61245
  ];
61218
61246
  }
61219
61247
  case 11:
@@ -61226,7 +61254,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61226
61254
  }
61227
61255
  return [
61228
61256
  3,
61229
- 39
61257
+ 38
61230
61258
  ];
61231
61259
  }
61232
61260
  case 12:
@@ -61246,7 +61274,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61246
61274
  }
61247
61275
  return [
61248
61276
  3,
61249
- 39
61277
+ 38
61250
61278
  ];
61251
61279
  }
61252
61280
  case 13:
@@ -61288,7 +61316,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61288
61316
  }
61289
61317
  return [
61290
61318
  3,
61291
- 39
61319
+ 38
61292
61320
  ];
61293
61321
  }
61294
61322
  case 14:
@@ -61323,7 +61351,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61323
61351
  }
61324
61352
  return [
61325
61353
  3,
61326
- 39
61354
+ 38
61327
61355
  ];
61328
61356
  }
61329
61357
  case 15:
@@ -61337,7 +61365,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61337
61365
  }
61338
61366
  return [
61339
61367
  3,
61340
- 39
61368
+ 38
61341
61369
  ];
61342
61370
  }
61343
61371
  case 16:
@@ -61369,7 +61397,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61369
61397
  case 20:
61370
61398
  return [
61371
61399
  3,
61372
- 39
61400
+ 38
61373
61401
  ];
61374
61402
  case 21:
61375
61403
  if (!(typeof propertyValue === 'string' && playerItem.type === spec.ItemType.video)) return [
@@ -61400,7 +61428,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61400
61428
  case 25:
61401
61429
  return [
61402
61430
  3,
61403
- 39
61431
+ 38
61404
61432
  ];
61405
61433
  case 26:
61406
61434
  if (!(playerItem.type === spec.ItemType.null)) return [
@@ -61440,12 +61468,15 @@ var PageDataUtils = /*#__PURE__*/ function() {
61440
61468
  compositionItem.parentId = playerItem.getInstanceId();
61441
61469
  component = compositionItem.components[0];
61442
61470
  component == null ? void 0 : component.pause();
61471
+ // 刷新前快照视频播放态,刷新后恢复,避免更换特效导致全量视频被自动播放
61472
+ videoPlayStates = this.snapshotVideoPlayStates();
61443
61473
  this.sdk.player.gotoAndPlay(0);
61474
+ this.restoreVideoPlayStates(videoPlayStates);
61444
61475
  _state.label = 28;
61445
61476
  case 28:
61446
61477
  return [
61447
61478
  3,
61448
- 39
61479
+ 38
61449
61480
  ];
61450
61481
  case 29:
61451
61482
  {
@@ -61457,7 +61488,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61457
61488
  }
61458
61489
  return [
61459
61490
  3,
61460
- 39
61491
+ 38
61461
61492
  ];
61462
61493
  }
61463
61494
  case 30:
@@ -61470,7 +61501,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61470
61501
  }
61471
61502
  return [
61472
61503
  3,
61473
- 39
61504
+ 38
61474
61505
  ];
61475
61506
  }
61476
61507
  case 31:
@@ -61483,20 +61514,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61483
61514
  }
61484
61515
  return [
61485
61516
  3,
61486
- 39
61517
+ 38
61487
61518
  ];
61488
61519
  }
61489
61520
  case 32:
61490
- {
61491
- if (isCardItem(targetItem)) {
61492
- targetItem.html = isCardHTMLValue(propertyValue) ? propertyValue : undefined;
61493
- }
61494
- return [
61495
- 3,
61496
- 39
61497
- ];
61498
- }
61499
- case 33:
61500
61521
  {
61501
61522
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61502
61523
  pixelTranslation = propertyValue.map(function(v, i) {
@@ -61509,10 +61530,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61509
61530
  }
61510
61531
  return [
61511
61532
  3,
61512
- 39
61533
+ 38
61513
61534
  ];
61514
61535
  }
61515
- case 34:
61536
+ case 33:
61516
61537
  {
61517
61538
  if (Array.isArray(propertyValue) && propertyValue.length === 3) {
61518
61539
  rotation = propertyValue.map(function(v, i) {
@@ -61523,10 +61544,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61523
61544
  }
61524
61545
  return [
61525
61546
  3,
61526
- 39
61547
+ 38
61527
61548
  ];
61528
61549
  }
61529
- case 35:
61550
+ case 34:
61530
61551
  {
61531
61552
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61532
61553
  currentScale = targetItem.property.scale;
@@ -61540,10 +61561,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61540
61561
  }
61541
61562
  return [
61542
61563
  3,
61543
- 39
61564
+ 38
61544
61565
  ];
61545
61566
  }
61546
- case 36:
61567
+ case 35:
61547
61568
  {
61548
61569
  if (propertyValue === FrameLayoutMode.AUTO || propertyValue === FrameLayoutMode.FREE) {
61549
61570
  frameComponent = playerItem.getComponent(FrameComponent);
@@ -61553,10 +61574,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61553
61574
  }
61554
61575
  return [
61555
61576
  3,
61556
- 39
61577
+ 38
61557
61578
  ];
61558
61579
  }
61559
- case 37:
61580
+ case 36:
61560
61581
  {
61561
61582
  if (typeof propertyValue === 'boolean') {
61562
61583
  playerItem.setVisible(propertyValue);
@@ -61569,10 +61590,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61569
61590
  }
61570
61591
  return [
61571
61592
  3,
61572
- 39
61593
+ 38
61573
61594
  ];
61574
61595
  }
61575
- case 38:
61596
+ case 37:
61576
61597
  {
61577
61598
  console.log('ignore property name ', propertyName);
61578
61599
  // 对于未明确处理的属性,尝试直接设置到 property 对象
@@ -61580,8 +61601,8 @@ var PageDataUtils = /*#__PURE__*/ function() {
61580
61601
  targetItem.property[propertyName] = propertyValue;
61581
61602
  }
61582
61603
  }
61583
- _state.label = 39;
61584
- case 39:
61604
+ _state.label = 38;
61605
+ case 38:
61585
61606
  // 非位置属性需要刷新播放器
61586
61607
  // template 模式下保持暂停态以避免播放器自动播放,editor 模式继续推进
61587
61608
  if (![
@@ -61590,11 +61611,14 @@ var PageDataUtils = /*#__PURE__*/ function() {
61590
61611
  'size'
61591
61612
  ].includes(propertyName)) {
61592
61613
  time = this.sdk.pageData.time;
61614
+ // 刷新前快照视频播放态,刷新后恢复,避免设置属性导致全量视频被自动播放
61615
+ videoPlayStates1 = this.snapshotVideoPlayStates();
61593
61616
  if (SDK.config.mode === 'editor') {
61594
61617
  this.player.gotoAndPlay(time);
61595
61618
  } else {
61596
61619
  this.player.gotoAndStop(time);
61597
61620
  }
61621
+ this.restoreVideoPlayStates(videoPlayStates1);
61598
61622
  }
61599
61623
  return [
61600
61624
  2
@@ -62461,6 +62485,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
62461
62485
  }
62462
62486
  break;
62463
62487
  }
62488
+ case 'cardType':
62489
+ {
62490
+ break;
62491
+ }
62464
62492
  default:
62465
62493
  {
62466
62494
  console.warn("Target property " + propertyName + " can not be changed.");
@@ -63053,12 +63081,15 @@ var PageDataUtils = /*#__PURE__*/ function() {
63053
63081
  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 ? [
63054
63082
  1,
63055
63083
  1
63056
- ] : _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 ? generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63084
+ ] : _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 ? generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63057
63085
  // 校验 cardType 是否已在配置中注册
63086
+ var cardTypeConfig = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
63087
+ return t.type === cardType;
63088
+ });
63058
63089
  var registeredTypes = SDK.config.itemConfig.cardConfig.cardTypes.map(function(t) {
63059
63090
  return t.type;
63060
63091
  });
63061
- if (!registeredTypes.includes(cardType)) {
63092
+ if (!cardTypeConfig) {
63062
63093
  console.warn('CardItem cardType "' + cardType + '" is not registered. Registered types: ' + registeredTypes.join(', '));
63063
63094
  return;
63064
63095
  }
@@ -63102,9 +63133,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
63102
63133
  width: width,
63103
63134
  height: height,
63104
63135
  scale: [].concat(scale),
63105
- cardType: cardType,
63106
- autoHeight: autoHeight,
63107
- html: html
63136
+ cardType: cardType
63108
63137
  },
63109
63138
  extension: extension
63110
63139
  });
@@ -64486,8 +64515,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
64486
64515
  scalar.y
64487
64516
  ],
64488
64517
  rotation: [].concat(rotation),
64489
- position: [].concat(resultPosition),
64490
- html: sdkItem.html
64518
+ position: [].concat(resultPosition)
64491
64519
  },
64492
64520
  extension: extension
64493
64521
  };
@@ -65533,7 +65561,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
65533
65561
  _this = this;
65534
65562
  changeProeprty = function changeProeprty(targetCreateInfo) {
65535
65563
  return _async_to_generator(function() {
65536
- var currentCreateInfo;
65564
+ var currentCreateInfo, itemId;
65537
65565
  return _ts_generator(this, function(_state) {
65538
65566
  switch(_state.label){
65539
65567
  case 0:
@@ -65544,16 +65572,20 @@ var PageDataUtils = /*#__PURE__*/ function() {
65544
65572
  2
65545
65573
  ];
65546
65574
  }
65575
+ itemId = targetCreateInfo.id;
65547
65576
  return [
65548
65577
  4,
65549
65578
  this.setItemProperty({
65550
- itemId: currentCreateInfo.id,
65579
+ itemId: itemId,
65551
65580
  type: currentCreateInfo.type,
65552
65581
  property: targetCreateInfo.property
65553
65582
  })
65554
65583
  ];
65555
65584
  case 1:
65556
65585
  _state.sent();
65586
+ if (targetCreateInfo.extension) {
65587
+ this.setItemExtension(itemId, targetCreateInfo.extension);
65588
+ }
65557
65589
  return [
65558
65590
  2
65559
65591
  ];
@@ -65609,6 +65641,51 @@ var PageDataUtils = /*#__PURE__*/ function() {
65609
65641
  var result = box.clone().scale(scale, center).translate(translation);
65610
65642
  return result;
65611
65643
  };
65644
+ /**
65645
+ * @description 快照当前所有视频元素的播放状态(播放/暂停 + 当前播放进度),用于属性刷新后恢复,
65646
+ * 避免设置属性导致全量视频被自动播放或进度被重置回 0s
65647
+ */ _proto.snapshotVideoPlayStates = function snapshotVideoPlayStates() {
65648
+ var states = new Map();
65649
+ var composition = this.getCurrentComposition();
65650
+ for(var _iterator = _create_for_of_iterator_helper_loose(composition.items), _step; !(_step = _iterator()).done;){
65651
+ var item = _step.value;
65652
+ if (item.type === spec.ItemType.video) {
65653
+ var videoComponent = item.getComponent(VideoComponent);
65654
+ if (!videoComponent) {
65655
+ continue;
65656
+ }
65657
+ //@ts-expect-error @赤芍 played 字段未在类型中声明,参见 rebuildCompositionItems 处用法
65658
+ var played = !!videoComponent.played;
65659
+ var time = videoComponent.getCurrentTime();
65660
+ states.set(item.getInstanceId(), {
65661
+ played: played,
65662
+ time: time
65663
+ });
65664
+ }
65665
+ }
65666
+ return states;
65667
+ };
65668
+ /**
65669
+ * @description 按快照恢复视频元素的播放状态(先 pause 再 seek,最后按原状态 play/pause,避免进度抖动)
65670
+ */ _proto.restoreVideoPlayStates = function restoreVideoPlayStates(states) {
65671
+ for(var _iterator = _create_for_of_iterator_helper_loose(states), _step; !(_step = _iterator()).done;){
65672
+ var _step_value = _step.value, id = _step_value[0], _step_value_ = _step_value[1], played = _step_value_.played, time = _step_value_.time;
65673
+ var playerItem = this.getPlayerItemById(id);
65674
+ if ((playerItem == null ? void 0 : playerItem.type) !== spec.ItemType.video) {
65675
+ continue;
65676
+ }
65677
+ var videoComponent = playerItem.getComponent(VideoComponent);
65678
+ if (!videoComponent) {
65679
+ continue;
65680
+ }
65681
+ // 先暂停再 seek,避免播放状态下 seek 导致画面抖动
65682
+ videoComponent.pauseVideo();
65683
+ videoComponent.setCurrentTime(time);
65684
+ if (played) {
65685
+ videoComponent.playVideo();
65686
+ }
65687
+ }
65688
+ };
65612
65689
  _proto.playVideoItem = function playVideoItem(id) {
65613
65690
  var playerItem = this.getPlayerItemById(id);
65614
65691
  if ((playerItem == null ? void 0 : playerItem.type) !== spec.ItemType.video) {
@@ -65871,35 +65948,56 @@ var PageDataUtils = /*#__PURE__*/ function() {
65871
65948
  };
65872
65949
  _proto.asyncAddItemByCreateInfos = function asyncAddItemByCreateInfos(createInfos) {
65873
65950
  return _async_to_generator(function() {
65874
- var _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, createInfo, id, type, url, textureId, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65951
+ var _loop, _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65875
65952
  return _ts_generator(this, function(_state) {
65876
65953
  switch(_state.label){
65877
65954
  case 0:
65878
- _this = this;
65879
- createInfoWithIds = createInfos.map(function(createInfo) {
65880
- return Object.assign({}, createInfo, createInfo.id ? {} : {
65881
- id: generateGUID()
65882
- });
65883
- });
65884
- itemToTextureInfo = new Map();
65885
- // 预处理所有 createInfo,分配 textureId
65886
- for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;){
65887
- createInfo = _step.value;
65888
- id = createInfo.id;
65889
- type = createInfo.type;
65890
- url = type === SDKItemType.SPRITE ? createInfo.property.image : type === SDKItemType.VIDEO ? createInfo.property.video : undefined;
65891
- if ((type === SDKItemType.SPRITE || type === SDKItemType.VIDEO) && url) {
65892
- textureId = generateGUID();
65893
- itemToTextureInfo.set(id, {
65955
+ _loop = function() {
65956
+ var createInfo = _step.value;
65957
+ var _ref = function() {
65958
+ switch(createInfo.type){
65959
+ case SDKItemType.SPRITE:
65960
+ {
65961
+ return {
65962
+ url: createInfo.property.image,
65963
+ type: 'image'
65964
+ };
65965
+ }
65966
+ case SDKItemType.VIDEO:
65967
+ {
65968
+ return {
65969
+ url: createInfo.property.video,
65970
+ type: 'video'
65971
+ };
65972
+ }
65973
+ default:
65974
+ {
65975
+ return {};
65976
+ }
65977
+ }
65978
+ }(), url = _ref.url, type = _ref.type;
65979
+ if (url && type) {
65980
+ var textureId = generateGUID();
65981
+ itemToTextureInfo.set(createInfo.id, {
65894
65982
  id: textureId,
65895
65983
  url: url,
65896
- type: type === SDKItemType.SPRITE ? 'image' : 'video'
65984
+ type: type
65897
65985
  });
65898
65986
  Object.assign(createInfo, {
65899
65987
  textureId: textureId
65900
65988
  });
65901
65989
  }
65902
- }
65990
+ };
65991
+ _this = this;
65992
+ createInfoWithIds = createInfos.map(function(createInfo) {
65993
+ var _createInfo_id;
65994
+ return Object.assign({}, createInfo, {
65995
+ id: (_createInfo_id = createInfo.id) != null ? _createInfo_id : generateGUID()
65996
+ });
65997
+ });
65998
+ itemToTextureInfo = new Map();
65999
+ // 预处理所有 createInfo,分配 textureId
66000
+ for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;)_loop();
65903
66001
  // 并行创建所有 item
65904
66002
  toAddedCreateInfo = createInfoWithIds.filter(function(createInfo) {
65905
66003
  return ![
@@ -66868,6 +66966,51 @@ var PageDataUtils = /*#__PURE__*/ function() {
66868
66966
  * @param id 元素id
66869
66967
  * @param size 目标大小 [width, height]
66870
66968
  * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66969
+ */ _proto.resizeCardItem = function resizeCardItem(id, size, translation) {
66970
+ var _frameController_children;
66971
+ var frameItem = this.getSDKItem(id);
66972
+ if (!frameItem) {
66973
+ return;
66974
+ }
66975
+ var newWidth = size[0], newHeight = size[1];
66976
+ // const originalWidth = frameItem.property.width
66977
+ // 计算世界尺寸(供后续使用)
66978
+ var viewSize = this.interactionUtils.getViewSizeByPixelSize(new Vector2(newWidth, newHeight));
66979
+ var worldSize = this.interactionUtils.getWorldSizeByViewSize(viewSize).abs();
66980
+ // 1 更新 Player 层的预合成和子元素
66981
+ // 1.1 更新 Player Item(空节点控制器)的大小
66982
+ var frameController = this.getPlayerItemById(id);
66983
+ if (frameController) {
66984
+ frameController.transform.setSize(worldSize.x, worldSize.y);
66985
+ // 如果有位移,更新位置
66986
+ if (translation && (translation.x !== 0 || translation.y !== 0)) {
66987
+ var currentPosition = frameController.transform.position;
66988
+ frameController.setPosition(currentPosition.x + translation.x, currentPosition.y + translation.y, currentPosition.z);
66989
+ }
66990
+ }
66991
+ // 1.2 更新 Player Children Item 的大小
66992
+ var subCompositionItem = frameController == null ? void 0 : (_frameController_children = frameController.children) == null ? void 0 : _frameController_children[0];
66993
+ if (subCompositionItem && translation) {
66994
+ // 更新子元素
66995
+ subCompositionItem.children.forEach(function(item) {
66996
+ var _item;
66997
+ var _item_transform_getParentMatrix;
66998
+ var parentMatrix = new Matrix4().copyFrom((_item_transform_getParentMatrix = item.transform.getParentMatrix()) != null ? _item_transform_getParentMatrix : new Matrix4());
66999
+ parentMatrix.setPosition(new Vector3());
67000
+ var result = translation.clone().applyMatrix(parentMatrix.invert()).negate();
67001
+ (_item = item).translate.apply(_item, [].concat(result.toArray()));
67002
+ item.transform.updateLocalMatrix();
67003
+ });
67004
+ }
67005
+ // 2: 刷新 SDKItem 数据
67006
+ // 更新 FrameItem 的 property
67007
+ this.refreshSDKItem(frameItem.id);
67008
+ };
67009
+ /**
67010
+ * @description 修改画板元素大小
67011
+ * @param id 元素id
67012
+ * @param size 目标大小 [width, height]
67013
+ * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66871
67014
  */ _proto.resizeFrameItem = function resizeFrameItem(id, size, translation) {
66872
67015
  var _this = this;
66873
67016
  var _frameController_children;
@@ -67174,7 +67317,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
67174
67317
  };
67175
67318
  _proto.autoLayoutPage = function autoLayoutPage() {
67176
67319
  return _async_to_generator(function(param) {
67177
- var _this, pageData, _param_mode, mode, ids, _param_focus, focus, _param_gap, gap, isPartialLayout, targetItems, layoutElements, moveInfos, anchor, _iterator, _step, moveInfo, sdkItem;
67320
+ var _this, pageData, _param_mode, mode, ids, _param_focus, focus, _param_gap, gap, shift, isPartialLayout, targetItems, layoutElements, moveInfos, anchor, _iterator, _step, moveInfo, sdkItem;
67178
67321
  return _ts_generator(this, function(_state) {
67179
67322
  switch(_state.label){
67180
67323
  case 0:
@@ -67189,7 +67332,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
67189
67332
  2
67190
67333
  ];
67191
67334
  }
67192
- _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;
67335
+ _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;
67193
67336
  isPartialLayout = !!(ids == null ? void 0 : ids.length);
67194
67337
  // 1. 确定参与排布的顶层元素(过滤子元素)
67195
67338
  targetItems = pageData.items.filter(function(item) {
@@ -67218,7 +67361,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
67218
67361
  // 4. 计算锚点偏移
67219
67362
  // - 选中元素排布:以原始包围盒左上角为锚点
67220
67363
  // - 全量排布:以视口中心为锚点
67221
- anchor = isPartialLayout ? this.getPartialLayoutAnchor(layoutElements, moveInfos.boundingBox) : this.getGlobalLayoutAnchor(moveInfos.boundingBox);
67364
+ anchor = isPartialLayout ? this.getPartialLayoutAnchor(layoutElements, moveInfos.boundingBox) : this.getGlobalLayoutAnchor(moveInfos.boundingBox, shift);
67222
67365
  _iterator = _create_for_of_iterator_helper_loose(moveInfos.items);
67223
67366
  _state.label = 1;
67224
67367
  case 1:
@@ -67261,7 +67404,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
67261
67404
  if (focus) {
67262
67405
  this.setPageZoom(1, undefined, true);
67263
67406
  this.setPageMove(new Vector2());
67264
- this.viewportFit(undefined, moveInfos.boundingBox.translate(anchor));
67407
+ this.viewportFit(shift, moveInfos.boundingBox.translate(anchor));
67265
67408
  }
67266
67409
  return [
67267
67410
  2
@@ -67285,8 +67428,9 @@ var PageDataUtils = /*#__PURE__*/ function() {
67285
67428
  /**
67286
67429
  * @description 计算全量排布的锚点偏移:以视口中心为锚点
67287
67430
  * @param layoutBoundingBox 排布算法输出的包围盒
67288
- */ _proto.getGlobalLayoutAnchor = function getGlobalLayoutAnchor(layoutBoundingBox) {
67289
- var viewCenter = new Vector2(this.sdk._container.offsetWidth / 2, this.sdk._container.offsetHeight / 2);
67431
+ */ _proto.getGlobalLayoutAnchor = function getGlobalLayoutAnchor(layoutBoundingBox, shift) {
67432
+ 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;
67433
+ var viewCenter = new Vector2(this.sdk._container.offsetWidth / 2 + left - right, this.sdk._container.offsetHeight / 2 + top - bottom);
67290
67434
  var boundCenter = layoutBoundingBox.getCenter();
67291
67435
  return new Vector2(viewCenter.x - boundCenter.x, viewCenter.y - boundCenter.y);
67292
67436
  };
@@ -68888,6 +69032,8 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
68888
69032
  */ _this.maskSprite = null, _this._config = {}, _this.boxGraphics = new Graphics(), _this.type = 'mask', _this.mode = 'paint', /**
68889
69033
  * 蒙版工具独立的撤销重做实例
68890
69034
  */ _this._undoRedo = new GizmoUndoRedo(), /**
69035
+ * 框选擦除进行中标记(按下到松开之间),用于实时选框描边的显示控制
69036
+ */ _this._isBoxErasing = false, /**
68891
69037
  * 鼠标状态绘制结果
68892
69038
  */ _this.cursorResult = {
68893
69039
  type: 'normal',
@@ -68904,10 +69050,22 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
68904
69050
  var _proto = MaskGizmo.prototype;
68905
69051
  /**
68906
69052
  * 设置模式
68907
- * @param mode 模式类型:'paint' 表示涂抹,'erase' 表示擦除
69053
+ * @param mode 模式类型:'paint' 笔刷涂抹、'erase' 笔刷逐笔擦除、'box-erase' 框选擦除、'box-paint' 框选涂抹
68908
69054
  */ _proto.setMode = function setMode(mode) {
68909
69055
  this.mode = mode;
68910
69056
  };
69057
+ /**
69058
+ * @description 判断点是否在包围盒内
69059
+ */ _proto._isPointInBox = function _isPointInBox(p, box) {
69060
+ return p.x >= box.min.x && p.x <= box.max.x && p.y >= box.min.y && p.y <= box.max.y;
69061
+ };
69062
+ /**
69063
+ * @description 将屏幕坐标转换为包围盒内的归一化坐标 [0,1](钳制在范围内)
69064
+ */ _proto._toNormalized = function _toNormalized(p, box) {
69065
+ var x = Math.max(0, Math.min(1, (p.x - box.min.x) / (box.max.x - box.min.x)));
69066
+ var y = Math.max(0, Math.min(1, (p.y - box.min.y) / (box.max.y - box.min.y)));
69067
+ return new Vector2(x, y);
69068
+ };
68911
69069
  _proto.initialize = function initialize() {};
68912
69070
  _proto.preparationAction = function preparationAction(event) {
68913
69071
  if (!this.interactive) {
@@ -68926,6 +69084,26 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
68926
69084
  };
68927
69085
  // 更新鼠标位置
68928
69086
  this.result.point = new Vector2(event.offsetX, event.offsetY);
69087
+ // 框选模式(框选擦除 / 框选涂抹):仅在元素包围盒内按下才触发
69088
+ if (this.mode === 'box-erase' || this.mode === 'box-paint') {
69089
+ var box = this.result.box;
69090
+ if (!box || !this._isPointInBox(this.result.point, box)) {
69091
+ // 包围盒外按下:不触发框选,交由其它 gizmo
69092
+ return undefined;
69093
+ }
69094
+ var start = this._toNormalized(this.result.point, box);
69095
+ this.result.lines.push({
69096
+ type: this.mode === 'box-paint' ? 'paint' : 'erase',
69097
+ shape: 'rect',
69098
+ brushSize: 0,
69099
+ points: [
69100
+ start,
69101
+ start.clone()
69102
+ ]
69103
+ });
69104
+ this._isBoxErasing = true;
69105
+ return this.type;
69106
+ }
68929
69107
  // 开启新画笔
68930
69108
  this.result.lines.push({
68931
69109
  type: this.mode,
@@ -68935,32 +69113,61 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
68935
69113
  return this.type;
68936
69114
  };
68937
69115
  _proto.action = function action(event) {
68938
- var // 记录鼠标划线位置
68939
- _this_result_lines_;
68940
69116
  if (!this.interactive || this.result.status === 'init') {
68941
69117
  return;
68942
69118
  }
68943
69119
  // 更新鼠标位置
68944
69120
  var box = this.result.box;
68945
- 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));
68946
- (_this_result_lines_ = this.result.lines[this.result.lines.length - 1]) == null ? void 0 : _this_result_lines_.points.push(point);
69121
+ var point = new Vector2(event.offsetX, event.offsetY);
69122
+ this.result.point = point;
69123
+ var lastLine = this.result.lines[this.result.lines.length - 1];
69124
+ // 框选擦除:更新框选终点(钳制到包围盒内)
69125
+ if ((lastLine == null ? void 0 : lastLine.shape) === 'rect') {
69126
+ lastLine.points[1] = this._toNormalized(point, box);
69127
+ return;
69128
+ }
69129
+ // 记录鼠标划线位置(笔刷模式)
69130
+ 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));
69131
+ lastLine == null ? void 0 : lastLine.points.push(np);
68947
69132
  };
68948
69133
  _proto.endAction = function endAction() {
68949
69134
  if (!this.interactive) {
68950
69135
  return undefined;
68951
69136
  }
68952
- // 记录操作到 undoRedo(仅当画线有实际点时才记录)
68953
69137
  var lastLine = this.result.lines[this.result.lines.length - 1];
69138
+ // 框选擦除:起点==终点视为空框选,移除;否则提交 undoRedo
69139
+ if ((lastLine == null ? void 0 : lastLine.shape) === 'rect') {
69140
+ this._isBoxErasing = false;
69141
+ var _lastLine_points = lastLine.points, a = _lastLine_points[0], b = _lastLine_points[1];
69142
+ var isEmpty = !!a && !!b && a.x === b.x && a.y === b.y;
69143
+ if (this._oldLines && !isEmpty) {
69144
+ var operation = {
69145
+ type: 'update',
69146
+ oldData: this._oldLines,
69147
+ newData: {
69148
+ lines: JSON.parse(JSON.stringify(this.result.lines))
69149
+ }
69150
+ };
69151
+ this._undoRedo.push(operation);
69152
+ this._eventEmitter.emit('maskGizmoUndoRedoChange', operation);
69153
+ } else {
69154
+ // 空框选移除
69155
+ this.result.lines.pop();
69156
+ }
69157
+ this._oldLines = undefined;
69158
+ return this.type;
69159
+ }
69160
+ // 记录操作到 undoRedo(仅当画线有实际点时才记录)
68954
69161
  if (this._oldLines && lastLine && lastLine.points.length > 0) {
68955
- var operation = {
69162
+ var operation1 = {
68956
69163
  type: 'update',
68957
69164
  oldData: this._oldLines,
68958
69165
  newData: {
68959
69166
  lines: JSON.parse(JSON.stringify(this.result.lines))
68960
69167
  }
68961
69168
  };
68962
- this._undoRedo.push(operation);
68963
- this._eventEmitter.emit('maskGizmoUndoRedoChange', operation);
69169
+ this._undoRedo.push(operation1);
69170
+ this._eventEmitter.emit('maskGizmoUndoRedoChange', operation1);
68964
69171
  } else if ((lastLine == null ? void 0 : lastLine.points.length) === 0) {
68965
69172
  // 如果没有实际绘制点,移除空的线条
68966
69173
  this.result.lines.pop();
@@ -69085,6 +69292,17 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
69085
69292
  this.boxGraphics.lineStyle(boxLineWidth, boxLineColor, boxLineAlpha);
69086
69293
  this.boxGraphics.drawBox(box);
69087
69294
  this.boxGraphics.endFill();
69295
+ // 框选擦除进行中:叠加当前拖动矩形的可视描边
69296
+ var lastLine = this.result.lines[this.result.lines.length - 1];
69297
+ if (this._isBoxErasing && (lastLine == null ? void 0 : lastLine.shape) === 'rect' && lastLine.points.length >= 2) {
69298
+ var _lastLine_points = lastLine.points, a = _lastLine_points[0], b = _lastLine_points[1];
69299
+ if (a && b) {
69300
+ 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)));
69301
+ this.boxGraphics.lineStyle(boxLineWidth, boxLineColor, boxLineAlpha);
69302
+ this.boxGraphics.drawBox(selBox);
69303
+ this.boxGraphics.endFill();
69304
+ }
69305
+ }
69088
69306
  // 1. 画线形(只用于遮罩,不直接显示
69089
69307
  for(var _iterator = _create_for_of_iterator_helper_loose(this.result.lines), _step; !(_step = _iterator()).done;){
69090
69308
  var line = _step.value;
@@ -69092,6 +69310,32 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
69092
69310
  continue;
69093
69311
  }
69094
69312
  var lineGraphics = new Graphics();
69313
+ // 矩形框选:填充矩形,paint 用 NORMAL 叠加,erase 用 DST_OUT 抠除
69314
+ if (line.shape === 'rect') {
69315
+ var a1 = line.points[0];
69316
+ var b1 = line.points[1];
69317
+ if (a1 && b1) {
69318
+ var w = box.max.x - box.min.x;
69319
+ var h = box.max.y - box.min.y;
69320
+ var x0 = Math.min(a1.x, b1.x) * w;
69321
+ var y0 = Math.min(a1.y, b1.y) * h;
69322
+ var x1 = Math.max(a1.x, b1.x) * w;
69323
+ var y1 = Math.max(a1.y, b1.y) * h;
69324
+ // 太小(纯点击)不渲染,避免 1px 擦除/涂抹点
69325
+ if (x1 - x0 > 0.5 || y1 - y0 > 0.5) {
69326
+ lineGraphics.beginFill(brushColor);
69327
+ lineGraphics.drawRect(x0, y0, x1 - x0, y1 - y0);
69328
+ lineGraphics.endFill();
69329
+ lineGraphics.blendMode = line.type === 'paint' ? BLEND_MODES.NORMAL : BLEND_MODES.DST_OUT;
69330
+ this._app.renderer.render(lineGraphics, {
69331
+ renderTexture: this.maskRenderTexture,
69332
+ clear: false
69333
+ });
69334
+ }
69335
+ }
69336
+ lineGraphics.destroy();
69337
+ continue;
69338
+ }
69095
69339
  lineGraphics.blendMode = line.type === 'paint' ? BLEND_MODES.NORMAL : BLEND_MODES.DST_OUT;
69096
69340
  lineGraphics.lineStyle({
69097
69341
  width: line.brushSize * viewportParam.scale,
@@ -69135,14 +69379,24 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
69135
69379
  if (!point || !box) {
69136
69380
  return;
69137
69381
  }
69138
- if (point.x >= box.min.x && point.x <= box.max.x && point.y >= box.min.y && point.y <= box.max.y) {
69139
- var viewportParam = this._pageDataUtils.interactionUtils.viewportParam;
69382
+ var inside = point.x >= box.min.x && point.x <= box.max.x && point.y >= box.min.y && point.y <= box.max.y;
69383
+ if (!inside) {
69384
+ return;
69385
+ }
69386
+ // 框选模式(框选擦除 / 框选涂抹):crosshair
69387
+ if (this.mode === 'box-erase' || this.mode === 'box-paint') {
69140
69388
  this.cursorResult = {
69141
- type: 'circle',
69142
- angle: 0,
69143
- radius: this.config.brushSize * viewportParam.scale / 2
69389
+ type: 'box-select',
69390
+ angle: 0
69144
69391
  };
69392
+ return;
69145
69393
  }
69394
+ var viewportParam = this._pageDataUtils.interactionUtils.viewportParam;
69395
+ this.cursorResult = {
69396
+ type: 'circle',
69397
+ angle: 0,
69398
+ radius: this.config.brushSize * viewportParam.scale / 2
69399
+ };
69146
69400
  };
69147
69401
  _proto.close = function close() {
69148
69402
  this._config.maskImage = undefined;
@@ -69290,6 +69544,21 @@ var MaskGizmo = /*#__PURE__*/ function(Gizmo) {
69290
69544
  if (!line || line.points.length === 0) {
69291
69545
  continue;
69292
69546
  }
69547
+ // 矩形框选:填充矩形
69548
+ if (line.shape === 'rect') {
69549
+ var _line_points = line.points, a = _line_points[0], b1 = _line_points[1];
69550
+ if (!a || !b1) {
69551
+ continue;
69552
+ }
69553
+ var x0 = Math.min(a.x, b1.x) * width;
69554
+ var y0 = Math.min(a.y, b1.y) * height;
69555
+ var x1 = Math.max(a.x, b1.x) * width;
69556
+ var y1 = Math.max(a.y, b1.y) * height;
69557
+ ctx.globalCompositeOperation = 'source-over';
69558
+ ctx.fillStyle = line.type === 'paint' ? maskHexColor : maskBackgroundHexColor;
69559
+ ctx.fillRect(x0, y0, Math.max(1, x1 - x0), Math.max(1, y1 - y0));
69560
+ continue;
69561
+ }
69293
69562
  ctx.lineWidth = line.brushSize * scale;
69294
69563
  ctx.lineCap = 'round';
69295
69564
  ctx.lineJoin = 'round';
@@ -71295,7 +71564,8 @@ var GestureHandler = /*#__PURE__*/ function() {
71295
71564
  'active-hand',
71296
71565
  'pointer',
71297
71566
  'text-create',
71298
- 'frame-create'
71567
+ 'frame-create',
71568
+ 'box-select'
71299
71569
  ].includes(result.type)) {
71300
71570
  var cursor = cursorMap[result.type];
71301
71571
  if (cursor.type === 'svg') {
@@ -71467,6 +71737,7 @@ var GestureHandler = /*#__PURE__*/ function() {
71467
71737
  return;
71468
71738
  }
71469
71739
  this.maskGizmo.setMode(mode);
71740
+ this.render();
71470
71741
  };
71471
71742
  _proto.openLoadingGizmo = function openLoadingGizmo(id, options) {
71472
71743
  var _this__emitter;
@@ -83072,43 +83343,12 @@ var BaseConfig = {
83072
83343
  },
83073
83344
  cardConfig: {
83074
83345
  backgroundColor: [
83075
- 0.6,
83076
- 0.6,
83077
- 0.6,
83078
- 0.12
83346
+ 1,
83347
+ 1,
83348
+ 1,
83349
+ 0
83079
83350
  ],
83080
- cardTypes: [
83081
- {
83082
- type: 'character',
83083
- label: '角色图',
83084
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83085
- },
83086
- {
83087
- type: 'environment',
83088
- label: '环境图',
83089
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83090
- },
83091
- {
83092
- type: 'storyboard',
83093
- label: '分镜图',
83094
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83095
- },
83096
- {
83097
- type: 'scene-clip',
83098
- label: '场景剪辑',
83099
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83100
- },
83101
- {
83102
- type: 'video-compose',
83103
- label: '视频合成',
83104
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83105
- },
83106
- {
83107
- type: 'video-generate',
83108
- label: '生成视频',
83109
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83110
- }
83111
- ]
83351
+ cardTypes: []
83112
83352
  }
83113
83353
  }
83114
83354
  };
@@ -91437,11 +91677,18 @@ function isCardHTMLAutoHeightMessage(data, id) {
91437
91677
  var message = data;
91438
91678
  return message.source === 'vvfx-card-html-auto-height' && message.id === id && typeof message.height === 'number';
91439
91679
  }
91680
+ function requestCardHTMLAutoHeight(iframe, id) {
91681
+ var _iframe_contentWindow;
91682
+ (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage({
91683
+ source: 'vvfx-card-html-auto-height-request',
91684
+ id: id
91685
+ }, '*');
91686
+ }
91440
91687
  function withCardHTMLAutoHeightBridge(html, id) {
91441
91688
  if (!id) {
91442
91689
  return html;
91443
91690
  }
91444
- 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>";
91691
+ 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>";
91445
91692
  if (/<\/body>/i.test(html)) {
91446
91693
  return html.replace(/<\/body>/i, "" + script + "</body>");
91447
91694
  }
@@ -91639,6 +91886,17 @@ function withCardHTMLViewportStyle(html) {
91639
91886
  return "<!doctype html><html><head>" + viewportStyle + "</head><body>" + html + "</body></html>";
91640
91887
  }
91641
91888
 
91889
+ function withCardHTMLAnchorNavigationGuard(html, allowAnchorNavigation) {
91890
+ if (allowAnchorNavigation === true) {
91891
+ return html;
91892
+ }
91893
+ 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>";
91894
+ if (/<\/body>/i.test(html)) {
91895
+ return html.replace(/<\/body>/i, "" + script + "</body>");
91896
+ }
91897
+ return "" + html + script;
91898
+ }
91899
+
91642
91900
  function renderDocumentContent(overlay, content, options) {
91643
91901
  var _files_get;
91644
91902
  var iframe = document.createElement('iframe');
@@ -91657,7 +91915,7 @@ function renderDocumentContent(overlay, content, options) {
91657
91915
  iframe.setAttribute('sandbox', content.sandbox);
91658
91916
  }
91659
91917
  var entryHtml = (_files_get = files.get(entry)) != null ? _files_get : '';
91660
- iframe.srcdoc = withCardHTMLAutoHeightBridge(withCardHTMLViewportStyle(transformHTMLDocument(entry, entryHtml, createFileUrl)), options == null ? void 0 : options.autoHeightId);
91918
+ iframe.srcdoc = withCardHTMLAutoHeightBridge(withCardHTMLAnchorNavigationGuard(withCardHTMLViewportStyle(transformHTMLDocument(entry, entryHtml, createFileUrl)), content.allowAnchorNavigation), options == null ? void 0 : options.autoHeightId);
91661
91919
  overlay.appendChild(iframe);
91662
91920
  return function() {
91663
91921
  messageCleanup();
@@ -91714,30 +91972,38 @@ function syncElementStackOrder(_container, elements) {
91714
91972
  });
91715
91973
  }
91716
91974
 
91717
- function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY) {
91975
+ function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
91718
91976
  if (offsetX === void 0) offsetX = 0;
91719
91977
  if (offsetY === void 0) offsetY = 0;
91720
91978
  if (box.corners.length === 4 && width > 0 && height > 0) {
91721
91979
  var _box_corners = box.corners, rightTop = _box_corners[0], leftBottom = _box_corners[2], leftTop = _box_corners[3];
91722
- var a = (rightTop.x - leftTop.x) / width;
91723
- var b = (rightTop.y - leftTop.y) / width;
91724
- var c = (leftBottom.x - leftTop.x) / height;
91725
- var d = (leftBottom.y - leftTop.y) / height;
91980
+ var contentWidth = width;
91981
+ var contentHeight = height;
91982
+ var a = (rightTop.x - leftTop.x) / contentWidth;
91983
+ var b = (rightTop.y - leftTop.y) / contentWidth;
91984
+ var c = (leftBottom.x - leftTop.x) / contentHeight;
91985
+ var d = (leftBottom.y - leftTop.y) / contentHeight;
91726
91986
  var e = leftTop.x - offsetX;
91727
91987
  var f = leftTop.y - offsetY;
91728
91988
  return {
91729
91989
  left: '0px',
91730
91990
  top: '0px',
91731
- width: "" + width + "px",
91732
- height: "" + height + "px",
91991
+ width: "" + formatPixelNumber(contentWidth) + "px",
91992
+ height: "" + formatPixelNumber(contentHeight) + "px",
91993
+ contentWidth: contentWidth,
91994
+ contentHeight: contentHeight,
91733
91995
  transform: "matrix(" + formatMatrixNumber(a) + ", " + formatMatrixNumber(b) + ", " + formatMatrixNumber(c) + ", " + formatMatrixNumber(d) + ", " + formatMatrixNumber(e) + ", " + formatMatrixNumber(f) + ")"
91734
91996
  };
91735
91997
  }
91998
+ var contentWidth1 = box.max.x - box.min.x;
91999
+ var contentHeight1 = box.max.y - box.min.y;
91736
92000
  return {
91737
92001
  left: "" + (box.min.x - offsetX) + "px",
91738
92002
  top: "" + (box.min.y - offsetY) + "px",
91739
- width: "" + (box.max.x - box.min.x) + "px",
91740
- height: "" + (box.max.y - box.min.y) + "px",
92003
+ width: "" + contentWidth1 + "px",
92004
+ height: "" + contentHeight1 + "px",
92005
+ contentWidth: contentWidth1,
92006
+ contentHeight: contentHeight1,
91741
92007
  transform: ''
91742
92008
  };
91743
92009
  }
@@ -91760,6 +92026,10 @@ function formatMatrixNumber(value) {
91760
92026
  var normalized = Object.is(value, -0) ? 0 : value;
91761
92027
  return Number(normalized.toFixed(6)).toString();
91762
92028
  }
92029
+ function formatPixelNumber(value) {
92030
+ var normalized = Object.is(value, -0) ? 0 : value;
92031
+ return Number(normalized.toFixed(6)).toString();
92032
+ }
91763
92033
 
91764
92034
  function mountHTMLShell(container, content, shell) {
91765
92035
  if (!shell) {
@@ -91780,23 +92050,73 @@ function mountHTMLShell(container, content, shell) {
91780
92050
 
91781
92051
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91782
92052
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
92053
+ var CONTENT_INTERACTIVE_SELECTOR = [
92054
+ '[data-vvfx-html-interaction-zone="self"]',
92055
+ '[data-vvfx-html-interaction-zone="subtree"]',
92056
+ 'a[href]',
92057
+ 'button:not([disabled])',
92058
+ 'input:not([disabled])',
92059
+ 'textarea:not([disabled])',
92060
+ 'select:not([disabled])',
92061
+ 'summary',
92062
+ 'video[controls]',
92063
+ 'audio[controls]',
92064
+ '[contenteditable]:not([contenteditable="false"])',
92065
+ '[role="button"]',
92066
+ '[role="link"]',
92067
+ '[role="textbox"]',
92068
+ '[tabindex]:not([tabindex="-1"])'
92069
+ ].join(', ');
92070
+ var CONTENT_INTERACTION_NONE_SELECTOR = [
92071
+ '[data-vvfx-html-interaction-zone="none"]'
92072
+ ].join(', ');
91783
92073
  var EDITING_VIEWPORT_PADDING = 48;
91784
92074
  var EDITING_VIEWPORT_BOX_SCALE = 1.1;
91785
92075
  var AUTO_HEIGHT_EPSILON = 0.5;
91786
92076
  var CARD_RASTERIZE_READY_TIMEOUT = 3000;
92077
+ var CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
92078
+ var requestHTMLOverlayFrame = function requestHTMLOverlayFrame(callback) {
92079
+ if (typeof requestAnimationFrame === 'function') {
92080
+ try {
92081
+ return requestAnimationFrame(callback);
92082
+ } catch (unused) {
92083
+ // Some non-browser test runtimes install a RAF polyfill that depends on window.
92084
+ }
92085
+ }
92086
+ return setTimeout(function() {
92087
+ callback(Date.now());
92088
+ }, 16);
92089
+ };
92090
+ var cancelHTMLOverlayFrame = function cancelHTMLOverlayFrame(frame) {
92091
+ if (typeof cancelAnimationFrame === 'function') {
92092
+ try {
92093
+ cancelAnimationFrame(frame);
92094
+ return;
92095
+ } catch (unused) {
92096
+ // Fall back to clearTimeout for frames created by requestHTMLOverlayFrame.
92097
+ }
92098
+ }
92099
+ clearTimeout(frame);
92100
+ };
91787
92101
  var HTMLOverlayManager = /*#__PURE__*/ function() {
91788
92102
  function HTMLOverlayManager(options) {
91789
92103
  var _this = this;
91790
92104
  this.options = options;
91791
92105
  this.eventCleanups = [];
92106
+ this.htmlRootConfigCleanups = new WeakMap();
91792
92107
  this.state = {
91793
92108
  frameElements: new Map(),
91794
92109
  elements: new Map(),
92110
+ selectionElements: new Map(),
91795
92111
  contentScaleElements: new Map(),
91796
92112
  contentElements: new Map(),
91797
92113
  contentMountElements: new Map(),
92114
+ contentInteractionZones: new Map(),
92115
+ contentInteractionZoneCleanups: new Map(),
92116
+ contentInteractionResizeCleanups: new Map(),
91798
92117
  contents: new Map(),
91799
92118
  cleanups: new Map(),
92119
+ autoHeightModes: new Map(),
91800
92120
  autoHeightCleanups: new Map(),
91801
92121
  autoHeightFrames: new Map()
91802
92122
  };
@@ -91813,12 +92133,18 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91813
92133
  }
91814
92134
  return;
91815
92135
  }
92136
+ if (!_this.isEditableCard(targetId)) {
92137
+ return;
92138
+ }
91816
92139
  event.preventDefault();
91817
92140
  event.stopPropagation();
91818
92141
  _this.enterEditing(targetId);
91819
92142
  };
91820
92143
  this.handleContainerMouseDown = function(event) {
91821
92144
  var _this_state_editing;
92145
+ if (event.button === 0) {
92146
+ _this.selectHTMLInteractionCard(event);
92147
+ }
91822
92148
  var editingId = (_this_state_editing = _this.state.editing) == null ? void 0 : _this_state_editing.id;
91823
92149
  if (!editingId || _this.isEventInsideOverlay(editingId, event)) {
91824
92150
  return;
@@ -91828,6 +92154,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91828
92154
  _this.exitEditing();
91829
92155
  };
91830
92156
  this.handleContainerMouseMove = function(event) {
92157
+ _this.scheduleActiveContentInteractionSync(event);
91831
92158
  var hoverShellInteractiveId = _this.getHoverShellInteractiveIdByEvent(event);
91832
92159
  if (_this.state.hoverShellInteractiveId === hoverShellInteractiveId) {
91833
92160
  return;
@@ -91841,7 +92168,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91841
92168
  _this.syncContentInteraction(hoverShellInteractiveId);
91842
92169
  }
91843
92170
  };
91844
- this.handleContainerMouseLeave = function() {
92171
+ this.handleContainerMouseLeave = function(event) {
92172
+ if (_this.isMouseLeaveWithinContainer(event)) {
92173
+ return;
92174
+ }
92175
+ if (_this.contentInteractionFrame !== undefined) {
92176
+ cancelHTMLOverlayFrame(_this.contentInteractionFrame);
92177
+ _this.contentInteractionFrame = undefined;
92178
+ }
92179
+ _this.pendingContentInteractionEvent = undefined;
92180
+ _this.setActiveContentInteraction(undefined);
91845
92181
  var previousId = _this.state.hoverShellInteractiveId;
91846
92182
  if (!previousId) {
91847
92183
  return;
@@ -91849,6 +92185,33 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91849
92185
  _this.state.hoverShellInteractiveId = undefined;
91850
92186
  _this.syncContentInteraction(previousId);
91851
92187
  };
92188
+ this.handleContainerContextMenu = function(event) {
92189
+ var activeInteraction = _this.state.activeContentInteraction;
92190
+ if (!activeInteraction || !_this.isEventInsideOverlay(activeInteraction.id, event) || _this.isHTMLContextMenuEvent(event)) {
92191
+ return;
92192
+ }
92193
+ var canvas = _this.options.getCanvasEventTarget == null ? void 0 : _this.options.getCanvasEventTarget.call(_this.options);
92194
+ if (!canvas) {
92195
+ return;
92196
+ }
92197
+ event.preventDefault();
92198
+ event.stopPropagation();
92199
+ _this.setActiveContentInteraction(undefined);
92200
+ canvas.dispatchEvent(new MouseEvent('contextmenu', {
92201
+ bubbles: true,
92202
+ cancelable: true,
92203
+ clientX: event.clientX,
92204
+ clientY: event.clientY,
92205
+ screenX: event.screenX,
92206
+ screenY: event.screenY,
92207
+ button: event.button,
92208
+ buttons: event.buttons,
92209
+ ctrlKey: event.ctrlKey,
92210
+ shiftKey: event.shiftKey,
92211
+ altKey: event.altKey,
92212
+ metaKey: event.metaKey
92213
+ }));
92214
+ };
91852
92215
  this.isAutoHeightMessage = isCardHTMLAutoHeightMessage;
91853
92216
  }
91854
92217
  var _proto = HTMLOverlayManager.prototype;
@@ -91862,7 +92225,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91862
92225
  layer.style.position = 'absolute';
91863
92226
  layer.style.inset = '0';
91864
92227
  layer.style.pointerEvents = 'none';
91865
- layer.style.zIndex = '1';
91866
92228
  container.appendChild(layer);
91867
92229
  this.state.layer = layer;
91868
92230
  this.initDOMEvents();
@@ -91872,25 +92234,41 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91872
92234
  _proto.dispose = function dispose() {
91873
92235
  var _this_state_layer;
91874
92236
  if (this.state.updateFrame !== undefined) {
91875
- cancelAnimationFrame(this.state.updateFrame);
92237
+ cancelHTMLOverlayFrame(this.state.updateFrame);
91876
92238
  this.state.updateFrame = undefined;
91877
92239
  }
92240
+ if (this.contentInteractionFrame !== undefined) {
92241
+ cancelHTMLOverlayFrame(this.contentInteractionFrame);
92242
+ this.contentInteractionFrame = undefined;
92243
+ }
92244
+ this.pendingContentInteractionEvent = undefined;
91878
92245
  this.state.cleanups.forEach(function(cleanup) {
91879
92246
  cleanup();
91880
92247
  });
91881
92248
  this.state.frameElements.clear();
91882
92249
  this.state.elements.clear();
92250
+ this.state.selectionElements.clear();
91883
92251
  this.state.contentScaleElements.clear();
91884
92252
  this.state.contentElements.clear();
91885
92253
  this.state.contentMountElements.clear();
92254
+ this.state.contentInteractionZones.clear();
92255
+ this.state.contentInteractionZoneCleanups.forEach(function(cleanup) {
92256
+ cleanup();
92257
+ });
92258
+ this.state.contentInteractionZoneCleanups.clear();
92259
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92260
+ cleanup();
92261
+ });
92262
+ this.state.contentInteractionResizeCleanups.clear();
91886
92263
  this.state.contents.clear();
91887
92264
  this.state.cleanups.clear();
92265
+ this.state.autoHeightModes.clear();
91888
92266
  this.state.autoHeightCleanups.forEach(function(cleanup) {
91889
92267
  cleanup();
91890
92268
  });
91891
92269
  this.state.autoHeightCleanups.clear();
91892
92270
  this.state.autoHeightFrames.forEach(function(frame) {
91893
- cancelAnimationFrame(frame);
92271
+ cancelHTMLOverlayFrame(frame);
91894
92272
  });
91895
92273
  this.state.autoHeightFrames.clear();
91896
92274
  this.eventCleanups.forEach(function(cleanup) {
@@ -91899,21 +92277,61 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91899
92277
  this.eventCleanups = [];
91900
92278
  (_this_state_layer = this.state.layer) == null ? void 0 : _this_state_layer.remove();
91901
92279
  this.state.layer = undefined;
92280
+ this.state.selectionLayer = undefined;
91902
92281
  this.options.container.removeEventListener('dblclick', this.handleContainerDoubleClick, true);
91903
92282
  this.options.container.removeEventListener('mousedown', this.handleContainerMouseDown, true);
91904
92283
  this.options.container.removeEventListener('mousemove', this.handleContainerMouseMove, true);
91905
92284
  this.options.container.removeEventListener('mouseleave', this.handleContainerMouseLeave, true);
92285
+ this.options.container.removeEventListener('contextmenu', this.handleContainerContextMenu, true);
91906
92286
  };
91907
92287
  _proto.scheduleRender = function scheduleRender() {
91908
92288
  var _this = this;
91909
92289
  if (this.state.updateFrame !== undefined) {
91910
- cancelAnimationFrame(this.state.updateFrame);
92290
+ cancelHTMLOverlayFrame(this.state.updateFrame);
91911
92291
  }
91912
- this.state.updateFrame = requestAnimationFrame(function() {
92292
+ this.state.updateFrame = requestHTMLOverlayFrame(function() {
91913
92293
  _this.state.updateFrame = undefined;
91914
92294
  _this.render();
91915
92295
  });
91916
92296
  };
92297
+ _proto.invalidateCardHTML = function invalidateCardHTML(id) {
92298
+ this.cleanupOverlayContent(id);
92299
+ this.invalidateContentInteractionZones(id);
92300
+ };
92301
+ _proto.getHtmlCardWindow = function getHtmlCardWindow(id) {
92302
+ var contentOverlay = this.state.contentElements.get(id);
92303
+ var iframe = contentOverlay == null ? void 0 : contentOverlay.querySelector('iframe');
92304
+ return iframe == null ? void 0 : iframe.contentWindow;
92305
+ };
92306
+ _proto.patchCardHTML = function patchCardHTML(id, patch) {
92307
+ var html = this.state.contents.get(id);
92308
+ if (!html) {
92309
+ return false;
92310
+ }
92311
+ var patchHandler = html.content.patch;
92312
+ if (!patchHandler) {
92313
+ return false;
92314
+ }
92315
+ var context = this.createPatchContext(id, html);
92316
+ return patchHandler(patch, context) !== false;
92317
+ };
92318
+ _proto.dispatchHtmlCardEvent = function dispatchHtmlCardEvent(id, type, detail) {
92319
+ var targetWindow = this.getHtmlCardWindow(id);
92320
+ try {
92321
+ if (!targetWindow || typeof targetWindow.postMessage !== 'function') {
92322
+ return false;
92323
+ }
92324
+ targetWindow.postMessage({
92325
+ detail: detail,
92326
+ payload: detail,
92327
+ source: CARD_HTML_EVENT_MESSAGE_SOURCE,
92328
+ type: type
92329
+ }, '*');
92330
+ return true;
92331
+ } catch (unused) {
92332
+ return false;
92333
+ }
92334
+ };
91917
92335
  _proto.rasterizeCard = function rasterizeCard(id, options) {
91918
92336
  return _async_to_generator(function() {
91919
92337
  var contentOverlay, capture, _ref, _options_pixelRatio, image, error;
@@ -91921,7 +92339,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91921
92339
  switch(_state.label){
91922
92340
  case 0:
91923
92341
  if (this.state.updateFrame !== undefined) {
91924
- cancelAnimationFrame(this.state.updateFrame);
92342
+ cancelHTMLOverlayFrame(this.state.updateFrame);
91925
92343
  this.state.updateFrame = undefined;
91926
92344
  }
91927
92345
  this.render();
@@ -92006,6 +92424,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92006
92424
  var events = [
92007
92425
  'pageDataChange',
92008
92426
  'selectedItemChange',
92427
+ 'preSelectedItemChange',
92009
92428
  'itemPropertyChange',
92010
92429
  'viewportTransform',
92011
92430
  'viewRebuildFinish'
@@ -92015,6 +92434,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92015
92434
  if (event === 'viewportTransform') {
92016
92435
  _this.handleViewportTransform();
92017
92436
  }
92437
+ _this.invalidateContentInteractionZones();
92018
92438
  _this.scheduleRender();
92019
92439
  });
92020
92440
  });
@@ -92024,6 +92444,33 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92024
92444
  this.options.container.addEventListener('mousedown', this.handleContainerMouseDown, true);
92025
92445
  this.options.container.addEventListener('mousemove', this.handleContainerMouseMove, true);
92026
92446
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92447
+ this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92448
+ };
92449
+ _proto.selectHTMLInteractionCard = function selectHTMLInteractionCard(event) {
92450
+ var decision = this.resolveHTMLInteractionTarget(event);
92451
+ if (decision.kind !== 'html') {
92452
+ return;
92453
+ }
92454
+ this.options.setSelectedItemIds([
92455
+ decision.interaction.id
92456
+ ]);
92457
+ };
92458
+ _proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
92459
+ var relatedTarget = event.relatedTarget;
92460
+ if (!relatedTarget) {
92461
+ return false;
92462
+ }
92463
+ try {
92464
+ return this.options.container.contains(relatedTarget);
92465
+ } catch (unused) {
92466
+ return false;
92467
+ }
92468
+ };
92469
+ _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92470
+ if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92471
+ return false;
92472
+ }
92473
+ return !!event.target.closest('[data-interaction-contextmenu="self"], [data-vvfx-html-contextmenu="self"]');
92027
92474
  };
92028
92475
  _proto.handleViewportTransform = function handleViewportTransform() {
92029
92476
  var editing = this.state.editing;
@@ -92043,11 +92490,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92043
92490
  }
92044
92491
  var items = this.options.getItems();
92045
92492
  var frameByChildId = this.renderFrameOverlays(items, layer);
92493
+ var selectionLayer = this.getOrCreateSelectionLayer(layer);
92046
92494
  var visibleCardIds = new Set();
92047
92495
  var editingVisible = false;
92048
92496
  items.forEach(function(item) {
92049
92497
  var _this_state_editing;
92050
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92498
+ if (!isCardItem(item) || !item.visible) {
92499
+ return;
92500
+ }
92501
+ var html = _this.options.resolveCardHTML(item);
92502
+ if (html === undefined) {
92051
92503
  return;
92052
92504
  }
92053
92505
  var itemBox = _this.options.getViewBoxById(item.id);
@@ -92062,21 +92514,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92062
92514
  var frameBox = frameId ? _this.options.getViewBoxById(frameId) : undefined;
92063
92515
  var overlay = _this.getOrCreateOverlay(item.id, parentOverlay, elements);
92064
92516
  var contentOverlay = _this.getOrCreateContentOverlay(item.id, overlay);
92065
- var html = item.html;
92066
- if (html && _this.state.contents.get(item.id) !== html) {
92067
- _this.renderOverlayHTML(item.id, contentOverlay, html);
92068
- }
92517
+ var selectionOverlay = _this.getOrCreateSelectionOverlay(item.id, selectionLayer);
92069
92518
  var offsetX = frameBox && !frameBox.isEmpty() ? frameBox.min.x : 0;
92070
92519
  var offsetY = frameBox && !frameBox.isEmpty() ? frameBox.min.y : 0;
92071
- var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY);
92520
+ var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, _this.isAutoScaleEnabled(item));
92521
+ _this.applyHTMLRootConfig(overlay, html);
92072
92522
  overlay.style.left = boxStyle.left;
92073
92523
  overlay.style.top = boxStyle.top;
92074
92524
  overlay.style.width = boxStyle.width;
92075
92525
  overlay.style.height = boxStyle.height;
92076
92526
  overlay.style.transform = boxStyle.transform;
92077
92527
  overlay.style.transformOrigin = '0 0';
92078
- _this.syncContentScale(item.id, item.property.width, item.property.height);
92079
- _this.syncAutoHeight(item.id, item.property.autoHeight === true);
92528
+ var selectionBoxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, 0, 0, _this.isAutoScaleEnabled(item));
92529
+ selectionOverlay.style.left = selectionBoxStyle.left;
92530
+ selectionOverlay.style.top = selectionBoxStyle.top;
92531
+ selectionOverlay.style.width = selectionBoxStyle.width;
92532
+ selectionOverlay.style.height = selectionBoxStyle.height;
92533
+ selectionOverlay.style.transform = selectionBoxStyle.transform;
92534
+ selectionOverlay.style.transformOrigin = '0 0';
92535
+ _this.applyHTMLRootConfig(selectionOverlay, html);
92536
+ _this.makeSelectionOverlayTransparent(selectionOverlay);
92537
+ _this.syncOverlaySelection(item.id, overlay, selectionOverlay);
92538
+ _this.syncContentScale(item.id, boxStyle.contentWidth, boxStyle.contentHeight);
92539
+ if (!_this.state.contents.has(item.id)) {
92540
+ _this.renderOverlayHTML(item.id, contentOverlay, html);
92541
+ }
92542
+ _this.syncAutoHeight(item.id, _this.isAutoHeightEnabled(item));
92080
92543
  _this.syncContentInteraction(item.id);
92081
92544
  });
92082
92545
  elements.forEach(function(_overlay, id) {
@@ -92115,6 +92578,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92115
92578
  }
92116
92579
  }
92117
92580
  syncElementStackOrder(layer, rootElements);
92581
+ if (this.state.selectionLayer) {
92582
+ this.state.selectionLayer.style.zIndex = "" + (rootElements.length + 1);
92583
+ }
92118
92584
  this.state.frameElements.forEach(function(frameOverlay, frameId) {
92119
92585
  var frameElements = [];
92120
92586
  for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
@@ -92130,6 +92596,28 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92130
92596
  syncElementStackOrder(frameOverlay, frameElements);
92131
92597
  });
92132
92598
  };
92599
+ _proto.getOrCreateSelectionLayer = function getOrCreateSelectionLayer(layer) {
92600
+ var _layer_ownerDocument;
92601
+ if (this.state.selectionLayer) {
92602
+ if (this.state.selectionLayer.parentElement !== layer) {
92603
+ layer.appendChild(this.state.selectionLayer);
92604
+ }
92605
+ return this.state.selectionLayer;
92606
+ }
92607
+ var ownerDocument = (_layer_ownerDocument = layer.ownerDocument) != null ? _layer_ownerDocument : typeof document === 'undefined' ? undefined : document;
92608
+ if (!ownerDocument) {
92609
+ return layer;
92610
+ }
92611
+ var selectionLayer = ownerDocument.createElement('div');
92612
+ selectionLayer.className = 'vvfx-card-html-overlay-selection-layer';
92613
+ selectionLayer.style.position = 'absolute';
92614
+ selectionLayer.style.inset = '0';
92615
+ selectionLayer.style.pointerEvents = 'none';
92616
+ selectionLayer.style.zIndex = '1';
92617
+ layer.appendChild(selectionLayer);
92618
+ this.state.selectionLayer = selectionLayer;
92619
+ return selectionLayer;
92620
+ };
92133
92621
  _proto.renderFrameOverlays = function renderFrameOverlays(items, layer) {
92134
92622
  var _this = this;
92135
92623
  var visibleFrameIds = new Set();
@@ -92194,6 +92682,41 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92194
92682
  elements.set(id, overlay);
92195
92683
  return overlay;
92196
92684
  };
92685
+ _proto.getOrCreateSelectionOverlay = function getOrCreateSelectionOverlay(id, parent) {
92686
+ var selectionOverlay = this.state.selectionElements.get(id);
92687
+ if (selectionOverlay) {
92688
+ if (selectionOverlay.parentElement !== parent) {
92689
+ parent.appendChild(selectionOverlay);
92690
+ }
92691
+ return selectionOverlay;
92692
+ }
92693
+ selectionOverlay = document.createElement('div');
92694
+ selectionOverlay.className = 'vvfx-card-html-overlay-selection';
92695
+ selectionOverlay.dataset.itemId = id;
92696
+ selectionOverlay.style.position = 'absolute';
92697
+ selectionOverlay.style.pointerEvents = 'none';
92698
+ selectionOverlay.style.zIndex = '1';
92699
+ parent.appendChild(selectionOverlay);
92700
+ this.state.selectionElements.set(id, selectionOverlay);
92701
+ return selectionOverlay;
92702
+ };
92703
+ _proto.syncOverlaySelection = function syncOverlaySelection(id, overlay, selectionOverlay) {
92704
+ var isSelected = this.options.getSelectedItemIds().includes(id);
92705
+ var isPreSelected = !isSelected && this.options.getPreSelectedItemId() === id;
92706
+ overlay.dataset.selected = isSelected ? 'true' : 'false';
92707
+ overlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92708
+ selectionOverlay.dataset.selected = isSelected ? 'true' : 'false';
92709
+ selectionOverlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92710
+ selectionOverlay.style.boxShadow = isSelected ? this.getSelectionBoxShadow() : isPreSelected ? this.getPreSelectionBoxShadow() : '';
92711
+ };
92712
+ _proto.getSelectionBoxShadow = function getSelectionBoxShadow() {
92713
+ var _this_options_getSelectionEdgeStyle = this.options.getSelectionEdgeStyle(), color = _this_options_getSelectionEdgeStyle.color, alpha = _this_options_getSelectionEdgeStyle.alpha, width = _this_options_getSelectionEdgeStyle.width;
92714
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92715
+ };
92716
+ _proto.getPreSelectionBoxShadow = function getPreSelectionBoxShadow() {
92717
+ var _this_options_getPreSelectionEdgeStyle = this.options.getPreSelectionEdgeStyle(), color = _this_options_getPreSelectionEdgeStyle.color, alpha = _this_options_getPreSelectionEdgeStyle.alpha, width = _this_options_getPreSelectionEdgeStyle.width;
92718
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92719
+ };
92197
92720
  _proto.getHTMLCardIdByEvent = function getHTMLCardIdByEvent(event) {
92198
92721
  var layer = this.state.layer;
92199
92722
  if (!layer) {
@@ -92203,7 +92726,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92203
92726
  var items = this.options.getItems();
92204
92727
  for(var i = items.length - 1; i >= 0; i--){
92205
92728
  var item = items[i];
92206
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92729
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92207
92730
  continue;
92208
92731
  }
92209
92732
  var box = this.options.getViewBoxById(item.id);
@@ -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);
@@ -92232,13 +92755,212 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92232
92755
  var contentOverlay = this.state.contentElements.get(item.id);
92233
92756
  var interactiveElements = contentOverlay ? Array.from(contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR)) : [];
92234
92757
  var isHoveringShellInteractive = interactiveElements.some(function(element) {
92235
- var rect = element.getBoundingClientRect();
92236
- return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
92758
+ return isMouseEventInsideRect(event, element.getBoundingClientRect());
92237
92759
  });
92238
92760
  return isHoveringShellInteractive ? item.id : undefined;
92239
92761
  }
92240
92762
  return undefined;
92241
92763
  };
92764
+ _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92765
+ var decision = this.resolveHTMLInteractionTarget(event);
92766
+ if (decision.kind === 'canvas' && this.shouldKeepActiveContentInteractionForFocusedElement()) {
92767
+ return;
92768
+ }
92769
+ this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
92770
+ };
92771
+ _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92772
+ var _this = this;
92773
+ if (typeof requestAnimationFrame !== 'function') {
92774
+ this.syncActiveContentInteraction(event);
92775
+ return;
92776
+ }
92777
+ this.pendingContentInteractionEvent = event;
92778
+ if (this.contentInteractionFrame !== undefined) {
92779
+ return;
92780
+ }
92781
+ try {
92782
+ this.contentInteractionFrame = requestAnimationFrame(function() {
92783
+ _this.contentInteractionFrame = undefined;
92784
+ var pendingEvent = _this.pendingContentInteractionEvent;
92785
+ _this.pendingContentInteractionEvent = undefined;
92786
+ if (pendingEvent) {
92787
+ _this.syncActiveContentInteraction(pendingEvent);
92788
+ }
92789
+ });
92790
+ } catch (unused) {
92791
+ this.contentInteractionFrame = undefined;
92792
+ this.pendingContentInteractionEvent = undefined;
92793
+ this.syncActiveContentInteraction(event);
92794
+ }
92795
+ };
92796
+ _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92797
+ var _this = this;
92798
+ var previous = this.state.activeContentInteraction;
92799
+ 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)) {
92800
+ return;
92801
+ }
92802
+ this.state.activeContentInteraction = zone;
92803
+ var changedIds = new Set();
92804
+ if (previous) {
92805
+ changedIds.add(previous.id);
92806
+ }
92807
+ if (zone) {
92808
+ changedIds.add(zone.id);
92809
+ }
92810
+ changedIds.forEach(function(id) {
92811
+ _this.syncContentInteraction(id);
92812
+ });
92813
+ };
92814
+ _proto.shouldKeepActiveContentInteractionForFocusedElement = function shouldKeepActiveContentInteractionForFocusedElement() {
92815
+ var activeInteraction = this.state.activeContentInteraction;
92816
+ if (!activeInteraction || typeof document === 'undefined') {
92817
+ return false;
92818
+ }
92819
+ var activeElement = document.activeElement;
92820
+ if (!activeElement || activeElement === document.body) {
92821
+ return false;
92822
+ }
92823
+ var interactionElement = activeInteraction.element;
92824
+ return interactionElement === activeElement || typeof interactionElement.contains === 'function' && interactionElement.contains(activeElement);
92825
+ };
92826
+ _proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
92827
+ var id = this.getHTMLCardIdByEvent(event);
92828
+ if (!id || this.isEditableCard(id)) {
92829
+ return {
92830
+ kind: 'canvas',
92831
+ id: id
92832
+ };
92833
+ }
92834
+ var contentOverlay = this.state.contentElements.get(id);
92835
+ if (!contentOverlay) {
92836
+ return {
92837
+ kind: 'canvas',
92838
+ id: id
92839
+ };
92840
+ }
92841
+ var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
92842
+ if (activeSubtree) {
92843
+ return {
92844
+ kind: 'html',
92845
+ interaction: activeSubtree
92846
+ };
92847
+ }
92848
+ var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
92849
+ return isMouseEventInsideRect(event, zone.rect);
92850
+ });
92851
+ var zone = this.resolveContentInteractionZone(matchedZones);
92852
+ if (zone) {
92853
+ return {
92854
+ kind: 'html',
92855
+ interaction: {
92856
+ id: id,
92857
+ element: zone.element,
92858
+ zone: zone.zone
92859
+ }
92860
+ };
92861
+ }
92862
+ return {
92863
+ kind: 'canvas',
92864
+ id: id
92865
+ };
92866
+ };
92867
+ _proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
92868
+ var activeInteraction = this.state.activeContentInteraction;
92869
+ if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
92870
+ return undefined;
92871
+ }
92872
+ var rect = activeInteraction.element.getBoundingClientRect();
92873
+ return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
92874
+ };
92875
+ _proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
92876
+ if (zones.length <= 1) {
92877
+ return zones[0];
92878
+ }
92879
+ var subtreeRoot = zones.find(function(candidate) {
92880
+ return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
92881
+ return zone.element !== candidate.element && candidate.element.contains(zone.element);
92882
+ });
92883
+ });
92884
+ return subtreeRoot != null ? subtreeRoot : zones[0];
92885
+ };
92886
+ _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92887
+ var _this = this;
92888
+ var cachedZones = this.state.contentInteractionZones.get(id);
92889
+ if (cachedZones) {
92890
+ return cachedZones;
92891
+ }
92892
+ var zones = Array.from(contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id))).filter(function(element) {
92893
+ return !_this.isContentInteractionDisabled(element);
92894
+ }).map(function(element) {
92895
+ return {
92896
+ element: element,
92897
+ rect: element.getBoundingClientRect(),
92898
+ zone: _this.getContentInteractionZoneMode(element)
92899
+ };
92900
+ });
92901
+ this.state.contentInteractionZones.set(id, zones);
92902
+ this.observeContentInteractionZoneResizes(id, zones);
92903
+ return zones;
92904
+ };
92905
+ _proto.getContentInteractiveSelector = function getContentInteractiveSelector(id) {
92906
+ var _ref;
92907
+ var _this_options_resolveCardTypeConfig_htmlInteractionSelectors, _this_options_resolveCardTypeConfig;
92908
+ var item = this.options.getItems().find(function(item) {
92909
+ return item.id === id;
92910
+ });
92911
+ if (!item) {
92912
+ return CONTENT_INTERACTIVE_SELECTOR;
92913
+ }
92914
+ 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 : [];
92915
+ if (selectors.length === 0) {
92916
+ return CONTENT_INTERACTIVE_SELECTOR;
92917
+ }
92918
+ return [].concat([
92919
+ CONTENT_INTERACTIVE_SELECTOR
92920
+ ], selectors).join(', ');
92921
+ };
92922
+ _proto.isContentInteractionDisabled = function isContentInteractionDisabled(element) {
92923
+ if (typeof element.closest !== 'function') {
92924
+ return false;
92925
+ }
92926
+ return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92927
+ };
92928
+ _proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
92929
+ var zone = element.dataset.vvfxHtmlInteractionZone;
92930
+ return zone === 'subtree' ? 'subtree' : 'self';
92931
+ };
92932
+ _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92933
+ if (id) {
92934
+ var _this_state_contentInteractionResizeCleanups_get;
92935
+ this.state.contentInteractionZones.delete(id);
92936
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92937
+ this.state.contentInteractionResizeCleanups.delete(id);
92938
+ return;
92939
+ }
92940
+ this.state.contentInteractionZones.clear();
92941
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92942
+ cleanup();
92943
+ });
92944
+ this.state.contentInteractionResizeCleanups.clear();
92945
+ };
92946
+ _proto.observeContentInteractionZoneResizes = function observeContentInteractionZoneResizes(id, zones) {
92947
+ var _this = this;
92948
+ var _this_state_contentInteractionResizeCleanups_get;
92949
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92950
+ this.state.contentInteractionResizeCleanups.delete(id);
92951
+ if (zones.length === 0 || typeof ResizeObserver !== 'function') {
92952
+ return;
92953
+ }
92954
+ var observer = new ResizeObserver(function() {
92955
+ _this.invalidateContentInteractionZones(id);
92956
+ });
92957
+ zones.forEach(function(zone) {
92958
+ observer.observe(zone.element);
92959
+ });
92960
+ this.state.contentInteractionResizeCleanups.set(id, function() {
92961
+ observer.disconnect();
92962
+ });
92963
+ };
92242
92964
  _proto.getLayerPoint = function getLayerPoint(event) {
92243
92965
  var rect = this.options.container.getBoundingClientRect();
92244
92966
  return {
@@ -92295,19 +93017,35 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92295
93017
  if (!scaleOverlay || !contentOverlay || width <= 0 || height <= 0) {
92296
93018
  return;
92297
93019
  }
92298
- scaleOverlay.style.width = "" + width + "px";
92299
- scaleOverlay.style.height = "" + height + "px";
93020
+ var nextWidth = "" + width + "px";
93021
+ var nextHeight = "" + height + "px";
93022
+ var sizeChanged = scaleOverlay.style.width !== nextWidth || scaleOverlay.style.height !== nextHeight;
93023
+ scaleOverlay.style.width = nextWidth;
93024
+ scaleOverlay.style.height = nextHeight;
92300
93025
  scaleOverlay.style.transform = 'none';
92301
- contentOverlay.style.width = "" + width + "px";
92302
- contentOverlay.style.height = "" + height + "px";
93026
+ contentOverlay.style.width = nextWidth;
93027
+ contentOverlay.style.height = nextHeight;
93028
+ if (sizeChanged && this.state.autoHeightModes.get(id) === 'message') {
93029
+ this.requestAutoHeightFromIframes(id, contentOverlay);
93030
+ }
93031
+ if (sizeChanged) {
93032
+ this.invalidateContentInteractionZones(id);
93033
+ }
93034
+ };
93035
+ _proto.requestAutoHeightFromIframes = function requestAutoHeightFromIframes(id, contentOverlay) {
93036
+ contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
93037
+ requestCardHTMLAutoHeight(iframe, id);
93038
+ });
92303
93039
  };
92304
93040
  _proto.syncContentInteraction = function syncContentInteraction(id) {
92305
- var _this_state_editing;
93041
+ var _this_state_editing, _this_state_activeContentInteraction;
92306
93042
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
93043
+ var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
92307
93044
  var overlay = this.state.elements.get(id);
92308
93045
  var scaleOverlay = this.state.contentScaleElements.get(id);
92309
93046
  var contentOverlay = this.state.contentElements.get(id);
92310
93047
  var contentMount = this.state.contentMountElements.get(id);
93048
+ var isInteractive = isEditing || !!activeInteraction;
92311
93049
  if (overlay) {
92312
93050
  overlay.dataset.editing = isEditing ? 'true' : 'false';
92313
93051
  overlay.style.pointerEvents = 'none';
@@ -92318,34 +93056,62 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92318
93056
  }
92319
93057
  if (contentOverlay) {
92320
93058
  contentOverlay.dataset.editing = isEditing ? 'true' : 'false';
92321
- contentOverlay.style.pointerEvents = 'none';
93059
+ contentOverlay.style.pointerEvents = isInteractive ? 'auto' : 'none';
92322
93060
  contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92323
- iframe.style.pointerEvents = isEditing ? 'auto' : 'none';
92324
- iframe.tabIndex = isEditing ? 0 : -1;
93061
+ var isActiveIframe = isEditing || (activeInteraction == null ? void 0 : activeInteraction.element) === iframe;
93062
+ iframe.style.pointerEvents = isActiveIframe ? 'auto' : 'none';
93063
+ iframe.tabIndex = isActiveIframe ? 0 : -1;
92325
93064
  });
92326
- this.syncShellInteraction(id, contentOverlay, isEditing);
93065
+ this.syncShellInteraction(id, contentOverlay, isInteractive);
93066
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
92327
93067
  }
92328
93068
  if (contentMount) {
92329
93069
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
92330
- contentMount.style.pointerEvents = isEditing ? 'auto' : 'none';
92331
- contentMount.inert = !isEditing;
92332
- if (isEditing) {
93070
+ contentMount.style.pointerEvents = isInteractive ? 'auto' : 'none';
93071
+ contentMount.inert = !isInteractive;
93072
+ if (isInteractive) {
92333
93073
  contentMount.removeAttribute('aria-hidden');
92334
93074
  } else {
92335
93075
  contentMount.setAttribute('aria-hidden', 'true');
92336
93076
  }
92337
93077
  }
92338
93078
  };
92339
- _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isEditing) {
93079
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
93080
+ var _this = this;
93081
+ var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
93082
+ contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
93083
+ if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
93084
+ _this.clearContentInteractionState(element);
93085
+ return;
93086
+ }
93087
+ if (!isInteractive) {
93088
+ _this.clearContentInteractionState(element);
93089
+ return;
93090
+ }
93091
+ if (_this.isContentInteractionDisabled(element)) {
93092
+ element.dataset.vvfxHtmlInteractionActive = 'false';
93093
+ element.style.pointerEvents = 'none';
93094
+ return;
93095
+ }
93096
+ var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
93097
+ element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
93098
+ element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
93099
+ });
93100
+ };
93101
+ _proto.clearContentInteractionState = function clearContentInteractionState(element) {
93102
+ delete element.dataset.vvfxHtmlInteractionActive;
93103
+ element.style.pointerEvents = '';
93104
+ };
93105
+ _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92340
93106
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92341
- var isShellInteractiveActive = isEditing || isHoveringShellInteractive;
93107
+ var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
92342
93108
  contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR).forEach(function(element) {
92343
93109
  element.dataset.vvfxHtmlShellInteractiveHover = isHoveringShellInteractive ? 'true' : 'false';
92344
93110
  element.dataset.vvfxHtmlShellInteractiveActive = isShellInteractiveActive ? 'true' : 'false';
92345
93111
  element.style.pointerEvents = isShellInteractiveActive ? 'auto' : 'none';
92346
93112
  });
92347
93113
  contentOverlay.querySelectorAll(EDITING_INTERACTIVE_SELECTOR).forEach(function(element) {
92348
- element.style.pointerEvents = isEditing ? 'auto' : 'none';
93114
+ element.style.pointerEvents = isInteractive ? 'auto' : 'none';
92349
93115
  });
92350
93116
  };
92351
93117
  _proto.enterEditing = function enterEditing(id) {
@@ -92353,6 +93119,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92353
93119
  if (((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id) {
92354
93120
  return;
92355
93121
  }
93122
+ if (!this.isEditableCard(id)) {
93123
+ return;
93124
+ }
92356
93125
  var box = this.options.getViewBoxById(id);
92357
93126
  if (box.isEmpty()) {
92358
93127
  return;
@@ -92396,6 +93165,13 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92396
93165
  this.options.setViewport(editing.restoreViewport);
92397
93166
  this.scheduleRender();
92398
93167
  };
93168
+ _proto.isEditableCard = function isEditableCard(id) {
93169
+ var _this_options_resolveCardTypeConfig;
93170
+ var item = this.options.getItems().find(function(item) {
93171
+ return item.id === id;
93172
+ });
93173
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.editable) !== false;
93174
+ };
92399
93175
  _proto.getEditingFitZoom = function getEditingFitZoom(box, currentZoom) {
92400
93176
  var viewportElement = this.options.container.parentElement;
92401
93177
  if (!viewportElement) {
@@ -92420,6 +93196,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92420
93196
  };
92421
93197
  _proto.renderOverlayHTML = function renderOverlayHTML(id, overlay, html) {
92422
93198
  this.cleanupOverlayContent(id);
93199
+ this.invalidateContentInteractionZones(id);
92423
93200
  overlay.innerHTML = '';
92424
93201
  var shell = mountHTMLShell(overlay, html.content, html.shell);
92425
93202
  var autoHeightMeasureElement = shell.contentContainer.isConnected ? shell.contentContainer : overlay;
@@ -92429,18 +93206,99 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92429
93206
  });
92430
93207
  var contentCleanup = this.renderOverlayContent(shell.contentContainer, html.content, {
92431
93208
  id: id,
92432
- autoHeight: isCardItem(item) && item.property.autoHeight === true
93209
+ autoHeight: this.isAutoHeightEnabled(item)
92433
93210
  });
93211
+ this.observeContentInteractionZones(id, shell.contentContainer);
92434
93212
  this.state.cleanups.set(id, function() {
92435
93213
  contentCleanup == null ? void 0 : contentCleanup();
92436
93214
  shell.cleanup == null ? void 0 : shell.cleanup.call(shell);
92437
93215
  });
92438
93216
  this.state.contents.set(id, html);
92439
93217
  };
93218
+ _proto.createPatchContext = function createPatchContext(id, html) {
93219
+ var _this = this;
93220
+ return {
93221
+ id: id,
93222
+ html: html,
93223
+ content: html.content,
93224
+ container: this.state.contentMountElements.get(id),
93225
+ contentWindow: this.getHtmlCardWindow(id),
93226
+ refresh: function refresh() {
93227
+ _this.invalidateCardHTML(id);
93228
+ _this.scheduleRender();
93229
+ }
93230
+ };
93231
+ };
93232
+ _proto.observeContentInteractionZones = function observeContentInteractionZones(id, contentContainer) {
93233
+ var _this = this;
93234
+ var _this_state_contentInteractionZoneCleanups_get;
93235
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
93236
+ this.state.contentInteractionZoneCleanups.delete(id);
93237
+ if (typeof MutationObserver !== 'function') {
93238
+ return;
93239
+ }
93240
+ var observer = new MutationObserver(function() {
93241
+ _this.invalidateContentInteractionZones(id);
93242
+ });
93243
+ observer.observe(contentContainer, {
93244
+ attributes: true,
93245
+ childList: true,
93246
+ subtree: true
93247
+ });
93248
+ this.state.contentInteractionZoneCleanups.set(id, function() {
93249
+ observer.disconnect();
93250
+ });
93251
+ };
93252
+ _proto.applyHTMLRootConfig = function applyHTMLRootConfig(root, html) {
93253
+ var _ref, _config_style;
93254
+ var _this_htmlRootConfigCleanups_get, _config_className;
93255
+ (_this_htmlRootConfigCleanups_get = this.htmlRootConfigCleanups.get(root)) == null ? void 0 : _this_htmlRootConfigCleanups_get();
93256
+ this.htmlRootConfigCleanups.delete(root);
93257
+ var config = html.root;
93258
+ if (!config) {
93259
+ return;
93260
+ }
93261
+ var classNames = (_ref = (_config_className = config.className) == null ? void 0 : _config_className.split(/\s+/).filter(Boolean)) != null ? _ref : [];
93262
+ var styleProperties = [];
93263
+ classNames.forEach(function(className) {
93264
+ root.classList.add(className);
93265
+ });
93266
+ Object.entries((_config_style = config.style) != null ? _config_style : {}).forEach(function(param) {
93267
+ var property = param[0], value = param[1];
93268
+ if (value === undefined) {
93269
+ return;
93270
+ }
93271
+ styleProperties.push(property);
93272
+ if (property.startsWith('--') || property.includes('-')) {
93273
+ root.style.setProperty(property, String(value));
93274
+ return;
93275
+ }
93276
+ root.style[property] = String(value);
93277
+ });
93278
+ this.htmlRootConfigCleanups.set(root, function() {
93279
+ classNames.forEach(function(className) {
93280
+ root.classList.remove(className);
93281
+ });
93282
+ styleProperties.forEach(function(property) {
93283
+ if (property.startsWith('--') || property.includes('-')) {
93284
+ root.style.removeProperty(property);
93285
+ return;
93286
+ }
93287
+ root.style[property] = '';
93288
+ });
93289
+ });
93290
+ };
93291
+ _proto.makeSelectionOverlayTransparent = function makeSelectionOverlayTransparent(selectionOverlay) {
93292
+ selectionOverlay.style.background = 'transparent';
93293
+ selectionOverlay.style.backgroundColor = 'transparent';
93294
+ };
92440
93295
  _proto.renderOverlayContent = function renderOverlayContent(overlay, content, options) {
92441
93296
  var _this = this;
92442
93297
  switch(content.kind){
92443
93298
  case 'inline':
93299
+ if (options == null ? void 0 : options.autoHeight) {
93300
+ this.state.autoHeightModes.set(options.id, 'message');
93301
+ }
92444
93302
  return this.chainCleanups(function() {
92445
93303
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92446
93304
  }, renderDocumentContent(overlay, {
@@ -92448,7 +93306,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92448
93306
  entry: 'index.html',
92449
93307
  files: {
92450
93308
  'index.html': content.html
92451
- }
93309
+ },
93310
+ allowAnchorNavigation: content.allowAnchorNavigation,
93311
+ sandbox: content.sandbox
92452
93312
  }, {
92453
93313
  autoHeightId: (options == null ? void 0 : options.autoHeight) ? options.id : undefined,
92454
93314
  onAutoHeight: (options == null ? void 0 : options.autoHeight) ? function(height) {
@@ -92457,6 +93317,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92457
93317
  }));
92458
93318
  case 'dom':
92459
93319
  {
93320
+ if (options == null ? void 0 : options.autoHeight) {
93321
+ this.state.autoHeightModes.set(options.id, 'measure');
93322
+ }
92460
93323
  if (content.target === 'iframe') {
92461
93324
  return renderDOMContentInIframe(overlay, content.render, content.cleanup);
92462
93325
  }
@@ -92466,6 +93329,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92466
93329
  } : undefined;
92467
93330
  }
92468
93331
  case 'document':
93332
+ if (options == null ? void 0 : options.autoHeight) {
93333
+ this.state.autoHeightModes.set(options.id, 'message');
93334
+ }
92469
93335
  return this.chainCleanups(function() {
92470
93336
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92471
93337
  }, renderDocumentContent(overlay, content, {
@@ -92493,6 +93359,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92493
93359
  };
92494
93360
  };
92495
93361
  _proto.cleanupOverlayContent = function cleanupOverlayContent(id) {
93362
+ var _this_state_contentInteractionZoneCleanups_get;
92496
93363
  var cleanup = this.state.cleanups.get(id);
92497
93364
  if (cleanup) {
92498
93365
  cleanup();
@@ -92500,13 +93367,19 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92500
93367
  }
92501
93368
  this.state.contents.delete(id);
92502
93369
  this.state.contentMountElements.delete(id);
93370
+ this.state.autoHeightModes.delete(id);
93371
+ this.invalidateContentInteractionZones(id);
93372
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
93373
+ this.state.contentInteractionZoneCleanups.delete(id);
92503
93374
  this.cleanupAutoHeight(id);
92504
93375
  };
92505
93376
  _proto.removeOverlay = function removeOverlay(id) {
92506
- var _this_state_elements_get;
93377
+ var _this_state_elements_get, _this_state_selectionElements_get;
92507
93378
  this.cleanupOverlayContent(id);
92508
93379
  (_this_state_elements_get = this.state.elements.get(id)) == null ? void 0 : _this_state_elements_get.remove();
93380
+ (_this_state_selectionElements_get = this.state.selectionElements.get(id)) == null ? void 0 : _this_state_selectionElements_get.remove();
92509
93381
  this.state.elements.delete(id);
93382
+ this.state.selectionElements.delete(id);
92510
93383
  this.state.contentScaleElements.delete(id);
92511
93384
  this.state.contentElements.delete(id);
92512
93385
  };
@@ -92515,11 +93388,27 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92515
93388
  this.cleanupAutoHeight(id);
92516
93389
  return;
92517
93390
  }
93391
+ this.ensureAutoHeightMode(id);
93392
+ if (this.state.autoHeightModes.get(id) === 'message') {
93393
+ this.cleanupAutoHeight(id);
93394
+ return;
93395
+ }
92518
93396
  if (!this.state.autoHeightCleanups.has(id)) {
92519
93397
  this.state.autoHeightCleanups.set(id, this.createAutoHeightObserver(id));
92520
93398
  }
92521
93399
  this.scheduleAutoHeightMeasure(id);
92522
93400
  };
93401
+ _proto.ensureAutoHeightMode = function ensureAutoHeightMode(id) {
93402
+ var _this_state_contents_get;
93403
+ if (this.state.autoHeightModes.has(id)) {
93404
+ return;
93405
+ }
93406
+ var content = (_this_state_contents_get = this.state.contents.get(id)) == null ? void 0 : _this_state_contents_get.content;
93407
+ if (!content) {
93408
+ return;
93409
+ }
93410
+ this.state.autoHeightModes.set(id, content.kind === 'inline' || content.kind === 'document' ? 'message' : 'measure');
93411
+ };
92523
93412
  _proto.createAutoHeightObserver = function createAutoHeightObserver(id) {
92524
93413
  var _this = this;
92525
93414
  var cleanupFns = [];
@@ -92597,7 +93486,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92597
93486
  if (this.state.autoHeightFrames.has(id)) {
92598
93487
  return;
92599
93488
  }
92600
- var frame = requestAnimationFrame(function() {
93489
+ var frame = requestHTMLOverlayFrame(function() {
92601
93490
  _this.state.autoHeightFrames.delete(id);
92602
93491
  _this.measureAutoHeight(id);
92603
93492
  });
@@ -92607,7 +93496,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92607
93496
  var item = this.options.getItems().find(function(candidate) {
92608
93497
  return candidate.id === id;
92609
93498
  });
92610
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93499
+ if (!this.isAutoHeightEnabled(item)) {
92611
93500
  this.cleanupAutoHeight(id);
92612
93501
  return;
92613
93502
  }
@@ -92626,7 +93515,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92626
93515
  }).filter(function(height) {
92627
93516
  return typeof height === 'number' && Number.isFinite(height) && height > 0;
92628
93517
  });
92629
- var childHeight = this.getChildrenNaturalHeight(element);
93518
+ var childHeight = this.getChildrenNaturalHeight(element, {
93519
+ includeIframes: iframeHeights.length === 0
93520
+ });
92630
93521
  var naturalHeight = (_Math = Math).max.apply(_Math, [].concat([
92631
93522
  childHeight
92632
93523
  ], iframeHeights));
@@ -92646,10 +93537,29 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92646
93537
  }
92647
93538
  return Math.max(documentElement.scrollHeight, (_ref = body == null ? void 0 : body.scrollHeight) != null ? _ref : 0);
92648
93539
  };
92649
- _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element) {
92650
- return Array.from(element.children).reduce(function(height, child) {
92651
- var childElement = child;
92652
- return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93540
+ _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element, options) {
93541
+ var _ref;
93542
+ var includeIframes = (_ref = options == null ? void 0 : options.includeIframes) != null ? _ref : true;
93543
+ return Array.from(element.childNodes).reduce(function(height, child) {
93544
+ var _child_textContent;
93545
+ if (child.nodeType === Node.ELEMENT_NODE) {
93546
+ var childElement = child;
93547
+ if (!includeIframes && childElement.tagName === 'IFRAME') {
93548
+ return height;
93549
+ }
93550
+ return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93551
+ }
93552
+ if (child.nodeType === Node.TEXT_NODE && ((_child_textContent = child.textContent) == null ? void 0 : _child_textContent.trim())) {
93553
+ var range = element.ownerDocument.createRange();
93554
+ range.selectNodeContents(child);
93555
+ var rects = Array.from(range.getClientRects());
93556
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
93557
+ range.detach();
93558
+ return rects.reduce(function(textHeight, rect) {
93559
+ return Math.max(textHeight, rect.bottom - element.getBoundingClientRect().top);
93560
+ }, height);
93561
+ }
93562
+ return height;
92653
93563
  }, 0);
92654
93564
  };
92655
93565
  _proto.cleanupAutoHeight = function cleanupAutoHeight(id) {
@@ -92660,7 +93570,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92660
93570
  }
92661
93571
  var frame = this.state.autoHeightFrames.get(id);
92662
93572
  if (frame !== undefined) {
92663
- cancelAnimationFrame(frame);
93573
+ cancelHTMLOverlayFrame(frame);
92664
93574
  this.state.autoHeightFrames.delete(id);
92665
93575
  }
92666
93576
  };
@@ -92668,14 +93578,59 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92668
93578
  var item = this.options.getItems().find(function(candidate) {
92669
93579
  return candidate.id === id;
92670
93580
  });
92671
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93581
+ if (!isCardItem(item) || !this.isAutoHeightEnabled(item)) {
93582
+ return;
93583
+ }
93584
+ if (!Number.isFinite(height) || height <= 0) {
92672
93585
  return;
92673
93586
  }
92674
- if (!Number.isFinite(height) || height <= 0 || Math.abs(height - item.property.height) <= AUTO_HEIGHT_EPSILON) {
93587
+ var nextHeight = Math.ceil(this.getAutoHeightItemHeight(item, height));
93588
+ if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
92675
93589
  return;
92676
93590
  }
92677
- this.options.setCardItemHeight(id, Math.ceil(height));
93591
+ this.options.setCardItemHeight(id, nextHeight, {
93592
+ anchor: this.getAutoHeightAnchor(item),
93593
+ previousHeight: item.property.height
93594
+ });
93595
+ };
93596
+ _proto.getAutoHeightAnchor = function getAutoHeightAnchor(item) {
93597
+ var _ref;
93598
+ var _this_options_resolveCardTypeConfig;
93599
+ if (!isCardItem(item)) {
93600
+ return 'top';
93601
+ }
93602
+ return (_ref = (_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeightAnchor) != null ? _ref : 'top';
93603
+ };
93604
+ _proto.getAutoHeightItemHeight = function getAutoHeightItemHeight(item, contentHeight) {
93605
+ if (!isCardItem(item) || this.isAutoScaleEnabled(item)) {
93606
+ return contentHeight;
93607
+ }
93608
+ var scaleOverlay = this.state.contentScaleElements.get(item.id);
93609
+ var displayedHeight = scaleOverlay ? Number.parseFloat(scaleOverlay.style.height) : 0;
93610
+ if (!Number.isFinite(displayedHeight) || displayedHeight <= 0 || item.property.height <= 0) {
93611
+ return contentHeight;
93612
+ }
93613
+ return contentHeight / displayedHeight * item.property.height;
93614
+ };
93615
+ _proto.isAutoHeightEnabled = function isAutoHeightEnabled(item) {
93616
+ var _this_options_resolveCardTypeConfig;
93617
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeight) === true;
93618
+ };
93619
+ _proto.isAutoScaleEnabled = function isAutoScaleEnabled(item) {
93620
+ var _this_options_resolveCardTypeConfig;
93621
+ if (!isCardItem(item)) {
93622
+ return true;
93623
+ }
93624
+ return ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoScale) !== false;
92678
93625
  };
93626
+ _create_class(HTMLOverlayManager, [
93627
+ {
93628
+ key: "layerElement",
93629
+ get: function get() {
93630
+ return this.state.layer;
93631
+ }
93632
+ }
93633
+ ]);
92679
93634
  return HTMLOverlayManager;
92680
93635
  }();
92681
93636
  function waitForCardCaptureReady(root) {
@@ -92717,9 +93672,20 @@ function waitForCardCaptureReady(root) {
92717
93672
  });
92718
93673
  })();
92719
93674
  }
93675
+ function formatCssColor(color, alpha) {
93676
+ var normalizedColor = Math.max(0, Math.min(0xFFFFFF, Math.round(color)));
93677
+ var red = normalizedColor >> 16 & 0xFF;
93678
+ var green = normalizedColor >> 8 & 0xFF;
93679
+ var blue = normalizedColor & 0xFF;
93680
+ return "rgba(" + red + ", " + green + ", " + blue + ", " + formatCssNumber(alpha) + ")";
93681
+ }
93682
+ function formatCssNumber(value) {
93683
+ var normalized = Number.isFinite(value) ? value : 0;
93684
+ return Number(normalized.toFixed(6)).toString();
93685
+ }
92720
93686
  function nextAnimationFrame() {
92721
93687
  return new Promise(function(resolve) {
92722
- requestAnimationFrame(function() {
93688
+ requestHTMLOverlayFrame(function() {
92723
93689
  resolve();
92724
93690
  });
92725
93691
  });
@@ -93135,6 +94101,9 @@ function createFlattenedContent(target, frameStyle, ownerDocument) {
93135
94101
  });
93136
94102
  return replacement;
93137
94103
  }
94104
+ function isMouseEventInsideRect(event, rect) {
94105
+ return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
94106
+ }
93138
94107
  function createFlattenedIframeContent(iframe) {
93139
94108
  var doc = iframe.contentDocument;
93140
94109
  if (!doc) {
@@ -93174,6 +94143,19 @@ function withTimeout(promise, timeout) {
93174
94143
  });
93175
94144
  }
93176
94145
 
94146
+ function orderSDKCanvasLayers(param) {
94147
+ var container = param.container, playerContainer = param.playerContainer, htmlOverlayLayer = param.htmlOverlayLayer, gestureCanvas = param.gestureCanvas;
94148
+ [
94149
+ playerContainer,
94150
+ htmlOverlayLayer,
94151
+ gestureCanvas
94152
+ ].forEach(function(layer) {
94153
+ if ((layer == null ? void 0 : layer.parentElement) === container) {
94154
+ container.appendChild(layer);
94155
+ }
94156
+ });
94157
+ }
94158
+
93177
94159
  var HTML_CARD_EDITING_VIEWPORT_PADDING = 48;
93178
94160
  var SDK = /*#__PURE__*/ function() {
93179
94161
  function SDK(container, mode) {
@@ -93272,16 +94254,72 @@ var SDK = /*#__PURE__*/ function() {
93272
94254
  bottom: HTML_CARD_EDITING_VIEWPORT_PADDING
93273
94255
  }, box);
93274
94256
  },
93275
- setCardItemHeight: function setCardItemHeight(id, height) {
94257
+ setCardItemHeight: function setCardItemHeight(id, height, options) {
94258
+ var item = _this.getSDKItem(id);
94259
+ if (!isCardItem(item) || options.anchor === 'center') {
94260
+ void _this.setItemProperty({
94261
+ itemId: id,
94262
+ type: SDKItemType.CARD,
94263
+ propertyName: 'height',
94264
+ propertyValue: height
94265
+ });
94266
+ return;
94267
+ }
94268
+ var _item_property_position = item.property.position, x = _item_property_position[0], y = _item_property_position[1];
94269
+ var deltaY = (height - options.previousHeight) / 2;
93276
94270
  void _this.setItemProperty({
93277
94271
  itemId: id,
93278
94272
  type: SDKItemType.CARD,
93279
- propertyName: 'height',
93280
- propertyValue: height
94273
+ property: {
94274
+ height: height,
94275
+ position: [
94276
+ x,
94277
+ y + deltaY
94278
+ ]
94279
+ }
93281
94280
  });
94281
+ },
94282
+ getSelectedItemIds: function getSelectedItemIds() {
94283
+ var _ref;
94284
+ var _this__pageData;
94285
+ return (_ref = (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.selectedItems) != null ? _ref : [];
94286
+ },
94287
+ setSelectedItemIds: function setSelectedItemIds(ids) {
94288
+ _this.setSelectedItems(ids);
94289
+ },
94290
+ getPreSelectedItemId: function getPreSelectedItemId() {
94291
+ var _this__pageData;
94292
+ return (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.preSelectedItem;
94293
+ },
94294
+ getSelectionEdgeStyle: function getSelectionEdgeStyle() {
94295
+ 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;
94296
+ return {
94297
+ color: wireframeColor,
94298
+ alpha: wireframeAlpha,
94299
+ width: wireframeWidth
94300
+ };
94301
+ },
94302
+ getPreSelectionEdgeStyle: function getPreSelectionEdgeStyle() {
94303
+ var _SDK_config_gestureHandlerConfig_selectorGizmoConfig = SDK.config.gestureHandlerConfig.selectorGizmoConfig, preSelectedColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedColor, preSelectedWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedWidth;
94304
+ return {
94305
+ color: preSelectedColor,
94306
+ alpha: 1,
94307
+ width: preSelectedWidth
94308
+ };
94309
+ },
94310
+ getCanvasEventTarget: function getCanvasEventTarget() {
94311
+ var _this__gestureHandler;
94312
+ return (_this__gestureHandler = _this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view;
94313
+ },
94314
+ resolveCardHTML: function resolveCardHTML(item) {
94315
+ return isCardItem(item) ? _this.resolveCardHTML(item) : undefined;
94316
+ },
94317
+ resolveCardTypeConfig: function resolveCardTypeConfig(item) {
94318
+ return isCardItem(item) ? _this.resolveCardTypeConfig(item) : undefined;
93282
94319
  }
93283
94320
  });
93284
94321
  this._htmlOverlayManager.attach();
94322
+ this.syncCanvasLayerOrder();
93285
94323
  }
93286
94324
  var _proto = SDK.prototype;
93287
94325
  _proto.dispose = function dispose() {
@@ -93301,18 +94339,22 @@ var SDK = /*#__PURE__*/ function() {
93301
94339
  _proto.initPlayer = function initPlayer(mode) {
93302
94340
  var _this = this;
93303
94341
  var playerContainer = document.createElement('div');
93304
- var _ref = mode === 'editor' ? [
93305
- this._container.clientWidth,
93306
- this._container.clientHeight
93307
- ] : [
94342
+ var _ref = mode === 'template' ? [
93308
94343
  this._container.offsetWidth,
93309
94344
  this._container.offsetHeight
94345
+ ] : [
94346
+ document.documentElement.clientWidth,
94347
+ document.documentElement.clientHeight
93310
94348
  ], width = _ref[0], height = _ref[1];
93311
94349
  this._playerContainer = playerContainer;
93312
94350
  this._playerContainer.id = 'player-container';
93313
94351
  this._playerContainer.style.position = 'absolute';
93314
94352
  this._playerContainer.style.width = "" + width + "px";
93315
94353
  this._playerContainer.style.height = "" + height + "px";
94354
+ if (mode === 'editor') {
94355
+ this._playerContainer.style.left = '0px';
94356
+ this._playerContainer.style.top = '0px';
94357
+ }
93316
94358
  this._container.appendChild(playerContainer);
93317
94359
  this.player = new Player({
93318
94360
  container: this._playerContainer,
@@ -93371,18 +94413,48 @@ var SDK = /*#__PURE__*/ function() {
93371
94413
  _this._gestureHandler.dispose();
93372
94414
  setTimeout(function() {
93373
94415
  return _async_to_generator(function() {
94416
+ var itemExtension, _this_pageData, _this_pageData1, createInfos;
93374
94417
  return _ts_generator(this, function(_state) {
93375
94418
  switch(_state.label){
93376
94419
  case 0:
93377
94420
  this.initPlayer(SDK.config.mode);
93378
94421
  this._pageDataUtils = new PageDataUtils(this.player, this._playerContainer, this._eventEmitter, this);
93379
94422
  this._gestureHandler = new GestureHandler(this._container);
94423
+ this.syncCanvasLayerOrder();
94424
+ itemExtension = {};
94425
+ if (!(SDK.config.mode === 'template')) return [
94426
+ 3,
94427
+ 2
94428
+ ];
94429
+ (_this_pageData = this.pageData) == null ? void 0 : _this_pageData.items.forEach(function(item) {
94430
+ itemExtension[item.id] = item.getAllExtension();
94431
+ });
93380
94432
  return [
93381
94433
  4,
93382
94434
  this.runByPageData(this.pageData)
93383
94435
  ];
93384
94436
  case 1:
93385
94437
  _state.sent();
94438
+ (_this_pageData1 = this.pageData) == null ? void 0 : _this_pageData1.items.forEach(function(item) {
94439
+ var extension = itemExtension[item.id];
94440
+ if (extension) {
94441
+ item.setExtensions(extension);
94442
+ }
94443
+ });
94444
+ return [
94445
+ 3,
94446
+ 4
94447
+ ];
94448
+ case 2:
94449
+ createInfos = this.getItemCreateInfos();
94450
+ return [
94451
+ 4,
94452
+ this.runByCreateInfos(createInfos)
94453
+ ];
94454
+ case 3:
94455
+ _state.sent();
94456
+ _state.label = 4;
94457
+ case 4:
93386
94458
  this._eventEmitter.emit('viewRebuildFinish');
93387
94459
  return [
93388
94460
  2
@@ -93426,6 +94498,16 @@ var SDK = /*#__PURE__*/ function() {
93426
94498
  env: 'editor'
93427
94499
  });
93428
94500
  this.player.resize();
94501
+ this.syncCanvasLayerOrder();
94502
+ };
94503
+ _proto.syncCanvasLayerOrder = function syncCanvasLayerOrder() {
94504
+ var _this__htmlOverlayManager, _this__gestureHandler;
94505
+ orderSDKCanvasLayers({
94506
+ container: this._container,
94507
+ playerContainer: this._playerContainer,
94508
+ htmlOverlayLayer: (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.layerElement,
94509
+ gestureCanvas: (_this__gestureHandler = this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view
94510
+ });
93429
94511
  };
93430
94512
  _proto.getInitParam = function getInitParam(param) {
93431
94513
  return _async_to_generator(function() {
@@ -94222,6 +95304,55 @@ var SDK = /*#__PURE__*/ function() {
94222
95304
  });
94223
95305
  }).call(this);
94224
95306
  };
95307
+ _proto.runByCreateInfos = function runByCreateInfos(createInfos) {
95308
+ return _async_to_generator(function() {
95309
+ var _this__pageData_activeData_view, _this__pageData_activeData_view1, viewSize, scene, targetViewProperty;
95310
+ return _ts_generator(this, function(_state) {
95311
+ switch(_state.label){
95312
+ case 0:
95313
+ assertExist$1(this._pageData, 'You must call SDK#run() first');
95314
+ this._pageData.property.zoom = 1;
95315
+ this._pageData.property.translation = [
95316
+ 0,
95317
+ 0
95318
+ ];
95319
+ this._pageDataUtils.init();
95320
+ return [
95321
+ 4,
95322
+ this._gestureHandler.init(this._pageDataUtils, this._eventEmitter)
95323
+ ];
95324
+ case 1:
95325
+ _state.sent();
95326
+ viewSize = [
95327
+ this._playerContainer.offsetWidth,
95328
+ this._playerContainer.offsetHeight
95329
+ ];
95330
+ scene = getBasicScene(viewSize);
95331
+ targetViewProperty = this.getViewProperty((_this__pageData_activeData_view = this._pageData.activeData.view) != null ? _this__pageData_activeData_view : 0);
95332
+ if (targetViewProperty) {
95333
+ targetViewProperty.scene = scene;
95334
+ }
95335
+ return [
95336
+ 4,
95337
+ this._pageDataUtils.loadScene((_this__pageData_activeData_view1 = this._pageData.activeData.view) != null ? _this__pageData_activeData_view1 : 0)
95338
+ ];
95339
+ case 2:
95340
+ _state.sent();
95341
+ return [
95342
+ 4,
95343
+ this.addItemByCreateInfos(createInfos)
95344
+ ];
95345
+ case 3:
95346
+ _state.sent();
95347
+ this._pageDataUtils.refreshPageTime(this._pageData.time);
95348
+ this._eventEmitter.emit('pageDataChange', this.pageData);
95349
+ return [
95350
+ 2
95351
+ ];
95352
+ }
95353
+ });
95354
+ }).call(this);
95355
+ };
94225
95356
  _proto.reloadPageDataByScene = function reloadPageDataByScene(scene) {
94226
95357
  return _async_to_generator(function() {
94227
95358
  var _ref, _this__pageData_activeData_view, _ref1, _ref2, _loadScene_compositions_find, _this_player_getCompositions_, _this_player_getCompositions_1, loadScene, response, error;
@@ -94520,8 +95651,7 @@ var SDK = /*#__PURE__*/ function() {
94520
95651
  * @param ignoreClamp 是否忽视约束
94521
95652
  */ _proto.setPageZoom = function setPageZoom(zoom, center, ignoreClamp) {
94522
95653
  assertExist$1(this._pageData);
94523
- this._pageData.property.zoom = zoom;
94524
- this._pageDataUtils.setPageZoom(this._pageData.property.zoom, center, ignoreClamp);
95654
+ this._pageDataUtils.setPageZoom(zoom, center, ignoreClamp);
94525
95655
  this._gestureHandler.render();
94526
95656
  };
94527
95657
  /**
@@ -94761,7 +95891,7 @@ var SDK = /*#__PURE__*/ function() {
94761
95891
  };
94762
95892
  /**
94763
95893
  * @description 设置蒙版工具模式
94764
- * @param mode 模式类型:'paint' 表示涂抹,'erase' 表示擦除
95894
+ * @param mode 模式类型:'paint' 笔刷涂抹、'erase' 笔刷逐笔擦除、'box-erase' 框选擦除、'box-paint' 框选涂抹
94765
95895
  */ _proto.setMaskGizmoMode = function setMaskGizmoMode(mode) {
94766
95896
  this._gestureHandler.setMaskGizmoMode(mode);
94767
95897
  };
@@ -94917,7 +96047,11 @@ var SDK = /*#__PURE__*/ function() {
94917
96047
  return item.id;
94918
96048
  })) != null ? _ref : [];
94919
96049
  ids.forEach(function(id) {
94920
- var createInfo = _this._pageDataUtils.getItemCreateInfo(id, true);
96050
+ var _this__pageDataUtils_getItemCreateInfo;
96051
+ var _this_pageData_items_find, _this_pageData;
96052
+ 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) {
96053
+ return item.id === id;
96054
+ })) == null ? void 0 : _this_pageData_items_find.toCreateInfo(true);
94921
96055
  if (createInfo) {
94922
96056
  createInfos.push(createInfo);
94923
96057
  }
@@ -95417,6 +96551,76 @@ var SDK = /*#__PURE__*/ function() {
95417
96551
  });
95418
96552
  };
95419
96553
  /**
96554
+ * @description 按 cardType 从注册表解析卡片的 HTML 渲染配置。
96555
+ * @param item 卡片元素
96556
+ * @returns HTML 渲染配置
96557
+ */ _proto.resolveCardHTML = function resolveCardHTML(item) {
96558
+ var _cardTypeConfig_html;
96559
+ var cardTypeConfig = this.resolveCardTypeConfig(item);
96560
+ return cardTypeConfig == null ? void 0 : (_cardTypeConfig_html = cardTypeConfig.html) == null ? void 0 : _cardTypeConfig_html.call(cardTypeConfig, item);
96561
+ };
96562
+ /**
96563
+ * @description 按 cardType 从注册表解析卡片类型配置。
96564
+ * @param item 卡片元素
96565
+ * @returns 卡片类型配置
96566
+ */ _proto.resolveCardTypeConfig = function resolveCardTypeConfig(item) {
96567
+ return SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96568
+ return t.type === item.cardType;
96569
+ });
96570
+ };
96571
+ /**
96572
+ * @description 重新解析并挂载指定卡片的 HTML 内容。
96573
+ * @description 当 inline/document 内容依赖 extension 或外部状态变化时,可调用此方法刷新 DOM。
96574
+ * @param id 卡片元素 ID
96575
+ * @returns 是否成功触发刷新
96576
+ */ _proto.refreshCardHTML = function refreshCardHTML(id) {
96577
+ var _this__htmlOverlayManager, _this__htmlOverlayManager1;
96578
+ var item = this.getSDKItem(id);
96579
+ if (!isCardItem(item)) {
96580
+ console.warn('CardItem "' + id + '" not found.');
96581
+ return false;
96582
+ }
96583
+ if (!this.resolveCardHTML(item)) {
96584
+ console.warn('CardItem "' + id + '" has no registered HTML renderer.');
96585
+ return false;
96586
+ }
96587
+ (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.invalidateCardHTML(id);
96588
+ (_this__htmlOverlayManager1 = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager1.scheduleRender();
96589
+ return true;
96590
+ };
96591
+ /**
96592
+ * @description 获取指定 HTML 卡片当前 iframe 的 window。
96593
+ * @description 仅 inline/document 或自行渲染 iframe 的 DOM 内容会返回 window。
96594
+ * @param id 卡片元素 ID
96595
+ * @returns HTML iframe window
96596
+ */ _proto.getHtmlCardWindow = function getHtmlCardWindow(id) {
96597
+ var _this__htmlOverlayManager;
96598
+ return (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.getHtmlCardWindow(id);
96599
+ };
96600
+ /**
96601
+ * @description 向指定 HTML 卡片发送增量 patch。
96602
+ * @description 当卡片内容配置了 CardHTMLPatchHandler 时,可用于局部更新 HTML,而不必整卡 refresh。
96603
+ * @param id 卡片元素 ID
96604
+ * @param patch patch 负载,由卡片内容自己的 patch handler 解释
96605
+ * @returns 是否被 patch handler 处理
96606
+ */ _proto.patchCardHTML = function patchCardHTML(id, patch) {
96607
+ var _ref;
96608
+ var _this__htmlOverlayManager;
96609
+ return (_ref = (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.patchCardHTML(id, patch)) != null ? _ref : false;
96610
+ };
96611
+ /**
96612
+ * @description 向指定 HTML 卡片 iframe 派发事件。
96613
+ * @description 通过 postMessage 投递事件,跨源/同源行为一致,消息 source 为 vvfx-card-html-event。
96614
+ * @param id 卡片元素 ID
96615
+ * @param type 事件名称
96616
+ * @param detail 事件 detail
96617
+ * @returns 是否成功派发或投递
96618
+ */ _proto.dispatchHtmlCardEvent = function dispatchHtmlCardEvent(id, type, detail) {
96619
+ var _ref;
96620
+ var _this__htmlOverlayManager;
96621
+ return (_ref = (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.dispatchHtmlCardEvent(id, type, detail)) != null ? _ref : false;
96622
+ };
96623
+ /**
95420
96624
  * @description 创建卡片元素
95421
96625
  * @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
95422
96626
  * @param createInfo 卡片创建信息
@@ -95711,8 +96915,8 @@ SDK.config = BaseConfig;
95711
96915
  _inherits(CardItem, BaseItem);
95712
96916
  function CardItem(options) {
95713
96917
  var _this;
95714
- var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
95715
- var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5, _SDK_config_itemConfig_cardConfig_cardTypes_, _options_property6, _options_property7;
96918
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
96919
+ var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5;
95716
96920
  _this = BaseItem.call(this, options) || this, /**
95717
96921
  * @description 元素类型
95718
96922
  */ _this.type = SDKItemType.CARD;
@@ -95733,9 +96937,7 @@ SDK.config = BaseConfig;
95733
96937
  1,
95734
96938
  1
95735
96939
  ],
95736
- 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 : '',
95737
- autoHeight: (_options_property6 = options.property) == null ? void 0 : _options_property6.autoHeight,
95738
- html: (_options_property7 = options.property) == null ? void 0 : _options_property7.html
96940
+ cardType: (_ref5 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref5 : 'unknown'
95739
96941
  };
95740
96942
  return _this;
95741
96943
  }
@@ -95746,22 +96948,18 @@ SDK.config = BaseConfig;
95746
96948
  * @param withParent 是否包含父节点ID
95747
96949
  */ _proto.toCreateInfo = function toCreateInfo(withParent) {
95748
96950
  var extension = this.getAllExtension();
95749
- var property = deepClone(this.property);
95750
- property.html = this.html;
95751
96951
  return {
95752
96952
  type: SDKItemType.CARD,
95753
96953
  id: this.id,
95754
96954
  name: this.name,
95755
96955
  parentId: withParent ? this.parentId : undefined,
95756
96956
  extension: Object.keys(extension).length > 0 ? extension : undefined,
95757
- property: property
96957
+ property: deepClone(this.property)
95758
96958
  };
95759
96959
  };
95760
96960
  /**
95761
96961
  * @description 克隆 SDKItem
95762
96962
  */ _proto.clone = function clone() {
95763
- var property = deepClone(this.property);
95764
- property.html = this.html;
95765
96963
  return new CardItem({
95766
96964
  id: generateGUID(),
95767
96965
  name: this.name,
@@ -95771,7 +96969,7 @@ SDK.config = BaseConfig;
95771
96969
  endBehavior: this.endBehavior,
95772
96970
  isLocked: this.isLocked,
95773
96971
  isCoreEditable: this.isCoreEditable,
95774
- property: property,
96972
+ property: deepClone(this.property),
95775
96973
  extension: this.getAllExtension()
95776
96974
  });
95777
96975
  };
@@ -95788,17 +96986,6 @@ SDK.config = BaseConfig;
95788
96986
  this.property.cardType = value;
95789
96987
  }
95790
96988
  },
95791
- {
95792
- key: "html",
95793
- get: /**
95794
- * @description HTML 覆盖层配置
95795
- */ function get() {
95796
- return this.property.html;
95797
- },
95798
- set: function set(value) {
95799
- this.property.html = value;
95800
- }
95801
- },
95802
96989
  {
95803
96990
  key: "position",
95804
96991
  get: // ==================== 便捷访问器 ====================
@@ -95811,6 +96998,16 @@ SDK.config = BaseConfig;
95811
96998
  this.property.position = value;
95812
96999
  }
95813
97000
  },
97001
+ {
97002
+ key: "isAutoScale",
97003
+ get: function get() {
97004
+ var _this = this;
97005
+ var config = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
97006
+ return t.type === _this.cardType;
97007
+ });
97008
+ return (config == null ? void 0 : config.autoScale) !== false;
97009
+ }
97010
+ },
95814
97011
  {
95815
97012
  key: "width",
95816
97013
  get: /**