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