@jpmorganchase/mosaic-plugins 0.1.0-beta.4 → 0.1.0-beta.40
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 +43 -63
- package/dist/$AliasPlugin.js.map +1 -1
- package/dist/$CodeModPlugin.d.ts +7 -0
- package/dist/$CodeModPlugin.js +19 -37
- package/dist/$CodeModPlugin.js.map +1 -1
- package/dist/$RefPlugin.d.ts +31 -0
- package/dist/$RefPlugin.js +108 -128
- package/dist/$RefPlugin.js.map +1 -1
- package/dist/$TagPlugin.d.ts +28 -0
- package/dist/$TagPlugin.js +49 -74
- package/dist/$TagPlugin.js.map +1 -1
- package/dist/BreadcrumbsPlugin.d.ts +18 -0
- package/dist/BreadcrumbsPlugin.js +23 -33
- 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 +7 -0
- package/dist/FragmentPlugin.js +86 -0
- package/dist/FragmentPlugin.js.map +1 -0
- package/dist/LazyPagePlugin.d.ts +14 -0
- package/dist/LazyPagePlugin.js +55 -87
- package/dist/LazyPagePlugin.js.map +1 -1
- package/dist/LocalFolderSavePlugin.d.ts +6 -0
- package/dist/LocalFolderSavePlugin.js +21 -0
- package/dist/LocalFolderSavePlugin.js.map +1 -0
- package/dist/PagesWithoutFileExtPlugin.d.ts +9 -0
- package/dist/PagesWithoutFileExtPlugin.js +18 -36
- package/dist/PagesWithoutFileExtPlugin.js.map +1 -1
- package/dist/PropsTablePlugin.d.ts +6 -0
- package/dist/PropsTablePlugin.js +80 -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 +23 -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 +13 -0
- package/dist/SharedConfigPlugin.js +25 -41
- package/dist/SharedConfigPlugin.js.map +1 -1
- package/dist/SidebarPlugin.d.ts +38 -0
- package/dist/SidebarPlugin.js +191 -95
- package/dist/SidebarPlugin.js.map +1 -1
- package/dist/SiteMapPlugin.d.ts +9 -0
- package/dist/SiteMapPlugin.js +20 -36
- package/dist/SiteMapPlugin.js.map +1 -1
- package/dist/TableOfContentsPlugin.d.ts +20 -0
- package/dist/TableOfContentsPlugin.js +43 -0
- package/dist/TableOfContentsPlugin.js.map +1 -0
- package/dist/utils/normaliseRefs.d.ts +1 -0
- package/dist/utils/normaliseRefs.js +52 -69
- package/dist/utils/normaliseRefs.js.map +1 -1
- package/package.json +41 -15
- package/CHANGELOG.md +0 -42
- package/dist/NextPrevPagePlugin.js +0 -59
- package/dist/NextPrevPagePlugin.js.map +0 -1
- package/dist/ReadingTimePlugin.mjs +0 -119
- package/dist/ReadingTimePlugin.mjs.map +0 -1
- package/dist/TableOfContentsPlugin.mjs +0 -140
- package/dist/TableOfContentsPlugin.mjs.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,75 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const lodash_1 = require("lodash");
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { escapeRegExp } from 'lodash-es';
|
|
3
|
+
function createPageTest(ignorePages, pageExtensions) {
|
|
4
|
+
const extTest = new RegExp(`${pageExtensions.map(escapeRegExp).join('|')}$`);
|
|
5
|
+
const ignoreTest = new RegExp(`${ignorePages.map(escapeRegExp).join('|')}$`);
|
|
6
|
+
return file => !ignoreTest.test(file) && extTest.test(file) && !path.basename(file).startsWith('.');
|
|
7
|
+
}
|
|
17
8
|
/**
|
|
18
9
|
* Plugin that scrapes `aliases` from page metadata and also applies all aliases stored in `config.data.aliases`
|
|
19
10
|
* Other plugins can use `setAliases` to apply new aliases, as long as they call it before this plugin has reaches `$beforeSend`
|
|
20
11
|
*/
|
|
21
12
|
const $AliasPlugin = {
|
|
22
|
-
$afterSource(pages, { config, ignorePages, pageExtensions }
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (page.aliases) {
|
|
31
|
-
config.setAliases(page.fullPath, page.aliases);
|
|
32
|
-
}
|
|
33
|
-
delete page.aliases;
|
|
13
|
+
async $afterSource(pages, { config, ignorePages, pageExtensions }) {
|
|
14
|
+
const isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
15
|
+
// Group together all aliases defined in the frontmatter and store them in the alias config object
|
|
16
|
+
for (const page of pages) {
|
|
17
|
+
if (!isNonHiddenPage(page.fullPath)) {
|
|
18
|
+
continue;
|
|
34
19
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
$beforeSend(mutableFilesystem, { config }) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
// Prevent any more aliases being set after this lifecycle has been called - as they won't take effect
|
|
41
|
-
config.setAliases = () => {
|
|
42
|
-
throw new Error('Cannot set aliases after `$AliasPlugin` has reached `$beforeSend` lifecycle phase.');
|
|
43
|
-
};
|
|
44
|
-
if (!config.data.aliases) {
|
|
45
|
-
return;
|
|
20
|
+
if (page.aliases) {
|
|
21
|
+
config.setAliases(page.fullPath, page.aliases);
|
|
46
22
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
23
|
+
delete page.aliases;
|
|
24
|
+
}
|
|
25
|
+
return pages;
|
|
26
|
+
},
|
|
27
|
+
async $beforeSend(mutableFilesystem, { config }) {
|
|
28
|
+
// Prevent any more aliases being set after this lifecycle has been called - as they won't take effect
|
|
29
|
+
config.setAliases = () => {
|
|
30
|
+
throw new Error('Cannot set aliases after `$AliasPlugin` has reached `$beforeSend` lifecycle phase.');
|
|
31
|
+
};
|
|
32
|
+
if (!config.data.aliases) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
for (const fullPath in config.data.aliases) {
|
|
36
|
+
for (const alias of config.data.aliases[fullPath]) {
|
|
37
|
+
const aliasPath = path.posix.resolve(path.dirname(fullPath), alias).toLowerCase();
|
|
38
|
+
const aliasDir = path.dirname(aliasPath);
|
|
39
|
+
if (!(await mutableFilesystem.promises.exists(aliasDir))) {
|
|
40
|
+
await mutableFilesystem.promises.mkdir(aliasDir, {
|
|
41
|
+
recursive: true
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (!(await mutableFilesystem.promises.exists(aliasPath))) {
|
|
45
|
+
await mutableFilesystem.promises.symlink(fullPath, aliasPath);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.warn(`Alias '${aliasPath}' already exists. Is there a duplicate alias, or a page with the same name but different file extensions?`);
|
|
62
49
|
}
|
|
63
50
|
}
|
|
64
|
-
}
|
|
51
|
+
}
|
|
65
52
|
}
|
|
66
53
|
};
|
|
67
|
-
|
|
68
|
-
function createPageTest(ignorePages, pageExtensions) {
|
|
69
|
-
const extTest = new RegExp(`${pageExtensions.map(lodash_1.escapeRegExp).join('|')}$`);
|
|
70
|
-
const ignoreTest = new RegExp(`${ignorePages.map(lodash_1.escapeRegExp).join('|')}$`);
|
|
71
|
-
return file => {
|
|
72
|
-
return !ignoreTest.test(file) && extTest.test(file) && !path_1.default.basename(file).startsWith('.');
|
|
73
|
-
};
|
|
74
|
-
}
|
|
54
|
+
export default $AliasPlugin;
|
|
75
55
|
//# sourceMappingURL=$AliasPlugin.js.map
|
package/dist/$AliasPlugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$AliasPlugin.js","sourceRoot":"","sources":["../src/$AliasPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"$AliasPlugin.js","sourceRoot":"","sources":["../src/$AliasPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,SAAS,cAAc,CAAC,WAAW,EAAE,cAAc;IACjD,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CA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,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBACjD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;gBAClF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;gBACzC,IAAI,CAAC,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE;oBACxD,MAAM,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE;wBAC/C,SAAS,EAAE,IAAI;qBAChB,CAAC,CAAC;iBACJ;gBACD,IAAI,CAAC,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE;oBACzD,MAAM,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;iBAC/D;qBAAM;oBACL,OAAO,CAAC,IAAI,CACV,UAAU,SAAS,2GAA2G,CAC/H,CAAC;iBACH;aACF;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,42 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const lodash_1 = require("lodash");
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
1
|
+
import { escapeRegExp } from 'lodash-es';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
function createPageTest(ignorePages, pageExtensions) {
|
|
4
|
+
const extTest = new RegExp(`${pageExtensions.map(escapeRegExp).join('|')}$`);
|
|
5
|
+
const ignoreTest = new RegExp(`${ignorePages.map(escapeRegExp).join('|')}$`);
|
|
6
|
+
return file => !ignoreTest.test(file) && extTest.test(file) && !path.basename(file).startsWith('.');
|
|
7
|
+
}
|
|
17
8
|
const $CodeModPlugin = {
|
|
18
|
-
$afterSource(pages, { ignorePages, pageExtensions }) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (page.frameOverrides) {
|
|
26
|
-
page.sharedConfig = page.frameOverrides;
|
|
27
|
-
page.frameOverrides = { $ref: '#/sharedConfig' };
|
|
28
|
-
}
|
|
9
|
+
async $afterSource(pages, { ignorePages, pageExtensions }) {
|
|
10
|
+
const isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
11
|
+
for (const page of pages) {
|
|
12
|
+
if (!isNonHiddenPage(page.fullPath)) {
|
|
13
|
+
continue;
|
|
29
14
|
}
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
if (page.frameOverrides) {
|
|
16
|
+
page.sharedConfig = page.frameOverrides;
|
|
17
|
+
page.frameOverrides = { $ref: '#/sharedConfig' };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return pages;
|
|
32
21
|
}
|
|
33
22
|
};
|
|
34
|
-
|
|
35
|
-
function createPageTest(ignorePages, pageExtensions) {
|
|
36
|
-
const extTest = new RegExp(`${pageExtensions.map(lodash_1.escapeRegExp).join('|')}$`);
|
|
37
|
-
const ignoreTest = new RegExp(`${ignorePages.map(lodash_1.escapeRegExp).join('|')}$`);
|
|
38
|
-
return file => {
|
|
39
|
-
return !ignoreTest.test(file) && extTest.test(file) && !path_1.default.basename(file).startsWith('.');
|
|
40
|
-
};
|
|
41
|
-
}
|
|
23
|
+
export default $CodeModPlugin;
|
|
42
24
|
//# sourceMappingURL=$CodeModPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$CodeModPlugin.js","sourceRoot":"","sources":["../src/$CodeModPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"$CodeModPlugin.js","sourceRoot":"","sources":["../src/$CodeModPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,SAAS,cAAc,CAAC,WAAW,EAAE,cAAc;IACjD,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7E,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7E,OAAO,IAAI,CAAC,EAAE,CACZ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACzF,CAAC;AAOD,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,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBACnC,SAAS;aACV;YACD,IAAI,IAAI,CAAC,cAAc,EAAE;gBACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC;gBACxC,IAAI,CAAC,cAAc,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;aAClD;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;
|
package/dist/$RefPlugin.js
CHANGED
|
@@ -1,146 +1,126 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { reduce, omit, escapeRegExp } from 'lodash-es';
|
|
3
|
+
import { $RefParser } from '@apidevtools/json-schema-ref-parser';
|
|
4
|
+
import deepmerge from 'deepmerge';
|
|
5
|
+
import normaliseRefs from './utils/normaliseRefs.js';
|
|
6
|
+
function createRefResolver(normalisedRefs, serialiser, mutableFilesystem) {
|
|
7
|
+
return {
|
|
8
|
+
file: {
|
|
9
|
+
canRead: true,
|
|
10
|
+
order: 1,
|
|
11
|
+
async read(file, callback) {
|
|
12
|
+
try {
|
|
13
|
+
const refedPage = normalisedRefs[file.url] ||
|
|
14
|
+
(await serialiser.deserialise(file.url, await mutableFilesystem.promises.readFile(file.url)));
|
|
15
|
+
return callback(null, omit(refedPage, 'content'));
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
return callback(e, null);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const findKeys = (obj, targetProp, pathParts = []) => reduce(obj, (found, value, key) => {
|
|
25
|
+
if (key === targetProp) {
|
|
26
|
+
return found.concat([[pathParts.concat(String(key)), value]]);
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === 'object') {
|
|
29
|
+
const foundParents = findKeys(value, targetProp, pathParts.concat(String(key)));
|
|
30
|
+
return found.concat(foundParents);
|
|
31
|
+
}
|
|
32
|
+
return found;
|
|
33
|
+
}, []);
|
|
34
|
+
function createPageTest(ignorePages, pageExtensions) {
|
|
35
|
+
const extTest = new RegExp(`${pageExtensions.map(escapeRegExp).join('|')}$`);
|
|
36
|
+
const ignoreTest = new RegExp(`${ignorePages.map(escapeRegExp).join('|')}$`);
|
|
37
|
+
return file => !ignoreTest.test(file) && extTest.test(file) && !path.basename(file).startsWith('.');
|
|
38
|
+
}
|
|
21
39
|
/**
|
|
22
40
|
* Plugin that scrapes `$ref` properties from page metadata and also applies all refs stored in `config.data.refs`.
|
|
23
41
|
* Other plugins can use `setRef` to apply new refs, as long as they call it before this plugin has reaches `$beforeSend`
|
|
24
42
|
*/
|
|
25
43
|
const $RefPlugin = {
|
|
26
|
-
afterUpdate(mutableFilesystem, { ignorePages, globalFilesystem, serialiser, pageExtensions, globalConfig }) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
return fileData;
|
|
48
|
-
}));
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
$beforeSend(mutableFilesystem, { config, serialiser, pageExtensions, ignorePages }, options) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
// Prevent any more refs being set after this lifecycle has been called - as they won't take effect
|
|
54
|
-
config.setRef = () => {
|
|
55
|
-
throw new Error('Cannot set refs after `RefPlugin` has reached `$beforeSend` lifecycle phase.');
|
|
56
|
-
};
|
|
57
|
-
const normalisedRefs = {};
|
|
58
|
-
if (config.data.refs) {
|
|
59
|
-
// First pass of refs, normalises any $ref entries to expand wildcards
|
|
60
|
-
for (const fullPath in config.data.refs) {
|
|
61
|
-
const page = yield serialiser.deserialise(fullPath, yield mutableFilesystem.promises.readFile(fullPath));
|
|
62
|
-
normalisedRefs[fullPath] = Object.assign(Object.assign({}, page), (yield (0, normaliseRefs_1.default)(String(fullPath), config.data.refs[fullPath], mutableFilesystem, pageExtensions, ignorePages)));
|
|
63
|
-
}
|
|
64
|
-
const resolve = createRefResolver(normalisedRefs, serialiser, mutableFilesystem);
|
|
65
|
-
const refParser = new json_schema_ref_parser_1.default();
|
|
66
|
-
// Second pass of refs, resolves the refs
|
|
67
|
-
for (const fullPath in normalisedRefs) {
|
|
68
|
-
const page = normalisedRefs[fullPath];
|
|
69
|
-
try {
|
|
70
|
-
const resolved = yield refParser.dereference(String(fullPath), page, {
|
|
71
|
-
resolve,
|
|
72
|
-
dereference: { circular: false }
|
|
73
|
-
});
|
|
74
|
-
normalisedRefs[fullPath] = Object.assign(Object.assign({}, page), resolved);
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
console.warn(`Error resolving ref(s) for page '${fullPath}'. ${e.message.replace(/\.$/, '')} in '${e.source}'`);
|
|
78
|
-
throw e;
|
|
79
|
-
}
|
|
44
|
+
async afterUpdate(mutableFilesystem, { ignorePages, globalFilesystem, serialiser, pageExtensions, globalConfig }) {
|
|
45
|
+
mutableFilesystem.__internal_do_not_use_addReadFileHook(async (pagePath, fileData) => {
|
|
46
|
+
if (globalConfig.data.globalRefs[pagePath]) {
|
|
47
|
+
const expandedRefs = await normaliseRefs(String(pagePath), globalConfig.data.globalRefs[pagePath], globalFilesystem, pageExtensions, ignorePages);
|
|
48
|
+
const page = await serialiser.deserialise(pagePath, fileData);
|
|
49
|
+
const normalisedRef = { ...page, ...expandedRefs };
|
|
50
|
+
const resolve = createRefResolver({
|
|
51
|
+
[pagePath]: normalisedRef
|
|
52
|
+
}, serialiser, globalFilesystem);
|
|
53
|
+
const refParser = new $RefParser();
|
|
54
|
+
try {
|
|
55
|
+
const resolved = await refParser.dereference(String(pagePath), normalisedRef, {
|
|
56
|
+
resolve,
|
|
57
|
+
dereference: { circular: false }
|
|
58
|
+
});
|
|
59
|
+
const serialisedPage = await serialiser.serialise(pagePath, {
|
|
60
|
+
...normalisedRef,
|
|
61
|
+
...resolved
|
|
62
|
+
});
|
|
63
|
+
return serialisedPage;
|
|
80
64
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
catch (e) {
|
|
66
|
+
console.warn(`Error resolving ref(s) for page '${pagePath}'. ${e.message.replace(/\.$/, '')} in '${e.source}'`);
|
|
67
|
+
throw e;
|
|
84
68
|
}
|
|
85
69
|
}
|
|
70
|
+
return fileData;
|
|
86
71
|
});
|
|
87
72
|
},
|
|
88
|
-
$
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
async $beforeSend(mutableFilesystem, { config, serialiser, pageExtensions, ignorePages }) {
|
|
74
|
+
// Prevent any more refs being set after this lifecycle has been called - as they won't take effect
|
|
75
|
+
config.setRef = () => {
|
|
76
|
+
throw new Error('Cannot set refs after `RefPlugin` has reached `$beforeSend` lifecycle phase.');
|
|
77
|
+
};
|
|
78
|
+
const normalisedRefs = {};
|
|
79
|
+
if (config.data.refs) {
|
|
80
|
+
// First pass of refs, normalises any $ref entries to expand wildcards
|
|
81
|
+
for (const fullPath in config.data.refs) {
|
|
82
|
+
const page = await serialiser.deserialise(fullPath, await mutableFilesystem.promises.readFile(fullPath));
|
|
83
|
+
const expandedRefs = await normaliseRefs(String(fullPath), config.data.refs[fullPath], mutableFilesystem, pageExtensions, ignorePages);
|
|
84
|
+
normalisedRefs[fullPath] = deepmerge(page, expandedRefs);
|
|
85
|
+
}
|
|
86
|
+
const resolve = createRefResolver(normalisedRefs, serialiser, mutableFilesystem);
|
|
87
|
+
const refParser = new $RefParser();
|
|
88
|
+
// Second pass of refs, resolves the refs
|
|
89
|
+
for (const fullPath in normalisedRefs) {
|
|
90
|
+
const page = normalisedRefs[fullPath];
|
|
91
|
+
try {
|
|
92
|
+
const resolved = await refParser.dereference(String(fullPath), page, {
|
|
93
|
+
resolve,
|
|
94
|
+
dereference: { circular: false }
|
|
95
|
+
});
|
|
96
|
+
normalisedRefs[fullPath] = { ...page, ...resolved };
|
|
94
97
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
config.setRef(page.fullPath, ...ref);
|
|
99
|
-
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
console.warn(`Error resolving ref(s) for page '${fullPath}'. ${e.message.replace(/\.$/, '')} in '${e.source}'`);
|
|
100
|
+
throw e;
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
exports.default = $RefPlugin;
|
|
107
|
-
function createRefResolver(normalisedRefs, serialiser, mutableFilesystem) {
|
|
108
|
-
return {
|
|
109
|
-
file: {
|
|
110
|
-
canRead: true,
|
|
111
|
-
order: 1,
|
|
112
|
-
read(file, callback) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
try {
|
|
115
|
-
const refedPage = normalisedRefs[file.url] ||
|
|
116
|
-
(yield serialiser.deserialise(file.url, yield mutableFilesystem.promises.readFile(file.url)));
|
|
117
|
-
return callback(null, (0, omit_1.default)(refedPage, 'content'));
|
|
118
|
-
}
|
|
119
|
-
catch (e) {
|
|
120
|
-
return callback(e, null);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
103
|
+
// Third pass, write out the files
|
|
104
|
+
for (const fullPath in normalisedRefs) {
|
|
105
|
+
await mutableFilesystem.promises.writeFile(fullPath, await serialiser.serialise(fullPath, normalisedRefs[fullPath]));
|
|
123
106
|
}
|
|
124
107
|
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
108
|
+
},
|
|
109
|
+
async $afterSource(pages, { config, ignorePages, pageExtensions }) {
|
|
110
|
+
const isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
111
|
+
for (const page of pages) {
|
|
112
|
+
if (!isNonHiddenPage(page.fullPath)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const refs = findKeys(page, '$ref');
|
|
116
|
+
if (refs.length) {
|
|
117
|
+
for (const ref of refs) {
|
|
118
|
+
config.setRef(page.fullPath, ...ref);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
135
121
|
}
|
|
136
|
-
return
|
|
137
|
-
}
|
|
122
|
+
return pages;
|
|
123
|
+
}
|
|
138
124
|
};
|
|
139
|
-
|
|
140
|
-
const extTest = new RegExp(`${pageExtensions.map(escapeRegExp_1.default).join('|')}$`);
|
|
141
|
-
const ignoreTest = new RegExp(`${ignorePages.map(escapeRegExp_1.default).join('|')}$`);
|
|
142
|
-
return file => {
|
|
143
|
-
return !ignoreTest.test(file) && extTest.test(file) && !path_1.default.basename(file).startsWith('.');
|
|
144
|
-
};
|
|
145
|
-
}
|
|
125
|
+
export default $RefPlugin;
|
|
146
126
|
//# sourceMappingURL=$RefPlugin.js.map
|
package/dist/$RefPlugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$RefPlugin.js","sourceRoot":"","sources":["../src/$RefPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"$RefPlugin.js","sourceRoot":"","sources":["../src/$RefPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,aAAa,MAAM,0BAA0B,CAAC;AAErD,SAAS,iBAAiB,CAAC,cAAc,EAAE,UAAU,EAAE,iBAAiB;IACtE,OAAO;QACL,IAAI,EAAE;YAC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KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE;QAC/D,MAAM,eAAe,GAAG,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAEpE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBACnC,SAAS;aACV;YACD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAEpC,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;oBACtB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC,CAAC;iBACtC;aACF;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';
|
|
2
|
+
interface TagPluginPage extends Page {
|
|
3
|
+
tags?: string[];
|
|
4
|
+
}
|
|
5
|
+
interface TagPluginConfigData {
|
|
6
|
+
tagRefs: {
|
|
7
|
+
[key: string]: {
|
|
8
|
+
$$path: string[];
|
|
9
|
+
$$value: string[];
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
globalRefs: {
|
|
13
|
+
[key: string]: {
|
|
14
|
+
$$path: string[];
|
|
15
|
+
$$value: string[];
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
subscribedTags: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Plugin that scrapes `$tag` from page metadata and also applies all aliases stored in `config.data.tags`.
|
|
22
|
+
* Tags ultimately resolve down into refs, but are different from normal refs, in that they are applied to the
|
|
23
|
+
* union filesystem (all merged filesystems), not to the individual source filesystem that they were defined on.
|
|
24
|
+
* Other plugins can use `setData()` and modify the `tags` property, to apply new global refs, as long as
|
|
25
|
+
* they do so before this plugin has reaches `$beforeSend`
|
|
26
|
+
*/
|
|
27
|
+
declare const $TagPlugin: PluginType<TagPluginPage, unknown, TagPluginConfigData>;
|
|
28
|
+
export default $TagPlugin;
|