@vvfx/sdk 0.2.6 → 0.2.8
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/html-overlay/html-capture-runtime.d.ts +12 -0
- package/dist/index.cjs +473 -214
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +474 -215
- package/dist/index.js.map +1 -1
- package/dist/sdk-item/types.d.ts +1 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Description: TODO
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 赤芍,何即,不择,意绮
|
|
6
|
-
* Version: v0.2.
|
|
6
|
+
* Version: v0.2.8
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { math, spec, generateGUID, SpriteComponent, TextComponent, assertExist as assertExist$1, version, VFXItem, PrecompositionManager, AssetManager, FrameComponent, glContext, CompositionComponent, Texture as Texture$1, getStandardJSON, EffectComponent, Geometry as Geometry$1, Material, Player, EventEmitter as EventEmitter$1 } from '@galacean/effects';
|
|
10
10
|
export { generateGUID, spec } from '@galacean/effects';
|
|
11
11
|
import { RichTextComponent } from '@galacean/effects-plugin-rich-text';
|
|
12
12
|
import { Vector2 as Vector2$1, Color } from '@galacean/effects-plugin-model';
|
|
@@ -29,12 +29,6 @@ import { parse, resolve as resolve$2, format } from 'url';
|
|
|
29
29
|
SDKItemType["CARD"] = "card";
|
|
30
30
|
return SDKItemType;
|
|
31
31
|
}({});
|
|
32
|
-
var _obj$2;
|
|
33
|
-
/**
|
|
34
|
-
* @description SDKItemType 与 spec.ItemType 的映射关系
|
|
35
|
-
*/ (_obj$2 = {}, _obj$2["sprite"] = spec.ItemType.sprite, _obj$2["text"] = spec.ItemType.text, _obj$2["video"] = spec.ItemType.video, _obj$2["group"] = spec.ItemType.null, _obj$2["effects"] = spec.ItemType.composition, _obj$2["frame"] = spec.ItemType.composition, // generator 在底层以 sprite 形式渲染
|
|
36
|
-
_obj$2["generator"] = spec.ItemType.sprite, // card 在底层以 sprite 形式渲染
|
|
37
|
-
_obj$2["card"] = spec.ItemType.sprite, _obj$2);
|
|
38
32
|
|
|
39
33
|
function _defineProperties(target, props) {
|
|
40
34
|
for(var i = 0; i < props.length; i++){
|
|
@@ -69952,6 +69946,442 @@ function syncElementStackOrder(_container, elements) {
|
|
|
69952
69946
|
});
|
|
69953
69947
|
}
|
|
69954
69948
|
|
|
69949
|
+
var CAPTURE_TIMEOUT = 5000;
|
|
69950
|
+
var MOTION_PROPERTIES = /^(animation|transition)(?:-|$)/i;
|
|
69951
|
+
var RUNTIME_SELECTOR = [
|
|
69952
|
+
'[data-hm-stream-runtime]',
|
|
69953
|
+
'[data-vvfx-card-html-auto-height]',
|
|
69954
|
+
'[data-vvfx-card-html-anchor-navigation-guard]',
|
|
69955
|
+
'script',
|
|
69956
|
+
'noscript',
|
|
69957
|
+
'template'
|
|
69958
|
+
].join(',');
|
|
69959
|
+
function captureViewportSize(logicalSize, _displayedBounds) {
|
|
69960
|
+
return {
|
|
69961
|
+
width: Math.max(1, logicalSize.width),
|
|
69962
|
+
height: Math.max(1, logicalSize.height)
|
|
69963
|
+
};
|
|
69964
|
+
}
|
|
69965
|
+
function serializeComputedCaptureStyle(style) {
|
|
69966
|
+
var declarations = [];
|
|
69967
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(style), _step; !(_step = _iterator()).done;){
|
|
69968
|
+
var property = _step.value;
|
|
69969
|
+
if (MOTION_PROPERTIES.test(property)) {
|
|
69970
|
+
continue;
|
|
69971
|
+
}
|
|
69972
|
+
var value = style.getPropertyValue(property);
|
|
69973
|
+
if (!value) {
|
|
69974
|
+
continue;
|
|
69975
|
+
}
|
|
69976
|
+
var priority = style.getPropertyPriority(property);
|
|
69977
|
+
declarations.push(property + ":" + value + (priority ? "!" + priority : ''));
|
|
69978
|
+
}
|
|
69979
|
+
declarations.push('animation:none!important', 'transition:none!important');
|
|
69980
|
+
return declarations.join(';');
|
|
69981
|
+
}
|
|
69982
|
+
function createHTMLCaptureReplica(ownerDocument, html, logicalSize) {
|
|
69983
|
+
return _async_to_generator(function() {
|
|
69984
|
+
var size, iframe, loaded, sourceDocument, replica;
|
|
69985
|
+
return _ts_generator(this, function(_state) {
|
|
69986
|
+
switch(_state.label){
|
|
69987
|
+
case 0:
|
|
69988
|
+
size = captureViewportSize(logicalSize);
|
|
69989
|
+
iframe = ownerDocument.createElement('iframe');
|
|
69990
|
+
Object.assign(iframe.style, {
|
|
69991
|
+
position: 'fixed',
|
|
69992
|
+
left: '-100000px',
|
|
69993
|
+
top: '0',
|
|
69994
|
+
width: "" + size.width + "px",
|
|
69995
|
+
height: "" + size.height + "px",
|
|
69996
|
+
border: '0',
|
|
69997
|
+
pointerEvents: 'none',
|
|
69998
|
+
opacity: '1',
|
|
69999
|
+
zIndex: '-1'
|
|
70000
|
+
});
|
|
70001
|
+
iframe.srcdoc = html;
|
|
70002
|
+
loaded = waitForNextLoad(iframe);
|
|
70003
|
+
ownerDocument.body.appendChild(iframe);
|
|
70004
|
+
return [
|
|
70005
|
+
4,
|
|
70006
|
+
withCaptureTimeout(loaded)
|
|
70007
|
+
];
|
|
70008
|
+
case 1:
|
|
70009
|
+
_state.sent();
|
|
70010
|
+
sourceDocument = iframe.contentDocument;
|
|
70011
|
+
if (!(sourceDocument == null ? void 0 : sourceDocument.documentElement) || !sourceDocument.body) {
|
|
70012
|
+
iframe.remove();
|
|
70013
|
+
return [
|
|
70014
|
+
2,
|
|
70015
|
+
undefined
|
|
70016
|
+
];
|
|
70017
|
+
}
|
|
70018
|
+
return [
|
|
70019
|
+
4,
|
|
70020
|
+
createHTMLCaptureReplicaFromDocument(ownerDocument, sourceDocument, size)
|
|
70021
|
+
];
|
|
70022
|
+
case 2:
|
|
70023
|
+
replica = _state.sent();
|
|
70024
|
+
if (!replica) {
|
|
70025
|
+
iframe.remove();
|
|
70026
|
+
return [
|
|
70027
|
+
2,
|
|
70028
|
+
undefined
|
|
70029
|
+
];
|
|
70030
|
+
}
|
|
70031
|
+
return [
|
|
70032
|
+
2,
|
|
70033
|
+
{
|
|
70034
|
+
target: replica.target,
|
|
70035
|
+
cleanup: function cleanup() {
|
|
70036
|
+
replica.cleanup();
|
|
70037
|
+
iframe.remove();
|
|
70038
|
+
}
|
|
70039
|
+
}
|
|
70040
|
+
];
|
|
70041
|
+
}
|
|
70042
|
+
});
|
|
70043
|
+
})();
|
|
70044
|
+
}
|
|
70045
|
+
function createHTMLCaptureReplicaFromDocument(ownerDocument, sourceDocument, logicalSize) {
|
|
70046
|
+
return _async_to_generator(function() {
|
|
70047
|
+
var target;
|
|
70048
|
+
return _ts_generator(this, function(_state) {
|
|
70049
|
+
switch(_state.label){
|
|
70050
|
+
case 0:
|
|
70051
|
+
if (!sourceDocument.documentElement || !sourceDocument.body || !sourceDocument.defaultView) {
|
|
70052
|
+
return [
|
|
70053
|
+
2,
|
|
70054
|
+
undefined
|
|
70055
|
+
];
|
|
70056
|
+
}
|
|
70057
|
+
return [
|
|
70058
|
+
4,
|
|
70059
|
+
withCaptureTimeout(waitForCaptureReady(sourceDocument))
|
|
70060
|
+
];
|
|
70061
|
+
case 1:
|
|
70062
|
+
_state.sent();
|
|
70063
|
+
target = createComputedCaptureTarget(ownerDocument, sourceDocument, captureViewportSize(logicalSize));
|
|
70064
|
+
return [
|
|
70065
|
+
2,
|
|
70066
|
+
{
|
|
70067
|
+
target: target,
|
|
70068
|
+
cleanup: function cleanup() {
|
|
70069
|
+
target.remove();
|
|
70070
|
+
}
|
|
70071
|
+
}
|
|
70072
|
+
];
|
|
70073
|
+
}
|
|
70074
|
+
});
|
|
70075
|
+
})();
|
|
70076
|
+
}
|
|
70077
|
+
function createComputedCaptureTarget(ownerDocument, sourceDocument, size) {
|
|
70078
|
+
var sourceWindow = sourceDocument.defaultView;
|
|
70079
|
+
if (!sourceWindow) {
|
|
70080
|
+
throw new Error('HTML capture replica has no window');
|
|
70081
|
+
}
|
|
70082
|
+
var frame = ownerDocument.createElement('div');
|
|
70083
|
+
frame.setAttribute('data-vvfx-html-capture-replica', 'true');
|
|
70084
|
+
frame.style.cssText = serializeComputedCaptureStyle(sourceWindow.getComputedStyle(sourceDocument.documentElement));
|
|
70085
|
+
Object.assign(frame.style, {
|
|
70086
|
+
position: 'fixed',
|
|
70087
|
+
left: '-100000px',
|
|
70088
|
+
top: '0',
|
|
70089
|
+
width: "" + size.width + "px",
|
|
70090
|
+
height: "" + size.height + "px",
|
|
70091
|
+
overflow: 'hidden',
|
|
70092
|
+
pointerEvents: 'none',
|
|
70093
|
+
opacity: '1',
|
|
70094
|
+
zIndex: '-1',
|
|
70095
|
+
transform: 'none'
|
|
70096
|
+
});
|
|
70097
|
+
appendDocumentFontSurface(frame, sourceDocument, ownerDocument);
|
|
70098
|
+
var sourceBody = sourceDocument.body;
|
|
70099
|
+
var bodyClone = sourceBody.cloneNode(true);
|
|
70100
|
+
bodyClone.querySelectorAll(RUNTIME_SELECTOR).forEach(function(node) {
|
|
70101
|
+
node.remove();
|
|
70102
|
+
});
|
|
70103
|
+
if (bodyClone.matches(RUNTIME_SELECTOR)) {
|
|
70104
|
+
bodyClone.replaceChildren();
|
|
70105
|
+
}
|
|
70106
|
+
frame.appendChild(bodyClone);
|
|
70107
|
+
ownerDocument.body.appendChild(frame);
|
|
70108
|
+
var sources = [].concat([
|
|
70109
|
+
sourceBody
|
|
70110
|
+
], Array.from(sourceBody.querySelectorAll('*'))).filter(isStylableElement).filter(function(node) {
|
|
70111
|
+
return !node.matches(RUNTIME_SELECTOR) && !node.closest(RUNTIME_SELECTOR);
|
|
70112
|
+
});
|
|
70113
|
+
var clones = [].concat([
|
|
70114
|
+
bodyClone
|
|
70115
|
+
], Array.from(bodyClone.querySelectorAll('*'))).filter(isStylableElement).filter(function(node) {
|
|
70116
|
+
return !node.matches(RUNTIME_SELECTOR) && !node.closest(RUNTIME_SELECTOR);
|
|
70117
|
+
});
|
|
70118
|
+
var pseudoRules = [];
|
|
70119
|
+
sources.forEach(function(source, index) {
|
|
70120
|
+
var clone = clones[index];
|
|
70121
|
+
if (!clone) {
|
|
70122
|
+
return;
|
|
70123
|
+
}
|
|
70124
|
+
clone.style.cssText = serializeComputedCaptureStyle(sourceWindow.getComputedStyle(source));
|
|
70125
|
+
freezeViewportPosition(source, clone, sourceWindow);
|
|
70126
|
+
preserveLiveElementState(source, clone, ownerDocument);
|
|
70127
|
+
appendPseudoRule(source, clone, sourceWindow, pseudoRules, index);
|
|
70128
|
+
});
|
|
70129
|
+
if (pseudoRules.length) {
|
|
70130
|
+
var style = ownerDocument.createElement('style');
|
|
70131
|
+
style.setAttribute('data-vvfx-html-capture-pseudo', 'true');
|
|
70132
|
+
style.textContent = pseudoRules.join('\n');
|
|
70133
|
+
frame.prepend(style);
|
|
70134
|
+
}
|
|
70135
|
+
return frame;
|
|
70136
|
+
}
|
|
70137
|
+
function appendDocumentFontSurface(frame, sourceDocument, ownerDocument) {
|
|
70138
|
+
var _sourceDocument_defaultView;
|
|
70139
|
+
var fontRules = [];
|
|
70140
|
+
var SourceCSSFontFaceRule = (_sourceDocument_defaultView = sourceDocument.defaultView) == null ? void 0 : _sourceDocument_defaultView.CSSFontFaceRule;
|
|
70141
|
+
Array.from(sourceDocument.styleSheets).forEach(function(sheet) {
|
|
70142
|
+
try {
|
|
70143
|
+
Array.from(sheet.cssRules).forEach(function(rule) {
|
|
70144
|
+
if (SourceCSSFontFaceRule && _instanceof(rule, SourceCSSFontFaceRule)) {
|
|
70145
|
+
fontRules.push(rule.cssText);
|
|
70146
|
+
}
|
|
70147
|
+
});
|
|
70148
|
+
} catch (unused) {
|
|
70149
|
+
// Cross-origin font stylesheets are already loaded in the replica but cannot be read.
|
|
70150
|
+
}
|
|
70151
|
+
});
|
|
70152
|
+
if (!fontRules.length) {
|
|
70153
|
+
return;
|
|
70154
|
+
}
|
|
70155
|
+
var style = ownerDocument.createElement('style');
|
|
70156
|
+
style.setAttribute('data-vvfx-html-capture-fonts', 'true');
|
|
70157
|
+
style.textContent = fontRules.join('\n');
|
|
70158
|
+
frame.appendChild(style);
|
|
70159
|
+
}
|
|
70160
|
+
function isStylableElement(element) {
|
|
70161
|
+
return 'style' in element;
|
|
70162
|
+
}
|
|
70163
|
+
function freezeViewportPosition(source, clone, sourceWindow) {
|
|
70164
|
+
if (sourceWindow.getComputedStyle(source).position !== 'fixed') {
|
|
70165
|
+
return;
|
|
70166
|
+
}
|
|
70167
|
+
var rect = source.getBoundingClientRect();
|
|
70168
|
+
Object.assign(clone.style, {
|
|
70169
|
+
position: 'absolute',
|
|
70170
|
+
left: "" + rect.left + "px",
|
|
70171
|
+
top: "" + rect.top + "px",
|
|
70172
|
+
right: 'auto',
|
|
70173
|
+
bottom: 'auto',
|
|
70174
|
+
width: "" + rect.width + "px",
|
|
70175
|
+
height: "" + rect.height + "px"
|
|
70176
|
+
});
|
|
70177
|
+
}
|
|
70178
|
+
function preserveLiveElementState(source, clone, ownerDocument) {
|
|
70179
|
+
if (_instanceof(source, source.ownerDocument.defaultView.HTMLImageElement) && _instanceof(clone, ownerDocument.defaultView.HTMLImageElement)) {
|
|
70180
|
+
clone.src = source.currentSrc || source.src;
|
|
70181
|
+
}
|
|
70182
|
+
if (_instanceof(source, source.ownerDocument.defaultView.HTMLInputElement) && _instanceof(clone, ownerDocument.defaultView.HTMLInputElement)) {
|
|
70183
|
+
clone.value = source.value;
|
|
70184
|
+
clone.checked = source.checked;
|
|
70185
|
+
}
|
|
70186
|
+
if (_instanceof(source, source.ownerDocument.defaultView.HTMLTextAreaElement) && _instanceof(clone, ownerDocument.defaultView.HTMLTextAreaElement)) {
|
|
70187
|
+
clone.value = source.value;
|
|
70188
|
+
clone.textContent = source.value;
|
|
70189
|
+
}
|
|
70190
|
+
if (_instanceof(source, source.ownerDocument.defaultView.HTMLCanvasElement) && _instanceof(clone, ownerDocument.defaultView.HTMLCanvasElement)) {
|
|
70191
|
+
clone.width = source.width;
|
|
70192
|
+
clone.height = source.height;
|
|
70193
|
+
try {
|
|
70194
|
+
var _clone_getContext;
|
|
70195
|
+
(_clone_getContext = clone.getContext('2d')) == null ? void 0 : _clone_getContext.drawImage(source, 0, 0);
|
|
70196
|
+
} catch (unused) {
|
|
70197
|
+
// Tainted canvases remain empty; snapdom cannot legally read them either.
|
|
70198
|
+
}
|
|
70199
|
+
}
|
|
70200
|
+
}
|
|
70201
|
+
function appendPseudoRule(source, clone, sourceWindow, rules, index) {
|
|
70202
|
+
var attribute = "capture-" + index;
|
|
70203
|
+
clone.setAttribute('data-vvfx-capture-node', attribute);
|
|
70204
|
+
[
|
|
70205
|
+
'::before',
|
|
70206
|
+
'::after'
|
|
70207
|
+
].forEach(function(pseudo) {
|
|
70208
|
+
var style = sourceWindow.getComputedStyle(source, pseudo);
|
|
70209
|
+
if (!style.content || style.content === 'none' || style.content === 'normal') {
|
|
70210
|
+
return;
|
|
70211
|
+
}
|
|
70212
|
+
rules.push('[data-vvfx-capture-node="' + attribute + '"]' + pseudo + "{" + serializeComputedCaptureStyle(style) + "}");
|
|
70213
|
+
});
|
|
70214
|
+
}
|
|
70215
|
+
function waitForCaptureReady(document) {
|
|
70216
|
+
return _async_to_generator(function() {
|
|
70217
|
+
var _document_fonts;
|
|
70218
|
+
return _ts_generator(this, function(_state) {
|
|
70219
|
+
switch(_state.label){
|
|
70220
|
+
case 0:
|
|
70221
|
+
return [
|
|
70222
|
+
4,
|
|
70223
|
+
(_document_fonts = document.fonts) == null ? void 0 : _document_fonts.ready
|
|
70224
|
+
];
|
|
70225
|
+
case 1:
|
|
70226
|
+
_state.sent();
|
|
70227
|
+
return [
|
|
70228
|
+
4,
|
|
70229
|
+
Promise.all(Array.from(document.images).map(function(image) {
|
|
70230
|
+
return _async_to_generator(function() {
|
|
70231
|
+
return _ts_generator(this, function(_state) {
|
|
70232
|
+
switch(_state.label){
|
|
70233
|
+
case 0:
|
|
70234
|
+
_state.trys.push([
|
|
70235
|
+
0,
|
|
70236
|
+
4,
|
|
70237
|
+
,
|
|
70238
|
+
5
|
|
70239
|
+
]);
|
|
70240
|
+
if (!!image.complete) return [
|
|
70241
|
+
3,
|
|
70242
|
+
2
|
|
70243
|
+
];
|
|
70244
|
+
return [
|
|
70245
|
+
4,
|
|
70246
|
+
new Promise(function(resolve) {
|
|
70247
|
+
image.addEventListener('load', function() {
|
|
70248
|
+
resolve();
|
|
70249
|
+
}, {
|
|
70250
|
+
once: true
|
|
70251
|
+
});
|
|
70252
|
+
image.addEventListener('error', function() {
|
|
70253
|
+
resolve();
|
|
70254
|
+
}, {
|
|
70255
|
+
once: true
|
|
70256
|
+
});
|
|
70257
|
+
})
|
|
70258
|
+
];
|
|
70259
|
+
case 1:
|
|
70260
|
+
_state.sent();
|
|
70261
|
+
_state.label = 2;
|
|
70262
|
+
case 2:
|
|
70263
|
+
return [
|
|
70264
|
+
4,
|
|
70265
|
+
image.decode == null ? void 0 : image.decode.call(image)
|
|
70266
|
+
];
|
|
70267
|
+
case 3:
|
|
70268
|
+
_state.sent();
|
|
70269
|
+
return [
|
|
70270
|
+
3,
|
|
70271
|
+
5
|
|
70272
|
+
];
|
|
70273
|
+
case 4:
|
|
70274
|
+
_state.sent();
|
|
70275
|
+
return [
|
|
70276
|
+
3,
|
|
70277
|
+
5
|
|
70278
|
+
];
|
|
70279
|
+
case 5:
|
|
70280
|
+
return [
|
|
70281
|
+
2
|
|
70282
|
+
];
|
|
70283
|
+
}
|
|
70284
|
+
});
|
|
70285
|
+
})();
|
|
70286
|
+
}))
|
|
70287
|
+
];
|
|
70288
|
+
case 2:
|
|
70289
|
+
_state.sent();
|
|
70290
|
+
return [
|
|
70291
|
+
4,
|
|
70292
|
+
waitForStableLayout(document)
|
|
70293
|
+
];
|
|
70294
|
+
case 3:
|
|
70295
|
+
_state.sent();
|
|
70296
|
+
return [
|
|
70297
|
+
2
|
|
70298
|
+
];
|
|
70299
|
+
}
|
|
70300
|
+
});
|
|
70301
|
+
})();
|
|
70302
|
+
}
|
|
70303
|
+
function waitForStableLayout(document) {
|
|
70304
|
+
return _async_to_generator(function() {
|
|
70305
|
+
var view, startedAt, previous, stableFrames, _ref, _ref1, _document_body, _document_body1, current;
|
|
70306
|
+
return _ts_generator(this, function(_state) {
|
|
70307
|
+
switch(_state.label){
|
|
70308
|
+
case 0:
|
|
70309
|
+
view = document.defaultView;
|
|
70310
|
+
if (!view) {
|
|
70311
|
+
return [
|
|
70312
|
+
2
|
|
70313
|
+
];
|
|
70314
|
+
}
|
|
70315
|
+
startedAt = performance.now();
|
|
70316
|
+
previous = '';
|
|
70317
|
+
stableFrames = 0;
|
|
70318
|
+
_state.label = 1;
|
|
70319
|
+
case 1:
|
|
70320
|
+
if (!(performance.now() - startedAt < CAPTURE_TIMEOUT && stableFrames < 3)) return [
|
|
70321
|
+
3,
|
|
70322
|
+
3
|
|
70323
|
+
];
|
|
70324
|
+
return [
|
|
70325
|
+
4,
|
|
70326
|
+
new Promise(function(resolve) {
|
|
70327
|
+
return view.requestAnimationFrame(function() {
|
|
70328
|
+
resolve();
|
|
70329
|
+
});
|
|
70330
|
+
})
|
|
70331
|
+
];
|
|
70332
|
+
case 2:
|
|
70333
|
+
_state.sent();
|
|
70334
|
+
current = [
|
|
70335
|
+
document.documentElement.scrollWidth,
|
|
70336
|
+
document.documentElement.scrollHeight,
|
|
70337
|
+
(_ref = (_document_body = document.body) == null ? void 0 : _document_body.scrollWidth) != null ? _ref : 0,
|
|
70338
|
+
(_ref1 = (_document_body1 = document.body) == null ? void 0 : _document_body1.scrollHeight) != null ? _ref1 : 0,
|
|
70339
|
+
document.styleSheets.length,
|
|
70340
|
+
document.querySelectorAll('style').length
|
|
70341
|
+
].join(':');
|
|
70342
|
+
stableFrames = current === previous ? stableFrames + 1 : 0;
|
|
70343
|
+
previous = current;
|
|
70344
|
+
return [
|
|
70345
|
+
3,
|
|
70346
|
+
1
|
|
70347
|
+
];
|
|
70348
|
+
case 3:
|
|
70349
|
+
return [
|
|
70350
|
+
2
|
|
70351
|
+
];
|
|
70352
|
+
}
|
|
70353
|
+
});
|
|
70354
|
+
})();
|
|
70355
|
+
}
|
|
70356
|
+
function waitForNextLoad(iframe) {
|
|
70357
|
+
return new Promise(function(resolve) {
|
|
70358
|
+
iframe.addEventListener('load', function() {
|
|
70359
|
+
resolve();
|
|
70360
|
+
}, {
|
|
70361
|
+
once: true
|
|
70362
|
+
});
|
|
70363
|
+
iframe.addEventListener('error', function() {
|
|
70364
|
+
resolve();
|
|
70365
|
+
}, {
|
|
70366
|
+
once: true
|
|
70367
|
+
});
|
|
70368
|
+
});
|
|
70369
|
+
}
|
|
70370
|
+
function withCaptureTimeout(promise) {
|
|
70371
|
+
return new Promise(function(resolve) {
|
|
70372
|
+
var timer = globalThis.setTimeout(function() {
|
|
70373
|
+
resolve(undefined);
|
|
70374
|
+
}, CAPTURE_TIMEOUT);
|
|
70375
|
+
promise.then(function(value) {
|
|
70376
|
+
globalThis.clearTimeout(timer);
|
|
70377
|
+
resolve(value);
|
|
70378
|
+
}, function() {
|
|
70379
|
+
globalThis.clearTimeout(timer);
|
|
70380
|
+
resolve(undefined);
|
|
70381
|
+
});
|
|
70382
|
+
});
|
|
70383
|
+
}
|
|
70384
|
+
|
|
69955
70385
|
function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
|
|
69956
70386
|
if (offsetX === void 0) offsetX = 0;
|
|
69957
70387
|
if (offsetY === void 0) offsetY = 0;
|
|
@@ -70347,7 +70777,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
70347
70777
|
_state.sent();
|
|
70348
70778
|
return [
|
|
70349
70779
|
4,
|
|
70350
|
-
createCardCaptureTarget(contentOverlay, this.state.contents.get(id)
|
|
70780
|
+
createCardCaptureTarget(contentOverlay, this.state.contents.get(id), {
|
|
70781
|
+
width: options.width,
|
|
70782
|
+
height: options.height
|
|
70783
|
+
})
|
|
70351
70784
|
];
|
|
70352
70785
|
case 3:
|
|
70353
70786
|
capture = _state.sent();
|
|
@@ -70364,9 +70797,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
70364
70797
|
I.toPng(capture.target, _extends({
|
|
70365
70798
|
embedFonts: true,
|
|
70366
70799
|
backgroundColor: 'transparent',
|
|
70367
|
-
dpr: (_ref = (_options_pixelRatio = options.pixelRatio) != null ? _options_pixelRatio : window.devicePixelRatio) != null ? _ref : 2
|
|
70368
|
-
width: options.width,
|
|
70369
|
-
height: options.height
|
|
70800
|
+
dpr: (_ref = (_options_pixelRatio = options.pixelRatio) != null ? _options_pixelRatio : window.devicePixelRatio) != null ? _ref : 2
|
|
70370
70801
|
}, options.snapdomOptions))
|
|
70371
70802
|
];
|
|
70372
70803
|
case 5:
|
|
@@ -71809,52 +72240,56 @@ function waitForIframeLoad(iframe) {
|
|
|
71809
72240
|
});
|
|
71810
72241
|
});
|
|
71811
72242
|
}
|
|
71812
|
-
function createCardCaptureTarget(root, html) {
|
|
72243
|
+
function createCardCaptureTarget(root, html, logicalSize) {
|
|
71813
72244
|
return _async_to_generator(function() {
|
|
71814
|
-
var
|
|
72245
|
+
var _root_querySelector, liveDocument, liveReplica, previewHTML, preview, flattenedTarget;
|
|
71815
72246
|
return _ts_generator(this, function(_state) {
|
|
71816
72247
|
switch(_state.label){
|
|
71817
72248
|
case 0:
|
|
71818
|
-
|
|
71819
|
-
if (!
|
|
72249
|
+
liveDocument = (_root_querySelector = root.querySelector('iframe')) == null ? void 0 : _root_querySelector.contentDocument;
|
|
72250
|
+
if (!liveDocument) return [
|
|
71820
72251
|
3,
|
|
71821
72252
|
2
|
|
71822
72253
|
];
|
|
71823
72254
|
return [
|
|
71824
72255
|
4,
|
|
71825
|
-
|
|
72256
|
+
createHTMLCaptureReplicaFromDocument(root.ownerDocument, liveDocument, logicalSize)
|
|
71826
72257
|
];
|
|
71827
72258
|
case 1:
|
|
71828
|
-
|
|
71829
|
-
if (
|
|
71830
|
-
isDirectIframe = root.children.length === 1 && _instanceof(root.children[0], HTMLIFrameElement);
|
|
71831
|
-
if (isDirectIframe) {
|
|
71832
|
-
directTarget = createDirectCaptureTarget(root, preview.target);
|
|
71833
|
-
return [
|
|
71834
|
-
2,
|
|
71835
|
-
{
|
|
71836
|
-
target: directTarget,
|
|
71837
|
-
cleanup: function cleanup() {
|
|
71838
|
-
directTarget.remove();
|
|
71839
|
-
preview.cleanup();
|
|
71840
|
-
}
|
|
71841
|
-
}
|
|
71842
|
-
];
|
|
71843
|
-
}
|
|
71844
|
-
shellTarget = createShellCaptureTarget(root, preview.target);
|
|
72259
|
+
liveReplica = _state.sent();
|
|
72260
|
+
if (liveReplica) {
|
|
71845
72261
|
return [
|
|
71846
72262
|
2,
|
|
71847
72263
|
{
|
|
71848
|
-
target:
|
|
71849
|
-
cleanup:
|
|
71850
|
-
shellTarget.remove();
|
|
71851
|
-
preview.cleanup();
|
|
71852
|
-
}
|
|
72264
|
+
target: liveReplica.target,
|
|
72265
|
+
cleanup: liveReplica.cleanup
|
|
71853
72266
|
}
|
|
71854
72267
|
];
|
|
71855
72268
|
}
|
|
71856
72269
|
_state.label = 2;
|
|
71857
72270
|
case 2:
|
|
72271
|
+
previewHTML = createCardPreviewHTML(html == null ? void 0 : html.content);
|
|
72272
|
+
if (!previewHTML) return [
|
|
72273
|
+
3,
|
|
72274
|
+
4
|
|
72275
|
+
];
|
|
72276
|
+
return [
|
|
72277
|
+
4,
|
|
72278
|
+
createHTMLCaptureReplica(root.ownerDocument, previewHTML, logicalSize)
|
|
72279
|
+
];
|
|
72280
|
+
case 3:
|
|
72281
|
+
preview = _state.sent();
|
|
72282
|
+
if (preview) {
|
|
72283
|
+
return [
|
|
72284
|
+
2,
|
|
72285
|
+
{
|
|
72286
|
+
target: preview.target,
|
|
72287
|
+
cleanup: preview.cleanup
|
|
72288
|
+
}
|
|
72289
|
+
];
|
|
72290
|
+
}
|
|
72291
|
+
_state.label = 4;
|
|
72292
|
+
case 4:
|
|
71858
72293
|
flattenedTarget = createFlattenedExistingIframeTarget(root);
|
|
71859
72294
|
return [
|
|
71860
72295
|
2,
|
|
@@ -71912,182 +72347,6 @@ function createCardPreviewHTML(content) {
|
|
|
71912
72347
|
}
|
|
71913
72348
|
return undefined;
|
|
71914
72349
|
}
|
|
71915
|
-
function createPreviewDocumentCaptureTarget(root, html) {
|
|
71916
|
-
return _async_to_generator(function() {
|
|
71917
|
-
var _ref, iframe, rect, loadPromise, doc, target;
|
|
71918
|
-
return _ts_generator(this, function(_state) {
|
|
71919
|
-
switch(_state.label){
|
|
71920
|
-
case 0:
|
|
71921
|
-
iframe = root.ownerDocument.createElement('iframe');
|
|
71922
|
-
rect = root.getBoundingClientRect();
|
|
71923
|
-
iframe.style.position = 'fixed';
|
|
71924
|
-
iframe.style.left = '-100000px';
|
|
71925
|
-
iframe.style.top = '0';
|
|
71926
|
-
iframe.style.width = "" + Math.max(1, rect.width) + "px";
|
|
71927
|
-
iframe.style.height = "" + Math.max(1, rect.height) + "px";
|
|
71928
|
-
iframe.style.border = '0';
|
|
71929
|
-
iframe.style.pointerEvents = 'none';
|
|
71930
|
-
iframe.style.opacity = '1';
|
|
71931
|
-
iframe.style.zIndex = '-1';
|
|
71932
|
-
loadPromise = waitForNextIframeLoad(iframe);
|
|
71933
|
-
root.ownerDocument.body.appendChild(iframe);
|
|
71934
|
-
iframe.srcdoc = html;
|
|
71935
|
-
return [
|
|
71936
|
-
4,
|
|
71937
|
-
loadPromise
|
|
71938
|
-
];
|
|
71939
|
-
case 1:
|
|
71940
|
-
_state.sent();
|
|
71941
|
-
return [
|
|
71942
|
-
4,
|
|
71943
|
-
waitForIframeContent(iframe)
|
|
71944
|
-
];
|
|
71945
|
-
case 2:
|
|
71946
|
-
_state.sent();
|
|
71947
|
-
doc = iframe.contentDocument;
|
|
71948
|
-
target = (_ref = doc == null ? void 0 : doc.body) != null ? _ref : doc == null ? void 0 : doc.documentElement;
|
|
71949
|
-
if (!target) {
|
|
71950
|
-
iframe.remove();
|
|
71951
|
-
return [
|
|
71952
|
-
2,
|
|
71953
|
-
undefined
|
|
71954
|
-
];
|
|
71955
|
-
}
|
|
71956
|
-
return [
|
|
71957
|
-
4,
|
|
71958
|
-
waitForDocumentFonts(target.ownerDocument)
|
|
71959
|
-
];
|
|
71960
|
-
case 3:
|
|
71961
|
-
_state.sent();
|
|
71962
|
-
return [
|
|
71963
|
-
4,
|
|
71964
|
-
waitForImages(target)
|
|
71965
|
-
];
|
|
71966
|
-
case 4:
|
|
71967
|
-
_state.sent();
|
|
71968
|
-
return [
|
|
71969
|
-
4,
|
|
71970
|
-
nextAnimationFrame()
|
|
71971
|
-
];
|
|
71972
|
-
case 5:
|
|
71973
|
-
_state.sent();
|
|
71974
|
-
return [
|
|
71975
|
-
2,
|
|
71976
|
-
{
|
|
71977
|
-
target: target,
|
|
71978
|
-
cleanup: function cleanup() {
|
|
71979
|
-
iframe.remove();
|
|
71980
|
-
}
|
|
71981
|
-
}
|
|
71982
|
-
];
|
|
71983
|
-
}
|
|
71984
|
-
});
|
|
71985
|
-
})();
|
|
71986
|
-
}
|
|
71987
|
-
function waitForNextIframeLoad(iframe) {
|
|
71988
|
-
return new Promise(function(resolve) {
|
|
71989
|
-
iframe.addEventListener('load', function() {
|
|
71990
|
-
resolve();
|
|
71991
|
-
}, {
|
|
71992
|
-
once: true
|
|
71993
|
-
});
|
|
71994
|
-
iframe.addEventListener('error', function() {
|
|
71995
|
-
resolve();
|
|
71996
|
-
}, {
|
|
71997
|
-
once: true
|
|
71998
|
-
});
|
|
71999
|
-
});
|
|
72000
|
-
}
|
|
72001
|
-
function waitForIframeContent(iframe) {
|
|
72002
|
-
return _async_to_generator(function() {
|
|
72003
|
-
var start, doc;
|
|
72004
|
-
return _ts_generator(this, function(_state) {
|
|
72005
|
-
switch(_state.label){
|
|
72006
|
-
case 0:
|
|
72007
|
-
start = performance.now();
|
|
72008
|
-
_state.label = 1;
|
|
72009
|
-
case 1:
|
|
72010
|
-
if (!(performance.now() - start < CARD_RASTERIZE_READY_TIMEOUT)) return [
|
|
72011
|
-
3,
|
|
72012
|
-
3
|
|
72013
|
-
];
|
|
72014
|
-
doc = iframe.contentDocument;
|
|
72015
|
-
if ((doc == null ? void 0 : doc.body) && doc.body.children.length > 0) {
|
|
72016
|
-
return [
|
|
72017
|
-
2
|
|
72018
|
-
];
|
|
72019
|
-
}
|
|
72020
|
-
return [
|
|
72021
|
-
4,
|
|
72022
|
-
nextAnimationFrame()
|
|
72023
|
-
];
|
|
72024
|
-
case 2:
|
|
72025
|
-
_state.sent();
|
|
72026
|
-
return [
|
|
72027
|
-
3,
|
|
72028
|
-
1
|
|
72029
|
-
];
|
|
72030
|
-
case 3:
|
|
72031
|
-
return [
|
|
72032
|
-
2
|
|
72033
|
-
];
|
|
72034
|
-
}
|
|
72035
|
-
});
|
|
72036
|
-
})();
|
|
72037
|
-
}
|
|
72038
|
-
function createShellCaptureTarget(root, contentTarget) {
|
|
72039
|
-
var clone = root.cloneNode(true);
|
|
72040
|
-
clone.style.position = 'fixed';
|
|
72041
|
-
clone.style.left = '-100000px';
|
|
72042
|
-
clone.style.top = '0';
|
|
72043
|
-
clone.style.pointerEvents = 'none';
|
|
72044
|
-
clone.style.opacity = '1';
|
|
72045
|
-
clone.style.zIndex = '-1';
|
|
72046
|
-
var clonedIframe = clone.querySelector('iframe');
|
|
72047
|
-
if (clonedIframe) {
|
|
72048
|
-
clonedIframe.replaceWith(createFlattenedContent(contentTarget, getComputedStyle(clonedIframe), root.ownerDocument));
|
|
72049
|
-
}
|
|
72050
|
-
root.ownerDocument.body.appendChild(clone);
|
|
72051
|
-
return clone;
|
|
72052
|
-
}
|
|
72053
|
-
function createDirectCaptureTarget(root, contentTarget) {
|
|
72054
|
-
var rect = root.getBoundingClientRect();
|
|
72055
|
-
var frame = root.ownerDocument.createElement('div');
|
|
72056
|
-
frame.style.position = 'fixed';
|
|
72057
|
-
frame.style.left = '-100000px';
|
|
72058
|
-
frame.style.top = '0';
|
|
72059
|
-
frame.style.width = "" + Math.max(1, rect.width) + "px";
|
|
72060
|
-
frame.style.height = "" + Math.max(1, rect.height) + "px";
|
|
72061
|
-
frame.style.pointerEvents = 'none';
|
|
72062
|
-
frame.style.opacity = '1';
|
|
72063
|
-
frame.style.zIndex = '-1';
|
|
72064
|
-
frame.style.overflow = 'hidden';
|
|
72065
|
-
var flattenedContent = createFlattenedContent(contentTarget, getComputedStyle(contentTarget), root.ownerDocument);
|
|
72066
|
-
flattenedContent.style.width = '100%';
|
|
72067
|
-
flattenedContent.style.height = '100%';
|
|
72068
|
-
frame.appendChild(flattenedContent);
|
|
72069
|
-
root.ownerDocument.body.appendChild(frame);
|
|
72070
|
-
return frame;
|
|
72071
|
-
}
|
|
72072
|
-
function createFlattenedContent(target, frameStyle, ownerDocument) {
|
|
72073
|
-
var replacement = ownerDocument.createElement('div');
|
|
72074
|
-
Object.assign(replacement.style, {
|
|
72075
|
-
width: frameStyle.width,
|
|
72076
|
-
height: frameStyle.height,
|
|
72077
|
-
display: frameStyle.display === 'none' ? 'block' : frameStyle.display,
|
|
72078
|
-
overflow: 'hidden',
|
|
72079
|
-
border: frameStyle.border,
|
|
72080
|
-
boxSizing: frameStyle.boxSizing,
|
|
72081
|
-
background: frameStyle.background
|
|
72082
|
-
});
|
|
72083
|
-
Array.from(target.ownerDocument.head.children).forEach(function(child) {
|
|
72084
|
-
replacement.appendChild(child.cloneNode(true));
|
|
72085
|
-
});
|
|
72086
|
-
Array.from(target.children).forEach(function(child) {
|
|
72087
|
-
replacement.appendChild(child.cloneNode(true));
|
|
72088
|
-
});
|
|
72089
|
-
return replacement;
|
|
72090
|
-
}
|
|
72091
72350
|
function isMouseEventInsideRect(event, rect) {
|
|
72092
72351
|
return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
72093
72352
|
}
|