vuepress-plugin-md-power 1.0.0-rc.80 → 1.0.0-rc.81

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 (92) hide show
  1. package/lib/client/components/CodeSandbox.vue +1 -1
  2. package/lib/client/components/PDFViewer.vue +1 -1
  3. package/lib/client/components/Plot.vue +1 -1
  4. package/lib/client/components/Replit.vue +1 -1
  5. package/lib/client/composables/codeRepl.d.ts +7 -5
  6. package/lib/client/composables/codeRepl.js +253 -145
  7. package/lib/client/composables/pdf.d.ts +7 -3
  8. package/lib/client/composables/pdf.js +55 -81
  9. package/lib/client/composables/rustRepl.d.ts +3 -2
  10. package/lib/client/composables/rustRepl.js +96 -94
  11. package/lib/client/composables/size.d.ts +9 -5
  12. package/lib/client/composables/size.js +36 -44
  13. package/lib/client/index.js +2 -1
  14. package/lib/client/options.d.ts +5 -2
  15. package/lib/client/options.js +5 -1
  16. package/lib/client/utils/http.d.ts +3 -1
  17. package/lib/client/utils/http.js +24 -20
  18. package/lib/client/utils/is.d.ts +5 -3
  19. package/lib/client/utils/is.js +16 -10
  20. package/lib/client/utils/link.d.ts +3 -1
  21. package/lib/client/utils/link.js +8 -4
  22. package/lib/client/utils/sleep.d.ts +3 -1
  23. package/lib/client/utils/sleep.js +8 -4
  24. package/lib/node/index.d.ts +188 -2
  25. package/lib/node/index.js +833 -2
  26. package/lib/shared/index.d.ts +185 -10
  27. package/lib/shared/index.js +0 -10
  28. package/package.json +5 -5
  29. package/lib/node/features/caniuse.d.ts +0 -25
  30. package/lib/node/features/caniuse.js +0 -87
  31. package/lib/node/features/codeSandbox.d.ts +0 -7
  32. package/lib/node/features/codeSandbox.js +0 -29
  33. package/lib/node/features/codepen.d.ts +0 -7
  34. package/lib/node/features/codepen.js +0 -42
  35. package/lib/node/features/icons/index.d.ts +0 -2
  36. package/lib/node/features/icons/index.js +0 -2
  37. package/lib/node/features/icons/plugin.d.ts +0 -10
  38. package/lib/node/features/icons/plugin.js +0 -61
  39. package/lib/node/features/icons/writer.d.ts +0 -11
  40. package/lib/node/features/icons/writer.js +0 -126
  41. package/lib/node/features/jsfiddle.d.ts +0 -6
  42. package/lib/node/features/jsfiddle.js +0 -28
  43. package/lib/node/features/langRepl.d.ts +0 -4
  44. package/lib/node/features/langRepl.js +0 -59
  45. package/lib/node/features/pdf.d.ts +0 -2
  46. package/lib/node/features/pdf.js +0 -31
  47. package/lib/node/features/plot.d.ts +0 -5
  48. package/lib/node/features/plot.js +0 -48
  49. package/lib/node/features/replit.d.ts +0 -7
  50. package/lib/node/features/replit.js +0 -22
  51. package/lib/node/features/video/bilibili.d.ts +0 -2
  52. package/lib/node/features/video/bilibili.js +0 -58
  53. package/lib/node/features/video/youtube.d.ts +0 -2
  54. package/lib/node/features/video/youtube.js +0 -47
  55. package/lib/node/plugin.d.ts +0 -3
  56. package/lib/node/plugin.js +0 -80
  57. package/lib/node/prepareConfigFile.d.ts +0 -3
  58. package/lib/node/prepareConfigFile.js +0 -59
  59. package/lib/node/utils/createRuleBlock.d.ts +0 -18
  60. package/lib/node/utils/createRuleBlock.js +0 -34
  61. package/lib/node/utils/package.d.ts +0 -4
  62. package/lib/node/utils/package.js +0 -4
  63. package/lib/node/utils/parseRect.d.ts +0 -1
  64. package/lib/node/utils/parseRect.js +0 -5
  65. package/lib/node/utils/resolveAttrs.d.ts +0 -4
  66. package/lib/node/utils/resolveAttrs.js +0 -29
  67. package/lib/node/utils/timeToSeconds.d.ts +0 -1
  68. package/lib/node/utils/timeToSeconds.js +0 -8
  69. package/lib/shared/caniuse.d.ts +0 -18
  70. package/lib/shared/caniuse.js +0 -1
  71. package/lib/shared/codeSandbox.d.ts +0 -11
  72. package/lib/shared/codeSandbox.js +0 -1
  73. package/lib/shared/codepen.d.ts +0 -10
  74. package/lib/shared/codepen.js +0 -1
  75. package/lib/shared/icons.d.ts +0 -17
  76. package/lib/shared/icons.js +0 -1
  77. package/lib/shared/jsfiddle.d.ts +0 -8
  78. package/lib/shared/jsfiddle.js +0 -1
  79. package/lib/shared/pdf.d.ts +0 -15
  80. package/lib/shared/pdf.js +0 -1
  81. package/lib/shared/plot.d.ts +0 -27
  82. package/lib/shared/plot.js +0 -1
  83. package/lib/shared/plugin.d.ts +0 -21
  84. package/lib/shared/plugin.js +0 -1
  85. package/lib/shared/repl.d.ts +0 -22
  86. package/lib/shared/repl.js +0 -1
  87. package/lib/shared/replit.d.ts +0 -6
  88. package/lib/shared/replit.js +0 -1
  89. package/lib/shared/size.d.ts +0 -5
  90. package/lib/shared/size.js +0 -1
  91. package/lib/shared/video.d.ts +0 -22
  92. package/lib/shared/video.js +0 -1
@@ -1,102 +1,104 @@
1
- /**
2
- * 相比于 golang kotlin 可以比较简单的实现,
3
- * rust 需要通过 websocket 建立连接在实现交互,因此,将其进行一些包装,
4
- * 方便在 codeRepl 中使用
5
- */
6
- import { tryOnScopeDispose } from '@vueuse/core';
7
- const wsUrl = 'wss://play.rust-lang.org/websocket';
8
- const payloadType = {
9
- connected: 'websocket/connected',
10
- request: 'output/execute/wsExecuteRequest',
11
- execute: {
12
- begin: 'output/execute/wsExecuteBegin',
13
- // status: 'output/execute/wsExecuteStatus',
14
- stderr: 'output/execute/wsExecuteStderr',
15
- stdout: 'output/execute/wsExecuteStdout',
16
- end: 'output/execute/wsExecuteEnd',
17
- },
1
+ // src/client/composables/rustRepl.ts
2
+ import { tryOnScopeDispose } from "@vueuse/core";
3
+ var wsUrl = "wss://play.rust-lang.org/websocket";
4
+ var payloadType = {
5
+ connected: "websocket/connected",
6
+ request: "output/execute/wsExecuteRequest",
7
+ execute: {
8
+ begin: "output/execute/wsExecuteBegin",
9
+ // status: 'output/execute/wsExecuteStatus',
10
+ stderr: "output/execute/wsExecuteStderr",
11
+ stdout: "output/execute/wsExecuteStdout",
12
+ end: "output/execute/wsExecuteEnd"
13
+ }
18
14
  };
19
- let ws = null;
20
- let isOpen = false;
21
- let uuid = 0;
15
+ var ws = null;
16
+ var isOpen = false;
17
+ var uuid = 0;
22
18
  function connect() {
23
- if (isOpen)
24
- return Promise.resolve();
25
- ws = new WebSocket(wsUrl);
26
- uuid = 0;
27
- ws.addEventListener('open', () => {
28
- isOpen = true;
29
- send(payloadType.connected, { iAcceptThisIsAnUnsupportedApi: true }, { websocket: true, sequenceNumber: uuid });
30
- });
31
- ws.addEventListener('close', () => {
32
- isOpen = false;
33
- ws = null;
34
- });
35
- tryOnScopeDispose(() => ws?.close());
36
- return new Promise((resolve) => {
37
- function connected(e) {
38
- const data = JSON.parse(e.data);
39
- if (data.type === payloadType.connected) {
40
- ws?.removeEventListener('message', connected);
41
- resolve();
42
- }
43
- }
44
- ws?.addEventListener('message', connected);
45
- });
19
+ if (isOpen)
20
+ return Promise.resolve();
21
+ ws = new WebSocket(wsUrl);
22
+ uuid = 0;
23
+ ws.addEventListener("open", () => {
24
+ isOpen = true;
25
+ send(
26
+ payloadType.connected,
27
+ { iAcceptThisIsAnUnsupportedApi: true },
28
+ { websocket: true, sequenceNumber: uuid }
29
+ );
30
+ });
31
+ ws.addEventListener("close", () => {
32
+ isOpen = false;
33
+ ws = null;
34
+ });
35
+ tryOnScopeDispose(() => ws?.close());
36
+ return new Promise((resolve) => {
37
+ function connected(e) {
38
+ const data = JSON.parse(e.data);
39
+ if (data.type === payloadType.connected) {
40
+ ws?.removeEventListener("message", connected);
41
+ resolve();
42
+ }
43
+ }
44
+ ws?.addEventListener("message", connected);
45
+ });
46
46
  }
47
47
  function send(type, payload, meta) {
48
- const msg = { type, meta, payload };
49
- ws?.send(JSON.stringify(msg));
48
+ const msg = { type, meta, payload };
49
+ ws?.send(JSON.stringify(msg));
50
50
  }
51
- export async function rustExecute(code, { onEnd, onError, onStderr, onStdout, onBegin }) {
52
- await connect();
53
- const meta = { sequenceNumber: uuid++ };
54
- const payload = {
55
- backtrace: false,
56
- channel: 'stable',
57
- crateType: 'bin',
58
- edition: '2021',
59
- mode: 'release',
60
- tests: false,
61
- code,
62
- };
63
- send(payloadType.request, payload, meta);
64
- let stdout = '';
65
- let stderr = '';
66
- function onMessage(e) {
67
- const data = JSON.parse(e.data);
68
- const { type, payload, meta: _meta = {} } = data;
69
- if (_meta.sequenceNumber !== meta.sequenceNumber)
70
- return;
71
- if (type === payloadType.execute.begin)
72
- onBegin?.();
73
- if (type === payloadType.execute.stdout) {
74
- stdout += payload;
75
- if (stdout.endsWith('\n')) {
76
- onStdout?.(stdout);
77
- stdout = '';
78
- }
79
- }
80
- if (type === payloadType.execute.stderr) {
81
- stderr += payload;
82
- if (stderr.endsWith('\n')) {
83
- if (stderr.startsWith('error:')) {
84
- const index = stderr.indexOf('\n');
85
- onStderr?.(stderr.slice(0, index));
86
- onStderr?.(stderr.slice(index + 1));
87
- }
88
- else {
89
- onStderr?.(stderr);
90
- }
91
- stderr = '';
92
- }
93
- }
94
- if (type === payloadType.execute.end) {
95
- if (payload.success === false)
96
- onError?.(payload.exitDetail);
97
- ws?.removeEventListener('message', onMessage);
98
- onEnd?.();
51
+ async function rustExecute(code, { onEnd, onError, onStderr, onStdout, onBegin }) {
52
+ await connect();
53
+ const meta = { sequenceNumber: uuid++ };
54
+ const payload = {
55
+ backtrace: false,
56
+ channel: "stable",
57
+ crateType: "bin",
58
+ edition: "2021",
59
+ mode: "release",
60
+ tests: false,
61
+ code
62
+ };
63
+ send(payloadType.request, payload, meta);
64
+ let stdout = "";
65
+ let stderr = "";
66
+ function onMessage(e) {
67
+ const data = JSON.parse(e.data);
68
+ const { type, payload: payload2, meta: _meta = {} } = data;
69
+ if (_meta.sequenceNumber !== meta.sequenceNumber)
70
+ return;
71
+ if (type === payloadType.execute.begin)
72
+ onBegin?.();
73
+ if (type === payloadType.execute.stdout) {
74
+ stdout += payload2;
75
+ if (stdout.endsWith("\n")) {
76
+ onStdout?.(stdout);
77
+ stdout = "";
78
+ }
79
+ }
80
+ if (type === payloadType.execute.stderr) {
81
+ stderr += payload2;
82
+ if (stderr.endsWith("\n")) {
83
+ if (stderr.startsWith("error:")) {
84
+ const index = stderr.indexOf("\n");
85
+ onStderr?.(stderr.slice(0, index));
86
+ onStderr?.(stderr.slice(index + 1));
87
+ } else {
88
+ onStderr?.(stderr);
99
89
  }
90
+ stderr = "";
91
+ }
92
+ }
93
+ if (type === payloadType.execute.end) {
94
+ if (payload2.success === false)
95
+ onError?.(payload2.exitDetail);
96
+ ws?.removeEventListener("message", onMessage);
97
+ onEnd?.();
100
98
  }
101
- ws?.addEventListener('message', onMessage);
99
+ }
100
+ ws?.addEventListener("message", onMessage);
102
101
  }
102
+ export {
103
+ rustExecute
104
+ };
@@ -1,3 +1,7 @@
1
+ import { MaybeRef } from '@vueuse/core';
2
+ import { ShallowRef, Ref, ToRefs } from 'vue';
3
+ import { SizeOptions } from '../../shared/index.js';
4
+
1
5
  /**
2
6
  * Fork for https://github.com/vuepress-theme-hope/vuepress-theme-hope/blob/main/packages/components/src/client/composables/useSize.ts
3
7
  *
@@ -10,13 +14,13 @@
10
14
  *
11
15
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
16
  */
13
- import type { MaybeRef } from '@vueuse/core';
14
- import type { Ref, ShallowRef, ToRefs } from 'vue';
15
- import type { SizeOptions } from '../../shared/size.js';
16
- export interface SizeInfo<T extends HTMLElement> {
17
+
18
+ interface SizeInfo<T extends HTMLElement> {
17
19
  el: ShallowRef<T | undefined>;
18
20
  width: Ref<string>;
19
21
  height: Ref<string>;
20
22
  resize: () => void;
21
23
  }
22
- export declare function useSize<T extends HTMLElement>(options: ToRefs<SizeOptions>, extraHeight?: MaybeRef<number>): SizeInfo<T>;
24
+ declare function useSize<T extends HTMLElement>(options: ToRefs<SizeOptions>, extraHeight?: MaybeRef<number>): SizeInfo<T>;
25
+
26
+ export { type SizeInfo, useSize };
@@ -1,45 +1,37 @@
1
- /**
2
- * Fork for https://github.com/vuepress-theme-hope/vuepress-theme-hope/blob/main/packages/components/src/client/composables/useSize.ts
3
- *
4
- * The MIT License (MIT)
5
- * Copyright (C) 2021 - PRESENT by Mr.Hope<mister-hope@outlook.com>
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
- *
9
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
- *
11
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
- */
13
- import { useEventListener } from '@vueuse/core';
14
- import { computed, isRef, onMounted, ref, shallowRef, toValue, watch } from 'vue';
15
- export function useSize(options, extraHeight = 0) {
16
- const el = shallowRef();
17
- const width = computed(() => toValue(options.width) || '100%');
18
- const height = ref('auto');
19
- const getRadio = (ratio) => {
20
- if (typeof ratio === 'string') {
21
- const [width, height] = ratio.split(':');
22
- const parsedRadio = Number(width) / Number(height);
23
- if (!Number.isNaN(parsedRadio))
24
- return parsedRadio;
25
- }
26
- return typeof ratio === 'number' ? ratio : 16 / 9;
27
- };
28
- const getHeight = (width) => {
29
- const height = toValue(options.height);
30
- const ratio = getRadio(toValue(options.ratio));
31
- return height || `${Number(width) / ratio + toValue(extraHeight)}px`;
32
- };
33
- const resize = () => {
34
- if (el.value)
35
- height.value = getHeight(el.value.offsetWidth);
36
- };
37
- onMounted(() => {
38
- resize();
39
- if (isRef(extraHeight))
40
- watch(extraHeight, resize);
41
- useEventListener('orientationchange', resize);
42
- useEventListener('resize', resize);
43
- });
44
- return { el, width, height, resize };
1
+ // src/client/composables/size.ts
2
+ import { useEventListener } from "@vueuse/core";
3
+ import { computed, isRef, onMounted, ref, shallowRef, toValue, watch } from "vue";
4
+ function useSize(options, extraHeight = 0) {
5
+ const el = shallowRef();
6
+ const width = computed(() => toValue(options.width) || "100%");
7
+ const height = ref("auto");
8
+ const getRadio = (ratio) => {
9
+ if (typeof ratio === "string") {
10
+ const [width2, height2] = ratio.split(":");
11
+ const parsedRadio = Number(width2) / Number(height2);
12
+ if (!Number.isNaN(parsedRadio))
13
+ return parsedRadio;
14
+ }
15
+ return typeof ratio === "number" ? ratio : 16 / 9;
16
+ };
17
+ const getHeight = (width2) => {
18
+ const height2 = toValue(options.height);
19
+ const ratio = getRadio(toValue(options.ratio));
20
+ return height2 || `${Number(width2) / ratio + toValue(extraHeight)}px`;
21
+ };
22
+ const resize = () => {
23
+ if (el.value)
24
+ height.value = getHeight(el.value.offsetWidth);
25
+ };
26
+ onMounted(() => {
27
+ resize();
28
+ if (isRef(extraHeight))
29
+ watch(extraHeight, resize);
30
+ useEventListener("orientationchange", resize);
31
+ useEventListener("resize", resize);
32
+ });
33
+ return { el, width, height, resize };
45
34
  }
35
+ export {
36
+ useSize
37
+ };
@@ -1 +1,2 @@
1
- export * from '../shared/index.js';
1
+ // src/client/index.ts
2
+ export * from "../shared/index.js";
@@ -1,2 +1,5 @@
1
- import type { MarkdownPowerPluginOptions } from '../shared/index.js';
2
- export declare const pluginOptions: MarkdownPowerPluginOptions;
1
+ import { MarkdownPowerPluginOptions } from '../shared/index.js';
2
+
3
+ declare const pluginOptions: MarkdownPowerPluginOptions;
4
+
5
+ export { pluginOptions };
@@ -1 +1,5 @@
1
- export const pluginOptions = __MD_POWER_INJECT_OPTIONS__;
1
+ // src/client/options.ts
2
+ var pluginOptions = __MD_POWER_INJECT_OPTIONS__;
3
+ export {
4
+ pluginOptions
5
+ };
@@ -1,4 +1,6 @@
1
- export declare const http: {
1
+ declare const http: {
2
2
  get: <T extends object = object, R = any>(url: string, query?: T) => Promise<R>;
3
3
  post: <T extends object = object, R = any>(url: string, data?: T) => Promise<R>;
4
4
  };
5
+
6
+ export { http };
@@ -1,21 +1,25 @@
1
- export const http = {
2
- get: async (url, query) => {
3
- const _url = new URL(url);
4
- if (query) {
5
- for (const [key, value] of Object.entries(query))
6
- _url.searchParams.append(key, value);
7
- }
8
- const res = await fetch(_url.toString());
9
- return await res.json();
10
- },
11
- post: async (url, data) => {
12
- const res = await fetch(url, {
13
- method: 'POST',
14
- headers: {
15
- 'Content-Type': 'application/json',
16
- },
17
- body: data ? JSON.stringify(data) : undefined,
18
- });
19
- return await res.json();
20
- },
1
+ // src/client/utils/http.ts
2
+ var http = {
3
+ get: async (url, query) => {
4
+ const _url = new URL(url);
5
+ if (query) {
6
+ for (const [key, value] of Object.entries(query))
7
+ _url.searchParams.append(key, value);
8
+ }
9
+ const res = await fetch(_url.toString());
10
+ return await res.json();
11
+ },
12
+ post: async (url, data) => {
13
+ const res = await fetch(url, {
14
+ method: "POST",
15
+ headers: {
16
+ "Content-Type": "application/json"
17
+ },
18
+ body: data ? JSON.stringify(data) : void 0
19
+ });
20
+ return await res.json();
21
+ }
22
+ };
23
+ export {
24
+ http
21
25
  };
@@ -1,3 +1,5 @@
1
- export declare function checkIsMobile(ua: string): boolean;
2
- export declare function checkIsSafari(ua: string): boolean;
3
- export declare function checkIsiPad(ua: string): boolean;
1
+ declare function checkIsMobile(ua: string): boolean;
2
+ declare function checkIsSafari(ua: string): boolean;
3
+ declare function checkIsiPad(ua: string): boolean;
4
+
5
+ export { checkIsMobile, checkIsSafari, checkIsiPad };
@@ -1,13 +1,19 @@
1
- export function checkIsMobile(ua) {
2
- return /\b(?:Android|iPhone)/i.test(ua);
1
+ // src/client/utils/is.ts
2
+ function checkIsMobile(ua) {
3
+ return /\b(?:Android|iPhone)/i.test(ua);
3
4
  }
4
- export function checkIsSafari(ua) {
5
- return /version\/[\w.]+ .*(?:mobile ?safari|safari)/i.test(ua);
5
+ function checkIsSafari(ua) {
6
+ return /version\/[\w.]+ .*(?:mobile ?safari|safari)/i.test(ua);
6
7
  }
7
- export function checkIsiPad(ua) {
8
- return [
9
- /\((ipad);[-\w),; ]+apple/i,
10
- /applecoremedia\/[\w.]+ \((ipad)/i,
11
- /\b(ipad)\d\d?,\d\d?[;\]].+ios/i,
12
- ].some(item => item.test(ua));
8
+ function checkIsiPad(ua) {
9
+ return [
10
+ /\((ipad);[-\w),; ]+apple/i,
11
+ /applecoremedia\/[\w.]+ \((ipad)/i,
12
+ /\b(ipad)\d\d?,\d\d?[;\]].+ios/i
13
+ ].some((item) => item.test(ua));
13
14
  }
15
+ export {
16
+ checkIsMobile,
17
+ checkIsSafari,
18
+ checkIsiPad
19
+ };
@@ -1 +1,3 @@
1
- export declare function normalizeLink(url: string): string;
1
+ declare function normalizeLink(url: string): string;
2
+
3
+ export { normalizeLink };
@@ -1,5 +1,9 @@
1
- import { isLinkHttp } from 'vuepress/shared';
2
- import { withBase } from 'vuepress/client';
3
- export function normalizeLink(url) {
4
- return isLinkHttp(url) ? url : withBase(url);
1
+ // src/client/utils/link.ts
2
+ import { isLinkHttp } from "vuepress/shared";
3
+ import { withBase } from "vuepress/client";
4
+ function normalizeLink(url) {
5
+ return isLinkHttp(url) ? url : withBase(url);
5
6
  }
7
+ export {
8
+ normalizeLink
9
+ };
@@ -1 +1,3 @@
1
- export declare function sleep(ms: number): Promise<void>;
1
+ declare function sleep(ms: number): Promise<void>;
2
+
3
+ export { sleep };
@@ -1,5 +1,9 @@
1
- export function sleep(ms) {
2
- return new Promise((resolve) => {
3
- setTimeout(resolve, ms);
4
- });
1
+ // src/client/utils/sleep.ts
2
+ function sleep(ms) {
3
+ return new Promise((resolve) => {
4
+ setTimeout(resolve, ms);
5
+ });
5
6
  }
7
+ export {
8
+ sleep
9
+ };
@@ -1,2 +1,188 @@
1
- export * from './plugin.js';
2
- export * from '../shared/index.js';
1
+ import { Plugin } from 'vuepress/core';
2
+ import { BuiltinTheme, ThemeRegistration } from 'shiki';
3
+
4
+ type CanIUseMode = 'embed' | 'image';
5
+ interface CanIUseTokenMeta {
6
+ feature: string;
7
+ mode: CanIUseMode;
8
+ versions: string;
9
+ }
10
+ interface CanIUseOptions {
11
+ /**
12
+ * 嵌入模式
13
+ *
14
+ * embed 通过iframe嵌入,提供可交互视图
15
+ *
16
+ * image 通过图片嵌入,静态
17
+ *
18
+ * @default 'embed'
19
+ */
20
+ mode?: CanIUseMode;
21
+ }
22
+
23
+ interface SizeOptions {
24
+ width?: string;
25
+ height?: string;
26
+ ratio?: number | string;
27
+ }
28
+
29
+ type PDFEmbedType = 'iframe' | 'embed' | 'pdfjs';
30
+ interface PDFTokenMeta extends SizeOptions {
31
+ page?: number;
32
+ noToolbar?: boolean;
33
+ zoom?: number;
34
+ src?: string;
35
+ title?: string;
36
+ }
37
+ interface PDFOptions {
38
+ /**
39
+ * pdfjs url
40
+ */
41
+ pdfjsUrl?: string;
42
+ }
43
+
44
+ interface IconsOptions {
45
+ /**
46
+ * The prefix of the icon className
47
+ * @default 'vp-mdi'
48
+ */
49
+ prefix?: string;
50
+ /**
51
+ * The size of the icon
52
+ * @default '1em'
53
+ */
54
+ size?: string | number;
55
+ /**
56
+ * The color of the icon
57
+ * @default 'currentColor'
58
+ */
59
+ color?: string;
60
+ }
61
+
62
+ interface VideoOptions {
63
+ bilibili?: boolean;
64
+ youtube?: boolean;
65
+ }
66
+ interface BilibiliTokenMeta extends SizeOptions {
67
+ title?: string;
68
+ bvid?: string;
69
+ aid?: string;
70
+ cid?: string;
71
+ autoplay?: boolean;
72
+ time?: string | number;
73
+ page?: number;
74
+ }
75
+ interface YoutubeTokenMeta extends SizeOptions {
76
+ title?: string;
77
+ id: string;
78
+ autoplay?: boolean;
79
+ loop?: boolean;
80
+ start?: string | number;
81
+ end?: string | number;
82
+ }
83
+
84
+ interface CodepenTokenMeta extends SizeOptions {
85
+ title?: string;
86
+ user?: string;
87
+ slash?: string;
88
+ tab?: string;
89
+ theme?: string;
90
+ preview?: boolean;
91
+ editable?: boolean;
92
+ }
93
+
94
+ interface CodeSandboxTokenMeta extends SizeOptions {
95
+ user?: string;
96
+ id?: string;
97
+ layout?: string;
98
+ type?: 'button' | 'embed';
99
+ title?: string;
100
+ filepath?: string;
101
+ navbar?: boolean;
102
+ console?: boolean;
103
+ }
104
+
105
+ type ThemeOptions = BuiltinTheme | {
106
+ light: BuiltinTheme;
107
+ dark: BuiltinTheme;
108
+ };
109
+ interface ReplOptions {
110
+ theme?: ThemeOptions;
111
+ go?: boolean;
112
+ kotlin?: boolean;
113
+ rust?: boolean;
114
+ }
115
+ interface ReplEditorData {
116
+ grammars: {
117
+ go?: any;
118
+ kotlin?: any;
119
+ rust?: any;
120
+ };
121
+ theme: ThemeRegistration | {
122
+ light: ThemeRegistration;
123
+ dark: ThemeRegistration;
124
+ };
125
+ }
126
+
127
+ interface ReplitTokenMeta extends SizeOptions {
128
+ title?: string;
129
+ source?: string;
130
+ theme?: string;
131
+ }
132
+
133
+ interface JSFiddleTokenMeta extends SizeOptions {
134
+ user?: string;
135
+ id?: string;
136
+ title?: string;
137
+ theme?: string;
138
+ tab?: string;
139
+ }
140
+
141
+ interface PlotOptions {
142
+ /**
143
+ * 是否启用 `=| |=` markdown (该标记为非标准标记,脱离插件将不生效)
144
+ * @default true
145
+ */
146
+ tag?: boolean;
147
+ /**
148
+ * 遮罩层颜色
149
+ */
150
+ mask?: string | {
151
+ light: string;
152
+ dark: string;
153
+ };
154
+ /**
155
+ * 文本颜色
156
+ */
157
+ color?: string | {
158
+ light: string;
159
+ dark: string;
160
+ };
161
+ /**
162
+ * 触发方式
163
+ *
164
+ * @default 'hover'
165
+ */
166
+ trigger?: 'hover' | 'click';
167
+ }
168
+
169
+ interface MarkdownPowerPluginOptions {
170
+ pdf?: boolean | PDFOptions;
171
+ icons?: boolean | IconsOptions;
172
+ plot?: boolean | PlotOptions;
173
+ bilibili?: boolean;
174
+ youtube?: boolean;
175
+ codepen?: boolean;
176
+ /**
177
+ * @deprecated
178
+ */
179
+ replit?: boolean;
180
+ codeSandbox?: boolean;
181
+ jsfiddle?: boolean;
182
+ repl?: false | ReplOptions;
183
+ caniuse?: boolean | CanIUseOptions;
184
+ }
185
+
186
+ declare function markdownPowerPlugin(options?: MarkdownPowerPluginOptions): Plugin;
187
+
188
+ export { type BilibiliTokenMeta, type CanIUseMode, type CanIUseOptions, type CanIUseTokenMeta, type CodeSandboxTokenMeta, type CodepenTokenMeta, type IconsOptions, type JSFiddleTokenMeta, type MarkdownPowerPluginOptions, type PDFEmbedType, type PDFOptions, type PDFTokenMeta, type PlotOptions, type ReplEditorData, type ReplOptions, type ReplitTokenMeta, type SizeOptions, type ThemeOptions, type VideoOptions, type YoutubeTokenMeta, markdownPowerPlugin };