@prose-reader/shared 1.275.0 → 1.277.0

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
@@ -1,32 +1,32 @@
1
- const a = (o, n) => o === n ? !0 : o.length !== n.length ? !1 : o.every((e, t) => e === n[t]), f = (o) => o.split(/[#?]/)[0]?.split(".").pop()?.trim() || "";
2
- function s(o) {
1
+ const w = (e, n) => e === n ? !0 : e.length !== n.length ? !1 : e.every((t, r) => t === n[r]), f = (e) => e.split(/[#?]/)[0]?.split(".").pop()?.trim() || "";
2
+ function g(e) {
3
3
  const n = [];
4
- if (o.length === 0)
4
+ if (e.length === 0)
5
5
  return "";
6
- if (typeof o[0] != "string")
7
- throw new TypeError(`Url must be a string. Received ${o[0]}`);
8
- o[0].match(/^[^/:]+:\/*$/) && o.length > 1 && (o[0] = o.shift() + o[0]), o[0].match(/^file:\/\/\//) ? o[0] = o[0].replace(/^([^/:]+):\/*/, "$1:///") : o[0] = o[0].replace(/^([^/:]+):\/*/, "$1://");
9
- for (let l = 0; l < o.length; l++) {
10
- let r = o[l];
11
- if (typeof r != "string")
12
- throw new TypeError(`Url must be a string. Received ${r}`);
13
- r !== "" && (l > 0 && (r = r.replace(/^[/]+/, "")), l < o.length - 1 ? r = r.replace(/[/]+$/, "") : r = r.replace(/[/]+$/, "/"), n.push(r));
6
+ if (typeof e[0] != "string")
7
+ throw new TypeError(`Url must be a string. Received ${e[0]}`);
8
+ e[0].match(/^[^/:]+:\/*$/) && e.length > 1 && (e[0] = e.shift() + e[0]), e[0].match(/^file:\/\/\//) ? e[0] = e[0].replace(/^([^/:]+):\/*/, "$1:///") : e[0] = e[0].replace(/^([^/:]+):\/*/, "$1://");
9
+ for (let l = 0; l < e.length; l++) {
10
+ let o = e[l];
11
+ if (typeof o != "string")
12
+ throw new TypeError(`Url must be a string. Received ${o}`);
13
+ o !== "" && (l > 0 && (o = o.replace(/^[/]+/, "")), l < e.length - 1 ? o = o.replace(/[/]+$/, "") : o = o.replace(/[/]+$/, "/"), n.push(o));
14
14
  }
15
- let e = n.join("/");
16
- e = e.replace(/\/(\?|&|#[^!])/g, "$1");
17
- const t = e.split("?");
18
- return e = t.shift() + (t.length > 0 ? "?" : "") + t.join("&"), e;
15
+ let t = n.join("/");
16
+ t = t.replace(/\/(\?|&|#[^!])/g, "$1");
17
+ const r = t.split("?");
18
+ return t = r.shift() + (r.length > 0 ? "?" : "") + r.join("&"), t;
19
19
  }
20
- function E(...o) {
21
- const n = Array.from(Array.isArray(o[0]) ? o[0] : o);
22
- return s(n);
20
+ function y(...e) {
21
+ const n = Array.from(Array.isArray(e[0]) ? e[0] : e);
22
+ return g(n);
23
23
  }
24
- function y(o) {
25
- const n = o.split("/");
24
+ function b(e) {
25
+ const n = e.split("/");
26
26
  return n.pop(), n.join("/");
27
27
  }
28
- const p = (o) => {
29
- switch (f(o)) {
28
+ const d = (e) => {
29
+ switch (f(e)) {
30
30
  case "png":
31
31
  return "image/png";
32
32
  case "jpg":
@@ -40,123 +40,139 @@ const p = (o) => {
40
40
  case "xhtml":
41
41
  return "application/xhtml+xml";
42
42
  }
43
- }, w = ({
44
- mimeType: o,
43
+ }, m = ({
44
+ mimeType: e,
45
45
  uri: n
46
- }) => (o ?? p(n ?? ""))?.startsWith("application/xhtml+xml"), R = (o) => o.length ? o.indexOf(";") ? o.substring(0, o.indexOf(";")) : o : void 0, g = Object.prototype.hasOwnProperty, d = (o, n) => o === n ? o !== 0 || n !== 0 || 1 / o === 1 / n : !1, m = (o, n, e) => {
47
- if (o === n)
46
+ }) => (e ?? d(n ?? ""))?.startsWith("application/xhtml+xml"), R = (e) => e.length ? e.indexOf(";") ? e.substring(0, e.indexOf(";")) : e : void 0, a = Object.prototype.hasOwnProperty, E = (e, n) => e === n ? e !== 0 || n !== 0 || 1 / e === 1 / n : !1, O = (e, n, t) => {
47
+ if (e === n)
48
48
  return !0;
49
- if (typeof o != "object" || o === null || typeof n != "object" || n === null)
49
+ if (typeof e != "object" || e === null || typeof n != "object" || n === null)
50
50
  return !1;
51
- const t = Object.keys(o), l = Object.keys(n);
52
- if (t.length !== l.length)
51
+ const r = Object.keys(e), l = Object.keys(n);
52
+ if (r.length !== l.length)
53
53
  return !1;
54
- const r = e && typeof e.customEqual == "function" ? e.customEqual : d;
55
- for (let c = 0; c < t.length; c++) {
56
- const i = t[c] || "";
57
- if (!g.call(n, i) || !r(o[i], n[i]))
54
+ const o = t && typeof t.customEqual == "function" ? t.customEqual : E;
55
+ for (let c = 0; c < r.length; c++) {
56
+ const u = r[c] || "";
57
+ if (!a.call(n, u) || !o(e[u], n[u]))
58
58
  return !1;
59
59
  }
60
60
  return !0;
61
- }, v = (o, n) => o.reduce(
62
- (e, t) => {
63
- const l = n(t);
64
- return e[l] || (e[l] = []), e[l].push(t), e;
61
+ }, _ = (e, n) => e.reduce(
62
+ (t, r) => {
63
+ const l = n(r);
64
+ return t[l] || (t[l] = []), t[l].push(r), t;
65
65
  },
66
66
  {}
67
67
  );
68
- function O(o, n) {
69
- const e = { ...o };
70
- for (const t in n)
71
- if (Object.hasOwn(n, t)) {
72
- const l = n[t];
73
- (l !== void 0 || !(t in o)) && (e[t] = l);
68
+ function x(e, n) {
69
+ const t = { ...e };
70
+ for (const r in n)
71
+ if (Object.hasOwn(n, r)) {
72
+ const l = n[r];
73
+ (l !== void 0 || !(r in e)) && (t[r] = l);
74
74
  }
75
- return e;
75
+ return t;
76
76
  }
77
77
  const h = () => {
78
78
  if (!(typeof window > "u"))
79
79
  return window;
80
80
  };
81
81
  function $() {
82
- const o = h()?.__PROSE_READER_DEBUG;
83
- return o === !0 || o === "true";
82
+ const e = h()?.__PROSE_READER_DEBUG;
83
+ return e === !0 || e === "true";
84
84
  }
85
- const u = (o, n = $(), e) => ({
86
- namespace: (t, l) => u(`${o} [${t}]`, l, e),
87
- debug: n ? o ? Function.prototype.bind.call(
88
- console.debug,
89
- console,
90
- o,
91
- `%c${o}`,
92
- e?.color ? `color: ${e.color}` : void 0
93
- ) : Function.prototype.bind.call(
94
- console.debug,
95
- console,
96
- `%c${o}`,
97
- e?.color ? `color: ${e.color}` : void 0
98
- ) : () => {
99
- },
100
- info: n ? o ? Function.prototype.bind.call(
101
- console.info,
102
- console,
103
- `%c${o}`,
104
- e?.color ? `color: ${e.color}` : void 0
105
- ) : Function.prototype.bind.call(
106
- console.info,
107
- console,
108
- `%c${o}`,
109
- e?.color ? `color: ${e.color}` : void 0
110
- ) : () => {
111
- },
112
- log: n ? o ? Function.prototype.bind.call(
113
- console.log,
114
- console,
115
- `%c${o}`,
116
- e?.color ? `color: ${e.color}` : void 0
117
- ) : Function.prototype.bind.call(console.log, console) : () => {
118
- },
119
- warn: n ? o ? Function.prototype.bind.call(
120
- console.warn,
121
- console,
122
- `%c${o}`,
123
- e?.color ? `color: ${e.color}` : void 0
124
- ) : Function.prototype.bind.call(
125
- console.warn,
126
- console,
127
- `%c${o}`,
128
- e?.color ? `color: ${e.color}` : void 0
129
- ) : () => {
130
- },
131
- error: n ? o ? Function.prototype.bind.call(
132
- console.error,
133
- console,
134
- `%c${o}`,
135
- e?.color ? `color: ${e.color}` : void 0
136
- ) : Function.prototype.bind.call(
137
- console.error,
138
- console,
139
- `%c${o}`,
140
- e?.color ? `color: ${e.color}` : void 0
141
- ) : () => {
142
- }
143
- }), _ = {
144
- ...u(),
145
- namespace: (o, n, e) => u(`[${o}]`, n, e)
146
- }, x = "prose-reader-resource-error";
85
+ const s = (e, n = $(), t) => {
86
+ let r = n;
87
+ const l = t?.color ? `color: ${t.color}` : void 0, o = {
88
+ enable: (i) => {
89
+ u(i);
90
+ },
91
+ namespace: (i, p) => s(`${e} [${i}]`, p, t),
92
+ isEnabled: () => r,
93
+ debug: () => {
94
+ },
95
+ info: () => {
96
+ },
97
+ log: () => {
98
+ },
99
+ groupCollapsed: () => {
100
+ },
101
+ groupEnd: () => {
102
+ },
103
+ getGroupArgs: (i) => l ? [`%c${e ? `${e} ${i}` : i}`, l] : [e ? `${e} ${i}` : i],
104
+ warn: () => {
105
+ },
106
+ error: () => {
107
+ }
108
+ }, c = (i) => {
109
+ if (!i) {
110
+ o.debug = () => {
111
+ }, o.info = () => {
112
+ }, o.log = () => {
113
+ }, o.groupCollapsed = () => {
114
+ }, o.groupEnd = () => {
115
+ }, o.warn = () => {
116
+ }, o.error = () => {
117
+ };
118
+ return;
119
+ }
120
+ o.debug = e ? Function.prototype.bind.call(
121
+ console.debug,
122
+ console,
123
+ e,
124
+ `%c${e}`,
125
+ l
126
+ ) : Function.prototype.bind.call(
127
+ console.debug,
128
+ console,
129
+ `%c${e}`,
130
+ l
131
+ ), o.info = Function.prototype.bind.call(
132
+ console.info,
133
+ console,
134
+ `%c${e}`,
135
+ l
136
+ ), o.log = e ? Function.prototype.bind.call(
137
+ console.log,
138
+ console,
139
+ `%c${e}`,
140
+ l
141
+ ) : Function.prototype.bind.call(console.log, console), o.groupCollapsed = Function.prototype.bind.call(
142
+ console.groupCollapsed,
143
+ console
144
+ ), o.groupEnd = Function.prototype.bind.call(console.groupEnd, console), o.warn = Function.prototype.bind.call(
145
+ console.warn,
146
+ console,
147
+ `%c${e}`,
148
+ l
149
+ ), o.error = Function.prototype.bind.call(
150
+ console.error,
151
+ console,
152
+ `%c${e}`,
153
+ l
154
+ );
155
+ }, u = (i) => {
156
+ r !== i && (r = i, c(r));
157
+ };
158
+ return c(r), o;
159
+ }, F = {
160
+ ...s(),
161
+ namespace: (e, n, t) => s(`[${e}]`, n, t)
162
+ }, T = "prose-reader-resource-error";
147
163
  export {
148
- x as PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME,
149
- _ as Report,
150
- a as arrayEqual,
151
- p as detectMimeTypeFromName,
152
- y as getParentPath,
164
+ T as PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME,
165
+ F as Report,
166
+ w as arrayEqual,
167
+ d as detectMimeTypeFromName,
168
+ b as getParentPath,
153
169
  f as getUrlExtension,
154
- v as groupBy,
155
- d as is,
156
- m as isShallowEqual,
157
- w as isXmlBasedMimeType,
170
+ _ as groupBy,
171
+ E as is,
172
+ O as isShallowEqual,
173
+ m as isXmlBasedMimeType,
158
174
  R as parseContentType,
159
- O as shallowMergeIfDefined,
160
- E as urlJoin
175
+ x as shallowMergeIfDefined,
176
+ y as urlJoin
161
177
  };
162
178
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/array.ts","../src/url.ts","../src/contentType.ts","../src/objects.ts","../src/report.ts","../src/resources.ts"],"sourcesContent":["// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const arrayEqual = <A extends any[], B extends any[]>(a: A, b: B) => {\n // @ts-expect-error\n if (a === b) return true\n if (a.length !== b.length) return false\n\n return a.every((v, i) => v === b[i])\n}\n","export const getUrlExtension = (url: string) => {\n return url.split(/[#?]/)[0]?.split(`.`).pop()?.trim() || ``\n}\n\nfunction normalize(strArray: string[]) {\n const resultArray = []\n if (strArray.length === 0) {\n return \"\"\n }\n\n if (typeof strArray[0] !== \"string\") {\n throw new TypeError(`Url must be a string. Received ${strArray[0]}`)\n }\n\n // If the first part is a plain protocol, we combine it with the next part.\n if (strArray[0].match(/^[^/:]+:\\/*$/) && strArray.length > 1) {\n strArray[0] = strArray.shift() + strArray[0]\n }\n\n // There must be two or three slashes in the file protocol, two slashes in anything else.\n if (strArray[0].match(/^file:\\/\\/\\//)) {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1:///\")\n } else {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1://\")\n }\n\n for (let i = 0; i < strArray.length; i++) {\n let component = strArray[i]\n\n if (typeof component !== \"string\") {\n throw new TypeError(`Url must be a string. Received ${component}`)\n }\n\n if (component === \"\") {\n continue\n }\n\n if (i > 0) {\n // Removing the starting slashes for each component but the first.\n component = component.replace(/^[/]+/, \"\")\n }\n if (i < strArray.length - 1) {\n // Removing the ending slashes for each component but the last.\n component = component.replace(/[/]+$/, \"\")\n } else {\n // For the last component we will combine multiple slashes to a single one.\n component = component.replace(/[/]+$/, \"/\")\n }\n\n resultArray.push(component)\n }\n\n let str = resultArray.join(\"/\")\n // Each input component is now separated by a single slash except the possible first plain protocol part.\n\n // remove trailing slash before parameters or hash\n str = str.replace(/\\/(\\?|&|#[^!])/g, \"$1\")\n\n // replace ? in parameters with &\n const parts = str.split(\"?\")\n str = parts.shift() + (parts.length > 0 ? \"?\" : \"\") + parts.join(\"&\")\n\n return str\n}\n\nexport function urlJoin(...args: (string | string[])[]) {\n const parts = Array.from(Array.isArray(args[0]) ? args[0] : args) as string[]\n\n return normalize(parts)\n}\n\nexport function getParentPath(uri: string): string {\n const parts = uri.split(\"/\")\n\n parts.pop() // Remove the last segment\n\n return parts.join(\"/\")\n}\n","import { getUrlExtension } from \"./url\"\n\nexport const detectMimeTypeFromName = (name: string) => {\n const extension = getUrlExtension(name)\n\n switch (extension) {\n case `png`:\n return `image/png`\n case `jpg`:\n return `image/jpg`\n case `jpeg`:\n return `image/jpeg`\n case `txt`:\n return `text/plain`\n case `webp`:\n return `image/webp`\n case `xhtml`:\n return `application/xhtml+xml`\n }\n\n return undefined\n}\n\nexport const isXmlBasedMimeType = ({\n mimeType,\n uri,\n}: {\n uri?: string\n mimeType?: string\n}) => {\n const _mimeType = mimeType ?? detectMimeTypeFromName(uri ?? \"\")\n\n return _mimeType?.startsWith(`application/xhtml+xml`)\n}\n\nexport const parseContentType = (str: string) => {\n if (!str.length) return undefined\n\n const cut = str.indexOf(`;`)\n\n return cut ? str.substring(0, str.indexOf(`;`)) : str\n}\n","// MIT © 2017 azu\nconst hasOwn = Object.prototype.hasOwnProperty\n\n// Object.is polyfill\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const is = (x: any, y: any): boolean => {\n if (x === y) {\n return x !== 0 || y !== 0 || 1 / x === 1 / y\n }\n return false\n}\n\n/**\n * Return true, if `objectA` is shallow equal to `objectB`.\n * Pass Custom equality function to `customEqual`.\n * Default equality is `Object.is`\n * Support Array\n *\n * Options:\n *\n * - `customEqual`: function should return true if the `a` value is equal to `b` value.\n * - `debug`: enable debug info to console log. This log will be disable in production build\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const isShallowEqual = <T = any, R = any>(\n objectA: T,\n objectB: R,\n options?: {\n customEqual?: <T>(a: T, b: T) => boolean\n },\n): boolean => {\n // @ts-expect-error\n if (objectA === objectB) {\n return true\n }\n if (typeof objectA !== \"object\" || objectA === null) {\n return false\n }\n if (typeof objectB !== \"object\" || objectB === null) {\n return false\n }\n\n const keysA = Object.keys(objectA)\n const keysB = Object.keys(objectB)\n\n if (keysA.length !== keysB.length) {\n return false\n }\n\n const isEqual =\n options && typeof options.customEqual === \"function\"\n ? options.customEqual\n : is\n\n for (let i = 0; i < keysA.length; i++) {\n const key = keysA[i] || ``\n // @ts-expect-error\n if (!hasOwn.call(objectB, key) || !isEqual(objectA[key], objectB[key])) {\n return false\n }\n }\n\n return true\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const groupBy = <T, K extends keyof any>(\n list: T[],\n getKey: (item: T) => K,\n) =>\n list.reduce(\n (previous, currentItem) => {\n const group = getKey(currentItem)\n if (!previous[group]) previous[group] = []\n previous[group].push(currentItem)\n return previous\n },\n {} as Record<K, T[]>,\n )\n\nexport function shallowMergeIfDefined<T extends object, U extends object>(\n obj1: T,\n obj2: U,\n): T & U {\n const result = { ...obj1 } as T & U\n\n for (const key in obj2) {\n if (Object.hasOwn(obj2, key)) {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n const value = (obj2 as any)[key]\n if (value !== undefined || !(key in obj1)) {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n ;(result as any)[key] = value\n }\n }\n }\n\n return result\n}\n","declare global {\n interface Window {\n __PROSE_READER_DEBUG?: boolean | string\n }\n}\n\nconst getWindow = () => {\n if (typeof window === \"undefined\") {\n return undefined\n }\n\n return window\n}\n\nfunction isGlobalDebugEnabled() {\n const debug = getWindow()?.__PROSE_READER_DEBUG\n\n return debug === true || debug === \"true\"\n}\n\nexport type Report = {\n namespace: (namespace: string, enabled?: boolean) => Report\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n debug: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n info: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n log: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n warn: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n error: (...args: any[]) => void\n}\n\nconst createReport = (\n namespace?: string,\n enabled = isGlobalDebugEnabled(),\n options?: {\n color?: string\n },\n): Report => {\n return {\n namespace: (_namespace: string, enabled?: boolean) =>\n createReport(`${namespace} [${_namespace}]`, enabled, options),\n debug: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.debug,\n console,\n namespace,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(\n console.debug,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n ),\n info: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.info,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(\n console.info,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n ),\n log: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.log,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(console.log, console),\n warn: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.warn,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(\n console.warn,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n ),\n error: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.error,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(\n console.error,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n ),\n }\n}\n\nexport const Report = {\n ...createReport(),\n namespace: (\n namespace: string,\n enabled?: boolean,\n options?: {\n color?: string\n },\n ) => createReport(`[${namespace}]`, enabled, options),\n}\n","export const PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME =\n \"prose-reader-resource-error\"\n"],"names":["arrayEqual","a","b","v","i","getUrlExtension","url","normalize","strArray","resultArray","component","str","parts","urlJoin","args","getParentPath","uri","detectMimeTypeFromName","name","isXmlBasedMimeType","mimeType","parseContentType","hasOwn","is","x","y","isShallowEqual","objectA","objectB","options","keysA","keysB","isEqual","key","groupBy","list","getKey","previous","currentItem","group","shallowMergeIfDefined","obj1","obj2","result","value","getWindow","isGlobalDebugEnabled","debug","createReport","namespace","enabled","_namespace","Report","PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME"],"mappings":"AACO,MAAMA,IAAa,CAAmCC,GAAMC,MAE7DD,MAAMC,IAAU,KAChBD,EAAE,WAAWC,EAAE,SAAe,KAE3BD,EAAE,MAAM,CAACE,GAAGC,MAAMD,MAAMD,EAAEE,CAAC,CAAC,GCNxBC,IAAkB,CAACC,MACvBA,EAAI,MAAM,MAAM,EAAE,CAAC,GAAG,MAAM,GAAG,EAAE,IAAA,GAAO,KAAA,KAAU;AAG3D,SAASC,EAAUC,GAAoB;AACrC,QAAMC,IAAc,CAAA;AACpB,MAAID,EAAS,WAAW;AACtB,WAAO;AAGT,MAAI,OAAOA,EAAS,CAAC,KAAM;AACzB,UAAM,IAAI,UAAU,kCAAkCA,EAAS,CAAC,CAAC,EAAE;AAIrE,EAAIA,EAAS,CAAC,EAAE,MAAM,cAAc,KAAKA,EAAS,SAAS,MACzDA,EAAS,CAAC,IAAIA,EAAS,MAAA,IAAUA,EAAS,CAAC,IA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","../src/objects.ts","../src/report.ts","../src/resources.ts"],"sourcesContent":["// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const arrayEqual = <A extends any[], B extends any[]>(a: A, b: B) => {\n // @ts-expect-error\n if (a === b) return true\n if (a.length !== b.length) return false\n\n return a.every((v, i) => v === b[i])\n}\n","export const getUrlExtension = (url: string) => {\n return url.split(/[#?]/)[0]?.split(`.`).pop()?.trim() || ``\n}\n\nfunction normalize(strArray: string[]) {\n const resultArray = []\n if (strArray.length === 0) {\n return \"\"\n }\n\n if (typeof strArray[0] !== \"string\") {\n throw new TypeError(`Url must be a string. Received ${strArray[0]}`)\n }\n\n // If the first part is a plain protocol, we combine it with the next part.\n if (strArray[0].match(/^[^/:]+:\\/*$/) && strArray.length > 1) {\n strArray[0] = strArray.shift() + strArray[0]\n }\n\n // There must be two or three slashes in the file protocol, two slashes in anything else.\n if (strArray[0].match(/^file:\\/\\/\\//)) {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1:///\")\n } else {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1://\")\n }\n\n for (let i = 0; i < strArray.length; i++) {\n let component = strArray[i]\n\n if (typeof component !== \"string\") {\n throw new TypeError(`Url must be a string. Received ${component}`)\n }\n\n if (component === \"\") {\n continue\n }\n\n if (i > 0) {\n // Removing the starting slashes for each component but the first.\n component = component.replace(/^[/]+/, \"\")\n }\n if (i < strArray.length - 1) {\n // Removing the ending slashes for each component but the last.\n component = component.replace(/[/]+$/, \"\")\n } else {\n // For the last component we will combine multiple slashes to a single one.\n component = component.replace(/[/]+$/, \"/\")\n }\n\n resultArray.push(component)\n }\n\n let str = resultArray.join(\"/\")\n // Each input component is now separated by a single slash except the possible first plain protocol part.\n\n // remove trailing slash before parameters or hash\n str = str.replace(/\\/(\\?|&|#[^!])/g, \"$1\")\n\n // replace ? in parameters with &\n const parts = str.split(\"?\")\n str = parts.shift() + (parts.length > 0 ? \"?\" : \"\") + parts.join(\"&\")\n\n return str\n}\n\nexport function urlJoin(...args: (string | string[])[]) {\n const parts = Array.from(Array.isArray(args[0]) ? args[0] : args) as string[]\n\n return normalize(parts)\n}\n\nexport function getParentPath(uri: string): string {\n const parts = uri.split(\"/\")\n\n parts.pop() // Remove the last segment\n\n return parts.join(\"/\")\n}\n","import { getUrlExtension } from \"./url\"\n\nexport const detectMimeTypeFromName = (name: string) => {\n const extension = getUrlExtension(name)\n\n switch (extension) {\n case `png`:\n return `image/png`\n case `jpg`:\n return `image/jpg`\n case `jpeg`:\n return `image/jpeg`\n case `txt`:\n return `text/plain`\n case `webp`:\n return `image/webp`\n case `xhtml`:\n return `application/xhtml+xml`\n }\n\n return undefined\n}\n\nexport const isXmlBasedMimeType = ({\n mimeType,\n uri,\n}: {\n uri?: string\n mimeType?: string\n}) => {\n const _mimeType = mimeType ?? detectMimeTypeFromName(uri ?? \"\")\n\n return _mimeType?.startsWith(`application/xhtml+xml`)\n}\n\nexport const parseContentType = (str: string) => {\n if (!str.length) return undefined\n\n const cut = str.indexOf(`;`)\n\n return cut ? str.substring(0, str.indexOf(`;`)) : str\n}\n","// MIT © 2017 azu\nconst hasOwn = Object.prototype.hasOwnProperty\n\n// Object.is polyfill\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const is = (x: any, y: any): boolean => {\n if (x === y) {\n return x !== 0 || y !== 0 || 1 / x === 1 / y\n }\n return false\n}\n\n/**\n * Return true, if `objectA` is shallow equal to `objectB`.\n * Pass Custom equality function to `customEqual`.\n * Default equality is `Object.is`\n * Support Array\n *\n * Options:\n *\n * - `customEqual`: function should return true if the `a` value is equal to `b` value.\n * - `debug`: enable debug info to console log. This log will be disable in production build\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const isShallowEqual = <T = any, R = any>(\n objectA: T,\n objectB: R,\n options?: {\n customEqual?: <T>(a: T, b: T) => boolean\n },\n): boolean => {\n // @ts-expect-error\n if (objectA === objectB) {\n return true\n }\n if (typeof objectA !== \"object\" || objectA === null) {\n return false\n }\n if (typeof objectB !== \"object\" || objectB === null) {\n return false\n }\n\n const keysA = Object.keys(objectA)\n const keysB = Object.keys(objectB)\n\n if (keysA.length !== keysB.length) {\n return false\n }\n\n const isEqual =\n options && typeof options.customEqual === \"function\"\n ? options.customEqual\n : is\n\n for (let i = 0; i < keysA.length; i++) {\n const key = keysA[i] || ``\n // @ts-expect-error\n if (!hasOwn.call(objectB, key) || !isEqual(objectA[key], objectB[key])) {\n return false\n }\n }\n\n return true\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const groupBy = <T, K extends keyof any>(\n list: T[],\n getKey: (item: T) => K,\n) =>\n list.reduce(\n (previous, currentItem) => {\n const group = getKey(currentItem)\n if (!previous[group]) previous[group] = []\n previous[group].push(currentItem)\n return previous\n },\n {} as Record<K, T[]>,\n )\n\nexport function shallowMergeIfDefined<T extends object, U extends object>(\n obj1: T,\n obj2: U,\n): T & U {\n const result = { ...obj1 } as T & U\n\n for (const key in obj2) {\n if (Object.hasOwn(obj2, key)) {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n const value = (obj2 as any)[key]\n if (value !== undefined || !(key in obj1)) {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n ;(result as any)[key] = value\n }\n }\n }\n\n return result\n}\n","declare global {\n interface Window {\n __PROSE_READER_DEBUG?: boolean | string\n }\n}\n\nconst getWindow = () => {\n if (typeof window === \"undefined\") {\n return undefined\n }\n\n return window\n}\n\nfunction isGlobalDebugEnabled() {\n const debug = getWindow()?.__PROSE_READER_DEBUG\n\n return debug === true || debug === \"true\"\n}\n\nexport type Report = {\n enable: (enabled: boolean) => void\n isEnabled: () => boolean\n namespace: (namespace: string, enabled?: boolean) => Report\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n debug: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n info: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n log: (...args: any[]) => void\n /** Use with getGroupArgs for namespace + color. Preserves call site. */\n groupCollapsed: (...args: unknown[]) => void\n groupEnd: () => void\n /** Returns [label, style?] to pass to groupCollapsed for namespace + color. */\n getGroupArgs: (title: string) => [string, string?] | [string]\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n warn: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n error: (...args: any[]) => void\n}\n\nconst createReport = (\n namespace?: string,\n enabled = isGlobalDebugEnabled(),\n options?: {\n color?: string\n },\n): Report => {\n let reportEnabled = enabled\n const color = options?.color ? `color: ${options.color}` : undefined\n\n const report: Report = {\n enable: (enabled: boolean) => {\n setEnabled(enabled)\n },\n namespace: (_namespace: string, enabled?: boolean) =>\n createReport(`${namespace} [${_namespace}]`, enabled, options),\n isEnabled: () => reportEnabled,\n debug: () => {},\n info: () => {},\n log: () => {},\n groupCollapsed: () => {},\n groupEnd: () => {},\n getGroupArgs: (title: string) =>\n color\n ? [`%c${namespace ? `${namespace} ${title}` : title}`, color]\n : [namespace ? `${namespace} ${title}` : title],\n warn: () => {},\n error: () => {},\n }\n\n // Keep direct prototype-bound console functions for enabled mode.\n // Wrapping console calls in closures changes call-site/stack behavior in devtools,\n // which makes runtime debugging harder to interpret.\n const applyEnabledState = (enabled: boolean) => {\n if (!enabled) {\n report.debug = () => {}\n report.info = () => {}\n report.log = () => {}\n report.groupCollapsed = () => {}\n report.groupEnd = () => {}\n report.warn = () => {}\n report.error = () => {}\n\n return\n }\n\n report.debug = namespace\n ? Function.prototype.bind.call(\n console.debug,\n console,\n namespace,\n `%c${namespace}`,\n color,\n )\n : Function.prototype.bind.call(\n console.debug,\n console,\n `%c${namespace}`,\n color,\n )\n report.info = Function.prototype.bind.call(\n console.info,\n console,\n `%c${namespace}`,\n color,\n )\n report.log = namespace\n ? Function.prototype.bind.call(\n console.log,\n console,\n `%c${namespace}`,\n color,\n )\n : Function.prototype.bind.call(console.log, console)\n report.groupCollapsed = Function.prototype.bind.call(\n console.groupCollapsed,\n console,\n )\n report.groupEnd = Function.prototype.bind.call(console.groupEnd, console)\n report.warn = Function.prototype.bind.call(\n console.warn,\n console,\n `%c${namespace}`,\n color,\n )\n report.error = Function.prototype.bind.call(\n console.error,\n console,\n `%c${namespace}`,\n color,\n )\n }\n\n const setEnabled = (enabled: boolean) => {\n if (reportEnabled === enabled) {\n return\n }\n\n reportEnabled = enabled\n applyEnabledState(reportEnabled)\n }\n\n applyEnabledState(reportEnabled)\n\n return report\n}\n\nexport const Report = {\n ...createReport(),\n namespace: (\n namespace: string,\n enabled?: boolean,\n options?: {\n color?: string\n },\n ) => createReport(`[${namespace}]`, enabled, options),\n}\n","export const PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME =\n \"prose-reader-resource-error\"\n"],"names":["arrayEqual","a","b","v","i","getUrlExtension","url","normalize","strArray","resultArray","component","str","parts","urlJoin","args","getParentPath","uri","detectMimeTypeFromName","name","isXmlBasedMimeType","mimeType","parseContentType","hasOwn","is","x","y","isShallowEqual","objectA","objectB","options","keysA","keysB","isEqual","key","groupBy","list","getKey","previous","currentItem","group","shallowMergeIfDefined","obj1","obj2","result","value","getWindow","isGlobalDebugEnabled","debug","createReport","namespace","enabled","reportEnabled","color","report","setEnabled","_namespace","title","applyEnabledState","Report","PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME"],"mappings":"AACO,MAAMA,IAAa,CAAmCC,GAAMC,MAE7DD,MAAMC,IAAU,KAChBD,EAAE,WAAWC,EAAE,SAAe,KAE3BD,EAAE,MAAM,CAACE,GAAGC,MAAMD,MAAMD,EAAEE,CAAC,CAAC,GCNxBC,IAAkB,CAACC,MACvBA,EAAI,MAAM,MAAM,EAAE,CAAC,GAAG,MAAM,GAAG,EAAE,IAAA,GAAO,KAAA,KAAU;AAG3D,SAASC,EAAUC,GAAoB;AACrC,QAAMC,IAAc,CAAA;AACpB,MAAID,EAAS,WAAW;AACtB,WAAO;AAGT,MAAI,OAAOA,EAAS,CAAC,KAAM;AACzB,UAAM,IAAI,UAAU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SAAS,UAAU,KAAK;AAAA,MACpC,QAAQ;AAAA,MACR;AAAA,MACA,KAAKJ,CAAS;AAAA,MACdG;AAAA,IAAA,GAEFC,EAAO,QAAQ,SAAS,UAAU,KAAK;AAAA,MACrC,QAAQ;AAAA,MACR;AAAA,MACA,KAAKJ,CAAS;AAAA,MACdG;AAAA,IAAA;AAAA,EAEJ,GAEME,IAAa,CAACJ,MAAqB;AACvC,IAAIC,MAAkBD,MAItBC,IAAgBD,GAChBO,EAAkBN,CAAa;AAAA,EACjC;AAEA,SAAAM,EAAkBN,CAAa,GAExBE;AACT,GAEaK,IAAS;AAAA,EACpB,GAAGV,EAAA;AAAA,EACH,WAAW,CACTC,GACAC,GACArB,MAGGmB,EAAa,IAAIC,CAAS,KAAKC,GAASrB,CAAO;AACtD,GC7Ja8B,IACX;"}
@@ -1,2 +1,2 @@
1
- (function(l,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(l=typeof globalThis<"u"?globalThis:l||self,i(l["prose-shared"]={}))})(this,(function(l){"use strict";const i=(e,n)=>e===n?!0:e.length!==n.length?!1:e.every((o,t)=>o===n[t]),d=e=>e.split(/[#?]/)[0]?.split(".").pop()?.trim()||"";function a(e){const n=[];if(e.length===0)return"";if(typeof e[0]!="string")throw new TypeError(`Url must be a string. Received ${e[0]}`);e[0].match(/^[^/:]+:\/*$/)&&e.length>1&&(e[0]=e.shift()+e[0]),e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(let r=0;r<e.length;r++){let c=e[r];if(typeof c!="string")throw new TypeError(`Url must be a string. Received ${c}`);c!==""&&(r>0&&(c=c.replace(/^[/]+/,"")),r<e.length-1?c=c.replace(/[/]+$/,""):c=c.replace(/[/]+$/,"/"),n.push(c))}let o=n.join("/");o=o.replace(/\/(\?|&|#[^!])/g,"$1");const t=o.split("?");return o=t.shift()+(t.length>0?"?":"")+t.join("&"),o}function h(...e){const n=Array.from(Array.isArray(e[0])?e[0]:e);return a(n)}function E(e){const n=e.split("/");return n.pop(),n.join("/")}const g=e=>{switch(d(e)){case"png":return"image/png";case"jpg":return"image/jpg";case"jpeg":return"image/jpeg";case"txt":return"text/plain";case"webp":return"image/webp";case"xhtml":return"application/xhtml+xml"}},y=({mimeType:e,uri:n})=>(e??g(n??""))?.startsWith("application/xhtml+xml"),$=e=>e.length?e.indexOf(";")?e.substring(0,e.indexOf(";")):e:void 0,R=Object.prototype.hasOwnProperty,p=(e,n)=>e===n?e!==0||n!==0||1/e===1/n:!1,m=(e,n,o)=>{if(e===n)return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;const t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;const c=o&&typeof o.customEqual=="function"?o.customEqual:p;for(let f=0;f<t.length;f++){const s=t[f]||"";if(!R.call(n,s)||!c(e[s],n[s]))return!1}return!0},w=(e,n)=>e.reduce((o,t)=>{const r=n(t);return o[r]||(o[r]=[]),o[r].push(t),o},{});function _(e,n){const o={...e};for(const t in n)if(Object.hasOwn(n,t)){const r=n[t];(r!==void 0||!(t in e))&&(o[t]=r)}return o}const O=()=>{if(!(typeof window>"u"))return window};function T(){const e=O()?.__PROSE_READER_DEBUG;return e===!0||e==="true"}const u=(e,n=T(),o)=>({namespace:(t,r)=>u(`${e} [${t}]`,r,o),debug:n?e?Function.prototype.bind.call(console.debug,console,e,`%c${e}`,o?.color?`color: ${o.color}`:void 0):Function.prototype.bind.call(console.debug,console,`%c${e}`,o?.color?`color: ${o.color}`:void 0):()=>{},info:n?e?Function.prototype.bind.call(console.info,console,`%c${e}`,o?.color?`color: ${o.color}`:void 0):Function.prototype.bind.call(console.info,console,`%c${e}`,o?.color?`color: ${o.color}`:void 0):()=>{},log:n?e?Function.prototype.bind.call(console.log,console,`%c${e}`,o?.color?`color: ${o.color}`:void 0):Function.prototype.bind.call(console.log,console):()=>{},warn:n?e?Function.prototype.bind.call(console.warn,console,`%c${e}`,o?.color?`color: ${o.color}`:void 0):Function.prototype.bind.call(console.warn,console,`%c${e}`,o?.color?`color: ${o.color}`:void 0):()=>{},error:n?e?Function.prototype.bind.call(console.error,console,`%c${e}`,o?.color?`color: ${o.color}`:void 0):Function.prototype.bind.call(console.error,console,`%c${e}`,o?.color?`color: ${o.color}`:void 0):()=>{}}),v={...u(),namespace:(e,n,o)=>u(`[${e}]`,n,o)},b="prose-reader-resource-error";l.PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME=b,l.Report=v,l.arrayEqual=i,l.detectMimeTypeFromName=g,l.getParentPath=E,l.getUrlExtension=d,l.groupBy=w,l.is=p,l.isShallowEqual=m,l.isXmlBasedMimeType=y,l.parseContentType=$,l.shallowMergeIfDefined=_,l.urlJoin=h,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i["prose-shared"]={}))})(this,(function(i){"use strict";const s=(e,n)=>e===n?!0:e.length!==n.length?!1:e.every((t,l)=>t===n[l]),d=e=>e.split(/[#?]/)[0]?.split(".").pop()?.trim()||"";function E(e){const n=[];if(e.length===0)return"";if(typeof e[0]!="string")throw new TypeError(`Url must be a string. Received ${e[0]}`);e[0].match(/^[^/:]+:\/*$/)&&e.length>1&&(e[0]=e.shift()+e[0]),e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,"$1:///"):e[0]=e[0].replace(/^([^/:]+):\/*/,"$1://");for(let r=0;r<e.length;r++){let o=e[r];if(typeof o!="string")throw new TypeError(`Url must be a string. Received ${o}`);o!==""&&(r>0&&(o=o.replace(/^[/]+/,"")),r<e.length-1?o=o.replace(/[/]+$/,""):o=o.replace(/[/]+$/,"/"),n.push(o))}let t=n.join("/");t=t.replace(/\/(\?|&|#[^!])/g,"$1");const l=t.split("?");return t=l.shift()+(l.length>0?"?":"")+l.join("&"),t}function h(...e){const n=Array.from(Array.isArray(e[0])?e[0]:e);return E(n)}function y(e){const n=e.split("/");return n.pop(),n.join("/")}const g=e=>{switch(d(e)){case"png":return"image/png";case"jpg":return"image/jpg";case"jpeg":return"image/jpeg";case"txt":return"text/plain";case"webp":return"image/webp";case"xhtml":return"application/xhtml+xml"}},m=({mimeType:e,uri:n})=>(e??g(n??""))?.startsWith("application/xhtml+xml"),R=e=>e.length?e.indexOf(";")?e.substring(0,e.indexOf(";")):e:void 0,w=Object.prototype.hasOwnProperty,a=(e,n)=>e===n?e!==0||n!==0||1/e===1/n:!1,$=(e,n,t)=>{if(e===n)return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;const l=Object.keys(e),r=Object.keys(n);if(l.length!==r.length)return!1;const o=t&&typeof t.customEqual=="function"?t.customEqual:a;for(let u=0;u<l.length;u++){const p=l[u]||"";if(!w.call(n,p)||!o(e[p],n[p]))return!1}return!0},b=(e,n)=>e.reduce((t,l)=>{const r=n(l);return t[r]||(t[r]=[]),t[r].push(l),t},{});function _(e,n){const t={...e};for(const l in n)if(Object.hasOwn(n,l)){const r=n[l];(r!==void 0||!(l in e))&&(t[l]=r)}return t}const O=()=>{if(!(typeof window>"u"))return window};function T(){const e=O()?.__PROSE_READER_DEBUG;return e===!0||e==="true"}const f=(e,n=T(),t)=>{let l=n;const r=t?.color?`color: ${t.color}`:void 0,o={enable:c=>{p(c)},namespace:(c,C)=>f(`${e} [${c}]`,C,t),isEnabled:()=>l,debug:()=>{},info:()=>{},log:()=>{},groupCollapsed:()=>{},groupEnd:()=>{},getGroupArgs:c=>r?[`%c${e?`${e} ${c}`:c}`,r]:[e?`${e} ${c}`:c],warn:()=>{},error:()=>{}},u=c=>{if(!c){o.debug=()=>{},o.info=()=>{},o.log=()=>{},o.groupCollapsed=()=>{},o.groupEnd=()=>{},o.warn=()=>{},o.error=()=>{};return}o.debug=e?Function.prototype.bind.call(console.debug,console,e,`%c${e}`,r):Function.prototype.bind.call(console.debug,console,`%c${e}`,r),o.info=Function.prototype.bind.call(console.info,console,`%c${e}`,r),o.log=e?Function.prototype.bind.call(console.log,console,`%c${e}`,r):Function.prototype.bind.call(console.log,console),o.groupCollapsed=Function.prototype.bind.call(console.groupCollapsed,console),o.groupEnd=Function.prototype.bind.call(console.groupEnd,console),o.warn=Function.prototype.bind.call(console.warn,console,`%c${e}`,r),o.error=Function.prototype.bind.call(console.error,console,`%c${e}`,r)},p=c=>{l!==c&&(l=c,u(l))};return u(l),o},F={...f(),namespace:(e,n,t)=>f(`[${e}]`,n,t)},M="prose-reader-resource-error";i.PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME=M,i.Report=F,i.arrayEqual=s,i.detectMimeTypeFromName=g,i.getParentPath=y,i.getUrlExtension=d,i.groupBy=b,i.is=a,i.isShallowEqual=$,i.isXmlBasedMimeType=m,i.parseContentType=R,i.shallowMergeIfDefined=_,i.urlJoin=h,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
2
2
  //# sourceMappingURL=index.umd.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.cjs","sources":["../src/array.ts","../src/url.ts","../src/contentType.ts","../src/objects.ts","../src/report.ts","../src/resources.ts"],"sourcesContent":["// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const arrayEqual = <A extends any[], B extends any[]>(a: A, b: B) => {\n // @ts-expect-error\n if (a === b) return true\n if (a.length !== b.length) return false\n\n return a.every((v, i) => v === b[i])\n}\n","export const getUrlExtension = (url: string) => {\n return url.split(/[#?]/)[0]?.split(`.`).pop()?.trim() || ``\n}\n\nfunction normalize(strArray: string[]) {\n const resultArray = []\n if (strArray.length === 0) {\n return \"\"\n }\n\n if (typeof strArray[0] !== \"string\") {\n throw new TypeError(`Url must be a string. Received ${strArray[0]}`)\n }\n\n // If the first part is a plain protocol, we combine it with the next part.\n if (strArray[0].match(/^[^/:]+:\\/*$/) && strArray.length > 1) {\n strArray[0] = strArray.shift() + strArray[0]\n }\n\n // There must be two or three slashes in the file protocol, two slashes in anything else.\n if (strArray[0].match(/^file:\\/\\/\\//)) {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1:///\")\n } else {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1://\")\n }\n\n for (let i = 0; i < strArray.length; i++) {\n let component = strArray[i]\n\n if (typeof component !== \"string\") {\n throw new TypeError(`Url must be a string. Received ${component}`)\n }\n\n if (component === \"\") {\n continue\n }\n\n if (i > 0) {\n // Removing the starting slashes for each component but the first.\n component = component.replace(/^[/]+/, \"\")\n }\n if (i < strArray.length - 1) {\n // Removing the ending slashes for each component but the last.\n component = component.replace(/[/]+$/, \"\")\n } else {\n // For the last component we will combine multiple slashes to a single one.\n component = component.replace(/[/]+$/, \"/\")\n }\n\n resultArray.push(component)\n }\n\n let str = resultArray.join(\"/\")\n // Each input component is now separated by a single slash except the possible first plain protocol part.\n\n // remove trailing slash before parameters or hash\n str = str.replace(/\\/(\\?|&|#[^!])/g, \"$1\")\n\n // replace ? in parameters with &\n const parts = str.split(\"?\")\n str = parts.shift() + (parts.length > 0 ? \"?\" : \"\") + parts.join(\"&\")\n\n return str\n}\n\nexport function urlJoin(...args: (string | string[])[]) {\n const parts = Array.from(Array.isArray(args[0]) ? args[0] : args) as string[]\n\n return normalize(parts)\n}\n\nexport function getParentPath(uri: string): string {\n const parts = uri.split(\"/\")\n\n parts.pop() // Remove the last segment\n\n return parts.join(\"/\")\n}\n","import { getUrlExtension } from \"./url\"\n\nexport const detectMimeTypeFromName = (name: string) => {\n const extension = getUrlExtension(name)\n\n switch (extension) {\n case `png`:\n return `image/png`\n case `jpg`:\n return `image/jpg`\n case `jpeg`:\n return `image/jpeg`\n case `txt`:\n return `text/plain`\n case `webp`:\n return `image/webp`\n case `xhtml`:\n return `application/xhtml+xml`\n }\n\n return undefined\n}\n\nexport const isXmlBasedMimeType = ({\n mimeType,\n uri,\n}: {\n uri?: string\n mimeType?: string\n}) => {\n const _mimeType = mimeType ?? detectMimeTypeFromName(uri ?? \"\")\n\n return _mimeType?.startsWith(`application/xhtml+xml`)\n}\n\nexport const parseContentType = (str: string) => {\n if (!str.length) return undefined\n\n const cut = str.indexOf(`;`)\n\n return cut ? str.substring(0, str.indexOf(`;`)) : str\n}\n","// MIT © 2017 azu\nconst hasOwn = Object.prototype.hasOwnProperty\n\n// Object.is polyfill\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const is = (x: any, y: any): boolean => {\n if (x === y) {\n return x !== 0 || y !== 0 || 1 / x === 1 / y\n }\n return false\n}\n\n/**\n * Return true, if `objectA` is shallow equal to `objectB`.\n * Pass Custom equality function to `customEqual`.\n * Default equality is `Object.is`\n * Support Array\n *\n * Options:\n *\n * - `customEqual`: function should return true if the `a` value is equal to `b` value.\n * - `debug`: enable debug info to console log. This log will be disable in production build\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const isShallowEqual = <T = any, R = any>(\n objectA: T,\n objectB: R,\n options?: {\n customEqual?: <T>(a: T, b: T) => boolean\n },\n): boolean => {\n // @ts-expect-error\n if (objectA === objectB) {\n return true\n }\n if (typeof objectA !== \"object\" || objectA === null) {\n return false\n }\n if (typeof objectB !== \"object\" || objectB === null) {\n return false\n }\n\n const keysA = Object.keys(objectA)\n const keysB = Object.keys(objectB)\n\n if (keysA.length !== keysB.length) {\n return false\n }\n\n const isEqual =\n options && typeof options.customEqual === \"function\"\n ? options.customEqual\n : is\n\n for (let i = 0; i < keysA.length; i++) {\n const key = keysA[i] || ``\n // @ts-expect-error\n if (!hasOwn.call(objectB, key) || !isEqual(objectA[key], objectB[key])) {\n return false\n }\n }\n\n return true\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const groupBy = <T, K extends keyof any>(\n list: T[],\n getKey: (item: T) => K,\n) =>\n list.reduce(\n (previous, currentItem) => {\n const group = getKey(currentItem)\n if (!previous[group]) previous[group] = []\n previous[group].push(currentItem)\n return previous\n },\n {} as Record<K, T[]>,\n )\n\nexport function shallowMergeIfDefined<T extends object, U extends object>(\n obj1: T,\n obj2: U,\n): T & U {\n const result = { ...obj1 } as T & U\n\n for (const key in obj2) {\n if (Object.hasOwn(obj2, key)) {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n const value = (obj2 as any)[key]\n if (value !== undefined || !(key in obj1)) {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n ;(result as any)[key] = value\n }\n }\n }\n\n return result\n}\n","declare global {\n interface Window {\n __PROSE_READER_DEBUG?: boolean | string\n }\n}\n\nconst getWindow = () => {\n if (typeof window === \"undefined\") {\n return undefined\n }\n\n return window\n}\n\nfunction isGlobalDebugEnabled() {\n const debug = getWindow()?.__PROSE_READER_DEBUG\n\n return debug === true || debug === \"true\"\n}\n\nexport type Report = {\n namespace: (namespace: string, enabled?: boolean) => Report\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n debug: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n info: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n log: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n warn: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n error: (...args: any[]) => void\n}\n\nconst createReport = (\n namespace?: string,\n enabled = isGlobalDebugEnabled(),\n options?: {\n color?: string\n },\n): Report => {\n return {\n namespace: (_namespace: string, enabled?: boolean) =>\n createReport(`${namespace} [${_namespace}]`, enabled, options),\n debug: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.debug,\n console,\n namespace,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(\n console.debug,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n ),\n info: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.info,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(\n console.info,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n ),\n log: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.log,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(console.log, console),\n warn: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.warn,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(\n console.warn,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n ),\n error: !enabled\n ? () => {}\n : namespace\n ? Function.prototype.bind.call(\n console.error,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n )\n : Function.prototype.bind.call(\n console.error,\n console,\n `%c${namespace}`,\n options?.color ? `color: ${options.color}` : undefined,\n ),\n }\n}\n\nexport const Report = {\n ...createReport(),\n namespace: (\n namespace: string,\n enabled?: boolean,\n options?: {\n color?: string\n },\n ) => createReport(`[${namespace}]`, enabled, options),\n}\n","export const PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME =\n \"prose-reader-resource-error\"\n"],"names":["arrayEqual","a","b","v","i","getUrlExtension","url","normalize","strArray","resultArray","component","str","parts","urlJoin","args","getParentPath","uri","detectMimeTypeFromName","name","isXmlBasedMimeType","mimeType","parseContentType","hasOwn","is","x","y","isShallowEqual","objectA","objectB","options","keysA","keysB","isEqual","key","groupBy","list","getKey","previous","currentItem","group","shallowMergeIfDefined","obj1","obj2","result","value","getWindow","isGlobalDebugEnabled","debug","createReport","namespace","enabled","_namespace","Report","PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME"],"mappings":"wOACO,MAAMA,EAAa,CAAmCC,EAAMC,IAE7DD,IAAMC,EAAU,GAChBD,EAAE,SAAWC,EAAE,OAAe,GAE3BD,EAAE,MAAM,CAACE,EAAGC,IAAMD,IAAM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EHD,EACE,SAAS,UAAU,KAAK,KACtB,QAAQ,KACR,QACA,KAAKA,CAAS,GACdpB,GAAS,MAAQ,UAAUA,EAAQ,KAAK,GAAK,MAAA,EAE/C,SAAS,UAAU,KAAK,KACtB,QAAQ,KACR,QACA,KAAKoB,CAAS,GACdpB,GAAS,MAAQ,UAAUA,EAAQ,KAAK,GAAK,MAAA,EAZjD,IAAM,CAAC,EAcX,IAAMqB,EAEFD,EACE,SAAS,UAAU,KAAK,KACtB,QAAQ,IACR,QACA,KAAKA,CAAS,GACdpB,GAAS,MAAQ,UAAUA,EAAQ,KAAK,GAAK,MAAA,EAE/C,SAAS,UAAU,KAAK,KAAK,QAAQ,IAAK,OAAO,EARnD,IAAM,CAAC,EASX,KAAOqB,EAEHD,EACE,SAAS,UAAU,KAAK,KACtB,QAAQ,KACR,QACA,KAAKA,CAAS,GACdpB,GAAS,MAAQ,UAAUA,EAAQ,KAAK,GAAK,MAAA,EAE/C,SAAS,UAAU,KAAK,KACtB,QAAQ,KACR,QACA,KAAKoB,CAAS,GACdpB,GAAS,MAAQ,UAAUA,EAAQ,KAAK,GAAK,MAAA,EAZjD,IAAM,CAAC,EAcX,MAAQqB,EAEJD,EACE,SAAS,UAAU,KAAK,KACtB,QAAQ,MACR,QACA,KAAKA,CAAS,GACdpB,GAAS,MAAQ,UAAUA,EAAQ,KAAK,GAAK,MAAA,EAE/C,SAAS,UAAU,KAAK,KACtB,QAAQ,MACR,QACA,KAAKoB,CAAS,GACdpB,GAAS,MAAQ,UAAUA,EAAQ,KAAK,GAAK,MAAA,EAZjD,IAAM,CAAC,CAaL,GAIGuB,EAAS,CACpB,GAAGJ,EAAA,EACH,UAAW,CACTC,EACAC,EACArB,IAGGmB,EAAa,IAAIC,CAAS,IAAKC,EAASrB,CAAO,CACtD,EC/HawB,EACX"}
1
+ {"version":3,"file":"index.umd.cjs","sources":["../src/array.ts","../src/url.ts","../src/contentType.ts","../src/objects.ts","../src/report.ts","../src/resources.ts"],"sourcesContent":["// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const arrayEqual = <A extends any[], B extends any[]>(a: A, b: B) => {\n // @ts-expect-error\n if (a === b) return true\n if (a.length !== b.length) return false\n\n return a.every((v, i) => v === b[i])\n}\n","export const getUrlExtension = (url: string) => {\n return url.split(/[#?]/)[0]?.split(`.`).pop()?.trim() || ``\n}\n\nfunction normalize(strArray: string[]) {\n const resultArray = []\n if (strArray.length === 0) {\n return \"\"\n }\n\n if (typeof strArray[0] !== \"string\") {\n throw new TypeError(`Url must be a string. Received ${strArray[0]}`)\n }\n\n // If the first part is a plain protocol, we combine it with the next part.\n if (strArray[0].match(/^[^/:]+:\\/*$/) && strArray.length > 1) {\n strArray[0] = strArray.shift() + strArray[0]\n }\n\n // There must be two or three slashes in the file protocol, two slashes in anything else.\n if (strArray[0].match(/^file:\\/\\/\\//)) {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1:///\")\n } else {\n strArray[0] = strArray[0].replace(/^([^/:]+):\\/*/, \"$1://\")\n }\n\n for (let i = 0; i < strArray.length; i++) {\n let component = strArray[i]\n\n if (typeof component !== \"string\") {\n throw new TypeError(`Url must be a string. Received ${component}`)\n }\n\n if (component === \"\") {\n continue\n }\n\n if (i > 0) {\n // Removing the starting slashes for each component but the first.\n component = component.replace(/^[/]+/, \"\")\n }\n if (i < strArray.length - 1) {\n // Removing the ending slashes for each component but the last.\n component = component.replace(/[/]+$/, \"\")\n } else {\n // For the last component we will combine multiple slashes to a single one.\n component = component.replace(/[/]+$/, \"/\")\n }\n\n resultArray.push(component)\n }\n\n let str = resultArray.join(\"/\")\n // Each input component is now separated by a single slash except the possible first plain protocol part.\n\n // remove trailing slash before parameters or hash\n str = str.replace(/\\/(\\?|&|#[^!])/g, \"$1\")\n\n // replace ? in parameters with &\n const parts = str.split(\"?\")\n str = parts.shift() + (parts.length > 0 ? \"?\" : \"\") + parts.join(\"&\")\n\n return str\n}\n\nexport function urlJoin(...args: (string | string[])[]) {\n const parts = Array.from(Array.isArray(args[0]) ? args[0] : args) as string[]\n\n return normalize(parts)\n}\n\nexport function getParentPath(uri: string): string {\n const parts = uri.split(\"/\")\n\n parts.pop() // Remove the last segment\n\n return parts.join(\"/\")\n}\n","import { getUrlExtension } from \"./url\"\n\nexport const detectMimeTypeFromName = (name: string) => {\n const extension = getUrlExtension(name)\n\n switch (extension) {\n case `png`:\n return `image/png`\n case `jpg`:\n return `image/jpg`\n case `jpeg`:\n return `image/jpeg`\n case `txt`:\n return `text/plain`\n case `webp`:\n return `image/webp`\n case `xhtml`:\n return `application/xhtml+xml`\n }\n\n return undefined\n}\n\nexport const isXmlBasedMimeType = ({\n mimeType,\n uri,\n}: {\n uri?: string\n mimeType?: string\n}) => {\n const _mimeType = mimeType ?? detectMimeTypeFromName(uri ?? \"\")\n\n return _mimeType?.startsWith(`application/xhtml+xml`)\n}\n\nexport const parseContentType = (str: string) => {\n if (!str.length) return undefined\n\n const cut = str.indexOf(`;`)\n\n return cut ? str.substring(0, str.indexOf(`;`)) : str\n}\n","// MIT © 2017 azu\nconst hasOwn = Object.prototype.hasOwnProperty\n\n// Object.is polyfill\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const is = (x: any, y: any): boolean => {\n if (x === y) {\n return x !== 0 || y !== 0 || 1 / x === 1 / y\n }\n return false\n}\n\n/**\n * Return true, if `objectA` is shallow equal to `objectB`.\n * Pass Custom equality function to `customEqual`.\n * Default equality is `Object.is`\n * Support Array\n *\n * Options:\n *\n * - `customEqual`: function should return true if the `a` value is equal to `b` value.\n * - `debug`: enable debug info to console log. This log will be disable in production build\n */\n\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const isShallowEqual = <T = any, R = any>(\n objectA: T,\n objectB: R,\n options?: {\n customEqual?: <T>(a: T, b: T) => boolean\n },\n): boolean => {\n // @ts-expect-error\n if (objectA === objectB) {\n return true\n }\n if (typeof objectA !== \"object\" || objectA === null) {\n return false\n }\n if (typeof objectB !== \"object\" || objectB === null) {\n return false\n }\n\n const keysA = Object.keys(objectA)\n const keysB = Object.keys(objectB)\n\n if (keysA.length !== keysB.length) {\n return false\n }\n\n const isEqual =\n options && typeof options.customEqual === \"function\"\n ? options.customEqual\n : is\n\n for (let i = 0; i < keysA.length; i++) {\n const key = keysA[i] || ``\n // @ts-expect-error\n if (!hasOwn.call(objectB, key) || !isEqual(objectA[key], objectB[key])) {\n return false\n }\n }\n\n return true\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: TODO\nexport const groupBy = <T, K extends keyof any>(\n list: T[],\n getKey: (item: T) => K,\n) =>\n list.reduce(\n (previous, currentItem) => {\n const group = getKey(currentItem)\n if (!previous[group]) previous[group] = []\n previous[group].push(currentItem)\n return previous\n },\n {} as Record<K, T[]>,\n )\n\nexport function shallowMergeIfDefined<T extends object, U extends object>(\n obj1: T,\n obj2: U,\n): T & U {\n const result = { ...obj1 } as T & U\n\n for (const key in obj2) {\n if (Object.hasOwn(obj2, key)) {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n const value = (obj2 as any)[key]\n if (value !== undefined || !(key in obj1)) {\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n ;(result as any)[key] = value\n }\n }\n }\n\n return result\n}\n","declare global {\n interface Window {\n __PROSE_READER_DEBUG?: boolean | string\n }\n}\n\nconst getWindow = () => {\n if (typeof window === \"undefined\") {\n return undefined\n }\n\n return window\n}\n\nfunction isGlobalDebugEnabled() {\n const debug = getWindow()?.__PROSE_READER_DEBUG\n\n return debug === true || debug === \"true\"\n}\n\nexport type Report = {\n enable: (enabled: boolean) => void\n isEnabled: () => boolean\n namespace: (namespace: string, enabled?: boolean) => Report\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n debug: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n info: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n log: (...args: any[]) => void\n /** Use with getGroupArgs for namespace + color. Preserves call site. */\n groupCollapsed: (...args: unknown[]) => void\n groupEnd: () => void\n /** Returns [label, style?] to pass to groupCollapsed for namespace + color. */\n getGroupArgs: (title: string) => [string, string?] | [string]\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n warn: (...args: any[]) => void\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n error: (...args: any[]) => void\n}\n\nconst createReport = (\n namespace?: string,\n enabled = isGlobalDebugEnabled(),\n options?: {\n color?: string\n },\n): Report => {\n let reportEnabled = enabled\n const color = options?.color ? `color: ${options.color}` : undefined\n\n const report: Report = {\n enable: (enabled: boolean) => {\n setEnabled(enabled)\n },\n namespace: (_namespace: string, enabled?: boolean) =>\n createReport(`${namespace} [${_namespace}]`, enabled, options),\n isEnabled: () => reportEnabled,\n debug: () => {},\n info: () => {},\n log: () => {},\n groupCollapsed: () => {},\n groupEnd: () => {},\n getGroupArgs: (title: string) =>\n color\n ? [`%c${namespace ? `${namespace} ${title}` : title}`, color]\n : [namespace ? `${namespace} ${title}` : title],\n warn: () => {},\n error: () => {},\n }\n\n // Keep direct prototype-bound console functions for enabled mode.\n // Wrapping console calls in closures changes call-site/stack behavior in devtools,\n // which makes runtime debugging harder to interpret.\n const applyEnabledState = (enabled: boolean) => {\n if (!enabled) {\n report.debug = () => {}\n report.info = () => {}\n report.log = () => {}\n report.groupCollapsed = () => {}\n report.groupEnd = () => {}\n report.warn = () => {}\n report.error = () => {}\n\n return\n }\n\n report.debug = namespace\n ? Function.prototype.bind.call(\n console.debug,\n console,\n namespace,\n `%c${namespace}`,\n color,\n )\n : Function.prototype.bind.call(\n console.debug,\n console,\n `%c${namespace}`,\n color,\n )\n report.info = Function.prototype.bind.call(\n console.info,\n console,\n `%c${namespace}`,\n color,\n )\n report.log = namespace\n ? Function.prototype.bind.call(\n console.log,\n console,\n `%c${namespace}`,\n color,\n )\n : Function.prototype.bind.call(console.log, console)\n report.groupCollapsed = Function.prototype.bind.call(\n console.groupCollapsed,\n console,\n )\n report.groupEnd = Function.prototype.bind.call(console.groupEnd, console)\n report.warn = Function.prototype.bind.call(\n console.warn,\n console,\n `%c${namespace}`,\n color,\n )\n report.error = Function.prototype.bind.call(\n console.error,\n console,\n `%c${namespace}`,\n color,\n )\n }\n\n const setEnabled = (enabled: boolean) => {\n if (reportEnabled === enabled) {\n return\n }\n\n reportEnabled = enabled\n applyEnabledState(reportEnabled)\n }\n\n applyEnabledState(reportEnabled)\n\n return report\n}\n\nexport const Report = {\n ...createReport(),\n namespace: (\n namespace: string,\n enabled?: boolean,\n options?: {\n color?: string\n },\n ) => createReport(`[${namespace}]`, enabled, options),\n}\n","export const PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME =\n \"prose-reader-resource-error\"\n"],"names":["arrayEqual","a","b","v","i","getUrlExtension","url","normalize","strArray","resultArray","component","str","parts","urlJoin","args","getParentPath","uri","detectMimeTypeFromName","name","isXmlBasedMimeType","mimeType","parseContentType","hasOwn","is","x","y","isShallowEqual","objectA","objectB","options","keysA","keysB","isEqual","key","groupBy","list","getKey","previous","currentItem","group","shallowMergeIfDefined","obj1","obj2","result","value","getWindow","isGlobalDebugEnabled","debug","createReport","namespace","enabled","reportEnabled","color","report","setEnabled","_namespace","title","applyEnabledState","Report","PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME"],"mappings":"wOACO,MAAMA,EAAa,CAAmCC,EAAMC,IAE7DD,IAAMC,EAAU,GAChBD,EAAE,SAAWC,EAAE,OAAe,GAE3BD,EAAE,MAAM,CAACE,EAAGC,IAAMD,IAAMD,EAAEE,CAAC,CAAC,ECNxBC,EAAmBC,GACvBA,EAAI,MAAM,MAAM,EAAE,CAAC,GAAG,MAAM,GAAG,EAAE,IAAA,GAAO,KAAA,GAAU,GAG3D,SAASC,EAAUC,EAAoB,CACrC,MAAMC,EAAc,CAAA,EACpB,GAAID,EAAS,SAAW,EACtB,MAAO,GAGT,GAAI,OAAOA,EAAS,CAAC,GAAM,SACzB,MAAM,IAAI,UAAU,kCAAkCA,EAAS,CAAC,CAAC,EAAE,EAIjEA,E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+ isEnabled: () => boolean;
7
9
  namespace: (namespace: string, enabled?: boolean) => Report;
8
10
  debug: (...args: any[]) => void;
9
11
  info: (...args: any[]) => void;
10
12
  log: (...args: any[]) => void;
13
+ groupCollapsed: (...args: unknown[]) => void;
14
+ groupEnd: () => void;
15
+ getGroupArgs: (title: string) => [string, string?] | [string];
11
16
  warn: (...args: any[]) => void;
12
17
  error: (...args: any[]) => void;
13
18
  };
@@ -15,9 +20,14 @@ export declare const Report: {
15
20
  namespace: (namespace: string, enabled?: boolean, options?: {
16
21
  color?: string;
17
22
  }) => Report;
23
+ enable: (enabled: boolean) => void;
24
+ isEnabled: () => boolean;
18
25
  debug: (...args: any[]) => void;
19
26
  info: (...args: any[]) => void;
20
27
  log: (...args: any[]) => void;
28
+ groupCollapsed: (...args: unknown[]) => void;
29
+ groupEnd: () => void;
30
+ getGroupArgs: (title: string) => [string, string?] | [string];
21
31
  warn: (...args: any[]) => void;
22
32
  error: (...args: any[]) => void;
23
33
  };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prose-reader/shared",
3
- "version": "1.275.0",
3
+ "version": "1.277.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",
@@ -20,5 +20,5 @@
20
20
  "build": "tsc && vite build",
21
21
  "test": "vitest run --coverage"
22
22
  },
23
- "gitHead": "f1f2246b951a8cf93d0aeb61ed1fb390d291282f"
23
+ "gitHead": "2a941001e0085bcf2360a54ef2441cbc10bf1744"
24
24
  }