single-file-core 1.0.28 → 1.0.30

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/.eslintrc.js CHANGED
File without changes
package/LICENSE CHANGED
File without changes
@@ -170,7 +170,6 @@
170
170
  async function initInfobar(url, saveDate, infoData) {
171
171
  let infobarElement = document.querySelector(INFOBAR_TAGNAME);
172
172
  if (!infobarElement) {
173
- url = url.split("url: ")[1];
174
173
  saveDate = saveDate.split("saved date: ")[1];
175
174
  if (infoData && infoData.length > 1) {
176
175
  let content = infoData[0].split("info: ")[1].trim();
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/modules/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -40,6 +40,9 @@
40
40
  const LAZY_LOAD_ATTRIBUTE = "single-file-lazy-load";
41
41
  const LOAD_IMAGE_EVENT = "single-file-load-image";
42
42
  const IMAGE_LOADED_EVENT = "single-file-image-loaded";
43
+ const FETCH_REQUEST_EVENT = "single-file-request-fetch";
44
+ const FETCH_ACK_EVENT = "single-file-ack-fetch";
45
+ const FETCH_RESPONSE_EVENT = "single-file-response-fetch";
43
46
  const NEW_FONT_FACE_EVENT = "single-file-new-font-face";
44
47
  const DELETE_FONT_EVENT = "single-file-delete-font";
45
48
  const CLEAR_FONTS_EVENT = "single-file-clear-fonts";
@@ -55,6 +58,7 @@
55
58
 
56
59
  const addEventListener = (type, listener, options) => globalThis.addEventListener(type, listener, options);
57
60
  const dispatchEvent = event => { try { globalThis.dispatchEvent(event); } catch (error) { /* ignored */ } };
61
+ const fetch = (url, options) => globalThis.fetch(url, options);
58
62
  const CustomEvent = globalThis.CustomEvent;
59
63
  const document = globalThis.document;
60
64
  const screen = globalThis.screen;
@@ -293,6 +297,19 @@
293
297
  }
294
298
  });
295
299
 
300
+ addEventListener(FETCH_REQUEST_EVENT, async event => {
301
+ dispatchEvent(new CustomEvent(FETCH_ACK_EVENT));
302
+ const { url, options } = JSON.parse(event.detail);
303
+ let detail;
304
+ try {
305
+ const response = await fetch(url, options);
306
+ detail = { url, response: await response.arrayBuffer(), headers: [...response.headers], status: response.status };
307
+ } catch (error) {
308
+ detail = { url, error: error && error.toString() };
309
+ }
310
+ dispatchEvent(new CustomEvent(FETCH_RESPONSE_EVENT, { detail }));
311
+ });
312
+
296
313
  if (globalThis.FontFace) {
297
314
  const FontFace = globalThis.FontFace;
298
315
  let warningFontFaceDisplayed;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/single-file.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/vendor/index.js CHANGED
File without changes
File without changes