storybook 10.1.0-alpha.9 → 10.1.0-beta.0
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/_browser-chunks/Color-FTG7SQDA.js +1097 -0
- package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
- package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
- package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
- package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
- package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
- package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
- package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
- package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
- package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
- package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
- package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
- package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
- package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
- package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
- package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
- package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
- package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
- package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
- package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
- package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
- package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
- package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
- package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
- package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
- package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
- package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
- package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
- package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
- package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
- package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
- package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
- package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
- package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
- package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
- package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
- package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
- package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
- package/dist/_node-chunks/{builder-manager-SM3UWERX.js → builder-manager-BDAQHXFI.js} +510 -1019
- package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
- package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
- package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
- package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
- package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
- package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
- package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-BG4RDXG7.js} +8 -10
- package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
- package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
- package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
- package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-D6ND3TVY.js} +116 -276
- package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
- package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-EVK2SBW5.js} +292 -688
- package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
- package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-KVRF22SH.js} +469 -983
- package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
- package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-MMVV6DGG.js} +8133 -8887
- package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
- package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
- package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
- package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
- package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
- package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
- package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
- package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
- package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
- package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
- package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
- package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-YWV55YW3.js} +15 -24
- package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
- package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
- package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
- package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
- package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
- package/dist/actions/decorator.js +21 -42
- package/dist/actions/index.js +3 -3
- package/dist/babel/index.d.ts +671 -335
- package/dist/babel/index.js +10 -11
- package/dist/bin/core.js +601 -1548
- package/dist/bin/dispatcher.js +36 -36
- package/dist/bin/loader.js +24 -38
- package/dist/channels/index.js +98 -234
- package/dist/cli/index.d.ts +1479 -133
- package/dist/cli/index.js +30 -8540
- package/dist/client-logger/index.js +31 -61
- package/dist/common/index.d.ts +139 -62
- package/dist/common/index.js +66 -51
- package/dist/components/index.d.ts +575 -273
- package/dist/components/index.js +14863 -4313
- package/dist/core-events/index.js +2 -66
- package/dist/core-server/index.d.ts +3 -2
- package/dist/core-server/index.js +2908 -8518
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +2521 -5233
- package/dist/core-server/presets/common-override-preset.js +31 -60
- package/dist/core-server/presets/common-preset.js +663 -962
- package/dist/csf/index.js +534 -1179
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +6 -6
- package/dist/highlight/index.js +2 -2
- package/dist/instrumenter/index.js +199 -415
- package/dist/manager/globals-runtime.js +59044 -67141
- package/dist/manager/globals.js +2 -3
- package/dist/manager/manager-stores.d.ts +1 -0
- package/dist/manager/manager-stores.js +23 -0
- package/dist/manager/runtime.js +11511 -10953
- package/dist/manager-api/index.d.ts +1811 -2
- package/dist/manager-api/index.js +1348 -2401
- package/dist/manager-errors.d.ts +9 -0
- package/dist/manager-errors.js +3 -3
- package/dist/mocking-utils/index.d.ts +1126 -0
- package/dist/mocking-utils/index.js +1181 -0
- package/dist/node-logger/index.d.ts +192 -24
- package/dist/node-logger/index.js +23 -4471
- package/dist/preview/globals.js +2 -3
- package/dist/preview/runtime.js +10799 -22393
- package/dist/preview-api/index.d.ts +68 -69
- package/dist/preview-api/index.js +13 -13
- package/dist/preview-errors.d.ts +9 -0
- package/dist/preview-errors.js +4 -4
- package/dist/router/index.js +347 -899
- package/dist/server-errors.d.ts +34 -1
- package/dist/server-errors.js +17 -10
- package/dist/telemetry/index.d.ts +24 -3
- package/dist/telemetry/index.js +25 -24
- package/dist/test/index.js +6131 -11916
- package/dist/theming/create.d.ts +1 -0
- package/dist/theming/create.js +4 -4
- package/dist/theming/index.d.ts +3366 -2599
- package/dist/theming/index.js +501 -1091
- package/dist/types/index.d.ts +72 -8
- package/dist/types/index.js +27 -12
- package/dist/viewport/index.js +3 -3
- package/package.json +26 -17
- package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
- package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
- package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
- package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
- package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
- package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
- package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
- package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
- package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
- package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
- package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
- package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
- package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
- package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
- package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
- package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
- package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
- package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
- package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
- package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
- package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
- package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
- package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
- package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
- package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
- package/dist/_node-chunks/camelcase-H5QSGQLK.js +0 -18
- package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
- package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
- package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
- package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
- package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
- package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
- package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
- package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
- package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
- package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
- package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
- package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
- package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
- package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
- package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
- package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
- package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
- package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
- package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
- package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
- package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
- package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
- package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
- package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
- package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
- package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
- package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
- package/dist/_node-chunks/dist-SL73W244.js +0 -175
- package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
- package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
- package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
- package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
- package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
- package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
- package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.js +0 -124
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
|
@@ -1,40 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_hjmvusgt1gv from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_hjmvusgt1gv from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_hjmvusgt1gv from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_hjmvusgt1gv.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_hjmvusgt1gv.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_hjmvusgt1gv.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
|
-
__commonJS
|
|
14
|
-
|
|
15
|
-
} from "./chunk-3THWHQOC.js";
|
|
13
|
+
__commonJS
|
|
14
|
+
} from "./chunk-UFOFO5H7.js";
|
|
16
15
|
|
|
17
16
|
// ../node_modules/picocolors/picocolors.js
|
|
18
17
|
var require_picocolors = __commonJS({
|
|
19
18
|
"../node_modules/picocolors/picocolors.js"(exports, module) {
|
|
20
|
-
var p = process || {}
|
|
21
|
-
var argv = p.argv || [];
|
|
22
|
-
var env = p.env || {};
|
|
23
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
24
|
-
var formatter = /* @__PURE__ */ __name((open, close, replace = open) => (input) => {
|
|
19
|
+
var p = process || {}, argv = p.argv || [], env = p.env || {}, isColorSupported = !(env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI), formatter = (open, close, replace = open) => (input) => {
|
|
25
20
|
let string = "" + input, index = string.indexOf(close, open.length);
|
|
26
21
|
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
27
|
-
},
|
|
28
|
-
var replaceClose = /* @__PURE__ */ __name((string, close, replace, index) => {
|
|
22
|
+
}, replaceClose = (string, close, replace, index) => {
|
|
29
23
|
let result = "", cursor = 0;
|
|
30
|
-
do
|
|
31
|
-
result += string.substring(cursor, index) + replace;
|
|
32
|
-
|
|
33
|
-
index = string.indexOf(close, cursor);
|
|
34
|
-
} while (~index);
|
|
24
|
+
do
|
|
25
|
+
result += string.substring(cursor, index) + replace, cursor = index + close.length, index = string.indexOf(close, cursor);
|
|
26
|
+
while (~index);
|
|
35
27
|
return result + string.substring(cursor);
|
|
36
|
-
},
|
|
37
|
-
var createColors = /* @__PURE__ */ __name((enabled = isColorSupported) => {
|
|
28
|
+
}, createColors = (enabled = isColorSupported) => {
|
|
38
29
|
let f = enabled ? formatter : () => String;
|
|
39
30
|
return {
|
|
40
31
|
isColorSupported: enabled,
|
|
@@ -80,7 +71,7 @@ var require_picocolors = __commonJS({
|
|
|
80
71
|
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
81
72
|
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
82
73
|
};
|
|
83
|
-
}
|
|
74
|
+
};
|
|
84
75
|
module.exports = createColors();
|
|
85
76
|
module.exports.createColors = createColors;
|
|
86
77
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_hjmvusgt1gv from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_hjmvusgt1gv from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_hjmvusgt1gv from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_hjmvusgt1gv.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_hjmvusgt1gv.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_hjmvusgt1gv.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
toEstree
|
|
14
|
+
} from "./chunk-EVK2SBW5.js";
|
|
15
|
+
import "./chunk-UFOFO5H7.js";
|
|
16
|
+
|
|
17
|
+
// ../node_modules/@storybook/docs-mdx/dist/index.js
|
|
18
|
+
var getAttr = (elt, what) => elt.attributes.find((n) => n.type === "JSXAttribute" && n.name.name === what), getAttrValue = (elt, what) => getAttr(elt, what)?.value, getAttrLiteral = (elt, what) => {
|
|
19
|
+
let attrValue = getAttrValue(elt, what);
|
|
20
|
+
if (attrValue) {
|
|
21
|
+
if (attrValue.type === "Literal")
|
|
22
|
+
return attrValue.value;
|
|
23
|
+
throw new Error(`Expected string literal ${what}, received ${attrValue.type}`);
|
|
24
|
+
}
|
|
25
|
+
}, getOf = (elt, varToImport) => {
|
|
26
|
+
let ofAttrValue = getAttrValue(elt, "of");
|
|
27
|
+
if (ofAttrValue)
|
|
28
|
+
if (ofAttrValue.type === "JSXExpressionContainer") {
|
|
29
|
+
let of = ofAttrValue.expression;
|
|
30
|
+
if (of?.type === "Identifier") {
|
|
31
|
+
let importName = varToImport[of.name];
|
|
32
|
+
if (importName)
|
|
33
|
+
return importName;
|
|
34
|
+
throw new Error(`Unknown identifier ${of.name}`);
|
|
35
|
+
} else
|
|
36
|
+
throw new Error(`Expected identifier, received ${of.type}`);
|
|
37
|
+
} else
|
|
38
|
+
throw new Error(`Expected JSX expression, received ${ofAttrValue.type}`);
|
|
39
|
+
}, getTags = (elt) => {
|
|
40
|
+
let tagsAttr = getAttr(elt, "tags");
|
|
41
|
+
if (!tagsAttr)
|
|
42
|
+
return;
|
|
43
|
+
let tagsContainer = tagsAttr.value;
|
|
44
|
+
if (tagsContainer.type === "JSXExpressionContainer") {
|
|
45
|
+
let tagsArray = tagsContainer.expression;
|
|
46
|
+
if (tagsArray.type === "ArrayExpression")
|
|
47
|
+
return tagsArray.elements.map((tag) => {
|
|
48
|
+
if (tag.type === "Literal" && typeof tag.value == "string")
|
|
49
|
+
return tag.value;
|
|
50
|
+
throw new Error(`Expected string literal tag, received ${tag.type}`);
|
|
51
|
+
});
|
|
52
|
+
throw new Error(`Expected tags array, received ${tagsArray.type}`);
|
|
53
|
+
} else
|
|
54
|
+
throw new Error(`Expected JSX expression tags, received ${tagsContainer.type}`);
|
|
55
|
+
}, getIsTemplate = (elt) => {
|
|
56
|
+
let isTemplateAttr = getAttr(elt, "isTemplate");
|
|
57
|
+
if (!isTemplateAttr)
|
|
58
|
+
return !1;
|
|
59
|
+
let isTemplate = isTemplateAttr.value;
|
|
60
|
+
if (isTemplate == null)
|
|
61
|
+
return !0;
|
|
62
|
+
if (isTemplate.type === "JSXExpressionContainer") {
|
|
63
|
+
let expression = isTemplate.expression;
|
|
64
|
+
if (expression.type === "Literal" && typeof expression.value == "boolean")
|
|
65
|
+
return expression.value;
|
|
66
|
+
throw new Error(`Expected boolean isTemplate, received ${typeof expression.value}`);
|
|
67
|
+
} else
|
|
68
|
+
throw new Error(`Expected expression isTemplate, received ${isTemplate.type}`);
|
|
69
|
+
}, extractTitle = (root, varToImport) => {
|
|
70
|
+
let result = { title: void 0, of: void 0, name: void 0, isTemplate: !1 }, fragments = root.body.filter(
|
|
71
|
+
(child) => child.type === "ExpressionStatement" && child.expression.type === "JSXFragment"
|
|
72
|
+
);
|
|
73
|
+
if (fragments.length > 1)
|
|
74
|
+
throw new Error("duplicate contents");
|
|
75
|
+
return fragments.length === 0 || fragments[0].expression.children.forEach((child) => {
|
|
76
|
+
if (child.type === "JSXElement") {
|
|
77
|
+
let { openingElement } = child;
|
|
78
|
+
if (openingElement.name.name === "Meta") {
|
|
79
|
+
if (result.title || result.name || result.of)
|
|
80
|
+
throw new Error("Meta can only be declared once");
|
|
81
|
+
result.title = getAttrLiteral(openingElement, "title"), result.name = getAttrLiteral(openingElement, "name"), result.of = getOf(openingElement, varToImport), result.isTemplate = getIsTemplate(openingElement), result.metaTags = getTags(openingElement);
|
|
82
|
+
}
|
|
83
|
+
} else if (child.type !== "JSXExpressionContainer")
|
|
84
|
+
throw new Error(`Unexpected JSX child: ${child.type}`);
|
|
85
|
+
}), result;
|
|
86
|
+
}, extractImports = (root) => {
|
|
87
|
+
let varToImport = {};
|
|
88
|
+
return root.body.forEach((child) => {
|
|
89
|
+
if (child.type === "ImportDeclaration") {
|
|
90
|
+
let { source, specifiers } = child;
|
|
91
|
+
if (source.type === "Literal")
|
|
92
|
+
specifiers.forEach((s) => {
|
|
93
|
+
varToImport[s.local.name] = source.value.toString();
|
|
94
|
+
});
|
|
95
|
+
else
|
|
96
|
+
throw new Error("MDX: unexpected import source");
|
|
97
|
+
}
|
|
98
|
+
}), varToImport;
|
|
99
|
+
}, plugin = (store) => (root) => {
|
|
100
|
+
let estree = toEstree(root), varToImport = extractImports(estree), { title, of, name, isTemplate, metaTags } = extractTitle(estree, varToImport);
|
|
101
|
+
return store.title = title, store.of = of, store.name = name, store.isTemplate = isTemplate, store.metaTags = metaTags, store.imports = Array.from(new Set(Object.values(varToImport))), root;
|
|
102
|
+
}, analyze = async (code) => {
|
|
103
|
+
let store = {
|
|
104
|
+
title: void 0,
|
|
105
|
+
of: void 0,
|
|
106
|
+
name: void 0,
|
|
107
|
+
isTemplate: !1,
|
|
108
|
+
metaTags: void 0,
|
|
109
|
+
imports: void 0
|
|
110
|
+
}, { compile } = await import("./mdx-N42X6CFJ-C5WFYYXR.js");
|
|
111
|
+
await compile(code, {
|
|
112
|
+
rehypePlugins: [[plugin, store]]
|
|
113
|
+
});
|
|
114
|
+
let { title, of, name, isTemplate, metaTags, imports = [] } = store;
|
|
115
|
+
return { title, of, name, isTemplate, metaTags, imports };
|
|
116
|
+
};
|
|
117
|
+
export {
|
|
118
|
+
analyze,
|
|
119
|
+
extractImports,
|
|
120
|
+
plugin
|
|
121
|
+
};
|