@boyernick/standard-ui-react 0.4.2-canary.61 → 0.4.2-canary.62
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/package.json
CHANGED
|
@@ -149,6 +149,21 @@ function drawable(element: Element): element is HTMLImageElement | HTMLVideoElem
|
|
|
149
149
|
return element instanceof HTMLCanvasElement && element.width > 0 && element.height > 0;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
/** Whether drawing this source would taint a canvas (its pixels are cross-origin). */
|
|
153
|
+
function unreadable(source: CanvasImageSource) {
|
|
154
|
+
const probe = document.createElement("canvas");
|
|
155
|
+
probe.width = probe.height = 1;
|
|
156
|
+
const context = probe.getContext("2d");
|
|
157
|
+
if (!context) return true;
|
|
158
|
+
try {
|
|
159
|
+
context.drawImage(source, 0, 0, 1, 1);
|
|
160
|
+
context.getImageData(0, 0, 1, 1);
|
|
161
|
+
return false;
|
|
162
|
+
} catch {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
152
167
|
function naturalSize(element: HTMLImageElement | HTMLVideoElement | HTMLCanvasElement) {
|
|
153
168
|
if (element instanceof HTMLImageElement) return { width: element.naturalWidth, height: element.naturalHeight };
|
|
154
169
|
if (element instanceof HTMLVideoElement) return { width: element.videoWidth, height: element.videoHeight };
|
|
@@ -489,8 +504,12 @@ export function createLensGlass({ root, glassElements, defaults = {} }: LensGlas
|
|
|
489
504
|
try {
|
|
490
505
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, scene);
|
|
491
506
|
} catch {
|
|
492
|
-
//
|
|
493
|
-
|
|
507
|
+
// Something we drew was cross-origin after all — a canvas, or media
|
|
508
|
+
// behind a same-origin address that redirects elsewhere (a video served
|
|
509
|
+
// through a signed-link redirect). Find it and leave it out from now on.
|
|
510
|
+
const media = drawn.filter(({ element: item }) => item instanceof HTMLImageElement || item instanceof HTMLVideoElement || item instanceof HTMLCanvasElement);
|
|
511
|
+
const culprits = media.filter(({ element: item }) => unreadable(item as CanvasImageSource));
|
|
512
|
+
for (const { element: item } of culprits.length ? culprits : media) tainted.add(item);
|
|
494
513
|
pane.signature = "";
|
|
495
514
|
forced = true;
|
|
496
515
|
return;
|