umwelt-js 0.1.0 → 0.2.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/dist/index.css +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +1220 -1009
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,287 +1,312 @@
|
|
|
1
|
-
import { createComponent as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { isMultiSpec as
|
|
4
|
-
import { VegaLiteAdapter as
|
|
5
|
-
import
|
|
6
|
-
import { getDomain as
|
|
7
|
-
import { compile as
|
|
8
|
-
import { evaluateVegaData as
|
|
9
|
-
import
|
|
10
|
-
import { withExternalStateParam as
|
|
1
|
+
import { createComponent as S, use as Ne, template as A, delegateEvents as at, insert as x, effect as L, setAttribute as Me, memo as pe, className as Vt, render as It } from "solid-js/web";
|
|
2
|
+
import { createContext as Y, createSignal as R, useContext as X, createMemo as k, createEffect as P, onCleanup as H, Switch as Lt, Match as Be, For as ie, onMount as jt, Show as st } from "solid-js";
|
|
3
|
+
import { isMultiSpec as ze, olliVis as qt } from "olli";
|
|
4
|
+
import { VegaLiteAdapter as Mt } from "olli/adapters";
|
|
5
|
+
import he from "moize";
|
|
6
|
+
import { getDomain as Bt, fetchAndParse as zt, typeCoerceData as Gt, getBins as Kt, serializeValue as Ht } from "@umwelt-data/umwelt-utils/data";
|
|
7
|
+
import { compile as Fe } from "vega-lite";
|
|
8
|
+
import { evaluateVegaData as ot, extractOutputDatasets as ct, computeGuideTicks as Jt } from "@umwelt-data/umwelt-utils/vega";
|
|
9
|
+
import $e from "lodash.clonedeep";
|
|
10
|
+
import { withExternalStateParam as Wt, selectionStoreToSelection as Yt, EXTERNAL_STATE_STORE as Ge, predicateToSelectionStore as Xt } from "@umwelt-data/umwelt-utils/vl-bridge";
|
|
11
11
|
import "lz-string";
|
|
12
|
-
import { parse as
|
|
13
|
-
import { debounce as
|
|
14
|
-
import "
|
|
15
|
-
import { createStore as
|
|
16
|
-
import { makeCommaSeparatedString as
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function sn(e) {
|
|
12
|
+
import { parse as Zt, View as Qt } from "vega";
|
|
13
|
+
import { debounce as en } from "@solid-primitives/scheduled";
|
|
14
|
+
import { testDatum as tn } from "@umwelt-data/umwelt-utils/predicate";
|
|
15
|
+
import { createStore as ye } from "solid-js/store";
|
|
16
|
+
import { makeCommaSeparatedString as Pe, fmtValue as nn, describeField as K } from "@umwelt-data/umwelt-utils/description";
|
|
17
|
+
import * as $ from "tone";
|
|
18
|
+
import { Storage as rn } from "versioned-storage";
|
|
19
|
+
import { scaleTime as an, scaleLinear as sn, scaleOrdinal as on, scalePoint as cn } from "d3-scale";
|
|
20
|
+
import ln from "fast-cartesian";
|
|
21
|
+
import { styled as N } from "solid-styled-components";
|
|
22
|
+
const un = "_Viewer_1uzho_29", dn = {
|
|
23
|
+
Viewer: un
|
|
24
|
+
}, fn = ["mean", "median", "min", "max", "sum", "count"];
|
|
25
|
+
function lt(e) {
|
|
26
|
+
return fn.includes(e);
|
|
27
|
+
}
|
|
28
|
+
function mn(e) {
|
|
30
29
|
return e && (typeof e.name == "string" || e.name === void 0) && Array.isArray(e.values);
|
|
31
30
|
}
|
|
32
|
-
function
|
|
31
|
+
function ut(e) {
|
|
33
32
|
return e && (typeof e.name == "string" || e.name === void 0) && typeof e.url == "string";
|
|
34
33
|
}
|
|
35
|
-
const
|
|
36
|
-
function
|
|
37
|
-
return
|
|
34
|
+
const pn = ["x", "y", "color", "shape", "size", "opacity", "order", "facet"], gn = ["pure", "bright", "hollow", "bell", "reed", "strings"];
|
|
35
|
+
function vn(e) {
|
|
36
|
+
return gn.includes(e);
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
function dt(e) {
|
|
39
|
+
return pn.includes(e);
|
|
40
|
+
}
|
|
41
|
+
const ft = "None";
|
|
42
|
+
function Ke(e) {
|
|
43
|
+
return "units" in e;
|
|
44
|
+
}
|
|
45
|
+
function He(e) {
|
|
46
|
+
return "units" in e;
|
|
47
|
+
}
|
|
48
|
+
const hn = "", J = (e, t) => `${t}_${e}`, j = (e) => [`${e}_bin_start`, `${e}_bin_end`], W = (e, t) => `${t}_${e}`, Se = (e) => {
|
|
49
|
+
const t = Ce([e]);
|
|
50
|
+
let n = e.field;
|
|
51
|
+
for (const i of t)
|
|
43
52
|
if ("aggregate" in i)
|
|
44
53
|
for (const r of i.aggregate)
|
|
45
|
-
|
|
46
|
-
else "bin" in i && !e.aggregate ?
|
|
47
|
-
return
|
|
48
|
-
},
|
|
49
|
-
const
|
|
50
|
-
let
|
|
51
|
-
for (const i of
|
|
54
|
+
lt(r.op) && (n = J(n, r.op));
|
|
55
|
+
else "bin" in i && !e.aggregate ? n = j(n)[0] : "timeUnit" in i && !e.aggregate && (n = W(n, i.timeUnit));
|
|
56
|
+
return n;
|
|
57
|
+
}, mt = (e) => {
|
|
58
|
+
const t = Ce([e]);
|
|
59
|
+
let n = e.field;
|
|
60
|
+
for (const i of t)
|
|
52
61
|
if ("aggregate" in i)
|
|
53
62
|
for (const r of i.aggregate)
|
|
54
|
-
|
|
55
|
-
else "bin" in i && !e.aggregate ? typeof
|
|
56
|
-
if (typeof
|
|
63
|
+
lt(r.op) && (typeof n == "string" ? n = J(n, r.op) : n = [J(n[0], r.op), J(n[1], r.op)]);
|
|
64
|
+
else "bin" in i && !e.aggregate ? typeof n == "string" ? n = j(n) : n = [j(n[0])[0], j(n[1])[1]] : "timeUnit" in i && !e.aggregate && (typeof n == "string" ? n = W(n, i.timeUnit) : n = [W(n[0], i.timeUnit), W(n[1], i.timeUnit)]);
|
|
65
|
+
if (typeof n == "string")
|
|
57
66
|
throw new Error("Expected derived field name to be a tuple");
|
|
58
|
-
return
|
|
59
|
-
},
|
|
60
|
-
const i = new Set(
|
|
67
|
+
return n;
|
|
68
|
+
}, Oe = (e, t, n) => {
|
|
69
|
+
const i = new Set(t.filter((s) => s.bin && n?.[s.field]?.length).map((s) => s.field));
|
|
61
70
|
let r = e;
|
|
62
71
|
i.size && (r = e.map((s) => {
|
|
63
|
-
const
|
|
64
|
-
for (const
|
|
65
|
-
const [d,
|
|
66
|
-
|
|
72
|
+
const o = { ...s };
|
|
73
|
+
for (const f of i) {
|
|
74
|
+
const [d, u] = j(f), c = yn(s[f], n[f]);
|
|
75
|
+
o[d] = c ? c[0] : null, o[u] = c ? c[1] : null;
|
|
67
76
|
}
|
|
68
|
-
return
|
|
77
|
+
return o;
|
|
69
78
|
}));
|
|
70
|
-
const a =
|
|
71
|
-
return
|
|
72
|
-
},
|
|
79
|
+
const a = Ce(t, i);
|
|
80
|
+
return pt(r, a);
|
|
81
|
+
}, yn = (e, t) => {
|
|
73
82
|
if (e == null) return;
|
|
74
|
-
const
|
|
75
|
-
if (!isNaN(
|
|
76
|
-
for (let i = 0; i <
|
|
77
|
-
const [r, a] =
|
|
78
|
-
if (
|
|
79
|
-
return
|
|
83
|
+
const n = Number(e);
|
|
84
|
+
if (!isNaN(n))
|
|
85
|
+
for (let i = 0; i < t.length; i++) {
|
|
86
|
+
const [r, a] = t[i];
|
|
87
|
+
if (n >= r && (n < a || i === t.length - 1 && n <= a))
|
|
88
|
+
return t[i];
|
|
80
89
|
}
|
|
81
|
-
},
|
|
82
|
-
const
|
|
83
|
-
for (const
|
|
84
|
-
const { field: s, timeUnit:
|
|
85
|
-
d || (
|
|
90
|
+
}, Ce = (e, t) => {
|
|
91
|
+
const n = [], i = [], r = [], a = /* @__PURE__ */ new Set();
|
|
92
|
+
for (const l of e) {
|
|
93
|
+
const { field: s, timeUnit: o, bin: f, aggregate: d } = l;
|
|
94
|
+
d || (o && a.add(W(s, o)), f && j(s).forEach((u) => a.add(u)), !o && !f && a.add(s));
|
|
86
95
|
}
|
|
87
|
-
for (const
|
|
88
|
-
const { field: s, timeUnit:
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
96
|
+
for (const l of e) {
|
|
97
|
+
const { field: s, timeUnit: o, bin: f, aggregate: d } = l;
|
|
98
|
+
if (f && !t?.has(s)) {
|
|
99
|
+
const u = j(s);
|
|
91
100
|
i.push({
|
|
92
101
|
bin: !0,
|
|
93
102
|
field: s,
|
|
94
|
-
as:
|
|
103
|
+
as: u
|
|
95
104
|
});
|
|
96
105
|
}
|
|
97
|
-
if (
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
timeUnit:
|
|
106
|
+
if (o) {
|
|
107
|
+
const u = f ? j(s)[0] : W(s, o);
|
|
108
|
+
n.push({
|
|
109
|
+
timeUnit: o,
|
|
101
110
|
field: s,
|
|
102
|
-
as:
|
|
111
|
+
as: u
|
|
103
112
|
});
|
|
104
113
|
}
|
|
105
114
|
if (d) {
|
|
106
|
-
const
|
|
107
|
-
|
|
115
|
+
const u = f ? j(s)[0] : s, c = r.find((p) => p.groupby?.length === a.size && p.groupby?.every((m) => a.has(m)));
|
|
116
|
+
c ? c.aggregate.push({
|
|
108
117
|
op: d,
|
|
109
|
-
field:
|
|
110
|
-
as:
|
|
118
|
+
field: u,
|
|
119
|
+
as: J(s, d)
|
|
111
120
|
}) : r.push({
|
|
112
121
|
aggregate: [
|
|
113
122
|
{
|
|
114
123
|
op: d,
|
|
115
|
-
field:
|
|
116
|
-
as:
|
|
124
|
+
field: u,
|
|
125
|
+
as: J(s, d)
|
|
117
126
|
}
|
|
118
127
|
],
|
|
119
128
|
groupby: Array.from(a)
|
|
120
129
|
});
|
|
121
130
|
}
|
|
122
131
|
}
|
|
123
|
-
return [...i, ...
|
|
132
|
+
return [...i, ...n, ...r];
|
|
124
133
|
};
|
|
125
|
-
function
|
|
126
|
-
const r =
|
|
134
|
+
function pt(e, t) {
|
|
135
|
+
const r = Fe({
|
|
127
136
|
data: { values: e },
|
|
128
|
-
transform:
|
|
137
|
+
transform: t,
|
|
129
138
|
mark: "point"
|
|
130
|
-
}).spec.data ?? [], a =
|
|
131
|
-
return
|
|
139
|
+
}).spec.data ?? [], a = ot(r), l = ct(r, a);
|
|
140
|
+
return l[l.length - 1] ?? [];
|
|
141
|
+
}
|
|
142
|
+
function Sn(e) {
|
|
143
|
+
const n = Fe(e).spec.data ?? [], i = ot(n), r = ct(n, i), a = /* @__PURE__ */ new Set();
|
|
144
|
+
for (const l of r) {
|
|
145
|
+
const s = l.find((o) => o && typeof o == "object");
|
|
146
|
+
s && Object.keys(s).forEach((o) => a.add(o));
|
|
147
|
+
}
|
|
148
|
+
return [...a];
|
|
132
149
|
}
|
|
133
|
-
const
|
|
134
|
-
const i =
|
|
135
|
-
return
|
|
136
|
-
}),
|
|
150
|
+
const re = he((e, t, n) => {
|
|
151
|
+
const i = n ? Se(e) : e.field;
|
|
152
|
+
return Bt({ field: i, type: e.type, timeUnit: e.timeUnit }, t);
|
|
153
|
+
}), bn = he((e, t) => {
|
|
137
154
|
if (e.bin) {
|
|
138
|
-
const
|
|
139
|
-
return
|
|
140
|
-
const r = i[
|
|
155
|
+
const n = mt(e);
|
|
156
|
+
return t.map((i) => {
|
|
157
|
+
const r = i[n[0]], a = i[n[1]];
|
|
141
158
|
return [r, a];
|
|
142
159
|
}).sort((i, r) => typeof i[0] == "number" && typeof r[0] == "number" ? i[0] - r[0] : i[0] instanceof Date && r[0] instanceof Date ? i[0].getTime() - r[0].getTime() : typeof i[0] == "string" && typeof r[0] == "string" ? i[0].localeCompare(r[0]) : 0);
|
|
143
160
|
}
|
|
144
161
|
return [];
|
|
145
|
-
}),
|
|
146
|
-
["stocks.csv", "cars.json", "weather.csv", "seattle-weather.csv", "penguins.json", "driving.json", "barley.json", "disasters.csv", "gapminder.json"].map((e) => [e, `${
|
|
162
|
+
}), ve = "dataset", wn = "https://raw.githubusercontent.com/vega/vega-datasets/master/data/", En = Object.fromEntries(
|
|
163
|
+
["stocks.csv", "cars.json", "weather.csv", "seattle-weather.csv", "penguins.json", "driving.json", "barley.json", "disasters.csv", "gapminder.json"].map((e) => [e, `${wn}${e}`])
|
|
147
164
|
);
|
|
148
|
-
async function
|
|
149
|
-
if (
|
|
150
|
-
const
|
|
151
|
-
return e.values.length ? { name:
|
|
165
|
+
async function Un(e) {
|
|
166
|
+
if (mn(e)) {
|
|
167
|
+
const t = e.name || ve;
|
|
168
|
+
return e.values.length ? { name: t, data: e.values } : void 0;
|
|
152
169
|
}
|
|
153
|
-
if (
|
|
154
|
-
const
|
|
155
|
-
return
|
|
170
|
+
if (ut(e)) {
|
|
171
|
+
const t = e.name || e.url.split("/").pop() || ve, n = await Je(e.url);
|
|
172
|
+
return n.length ? { name: t, data: n, sourceUrl: e.url } : void 0;
|
|
156
173
|
}
|
|
157
174
|
if (e.name) {
|
|
158
|
-
const
|
|
159
|
-
if (!
|
|
175
|
+
const t = En[e.name];
|
|
176
|
+
if (!t) {
|
|
160
177
|
console.error(`Unknown example dataset "${e.name}". A name-only data source must reference a built-in example dataset, or provide a url or values.`);
|
|
161
178
|
return;
|
|
162
179
|
}
|
|
163
|
-
const
|
|
164
|
-
return
|
|
180
|
+
const n = await Je(t);
|
|
181
|
+
return n.length ? { name: e.name, data: n, sourceUrl: t } : void 0;
|
|
165
182
|
}
|
|
166
183
|
}
|
|
167
|
-
const
|
|
184
|
+
const Je = he.promise(async (e) => {
|
|
168
185
|
try {
|
|
169
|
-
const
|
|
170
|
-
return Array.isArray(
|
|
171
|
-
} catch (
|
|
186
|
+
const t = await zt(e);
|
|
187
|
+
return Array.isArray(t) ? t : [];
|
|
188
|
+
} catch (t) {
|
|
172
189
|
return console.warn(`Failed to load data from ${e}
|
|
173
|
-
${
|
|
190
|
+
${t}`), [];
|
|
174
191
|
}
|
|
175
192
|
});
|
|
176
|
-
|
|
193
|
+
he.promise(async (e, t) => {
|
|
177
194
|
try {
|
|
178
|
-
return
|
|
179
|
-
} catch (
|
|
195
|
+
return pt(e, t);
|
|
196
|
+
} catch (n) {
|
|
180
197
|
return console.warn(`Failed to evaluate transforms
|
|
181
|
-
${
|
|
198
|
+
${n}`), [];
|
|
182
199
|
}
|
|
183
200
|
});
|
|
184
|
-
function
|
|
185
|
-
const
|
|
186
|
-
return
|
|
201
|
+
function An(e, t) {
|
|
202
|
+
const n = t.map((i) => ({ name: i.name, type: i.type }));
|
|
203
|
+
return Gt(e, n);
|
|
187
204
|
}
|
|
188
|
-
function
|
|
189
|
-
return e.filter((
|
|
205
|
+
function Dn(e, t) {
|
|
206
|
+
return e.filter((n) => Object.entries(n).every(([i, r]) => t.find((a) => a.name === i) ? r != null : !0));
|
|
190
207
|
}
|
|
191
|
-
function
|
|
192
|
-
return e.fields.find((
|
|
208
|
+
function D(e, t) {
|
|
209
|
+
return e.fields.find((n) => n.name === t);
|
|
193
210
|
}
|
|
194
|
-
function
|
|
195
|
-
const { active:
|
|
211
|
+
function _(e, t) {
|
|
212
|
+
const { active: n, name: i, encodings: r, ...a } = e, l = t ? {
|
|
196
213
|
...a,
|
|
197
|
-
...
|
|
214
|
+
...t
|
|
198
215
|
} : { field: i, ...a };
|
|
199
|
-
return Object.fromEntries(Object.entries(
|
|
216
|
+
return Object.fromEntries(Object.entries(l).filter(([s, o]) => o !== ft));
|
|
200
217
|
}
|
|
201
|
-
function
|
|
202
|
-
const i = [...Object.values(
|
|
203
|
-
const
|
|
204
|
-
return
|
|
218
|
+
function Re(e, t) {
|
|
219
|
+
const i = [...Object.values(t.encoding), ...t.traversal].flatMap((a) => {
|
|
220
|
+
const l = D(e, a.field);
|
|
221
|
+
return l ? [_(l, a)] : [];
|
|
205
222
|
}), r = /* @__PURE__ */ new Set();
|
|
206
223
|
return i.filter((a) => {
|
|
207
|
-
const
|
|
208
|
-
return r.has(
|
|
224
|
+
const l = JSON.stringify(a);
|
|
225
|
+
return r.has(l) ? !1 : (r.add(l), !0);
|
|
209
226
|
});
|
|
210
227
|
}
|
|
211
|
-
async function
|
|
228
|
+
async function $n(e, t, n) {
|
|
212
229
|
if (!e.data || !(e.fields && e.fields.length))
|
|
213
230
|
return;
|
|
214
231
|
const i = e.data.name;
|
|
215
|
-
if (i &&
|
|
216
|
-
return
|
|
217
|
-
const r = await
|
|
232
|
+
if (i && t[i]?.data?.length)
|
|
233
|
+
return We(e);
|
|
234
|
+
const r = await Un(e.data);
|
|
218
235
|
if (!r)
|
|
219
236
|
return;
|
|
220
|
-
const a =
|
|
237
|
+
const a = We(e), l = An(r.data, a.fields), s = Dn(l, a.fields);
|
|
221
238
|
if (s.length)
|
|
222
|
-
return
|
|
223
|
-
}
|
|
224
|
-
function
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
239
|
+
return n(r.name, s, r.sourceUrl), a;
|
|
240
|
+
}
|
|
241
|
+
function Tn(e) {
|
|
242
|
+
if (e.instrument !== void 0 && !vn(e.instrument)) {
|
|
243
|
+
console.warn(`Unknown audio instrument "${e.instrument}" on unit "${e.name}"; falling back to the default.`);
|
|
244
|
+
const { instrument: t, ...n } = e;
|
|
245
|
+
return n;
|
|
246
|
+
}
|
|
247
|
+
return e;
|
|
248
|
+
}
|
|
249
|
+
function We(e) {
|
|
250
|
+
const t = Ke(e.visual) ? e.visual.units : [e.visual], n = Ke(e.visual) ? e.visual.composition : void 0, i = He(e.audio) ? e.audio.units : [e.audio], r = He(e.audio) ? e.audio.composition : void 0, a = e.fields.map((s) => {
|
|
251
|
+
const o = [];
|
|
252
|
+
return t.forEach((f) => {
|
|
253
|
+
Object.entries(f.encoding).forEach(([d, u]) => {
|
|
254
|
+
dt(d) && u.field === s.name && o.push({ unit: f.name, property: d });
|
|
230
255
|
});
|
|
231
|
-
}),
|
|
232
|
-
Object.entries(
|
|
233
|
-
|
|
256
|
+
}), i.forEach((f) => {
|
|
257
|
+
Object.entries(f.encoding).forEach(([d, u]) => {
|
|
258
|
+
d === "pitch" && u.field === s.name && o.push({ unit: f.name, property: d });
|
|
234
259
|
});
|
|
235
|
-
}), { ...
|
|
260
|
+
}), { ...s, active: !0, encodings: o };
|
|
236
261
|
});
|
|
237
262
|
return {
|
|
238
263
|
...e,
|
|
239
264
|
data: {
|
|
240
|
-
name: e.data.name || (
|
|
265
|
+
name: e.data.name || (ut(e.data) ? e.data.url.split("/").pop() : ve) || ve
|
|
241
266
|
},
|
|
242
|
-
fields:
|
|
243
|
-
visual: { units:
|
|
244
|
-
audio: { units:
|
|
267
|
+
fields: a,
|
|
268
|
+
visual: { units: t, composition: n || "layer" },
|
|
269
|
+
audio: { units: i.map(Tn), composition: r || "concat" },
|
|
245
270
|
// regenerate node ids on import so a serialized id can never collide with one
|
|
246
271
|
// this session's counter later mints
|
|
247
272
|
text: {
|
|
248
|
-
structures: e.text?.structures ? Object.fromEntries(Object.entries(e.text.structures).map(([
|
|
273
|
+
structures: e.text?.structures ? Object.fromEntries(Object.entries(e.text.structures).map(([s, o]) => [s, o.map(gt)])) : {}
|
|
249
274
|
}
|
|
250
275
|
};
|
|
251
276
|
}
|
|
252
|
-
function
|
|
253
|
-
if (e.visual.units.length === 0 || e.visual.units.map((
|
|
277
|
+
function xe(e, t) {
|
|
278
|
+
if (e.visual.units.length === 0 || e.visual.units.map((o) => Object.values(o.encoding).length).reduce((o, f) => o + f, 0) === 0) return;
|
|
254
279
|
const i = [
|
|
255
280
|
{
|
|
256
281
|
name: "brush",
|
|
257
282
|
select: "interval"
|
|
258
283
|
}
|
|
259
284
|
];
|
|
260
|
-
function r(
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
263
|
-
const d =
|
|
264
|
-
return
|
|
265
|
-
if (
|
|
266
|
-
const p =
|
|
285
|
+
function r(o) {
|
|
286
|
+
const f = o.visual.units;
|
|
287
|
+
if (f.length === 1) {
|
|
288
|
+
const d = f[0], u = $e(d.encoding);
|
|
289
|
+
return u && Object.keys(u).forEach((c) => {
|
|
290
|
+
if (dt(c)) {
|
|
291
|
+
const p = u[c];
|
|
267
292
|
if (p) {
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
...
|
|
273
|
-
},
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
...
|
|
277
|
-
columns:
|
|
293
|
+
const m = D(o, p.field);
|
|
294
|
+
if (m) {
|
|
295
|
+
const y = _(m, p);
|
|
296
|
+
if (u[c] = {
|
|
297
|
+
...y
|
|
298
|
+
}, c === "facet") {
|
|
299
|
+
const w = re(y, t);
|
|
300
|
+
u[c] = {
|
|
301
|
+
...y,
|
|
302
|
+
columns: w.length === 3 ? 3 : 2
|
|
278
303
|
// TODO do something better
|
|
279
304
|
};
|
|
280
305
|
}
|
|
281
|
-
d.mark === "point" && (
|
|
282
|
-
...
|
|
306
|
+
d.mark === "point" && (c === "x" || c === "y") && y.type === "quantitative" && (u[c] = {
|
|
307
|
+
...y,
|
|
283
308
|
scale: {
|
|
284
|
-
...
|
|
309
|
+
...y.scale,
|
|
285
310
|
zero: !1
|
|
286
311
|
}
|
|
287
312
|
});
|
|
@@ -291,870 +316,1047 @@ function ot(e, n) {
|
|
|
291
316
|
}), {
|
|
292
317
|
mark: d.mark,
|
|
293
318
|
encoding: {
|
|
294
|
-
...
|
|
319
|
+
...u,
|
|
295
320
|
color: {
|
|
296
|
-
...a({ ...
|
|
321
|
+
...a({ ...u.color || { value: "navy" }, scale: d.mark === "area" ? { scheme: "category20b" } : void 0 }, "brush", "grey")
|
|
297
322
|
}
|
|
298
323
|
}
|
|
299
324
|
};
|
|
300
|
-
} else if (
|
|
301
|
-
const d =
|
|
325
|
+
} else if (f.length > 1) {
|
|
326
|
+
const d = o.visual.composition || "layer";
|
|
302
327
|
return {
|
|
303
|
-
columns: d === "concat" ?
|
|
304
|
-
[d]:
|
|
328
|
+
columns: d === "concat" ? f.length < 3 ? 1 : 2 : void 0,
|
|
329
|
+
[d]: f.map((u, c) => {
|
|
305
330
|
const p = r({
|
|
306
|
-
...
|
|
331
|
+
...o,
|
|
307
332
|
visual: {
|
|
308
|
-
units: [
|
|
333
|
+
units: [u],
|
|
309
334
|
composition: d
|
|
310
335
|
}
|
|
311
336
|
});
|
|
312
|
-
return
|
|
337
|
+
return c === 0 && (p.params = i), p;
|
|
313
338
|
})
|
|
314
339
|
};
|
|
315
340
|
}
|
|
316
341
|
}
|
|
317
342
|
if (e.visual.units[0].mark === "line" || e.visual.units[0].mark === "bar") {
|
|
318
|
-
const
|
|
319
|
-
|
|
343
|
+
const o = e.visual.units[0], f = o.encoding.y?.field, d = o.encoding.x?.field, u = D(e, f), c = D(e, d);
|
|
344
|
+
u?.type === "quantitative" && c?.type !== "quantitative" ? i[0].select = { type: "interval", encodings: ["x"] } : c?.type === "quantitative" && u?.type !== "quantitative" && (i[0].select = { type: "interval", encodings: ["y"] });
|
|
320
345
|
}
|
|
321
|
-
const a = (
|
|
322
|
-
condition: { param:
|
|
346
|
+
const a = (o, f, d, u) => ({
|
|
347
|
+
condition: { param: f, empty: u || !0, ...o },
|
|
323
348
|
value: d
|
|
324
|
-
}),
|
|
349
|
+
}), l = r(e);
|
|
325
350
|
let s;
|
|
326
|
-
return "mark" in
|
|
327
|
-
data: { values:
|
|
351
|
+
return "mark" in l ? s = $e({
|
|
352
|
+
data: { values: t },
|
|
328
353
|
params: i,
|
|
329
|
-
...
|
|
330
|
-
}) : s =
|
|
331
|
-
data: { values:
|
|
332
|
-
...
|
|
333
|
-
}),
|
|
334
|
-
}
|
|
335
|
-
async function
|
|
336
|
-
let
|
|
337
|
-
const i = e.text.structures, r = e.visual.units.map((
|
|
354
|
+
...l
|
|
355
|
+
}) : s = $e({
|
|
356
|
+
data: { values: t },
|
|
357
|
+
...l
|
|
358
|
+
}), Wt(s);
|
|
359
|
+
}
|
|
360
|
+
async function kn(e, t) {
|
|
361
|
+
let n;
|
|
362
|
+
const i = e.text.structures, r = e.visual.units.map((o) => o.name);
|
|
338
363
|
JSON.stringify(i);
|
|
339
|
-
const a = new Map(e.fields.map((
|
|
340
|
-
if (
|
|
341
|
-
data:
|
|
364
|
+
const a = new Map(e.fields.map((o) => [o.name, o.type])), l = xe(e, t);
|
|
365
|
+
if (l ? n = await Mt(l) : n = {
|
|
366
|
+
data: t,
|
|
342
367
|
fields: []
|
|
343
|
-
},
|
|
344
|
-
s(
|
|
345
|
-
}) : s(
|
|
346
|
-
(
|
|
347
|
-
const
|
|
348
|
-
|
|
368
|
+
}, ze(n) ? n.units.forEach((o) => {
|
|
369
|
+
s(o, e);
|
|
370
|
+
}) : s(n, e), l)
|
|
371
|
+
(ze(n) ? n.units : [n]).forEach((f, d) => {
|
|
372
|
+
const u = i[r[d]];
|
|
373
|
+
u?.length && Xe(f, u, a);
|
|
349
374
|
});
|
|
350
375
|
else {
|
|
351
|
-
const
|
|
352
|
-
|
|
376
|
+
const o = i[hn];
|
|
377
|
+
o?.length && Xe(n, o, a);
|
|
353
378
|
}
|
|
354
|
-
function s(
|
|
355
|
-
|
|
356
|
-
|
|
379
|
+
function s(o, f) {
|
|
380
|
+
o.fields?.length === 0 && (delete o.mark, delete o.axes, delete o.legends), o.fields && f.fields.filter((d) => d.active).forEach((d) => {
|
|
381
|
+
o.fields?.find((u) => u.field === d.name) || o.fields?.push({
|
|
357
382
|
...d,
|
|
358
383
|
field: d.name,
|
|
359
384
|
timeUnit: d.timeUnit
|
|
360
385
|
});
|
|
361
386
|
});
|
|
362
387
|
}
|
|
363
|
-
return
|
|
388
|
+
return n;
|
|
364
389
|
}
|
|
365
|
-
let
|
|
366
|
-
function
|
|
367
|
-
return `text_node_${
|
|
390
|
+
let xn = 0;
|
|
391
|
+
function _n() {
|
|
392
|
+
return `text_node_${xn++}`;
|
|
368
393
|
}
|
|
369
|
-
function
|
|
370
|
-
return { ...e, id:
|
|
394
|
+
function gt(e) {
|
|
395
|
+
return { ...e, id: _n(), children: e.children.map(gt) };
|
|
371
396
|
}
|
|
372
|
-
function
|
|
397
|
+
function ge(e, t) {
|
|
373
398
|
if (!e || typeof e != "object") return e;
|
|
374
|
-
if ("and" in e) return { and: e.and.map((
|
|
375
|
-
if ("or" in e) return { or: e.or.map((
|
|
376
|
-
if ("not" in e) return { not:
|
|
377
|
-
if ("field" in e &&
|
|
378
|
-
const
|
|
399
|
+
if ("and" in e) return { and: e.and.map((n) => ge(n, t)) };
|
|
400
|
+
if ("or" in e) return { or: e.or.map((n) => ge(n, t)) };
|
|
401
|
+
if ("not" in e) return { not: ge(e.not, t) };
|
|
402
|
+
if ("field" in e && t.get(e.field) === "temporal") {
|
|
403
|
+
const n = (r) => r instanceof Date || r == null ? r : new Date(r), i = { ...e };
|
|
379
404
|
for (const r of ["equal", "lt", "lte", "gt", "gte"])
|
|
380
|
-
r in i && (i[r] =
|
|
381
|
-
return "range" in i && Array.isArray(i.range) && (i.range = i.range.map(
|
|
405
|
+
r in i && (i[r] = n(i[r]));
|
|
406
|
+
return "range" in i && Array.isArray(i.range) && (i.range = i.range.map(n)), "oneOf" in i && Array.isArray(i.oneOf) && (i.oneOf = i.oneOf.map(n)), i;
|
|
382
407
|
}
|
|
383
408
|
return e;
|
|
384
409
|
}
|
|
385
|
-
function
|
|
386
|
-
const i = e.children.map((r) =>
|
|
410
|
+
function vt(e, t, n) {
|
|
411
|
+
const i = e.children.map((r) => vt(r, t, n));
|
|
387
412
|
if (e.nodeType === "group") {
|
|
388
|
-
const r = e.groupby.map(
|
|
413
|
+
const r = e.groupby.map(n);
|
|
389
414
|
return { groupby: r.length === 1 ? r[0] : r, ...i.length ? { children: i } : {} };
|
|
390
415
|
}
|
|
391
416
|
return {
|
|
392
|
-
predicate:
|
|
417
|
+
predicate: ge(e.predicate, t),
|
|
393
418
|
...e.name ? { name: e.name } : {},
|
|
394
419
|
...e.reasoning ? { reasoning: e.reasoning } : {},
|
|
395
420
|
...i.length ? { children: i } : {}
|
|
396
421
|
};
|
|
397
422
|
}
|
|
398
|
-
function
|
|
423
|
+
function Ye(e, t) {
|
|
399
424
|
return {
|
|
400
|
-
type: e.type ??
|
|
401
|
-
timeUnit: e.timeUnit ===
|
|
402
|
-
bin: e.bin !== void 0 ? e.bin : !!
|
|
425
|
+
type: e.type ?? t?.type,
|
|
426
|
+
timeUnit: e.timeUnit === ft ? void 0 : e.timeUnit ?? t?.timeUnit,
|
|
427
|
+
bin: e.bin !== void 0 ? e.bin : !!t?.bin
|
|
403
428
|
};
|
|
404
429
|
}
|
|
405
|
-
const
|
|
406
|
-
function
|
|
407
|
-
const i = e.fields ?? (e.fields = []), r = e.data ?? [], a = (d) => i.find((
|
|
408
|
-
|
|
409
|
-
const p =
|
|
410
|
-
|
|
411
|
-
}), s(
|
|
430
|
+
const Te = (e) => `${e.type ?? ""}|${e.timeUnit ?? ""}|${e.bin ? "bin" : ""}`;
|
|
431
|
+
function Xe(e, t, n) {
|
|
432
|
+
const i = e.fields ?? (e.fields = []), r = e.data ?? [], a = (d) => i.find((u) => u.field === d), l = /* @__PURE__ */ new Map(), s = (d) => d.forEach((u) => {
|
|
433
|
+
u.nodeType === "group" && u.groupby.forEach((c) => {
|
|
434
|
+
const p = Ye(c, a(c.field)), m = l.get(c.field) ?? /* @__PURE__ */ new Map();
|
|
435
|
+
m.set(Te(p), p), l.set(c.field, m);
|
|
436
|
+
}), s(u.children);
|
|
412
437
|
});
|
|
413
|
-
s(
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
const
|
|
417
|
-
d.forEach((
|
|
418
|
-
if (
|
|
419
|
-
|
|
438
|
+
s(t);
|
|
439
|
+
const o = /* @__PURE__ */ new Map();
|
|
440
|
+
l.forEach((d, u) => {
|
|
441
|
+
const c = a(u), p = c ? Te({ type: c.type, timeUnit: c.timeUnit, bin: !!c.bin }) : void 0, m = [...d.keys()], y = p && d.has(p) ? p : m[0];
|
|
442
|
+
d.forEach((w, O) => {
|
|
443
|
+
if (O === y)
|
|
444
|
+
c && (w.type && (c.type = w.type), c.timeUnit = w.timeUnit, c.bin = w.bin || void 0), o.set(`${u}|${O}`, u);
|
|
420
445
|
else {
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
446
|
+
const V = [w.type, w.timeUnit, w.bin ? "bin" : ""].filter(Boolean), C = `${u}__${V.join("_") || "raw"}`;
|
|
447
|
+
o.set(`${u}|${O}`, C), i.find((T) => T.field === C) || i.push({ field: C, label: u, type: w.type ?? n.get(u), timeUnit: w.timeUnit, bin: w.bin || void 0 }), r.forEach((T) => {
|
|
448
|
+
u in T && !(C in T) && (T[C] = T[u]);
|
|
424
449
|
});
|
|
425
450
|
}
|
|
426
451
|
});
|
|
427
452
|
});
|
|
428
|
-
const
|
|
429
|
-
e.structure =
|
|
453
|
+
const f = (d) => o.get(`${d.field}|${Te(Ye(d, a(d.field)))}`) ?? d.field;
|
|
454
|
+
e.structure = t.map((d) => vt(d, n, f));
|
|
430
455
|
}
|
|
431
|
-
function
|
|
432
|
-
const
|
|
456
|
+
function Nn(e, t) {
|
|
457
|
+
const n = Fe(e).spec, i = Zt(n), r = new Qt(i, {
|
|
433
458
|
renderer: "canvas",
|
|
434
|
-
container:
|
|
459
|
+
container: t,
|
|
435
460
|
hover: !0
|
|
436
461
|
});
|
|
437
462
|
return r.runAsync(), r;
|
|
438
463
|
}
|
|
439
|
-
const
|
|
440
|
-
function
|
|
441
|
-
const [
|
|
464
|
+
const ht = Y();
|
|
465
|
+
function Fn(e) {
|
|
466
|
+
const [t, n] = R(void 0), i = {
|
|
442
467
|
setSelection: (r) => {
|
|
443
|
-
r && r.predicate && "and" in r.predicate && r.predicate.and.length === 0 && (r.predicate = void 0),
|
|
468
|
+
r && r.predicate && "and" in r.predicate && r.predicate.and.length === 0 && (r.predicate = void 0), n(r);
|
|
444
469
|
}
|
|
445
470
|
};
|
|
446
|
-
return
|
|
447
|
-
value: [
|
|
471
|
+
return S(ht.Provider, {
|
|
472
|
+
value: [t, i],
|
|
448
473
|
get children() {
|
|
449
474
|
return e.children;
|
|
450
475
|
}
|
|
451
476
|
});
|
|
452
477
|
}
|
|
453
|
-
function
|
|
454
|
-
const e =
|
|
478
|
+
function se() {
|
|
479
|
+
const e = X(ht);
|
|
455
480
|
if (e === void 0)
|
|
456
481
|
throw new Error("useUmweltSelection must be used within a UmweltSelectionProvider");
|
|
457
482
|
return e;
|
|
458
483
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
484
|
+
function yt(e, t, n) {
|
|
485
|
+
const i = D(e, n);
|
|
486
|
+
if (!i) return;
|
|
487
|
+
const r = i.encodings.find((u) => u.property === "x" || u.property === "y");
|
|
488
|
+
if (!r) return;
|
|
489
|
+
const a = e.visual.units.find((u) => u.name === r.unit), l = a?.encoding[r.property];
|
|
490
|
+
if (!a || !l) return;
|
|
491
|
+
const s = _(i, l), o = a.mark === "point" && s.type === "quantitative" ? !1 : s.scale?.zero, f = Array.isArray(s.scale?.domain) ? s.scale?.domain : void 0, d = {
|
|
492
|
+
field: n,
|
|
493
|
+
type: s.type,
|
|
494
|
+
bin: !!s.bin,
|
|
495
|
+
timeUnit: s.timeUnit,
|
|
496
|
+
scaleZero: o,
|
|
497
|
+
scaleDomain: f,
|
|
498
|
+
// vega-lite sorts discrete scales ascending unless told otherwise
|
|
499
|
+
sort: s.sort === void 0 ? "ascending" : s.sort
|
|
500
|
+
};
|
|
501
|
+
return Jt(t, d);
|
|
502
|
+
}
|
|
503
|
+
function St(e, t) {
|
|
504
|
+
const n = D(e, t);
|
|
505
|
+
if (!n) return;
|
|
506
|
+
const i = n.encodings.find((l) => l.property === "x" || l.property === "y");
|
|
507
|
+
if (!i) return;
|
|
508
|
+
const a = e.visual.units.find((l) => l.name === i.unit)?.encoding[i.property];
|
|
509
|
+
if (a)
|
|
510
|
+
return _(n, a);
|
|
511
|
+
}
|
|
512
|
+
function Pn(e, t) {
|
|
513
|
+
return !!St(e, t)?.bin;
|
|
514
|
+
}
|
|
515
|
+
function Ve(e, t, n, i) {
|
|
516
|
+
const r = {};
|
|
517
|
+
for (const a of i)
|
|
518
|
+
if (a.bin && a.type === "quantitative" && !(a.field in r)) {
|
|
519
|
+
if (Pn(e, a.field)) continue;
|
|
520
|
+
const l = { field: a.field, type: a.type };
|
|
521
|
+
let s = Kt(l, n, yt(e, t, a.field));
|
|
522
|
+
if (s.length === 0) {
|
|
523
|
+
let o = 1 / 0, f = -1 / 0;
|
|
524
|
+
for (const d of n) {
|
|
525
|
+
const u = d[a.field];
|
|
526
|
+
if (u == null) continue;
|
|
527
|
+
const c = Number(u);
|
|
528
|
+
isNaN(c) || (c < o && (o = c), c > f && (f = c));
|
|
529
|
+
}
|
|
530
|
+
o <= f && (s = [[o, f]]);
|
|
531
|
+
}
|
|
532
|
+
r[a.field] = s;
|
|
533
|
+
}
|
|
534
|
+
return r;
|
|
535
|
+
}
|
|
536
|
+
function Ie(e, t) {
|
|
537
|
+
return e.filter((n) => tn(n, t));
|
|
538
|
+
}
|
|
539
|
+
const Ze = (e) => e == null ? e : e instanceof Date ? e.getTime() : new Date(e).getTime();
|
|
540
|
+
function On(e, t, n) {
|
|
541
|
+
return e.aggregate ? `${e.aggregate}_${t}` : e.timeUnit ? `${e.timeUnit}_${t}` : e.bin ? n.find((i) => i.startsWith("bin") && i.includes(t) && !i.endsWith("_end")) ?? t : t;
|
|
542
|
+
}
|
|
543
|
+
function Cn(e, t, n) {
|
|
544
|
+
if (!t) return t;
|
|
545
|
+
const i = (r) => {
|
|
546
|
+
if (!r || typeof r != "object") return r;
|
|
547
|
+
if ("and" in r) return { and: r.and.map(i) };
|
|
548
|
+
if ("or" in r) return { or: r.or.map(i) };
|
|
549
|
+
if ("not" in r) return { not: i(r.not) };
|
|
550
|
+
if (!("field" in r)) return r;
|
|
551
|
+
const a = St(e, r.field);
|
|
552
|
+
if (!a) return r;
|
|
553
|
+
const l = On(a, r.field, n), s = l === r.field ? { ...r } : { ...r, field: l };
|
|
554
|
+
return a.type === "temporal" && ("equal" in s && (s.equal = Ze(s.equal)), "range" in s && Array.isArray(s.range) && (s.range = s.range.map(Ze))), s;
|
|
555
|
+
};
|
|
556
|
+
return i(t);
|
|
557
|
+
}
|
|
558
|
+
var Rn = /* @__PURE__ */ A("<div class=uw-vl-container>");
|
|
559
|
+
function Vn(e) {
|
|
560
|
+
const [t, n] = se(), [i, r] = R(!1), [a, l] = R(null), [s, o] = R(null), f = en((u) => {
|
|
462
561
|
if (i()) {
|
|
463
|
-
const
|
|
464
|
-
|
|
562
|
+
const c = Yt(u);
|
|
563
|
+
n.setSelection({
|
|
465
564
|
source: "visualization",
|
|
466
|
-
predicate:
|
|
565
|
+
predicate: c
|
|
467
566
|
});
|
|
468
567
|
}
|
|
469
|
-
}, 250)
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
568
|
+
}, 250), d = k(() => {
|
|
569
|
+
const u = xe(e.spec, e.data);
|
|
570
|
+
return u ? Sn(u) : [];
|
|
571
|
+
});
|
|
572
|
+
return P(() => {
|
|
573
|
+
const u = t(), c = a();
|
|
574
|
+
if (!u) {
|
|
575
|
+
c && c.data(Ge, []).run();
|
|
474
576
|
return;
|
|
475
577
|
}
|
|
476
|
-
if (
|
|
477
|
-
const
|
|
478
|
-
|
|
578
|
+
if (c && (u.source === "sonification" || u.source === "text-navigation")) {
|
|
579
|
+
const p = u.source === "sonification" ? Cn(e.spec, u.predicate, d()) : u.predicate, m = Xt(p);
|
|
580
|
+
c.data(Ge, m ? [m] : []).run();
|
|
479
581
|
}
|
|
480
|
-
}),
|
|
481
|
-
const
|
|
482
|
-
if (c)
|
|
582
|
+
}), P(() => {
|
|
583
|
+
const u = xe(e.spec, e.data), c = s();
|
|
584
|
+
if (u && c)
|
|
483
585
|
try {
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}),
|
|
488
|
-
} catch (
|
|
489
|
-
console.error(
|
|
586
|
+
const p = Nn(u, c);
|
|
587
|
+
p.addDataListener("brush_store", (m, y) => {
|
|
588
|
+
f(y);
|
|
589
|
+
}), l(p);
|
|
590
|
+
} catch (p) {
|
|
591
|
+
console.error(p);
|
|
490
592
|
}
|
|
491
|
-
|
|
492
|
-
a()?.finalize(),
|
|
593
|
+
H(() => {
|
|
594
|
+
a()?.finalize(), l(null);
|
|
595
|
+
const p = s();
|
|
596
|
+
p && (p.innerHTML = "");
|
|
493
597
|
});
|
|
494
598
|
}), (() => {
|
|
495
|
-
var
|
|
496
|
-
return
|
|
599
|
+
var u = Rn();
|
|
600
|
+
return u.addEventListener("mouseleave", () => r(!1)), u.addEventListener("mouseenter", () => r(!0)), Ne(o, u), u;
|
|
497
601
|
})();
|
|
498
602
|
}
|
|
499
|
-
var
|
|
500
|
-
function
|
|
501
|
-
const [
|
|
603
|
+
var In = /* @__PURE__ */ A("<div class=uw-olli-container>");
|
|
604
|
+
function Ln(e) {
|
|
605
|
+
const [t, n] = se(), [i, r] = R(null), [a, l] = R(null);
|
|
502
606
|
let s = !1;
|
|
503
|
-
return
|
|
504
|
-
let
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}),
|
|
607
|
+
return P(() => {
|
|
608
|
+
let o = !1;
|
|
609
|
+
H(() => {
|
|
610
|
+
o = !0;
|
|
611
|
+
}), kn(e.spec, e.data).then((f) => {
|
|
508
612
|
const d = i();
|
|
509
|
-
if (
|
|
613
|
+
if (o || !f || !d) return;
|
|
510
614
|
a()?.destroy(), d.innerHTML = "";
|
|
511
|
-
const
|
|
512
|
-
|
|
615
|
+
const u = qt(f, d);
|
|
616
|
+
u.onFocusChange((c) => {
|
|
513
617
|
if (s) return;
|
|
514
|
-
const p =
|
|
515
|
-
"and" in p && p.and.length > 0 ?
|
|
618
|
+
const p = u.fullPredicate(c);
|
|
619
|
+
"and" in p && p.and.length > 0 ? n.setSelection({
|
|
516
620
|
source: "text-navigation",
|
|
517
621
|
predicate: p
|
|
518
|
-
}) :
|
|
622
|
+
}) : n.setSelection({
|
|
519
623
|
source: "text-navigation",
|
|
520
624
|
predicate: void 0
|
|
521
625
|
});
|
|
522
|
-
}),
|
|
523
|
-
|
|
626
|
+
}), u.onSelectionChange((c) => {
|
|
627
|
+
n.setSelection({
|
|
524
628
|
source: "text-filter",
|
|
525
|
-
predicate:
|
|
629
|
+
predicate: c
|
|
526
630
|
});
|
|
527
|
-
}), u
|
|
631
|
+
}), l(u);
|
|
528
632
|
});
|
|
529
|
-
}),
|
|
530
|
-
const
|
|
531
|
-
|
|
633
|
+
}), P(() => {
|
|
634
|
+
const o = t(), f = a();
|
|
635
|
+
o && f && o.source === "visualization" && (s = !0, f.setSelection(o.predicate ?? {
|
|
532
636
|
and: []
|
|
533
637
|
}), queueMicrotask(() => {
|
|
534
638
|
s = !1;
|
|
535
639
|
}));
|
|
536
|
-
}),
|
|
640
|
+
}), H(() => {
|
|
537
641
|
a()?.destroy();
|
|
538
642
|
}), (() => {
|
|
539
|
-
var
|
|
540
|
-
return
|
|
643
|
+
var o = In();
|
|
644
|
+
return Ne(r, o), o;
|
|
541
645
|
})();
|
|
542
646
|
}
|
|
543
|
-
const
|
|
544
|
-
function
|
|
545
|
-
const [
|
|
647
|
+
const bt = Y();
|
|
648
|
+
function jn(e) {
|
|
649
|
+
const [t] = se(), n = () => ({
|
|
546
650
|
activeUnitName: void 0,
|
|
547
651
|
selection: void 0
|
|
548
|
-
}), [i, r] =
|
|
652
|
+
}), [i, r] = ye(n());
|
|
549
653
|
let a = null;
|
|
550
|
-
|
|
551
|
-
const s =
|
|
552
|
-
s && s.source !== "sonification" &&
|
|
654
|
+
P(() => {
|
|
655
|
+
const s = t();
|
|
656
|
+
s && s.source !== "sonification" && l.setSelection(s.predicate);
|
|
553
657
|
});
|
|
554
|
-
const
|
|
658
|
+
const l = {
|
|
555
659
|
setActiveUnit: (s) => {
|
|
556
660
|
r("activeUnitName", s);
|
|
557
661
|
},
|
|
558
662
|
setSelection: (s) => {
|
|
559
663
|
r("selection", s);
|
|
560
664
|
},
|
|
561
|
-
registerPlayCallback: (s,
|
|
562
|
-
(
|
|
665
|
+
registerPlayCallback: (s, o = !1) => {
|
|
666
|
+
(o || a === null) && (a = s);
|
|
563
667
|
},
|
|
564
668
|
triggerPlay: () => {
|
|
565
669
|
a?.();
|
|
566
670
|
}
|
|
567
671
|
};
|
|
568
|
-
return
|
|
569
|
-
value: [i,
|
|
672
|
+
return S(bt.Provider, {
|
|
673
|
+
value: [i, l],
|
|
570
674
|
get children() {
|
|
571
675
|
return e.children;
|
|
572
676
|
}
|
|
573
677
|
});
|
|
574
678
|
}
|
|
575
|
-
function
|
|
576
|
-
const e =
|
|
679
|
+
function be() {
|
|
680
|
+
const e = X(bt);
|
|
577
681
|
if (e === void 0)
|
|
578
682
|
throw new Error("useSonificationRuntime must be used within a SonificationRuntimeProvider");
|
|
579
683
|
return e;
|
|
580
684
|
}
|
|
581
|
-
const
|
|
582
|
-
function Ne(e, n) {
|
|
583
|
-
return e.filter((t) => Xt(t, n));
|
|
584
|
-
}
|
|
585
|
-
const Tn = "umwelt", kn = 1, xn = {
|
|
685
|
+
const B = (e, t) => Array.isArray(e) ? e.length === 2 && (t.type === "quantitative" || t.type === "temporal") ? e.map((n) => B(n, t)).join("–") : Pe(e.map((n) => B(n, t))) : nn(e, t), qn = "umwelt", Mn = 1, Bn = {
|
|
586
686
|
muted: !1,
|
|
587
687
|
speakAxisTicks: !0,
|
|
588
688
|
speechRate: 50,
|
|
589
689
|
playbackRate: 1
|
|
590
|
-
},
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
...
|
|
690
|
+
}, wt = () => new rn(qn, Mn), Et = () => wt().read(), de = (e) => {
|
|
691
|
+
const t = Et() ?? Bn;
|
|
692
|
+
wt().write({
|
|
693
|
+
...t,
|
|
594
694
|
...e
|
|
595
695
|
});
|
|
596
|
-
},
|
|
597
|
-
|
|
598
|
-
|
|
696
|
+
}, Qe = (e, t, n) => Math.min(Math.max(e, t), n), zn = {
|
|
697
|
+
// clean triangle beep — the historical default; most pitch-legible source
|
|
698
|
+
pure: {
|
|
699
|
+
create: () => new $.Synth({
|
|
700
|
+
oscillator: {
|
|
701
|
+
type: "triangle"
|
|
702
|
+
},
|
|
703
|
+
envelope: {
|
|
704
|
+
attack: 0.01,
|
|
705
|
+
decay: 0,
|
|
706
|
+
sustain: 1,
|
|
707
|
+
release: 0.01
|
|
708
|
+
}
|
|
709
|
+
}),
|
|
710
|
+
gainTrim: 0
|
|
711
|
+
},
|
|
712
|
+
// buzzy sawtooth: bright, fast attack, no inharmonicity
|
|
713
|
+
bright: {
|
|
714
|
+
create: () => new $.Synth({
|
|
715
|
+
oscillator: {
|
|
716
|
+
type: "sawtooth"
|
|
717
|
+
},
|
|
718
|
+
envelope: {
|
|
719
|
+
attack: 0.01,
|
|
720
|
+
decay: 0,
|
|
721
|
+
sustain: 1,
|
|
722
|
+
release: 0.05
|
|
723
|
+
}
|
|
724
|
+
}),
|
|
725
|
+
gainTrim: -6
|
|
726
|
+
},
|
|
727
|
+
// clarinet-ish square with a slow attack (breaks the saw/square confusion by
|
|
728
|
+
// differing on attack as well as spectrum)
|
|
729
|
+
hollow: {
|
|
730
|
+
create: () => new $.Synth({
|
|
731
|
+
oscillator: {
|
|
732
|
+
type: "square"
|
|
733
|
+
},
|
|
734
|
+
envelope: {
|
|
735
|
+
attack: 0.08,
|
|
736
|
+
decay: 0,
|
|
737
|
+
sustain: 1,
|
|
738
|
+
release: 0.05
|
|
739
|
+
}
|
|
740
|
+
}),
|
|
741
|
+
gainTrim: -8
|
|
742
|
+
},
|
|
743
|
+
// electric bell: FM with inharmonic partials, fast attack
|
|
744
|
+
bell: {
|
|
745
|
+
create: () => new $.FMSynth({
|
|
746
|
+
harmonicity: 3.01,
|
|
747
|
+
modulationIndex: 12,
|
|
748
|
+
oscillator: {
|
|
749
|
+
type: "sine"
|
|
750
|
+
},
|
|
751
|
+
envelope: {
|
|
752
|
+
attack: 5e-3,
|
|
753
|
+
decay: 0,
|
|
754
|
+
sustain: 1,
|
|
755
|
+
release: 0.1
|
|
756
|
+
},
|
|
757
|
+
modulation: {
|
|
758
|
+
type: "sine"
|
|
759
|
+
},
|
|
760
|
+
modulationEnvelope: {
|
|
761
|
+
attack: 5e-3,
|
|
762
|
+
decay: 0,
|
|
763
|
+
sustain: 1,
|
|
764
|
+
release: 0.1
|
|
765
|
+
}
|
|
766
|
+
}),
|
|
767
|
+
gainTrim: -2
|
|
768
|
+
},
|
|
769
|
+
// reedy AM tone: amplitude-modulation roughness, medium attack
|
|
770
|
+
reed: {
|
|
771
|
+
create: () => new $.AMSynth({
|
|
772
|
+
harmonicity: 2,
|
|
773
|
+
oscillator: {
|
|
774
|
+
type: "square"
|
|
775
|
+
},
|
|
776
|
+
envelope: {
|
|
777
|
+
attack: 0.06,
|
|
778
|
+
decay: 0,
|
|
779
|
+
sustain: 1,
|
|
780
|
+
release: 0.05
|
|
781
|
+
},
|
|
782
|
+
modulation: {
|
|
783
|
+
type: "square"
|
|
784
|
+
},
|
|
785
|
+
modulationEnvelope: {
|
|
786
|
+
attack: 0.06,
|
|
787
|
+
decay: 0,
|
|
788
|
+
sustain: 1,
|
|
789
|
+
release: 0.05
|
|
790
|
+
}
|
|
791
|
+
}),
|
|
792
|
+
// AM output reads quieter by ear than the amplitude suggests; lifted from -6,
|
|
793
|
+
// and again to 0 as it still read a touch under bell/strings.
|
|
794
|
+
gainTrim: 0
|
|
795
|
+
},
|
|
796
|
+
// detuned-unison pad: chorus/beating flux, slow attack
|
|
797
|
+
strings: {
|
|
798
|
+
create: () => new $.Synth({
|
|
799
|
+
oscillator: {
|
|
800
|
+
type: "fatsawtooth",
|
|
801
|
+
count: 3,
|
|
802
|
+
spread: 20
|
|
803
|
+
},
|
|
804
|
+
envelope: {
|
|
805
|
+
attack: 0.15,
|
|
806
|
+
decay: 0,
|
|
807
|
+
sustain: 1,
|
|
808
|
+
release: 0.2
|
|
809
|
+
}
|
|
810
|
+
}),
|
|
811
|
+
gainTrim: -7
|
|
812
|
+
}
|
|
813
|
+
}, et = ["pure", "bell", "bright", "reed", "hollow", "strings"], Gn = (e) => et[e % et.length], ke = "default", ne = 0.1;
|
|
814
|
+
let M = null;
|
|
815
|
+
const ae = 120, Ut = Y();
|
|
816
|
+
function Kn(e) {
|
|
817
|
+
const t = /* @__PURE__ */ new Map(), n = {
|
|
599
818
|
attack: 0.01,
|
|
600
819
|
decay: 0,
|
|
601
820
|
sustain: 1,
|
|
602
821
|
release: 0.01
|
|
603
|
-
}, i = (
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
},
|
|
610
|
-
envelope: t
|
|
611
|
-
}).toDestination(), p = new V.NoiseSynth({
|
|
822
|
+
}, i = (c) => {
|
|
823
|
+
c.synth.dispose(), c.noiseSynth.dispose(), c.noiseGain.dispose(), c.panner.dispose();
|
|
824
|
+
}, r = (c, p) => {
|
|
825
|
+
let m = t.get(c);
|
|
826
|
+
if (m && p !== void 0 && m.instrument !== p && (i(m), t.delete(c), m = void 0), !m) {
|
|
827
|
+
const y = p ?? "pure", w = zn[y], O = new $.Panner(0).toDestination(), V = w.create().connect(O), C = new $.NoiseSynth({
|
|
612
828
|
noise: {
|
|
613
829
|
type: "pink"
|
|
614
830
|
},
|
|
615
|
-
envelope:
|
|
616
|
-
}),
|
|
617
|
-
|
|
618
|
-
synth:
|
|
619
|
-
noiseSynth:
|
|
620
|
-
noiseGain:
|
|
831
|
+
envelope: n
|
|
832
|
+
}), T = new $.Gain(0.3);
|
|
833
|
+
C.connect(T), T.connect(O), m = {
|
|
834
|
+
synth: V,
|
|
835
|
+
noiseSynth: C,
|
|
836
|
+
noiseGain: T,
|
|
837
|
+
panner: O,
|
|
838
|
+
instrument: y,
|
|
839
|
+
gainTrim: w.gainTrim,
|
|
621
840
|
isSynthPlaying: !1,
|
|
622
841
|
isNoisePlaying: !1
|
|
623
|
-
},
|
|
842
|
+
}, t.set(c, m);
|
|
624
843
|
}
|
|
625
|
-
return
|
|
626
|
-
},
|
|
627
|
-
|
|
844
|
+
return m;
|
|
845
|
+
}, a = (c) => {
|
|
846
|
+
c.synth.triggerRelease(), c.noiseSynth.triggerRelease(), c.isSynthPlaying = !1, c.isNoisePlaying = !1;
|
|
628
847
|
};
|
|
629
|
-
|
|
630
|
-
const
|
|
631
|
-
document.hidden &&
|
|
848
|
+
P(() => {
|
|
849
|
+
const c = () => {
|
|
850
|
+
document.hidden && u.stopTransport();
|
|
632
851
|
};
|
|
633
|
-
document.addEventListener("visibilitychange",
|
|
634
|
-
document.removeEventListener("visibilitychange",
|
|
635
|
-
d.synth.dispose(), d.noiseSynth.dispose(), d.noiseGain.dispose();
|
|
636
|
-
}), n.clear(), V.getTransport().cancel(), V.getTransport().stop();
|
|
852
|
+
document.addEventListener("visibilitychange", c), H(() => {
|
|
853
|
+
document.removeEventListener("visibilitychange", c), t.forEach(i), t.clear(), M === d && (M = null, $.getTransport().cancel(), $.getTransport().stop());
|
|
637
854
|
});
|
|
638
855
|
});
|
|
639
|
-
const
|
|
640
|
-
const
|
|
856
|
+
const l = () => {
|
|
857
|
+
const c = Et();
|
|
641
858
|
return {
|
|
642
|
-
transport:
|
|
643
|
-
muted:
|
|
644
|
-
speakAxisTicks:
|
|
645
|
-
speechRate:
|
|
646
|
-
playbackRate:
|
|
859
|
+
transport: $.getTransport(),
|
|
860
|
+
muted: c?.muted ?? !1,
|
|
861
|
+
speakAxisTicks: c?.speakAxisTicks ?? !0,
|
|
862
|
+
speechRate: c?.speechRate ?? 50,
|
|
863
|
+
playbackRate: c?.playbackRate ?? 1,
|
|
647
864
|
pauseBetweenSections: 0.25,
|
|
648
865
|
isPlaying: !1
|
|
649
866
|
};
|
|
650
|
-
}, [
|
|
651
|
-
|
|
652
|
-
|
|
867
|
+
}, [s, o] = ye(l());
|
|
868
|
+
P(() => {
|
|
869
|
+
s.transport.bpm.value = ae * s.playbackRate;
|
|
653
870
|
});
|
|
654
|
-
const
|
|
871
|
+
const f = () => {
|
|
872
|
+
o((c) => ({
|
|
873
|
+
...c,
|
|
874
|
+
isPlaying: !1
|
|
875
|
+
})), speechSynthesis.cancel(), $.getTransport().pause(), u.releaseSynth();
|
|
876
|
+
}, d = {
|
|
877
|
+
deactivate: f
|
|
878
|
+
}, u = {
|
|
655
879
|
startAudioContext: async () => {
|
|
656
|
-
await
|
|
880
|
+
await $.start(), r(ke);
|
|
657
881
|
},
|
|
658
|
-
ensureVoice: (
|
|
659
|
-
|
|
882
|
+
ensureVoice: (c, p) => {
|
|
883
|
+
r(c, p);
|
|
660
884
|
},
|
|
661
|
-
setMuted: (
|
|
662
|
-
|
|
663
|
-
muted:
|
|
664
|
-
}),
|
|
665
|
-
...
|
|
666
|
-
muted:
|
|
667
|
-
})),
|
|
885
|
+
setMuted: (c) => {
|
|
886
|
+
de({
|
|
887
|
+
muted: c
|
|
888
|
+
}), o((p) => ({
|
|
889
|
+
...p,
|
|
890
|
+
muted: c
|
|
891
|
+
})), $.getDestination().mute = c;
|
|
668
892
|
},
|
|
669
|
-
setSpeakAxisTicks: (
|
|
670
|
-
|
|
671
|
-
speakAxisTicks:
|
|
672
|
-
}),
|
|
673
|
-
...
|
|
674
|
-
speakAxisTicks:
|
|
675
|
-
})),
|
|
893
|
+
setSpeakAxisTicks: (c) => {
|
|
894
|
+
de({
|
|
895
|
+
speakAxisTicks: c
|
|
896
|
+
}), o((p) => ({
|
|
897
|
+
...p,
|
|
898
|
+
speakAxisTicks: c
|
|
899
|
+
})), c || (speechSynthesis.cancel(), s.isPlaying && $.getTransport().start());
|
|
676
900
|
},
|
|
677
|
-
setSpeechRate: (
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
speechRate:
|
|
681
|
-
}),
|
|
682
|
-
...
|
|
683
|
-
speechRate:
|
|
901
|
+
setSpeechRate: (c) => {
|
|
902
|
+
const p = Qe(c, 1, 100);
|
|
903
|
+
de({
|
|
904
|
+
speechRate: c
|
|
905
|
+
}), o((m) => ({
|
|
906
|
+
...m,
|
|
907
|
+
speechRate: p
|
|
684
908
|
}));
|
|
685
909
|
},
|
|
686
|
-
setPlaybackRate: (
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
playbackRate:
|
|
690
|
-
}),
|
|
691
|
-
...
|
|
692
|
-
playbackRate:
|
|
910
|
+
setPlaybackRate: (c) => {
|
|
911
|
+
const p = Qe(c, 0.1, 4);
|
|
912
|
+
de({
|
|
913
|
+
playbackRate: p
|
|
914
|
+
}), o((m) => ({
|
|
915
|
+
...m,
|
|
916
|
+
playbackRate: p
|
|
693
917
|
}));
|
|
694
918
|
},
|
|
695
919
|
startTransport: async () => {
|
|
696
|
-
|
|
697
|
-
...
|
|
920
|
+
M && M !== d && M.deactivate(), M = d, o((c) => ({
|
|
921
|
+
...c,
|
|
698
922
|
isPlaying: !0
|
|
699
|
-
})),
|
|
923
|
+
})), $.getTransport().start();
|
|
700
924
|
},
|
|
701
925
|
stopTransport: () => {
|
|
702
|
-
|
|
703
|
-
...o,
|
|
704
|
-
isPlaying: !1
|
|
705
|
-
})), speechSynthesis.cancel(), V.getTransport().pause(), c.releaseSynth();
|
|
926
|
+
f(), M === d && (M = null);
|
|
706
927
|
},
|
|
707
|
-
playNote: (
|
|
708
|
-
const
|
|
709
|
-
if (
|
|
710
|
-
if (
|
|
711
|
-
|
|
712
|
-
const
|
|
713
|
-
|
|
928
|
+
playNote: (c, p = ke) => {
|
|
929
|
+
const m = r(p);
|
|
930
|
+
if (m.noiseSynth.triggerRelease(), m.synth.triggerRelease(), m.isSynthPlaying = !1, m.isNoisePlaying = !1, !c.rest)
|
|
931
|
+
if (m.panner.pan.value = c.pan, c.pitch) {
|
|
932
|
+
m.synth.volume.value = c.volume + m.gainTrim;
|
|
933
|
+
const y = $.Frequency(c.pitch, "midi").toFrequency();
|
|
934
|
+
m.synth.triggerAttackRelease(y, c.duration);
|
|
714
935
|
} else
|
|
715
|
-
|
|
936
|
+
m.noiseSynth.volume.value = c.volume, m.noiseSynth.triggerAttackRelease(c.duration);
|
|
716
937
|
},
|
|
717
|
-
startOrRampSynth: (
|
|
718
|
-
const
|
|
719
|
-
if (
|
|
720
|
-
|
|
938
|
+
startOrRampSynth: (c, p = ke) => {
|
|
939
|
+
const m = r(p);
|
|
940
|
+
if (c.rest) {
|
|
941
|
+
a(m);
|
|
721
942
|
return;
|
|
722
943
|
}
|
|
723
|
-
if (
|
|
724
|
-
|
|
725
|
-
const
|
|
726
|
-
|
|
944
|
+
if (c.pitch) {
|
|
945
|
+
m.noiseSynth.triggerRelease(), m.isNoisePlaying = !1;
|
|
946
|
+
const y = $.Frequency(c.pitch, "midi").toFrequency();
|
|
947
|
+
m.isSynthPlaying ? (m.synth.volume.rampTo(c.volume + m.gainTrim, ne), m.synth.frequency.rampTo(y, ne), m.panner.pan.rampTo(c.pan, ne)) : (m.synth.volume.value = c.volume + m.gainTrim, m.panner.pan.value = c.pan, m.isSynthPlaying = !0, m.synth.triggerAttack(y));
|
|
727
948
|
} else
|
|
728
|
-
|
|
949
|
+
m.synth.triggerRelease(), m.isSynthPlaying = !1, m.isNoisePlaying ? (m.noiseSynth.volume.rampTo(c.volume, ne), m.panner.pan.rampTo(c.pan, ne)) : (m.noiseSynth.volume.value = c.volume, m.panner.pan.value = c.pan, m.isNoisePlaying = !0, m.noiseSynth.triggerAttack());
|
|
729
950
|
},
|
|
730
|
-
releaseSynth: (
|
|
731
|
-
if (
|
|
732
|
-
const
|
|
733
|
-
|
|
951
|
+
releaseSynth: (c) => {
|
|
952
|
+
if (c !== void 0) {
|
|
953
|
+
const p = t.get(c);
|
|
954
|
+
p && a(p);
|
|
734
955
|
} else
|
|
735
|
-
|
|
956
|
+
t.forEach(a);
|
|
736
957
|
}
|
|
737
958
|
};
|
|
738
|
-
return
|
|
739
|
-
value: [
|
|
959
|
+
return S(Ut.Provider, {
|
|
960
|
+
value: [s, u],
|
|
740
961
|
get children() {
|
|
741
962
|
return e.children;
|
|
742
963
|
}
|
|
743
964
|
});
|
|
744
965
|
}
|
|
745
|
-
function
|
|
746
|
-
const e =
|
|
966
|
+
function Z() {
|
|
967
|
+
const e = X(Ut);
|
|
747
968
|
if (e === void 0)
|
|
748
969
|
throw new Error("useSonificationRuntime must be used within a SonificationRuntimeProvider");
|
|
749
970
|
return e;
|
|
750
971
|
}
|
|
751
|
-
|
|
752
|
-
const i = $(e, t);
|
|
753
|
-
if (!i) return;
|
|
754
|
-
const r = i.encodings.find((l) => l.property === "x" || l.property === "y");
|
|
755
|
-
if (!r) return;
|
|
756
|
-
const a = e.visual.units.find((l) => l.name === r.unit), u = a?.encoding[r.property];
|
|
757
|
-
if (!a || !u) return;
|
|
758
|
-
const s = N(i, u), c = a.mark === "point" && s.type === "quantitative" ? !1 : s.scale?.zero, o = Array.isArray(s.scale?.domain) ? s.scale?.domain : void 0, d = {
|
|
759
|
-
field: t,
|
|
760
|
-
type: s.type,
|
|
761
|
-
bin: !!s.bin,
|
|
762
|
-
timeUnit: s.timeUnit,
|
|
763
|
-
scaleZero: c,
|
|
764
|
-
scaleDomain: o,
|
|
765
|
-
// vega-lite sorts discrete scales ascending unless told otherwise
|
|
766
|
-
sort: s.sort === void 0 ? "ascending" : s.sort
|
|
767
|
-
};
|
|
768
|
-
return Mt(n, d);
|
|
769
|
-
}
|
|
770
|
-
function Pe(e, n, t, i) {
|
|
771
|
-
const r = {};
|
|
772
|
-
for (const a of i)
|
|
773
|
-
if (a.bin && a.type === "quantitative" && !(a.field in r)) {
|
|
774
|
-
const u = { field: a.field, type: a.type };
|
|
775
|
-
let s = It(u, t, gt(e, n, a.field));
|
|
776
|
-
if (s.length === 0) {
|
|
777
|
-
let c = 1 / 0, o = -1 / 0;
|
|
778
|
-
for (const d of t) {
|
|
779
|
-
const l = d[a.field];
|
|
780
|
-
if (l == null) continue;
|
|
781
|
-
const f = Number(l);
|
|
782
|
-
isNaN(f) || (f < c && (c = f), f > o && (o = f));
|
|
783
|
-
}
|
|
784
|
-
c <= o && (s = [[c, o]]);
|
|
785
|
-
}
|
|
786
|
-
r[a.field] = s;
|
|
787
|
-
}
|
|
788
|
-
return r;
|
|
789
|
-
}
|
|
790
|
-
const vt = W(), Pn = {
|
|
972
|
+
const At = Y(), Hn = {
|
|
791
973
|
pitch: [48, 84],
|
|
792
974
|
// in MIDI. Three octaves from C3 to C6
|
|
793
975
|
duration: [0.25, 1],
|
|
794
976
|
// in seconds
|
|
795
|
-
volume: [-20, 0]
|
|
977
|
+
volume: [-20, 0],
|
|
796
978
|
// in decibels
|
|
797
|
-
|
|
979
|
+
// stereo position. ±0.9 rather than ±1 so the extremes stay unambiguously
|
|
980
|
+
// lateral without ever going fully single-channel — full pan drops the off ear
|
|
981
|
+
// to silence (fatiguing on headphones, inaudible for single-sided hearing loss).
|
|
982
|
+
pan: [-0.9, 0.9]
|
|
983
|
+
}, tt = {
|
|
798
984
|
pitch: 60,
|
|
799
985
|
// MIDI C4 middle C. We encode in MIDI because linear interpolations in Hz are not perceptually linear
|
|
800
986
|
duration: 0.2,
|
|
801
987
|
// seconds
|
|
802
|
-
volume: -10
|
|
988
|
+
volume: -10,
|
|
803
989
|
// dB
|
|
990
|
+
pan: 0
|
|
991
|
+
// center
|
|
804
992
|
};
|
|
805
|
-
function
|
|
806
|
-
|
|
993
|
+
function Jn(e, t, n) {
|
|
994
|
+
if (t.length === e.length) {
|
|
995
|
+
const a = on().domain(e).range(t);
|
|
996
|
+
return (l) => a(l);
|
|
997
|
+
}
|
|
998
|
+
const i = [Math.min(...t), Math.max(...t)];
|
|
999
|
+
t.length !== 2 && console.warn(`Audio ${n} scale range has ${t.length} values for ${e.length} categories; ignoring it and spacing evenly across [${i[0]}, ${i[1]}].`);
|
|
1000
|
+
const r = cn().domain(e.map(String)).range(i).align(0);
|
|
1001
|
+
return (a) => r(String(a)) ?? i[0];
|
|
1002
|
+
}
|
|
1003
|
+
function fe(e, t, n, i) {
|
|
1004
|
+
const r = n.encoding[i];
|
|
807
1005
|
if (!r)
|
|
808
|
-
return () =>
|
|
809
|
-
const a =
|
|
1006
|
+
return () => tt[i];
|
|
1007
|
+
const a = D(e, r.field);
|
|
810
1008
|
if (!a)
|
|
811
|
-
return console.warn(`Field ${r.field} not found in spec`), () =>
|
|
812
|
-
const
|
|
813
|
-
let s =
|
|
1009
|
+
return console.warn(`Field ${r.field} not found in spec`), () => tt[i];
|
|
1010
|
+
const l = _(a, r);
|
|
1011
|
+
let s = l.scale?.domain;
|
|
814
1012
|
if (!s) {
|
|
815
|
-
const
|
|
1013
|
+
const f = l.aggregate === "count" || l.aggregate === "sum", d = Re(e, n), u = f ? Oe(t, d, Ve(e, t, t, d)) : t;
|
|
816
1014
|
switch (a.type) {
|
|
817
1015
|
case "ordinal":
|
|
818
1016
|
case "nominal":
|
|
819
|
-
s =
|
|
1017
|
+
s = re(l, u, f);
|
|
820
1018
|
break;
|
|
821
1019
|
case "quantitative":
|
|
822
1020
|
case "temporal":
|
|
823
|
-
s =
|
|
1021
|
+
s = re(l, u, f), s = [s[0], s[s.length - 1]];
|
|
824
1022
|
break;
|
|
825
1023
|
default:
|
|
826
|
-
throw new Error(`Unsupported field type ${
|
|
1024
|
+
throw new Error(`Unsupported field type ${l.type}`);
|
|
827
1025
|
}
|
|
828
1026
|
}
|
|
829
|
-
const
|
|
830
|
-
switch (
|
|
1027
|
+
const o = l.scale?.range || Hn[i];
|
|
1028
|
+
switch (l.type) {
|
|
831
1029
|
case "ordinal":
|
|
832
1030
|
case "nominal":
|
|
833
|
-
return
|
|
1031
|
+
return Jn(s, o, i);
|
|
834
1032
|
case "quantitative":
|
|
835
|
-
return
|
|
1033
|
+
return sn().domain(s).range(o);
|
|
836
1034
|
case "temporal":
|
|
837
|
-
return
|
|
1035
|
+
return an().domain(s).range(o);
|
|
838
1036
|
default:
|
|
839
|
-
throw new Error(`Unsupported field type ${
|
|
1037
|
+
throw new Error(`Unsupported field type ${l.type}`);
|
|
840
1038
|
}
|
|
841
1039
|
}
|
|
842
|
-
function
|
|
1040
|
+
function Dt(e, t, n) {
|
|
843
1041
|
return {
|
|
844
|
-
pitch:
|
|
845
|
-
duration:
|
|
846
|
-
volume:
|
|
1042
|
+
pitch: fe(e, t, n, "pitch"),
|
|
1043
|
+
duration: fe(e, t, n, "duration"),
|
|
1044
|
+
volume: fe(e, t, n, "volume"),
|
|
1045
|
+
pan: fe(e, t, n, "pan")
|
|
847
1046
|
};
|
|
848
1047
|
}
|
|
849
|
-
function
|
|
850
|
-
return
|
|
1048
|
+
function $t(e, t, n) {
|
|
1049
|
+
return yt(e, t, n) ?? [];
|
|
851
1050
|
}
|
|
852
|
-
function
|
|
853
|
-
const
|
|
854
|
-
getAxisTicks:
|
|
1051
|
+
function Wn(e) {
|
|
1052
|
+
const t = (r) => $t(e.spec, e.data, r.field), n = Dt(e.spec, e.data, e.audioUnitSpec), i = {
|
|
1053
|
+
getAxisTicks: t
|
|
855
1054
|
};
|
|
856
|
-
return
|
|
857
|
-
value: [
|
|
1055
|
+
return S(At.Provider, {
|
|
1056
|
+
value: [n, i],
|
|
858
1057
|
get children() {
|
|
859
1058
|
return e.children;
|
|
860
1059
|
}
|
|
861
1060
|
});
|
|
862
1061
|
}
|
|
863
|
-
function
|
|
864
|
-
const e =
|
|
1062
|
+
function Yn() {
|
|
1063
|
+
const e = X(At);
|
|
865
1064
|
if (e === void 0)
|
|
866
1065
|
throw new Error("useSonificationRuntime must be used within a SonificationRuntimeProvider");
|
|
867
1066
|
return e;
|
|
868
1067
|
}
|
|
869
|
-
const
|
|
1068
|
+
const nt = {
|
|
870
1069
|
pitch: 60,
|
|
871
1070
|
// MIDI C4 middle C. We encode in MIDI because linear interpolations in Hz are not perceptually linear
|
|
872
1071
|
duration: 0.2,
|
|
873
1072
|
// seconds
|
|
874
|
-
volume: -15
|
|
1073
|
+
volume: -15,
|
|
875
1074
|
// dB
|
|
1075
|
+
pan: 0
|
|
1076
|
+
// center
|
|
876
1077
|
};
|
|
877
|
-
function
|
|
878
|
-
if (!
|
|
879
|
-
return
|
|
880
|
-
const a =
|
|
1078
|
+
function me(e, t, n, i, r) {
|
|
1079
|
+
if (!n)
|
|
1080
|
+
return nt[e];
|
|
1081
|
+
const a = D(t, n.field);
|
|
881
1082
|
if (!a)
|
|
882
|
-
return
|
|
883
|
-
const
|
|
1083
|
+
return nt[e];
|
|
1084
|
+
const l = _(a, n), s = Se(l);
|
|
884
1085
|
return i(r[0][s]);
|
|
885
1086
|
}
|
|
886
|
-
const
|
|
887
|
-
function
|
|
888
|
-
const i =
|
|
1087
|
+
const Le = (e, t) => e.audioUnitSpec.traversal.find((n) => n.field === t);
|
|
1088
|
+
function we(e, t, n) {
|
|
1089
|
+
const i = D(e.spec, t), r = _(i, Le(e, t)), a = e.fieldDomains[t];
|
|
889
1090
|
if (r.bin && !r.aggregate) {
|
|
890
|
-
const [
|
|
891
|
-
return [
|
|
1091
|
+
const [l, s] = mt(r), o = a[n], f = e.derivedData.find((d) => d[l] === o)?.[s] ?? null;
|
|
1092
|
+
return [o, f];
|
|
892
1093
|
} else
|
|
893
|
-
return a[
|
|
1094
|
+
return a[n];
|
|
894
1095
|
}
|
|
895
|
-
function
|
|
1096
|
+
function Tt(e, t) {
|
|
896
1097
|
return {
|
|
897
|
-
and: Object.entries(
|
|
898
|
-
const r =
|
|
1098
|
+
and: Object.entries(t).map(([n, i]) => {
|
|
1099
|
+
const r = we(e, n, i), a = e.fieldDomains[n].length - 1;
|
|
899
1100
|
return Array.isArray(r) ? {
|
|
900
|
-
field:
|
|
1101
|
+
field: n,
|
|
901
1102
|
range: r,
|
|
902
1103
|
inclusiveLeft: !0,
|
|
903
1104
|
inclusiveRight: i === a
|
|
904
1105
|
} : {
|
|
905
|
-
field:
|
|
1106
|
+
field: n,
|
|
906
1107
|
equal: r
|
|
907
1108
|
};
|
|
908
1109
|
})
|
|
909
1110
|
};
|
|
910
1111
|
}
|
|
911
|
-
function
|
|
912
|
-
const
|
|
913
|
-
and: Object.entries(
|
|
914
|
-
const a = e.fieldDomains[i][r],
|
|
915
|
-
if (!
|
|
1112
|
+
function _e(e, t) {
|
|
1113
|
+
const n = {
|
|
1114
|
+
and: Object.entries(t).map(([i, r]) => {
|
|
1115
|
+
const a = e.fieldDomains[i][r], l = D(e.spec, i);
|
|
1116
|
+
if (!l)
|
|
916
1117
|
return { field: i, equal: a };
|
|
917
|
-
const s =
|
|
1118
|
+
const s = _(l, Le(e, i));
|
|
918
1119
|
return {
|
|
919
|
-
field:
|
|
920
|
-
equal:
|
|
1120
|
+
field: Se(s),
|
|
1121
|
+
equal: Ht(a, l)
|
|
921
1122
|
};
|
|
922
1123
|
})
|
|
923
1124
|
};
|
|
924
|
-
return
|
|
1125
|
+
return Ie(e.derivedData, n);
|
|
925
1126
|
}
|
|
926
|
-
function
|
|
927
|
-
const
|
|
1127
|
+
function Xn(e, t) {
|
|
1128
|
+
const n = e.audioUnitSpec.encoding;
|
|
928
1129
|
return {
|
|
929
|
-
pitch:
|
|
930
|
-
volume:
|
|
931
|
-
duration:
|
|
1130
|
+
pitch: t.length ? me("pitch", e.spec, n.pitch, e.scales.pitch, t) : void 0,
|
|
1131
|
+
volume: me("volume", e.spec, n.volume, e.scales.volume, t),
|
|
1132
|
+
duration: me("duration", e.spec, n.duration, e.scales.duration, t),
|
|
1133
|
+
pan: me("pan", e.spec, n.pan, e.scales.pan, t)
|
|
932
1134
|
};
|
|
933
1135
|
}
|
|
934
|
-
function
|
|
935
|
-
const
|
|
1136
|
+
function Zn(e, t) {
|
|
1137
|
+
const n = Object.entries(t).map(([r, a]) => a === e.fieldDomains[r].length - 1 ? 1 : 0).reverse();
|
|
936
1138
|
let i = 0;
|
|
937
|
-
for (let r of
|
|
1139
|
+
for (let r of n)
|
|
938
1140
|
if (r)
|
|
939
1141
|
i++;
|
|
940
1142
|
else break;
|
|
941
1143
|
return i;
|
|
942
1144
|
}
|
|
943
|
-
function
|
|
1145
|
+
function Qn(e) {
|
|
944
1146
|
if (e.audioUnitSpec.traversal.length === 0)
|
|
945
1147
|
return !1;
|
|
946
|
-
const
|
|
947
|
-
return
|
|
1148
|
+
const t = e.audioUnitSpec.traversal[e.audioUnitSpec.traversal.length - 1].field, n = D(e.spec, t);
|
|
1149
|
+
return n?.type === "quantitative" || n?.type === "temporal";
|
|
948
1150
|
}
|
|
949
|
-
function
|
|
950
|
-
const
|
|
951
|
-
return
|
|
1151
|
+
function ei(e) {
|
|
1152
|
+
const t = e.audioUnitSpec.traversal.map((r) => r.field), n = t.map((r) => Array.from({ length: e.fieldDomains[r].length }, (a, l) => l));
|
|
1153
|
+
return ln(n).map((r) => {
|
|
952
1154
|
const a = {};
|
|
953
|
-
return r.forEach((
|
|
954
|
-
a[
|
|
1155
|
+
return r.forEach((l, s) => {
|
|
1156
|
+
a[t[s]] = l;
|
|
955
1157
|
}), a;
|
|
956
1158
|
});
|
|
957
1159
|
}
|
|
958
|
-
function
|
|
959
|
-
if (!
|
|
1160
|
+
function ti(e, t, n, i) {
|
|
1161
|
+
if (!n)
|
|
960
1162
|
return !0;
|
|
961
1163
|
if (i.bin || i.type === "nominal" || i.type === "ordinal")
|
|
962
|
-
return
|
|
963
|
-
const r = e.axisTicks[i.field] ?? [], a =
|
|
964
|
-
if (a.length &&
|
|
965
|
-
const s =
|
|
966
|
-
if (
|
|
967
|
-
const d = r.findIndex((
|
|
968
|
-
const
|
|
969
|
-
return
|
|
970
|
-
}),
|
|
971
|
-
const
|
|
972
|
-
return
|
|
1164
|
+
return t[i.field] !== n[i.field];
|
|
1165
|
+
const r = e.axisTicks[i.field] ?? [], a = _e(e, t), l = _e(e, n);
|
|
1166
|
+
if (a.length && l.length) {
|
|
1167
|
+
const s = Se(i), o = a[0][s], f = l[0][s];
|
|
1168
|
+
if (o && f) {
|
|
1169
|
+
const d = r.findIndex((c, p) => {
|
|
1170
|
+
const m = c instanceof Date ? c.getTime() : c, y = r[p + 1], w = y instanceof Date ? y.getTime() : y;
|
|
1171
|
+
return m && o >= m && o < (w || 1 / 0);
|
|
1172
|
+
}), u = r.findIndex((c, p) => {
|
|
1173
|
+
const m = c instanceof Date ? c.getTime() : c, y = r[p + 1], w = y instanceof Date ? y.getTime() : y;
|
|
1174
|
+
return m && f >= m && f < (w || 1 / 0);
|
|
973
1175
|
});
|
|
974
|
-
return d !==
|
|
1176
|
+
return d !== u;
|
|
975
1177
|
}
|
|
976
1178
|
}
|
|
977
1179
|
return !1;
|
|
978
1180
|
}
|
|
979
|
-
function
|
|
1181
|
+
function ni(e, t, n) {
|
|
980
1182
|
const i = [];
|
|
981
|
-
return Object.entries(
|
|
1183
|
+
return Object.entries(t).forEach(([r]) => {
|
|
982
1184
|
if (!e.fieldDomains[r].length) return;
|
|
983
|
-
const
|
|
984
|
-
|
|
1185
|
+
const l = D(e.spec, r), s = _(l, Le(e, r));
|
|
1186
|
+
ti(e, t, n, s) && i.push(B(we(e, r, t[r]), s));
|
|
985
1187
|
}), i.join(", ");
|
|
986
1188
|
}
|
|
987
|
-
function
|
|
988
|
-
let
|
|
989
|
-
const
|
|
1189
|
+
function kt(e) {
|
|
1190
|
+
let t = 0;
|
|
1191
|
+
const n = [], i = ei(e), r = Qn(e);
|
|
990
1192
|
let a;
|
|
991
|
-
return i.forEach((
|
|
992
|
-
const s =
|
|
993
|
-
|
|
994
|
-
...
|
|
995
|
-
time:
|
|
1193
|
+
return i.forEach((l) => {
|
|
1194
|
+
const s = _e(e, l), o = Xn(e, s), f = Zn(e, l), d = e.pauseBetweenSections * f;
|
|
1195
|
+
n.push({
|
|
1196
|
+
...o,
|
|
1197
|
+
time: t,
|
|
996
1198
|
pauseAfter: d,
|
|
997
1199
|
ramp: r,
|
|
998
1200
|
rest: s.length === 0,
|
|
999
|
-
state:
|
|
1000
|
-
speakBefore:
|
|
1001
|
-
}),
|
|
1002
|
-
}),
|
|
1201
|
+
state: l,
|
|
1202
|
+
speakBefore: ni(e, l, a)
|
|
1203
|
+
}), t += o.duration + d, a = l;
|
|
1204
|
+
}), n;
|
|
1003
1205
|
}
|
|
1004
|
-
function
|
|
1206
|
+
function ii(e) {
|
|
1005
1207
|
if (!e.length) return [];
|
|
1006
|
-
const
|
|
1208
|
+
const t = e[0].notes.length, n = [];
|
|
1007
1209
|
let i = 0;
|
|
1008
|
-
for (let r = 0; r <
|
|
1009
|
-
const a = e.map((
|
|
1010
|
-
|
|
1210
|
+
for (let r = 0; r < t; r++) {
|
|
1211
|
+
const a = e.map((f) => ({ voiceId: f.voiceId, note: f.notes[r] })), l = Math.max(...a.map((f) => f.note.duration)), s = e[0].notes[r], o = s.pauseAfter ?? 0;
|
|
1212
|
+
n.push({
|
|
1011
1213
|
state: s.state,
|
|
1012
1214
|
time: i,
|
|
1013
|
-
slotDuration:
|
|
1014
|
-
pauseAfter:
|
|
1215
|
+
slotDuration: l,
|
|
1216
|
+
pauseAfter: o,
|
|
1015
1217
|
speakBefore: s.speakBefore,
|
|
1016
1218
|
ramp: s.ramp,
|
|
1017
1219
|
notes: a
|
|
1018
|
-
}), i +=
|
|
1220
|
+
}), i += l + o;
|
|
1019
1221
|
}
|
|
1020
|
-
return
|
|
1222
|
+
return n;
|
|
1021
1223
|
}
|
|
1022
|
-
function
|
|
1023
|
-
return
|
|
1024
|
-
Object.entries(e.audioUnitSpec.encoding).map(([
|
|
1224
|
+
function xt(e) {
|
|
1225
|
+
return Pe(
|
|
1226
|
+
Object.entries(e.audioUnitSpec.encoding).map(([t, n]) => n ? `${K(_(D(e.spec, n.field), n))} as ${t}` : "").filter((t) => t)
|
|
1025
1227
|
);
|
|
1026
1228
|
}
|
|
1027
|
-
function
|
|
1229
|
+
function _t(e) {
|
|
1028
1230
|
if (!e.audioUnitSpec.traversal.length)
|
|
1029
1231
|
return "";
|
|
1030
|
-
const
|
|
1232
|
+
const t = e.audioUnitSpec.traversal[e.audioUnitSpec.traversal.length - 1], n = D(e.spec, t.field), i = _(n, t);
|
|
1031
1233
|
let r;
|
|
1032
|
-
i.bin ? r =
|
|
1234
|
+
i.bin ? r = bn(i, e.derivedData) : r = e.fieldDomains[t.field];
|
|
1033
1235
|
let a = "";
|
|
1034
|
-
r.length > 1 ? a = `${
|
|
1035
|
-
const
|
|
1036
|
-
const
|
|
1037
|
-
return
|
|
1236
|
+
r.length > 1 ? a = `${K(i)} from ${B(r[0], i)} to ${B(r[r.length - 1], i)}` : r.length === 1 ? a = `${K(i)} equals ${B(r[0], i)}` : a = K(i);
|
|
1237
|
+
const l = e.audioUnitSpec.traversal.slice(0, -1).map((s) => {
|
|
1238
|
+
const o = D(e.spec, s.field);
|
|
1239
|
+
return K(_(o, s));
|
|
1038
1240
|
});
|
|
1039
|
-
return
|
|
1241
|
+
return l.length && (a += ` for each ${Pe(l)}`), a;
|
|
1040
1242
|
}
|
|
1041
|
-
const
|
|
1042
|
-
function
|
|
1043
|
-
const [
|
|
1044
|
-
const
|
|
1045
|
-
d(
|
|
1243
|
+
const je = Y();
|
|
1244
|
+
function ri(e) {
|
|
1245
|
+
const [t, n] = se(), [i, r] = Yn(), [a, l] = be(), [s, o] = Z(), [f, d] = R(), u = () => {
|
|
1246
|
+
const E = speechSynthesis.getVoices(), b = E.find((h) => h.name === "Samantha"), g = E.find((h) => h.localService && h.default), v = E.find((h) => h.default);
|
|
1247
|
+
d(b ?? g ?? v);
|
|
1046
1248
|
};
|
|
1047
|
-
|
|
1048
|
-
const
|
|
1049
|
-
traversalState: Object.fromEntries(e.audioUnitSpec.traversal.map((
|
|
1050
|
-
}), [p,
|
|
1051
|
-
const
|
|
1052
|
-
return [
|
|
1053
|
-
}))),
|
|
1054
|
-
const
|
|
1055
|
-
return [
|
|
1056
|
-
}))),
|
|
1249
|
+
u(), speechSynthesis.addEventListener("voiceschanged", u), H(() => speechSynthesis.removeEventListener("voiceschanged", u));
|
|
1250
|
+
const c = () => ({
|
|
1251
|
+
traversalState: Object.fromEntries(e.audioUnitSpec.traversal.map((E) => [E.field, 0]))
|
|
1252
|
+
}), [p, m] = ye(c()), y = () => e.audioUnitSpec.name, w = () => e.audioUnitSpec.instrument ?? "pure", O = k(() => Re(e.spec, e.audioUnitSpec)), V = k(() => a.selection ? Ie(e.data, a.selection) : e.data), C = k(() => Ve(e.spec, e.data, V(), O())), T = k(() => Oe(V(), O(), C())), z = k(() => Object.fromEntries(e.audioUnitSpec.traversal.map((E) => {
|
|
1253
|
+
const b = D(e.spec, E.field), g = _(b, E), v = re(g, T(), !0);
|
|
1254
|
+
return [E.field, v];
|
|
1255
|
+
}))), Ue = k(() => Object.fromEntries(e.audioUnitSpec.traversal.map((E) => {
|
|
1256
|
+
const b = D(e.spec, E.field), g = _(b, E);
|
|
1257
|
+
return [E.field, r.getAxisTicks(g)];
|
|
1258
|
+
}))), q = k(() => ({
|
|
1057
1259
|
spec: e.spec,
|
|
1058
1260
|
audioUnitSpec: e.audioUnitSpec,
|
|
1059
|
-
derivedData:
|
|
1060
|
-
fieldDomains:
|
|
1061
|
-
axisTicks:
|
|
1261
|
+
derivedData: T(),
|
|
1262
|
+
fieldDomains: z(),
|
|
1263
|
+
axisTicks: Ue(),
|
|
1062
1264
|
scales: i,
|
|
1063
1265
|
pauseBetweenSections: s.pauseBetweenSections
|
|
1064
|
-
})),
|
|
1065
|
-
|
|
1266
|
+
})), oe = k(() => kt(q())), Ae = (E, b) => we(q(), E, b), Q = k(() => Tt(q(), p.traversalState)), ce = (E) => oe().find((b) => Object.entries(E).every(([g, v]) => b.state[g] === v));
|
|
1267
|
+
P(() => {
|
|
1066
1268
|
if (s.isPlaying) {
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1269
|
+
const E = Q();
|
|
1270
|
+
n.setSelection({
|
|
1069
1271
|
source: "sonification",
|
|
1070
|
-
predicate:
|
|
1272
|
+
predicate: E
|
|
1071
1273
|
});
|
|
1072
1274
|
}
|
|
1073
|
-
}),
|
|
1074
|
-
const
|
|
1275
|
+
}), P((E) => {
|
|
1276
|
+
const b = z(), g = {
|
|
1075
1277
|
...p.traversalState
|
|
1076
1278
|
};
|
|
1077
|
-
let
|
|
1078
|
-
const
|
|
1079
|
-
...
|
|
1279
|
+
let v = !1;
|
|
1280
|
+
const h = {
|
|
1281
|
+
...g
|
|
1080
1282
|
};
|
|
1081
|
-
return Object.entries(
|
|
1082
|
-
const
|
|
1083
|
-
if (
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1283
|
+
return Object.entries(b).forEach(([U, F]) => {
|
|
1284
|
+
const I = g[U], te = (E?.[U] ?? F)[I];
|
|
1285
|
+
if (te !== void 0) {
|
|
1286
|
+
const le = F.findIndex((ue) => ue === te);
|
|
1287
|
+
le !== I && (h[U] = le !== -1 ? le : 0, v = !0);
|
|
1086
1288
|
}
|
|
1087
|
-
}),
|
|
1088
|
-
...
|
|
1089
|
-
traversalState:
|
|
1090
|
-
})), a.activeUnitName === e.audioUnitSpec.name &&
|
|
1091
|
-
}),
|
|
1092
|
-
const
|
|
1093
|
-
setTraversalIndex: (
|
|
1094
|
-
|
|
1095
|
-
...
|
|
1289
|
+
}), v && (m((U) => ({
|
|
1290
|
+
...U,
|
|
1291
|
+
traversalState: h
|
|
1292
|
+
})), a.activeUnitName === e.audioUnitSpec.name && G.setupTransportSequence()), b;
|
|
1293
|
+
}), P((E) => (E !== e.audioUnitSpec && G.setupTransportSequence(), e.audioUnitSpec));
|
|
1294
|
+
const G = {
|
|
1295
|
+
setTraversalIndex: (E, b) => {
|
|
1296
|
+
o.stopTransport(), m((h) => ({
|
|
1297
|
+
...h,
|
|
1096
1298
|
traversalState: {
|
|
1097
|
-
...
|
|
1098
|
-
[
|
|
1299
|
+
...h.traversalState,
|
|
1300
|
+
[E]: b
|
|
1099
1301
|
}
|
|
1100
|
-
})), a.activeUnitName === e.audioUnitSpec.name && (
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1302
|
+
})), a.activeUnitName === e.audioUnitSpec.name && (l.setActiveUnit(e.audioUnitSpec.name), G.setupTransportSequence());
|
|
1303
|
+
const g = Q();
|
|
1304
|
+
n.setSelection({
|
|
1103
1305
|
source: "sonification",
|
|
1104
|
-
predicate:
|
|
1306
|
+
predicate: g
|
|
1105
1307
|
});
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1308
|
+
const v = ce(p.traversalState);
|
|
1309
|
+
v && (o.ensureVoice(y(), w()), s.transport.seconds = v.time, o.playNote(v, y()));
|
|
1108
1310
|
},
|
|
1109
|
-
getTraversalIndex: (
|
|
1311
|
+
getTraversalIndex: (E) => p.traversalState[E],
|
|
1110
1312
|
setupTransportSequence: () => {
|
|
1111
|
-
s.transport.cancel(), s.transport.bpm.value =
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
Object.entries(
|
|
1313
|
+
s.transport.cancel(), o.ensureVoice(y(), w()), s.transport.bpm.value = ae;
|
|
1314
|
+
const E = oe();
|
|
1315
|
+
E.forEach((b, g) => {
|
|
1316
|
+
Object.entries(b.state).every(([v, h]) => p.traversalState[v] === h) && (s.transport.seconds = b.time), s.transport.schedule(() => {
|
|
1115
1317
|
if (s.isPlaying)
|
|
1116
|
-
if (
|
|
1117
|
-
...
|
|
1118
|
-
traversalState:
|
|
1119
|
-
})),
|
|
1120
|
-
s.transport.pause(),
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1123
|
-
s.isPlaying && (
|
|
1124
|
-
}, speechSynthesis.speak(
|
|
1318
|
+
if (m((v) => ({
|
|
1319
|
+
...v,
|
|
1320
|
+
traversalState: b.state
|
|
1321
|
+
})), b.speakBefore && s.speakAxisTicks && !s.muted) {
|
|
1322
|
+
s.transport.pause(), o.releaseSynth(y()), speechSynthesis.cancel();
|
|
1323
|
+
const v = new SpeechSynthesisUtterance(b.speakBefore);
|
|
1324
|
+
v.voice = f() ?? null, v.rate = s.speechRate / 25, v.onend = () => {
|
|
1325
|
+
s.isPlaying && (b.ramp ? o.startOrRampSynth(b, y()) : o.playNote(b, y()), s.transport.start());
|
|
1326
|
+
}, speechSynthesis.speak(v);
|
|
1125
1327
|
} else
|
|
1126
|
-
|
|
1127
|
-
},
|
|
1128
|
-
|
|
1129
|
-
},
|
|
1130
|
-
|
|
1131
|
-
},
|
|
1132
|
-
}), s.transport.bpm.value =
|
|
1328
|
+
b.ramp ? o.startOrRampSynth(b, y()) : o.playNote(b, y());
|
|
1329
|
+
}, b.time), b.pauseAfter && s.transport.schedule(() => {
|
|
1330
|
+
o.releaseSynth(y());
|
|
1331
|
+
}, b.time + b.duration), g === E.length - 1 && s.transport.schedule(() => {
|
|
1332
|
+
o.stopTransport();
|
|
1333
|
+
}, b.time + b.duration);
|
|
1334
|
+
}), s.transport.bpm.value = ae * s.playbackRate;
|
|
1133
1335
|
},
|
|
1134
|
-
getFieldDomains:
|
|
1135
|
-
getDerivedData:
|
|
1336
|
+
getFieldDomains: z,
|
|
1337
|
+
getDerivedData: T,
|
|
1136
1338
|
resetTraversalIfEnd: () => {
|
|
1137
|
-
const
|
|
1138
|
-
|
|
1339
|
+
const E = e.audioUnitSpec.traversal.map((v) => v.field), b = p.traversalState;
|
|
1340
|
+
E.every((v) => b[v] === z()[v].length - 1) && (m(c()), s.transport.seconds = 0);
|
|
1139
1341
|
},
|
|
1140
|
-
getDomainValue:
|
|
1141
|
-
describeEncodings: () =>
|
|
1142
|
-
describePlaybackOrder: () =>
|
|
1342
|
+
getDomainValue: Ae,
|
|
1343
|
+
describeEncodings: () => xt(q()),
|
|
1344
|
+
describePlaybackOrder: () => _t(q())
|
|
1143
1345
|
};
|
|
1144
|
-
return
|
|
1145
|
-
value: [p,
|
|
1346
|
+
return S(je.Provider, {
|
|
1347
|
+
value: [p, G],
|
|
1146
1348
|
get children() {
|
|
1147
1349
|
return e.children;
|
|
1148
1350
|
}
|
|
1149
1351
|
});
|
|
1150
1352
|
}
|
|
1151
|
-
function
|
|
1152
|
-
const e =
|
|
1353
|
+
function Ee() {
|
|
1354
|
+
const e = X(je);
|
|
1153
1355
|
if (e === void 0)
|
|
1154
1356
|
throw new Error("useAudioUnitState must be used within a AudioUnitStateProvider");
|
|
1155
1357
|
return e;
|
|
1156
1358
|
}
|
|
1157
|
-
const
|
|
1359
|
+
const Nt = N("div")`
|
|
1158
1360
|
margin-bottom: 3px;
|
|
1159
1361
|
|
|
1160
1362
|
label {
|
|
@@ -1167,25 +1369,25 @@ const Dt = x("div")`
|
|
|
1167
1369
|
label > * {
|
|
1168
1370
|
justify-self: start;
|
|
1169
1371
|
}
|
|
1170
|
-
`,
|
|
1372
|
+
`, qe = `
|
|
1171
1373
|
font-family: monospace;
|
|
1172
|
-
`,
|
|
1374
|
+
`, Ft = N("div")`
|
|
1173
1375
|
border-left: 1px solid #ccc;
|
|
1174
1376
|
padding-left: 1rem;
|
|
1175
1377
|
`;
|
|
1176
|
-
|
|
1378
|
+
N("form")`
|
|
1177
1379
|
display: flex;
|
|
1178
1380
|
gap: 8px;
|
|
1179
1381
|
margin-bottom: 8px;
|
|
1180
1382
|
`;
|
|
1181
|
-
|
|
1383
|
+
N("input")`
|
|
1182
1384
|
flex: 1;
|
|
1183
1385
|
`;
|
|
1184
|
-
|
|
1386
|
+
N("div")`
|
|
1185
1387
|
color: red;
|
|
1186
1388
|
font-size: 14px;
|
|
1187
1389
|
`;
|
|
1188
|
-
|
|
1390
|
+
N("div")`
|
|
1189
1391
|
margin-top: 0.5rem;
|
|
1190
1392
|
display: grid;
|
|
1191
1393
|
grid-template-columns: 25% auto;
|
|
@@ -1195,132 +1397,132 @@ x("div")`
|
|
|
1195
1397
|
margin: 0;
|
|
1196
1398
|
}
|
|
1197
1399
|
`;
|
|
1198
|
-
|
|
1400
|
+
N("div")`
|
|
1199
1401
|
> * {
|
|
1200
1402
|
margin-bottom: 3px;
|
|
1201
1403
|
}
|
|
1202
1404
|
`;
|
|
1203
|
-
|
|
1405
|
+
N("div")`
|
|
1204
1406
|
display: flex;
|
|
1205
1407
|
gap: 3px;
|
|
1206
1408
|
`;
|
|
1207
|
-
|
|
1409
|
+
N("div")`
|
|
1208
1410
|
margin-top: 1em;
|
|
1209
1411
|
`;
|
|
1210
|
-
|
|
1211
|
-
${
|
|
1412
|
+
N("h4")`
|
|
1413
|
+
${qe}
|
|
1212
1414
|
`;
|
|
1213
|
-
|
|
1214
|
-
${
|
|
1415
|
+
N("div")`
|
|
1416
|
+
${qe}
|
|
1215
1417
|
`;
|
|
1216
|
-
|
|
1418
|
+
N("table")`
|
|
1217
1419
|
border: 1px solid #ccc;
|
|
1218
|
-
${
|
|
1420
|
+
${qe}
|
|
1219
1421
|
`;
|
|
1220
|
-
|
|
1422
|
+
N("button")`
|
|
1221
1423
|
margin-top: 1rem;
|
|
1222
1424
|
`;
|
|
1223
|
-
|
|
1425
|
+
N("div")`
|
|
1224
1426
|
display: flex;
|
|
1225
1427
|
align-items: center;
|
|
1226
1428
|
gap: 8px;
|
|
1227
1429
|
`;
|
|
1228
|
-
var
|
|
1229
|
-
function
|
|
1230
|
-
const [
|
|
1231
|
-
r.startAudioContext(),
|
|
1232
|
-
},
|
|
1233
|
-
return
|
|
1430
|
+
var ai = /* @__PURE__ */ A("<select>"), si = /* @__PURE__ */ A("<div><input aria-live=assertive type=range min=0><span>"), oi = /* @__PURE__ */ A("<label><span>"), ci = /* @__PURE__ */ A("<option>");
|
|
1431
|
+
function Pt(e) {
|
|
1432
|
+
const [t, n] = Ee(), [i, r] = Z(), a = () => D(e.spec, e.traversalFieldDef.field), l = () => _(a(), e.traversalFieldDef), s = () => n.getTraversalIndex(e.traversalFieldDef.field), o = (u) => {
|
|
1433
|
+
r.startAudioContext(), n.setTraversalIndex(e.traversalFieldDef.field, u);
|
|
1434
|
+
}, f = () => n.getFieldDomains()[e.traversalFieldDef.field], d = () => n.getDomainValue(e.traversalFieldDef.field, s());
|
|
1435
|
+
return S(Nt, {
|
|
1234
1436
|
get children() {
|
|
1235
|
-
var
|
|
1236
|
-
return
|
|
1437
|
+
var u = oi(), c = u.firstChild;
|
|
1438
|
+
return x(c, () => K(l())), x(u, S(Lt, {
|
|
1237
1439
|
get children() {
|
|
1238
|
-
return [
|
|
1440
|
+
return [S(Be, {
|
|
1239
1441
|
get when() {
|
|
1240
|
-
return
|
|
1442
|
+
return l().type === "nominal";
|
|
1241
1443
|
},
|
|
1242
1444
|
get children() {
|
|
1243
|
-
var p =
|
|
1244
|
-
return p.$$mousedown = () => r.stopTransport(), p.addEventListener("change", (
|
|
1445
|
+
var p = ai();
|
|
1446
|
+
return p.$$mousedown = () => r.stopTransport(), p.addEventListener("change", (m) => o(m.target.selectedIndex)), x(p, S(ie, {
|
|
1245
1447
|
get each() {
|
|
1246
|
-
return
|
|
1448
|
+
return f();
|
|
1247
1449
|
},
|
|
1248
|
-
children: (
|
|
1249
|
-
var
|
|
1250
|
-
return
|
|
1450
|
+
children: (m) => (() => {
|
|
1451
|
+
var y = ci();
|
|
1452
|
+
return x(y, () => String(m)), L(() => y.value = String(m)), y;
|
|
1251
1453
|
})()
|
|
1252
|
-
})),
|
|
1454
|
+
})), L(() => p.value = String(d())), p;
|
|
1253
1455
|
}
|
|
1254
|
-
}),
|
|
1456
|
+
}), S(Be, {
|
|
1255
1457
|
get when() {
|
|
1256
|
-
return
|
|
1458
|
+
return l().type !== "nominal";
|
|
1257
1459
|
},
|
|
1258
1460
|
get children() {
|
|
1259
|
-
var p =
|
|
1260
|
-
return
|
|
1261
|
-
var
|
|
1262
|
-
return
|
|
1461
|
+
var p = si(), m = p.firstChild, y = m.nextSibling;
|
|
1462
|
+
return m.$$mousedown = () => r.stopTransport(), m.$$input = (w) => o(w.currentTarget.valueAsNumber), x(y, () => B(d(), l())), L((w) => {
|
|
1463
|
+
var O = B(d(), l()), V = f().length - 1;
|
|
1464
|
+
return O !== w.e && Me(m, "aria-valuetext", w.e = O), V !== w.t && Me(m, "max", w.t = V), w;
|
|
1263
1465
|
}, {
|
|
1264
1466
|
e: void 0,
|
|
1265
1467
|
t: void 0
|
|
1266
|
-
}),
|
|
1468
|
+
}), L(() => m.value = s()), p;
|
|
1267
1469
|
}
|
|
1268
1470
|
})];
|
|
1269
1471
|
}
|
|
1270
|
-
}), null),
|
|
1472
|
+
}), null), u;
|
|
1271
1473
|
}
|
|
1272
1474
|
});
|
|
1273
1475
|
}
|
|
1274
|
-
|
|
1275
|
-
var
|
|
1276
|
-
function
|
|
1277
|
-
const [
|
|
1476
|
+
at(["mousedown", "input"]);
|
|
1477
|
+
var li = /* @__PURE__ */ A("<button>Pause"), ui = /* @__PURE__ */ A("<div>"), di = /* @__PURE__ */ A("<button>Play");
|
|
1478
|
+
function Ot(e) {
|
|
1479
|
+
const [t, n] = Ee(), [i, r] = Z(), [a, l] = be();
|
|
1278
1480
|
function s() {
|
|
1279
|
-
r.startAudioContext(), a.activeUnitName !== e.unitName && (
|
|
1481
|
+
r.startAudioContext(), a.activeUnitName !== e.unitName && (l.setActiveUnit(e.unitName), n.setupTransportSequence()), n.resetTraversalIfEnd(), r.startTransport();
|
|
1280
1482
|
}
|
|
1281
|
-
return
|
|
1282
|
-
a.activeUnitName === e.unitName &&
|
|
1483
|
+
return jt(() => l.registerPlayCallback(s)), P(() => {
|
|
1484
|
+
a.activeUnitName === e.unitName && l.registerPlayCallback(s, !0);
|
|
1283
1485
|
}), (() => {
|
|
1284
|
-
var
|
|
1285
|
-
return
|
|
1486
|
+
var o = ui();
|
|
1487
|
+
return x(o, S(st, {
|
|
1286
1488
|
get when() {
|
|
1287
|
-
return
|
|
1489
|
+
return pe(() => !!i.isPlaying)() && a.activeUnitName === e.unitName;
|
|
1288
1490
|
},
|
|
1289
1491
|
get fallback() {
|
|
1290
1492
|
return (() => {
|
|
1291
|
-
var
|
|
1292
|
-
return
|
|
1493
|
+
var f = di();
|
|
1494
|
+
return f.$$click = () => s(), f;
|
|
1293
1495
|
})();
|
|
1294
1496
|
},
|
|
1295
1497
|
get children() {
|
|
1296
|
-
var
|
|
1297
|
-
return
|
|
1498
|
+
var f = li();
|
|
1499
|
+
return f.$$click = () => r.stopTransport(), f;
|
|
1298
1500
|
}
|
|
1299
|
-
})),
|
|
1501
|
+
})), o;
|
|
1300
1502
|
})();
|
|
1301
1503
|
}
|
|
1302
|
-
|
|
1303
|
-
var
|
|
1304
|
-
const
|
|
1504
|
+
at(["click"]);
|
|
1505
|
+
var fi = /* @__PURE__ */ A("<label> <input readonly>"), mi = /* @__PURE__ */ A("<p><br>playing ");
|
|
1506
|
+
const pi = N.div`
|
|
1305
1507
|
margin-bottom: 1em;
|
|
1306
1508
|
`;
|
|
1307
|
-
function
|
|
1308
|
-
function
|
|
1309
|
-
return
|
|
1509
|
+
function gi(e) {
|
|
1510
|
+
function t() {
|
|
1511
|
+
return S(pi, {
|
|
1310
1512
|
get children() {
|
|
1311
|
-
return
|
|
1513
|
+
return S(ie, {
|
|
1312
1514
|
get each() {
|
|
1313
1515
|
return Object.entries(e.audioUnitSpec.encoding);
|
|
1314
1516
|
},
|
|
1315
1517
|
children: ([i, r]) => {
|
|
1316
1518
|
if (r) {
|
|
1317
|
-
const a =
|
|
1519
|
+
const a = D(e.spec, r.field);
|
|
1318
1520
|
if (a) {
|
|
1319
|
-
const
|
|
1320
|
-
return
|
|
1521
|
+
const l = _(a, r);
|
|
1522
|
+
return S(Nt, {
|
|
1321
1523
|
get children() {
|
|
1322
|
-
var s =
|
|
1323
|
-
return
|
|
1524
|
+
var s = fi(), o = s.firstChild, f = o.nextSibling;
|
|
1525
|
+
return x(s, i, o), L(() => f.value = K(l)), s;
|
|
1324
1526
|
}
|
|
1325
1527
|
});
|
|
1326
1528
|
}
|
|
@@ -1330,16 +1532,16 @@ function Qn(e) {
|
|
|
1330
1532
|
}
|
|
1331
1533
|
});
|
|
1332
1534
|
}
|
|
1333
|
-
function
|
|
1334
|
-
const [i, r] =
|
|
1535
|
+
function n() {
|
|
1536
|
+
const [i, r] = Ee();
|
|
1335
1537
|
return (() => {
|
|
1336
|
-
var a =
|
|
1337
|
-
return
|
|
1538
|
+
var a = mi(), l = a.firstChild;
|
|
1539
|
+
return l.nextSibling, x(a, () => r.describeEncodings(), l), x(a, () => r.describePlaybackOrder(), null), a;
|
|
1338
1540
|
})();
|
|
1339
1541
|
}
|
|
1340
|
-
return Object.keys(e.audioUnitSpec.encoding).length === 0 ? null :
|
|
1542
|
+
return Object.keys(e.audioUnitSpec.encoding).length === 0 ? null : S(Ft, {
|
|
1341
1543
|
get children() {
|
|
1342
|
-
return
|
|
1544
|
+
return S(Wn, {
|
|
1343
1545
|
get spec() {
|
|
1344
1546
|
return e.spec;
|
|
1345
1547
|
},
|
|
@@ -1350,7 +1552,7 @@ function Qn(e) {
|
|
|
1350
1552
|
return e.audioUnitSpec;
|
|
1351
1553
|
},
|
|
1352
1554
|
get children() {
|
|
1353
|
-
return
|
|
1555
|
+
return S(ri, {
|
|
1354
1556
|
get spec() {
|
|
1355
1557
|
return e.spec;
|
|
1356
1558
|
},
|
|
@@ -1361,17 +1563,17 @@ function Qn(e) {
|
|
|
1361
1563
|
return e.audioUnitSpec;
|
|
1362
1564
|
},
|
|
1363
1565
|
get children() {
|
|
1364
|
-
return [
|
|
1566
|
+
return [S(n, {}), S(t, {}), S(ie, {
|
|
1365
1567
|
get each() {
|
|
1366
1568
|
return e.audioUnitSpec.traversal;
|
|
1367
1569
|
},
|
|
1368
|
-
children: (i) =>
|
|
1570
|
+
children: (i) => S(Pt, {
|
|
1369
1571
|
get spec() {
|
|
1370
1572
|
return e.spec;
|
|
1371
1573
|
},
|
|
1372
1574
|
traversalFieldDef: i
|
|
1373
1575
|
})
|
|
1374
|
-
}),
|
|
1576
|
+
}), S(Ot, {
|
|
1375
1577
|
get unitName() {
|
|
1376
1578
|
return e.audioUnitSpec.name;
|
|
1377
1579
|
}
|
|
@@ -1383,160 +1585,160 @@ function Qn(e) {
|
|
|
1383
1585
|
}
|
|
1384
1586
|
});
|
|
1385
1587
|
}
|
|
1386
|
-
function
|
|
1387
|
-
const [
|
|
1388
|
-
const
|
|
1389
|
-
|
|
1588
|
+
function vi(e) {
|
|
1589
|
+
const [t, n] = se(), [i, r] = be(), [a, l] = Z(), [s, o] = R(), f = () => {
|
|
1590
|
+
const g = speechSynthesis.getVoices(), v = g.find((F) => F.name === "Samantha"), h = g.find((F) => F.localService && F.default), U = g.find((F) => F.default);
|
|
1591
|
+
o(v ?? h ?? U);
|
|
1390
1592
|
};
|
|
1391
|
-
|
|
1392
|
-
const d = () => e.units[0],
|
|
1393
|
-
traversalState: Object.fromEntries(
|
|
1394
|
-
}), [p,
|
|
1395
|
-
const
|
|
1593
|
+
f(), speechSynthesis.addEventListener("voiceschanged", f), H(() => speechSynthesis.removeEventListener("voiceschanged", f));
|
|
1594
|
+
const d = () => e.units[0], u = () => d().traversal, c = () => ({
|
|
1595
|
+
traversalState: Object.fromEntries(u().map((g) => [g.field, 0]))
|
|
1596
|
+
}), [p, m] = ye(c()), y = k(() => {
|
|
1597
|
+
const g = i.selection;
|
|
1396
1598
|
return e.units.map((v) => {
|
|
1397
|
-
const
|
|
1599
|
+
const h = Re(e.spec, v), U = g ? Ie(e.data, g) : e.data, F = Ve(e.spec, e.data, U, h), I = Oe(U, h, F), ee = Dt(e.spec, e.data, v);
|
|
1398
1600
|
return {
|
|
1399
1601
|
unit: v,
|
|
1400
|
-
derivedData:
|
|
1401
|
-
scales:
|
|
1602
|
+
derivedData: I,
|
|
1603
|
+
scales: ee
|
|
1402
1604
|
};
|
|
1403
1605
|
});
|
|
1404
|
-
}),
|
|
1405
|
-
const
|
|
1406
|
-
return Object.fromEntries(
|
|
1407
|
-
const
|
|
1408
|
-
return [v.field,
|
|
1606
|
+
}), w = k(() => {
|
|
1607
|
+
const g = y().flatMap((v) => v.derivedData);
|
|
1608
|
+
return Object.fromEntries(u().map((v) => {
|
|
1609
|
+
const h = D(e.spec, v.field), U = _(h, v);
|
|
1610
|
+
return [v.field, re(U, g, !0)];
|
|
1409
1611
|
}));
|
|
1410
|
-
}),
|
|
1612
|
+
}), O = k(() => Object.fromEntries(u().map((g) => [g.field, $t(e.spec, e.data, g.field)]))), V = (g, v, h) => ({
|
|
1411
1613
|
spec: e.spec,
|
|
1412
|
-
audioUnitSpec:
|
|
1614
|
+
audioUnitSpec: g,
|
|
1413
1615
|
derivedData: v,
|
|
1414
|
-
fieldDomains:
|
|
1415
|
-
axisTicks:
|
|
1416
|
-
scales:
|
|
1616
|
+
fieldDomains: w(),
|
|
1617
|
+
axisTicks: O(),
|
|
1618
|
+
scales: h,
|
|
1417
1619
|
pauseBetweenSections: a.pauseBetweenSections
|
|
1418
|
-
}),
|
|
1419
|
-
const
|
|
1420
|
-
return
|
|
1421
|
-
}),
|
|
1422
|
-
voiceId:
|
|
1423
|
-
|
|
1424
|
-
notes:
|
|
1425
|
-
}))),
|
|
1426
|
-
voiceId:
|
|
1427
|
-
notes:
|
|
1428
|
-
})))),
|
|
1429
|
-
|
|
1430
|
-
a.isPlaying &&
|
|
1620
|
+
}), C = k(() => {
|
|
1621
|
+
const g = y()[0];
|
|
1622
|
+
return V(g.unit, g.derivedData, g.scales);
|
|
1623
|
+
}), T = k(() => y().map((g, v) => ({
|
|
1624
|
+
voiceId: g.unit.name,
|
|
1625
|
+
instrument: g.unit.instrument ?? Gn(v),
|
|
1626
|
+
notes: kt(V(g.unit, g.derivedData, g.scales))
|
|
1627
|
+
}))), z = k(() => ii(T().map((g) => ({
|
|
1628
|
+
voiceId: g.voiceId,
|
|
1629
|
+
notes: g.notes
|
|
1630
|
+
})))), Ue = (g) => z().find((v) => Object.entries(g).every(([h, U]) => v.state[h] === U)), q = k(() => Tt(C(), p.traversalState)), oe = () => w(), Ae = (g, v) => we(C(), g, v), Q = () => i.activeUnitName === e.groupName;
|
|
1631
|
+
P(() => {
|
|
1632
|
+
a.isPlaying && n.setSelection({
|
|
1431
1633
|
source: "sonification",
|
|
1432
|
-
predicate:
|
|
1634
|
+
predicate: q()
|
|
1433
1635
|
});
|
|
1434
|
-
}),
|
|
1435
|
-
const v =
|
|
1636
|
+
}), P((g) => {
|
|
1637
|
+
const v = w(), h = {
|
|
1436
1638
|
...p.traversalState
|
|
1437
1639
|
};
|
|
1438
1640
|
let U = !1;
|
|
1439
|
-
const
|
|
1440
|
-
...
|
|
1641
|
+
const F = {
|
|
1642
|
+
...h
|
|
1441
1643
|
};
|
|
1442
|
-
return Object.entries(v).forEach(([
|
|
1443
|
-
const
|
|
1444
|
-
if (
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1644
|
+
return Object.entries(v).forEach(([I, ee]) => {
|
|
1645
|
+
const te = h[I], ue = (g?.[I] ?? ee)[te];
|
|
1646
|
+
if (ue !== void 0) {
|
|
1647
|
+
const De = ee.findIndex((Rt) => Rt === ue);
|
|
1648
|
+
De !== te && (F[I] = De !== -1 ? De : 0, U = !0);
|
|
1447
1649
|
}
|
|
1448
|
-
}), U && (
|
|
1449
|
-
...
|
|
1450
|
-
traversalState:
|
|
1451
|
-
})),
|
|
1452
|
-
}),
|
|
1453
|
-
const
|
|
1454
|
-
voiceId:
|
|
1455
|
-
|
|
1456
|
-
}) =>
|
|
1457
|
-
|
|
1650
|
+
}), U && (m((I) => ({
|
|
1651
|
+
...I,
|
|
1652
|
+
traversalState: F
|
|
1653
|
+
})), Q() && b.setupTransportSequence()), v;
|
|
1654
|
+
}), P((g) => (g !== e.units && b.setupTransportSequence(), e.units));
|
|
1655
|
+
const ce = () => T().forEach(({
|
|
1656
|
+
voiceId: g,
|
|
1657
|
+
instrument: v
|
|
1658
|
+
}) => l.ensureVoice(g, v)), G = (g) => {
|
|
1659
|
+
g.notes.forEach(({
|
|
1458
1660
|
voiceId: v,
|
|
1459
|
-
note:
|
|
1661
|
+
note: h
|
|
1460
1662
|
}) => {
|
|
1461
|
-
|
|
1663
|
+
g.ramp ? l.startOrRampSynth(h, v) : l.playNote(h, v);
|
|
1462
1664
|
});
|
|
1463
|
-
},
|
|
1464
|
-
|
|
1665
|
+
}, E = (g) => {
|
|
1666
|
+
g.notes.forEach(({
|
|
1465
1667
|
voiceId: v,
|
|
1466
|
-
note:
|
|
1467
|
-
}) =>
|
|
1468
|
-
},
|
|
1469
|
-
setTraversalIndex: (
|
|
1470
|
-
|
|
1668
|
+
note: h
|
|
1669
|
+
}) => l.playNote(h, v));
|
|
1670
|
+
}, b = {
|
|
1671
|
+
setTraversalIndex: (g, v) => {
|
|
1672
|
+
l.stopTransport(), m((U) => ({
|
|
1471
1673
|
...U,
|
|
1472
1674
|
traversalState: {
|
|
1473
1675
|
...U.traversalState,
|
|
1474
|
-
[
|
|
1676
|
+
[g]: v
|
|
1475
1677
|
}
|
|
1476
|
-
})),
|
|
1678
|
+
})), Q() && (r.setActiveUnit(e.groupName), b.setupTransportSequence()), n.setSelection({
|
|
1477
1679
|
source: "sonification",
|
|
1478
|
-
predicate:
|
|
1479
|
-
}),
|
|
1480
|
-
const
|
|
1481
|
-
|
|
1680
|
+
predicate: q()
|
|
1681
|
+
}), ce();
|
|
1682
|
+
const h = Ue(p.traversalState);
|
|
1683
|
+
h && (a.transport.seconds = h.time, E(h));
|
|
1482
1684
|
},
|
|
1483
|
-
getTraversalIndex: (
|
|
1484
|
-
getFieldDomains:
|
|
1485
|
-
getDerivedData: () =>
|
|
1486
|
-
getDomainValue:
|
|
1685
|
+
getTraversalIndex: (g) => p.traversalState[g],
|
|
1686
|
+
getFieldDomains: oe,
|
|
1687
|
+
getDerivedData: () => C().derivedData,
|
|
1688
|
+
getDomainValue: Ae,
|
|
1487
1689
|
setupTransportSequence: () => {
|
|
1488
|
-
a.transport.cancel(), a.transport.bpm.value =
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
Object.entries(
|
|
1690
|
+
a.transport.cancel(), a.transport.bpm.value = ae, ce();
|
|
1691
|
+
const g = z();
|
|
1692
|
+
g.forEach((h) => {
|
|
1693
|
+
Object.entries(h.state).every(([U, F]) => p.traversalState[U] === F) && (a.transport.seconds = h.time), a.transport.schedule(() => {
|
|
1492
1694
|
if (a.isPlaying)
|
|
1493
|
-
if (
|
|
1695
|
+
if (m((U) => ({
|
|
1494
1696
|
...U,
|
|
1495
|
-
traversalState:
|
|
1496
|
-
})),
|
|
1497
|
-
a.transport.pause(),
|
|
1498
|
-
const U = new SpeechSynthesisUtterance(
|
|
1697
|
+
traversalState: h.state
|
|
1698
|
+
})), h.speakBefore && a.speakAxisTicks && !a.muted) {
|
|
1699
|
+
a.transport.pause(), l.releaseSynth(), speechSynthesis.cancel();
|
|
1700
|
+
const U = new SpeechSynthesisUtterance(h.speakBefore);
|
|
1499
1701
|
U.voice = s() ?? null, U.rate = a.speechRate / 25, U.onend = () => {
|
|
1500
|
-
a.isPlaying && (
|
|
1702
|
+
a.isPlaying && (G(h), a.transport.start());
|
|
1501
1703
|
}, speechSynthesis.speak(U);
|
|
1502
1704
|
} else
|
|
1503
|
-
|
|
1504
|
-
},
|
|
1705
|
+
G(h);
|
|
1706
|
+
}, h.time), h.pauseAfter && a.transport.schedule(() => l.releaseSynth(), h.time + h.slotDuration);
|
|
1505
1707
|
});
|
|
1506
|
-
const v =
|
|
1507
|
-
v && a.transport.schedule(() =>
|
|
1708
|
+
const v = g[g.length - 1];
|
|
1709
|
+
v && a.transport.schedule(() => l.stopTransport(), v.time + v.slotDuration), a.transport.bpm.value = ae * a.playbackRate;
|
|
1508
1710
|
},
|
|
1509
1711
|
resetTraversalIfEnd: () => {
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1712
|
+
const g = w();
|
|
1713
|
+
u().every((h) => p.traversalState[h.field] === g[h.field].length - 1) && (m(c()), a.transport.seconds = 0);
|
|
1512
1714
|
},
|
|
1513
|
-
describeEncodings: () => e.units.map((
|
|
1514
|
-
describePlaybackOrder: () =>
|
|
1715
|
+
describeEncodings: () => e.units.map((g, v) => `layer ${v + 1}: ${xt(V(g, y()[v].derivedData, y()[v].scales))}`).join("; "),
|
|
1716
|
+
describePlaybackOrder: () => _t(C())
|
|
1515
1717
|
};
|
|
1516
|
-
return
|
|
1517
|
-
value: [p,
|
|
1718
|
+
return S(je.Provider, {
|
|
1719
|
+
value: [p, b],
|
|
1518
1720
|
get children() {
|
|
1519
1721
|
return e.children;
|
|
1520
1722
|
}
|
|
1521
1723
|
});
|
|
1522
1724
|
}
|
|
1523
|
-
var
|
|
1524
|
-
const
|
|
1525
|
-
function
|
|
1526
|
-
const [e,
|
|
1725
|
+
var hi = /* @__PURE__ */ A("<p><br>playing ");
|
|
1726
|
+
const it = "layer-group";
|
|
1727
|
+
function yi() {
|
|
1728
|
+
const [e, t] = Ee();
|
|
1527
1729
|
return (() => {
|
|
1528
|
-
var
|
|
1529
|
-
return i.nextSibling,
|
|
1730
|
+
var n = hi(), i = n.firstChild;
|
|
1731
|
+
return i.nextSibling, x(n, () => t.describeEncodings(), i), x(n, () => t.describePlaybackOrder(), null), n;
|
|
1530
1732
|
})();
|
|
1531
1733
|
}
|
|
1532
|
-
function
|
|
1533
|
-
const
|
|
1534
|
-
if (
|
|
1734
|
+
function Si(e) {
|
|
1735
|
+
const t = () => e.units.filter((i) => Object.keys(i.encoding).length > 0);
|
|
1736
|
+
if (t().length === 0)
|
|
1535
1737
|
return null;
|
|
1536
|
-
const
|
|
1537
|
-
return
|
|
1738
|
+
const n = () => t()[0].traversal;
|
|
1739
|
+
return S(Ft, {
|
|
1538
1740
|
get children() {
|
|
1539
|
-
return
|
|
1741
|
+
return S(vi, {
|
|
1540
1742
|
get spec() {
|
|
1541
1743
|
return e.spec;
|
|
1542
1744
|
},
|
|
@@ -1544,109 +1746,116 @@ function ii(e) {
|
|
|
1544
1746
|
return e.data;
|
|
1545
1747
|
},
|
|
1546
1748
|
get units() {
|
|
1547
|
-
return
|
|
1749
|
+
return t();
|
|
1548
1750
|
},
|
|
1549
|
-
groupName:
|
|
1751
|
+
groupName: it,
|
|
1550
1752
|
get children() {
|
|
1551
|
-
return [
|
|
1753
|
+
return [S(yi, {}), S(ie, {
|
|
1552
1754
|
get each() {
|
|
1553
|
-
return
|
|
1755
|
+
return n();
|
|
1554
1756
|
},
|
|
1555
|
-
children: (i) =>
|
|
1757
|
+
children: (i) => S(Pt, {
|
|
1556
1758
|
get spec() {
|
|
1557
1759
|
return e.spec;
|
|
1558
1760
|
},
|
|
1559
1761
|
traversalFieldDef: i
|
|
1560
1762
|
})
|
|
1561
|
-
}),
|
|
1562
|
-
unitName:
|
|
1763
|
+
}), S(Ot, {
|
|
1764
|
+
unitName: it
|
|
1563
1765
|
})];
|
|
1564
1766
|
}
|
|
1565
1767
|
});
|
|
1566
1768
|
}
|
|
1567
1769
|
});
|
|
1568
1770
|
}
|
|
1569
|
-
var
|
|
1570
|
-
const
|
|
1771
|
+
var bi = /* @__PURE__ */ A("<div><label>Playback rate <input type=number min=0.1 max=4 step=0.1 id=rate>x"), wi = /* @__PURE__ */ A("<label><input type=checkbox>Speak axis ticks"), Ei = /* @__PURE__ */ A("<label><input type=number min=1 max=100 step=10 id=speechRate>speech rate"), Ui = /* @__PURE__ */ A("<div><label><input type=checkbox aria-live=polite>");
|
|
1772
|
+
const Ai = N.div`
|
|
1571
1773
|
margin-top: 1rem;
|
|
1572
|
-
`,
|
|
1774
|
+
`, Di = N.div`
|
|
1573
1775
|
display: flex;
|
|
1574
1776
|
gap: 3px;
|
|
1575
1777
|
`;
|
|
1576
|
-
function
|
|
1577
|
-
const [
|
|
1578
|
-
return
|
|
1778
|
+
function $i(e) {
|
|
1779
|
+
const [t, n] = Z();
|
|
1780
|
+
return S(Ai, {
|
|
1579
1781
|
get children() {
|
|
1580
1782
|
return [(() => {
|
|
1581
|
-
var i =
|
|
1582
|
-
return
|
|
1583
|
-
})(),
|
|
1783
|
+
var i = bi(), r = i.firstChild, a = r.firstChild, l = a.nextSibling;
|
|
1784
|
+
return l.addEventListener("change", (s) => n.setPlaybackRate(Number(s.target.value))), L(() => l.value = t.playbackRate), i;
|
|
1785
|
+
})(), S(Di, {
|
|
1584
1786
|
get children() {
|
|
1585
1787
|
return [(() => {
|
|
1586
|
-
var i =
|
|
1587
|
-
return r.addEventListener("change", (a) =>
|
|
1788
|
+
var i = wi(), r = i.firstChild;
|
|
1789
|
+
return r.addEventListener("change", (a) => n.setSpeakAxisTicks(a.target.checked)), L(() => r.checked = t.speakAxisTicks), i;
|
|
1588
1790
|
})(), (() => {
|
|
1589
|
-
var i =
|
|
1590
|
-
return r.addEventListener("change", (a) =>
|
|
1791
|
+
var i = Ei(), r = i.firstChild;
|
|
1792
|
+
return r.addEventListener("change", (a) => n.setSpeechRate(Number(a.target.value))), L(() => r.value = t.speechRate), i;
|
|
1591
1793
|
})()];
|
|
1592
1794
|
}
|
|
1593
1795
|
}), (() => {
|
|
1594
|
-
var i =
|
|
1595
|
-
return a.addEventListener("change", (
|
|
1796
|
+
var i = Ui(), r = i.firstChild, a = r.firstChild;
|
|
1797
|
+
return a.addEventListener("change", (l) => n.setMuted(l.target.checked)), x(r, () => t.muted ? "Muted" : "Unmuted", null), L(() => a.checked = t.muted), i;
|
|
1596
1798
|
})()];
|
|
1597
1799
|
}
|
|
1598
1800
|
});
|
|
1599
1801
|
}
|
|
1600
|
-
function
|
|
1802
|
+
function Ti() {
|
|
1601
1803
|
const e = document.activeElement;
|
|
1602
1804
|
if (!e) return !1;
|
|
1603
|
-
const
|
|
1604
|
-
return
|
|
1605
|
-
}
|
|
1606
|
-
function
|
|
1607
|
-
const n = (
|
|
1608
|
-
if (
|
|
1609
|
-
const
|
|
1610
|
-
|
|
1805
|
+
const t = e.tagName.toLowerCase();
|
|
1806
|
+
return t === "input" || t === "select" || t === "textarea" || e.isContentEditable;
|
|
1807
|
+
}
|
|
1808
|
+
function ki(e, t) {
|
|
1809
|
+
const n = (i) => {
|
|
1810
|
+
if (Ti()) return;
|
|
1811
|
+
const r = e[i.key];
|
|
1812
|
+
r && (i.preventDefault(), r());
|
|
1611
1813
|
};
|
|
1612
|
-
|
|
1814
|
+
P(() => {
|
|
1815
|
+
const i = t ? t() : document;
|
|
1816
|
+
i && (i.addEventListener("keydown", n), H(() => i.removeEventListener("keydown", n)));
|
|
1817
|
+
});
|
|
1613
1818
|
}
|
|
1614
|
-
function
|
|
1615
|
-
const [
|
|
1616
|
-
return
|
|
1819
|
+
function xi(e) {
|
|
1820
|
+
const [t, n] = Z(), [i, r] = be();
|
|
1821
|
+
return ki({
|
|
1617
1822
|
p: () => {
|
|
1618
|
-
|
|
1823
|
+
t.isPlaying ? n.stopTransport() : r.triggerPlay();
|
|
1619
1824
|
}
|
|
1620
|
-
}), null;
|
|
1825
|
+
}, e.target), null;
|
|
1621
1826
|
}
|
|
1622
|
-
function
|
|
1623
|
-
const
|
|
1624
|
-
return
|
|
1827
|
+
function _i(e) {
|
|
1828
|
+
const t = () => e.spec.audio.composition === "layer" && e.spec.audio.units.length > 1;
|
|
1829
|
+
return S(jn, {
|
|
1625
1830
|
get children() {
|
|
1626
|
-
return
|
|
1831
|
+
return S(Kn, {
|
|
1627
1832
|
get children() {
|
|
1628
|
-
return [
|
|
1833
|
+
return [S(xi, {
|
|
1834
|
+
get target() {
|
|
1835
|
+
return e.keyEventTarget;
|
|
1836
|
+
}
|
|
1837
|
+
}), S(st, {
|
|
1629
1838
|
get when() {
|
|
1630
|
-
return
|
|
1839
|
+
return t();
|
|
1631
1840
|
},
|
|
1632
1841
|
get fallback() {
|
|
1633
|
-
return
|
|
1842
|
+
return S(ie, {
|
|
1634
1843
|
get each() {
|
|
1635
1844
|
return e.spec.audio.units;
|
|
1636
1845
|
},
|
|
1637
|
-
children: (
|
|
1846
|
+
children: (n) => S(gi, {
|
|
1638
1847
|
get spec() {
|
|
1639
1848
|
return e.spec;
|
|
1640
1849
|
},
|
|
1641
1850
|
get data() {
|
|
1642
1851
|
return e.data;
|
|
1643
1852
|
},
|
|
1644
|
-
audioUnitSpec:
|
|
1853
|
+
audioUnitSpec: n
|
|
1645
1854
|
})
|
|
1646
1855
|
});
|
|
1647
1856
|
},
|
|
1648
1857
|
get children() {
|
|
1649
|
-
return
|
|
1858
|
+
return S(Si, {
|
|
1650
1859
|
get spec() {
|
|
1651
1860
|
return e.spec;
|
|
1652
1861
|
},
|
|
@@ -1658,150 +1867,152 @@ function pi(e) {
|
|
|
1658
1867
|
}
|
|
1659
1868
|
});
|
|
1660
1869
|
}
|
|
1661
|
-
}),
|
|
1870
|
+
}), S($i, {})];
|
|
1662
1871
|
}
|
|
1663
1872
|
});
|
|
1664
1873
|
}
|
|
1665
1874
|
});
|
|
1666
1875
|
}
|
|
1667
|
-
var
|
|
1668
|
-
function
|
|
1876
|
+
var Ni = /* @__PURE__ */ A("<h2>Visualization"), Fi = /* @__PURE__ */ A("<h2>Description"), Pi = /* @__PURE__ */ A("<h2>Sonification"), Oi = /* @__PURE__ */ A('<div><div class=uw-viewer role=region aria-label="Umwelt Viewer">');
|
|
1877
|
+
function Ci(e) {
|
|
1878
|
+
const [t, n] = R();
|
|
1669
1879
|
return (() => {
|
|
1670
|
-
var
|
|
1671
|
-
return
|
|
1880
|
+
var i = Oi(), r = i.firstChild;
|
|
1881
|
+
return Ne(n, r), x(r, S(Fn, {
|
|
1672
1882
|
get children() {
|
|
1673
|
-
return [
|
|
1883
|
+
return [Ni(), S(Vn, {
|
|
1674
1884
|
get spec() {
|
|
1675
1885
|
return e.spec;
|
|
1676
1886
|
},
|
|
1677
1887
|
get data() {
|
|
1678
1888
|
return e.data;
|
|
1679
1889
|
}
|
|
1680
|
-
}),
|
|
1890
|
+
}), Fi(), S(Ln, {
|
|
1681
1891
|
get spec() {
|
|
1682
1892
|
return e.spec;
|
|
1683
1893
|
},
|
|
1684
1894
|
get data() {
|
|
1685
1895
|
return e.data;
|
|
1686
1896
|
}
|
|
1687
|
-
}),
|
|
1897
|
+
}), Pi(), S(_i, {
|
|
1688
1898
|
get spec() {
|
|
1689
1899
|
return e.spec;
|
|
1690
1900
|
},
|
|
1691
1901
|
get data() {
|
|
1692
1902
|
return e.data;
|
|
1693
|
-
}
|
|
1903
|
+
},
|
|
1904
|
+
keyEventTarget: t
|
|
1694
1905
|
})];
|
|
1695
1906
|
}
|
|
1696
|
-
})),
|
|
1907
|
+
})), L(() => Vt(i, dn.Viewer)), i;
|
|
1697
1908
|
})();
|
|
1698
1909
|
}
|
|
1699
|
-
function
|
|
1700
|
-
const i =
|
|
1910
|
+
function rt(e, t, n = localStorage) {
|
|
1911
|
+
const i = n.getItem(e) ? JSON.parse(n.getItem(e)) : t, [r, a] = R(i);
|
|
1701
1912
|
return [r, ((s) => {
|
|
1702
1913
|
if (s) {
|
|
1703
|
-
const
|
|
1704
|
-
return
|
|
1914
|
+
const o = a(s);
|
|
1915
|
+
return n.setItem(e, JSON.stringify(o)), o;
|
|
1705
1916
|
}
|
|
1706
1917
|
})];
|
|
1707
1918
|
}
|
|
1708
|
-
const
|
|
1709
|
-
function
|
|
1710
|
-
const
|
|
1711
|
-
...
|
|
1919
|
+
const Ct = Y();
|
|
1920
|
+
function Ri(e) {
|
|
1921
|
+
const t = e.persist !== !1, [n, i] = t ? rt("umweltDatastore", {}) : R({}), [r, a] = t ? rt("umweltSessionDatastore", {}, sessionStorage) : R({}), l = () => ({
|
|
1922
|
+
...n(),
|
|
1712
1923
|
...r()
|
|
1713
1924
|
}), s = {
|
|
1714
|
-
setDataset: (
|
|
1715
|
-
|
|
1716
|
-
...
|
|
1717
|
-
[
|
|
1718
|
-
data:
|
|
1925
|
+
setDataset: (o, f, d, u) => {
|
|
1926
|
+
u?.session ? a((c) => ({
|
|
1927
|
+
...c,
|
|
1928
|
+
[o]: {
|
|
1929
|
+
data: f,
|
|
1719
1930
|
sourceUrl: d
|
|
1720
1931
|
}
|
|
1721
|
-
})) : i((
|
|
1722
|
-
...
|
|
1723
|
-
[
|
|
1724
|
-
data:
|
|
1725
|
-
sourceUrl:
|
|
1932
|
+
})) : i((c) => ({
|
|
1933
|
+
...c,
|
|
1934
|
+
[o]: {
|
|
1935
|
+
data: f,
|
|
1936
|
+
sourceUrl: c[o]?.sourceUrl || d
|
|
1726
1937
|
}
|
|
1727
1938
|
}));
|
|
1728
1939
|
},
|
|
1729
|
-
removeDataset: (
|
|
1730
|
-
i((
|
|
1940
|
+
removeDataset: (o) => {
|
|
1941
|
+
i((f) => {
|
|
1731
1942
|
const d = {
|
|
1732
|
-
...
|
|
1943
|
+
...f
|
|
1733
1944
|
};
|
|
1734
|
-
return delete d[
|
|
1735
|
-
}), s.removeSessionDataset(
|
|
1945
|
+
return delete d[o], d;
|
|
1946
|
+
}), s.removeSessionDataset(o);
|
|
1736
1947
|
},
|
|
1737
|
-
removeSessionDataset: (
|
|
1738
|
-
a((
|
|
1948
|
+
removeSessionDataset: (o) => {
|
|
1949
|
+
a((f) => {
|
|
1739
1950
|
const d = {
|
|
1740
|
-
...
|
|
1951
|
+
...f
|
|
1741
1952
|
};
|
|
1742
|
-
return delete d[
|
|
1953
|
+
return delete d[o], d;
|
|
1743
1954
|
});
|
|
1744
1955
|
}
|
|
1745
1956
|
};
|
|
1746
|
-
return
|
|
1747
|
-
value: [
|
|
1957
|
+
return S(Ct.Provider, {
|
|
1958
|
+
value: [l, s],
|
|
1748
1959
|
get children() {
|
|
1749
1960
|
return e.children;
|
|
1750
1961
|
}
|
|
1751
1962
|
});
|
|
1752
1963
|
}
|
|
1753
|
-
function
|
|
1754
|
-
const e =
|
|
1964
|
+
function Vi() {
|
|
1965
|
+
const e = X(Ct);
|
|
1755
1966
|
if (e === void 0)
|
|
1756
1967
|
throw new Error("useUmweltDatastore must be used within a UmweltDatastoreProvider");
|
|
1757
1968
|
return e;
|
|
1758
1969
|
}
|
|
1759
|
-
var
|
|
1760
|
-
function
|
|
1761
|
-
const [
|
|
1970
|
+
var Ii = /* @__PURE__ */ A("<div>"), Li = /* @__PURE__ */ A("<div>Loading..."), ji = /* @__PURE__ */ A("<div role=alert>");
|
|
1971
|
+
function qi(e) {
|
|
1972
|
+
const [t, n] = Vi(), [i, r] = R(), [a, l] = R(!0), [s, o] = R(), f = () => {
|
|
1762
1973
|
const d = i();
|
|
1763
|
-
return d ?
|
|
1974
|
+
return d ? t()[d.data.name]?.data || [] : [];
|
|
1764
1975
|
};
|
|
1765
|
-
return
|
|
1976
|
+
return P(async () => {
|
|
1766
1977
|
const d = e.exportableSpec;
|
|
1767
|
-
|
|
1978
|
+
l(!0), o(void 0);
|
|
1768
1979
|
try {
|
|
1769
|
-
const
|
|
1770
|
-
|
|
1771
|
-
} catch (
|
|
1772
|
-
console.error("Error loading spec:",
|
|
1980
|
+
const u = await $n(d, t(), n.setDataset);
|
|
1981
|
+
u ? r(u) : o("Failed to load Umwelt spec: the spec is invalid or its data source could not be resolved.");
|
|
1982
|
+
} catch (u) {
|
|
1983
|
+
console.error("Error loading spec:", u), o(`Failed to load Umwelt spec: ${u}`);
|
|
1773
1984
|
} finally {
|
|
1774
|
-
|
|
1985
|
+
l(!1);
|
|
1775
1986
|
}
|
|
1776
1987
|
}), (() => {
|
|
1777
|
-
var d =
|
|
1778
|
-
return
|
|
1779
|
-
var
|
|
1780
|
-
return () =>
|
|
1781
|
-
})(), null),
|
|
1782
|
-
var
|
|
1783
|
-
return () =>
|
|
1784
|
-
var
|
|
1785
|
-
return
|
|
1988
|
+
var d = Ii();
|
|
1989
|
+
return x(d, (() => {
|
|
1990
|
+
var u = pe(() => !!a());
|
|
1991
|
+
return () => u() && Li();
|
|
1992
|
+
})(), null), x(d, (() => {
|
|
1993
|
+
var u = pe(() => !!(!a() && s()));
|
|
1994
|
+
return () => u() && (() => {
|
|
1995
|
+
var c = ji();
|
|
1996
|
+
return x(c, s), c;
|
|
1786
1997
|
})();
|
|
1787
|
-
})(), null),
|
|
1788
|
-
var
|
|
1789
|
-
return () =>
|
|
1998
|
+
})(), null), x(d, (() => {
|
|
1999
|
+
var u = pe(() => !!(!a() && !s() && i()));
|
|
2000
|
+
return () => u() && S(Ci, {
|
|
1790
2001
|
get spec() {
|
|
1791
2002
|
return i();
|
|
1792
2003
|
},
|
|
1793
2004
|
get data() {
|
|
1794
|
-
return
|
|
2005
|
+
return f();
|
|
1795
2006
|
}
|
|
1796
2007
|
});
|
|
1797
2008
|
})(), null), d;
|
|
1798
2009
|
})();
|
|
1799
2010
|
}
|
|
1800
|
-
function
|
|
1801
|
-
return
|
|
2011
|
+
function Mi(e) {
|
|
2012
|
+
return S(Ri, {
|
|
1802
2013
|
persist: !1,
|
|
1803
2014
|
get children() {
|
|
1804
|
-
return
|
|
2015
|
+
return S(qi, {
|
|
1805
2016
|
get exportableSpec() {
|
|
1806
2017
|
return e.exportableSpec;
|
|
1807
2018
|
}
|
|
@@ -1809,25 +2020,25 @@ function $i(e) {
|
|
|
1809
2020
|
}
|
|
1810
2021
|
});
|
|
1811
2022
|
}
|
|
1812
|
-
class
|
|
1813
|
-
constructor(
|
|
1814
|
-
this.options =
|
|
2023
|
+
class Bi {
|
|
2024
|
+
constructor(t) {
|
|
2025
|
+
this.options = t, this.mount();
|
|
1815
2026
|
}
|
|
1816
2027
|
disposal;
|
|
1817
2028
|
isDestroyed = !1;
|
|
1818
2029
|
mount() {
|
|
1819
2030
|
if (this.isDestroyed)
|
|
1820
2031
|
throw new Error("Cannot mount a destroyed UmweltViewer. Create a new instance.");
|
|
1821
|
-
this.disposal =
|
|
2032
|
+
this.disposal = It(() => Mi({ exportableSpec: this.options.spec }), this.options.container);
|
|
1822
2033
|
}
|
|
1823
2034
|
/**
|
|
1824
2035
|
* Update the viewer with a new specification.
|
|
1825
2036
|
* This will re-render the entire viewer with the new data and configuration.
|
|
1826
2037
|
*/
|
|
1827
|
-
updateSpec(
|
|
2038
|
+
updateSpec(t) {
|
|
1828
2039
|
if (this.isDestroyed)
|
|
1829
2040
|
throw new Error("Cannot update a destroyed UmweltViewer.");
|
|
1830
|
-
this.cleanup(), this.options.spec =
|
|
2041
|
+
this.cleanup(), this.options.spec = t, this.mount();
|
|
1831
2042
|
}
|
|
1832
2043
|
/**
|
|
1833
2044
|
* Get the current specification.
|
|
@@ -1858,10 +2069,10 @@ class Ti {
|
|
|
1858
2069
|
return this.isDestroyed;
|
|
1859
2070
|
}
|
|
1860
2071
|
}
|
|
1861
|
-
function
|
|
1862
|
-
return new
|
|
2072
|
+
function ur(e, t) {
|
|
2073
|
+
return new Bi({ spec: e, container: t });
|
|
1863
2074
|
}
|
|
1864
2075
|
export {
|
|
1865
|
-
|
|
1866
|
-
|
|
2076
|
+
Bi as UmweltViewer,
|
|
2077
|
+
ur as createViewer
|
|
1867
2078
|
};
|