@jpmorganchase/mosaic-plugins 0.1.0-beta.8 → 0.1.0-beta.80
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/dist/$AliasPlugin.d.ts +10 -0
- package/dist/$AliasPlugin.js +49 -228
- package/dist/$AliasPlugin.js.map +1 -1
- package/dist/$CodeModPlugin.d.ts +7 -0
- package/dist/$CodeModPlugin.js +18 -118
- package/dist/$CodeModPlugin.js.map +1 -1
- package/dist/$RefPlugin.d.ts +31 -0
- package/dist/$RefPlugin.js +123 -451
- package/dist/$RefPlugin.js.map +1 -1
- package/dist/$TagPlugin.d.ts +28 -0
- package/dist/$TagPlugin.js +51 -234
- package/dist/$TagPlugin.js.map +1 -1
- package/dist/BreadcrumbsPlugin.d.ts +19 -0
- package/dist/BreadcrumbsPlugin.js +87 -112
- package/dist/BreadcrumbsPlugin.js.map +1 -1
- package/dist/BrokenLinksPlugin.d.ts +10 -0
- package/dist/BrokenLinksPlugin.js +80 -0
- package/dist/BrokenLinksPlugin.js.map +1 -0
- package/dist/FragmentPlugin.d.ts +3 -0
- package/dist/FragmentPlugin.js +61 -0
- package/dist/FragmentPlugin.js.map +1 -0
- package/dist/LazyPagePlugin.d.ts +14 -0
- package/dist/LazyPagePlugin.js +50 -254
- package/dist/LazyPagePlugin.js.map +1 -1
- package/dist/PagesWithoutFileExtPlugin.d.ts +9 -0
- package/dist/PagesWithoutFileExtPlugin.js +20 -118
- package/dist/PagesWithoutFileExtPlugin.js.map +1 -1
- package/dist/PropsTablePlugin.d.ts +6 -0
- package/dist/PropsTablePlugin.js +88 -0
- package/dist/PropsTablePlugin.js.map +1 -0
- package/dist/PublicAssetsPlugin.d.ts +18 -0
- package/dist/PublicAssetsPlugin.js +28 -0
- package/dist/PublicAssetsPlugin.js.map +1 -0
- package/dist/ReadingTimePlugin.d.ts +10 -0
- package/dist/ReadingTimePlugin.js +39 -0
- package/dist/ReadingTimePlugin.js.map +1 -0
- package/dist/SearchIndexPlugin.d.ts +56 -0
- package/dist/SearchIndexPlugin.js +154 -0
- package/dist/SearchIndexPlugin.js.map +1 -0
- package/dist/SharedConfigPlugin.d.ts +14 -0
- package/dist/SharedConfigPlugin.js +129 -168
- package/dist/SharedConfigPlugin.js.map +1 -1
- package/dist/SidebarPlugin.d.ts +45 -0
- package/dist/SidebarPlugin.js +285 -324
- package/dist/SidebarPlugin.js.map +1 -1
- package/dist/SiteMapPlugin.d.ts +9 -0
- package/dist/SiteMapPlugin.js +23 -91
- package/dist/SiteMapPlugin.js.map +1 -1
- package/dist/TableOfContentsPlugin.d.ts +20 -0
- package/dist/TableOfContentsPlugin.js +44 -0
- package/dist/TableOfContentsPlugin.js.map +1 -0
- package/dist/utils/PluginError.d.ts +7 -0
- package/dist/utils/PluginError.js +13 -0
- package/dist/utils/PluginError.js.map +1 -0
- package/dist/utils/createPageTest.d.ts +1 -0
- package/dist/utils/createPageTest.js +8 -0
- package/dist/utils/createPageTest.js.map +1 -0
- package/dist/utils/mergePageContent.d.ts +16 -0
- package/dist/utils/mergePageContent.js +23 -0
- package/dist/utils/mergePageContent.js.map +1 -0
- package/dist/utils/normaliseRefs.d.ts +1 -0
- package/dist/utils/normaliseRefs.js +56 -275
- package/dist/utils/normaliseRefs.js.map +1 -1
- package/dist/utils/sortSidebarData.d.ts +29 -0
- package/dist/utils/sortSidebarData.js +47 -0
- package/dist/utils/sortSidebarData.js.map +1 -0
- package/package.json +41 -19
- package/CHANGELOG.md +0 -93
- package/dist/LocalFolderSavePlugin.js +0 -165
- package/dist/LocalFolderSavePlugin.js.map +0 -1
- package/dist/NextPrevPagePlugin.js +0 -173
- package/dist/NextPrevPagePlugin.js.map +0 -1
- package/dist/ReadingTimePlugin.mjs +0 -119
- package/dist/ReadingTimePlugin.mjs.map +0 -1
- package/dist/SearchIndexPlugin.mjs +0 -268
- package/dist/SearchIndexPlugin.mjs.map +0 -1
- package/dist/TableOfContentsPlugin.mjs +0 -131
- package/dist/TableOfContentsPlugin.mjs.map +0 -1
- package/dist/__tests__/BreadcrumbsPlugin.test.js +0 -160
- package/dist/__tests__/BreadcrumbsPlugin.test.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
interface AliasPluginPage extends Page {
|
|
3
|
+
aliases?: string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Plugin that scrapes `aliases` from page metadata and also applies all aliases stored in `config.data.aliases`
|
|
7
|
+
* Other plugins can use `setAliases` to apply new aliases, as long as they call it before this plugin has reaches `$beforeSend`
|
|
8
|
+
*/
|
|
9
|
+
declare const $AliasPlugin: PluginType<AliasPluginPage>;
|
|
10
|
+
export default $AliasPlugin;
|
package/dist/$AliasPlugin.js
CHANGED
|
@@ -1,240 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
import regeneratorRuntime from "regenerator-runtime";
|
|
31
|
-
import path from "path";
|
|
32
|
-
import { escapeRegExp } from "lodash";
|
|
33
|
-
function createPageTest(ignorePages, pageExtensions) {
|
|
34
|
-
var extTest = new RegExp("".concat(pageExtensions.map(escapeRegExp).join("|"), "$"));
|
|
35
|
-
var ignoreTest = new RegExp("".concat(ignorePages.map(escapeRegExp).join("|"), "$"));
|
|
36
|
-
return function(file) {
|
|
37
|
-
return !ignoreTest.test(file) && extTest.test(file) && !path.basename(file).startsWith(".");
|
|
38
|
-
};
|
|
39
|
-
}
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import PluginError from './utils/PluginError.js';
|
|
3
|
+
import { createPageTest } from './utils/createPageTest.js';
|
|
40
4
|
/**
|
|
41
5
|
* Plugin that scrapes `aliases` from page metadata and also applies all aliases stored in `config.data.aliases`
|
|
42
6
|
* Other plugins can use `setAliases` to apply new aliases, as long as they call it before this plugin has reaches `$beforeSend`
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
case 4:
|
|
56
|
-
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
|
57
|
-
_ctx.next = 13;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
page = _step.value;
|
|
61
|
-
if (isNonHiddenPage(page.fullPath)) {
|
|
62
|
-
_ctx.next = 8;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
return _ctx.abrupt("continue", 10);
|
|
66
|
-
case 8:
|
|
67
|
-
if (page.aliases) {
|
|
68
|
-
config.setAliases(page.fullPath, page.aliases);
|
|
69
|
-
}
|
|
70
|
-
delete page.aliases;
|
|
71
|
-
case 10:
|
|
72
|
-
_iteratorNormalCompletion = true;
|
|
73
|
-
_ctx.next = 4;
|
|
74
|
-
break;
|
|
75
|
-
case 13:
|
|
76
|
-
_ctx.next = 19;
|
|
77
|
-
break;
|
|
78
|
-
case 15:
|
|
79
|
-
_ctx.prev = 15;
|
|
80
|
-
_ctx.t0 = _ctx["catch"](2);
|
|
81
|
-
_didIteratorError = true;
|
|
82
|
-
_iteratorError = _ctx.t0;
|
|
83
|
-
case 19:
|
|
84
|
-
_ctx.prev = 19;
|
|
85
|
-
_ctx.prev = 20;
|
|
86
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
87
|
-
_iterator.return();
|
|
88
|
-
}
|
|
89
|
-
case 22:
|
|
90
|
-
_ctx.prev = 22;
|
|
91
|
-
if (!_didIteratorError) {
|
|
92
|
-
_ctx.next = 25;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
throw _iteratorError;
|
|
96
|
-
case 25:
|
|
97
|
-
return _ctx.finish(22);
|
|
98
|
-
case 26:
|
|
99
|
-
return _ctx.finish(19);
|
|
100
|
-
case 27:
|
|
101
|
-
return _ctx.abrupt("return", pages);
|
|
102
|
-
case 28:
|
|
103
|
-
case "end":
|
|
104
|
-
return _ctx.stop();
|
|
7
|
+
*/
|
|
8
|
+
const $AliasPlugin = {
|
|
9
|
+
async $afterSource(pages, { config, ignorePages, pageExtensions }) {
|
|
10
|
+
const isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
11
|
+
// Group together all aliases defined in the frontmatter and store them in the alias config object
|
|
12
|
+
for (const page of pages) {
|
|
13
|
+
try {
|
|
14
|
+
if (!isNonHiddenPage(page.fullPath)) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (page.aliases) {
|
|
18
|
+
config.setAliases(page.fullPath, page.aliases);
|
|
105
19
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
[
|
|
114
|
-
20,
|
|
115
|
-
,
|
|
116
|
-
22,
|
|
117
|
-
26
|
|
118
|
-
]
|
|
119
|
-
]);
|
|
120
|
-
}))();
|
|
20
|
+
delete page.aliases;
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
throw new PluginError(e.message, page.fullPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return pages;
|
|
121
27
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return _ctx.abrupt("return");
|
|
138
|
-
case 3:
|
|
139
|
-
_ctx.t0 = regeneratorRuntime.keys(config.data.aliases);
|
|
140
|
-
case 4:
|
|
141
|
-
if ((_ctx.t1 = _ctx.t0()).done) {
|
|
142
|
-
_ctx.next = 45;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
fullPath = _ctx.t1.value;
|
|
146
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
147
|
-
_ctx.prev = 7;
|
|
148
|
-
_iterator = config.data.aliases[fullPath][Symbol.iterator]();
|
|
149
|
-
case 9:
|
|
150
|
-
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
|
151
|
-
_ctx.next = 29;
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
alias = _step.value;
|
|
155
|
-
aliasPath = path.resolve(path.dirname(fullPath), alias).toLowerCase();
|
|
156
|
-
aliasDir = path.dirname(aliasPath);
|
|
157
|
-
_ctx.next = 15;
|
|
158
|
-
return mutableFilesystem.promises.exists(aliasDir);
|
|
159
|
-
case 15:
|
|
160
|
-
if (_ctx.sent) {
|
|
161
|
-
_ctx.next = 18;
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
_ctx.next = 18;
|
|
165
|
-
return mutableFilesystem.promises.mkdir(aliasDir, {
|
|
28
|
+
async $beforeSend(mutableFilesystem, { config }) {
|
|
29
|
+
// Prevent any more aliases being set after this lifecycle has been called - as they won't take effect
|
|
30
|
+
config.setAliases = () => {
|
|
31
|
+
throw new Error('Cannot set aliases after `$AliasPlugin` has reached `$beforeSend` lifecycle phase.');
|
|
32
|
+
};
|
|
33
|
+
if (!config.data.aliases) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
for (const fullPath in config.data.aliases) {
|
|
37
|
+
try {
|
|
38
|
+
for (const alias of config.data.aliases[fullPath]) {
|
|
39
|
+
const aliasPath = path.posix.resolve(path.dirname(fullPath), alias).toLowerCase();
|
|
40
|
+
const aliasDir = path.dirname(aliasPath);
|
|
41
|
+
if (!(await mutableFilesystem.promises.exists(aliasDir))) {
|
|
42
|
+
await mutableFilesystem.promises.mkdir(aliasDir, {
|
|
166
43
|
recursive: true
|
|
167
44
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
_ctx.next = 23;
|
|
177
|
-
return mutableFilesystem.promises.symlink(fullPath, aliasPath);
|
|
178
|
-
case 23:
|
|
179
|
-
_ctx.next = 26;
|
|
180
|
-
break;
|
|
181
|
-
case 25:
|
|
182
|
-
{
|
|
183
|
-
console.warn("Alias '".concat(aliasPath, "' already exists. Is there a duplicate alias, or a page with the same name but different file extensions?"));
|
|
184
|
-
}
|
|
185
|
-
case 26:
|
|
186
|
-
_iteratorNormalCompletion = true;
|
|
187
|
-
_ctx.next = 9;
|
|
188
|
-
break;
|
|
189
|
-
case 29:
|
|
190
|
-
_ctx.next = 35;
|
|
191
|
-
break;
|
|
192
|
-
case 31:
|
|
193
|
-
_ctx.prev = 31;
|
|
194
|
-
_ctx.t2 = _ctx["catch"](7);
|
|
195
|
-
_didIteratorError = true;
|
|
196
|
-
_iteratorError = _ctx.t2;
|
|
197
|
-
case 35:
|
|
198
|
-
_ctx.prev = 35;
|
|
199
|
-
_ctx.prev = 36;
|
|
200
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
201
|
-
_iterator.return();
|
|
202
|
-
}
|
|
203
|
-
case 38:
|
|
204
|
-
_ctx.prev = 38;
|
|
205
|
-
if (!_didIteratorError) {
|
|
206
|
-
_ctx.next = 41;
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
throw _iteratorError;
|
|
210
|
-
case 41:
|
|
211
|
-
return _ctx.finish(38);
|
|
212
|
-
case 42:
|
|
213
|
-
return _ctx.finish(35);
|
|
214
|
-
case 43:
|
|
215
|
-
_ctx.next = 4;
|
|
216
|
-
break;
|
|
217
|
-
case 45:
|
|
218
|
-
case "end":
|
|
219
|
-
return _ctx.stop();
|
|
45
|
+
}
|
|
46
|
+
if (!(await mutableFilesystem.promises.exists(aliasPath))) {
|
|
47
|
+
await mutableFilesystem.promises.symlink(fullPath, aliasPath);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.warn(`Alias '${aliasPath}' already exists. Is there a duplicate alias, or a page with the same name but different file extensions?`);
|
|
51
|
+
}
|
|
220
52
|
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
43
|
|
227
|
-
],
|
|
228
|
-
[
|
|
229
|
-
36,
|
|
230
|
-
,
|
|
231
|
-
38,
|
|
232
|
-
42
|
|
233
|
-
]
|
|
234
|
-
]);
|
|
235
|
-
}))();
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
throw new PluginError(e.message, fullPath);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
236
58
|
}
|
|
237
59
|
};
|
|
238
60
|
export default $AliasPlugin;
|
|
239
|
-
|
|
240
61
|
//# sourceMappingURL=$AliasPlugin.js.map
|
package/dist/$AliasPlugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"$AliasPlugin.js","sourceRoot":"","sources":["../src/$AliasPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAM3D;;;GAGG;AACH,MAAM,YAAY,GAAgC;IAChD,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE;QAC/D,MAAM,eAAe,GAAG,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAEpE,kGAAkG;QAClG,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,IAAI;gBACF,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;oBACnC,SAAS;iBACV;gBACD,IAAI,IAAI,CAAC,OAAO,EAAE;oBAChB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;iBAChD;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC;aACrB;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;aACjD;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE;QAC7C,sGAAsG;QACtG,MAAM,CAAC,UAAU,GAAG,GAAG,EAAE;YACvB,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;QACJ,CAAC,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE;YACxB,OAAO;SACR;QACD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE;YAC1C,IAAI;gBACF,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;oBACjD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;oBAClF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;oBACzC,IAAI,CAAC,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE;wBACxD,MAAM,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;4BAC/C,SAAS,EAAE,IAAI;yBAChB,CAAC,CAAC;qBACJ;oBACD,IAAI,CAAC,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE;wBACzD,MAAM,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;qBAC/D;yBAAM;wBACL,OAAO,CAAC,IAAI,CACV,UAAU,SAAS,2GAA2G,CAC/H,CAAC;qBACH;iBACF;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;aAC5C;SACF;IACH,CAAC;CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
interface CodeModPluginPage extends Page {
|
|
3
|
+
frameOverrides?: Record<string, unknown>;
|
|
4
|
+
sharedConfig?: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
declare const $CodeModPlugin: PluginType<CodeModPluginPage>;
|
|
7
|
+
export default $CodeModPlugin;
|
package/dist/$CodeModPlugin.js
CHANGED
|
@@ -1,124 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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);
|
|
1
|
+
import PluginError from './utils/PluginError.js';
|
|
2
|
+
import { createPageTest } from './utils/createPageTest.js';
|
|
3
|
+
const $CodeModPlugin = {
|
|
4
|
+
async $afterSource(pages, { ignorePages, pageExtensions }) {
|
|
5
|
+
const isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
6
|
+
for (const page of pages) {
|
|
7
|
+
try {
|
|
8
|
+
if (!isNonHiddenPage(page.fullPath)) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (page.frameOverrides) {
|
|
12
|
+
page.sharedConfig = page.frameOverrides;
|
|
13
|
+
page.frameOverrides = { $ref: '#/sharedConfig' };
|
|
14
|
+
}
|
|
22
15
|
}
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
catch (e) {
|
|
17
|
+
throw new PluginError(e.message, page.fullPath);
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
import regeneratorRuntime from "regenerator-runtime";
|
|
31
|
-
import { escapeRegExp } from "lodash";
|
|
32
|
-
import path from "path";
|
|
33
|
-
function createPageTest(ignorePages, pageExtensions) {
|
|
34
|
-
var extTest = new RegExp("".concat(pageExtensions.map(escapeRegExp).join("|"), "$"));
|
|
35
|
-
var ignoreTest = new RegExp("".concat(ignorePages.map(escapeRegExp).join("|"), "$"));
|
|
36
|
-
return function(file) {
|
|
37
|
-
return !ignoreTest.test(file) && extTest.test(file) && !path.basename(file).startsWith(".");
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
var $CodeModPlugin = {
|
|
41
|
-
$afterSource: function $afterSource(pages, param) {
|
|
42
|
-
var ignorePages = param.ignorePages, pageExtensions = param.pageExtensions;
|
|
43
|
-
return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
|
|
44
|
-
var isNonHiddenPage, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, page;
|
|
45
|
-
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
46
|
-
while(1)switch(_ctx.prev = _ctx.next){
|
|
47
|
-
case 0:
|
|
48
|
-
isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
49
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
50
|
-
_ctx.prev = 2;
|
|
51
|
-
_iterator = pages[Symbol.iterator]();
|
|
52
|
-
case 4:
|
|
53
|
-
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
|
54
|
-
_ctx.next = 12;
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
page = _step.value;
|
|
58
|
-
if (isNonHiddenPage(page.fullPath)) {
|
|
59
|
-
_ctx.next = 8;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
return _ctx.abrupt("continue", 9);
|
|
63
|
-
case 8:
|
|
64
|
-
if (page.frameOverrides) {
|
|
65
|
-
page.sharedConfig = page.frameOverrides;
|
|
66
|
-
page.frameOverrides = {
|
|
67
|
-
$ref: "#/sharedConfig"
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
case 9:
|
|
71
|
-
_iteratorNormalCompletion = true;
|
|
72
|
-
_ctx.next = 4;
|
|
73
|
-
break;
|
|
74
|
-
case 12:
|
|
75
|
-
_ctx.next = 18;
|
|
76
|
-
break;
|
|
77
|
-
case 14:
|
|
78
|
-
_ctx.prev = 14;
|
|
79
|
-
_ctx.t0 = _ctx["catch"](2);
|
|
80
|
-
_didIteratorError = true;
|
|
81
|
-
_iteratorError = _ctx.t0;
|
|
82
|
-
case 18:
|
|
83
|
-
_ctx.prev = 18;
|
|
84
|
-
_ctx.prev = 19;
|
|
85
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
86
|
-
_iterator.return();
|
|
87
|
-
}
|
|
88
|
-
case 21:
|
|
89
|
-
_ctx.prev = 21;
|
|
90
|
-
if (!_didIteratorError) {
|
|
91
|
-
_ctx.next = 24;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
throw _iteratorError;
|
|
95
|
-
case 24:
|
|
96
|
-
return _ctx.finish(21);
|
|
97
|
-
case 25:
|
|
98
|
-
return _ctx.finish(18);
|
|
99
|
-
case 26:
|
|
100
|
-
return _ctx.abrupt("return", pages);
|
|
101
|
-
case 27:
|
|
102
|
-
case "end":
|
|
103
|
-
return _ctx.stop();
|
|
104
|
-
}
|
|
105
|
-
}, _callee, null, [
|
|
106
|
-
[
|
|
107
|
-
2,
|
|
108
|
-
14,
|
|
109
|
-
18,
|
|
110
|
-
26
|
|
111
|
-
],
|
|
112
|
-
[
|
|
113
|
-
19,
|
|
114
|
-
,
|
|
115
|
-
21,
|
|
116
|
-
25
|
|
117
|
-
]
|
|
118
|
-
]);
|
|
119
|
-
}))();
|
|
19
|
+
}
|
|
20
|
+
return pages;
|
|
120
21
|
}
|
|
121
22
|
};
|
|
122
23
|
export default $CodeModPlugin;
|
|
123
|
-
|
|
124
24
|
//# sourceMappingURL=$CodeModPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"$CodeModPlugin.js","sourceRoot":"","sources":["../src/$CodeModPlugin.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAO3D,MAAM,cAAc,GAAkC;IACpD,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE;QACvD,MAAM,eAAe,GAAG,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAEpE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,IAAI;gBACF,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;oBACnC,SAAS;iBACV;gBACD,IAAI,IAAI,CAAC,cAAc,EAAE;oBACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC;oBACxC,IAAI,CAAC,cAAc,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;iBAClD;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;aACjD;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Plugin as PluginType } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
interface RefsPluginConfigData {
|
|
3
|
+
refs: {
|
|
4
|
+
[key: string]: {
|
|
5
|
+
$$path: string[];
|
|
6
|
+
$$value: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
globalRefs: {
|
|
10
|
+
[key: string]: {
|
|
11
|
+
$$path: string[];
|
|
12
|
+
$$value: string;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
subscribedTags: string[];
|
|
16
|
+
}
|
|
17
|
+
interface RefsPluginPage {
|
|
18
|
+
fullPath: string;
|
|
19
|
+
refs: {
|
|
20
|
+
[key: string]: {
|
|
21
|
+
$$path: string[];
|
|
22
|
+
$$value: string;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Plugin that scrapes `$ref` properties from page metadata and also applies all refs stored in `config.data.refs`.
|
|
28
|
+
* Other plugins can use `setRef` to apply new refs, as long as they call it before this plugin has reaches `$beforeSend`
|
|
29
|
+
*/
|
|
30
|
+
declare const $RefPlugin: PluginType<RefsPluginPage, unknown, RefsPluginConfigData>;
|
|
31
|
+
export default $RefPlugin;
|