@jpmorganchase/mosaic-plugins 0.1.0-beta.6 → 0.1.0-beta.60

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/$AliasPlugin.d.ts +10 -0
  2. package/dist/$AliasPlugin.js +39 -48
  3. package/dist/$AliasPlugin.js.map +1 -1
  4. package/dist/$CodeModPlugin.d.ts +7 -0
  5. package/dist/$CodeModPlugin.js +18 -30
  6. package/dist/$CodeModPlugin.js.map +1 -1
  7. package/dist/$RefPlugin.d.ts +31 -0
  8. package/dist/$RefPlugin.js +131 -127
  9. package/dist/$RefPlugin.js.map +1 -1
  10. package/dist/$TagPlugin.d.ts +28 -0
  11. package/dist/$TagPlugin.js +37 -56
  12. package/dist/$TagPlugin.js.map +1 -1
  13. package/dist/BreadcrumbsPlugin.d.ts +19 -0
  14. package/dist/BreadcrumbsPlugin.js +84 -32
  15. package/dist/BreadcrumbsPlugin.js.map +1 -1
  16. package/dist/BrokenLinksPlugin.d.ts +10 -0
  17. package/dist/BrokenLinksPlugin.js +80 -0
  18. package/dist/BrokenLinksPlugin.js.map +1 -0
  19. package/dist/FragmentPlugin.d.ts +7 -0
  20. package/dist/FragmentPlugin.js +92 -0
  21. package/dist/FragmentPlugin.js.map +1 -0
  22. package/dist/LazyPagePlugin.d.ts +14 -0
  23. package/dist/LazyPagePlugin.js +57 -87
  24. package/dist/LazyPagePlugin.js.map +1 -1
  25. package/dist/PagesWithoutFileExtPlugin.d.ts +9 -0
  26. package/dist/PagesWithoutFileExtPlugin.js +19 -31
  27. package/dist/PagesWithoutFileExtPlugin.js.map +1 -1
  28. package/dist/PropsTablePlugin.d.ts +6 -0
  29. package/dist/PropsTablePlugin.js +88 -0
  30. package/dist/PropsTablePlugin.js.map +1 -0
  31. package/dist/PublicAssetsPlugin.d.ts +18 -0
  32. package/dist/PublicAssetsPlugin.js +28 -0
  33. package/dist/PublicAssetsPlugin.js.map +1 -0
  34. package/dist/ReadingTimePlugin.d.ts +10 -0
  35. package/dist/ReadingTimePlugin.js +36 -0
  36. package/dist/ReadingTimePlugin.js.map +1 -0
  37. package/dist/SearchIndexPlugin.d.ts +56 -0
  38. package/dist/SearchIndexPlugin.js +154 -0
  39. package/dist/SearchIndexPlugin.js.map +1 -0
  40. package/dist/SharedConfigPlugin.d.ts +14 -0
  41. package/dist/SharedConfigPlugin.js +134 -38
  42. package/dist/SharedConfigPlugin.js.map +1 -1
  43. package/dist/SidebarPlugin.d.ts +44 -0
  44. package/dist/SidebarPlugin.js +246 -95
  45. package/dist/SidebarPlugin.js.map +1 -1
  46. package/dist/SiteMapPlugin.d.ts +9 -0
  47. package/dist/SiteMapPlugin.js +20 -36
  48. package/dist/SiteMapPlugin.js.map +1 -1
  49. package/dist/TableOfContentsPlugin.d.ts +20 -0
  50. package/dist/TableOfContentsPlugin.js +43 -0
  51. package/dist/TableOfContentsPlugin.js.map +1 -0
  52. package/dist/utils/PluginError.d.ts +7 -0
  53. package/dist/utils/PluginError.js +13 -0
  54. package/dist/utils/PluginError.js.map +1 -0
  55. package/dist/utils/mergePageConent.d.ts +16 -0
  56. package/dist/utils/mergePageConent.js +23 -0
  57. package/dist/utils/mergePageConent.js.map +1 -0
  58. package/dist/utils/normaliseRefs.d.ts +1 -0
  59. package/dist/utils/normaliseRefs.js +52 -69
  60. package/dist/utils/normaliseRefs.js.map +1 -1
  61. package/dist/utils/sortSidebarData.d.ts +19 -0
  62. package/dist/utils/sortSidebarData.js +35 -0
  63. package/dist/utils/sortSidebarData.js.map +1 -0
  64. package/package.json +48 -15
  65. package/CHANGELOG.md +0 -58
  66. package/dist/NextPrevPagePlugin.js +0 -63
  67. package/dist/NextPrevPagePlugin.js.map +0 -1
  68. package/dist/ReadingTimePlugin.mjs +0 -119
  69. package/dist/ReadingTimePlugin.mjs.map +0 -1
  70. package/dist/TableOfContentsPlugin.mjs +0 -140
  71. package/dist/TableOfContentsPlugin.mjs.map +0 -1
@@ -1,140 +0,0 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _asyncToGenerator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- function _throw(e) {
31
- throw e;
32
- }
33
- import regeneratorRuntime from "regenerator-runtime";
34
- import Slugger from "github-slugger";
35
- import { toString } from "hast-util-to-string";
36
- import markdown from "remark-parse";
37
- import { unified } from "unified";
38
- import { visit } from "unist-util-visit";
39
- /**
40
- * Calculates table of contents from page headings
41
- */ var TableOfContentsPlugin = {
42
- $afterSource: function $afterSource(pages, _$param, param) {
43
- var _$param = _$param !== null ? _$param : _throw(new TypeError("Cannot destructure undefined")), minRank = param.minRank, maxRank = param.maxRank;
44
- return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
45
- var processor, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, page, slugger, tree, items, test, isHeadingInRange;
46
- return regeneratorRuntime.wrap(function _callee$(_ctx) {
47
- while(1)switch(_ctx.prev = _ctx.next){
48
- case 0:
49
- test = function _test(node) {
50
- return node.type === "heading" && isHeadingInRange(node);
51
- };
52
- isHeadingInRange = function _isHeadingInRange(node) {
53
- var depth = node.depth;
54
- if (depth < minRank || depth > maxRank) {
55
- return false;
56
- }
57
- return true;
58
- };
59
- processor = unified().use(markdown);
60
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
61
- _ctx.prev = 4;
62
- _iterator = pages[Symbol.iterator]();
63
- case 6:
64
- if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
65
- _ctx.next = 18;
66
- break;
67
- }
68
- page = _step.value;
69
- slugger = new Slugger();
70
- _ctx.next = 11;
71
- return processor.parse(page.content);
72
- case 11:
73
- tree = _ctx.sent;
74
- items = [];
75
- visit(tree, function(node) {
76
- return test(node);
77
- }, function(node) {
78
- var text = toString(node).trim();
79
- items.push({
80
- level: node.depth,
81
- id: slugger.slug(text),
82
- text: text
83
- });
84
- });
85
- page.tableOfContents = items;
86
- case 15:
87
- _iteratorNormalCompletion = true;
88
- _ctx.next = 6;
89
- break;
90
- case 18:
91
- _ctx.next = 24;
92
- break;
93
- case 20:
94
- _ctx.prev = 20;
95
- _ctx.t0 = _ctx["catch"](4);
96
- _didIteratorError = true;
97
- _iteratorError = _ctx.t0;
98
- case 24:
99
- _ctx.prev = 24;
100
- _ctx.prev = 25;
101
- if (!_iteratorNormalCompletion && _iterator.return != null) {
102
- _iterator.return();
103
- }
104
- case 27:
105
- _ctx.prev = 27;
106
- if (!_didIteratorError) {
107
- _ctx.next = 30;
108
- break;
109
- }
110
- throw _iteratorError;
111
- case 30:
112
- return _ctx.finish(27);
113
- case 31:
114
- return _ctx.finish(24);
115
- case 32:
116
- return _ctx.abrupt("return", pages);
117
- case 35:
118
- case "end":
119
- return _ctx.stop();
120
- }
121
- }, _callee, null, [
122
- [
123
- 4,
124
- 20,
125
- 24,
126
- 32
127
- ],
128
- [
129
- 25,
130
- ,
131
- 27,
132
- 31
133
- ]
134
- ]);
135
- }))();
136
- }
137
- };
138
- export default TableOfContentsPlugin;
139
-
140
- //# sourceMappingURL=TableOfContentsPlugin.mjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/TableOfContentsPlugin.mjs.ts"],"sourcesContent":["import type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';\nimport Slugger from 'github-slugger';\nimport { toString } from 'hast-util-to-string';\nimport markdown from 'remark-parse';\nimport { unified } from 'unified';\nimport { visit } from 'unist-util-visit';\n\ntype TOCItem = { level: number; id: string; text: string };\n\n/**\n * Calculates table of contents from page headings\n */\nconst TableOfContentsPlugin: PluginType<{}, { minRank: 2; maxRank: 4 }> = {\n async $afterSource(pages: Page[], {}, { minRank, maxRank }) {\n const processor = unified().use(markdown);\n for (const page of pages) {\n const slugger = new Slugger();\n const tree = await processor.parse(page.content);\n const items: TOCItem[] = [];\n visit(\n tree,\n node => test(node),\n node => {\n const text = toString(node).trim();\n items.push({\n level: node.depth,\n id: slugger.slug(text),\n text: text\n });\n }\n );\n page.tableOfContents = items;\n }\n\n return pages;\n\n function test(node) {\n return node.type === 'heading' && isHeadingInRange(node);\n }\n\n function isHeadingInRange(node) {\n const depth = node.depth;\n if (depth < minRank || depth > maxRank) {\n return false;\n }\n return true;\n }\n }\n};\n\nexport default TableOfContentsPlugin;\n"],"names":["Slugger","toString","markdown","unified","visit","TableOfContentsPlugin","$afterSource","pages","minRank","maxRank","processor","page","slugger","tree","items","test","isHeadingInRange","node","type","depth","use","parse","content","text","trim","push","level","id","slug","tableOfContents"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAOA,OAAO,MAAM,gBAAgB,CAAC;AACrC,SAASC,QAAQ,QAAQ,qBAAqB,CAAC;AAC/C,OAAOC,QAAQ,MAAM,cAAc,CAAC;AACpC,SAASC,OAAO,QAAQ,SAAS,CAAC;AAClC,SAASC,KAAK,QAAQ,kBAAkB,CAAC;AAIzC;;CAEC,GACD,IAAMC,qBAAqB,GAA+C;IAClEC,YAAY,EAAlB,SAAMA,YAAY,CAACC,KAAa,EAAE,OAAE,EAAE,KAAoB;YAAxB,OAAE,GAAF,OAAE,YAAF,OAAE,wDAAA,EAAIC,OAAO,GAAT,KAAoB,CAAlBA,OAAO,EAAEC,OAAO,GAAlB,KAAoB,CAATA,OAAO;eAAI,wDAAA,mBAAA;gBACpDC,SAAS,EAC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