@astrojs/mdx 4.0.4 → 4.0.6

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/server.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { NamedSSRLoadedRendererValue } from 'astro';
2
- export declare function check(): Promise<boolean>;
2
+ export declare function check(Component: any, props: any, { default: children, ...slotted }?: {
3
+ default?: null | undefined;
4
+ }): Promise<any>;
3
5
  export declare function renderToStaticMarkup(this: any, Component: any, props?: {}, { default: children, ...slotted }?: {
4
6
  default?: null | undefined;
5
7
  }): Promise<{
package/dist/server.js CHANGED
@@ -1,8 +1,20 @@
1
1
  import { AstroError } from "astro/errors";
2
- import { jsx } from "astro/jsx-runtime";
2
+ import { AstroJSX, jsx } from "astro/jsx-runtime";
3
3
  import { renderJSX } from "astro/runtime/server/index.js";
4
4
  const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
5
- async function check() {
5
+ async function check(Component, props, { default: children = null, ...slotted } = {}) {
6
+ if (typeof Component !== "function") return false;
7
+ const slots = {};
8
+ for (const [key, value] of Object.entries(slotted)) {
9
+ const name = slotName(key);
10
+ slots[name] = value;
11
+ }
12
+ try {
13
+ const result = await Component({ ...props, ...slots, children });
14
+ return result[AstroJSX];
15
+ } catch (e) {
16
+ throwEnhancedErrorIfMdxComponent(e, Component);
17
+ }
6
18
  return false;
7
19
  }
8
20
  async function renderToStaticMarkup(Component, props = {}, { default: children = null, ...slotted } = {}) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/mdx",
3
3
  "description": "Add support for MDX pages in your Astro site",
4
- "version": "4.0.4",
4
+ "version": "4.0.6",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -30,9 +30,9 @@
30
30
  "dependencies": {
31
31
  "@mdx-js/mdx": "^3.1.0",
32
32
  "acorn": "^8.14.0",
33
- "es-module-lexer": "^1.5.4",
33
+ "es-module-lexer": "^1.6.0",
34
34
  "estree-util-visit": "^2.0.0",
35
- "hast-util-to-html": "^9.0.3",
35
+ "hast-util-to-html": "^9.0.4",
36
36
  "kleur": "^4.1.5",
37
37
  "rehype-raw": "^7.0.0",
38
38
  "remark-gfm": "^4.0.0",
@@ -40,7 +40,7 @@
40
40
  "source-map": "^0.7.4",
41
41
  "unist-util-visit": "^5.0.0",
42
42
  "vfile": "^6.0.3",
43
- "@astrojs/markdown-remark": "6.0.1"
43
+ "@astrojs/markdown-remark": "6.0.2"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "astro": "^5.0.0"
@@ -50,9 +50,9 @@
50
50
  "@types/hast": "^3.0.4",
51
51
  "@types/mdast": "^4.0.4",
52
52
  "cheerio": "1.0.0",
53
- "linkedom": "^0.18.5",
53
+ "linkedom": "^0.18.6",
54
54
  "mdast-util-mdx": "^3.0.0",
55
- "mdast-util-mdx-jsx": "^3.1.3",
55
+ "mdast-util-mdx-jsx": "^3.2.0",
56
56
  "mdast-util-to-string": "^4.0.0",
57
57
  "rehype-mathjax": "^6.0.0",
58
58
  "rehype-pretty-code": "^0.14.0",
@@ -60,10 +60,10 @@
60
60
  "remark-rehype": "^11.1.1",
61
61
  "remark-shiki-twoslash": "^3.1.3",
62
62
  "remark-toc": "^9.0.0",
63
- "shiki": "^1.23.1",
63
+ "shiki": "^1.26.2",
64
64
  "unified": "^11.0.5",
65
- "vite": "^6.0.5",
66
- "astro": "5.1.4",
65
+ "vite": "^6.0.7",
66
+ "astro": "5.1.7",
67
67
  "astro-scripts": "0.0.14"
68
68
  },
69
69
  "engines": {