@prose-reader/shared 1.290.0 → 1.291.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 +106 -80
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/dist/report.d.ts +15 -17
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
1
|
+
const y = (e, o) => e === o ? !0 : e.length !== o.length ? !1 : e.every((t, n) => t === o[n]), f = (e) => e.split(/[#?]/)[0]?.split(".").pop()?.trim() || "";
|
|
2
|
+
function d(e) {
|
|
3
3
|
const o = [];
|
|
4
4
|
if (e.length === 0)
|
|
5
5
|
return "";
|
|
@@ -7,26 +7,26 @@ function g(e) {
|
|
|
7
7
|
throw new TypeError(`Url must be a string. Received ${e[0]}`);
|
|
8
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
9
|
for (let r = 0; r < e.length; r++) {
|
|
10
|
-
let
|
|
11
|
-
if (typeof
|
|
12
|
-
throw new TypeError(`Url must be a string. Received ${
|
|
13
|
-
|
|
10
|
+
let l = e[r];
|
|
11
|
+
if (typeof l != "string")
|
|
12
|
+
throw new TypeError(`Url must be a string. Received ${l}`);
|
|
13
|
+
l !== "" && (r > 0 && (l = l.replace(/^[/]+/, "")), r < e.length - 1 ? l = l.replace(/[/]+$/, "") : l = l.replace(/[/]+$/, "/"), o.push(l));
|
|
14
14
|
}
|
|
15
15
|
let t = o.join("/");
|
|
16
16
|
t = t.replace(/\/(\?|&|#[^!])/g, "$1");
|
|
17
|
-
const
|
|
18
|
-
return t =
|
|
17
|
+
const n = t.split("?");
|
|
18
|
+
return t = n.shift() + (n.length > 0 ? "?" : "") + n.join("&"), t;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function R(...e) {
|
|
21
21
|
const o = Array.from(Array.isArray(e[0]) ? e[0] : e);
|
|
22
|
-
return
|
|
22
|
+
return d(o);
|
|
23
23
|
}
|
|
24
24
|
function $(e) {
|
|
25
25
|
const o = e.split("/");
|
|
26
26
|
return o.pop(), o.join("/");
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
switch (
|
|
28
|
+
const h = (e) => {
|
|
29
|
+
switch (f(e)) {
|
|
30
30
|
case "png":
|
|
31
31
|
return "image/png";
|
|
32
32
|
case "jpg":
|
|
@@ -56,58 +56,91 @@ const d = (e) => {
|
|
|
56
56
|
case "opus":
|
|
57
57
|
return "audio/opus";
|
|
58
58
|
}
|
|
59
|
-
},
|
|
59
|
+
}, x = ({
|
|
60
60
|
mimeType: e,
|
|
61
61
|
uri: o
|
|
62
|
-
}) => (e ??
|
|
62
|
+
}) => (e ?? h(o ?? ""))?.startsWith("application/xhtml+xml"), _ = (e) => e.startsWith("image/") || e.startsWith("audio/") || e.startsWith("video/"), C = (e) => {
|
|
63
63
|
if (!e.length) return;
|
|
64
64
|
const o = e.indexOf(";");
|
|
65
65
|
return o >= 0 ? e.substring(0, o) : e;
|
|
66
|
-
},
|
|
66
|
+
}, v = (e, o, t) => {
|
|
67
67
|
if (Object.is(e, o))
|
|
68
68
|
return !0;
|
|
69
69
|
if (typeof e != "object" || e === null || typeof o != "object" || o === null)
|
|
70
70
|
return !1;
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
71
|
+
const n = Object.keys(e), r = Object.keys(o);
|
|
72
|
+
if (n.length !== r.length)
|
|
73
73
|
return !1;
|
|
74
|
-
const
|
|
75
|
-
for (const i of
|
|
76
|
-
if (!Object.hasOwn(
|
|
74
|
+
const l = t?.customEqual ?? Object.is, c = e, s = o;
|
|
75
|
+
for (const i of n)
|
|
76
|
+
if (!Object.hasOwn(s, i) || !l(c[i], s[i]))
|
|
77
77
|
return !1;
|
|
78
78
|
return !0;
|
|
79
|
-
},
|
|
80
|
-
(t,
|
|
81
|
-
const r = o(
|
|
82
|
-
return t[r] || (t[r] = []), t[r].push(
|
|
79
|
+
}, F = (e, o) => e.reduce(
|
|
80
|
+
(t, n) => {
|
|
81
|
+
const r = o(n);
|
|
82
|
+
return t[r] || (t[r] = []), t[r].push(n), t;
|
|
83
83
|
},
|
|
84
84
|
{}
|
|
85
85
|
);
|
|
86
|
-
function
|
|
86
|
+
function T(e, o) {
|
|
87
87
|
const t = { ...e };
|
|
88
|
-
for (const
|
|
89
|
-
if (Object.hasOwn(o,
|
|
90
|
-
const r = o[
|
|
91
|
-
(r !== void 0 || !(
|
|
88
|
+
for (const n in o)
|
|
89
|
+
if (Object.hasOwn(o, n)) {
|
|
90
|
+
const r = o[n];
|
|
91
|
+
(r !== void 0 || !(n in e)) && (t[n] = r);
|
|
92
92
|
}
|
|
93
93
|
return t;
|
|
94
94
|
}
|
|
95
|
-
const
|
|
95
|
+
const E = () => {
|
|
96
96
|
if (!(typeof window > "u"))
|
|
97
97
|
return window;
|
|
98
98
|
};
|
|
99
|
-
function
|
|
100
|
-
const e =
|
|
99
|
+
function b() {
|
|
100
|
+
const e = E()?.__PROSE_READER_DEBUG;
|
|
101
101
|
return e === !0 || e === "true";
|
|
102
102
|
}
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
const m = (e, o) => typeof e == "boolean" ? {
|
|
104
|
+
enabled: e,
|
|
105
|
+
options: o
|
|
106
|
+
} : {
|
|
107
|
+
enabled: e?.enabled,
|
|
108
|
+
options: e ?? o
|
|
109
|
+
}, w = (e) => e.at(-1)?.color, u = (e) => {
|
|
110
|
+
if (!e.length)
|
|
111
|
+
return;
|
|
112
|
+
if (!e.some((n) => n.color))
|
|
113
|
+
return [e.map((n) => n.label).join(" ")];
|
|
114
|
+
let o = "";
|
|
115
|
+
const t = [];
|
|
116
|
+
for (const n of e)
|
|
117
|
+
o += `%c${o ? ` ${n.label}` : n.label}`, t.push(
|
|
118
|
+
n.color ? `color: ${n.color}` : ""
|
|
119
|
+
);
|
|
120
|
+
return [o, ...t];
|
|
121
|
+
}, p = (e = [], o = b()) => {
|
|
122
|
+
let t = o;
|
|
123
|
+
const n = {
|
|
124
|
+
enable: (c) => {
|
|
125
|
+
l(c);
|
|
126
|
+
},
|
|
127
|
+
namespace: (c, s, i) => {
|
|
128
|
+
const a = m(
|
|
129
|
+
s,
|
|
130
|
+
i
|
|
131
|
+
), g = a.options?.color ?? w(e);
|
|
132
|
+
return p(
|
|
133
|
+
[
|
|
134
|
+
...e,
|
|
135
|
+
{
|
|
136
|
+
label: `[${c}]`,
|
|
137
|
+
color: g
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
a.enabled ?? t
|
|
141
|
+
);
|
|
108
142
|
},
|
|
109
|
-
|
|
110
|
-
isEnabled: () => l,
|
|
143
|
+
isEnabled: () => t,
|
|
111
144
|
debug: () => {
|
|
112
145
|
},
|
|
113
146
|
info: () => {
|
|
@@ -118,13 +151,19 @@ const s = (e, o = h(), t) => {
|
|
|
118
151
|
},
|
|
119
152
|
groupEnd: () => {
|
|
120
153
|
},
|
|
121
|
-
getGroupArgs: (
|
|
154
|
+
getGroupArgs: (c) => {
|
|
155
|
+
const s = u(e);
|
|
156
|
+
if (!s)
|
|
157
|
+
return [c];
|
|
158
|
+
const [i, ...a] = s;
|
|
159
|
+
return [`${i} ${c}`, ...a];
|
|
160
|
+
},
|
|
122
161
|
warn: () => {
|
|
123
162
|
},
|
|
124
163
|
error: () => {
|
|
125
164
|
}
|
|
126
|
-
},
|
|
127
|
-
if (!
|
|
165
|
+
}, r = (c) => {
|
|
166
|
+
if (!c) {
|
|
128
167
|
n.debug = () => {
|
|
129
168
|
}, n.info = () => {
|
|
130
169
|
}, n.log = () => {
|
|
@@ -135,62 +174,49 @@ const s = (e, o = h(), t) => {
|
|
|
135
174
|
};
|
|
136
175
|
return;
|
|
137
176
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
console,
|
|
141
|
-
e,
|
|
142
|
-
`%c${e}`,
|
|
143
|
-
r
|
|
144
|
-
) : Function.prototype.bind.call(
|
|
177
|
+
const s = u(e) ?? [];
|
|
178
|
+
n.debug = Function.prototype.bind.call(
|
|
145
179
|
console.debug,
|
|
146
180
|
console,
|
|
147
|
-
|
|
148
|
-
r
|
|
181
|
+
...s
|
|
149
182
|
), n.info = Function.prototype.bind.call(
|
|
150
183
|
console.info,
|
|
151
184
|
console,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
), n.log = e ? Function.prototype.bind.call(
|
|
185
|
+
...s
|
|
186
|
+
), n.log = Function.prototype.bind.call(
|
|
155
187
|
console.log,
|
|
156
188
|
console,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
) : Function.prototype.bind.call(console.log, console), n.groupCollapsed = Function.prototype.bind.call(
|
|
189
|
+
...s
|
|
190
|
+
), n.groupCollapsed = Function.prototype.bind.call(
|
|
160
191
|
console.groupCollapsed,
|
|
161
192
|
console
|
|
162
193
|
), n.groupEnd = Function.prototype.bind.call(console.groupEnd, console), n.warn = Function.prototype.bind.call(
|
|
163
194
|
console.warn,
|
|
164
195
|
console,
|
|
165
|
-
|
|
166
|
-
r
|
|
196
|
+
...s
|
|
167
197
|
), n.error = Function.prototype.bind.call(
|
|
168
198
|
console.error,
|
|
169
199
|
console,
|
|
170
|
-
|
|
171
|
-
r
|
|
200
|
+
...s
|
|
172
201
|
);
|
|
173
|
-
},
|
|
174
|
-
|
|
202
|
+
}, l = (c) => {
|
|
203
|
+
t !== c && (t = c, r(t));
|
|
175
204
|
};
|
|
176
|
-
return
|
|
177
|
-
},
|
|
178
|
-
...s(),
|
|
179
|
-
namespace: (e, o, t) => s(`[${e}]`, o, t)
|
|
180
|
-
}, F = "prose-reader-resource-error";
|
|
205
|
+
return r(t), n;
|
|
206
|
+
}, M = p(), O = "prose-reader-resource-error";
|
|
181
207
|
export {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
208
|
+
O as PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME,
|
|
209
|
+
M as Report,
|
|
210
|
+
y as arrayEqual,
|
|
211
|
+
h as detectMimeTypeFromName,
|
|
186
212
|
$ as getParentPath,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
213
|
+
f as getUrlExtension,
|
|
214
|
+
F as groupBy,
|
|
215
|
+
_ as isMediaContentMimeType,
|
|
216
|
+
v as isShallowEqual,
|
|
217
|
+
x as isXmlBasedMimeType,
|
|
218
|
+
C as parseContentType,
|
|
219
|
+
T as shallowMergeIfDefined,
|
|
220
|
+
R as urlJoin
|
|
195
221
|
};
|
|
196
222
|
//# 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 case `mp3`:\n return `audio/mpeg`\n case `m4a`:\n case `m4b`:\n return `audio/mp4`\n case `aac`:\n return `audio/aac`\n case `ogg`:\n case `oga`:\n return `audio/ogg`\n case `wav`:\n return `audio/wav`\n case `flac`:\n return `audio/flac`\n case `opus`:\n return `audio/opus`\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\n/**\n * Discrete media MIME types represent a single self-contained unit\n * (an image, an audio track, a video clip) as opposed to document\n * content that may need reflowable layout.\n */\nexport const isMediaContentMimeType = (mimeType: string) =>\n mimeType.startsWith(\"image/\") ||\n mimeType.startsWith(\"audio/\") ||\n mimeType.startsWith(\"video/\")\n\nexport const parseContentType = (str: string) => {\n if (!str.length) return undefined\n\n const cut = str.indexOf(`;`)\n\n return cut >= 0 ? str.substring(0, cut) : str\n}\n","/**\n * Return true if `objectA` is shallow equal to `objectB`.\n *\n * - Primitives are compared with `Object.is` (so `NaN === NaN`, `+0 ≠ -0`).\n * - Objects and arrays are compared by their own enumerable string keys,\n * each value pair compared with `Object.is` (or `customEqual`).\n * - Two objects with the same keys but different prototypes are considered\n * equal — class identity is not checked.\n *\n * Pass `customEqual` to override the per-value comparator (e.g. to recurse\n * one level deeper, or to compare specific value types by content).\n */\nexport const isShallowEqual = <A = unknown, B = unknown>(\n objectA: A,\n objectB: B,\n options?: {\n customEqual?: (a: unknown, b: unknown) => boolean\n },\n): boolean => {\n if (Object.is(objectA, objectB)) {\n return true\n }\n if (\n typeof objectA !== \"object\" ||\n objectA === null ||\n typeof objectB !== \"object\" ||\n objectB === null\n ) {\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 = options?.customEqual ?? Object.is\n\n // Indexable cast after narrowing to non-null `object`: TypeScript doesn't\n // widen `object` itself, but every iterated key is verified as own via\n // `Object.keys` / `Object.hasOwn`.\n const a = objectA as Record<string, unknown>\n const b = objectB as Record<string, unknown>\n\n for (const key of keysA) {\n if (!Object.hasOwn(b, key) || !isEqual(a[key], b[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","isMediaContentMimeType","parseContentType","cut","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,kCAAkCA,EAAS,CAAC,CAAC,EAAE;AAIrE,EAAIA,EAAS,CAAC,EAAE,MAAM,cAAc,KAAKA,EAAS,SAAS,MACzDA,EAAS,CAAC,IAAIA,EAAS,MAAA,IAAUA,EAAS,CAAC,IAIzCA,EAAS,CAAC,EAAE,MAAM,cAAc,IAClCA,EAAS,CAAC,IAAIA,EAAS,CAAC,EAA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A,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
|
+
{"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 case `mp3`:\n return `audio/mpeg`\n case `m4a`:\n case `m4b`:\n return `audio/mp4`\n case `aac`:\n return `audio/aac`\n case `ogg`:\n case `oga`:\n return `audio/ogg`\n case `wav`:\n return `audio/wav`\n case `flac`:\n return `audio/flac`\n case `opus`:\n return `audio/opus`\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\n/**\n * Discrete media MIME types represent a single self-contained unit\n * (an image, an audio track, a video clip) as opposed to document\n * content that may need reflowable layout.\n */\nexport const isMediaContentMimeType = (mimeType: string) =>\n mimeType.startsWith(\"image/\") ||\n mimeType.startsWith(\"audio/\") ||\n mimeType.startsWith(\"video/\")\n\nexport const parseContentType = (str: string) => {\n if (!str.length) return undefined\n\n const cut = str.indexOf(`;`)\n\n return cut >= 0 ? str.substring(0, cut) : str\n}\n","/**\n * Return true if `objectA` is shallow equal to `objectB`.\n *\n * - Primitives are compared with `Object.is` (so `NaN === NaN`, `+0 ≠ -0`).\n * - Objects and arrays are compared by their own enumerable string keys,\n * each value pair compared with `Object.is` (or `customEqual`).\n * - Two objects with the same keys but different prototypes are considered\n * equal — class identity is not checked.\n *\n * Pass `customEqual` to override the per-value comparator (e.g. to recurse\n * one level deeper, or to compare specific value types by content).\n */\nexport const isShallowEqual = <A = unknown, B = unknown>(\n objectA: A,\n objectB: B,\n options?: {\n customEqual?: (a: unknown, b: unknown) => boolean\n },\n): boolean => {\n if (Object.is(objectA, objectB)) {\n return true\n }\n if (\n typeof objectA !== \"object\" ||\n objectA === null ||\n typeof objectB !== \"object\" ||\n objectB === null\n ) {\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 = options?.customEqual ?? Object.is\n\n // Indexable cast after narrowing to non-null `object`: TypeScript doesn't\n // widen `object` itself, but every iterated key is verified as own via\n // `Object.keys` / `Object.hasOwn`.\n const a = objectA as Record<string, unknown>\n const b = objectB as Record<string, unknown>\n\n for (const key of keysA) {\n if (!Object.hasOwn(b, key) || !isEqual(a[key], b[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","/**\n * This report class needs to be fast because it is used in hot path. The disabled state\n * should not trigger any i/o and be no op operations.\n * The logging should keep the original stack trace.\n */\n\ndeclare 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 ReportOptions = {\n color?: string\n}\n\nexport type ReportNamespaceOptions = ReportOptions & {\n enabled?: boolean\n}\n\ntype ReportNamespace = {\n (namespace: string, enabled?: boolean, options?: ReportOptions): Report\n (namespace: string, options?: ReportNamespaceOptions): Report\n}\n\ntype ReportGroupArgs = [label: string, ...styles: string[]]\n\ntype NamespaceSegment = {\n label: string\n color?: string\n}\n\nexport type Report = {\n enable: (enabled: boolean) => void\n isEnabled: () => boolean\n namespace: ReportNamespace\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, ...styles] to pass to groupCollapsed for namespace + color. */\n getGroupArgs: (title: string) => ReportGroupArgs\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 getNamespaceArgs = (\n enabledOrOptions?: boolean | ReportNamespaceOptions,\n options?: ReportOptions,\n) => {\n if (typeof enabledOrOptions === \"boolean\") {\n return {\n enabled: enabledOrOptions,\n options,\n }\n }\n\n return {\n enabled: enabledOrOptions?.enabled,\n options: enabledOrOptions ?? options,\n }\n}\n\nconst getCurrentColor = (namespaceSegments: NamespaceSegment[]) =>\n namespaceSegments.at(-1)?.color\n\nconst getStyledNamespaceArgs = (\n namespaceSegments: NamespaceSegment[],\n): ReportGroupArgs | undefined => {\n if (!namespaceSegments.length) {\n return undefined\n }\n\n if (!namespaceSegments.some((segment) => segment.color)) {\n return [namespaceSegments.map((segment) => segment.label).join(\" \")]\n }\n\n let label = \"\"\n const styles: string[] = []\n\n for (const namespaceSegment of namespaceSegments) {\n label += `%c${label ? ` ${namespaceSegment.label}` : namespaceSegment.label}`\n styles.push(\n namespaceSegment.color ? `color: ${namespaceSegment.color}` : \"\",\n )\n }\n\n return [label, ...styles]\n}\n\nconst createReport = (\n namespaceSegments: NamespaceSegment[] = [],\n enabled = isGlobalDebugEnabled(),\n): Report => {\n let reportEnabled = enabled\n\n const report: Report = {\n enable: (enabled: boolean) => {\n setEnabled(enabled)\n },\n namespace: (\n _namespace: string,\n enabledOrOptions?: boolean | ReportNamespaceOptions,\n namespaceOptions?: ReportOptions,\n ) => {\n const childNamespaceArgs = getNamespaceArgs(\n enabledOrOptions,\n namespaceOptions,\n )\n\n const childColor =\n childNamespaceArgs.options?.color ?? getCurrentColor(namespaceSegments)\n\n return createReport(\n [\n ...namespaceSegments,\n {\n label: `[${_namespace}]`,\n color: childColor,\n },\n ],\n childNamespaceArgs.enabled ?? reportEnabled,\n )\n },\n isEnabled: () => reportEnabled,\n debug: () => {},\n info: () => {},\n log: () => {},\n groupCollapsed: () => {},\n groupEnd: () => {},\n getGroupArgs: (title: string) => {\n const namespaceArgs = getStyledNamespaceArgs(namespaceSegments)\n\n if (!namespaceArgs) {\n return [title]\n }\n\n const [namespaceLabel, ...namespaceStyles] = namespaceArgs\n\n return [`${namespaceLabel} ${title}`, ...namespaceStyles]\n },\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 const namespaceArgs = getStyledNamespaceArgs(namespaceSegments) ?? []\n\n report.debug = Function.prototype.bind.call(\n console.debug,\n console,\n ...namespaceArgs,\n )\n report.info = Function.prototype.bind.call(\n console.info,\n console,\n ...namespaceArgs,\n )\n report.log = Function.prototype.bind.call(\n console.log,\n console,\n ...namespaceArgs,\n )\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 ...namespaceArgs,\n )\n report.error = Function.prototype.bind.call(\n console.error,\n console,\n ...namespaceArgs,\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 = createReport()\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","isMediaContentMimeType","parseContentType","cut","isShallowEqual","objectA","objectB","options","keysA","keysB","isEqual","key","groupBy","list","getKey","previous","currentItem","group","shallowMergeIfDefined","obj1","obj2","result","value","getWindow","isGlobalDebugEnabled","debug","getNamespaceArgs","enabledOrOptions","getCurrentColor","namespaceSegments","getStyledNamespaceArgs","segment","label","styles","namespaceSegment","createReport","enabled","reportEnabled","report","setEnabled","_namespace","namespaceOptions","childNamespaceArgs","childColor","title","namespaceArgs","namespaceLabel","namespaceStyles","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,kCAAkCA,EAAS,CAAC,CAAC,EAAE;AAIrE,EAAIA,EAAS,CAAC,EAAE,MAAM,cAAc,KAAKA,EAAS,SAAS,MACzDA,EAAS,CAAC,IAAIA,EAAS,MAAA,IAAUA,EAAS,CAAC,IAIzCA,EAAS,CAAC,EAAE,MAAM,cAAc,IAClCA,EAAS,CAAC,IAAIA,EAAS,CAAC,EAAE,QAAQ,iBAAiB,QAAQ,IAE3DA,EAAS,CAAC,IAAIA,EAAS,CAAC,EAAE,QAAQ,iBAAiB,OAAO;AAG5D,WAASJ,IAAI,GAAGA,IAAII,EAAS,QAAQJ,KAAK;AACxC,QAAIM,IAAYF,EAASJ,CAAC;AAE1B,QAAI,OAAOM,KAAc;AACvB,YAAM,IAAI,UAAU,kCAAkCA,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AAS,EAAO,QAAQ,SAAS,UAAU,KAAK;AAAA,MACrC,QAAQ;AAAA,MACR;AAAA,MACA,GAAGO;AAAA,IAAA,GAELP,EAAO,OAAO,SAAS,UAAU,KAAK;AAAA,MACpC,QAAQ;AAAA,MACR;AAAA,MACA,GAAGO;AAAA,IAAA,GAELP,EAAO,MAAM,SAAS,UAAU,KAAK;AAAA,MACnC,QAAQ;AAAA,MACR;AAAA,MACA,GAAGO;AAAA,IAAA,GAELP,EAAO,iBAAiB,SAAS,UAAU,KAAK;AAAA,MAC9C,QAAQ;AAAA,MACR;AAAA,IAAA,GAEFA,EAAO,WAAW,SAAS,UAAU,KAAK,KAAK,QAAQ,UAAU,OAAO,GACxEA,EAAO,OAAO,SAAS,UAAU,KAAK;AAAA,MACpC,QAAQ;AAAA,MACR;AAAA,MACA,GAAGO;AAAA,IAAA,GAELP,EAAO,QAAQ,SAAS,UAAU,KAAK;AAAA,MACrC,QAAQ;AAAA,MACR;AAAA,MACA,GAAGO;AAAA,IAAA;AAAA,EAEP,GAEMN,IAAa,CAACH,MAAqB;AACvC,IAAIC,MAAkBD,MAItBC,IAAgBD,GAChBY,EAAkBX,CAAa;AAAA,EACjC;AAEA,SAAAW,EAAkBX,CAAa,GAExBC;AACT,GAEaW,IAASd,EAAA,GCtOTe,IACX;"}
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(r,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(r=typeof globalThis<"u"?globalThis:r||self,u(r["prose-shared"]={}))})(this,(function(r){"use strict";const u=(e,o)=>e===o?!0:e.length!==o.length?!1:e.every((t,n)=>t===o[n]),f=e=>e.split(/[#?]/)[0]?.split(".").pop()?.trim()||"";function h(e){const o=[];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 l=0;l<e.length;l++){let i=e[l];if(typeof i!="string")throw new TypeError(`Url must be a string. Received ${i}`);i!==""&&(l>0&&(i=i.replace(/^[/]+/,"")),l<e.length-1?i=i.replace(/[/]+$/,""):i=i.replace(/[/]+$/,"/"),o.push(i))}let t=o.join("/");t=t.replace(/\/(\?|&|#[^!])/g,"$1");const n=t.split("?");return t=n.shift()+(n.length>0?"?":"")+n.join("&"),t}function m(...e){const o=Array.from(Array.isArray(e[0])?e[0]:e);return h(o)}function b(e){const o=e.split("/");return o.pop(),o.join("/")}const d=e=>{switch(f(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";case"mp3":return"audio/mpeg";case"m4a":case"m4b":return"audio/mp4";case"aac":return"audio/aac";case"ogg":case"oga":return"audio/ogg";case"wav":return"audio/wav";case"flac":return"audio/flac";case"opus":return"audio/opus"}},y=({mimeType:e,uri:o})=>(e??d(o??""))?.startsWith("application/xhtml+xml"),w=e=>e.startsWith("image/")||e.startsWith("audio/")||e.startsWith("video/"),R=e=>{if(!e.length)return;const o=e.indexOf(";");return o>=0?e.substring(0,o):e},_=(e,o,t)=>{if(Object.is(e,o))return!0;if(typeof e!="object"||e===null||typeof o!="object"||o===null)return!1;const n=Object.keys(e),l=Object.keys(o);if(n.length!==l.length)return!1;const i=t?.customEqual??Object.is,c=e,s=o;for(const a of n)if(!Object.hasOwn(s,a)||!i(c[a],s[a]))return!1;return!0},T=(e,o)=>e.reduce((t,n)=>{const l=o(n);return t[l]||(t[l]=[]),t[l].push(n),t},{});function C(e,o){const t={...e};for(const n in o)if(Object.hasOwn(o,n)){const l=o[n];(l!==void 0||!(n in e))&&(t[n]=l)}return t}const M=()=>{if(!(typeof window>"u"))return window};function $(){const e=M()?.__PROSE_READER_DEBUG;return e===!0||e==="true"}const O=(e,o)=>typeof e=="boolean"?{enabled:e,options:o}:{enabled:e?.enabled,options:e??o},v=e=>e.at(-1)?.color,g=e=>{if(!e.length)return;if(!e.some(n=>n.color))return[e.map(n=>n.label).join(" ")];let o="";const t=[];for(const n of e)o+=`%c${o?` ${n.label}`:n.label}`,t.push(n.color?`color: ${n.color}`:"");return[o,...t]},E=(e=[],o=$())=>{let t=o;const n={enable:c=>{i(c)},namespace:(c,s,a)=>{const p=O(s,a),N=p.options?.color??v(e);return E([...e,{label:`[${c}]`,color:N}],p.enabled??t)},isEnabled:()=>t,debug:()=>{},info:()=>{},log:()=>{},groupCollapsed:()=>{},groupEnd:()=>{},getGroupArgs:c=>{const s=g(e);if(!s)return[c];const[a,...p]=s;return[`${a} ${c}`,...p]},warn:()=>{},error:()=>{}},l=c=>{if(!c){n.debug=()=>{},n.info=()=>{},n.log=()=>{},n.groupCollapsed=()=>{},n.groupEnd=()=>{},n.warn=()=>{},n.error=()=>{};return}const s=g(e)??[];n.debug=Function.prototype.bind.call(console.debug,console,...s),n.info=Function.prototype.bind.call(console.info,console,...s),n.log=Function.prototype.bind.call(console.log,console,...s),n.groupCollapsed=Function.prototype.bind.call(console.groupCollapsed,console),n.groupEnd=Function.prototype.bind.call(console.groupEnd,console),n.warn=Function.prototype.bind.call(console.warn,console,...s),n.error=Function.prototype.bind.call(console.error,console,...s)},i=c=>{t!==c&&(t=c,l(t))};return l(t),n},D=E(),F="prose-reader-resource-error";r.PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME=F,r.Report=D,r.arrayEqual=u,r.detectMimeTypeFromName=d,r.getParentPath=b,r.getUrlExtension=f,r.groupBy=T,r.isMediaContentMimeType=w,r.isShallowEqual=_,r.isXmlBasedMimeType=y,r.parseContentType=R,r.shallowMergeIfDefined=C,r.urlJoin=m,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
|
|
2
2
|
//# sourceMappingURL=index.umd.cjs.map
|
package/dist/index.umd.cjs.map
CHANGED
|
@@ -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 case `mp3`:\n return `audio/mpeg`\n case `m4a`:\n case `m4b`:\n return `audio/mp4`\n case `aac`:\n return `audio/aac`\n case `ogg`:\n case `oga`:\n return `audio/ogg`\n case `wav`:\n return `audio/wav`\n case `flac`:\n return `audio/flac`\n case `opus`:\n return `audio/opus`\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\n/**\n * Discrete media MIME types represent a single self-contained unit\n * (an image, an audio track, a video clip) as opposed to document\n * content that may need reflowable layout.\n */\nexport const isMediaContentMimeType = (mimeType: string) =>\n mimeType.startsWith(\"image/\") ||\n mimeType.startsWith(\"audio/\") ||\n mimeType.startsWith(\"video/\")\n\nexport const parseContentType = (str: string) => {\n if (!str.length) return undefined\n\n const cut = str.indexOf(`;`)\n\n return cut >= 0 ? str.substring(0, cut) : str\n}\n","/**\n * Return true if `objectA` is shallow equal to `objectB`.\n *\n * - Primitives are compared with `Object.is` (so `NaN === NaN`, `+0 ≠ -0`).\n * - Objects and arrays are compared by their own enumerable string keys,\n * each value pair compared with `Object.is` (or `customEqual`).\n * - Two objects with the same keys but different prototypes are considered\n * equal — class identity is not checked.\n *\n * Pass `customEqual` to override the per-value comparator (e.g. to recurse\n * one level deeper, or to compare specific value types by content).\n */\nexport const isShallowEqual = <A = unknown, B = unknown>(\n objectA: A,\n objectB: B,\n options?: {\n customEqual?: (a: unknown, b: unknown) => boolean\n },\n): boolean => {\n if (Object.is(objectA, objectB)) {\n return true\n }\n if (\n typeof objectA !== \"object\" ||\n objectA === null ||\n typeof objectB !== \"object\" ||\n objectB === null\n ) {\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 = options?.customEqual ?? Object.is\n\n // Indexable cast after narrowing to non-null `object`: TypeScript doesn't\n // widen `object` itself, but every iterated key is verified as own via\n // `Object.keys` / `Object.hasOwn`.\n const a = objectA as Record<string, unknown>\n const b = objectB as Record<string, unknown>\n\n for (const key of keysA) {\n if (!Object.hasOwn(b, key) || !isEqual(a[key], b[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","getUrlExtension","url","normalize","strArray","resultArray","i","component","str","parts","urlJoin","args","getParentPath","uri","detectMimeTypeFromName","name","isXmlBasedMimeType","mimeType","isMediaContentMimeType","parseContentType","cut","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_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ACR,OAAA,EAEFA,EAAO,SAAW,SAAS,UAAU,KAAK,KAAK,QAAQ,SAAU,OAAO,EACxEA,EAAO,KAAO,SAAS,UAAU,KAAK,KACpC,QAAQ,KACR,QACA,KAAKJ,CAAS,GACdG,CAAA,EAEFC,EAAO,MAAQ,SAAS,UAAU,KAAK,KACrC,QAAQ,MACR,QACA,KAAKJ,CAAS,GACdG,CAAA,CAEJ,EAEME,EAAcJ,GAAqB,CACnCC,IAAkBD,IAItBC,EAAgBD,EAChBO,EAAkBN,CAAa,EACjC,EAEA,OAAAM,EAAkBN,CAAa,EAExBE,CACT,EAEaK,EAAS,CACpB,GAAGV,EAAA,EACH,UAAW,CACTC,EACAC,EACArB,IAGGmB,EAAa,IAAIC,CAAS,IAAKC,EAASrB,CAAO,CACtD,EC7Ja8B,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 case `mp3`:\n return `audio/mpeg`\n case `m4a`:\n case `m4b`:\n return `audio/mp4`\n case `aac`:\n return `audio/aac`\n case `ogg`:\n case `oga`:\n return `audio/ogg`\n case `wav`:\n return `audio/wav`\n case `flac`:\n return `audio/flac`\n case `opus`:\n return `audio/opus`\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\n/**\n * Discrete media MIME types represent a single self-contained unit\n * (an image, an audio track, a video clip) as opposed to document\n * content that may need reflowable layout.\n */\nexport const isMediaContentMimeType = (mimeType: string) =>\n mimeType.startsWith(\"image/\") ||\n mimeType.startsWith(\"audio/\") ||\n mimeType.startsWith(\"video/\")\n\nexport const parseContentType = (str: string) => {\n if (!str.length) return undefined\n\n const cut = str.indexOf(`;`)\n\n return cut >= 0 ? str.substring(0, cut) : str\n}\n","/**\n * Return true if `objectA` is shallow equal to `objectB`.\n *\n * - Primitives are compared with `Object.is` (so `NaN === NaN`, `+0 ≠ -0`).\n * - Objects and arrays are compared by their own enumerable string keys,\n * each value pair compared with `Object.is` (or `customEqual`).\n * - Two objects with the same keys but different prototypes are considered\n * equal — class identity is not checked.\n *\n * Pass `customEqual` to override the per-value comparator (e.g. to recurse\n * one level deeper, or to compare specific value types by content).\n */\nexport const isShallowEqual = <A = unknown, B = unknown>(\n objectA: A,\n objectB: B,\n options?: {\n customEqual?: (a: unknown, b: unknown) => boolean\n },\n): boolean => {\n if (Object.is(objectA, objectB)) {\n return true\n }\n if (\n typeof objectA !== \"object\" ||\n objectA === null ||\n typeof objectB !== \"object\" ||\n objectB === null\n ) {\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 = options?.customEqual ?? Object.is\n\n // Indexable cast after narrowing to non-null `object`: TypeScript doesn't\n // widen `object` itself, but every iterated key is verified as own via\n // `Object.keys` / `Object.hasOwn`.\n const a = objectA as Record<string, unknown>\n const b = objectB as Record<string, unknown>\n\n for (const key of keysA) {\n if (!Object.hasOwn(b, key) || !isEqual(a[key], b[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","/**\n * This report class needs to be fast because it is used in hot path. The disabled state\n * should not trigger any i/o and be no op operations.\n * The logging should keep the original stack trace.\n */\n\ndeclare 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 ReportOptions = {\n color?: string\n}\n\nexport type ReportNamespaceOptions = ReportOptions & {\n enabled?: boolean\n}\n\ntype ReportNamespace = {\n (namespace: string, enabled?: boolean, options?: ReportOptions): Report\n (namespace: string, options?: ReportNamespaceOptions): Report\n}\n\ntype ReportGroupArgs = [label: string, ...styles: string[]]\n\ntype NamespaceSegment = {\n label: string\n color?: string\n}\n\nexport type Report = {\n enable: (enabled: boolean) => void\n isEnabled: () => boolean\n namespace: ReportNamespace\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, ...styles] to pass to groupCollapsed for namespace + color. */\n getGroupArgs: (title: string) => ReportGroupArgs\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 getNamespaceArgs = (\n enabledOrOptions?: boolean | ReportNamespaceOptions,\n options?: ReportOptions,\n) => {\n if (typeof enabledOrOptions === \"boolean\") {\n return {\n enabled: enabledOrOptions,\n options,\n }\n }\n\n return {\n enabled: enabledOrOptions?.enabled,\n options: enabledOrOptions ?? options,\n }\n}\n\nconst getCurrentColor = (namespaceSegments: NamespaceSegment[]) =>\n namespaceSegments.at(-1)?.color\n\nconst getStyledNamespaceArgs = (\n namespaceSegments: NamespaceSegment[],\n): ReportGroupArgs | undefined => {\n if (!namespaceSegments.length) {\n return undefined\n }\n\n if (!namespaceSegments.some((segment) => segment.color)) {\n return [namespaceSegments.map((segment) => segment.label).join(\" \")]\n }\n\n let label = \"\"\n const styles: string[] = []\n\n for (const namespaceSegment of namespaceSegments) {\n label += `%c${label ? ` ${namespaceSegment.label}` : namespaceSegment.label}`\n styles.push(\n namespaceSegment.color ? `color: ${namespaceSegment.color}` : \"\",\n )\n }\n\n return [label, ...styles]\n}\n\nconst createReport = (\n namespaceSegments: NamespaceSegment[] = [],\n enabled = isGlobalDebugEnabled(),\n): Report => {\n let reportEnabled = enabled\n\n const report: Report = {\n enable: (enabled: boolean) => {\n setEnabled(enabled)\n },\n namespace: (\n _namespace: string,\n enabledOrOptions?: boolean | ReportNamespaceOptions,\n namespaceOptions?: ReportOptions,\n ) => {\n const childNamespaceArgs = getNamespaceArgs(\n enabledOrOptions,\n namespaceOptions,\n )\n\n const childColor =\n childNamespaceArgs.options?.color ?? getCurrentColor(namespaceSegments)\n\n return createReport(\n [\n ...namespaceSegments,\n {\n label: `[${_namespace}]`,\n color: childColor,\n },\n ],\n childNamespaceArgs.enabled ?? reportEnabled,\n )\n },\n isEnabled: () => reportEnabled,\n debug: () => {},\n info: () => {},\n log: () => {},\n groupCollapsed: () => {},\n groupEnd: () => {},\n getGroupArgs: (title: string) => {\n const namespaceArgs = getStyledNamespaceArgs(namespaceSegments)\n\n if (!namespaceArgs) {\n return [title]\n }\n\n const [namespaceLabel, ...namespaceStyles] = namespaceArgs\n\n return [`${namespaceLabel} ${title}`, ...namespaceStyles]\n },\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 const namespaceArgs = getStyledNamespaceArgs(namespaceSegments) ?? []\n\n report.debug = Function.prototype.bind.call(\n console.debug,\n console,\n ...namespaceArgs,\n )\n report.info = Function.prototype.bind.call(\n console.info,\n console,\n ...namespaceArgs,\n )\n report.log = Function.prototype.bind.call(\n console.log,\n console,\n ...namespaceArgs,\n )\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 ...namespaceArgs,\n )\n report.error = Function.prototype.bind.call(\n console.error,\n console,\n ...namespaceArgs,\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 = createReport()\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","isMediaContentMimeType","parseContentType","cut","isShallowEqual","objectA","objectB","options","keysA","keysB","isEqual","key","groupBy","list","getKey","previous","currentItem","group","shallowMergeIfDefined","obj1","obj2","result","value","getWindow","isGlobalDebugEnabled","debug","getNamespaceArgs","enabledOrOptions","getCurrentColor","namespaceSegments","getStyledNamespaceArgs","segment","label","styles","namespaceSegment","createReport","enabled","reportEnabled","report","setEnabled","_namespace","namespaceOptions","childNamespaceArgs","childColor","title","namespaceArgs","namespaceLabel","namespaceStyles","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,EAAS,CAAC,EAAE,MAAM,cAAc,GAAKA,EAAS,OAAS,IACzDA,EAAS,CAAC,EAAIA,EAAS,MAAA,EAAUA,EAAS,CAAC,GAIzCA,EAAS,CAAC,EAAE,MAAM,cAAc,EAClCA,EAAS,CAAC,EAAIA,EAAS,CAAC,EAAE,QAAQ,gBAAiB,QAAQ,EAE3DA,EAAS,CAAC,EAAIA,EAAS,CAAC,EAAE,QAAQ,gBAAiB,OAAO,EAG5D,QAASJ,EAAI,EAAGA,EAAII,EAAS,OAAQJ,IAAK,CACxC,IAAIM,EAAYF,EAASJ,CAAC,EAE1B,GAAI,OAA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AA,CAEP,EAEMN,EAAcH,GAAqB,CACnCC,IAAkBD,IAItBC,EAAgBD,EAChBY,EAAkBX,CAAa,EACjC,EAEA,OAAAW,EAAkBX,CAAa,EAExBC,CACT,EAEaW,EAASd,EAAA,ECtOTe,EACX"}
|
package/dist/report.d.ts
CHANGED
|
@@ -3,31 +3,29 @@ declare global {
|
|
|
3
3
|
__PROSE_READER_DEBUG?: boolean | string;
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
isEnabled: () => boolean;
|
|
9
|
-
namespace: (namespace: string, enabled?: boolean) => Report;
|
|
10
|
-
debug: (...args: any[]) => void;
|
|
11
|
-
info: (...args: any[]) => void;
|
|
12
|
-
log: (...args: any[]) => void;
|
|
13
|
-
groupCollapsed: (...args: unknown[]) => void;
|
|
14
|
-
groupEnd: () => void;
|
|
15
|
-
getGroupArgs: (title: string) => [string, string?] | [string];
|
|
16
|
-
warn: (...args: any[]) => void;
|
|
17
|
-
error: (...args: any[]) => void;
|
|
6
|
+
export type ReportOptions = {
|
|
7
|
+
color?: string;
|
|
18
8
|
};
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
export type ReportNamespaceOptions = ReportOptions & {
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type ReportNamespace = {
|
|
13
|
+
(namespace: string, enabled?: boolean, options?: ReportOptions): Report;
|
|
14
|
+
(namespace: string, options?: ReportNamespaceOptions): Report;
|
|
15
|
+
};
|
|
16
|
+
type ReportGroupArgs = [label: string, ...styles: string[]];
|
|
17
|
+
export type Report = {
|
|
23
18
|
enable: (enabled: boolean) => void;
|
|
24
19
|
isEnabled: () => boolean;
|
|
20
|
+
namespace: ReportNamespace;
|
|
25
21
|
debug: (...args: any[]) => void;
|
|
26
22
|
info: (...args: any[]) => void;
|
|
27
23
|
log: (...args: any[]) => void;
|
|
28
24
|
groupCollapsed: (...args: unknown[]) => void;
|
|
29
25
|
groupEnd: () => void;
|
|
30
|
-
getGroupArgs: (title: string) =>
|
|
26
|
+
getGroupArgs: (title: string) => ReportGroupArgs;
|
|
31
27
|
warn: (...args: any[]) => void;
|
|
32
28
|
error: (...args: any[]) => void;
|
|
33
29
|
};
|
|
30
|
+
export declare const Report: Report;
|
|
31
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prose-reader/shared",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.291.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": "
|
|
23
|
+
"gitHead": "95d3d207700bd99e75fdc6a169c7102f90cc7781"
|
|
24
24
|
}
|