@storyteller-platform/epub 0.4.8 → 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:2541](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2541)
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:1532](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1532)
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:1874](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1874)
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:1719](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1719)
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:2237](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2237)
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:2242](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2242)
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:2247](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2247)
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:2359](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2359)
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:1928](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1928)
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:1061](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1061)
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
 
@@ -581,6 +581,23 @@ Add a subject to the EPUB metadata.
581
581
 
582
582
  https://www.w3.org/TR/epub-33/#sec-opf-dcsubject
583
583
 
584
+ #### copy()
585
+
586
+ > **copy**(`path?`): `Promise`\<[`Epub`](#epub)\>
587
+
588
+ Defined in:
589
+ [epub/index.ts:593](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L593)
590
+
591
+ ##### Parameters
592
+
593
+ | Parameter | Type |
594
+ | --------- | -------- |
595
+ | `path?` | `string` |
596
+
597
+ ##### Returns
598
+
599
+ `Promise`\<[`Epub`](#epub)\>
600
+
584
601
  #### createXhtmlDocument()
585
602
 
586
603
  > **createXhtmlDocument**(`body`, `head?`, `language?`):
@@ -588,7 +605,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcsubject
588
605
  > [`XmlElement`](#xmlelement)\<`"?xml"`\>)[]\>
589
606
 
590
607
  Defined in:
591
- [epub/index.ts:2063](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2063)
608
+ [epub/index.ts:2117](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2117)
592
609
 
593
610
  Create a new XHTML document with the given body and head.
594
611
 
@@ -610,7 +627,7 @@ Create a new XHTML document with the given body and head.
610
627
  > **discardAndClose**(): `void`
611
628
 
612
629
  Defined in:
613
- [epub/index.ts:2468](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2468)
630
+ [epub/index.ts:2522](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2522)
614
631
 
615
632
  ##### Returns
616
633
 
@@ -621,7 +638,7 @@ Defined in:
621
638
  > **findAllMetadataItems**(`predicate`): `Promise`\<`object`[]\>
622
639
 
623
640
  Defined in:
624
- [epub/index.ts:784](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L784)
641
+ [epub/index.ts:838](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L838)
625
642
 
626
643
  Returns the item in the metadata element's children array that matches the
627
644
  provided predicate.
@@ -661,7 +678,7 @@ provided predicate.
661
678
  > \}\>
662
679
 
663
680
  Defined in:
664
- [epub/index.ts:775](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L775)
681
+ [epub/index.ts:829](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L829)
665
682
 
666
683
  Returns the item in the metadata element's children array that matches the
667
684
  provided predicate.
@@ -700,7 +717,7 @@ provided predicate.
700
717
  > **getCollections**(): `Promise`\<[`Collection`](#collection)[]\>
701
718
 
702
719
  Defined in:
703
- [epub/index.ts:1492](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1492)
720
+ [epub/index.ts:1546](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1546)
704
721
 
705
722
  Retrieve the list of collections.
706
723
 
@@ -713,7 +730,7 @@ Retrieve the list of collections.
713
730
  > **getContributors**(): `Promise`\<[`DcCreator`](#dccreator)[]\>
714
731
 
715
732
  Defined in:
716
- [epub/index.ts:1706](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1706)
733
+ [epub/index.ts:1760](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1760)
717
734
 
718
735
  Retrieve the list of contributors.
719
736
 
@@ -732,7 +749,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccontributor
732
749
  > **getCoverImage**(): `Promise`\<`null` \| `Uint8Array`\<`ArrayBufferLike`\>\>
733
750
 
734
751
  Defined in:
735
- [epub/index.ts:964](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L964)
752
+ [epub/index.ts:1018](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1018)
736
753
 
737
754
  Retrieve the cover image data as a byte array.
738
755
 
@@ -753,7 +770,7 @@ https://www.w3.org/TR/epub-33/#sec-cover-image
753
770
  > [`ManifestItem`](#manifestitem)\>
754
771
 
755
772
  Defined in:
756
- [epub/index.ts:945](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L945)
773
+ [epub/index.ts:999](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L999)
757
774
 
758
775
  Retrieve the cover image manifest item.
759
776
 
@@ -773,7 +790,7 @@ https://www.w3.org/TR/epub-33/#sec-cover-image
773
790
  > **getCreators**(`type`): `Promise`\<[`DcCreator`](#dccreator)[]\>
774
791
 
775
792
  Defined in:
776
- [epub/index.ts:1645](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1645)
793
+ [epub/index.ts:1699](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1699)
777
794
 
778
795
  Retrieve the list of creators.
779
796
 
@@ -796,7 +813,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
796
813
  > **getDescription**(): `Promise`\<`null` \| `string`\>
797
814
 
798
815
  Defined in:
799
- [epub/index.ts:1343](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1343)
816
+ [epub/index.ts:1397](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1397)
800
817
 
801
818
  Retrieve the Epub's description as specified in its package document metadata.
802
819
 
@@ -812,7 +829,7 @@ as a string. Descriptions may include HTML markup.
812
829
  > **getIdentifier**(): `Promise`\<`null` \| `string`\>
813
830
 
814
831
  Defined in:
815
- [epub/index.ts:879](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L879)
832
+ [epub/index.ts:933](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L933)
816
833
 
817
834
  Retrieve the identifier from the dc:identifier element in the EPUB metadata.
818
835
 
@@ -831,7 +848,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
831
848
  > **getLanguage**(): `Promise`\<`null` \| `Locale`\>
832
849
 
833
850
  Defined in:
834
- [epub/index.ts:1180](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1180)
851
+ [epub/index.ts:1234](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1234)
835
852
 
836
853
  Retrieve the Epub's language as specified in its package document metadata.
837
854
 
@@ -852,7 +869,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dclanguage
852
869
  > [`ManifestItem`](#manifestitem)\>\>
853
870
 
854
871
  Defined in:
855
- [epub/index.ts:700](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L700)
872
+ [epub/index.ts:754](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L754)
856
873
 
857
874
  Retrieve the manifest for the Epub.
858
875
 
@@ -872,7 +889,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-manifest
872
889
  > **getMetadata**(): `Promise`\<[`EpubMetadata`](#epubmetadata)\>
873
890
 
874
891
  Defined in:
875
- [epub/index.ts:851](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L851)
892
+ [epub/index.ts:905](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L905)
876
893
 
877
894
  Retrieve the metadata entries for the Epub.
878
895
 
@@ -896,7 +913,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-metadata
896
913
  > `string`\>\>
897
914
 
898
915
  Defined in:
899
- [epub/index.ts:1360](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1360)
916
+ [epub/index.ts:1414](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1414)
900
917
 
901
918
  Return the set of custom vocabulary prefixes set on this publication's root
902
919
  package element.
@@ -916,7 +933,7 @@ https://www.w3.org/TR/epub-33/#sec-prefix-attr
916
933
  > **getPublicationDate**(): `Promise`\<`null` \| `Date`\>
917
934
 
918
935
  Defined in:
919
- [epub/index.ts:1001](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1001)
936
+ [epub/index.ts:1055](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1055)
920
937
 
921
938
  Retrieve the publication date from the dc:date element in the EPUB metadata as a
922
939
  Date object.
@@ -936,7 +953,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcdate
936
953
  > **getRootfile**(): `Promise`\<`string`\>
937
954
 
938
955
  Defined in:
939
- [epub/index.ts:552](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L552)
956
+ [epub/index.ts:626](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L626)
940
957
 
941
958
  ##### Returns
942
959
 
@@ -947,7 +964,7 @@ Defined in:
947
964
  > **getSpineItems**(): `Promise`\<[`ManifestItem`](#manifestitem)[]\>
948
965
 
949
966
  Defined in:
950
- [epub/index.ts:1909](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1909)
967
+ [epub/index.ts:1963](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1963)
951
968
 
952
969
  Retrieve the manifest items that make up the Epub's spine.
953
970
 
@@ -967,7 +984,7 @@ https://www.w3.org/TR/epub-33/#sec-spine-elem
967
984
  > **getSubjects**(): `Promise`\<(`string` \| [`DcSubject`](#dcsubject))[]\>
968
985
 
969
986
  Defined in:
970
- [epub/index.ts:1135](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1135)
987
+ [epub/index.ts:1189](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1189)
971
988
 
972
989
  Retrieve the list of subjects for this EPUB.
973
990
 
@@ -988,7 +1005,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcsubject
988
1005
  > **getSubtitle**(): `Promise`\<`null` \| `string`\>
989
1006
 
990
1007
  Defined in:
991
- [epub/index.ts:1250](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1250)
1008
+ [epub/index.ts:1304](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1304)
992
1009
 
993
1010
  Retrieve the subtitle of the Epub, if it exists.
994
1011
 
@@ -1005,7 +1022,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctitle
1005
1022
  > **getTitle**(`expanded`): `Promise`\<`null` \| `string`\>
1006
1023
 
1007
1024
  Defined in:
1008
- [epub/index.ts:1226](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1226)
1025
+ [epub/index.ts:1280](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1280)
1009
1026
 
1010
1027
  Retrieve the title of the Epub.
1011
1028
 
@@ -1028,7 +1045,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctitle
1028
1045
  > **getTitles**(): `Promise`\<`object`[]\>
1029
1046
 
1030
1047
  Defined in:
1031
- [epub/index.ts:1262](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1262)
1048
+ [epub/index.ts:1316](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1316)
1032
1049
 
1033
1050
  Retrieve all title entries of the Epub.
1034
1051
 
@@ -1045,7 +1062,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctitle
1045
1062
  > **getType**(): `Promise`\<`null` \| [`MetadataEntry`](#metadataentry)\>
1046
1063
 
1047
1064
  Defined in:
1048
- [epub/index.ts:1048](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1048)
1065
+ [epub/index.ts:1102](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1102)
1049
1066
 
1050
1067
  Retrieve the publication type from the dc:type element in the EPUB metadata.
1051
1068
 
@@ -1067,7 +1084,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctype
1067
1084
  > `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
1068
1085
 
1069
1086
  Defined in:
1070
- [epub/index.ts:2004](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2004)
1087
+ [epub/index.ts:2058](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2058)
1071
1088
 
1072
1089
  Retrieve the contents of a file, given its href.
1073
1090
 
@@ -1090,7 +1107,7 @@ encoding parameter.
1090
1107
  > **readFileContents**(`href`, `relativeTo`, `encoding`): `Promise`\<`string`\>
1091
1108
 
1092
1109
  Defined in:
1093
- [epub/index.ts:2005](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2005)
1110
+ [epub/index.ts:2059](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2059)
1094
1111
 
1095
1112
  Retrieve the contents of a file, given its href.
1096
1113
 
@@ -1116,7 +1133,7 @@ encoding parameter.
1116
1133
  > **readItemContents**(`id`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\>\>
1117
1134
 
1118
1135
  Defined in:
1119
- [epub/index.ts:2035](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2035)
1136
+ [epub/index.ts:2089](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2089)
1120
1137
 
1121
1138
  Retrieve the contents of a manifest item, given its id.
1122
1139
 
@@ -1139,7 +1156,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
1139
1156
  > **readItemContents**(`id`, `encoding`): `Promise`\<`string`\>
1140
1157
 
1141
1158
  Defined in:
1142
- [epub/index.ts:2036](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2036)
1159
+ [epub/index.ts:2090](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2090)
1143
1160
 
1144
1161
  Retrieve the contents of a manifest item, given its id.
1145
1162
 
@@ -1165,7 +1182,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
1165
1182
  > **readXhtmlItemContents**(`id`, `as?`): `Promise`\<[`ParsedXml`](#parsedxml)\>
1166
1183
 
1167
1184
  Defined in:
1168
- [epub/index.ts:2098](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2098)
1185
+ [epub/index.ts:2152](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2152)
1169
1186
 
1170
1187
  Retrieves the contents of an XHTML item, given its manifest id.
1171
1188
 
@@ -1189,7 +1206,7 @@ https://www.w3.org/TR/epub-33/#sec-xhtml
1189
1206
  > **readXhtmlItemContents**(`id`, `as`): `Promise`\<`string`\>
1190
1207
 
1191
1208
  Defined in:
1192
- [epub/index.ts:2099](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2099)
1209
+ [epub/index.ts:2153](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2153)
1193
1210
 
1194
1211
  Retrieves the contents of an XHTML item, given its manifest id.
1195
1212
 
@@ -1213,7 +1230,7 @@ https://www.w3.org/TR/epub-33/#sec-xhtml
1213
1230
  > **removeCollection**(`index`): `Promise`\<`void`\>
1214
1231
 
1215
1232
  Defined in:
1216
- [epub/index.ts:1601](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1601)
1233
+ [epub/index.ts:1655](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1655)
1217
1234
 
1218
1235
  Remove a collection from the EPUB metadata.
1219
1236
 
@@ -1235,7 +1252,7 @@ returned by `epub.getCollections()`.
1235
1252
  > **removeContributor**(`index`): `Promise`\<`void`\>
1236
1253
 
1237
1254
  Defined in:
1238
- [epub/index.ts:1858](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1858)
1255
+ [epub/index.ts:1912](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1912)
1239
1256
 
1240
1257
  Remove a contributor from the EPUB metadata.
1241
1258
 
@@ -1263,7 +1280,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
1263
1280
  > **removeCreator**(`index`, `type`): `Promise`\<`void`\>
1264
1281
 
1265
1282
  Defined in:
1266
- [epub/index.ts:1806](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1806)
1283
+ [epub/index.ts:1860](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1860)
1267
1284
 
1268
1285
  Remove a creator from the EPUB metadata.
1269
1286
 
@@ -1290,7 +1307,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
1290
1307
  > **removeManifestItem**(`id`): `Promise`\<`void`\>
1291
1308
 
1292
1309
  Defined in:
1293
- [epub/index.ts:2194](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2194)
1310
+ [epub/index.ts:2248](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2248)
1294
1311
 
1295
1312
  ##### Parameters
1296
1313
 
@@ -1307,7 +1324,7 @@ Defined in:
1307
1324
  > **removeMetadata**(`predicate`): `Promise`\<`void`\>
1308
1325
 
1309
1326
  Defined in:
1310
- [epub/index.ts:2443](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2443)
1327
+ [epub/index.ts:2497](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2497)
1311
1328
 
1312
1329
  Remove one or more metadata entries.
1313
1330
 
@@ -1333,7 +1350,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-metadata
1333
1350
  > **removeSpineItem**(`index`): `Promise`\<`void`\>
1334
1351
 
1335
1352
  Defined in:
1336
- [epub/index.ts:1964](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1964)
1353
+ [epub/index.ts:2018](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2018)
1337
1354
 
1338
1355
  Remove the spine item at the specified index.
1339
1356
 
@@ -1356,7 +1373,7 @@ https://www.w3.org/TR/epub-33/#sec-spine-elem
1356
1373
  > **removeSubject**(`index`): `Promise`\<`void`\>
1357
1374
 
1358
1375
  Defined in:
1359
- [epub/index.ts:1098](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1098)
1376
+ [epub/index.ts:1152](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1152)
1360
1377
 
1361
1378
  Remove a subject from the EPUB metadata.
1362
1379
 
@@ -1382,7 +1399,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dccreator
1382
1399
  > **replaceMetadata**(`predicate`, `entry`): `Promise`\<`void`\>
1383
1400
 
1384
1401
  Defined in:
1385
- [epub/index.ts:2398](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2398)
1402
+ [epub/index.ts:2452](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2452)
1386
1403
 
1387
1404
  Replace a metadata entry with a new one.
1388
1405
 
@@ -1409,7 +1426,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-metadata
1409
1426
  > **saveAndClose**(): `Promise`\<`void`\>
1410
1427
 
1411
1428
  Defined in:
1412
- [epub/index.ts:2484](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2484)
1429
+ [epub/index.ts:2538](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2538)
1413
1430
 
1414
1431
  Write the current contents of the Epub to a new EPUB archive on disk.
1415
1432
 
@@ -1425,7 +1442,7 @@ updated to the current UTC timestamp.
1425
1442
  > **setCoverImage**(`href`, `data`): `Promise`\<`void`\>
1426
1443
 
1427
1444
  Defined in:
1428
- [epub/index.ts:978](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L978)
1445
+ [epub/index.ts:1032](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1032)
1429
1446
 
1430
1447
  Set the cover image for the EPUB.
1431
1448
 
@@ -1448,7 +1465,7 @@ then writes the provided image data to the provided href within the publication.
1448
1465
  > **setDescription**(`description`): `Promise`\<`void`\>
1449
1466
 
1450
1467
  Defined in:
1451
- [epub/index.ts:1327](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1327)
1468
+ [epub/index.ts:1381](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1381)
1452
1469
 
1453
1470
  Update the Epub's description metadata entry.
1454
1471
 
@@ -1471,7 +1488,7 @@ encoded as HTML entities.
1471
1488
  > **setIdentifier**(`identifier`): `Promise`\<`void`\>
1472
1489
 
1473
1490
  Defined in:
1474
- [epub/index.ts:893](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L893)
1491
+ [epub/index.ts:947](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L947)
1475
1492
 
1476
1493
  Set the dc:identifier metadata element with the provided string.
1477
1494
 
@@ -1497,7 +1514,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcidentifier
1497
1514
  > **setLanguage**(`locale`): `Promise`\<`void`\>
1498
1515
 
1499
1516
  Defined in:
1500
- [epub/index.ts:1209](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1209)
1517
+ [epub/index.ts:1263](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1263)
1501
1518
 
1502
1519
  Update the Epub's language metadata entry.
1503
1520
 
@@ -1523,7 +1540,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dclanguage
1523
1540
  > **setPackageVocabularyPrefix**(`prefix`, `uri`): `Promise`\<`void`\>
1524
1541
 
1525
1542
  Defined in:
1526
- [epub/index.ts:1378](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1378)
1543
+ [epub/index.ts:1432](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1432)
1527
1544
 
1528
1545
  Set a custom vocabulary prefix on the root package element.
1529
1546
 
@@ -1547,7 +1564,7 @@ https://www.w3.org/TR/epub-33/#sec-prefix-attr
1547
1564
  > **setPublicationDate**(`date`): `Promise`\<`void`\>
1548
1565
 
1549
1566
  Defined in:
1550
- [epub/index.ts:1016](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1016)
1567
+ [epub/index.ts:1070](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1070)
1551
1568
 
1552
1569
  Set the dc:date metadata element with the provided date.
1553
1570
 
@@ -1573,7 +1590,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dcdate
1573
1590
  > **setTitle**(`title`): `Promise`\<`void`\>
1574
1591
 
1575
1592
  Defined in:
1576
- [epub/index.ts:1402](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1402)
1593
+ [epub/index.ts:1456](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1456)
1577
1594
 
1578
1595
  Set the title of the Epub.
1579
1596
 
@@ -1601,7 +1618,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctitle
1601
1618
  > **setTitles**(`entries`): `Promise`\<`void`\>
1602
1619
 
1603
1620
  Defined in:
1604
- [epub/index.ts:1430](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1430)
1621
+ [epub/index.ts:1484](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1484)
1605
1622
 
1606
1623
  ##### Parameters
1607
1624
 
@@ -1618,7 +1635,7 @@ Defined in:
1618
1635
  > **setType**(`type`): `Promise`\<`void`\>
1619
1636
 
1620
1637
  Defined in:
1621
- [epub/index.ts:1032](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1032)
1638
+ [epub/index.ts:1086](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L1086)
1622
1639
 
1623
1640
  Set the dc:type metadata element.
1624
1641
 
@@ -1644,7 +1661,7 @@ https://www.w3.org/TR/epub-33/#sec-opf-dctype
1644
1661
  > **updateManifestItem**(`id`, `newItem`): `Promise`\<`void`\>
1645
1662
 
1646
1663
  Defined in:
1647
- [epub/index.ts:2310](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2310)
1664
+ [epub/index.ts:2364](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2364)
1648
1665
 
1649
1666
  Update the manifest entry for an existing item.
1650
1667
 
@@ -1673,7 +1690,7 @@ https://www.w3.org/TR/epub-33/#sec-pkg-manifest
1673
1690
  > **writeItemContents**(`id`, `contents`): `Promise`\<`void`\>
1674
1691
 
1675
1692
  Defined in:
1676
- [epub/index.ts:2146](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2146)
1693
+ [epub/index.ts:2200](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2200)
1677
1694
 
1678
1695
  Write new contents for an existing manifest item, specified by its id.
1679
1696
 
@@ -1700,7 +1717,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
1700
1717
  > **writeItemContents**(`id`, `contents`, `encoding`): `Promise`\<`void`\>
1701
1718
 
1702
1719
  Defined in:
1703
- [epub/index.ts:2147](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2147)
1720
+ [epub/index.ts:2201](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2201)
1704
1721
 
1705
1722
  Write new contents for an existing manifest item, specified by its id.
1706
1723
 
@@ -1728,7 +1745,7 @@ https://www.w3.org/TR/epub-33/#sec-contentdocs
1728
1745
  > **writeXhtmlItemContents**(`id`, `contents`): `Promise`\<`void`\>
1729
1746
 
1730
1747
  Defined in:
1731
- [epub/index.ts:2186](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2186)
1748
+ [epub/index.ts:2240](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L2240)
1732
1749
 
1733
1750
  Write new contents for an existing XHTML item, specified by its id.
1734
1751
 
@@ -1755,7 +1772,7 @@ https://www.w3.org/TR/epub-33/#sec-xhtml
1755
1772
  > `static` **addLinkToXhtmlHead**(`xml`, `link`): `void`
1756
1773
 
1757
1774
  Defined in:
1758
- [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)
1759
1776
 
1760
1777
  Given an XML structure representing a complete XHTML document, add a `link`
1761
1778
  element to the `head` of the document.
@@ -1782,7 +1799,7 @@ This method modifies the provided XML structure.
1782
1799
  > `Promise`\<[`Epub`](#epub)\>
1783
1800
 
1784
1801
  Defined in:
1785
- [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)
1786
1803
 
1787
1804
  Construct an Epub instance, optionally beginning with the provided metadata.
1788
1805
 
@@ -1804,7 +1821,7 @@ Construct an Epub instance, optionally beginning with the provided metadata.
1804
1821
  > [`XmlElement`](#xmlelement)\<`Name`\>
1805
1822
 
1806
1823
  Defined in:
1807
- [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)
1808
1825
 
1809
1826
  ##### Type Parameters
1810
1827
 
@@ -1829,7 +1846,7 @@ Defined in:
1829
1846
  > `static` **createXmlTextNode**(`text`): [`XmlTextNode`](#xmltextnode)
1830
1847
 
1831
1848
  Defined in:
1832
- [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)
1833
1850
 
1834
1851
  ##### Parameters
1835
1852
 
@@ -1847,7 +1864,7 @@ Defined in:
1847
1864
  > `undefined` \| [`XmlElement`](#xmlelement)\<`Name`\>
1848
1865
 
1849
1866
  Defined in:
1850
- [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)
1851
1868
 
1852
1869
  Given an XML structure, find the first child matching the provided name and
1853
1870
  optional filter.
@@ -1875,7 +1892,7 @@ optional filter.
1875
1892
  > `static` **formatSmilDuration**(`duration`): `string`
1876
1893
 
1877
1894
  Defined in:
1878
- [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)
1879
1896
 
1880
1897
  Format a duration, provided as a number of seconds, as a SMIL clock value, to be
1881
1898
  used for Media Overlays.
@@ -1899,7 +1916,7 @@ https://www.w3.org/TR/epub-33/#sec-duration
1899
1916
  > `static` **from**(`pathOrData`): `Promise`\<[`Epub`](#epub)\>
1900
1917
 
1901
1918
  Defined in:
1902
- [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)
1903
1920
 
1904
1921
  Construct an Epub instance by reading an existing EPUB publication.
1905
1922
 
@@ -1918,7 +1935,7 @@ Construct an Epub instance by reading an existing EPUB publication.
1918
1935
  > `static` **getXhtmlBody**(`xml`): [`ParsedXml`](#parsedxml)
1919
1936
 
1920
1937
  Defined in:
1921
- [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)
1922
1939
 
1923
1940
  Given an XML structure representing a complete XHTML document, return the
1924
1941
  sub-structure representing the children of the document's body element.
@@ -1938,7 +1955,7 @@ sub-structure representing the children of the document's body element.
1938
1955
  > `static` **getXhtmlTextContent**(`xml`): `string`
1939
1956
 
1940
1957
  Defined in:
1941
- [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)
1942
1959
 
1943
1960
  Given an XML structure representing a complete XHTML document, return a string
1944
1961
  representing the concatenation of all text nodes in the document.
@@ -1958,7 +1975,7 @@ representing the concatenation of all text nodes in the document.
1958
1975
  > `static` **getXmlAttributes**(`element`): `Record`\<`string`, `string`\>
1959
1976
 
1960
1977
  Defined in:
1961
- [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)
1962
1979
 
1963
1980
  Given an XMLElement, return its attributes.
1964
1981
 
@@ -1977,7 +1994,7 @@ Given an XMLElement, return its attributes.
1977
1994
  > `static` **getXmlChildren**\<`Name`\>(`element`): [`ParsedXml`](#parsedxml)
1978
1995
 
1979
1996
  Defined in:
1980
- [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)
1981
1998
 
1982
1999
  Given an XMLElement, return a list of its children
1983
2000
 
@@ -2002,7 +2019,7 @@ Given an XMLElement, return a list of its children
2002
2019
  > `static` **getXmlElementName**\<`Name`\>(`element`): `Name`
2003
2020
 
2004
2021
  Defined in:
2005
- [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)
2006
2023
 
2007
2024
  Given an XMLElement, return its tag name.
2008
2025
 
@@ -2027,7 +2044,7 @@ Given an XMLElement, return its tag name.
2027
2044
  > `static` **isXmlTextNode**(`node`): `node is XmlTextNode`
2028
2045
 
2029
2046
  Defined in:
2030
- [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)
2031
2048
 
2032
2049
  Given an XMLNode, determine whether it represents a text node or an XML element.
2033
2050
 
@@ -2046,7 +2063,7 @@ Given an XMLNode, determine whether it represents a text node or an XML element.
2046
2063
  > `static` **replaceXmlChildren**\<`Name`\>(`element`, `children`): `void`
2047
2064
 
2048
2065
  Defined in:
2049
- [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)
2050
2067
 
2051
2068
  ##### Type Parameters
2052
2069
 
@@ -2374,8 +2391,7 @@ Defined in:
2374
2391
 
2375
2392
  ## PackageElement
2376
2393
 
2377
- > **PackageElement** = [`XmlElement`](#xmlelement)\<`"package"`\> \|
2378
- > [`XmlElement`](#xmlelement)\<`"opf:package"`\>
2394
+ > **PackageElement** = [`XmlElement`](#xmlelement)\<`"package"`\>
2379
2395
 
2380
2396
  Defined in:
2381
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,39 @@ ${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;
429
+ }
430
+ async copy(path) {
431
+ const extractPath = (0, import_path.join)(
432
+ (0, import_node_os.tmpdir)(),
433
+ `storyteller-platform-epub-${(0, import_node_crypto.randomUUID)()}.epub`
434
+ );
435
+ try {
436
+ await (0, import_promises.cp)(this.extractPath, extractPath, { recursive: true });
437
+ } catch (error) {
438
+ (0, import_node_fs.rmSync)(extractPath, { force: true, recursive: true });
439
+ throw error;
440
+ }
441
+ return new Epub(extractPath, path);
387
442
  }
388
443
  async removeEntry(href) {
389
444
  const rootfile = await this.getRootfile();
@@ -432,17 +487,6 @@ ${JSON.stringify(element, null, 2)}`
432
487
  this.rootfile = (0, import_path.resolve)(this.extractPath, fullPath);
433
488
  return this.rootfile;
434
489
  }
435
- migratePackageDocument(packageDocument) {
436
- for (const element of packageDocument) {
437
- if (Epub.isXmlTextNode(element)) continue;
438
- const elementName = Epub.getXmlElementName(element);
439
- if (elementName.startsWith("opf:")) {
440
- element[elementName.replace("opf:", "")] = Epub.getXmlChildren(element);
441
- delete element[elementName];
442
- this.migratePackageDocument(Epub.getXmlChildren(element));
443
- }
444
- }
445
- }
446
490
  async getPackageDocument() {
447
491
  const rootfile = await this.getRootfile();
448
492
  const packageDocumentString = await this.getFileData(rootfile, "utf-8");
@@ -457,13 +501,12 @@ ${JSON.stringify(element, null, 2)}`
457
501
  }
458
502
  async getPackageElement() {
459
503
  const packageDocument = await this.getPackageDocument();
460
- const packageElement = Epub.findXmlChildByName("package", packageDocument) ?? Epub.findXmlChildByName("opf:package", packageDocument);
504
+ const packageElement = Epub.findXmlChildByName("package", packageDocument);
461
505
  if (!packageElement) {
462
506
  throw new Error(
463
507
  "Failed to parse EPUB: Found no package element in package document"
464
508
  );
465
509
  }
466
- this.migratePackageDocument(packageDocument);
467
510
  return packageElement;
468
511
  }
469
512
  /**
@@ -481,7 +524,7 @@ ${JSON.stringify(element, null, 2)}`
481
524
  async withPackage(producer) {
482
525
  await this.packageMutex.runExclusive(async () => {
483
526
  const packageDocument = await this.getPackageDocument();
484
- const packageElement = Epub.findXmlChildByName("package", packageDocument) ?? Epub.findXmlChildByName("opf:package", packageDocument);
527
+ const packageElement = Epub.findXmlChildByName("package", packageDocument);
485
528
  if (!packageElement) {
486
529
  throw new Error(
487
530
  "Failed to parse EPUB: Found no package element in package document"
@@ -1910,7 +1953,8 @@ ${JSON.stringify(element, null, 2)}`
1910
1953
  if (entry.name === "mimetype" || entry.isDirectory()) continue;
1911
1954
  zipfile.addFile(
1912
1955
  (0, import_path.join)(entry.parentPath, entry.name),
1913
- (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) }
1914
1958
  );
1915
1959
  }
1916
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
  *
@@ -186,10 +186,10 @@ declare class Epub {
186
186
  * the data of the EPUB publication.
187
187
  */
188
188
  static from(pathOrData: string | Uint8Array): Promise<Epub>;
189
+ copy(path?: string): Promise<Epub>;
189
190
  private removeEntry;
190
191
  private getFileData;
191
192
  getRootfile(): Promise<string>;
192
- private migratePackageDocument;
193
193
  private getPackageDocument;
194
194
  private getPackageElement;
195
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
  *
@@ -186,10 +186,10 @@ declare class Epub {
186
186
  * the data of the EPUB publication.
187
187
  */
188
188
  static from(pathOrData: string | Uint8Array): Promise<Epub>;
189
+ copy(path?: string): Promise<Epub>;
189
190
  private removeEntry;
190
191
  private getFileData;
191
192
  getRootfile(): Promise<string>;
192
- private migratePackageDocument;
193
193
  private getPackageDocument;
194
194
  private getPackageElement;
195
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,39 @@ ${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;
396
+ }
397
+ async copy(path) {
398
+ const extractPath = join(
399
+ tmpdir(),
400
+ `storyteller-platform-epub-${randomUUID()}.epub`
401
+ );
402
+ try {
403
+ await cp(this.extractPath, extractPath, { recursive: true });
404
+ } catch (error) {
405
+ rmSync(extractPath, { force: true, recursive: true });
406
+ throw error;
407
+ }
408
+ return new Epub(extractPath, path);
354
409
  }
355
410
  async removeEntry(href) {
356
411
  const rootfile = await this.getRootfile();
@@ -399,17 +454,6 @@ ${JSON.stringify(element, null, 2)}`
399
454
  this.rootfile = resolve(this.extractPath, fullPath);
400
455
  return this.rootfile;
401
456
  }
402
- migratePackageDocument(packageDocument) {
403
- for (const element of packageDocument) {
404
- if (Epub.isXmlTextNode(element)) continue;
405
- const elementName = Epub.getXmlElementName(element);
406
- if (elementName.startsWith("opf:")) {
407
- element[elementName.replace("opf:", "")] = Epub.getXmlChildren(element);
408
- delete element[elementName];
409
- this.migratePackageDocument(Epub.getXmlChildren(element));
410
- }
411
- }
412
- }
413
457
  async getPackageDocument() {
414
458
  const rootfile = await this.getRootfile();
415
459
  const packageDocumentString = await this.getFileData(rootfile, "utf-8");
@@ -424,13 +468,12 @@ ${JSON.stringify(element, null, 2)}`
424
468
  }
425
469
  async getPackageElement() {
426
470
  const packageDocument = await this.getPackageDocument();
427
- const packageElement = Epub.findXmlChildByName("package", packageDocument) ?? Epub.findXmlChildByName("opf:package", packageDocument);
471
+ const packageElement = Epub.findXmlChildByName("package", packageDocument);
428
472
  if (!packageElement) {
429
473
  throw new Error(
430
474
  "Failed to parse EPUB: Found no package element in package document"
431
475
  );
432
476
  }
433
- this.migratePackageDocument(packageDocument);
434
477
  return packageElement;
435
478
  }
436
479
  /**
@@ -448,7 +491,7 @@ ${JSON.stringify(element, null, 2)}`
448
491
  async withPackage(producer) {
449
492
  await this.packageMutex.runExclusive(async () => {
450
493
  const packageDocument = await this.getPackageDocument();
451
- const packageElement = Epub.findXmlChildByName("package", packageDocument) ?? Epub.findXmlChildByName("opf:package", packageDocument);
494
+ const packageElement = Epub.findXmlChildByName("package", packageDocument);
452
495
  if (!packageElement) {
453
496
  throw new Error(
454
497
  "Failed to parse EPUB: Found no package element in package document"
@@ -1877,7 +1920,8 @@ ${JSON.stringify(element, null, 2)}`
1877
1920
  if (entry.name === "mimetype" || entry.isDirectory()) continue;
1878
1921
  zipfile.addFile(
1879
1922
  join(entry.parentPath, entry.name),
1880
- join(entry.parentPath, entry.name).replace(`${this.extractPath}/`, "")
1923
+ join(entry.parentPath, entry.name).replace(`${this.extractPath}/`, ""),
1924
+ { compress: !isAudioFile(entry.name) }
1881
1925
  );
1882
1926
  }
1883
1927
  zipfile.end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storyteller-platform/epub",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",