@canopycanopycanopy/b-ber-lib 2.0.0 → 3.0.0
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/package.json +7 -7
- package/utils/index.js +15 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canopycanopycanopy/b-ber-lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime-corejs3": "^7.10.5",
|
|
31
|
-
"@canopycanopycanopy/b-ber-logger": "
|
|
32
|
-
"@canopycanopycanopy/b-ber-shapes-dublin-core": "
|
|
33
|
-
"@canopycanopycanopy/b-ber-shapes-sequences": "
|
|
34
|
-
"@canopycanopycanopy/b-ber-theme-sans": "
|
|
35
|
-
"@canopycanopycanopy/b-ber-theme-serif": "
|
|
31
|
+
"@canopycanopycanopy/b-ber-logger": "3.0.0",
|
|
32
|
+
"@canopycanopycanopy/b-ber-shapes-dublin-core": "3.0.0",
|
|
33
|
+
"@canopycanopycanopy/b-ber-shapes-sequences": "3.0.0",
|
|
34
|
+
"@canopycanopycanopy/b-ber-theme-sans": "3.0.0",
|
|
35
|
+
"@canopycanopycanopy/b-ber-theme-serif": "3.0.0",
|
|
36
36
|
"command-exists": "^1.2.2",
|
|
37
37
|
"fs-extra": "^8.1.0",
|
|
38
38
|
"glob": "^7.1.4",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"url": "https://maxwellsimmer.com"
|
|
78
78
|
}
|
|
79
79
|
],
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "676dbec7fbdcc46eb8168f1d437d294ed549e2e8"
|
|
81
81
|
}
|
package/utils/index.js
CHANGED
|
@@ -13,11 +13,7 @@ exports.ensure = void 0;
|
|
|
13
13
|
exports.ensurePoster = ensurePoster;
|
|
14
14
|
exports.ensureSource = ensureSource;
|
|
15
15
|
exports.ensureSupportedClassNames = ensureSupportedClassNames;
|
|
16
|
-
exports.validatePosterImage = exports.safeWrite = exports.resolveIntersectingUrl = exports.renderPosterImage = exports.renderCaption = exports.opsPath = exports.getTitle = exports.getMediaType = exports.getImageOrientation = exports.getBookMetadata = exports.generateWebpubManifest = exports.
|
|
17
|
-
|
|
18
|
-
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
19
|
-
|
|
20
|
-
var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
|
|
16
|
+
exports.validatePosterImage = exports.safeWrite = exports.resolveIntersectingUrl = exports.renderPosterImage = exports.renderCaption = exports.opsPath = exports.getTitle = exports.getMediaType = exports.getImageOrientation = exports.getBookMetadata = exports.generateWebpubManifest = exports.fileId = exports.fail = void 0;
|
|
21
17
|
|
|
22
18
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
23
19
|
|
|
@@ -84,16 +80,7 @@ const getImageOrientation = (w, h) => {
|
|
|
84
80
|
// const { display_aspect_ratio: aspectRatio } = streams
|
|
85
81
|
// return getAspectRatioClassName(aspectRatio)
|
|
86
82
|
// }
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
exports.getImageOrientation = getImageOrientation;
|
|
91
|
-
|
|
92
|
-
const forOf = (collection, iterator) => {
|
|
93
|
-
var _context;
|
|
94
|
-
|
|
95
|
-
return (0, _forEach.default)(_context = (0, _entries.default)(collection)).call(_context, ([key, val]) => iterator(key, val));
|
|
96
|
-
}; // TODO: the whole figures/generated pages/user-configurable YAML thing should
|
|
83
|
+
// TODO: the whole figures/generated pages/user-configurable YAML thing should
|
|
97
84
|
// be worked out better. one reason is below, where we need the title of a
|
|
98
85
|
// generated page, but since metadata is attached in the frontmatter YAML of an
|
|
99
86
|
// MD file, there is no reference for the metadata.
|
|
@@ -102,7 +89,7 @@ const forOf = (collection, iterator) => {
|
|
|
102
89
|
// this is provisional, will just cause more confusion in the future
|
|
103
90
|
|
|
104
91
|
|
|
105
|
-
exports.
|
|
92
|
+
exports.getImageOrientation = getImageOrientation;
|
|
106
93
|
|
|
107
94
|
const getTitle = page => {
|
|
108
95
|
if (page.name === 'figures-titlepage') return 'Figures';
|
|
@@ -139,24 +126,24 @@ const fail = (_msg, _err, yargs) => {
|
|
|
139
126
|
exports.fail = fail;
|
|
140
127
|
|
|
141
128
|
const ensureDirs = (dirs, prefix) => {
|
|
142
|
-
var
|
|
129
|
+
var _context, _context2;
|
|
143
130
|
|
|
144
131
|
const cwd = process.cwd();
|
|
145
|
-
const dirs_ = (0, _map.default)(
|
|
132
|
+
const dirs_ = (0, _map.default)(_context = (0, _uniq.default)((0, _concat.default)(_context2 = [`${prefix}/_project`, `${prefix}/_project/_fonts`, `${prefix}/_project/_images`, `${prefix}/_project/_javascripts`, `${prefix}/_project/_markdown`, `${prefix}/_project/_media`, `${prefix}/_project/_stylesheets`, `${prefix}/themes`]).call(_context2, dirs))).call(_context, a => _fsExtra.default.ensureDir(_path.default.join(cwd, a)));
|
|
146
133
|
return _promise.default.all(dirs_);
|
|
147
134
|
};
|
|
148
135
|
|
|
149
136
|
const ensureFiles = (files, prefix) => {
|
|
150
|
-
var _context4, _context5
|
|
137
|
+
var _context3, _context4, _context5;
|
|
151
138
|
|
|
152
|
-
const files_ = (0, _reduce.default)(
|
|
139
|
+
const files_ = (0, _reduce.default)(_context3 = (0, _concat.default)(_context4 = (0, _filter.default)(_context5 = [{
|
|
153
140
|
absolutePath: _path.default.resolve(prefix, '_project', 'toc.yml'),
|
|
154
141
|
content: ''
|
|
155
|
-
}]).call(
|
|
142
|
+
}]).call(_context5, ({
|
|
156
143
|
absolutePath
|
|
157
144
|
}) => (0, _findIndex.default)(files, {
|
|
158
145
|
absolutePath
|
|
159
|
-
}) < 0)).call(
|
|
146
|
+
}) < 0)).call(_context4, files)).call(_context3, (acc, curr) => _fsExtra.default.existsSync(curr.absolutePath) ? acc : (0, _concat.default)(acc).call(acc, _fsExtra.default.writeFile(curr.absolutePath, curr.content)), []);
|
|
160
147
|
return _promise.default.all(files_);
|
|
161
148
|
}; // make sure all necessary files and directories exist
|
|
162
149
|
|
|
@@ -172,7 +159,7 @@ exports.ensure = ensure;
|
|
|
172
159
|
const trimLeadingSlash = s => s.replace(/^\//, '');
|
|
173
160
|
|
|
174
161
|
const resolveIntersectingUrl = (u, p) => {
|
|
175
|
-
var
|
|
162
|
+
var _context6, _context7;
|
|
176
163
|
|
|
177
164
|
let url;
|
|
178
165
|
|
|
@@ -187,8 +174,8 @@ const resolveIntersectingUrl = (u, p) => {
|
|
|
187
174
|
const {
|
|
188
175
|
pathname
|
|
189
176
|
} = url;
|
|
190
|
-
let urlParts = (0, _filter.default)(
|
|
191
|
-
let pathParts = (0, _filter.default)(
|
|
177
|
+
let urlParts = (0, _filter.default)(_context6 = pathname.split('/')).call(_context6, Boolean);
|
|
178
|
+
let pathParts = (0, _filter.default)(_context7 = p.split('/')).call(_context7, Boolean); // Remove filename if there is one
|
|
192
179
|
|
|
193
180
|
if (/\./.test(urlParts[urlParts.length - 1])) {
|
|
194
181
|
urlParts.pop();
|
|
@@ -238,14 +225,14 @@ const webpubManifestReadingOrderItem = base => ({
|
|
|
238
225
|
|
|
239
226
|
|
|
240
227
|
const generateWebpubManifest = files => {
|
|
241
|
-
var
|
|
228
|
+
var _context8, _context9;
|
|
242
229
|
|
|
243
230
|
const remoteURL = _.Url.trimSlashes(_.State.config.remote_url); // Build a map to sort the files according to the position in the spine
|
|
244
231
|
|
|
245
232
|
|
|
246
233
|
const fileMap = new _map2.default((0, _map.default)(files).call(files, f => [_path.default.basename(f), f])); // Create the items for the manifest's reading order
|
|
247
234
|
|
|
248
|
-
const readingOrderItems = (0, _reduce.default)(
|
|
235
|
+
const readingOrderItems = (0, _reduce.default)(_context8 = _.State.spine.flattened).call(_context8, (acc, curr) => {
|
|
249
236
|
const file = fileMap.get(`${curr.fileName}.xhtml`);
|
|
250
237
|
return !file ? acc : (0, _concat.default)(acc).call(acc, {
|
|
251
238
|
file,
|
|
@@ -253,7 +240,7 @@ const generateWebpubManifest = files => {
|
|
|
253
240
|
});
|
|
254
241
|
}, []);
|
|
255
242
|
const readingOrder = (0, _map.default)(readingOrderItems).call(readingOrderItems, webpubManifestReadingOrderItem(remoteURL));
|
|
256
|
-
const resources = (0, _map.default)(
|
|
243
|
+
const resources = (0, _map.default)(_context9 = (0, _filter.default)(files).call(files, file => _path.default.basename(file).charAt(0) !== '.')).call(_context9, webpubManifestResource(remoteURL));
|
|
257
244
|
const manifest = {
|
|
258
245
|
'@context': 'https://readium.org/webpub-manifest/context.jsonld',
|
|
259
246
|
metadata: {
|