@canopycanopycanopy/b-ber-templates 3.0.8-next.61 → 3.0.8-next.97

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.
Files changed (71) hide show
  1. package/dist/Guide-DtZekBN_.d.ts +19 -0
  2. package/dist/Guide-DtZekBN_.d.ts.map +1 -0
  3. package/dist/Manifest-xzjWoNoJ.d.ts +10 -0
  4. package/dist/Manifest-xzjWoNoJ.d.ts.map +1 -0
  5. package/dist/Metadata-Cv6mesgj.d.ts +11 -0
  6. package/dist/Metadata-Cv6mesgj.d.ts.map +1 -0
  7. package/dist/Ncx/index.d.ts +13 -0
  8. package/dist/Ncx/index.d.ts.map +1 -0
  9. package/dist/Ncx/index.js +83 -0
  10. package/dist/Opf/Guide.d.ts +2 -0
  11. package/dist/Opf/Guide.js +36 -0
  12. package/dist/Opf/Manifest.d.ts +2 -0
  13. package/dist/Opf/Manifest.js +26 -0
  14. package/dist/Opf/Metadata.d.ts +2 -0
  15. package/dist/Opf/Metadata.js +55 -0
  16. package/dist/Opf/Pkg.d.ts +2 -0
  17. package/dist/Opf/Pkg.js +26 -0
  18. package/dist/Opf/Spine.d.ts +2 -0
  19. package/dist/Opf/Spine.js +43 -0
  20. package/dist/Pkg-BAwlpc2n.d.ts +9 -0
  21. package/dist/Pkg-BAwlpc2n.d.ts.map +1 -0
  22. package/dist/Project/index.d.ts +44 -0
  23. package/dist/Project/index.d.ts.map +1 -0
  24. package/dist/Project/index.js +2 -0
  25. package/dist/Project-D0Q1l_Vp.js +430 -0
  26. package/dist/Spine-B4MQP83_.d.ts +19 -0
  27. package/dist/Spine-B4MQP83_.d.ts.map +1 -0
  28. package/dist/Toc/index.d.ts +10 -0
  29. package/dist/Toc/index.d.ts.map +1 -0
  30. package/dist/Toc/index.js +31 -0
  31. package/dist/Xhtml/index.d.ts +23 -0
  32. package/dist/Xhtml/index.d.ts.map +1 -0
  33. package/dist/Xhtml/index.js +59 -0
  34. package/dist/Xml/index.d.ts +7 -0
  35. package/dist/Xml/index.d.ts.map +1 -0
  36. package/dist/Xml/index.js +17 -0
  37. package/dist/chunk-DakpK96I.js +43 -0
  38. package/dist/figures/index.d.ts +4 -0
  39. package/dist/figures/index.d.ts.map +1 -0
  40. package/dist/figures/index.js +342 -0
  41. package/dist/index.d.ts +23 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +40 -0
  44. package/package.json +28 -33
  45. package/Ncx/index.js +0 -98
  46. package/Opf/Guide.js +0 -47
  47. package/Opf/Manifest.js +0 -36
  48. package/Opf/Metadata.js +0 -84
  49. package/Opf/Pkg.js +0 -30
  50. package/Opf/Spine.js +0 -69
  51. package/Opf/index.js +0 -42
  52. package/Ops/index.js +0 -13
  53. package/Project/README.md.js +0 -6
  54. package/Project/application.js.js +0 -106
  55. package/Project/gitignore.js +0 -17
  56. package/Project/index.js +0 -94
  57. package/Project/metadata.yml.js +0 -125
  58. package/Project/project-name-chapter-01.md.js +0 -15
  59. package/Project/project-name-colophon.md.js +0 -32
  60. package/Project/project-name-title-page.md.js +0 -13
  61. package/Project/toc.yml.js +0 -16
  62. package/Toc/index.js +0 -40
  63. package/Xhtml/index.js +0 -86
  64. package/Xml/index.js +0 -22
  65. package/figures/epub.js +0 -51
  66. package/figures/helpers.js +0 -213
  67. package/figures/index.js +0 -49
  68. package/figures/mobi.js +0 -56
  69. package/figures/reader.js +0 -54
  70. package/figures/web.js +0 -50
  71. package/index.js +0 -56
@@ -0,0 +1,342 @@
1
+ const require_chunk = require("../chunk-DakpK96I.js");
2
+ let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
3
+ let _canopycanopycanopy_b_ber_logger = require("@canopycanopycanopy/b-ber-logger");
4
+ _canopycanopycanopy_b_ber_logger = require_chunk.__toESM(_canopycanopycanopy_b_ber_logger);
5
+ let image_size = require("image-size");
6
+ image_size = require_chunk.__toESM(image_size);
7
+ let lodash_uniq_js = require("lodash/uniq.js");
8
+ lodash_uniq_js = require_chunk.__toESM(lodash_uniq_js);
9
+ //#region src/figures/helpers.ts
10
+ const { getImageOrientation: getImageOrientation$1 } = _canopycanopycanopy_b_ber_lib.utils;
11
+ const FULLBLEED_CLASS_NAME = "figure__fullbleed";
12
+ const getClassNamesArray = ({ classes = "" }) => classes.split(" ");
13
+ const getFigureInlineClasses = (data, ratioName) => data.inline || data.applyInlineClasses ? (0, lodash_uniq_js.default)([
14
+ "figure__large",
15
+ "figure__inline",
16
+ `figure__inline--${ratioName}`
17
+ ].concat(getClassNamesArray(data))).filter(Boolean).join(" ") : `figure__large figure__large--${ratioName}`;
18
+ const getMediaInlineClasses = (data) => data.inline || data.applyInlineClasses ? (0, lodash_uniq_js.default)([
19
+ "figure__large",
20
+ "figure__large--media",
21
+ "figure__inline--square"
22
+ ].concat(getClassNamesArray(data))).filter(Boolean).join(" ") : "figure__large figure__large--media figure__large--square";
23
+ const getSectionOpen = ({ inline }) => inline ? "" : "<section epub:type=\"loi\" class=\"chapter figures\">";
24
+ const getImageClassName = (data, ratioName) => getClassNamesArray(data).includes(FULLBLEED_CLASS_NAME) ? "fullbleed" : ratioName;
25
+ const linkedImage = (data) => `
26
+ %LINK_OPEN%
27
+ <img class="%IMAGE_CLASS_NAME%" alt="%IMAGE_ALT%" src="../images/%IMAGE_SRC%"/>
28
+ %LINK_CLOSE%
29
+ <div class="figcaption">
30
+ <p class="small">%CAPTION_CONTENT%</p>
31
+ </div>
32
+ `.replace(/%LINK_OPEN%/, data.inline ? "" : `<a href="${data.ref}.xhtml#ref${data.id}">`).replace(/%LINK_CLOSE%/, data.inline ? "" : "</a>").replace(/%IMAGE_CLASS_NAME%/, data.imageClassName).replace(/%IMAGE_ALT%/, data.alt).replace(/%IMAGE_SRC%/, data.source).replace(/%CAPTION_CONTENT%/, data.caption);
33
+ const unLinkedImage = (data) => `
34
+ <span>
35
+ <img class="portrait" alt="%IMAGE_ALT%" src="../images/%IMAGE_SRC%"/>
36
+ </span>
37
+ <div class="figcaption">
38
+ <p class="small">
39
+ %CAPTION_CONTENT%
40
+ %CAPTION_CONTENT_AFTER%
41
+ %CAPTION_BACK_LINK%
42
+ </p>
43
+ </div>
44
+ </div>
45
+ `.replace(/%IMAGE_ALT%/, data.alt).replace(/%IMAGE_SRC%/, data.source).replace(/%CAPTION_CONTENT%/, data.caption).replace(/%CAPTION_CONTENT_AFTER%/, data.caption && !data.inline ? "<br/>" : "").replace(/%CAPTION_BACK_LINK%/, data.inline ? "" : `<a href="${data.ref}.xhtml#ref${data.id}">Return</a>`);
46
+ const figureTemplate = (data) => `
47
+ %SECTION_OPEN%
48
+ <div class="%FIGURE_CLASS_NAMES%">
49
+ <figure id="%ID%">
50
+ <div class="figure__items">
51
+ %IMAGE%
52
+ </div>
53
+ </figure>
54
+ </div>
55
+ %SECTION_CLOSE%
56
+ `.replace(/%SECTION_OPEN%/, getSectionOpen(data)).replace(/%FIGURE_CLASS_NAMES%/, data.classes).replace(/%ID%/g, data.id).replace(/%IMAGE%/g, data.linkImages ? linkedImage(data) : unLinkedImage(data)).replace(/%SECTION_CLOSE%/, data.inline ? "" : "</section>");
57
+ const media = (data) => `
58
+ %SECTION_OPEN%
59
+ <div class="%FIGURE_CLASS_NAMES%">
60
+ <figure id="%ID%">
61
+ <div class="figure__items">
62
+ <div class="%MEDIA_TYPE%">
63
+ <%MEDIA_TYPE% id="%MEDIA_TYPE%-%ID%" %ELEMENT_ATTRIBUTES%>
64
+ %SOURCE_ELEMENTS%
65
+ <div class="media__fallback__%MEDIA_TYPE% media__fallback--image">
66
+ <figure>
67
+ <img src="%POSTER_IMAGE%" alt="Media fallback image"/>
68
+ </figure>
69
+ </div>
70
+ <p class="media__fallback__%MEDIA_TYPE% media__fallback--text">Your device does not support the HTML5 %MEDIA_TYPE% API.</p>
71
+ </%MEDIA_TYPE%>
72
+ </div>
73
+ <div class="figcaption">
74
+ <p class="small">
75
+ %CAPTION%
76
+ <a href="%REF%.xhtml#ref%ID%">Return</a>
77
+ </p>
78
+ </div>
79
+ </div>
80
+ </figure>
81
+ </div>
82
+ %SECTION_CLOSE%
83
+ `.replace(/%SECTION_OPEN%/, getSectionOpen(data)).replace(/%FIGURE_CLASS_NAMES%/, getMediaInlineClasses(data)).replace(/%ID%/g, data.id).replace(/%MEDIA_TYPE%/g, data.mediaType).replace(/%ELEMENT_ATTRIBUTES%/g, data.attrString).replace(/%SOURCE_ELEMENTS%/g, data.sourceElements).replace(/%POSTER_IMAGE%/g, data.poster).replace(/%CAPTION%/g, data.caption ? `${data.caption}<br/>` : "").replace(/%REF%/g, data.ref).replace(/%SECTION_CLOSE%/, data.inline ? "" : "</section>");
84
+ const iframe = (data) => `
85
+ %SECTION_OPEN%
86
+ <div class="figure__large figure__large--iframe">
87
+ <figure id="%ID%">
88
+ <div class="figure__items">
89
+ <div class="iframe">
90
+ <iframe
91
+ src="%SRC%"
92
+ title="%TITLE%"
93
+ width="%WIDTH%"
94
+ height="%HEIGHT%"
95
+ webkitallowfullscreen="webkitallowfullscreen"
96
+ mozallowfullscreen="mozallowfullscreen"
97
+ allowfullscreen="allowfullscreen"
98
+ allow="autoplay"
99
+ frameborder="0"
100
+ scrolling="no"
101
+ />
102
+ </div>
103
+
104
+ <div class="figcaption">
105
+ <p class="small">
106
+ %CAPTION%
107
+ <a href="%REF%.xhtml#ref%ID%">Return</a>
108
+ </p>
109
+ </div>
110
+ </div>
111
+ </figure>
112
+ </div>
113
+ %SECTION_CLOSE%
114
+ `.replace(/%SECTION_OPEN%/, getSectionOpen(data)).replace(/%ID%/g, data.id).replace(/%SRC%/g, data.source).replace(/%TITLE%/g, data.title).replace(/%WIDTH%/g, data.width).replace(/%HEIGHT%/g, data.height).replace(/%CAPTION%/g, data.caption ? `${data.caption}<br/>` : "").replace(/%REF%/g, data.ref).replace(/%SECTION_CLOSE%/g, data.inline ? "" : "</section>");
115
+ const vimeo = (data) => `
116
+ %SECTION_OPEN%
117
+ <div class="figure__large figure__large--vimeo figure__large--%ASPECT_RATIO%">
118
+ <figure id="%ID%">
119
+ <div class="figure__items">
120
+ <div class="vimeo %ASPECT_RATIO_CLASS_NAME%">
121
+ <div class="embed %SUPPORT_CLASS_NAME%">
122
+ %POSTER_IMAGE_ELEMENT%
123
+ <iframe
124
+ data-vimeo="true"
125
+ data-vimeo-poster="%POSTER_IMAGE_SRC%"
126
+ data-aspect-ratio="%ASPECT_RATIO%"
127
+ src="%SRC%" webkitallowfullscreen="webkitallowfullscreen" mozallowfullscreen="mozallowfullscreen" allowfullscreen="allowfullscreen" frameborder="0" />
128
+ </div>
129
+ </div>
130
+
131
+ <div class="figcaption">
132
+ <p class="small">
133
+ %CAPTION%
134
+ <a href="%REF%.xhtml#ref%ID%">Return</a>
135
+ </p>
136
+ </div>
137
+ </div>
138
+ </figure>
139
+ </div>
140
+ %SECTION_CLOSE%
141
+ `.replace(/%SECTION_OPEN%/, getSectionOpen(data)).replace(/%ID%/g, data.id).replace(/%ASPECT_RATIO%/g, data.aspectRatio).replace(/%POSTER_IMAGE_ELEMENT%/, data.poster && _canopycanopycanopy_b_ber_lib.State.build !== "reader" ? `<img src="${data.poster}" alt="Poster Image" />` : "").replace(/%POSTER_IMAGE_SRC%/, data.poster).replace(/%SUPPORT_CLASS_NAME%/, _canopycanopycanopy_b_ber_lib.State.build === "reader" || _canopycanopycanopy_b_ber_lib.State.build === "web" ? "supported" : "unsupported").replace(/%ASPECT_RATIO_CLASS_NAME%/, data.aspectRatioClassName).replace(/%SRC%/, `https://player.vimeo.com/video/${data.source}${data.attrQuery}`).replace(/%CAPTION%/, data.caption ? `${data.caption}<br/>` : "").replace(/%REF%/, data.ref).replace(/%SECTION_CLOSE%/, data.inline ? "" : "</section>");
142
+ const figure$1 = ({ data, ratioName, applyInlineClasses = false, linkImages = true }) => figureTemplate({
143
+ ...data,
144
+ linkImages,
145
+ classes: getFigureInlineClasses(data, ratioName),
146
+ imageClassName: getImageClassName(data, ratioName),
147
+ applyInlineClasses
148
+ });
149
+ const unsupported = ({ data, applyInlineClasses = false, linkImages = true }) => {
150
+ const source = data.poster.slice(data.poster.lastIndexOf("/") + 1);
151
+ const { width, height } = (0, image_size.default)(_canopycanopycanopy_b_ber_lib.State.src.images(source));
152
+ const ratioName = getImageOrientation$1(width, height);
153
+ return figureTemplate({
154
+ ...data,
155
+ source,
156
+ alt: "Media Fallback Image",
157
+ caption: "Your device does not support embedded media.",
158
+ linkImages,
159
+ classes: getFigureInlineClasses(data, ratioName),
160
+ imageClassName: getImageClassName(data, ratioName),
161
+ applyInlineClasses
162
+ });
163
+ };
164
+ //#endregion
165
+ //#region src/figures/epub.ts
166
+ const epub = {
167
+ portrait: (data) => figure$1({
168
+ data,
169
+ ratioName: "portrait"
170
+ }),
171
+ landscape: (data) => figure$1({
172
+ data,
173
+ ratioName: "landscape"
174
+ }),
175
+ "portrait-high": (data) => figure$1({
176
+ data,
177
+ ratioName: "portrait-high"
178
+ }),
179
+ square: (data) => figure$1({
180
+ data,
181
+ ratioName: "square"
182
+ }),
183
+ audio: (data) => media({
184
+ ...data,
185
+ applyInlineClasses: true
186
+ }),
187
+ video: (data) => media({
188
+ ...data,
189
+ applyInlineClasses: true
190
+ }),
191
+ iframe: (data) => iframe({
192
+ ...data,
193
+ applyInlineClasses: true
194
+ }),
195
+ vimeo: (data) => unsupported({
196
+ data,
197
+ applyInlineClasses: true
198
+ })
199
+ };
200
+ //#endregion
201
+ //#region src/figures/mobi.ts
202
+ const mobi = {
203
+ portrait: (data) => figure$1({
204
+ data,
205
+ ratioName: "portrait",
206
+ linkImages: false
207
+ }),
208
+ landscape: (data) => figure$1({
209
+ data,
210
+ ratioName: "landscape",
211
+ linkImages: false
212
+ }),
213
+ "portrait-high": (data) => figure$1({
214
+ data,
215
+ ratioName: "portrait-high",
216
+ linkImages: false
217
+ }),
218
+ square: (data) => figure$1({
219
+ data,
220
+ ratioName: "square",
221
+ linkImages: false
222
+ }),
223
+ audio: (data) => media({
224
+ ...data,
225
+ applyInlineClasses: true
226
+ }),
227
+ video: (data) => media({
228
+ ...data,
229
+ applyInlineClasses: true
230
+ }),
231
+ iframe: (data) => unsupported({
232
+ data,
233
+ applyInlineClasses: true
234
+ }),
235
+ vimeo: (data) => unsupported({
236
+ data,
237
+ applyInlineClasses: true
238
+ })
239
+ };
240
+ //#endregion
241
+ //#region src/figures/reader.ts
242
+ const reader = {
243
+ landscape: (data) => figure$1({
244
+ data,
245
+ ratioName: "landscape",
246
+ applyInlineClasses: true
247
+ }),
248
+ portrait: (data) => figure$1({
249
+ data,
250
+ ratioName: "portrait",
251
+ applyInlineClasses: true
252
+ }),
253
+ "portrait-high": (data) => figure$1({
254
+ data,
255
+ ratioName: "portrait-high",
256
+ applyInlineClasses: true
257
+ }),
258
+ square: (data) => figure$1({
259
+ data,
260
+ ratioName: "square",
261
+ applyInlineClasses: true
262
+ }),
263
+ audio: (data) => media({
264
+ ...data,
265
+ applyInlineClasses: true
266
+ }),
267
+ video: (data) => media({
268
+ ...data,
269
+ applyInlineClasses: true
270
+ }),
271
+ iframe: (data) => iframe({
272
+ ...data,
273
+ applyInlineClasses: true
274
+ }),
275
+ vimeo: (data) => vimeo({
276
+ ...data,
277
+ applyInlineClasses: true
278
+ })
279
+ };
280
+ //#endregion
281
+ //#region src/figures/web.ts
282
+ const web = {
283
+ portrait: (data) => figure$1({
284
+ data,
285
+ ratioName: "portrait"
286
+ }),
287
+ landscape: (data) => figure$1({
288
+ data,
289
+ ratioName: "landscape"
290
+ }),
291
+ "portrait-high": (data) => figure$1({
292
+ data,
293
+ ratioName: "portrait-high"
294
+ }),
295
+ square: (data) => figure$1({
296
+ data,
297
+ ratioName: "square"
298
+ }),
299
+ audio: (data) => media({
300
+ ...data,
301
+ applyInlineClasses: true
302
+ }),
303
+ video: (data) => media({
304
+ ...data,
305
+ applyInlineClasses: true
306
+ }),
307
+ iframe: (data) => iframe({
308
+ ...data,
309
+ applyInlineClasses: true
310
+ }),
311
+ vimeo: (data) => vimeo({
312
+ ...data,
313
+ applyInlineClasses: true
314
+ })
315
+ };
316
+ //#endregion
317
+ //#region src/figures/index.ts
318
+ const { getImageOrientation } = _canopycanopycanopy_b_ber_lib.utils;
319
+ const figures = {
320
+ epub,
321
+ mobi,
322
+ reader,
323
+ web
324
+ };
325
+ const isImage = (mime) => /^image/.test(mime);
326
+ const isAudio = (mime) => /^audio/.test(mime);
327
+ const isVideo = (mime) => /^video/.test(mime);
328
+ const isIframe = (type) => type === "iframe";
329
+ const isVimeo = (type) => type === "vimeo";
330
+ const figure = (data, buildType) => {
331
+ const { width, height, mime, type } = data;
332
+ const build = !buildType || !figures[buildType] ? "epub" : buildType;
333
+ let format = null;
334
+ if (isIframe(type) || isVimeo(type)) format = type;
335
+ else if (isImage(mime)) format = getImageOrientation(width, height);
336
+ else if (isAudio(mime)) format = "audio";
337
+ else if (isVideo(mime)) format = "video";
338
+ if (!format) _canopycanopycanopy_b_ber_logger.default.error(`bber-templates: [${data.source}] is of unsupported media type [${mime}]`);
339
+ return figures[build][format](data);
340
+ };
341
+ //#endregion
342
+ module.exports = figure;
@@ -0,0 +1,23 @@
1
+ import Ncx from "./Ncx/index.js";
2
+ import { t as Guide } from "./Guide-DtZekBN_.js";
3
+ import { t as Manifest } from "./Manifest-xzjWoNoJ.js";
4
+ import { t as Metadata } from "./Metadata-Cv6mesgj.js";
5
+ import { t as Pkg } from "./Pkg-BAwlpc2n.js";
6
+ import { t as Spine } from "./Spine-B4MQP83_.js";
7
+ import Project from "./Project/index.js";
8
+ import Toc from "./Toc/index.js";
9
+ import Xhtml from "./Xhtml/index.js";
10
+ import Xml from "./Xml/index.js";
11
+
12
+ //#region \0rolldown/runtime.js
13
+ declare namespace index_d_exports {
14
+ export { Guide, Manifest, Metadata, Pkg, Spine };
15
+ }
16
+ //#endregion
17
+ //#region src/Ops/index.d.ts
18
+ declare class Ops {
19
+ static mimetype(): string;
20
+ }
21
+ //#endregion
22
+ export { Ncx, index_d_exports as Opf, Ops, Project, Toc, Xhtml, Xml };
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/Opf/index.ts","../src/Ops/index.ts"],"mappings":";;;;;;;;;;;;;;;;;cCAM,GAAA;EAAA,OACG,QAAQ;AAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_chunk = require("./chunk-DakpK96I.js");
3
+ const require_Ncx_index = require("./Ncx/index.js");
4
+ const require_Opf_Guide = require("./Opf/Guide.js");
5
+ const require_Opf_Manifest = require("./Opf/Manifest.js");
6
+ const require_Opf_Metadata = require("./Opf/Metadata.js");
7
+ const require_Opf_Pkg = require("./Opf/Pkg.js");
8
+ const require_Opf_Spine = require("./Opf/Spine.js");
9
+ const require_Project = require("./Project-D0Q1l_Vp.js");
10
+ const require_Toc_index = require("./Toc/index.js");
11
+ const require_Xhtml_index = require("./Xhtml/index.js");
12
+ const require_Xml_index = require("./Xml/index.js");
13
+ //#region src/Opf/index.ts
14
+ var Opf_exports = /* @__PURE__ */ require_chunk.__exportAll({
15
+ Guide: () => require_Opf_Guide,
16
+ Manifest: () => require_Opf_Manifest,
17
+ Metadata: () => require_Opf_Metadata,
18
+ Pkg: () => require_Opf_Pkg,
19
+ Spine: () => require_Opf_Spine
20
+ });
21
+ //#endregion
22
+ //#region src/Ops/index.ts
23
+ var Ops = class {
24
+ static mimetype() {
25
+ return "application/epub+zip";
26
+ }
27
+ };
28
+ //#endregion
29
+ exports.Ncx = require_Ncx_index;
30
+ Object.defineProperty(exports, "Opf", {
31
+ enumerable: true,
32
+ get: function() {
33
+ return Opf_exports;
34
+ }
35
+ });
36
+ exports.Ops = Ops;
37
+ exports.Project = require_Project.Project;
38
+ exports.Toc = require_Toc_index;
39
+ exports.Xhtml = require_Xhtml_index;
40
+ exports.Xml = require_Xml_index;
package/package.json CHANGED
@@ -1,23 +1,26 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-templates",
3
- "version": "3.0.8-next.61+2bbec564",
3
+ "version": "3.0.8-next.97+2e9748e6",
4
4
  "description": "",
5
- "main": "index.js",
6
- "directories": {
7
- "Ncx": "Ncx",
8
- "Opf": "Opf",
9
- "Ops": "Ops",
10
- "Project": "Project",
11
- "Toc": "Toc",
12
- "Xhtml": "Xhtml",
13
- "Xml": "Xml"
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": "./dist/index.js",
9
+ "./figures": "./dist/figures/index.js",
10
+ "./Ncx": "./dist/Ncx/index.js",
11
+ "./Opf/Guide": "./dist/Opf/Guide.js",
12
+ "./Opf/Manifest": "./dist/Opf/Manifest.js",
13
+ "./Opf/Metadata": "./dist/Opf/Metadata.js",
14
+ "./Opf/Pkg": "./dist/Opf/Pkg.js",
15
+ "./Opf/Spine": "./dist/Opf/Spine.js",
16
+ "./Project": "./dist/Project/index.js",
17
+ "./Toc": "./dist/Toc/index.js",
18
+ "./Xhtml": "./dist/Xhtml/index.js",
19
+ "./Xml": "./dist/Xml/index.js"
14
20
  },
15
21
  "scripts": {
16
- "prepare:dist": "BABEL_ENV=production babel --config-file ../../babel.config.js -d ./ src/ --ignore **/__tests__/**",
17
- "prepare": "npm run clean && npm run prepare:dist",
18
- "clean": "rimraf ./index.js && rimraf Ncx && rimraf Opf && rimraf Ops && rimraf Project && rimraf Toc && rimraf Xhtml && rimraf Xml && rimraf figures",
19
- "build": "npm run prepare",
20
- "watch": "BABEL_ENV=production babel --config-file ../../babel.config.js -d ./ src/ --watch src",
22
+ "build": "tsdown",
23
+ "typecheck": "tsc --noEmit",
21
24
  "test": "jest"
22
25
  },
23
26
  "author": "Triple Canopy <b-ber@canopycanopycanopy.com> (https://triplecanopy.github.io/)",
@@ -26,17 +29,16 @@
26
29
  "access": "public"
27
30
  },
28
31
  "devDependencies": {
29
- "@babel/cli": "^7.10.5",
30
- "@babel/core": "^7.10.5",
31
- "@babel/preset-env": "^7.10.4",
32
- "browserslist": "^4.17.4",
33
- "jest": "^26.6.3",
34
- "rimraf": "^2.7.1"
32
+ "@swc/core": "^1.15.40",
33
+ "@swc/jest": "^0.2.39",
34
+ "jest": "^29.7.0",
35
+ "rimraf": "^2.7.1",
36
+ "tsdown": "^0.22.1",
37
+ "typescript": "^6.0.3"
35
38
  },
36
39
  "dependencies": {
37
- "@babel/runtime-corejs3": "^7.10.5",
38
- "@canopycanopycanopy/b-ber-lib": "3.0.8-next.61+2bbec564",
39
- "@canopycanopycanopy/b-ber-logger": "3.0.8-next.61+2bbec564",
40
+ "@canopycanopycanopy/b-ber-lib": "3.0.8-next.97+2e9748e6",
41
+ "@canopycanopycanopy/b-ber-logger": "3.0.8-next.97+2e9748e6",
40
42
  "fs-extra": "^8.1.0",
41
43
  "image-size": "^0.8.3",
42
44
  "lodash": "^4.17.21",
@@ -45,14 +47,7 @@
45
47
  "vinyl": "^2.2.0"
46
48
  },
47
49
  "files": [
48
- "figures",
49
- "Ncx",
50
- "Opf",
51
- "Ops",
52
- "Project",
53
- "Toc",
54
- "Xhtml",
55
- "Xml"
50
+ "dist"
56
51
  ],
57
52
  "repository": {
58
53
  "type": "git",
@@ -68,5 +63,5 @@
68
63
  "url": "https://maxwellsimmer.com"
69
64
  }
70
65
  ],
71
- "gitHead": "2bbec5643278f53becb0d2ba1f55edfe379d5587"
66
+ "gitHead": "2e9748e6f00446cd35dc8f933e049d8200fc24dd"
72
67
  }
package/Ncx/index.js DELETED
@@ -1,98 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
10
- var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
11
- var _vinyl = _interopRequireDefault(require("vinyl"));
12
- var _find = _interopRequireDefault(require("lodash/find"));
13
- var _has = _interopRequireDefault(require("lodash/has"));
14
- var _bBerLib = require("@canopycanopycanopy/b-ber-lib");
15
- var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
16
- var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
17
- // eslint-disable-line import/no-unresolved
18
-
19
- class Ncx {
20
- static head() {
21
- const entry = (0, _find.default)(_State.default.metadata.json(), {
22
- term: 'identifier'
23
- });
24
- const identifier = entry && (0, _has.default)(entry, 'value') ? entry.value : '';
25
- return `
26
- <head>
27
- <meta name="dtb:uid" content="${identifier}"/>
28
- <meta name="dtb:depth" content="1"/>
29
- <meta name="dtb:totalPageCount" content="1"/>
30
- <meta name="dtb:maxPageNumber" content="1"/>
31
- </head>
32
- `;
33
- }
34
- static title() {
35
- const entry = (0, _find.default)(_State.default.metadata.json(), {
36
- term: 'title'
37
- });
38
- const title = entry && (0, _has.default)(entry, 'value') ? entry.value : '';
39
- return `
40
- <docTitle>
41
- <text>${_bBerLib.Html.escape(title)}</text>
42
- </docTitle>
43
- `;
44
- }
45
- static author() {
46
- const entry = (0, _find.default)(_State.default.metadata.json(), {
47
- term: 'creator'
48
- });
49
- const creator = entry && (0, _has.default)(entry, 'value') ? entry.value : '';
50
- return `
51
- <docAuthor>
52
- <text>${_bBerLib.Html.escape(creator)}</text>
53
- </docAuthor>
54
- `;
55
- }
56
- static document() {
57
- return new _vinyl.default({
58
- path: 'ncx.document.tmpl',
59
- contents: Buffer.from(`<?xml version="1.0" encoding="UTF-8"?>
60
- <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
61
- ${Ncx.head()}
62
- ${Ncx.title()}
63
- ${Ncx.author()}
64
- <navMap>
65
- {% body %}
66
- </navMap>
67
- </ncx>
68
- `)
69
- });
70
- }
71
- static navPoint(data) {
72
- return `
73
- <navLabel>
74
- <text>${_bBerLib.Html.escape((0, _utils.getTitle)(data))}</text>
75
- </navLabel>
76
- <content src="${data.relativePath}.xhtml" />
77
- `;
78
- }
79
- static navPoints(data) {
80
- let index = 0;
81
- function render(nodes) {
82
- if (!nodes || !nodes.length) return '';
83
- return (0, _reduce.default)(nodes).call(nodes, (acc, curr) => {
84
- if (curr.in_toc === false) return acc;
85
- index += 1;
86
- return (0, _concat.default)(acc).call(acc, `
87
- <navPoint id="navPoint-${index}" playOrder="${index}">
88
- ${Ncx.navPoint(curr)}
89
- ${render(curr.nodes)}
90
- </navPoint>
91
- `);
92
- }, '');
93
- }
94
- const xml = render(data);
95
- return xml;
96
- }
97
- }
98
- var _default = exports.default = Ncx;
package/Opf/Guide.js DELETED
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
10
- var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
11
- var _path = _interopRequireDefault(require("path"));
12
- var _vinyl = _interopRequireDefault(require("vinyl"));
13
- var _bBerLib = require("@canopycanopycanopy/b-ber-lib");
14
- var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
15
- class Guide {
16
- static body() {
17
- return new _vinyl.default({
18
- path: 'guide.body.tmpl',
19
- contents: Buffer.from('<guide>{% body %}</guide>')
20
- });
21
- }
22
- static item({
23
- type,
24
- title,
25
- href
26
- }) {
27
- return `<reference type="${type}" title="${title}" href="${href}"/>`;
28
- }
29
- static items(data) {
30
- return (0, _reduce.default)(data).call(data, (acc, curr) => {
31
- if (!curr.type) return acc;
32
- _bBerLogger.default.info(`guide adding landmark [${curr.fileName}] as [${curr.type}]`);
33
- const {
34
- type
35
- } = curr;
36
- const title = _bBerLib.Html.escape(curr.title);
37
- const href = `text/${encodeURI(_path.default.basename(curr.fileName, '.xhtml'))}.xhtml`; // TODO: fixme
38
-
39
- return (0, _concat.default)(acc).call(acc, Guide.item({
40
- type,
41
- title,
42
- href
43
- }));
44
- }, '');
45
- }
46
- }
47
- var _default = exports.default = Guide;