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.cjs
CHANGED
|
@@ -11458,6 +11458,7 @@ function expressive$1(target, options, env) {
|
|
|
11458
11458
|
return true;
|
|
11459
11459
|
}
|
|
11460
11460
|
};
|
|
11461
|
+
const refreshed = /* @__PURE__ */ new Set();
|
|
11461
11462
|
insides.set(link, {
|
|
11462
11463
|
root: () => root,
|
|
11463
11464
|
ancestor: () => ancestor,
|
|
@@ -11465,7 +11466,8 @@ function expressive$1(target, options, env) {
|
|
|
11465
11466
|
keyOf: (element) => ownerOf(element)?.record.key,
|
|
11466
11467
|
colorOf: (key) => records.get(key)?.mark.parts[0]?.colors?.color,
|
|
11467
11468
|
moveTabStop: (key) => keyboard?.moveTabStop(key) ?? false,
|
|
11468
|
-
edits
|
|
11469
|
+
edits,
|
|
11470
|
+
refreshed
|
|
11469
11471
|
});
|
|
11470
11472
|
return linkable(link, {
|
|
11471
11473
|
refresh(next) {
|
|
@@ -11504,6 +11506,7 @@ function expressive$1(target, options, env) {
|
|
|
11504
11506
|
for (const record of following) runner.change(record.mark.geometry, record.mark.data);
|
|
11505
11507
|
runner.settle();
|
|
11506
11508
|
keyboard?.sync();
|
|
11509
|
+
for (const listener of refreshed) listener();
|
|
11507
11510
|
exited.then(() => {
|
|
11508
11511
|
for (const record of diff.exiting) if (leaving.get(record.key) === record) leaving.delete(record.key);
|
|
11509
11512
|
});
|
|
@@ -11731,6 +11734,7 @@ function hostView(attachment, options = {}) {
|
|
|
11731
11734
|
const svg = () => inside.root();
|
|
11732
11735
|
let given;
|
|
11733
11736
|
let hidden = [];
|
|
11737
|
+
let classed;
|
|
11734
11738
|
function read() {
|
|
11735
11739
|
if (!options.labels) return [];
|
|
11736
11740
|
const keys = new Set(attachment.marks().map((mark) => mark.key));
|
|
@@ -11770,6 +11774,23 @@ function hostView(attachment, options = {}) {
|
|
|
11770
11774
|
element: text
|
|
11771
11775
|
};
|
|
11772
11776
|
}
|
|
11777
|
+
const hide = (on) => {
|
|
11778
|
+
const root = on ? svg() : void 0;
|
|
11779
|
+
given = on ? read() : void 0;
|
|
11780
|
+
const now = new Set(given ? [
|
|
11781
|
+
...inside.elements(),
|
|
11782
|
+
...given.map((label) => label.element),
|
|
11783
|
+
...hidden.filter((element) => root?.contains(element))
|
|
11784
|
+
] : []);
|
|
11785
|
+
for (const element of hidden) if (!now.has(element)) edits.style(element, "visibility", void 0);
|
|
11786
|
+
hidden = [...now];
|
|
11787
|
+
for (const element of hidden) edits.style(element, "visibility", "hidden");
|
|
11788
|
+
if (classed !== root) {
|
|
11789
|
+
if (classed) edits.toggleClass(classed, "ec-morphing", false);
|
|
11790
|
+
if (root) edits.toggleClass(root, "ec-morphing", true);
|
|
11791
|
+
classed = root;
|
|
11792
|
+
}
|
|
11793
|
+
};
|
|
11773
11794
|
const view = {
|
|
11774
11795
|
get element() {
|
|
11775
11796
|
return svg();
|
|
@@ -11784,7 +11805,7 @@ function hostView(attachment, options = {}) {
|
|
|
11784
11805
|
focus: (key) => attachment.focus(key),
|
|
11785
11806
|
leave: () => attachment.leave(),
|
|
11786
11807
|
destroy() {
|
|
11787
|
-
given = void 0;
|
|
11808
|
+
given = classed = void 0;
|
|
11788
11809
|
hidden = [];
|
|
11789
11810
|
attachment.destroy();
|
|
11790
11811
|
},
|
|
@@ -11799,14 +11820,11 @@ function hostView(attachment, options = {}) {
|
|
|
11799
11820
|
},
|
|
11800
11821
|
keyOf: (element) => inside.keyOf(element),
|
|
11801
11822
|
moveTabStop: (key) => inside.moveTabStop(key),
|
|
11802
|
-
morphing
|
|
11803
|
-
for (const element of hidden) edits.style(element, "visibility", void 0);
|
|
11804
|
-
given = on ? read() : void 0;
|
|
11805
|
-
hidden = given ? [...inside.elements(), ...given.map((label) => label.element)] : [];
|
|
11806
|
-
for (const element of hidden) edits.style(element, "visibility", "hidden");
|
|
11807
|
-
edits.toggleClass(svg(), "ec-morphing", on);
|
|
11808
|
-
}
|
|
11823
|
+
morphing: hide
|
|
11809
11824
|
};
|
|
11825
|
+
inside.refreshed.add(() => {
|
|
11826
|
+
if (given) hide(true);
|
|
11827
|
+
});
|
|
11810
11828
|
return linkable(port, view);
|
|
11811
11829
|
}
|
|
11812
11830
|
// src/charts/adapter/vega.ts
|
|
@@ -12506,6 +12524,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
12506
12524
|
}) : void 0;
|
|
12507
12525
|
observer?.observe(wrapper);
|
|
12508
12526
|
const view = (name) => views.get(name);
|
|
12527
|
+
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(", ")}.`);
|
|
12509
12528
|
function focused() {
|
|
12510
12529
|
return wrapper.getRootNode().activeElement ?? null;
|
|
12511
12530
|
}
|
|
@@ -12541,7 +12560,10 @@ function chartSwitch$1(target, options, env) {
|
|
|
12541
12560
|
function reached() {
|
|
12542
12561
|
if (held) linked?.shown();
|
|
12543
12562
|
}
|
|
12544
|
-
function
|
|
12563
|
+
function jump(from, to, via, carried) {
|
|
12564
|
+
return via === void 0 || !motion.staged || via === from.name || via === to.name ? start(from, to, carried) : start(from, view(via), carried, to);
|
|
12565
|
+
}
|
|
12566
|
+
function start(from, to, carried, next) {
|
|
12545
12567
|
const memory = carried ? carried.focus : readFocus(from);
|
|
12546
12568
|
const waiting = [];
|
|
12547
12569
|
opening = waiting;
|
|
@@ -12550,16 +12572,17 @@ function chartSwitch$1(target, options, env) {
|
|
|
12550
12572
|
} finally {
|
|
12551
12573
|
opening = void 0;
|
|
12552
12574
|
}
|
|
12553
|
-
const done = destroyed ? Promise.resolve() : begin(from, to, memory);
|
|
12575
|
+
const done = destroyed ? Promise.resolve() : begin(from, to, memory, next);
|
|
12554
12576
|
for (const run of waiting) run();
|
|
12555
12577
|
return done;
|
|
12556
12578
|
}
|
|
12557
|
-
function begin(from, to, memory) {
|
|
12558
|
-
current = to.name;
|
|
12579
|
+
function begin(from, to, memory, next, carried) {
|
|
12580
|
+
current = (next ?? to).name;
|
|
12559
12581
|
if (motion.mode === "off") {
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
|
|
12582
|
+
const end = view(current);
|
|
12583
|
+
for (const each of views.values()) setActive(each.container, each === end);
|
|
12584
|
+
restoreFocus(end, memory);
|
|
12585
|
+
say(end);
|
|
12563
12586
|
reached();
|
|
12564
12587
|
return Promise.resolve();
|
|
12565
12588
|
}
|
|
@@ -12571,7 +12594,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
12571
12594
|
each.chart.element.classList.add("ec-morphing");
|
|
12572
12595
|
}
|
|
12573
12596
|
const { pairs, surface, scene } = prepare(from, to);
|
|
12574
|
-
const { done, settle } = deferred();
|
|
12597
|
+
const { done, settle } = carried ?? deferred();
|
|
12575
12598
|
const session = {
|
|
12576
12599
|
a: from,
|
|
12577
12600
|
b: to,
|
|
@@ -12584,6 +12607,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
12584
12607
|
surface,
|
|
12585
12608
|
scene,
|
|
12586
12609
|
focus: memory,
|
|
12610
|
+
next,
|
|
12587
12611
|
progress: 0,
|
|
12588
12612
|
transition: void 0,
|
|
12589
12613
|
driver: void 0,
|
|
@@ -12598,7 +12622,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
12598
12622
|
function play(session, begin) {
|
|
12599
12623
|
const run = ++session.run;
|
|
12600
12624
|
if (begin >= 1) {
|
|
12601
|
-
|
|
12625
|
+
arrive(session);
|
|
12602
12626
|
return;
|
|
12603
12627
|
}
|
|
12604
12628
|
const at = (progress) => {
|
|
@@ -12620,7 +12644,19 @@ function chartSwitch$1(target, options, env) {
|
|
|
12620
12644
|
});
|
|
12621
12645
|
started.release();
|
|
12622
12646
|
Promise.all([session.driver.finished, session.transition.finished]).then(([result]) => {
|
|
12623
|
-
if (active === session && session.run === run && result === "done")
|
|
12647
|
+
if (active === session && session.run === run && result === "done") arrive(session);
|
|
12648
|
+
});
|
|
12649
|
+
}
|
|
12650
|
+
function arrive(session) {
|
|
12651
|
+
const next = session.forward ? session.next : void 0;
|
|
12652
|
+
if (!next || motion.mode === "off") return land(session, true);
|
|
12653
|
+
const { done, settle } = session;
|
|
12654
|
+
session.next = void 0;
|
|
12655
|
+
session.settle = () => {};
|
|
12656
|
+
land(session, false);
|
|
12657
|
+
begin(session.b, next, session.focus, void 0, {
|
|
12658
|
+
done,
|
|
12659
|
+
settle
|
|
12624
12660
|
});
|
|
12625
12661
|
}
|
|
12626
12662
|
function reverse(session) {
|
|
@@ -12640,7 +12676,7 @@ function chartSwitch$1(target, options, env) {
|
|
|
12640
12676
|
session.driver?.cancel();
|
|
12641
12677
|
session.transition?.clear();
|
|
12642
12678
|
session.scene.clear();
|
|
12643
|
-
const to = session.forward ? session.b : session.a;
|
|
12679
|
+
const to = session.forward ? session.next ?? session.b : session.a;
|
|
12644
12680
|
for (const each of [session.a, session.b]) {
|
|
12645
12681
|
each.chart.element.classList.remove("ec-morphing");
|
|
12646
12682
|
each.chart.morphing?.(false);
|
|
@@ -12781,23 +12817,35 @@ function chartSwitch$1(target, options, env) {
|
|
|
12781
12817
|
get current() {
|
|
12782
12818
|
return current;
|
|
12783
12819
|
},
|
|
12784
|
-
show(name) {
|
|
12785
|
-
if (!views.has(name)) return Promise.reject(
|
|
12820
|
+
show(name, options) {
|
|
12821
|
+
if (!views.has(name)) return Promise.reject(missing(name));
|
|
12822
|
+
const via = options?.via;
|
|
12823
|
+
if (via !== void 0 && !views.has(via)) return Promise.reject(missing(via, " to go via"));
|
|
12786
12824
|
if (destroyed) return Promise.resolve();
|
|
12787
12825
|
const waiting = opening;
|
|
12788
|
-
if (waiting) return new Promise((resolve) => waiting.push(() => resolve(api.show(name))));
|
|
12826
|
+
if (waiting) return new Promise((resolve) => waiting.push(() => resolve(api.show(name, options))));
|
|
12789
12827
|
const session = active;
|
|
12790
|
-
if (!session) return name === current ? Promise.resolve() :
|
|
12828
|
+
if (!session) return name === current ? Promise.resolve() : jump(view(current), view(name), via);
|
|
12791
12829
|
const heading = session.forward ? session.b : session.a;
|
|
12792
12830
|
const leaving = session.forward ? session.a : session.b;
|
|
12793
|
-
|
|
12831
|
+
const next = session.next;
|
|
12832
|
+
if (name === (next ?? heading).name) return session.done;
|
|
12833
|
+
if (next) {
|
|
12834
|
+
session.next = void 0;
|
|
12835
|
+
if (name === heading.name) {
|
|
12836
|
+
current = name;
|
|
12837
|
+
session.settle();
|
|
12838
|
+
({done: session.done, settle: session.settle} = deferred());
|
|
12839
|
+
return session.done;
|
|
12840
|
+
}
|
|
12841
|
+
}
|
|
12794
12842
|
if (name === leaving.name) return reverse(session);
|
|
12795
12843
|
land(session, false);
|
|
12796
|
-
return
|
|
12844
|
+
return jump(heading, view(name), via, { focus: session.focus });
|
|
12797
12845
|
},
|
|
12798
12846
|
chart(name) {
|
|
12799
12847
|
const found = views.get(name);
|
|
12800
|
-
if (!found) throw
|
|
12848
|
+
if (!found) throw missing(name);
|
|
12801
12849
|
return found.chart;
|
|
12802
12850
|
},
|
|
12803
12851
|
on(type, listener) {
|
|
@@ -14223,10 +14271,11 @@ function drawing(from, to, layer, points, align) {
|
|
|
14223
14271
|
if (closed !== to.outline.closed) return crossfade(from, to, layer);
|
|
14224
14272
|
const across = closed ? void 0 : acrossX(from, to, points);
|
|
14225
14273
|
if (across) return piecewise(from, to, layer, across.stops, across.kinds);
|
|
14226
|
-
const
|
|
14227
|
-
const
|
|
14274
|
+
const bands = closed ? bandsAcross(from, to, points) : void 0;
|
|
14275
|
+
const a = bands?.from ?? from.outline.sample(points);
|
|
14276
|
+
const b = bands?.to ?? to.outline.sample(points);
|
|
14228
14277
|
if (!closed) return from.gaps?.length || to.gaps?.length ? gapped(from, to, layer, a, b) : stroke(from, to, layer, a, b);
|
|
14229
|
-
const [shiftA, shiftB] = align === "drop" ? turn(from, to, points) : [0, 0];
|
|
14278
|
+
const [shiftA, shiftB] = !bands && align === "drop" ? turn(from, to, points) : [0, 0];
|
|
14230
14279
|
const holes = holePairs(from, to, a, b, [shiftA, shiftB], points / 4);
|
|
14231
14280
|
let path;
|
|
14232
14281
|
return (p) => {
|
|
@@ -14316,6 +14365,9 @@ function acrossX(from, to, points) {
|
|
|
14316
14365
|
const a = courseOf(from);
|
|
14317
14366
|
const b = a && courseOf(to);
|
|
14318
14367
|
if (!a || !b || a.way !== b.way) return void 0;
|
|
14368
|
+
return byX(a, b, points);
|
|
14369
|
+
}
|
|
14370
|
+
function byX(a, b, points) {
|
|
14319
14371
|
const all = [
|
|
14320
14372
|
...Array.from({ length: points }, (_, i) => [i / (points - 1), 0]),
|
|
14321
14373
|
...corners(a).map((s) => [s, 1]),
|
|
@@ -14371,7 +14423,9 @@ function courseOf(mark) {
|
|
|
14371
14423
|
before.push(points.length - 1);
|
|
14372
14424
|
from = end;
|
|
14373
14425
|
}
|
|
14374
|
-
|
|
14426
|
+
return !stretch(1) || next < subpaths.length || points.length < 2 ? void 0 : courseThrough(points, before);
|
|
14427
|
+
}
|
|
14428
|
+
function courseThrough(points, before = []) {
|
|
14375
14429
|
const x0 = points[0].x;
|
|
14376
14430
|
const span = points[points.length - 1].x - x0;
|
|
14377
14431
|
const way = Math.sign(span);
|
|
@@ -14412,6 +14466,48 @@ function placed(course, shares) {
|
|
|
14412
14466
|
return mixed(points[i], points[i + 1], width > 0 ? Math.min(1, Math.max(0, (s - at[i]) / width)) : 0);
|
|
14413
14467
|
});
|
|
14414
14468
|
}
|
|
14469
|
+
function bandsAcross(from, to, points) {
|
|
14470
|
+
const a = bandOf(from.outline);
|
|
14471
|
+
const b = a && bandOf(to.outline);
|
|
14472
|
+
if (!a || !b || Math.abs(a.left - b.left) > SAME_X || Math.abs(a.right - b.right) > SAME_X) return void 0;
|
|
14473
|
+
const upper = byX(a.upper, b.upper, points);
|
|
14474
|
+
const lower = byX(a.lower, b.lower, points);
|
|
14475
|
+
if (!upper || !lower) return void 0;
|
|
14476
|
+
const stops = [...upper.stops, ...lower.stops];
|
|
14477
|
+
return {
|
|
14478
|
+
from: stops.map((stop) => stop.from),
|
|
14479
|
+
to: stops.map((stop) => stop.to)
|
|
14480
|
+
};
|
|
14481
|
+
}
|
|
14482
|
+
function bandOf(outline) {
|
|
14483
|
+
const loops = loopsOf(outline);
|
|
14484
|
+
const ring = [];
|
|
14485
|
+
for (const segment of loops[outsideOf(loops)] ?? []) {
|
|
14486
|
+
if (segment.kind !== "line") return void 0;
|
|
14487
|
+
ring.push(segment.to);
|
|
14488
|
+
}
|
|
14489
|
+
if (areaOf(ring) < 0) ring.reverse();
|
|
14490
|
+
const left = ring.reduce((x, point) => Math.min(x, point.x), Infinity);
|
|
14491
|
+
const right = ring.reduce((x, point) => Math.max(x, point.x), -Infinity);
|
|
14492
|
+
if (!(right - left > 2 * SAME_X)) return void 0;
|
|
14493
|
+
const atLeft = (point) => point.x - left <= SAME_X;
|
|
14494
|
+
const atRight = (point) => right - point.x <= SAME_X;
|
|
14495
|
+
const s = ring.findIndex((point, i) => atLeft(point) && !atLeft(ring[(i + 1) % ring.length]));
|
|
14496
|
+
const walk = [...ring.slice(s), ...ring.slice(0, s + 1)];
|
|
14497
|
+
const topRight = walk.findIndex(atRight);
|
|
14498
|
+
let baseRight = topRight;
|
|
14499
|
+
while (atRight(walk[baseRight + 1])) baseRight++;
|
|
14500
|
+
const baseLeft = walk.findIndex((point, i) => i > baseRight && atLeft(point));
|
|
14501
|
+
if (walk.slice(baseLeft).some((point) => !atLeft(point))) return void 0;
|
|
14502
|
+
const upper = courseThrough(walk.slice(0, topRight + 1));
|
|
14503
|
+
const lower = courseThrough(walk.slice(baseRight, baseLeft + 1));
|
|
14504
|
+
return upper && lower && upper.points.length > 2 && lower.points.length > 2 ? {
|
|
14505
|
+
upper,
|
|
14506
|
+
lower,
|
|
14507
|
+
left,
|
|
14508
|
+
right
|
|
14509
|
+
} : void 0;
|
|
14510
|
+
}
|
|
14415
14511
|
function inside(gaps) {
|
|
14416
14512
|
let k = 0;
|
|
14417
14513
|
return (s) => {
|
|
@@ -14537,13 +14633,9 @@ function placeIn(point, own, other) {
|
|
|
14537
14633
|
};
|
|
14538
14634
|
}
|
|
14539
14635
|
function holesOf(outline, count) {
|
|
14540
|
-
const loops =
|
|
14636
|
+
const loops = loopsOf(outline);
|
|
14541
14637
|
if (loops.length < 2) return [];
|
|
14542
|
-
const
|
|
14543
|
-
let longest = 0;
|
|
14544
|
-
lengths.forEach((length, i) => {
|
|
14545
|
-
if (length > lengths[longest] + Math.max(.01, lengths[longest] / 1e3)) longest = i;
|
|
14546
|
-
});
|
|
14638
|
+
const longest = outsideOf(loops);
|
|
14547
14639
|
return loops.filter((_, i) => i !== longest).map((loop) => {
|
|
14548
14640
|
const round = loopOutline([loop]).sample(4 * count);
|
|
14549
14641
|
const points = round.filter((_, i) => i % 4 === 0);
|
|
@@ -14559,6 +14651,15 @@ function holesOf(outline, count) {
|
|
|
14559
14651
|
};
|
|
14560
14652
|
}).sort((x, y) => y.area - x.area);
|
|
14561
14653
|
}
|
|
14654
|
+
const loopsOf = (outline) => flattenPath(parsePath(outline.d)).map((subpath) => subpath.segments).filter((segments) => segments.length > 0);
|
|
14655
|
+
function outsideOf(loops) {
|
|
14656
|
+
const lengths = loops.map((loop) => loop.reduce((sum, segment) => sum + segment.length, 0));
|
|
14657
|
+
let longest = 0;
|
|
14658
|
+
lengths.forEach((length, i) => {
|
|
14659
|
+
if (length > lengths[longest] + Math.max(.01, lengths[longest] / 1e3)) longest = i;
|
|
14660
|
+
});
|
|
14661
|
+
return longest;
|
|
14662
|
+
}
|
|
14562
14663
|
function areaOf(points) {
|
|
14563
14664
|
let sum = 0;
|
|
14564
14665
|
points.forEach((p, i) => {
|
|
@@ -15213,7 +15314,7 @@ function configure(options) {
|
|
|
15213
15314
|
}
|
|
15214
15315
|
}
|
|
15215
15316
|
// src/index.ts
|
|
15216
|
-
const VERSION = "0.
|
|
15317
|
+
const VERSION = "0.10.0";
|
|
15217
15318
|
const env = {
|
|
15218
15319
|
presets: presetRegistry,
|
|
15219
15320
|
icons: iconRegistry,
|