storybook-solidjs-vite 9.0.0 → 9.0.1-dev.1
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/chunk-DW4YVOOF.mjs +33 -0
- package/dist/chunk-DW4YVOOF.mjs.map +1 -0
- package/dist/chunk-J7LXIPZS.mjs +43 -0
- package/dist/chunk-J7LXIPZS.mjs.map +1 -0
- package/dist/chunk-LBLGWNID.mjs +16 -0
- package/dist/chunk-LBLGWNID.mjs.map +1 -0
- package/dist/chunk-X7YLPC2R.mjs +95 -0
- package/dist/chunk-X7YLPC2R.mjs.map +1 -0
- package/dist/dist-VUIGXKYP.mjs +226 -0
- package/dist/dist-VUIGXKYP.mjs.map +1 -0
- package/dist/esm-35SYD6Z5.mjs +83070 -0
- package/dist/esm-35SYD6Z5.mjs.map +1 -0
- package/dist/esm-IHDSDIQY.mjs +6575 -0
- package/dist/esm-IHDSDIQY.mjs.map +1 -0
- package/dist/generate-7XS473XE.mjs +1224 -0
- package/dist/generate-7XS473XE.mjs.map +1 -0
- package/dist/index.js +2 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib-YN2LA5DC.mjs +1086 -0
- package/dist/lib-YN2LA5DC.mjs.map +1 -0
- package/dist/options-ZMO2JJIZ.mjs +14 -0
- package/dist/options-ZMO2JJIZ.mjs.map +1 -0
- package/dist/preset.js +3 -9344
- package/dist/preset.js.map +1 -1
- package/dist/preset.mjs +1 -1
- package/dist/preset.mjs.map +1 -1
- package/dist/renderer/index.js +2 -20
- package/dist/renderer/index.js.map +1 -1
- package/dist/renderer/index.mjs +1 -1
- package/dist/typescript-SI2KOXSW.mjs +23 -0
- package/dist/typescript-SI2KOXSW.mjs.map +1 -0
- package/package.json +21 -19
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { entry_preview_exports } from './chunk-X7YLPC2R.mjs';
|
|
2
|
+
import { setDefaultProjectAnnotations, setProjectAnnotations as setProjectAnnotations$1 } from 'storybook/preview-api';
|
|
3
|
+
|
|
4
|
+
// node_modules/@storybook/global/dist/index.mjs
|
|
5
|
+
var scope = (() => {
|
|
6
|
+
let win;
|
|
7
|
+
if (typeof window !== "undefined") {
|
|
8
|
+
win = window;
|
|
9
|
+
} else if (typeof globalThis !== "undefined") {
|
|
10
|
+
win = globalThis;
|
|
11
|
+
} else if (typeof global !== "undefined") {
|
|
12
|
+
win = global;
|
|
13
|
+
} else if (typeof self !== "undefined") {
|
|
14
|
+
win = self;
|
|
15
|
+
} else {
|
|
16
|
+
win = {};
|
|
17
|
+
}
|
|
18
|
+
return win;
|
|
19
|
+
})();
|
|
20
|
+
|
|
21
|
+
// src/renderer/globals.ts
|
|
22
|
+
var { window: globalWindow } = scope;
|
|
23
|
+
globalWindow.STORYBOOK_ENV = "solid";
|
|
24
|
+
function setProjectAnnotations(projectAnnotations) {
|
|
25
|
+
setDefaultProjectAnnotations(entry_preview_exports);
|
|
26
|
+
return setProjectAnnotations$1(
|
|
27
|
+
projectAnnotations
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { setProjectAnnotations };
|
|
32
|
+
//# sourceMappingURL=chunk-DW4YVOOF.mjs.map
|
|
33
|
+
//# sourceMappingURL=chunk-DW4YVOOF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node_modules/@storybook/global/dist/index.mjs","../src/renderer/globals.ts","../src/renderer/portable-stories.ts"],"names":["originalSetProjectAnnotations"],"mappings":";;;;AACA,IAAI,SAAS,MAAM;AACjB,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA,GAAA,GAAM,MAAA;AAAA,GACR,MAAA,IAAW,OAAO,UAAA,KAAe,WAAA,EAAa;AAC5C,IAAA,GAAA,GAAM,UAAA;AAAA,GACR,MAAA,IAAW,OAAO,MAAA,KAAW,WAAA,EAAa;AACxC,IAAA,GAAA,GAAM,MAAA;AAAA,GACR,MAAA,IAAW,OAAO,IAAA,KAAS,WAAA,EAAa;AACtC,IAAA,GAAA,GAAM,IAAA;AAAA,GACR,MAAO;AACL,IAAA,GAAA,GAAM,EAAC;AAAA;AAET,EAAA,OAAO,GAAA;AACT,CAAA,GAAG;;;ACbH,IAAM,EAAE,MAAA,EAAQ,YAAA,EAAa,GAAI,KAAA;AAEjC,YAAA,CAAa,aAAA,GAAgB,OAAA;AC8BtB,SAAS,sBACZ,kBAAA,EAG2C;AAC3C,EAAA,4BAAA,CAA6B,qBAAoC,CAAA;AAEjE,EAAA,OAAOA,uBAAA;AAAA,IACH;AAAA,GACJ;AACJ","file":"chunk-DW4YVOOF.mjs","sourcesContent":["// src/index.ts\nvar scope = (() => {\n let win;\n if (typeof window !== \"undefined\") {\n win = window;\n } else if (typeof globalThis !== \"undefined\") {\n win = globalThis;\n } else if (typeof global !== \"undefined\") {\n win = global;\n } else if (typeof self !== \"undefined\") {\n win = self;\n } else {\n win = {};\n }\n return win;\n})();\nexport {\n scope as global\n};\n","import { global } from '@storybook/global';\n\nconst { window: globalWindow } = global as any;\n\nglobalWindow.STORYBOOK_ENV = 'solid';\n","import {\n setDefaultProjectAnnotations,\n setProjectAnnotations as originalSetProjectAnnotations,\n} from 'storybook/preview-api';\n\nimport * as INTERNAL_DEFAULT_PROJECT_ANNOTATIONS from './entry-preview';\n\nimport type { SolidRenderer } from './types';\n\nimport type {\n NamedOrDefaultProjectAnnotations,\n NormalizedProjectAnnotations,\n} from 'storybook/internal/types';\n\n\n/**\n * Function that sets the globalConfig of your storybook. The global config is the preview module of\n * your .storybook folder.\n *\n * It should be run a single time, so that your global config (e.g. decorators) is applied to your\n * stories when using `composeStories` or `composeStory`.\n *\n * Example:\n *\n * ```jsx\n * // setup-file.js\n * import { setProjectAnnotations } from 'storybook-solidjs';\n * import projectAnnotations from './.storybook/preview';\n *\n * setProjectAnnotations(projectAnnotations);\n * ```\n *\n * @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')\n */\nexport function setProjectAnnotations(\n projectAnnotations:\n | NamedOrDefaultProjectAnnotations<any>\n | NamedOrDefaultProjectAnnotations<any>[]\n): NormalizedProjectAnnotations<SolidRenderer> {\n setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS);\n\n return originalSetProjectAnnotations(\n projectAnnotations\n ) as NormalizedProjectAnnotations<SolidRenderer>;\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __esm = (fn, res) => function __init() {
|
|
14
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
15
|
+
};
|
|
16
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
37
|
+
mod
|
|
38
|
+
));
|
|
39
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
|
+
|
|
41
|
+
export { __commonJS, __esm, __export, __require, __toCommonJS, __toESM };
|
|
42
|
+
//# sourceMappingURL=chunk-J7LXIPZS.mjs.map
|
|
43
|
+
//# sourceMappingURL=chunk-J7LXIPZS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-J7LXIPZS.mjs"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { entry_preview_exports } from './chunk-OLDYMLWC.mjs';
|
|
2
|
+
import { global } from '@storybook/global';
|
|
3
|
+
import { setDefaultProjectAnnotations, setProjectAnnotations as setProjectAnnotations$1 } from 'storybook/preview-api';
|
|
4
|
+
|
|
5
|
+
var { window: globalWindow } = global;
|
|
6
|
+
globalWindow.STORYBOOK_ENV = "solid";
|
|
7
|
+
function setProjectAnnotations(projectAnnotations) {
|
|
8
|
+
setDefaultProjectAnnotations(entry_preview_exports);
|
|
9
|
+
return setProjectAnnotations$1(
|
|
10
|
+
projectAnnotations
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { setProjectAnnotations };
|
|
15
|
+
//# sourceMappingURL=chunk-LBLGWNID.mjs.map
|
|
16
|
+
//# sourceMappingURL=chunk-LBLGWNID.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/renderer/globals.ts","../src/renderer/portable-stories.ts"],"names":["originalSetProjectAnnotations"],"mappings":";;;;AAEA,IAAM,EAAE,MAAA,EAAQ,YAAA,EAAa,GAAI,MAAA;AAEjC,YAAA,CAAa,aAAA,GAAgB,OAAA;AC8BtB,SAAS,sBACZ,kBAAA,EAG2C;AAC3C,EAAA,4BAAA,CAA6B,qBAAoC,CAAA;AAEjE,EAAA,OAAOA,uBAAA;AAAA,IACH;AAAA,GACJ;AACJ","file":"chunk-LBLGWNID.mjs","sourcesContent":["import { global } from '@storybook/global';\n\nconst { window: globalWindow } = global as any;\n\nglobalWindow.STORYBOOK_ENV = 'solid';\n","import {\n setDefaultProjectAnnotations,\n setProjectAnnotations as originalSetProjectAnnotations,\n} from 'storybook/preview-api';\n\nimport * as INTERNAL_DEFAULT_PROJECT_ANNOTATIONS from './entry-preview';\n\nimport type { SolidRenderer } from './types';\n\nimport type {\n NamedOrDefaultProjectAnnotations,\n NormalizedProjectAnnotations,\n} from 'storybook/internal/types';\n\n\n/**\n * Function that sets the globalConfig of your storybook. The global config is the preview module of\n * your .storybook folder.\n *\n * It should be run a single time, so that your global config (e.g. decorators) is applied to your\n * stories when using `composeStories` or `composeStory`.\n *\n * Example:\n *\n * ```jsx\n * // setup-file.js\n * import { setProjectAnnotations } from 'storybook-solidjs';\n * import projectAnnotations from './.storybook/preview';\n *\n * setProjectAnnotations(projectAnnotations);\n * ```\n *\n * @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')\n */\nexport function setProjectAnnotations(\n projectAnnotations:\n | NamedOrDefaultProjectAnnotations<any>\n | NamedOrDefaultProjectAnnotations<any>[]\n): NormalizedProjectAnnotations<SolidRenderer> {\n setDefaultProjectAnnotations(INTERNAL_DEFAULT_PROJECT_ANNOTATIONS);\n\n return originalSetProjectAnnotations(\n projectAnnotations\n ) as NormalizedProjectAnnotations<SolidRenderer>;\n}\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { __export } from './chunk-J7LXIPZS.mjs';
|
|
2
|
+
import { enhanceArgTypes } from 'storybook/internal/docs-tools';
|
|
3
|
+
import { createComponent, mergeProps, render as render$1 } from 'solid-js/web';
|
|
4
|
+
import { onMount, ErrorBoundary } from 'solid-js';
|
|
5
|
+
import { createStore } from 'solid-js/store';
|
|
6
|
+
|
|
7
|
+
// src/renderer/entry-preview.ts
|
|
8
|
+
var entry_preview_exports = {};
|
|
9
|
+
__export(entry_preview_exports, {
|
|
10
|
+
argTypesEnhancers: () => argTypesEnhancers,
|
|
11
|
+
decorators: () => decorators,
|
|
12
|
+
parameters: () => parameters,
|
|
13
|
+
render: () => render,
|
|
14
|
+
renderToCanvas: () => renderToCanvas
|
|
15
|
+
});
|
|
16
|
+
var [store, setStore] = createStore({});
|
|
17
|
+
var solidReactivityDecorator = (Story, context) => {
|
|
18
|
+
const storyId = context.canvasElement.id;
|
|
19
|
+
context.args = store[storyId]?.args || {};
|
|
20
|
+
return createComponent(Story, mergeProps(() => context.args));
|
|
21
|
+
};
|
|
22
|
+
var cleanStoryStore = (storeId) => {
|
|
23
|
+
setStore({
|
|
24
|
+
[storeId]: {
|
|
25
|
+
args: {},
|
|
26
|
+
rendered: false,
|
|
27
|
+
disposeFn: () => {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var disposeStory = (storeId) => {
|
|
33
|
+
store[storeId]?.disposeFn?.();
|
|
34
|
+
};
|
|
35
|
+
var storyIsRendered = (storyId) => Boolean(store[storyId]?.rendered);
|
|
36
|
+
var renderSolidApp = (storyId, renderContext, canvasElement) => {
|
|
37
|
+
const {
|
|
38
|
+
storyContext,
|
|
39
|
+
storyFn,
|
|
40
|
+
showMain,
|
|
41
|
+
showException
|
|
42
|
+
} = renderContext;
|
|
43
|
+
const App = () => {
|
|
44
|
+
const Story = storyFn;
|
|
45
|
+
onMount(() => {
|
|
46
|
+
showMain();
|
|
47
|
+
});
|
|
48
|
+
return createComponent(ErrorBoundary, {
|
|
49
|
+
fallback: (err) => {
|
|
50
|
+
showException(err);
|
|
51
|
+
return err;
|
|
52
|
+
},
|
|
53
|
+
get children() {
|
|
54
|
+
return createComponent(Story, storyContext);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const disposeFn = render$1(() => createComponent(App, {}), canvasElement);
|
|
59
|
+
setStore(storyId, "disposeFn", () => disposeFn);
|
|
60
|
+
setStore(storyId, "rendered", true);
|
|
61
|
+
};
|
|
62
|
+
async function renderToCanvas(renderContext, canvasElement) {
|
|
63
|
+
const {
|
|
64
|
+
storyContext,
|
|
65
|
+
forceRemount
|
|
66
|
+
} = renderContext;
|
|
67
|
+
const storyId = storyContext.canvasElement.id;
|
|
68
|
+
if (forceRemount) {
|
|
69
|
+
disposeStory(storyId);
|
|
70
|
+
cleanStoryStore(storyId);
|
|
71
|
+
}
|
|
72
|
+
setStore(storyId, "args", storyContext.args);
|
|
73
|
+
if (!storyIsRendered(storyId)) {
|
|
74
|
+
renderSolidApp(storyId, renderContext, canvasElement);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
var render = (_, context) => {
|
|
78
|
+
const {
|
|
79
|
+
id,
|
|
80
|
+
component: Component
|
|
81
|
+
} = context;
|
|
82
|
+
if (!Component) {
|
|
83
|
+
throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);
|
|
84
|
+
}
|
|
85
|
+
return createComponent(Component, mergeProps(() => context.args));
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/renderer/entry-preview.ts
|
|
89
|
+
var parameters = { renderer: "solid" };
|
|
90
|
+
var decorators = [solidReactivityDecorator];
|
|
91
|
+
var argTypesEnhancers = [enhanceArgTypes];
|
|
92
|
+
|
|
93
|
+
export { argTypesEnhancers, decorators, entry_preview_exports, parameters, render, renderToCanvas };
|
|
94
|
+
//# sourceMappingURL=chunk-X7YLPC2R.mjs.map
|
|
95
|
+
//# sourceMappingURL=chunk-X7YLPC2R.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/renderer/entry-preview.ts","../src/renderer/renderToCanvas.tsx","../src/renderer/render.tsx"],"names":["store","setStore","createStore","solidReactivityDecorator","Story","context","storyId","canvasElement","id","args","_$createComponent","_$mergeProps","cleanStoryStore","storeId","rendered","disposeFn","disposeStory","storyIsRendered","Boolean","renderSolidApp","renderContext","storyContext","storyFn","showMain","showException","App","onMount","ErrorBoundary","fallback","err","children","solidRender","renderToCanvas","forceRemount","render","_","component","Component","Error"],"mappings":";;;;;;;AAAA,IAAA,qBAAA,GAAA;AAAA,QAAA,CAAA,qBAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,MAAA,EAAA,MAAA,MAAA;AAAA,EAAA,cAAA,EAAA,MAAA;AAAA,CAAA,CAAA;ACcA,IAAM,CAACA,KAAAA,EAAOC,QAAQ,CAAA,GAAIC,WAAAA,CAAY,EAAoB,CAAA;AAKnD,IAAMC,wBAAAA,GAAsCA,CAACC,KAAAA,EAAOC,OAAAA,KAAY;AACnE,EAAA,MAAMC,OAAAA,GAAUD,QAAQE,aAAAA,CAAcC,EAAAA;AAEtCH,EAAAA,OAAAA,CAAQI,IAAAA,GAAOT,KAAAA,CAAMM,OAAO,CAAA,EAAGG,QAAQ,EAAC;AAExC,EAAA,OAAAC,gBAAQN,KAAAA,EAAKO,UAAAA,CAAA,MAAMN,OAAAA,CAAQI,IAAI,CAAA,CAAA;AACnC,CAAA;AAKA,IAAMG,kBAAmBC,CAAAA,O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,QAAAA,CAASK,OAAAA,EAAS,YAAY,IAAI,CAAA;AACtC,CAAA;AAYA,eAAsB0B,cAAAA,CAClBZ,eACAb,aAAAA,EACF;AACE,EAAA,MAAM;AAAEc,IAAAA,YAAAA;AAAcY,IAAAA;GAAa,GAAIb,aAAAA;AACvC,EAAA,MAAMd,OAAAA,GAAUe,aAAad,aAAAA,CAAcC,EAAAA;AAG3C,EAAA,IAAIyB,YAAAA,EAAc;AACdjB,IAAAA,YAAAA,CAAaV,OAAO,CAAA;AACpBM,IAAAA,eAAAA,CAAgBN,OAAO,CAAA;AAC3B;AAGAL,EAAAA,QAAAA,CAASK,OAAAA,EAAS,MAAA,EAAQe,YAAAA,CAAaZ,IAAI,CAAA;AAG3C,EAAA,IAAI,CAACQ,eAAAA,CAAgBX,OAAO,CAAA,EAAG;AAC3Ba,IAAAA,cAAAA,CAAeb,OAAAA,EAASc,eAAeb,aAAa,CAAA;AACxD;AACJ;AClGO,IAAM2B,MAAAA,GAAqCA,CAACC,CAAAA,EAAG9B,OAAAA,KAAY;AAC9D,EAAA,MAAM;AAAEG,IAAAA,EAAAA;IAAI4B,SAAAA,EAAWC;GAAU,GAAIhC,OAAAA;AAErC,EAAA,IAAI,CAACgC,SAAAA,EAAW;AACZ,IAAA,MAAM,IAAIC,KAAAA,CACN,CAAA,uBAAA,EAA2B9B,EAAE,CAAA,+DAAA,CACjC,CAAA;AACJ;AAGA,EAAA,OAAAE,gBAAQ2B,SAAAA,EAAS1B,UAAAA,CAAA,MAAMN,OAAAA,CAAQI,IAAI,CAAA,CAAA;AACvC;;;AFfO,IAAM,UAAA,GAAa,EAAE,QAAA,EAAU,OAAA;AAC/B,IAAM,UAAA,GAA0B,CAAC,wBAAwB;AACzD,IAAM,iBAAA,GAAwC,CAAC,eAAe","file":"chunk-X7YLPC2R.mjs","sourcesContent":["/* Configuration for default renderer. */\nimport { enhanceArgTypes } from 'storybook/internal/docs-tools';\n\nimport { solidReactivityDecorator } from './renderToCanvas';\n\nimport type { Decorator } from './public-types';\nimport type { ArgTypesEnhancer } from 'storybook/internal/types';\n\nexport { render } from './render';\nexport { renderToCanvas } from './renderToCanvas';\n\nexport const parameters = { renderer: 'solid' };\nexport const decorators: Decorator[] = [solidReactivityDecorator];\nexport const argTypesEnhancers: ArgTypesEnhancer[] = [enhanceArgTypes];\n","import { ErrorBoundary, onMount } from 'solid-js';\nimport { createStore } from 'solid-js/store';\nimport { render as solidRender } from 'solid-js/web';\n\nimport type { Decorator } from './public-types';\n\nimport type { ComponentsData, SolidRenderer, StoryContext } from './types';\nimport type { Component } from 'solid-js';\nimport type { RenderContext } from 'storybook/internal/types';\n\n/**\n * SolidJS store for handling fine grained updates\n * of the components data as f.e. story args.\n */\nconst [store, setStore] = createStore({} as ComponentsData);\n\n/**\n * A decorator that ensures changing args updates the story.\n */\nexport const solidReactivityDecorator: Decorator = (Story, context) => {\n const storyId = context.canvasElement.id;\n\n context.args = store[storyId]?.args || {};\n\n return <Story { ...context.args } />;\n};\n\n/**\n * Resets an specific story store.\n */\nconst cleanStoryStore = (storeId: string) => {\n setStore({ [storeId]: { args: {}, rendered: false, disposeFn: () => {} } });\n};\n\n/**\n * Disposes an specific story.\n */\nconst disposeStory = (storeId: string) => {\n store[storeId]?.disposeFn?.();\n};\n\n\n/**\n * Checks if the story store exists\n */\nconst storyIsRendered = (storyId: string) => Boolean(store[storyId]?.rendered);\n\n/**\n * Renders solid App into DOM.\n */\nconst renderSolidApp = (\n storyId: string,\n renderContext: RenderContext<SolidRenderer>,\n canvasElement: SolidRenderer['canvasElement']\n) => {\n const { storyContext, storyFn, showMain, showException } = renderContext;\n\n const App: Component = () => {\n const Story = storyFn as Component<StoryContext<SolidRenderer>>;\n\n onMount(() => {\n showMain();\n });\n\n return (\n <ErrorBoundary\n fallback={ (err: any) => {\n showException(err);\n\n return err;\n } }\n >\n <Story { ...storyContext } />\n </ErrorBoundary>\n );\n };\n\n const disposeFn = solidRender(() => <App />, canvasElement);\n\n setStore(storyId, 'disposeFn', () => disposeFn);\n setStore(storyId, 'rendered', true);\n};\n\n/**\n * Main renderer function for initializing the SolidJS app with the story content.\n *\n * How this works is a bit different from the React renderer.\n * In React, components run again on rerender so the React renderer just recalls the component,\n * but Solid has fine-grained reactivity so components run once,\n * and when dependencies are updated, effects/tracking scopes run again.\n *\n * So, we can store args in a store and just update the store when this function is called.\n */\nexport async function renderToCanvas(\n renderContext: RenderContext<SolidRenderer>,\n canvasElement: SolidRenderer['canvasElement']\n) {\n const { storyContext, forceRemount } = renderContext;\n const storyId = storyContext.canvasElement.id;\n\n // Story is remounted given the conditions\n if (forceRemount) {\n disposeStory(storyId);\n cleanStoryStore(storyId);\n }\n\n // Story store data is updated\n setStore(storyId, 'args', storyContext.args);\n\n // Story is rendered and store data is created\n if (!storyIsRendered(storyId)) {\n renderSolidApp(storyId, renderContext, canvasElement);\n }\n}\n","import type { SolidRenderer } from './types';\nimport type { ArgsStoryFn } from 'storybook/internal/types';\n\n/**\n * Default render function for a story definition (inside a csf file) without\n * a render function. e.g:\n * ```typescript\n * export const StoryExample = {\n * args: {\n * disabled: true,\n * children: \"Hello World\",\n * },\n * };\n * ```\n */\nexport const render: ArgsStoryFn<SolidRenderer> = (_, context) => {\n const { id, component: Component } = context;\n\n if (!Component) {\n throw new Error(\n `Unable to render story ${ id } as the component annotation is missing from the default export`\n );\n }\n\n // context.args is a SolidJS proxy thanks to the solidReactivityDecorator.\n return <Component { ...context.args } />;\n};\n"]}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import './chunk-J7LXIPZS.mjs';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
var defaultPropFilter = (prop) => {
|
|
6
|
+
return !prop.parent?.fileName.includes("node_modules");
|
|
7
|
+
};
|
|
8
|
+
var getDocgen = async (config) => {
|
|
9
|
+
const docGen = await import('./lib-YN2LA5DC.mjs');
|
|
10
|
+
const {
|
|
11
|
+
tsconfigPath,
|
|
12
|
+
compilerOptions,
|
|
13
|
+
propFilter = defaultPropFilter,
|
|
14
|
+
setDisplayName,
|
|
15
|
+
typePropName,
|
|
16
|
+
EXPERIMENTAL_useWatchProgram,
|
|
17
|
+
...rest
|
|
18
|
+
} = config;
|
|
19
|
+
const docgenOptions = {
|
|
20
|
+
propFilter,
|
|
21
|
+
...rest
|
|
22
|
+
};
|
|
23
|
+
return docGen.withCompilerOptions(
|
|
24
|
+
// Compiler Options are passed in to the custom program.
|
|
25
|
+
{},
|
|
26
|
+
docgenOptions
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
var getCompilerOptions = async (config, tsconfigPath) => {
|
|
30
|
+
const { default: ts } = await import('typescript');
|
|
31
|
+
const { getTSConfigFile } = await import('./typescript-SI2KOXSW.mjs');
|
|
32
|
+
let compilerOptions = {
|
|
33
|
+
jsx: ts.JsxEmit.React,
|
|
34
|
+
module: ts.ModuleKind.CommonJS,
|
|
35
|
+
target: ts.ScriptTarget.Latest
|
|
36
|
+
};
|
|
37
|
+
if (config.compilerOptions) {
|
|
38
|
+
compilerOptions = {
|
|
39
|
+
...compilerOptions,
|
|
40
|
+
...config.compilerOptions
|
|
41
|
+
};
|
|
42
|
+
} else {
|
|
43
|
+
const { options: tsOptions } = getTSConfigFile(tsconfigPath);
|
|
44
|
+
compilerOptions = { ...compilerOptions, ...tsOptions };
|
|
45
|
+
}
|
|
46
|
+
return compilerOptions;
|
|
47
|
+
};
|
|
48
|
+
var createProgram = async (compilerOptions, includeArray) => {
|
|
49
|
+
const { default: ts } = await import('typescript');
|
|
50
|
+
const { globSync } = await import('./esm-IHDSDIQY.mjs');
|
|
51
|
+
const files = includeArray.map(
|
|
52
|
+
(filePath) => globSync(
|
|
53
|
+
path.isAbsolute(filePath) ? filePath : path.posix.join(process.cwd(), filePath)
|
|
54
|
+
)
|
|
55
|
+
).reduce((carry, files2) => carry.concat(files2), []);
|
|
56
|
+
return ts.createProgram(files, compilerOptions);
|
|
57
|
+
};
|
|
58
|
+
var doNothing = () => {
|
|
59
|
+
};
|
|
60
|
+
var createStubFileWatcher = () => ({
|
|
61
|
+
close: doNothing
|
|
62
|
+
});
|
|
63
|
+
var createProjectService = async () => {
|
|
64
|
+
const { default: tsserver } = await import('typescript/lib/tsserverlibrary.js');
|
|
65
|
+
const system = {
|
|
66
|
+
...tsserver.sys,
|
|
67
|
+
clearImmediate,
|
|
68
|
+
clearTimeout,
|
|
69
|
+
setImmediate,
|
|
70
|
+
setTimeout,
|
|
71
|
+
watchDirectory: createStubFileWatcher,
|
|
72
|
+
watchFile: createStubFileWatcher
|
|
73
|
+
};
|
|
74
|
+
return new tsserver.server.ProjectService({
|
|
75
|
+
cancellationToken: { isCancellationRequested: () => false },
|
|
76
|
+
host: system,
|
|
77
|
+
jsDocParsingMode: 0,
|
|
78
|
+
logger: {
|
|
79
|
+
close: doNothing,
|
|
80
|
+
endGroup: doNothing,
|
|
81
|
+
getLogFileName: () => void 0,
|
|
82
|
+
hasLevel: () => false,
|
|
83
|
+
info: doNothing,
|
|
84
|
+
loggingEnabled: () => false,
|
|
85
|
+
msg: doNothing,
|
|
86
|
+
perftrc: doNothing,
|
|
87
|
+
startGroup: doNothing
|
|
88
|
+
},
|
|
89
|
+
session: void 0,
|
|
90
|
+
useInferredProjectPerProjectRoot: false,
|
|
91
|
+
useSingleInferredProject: false
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
var startWatch = async (compilerOptions, tsconfigPath, onProgramCreatedOrUpdated) => {
|
|
95
|
+
const { default: ts } = await import('typescript');
|
|
96
|
+
const host = ts.createWatchCompilerHost(
|
|
97
|
+
tsconfigPath,
|
|
98
|
+
compilerOptions,
|
|
99
|
+
ts.sys,
|
|
100
|
+
ts.createSemanticDiagnosticsBuilderProgram,
|
|
101
|
+
void 0,
|
|
102
|
+
() => {
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
host.afterProgramCreate = (program) => {
|
|
106
|
+
onProgramCreatedOrUpdated(program.getProgram());
|
|
107
|
+
};
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
const watch = ts.createWatchProgram(host);
|
|
110
|
+
resolve([watch.getProgram().getProgram(), watch.close]);
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
function reactDocgenTypescript(config = {}) {
|
|
114
|
+
let tsProgram;
|
|
115
|
+
let docGenParser;
|
|
116
|
+
let generateDocgenCodeBlock;
|
|
117
|
+
let generateOptions;
|
|
118
|
+
let filter;
|
|
119
|
+
const moduleInvalidationQueue = /* @__PURE__ */ new Map();
|
|
120
|
+
let closeWatch;
|
|
121
|
+
let projectService = null;
|
|
122
|
+
return {
|
|
123
|
+
name: "vite:react-docgen-typescript",
|
|
124
|
+
async configResolved() {
|
|
125
|
+
const { getGenerateOptions } = await import('./options-ZMO2JJIZ.mjs');
|
|
126
|
+
generateDocgenCodeBlock = (await import('./generate-7XS473XE.mjs')).generateDocgenCodeBlock;
|
|
127
|
+
const { createFilter } = await import('vite');
|
|
128
|
+
docGenParser = await getDocgen(config);
|
|
129
|
+
generateOptions = getGenerateOptions(config);
|
|
130
|
+
const tsconfigPath = config.tsconfigPath ?? "./tsconfig.json";
|
|
131
|
+
const compilerOptions = await getCompilerOptions(config, tsconfigPath);
|
|
132
|
+
const includeArray = config.include ?? ["**/**.tsx"];
|
|
133
|
+
filter = createFilter(
|
|
134
|
+
includeArray,
|
|
135
|
+
config.exclude ?? ["**/**.stories.tsx"]
|
|
136
|
+
);
|
|
137
|
+
if (config.EXPERIMENTAL_useProjectService) {
|
|
138
|
+
projectService = await createProjectService();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (config.EXPERIMENTAL_useWatchProgram) {
|
|
142
|
+
[tsProgram, closeWatch] = await startWatch(
|
|
143
|
+
compilerOptions,
|
|
144
|
+
tsconfigPath,
|
|
145
|
+
(program) => {
|
|
146
|
+
tsProgram = program;
|
|
147
|
+
for (const [
|
|
148
|
+
filepath,
|
|
149
|
+
invalidateModule
|
|
150
|
+
] of moduleInvalidationQueue.entries()) {
|
|
151
|
+
invalidateModule();
|
|
152
|
+
moduleInvalidationQueue.delete(filepath);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
} else {
|
|
157
|
+
tsProgram = await createProgram(compilerOptions, includeArray);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
async transform(src, id) {
|
|
161
|
+
if (!filter(id)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const source = await fs.readFile(id, "utf-8");
|
|
165
|
+
try {
|
|
166
|
+
const componentDocs = docGenParser.parseWithProgramProvider(id, () => {
|
|
167
|
+
if (tsProgram) {
|
|
168
|
+
return tsProgram;
|
|
169
|
+
}
|
|
170
|
+
projectService?.openClientFile(
|
|
171
|
+
id,
|
|
172
|
+
source,
|
|
173
|
+
/* scriptKind */
|
|
174
|
+
void 0,
|
|
175
|
+
projectService?.currentDirectory
|
|
176
|
+
);
|
|
177
|
+
const scriptInfo = projectService?.getScriptInfo(id);
|
|
178
|
+
if (scriptInfo?.fileName) {
|
|
179
|
+
const languageServiceProgram = projectService?.getDefaultProjectForFile(scriptInfo?.fileName, true)?.getLanguageService(true).getProgram();
|
|
180
|
+
if (languageServiceProgram) {
|
|
181
|
+
return languageServiceProgram;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
throw new Error("Internal Error: No program available");
|
|
185
|
+
});
|
|
186
|
+
if (!componentDocs.length) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
return generateDocgenCodeBlock({
|
|
190
|
+
filename: id,
|
|
191
|
+
source: src,
|
|
192
|
+
componentDocs,
|
|
193
|
+
...generateOptions
|
|
194
|
+
});
|
|
195
|
+
} catch (e) {
|
|
196
|
+
return src;
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
async handleHotUpdate({ file, server, modules }) {
|
|
200
|
+
if (!config.EXPERIMENTAL_useWatchProgram) return;
|
|
201
|
+
if (!filter(file)) return;
|
|
202
|
+
const module = modules.find((mod) => mod.file === file);
|
|
203
|
+
if (!module) return;
|
|
204
|
+
moduleInvalidationQueue.set(file, () => {
|
|
205
|
+
server.moduleGraph.invalidateModule(
|
|
206
|
+
module,
|
|
207
|
+
void 0,
|
|
208
|
+
Date.now(),
|
|
209
|
+
true
|
|
210
|
+
);
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
closeBundle() {
|
|
214
|
+
if (!config.EXPERIMENTAL_useWatchProgram) return;
|
|
215
|
+
closeWatch();
|
|
216
|
+
},
|
|
217
|
+
buildEnd() {
|
|
218
|
+
if (!config.EXPERIMENTAL_useWatchProgram) return;
|
|
219
|
+
closeWatch();
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export { reactDocgenTypescript as default };
|
|
225
|
+
//# sourceMappingURL=dist-VUIGXKYP.mjs.map
|
|
226
|
+
//# sourceMappingURL=dist-VUIGXKYP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node_modules/@joshwooding/vite-plugin-react-docgen-typescript/dist/index.mjs"],"names":[],"mappings":";;;;AAGA,IAAM,iBAAA,GAAoB,CAAC,IAAA,KAAS;AAClC,EAAA,OAAO,CAAC,IAAA,CAAK,MAAA,EAAQ,QAAA,CAAS,SAAS,cAAc,CAAA;AACvD,CAAA;AAEA,IAAM,SAAA,GAAY,OAAO,MAAA,KAAW;AAClC,EAAA,MAAM,MAAA,GAAS,MAAM,OAAO,oBAAyB,CAAA;AACrD,EAAA,MAAM;AAAA,IACJ,YAAA;AAAA,IACA,eAAA;AAAA,IACA,UAAA,GAAa,iBAAA;AAAA,IACb,cAAA;AAAA,IACA,YAAA;AAAA,IACA,4BAAA;AAAA,IACA,GAAG;AAAA,GACL,GAAI,MAAA;AACJ,EAAA,MAAM,aAAA,GAAgB;AAAA,IACpB,UAAA;AAAA,IACA,GAAG;AAAA,GACL;AACA,EAAA,OAAO,MAA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uBAAA,CAAwB,GAAA,CAAI,MAAM,MAAM;AACtC,QAAA,MAAA,CAAO,WAAA,CAAY,gBAAA;AAAA,UACjB,MAAA;AAAA,UACA,MAAA;AAAA,UACA,KAAK,GAAA,EAAI;AAAA,UACT;AAAA,SACF;AAAA,OACD,CAAA;AAAA,KACH;AAAA,IACA,WAAA,GAAc;AACZ,MAAA,IAAI,CAAC,OAAO,4BAAA,EAA8B;AAC1C,MAAA,UAAA,EAAW;AAAA,KACb;AAAA,IACA,QAAA,GAAW;AACT,MAAA,IAAI,CAAC,OAAO,4BAAA,EAA8B;AAC1C,MAAA,UAAA,EAAW;AAAA;AACb,GACF;AACF","file":"dist-VUIGXKYP.mjs","sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nconst defaultPropFilter = (prop) => {\n return !prop.parent?.fileName.includes(\"node_modules\");\n};\n\nconst getDocgen = async (config) => {\n const docGen = await import('react-docgen-typescript');\n const {\n tsconfigPath,\n compilerOptions,\n propFilter = defaultPropFilter,\n setDisplayName,\n typePropName,\n EXPERIMENTAL_useWatchProgram,\n ...rest\n } = config;\n const docgenOptions = {\n propFilter,\n ...rest\n };\n return docGen.withCompilerOptions(\n // Compiler Options are passed in to the custom program.\n {},\n docgenOptions\n );\n};\nconst getCompilerOptions = async (config, tsconfigPath) => {\n const { default: ts } = await import('typescript');\n const { getTSConfigFile } = await import('./chunks/typescript.mjs');\n let compilerOptions = {\n jsx: ts.JsxEmit.React,\n module: ts.ModuleKind.CommonJS,\n target: ts.ScriptTarget.Latest\n };\n if (config.compilerOptions) {\n compilerOptions = {\n ...compilerOptions,\n ...config.compilerOptions\n };\n } else {\n const { options: tsOptions } = getTSConfigFile(tsconfigPath);\n compilerOptions = { ...compilerOptions, ...tsOptions };\n }\n return compilerOptions;\n};\nconst createProgram = async (compilerOptions, includeArray) => {\n const { default: ts } = await import('typescript');\n const { globSync } = await import('glob');\n const files = includeArray.map(\n (filePath) => globSync(\n path.isAbsolute(filePath) ? filePath : path.posix.join(process.cwd(), filePath)\n )\n ).reduce((carry, files2) => carry.concat(files2), []);\n return ts.createProgram(files, compilerOptions);\n};\nconst doNothing = () => {\n};\nconst createStubFileWatcher = () => ({\n close: doNothing\n});\nconst createProjectService = async () => {\n const { default: tsserver } = await import('typescript/lib/tsserverlibrary.js');\n const system = {\n ...tsserver.sys,\n clearImmediate,\n clearTimeout,\n setImmediate,\n setTimeout,\n watchDirectory: createStubFileWatcher,\n watchFile: createStubFileWatcher\n };\n return new tsserver.server.ProjectService({\n cancellationToken: { isCancellationRequested: () => false },\n host: system,\n jsDocParsingMode: 0,\n logger: {\n close: doNothing,\n endGroup: doNothing,\n getLogFileName: () => void 0,\n hasLevel: () => false,\n info: doNothing,\n loggingEnabled: () => false,\n msg: doNothing,\n perftrc: doNothing,\n startGroup: doNothing\n },\n session: void 0,\n useInferredProjectPerProjectRoot: false,\n useSingleInferredProject: false\n });\n};\nconst startWatch = async (compilerOptions, tsconfigPath, onProgramCreatedOrUpdated) => {\n const { default: ts } = await import('typescript');\n const host = ts.createWatchCompilerHost(\n tsconfigPath,\n compilerOptions,\n ts.sys,\n ts.createSemanticDiagnosticsBuilderProgram,\n void 0,\n () => {\n }\n );\n host.afterProgramCreate = (program) => {\n onProgramCreatedOrUpdated(program.getProgram());\n };\n return new Promise((resolve) => {\n const watch = ts.createWatchProgram(host);\n resolve([watch.getProgram().getProgram(), watch.close]);\n });\n};\nfunction reactDocgenTypescript(config = {}) {\n let tsProgram;\n let docGenParser;\n let generateDocgenCodeBlock;\n let generateOptions;\n let filter;\n const moduleInvalidationQueue = /* @__PURE__ */ new Map();\n let closeWatch;\n let projectService = null;\n return {\n name: \"vite:react-docgen-typescript\",\n async configResolved() {\n const { getGenerateOptions } = await import('./chunks/options.mjs');\n generateDocgenCodeBlock = (await import('./chunks/generate.mjs')).generateDocgenCodeBlock;\n const { createFilter } = await import('vite');\n docGenParser = await getDocgen(config);\n generateOptions = getGenerateOptions(config);\n const tsconfigPath = config.tsconfigPath ?? \"./tsconfig.json\";\n const compilerOptions = await getCompilerOptions(config, tsconfigPath);\n const includeArray = config.include ?? [\"**/**.tsx\"];\n filter = createFilter(\n includeArray,\n config.exclude ?? [\"**/**.stories.tsx\"]\n );\n if (config.EXPERIMENTAL_useProjectService) {\n projectService = await createProjectService();\n return;\n }\n if (config.EXPERIMENTAL_useWatchProgram) {\n [tsProgram, closeWatch] = await startWatch(\n compilerOptions,\n tsconfigPath,\n (program) => {\n tsProgram = program;\n for (const [\n filepath,\n invalidateModule\n ] of moduleInvalidationQueue.entries()) {\n invalidateModule();\n moduleInvalidationQueue.delete(filepath);\n }\n }\n );\n } else {\n tsProgram = await createProgram(compilerOptions, includeArray);\n }\n },\n async transform(src, id) {\n if (!filter(id)) {\n return;\n }\n const source = await fs.readFile(id, \"utf-8\");\n try {\n const componentDocs = docGenParser.parseWithProgramProvider(id, () => {\n if (tsProgram) {\n return tsProgram;\n }\n projectService?.openClientFile(\n id,\n source,\n /* scriptKind */\n void 0,\n projectService?.currentDirectory\n );\n const scriptInfo = projectService?.getScriptInfo(id);\n if (scriptInfo?.fileName) {\n const languageServiceProgram = projectService?.getDefaultProjectForFile(scriptInfo?.fileName, true)?.getLanguageService(true).getProgram();\n if (languageServiceProgram) {\n return languageServiceProgram;\n }\n }\n throw new Error(\"Internal Error: No program available\");\n });\n if (!componentDocs.length) {\n return null;\n }\n return generateDocgenCodeBlock({\n filename: id,\n source: src,\n componentDocs,\n ...generateOptions\n });\n } catch (e) {\n return src;\n }\n },\n async handleHotUpdate({ file, server, modules }) {\n if (!config.EXPERIMENTAL_useWatchProgram) return;\n if (!filter(file)) return;\n const module = modules.find((mod) => mod.file === file);\n if (!module) return;\n moduleInvalidationQueue.set(file, () => {\n server.moduleGraph.invalidateModule(\n module,\n void 0,\n Date.now(),\n true\n );\n });\n },\n closeBundle() {\n if (!config.EXPERIMENTAL_useWatchProgram) return;\n closeWatch();\n },\n buildEnd() {\n if (!config.EXPERIMENTAL_useWatchProgram) return;\n closeWatch();\n }\n };\n}\n\nexport { reactDocgenTypescript as default };\n"]}
|