@jpmorganchase/mosaic-site-middleware 0.1.0-beta.85 → 0.1.0-beta.87
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/compileMdx.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function compileMDX(content: any, parseFrontmatter?: boolean, rehypePlugins?: never[], remarkPlugins?: never[]): Promise<import("next-mdx-remote/dist/types.js").MDXRemoteSerializeResult<Record<string, unknown>, Record<string,
|
|
1
|
+
export declare function compileMDX(content: any, parseFrontmatter?: boolean, rehypePlugins?: never[], remarkPlugins?: never[]): Promise<import("next-mdx-remote/dist/types.js").MDXRemoteSerializeResult<Record<string, unknown>, Record<string, unknown>>>;
|
package/dist/compileMdx.js
CHANGED
|
@@ -5,8 +5,8 @@ import { codeBlocks } from './plugins/codeBlocks.js';
|
|
|
5
5
|
export async function compileMDX(content, parseFrontmatter = true, rehypePlugins = [], remarkPlugins = []) {
|
|
6
6
|
const mdxSource = await serialize(content, {
|
|
7
7
|
mdxOptions: {
|
|
8
|
-
rehypePlugins: [rehypeSlug, ...remarkPlugins],
|
|
9
|
-
remarkPlugins: [
|
|
8
|
+
rehypePlugins: [codeBlocks, rehypeSlug, ...remarkPlugins],
|
|
9
|
+
remarkPlugins: [remarkGfm, ...rehypePlugins]
|
|
10
10
|
},
|
|
11
11
|
parseFrontmatter
|
|
12
12
|
});
|
package/dist/compileMdx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileMdx.js","sourceRoot":"","sources":["../src/compileMdx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAO,EACP,gBAAgB,GAAG,IAAI,EACvB,aAAa,GAAG,EAAE,EAClB,aAAa,GAAG,EAAE;IAElB,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE;QACzC,UAAU,EAAE;YACV,aAAa,EAAE,CAAC,UAAU,EAAE,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"compileMdx.js","sourceRoot":"","sources":["../src/compileMdx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAO,EACP,gBAAgB,GAAG,IAAI,EACvB,aAAa,GAAG,EAAE,EAClB,aAAa,GAAG,EAAE;IAElB,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE;QACzC,UAAU,EAAE;YACV,aAAa,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;YACzD,aAAa,EAAE,CAAC,SAAS,EAAE,GAAG,aAAa,CAAC;SAC7C;QACD,gBAAgB;KACjB,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Root } from 'hast';
|
|
2
|
+
import type { Plugin, Transformer } from 'unified';
|
|
2
3
|
/**
|
|
3
|
-
* Modified from: https://github.com/remcohaszing/
|
|
4
|
+
* Modified from: https://github.com/remcohaszing/rehype-mdx-code-props/blob/main/src/rehype-mdx-code-props.ts
|
|
4
5
|
*
|
|
5
6
|
* Custom meta parser for codefences that have extra params. e.g.
|
|
6
7
|
* ```jsx filename="hello.jsx"
|
|
@@ -13,10 +14,10 @@ import { Plugin, Transformer } from 'unified';
|
|
|
13
14
|
* meta.data.someStringOnlyAvailableAtRuntime
|
|
14
15
|
* ```
|
|
15
16
|
*/
|
|
16
|
-
export declare const transformer: Transformer
|
|
17
|
+
export declare const transformer: Transformer<Root>;
|
|
17
18
|
/**
|
|
18
19
|
* A markdown plugin for transforming code metadata.
|
|
19
20
|
*
|
|
20
21
|
* @returns A unified transformer.
|
|
21
22
|
*/
|
|
22
|
-
export declare const codeBlocks: Plugin<[]>;
|
|
23
|
+
export declare const codeBlocks: Plugin<[], Root>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { visitParents } from 'unist-util-visit-parents';
|
|
2
|
+
import { fromMarkdown } from 'mdast-util-from-markdown';
|
|
3
|
+
import { mdxjs } from 'micromark-extension-mdxjs';
|
|
4
|
+
import { mdxFromMarkdown } from 'mdast-util-mdx';
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import { propertiesToMdxJsxAttributes } from 'hast-util-properties-to-mdx-jsx-attributes';
|
|
5
7
|
/**
|
|
6
|
-
* Modified from: https://github.com/remcohaszing/
|
|
8
|
+
* Modified from: https://github.com/remcohaszing/rehype-mdx-code-props/blob/main/src/rehype-mdx-code-props.ts
|
|
7
9
|
*
|
|
8
10
|
* Custom meta parser for codefences that have extra params. e.g.
|
|
9
11
|
* ```jsx filename="hello.jsx"
|
|
@@ -17,24 +19,47 @@ const parser = Parser.extend(jsx());
|
|
|
17
19
|
* ```
|
|
18
20
|
*/
|
|
19
21
|
export const transformer = ast => {
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
+
visitParents(ast, 'element', (node, ancestors) => {
|
|
23
|
+
if (node.tagName !== 'code') {
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const meta = node.data?.meta;
|
|
27
|
+
if (typeof meta !== 'string' || !meta) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
31
|
+
let parent = ancestors.at(-1);
|
|
32
|
+
if (parent.type !== 'element') {
|
|
33
|
+
return;
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
if (parent.tagName !== 'pre') {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (parent.children.length !== 1) {
|
|
39
|
+
return;
|
|
32
40
|
}
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
|
|
41
|
+
const child = parent;
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43
|
+
parent = ancestors.at(-2);
|
|
44
|
+
// Limit eval to just basic strings that start with "meta."
|
|
45
|
+
// const isEval =
|
|
46
|
+
// /(^| )eval(="true"| |$)/.test(meta) && /^meta\.[a-z0-9_[\].$"']+$/i.test(child.value);
|
|
47
|
+
//
|
|
48
|
+
// let code;
|
|
49
|
+
// if (!isEval) {
|
|
50
|
+
// code = JSON.stringify(`${child.value}\n`);
|
|
51
|
+
// } else {
|
|
52
|
+
// code = child.value;
|
|
53
|
+
// }
|
|
54
|
+
const replacement = fromMarkdown(`<${child.tagName} ${meta} />`, {
|
|
55
|
+
extensions: [mdxjs()],
|
|
56
|
+
mdastExtensions: [mdxFromMarkdown()]
|
|
57
|
+
}).children[0];
|
|
58
|
+
replacement.children = child.children;
|
|
59
|
+
replacement.data = child.data;
|
|
60
|
+
replacement.position = child.position;
|
|
61
|
+
replacement.attributes.unshift(...propertiesToMdxJsxAttributes(child.properties, { elementAttributeNameCase: 'react' }));
|
|
62
|
+
parent.children[parent.children.indexOf(child)] = replacement;
|
|
38
63
|
});
|
|
39
64
|
};
|
|
40
65
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codeBlocks.js","sourceRoot":"","sources":["../../src/plugins/codeBlocks.ts"],"names":[],"mappings":"
|
|
1
|
+
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X,wBAAwB;QACxB,IAAI;QAEJ,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,KAAK,CAAC,OAAO,IAAI,IAAI,KAAK,EAAE;YAC/D,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC;YACrB,eAAe,EAAE,CAAC,eAAe,EAAE,CAAC;SACrC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAA0B,CAAC;QACxC,WAAW,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QACtC,WAAW,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAC9B,WAAW,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QACtC,WAAW,CAAC,UAAU,CAAC,OAAO,CAC5B,GAAG,4BAA4B,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,wBAAwB,EAAE,OAAO,EAAE,CAAC,CACzF,CAAC;QAEF,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,WAAW,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAqB,GAAG,EAAE,CAAC,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-site-middleware",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.87",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Mosaic - Site middleware",
|
|
6
6
|
"repository": {
|
|
@@ -30,29 +30,35 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"aws-sdk-client-mock": "^2.0.1",
|
|
33
|
-
"
|
|
34
|
-
"mock-fs": "^
|
|
33
|
+
"vitest-fetch-mock": "^0.3.0",
|
|
34
|
+
"mock-fs": "^5.0.0",
|
|
35
35
|
"typescript": "^4.8.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@aws-sdk/client-s3": "^3.
|
|
39
|
-
"@jpmorganchase/mosaic-schemas": "^0.1.0-beta.
|
|
40
|
-
"@jpmorganchase/mosaic-store": "^0.1.0-beta.
|
|
41
|
-
"@jpmorganchase/mosaic-types": "^0.1.0-beta.
|
|
38
|
+
"@aws-sdk/client-s3": "^3.645.0",
|
|
39
|
+
"@jpmorganchase/mosaic-schemas": "^0.1.0-beta.87",
|
|
40
|
+
"@jpmorganchase/mosaic-store": "^0.1.0-beta.87",
|
|
41
|
+
"@jpmorganchase/mosaic-types": "^0.1.0-beta.87",
|
|
42
42
|
"@types/mdast": "^3.0.0",
|
|
43
43
|
"acorn": "^8.0.0",
|
|
44
44
|
"acorn-jsx": "^5.0.0",
|
|
45
45
|
"deepmerge": "^4.2.2",
|
|
46
|
+
"hast-util-properties-to-mdx-jsx-attributes": "^1.0.0",
|
|
46
47
|
"jwt-decode": "^3.1.2",
|
|
47
48
|
"lodash-es": "^4.17.21",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
49
|
+
"mdast-util-mdx": "^3.0.0",
|
|
50
|
+
"mdast-util-mdx-jsx": "^3.0.0",
|
|
51
|
+
"mdast-util-from-markdown": "^2.0.0",
|
|
52
|
+
"micromark-extension-mdxjs": "^3.0.0",
|
|
53
|
+
"next": "^14.0.0",
|
|
54
|
+
"next-mdx-remote": "^5.0.0",
|
|
50
55
|
"node-cookie": "^2.1.2",
|
|
51
56
|
"react-error-boundary": "^3.1.4",
|
|
52
|
-
"remark-gfm": "
|
|
53
|
-
"rehype-slug": "^
|
|
54
|
-
"unified": "^
|
|
55
|
-
"unist-util-visit": "^
|
|
57
|
+
"remark-gfm": "^4.0.0",
|
|
58
|
+
"rehype-slug": "^6.0.0",
|
|
59
|
+
"unified": "^11.0.0",
|
|
60
|
+
"unist-util-visit": "^5.0.0",
|
|
61
|
+
"unist-util-visit-parents": "^6.0.0",
|
|
56
62
|
"warning": "^3.0.0"
|
|
57
63
|
},
|
|
58
64
|
"peerDependencies": {
|