@d-i-t-a/reader 3.0.0-alpha.6 → 3.0.0-alpha.7
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/esm/index.js +44 -79
- package/dist/esm/index.js.map +4 -4
- package/dist/reader.js +49 -49
- package/dist/reader.js.map +4 -4
- package/dist/types/model/Link.d.ts +7 -5
- package/dist/types/model/v3/Publication.d.ts +6 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -14676,7 +14676,7 @@ var require_lodash = __commonJS({
|
|
|
14676
14676
|
} else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
|
14677
14677
|
newValue = objValue;
|
|
14678
14678
|
if (isArguments(objValue)) {
|
|
14679
|
-
newValue =
|
|
14679
|
+
newValue = toPlainObject2(objValue);
|
|
14680
14680
|
} else if (!isObject(objValue) || isFunction(objValue)) {
|
|
14681
14681
|
newValue = initCloneObject(srcValue);
|
|
14682
14682
|
}
|
|
@@ -17317,7 +17317,7 @@ var require_lodash = __commonJS({
|
|
|
17317
17317
|
var isBinary = reIsBinary.test(value);
|
|
17318
17318
|
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
17319
17319
|
}
|
|
17320
|
-
function
|
|
17320
|
+
function toPlainObject2(value) {
|
|
17321
17321
|
return copyObject(value, keysIn(value));
|
|
17322
17322
|
}
|
|
17323
17323
|
function toSafeInteger(value) {
|
|
@@ -18197,7 +18197,7 @@ var require_lodash = __commonJS({
|
|
|
18197
18197
|
lodash4.toPairs = toPairs;
|
|
18198
18198
|
lodash4.toPairsIn = toPairsIn;
|
|
18199
18199
|
lodash4.toPath = toPath;
|
|
18200
|
-
lodash4.toPlainObject =
|
|
18200
|
+
lodash4.toPlainObject = toPlainObject2;
|
|
18201
18201
|
lodash4.transform = transform;
|
|
18202
18202
|
lodash4.unary = unary;
|
|
18203
18203
|
lodash4.union = union;
|
|
@@ -68637,7 +68637,7 @@ var Link = class extends U {
|
|
|
68637
68637
|
// src/model/v3/Publication.ts
|
|
68638
68638
|
function toLink(link) {
|
|
68639
68639
|
if (link instanceof Link) return link;
|
|
68640
|
-
return
|
|
68640
|
+
return new Link({
|
|
68641
68641
|
href: link.href,
|
|
68642
68642
|
templated: link.templated,
|
|
68643
68643
|
type: link.type,
|
|
@@ -68663,6 +68663,27 @@ var Publication = class _Publication {
|
|
|
68663
68663
|
this.manifest = manifest;
|
|
68664
68664
|
this.manifestUrl = manifestUrl;
|
|
68665
68665
|
}
|
|
68666
|
+
/**
|
|
68667
|
+
* Create a Publication from a raw JSON object.
|
|
68668
|
+
* Handles both RWPM (camelCase) and legacy (PascalCase) key formats.
|
|
68669
|
+
* Returns null if the JSON cannot be parsed.
|
|
68670
|
+
*/
|
|
68671
|
+
static fromJSON(json, url) {
|
|
68672
|
+
const normalized = {
|
|
68673
|
+
metadata: json.metadata ?? json.Metadata ?? { title: "" },
|
|
68674
|
+
links: json.links ?? json.Links ?? [],
|
|
68675
|
+
readingOrder: json.readingOrder ?? json.spine ?? json.Spine ?? [],
|
|
68676
|
+
resources: json.resources ?? json.Resources,
|
|
68677
|
+
toc: json.toc ?? json.TOC
|
|
68678
|
+
};
|
|
68679
|
+
if (!normalized.metadata.title) {
|
|
68680
|
+
normalized.metadata.title = normalized.metadata.Title ?? "";
|
|
68681
|
+
}
|
|
68682
|
+
const manifest = Ue.deserialize(normalized);
|
|
68683
|
+
if (!manifest) return null;
|
|
68684
|
+
manifest.setSelfLink(url.href);
|
|
68685
|
+
return new _Publication(manifest, url);
|
|
68686
|
+
}
|
|
68666
68687
|
static async fromUrl(url, requestConfig) {
|
|
68667
68688
|
const response = await fetch(url.href, requestConfig);
|
|
68668
68689
|
const manifestJSON = await response.json();
|
|
@@ -76921,16 +76942,6 @@ var MediaOverlayNode = class _MediaOverlayNode {
|
|
|
76921
76942
|
}
|
|
76922
76943
|
};
|
|
76923
76944
|
|
|
76924
|
-
// src/utils/JsonUtil.ts
|
|
76925
|
-
init_polyfills();
|
|
76926
|
-
function TaJsonDeserialize(json, type) {
|
|
76927
|
-
if (type && typeof type.deserialize === "function") {
|
|
76928
|
-
const result = type.deserialize(json);
|
|
76929
|
-
if (result) return result;
|
|
76930
|
-
}
|
|
76931
|
-
return Object.assign(new type(), json);
|
|
76932
|
-
}
|
|
76933
|
-
|
|
76934
76945
|
// src/modules/mediaoverlays/MediaOverlaySettings.ts
|
|
76935
76946
|
init_polyfills();
|
|
76936
76947
|
init_HTMLUtilities();
|
|
@@ -77393,10 +77404,7 @@ var MediaOverlayModule = class {
|
|
|
77393
77404
|
import_loglevel11.default.log("## moJson" + moJson);
|
|
77394
77405
|
return;
|
|
77395
77406
|
}
|
|
77396
|
-
link.mediaOverlayNode =
|
|
77397
|
-
moJson,
|
|
77398
|
-
MediaOverlayNode
|
|
77399
|
-
);
|
|
77407
|
+
link.mediaOverlayNode = MediaOverlayNode.deserialize(moJson);
|
|
77400
77408
|
link.mediaOverlayNode.initialized = true;
|
|
77401
77409
|
const href = link.hrefDecoded || link.href;
|
|
77402
77410
|
const hrefUrlObj = new URL("https://dita.digital/" + href);
|
|
@@ -77475,10 +77483,7 @@ var MediaOverlayModule = class {
|
|
|
77475
77483
|
if (response.ok) {
|
|
77476
77484
|
const moJson = await response.json();
|
|
77477
77485
|
if (moJson) {
|
|
77478
|
-
link.mediaOverlayNode =
|
|
77479
|
-
moJson,
|
|
77480
|
-
MediaOverlayNode
|
|
77481
|
-
);
|
|
77486
|
+
link.mediaOverlayNode = MediaOverlayNode.deserialize(moJson);
|
|
77482
77487
|
link.mediaOverlayNode.initialized = true;
|
|
77483
77488
|
}
|
|
77484
77489
|
}
|
|
@@ -87512,41 +87517,18 @@ init_HTMLUtilities();
|
|
|
87512
87517
|
|
|
87513
87518
|
// src/model/Link.ts
|
|
87514
87519
|
init_polyfills();
|
|
87515
|
-
function
|
|
87520
|
+
function toPlainObject(o) {
|
|
87516
87521
|
if (o == null) return o;
|
|
87517
|
-
if (o
|
|
87518
|
-
|
|
87519
|
-
|
|
87520
|
-
|
|
87521
|
-
|
|
87522
|
-
|
|
87523
|
-
|
|
87524
|
-
|
|
87525
|
-
}
|
|
87526
|
-
return value2;
|
|
87527
|
-
});
|
|
87528
|
-
} else {
|
|
87529
|
-
newO = {};
|
|
87530
|
-
for (origKey in o) {
|
|
87531
|
-
if (o.hasOwnProperty(origKey)) {
|
|
87532
|
-
newKey = (origKey.charAt(0).toLowerCase() + origKey.slice(1) || origKey).toString();
|
|
87533
|
-
value = o[origKey];
|
|
87534
|
-
if (value && value.items && Array.isArray(value.items)) {
|
|
87535
|
-
value = convertAndCamel(value.items);
|
|
87536
|
-
} else if (value instanceof Array || value !== null && value !== void 0 && value.constructor === Object) {
|
|
87537
|
-
value = convertAndCamel(value);
|
|
87538
|
-
}
|
|
87539
|
-
if (newKey === "href1") {
|
|
87540
|
-
newO["href"] = value;
|
|
87541
|
-
} else if (newKey === "typeLink") {
|
|
87542
|
-
newO["type"] = value;
|
|
87543
|
-
} else {
|
|
87544
|
-
newO[newKey] = value;
|
|
87545
|
-
}
|
|
87546
|
-
}
|
|
87547
|
-
}
|
|
87522
|
+
if (o instanceof Set) return Array.from(o);
|
|
87523
|
+
if (o.items && Array.isArray(o.items)) return o.items.map(toPlainObject);
|
|
87524
|
+
if (Array.isArray(o)) return o.map(toPlainObject);
|
|
87525
|
+
if (typeof o !== "object") return o;
|
|
87526
|
+
const result = {};
|
|
87527
|
+
for (const key in o) {
|
|
87528
|
+
if (!o.hasOwnProperty(key)) continue;
|
|
87529
|
+
result[key] = toPlainObject(o[key]);
|
|
87548
87530
|
}
|
|
87549
|
-
return
|
|
87531
|
+
return result;
|
|
87550
87532
|
}
|
|
87551
87533
|
|
|
87552
87534
|
// src/modules/highlight/LayerSettings.ts
|
|
@@ -88022,27 +88004,10 @@ var D2Reader = class _D2Reader {
|
|
|
88022
88004
|
if (pubInput instanceof Publication) {
|
|
88023
88005
|
publication = pubInput;
|
|
88024
88006
|
} else {
|
|
88025
|
-
|
|
88026
|
-
metadata: pubInput.metadata ?? pubInput.Metadata ?? { title: "" },
|
|
88027
|
-
links: pubInput.links ?? pubInput.Links ?? [],
|
|
88028
|
-
readingOrder: pubInput.readingOrder ?? pubInput.spine ?? pubInput.Spine ?? [],
|
|
88029
|
-
resources: pubInput.resources ?? pubInput.Resources,
|
|
88030
|
-
toc: pubInput.toc ?? pubInput.TOC
|
|
88031
|
-
};
|
|
88032
|
-
if (!json.metadata.title && !json.metadata.Title) {
|
|
88033
|
-
json.metadata.title = "";
|
|
88034
|
-
}
|
|
88035
|
-
if (json.metadata.Title && !json.metadata.title) {
|
|
88036
|
-
json.metadata.title = json.metadata.Title;
|
|
88037
|
-
}
|
|
88038
|
-
const manifest = Ue.deserialize(json);
|
|
88039
|
-
if (!manifest) {
|
|
88040
|
-
throw new Error("Failed to parse publication manifest from config");
|
|
88041
|
-
}
|
|
88042
|
-
manifest.setSelfLink(webPubManifestUrl.href);
|
|
88043
|
-
publication = new Publication(manifest, new URL(webPubManifestUrl));
|
|
88007
|
+
publication = Publication.fromJSON(pubInput, webPubManifestUrl);
|
|
88044
88008
|
}
|
|
88045
|
-
}
|
|
88009
|
+
}
|
|
88010
|
+
if (!publication) {
|
|
88046
88011
|
publication = await Publication.fromUrl(
|
|
88047
88012
|
webPubManifestUrl,
|
|
88048
88013
|
initialConfig.requestConfig
|
|
@@ -88266,19 +88231,19 @@ var D2Reader = class _D2Reader {
|
|
|
88266
88231
|
}
|
|
88267
88232
|
/** Table of Contents */
|
|
88268
88233
|
get tableOfContents() {
|
|
88269
|
-
return
|
|
88234
|
+
return toPlainObject(this.navigator.tableOfContents()) ?? [];
|
|
88270
88235
|
}
|
|
88271
88236
|
/** Landmarks */
|
|
88272
88237
|
get landmarks() {
|
|
88273
|
-
return
|
|
88238
|
+
return toPlainObject(this.navigator.landmarks()) ?? [];
|
|
88274
88239
|
}
|
|
88275
88240
|
/** Page List */
|
|
88276
88241
|
get pageList() {
|
|
88277
|
-
return
|
|
88242
|
+
return toPlainObject(this.navigator.pageList()) ?? [];
|
|
88278
88243
|
}
|
|
88279
88244
|
/** Reading Order or Spine */
|
|
88280
88245
|
get readingOrder() {
|
|
88281
|
-
return
|
|
88246
|
+
return toPlainObject(this.navigator.readingOrder()) ?? [];
|
|
88282
88247
|
}
|
|
88283
88248
|
/** Current Bookmarks */
|
|
88284
88249
|
get bookmarks() {
|