@canopycanopycanopy/b-ber-grammar-section 3.0.8-next.61 → 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.
@@ -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,134 +1,103 @@
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 _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
18
- var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
19
- var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
20
- var _find = _interopRequireDefault(require("lodash/find"));
21
- var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
22
- var _bBerLib = require("@canopycanopycanopy/b-ber-lib");
23
- var _bBerShapesDirectives = require("@canopycanopycanopy/b-ber-shapes-directives");
24
- var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
25
- var _bBerParserSection = _interopRequireDefault(require("@canopycanopycanopy/b-ber-parser-section"));
26
- var _bBerGrammarRenderer = _interopRequireDefault(require("@canopycanopycanopy/b-ber-grammar-renderer"));
27
- var _bBerGrammarAttributes = require("@canopycanopycanopy/b-ber-grammar-attributes");
28
- 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; }
29
- 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; }
30
- // This matches *all* container-type directives, and outputs the appropriate
31
- // HTML based on user-defined attributes
32
- const containers = (0, _from.default)(_bBerShapesDirectives.BLOCK_DIRECTIVES).join('|');
33
-
34
- // Treat `exit` like an opening marker
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_logger = require("@canopycanopycanopy/b-ber-logger");
28
+ _canopycanopycanopy_b_ber_logger = __toESM(_canopycanopycanopy_b_ber_logger);
29
+ let _canopycanopycanopy_b_ber_parser_section = require("@canopycanopycanopy/b-ber-parser-section");
30
+ _canopycanopycanopy_b_ber_parser_section = __toESM(_canopycanopycanopy_b_ber_parser_section);
31
+ let _canopycanopycanopy_b_ber_shapes_directives = require("@canopycanopycanopy/b-ber-shapes-directives");
32
+ let lodash_find_js = require("lodash/find.js");
33
+ lodash_find_js = __toESM(lodash_find_js);
34
+ //#region src/index.ts
35
+ const containers = Array.from(_canopycanopycanopy_b_ber_shapes_directives.BLOCK_DIRECTIVES).join("|");
35
36
  const MARKER_OPEN_RE = new RegExp(`^(${containers}|exit)(?::([^\\s]+)(\\s.*)?)?$`);
36
37
  const MARKER_CLOSE_RE = /(exit)(?::([^\s]+))?/;
37
-
38
- // `context` must be available in this `render` method and is passed
39
- // into `createRenderer` below. Default for `context` is set for use
40
- // during tests
41
-
42
38
  function isGallery(directive) {
43
- return directive && directive.type === 'gallery' && (_State.default.build === 'web' || _State.default.build === 'reader');
39
+ return directive && directive.type === "gallery" && (_canopycanopycanopy_b_ber_lib.State.build === "web" || _canopycanopycanopy_b_ber_lib.State.build === "reader");
44
40
  }
45
41
  function isSpread(directive) {
46
- return directive && directive.type === 'spread' && (_State.default.build === 'web' || _State.default.build === 'reader');
42
+ return directive && directive.type === "spread" && (_canopycanopycanopy_b_ber_lib.State.build === "web" || _canopycanopycanopy_b_ber_lib.State.build === "reader");
47
43
  }
48
44
  function handleExitDirective(token) {
49
- const [, type, id] = token;
50
- _bBerLogger.default.debug(`exit directive [${id}]`);
51
- const comment = _bBerLib.Html.comment(`END: section:${type}#${(0, _bBerGrammarAttributes.htmlId)(id)}`);
52
- const directive = (0, _find.default)(_State.default.cursor, {
53
- id
54
- });
55
- _State.default.remove('cursor', {
56
- id
57
- });
58
- if (isGallery(directive)) {
59
- // prettier-ignore
60
- return `</div>
45
+ const [, type, id] = token;
46
+ _canopycanopycanopy_b_ber_logger.default.debug(`exit directive [${id}]`);
47
+ const comment = _canopycanopycanopy_b_ber_lib.Html.comment(`END: section:${type}#${(0, _canopycanopycanopy_b_ber_grammar_attributes.htmlId)(id)}`);
48
+ const directive = (0, lodash_find_js.default)(_canopycanopycanopy_b_ber_lib.State.cursor, { id });
49
+ _canopycanopycanopy_b_ber_lib.State.remove("cursor", { id });
50
+ if (isGallery(directive)) return `</div>
61
51
  </figure>
62
52
  </div>
63
53
  </section>${comment}`;
64
- }
65
- if (isSpread(directive)) {
66
- return `</div>
54
+ if (isSpread(directive)) return `</div>
67
55
  </div>
68
56
 
69
- ${_State.default.build === 'reader' ? `<!-- Empty node required for spread markers -->
70
- <div></div>` : ''}
57
+ ${_canopycanopycanopy_b_ber_lib.State.build === "reader" ? `<!-- Empty node required for spread markers -->
58
+ <div></div>` : ""}
71
59
 
72
60
  ${comment}`;
73
- }
74
- return `</section>${comment}`;
61
+ return `</section>${comment}`;
75
62
  }
76
63
  function openElement(token, fileName, lineNumber) {
77
- // Destructure the attributes from matches, omitting `matches[0]` since
78
- // we're only interested in the captures
79
- const [, type, id, attr] = token;
80
- _bBerLogger.default.debug(`open directive [${id}]`);
81
- const comment = _bBerLib.Html.comment(`START: section:${type}#${(0, _bBerGrammarAttributes.htmlId)(id)}; ${fileName}:${lineNumber}`);
82
- const attrs = (0, _bBerGrammarAttributes.attributes)(attr, type, {
83
- fileName,
84
- lineNumber
85
- });
86
- return `${comment}<section id="${(0, _bBerGrammarAttributes.htmlId)(id)}"${attrs}>`;
64
+ const [, type, id, attr] = token;
65
+ _canopycanopycanopy_b_ber_logger.default.debug(`open directive [${id}]`);
66
+ const comment = _canopycanopycanopy_b_ber_lib.Html.comment(`START: section:${type}#${(0, _canopycanopycanopy_b_ber_grammar_attributes.htmlId)(id)}; ${fileName}:${lineNumber}`);
67
+ const attrs = (0, _canopycanopycanopy_b_ber_grammar_attributes.attributes)(attr, type, {
68
+ fileName,
69
+ lineNumber
70
+ });
71
+ return `${comment}<section id="${(0, _canopycanopycanopy_b_ber_grammar_attributes.htmlId)(id)}"${attrs}>`;
87
72
  }
88
73
  function closeElement(marker) {
89
- // tokens `nesting` prop is -1. we should be closing the html element
90
- // here, but probably have done so above since we're treating `exit`
91
- // directives as openers. check to see if the element has in fact been
92
- // closed
93
-
94
- const token = marker.split(':');
95
- if (token.length < 2) return '';
96
- const [, id] = token;
97
- if (!_State.default.contains('cursor', {
98
- id
99
- })) return '';
100
-
101
- // its id still exists in state, so it's open. force close here
102
- const comment = _bBerLib.Html.comment(`END: section:#${(0, _bBerGrammarAttributes.htmlId)(id)}`);
103
- const result = `</section>${comment}`;
104
-
105
- // remove the id
106
- _State.default.remove('cursor', {
107
- id
108
- });
109
- return result;
74
+ const token = marker.split(":");
75
+ if (token.length < 2) return "";
76
+ const [, id] = token;
77
+ if (!_canopycanopycanopy_b_ber_lib.State.contains("cursor", { id })) return "";
78
+ const result = `</section>${_canopycanopycanopy_b_ber_lib.Html.comment(`END: section:#${(0, _canopycanopycanopy_b_ber_grammar_attributes.htmlId)(id)}`)}`;
79
+ _canopycanopycanopy_b_ber_lib.State.remove("cursor", { id });
80
+ return result;
110
81
  }
111
- const render = ({
112
- context = {}
113
- }) => (tokens, index) => {
114
- var _context;
115
- const token = tokens[index];
116
- const lineNumber = (0, _map.default)(token) ? (0, _map.default)(token)[0] : null;
117
- const fileName = `_markdown/${context.fileName}.md`;
118
- const marker = (0, _trim.default)(_context = token.info).call(_context);
119
- if (token.nesting !== 1) return closeElement(marker);
120
-
121
- // token open, we ignore closing tokens and let `exit` handle those
122
- const tokenClose = marker.match(MARKER_CLOSE_RE);
123
- const tokenOpen = marker.match(MARKER_OPEN_RE);
124
- return tokenClose ? handleExitDirective(tokenClose) : openElement(tokenOpen, fileName, lineNumber);
82
+ const render = ({ context = {} }) => (tokens, index) => {
83
+ const token = tokens[index];
84
+ const lineNumber = token.map ? token.map[0] : null;
85
+ const fileName = `_markdown/${context.fileName}.md`;
86
+ const marker = token.info.trim();
87
+ if (token.nesting !== 1) return closeElement(marker);
88
+ const tokenClose = marker.match(MARKER_CLOSE_RE);
89
+ const tokenOpen = marker.match(MARKER_OPEN_RE);
90
+ return tokenClose ? handleExitDirective(tokenClose) : openElement(tokenOpen, fileName, lineNumber);
91
+ };
92
+ var src_default = {
93
+ plugin: _canopycanopycanopy_b_ber_parser_section.default,
94
+ name: "section",
95
+ renderer: (args) => (0, _canopycanopycanopy_b_ber_grammar_renderer.default)({
96
+ ...args,
97
+ markerOpen: MARKER_OPEN_RE,
98
+ markerClose: MARKER_CLOSE_RE,
99
+ render: render(args)
100
+ })
125
101
  };
126
- var _default = exports.default = {
127
- plugin: _bBerParserSection.default,
128
- name: 'section',
129
- renderer: args => (0, _bBerGrammarRenderer.default)(_objectSpread(_objectSpread({}, args), {}, {
130
- markerOpen: MARKER_OPEN_RE,
131
- markerClose: MARKER_CLOSE_RE,
132
- render: render(args)
133
- }))
134
- };
102
+ //#endregion
103
+ module.exports = src_default;
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "@canopycanopycanopy/b-ber-grammar-section",
3
- "version": "3.0.8-next.61+2bbec564",
3
+ "version": "3.0.8-next.96+7446845b",
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,20 +14,20 @@
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-next.61+2bbec564",
29
- "@canopycanopycanopy/b-ber-grammar-renderer": "3.0.8-next.61+2bbec564",
30
- "@canopycanopycanopy/b-ber-lib": "3.0.8-next.61+2bbec564",
31
- "@canopycanopycanopy/b-ber-logger": "3.0.8-next.61+2bbec564",
32
- "@canopycanopycanopy/b-ber-parser-section": "3.0.8-next.61+2bbec564",
33
- "@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-next.61+2bbec564",
25
+ "@canopycanopycanopy/b-ber-grammar-attributes": "3.0.8-next.96+7446845b",
26
+ "@canopycanopycanopy/b-ber-grammar-renderer": "3.0.8-next.96+7446845b",
27
+ "@canopycanopycanopy/b-ber-lib": "3.0.8-next.96+7446845b",
28
+ "@canopycanopycanopy/b-ber-logger": "3.0.8-next.96+7446845b",
29
+ "@canopycanopycanopy/b-ber-parser-section": "3.0.8-next.96+7446845b",
30
+ "@canopycanopycanopy/b-ber-shapes-directives": "3.0.8-next.96+7446845b",
34
31
  "lodash": "^4.17.21"
35
32
  },
36
33
  "files": [
@@ -50,5 +47,6 @@
50
47
  "url": "https://maxwellsimmer.com"
51
48
  }
52
49
  ],
53
- "gitHead": "2bbec5643278f53becb0d2ba1f55edfe379d5587"
50
+ "gitHead": "7446845bcda4337bfbc9f75b55a1e0ca805023eb",
51
+ "types": "dist/index.d.ts"
54
52
  }