@vuepress/shared 2.0.0-rc.31 → 2.0.0-rc.32

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.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { MarkdownItHeader } from "@mdit-vue/types";
2
- //#region src/types/head.d.ts
3
2
  /**
4
3
  * Config for `<head>` tags
5
4
  */
@@ -22,8 +21,6 @@ type HeadTagEmpty = 'base' | 'link' | 'meta' | 'script';
22
21
  * Attributes to be set for tags in `<head>`
23
22
  */
24
23
  type HeadAttrsConfig = Record<string, boolean | string>;
25
- //#endregion
26
- //#region src/types/locale.d.ts
27
24
  /**
28
25
  * Locales config, a key-value object
29
26
  *
@@ -36,9 +33,7 @@ type LocaleConfig<T extends LocaleData = LocaleData> = Record<string, Partial<T>
36
33
  /**
37
34
  * Locales data
38
35
  */
39
- type LocaleData = Record<never, never>;
40
- //#endregion
41
- //#region src/types/page.d.ts
36
+ type LocaleData = object;
42
37
  /**
43
38
  * Base type of vuepress page
44
39
  */
@@ -92,8 +87,6 @@ type PageFrontmatter<T extends Record<string, unknown> = Record<string, unknown>
92
87
  * Vuepress page header
93
88
  */
94
89
  type PageHeader = MarkdownItHeader;
95
- //#endregion
96
- //#region src/types/site.d.ts
97
90
  /**
98
91
  * Vuepress site data
99
92
  */
@@ -171,8 +164,6 @@ interface SiteLocaleData {
171
164
  * Site locale config
172
165
  */
173
166
  type SiteLocaleConfig = LocaleConfig<SiteLocaleData>;
174
- //#endregion
175
- //#region src/types/ssr.d.ts
176
167
  /**
177
168
  * Context for SSR
178
169
  */
@@ -180,14 +171,10 @@ interface VuepressSSRContext {
180
171
  lang: string;
181
172
  head: HeadConfig[];
182
173
  }
183
- //#endregion
184
- //#region src/utils/links/isLinkExternal.d.ts
185
174
  /**
186
175
  * Determine a link is external or not
187
176
  */
188
- declare const isLinkExternal: (link: string, base?: string) => boolean;
189
- //#endregion
190
- //#region src/utils/links/isLinkHttp.d.ts
177
+ export declare const isLinkExternal: (link: string, base?: string) => boolean;
191
178
  /**
192
179
  * Determine a link is http link or not
193
180
  *
@@ -195,109 +182,78 @@ declare const isLinkExternal: (link: string, base?: string) => boolean;
195
182
  * - https://github.com
196
183
  * - //github.com
197
184
  */
198
- declare const isLinkHttp: (link: string) => boolean;
199
- //#endregion
200
- //#region src/utils/links/isLinkWithProtocol.d.ts
185
+ export declare const isLinkHttp: (link: string) => boolean;
201
186
  /**
202
187
  * Determine a link has protocol or not
203
188
  */
204
- declare const isLinkWithProtocol: (link: string) => boolean;
205
- //#endregion
206
- //#region src/utils/routes/inferRoutePath.d.ts
189
+ export declare const isLinkWithProtocol: (link: string) => boolean;
207
190
  /**
208
191
  * Infer route path of the given raw path
209
192
  */
210
- declare const inferRoutePath: (rawPath: string) => string;
211
- //#endregion
212
- //#region src/utils/routes/normalizeRoutePath.d.ts
193
+ export declare const inferRoutePath: (rawPath: string) => string;
213
194
  /**
214
195
  * Normalize the given pathname path to the final route path
215
196
  */
216
- declare const normalizeRoutePath: (pathname: string, current?: string) => string;
217
- //#endregion
218
- //#region src/utils/routes/resolveLocalePath.d.ts
197
+ export declare const normalizeRoutePath: (pathname: string, current?: string) => string;
219
198
  /**
220
199
  * Resolve the matched locale path of route path
221
200
  */
222
- declare const resolveLocalePath: (locales: LocaleConfig, routePath: string) => string;
223
- //#endregion
224
- //#region src/utils/routes/resolveRoutePathFromUrl.d.ts
201
+ export declare const resolveLocalePath: (locales: LocaleConfig, routePath: string) => string;
225
202
  /**
226
203
  * For a give URL, remove the origin and the site base to get the route path
227
204
  */
228
- declare const resolveRoutePathFromUrl: (url: string, base?: string) => string;
229
- //#endregion
230
- //#region src/utils/routes/splitPath.d.ts
205
+ export declare const resolveRoutePathFromUrl: (url: string, base?: string) => string;
231
206
  /**
232
207
  * Split a path into pathname and hashAndQueries
233
208
  */
234
- declare const splitPath: (path: string) => {
209
+ export declare const splitPath: (path: string) => {
235
210
  pathname: string;
236
211
  hashAndQueries: string;
237
212
  };
238
- //#endregion
239
- //#region src/utils/dedupeHead.d.ts
240
213
  /**
241
214
  * Dedupe head config with identifier
242
215
  *
243
216
  * Items that appear earlier have higher priority
244
217
  */
245
- declare const dedupeHead: (head: HeadConfig[]) => HeadConfig[];
246
- //#endregion
247
- //#region src/utils/ensureLeadingSlash.d.ts
218
+ export declare const dedupeHead: (head: HeadConfig[]) => HeadConfig[];
248
219
  /**
249
220
  * Ensure a url string to have leading slash /
250
221
  */
251
- declare const ensureLeadingSlash: (str: string) => string;
252
- //#endregion
253
- //#region src/utils/ensureEndingSlash.d.ts
222
+ export declare const ensureLeadingSlash: (str: string) => string;
254
223
  /**
255
224
  * Ensure a url string to have ending slash /
256
225
  */
257
- declare const ensureEndingSlash: (str: string) => string;
258
- //#endregion
259
- //#region src/utils/formatDateString.d.ts
226
+ export declare const ensureEndingSlash: (str: string) => string;
260
227
  /**
261
228
  * Format a date string to `yyyy-MM-dd`
262
229
  */
263
- declare const formatDateString: (str: string, defaultDateString?: string) => string;
264
- //#endregion
265
- //#region src/utils/omit.d.ts
230
+ export declare const formatDateString: (str: string, defaultDateString?: string) => string;
266
231
  /**
267
232
  * Omit properties from an object
268
233
  */
269
- declare const omit: <T extends Record<string, unknown>, U extends string[]>(obj: T, ...keys: U) => Omit<T, U[number]>;
270
- //#endregion
271
- //#region src/utils/removeEndingSlash.d.ts
234
+ export declare const omit: <T extends Record<string, unknown>, U extends string[]>(obj: T, ...keys: U) => Omit<T, U[number]>;
272
235
  /**
273
236
  * Remove ending slash / from a string
274
237
  */
275
- declare const removeEndingSlash: (str: string) => string;
276
- //#endregion
277
- //#region src/utils/removeLeadingSlash.d.ts
238
+ export declare const removeEndingSlash: (str: string) => string;
278
239
  /**
279
240
  * Remove leading slash / from a string
280
241
  */
281
- declare const removeLeadingSlash: (str: string) => string;
282
- //#endregion
283
- //#region src/utils/resolveHeadIdentifier.d.ts
242
+ export declare const removeLeadingSlash: (str: string) => string;
284
243
  /**
285
244
  * Resolve identifier of a tag, to avoid duplicated tags in `<head>`
286
245
  */
287
- declare const resolveHeadIdentifier: ([tag, attrs, content]: HeadConfig) => string | null;
288
- //#endregion
289
- //#region src/utils/typeGuards.d.ts
246
+ export declare const resolveHeadIdentifier: ([tag, attrs, content]: HeadConfig) => string | null;
290
247
  /**
291
248
  * Check if a value is a function
292
249
  */
293
- declare const isFunction: (val: unknown) => val is Function;
250
+ export declare const isFunction: (val: unknown) => val is Function;
294
251
  /**
295
252
  * Check if a value is plain object, with generic type support
296
253
  */
297
- declare const isPlainObject: <T extends Record<any, any> = Record<any, any>>(val: unknown) => val is T;
254
+ export declare const isPlainObject: <T extends Record<any, any> = Record<any, any>>(val: unknown) => val is T;
298
255
  /**
299
256
  * Check if a value is a string
300
257
  */
301
- declare const isString: (val: unknown) => val is string;
302
- //#endregion
303
- export { type HeadAttrsConfig, type HeadConfig, type HeadTag, type HeadTagEmpty, type HeadTagNonEmpty, type LocaleConfig, type LocaleData, type PageBase, type PageData, type PageFrontmatter, type PageHeader, type SiteData, type SiteLocaleConfig, type SiteLocaleData, type VuepressSSRContext, dedupeHead, ensureEndingSlash, ensureLeadingSlash, formatDateString, inferRoutePath, isFunction, isLinkExternal, isLinkHttp, isLinkWithProtocol, isPlainObject, isString, normalizeRoutePath, omit, removeEndingSlash, removeLeadingSlash, resolveHeadIdentifier, resolveLocalePath, resolveRoutePathFromUrl, splitPath };
258
+ export declare const isString: (val: unknown) => val is string;
259
+ export type { HeadAttrsConfig, HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, LocaleConfig, LocaleData, PageBase, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig, SiteLocaleData, VuepressSSRContext };
package/dist/index.js CHANGED
@@ -1,17 +1,15 @@
1
- //#region src/utils/links/isLinkWithProtocol.ts
1
+ // src/utils/links/isLinkWithProtocol.ts
2
2
  /**
3
3
  * Determine a link has protocol or not
4
4
  */
5
5
  const isLinkWithProtocol = (link) => /^[a-z][a-z0-9+.-]*:/.test(link) || link.startsWith("//");
6
- //#endregion
7
- //#region src/utils/links/isLinkExternal.ts
6
+ // src/utils/links/isLinkExternal.ts
8
7
  const markdownLinkRegexp = /.md((\?|#).*)?$/;
9
8
  /**
10
9
  * Determine a link is external or not
11
10
  */
12
11
  const isLinkExternal = (link, base = "/") => isLinkWithProtocol(link) || link.startsWith("/") && !link.startsWith(base) && !markdownLinkRegexp.test(link);
13
- //#endregion
14
- //#region src/utils/links/isLinkHttp.ts
12
+ // src/utils/links/isLinkHttp.ts
15
13
  /**
16
14
  * Determine a link is http link or not
17
15
  *
@@ -20,8 +18,7 @@ const isLinkExternal = (link, base = "/") => isLinkWithProtocol(link) || link.st
20
18
  * - //github.com
21
19
  */
22
20
  const isLinkHttp = (link) => /^(https?:)?\/\//.test(link);
23
- //#endregion
24
- //#region src/utils/routes/inferRoutePath.ts
21
+ // src/utils/routes/inferRoutePath.ts
25
22
  /**
26
23
  * Infer route path of the given raw path
27
24
  */
@@ -33,8 +30,7 @@ const inferRoutePath = (rawPath) => {
33
30
  if (routePath.endsWith("/index.html")) routePath = routePath.substring(0, routePath.length - 10);
34
31
  return routePath;
35
32
  };
36
- //#endregion
37
- //#region src/utils/routes/normalizeRoutePath.ts
33
+ // src/utils/routes/normalizeRoutePath.ts
38
34
  const FAKE_HOST = "http://.";
39
35
  /**
40
36
  * Normalize the given pathname path to the final route path
@@ -46,8 +42,7 @@ const normalizeRoutePath = (pathname, current) => {
46
42
  }
47
43
  return inferRoutePath(pathname);
48
44
  };
49
- //#endregion
50
- //#region src/utils/routes/resolveLocalePath.ts
45
+ // src/utils/routes/resolveLocalePath.ts
51
46
  /**
52
47
  * Resolve the matched locale path of route path
53
48
  */
@@ -60,8 +55,7 @@ const resolveLocalePath = (locales, routePath) => {
60
55
  for (const localePath of localePaths) if (routePath.startsWith(localePath)) return localePath;
61
56
  return "/";
62
57
  };
63
- //#endregion
64
- //#region src/utils/routes/resolveRoutePathFromUrl.ts
58
+ // src/utils/routes/resolveRoutePathFromUrl.ts
65
59
  /**
66
60
  * For a give URL, remove the origin and the site base to get the route path
67
61
  */
@@ -69,8 +63,7 @@ const resolveRoutePathFromUrl = (url, base = "/") => {
69
63
  const pathname = url.replace(/^(?:https?:)?\/\/[^/]*/, "");
70
64
  return pathname.startsWith(base) ? `/${pathname.slice(base.length)}` : pathname;
71
65
  };
72
- //#endregion
73
- //#region src/utils/routes/splitPath.ts
66
+ // src/utils/routes/splitPath.ts
74
67
  const SPLIT_CHAR_REGEXP = /(#|\?)/;
75
68
  /**
76
69
  * Split a path into pathname and hashAndQueries
@@ -82,8 +75,7 @@ const splitPath = (path) => {
82
75
  hashAndQueries: hashAndQueries.join("")
83
76
  };
84
77
  };
85
- //#endregion
86
- //#region src/utils/resolveHeadIdentifier.ts
78
+ // src/utils/resolveHeadIdentifier.ts
87
79
  const TAGS_ALLOWED = [
88
80
  "link",
89
81
  "meta",
@@ -110,8 +102,7 @@ const resolveHeadIdentifier = ([tag, attrs, content]) => {
110
102
  content
111
103
  ]);
112
104
  };
113
- //#endregion
114
- //#region src/utils/dedupeHead.ts
105
+ // src/utils/dedupeHead.ts
115
106
  /**
116
107
  * Dedupe head config with identifier
117
108
  *
@@ -129,20 +120,17 @@ const dedupeHead = (head) => {
129
120
  });
130
121
  return result;
131
122
  };
132
- //#endregion
133
- //#region src/utils/ensureLeadingSlash.ts
123
+ // src/utils/ensureLeadingSlash.ts
134
124
  /**
135
125
  * Ensure a url string to have leading slash /
136
126
  */
137
127
  const ensureLeadingSlash = (str) => str.startsWith("/") ? str : `/${str}`;
138
- //#endregion
139
- //#region src/utils/ensureEndingSlash.ts
128
+ // src/utils/ensureEndingSlash.ts
140
129
  /**
141
130
  * Ensure a url string to have ending slash /
142
131
  */
143
132
  const ensureEndingSlash = (str) => str.endsWith("/") || str.endsWith(".html") ? str : `${str}/`;
144
- //#endregion
145
- //#region src/utils/formatDateString.ts
133
+ // src/utils/formatDateString.ts
146
134
  /**
147
135
  * Format a date string to `yyyy-MM-dd`
148
136
  */
@@ -156,8 +144,7 @@ const formatDateString = (str, defaultDateString = "") => {
156
144
  dayStr.padStart(2, "0")
157
145
  ].join("-");
158
146
  };
159
- //#endregion
160
- //#region src/utils/omit.ts
147
+ // src/utils/omit.ts
161
148
  /**
162
149
  * Omit properties from an object
163
150
  */
@@ -166,20 +153,17 @@ const omit = (obj, ...keys) => {
166
153
  for (const key of keys) delete result[key];
167
154
  return result;
168
155
  };
169
- //#endregion
170
- //#region src/utils/removeEndingSlash.ts
156
+ // src/utils/removeEndingSlash.ts
171
157
  /**
172
158
  * Remove ending slash / from a string
173
159
  */
174
160
  const removeEndingSlash = (str) => str.endsWith("/") ? str.slice(0, -1) : str;
175
- //#endregion
176
- //#region src/utils/removeLeadingSlash.ts
161
+ // src/utils/removeLeadingSlash.ts
177
162
  /**
178
163
  * Remove leading slash / from a string
179
164
  */
180
165
  const removeLeadingSlash = (str) => str.startsWith("/") ? str.slice(1) : str;
181
- //#endregion
182
- //#region src/utils/typeGuards.ts
166
+ // src/utils/typeGuards.ts
183
167
  /**
184
168
  * Check if a value is a function
185
169
  */
@@ -192,5 +176,4 @@ const isPlainObject = (val) => Object.prototype.toString.call(val) === "[object
192
176
  * Check if a value is a string
193
177
  */
194
178
  const isString = (val) => typeof val === "string";
195
- //#endregion
196
179
  export { dedupeHead, ensureEndingSlash, ensureLeadingSlash, formatDateString, inferRoutePath, isFunction, isLinkExternal, isLinkHttp, isLinkWithProtocol, isPlainObject, isString, normalizeRoutePath, omit, removeEndingSlash, removeLeadingSlash, resolveHeadIdentifier, resolveLocalePath, resolveRoutePathFromUrl, splitPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/shared",
3
- "version": "2.0.0-rc.31",
3
+ "version": "2.0.0-rc.32",
4
4
  "description": "Utils that shared between VuePress node and client",
5
5
  "keywords": [
6
6
  "shared",
@@ -32,7 +32,7 @@
32
32
  "access": "public"
33
33
  },
34
34
  "dependencies": {
35
- "@mdit-vue/types": "^3.0.2"
35
+ "@mdit-vue/types": "^4.0.0"
36
36
  },
37
37
  "tsdown": {
38
38
  "dts": true,