@vvfx/sdk 0.2.2-beta.13 → 0.2.2-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.2-beta.13
6
+ * Version: v0.2.2-beta.17
7
7
  */
8
8
 
9
9
  'use strict';
@@ -60433,6 +60433,8 @@ var PageDataUtils = /*#__PURE__*/ function() {
60433
60433
  }
60434
60434
  }
60435
60435
  var isLocked = (_this_getSDKItem = this.getSDKItem(playerItem.getInstanceId())) == null ? void 0 : _this_getSDKItem.isLocked;
60436
+ // 优先通过 ID 查找现有 SDKItem,获取其 SDKItemType
60437
+ var existingSDKItem = this.getSDKItem(playerItem.getInstanceId());
60436
60438
  // 创建基础选项
60437
60439
  var baseOptions = {
60438
60440
  id: playerItem.getInstanceId(),
@@ -60444,12 +60446,11 @@ var PageDataUtils = /*#__PURE__*/ function() {
60444
60446
  endBehavior: playerItem.endBehavior,
60445
60447
  visible: isVisible,
60446
60448
  isLocked: isLocked,
60447
- isCoreEditable: isCoreEditable
60449
+ isCoreEditable: isCoreEditable,
60450
+ extension: existingSDKItem == null ? void 0 : existingSDKItem.extension
60448
60451
  };
60449
60452
  // 根据类型创建对应的 SDKItem 类实例
60450
60453
  var sdkItem;
60451
- // 优先通过 ID 查找现有 SDKItem,获取其 SDKItemType
60452
- var existingSDKItem = this.getSDKItem(playerItem.getInstanceId());
60453
60454
  // 如果找到了现有 SDKItem,根据 SDKItemType 创建
60454
60455
  // 将类型转换为 string 进行比较
60455
60456
  if ((existingSDKItem == null ? void 0 : existingSDKItem.type) === SDKItemType.GENERATOR) {
@@ -91709,6 +91710,17 @@ function withCardHTMLViewportStyle(html) {
91709
91710
  return "<!doctype html><html><head>" + viewportStyle + "</head><body>" + html + "</body></html>";
91710
91711
  }
91711
91712
 
91713
+ function withCardHTMLAnchorNavigationGuard(html, allowAnchorNavigation) {
91714
+ if (allowAnchorNavigation === true) {
91715
+ return html;
91716
+ }
91717
+ 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>";
91718
+ if (/<\/body>/i.test(html)) {
91719
+ return html.replace(/<\/body>/i, "" + script + "</body>");
91720
+ }
91721
+ return "" + html + script;
91722
+ }
91723
+
91712
91724
  function renderDocumentContent(overlay, content, options) {
91713
91725
  var _files_get;
91714
91726
  var iframe = document.createElement('iframe');
@@ -91727,7 +91739,7 @@ function renderDocumentContent(overlay, content, options) {
91727
91739
  iframe.setAttribute('sandbox', content.sandbox);
91728
91740
  }
91729
91741
  var entryHtml = (_files_get = files.get(entry)) != null ? _files_get : '';
91730
- iframe.srcdoc = withCardHTMLAutoHeightBridge(withCardHTMLViewportStyle(transformHTMLDocument(entry, entryHtml, createFileUrl)), options == null ? void 0 : options.autoHeightId);
91742
+ iframe.srcdoc = withCardHTMLAutoHeightBridge(withCardHTMLAnchorNavigationGuard(withCardHTMLViewportStyle(transformHTMLDocument(entry, entryHtml, createFileUrl)), content.allowAnchorNavigation), options == null ? void 0 : options.autoHeightId);
91731
91743
  overlay.appendChild(iframe);
91732
91744
  return function() {
91733
91745
  messageCleanup();
@@ -93106,7 +93118,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
93106
93118
  entry: 'index.html',
93107
93119
  files: {
93108
93120
  'index.html': content.html
93109
- }
93121
+ },
93122
+ allowAnchorNavigation: content.allowAnchorNavigation,
93123
+ sandbox: content.sandbox
93110
93124
  }, {
93111
93125
  autoHeightId: (options == null ? void 0 : options.autoHeight) ? options.id : undefined,
93112
93126
  onAutoHeight: (options == null ? void 0 : options.autoHeight) ? function(height) {
@@ -94134,18 +94148,22 @@ var SDK = /*#__PURE__*/ function() {
94134
94148
  _proto.initPlayer = function initPlayer(mode) {
94135
94149
  var _this = this;
94136
94150
  var playerContainer = document.createElement('div');
94137
- var _ref = mode === 'editor' ? [
94138
- this._container.clientWidth,
94139
- this._container.clientHeight
94140
- ] : [
94151
+ var _ref = mode === 'template' ? [
94141
94152
  this._container.offsetWidth,
94142
94153
  this._container.offsetHeight
94154
+ ] : [
94155
+ document.documentElement.clientWidth,
94156
+ document.documentElement.clientHeight
94143
94157
  ], width = _ref[0], height = _ref[1];
94144
94158
  this._playerContainer = playerContainer;
94145
94159
  this._playerContainer.id = 'player-container';
94146
94160
  this._playerContainer.style.position = 'absolute';
94147
94161
  this._playerContainer.style.width = "" + width + "px";
94148
94162
  this._playerContainer.style.height = "" + height + "px";
94163
+ if (mode === 'editor') {
94164
+ this._playerContainer.style.left = '0px';
94165
+ this._playerContainer.style.top = '0px';
94166
+ }
94149
94167
  this._container.appendChild(playerContainer);
94150
94168
  this.player = new EFFECTS.Player({
94151
94169
  container: this._playerContainer,
@@ -94204,6 +94222,7 @@ var SDK = /*#__PURE__*/ function() {
94204
94222
  _this._gestureHandler.dispose();
94205
94223
  setTimeout(function() {
94206
94224
  return _async_to_generator(function() {
94225
+ var itemExtension, _this_pageData, _this_pageData1, createInfos;
94207
94226
  return _ts_generator(this, function(_state) {
94208
94227
  switch(_state.label){
94209
94228
  case 0:
@@ -94211,12 +94230,40 @@ var SDK = /*#__PURE__*/ function() {
94211
94230
  this._pageDataUtils = new PageDataUtils(this.player, this._playerContainer, this._eventEmitter, this);
94212
94231
  this._gestureHandler = new GestureHandler(this._container);
94213
94232
  this.syncCanvasLayerOrder();
94233
+ itemExtension = {};
94234
+ if (!(SDK.config.mode === 'template')) return [
94235
+ 3,
94236
+ 2
94237
+ ];
94238
+ (_this_pageData = this.pageData) == null ? void 0 : _this_pageData.items.forEach(function(item) {
94239
+ itemExtension[item.id] = item.getAllExtension();
94240
+ });
94214
94241
  return [
94215
94242
  4,
94216
94243
  this.runByPageData(this.pageData)
94217
94244
  ];
94218
94245
  case 1:
94219
94246
  _state.sent();
94247
+ (_this_pageData1 = this.pageData) == null ? void 0 : _this_pageData1.items.forEach(function(item) {
94248
+ var extension = itemExtension[item.id];
94249
+ if (extension) {
94250
+ item.setExtensions(extension);
94251
+ }
94252
+ });
94253
+ return [
94254
+ 3,
94255
+ 4
94256
+ ];
94257
+ case 2:
94258
+ createInfos = this.getItemCreateInfos();
94259
+ return [
94260
+ 4,
94261
+ this.runByCreateInfos(createInfos)
94262
+ ];
94263
+ case 3:
94264
+ _state.sent();
94265
+ _state.label = 4;
94266
+ case 4:
94220
94267
  this._eventEmitter.emit('viewRebuildFinish');
94221
94268
  return [
94222
94269
  2
@@ -95066,6 +95113,55 @@ var SDK = /*#__PURE__*/ function() {
95066
95113
  });
95067
95114
  }).call(this);
95068
95115
  };
95116
+ _proto.runByCreateInfos = function runByCreateInfos(createInfos) {
95117
+ return _async_to_generator(function() {
95118
+ var _this__pageData_activeData_view, _this__pageData_activeData_view1, viewSize, scene, targetViewProperty;
95119
+ return _ts_generator(this, function(_state) {
95120
+ switch(_state.label){
95121
+ case 0:
95122
+ EFFECTS.assertExist(this._pageData, 'You must call SDK#run() first');
95123
+ this._pageData.property.zoom = 1;
95124
+ this._pageData.property.translation = [
95125
+ 0,
95126
+ 0
95127
+ ];
95128
+ this._pageDataUtils.init();
95129
+ return [
95130
+ 4,
95131
+ this._gestureHandler.init(this._pageDataUtils, this._eventEmitter)
95132
+ ];
95133
+ case 1:
95134
+ _state.sent();
95135
+ viewSize = [
95136
+ this._playerContainer.offsetWidth,
95137
+ this._playerContainer.offsetHeight
95138
+ ];
95139
+ scene = getBasicScene(viewSize);
95140
+ targetViewProperty = this.getViewProperty((_this__pageData_activeData_view = this._pageData.activeData.view) != null ? _this__pageData_activeData_view : 0);
95141
+ if (targetViewProperty) {
95142
+ targetViewProperty.scene = scene;
95143
+ }
95144
+ return [
95145
+ 4,
95146
+ this._pageDataUtils.loadScene((_this__pageData_activeData_view1 = this._pageData.activeData.view) != null ? _this__pageData_activeData_view1 : 0)
95147
+ ];
95148
+ case 2:
95149
+ _state.sent();
95150
+ return [
95151
+ 4,
95152
+ this.addItemByCreateInfos(createInfos)
95153
+ ];
95154
+ case 3:
95155
+ _state.sent();
95156
+ this._pageDataUtils.refreshPageTime(this._pageData.time);
95157
+ this._eventEmitter.emit('pageDataChange', this.pageData);
95158
+ return [
95159
+ 2
95160
+ ];
95161
+ }
95162
+ });
95163
+ }).call(this);
95164
+ };
95069
95165
  _proto.reloadPageDataByScene = function reloadPageDataByScene(scene) {
95070
95166
  return _async_to_generator(function() {
95071
95167
  var _ref, _this__pageData_activeData_view, _ref1, _ref2, _loadScene_compositions_find, _this_player_getCompositions_, _this_player_getCompositions_1, loadScene, response, error;
@@ -95760,7 +95856,11 @@ var SDK = /*#__PURE__*/ function() {
95760
95856
  return item.id;
95761
95857
  })) != null ? _ref : [];
95762
95858
  ids.forEach(function(id) {
95763
- var createInfo = _this._pageDataUtils.getItemCreateInfo(id, true);
95859
+ var _this__pageDataUtils_getItemCreateInfo;
95860
+ var _this_pageData_items_find, _this_pageData;
95861
+ 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) {
95862
+ return item.id === id;
95863
+ })) == null ? void 0 : _this_pageData_items_find.toCreateInfo(true);
95764
95864
  if (createInfo) {
95765
95865
  createInfos.push(createInfo);
95766
95866
  }