@storyteller-platform/epub 0.4.9 → 0.4.10

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/README.md CHANGED
@@ -220,7 +220,7 @@ To get started with developing in the Storyteller monorepo, check out the
220
220
  ## Epub
221
221
 
222
222
  Defined in:
223
- [epub/index.ts:167](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L167)
223
+ [epub/index.ts:206](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L206)
224
224
 
225
225
  A single EPUB instance.
226
226
 
@@ -262,7 +262,7 @@ https://www.w3.org/TR/epub-33/
262
262
  > `protected` **new Epub**(`extractPath`, `inputPath`): [`Epub`](#epub)
263
263
 
264
264
  Defined in:
265
- [epub/index.ts:391](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L391)
265
+ [epub/index.ts:430](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L430)
266
266
 
267
267
  ##### Parameters
268
268
 
@@ -282,42 +282,42 @@ Defined in:
282
282
  > `protected` **extractPath**: `string`
283
283
 
284
284
  Defined in:
285
- [epub/index.ts:392](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L392)
285
+ [epub/index.ts:431](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L431)
286
286
 
287
287
  #### inputPath
288
288
 
289
289
  > `protected` **inputPath**: `undefined` \| `string`
290
290
 
291
291
  Defined in:
292
- [epub/index.ts:393](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L393)
292
+ [epub/index.ts:432](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L432)
293
293
 
294
294
  #### xhtmlBuilder
295
295
 
296
296
  > `static` **xhtmlBuilder**: `XMLBuilder`
297
297
 
298
298
  Defined in:
299
- [epub/index.ts:215](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L215)
299
+ [epub/index.ts:254](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L254)
300
300
 
301
301
  #### xhtmlParser
302
302
 
303
303
  > `static` **xhtmlParser**: `XMLParser`
304
304
 
305
305
  Defined in:
306
- [epub/index.ts:175](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L175)
306
+ [epub/index.ts:214](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L214)
307
307
 
308
308
  #### xmlBuilder
309
309
 
310
310
  > `static` **xmlBuilder**: `XMLBuilder`
311
311
 
312
312
  Defined in:
313
- [epub/index.ts:208](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L208)
313
+ [epub/index.ts:247](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L247)
314
314
 
315
315
  #### xmlParser
316
316
 
317
317
  > `static` **xmlParser**: `XMLParser`
318
318
 
319
319
  Defined in:
320
- [epub/index.ts:168](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L168)
320
+ [epub/index.ts:207](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L207)
321
321
 
322
322
  ### Methods
323
323
 
@@ -326,7 +326,7 @@ Defined in:
326
326
  > **\[dispose\]**(): `void`
327
327
 
328
328
  Defined in:
329
- [epub/index.ts:2557](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2557)
329
+ [epub/index.ts:2597](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2597)
330
330
 
331
331
  ##### Returns
332
332
 
@@ -337,7 +337,7 @@ Defined in:
337
337
  > **addCollection**(`collection`, `index?`): `Promise`\<`void`\>
338
338
 
339
339
  Defined in:
340
- [epub/index.ts:1548](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1548)
340
+ [epub/index.ts:1586](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1586)
341
341
 
342
342
  Add a collection to the EPUB metadata.
343
343
 
@@ -360,7 +360,7 @@ collections. Otherwise, it will be added to the end of the list.
360
360
  > **addContributor**(`contributor`, `index?`): `Promise`\<`void`\>
361
361
 
362
362
  Defined in:
363
- [epub/index.ts:1890](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1890)
363
+ [epub/index.ts:1928](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1928)
364
364
 
365
365
  Add a contributor to the EPUB metadata.
366
366
 
@@ -390,7 +390,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
390
390
  > **addCreator**(`creator`, `index?`, `type?`): `Promise`\<`void`\>
391
391
 
392
392
  Defined in:
393
- [epub/index.ts:1735](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1735)
393
+ [epub/index.ts:1773](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1773)
394
394
 
395
395
  Add a creator to the EPUB metadata.
396
396
 
@@ -420,7 +420,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
420
420
  > **addManifestItem**(`item`, `contents`, `encoding`): `Promise`\<`void`\>
421
421
 
422
422
  Defined in:
423
- [epub/index.ts:2253](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2253)
423
+ [epub/index.ts:2291](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2291)
424
424
 
425
425
  Create a new manifest item and write its contents to a new entry.
426
426
 
@@ -449,7 +449,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
449
449
  > **addManifestItem**(`item`, `contents`, `encoding`): `Promise`\<`void`\>
450
450
 
451
451
  Defined in:
452
- [epub/index.ts:2258](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2258)
452
+ [epub/index.ts:2296](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2296)
453
453
 
454
454
  Create a new manifest item and write its contents to a new entry.
455
455
 
@@ -478,7 +478,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
478
478
  > **addManifestItem**(`item`, `contents`): `Promise`\<`void`\>
479
479
 
480
480
  Defined in:
481
- [epub/index.ts:2263](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2263)
481
+ [epub/index.ts:2301](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2301)
482
482
 
483
483
  Create a new manifest item and write its contents to a new entry.
484
484
 
@@ -506,7 +506,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
506
506
  > **addMetadata**(`entry`): `Promise`\<`void`\>
507
507
 
508
508
  Defined in:
509
- [epub/index.ts:2375](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2375)
509
+ [epub/index.ts:2413](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2413)
510
510
 
511
511
  Add a new metadata entry to the Epub.
512
512
 
@@ -533,7 +533,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-metadata
533
533
  > **addSpineItem**(`manifestId`, `index?`): `Promise`\<`void`\>
534
534
 
535
535
  Defined in:
536
- [epub/index.ts:1944](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1944)
536
+ [epub/index.ts:1982](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1982)
537
537
 
538
538
  Add an item to the spine of the EPUB.
539
539
 
@@ -563,7 +563,7 @@ https://www.w3.org/TR/epub-33/#sec-spine-elem
563
563
  > **addSubject**(`subject`): `Promise`\<`void`\>
564
564
 
565
565
  Defined in:
566
- [epub/index.ts:1077](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1077)
566
+ [epub/index.ts:1115](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1115)
567
567
 
568
568
  Add a subject to the EPUB metadata.
569
569
 
@@ -586,7 +586,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcsubject
586
586
  > **copy**(`path?`): `Promise`\<[`Epub`](#epub)\>
587
587
 
588
588
  Defined in:
589
- [epub/index.ts:535](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L535)
589
+ [epub/index.ts:593](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L593)
590
590
 
591
591
  ##### Parameters
592
592
 
@@ -605,7 +605,7 @@ Defined in:
605
605
  > [`XmlElement`](#xmlelement)\<`"?xml"`\>)[]\>
606
606
 
607
607
  Defined in:
608
- [epub/index.ts:2079](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2079)
608
+ [epub/index.ts:2117](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2117)
609
609
 
610
610
  Create a new XHTML document with the given body and head.
611
611
 
@@ -627,7 +627,7 @@ Create a new XHTML document with the given body and head.
627
627
  > **discardAndClose**(): `void`
628
628
 
629
629
  Defined in:
630
- [epub/index.ts:2484](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2484)
630
+ [epub/index.ts:2522](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2522)
631
631
 
632
632
  ##### Returns
633
633
 
@@ -638,7 +638,7 @@ Defined in:
638
638
  > **findAllMetadataItems**(`predicate`): `Promise`\<`object`[]\>
639
639
 
640
640
  Defined in:
641
- [epub/index.ts:800](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L800)
641
+ [epub/index.ts:838](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L838)
642
642
 
643
643
  Returns the item in the metadata element's children array that matches the
644
644
  provided predicate.
@@ -678,7 +678,7 @@ provided predicate.
678
678
  > \}\>
679
679
 
680
680
  Defined in:
681
- [epub/index.ts:791](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L791)
681
+ [epub/index.ts:829](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L829)
682
682
 
683
683
  Returns the item in the metadata element's children array that matches the
684
684
  provided predicate.
@@ -717,7 +717,7 @@ provided predicate.
717
717
  > **getCollections**(): `Promise`\<[`Collection`](#collection)[]\>
718
718
 
719
719
  Defined in:
720
- [epub/index.ts:1508](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1508)
720
+ [epub/index.ts:1546](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1546)
721
721
 
722
722
  Retrieve the list of collections.
723
723
 
@@ -730,7 +730,7 @@ Retrieve the list of collections.
730
730
  > **getContributors**(): `Promise`\<[`DcCreator`](#dccreator)[]\>
731
731
 
732
732
  Defined in:
733
- [epub/index.ts:1722](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1722)
733
+ [epub/index.ts:1760](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1760)
734
734
 
735
735
  Retrieve the list of contributors.
736
736
 
@@ -749,7 +749,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccontributor
749
749
  > **getCoverImage**(): `Promise`\<`null` \| `Uint8Array`\<`ArrayBufferLike`\>\>
750
750
 
751
751
  Defined in:
752
- [epub/index.ts:980](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L980)
752
+ [epub/index.ts:1018](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1018)
753
753
 
754
754
  Retrieve the cover image data as a byte array.
755
755
 
@@ -770,7 +770,7 @@ https://www.w3.org/TR/epub-33/#sec-cover-image
770
770
  > [`ManifestItem`](#manifestitem)\>
771
771
 
772
772
  Defined in:
773
- [epub/index.ts:961](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L961)
773
+ [epub/index.ts:999](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L999)
774
774
 
775
775
  Retrieve the cover image manifest item.
776
776
 
@@ -790,7 +790,7 @@ https://www.w3.org/TR/epub-33/#sec-cover-image
790
790
  > **getCreators**(`type`): `Promise`\<[`DcCreator`](#dccreator)[]\>
791
791
 
792
792
  Defined in:
793
- [epub/index.ts:1661](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1661)
793
+ [epub/index.ts:1699](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1699)
794
794
 
795
795
  Retrieve the list of creators.
796
796
 
@@ -813,7 +813,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
813
813
  > **getDescription**(): `Promise`\<`null` \| `string`\>
814
814
 
815
815
  Defined in:
816
- [epub/index.ts:1359](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1359)
816
+ [epub/index.ts:1397](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1397)
817
817
 
818
818
  Retrieve the Epub's description as specified in its package document metadata.
819
819
 
@@ -829,7 +829,7 @@ as a string. Descriptions may include HTML markup.
829
829
  > **getIdentifier**(): `Promise`\<`null` \| `string`\>
830
830
 
831
831
  Defined in:
832
- [epub/index.ts:895](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L895)
832
+ [epub/index.ts:933](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L933)
833
833
 
834
834
  Retrieve the identifier from the dc:identifier element in the EPUB metadata.
835
835
 
@@ -848,7 +848,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
848
848
  > **getLanguage**(): `Promise`\<`null` \| `Locale`\>
849
849
 
850
850
  Defined in:
851
- [epub/index.ts:1196](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1196)
851
+ [epub/index.ts:1234](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1234)
852
852
 
853
853
  Retrieve the Epub's language as specified in its package document metadata.
854
854
 
@@ -869,7 +869,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dclanguage
869
869
  > [`ManifestItem`](#manifestitem)\>\>
870
870
 
871
871
  Defined in:
872
- [epub/index.ts:716](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L716)
872
+ [epub/index.ts:754](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L754)
873
873
 
874
874
  Retrieve the manifest for the Epub.
875
875
 
@@ -889,7 +889,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-manifest
889
889
  > **getMetadata**(): `Promise`\<[`EpubMetadata`](#epubmetadata)\>
890
890
 
891
891
  Defined in:
892
- [epub/index.ts:867](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L867)
892
+ [epub/index.ts:905](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L905)
893
893
 
894
894
  Retrieve the metadata entries for the Epub.
895
895
 
@@ -913,7 +913,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-metadata
913
913
  > `string`\>\>
914
914
 
915
915
  Defined in:
916
- [epub/index.ts:1376](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1376)
916
+ [epub/index.ts:1414](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1414)
917
917
 
918
918
  Return the set of custom vocabulary prefixes set on this publication's root
919
919
  package element.
@@ -933,7 +933,7 @@ https://www.w3.org/TR/epub-33/#sec-prefix-attr
933
933
  > **getPublicationDate**(): `Promise`\<`null` \| `Date`\>
934
934
 
935
935
  Defined in:
936
- [epub/index.ts:1017](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1017)
936
+ [epub/index.ts:1055](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1055)
937
937
 
938
938
  Retrieve the publication date from the dc:date element in the EPUB metadata as a
939
939
  Date object.
@@ -953,7 +953,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcdate
953
953
  > **getRootfile**(): `Promise`\<`string`\>
954
954
 
955
955
  Defined in:
956
- [epub/index.ts:568](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L568)
956
+ [epub/index.ts:626](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L626)
957
957
 
958
958
  ##### Returns
959
959
 
@@ -964,7 +964,7 @@ Defined in:
964
964
  > **getSpineItems**(): `Promise`\<[`ManifestItem`](#manifestitem)[]\>
965
965
 
966
966
  Defined in:
967
- [epub/index.ts:1925](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1925)
967
+ [epub/index.ts:1963](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1963)
968
968
 
969
969
  Retrieve the manifest items that make up the Epub's spine.
970
970
 
@@ -984,7 +984,7 @@ https://www.w3.org/TR/epub-33/#sec-spine-elem
984
984
  > **getSubjects**(): `Promise`\<(`string` \| [`DcSubject`](#dcsubject))[]\>
985
985
 
986
986
  Defined in:
987
- [epub/index.ts:1151](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1151)
987
+ [epub/index.ts:1189](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1189)
988
988
 
989
989
  Retrieve the list of subjects for this EPUB.
990
990
 
@@ -1005,7 +1005,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcsubject
1005
1005
  > **getSubtitle**(): `Promise`\<`null` \| `string`\>
1006
1006
 
1007
1007
  Defined in:
1008
- [epub/index.ts:1266](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1266)
1008
+ [epub/index.ts:1304](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1304)
1009
1009
 
1010
1010
  Retrieve the subtitle of the Epub, if it exists.
1011
1011
 
@@ -1022,7 +1022,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctitle
1022
1022
  > **getTitle**(`expanded`): `Promise`\<`null` \| `string`\>
1023
1023
 
1024
1024
  Defined in:
1025
- [epub/index.ts:1242](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1242)
1025
+ [epub/index.ts:1280](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1280)
1026
1026
 
1027
1027
  Retrieve the title of the Epub.
1028
1028
 
@@ -1045,7 +1045,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctitle
1045
1045
  > **getTitles**(): `Promise`\<`object`[]\>
1046
1046
 
1047
1047
  Defined in:
1048
- [epub/index.ts:1278](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1278)
1048
+ [epub/index.ts:1316](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1316)
1049
1049
 
1050
1050
  Retrieve all title entries of the Epub.
1051
1051
 
@@ -1062,7 +1062,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctitle
1062
1062
  > **getType**(): `Promise`\<`null` \| [`MetadataEntry`](#metadataentry)\>
1063
1063
 
1064
1064
  Defined in:
1065
- [epub/index.ts:1064](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1064)
1065
+ [epub/index.ts:1102](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1102)
1066
1066
 
1067
1067
  Retrieve the publication type from the dc:type element in the EPUB metadata.
1068
1068
 
@@ -1084,7 +1084,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctype
1084
1084
  > `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
1085
1085
 
1086
1086
  Defined in:
1087
- [epub/index.ts:2020](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2020)
1087
+ [epub/index.ts:2058](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2058)
1088
1088
 
1089
1089
  Retrieve the contents of a file, given its href.
1090
1090
 
@@ -1107,7 +1107,7 @@ encoding parameter.
1107
1107
  > **readFileContents**(`href`, `relativeTo`, `encoding`): `Promise`\<`string`\>
1108
1108
 
1109
1109
  Defined in:
1110
- [epub/index.ts:2021](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2021)
1110
+ [epub/index.ts:2059](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2059)
1111
1111
 
1112
1112
  Retrieve the contents of a file, given its href.
1113
1113
 
@@ -1133,7 +1133,7 @@ encoding parameter.
1133
1133
  > **readItemContents**(`id`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
1134
1134
 
1135
1135
  Defined in:
1136
- [epub/index.ts:2051](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2051)
1136
+ [epub/index.ts:2089](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2089)
1137
1137
 
1138
1138
  Retrieve the contents of a manifest item, given its id.
1139
1139
 
@@ -1156,7 +1156,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
1156
1156
  > **readItemContents**(`id`, `encoding`): `Promise`\<`string`\>
1157
1157
 
1158
1158
  Defined in:
1159
- [epub/index.ts:2052](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2052)
1159
+ [epub/index.ts:2090](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2090)
1160
1160
 
1161
1161
  Retrieve the contents of a manifest item, given its id.
1162
1162
 
@@ -1182,7 +1182,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
1182
1182
  > **readXhtmlItemContents**(`id`, `as?`): `Promise`\<[`ParsedXml`](#parsedxml)\>
1183
1183
 
1184
1184
  Defined in:
1185
- [epub/index.ts:2114](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2114)
1185
+ [epub/index.ts:2152](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2152)
1186
1186
 
1187
1187
  Retrieves the contents of an XHTML item, given its manifest id.
1188
1188
 
@@ -1206,7 +1206,7 @@ https://www.w3.org/TR/epub-33/#sec-xhtml
1206
1206
  > **readXhtmlItemContents**(`id`, `as`): `Promise`\<`string`\>
1207
1207
 
1208
1208
  Defined in:
1209
- [epub/index.ts:2115](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2115)
1209
+ [epub/index.ts:2153](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2153)
1210
1210
 
1211
1211
  Retrieves the contents of an XHTML item, given its manifest id.
1212
1212
 
@@ -1230,7 +1230,7 @@ https://www.w3.org/TR/epub-33/#sec-xhtml
1230
1230
  > **removeCollection**(`index`): `Promise`\<`void`\>
1231
1231
 
1232
1232
  Defined in:
1233
- [epub/index.ts:1617](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1617)
1233
+ [epub/index.ts:1655](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1655)
1234
1234
 
1235
1235
  Remove a collection from the EPUB metadata.
1236
1236
 
@@ -1252,7 +1252,7 @@ returned by `epub.getCollections()`.
1252
1252
  > **removeContributor**(`index`): `Promise`\<`void`\>
1253
1253
 
1254
1254
  Defined in:
1255
- [epub/index.ts:1874](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1874)
1255
+ [epub/index.ts:1912](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1912)
1256
1256
 
1257
1257
  Remove a contributor from the EPUB metadata.
1258
1258
 
@@ -1280,7 +1280,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
1280
1280
  > **removeCreator**(`index`, `type`): `Promise`\<`void`\>
1281
1281
 
1282
1282
  Defined in:
1283
- [epub/index.ts:1822](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1822)
1283
+ [epub/index.ts:1860](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1860)
1284
1284
 
1285
1285
  Remove a creator from the EPUB metadata.
1286
1286
 
@@ -1307,7 +1307,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
1307
1307
  > **removeManifestItem**(`id`): `Promise`\<`void`\>
1308
1308
 
1309
1309
  Defined in:
1310
- [epub/index.ts:2210](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2210)
1310
+ [epub/index.ts:2248](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2248)
1311
1311
 
1312
1312
  ##### Parameters
1313
1313
 
@@ -1324,7 +1324,7 @@ Defined in:
1324
1324
  > **removeMetadata**(`predicate`): `Promise`\<`void`\>
1325
1325
 
1326
1326
  Defined in:
1327
- [epub/index.ts:2459](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2459)
1327
+ [epub/index.ts:2497](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2497)
1328
1328
 
1329
1329
  Remove one or more metadata entries.
1330
1330
 
@@ -1350,7 +1350,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-metadata
1350
1350
  > **removeSpineItem**(`index`): `Promise`\<`void`\>
1351
1351
 
1352
1352
  Defined in:
1353
- [epub/index.ts:1980](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1980)
1353
+ [epub/index.ts:2018](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2018)
1354
1354
 
1355
1355
  Remove the spine item at the specified index.
1356
1356
 
@@ -1373,7 +1373,7 @@ https://www.w3.org/TR/epub-33/#sec-spine-elem
1373
1373
  > **removeSubject**(`index`): `Promise`\<`void`\>
1374
1374
 
1375
1375
  Defined in:
1376
- [epub/index.ts:1114](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1114)
1376
+ [epub/index.ts:1152](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1152)
1377
1377
 
1378
1378
  Remove a subject from the EPUB metadata.
1379
1379
 
@@ -1399,7 +1399,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
1399
1399
  > **replaceMetadata**(`predicate`, `entry`): `Promise`\<`void`\>
1400
1400
 
1401
1401
  Defined in:
1402
- [epub/index.ts:2414](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2414)
1402
+ [epub/index.ts:2452](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2452)
1403
1403
 
1404
1404
  Replace a metadata entry with a new one.
1405
1405
 
@@ -1426,7 +1426,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-metadata
1426
1426
  > **saveAndClose**(): `Promise`\<`void`\>
1427
1427
 
1428
1428
  Defined in:
1429
- [epub/index.ts:2500](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2500)
1429
+ [epub/index.ts:2538](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2538)
1430
1430
 
1431
1431
  Write the current contents of the Epub to a new EPUB archive on disk.
1432
1432
 
@@ -1442,7 +1442,7 @@ updated to the current UTC timestamp.
1442
1442
  > **setCoverImage**(`href`, `data`): `Promise`\<`void`\>
1443
1443
 
1444
1444
  Defined in:
1445
- [epub/index.ts:994](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L994)
1445
+ [epub/index.ts:1032](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1032)
1446
1446
 
1447
1447
  Set the cover image for the EPUB.
1448
1448
 
@@ -1465,7 +1465,7 @@ then writes the provided image data to the provided href within the publication.
1465
1465
  > **setDescription**(`description`): `Promise`\<`void`\>
1466
1466
 
1467
1467
  Defined in:
1468
- [epub/index.ts:1343](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1343)
1468
+ [epub/index.ts:1381](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1381)
1469
1469
 
1470
1470
  Update the Epub's description metadata entry.
1471
1471
 
@@ -1488,7 +1488,7 @@ encoded as HTML entities.
1488
1488
  > **setIdentifier**(`identifier`): `Promise`\<`void`\>
1489
1489
 
1490
1490
  Defined in:
1491
- [epub/index.ts:909](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L909)
1491
+ [epub/index.ts:947](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L947)
1492
1492
 
1493
1493
  Set the dc:identifier metadata element with the provided string.
1494
1494
 
@@ -1514,7 +1514,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
1514
1514
  > **setLanguage**(`locale`): `Promise`\<`void`\>
1515
1515
 
1516
1516
  Defined in:
1517
- [epub/index.ts:1225](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1225)
1517
+ [epub/index.ts:1263](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1263)
1518
1518
 
1519
1519
  Update the Epub's language metadata entry.
1520
1520
 
@@ -1540,7 +1540,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dclanguage
1540
1540
  > **setPackageVocabularyPrefix**(`prefix`, `uri`): `Promise`\<`void`\>
1541
1541
 
1542
1542
  Defined in:
1543
- [epub/index.ts:1394](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1394)
1543
+ [epub/index.ts:1432](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1432)
1544
1544
 
1545
1545
  Set a custom vocabulary prefix on the root package element.
1546
1546
 
@@ -1564,7 +1564,7 @@ https://www.w3.org/TR/epub-33/#sec-prefix-attr
1564
1564
  > **setPublicationDate**(`date`): `Promise`\<`void`\>
1565
1565
 
1566
1566
  Defined in:
1567
- [epub/index.ts:1032](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1032)
1567
+ [epub/index.ts:1070](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1070)
1568
1568
 
1569
1569
  Set the dc:date metadata element with the provided date.
1570
1570
 
@@ -1590,7 +1590,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcdate
1590
1590
  > **setTitle**(`title`): `Promise`\<`void`\>
1591
1591
 
1592
1592
  Defined in:
1593
- [epub/index.ts:1418](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1418)
1593
+ [epub/index.ts:1456](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1456)
1594
1594
 
1595
1595
  Set the title of the Epub.
1596
1596
 
@@ -1618,7 +1618,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctitle
1618
1618
  > **setTitles**(`entries`): `Promise`\<`void`\>
1619
1619
 
1620
1620
  Defined in:
1621
- [epub/index.ts:1446](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1446)
1621
+ [epub/index.ts:1484](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1484)
1622
1622
 
1623
1623
  ##### Parameters
1624
1624
 
@@ -1635,7 +1635,7 @@ Defined in:
1635
1635
  > **setType**(`type`): `Promise`\<`void`\>
1636
1636
 
1637
1637
  Defined in:
1638
- [epub/index.ts:1048](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1048)
1638
+ [epub/index.ts:1086](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1086)
1639
1639
 
1640
1640
  Set the dc:type metadata element.
1641
1641
 
@@ -1661,7 +1661,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctype
1661
1661
  > **updateManifestItem**(`id`, `newItem`): `Promise`\<`void`\>
1662
1662
 
1663
1663
  Defined in:
1664
- [epub/index.ts:2326](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2326)
1664
+ [epub/index.ts:2364](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2364)
1665
1665
 
1666
1666
  Update the manifest entry for an existing item.
1667
1667
 
@@ -1690,7 +1690,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-manifest
1690
1690
  > **writeItemContents**(`id`, `contents`): `Promise`\<`void`\>
1691
1691
 
1692
1692
  Defined in:
1693
- [epub/index.ts:2162](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2162)
1693
+ [epub/index.ts:2200](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2200)
1694
1694
 
1695
1695
  Write new contents for an existing manifest item, specified by its id.
1696
1696
 
@@ -1717,7 +1717,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
1717
1717
  > **writeItemContents**(`id`, `contents`, `encoding`): `Promise`\<`void`\>
1718
1718
 
1719
1719
  Defined in:
1720
- [epub/index.ts:2163](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2163)
1720
+ [epub/index.ts:2201](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2201)
1721
1721
 
1722
1722
  Write new contents for an existing manifest item, specified by its id.
1723
1723
 
@@ -1745,7 +1745,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
1745
1745
  > **writeXhtmlItemContents**(`id`, `contents`): `Promise`\<`void`\>
1746
1746
 
1747
1747
  Defined in:
1748
- [epub/index.ts:2202](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2202)
1748
+ [epub/index.ts:2240](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2240)
1749
1749
 
1750
1750
  Write new contents for an existing XHTML item, specified by its id.
1751
1751
 
@@ -1772,7 +1772,7 @@ https://www.w3.org/TR/epub-33/#sec-xhtml
1772
1772
  > `static` **addLinkToXhtmlHead**(`xml`, `link`): `void`
1773
1773
 
1774
1774
  Defined in:
1775
- [epub/index.ts:245](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L245)
1775
+ [epub/index.ts:284](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L284)
1776
1776
 
1777
1777
  Given an XML structure representing a complete XHTML document, add a `link`
1778
1778
  element to the `head` of the document.
@@ -1799,7 +1799,7 @@ This method modifies the provided XML structure.
1799
1799
  > `Promise`\<[`Epub`](#epub)\>
1800
1800
 
1801
1801
  Defined in:
1802
- [epub/index.ts:411](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L411)
1802
+ [epub/index.ts:450](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L450)
1803
1803
 
1804
1804
  Construct an Epub instance, optionally beginning with the provided metadata.
1805
1805
 
@@ -1821,7 +1821,7 @@ Construct an Epub instance, optionally beginning with the provided metadata.
1821
1821
  > [`XmlElement`](#xmlelement)\<`Name`\>
1822
1822
 
1823
1823
  Defined in:
1824
- [epub/index.ts:280](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L280)
1824
+ [epub/index.ts:319](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L319)
1825
1825
 
1826
1826
  ##### Type Parameters
1827
1827
 
@@ -1846,7 +1846,7 @@ Defined in:
1846
1846
  > `static` **createXmlTextNode**(`text`): [`XmlTextNode`](#xmltextnode)
1847
1847
 
1848
1848
  Defined in:
1849
- [epub/index.ts:293](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L293)
1849
+ [epub/index.ts:332](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L332)
1850
1850
 
1851
1851
  ##### Parameters
1852
1852
 
@@ -1864,7 +1864,7 @@ Defined in:
1864
1864
  > `undefined` \| [`XmlElement`](#xmlelement)\<`Name`\>
1865
1865
 
1866
1866
  Defined in:
1867
- [epub/index.ts:366](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L366)
1867
+ [epub/index.ts:405](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L405)
1868
1868
 
1869
1869
  Given an XML structure, find the first child matching the provided name and
1870
1870
  optional filter.
@@ -1892,7 +1892,7 @@ optional filter.
1892
1892
  > `static` **formatSmilDuration**(`duration`): `string`
1893
1893
 
1894
1894
  Defined in:
1895
- [epub/index.ts:228](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L228)
1895
+ [epub/index.ts:267](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L267)
1896
1896
 
1897
1897
  Format a duration, provided as a number of seconds, as a SMIL clock value, to be
1898
1898
  used for Media Overlays.
@@ -1916,7 +1916,7 @@ https://www.w3.org/TR/epub-33/#sec-duration
1916
1916
  > `static` **from**(`pathOrData`): `Promise`\<[`Epub`](#epub)\>
1917
1917
 
1918
1918
  Defined in:
1919
- [epub/index.ts:495](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L495)
1919
+ [epub/index.ts:534](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L534)
1920
1920
 
1921
1921
  Construct an Epub instance by reading an existing EPUB publication.
1922
1922
 
@@ -1935,7 +1935,7 @@ Construct an Epub instance by reading an existing EPUB publication.
1935
1935
  > `static` **getXhtmlBody**(`xml`): [`ParsedXml`](#parsedxml)
1936
1936
 
1937
1937
  Defined in:
1938
- [epub/index.ts:270](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L270)
1938
+ [epub/index.ts:309](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L309)
1939
1939
 
1940
1940
  Given an XML structure representing a complete XHTML document, return the
1941
1941
  sub-structure representing the children of the document's body element.
@@ -1955,7 +1955,7 @@ sub-structure representing the children of the document's body element.
1955
1955
  > `static` **getXhtmlTextContent**(`xml`): `string`
1956
1956
 
1957
1957
  Defined in:
1958
- [epub/index.ts:302](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L302)
1958
+ [epub/index.ts:341](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L341)
1959
1959
 
1960
1960
  Given an XML structure representing a complete XHTML document, return a string
1961
1961
  representing the concatenation of all text nodes in the document.
@@ -1975,7 +1975,7 @@ representing the concatenation of all text nodes in the document.
1975
1975
  > `static` **getXmlAttributes**(`element`): `Record`\<`string`, `string`\>
1976
1976
 
1977
1977
  Defined in:
1978
- [epub/index.ts:319](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L319)
1978
+ [epub/index.ts:358](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L358)
1979
1979
 
1980
1980
  Given an XMLElement, return its attributes.
1981
1981
 
@@ -1994,7 +1994,7 @@ Given an XMLElement, return its attributes.
1994
1994
  > `static` **getXmlChildren**\<`Name`\>(`element`): [`ParsedXml`](#parsedxml)
1995
1995
 
1996
1996
  Defined in:
1997
- [epub/index.ts:346](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L346)
1997
+ [epub/index.ts:385](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L385)
1998
1998
 
1999
1999
  Given an XMLElement, return a list of its children
2000
2000
 
@@ -2019,7 +2019,7 @@ Given an XMLElement, return a list of its children
2019
2019
  > `static` **getXmlElementName**\<`Name`\>(`element`): `Name`
2020
2020
 
2021
2021
  Defined in:
2022
- [epub/index.ts:331](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L331)
2022
+ [epub/index.ts:370](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L370)
2023
2023
 
2024
2024
  Given an XMLElement, return its tag name.
2025
2025
 
@@ -2044,7 +2044,7 @@ Given an XMLElement, return its tag name.
2044
2044
  > `static` **isXmlTextNode**(`node`): `node is XmlTextNode`
2045
2045
 
2046
2046
  Defined in:
2047
- [epub/index.ts:379](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L379)
2047
+ [epub/index.ts:418](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L418)
2048
2048
 
2049
2049
  Given an XMLNode, determine whether it represents a text node or an XML element.
2050
2050
 
@@ -2063,7 +2063,7 @@ Given an XMLNode, determine whether it represents a text node or an XML element.
2063
2063
  > `static` **replaceXmlChildren**\<`Name`\>(`element`, `children`): `void`
2064
2064
 
2065
2065
  Defined in:
2066
- [epub/index.ts:354](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L354)
2066
+ [epub/index.ts:393](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L393)
2067
2067
 
2068
2068
  ##### Type Parameters
2069
2069
 
@@ -2391,8 +2391,7 @@ Defined in:
2391
2391
 
2392
2392
  ## PackageElement
2393
2393
 
2394
- > **PackageElement** = [`XmlElement`](#xmlelement)\<`"package"`\> \|
2395
- > [`XmlElement`](#xmlelement)\<`"opf:package"`\>
2394
+ > **PackageElement** = [`XmlElement`](#xmlelement)\<`"package"`\>
2396
2395
 
2397
2396
  Defined in:
2398
2397
  [epub/index.ts:138](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L138)
package/dist/index.cjs CHANGED
@@ -89,6 +89,31 @@ var import_nanoid = require("nanoid");
89
89
  var import_yauzl_promise = require("yauzl-promise");
90
90
  var import_yazl = require("yazl");
91
91
  var import_path = require("@storyteller-platform/path");
92
+ const MP3_FILE_EXTENSIONS = [".mp3"];
93
+ const MPEG4_FILE_EXTENSIONS = [".mp4", ".m4a", ".m4b"];
94
+ const AAC_FILE_EXTENSIONS = [".aac"];
95
+ const OGG_FILE_EXTENSIONS = [".ogg", ".oga", ".mogg"];
96
+ const OPUS_FILE_EXTENSIONS = [".opus"];
97
+ const WAVE_FILE_EXTENSIONS = [".wav"];
98
+ const AIFF_FILE_EXTENSIONS = [".aiff"];
99
+ const FLAC_FILE_EXTENSIONS = [".flac"];
100
+ const ALAC_FILE_EXTENSIONS = [".alac"];
101
+ const WEBM_FILE_EXTENSIONS = [".weba"];
102
+ const AUDIO_FILE_EXTENSIONS = [
103
+ ...MP3_FILE_EXTENSIONS,
104
+ ...AAC_FILE_EXTENSIONS,
105
+ ...MPEG4_FILE_EXTENSIONS,
106
+ ...OPUS_FILE_EXTENSIONS,
107
+ ...OGG_FILE_EXTENSIONS,
108
+ ...WAVE_FILE_EXTENSIONS,
109
+ ...AIFF_FILE_EXTENSIONS,
110
+ ...FLAC_FILE_EXTENSIONS,
111
+ ...ALAC_FILE_EXTENSIONS,
112
+ ...WEBM_FILE_EXTENSIONS
113
+ ];
114
+ function isAudioFile(filenameOrExt) {
115
+ return AUDIO_FILE_EXTENSIONS.some((ext) => filenameOrExt.endsWith(ext));
116
+ }
92
117
  class Epub {
93
118
  constructor(extractPath, inputPath) {
94
119
  this.extractPath = extractPath;
@@ -348,6 +373,7 @@ ${JSON.stringify(element, null, 2)}`
348
373
  */
349
374
  // eslint-disable-next-line @typescript-eslint/require-await
350
375
  static async from(pathOrData) {
376
+ var _a, _b;
351
377
  const extractPath = (0, import_path.join)(
352
378
  (0, import_node_os.tmpdir)(),
353
379
  `storyteller-platform-epub-${(0, import_node_crypto.randomUUID)()}.epub`
@@ -380,10 +406,26 @@ ${JSON.stringify(element, null, 2)}`
380
406
  (0, import_node_fs.rmSync)(extractPath, { force: true, recursive: true });
381
407
  throw error;
382
408
  }
383
- return new this(
409
+ const epub = new this(
384
410
  extractPath,
385
411
  typeof pathOrData === "string" ? pathOrData : void 0
386
412
  );
413
+ try {
414
+ await epub.getPackageElement();
415
+ } catch (e) {
416
+ epub.discardAndClose();
417
+ console.error(e);
418
+ throw new Error(
419
+ "This is not a valid EPUB 3 publication. This library only support EPUB 3, not EPUB 2. Try using an automatic conversion tool to convert this publication to EPUB 3."
420
+ );
421
+ }
422
+ const packageEl = await epub.getPackageElement();
423
+ if (!((_b = (_a = packageEl[":@"]) == null ? void 0 : _a["@_version"]) == null ? void 0 : _b.startsWith("3."))) {
424
+ throw new Error(
425
+ "This is not a valid EPUB 3 publication. This library only support EPUB 3, not EPUB 2. Try using an automatic conversion tool to convert this publication to EPUB 3."
426
+ );
427
+ }
428
+ return epub;
387
429
  }
388
430
  async copy(path) {
389
431
  const extractPath = (0, import_path.join)(
@@ -445,17 +487,6 @@ ${JSON.stringify(element, null, 2)}`
445
487
  this.rootfile = (0, import_path.resolve)(this.extractPath, fullPath);
446
488
  return this.rootfile;
447
489
  }
448
- migratePackageDocument(packageDocument) {
449
- for (const element of packageDocument) {
450
- if (Epub.isXmlTextNode(element)) continue;
451
- const elementName = Epub.getXmlElementName(element);
452
- if (elementName.startsWith("opf:")) {
453
- element[elementName.replace("opf:", "")] = Epub.getXmlChildren(element);
454
- delete element[elementName];
455
- this.migratePackageDocument(Epub.getXmlChildren(element));
456
- }
457
- }
458
- }
459
490
  async getPackageDocument() {
460
491
  const rootfile = await this.getRootfile();
461
492
  const packageDocumentString = await this.getFileData(rootfile, "utf-8");
@@ -470,13 +501,12 @@ ${JSON.stringify(element, null, 2)}`
470
501
  }
471
502
  async getPackageElement() {
472
503
  const packageDocument = await this.getPackageDocument();
473
- const packageElement = Epub.findXmlChildByName("package", packageDocument) ?? Epub.findXmlChildByName("opf:package", packageDocument);
504
+ const packageElement = Epub.findXmlChildByName("package", packageDocument);
474
505
  if (!packageElement) {
475
506
  throw new Error(
476
507
  "Failed to parse EPUB: Found no package element in package document"
477
508
  );
478
509
  }
479
- this.migratePackageDocument(packageDocument);
480
510
  return packageElement;
481
511
  }
482
512
  /**
@@ -494,7 +524,7 @@ ${JSON.stringify(element, null, 2)}`
494
524
  async withPackage(producer) {
495
525
  await this.packageMutex.runExclusive(async () => {
496
526
  const packageDocument = await this.getPackageDocument();
497
- const packageElement = Epub.findXmlChildByName("package", packageDocument) ?? Epub.findXmlChildByName("opf:package", packageDocument);
527
+ const packageElement = Epub.findXmlChildByName("package", packageDocument);
498
528
  if (!packageElement) {
499
529
  throw new Error(
500
530
  "Failed to parse EPUB: Found no package element in package document"
@@ -1923,7 +1953,8 @@ ${JSON.stringify(element, null, 2)}`
1923
1953
  if (entry.name === "mimetype" || entry.isDirectory()) continue;
1924
1954
  zipfile.addFile(
1925
1955
  (0, import_path.join)(entry.parentPath, entry.name),
1926
- (0, import_path.join)(entry.parentPath, entry.name).replace(`${this.extractPath}/`, "")
1956
+ (0, import_path.join)(entry.parentPath, entry.name).replace(`${this.extractPath}/`, ""),
1957
+ { compress: !isAudioFile(entry.name) }
1927
1958
  );
1928
1959
  }
1929
1960
  zipfile.end();
package/dist/index.d.cts CHANGED
@@ -74,7 +74,7 @@ interface Collection {
74
74
  type?: string;
75
75
  position?: string;
76
76
  }
77
- type PackageElement = XmlElement<"package"> | XmlElement<"opf:package">;
77
+ type PackageElement = XmlElement<"package">;
78
78
  /**
79
79
  * A single EPUB instance.
80
80
  *
@@ -190,7 +190,6 @@ declare class Epub {
190
190
  private removeEntry;
191
191
  private getFileData;
192
192
  getRootfile(): Promise<string>;
193
- private migratePackageDocument;
194
193
  private getPackageDocument;
195
194
  private getPackageElement;
196
195
  /**
package/dist/index.d.ts CHANGED
@@ -74,7 +74,7 @@ interface Collection {
74
74
  type?: string;
75
75
  position?: string;
76
76
  }
77
- type PackageElement = XmlElement<"package"> | XmlElement<"opf:package">;
77
+ type PackageElement = XmlElement<"package">;
78
78
  /**
79
79
  * A single EPUB instance.
80
80
  *
@@ -190,7 +190,6 @@ declare class Epub {
190
190
  private removeEntry;
191
191
  private getFileData;
192
192
  getRootfile(): Promise<string>;
193
- private migratePackageDocument;
194
193
  private getPackageDocument;
195
194
  private getPackageElement;
196
195
  /**
package/dist/index.js CHANGED
@@ -56,6 +56,31 @@ import { nanoid } from "nanoid";
56
56
  import { fromBuffer, open } from "yauzl-promise";
57
57
  import { ZipFile } from "yazl";
58
58
  import { dirname, join, resolve } from "@storyteller-platform/path";
59
+ const MP3_FILE_EXTENSIONS = [".mp3"];
60
+ const MPEG4_FILE_EXTENSIONS = [".mp4", ".m4a", ".m4b"];
61
+ const AAC_FILE_EXTENSIONS = [".aac"];
62
+ const OGG_FILE_EXTENSIONS = [".ogg", ".oga", ".mogg"];
63
+ const OPUS_FILE_EXTENSIONS = [".opus"];
64
+ const WAVE_FILE_EXTENSIONS = [".wav"];
65
+ const AIFF_FILE_EXTENSIONS = [".aiff"];
66
+ const FLAC_FILE_EXTENSIONS = [".flac"];
67
+ const ALAC_FILE_EXTENSIONS = [".alac"];
68
+ const WEBM_FILE_EXTENSIONS = [".weba"];
69
+ const AUDIO_FILE_EXTENSIONS = [
70
+ ...MP3_FILE_EXTENSIONS,
71
+ ...AAC_FILE_EXTENSIONS,
72
+ ...MPEG4_FILE_EXTENSIONS,
73
+ ...OPUS_FILE_EXTENSIONS,
74
+ ...OGG_FILE_EXTENSIONS,
75
+ ...WAVE_FILE_EXTENSIONS,
76
+ ...AIFF_FILE_EXTENSIONS,
77
+ ...FLAC_FILE_EXTENSIONS,
78
+ ...ALAC_FILE_EXTENSIONS,
79
+ ...WEBM_FILE_EXTENSIONS
80
+ ];
81
+ function isAudioFile(filenameOrExt) {
82
+ return AUDIO_FILE_EXTENSIONS.some((ext) => filenameOrExt.endsWith(ext));
83
+ }
59
84
  class Epub {
60
85
  constructor(extractPath, inputPath) {
61
86
  this.extractPath = extractPath;
@@ -315,6 +340,7 @@ ${JSON.stringify(element, null, 2)}`
315
340
  */
316
341
  // eslint-disable-next-line @typescript-eslint/require-await
317
342
  static async from(pathOrData) {
343
+ var _a, _b;
318
344
  const extractPath = join(
319
345
  tmpdir(),
320
346
  `storyteller-platform-epub-${randomUUID()}.epub`
@@ -347,10 +373,26 @@ ${JSON.stringify(element, null, 2)}`
347
373
  rmSync(extractPath, { force: true, recursive: true });
348
374
  throw error;
349
375
  }
350
- return new this(
376
+ const epub = new this(
351
377
  extractPath,
352
378
  typeof pathOrData === "string" ? pathOrData : void 0
353
379
  );
380
+ try {
381
+ await epub.getPackageElement();
382
+ } catch (e) {
383
+ epub.discardAndClose();
384
+ console.error(e);
385
+ throw new Error(
386
+ "This is not a valid EPUB 3 publication. This library only support EPUB 3, not EPUB 2. Try using an automatic conversion tool to convert this publication to EPUB 3."
387
+ );
388
+ }
389
+ const packageEl = await epub.getPackageElement();
390
+ if (!((_b = (_a = packageEl[":@"]) == null ? void 0 : _a["@_version"]) == null ? void 0 : _b.startsWith("3."))) {
391
+ throw new Error(
392
+ "This is not a valid EPUB 3 publication. This library only support EPUB 3, not EPUB 2. Try using an automatic conversion tool to convert this publication to EPUB 3."
393
+ );
394
+ }
395
+ return epub;
354
396
  }
355
397
  async copy(path) {
356
398
  const extractPath = join(
@@ -412,17 +454,6 @@ ${JSON.stringify(element, null, 2)}`
412
454
  this.rootfile = resolve(this.extractPath, fullPath);
413
455
  return this.rootfile;
414
456
  }
415
- migratePackageDocument(packageDocument) {
416
- for (const element of packageDocument) {
417
- if (Epub.isXmlTextNode(element)) continue;
418
- const elementName = Epub.getXmlElementName(element);
419
- if (elementName.startsWith("opf:")) {
420
- element[elementName.replace("opf:", "")] = Epub.getXmlChildren(element);
421
- delete element[elementName];
422
- this.migratePackageDocument(Epub.getXmlChildren(element));
423
- }
424
- }
425
- }
426
457
  async getPackageDocument() {
427
458
  const rootfile = await this.getRootfile();
428
459
  const packageDocumentString = await this.getFileData(rootfile, "utf-8");
@@ -437,13 +468,12 @@ ${JSON.stringify(element, null, 2)}`
437
468
  }
438
469
  async getPackageElement() {
439
470
  const packageDocument = await this.getPackageDocument();
440
- const packageElement = Epub.findXmlChildByName("package", packageDocument) ?? Epub.findXmlChildByName("opf:package", packageDocument);
471
+ const packageElement = Epub.findXmlChildByName("package", packageDocument);
441
472
  if (!packageElement) {
442
473
  throw new Error(
443
474
  "Failed to parse EPUB: Found no package element in package document"
444
475
  );
445
476
  }
446
- this.migratePackageDocument(packageDocument);
447
477
  return packageElement;
448
478
  }
449
479
  /**
@@ -461,7 +491,7 @@ ${JSON.stringify(element, null, 2)}`
461
491
  async withPackage(producer) {
462
492
  await this.packageMutex.runExclusive(async () => {
463
493
  const packageDocument = await this.getPackageDocument();
464
- const packageElement = Epub.findXmlChildByName("package", packageDocument) ?? Epub.findXmlChildByName("opf:package", packageDocument);
494
+ const packageElement = Epub.findXmlChildByName("package", packageDocument);
465
495
  if (!packageElement) {
466
496
  throw new Error(
467
497
  "Failed to parse EPUB: Found no package element in package document"
@@ -1890,7 +1920,8 @@ ${JSON.stringify(element, null, 2)}`
1890
1920
  if (entry.name === "mimetype" || entry.isDirectory()) continue;
1891
1921
  zipfile.addFile(
1892
1922
  join(entry.parentPath, entry.name),
1893
- join(entry.parentPath, entry.name).replace(`${this.extractPath}/`, "")
1923
+ join(entry.parentPath, entry.name).replace(`${this.extractPath}/`, ""),
1924
+ { compress: !isAudioFile(entry.name) }
1894
1925
  );
1895
1926
  }
1896
1927
  zipfile.end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyteller-platform/epub",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",