@storyteller-platform/epub 0.6.1 → 0.6.3
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 +362 -1
- package/dist/epubcheck.cjs +60 -0
- package/dist/epubcheck.d.cts +23 -0
- package/dist/epubcheck.d.ts +23 -0
- package/dist/epubcheck.js +36 -0
- package/dist/index.cjs +10 -4
- package/dist/index.js +10 -4
- package/dist/upgrade.d.cts +2 -2
- package/dist/upgrade.d.ts +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -4284,4 +4284,365 @@ Defined in:
|
|
|
4284
4284
|
[epub/adapters/memory.ts:22](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/adapters/memory.ts#L22)
|
|
4285
4285
|
|
|
4286
4286
|
per-entry decompressed buffer cache turn it off when opening many EPUBs and
|
|
4287
|
-
reading
|
|
4287
|
+
reading each entry at most once keeps resident size bounded by the entry index,
|
|
4288
|
+
not the decompressed payload sum
|
|
4289
|
+
|
|
4290
|
+
##### Default
|
|
4291
|
+
|
|
4292
|
+
```ts
|
|
4293
|
+
true
|
|
4294
|
+
```
|
|
4295
|
+
|
|
4296
|
+
#### signal?
|
|
4297
|
+
|
|
4298
|
+
> `optional` **signal**: `AbortSignal`
|
|
4299
|
+
|
|
4300
|
+
Defined in:
|
|
4301
|
+
[epub/adapters/memory.ts:23](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/adapters/memory.ts#L23)
|
|
4302
|
+
|
|
4303
|
+
---
|
|
4304
|
+
|
|
4305
|
+
## Navigation
|
|
4306
|
+
|
|
4307
|
+
Defined in:
|
|
4308
|
+
[epub/index.ts:165](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L165)
|
|
4309
|
+
|
|
4310
|
+
### Properties
|
|
4311
|
+
|
|
4312
|
+
#### children
|
|
4313
|
+
|
|
4314
|
+
> **children**: [`NavigationList`](#navigationlist)
|
|
4315
|
+
|
|
4316
|
+
Defined in:
|
|
4317
|
+
[epub/index.ts:167](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L167)
|
|
4318
|
+
|
|
4319
|
+
#### title?
|
|
4320
|
+
|
|
4321
|
+
> `optional` **title**: `string`
|
|
4322
|
+
|
|
4323
|
+
Defined in:
|
|
4324
|
+
[epub/index.ts:166](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L166)
|
|
4325
|
+
|
|
4326
|
+
---
|
|
4327
|
+
|
|
4328
|
+
## NavigationItem
|
|
4329
|
+
|
|
4330
|
+
Defined in:
|
|
4331
|
+
[epub/index.ts:157](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L157)
|
|
4332
|
+
|
|
4333
|
+
### Properties
|
|
4334
|
+
|
|
4335
|
+
#### children?
|
|
4336
|
+
|
|
4337
|
+
> `optional` **children**: [`NavigationList`](#navigationlist)
|
|
4338
|
+
|
|
4339
|
+
Defined in:
|
|
4340
|
+
[epub/index.ts:160](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L160)
|
|
4341
|
+
|
|
4342
|
+
#### href?
|
|
4343
|
+
|
|
4344
|
+
> `optional` **href**: `string`
|
|
4345
|
+
|
|
4346
|
+
Defined in:
|
|
4347
|
+
[epub/index.ts:159](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L159)
|
|
4348
|
+
|
|
4349
|
+
#### title
|
|
4350
|
+
|
|
4351
|
+
> **title**: `string`
|
|
4352
|
+
|
|
4353
|
+
Defined in:
|
|
4354
|
+
[epub/index.ts:158](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L158)
|
|
4355
|
+
|
|
4356
|
+
---
|
|
4357
|
+
|
|
4358
|
+
## AdapterOptions\<A\>
|
|
4359
|
+
|
|
4360
|
+
> **AdapterOptions**\<`A`\> = `A` _extends_
|
|
4361
|
+
> [`EpubStorageAdapterClass`](#epubstorageadapterclass)\<infer Opts\> ? `Opts` :
|
|
4362
|
+
> `object`
|
|
4363
|
+
|
|
4364
|
+
Defined in:
|
|
4365
|
+
[epub/adapters/interface.ts:82](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/adapters/interface.ts#L82)
|
|
4366
|
+
|
|
4367
|
+
### Type Parameters
|
|
4368
|
+
|
|
4369
|
+
| Type Parameter |
|
|
4370
|
+
| -------------- |
|
|
4371
|
+
| `A` |
|
|
4372
|
+
|
|
4373
|
+
---
|
|
4374
|
+
|
|
4375
|
+
## ElementName
|
|
4376
|
+
|
|
4377
|
+
> **ElementName** =
|
|
4378
|
+
> \`$\{Letter \| Uppercase\<Letter\> \| QuestionMark\}$\{string\}\`
|
|
4379
|
+
|
|
4380
|
+
Defined in:
|
|
4381
|
+
[epub/index.ts:82](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L82)
|
|
4382
|
+
|
|
4383
|
+
A valid name for an XML element (must start with a letter)
|
|
4384
|
+
|
|
4385
|
+
---
|
|
4386
|
+
|
|
4387
|
+
## EpubInstanceFor\<A\>
|
|
4388
|
+
|
|
4389
|
+
> **EpubInstanceFor**\<`A`\> = `A`\[`"capabilities"`\]\[`"writable"`\] _extends_
|
|
4390
|
+
> `true` ? [`Epub`](#epub) : [`EpubReader`](#epubreader)
|
|
4391
|
+
|
|
4392
|
+
Defined in:
|
|
4393
|
+
[epub/index.ts:3006](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L3006)
|
|
4394
|
+
|
|
4395
|
+
Resolves to [Epub](#epub) for writable adapters, [EpubReader](#epubreader) for
|
|
4396
|
+
read-only ones.
|
|
4397
|
+
|
|
4398
|
+
The conditional pivots on `capabilities.writable`, which must be a literal
|
|
4399
|
+
`true`/`false` on the adapter class (use `as const`) for inference to work.
|
|
4400
|
+
|
|
4401
|
+
### Type Parameters
|
|
4402
|
+
|
|
4403
|
+
| Type Parameter |
|
|
4404
|
+
| ------------------------------------------------------------------- |
|
|
4405
|
+
| `A` _extends_ [`EpubStorageAdapterClass`](#epubstorageadapterclass) |
|
|
4406
|
+
|
|
4407
|
+
---
|
|
4408
|
+
|
|
4409
|
+
## EpubMetadata
|
|
4410
|
+
|
|
4411
|
+
> **EpubMetadata** = [`MetadataEntry`](#metadataentry)[]
|
|
4412
|
+
|
|
4413
|
+
Defined in:
|
|
4414
|
+
[epub/index.ts:119](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L119)
|
|
4415
|
+
|
|
4416
|
+
---
|
|
4417
|
+
|
|
4418
|
+
## EpubReader
|
|
4419
|
+
|
|
4420
|
+
> **EpubReader** = `Pick`\<[`Epub`](#epub), `"storage"` \| `"getManifest"` \|
|
|
4421
|
+
> `"getVersion"` \| `"getLayout"` \| `"getBaseDirection"` \| `"getMetadata"` \|
|
|
4422
|
+
> `"findMetadataItem"` \| `"findAllMetadataItems"` \| `"getIdentifier"` \|
|
|
4423
|
+
> `"getTitle"` \| `"getSubtitle"` \| `"getTitles"` \| `"getLanguage"` \|
|
|
4424
|
+
> `"getPublicationDate"` \| `"getModifiedDate"` \| `"getDescription"` \|
|
|
4425
|
+
> `"getType"` \| `"getCreators"` \| `"getContributors"` \| `"getSubjects"` \|
|
|
4426
|
+
> `"getCollections"` \| `"getPackageVocabularyPrefixes"` \|
|
|
4427
|
+
> `"getCoverImageItem"` \| `"getCoverImage"` \| `"getSpineItems"` \|
|
|
4428
|
+
> `"getNcxTableOfContents"` \| `"getGuideEntries"` \| `"getTableOfContents"` \|
|
|
4429
|
+
> `"getLandmarks"` \| `"getPageList"` \| `"resolveHref"` \| `"readFileContents"`
|
|
4430
|
+
> \| `"readItemContents"` \| `"readXhtmlItemContents"` \|
|
|
4431
|
+
> `"getItemArchiveLength"` \| `"discardAndClose"`\> & `Disposable`
|
|
4432
|
+
|
|
4433
|
+
Defined in:
|
|
4434
|
+
[epub/index.ts:190](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L190)
|
|
4435
|
+
|
|
4436
|
+
Read-only view of an EPUB Returned by Epub.using(MemoryAdapter).from(...) and by
|
|
4437
|
+
Epub.from(path, { readonly: true })
|
|
4438
|
+
|
|
4439
|
+
---
|
|
4440
|
+
|
|
4441
|
+
## EpubStorageKind
|
|
4442
|
+
|
|
4443
|
+
> **EpubStorageKind** = `"tmp-dir"` \| `"in-memory"` \| `string` & `object`
|
|
4444
|
+
|
|
4445
|
+
Defined in:
|
|
4446
|
+
[epub/adapters/interface.ts:10](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/adapters/interface.ts#L10)
|
|
4447
|
+
|
|
4448
|
+
Pluggable storage backend for an Epub instance
|
|
4449
|
+
|
|
4450
|
+
Built-in adapters:
|
|
4451
|
+
|
|
4452
|
+
- [TmpFsAdapter](#tmpfsadapter) extracts the archive to a tmp directory and
|
|
4453
|
+
supports the full read/write/save/upgrade
|
|
4454
|
+
- [MemoryAdapter](#memoryadapter) keeps an in-memory zip handle and supports
|
|
4455
|
+
reads only
|
|
4456
|
+
|
|
4457
|
+
---
|
|
4458
|
+
|
|
4459
|
+
## InMemoryEpubReader
|
|
4460
|
+
|
|
4461
|
+
> **InMemoryEpubReader** = [`EpubReader`](#epubreader) & `object`
|
|
4462
|
+
|
|
4463
|
+
Defined in:
|
|
4464
|
+
[epub/index.ts:235](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L235)
|
|
4465
|
+
|
|
4466
|
+
Readonly Epub-instance backed by an in-memory zip handle Returned by
|
|
4467
|
+
`Epub.using(MemoryAdapter).from(...)`
|
|
4468
|
+
|
|
4469
|
+
### Type Declaration
|
|
4470
|
+
|
|
4471
|
+
#### storage
|
|
4472
|
+
|
|
4473
|
+
> `readonly` **storage**: `"in-memory"`
|
|
4474
|
+
|
|
4475
|
+
---
|
|
4476
|
+
|
|
4477
|
+
## ManifestItem
|
|
4478
|
+
|
|
4479
|
+
> **ManifestItem** = `object`
|
|
4480
|
+
|
|
4481
|
+
Defined in:
|
|
4482
|
+
[epub/index.ts:103](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L103)
|
|
4483
|
+
|
|
4484
|
+
### Properties
|
|
4485
|
+
|
|
4486
|
+
#### fallback?
|
|
4487
|
+
|
|
4488
|
+
> `optional` **fallback**: `string`
|
|
4489
|
+
|
|
4490
|
+
Defined in:
|
|
4491
|
+
[epub/index.ts:107](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L107)
|
|
4492
|
+
|
|
4493
|
+
#### href
|
|
4494
|
+
|
|
4495
|
+
> **href**: `string`
|
|
4496
|
+
|
|
4497
|
+
Defined in:
|
|
4498
|
+
[epub/index.ts:105](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L105)
|
|
4499
|
+
|
|
4500
|
+
#### id
|
|
4501
|
+
|
|
4502
|
+
> **id**: `string`
|
|
4503
|
+
|
|
4504
|
+
Defined in:
|
|
4505
|
+
[epub/index.ts:104](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L104)
|
|
4506
|
+
|
|
4507
|
+
#### mediaOverlay?
|
|
4508
|
+
|
|
4509
|
+
> `optional` **mediaOverlay**: `string`
|
|
4510
|
+
|
|
4511
|
+
Defined in:
|
|
4512
|
+
[epub/index.ts:108](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L108)
|
|
4513
|
+
|
|
4514
|
+
#### mediaType?
|
|
4515
|
+
|
|
4516
|
+
> `optional` **mediaType**: `string`
|
|
4517
|
+
|
|
4518
|
+
Defined in:
|
|
4519
|
+
[epub/index.ts:106](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L106)
|
|
4520
|
+
|
|
4521
|
+
#### properties?
|
|
4522
|
+
|
|
4523
|
+
> `optional` **properties**: `string`[]
|
|
4524
|
+
|
|
4525
|
+
Defined in:
|
|
4526
|
+
[epub/index.ts:109](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L109)
|
|
4527
|
+
|
|
4528
|
+
---
|
|
4529
|
+
|
|
4530
|
+
## MetadataEntry
|
|
4531
|
+
|
|
4532
|
+
> **MetadataEntry** = `object`
|
|
4533
|
+
|
|
4534
|
+
Defined in:
|
|
4535
|
+
[epub/index.ts:112](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L112)
|
|
4536
|
+
|
|
4537
|
+
### Properties
|
|
4538
|
+
|
|
4539
|
+
#### id?
|
|
4540
|
+
|
|
4541
|
+
> `optional` **id**: `string`
|
|
4542
|
+
|
|
4543
|
+
Defined in:
|
|
4544
|
+
[epub/index.ts:113](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L113)
|
|
4545
|
+
|
|
4546
|
+
#### properties
|
|
4547
|
+
|
|
4548
|
+
> **properties**: `Record`\<`string`, `string`\>
|
|
4549
|
+
|
|
4550
|
+
Defined in:
|
|
4551
|
+
[epub/index.ts:115](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L115)
|
|
4552
|
+
|
|
4553
|
+
#### type
|
|
4554
|
+
|
|
4555
|
+
> **type**: [`ElementName`](#elementname)
|
|
4556
|
+
|
|
4557
|
+
Defined in:
|
|
4558
|
+
[epub/index.ts:114](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L114)
|
|
4559
|
+
|
|
4560
|
+
#### value
|
|
4561
|
+
|
|
4562
|
+
> **value**: `string` \| `undefined`
|
|
4563
|
+
|
|
4564
|
+
Defined in:
|
|
4565
|
+
[epub/index.ts:116](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L116)
|
|
4566
|
+
|
|
4567
|
+
---
|
|
4568
|
+
|
|
4569
|
+
## NavigationList
|
|
4570
|
+
|
|
4571
|
+
> **NavigationList** = [`NavigationItem`](#navigationitem)[]
|
|
4572
|
+
|
|
4573
|
+
Defined in:
|
|
4574
|
+
[epub/index.ts:163](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L163)
|
|
4575
|
+
|
|
4576
|
+
---
|
|
4577
|
+
|
|
4578
|
+
## PackageElement
|
|
4579
|
+
|
|
4580
|
+
> **PackageElement** = [`XmlElement`](#xmlelement)\<`"package"`\>
|
|
4581
|
+
|
|
4582
|
+
Defined in:
|
|
4583
|
+
[epub/index.ts:176](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L176)
|
|
4584
|
+
|
|
4585
|
+
---
|
|
4586
|
+
|
|
4587
|
+
## ParsedXml
|
|
4588
|
+
|
|
4589
|
+
> **ParsedXml** = [`XmlNode`](#xmlnode)[]
|
|
4590
|
+
|
|
4591
|
+
Defined in:
|
|
4592
|
+
[epub/index.ts:101](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L101)
|
|
4593
|
+
|
|
4594
|
+
An XML structure
|
|
4595
|
+
|
|
4596
|
+
---
|
|
4597
|
+
|
|
4598
|
+
## XmlElement\<Name\>
|
|
4599
|
+
|
|
4600
|
+
> **XmlElement**\<`Name`\> = `object` & `{ [key in Name]: ParsedXml }`
|
|
4601
|
+
|
|
4602
|
+
Defined in:
|
|
4603
|
+
[epub/index.ts:88](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L88)
|
|
4604
|
+
|
|
4605
|
+
An XML element
|
|
4606
|
+
|
|
4607
|
+
### Type Declaration
|
|
4608
|
+
|
|
4609
|
+
#### :@?
|
|
4610
|
+
|
|
4611
|
+
> `optional` **:@**: `Record`\<`` `${PropertyPrefix}${string}` ``, `string`\>
|
|
4612
|
+
|
|
4613
|
+
### Type Parameters
|
|
4614
|
+
|
|
4615
|
+
| Type Parameter | Default type |
|
|
4616
|
+
| ---------------------------------------------- | ----------------------------- |
|
|
4617
|
+
| `Name` _extends_ [`ElementName`](#elementname) | [`ElementName`](#elementname) |
|
|
4618
|
+
|
|
4619
|
+
---
|
|
4620
|
+
|
|
4621
|
+
## XmlNode
|
|
4622
|
+
|
|
4623
|
+
> **XmlNode** = [`XmlElement`](#xmlelement) \| [`XmlTextNode`](#xmltextnode)
|
|
4624
|
+
|
|
4625
|
+
Defined in:
|
|
4626
|
+
[epub/index.ts:98](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L98)
|
|
4627
|
+
|
|
4628
|
+
A valid XML node. May be either an element or a text node.
|
|
4629
|
+
|
|
4630
|
+
---
|
|
4631
|
+
|
|
4632
|
+
## XmlTextNode
|
|
4633
|
+
|
|
4634
|
+
> **XmlTextNode** = `object`
|
|
4635
|
+
|
|
4636
|
+
Defined in:
|
|
4637
|
+
[epub/index.ts:95](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L95)
|
|
4638
|
+
|
|
4639
|
+
A text node in an XML document
|
|
4640
|
+
|
|
4641
|
+
### Properties
|
|
4642
|
+
|
|
4643
|
+
#### #text
|
|
4644
|
+
|
|
4645
|
+
> **#text**: `string`
|
|
4646
|
+
|
|
4647
|
+
Defined in:
|
|
4648
|
+
[epub/index.ts:95](https://gitlab.com/storyteller-platform/storyteller/-/blob/main/epub/index.ts#L95)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var epubcheck_exports = {};
|
|
20
|
+
__export(epubcheck_exports, {
|
|
21
|
+
epubcheck: () => epubcheck
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(epubcheck_exports);
|
|
24
|
+
var import_node_child_process = require("node:child_process");
|
|
25
|
+
var import_node_crypto = require("node:crypto");
|
|
26
|
+
var import_promises = require("node:fs/promises");
|
|
27
|
+
var import_node_os = require("node:os");
|
|
28
|
+
var import_node_path = require("node:path");
|
|
29
|
+
var import_node_url = require("node:url");
|
|
30
|
+
var import_node_util = require("node:util");
|
|
31
|
+
const import_meta = {};
|
|
32
|
+
const here = (0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
33
|
+
const JAR = (0, import_node_path.join)(here, "vendors", "epubcheck-5.3.0", "epubcheck.jar");
|
|
34
|
+
async function epubcheck(epubFile) {
|
|
35
|
+
const output = (0, import_node_path.join)((0, import_node_os.tmpdir)(), `epubcheck-${(0, import_node_crypto.randomUUID)()}.json`);
|
|
36
|
+
const execFilePromise = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
37
|
+
try {
|
|
38
|
+
await execFilePromise("java", [
|
|
39
|
+
"-jar",
|
|
40
|
+
JAR,
|
|
41
|
+
"--json",
|
|
42
|
+
output,
|
|
43
|
+
epubFile
|
|
44
|
+
]).catch((error) => {
|
|
45
|
+
if (error instanceof Error && error.message.includes("Check finished with errors")) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
throw error;
|
|
49
|
+
});
|
|
50
|
+
const json = await (0, import_promises.readFile)(output, "utf8");
|
|
51
|
+
return JSON.parse(json);
|
|
52
|
+
} finally {
|
|
53
|
+
await (0, import_promises.unlink)(output).catch(() => {
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
epubcheck
|
|
60
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface Location {
|
|
2
|
+
url: {
|
|
3
|
+
hierachical: boolean;
|
|
4
|
+
opaque: boolean;
|
|
5
|
+
};
|
|
6
|
+
path: string;
|
|
7
|
+
line: number;
|
|
8
|
+
column: number;
|
|
9
|
+
context: string | null;
|
|
10
|
+
}
|
|
11
|
+
interface Message {
|
|
12
|
+
ID: string;
|
|
13
|
+
severity: "FATAL" | "ERROR" | "WARNING" | "INFO" | "USAGE";
|
|
14
|
+
message: string;
|
|
15
|
+
additionalLocations: number;
|
|
16
|
+
locations: Location[];
|
|
17
|
+
}
|
|
18
|
+
interface Report {
|
|
19
|
+
messages: Message[];
|
|
20
|
+
}
|
|
21
|
+
declare function epubcheck(epubFile: string): Promise<Report>;
|
|
22
|
+
|
|
23
|
+
export { type Location, type Message, type Report, epubcheck };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface Location {
|
|
2
|
+
url: {
|
|
3
|
+
hierachical: boolean;
|
|
4
|
+
opaque: boolean;
|
|
5
|
+
};
|
|
6
|
+
path: string;
|
|
7
|
+
line: number;
|
|
8
|
+
column: number;
|
|
9
|
+
context: string | null;
|
|
10
|
+
}
|
|
11
|
+
interface Message {
|
|
12
|
+
ID: string;
|
|
13
|
+
severity: "FATAL" | "ERROR" | "WARNING" | "INFO" | "USAGE";
|
|
14
|
+
message: string;
|
|
15
|
+
additionalLocations: number;
|
|
16
|
+
locations: Location[];
|
|
17
|
+
}
|
|
18
|
+
interface Report {
|
|
19
|
+
messages: Message[];
|
|
20
|
+
}
|
|
21
|
+
declare function epubcheck(epubFile: string): Promise<Report>;
|
|
22
|
+
|
|
23
|
+
export { type Location, type Message, type Report, epubcheck };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import "./chunk-BIEQXUOY.js";
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { readFile, unlink } from "node:fs/promises";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { promisify } from "node:util";
|
|
9
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const JAR = join(here, "vendors", "epubcheck-5.3.0", "epubcheck.jar");
|
|
11
|
+
async function epubcheck(epubFile) {
|
|
12
|
+
const output = join(tmpdir(), `epubcheck-${randomUUID()}.json`);
|
|
13
|
+
const execFilePromise = promisify(execFile);
|
|
14
|
+
try {
|
|
15
|
+
await execFilePromise("java", [
|
|
16
|
+
"-jar",
|
|
17
|
+
JAR,
|
|
18
|
+
"--json",
|
|
19
|
+
output,
|
|
20
|
+
epubFile
|
|
21
|
+
]).catch((error) => {
|
|
22
|
+
if (error instanceof Error && error.message.includes("Check finished with errors")) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
throw error;
|
|
26
|
+
});
|
|
27
|
+
const json = await readFile(output, "utf8");
|
|
28
|
+
return JSON.parse(json);
|
|
29
|
+
} finally {
|
|
30
|
+
await unlink(output).catch(() => {
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
epubcheck
|
|
36
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1289,7 +1289,14 @@ ${JSON.stringify(element, null, 2)}`
|
|
|
1289
1289
|
const creatorEntries = metadata.filter(
|
|
1290
1290
|
(entry) => entry.type === `dc:${type}`
|
|
1291
1291
|
);
|
|
1292
|
-
const creators =
|
|
1292
|
+
const creators = [];
|
|
1293
|
+
const creatorsById = /* @__PURE__ */ new Map();
|
|
1294
|
+
for (const entry of creatorEntries) {
|
|
1295
|
+
if (!entry.value) continue;
|
|
1296
|
+
const creator = { name: entry.value };
|
|
1297
|
+
creators.push(creator);
|
|
1298
|
+
if (entry.id) creatorsById.set(entry.id, creator);
|
|
1299
|
+
}
|
|
1293
1300
|
metadata.forEach((entry) => {
|
|
1294
1301
|
if (entry.type !== "meta" || entry.properties["property"] !== "file-as" && entry.properties["property"] !== "role" && entry.properties["property"] !== "alternate-script" || !entry.value) {
|
|
1295
1302
|
return;
|
|
@@ -1297,9 +1304,8 @@ ${JSON.stringify(element, null, 2)}`
|
|
|
1297
1304
|
const creatorIdref = entry.properties["refines"];
|
|
1298
1305
|
if (!creatorIdref) return;
|
|
1299
1306
|
const creatorId = creatorIdref.slice(1);
|
|
1300
|
-
const
|
|
1301
|
-
if (
|
|
1302
|
-
const creator = creators[index];
|
|
1307
|
+
const creator = creatorsById.get(creatorId);
|
|
1308
|
+
if (!creator) return;
|
|
1303
1309
|
if (entry.properties["alternate-script"]) {
|
|
1304
1310
|
if (!entry.properties["xml:lang"]) return;
|
|
1305
1311
|
creator.alternateScripts ??= [];
|
package/dist/index.js
CHANGED
|
@@ -1257,7 +1257,14 @@ ${JSON.stringify(element, null, 2)}`
|
|
|
1257
1257
|
const creatorEntries = metadata.filter(
|
|
1258
1258
|
(entry) => entry.type === `dc:${type}`
|
|
1259
1259
|
);
|
|
1260
|
-
const creators =
|
|
1260
|
+
const creators = [];
|
|
1261
|
+
const creatorsById = /* @__PURE__ */ new Map();
|
|
1262
|
+
for (const entry of creatorEntries) {
|
|
1263
|
+
if (!entry.value) continue;
|
|
1264
|
+
const creator = { name: entry.value };
|
|
1265
|
+
creators.push(creator);
|
|
1266
|
+
if (entry.id) creatorsById.set(entry.id, creator);
|
|
1267
|
+
}
|
|
1261
1268
|
metadata.forEach((entry) => {
|
|
1262
1269
|
if (entry.type !== "meta" || entry.properties["property"] !== "file-as" && entry.properties["property"] !== "role" && entry.properties["property"] !== "alternate-script" || !entry.value) {
|
|
1263
1270
|
return;
|
|
@@ -1265,9 +1272,8 @@ ${JSON.stringify(element, null, 2)}`
|
|
|
1265
1272
|
const creatorIdref = entry.properties["refines"];
|
|
1266
1273
|
if (!creatorIdref) return;
|
|
1267
1274
|
const creatorId = creatorIdref.slice(1);
|
|
1268
|
-
const
|
|
1269
|
-
if (
|
|
1270
|
-
const creator = creators[index];
|
|
1275
|
+
const creator = creatorsById.get(creatorId);
|
|
1276
|
+
if (!creator) return;
|
|
1271
1277
|
if (entry.properties["alternate-script"]) {
|
|
1272
1278
|
if (!entry.properties["xml:lang"]) return;
|
|
1273
1279
|
creator.alternateScripts ??= [];
|
package/dist/upgrade.d.cts
CHANGED
|
@@ -366,7 +366,7 @@ declare class Epub {
|
|
|
366
366
|
*/
|
|
367
367
|
findMetadataItem(predicate: (entry: MetadataEntry) => boolean): Promise<{
|
|
368
368
|
id: string | undefined;
|
|
369
|
-
type: `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}
|
|
369
|
+
type: `?${string}` | `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}`;
|
|
370
370
|
properties: {
|
|
371
371
|
[k: string]: string;
|
|
372
372
|
};
|
|
@@ -378,7 +378,7 @@ declare class Epub {
|
|
|
378
378
|
*/
|
|
379
379
|
findAllMetadataItems(predicate: (entry: MetadataEntry) => boolean): Promise<{
|
|
380
380
|
id: string | undefined;
|
|
381
|
-
type: `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}
|
|
381
|
+
type: `?${string}` | `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}`;
|
|
382
382
|
properties: {
|
|
383
383
|
[k: string]: string;
|
|
384
384
|
};
|
package/dist/upgrade.d.ts
CHANGED
|
@@ -366,7 +366,7 @@ declare class Epub {
|
|
|
366
366
|
*/
|
|
367
367
|
findMetadataItem(predicate: (entry: MetadataEntry) => boolean): Promise<{
|
|
368
368
|
id: string | undefined;
|
|
369
|
-
type: `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}
|
|
369
|
+
type: `?${string}` | `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}`;
|
|
370
370
|
properties: {
|
|
371
371
|
[k: string]: string;
|
|
372
372
|
};
|
|
@@ -378,7 +378,7 @@ declare class Epub {
|
|
|
378
378
|
*/
|
|
379
379
|
findAllMetadataItems(predicate: (entry: MetadataEntry) => boolean): Promise<{
|
|
380
380
|
id: string | undefined;
|
|
381
|
-
type: `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}
|
|
381
|
+
type: `?${string}` | `a${string}` | `b${string}` | `c${string}` | `d${string}` | `e${string}` | `f${string}` | `g${string}` | `h${string}` | `i${string}` | `j${string}` | `k${string}` | `l${string}` | `m${string}` | `n${string}` | `o${string}` | `p${string}` | `q${string}` | `r${string}` | `s${string}` | `t${string}` | `u${string}` | `v${string}` | `w${string}` | `x${string}` | `y${string}` | `z${string}` | `A${string}` | `B${string}` | `C${string}` | `D${string}` | `E${string}` | `F${string}` | `G${string}` | `H${string}` | `I${string}` | `J${string}` | `K${string}` | `L${string}` | `M${string}` | `N${string}` | `O${string}` | `P${string}` | `Q${string}` | `R${string}` | `S${string}` | `T${string}` | `U${string}` | `V${string}` | `W${string}` | `X${string}` | `Y${string}` | `Z${string}`;
|
|
382
382
|
properties: {
|
|
383
383
|
[k: string]: string;
|
|
384
384
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyteller-platform/epub",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
"readme:toc": "markdown-toc --maxdepth=5 --append='\n- [API Docs](#api-docs)' --bullets='-' -i readme-stub.md",
|
|
24
24
|
"readme:api": "typedoc",
|
|
25
25
|
"readme": "yarn readme:api && yarn readme:toc && cat readme-stub.md > README.md && tail -n +2 gen/README.md >> README.md",
|
|
26
|
-
"
|
|
27
|
-
"test
|
|
26
|
+
"install-epubcheck": "tsx scripts/install-epubcheck.ts",
|
|
27
|
+
"test": "yarn install-epubcheck && tsx -C @storyteller --test *.test.ts",
|
|
28
|
+
"test:watch": "yarn install-epubcheck && tsx -C @storyteller --test --watch *.test.ts",
|
|
28
29
|
"prepack": "yarn build"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
@@ -35,7 +36,6 @@
|
|
|
35
36
|
"@types/node": "^24.0.0",
|
|
36
37
|
"@types/yauzl-promise": "^4",
|
|
37
38
|
"@types/yazl": "^3",
|
|
38
|
-
"epubchecker": "^5.2.1",
|
|
39
39
|
"eslint": "^8.0.0",
|
|
40
40
|
"markdown-toc": "^1.2.0",
|
|
41
41
|
"remark-toc": "^9.0.0",
|