@fxi/zartigl 0.10.5 → 0.11.1
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/catalog.js +1 -1
- package/dist/{engine--787AbnI.js → engine-BBxJ6x3s.js} +767 -483
- package/dist/engine.d.ts +61 -2
- package/dist/engine.js +57 -56
- package/dist/{index-Bo7du_KN.js → index-DKYFuzyw.js} +1 -1
- package/dist/zartigl.js +3 -3
- package/package.json +1 -1
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import "./backdrop-Dceb4d8E.js";
|
|
2
|
-
const
|
|
3
|
-
thermal:
|
|
2
|
+
const Te = { label: "Thermal", tags: ["sequential", "temperature"], colors: ["#042333", "#2c3395", "#744796", "#b15f82", "#eb7958", "#fbb43d", "#e8fa5b"] }, be = { label: "Haline", tags: ["sequential", "salinity"], colors: ["#2a186c", "#17568b", "#1a7e8f", "#22a785", "#55c666", "#aadc32", "#fde333"] }, we = { label: "Solar", tags: ["sequential", "irradiance"], colors: ["#330f0b", "#6b2313", "#a83c12", "#d6621a", "#f3951e", "#f7c741", "#f9f871"] }, ye = { label: "Ice", tags: ["sequential"], colors: ["#040d1a", "#123365", "#1c5f9e", "#2b8ece", "#62bde3", "#aaddf2", "#f2faff"] }, _e = { label: "Deep", tags: ["sequential", "depth"], colors: ["#fdfecc", "#c8e59b", "#74c8a3", "#3194b0", "#2a5b8e", "#281a5e", "#0c0820"] }, Re = { label: "RdYlBu", tags: ["diverging"], colors: ["#3288bd", "#66c2a5", "#abdda4", "#e6f598", "#fee08b", "#fdae61", "#f46d43", "#d53e4f"] }, xe = { label: "Dense", tags: ["sequential"], colors: ["#e6f1f1", "#92c4ca", "#44929a", "#20627a", "#1a3c6a", "#211a50", "#0d0621"] }, ve = { label: "Algae", tags: ["sequential", "biology", "log"], colors: ["#d7f9d0", "#a2d595", "#64b463", "#129450", "#126e45", "#1a482f", "#122414"] }, ke = { label: "Oxygen", tags: ["sequential", "biology", "hypoxia"], colors: ["#09060f", "#5b1028", "#d43d2f", "#f39b3d", "#f3e7b3", "#79cbd1", "#176b9c"] }, Ae = { label: "Matter", tags: ["sequential", "biology"], colors: ["#fdfecc", "#f2c98a", "#e07c4e", "#bc3754", "#8d1a6d", "#51156b", "#1c0c3f"] }, Fe = { label: "Viridis", tags: ["sequential", "perceptual"], colors: ["#440154", "#443983", "#31688e", "#21918c", "#35b779", "#90d743", "#fde725"] }, Se = { label: "Plasma", tags: ["sequential", "perceptual"], colors: ["#0d0887", "#5e01a6", "#9c179e", "#cc4778", "#ed7953", "#fdb42f", "#f0f921"] }, Ue = { label: "Cyclic", tags: ["cyclic", "direction"], colors: ["#2e22ea", "#b541fb", "#fc93c0", "#f1ee35", "#77c80d", "#458776", "#2c24e9"] }, Me = { label: "Tempo", tags: ["sequential"], colors: ["#fff6f4", "#c2d1b9", "#7db390", "#2a937f", "#156d73", "#1c455b", "#151d44"] }, Pe = { label: "Turbid", tags: ["sequential", "biology", "log"], colors: ["#e9f5a0", "#c8c86e", "#a09845", "#786031", "#533324", "#341423", "#150d17"] }, De = { label: "Speed", tags: ["sequential", "velocity"], colors: ["#fcfea4", "#d5e429", "#94c63e", "#52a657", "#2d8169", "#1d5b6d", "#0d3361"] }, Ge = { label: "Amp", tags: ["sequential"], colors: ["#f2f2f2", "#c0b8db", "#9180b6", "#6c4e9e", "#4e2e83", "#32185d", "#110a35"] }, Ne = { label: "Heat", tags: ["sequential"], colors: ["#fde725", "#fde725", "#f8961e", "#e63946", "#9d0208", "#3a0007"] }, Ie = { label: "Balance", tags: ["diverging"], colors: ["#181c43", "#3066af", "#9bbcdd", "#f2f2f2", "#e07d53", "#b13626", "#2c0b0e"] }, Le = { label: "Delta", tags: ["diverging"], colors: ["#0e3f31", "#20877b", "#99d4c1", "#f2f2f2", "#a1b0d4", "#3c5b9e", "#0d1938"] }, Ce = { label: "Curl", tags: ["diverging"], colors: ["#152237", "#2471b3", "#8dbac4", "#f2f2f2", "#c79f84", "#a63827", "#270b17"] }, Ve = { label: "Gray", tags: ["sequential"], colors: ["#000000", "#252525", "#4d4d4d", "#7a7a7a", "#a8a8a8", "#d4d4d4", "#ffffff"] }, he = {
|
|
3
|
+
thermal: Te,
|
|
4
4
|
"thermal-alt": { label: "Thermal Alt", tags: ["sequential", "temperature"], colors: ["#176b9c", "#79cbd1", "#f3e7b3", "#f39b3d", "#d43d2f", "#5b1028", "#09060f"] },
|
|
5
|
-
haline:
|
|
6
|
-
solar:
|
|
7
|
-
ice:
|
|
8
|
-
deep:
|
|
9
|
-
rdylbu:
|
|
10
|
-
dense:
|
|
11
|
-
algae:
|
|
12
|
-
oxygen:
|
|
13
|
-
matter:
|
|
14
|
-
viridis:
|
|
15
|
-
plasma:
|
|
16
|
-
cyclic:
|
|
17
|
-
tempo:
|
|
18
|
-
turbid:
|
|
19
|
-
speed:
|
|
20
|
-
amp:
|
|
21
|
-
heat:
|
|
5
|
+
haline: be,
|
|
6
|
+
solar: we,
|
|
7
|
+
ice: ye,
|
|
8
|
+
deep: _e,
|
|
9
|
+
rdylbu: Re,
|
|
10
|
+
dense: xe,
|
|
11
|
+
algae: ve,
|
|
12
|
+
oxygen: ke,
|
|
13
|
+
matter: Ae,
|
|
14
|
+
viridis: Fe,
|
|
15
|
+
plasma: Se,
|
|
16
|
+
cyclic: Ue,
|
|
17
|
+
tempo: Me,
|
|
18
|
+
turbid: Pe,
|
|
19
|
+
speed: De,
|
|
20
|
+
amp: Ge,
|
|
21
|
+
heat: Ne,
|
|
22
22
|
"heat-alert": { label: "Heat Alert", tags: ["sequential", "alpha", "deprecated"], colors: ["#fde72500", "#fde725cc", "#f8961e", "#e63946", "#9d0208", "#3a0007"] },
|
|
23
|
-
balance:
|
|
24
|
-
delta:
|
|
25
|
-
curl:
|
|
23
|
+
balance: Ie,
|
|
24
|
+
delta: Le,
|
|
25
|
+
curl: Ce,
|
|
26
26
|
"mono-black": { label: "Black", tags: ["monochrome", "particles"], colors: ["#000000", "#000000"] },
|
|
27
27
|
"mono-white": { label: "White", tags: ["monochrome", "particles"], colors: ["#ffffff", "#ffffff"] },
|
|
28
28
|
"mono-pink": { label: "Pink", tags: ["monochrome", "particles"], colors: ["#ff2aa1", "#ff2aa1"] },
|
|
29
|
-
gray:
|
|
30
|
-
},
|
|
29
|
+
gray: Ve
|
|
30
|
+
}, ie = 64, Oe = {
|
|
31
31
|
linear: (t) => t,
|
|
32
32
|
// Rises fast: values just inside the zone already show.
|
|
33
33
|
log: (t) => Math.log10(1 + 9 * t),
|
|
34
34
|
// Stays faint longer: codec noise at the end of the range stays hidden.
|
|
35
35
|
exp: (t) => (10 ** t - 1) / 9
|
|
36
36
|
};
|
|
37
|
-
function
|
|
38
|
-
const i =
|
|
39
|
-
let
|
|
40
|
-
return r > 0 && t < r && (
|
|
37
|
+
function Be(t, e) {
|
|
38
|
+
const i = Oe[e.curve ?? "linear"], r = e.low ?? 0, n = e.high ?? 0;
|
|
39
|
+
let s = 1;
|
|
40
|
+
return r > 0 && t < r && (s = Math.min(s, i(Math.max(t, 0) / r))), n > 0 && t > 1 - n && (s = Math.min(s, i(Math.max(1 - t, 0) / n))), s;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function Xe(t) {
|
|
43
43
|
let e = t.replace("#", "");
|
|
44
44
|
(e.length === 3 || e.length === 4) && (e = [...e].map((r) => r + r).join(""));
|
|
45
45
|
const i = (r) => parseInt(e.slice(r, r + 2), 16);
|
|
@@ -50,46 +50,46 @@ function ve(t) {
|
|
|
50
50
|
e.length === 8 ? i(6) : 255
|
|
51
51
|
];
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function qe([t, e, i, r]) {
|
|
54
54
|
return `#${[t, e, i, r].map(
|
|
55
55
|
(n) => Math.round(Math.min(255, Math.max(0, n))).toString(16).padStart(2, "0")
|
|
56
56
|
).join("")}`;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function $e(t, e) {
|
|
59
59
|
if (e <= t[0][0])
|
|
60
60
|
return t[0][1];
|
|
61
61
|
for (let i = 1; i < t.length; i++) {
|
|
62
62
|
const [r, n] = t[i];
|
|
63
63
|
if (e <= r) {
|
|
64
|
-
const [
|
|
65
|
-
return o.map((
|
|
64
|
+
const [s, o] = t[i - 1], a = r === s ? 1 : (e - s) / (r - s);
|
|
65
|
+
return o.map((d, c) => d + (n[c] - d) * a);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
return t[t.length - 1][1];
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function We(t, e) {
|
|
71
71
|
const i = Object.entries(t).map(
|
|
72
|
-
([n,
|
|
73
|
-
).sort((n,
|
|
74
|
-
for (let n = 0; n <=
|
|
75
|
-
const
|
|
76
|
-
r[
|
|
72
|
+
([n, s]) => [Number(n), Xe(s)]
|
|
73
|
+
).sort((n, s) => n[0] - s[0]), r = {};
|
|
74
|
+
for (let n = 0; n <= ie; n++) {
|
|
75
|
+
const s = n / ie, [o, a, d, c] = $e(i, s);
|
|
76
|
+
r[s] = qe([o, a, d, c * Be(s, e)]);
|
|
77
77
|
}
|
|
78
78
|
return r;
|
|
79
79
|
}
|
|
80
|
-
const
|
|
81
|
-
function
|
|
80
|
+
const He = (t) => !!t && ((t.low ?? 0) > 0 || (t.high ?? 0) > 0);
|
|
81
|
+
function re(t) {
|
|
82
82
|
const e = {}, i = t.length - 1;
|
|
83
83
|
return t.forEach((r, n) => {
|
|
84
84
|
e[i === 0 ? 0 : n / i] = r;
|
|
85
85
|
}), e;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
const i =
|
|
89
|
-
return
|
|
87
|
+
function ze(t, e) {
|
|
88
|
+
const i = Ye(t, e?.reverse ?? !1);
|
|
89
|
+
return He(e?.alphaFade) ? We(i, e.alphaFade) : i;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
const i =
|
|
91
|
+
function Ye(t, e) {
|
|
92
|
+
const i = he;
|
|
93
93
|
if (typeof t == "string") {
|
|
94
94
|
const r = i[t];
|
|
95
95
|
if (!r)
|
|
@@ -99,22 +99,22 @@ function Ue(t, e) {
|
|
|
99
99
|
).join(", ")}`
|
|
100
100
|
);
|
|
101
101
|
const n = e ? [...r.colors].reverse() : r.colors;
|
|
102
|
-
return
|
|
102
|
+
return re(n);
|
|
103
103
|
}
|
|
104
104
|
if (Array.isArray(t)) {
|
|
105
105
|
const r = e ? [...t].reverse() : t;
|
|
106
|
-
return
|
|
106
|
+
return re(r);
|
|
107
107
|
}
|
|
108
108
|
return e ? Object.fromEntries(
|
|
109
109
|
Object.entries(t).map(([r, n]) => [1 - Number(r), n])
|
|
110
110
|
) : t;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
return Object.entries(
|
|
112
|
+
function jt(t = {}) {
|
|
113
|
+
return Object.entries(he).map(([i, r]) => ({ id: i, ...r })).filter(
|
|
114
114
|
(i) => t.includeDeprecated || !i.tags.includes("deprecated")
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function ne(t, e, i) {
|
|
118
118
|
const r = t.createShader(e);
|
|
119
119
|
if (!r)
|
|
120
120
|
throw new Error("Failed to create shader");
|
|
@@ -124,22 +124,22 @@ function X(t, e, i) {
|
|
|
124
124
|
}
|
|
125
125
|
return r;
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function Kt(t, e, i) {
|
|
128
128
|
const r = t.createProgram();
|
|
129
129
|
if (!r)
|
|
130
130
|
throw new Error("Failed to create program");
|
|
131
|
-
const n =
|
|
132
|
-
if (t.attachShader(r, n), t.attachShader(r,
|
|
131
|
+
const n = ne(t, t.VERTEX_SHADER, e), s = ne(t, t.FRAGMENT_SHADER, i);
|
|
132
|
+
if (t.attachShader(r, n), t.attachShader(r, s), t.linkProgram(r), !t.getProgramParameter(r, t.LINK_STATUS)) {
|
|
133
133
|
const o = t.getProgramInfoLog(r);
|
|
134
134
|
throw t.deleteProgram(r), new Error(`Program link error: ${o}`);
|
|
135
135
|
}
|
|
136
|
-
return t.deleteShader(n), t.deleteShader(
|
|
136
|
+
return t.deleteShader(n), t.deleteShader(s), r;
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
140
|
-
if (!
|
|
138
|
+
function Qt(t, e, i, r, n) {
|
|
139
|
+
const s = t.createTexture();
|
|
140
|
+
if (!s)
|
|
141
141
|
throw new Error("Failed to create texture");
|
|
142
|
-
return t.bindTexture(t.TEXTURE_2D,
|
|
142
|
+
return t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
|
|
143
143
|
t.TEXTURE_2D,
|
|
144
144
|
0,
|
|
145
145
|
t.RGBA,
|
|
@@ -149,19 +149,19 @@ function Dt(t, e, i, r, n) {
|
|
|
149
149
|
t.RGBA,
|
|
150
150
|
t.UNSIGNED_BYTE,
|
|
151
151
|
i
|
|
152
|
-
), t.bindTexture(t.TEXTURE_2D, null),
|
|
152
|
+
), t.bindTexture(t.TEXTURE_2D, null), s;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function je(t, e, i) {
|
|
155
155
|
const r = t.getParameter(
|
|
156
156
|
t.TEXTURE_BINDING_2D
|
|
157
157
|
), n = t.getParameter(
|
|
158
158
|
t.FRAMEBUFFER_BINDING
|
|
159
|
-
),
|
|
160
|
-
if (!
|
|
161
|
-
return
|
|
162
|
-
let
|
|
159
|
+
), s = t.createTexture(), o = t.createFramebuffer();
|
|
160
|
+
if (!s || !o)
|
|
161
|
+
return s && t.deleteTexture(s), o && t.deleteFramebuffer(o), t.bindTexture(t.TEXTURE_2D, r), t.bindFramebuffer(t.FRAMEBUFFER, n), !1;
|
|
162
|
+
let a = !1;
|
|
163
163
|
try {
|
|
164
|
-
t.bindTexture(t.TEXTURE_2D,
|
|
164
|
+
t.bindTexture(t.TEXTURE_2D, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST), t.texImage2D(
|
|
165
165
|
t.TEXTURE_2D,
|
|
166
166
|
0,
|
|
167
167
|
e,
|
|
@@ -175,27 +175,27 @@ function Pe(t, e, i) {
|
|
|
175
175
|
t.FRAMEBUFFER,
|
|
176
176
|
t.COLOR_ATTACHMENT0,
|
|
177
177
|
t.TEXTURE_2D,
|
|
178
|
-
|
|
178
|
+
s,
|
|
179
179
|
0
|
|
180
|
-
),
|
|
180
|
+
), a = t.checkFramebufferStatus(t.FRAMEBUFFER) === t.FRAMEBUFFER_COMPLETE;
|
|
181
181
|
} finally {
|
|
182
|
-
t.bindFramebuffer(t.FRAMEBUFFER, n), t.bindTexture(t.TEXTURE_2D, r), t.deleteFramebuffer(o), t.deleteTexture(
|
|
182
|
+
t.bindFramebuffer(t.FRAMEBUFFER, n), t.bindTexture(t.TEXTURE_2D, r), t.deleteFramebuffer(o), t.deleteTexture(s);
|
|
183
183
|
}
|
|
184
|
-
return
|
|
184
|
+
return a;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function Ke(t) {
|
|
187
187
|
return {
|
|
188
188
|
kind: "rgba8-packed",
|
|
189
189
|
internalFormat: t.RGBA,
|
|
190
190
|
type: t.UNSIGNED_BYTE
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function Zt(t) {
|
|
194
194
|
if (typeof WebGL2RenderingContext > "u" || !(t instanceof WebGL2RenderingContext))
|
|
195
195
|
throw new Error("zartigl requires WebGL2");
|
|
196
196
|
return t;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function Jt(t) {
|
|
199
199
|
const e = [];
|
|
200
200
|
t.getExtension("EXT_color_buffer_float") ? e.push(
|
|
201
201
|
{ kind: "float32", internalFormat: t.RGBA32F, type: t.FLOAT },
|
|
@@ -206,34 +206,34 @@ function Pt(t) {
|
|
|
206
206
|
type: t.HALF_FLOAT
|
|
207
207
|
});
|
|
208
208
|
for (const i of e)
|
|
209
|
-
if (
|
|
209
|
+
if (je(
|
|
210
210
|
t,
|
|
211
211
|
i.internalFormat,
|
|
212
212
|
i.type
|
|
213
213
|
))
|
|
214
214
|
return i;
|
|
215
|
-
return
|
|
215
|
+
return Ke(t);
|
|
216
216
|
}
|
|
217
|
-
function
|
|
218
|
-
const
|
|
219
|
-
if (!
|
|
217
|
+
function ei(t, e, i, r, n, s, o) {
|
|
218
|
+
const a = t.createTexture();
|
|
219
|
+
if (!a)
|
|
220
220
|
throw new Error("Failed to create texture");
|
|
221
|
-
return t.bindTexture(t.TEXTURE_2D,
|
|
221
|
+
return t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texImage2D(
|
|
222
222
|
t.TEXTURE_2D,
|
|
223
223
|
0,
|
|
224
|
-
|
|
224
|
+
s,
|
|
225
225
|
r,
|
|
226
226
|
n,
|
|
227
227
|
0,
|
|
228
228
|
t.RGBA,
|
|
229
229
|
o,
|
|
230
230
|
i
|
|
231
|
-
), t.bindTexture(t.TEXTURE_2D, null),
|
|
231
|
+
), t.bindTexture(t.TEXTURE_2D, null), a;
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function ti(t, e, i) {
|
|
234
234
|
t.activeTexture(t.TEXTURE0 + i), t.bindTexture(t.TEXTURE_2D, e);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function ii(t, e) {
|
|
237
237
|
const i = t.createFramebuffer();
|
|
238
238
|
if (!i)
|
|
239
239
|
throw new Error("Failed to create framebuffer");
|
|
@@ -245,7 +245,7 @@ function Nt(t, e) {
|
|
|
245
245
|
0
|
|
246
246
|
), t.bindFramebuffer(t.FRAMEBUFFER, null), i;
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function ri(t) {
|
|
249
249
|
const e = t.createBuffer();
|
|
250
250
|
if (!e)
|
|
251
251
|
throw new Error("Failed to create buffer");
|
|
@@ -255,7 +255,7 @@ function It(t) {
|
|
|
255
255
|
t.STATIC_DRAW
|
|
256
256
|
), e;
|
|
257
257
|
}
|
|
258
|
-
const
|
|
258
|
+
const Qe = {
|
|
259
259
|
0: "#3288bd",
|
|
260
260
|
0.1: "#66c2a5",
|
|
261
261
|
0.2: "#abdda4",
|
|
@@ -265,19 +265,19 @@ const Ge = {
|
|
|
265
265
|
0.6: "#f46d43",
|
|
266
266
|
1: "#d53e4f"
|
|
267
267
|
};
|
|
268
|
-
function
|
|
269
|
-
const r =
|
|
268
|
+
function ni(t, e, i) {
|
|
269
|
+
const r = ze(e ?? Qe, i), n = document.createElement("canvas");
|
|
270
270
|
n.width = 256, n.height = 1;
|
|
271
|
-
const
|
|
272
|
-
for (const [
|
|
273
|
-
o.addColorStop(Number(
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
if (!
|
|
271
|
+
const s = n.getContext("2d"), o = s.createLinearGradient(0, 0, 256, 0);
|
|
272
|
+
for (const [d, c] of Object.entries(r))
|
|
273
|
+
o.addColorStop(Number(d), c);
|
|
274
|
+
s.fillStyle = o, s.fillRect(0, 0, 256, 1);
|
|
275
|
+
const a = t.createTexture();
|
|
276
|
+
if (!a)
|
|
277
277
|
throw new Error("Failed to create color ramp texture");
|
|
278
|
-
return t.bindTexture(t.TEXTURE_2D,
|
|
278
|
+
return t.bindTexture(t.TEXTURE_2D, a), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, n), t.bindTexture(t.TEXTURE_2D, null), a;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function si(t) {
|
|
281
281
|
const e = t.getExtension("WEBGL_debug_renderer_info");
|
|
282
282
|
return {
|
|
283
283
|
vendor: String(t.getParameter(t.VENDOR) ?? ""),
|
|
@@ -287,7 +287,7 @@ function Ct(t) {
|
|
|
287
287
|
version: String(t.getParameter(t.VERSION) ?? "")
|
|
288
288
|
};
|
|
289
289
|
}
|
|
290
|
-
function
|
|
290
|
+
function ai(t) {
|
|
291
291
|
return {
|
|
292
292
|
program: t.getParameter(t.CURRENT_PROGRAM),
|
|
293
293
|
activeTexture: t.getParameter(t.ACTIVE_TEXTURE),
|
|
@@ -304,10 +304,10 @@ function Vt(t) {
|
|
|
304
304
|
]
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function oi(t, e) {
|
|
308
308
|
t.useProgram(e.program), t.activeTexture(e.activeTexture), t.bindBuffer(t.ARRAY_BUFFER, e.arrayBuffer), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, e.elementBuffer), t.bindFramebuffer(t.FRAMEBUFFER, e.framebuffer), e.blend ? t.enable(t.BLEND) : t.disable(t.BLEND), e.depthTest ? t.enable(t.DEPTH_TEST) : t.disable(t.DEPTH_TEST), e.stencilTest ? t.enable(t.STENCIL_TEST) : t.disable(t.STENCIL_TEST), t.viewport(e.viewport[0], e.viewport[1], e.viewport[2], e.viewport[3]), t.blendFunc(e.blendFunc[0], e.blendFunc[1]);
|
|
309
309
|
}
|
|
310
|
-
const
|
|
310
|
+
const Ze = {
|
|
311
311
|
degrees_c: "°C",
|
|
312
312
|
degc: "°C",
|
|
313
313
|
degrees_celsius: "°C",
|
|
@@ -323,7 +323,7 @@ const Ne = {
|
|
|
323
323
|
"0.001": "PSU",
|
|
324
324
|
psu: "PSU",
|
|
325
325
|
stress_level: ""
|
|
326
|
-
},
|
|
326
|
+
}, Je = {
|
|
327
327
|
meter: "m",
|
|
328
328
|
meters: "m",
|
|
329
329
|
metre: "m",
|
|
@@ -346,36 +346,36 @@ const Ne = {
|
|
|
346
346
|
newton: "N",
|
|
347
347
|
pascal: "Pa",
|
|
348
348
|
kelvin: "K"
|
|
349
|
-
},
|
|
350
|
-
function
|
|
351
|
-
return t === 1 ? "" : [...String(t)].map((e) =>
|
|
349
|
+
}, et = "⁰¹²³⁴⁵⁶⁷⁸⁹";
|
|
350
|
+
function se(t) {
|
|
351
|
+
return t === 1 ? "" : [...String(t)].map((e) => et[Number(e)]).join("");
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
const e = t?.trim() ?? "", i =
|
|
353
|
+
function ci(t) {
|
|
354
|
+
const e = t?.trim() ?? "", i = Ze[e.toLowerCase()];
|
|
355
355
|
if (i != null)
|
|
356
356
|
return i;
|
|
357
357
|
if (e.includes("/"))
|
|
358
358
|
return e;
|
|
359
359
|
const r = [], n = [];
|
|
360
|
-
for (const
|
|
361
|
-
const o = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(
|
|
360
|
+
for (const s of e.split(/\s+/)) {
|
|
361
|
+
const o = /^([A-Za-z]+)\^?(-?\d+)?$/.exec(s);
|
|
362
362
|
if (!o)
|
|
363
363
|
return e.replace(/_/g, " ");
|
|
364
|
-
const
|
|
365
|
-
|
|
364
|
+
const a = Je[o[1]] ?? o[1], d = Number(o[2] ?? 1);
|
|
365
|
+
d < 0 ? n.push(a + se(-d)) : r.push(a + se(d));
|
|
366
366
|
}
|
|
367
367
|
return [r.join(" ") || "1", ...n].join("/");
|
|
368
368
|
}
|
|
369
|
-
const
|
|
370
|
-
function
|
|
369
|
+
const ae = 20, tt = 600;
|
|
370
|
+
function it(t) {
|
|
371
371
|
const e = Math.max(0, Math.min(1, t));
|
|
372
|
-
return
|
|
372
|
+
return ae * Math.pow(tt / ae, e);
|
|
373
373
|
}
|
|
374
|
-
function
|
|
375
|
-
return Math.exp(-1 /
|
|
374
|
+
function di(t) {
|
|
375
|
+
return Math.exp(-1 / it(t));
|
|
376
376
|
}
|
|
377
|
-
const
|
|
378
|
-
class
|
|
377
|
+
const rt = 0.8, nt = 120, st = 300;
|
|
378
|
+
class li {
|
|
379
379
|
constructor(e) {
|
|
380
380
|
this.base = e, this.moving = !1, this.start = 0, this.duration = 0, this.from = e, this.to = e;
|
|
381
381
|
}
|
|
@@ -384,7 +384,7 @@ class qt {
|
|
|
384
384
|
this.base = e, this.moving || (this.from = e, this.to = e, this.duration = 0);
|
|
385
385
|
}
|
|
386
386
|
setMoving(e, i) {
|
|
387
|
-
e !== this.moving && (this.from = this.value(i), this.moving = e, this.to = e ?
|
|
387
|
+
e !== this.moving && (this.from = this.value(i), this.moving = e, this.to = e ? rt : this.base, this.start = i, this.duration = e ? nt : st);
|
|
388
388
|
}
|
|
389
389
|
value(e) {
|
|
390
390
|
if (this.duration === 0)
|
|
@@ -393,7 +393,7 @@ class qt {
|
|
|
393
393
|
return i === 1 ? (this.duration = 0, this.from = this.to, this.to) : this.from + (this.to - this.from) * i * i * (3 - 2 * i);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
|
-
var
|
|
396
|
+
var at = `vec3 velocityValue(vec4 texel, vec2 minimum, vec2 maximum, float physical) {
|
|
397
397
|
if (physical > 0.5) return texel.xyz;
|
|
398
398
|
return vec3(mix(minimum, maximum, texel.rg), texel.a);
|
|
399
399
|
}
|
|
@@ -401,7 +401,7 @@ var qe = `vec3 velocityValue(vec4 texel, vec2 minimum, vec2 maximum, float physi
|
|
|
401
401
|
vec3 blendVelocity(vec3 a, vec3 b, float fraction) {
|
|
402
402
|
if (fraction <= 0.0) return a;
|
|
403
403
|
return mix(a, b, fraction);
|
|
404
|
-
}`,
|
|
404
|
+
}`, ot = `vec3 applyVibrance(vec3 c, float v) {
|
|
405
405
|
float mx = max(c.r, max(c.g, c.b));
|
|
406
406
|
float mn = min(c.r, min(c.g, c.b));
|
|
407
407
|
float boost = v * (1.0 - (mx - mn));
|
|
@@ -422,7 +422,7 @@ vec3 gradeColor(vec3 c, vec4 g) {
|
|
|
422
422
|
|
|
423
423
|
c = mix(c, c * c * (3.0 - 2.0 * c), g.y);
|
|
424
424
|
return clamp(applyVibrance(c, g.z), 0.0, 1.0);
|
|
425
|
-
}`,
|
|
425
|
+
}`, ct = `uniform vec2 u_code_range;
|
|
426
426
|
uniform vec2 u_value_range;
|
|
427
427
|
uniform float u_scalar_transfer;
|
|
428
428
|
|
|
@@ -434,7 +434,7 @@ float geoVideoScalarValue(float r) {
|
|
|
434
434
|
float code = geoVideoScalarCode(r);
|
|
435
435
|
float t = mix(code, (pow(10.0, code) - 1.0) / 9.0, u_scalar_transfer);
|
|
436
436
|
return mix(u_value_range.x, u_value_range.y, t);
|
|
437
|
-
}`,
|
|
437
|
+
}`, dt = `uint pcg(uint v) {
|
|
438
438
|
uint state = v * 747796405u + 2891336453u;
|
|
439
439
|
uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
|
|
440
440
|
return (word >> 22u) ^ word;
|
|
@@ -442,13 +442,13 @@ float geoVideoScalarValue(float r) {
|
|
|
442
442
|
|
|
443
443
|
float random(uvec3 v) {
|
|
444
444
|
return float(pcg(v.x ^ pcg(v.y ^ pcg(v.z))) >> 8u) * (1.0 / 16777216.0);
|
|
445
|
-
}`,
|
|
445
|
+
}`, lt = `vec3 applyVibrance(vec3 c, float v) {
|
|
446
446
|
float mx = max(c.r, max(c.g, c.b));
|
|
447
447
|
float mn = min(c.r, min(c.g, c.b));
|
|
448
448
|
float boost = v * (1.0 - (mx - mn));
|
|
449
449
|
float luma = dot(c, vec3(0.299, 0.587, 0.114));
|
|
450
450
|
return mix(vec3(luma), c, 1.0 + boost);
|
|
451
|
-
}`,
|
|
451
|
+
}`, ht = `#define GLOW_SCALE 4
|
|
452
452
|
|
|
453
453
|
vec4 glowGather(sampler2D trails, ivec2 texel) {
|
|
454
454
|
ivec2 last = textureSize(trails, 0) - 1;
|
|
@@ -476,8 +476,8 @@ vec4 addGlow(vec4 trail, sampler2D glowTex, vec2 uv, float gain) {
|
|
|
476
476
|
vec3 rgb = (trail.rgb * trail.a + glow.rgb * under) / max(alpha, 1e-4);
|
|
477
477
|
return vec4(rgb, alpha);
|
|
478
478
|
}`;
|
|
479
|
-
const
|
|
480
|
-
function
|
|
479
|
+
const hi = lt, ui = ot, fi = dt, mi = ct, pi = at, Ei = ht, gi = 4, Ti = 1.2;
|
|
480
|
+
function bi(t) {
|
|
481
481
|
if (t == null)
|
|
482
482
|
return null;
|
|
483
483
|
if (!Number.isFinite(t[0]) || !Number.isFinite(t[1]) || t[0] >= t[1])
|
|
@@ -486,12 +486,12 @@ function Jt(t) {
|
|
|
486
486
|
);
|
|
487
487
|
return [t[0], t[1]];
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function x(t, e) {
|
|
490
490
|
if (typeof t != "number" || !Number.isFinite(t))
|
|
491
491
|
throw new Error(`Invalid GeoVideo manifest ${e}`);
|
|
492
492
|
return t;
|
|
493
493
|
}
|
|
494
|
-
function
|
|
494
|
+
function B(t, e) {
|
|
495
495
|
if (typeof t != "string")
|
|
496
496
|
throw new Error(`Invalid GeoVideo manifest ${e}`);
|
|
497
497
|
const i = new Date(t).getTime();
|
|
@@ -499,12 +499,12 @@ function v(t, e) {
|
|
|
499
499
|
throw new Error(`Invalid GeoVideo manifest ${e}`);
|
|
500
500
|
return i;
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function Y(t) {
|
|
503
503
|
return typeof t == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(
|
|
504
504
|
t
|
|
505
505
|
);
|
|
506
506
|
}
|
|
507
|
-
function
|
|
507
|
+
function oe(t) {
|
|
508
508
|
if (!t || typeof t != "object")
|
|
509
509
|
throw new Error("Invalid GeoVideo manifest");
|
|
510
510
|
const e = t;
|
|
@@ -516,79 +516,79 @@ function $(t) {
|
|
|
516
516
|
);
|
|
517
517
|
if (!Array.isArray(e.bounds) || e.bounds.length !== 4)
|
|
518
518
|
throw new Error("Invalid GeoVideo manifest bounds");
|
|
519
|
-
const [i, r, n,
|
|
520
|
-
(
|
|
519
|
+
const [i, r, n, s] = e.bounds.map(
|
|
520
|
+
(m, E) => x(m, `bounds[${E}]`)
|
|
521
521
|
);
|
|
522
|
-
if (r < -90 ||
|
|
522
|
+
if (r < -90 || s > 90 || r >= s || i === n)
|
|
523
523
|
throw new Error("Invalid GeoVideo geographic bounds");
|
|
524
524
|
const o = e.media;
|
|
525
525
|
if (!o || typeof o.url != "string" || !o.url)
|
|
526
526
|
throw new Error("Invalid GeoVideo media");
|
|
527
|
-
for (const
|
|
528
|
-
if (
|
|
529
|
-
throw new Error(`Invalid GeoVideo media.${
|
|
530
|
-
const
|
|
531
|
-
if (!
|
|
527
|
+
for (const m of ["width", "height", "fps", "durationSeconds"])
|
|
528
|
+
if (x(o[m], `media.${m}`) <= 0)
|
|
529
|
+
throw new Error(`Invalid GeoVideo media.${m}`);
|
|
530
|
+
const a = e.encoding;
|
|
531
|
+
if (!a || a.bits !== 8 || a.colorSpace !== "bt709" || a.colorRange !== "limited" && a.colorRange !== "full")
|
|
532
532
|
throw new Error("Invalid GeoVideo encoding");
|
|
533
|
-
const
|
|
534
|
-
if (
|
|
533
|
+
const d = x(a.codeMin, "encoding.codeMin"), c = x(a.codeMax, "encoding.codeMax");
|
|
534
|
+
if (d < 0 || c > 255 || d >= c)
|
|
535
535
|
throw new Error("Invalid GeoVideo code range");
|
|
536
|
-
let
|
|
537
|
-
if (
|
|
538
|
-
if (
|
|
536
|
+
let l = o.height;
|
|
537
|
+
if (a.kind === "scalar-luma") {
|
|
538
|
+
if (a.transfer !== "linear" && a.transfer !== "log10-1p9" || x(a.valueMin, "encoding.valueMin") >= x(a.valueMax, "encoding.valueMax"))
|
|
539
539
|
throw new Error("Invalid GeoVideo scalar-luma encoding");
|
|
540
|
-
} else if (
|
|
541
|
-
if (
|
|
540
|
+
} else if (a.kind === "vector-luma") {
|
|
541
|
+
if (a.transfer !== "linear" && a.transfer !== "sqrt" || a.layout !== "stacked-uv" || x(a.valueDomain, "encoding.valueDomain") <= 0 || o.height % 2 !== 0)
|
|
542
542
|
throw new Error("Invalid GeoVideo vector-luma encoding");
|
|
543
|
-
|
|
543
|
+
l = o.height / 2;
|
|
544
544
|
} else
|
|
545
545
|
throw new Error("Unsupported GeoVideo encoding");
|
|
546
546
|
const h = e.mask;
|
|
547
|
-
if (!h || h.kind !== "static-validity" || typeof h.url != "string" || !h.url ||
|
|
547
|
+
if (!h || h.kind !== "static-validity" || typeof h.url != "string" || !h.url || x(h.width, "mask.width") !== o.width || x(h.height, "mask.height") !== l || x(h.threshold, "mask.threshold") < 0 || h.threshold > 1)
|
|
548
548
|
throw new Error("Invalid GeoVideo static mask");
|
|
549
549
|
if (e.timeline?.kind === "range") {
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
550
|
+
const m = B(e.timeline.dateStart, "timeline.dateStart");
|
|
551
|
+
if (B(e.timeline.dateEnd, "timeline.dateEnd") <= m)
|
|
552
552
|
throw new Error("GeoVideo timeline end must follow start");
|
|
553
553
|
if (e.timeline.interpolation !== "linear" && e.timeline.interpolation !== "nearest")
|
|
554
554
|
throw new Error("Invalid GeoVideo interpolation");
|
|
555
555
|
} else if (e.timeline?.kind === "snapshot-loop")
|
|
556
|
-
|
|
556
|
+
B(e.timeline.date, "timeline.date");
|
|
557
557
|
else if (e.timeline?.kind === "sample-sequence") {
|
|
558
558
|
if (!Array.isArray(e.timeline.values) || e.timeline.values.length === 0)
|
|
559
559
|
throw new Error("GeoVideo sample sequence must contain values");
|
|
560
|
-
const
|
|
561
|
-
(
|
|
560
|
+
const m = e.timeline.values.map(
|
|
561
|
+
(E, w) => B(E, `timeline.values[${w}]`)
|
|
562
562
|
);
|
|
563
|
-
if (
|
|
563
|
+
if (m.some((E, w) => w > 0 && E <= m[w - 1]))
|
|
564
564
|
throw new Error(
|
|
565
565
|
"GeoVideo sample sequence values must be strictly increasing"
|
|
566
566
|
);
|
|
567
567
|
} else
|
|
568
568
|
throw new Error("Invalid GeoVideo timeline");
|
|
569
|
-
const
|
|
570
|
-
if (!Array.isArray(
|
|
569
|
+
const p = e.style?.colorDomain;
|
|
570
|
+
if (!Array.isArray(p) || p.length !== 2 || !p.every(Number.isFinite) || p[0] >= p[1])
|
|
571
571
|
throw new Error("Invalid GeoVideo color domain");
|
|
572
|
-
if (!
|
|
572
|
+
if (!Y(e.id) || !e.provenance || !Y(e.provenance.catalogEntryId) || !Y(e.provenance.inputSourceId) || !Array.isArray(e.provenance.variables) || e.provenance.variables.length === 0)
|
|
573
573
|
throw new Error("Invalid GeoVideo provenance");
|
|
574
|
-
return { ...e, bounds: [i, r, n,
|
|
574
|
+
return { ...e, bounds: [i, r, n, s] };
|
|
575
575
|
}
|
|
576
|
-
async function
|
|
576
|
+
async function ut(t, e) {
|
|
577
577
|
if (typeof t != "string")
|
|
578
|
-
return
|
|
578
|
+
return oe(t);
|
|
579
579
|
const i = await fetch(t, { signal: e });
|
|
580
580
|
if (!i.ok)
|
|
581
581
|
throw new Error(
|
|
582
582
|
`GeoVideo manifest request failed (${i.status}): ${t}`
|
|
583
583
|
);
|
|
584
|
-
const r = await i.json(), n =
|
|
584
|
+
const r = await i.json(), n = oe(r), s = typeof document < "u" ? new URL(t, document.baseURI).href : t;
|
|
585
585
|
return {
|
|
586
586
|
...n,
|
|
587
|
-
media: { ...n.media, url: new URL(n.media.url,
|
|
588
|
-
mask: { ...n.mask, url: new URL(n.mask.url,
|
|
587
|
+
media: { ...n.media, url: new URL(n.media.url, s).href },
|
|
588
|
+
mask: { ...n.mask, url: new URL(n.mask.url, s).href }
|
|
589
589
|
};
|
|
590
590
|
}
|
|
591
|
-
function
|
|
591
|
+
function M(t) {
|
|
592
592
|
if (t.timeline.kind === "snapshot-loop")
|
|
593
593
|
return [new Date(t.timeline.date).getTime()];
|
|
594
594
|
if (t.timeline.kind === "sample-sequence")
|
|
@@ -599,43 +599,43 @@ function _(t) {
|
|
|
599
599
|
);
|
|
600
600
|
return Array.from(
|
|
601
601
|
{ length: r },
|
|
602
|
-
(n,
|
|
602
|
+
(n, s) => e + (i - e) * s / (r - 1)
|
|
603
603
|
);
|
|
604
604
|
}
|
|
605
|
-
function
|
|
605
|
+
function ue(t) {
|
|
606
606
|
return t.timeline.kind === "sample-sequence" ? t.timeline.values.length / t.media.durationSeconds : t.media.fps;
|
|
607
607
|
}
|
|
608
|
-
function
|
|
609
|
-
return e /
|
|
608
|
+
function wi(t, e) {
|
|
609
|
+
return e / ue(t);
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function ft(t, e) {
|
|
612
612
|
if (t.timeline.kind === "snapshot-loop")
|
|
613
613
|
return 0;
|
|
614
614
|
if (t.timeline.kind === "sample-sequence") {
|
|
615
|
-
const
|
|
615
|
+
const s = M(t);
|
|
616
616
|
let o = 0;
|
|
617
|
-
for (let
|
|
618
|
-
Math.abs(
|
|
619
|
-
const
|
|
620
|
-
return o *
|
|
617
|
+
for (let d = 1; d < s.length; d += 1)
|
|
618
|
+
Math.abs(s[d] - e) < Math.abs(s[o] - e) && (o = d);
|
|
619
|
+
const a = t.media.durationSeconds / s.length;
|
|
620
|
+
return o * a + Math.min(a / 2, 0.5 / t.media.fps);
|
|
621
621
|
}
|
|
622
622
|
const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime();
|
|
623
|
-
return Math.max(0, Math.min(1, (e - i) / (r - i))) *
|
|
623
|
+
return Math.max(0, Math.min(1, (e - i) / (r - i))) * fe(t);
|
|
624
624
|
}
|
|
625
|
-
function
|
|
625
|
+
function yi(t, e) {
|
|
626
626
|
if (t.timeline.kind === "snapshot-loop")
|
|
627
627
|
return new Date(t.timeline.date).getTime();
|
|
628
628
|
if (t.timeline.kind === "sample-sequence") {
|
|
629
|
-
const o =
|
|
630
|
-
return o[Math.max(0, Math.min(o.length - 1,
|
|
629
|
+
const o = M(t), a = t.media.durationSeconds / o.length, d = Math.floor((e + 0.25 / t.media.fps) / a);
|
|
630
|
+
return o[Math.max(0, Math.min(o.length - 1, d))];
|
|
631
631
|
}
|
|
632
|
-
const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime(), n =
|
|
633
|
-
return i + (r - i) *
|
|
632
|
+
const i = new Date(t.timeline.dateStart).getTime(), r = new Date(t.timeline.dateEnd).getTime(), n = fe(t), s = n > 0 ? Math.max(0, Math.min(1, e / n)) : 0;
|
|
633
|
+
return i + (r - i) * s;
|
|
634
634
|
}
|
|
635
|
-
function
|
|
635
|
+
function fe(t) {
|
|
636
636
|
return Math.max(0, t.media.durationSeconds - 1 / t.media.fps);
|
|
637
637
|
}
|
|
638
|
-
function
|
|
638
|
+
function mt(t, e) {
|
|
639
639
|
const i = new Uint8Array(t.length / 4);
|
|
640
640
|
for (let r = 0; r < i.length; r++) {
|
|
641
641
|
const n = t[r * 4];
|
|
@@ -643,7 +643,7 @@ function Ze(t, e) {
|
|
|
643
643
|
}
|
|
644
644
|
return i;
|
|
645
645
|
}
|
|
646
|
-
class
|
|
646
|
+
class pt {
|
|
647
647
|
constructor() {
|
|
648
648
|
this.gl = null, this.texture = null, this.framebuffer = null;
|
|
649
649
|
}
|
|
@@ -656,8 +656,8 @@ class Je {
|
|
|
656
656
|
this.texture,
|
|
657
657
|
0
|
|
658
658
|
);
|
|
659
|
-
const
|
|
660
|
-
return n.readPixels(0, 0, i, r, n.RGBA, n.UNSIGNED_BYTE,
|
|
659
|
+
const s = new Uint8Array(i * r * 4);
|
|
660
|
+
return n.readPixels(0, 0, i, r, n.RGBA, n.UNSIGNED_BYTE, s), n.bindFramebuffer(n.FRAMEBUFFER, null), s;
|
|
661
661
|
}
|
|
662
662
|
release() {
|
|
663
663
|
this.gl?.getExtension("WEBGL_lose_context")?.loseContext(), this.gl = null, this.texture = null, this.framebuffer = null;
|
|
@@ -674,44 +674,44 @@ class Je {
|
|
|
674
674
|
return this.gl = r, this.texture = r.createTexture(), this.framebuffer = r.createFramebuffer(), r;
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
|
-
function
|
|
677
|
+
function ce(t) {
|
|
678
678
|
const e = Math.max(4, Math.floor(t.length / 4 / 997) * 4);
|
|
679
679
|
for (let i = 3; i < t.length; i += e)
|
|
680
680
|
if (t[i] !== 0)
|
|
681
681
|
return !1;
|
|
682
682
|
return !0;
|
|
683
683
|
}
|
|
684
|
-
function
|
|
684
|
+
function g() {
|
|
685
685
|
return new DOMException("GeoVideo frame request was cancelled", "AbortError");
|
|
686
686
|
}
|
|
687
|
-
function
|
|
687
|
+
function G(t, e, i) {
|
|
688
688
|
return e ? e.aborted ? (t.catch(() => {
|
|
689
|
-
}), i?.(), Promise.reject(
|
|
690
|
-
const
|
|
691
|
-
i?.(), n(
|
|
689
|
+
}), i?.(), Promise.reject(g())) : new Promise((r, n) => {
|
|
690
|
+
const s = () => {
|
|
691
|
+
i?.(), n(g());
|
|
692
692
|
};
|
|
693
|
-
e.addEventListener("abort",
|
|
694
|
-
e.removeEventListener("abort",
|
|
693
|
+
e.addEventListener("abort", s, { once: !0 }), t.then(r, n).finally(() => {
|
|
694
|
+
e.removeEventListener("abort", s);
|
|
695
695
|
});
|
|
696
696
|
}) : t;
|
|
697
697
|
}
|
|
698
|
-
function
|
|
698
|
+
function j(t, e) {
|
|
699
699
|
return new Promise(
|
|
700
700
|
(i) => t.addEventListener(e, () => i(), { once: !0 })
|
|
701
701
|
);
|
|
702
702
|
}
|
|
703
|
-
const
|
|
704
|
-
function
|
|
703
|
+
const Et = 250;
|
|
704
|
+
function gt(t) {
|
|
705
705
|
return "requestVideoFrameCallback" in t ? Promise.race([
|
|
706
706
|
new Promise(
|
|
707
707
|
(e) => t.requestVideoFrameCallback(() => e())
|
|
708
708
|
),
|
|
709
|
-
new Promise((e) => setTimeout(e,
|
|
709
|
+
new Promise((e) => setTimeout(e, Et))
|
|
710
710
|
]) : Promise.resolve();
|
|
711
711
|
}
|
|
712
|
-
class
|
|
712
|
+
class me {
|
|
713
713
|
constructor(e, i, r = {}) {
|
|
714
|
-
this.reader = new
|
|
714
|
+
this.reader = new pt(), this.video = null, this.maskCodes = null, this.initPromise = null, this.presented = !1, this.primed = !1, this.queue = Promise.resolve(), this.frames = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Set(), this.manifest = e, this.planes = i, this.cacheSize = Math.max(1, r.cacheSize ?? 3), this.width = e.media.width, this.height = e.media.height / i, this.times = Float64Array.from(M(e));
|
|
715
715
|
}
|
|
716
716
|
/** Static validity, one 8-bit value per grid cell; null before init(). */
|
|
717
717
|
get mask() {
|
|
@@ -720,11 +720,11 @@ class J {
|
|
|
720
720
|
/** Luma codes of the presented frame, or null when it is blank. */
|
|
721
721
|
readCodes(e, i) {
|
|
722
722
|
const r = this.reader.read(e, this.width, i);
|
|
723
|
-
return
|
|
723
|
+
return ce(r) ? null : mt(r, this.manifest.encoding.colorRange);
|
|
724
724
|
}
|
|
725
725
|
/** True when the decoder exposed no pixels; reads back one row only. */
|
|
726
726
|
isBlank(e) {
|
|
727
|
-
return
|
|
727
|
+
return ce(this.reader.read(e, this.width, 1));
|
|
728
728
|
}
|
|
729
729
|
init() {
|
|
730
730
|
return this.initPromise ??= this.load().catch((e) => {
|
|
@@ -748,23 +748,23 @@ class J {
|
|
|
748
748
|
frame(e, i = {}) {
|
|
749
749
|
const { signal: r } = i;
|
|
750
750
|
if (r?.aborted)
|
|
751
|
-
return Promise.reject(
|
|
751
|
+
return Promise.reject(g());
|
|
752
752
|
let n = this.frames.get(e);
|
|
753
753
|
if (n ? (this.frames.delete(e), this.frames.set(e, n)) : n = this.enqueue(e), n.settled)
|
|
754
754
|
return n.promise;
|
|
755
|
-
const
|
|
756
|
-
return
|
|
755
|
+
const s = n;
|
|
756
|
+
return s.waiters++, G(s.promise, r, () => this.leave(s));
|
|
757
757
|
}
|
|
758
758
|
enqueue(e) {
|
|
759
759
|
const i = new AbortController(), r = this.queue.then(
|
|
760
|
-
() => i.signal.aborted ? Promise.reject(
|
|
760
|
+
() => i.signal.aborted ? Promise.reject(g()) : this.decode(e, i.signal)
|
|
761
761
|
);
|
|
762
762
|
this.queue = r.catch(() => {
|
|
763
763
|
});
|
|
764
764
|
const n = {
|
|
765
765
|
index: e,
|
|
766
766
|
controller: i,
|
|
767
|
-
promise:
|
|
767
|
+
promise: G(r, i.signal),
|
|
768
768
|
waiters: 0,
|
|
769
769
|
settled: !1
|
|
770
770
|
};
|
|
@@ -787,7 +787,7 @@ class J {
|
|
|
787
787
|
e.controller.abort(), this.pending.delete(e), this.frames.get(e.index) === e && this.frames.delete(e.index);
|
|
788
788
|
}
|
|
789
789
|
async load() {
|
|
790
|
-
const [e] = await Promise.all([this.loadMask(), this.
|
|
790
|
+
const [e] = await Promise.all([this.loadMask(), this.loadMedia()]);
|
|
791
791
|
this.maskCodes = e;
|
|
792
792
|
}
|
|
793
793
|
async loadMask() {
|
|
@@ -802,12 +802,13 @@ class J {
|
|
|
802
802
|
throw new Error(
|
|
803
803
|
`GeoVideo mask dimensions ${n.naturalWidth}x${n.naturalHeight} do not match manifest ${i}x${r}`
|
|
804
804
|
);
|
|
805
|
-
const
|
|
806
|
-
for (let
|
|
807
|
-
o[
|
|
805
|
+
const s = this.reader.read(n, i, r), o = new Uint8Array(i * r);
|
|
806
|
+
for (let a = 0; a < o.length; a++)
|
|
807
|
+
o[a] = s[a * 4];
|
|
808
808
|
return o;
|
|
809
809
|
}
|
|
810
|
-
|
|
810
|
+
/** Open the media; the default reads frames by seeking a video element. */
|
|
811
|
+
async loadMedia() {
|
|
811
812
|
const e = document.createElement("video");
|
|
812
813
|
if (e.crossOrigin = "anonymous", e.muted = !0, e.playsInline = !0, e.preload = "metadata", e.src = this.manifest.media.url, this.video = e, await new Promise((i, r) => {
|
|
813
814
|
e.addEventListener("loadedmetadata", () => i(), {
|
|
@@ -830,8 +831,8 @@ class J {
|
|
|
830
831
|
async presentFrame(e, i) {
|
|
831
832
|
if (this.presented && Math.abs(e.currentTime - i) <= 1e-3 && !e.seeking)
|
|
832
833
|
return;
|
|
833
|
-
const r =
|
|
834
|
-
e.currentTime = i, await n, e.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([
|
|
834
|
+
const r = gt(e), n = j(e, "seeked");
|
|
835
|
+
e.currentTime = i, await n, e.readyState < HTMLMediaElement.HAVE_CURRENT_DATA && await Promise.race([j(e, "loadeddata"), j(e, "canplay")]), await r, this.presented = !0;
|
|
835
836
|
}
|
|
836
837
|
/**
|
|
837
838
|
* Some mobile browsers expose no decoded pixels to WebGL until playback
|
|
@@ -846,40 +847,44 @@ class J {
|
|
|
846
847
|
}
|
|
847
848
|
e.pause(), this.presented = !1;
|
|
848
849
|
}
|
|
850
|
+
/** Media time inside the video frame showing step `index`. */
|
|
851
|
+
stepSeconds(e) {
|
|
852
|
+
return this.manifest.timeline.kind === "snapshot-loop" ? e / this.manifest.media.fps : ft(this.manifest, this.times[e]);
|
|
853
|
+
}
|
|
849
854
|
/**
|
|
850
855
|
* Seek and capture one step. `signal` aborts it between steps; a seek
|
|
851
856
|
* already started completes first, keeping the queue serial.
|
|
852
857
|
*/
|
|
853
858
|
async decode(e, i) {
|
|
854
859
|
if (i.aborted)
|
|
855
|
-
throw
|
|
860
|
+
throw g();
|
|
856
861
|
await this.init();
|
|
857
862
|
const r = this.video, n = this.maskCodes;
|
|
858
863
|
if (i.aborted || !r || !n)
|
|
859
|
-
throw
|
|
860
|
-
const
|
|
861
|
-
if (await this.presentFrame(r,
|
|
862
|
-
throw
|
|
864
|
+
throw g();
|
|
865
|
+
const s = this.stepSeconds(e);
|
|
866
|
+
if (await this.presentFrame(r, s), i.aborted || r !== this.video)
|
|
867
|
+
throw g();
|
|
863
868
|
const o = this.height * this.planes;
|
|
864
|
-
let
|
|
865
|
-
if (
|
|
866
|
-
if (await this.primeDecoder(r), await this.presentFrame(r,
|
|
867
|
-
throw
|
|
868
|
-
|
|
869
|
+
let a = await this.capture(r, o, n);
|
|
870
|
+
if (a === null && !this.primed) {
|
|
871
|
+
if (await this.primeDecoder(r), await this.presentFrame(r, s), i.aborted || r !== this.video)
|
|
872
|
+
throw g();
|
|
873
|
+
a = await this.capture(r, o, n);
|
|
869
874
|
}
|
|
870
|
-
if (
|
|
875
|
+
if (a === null)
|
|
871
876
|
throw new Error("GeoVideo frame could not be read back from the decoder");
|
|
872
|
-
return
|
|
877
|
+
return a;
|
|
873
878
|
}
|
|
874
879
|
}
|
|
875
|
-
function
|
|
880
|
+
function Tt(t) {
|
|
876
881
|
return {
|
|
877
882
|
codeRange: [t.codeMin / 255, t.codeMax / 255],
|
|
878
883
|
valueRange: [t.valueMin, t.valueMax],
|
|
879
884
|
transfer: t.transfer === "log10-1p9" ? 1 : 0
|
|
880
885
|
};
|
|
881
886
|
}
|
|
882
|
-
class
|
|
887
|
+
class bt extends me {
|
|
883
888
|
constructor(e, i = {}) {
|
|
884
889
|
if (e.encoding.kind !== "scalar-luma")
|
|
885
890
|
throw new Error("GeoVideoScalarSource requires a scalar-luma manifest");
|
|
@@ -892,7 +897,7 @@ class it extends J {
|
|
|
892
897
|
});
|
|
893
898
|
}
|
|
894
899
|
}
|
|
895
|
-
function
|
|
900
|
+
function v(t, e) {
|
|
896
901
|
if (e <= t[0])
|
|
897
902
|
return { index: 0, fraction: 0 };
|
|
898
903
|
const i = t.length - 1;
|
|
@@ -900,55 +905,310 @@ function b(t, e) {
|
|
|
900
905
|
return { index: i, fraction: 0 };
|
|
901
906
|
let r = 0, n = i;
|
|
902
907
|
for (; n - r > 1; ) {
|
|
903
|
-
const
|
|
904
|
-
t[
|
|
908
|
+
const s = r + n >> 1;
|
|
909
|
+
t[s] <= e ? r = s : n = s;
|
|
905
910
|
}
|
|
906
911
|
return { index: r, fraction: (e - t[r]) / (t[n] - t[r]) };
|
|
907
912
|
}
|
|
908
|
-
function
|
|
909
|
-
const { index: i, fraction: r } =
|
|
913
|
+
function K(t, e) {
|
|
914
|
+
const { index: i, fraction: r } = v(t, e);
|
|
910
915
|
return i + r;
|
|
911
916
|
}
|
|
912
|
-
function
|
|
917
|
+
function wt(t, e) {
|
|
913
918
|
const i = Math.max(0, Math.min(t.length - 1, Math.floor(e))), r = Math.min(i + 1, t.length - 1);
|
|
914
919
|
return t[i] + (t[r] - t[i]) * Math.max(0, e - i);
|
|
915
920
|
}
|
|
916
|
-
function
|
|
921
|
+
function $(t, e, i) {
|
|
922
|
+
const r = [];
|
|
923
|
+
let n = e;
|
|
924
|
+
for (; n + 8 <= i; ) {
|
|
925
|
+
let s = t.getUint32(n);
|
|
926
|
+
const o = String.fromCharCode(
|
|
927
|
+
t.getUint8(n + 4),
|
|
928
|
+
t.getUint8(n + 5),
|
|
929
|
+
t.getUint8(n + 6),
|
|
930
|
+
t.getUint8(n + 7)
|
|
931
|
+
);
|
|
932
|
+
let a = 8;
|
|
933
|
+
if (s === 1 ? (s = Number(t.getBigUint64(n + 8)), a = 16) : s === 0 && (s = i - n), s < a || n + s > i)
|
|
934
|
+
throw new Error(`Malformed MP4 box ${o}`);
|
|
935
|
+
r.push({ type: o, start: n + a, end: n + s }), n += s;
|
|
936
|
+
}
|
|
937
|
+
return r;
|
|
938
|
+
}
|
|
939
|
+
function b(t, e, i) {
|
|
940
|
+
const r = $(t, e.start, e.end).find(
|
|
941
|
+
(n) => n.type === i
|
|
942
|
+
);
|
|
943
|
+
if (!r)
|
|
944
|
+
throw new Error(`MP4 box ${i} not found in ${e.type}`);
|
|
945
|
+
return r;
|
|
946
|
+
}
|
|
947
|
+
function V(t, e, i) {
|
|
948
|
+
return $(t, e.start, e.end).find((r) => r.type === i) ?? null;
|
|
949
|
+
}
|
|
950
|
+
function D(t, e) {
|
|
951
|
+
return { at: e.start + 8, count: t.getUint32(e.start + 4) };
|
|
952
|
+
}
|
|
953
|
+
function yt(t, e, i) {
|
|
954
|
+
const r = V(t, e, "edts"), n = r && V(t, r, "elst");
|
|
955
|
+
if (!n)
|
|
956
|
+
return;
|
|
957
|
+
const { at: s, count: o } = D(t, n), a = t.getUint8(n.start) === 1 ? Number(t.getBigInt64(s + 8)) : t.getInt32(s + 4);
|
|
958
|
+
if (o !== 1 || a !== i)
|
|
959
|
+
throw new Error("Unsupported MP4 edit list");
|
|
960
|
+
}
|
|
961
|
+
function _t(t) {
|
|
962
|
+
const e = new DataView(t), i = { type: "file", start: 0, end: t.byteLength }, r = b(e, i, "moov"), n = $(e, r.start, r.end).find((f) => {
|
|
963
|
+
if (f.type !== "trak")
|
|
964
|
+
return !1;
|
|
965
|
+
const u = b(e, b(e, f, "mdia"), "hdlr");
|
|
966
|
+
return String.fromCharCode(...new Uint8Array(t, u.start + 8, 4)) === "vide";
|
|
967
|
+
});
|
|
968
|
+
if (!n)
|
|
969
|
+
throw new Error("MP4 has no video track");
|
|
970
|
+
const s = b(
|
|
971
|
+
e,
|
|
972
|
+
b(e, b(e, n, "mdia"), "minf"),
|
|
973
|
+
"stbl"
|
|
974
|
+
), o = b(e, s, "stsd"), [a] = $(e, o.start + 8, o.end);
|
|
975
|
+
if (!a || a.type !== "avc1" && a.type !== "avc3")
|
|
976
|
+
throw new Error(`Unsupported MP4 sample entry ${a?.type}`);
|
|
977
|
+
const d = e.getUint16(a.start + 24), c = e.getUint16(a.start + 26), l = b(e, { ...a, start: a.start + 78 }, "avcC"), h = new Uint8Array(t.slice(l.start, l.end)), p = (f) => h[f].toString(16).padStart(2, "0"), m = `avc1.${p(1)}${p(2)}${p(3)}`, E = b(e, s, "stsz"), w = e.getUint32(E.start + 4), y = e.getUint32(E.start + 8), A = Array.from(
|
|
978
|
+
{ length: y },
|
|
979
|
+
(f, u) => w || e.getUint32(E.start + 12 + u * 4)
|
|
980
|
+
), N = V(e, s, "co64"), O = N ?? b(e, s, "stco"), U = D(e, O), T = Array.from(
|
|
981
|
+
{ length: U.count },
|
|
982
|
+
(f, u) => N ? Number(e.getBigUint64(U.at + u * 8)) : e.getUint32(U.at + u * 4)
|
|
983
|
+
), _ = D(e, b(e, s, "stsc")), F = [];
|
|
984
|
+
for (let f = 0; f < _.count; f++) {
|
|
985
|
+
const u = _.at + f * 12, I = e.getUint32(u) - 1, R = e.getUint32(u + 4), z = f + 1 < _.count ? e.getUint32(u + 12) - 1 : T.length;
|
|
986
|
+
for (let L = I; L < z; L++) {
|
|
987
|
+
let C = T[L];
|
|
988
|
+
for (let te = 0; te < R && F.length < y; te++)
|
|
989
|
+
F.push(C), C += A[F.length - 1];
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
const S = D(e, b(e, s, "stts")), k = [];
|
|
993
|
+
let P = 0;
|
|
994
|
+
for (let f = 0; f < S.count; f++) {
|
|
995
|
+
const u = e.getUint32(S.at + f * 8), I = e.getUint32(S.at + f * 8 + 4);
|
|
996
|
+
for (let R = 0; R < u; R++)
|
|
997
|
+
k.push(P), P += I;
|
|
998
|
+
}
|
|
999
|
+
const W = V(e, s, "ctts");
|
|
1000
|
+
if (W) {
|
|
1001
|
+
const f = e.getUint8(W.start) === 1, u = D(e, W);
|
|
1002
|
+
let I = 0;
|
|
1003
|
+
for (let R = 0; R < u.count; R++) {
|
|
1004
|
+
const z = e.getUint32(u.at + R * 8), L = f ? e.getInt32(u.at + R * 8 + 4) : e.getUint32(u.at + R * 8 + 4);
|
|
1005
|
+
for (let C = 0; C < z; C++)
|
|
1006
|
+
k[I++] += L;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
yt(e, n, Math.min(...k.slice(0, y)));
|
|
1010
|
+
const ge = k.slice(0, y).map((f, u) => [f, u]).sort((f, u) => f[0] - u[0]), J = new Array(y);
|
|
1011
|
+
ge.forEach(([, f], u) => J[f] = u);
|
|
1012
|
+
const H = V(e, s, "stss"), ee = /* @__PURE__ */ new Set();
|
|
1013
|
+
if (H) {
|
|
1014
|
+
const f = D(e, H);
|
|
1015
|
+
for (let u = 0; u < f.count; u++)
|
|
1016
|
+
ee.add(e.getUint32(f.at + u * 4) - 1);
|
|
1017
|
+
}
|
|
1018
|
+
if (F.length !== y || k.length < y)
|
|
1019
|
+
throw new Error("Inconsistent MP4 sample tables");
|
|
1020
|
+
return {
|
|
1021
|
+
codec: m,
|
|
1022
|
+
description: h,
|
|
1023
|
+
width: d,
|
|
1024
|
+
height: c,
|
|
1025
|
+
samples: A.map((f, u) => ({
|
|
1026
|
+
offset: F[u],
|
|
1027
|
+
size: f,
|
|
1028
|
+
frame: J[u],
|
|
1029
|
+
key: H ? ee.has(u) : !0
|
|
1030
|
+
}))
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
const Rt = 50;
|
|
1034
|
+
class xt extends bt {
|
|
1035
|
+
constructor() {
|
|
1036
|
+
super(...arguments), this.track = null, this.data = null, this.sampleOfFrame = [], this.decoder = null, this.fed = -1, this.taken = -1, this.outputs = /* @__PURE__ */ new Map(), this.progress = null, this.failure = null, this.loading = null;
|
|
1037
|
+
}
|
|
1038
|
+
/** True once the media decodes through WebCodecs. */
|
|
1039
|
+
get usesWebCodecs() {
|
|
1040
|
+
return this.track !== null;
|
|
1041
|
+
}
|
|
1042
|
+
async loadMedia() {
|
|
1043
|
+
if (typeof VideoDecoder > "u" || typeof fetch > "u")
|
|
1044
|
+
return super.loadMedia();
|
|
1045
|
+
const e = new AbortController();
|
|
1046
|
+
this.loading = e;
|
|
1047
|
+
const i = await fetch(this.manifest.media.url, {
|
|
1048
|
+
signal: e.signal
|
|
1049
|
+
});
|
|
1050
|
+
if (!i.ok)
|
|
1051
|
+
throw new Error(
|
|
1052
|
+
`Failed to load GeoVideo media: ${this.manifest.media.url}`
|
|
1053
|
+
);
|
|
1054
|
+
const r = await i.arrayBuffer();
|
|
1055
|
+
let n;
|
|
1056
|
+
try {
|
|
1057
|
+
n = _t(r);
|
|
1058
|
+
} catch {
|
|
1059
|
+
return this.loading === e ? super.loadMedia() : void 0;
|
|
1060
|
+
}
|
|
1061
|
+
if (n.width !== this.manifest.media.width || n.height !== this.manifest.media.height)
|
|
1062
|
+
throw new Error(
|
|
1063
|
+
`GeoVideo media dimensions ${n.width}x${n.height} do not match manifest ${this.manifest.media.width}x${this.manifest.media.height}`
|
|
1064
|
+
);
|
|
1065
|
+
const { supported: s } = await VideoDecoder.isConfigSupported(
|
|
1066
|
+
this.config(n)
|
|
1067
|
+
).catch(() => ({ supported: !1 }));
|
|
1068
|
+
if (this.loading !== e)
|
|
1069
|
+
throw g();
|
|
1070
|
+
if (this.loading = null, !s)
|
|
1071
|
+
return super.loadMedia();
|
|
1072
|
+
this.sampleOfFrame = [], n.samples.forEach(
|
|
1073
|
+
(o, a) => this.sampleOfFrame[o.frame] = a
|
|
1074
|
+
), this.data = r, this.track = n;
|
|
1075
|
+
}
|
|
1076
|
+
release() {
|
|
1077
|
+
this.loading?.abort(), this.loading = null, this.closeDecoder(), this.track = null, this.data = null, super.release();
|
|
1078
|
+
}
|
|
1079
|
+
async decode(e, i) {
|
|
1080
|
+
if (await this.init(), !this.track)
|
|
1081
|
+
return super.decode(e, i);
|
|
1082
|
+
if (i.aborted)
|
|
1083
|
+
throw g();
|
|
1084
|
+
const r = Math.min(
|
|
1085
|
+
this.track.samples.length - 1,
|
|
1086
|
+
Math.floor(this.stepSeconds(e) * this.manifest.media.fps + 1e-6)
|
|
1087
|
+
), n = await this.decodeFrame(r, i);
|
|
1088
|
+
try {
|
|
1089
|
+
return await createImageBitmap(n, {
|
|
1090
|
+
premultiplyAlpha: "none",
|
|
1091
|
+
colorSpaceConversion: "none"
|
|
1092
|
+
});
|
|
1093
|
+
} finally {
|
|
1094
|
+
n.close();
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
config(e) {
|
|
1098
|
+
return {
|
|
1099
|
+
codec: e.codec,
|
|
1100
|
+
description: e.description,
|
|
1101
|
+
codedWidth: e.width,
|
|
1102
|
+
codedHeight: e.height,
|
|
1103
|
+
optimizeForLatency: !0
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
/** Video frame `frame`, owned by the caller. */
|
|
1107
|
+
async decodeFrame(e, i) {
|
|
1108
|
+
const r = this.track, n = this.sampleOfFrame[e], s = this.keySample(n);
|
|
1109
|
+
for ((this.fed < 0 || e <= this.taken || s > this.fed) && this.restart(s), this.taken = e - 1, this.dropOutputsBefore(e); !this.outputs.has(e); ) {
|
|
1110
|
+
if (this.failure)
|
|
1111
|
+
throw this.failure;
|
|
1112
|
+
if (i.aborted)
|
|
1113
|
+
throw g();
|
|
1114
|
+
const a = this.decoder;
|
|
1115
|
+
this.fed < r.samples.length && a.decodeQueueSize < 2 && (this.feed(this.fed++), this.fed === r.samples.length && a.flush().catch(() => {
|
|
1116
|
+
})), await this.waitProgress();
|
|
1117
|
+
}
|
|
1118
|
+
const o = this.outputs.get(e);
|
|
1119
|
+
return this.outputs.delete(e), this.taken = e, o;
|
|
1120
|
+
}
|
|
1121
|
+
dropOutputsBefore(e) {
|
|
1122
|
+
for (const [i, r] of this.outputs)
|
|
1123
|
+
i < e && (r.close(), this.outputs.delete(i));
|
|
1124
|
+
}
|
|
1125
|
+
keySample(e) {
|
|
1126
|
+
const { samples: i } = this.track;
|
|
1127
|
+
let r = e;
|
|
1128
|
+
for (; r > 0 && !i[r].key; )
|
|
1129
|
+
r--;
|
|
1130
|
+
return r;
|
|
1131
|
+
}
|
|
1132
|
+
restart(e) {
|
|
1133
|
+
this.closeDecoder(), this.failure = null;
|
|
1134
|
+
const i = new VideoDecoder({
|
|
1135
|
+
output: (r) => {
|
|
1136
|
+
this.decoder !== i || r.timestamp <= this.taken ? r.close() : this.outputs.set(r.timestamp, r), this.notify();
|
|
1137
|
+
},
|
|
1138
|
+
error: (r) => {
|
|
1139
|
+
this.decoder === i && (this.failure = r, this.fed = -1), this.notify();
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
i.addEventListener("dequeue", () => this.notify()), i.configure(this.config(this.track)), this.decoder = i, this.fed = e, this.taken = this.track.samples[e].frame - 1;
|
|
1143
|
+
}
|
|
1144
|
+
feed(e) {
|
|
1145
|
+
const i = this.track.samples[e];
|
|
1146
|
+
this.decoder.decode(
|
|
1147
|
+
new EncodedVideoChunk({
|
|
1148
|
+
type: i.key ? "key" : "delta",
|
|
1149
|
+
// Video frame numbers: outputs carry them back in display order.
|
|
1150
|
+
timestamp: i.frame,
|
|
1151
|
+
data: new Uint8Array(this.data, i.offset, i.size)
|
|
1152
|
+
})
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
/** Next output, dequeue or error; a timer for decoders without events. */
|
|
1156
|
+
waitProgress() {
|
|
1157
|
+
return new Promise((e) => {
|
|
1158
|
+
const i = setTimeout(r, Rt);
|
|
1159
|
+
function r() {
|
|
1160
|
+
clearTimeout(i), e();
|
|
1161
|
+
}
|
|
1162
|
+
this.progress = r;
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
notify() {
|
|
1166
|
+
const e = this.progress;
|
|
1167
|
+
this.progress = null, e?.();
|
|
1168
|
+
}
|
|
1169
|
+
closeDecoder() {
|
|
1170
|
+
this.decoder && this.decoder.state !== "closed" && this.decoder.close(), this.decoder = null, this.fed = -1;
|
|
1171
|
+
for (const e of this.outputs.values())
|
|
1172
|
+
e.close();
|
|
1173
|
+
this.outputs.clear();
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
function vt(t, e) {
|
|
917
1177
|
let i = (t - e.codeMin) / (e.codeMax - e.codeMin) * 2 - 1;
|
|
918
1178
|
return i = Math.max(-1, Math.min(1, i)), e.transfer === "sqrt" && (i = Math.sign(i) * i * i), i * e.valueDomain;
|
|
919
1179
|
}
|
|
920
|
-
function
|
|
1180
|
+
function kt(t, e, i, r) {
|
|
921
1181
|
const n = e.length;
|
|
922
1182
|
if (t.length !== 2 * n)
|
|
923
1183
|
throw new Error(
|
|
924
1184
|
`GeoVideo vector frame has ${t.length} codes, expected ${2 * n}`
|
|
925
1185
|
);
|
|
926
|
-
const
|
|
1186
|
+
const s = new Float32Array(256);
|
|
927
1187
|
for (let c = 0; c < 256; c++)
|
|
928
|
-
|
|
929
|
-
const o = i * 255,
|
|
1188
|
+
s[c] = vt(c, r);
|
|
1189
|
+
const o = i * 255, a = new Float32Array(n), d = new Float32Array(n);
|
|
930
1190
|
for (let c = 0; c < n; c++) {
|
|
931
|
-
const
|
|
932
|
-
|
|
1191
|
+
const l = e[c] >= o;
|
|
1192
|
+
a[c] = l ? s[t[c]] : NaN, d[c] = l ? s[t[n + c]] : NaN;
|
|
933
1193
|
}
|
|
934
|
-
return { u:
|
|
1194
|
+
return { u: a, v: d };
|
|
935
1195
|
}
|
|
936
|
-
class
|
|
1196
|
+
class At extends me {
|
|
937
1197
|
constructor(e, i = {}) {
|
|
938
1198
|
if (e.encoding.kind !== "vector-luma")
|
|
939
1199
|
throw new Error("GeoVideoVectorSource requires a vector-luma manifest");
|
|
940
1200
|
super(e, 2, i), this.encoding = e.encoding;
|
|
941
|
-
const [r, n,
|
|
1201
|
+
const [r, n, s, o] = e.bounds, a = (s - r) / this.width, d = (o - n) / this.height;
|
|
942
1202
|
this.coords = {
|
|
943
1203
|
time: this.times,
|
|
944
1204
|
vertical: new Float32Array([0]),
|
|
945
1205
|
latitude: Float32Array.from(
|
|
946
1206
|
{ length: this.height },
|
|
947
|
-
(c,
|
|
1207
|
+
(c, l) => o - (l + 0.5) * d
|
|
948
1208
|
),
|
|
949
1209
|
longitude: Float32Array.from(
|
|
950
1210
|
{ length: this.width },
|
|
951
|
-
(c,
|
|
1211
|
+
(c, l) => r + (l + 0.5) * a
|
|
952
1212
|
)
|
|
953
1213
|
};
|
|
954
1214
|
}
|
|
@@ -970,12 +1230,12 @@ class st extends J {
|
|
|
970
1230
|
findTimeIndex(e) {
|
|
971
1231
|
const i = typeof e == "number" ? e : new Date(e).getTime(), r = this.coords.time;
|
|
972
1232
|
let n = 0;
|
|
973
|
-
for (let
|
|
974
|
-
Math.abs(r[
|
|
1233
|
+
for (let s = 1; s < r.length; s++)
|
|
1234
|
+
Math.abs(r[s] - i) < Math.abs(r[n] - i) && (n = s);
|
|
975
1235
|
return n;
|
|
976
1236
|
}
|
|
977
1237
|
getChunksForBounds(e, i, r) {
|
|
978
|
-
const { latitude: n, longitude:
|
|
1238
|
+
const { latitude: n, longitude: s } = this.coords;
|
|
979
1239
|
return [
|
|
980
1240
|
{
|
|
981
1241
|
timeIdx: i,
|
|
@@ -983,7 +1243,7 @@ class st extends J {
|
|
|
983
1243
|
latIdx: 0,
|
|
984
1244
|
lonIdx: 0,
|
|
985
1245
|
latRange: [n[0], n[this.height - 1]],
|
|
986
|
-
lonRange: [
|
|
1246
|
+
lonRange: [s[0], s[this.width - 1]],
|
|
987
1247
|
latSize: this.height,
|
|
988
1248
|
lonSize: this.width
|
|
989
1249
|
}
|
|
@@ -1000,7 +1260,7 @@ class st extends J {
|
|
|
1000
1260
|
/** u/v codes are written into luma: read back, then decoded on the CPU. */
|
|
1001
1261
|
async capture(e, i, r) {
|
|
1002
1262
|
const n = this.readCodes(e, i);
|
|
1003
|
-
return n ?
|
|
1263
|
+
return n ? kt(
|
|
1004
1264
|
n,
|
|
1005
1265
|
r,
|
|
1006
1266
|
this.manifest.mask.threshold,
|
|
@@ -1008,23 +1268,23 @@ class st extends J {
|
|
|
1008
1268
|
) : null;
|
|
1009
1269
|
}
|
|
1010
1270
|
}
|
|
1011
|
-
function
|
|
1012
|
-
const [r, n] = i.range ?? [-1 / 0, 1 / 0],
|
|
1013
|
-
(
|
|
1014
|
-
) ?? (i.loop ?
|
|
1015
|
-
(
|
|
1271
|
+
function Ft(t, e, i = {}) {
|
|
1272
|
+
const [r, n] = i.range ?? [-1 / 0, 1 / 0], s = [...t].sort((a, d) => a.start - d.start), o = s.find(
|
|
1273
|
+
(a) => a.start > e && a.start <= n
|
|
1274
|
+
) ?? (i.loop ? s.find(
|
|
1275
|
+
(a) => a.end >= r && a.start <= n
|
|
1016
1276
|
) : void 0);
|
|
1017
1277
|
return o ? { chunk: o, time: Math.max(o.start, r) } : null;
|
|
1018
1278
|
}
|
|
1019
|
-
function
|
|
1279
|
+
function St(t, e) {
|
|
1020
1280
|
let i = null, r = -1 / 0;
|
|
1021
1281
|
for (const n of e) {
|
|
1022
|
-
const
|
|
1023
|
-
Number.isFinite(
|
|
1282
|
+
const s = Math.min(t.end, n.end) - Math.max(t.start, n.start);
|
|
1283
|
+
Number.isFinite(s) && s >= 0 && s > r && (i = n, r = s);
|
|
1024
1284
|
}
|
|
1025
1285
|
return i;
|
|
1026
1286
|
}
|
|
1027
|
-
function
|
|
1287
|
+
function Ut(t) {
|
|
1028
1288
|
return {
|
|
1029
1289
|
width: t.mask.width,
|
|
1030
1290
|
height: t.mask.height,
|
|
@@ -1032,11 +1292,11 @@ function lt(t) {
|
|
|
1032
1292
|
rowOrder: "north-to-south"
|
|
1033
1293
|
};
|
|
1034
1294
|
}
|
|
1035
|
-
function
|
|
1036
|
-
return t.encoding.kind === "vector-luma" ? new
|
|
1295
|
+
function pe(t, e = {}) {
|
|
1296
|
+
return t.encoding.kind === "vector-luma" ? new At(t, e) : new xt(t, e);
|
|
1037
1297
|
}
|
|
1038
|
-
const
|
|
1039
|
-
function
|
|
1298
|
+
const Mt = 3, Pt = 3, Dt = 0.6, Gt = 1.5;
|
|
1299
|
+
function Nt(t) {
|
|
1040
1300
|
const e = new AbortController();
|
|
1041
1301
|
if (!t)
|
|
1042
1302
|
return { controller: e, unlink: () => {
|
|
@@ -1047,14 +1307,14 @@ function mt(t) {
|
|
|
1047
1307
|
unlink: () => t.removeEventListener("abort", i)
|
|
1048
1308
|
};
|
|
1049
1309
|
}
|
|
1050
|
-
class
|
|
1310
|
+
class _i {
|
|
1051
1311
|
constructor(e) {
|
|
1052
1312
|
this.manifests = /* @__PURE__ */ new Map(), this.open = /* @__PURE__ */ new Map(), this.id = e.id, this.chunks = e.chunks.filter(
|
|
1053
1313
|
(i) => Number.isFinite(i.start) && Number.isFinite(i.end) && i.end >= i.start
|
|
1054
|
-
).sort((i, r) => i.start - r.start), this.maxOpenChunks = Math.max(2, e.maxOpenChunks ??
|
|
1314
|
+
).sort((i, r) => i.start - r.start), this.maxOpenChunks = Math.max(2, e.maxOpenChunks ?? Mt), this.frameCacheSize = Math.max(
|
|
1055
1315
|
1,
|
|
1056
|
-
e.frameCacheSize ??
|
|
1057
|
-
), this.prefetchAt = e.prefetchAt ??
|
|
1316
|
+
e.frameCacheSize ?? Pt
|
|
1317
|
+
), this.prefetchAt = e.prefetchAt ?? Dt, this.maxGap = e.maxGap, this.loadManifest = e.loadManifest ?? ut, this.createFrameSource = e.createFrameSource ?? ((i, r) => pe(
|
|
1058
1318
|
i,
|
|
1059
1319
|
r
|
|
1060
1320
|
));
|
|
@@ -1072,12 +1332,12 @@ class ti {
|
|
|
1072
1332
|
/** Every step time of the archive; loads all chunk manifests. */
|
|
1073
1333
|
async steps(e = {}) {
|
|
1074
1334
|
if (e.signal?.aborted)
|
|
1075
|
-
throw
|
|
1076
|
-
const i = await
|
|
1335
|
+
throw g();
|
|
1336
|
+
const i = await G(
|
|
1077
1337
|
Promise.all(this.chunks.map((r) => this.manifest(r))),
|
|
1078
1338
|
e.signal
|
|
1079
1339
|
);
|
|
1080
|
-
return Float64Array.from(i.flatMap(
|
|
1340
|
+
return Float64Array.from(i.flatMap(M));
|
|
1081
1341
|
}
|
|
1082
1342
|
/**
|
|
1083
1343
|
* The frames bracketing `time`, decoded; null out of coverage (before the
|
|
@@ -1086,42 +1346,42 @@ class ti {
|
|
|
1086
1346
|
async sample(e, i = {}) {
|
|
1087
1347
|
const { signal: r } = i, n = i.mode ?? "interpolate";
|
|
1088
1348
|
if (r?.aborted)
|
|
1089
|
-
throw
|
|
1090
|
-
const
|
|
1091
|
-
if (
|
|
1349
|
+
throw g();
|
|
1350
|
+
const s = this.chunkIndexAt(e);
|
|
1351
|
+
if (s < 0)
|
|
1092
1352
|
return null;
|
|
1093
|
-
const o = [], { controller:
|
|
1353
|
+
const o = [], { controller: a, unlink: d } = Nt(r);
|
|
1094
1354
|
try {
|
|
1095
|
-
const c = this.acquire(this.chunks[
|
|
1096
|
-
let
|
|
1355
|
+
const c = this.acquire(this.chunks[s], o), l = await G(c.ready, a.signal), { times: h } = l;
|
|
1356
|
+
let p;
|
|
1097
1357
|
if (e <= h[h.length - 1]) {
|
|
1098
|
-
const { index:
|
|
1099
|
-
|
|
1358
|
+
const { index: T, fraction: _ } = v(h, e);
|
|
1359
|
+
p = n === "discrete" || _ === 0 ? [c, T, c, T, 0] : [c, T, c, T + 1, _];
|
|
1100
1360
|
} else {
|
|
1101
|
-
const
|
|
1102
|
-
if (!
|
|
1361
|
+
const T = this.chunks[s + 1];
|
|
1362
|
+
if (!T)
|
|
1103
1363
|
return null;
|
|
1104
|
-
const
|
|
1105
|
-
if (
|
|
1364
|
+
const _ = this.acquire(T, o), F = await G(_.ready, a.signal), S = h.length - 1, k = h[S], P = F.times[0];
|
|
1365
|
+
if (P - k > this.gapLimit(h, F.times))
|
|
1106
1366
|
return null;
|
|
1107
|
-
|
|
1367
|
+
p = n === "discrete" ? [c, S, c, S, 0] : e >= P ? [_, 0, _, 0, 0] : [c, S, _, 0, (e - k) / (P - k)];
|
|
1108
1368
|
}
|
|
1109
|
-
const [
|
|
1110
|
-
|
|
1111
|
-
let
|
|
1369
|
+
const [m, E, w, y, A] = p, N = m === w && E === y, O = [this.frame(m, E, a.signal)];
|
|
1370
|
+
N || O.push(this.frame(w, y, a.signal));
|
|
1371
|
+
let U;
|
|
1112
1372
|
try {
|
|
1113
|
-
|
|
1114
|
-
} catch (
|
|
1115
|
-
throw
|
|
1373
|
+
U = await Promise.all(O);
|
|
1374
|
+
} catch (T) {
|
|
1375
|
+
throw a.abort(), T;
|
|
1116
1376
|
}
|
|
1117
|
-
return this.prefetchAfter(
|
|
1377
|
+
return this.prefetchAfter(s, e), {
|
|
1118
1378
|
time: e,
|
|
1119
|
-
a:
|
|
1120
|
-
b:
|
|
1121
|
-
mix:
|
|
1379
|
+
a: U[0],
|
|
1380
|
+
b: U[N ? 0 : 1],
|
|
1381
|
+
mix: A
|
|
1122
1382
|
};
|
|
1123
1383
|
} finally {
|
|
1124
|
-
|
|
1384
|
+
d();
|
|
1125
1385
|
for (const c of o)
|
|
1126
1386
|
c.users--;
|
|
1127
1387
|
this.trim();
|
|
@@ -1145,8 +1405,8 @@ class ti {
|
|
|
1145
1405
|
chunkIndexAt(e) {
|
|
1146
1406
|
let i = 0, r = this.chunks.length - 1, n = -1;
|
|
1147
1407
|
for (; i <= r; ) {
|
|
1148
|
-
const
|
|
1149
|
-
this.chunks[
|
|
1408
|
+
const s = i + r >> 1;
|
|
1409
|
+
this.chunks[s].start <= e ? (n = s, i = s + 1) : r = s - 1;
|
|
1150
1410
|
}
|
|
1151
1411
|
return n;
|
|
1152
1412
|
}
|
|
@@ -1157,10 +1417,10 @@ class ti {
|
|
|
1157
1417
|
e.length > 1 ? e[e.length - 1] - e[e.length - 2] : 0,
|
|
1158
1418
|
i.length > 1 ? i[1] - i[0] : 0
|
|
1159
1419
|
], n = Math.max(...r);
|
|
1160
|
-
return n > 0 ? n *
|
|
1420
|
+
return n > 0 ? n * Gt : -1 / 0;
|
|
1161
1421
|
}
|
|
1162
1422
|
prefetchAfter(e, i) {
|
|
1163
|
-
const r = this.chunks[e], n = this.chunks[e + 1],
|
|
1423
|
+
const r = this.chunks[e], n = this.chunks[e + 1], s = r.end - r.start, o = s > 0 ? (i - r.start) / s : 1;
|
|
1164
1424
|
n && o > this.prefetchAt && this.prefetch(n);
|
|
1165
1425
|
}
|
|
1166
1426
|
manifest(e) {
|
|
@@ -1190,11 +1450,11 @@ class ti {
|
|
|
1190
1450
|
};
|
|
1191
1451
|
r.ready = this.manifest(e).then((n) => {
|
|
1192
1452
|
if (r.released)
|
|
1193
|
-
throw
|
|
1453
|
+
throw g();
|
|
1194
1454
|
return r.opened = {
|
|
1195
1455
|
manifest: n,
|
|
1196
|
-
times: Float64Array.from(
|
|
1197
|
-
grid:
|
|
1456
|
+
times: Float64Array.from(M(n)),
|
|
1457
|
+
grid: Ut(n),
|
|
1198
1458
|
source: this.createFrameSource(n, {
|
|
1199
1459
|
cacheSize: this.frameCacheSize
|
|
1200
1460
|
})
|
|
@@ -1206,19 +1466,19 @@ class ti {
|
|
|
1206
1466
|
return this.open.set(e.key, i), i;
|
|
1207
1467
|
}
|
|
1208
1468
|
async frame(e, i, r) {
|
|
1209
|
-
const { manifest: n, times:
|
|
1469
|
+
const { manifest: n, times: s, grid: o, source: a } = await G(
|
|
1210
1470
|
e.ready,
|
|
1211
1471
|
r
|
|
1212
1472
|
);
|
|
1213
1473
|
if (e.released)
|
|
1214
|
-
throw
|
|
1215
|
-
const
|
|
1474
|
+
throw g();
|
|
1475
|
+
const d = await a.frame(i, { signal: r });
|
|
1216
1476
|
return {
|
|
1217
1477
|
key: `${this.id}/${e.chunk.key}/${i}`,
|
|
1218
1478
|
chunk: e.chunk,
|
|
1219
1479
|
step: i,
|
|
1220
|
-
time:
|
|
1221
|
-
data:
|
|
1480
|
+
time: s[i],
|
|
1481
|
+
data: d,
|
|
1222
1482
|
grid: o,
|
|
1223
1483
|
manifest: n
|
|
1224
1484
|
};
|
|
@@ -1236,18 +1496,18 @@ class ti {
|
|
|
1236
1496
|
e.released = !0, e.prefetch?.abort(), e.prefetch = null, e.opened?.source.release(), e.opened = null, this.open.get(e.chunk.key) === e && this.open.delete(e.chunk.key);
|
|
1237
1497
|
}
|
|
1238
1498
|
}
|
|
1239
|
-
const
|
|
1499
|
+
const It = {
|
|
1240
1500
|
a: "u_vel0",
|
|
1241
1501
|
b: "u_vel1",
|
|
1242
1502
|
mix: "u_vel_mix",
|
|
1243
1503
|
bounds: "u_bounds"
|
|
1244
|
-
},
|
|
1504
|
+
}, Lt = {
|
|
1245
1505
|
a: "u_tint0",
|
|
1246
1506
|
b: "u_tint1",
|
|
1247
1507
|
mix: "u_tint_mix",
|
|
1248
1508
|
bounds: "u_tint_bounds"
|
|
1249
1509
|
};
|
|
1250
|
-
function
|
|
1510
|
+
function Ct(t) {
|
|
1251
1511
|
const e = new Float32Array(t.u.length * 4);
|
|
1252
1512
|
for (let i = 0; i < t.u.length; i++) {
|
|
1253
1513
|
const r = t.u[i], n = t.v[i];
|
|
@@ -1255,10 +1515,10 @@ function Tt(t) {
|
|
|
1255
1515
|
}
|
|
1256
1516
|
return e;
|
|
1257
1517
|
}
|
|
1258
|
-
class
|
|
1518
|
+
class Vt {
|
|
1259
1519
|
constructor(e, i, r = {}) {
|
|
1260
|
-
this.gl = e, this.manifest = i, this.options = r, this.textures = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.mask = null, this.pair = null, this.destroyed = !1, this.linearFilter = !0, this.uploadedFrames = 0, this.lastUploadDurationMs = 0, this.vector = i.encoding.kind === "vector-luma", this.source =
|
|
1261
|
-
const n =
|
|
1520
|
+
this.gl = e, this.manifest = i, this.options = r, this.textures = /* @__PURE__ */ new Map(), this.pending = /* @__PURE__ */ new Map(), this.mask = null, this.pair = null, this.destroyed = !1, this.linearFilter = !0, this.uploadedFrames = 0, this.lastUploadDurationMs = 0, this.vector = i.encoding.kind === "vector-luma", this.source = pe(i, { cacheSize: 2 }), this.uniforms = this.vector ? It : Lt;
|
|
1521
|
+
const n = M(i);
|
|
1262
1522
|
this.times = r.animateSnapshot && i.timeline.kind === "snapshot-loop" ? Array.from(
|
|
1263
1523
|
{
|
|
1264
1524
|
length: Math.max(
|
|
@@ -1266,7 +1526,7 @@ class gt {
|
|
|
1266
1526
|
Math.round(i.media.durationSeconds * i.media.fps)
|
|
1267
1527
|
)
|
|
1268
1528
|
},
|
|
1269
|
-
(
|
|
1529
|
+
(s, o) => n[0] + o * 1e3 / i.media.fps
|
|
1270
1530
|
) : n, this.bounds = i.bounds;
|
|
1271
1531
|
}
|
|
1272
1532
|
get currentPair() {
|
|
@@ -1283,12 +1543,16 @@ class gt {
|
|
|
1283
1543
|
}
|
|
1284
1544
|
/** Resolves once the step at `ms` is uploaded. */
|
|
1285
1545
|
async prime(e) {
|
|
1286
|
-
const { index: i } =
|
|
1546
|
+
const { index: i } = v(this.times, e);
|
|
1287
1547
|
await this.request(i);
|
|
1288
1548
|
}
|
|
1549
|
+
/** The uploaded texture of the step at `ms`, or null. */
|
|
1550
|
+
texture(e) {
|
|
1551
|
+
return this.textures.get(v(this.times, e).index) ?? null;
|
|
1552
|
+
}
|
|
1289
1553
|
/** True once the frames interpolated at `ms` are uploaded. */
|
|
1290
1554
|
ready(e) {
|
|
1291
|
-
const { index: i, fraction: r } =
|
|
1555
|
+
const { index: i, fraction: r } = v(this.times, e);
|
|
1292
1556
|
return this.textures.has(i) && (r === 0 || this.textures.has(i + 1));
|
|
1293
1557
|
}
|
|
1294
1558
|
/**
|
|
@@ -1296,12 +1560,12 @@ class gt {
|
|
|
1296
1560
|
* `ms`, then request those first.
|
|
1297
1561
|
*/
|
|
1298
1562
|
focus(e) {
|
|
1299
|
-
const { index: i } =
|
|
1563
|
+
const { index: i } = v(this.times, e), r = Math.min(i + 1, this.times.length - 1);
|
|
1300
1564
|
[...this.pending.keys()].some(
|
|
1301
|
-
(
|
|
1565
|
+
(s) => s !== i && s !== r
|
|
1302
1566
|
) && (this.source.cancelAll(), this.pending.clear());
|
|
1303
|
-
for (const
|
|
1304
|
-
this.request(
|
|
1567
|
+
for (const s of [i, r])
|
|
1568
|
+
this.request(s).catch(() => {
|
|
1305
1569
|
});
|
|
1306
1570
|
}
|
|
1307
1571
|
/**
|
|
@@ -1309,13 +1573,13 @@ class gt {
|
|
|
1309
1573
|
* while a requested frame decodes.
|
|
1310
1574
|
*/
|
|
1311
1575
|
sample(e, i = !0) {
|
|
1312
|
-
const { index: r, fraction: n } =
|
|
1313
|
-
[...this.pending.keys()].some((c) => c < r || c >
|
|
1314
|
-
for (const c of [r,
|
|
1576
|
+
const { index: r, fraction: n } = v(this.times, e), s = Math.min(r + 1, this.times.length - 1);
|
|
1577
|
+
[...this.pending.keys()].some((c) => c < r || c > s + 1) && (this.source.cancelAll(), this.pending.clear());
|
|
1578
|
+
for (const c of [r, s, s + 1])
|
|
1315
1579
|
c < this.times.length && this.request(c).catch(() => {
|
|
1316
1580
|
});
|
|
1317
|
-
const o = this.textures.get(r),
|
|
1318
|
-
return o && (
|
|
1581
|
+
const o = this.textures.get(r), a = this.textures.get(s), d = i ? n : 0;
|
|
1582
|
+
return o && (d === 0 || a) && (this.pair = [o, d === 0 ? o : a, d]), this.evict(r), this.pair;
|
|
1319
1583
|
}
|
|
1320
1584
|
/** Switch spatial filtering without changing the decoded-step cache. */
|
|
1321
1585
|
setFilter(e) {
|
|
@@ -1348,10 +1612,10 @@ class gt {
|
|
|
1348
1612
|
return !1;
|
|
1349
1613
|
const n = this.uniforms;
|
|
1350
1614
|
if (e.texture(n.a, r, this.pair[0]), e.texture(n.b, r + 1, this.pair[1]), e.float(n.mix, this.pair[2]), e.vec4(n.bounds, this.bounds), this.mask && this.manifest.encoding.kind === "scalar-luma") {
|
|
1351
|
-
const { codeRange:
|
|
1615
|
+
const { codeRange: s, valueRange: o, transfer: a } = Tt(
|
|
1352
1616
|
this.manifest.encoding
|
|
1353
1617
|
);
|
|
1354
|
-
e.texture("u_tint_mask", r + 2, this.mask), e.vec2("u_code_range", ...
|
|
1618
|
+
e.texture("u_tint_mask", r + 2, this.mask), e.vec2("u_code_range", ...s), e.vec2("u_value_range", ...o), e.float("u_scalar_transfer", a);
|
|
1355
1619
|
}
|
|
1356
1620
|
return !0;
|
|
1357
1621
|
}
|
|
@@ -1369,8 +1633,8 @@ class gt {
|
|
|
1369
1633
|
return i;
|
|
1370
1634
|
const r = this.source.frame(e).then((n) => {
|
|
1371
1635
|
if (!this.destroyed && this.pending.get(e) === r && !this.textures.has(e)) {
|
|
1372
|
-
const
|
|
1373
|
-
this.textures.set(e, this.uploadPreservingState(n)), this.uploadedFrames++, this.lastUploadDurationMs = performance.now() -
|
|
1636
|
+
const s = performance.now();
|
|
1637
|
+
this.textures.set(e, this.uploadPreservingState(n)), this.uploadedFrames++, this.lastUploadDurationMs = performance.now() - s, this.options.onReady?.();
|
|
1374
1638
|
}
|
|
1375
1639
|
}).catch((n) => {
|
|
1376
1640
|
throw !this.destroyed && this.pending.get(e) === r && !(n instanceof Error && n.name === "AbortError") && this.options.onError?.(n), n;
|
|
@@ -1387,15 +1651,15 @@ class gt {
|
|
|
1387
1651
|
i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,
|
|
1388
1652
|
i.UNPACK_COLORSPACE_CONVERSION_WEBGL,
|
|
1389
1653
|
i.UNPACK_ALIGNMENT
|
|
1390
|
-
],
|
|
1654
|
+
], s = n.map((o) => i.getParameter(o));
|
|
1391
1655
|
try {
|
|
1392
1656
|
return this.upload(e);
|
|
1393
1657
|
} finally {
|
|
1394
|
-
i.bindTexture(i.TEXTURE_2D, r), n.forEach((o,
|
|
1658
|
+
i.bindTexture(i.TEXTURE_2D, r), n.forEach((o, a) => i.pixelStorei(o, s[a]));
|
|
1395
1659
|
}
|
|
1396
1660
|
}
|
|
1397
1661
|
upload(e) {
|
|
1398
|
-
const i = this.gl, { width: r, height: n } = this.source,
|
|
1662
|
+
const i = this.gl, { width: r, height: n } = this.source, s = this.gridTexture();
|
|
1399
1663
|
return this.vector ? i.texImage2D(
|
|
1400
1664
|
i.TEXTURE_2D,
|
|
1401
1665
|
0,
|
|
@@ -1405,7 +1669,7 @@ class gt {
|
|
|
1405
1669
|
0,
|
|
1406
1670
|
i.RGBA,
|
|
1407
1671
|
i.FLOAT,
|
|
1408
|
-
|
|
1672
|
+
Ct(e)
|
|
1409
1673
|
) : (i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !1), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, i.NONE), i.texImage2D(
|
|
1410
1674
|
i.TEXTURE_2D,
|
|
1411
1675
|
0,
|
|
@@ -1413,7 +1677,7 @@ class gt {
|
|
|
1413
1677
|
i.RGBA,
|
|
1414
1678
|
i.UNSIGNED_BYTE,
|
|
1415
1679
|
e
|
|
1416
|
-
), this.mask ??= this.uploadMask()), i.bindTexture(i.TEXTURE_2D, null),
|
|
1680
|
+
), this.mask ??= this.uploadMask()), i.bindTexture(i.TEXTURE_2D, null), s;
|
|
1417
1681
|
}
|
|
1418
1682
|
/** The source's mask, loaded with its first frame, as an R8 texture. */
|
|
1419
1683
|
uploadMask() {
|
|
@@ -1458,7 +1722,7 @@ class gt {
|
|
|
1458
1722
|
}
|
|
1459
1723
|
}
|
|
1460
1724
|
}
|
|
1461
|
-
class
|
|
1725
|
+
class Ot {
|
|
1462
1726
|
constructor(e, i) {
|
|
1463
1727
|
this.onPlaying = i, this.time = 0, this.endFraction = 0, this.held = !1, this.playingValue = e;
|
|
1464
1728
|
}
|
|
@@ -1469,6 +1733,10 @@ class bt {
|
|
|
1469
1733
|
set ms(e) {
|
|
1470
1734
|
this.time = e, this.endFraction = 0;
|
|
1471
1735
|
}
|
|
1736
|
+
/** Progress through the final sample's held step, 0 elsewhere. */
|
|
1737
|
+
get holdFraction() {
|
|
1738
|
+
return this.endFraction;
|
|
1739
|
+
}
|
|
1472
1740
|
get playing() {
|
|
1473
1741
|
return this.playingValue;
|
|
1474
1742
|
}
|
|
@@ -1483,37 +1751,37 @@ class bt {
|
|
|
1483
1751
|
* Advance in step units, including irregular timelines. Returns true at a
|
|
1484
1752
|
* non-looping end. holdLastStep gives the final sample a full step's duration.
|
|
1485
1753
|
*/
|
|
1486
|
-
advance(e, i, r, n = [i[0], i[i.length - 1]],
|
|
1754
|
+
advance(e, i, r, n = [i[0], i[i.length - 1]], s = !1, o = !1) {
|
|
1487
1755
|
if (!this.advancing || !i.length)
|
|
1488
1756
|
return !1;
|
|
1489
|
-
const
|
|
1490
|
-
let
|
|
1491
|
-
const h = o ?
|
|
1492
|
-
return h &&
|
|
1757
|
+
const a = K(i, n[0]), d = K(i, n[1]), c = d + (o ? 1 : 0);
|
|
1758
|
+
let l = Math.max(a, K(i, this.ms) + this.endFraction) + Math.max(0, e) * r;
|
|
1759
|
+
const h = o ? l >= c : l > c;
|
|
1760
|
+
return h && s && c > a ? l = a + (l - a) % (c - a) : l = Math.min(c, l), this.time = wt(i, Math.min(d, l)), this.endFraction = Math.max(0, l - d), h && !s;
|
|
1493
1761
|
}
|
|
1494
1762
|
}
|
|
1495
|
-
function
|
|
1496
|
-
const e =
|
|
1763
|
+
function X(t) {
|
|
1764
|
+
const e = M(t);
|
|
1497
1765
|
return [e[0], e[e.length - 1]];
|
|
1498
1766
|
}
|
|
1499
|
-
function
|
|
1767
|
+
function Q(t, e) {
|
|
1500
1768
|
return e ? [Math.max(t[0], e[0]), Math.min(t[1], e[1])] : t;
|
|
1501
1769
|
}
|
|
1502
|
-
function
|
|
1770
|
+
function q([t, e], i) {
|
|
1503
1771
|
return Math.max(t, Math.min(e, i));
|
|
1504
1772
|
}
|
|
1505
|
-
class
|
|
1773
|
+
class Ri {
|
|
1506
1774
|
constructor(e, i, r) {
|
|
1507
1775
|
this.repaint = i, this.emit = r, this.field = null, this.manifest = null, this.gl = null, this.pendingField = null, this.standby = null, this.awaitingNext = !1, this.timeRange = null, this.lastTick = null, this.lastStepTime = null, this.seekId = 0, this.seeking = !1, this.failed = !1, this.exactTime = 0, this.endEmitted = !1, this.destroyed = !1, this.resumePlayback = !1, this.playOnReady = e.autoplay ?? !0, this.loop = e.loop ?? !0, this.playbackRate = e.playbackRate ?? 1, this.stepsPerSecond = e.stepsPerSecond;
|
|
1508
1776
|
const n = typeof e.time == "string" ? Date.parse(e.time) : e.time;
|
|
1509
|
-
this.requestedTime = n != null && Number.isFinite(n) ? n : null, this.requestedTimeRange = e.timeRange, this.clock = new
|
|
1777
|
+
this.requestedTime = n != null && Number.isFinite(n) ? n : null, this.requestedTimeRange = e.timeRange, this.clock = new Ot(
|
|
1510
1778
|
!1,
|
|
1511
|
-
(
|
|
1779
|
+
(s) => this.emit("playbackChange", s)
|
|
1512
1780
|
);
|
|
1513
1781
|
}
|
|
1514
1782
|
async load(e, i) {
|
|
1515
|
-
if (this.gl = e, this.manifest = i, this.timeRange =
|
|
1516
|
-
|
|
1783
|
+
if (this.gl = e, this.manifest = i, this.timeRange = Q(
|
|
1784
|
+
X(i),
|
|
1517
1785
|
this.requestedTimeRange
|
|
1518
1786
|
), this.timeRange[0] > this.timeRange[1])
|
|
1519
1787
|
throw new Error(
|
|
@@ -1522,10 +1790,25 @@ class ii {
|
|
|
1522
1790
|
this.pendingField = this.createField(i), await this.prepare(this.pendingField);
|
|
1523
1791
|
}
|
|
1524
1792
|
sample(e) {
|
|
1525
|
-
|
|
1793
|
+
if (this.tick(e), !this.field)
|
|
1794
|
+
return null;
|
|
1795
|
+
const i = this.pendingField || this.seeking ? this.field.currentPair : this.field.sample(
|
|
1526
1796
|
this.clock.advancing ? this.clock.ms : this.exactTime,
|
|
1527
1797
|
this.clock.advancing && !this.awaitingNext
|
|
1528
|
-
)
|
|
1798
|
+
);
|
|
1799
|
+
return this.handoff(i) ?? i;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Through the final step of a chunk followed by a decoded one, the last
|
|
1803
|
+
* frame blends into the next chunk's first, as steps do within a chunk:
|
|
1804
|
+
* the chunk swap then lands on the frame already shown.
|
|
1805
|
+
*/
|
|
1806
|
+
handoff(e) {
|
|
1807
|
+
const i = this.clock.holdFraction, r = this.pendingField ?? this.standby?.field, n = this.pendingField ? this.requestedTime : this.standby?.time;
|
|
1808
|
+
if (!e || i <= 0 || !r || n == null)
|
|
1809
|
+
return null;
|
|
1810
|
+
const s = r.texture(n);
|
|
1811
|
+
return s ? [e[0], s, Math.min(1, i)] : null;
|
|
1529
1812
|
}
|
|
1530
1813
|
get time() {
|
|
1531
1814
|
return this.clock.ms;
|
|
@@ -1557,12 +1840,12 @@ class ii {
|
|
|
1557
1840
|
const r = this.clock.advance(
|
|
1558
1841
|
i,
|
|
1559
1842
|
this.field.times,
|
|
1560
|
-
this.stepsPerSecond ?? this.playbackRate *
|
|
1843
|
+
this.stepsPerSecond ?? this.playbackRate * ue(this.field.manifest),
|
|
1561
1844
|
this.playbackRange(this.field),
|
|
1562
1845
|
this.loop,
|
|
1563
1846
|
!0
|
|
1564
|
-
), { index: n } =
|
|
1565
|
-
|
|
1847
|
+
), { index: n } = v(this.field.times, this.clock.ms), s = this.field.manifest.timeline.kind === "snapshot-loop" ? this.field.times[0] : q(this.timeRange, this.field.times[n]);
|
|
1848
|
+
s !== this.lastStepTime && (this.lastStepTime = s, this.emit("timeChange", s)), r ? this.reachEnd() : this.repaint();
|
|
1566
1849
|
}
|
|
1567
1850
|
setTime(e) {
|
|
1568
1851
|
const i = typeof e == "number" ? e : Date.parse(e);
|
|
@@ -1575,27 +1858,27 @@ class ii {
|
|
|
1575
1858
|
/** Load the requested step first; stale seeks and swaps cannot replace it. */
|
|
1576
1859
|
async prepare(e, i) {
|
|
1577
1860
|
this.failed = !1;
|
|
1578
|
-
const r = ++this.seekId, n = this.timeRange ??
|
|
1861
|
+
const r = ++this.seekId, n = this.timeRange ?? X(e.manifest), s = i ?? q(n, this.requestedTime ?? n[0]), o = v(e.times, s), a = Math.min(
|
|
1579
1862
|
e.times.length - 1,
|
|
1580
1863
|
o.index + (o.fraction > 0.5 ? 1 : 0)
|
|
1581
|
-
),
|
|
1582
|
-
this.seeking = !0, this.lastTick = null, e.focus(
|
|
1864
|
+
), d = e.times[a];
|
|
1865
|
+
this.seeking = !0, this.lastTick = null, e.focus(d);
|
|
1583
1866
|
try {
|
|
1584
|
-
await e.prime(
|
|
1585
|
-
} catch (
|
|
1867
|
+
await e.prime(d);
|
|
1868
|
+
} catch (l) {
|
|
1586
1869
|
if (r !== this.seekId)
|
|
1587
1870
|
return;
|
|
1588
|
-
throw
|
|
1871
|
+
throw l;
|
|
1589
1872
|
}
|
|
1590
1873
|
if (r !== this.seekId || this.destroyed)
|
|
1591
1874
|
return;
|
|
1592
1875
|
const c = this.pendingField === e;
|
|
1593
|
-
if (c && (this.field?.destroy(), this.field = e, this.pendingField = null, this.lastStepTime = null), this.exactTime =
|
|
1594
|
-
const
|
|
1876
|
+
if (c && (this.field?.destroy(), this.field = e, this.pendingField = null, this.lastStepTime = null), this.exactTime = d, this.clock.ms = q(this.playbackRange(e), d), e.sample(d, !1), this.seeking = !1, this.endEmitted = !1, this.repaint(), c) {
|
|
1877
|
+
const l = e.manifest;
|
|
1595
1878
|
if (this.emit("loaded", {
|
|
1596
|
-
min:
|
|
1597
|
-
max:
|
|
1598
|
-
unit:
|
|
1879
|
+
min: l.style.colorDomain[0],
|
|
1880
|
+
max: l.style.colorDomain[1],
|
|
1881
|
+
unit: l.style.unit ?? "",
|
|
1599
1882
|
time: new Date(this.clock.ms).toISOString()
|
|
1600
1883
|
}), this.emit("status", { phase: "ready", time: this.clock.ms }), this.playOnReady) {
|
|
1601
1884
|
this.playOnReady = !1;
|
|
@@ -1612,7 +1895,7 @@ class ii {
|
|
|
1612
1895
|
this.playOnReady ||= this.isPlaying(), this.pendingField?.destroy();
|
|
1613
1896
|
const n = this.standby;
|
|
1614
1897
|
return this.standby = null, n && n.field.manifest.media.url !== e.media.url && n.field.destroy(), this.pendingField = n?.field.manifest.media.url === e.media.url ? n.field : this.createField(e), this.awaitingNext = !1, this.manifest = e, this.requestedTimeRange = i.timeRange, this.timeRange = r, this.requestedTime = i.time ?? r[0], this.loop = i.loop ?? this.loop, this.playbackRate = i.playbackRate ?? this.playbackRate, this.stepsPerSecond = i.stepsPerSecond ?? this.stepsPerSecond, this.lastTick = null, this.prepare(this.pendingField).catch(
|
|
1615
|
-
(
|
|
1898
|
+
(s) => this.reportError(s)
|
|
1616
1899
|
), !0;
|
|
1617
1900
|
}
|
|
1618
1901
|
/** Decode the next chunk ahead of its swap, including its static mask. */
|
|
@@ -1620,11 +1903,11 @@ class ii {
|
|
|
1620
1903
|
const r = this.replacementTimeRange(e, i);
|
|
1621
1904
|
if (!r || !this.gl || e.media.url === this.manifest?.media.url)
|
|
1622
1905
|
return !1;
|
|
1623
|
-
const n =
|
|
1906
|
+
const n = q(r, i.time ?? r[0]);
|
|
1624
1907
|
this.standby?.field.manifest.media.url !== e.media.url && (this.discardStandby(), this.standby = { field: this.createField(e), time: n });
|
|
1625
|
-
const
|
|
1626
|
-
return
|
|
1627
|
-
this.standby ===
|
|
1908
|
+
const s = this.standby;
|
|
1909
|
+
return s.time = n, s.field.focus(n), s.field.prime(n).catch(() => {
|
|
1910
|
+
this.standby === s && this.discardStandby();
|
|
1628
1911
|
}), !0;
|
|
1629
1912
|
}
|
|
1630
1913
|
discardStandby() {
|
|
@@ -1635,8 +1918,8 @@ class ii {
|
|
|
1635
1918
|
const r = this.manifest;
|
|
1636
1919
|
if (!r || e.encoding.kind !== r.encoding.kind || e.media.width !== r.media.width || e.media.height !== r.media.height || e.mask.width !== r.mask.width || e.mask.height !== r.mask.height)
|
|
1637
1920
|
return null;
|
|
1638
|
-
const n =
|
|
1639
|
-
|
|
1921
|
+
const n = Q(
|
|
1922
|
+
X(e),
|
|
1640
1923
|
i.timeRange
|
|
1641
1924
|
);
|
|
1642
1925
|
return n[0] <= n[1] ? n : null;
|
|
@@ -1657,7 +1940,7 @@ class ii {
|
|
|
1657
1940
|
pause() {
|
|
1658
1941
|
const e = this.playOnReady && !this.clock.playing;
|
|
1659
1942
|
if (this.playOnReady = !1, this.awaitingNext = !1, this.clock.setPlaying(!1), this.field && !this.pendingField && !this.seeking && !this.endEmitted) {
|
|
1660
|
-
const { index: i } =
|
|
1943
|
+
const { index: i } = v(this.field.times, this.clock.ms);
|
|
1661
1944
|
this.prepare(this.field, this.field.times[i]).catch(
|
|
1662
1945
|
(r) => this.reportError(r)
|
|
1663
1946
|
);
|
|
@@ -1681,8 +1964,8 @@ class ii {
|
|
|
1681
1964
|
setTimeRange(e) {
|
|
1682
1965
|
if (!Number.isFinite(e[0]) || !Number.isFinite(e[1]) || e[0] > e[1])
|
|
1683
1966
|
throw new Error("Invalid GeoVideo time range");
|
|
1684
|
-
const i =
|
|
1685
|
-
this.manifest ?
|
|
1967
|
+
const i = Q(
|
|
1968
|
+
this.manifest ? X(this.manifest) : e,
|
|
1686
1969
|
e
|
|
1687
1970
|
);
|
|
1688
1971
|
if (i[0] > i[1])
|
|
@@ -1700,7 +1983,7 @@ class ii {
|
|
|
1700
1983
|
];
|
|
1701
1984
|
}
|
|
1702
1985
|
createField(e) {
|
|
1703
|
-
const i = new
|
|
1986
|
+
const i = new Vt(this.gl, e, {
|
|
1704
1987
|
repeatLongitude: !1,
|
|
1705
1988
|
animateSnapshot: !0,
|
|
1706
1989
|
onError: (r) => {
|
|
@@ -1715,7 +1998,7 @@ class ii {
|
|
|
1715
1998
|
i.name === "AbortError" || this.destroyed || (this.playOnReady = !1, this.awaitingNext = !1, this.failed = !0, this.seeking = !0, this.clock.setPlaying(!1), this.emit("status", { phase: "error", error: i }), this.emit("error", i));
|
|
1716
1999
|
}
|
|
1717
2000
|
}
|
|
1718
|
-
function
|
|
2001
|
+
function Z(t) {
|
|
1719
2002
|
const { start: e, end: i } = t.temporal ?? {};
|
|
1720
2003
|
return {
|
|
1721
2004
|
source: t,
|
|
@@ -1723,70 +2006,70 @@ function I(t) {
|
|
|
1723
2006
|
end: Date.parse(i ?? e ?? "")
|
|
1724
2007
|
};
|
|
1725
2008
|
}
|
|
1726
|
-
function
|
|
1727
|
-
const r = t.filter((
|
|
2009
|
+
function xi(t, e, i = {}) {
|
|
2010
|
+
const r = t.filter((s) => s.id === e.id && s.temporal?.start != null).map(Z), n = Ft(
|
|
1728
2011
|
r,
|
|
1729
2012
|
Date.parse(e.temporal?.end ?? ""),
|
|
1730
2013
|
i
|
|
1731
2014
|
);
|
|
1732
2015
|
return n ? { source: n.chunk.source, time: n.time } : null;
|
|
1733
2016
|
}
|
|
1734
|
-
function
|
|
1735
|
-
return
|
|
2017
|
+
function vi(t, e) {
|
|
2018
|
+
return St(Z(t), e.map(Z))?.source ?? null;
|
|
1736
2019
|
}
|
|
1737
|
-
const
|
|
1738
|
-
function
|
|
2020
|
+
const Bt = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;
|
|
2021
|
+
function Xt(t) {
|
|
1739
2022
|
return t instanceof Date ? t.getTime() : typeof t == "number" ? t : new Date(t).getTime();
|
|
1740
2023
|
}
|
|
1741
|
-
function
|
|
1742
|
-
const i =
|
|
2024
|
+
function de(t, e) {
|
|
2025
|
+
const i = Xt(t);
|
|
1743
2026
|
if (!Number.isFinite(i))
|
|
1744
2027
|
throw new Error(`Invalid ${e}`);
|
|
1745
2028
|
return i;
|
|
1746
2029
|
}
|
|
1747
|
-
function
|
|
1748
|
-
const i = e.match(
|
|
2030
|
+
function Ee(t, e) {
|
|
2031
|
+
const i = e.match(Bt);
|
|
1749
2032
|
if (!i)
|
|
1750
2033
|
throw new Error(`Invalid trailing time duration: ${e}`);
|
|
1751
|
-
const r = i.slice(1).map((
|
|
1752
|
-
if (!r.some((
|
|
2034
|
+
const r = i.slice(1).map((A) => Number(A ?? 0));
|
|
2035
|
+
if (!r.some((A) => A > 0))
|
|
1753
2036
|
throw new Error("Trailing time duration must be positive");
|
|
1754
|
-
const [n,
|
|
2037
|
+
const [n, s, o, a, d, c, l] = r, h = new Date(t), p = h.getUTCFullYear() * 12 + h.getUTCMonth() - n * 12 - s, m = Math.floor(p / 12), E = (p % 12 + 12) % 12, w = new Date(Date.UTC(m, E + 1, 0)).getUTCDate();
|
|
1755
2038
|
return Date.UTC(
|
|
1756
|
-
u,
|
|
1757
2039
|
m,
|
|
1758
|
-
|
|
2040
|
+
E,
|
|
2041
|
+
Math.min(h.getUTCDate(), w),
|
|
1759
2042
|
h.getUTCHours(),
|
|
1760
2043
|
h.getUTCMinutes(),
|
|
1761
2044
|
h.getUTCSeconds(),
|
|
1762
2045
|
h.getUTCMilliseconds()
|
|
1763
|
-
) - (((o * 7 +
|
|
2046
|
+
) - (((o * 7 + a) * 24 + d) * 60 + c) * 6e4 - l * 1e3;
|
|
1764
2047
|
}
|
|
1765
|
-
function
|
|
2048
|
+
function ki(t, [e, i]) {
|
|
1766
2049
|
let r = e, n = i;
|
|
1767
|
-
if (typeof t.trailing == "string" ? r =
|
|
2050
|
+
if (typeof t.trailing == "string" ? r = Ee(i, t.trailing) : (t.start != null && (r = de(t.start, "time range start")), t.end != null && (n = de(t.end, "time range end"))), r > n)
|
|
1768
2051
|
throw new Error("Time range start must not follow its end");
|
|
1769
2052
|
return [Math.max(e, r), Math.min(i, n)];
|
|
1770
2053
|
}
|
|
1771
|
-
const
|
|
1772
|
-
function
|
|
1773
|
-
if (!
|
|
2054
|
+
const qt = (t) => typeof t == "object" && t !== null && !Array.isArray(t);
|
|
2055
|
+
function Ai(t, e) {
|
|
2056
|
+
if (!qt(t))
|
|
1774
2057
|
throw new Error(`${e} must be an object`);
|
|
1775
|
-
for (const
|
|
1776
|
-
if (
|
|
1777
|
-
throw new Error(`${e}.${
|
|
2058
|
+
for (const s of Object.keys(t))
|
|
2059
|
+
if (s !== "start" && s !== "end" && s !== "trailing")
|
|
2060
|
+
throw new Error(`${e}.${s} is not a time range key`);
|
|
1778
2061
|
if (t.trailing !== void 0) {
|
|
1779
2062
|
if (t.start !== void 0 || t.end !== void 0)
|
|
1780
2063
|
throw new Error(`${e}.trailing excludes start and end`);
|
|
1781
2064
|
if (typeof t.trailing != "string")
|
|
1782
2065
|
throw new Error(`${e}.trailing must be an ISO 8601 duration`);
|
|
1783
|
-
return
|
|
2066
|
+
return Ee(0, t.trailing), { trailing: t.trailing };
|
|
1784
2067
|
}
|
|
1785
|
-
const i = (
|
|
1786
|
-
const o = t[
|
|
2068
|
+
const i = (s) => {
|
|
2069
|
+
const o = t[s];
|
|
1787
2070
|
if (o !== void 0) {
|
|
1788
2071
|
if (typeof o != "string" || !Number.isFinite(Date.parse(o)))
|
|
1789
|
-
throw new Error(`${e}.${
|
|
2072
|
+
throw new Error(`${e}.${s} is not a date`);
|
|
1790
2073
|
return o;
|
|
1791
2074
|
}
|
|
1792
2075
|
}, r = i("start"), n = i("end");
|
|
@@ -1797,37 +2080,37 @@ function si(t, e) {
|
|
|
1797
2080
|
...n !== void 0 && { end: n }
|
|
1798
2081
|
};
|
|
1799
2082
|
}
|
|
1800
|
-
function
|
|
2083
|
+
function Fi(t) {
|
|
1801
2084
|
return t.type === "geovideo" && typeof t.indexUrl == "string";
|
|
1802
2085
|
}
|
|
1803
|
-
function
|
|
2086
|
+
function Si(t, e) {
|
|
1804
2087
|
return t.id === e.id && (t.type !== "geovideo" || e.type !== "geovideo" || t.manifestUrl === e.manifestUrl);
|
|
1805
2088
|
}
|
|
1806
|
-
function
|
|
2089
|
+
function le(t) {
|
|
1807
2090
|
return typeof t == "string" && Number.isFinite(Date.parse(t));
|
|
1808
2091
|
}
|
|
1809
|
-
function
|
|
2092
|
+
function $t(t) {
|
|
1810
2093
|
const e = t;
|
|
1811
2094
|
if (!e || e.schemaVersion !== 1 || e.type !== "geovideo-index" || !Array.isArray(e.chunks))
|
|
1812
2095
|
throw new Error("Unsupported GeoVideo index");
|
|
1813
2096
|
for (const i of e.chunks)
|
|
1814
|
-
if (!
|
|
2097
|
+
if (!le(i?.start) || !le(i.end) || Date.parse(i.end) < Date.parse(i.start) || typeof i.manifestUrl != "string")
|
|
1815
2098
|
throw new Error("Invalid GeoVideo index chunk");
|
|
1816
2099
|
return e;
|
|
1817
2100
|
}
|
|
1818
|
-
async function
|
|
2101
|
+
async function Ui(t, e) {
|
|
1819
2102
|
const i = await fetch(t, { signal: e });
|
|
1820
2103
|
if (!i.ok)
|
|
1821
2104
|
throw new Error(
|
|
1822
2105
|
`GeoVideo index request failed (${i.status}): ${t}`
|
|
1823
2106
|
);
|
|
1824
|
-
return
|
|
2107
|
+
return $t(await i.json());
|
|
1825
2108
|
}
|
|
1826
|
-
function
|
|
2109
|
+
function Wt(t) {
|
|
1827
2110
|
return typeof document < "u" ? new URL(t, document.baseURI).href : t;
|
|
1828
2111
|
}
|
|
1829
|
-
function
|
|
1830
|
-
const i =
|
|
2112
|
+
function Ht(t, e) {
|
|
2113
|
+
const i = Wt(e);
|
|
1831
2114
|
return t.chunks.map((r) => ({
|
|
1832
2115
|
key: r.key,
|
|
1833
2116
|
manifestUrl: new URL(r.manifestUrl, i).href,
|
|
@@ -1837,17 +2120,17 @@ function vt(t, e) {
|
|
|
1837
2120
|
...r.provisional ? { provisional: !0 } : {}
|
|
1838
2121
|
}));
|
|
1839
2122
|
}
|
|
1840
|
-
function
|
|
2123
|
+
function zt(t, e, i) {
|
|
1841
2124
|
if (e.sourceId !== t.id || e.catalogEntryId !== i.id)
|
|
1842
2125
|
throw new Error(
|
|
1843
2126
|
`GeoVideo index identity does not match catalog entry/source: ${t.id}`
|
|
1844
2127
|
);
|
|
1845
2128
|
}
|
|
1846
|
-
function
|
|
1847
|
-
|
|
1848
|
-
const r =
|
|
2129
|
+
function Mi(t, e, i) {
|
|
2130
|
+
zt(t, e, i);
|
|
2131
|
+
const r = Ht(e, t.indexUrl);
|
|
1849
2132
|
return e.chunks.map(
|
|
1850
|
-
(n,
|
|
2133
|
+
(n, s) => ({
|
|
1851
2134
|
id: t.id,
|
|
1852
2135
|
type: "geovideo",
|
|
1853
2136
|
title: t.title,
|
|
@@ -1858,75 +2141,76 @@ function di(t, e, i) {
|
|
|
1858
2141
|
start: n.start,
|
|
1859
2142
|
end: n.end
|
|
1860
2143
|
},
|
|
1861
|
-
manifestUrl: r[
|
|
2144
|
+
manifestUrl: r[s].manifestUrl
|
|
1862
2145
|
})
|
|
1863
2146
|
);
|
|
1864
2147
|
}
|
|
1865
2148
|
export {
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2149
|
+
ne as $,
|
|
2150
|
+
ue as A,
|
|
2151
|
+
ci as B,
|
|
2152
|
+
Fi as C,
|
|
2153
|
+
xi as D,
|
|
2154
|
+
Ui as E,
|
|
2155
|
+
Mi as F,
|
|
2156
|
+
Ti as G,
|
|
2157
|
+
ki as H,
|
|
2158
|
+
yi as I,
|
|
2159
|
+
oe as J,
|
|
2160
|
+
ui as K,
|
|
2161
|
+
mi as L,
|
|
2162
|
+
Ei as M,
|
|
2163
|
+
_i as N,
|
|
2164
|
+
Ot as O,
|
|
2165
|
+
xt as P,
|
|
2166
|
+
Vt as Q,
|
|
2167
|
+
me as R,
|
|
2168
|
+
bt as S,
|
|
2169
|
+
li as T,
|
|
2170
|
+
At as U,
|
|
2171
|
+
fi as V,
|
|
2172
|
+
pi as W,
|
|
2173
|
+
hi as X,
|
|
2174
|
+
Be as Y,
|
|
2175
|
+
zt as Z,
|
|
2176
|
+
pe as _,
|
|
2177
|
+
ri as a,
|
|
2178
|
+
it as a0,
|
|
2179
|
+
Ut as a1,
|
|
2180
|
+
Ht as a2,
|
|
2181
|
+
Ft as a3,
|
|
2182
|
+
vi as a4,
|
|
2183
|
+
St as a5,
|
|
2184
|
+
Ai as a6,
|
|
2185
|
+
wt as a7,
|
|
2186
|
+
Ee as a8,
|
|
2187
|
+
v as a9,
|
|
2188
|
+
K as aa,
|
|
2189
|
+
$t as ab,
|
|
2190
|
+
Ct as ac,
|
|
2191
|
+
ni as b,
|
|
2192
|
+
Kt as c,
|
|
2193
|
+
Jt as d,
|
|
2194
|
+
ei as e,
|
|
2195
|
+
ii as f,
|
|
2196
|
+
si as g,
|
|
2197
|
+
Qt as h,
|
|
2198
|
+
ti as i,
|
|
2199
|
+
gi as j,
|
|
2200
|
+
Zt as k,
|
|
2201
|
+
oi as l,
|
|
2202
|
+
Ri as m,
|
|
2203
|
+
di as n,
|
|
2204
|
+
ut as o,
|
|
2205
|
+
Tt as p,
|
|
2206
|
+
ze as q,
|
|
2207
|
+
Ke as r,
|
|
2208
|
+
ai as s,
|
|
2209
|
+
ft as t,
|
|
2210
|
+
jt as u,
|
|
2211
|
+
bi as v,
|
|
2212
|
+
de as w,
|
|
2213
|
+
M as x,
|
|
2214
|
+
Si as y,
|
|
2215
|
+
wi as z
|
|
1932
2216
|
};
|