@antv/dumi-theme-antv 0.3.0-beta.2 → 0.3.0-beta.21

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.
Files changed (89) hide show
  1. package/dist/builtins/Playground/index.d.ts +3 -6
  2. package/dist/builtins/Playground/index.js +27 -7
  3. package/dist/context.d.ts +2 -1
  4. package/dist/layouts/DocLayout.js +25 -16
  5. package/dist/layouts/entry/Index.js +21 -12
  6. package/dist/layouts/entry/Manual.js +6 -4
  7. package/dist/pages/404.js +7 -4
  8. package/dist/pages/Example/index.js +31 -55
  9. package/dist/pages/Example/index.module.less +50 -8
  10. package/dist/pages/Example/utils.d.ts +1 -0
  11. package/dist/pages/Example/utils.js +9 -0
  12. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +6 -1
  13. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +11 -6
  14. package/dist/pages/Examples/index.js +24 -4
  15. package/dist/pages/Examples/index.module.less +15 -0
  16. package/dist/pages/Examples/types.d.ts +7 -6
  17. package/dist/plugin/examples.d.ts +14 -5
  18. package/dist/plugin/examples.js +17 -3
  19. package/dist/plugin/index.js +31 -8
  20. package/dist/plugin/utils.js +3 -2
  21. package/dist/slots/Article/index.d.ts +3 -0
  22. package/dist/slots/Article/index.js +11 -0
  23. package/dist/slots/Article/index.module.less +8 -0
  24. package/dist/slots/Banner/Notification.d.ts +10 -0
  25. package/dist/slots/Banner/Notification.js +43 -0
  26. package/dist/slots/Banner/Notification.module.less +120 -0
  27. package/dist/slots/Banner/index.d.ts +26 -0
  28. package/dist/slots/Banner/index.js +184 -0
  29. package/dist/slots/Banner/index.module.less +449 -0
  30. package/dist/slots/Cases/index.d.ts +1 -0
  31. package/dist/slots/Cases/index.js +13 -7
  32. package/dist/slots/Cases/index.module.less +2 -1
  33. package/dist/slots/CodeEditor/Toolbar.js +17 -22
  34. package/dist/slots/CodeEditor/index.d.ts +4 -0
  35. package/dist/slots/CodeEditor/index.js +71 -23
  36. package/dist/slots/CodeEditor/utils.js +2 -2
  37. package/dist/slots/CodePreview/CodeHeader.js +15 -14
  38. package/dist/slots/CodePreview/index.d.ts +8 -0
  39. package/dist/slots/CodePreview/index.js +15 -6
  40. package/dist/slots/CodePreview/index.module.less +17 -7
  41. package/dist/slots/CodeRunner/index.d.ts +5 -2
  42. package/dist/slots/CodeRunner/index.js +19 -8
  43. package/dist/slots/CodeRunner/utils.d.ts +3 -2
  44. package/dist/slots/CodeRunner/utils.js +1 -1
  45. package/dist/slots/Companies/index.d.ts +1 -1
  46. package/dist/slots/{TOC.d.ts → ContentTable/index.d.ts} +2 -1
  47. package/dist/slots/{TOC.js → ContentTable/index.js} +2 -1
  48. package/dist/slots/ContentTable/index.module.less +11 -0
  49. package/dist/slots/Detail/News.d.ts +1 -0
  50. package/dist/slots/Detail/News.js +3 -2
  51. package/dist/slots/Detail/index.d.ts +1 -0
  52. package/dist/slots/Detail/index.js +4 -2
  53. package/dist/slots/ExampleSider/index.d.ts +4 -38
  54. package/dist/slots/ExampleSider/index.js +28 -49
  55. package/dist/slots/ExampleSider/index.module.less +1 -1
  56. package/dist/slots/Features/FeatureCard.d.ts +1 -0
  57. package/dist/slots/Features/index.js +7 -3
  58. package/dist/slots/Features/index.module.less +1 -1
  59. package/dist/slots/Footer/index.js +34 -14
  60. package/dist/slots/Header/LogoWhite.js +1 -2
  61. package/dist/slots/Header/Navs.d.ts +10 -1
  62. package/dist/slots/Header/Navs.js +36 -19
  63. package/dist/slots/Header/Products/NavigatorBanner.js +4 -3
  64. package/dist/slots/Header/Products/Product.js +7 -3
  65. package/dist/slots/Header/Products/index.js +5 -3
  66. package/dist/slots/Header/Search.js +5 -3
  67. package/dist/slots/Header/index.d.ts +7 -2
  68. package/dist/slots/Header/index.js +135 -30
  69. package/dist/slots/Loading/index.d.ts +6 -1
  70. package/dist/slots/Loading/index.js +24 -10
  71. package/dist/slots/Loading/index.module.less +276 -9
  72. package/dist/slots/ManualContent/NavigatorBanner.js +5 -3
  73. package/dist/slots/ManualContent/ReadingTime.js +6 -2
  74. package/dist/slots/ManualContent/index.js +143 -126
  75. package/dist/slots/ManualContent/index.module.less +52 -33
  76. package/dist/slots/ManualContent/utils.d.ts +18 -0
  77. package/dist/slots/ManualContent/utils.js +64 -0
  78. package/dist/slots/SEO.d.ts +10 -0
  79. package/dist/slots/SEO.js +59 -0
  80. package/dist/slots/_.less +1 -1
  81. package/dist/slots/hooks.d.ts +4 -4
  82. package/dist/slots/hooks.js +5 -8
  83. package/dist/slots/utils.d.ts +4 -19
  84. package/dist/slots/utils.js +82 -119
  85. package/dist/types.d.ts +83 -0
  86. package/dist/typings.d.ts +0 -116
  87. package/package.json +9 -5
  88. package/dist/slots/Loading.d.ts +0 -5
  89. package/dist/slots/Loading.js +0 -8
@@ -0,0 +1,59 @@
1
+ import { useSiteData } from 'dumi';
2
+ import React from 'react';
3
+ import { Helmet } from 'react-helmet';
4
+ export var SEO = function SEO(_ref) {
5
+ var description = _ref.description,
6
+ _ref$lang = _ref.lang,
7
+ lang = _ref$lang === void 0 ? '' : _ref$lang,
8
+ _ref$meta = _ref.meta,
9
+ meta = _ref$meta === void 0 ? [] : _ref$meta,
10
+ title = _ref.title,
11
+ titleSuffix = _ref.titleSuffix;
12
+
13
+ var _useSiteData = useSiteData(),
14
+ themeConfig = _useSiteData.themeConfig;
15
+
16
+ var defaultTitle = themeConfig.title,
17
+ defaultDescription = themeConfig.defaultDescription;
18
+ var metaDescription = description || defaultDescription;
19
+ return /*#__PURE__*/React.createElement(Helmet, {
20
+ htmlAttributes: {
21
+ lang: lang
22
+ },
23
+ title: title,
24
+ titleTemplate: "%s | ".concat(titleSuffix || defaultTitle),
25
+ meta: [{
26
+ name: "description",
27
+ content: metaDescription
28
+ }, {
29
+ property: "og:title",
30
+ content: title
31
+ }, {
32
+ property: "og:description",
33
+ content: metaDescription
34
+ }, {
35
+ property: "og:image",
36
+ content: 'https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png'
37
+ }, {
38
+ property: "og:type",
39
+ content: "website"
40
+ }, {
41
+ name: "twitter:card",
42
+ content: "summary"
43
+ }, {
44
+ name: "twitter:title",
45
+ content: title
46
+ }, {
47
+ name: "twitter:description",
48
+ content: metaDescription
49
+ }, {
50
+ property: "twitter:image",
51
+ content: 'https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png'
52
+ }].concat(meta)
53
+ });
54
+ };
55
+ SEO.defaultProps = {
56
+ lang: "zh",
57
+ meta: [],
58
+ description: ""
59
+ };
package/dist/slots/_.less CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  @media only screen and (max-width: 931.99px) {
12
12
  & {
13
- max-width: calc(100% - 60px);
13
+ max-width: calc(100% - 80px);
14
14
  }
15
15
  }
16
16
 
@@ -1,11 +1,10 @@
1
1
  import { NavigatorBannerProps } from './ManualContent/NavigatorBanner';
2
2
  export declare const useChinaMirrorHost: () => [boolean];
3
3
  export declare const useScrollToTop: () => void;
4
- export declare const useT: (transformedMessage: string) => string;
5
4
  export declare const useLogoLink: ({ link, siteUrl, lang, }: {
6
- link?: string | undefined;
7
- siteUrl?: string | undefined;
8
- lang?: string | undefined;
5
+ link?: string;
6
+ siteUrl?: string;
7
+ lang?: string;
9
8
  }) => [string];
10
9
  export declare const usePrevAndNext: () => NavigatorBannerProps['post'][];
11
10
  /**
@@ -14,3 +13,4 @@ export declare const usePrevAndNext: () => NavigatorBannerProps['post'][];
14
13
  * @param v
15
14
  */
16
15
  export declare function ic(v: string | object): any;
16
+ export declare function icWithLocale(v: string | object, locale: any): any;
@@ -14,7 +14,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
14
 
15
15
  import { useEffect, useState } from 'react';
16
16
  import { get } from 'lodash-es';
17
- import { useIntl, useLocale } from 'dumi';
17
+ import { useLocale } from 'dumi';
18
18
  export var useChinaMirrorHost = function useChinaMirrorHost() {
19
19
  var _useState = useState(false),
20
20
  _useState2 = _slicedToArray(_useState, 2),
@@ -31,12 +31,6 @@ export var useChinaMirrorHost = function useChinaMirrorHost() {
31
31
  export var useScrollToTop = function useScrollToTop() {
32
32
  document.body.scrollTop = document.documentElement.scrollTop = 0;
33
33
  };
34
- export var useT = function useT(transformedMessage) {
35
- var intl = useIntl();
36
- return intl.formatMessage({
37
- id: transformedMessage
38
- });
39
- };
40
34
  export var useLogoLink = function useLogoLink(_ref) {
41
35
  var _ref$link = _ref.link,
42
36
  link = _ref$link === void 0 ? '' : _ref$link,
@@ -100,5 +94,8 @@ export var usePrevAndNext = function usePrevAndNext() {
100
94
 
101
95
  export function ic(v) {
102
96
  var locale = useLocale();
103
- return _typeof(v) === 'object' ? get(v, [locale.id]) : v;
97
+ return icWithLocale(v, locale.id);
98
+ }
99
+ export function icWithLocale(v, locale) {
100
+ return _typeof(v) === 'object' ? get(v, [locale]) : v;
104
101
  }
@@ -1,20 +1,5 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- /// <reference types="node" />
5
- /// <reference types="lodash" />
6
- declare type Status = 'responded' | 'error' | 'timeout';
7
- export declare const ping: (callback: (status: Status) => void) => NodeJS.Timeout;
1
+ import { Status, TreeNode } from '../types';
2
+ export declare function ping(): Promise<Status>;
8
3
  export declare const getChinaMirrorHost: (host?: string) => string;
9
- export declare function getGithubSourceUrl(githubUrl: string, relativePath: string, prefix?: string): string;
10
- export declare const getAllDemosInCategory: (allDemos: any[], lang: string) => import("lodash").Dictionary<any[]>;
11
- export declare const getSortedCategories: (allDemosInCategory: any, locale: string) => string[];
12
- export declare const getGroupedEdges: (edges: any) => import("lodash").Dictionary<any[]>;
13
- export declare const getGroupedEdgesDataEdit: (examples: any, edges: any, local: string) => string[];
14
- export declare const getTreeDataByExamplesAndEdges: (examples: any, edges: any, locale: string) => {
15
- title: any;
16
- value: string;
17
- icon: any;
18
- children: any[];
19
- }[];
20
- export {};
4
+ export declare function getGithubSourceURL(githubUrl: string, relativePath: string, prefix?: string): string;
5
+ export declare const filterTreeNode: (treeNode: TreeNode, keyValue: string, locale: string) => TreeNode;
@@ -1,30 +1,68 @@
1
- import { groupBy } from 'lodash-es';
2
- export var ping = function ping(callback) {
3
- var url = 'https://private-a' + 'lipay' + 'objects.alip' + 'ay.com/alip' + 'ay-rmsdeploy-image/rmsportal/RKuAiriJqrUhyqW.png';
4
- var img = new Image();
5
- var done = false;
6
-
7
- var finish = function finish(status) {
8
- if (!done) {
9
- done = true;
10
- img.src = '';
11
- callback(status);
12
- }
13
- };
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); }
14
2
 
15
- img.onload = function () {
16
- return finish('responded');
17
- };
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, $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 generator._invoke = function (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); } }; }(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; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return 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, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), 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 (object) { var 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; }
18
4
 
19
- img.onerror = function () {
20
- return finish('error');
21
- };
5
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
+
7
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+
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
+
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
+
15
+ 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; }
16
+
17
+ 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); } }
18
+
19
+ 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); }); }; }
20
+
21
+ import { icWithLocale } from "./hooks";
22
+ export function ping() {
23
+ return _ping.apply(this, arguments);
24
+ }
25
+
26
+ function _ping() {
27
+ _ping = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
28
+ var timeout, network;
29
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
30
+ while (1) {
31
+ switch (_context.prev = _context.next) {
32
+ case 0:
33
+ timeout = new Promise(function (resolve) {
34
+ setTimeout(function () {
35
+ resolve('timeout');
36
+ }, 1500);
37
+ });
38
+ network = new Promise(function (resolve) {
39
+ var url = 'https://private-a' + 'lipay' + 'objects.alip' + 'ay.com/alip' + 'ay-rmsdeploy-image/rmsportal/RKuAiriJqrUhyqW.png';
40
+ var img = new Image();
41
+
42
+ img.onload = function () {
43
+ img.src = '';
44
+ resolve('responded');
45
+ };
46
+
47
+ img.onerror = function () {
48
+ img.src = '';
49
+ resolve('error');
50
+ };
51
+
52
+ img.src = url;
53
+ });
54
+ return _context.abrupt("return", Promise.race([timeout, network]));
55
+
56
+ case 3:
57
+ case "end":
58
+ return _context.stop();
59
+ }
60
+ }
61
+ }, _callee);
62
+ }));
63
+ return _ping.apply(this, arguments);
64
+ }
22
65
 
23
- img.src = url;
24
- return setTimeout(function () {
25
- return finish('timeout');
26
- }, 1500);
27
- };
28
66
  export var getChinaMirrorHost = function getChinaMirrorHost(host) {
29
67
  var hostString = typeof host === 'undefined' ? window.location.host : host; // antv.vision => antv.gitee.io
30
68
 
@@ -41,7 +79,7 @@ export var getChinaMirrorHost = function getChinaMirrorHost(host) {
41
79
 
42
80
  return hostString;
43
81
  };
44
- export function getGithubSourceUrl(githubUrl, relativePath) {
82
+ export function getGithubSourceURL(githubUrl, relativePath) {
45
83
  var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'examples';
46
84
 
47
85
  // https://github.com/antvis/x6/tree/master/packages/x6-sites
@@ -51,104 +89,29 @@ export function getGithubSourceUrl(githubUrl, relativePath) {
51
89
 
52
90
  return "".concat(githubUrl, "/edit/master/").concat(prefix, "/").concat(relativePath);
53
91
  }
54
- export var getAllDemosInCategory = function getAllDemosInCategory(allDemos, lang) {
55
- return groupBy(allDemos || [], function (demo) {
56
- if (!demo.postFrontmatter || !demo.postFrontmatter[lang]) {
57
- return 'OTHER';
58
- }
59
-
60
- return demo.postFrontmatter[lang].title;
61
- });
62
- };
63
- export var getSortedCategories = function getSortedCategories(allDemosInCategory, locale) {
64
- return Object.keys(allDemosInCategory).sort(function (a, b) {
65
- if (a === 'OTHER') {
66
- return -1;
67
- }
92
+ export var filterTreeNode = function filterTreeNode(treeNode, keyValue, locale) {
93
+ if (treeNode.childrenKey && Array.isArray(treeNode[treeNode.childrenKey])) {
94
+ var children = treeNode[treeNode.childrenKey];
95
+ var filteredChildren = children.filter(function (child) {
96
+ var c = filterTreeNode(child, keyValue, locale);
97
+ return c !== null;
98
+ });
68
99
 
69
- if (b === 'OTHER') {
70
- return 1;
100
+ if (filteredChildren.length > 0) {
101
+ treeNode[treeNode.childrenKey] = _toConsumableArray(filteredChildren);
102
+ return treeNode;
71
103
  }
72
-
73
- return allDemosInCategory[a][0].postFrontmatter[locale].order - allDemosInCategory[b][0].postFrontmatter[locale].order;
74
- });
75
- };
76
-
77
- var getMenuItemLocaleKey = function getMenuItemLocaleKey() {
78
- var slug = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
79
- var slugPieces = slug.split('/');
80
- return slugPieces.slice(slugPieces.indexOf('examples') + 1).filter(function (key) {
81
- return key;
82
- }).join('/');
83
- };
84
-
85
- var getExampleOrder = function getExampleOrder(options) {
86
- var groupedEdgeKey = options.groupedEdgeKey,
87
- groupedEdges = options.groupedEdges,
88
- examples = options.examples;
89
- var key = getMenuItemLocaleKey(groupedEdgeKey);
90
-
91
- if (examples.find(function (item) {
92
- return item.slug === key;
93
- })) {
94
- return (examples.findIndex(function (item) {
95
- return item.slug === key;
96
- }) || 0) + 100;
97
104
  }
98
105
 
99
- if (!groupedEdges[groupedEdgeKey] && !groupedEdges[groupedEdgeKey].length) {
100
- return 0;
101
- }
106
+ var title = icWithLocale(treeNode.title, locale) || '';
107
+ var matchFields = [title, treeNode.id, treeNode.filename];
108
+ var isCurrentTreeNodeMatched = matchFields.some(function (f) {
109
+ return (f ? f.toLowerCase() : '').includes(keyValue ? keyValue.toLowerCase() : '');
110
+ }); // 当前节点自身匹配,那么其孩子直接匹配,可以直接返回当前节点
102
111
 
103
- return groupedEdges[groupedEdgeKey][0].node.frontmatter.order || 0;
104
- };
112
+ if (isCurrentTreeNodeMatched) {
113
+ return treeNode;
114
+ }
105
115
 
106
- export var getGroupedEdges = function getGroupedEdges(edges) {
107
- return groupBy(edges, function (_ref) {
108
- var slugString = _ref.node.fields.slug;
109
-
110
- // API.md and design.md
111
- if (slugString.endsWith('/API') || slugString.endsWith('/design')) {
112
- return slugString.split('/').slice(0, -2).join('/');
113
- } // index.md
114
-
115
-
116
- return slugString.split('/').slice(0, -1).join('/');
117
- });
118
- }; // 提取出筛选 和 排序的方法 好在获取treeData 的时候使用
119
-
120
- export var getGroupedEdgesDataEdit = function getGroupedEdgesDataEdit(examples, edges, local) {
121
- var groupedEdges = getGroupedEdges(edges);
122
- return Object.keys(groupedEdges).filter(function (key) {
123
- return key.startsWith("/".concat(local, "/"));
124
- }).sort(function (a, b) {
125
- var aOrder = getExampleOrder({
126
- groupedEdgeKey: a,
127
- examples: examples,
128
- groupedEdges: groupedEdges
129
- });
130
- var bOrder = getExampleOrder({
131
- groupedEdgeKey: b,
132
- examples: examples,
133
- groupedEdges: groupedEdges
134
- });
135
- return aOrder - bOrder;
136
- });
137
- };
138
- export var getTreeDataByExamplesAndEdges = function getTreeDataByExamplesAndEdges(examples, edges, locale) {
139
- return getGroupedEdgesDataEdit(examples, edges, locale).map(function (slugString) {
140
- var menuItemLocaleKey = getMenuItemLocaleKey(slugString);
141
- var doc = examples.find(function (item) {
142
- return item.slug === menuItemLocaleKey;
143
- }) || {};
144
- return {
145
- title: doc && doc.title ? doc.title[locale] : menuItemLocaleKey,
146
- value: slugString,
147
- icon: doc.icon,
148
- children: getGroupedEdges(edges)[slugString].filter(function (edge) {
149
- var slug = edge.node.fields.slug;
150
- return !(slug.endsWith('/API') || slug.endsWith('/design') || slug.endsWith('/gallery'));
151
- })
152
- };
153
- });
116
+ return null;
154
117
  };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,86 @@
1
1
  export interface IThemeConfig {
2
2
  [key: string]: any;
3
3
  }
4
+ export declare type Status = 'responded' | 'error' | 'timeout';
5
+ /**
6
+ * 配置文件中的国际化配置
7
+ */
8
+ export declare type IC = string | {
9
+ zh: string;
10
+ en: string;
11
+ };
12
+ export interface TreeNode {
13
+ /**
14
+ * id
15
+ */
16
+ id: string;
17
+ /**
18
+ * 孩子节点 key
19
+ */
20
+ childrenKey?: string;
21
+ /**
22
+ * 标题(支持国际化)
23
+ */
24
+ title: {
25
+ zh: string;
26
+ en: string;
27
+ };
28
+ [key: string]: any;
29
+ }
30
+ /** 案例 DEMO */
31
+ export interface Demo extends TreeNode {
32
+ /**
33
+ * 截图
34
+ */
35
+ screenshot: string;
36
+ /**
37
+ * TypeScript 源码文件
38
+ */
39
+ source: string;
40
+ /**
41
+ * DEMO 代码文件名称
42
+ */
43
+ filename: string;
44
+ /**
45
+ * 衍生属性,通过 topic.id + example.id + demo.id 可以计算获取
46
+ */
47
+ relativePath?: string;
48
+ /**
49
+ * 是否为新品
50
+ */
51
+ isNew?: boolean;
52
+ /**
53
+ * 目标 example
54
+ */
55
+ targetExample?: Example;
56
+ /**
57
+ * 目标主题
58
+ */
59
+ targetTopic?: ExampleTopic;
60
+ }
61
+ /** 示例 */
62
+ export interface Example extends TreeNode {
63
+ /**
64
+ * 图标
65
+ */
66
+ icon: string;
67
+ /**
68
+ * DEMO
69
+ */
70
+ demos: Demo[];
71
+ }
72
+ /** 案例主题 */
73
+ export interface ExampleTopic extends TreeNode {
74
+ /**
75
+ * 图标
76
+ */
77
+ icon: string;
78
+ /**
79
+ * slug 和 id 一样,兼容旧配置
80
+ */
81
+ slug?: string;
82
+ /**
83
+ * 所有案例
84
+ */
85
+ examples: Example[];
86
+ }
package/dist/typings.d.ts CHANGED
@@ -22,119 +22,3 @@ declare module '\*.svg' {
22
22
  const content: any;
23
23
  export default content;
24
24
  }
25
-
26
- declare namespace ExamplesPage {
27
- /** 案例 DEMO */
28
- export interface Demo {
29
- /**
30
- * id
31
- */
32
- id: string;
33
-
34
- /**
35
- * 标题(支持国际化)
36
- */
37
- title: {
38
- zh: string;
39
- en: string;
40
- };
41
-
42
- /**
43
- * 截图
44
- */
45
- screenshot: string;
46
-
47
- /**
48
- * TypeScript 源码文件
49
- */
50
- source: string;
51
-
52
- /**
53
- * DEMO 代码文件名称
54
- */
55
- filename: string;
56
-
57
- /**
58
- * 衍生属性,通过 topic.id + example.id + demo.id 可以计算获取
59
- */
60
- relativePath?: string;
61
-
62
- /**
63
- * 是否为新品
64
- */
65
- isNew?: boolean;
66
-
67
- /**
68
- * 目标 example
69
- */
70
- targetExample?: ExamplesPage.Example;
71
-
72
- /**
73
- * 目标主题
74
- */
75
- targetTopic?: ExamplesPage.ExampleTopic;
76
- }
77
-
78
- /** 示例 */
79
- export interface Example {
80
- /**
81
- * id
82
- */
83
- id: string;
84
-
85
- /**
86
- * 标题(支持国际化)
87
- */
88
- title: {
89
- zh: string;
90
- en: string;
91
- };
92
-
93
- /**
94
- * 图标
95
- */
96
- icon: string;
97
-
98
- /**
99
- * DEMO
100
- */
101
- demos: Demo[];
102
- }
103
-
104
- /** 案例主题 */
105
- export interface ExampleTopic {
106
- /**
107
- * id 和文件夹目录名保持一致
108
- */
109
- id: string;
110
- /**
111
- * slug 和 id 一样,兼容旧配置
112
- */
113
- slug?: string;
114
- /**
115
- * 标题
116
- */
117
- title: {
118
- zh: string;
119
- en: string;
120
- };
121
-
122
- /**
123
- * 图标
124
- */
125
- icon: string;
126
-
127
- /**
128
- * 所有案例
129
- */
130
- examples: Example[];
131
- }
132
- }
133
-
134
- /**
135
- * 配置文件中的国际化配置
136
- */
137
- declare type IC = string | {
138
- zh: string;
139
- en: string;
140
- }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.3.0-beta.2",
3
+ "version": "0.3.0-beta.21",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "types": "dist/types.d.ts",
6
6
  "scripts": {
7
7
  "dev": "father dev",
8
+ "dev:example-site": "cd example && npm run start",
8
9
  "build": "father build",
9
10
  "prepare": "father link-dev-theme",
10
11
  "lint": "npm run lint:es && npm run lint:css",
@@ -61,7 +62,7 @@
61
62
  "classnames": "^2.3.2",
62
63
  "codesandbox": "^2.2.3",
63
64
  "docsearch.js": "^2.6.3",
64
- "dumi": "^2.0.0-beta.11",
65
+ "dumi": "^2.0.0-beta.15",
65
66
  "front-matter": "^4.0.2",
66
67
  "fs-extra": "^10.1.0",
67
68
  "glob": "^8.0.3",
@@ -74,17 +75,21 @@
74
75
  "rc-footer": "^0.6.6",
75
76
  "react": "^18.2.0",
76
77
  "react-dom": "^18.2.0",
78
+ "react-error-boundary": "^3.1.4",
77
79
  "react-github-button": "^0.1.11",
80
+ "react-helmet": "^6.1.0",
78
81
  "react-router-dom": "^6.4.2",
79
82
  "react-slick": "^0.29.0",
80
83
  "react-split-pane": "^0.1.92",
81
84
  "react-use": "^17.4.0",
82
85
  "reading-time": "^1.5.0",
86
+ "size-sensor": "^1.0.1",
83
87
  "slick-carousel": "^1.8.1",
84
- "uri-parse": "^1.0.0"
88
+ "uri-parse": "^1.0.0",
89
+ "video-react": "^0.16.0"
85
90
  },
86
91
  "peerDependencies": {
87
- "dumi": "^2.0.0-beta.14",
92
+ "dumi": "^2.0.0-beta.15",
88
93
  "react": ">=16.9.0",
89
94
  "react-dom": ">=16.9.0"
90
95
  },
@@ -100,7 +105,6 @@
100
105
  "@types/react-router-dom": "^5.3.3",
101
106
  "@types/react-slick": "^0.23.10",
102
107
  "@umijs/lint": "^4.0.0",
103
- "dumi": "^2.0.0-beta.14",
104
108
  "eslint": "^8.23.0",
105
109
  "father": "^4.1.0",
106
110
  "father-plugin-dumi-theme": "^1.0.0-beta.1",
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Loading
4
- */
5
- export declare const Loading: () => JSX.Element;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- /**
3
- * Loading
4
- */
5
-
6
- export var Loading = function Loading() {
7
- return /*#__PURE__*/React.createElement(React.Fragment, null, "404");
8
- };