@vuepress/shared 2.0.0-beta.37 → 2.0.0-beta.40
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/index.cjs +198 -0
- package/dist/index.d.ts +289 -0
- package/dist/index.js +152 -0
- package/package.json +36 -13
- package/lib/esm/index.d.ts +0 -2
- package/lib/esm/index.js +0 -2
- package/lib/esm/types/head.d.ts +0 -27
- package/lib/esm/types/head.js +0 -1
- package/lib/esm/types/index.d.ts +0 -5
- package/lib/esm/types/index.js +0 -5
- package/lib/esm/types/locale.d.ts +0 -13
- package/lib/esm/types/locale.js +0 -1
- package/lib/esm/types/page.d.ts +0 -71
- package/lib/esm/types/page.js +0 -1
- package/lib/esm/types/site.d.ts +0 -42
- package/lib/esm/types/site.js +0 -1
- package/lib/esm/types/ssr.d.ts +0 -8
- package/lib/esm/types/ssr.js +0 -1
- package/lib/esm/utils/dedupeHead.d.ts +0 -7
- package/lib/esm/utils/dedupeHead.js +0 -18
- package/lib/esm/utils/ensureEndingSlash.d.ts +0 -4
- package/lib/esm/utils/ensureEndingSlash.js +0 -4
- package/lib/esm/utils/ensureLeadingSlash.d.ts +0 -4
- package/lib/esm/utils/ensureLeadingSlash.js +0 -4
- package/lib/esm/utils/formatDateString.d.ts +0 -4
- package/lib/esm/utils/formatDateString.js +0 -14
- package/lib/esm/utils/htmlEscape.d.ts +0 -4
- package/lib/esm/utils/htmlEscape.js +0 -12
- package/lib/esm/utils/htmlUnescape.d.ts +0 -4
- package/lib/esm/utils/htmlUnescape.js +0 -17
- package/lib/esm/utils/index.d.ts +0 -19
- package/lib/esm/utils/index.js +0 -19
- package/lib/esm/utils/isLinkExternal.d.ts +0 -4
- package/lib/esm/utils/isLinkExternal.js +0 -16
- package/lib/esm/utils/isLinkFtp.d.ts +0 -4
- package/lib/esm/utils/isLinkFtp.js +0 -4
- package/lib/esm/utils/isLinkHttp.d.ts +0 -8
- package/lib/esm/utils/isLinkHttp.js +0 -8
- package/lib/esm/utils/isLinkMailto.d.ts +0 -4
- package/lib/esm/utils/isLinkMailto.js +0 -4
- package/lib/esm/utils/isLinkTel.d.ts +0 -4
- package/lib/esm/utils/isLinkTel.js +0 -4
- package/lib/esm/utils/isPlainObject.d.ts +0 -4
- package/lib/esm/utils/isPlainObject.js +0 -4
- package/lib/esm/utils/normalizePackageName.d.ts +0 -4
- package/lib/esm/utils/normalizePackageName.js +0 -37
- package/lib/esm/utils/removeEndingSlash.d.ts +0 -4
- package/lib/esm/utils/removeEndingSlash.js +0 -4
- package/lib/esm/utils/removeLeadingSlash.d.ts +0 -4
- package/lib/esm/utils/removeLeadingSlash.js +0 -4
- package/lib/esm/utils/resolveHeadIdentifier.d.ts +0 -5
- package/lib/esm/utils/resolveHeadIdentifier.js +0 -18
- package/lib/esm/utils/resolveLocalePath.d.ts +0 -5
- package/lib/esm/utils/resolveLocalePath.js +0 -18
- package/lib/esm/utils/resolveRoutePathFromUrl.d.ts +0 -1
- package/lib/esm/utils/resolveRoutePathFromUrl.js +0 -5
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -18
- package/lib/types/head.d.ts +0 -27
- package/lib/types/head.js +0 -2
- package/lib/types/index.d.ts +0 -5
- package/lib/types/index.js +0 -21
- package/lib/types/locale.d.ts +0 -13
- package/lib/types/locale.js +0 -2
- package/lib/types/page.d.ts +0 -71
- package/lib/types/page.js +0 -2
- package/lib/types/site.d.ts +0 -42
- package/lib/types/site.js +0 -2
- package/lib/types/ssr.d.ts +0 -8
- package/lib/types/ssr.js +0 -2
- package/lib/utils/dedupeHead.d.ts +0 -7
- package/lib/utils/dedupeHead.js +0 -22
- package/lib/utils/ensureEndingSlash.d.ts +0 -4
- package/lib/utils/ensureEndingSlash.js +0 -8
- package/lib/utils/ensureLeadingSlash.d.ts +0 -4
- package/lib/utils/ensureLeadingSlash.js +0 -8
- package/lib/utils/formatDateString.d.ts +0 -4
- package/lib/utils/formatDateString.js +0 -18
- package/lib/utils/htmlEscape.d.ts +0 -4
- package/lib/utils/htmlEscape.js +0 -16
- package/lib/utils/htmlUnescape.d.ts +0 -4
- package/lib/utils/htmlUnescape.js +0 -21
- package/lib/utils/index.d.ts +0 -19
- package/lib/utils/index.js +0 -40
- package/lib/utils/isLinkExternal.d.ts +0 -4
- package/lib/utils/isLinkExternal.js +0 -20
- package/lib/utils/isLinkFtp.d.ts +0 -4
- package/lib/utils/isLinkFtp.js +0 -8
- package/lib/utils/isLinkHttp.d.ts +0 -8
- package/lib/utils/isLinkHttp.js +0 -12
- package/lib/utils/isLinkMailto.d.ts +0 -4
- package/lib/utils/isLinkMailto.js +0 -8
- package/lib/utils/isLinkTel.d.ts +0 -4
- package/lib/utils/isLinkTel.js +0 -8
- package/lib/utils/isPlainObject.d.ts +0 -4
- package/lib/utils/isPlainObject.js +0 -8
- package/lib/utils/normalizePackageName.d.ts +0 -4
- package/lib/utils/normalizePackageName.js +0 -41
- package/lib/utils/removeEndingSlash.d.ts +0 -4
- package/lib/utils/removeEndingSlash.js +0 -8
- package/lib/utils/removeLeadingSlash.d.ts +0 -4
- package/lib/utils/removeLeadingSlash.js +0 -8
- package/lib/utils/resolveHeadIdentifier.d.ts +0 -5
- package/lib/utils/resolveHeadIdentifier.js +0 -22
- package/lib/utils/resolveLocalePath.d.ts +0 -5
- package/lib/utils/resolveLocalePath.js +0 -22
- package/lib/utils/resolveRoutePathFromUrl.d.ts +0 -1
- package/lib/utils/resolveRoutePathFromUrl.js +0 -9
package/lib/types/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./head"), exports);
|
|
18
|
-
__exportStar(require("./locale"), exports);
|
|
19
|
-
__exportStar(require("./page"), exports);
|
|
20
|
-
__exportStar(require("./site"), exports);
|
|
21
|
-
__exportStar(require("./ssr"), exports);
|
package/lib/types/locale.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Locales config, a key-value object
|
|
3
|
-
*
|
|
4
|
-
* - Key is the locale path (prefix)
|
|
5
|
-
* - Value is the locales data
|
|
6
|
-
*
|
|
7
|
-
* @remark suffix `Config` means this is for user config
|
|
8
|
-
*/
|
|
9
|
-
export declare type LocaleConfig<T extends LocaleData = LocaleData> = Record<string, Partial<T>>;
|
|
10
|
-
/**
|
|
11
|
-
* Locales data
|
|
12
|
-
*/
|
|
13
|
-
export declare type LocaleData = Record<string, any>;
|
package/lib/types/locale.js
DELETED
package/lib/types/page.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { HeadConfig } from './head';
|
|
2
|
-
/**
|
|
3
|
-
* Vuepress page data
|
|
4
|
-
*/
|
|
5
|
-
export declare type PageData<ExtraPageData extends Record<any, any> = Record<never, never>> = ExtraPageData & {
|
|
6
|
-
/**
|
|
7
|
-
* Identifier of the page
|
|
8
|
-
*
|
|
9
|
-
* Will also be used as the component name
|
|
10
|
-
*
|
|
11
|
-
* @example 'v-foobar'
|
|
12
|
-
*/
|
|
13
|
-
key: string;
|
|
14
|
-
/**
|
|
15
|
-
* Route path of the page
|
|
16
|
-
*
|
|
17
|
-
* Firstly inferred from the file path
|
|
18
|
-
*
|
|
19
|
-
* Might be overridden by permalink
|
|
20
|
-
*
|
|
21
|
-
* @example '/guide/index.html'
|
|
22
|
-
* @example '/2020/02/02/hello-world.html'
|
|
23
|
-
*/
|
|
24
|
-
path: string;
|
|
25
|
-
/**
|
|
26
|
-
* Title of the page
|
|
27
|
-
*/
|
|
28
|
-
title: string;
|
|
29
|
-
/**
|
|
30
|
-
* Language of the page
|
|
31
|
-
*/
|
|
32
|
-
lang: string;
|
|
33
|
-
/**
|
|
34
|
-
* Front matter of the page
|
|
35
|
-
*/
|
|
36
|
-
frontmatter: PageFrontmatter;
|
|
37
|
-
/**
|
|
38
|
-
* Excerpt of the page
|
|
39
|
-
*/
|
|
40
|
-
excerpt: string;
|
|
41
|
-
/**
|
|
42
|
-
* Headers of the page
|
|
43
|
-
*/
|
|
44
|
-
headers: PageHeader[];
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Vuepress page frontmatter
|
|
48
|
-
*
|
|
49
|
-
* Notice that frontmatter is parsed from yaml or other languages,
|
|
50
|
-
* so we cannot guarantee the type safety
|
|
51
|
-
*/
|
|
52
|
-
export declare type PageFrontmatter<T extends Record<any, any> = Record<string, unknown>> = Partial<T> & {
|
|
53
|
-
date?: string | Date;
|
|
54
|
-
description?: string;
|
|
55
|
-
head?: HeadConfig[];
|
|
56
|
-
lang?: string;
|
|
57
|
-
layout?: string;
|
|
58
|
-
permalink?: string;
|
|
59
|
-
permalinkPattern?: string;
|
|
60
|
-
routeMeta?: Record<string, unknown>;
|
|
61
|
-
title?: string;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Vuepress page header
|
|
65
|
-
*/
|
|
66
|
-
export interface PageHeader {
|
|
67
|
-
level: number;
|
|
68
|
-
title: string;
|
|
69
|
-
slug: string;
|
|
70
|
-
children: PageHeader[];
|
|
71
|
-
}
|
package/lib/types/page.js
DELETED
package/lib/types/site.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { HeadConfig } from './head';
|
|
2
|
-
import type { LocaleConfig } from './locale';
|
|
3
|
-
/**
|
|
4
|
-
* Vuepress site data
|
|
5
|
-
*/
|
|
6
|
-
export interface SiteData extends SiteLocaleData {
|
|
7
|
-
base: '/' | `/${string}/`;
|
|
8
|
-
locales: SiteLocaleConfig;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Locales data of vuepress site
|
|
12
|
-
*
|
|
13
|
-
* If they are set in the root of site data, they will be used
|
|
14
|
-
* as the default value
|
|
15
|
-
*
|
|
16
|
-
* If they are set in the `locales` of site data, they will be
|
|
17
|
-
* used for specific locale
|
|
18
|
-
*/
|
|
19
|
-
export interface SiteLocaleData {
|
|
20
|
-
lang: string;
|
|
21
|
-
title: string;
|
|
22
|
-
description: string;
|
|
23
|
-
head: HeadConfig[];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Site locale config
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* {
|
|
30
|
-
* '/en/': {
|
|
31
|
-
* lang: 'en-US',
|
|
32
|
-
* title: 'Hello',
|
|
33
|
-
* },
|
|
34
|
-
* '/zh/: {
|
|
35
|
-
* lang: 'zh-CN',
|
|
36
|
-
* title: '你好',
|
|
37
|
-
* }
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* @remark suffix `Config` means this is for user config
|
|
41
|
-
*/
|
|
42
|
-
export declare type SiteLocaleConfig = LocaleConfig<SiteLocaleData>;
|
package/lib/types/site.js
DELETED
package/lib/types/ssr.d.ts
DELETED
package/lib/types/ssr.js
DELETED
package/lib/utils/dedupeHead.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dedupeHead = void 0;
|
|
4
|
-
const resolveHeadIdentifier_1 = require("./resolveHeadIdentifier");
|
|
5
|
-
/**
|
|
6
|
-
* Dedupe head config with identifier
|
|
7
|
-
*
|
|
8
|
-
* Items that appear earlier have higher priority
|
|
9
|
-
*/
|
|
10
|
-
const dedupeHead = (head) => {
|
|
11
|
-
const identifierSet = new Set();
|
|
12
|
-
const result = [];
|
|
13
|
-
head.forEach((item) => {
|
|
14
|
-
const identifier = (0, resolveHeadIdentifier_1.resolveHeadIdentifier)(item);
|
|
15
|
-
if (!identifierSet.has(identifier)) {
|
|
16
|
-
identifierSet.add(identifier);
|
|
17
|
-
result.push(item);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
return result;
|
|
21
|
-
};
|
|
22
|
-
exports.dedupeHead = dedupeHead;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureEndingSlash = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Ensure a url string to have ending slash /
|
|
6
|
-
*/
|
|
7
|
-
const ensureEndingSlash = (str) => /(\.html|\/)$/.test(str) ? str : str + '/';
|
|
8
|
-
exports.ensureEndingSlash = ensureEndingSlash;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureLeadingSlash = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Ensure a url string to have leading slash /
|
|
6
|
-
*/
|
|
7
|
-
const ensureLeadingSlash = (str) => str.replace(/^\/?/, '/');
|
|
8
|
-
exports.ensureLeadingSlash = ensureLeadingSlash;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatDateString = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Format a date string to `yyyy-MM-dd`
|
|
6
|
-
*/
|
|
7
|
-
const formatDateString = (str, defaultDateString = '') => {
|
|
8
|
-
// match the `yyyy-(M)M-(d)d` pattern
|
|
9
|
-
const dateMatch = str.match(/\b(\d{4})-(\d{1,2})-(\d{1,2})\b/);
|
|
10
|
-
// return `defaultDateString` if no matched pattern
|
|
11
|
-
if (dateMatch === null) {
|
|
12
|
-
return defaultDateString;
|
|
13
|
-
}
|
|
14
|
-
// fill leading zeros for month and day
|
|
15
|
-
const [, yearStr, monthStr, dayStr] = dateMatch;
|
|
16
|
-
return [yearStr, monthStr.padStart(2, '0'), dayStr.padStart(2, '0')].join('-');
|
|
17
|
-
};
|
|
18
|
-
exports.formatDateString = formatDateString;
|
package/lib/utils/htmlEscape.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.htmlEscape = void 0;
|
|
4
|
-
const htmlEscapeMap = {
|
|
5
|
-
'&': '&',
|
|
6
|
-
'<': '<',
|
|
7
|
-
'>': '>',
|
|
8
|
-
"'": ''',
|
|
9
|
-
'"': '"',
|
|
10
|
-
};
|
|
11
|
-
const htmlEscapeRegexp = /[&<>'"]/g;
|
|
12
|
-
/**
|
|
13
|
-
* Escape html chars
|
|
14
|
-
*/
|
|
15
|
-
const htmlEscape = (str) => str.replace(htmlEscapeRegexp, (char) => htmlEscapeMap[char]);
|
|
16
|
-
exports.htmlEscape = htmlEscape;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.htmlUnescape = void 0;
|
|
4
|
-
const htmlUnescapeMap = {
|
|
5
|
-
'&': '&',
|
|
6
|
-
'&': '&',
|
|
7
|
-
'<': '<',
|
|
8
|
-
'<': '<',
|
|
9
|
-
'>': '>',
|
|
10
|
-
'>': '>',
|
|
11
|
-
''': "'",
|
|
12
|
-
''': "'",
|
|
13
|
-
'"': '"',
|
|
14
|
-
'"': '"',
|
|
15
|
-
};
|
|
16
|
-
const htmlUnescapeRegexp = /&(amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
|
|
17
|
-
/**
|
|
18
|
-
* Unescape html chars
|
|
19
|
-
*/
|
|
20
|
-
const htmlUnescape = (str) => str.replace(htmlUnescapeRegexp, (char) => htmlUnescapeMap[char]);
|
|
21
|
-
exports.htmlUnescape = htmlUnescape;
|
package/lib/utils/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export { isArray, isFunction, isPromise, isString } from '@vue/shared';
|
|
2
|
-
export * from './dedupeHead';
|
|
3
|
-
export * from './ensureLeadingSlash';
|
|
4
|
-
export * from './ensureEndingSlash';
|
|
5
|
-
export * from './formatDateString';
|
|
6
|
-
export * from './htmlEscape';
|
|
7
|
-
export * from './htmlUnescape';
|
|
8
|
-
export * from './isLinkExternal';
|
|
9
|
-
export * from './isLinkFtp';
|
|
10
|
-
export * from './isLinkHttp';
|
|
11
|
-
export * from './isLinkMailto';
|
|
12
|
-
export * from './isLinkTel';
|
|
13
|
-
export * from './isPlainObject';
|
|
14
|
-
export * from './normalizePackageName';
|
|
15
|
-
export * from './removeEndingSlash';
|
|
16
|
-
export * from './removeLeadingSlash';
|
|
17
|
-
export * from './resolveHeadIdentifier';
|
|
18
|
-
export * from './resolveLocalePath';
|
|
19
|
-
export * from './resolveRoutePathFromUrl';
|
package/lib/utils/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isString = exports.isPromise = exports.isFunction = exports.isArray = void 0;
|
|
18
|
-
var shared_1 = require("@vue/shared");
|
|
19
|
-
Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return shared_1.isArray; } });
|
|
20
|
-
Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return shared_1.isFunction; } });
|
|
21
|
-
Object.defineProperty(exports, "isPromise", { enumerable: true, get: function () { return shared_1.isPromise; } });
|
|
22
|
-
Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return shared_1.isString; } });
|
|
23
|
-
__exportStar(require("./dedupeHead"), exports);
|
|
24
|
-
__exportStar(require("./ensureLeadingSlash"), exports);
|
|
25
|
-
__exportStar(require("./ensureEndingSlash"), exports);
|
|
26
|
-
__exportStar(require("./formatDateString"), exports);
|
|
27
|
-
__exportStar(require("./htmlEscape"), exports);
|
|
28
|
-
__exportStar(require("./htmlUnescape"), exports);
|
|
29
|
-
__exportStar(require("./isLinkExternal"), exports);
|
|
30
|
-
__exportStar(require("./isLinkFtp"), exports);
|
|
31
|
-
__exportStar(require("./isLinkHttp"), exports);
|
|
32
|
-
__exportStar(require("./isLinkMailto"), exports);
|
|
33
|
-
__exportStar(require("./isLinkTel"), exports);
|
|
34
|
-
__exportStar(require("./isPlainObject"), exports);
|
|
35
|
-
__exportStar(require("./normalizePackageName"), exports);
|
|
36
|
-
__exportStar(require("./removeEndingSlash"), exports);
|
|
37
|
-
__exportStar(require("./removeLeadingSlash"), exports);
|
|
38
|
-
__exportStar(require("./resolveHeadIdentifier"), exports);
|
|
39
|
-
__exportStar(require("./resolveLocalePath"), exports);
|
|
40
|
-
__exportStar(require("./resolveRoutePathFromUrl"), exports);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLinkExternal = void 0;
|
|
4
|
-
const isLinkFtp_1 = require("./isLinkFtp");
|
|
5
|
-
const isLinkHttp_1 = require("./isLinkHttp");
|
|
6
|
-
/**
|
|
7
|
-
* Determine a link is external or not
|
|
8
|
-
*/
|
|
9
|
-
const isLinkExternal = (link, base = '/') => {
|
|
10
|
-
// http link or ftp link
|
|
11
|
-
if ((0, isLinkHttp_1.isLinkHttp)(link) || (0, isLinkFtp_1.isLinkFtp)(link)) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
// absolute link that does not start with `base`
|
|
15
|
-
if (link.startsWith('/') && !link.startsWith(base)) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
};
|
|
20
|
-
exports.isLinkExternal = isLinkExternal;
|
package/lib/utils/isLinkFtp.d.ts
DELETED
package/lib/utils/isLinkFtp.js
DELETED
package/lib/utils/isLinkHttp.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLinkHttp = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Determine a link is http link or not
|
|
6
|
-
*
|
|
7
|
-
* - http://github.com
|
|
8
|
-
* - https://github.com
|
|
9
|
-
* - //github.com
|
|
10
|
-
*/
|
|
11
|
-
const isLinkHttp = (link) => /^(https?:)?\/\//.test(link);
|
|
12
|
-
exports.isLinkHttp = isLinkHttp;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLinkMailto = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Determine a link is a mailto: address or not
|
|
6
|
-
*/
|
|
7
|
-
const isLinkMailto = (link) => /^mailto:/.test(link);
|
|
8
|
-
exports.isLinkMailto = isLinkMailto;
|
package/lib/utils/isLinkTel.d.ts
DELETED
package/lib/utils/isLinkTel.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isPlainObject = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Check if a value is plain object, with generic type support
|
|
6
|
-
*/
|
|
7
|
-
const isPlainObject = (val) => Object.prototype.toString.call(val) === '[object Object]';
|
|
8
|
-
exports.isPlainObject = isPlainObject;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizePackageName = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Normalize package name
|
|
6
|
-
*/
|
|
7
|
-
const normalizePackageName = (request, org, type = null) => {
|
|
8
|
-
// org prefix and type prefix
|
|
9
|
-
const orgPrefix = `${org}-`;
|
|
10
|
-
const typePrefix = type === null ? '' : `${type}-`;
|
|
11
|
-
// scoped package pattern
|
|
12
|
-
const scopedMatch = request.match(/^@(.*)\/(.*)$/);
|
|
13
|
-
// handle non-scoped package
|
|
14
|
-
if (scopedMatch === null) {
|
|
15
|
-
// full name, return as is
|
|
16
|
-
if (request.startsWith(`${orgPrefix}${typePrefix}`)) {
|
|
17
|
-
return request;
|
|
18
|
-
}
|
|
19
|
-
// short name, add org prefix and type prefix
|
|
20
|
-
return `${orgPrefix}${typePrefix}${request}`;
|
|
21
|
-
}
|
|
22
|
-
// handle scoped package
|
|
23
|
-
const [, reqOrg, reqName] = scopedMatch;
|
|
24
|
-
// handle default org
|
|
25
|
-
if (reqOrg === org) {
|
|
26
|
-
// full name, return as is
|
|
27
|
-
if (reqName.startsWith(typePrefix)) {
|
|
28
|
-
return request;
|
|
29
|
-
}
|
|
30
|
-
// short name, add type prefix
|
|
31
|
-
return `@${reqOrg}/${typePrefix}${reqName}`;
|
|
32
|
-
}
|
|
33
|
-
// handle other org
|
|
34
|
-
// full name, return as is
|
|
35
|
-
if (reqName.startsWith(`${orgPrefix}${typePrefix}`)) {
|
|
36
|
-
return request;
|
|
37
|
-
}
|
|
38
|
-
// short name, add org prefix and type prefix
|
|
39
|
-
return `@${reqOrg}/${orgPrefix}${typePrefix}${reqName}`;
|
|
40
|
-
};
|
|
41
|
-
exports.normalizePackageName = normalizePackageName;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeEndingSlash = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Remove ending slash / from a string
|
|
6
|
-
*/
|
|
7
|
-
const removeEndingSlash = (str) => str.replace(/\/$/, '');
|
|
8
|
-
exports.removeEndingSlash = removeEndingSlash;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeLeadingSlash = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Remove leading slash / from a string
|
|
6
|
-
*/
|
|
7
|
-
const removeLeadingSlash = (str) => str.replace(/^\//, '');
|
|
8
|
-
exports.removeLeadingSlash = removeLeadingSlash;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveHeadIdentifier = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve identifier of a tag, to avoid duplicated tags in `<head>`
|
|
6
|
-
*/
|
|
7
|
-
const resolveHeadIdentifier = ([tag, attrs, content,]) => {
|
|
8
|
-
// avoid duplicated `<meta>` with same `name`
|
|
9
|
-
if (tag === 'meta' && attrs.name) {
|
|
10
|
-
return `${tag}.${attrs.name}`;
|
|
11
|
-
}
|
|
12
|
-
// there should be only one `<title>` or `<base>`
|
|
13
|
-
if (['title', 'base'].includes(tag)) {
|
|
14
|
-
return tag;
|
|
15
|
-
}
|
|
16
|
-
// avoid duplicated `<template>` with same `id`
|
|
17
|
-
if (tag === 'template' && attrs.id) {
|
|
18
|
-
return `${tag}.${attrs.id}`;
|
|
19
|
-
}
|
|
20
|
-
return JSON.stringify([tag, attrs, content]);
|
|
21
|
-
};
|
|
22
|
-
exports.resolveHeadIdentifier = resolveHeadIdentifier;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveLocalePath = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve the matched locale path of route path
|
|
6
|
-
*/
|
|
7
|
-
const resolveLocalePath = (locales, routePath) => {
|
|
8
|
-
const localePaths = Object.keys(locales).sort((a, b) => {
|
|
9
|
-
const levelDelta = b.split('/').length - a.split('/').length;
|
|
10
|
-
if (levelDelta !== 0) {
|
|
11
|
-
return levelDelta;
|
|
12
|
-
}
|
|
13
|
-
return b.length - a.length;
|
|
14
|
-
});
|
|
15
|
-
for (const localePath of localePaths) {
|
|
16
|
-
if (routePath.startsWith(localePath)) {
|
|
17
|
-
return localePath;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return '/';
|
|
21
|
-
};
|
|
22
|
-
exports.resolveLocalePath = resolveLocalePath;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const resolveRoutePathFromUrl: (url: string, base?: string) => string;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveRoutePathFromUrl = void 0;
|
|
4
|
-
const resolveRoutePathFromUrl = (url, base = '/') => url
|
|
5
|
-
// remove url origin
|
|
6
|
-
.replace(/^(https?:)?\/\/[^/]*/, '')
|
|
7
|
-
// remove site base
|
|
8
|
-
.replace(new RegExp(`^${base}`), '/');
|
|
9
|
-
exports.resolveRoutePathFromUrl = resolveRoutePathFromUrl;
|