vuepress-plugin-md-power 1.0.0-rc.80 → 1.0.0-rc.82
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/lib/client/components/CodeEditor.vue +4 -3
- package/lib/client/components/CodeSandbox.vue +1 -1
- package/lib/client/components/PDFViewer.vue +1 -1
- package/lib/client/components/Plot.vue +1 -1
- package/lib/client/components/Replit.vue +1 -1
- package/lib/client/composables/codeRepl.d.ts +7 -5
- package/lib/client/composables/codeRepl.js +253 -145
- package/lib/client/composables/pdf.d.ts +7 -3
- package/lib/client/composables/pdf.js +55 -81
- package/lib/client/composables/rustRepl.d.ts +3 -2
- package/lib/client/composables/rustRepl.js +96 -94
- package/lib/client/composables/size.d.ts +9 -5
- package/lib/client/composables/size.js +36 -44
- package/lib/client/index.js +2 -1
- package/lib/client/options.d.ts +5 -2
- package/lib/client/options.js +5 -1
- package/lib/client/utils/http.d.ts +3 -1
- package/lib/client/utils/http.js +24 -20
- package/lib/client/utils/is.d.ts +5 -3
- package/lib/client/utils/is.js +16 -10
- package/lib/client/utils/link.d.ts +3 -1
- package/lib/client/utils/link.js +8 -4
- package/lib/client/utils/sleep.d.ts +3 -1
- package/lib/client/utils/sleep.js +8 -4
- package/lib/node/index.d.ts +188 -2
- package/lib/node/index.js +847 -2
- package/lib/shared/index.d.ts +185 -10
- package/lib/shared/index.js +0 -10
- package/package.json +9 -9
- package/lib/node/features/caniuse.d.ts +0 -25
- package/lib/node/features/caniuse.js +0 -87
- package/lib/node/features/codeSandbox.d.ts +0 -7
- package/lib/node/features/codeSandbox.js +0 -29
- package/lib/node/features/codepen.d.ts +0 -7
- package/lib/node/features/codepen.js +0 -42
- package/lib/node/features/icons/index.d.ts +0 -2
- package/lib/node/features/icons/index.js +0 -2
- package/lib/node/features/icons/plugin.d.ts +0 -10
- package/lib/node/features/icons/plugin.js +0 -61
- package/lib/node/features/icons/writer.d.ts +0 -11
- package/lib/node/features/icons/writer.js +0 -126
- package/lib/node/features/jsfiddle.d.ts +0 -6
- package/lib/node/features/jsfiddle.js +0 -28
- package/lib/node/features/langRepl.d.ts +0 -4
- package/lib/node/features/langRepl.js +0 -59
- package/lib/node/features/pdf.d.ts +0 -2
- package/lib/node/features/pdf.js +0 -31
- package/lib/node/features/plot.d.ts +0 -5
- package/lib/node/features/plot.js +0 -48
- package/lib/node/features/replit.d.ts +0 -7
- package/lib/node/features/replit.js +0 -22
- package/lib/node/features/video/bilibili.d.ts +0 -2
- package/lib/node/features/video/bilibili.js +0 -58
- package/lib/node/features/video/youtube.d.ts +0 -2
- package/lib/node/features/video/youtube.js +0 -47
- package/lib/node/plugin.d.ts +0 -3
- package/lib/node/plugin.js +0 -80
- package/lib/node/prepareConfigFile.d.ts +0 -3
- package/lib/node/prepareConfigFile.js +0 -59
- package/lib/node/utils/createRuleBlock.d.ts +0 -18
- package/lib/node/utils/createRuleBlock.js +0 -34
- package/lib/node/utils/package.d.ts +0 -4
- package/lib/node/utils/package.js +0 -4
- package/lib/node/utils/parseRect.d.ts +0 -1
- package/lib/node/utils/parseRect.js +0 -5
- package/lib/node/utils/resolveAttrs.d.ts +0 -4
- package/lib/node/utils/resolveAttrs.js +0 -29
- package/lib/node/utils/timeToSeconds.d.ts +0 -1
- package/lib/node/utils/timeToSeconds.js +0 -8
- package/lib/shared/caniuse.d.ts +0 -18
- package/lib/shared/caniuse.js +0 -1
- package/lib/shared/codeSandbox.d.ts +0 -11
- package/lib/shared/codeSandbox.js +0 -1
- package/lib/shared/codepen.d.ts +0 -10
- package/lib/shared/codepen.js +0 -1
- package/lib/shared/icons.d.ts +0 -17
- package/lib/shared/icons.js +0 -1
- package/lib/shared/jsfiddle.d.ts +0 -8
- package/lib/shared/jsfiddle.js +0 -1
- package/lib/shared/pdf.d.ts +0 -15
- package/lib/shared/pdf.js +0 -1
- package/lib/shared/plot.d.ts +0 -27
- package/lib/shared/plot.js +0 -1
- package/lib/shared/plugin.d.ts +0 -21
- package/lib/shared/plugin.js +0 -1
- package/lib/shared/repl.d.ts +0 -22
- package/lib/shared/repl.js +0 -1
- package/lib/shared/replit.d.ts +0 -6
- package/lib/shared/replit.js +0 -1
- package/lib/shared/size.d.ts +0 -5
- package/lib/shared/size.js +0 -1
- package/lib/shared/video.d.ts +0 -22
- package/lib/shared/video.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare function rustExecute(code: string, { onEnd, onError, onStderr, onStdout, onBegin }: RustExecuteOptions): Promise<void>;
|
|
2
2
|
interface RustExecuteOptions {
|
|
3
3
|
onBegin?: () => void;
|
|
4
4
|
onStdout?: (message: string) => void;
|
|
@@ -6,4 +6,5 @@ interface RustExecuteOptions {
|
|
|
6
6
|
onEnd?: () => void;
|
|
7
7
|
onError?: (message: string) => void;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
export { rustExecute };
|
|
@@ -1,102 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
var ws = null;
|
|
16
|
+
var isOpen = false;
|
|
17
|
+
var uuid = 0;
|
|
22
18
|
function connect() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
ws?.
|
|
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
|
-
|
|
49
|
-
|
|
48
|
+
const msg = { type, meta, payload };
|
|
49
|
+
ws?.send(JSON.stringify(msg));
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
};
|
package/lib/client/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
// src/client/index.ts
|
|
2
|
+
export * from "../shared/index.js";
|
package/lib/client/options.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { MarkdownPowerPluginOptions } from '../shared/index.js';
|
|
2
|
+
|
|
3
|
+
declare const pluginOptions: MarkdownPowerPluginOptions;
|
|
4
|
+
|
|
5
|
+
export { pluginOptions };
|
package/lib/client/options.js
CHANGED
package/lib/client/utils/http.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
};
|
package/lib/client/utils/is.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 };
|
package/lib/client/utils/is.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/client/utils/is.ts
|
|
2
|
+
function checkIsMobile(ua) {
|
|
3
|
+
return /\b(?:Android|iPhone)/i.test(ua);
|
|
3
4
|
}
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
function checkIsSafari(ua) {
|
|
6
|
+
return /version\/[\w.]+ .*(?:mobile ?safari|safari)/i.test(ua);
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
};
|
package/lib/client/utils/link.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
};
|