@d-i-t-a/reader 3.0.0-alpha.3 → 3.0.0-alpha.5

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 CHANGED
@@ -88012,13 +88012,30 @@ var D2Reader = class _D2Reader {
88012
88012
  let webPubManifestUrl = initialConfig.url;
88013
88013
  let publication;
88014
88014
  if (initialConfig.publication) {
88015
- const pubJson = initialConfig.publication;
88016
- const manifest = Ue.deserialize(pubJson);
88017
- if (!manifest) {
88018
- throw new Error("Failed to parse publication manifest from config");
88015
+ const pubInput = initialConfig.publication;
88016
+ if (pubInput instanceof Publication) {
88017
+ publication = pubInput;
88018
+ } else {
88019
+ const json = {
88020
+ metadata: pubInput.metadata ?? pubInput.Metadata ?? { title: "" },
88021
+ links: pubInput.links ?? pubInput.Links ?? [],
88022
+ readingOrder: pubInput.readingOrder ?? pubInput.spine ?? pubInput.Spine ?? [],
88023
+ resources: pubInput.resources ?? pubInput.Resources,
88024
+ toc: pubInput.toc ?? pubInput.TOC
88025
+ };
88026
+ if (!json.metadata.title && !json.metadata.Title) {
88027
+ json.metadata.title = "";
88028
+ }
88029
+ if (json.metadata.Title && !json.metadata.title) {
88030
+ json.metadata.title = json.metadata.Title;
88031
+ }
88032
+ const manifest = Ue.deserialize(json);
88033
+ if (!manifest) {
88034
+ throw new Error("Failed to parse publication manifest from config");
88035
+ }
88036
+ manifest.setSelfLink(webPubManifestUrl.href);
88037
+ publication = new Publication(manifest, new URL(webPubManifestUrl));
88019
88038
  }
88020
- manifest.setSelfLink(webPubManifestUrl.href);
88021
- publication = new Publication(manifest, new URL(webPubManifestUrl));
88022
88039
  } else {
88023
88040
  publication = await Publication.fromUrl(
88024
88041
  webPubManifestUrl,