dumi 2.2.1 → 2.2.2
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/compiled/crates/swc_plugin_react_demo.wasm +0 -0
- package/dist/assetParsers/atom.js +15 -5
- package/dist/assetParsers/block.js +27 -9
- package/dist/cli.js +8 -1
- package/dist/client/pages/Demo/index.js +3 -8
- package/dist/client/theme-api/AtomRenderer.d.ts +2 -2
- package/dist/client/theme-api/AtomRenderer.js +19 -35
- package/dist/client/theme-api/DumiDemo.js +8 -13
- package/dist/client/theme-api/DumiDemoGrid.js +12 -26
- package/dist/client/theme-api/DumiPage.js +16 -34
- package/dist/client/theme-api/openCodeSandbox.js +18 -23
- package/dist/client/theme-api/openStackBlitz.js +6 -14
- package/dist/client/theme-api/types.d.ts +15 -12
- package/dist/client/theme-api/useAtomAssets.js +1 -2
- package/dist/client/theme-api/useLocale.js +10 -19
- package/dist/client/theme-api/useNavData.js +78 -103
- package/dist/client/theme-api/usePrefersColor.d.ts +2 -2
- package/dist/client/theme-api/usePrefersColor.js +39 -66
- package/dist/client/theme-api/useRouteMeta.js +9 -23
- package/dist/client/theme-api/useSidebarData.js +124 -158
- package/dist/client/theme-api/useSiteSearch/index.d.ts +1 -1
- package/dist/client/theme-api/useSiteSearch/index.js +24 -38
- package/dist/client/theme-api/useTabMeta.js +8 -19
- package/dist/client/theme-api/utils.d.ts +2 -2
- package/dist/client/theme-api/utils.js +33 -47
- package/dist/client/typings.d.ts +0 -5
- package/dist/features/assets.js +23 -4
- package/dist/features/autoAlias.js +8 -3
- package/dist/features/compile/babelLoaderCustomize.js +0 -2
- package/dist/features/compile/index.js +20 -9
- package/dist/features/configPlugins/index.js +3 -4
- package/dist/features/configPlugins/schema.d.ts +1 -1
- package/dist/features/configPlugins/schema.js +20 -3
- package/dist/features/derivative.js +54 -11
- package/dist/features/exportStatic.js +11 -7
- package/dist/features/exports.js +8 -3
- package/dist/features/html2sketch.js +7 -5
- package/dist/features/locales.js +53 -17
- package/dist/features/meta.js +23 -10
- package/dist/features/parser.js +17 -5
- package/dist/features/routes.js +63 -24
- package/dist/features/sideEffects/docSideEffectsWebpackPlugin.js +27 -16
- package/dist/features/sideEffects/index.js +13 -4
- package/dist/features/sitemap.js +17 -5
- package/dist/features/tabs.js +23 -11
- package/dist/features/theme/index.js +133 -38
- package/dist/features/theme/loader.js +23 -7
- package/dist/index.js +10 -2
- package/dist/loaders/demo/index.js +3 -3
- package/dist/loaders/markdown/index.d.ts +1 -1
- package/dist/loaders/markdown/index.js +36 -24
- package/dist/loaders/markdown/transformer/index.d.ts +2 -1
- package/dist/loaders/markdown/transformer/index.js +34 -17
- package/dist/loaders/markdown/transformer/rehypeDemo.d.ts +3 -1
- package/dist/loaders/markdown/transformer/rehypeDemo.js +125 -68
- package/dist/loaders/markdown/transformer/rehypeDesc.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeEnhancedTag.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeHighlightLine.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeImg.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeIsolation.js +36 -21
- package/dist/loaders/markdown/transformer/rehypeJsxify.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeLink.d.ts +1 -1
- package/dist/loaders/markdown/transformer/rehypeLink.js +24 -9
- package/dist/loaders/markdown/transformer/rehypeRaw.d.ts +1 -1
- package/dist/loaders/markdown/transformer/rehypeRaw.js +20 -6
- package/dist/loaders/markdown/transformer/rehypeSlug.js +16 -3
- package/dist/loaders/markdown/transformer/rehypeStrip.js +8 -3
- package/dist/loaders/markdown/transformer/rehypeText.js +14 -5
- package/dist/loaders/markdown/transformer/remarkBreaks.js +16 -5
- package/dist/loaders/markdown/transformer/remarkContainer.js +28 -13
- package/dist/loaders/markdown/transformer/remarkEmbed.js +43 -21
- package/dist/loaders/markdown/transformer/remarkMeta.d.ts +3 -1
- package/dist/loaders/markdown/transformer/remarkMeta.js +39 -9
- package/dist/loaders/page/index.js +12 -4
- package/dist/loaders/pre-raw/index.js +0 -2
- package/dist/preset.js +8 -3
- package/dist/registerMethods.js +0 -2
- package/dist/service/dev.js +8 -1
- package/dist/service/printHelp.js +3 -1
- package/dist/techStacks/react.js +8 -3
- package/dist/types.d.ts +6 -6
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +15 -6
- package/package.json +11 -9
- package/theme-default/builtins/API/index.js +15 -36
- package/theme-default/builtins/Badge/index.js +0 -3
- package/theme-default/builtins/Container/index.js +6 -15
- package/theme-default/builtins/Previewer/index.js +1 -8
- package/theme-default/builtins/SourceCode/index.js +15 -27
- package/theme-default/builtins/Table/index.js +10 -25
- package/theme-default/builtins/Tree/index.js +13 -44
- package/theme-default/layouts/DocLayout/index.js +14 -27
- package/theme-default/locales/en-US.json +4 -0
- package/theme-default/locales/zh-CN.json +4 -0
- package/theme-default/slots/ColorSwitch/index.js +7 -22
- package/theme-default/slots/Content/index.js +5 -7
- package/theme-default/slots/Content/index.less +16 -1
- package/theme-default/slots/ContentFooter/index.d.ts +4 -0
- package/theme-default/slots/ContentFooter/index.js +93 -0
- package/theme-default/slots/ContentFooter/index.less +163 -0
- package/theme-default/slots/ContentTabs/index.d.ts +1 -1
- package/theme-default/slots/ContentTabs/index.js +5 -5
- package/theme-default/slots/Features/index.js +6 -11
- package/theme-default/slots/Footer/index.js +1 -4
- package/theme-default/slots/Header/index.js +7 -18
- package/theme-default/slots/HeaderExtra/index.js +0 -2
- package/theme-default/slots/Hero/index.js +2 -6
- package/theme-default/slots/HeroTitle/index.js +0 -2
- package/theme-default/slots/LangSwitch/index.js +23 -35
- package/theme-default/slots/Logo/index.js +1 -4
- package/theme-default/slots/Navbar/index.js +14 -29
- package/theme-default/slots/NavbarExtra/index.js +0 -2
- package/theme-default/slots/NotFound/index.js +0 -2
- package/theme-default/slots/PreviewerActions/index.js +13 -35
- package/theme-default/slots/PreviewerActionsExtra/index.js +0 -2
- package/theme-default/slots/RtlSwitch/index.js +6 -20
- package/theme-default/slots/RtlSwitch/index.less +5 -0
- package/theme-default/slots/SearchBar/Input.d.ts +1 -1
- package/theme-default/slots/SearchBar/Input.js +6 -5
- package/theme-default/slots/SearchBar/Mask.d.ts +1 -1
- package/theme-default/slots/SearchBar/Mask.js +0 -1
- package/theme-default/slots/SearchBar/index.js +20 -41
- package/theme-default/slots/SearchResult/index.d.ts +1 -1
- package/theme-default/slots/SearchResult/index.js +13 -36
- package/theme-default/slots/Sidebar/index.js +1 -4
- package/theme-default/slots/SocialIcon/index.d.ts +2 -2
- package/theme-default/slots/SocialIcon/index.js +1 -3
- package/theme-default/slots/Toc/index.js +12 -28
|
Binary file
|
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/assetParsers/atom.ts
|
|
@@ -45,6 +52,7 @@ var AtomAssetsParser = class {
|
|
|
45
52
|
basePath: (0, import_utils.getProjectRoot)(opts.resolveDir),
|
|
46
53
|
unPkgHost: opts.unpkgHost ?? "https://unpkg.com",
|
|
47
54
|
mode: "worker",
|
|
55
|
+
// @ts-ignore
|
|
48
56
|
parseOptions: opts.parseOptions
|
|
49
57
|
});
|
|
50
58
|
this.watchArgs = {
|
|
@@ -88,7 +96,9 @@ var AtomAssetsParser = class {
|
|
|
88
96
|
const size = Buffer.byteLength(JSON.stringify(propsConfig));
|
|
89
97
|
if (size > MAX_PARSE_SIZE) {
|
|
90
98
|
propsConfig = fallbackProps;
|
|
91
|
-
import_plugin_utils.logger.warn(
|
|
99
|
+
import_plugin_utils.logger.warn(
|
|
100
|
+
`Parsed component ${id} props size ${size} exceeds 512KB, skip it.`
|
|
101
|
+
);
|
|
92
102
|
}
|
|
93
103
|
result.components[id] = {
|
|
94
104
|
type: "COMPONENT",
|
|
@@ -107,7 +117,9 @@ var AtomAssetsParser = class {
|
|
|
107
117
|
const size = Buffer.byteLength(JSON.stringify(signature));
|
|
108
118
|
if (size > MAX_PARSE_SIZE) {
|
|
109
119
|
signature = fallbackSignature;
|
|
110
|
-
import_plugin_utils.logger.warn(
|
|
120
|
+
import_plugin_utils.logger.warn(
|
|
121
|
+
`Parsed function ${id} signature size ${size} exceeds 512KB, skip it.`
|
|
122
|
+
);
|
|
111
123
|
}
|
|
112
124
|
result.functions[id] = {
|
|
113
125
|
type: "FUNCTION",
|
|
@@ -153,5 +165,3 @@ var AtomAssetsParser = class {
|
|
|
153
165
|
}
|
|
154
166
|
};
|
|
155
167
|
var atom_default = AtomAssetsParser;
|
|
156
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
157
|
-
0 && (module.exports = {});
|
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/assetParsers/block.ts
|
|
@@ -44,11 +51,14 @@ async function parseBlockAsset(opts) {
|
|
|
44
51
|
frontmatter: null
|
|
45
52
|
};
|
|
46
53
|
const deferrer = (0, import_esbuild.build)({
|
|
54
|
+
// do not emit file
|
|
47
55
|
write: false,
|
|
56
|
+
// enable bundle for trigger onResolve hook, but all deps will be externalized
|
|
48
57
|
bundle: true,
|
|
49
58
|
logLevel: "silent",
|
|
50
59
|
format: "esm",
|
|
51
60
|
target: "esnext",
|
|
61
|
+
// esbuild need relative entry path
|
|
52
62
|
entryPoints: [import_path.default.basename(opts.fileAbsPath)],
|
|
53
63
|
absWorkingDir: import_path.default.dirname(opts.fileAbsPath),
|
|
54
64
|
plugins: [
|
|
@@ -58,7 +68,10 @@ async function parseBlockAsset(opts) {
|
|
|
58
68
|
builder.onResolve({ filter: /.*/ }, (args) => {
|
|
59
69
|
if (args.kind !== "entry-point" && !args.path.startsWith(".")) {
|
|
60
70
|
const resolved = opts.resolver(args.resolveDir, args.path);
|
|
61
|
-
(0, import_assert.default)(
|
|
71
|
+
(0, import_assert.default)(
|
|
72
|
+
resolved,
|
|
73
|
+
`Can't resolve ${args.path} from ${args.resolveDir}`
|
|
74
|
+
);
|
|
62
75
|
const pkgJsonPath = import_plugin_utils.pkgUp.pkgUpSync({
|
|
63
76
|
cwd: resolved
|
|
64
77
|
});
|
|
@@ -88,26 +101,33 @@ async function parseBlockAsset(opts) {
|
|
|
88
101
|
".json"
|
|
89
102
|
].includes(ext);
|
|
90
103
|
const isEntryPoint = args.pluginData.kind === "entry-point";
|
|
91
|
-
const filename = isEntryPoint ? `index${ext}` : (0, import_plugin_utils.winPath)(
|
|
104
|
+
const filename = isEntryPoint ? `index${ext}` : (0, import_plugin_utils.winPath)(
|
|
105
|
+
import_path.default.relative(import_path.default.dirname(opts.fileAbsPath), args.path)
|
|
106
|
+
).replace(/^(\.?\.\/)+/g, "");
|
|
92
107
|
if (isModule || isPlainText) {
|
|
93
108
|
asset.dependencies[filename] = {
|
|
94
109
|
type: "FILE",
|
|
95
110
|
value: opts.entryPointCode ?? import_fs.default.readFileSync(args.path, "utf-8")
|
|
96
111
|
};
|
|
97
112
|
if (isEntryPoint) {
|
|
98
|
-
const { code, frontmatter } = (0, import_utils.parseCodeFrontmatter)(
|
|
113
|
+
const { code, frontmatter } = (0, import_utils.parseCodeFrontmatter)(
|
|
114
|
+
asset.dependencies[filename].value
|
|
115
|
+
);
|
|
99
116
|
if (frontmatter) {
|
|
100
117
|
asset.dependencies[filename].value = code;
|
|
101
118
|
result.frontmatter = frontmatter;
|
|
102
|
-
["description", "title", "snapshot", "keywords"].forEach(
|
|
103
|
-
|
|
104
|
-
|
|
119
|
+
["description", "title", "snapshot", "keywords"].forEach(
|
|
120
|
+
(key) => {
|
|
121
|
+
asset[key] = frontmatter == null ? void 0 : frontmatter[key];
|
|
122
|
+
}
|
|
123
|
+
);
|
|
105
124
|
}
|
|
106
125
|
}
|
|
107
126
|
if (!isEntryPoint || !opts.entryPointCode) {
|
|
108
127
|
result.sources[filename] = args.path;
|
|
109
128
|
}
|
|
110
129
|
return {
|
|
130
|
+
// only continue to load for module files
|
|
111
131
|
contents: isModule ? asset.dependencies[filename].value : "",
|
|
112
132
|
loader: isModule ? ext.slice(1) : "text"
|
|
113
133
|
};
|
|
@@ -124,5 +144,3 @@ async function parseBlockAsset(opts) {
|
|
|
124
144
|
return result;
|
|
125
145
|
}
|
|
126
146
|
var block_default = parseBlockAsset;
|
|
127
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
-
0 && (module.exports = {});
|
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
}
|
|
13
13
|
return to;
|
|
14
14
|
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
16
23
|
|
|
17
24
|
// src/cli.ts
|
|
18
25
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { useParams, useSiteData } from 'dumi';
|
|
2
2
|
import { createElement } from 'react';
|
|
3
3
|
import "./index.less";
|
|
4
|
-
|
|
5
4
|
var DemoRenderPage = function DemoRenderPage() {
|
|
6
5
|
var _useParams = useParams(),
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
id = _useParams.id;
|
|
9
7
|
var _useSiteData = useSiteData(),
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
demos = _useSiteData.demos;
|
|
12
9
|
var _ref = demos[id] || {},
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
component = _ref.component;
|
|
15
11
|
return component && /*#__PURE__*/createElement(component);
|
|
16
12
|
};
|
|
17
|
-
|
|
18
13
|
export default DemoRenderPage;
|
|
@@ -6,8 +6,8 @@ interface IAtomRendererProps {
|
|
|
6
6
|
value: ExamplePresetAsset['value'];
|
|
7
7
|
processor?: typeof builtInProcessor;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
type Entity = TypeMap['element'] | TypeMap['function'] | TypeMap['dom'];
|
|
10
|
+
type Exports = Record<string, any>;
|
|
11
11
|
declare function builtInProcessor(entity: Entity, entryExports: Exports): any;
|
|
12
12
|
export declare const AtomRenderer: FC<IAtomRendererProps>;
|
|
13
13
|
export {};
|
|
@@ -1,77 +1,64 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
3
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
5
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
6
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
|
|
9
7
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
|
|
11
8
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
16
|
-
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
17
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
|
|
19
12
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
20
|
-
|
|
21
13
|
import { useSiteData } from 'dumi';
|
|
22
14
|
import React from 'react';
|
|
23
|
-
|
|
24
15
|
function builtInProcessor(entity, entryExports) {
|
|
25
16
|
var mod;
|
|
26
|
-
|
|
27
17
|
switch (entity.$$__type) {
|
|
28
18
|
case 'function':
|
|
29
19
|
// eslint-disable-next-line no-eval
|
|
30
20
|
return eval(entity.$$__body.sourceCode);
|
|
31
|
-
|
|
32
21
|
case 'element':
|
|
33
22
|
// find child component from entry exports
|
|
34
23
|
mod = entity.$$__body.componentName.split('.').reduce(function (col, cur) {
|
|
35
24
|
return col[cur];
|
|
36
|
-
}, entryExports);
|
|
25
|
+
}, entryExports);
|
|
37
26
|
|
|
38
|
-
|
|
27
|
+
// fallback to HTML tag
|
|
28
|
+
if (mod === undefined) return entity.$$__body.componentName;
|
|
39
29
|
|
|
30
|
+
// support pure render for antd components
|
|
40
31
|
return '_InternalPanelDoNotUseOrYouWillBeFired' in mod ? mod._InternalPanelDoNotUseOrYouWillBeFired : mod;
|
|
41
32
|
}
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
function deepReplace(value, entityProcessor) {
|
|
45
35
|
// transform array props
|
|
46
36
|
if (Array.isArray(value)) {
|
|
47
37
|
return value.map(function (e) {
|
|
48
38
|
return deepReplace(e, entityProcessor);
|
|
49
39
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
40
|
+
}
|
|
52
41
|
|
|
42
|
+
// transform element props
|
|
53
43
|
if (_typeof(value) === 'object' && (value === null || value === void 0 ? void 0 : value.$$__type) === 'element') {
|
|
54
44
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
55
45
|
return translatePresetToReact(value.$$__body, entityProcessor);
|
|
56
|
-
}
|
|
57
|
-
|
|
46
|
+
}
|
|
58
47
|
|
|
48
|
+
// transform pure object props
|
|
59
49
|
if (_typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Object]') {
|
|
60
50
|
return Object.entries(value).reduce(function (col, _ref) {
|
|
61
51
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
key = _ref2[0],
|
|
53
|
+
value = _ref2[1];
|
|
65
54
|
return _objectSpread(_objectSpread({}, col), {}, _defineProperty({}, key, deepReplace(value, entityProcessor)));
|
|
66
55
|
}, {});
|
|
67
56
|
}
|
|
68
|
-
|
|
69
57
|
return value;
|
|
70
58
|
}
|
|
71
|
-
|
|
72
59
|
function translatePresetToReact(value, processor) {
|
|
73
60
|
var props = value.props,
|
|
74
|
-
|
|
61
|
+
size = value.size;
|
|
75
62
|
var Component = processor({
|
|
76
63
|
$$__type: 'element',
|
|
77
64
|
$$__body: value
|
|
@@ -80,22 +67,19 @@ function translatePresetToReact(value, processor) {
|
|
|
80
67
|
style: _objectSpread(_objectSpread({}, props.style), size)
|
|
81
68
|
}), processor));
|
|
82
69
|
}
|
|
83
|
-
|
|
84
70
|
export var AtomRenderer = function AtomRenderer(props) {
|
|
85
71
|
var _useSiteData = useSiteData(),
|
|
86
|
-
|
|
87
|
-
|
|
72
|
+
entryExports = _useSiteData.entryExports;
|
|
88
73
|
switch (props.type) {
|
|
89
74
|
case 'COMPONENT':
|
|
90
75
|
return translatePresetToReact(props.value, function (entity) {
|
|
91
76
|
var _props$processor, _props$processor2;
|
|
92
|
-
|
|
93
77
|
return (// support custom processor
|
|
94
|
-
(_props$processor = (_props$processor2 = props.processor) === null || _props$processor2 === void 0 ? void 0 : _props$processor2.call(props, entity, entryExports)) !== null && _props$processor !== void 0 ? _props$processor :
|
|
78
|
+
(_props$processor = (_props$processor2 = props.processor) === null || _props$processor2 === void 0 ? void 0 : _props$processor2.call(props, entity, entryExports)) !== null && _props$processor !== void 0 ? _props$processor :
|
|
79
|
+
// fallback to built-in processor
|
|
95
80
|
builtInProcessor(entity, entryExports)
|
|
96
81
|
);
|
|
97
82
|
});
|
|
98
|
-
|
|
99
83
|
default:
|
|
100
84
|
// TODO: handle FUNCTION type
|
|
101
85
|
return /*#__PURE__*/React.createElement(React.Fragment, null, props.type, " atom is not supported.");
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
2
|
import { SP_ROUTE_PREFIX } from "../../constants";
|
|
4
3
|
import { useAppData, useSiteData } from 'dumi';
|
|
5
4
|
import Container from 'dumi/theme/builtins/Container';
|
|
6
5
|
import Previewer from 'dumi/theme/builtins/Previewer';
|
|
7
6
|
import React, { createElement } from 'react';
|
|
8
7
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
9
|
-
|
|
10
8
|
var DemoErrorBoundary = function DemoErrorBoundary(props) {
|
|
11
9
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
12
10
|
fallbackRender: function fallbackRender(_ref) {
|
|
@@ -19,29 +17,26 @@ var DemoErrorBoundary = function DemoErrorBoundary(props) {
|
|
|
19
17
|
}
|
|
20
18
|
}, props.children);
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
export var DumiDemo = /*#__PURE__*/React.memo(function (props) {
|
|
24
21
|
var _useSiteData = useSiteData(),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
demos = _useSiteData.demos,
|
|
23
|
+
historyType = _useSiteData.historyType;
|
|
28
24
|
var _useAppData = useAppData(),
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
basename = _useAppData.basename;
|
|
31
26
|
var _demos$props$demo$id = demos[props.demo.id],
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
component = _demos$props$demo$id.component,
|
|
28
|
+
asset = _demos$props$demo$id.asset;
|
|
34
29
|
|
|
30
|
+
// hide debug demo in production
|
|
35
31
|
if (process.env.NODE_ENV === 'production' && props.previewerProps.debug) return null;
|
|
36
|
-
|
|
37
32
|
if (props.demo.inline) {
|
|
38
33
|
return /*#__PURE__*/React.createElement(DemoErrorBoundary, null, /*#__PURE__*/createElement(component));
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
var isHashRoute = historyType === 'hash';
|
|
42
36
|
return /*#__PURE__*/React.createElement(Previewer, _extends({
|
|
43
37
|
asset: asset,
|
|
44
|
-
demoUrl:
|
|
38
|
+
demoUrl:
|
|
39
|
+
// allow user override demoUrl by frontmatter
|
|
45
40
|
props.previewerProps.demoUrl || // when use hash route, browser can automatically handle relative paths starting with #
|
|
46
41
|
"".concat(isHashRoute ? "#" : '').concat(basename).concat(SP_ROUTE_PREFIX, "demos/").concat(props.demo.id)
|
|
47
42
|
}, props.previewerProps), props.previewerProps.iframe ? null : /*#__PURE__*/React.createElement(DemoErrorBoundary, null, /*#__PURE__*/createElement(component)));
|
|
@@ -1,63 +1,49 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
2
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
-
|
|
5
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
|
|
7
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
12
|
-
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
7
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
|
|
15
8
|
import { DumiDemo, useRouteMeta } from 'dumi';
|
|
16
9
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
17
10
|
export var DumiDemoGrid = function DumiDemoGrid(props) {
|
|
18
11
|
var _useRouteMeta = useRouteMeta(),
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
fm = _useRouteMeta.frontmatter;
|
|
21
13
|
var generator = useCallback(function (fm, oItems) {
|
|
22
14
|
var _fm$demo;
|
|
23
|
-
|
|
24
15
|
var cols = [];
|
|
25
|
-
var items = process.env.NODE_ENV === 'production' ?
|
|
16
|
+
var items = process.env.NODE_ENV === 'production' ?
|
|
17
|
+
// hide debug demo in production
|
|
26
18
|
oItems.filter(function (d) {
|
|
27
19
|
return !d.previewerProps.debug;
|
|
28
20
|
}) : oItems;
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
if ((_fm$demo = fm.demo) !== null && _fm$demo !== void 0 && _fm$demo.cols && fm.demo.cols > 1 && (
|
|
22
|
+
// compatible for ssr env
|
|
31
23
|
typeof window === 'undefined' || window.innerWidth > 1024)) {
|
|
32
24
|
for (var i = 0; i < items.length; i += fm.demo.cols) {
|
|
33
25
|
items.slice(i, i + fm.demo.cols).forEach(function (item, j) {
|
|
34
26
|
var _cols$j;
|
|
35
|
-
|
|
36
27
|
(_cols$j = cols[j]) !== null && _cols$j !== void 0 ? _cols$j : cols[j] = [];
|
|
37
28
|
cols[j].push(item);
|
|
38
29
|
});
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
return cols;
|
|
42
32
|
} else {
|
|
43
33
|
cols.push(items);
|
|
44
34
|
}
|
|
45
|
-
|
|
46
35
|
return cols;
|
|
47
36
|
}, []);
|
|
48
|
-
|
|
49
37
|
var _useState = useState(function () {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
return generator(fm, props.items);
|
|
39
|
+
}),
|
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
+
cols = _useState2[0],
|
|
42
|
+
setCols = _useState2[1];
|
|
56
43
|
useEffect(function () {
|
|
57
44
|
var handler = function handler() {
|
|
58
45
|
return setCols(generator(fm, props.items));
|
|
59
46
|
};
|
|
60
|
-
|
|
61
47
|
window.addEventListener('resize', handler);
|
|
62
48
|
handler();
|
|
63
49
|
return function () {
|
|
@@ -1,47 +1,29 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
11
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
|
-
import { useRouteMeta, useSiteData } from 'dumi';
|
|
7
|
+
import { useRouteMeta } from 'dumi';
|
|
14
8
|
import ContentTabs from 'dumi/theme/slots/ContentTabs';
|
|
15
|
-
import
|
|
16
|
-
import React, { useEffect, useState } from 'react';
|
|
9
|
+
import React, { useState } from 'react';
|
|
17
10
|
import { useTabQueryState } from "./useTabMeta";
|
|
18
11
|
export var DumiPage = function DumiPage(props) {
|
|
19
12
|
var _useRouteMeta = useRouteMeta(),
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
tabs = _useRouteMeta.tabs;
|
|
22
14
|
var _useTabQueryState = useTabQueryState(),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
_useTabQueryState2 = _slicedToArray(_useTabQueryState, 2),
|
|
16
|
+
tabKey = _useTabQueryState2[0],
|
|
17
|
+
setTabKey = _useTabQueryState2[1];
|
|
27
18
|
var _useState = useState(function () {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var _useSiteData = useSiteData(),
|
|
38
|
-
setLoading = _useSiteData.setLoading; // update loading status when page loaded
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
useEffect(function () {
|
|
42
|
-
setLoading(false);
|
|
43
|
-
nprogress.done();
|
|
44
|
-
}, []);
|
|
19
|
+
return tabs === null || tabs === void 0 ? void 0 : tabs.find(function (_ref) {
|
|
20
|
+
var key = _ref.key;
|
|
21
|
+
return key === tabKey;
|
|
22
|
+
});
|
|
23
|
+
}),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
tab = _useState2[0],
|
|
26
|
+
setTab = _useState2[1];
|
|
45
27
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ContentTabs, {
|
|
46
28
|
tabs: tabs,
|
|
47
29
|
tabKey: tabKey,
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
11
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
7
|
import { getParameters } from 'codesandbox/lib/api/define';
|
|
14
8
|
import { ApplyPluginsType } from 'dumi';
|
|
15
9
|
import { genReactRenderCode, pluginManager } from "./utils";
|
|
16
10
|
var CSB_API_ENDPOINT = 'https://codesandbox.io/api/v1/sandboxes/define';
|
|
11
|
+
|
|
17
12
|
/**
|
|
18
13
|
* get serialized data that use to submit to codesandbox.io
|
|
19
14
|
* @param opts previewer props
|
|
20
15
|
*/
|
|
21
|
-
|
|
22
16
|
function getCSBData(opts) {
|
|
23
17
|
var _opts$asset$dependenc, _react, _deps$_react, _reactDom, _deps$_reactDom;
|
|
24
|
-
|
|
25
18
|
var isTSX = Boolean((_opts$asset$dependenc = opts.asset.dependencies) === null || _opts$asset$dependenc === void 0 ? void 0 : _opts$asset$dependenc['index.tsx']);
|
|
26
19
|
var ext = isTSX ? '.tsx' : '.jsx';
|
|
27
20
|
var files = {};
|
|
@@ -29,11 +22,10 @@ function getCSBData(opts) {
|
|
|
29
22
|
var entryFileName = "index".concat(ext);
|
|
30
23
|
Object.entries(opts.asset.dependencies).forEach(function (_ref) {
|
|
31
24
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
name = _ref2[0],
|
|
26
|
+
_ref2$ = _ref2[1],
|
|
27
|
+
type = _ref2$.type,
|
|
28
|
+
value = _ref2$.value;
|
|
37
29
|
if (type === 'NPM') {
|
|
38
30
|
// generate dependencies
|
|
39
31
|
deps[name] = value;
|
|
@@ -44,18 +36,21 @@ function getCSBData(opts) {
|
|
|
44
36
|
isBinary: false
|
|
45
37
|
};
|
|
46
38
|
}
|
|
47
|
-
});
|
|
39
|
+
});
|
|
48
40
|
|
|
41
|
+
// add react、react-dom dependency
|
|
49
42
|
(_deps$_react = deps[_react = 'react']) !== null && _deps$_react !== void 0 ? _deps$_react : deps[_react] = 'latest';
|
|
50
|
-
(_deps$_reactDom = deps[_reactDom = 'react-dom']) !== null && _deps$_reactDom !== void 0 ? _deps$_reactDom : deps[_reactDom] = deps.react;
|
|
43
|
+
(_deps$_reactDom = deps[_reactDom = 'react-dom']) !== null && _deps$_reactDom !== void 0 ? _deps$_reactDom : deps[_reactDom] = deps.react;
|
|
51
44
|
|
|
45
|
+
// append sandbox.config.json
|
|
52
46
|
files['sandbox.config.json'] = {
|
|
53
47
|
content: JSON.stringify({
|
|
54
48
|
template: 'create-react-app'
|
|
55
49
|
}, null, 2),
|
|
56
50
|
isBinary: false
|
|
57
|
-
};
|
|
51
|
+
};
|
|
58
52
|
|
|
53
|
+
// append package.json
|
|
59
54
|
files['package.json'] = {
|
|
60
55
|
content: JSON.stringify({
|
|
61
56
|
name: opts.title,
|
|
@@ -68,13 +63,15 @@ function getCSBData(opts) {
|
|
|
68
63
|
} : {}
|
|
69
64
|
}, null, 2),
|
|
70
65
|
isBinary: false
|
|
71
|
-
};
|
|
66
|
+
};
|
|
72
67
|
|
|
68
|
+
// append index.html
|
|
73
69
|
files['index.html'] = {
|
|
74
70
|
content: '<div style="margin: 16px;" id="root"></div>',
|
|
75
71
|
isBinary: false
|
|
76
|
-
};
|
|
72
|
+
};
|
|
77
73
|
|
|
74
|
+
// append entry file
|
|
78
75
|
files[entryFileName] = {
|
|
79
76
|
content: genReactRenderCode(deps.react),
|
|
80
77
|
isBinary: false
|
|
@@ -89,17 +86,15 @@ function getCSBData(opts) {
|
|
|
89
86
|
});
|
|
90
87
|
return getParameters(csbOpts);
|
|
91
88
|
}
|
|
89
|
+
|
|
92
90
|
/**
|
|
93
91
|
* use CodeSandbox.io
|
|
94
92
|
* @param data previewer opts
|
|
95
93
|
* @param opts the api that CodeSandbox calls when creating the demo
|
|
96
94
|
* @note return a open function for open demo on codesandbox.io
|
|
97
95
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
96
|
export var openCodeSandbox = function openCodeSandbox(data, opts) {
|
|
101
97
|
var _data$assets;
|
|
102
|
-
|
|
103
98
|
var form = document.createElement('form');
|
|
104
99
|
var input = document.createElement('input');
|
|
105
100
|
var CSBData = getCSBData(data);
|