vuepress-plugin-md-power 1.0.0-rc.146 → 1.0.0-rc.148
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/VPCodeTree.vue +16 -0
- package/lib/client/composables/audio.d.ts +35 -35
- package/lib/client/composables/audio.js +169 -181
- package/lib/client/composables/codeRepl.d.ts +20 -17
- package/lib/client/composables/codeRepl.js +146 -252
- package/lib/client/composables/demo.d.ts +34 -41
- package/lib/client/composables/demo.js +108 -102
- package/lib/client/composables/pdf.d.ts +4 -15
- package/lib/client/composables/pdf.js +46 -51
- package/lib/client/composables/rustRepl-iGLjb94D.js +101 -0
- package/lib/client/composables/rustRepl.d.ts +15 -7
- package/lib/client/composables/rustRepl.js +3 -104
- package/lib/client/composables/size.d.ts +11 -21
- package/lib/client/composables/size.js +35 -32
- package/lib/client/index.d.ts +1 -1
- package/lib/client/index.js +1 -2
- package/lib/client/options.d.ts +8 -8
- package/lib/client/options.js +20 -29
- package/lib/client/utils/http.d.ts +5 -3
- package/lib/client/utils/http.js +19 -24
- package/lib/client/utils/link.d.ts +3 -1
- package/lib/client/utils/link.js +6 -5
- package/lib/client/utils/sleep.d.ts +3 -1
- package/lib/client/utils/sleep.js +7 -7
- package/lib/node/index.d.ts +405 -368
- package/lib/node/index.js +3777 -3779
- package/lib/shared/index.d.ts +395 -365
- package/package.json +10 -10
|
@@ -126,6 +126,13 @@ onMounted(() => {
|
|
|
126
126
|
border-bottom-left-radius: 0;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
@media (min-width: 768px) {
|
|
130
|
+
.vp-code-tree .code-tree-panel .vp-file-tree,
|
|
131
|
+
.vp-code-tree .code-panel [class*="language-"] {
|
|
132
|
+
overscroll-behavior: contain;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
129
136
|
.vp-code-tree .code-panel .code-block-title {
|
|
130
137
|
display: none;
|
|
131
138
|
height: 100%;
|
|
@@ -141,6 +148,15 @@ onMounted(() => {
|
|
|
141
148
|
border-radius: 0;
|
|
142
149
|
}
|
|
143
150
|
|
|
151
|
+
.vp-code-tree .code-panel div[class*="language-"].has-collapsed-lines.collapsed {
|
|
152
|
+
height: auto;
|
|
153
|
+
overflow: auto;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.vp-code-tree .code-panel div[class*="language-"].has-collapsed-lines .collapsed-lines {
|
|
157
|
+
display: none;
|
|
158
|
+
}
|
|
159
|
+
|
|
144
160
|
.vp-code-tree .code-panel .code-tree-empty {
|
|
145
161
|
display: flex;
|
|
146
162
|
align-items: center;
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MaybeRef } from 'vue';
|
|
1
|
+
import { MaybeRef, Ref } from "vue";
|
|
3
2
|
|
|
3
|
+
//#region src/client/composables/audio.d.ts
|
|
4
4
|
interface BufferedRange {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
7
|
}
|
|
8
8
|
interface AudioPlayerOptions {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
type?: MaybeRef<string>;
|
|
10
|
+
autoplay?: boolean;
|
|
11
|
+
mutex?: boolean;
|
|
12
|
+
onload?: HTMLAudioElement["onload"];
|
|
13
|
+
onerror?: HTMLAudioElement["onerror"];
|
|
14
|
+
onpause?: HTMLAudioElement["onpause"];
|
|
15
|
+
onplay?: HTMLAudioElement["onplay"];
|
|
16
|
+
onplaying?: HTMLAudioElement["onplaying"];
|
|
17
|
+
onseeked?: HTMLAudioElement["onseeked"];
|
|
18
|
+
onvolume?: (volume: number) => void;
|
|
19
|
+
onend?: HTMLAudioElement["onended"];
|
|
20
|
+
onprogress?: (current: number, total: number) => void;
|
|
21
|
+
oncanplay?: HTMLAudioElement["oncanplay"];
|
|
22
|
+
oncanplaythrough?: HTMLAudioElement["oncanplaythrough"];
|
|
23
|
+
ontimeupdate?: (currentTime: number) => void;
|
|
24
|
+
onwaiting?: HTMLAudioElement["onwaiting"];
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export {
|
|
26
|
+
interface UseAudioPlayerResult {
|
|
27
|
+
player: HTMLAudioElement | null;
|
|
28
|
+
isSupported: Ref<boolean>;
|
|
29
|
+
loaded: Ref<boolean>;
|
|
30
|
+
paused: Ref<boolean>;
|
|
31
|
+
currentTime: Ref<number>;
|
|
32
|
+
duration: Ref<number>;
|
|
33
|
+
play: () => void;
|
|
34
|
+
pause: () => void;
|
|
35
|
+
seek: (time: number) => void;
|
|
36
|
+
setVolume: (volume: number) => void;
|
|
37
|
+
destroy: () => void;
|
|
38
|
+
}
|
|
39
|
+
declare function useAudioPlayer(source: MaybeRef<string>, options?: AudioPlayerOptions): UseAudioPlayerResult; //#endregion
|
|
40
|
+
export { AudioPlayerOptions, BufferedRange, useAudioPlayer };
|
|
@@ -1,185 +1,173 @@
|
|
|
1
|
-
// src/client/composables/audio.ts
|
|
2
1
|
import { onMounted, onUnmounted, ref, toValue, watch } from "vue";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
|
|
3
|
+
//#region src/client/composables/audio.ts
|
|
4
|
+
const mimeTypes = {
|
|
5
|
+
"audio/flac": ["flac", "fla"],
|
|
6
|
+
"audio/mpeg": ["mp3", "mpga"],
|
|
7
|
+
"audio/mp4": ["mp4", "m4a"],
|
|
8
|
+
"audio/ogg": ["ogg", "oga"],
|
|
9
|
+
"audio/aac": ["aac", "adts"],
|
|
10
|
+
"audio/x-ms-wma": ["wma"],
|
|
11
|
+
"audio/x-aiff": [
|
|
12
|
+
"aiff",
|
|
13
|
+
"aif",
|
|
14
|
+
"aifc"
|
|
15
|
+
],
|
|
16
|
+
"audio/webm": ["webm"]
|
|
12
17
|
};
|
|
13
|
-
|
|
18
|
+
const playerList = [];
|
|
14
19
|
function useAudioPlayer(source, options = {}) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
for (const p of playerList) {
|
|
166
|
-
if (p !== player)
|
|
167
|
-
p.pause();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
player?.play();
|
|
171
|
-
},
|
|
172
|
-
pause: () => player?.pause(),
|
|
173
|
-
seek(time) {
|
|
174
|
-
if (player)
|
|
175
|
-
player.currentTime = time;
|
|
176
|
-
},
|
|
177
|
-
setVolume(volume2) {
|
|
178
|
-
if (player)
|
|
179
|
-
player.volume = Math.min(1, Math.max(0, volume2));
|
|
180
|
-
}
|
|
181
|
-
};
|
|
20
|
+
let player = null;
|
|
21
|
+
let unknownSupport = false;
|
|
22
|
+
const isSupported = ref(false);
|
|
23
|
+
const loaded = ref(false);
|
|
24
|
+
const paused = ref(true);
|
|
25
|
+
const currentTime = ref(0);
|
|
26
|
+
const duration = ref(0);
|
|
27
|
+
const volume = ref(1);
|
|
28
|
+
function initialize() {
|
|
29
|
+
player = document.createElement("audio");
|
|
30
|
+
player.className = "audio-player";
|
|
31
|
+
player.style.display = "none";
|
|
32
|
+
player.preload = options.autoplay ? "auto" : "none";
|
|
33
|
+
player.autoplay = options.autoplay ?? false;
|
|
34
|
+
document.body.appendChild(player);
|
|
35
|
+
playerList.push(player);
|
|
36
|
+
player.onloadedmetadata = () => {
|
|
37
|
+
duration.value = player.duration;
|
|
38
|
+
currentTime.value = player.currentTime;
|
|
39
|
+
volume.value = player.volume;
|
|
40
|
+
loaded.value = true;
|
|
41
|
+
};
|
|
42
|
+
player.oncanplay = (...args) => {
|
|
43
|
+
loaded.value = true;
|
|
44
|
+
if (unknownSupport) isSupported.value = true;
|
|
45
|
+
options.oncanplay?.bind(player)(...args);
|
|
46
|
+
};
|
|
47
|
+
player.onplay = (...args) => {
|
|
48
|
+
paused.value = false;
|
|
49
|
+
options.onplay?.bind(player)(...args);
|
|
50
|
+
};
|
|
51
|
+
player.onpause = (...args) => {
|
|
52
|
+
paused.value = true;
|
|
53
|
+
options.onpause?.bind(player)(...args);
|
|
54
|
+
};
|
|
55
|
+
player.ontimeupdate = () => {
|
|
56
|
+
if (isValidDuration(player.duration)) {
|
|
57
|
+
const lastBufferTime = getLastBufferedTime();
|
|
58
|
+
if (lastBufferTime <= player.duration) {
|
|
59
|
+
options.ontimeupdate?.bind(player)(lastBufferTime);
|
|
60
|
+
currentTime.value = lastBufferTime;
|
|
61
|
+
options.onprogress?.bind(player)(lastBufferTime, player.duration);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
player.onvolumechange = () => {
|
|
66
|
+
volume.value = player.volume;
|
|
67
|
+
options.onvolume?.bind(player)(player.volume);
|
|
68
|
+
};
|
|
69
|
+
player.onended = (...args) => {
|
|
70
|
+
paused.value = true;
|
|
71
|
+
options.onend?.bind(player)(...args);
|
|
72
|
+
};
|
|
73
|
+
player.onplaying = options.onplaying;
|
|
74
|
+
player.onload = options.onload;
|
|
75
|
+
player.onerror = options.onerror;
|
|
76
|
+
player.onseeked = options.onseeked;
|
|
77
|
+
player.oncanplaythrough = options.oncanplaythrough;
|
|
78
|
+
player.onwaiting = options.onwaiting;
|
|
79
|
+
isSupported.value = isSupportType();
|
|
80
|
+
player.src = toValue(source);
|
|
81
|
+
player.load();
|
|
82
|
+
}
|
|
83
|
+
function isSupportType() {
|
|
84
|
+
if (!player) return false;
|
|
85
|
+
let type = toValue(options.type);
|
|
86
|
+
if (!type) {
|
|
87
|
+
const ext = toValue(source).split(".").pop() || "";
|
|
88
|
+
type = Object.keys(mimeTypes).filter((type$1) => mimeTypes[type$1].includes(ext))[0];
|
|
89
|
+
}
|
|
90
|
+
if (!type) {
|
|
91
|
+
unknownSupport = true;
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const isSupported$1 = player.canPlayType(type) !== "";
|
|
95
|
+
if (!isSupported$1) console.warn(`The specified type "${type}" is not supported by the browser.`);
|
|
96
|
+
return isSupported$1;
|
|
97
|
+
}
|
|
98
|
+
function getBufferedRanges() {
|
|
99
|
+
if (!player) return [];
|
|
100
|
+
const ranges = [];
|
|
101
|
+
const seekable = player.buffered || [];
|
|
102
|
+
const offset = 0;
|
|
103
|
+
for (let i = 0, length = seekable.length; i < length; i++) {
|
|
104
|
+
let start = seekable.start(i);
|
|
105
|
+
let end = seekable.end(i);
|
|
106
|
+
if (!isValidDuration(start)) start = 0;
|
|
107
|
+
if (!isValidDuration(end)) {
|
|
108
|
+
end = 0;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
ranges.push({
|
|
112
|
+
start: start + offset,
|
|
113
|
+
end: end + offset
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return ranges;
|
|
117
|
+
}
|
|
118
|
+
function getLastBufferedTime() {
|
|
119
|
+
const bufferedRanges = getBufferedRanges();
|
|
120
|
+
if (!bufferedRanges.length) return 0;
|
|
121
|
+
const buff = bufferedRanges.find((buff$1) => buff$1.start < player.currentTime && buff$1.end > player.currentTime);
|
|
122
|
+
if (buff) return buff.end;
|
|
123
|
+
const last = bufferedRanges[bufferedRanges.length - 1];
|
|
124
|
+
return last.end;
|
|
125
|
+
}
|
|
126
|
+
function isValidDuration(duration$1) {
|
|
127
|
+
if (duration$1 && !Number.isNaN(duration$1) && duration$1 !== Number.POSITIVE_INFINITY && duration$1 !== Number.NEGATIVE_INFINITY) return true;
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
function destroy() {
|
|
131
|
+
player?.pause();
|
|
132
|
+
player?.remove();
|
|
133
|
+
playerList.splice(playerList.indexOf(player), 1);
|
|
134
|
+
player = null;
|
|
135
|
+
}
|
|
136
|
+
onMounted(() => {
|
|
137
|
+
initialize();
|
|
138
|
+
watch([source, options.type], () => {
|
|
139
|
+
destroy();
|
|
140
|
+
loaded.value = false;
|
|
141
|
+
paused.value = true;
|
|
142
|
+
currentTime.value = 0;
|
|
143
|
+
duration.value = 0;
|
|
144
|
+
initialize();
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
onUnmounted(() => destroy());
|
|
148
|
+
return {
|
|
149
|
+
isSupported,
|
|
150
|
+
paused,
|
|
151
|
+
loaded,
|
|
152
|
+
currentTime,
|
|
153
|
+
duration,
|
|
154
|
+
player,
|
|
155
|
+
destroy,
|
|
156
|
+
play: () => {
|
|
157
|
+
if (options.mutex ?? true) {
|
|
158
|
+
for (const p of playerList) if (p !== player) p.pause();
|
|
159
|
+
}
|
|
160
|
+
player?.play();
|
|
161
|
+
},
|
|
162
|
+
pause: () => player?.pause(),
|
|
163
|
+
seek(time) {
|
|
164
|
+
if (player) player.currentTime = time;
|
|
165
|
+
},
|
|
166
|
+
setVolume(volume$1) {
|
|
167
|
+
if (player) player.volume = Math.min(1, Math.max(0, volume$1));
|
|
168
|
+
}
|
|
169
|
+
};
|
|
182
170
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
};
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
export { useAudioPlayer };
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import { Ref } from
|
|
1
|
+
import { Ref } from "vue";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region src/client/composables/codeRepl.d.ts
|
|
4
|
+
type Lang = "kotlin" | "go" | "rust";
|
|
4
5
|
declare function resolveCode(el: HTMLElement): string;
|
|
5
6
|
declare function resolveCodeInfo(el: HTMLDivElement): {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
declare function useCodeRepl(el: Ref<HTMLDivElement | null>): {
|
|
10
|
-
onRunCode: () => Promise<void>;
|
|
11
|
-
onCleanRun: () => void;
|
|
12
|
-
lang: Ref<Lang | undefined, Lang | undefined>;
|
|
13
|
-
backendVersion: Ref<string, string>;
|
|
14
|
-
firstRun: Ref<boolean, boolean>;
|
|
15
|
-
stderr: Ref<string[], string[]>;
|
|
16
|
-
stdout: Ref<string[], string[]>;
|
|
17
|
-
loaded: Ref<boolean, boolean>;
|
|
18
|
-
finished: Ref<boolean, boolean>;
|
|
19
|
-
error: Ref<string, string>;
|
|
7
|
+
lang: Lang;
|
|
8
|
+
code: string;
|
|
20
9
|
};
|
|
10
|
+
interface UseCodeReplResult {
|
|
11
|
+
lang: Ref<Lang | undefined>;
|
|
12
|
+
loaded: Ref<boolean>;
|
|
13
|
+
firstRun: Ref<boolean>;
|
|
14
|
+
finished: Ref<boolean>;
|
|
15
|
+
stdout: Ref<string[]>;
|
|
16
|
+
stderr: Ref<string[]>;
|
|
17
|
+
error: Ref<string>;
|
|
18
|
+
backendVersion: Ref<string>;
|
|
19
|
+
onCleanRun: () => void;
|
|
20
|
+
onRunCode: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
declare function useCodeRepl(el: Ref<HTMLDivElement | null>): UseCodeReplResult;
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
//#endregion
|
|
25
|
+
export { resolveCode, resolveCodeInfo, useCodeRepl };
|