vue-verovio-canvas 1.2.0 → 1.2.2
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/dist/style.css +1 -1
- package/dist/vue-verovio-canvas.js +331 -299
- package/dist/vue-verovio-canvas.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/style.css
CHANGED
|
@@ -1 +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-
|
|
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-77515b2e],*[data-v-77515b2e]:before,*[data-v-77515b2e]:after{box-sizing:border-box}.verovio-container[data-v-77515b2e]{display:flex;flex-direction:column;height:100%}.verovio-canvas[data-v-77515b2e]{position:relative;min-width:100%;min-height:100%}.verovio-canvas-vertical[data-v-77515b2e]{overflow-x:auto}.verovio-canvas-horizontal[data-v-77515b2e]{overflow-y:auto}.verovio-canvas-stage[data-v-77515b2e]{display:flex;justify-content:center;flex-direction:column}.verovio-canvas-status[data-v-77515b2e]{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-77515b2e]{background-color:#fee2e2cc;border-color:#fecaca}
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { ref as h, watch as x, readonly as w, reactive as ie, onMounted as J, onUnmounted as ue, openBlock as _, createElementBlock as I, pushScopeId as le, popScopeId as ce, createElementVNode as M, createVNode as de, toDisplayString as X, createCommentVNode as ve, getCurrentScope as pe, onScopeDispose as ge, unref as O, getCurrentInstance as fe, nextTick as ye, toRefs as me, normalizeClass as W, createBlock as he } from "vue";
|
|
2
|
+
function we(e, t, n, o, a) {
|
|
3
|
+
const s = h(1);
|
|
4
|
+
let u = null;
|
|
5
|
+
x(s, () => {
|
|
6
|
+
y();
|
|
7
7
|
});
|
|
8
|
-
async function
|
|
9
|
-
|
|
8
|
+
async function l() {
|
|
9
|
+
s.value = await d(s.value + 1);
|
|
10
10
|
}
|
|
11
|
-
async function
|
|
12
|
-
|
|
11
|
+
async function r() {
|
|
12
|
+
s.value = await d(s.value - 1);
|
|
13
13
|
}
|
|
14
|
-
async function
|
|
15
|
-
|
|
14
|
+
async function f(v) {
|
|
15
|
+
s.value = await d(v);
|
|
16
16
|
}
|
|
17
|
-
async function d(
|
|
18
|
-
if (!Number.isInteger(Number(
|
|
19
|
-
throw new Error(`Page must be an integer, "${
|
|
20
|
-
return Math.min(Math.max(
|
|
17
|
+
async function d(v) {
|
|
18
|
+
if (!Number.isInteger(Number(v)))
|
|
19
|
+
throw new Error(`Page must be an integer, "${v}" given.`);
|
|
20
|
+
return Math.min(Math.max(v, 1), await e.value.getPageCount());
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
clearTimeout(
|
|
24
|
-
|
|
22
|
+
function y() {
|
|
23
|
+
clearTimeout(u), u = setTimeout(() => {
|
|
24
|
+
g();
|
|
25
25
|
}, 100);
|
|
26
26
|
}
|
|
27
|
-
async function
|
|
28
|
-
|
|
27
|
+
async function g() {
|
|
28
|
+
o.value = !0, await n.promise, s.value = await d(s.value), c(s.value);
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
31
|
-
t.value = await e.value.renderToSVG(
|
|
30
|
+
async function c(v) {
|
|
31
|
+
t.value = await e.value.renderToSVG(v), o.value = !1, a.value = !1;
|
|
32
32
|
}
|
|
33
33
|
return {
|
|
34
|
-
page:
|
|
35
|
-
nextPage:
|
|
36
|
-
prevPage:
|
|
37
|
-
setPage:
|
|
38
|
-
renderCurrentPage:
|
|
34
|
+
page: w(s),
|
|
35
|
+
nextPage: l,
|
|
36
|
+
prevPage: r,
|
|
37
|
+
setPage: f,
|
|
38
|
+
renderCurrentPage: g
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
class
|
|
41
|
+
class k {
|
|
42
42
|
constructor() {
|
|
43
43
|
this.promise = new Promise((t, n) => {
|
|
44
44
|
this.reject = n, this.resolve = t;
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const t =
|
|
48
|
+
function _e(e) {
|
|
49
|
+
const t = ie({
|
|
50
50
|
width: null,
|
|
51
51
|
height: null
|
|
52
52
|
});
|
|
53
53
|
let n = null;
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
const o = new k();
|
|
55
|
+
J(() => {
|
|
56
|
+
a(e.value), o.resolve(e.value);
|
|
57
57
|
});
|
|
58
|
-
function
|
|
59
|
-
|
|
58
|
+
function a(l) {
|
|
59
|
+
l instanceof HTMLElement && (t.width = l.clientWidth, t.height = l.clientHeight, n = new ResizeObserver(([r]) => {
|
|
60
60
|
t.width = r.target.clientWidth, t.height = r.target.clientHeight;
|
|
61
61
|
}));
|
|
62
62
|
}
|
|
63
|
-
async function
|
|
64
|
-
const
|
|
65
|
-
n && n.observe(
|
|
63
|
+
async function s() {
|
|
64
|
+
const l = await o.promise;
|
|
65
|
+
n && n.observe(l);
|
|
66
66
|
}
|
|
67
67
|
async function u() {
|
|
68
|
-
const
|
|
69
|
-
n && n.unobserve(
|
|
68
|
+
const l = await o.promise;
|
|
69
|
+
n && n.unobserve(l);
|
|
70
70
|
}
|
|
71
71
|
return {
|
|
72
|
-
observe:
|
|
72
|
+
observe: s,
|
|
73
73
|
unobserve: u,
|
|
74
|
-
dimensions:
|
|
74
|
+
dimensions: w(t)
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const be = {
|
|
78
78
|
scale: 40,
|
|
79
79
|
pageMarginTop: 0,
|
|
80
80
|
pageMarginRight: 0,
|
|
@@ -83,121 +83,126 @@ const we = {
|
|
|
83
83
|
header: "none",
|
|
84
84
|
footer: "none"
|
|
85
85
|
};
|
|
86
|
-
function
|
|
86
|
+
function Oe(e, t) {
|
|
87
87
|
const {
|
|
88
88
|
url: n,
|
|
89
|
-
data:
|
|
90
|
-
scale:
|
|
91
|
-
viewMode:
|
|
89
|
+
data: o,
|
|
90
|
+
scale: a,
|
|
91
|
+
viewMode: s,
|
|
92
92
|
pageMargin: u,
|
|
93
|
-
options:
|
|
93
|
+
options: l,
|
|
94
94
|
select: r
|
|
95
|
-
} = e,
|
|
96
|
-
let
|
|
97
|
-
const { page:
|
|
98
|
-
|
|
95
|
+
} = e, f = h(null), d = h(!0), y = h(!1), g = h(null), c = h(null), v = new k(), m = new k(), T = h(!0);
|
|
96
|
+
let P = null;
|
|
97
|
+
const { page: S, nextPage: V, prevPage: b, setPage: C, renderCurrentPage: R } = we(
|
|
98
|
+
c,
|
|
99
|
+
f,
|
|
100
|
+
v,
|
|
99
101
|
d,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
s && (i.value = s, i.value.moduleIsReady().then(() => y.resolve()));
|
|
102
|
+
T
|
|
103
|
+
), { observe: j, unobserve: Z, dimensions: L } = _e(t);
|
|
104
|
+
g.value = "Initializing Verovio WebAssembly runtime";
|
|
105
|
+
function ee(i) {
|
|
106
|
+
i && (c.value = i, c.value.moduleIsReady().then(() => m.resolve()));
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}),
|
|
110
|
-
|
|
108
|
+
x([a, l, L, s], () => {
|
|
109
|
+
T.value = !0, oe();
|
|
110
|
+
}), x(o, () => {
|
|
111
|
+
U();
|
|
111
112
|
});
|
|
112
|
-
async function
|
|
113
|
-
await
|
|
113
|
+
async function B() {
|
|
114
|
+
await c.value.setOptions(ne());
|
|
114
115
|
}
|
|
115
|
-
async function
|
|
116
|
-
return await
|
|
116
|
+
async function te(i, ...se) {
|
|
117
|
+
return await v.promise, await c.value[i](...se);
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
-
const
|
|
120
|
-
scale:
|
|
121
|
-
},
|
|
122
|
-
return Object.assign(
|
|
123
|
-
pageWidth: Math.min(Math.max(
|
|
124
|
-
pageHeight: Math.min(Math.max(
|
|
125
|
-
pageMarginTop:
|
|
126
|
-
pageMarginRight:
|
|
127
|
-
pageMarginBottom:
|
|
128
|
-
pageMarginLeft:
|
|
129
|
-
}),
|
|
119
|
+
function ne() {
|
|
120
|
+
const i = Object.assign({}, be, {
|
|
121
|
+
scale: a.value
|
|
122
|
+
}, l.value);
|
|
123
|
+
return Object.assign(i, {
|
|
124
|
+
pageWidth: Math.min(Math.max(L.width * (100 / i.scale), 100), 6e4),
|
|
125
|
+
pageHeight: Math.min(Math.max(L.height * (100 / i.scale), 100), 6e4),
|
|
126
|
+
pageMarginTop: i.pageMarginTop ? i.pageMarginTop : u.value,
|
|
127
|
+
pageMarginRight: i.pageMarginRight ? i.pageMarginRight : u.value,
|
|
128
|
+
pageMarginBottom: i.pageMarginBottom ? i.pageMarginBottom : u.value,
|
|
129
|
+
pageMarginLeft: i.pageMarginLeft ? i.pageMarginLeft : u.value
|
|
130
|
+
}), s.value === "vertical" ? (i.adjustPageHeight = !0, i.pageHeight = 6e4) : s.value === "horizontal" && (i.adjustPageHeight = !0, i.breaks = "none", i.pageWidth = 6e4), i;
|
|
130
131
|
}
|
|
131
|
-
async function
|
|
132
|
-
await
|
|
133
|
-
await
|
|
132
|
+
async function oe() {
|
|
133
|
+
await v.promise, clearTimeout(P), d.value = !0, P = setTimeout(async () => {
|
|
134
|
+
await B(), await c.value.redoLayout(), await R();
|
|
134
135
|
}, 100);
|
|
135
136
|
}
|
|
136
|
-
async function
|
|
137
|
+
async function U() {
|
|
137
138
|
try {
|
|
138
|
-
await
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
} catch (
|
|
142
|
-
|
|
139
|
+
await m.promise, await B();
|
|
140
|
+
const i = await ae();
|
|
141
|
+
g.value = "Load score with verovio", (!r.value || Object.keys(r.value).length !== 0 || Object.getPrototypeOf(r.value) !== Object.prototype) && await c.value.select(r.value), await c.value.loadData(i), v.resolve(), T.value && (g.value = "Render current page with verovio", await R()), j();
|
|
142
|
+
} catch (i) {
|
|
143
|
+
y.value = !0, g.value = `Cannot display score with verovio (${i.message})`, console.error(i);
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
|
-
async function
|
|
146
|
-
if (
|
|
147
|
-
return
|
|
146
|
+
async function ae() {
|
|
147
|
+
if (o.value)
|
|
148
|
+
return o.value;
|
|
148
149
|
if (n.value) {
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
152
|
-
throw new Error(`${
|
|
153
|
-
return await
|
|
150
|
+
g.value = "Fetching score file from server";
|
|
151
|
+
const i = await fetch(n.value);
|
|
152
|
+
if (!i.ok)
|
|
153
|
+
throw new Error(`${i.status} ${i.statusText}`);
|
|
154
|
+
return await i.text();
|
|
154
155
|
}
|
|
155
156
|
throw new Error("Input missing: pass url or data prop");
|
|
156
157
|
}
|
|
157
|
-
async function
|
|
158
|
-
return await
|
|
158
|
+
async function re() {
|
|
159
|
+
return await m.promise, await U();
|
|
159
160
|
}
|
|
160
|
-
return
|
|
161
|
-
|
|
161
|
+
return ue(async () => {
|
|
162
|
+
c.value && await c.value.removeToolkit();
|
|
162
163
|
}), {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
verovioModuleIsReady: m,
|
|
165
|
+
scoreIsReady: v,
|
|
166
|
+
renderedScore: w(f),
|
|
167
|
+
page: w(S),
|
|
168
|
+
isLoading: w(d),
|
|
169
|
+
isError: w(y),
|
|
170
|
+
message: w(g),
|
|
171
|
+
dimensions: w(L),
|
|
172
|
+
callVerovioMethod: te,
|
|
173
|
+
nextPage: V,
|
|
174
|
+
prevPage: b,
|
|
175
|
+
setPage: C,
|
|
176
|
+
load: re,
|
|
177
|
+
setToolkit: ee,
|
|
178
|
+
observe: j,
|
|
179
|
+
unobserve: Z
|
|
175
180
|
};
|
|
176
181
|
}
|
|
177
|
-
const
|
|
182
|
+
const N = (e, t) => {
|
|
178
183
|
const n = e.__vccOpts || e;
|
|
179
|
-
for (const [
|
|
180
|
-
n[
|
|
184
|
+
for (const [o, a] of t)
|
|
185
|
+
n[o] = a;
|
|
181
186
|
return n;
|
|
182
|
-
},
|
|
187
|
+
}, Ie = (e) => (le("data-v-42c50a38"), e = e(), ce(), e), Me = ["width", "height", "stroke"], ke = /* @__PURE__ */ Ie(() => /* @__PURE__ */ M("g", {
|
|
183
188
|
fill: "none",
|
|
184
189
|
"fill-rule": "evenodd"
|
|
185
190
|
}, [
|
|
186
|
-
/* @__PURE__ */
|
|
191
|
+
/* @__PURE__ */ M("g", {
|
|
187
192
|
transform: "translate(1 1)",
|
|
188
193
|
"stroke-width": "2"
|
|
189
194
|
}, [
|
|
190
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ M("circle", {
|
|
191
196
|
"stroke-opacity": ".25",
|
|
192
197
|
cx: "18",
|
|
193
198
|
cy: "18",
|
|
194
199
|
r: "18"
|
|
195
200
|
}),
|
|
196
|
-
/* @__PURE__ */
|
|
201
|
+
/* @__PURE__ */ M("path", { d: "M36 18c0-9.94-8.06-18-18-18" })
|
|
197
202
|
])
|
|
198
|
-
], -1)),
|
|
199
|
-
|
|
200
|
-
],
|
|
203
|
+
], -1)), Te = [
|
|
204
|
+
ke
|
|
205
|
+
], Pe = {
|
|
201
206
|
__name: "LoadingSpinner",
|
|
202
207
|
props: {
|
|
203
208
|
color: {
|
|
@@ -210,25 +215,25 @@ const R = (e, t) => {
|
|
|
210
215
|
}
|
|
211
216
|
},
|
|
212
217
|
setup(e) {
|
|
213
|
-
return (t, n) => (_(),
|
|
218
|
+
return (t, n) => (_(), I("svg", {
|
|
214
219
|
class: "loading-spinner",
|
|
215
220
|
viewBox: "0 0 38 38",
|
|
216
221
|
xmlns: "http://www.w3.org/2000/svg",
|
|
217
222
|
width: e.size,
|
|
218
223
|
height: e.size,
|
|
219
224
|
stroke: e.color
|
|
220
|
-
},
|
|
225
|
+
}, Te, 8, Me));
|
|
221
226
|
}
|
|
222
|
-
},
|
|
223
|
-
const
|
|
227
|
+
}, xe = /* @__PURE__ */ N(Pe, [["__scopeId", "data-v-42c50a38"]]);
|
|
228
|
+
const Se = { class: "loading-component" }, Ce = { class: "loading-component-inner" }, Re = { class: "loading-component-spinner" }, Le = {
|
|
224
229
|
key: 0,
|
|
225
230
|
class: "loading-component-message"
|
|
226
|
-
},
|
|
231
|
+
}, Ee = {
|
|
227
232
|
__name: "Loading",
|
|
228
233
|
props: {
|
|
229
234
|
message: {
|
|
230
235
|
type: String,
|
|
231
|
-
default: "Loading
|
|
236
|
+
default: "Loading…"
|
|
232
237
|
},
|
|
233
238
|
showMessage: {
|
|
234
239
|
type: Boolean,
|
|
@@ -244,94 +249,90 @@ const Te = { class: "loading-component" }, xe = { class: "loading-component-inne
|
|
|
244
249
|
}
|
|
245
250
|
},
|
|
246
251
|
setup(e) {
|
|
247
|
-
return (t, n) => (_(),
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
252
|
+
return (t, n) => (_(), I("div", Se, [
|
|
253
|
+
M("div", Ce, [
|
|
254
|
+
M("div", Re, [
|
|
255
|
+
de(xe, {
|
|
251
256
|
size: e.spinnerSize,
|
|
252
257
|
stroke: e.spinnerColor
|
|
253
258
|
}, null, 8, ["size", "stroke"])
|
|
254
259
|
]),
|
|
255
|
-
e.showMessage ? (_(),
|
|
260
|
+
e.showMessage ? (_(), I("div", Le, X(e.message), 1)) : ve("", !0)
|
|
256
261
|
])
|
|
257
262
|
]));
|
|
258
263
|
}
|
|
259
|
-
},
|
|
260
|
-
var
|
|
261
|
-
const
|
|
264
|
+
}, Ve = /* @__PURE__ */ N(Ee, [["__scopeId", "data-v-956ec44e"]]);
|
|
265
|
+
var $;
|
|
266
|
+
const Y = typeof window < "u", z = () => {
|
|
262
267
|
};
|
|
263
|
-
|
|
264
|
-
function
|
|
265
|
-
return typeof e == "function" ? e() :
|
|
268
|
+
Y && (($ = window == null ? void 0 : window.navigator) != null && $.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
269
|
+
function ze(e) {
|
|
270
|
+
return typeof e == "function" ? e() : O(e);
|
|
266
271
|
}
|
|
267
|
-
function
|
|
272
|
+
function Ne(e) {
|
|
268
273
|
return e;
|
|
269
274
|
}
|
|
270
|
-
function
|
|
271
|
-
return
|
|
275
|
+
function je(e) {
|
|
276
|
+
return pe() ? (ge(e), !0) : !1;
|
|
272
277
|
}
|
|
273
|
-
function
|
|
274
|
-
|
|
278
|
+
function Be(e, t = !0) {
|
|
279
|
+
fe() ? J(e) : t ? e() : ye(e);
|
|
275
280
|
}
|
|
276
|
-
function
|
|
281
|
+
function D(e) {
|
|
277
282
|
var t;
|
|
278
|
-
const n =
|
|
283
|
+
const n = ze(e);
|
|
279
284
|
return (t = n == null ? void 0 : n.$el) != null ? t : n;
|
|
280
285
|
}
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
function Ue(e, t = !1) {
|
|
286
|
-
const n = w(), a = () => n.value = Boolean(e());
|
|
287
|
-
return a(), Ne(a, t), n;
|
|
286
|
+
const Ue = Y ? window : void 0;
|
|
287
|
+
function We(e, t = !1) {
|
|
288
|
+
const n = h(), o = () => n.value = !!e();
|
|
289
|
+
return o(), Be(o, t), n;
|
|
288
290
|
}
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
function Be(e, t, n = {}) {
|
|
291
|
+
const H = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Q = "__vueuse_ssr_handlers__";
|
|
292
|
+
H[Q] = H[Q] || {};
|
|
293
|
+
function $e(e, t, n = {}) {
|
|
293
294
|
const {
|
|
294
|
-
root:
|
|
295
|
-
rootMargin:
|
|
296
|
-
threshold:
|
|
297
|
-
window: u =
|
|
298
|
-
} = n,
|
|
299
|
-
let r =
|
|
300
|
-
const
|
|
301
|
-
el:
|
|
302
|
-
root:
|
|
303
|
-
}), ({ el:
|
|
304
|
-
if (r(), !
|
|
295
|
+
root: o,
|
|
296
|
+
rootMargin: a = "0px",
|
|
297
|
+
threshold: s = 0.1,
|
|
298
|
+
window: u = Ue
|
|
299
|
+
} = n, l = We(() => u && "IntersectionObserver" in u);
|
|
300
|
+
let r = z;
|
|
301
|
+
const f = l.value ? x(() => ({
|
|
302
|
+
el: D(e),
|
|
303
|
+
root: D(o)
|
|
304
|
+
}), ({ el: y, root: g }) => {
|
|
305
|
+
if (r(), !y)
|
|
305
306
|
return;
|
|
306
|
-
const
|
|
307
|
-
root:
|
|
308
|
-
rootMargin:
|
|
309
|
-
threshold:
|
|
307
|
+
const c = new IntersectionObserver(t, {
|
|
308
|
+
root: g,
|
|
309
|
+
rootMargin: a,
|
|
310
|
+
threshold: s
|
|
310
311
|
});
|
|
311
|
-
|
|
312
|
-
|
|
312
|
+
c.observe(y), r = () => {
|
|
313
|
+
c.disconnect(), r = z;
|
|
313
314
|
};
|
|
314
|
-
}, { immediate: !0, flush: "post" }) :
|
|
315
|
-
r(),
|
|
315
|
+
}, { immediate: !0, flush: "post" }) : z, d = () => {
|
|
316
|
+
r(), f();
|
|
316
317
|
};
|
|
317
|
-
return
|
|
318
|
-
isSupported:
|
|
319
|
-
stop:
|
|
318
|
+
return je(d), {
|
|
319
|
+
isSupported: l,
|
|
320
|
+
stop: d
|
|
320
321
|
};
|
|
321
322
|
}
|
|
322
|
-
var
|
|
323
|
+
var q;
|
|
323
324
|
(function(e) {
|
|
324
325
|
e.UP = "UP", e.RIGHT = "RIGHT", e.DOWN = "DOWN", e.LEFT = "LEFT", e.NONE = "NONE";
|
|
325
|
-
})(
|
|
326
|
-
var
|
|
326
|
+
})(q || (q = {}));
|
|
327
|
+
var De = Object.defineProperty, A = Object.getOwnPropertySymbols, He = Object.prototype.hasOwnProperty, Qe = Object.prototype.propertyIsEnumerable, G = (e, t, n) => t in e ? De(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, qe = (e, t) => {
|
|
327
328
|
for (var n in t || (t = {}))
|
|
328
|
-
|
|
329
|
-
if (
|
|
330
|
-
for (var n of
|
|
331
|
-
|
|
329
|
+
He.call(t, n) && G(e, n, t[n]);
|
|
330
|
+
if (A)
|
|
331
|
+
for (var n of A(t))
|
|
332
|
+
Qe.call(t, n) && G(e, n, t[n]);
|
|
332
333
|
return e;
|
|
333
334
|
};
|
|
334
|
-
const
|
|
335
|
+
const Ae = {
|
|
335
336
|
easeInSine: [0.12, 0, 0.39, 0],
|
|
336
337
|
easeOutSine: [0.61, 1, 0.88, 1],
|
|
337
338
|
easeInOutSine: [0.37, 0, 0.63, 1],
|
|
@@ -357,15 +358,14 @@ const Qe = {
|
|
|
357
358
|
easeOutBack: [0.34, 1.56, 0.64, 1],
|
|
358
359
|
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
|
|
359
360
|
};
|
|
360
|
-
|
|
361
|
-
linear:
|
|
362
|
-
},
|
|
363
|
-
const
|
|
361
|
+
qe({
|
|
362
|
+
linear: Ne
|
|
363
|
+
}, Ae);
|
|
364
|
+
const Ge = { class: "verovio-container" }, Fe = ["textContent"], Ke = ["innerHTML"], Je = {
|
|
364
365
|
__name: "VerovioCanvas",
|
|
365
366
|
props: {
|
|
366
367
|
toolkit: {
|
|
367
|
-
type: Object
|
|
368
|
-
required: !0
|
|
368
|
+
type: Object
|
|
369
369
|
},
|
|
370
370
|
url: {
|
|
371
371
|
type: String,
|
|
@@ -407,174 +407,206 @@ const qe = { class: "verovio-container" }, Ae = ["textContent"], Ge = ["innerHTM
|
|
|
407
407
|
lazy: {
|
|
408
408
|
type: Boolean,
|
|
409
409
|
default: !1
|
|
410
|
+
},
|
|
411
|
+
unload: {
|
|
412
|
+
type: Boolean,
|
|
413
|
+
default: !1
|
|
414
|
+
},
|
|
415
|
+
lazyDelay: {
|
|
416
|
+
type: Number,
|
|
417
|
+
default: 0
|
|
410
418
|
}
|
|
411
419
|
},
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
420
|
+
emits: ["moduleIsReady", "scoreIsReady", "load", "unload"],
|
|
421
|
+
setup(e, { expose: t, emit: n }) {
|
|
422
|
+
const o = e, a = h(null), {
|
|
423
|
+
isLoading: s,
|
|
424
|
+
isError: u,
|
|
425
|
+
renderedScore: l,
|
|
426
|
+
message: r,
|
|
427
|
+
dimensions: f,
|
|
419
428
|
page: d,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
+
verovioModuleIsReady: y,
|
|
430
|
+
scoreIsReady: g,
|
|
431
|
+
callVerovioMethod: c,
|
|
432
|
+
nextPage: v,
|
|
433
|
+
prevPage: m,
|
|
434
|
+
setPage: T,
|
|
435
|
+
load: P,
|
|
436
|
+
setToolkit: S,
|
|
437
|
+
unobserve: V
|
|
438
|
+
} = Oe(me(o), a);
|
|
439
|
+
if (y.promise.then(() => {
|
|
440
|
+
n("moduleIsReady", {
|
|
441
|
+
callVerovioMethod: c
|
|
442
|
+
});
|
|
443
|
+
}), g.promise.then(() => {
|
|
444
|
+
n("scoreIsReady", {
|
|
445
|
+
callVerovioMethod: c
|
|
446
|
+
});
|
|
447
|
+
}), S(o.toolkit), x(() => o.toolkit, (b) => {
|
|
448
|
+
S(b);
|
|
429
449
|
}), t({
|
|
430
|
-
isLoading:
|
|
431
|
-
dimensions:
|
|
450
|
+
isLoading: s,
|
|
451
|
+
dimensions: f,
|
|
432
452
|
page: d,
|
|
433
|
-
callVerovioMethod:
|
|
434
|
-
nextPage:
|
|
435
|
-
prevPage:
|
|
436
|
-
setPage:
|
|
437
|
-
}),
|
|
438
|
-
|
|
439
|
-
|
|
453
|
+
callVerovioMethod: c,
|
|
454
|
+
nextPage: v,
|
|
455
|
+
prevPage: m,
|
|
456
|
+
setPage: T
|
|
457
|
+
}), o.lazy) {
|
|
458
|
+
let b = null;
|
|
459
|
+
const { stop: C } = $e(a, ([{ isIntersecting: R }]) => {
|
|
460
|
+
R === !0 ? b = setTimeout(() => {
|
|
461
|
+
n("load"), P(), o.unload || C();
|
|
462
|
+
}, o.lazyDelay) : o.unload && (clearTimeout(b), V(), n("unload"));
|
|
440
463
|
});
|
|
441
464
|
} else
|
|
442
|
-
|
|
443
|
-
return (
|
|
444
|
-
|
|
445
|
-
class:
|
|
465
|
+
n("load"), P();
|
|
466
|
+
return (b, C) => (_(), I("div", Ge, [
|
|
467
|
+
M("div", {
|
|
468
|
+
class: W(["verovio-canvas", `verovio-canvas-${e.viewMode}`]),
|
|
446
469
|
ref_key: "verovioCanvas",
|
|
447
470
|
ref: a
|
|
448
471
|
}, [
|
|
449
|
-
|
|
472
|
+
O(l) === null ? (_(), I("div", {
|
|
450
473
|
key: 0,
|
|
451
|
-
class:
|
|
474
|
+
class: W(["verovio-canvas-status", { "verovio-canvas-status-error": O(u) }])
|
|
452
475
|
}, [
|
|
453
|
-
|
|
476
|
+
O(u) ? (_(), I("div", {
|
|
454
477
|
key: 1,
|
|
455
478
|
class: "verovio-canvas-status-error-message",
|
|
456
|
-
textContent:
|
|
457
|
-
}, null, 8,
|
|
479
|
+
textContent: X(O(r))
|
|
480
|
+
}, null, 8, Fe)) : (_(), he(Ve, {
|
|
458
481
|
key: 0,
|
|
459
|
-
message:
|
|
482
|
+
message: O(r)
|
|
460
483
|
}, null, 8, ["message"]))
|
|
461
|
-
], 2)) : (_(),
|
|
484
|
+
], 2)) : (_(), I("div", {
|
|
462
485
|
key: 1,
|
|
463
486
|
class: "verovio-canvas-stage",
|
|
464
|
-
innerHTML:
|
|
465
|
-
}, null, 8,
|
|
487
|
+
innerHTML: O(l)
|
|
488
|
+
}, null, 8, Ke))
|
|
466
489
|
], 2)
|
|
467
490
|
]));
|
|
468
491
|
}
|
|
469
|
-
},
|
|
470
|
-
function
|
|
492
|
+
}, nt = /* @__PURE__ */ N(Je, [["__scopeId", "data-v-77515b2e"]]);
|
|
493
|
+
function ot(e) {
|
|
471
494
|
return new Proxy({}, {
|
|
472
|
-
get: (t, n) => (...
|
|
473
|
-
const
|
|
495
|
+
get: (t, n) => (...o) => {
|
|
496
|
+
const a = new k(), s = e[n];
|
|
474
497
|
let u;
|
|
475
|
-
return
|
|
498
|
+
return s && (u = s.apply(e, o || [])), a.resolve(u), a.promise;
|
|
476
499
|
}
|
|
477
500
|
});
|
|
478
501
|
}
|
|
479
|
-
let
|
|
480
|
-
const
|
|
481
|
-
function
|
|
482
|
-
if (!
|
|
502
|
+
let E;
|
|
503
|
+
const Xe = new Uint8Array(16);
|
|
504
|
+
function Ye() {
|
|
505
|
+
if (!E && (E = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !E))
|
|
483
506
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
484
|
-
return
|
|
507
|
+
return E(Xe);
|
|
485
508
|
}
|
|
486
|
-
const
|
|
509
|
+
const p = [];
|
|
487
510
|
for (let e = 0; e < 256; ++e)
|
|
488
|
-
|
|
489
|
-
function
|
|
490
|
-
return (
|
|
511
|
+
p.push((e + 256).toString(16).slice(1));
|
|
512
|
+
function Ze(e, t = 0) {
|
|
513
|
+
return (p[e[t + 0]] + p[e[t + 1]] + p[e[t + 2]] + p[e[t + 3]] + "-" + p[e[t + 4]] + p[e[t + 5]] + "-" + p[e[t + 6]] + p[e[t + 7]] + "-" + p[e[t + 8]] + p[e[t + 9]] + "-" + p[e[t + 10]] + p[e[t + 11]] + p[e[t + 12]] + p[e[t + 13]] + p[e[t + 14]] + p[e[t + 15]]).toLowerCase();
|
|
491
514
|
}
|
|
492
|
-
const
|
|
493
|
-
randomUUID:
|
|
515
|
+
const et = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), F = {
|
|
516
|
+
randomUUID: et
|
|
494
517
|
};
|
|
495
|
-
function
|
|
496
|
-
if (
|
|
497
|
-
return
|
|
518
|
+
function K(e, t, n) {
|
|
519
|
+
if (F.randomUUID && !t && !e)
|
|
520
|
+
return F.randomUUID();
|
|
498
521
|
e = e || {};
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
522
|
+
const o = e.random || (e.rng || Ye)();
|
|
523
|
+
if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, t) {
|
|
501
524
|
n = n || 0;
|
|
502
|
-
for (let
|
|
503
|
-
t[n +
|
|
525
|
+
for (let a = 0; a < 16; ++a)
|
|
526
|
+
t[n + a] = o[a];
|
|
504
527
|
return t;
|
|
505
528
|
}
|
|
506
|
-
return
|
|
529
|
+
return Ze(o);
|
|
507
530
|
}
|
|
508
|
-
function
|
|
509
|
-
const t =
|
|
510
|
-
return e.addEventListener("message", (
|
|
511
|
-
const { id:
|
|
512
|
-
u && (u.resolve(
|
|
531
|
+
function at(e) {
|
|
532
|
+
const t = K(), n = {};
|
|
533
|
+
return e.addEventListener("message", (o) => {
|
|
534
|
+
const { id: a, result: s } = o.data, u = n[a];
|
|
535
|
+
u && (u.resolve(s), delete n[a]);
|
|
513
536
|
}), new Proxy({}, {
|
|
514
|
-
get: (
|
|
515
|
-
const u =
|
|
537
|
+
get: (o, a) => (...s) => {
|
|
538
|
+
const u = K();
|
|
516
539
|
e.postMessage({
|
|
517
540
|
toolkitId: t,
|
|
518
541
|
id: u,
|
|
519
|
-
method:
|
|
520
|
-
args:
|
|
542
|
+
method: a,
|
|
543
|
+
args: s
|
|
521
544
|
});
|
|
522
|
-
const
|
|
523
|
-
return n[u] =
|
|
545
|
+
const l = new k();
|
|
546
|
+
return n[u] = l, l.promise;
|
|
524
547
|
}
|
|
525
548
|
});
|
|
526
549
|
}
|
|
527
|
-
function
|
|
550
|
+
function rt(e, t, n, o) {
|
|
528
551
|
if (typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope) {
|
|
529
|
-
let
|
|
530
|
-
|
|
552
|
+
let l = function(r) {
|
|
553
|
+
a[r] && (a[r].destroy(), delete a[r]);
|
|
531
554
|
};
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
555
|
+
const a = {};
|
|
556
|
+
let s;
|
|
557
|
+
if (typeof e == "function")
|
|
558
|
+
s = e();
|
|
559
|
+
else {
|
|
560
|
+
const r = new k();
|
|
561
|
+
s = r.promise, e.onRuntimeInitialized = function() {
|
|
562
|
+
r.resolve(e);
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
s.then((r) => {
|
|
566
|
+
n && n(o, r);
|
|
535
567
|
});
|
|
536
568
|
async function u(r) {
|
|
537
|
-
if (
|
|
538
|
-
return
|
|
539
|
-
const
|
|
540
|
-
return
|
|
569
|
+
if (a[r])
|
|
570
|
+
return a[r];
|
|
571
|
+
const f = await s;
|
|
572
|
+
return a[r] = new t(f), a[r];
|
|
541
573
|
}
|
|
542
574
|
addEventListener("message", async (r) => {
|
|
543
|
-
const { id:
|
|
544
|
-
if (
|
|
545
|
-
|
|
575
|
+
const { id: f, method: d, args: y, toolkitId: g } = r.data;
|
|
576
|
+
if (d === "moduleIsReady") {
|
|
577
|
+
s.then(() => {
|
|
546
578
|
postMessage({
|
|
547
|
-
id:
|
|
548
|
-
method:
|
|
549
|
-
args:
|
|
579
|
+
id: f,
|
|
580
|
+
method: d,
|
|
581
|
+
args: y,
|
|
550
582
|
result: null
|
|
551
583
|
}, r);
|
|
552
584
|
});
|
|
553
585
|
return;
|
|
554
586
|
}
|
|
555
|
-
if (
|
|
556
|
-
|
|
557
|
-
id:
|
|
558
|
-
method:
|
|
559
|
-
args:
|
|
560
|
-
result: Object.keys(
|
|
587
|
+
if (d === "removeToolkit") {
|
|
588
|
+
l(g), postMessage({
|
|
589
|
+
id: f,
|
|
590
|
+
method: d,
|
|
591
|
+
args: y,
|
|
592
|
+
result: Object.keys(a).length
|
|
561
593
|
}, r);
|
|
562
594
|
return;
|
|
563
595
|
}
|
|
564
|
-
const
|
|
565
|
-
let
|
|
566
|
-
|
|
567
|
-
id:
|
|
568
|
-
method:
|
|
569
|
-
args:
|
|
570
|
-
result:
|
|
596
|
+
const c = await u(g), v = c[d];
|
|
597
|
+
let m;
|
|
598
|
+
v && (m = v.apply(c, y || [])), postMessage({
|
|
599
|
+
id: f,
|
|
600
|
+
method: d,
|
|
601
|
+
args: y,
|
|
602
|
+
result: m
|
|
571
603
|
}, r);
|
|
572
604
|
});
|
|
573
605
|
}
|
|
574
606
|
}
|
|
575
607
|
export {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
608
|
+
nt as VerovioCanvas,
|
|
609
|
+
ot as createAsyncVerovioToolkit,
|
|
610
|
+
rt as createVerovioWorker,
|
|
611
|
+
at as createWorkerVerovioToolkit
|
|
580
612
|
};
|
|
@@ -1 +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 $(e,n,o,r){const a=t.ref(1);let u=null;t.watch(a,()=>{f()});async function c(){a.value=await g(a.value+1)}async function d(){a.value=await g(a.value-1)}async function i(l){a.value=await g(l)}async function g(l){if(!Number.isInteger(Number(l)))throw new Error(`Page must be an integer, "${l}" given.`);return Math.min(Math.max(l,1),await e.value.getPageCount())}function f(){clearTimeout(u),u=setTimeout(()=>{v()},100)}async function v(){r.value=!0,await o.promise,a.value=await g(a.value),m(a.value)}async function m(l){n.value=await e.value.renderToSVG(l),r.value=!1}return{page:t.readonly(a),nextPage:c,prevPage:d,setPage:i,renderCurrentPage:v}}class k{constructor(){this.promise=new Promise((n,o)=>{this.reject=o,this.resolve=n})}}function W(e){const n=t.reactive({width:null,height:null});let o=null;const r=new k;t.onMounted(()=>{a(e.value),r.resolve(e.value)});function a(d){d instanceof HTMLElement&&(n.width=d.clientWidth,n.height=d.clientHeight,o=new ResizeObserver(([i])=>{n.width=i.target.clientWidth,n.height=i.target.clientHeight}))}async function u(){const d=await r.promise;o&&o.observe(d)}async function c(){const d=await r.promise;o&&o.unobserve(d)}return{observe:u,unobserve:c,dimensions:t.readonly(n)}}const D={scale:40,pageMarginTop:0,pageMarginRight:0,pageMarginBottom:0,pageMarginLeft:0,header:"none",footer:"none"};function H(e,n){const{url:o,data:r,scale:a,viewMode:u,pageMargin:c,options:d,select:i}=e,g=t.ref(null),f=t.ref(!0),v=t.ref(!1),m=t.ref(null),l=t.ref(null),h=new k,w=new k;let _=null;const{page:b,nextPage:_e,prevPage:ke,setPage:Oe,renderCurrentPage:z}=$(l,g,h,f),{observe:Me,dimensions:I}=W(n);m.value="Initializing Verovio WebAssembly runtime";function be(s){s&&(l.value=s,l.value.moduleIsReady().then(()=>w.resolve()))}t.watch([a,d,I,u],()=>{Ve()}),t.watch(r,()=>{U()});async function j(){await l.value.setOptions(Te())}async function Ie(s,...Ee){return await h.promise,await l.value[s](...Ee)}function Te(){const s=Object.assign({},D,{scale:a.value},d.value);return Object.assign(s,{pageWidth:Math.min(Math.max(I.width*(100/s.scale),100),6e4),pageHeight:Math.min(Math.max(I.height*(100/s.scale),100),6e4),pageMarginTop:s.pageMarginTop?s.pageMarginTop:c.value,pageMarginRight:s.pageMarginRight?s.pageMarginRight:c.value,pageMarginBottom:s.pageMarginBottom?s.pageMarginBottom:c.value,pageMarginLeft:s.pageMarginLeft?s.pageMarginLeft:c.value}),u.value==="vertical"?(s.adjustPageHeight=!0,s.pageHeight=6e4):u.value==="horizontal"&&(s.adjustPageHeight=!0,s.breaks="none",s.pageWidth=6e4),s}async function Ve(){await h.promise,clearTimeout(_),f.value=!0,_=setTimeout(async()=>{await j(),await l.value.redoLayout(),await z()},100)}async function U(){try{await w.promise,await j();const s=await Pe();m.value="Load score with verovio",(!i.value||Object.keys(i.value).length!==0||Object.getPrototypeOf(i.value)!==Object.prototype)&&await l.value.select(i.value),await l.value.loadData(s),h.resolve(),m.value="Render current page with verovio",await z(),Me()}catch(s){v.value=!0,m.value=`Cannot display score with verovio (${s.message})`,console.error(s)}}async function Pe(){if(r.value)return r.value;if(o.value){m.value="Fetching score file from server";const s=await fetch(o.value);if(!s.ok)throw new Error(`${s.status} ${s.statusText}`);return await s.text()}throw new Error("Input missing: pass url or data prop")}async function Se(){return await w.promise,await U()}return t.onUnmounted(async()=>{l.value&&await l.value.removeToolkit()}),{renderedScore:t.readonly(g),page:t.readonly(b),isLoading:t.readonly(f),isError:t.readonly(v),message:t.readonly(m),dimensions:t.readonly(I),callVerovioMethod:Ie,nextPage:_e,prevPage:ke,setPage:Oe,load:Se,setToolkit:be}}const xe="",T=(e,n)=>{const o=e.__vccOpts||e;for(const[r,a]of n)o[r]=a;return o},q=e=>(t.pushScopeId("data-v-42c50a38"),e=e(),t.popScopeId(),e),Q=["width","height","stroke"],A=[q(()=>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))],G=T({__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},A,8,Q))}},[["__scopeId","data-v-42c50a38"]]),Le="",F={class:"loading-component"},K={class:"loading-component-inner"},J={class:"loading-component-spinner"},X={key:0,class:"loading-component-message"},Y=T({__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",F,[t.createElementVNode("div",K,[t.createElementVNode("div",J,[t.createVNode(G,{size:e.spinnerSize,stroke:e.spinnerColor},null,8,["size","stroke"])]),e.showMessage?(t.openBlock(),t.createElementBlock("div",X,t.toDisplayString(e.message),1)):t.createCommentVNode("",!0)])]))}},[["__scopeId","data-v-956ec44e"]]);var E;const O=typeof window<"u",V=()=>{};O&&((E=window==null?void 0:window.navigator)==null?void 0:E.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function Z(e){return typeof e=="function"?e():t.unref(e)}function ee(e){return e}function te(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function ne(e,n=!0){t.getCurrentInstance()?t.onMounted(e):n?e():t.nextTick(e)}function x(e){var n;const o=Z(e);return(n=o==null?void 0:o.$el)!=null?n:o}const oe=O?window:void 0;O&&window.document,O&&window.navigator,O&&window.location;function ae(e,n=!1){const o=t.ref(),r=()=>o.value=Boolean(e());return r(),ne(r,n),o}const P=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},S="__vueuse_ssr_handlers__";P[S]=P[S]||{},P[S];function re(e,n,o={}){const{root:r,rootMargin:a="0px",threshold:u=.1,window:c=oe}=o,d=ae(()=>c&&"IntersectionObserver"in c);let i=V;const g=d.value?t.watch(()=>({el:x(e),root:x(r)}),({el:v,root:m})=>{if(i(),!v)return;const l=new IntersectionObserver(n,{root:m,rootMargin:a,threshold:u});l.observe(v),i=()=>{l.disconnect(),i=V}},{immediate:!0,flush:"post"}):V,f=()=>{i(),g()};return te(f),{isSupported:d,stop:f}}var C;(function(e){e.UP="UP",e.RIGHT="RIGHT",e.DOWN="DOWN",e.LEFT="LEFT",e.NONE="NONE"})(C||(C={}));var ie=Object.defineProperty,B=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,L=(e,n,o)=>n in e?ie(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,ce=(e,n)=>{for(var o in n||(n={}))se.call(n,o)&&L(e,o,n[o]);if(B)for(var o of B(n))le.call(n,o)&&L(e,o,n[o]);return e};ce({linear:ee},{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 ze="",ue={class:"verovio-container"},de=["textContent"],pe=["innerHTML"],ge=T({__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:u,renderedScore:c,message:d,dimensions:i,page:g,callVerovioMethod:f,nextPage:v,prevPage:m,setPage:l,load:h,setToolkit:w}=H(t.toRefs(o),r);if(w(o.toolkit),t.watch(()=>o.toolkit,_=>{w(_)}),n({isLoading:a,dimensions:i,page:g,callVerovioMethod:f,nextPage:v,prevPage:m,setPage:l}),o.lazy){const{stop:_}=re(r,([{isIntersecting:b}])=>{b===!0&&(h(),_())})}else h();return(_,b)=>(t.openBlock(),t.createElementBlock("div",ue,[t.createElementVNode("div",{class:t.normalizeClass(["verovio-canvas",`verovio-canvas-${e.viewMode}`]),ref_key:"verovioCanvas",ref:r},[t.unref(c)===null?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["verovio-canvas-status",{"verovio-canvas-status-error":t.unref(u)}])},[t.unref(u)?(t.openBlock(),t.createElementBlock("div",{key:1,class:"verovio-canvas-status-error-message",textContent:t.toDisplayString(t.unref(d))},null,8,de)):(t.openBlock(),t.createBlock(Y,{key:0,message:t.unref(d)},null,8,["message"]))],2)):(t.openBlock(),t.createElementBlock("div",{key:1,class:"verovio-canvas-stage",innerHTML:t.unref(c)},null,8,pe))],2)]))}},[["__scopeId","data-v-fe9d8882"]]);function fe(e){return new Proxy({},{get:(n,o)=>(...r)=>{const a=new k,u=e[o];let c;return u&&(c=u.apply(e,r||[])),a.resolve(c),a.promise}})}let M;const ve=new Uint8Array(16);function me(){if(!M&&(M=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!M))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return M(ve)}const p=[];for(let e=0;e<256;++e)p.push((e+256).toString(16).slice(1));function ye(e,n=0){return(p[e[n+0]]+p[e[n+1]]+p[e[n+2]]+p[e[n+3]]+"-"+p[e[n+4]]+p[e[n+5]]+"-"+p[e[n+6]]+p[e[n+7]]+"-"+p[e[n+8]]+p[e[n+9]]+"-"+p[e[n+10]]+p[e[n+11]]+p[e[n+12]]+p[e[n+13]]+p[e[n+14]]+p[e[n+15]]).toLowerCase()}const N={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function R(e,n,o){if(N.randomUUID&&!n&&!e)return N.randomUUID();e=e||{};const r=e.random||(e.rng||me)();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 ye(r)}function he(e){const n=R(),o={};return e.addEventListener("message",r=>{const{id:a,result:u}=r.data,c=o[a];c&&(c.resolve(u),delete o[a])}),new Proxy({},{get:(r,a)=>(...u)=>{const c=R();e.postMessage({toolkitId:n,id:c,method:a,args:u});const d=new k;return o[c]=d,d.promise}})}function we(e,n,o,r){if(typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope){let d=function(i){a[i]&&(a[i].destroy(),delete a[i])};const a={},u=e();u.then(i=>{o&&o(r,i)});async function c(i){if(a[i])return a[i];const g=await u;return a[i]=new n(g),a[i]}addEventListener("message",async i=>{const{id:g,method:f,args:v,toolkitId:m}=i.data;if(f==="moduleIsReady"){u.then(()=>{postMessage({id:g,method:f,args:v,result:null},i)});return}if(f==="removeToolkit"){d(m),postMessage({id:g,method:f,args:v,result:Object.keys(a).length},i);return}const l=await c(m),h=l[f];let w;h&&(w=h.apply(l,v||[])),postMessage({id:g,method:f,args:v,result:w},i)})}}y.VerovioCanvas=ge,y.createAsyncVerovioToolkit=fe,y.createVerovioWorker=we,y.createWorkerVerovioToolkit=he,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(h,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(h=typeof globalThis<"u"?globalThis:h||self,t(h.VueVerovioCanvas={},h.Vue))})(this,function(h,t){"use strict";function q(e,n,o,a,r){const i=t.ref(1);let c=null;t.watch(i,()=>{y()});async function u(){i.value=await p(i.value+1)}async function s(){i.value=await p(i.value-1)}async function m(g){i.value=await p(g)}async function p(g){if(!Number.isInteger(Number(g)))throw new Error(`Page must be an integer, "${g}" given.`);return Math.min(Math.max(g,1),await e.value.getPageCount())}function y(){clearTimeout(c),c=setTimeout(()=>{v()},100)}async function v(){a.value=!0,await o.promise,i.value=await p(i.value),d(i.value)}async function d(g){n.value=await e.value.renderToSVG(g),a.value=!1,r.value=!1}return{page:t.readonly(i),nextPage:u,prevPage:s,setPage:m,renderCurrentPage:v}}class k{constructor(){this.promise=new Promise((n,o)=>{this.reject=o,this.resolve=n})}}function A(e){const n=t.reactive({width:null,height:null});let o=null;const a=new k;t.onMounted(()=>{r(e.value),a.resolve(e.value)});function r(u){u instanceof HTMLElement&&(n.width=u.clientWidth,n.height=u.clientHeight,o=new ResizeObserver(([s])=>{n.width=s.target.clientWidth,n.height=s.target.clientHeight}))}async function i(){const u=await a.promise;o&&o.observe(u)}async function c(){const u=await a.promise;o&&o.unobserve(u)}return{observe:i,unobserve:c,dimensions:t.readonly(n)}}const G={scale:40,pageMarginTop:0,pageMarginRight:0,pageMarginBottom:0,pageMarginLeft:0,header:"none",footer:"none"};function F(e,n){const{url:o,data:a,scale:r,viewMode:i,pageMargin:c,options:u,select:s}=e,m=t.ref(null),p=t.ref(!0),y=t.ref(!1),v=t.ref(null),d=t.ref(null),g=new k,_=new k,b=t.ref(!0);let O=null;const{page:M,nextPage:x,prevPage:w,setPage:T,renderCurrentPage:P}=q(d,m,g,p,b),{observe:D,unobserve:Me,dimensions:S}=A(n);v.value="Initializing Verovio WebAssembly runtime";function Te(l){l&&(d.value=l,d.value.moduleIsReady().then(()=>_.resolve()))}t.watch([r,u,S,i],()=>{b.value=!0,Ve()}),t.watch(a,()=>{Q()});async function H(){await d.value.setOptions(Se())}async function Pe(l,...Ce){return await g.promise,await d.value[l](...Ce)}function Se(){const l=Object.assign({},G,{scale:r.value},u.value);return Object.assign(l,{pageWidth:Math.min(Math.max(S.width*(100/l.scale),100),6e4),pageHeight:Math.min(Math.max(S.height*(100/l.scale),100),6e4),pageMarginTop:l.pageMarginTop?l.pageMarginTop:c.value,pageMarginRight:l.pageMarginRight?l.pageMarginRight:c.value,pageMarginBottom:l.pageMarginBottom?l.pageMarginBottom:c.value,pageMarginLeft:l.pageMarginLeft?l.pageMarginLeft:c.value}),i.value==="vertical"?(l.adjustPageHeight=!0,l.pageHeight=6e4):i.value==="horizontal"&&(l.adjustPageHeight=!0,l.breaks="none",l.pageWidth=6e4),l}async function Ve(){await g.promise,clearTimeout(O),p.value=!0,O=setTimeout(async()=>{await H(),await d.value.redoLayout(),await P()},100)}async function Q(){try{await _.promise,await H();const l=await Ee();v.value="Load score with verovio",(!s.value||Object.keys(s.value).length!==0||Object.getPrototypeOf(s.value)!==Object.prototype)&&await d.value.select(s.value),await d.value.loadData(l),g.resolve(),b.value&&(v.value="Render current page with verovio",await P()),D()}catch(l){y.value=!0,v.value=`Cannot display score with verovio (${l.message})`,console.error(l)}}async function Ee(){if(a.value)return a.value;if(o.value){v.value="Fetching score file from server";const l=await fetch(o.value);if(!l.ok)throw new Error(`${l.status} ${l.statusText}`);return await l.text()}throw new Error("Input missing: pass url or data prop")}async function xe(){return await _.promise,await Q()}return t.onUnmounted(async()=>{d.value&&await d.value.removeToolkit()}),{verovioModuleIsReady:_,scoreIsReady:g,renderedScore:t.readonly(m),page:t.readonly(M),isLoading:t.readonly(p),isError:t.readonly(y),message:t.readonly(v),dimensions:t.readonly(S),callVerovioMethod:Pe,nextPage:x,prevPage:w,setPage:T,load:xe,setToolkit:Te,observe:D,unobserve:Me}}const Be="",V=(e,n)=>{const o=e.__vccOpts||e;for(const[a,r]of n)o[a]=r;return o},K=e=>(t.pushScopeId("data-v-42c50a38"),e=e(),t.popScopeId(),e),J=["width","height","stroke"],X=[K(()=>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))],Y=V({__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},X,8,J))}},[["__scopeId","data-v-42c50a38"]]),Ne="",Z={class:"loading-component"},ee={class:"loading-component-inner"},te={class:"loading-component-spinner"},ne={key:0,class:"loading-component-message"},oe=V({__name:"Loading",props:{message:{type:String,default:"Loading…"},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",Z,[t.createElementVNode("div",ee,[t.createElementVNode("div",te,[t.createVNode(Y,{size:e.spinnerSize,stroke:e.spinnerColor},null,8,["size","stroke"])]),e.showMessage?(t.openBlock(),t.createElementBlock("div",ne,t.toDisplayString(e.message),1)):t.createCommentVNode("",!0)])]))}},[["__scopeId","data-v-956ec44e"]]);var C;const B=typeof window<"u",E=()=>{};B&&((C=window==null?void 0:window.navigator)!=null&&C.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function ae(e){return typeof e=="function"?e():t.unref(e)}function re(e){return e}function se(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function ie(e,n=!0){t.getCurrentInstance()?t.onMounted(e):n?e():t.nextTick(e)}function R(e){var n;const o=ae(e);return(n=o==null?void 0:o.$el)!=null?n:o}const le=B?window:void 0;function ce(e,n=!1){const o=t.ref(),a=()=>o.value=!!e();return a(),ie(a,n),o}const L=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},N="__vueuse_ssr_handlers__";L[N]=L[N]||{};function ue(e,n,o={}){const{root:a,rootMargin:r="0px",threshold:i=.1,window:c=le}=o,u=ce(()=>c&&"IntersectionObserver"in c);let s=E;const m=u.value?t.watch(()=>({el:R(e),root:R(a)}),({el:y,root:v})=>{if(s(),!y)return;const d=new IntersectionObserver(n,{root:v,rootMargin:r,threshold:i});d.observe(y),s=()=>{d.disconnect(),s=E}},{immediate:!0,flush:"post"}):E,p=()=>{s(),m()};return se(p),{isSupported:u,stop:p}}var z;(function(e){e.UP="UP",e.RIGHT="RIGHT",e.DOWN="DOWN",e.LEFT="LEFT",e.NONE="NONE"})(z||(z={}));var de=Object.defineProperty,j=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,U=(e,n,o)=>n in e?de(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,fe=(e,n)=>{for(var o in n||(n={}))pe.call(n,o)&&U(e,o,n[o]);if(j)for(var o of j(n))ge.call(n,o)&&U(e,o,n[o]);return e};fe({linear:re},{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 Ue="",ve={class:"verovio-container"},me=["textContent"],ye=["innerHTML"],he=V({__name:"VerovioCanvas",props:{toolkit:{type:Object},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},unload:{type:Boolean,default:!1},lazyDelay:{type:Number,default:0}},emits:["moduleIsReady","scoreIsReady","load","unload"],setup(e,{expose:n,emit:o}){const a=e,r=t.ref(null),{isLoading:i,isError:c,renderedScore:u,message:s,dimensions:m,page:p,verovioModuleIsReady:y,scoreIsReady:v,callVerovioMethod:d,nextPage:g,prevPage:_,setPage:b,load:O,setToolkit:M,unobserve:x}=F(t.toRefs(a),r);if(y.promise.then(()=>{o("moduleIsReady",{callVerovioMethod:d})}),v.promise.then(()=>{o("scoreIsReady",{callVerovioMethod:d})}),M(a.toolkit),t.watch(()=>a.toolkit,w=>{M(w)}),n({isLoading:i,dimensions:m,page:p,callVerovioMethod:d,nextPage:g,prevPage:_,setPage:b}),a.lazy){let w=null;const{stop:T}=ue(r,([{isIntersecting:P}])=>{P===!0?w=setTimeout(()=>{o("load"),O(),a.unload||T()},a.lazyDelay):a.unload&&(clearTimeout(w),x(),o("unload"))})}else o("load"),O();return(w,T)=>(t.openBlock(),t.createElementBlock("div",ve,[t.createElementVNode("div",{class:t.normalizeClass(["verovio-canvas",`verovio-canvas-${e.viewMode}`]),ref_key:"verovioCanvas",ref:r},[t.unref(u)===null?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["verovio-canvas-status",{"verovio-canvas-status-error":t.unref(c)}])},[t.unref(c)?(t.openBlock(),t.createElementBlock("div",{key:1,class:"verovio-canvas-status-error-message",textContent:t.toDisplayString(t.unref(s))},null,8,me)):(t.openBlock(),t.createBlock(oe,{key:0,message:t.unref(s)},null,8,["message"]))],2)):(t.openBlock(),t.createElementBlock("div",{key:1,class:"verovio-canvas-stage",innerHTML:t.unref(u)},null,8,ye))],2)]))}},[["__scopeId","data-v-77515b2e"]]);function _e(e){return new Proxy({},{get:(n,o)=>(...a)=>{const r=new k,i=e[o];let c;return i&&(c=i.apply(e,a||[])),r.resolve(c),r.promise}})}let I;const we=new Uint8Array(16);function ke(){if(!I&&(I=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!I))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(we)}const f=[];for(let e=0;e<256;++e)f.push((e+256).toString(16).slice(1));function be(e,n=0){return(f[e[n+0]]+f[e[n+1]]+f[e[n+2]]+f[e[n+3]]+"-"+f[e[n+4]]+f[e[n+5]]+"-"+f[e[n+6]]+f[e[n+7]]+"-"+f[e[n+8]]+f[e[n+9]]+"-"+f[e[n+10]]+f[e[n+11]]+f[e[n+12]]+f[e[n+13]]+f[e[n+14]]+f[e[n+15]]).toLowerCase()}const $={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function W(e,n,o){if($.randomUUID&&!n&&!e)return $.randomUUID();e=e||{};const a=e.random||(e.rng||ke)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,n){o=o||0;for(let r=0;r<16;++r)n[o+r]=a[r];return n}return be(a)}function Oe(e){const n=W(),o={};return e.addEventListener("message",a=>{const{id:r,result:i}=a.data,c=o[r];c&&(c.resolve(i),delete o[r])}),new Proxy({},{get:(a,r)=>(...i)=>{const c=W();e.postMessage({toolkitId:n,id:c,method:r,args:i});const u=new k;return o[c]=u,u.promise}})}function Ie(e,n,o,a){if(typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope){let u=function(s){r[s]&&(r[s].destroy(),delete r[s])};const r={};let i;if(typeof e=="function")i=e();else{const s=new k;i=s.promise,e.onRuntimeInitialized=function(){s.resolve(e)}}i.then(s=>{o&&o(a,s)});async function c(s){if(r[s])return r[s];const m=await i;return r[s]=new n(m),r[s]}addEventListener("message",async s=>{const{id:m,method:p,args:y,toolkitId:v}=s.data;if(p==="moduleIsReady"){i.then(()=>{postMessage({id:m,method:p,args:y,result:null},s)});return}if(p==="removeToolkit"){u(v),postMessage({id:m,method:p,args:y,result:Object.keys(r).length},s);return}const d=await c(v),g=d[p];let _;g&&(_=g.apply(d,y||[])),postMessage({id:m,method:p,args:y,result:_},s)})}}h.VerovioCanvas=he,h.createAsyncVerovioToolkit=_e,h.createVerovioWorker=Ie,h.createWorkerVerovioToolkit=Oe,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|