@prose-reader/shared 1.24.0 → 1.26.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/Manifest.d.ts +34 -34
- package/dist/contentType.d.ts +11 -6
- package/dist/index.d.ts +4 -4
- package/dist/prose-shared.js +45 -39
- package/dist/prose-shared.umd.cjs +67 -1
- package/dist/resources.d.ts +1 -1
- package/dist/url.d.ts +2 -2
- package/package.json +2 -2
package/dist/Manifest.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
export type TocItem = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
2
|
+
title: string
|
|
3
|
+
path: string
|
|
4
|
+
contents: TocItem[]
|
|
5
|
+
href: string
|
|
6
|
+
}
|
|
7
7
|
export type Manifest = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
8
|
+
filename: string
|
|
9
|
+
nav?: {
|
|
10
|
+
toc: TocItem[]
|
|
11
|
+
}
|
|
12
|
+
title: string
|
|
13
|
+
renditionLayout: `reflowable` | `pre-paginated` | undefined
|
|
14
|
+
renditionFlow?: `scrolled-continuous` | `scrolled-doc` | `paginated` | `auto`
|
|
15
|
+
renditionSpread: `none` | `landscape` | `portrait` | `both` | `auto` | undefined
|
|
16
|
+
readingDirection: "ltr" | "rtl"
|
|
17
|
+
guide?: {
|
|
18
|
+
type: `cover` | `title-page` | `copyright-page` | `text`
|
|
19
|
+
title: string
|
|
20
|
+
href: string
|
|
21
|
+
}[]
|
|
22
|
+
spineItems: {
|
|
23
|
+
id: string
|
|
24
|
+
href: string
|
|
25
|
+
renditionLayout: `reflowable` | `pre-paginated`
|
|
26
|
+
progressionWeight: number
|
|
27
|
+
pageSpreadLeft: true | undefined
|
|
28
|
+
pageSpreadRight: true | undefined
|
|
29
|
+
mediaType?: string
|
|
30
|
+
}[]
|
|
31
|
+
items: {
|
|
32
|
+
id: string
|
|
33
|
+
href: string
|
|
34
|
+
mediaType?: string
|
|
35
|
+
}[]
|
|
36
|
+
}
|
package/dist/contentType.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
export declare const detectMimeTypeFromName: (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export declare const detectMimeTypeFromName: (
|
|
2
|
+
name: string
|
|
3
|
+
) => "image/png" | "image/jpg" | "image/jpeg" | "text/plain" | "image/webp" | "application/xhtml+xml" | undefined
|
|
4
|
+
export declare const isXmlBasedMimeType: ({
|
|
5
|
+
mimeType,
|
|
6
|
+
uri,
|
|
7
|
+
}: {
|
|
8
|
+
uri?: string | undefined
|
|
9
|
+
mimeType?: string | undefined
|
|
10
|
+
}) => boolean | undefined
|
|
11
|
+
export declare const parseContentType: (str: string) => string | undefined
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Manifest, TocItem } from "./Manifest"
|
|
2
|
-
export * from "./contentType"
|
|
3
|
-
export * from "./url"
|
|
4
|
-
export * from "./resources"
|
|
1
|
+
export type { Manifest, TocItem } from "./Manifest"
|
|
2
|
+
export * from "./contentType"
|
|
3
|
+
export * from "./url"
|
|
4
|
+
export * from "./resources"
|
package/dist/prose-shared.js
CHANGED
|
@@ -1,54 +1,60 @@
|
|
|
1
1
|
const p = (e) => {
|
|
2
|
-
var n, t
|
|
3
|
-
return ((t = (n = e.split(/[#?]/)[0]) == null ? void 0 : n.split(".").pop()) == null ? void 0 : t.trim()) || ""
|
|
4
|
-
}
|
|
2
|
+
var n, t
|
|
3
|
+
return ((t = (n = e.split(/[#?]/)[0]) == null ? void 0 : n.split(".").pop()) == null ? void 0 : t.trim()) || ""
|
|
4
|
+
}
|
|
5
5
|
function l(e) {
|
|
6
|
-
const n = []
|
|
7
|
-
if (e.length === 0)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const n = []
|
|
7
|
+
if (e.length === 0) return ""
|
|
8
|
+
if (typeof e[0] != "string") throw new TypeError("Url must be a string. Received " + e[0])
|
|
9
|
+
e[0].match(/^[^/:]+:\/*$/) && e.length > 1 && (e[0] = e.shift() + e[0]),
|
|
10
|
+
e[0].match(/^file:\/\/\//)
|
|
11
|
+
? (e[0] = e[0].replace(/^([^/:]+):\/*/, "$1:///"))
|
|
12
|
+
: (e[0] = e[0].replace(/^([^/:]+):\/*/, "$1://"))
|
|
12
13
|
for (let o = 0; o < e.length; o++) {
|
|
13
|
-
let i = e[o]
|
|
14
|
-
if (typeof i != "string")
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
let i = e[o]
|
|
15
|
+
if (typeof i != "string") throw new TypeError("Url must be a string. Received " + i)
|
|
16
|
+
i !== "" &&
|
|
17
|
+
(o > 0 && (i = i.replace(/^[/]+/, "")),
|
|
18
|
+
o < e.length - 1 ? (i = i.replace(/[/]+$/, "")) : (i = i.replace(/[/]+$/, "/")),
|
|
19
|
+
n.push(i))
|
|
17
20
|
}
|
|
18
|
-
let t = n.join("/")
|
|
19
|
-
t = t.replace(/\/(\?|&|#[^!])/g, "$1")
|
|
20
|
-
const c = t.split("?")
|
|
21
|
-
return t = c.shift() + (c.length > 0 ? "?" : "") + c.join("&"), t
|
|
21
|
+
let t = n.join("/")
|
|
22
|
+
t = t.replace(/\/(\?|&|#[^!])/g, "$1")
|
|
23
|
+
const c = t.split("?")
|
|
24
|
+
return (t = c.shift() + (c.length > 0 ? "?" : "") + c.join("&")), t
|
|
22
25
|
}
|
|
23
26
|
function s(...e) {
|
|
24
|
-
const n = Array.from(Array.isArray(e[0]) ? e[0] : e)
|
|
25
|
-
return l(n)
|
|
27
|
+
const n = Array.from(Array.isArray(e[0]) ? e[0] : e)
|
|
28
|
+
return l(n)
|
|
26
29
|
}
|
|
27
30
|
const r = (e) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
switch (p(e)) {
|
|
32
|
+
case "png":
|
|
33
|
+
return "image/png"
|
|
34
|
+
case "jpg":
|
|
35
|
+
return "image/jpg"
|
|
36
|
+
case "jpeg":
|
|
37
|
+
return "image/jpeg"
|
|
38
|
+
case "txt":
|
|
39
|
+
return "text/plain"
|
|
40
|
+
case "webp":
|
|
41
|
+
return "image/webp"
|
|
42
|
+
case "xhtml":
|
|
43
|
+
return "application/xhtml+xml"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
u = ({ mimeType: e, uri: n }) => {
|
|
47
|
+
const t = e ?? r(n ?? "")
|
|
48
|
+
return t == null ? void 0 : t.startsWith("application/xhtml+xml")
|
|
49
|
+
},
|
|
50
|
+
g = (e) => (e.length ? (e.indexOf(";") ? e.substring(0, e.indexOf(";")) : e) : void 0),
|
|
51
|
+
a = "prose-reader-resource-error"
|
|
46
52
|
export {
|
|
47
53
|
a as PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME,
|
|
48
54
|
r as detectMimeTypeFromName,
|
|
49
55
|
p as getUrlExtension,
|
|
50
56
|
u as isXmlBasedMimeType,
|
|
51
57
|
g as parseContentType,
|
|
52
|
-
s as urlJoin
|
|
53
|
-
}
|
|
58
|
+
s as urlJoin,
|
|
59
|
+
}
|
|
54
60
|
//# sourceMappingURL=prose-shared.js.map
|
|
@@ -1,2 +1,68 @@
|
|
|
1
|
-
(function
|
|
1
|
+
;(function (t, l) {
|
|
2
|
+
typeof exports == "object" && typeof module < "u"
|
|
3
|
+
? l(exports)
|
|
4
|
+
: typeof define == "function" && define.amd
|
|
5
|
+
? define(["exports"], l)
|
|
6
|
+
: ((t = typeof globalThis < "u" ? globalThis : t || self), l((t["prose-shared"] = {})))
|
|
7
|
+
})(this, function (t) {
|
|
8
|
+
"use strict"
|
|
9
|
+
const l = (e) => {
|
|
10
|
+
var i, n
|
|
11
|
+
return ((n = (i = e.split(/[#?]/)[0]) == null ? void 0 : i.split(".").pop()) == null ? void 0 : n.trim()) || ""
|
|
12
|
+
}
|
|
13
|
+
function u(e) {
|
|
14
|
+
const i = []
|
|
15
|
+
if (e.length === 0) return ""
|
|
16
|
+
if (typeof e[0] != "string") throw new TypeError("Url must be a string. Received " + e[0])
|
|
17
|
+
e[0].match(/^[^/:]+:\/*$/) && e.length > 1 && (e[0] = e.shift() + e[0]),
|
|
18
|
+
e[0].match(/^file:\/\/\//)
|
|
19
|
+
? (e[0] = e[0].replace(/^([^/:]+):\/*/, "$1:///"))
|
|
20
|
+
: (e[0] = e[0].replace(/^([^/:]+):\/*/, "$1://"))
|
|
21
|
+
for (let c = 0; c < e.length; c++) {
|
|
22
|
+
let o = e[c]
|
|
23
|
+
if (typeof o != "string") throw new TypeError("Url must be a string. Received " + o)
|
|
24
|
+
o !== "" &&
|
|
25
|
+
(c > 0 && (o = o.replace(/^[/]+/, "")),
|
|
26
|
+
c < e.length - 1 ? (o = o.replace(/[/]+$/, "")) : (o = o.replace(/[/]+$/, "/")),
|
|
27
|
+
i.push(o))
|
|
28
|
+
}
|
|
29
|
+
let n = i.join("/")
|
|
30
|
+
n = n.replace(/\/(\?|&|#[^!])/g, "$1")
|
|
31
|
+
const p = n.split("?")
|
|
32
|
+
return (n = p.shift() + (p.length > 0 ? "?" : "") + p.join("&")), n
|
|
33
|
+
}
|
|
34
|
+
function f(...e) {
|
|
35
|
+
const i = Array.from(Array.isArray(e[0]) ? e[0] : e)
|
|
36
|
+
return u(i)
|
|
37
|
+
}
|
|
38
|
+
const s = (e) => {
|
|
39
|
+
switch (l(e)) {
|
|
40
|
+
case "png":
|
|
41
|
+
return "image/png"
|
|
42
|
+
case "jpg":
|
|
43
|
+
return "image/jpg"
|
|
44
|
+
case "jpeg":
|
|
45
|
+
return "image/jpeg"
|
|
46
|
+
case "txt":
|
|
47
|
+
return "text/plain"
|
|
48
|
+
case "webp":
|
|
49
|
+
return "image/webp"
|
|
50
|
+
case "xhtml":
|
|
51
|
+
return "application/xhtml+xml"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
r = ({ mimeType: e, uri: i }) => {
|
|
55
|
+
const n = e ?? s(i ?? "")
|
|
56
|
+
return n == null ? void 0 : n.startsWith("application/xhtml+xml")
|
|
57
|
+
},
|
|
58
|
+
m = (e) => (e.length ? (e.indexOf(";") ? e.substring(0, e.indexOf(";")) : e) : void 0),
|
|
59
|
+
a = "prose-reader-resource-error"
|
|
60
|
+
;(t.PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME = a),
|
|
61
|
+
(t.detectMimeTypeFromName = s),
|
|
62
|
+
(t.getUrlExtension = l),
|
|
63
|
+
(t.isXmlBasedMimeType = r),
|
|
64
|
+
(t.parseContentType = m),
|
|
65
|
+
(t.urlJoin = f),
|
|
66
|
+
Object.defineProperty(t, Symbol.toStringTag, { value: "Module" })
|
|
67
|
+
})
|
|
2
68
|
//# sourceMappingURL=prose-shared.umd.cjs.map
|
package/dist/resources.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME = "prose-reader-resource-error"
|
|
1
|
+
export declare const PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME = "prose-reader-resource-error"
|
package/dist/url.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getUrlExtension: (url: string) => string
|
|
2
|
-
export declare function urlJoin(...args: (string | string[])[]): string
|
|
1
|
+
export declare const getUrlExtension: (url: string) => string
|
|
2
|
+
export declare function urlJoin(...args: (string | string[])[]): string
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prose-reader/shared",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/prose-shared.umd.cjs",
|
|
6
6
|
"module": "./dist/prose-shared.js",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"build": "tsc && vite build",
|
|
23
23
|
"test": "vitest run --coverage"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "c6367c4c2ce1fee886ebfb27c93e393422ca520a"
|
|
26
26
|
}
|