single-file-core 1.5.75 → 1.5.76

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/core/helper.js CHANGED
@@ -463,7 +463,7 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
463
463
  if (tagName == "CANVAS") {
464
464
  try {
465
465
  data.canvases.push({
466
- dataURI: element.toDataURL("image/png", ""),
466
+ dataURI: element.toDataURL("image/png"),
467
467
  backgroundColor: computedStyle.getPropertyValue("background-color")
468
468
  });
469
469
  element.setAttribute(CANVAS_ATTRIBUTE_NAME, data.canvases.length - 1);
@@ -523,7 +523,7 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
523
523
  canvasElement.height = element.videoHeight;
524
524
  try {
525
525
  context.drawImage(element, 0, 0, canvasElement.width, canvasElement.height);
526
- data.posters.push(canvasElement.toDataURL("image/png", ""));
526
+ data.posters.push(canvasElement.toDataURL("image/png"));
527
527
  element.setAttribute(POSTER_ATTRIBUTE_NAME, data.posters.length - 1);
528
528
  data.markedElements.push(element);
529
529
  // eslint-disable-next-line no-unused-vars
package/core/index.js CHANGED
@@ -1190,15 +1190,17 @@ class Processor {
1190
1190
  canvasElement.height = videoData.size.videoHeight;
1191
1191
  context.drawImage(temporaryVideoElement, 0, 0, canvasElement.width, canvasElement.height);
1192
1192
  try {
1193
- videoElement.poster = canvasElement.toDataURL("image/png", "");
1193
+ videoElement.poster = canvasElement.toDataURL("image/png");
1194
1194
  // eslint-disable-next-line no-unused-vars
1195
1195
  } catch (error) {
1196
+ videoElement.poster = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='" + videoData.size.videoWidth + "' height='" + videoData.size.videoHeight + "'%3E%3C/svg%3E";
1196
1197
  // ignored
1197
1198
  }
1198
1199
  temporaryVideoElement.remove();
1199
1200
  resolve();
1200
1201
  };
1201
1202
  temporaryVideoElement.onerror = () => {
1203
+ videoElement.poster = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='" + videoData.size.videoWidth + "' height='" + videoData.size.videoHeight + "'%3E%3C/svg%3E";
1202
1204
  temporaryVideoElement.remove();
1203
1205
  resolve();
1204
1206
  };
@@ -389,9 +389,6 @@ function getProcessorHelperClass(utilInstance) {
389
389
  }
390
390
  }
391
391
  }
392
- if (options.imageReductionFactor > 1) {
393
- content = await resizeImage(doc, content, options);
394
- }
395
392
  if (removeElementIfMissing && this.testEmptyResource(content)) {
396
393
  resourceElement.remove();
397
394
  } else if (!this.testEmptyResource(content)) {
@@ -415,6 +412,9 @@ function getProcessorHelperClass(utilInstance) {
415
412
  const isSVG = content.startsWith(PREFIX_DATA_URI_IMAGE_SVG);
416
413
  const maxSizeDuplicateImages = options.maxSizeDuplicateImages || SINGLE_FILE_VARIABLE_MAX_SIZE;
417
414
  if (processDuplicates && duplicate && !isSVG && util.getContentSize(content) < maxSizeDuplicateImages) {
415
+ if (options.imageReductionFactor > 1 && expectedType == "image") {
416
+ content = await resizeImage(doc, content, options);
417
+ }
418
418
  if (this.replaceImageSource(resourceElement, SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource, options)) {
419
419
  resources.cssVariables.set(indexResource, { content, url: originURL });
420
420
  const declarationList = cssTree.parse(resourceElement.getAttribute("style"), { context: "declarationList", parseCustomProperty: true });
@@ -356,7 +356,7 @@ function getProcessorHelperClass(utilInstance) {
356
356
  }
357
357
  }
358
358
  }
359
- if (options.imageReductionFactor > 1) {
359
+ if (options.imageReductionFactor > 1 && expectedType == "image") {
360
360
  const dataURI = await resizeImage(doc, await toDataURI(new Blob([content], { type: contentType }), charset), options);
361
361
  content = (await util.getContent(dataURI, { asBinary: true })).data;
362
362
  }
@@ -60,7 +60,6 @@ const UNMATCHABLE_PSEUDO_CLASSES = [
60
60
  "focus-visible",
61
61
  "target-current",
62
62
  "enabled",
63
- "disabled",
64
63
  "read-only",
65
64
  "read-write",
66
65
  "placeholder-shown",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.5.75",
3
+ "version": "1.5.76",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",