vuepress-plugin-md-power 1.0.0-rc.146 → 1.0.0-rc.147

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.
@@ -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 * as vue from 'vue';
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
- start: number;
6
- end: number;
5
+ start: number;
6
+ end: number;
7
7
  }
8
8
  interface AudioPlayerOptions {
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'];
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
- declare function useAudioPlayer(source: MaybeRef<string>, options?: AudioPlayerOptions): {
27
- isSupported: vue.Ref<boolean, boolean>;
28
- paused: vue.Ref<boolean, boolean>;
29
- loaded: vue.Ref<boolean, boolean>;
30
- currentTime: vue.Ref<number, number>;
31
- duration: vue.Ref<number, number>;
32
- player: null;
33
- destroy: () => void;
34
- play: () => void;
35
- pause: () => void | undefined;
36
- seek(time: number): void;
37
- setVolume(volume: number): void;
38
- };
39
-
40
- export { type AudioPlayerOptions, type BufferedRange, useAudioPlayer };
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
- var mimeTypes = {
4
- "audio/flac": ["flac", "fla"],
5
- "audio/mpeg": ["mp3", "mpga"],
6
- "audio/mp4": ["mp4", "m4a"],
7
- "audio/ogg": ["ogg", "oga"],
8
- "audio/aac": ["aac", "adts"],
9
- "audio/x-ms-wma": ["wma"],
10
- "audio/x-aiff": ["aiff", "aif", "aifc"],
11
- "audio/webm": ["webm"]
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
- var playerList = [];
18
+ const playerList = [];
14
19
  function useAudioPlayer(source, options = {}) {
15
- let player = null;
16
- let unknownSupport = false;
17
- const isSupported = ref(false);
18
- const loaded = ref(false);
19
- const paused = ref(true);
20
- const currentTime = ref(0);
21
- const duration = ref(0);
22
- const volume = ref(1);
23
- function initialize() {
24
- player = document.createElement("audio");
25
- player.className = "audio-player";
26
- player.style.display = "none";
27
- player.preload = options.autoplay ? "auto" : "none";
28
- player.autoplay = options.autoplay ?? false;
29
- document.body.appendChild(player);
30
- playerList.push(player);
31
- player.onloadedmetadata = () => {
32
- duration.value = player.duration;
33
- currentTime.value = player.currentTime;
34
- volume.value = player.volume;
35
- loaded.value = true;
36
- };
37
- player.oncanplay = (...args) => {
38
- loaded.value = true;
39
- if (unknownSupport)
40
- isSupported.value = true;
41
- options.oncanplay?.bind(player)(...args);
42
- };
43
- player.onplay = (...args) => {
44
- paused.value = false;
45
- options.onplay?.bind(player)(...args);
46
- };
47
- player.onpause = (...args) => {
48
- paused.value = true;
49
- options.onpause?.bind(player)(...args);
50
- };
51
- player.ontimeupdate = () => {
52
- if (isValidDuration(player.duration)) {
53
- const lastBufferTime = getLastBufferedTime();
54
- if (lastBufferTime <= player.duration) {
55
- options.ontimeupdate?.bind(player)(lastBufferTime);
56
- currentTime.value = lastBufferTime;
57
- options.onprogress?.bind(player)(lastBufferTime, player.duration);
58
- }
59
- }
60
- };
61
- player.onvolumechange = () => {
62
- volume.value = player.volume;
63
- options.onvolume?.bind(player)(player.volume);
64
- };
65
- player.onended = (...args) => {
66
- paused.value = true;
67
- options.onend?.bind(player)(...args);
68
- };
69
- player.onplaying = options.onplaying;
70
- player.onload = options.onload;
71
- player.onerror = options.onerror;
72
- player.onseeked = options.onseeked;
73
- player.oncanplaythrough = options.oncanplaythrough;
74
- player.onwaiting = options.onwaiting;
75
- isSupported.value = isSupportType();
76
- player.src = toValue(source);
77
- player.load();
78
- }
79
- function isSupportType() {
80
- if (!player)
81
- return false;
82
- let type = toValue(options.type);
83
- if (!type) {
84
- const ext = toValue(source).split(".").pop() || "";
85
- type = Object.keys(mimeTypes).filter((type2) => mimeTypes[type2].includes(ext))[0];
86
- }
87
- if (!type) {
88
- unknownSupport = true;
89
- return false;
90
- }
91
- const isSupported2 = player.canPlayType(type) !== "";
92
- if (!isSupported2) {
93
- console.warn(`The specified type "${type}" is not supported by the browser.`);
94
- }
95
- return isSupported2;
96
- }
97
- function getBufferedRanges() {
98
- if (!player)
99
- 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))
107
- start = 0;
108
- if (!isValidDuration(end)) {
109
- end = 0;
110
- continue;
111
- }
112
- ranges.push({
113
- start: start + offset,
114
- end: end + offset
115
- });
116
- }
117
- return ranges;
118
- }
119
- function getLastBufferedTime() {
120
- const bufferedRanges = getBufferedRanges();
121
- if (!bufferedRanges.length)
122
- return 0;
123
- const buff = bufferedRanges.find(
124
- (buff2) => buff2.start < player.currentTime && buff2.end > player.currentTime
125
- );
126
- if (buff)
127
- return buff.end;
128
- const last = bufferedRanges[bufferedRanges.length - 1];
129
- return last.end;
130
- }
131
- function isValidDuration(duration2) {
132
- if (duration2 && !Number.isNaN(duration2) && duration2 !== Number.POSITIVE_INFINITY && duration2 !== Number.NEGATIVE_INFINITY) {
133
- return true;
134
- }
135
- return false;
136
- }
137
- function destroy() {
138
- player?.pause();
139
- player?.remove();
140
- playerList.splice(playerList.indexOf(player), 1);
141
- player = null;
142
- }
143
- onMounted(() => {
144
- initialize();
145
- watch([source, options.type], () => {
146
- destroy();
147
- loaded.value = false;
148
- paused.value = true;
149
- currentTime.value = 0;
150
- duration.value = 0;
151
- initialize();
152
- });
153
- });
154
- onUnmounted(() => destroy());
155
- return {
156
- isSupported,
157
- paused,
158
- loaded,
159
- currentTime,
160
- duration,
161
- player,
162
- destroy,
163
- play: () => {
164
- if (options.mutex ?? true) {
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
- export {
184
- useAudioPlayer
185
- };
171
+
172
+ //#endregion
173
+ export { useAudioPlayer };
@@ -1,22 +1,25 @@
1
- import { Ref } from 'vue';
1
+ import { Ref } from "vue";
2
2
 
3
- type Lang = 'kotlin' | 'go' | 'rust';
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
- lang: Lang;
7
- code: string;
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
- export { resolveCode, resolveCodeInfo, useCodeRepl };
24
+ //#endregion
25
+ export { resolveCode, resolveCodeInfo, useCodeRepl };