@canopycanopycanopy/b-ber-lib 3.0.8-nav-memo.4 → 3.0.8-next.61

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
@@ -1,9 +1,27 @@
1
1
  # `@canopycanopycanopy/b-ber-lib`
2
2
 
3
- The `b-ber-lib` package includes classes and modules for managing b-ber's internal state, performing I/O operations, and parsing and rendering YAML and JSON data.
3
+ `b-ber-lib` is the shared utility library used across the b-ber build pipeline. It provides the central `State` singleton (project configuration, spine, metadata, and src/dist path helpers), `Config` (settings merged from `config.yml`), `Spine` and `SpineItem` (ordered content navigation built from `toc.yml`), `Theme` (SCSS theme loading), and a set of lower-level helpers for URL normalisation, HTML serialisation, YAML I/O, EPUB manifest properties, and Calibre ebook conversion. Virtually every other b-ber package depends on this package.
4
4
 
5
- ## Install
5
+ ## Key exports
6
6
 
7
- ```
8
- $ npm i -g @canopycanopycanopy/b-ber-lib
7
+ | Export | Purpose |
8
+ | ------------------------ | ------------------------------------------------------------------------------------------------------ |
9
+ | `State` | Singleton holding full build state: config, spine, metadata, figures, footnotes, src/dist path helpers |
10
+ | `Config` | Constructs project config by deep-merging `config.yml` over defaults |
11
+ | `Spine` / `SpineItem` | Reads `toc.yml`; produces nested and flattened page-flow for each build type |
12
+ | `YamlAdaptor` | Loads and queries YAML files; supports comment-preserving write-back via yawn-yaml |
13
+ | `Html` / `HtmlToXml` | Helpers for serialising and converting HTML to XHTML |
14
+ | `Url` | URL normalisation utilities |
15
+ | `Theme` | Resolves and loads built-in or user-defined SCSS themes |
16
+ | `Template` | Wraps rendered body content in the XHTML page template |
17
+ | `ManifestItemProperties` | Derives EPUB manifest `properties` attributes from content |
18
+ | `GuideItem` | Represents an EPUB guide reference entry |
19
+ | `EbookConvert` | Shell wrapper for the Calibre `ebook-convert` binary |
20
+ | `utils` | Miscellaneous low-level helpers |
21
+
22
+ ## Dev
23
+
24
+ ```bash
25
+ npm test # jest
26
+ npm run build
9
27
  ```
package/State.js CHANGED
@@ -64,7 +64,7 @@ const skipInitialization = () => {
64
64
  argv.length < 3 ||
65
65
  // if there are insufficient arguments
66
66
  (0, _includes.default)(argv).call(argv, 'new') // if it's a new project
67
- ;
67
+ ;
68
68
  };
69
69
  const SRC_DIR_IMAGES = '_images';
70
70
  const SRC_DIR_MARKDOWN = '_markdown';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-lib",
3
- "version": "3.0.8-nav-memo.4+d47a9aae",
3
+ "version": "3.0.8-next.61+2bbec564",
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": "3.0.8-nav-memo.4+d47a9aae",
32
- "@canopycanopycanopy/b-ber-shapes-dublin-core": "3.0.8-nav-memo.4+d47a9aae",
33
- "@canopycanopycanopy/b-ber-shapes-sequences": "3.0.8-nav-memo.4+d47a9aae",
34
- "@canopycanopycanopy/b-ber-theme-sans": "3.0.8-nav-memo.4+d47a9aae",
35
- "@canopycanopycanopy/b-ber-theme-serif": "3.0.8-nav-memo.4+d47a9aae",
31
+ "@canopycanopycanopy/b-ber-logger": "3.0.8-next.61+2bbec564",
32
+ "@canopycanopycanopy/b-ber-shapes-dublin-core": "3.0.8-next.61+2bbec564",
33
+ "@canopycanopycanopy/b-ber-shapes-sequences": "3.0.8-next.61+2bbec564",
34
+ "@canopycanopycanopy/b-ber-theme-sans": "3.0.8-next.61+2bbec564",
35
+ "@canopycanopycanopy/b-ber-theme-serif": "3.0.8-next.61+2bbec564",
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": "d47a9aae74dec3e3225e363b2434c7abe0fcf21b"
80
+ "gitHead": "2bbec5643278f53becb0d2ba1f55edfe379d5587"
81
81
  }
package/utils/index.js CHANGED
@@ -27,7 +27,8 @@ var _uniq = _interopRequireDefault(require("lodash/uniq"));
27
27
  var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
28
28
  var _findIndex = _interopRequireDefault(require("lodash/findIndex"));
29
29
  var _mimeTypes = _interopRequireDefault(require("mime-types"));
30
- var _ = require("..");
30
+ var _Url = _interopRequireDefault(require("../Url"));
31
+ var _State = _interopRequireDefault(require("../State"));
31
32
  // import ffprobe from 'ffprobe'
32
33
  // import ffprobeStatic from 'ffprobe-static'
33
34
 
@@ -73,12 +74,12 @@ const getImageOrientation = (w, h) => {
73
74
  exports.getImageOrientation = getImageOrientation;
74
75
  const getTitle = page => {
75
76
  if (page.name === 'figures-titlepage') return 'Figures';
76
- const meta = _.State.spine.frontMatter.get(page.name);
77
+ const meta = _State.default.spine.frontMatter.get(page.name);
77
78
  return meta && meta.title ? meta.title : page.title || page.name;
78
79
  };
79
80
  exports.getTitle = getTitle;
80
81
  const getBookMetadata = term => {
81
- const entry = (0, _find.default)(_.State.metadata.json(), {
82
+ const entry = (0, _find.default)(_State.default.metadata.json(), {
82
83
  term
83
84
  });
84
85
  if (entry && entry.value) return entry.value;
@@ -180,13 +181,13 @@ const webpubManifestReadingOrderItem = base => ({
180
181
  // https://github.com/readium/webpub-manifest
181
182
  const generateWebpubManifest = files => {
182
183
  var _context8, _context9;
183
- const remoteURL = _.Url.trimSlashes(_.State.config.remote_url);
184
+ const remoteURL = _Url.default.trimSlashes(_State.default.config.remote_url);
184
185
 
185
186
  // Build a map to sort the files according to the position in the spine
186
187
  const fileMap = new _map2.default((0, _map.default)(files).call(files, f => [_path.default.basename(f), f]));
187
188
 
188
189
  // Create the items for the manifest's reading order
189
- const readingOrderItems = (0, _reduce.default)(_context8 = _.State.spine.flattened).call(_context8, (acc, curr) => {
190
+ const readingOrderItems = (0, _reduce.default)(_context8 = _State.default.spine.flattened).call(_context8, (acc, curr) => {
190
191
  const file = fileMap.get(`${curr.fileName}.xhtml`);
191
192
  return !file ? acc : (0, _concat.default)(acc).call(acc, {
192
193
  file,
@@ -199,16 +200,16 @@ const generateWebpubManifest = files => {
199
200
  '@context': 'https://readium.org/webpub-manifest/context.jsonld',
200
201
  metadata: {
201
202
  '@type': 'http://schema.org/Book',
202
- title: getBookMetadata('title', _.State),
203
- author: getBookMetadata('creator', _.State),
204
- identifier: getBookMetadata('identifier', _.State),
205
- language: getBookMetadata('language', _.State),
206
- publisher: getBookMetadata('publisher', _.State),
203
+ title: getBookMetadata('title', _State.default),
204
+ author: getBookMetadata('creator', _State.default),
205
+ identifier: getBookMetadata('identifier', _State.default),
206
+ language: getBookMetadata('language', _State.default),
207
+ publisher: getBookMetadata('publisher', _State.default),
207
208
  modified: new Date().toISOString()
208
209
  },
209
210
  links: [{
210
211
  rel: 'self',
211
- href: `${remoteURL}/${trimLeadingSlash(_.State.distDir)}/manifest.json`,
212
+ href: `${remoteURL}/${trimLeadingSlash(_State.default.distDir)}/manifest.json`,
212
213
  type: 'application/webpub+json'
213
214
  }
214
215
  // { rel: 'alternate', href: `${remoteURL}/publication.epub`, type: 'application/epub+zip' },
@@ -223,7 +224,7 @@ const generateWebpubManifest = files => {
223
224
  // b-ber-grammar-* utilities
224
225
  exports.generateWebpubManifest = generateWebpubManifest;
225
226
  const validatePosterImage = (asset, type) => {
226
- const assetPath = _.State.src.images(asset);
227
+ const assetPath = _State.default.src.images(asset);
227
228
  if (!_fsExtra.default.existsSync(assetPath)) {
228
229
  _bBerLogger.default.error(`bber-directives: Poster image for [${type}] does not exist`);
229
230
  }
@@ -281,5 +282,5 @@ function ensurePoster(obj, type) {
281
282
  // Add mediaType to classes
282
283
  function ensureSupportedClassNames(obj, supported) {
283
284
  // eslint-disable-next-line no-param-reassign
284
- obj.classes += ` embed ${supported(_.State.build) ? '' : 'un'}supported`;
285
+ obj.classes += ` embed ${supported(_State.default.build) ? '' : 'un'}supported`;
285
286
  }