vue-verovio-canvas 1.0.0
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/README.md +147 -0
- package/dist/style.css +1 -0
- package/dist/vue-verovio-canvas.js +548 -0
- package/dist/vue-verovio-canvas.umd.cjs +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# vue-verovio-canvas
|
|
2
|
+
|
|
3
|
+
A Vue 3 component to display music scores with [Verovio](https://www.verovio.org/index.xhtml).
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
| Prop | Default | Description |
|
|
8
|
+
|------------|------------|-------------------------------------------------------------------------------------------------------------|
|
|
9
|
+
| url | – | URL of the score file to display |
|
|
10
|
+
| data | – | String of the score to display when url prop is not set |
|
|
11
|
+
| scale | `40` | Scale of the output in percent (min: 1; max: 1000) and fallback value for `options.scale` |
|
|
12
|
+
| viewMode | `vertical` | `page`, `horizontal`, `vertical` |
|
|
13
|
+
| pageMargin | `0` | Change all page margins at once and fallback value when top, right, left or bottom page margins are not set |
|
|
14
|
+
| options | – | Pass options to verovio; Use `verovio -h` in the CLI to check all options and values |
|
|
15
|
+
| select | `{}` | Select a portion of a score; e.g. `{measureRange: '8-end'}`, `{start: 'measure-L337', end: 'measure-L355'}` |
|
|
16
|
+
| lazy | `false` | Lazy load verovio score when visible on screen |
|
|
17
|
+
|
|
18
|
+
## Info
|
|
19
|
+
|
|
20
|
+
If you want to display the whole score at once with the available width of the
|
|
21
|
+
parent container element and the hight of the score adjusted to the required
|
|
22
|
+
height use the `vertical` view mode:
|
|
23
|
+
|
|
24
|
+
```vue
|
|
25
|
+
<VerovioCanvas url="/file.mei" view-mode="vertical" />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or use the `horizontal` view mode to make the score scrollable on the x-axis:
|
|
29
|
+
|
|
30
|
+
```vue
|
|
31
|
+
<VerovioCanvas url="/file.mei" view-mode="horizontal" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If you want to use pagination wrap the `<VerovioCanvas />` component in a
|
|
35
|
+
container element with specific dimensions:
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<div style="width: 640px; height: 360px;">
|
|
39
|
+
<VerovioCanvas url="/file.mei" view-mode="page" />
|
|
40
|
+
</div>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
You can also use the wrapper element with specific dimensions if you want to use
|
|
44
|
+
`vertical` view mode but with scrollable on the y-axis.
|
|
45
|
+
|
|
46
|
+
## Exposed variables and methods
|
|
47
|
+
|
|
48
|
+
The `<VerovioCanvas>` component exposes the following options
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
defineExpose({
|
|
52
|
+
isLoading,
|
|
53
|
+
dimensions,
|
|
54
|
+
page,
|
|
55
|
+
callVerovioMethod,
|
|
56
|
+
nextPage,
|
|
57
|
+
prevPage,
|
|
58
|
+
setPage,
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
These exposed variables and methods can be used to interact with the `VerovioCanvas` component:
|
|
63
|
+
|
|
64
|
+
```vue
|
|
65
|
+
<script setup>
|
|
66
|
+
import { ref, computed } from 'vue';
|
|
67
|
+
|
|
68
|
+
const scale = ref(30);
|
|
69
|
+
const score = ref(null);
|
|
70
|
+
const viewMode = ref('page');
|
|
71
|
+
|
|
72
|
+
function next() {
|
|
73
|
+
score.value.nextPage();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function prev() {
|
|
77
|
+
score.value.prevPage();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const page = computed({
|
|
81
|
+
get() {
|
|
82
|
+
return score.value && score.value.page;
|
|
83
|
+
},
|
|
84
|
+
set(value) {
|
|
85
|
+
score.value.setPage(value);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<template>
|
|
91
|
+
<input type="range" min="1" max="100" v-model.number="scale" />
|
|
92
|
+
<select v-model="viewMode">
|
|
93
|
+
<option value="page">page</option>
|
|
94
|
+
<option value="horizontal">horizontal</option>
|
|
95
|
+
<option value="vertical">vertical</option>
|
|
96
|
+
</select>
|
|
97
|
+
<button @click="prev">prev page</button>
|
|
98
|
+
<input type="text" v-model.lazy="page" />
|
|
99
|
+
<button @click="next">next page</button>
|
|
100
|
+
<div style="width: 640px; height: 360px">
|
|
101
|
+
<VerovioCanvas ref="score" url="https://raw.githubusercontent.com/WolfgangDrescher/lassus-geistliche-psalmen/master/kern/01-beatus-vir.krn" :scale="scale" :view-mode="viewMode" />
|
|
102
|
+
</div>
|
|
103
|
+
</template>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Custom Verovio method calls
|
|
107
|
+
|
|
108
|
+
Use `callVerovioMethod` to call other methods on the Verovio toolkit instance. `callVerovioMethod` is async
|
|
109
|
+
to ensure that the Verovio runtime is initialized and the score if already loaded.
|
|
110
|
+
|
|
111
|
+
```vue
|
|
112
|
+
<script setup>
|
|
113
|
+
import { ref, onMounted } from 'vue';
|
|
114
|
+
|
|
115
|
+
const score = ref(null);
|
|
116
|
+
onMounted(() => {
|
|
117
|
+
score.value.callVerovioMethod('renderToMIDI', {
|
|
118
|
+
midiTempoAdjustment: 1.25,
|
|
119
|
+
}).then(midiBase64 => {
|
|
120
|
+
console.log(midiBase64);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
<template>
|
|
126
|
+
<VerovioCanvas ref="score" url="https://raw.githubusercontent.com/WolfgangDrescher/lassus-geistliche-psalmen/master/kern/01-beatus-vir.krn" />
|
|
127
|
+
</template>
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Avoid use with SSR
|
|
132
|
+
|
|
133
|
+
Errors may occur when the component is loaded with server side rendering. Try to
|
|
134
|
+
load the `VerovioCanvas` component in wrapped in `ClientOnly`. If not available
|
|
135
|
+
you can try something like this:
|
|
136
|
+
|
|
137
|
+
```vue
|
|
138
|
+
<script setup>
|
|
139
|
+
import { defineAsyncComponent } from 'vue';
|
|
140
|
+
import 'vue-verovio-canvas/dist/style.css';
|
|
141
|
+
const AsyncVerovioCanvas = defineAsyncComponent(() => import('vue-verovio-canvas'));
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<template>
|
|
145
|
+
<component :is="AsyncVerovioCanvas" v-bind="{...$attrs, ...$props}"></component>
|
|
146
|
+
</template>
|
|
147
|
+
```
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.loading-spinner[data-v-42c50a38]{animation:spin-animation-42c50a38 .8s infinite linear}@keyframes spin-animation-42c50a38{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.loading-component[data-v-956ec44e]{width:100%;height:100%;display:flex;justify-content:center;align-items:center}.loading-component-spinner[data-v-956ec44e]{display:flex;justify-content:center;align-items:center}.loading-component-message[data-v-956ec44e]{text-align:center;margin-top:.5rem}*[data-v-068e7b05],*[data-v-068e7b05]:before,*[data-v-068e7b05]:after{box-sizing:border-box}.verovio-container[data-v-068e7b05]{display:flex;flex-direction:column;height:100%}.verovio-canvas[data-v-068e7b05]{position:relative;min-width:100%;min-height:100%}.verovio-canvas-vertical[data-v-068e7b05]{overflow-x:auto}.verovio-canvas-horizontal[data-v-068e7b05]{overflow-y:auto}.verovio-canvas-stage[data-v-068e7b05]{display:flex;justify-content:center;flex-direction:column}.verovio-canvas-status[data-v-068e7b05]{width:100%;height:100%;background-color:#f3f4f6cc;border-radius:3px;border:1px solid #e5e7eb;display:flex;align-items:center;justify-content:center;padding:1rem}.verovio-canvas-status-error[data-v-068e7b05]{background-color:#fee2e2cc;border-color:#fecaca}
|
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import { ref as y, watch as x, readonly as m, reactive as oe, onMounted as q, openBlock as h, createElementBlock as b, pushScopeId as ae, popScopeId as re, createElementVNode as I, createVNode as se, toDisplayString as A, createCommentVNode as ie, getCurrentScope as ue, onScopeDispose as le, unref as O, getCurrentInstance as ce, nextTick as de, toRefs as ge, normalizeClass as B, createBlock as ve } from "vue";
|
|
2
|
+
function pe(e, t, n, a) {
|
|
3
|
+
const o = y(1);
|
|
4
|
+
let s = null;
|
|
5
|
+
x(o, () => {
|
|
6
|
+
v();
|
|
7
|
+
});
|
|
8
|
+
async function i() {
|
|
9
|
+
o.value = await d(o.value + 1);
|
|
10
|
+
}
|
|
11
|
+
async function g() {
|
|
12
|
+
o.value = await d(o.value - 1);
|
|
13
|
+
}
|
|
14
|
+
async function l(u) {
|
|
15
|
+
o.value = await d(u);
|
|
16
|
+
}
|
|
17
|
+
async function d(u) {
|
|
18
|
+
if (!Number.isInteger(Number(u)))
|
|
19
|
+
throw new Error(`Page must be an integer, "${u}" given.`);
|
|
20
|
+
return Math.min(Math.max(u, 1), await e.value.getPageCount());
|
|
21
|
+
}
|
|
22
|
+
function v() {
|
|
23
|
+
clearTimeout(s), s = setTimeout(() => {
|
|
24
|
+
p();
|
|
25
|
+
}, 100);
|
|
26
|
+
}
|
|
27
|
+
async function p() {
|
|
28
|
+
a.value = !0, await n.promise, o.value = await d(o.value), f(o.value);
|
|
29
|
+
}
|
|
30
|
+
async function f(u) {
|
|
31
|
+
t.value = await e.value.renderToSVG(u), a.value = !1;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
page: m(o),
|
|
35
|
+
nextPage: i,
|
|
36
|
+
prevPage: g,
|
|
37
|
+
setPage: l,
|
|
38
|
+
renderCurrentPage: p
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function fe(e) {
|
|
42
|
+
const t = oe({
|
|
43
|
+
width: null,
|
|
44
|
+
height: null
|
|
45
|
+
});
|
|
46
|
+
let n = null;
|
|
47
|
+
q(() => {
|
|
48
|
+
a(e.value);
|
|
49
|
+
});
|
|
50
|
+
function a(o) {
|
|
51
|
+
o instanceof HTMLElement && (t.width = o.clientWidth, t.height = o.clientHeight, n = new ResizeObserver(([s]) => {
|
|
52
|
+
t.width = s.target.clientWidth, t.height = s.target.clientHeight;
|
|
53
|
+
}), n.observe(o));
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
dimensions: m(t)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
class P {
|
|
60
|
+
constructor() {
|
|
61
|
+
this.promise = new Promise((t, n) => {
|
|
62
|
+
this.reject = n, this.resolve = t;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const me = {
|
|
67
|
+
scale: 40,
|
|
68
|
+
pageMarginTop: 0,
|
|
69
|
+
pageMarginRight: 0,
|
|
70
|
+
pageMarginBottom: 0,
|
|
71
|
+
pageMarginLeft: 0,
|
|
72
|
+
header: "none",
|
|
73
|
+
footer: "none"
|
|
74
|
+
};
|
|
75
|
+
function ye(e, t) {
|
|
76
|
+
const {
|
|
77
|
+
url: n,
|
|
78
|
+
data: a,
|
|
79
|
+
scale: o,
|
|
80
|
+
viewMode: s,
|
|
81
|
+
pageMargin: i,
|
|
82
|
+
options: g,
|
|
83
|
+
select: l
|
|
84
|
+
} = e, d = y(null), v = y(!0), p = y(!1), f = y(null), u = y(null), w = new P(), M = new P();
|
|
85
|
+
let _ = null;
|
|
86
|
+
const { page: k, nextPage: G, prevPage: F, setPage: K, renderCurrentPage: z } = pe(
|
|
87
|
+
u,
|
|
88
|
+
d,
|
|
89
|
+
w,
|
|
90
|
+
v
|
|
91
|
+
), { dimensions: T } = fe(t);
|
|
92
|
+
f.value = "Initializing Verovio WebAssembly runtime";
|
|
93
|
+
function J(r) {
|
|
94
|
+
r && (u.value = r, u.value.moduleIsReady().then(() => M.resolve()));
|
|
95
|
+
}
|
|
96
|
+
x([o, g, T, s], () => {
|
|
97
|
+
Z();
|
|
98
|
+
}), x(a, () => {
|
|
99
|
+
j();
|
|
100
|
+
});
|
|
101
|
+
async function N() {
|
|
102
|
+
await u.value.setOptions(Y());
|
|
103
|
+
}
|
|
104
|
+
async function X(r, ...ne) {
|
|
105
|
+
return await w.promise, await u.value[r](...ne);
|
|
106
|
+
}
|
|
107
|
+
function Y() {
|
|
108
|
+
const r = Object.assign({}, me, {
|
|
109
|
+
scale: o.value
|
|
110
|
+
}, g.value);
|
|
111
|
+
return Object.assign(r, {
|
|
112
|
+
pageWidth: Math.min(Math.max(T.width * (100 / r.scale), 100), 6e4),
|
|
113
|
+
pageHeight: Math.min(Math.max(T.height * (100 / r.scale), 100), 6e4),
|
|
114
|
+
pageMarginTop: r.pageMarginTop ? r.pageMarginTop : i.value,
|
|
115
|
+
pageMarginRight: r.pageMarginRight ? r.pageMarginRight : i.value,
|
|
116
|
+
pageMarginBottom: r.pageMarginBottom ? r.pageMarginBottom : i.value,
|
|
117
|
+
pageMarginLeft: r.pageMarginLeft ? r.pageMarginLeft : i.value
|
|
118
|
+
}), s.value === "vertical" ? (r.adjustPageHeight = !0, r.pageHeight = 6e4) : s.value === "horizontal" && (r.adjustPageHeight = !0, r.breaks = "none", r.pageWidth = 6e4), r;
|
|
119
|
+
}
|
|
120
|
+
async function Z() {
|
|
121
|
+
await w.promise, clearTimeout(_), v.value = !0, _ = setTimeout(async () => {
|
|
122
|
+
N(), await u.value.redoLayout(), z();
|
|
123
|
+
}, 100);
|
|
124
|
+
}
|
|
125
|
+
async function j() {
|
|
126
|
+
try {
|
|
127
|
+
await u.value.moduleIsReady(), N();
|
|
128
|
+
const r = await ee();
|
|
129
|
+
f.value = "Load score with verovio", (!l.value || Object.keys(l.value).length !== 0 || Object.getPrototypeOf(l.value) !== Object.prototype) && await u.value.select(l.value), await u.value.loadData(r), w.resolve(), f.value = "Render current page with verovio", z();
|
|
130
|
+
} catch (r) {
|
|
131
|
+
p.value = !0, f.value = `Cannot display score with verovio (${r.message})`, console.error(r);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async function ee() {
|
|
135
|
+
if (a.value)
|
|
136
|
+
return a.value;
|
|
137
|
+
if (n.value) {
|
|
138
|
+
f.value = "Fetching score file from server";
|
|
139
|
+
const r = await fetch(n.value);
|
|
140
|
+
if (!r.ok)
|
|
141
|
+
throw new Error(`${r.status} ${r.statusText}`);
|
|
142
|
+
return await r.text();
|
|
143
|
+
}
|
|
144
|
+
throw new Error("Input missing: pass url or data prop");
|
|
145
|
+
}
|
|
146
|
+
async function te() {
|
|
147
|
+
return await M.promise, await j();
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
renderedScore: m(d),
|
|
151
|
+
page: m(k),
|
|
152
|
+
isLoading: m(v),
|
|
153
|
+
isError: m(p),
|
|
154
|
+
message: m(f),
|
|
155
|
+
dimensions: m(T),
|
|
156
|
+
callVerovioMethod: X,
|
|
157
|
+
nextPage: G,
|
|
158
|
+
prevPage: F,
|
|
159
|
+
setPage: K,
|
|
160
|
+
load: te,
|
|
161
|
+
setToolkit: J
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const V = (e, t) => {
|
|
165
|
+
const n = e.__vccOpts || e;
|
|
166
|
+
for (const [a, o] of t)
|
|
167
|
+
n[a] = o;
|
|
168
|
+
return n;
|
|
169
|
+
}, he = (e) => (ae("data-v-42c50a38"), e = e(), re(), e), we = ["width", "height", "stroke"], _e = /* @__PURE__ */ he(() => /* @__PURE__ */ I("g", {
|
|
170
|
+
fill: "none",
|
|
171
|
+
"fill-rule": "evenodd"
|
|
172
|
+
}, [
|
|
173
|
+
/* @__PURE__ */ I("g", {
|
|
174
|
+
transform: "translate(1 1)",
|
|
175
|
+
"stroke-width": "2"
|
|
176
|
+
}, [
|
|
177
|
+
/* @__PURE__ */ I("circle", {
|
|
178
|
+
"stroke-opacity": ".25",
|
|
179
|
+
cx: "18",
|
|
180
|
+
cy: "18",
|
|
181
|
+
r: "18"
|
|
182
|
+
}),
|
|
183
|
+
/* @__PURE__ */ I("path", { d: "M36 18c0-9.94-8.06-18-18-18" })
|
|
184
|
+
])
|
|
185
|
+
], -1)), Oe = [
|
|
186
|
+
_e
|
|
187
|
+
], be = {
|
|
188
|
+
__name: "LoadingSpinner",
|
|
189
|
+
props: {
|
|
190
|
+
color: {
|
|
191
|
+
type: String,
|
|
192
|
+
default: "#000"
|
|
193
|
+
},
|
|
194
|
+
size: {
|
|
195
|
+
type: Number,
|
|
196
|
+
default: 64
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
setup(e) {
|
|
200
|
+
return (t, n) => (h(), b("svg", {
|
|
201
|
+
class: "loading-spinner",
|
|
202
|
+
viewBox: "0 0 38 38",
|
|
203
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
204
|
+
width: e.size,
|
|
205
|
+
height: e.size,
|
|
206
|
+
stroke: e.color
|
|
207
|
+
}, Oe, 8, we));
|
|
208
|
+
}
|
|
209
|
+
}, Ie = /* @__PURE__ */ V(be, [["__scopeId", "data-v-42c50a38"]]);
|
|
210
|
+
const Me = { class: "loading-component" }, xe = { class: "loading-component-inner" }, Pe = { class: "loading-component-spinner" }, Se = {
|
|
211
|
+
key: 0,
|
|
212
|
+
class: "loading-component-message"
|
|
213
|
+
}, ke = {
|
|
214
|
+
__name: "Loading",
|
|
215
|
+
props: {
|
|
216
|
+
message: {
|
|
217
|
+
type: String,
|
|
218
|
+
default: "Loading\u2026"
|
|
219
|
+
},
|
|
220
|
+
showMessage: {
|
|
221
|
+
type: Boolean,
|
|
222
|
+
default: !0
|
|
223
|
+
},
|
|
224
|
+
spinnerSize: {
|
|
225
|
+
type: Number,
|
|
226
|
+
default: 64
|
|
227
|
+
},
|
|
228
|
+
spinnerColor: {
|
|
229
|
+
type: String,
|
|
230
|
+
default: "#000"
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
setup(e) {
|
|
234
|
+
return (t, n) => (h(), b("div", Me, [
|
|
235
|
+
I("div", xe, [
|
|
236
|
+
I("div", Pe, [
|
|
237
|
+
se(Ie, {
|
|
238
|
+
size: e.spinnerSize,
|
|
239
|
+
stroke: e.spinnerColor
|
|
240
|
+
}, null, 8, ["size", "stroke"])
|
|
241
|
+
]),
|
|
242
|
+
e.showMessage ? (h(), b("div", Se, A(e.message), 1)) : ie("", !0)
|
|
243
|
+
])
|
|
244
|
+
]));
|
|
245
|
+
}
|
|
246
|
+
}, Te = /* @__PURE__ */ V(ke, [["__scopeId", "data-v-956ec44e"]]);
|
|
247
|
+
var U;
|
|
248
|
+
const S = typeof window < "u", L = () => {
|
|
249
|
+
};
|
|
250
|
+
S && ((U = window == null ? void 0 : window.navigator) == null ? void 0 : U.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
251
|
+
function Ce(e) {
|
|
252
|
+
return typeof e == "function" ? e() : O(e);
|
|
253
|
+
}
|
|
254
|
+
function Le(e) {
|
|
255
|
+
return e;
|
|
256
|
+
}
|
|
257
|
+
function Ee(e) {
|
|
258
|
+
return ue() ? (le(e), !0) : !1;
|
|
259
|
+
}
|
|
260
|
+
function Re(e, t = !0) {
|
|
261
|
+
ce() ? q(e) : t ? e() : de(e);
|
|
262
|
+
}
|
|
263
|
+
function W(e) {
|
|
264
|
+
var t;
|
|
265
|
+
const n = Ce(e);
|
|
266
|
+
return (t = n == null ? void 0 : n.$el) != null ? t : n;
|
|
267
|
+
}
|
|
268
|
+
const Ve = S ? window : void 0;
|
|
269
|
+
S && window.document;
|
|
270
|
+
S && window.navigator;
|
|
271
|
+
S && window.location;
|
|
272
|
+
function ze(e, t = !1) {
|
|
273
|
+
const n = y(), a = () => n.value = Boolean(e());
|
|
274
|
+
return a(), Re(a, t), n;
|
|
275
|
+
}
|
|
276
|
+
const E = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, R = "__vueuse_ssr_handlers__";
|
|
277
|
+
E[R] = E[R] || {};
|
|
278
|
+
E[R];
|
|
279
|
+
function Ne(e, t, n = {}) {
|
|
280
|
+
const {
|
|
281
|
+
root: a,
|
|
282
|
+
rootMargin: o = "0px",
|
|
283
|
+
threshold: s = 0.1,
|
|
284
|
+
window: i = Ve
|
|
285
|
+
} = n, g = ze(() => i && "IntersectionObserver" in i);
|
|
286
|
+
let l = L;
|
|
287
|
+
const d = g.value ? x(() => ({
|
|
288
|
+
el: W(e),
|
|
289
|
+
root: W(a)
|
|
290
|
+
}), ({ el: p, root: f }) => {
|
|
291
|
+
if (l(), !p)
|
|
292
|
+
return;
|
|
293
|
+
const u = new IntersectionObserver(t, {
|
|
294
|
+
root: f,
|
|
295
|
+
rootMargin: o,
|
|
296
|
+
threshold: s
|
|
297
|
+
});
|
|
298
|
+
u.observe(p), l = () => {
|
|
299
|
+
u.disconnect(), l = L;
|
|
300
|
+
};
|
|
301
|
+
}, { immediate: !0, flush: "post" }) : L, v = () => {
|
|
302
|
+
l(), d();
|
|
303
|
+
};
|
|
304
|
+
return Ee(v), {
|
|
305
|
+
isSupported: g,
|
|
306
|
+
stop: v
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
var $;
|
|
310
|
+
(function(e) {
|
|
311
|
+
e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
|
|
312
|
+
})($ || ($ = {}));
|
|
313
|
+
var je = Object.defineProperty, H = Object.getOwnPropertySymbols, Be = Object.prototype.hasOwnProperty, Ue = Object.prototype.propertyIsEnumerable, D = (e, t, n) => t in e ? je(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, We = (e, t) => {
|
|
314
|
+
for (var n in t || (t = {}))
|
|
315
|
+
Be.call(t, n) && D(e, n, t[n]);
|
|
316
|
+
if (H)
|
|
317
|
+
for (var n of H(t))
|
|
318
|
+
Ue.call(t, n) && D(e, n, t[n]);
|
|
319
|
+
return e;
|
|
320
|
+
};
|
|
321
|
+
const $e = {
|
|
322
|
+
easeInSine: [0.12, 0, 0.39, 0],
|
|
323
|
+
easeOutSine: [0.61, 1, 0.88, 1],
|
|
324
|
+
easeInOutSine: [0.37, 0, 0.63, 1],
|
|
325
|
+
easeInQuad: [0.11, 0, 0.5, 0],
|
|
326
|
+
easeOutQuad: [0.5, 1, 0.89, 1],
|
|
327
|
+
easeInOutQuad: [0.45, 0, 0.55, 1],
|
|
328
|
+
easeInCubic: [0.32, 0, 0.67, 0],
|
|
329
|
+
easeOutCubic: [0.33, 1, 0.68, 1],
|
|
330
|
+
easeInOutCubic: [0.65, 0, 0.35, 1],
|
|
331
|
+
easeInQuart: [0.5, 0, 0.75, 0],
|
|
332
|
+
easeOutQuart: [0.25, 1, 0.5, 1],
|
|
333
|
+
easeInOutQuart: [0.76, 0, 0.24, 1],
|
|
334
|
+
easeInQuint: [0.64, 0, 0.78, 0],
|
|
335
|
+
easeOutQuint: [0.22, 1, 0.36, 1],
|
|
336
|
+
easeInOutQuint: [0.83, 0, 0.17, 1],
|
|
337
|
+
easeInExpo: [0.7, 0, 0.84, 0],
|
|
338
|
+
easeOutExpo: [0.16, 1, 0.3, 1],
|
|
339
|
+
easeInOutExpo: [0.87, 0, 0.13, 1],
|
|
340
|
+
easeInCirc: [0.55, 0, 1, 0.45],
|
|
341
|
+
easeOutCirc: [0, 0.55, 0.45, 1],
|
|
342
|
+
easeInOutCirc: [0.85, 0, 0.15, 1],
|
|
343
|
+
easeInBack: [0.36, 0, 0.66, -0.56],
|
|
344
|
+
easeOutBack: [0.34, 1.56, 0.64, 1],
|
|
345
|
+
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
|
|
346
|
+
};
|
|
347
|
+
We({
|
|
348
|
+
linear: Le
|
|
349
|
+
}, $e);
|
|
350
|
+
const He = { class: "verovio-container" }, De = ["textContent"], Qe = ["innerHTML"], qe = {
|
|
351
|
+
__name: "VerovioCanvas",
|
|
352
|
+
props: {
|
|
353
|
+
toolkit: {
|
|
354
|
+
type: Object,
|
|
355
|
+
required: !0
|
|
356
|
+
},
|
|
357
|
+
url: {
|
|
358
|
+
type: String,
|
|
359
|
+
required: !1,
|
|
360
|
+
default: null
|
|
361
|
+
},
|
|
362
|
+
data: {
|
|
363
|
+
type: String,
|
|
364
|
+
required: !1,
|
|
365
|
+
default: null
|
|
366
|
+
},
|
|
367
|
+
scale: {
|
|
368
|
+
type: Number,
|
|
369
|
+
required: !1,
|
|
370
|
+
default: 40,
|
|
371
|
+
validator: (e) => e >= 1 && e <= 1e3
|
|
372
|
+
},
|
|
373
|
+
viewMode: {
|
|
374
|
+
type: String,
|
|
375
|
+
required: !1,
|
|
376
|
+
default: "vertical",
|
|
377
|
+
validator: (e) => ["page", "horizontal", "vertical"].includes(e)
|
|
378
|
+
},
|
|
379
|
+
pageMargin: {
|
|
380
|
+
type: Number,
|
|
381
|
+
required: !1,
|
|
382
|
+
default: 0
|
|
383
|
+
},
|
|
384
|
+
options: {
|
|
385
|
+
type: Object,
|
|
386
|
+
required: !1,
|
|
387
|
+
default: () => ({})
|
|
388
|
+
},
|
|
389
|
+
select: {
|
|
390
|
+
type: Object,
|
|
391
|
+
required: !1,
|
|
392
|
+
default: () => ({})
|
|
393
|
+
},
|
|
394
|
+
lazy: {
|
|
395
|
+
type: Boolean,
|
|
396
|
+
default: !1
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
setup(e, { expose: t }) {
|
|
400
|
+
const n = e, a = y(null), {
|
|
401
|
+
isLoading: o,
|
|
402
|
+
isError: s,
|
|
403
|
+
renderedScore: i,
|
|
404
|
+
message: g,
|
|
405
|
+
dimensions: l,
|
|
406
|
+
page: d,
|
|
407
|
+
callVerovioMethod: v,
|
|
408
|
+
nextPage: p,
|
|
409
|
+
prevPage: f,
|
|
410
|
+
setPage: u,
|
|
411
|
+
load: w,
|
|
412
|
+
setToolkit: M
|
|
413
|
+
} = ye(ge(n), a);
|
|
414
|
+
if (M(n.toolkit), x(() => n.toolkit, (_) => {
|
|
415
|
+
M(_);
|
|
416
|
+
}), t({
|
|
417
|
+
isLoading: o,
|
|
418
|
+
dimensions: l,
|
|
419
|
+
page: d,
|
|
420
|
+
callVerovioMethod: v,
|
|
421
|
+
nextPage: p,
|
|
422
|
+
prevPage: f,
|
|
423
|
+
setPage: u
|
|
424
|
+
}), n.lazy) {
|
|
425
|
+
const { stop: _ } = Ne(a, ([{ isIntersecting: k }]) => {
|
|
426
|
+
k === !0 && (w(), _());
|
|
427
|
+
});
|
|
428
|
+
} else
|
|
429
|
+
w();
|
|
430
|
+
return (_, k) => (h(), b("div", He, [
|
|
431
|
+
I("div", {
|
|
432
|
+
class: B(["verovio-canvas", `verovio-canvas-${e.viewMode}`]),
|
|
433
|
+
ref_key: "verovioCanvas",
|
|
434
|
+
ref: a
|
|
435
|
+
}, [
|
|
436
|
+
O(i) === null ? (h(), b("div", {
|
|
437
|
+
key: 0,
|
|
438
|
+
class: B(["verovio-canvas-status", { "verovio-canvas-status-error": O(s) }])
|
|
439
|
+
}, [
|
|
440
|
+
O(s) ? (h(), b("div", {
|
|
441
|
+
key: 1,
|
|
442
|
+
class: "verovio-canvas-status-error-message",
|
|
443
|
+
textContent: A(O(g))
|
|
444
|
+
}, null, 8, De)) : (h(), ve(Te, {
|
|
445
|
+
key: 0,
|
|
446
|
+
message: O(g)
|
|
447
|
+
}, null, 8, ["message"]))
|
|
448
|
+
], 2)) : (h(), b("div", {
|
|
449
|
+
key: 1,
|
|
450
|
+
class: "verovio-canvas-stage",
|
|
451
|
+
innerHTML: O(i)
|
|
452
|
+
}, null, 8, Qe))
|
|
453
|
+
], 2)
|
|
454
|
+
]));
|
|
455
|
+
}
|
|
456
|
+
}, Ye = /* @__PURE__ */ V(qe, [["__scopeId", "data-v-068e7b05"]]);
|
|
457
|
+
function Ze(e) {
|
|
458
|
+
return new Proxy({}, {
|
|
459
|
+
get: (t, n) => (...a) => {
|
|
460
|
+
const o = new P(), s = e[n];
|
|
461
|
+
let i;
|
|
462
|
+
return s && (i = s.apply(e, a || [])), o.resolve(i), o.promise;
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
let C;
|
|
467
|
+
const Ae = new Uint8Array(16);
|
|
468
|
+
function Ge() {
|
|
469
|
+
if (!C && (C = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !C))
|
|
470
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
471
|
+
return C(Ae);
|
|
472
|
+
}
|
|
473
|
+
const c = [];
|
|
474
|
+
for (let e = 0; e < 256; ++e)
|
|
475
|
+
c.push((e + 256).toString(16).slice(1));
|
|
476
|
+
function Fe(e, t = 0) {
|
|
477
|
+
return (c[e[t + 0]] + c[e[t + 1]] + c[e[t + 2]] + c[e[t + 3]] + "-" + c[e[t + 4]] + c[e[t + 5]] + "-" + c[e[t + 6]] + c[e[t + 7]] + "-" + c[e[t + 8]] + c[e[t + 9]] + "-" + c[e[t + 10]] + c[e[t + 11]] + c[e[t + 12]] + c[e[t + 13]] + c[e[t + 14]] + c[e[t + 15]]).toLowerCase();
|
|
478
|
+
}
|
|
479
|
+
const Ke = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Q = {
|
|
480
|
+
randomUUID: Ke
|
|
481
|
+
};
|
|
482
|
+
function Je(e, t, n) {
|
|
483
|
+
if (Q.randomUUID && !t && !e)
|
|
484
|
+
return Q.randomUUID();
|
|
485
|
+
e = e || {};
|
|
486
|
+
const a = e.random || (e.rng || Ge)();
|
|
487
|
+
if (a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, t) {
|
|
488
|
+
n = n || 0;
|
|
489
|
+
for (let o = 0; o < 16; ++o)
|
|
490
|
+
t[n + o] = a[o];
|
|
491
|
+
return t;
|
|
492
|
+
}
|
|
493
|
+
return Fe(a);
|
|
494
|
+
}
|
|
495
|
+
function et(e) {
|
|
496
|
+
const t = {};
|
|
497
|
+
return e.addEventListener("message", (n) => {
|
|
498
|
+
const { id: a, result: o } = n.data, s = t[a];
|
|
499
|
+
s && (s.resolve(o), delete t[a]);
|
|
500
|
+
}), new Proxy({}, {
|
|
501
|
+
get: (n, a) => (...o) => {
|
|
502
|
+
const s = Je();
|
|
503
|
+
e.postMessage({
|
|
504
|
+
id: s,
|
|
505
|
+
method: a,
|
|
506
|
+
args: o
|
|
507
|
+
});
|
|
508
|
+
const i = new P();
|
|
509
|
+
return t[s] = i, i.promise;
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
function tt(e, t, n, a) {
|
|
514
|
+
if (typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope) {
|
|
515
|
+
let o = {};
|
|
516
|
+
const s = new P();
|
|
517
|
+
e().then((i) => {
|
|
518
|
+
n && n(a, i), o = new t(i), s.resolve();
|
|
519
|
+
}), addEventListener("message", (i) => {
|
|
520
|
+
const { id: g, method: l, args: d } = i.data;
|
|
521
|
+
if (l === "moduleIsReady") {
|
|
522
|
+
s.promise.then(() => {
|
|
523
|
+
postMessage({
|
|
524
|
+
id: g,
|
|
525
|
+
method: l,
|
|
526
|
+
args: d,
|
|
527
|
+
result: null
|
|
528
|
+
}, i);
|
|
529
|
+
});
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
const v = o[l];
|
|
533
|
+
let p;
|
|
534
|
+
v && (p = v.apply(o, d || [])), postMessage({
|
|
535
|
+
id: g,
|
|
536
|
+
method: l,
|
|
537
|
+
args: d,
|
|
538
|
+
result: p
|
|
539
|
+
}, i);
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
export {
|
|
544
|
+
Ye as VerovioCanvas,
|
|
545
|
+
Ze as createAsyncVerovioToolkit,
|
|
546
|
+
tt as createVerovioWorker,
|
|
547
|
+
et as createWorkerVerovioToolkit
|
|
548
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(y,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(y=typeof globalThis<"u"?globalThis:y||self,t(y.VueVerovioCanvas={},y.Vue))})(this,function(y,t){"use strict";function j(e,n,o,r){const a=t.ref(1);let s=null;t.watch(a,()=>{f()});async function l(){a.value=await p(a.value+1)}async function g(){a.value=await p(a.value-1)}async function d(c){a.value=await p(c)}async function p(c){if(!Number.isInteger(Number(c)))throw new Error(`Page must be an integer, "${c}" given.`);return Math.min(Math.max(c,1),await e.value.getPageCount())}function f(){clearTimeout(s),s=setTimeout(()=>{v()},100)}async function v(){r.value=!0,await o.promise,a.value=await p(a.value),m(a.value)}async function m(c){n.value=await e.value.renderToSVG(c),r.value=!1}return{page:t.readonly(a),nextPage:l,prevPage:g,setPage:d,renderCurrentPage:v}}function U(e){const n=t.reactive({width:null,height:null});let o=null;t.onMounted(()=>{r(e.value)});function r(a){a instanceof HTMLElement&&(n.width=a.clientWidth,n.height=a.clientHeight,o=new ResizeObserver(([s])=>{n.width=s.target.clientWidth,n.height=s.target.clientHeight}),o.observe(a))}return{dimensions:t.readonly(n)}}class w{constructor(){this.promise=new Promise((n,o)=>{this.reject=o,this.resolve=n})}}const W={scale:40,pageMarginTop:0,pageMarginRight:0,pageMarginBottom:0,pageMarginLeft:0,header:"none",footer:"none"};function D(e,n){const{url:o,data:r,scale:a,viewMode:s,pageMargin:l,options:g,select:d}=e,p=t.ref(null),f=t.ref(!0),v=t.ref(!1),m=t.ref(null),c=t.ref(null),h=new w,k=new w;let _=null;const{page:I,nextPage:we,prevPage:Oe,setPage:ke,renderCurrentPage:R}=j(c,p,h,f),{dimensions:M}=U(n);m.value="Initializing Verovio WebAssembly runtime";function be(i){i&&(c.value=i,c.value.moduleIsReady().then(()=>k.resolve()))}t.watch([a,g,M,s],()=>{Se()}),t.watch(r,()=>{$()});async function z(){await c.value.setOptions(Me())}async function Ie(i,...Ve){return await h.promise,await c.value[i](...Ve)}function Me(){const i=Object.assign({},W,{scale:a.value},g.value);return Object.assign(i,{pageWidth:Math.min(Math.max(M.width*(100/i.scale),100),6e4),pageHeight:Math.min(Math.max(M.height*(100/i.scale),100),6e4),pageMarginTop:i.pageMarginTop?i.pageMarginTop:l.value,pageMarginRight:i.pageMarginRight?i.pageMarginRight:l.value,pageMarginBottom:i.pageMarginBottom?i.pageMarginBottom:l.value,pageMarginLeft:i.pageMarginLeft?i.pageMarginLeft:l.value}),s.value==="vertical"?(i.adjustPageHeight=!0,i.pageHeight=6e4):s.value==="horizontal"&&(i.adjustPageHeight=!0,i.breaks="none",i.pageWidth=6e4),i}async function Se(){await h.promise,clearTimeout(_),f.value=!0,_=setTimeout(async()=>{z(),await c.value.redoLayout(),R()},100)}async function $(){try{await c.value.moduleIsReady(),z();const i=await Pe();m.value="Load score with verovio",(!d.value||Object.keys(d.value).length!==0||Object.getPrototypeOf(d.value)!==Object.prototype)&&await c.value.select(d.value),await c.value.loadData(i),h.resolve(),m.value="Render current page with verovio",R()}catch(i){v.value=!0,m.value=`Cannot display score with verovio (${i.message})`,console.error(i)}}async function Pe(){if(r.value)return r.value;if(o.value){m.value="Fetching score file from server";const i=await fetch(o.value);if(!i.ok)throw new Error(`${i.status} ${i.statusText}`);return await i.text()}throw new Error("Input missing: pass url or data prop")}async function Te(){return await k.promise,await $()}return{renderedScore:t.readonly(p),page:t.readonly(I),isLoading:t.readonly(f),isError:t.readonly(v),message:t.readonly(m),dimensions:t.readonly(M),callVerovioMethod:Ie,nextPage:we,prevPage:Oe,setPage:ke,load:Te,setToolkit:be}}const Ee="",S=(e,n)=>{const o=e.__vccOpts||e;for(const[r,a]of n)o[r]=a;return o},H=e=>(t.pushScopeId("data-v-42c50a38"),e=e(),t.popScopeId(),e),q=["width","height","stroke"],Q=[H(()=>t.createElementVNode("g",{fill:"none","fill-rule":"evenodd"},[t.createElementVNode("g",{transform:"translate(1 1)","stroke-width":"2"},[t.createElementVNode("circle",{"stroke-opacity":".25",cx:"18",cy:"18",r:"18"}),t.createElementVNode("path",{d:"M36 18c0-9.94-8.06-18-18-18"})])],-1))],A=S({__name:"LoadingSpinner",props:{color:{type:String,default:"#000"},size:{type:Number,default:64}},setup(e){return(n,o)=>(t.openBlock(),t.createElementBlock("svg",{class:"loading-spinner",viewBox:"0 0 38 38",xmlns:"http://www.w3.org/2000/svg",width:e.size,height:e.size,stroke:e.color},Q,8,q))}},[["__scopeId","data-v-42c50a38"]]),Be="",G={class:"loading-component"},F={class:"loading-component-inner"},K={class:"loading-component-spinner"},J={key:0,class:"loading-component-message"},X=S({__name:"Loading",props:{message:{type:String,default:"Loading\u2026"},showMessage:{type:Boolean,default:!0},spinnerSize:{type:Number,default:64},spinnerColor:{type:String,default:"#000"}},setup(e){return(n,o)=>(t.openBlock(),t.createElementBlock("div",G,[t.createElementVNode("div",F,[t.createElementVNode("div",K,[t.createVNode(A,{size:e.spinnerSize,stroke:e.spinnerColor},null,8,["size","stroke"])]),e.showMessage?(t.openBlock(),t.createElementBlock("div",J,t.toDisplayString(e.message),1)):t.createCommentVNode("",!0)])]))}},[["__scopeId","data-v-956ec44e"]]);var E;const O=typeof window<"u",P=()=>{};O&&((E=window==null?void 0:window.navigator)==null?void 0:E.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function Y(e){return typeof e=="function"?e():t.unref(e)}function Z(e){return e}function ee(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function te(e,n=!0){t.getCurrentInstance()?t.onMounted(e):n?e():t.nextTick(e)}function x(e){var n;const o=Y(e);return(n=o==null?void 0:o.$el)!=null?n:o}const ne=O?window:void 0;O&&window.document,O&&window.navigator,O&&window.location;function oe(e,n=!1){const o=t.ref(),r=()=>o.value=Boolean(e());return r(),te(r,n),o}const T=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V="__vueuse_ssr_handlers__";T[V]=T[V]||{},T[V];function ae(e,n,o={}){const{root:r,rootMargin:a="0px",threshold:s=.1,window:l=ne}=o,g=oe(()=>l&&"IntersectionObserver"in l);let d=P;const p=g.value?t.watch(()=>({el:x(e),root:x(r)}),({el:v,root:m})=>{if(d(),!v)return;const c=new IntersectionObserver(n,{root:m,rootMargin:a,threshold:s});c.observe(v),d=()=>{c.disconnect(),d=P}},{immediate:!0,flush:"post"}):P,f=()=>{d(),p()};return ee(f),{isSupported:g,stop:f}}var C;(function(e){e.UP="UP",e.RIGHT="RIGHT",e.DOWN="DOWN",e.LEFT="LEFT",e.NONE="NONE"})(C||(C={}));var re=Object.defineProperty,B=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,L=(e,n,o)=>n in e?re(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,le=(e,n)=>{for(var o in n||(n={}))ie.call(n,o)&&L(e,o,n[o]);if(B)for(var o of B(n))se.call(n,o)&&L(e,o,n[o]);return e};le({linear:Z},{easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]});const Re="",ce={class:"verovio-container"},de=["textContent"],ue=["innerHTML"],pe=S({__name:"VerovioCanvas",props:{toolkit:{type:Object,required:!0},url:{type:String,required:!1,default:null},data:{type:String,required:!1,default:null},scale:{type:Number,required:!1,default:40,validator:e=>e>=1&&e<=1e3},viewMode:{type:String,required:!1,default:"vertical",validator:e=>["page","horizontal","vertical"].includes(e)},pageMargin:{type:Number,required:!1,default:0},options:{type:Object,required:!1,default:()=>({})},select:{type:Object,required:!1,default:()=>({})},lazy:{type:Boolean,default:!1}},setup(e,{expose:n}){const o=e,r=t.ref(null),{isLoading:a,isError:s,renderedScore:l,message:g,dimensions:d,page:p,callVerovioMethod:f,nextPage:v,prevPage:m,setPage:c,load:h,setToolkit:k}=D(t.toRefs(o),r);if(k(o.toolkit),t.watch(()=>o.toolkit,_=>{k(_)}),n({isLoading:a,dimensions:d,page:p,callVerovioMethod:f,nextPage:v,prevPage:m,setPage:c}),o.lazy){const{stop:_}=ae(r,([{isIntersecting:I}])=>{I===!0&&(h(),_())})}else h();return(_,I)=>(t.openBlock(),t.createElementBlock("div",ce,[t.createElementVNode("div",{class:t.normalizeClass(["verovio-canvas",`verovio-canvas-${e.viewMode}`]),ref_key:"verovioCanvas",ref:r},[t.unref(l)===null?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["verovio-canvas-status",{"verovio-canvas-status-error":t.unref(s)}])},[t.unref(s)?(t.openBlock(),t.createElementBlock("div",{key:1,class:"verovio-canvas-status-error-message",textContent:t.toDisplayString(t.unref(g))},null,8,de)):(t.openBlock(),t.createBlock(X,{key:0,message:t.unref(g)},null,8,["message"]))],2)):(t.openBlock(),t.createElementBlock("div",{key:1,class:"verovio-canvas-stage",innerHTML:t.unref(l)},null,8,ue))],2)]))}},[["__scopeId","data-v-068e7b05"]]);function ge(e){return new Proxy({},{get:(n,o)=>(...r)=>{const a=new w,s=e[o];let l;return s&&(l=s.apply(e,r||[])),a.resolve(l),a.promise}})}let b;const fe=new Uint8Array(16);function ve(){if(!b&&(b=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!b))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return b(fe)}const u=[];for(let e=0;e<256;++e)u.push((e+256).toString(16).slice(1));function me(e,n=0){return(u[e[n+0]]+u[e[n+1]]+u[e[n+2]]+u[e[n+3]]+"-"+u[e[n+4]]+u[e[n+5]]+"-"+u[e[n+6]]+u[e[n+7]]+"-"+u[e[n+8]]+u[e[n+9]]+"-"+u[e[n+10]]+u[e[n+11]]+u[e[n+12]]+u[e[n+13]]+u[e[n+14]]+u[e[n+15]]).toLowerCase()}const N={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ye(e,n,o){if(N.randomUUID&&!n&&!e)return N.randomUUID();e=e||{};const r=e.random||(e.rng||ve)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,n){o=o||0;for(let a=0;a<16;++a)n[o+a]=r[a];return n}return me(r)}function he(e){const n={};return e.addEventListener("message",o=>{const{id:r,result:a}=o.data,s=n[r];s&&(s.resolve(a),delete n[r])}),new Proxy({},{get:(o,r)=>(...a)=>{const s=ye();e.postMessage({id:s,method:r,args:a});const l=new w;return n[s]=l,l.promise}})}function _e(e,n,o,r){if(typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope){let a={};const s=new w;e().then(l=>{o&&o(r,l),a=new n(l),s.resolve()}),addEventListener("message",l=>{const{id:g,method:d,args:p}=l.data;if(d==="moduleIsReady"){s.promise.then(()=>{postMessage({id:g,method:d,args:p,result:null},l)});return}const f=a[d];let v;f&&(v=f.apply(a,p||[])),postMessage({id:g,method:d,args:p,result:v},l)})}}y.VerovioCanvas=pe,y.createAsyncVerovioToolkit=ge,y.createVerovioWorker=_e,y.createWorkerVerovioToolkit=he,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vue-verovio-canvas",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A Vue 3 component to display music scores with Verovio.",
|
|
5
|
+
"author": "Wolfgang Drescher",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/WolfgangDrescher/vue-verovio-canvas.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/WolfgangDrescher/vue-verovio-canvas/issues"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"main": "./dist/vue-verovio-canvas.umd.cjs",
|
|
18
|
+
"module": "./dist/vue-verovio-canvas.js",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/vue-verovio-canvas.js",
|
|
22
|
+
"require": "./dist/vue-verovio-canvas.umd.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./style.css": "./dist/style.css"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "vite",
|
|
28
|
+
"build": "vite build",
|
|
29
|
+
"preview": "vite preview --port 5050",
|
|
30
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@rushstack/eslint-patch": "^1.2.0",
|
|
34
|
+
"@vitejs/plugin-vue": "^3.1.0",
|
|
35
|
+
"@vue/eslint-config-prettier": "^7.0.0",
|
|
36
|
+
"eslint": "^8.24.0",
|
|
37
|
+
"eslint-plugin-vue": "^9.5.1",
|
|
38
|
+
"prettier": "^2.7.1",
|
|
39
|
+
"vite": "^3.1.3",
|
|
40
|
+
"vue": "^3.2.39"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"verovio": "^3.13.0",
|
|
44
|
+
"vue": "^3.2.39"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@vueuse/core": "^9.6.0",
|
|
48
|
+
"uuid": "^9.0.0"
|
|
49
|
+
}
|
|
50
|
+
}
|