@foxycape/core 1.2.0 → 1.2.2
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/kernal/crypto/WebCrypto.cjs +1 -1
- package/dist/kernal/crypto/WebCrypto.mjs +36 -31
- package/dist/kernal/index.cjs +1 -1
- package/dist/kernal/index.d.ts +0 -3
- package/dist/kernal/index.mjs +35 -37
- package/dist/kernal/io/IByteSource.cjs +1 -1
- package/dist/kernal/io/IByteSource.mjs +16 -17
- package/dist/kernal/pipelines/FileLoadPipeline.cjs +1 -1
- package/dist/kernal/pipelines/FileLoadPipeline.mjs +2 -1
- package/dist/kernal/pipelines/InputFormatter.cjs +1 -1
- package/dist/kernal/pipelines/InputFormatter.d.ts +0 -1
- package/dist/kernal/pipelines/InputFormatter.mjs +47 -60
- package/dist/kernal/services/ServiceCollection.cjs +1 -1
- package/dist/kernal/services/ServiceCollection.mjs +0 -3
- package/dist/mediaTypes/html/renderer/HtmlRenderer.cjs +1 -1
- package/dist/mediaTypes/html/renderer/HtmlRenderer.d.ts +2 -2
- package/dist/mediaTypes/html/renderer/HtmlRenderer.mjs +2 -10
- package/package.json +1 -4
- package/dist/kernal/crypto/MD5.cjs +0 -1
- package/dist/kernal/crypto/MD5.d.ts +0 -4
- package/dist/kernal/crypto/MD5.mjs +0 -6
- package/dist/kernal/crypto/hash.cjs +0 -1
- package/dist/kernal/crypto/hash.d.ts +0 -21
- package/dist/kernal/crypto/hash.mjs +0 -48
- package/dist/kernal/plugins/keyboard/KeyboardPageTurning.cjs +0 -1
- package/dist/kernal/plugins/keyboard/KeyboardPageTurning.d.ts +0 -39
- package/dist/kernal/plugins/keyboard/KeyboardPageTurning.mjs +0 -136
- package/dist/mediaTypes/html/renderer/style/LanguageHighlighter.cjs +0 -1
- package/dist/mediaTypes/html/renderer/style/LanguageHighlighter.d.ts +0 -18
- package/dist/mediaTypes/html/renderer/style/LanguageHighlighter.mjs +0 -52
- package/dist/node_modules/highlight.js/styles/github-dark.cjs +0 -118
- package/dist/node_modules/highlight.js/styles/github-dark.mjs +0 -4
- package/dist/node_modules/highlight.js/styles/github.cjs +0 -118
- package/dist/node_modules/highlight.js/styles/github.mjs +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../common/buffer.cjs");var t=()=>{let e=globalThis.crypto||globalThis.msCrypto;return e.subtle||e.webkitSubtle},n=e=>typeof e==`string`?new TextEncoder().encode(e):e,r=(e,t)=>{if(e==null)throw Error(`iv is required for AES`);return typeof e==`string`?new TextEncoder().encode(e.substring(0,t)):e.byteLength>t?e.slice(0,t):e},i=(t,n,r,i=!1)=>{let a=t.trim();if(a.startsWith(`-----`)){if(i&&!a.includes(n))throw Error(`RSA decrypt requires PKCS#8 private key (BEGIN PRIVATE KEY)`);let e=a.indexOf(n);a=a.substring(e>=0?e+n.length:0).trim();let t=a.indexOf(r);a=(t>=0?a.substring(0,t):a).trim()}return e.convertBase64ToArrayBuffer(a)},a=async e=>{let t=typeof e==`string`?i(e,`-----BEGIN PUBLIC KEY-----`,`-----END PUBLIC KEY-----`):e;return await globalThis.crypto.subtle.importKey(`spki`,t,{name:`RSA-OAEP`,hash:`SHA-256`},!0,[`encrypt`])},o=async e=>{let t=typeof e==`string`?i(e,`-----BEGIN PRIVATE KEY-----`,`-----END PRIVATE KEY-----`,!0):e;return await globalThis.crypto.subtle.importKey(`pkcs8`,t,{name:`RSA-OAEP`,hash:`SHA-256`},!0,[`decrypt`])},s=async e=>typeof e==`string`?new TextEncoder().encode(e):e instanceof Blob?await e.arrayBuffer():e,c=e=>{let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e++)n+=t[e].toString(16).padStart(2,`0`);return n},l=class{async digest(e,n){let r=n??`SHA-256`;if(r===`MD5`)throw Error(`MD5 is not implemented`);return c(await t().digest(r,await s(e)))}async encrypt(e,i){let o=t(),{key:s,iv:c,mode:l,algorithm:u}=i;if(!u||u==`aes`){let t=n(s);if(!t||t.byteLength<16||t.byteLength%16>0)throw Error(`key must greater than 16`);let i=typeof e==`string`?new TextEncoder().encode(e):e,a=r(c,t.byteLength),u=l===`CBC`?`AES-CBC`:l,d=await o.importKey(`raw`,t,u,!0,[`encrypt`]);return await o.encrypt({name:u,iv:a},d,i)}{let t=typeof e==`string`?new TextEncoder().encode(e):e,n=await a(s);return await o.encrypt({name:`RSA-OAEP`},n,t)}}async decrypt(e,i){let{key:a,iv:s,mode:c,algorithm:l}=i,u=t();if(!l||l==`aes`){let t=n(a);if(!t||t.byteLength<16||t.byteLength%16>0)throw Error(`key must greater than 16`);let i=r(s,t.byteLength),o=c===`CBC`?`AES-CBC`:c,l=await u.importKey(`raw`,t,o,!0,[`decrypt`]);return await u.decrypt({name:o,iv:i},l,e)}let d=await o(a);return await u.decrypt({name:`RSA-OAEP`},d,e)}};exports.WebCrypto=l;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { convertBase64ToArrayBuffer as t } from "../common/buffer.mjs";
|
|
1
|
+
import { convertBase64ToArrayBuffer as e } from "../common/buffer.mjs";
|
|
3
2
|
//#region kernal/crypto/WebCrypto.ts
|
|
4
|
-
var
|
|
3
|
+
var t = () => {
|
|
5
4
|
let e = globalThis.crypto || globalThis.msCrypto;
|
|
6
5
|
return e.subtle || e.webkitSubtle;
|
|
7
|
-
},
|
|
6
|
+
}, n = (e) => typeof e == "string" ? new TextEncoder().encode(e) : e, r = (e, t) => {
|
|
8
7
|
if (e == null) throw Error("iv is required for AES");
|
|
9
8
|
return typeof e == "string" ? new TextEncoder().encode(e.substring(0, t)) : e.byteLength > t ? e.slice(0, t) : e;
|
|
10
|
-
},
|
|
11
|
-
let a =
|
|
9
|
+
}, i = (t, n, r, i = !1) => {
|
|
10
|
+
let a = t.trim();
|
|
12
11
|
if (a.startsWith("-----")) {
|
|
13
12
|
if (i && !a.includes(n)) throw Error("RSA decrypt requires PKCS#8 private key (BEGIN PRIVATE KEY)");
|
|
14
13
|
let e = a.indexOf(n);
|
|
@@ -16,53 +15,59 @@ var n = () => {
|
|
|
16
15
|
let t = a.indexOf(r);
|
|
17
16
|
a = (t >= 0 ? a.substring(0, t) : a).trim();
|
|
18
17
|
}
|
|
19
|
-
return
|
|
20
|
-
},
|
|
21
|
-
let t = typeof e == "string" ?
|
|
18
|
+
return e(a);
|
|
19
|
+
}, a = async (e) => {
|
|
20
|
+
let t = typeof e == "string" ? i(e, "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----") : e;
|
|
22
21
|
return await globalThis.crypto.subtle.importKey("spki", t, {
|
|
23
22
|
name: "RSA-OAEP",
|
|
24
23
|
hash: "SHA-256"
|
|
25
24
|
}, !0, ["encrypt"]);
|
|
26
|
-
},
|
|
27
|
-
let t = typeof e == "string" ?
|
|
25
|
+
}, o = async (e) => {
|
|
26
|
+
let t = typeof e == "string" ? i(e, "-----BEGIN PRIVATE KEY-----", "-----END PRIVATE KEY-----", !0) : e;
|
|
28
27
|
return await globalThis.crypto.subtle.importKey("pkcs8", t, {
|
|
29
28
|
name: "RSA-OAEP",
|
|
30
29
|
hash: "SHA-256"
|
|
31
30
|
}, !0, ["decrypt"]);
|
|
32
|
-
}, c =
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
}, s = async (e) => typeof e == "string" ? new TextEncoder().encode(e) : e instanceof Blob ? await e.arrayBuffer() : e, c = (e) => {
|
|
32
|
+
let t = new Uint8Array(e), n = "";
|
|
33
|
+
for (let e = 0; e < t.length; e++) n += t[e].toString(16).padStart(2, "0");
|
|
34
|
+
return n;
|
|
35
|
+
}, l = class {
|
|
36
|
+
async digest(e, n) {
|
|
37
|
+
let r = n ?? "SHA-256";
|
|
38
|
+
if (r === "MD5") throw Error("MD5 is not implemented");
|
|
39
|
+
return c(await t().digest(r, await s(e)));
|
|
35
40
|
}
|
|
36
|
-
async encrypt(e,
|
|
37
|
-
let
|
|
41
|
+
async encrypt(e, i) {
|
|
42
|
+
let o = t(), { key: s, iv: c, mode: l, algorithm: u } = i;
|
|
38
43
|
if (!u || u == "aes") {
|
|
39
|
-
let t =
|
|
44
|
+
let t = n(s);
|
|
40
45
|
if (!t || t.byteLength < 16 || t.byteLength % 16 > 0) throw Error("key must greater than 16");
|
|
41
|
-
let
|
|
42
|
-
return await
|
|
46
|
+
let i = typeof e == "string" ? new TextEncoder().encode(e) : e, a = r(c, t.byteLength), u = l === "CBC" ? "AES-CBC" : l, d = await o.importKey("raw", t, u, !0, ["encrypt"]);
|
|
47
|
+
return await o.encrypt({
|
|
43
48
|
name: u,
|
|
44
|
-
iv:
|
|
45
|
-
}, d,
|
|
49
|
+
iv: a
|
|
50
|
+
}, d, i);
|
|
46
51
|
}
|
|
47
52
|
{
|
|
48
|
-
let t = typeof e == "string" ? new TextEncoder().encode(e) : e, n = await
|
|
49
|
-
return await
|
|
53
|
+
let t = typeof e == "string" ? new TextEncoder().encode(e) : e, n = await a(s);
|
|
54
|
+
return await o.encrypt({ name: "RSA-OAEP" }, n, t);
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
|
-
async decrypt(e,
|
|
53
|
-
let { key: a, iv:
|
|
57
|
+
async decrypt(e, i) {
|
|
58
|
+
let { key: a, iv: s, mode: c, algorithm: l } = i, u = t();
|
|
54
59
|
if (!l || l == "aes") {
|
|
55
|
-
let t =
|
|
60
|
+
let t = n(a);
|
|
56
61
|
if (!t || t.byteLength < 16 || t.byteLength % 16 > 0) throw Error("key must greater than 16");
|
|
57
|
-
let
|
|
62
|
+
let i = r(s, t.byteLength), o = c === "CBC" ? "AES-CBC" : c, l = await u.importKey("raw", t, o, !0, ["decrypt"]);
|
|
58
63
|
return await u.decrypt({
|
|
59
|
-
name:
|
|
60
|
-
iv:
|
|
64
|
+
name: o,
|
|
65
|
+
iv: i
|
|
61
66
|
}, l, e);
|
|
62
67
|
}
|
|
63
|
-
let d = await
|
|
68
|
+
let d = await o(a);
|
|
64
69
|
return await u.decrypt({ name: "RSA-OAEP" }, d, e);
|
|
65
70
|
}
|
|
66
71
|
};
|
|
67
72
|
//#endregion
|
|
68
|
-
export {
|
|
73
|
+
export { l as WebCrypto };
|
package/dist/kernal/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./EventNames.cjs"),t=require("./common/data.cjs"),n=require("./web/BrowserCapabilities.cjs"),r=require("./EventEmitter.cjs"),i=require("./logger/LogLevel.cjs"),a=require("./MediaTypeRegistry.cjs"),o=require("./Options.cjs"),s=require("./Metadata.cjs"),c=require("./OpenOptions.cjs"),l=require("./progress/Progress.cjs"),u=require("./progress/userChangedProgress.cjs"),d=require("./Context.cjs"),f=require("./IFileParser.cjs"),p=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./EventNames.cjs"),t=require("./common/data.cjs"),n=require("./web/BrowserCapabilities.cjs"),r=require("./EventEmitter.cjs"),i=require("./logger/LogLevel.cjs"),a=require("./MediaTypeRegistry.cjs"),o=require("./Options.cjs"),s=require("./Metadata.cjs"),c=require("./OpenOptions.cjs"),l=require("./progress/Progress.cjs"),u=require("./progress/userChangedProgress.cjs"),d=require("./Context.cjs"),f=require("./IFileParser.cjs"),p=require("./Constants.cjs"),m=require("./services/ServiceCollection.cjs"),h=require("./FileLoader.cjs"),g=require("./hostViewport.cjs"),_=require("./plugins/PluginRegistry.cjs"),v=require("./plugins/PluginManager.cjs"),y=require("./Theme.cjs"),b=require("./OptionsProvider.cjs"),x=require("./Reader.cjs"),S=require("./LocationState.cjs"),C=require("./JsonConvert.cjs"),w=require("./IWallpaperProvider.cjs"),T=require("./network/HttpClient.cjs"),E=require("./services/file/IFileDecrypter.cjs"),D=require("./navigator/INavigator.cjs"),O=require("./navigator/IPagingNavigator.cjs"),k=require("./services/loading/ILoading.cjs"),A=require("./device/IDevice.cjs"),j=require("./web/scheduler.cjs"),M=require("./device/WebBrowser.cjs"),N=require("./IDocument.cjs"),P=require("./shape/SimpleMatrix.cjs"),F=require("./i18n/ILocale.cjs"),I=require("./i18n/textDirection.cjs"),L=require("./plugins/PluginCore.cjs"),R=require("./services/font/IFontProvider.cjs"),z=require("./nav/Nav.cjs"),B=require("./web/debounce.cjs"),V=require("./io/IByteSource.cjs"),H=require("./io/BlobByteSource.cjs"),U=require("./io/MemoryByteSource.cjs"),W=require("./io/HttpByteSource.cjs"),G=require("./ContentRange.cjs");let K=require("js-logger"),q=require("perfect-debounce");exports.AnimationClassName=p.AnimationClassName,exports.BlobByteSource=H.BlobByteSource,exports.BrowserCapabilities=n.BrowserCapabilities,exports.CORE_SERVICE_KEYS=m.CORE_SERVICE_KEYS,exports.Context=d.Context,exports.DecryptFile=E.DecryptFile,exports.DecryptParentFile=E.DecryptParentFile,exports.DeviceInfo=A.DeviceInfo,exports.ElementInitialNumberName=p.ElementInitialNumberName,exports.ElementMtInitialNumberName=p.ElementMtInitialNumberName,exports.EventEmitter=r.EventEmitter,exports.EventNames=e.EventNames,exports.ExtractImageOptions=N.ExtractImageOptions,exports.FileLoader=h.FileLoader,exports.FileLocation=l.FileLocation,exports.FilePackage=f.FilePackage,exports.Font=R.Font,exports.FontConfig=R.FontConfig,exports.FontResource=R.FontResource,Object.defineProperty(exports,"GlobalLogger",{enumerable:!0,get:function(){return K.GlobalLogger}}),exports.GotoPercentegeOptions=D.GotoPercentegeOptions,exports.GotoResult=N.GotoResult,exports.HttpByteSource=W.HttpByteSource,exports.HttpClient=T.HttpClient,Object.defineProperty(exports,"ILogHandler",{enumerable:!0,get:function(){return K.ILogHandler}}),Object.defineProperty(exports,"ILogLevel",{enumerable:!0,get:function(){return K.ILogLevel}}),Object.defineProperty(exports,"ILogger",{enumerable:!0,get:function(){return K.ILogger}}),Object.defineProperty(exports,"ILoggerOpts",{enumerable:!0,get:function(){return K.ILoggerOpts}}),exports.ImageActionDescriptor=N.ImageActionDescriptor,exports.ImageDescriptor=N.ImageDescriptor,exports.JsonConvert=C.JsonConvert,exports.Language=F.Language,exports.LastElementAttributeName=p.LastElementAttributeName,exports.LoadingOptions=k.LoadingOptions,exports.LocationState=S.LocationState,exports.LogLevel=i.LogLevel,exports.MIN_HOST_VIEWPORT_PX=g.MIN_HOST_VIEWPORT_PX,exports.MTTAG=p.MTTAG,exports.MediaTypeRegistry=a.MediaTypeRegistry,exports.MemoryByteSource=U.MemoryByteSource,exports.Metadata=s.Metadata,exports.Nav=z.Nav,exports.NavPoint=z.NavPoint,exports.OpenOptions=c.OpenOptions,exports.OptionKeys=o.OptionKeys,exports.Options=o.Options,exports.OptionsCssKeys=o.OptionsCssKeys,exports.OptionsProvider=b.OptionsProvider,exports.PageChangeOptions=O.PageChangeOptions,exports.PagingExtra=O.PagingExtra,exports.PluginCore=L.PluginCore,exports.PluginManager=v.PluginManager,exports.PluginRegistry=_.PluginRegistry,exports.Progress=l.Progress,exports.ROOT_IDX=p.ROOT_IDX,exports.Reader=x.Reader,exports.ReadingLocation=l.ReadingLocation,exports.RtlLanguageCodes=I.RtlLanguageCodes,exports.STTAG=p.STTAG,exports.ServiceCollection=m.ServiceCollection,exports.SimpleMatrix=P.SimpleMatrix,exports.SpineFile=f.SpineFile,exports.TextFormatOptions=N.TextFormatOptions,exports.Theme=y.Theme,exports.ThemeCssKeys=y.ThemeCssKeys,exports.UI_SERVICE_KEYS=m.UI_SERVICE_KEYS,exports.Wallpaper=w.Wallpaper,exports.WebBrowser=M.WebBrowser,exports.applyPagingLocationFrom=u.applyPagingLocationFrom,exports.assertByteRange=V.assertByteRange,exports.asyncDebounce=q.debounce,exports.debounce=B.debounce,exports.fillMetadata=s.fillMetadata,exports.findNearestObserverRoot=g.findNearestObserverRoot,exports.findNearestScrollElement=g.findNearestScrollElement,exports.formatFileSize=t.formatFileSize,exports.isAppLocationFrom=u.isAppLocationFrom,exports.isFixedContentRange=G.isFixedContentRange,exports.isMediaContentRange=G.isMediaContentRange,exports.isOptionKey=o.isOptionKey,exports.isOptionsCssKey=o.isOptionsCssKey,exports.isReflowableContentRange=G.isReflowableContentRange,exports.isRtlLanguage=I.isRtlLanguage,exports.locationFromOfPagingExtra=u.locationFromOfPagingExtra,exports.materialize=V.materialize,exports.normalizeLanguageCode=I.normalizeLanguageCode,exports.openHttpByteSource=W.openHttpByteSource,exports.probeDefiniteHostHeight=g.probeDefiniteHostHeight,exports.readExact=V.readExact,exports.readerPrefixName=p.readerPrefixName,exports.refreshHostViewportSize=g.refreshHostViewportSize,exports.resolveHostViewport=g.resolveHostViewport,exports.resolveTextDirectionFromLanguage=I.resolveTextDirectionFromLanguage,exports.resolveViewportHeight=g.resolveViewportHeight,exports.shouldSetUserChangedProgress=u.shouldSetUserChangedProgress,exports.sliceByteSource=V.sliceByteSource,exports.supportScheduler=j.supportScheduler,exports.throttle=B.throttle,exports.toMetadataList=s.toMetadataList,exports.unescapeHtml=s.unescapeHtml,exports.whitespaceRegex=p.whitespaceRegex,exports.yieldToMain=j.yieldToMain;
|
package/dist/kernal/index.d.ts
CHANGED
|
@@ -58,8 +58,5 @@ export { assertByteRange, materialize, readExact, sliceByteSource } from './io/I
|
|
|
58
58
|
export { BlobByteSource } from './io/BlobByteSource';
|
|
59
59
|
export { HttpByteSource, openHttpByteSource } from './io/HttpByteSource';
|
|
60
60
|
export { MemoryByteSource } from './io/MemoryByteSource';
|
|
61
|
-
export { computeMd5, computeSimpleId } from './crypto/MD5';
|
|
62
|
-
export { createHasher, digestMany, digestStream, HASH_CHUNK_SIZE, SIMPLE_ID_BYTE_LENGTH } from './crypto/hash';
|
|
63
|
-
export type { DigestSource, HashSpec, StreamingHasher } from './crypto/hash';
|
|
64
61
|
export * from './JsonConvert';
|
|
65
62
|
export * from './ContentRange';
|
package/dist/kernal/index.mjs
CHANGED
|
@@ -11,40 +11,38 @@ import { FileLocation as g, Progress as _, ReadingLocation as v } from "./progre
|
|
|
11
11
|
import { applyPagingLocationFrom as y, isAppLocationFrom as b, locationFromOfPagingExtra as x, shouldSetUserChangedProgress as S } from "./progress/userChangedProgress.mjs";
|
|
12
12
|
import { Context as C } from "./Context.mjs";
|
|
13
13
|
import { FilePackage as w, SpineFile as T } from "./IFileParser.mjs";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
|
|
49
|
-
import { GlobalLogger as Xe, ILogHandler as Ze, ILogLevel as Qe, ILogger as $e, ILoggerOpts as et } from "js-logger";
|
|
50
|
-
export { N as AnimationClassName, Ue as BlobByteSource, n as BrowserCapabilities, H as CORE_SERVICE_KEYS, C as Context, le as DecryptFile, ue as DecryptParentFile, he as DeviceInfo, P as ElementInitialNumberName, F as ElementMtInitialNumberName, r as EventEmitter, e as EventNames, ye as ExtractImageOptions, G as FileLoader, g as FileLocation, w as FilePackage, je as Font, Me as FontConfig, Ne as FontResource, Xe as GlobalLogger, de as GotoPercentegeOptions, be as GotoResult, E as HASH_CHUNK_SIZE, Ge as HttpByteSource, ce as HttpClient, Ze as ILogHandler, Qe as ILogLevel, $e as ILogger, et as ILoggerOpts, xe as ImageActionDescriptor, Se as ImageDescriptor, oe as JsonConvert, Te as Language, I as LastElementAttributeName, me as LoadingOptions, ae as LocationState, i as LogLevel, K as MIN_HOST_VIEWPORT_PX, L as MTTAG, a as MediaTypeRegistry, We as MemoryByteSource, d as Metadata, Pe as Nav, Fe as NavPoint, h as OpenOptions, o as OptionKeys, s as Options, c as OptionsCssKeys, re as OptionsProvider, fe as PageChangeOptions, pe as PagingExtra, Ae as PluginCore, ee as PluginManager, $ as PluginRegistry, _ as Progress, R as ROOT_IDX, ie as Reader, v as ReadingLocation, Ee as RtlLanguageCodes, D as SIMPLE_ID_BYTE_LENGTH, z as STTAG, U as ServiceCollection, we as SimpleMatrix, T as SpineFile, Ce as TextFormatOptions, te as Theme, ne as ThemeCssKeys, W as UI_SERVICE_KEYS, se as Wallpaper, ve as WebBrowser, y as applyPagingLocationFrom, ze as assertByteRange, Ie as asyncDebounce, j as computeMd5, M as computeSimpleId, O as createHasher, Le as debounce, k as digestMany, A as digestStream, f as fillMetadata, q as findNearestObserverRoot, J as findNearestScrollElement, t as formatFileSize, b as isAppLocationFrom, qe as isFixedContentRange, Je as isMediaContentRange, l as isOptionKey, u as isOptionsCssKey, Ye as isReflowableContentRange, De as isRtlLanguage, x as locationFromOfPagingExtra, Be as materialize, Oe as normalizeLanguageCode, Ke as openHttpByteSource, Y as probeDefiniteHostHeight, Ve as readExact, B as readerPrefixName, X as refreshHostViewportSize, Z as resolveHostViewport, ke as resolveTextDirectionFromLanguage, Q as resolveViewportHeight, S as shouldSetUserChangedProgress, He as sliceByteSource, ge as supportScheduler, Re as throttle, p as toMetadataList, m as unescapeHtml, V as whitespaceRegex, _e as yieldToMain };
|
|
14
|
+
import { AnimationClassName as E, ElementInitialNumberName as D, ElementMtInitialNumberName as O, LastElementAttributeName as k, MTTAG as A, ROOT_IDX as j, STTAG as M, readerPrefixName as N, whitespaceRegex as P } from "./Constants.mjs";
|
|
15
|
+
import { CORE_SERVICE_KEYS as F, ServiceCollection as I, UI_SERVICE_KEYS as L } from "./services/ServiceCollection.mjs";
|
|
16
|
+
import { FileLoader as R } from "./FileLoader.mjs";
|
|
17
|
+
import { MIN_HOST_VIEWPORT_PX as z, findNearestObserverRoot as B, findNearestScrollElement as V, probeDefiniteHostHeight as H, refreshHostViewportSize as U, resolveHostViewport as W, resolveViewportHeight as G } from "./hostViewport.mjs";
|
|
18
|
+
import { PluginRegistry as K } from "./plugins/PluginRegistry.mjs";
|
|
19
|
+
import { PluginManager as q } from "./plugins/PluginManager.mjs";
|
|
20
|
+
import { Theme as J, ThemeCssKeys as Y } from "./Theme.mjs";
|
|
21
|
+
import { OptionsProvider as X } from "./OptionsProvider.mjs";
|
|
22
|
+
import { Reader as Z } from "./Reader.mjs";
|
|
23
|
+
import { LocationState as Q } from "./LocationState.mjs";
|
|
24
|
+
import { JsonConvert as $ } from "./JsonConvert.mjs";
|
|
25
|
+
import { Wallpaper as ee } from "./IWallpaperProvider.mjs";
|
|
26
|
+
import { HttpClient as te } from "./network/HttpClient.mjs";
|
|
27
|
+
import { DecryptFile as ne, DecryptParentFile as re } from "./services/file/IFileDecrypter.mjs";
|
|
28
|
+
import { GotoPercentegeOptions as ie } from "./navigator/INavigator.mjs";
|
|
29
|
+
import { PageChangeOptions as ae, PagingExtra as oe } from "./navigator/IPagingNavigator.mjs";
|
|
30
|
+
import { LoadingOptions as se } from "./services/loading/ILoading.mjs";
|
|
31
|
+
import { DeviceInfo as ce } from "./device/IDevice.mjs";
|
|
32
|
+
import { supportScheduler as le, yieldToMain as ue } from "./web/scheduler.mjs";
|
|
33
|
+
import { WebBrowser as de } from "./device/WebBrowser.mjs";
|
|
34
|
+
import { ExtractImageOptions as fe, GotoResult as pe, ImageActionDescriptor as me, ImageDescriptor as he, TextFormatOptions as ge } from "./IDocument.mjs";
|
|
35
|
+
import { SimpleMatrix as _e } from "./shape/SimpleMatrix.mjs";
|
|
36
|
+
import { Language as ve } from "./i18n/ILocale.mjs";
|
|
37
|
+
import { RtlLanguageCodes as ye, isRtlLanguage as be, normalizeLanguageCode as xe, resolveTextDirectionFromLanguage as Se } from "./i18n/textDirection.mjs";
|
|
38
|
+
import { PluginCore as Ce } from "./plugins/PluginCore.mjs";
|
|
39
|
+
import { Font as we, FontConfig as Te, FontResource as Ee } from "./services/font/IFontProvider.mjs";
|
|
40
|
+
import { Nav as De, NavPoint as Oe } from "./nav/Nav.mjs";
|
|
41
|
+
import { asyncDebounce as ke, debounce as Ae, throttle as je } from "./web/debounce.mjs";
|
|
42
|
+
import { assertByteRange as Me, materialize as Ne, readExact as Pe, sliceByteSource as Fe } from "./io/IByteSource.mjs";
|
|
43
|
+
import { BlobByteSource as Ie } from "./io/BlobByteSource.mjs";
|
|
44
|
+
import { MemoryByteSource as Le } from "./io/MemoryByteSource.mjs";
|
|
45
|
+
import { HttpByteSource as Re, openHttpByteSource as ze } from "./io/HttpByteSource.mjs";
|
|
46
|
+
import { isFixedContentRange as Be, isMediaContentRange as Ve, isReflowableContentRange as He } from "./ContentRange.mjs";
|
|
47
|
+
import { GlobalLogger as Ue, ILogHandler as We, ILogLevel as Ge, ILogger as Ke, ILoggerOpts as qe } from "js-logger";
|
|
48
|
+
export { E as AnimationClassName, Ie as BlobByteSource, n as BrowserCapabilities, F as CORE_SERVICE_KEYS, C as Context, ne as DecryptFile, re as DecryptParentFile, ce as DeviceInfo, D as ElementInitialNumberName, O as ElementMtInitialNumberName, r as EventEmitter, e as EventNames, fe as ExtractImageOptions, R as FileLoader, g as FileLocation, w as FilePackage, we as Font, Te as FontConfig, Ee as FontResource, Ue as GlobalLogger, ie as GotoPercentegeOptions, pe as GotoResult, Re as HttpByteSource, te as HttpClient, We as ILogHandler, Ge as ILogLevel, Ke as ILogger, qe as ILoggerOpts, me as ImageActionDescriptor, he as ImageDescriptor, $ as JsonConvert, ve as Language, k as LastElementAttributeName, se as LoadingOptions, Q as LocationState, i as LogLevel, z as MIN_HOST_VIEWPORT_PX, A as MTTAG, a as MediaTypeRegistry, Le as MemoryByteSource, d as Metadata, De as Nav, Oe as NavPoint, h as OpenOptions, o as OptionKeys, s as Options, c as OptionsCssKeys, X as OptionsProvider, ae as PageChangeOptions, oe as PagingExtra, Ce as PluginCore, q as PluginManager, K as PluginRegistry, _ as Progress, j as ROOT_IDX, Z as Reader, v as ReadingLocation, ye as RtlLanguageCodes, M as STTAG, I as ServiceCollection, _e as SimpleMatrix, T as SpineFile, ge as TextFormatOptions, J as Theme, Y as ThemeCssKeys, L as UI_SERVICE_KEYS, ee as Wallpaper, de as WebBrowser, y as applyPagingLocationFrom, Me as assertByteRange, ke as asyncDebounce, Ae as debounce, f as fillMetadata, B as findNearestObserverRoot, V as findNearestScrollElement, t as formatFileSize, b as isAppLocationFrom, Be as isFixedContentRange, Ve as isMediaContentRange, l as isOptionKey, u as isOptionsCssKey, He as isReflowableContentRange, be as isRtlLanguage, x as locationFromOfPagingExtra, Ne as materialize, xe as normalizeLanguageCode, ze as openHttpByteSource, H as probeDefiniteHostHeight, Pe as readExact, N as readerPrefixName, U as refreshHostViewportSize, W as resolveHostViewport, Se as resolveTextDirectionFromLanguage, G as resolveViewportHeight, S as shouldSetUserChangedProgress, Fe as sliceByteSource, le as supportScheduler, je as throttle, p as toMetadataList, m as unescapeHtml, P as whitespaceRegex, ue as yieldToMain };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=2097152,t=(e,t)=>{if(!Number.isInteger(e)||!Number.isInteger(t)||e<0||t<e)throw RangeError(`Invalid byte range: ${e}-${t}`)},n=async(e,n,r)=>{t(n,r);let i=await e.read(n,r),a=r-n;if(i.byteLength!==a)throw RangeError(`Expected ${a} bytes at ${n}, received ${i.byteLength}`);return i},r=(e,n,r)=>{if(t(n,r),r>e.size)throw RangeError(`Byte window ${n}-${r} exceeds source size ${e.size}`);let i=r-n;return{size:i,read:async(r,a)=>{if(t(r,a),r>=i)return new Uint8Array;let o=Math.min(a,i);return e.read(n+r,n+o)},close:async()=>{}}},i=async t=>{let n=new Uint8Array(t.size),r=0;for(;r<t.size;){let i=Math.min(r+e,t.size),a=await t.read(r,i);if(a.byteLength===0)break;n.set(a,r),r+=a.byteLength}return n.buffer};exports.assertByteRange=t,exports.materialize=i,exports.readExact=n,exports.sliceByteSource=r;
|
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import { HASH_CHUNK_SIZE as e } from "../crypto/hash.mjs";
|
|
2
1
|
//#region kernal/io/IByteSource.ts
|
|
3
|
-
var
|
|
2
|
+
var e = (e, t) => {
|
|
4
3
|
if (!Number.isInteger(e) || !Number.isInteger(t) || e < 0 || t < e) throw RangeError(`Invalid byte range: ${e}-${t}`);
|
|
5
|
-
},
|
|
6
|
-
|
|
7
|
-
let i = await
|
|
4
|
+
}, t = async (t, n, r) => {
|
|
5
|
+
e(n, r);
|
|
6
|
+
let i = await t.read(n, r), a = r - n;
|
|
8
7
|
if (i.byteLength !== a) throw RangeError(`Expected ${a} bytes at ${n}, received ${i.byteLength}`);
|
|
9
8
|
return i;
|
|
10
|
-
},
|
|
11
|
-
if (
|
|
9
|
+
}, n = (t, n, r) => {
|
|
10
|
+
if (e(n, r), r > t.size) throw RangeError(`Byte window ${n}-${r} exceeds source size ${t.size}`);
|
|
12
11
|
let i = r - n;
|
|
13
12
|
return {
|
|
14
13
|
size: i,
|
|
15
14
|
read: async (r, a) => {
|
|
16
|
-
if (
|
|
15
|
+
if (e(r, a), r >= i) return /* @__PURE__ */ new Uint8Array();
|
|
17
16
|
let o = Math.min(a, i);
|
|
18
|
-
return
|
|
17
|
+
return t.read(n + r, n + o);
|
|
19
18
|
},
|
|
20
19
|
close: async () => {}
|
|
21
20
|
};
|
|
22
|
-
},
|
|
23
|
-
let
|
|
24
|
-
for (;
|
|
25
|
-
let
|
|
26
|
-
if (
|
|
27
|
-
|
|
21
|
+
}, r = async (e) => {
|
|
22
|
+
let t = new Uint8Array(e.size), n = 0;
|
|
23
|
+
for (; n < e.size;) {
|
|
24
|
+
let r = Math.min(n + 2097152, e.size), i = await e.read(n, r);
|
|
25
|
+
if (i.byteLength === 0) break;
|
|
26
|
+
t.set(i, n), n += i.byteLength;
|
|
28
27
|
}
|
|
29
|
-
return
|
|
28
|
+
return t.buffer;
|
|
30
29
|
};
|
|
31
30
|
//#endregion
|
|
32
|
-
export {
|
|
31
|
+
export { e as assertByteRange, r as materialize, t as readExact, n as sliceByteSource };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Metadata.cjs"),t=require("../progress/Progress.cjs"),n=require("../Context.cjs"),r=require("../IFileParser.cjs"),i=require("./metadata.cjs");var a=class{constructor(e){this.deps=e}async load(r,a,o){let{inputFormatter:s,mediaTypeRegistry:c,options:l,events:u,lifecycle:d}=this.deps;s.guardUrl(r);let f=await s.formatInputParameters(r,a);if(!f.extension)throw Error(`file extension is required`);await d.onInitialize?.(f.extension);let p=await this.resolveSimpleId(f.url,f.openOptions);await d.onOptionsParse?.(l);let m={url:f.url,openOptions:f.openOptions,extension:f.extension,id:p},h=await o?.prepareContext?.(m),g=new n.Context(u,{id:p,url:f.url,extension:f.extension,options:l,openOptions:f.openOptions,...o?.contextInit,...h});o?.attachContext?.(g);let{url:_,abortController:v}=s.formatParserUrl(f.url,f.extension,f.openOptions);o?.onAbortController?.(v);let y=await c.createFileParser(_,f.extension);if(await y.load({measureFilePercentage:o?.measureFilePercentage}),o?.isCancelled?.())throw Error(`User cancelled task`);let b=s.formatLocation(f.openOptions?.location,f.extension),x=b.location,S=b.percentage;if(!(x!=null||!isNaN(S)&&S<=1&&S>=0))try{x=await d.onLocationRequest?.(p)??new t.FileLocation(`0`,1,`ratio`)}catch{x=new t.FileLocation(`0`,1,`ratio`)}await o?.afterParserReady?.(f.extension);let C=typeof f.openOptions?.fileName==`string`?f.openOptions.fileName.trim():``,w=i.formatMetadata(await y.getMetadata(),f.url,f.extension,C),T=f.openOptions?.metadata,E=e.fillMetadata(w,T);return T?.fileName&&typeof T.fileName==`string`&&T.fileName.trim()?E.fileName=T.fileName.trim():C&&!i.isUriLikeBookTitle(C)&&(E.fileName=C),g.metadata=E,await d.onFileParsed?.(y),{url:f.url,openOptions:f.openOptions,extension:f.extension,id:p,fileParser:y,metadata:E,context:g,abortController:v,location:x,percentage:S}}async resolveSimpleId(e,t){let n=typeof t?.id==`string`?t.id.trim():``;if(n)return n;if(e instanceof r.FilePackage){let t=typeof e.id==`string`?e.id.trim():``;if(t)return t}let i=await this.deps.services.get(`simpleIdProvider`);return i
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Metadata.cjs"),t=require("../progress/Progress.cjs"),n=require("../Context.cjs"),r=require("../IFileParser.cjs"),i=require("./metadata.cjs");var a=class{constructor(e){this.deps=e}async load(r,a,o){let{inputFormatter:s,mediaTypeRegistry:c,options:l,events:u,lifecycle:d}=this.deps;s.guardUrl(r);let f=await s.formatInputParameters(r,a);if(!f.extension)throw Error(`file extension is required`);await d.onInitialize?.(f.extension);let p=await this.resolveSimpleId(f.url,f.openOptions);await d.onOptionsParse?.(l);let m={url:f.url,openOptions:f.openOptions,extension:f.extension,id:p},h=await o?.prepareContext?.(m),g=new n.Context(u,{id:p,url:f.url,extension:f.extension,options:l,openOptions:f.openOptions,...o?.contextInit,...h});o?.attachContext?.(g);let{url:_,abortController:v}=s.formatParserUrl(f.url,f.extension,f.openOptions);o?.onAbortController?.(v);let y=await c.createFileParser(_,f.extension);if(await y.load({measureFilePercentage:o?.measureFilePercentage}),o?.isCancelled?.())throw Error(`User cancelled task`);let b=s.formatLocation(f.openOptions?.location,f.extension),x=b.location,S=b.percentage;if(!(x!=null||!isNaN(S)&&S<=1&&S>=0))try{x=await d.onLocationRequest?.(p)??new t.FileLocation(`0`,1,`ratio`)}catch{x=new t.FileLocation(`0`,1,`ratio`)}await o?.afterParserReady?.(f.extension);let C=typeof f.openOptions?.fileName==`string`?f.openOptions.fileName.trim():``,w=i.formatMetadata(await y.getMetadata(),f.url,f.extension,C),T=f.openOptions?.metadata,E=e.fillMetadata(w,T);return T?.fileName&&typeof T.fileName==`string`&&T.fileName.trim()?E.fileName=T.fileName.trim():C&&!i.isUriLikeBookTitle(C)&&(E.fileName=C),g.metadata=E,await d.onFileParsed?.(y),{url:f.url,openOptions:f.openOptions,extension:f.extension,id:p,fileParser:y,metadata:E,context:g,abortController:v,location:x,percentage:S}}async resolveSimpleId(e,t){let n=typeof t?.id==`string`?t.id.trim():``;if(n)return n;if(e instanceof r.FilePackage){let t=typeof e.id==`string`?e.id.trim():``;if(t)return t}let i=await this.deps.services.get(`simpleIdProvider`);if(i)return i.getSimpleId(e);throw Error(`simpleIdProvider is not registered`)}};exports.FileLoadPipeline=a;
|
|
@@ -64,7 +64,8 @@ var o = class {
|
|
|
64
64
|
if (t) return t;
|
|
65
65
|
}
|
|
66
66
|
let i = await this.deps.services.get("simpleIdProvider");
|
|
67
|
-
|
|
67
|
+
if (i) return i.getSimpleId(e);
|
|
68
|
+
throw Error("simpleIdProvider is not registered");
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
71
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../common/object.cjs"),t=require("../common/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../common/object.cjs"),t=require("../common/text.cjs"),n=require("../common/url.cjs"),r=require("../common/path.cjs"),i=require("../OpenOptions.cjs"),a=require("../progress/Progress.cjs"),o=require("../IFileParser.cjs"),s=require("../html/finder.cjs");var c=class{constructor(n,r){this.services=n,this.options=r,this.isFilePackageLike=e=>typeof e!=`object`||!e?!1:e instanceof o.FilePackage?!0:Array.isArray(e)||e instanceof ArrayBuffer||e instanceof Uint8Array||e instanceof Blob||typeof FileSystemFileHandle<`u`&&e instanceof FileSystemFileHandle?!1:`fileUrl`in e||`spineFiles`in e,this.formatLocation=(n,r)=>{let i,o;if(!n)return{location:i,percentage:o};if(n instanceof a.FileLocation)i=n;else if(Object.prototype.toString.call(n)===`[object Object]`){let t=JSON.parse(JSON.stringify(n));if(t.url)return{location:e.deepClone(t),percentage:o}}else if(typeof n==`number`)!isNaN(o)&&o<=1&&o>=0&&(o=n);else if(typeof n==`string`&&!t.isNullOrWhiteSpace(n)){let e=!1;if(n.trim().indexOf(`{`)>=0)try{i=JSON.parse(n.trim()),e=!0}catch{e=!1}if(!e){let e=n.split(/[-_]/);if(e.length==1){let e=parseFloat(n);!isNaN(e)&&e<=1&&e>=0?o=e:!isNaN(e)&&r===`.pdf`&&(i=new a.FileLocation(``,1,`page`),i.current=e)}else if(e.length==2){i=new a.FileLocation(e[0],1,`ratio`);let t=parseFloat(e[1]);if(isNaN(t)){let n=e[1].split(`@`);if(n.length>1){let e=n[0].toLowerCase();e==`char`?i.symbolType=e:i.symbolType=`custom`,t=parseFloat(n[1]),isNaN(t)||t<0?i.current=0:i.current=t}else i.current=0}else i.current=t<0?0:t}else if(e.length==3){i=new a.FileLocation(e[0],1,`ratio`),i.tagName=e[1];let t=parseInt(e[2]);isNaN(t)||t<0?i.tagIndex=0:i.tagIndex=t}}}return{location:i,percentage:o}}}formatOpenOptions(e){let t=Object.assign(new i.OpenOptions,e);return t||=new i.OpenOptions,Object.keys(t).forEach(e=>{(t[e]===null||t[e]===void 0||t[e]===``)&&delete t[e]}),t}async getOpenUrl(e,t){let n=e;if(!this.isValidFileUrl(e)){let e=await this.services.get(`fileUrlProvider`,!1);if(!e)return;n=await e.getUrl(t)}return this.formatUrl(n)}async formatInputParameters(e,t){let n=await this.getOpenUrl(e,t),r=this.formatOpenOptions(t);return{url:n,openOptions:r,extension:this.formatExtension(n,r.extension)}}guardUrl(e){if(!this.isValidFileUrl(e)&&!this.services.has(`fileUrlProvider`))throw Error(`FileUrlProvider is not registered`)}formatUrl(e){return this.isFilePackageLike(e)&&!(e instanceof o.FilePackage)&&(e=Object.assign(new o.FilePackage,e)),e}isValidFileUrl(e){return e?typeof e==`string`||e instanceof Array||e instanceof o.FilePackage||e instanceof ArrayBuffer||e instanceof Uint8Array||e instanceof Blob||globalThis.FileSystemFileHandle&&e instanceof FileSystemFileHandle?!0:(typeof e==`object`&&Object.keys(e).length,!1):!1}formatReaderWrapper(e){let t;return t=typeof e==`string`?document.querySelector(e):e,t instanceof t.ownerDocument.defaultView.window.HTMLHtmlElement&&(t=s.getDocumentBody(t.ownerDocument)),t.style.overflow=`hidden`,t.style.position=`relative`,t}formatExtension(e,n){let i=n??``;if(t.isNullOrWhiteSpace(i)){if(typeof e==`string`)i=r.getExtension(e)??``;else if(e instanceof Array){let t=e;if(t.length==0)throw Error(`multiUrls is required`);i=r.getExtension(t[0])??``}else e instanceof o.FilePackage?t.isNullOrWhiteSpace(e.extension)?!t.isNullOrWhiteSpace(e.fileUrl)&&typeof e.fileUrl==`string`&&(i=r.getExtension(e.fileUrl)):i=e.extension:globalThis.FileSystemFileHandle&&e instanceof FileSystemFileHandle&&(i=r.getExtension(e.name))}return i.startsWith(`.`)||(i=`.`+i),i?.toLowerCase()}formatParserUrl(e,t,r){let i;e instanceof o.FilePackage||e instanceof Array?i=e:(i=new o.FilePackage,i.fileUrl=e,i.extension=t);let{metadata:a,...s}=r;i=Object.assign(i,s);let c;return(typeof e==`string`||e?.fileUrl&&typeof e.fileUrl==`string`&&n.checkIsHttpUrl(e.fileUrl))&&(c=new AbortController,i.abortController=c),{url:i,abortController:c}}};exports.InputFormatter=c;
|
|
@@ -20,7 +20,6 @@ export declare class InputFormatter {
|
|
|
20
20
|
private isValidFileUrl;
|
|
21
21
|
formatReaderWrapper(container: string | HTMLElement): HTMLElement;
|
|
22
22
|
private formatExtension;
|
|
23
|
-
getSimpleId: (url: any, existId?: string) => Promise<string>;
|
|
24
23
|
formatLocation: (inputLocation: FileLocation | number | string, extension: string) => {
|
|
25
24
|
location: FileLocation;
|
|
26
25
|
percentage: number;
|
|
@@ -1,55 +1,42 @@
|
|
|
1
1
|
import { deepClone as e } from "../common/object.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { computeSimpleId as c } from "../crypto/MD5.mjs";
|
|
10
|
-
import { getDocumentBody as l } from "../html/finder.mjs";
|
|
2
|
+
import { isNullOrWhiteSpace as t } from "../common/text.mjs";
|
|
3
|
+
import { checkIsHttpUrl as n } from "../common/url.mjs";
|
|
4
|
+
import { getExtension as r } from "../common/path.mjs";
|
|
5
|
+
import { OpenOptions as i } from "../OpenOptions.mjs";
|
|
6
|
+
import { FileLocation as a } from "../progress/Progress.mjs";
|
|
7
|
+
import { FilePackage as o } from "../IFileParser.mjs";
|
|
8
|
+
import { getDocumentBody as s } from "../html/finder.mjs";
|
|
11
9
|
//#region kernal/pipelines/InputFormatter.ts
|
|
12
|
-
var
|
|
13
|
-
constructor(
|
|
14
|
-
this.services =
|
|
15
|
-
let i
|
|
16
|
-
if (!
|
|
17
|
-
if (n(i)) {
|
|
18
|
-
if (typeof e == "string" || e instanceof ArrayBuffer || e instanceof Uint8Array || e instanceof Blob || globalThis.FileSystemFileHandle && e instanceof FileSystemFileHandle) i = await c(e);
|
|
19
|
-
else if (e instanceof s) {
|
|
20
|
-
if (e.id) i = e.id;
|
|
21
|
-
else throw Error("Missing id in FilePackage");
|
|
22
|
-
} else i = t();
|
|
23
|
-
}
|
|
24
|
-
return i;
|
|
25
|
-
}, this.formatLocation = (t, r) => {
|
|
26
|
-
let i, a;
|
|
27
|
-
if (!t) return {
|
|
10
|
+
var c = class {
|
|
11
|
+
constructor(n, r) {
|
|
12
|
+
this.services = n, this.options = r, this.isFilePackageLike = (e) => typeof e != "object" || !e ? !1 : e instanceof o ? !0 : Array.isArray(e) || e instanceof ArrayBuffer || e instanceof Uint8Array || e instanceof Blob || typeof FileSystemFileHandle < "u" && e instanceof FileSystemFileHandle ? !1 : "fileUrl" in e || "spineFiles" in e, this.formatLocation = (n, r) => {
|
|
13
|
+
let i, o;
|
|
14
|
+
if (!n) return {
|
|
28
15
|
location: i,
|
|
29
|
-
percentage:
|
|
16
|
+
percentage: o
|
|
30
17
|
};
|
|
31
|
-
if (
|
|
32
|
-
else if (Object.prototype.toString.call(
|
|
33
|
-
let
|
|
34
|
-
if (
|
|
35
|
-
location: e(
|
|
36
|
-
percentage:
|
|
18
|
+
if (n instanceof a) i = n;
|
|
19
|
+
else if (Object.prototype.toString.call(n) === "[object Object]") {
|
|
20
|
+
let t = JSON.parse(JSON.stringify(n));
|
|
21
|
+
if (t.url) return {
|
|
22
|
+
location: e(t),
|
|
23
|
+
percentage: o
|
|
37
24
|
};
|
|
38
|
-
} else if (typeof
|
|
39
|
-
else if (typeof
|
|
25
|
+
} else if (typeof n == "number") !isNaN(o) && o <= 1 && o >= 0 && (o = n);
|
|
26
|
+
else if (typeof n == "string" && !t(n)) {
|
|
40
27
|
let e = !1;
|
|
41
|
-
if (
|
|
42
|
-
i = JSON.parse(
|
|
28
|
+
if (n.trim().indexOf("{") >= 0) try {
|
|
29
|
+
i = JSON.parse(n.trim()), e = !0;
|
|
43
30
|
} catch {
|
|
44
31
|
e = !1;
|
|
45
32
|
}
|
|
46
33
|
if (!e) {
|
|
47
|
-
let e =
|
|
34
|
+
let e = n.split(/[-_]/);
|
|
48
35
|
if (e.length == 1) {
|
|
49
|
-
let e = parseFloat(
|
|
50
|
-
!isNaN(e) && e <= 1 && e >= 0 ?
|
|
36
|
+
let e = parseFloat(n);
|
|
37
|
+
!isNaN(e) && e <= 1 && e >= 0 ? o = e : !isNaN(e) && r === ".pdf" && (i = new a("", 1, "page"), i.current = e);
|
|
51
38
|
} else if (e.length == 2) {
|
|
52
|
-
i = new
|
|
39
|
+
i = new a(e[0], 1, "ratio");
|
|
53
40
|
let t = parseFloat(e[1]);
|
|
54
41
|
if (isNaN(t)) {
|
|
55
42
|
let n = e[1].split("@");
|
|
@@ -59,7 +46,7 @@ var u = class {
|
|
|
59
46
|
} else i.current = 0;
|
|
60
47
|
} else i.current = t < 0 ? 0 : t;
|
|
61
48
|
} else if (e.length == 3) {
|
|
62
|
-
i = new
|
|
49
|
+
i = new a(e[0], 1, "ratio"), i.tagName = e[1];
|
|
63
50
|
let t = parseInt(e[2]);
|
|
64
51
|
isNaN(t) || t < 0 ? i.tagIndex = 0 : i.tagIndex = t;
|
|
65
52
|
}
|
|
@@ -67,13 +54,13 @@ var u = class {
|
|
|
67
54
|
}
|
|
68
55
|
return {
|
|
69
56
|
location: i,
|
|
70
|
-
percentage:
|
|
57
|
+
percentage: o
|
|
71
58
|
};
|
|
72
59
|
};
|
|
73
60
|
}
|
|
74
61
|
formatOpenOptions(e) {
|
|
75
|
-
let t = Object.assign(new
|
|
76
|
-
return t ||= new
|
|
62
|
+
let t = Object.assign(new i(), e);
|
|
63
|
+
return t ||= new i(), Object.keys(t).forEach((e) => {
|
|
77
64
|
(t[e] === null || t[e] === void 0 || t[e] === "") && delete t[e];
|
|
78
65
|
}), t;
|
|
79
66
|
}
|
|
@@ -98,38 +85,38 @@ var u = class {
|
|
|
98
85
|
if (!this.isValidFileUrl(e) && !this.services.has("fileUrlProvider")) throw Error("FileUrlProvider is not registered");
|
|
99
86
|
}
|
|
100
87
|
formatUrl(e) {
|
|
101
|
-
return this.isFilePackageLike(e) && !(e instanceof
|
|
88
|
+
return this.isFilePackageLike(e) && !(e instanceof o) && (e = Object.assign(new o(), e)), e;
|
|
102
89
|
}
|
|
103
90
|
isValidFileUrl(e) {
|
|
104
|
-
return e ? typeof e == "string" || e instanceof Array || e instanceof
|
|
91
|
+
return e ? typeof e == "string" || e instanceof Array || e instanceof o || e instanceof ArrayBuffer || e instanceof Uint8Array || e instanceof Blob || globalThis.FileSystemFileHandle && e instanceof FileSystemFileHandle ? !0 : (typeof e == "object" && Object.keys(e).length, !1) : !1;
|
|
105
92
|
}
|
|
106
93
|
formatReaderWrapper(e) {
|
|
107
94
|
let t;
|
|
108
|
-
return t = typeof e == "string" ? document.querySelector(e) : e, t instanceof t.ownerDocument.defaultView.window.HTMLHtmlElement && (t =
|
|
95
|
+
return t = typeof e == "string" ? document.querySelector(e) : e, t instanceof t.ownerDocument.defaultView.window.HTMLHtmlElement && (t = s(t.ownerDocument)), t.style.overflow = "hidden", t.style.position = "relative", t;
|
|
109
96
|
}
|
|
110
|
-
formatExtension(e,
|
|
111
|
-
let
|
|
112
|
-
if (
|
|
113
|
-
if (typeof e == "string")
|
|
97
|
+
formatExtension(e, n) {
|
|
98
|
+
let i = n ?? "";
|
|
99
|
+
if (t(i)) {
|
|
100
|
+
if (typeof e == "string") i = r(e) ?? "";
|
|
114
101
|
else if (e instanceof Array) {
|
|
115
102
|
let t = e;
|
|
116
103
|
if (t.length == 0) throw Error("multiUrls is required");
|
|
117
|
-
|
|
118
|
-
} else e instanceof
|
|
104
|
+
i = r(t[0]) ?? "";
|
|
105
|
+
} else e instanceof o ? t(e.extension) ? !t(e.fileUrl) && typeof e.fileUrl == "string" && (i = r(e.fileUrl)) : i = e.extension : globalThis.FileSystemFileHandle && e instanceof FileSystemFileHandle && (i = r(e.name));
|
|
119
106
|
}
|
|
120
|
-
return
|
|
107
|
+
return i.startsWith(".") || (i = "." + i), i?.toLowerCase();
|
|
121
108
|
}
|
|
122
|
-
formatParserUrl(e, t,
|
|
109
|
+
formatParserUrl(e, t, r) {
|
|
123
110
|
let i;
|
|
124
|
-
e instanceof
|
|
125
|
-
let { metadata: a, ...
|
|
126
|
-
i = Object.assign(i,
|
|
111
|
+
e instanceof o || e instanceof Array ? i = e : (i = new o(), i.fileUrl = e, i.extension = t);
|
|
112
|
+
let { metadata: a, ...s } = r;
|
|
113
|
+
i = Object.assign(i, s);
|
|
127
114
|
let c;
|
|
128
|
-
return (typeof e == "string" || e?.fileUrl && typeof e.fileUrl == "string" &&
|
|
115
|
+
return (typeof e == "string" || e?.fileUrl && typeof e.fileUrl == "string" && n(e.fileUrl)) && (c = new AbortController(), i.abortController = c), {
|
|
129
116
|
url: i,
|
|
130
117
|
abortController: c
|
|
131
118
|
};
|
|
132
119
|
}
|
|
133
120
|
};
|
|
134
121
|
//#endregion
|
|
135
|
-
export {
|
|
122
|
+
export { c as InputFormatter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.keys({httpClient:!0,internalUrlBuilder:!0,fileUrlParser:!0,crypto:!0,fileUrlProvider:!0,fileDecrypter:!0,fileProvider:!0,simpleIdProvider:!0}),t=Object.keys({notifier:!0,loading:!0,themeProvider:!0,wallpaperProvider:!0,loadLayer:!0,fullscreen:!0}),n=class{constructor(e,t,n){this.locale=e,this.events=t,this.readerInfo=n,this.services=new Map}add(e,t){this.services.set(e,t)}async get(e,t){let n=this.services.get(e);if(n===void 0){if(t)throw Error(`Service "${String(e)}" is not registered.`);return}return await n()}has(e){return this.services.has(e)}remove(e){this.services.delete(e)}clear(){this.services.clear()}asReaderServices(){return this}registerCoreServices(){this.has(`httpClient`)||this.add(`httpClient`,async()=>{let{HttpClient:e}=await Promise.resolve().then(()=>require("../network/HttpClient.cjs"));return new e}),this.has(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.keys({httpClient:!0,internalUrlBuilder:!0,fileUrlParser:!0,crypto:!0,fileUrlProvider:!0,fileDecrypter:!0,fileProvider:!0,simpleIdProvider:!0}),t=Object.keys({notifier:!0,loading:!0,themeProvider:!0,wallpaperProvider:!0,loadLayer:!0,fullscreen:!0}),n=class{constructor(e,t,n){this.locale=e,this.events=t,this.readerInfo=n,this.services=new Map}add(e,t){this.services.set(e,t)}async get(e,t){let n=this.services.get(e);if(n===void 0){if(t)throw Error(`Service "${String(e)}" is not registered.`);return}return await n()}has(e){return this.services.has(e)}remove(e){this.services.delete(e)}clear(){this.services.clear()}asReaderServices(){return this}registerCoreServices(){this.has(`httpClient`)||this.add(`httpClient`,async()=>{let{HttpClient:e}=await Promise.resolve().then(()=>require("../network/HttpClient.cjs"));return new e}),this.has(`internalUrlBuilder`)||this.add(`internalUrlBuilder`,async()=>{let{DefaultInternalUrlBuilder:e}=await Promise.resolve().then(()=>require("./internalUrlBuilder/DefaultInternalUrlBuilder.cjs"));return new e(this.readerInfo.baseUrl,this.readerInfo.preventCacheHash)}),this.has(`fileUrlParser`)||this.add(`fileUrlParser`,async()=>{let{DefaultFileUrlParser:e}=await Promise.resolve().then(()=>require("./fileUrlParser/DefaultFileUrlParser.cjs"));return new e(await this.get(`httpClient`,!0),await this.get(`internalUrlBuilder`,!0),this.locale)})}registerUiServices(){this.has(`notifier`)||this.add(`notifier`,async()=>{let{DefaultNotifier:e}=await Promise.resolve().then(()=>require("./notifier/DefaultNotifier.cjs"));return new e}),this.has(`loading`)||this.add(`loading`,async()=>{let{DefaultLoading:e}=await Promise.resolve().then(()=>require("./loading/DefaultLoading.cjs"));return new e(this.locale)}),this.has(`loadLayer`)||this.add(`loadLayer`,async()=>{let{HtmlLoadLayer:e}=await Promise.resolve().then(()=>require("./docLoadLayer/HtmlLoadLayer.cjs"));return new e(this.events,this.locale)})}};exports.CORE_SERVICE_KEYS=e,exports.ServiceCollection=n,exports.UI_SERVICE_KEYS=t;
|
|
@@ -46,9 +46,6 @@ var e = Object.keys({
|
|
|
46
46
|
this.has("httpClient") || this.add("httpClient", async () => {
|
|
47
47
|
let { HttpClient: e } = await import("../network/HttpClient.mjs");
|
|
48
48
|
return new e();
|
|
49
|
-
}), this.has("crypto") || this.add("crypto", async () => {
|
|
50
|
-
let { WebCrypto: e } = await import("../crypto/WebCrypto.mjs");
|
|
51
|
-
return new e();
|
|
52
49
|
}), this.has("internalUrlBuilder") || this.add("internalUrlBuilder", async () => {
|
|
53
50
|
let { DefaultInternalUrlBuilder: e } = await import("./internalUrlBuilder/DefaultInternalUrlBuilder.mjs");
|
|
54
51
|
return new e(this.readerInfo.baseUrl, this.readerInfo.preventCacheHash);
|