@antv/dumi-theme-antv 0.3.0-beta.1 → 0.3.0-beta.11
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/builtins/Playground/index.d.ts +2 -5
- package/dist/builtins/Playground/index.js +25 -6
- package/dist/context.d.ts +2 -1
- package/dist/layouts/DocLayout.js +25 -16
- package/dist/layouts/entry/Index.js +10 -2
- package/dist/layouts/entry/Manual.js +3 -1
- package/dist/pages/404.js +5 -1
- package/dist/pages/Example/index.js +28 -52
- package/dist/pages/Example/index.module.less +50 -8
- package/dist/pages/Example/utils.d.ts +1 -0
- package/dist/pages/Example/utils.js +9 -0
- package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +8 -5
- package/dist/pages/Examples/index.js +22 -2
- package/dist/pages/Examples/index.module.less +2 -0
- package/dist/pages/Examples/types.d.ts +7 -6
- package/dist/plugin/examples.d.ts +16 -2
- package/dist/plugin/examples.js +32 -10
- package/dist/plugin/index.js +31 -20
- package/dist/plugin/utils.d.ts +5 -0
- package/dist/plugin/utils.js +46 -0
- package/dist/slots/Cases/index.d.ts +1 -0
- package/dist/slots/Cases/index.js +1 -1
- package/dist/slots/Cases/index.module.less +2 -1
- package/dist/slots/CodeEditor/Toolbar.js +4 -16
- package/dist/slots/CodeEditor/index.d.ts +4 -0
- package/dist/slots/CodeEditor/index.js +48 -16
- package/dist/slots/CodeEditor/utils.js +2 -2
- package/dist/slots/CodePreview/CodeHeader.js +15 -14
- package/dist/slots/CodePreview/index.d.ts +8 -0
- package/dist/slots/CodePreview/index.js +6 -4
- package/dist/slots/CodePreview/index.module.less +17 -7
- package/dist/slots/CodeRunner/index.d.ts +5 -2
- package/dist/slots/CodeRunner/index.js +18 -4
- package/dist/slots/CodeRunner/utils.d.ts +3 -2
- package/dist/slots/CodeRunner/utils.js +1 -1
- package/dist/slots/Detail/News.d.ts +1 -0
- package/dist/slots/Detail/index.d.ts +1 -0
- package/dist/slots/Detail/index.js +1 -1
- package/dist/slots/ExampleSider/index.d.ts +4 -38
- package/dist/slots/ExampleSider/index.js +22 -44
- package/dist/slots/ExampleSider/index.module.less +1 -1
- package/dist/slots/Features/FeatureCard.d.ts +1 -0
- package/dist/slots/Features/index.js +2 -1
- package/dist/slots/Footer/index.js +3 -2
- package/dist/slots/Header/Navs.d.ts +10 -1
- package/dist/slots/Header/Navs.js +36 -19
- package/dist/slots/Header/index.js +8 -7
- package/dist/slots/Loading/index.d.ts +6 -1
- package/dist/slots/Loading/index.js +24 -10
- package/dist/slots/Loading/index.module.less +276 -9
- package/dist/slots/ManualContent/index.js +138 -113
- package/dist/slots/ManualContent/index.module.less +40 -33
- package/dist/slots/ManualContent/utils.d.ts +18 -0
- package/dist/slots/ManualContent/utils.js +64 -0
- package/dist/slots/SEO.d.ts +10 -0
- package/dist/slots/SEO.js +59 -0
- package/dist/slots/{TOC.d.ts → TOC/index.d.ts} +1 -0
- package/dist/slots/{TOC.js → TOC/index.js} +1 -0
- package/dist/slots/TOC/index.module.less +11 -0
- package/dist/slots/hooks.d.ts +3 -3
- package/dist/slots/utils.d.ts +4 -19
- package/dist/slots/utils.js +77 -119
- package/dist/types.d.ts +83 -0
- package/dist/typings.d.ts +0 -113
- package/package.json +7 -4
- package/dist/slots/Loading.d.ts +0 -5
- package/dist/slots/Loading.js +0 -8
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
.markdown {
|
|
8
8
|
font-size: 14px;
|
|
9
9
|
line-height: 2;
|
|
10
|
+
min-height: 600px; // 大概一屏幕占位,防止切换文档的时候,有黑影!
|
|
10
11
|
|
|
11
12
|
h1 {
|
|
12
13
|
margin-bottom: 20px;
|
|
@@ -203,7 +204,7 @@
|
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
.main {
|
|
206
|
-
width:
|
|
207
|
+
width: 100%;
|
|
207
208
|
padding-left: 48px;
|
|
208
209
|
padding-right: 24px;
|
|
209
210
|
overflow: hidden;
|
|
@@ -236,21 +237,39 @@
|
|
|
236
237
|
|
|
237
238
|
// reference yuque UI
|
|
238
239
|
.toc {
|
|
239
|
-
:
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
240
|
+
width: @toc-width;
|
|
241
|
+
float: right;
|
|
242
|
+
font-size: 12px;
|
|
243
|
+
background: #fff;
|
|
244
|
+
max-height: 100vh;
|
|
245
|
+
overflow: scroll;
|
|
246
|
+
|
|
247
|
+
position: sticky;
|
|
248
|
+
top: 0;
|
|
249
|
+
|
|
250
|
+
ul>li {
|
|
251
|
+
list-style: none !important;
|
|
252
|
+
padding: 0 !important;
|
|
253
|
+
margin-left: -1px !important;
|
|
254
|
+
|
|
255
|
+
// 超出部分省略号显示
|
|
256
|
+
text-overflow: ellipsis;
|
|
257
|
+
overflow: hidden;
|
|
258
|
+
white-space: nowrap;
|
|
259
|
+
|
|
260
|
+
a {
|
|
261
|
+
color: @text-color;
|
|
250
262
|
}
|
|
251
263
|
}
|
|
252
264
|
}
|
|
253
|
-
|
|
265
|
+
.contentTitle {
|
|
266
|
+
margin-top: 8px;
|
|
267
|
+
margin-bottom: 20px;
|
|
268
|
+
font-weight: 500;
|
|
269
|
+
font-size: 30px;
|
|
270
|
+
font-family: Avenir, -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
|
|
271
|
+
line-height: 38px;
|
|
272
|
+
}
|
|
254
273
|
.sider {
|
|
255
274
|
width: 280px !important;
|
|
256
275
|
height: inherit;
|
|
@@ -460,16 +479,11 @@
|
|
|
460
479
|
padding-left: 32px;
|
|
461
480
|
padding-right: 32px;
|
|
462
481
|
}
|
|
463
|
-
|
|
464
|
-
.toc {
|
|
465
|
-
display: none;
|
|
466
|
-
}
|
|
467
482
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
width: 240px !important;
|
|
483
|
+
.tocSiderbar {
|
|
484
|
+
display: none;
|
|
471
485
|
}
|
|
472
|
-
|
|
486
|
+
|
|
473
487
|
.gallery {
|
|
474
488
|
.galleryCard {
|
|
475
489
|
width: 50%;
|
|
@@ -487,11 +501,9 @@
|
|
|
487
501
|
}
|
|
488
502
|
|
|
489
503
|
.sider {
|
|
490
|
-
width: 100% !important;
|
|
491
504
|
margin-bottom: 32px;
|
|
492
505
|
padding-bottom: 32px;
|
|
493
506
|
border-bottom: 1px solid #e8e8e8;
|
|
494
|
-
display: none;
|
|
495
507
|
}
|
|
496
508
|
|
|
497
509
|
.markdown {
|
|
@@ -596,19 +608,13 @@
|
|
|
596
608
|
margin-bottom: 20px;
|
|
597
609
|
font-weight: 500;
|
|
598
610
|
font-size: 30px;
|
|
599
|
-
font-family: Avenir, -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
|
|
600
611
|
line-height: 38px;
|
|
601
612
|
}
|
|
602
613
|
|
|
603
614
|
.content {
|
|
604
|
-
|
|
605
|
-
justify-content: center;
|
|
615
|
+
width: 100% !important;
|
|
606
616
|
min-width: 400px;
|
|
607
|
-
|
|
608
|
-
.contentMain {
|
|
609
|
-
width: 100%;
|
|
610
|
-
padding: 0 24px 0 48px;
|
|
611
|
-
}
|
|
617
|
+
justify-content: center;
|
|
612
618
|
}
|
|
613
619
|
|
|
614
620
|
.menuSwitch {
|
|
@@ -630,10 +636,11 @@
|
|
|
630
636
|
border-radius: 0 4px 4px 0;
|
|
631
637
|
}
|
|
632
638
|
|
|
633
|
-
|
|
639
|
+
.readtimeContainer {
|
|
640
|
+
margin-bottom: 1.2em;
|
|
641
|
+
}
|
|
634
642
|
|
|
635
643
|
.readtime {
|
|
636
|
-
margin-bottom: 1.2em;
|
|
637
644
|
color: #0d1a26;
|
|
638
645
|
line-height: 1.5715;
|
|
639
646
|
list-style: none;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function getOpenKeys(): any[];
|
|
2
|
+
export declare function getBaseRoute(): string;
|
|
3
|
+
export declare function getIndexRoute(MenuData: any): any;
|
|
4
|
+
/**
|
|
5
|
+
* 返回需要跳转的 pathname
|
|
6
|
+
* /en/api/ ----> /en/api/[first-doc]
|
|
7
|
+
* /zh/api/ ----> /api/[first-doc]
|
|
8
|
+
* /en/docs/api/ ----> /en/api/[first-doc]
|
|
9
|
+
* /zh/docs/api/ ----> /api/[first-doc]
|
|
10
|
+
*
|
|
11
|
+
* /en/docs/api/xxx ----> /en/api/xxx
|
|
12
|
+
* /zh/docs/api/xxx ----> /api/xxx
|
|
13
|
+
*
|
|
14
|
+
* /docs/api/xxx -----> /api/xxx
|
|
15
|
+
*
|
|
16
|
+
* @param p
|
|
17
|
+
*/
|
|
18
|
+
export declare function getNavigateUrl(pathname: string, first: string, siderbarMenu: any[]): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export function getOpenKeys() {
|
|
2
|
+
var pathname = window.location.pathname.replace('/docs/', '/').replace('/zh/', '/');
|
|
3
|
+
var pathArr = pathname.split('/');
|
|
4
|
+
var openKeys = [];
|
|
5
|
+
|
|
6
|
+
for (var i = pathArr.length; i > 0; i--) {
|
|
7
|
+
var tem = pathArr.slice(0, i);
|
|
8
|
+
openKeys.push(tem.join('/'));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return openKeys;
|
|
12
|
+
}
|
|
13
|
+
export function getBaseRoute() {
|
|
14
|
+
var matchRoute = window.location.pathname; // 兼容 zh
|
|
15
|
+
|
|
16
|
+
matchRoute = matchRoute.replace('/zh/', '/'); // 兼容带有docs的route
|
|
17
|
+
|
|
18
|
+
matchRoute = matchRoute.replace('/docs', ''); // 查找 baseRoute
|
|
19
|
+
|
|
20
|
+
var reg = window.location.pathname.startsWith('/en') ? /(\/[A-z]*\/?\/[A-z]*)\/?/ : /(\/[A-z]*)\/?/;
|
|
21
|
+
var mainRoute = matchRoute.match(reg);
|
|
22
|
+
return mainRoute[1];
|
|
23
|
+
}
|
|
24
|
+
export function getIndexRoute(MenuData) {
|
|
25
|
+
var defaultOpenKeys = [];
|
|
26
|
+
var topRoute = MenuData[0];
|
|
27
|
+
defaultOpenKeys.push(topRoute.key);
|
|
28
|
+
|
|
29
|
+
while (topRoute.children) {
|
|
30
|
+
topRoute = topRoute.children[0];
|
|
31
|
+
defaultOpenKeys.push(topRoute.key);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return defaultOpenKeys[defaultOpenKeys.length - 1];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 返回需要跳转的 pathname
|
|
38
|
+
* /en/api/ ----> /en/api/[first-doc]
|
|
39
|
+
* /zh/api/ ----> /api/[first-doc]
|
|
40
|
+
* /en/docs/api/ ----> /en/api/[first-doc]
|
|
41
|
+
* /zh/docs/api/ ----> /api/[first-doc]
|
|
42
|
+
*
|
|
43
|
+
* /en/docs/api/xxx ----> /en/api/xxx
|
|
44
|
+
* /zh/docs/api/xxx ----> /api/xxx
|
|
45
|
+
*
|
|
46
|
+
* /docs/api/xxx -----> /api/xxx
|
|
47
|
+
*
|
|
48
|
+
* @param p
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
export function getNavigateUrl(pathname, first, siderbarMenu) {
|
|
52
|
+
// 兜底 如果 nav 指定有误则自动重定向到 indexDocRoute
|
|
53
|
+
if (pathname.includes('/docs/') || pathname.includes('/zh/')) {
|
|
54
|
+
return pathname.replace('/docs/', '/').replace('/zh/', '/');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!siderbarMenu.some(function (item) {
|
|
58
|
+
return item === pathname;
|
|
59
|
+
})) {
|
|
60
|
+
return first;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return pathname;
|
|
64
|
+
}
|
|
@@ -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/hooks.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ export declare const useChinaMirrorHost: () => [boolean];
|
|
|
3
3
|
export declare const useScrollToTop: () => void;
|
|
4
4
|
export declare const useT: (transformedMessage: string) => string;
|
|
5
5
|
export declare const useLogoLink: ({ link, siteUrl, lang, }: {
|
|
6
|
-
link?: string
|
|
7
|
-
siteUrl?: string
|
|
8
|
-
lang?: string
|
|
6
|
+
link?: string;
|
|
7
|
+
siteUrl?: string;
|
|
8
|
+
lang?: string;
|
|
9
9
|
}) => [string];
|
|
10
10
|
export declare const usePrevAndNext: () => NavigatorBannerProps['post'][];
|
|
11
11
|
/**
|
package/dist/slots/utils.d.ts
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
10
|
-
export declare const
|
|
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;
|
package/dist/slots/utils.js
CHANGED
|
@@ -1,30 +1,67 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
20
|
-
|
|
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
|
+
export function ping() {
|
|
22
|
+
return _ping.apply(this, arguments);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function _ping() {
|
|
26
|
+
_ping = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
27
|
+
var timeout, network;
|
|
28
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
29
|
+
while (1) {
|
|
30
|
+
switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
timeout = new Promise(function (resolve) {
|
|
33
|
+
setTimeout(function () {
|
|
34
|
+
resolve('timeout');
|
|
35
|
+
}, 1500);
|
|
36
|
+
});
|
|
37
|
+
network = new Promise(function (resolve) {
|
|
38
|
+
var url = 'https://private-a' + 'lipay' + 'objects.alip' + 'ay.com/alip' + 'ay-rmsdeploy-image/rmsportal/RKuAiriJqrUhyqW.png';
|
|
39
|
+
var img = new Image();
|
|
40
|
+
|
|
41
|
+
img.onload = function () {
|
|
42
|
+
img.src = '';
|
|
43
|
+
resolve('responded');
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
img.onerror = function () {
|
|
47
|
+
img.src = '';
|
|
48
|
+
resolve('error');
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
img.src = url;
|
|
52
|
+
});
|
|
53
|
+
return _context.abrupt("return", Promise.race([timeout, network]));
|
|
54
|
+
|
|
55
|
+
case 3:
|
|
56
|
+
case "end":
|
|
57
|
+
return _context.stop();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, _callee);
|
|
61
|
+
}));
|
|
62
|
+
return _ping.apply(this, arguments);
|
|
63
|
+
}
|
|
22
64
|
|
|
23
|
-
img.src = url;
|
|
24
|
-
return setTimeout(function () {
|
|
25
|
-
return finish('timeout');
|
|
26
|
-
}, 1500);
|
|
27
|
-
};
|
|
28
65
|
export var getChinaMirrorHost = function getChinaMirrorHost(host) {
|
|
29
66
|
var hostString = typeof host === 'undefined' ? window.location.host : host; // antv.vision => antv.gitee.io
|
|
30
67
|
|
|
@@ -41,7 +78,7 @@ export var getChinaMirrorHost = function getChinaMirrorHost(host) {
|
|
|
41
78
|
|
|
42
79
|
return hostString;
|
|
43
80
|
};
|
|
44
|
-
export function
|
|
81
|
+
export function getGithubSourceURL(githubUrl, relativePath) {
|
|
45
82
|
var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'examples';
|
|
46
83
|
|
|
47
84
|
// https://github.com/antvis/x6/tree/master/packages/x6-sites
|
|
@@ -51,104 +88,25 @@ export function getGithubSourceUrl(githubUrl, relativePath) {
|
|
|
51
88
|
|
|
52
89
|
return "".concat(githubUrl, "/edit/master/").concat(prefix, "/").concat(relativePath);
|
|
53
90
|
}
|
|
54
|
-
export var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
}
|
|
91
|
+
export var filterTreeNode = function filterTreeNode(treeNode, keyValue, locale) {
|
|
92
|
+
if (treeNode.childrenKey && Array.isArray(treeNode[treeNode.childrenKey])) {
|
|
93
|
+
var children = treeNode[treeNode.childrenKey];
|
|
94
|
+
var filteredChildren = children.filter(function (child) {
|
|
95
|
+
var c = filterTreeNode(child, keyValue, locale);
|
|
96
|
+
return c !== null;
|
|
97
|
+
});
|
|
68
98
|
|
|
69
|
-
if (
|
|
70
|
-
|
|
99
|
+
if (filteredChildren.length > 0) {
|
|
100
|
+
treeNode[treeNode.childrenKey] = _toConsumableArray(filteredChildren);
|
|
101
|
+
return treeNode;
|
|
71
102
|
}
|
|
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
103
|
}
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
return 0;
|
|
101
|
-
}
|
|
105
|
+
var isCurrentTreeNodeMatched = treeNode.title[locale].toLowerCase().includes(keyValue.toLowerCase()); // 当前节点自身匹配,那么其孩子直接匹配,可以直接返回当前节点
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
if (isCurrentTreeNodeMatched) {
|
|
108
|
+
return treeNode;
|
|
109
|
+
}
|
|
105
110
|
|
|
106
|
-
|
|
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
|
-
});
|
|
111
|
+
return null;
|
|
154
112
|
};
|