dumi 2.3.0-alpha.9 → 2.3.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assetParsers/block.d.ts +7 -1
- package/dist/assetParsers/block.js +14 -6
- package/dist/client/pages/Demo/index.js +19 -5
- package/dist/client/pages/Loading.d.ts +1 -0
- package/dist/client/pages/Loading.js +2 -0
- package/dist/client/theme-api/DumiDemo/index.js +4 -4
- package/dist/client/theme-api/{context/index.d.ts → context.d.ts} +4 -12
- package/dist/client/theme-api/context.js +16 -0
- package/dist/client/theme-api/index.d.ts +2 -3
- package/dist/client/theme-api/index.js +2 -3
- package/dist/client/theme-api/types.d.ts +6 -4
- package/dist/client/theme-api/useLiveDemo.d.ts +6 -0
- package/dist/client/theme-api/useLiveDemo.js +70 -0
- package/dist/client/theme-api/useRouteMeta.js +73 -20
- package/dist/client/theme-api/useSiteSearch/index.d.ts +1 -1
- package/dist/client/theme-api/useSiteSearch/index.js +20 -48
- package/dist/client/theme-api/useSiteSearch/useSearchData.d.ts +9 -6
- package/dist/client/theme-api/useSiteSearch/useSearchData.js +55 -60
- package/dist/client/theme-api/useTabMeta.js +1 -1
- package/dist/client/theme-api/utils.d.ts +10 -0
- package/dist/client/theme-api/utils.js +25 -0
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -4
- package/dist/features/compile/index.js +11 -18
- package/dist/features/exports.js +3 -3
- package/dist/features/meta.js +12 -31
- package/dist/features/theme/index.js +8 -5
- package/dist/loaders/markdown/index.d.ts +1 -7
- package/dist/loaders/markdown/index.js +39 -113
- package/dist/loaders/markdown/transformer/index.d.ts +1 -1
- package/dist/loaders/markdown/transformer/rehypeDemo.js +8 -2
- package/dist/loaders/page/index.js +1 -3
- package/dist/preset.js +1 -2
- package/dist/templates/ContextWrapper.ts.tpl +2 -10
- package/dist/templates/meta/exports.ts.tpl +160 -0
- package/dist/templates/meta/index.ts.tpl +26 -0
- package/dist/templates/{meta-runtime.ts.tpl → meta/runtime.ts.tpl} +11 -22
- package/dist/types.d.ts +2 -2
- package/index.d.ts +1 -4
- package/package.json +2 -1
- package/theme-default/builtins/Previewer/index.d.ts +1 -1
- package/theme-default/builtins/Previewer/index.js +35 -33
- package/theme-default/builtins/Previewer/index.less +34 -0
- package/theme-default/builtins/SourceCode/index.d.ts +2 -1
- package/theme-default/builtins/SourceCode/index.js +3 -3
- package/theme-default/builtins/SourceCode/index.less +1 -0
- package/theme-default/locales/en-US.json +2 -0
- package/theme-default/locales/zh-CN.json +2 -0
- package/theme-default/slots/Loading/index.d.ts +5 -0
- package/theme-default/slots/Loading/index.js +18 -0
- package/theme-default/slots/Loading/index.less +20 -0
- package/theme-default/slots/PreviewerActions/index.d.ts +7 -1
- package/theme-default/slots/PreviewerActions/index.js +49 -6
- package/theme-default/slots/PreviewerActions/index.less +58 -14
- package/theme-default/slots/SearchBar/Mask.js +1 -1
- package/theme-default/slots/SearchBar/index.js +1 -1
- package/theme-default/slots/SearchResult/index.js +1 -10
- package/theme-default/slots/SourceCodeEditor/index.d.ts +18 -0
- package/theme-default/slots/SourceCodeEditor/index.js +106 -0
- package/theme-default/slots/SourceCodeEditor/index.less +45 -0
- package/dist/client/theme-api/context/index.js +0 -50
- package/dist/client/theme-api/context/use.d.ts +0 -10
- package/dist/client/theme-api/context/use.js +0 -25
- package/dist/client/theme-api/evalCode.d.ts +0 -2
- package/dist/client/theme-api/evalCode.js +0 -17
- package/dist/client/theme-api/live/LiveProvider.d.ts +0 -16
- package/dist/client/theme-api/live/LiveProvider.js +0 -74
- package/dist/client/theme-api/live/index.d.ts +0 -3
- package/dist/client/theme-api/live/index.js +0 -3
- package/dist/client/theme-api/live/useDemoScopes.d.ts +0 -2
- package/dist/client/theme-api/live/useDemoScopes.js +0 -15
- package/dist/features/live.d.ts +0 -3
- package/dist/features/live.js +0 -74
- package/dist/templates/live/demo-scopes.ts.tpl +0 -22
- package/dist/templates/live/disabled.ts.tpl +0 -1
- package/dist/templates/meta-demos.ts.tpl +0 -34
- package/dist/templates/meta-frontmatter.ts.tpl +0 -9
- package/dist/templates/meta-route.ts.tpl +0 -43
- package/dist/templates/meta-search.ts.tpl +0 -41
- package/theme-default/slots/LiveDemo/index.d.ts +0 -3
- package/theme-default/slots/LiveDemo/index.js +0 -8
- package/theme-default/slots/LiveEditor/index.d.ts +0 -4
- package/theme-default/slots/LiveEditor/index.js +0 -20
- package/theme-default/slots/LiveError/index.d.ts +0 -4
- package/theme-default/slots/LiveError/index.js +0 -15
- package/theme-default/slots/LiveError/index.less +0 -22
|
@@ -1,77 +1,72 @@
|
|
|
1
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
|
+
var _excluded = ["component", "context"];
|
|
3
|
+
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; }
|
|
4
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
5
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
2
6
|
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
7
|
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
8
|
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
9
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
10
|
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); }
|
|
11
|
+
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); } }
|
|
12
|
+
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); }); }; }
|
|
7
13
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
14
|
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
15
|
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
16
|
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
17
|
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
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
19
|
+
import { getFullDemos, getFullRoutesMeta } from 'dumi';
|
|
20
|
+
import { useCallback, useRef, useState } from 'react';
|
|
15
21
|
import { useLocaleDocRoutes } from "../utils";
|
|
16
|
-
export default function useSearchData(
|
|
22
|
+
export default function useSearchData() {
|
|
17
23
|
var routes = useLocaleDocRoutes();
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
24
|
+
var _useState = useState(null),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
data = _useState2[0],
|
|
27
|
+
setData = _useState2[1];
|
|
28
|
+
var loading = useRef(false);
|
|
29
|
+
var load = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
30
|
+
var routesMeta, _demos, mergedRoutes;
|
|
31
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
32
|
+
while (1) switch (_context.prev = _context.next) {
|
|
33
|
+
case 0:
|
|
34
|
+
if (!(!loading.current && !data)) {
|
|
35
|
+
_context.next = 12;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
_context.next = 3;
|
|
39
|
+
return getFullRoutesMeta();
|
|
40
|
+
case 3:
|
|
41
|
+
routesMeta = _context.sent;
|
|
42
|
+
_context.next = 6;
|
|
43
|
+
return getFullDemos();
|
|
44
|
+
case 6:
|
|
45
|
+
_demos = _context.sent;
|
|
46
|
+
mergedRoutes = {}; // generate new routes with meta data
|
|
47
|
+
Object.keys(routes).forEach(function (routeId) {
|
|
48
|
+
mergedRoutes[routeId] = _objectSpread(_objectSpread({}, routes[routeId]), {}, {
|
|
49
|
+
meta: routesMeta[routeId]
|
|
55
50
|
});
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
51
|
+
});
|
|
60
52
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
53
|
+
// omit demo component for postmessage
|
|
54
|
+
Object.entries(_demos).forEach(function (_ref2) {
|
|
55
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
56
|
+
id = _ref3[0],
|
|
57
|
+
_ref3$ = _ref3[1],
|
|
58
|
+
component = _ref3$.component,
|
|
59
|
+
context = _ref3$.context,
|
|
60
|
+
demo = _objectWithoutProperties(_ref3$, _excluded);
|
|
61
|
+
_demos[id] = demo;
|
|
62
|
+
});
|
|
63
|
+
setData([mergedRoutes, _demos]);
|
|
64
|
+
loading.current = false;
|
|
65
|
+
case 12:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}, _callee);
|
|
70
|
+
})), [data]);
|
|
71
|
+
return [data, load];
|
|
77
72
|
}
|
|
@@ -19,7 +19,7 @@ export var useTabQueryState = function useTabQueryState() {
|
|
|
19
19
|
pathname: pathname,
|
|
20
20
|
search: "?".concat(params.toString())
|
|
21
21
|
});
|
|
22
|
-
}, [params]);
|
|
22
|
+
}, [params, pathname]);
|
|
23
23
|
return [params.get(TAB_QUERY_KEY), setTabQueryState];
|
|
24
24
|
};
|
|
25
25
|
export var useTabMeta = function useTabMeta() {
|
|
@@ -28,3 +28,13 @@ export declare const useRouteDataComparer: <T extends {
|
|
|
28
28
|
*/
|
|
29
29
|
export declare const pickRouteSortMeta: (original: Partial<Pick<INavItem, 'order' | 'title'>>, field: 'nav' | 'nav.second' | 'group', fm: IRouteMeta['frontmatter']) => Partial<Pick<INavItem, "title" | "order">>;
|
|
30
30
|
export declare function getLocaleNav(nav: IUserNavValue | INav, locale: ILocale): import("./types").IUserNavItems;
|
|
31
|
+
type ReactPromise<T> = Promise<T> & {
|
|
32
|
+
status?: 'pending' | 'fulfilled' | 'rejected';
|
|
33
|
+
value?: T;
|
|
34
|
+
reason?: any;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* @private Internal usage. Safe to remove
|
|
38
|
+
*/
|
|
39
|
+
export declare function use<T>(promise: ReactPromise<T>): T;
|
|
40
|
+
export {};
|
|
@@ -96,4 +96,29 @@ export var pickRouteSortMeta = function pickRouteSortMeta(original, field, fm) {
|
|
|
96
96
|
};
|
|
97
97
|
export function getLocaleNav(nav, locale) {
|
|
98
98
|
return Array.isArray(nav) ? nav : nav[locale.id];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Copy from React official demo.
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @private Internal usage. Safe to remove
|
|
105
|
+
*/
|
|
106
|
+
export function use(promise) {
|
|
107
|
+
if (promise.status === 'fulfilled') {
|
|
108
|
+
return promise.value;
|
|
109
|
+
} else if (promise.status === 'rejected') {
|
|
110
|
+
throw promise.reason;
|
|
111
|
+
} else if (promise.status === 'pending') {
|
|
112
|
+
throw promise;
|
|
113
|
+
} else {
|
|
114
|
+
promise.status = 'pending';
|
|
115
|
+
promise.then(function (result) {
|
|
116
|
+
promise.status = 'fulfilled';
|
|
117
|
+
promise.value = result;
|
|
118
|
+
}, function (reason) {
|
|
119
|
+
promise.status = 'rejected';
|
|
120
|
+
promise.reason = reason;
|
|
121
|
+
});
|
|
122
|
+
throw promise;
|
|
123
|
+
}
|
|
99
124
|
}
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -26,14 +26,12 @@ __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,
|
|
30
29
|
THEME_PREFIX: () => THEME_PREFIX,
|
|
31
30
|
USELESS_TMP_FILES: () => USELESS_TMP_FILES,
|
|
32
31
|
VERSION_2_DEPRECATE_SOFT_BREAKS: () => VERSION_2_DEPRECATE_SOFT_BREAKS,
|
|
33
32
|
VERSION_2_LEVEL_NAV: () => VERSION_2_LEVEL_NAV
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(constants_exports);
|
|
36
|
-
var import_path = require("path");
|
|
37
35
|
var LOCAL_DUMI_DIR = ".dumi";
|
|
38
36
|
var LOCAL_THEME_DIR = `${LOCAL_DUMI_DIR}/theme`;
|
|
39
37
|
var LOCAL_PAGES_DIR = `${LOCAL_DUMI_DIR}/pages`;
|
|
@@ -53,7 +51,6 @@ var PICKED_PKG_FIELDS = {
|
|
|
53
51
|
var USELESS_TMP_FILES = ["tsconfig.json", "typings.d.ts"];
|
|
54
52
|
var VERSION_2_LEVEL_NAV = "^2.2.0";
|
|
55
53
|
var VERSION_2_DEPRECATE_SOFT_BREAKS = "^2.2.0";
|
|
56
|
-
var TEMPLATES_DIR = (0, import_path.join)(__dirname, "./templates");
|
|
57
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
55
|
0 && (module.exports = {
|
|
59
56
|
LOCAL_DUMI_DIR,
|
|
@@ -63,7 +60,6 @@ var TEMPLATES_DIR = (0, import_path.join)(__dirname, "./templates");
|
|
|
63
60
|
PREFERS_COLOR_ATTR,
|
|
64
61
|
PREFERS_COLOR_LS_KEY,
|
|
65
62
|
SP_ROUTE_PREFIX,
|
|
66
|
-
TEMPLATES_DIR,
|
|
67
63
|
THEME_PREFIX,
|
|
68
64
|
USELESS_TMP_FILES,
|
|
69
65
|
VERSION_2_DEPRECATE_SOFT_BREAKS,
|
|
@@ -68,25 +68,18 @@ var compile_default = (api) => {
|
|
|
68
68
|
locales: api.config.locales,
|
|
69
69
|
pkg: api.pkg
|
|
70
70
|
};
|
|
71
|
-
memo.module.rule("dumi-md").type("javascript/auto").test(/\.md$/)
|
|
71
|
+
const mdRule = memo.module.rule("dumi-md").type("javascript/auto").test(/\.md$/);
|
|
72
|
+
["frontmatter", "text", "demo-index"].forEach((type) => {
|
|
73
|
+
mdRule.oneOf(`md-${type}`).resourceQuery(new RegExp(`${type}$`)).use(`md-${type}-loader`).loader(loaderPath).options({
|
|
74
|
+
...loaderBaseOpts,
|
|
75
|
+
mode: type
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
mdRule.oneOf("md-demo").resourceQuery(/demo$/).use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-demo-loader").loader(loaderPath).options({
|
|
72
79
|
...loaderBaseOpts,
|
|
73
80
|
mode: "demo"
|
|
74
|
-
}).end().end()
|
|
75
|
-
|
|
76
|
-
mode: "demo-index"
|
|
77
|
-
}).end().end().oneOf("md-frontmatter").resourceQuery(/frontmatter$/).use("md-frontmatter-loader").loader(loaderPath).options({
|
|
78
|
-
...loaderBaseOpts,
|
|
79
|
-
mode: "frontmatter"
|
|
80
|
-
}).end().end().oneOf("md-text").resourceQuery(/text$/).use("md-text-loader").loader(loaderPath).options({
|
|
81
|
-
...loaderBaseOpts,
|
|
82
|
-
mode: "text"
|
|
83
|
-
}).end().end().oneOf("md-scope").resourceQuery(/scope$/).use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-scope-loader").loader(loaderPath).options({
|
|
84
|
-
...loaderBaseOpts,
|
|
85
|
-
mode: "scope"
|
|
86
|
-
}).end().end().oneOf("md-scope-index").resourceQuery(/scope-index$/).use("md-scope-index-loader").loader(loaderPath).options({
|
|
87
|
-
...loaderBaseOpts,
|
|
88
|
-
mode: "scope-index"
|
|
89
|
-
}).end().end().oneOf("md").use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-loader").loader(loaderPath).options({
|
|
81
|
+
}).end().end();
|
|
82
|
+
mdRule.oneOf("md").use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-loader").loader(loaderPath).options({
|
|
90
83
|
...loaderBaseOpts,
|
|
91
84
|
builtins: api.service.themeData.builtins,
|
|
92
85
|
onResolveDemos(demos) {
|
|
@@ -102,7 +95,7 @@ var compile_default = (api) => {
|
|
|
102
95
|
},
|
|
103
96
|
onResolveAtomMeta: import_assets.addAtomMeta
|
|
104
97
|
});
|
|
105
|
-
memo.module.rule("dumi-page").type("javascript/auto").test(/\.(j|t)sx?$/).resourceQuery(/
|
|
98
|
+
memo.module.rule("dumi-page").type("javascript/auto").test(/\.(j|t)sx?$/).resourceQuery(/frontmatter$/).use("page-meta-loader").loader(require.resolve("../../loaders/page"));
|
|
106
99
|
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 });
|
|
107
100
|
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"));
|
|
108
101
|
if (api.env === "development" && memo.plugins.has("fastRefresh")) {
|
package/dist/features/exports.js
CHANGED
|
@@ -32,11 +32,13 @@ __export(exports_exports, {
|
|
|
32
32
|
default: () => exports_default
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(exports_exports);
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
35
36
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
36
37
|
var exports_default = (api) => {
|
|
37
38
|
api.describe({ key: "dumi:exports" });
|
|
38
39
|
api.modifyConfig((memo) => {
|
|
39
40
|
memo.alias["dumi$"] = "@@/dumi/exports";
|
|
41
|
+
memo.alias["dumi/dist"] = (0, import_plugin_utils.winPath)(import_path.default.join(__dirname, ".."));
|
|
40
42
|
return memo;
|
|
41
43
|
});
|
|
42
44
|
api.onGenerateFiles(() => {
|
|
@@ -45,9 +47,7 @@ var exports_default = (api) => {
|
|
|
45
47
|
path: "dumi/exports.ts",
|
|
46
48
|
content: `export * from '../exports';
|
|
47
49
|
export * from '${(0, import_plugin_utils.winPath)(require.resolve("../client/theme-api"))}';
|
|
48
|
-
export
|
|
49
|
-
export { loadFilesMeta } from './meta/search';
|
|
50
|
-
export { getDemoScopesById } from './live/demo-scopes';`
|
|
50
|
+
export * from './meta/exports';`
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
};
|
package/dist/features/meta.js
CHANGED
|
@@ -34,7 +34,6 @@ __export(meta_exports, {
|
|
|
34
34
|
default: () => meta_default
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(meta_exports);
|
|
37
|
-
var import_constants = require("../constants");
|
|
38
37
|
var import_utils = require("../utils");
|
|
39
38
|
var import_path = __toESM(require("path"));
|
|
40
39
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
@@ -72,39 +71,15 @@ var meta_default = (api) => {
|
|
|
72
71
|
key: "dumi.modifyMetaFiles",
|
|
73
72
|
initialValue: JSON.parse(JSON.stringify(metaFiles))
|
|
74
73
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
path: "dumi/meta/search.ts",
|
|
78
|
-
tplPath: (0, import_plugin_utils.winPath)((0, import_path.join)(import_constants.TEMPLATES_DIR, "meta-search.ts.tpl")),
|
|
79
|
-
context: {
|
|
80
|
-
metaFiles: parsedMetaFiles
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
api.writeTmpFile({
|
|
84
|
-
noPluginDir: true,
|
|
85
|
-
path: "dumi/meta/frontmatter.ts",
|
|
86
|
-
tplPath: (0, import_plugin_utils.winPath)((0, import_path.join)(import_constants.TEMPLATES_DIR, "meta-frontmatter.ts.tpl")),
|
|
87
|
-
context: {
|
|
88
|
-
metaFiles: parsedMetaFiles
|
|
89
|
-
}
|
|
74
|
+
parsedMetaFiles.forEach((metaFile) => {
|
|
75
|
+
metaFile.isMarkdown = metaFile.file.endsWith(".md");
|
|
90
76
|
});
|
|
91
|
-
const mdFiles = parsedMetaFiles.filter(
|
|
92
|
-
(metaFile) => metaFile.file.endsWith(".md")
|
|
93
|
-
);
|
|
94
77
|
api.writeTmpFile({
|
|
95
78
|
noPluginDir: true,
|
|
96
|
-
path: "dumi/meta/
|
|
97
|
-
tplPath:
|
|
79
|
+
path: "dumi/meta/index.ts",
|
|
80
|
+
tplPath: require.resolve("../templates/meta/index.ts.tpl"),
|
|
98
81
|
context: {
|
|
99
|
-
metaFiles:
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
api.writeTmpFile({
|
|
103
|
-
noPluginDir: true,
|
|
104
|
-
path: "dumi/meta/route-meta.ts",
|
|
105
|
-
tplPath: (0, import_plugin_utils.winPath)((0, import_path.join)(import_constants.TEMPLATES_DIR, "meta-route.ts.tpl")),
|
|
106
|
-
context: {
|
|
107
|
-
metaFiles: mdFiles,
|
|
82
|
+
metaFiles: parsedMetaFiles,
|
|
108
83
|
chunkName: function chunkName() {
|
|
109
84
|
var _a;
|
|
110
85
|
if (!("file" in this)) {
|
|
@@ -121,11 +96,17 @@ var meta_default = (api) => {
|
|
|
121
96
|
api.writeTmpFile({
|
|
122
97
|
noPluginDir: true,
|
|
123
98
|
path: "dumi/meta/runtime.ts",
|
|
124
|
-
tplPath:
|
|
99
|
+
tplPath: require.resolve("../templates/meta/runtime.ts.tpl"),
|
|
125
100
|
context: {
|
|
126
101
|
deepmerge: (0, import_plugin_utils.winPath)(import_path.default.dirname(require.resolve("deepmerge/package")))
|
|
127
102
|
}
|
|
128
103
|
});
|
|
104
|
+
api.writeTmpFile({
|
|
105
|
+
noPluginDir: true,
|
|
106
|
+
path: "dumi/meta/exports.ts",
|
|
107
|
+
tplPath: require.resolve("../templates/meta/exports.ts.tpl"),
|
|
108
|
+
context: {}
|
|
109
|
+
});
|
|
129
110
|
});
|
|
130
111
|
api.addRuntimePlugin(() => "@@/dumi/meta/runtime.ts");
|
|
131
112
|
};
|
|
@@ -42,6 +42,9 @@ var import_plugin_utils = require("umi/plugin-utils");
|
|
|
42
42
|
var import_derivative = require("../derivative");
|
|
43
43
|
var import_loader = __toESM(require("./loader"));
|
|
44
44
|
var DEFAULT_THEME_PATH = import_path.default.join(__dirname, "../../../theme-default");
|
|
45
|
+
var DEFAULT_LOADING_PATH = (0, import_plugin_utils.winPath)(
|
|
46
|
+
import_path.default.resolve(__dirname, "../../client/pages/Loading")
|
|
47
|
+
);
|
|
45
48
|
function getPkgThemeName(api) {
|
|
46
49
|
if (process.env.DUMI_THEME) {
|
|
47
50
|
const envThemePkgPath = require.resolve(
|
|
@@ -216,7 +219,7 @@ var theme_default = (api) => {
|
|
|
216
219
|
// execute before umi tmpFiles plugin
|
|
217
220
|
stage: -Infinity,
|
|
218
221
|
fn() {
|
|
219
|
-
const { globalLoading } = api.appData;
|
|
222
|
+
const { globalLoading = DEFAULT_LOADING_PATH } = api.appData;
|
|
220
223
|
const enableNProgress = !!api.config.themeConfig.nprogress;
|
|
221
224
|
api.appData.globalLoading = "@@/dumi/theme/loading";
|
|
222
225
|
api.writeTmpFile({
|
|
@@ -225,8 +228,8 @@ var theme_default = (api) => {
|
|
|
225
228
|
content: `${enableNProgress ? `import nprogress from '${(0, import_plugin_utils.winPath)(
|
|
226
229
|
import_path.default.dirname(require.resolve("nprogress/package"))
|
|
227
230
|
)}';
|
|
228
|
-
import './nprogress.css';` : ""}
|
|
229
|
-
import UserLoading from '${globalLoading}'
|
|
231
|
+
import './nprogress.css';` : ""}
|
|
232
|
+
import UserLoading from '${globalLoading}';
|
|
230
233
|
import React, { useLayoutEffect, type FC } from 'react';
|
|
231
234
|
import { useSiteData } from 'dumi';
|
|
232
235
|
|
|
@@ -243,7 +246,7 @@ const DumiLoading: FC = () => {
|
|
|
243
246
|
}
|
|
244
247
|
}, []);
|
|
245
248
|
|
|
246
|
-
return
|
|
249
|
+
return <UserLoading />
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
export default DumiLoading;
|
|
@@ -279,7 +282,7 @@ export default DumiLoading;
|
|
|
279
282
|
api.writeTmpFile({
|
|
280
283
|
noPluginDir: true,
|
|
281
284
|
path: "dumi/theme/ContextWrapper.tsx",
|
|
282
|
-
tplPath:
|
|
285
|
+
tplPath: require.resolve("../../templates/ContextWrapper.ts.tpl"),
|
|
283
286
|
context: {
|
|
284
287
|
contextPath: (0, import_plugin_utils.winPath)(require.resolve("../../client/theme-api/context")),
|
|
285
288
|
defaultExport: hasDefaultExport ? `import entryDefaultExport from '${(0, import_plugin_utils.winPath)(entryFile)}';` : "",
|
|
@@ -21,12 +21,6 @@ interface IMdLoaderFrontmatterModeOptions extends Omit<IMdLoaderDefaultModeOptio
|
|
|
21
21
|
interface IMdLoaderTextModeOptions extends Omit<IMdLoaderDefaultModeOptions, 'builtins' | 'mode'> {
|
|
22
22
|
mode: 'text';
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
mode: 'scope';
|
|
26
|
-
}
|
|
27
|
-
interface IMdLoaderScopeIndexModeOptions extends Omit<IMdLoaderDefaultModeOptions, 'builtins' | 'mode'> {
|
|
28
|
-
mode: 'scope-index';
|
|
29
|
-
}
|
|
30
|
-
export type IMdLoaderOptions = IMdLoaderDefaultModeOptions | IMdLoaderDemosModeOptions | IMdLoaderDemoModeOptions | IMdLoaderFrontmatterModeOptions | IMdLoaderTextModeOptions | IMdLoaderDemoIndexModeOptions | IMdLoaderScopeModeOptions | IMdLoaderScopeIndexModeOptions;
|
|
24
|
+
export type IMdLoaderOptions = IMdLoaderDefaultModeOptions | IMdLoaderDemosModeOptions | IMdLoaderDemoModeOptions | IMdLoaderFrontmatterModeOptions | IMdLoaderTextModeOptions | IMdLoaderDemoIndexModeOptions;
|
|
31
25
|
export default function mdLoader(this: any, content: string): void;
|
|
32
26
|
export {};
|