@vvfx/sdk 0.2.5 → 0.2.7
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/auto-height-runtime.d.ts +3 -0
- package/dist/html-overlay/html-capture-runtime.d.ts +12 -0
- package/dist/html-overlay/manager.d.ts +2 -1
- package/dist/index.cjs +530 -233
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +530 -233
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: TODO
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 赤芍,何即,不择,意绮
|
|
6
|
-
* Version: v0.2.
|
|
6
|
+
* Version: v0.2.7
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -69616,16 +69616,41 @@ function createAutoHeightMessageListener(iframe, options) {
|
|
|
69616
69616
|
};
|
|
69617
69617
|
}
|
|
69618
69618
|
var handleMessage = function handleMessage(event) {
|
|
69619
|
-
if (event.source !== iframe.contentWindow
|
|
69619
|
+
if (event.source !== iframe.contentWindow) {
|
|
69620
69620
|
return;
|
|
69621
69621
|
}
|
|
69622
|
-
|
|
69622
|
+
if (isCardHTMLAutoHeightMessage(event.data, options.autoHeightId)) {
|
|
69623
|
+
options.onAutoHeight == null ? void 0 : options.onAutoHeight.call(options, event.data.height);
|
|
69624
|
+
return;
|
|
69625
|
+
}
|
|
69626
|
+
var phase = getCardHTMLStreamRuntimePhase(event.data);
|
|
69627
|
+
if (phase) {
|
|
69628
|
+
options.onStreamRuntimePhase == null ? void 0 : options.onStreamRuntimePhase.call(options, phase);
|
|
69629
|
+
}
|
|
69623
69630
|
};
|
|
69624
69631
|
window.addEventListener('message', handleMessage);
|
|
69625
69632
|
return function() {
|
|
69626
69633
|
window.removeEventListener('message', handleMessage);
|
|
69627
69634
|
};
|
|
69628
69635
|
}
|
|
69636
|
+
function getCardHTMLStreamRuntimePhase(data) {
|
|
69637
|
+
if ((typeof data === "undefined" ? "undefined" : _type_of(data)) !== 'object' || data === null) {
|
|
69638
|
+
return undefined;
|
|
69639
|
+
}
|
|
69640
|
+
var message = data;
|
|
69641
|
+
if (message.type !== 'huamei:html-stream-runtime-status' || _type_of(message.payload) !== 'object' || message.payload === null) {
|
|
69642
|
+
return undefined;
|
|
69643
|
+
}
|
|
69644
|
+
var phase = message.payload.phase;
|
|
69645
|
+
return [
|
|
69646
|
+
'parsing',
|
|
69647
|
+
'draining',
|
|
69648
|
+
'complete',
|
|
69649
|
+
'finalizing',
|
|
69650
|
+
'disposed',
|
|
69651
|
+
'error'
|
|
69652
|
+
].includes(String(phase)) ? phase : undefined;
|
|
69653
|
+
}
|
|
69629
69654
|
function isCardHTMLAutoHeightMessage(data, id) {
|
|
69630
69655
|
if ((typeof data === "undefined" ? "undefined" : _type_of(data)) !== 'object' || data === null) {
|
|
69631
69656
|
return false;
|
|
@@ -69644,7 +69669,7 @@ function withCardHTMLAutoHeightBridge(html, id) {
|
|
|
69644
69669
|
if (!id) {
|
|
69645
69670
|
return html;
|
|
69646
69671
|
}
|
|
69647
|
-
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>";
|
|
69672
|
+
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 if (window.getComputedStyle(node).position === 'fixed') {\n return 0;\n }\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>";
|
|
69648
69673
|
if (/<\/body>/i.test(html)) {
|
|
69649
69674
|
return html.replace(/<\/body>/i, "" + script + "</body>");
|
|
69650
69675
|
}
|
|
@@ -69928,6 +69953,442 @@ function syncElementStackOrder(_container, elements) {
|
|
|
69928
69953
|
});
|
|
69929
69954
|
}
|
|
69930
69955
|
|
|
69956
|
+
var CAPTURE_TIMEOUT = 5000;
|
|
69957
|
+
var MOTION_PROPERTIES = /^(animation|transition)(?:-|$)/i;
|
|
69958
|
+
var RUNTIME_SELECTOR = [
|
|
69959
|
+
'[data-hm-stream-runtime]',
|
|
69960
|
+
'[data-vvfx-card-html-auto-height]',
|
|
69961
|
+
'[data-vvfx-card-html-anchor-navigation-guard]',
|
|
69962
|
+
'script',
|
|
69963
|
+
'noscript',
|
|
69964
|
+
'template'
|
|
69965
|
+
].join(',');
|
|
69966
|
+
function captureViewportSize(logicalSize, _displayedBounds) {
|
|
69967
|
+
return {
|
|
69968
|
+
width: Math.max(1, logicalSize.width),
|
|
69969
|
+
height: Math.max(1, logicalSize.height)
|
|
69970
|
+
};
|
|
69971
|
+
}
|
|
69972
|
+
function serializeComputedCaptureStyle(style) {
|
|
69973
|
+
var declarations = [];
|
|
69974
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(style), _step; !(_step = _iterator()).done;){
|
|
69975
|
+
var property = _step.value;
|
|
69976
|
+
if (MOTION_PROPERTIES.test(property)) {
|
|
69977
|
+
continue;
|
|
69978
|
+
}
|
|
69979
|
+
var value = style.getPropertyValue(property);
|
|
69980
|
+
if (!value) {
|
|
69981
|
+
continue;
|
|
69982
|
+
}
|
|
69983
|
+
var priority = style.getPropertyPriority(property);
|
|
69984
|
+
declarations.push(property + ":" + value + (priority ? "!" + priority : ''));
|
|
69985
|
+
}
|
|
69986
|
+
declarations.push('animation:none!important', 'transition:none!important');
|
|
69987
|
+
return declarations.join(';');
|
|
69988
|
+
}
|
|
69989
|
+
function createHTMLCaptureReplica(ownerDocument, html, logicalSize) {
|
|
69990
|
+
return _async_to_generator(function() {
|
|
69991
|
+
var size, iframe, loaded, sourceDocument, replica;
|
|
69992
|
+
return _ts_generator(this, function(_state) {
|
|
69993
|
+
switch(_state.label){
|
|
69994
|
+
case 0:
|
|
69995
|
+
size = captureViewportSize(logicalSize);
|
|
69996
|
+
iframe = ownerDocument.createElement('iframe');
|
|
69997
|
+
Object.assign(iframe.style, {
|
|
69998
|
+
position: 'fixed',
|
|
69999
|
+
left: '-100000px',
|
|
70000
|
+
top: '0',
|
|
70001
|
+
width: "" + size.width + "px",
|
|
70002
|
+
height: "" + size.height + "px",
|
|
70003
|
+
border: '0',
|
|
70004
|
+
pointerEvents: 'none',
|
|
70005
|
+
opacity: '1',
|
|
70006
|
+
zIndex: '-1'
|
|
70007
|
+
});
|
|
70008
|
+
iframe.srcdoc = html;
|
|
70009
|
+
loaded = waitForNextLoad(iframe);
|
|
70010
|
+
ownerDocument.body.appendChild(iframe);
|
|
70011
|
+
return [
|
|
70012
|
+
4,
|
|
70013
|
+
withCaptureTimeout(loaded)
|
|
70014
|
+
];
|
|
70015
|
+
case 1:
|
|
70016
|
+
_state.sent();
|
|
70017
|
+
sourceDocument = iframe.contentDocument;
|
|
70018
|
+
if (!(sourceDocument == null ? void 0 : sourceDocument.documentElement) || !sourceDocument.body) {
|
|
70019
|
+
iframe.remove();
|
|
70020
|
+
return [
|
|
70021
|
+
2,
|
|
70022
|
+
undefined
|
|
70023
|
+
];
|
|
70024
|
+
}
|
|
70025
|
+
return [
|
|
70026
|
+
4,
|
|
70027
|
+
createHTMLCaptureReplicaFromDocument(ownerDocument, sourceDocument, size)
|
|
70028
|
+
];
|
|
70029
|
+
case 2:
|
|
70030
|
+
replica = _state.sent();
|
|
70031
|
+
if (!replica) {
|
|
70032
|
+
iframe.remove();
|
|
70033
|
+
return [
|
|
70034
|
+
2,
|
|
70035
|
+
undefined
|
|
70036
|
+
];
|
|
70037
|
+
}
|
|
70038
|
+
return [
|
|
70039
|
+
2,
|
|
70040
|
+
{
|
|
70041
|
+
target: replica.target,
|
|
70042
|
+
cleanup: function cleanup() {
|
|
70043
|
+
replica.cleanup();
|
|
70044
|
+
iframe.remove();
|
|
70045
|
+
}
|
|
70046
|
+
}
|
|
70047
|
+
];
|
|
70048
|
+
}
|
|
70049
|
+
});
|
|
70050
|
+
})();
|
|
70051
|
+
}
|
|
70052
|
+
function createHTMLCaptureReplicaFromDocument(ownerDocument, sourceDocument, logicalSize) {
|
|
70053
|
+
return _async_to_generator(function() {
|
|
70054
|
+
var target;
|
|
70055
|
+
return _ts_generator(this, function(_state) {
|
|
70056
|
+
switch(_state.label){
|
|
70057
|
+
case 0:
|
|
70058
|
+
if (!sourceDocument.documentElement || !sourceDocument.body || !sourceDocument.defaultView) {
|
|
70059
|
+
return [
|
|
70060
|
+
2,
|
|
70061
|
+
undefined
|
|
70062
|
+
];
|
|
70063
|
+
}
|
|
70064
|
+
return [
|
|
70065
|
+
4,
|
|
70066
|
+
withCaptureTimeout(waitForCaptureReady(sourceDocument))
|
|
70067
|
+
];
|
|
70068
|
+
case 1:
|
|
70069
|
+
_state.sent();
|
|
70070
|
+
target = createComputedCaptureTarget(ownerDocument, sourceDocument, captureViewportSize(logicalSize));
|
|
70071
|
+
return [
|
|
70072
|
+
2,
|
|
70073
|
+
{
|
|
70074
|
+
target: target,
|
|
70075
|
+
cleanup: function cleanup() {
|
|
70076
|
+
target.remove();
|
|
70077
|
+
}
|
|
70078
|
+
}
|
|
70079
|
+
];
|
|
70080
|
+
}
|
|
70081
|
+
});
|
|
70082
|
+
})();
|
|
70083
|
+
}
|
|
70084
|
+
function createComputedCaptureTarget(ownerDocument, sourceDocument, size) {
|
|
70085
|
+
var sourceWindow = sourceDocument.defaultView;
|
|
70086
|
+
if (!sourceWindow) {
|
|
70087
|
+
throw new Error('HTML capture replica has no window');
|
|
70088
|
+
}
|
|
70089
|
+
var frame = ownerDocument.createElement('div');
|
|
70090
|
+
frame.setAttribute('data-vvfx-html-capture-replica', 'true');
|
|
70091
|
+
frame.style.cssText = serializeComputedCaptureStyle(sourceWindow.getComputedStyle(sourceDocument.documentElement));
|
|
70092
|
+
Object.assign(frame.style, {
|
|
70093
|
+
position: 'fixed',
|
|
70094
|
+
left: '-100000px',
|
|
70095
|
+
top: '0',
|
|
70096
|
+
width: "" + size.width + "px",
|
|
70097
|
+
height: "" + size.height + "px",
|
|
70098
|
+
overflow: 'hidden',
|
|
70099
|
+
pointerEvents: 'none',
|
|
70100
|
+
opacity: '1',
|
|
70101
|
+
zIndex: '-1',
|
|
70102
|
+
transform: 'none'
|
|
70103
|
+
});
|
|
70104
|
+
appendDocumentFontSurface(frame, sourceDocument, ownerDocument);
|
|
70105
|
+
var sourceBody = sourceDocument.body;
|
|
70106
|
+
var bodyClone = sourceBody.cloneNode(true);
|
|
70107
|
+
bodyClone.querySelectorAll(RUNTIME_SELECTOR).forEach(function(node) {
|
|
70108
|
+
node.remove();
|
|
70109
|
+
});
|
|
70110
|
+
if (bodyClone.matches(RUNTIME_SELECTOR)) {
|
|
70111
|
+
bodyClone.replaceChildren();
|
|
70112
|
+
}
|
|
70113
|
+
frame.appendChild(bodyClone);
|
|
70114
|
+
ownerDocument.body.appendChild(frame);
|
|
70115
|
+
var sources = [].concat([
|
|
70116
|
+
sourceBody
|
|
70117
|
+
], Array.from(sourceBody.querySelectorAll('*'))).filter(isStylableElement).filter(function(node) {
|
|
70118
|
+
return !node.matches(RUNTIME_SELECTOR) && !node.closest(RUNTIME_SELECTOR);
|
|
70119
|
+
});
|
|
70120
|
+
var clones = [].concat([
|
|
70121
|
+
bodyClone
|
|
70122
|
+
], Array.from(bodyClone.querySelectorAll('*'))).filter(isStylableElement).filter(function(node) {
|
|
70123
|
+
return !node.matches(RUNTIME_SELECTOR) && !node.closest(RUNTIME_SELECTOR);
|
|
70124
|
+
});
|
|
70125
|
+
var pseudoRules = [];
|
|
70126
|
+
sources.forEach(function(source, index) {
|
|
70127
|
+
var clone = clones[index];
|
|
70128
|
+
if (!clone) {
|
|
70129
|
+
return;
|
|
70130
|
+
}
|
|
70131
|
+
clone.style.cssText = serializeComputedCaptureStyle(sourceWindow.getComputedStyle(source));
|
|
70132
|
+
freezeViewportPosition(source, clone, sourceWindow);
|
|
70133
|
+
preserveLiveElementState(source, clone, ownerDocument);
|
|
70134
|
+
appendPseudoRule(source, clone, sourceWindow, pseudoRules, index);
|
|
70135
|
+
});
|
|
70136
|
+
if (pseudoRules.length) {
|
|
70137
|
+
var style = ownerDocument.createElement('style');
|
|
70138
|
+
style.setAttribute('data-vvfx-html-capture-pseudo', 'true');
|
|
70139
|
+
style.textContent = pseudoRules.join('\n');
|
|
70140
|
+
frame.prepend(style);
|
|
70141
|
+
}
|
|
70142
|
+
return frame;
|
|
70143
|
+
}
|
|
70144
|
+
function appendDocumentFontSurface(frame, sourceDocument, ownerDocument) {
|
|
70145
|
+
var _sourceDocument_defaultView;
|
|
70146
|
+
var fontRules = [];
|
|
70147
|
+
var SourceCSSFontFaceRule = (_sourceDocument_defaultView = sourceDocument.defaultView) == null ? void 0 : _sourceDocument_defaultView.CSSFontFaceRule;
|
|
70148
|
+
Array.from(sourceDocument.styleSheets).forEach(function(sheet) {
|
|
70149
|
+
try {
|
|
70150
|
+
Array.from(sheet.cssRules).forEach(function(rule) {
|
|
70151
|
+
if (SourceCSSFontFaceRule && _instanceof(rule, SourceCSSFontFaceRule)) {
|
|
70152
|
+
fontRules.push(rule.cssText);
|
|
70153
|
+
}
|
|
70154
|
+
});
|
|
70155
|
+
} catch (unused) {
|
|
70156
|
+
// Cross-origin font stylesheets are already loaded in the replica but cannot be read.
|
|
70157
|
+
}
|
|
70158
|
+
});
|
|
70159
|
+
if (!fontRules.length) {
|
|
70160
|
+
return;
|
|
70161
|
+
}
|
|
70162
|
+
var style = ownerDocument.createElement('style');
|
|
70163
|
+
style.setAttribute('data-vvfx-html-capture-fonts', 'true');
|
|
70164
|
+
style.textContent = fontRules.join('\n');
|
|
70165
|
+
frame.appendChild(style);
|
|
70166
|
+
}
|
|
70167
|
+
function isStylableElement(element) {
|
|
70168
|
+
return 'style' in element;
|
|
70169
|
+
}
|
|
70170
|
+
function freezeViewportPosition(source, clone, sourceWindow) {
|
|
70171
|
+
if (sourceWindow.getComputedStyle(source).position !== 'fixed') {
|
|
70172
|
+
return;
|
|
70173
|
+
}
|
|
70174
|
+
var rect = source.getBoundingClientRect();
|
|
70175
|
+
Object.assign(clone.style, {
|
|
70176
|
+
position: 'absolute',
|
|
70177
|
+
left: "" + rect.left + "px",
|
|
70178
|
+
top: "" + rect.top + "px",
|
|
70179
|
+
right: 'auto',
|
|
70180
|
+
bottom: 'auto',
|
|
70181
|
+
width: "" + rect.width + "px",
|
|
70182
|
+
height: "" + rect.height + "px"
|
|
70183
|
+
});
|
|
70184
|
+
}
|
|
70185
|
+
function preserveLiveElementState(source, clone, ownerDocument) {
|
|
70186
|
+
if (_instanceof(source, source.ownerDocument.defaultView.HTMLImageElement) && _instanceof(clone, ownerDocument.defaultView.HTMLImageElement)) {
|
|
70187
|
+
clone.src = source.currentSrc || source.src;
|
|
70188
|
+
}
|
|
70189
|
+
if (_instanceof(source, source.ownerDocument.defaultView.HTMLInputElement) && _instanceof(clone, ownerDocument.defaultView.HTMLInputElement)) {
|
|
70190
|
+
clone.value = source.value;
|
|
70191
|
+
clone.checked = source.checked;
|
|
70192
|
+
}
|
|
70193
|
+
if (_instanceof(source, source.ownerDocument.defaultView.HTMLTextAreaElement) && _instanceof(clone, ownerDocument.defaultView.HTMLTextAreaElement)) {
|
|
70194
|
+
clone.value = source.value;
|
|
70195
|
+
clone.textContent = source.value;
|
|
70196
|
+
}
|
|
70197
|
+
if (_instanceof(source, source.ownerDocument.defaultView.HTMLCanvasElement) && _instanceof(clone, ownerDocument.defaultView.HTMLCanvasElement)) {
|
|
70198
|
+
clone.width = source.width;
|
|
70199
|
+
clone.height = source.height;
|
|
70200
|
+
try {
|
|
70201
|
+
var _clone_getContext;
|
|
70202
|
+
(_clone_getContext = clone.getContext('2d')) == null ? void 0 : _clone_getContext.drawImage(source, 0, 0);
|
|
70203
|
+
} catch (unused) {
|
|
70204
|
+
// Tainted canvases remain empty; snapdom cannot legally read them either.
|
|
70205
|
+
}
|
|
70206
|
+
}
|
|
70207
|
+
}
|
|
70208
|
+
function appendPseudoRule(source, clone, sourceWindow, rules, index) {
|
|
70209
|
+
var attribute = "capture-" + index;
|
|
70210
|
+
clone.setAttribute('data-vvfx-capture-node', attribute);
|
|
70211
|
+
[
|
|
70212
|
+
'::before',
|
|
70213
|
+
'::after'
|
|
70214
|
+
].forEach(function(pseudo) {
|
|
70215
|
+
var style = sourceWindow.getComputedStyle(source, pseudo);
|
|
70216
|
+
if (!style.content || style.content === 'none' || style.content === 'normal') {
|
|
70217
|
+
return;
|
|
70218
|
+
}
|
|
70219
|
+
rules.push('[data-vvfx-capture-node="' + attribute + '"]' + pseudo + "{" + serializeComputedCaptureStyle(style) + "}");
|
|
70220
|
+
});
|
|
70221
|
+
}
|
|
70222
|
+
function waitForCaptureReady(document) {
|
|
70223
|
+
return _async_to_generator(function() {
|
|
70224
|
+
var _document_fonts;
|
|
70225
|
+
return _ts_generator(this, function(_state) {
|
|
70226
|
+
switch(_state.label){
|
|
70227
|
+
case 0:
|
|
70228
|
+
return [
|
|
70229
|
+
4,
|
|
70230
|
+
(_document_fonts = document.fonts) == null ? void 0 : _document_fonts.ready
|
|
70231
|
+
];
|
|
70232
|
+
case 1:
|
|
70233
|
+
_state.sent();
|
|
70234
|
+
return [
|
|
70235
|
+
4,
|
|
70236
|
+
Promise.all(Array.from(document.images).map(function(image) {
|
|
70237
|
+
return _async_to_generator(function() {
|
|
70238
|
+
return _ts_generator(this, function(_state) {
|
|
70239
|
+
switch(_state.label){
|
|
70240
|
+
case 0:
|
|
70241
|
+
_state.trys.push([
|
|
70242
|
+
0,
|
|
70243
|
+
4,
|
|
70244
|
+
,
|
|
70245
|
+
5
|
|
70246
|
+
]);
|
|
70247
|
+
if (!!image.complete) return [
|
|
70248
|
+
3,
|
|
70249
|
+
2
|
|
70250
|
+
];
|
|
70251
|
+
return [
|
|
70252
|
+
4,
|
|
70253
|
+
new Promise(function(resolve) {
|
|
70254
|
+
image.addEventListener('load', function() {
|
|
70255
|
+
resolve();
|
|
70256
|
+
}, {
|
|
70257
|
+
once: true
|
|
70258
|
+
});
|
|
70259
|
+
image.addEventListener('error', function() {
|
|
70260
|
+
resolve();
|
|
70261
|
+
}, {
|
|
70262
|
+
once: true
|
|
70263
|
+
});
|
|
70264
|
+
})
|
|
70265
|
+
];
|
|
70266
|
+
case 1:
|
|
70267
|
+
_state.sent();
|
|
70268
|
+
_state.label = 2;
|
|
70269
|
+
case 2:
|
|
70270
|
+
return [
|
|
70271
|
+
4,
|
|
70272
|
+
image.decode == null ? void 0 : image.decode.call(image)
|
|
70273
|
+
];
|
|
70274
|
+
case 3:
|
|
70275
|
+
_state.sent();
|
|
70276
|
+
return [
|
|
70277
|
+
3,
|
|
70278
|
+
5
|
|
70279
|
+
];
|
|
70280
|
+
case 4:
|
|
70281
|
+
_state.sent();
|
|
70282
|
+
return [
|
|
70283
|
+
3,
|
|
70284
|
+
5
|
|
70285
|
+
];
|
|
70286
|
+
case 5:
|
|
70287
|
+
return [
|
|
70288
|
+
2
|
|
70289
|
+
];
|
|
70290
|
+
}
|
|
70291
|
+
});
|
|
70292
|
+
})();
|
|
70293
|
+
}))
|
|
70294
|
+
];
|
|
70295
|
+
case 2:
|
|
70296
|
+
_state.sent();
|
|
70297
|
+
return [
|
|
70298
|
+
4,
|
|
70299
|
+
waitForStableLayout(document)
|
|
70300
|
+
];
|
|
70301
|
+
case 3:
|
|
70302
|
+
_state.sent();
|
|
70303
|
+
return [
|
|
70304
|
+
2
|
|
70305
|
+
];
|
|
70306
|
+
}
|
|
70307
|
+
});
|
|
70308
|
+
})();
|
|
70309
|
+
}
|
|
70310
|
+
function waitForStableLayout(document) {
|
|
70311
|
+
return _async_to_generator(function() {
|
|
70312
|
+
var view, startedAt, previous, stableFrames, _ref, _ref1, _document_body, _document_body1, current;
|
|
70313
|
+
return _ts_generator(this, function(_state) {
|
|
70314
|
+
switch(_state.label){
|
|
70315
|
+
case 0:
|
|
70316
|
+
view = document.defaultView;
|
|
70317
|
+
if (!view) {
|
|
70318
|
+
return [
|
|
70319
|
+
2
|
|
70320
|
+
];
|
|
70321
|
+
}
|
|
70322
|
+
startedAt = performance.now();
|
|
70323
|
+
previous = '';
|
|
70324
|
+
stableFrames = 0;
|
|
70325
|
+
_state.label = 1;
|
|
70326
|
+
case 1:
|
|
70327
|
+
if (!(performance.now() - startedAt < CAPTURE_TIMEOUT && stableFrames < 3)) return [
|
|
70328
|
+
3,
|
|
70329
|
+
3
|
|
70330
|
+
];
|
|
70331
|
+
return [
|
|
70332
|
+
4,
|
|
70333
|
+
new Promise(function(resolve) {
|
|
70334
|
+
return view.requestAnimationFrame(function() {
|
|
70335
|
+
resolve();
|
|
70336
|
+
});
|
|
70337
|
+
})
|
|
70338
|
+
];
|
|
70339
|
+
case 2:
|
|
70340
|
+
_state.sent();
|
|
70341
|
+
current = [
|
|
70342
|
+
document.documentElement.scrollWidth,
|
|
70343
|
+
document.documentElement.scrollHeight,
|
|
70344
|
+
(_ref = (_document_body = document.body) == null ? void 0 : _document_body.scrollWidth) != null ? _ref : 0,
|
|
70345
|
+
(_ref1 = (_document_body1 = document.body) == null ? void 0 : _document_body1.scrollHeight) != null ? _ref1 : 0,
|
|
70346
|
+
document.styleSheets.length,
|
|
70347
|
+
document.querySelectorAll('style').length
|
|
70348
|
+
].join(':');
|
|
70349
|
+
stableFrames = current === previous ? stableFrames + 1 : 0;
|
|
70350
|
+
previous = current;
|
|
70351
|
+
return [
|
|
70352
|
+
3,
|
|
70353
|
+
1
|
|
70354
|
+
];
|
|
70355
|
+
case 3:
|
|
70356
|
+
return [
|
|
70357
|
+
2
|
|
70358
|
+
];
|
|
70359
|
+
}
|
|
70360
|
+
});
|
|
70361
|
+
})();
|
|
70362
|
+
}
|
|
70363
|
+
function waitForNextLoad(iframe) {
|
|
70364
|
+
return new Promise(function(resolve) {
|
|
70365
|
+
iframe.addEventListener('load', function() {
|
|
70366
|
+
resolve();
|
|
70367
|
+
}, {
|
|
70368
|
+
once: true
|
|
70369
|
+
});
|
|
70370
|
+
iframe.addEventListener('error', function() {
|
|
70371
|
+
resolve();
|
|
70372
|
+
}, {
|
|
70373
|
+
once: true
|
|
70374
|
+
});
|
|
70375
|
+
});
|
|
70376
|
+
}
|
|
70377
|
+
function withCaptureTimeout(promise) {
|
|
70378
|
+
return new Promise(function(resolve) {
|
|
70379
|
+
var timer = globalThis.setTimeout(function() {
|
|
70380
|
+
resolve(undefined);
|
|
70381
|
+
}, CAPTURE_TIMEOUT);
|
|
70382
|
+
promise.then(function(value) {
|
|
70383
|
+
globalThis.clearTimeout(timer);
|
|
70384
|
+
resolve(value);
|
|
70385
|
+
}, function() {
|
|
70386
|
+
globalThis.clearTimeout(timer);
|
|
70387
|
+
resolve(undefined);
|
|
70388
|
+
});
|
|
70389
|
+
});
|
|
70390
|
+
}
|
|
70391
|
+
|
|
69931
70392
|
function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
|
|
69932
70393
|
if (offsetX === void 0) offsetX = 0;
|
|
69933
70394
|
if (offsetY === void 0) offsetY = 0;
|
|
@@ -70074,7 +70535,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
70074
70535
|
cleanups: new Map(),
|
|
70075
70536
|
autoHeightModes: new Map(),
|
|
70076
70537
|
autoHeightCleanups: new Map(),
|
|
70077
|
-
autoHeightFrames: new Map()
|
|
70538
|
+
autoHeightFrames: new Map(),
|
|
70539
|
+
autoHeightStreamPhases: new Map()
|
|
70078
70540
|
};
|
|
70079
70541
|
this.handleContainerDoubleClick = function(event) {
|
|
70080
70542
|
var _this_state_editing;
|
|
@@ -70168,7 +70630,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
70168
70630
|
metaKey: event.metaKey
|
|
70169
70631
|
}));
|
|
70170
70632
|
};
|
|
70171
|
-
this.isAutoHeightMessage = isCardHTMLAutoHeightMessage;
|
|
70172
70633
|
}
|
|
70173
70634
|
var _proto = HTMLOverlayManager.prototype;
|
|
70174
70635
|
_proto.attach = function attach() {
|
|
@@ -70227,6 +70688,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
70227
70688
|
cancelHTMLOverlayFrame(frame);
|
|
70228
70689
|
});
|
|
70229
70690
|
this.state.autoHeightFrames.clear();
|
|
70691
|
+
this.state.autoHeightStreamPhases.clear();
|
|
70230
70692
|
this.eventCleanups.forEach(function(cleanup) {
|
|
70231
70693
|
cleanup();
|
|
70232
70694
|
});
|
|
@@ -70322,7 +70784,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
70322
70784
|
_state.sent();
|
|
70323
70785
|
return [
|
|
70324
70786
|
4,
|
|
70325
|
-
createCardCaptureTarget(contentOverlay, this.state.contents.get(id)
|
|
70787
|
+
createCardCaptureTarget(contentOverlay, this.state.contents.get(id), {
|
|
70788
|
+
width: options.width,
|
|
70789
|
+
height: options.height
|
|
70790
|
+
})
|
|
70326
70791
|
];
|
|
70327
70792
|
case 3:
|
|
70328
70793
|
capture = _state.sent();
|
|
@@ -70339,9 +70804,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
70339
70804
|
I.toPng(capture.target, _extends({
|
|
70340
70805
|
embedFonts: true,
|
|
70341
70806
|
backgroundColor: 'transparent',
|
|
70342
|
-
dpr: (_ref = (_options_pixelRatio = options.pixelRatio) != null ? _options_pixelRatio : window.devicePixelRatio) != null ? _ref : 2
|
|
70343
|
-
width: options.width,
|
|
70344
|
-
height: options.height
|
|
70807
|
+
dpr: (_ref = (_options_pixelRatio = options.pixelRatio) != null ? _options_pixelRatio : window.devicePixelRatio) != null ? _ref : 2
|
|
70345
70808
|
}, options.snapdomOptions))
|
|
70346
70809
|
];
|
|
70347
70810
|
case 5:
|
|
@@ -71269,6 +71732,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71269
71732
|
autoHeightId: (options == null ? void 0 : options.autoHeight) ? options.id : undefined,
|
|
71270
71733
|
onAutoHeight: (options == null ? void 0 : options.autoHeight) ? function(height) {
|
|
71271
71734
|
_this.applyAutoHeight(options.id, height);
|
|
71735
|
+
} : undefined,
|
|
71736
|
+
onStreamRuntimePhase: (options == null ? void 0 : options.autoHeight) ? function(phase) {
|
|
71737
|
+
_this.setAutoHeightStreamPhase(options.id, phase);
|
|
71272
71738
|
} : undefined
|
|
71273
71739
|
}));
|
|
71274
71740
|
case 'dom':
|
|
@@ -71294,6 +71760,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71294
71760
|
autoHeightId: (options == null ? void 0 : options.autoHeight) ? options.id : undefined,
|
|
71295
71761
|
onAutoHeight: (options == null ? void 0 : options.autoHeight) ? function(height) {
|
|
71296
71762
|
_this.applyAutoHeight(options.id, height);
|
|
71763
|
+
} : undefined,
|
|
71764
|
+
onStreamRuntimePhase: (options == null ? void 0 : options.autoHeight) ? function(phase) {
|
|
71765
|
+
_this.setAutoHeightStreamPhase(options.id, phase);
|
|
71297
71766
|
} : undefined
|
|
71298
71767
|
}));
|
|
71299
71768
|
}
|
|
@@ -71324,6 +71793,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71324
71793
|
this.state.contents.delete(id);
|
|
71325
71794
|
this.state.contentMountElements.delete(id);
|
|
71326
71795
|
this.state.autoHeightModes.delete(id);
|
|
71796
|
+
this.state.autoHeightStreamPhases.delete(id);
|
|
71327
71797
|
this.invalidateContentInteractionZones(id);
|
|
71328
71798
|
(_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
|
|
71329
71799
|
this.state.contentInteractionZoneCleanups.delete(id);
|
|
@@ -71345,10 +71815,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71345
71815
|
return;
|
|
71346
71816
|
}
|
|
71347
71817
|
this.ensureAutoHeightMode(id);
|
|
71348
|
-
if (this.state.autoHeightModes.get(id) === 'message') {
|
|
71349
|
-
this.cleanupAutoHeight(id);
|
|
71350
|
-
return;
|
|
71351
|
-
}
|
|
71352
71818
|
if (!this.state.autoHeightCleanups.has(id)) {
|
|
71353
71819
|
this.state.autoHeightCleanups.set(id, this.createAutoHeightObserver(id));
|
|
71354
71820
|
}
|
|
@@ -71395,16 +71861,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71395
71861
|
var mount = this.state.contentMountElements.get(id);
|
|
71396
71862
|
observeElement(mount);
|
|
71397
71863
|
mount == null ? void 0 : mount.querySelectorAll('iframe').forEach(function(iframe) {
|
|
71398
|
-
var handleAutoHeightMessage = function handleAutoHeightMessage(event) {
|
|
71399
|
-
if (event.source !== iframe.contentWindow || !_this.isAutoHeightMessage(event.data, id)) {
|
|
71400
|
-
return;
|
|
71401
|
-
}
|
|
71402
|
-
_this.applyAutoHeight(id, event.data.height);
|
|
71403
|
-
};
|
|
71404
|
-
window.addEventListener('message', handleAutoHeightMessage);
|
|
71405
|
-
cleanupFns.push(function() {
|
|
71406
|
-
window.removeEventListener('message', handleAutoHeightMessage);
|
|
71407
|
-
});
|
|
71408
71864
|
var syncIframeDocument = function syncIframeDocument() {
|
|
71409
71865
|
var doc = null;
|
|
71410
71866
|
try {
|
|
@@ -71415,12 +71871,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71415
71871
|
if (!doc) {
|
|
71416
71872
|
return;
|
|
71417
71873
|
}
|
|
71418
|
-
doc.documentElement.style.height = 'auto';
|
|
71419
|
-
doc.documentElement.style.minHeight = '0';
|
|
71420
|
-
if (doc.body) {
|
|
71421
|
-
doc.body.style.height = 'auto';
|
|
71422
|
-
doc.body.style.minHeight = '0';
|
|
71423
|
-
}
|
|
71424
71874
|
observeElement(doc.documentElement);
|
|
71425
71875
|
observeElement(doc.body);
|
|
71426
71876
|
_this.scheduleAutoHeightMeasure(id);
|
|
@@ -71487,6 +71937,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71487
71937
|
}
|
|
71488
71938
|
var body = doc.body;
|
|
71489
71939
|
var documentElement = doc.documentElement;
|
|
71940
|
+
if (!documentElement) {
|
|
71941
|
+
return undefined;
|
|
71942
|
+
}
|
|
71490
71943
|
var childHeight = body ? this.getChildrenNaturalHeight(body) : 0;
|
|
71491
71944
|
if (childHeight > 0) {
|
|
71492
71945
|
return childHeight;
|
|
@@ -71503,6 +71956,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71503
71956
|
if (!includeIframes && childElement.tagName === 'IFRAME') {
|
|
71504
71957
|
return height;
|
|
71505
71958
|
}
|
|
71959
|
+
if (globalThis.getComputedStyle(childElement).position === 'fixed') {
|
|
71960
|
+
return height;
|
|
71961
|
+
}
|
|
71506
71962
|
return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
|
|
71507
71963
|
}
|
|
71508
71964
|
if (child.nodeType === Node.TEXT_NODE && ((_child_textContent = child.textContent) == null ? void 0 : _child_textContent.trim())) {
|
|
@@ -71541,6 +71997,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71541
71997
|
return;
|
|
71542
71998
|
}
|
|
71543
71999
|
var nextHeight = Math.ceil(this.getAutoHeightItemHeight(item, height));
|
|
72000
|
+
if (this.isAutoHeightStreamActive(id) && nextHeight < item.property.height) {
|
|
72001
|
+
return;
|
|
72002
|
+
}
|
|
71544
72003
|
if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
|
|
71545
72004
|
return;
|
|
71546
72005
|
}
|
|
@@ -71549,6 +72008,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
71549
72008
|
previousHeight: item.property.height
|
|
71550
72009
|
});
|
|
71551
72010
|
};
|
|
72011
|
+
_proto.setAutoHeightStreamPhase = function setAutoHeightStreamPhase(id, phase) {
|
|
72012
|
+
if (phase === 'parsing' || phase === 'draining' || phase === 'finalizing') {
|
|
72013
|
+
this.state.autoHeightStreamPhases.set(id, phase);
|
|
72014
|
+
return;
|
|
72015
|
+
}
|
|
72016
|
+
this.state.autoHeightStreamPhases.delete(id);
|
|
72017
|
+
};
|
|
72018
|
+
_proto.isAutoHeightStreamActive = function isAutoHeightStreamActive(id) {
|
|
72019
|
+
return this.state.autoHeightStreamPhases.has(id);
|
|
72020
|
+
};
|
|
71552
72021
|
_proto.getAutoHeightAnchor = function getAutoHeightAnchor(item) {
|
|
71553
72022
|
var _ref;
|
|
71554
72023
|
var _this_options_resolveCardTypeConfig;
|
|
@@ -71778,52 +72247,56 @@ function waitForIframeLoad(iframe) {
|
|
|
71778
72247
|
});
|
|
71779
72248
|
});
|
|
71780
72249
|
}
|
|
71781
|
-
function createCardCaptureTarget(root, html) {
|
|
72250
|
+
function createCardCaptureTarget(root, html, logicalSize) {
|
|
71782
72251
|
return _async_to_generator(function() {
|
|
71783
|
-
var
|
|
72252
|
+
var _root_querySelector, liveDocument, liveReplica, previewHTML, preview, flattenedTarget;
|
|
71784
72253
|
return _ts_generator(this, function(_state) {
|
|
71785
72254
|
switch(_state.label){
|
|
71786
72255
|
case 0:
|
|
71787
|
-
|
|
71788
|
-
if (!
|
|
72256
|
+
liveDocument = (_root_querySelector = root.querySelector('iframe')) == null ? void 0 : _root_querySelector.contentDocument;
|
|
72257
|
+
if (!liveDocument) return [
|
|
71789
72258
|
3,
|
|
71790
72259
|
2
|
|
71791
72260
|
];
|
|
71792
72261
|
return [
|
|
71793
72262
|
4,
|
|
71794
|
-
|
|
72263
|
+
createHTMLCaptureReplicaFromDocument(root.ownerDocument, liveDocument, logicalSize)
|
|
71795
72264
|
];
|
|
71796
72265
|
case 1:
|
|
71797
|
-
|
|
71798
|
-
if (
|
|
71799
|
-
isDirectIframe = root.children.length === 1 && _instanceof(root.children[0], HTMLIFrameElement);
|
|
71800
|
-
if (isDirectIframe) {
|
|
71801
|
-
directTarget = createDirectCaptureTarget(root, preview.target);
|
|
71802
|
-
return [
|
|
71803
|
-
2,
|
|
71804
|
-
{
|
|
71805
|
-
target: directTarget,
|
|
71806
|
-
cleanup: function cleanup() {
|
|
71807
|
-
directTarget.remove();
|
|
71808
|
-
preview.cleanup();
|
|
71809
|
-
}
|
|
71810
|
-
}
|
|
71811
|
-
];
|
|
71812
|
-
}
|
|
71813
|
-
shellTarget = createShellCaptureTarget(root, preview.target);
|
|
72266
|
+
liveReplica = _state.sent();
|
|
72267
|
+
if (liveReplica) {
|
|
71814
72268
|
return [
|
|
71815
72269
|
2,
|
|
71816
72270
|
{
|
|
71817
|
-
target:
|
|
71818
|
-
cleanup:
|
|
71819
|
-
shellTarget.remove();
|
|
71820
|
-
preview.cleanup();
|
|
71821
|
-
}
|
|
72271
|
+
target: liveReplica.target,
|
|
72272
|
+
cleanup: liveReplica.cleanup
|
|
71822
72273
|
}
|
|
71823
72274
|
];
|
|
71824
72275
|
}
|
|
71825
72276
|
_state.label = 2;
|
|
71826
72277
|
case 2:
|
|
72278
|
+
previewHTML = createCardPreviewHTML(html == null ? void 0 : html.content);
|
|
72279
|
+
if (!previewHTML) return [
|
|
72280
|
+
3,
|
|
72281
|
+
4
|
|
72282
|
+
];
|
|
72283
|
+
return [
|
|
72284
|
+
4,
|
|
72285
|
+
createHTMLCaptureReplica(root.ownerDocument, previewHTML, logicalSize)
|
|
72286
|
+
];
|
|
72287
|
+
case 3:
|
|
72288
|
+
preview = _state.sent();
|
|
72289
|
+
if (preview) {
|
|
72290
|
+
return [
|
|
72291
|
+
2,
|
|
72292
|
+
{
|
|
72293
|
+
target: preview.target,
|
|
72294
|
+
cleanup: preview.cleanup
|
|
72295
|
+
}
|
|
72296
|
+
];
|
|
72297
|
+
}
|
|
72298
|
+
_state.label = 4;
|
|
72299
|
+
case 4:
|
|
71827
72300
|
flattenedTarget = createFlattenedExistingIframeTarget(root);
|
|
71828
72301
|
return [
|
|
71829
72302
|
2,
|
|
@@ -71881,182 +72354,6 @@ function createCardPreviewHTML(content) {
|
|
|
71881
72354
|
}
|
|
71882
72355
|
return undefined;
|
|
71883
72356
|
}
|
|
71884
|
-
function createPreviewDocumentCaptureTarget(root, html) {
|
|
71885
|
-
return _async_to_generator(function() {
|
|
71886
|
-
var _ref, iframe, rect, loadPromise, doc, target;
|
|
71887
|
-
return _ts_generator(this, function(_state) {
|
|
71888
|
-
switch(_state.label){
|
|
71889
|
-
case 0:
|
|
71890
|
-
iframe = root.ownerDocument.createElement('iframe');
|
|
71891
|
-
rect = root.getBoundingClientRect();
|
|
71892
|
-
iframe.style.position = 'fixed';
|
|
71893
|
-
iframe.style.left = '-100000px';
|
|
71894
|
-
iframe.style.top = '0';
|
|
71895
|
-
iframe.style.width = "" + Math.max(1, rect.width) + "px";
|
|
71896
|
-
iframe.style.height = "" + Math.max(1, rect.height) + "px";
|
|
71897
|
-
iframe.style.border = '0';
|
|
71898
|
-
iframe.style.pointerEvents = 'none';
|
|
71899
|
-
iframe.style.opacity = '1';
|
|
71900
|
-
iframe.style.zIndex = '-1';
|
|
71901
|
-
loadPromise = waitForNextIframeLoad(iframe);
|
|
71902
|
-
root.ownerDocument.body.appendChild(iframe);
|
|
71903
|
-
iframe.srcdoc = html;
|
|
71904
|
-
return [
|
|
71905
|
-
4,
|
|
71906
|
-
loadPromise
|
|
71907
|
-
];
|
|
71908
|
-
case 1:
|
|
71909
|
-
_state.sent();
|
|
71910
|
-
return [
|
|
71911
|
-
4,
|
|
71912
|
-
waitForIframeContent(iframe)
|
|
71913
|
-
];
|
|
71914
|
-
case 2:
|
|
71915
|
-
_state.sent();
|
|
71916
|
-
doc = iframe.contentDocument;
|
|
71917
|
-
target = (_ref = doc == null ? void 0 : doc.body) != null ? _ref : doc == null ? void 0 : doc.documentElement;
|
|
71918
|
-
if (!target) {
|
|
71919
|
-
iframe.remove();
|
|
71920
|
-
return [
|
|
71921
|
-
2,
|
|
71922
|
-
undefined
|
|
71923
|
-
];
|
|
71924
|
-
}
|
|
71925
|
-
return [
|
|
71926
|
-
4,
|
|
71927
|
-
waitForDocumentFonts(target.ownerDocument)
|
|
71928
|
-
];
|
|
71929
|
-
case 3:
|
|
71930
|
-
_state.sent();
|
|
71931
|
-
return [
|
|
71932
|
-
4,
|
|
71933
|
-
waitForImages(target)
|
|
71934
|
-
];
|
|
71935
|
-
case 4:
|
|
71936
|
-
_state.sent();
|
|
71937
|
-
return [
|
|
71938
|
-
4,
|
|
71939
|
-
nextAnimationFrame()
|
|
71940
|
-
];
|
|
71941
|
-
case 5:
|
|
71942
|
-
_state.sent();
|
|
71943
|
-
return [
|
|
71944
|
-
2,
|
|
71945
|
-
{
|
|
71946
|
-
target: target,
|
|
71947
|
-
cleanup: function cleanup() {
|
|
71948
|
-
iframe.remove();
|
|
71949
|
-
}
|
|
71950
|
-
}
|
|
71951
|
-
];
|
|
71952
|
-
}
|
|
71953
|
-
});
|
|
71954
|
-
})();
|
|
71955
|
-
}
|
|
71956
|
-
function waitForNextIframeLoad(iframe) {
|
|
71957
|
-
return new Promise(function(resolve) {
|
|
71958
|
-
iframe.addEventListener('load', function() {
|
|
71959
|
-
resolve();
|
|
71960
|
-
}, {
|
|
71961
|
-
once: true
|
|
71962
|
-
});
|
|
71963
|
-
iframe.addEventListener('error', function() {
|
|
71964
|
-
resolve();
|
|
71965
|
-
}, {
|
|
71966
|
-
once: true
|
|
71967
|
-
});
|
|
71968
|
-
});
|
|
71969
|
-
}
|
|
71970
|
-
function waitForIframeContent(iframe) {
|
|
71971
|
-
return _async_to_generator(function() {
|
|
71972
|
-
var start, doc;
|
|
71973
|
-
return _ts_generator(this, function(_state) {
|
|
71974
|
-
switch(_state.label){
|
|
71975
|
-
case 0:
|
|
71976
|
-
start = performance.now();
|
|
71977
|
-
_state.label = 1;
|
|
71978
|
-
case 1:
|
|
71979
|
-
if (!(performance.now() - start < CARD_RASTERIZE_READY_TIMEOUT)) return [
|
|
71980
|
-
3,
|
|
71981
|
-
3
|
|
71982
|
-
];
|
|
71983
|
-
doc = iframe.contentDocument;
|
|
71984
|
-
if ((doc == null ? void 0 : doc.body) && doc.body.children.length > 0) {
|
|
71985
|
-
return [
|
|
71986
|
-
2
|
|
71987
|
-
];
|
|
71988
|
-
}
|
|
71989
|
-
return [
|
|
71990
|
-
4,
|
|
71991
|
-
nextAnimationFrame()
|
|
71992
|
-
];
|
|
71993
|
-
case 2:
|
|
71994
|
-
_state.sent();
|
|
71995
|
-
return [
|
|
71996
|
-
3,
|
|
71997
|
-
1
|
|
71998
|
-
];
|
|
71999
|
-
case 3:
|
|
72000
|
-
return [
|
|
72001
|
-
2
|
|
72002
|
-
];
|
|
72003
|
-
}
|
|
72004
|
-
});
|
|
72005
|
-
})();
|
|
72006
|
-
}
|
|
72007
|
-
function createShellCaptureTarget(root, contentTarget) {
|
|
72008
|
-
var clone = root.cloneNode(true);
|
|
72009
|
-
clone.style.position = 'fixed';
|
|
72010
|
-
clone.style.left = '-100000px';
|
|
72011
|
-
clone.style.top = '0';
|
|
72012
|
-
clone.style.pointerEvents = 'none';
|
|
72013
|
-
clone.style.opacity = '1';
|
|
72014
|
-
clone.style.zIndex = '-1';
|
|
72015
|
-
var clonedIframe = clone.querySelector('iframe');
|
|
72016
|
-
if (clonedIframe) {
|
|
72017
|
-
clonedIframe.replaceWith(createFlattenedContent(contentTarget, getComputedStyle(clonedIframe), root.ownerDocument));
|
|
72018
|
-
}
|
|
72019
|
-
root.ownerDocument.body.appendChild(clone);
|
|
72020
|
-
return clone;
|
|
72021
|
-
}
|
|
72022
|
-
function createDirectCaptureTarget(root, contentTarget) {
|
|
72023
|
-
var rect = root.getBoundingClientRect();
|
|
72024
|
-
var frame = root.ownerDocument.createElement('div');
|
|
72025
|
-
frame.style.position = 'fixed';
|
|
72026
|
-
frame.style.left = '-100000px';
|
|
72027
|
-
frame.style.top = '0';
|
|
72028
|
-
frame.style.width = "" + Math.max(1, rect.width) + "px";
|
|
72029
|
-
frame.style.height = "" + Math.max(1, rect.height) + "px";
|
|
72030
|
-
frame.style.pointerEvents = 'none';
|
|
72031
|
-
frame.style.opacity = '1';
|
|
72032
|
-
frame.style.zIndex = '-1';
|
|
72033
|
-
frame.style.overflow = 'hidden';
|
|
72034
|
-
var flattenedContent = createFlattenedContent(contentTarget, getComputedStyle(contentTarget), root.ownerDocument);
|
|
72035
|
-
flattenedContent.style.width = '100%';
|
|
72036
|
-
flattenedContent.style.height = '100%';
|
|
72037
|
-
frame.appendChild(flattenedContent);
|
|
72038
|
-
root.ownerDocument.body.appendChild(frame);
|
|
72039
|
-
return frame;
|
|
72040
|
-
}
|
|
72041
|
-
function createFlattenedContent(target, frameStyle, ownerDocument) {
|
|
72042
|
-
var replacement = ownerDocument.createElement('div');
|
|
72043
|
-
Object.assign(replacement.style, {
|
|
72044
|
-
width: frameStyle.width,
|
|
72045
|
-
height: frameStyle.height,
|
|
72046
|
-
display: frameStyle.display === 'none' ? 'block' : frameStyle.display,
|
|
72047
|
-
overflow: 'hidden',
|
|
72048
|
-
border: frameStyle.border,
|
|
72049
|
-
boxSizing: frameStyle.boxSizing,
|
|
72050
|
-
background: frameStyle.background
|
|
72051
|
-
});
|
|
72052
|
-
Array.from(target.ownerDocument.head.children).forEach(function(child) {
|
|
72053
|
-
replacement.appendChild(child.cloneNode(true));
|
|
72054
|
-
});
|
|
72055
|
-
Array.from(target.children).forEach(function(child) {
|
|
72056
|
-
replacement.appendChild(child.cloneNode(true));
|
|
72057
|
-
});
|
|
72058
|
-
return replacement;
|
|
72059
|
-
}
|
|
72060
72357
|
function isMouseEventInsideRect(event, rect) {
|
|
72061
72358
|
return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
72062
72359
|
}
|