@readium/navigator-html-injectables 2.4.2 → 2.4.4

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/index.js CHANGED
@@ -257,12 +257,12 @@ const jt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], He = /* @__PURE__ */ J
257
257
  // 'tr': () => import('@edrlab/thorium-locales/publication-metadata/tr.json'),
258
258
  // 'uk': () => import('@edrlab/thorium-locales/publication-metadata/uk.json')
259
259
  }, ee = _e?.publication?.metadata?.accessibility?.["display-guide"] || {};
260
- class $ {
260
+ class Y {
261
261
  constructor() {
262
262
  this.currentLocaleCode = "en", this.locale = ee, this.loadedLocales = {}, this.loadedLocales.en = ee;
263
263
  }
264
264
  static getInstance() {
265
- return $.instance || ($.instance = new $()), $.instance;
265
+ return Y.instance || (Y.instance = new Y()), Y.instance;
266
266
  }
267
267
  /**
268
268
  * Loads a locale dynamically
@@ -333,7 +333,7 @@ class $ {
333
333
  return e === void 0 && this.currentLocaleCode !== "en" && (e = this.getNestedValue(this.loadedLocales.en, t)), e !== void 0 ? typeof e == "string" ? { compact: e, descriptive: e } : e : (console.warn(`Missing localization for key: ${t}`), { compact: "", descriptive: "" });
334
334
  }
335
335
  }
336
- $.getInstance();
336
+ Y.getInstance();
337
337
  class kt {
338
338
  /**
339
339
  * Creates a [Encryption].
@@ -2162,7 +2162,7 @@ function gt(n, t) {
2162
2162
  n.document.documentElement.style.removeProperty(t);
2163
2163
  }
2164
2164
  let lt = null, St = null, J = 0;
2165
- const G = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), ri = () => {
2165
+ const $ = { r: 255, g: 255, b: 255, a: 1 }, G = /* @__PURE__ */ new Map(), ri = () => {
2166
2166
  if (!lt)
2167
2167
  if (typeof OffscreenCanvas < "u")
2168
2168
  lt = new OffscreenCanvas(5, 5), St = lt.getContext("2d", {
@@ -2198,17 +2198,17 @@ const G = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), ri =
2198
2198
  ].some((s) => t.includes(s));
2199
2199
  }, ct = (n, t) => {
2200
2200
  console.warn(
2201
- `[Decorator] Could not parse color: "${n}". ${t} Falling back to ${JSON.stringify(G)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
2201
+ `[Decorator] Could not parse color: "${n}". ${t} Falling back to ${JSON.stringify($)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
2202
2202
  );
2203
2203
  }, Ct = (n, t = null) => {
2204
- const e = t ? `${n}|${t}` : n, i = F.get(e);
2204
+ const e = t ? `${n}|${t}` : n, i = G.get(e);
2205
2205
  if (i !== void 0)
2206
- return i ?? G;
2206
+ return i ?? $;
2207
2207
  if (ni(n))
2208
- return ct(n, "Unsupported color format or special value."), F.set(e, null), G;
2208
+ return ct(n, "Unsupported color format or special value."), G.set(e, null), $;
2209
2209
  const s = ri();
2210
2210
  if (!s)
2211
- return ct(n, "Could not get canvas context."), F.set(e, null), G;
2211
+ return ct(n, "Could not get canvas context."), G.set(e, null), $;
2212
2212
  try {
2213
2213
  J === 0 && s.clearRect(0, 0, 5, 5);
2214
2214
  const r = J % 5, o = Math.floor(J / 5);
@@ -2217,11 +2217,11 @@ const G = { r: 255, g: 255, b: 255, a: 1 }, F = /* @__PURE__ */ new Map(), ri =
2217
2217
  J = (J + 1) % 25;
2218
2218
  const [c, u, d, f] = a.data;
2219
2219
  if (f === 0)
2220
- return ct(n, "Fully transparent color."), F.set(e, null), G;
2220
+ return ct(n, "Fully transparent color."), G.set(e, null), $;
2221
2221
  const p = { r: c, g: u, b: d, a: f / 255 };
2222
- return F.set(e, p), p;
2222
+ return G.set(e, p), p;
2223
2223
  } catch (r) {
2224
- return ct(n, `Error: ${r instanceof Error ? r.message : String(r)}`), F.set(e, null), G;
2224
+ return ct(n, `Error: ${r instanceof Error ? r.message : String(r)}`), G.set(e, null), $;
2225
2225
  }
2226
2226
  }, Et = (n) => {
2227
2227
  const t = n / 255;
@@ -2562,7 +2562,7 @@ function gi(n) {
2562
2562
  return n ? n.closest("[inert]") !== null || n.hasAttribute("disabled") : !0;
2563
2563
  }
2564
2564
  function ze(n) {
2565
- return n ? n.role && fi.includes(n.role) || n.tabIndex >= 0 ? !0 : mi.includes(n.nodeName.toLowerCase()) || n.hasAttribute("contenteditable") && n.getAttribute("contenteditable")?.toLowerCase() !== "false" : !1;
2565
+ return n ? n.role && fi.includes(n.role) ? !0 : n.tagName.toLowerCase() === "iframe" ? !1 : n.tabIndex >= 0 ? !0 : mi.includes(n.nodeName.toLowerCase()) || n.hasAttribute("contenteditable") && n.getAttribute("contenteditable")?.toLowerCase() !== "false" : !1;
2566
2566
  }
2567
2567
  function yt(n, t) {
2568
2568
  const e = Me(n, n.document.body, t), i = n._readium_cssSelectorGenerator.getCssSelector(e, {
@@ -3370,20 +3370,22 @@ class xi {
3370
3370
  createUnifiedHandler(t, e, i, s) {
3371
3371
  const r = this.createKeyboardHandlers(t, e, i, s);
3372
3372
  return (o) => {
3373
- for (const a of r)
3374
- if (this.match(o, [a])) {
3375
- const c = a.suppressOnInteractiveElement;
3376
- if (c) {
3377
- const u = (s?.document ?? document).activeElement;
3378
- if (Array.isArray(c) ? c.some((d) => u?.matches(d)) : ze(u)) return;
3373
+ if (o.isTrusted) {
3374
+ for (const a of r)
3375
+ if (this.match(o, [a])) {
3376
+ const c = a.suppressOnInteractiveElement;
3377
+ if (c) {
3378
+ const u = (s?.document ?? document).activeElement;
3379
+ if (Array.isArray(c) ? c.some((d) => u?.matches(d)) : ze(u)) return;
3380
+ }
3381
+ o.preventDefault(), o.stopPropagation(), a.handler(o);
3382
+ return;
3379
3383
  }
3380
- o.preventDefault(), o.stopPropagation(), a.handler(o);
3381
- return;
3382
- }
3384
+ }
3383
3385
  };
3384
3386
  }
3385
3387
  }
3386
- const Y = class Y extends K {
3388
+ const F = class F extends K {
3387
3389
  constructor() {
3388
3390
  super(...arguments), this.configApplied = !1, this.cleanupCallbacks = [], this.pointerMoved = !1, this.isContextMenuEnabled = !1, this.isDragAndDropEnabled = !1, this.isSelectionMonitoringEnabled = !1, this.isBulkCopyProtectionEnabled = !1, this.selectionAnalyzer = null, this.currentSelection = null, this.bulkCopyProtector = null, this.keyManager = new xi(), this.keyDownHandler = null, this.preventBulkCopy = (t) => {
3389
3391
  if (!this.isBulkCopyProtectionEnabled || !this.bulkCopyProtector)
@@ -3577,7 +3579,7 @@ const Y = class Y extends K {
3577
3579
  }
3578
3580
  }
3579
3581
  registerProtectionHandlers() {
3580
- this.comms?.register("peripherals_protection", Y.moduleName, (t, e) => {
3582
+ this.comms?.register("peripherals_protection", F.moduleName, (t, e) => {
3581
3583
  const i = t;
3582
3584
  if (!this.configApplied) {
3583
3585
  if (this.configApplied = !0, i.monitorSelection) {
@@ -3595,7 +3597,9 @@ const Y = class Y extends K {
3595
3597
  }), this.comms?.log("Copy protection enabled")), i.disableContextMenu && (this.addContextMenuPrevention(), this.comms?.log("Context menu protection enabled")), i.disableDragAndDrop && (this.addDragAndDropPrevention(), this.comms?.log("Drag and drop protection enabled"));
3596
3598
  }
3597
3599
  e(!0);
3598
- }), this.comms?.register("keyboard_peripherals", Y.moduleName, (t, e) => {
3600
+ }), this.comms?.register("unfocus", F.moduleName, (t, e) => {
3601
+ this.disableKeyboardPeripherals(), e(!0);
3602
+ }), this.comms?.register("keyboard_peripherals", F.moduleName, (t, e) => {
3599
3603
  const i = t;
3600
3604
  i && i.length > 0 && (this.enableKeyboardPeripherals(i), this.comms?.log(`Keyboard peripherals enabled: ${i.map((s) => s.type).join(", ")}`)), e(!0);
3601
3605
  });
@@ -3604,11 +3608,11 @@ const Y = class Y extends K {
3604
3608
  return this.wnd = t, this.comms = e, this.registerProtectionHandlers(), t.document.addEventListener("pointerdown", this.onPointerDown), t.document.addEventListener("pointerup", this.onPointerUp), t.document.addEventListener("pointermove", this.onPointerMove), t.document.addEventListener("click", this.onClicker), e.log("Peripherals Mounted"), !0;
3605
3609
  }
3606
3610
  unmount(t, e) {
3607
- return this.removeBulkCopyProtection(), this.removeSelectionMonitoring(), this.removeContextMenuPrevention(), this.removeDragAndDropPrevention(), this.disableKeyboardPeripherals(), this.cleanupCallbacks.forEach((i) => i()), this.cleanupCallbacks = [], t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.unregisterAll(Y.moduleName), this.configApplied = !1, e.log("Peripherals Unmounted"), !0;
3611
+ return this.removeBulkCopyProtection(), this.removeSelectionMonitoring(), this.removeContextMenuPrevention(), this.removeDragAndDropPrevention(), this.disableKeyboardPeripherals(), this.cleanupCallbacks.forEach((i) => i()), this.cleanupCallbacks = [], t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.unregisterAll(F.moduleName), this.configApplied = !1, e.log("Peripherals Unmounted"), !0;
3608
3612
  }
3609
3613
  };
3610
- Y.moduleName = "peripherals";
3611
- let Ot = Y;
3614
+ F.moduleName = "peripherals";
3615
+ let Ot = F;
3612
3616
  const et = class et extends K {
3613
3617
  constructor() {
3614
3618
  super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
@@ -3659,7 +3663,7 @@ const et = class et extends K {
3659
3663
  ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
3660
3664
  value: {
3661
3665
  name: "readium-ts-toolkit",
3662
- version: "2.4.2",
3666
+ version: "2.4.4",
3663
3667
  hasFeature: (s, r = "") => {
3664
3668
  switch (s) {
3665
3669
  case "dom-manipulation":