vuepress-plugin-md-power 1.0.0-rc.129 → 1.0.0-rc.131
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/VPDemoBasic.vue +2 -5
- package/lib/client/components/VPDemoNormal.vue +28 -109
- package/lib/client/composables/demo.d.ts +48 -0
- package/lib/client/composables/demo.js +140 -0
- package/lib/client/styles/demo.css +7 -0
- package/lib/node/index.js +6 -4
- package/package.json +13 -13
- package/lib/client/utils/shared.d.ts +0 -4
- package/lib/client/utils/shared.js +0 -36
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { useExpand } from '../composables/demo.js'
|
|
3
3
|
|
|
4
4
|
import '../styles/demo.css'
|
|
5
5
|
|
|
@@ -10,10 +10,7 @@ const props = defineProps<{
|
|
|
10
10
|
expanded?: boolean
|
|
11
11
|
}>()
|
|
12
12
|
|
|
13
|
-
const showCode =
|
|
14
|
-
function toggleCode() {
|
|
15
|
-
showCode.value = !showCode.value
|
|
16
|
-
}
|
|
13
|
+
const [showCode, toggleCode] = useExpand(props.expanded)
|
|
17
14
|
</script>
|
|
18
15
|
|
|
19
16
|
<template>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import Loading from './icons/Loading.vue'
|
|
2
|
+
import type { DemoConfig } from '../composables/demo.js'
|
|
3
|
+
import { useTemplateRef } from 'vue'
|
|
4
|
+
import { useExpand, useFence, useNormalDemo, useResources } from '../composables/demo.js'
|
|
6
5
|
|
|
7
6
|
import '../styles/demo.css'
|
|
8
7
|
|
|
@@ -10,121 +9,41 @@ const props = defineProps<{
|
|
|
10
9
|
title?: string
|
|
11
10
|
desc?: string
|
|
12
11
|
expanded?: boolean
|
|
13
|
-
config?:
|
|
14
|
-
html: string
|
|
15
|
-
css: string
|
|
16
|
-
script: string
|
|
17
|
-
jsLib: string[]
|
|
18
|
-
cssLib: string[]
|
|
19
|
-
}
|
|
12
|
+
config?: DemoConfig
|
|
20
13
|
}>()
|
|
21
14
|
|
|
22
|
-
const
|
|
23
|
-
const id = useId()
|
|
24
|
-
const loaded = ref(true)
|
|
15
|
+
const [showCode, toggleCode] = useExpand(props.expanded)
|
|
25
16
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}[]>(() => {
|
|
31
|
-
if (!props.config)
|
|
32
|
-
return []
|
|
33
|
-
return [
|
|
34
|
-
{ name: 'JavaScript', items: props.config.jsLib.map(url => ({ name: normalizeName(url), url })) },
|
|
35
|
-
{ name: 'CSS', items: props.config.cssLib.map(url => ({ name: normalizeName(url), url })) },
|
|
36
|
-
].filter(i => i.items.length)
|
|
37
|
-
})
|
|
17
|
+
const { resources, showResources, toggleResources } = useResources(
|
|
18
|
+
useTemplateRef<HTMLDivElement>('resourcesEl'),
|
|
19
|
+
() => props.config,
|
|
20
|
+
)
|
|
38
21
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
const { id, height } = useNormalDemo(
|
|
23
|
+
useTemplateRef<HTMLIFrameElement>('draw'),
|
|
24
|
+
() => props.title,
|
|
25
|
+
() => props.config,
|
|
26
|
+
)
|
|
42
27
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
onClickOutside(resourcesEl, () => {
|
|
50
|
-
showResources.value = false
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
onMounted(() => {
|
|
54
|
-
if (!draw.value)
|
|
55
|
-
return
|
|
56
|
-
const root = draw.value.attachShadow({ mode: 'open' })
|
|
57
|
-
|
|
58
|
-
watch(() => props.config, async () => {
|
|
59
|
-
root.innerHTML = props.config?.html ?? ''
|
|
60
|
-
|
|
61
|
-
props.config?.cssLib?.forEach(url => loadStyle(url, root))
|
|
62
|
-
if (props.config?.css) {
|
|
63
|
-
const style = document.createElement('style')
|
|
64
|
-
style.innerHTML = props.config?.css ?? ''
|
|
65
|
-
root.appendChild(style)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (props.config?.jsLib?.length) {
|
|
69
|
-
loaded.value = false
|
|
70
|
-
await Promise.all(props.config.jsLib.map(url => loadScript(url)))
|
|
71
|
-
.catch(e => console.warn(e))
|
|
72
|
-
loaded.value = true
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (props.config?.script) {
|
|
76
|
-
const script = document.createElement('script')
|
|
77
|
-
script.type = 'text/javascript'
|
|
78
|
-
script.innerHTML = `;(function(document){\n${props.config.script}\n})(document.querySelector('#VPDemoNormalDraw${id}').shadowRoot);`
|
|
79
|
-
root.appendChild(script)
|
|
80
|
-
}
|
|
81
|
-
}, { immediate: true })
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
const fence = useTemplateRef<HTMLDivElement>('fence')
|
|
85
|
-
const data = ref<{
|
|
86
|
-
js: string
|
|
87
|
-
css: string
|
|
88
|
-
html: string
|
|
89
|
-
jsType: string
|
|
90
|
-
cssType: string
|
|
91
|
-
}>({ js: '', css: '', html: '', jsType: '', cssType: '' })
|
|
92
|
-
|
|
93
|
-
onMounted(() => {
|
|
94
|
-
if (!fence.value)
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
data.value.html = props.config?.html ?? ''
|
|
98
|
-
const els = Array.from(fence.value.querySelectorAll('div[class*="language-"]'))
|
|
99
|
-
for (const el of els) {
|
|
100
|
-
const lang = el.className.match(/language-(\w+)/)?.[1] ?? ''
|
|
101
|
-
const content = el.querySelector('pre')?.textContent ?? ''
|
|
102
|
-
if (lang === 'js' || lang === 'javascript') {
|
|
103
|
-
data.value.js = content
|
|
104
|
-
data.value.jsType = 'js'
|
|
105
|
-
}
|
|
106
|
-
if (lang === 'ts' || lang === 'typescript') {
|
|
107
|
-
data.value.js = content
|
|
108
|
-
data.value.jsType = 'ts'
|
|
109
|
-
}
|
|
110
|
-
if (lang === 'css' || lang === 'scss' || lang === 'less' || lang === 'stylus' || lang === 'styl') {
|
|
111
|
-
data.value.css = content
|
|
112
|
-
data.value.cssType = lang === 'styl' ? 'stylus' : lang
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
const showCode = ref(props.expanded ?? false)
|
|
118
|
-
function toggleCode() {
|
|
119
|
-
showCode.value = !showCode.value
|
|
120
|
-
}
|
|
28
|
+
const data = useFence(
|
|
29
|
+
useTemplateRef<HTMLDivElement>('fence'),
|
|
30
|
+
() => props.config,
|
|
31
|
+
)
|
|
121
32
|
</script>
|
|
122
33
|
|
|
123
34
|
<template>
|
|
124
35
|
<div class="vp-demo-wrapper normal">
|
|
125
36
|
<div class="demo-draw">
|
|
126
|
-
<
|
|
127
|
-
|
|
37
|
+
<iframe
|
|
38
|
+
:id="`VPDemoNormalDraw${id}`"
|
|
39
|
+
ref="draw"
|
|
40
|
+
class="draw-iframe"
|
|
41
|
+
allow="accelerometer *; bluetooth *; camera *; encrypted-media *; display-capture *; geolocation *; gyroscope *; microphone *; midi *; clipboard-read *; clipboard-write *; web-share *; serial *; xr-spatial-tracking *"
|
|
42
|
+
allowfullscreen="true"
|
|
43
|
+
allowpaymentrequest="true"
|
|
44
|
+
allowtransparency="true"
|
|
45
|
+
sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups-to-escape-sandbox allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation" :style="{ height }"
|
|
46
|
+
/>
|
|
128
47
|
</div>
|
|
129
48
|
<div v-if="title || desc" class="demo-info">
|
|
130
49
|
<p v-if="title" class="title">
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { ShallowRef, MaybeRefOrGetter } from 'vue';
|
|
3
|
+
|
|
4
|
+
interface DemoConfig {
|
|
5
|
+
html: string;
|
|
6
|
+
css: string;
|
|
7
|
+
script: string;
|
|
8
|
+
jsLib: string[];
|
|
9
|
+
cssLib: string[];
|
|
10
|
+
}
|
|
11
|
+
declare function useExpand(defaultExpand?: boolean): readonly [vue.Ref<boolean, boolean>, () => void];
|
|
12
|
+
declare function useResources(el: ShallowRef<HTMLDivElement | null>, config: MaybeRefOrGetter<DemoConfig | undefined>): {
|
|
13
|
+
resources: vue.ComputedRef<{
|
|
14
|
+
name: string;
|
|
15
|
+
items: {
|
|
16
|
+
name: string;
|
|
17
|
+
url: string;
|
|
18
|
+
}[];
|
|
19
|
+
}[]>;
|
|
20
|
+
showResources: vue.Ref<boolean, boolean>;
|
|
21
|
+
toggleResources: () => void;
|
|
22
|
+
};
|
|
23
|
+
declare function useFence(fence: ShallowRef<HTMLDivElement | null>, config: MaybeRefOrGetter<DemoConfig | undefined>): vue.Ref<{
|
|
24
|
+
js: string;
|
|
25
|
+
css: string;
|
|
26
|
+
html: string;
|
|
27
|
+
jsType: string;
|
|
28
|
+
cssType: string;
|
|
29
|
+
}, {
|
|
30
|
+
js: string;
|
|
31
|
+
css: string;
|
|
32
|
+
html: string;
|
|
33
|
+
jsType: string;
|
|
34
|
+
cssType: string;
|
|
35
|
+
} | {
|
|
36
|
+
js: string;
|
|
37
|
+
css: string;
|
|
38
|
+
html: string;
|
|
39
|
+
jsType: string;
|
|
40
|
+
cssType: string;
|
|
41
|
+
}>;
|
|
42
|
+
declare function useNormalDemo(draw: ShallowRef<HTMLIFrameElement | null>, title: MaybeRefOrGetter<string | undefined>, config: MaybeRefOrGetter<DemoConfig | undefined>): {
|
|
43
|
+
id: string;
|
|
44
|
+
height: vue.Ref<string, string>;
|
|
45
|
+
};
|
|
46
|
+
declare function parseData(data: any): any;
|
|
47
|
+
|
|
48
|
+
export { type DemoConfig, parseData, useExpand, useFence, useNormalDemo, useResources };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// src/client/composables/demo.ts
|
|
2
|
+
import { onClickOutside, useEventListener } from "@vueuse/core";
|
|
3
|
+
import { computed, getCurrentInstance, onMounted, ref, toValue, useId, watch } from "vue";
|
|
4
|
+
import { isPlainObject } from "vuepress/shared";
|
|
5
|
+
function useExpand(defaultExpand = true) {
|
|
6
|
+
const expanded = ref(defaultExpand);
|
|
7
|
+
function toggle() {
|
|
8
|
+
expanded.value = !expanded.value;
|
|
9
|
+
}
|
|
10
|
+
return [expanded, toggle];
|
|
11
|
+
}
|
|
12
|
+
function useResources(el, config) {
|
|
13
|
+
const resources = computed(() => {
|
|
14
|
+
const conf = toValue(config);
|
|
15
|
+
if (!conf)
|
|
16
|
+
return [];
|
|
17
|
+
return [
|
|
18
|
+
{ name: "JavaScript", items: conf.jsLib.map((url) => ({ name: normalizeName(url), url })) },
|
|
19
|
+
{ name: "CSS", items: conf.cssLib.map((url) => ({ name: normalizeName(url), url })) }
|
|
20
|
+
].filter((i) => i.items.length);
|
|
21
|
+
});
|
|
22
|
+
function normalizeName(url) {
|
|
23
|
+
return url.slice(url.lastIndexOf("/") + 1);
|
|
24
|
+
}
|
|
25
|
+
const showResources = ref(false);
|
|
26
|
+
function toggleResources() {
|
|
27
|
+
showResources.value = !showResources.value;
|
|
28
|
+
}
|
|
29
|
+
onClickOutside(el, () => {
|
|
30
|
+
showResources.value = false;
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
resources,
|
|
34
|
+
showResources,
|
|
35
|
+
toggleResources
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function useFence(fence, config) {
|
|
39
|
+
const data = ref({ js: "", css: "", html: "", jsType: "", cssType: "" });
|
|
40
|
+
onMounted(() => {
|
|
41
|
+
if (!fence.value)
|
|
42
|
+
return;
|
|
43
|
+
const conf = toValue(config);
|
|
44
|
+
data.value.html = conf?.html ?? "";
|
|
45
|
+
const els = Array.from(fence.value.querySelectorAll('div[class*="language-"]'));
|
|
46
|
+
for (const el of els) {
|
|
47
|
+
const lang = el.className.match(/language-(\w+)/)?.[1] ?? "";
|
|
48
|
+
const content = el.querySelector("pre")?.textContent ?? "";
|
|
49
|
+
if (lang === "js" || lang === "javascript") {
|
|
50
|
+
data.value.js = content;
|
|
51
|
+
data.value.jsType = "js";
|
|
52
|
+
}
|
|
53
|
+
if (lang === "ts" || lang === "typescript") {
|
|
54
|
+
data.value.js = content;
|
|
55
|
+
data.value.jsType = "ts";
|
|
56
|
+
}
|
|
57
|
+
if (lang === "css" || lang === "scss" || lang === "less" || lang === "stylus" || lang === "styl") {
|
|
58
|
+
data.value.css = content;
|
|
59
|
+
data.value.cssType = lang === "styl" ? "stylus" : lang;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return data;
|
|
64
|
+
}
|
|
65
|
+
function useNormalDemo(draw, title, config) {
|
|
66
|
+
const current = getCurrentInstance();
|
|
67
|
+
const id = useId();
|
|
68
|
+
const isDark = computed(() => current?.appContext.config.globalProperties.$isDark.value);
|
|
69
|
+
const height = ref("100px");
|
|
70
|
+
onMounted(() => {
|
|
71
|
+
if (!draw.value)
|
|
72
|
+
return;
|
|
73
|
+
const iframeDoc = draw.value.contentDocument || draw.value.contentWindow?.document;
|
|
74
|
+
if (!iframeDoc)
|
|
75
|
+
return;
|
|
76
|
+
const templateId = `VPDemoNormalDraw${id}`;
|
|
77
|
+
useEventListener("message", (event) => {
|
|
78
|
+
const data = parseData(event.data);
|
|
79
|
+
if (data.type === templateId) {
|
|
80
|
+
height.value = `${data.height + 5}px`;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
watch([config, title], () => {
|
|
84
|
+
iframeDoc.write(createHTMLTemplate(toValue(title) || "Demo", templateId, toValue(config)));
|
|
85
|
+
}, { immediate: true });
|
|
86
|
+
watch(isDark, () => {
|
|
87
|
+
iframeDoc.documentElement.dataset.theme = isDark.value ? "dark" : "light";
|
|
88
|
+
}, { immediate: true });
|
|
89
|
+
});
|
|
90
|
+
return { id, height };
|
|
91
|
+
}
|
|
92
|
+
function createHTMLTemplate(title, id, config) {
|
|
93
|
+
const { cssLib = [], jsLib = [], html, css, script } = config || {};
|
|
94
|
+
const stylesheet = cssLib.map((url) => `<link rel="stylesheet" href="${url}">`).join("");
|
|
95
|
+
const scripts = jsLib.map((url) => `<script src="${url}"></script>`).join("");
|
|
96
|
+
return `<!DOCTYPE html>
|
|
97
|
+
<html>
|
|
98
|
+
<head>
|
|
99
|
+
<meta charset="utf-8">
|
|
100
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
101
|
+
<title>${title}</title>
|
|
102
|
+
${stylesheet}${scripts}
|
|
103
|
+
<style>${css}</style>
|
|
104
|
+
</head>
|
|
105
|
+
<body>
|
|
106
|
+
${html}
|
|
107
|
+
<script>;(function(){${script}})();</script>
|
|
108
|
+
<script>;(function(){
|
|
109
|
+
const height = Math.ceil(document.documentElement.getBoundingClientRect().height)
|
|
110
|
+
window.parent?.postMessage({ type: '${id}', height }, '*')
|
|
111
|
+
if (typeof window.ResizeObserver === 'undefined')
|
|
112
|
+
return
|
|
113
|
+
const resizeObserver = new ResizeObserver(entries => {
|
|
114
|
+
const height = Math.ceil(document.documentElement.getBoundingClientRect().height)
|
|
115
|
+
window.parent?.postMessage({ type: '${id}', height }, '*')
|
|
116
|
+
})
|
|
117
|
+
resizeObserver.observe(document.documentElement)
|
|
118
|
+
})();</script>
|
|
119
|
+
</body>
|
|
120
|
+
</html>`;
|
|
121
|
+
}
|
|
122
|
+
function parseData(data) {
|
|
123
|
+
try {
|
|
124
|
+
if (typeof data === "string") {
|
|
125
|
+
return JSON.parse(data);
|
|
126
|
+
} else if (isPlainObject(data)) {
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
return {};
|
|
130
|
+
} catch {
|
|
131
|
+
return {};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
parseData,
|
|
136
|
+
useExpand,
|
|
137
|
+
useFence,
|
|
138
|
+
useNormalDemo,
|
|
139
|
+
useResources
|
|
140
|
+
};
|
package/lib/node/index.js
CHANGED
|
@@ -2101,9 +2101,11 @@ function demoWatcher(app, watchers) {
|
|
|
2101
2101
|
delete tasks[path9];
|
|
2102
2102
|
watcher.unwatch(path9);
|
|
2103
2103
|
});
|
|
2104
|
-
watchers.push(
|
|
2105
|
-
|
|
2106
|
-
|
|
2104
|
+
watchers.push({
|
|
2105
|
+
close: () => {
|
|
2106
|
+
watcher.close();
|
|
2107
|
+
watcher = null;
|
|
2108
|
+
}
|
|
2107
2109
|
});
|
|
2108
2110
|
}
|
|
2109
2111
|
function addTask(app, path9, output) {
|
|
@@ -3254,7 +3256,7 @@ function markdownPowerPlugin(options = {}) {
|
|
|
3254
3256
|
addViteOptimizeDepsInclude(
|
|
3255
3257
|
bundlerOptions,
|
|
3256
3258
|
app,
|
|
3257
|
-
["artplayer", "dashjs", "hls.js", "mpegts.js"]
|
|
3259
|
+
["artplayer", "dashjs", "hls.js", "mpegts.js/dist/mpegts.js"]
|
|
3258
3260
|
);
|
|
3259
3261
|
}
|
|
3260
3262
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuepress-plugin-md-power",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.131",
|
|
5
5
|
"description": "The Plugin for VuePress 2 - markdown power",
|
|
6
6
|
"author": "pengzhanbo <volodymyr@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"artplayer": "^5.2.0",
|
|
35
35
|
"dashjs": "^4.7.4",
|
|
36
|
-
"esbuild": "
|
|
36
|
+
"esbuild": ">=0.24.2",
|
|
37
37
|
"hls.js": "^1.5.18",
|
|
38
38
|
"less": "^4.2.1",
|
|
39
39
|
"markdown-it": "^14.0.0",
|
|
40
|
-
"mpegts.js": "1.
|
|
40
|
+
"mpegts.js": "^1.8.0",
|
|
41
41
|
"sass": "^1.83.0",
|
|
42
42
|
"sass-embedded": "^1.83.0",
|
|
43
|
-
"stylus": "0.64.0",
|
|
43
|
+
"stylus": ">=0.64.0",
|
|
44
44
|
"vuepress": "2.0.0-rc.19"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@mdit/plugin-attrs": "^0.16.
|
|
64
|
+
"@mdit/plugin-attrs": "^0.16.7",
|
|
65
65
|
"@mdit/plugin-footnote": "^0.16.0",
|
|
66
66
|
"@mdit/plugin-mark": "^0.16.0",
|
|
67
67
|
"@mdit/plugin-sub": "^0.16.0",
|
|
@@ -69,24 +69,24 @@
|
|
|
69
69
|
"@mdit/plugin-tab": "^0.16.0",
|
|
70
70
|
"@mdit/plugin-tasklist": "^0.16.0",
|
|
71
71
|
"@vuepress/helper": "2.0.0-rc.73",
|
|
72
|
-
"@vueuse/core": "^12.
|
|
72
|
+
"@vueuse/core": "^12.7.0",
|
|
73
73
|
"chokidar": "3.6.0",
|
|
74
74
|
"image-size": "^1.2.0",
|
|
75
75
|
"local-pkg": "^1.0.0",
|
|
76
76
|
"lru-cache": "^11.0.2",
|
|
77
77
|
"markdown-it-container": "^4.0.0",
|
|
78
|
-
"nanoid": "^5.0
|
|
79
|
-
"shiki": "^2.
|
|
80
|
-
"tm-grammars": "^1.22.
|
|
81
|
-
"tm-themes": "^1.9.
|
|
78
|
+
"nanoid": "^5.1.0",
|
|
79
|
+
"shiki": "^2.4.1",
|
|
80
|
+
"tm-grammars": "^1.22.14",
|
|
81
|
+
"tm-themes": "^1.9.12",
|
|
82
82
|
"vue": "^3.5.13"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/markdown-it": "^14.1.2",
|
|
86
86
|
"artplayer": "^5.2.2",
|
|
87
|
-
"dashjs": "^
|
|
88
|
-
"hls.js": "^1.5.
|
|
89
|
-
"mpegts.js": "1.
|
|
87
|
+
"dashjs": "^5.0.0",
|
|
88
|
+
"hls.js": "^1.5.20",
|
|
89
|
+
"mpegts.js": "^1.8.0"
|
|
90
90
|
},
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// src/client/utils/shared.ts
|
|
2
|
-
var cache = {};
|
|
3
|
-
function loadScript(src) {
|
|
4
|
-
if (__VUEPRESS_SSR__)
|
|
5
|
-
return Promise.resolve();
|
|
6
|
-
if (document.querySelector(`script[src="${src}"]`)) {
|
|
7
|
-
if (cache[src])
|
|
8
|
-
return cache[src];
|
|
9
|
-
return Promise.resolve();
|
|
10
|
-
}
|
|
11
|
-
const script = document.createElement("script");
|
|
12
|
-
script.src = src;
|
|
13
|
-
document.body.appendChild(script);
|
|
14
|
-
cache[src] = new Promise((resolve, reject) => {
|
|
15
|
-
script.onload = () => {
|
|
16
|
-
resolve();
|
|
17
|
-
delete cache[src];
|
|
18
|
-
};
|
|
19
|
-
script.onerror = reject;
|
|
20
|
-
});
|
|
21
|
-
return cache[src];
|
|
22
|
-
}
|
|
23
|
-
function loadStyle(href, target) {
|
|
24
|
-
if (__VUEPRESS_SSR__)
|
|
25
|
-
return;
|
|
26
|
-
if (target.querySelector(`link[href="${href}"]`))
|
|
27
|
-
return;
|
|
28
|
-
const link = document.createElement("link");
|
|
29
|
-
link.rel = "stylesheet";
|
|
30
|
-
link.href = href;
|
|
31
|
-
target.appendChild(link);
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
34
|
-
loadScript,
|
|
35
|
-
loadStyle
|
|
36
|
-
};
|