@jpmorganchase/mosaic-plugins 0.1.0-beta.6 → 0.1.0-beta.61
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 +39 -48
- package/dist/$AliasPlugin.js.map +1 -1
- package/dist/$CodeModPlugin.d.ts +7 -0
- package/dist/$CodeModPlugin.js +18 -30
- package/dist/$CodeModPlugin.js.map +1 -1
- package/dist/$RefPlugin.d.ts +31 -0
- package/dist/$RefPlugin.js +131 -127
- package/dist/$RefPlugin.js.map +1 -1
- package/dist/$TagPlugin.d.ts +28 -0
- package/dist/$TagPlugin.js +37 -56
- package/dist/$TagPlugin.js.map +1 -1
- package/dist/BreadcrumbsPlugin.d.ts +19 -0
- package/dist/BreadcrumbsPlugin.js +84 -32
- 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 +92 -0
- package/dist/FragmentPlugin.js.map +1 -0
- package/dist/LazyPagePlugin.d.ts +14 -0
- package/dist/LazyPagePlugin.js +57 -87
- package/dist/LazyPagePlugin.js.map +1 -1
- package/dist/PagesWithoutFileExtPlugin.d.ts +9 -0
- package/dist/PagesWithoutFileExtPlugin.js +19 -31
- 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 +36 -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 +134 -38
- package/dist/SharedConfigPlugin.js.map +1 -1
- package/dist/SidebarPlugin.d.ts +44 -0
- package/dist/SidebarPlugin.js +246 -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/PluginError.d.ts +7 -0
- package/dist/utils/PluginError.js +13 -0
- package/dist/utils/PluginError.js.map +1 -0
- package/dist/utils/mergePageConent.d.ts +16 -0
- package/dist/utils/mergePageConent.js +23 -0
- package/dist/utils/mergePageConent.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/dist/utils/sortSidebarData.d.ts +19 -0
- package/dist/utils/sortSidebarData.js +35 -0
- package/dist/utils/sortSidebarData.js.map +1 -0
- package/package.json +48 -15
- package/CHANGELOG.md +0 -58
- package/dist/NextPrevPagePlugin.js +0 -63
- 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,29 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
import PluginError from './utils/PluginError.js';
|
|
4
|
+
function createPageTest(ignorePages, pageExtensions) {
|
|
5
|
+
const extTest = new RegExp(`${pageExtensions.map(escapeRegExp).join('|')}$`);
|
|
6
|
+
const ignoreTest = new RegExp(`${ignorePages.map(escapeRegExp).join('|')}$`);
|
|
7
|
+
return file => !ignoreTest.test(file) && extTest.test(file) && !path.basename(file).startsWith('.');
|
|
8
|
+
}
|
|
17
9
|
/**
|
|
18
10
|
* Plugin that scrapes `aliases` from page metadata and also applies all aliases stored in `config.data.aliases`
|
|
19
11
|
* Other plugins can use `setAliases` to apply new aliases, as long as they call it before this plugin has reaches `$beforeSend`
|
|
20
12
|
*/
|
|
21
13
|
const $AliasPlugin = {
|
|
22
|
-
$afterSource(pages, { config, ignorePages, pageExtensions }
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
async $afterSource(pages, { config, ignorePages, pageExtensions }) {
|
|
15
|
+
const isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
16
|
+
// Group together all aliases defined in the frontmatter and store them in the alias config object
|
|
17
|
+
for (const page of pages) {
|
|
18
|
+
try {
|
|
27
19
|
if (!isNonHiddenPage(page.fullPath)) {
|
|
28
20
|
continue;
|
|
29
21
|
}
|
|
@@ -32,44 +24,43 @@ const $AliasPlugin = {
|
|
|
32
24
|
}
|
|
33
25
|
delete page.aliases;
|
|
34
26
|
}
|
|
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;
|
|
27
|
+
catch (e) {
|
|
28
|
+
throw new PluginError(e.message, page.fullPath);
|
|
46
29
|
}
|
|
47
|
-
|
|
30
|
+
}
|
|
31
|
+
return pages;
|
|
32
|
+
},
|
|
33
|
+
async $beforeSend(mutableFilesystem, { config }) {
|
|
34
|
+
// Prevent any more aliases being set after this lifecycle has been called - as they won't take effect
|
|
35
|
+
config.setAliases = () => {
|
|
36
|
+
throw new Error('Cannot set aliases after `$AliasPlugin` has reached `$beforeSend` lifecycle phase.');
|
|
37
|
+
};
|
|
38
|
+
if (!config.data.aliases) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
for (const fullPath in config.data.aliases) {
|
|
42
|
+
try {
|
|
48
43
|
for (const alias of config.data.aliases[fullPath]) {
|
|
49
|
-
const aliasPath =
|
|
50
|
-
const aliasDir =
|
|
51
|
-
if (!(
|
|
52
|
-
|
|
44
|
+
const aliasPath = path.posix.resolve(path.dirname(fullPath), alias).toLowerCase();
|
|
45
|
+
const aliasDir = path.dirname(aliasPath);
|
|
46
|
+
if (!(await mutableFilesystem.promises.exists(aliasDir))) {
|
|
47
|
+
await mutableFilesystem.promises.mkdir(aliasDir, {
|
|
53
48
|
recursive: true
|
|
54
49
|
});
|
|
55
50
|
}
|
|
56
|
-
if (!(
|
|
57
|
-
|
|
51
|
+
if (!(await mutableFilesystem.promises.exists(aliasPath))) {
|
|
52
|
+
await mutableFilesystem.promises.symlink(fullPath, aliasPath);
|
|
58
53
|
}
|
|
59
54
|
else {
|
|
60
55
|
console.warn(`Alias '${aliasPath}' already exists. Is there a duplicate alias, or a page with the same name but different file extensions?`);
|
|
61
56
|
}
|
|
62
57
|
}
|
|
63
58
|
}
|
|
64
|
-
|
|
59
|
+
catch (e) {
|
|
60
|
+
throw new PluginError(e.message, fullPath);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
65
63
|
}
|
|
66
64
|
};
|
|
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
|
-
}
|
|
65
|
+
export default $AliasPlugin;
|
|
75
66
|
//# 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;AAEzC,OAAO,WAAW,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;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,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
import PluginError from './utils/PluginError.js';
|
|
4
|
+
function createPageTest(ignorePages, pageExtensions) {
|
|
5
|
+
const extTest = new RegExp(`${pageExtensions.map(escapeRegExp).join('|')}$`);
|
|
6
|
+
const ignoreTest = new RegExp(`${ignorePages.map(escapeRegExp).join('|')}$`);
|
|
7
|
+
return file => !ignoreTest.test(file) && extTest.test(file) && !path.basename(file).startsWith('.');
|
|
8
|
+
}
|
|
17
9
|
const $CodeModPlugin = {
|
|
18
|
-
$afterSource(pages, { ignorePages, pageExtensions }) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
async $afterSource(pages, { ignorePages, pageExtensions }) {
|
|
11
|
+
const isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
12
|
+
for (const page of pages) {
|
|
13
|
+
try {
|
|
22
14
|
if (!isNonHiddenPage(page.fullPath)) {
|
|
23
15
|
continue;
|
|
24
16
|
}
|
|
@@ -27,16 +19,12 @@ const $CodeModPlugin = {
|
|
|
27
19
|
page.frameOverrides = { $ref: '#/sharedConfig' };
|
|
28
20
|
}
|
|
29
21
|
}
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
catch (e) {
|
|
23
|
+
throw new PluginError(e.message, page.fullPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return pages;
|
|
32
27
|
}
|
|
33
28
|
};
|
|
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
|
-
}
|
|
29
|
+
export default $CodeModPlugin;
|
|
42
30
|
//# 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;AACxB,OAAO,WAAW,MAAM,wBAAwB,CAAC;AAEjD,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;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;
|
package/dist/$RefPlugin.js
CHANGED
|
@@ -1,146 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import { reduce, omit, escapeRegExp } from 'lodash-es';
|
|
4
|
+
import { $RefParser } from '@apidevtools/json-schema-ref-parser';
|
|
5
|
+
import deepmerge from 'deepmerge';
|
|
6
|
+
import normaliseRefs from './utils/normaliseRefs.js';
|
|
7
|
+
import PluginError from './utils/PluginError.js';
|
|
8
|
+
import { mergePageContent } from './utils/mergePageConent.js';
|
|
9
|
+
const isWindows = /^win/.test(os.platform());
|
|
10
|
+
const windowsDrivePattern = /^([a-z]):/i;
|
|
11
|
+
/**
|
|
12
|
+
* The JSON Schema Ref parser turns refs into URLs.
|
|
13
|
+
* When running on Windows it adds in the drive letter to the beginning of the resolved ref filepath
|
|
14
|
+
*
|
|
15
|
+
* WE DON"T WANT THIS
|
|
16
|
+
*
|
|
17
|
+
* Regardless of platform, Mosaic uses an in-memory fs so we don't need drive letters.
|
|
18
|
+
* We need the path as it is in the mosaic fs.
|
|
19
|
+
*/
|
|
20
|
+
function normaliseWindowsPath(url) {
|
|
21
|
+
const drivePart = windowsDrivePattern.exec(url)?.[0];
|
|
22
|
+
return drivePart ? url.slice(drivePart.length) : url;
|
|
23
|
+
}
|
|
24
|
+
function createRefResolver(normalisedRefs, serialiser, mutableFilesystem) {
|
|
25
|
+
return {
|
|
26
|
+
file: {
|
|
27
|
+
canRead: true,
|
|
28
|
+
order: 1,
|
|
29
|
+
async read(file, callback) {
|
|
30
|
+
try {
|
|
31
|
+
const filePath = isWindows ? normaliseWindowsPath(file.url) : file.url;
|
|
32
|
+
const refedPage = normalisedRefs[filePath] ||
|
|
33
|
+
(await serialiser.deserialise(filePath, await mutableFilesystem.promises.readFile(filePath)));
|
|
34
|
+
return callback(null, omit(refedPage, 'content'));
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
return callback(e, null);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const findKeys = (obj, targetProp, pathParts = []) => reduce(obj, (found, value, key) => {
|
|
44
|
+
if (key === targetProp) {
|
|
45
|
+
return found.concat([[pathParts.concat(String(key)), value]]);
|
|
46
|
+
}
|
|
47
|
+
if (typeof value === 'object') {
|
|
48
|
+
const foundParents = findKeys(value, targetProp, pathParts.concat(String(key)));
|
|
49
|
+
return found.concat(foundParents);
|
|
50
|
+
}
|
|
51
|
+
return found;
|
|
52
|
+
}, []);
|
|
53
|
+
function createPageTest(ignorePages, pageExtensions) {
|
|
54
|
+
const extTest = new RegExp(`${pageExtensions.map(escapeRegExp).join('|')}$`);
|
|
55
|
+
const ignoreTest = new RegExp(`${ignorePages.map(escapeRegExp).join('|')}$`);
|
|
56
|
+
return file => !ignoreTest.test(file) && extTest.test(file) && !path.basename(file).startsWith('.');
|
|
57
|
+
}
|
|
21
58
|
/**
|
|
22
59
|
* Plugin that scrapes `$ref` properties from page metadata and also applies all refs stored in `config.data.refs`.
|
|
23
60
|
* Other plugins can use `setRef` to apply new refs, as long as they call it before this plugin has reaches `$beforeSend`
|
|
24
61
|
*/
|
|
25
62
|
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
|
-
|
|
63
|
+
async afterUpdate(mutableFilesystem, { ignorePages, globalFilesystem, serialiser, pageExtensions, globalConfig }) {
|
|
64
|
+
mutableFilesystem.__internal_do_not_use_addReadFileHook(async (pagePath, fileData) => {
|
|
65
|
+
if (globalConfig.data.globalRefs[pagePath]) {
|
|
66
|
+
const expandedRefs = await normaliseRefs(String(pagePath), globalConfig.data.globalRefs[pagePath], globalFilesystem, pageExtensions, ignorePages);
|
|
67
|
+
const page = await serialiser.deserialise(pagePath, fileData);
|
|
68
|
+
const normalisedRef = mergePageContent(page, expandedRefs);
|
|
69
|
+
const resolve = createRefResolver({
|
|
70
|
+
[pagePath]: normalisedRef
|
|
71
|
+
}, serialiser, globalFilesystem);
|
|
72
|
+
const refParser = new $RefParser();
|
|
73
|
+
try {
|
|
74
|
+
const resolved = await refParser.dereference(String(pagePath), normalisedRef, {
|
|
75
|
+
resolve,
|
|
76
|
+
dereference: { circular: false }
|
|
77
|
+
});
|
|
78
|
+
const serialisedPage = await serialiser.serialise(pagePath, {
|
|
79
|
+
...normalisedRef,
|
|
80
|
+
...resolved
|
|
81
|
+
});
|
|
82
|
+
return serialisedPage;
|
|
46
83
|
}
|
|
47
|
-
|
|
48
|
-
|
|
84
|
+
catch (e) {
|
|
85
|
+
console.warn(`Error resolving ref(s) for page '${pagePath}'. ${e.message.replace(/\.$/, '')} in '${e.source}'`);
|
|
86
|
+
throw new PluginError(e.message, page.fullPath);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return fileData;
|
|
49
90
|
});
|
|
50
91
|
},
|
|
51
|
-
$beforeSend(mutableFilesystem, { config, serialiser, pageExtensions, ignorePages }
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
92
|
+
async $beforeSend(mutableFilesystem, { config, serialiser, pageExtensions, ignorePages }) {
|
|
93
|
+
// Prevent any more refs being set after this lifecycle has been called - as they won't take effect
|
|
94
|
+
config.setRef = () => {
|
|
95
|
+
throw new Error('Cannot set refs after `RefPlugin` has reached `$beforeSend` lifecycle phase.');
|
|
96
|
+
};
|
|
97
|
+
const normalisedRefs = {};
|
|
98
|
+
if (config.data.refs) {
|
|
99
|
+
// First pass of refs, normalises any $ref entries to expand wildcards
|
|
100
|
+
for (const fullPath in config.data.refs) {
|
|
101
|
+
const page = await serialiser.deserialise(fullPath, await mutableFilesystem.promises.readFile(fullPath));
|
|
102
|
+
try {
|
|
103
|
+
const expandedRefs = await normaliseRefs(String(fullPath), config.data.refs[fullPath], mutableFilesystem, pageExtensions, ignorePages);
|
|
104
|
+
normalisedRefs[fullPath] = deepmerge(page, expandedRefs);
|
|
63
105
|
}
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
}
|
|
80
|
-
}
|
|
81
|
-
// Third pass, write out the files
|
|
82
|
-
for (const fullPath in normalisedRefs) {
|
|
83
|
-
yield mutableFilesystem.promises.writeFile(fullPath, yield serialiser.serialise(fullPath, normalisedRefs[fullPath]));
|
|
106
|
+
catch (e) {
|
|
107
|
+
throw new PluginError(e.message, page.fullPath);
|
|
84
108
|
}
|
|
85
109
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
110
|
+
const resolve = createRefResolver(normalisedRefs, serialiser, mutableFilesystem);
|
|
111
|
+
const refParser = new $RefParser();
|
|
112
|
+
// Second pass of refs, resolves the refs
|
|
113
|
+
for (const fullPath in normalisedRefs) {
|
|
114
|
+
const page = normalisedRefs[fullPath];
|
|
115
|
+
try {
|
|
116
|
+
const resolved = await refParser.dereference(String(fullPath), page, {
|
|
117
|
+
resolve,
|
|
118
|
+
dereference: { circular: false }
|
|
119
|
+
});
|
|
120
|
+
normalisedRefs[fullPath] = { ...page, ...resolved };
|
|
94
121
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
config.setRef(page.fullPath, ...ref);
|
|
99
|
-
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
console.warn(`Error resolving ref(s) for page '${fullPath}'. ${e.message.replace(/\.$/, '')} in '${e.source}'`);
|
|
124
|
+
throw new PluginError(e.message, page.fullPath);
|
|
100
125
|
}
|
|
101
126
|
}
|
|
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
|
-
});
|
|
127
|
+
// Third pass, write out the files
|
|
128
|
+
for (const fullPath in normalisedRefs) {
|
|
129
|
+
await mutableFilesystem.promises.writeFile(fullPath, await serialiser.serialise(fullPath, normalisedRefs[fullPath]));
|
|
123
130
|
}
|
|
124
131
|
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
},
|
|
133
|
+
async $afterSource(pages, { config, ignorePages, pageExtensions }) {
|
|
134
|
+
const isNonHiddenPage = createPageTest(ignorePages, pageExtensions);
|
|
135
|
+
for (const page of pages) {
|
|
136
|
+
if (!isNonHiddenPage(page.fullPath)) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const refs = findKeys(page, '$ref');
|
|
140
|
+
if (refs.length) {
|
|
141
|
+
for (const ref of refs) {
|
|
142
|
+
config.setRef(page.fullPath, ...ref);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
135
145
|
}
|
|
136
|
-
return
|
|
137
|
-
}
|
|
146
|
+
return pages;
|
|
147
|
+
}
|
|
138
148
|
};
|
|
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
|
-
}
|
|
149
|
+
export default $RefPlugin;
|
|
146
150
|
//# 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,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,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;AACrD,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC7C,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAEzC;;;;;;;;GAQG;AACH,SAAS,oBAAoB,CAAC,GAAW;IACvC,MAAM,SAAS,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACrD,O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
|
|
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;
|