@canopycanopycanopy/b-ber-templates 3.0.8-nav.0 → 3.0.8-next.96
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 +21 -5
- package/dist/Guide-DtZekBN_.d.ts +19 -0
- package/dist/Guide-DtZekBN_.d.ts.map +1 -0
- package/dist/Manifest-xzjWoNoJ.d.ts +10 -0
- package/dist/Manifest-xzjWoNoJ.d.ts.map +1 -0
- package/dist/Metadata-Cv6mesgj.d.ts +11 -0
- package/dist/Metadata-Cv6mesgj.d.ts.map +1 -0
- package/dist/Ncx/index.d.ts +13 -0
- package/dist/Ncx/index.d.ts.map +1 -0
- package/dist/Ncx/index.js +83 -0
- package/dist/Opf/Guide.d.ts +2 -0
- package/dist/Opf/Guide.js +36 -0
- package/dist/Opf/Manifest.d.ts +2 -0
- package/dist/Opf/Manifest.js +26 -0
- package/dist/Opf/Metadata.d.ts +2 -0
- package/dist/Opf/Metadata.js +55 -0
- package/dist/Opf/Pkg.d.ts +2 -0
- package/dist/Opf/Pkg.js +26 -0
- package/dist/Opf/Spine.d.ts +2 -0
- package/dist/Opf/Spine.js +43 -0
- package/dist/Pkg-BAwlpc2n.d.ts +9 -0
- package/dist/Pkg-BAwlpc2n.d.ts.map +1 -0
- package/dist/Project/index.d.ts +44 -0
- package/dist/Project/index.d.ts.map +1 -0
- package/dist/Project/index.js +2 -0
- package/dist/Project-D0Q1l_Vp.js +430 -0
- package/dist/Spine-B4MQP83_.d.ts +19 -0
- package/dist/Spine-B4MQP83_.d.ts.map +1 -0
- package/dist/Toc/index.d.ts +10 -0
- package/dist/Toc/index.d.ts.map +1 -0
- package/dist/Toc/index.js +31 -0
- package/dist/Xhtml/index.d.ts +23 -0
- package/dist/Xhtml/index.d.ts.map +1 -0
- package/dist/Xhtml/index.js +59 -0
- package/dist/Xml/index.d.ts +7 -0
- package/dist/Xml/index.d.ts.map +1 -0
- package/dist/Xml/index.js +17 -0
- package/dist/chunk-DakpK96I.js +43 -0
- package/dist/figures/index.d.ts +4 -0
- package/dist/figures/index.d.ts.map +1 -0
- package/dist/figures/index.js +342 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/package.json +28 -36
- package/Ncx/index.js +0 -97
- package/Opf/Guide.js +0 -48
- package/Opf/Manifest.js +0 -37
- package/Opf/Metadata.js +0 -85
- package/Opf/Pkg.js +0 -31
- package/Opf/Spine.js +0 -70
- package/Opf/index.js +0 -42
- package/Ops/index.js +0 -14
- package/Project/README.md.js +0 -6
- package/Project/application.js.js +0 -106
- package/Project/gitignore.js +0 -17
- package/Project/index.js +0 -95
- package/Project/metadata.yml.js +0 -125
- package/Project/project-name-chapter-01.md.js +0 -15
- package/Project/project-name-colophon.md.js +0 -32
- package/Project/project-name-title-page.md.js +0 -13
- package/Project/toc.yml.js +0 -16
- package/Toc/index.js +0 -41
- package/Xhtml/index.js +0 -87
- package/Xml/index.js +0 -23
- package/figures/epub.js +0 -52
- package/figures/helpers.js +0 -213
- package/figures/index.js +0 -50
- package/figures/mobi.js +0 -57
- package/figures/reader.js +0 -55
- package/figures/web.js +0 -51
- package/index.js +0 -56
package/README.md
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# b-ber-templates
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Provides JavaScript template classes used by the b-ber build pipeline to generate EPUB structural files and figure markup. Each class exposes static methods that return either XML/HTML strings or Vinyl file objects containing `{% body %}` placeholders that the build pipeline fills in. Templates cover EPUB 3 structural formats (OPF package, NCX navigation, XHTML pages, container XML) as well as project scaffolding files and per-build-target figure markup.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Contents
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
| Path | Purpose |
|
|
8
|
+
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
9
|
+
| `src/Ncx/` | EPUB 2 NCX navigation document (head, docTitle, navMap, navPoints) |
|
|
10
|
+
| `src/Opf/` | EPUB 3 OPF package: `Pkg`, `Metadata`, `Manifest`, `Spine`, `Guide` |
|
|
11
|
+
| `src/Ops/` | Returns the `application/epub+zip` MIME type string |
|
|
12
|
+
| `src/Toc/` | EPUB 3 `nav` TOC element with nested `<ol>` item rendering |
|
|
13
|
+
| `src/Xhtml/` | XHTML page template: head, body, stylesheet/script link tags, cover SVG, LOI section |
|
|
14
|
+
| `src/Xml/` | EPUB `META-INF/container.xml` and mimetype string |
|
|
15
|
+
| `src/Project/` | Scaffolding for new projects: directory layout, `toc.yml`, `metadata.yml`, starter Markdown files, `config.yml`, `.gitignore`, `README.md` |
|
|
16
|
+
| `src/figures/` | Per-build-target figure markup: `epub`, `mobi`, `reader`, `web`; dispatches by media type (image orientation, audio, video, iframe, vimeo) |
|
|
17
|
+
| `Ncx/`, `Opf/`, `Ops/`, `Toc/`, `Xhtml/`, `Xml/`, `figures/`, `Project/` | Built output of `src/` (generated by `npm run build`) |
|
|
18
|
+
|
|
19
|
+
## Dev
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm test # runs jest; snapshot tests for Toc, Xhtml, Xml, Project, and figure variants
|
|
23
|
+
npm run build # transpiles src/ to output directories via Babel
|
|
24
|
+
npm run watch # watch mode for development
|
|
9
25
|
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import File from "vinyl";
|
|
2
|
+
|
|
3
|
+
//#region src/Opf/Guide.d.ts
|
|
4
|
+
declare class Guide {
|
|
5
|
+
static body(): File.BufferFile;
|
|
6
|
+
static item({
|
|
7
|
+
type,
|
|
8
|
+
title,
|
|
9
|
+
href
|
|
10
|
+
}: {
|
|
11
|
+
type: any;
|
|
12
|
+
title: any;
|
|
13
|
+
href: any;
|
|
14
|
+
}): string;
|
|
15
|
+
static items(data: any): any;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Guide as t };
|
|
19
|
+
//# sourceMappingURL=Guide-DtZekBN_.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Guide-DtZekBN_.d.ts","names":[],"sources":["../src/Opf/Guide.ts"],"mappings":";;;cAKM,KAAA;EAAA,OACG,IAAA,IAAI,IAAA,CAAA,UAAA;EAAA,OAOJ,IAAA;IAAO,IAAA;IAAM,KAAA;IAAO;EAAA;;;;;SAIpB,KAAA,CAAM,IAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Manifest-xzjWoNoJ.d.ts","names":[],"sources":["../src/Opf/Manifest.ts"],"mappings":";;;cAcM,QAAA;EAAA,OACG,IAAA,IAAI,IAAA,CAAA,UAAA;EAAA,OAOJ,IAAA,CAAK,IAAA;AAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import File from "vinyl";
|
|
2
|
+
|
|
3
|
+
//#region src/Opf/Metadata.d.ts
|
|
4
|
+
declare class Metadata {
|
|
5
|
+
static uid(): string;
|
|
6
|
+
static body(): File.BufferFile;
|
|
7
|
+
static meta(data: any): string;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { Metadata as t };
|
|
11
|
+
//# sourceMappingURL=Metadata-Cv6mesgj.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Metadata-Cv6mesgj.d.ts","names":[],"sources":["../src/Opf/Metadata.ts"],"mappings":";;;cAWM,QAAA;EAAA,OACG,GAAA;EAAA,OAIA,IAAA,IAAI,IAAA,CAAA,UAAA;EAAA,OAOJ,IAAA,CAAK,IAAA;AAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import File from "vinyl";
|
|
2
|
+
|
|
3
|
+
//#region src/Ncx/index.d.ts
|
|
4
|
+
declare class Ncx {
|
|
5
|
+
static head(): string;
|
|
6
|
+
static title(): string;
|
|
7
|
+
static author(): string;
|
|
8
|
+
static document(): File.BufferFile;
|
|
9
|
+
static navPoint(data: any): string;
|
|
10
|
+
static navPoints(data: any): any;
|
|
11
|
+
}
|
|
12
|
+
export = Ncx;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/Ncx/index.ts"],"mappings":";;;cAOM,GAAA;EAAA,OACG,IAAA;EAAA,OAaA,KAAA;EAAA,OAUA,MAAA;EAAA,OAUA,QAAA,IAAQ,IAAA,CAAA,UAAA;EAAA,OAgBR,QAAA,CAAS,IAAA;EAAA,OAST,SAAA,CAAU,IAAA;AAAA;AAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const require_chunk = require("../chunk-DakpK96I.js");
|
|
2
|
+
let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
|
|
3
|
+
let lodash_find_js = require("lodash/find.js");
|
|
4
|
+
lodash_find_js = require_chunk.__toESM(lodash_find_js);
|
|
5
|
+
let lodash_has_js = require("lodash/has.js");
|
|
6
|
+
lodash_has_js = require_chunk.__toESM(lodash_has_js);
|
|
7
|
+
let vinyl = require("vinyl");
|
|
8
|
+
vinyl = require_chunk.__toESM(vinyl);
|
|
9
|
+
//#region src/Ncx/index.ts
|
|
10
|
+
const { getTitle } = _canopycanopycanopy_b_ber_lib.utils;
|
|
11
|
+
var Ncx = class Ncx {
|
|
12
|
+
static head() {
|
|
13
|
+
const entry = (0, lodash_find_js.default)(_canopycanopycanopy_b_ber_lib.State.metadata.json(), { term: "identifier" });
|
|
14
|
+
return `
|
|
15
|
+
<head>
|
|
16
|
+
<meta name="dtb:uid" content="${entry && (0, lodash_has_js.default)(entry, "value") ? entry.value : ""}"/>
|
|
17
|
+
<meta name="dtb:depth" content="1"/>
|
|
18
|
+
<meta name="dtb:totalPageCount" content="1"/>
|
|
19
|
+
<meta name="dtb:maxPageNumber" content="1"/>
|
|
20
|
+
</head>
|
|
21
|
+
`;
|
|
22
|
+
}
|
|
23
|
+
static title() {
|
|
24
|
+
const entry = (0, lodash_find_js.default)(_canopycanopycanopy_b_ber_lib.State.metadata.json(), { term: "title" });
|
|
25
|
+
const title = entry && (0, lodash_has_js.default)(entry, "value") ? entry.value : "";
|
|
26
|
+
return `
|
|
27
|
+
<docTitle>
|
|
28
|
+
<text>${_canopycanopycanopy_b_ber_lib.Html.escape(title)}</text>
|
|
29
|
+
</docTitle>
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
static author() {
|
|
33
|
+
const entry = (0, lodash_find_js.default)(_canopycanopycanopy_b_ber_lib.State.metadata.json(), { term: "creator" });
|
|
34
|
+
const creator = entry && (0, lodash_has_js.default)(entry, "value") ? entry.value : "";
|
|
35
|
+
return `
|
|
36
|
+
<docAuthor>
|
|
37
|
+
<text>${_canopycanopycanopy_b_ber_lib.Html.escape(creator)}</text>
|
|
38
|
+
</docAuthor>
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
static document() {
|
|
42
|
+
return new vinyl.default({
|
|
43
|
+
path: "ncx.document.tmpl",
|
|
44
|
+
contents: Buffer.from(`<?xml version="1.0" encoding="UTF-8"?>
|
|
45
|
+
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
|
|
46
|
+
${Ncx.head()}
|
|
47
|
+
${Ncx.title()}
|
|
48
|
+
${Ncx.author()}
|
|
49
|
+
<navMap>
|
|
50
|
+
{% body %}
|
|
51
|
+
</navMap>
|
|
52
|
+
</ncx>
|
|
53
|
+
`)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
static navPoint(data) {
|
|
57
|
+
return `
|
|
58
|
+
<navLabel>
|
|
59
|
+
<text>${_canopycanopycanopy_b_ber_lib.Html.escape(getTitle(data))}</text>
|
|
60
|
+
</navLabel>
|
|
61
|
+
<content src="${data.relativePath}.xhtml" />
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
static navPoints(data) {
|
|
65
|
+
let index = 0;
|
|
66
|
+
function render(nodes) {
|
|
67
|
+
if (!nodes || !nodes.length) return "";
|
|
68
|
+
return nodes.reduce((acc, curr) => {
|
|
69
|
+
if (curr.in_toc === false) return acc;
|
|
70
|
+
index += 1;
|
|
71
|
+
return acc.concat(`
|
|
72
|
+
<navPoint id="navPoint-${index}" playOrder="${index}">
|
|
73
|
+
${Ncx.navPoint(curr)}
|
|
74
|
+
${render(curr.nodes)}
|
|
75
|
+
</navPoint>
|
|
76
|
+
`);
|
|
77
|
+
}, "");
|
|
78
|
+
}
|
|
79
|
+
return render(data);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
module.exports = Ncx;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const require_chunk = require("../chunk-DakpK96I.js");
|
|
2
|
+
let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
|
|
3
|
+
let vinyl = require("vinyl");
|
|
4
|
+
vinyl = require_chunk.__toESM(vinyl);
|
|
5
|
+
let _canopycanopycanopy_b_ber_logger = require("@canopycanopycanopy/b-ber-logger");
|
|
6
|
+
_canopycanopycanopy_b_ber_logger = require_chunk.__toESM(_canopycanopycanopy_b_ber_logger);
|
|
7
|
+
let path = require("path");
|
|
8
|
+
path = require_chunk.__toESM(path);
|
|
9
|
+
//#region src/Opf/Guide.ts
|
|
10
|
+
var Guide = class Guide {
|
|
11
|
+
static body() {
|
|
12
|
+
return new vinyl.default({
|
|
13
|
+
path: "guide.body.tmpl",
|
|
14
|
+
contents: Buffer.from("<guide>{% body %}</guide>")
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
static item({ type, title, href }) {
|
|
18
|
+
return `<reference type="${type}" title="${title}" href="${href}"/>`;
|
|
19
|
+
}
|
|
20
|
+
static items(data) {
|
|
21
|
+
return data.reduce((acc, curr) => {
|
|
22
|
+
if (!curr.type) return acc;
|
|
23
|
+
_canopycanopycanopy_b_ber_logger.default.info(`guide adding landmark [${curr.fileName}] as [${curr.type}]`);
|
|
24
|
+
const { type } = curr;
|
|
25
|
+
const title = _canopycanopycanopy_b_ber_lib.Html.escape(curr.title);
|
|
26
|
+
const href = `text/${encodeURI(path.default.basename(curr.fileName, ".xhtml"))}.xhtml`;
|
|
27
|
+
return acc.concat(Guide.item({
|
|
28
|
+
type,
|
|
29
|
+
title,
|
|
30
|
+
href
|
|
31
|
+
}));
|
|
32
|
+
}, "");
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
module.exports = Guide;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_chunk = require("../chunk-DakpK96I.js");
|
|
2
|
+
let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
|
|
3
|
+
let vinyl = require("vinyl");
|
|
4
|
+
vinyl = require_chunk.__toESM(vinyl);
|
|
5
|
+
let mime_types = require("mime-types");
|
|
6
|
+
mime_types = require_chunk.__toESM(mime_types);
|
|
7
|
+
//#region src/Opf/Manifest.ts
|
|
8
|
+
const { fileId } = _canopycanopycanopy_b_ber_lib.utils;
|
|
9
|
+
const getProps = (file) => {
|
|
10
|
+
const props = _canopycanopycanopy_b_ber_lib.ManifestItemProperties.testHTML(file);
|
|
11
|
+
return props && props.length ? `properties="${props.join(" ")}"` : "";
|
|
12
|
+
};
|
|
13
|
+
const getMediaType = ({ remote, absolutePath }) => remote ? "application/octet-stream" : mime_types.default.lookup(absolutePath);
|
|
14
|
+
var Manifest = class {
|
|
15
|
+
static body() {
|
|
16
|
+
return new vinyl.default({
|
|
17
|
+
path: "manifest.body.tmpl",
|
|
18
|
+
contents: Buffer.from("<manifest>{% body %}</manifest>")
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
static item(file) {
|
|
22
|
+
return `<item id="${fileId(file.name)}" href="${encodeURI(file.opsPath)}" media-type="${getMediaType(file)}" ${getProps(file)}/>`;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
module.exports = Manifest;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const require_chunk = require("../chunk-DakpK96I.js");
|
|
2
|
+
let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
|
|
3
|
+
let vinyl = require("vinyl");
|
|
4
|
+
vinyl = require_chunk.__toESM(vinyl);
|
|
5
|
+
let _canopycanopycanopy_b_ber_logger = require("@canopycanopycanopy/b-ber-logger");
|
|
6
|
+
_canopycanopycanopy_b_ber_logger = require_chunk.__toESM(_canopycanopycanopy_b_ber_logger);
|
|
7
|
+
let crypto = require("crypto");
|
|
8
|
+
crypto = require_chunk.__toESM(crypto);
|
|
9
|
+
//#region src/Opf/Metadata.ts
|
|
10
|
+
const { fileId } = _canopycanopycanopy_b_ber_lib.utils;
|
|
11
|
+
var Metadata = class Metadata {
|
|
12
|
+
static uid() {
|
|
13
|
+
return `_${crypto.default.randomBytes(8).toString("hex")}`;
|
|
14
|
+
}
|
|
15
|
+
static body() {
|
|
16
|
+
return new vinyl.default({
|
|
17
|
+
path: "metadata.body.tmpl",
|
|
18
|
+
contents: Buffer.from("<metadata>{% body %}</metadata>")
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
static meta(data) {
|
|
22
|
+
const { term, element } = _canopycanopycanopy_b_ber_lib.ManifestItemProperties.testMeta(data);
|
|
23
|
+
const itemid = element && data.term === "identifier" ? "uuid" : Metadata.uid();
|
|
24
|
+
let res = [];
|
|
25
|
+
if (term) res.push(`<meta property="dcterms:${data.term}">${_canopycanopycanopy_b_ber_lib.Html.escape(data.value)}</meta>`);
|
|
26
|
+
if (element) res.push(`<dc:${data.term} id="${itemid}">${_canopycanopycanopy_b_ber_lib.Html.escape(data.value)}</dc:${data.term}>`);
|
|
27
|
+
if (data.refines) {
|
|
28
|
+
const refines = data.refines.reduce((acc, curr) => acc.concat(Object.entries(curr).map(([key, value]) => `<meta refines="#${itemid}" property="${key}">${_canopycanopycanopy_b_ber_lib.Html.escape(value)}</meta>`)), []);
|
|
29
|
+
res = res.concat(refines);
|
|
30
|
+
}
|
|
31
|
+
if (term && element && data.term_property && data.term_property_value) {
|
|
32
|
+
let message = "\n";
|
|
33
|
+
message += "You're using an outdated syntax in `metadata.yml` which will be removed in future versions.";
|
|
34
|
+
message += "\nUpdate the entries in the `metadata.yml` file to use the new `refines` syntax:";
|
|
35
|
+
message += `
|
|
36
|
+
|
|
37
|
+
- - term: ${data.term}
|
|
38
|
+
- value: ${data.value}
|
|
39
|
+
- term_property: ${data.term_property}
|
|
40
|
+
- term_property_value: ${data.term_property_value}
|
|
41
|
+
+ - term: ${data.term}
|
|
42
|
+
+ value: ${data.value}
|
|
43
|
+
+ - refines:
|
|
44
|
+
+ - ${data.term_property}: ${data.term_property_value}
|
|
45
|
+
`;
|
|
46
|
+
_canopycanopycanopy_b_ber_logger.default.notice(message);
|
|
47
|
+
res.push(`<meta refines="#${itemid}" property="${data.term_property}">${_canopycanopycanopy_b_ber_lib.Html.escape(data.term_property_value)}</meta>`);
|
|
48
|
+
}
|
|
49
|
+
if (!term && !element) if (data.term !== "cover") res.push(`<meta name="${data.term}" content="${_canopycanopycanopy_b_ber_lib.Html.escape(data.value)}"/>`);
|
|
50
|
+
else res.push(`<meta name="${data.term}" content="${fileId(_canopycanopycanopy_b_ber_lib.Html.escape(data.value))}"/>`);
|
|
51
|
+
return res.join("");
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
module.exports = Metadata;
|
package/dist/Opf/Pkg.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_chunk = require("../chunk-DakpK96I.js");
|
|
2
|
+
let vinyl = require("vinyl");
|
|
3
|
+
vinyl = require_chunk.__toESM(vinyl);
|
|
4
|
+
//#region src/Opf/Pkg.ts
|
|
5
|
+
var Pkg = class {
|
|
6
|
+
static body() {
|
|
7
|
+
return new vinyl.default({
|
|
8
|
+
path: "pkg.body.tmpl",
|
|
9
|
+
contents: Buffer.from(`<?xml version="1.0" encoding="UTF-8"?>
|
|
10
|
+
<package
|
|
11
|
+
version="3.0"
|
|
12
|
+
xml:lang="en"
|
|
13
|
+
unique-identifier="uuid"
|
|
14
|
+
xmlns="http://www.idpf.org/2007/opf"
|
|
15
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
16
|
+
xmlns:dcterms="http://purl.org/dc/terms/"
|
|
17
|
+
prefix="ibooks: http://vocabulary.itunes.apple.com/rdf/ibooks/vocabulary-extensions-1.0/"
|
|
18
|
+
>
|
|
19
|
+
{% body %}
|
|
20
|
+
</package>
|
|
21
|
+
`)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
module.exports = Pkg;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const require_chunk = require("../chunk-DakpK96I.js");
|
|
2
|
+
let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
|
|
3
|
+
let vinyl = require("vinyl");
|
|
4
|
+
vinyl = require_chunk.__toESM(vinyl);
|
|
5
|
+
let _canopycanopycanopy_b_ber_logger = require("@canopycanopycanopy/b-ber-logger");
|
|
6
|
+
_canopycanopycanopy_b_ber_logger = require_chunk.__toESM(_canopycanopycanopy_b_ber_logger);
|
|
7
|
+
let path = require("path");
|
|
8
|
+
path = require_chunk.__toESM(path);
|
|
9
|
+
//#region src/Opf/Spine.ts
|
|
10
|
+
const { fileId } = _canopycanopycanopy_b_ber_lib.utils;
|
|
11
|
+
var Spine = class Spine {
|
|
12
|
+
static body() {
|
|
13
|
+
return new vinyl.default({
|
|
14
|
+
path: "spine.body.tmpl",
|
|
15
|
+
contents: Buffer.from("<spine toc=\"_toc_ncx\">{% body %}</spine>")
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
static item({ fileName, extension, linear }) {
|
|
19
|
+
return `<itemref idref="${fileId(path.default.basename(fileName, extension))}_xhtml" linear="${linear ? "yes" : "no"}"/>`;
|
|
20
|
+
}
|
|
21
|
+
static items(data) {
|
|
22
|
+
return data.reduce((acc, curr) => {
|
|
23
|
+
const { fileName } = curr;
|
|
24
|
+
if (curr.linear === false) {
|
|
25
|
+
if (_canopycanopycanopy_b_ber_lib.State.build === "mobi") {
|
|
26
|
+
_canopycanopycanopy_b_ber_logger.default.info(`opf templates/spine omitting non-linear asset [${fileName}] for mobi build`);
|
|
27
|
+
return acc;
|
|
28
|
+
}
|
|
29
|
+
_canopycanopycanopy_b_ber_logger.default.info(`opf templates/spine writing non-linear asset [${fileName}]`);
|
|
30
|
+
}
|
|
31
|
+
if (fileName === "figures-titlepage") {
|
|
32
|
+
_canopycanopycanopy_b_ber_logger.default.info("opf templates/spine writing [loi]");
|
|
33
|
+
if (_canopycanopycanopy_b_ber_lib.State.loi.length) return acc.concat(_canopycanopycanopy_b_ber_lib.State.loi.reduce((acc2, curr2) => acc2.concat(Spine.item({
|
|
34
|
+
...curr2,
|
|
35
|
+
linear: true
|
|
36
|
+
})), Spine.item(curr)));
|
|
37
|
+
}
|
|
38
|
+
return acc.concat(Spine.item(curr));
|
|
39
|
+
}, "");
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
module.exports = Spine;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pkg-BAwlpc2n.d.ts","names":[],"sources":["../src/Opf/Pkg.ts"],"mappings":";;;cAEM,GAAA;EAAA,OACG,IAAA,IAAI,IAAA,CAAA,UAAA;AAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//#region src/Project/index.d.ts
|
|
2
|
+
declare class Project {
|
|
3
|
+
static directories(src: string): string[];
|
|
4
|
+
static relativePath(src: string, ...rest: string[]): string;
|
|
5
|
+
static absolutePath(src: string, ...rest: string[]): string;
|
|
6
|
+
static configYAML(src: string, config?: Record<string, any>): {
|
|
7
|
+
relativePath: string;
|
|
8
|
+
absolutePath: string;
|
|
9
|
+
content: string;
|
|
10
|
+
};
|
|
11
|
+
static tocYAML(src: string): {
|
|
12
|
+
relativePath: string;
|
|
13
|
+
absolutePath: string;
|
|
14
|
+
content: string;
|
|
15
|
+
};
|
|
16
|
+
static metadataYAML(src: string): {
|
|
17
|
+
relativePath: string;
|
|
18
|
+
absolutePath: string;
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
static javascripts(src: string): Array<{
|
|
22
|
+
relativePath: string;
|
|
23
|
+
absolutePath: string;
|
|
24
|
+
content: string;
|
|
25
|
+
}>;
|
|
26
|
+
static markdown(src: string): Array<{
|
|
27
|
+
relativePath: string;
|
|
28
|
+
absolutePath: string;
|
|
29
|
+
content: string;
|
|
30
|
+
}>;
|
|
31
|
+
static stylesheets(): never[];
|
|
32
|
+
static readme(src: string): {
|
|
33
|
+
relativePath: string;
|
|
34
|
+
absolutePath: string;
|
|
35
|
+
content: string;
|
|
36
|
+
};
|
|
37
|
+
static gitignore(src: string): {
|
|
38
|
+
relativePath: string;
|
|
39
|
+
absolutePath: string;
|
|
40
|
+
content: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export = Project;
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/Project/index.ts"],"mappings":";cAYM,OAAA;EAAA,OACG,WAAA,CAAY,GAAA;EAAA,OAYZ,YAAA,CAAa,GAAA,aAAgB,IAAA;EAAA,OAI7B,YAAA,CAAa,GAAA,aAAgB,IAAA;EAAA,OAI7B,UAAA,CACL,GAAA,UACA,MAAA,GAAQ,MAAA;IACL,YAAA;IAAsB,YAAA;IAAsB,OAAA;EAAA;EAAA,OAQ1C,OAAA,CAAQ,GAAA;IACb,YAAA;IACA,YAAA;IACA,OAAA;EAAA;EAAA,OASK,YAAA,CAAa,GAAA;IAClB,YAAA;IACA,YAAA;IACA,OAAA;EAAA;EAAA,OAYK,WAAA,CACL,GAAA,WACC,KAAA;IAAQ,YAAA;IAAsB,YAAA;IAAsB,OAAA;EAAA;EAAA,OAkBhD,QAAA,CACL,GAAA,WACC,KAAA;IAAQ,YAAA;IAAsB,YAAA;IAAsB,OAAA;EAAA;EAAA,OA4ChD,WAAA;EAAA,OAIA,MAAA,CAAO,GAAA;IACZ,YAAA;IACA,YAAA;IACA,OAAA;EAAA;EAAA,OAYK,SAAA,CAAU,GAAA;IACf,YAAA;IACA,YAAA;IACA,OAAA;EAAA;AAAA;AAAA"}
|