@canopycanopycanopy/b-ber-grammar-gallery 3.0.8-nav-memo.4 → 3.0.8-next.100

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,20 @@
1
- # `@canopycanopycanopy/b-ber-grammar-gallery`
1
+ # b-ber-grammar-gallery
2
2
 
3
- The `b-ber-grammar-gallery` package renders b-ber's custom `gallery` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki).
3
+ Handles the `gallery` / `exit` block directive pair. A `gallery` opening marker wraps its content in a build-target-aware container: for `reader` and `web` builds it emits a fullscreen gallery scaffold (`<section>` > `<div class="figure__gallery">` > `<figure>` > `<div class="figure__items">`); for EPUB, Mobi, PDF, and sample builds it emits a plain `<section>` that may be initialized as a slider by JavaScript if available. The exit marker (handled by `b-ber-grammar-section`) closes the open elements. Uses `b-ber-parser-gallery` as the MarkdownIt plugin and delegates open/close validation to `b-ber-grammar-renderer`.
4
4
 
5
- ## Install
5
+ ## Usage
6
6
 
7
+ Registered as a MarkdownIt plugin by the rendering engine:
8
+
9
+ ```js
10
+ import gallery from '@canopycanopycanopy/b-ber-grammar-gallery'
11
+ // { plugin, name: 'gallery', renderer }
7
12
  ```
8
- $ npm i -g @canopycanopycanopy/b-ber-grammar-gallery
13
+
14
+ ## Dev
15
+
9
16
  ```
17
+ npm test
18
+ ```
19
+
20
+ Tests are in `__tests__/index.test.js`.
@@ -0,0 +1,15 @@
1
+ //#region src/index.d.ts
2
+ declare const _default: {
3
+ plugin: (md: any, name: string, options?: any) => void;
4
+ name: string;
5
+ renderer: (args: any) => {
6
+ render: any;
7
+ marker: string;
8
+ minMarkers: number;
9
+ markerOpen: any;
10
+ markerClose: any;
11
+ validateOpen(params: any, line: any): boolean | undefined;
12
+ };
13
+ };
14
+ export = _default;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":""}
package/dist/index.js CHANGED
@@ -1,74 +1,58 @@
1
- "use strict";
2
-
3
- var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
4
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
5
- var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
6
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
7
- var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
8
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
9
- var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
10
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
11
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
12
- _Object$defineProperty(exports, "__esModule", {
13
- value: true
14
- });
15
- exports.default = void 0;
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
17
- var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
18
- var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
19
- var _bBerGrammarRenderer = _interopRequireDefault(require("@canopycanopycanopy/b-ber-grammar-renderer"));
20
- var _bBerGrammarAttributes = require("@canopycanopycanopy/b-ber-grammar-attributes");
21
- var _bBerParserGallery = _interopRequireDefault(require("@canopycanopycanopy/b-ber-parser-gallery"));
22
- function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
24
- // define our open and closing markers, used by the `validateOpen` and
25
- // `validateClose` methods in the `createRenderer`
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ let _canopycanopycanopy_b_ber_grammar_attributes = require("@canopycanopycanopy/b-ber-grammar-attributes");
24
+ let _canopycanopycanopy_b_ber_grammar_renderer = require("@canopycanopycanopy/b-ber-grammar-renderer");
25
+ _canopycanopycanopy_b_ber_grammar_renderer = __toESM(_canopycanopycanopy_b_ber_grammar_renderer);
26
+ let _canopycanopycanopy_b_ber_lib = require("@canopycanopycanopy/b-ber-lib");
27
+ let _canopycanopycanopy_b_ber_parser_gallery = require("@canopycanopycanopy/b-ber-parser-gallery");
28
+ _canopycanopycanopy_b_ber_parser_gallery = __toESM(_canopycanopycanopy_b_ber_parser_gallery);
29
+ //#region src/index.ts
26
30
  const MARKER_OPEN_RE = /^(gallery)(?::([^\s]+)(\s.*)?)?$/;
27
31
  const MARKER_CLOSE_RE = /^(exit)(?::([^\s]+))?/;
28
-
29
- // a simple `render` function that gets passed into our `createRenderer` is
30
- // responsible for the HTML output.
31
32
  const render = (tokens, idx) => {
32
- var _context;
33
- const token = (0, _trim.default)(_context = tokens[idx].info).call(_context).match(MARKER_OPEN_RE);
34
- if (tokens[idx].nesting !== 1 || !token) return '';
35
- const [, type, id, attrs] = token;
36
- const attrsObject = (0, _bBerGrammarAttributes.attributesObject)(attrs, type);
37
- const attrsString = (0, _bBerGrammarAttributes.attributesString)(attrsObject);
38
-
39
- // gallery directive is handled differentenly based on build:
40
-
41
- // web: drop all assets (images, videos, etc) into a `fullscreen`
42
- // container so that they can be positioned using custom CSS
43
-
44
- // epub, mobi: drop all assets into a section.gallery container
45
- // that is initialized as a slider via JS if available.
46
- // defaults to a simple sequence of images
47
-
48
- // pdf: sequence of images
49
-
50
- switch (_State.default.build) {
51
- case 'web':
52
- case 'reader':
53
- return `
54
- <section id="${(0, _bBerGrammarAttributes.htmlId)(id)}" ${attrsString}>
33
+ const token = tokens[idx].info.trim().match(MARKER_OPEN_RE);
34
+ if (tokens[idx].nesting !== 1 || !token) return "";
35
+ const [, type, id, attrs] = token;
36
+ const attrsString = (0, _canopycanopycanopy_b_ber_grammar_attributes.attributesString)((0, _canopycanopycanopy_b_ber_grammar_attributes.attributesObject)(attrs, type));
37
+ switch (_canopycanopycanopy_b_ber_lib.State.build) {
38
+ case "web":
39
+ case "reader": return `
40
+ <section id="${(0, _canopycanopycanopy_b_ber_grammar_attributes.htmlId)(id)}" ${attrsString}>
55
41
  <div class="figure__large figure__inline figure__fullbleed figure__gallery">
56
42
  <figure>
57
43
  <div class="figure__items">`;
58
- case 'epub':
59
- case 'mobi':
60
- case 'pdf':
61
- case 'sample':
62
- default:
63
- return `<section id="${(0, _bBerGrammarAttributes.htmlId)(id)}" ${attrsString}>`;
64
- }
44
+ default: return `<section id="${(0, _canopycanopycanopy_b_ber_grammar_attributes.htmlId)(id)}" ${attrsString}>`;
45
+ }
46
+ };
47
+ var src_default = {
48
+ plugin: _canopycanopycanopy_b_ber_parser_gallery.default,
49
+ name: "gallery",
50
+ renderer: (args) => (0, _canopycanopycanopy_b_ber_grammar_renderer.default)({
51
+ ...args,
52
+ markerOpen: MARKER_OPEN_RE,
53
+ markerClose: MARKER_CLOSE_RE,
54
+ render
55
+ })
65
56
  };
66
- var _default = exports.default = {
67
- plugin: _bBerParserGallery.default,
68
- name: 'gallery',
69
- renderer: args => (0, _bBerGrammarRenderer.default)(_objectSpread(_objectSpread({}, args), {}, {
70
- markerOpen: MARKER_OPEN_RE,
71
- markerClose: MARKER_CLOSE_RE,
72
- render
73
- }))
74
- };
57
+ //#endregion
58
+ module.exports = src_default;
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-grammar-gallery",
3
- "version": "3.0.8-nav-memo.4+d47a9aae",
3
+ "version": "3.0.8-next.100+20b74691",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "prepare:dist": "BABEL_ENV=production babel --config-file ../../babel.config.js -d dist/ src/ --ignore **/__tests__/**",
8
- "clean": "rimraf dist",
9
- "prepare": "npm run clean && npm run prepare:dist",
10
- "build": "npm run prepare",
11
- "watch": "BABEL_ENV=production babel --config-file ../../babel.config.js -d dist/ src/ --watch src",
7
+ "build": "tsdown",
8
+ "typecheck": "tsc --noEmit",
12
9
  "test": "jest"
13
10
  },
14
11
  "author": "Triple Canopy <b-ber@canopycanopycanopy.com> (https://triplecanopy.github.io/)",
@@ -17,18 +14,19 @@
17
14
  "access": "public"
18
15
  },
19
16
  "devDependencies": {
20
- "@babel/cli": "^7.10.5",
21
- "@babel/core": "^7.10.5",
22
- "@babel/preset-env": "^7.10.4",
23
- "browserslist": "^4.17.4",
24
- "jest": "^26.6.3",
25
- "rimraf": "^2.7.1"
17
+ "@swc/core": "^1.15.40",
18
+ "@swc/jest": "^0.2.39",
19
+ "jest": "^29.7.0",
20
+ "rimraf": "^2.7.1",
21
+ "tsdown": "^0.22.1",
22
+ "typescript": "^6.0.3"
26
23
  },
27
24
  "dependencies": {
28
- "@canopycanopycanopy/b-ber-grammar-attributes": "3.0.8-nav-memo.4+d47a9aae",
29
- "@canopycanopycanopy/b-ber-grammar-renderer": "3.0.8-nav-memo.4+d47a9aae",
30
- "@canopycanopycanopy/b-ber-lib": "3.0.8-nav-memo.4+d47a9aae",
31
- "@canopycanopycanopy/b-ber-parser-gallery": "3.0.8-nav-memo.4+d47a9aae",
25
+ "@canopycanopycanopy/b-ber-grammar-attributes": "3.0.8-next.100+20b74691",
26
+ "@canopycanopycanopy/b-ber-grammar-renderer": "3.0.8-next.100+20b74691",
27
+ "@canopycanopycanopy/b-ber-lib": "3.0.8-next.100+20b74691",
28
+ "@canopycanopycanopy/b-ber-logger": "3.0.8-next.100+20b74691",
29
+ "@canopycanopycanopy/b-ber-parser-gallery": "3.0.8-next.100+20b74691",
32
30
  "lodash": "^4.17.21",
33
31
  "tar": "^6.1.11"
34
32
  },
@@ -49,5 +47,6 @@
49
47
  "url": "https://maxwellsimmer.com"
50
48
  }
51
49
  ],
52
- "gitHead": "d47a9aae74dec3e3225e363b2434c7abe0fcf21b"
50
+ "gitHead": "20b746918e81513be00a2f04971b00b296850f61",
51
+ "types": "dist/index.d.ts"
53
52
  }