dumi 2.2.7 → 2.3.0-alpha.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/client/pages/Demo/index.js +3 -4
- package/dist/client/theme-api/DumiDemo/DemoErrorBoundary.d.ts +5 -0
- package/dist/client/theme-api/DumiDemo/DemoErrorBoundary.js +16 -0
- package/dist/client/theme-api/{DumiDemo.d.ts → DumiDemo/index.d.ts} +1 -1
- package/dist/client/theme-api/DumiDemo/index.js +37 -0
- package/dist/client/theme-api/DumiDemoGrid.js +4 -1
- package/dist/client/theme-api/{context.d.ts → context/index.d.ts} +11 -7
- package/dist/client/theme-api/context/index.js +50 -0
- package/dist/client/theme-api/context/use.d.ts +10 -0
- package/dist/client/theme-api/context/use.js +25 -0
- package/dist/client/theme-api/index.d.ts +2 -2
- package/dist/client/theme-api/index.js +2 -2
- package/dist/client/theme-api/useRouteMeta.js +27 -26
- package/dist/client/theme-api/useSiteSearch/index.js +31 -13
- package/dist/client/theme-api/useSiteSearch/useSearchData.d.ts +9 -0
- package/dist/client/theme-api/useSiteSearch/useSearchData.js +76 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +4 -0
- package/dist/features/compile/index.js +13 -1
- package/dist/features/exports.js +3 -1
- package/dist/features/meta.js +41 -76
- package/dist/features/theme/index.js +19 -55
- package/dist/loaders/markdown/index.d.ts +15 -3
- package/dist/loaders/markdown/index.js +117 -38
- package/dist/templates/ContextWrapper.ts.tpl +92 -0
- package/dist/templates/meta-demos.ts.tpl +34 -0
- package/dist/templates/meta-frontmatter.ts.tpl +9 -0
- package/dist/templates/meta-route.ts.tpl +43 -0
- package/dist/templates/meta-runtime.ts.tpl +48 -0
- package/dist/templates/meta-search.ts.tpl +43 -0
- package/index.d.ts +3 -0
- package/package.json +2 -1
- package/theme-default/locales/en-US.json +1 -0
- package/theme-default/locales/zh-CN.json +1 -0
- package/theme-default/slots/ContentTabs/index.js +0 -1
- package/theme-default/slots/SearchBar/index.js +3 -3
- package/theme-default/slots/SearchResult/index.js +34 -22
- package/dist/client/theme-api/DumiDemo.js +0 -46
- package/dist/client/theme-api/context.js +0 -16
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useDemoData, useParams } from 'dumi';
|
|
2
2
|
import { createElement } from 'react';
|
|
3
3
|
import "./index.less";
|
|
4
4
|
var DemoRenderPage = function DemoRenderPage() {
|
|
5
5
|
var _useParams = useParams(),
|
|
6
6
|
id = _useParams.id;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var _ref = demos[id] || {},
|
|
7
|
+
var demoInfo = useDemoData(id);
|
|
8
|
+
var _ref = demoInfo,
|
|
10
9
|
component = _ref.component;
|
|
11
10
|
return component && /*#__PURE__*/createElement(component);
|
|
12
11
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Container from 'dumi/theme/builtins/Container';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
4
|
+
var DemoErrorBoundary = function DemoErrorBoundary(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
6
|
+
fallbackRender: function fallbackRender(_ref) {
|
|
7
|
+
var error = _ref.error;
|
|
8
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
9
|
+
type: "error"
|
|
10
|
+
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("strong", null, error.message || 'This demo has been crashed.')), error.stack && /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("details", {
|
|
11
|
+
open: true
|
|
12
|
+
}, /*#__PURE__*/React.createElement("summary", null, "Error stack"), /*#__PURE__*/React.createElement("pre", null, error.stack))));
|
|
13
|
+
}
|
|
14
|
+
}, props.children);
|
|
15
|
+
};
|
|
16
|
+
export default DemoErrorBoundary;
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
import { SP_ROUTE_PREFIX } from "../../../constants";
|
|
3
|
+
import { useAppData, useDemoData, useSiteData } from 'dumi';
|
|
4
|
+
import React, { createElement } from 'react';
|
|
5
|
+
import Previewer from 'dumi/theme/builtins/Previewer';
|
|
6
|
+
import DemoErrorBoundary from "./DemoErrorBoundary";
|
|
7
|
+
var InternalDumiDemo = function InternalDumiDemo(props) {
|
|
8
|
+
var _useSiteData = useSiteData(),
|
|
9
|
+
historyType = _useSiteData.historyType;
|
|
10
|
+
var _useAppData = useAppData(),
|
|
11
|
+
basename = _useAppData.basename;
|
|
12
|
+
var demoInfo = useDemoData(props.demo.id);
|
|
13
|
+
|
|
14
|
+
// hide debug demo in production
|
|
15
|
+
if (process.env.NODE_ENV === 'production' && props.previewerProps.debug) return null;
|
|
16
|
+
var component = demoInfo.component,
|
|
17
|
+
asset = demoInfo.asset;
|
|
18
|
+
var demoNode = /*#__PURE__*/React.createElement(DemoErrorBoundary, null, /*#__PURE__*/createElement(component));
|
|
19
|
+
if (props.demo.inline) {
|
|
20
|
+
return demoNode;
|
|
21
|
+
}
|
|
22
|
+
var isHashRoute = historyType === 'hash';
|
|
23
|
+
return /*#__PURE__*/React.createElement(Previewer, _extends({
|
|
24
|
+
asset: asset,
|
|
25
|
+
demoUrl:
|
|
26
|
+
// allow user override demoUrl by frontmatter
|
|
27
|
+
props.previewerProps.demoUrl || // when use hash route, browser can automatically handle relative paths starting with #
|
|
28
|
+
"".concat(isHashRoute ? "#" : '').concat(basename).concat(SP_ROUTE_PREFIX, "demos/").concat(props.demo.id)
|
|
29
|
+
}, props.previewerProps), props.previewerProps.iframe ? null : demoNode);
|
|
30
|
+
};
|
|
31
|
+
export var DumiDemo = /*#__PURE__*/React.memo(InternalDumiDemo, function (prev, next) {
|
|
32
|
+
// compare length for performance
|
|
33
|
+
return JSON.stringify(prev).length === JSON.stringify(next).length;
|
|
34
|
+
});
|
|
35
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
36
|
+
InternalDumiDemo.displayName = 'DumiDemo';
|
|
37
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import type { PICKED_PKG_FIELDS } from "
|
|
1
|
+
import type { PICKED_PKG_FIELDS } from "../../../constants";
|
|
2
2
|
import type { AtomComponentAsset } from 'dumi-assets-types';
|
|
3
3
|
import { type ComponentType } from 'react';
|
|
4
|
-
import type { ILocalesConfig, IPreviewerProps, IThemeConfig } from '
|
|
4
|
+
import type { ILocalesConfig, IPreviewerProps, IRouteMeta, IThemeConfig } from '../types';
|
|
5
|
+
export type DemoInfo = {
|
|
6
|
+
component: ComponentType;
|
|
7
|
+
asset: IPreviewerProps['asset'];
|
|
8
|
+
routeId: string;
|
|
9
|
+
};
|
|
5
10
|
interface ISiteContext {
|
|
6
11
|
pkg: Partial<Record<keyof typeof PICKED_PKG_FIELDS, any>>;
|
|
7
12
|
historyType: 'browser' | 'hash' | 'memory';
|
|
8
13
|
entryExports: Record<string, any>;
|
|
9
|
-
demos: Record<string,
|
|
10
|
-
component: ComponentType;
|
|
11
|
-
asset: IPreviewerProps['asset'];
|
|
12
|
-
routeId: string;
|
|
13
|
-
}>;
|
|
14
|
+
demos: Record<string, DemoInfo>;
|
|
14
15
|
components: Record<string, AtomComponentAsset>;
|
|
16
|
+
tabs: IRouteMeta['tabs'];
|
|
15
17
|
locales: ILocalesConfig;
|
|
16
18
|
themeConfig: IThemeConfig;
|
|
17
19
|
hostname?: string;
|
|
@@ -21,7 +23,9 @@ interface ISiteContext {
|
|
|
21
23
|
* private field, do not use it in your code
|
|
22
24
|
*/
|
|
23
25
|
_2_level_nav_available: boolean;
|
|
26
|
+
getDemoById: (id: string) => Promise<DemoInfo | null>;
|
|
24
27
|
}
|
|
25
28
|
export declare const SiteContext: import("react").Context<ISiteContext>;
|
|
26
29
|
export declare const useSiteData: () => ISiteContext;
|
|
30
|
+
export declare function useDemoData(demoId: string): DemoInfo | null;
|
|
27
31
|
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
import { createContext, useContext } from 'react';
|
|
6
|
+
import use from "./use";
|
|
7
|
+
export var SiteContext = /*#__PURE__*/createContext({
|
|
8
|
+
pkg: {},
|
|
9
|
+
historyType: 'browser',
|
|
10
|
+
entryExports: {},
|
|
11
|
+
demos: {},
|
|
12
|
+
components: {},
|
|
13
|
+
locales: [],
|
|
14
|
+
themeConfig: {},
|
|
15
|
+
loading: false,
|
|
16
|
+
setLoading: function setLoading() {},
|
|
17
|
+
_2_level_nav_available: true,
|
|
18
|
+
getDemoById: function () {
|
|
19
|
+
var _getDemoById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
20
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
21
|
+
while (1) switch (_context.prev = _context.next) {
|
|
22
|
+
case 0:
|
|
23
|
+
return _context.abrupt("return", null);
|
|
24
|
+
case 1:
|
|
25
|
+
case "end":
|
|
26
|
+
return _context.stop();
|
|
27
|
+
}
|
|
28
|
+
}, _callee);
|
|
29
|
+
}));
|
|
30
|
+
function getDemoById() {
|
|
31
|
+
return _getDemoById.apply(this, arguments);
|
|
32
|
+
}
|
|
33
|
+
return getDemoById;
|
|
34
|
+
}(),
|
|
35
|
+
tabs: []
|
|
36
|
+
});
|
|
37
|
+
export var useSiteData = function useSiteData() {
|
|
38
|
+
return useContext(SiteContext);
|
|
39
|
+
};
|
|
40
|
+
var cache = new Map();
|
|
41
|
+
|
|
42
|
+
// Async load demo data
|
|
43
|
+
export function useDemoData(demoId) {
|
|
44
|
+
var _useSiteData = useSiteData(),
|
|
45
|
+
getDemoById = _useSiteData.getDemoById;
|
|
46
|
+
if (!cache.has(demoId)) {
|
|
47
|
+
cache.set(demoId, getDemoById(demoId));
|
|
48
|
+
}
|
|
49
|
+
return use(cache.get(demoId));
|
|
50
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copy from React official demo.
|
|
2
|
+
// This will be replace if React release new version of use hooks
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @private Internal usage. Safe to remove
|
|
6
|
+
*/
|
|
7
|
+
export default function use(promise) {
|
|
8
|
+
if (promise.status === 'fulfilled') {
|
|
9
|
+
return promise.value;
|
|
10
|
+
} else if (promise.status === 'rejected') {
|
|
11
|
+
throw promise.reason;
|
|
12
|
+
} else if (promise.status === 'pending') {
|
|
13
|
+
throw promise;
|
|
14
|
+
} else {
|
|
15
|
+
promise.status = 'pending';
|
|
16
|
+
promise.then(function (result) {
|
|
17
|
+
promise.status = 'fulfilled';
|
|
18
|
+
promise.value = result;
|
|
19
|
+
}, function (reason) {
|
|
20
|
+
promise.status = 'rejected';
|
|
21
|
+
promise.reason = reason;
|
|
22
|
+
});
|
|
23
|
+
throw promise;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { FormattedDate, FormattedDateParts, FormattedDisplayName, FormattedList, FormattedMessage, FormattedNumber, FormattedNumberParts, FormattedPlural, FormattedRelativeTime, FormattedTime, FormattedTimeParts, IntlContext, IntlProvider, RawIntlProvider, createIntlCache, defineMessages, injectIntl, useIntl, } from 'react-intl';
|
|
2
2
|
export { AtomRenderer } from './AtomRenderer';
|
|
3
|
-
export { useSiteData } from './context';
|
|
4
3
|
export { DumiDemo } from './DumiDemo';
|
|
5
4
|
export { DumiDemoGrid } from './DumiDemoGrid';
|
|
6
5
|
export { DumiPage } from './DumiPage';
|
|
6
|
+
export { useDemoData, useSiteData } from './context';
|
|
7
7
|
export { openCodeSandbox } from './openCodeSandbox';
|
|
8
8
|
export { openStackBlitz } from './openStackBlitz';
|
|
9
9
|
export type { IPreviewerProps } from './types';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { FormattedDate, FormattedDateParts, FormattedDisplayName, FormattedList, FormattedMessage, FormattedNumber, FormattedNumberParts, FormattedPlural, FormattedRelativeTime, FormattedTime, FormattedTimeParts, IntlContext, IntlProvider, RawIntlProvider, createIntlCache, defineMessages, injectIntl, useIntl } from 'react-intl';
|
|
2
2
|
export { AtomRenderer } from "./AtomRenderer";
|
|
3
|
-
export { useSiteData } from "./context";
|
|
4
3
|
export { DumiDemo } from "./DumiDemo";
|
|
5
4
|
export { DumiDemoGrid } from "./DumiDemoGrid";
|
|
6
5
|
export { DumiPage } from "./DumiPage";
|
|
6
|
+
export { useDemoData, useSiteData } from "./context";
|
|
7
7
|
export { openCodeSandbox } from "./openCodeSandbox";
|
|
8
8
|
export { openStackBlitz } from "./openStackBlitz";
|
|
9
9
|
export { useAtomAssets } from "./useAtomAssets";
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
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); }
|
|
2
|
+
import { getRouteMetaById, matchRoutes, useAppData, useLocation, useRouteData } from 'dumi';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import use from "./context/use";
|
|
5
|
+
var cache = new Map();
|
|
6
|
+
var useAsyncRouteMeta = function useAsyncRouteMeta(id) {
|
|
7
|
+
if (!cache.has(id)) {
|
|
8
|
+
cache.set(id, getRouteMetaById(id));
|
|
9
|
+
}
|
|
10
|
+
return use(cache.get(id));
|
|
11
|
+
};
|
|
12
|
+
var emptyMeta = {
|
|
13
|
+
frontmatter: {},
|
|
14
|
+
toc: [],
|
|
15
|
+
texts: []
|
|
16
|
+
};
|
|
10
17
|
|
|
11
18
|
/**
|
|
12
19
|
* hook for get matched route meta
|
|
@@ -18,29 +25,23 @@ export var useRouteMeta = function useRouteMeta() {
|
|
|
18
25
|
pathname = _useLocation.pathname;
|
|
19
26
|
var _useAppData = useAppData(),
|
|
20
27
|
clientRoutes = _useAppData.clientRoutes;
|
|
21
|
-
var
|
|
22
|
-
var ret;
|
|
28
|
+
var curRoute = useMemo(function () {
|
|
23
29
|
if (route.path === pathname && !('isLayout' in route)) {
|
|
24
30
|
// use `useRouteData` result if matched, for performance
|
|
25
|
-
|
|
31
|
+
return route;
|
|
26
32
|
} else {
|
|
27
|
-
var _matchRoutes
|
|
33
|
+
var _matchRoutes;
|
|
28
34
|
// match manually for dynamic route & layout component
|
|
29
35
|
var matched = (_matchRoutes = matchRoutes(clientRoutes, pathname)) === null || _matchRoutes === void 0 ? void 0 : _matchRoutes.pop();
|
|
30
|
-
|
|
36
|
+
return matched === null || matched === void 0 ? void 0 : matched.route;
|
|
31
37
|
}
|
|
32
|
-
return ret || {
|
|
33
|
-
frontmatter: {},
|
|
34
|
-
toc: [],
|
|
35
|
-
texts: []
|
|
36
|
-
};
|
|
37
|
-
}, [clientRoutes.length, pathname]);
|
|
38
|
-
var _useState = useState(getter),
|
|
39
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
40
|
-
meta = _useState2[0],
|
|
41
|
-
setMeta = _useState2[1];
|
|
42
|
-
useIsomorphicLayoutEffect(function () {
|
|
43
|
-
setMeta(getter);
|
|
44
38
|
}, [clientRoutes.length, pathname]);
|
|
39
|
+
var meta = useAsyncRouteMeta(curRoute === null || curRoute === void 0 ? void 0 : curRoute.id) || emptyMeta;
|
|
40
|
+
if (curRoute && 'meta' in curRoute && _typeof(curRoute.meta) === 'object') {
|
|
41
|
+
Object.keys(curRoute.meta).forEach(function (key) {
|
|
42
|
+
var _ref, _ref$key;
|
|
43
|
+
(_ref$key = (_ref = meta)[key]) !== null && _ref$key !== void 0 ? _ref$key : _ref[key] = curRoute.meta[key];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
45
46
|
return meta;
|
|
46
47
|
};
|
|
@@ -10,11 +10,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
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; }
|
|
11
11
|
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; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import { useNavData
|
|
13
|
+
import { useNavData } from 'dumi';
|
|
14
14
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
15
|
-
import { useLocaleDocRoutes } from "../utils";
|
|
16
15
|
// @ts-ignore
|
|
17
16
|
import workerCode from '-!../../../../compiled/_internal/searchWorker.min?dumi-raw';
|
|
17
|
+
import useSearchData from "./useSearchData";
|
|
18
18
|
var worker;
|
|
19
19
|
|
|
20
20
|
// for ssr
|
|
@@ -26,9 +26,8 @@ if (typeof window !== 'undefined') {
|
|
|
26
26
|
}
|
|
27
27
|
export var useSiteSearch = function useSiteSearch() {
|
|
28
28
|
var debounceTimer = useRef();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
demos = _useSiteData.demos;
|
|
29
|
+
// const routes = useLocaleDocRoutes();
|
|
30
|
+
// const { demos } = useSiteData();
|
|
32
31
|
var _useState = useState(false),
|
|
33
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
34
33
|
loading = _useState2[0],
|
|
@@ -37,15 +36,27 @@ export var useSiteSearch = function useSiteSearch() {
|
|
|
37
36
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
38
37
|
keywords = _useState4[0],
|
|
39
38
|
setKeywords = _useState4[1];
|
|
40
|
-
var
|
|
41
|
-
var _useState5 = useState([]),
|
|
39
|
+
var _useState5 = useState(false),
|
|
42
40
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
enabled = _useState6[0],
|
|
42
|
+
setEnabled = _useState6[1];
|
|
43
|
+
var navData = useNavData();
|
|
44
|
+
var _useState7 = useState([]),
|
|
45
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
46
|
+
result = _useState8[0],
|
|
47
|
+
setResult = _useState8[1];
|
|
45
48
|
var setter = useCallback(function (val) {
|
|
46
49
|
setLoading(true);
|
|
47
50
|
setKeywords(val);
|
|
51
|
+
if (val) {
|
|
52
|
+
setEnabled(true);
|
|
53
|
+
}
|
|
48
54
|
}, []);
|
|
55
|
+
var _useSearchData = useSearchData(enabled),
|
|
56
|
+
_useSearchData2 = _slicedToArray(_useSearchData, 2),
|
|
57
|
+
filledRoutes = _useSearchData2[0],
|
|
58
|
+
demos = _useSearchData2[1];
|
|
59
|
+
var mergedLoading = loading || !filledRoutes;
|
|
49
60
|
useEffect(function () {
|
|
50
61
|
worker.onmessage = function (e) {
|
|
51
62
|
setResult(e.data);
|
|
@@ -53,6 +64,10 @@ export var useSiteSearch = function useSiteSearch() {
|
|
|
53
64
|
};
|
|
54
65
|
}, []);
|
|
55
66
|
useEffect(function () {
|
|
67
|
+
if (!filledRoutes || !demos) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
56
71
|
// omit demo component for postmessage
|
|
57
72
|
var demoData = Object.entries(demos).reduce(function (acc, _ref) {
|
|
58
73
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
@@ -68,13 +83,16 @@ export var useSiteSearch = function useSiteSearch() {
|
|
|
68
83
|
worker.postMessage({
|
|
69
84
|
action: 'generate-metadata',
|
|
70
85
|
args: {
|
|
71
|
-
routes: JSON.parse(JSON.stringify(
|
|
86
|
+
routes: JSON.parse(JSON.stringify(filledRoutes)),
|
|
72
87
|
nav: navData,
|
|
73
88
|
demos: demoData
|
|
74
89
|
}
|
|
75
90
|
});
|
|
76
|
-
}, [
|
|
91
|
+
}, [demos, navData, filledRoutes]);
|
|
77
92
|
useEffect(function () {
|
|
93
|
+
if (!filledRoutes) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
78
96
|
var str = keywords.trim();
|
|
79
97
|
if (str) {
|
|
80
98
|
clearTimeout(debounceTimer.current);
|
|
@@ -89,11 +107,11 @@ export var useSiteSearch = function useSiteSearch() {
|
|
|
89
107
|
} else {
|
|
90
108
|
setResult([]);
|
|
91
109
|
}
|
|
92
|
-
}, [keywords]);
|
|
110
|
+
}, [keywords, filledRoutes]);
|
|
93
111
|
return {
|
|
94
112
|
keywords: keywords,
|
|
95
113
|
setKeywords: setter,
|
|
96
114
|
result: result,
|
|
97
|
-
loading:
|
|
115
|
+
loading: mergedLoading
|
|
98
116
|
};
|
|
99
117
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DemoInfo } from '../context';
|
|
2
|
+
import { useLocaleDocRoutes } from '../utils';
|
|
3
|
+
type Demos = Record<string, DemoInfo>;
|
|
4
|
+
type ReturnData = [
|
|
5
|
+
routes: ReturnType<typeof useLocaleDocRoutes> | null,
|
|
6
|
+
demo: Demos | null
|
|
7
|
+
];
|
|
8
|
+
export default function useSearchData(enabled: boolean): ReturnData;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { loadFilesMeta, useSiteData } from 'dumi';
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { useLocaleDocRoutes } from "../utils";
|
|
16
|
+
export default function useSearchData(enabled) {
|
|
17
|
+
var routes = useLocaleDocRoutes();
|
|
18
|
+
var _React$useState = React.useState(null),
|
|
19
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
20
|
+
filesMeta = _React$useState2[0],
|
|
21
|
+
setFilesMeta = _React$useState2[1];
|
|
22
|
+
var _useSiteData = useSiteData(),
|
|
23
|
+
tabs = _useSiteData.tabs;
|
|
24
|
+
React.useEffect(function () {
|
|
25
|
+
if (enabled) {
|
|
26
|
+
loadFilesMeta().then(function (data) {
|
|
27
|
+
setFilesMeta(data);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}, [enabled]);
|
|
31
|
+
return React.useMemo(function () {
|
|
32
|
+
if (!filesMeta) {
|
|
33
|
+
return [null, null];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Route Meta
|
|
37
|
+
var mergedRoutes = {};
|
|
38
|
+
Object.keys(routes).forEach(function (routeId) {
|
|
39
|
+
mergedRoutes[routeId] = _objectSpread({}, routes[routeId]);
|
|
40
|
+
|
|
41
|
+
// Fill routes meta
|
|
42
|
+
if (mergedRoutes[routeId].meta) {
|
|
43
|
+
var _mergedRoutes$routeId;
|
|
44
|
+
mergedRoutes[routeId].meta = _objectSpread(_objectSpread(_objectSpread({}, mergedRoutes[routeId].meta), filesMeta[routeId]), {}, {
|
|
45
|
+
tabs: (_mergedRoutes$routeId = mergedRoutes[routeId].tabs) === null || _mergedRoutes$routeId === void 0 ? void 0 : _mergedRoutes$routeId.map(function (id) {
|
|
46
|
+
var meta = {
|
|
47
|
+
frontmatter: {
|
|
48
|
+
title: tabs[id].title
|
|
49
|
+
},
|
|
50
|
+
toc: [],
|
|
51
|
+
texts: []
|
|
52
|
+
};
|
|
53
|
+
return _objectSpread(_objectSpread({}, tabs[id]), {}, {
|
|
54
|
+
meta: filesMeta[id] || meta
|
|
55
|
+
});
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Demos
|
|
62
|
+
var demos = Object.entries(filesMeta).reduce(function (acc, _ref) {
|
|
63
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
64
|
+
id = _ref2[0],
|
|
65
|
+
meta = _ref2[1];
|
|
66
|
+
// append route id to demo
|
|
67
|
+
Object.values(meta.demos).forEach(function (demo) {
|
|
68
|
+
demo.routeId = id;
|
|
69
|
+
});
|
|
70
|
+
// merge demos
|
|
71
|
+
Object.assign(acc, meta.demos);
|
|
72
|
+
return acc;
|
|
73
|
+
}, {});
|
|
74
|
+
return [mergedRoutes, demos];
|
|
75
|
+
}, [filesMeta, routes, tabs]);
|
|
76
|
+
}
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -26,12 +26,14 @@ __export(constants_exports, {
|
|
|
26
26
|
PREFERS_COLOR_ATTR: () => PREFERS_COLOR_ATTR,
|
|
27
27
|
PREFERS_COLOR_LS_KEY: () => PREFERS_COLOR_LS_KEY,
|
|
28
28
|
SP_ROUTE_PREFIX: () => SP_ROUTE_PREFIX,
|
|
29
|
+
TEMPLATES_DIR: () => TEMPLATES_DIR,
|
|
29
30
|
THEME_PREFIX: () => THEME_PREFIX,
|
|
30
31
|
USELESS_TMP_FILES: () => USELESS_TMP_FILES,
|
|
31
32
|
VERSION_2_DEPRECATE_SOFT_BREAKS: () => VERSION_2_DEPRECATE_SOFT_BREAKS,
|
|
32
33
|
VERSION_2_LEVEL_NAV: () => VERSION_2_LEVEL_NAV
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(constants_exports);
|
|
36
|
+
var import_path = require("path");
|
|
35
37
|
var LOCAL_DUMI_DIR = ".dumi";
|
|
36
38
|
var LOCAL_THEME_DIR = `${LOCAL_DUMI_DIR}/theme`;
|
|
37
39
|
var LOCAL_PAGES_DIR = `${LOCAL_DUMI_DIR}/pages`;
|
|
@@ -51,6 +53,7 @@ var PICKED_PKG_FIELDS = {
|
|
|
51
53
|
var USELESS_TMP_FILES = ["tsconfig.json", "typings.d.ts"];
|
|
52
54
|
var VERSION_2_LEVEL_NAV = "^2.2.0";
|
|
53
55
|
var VERSION_2_DEPRECATE_SOFT_BREAKS = "^2.2.0";
|
|
56
|
+
var TEMPLATES_DIR = (0, import_path.join)(__dirname, "./templates");
|
|
54
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
55
58
|
0 && (module.exports = {
|
|
56
59
|
LOCAL_DUMI_DIR,
|
|
@@ -60,6 +63,7 @@ var VERSION_2_DEPRECATE_SOFT_BREAKS = "^2.2.0";
|
|
|
60
63
|
PREFERS_COLOR_ATTR,
|
|
61
64
|
PREFERS_COLOR_LS_KEY,
|
|
62
65
|
SP_ROUTE_PREFIX,
|
|
66
|
+
TEMPLATES_DIR,
|
|
63
67
|
THEME_PREFIX,
|
|
64
68
|
USELESS_TMP_FILES,
|
|
65
69
|
VERSION_2_DEPRECATE_SOFT_BREAKS,
|
|
@@ -83,11 +83,23 @@ var compile_default = (api) => {
|
|
|
83
83
|
(0, import_assets.addExampleAssets)(assets);
|
|
84
84
|
},
|
|
85
85
|
onResolveAtomMeta: import_assets.addAtomMeta
|
|
86
|
+
}).end().end().oneOf("md-demo").resourceQuery(/demo$/).use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-demo-loader").loader(loaderPath).options({
|
|
87
|
+
...loaderBaseOpts,
|
|
88
|
+
mode: "demo"
|
|
89
|
+
}).end().end().oneOf("md-demo-index").resourceQuery(/demo-index$/).use("md-demo-index-loader").loader(loaderPath).options({
|
|
90
|
+
...loaderBaseOpts,
|
|
91
|
+
mode: "demo-index"
|
|
92
|
+
}).end().end().oneOf("md-frontmatter").resourceQuery(/frontmatter$/).use("md-frontmatter-loader").loader(loaderPath).options({
|
|
93
|
+
...loaderBaseOpts,
|
|
94
|
+
mode: "frontmatter"
|
|
95
|
+
}).end().end().oneOf("md-text").resourceQuery(/text$/).use("md-text-loader").loader(loaderPath).options({
|
|
96
|
+
...loaderBaseOpts,
|
|
97
|
+
mode: "text"
|
|
86
98
|
}).end().end().oneOf("md").use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-loader").loader(loaderPath).options({
|
|
87
99
|
...loaderBaseOpts,
|
|
88
100
|
builtins: api.service.themeData.builtins
|
|
89
101
|
});
|
|
90
|
-
memo.module.rule("dumi-page").type("javascript/auto").test(/\.(j|t)sx?$/).resourceQuery(/meta$/).use("page-meta-loader").loader(require.resolve("../../loaders/page"));
|
|
102
|
+
memo.module.rule("dumi-page").type("javascript/auto").test(/\.(j|t)sx?$/).resourceQuery(/(meta|frontmatter)$/).use("page-meta-loader").loader(require.resolve("../../loaders/page"));
|
|
91
103
|
memo.module.rule("dumi-demo").type("javascript/auto").test(/\..+$/).enforce("pre").resourceQuery(/techStack/).use("demo-loader").loader(require.resolve("../../loaders/demo")).options({ techStacks, cwd: api.cwd });
|
|
92
104
|
memo.module.rule("dumi-raw").type("javascript/auto").post().resourceQuery(/dumi-raw/).use("raw-loader").loader(require.resolve("raw-loader")).end().use("pre-raw-loader").loader(require.resolve("../../loaders/pre-raw"));
|
|
93
105
|
if (api.env === "development" && memo.plugins.has("fastRefresh")) {
|
package/dist/features/exports.js
CHANGED
|
@@ -44,7 +44,9 @@ var exports_default = (api) => {
|
|
|
44
44
|
noPluginDir: true,
|
|
45
45
|
path: "dumi/exports.ts",
|
|
46
46
|
content: `export * from '../exports';
|
|
47
|
-
export * from '${(0, import_plugin_utils.winPath)(require.resolve("../client/theme-api"))}'
|
|
47
|
+
export * from '${(0, import_plugin_utils.winPath)(require.resolve("../client/theme-api"))}';
|
|
48
|
+
export { getRouteMetaById } from './meta/route-meta';
|
|
49
|
+
export { loadFilesMeta } from './meta/search';`
|
|
48
50
|
});
|
|
49
51
|
});
|
|
50
52
|
};
|