single-file-core 1.5.0 → 1.5.2

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/util.js CHANGED
@@ -71,7 +71,11 @@ const URL = globalThis.URL;
71
71
  const DOMParser = globalThis.DOMParser;
72
72
  const Blob = globalThis.Blob;
73
73
  const FileReader = globalThis.FileReader;
74
- const fetch = (url, options) => globalThis.fetch(url, options);
74
+ const fetch = (url, options) => {
75
+ options.cache = "force-cache";
76
+ options.referrerPolicy = "strict-origin-when-cross-origin";
77
+ return globalThis.fetch(url, options);
78
+ };
75
79
  const TextDecoder = globalThis.TextDecoder;
76
80
  const URLSearchParams = globalThis.URLSearchParams;
77
81
 
@@ -87,7 +91,7 @@ function getInstance(utilOptions) {
87
91
  getDoctypeString,
88
92
  getFilenameExtension(resourceURL, replacedCharacters, replacementCharacter) {
89
93
  let matchExtension;
90
- try {
94
+ try {
91
95
  matchExtension = new URL(resourceURL).pathname.match(/(\.[^\\/.]*)$/);
92
96
  } catch (error) {
93
97
  // ignored
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -66,6 +66,7 @@ const MessageChannel = globalThis.MessageChannel;
66
66
  const document = globalThis.document;
67
67
  const JSON = globalThis.JSON;
68
68
  const MutationObserver = globalThis.MutationObserver;
69
+ const DOMParser = globalThis.DOMParser;
69
70
 
70
71
  let sessions = globalThis.sessions;
71
72
  if (!sessions) {
@@ -303,16 +304,22 @@ function processFramesSync(doc, frameElements, options, parentWindowId, sessionI
303
304
  const frames = [];
304
305
  frameElements.forEach((frameElement, frameIndex) => {
305
306
  const windowId = parentWindowId + WINDOW_ID_SEPARATOR + frameIndex;
306
- let frameDoc;
307
+ let frameDoc, frameWindow;
307
308
  try {
308
309
  frameDoc = frameElement.contentDocument;
310
+ frameWindow = frameElement.contentWindow;
311
+ frameWindow.stop();
309
312
  } catch (error) {
310
313
  // ignored
311
314
  }
315
+ const srcdoc = frameElement.getAttribute("srcdoc");
316
+ if (!frameDoc && srcdoc) {
317
+ const doc = new DOMParser().parseFromString(srcdoc, "text/html");
318
+ frameDoc = doc;
319
+ frameWindow = globalThis;
320
+ }
312
321
  if (frameDoc) {
313
322
  try {
314
- const frameWindow = frameElement.contentWindow;
315
- frameWindow.stop();
316
323
  clearFrameTimeout("requestTimeouts", sessionId, windowId);
317
324
  processFrames(frameDoc, options, windowId, sessionId);
318
325
  frames.push(getFrameData(frameDoc, frameWindow, windowId, options, frameElement.scrolling));