expressive-charts 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +7 -7
- package/dist/drawing-OmQV-0BB.d.ts +1 -2
- package/dist/effect-HCWnmB72.d.ts +1 -2
- package/dist/expressive-charts.global.js +6 -6
- package/dist/expressive-charts.global.js.map +1 -1
- package/dist/icons/sport.d.cts +2 -3
- package/dist/icons/sport.d.ts +1 -2
- package/dist/index-CmnxlWkB.d.cts +752 -0
- package/dist/index.cjs +139 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -290
- package/dist/index.d.ts +33 -8
- package/dist/index.js +139 -38
- package/dist/index.js.map +1 -1
- package/dist/runner-C87v9F_y.d.cts +1 -0
- package/dist/testing.d.cts +3 -4
- package/dist/testing.d.ts +1 -2
- package/package.json +8 -6
- package/dist/drawing-OmQV-0BB.d.cts +0 -220
- package/dist/effect-DYCLY_6e.d.cts +0 -256
package/dist/index.js
CHANGED
|
@@ -9363,6 +9363,7 @@ function expressive$1(target, options, env) {
|
|
|
9363
9363
|
return true;
|
|
9364
9364
|
}
|
|
9365
9365
|
};
|
|
9366
|
+
const refreshed = /* @__PURE__ */ new Set();
|
|
9366
9367
|
insides.set(link, {
|
|
9367
9368
|
root: () => root,
|
|
9368
9369
|
ancestor: () => ancestor,
|
|
@@ -9370,7 +9371,8 @@ function expressive$1(target, options, env) {
|
|
|
9370
9371
|
keyOf: (element) => ownerOf(element)?.record.key,
|
|
9371
9372
|
colorOf: (key) => records.get(key)?.mark.parts[0]?.colors?.color,
|
|
9372
9373
|
moveTabStop: (key) => keyboard?.moveTabStop(key) ?? false,
|
|
9373
|
-
edits
|
|
9374
|
+
edits,
|
|
9375
|
+
refreshed
|
|
9374
9376
|
});
|
|
9375
9377
|
return linkable(link, {
|
|
9376
9378
|
refresh(next) {
|
|
@@ -9409,6 +9411,7 @@ function expressive$1(target, options, env) {
|
|
|
9409
9411
|
for (const record of following) runner.change(record.mark.geometry, record.mark.data);
|
|
9410
9412
|
runner.settle();
|
|
9411
9413
|
keyboard?.sync();
|
|
9414
|
+
for (const listener of refreshed) listener();
|
|
9412
9415
|
exited.then(() => {
|
|
9413
9416
|
for (const record of diff.exiting) if (leaving.get(record.key) === record) leaving.delete(record.key);
|
|
9414
9417
|
});
|
|
@@ -9636,6 +9639,7 @@ function hostView(attachment, options = {}) {
|
|
|
9636
9639
|
const svg = () => inside.root();
|
|
9637
9640
|
let given;
|
|
9638
9641
|
let hidden = [];
|
|
9642
|
+
let classed;
|
|
9639
9643
|
function read() {
|
|
9640
9644
|
if (!options.labels) return [];
|
|
9641
9645
|
const keys = new Set(attachment.marks().map((mark) => mark.key));
|
|
@@ -9675,6 +9679,23 @@ function hostView(attachment, options = {}) {
|
|
|
9675
9679
|
element: text
|
|
9676
9680
|
};
|
|
9677
9681
|
}
|
|
9682
|
+
const hide = (on) => {
|
|
9683
|
+
const root = on ? svg() : void 0;
|
|
9684
|
+
given = on ? read() : void 0;
|
|
9685
|
+
const now = new Set(given ? [
|
|
9686
|
+
...inside.elements(),
|
|
9687
|
+
...given.map((label) => label.element),
|
|
9688
|
+
...hidden.filter((element) => root?.contains(element))
|
|
9689
|
+
] : []);
|
|
9690
|
+
for (const element of hidden) if (!now.has(element)) edits.style(element, "visibility", void 0);
|
|
9691
|
+
hidden = [...now];
|
|
9692
|
+
for (const element of hidden) edits.style(element, "visibility", "hidden");
|
|
9693
|
+
if (classed !== root) {
|
|
9694
|
+
if (classed) edits.toggleClass(classed, "ec-morphing", false);
|
|
9695
|
+
if (root) edits.toggleClass(root, "ec-morphing", true);
|
|
9696
|
+
classed = root;
|
|
9697
|
+
}
|
|
9698
|
+
};
|
|
9678
9699
|
const view = {
|
|
9679
9700
|
get element() {
|
|
9680
9701
|
return svg();
|
|
@@ -9689,7 +9710,7 @@ function hostView(attachment, options = {}) {
|
|
|
9689
9710
|
focus: (key) => attachment.focus(key),
|
|
9690
9711
|
leave: () => attachment.leave(),
|
|
9691
9712
|
destroy() {
|
|
9692
|
-
given = void 0;
|
|
9713
|
+
given = classed = void 0;
|
|
9693
9714
|
hidden = [];
|
|
9694
9715
|
attachment.destroy();
|
|
9695
9716
|
},
|
|
@@ -9704,14 +9725,11 @@ function hostView(attachment, options = {}) {
|
|
|
9704
9725
|
},
|
|
9705
9726
|
keyOf: (element) => inside.keyOf(element),
|
|
9706
9727
|
moveTabStop: (key) => inside.moveTabStop(key),
|
|
9707
|
-
morphing
|
|
9708
|
-
for (const element of hidden) edits.style(element, "visibility", void 0);
|
|
9709
|
-
given = on ? read() : void 0;
|
|
9710
|
-
hidden = given ? [...inside.elements(), ...given.map((label) => label.element)] : [];
|
|
9711
|
-
for (const element of hidden) edits.style(element, "visibility", "hidden");
|
|
9712
|
-
edits.toggleClass(svg(), "ec-morphing", on);
|
|
9713
|
-
}
|
|
9728
|
+
morphing: hide
|
|
9714
9729
|
};
|
|
9730
|
+
inside.refreshed.add(() => {
|
|
9731
|
+
if (given) hide(true);
|
|
9732
|
+
});
|
|
9715
9733
|
return linkable(port, view);
|
|
9716
9734
|
}
|
|
9717
9735
|
// src/charts/adapter/vega.ts
|
|
@@ -10267,6 +10285,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10267
10285
|
}) : void 0;
|
|
10268
10286
|
observer?.observe(wrapper);
|
|
10269
10287
|
const view = (name) => views.get(name);
|
|
10288
|
+
const missing = (name, what = "") => /* @__PURE__ */ new TypeError(`chartSwitch: there's no view ${JSON.stringify(name)}${what}. The views are ${names.map((n) => JSON.stringify(n)).join(", ")}.`);
|
|
10270
10289
|
function focused() {
|
|
10271
10290
|
return wrapper.getRootNode().activeElement ?? null;
|
|
10272
10291
|
}
|
|
@@ -10302,7 +10321,10 @@ function chartSwitch$1(target, options, env) {
|
|
|
10302
10321
|
function reached() {
|
|
10303
10322
|
if (held) linked?.shown();
|
|
10304
10323
|
}
|
|
10305
|
-
function
|
|
10324
|
+
function jump(from, to, via, carried) {
|
|
10325
|
+
return via === void 0 || !motion.staged || via === from.name || via === to.name ? start(from, to, carried) : start(from, view(via), carried, to);
|
|
10326
|
+
}
|
|
10327
|
+
function start(from, to, carried, next) {
|
|
10306
10328
|
const memory = carried ? carried.focus : readFocus(from);
|
|
10307
10329
|
const waiting = [];
|
|
10308
10330
|
opening = waiting;
|
|
@@ -10311,16 +10333,17 @@ function chartSwitch$1(target, options, env) {
|
|
|
10311
10333
|
} finally {
|
|
10312
10334
|
opening = void 0;
|
|
10313
10335
|
}
|
|
10314
|
-
const done = destroyed ? Promise.resolve() : begin(from, to, memory);
|
|
10336
|
+
const done = destroyed ? Promise.resolve() : begin(from, to, memory, next);
|
|
10315
10337
|
for (const run of waiting) run();
|
|
10316
10338
|
return done;
|
|
10317
10339
|
}
|
|
10318
|
-
function begin(from, to, memory) {
|
|
10319
|
-
current = to.name;
|
|
10340
|
+
function begin(from, to, memory, next, carried) {
|
|
10341
|
+
current = (next ?? to).name;
|
|
10320
10342
|
if (motion.mode === "off") {
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10343
|
+
const end = view(current);
|
|
10344
|
+
for (const each of views.values()) setActive(each.container, each === end);
|
|
10345
|
+
restoreFocus(end, memory);
|
|
10346
|
+
say(end);
|
|
10324
10347
|
reached();
|
|
10325
10348
|
return Promise.resolve();
|
|
10326
10349
|
}
|
|
@@ -10332,7 +10355,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10332
10355
|
each.chart.element.classList.add("ec-morphing");
|
|
10333
10356
|
}
|
|
10334
10357
|
const { pairs, surface, scene } = prepare(from, to);
|
|
10335
|
-
const { done, settle } = deferred();
|
|
10358
|
+
const { done, settle } = carried ?? deferred();
|
|
10336
10359
|
const session = {
|
|
10337
10360
|
a: from,
|
|
10338
10361
|
b: to,
|
|
@@ -10345,6 +10368,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10345
10368
|
surface,
|
|
10346
10369
|
scene,
|
|
10347
10370
|
focus: memory,
|
|
10371
|
+
next,
|
|
10348
10372
|
progress: 0,
|
|
10349
10373
|
transition: void 0,
|
|
10350
10374
|
driver: void 0,
|
|
@@ -10359,7 +10383,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10359
10383
|
function play(session, begin) {
|
|
10360
10384
|
const run = ++session.run;
|
|
10361
10385
|
if (begin >= 1) {
|
|
10362
|
-
|
|
10386
|
+
arrive(session);
|
|
10363
10387
|
return;
|
|
10364
10388
|
}
|
|
10365
10389
|
const at = (progress) => {
|
|
@@ -10381,7 +10405,19 @@ function chartSwitch$1(target, options, env) {
|
|
|
10381
10405
|
});
|
|
10382
10406
|
started.release();
|
|
10383
10407
|
Promise.all([session.driver.finished, session.transition.finished]).then(([result]) => {
|
|
10384
|
-
if (active === session && session.run === run && result === "done")
|
|
10408
|
+
if (active === session && session.run === run && result === "done") arrive(session);
|
|
10409
|
+
});
|
|
10410
|
+
}
|
|
10411
|
+
function arrive(session) {
|
|
10412
|
+
const next = session.forward ? session.next : void 0;
|
|
10413
|
+
if (!next || motion.mode === "off") return land(session, true);
|
|
10414
|
+
const { done, settle } = session;
|
|
10415
|
+
session.next = void 0;
|
|
10416
|
+
session.settle = () => {};
|
|
10417
|
+
land(session, false);
|
|
10418
|
+
begin(session.b, next, session.focus, void 0, {
|
|
10419
|
+
done,
|
|
10420
|
+
settle
|
|
10385
10421
|
});
|
|
10386
10422
|
}
|
|
10387
10423
|
function reverse(session) {
|
|
@@ -10401,7 +10437,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
10401
10437
|
session.driver?.cancel();
|
|
10402
10438
|
session.transition?.clear();
|
|
10403
10439
|
session.scene.clear();
|
|
10404
|
-
const to = session.forward ? session.b : session.a;
|
|
10440
|
+
const to = session.forward ? session.next ?? session.b : session.a;
|
|
10405
10441
|
for (const each of [session.a, session.b]) {
|
|
10406
10442
|
each.chart.element.classList.remove("ec-morphing");
|
|
10407
10443
|
each.chart.morphing?.(false);
|
|
@@ -10542,23 +10578,35 @@ function chartSwitch$1(target, options, env) {
|
|
|
10542
10578
|
get current() {
|
|
10543
10579
|
return current;
|
|
10544
10580
|
},
|
|
10545
|
-
show(name) {
|
|
10546
|
-
if (!views.has(name)) return Promise.reject(
|
|
10581
|
+
show(name, options) {
|
|
10582
|
+
if (!views.has(name)) return Promise.reject(missing(name));
|
|
10583
|
+
const via = options?.via;
|
|
10584
|
+
if (via !== void 0 && !views.has(via)) return Promise.reject(missing(via, " to go via"));
|
|
10547
10585
|
if (destroyed) return Promise.resolve();
|
|
10548
10586
|
const waiting = opening;
|
|
10549
|
-
if (waiting) return new Promise((resolve) => waiting.push(() => resolve(api.show(name))));
|
|
10587
|
+
if (waiting) return new Promise((resolve) => waiting.push(() => resolve(api.show(name, options))));
|
|
10550
10588
|
const session = active;
|
|
10551
|
-
if (!session) return name === current ? Promise.resolve() :
|
|
10589
|
+
if (!session) return name === current ? Promise.resolve() : jump(view(current), view(name), via);
|
|
10552
10590
|
const heading = session.forward ? session.b : session.a;
|
|
10553
10591
|
const leaving = session.forward ? session.a : session.b;
|
|
10554
|
-
|
|
10592
|
+
const next = session.next;
|
|
10593
|
+
if (name === (next ?? heading).name) return session.done;
|
|
10594
|
+
if (next) {
|
|
10595
|
+
session.next = void 0;
|
|
10596
|
+
if (name === heading.name) {
|
|
10597
|
+
current = name;
|
|
10598
|
+
session.settle();
|
|
10599
|
+
({done: session.done, settle: session.settle} = deferred());
|
|
10600
|
+
return session.done;
|
|
10601
|
+
}
|
|
10602
|
+
}
|
|
10555
10603
|
if (name === leaving.name) return reverse(session);
|
|
10556
10604
|
land(session, false);
|
|
10557
|
-
return
|
|
10605
|
+
return jump(heading, view(name), via, { focus: session.focus });
|
|
10558
10606
|
},
|
|
10559
10607
|
chart(name) {
|
|
10560
10608
|
const found = views.get(name);
|
|
10561
|
-
if (!found) throw
|
|
10609
|
+
if (!found) throw missing(name);
|
|
10562
10610
|
return found.chart;
|
|
10563
10611
|
},
|
|
10564
10612
|
on(type, listener) {
|
|
@@ -11984,10 +12032,11 @@ function drawing(from, to, layer, points, align) {
|
|
|
11984
12032
|
if (closed !== to.outline.closed) return crossfade(from, to, layer);
|
|
11985
12033
|
const across = closed ? void 0 : acrossX(from, to, points);
|
|
11986
12034
|
if (across) return piecewise(from, to, layer, across.stops, across.kinds);
|
|
11987
|
-
const
|
|
11988
|
-
const
|
|
12035
|
+
const bands = closed ? bandsAcross(from, to, points) : void 0;
|
|
12036
|
+
const a = bands?.from ?? from.outline.sample(points);
|
|
12037
|
+
const b = bands?.to ?? to.outline.sample(points);
|
|
11989
12038
|
if (!closed) return from.gaps?.length || to.gaps?.length ? gapped(from, to, layer, a, b) : stroke(from, to, layer, a, b);
|
|
11990
|
-
const [shiftA, shiftB] = align === "drop" ? turn(from, to, points) : [0, 0];
|
|
12039
|
+
const [shiftA, shiftB] = !bands && align === "drop" ? turn(from, to, points) : [0, 0];
|
|
11991
12040
|
const holes = holePairs(from, to, a, b, [shiftA, shiftB], points / 4);
|
|
11992
12041
|
let path;
|
|
11993
12042
|
return (p) => {
|
|
@@ -12077,6 +12126,9 @@ function acrossX(from, to, points) {
|
|
|
12077
12126
|
const a = courseOf(from);
|
|
12078
12127
|
const b = a && courseOf(to);
|
|
12079
12128
|
if (!a || !b || a.way !== b.way) return void 0;
|
|
12129
|
+
return byX(a, b, points);
|
|
12130
|
+
}
|
|
12131
|
+
function byX(a, b, points) {
|
|
12080
12132
|
const all = [
|
|
12081
12133
|
...Array.from({ length: points }, (_, i) => [i / (points - 1), 0]),
|
|
12082
12134
|
...corners(a).map((s) => [s, 1]),
|
|
@@ -12132,7 +12184,9 @@ function courseOf(mark) {
|
|
|
12132
12184
|
before.push(points.length - 1);
|
|
12133
12185
|
from = end;
|
|
12134
12186
|
}
|
|
12135
|
-
|
|
12187
|
+
return !stretch(1) || next < subpaths.length || points.length < 2 ? void 0 : courseThrough(points, before);
|
|
12188
|
+
}
|
|
12189
|
+
function courseThrough(points, before = []) {
|
|
12136
12190
|
const x0 = points[0].x;
|
|
12137
12191
|
const span = points[points.length - 1].x - x0;
|
|
12138
12192
|
const way = Math.sign(span);
|
|
@@ -12173,6 +12227,48 @@ function placed(course, shares) {
|
|
|
12173
12227
|
return mixed(points[i], points[i + 1], width > 0 ? Math.min(1, Math.max(0, (s - at[i]) / width)) : 0);
|
|
12174
12228
|
});
|
|
12175
12229
|
}
|
|
12230
|
+
function bandsAcross(from, to, points) {
|
|
12231
|
+
const a = bandOf(from.outline);
|
|
12232
|
+
const b = a && bandOf(to.outline);
|
|
12233
|
+
if (!a || !b || Math.abs(a.left - b.left) > SAME_X || Math.abs(a.right - b.right) > SAME_X) return void 0;
|
|
12234
|
+
const upper = byX(a.upper, b.upper, points);
|
|
12235
|
+
const lower = byX(a.lower, b.lower, points);
|
|
12236
|
+
if (!upper || !lower) return void 0;
|
|
12237
|
+
const stops = [...upper.stops, ...lower.stops];
|
|
12238
|
+
return {
|
|
12239
|
+
from: stops.map((stop) => stop.from),
|
|
12240
|
+
to: stops.map((stop) => stop.to)
|
|
12241
|
+
};
|
|
12242
|
+
}
|
|
12243
|
+
function bandOf(outline) {
|
|
12244
|
+
const loops = loopsOf(outline);
|
|
12245
|
+
const ring = [];
|
|
12246
|
+
for (const segment of loops[outsideOf(loops)] ?? []) {
|
|
12247
|
+
if (segment.kind !== "line") return void 0;
|
|
12248
|
+
ring.push(segment.to);
|
|
12249
|
+
}
|
|
12250
|
+
if (areaOf(ring) < 0) ring.reverse();
|
|
12251
|
+
const left = ring.reduce((x, point) => Math.min(x, point.x), Infinity);
|
|
12252
|
+
const right = ring.reduce((x, point) => Math.max(x, point.x), -Infinity);
|
|
12253
|
+
if (!(right - left > 2 * SAME_X)) return void 0;
|
|
12254
|
+
const atLeft = (point) => point.x - left <= SAME_X;
|
|
12255
|
+
const atRight = (point) => right - point.x <= SAME_X;
|
|
12256
|
+
const s = ring.findIndex((point, i) => atLeft(point) && !atLeft(ring[(i + 1) % ring.length]));
|
|
12257
|
+
const walk = [...ring.slice(s), ...ring.slice(0, s + 1)];
|
|
12258
|
+
const topRight = walk.findIndex(atRight);
|
|
12259
|
+
let baseRight = topRight;
|
|
12260
|
+
while (atRight(walk[baseRight + 1])) baseRight++;
|
|
12261
|
+
const baseLeft = walk.findIndex((point, i) => i > baseRight && atLeft(point));
|
|
12262
|
+
if (walk.slice(baseLeft).some((point) => !atLeft(point))) return void 0;
|
|
12263
|
+
const upper = courseThrough(walk.slice(0, topRight + 1));
|
|
12264
|
+
const lower = courseThrough(walk.slice(baseRight, baseLeft + 1));
|
|
12265
|
+
return upper && lower && upper.points.length > 2 && lower.points.length > 2 ? {
|
|
12266
|
+
upper,
|
|
12267
|
+
lower,
|
|
12268
|
+
left,
|
|
12269
|
+
right
|
|
12270
|
+
} : void 0;
|
|
12271
|
+
}
|
|
12176
12272
|
function inside(gaps) {
|
|
12177
12273
|
let k = 0;
|
|
12178
12274
|
return (s) => {
|
|
@@ -12298,13 +12394,9 @@ function placeIn(point, own, other) {
|
|
|
12298
12394
|
};
|
|
12299
12395
|
}
|
|
12300
12396
|
function holesOf(outline, count) {
|
|
12301
|
-
const loops =
|
|
12397
|
+
const loops = loopsOf(outline);
|
|
12302
12398
|
if (loops.length < 2) return [];
|
|
12303
|
-
const
|
|
12304
|
-
let longest = 0;
|
|
12305
|
-
lengths.forEach((length, i) => {
|
|
12306
|
-
if (length > lengths[longest] + Math.max(.01, lengths[longest] / 1e3)) longest = i;
|
|
12307
|
-
});
|
|
12399
|
+
const longest = outsideOf(loops);
|
|
12308
12400
|
return loops.filter((_, i) => i !== longest).map((loop) => {
|
|
12309
12401
|
const round = loopOutline([loop]).sample(4 * count);
|
|
12310
12402
|
const points = round.filter((_, i) => i % 4 === 0);
|
|
@@ -12320,6 +12412,15 @@ function holesOf(outline, count) {
|
|
|
12320
12412
|
};
|
|
12321
12413
|
}).sort((x, y) => y.area - x.area);
|
|
12322
12414
|
}
|
|
12415
|
+
const loopsOf = (outline) => flattenPath(parsePath(outline.d)).map((subpath) => subpath.segments).filter((segments) => segments.length > 0);
|
|
12416
|
+
function outsideOf(loops) {
|
|
12417
|
+
const lengths = loops.map((loop) => loop.reduce((sum, segment) => sum + segment.length, 0));
|
|
12418
|
+
let longest = 0;
|
|
12419
|
+
lengths.forEach((length, i) => {
|
|
12420
|
+
if (length > lengths[longest] + Math.max(.01, lengths[longest] / 1e3)) longest = i;
|
|
12421
|
+
});
|
|
12422
|
+
return longest;
|
|
12423
|
+
}
|
|
12323
12424
|
function areaOf(points) {
|
|
12324
12425
|
let sum = 0;
|
|
12325
12426
|
points.forEach((p, i) => {
|
|
@@ -12882,7 +12983,7 @@ function configure(options) {
|
|
|
12882
12983
|
}
|
|
12883
12984
|
}
|
|
12884
12985
|
// src/index.ts
|
|
12885
|
-
const VERSION = "0.
|
|
12986
|
+
const VERSION = "0.10.0";
|
|
12886
12987
|
const env = {
|
|
12887
12988
|
presets: presetRegistry,
|
|
12888
12989
|
icons: iconRegistry,
|