@msb235/blits-panel 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@ This package follows [semver](https://semver.org). Below 1.0.0, a breaking chang
4
4
  version and everything else the patch. The release workflow refuses a `panel-v*` tag with no
5
5
  section here.
6
6
 
7
+ ## 0.2.0
8
+
9
+ ### Breaking
10
+
11
+ - `@msb235/blits` is a peer at `^0.14.0`, where it was `^0.12.0`. Engine 0.13.0 has breaking
12
+ changes of its own, listed in its changelog.
13
+
14
+ ### Changed
15
+
16
+ - With one mix on the page and none picked, the panel picks it, so the clock controls work
17
+ without opening the window first.
18
+ - The clock reads `1:05.20` past a minute and `2:03:07.50` past an hour, where it counted seconds
19
+ only.
20
+
21
+ ## 0.1.1
22
+
23
+ 0.1.0 again, published from the release workflow with provenance; 0.1.0 went out by hand.
24
+
7
25
  ## 0.1.0
8
26
 
9
27
  ### Added
package/dist/index.js CHANGED
@@ -268,9 +268,14 @@ function T(t = {}) {
268
268
  z(e.subject === null ? void 0 : r.get(e.subject));
269
269
  return;
270
270
  }
271
- }, J = i.on((e) => {
272
- E(), e.kind === "gone" && a === e.id && I(null);
273
- }), Y = setInterval(j, b);
271
+ }, J = () => {
272
+ let [e, ...t] = h();
273
+ a === null && e !== void 0 && t.length === 0 && I(e.id);
274
+ }, Y = i.on((e) => {
275
+ E(), e.kind === "gone" && a === e.id && I(null), J();
276
+ });
277
+ J();
278
+ let X = setInterval(j, b);
274
279
  return {
275
280
  subscribe(e) {
276
281
  return n.add(e), e({
@@ -289,7 +294,7 @@ function T(t = {}) {
289
294
  },
290
295
  send: q,
291
296
  dispose() {
292
- K(!1), F(), s?.(), s = null, clearInterval(Y), J(), z(void 0), n.clear();
297
+ K(!1), F(), s?.(), s = null, clearInterval(X), Y(), z(void 0), n.clear();
293
298
  }
294
299
  };
295
300
  }
@@ -417,8 +422,18 @@ function I({ label: e, times: t, series: n, playhead: r, width: i = 320, height:
417
422
  });
418
423
  }
419
424
  //#endregion
425
+ //#region src/ui/time.ts
426
+ var L = (e) => String(e).padStart(2, "0");
427
+ function R(e) {
428
+ if (!Number.isFinite(e)) return "—";
429
+ let t = e < 0 ? "-" : "", n = Math.floor(Math.abs(e) / 10), r = n % 6e3 / 100, i = Math.floor(n / 6e3) % 60, a = Math.floor(n / 36e4);
430
+ if (a === 0 && i === 0) return `${t}${r.toFixed(2)}s`;
431
+ let o = r.toFixed(2).padStart(5, "0");
432
+ return a === 0 ? `${t}${i}:${o}` : `${t}${a}:${L(i)}:${o}`;
433
+ }
434
+ //#endregion
420
435
  //#region src/ui/Panel.tsx
421
- var L = {
436
+ var z = {
422
437
  mixes: [],
423
438
  mix: null,
424
439
  subject: null,
@@ -433,7 +448,7 @@ var L = {
433
448
  arming: !1,
434
449
  drawn: 0
435
450
  };
436
- function R(e, t) {
451
+ function B(e, t) {
437
452
  switch (t.kind) {
438
453
  case "mixes": return {
439
454
  ...e,
@@ -468,17 +483,17 @@ function R(e, t) {
468
483
  case "samples": return e;
469
484
  }
470
485
  }
471
- var z = [
486
+ var V = [
472
487
  0,
473
488
  .1,
474
489
  .25,
475
490
  .5,
476
491
  1,
477
492
  2
478
- ], B = 1e3 / 60, V = "blits-panel:place";
479
- function H() {
493
+ ], H = 1e3 / 60, U = "blits-panel:place";
494
+ function W() {
480
495
  try {
481
- let e = JSON.parse(localStorage.getItem(V) ?? "null");
496
+ let e = JSON.parse(localStorage.getItem(U) ?? "null");
482
497
  if (e && typeof e.x == "number" && typeof e.y == "number") return e;
483
498
  } catch {}
484
499
  return {
@@ -487,25 +502,24 @@ function H() {
487
502
  open: !1
488
503
  };
489
504
  }
490
- function U(e) {
505
+ function G(e) {
491
506
  try {
492
- localStorage.setItem(V, JSON.stringify(e));
507
+ localStorage.setItem(U, JSON.stringify(e));
493
508
  } catch {}
494
509
  }
495
- function W(e, t) {
510
+ function K(e, t) {
496
511
  let n = typeof innerWidth == "number" ? innerWidth : 1024, r = typeof innerHeight == "number" ? innerHeight : 768;
497
512
  return {
498
513
  x: Math.min(Math.max(0, e), Math.max(0, n - 120)),
499
514
  y: Math.min(Math.max(0, t), Math.max(0, r - 40))
500
515
  };
501
516
  }
502
- var G = (e) => Number.isFinite(e) ? `${(e / 1e3).toFixed(2)}s` : "—";
503
- function K({ source: e, docked: t = !1, bar: n }) {
504
- let [r, a] = o(R, L), l = s(new k()), [u, m] = c(() => {
505
- let e = H();
517
+ function q({ source: e, docked: t = !1, bar: n }) {
518
+ let [r, a] = o(B, z), l = s(new k()), [u, m] = c(() => {
519
+ let e = W();
506
520
  return {
507
521
  ...e,
508
- ...W(e.x, e.y)
522
+ ...K(e.x, e.y)
509
523
  };
510
524
  }), [h, g] = c(""), [_, v] = c(null);
511
525
  i(() => {
@@ -542,10 +556,10 @@ function K({ source: e, docked: t = !1, bar: n }) {
542
556
  S && r.hold.now > y.current && (y.current = r.hold.now), S || (y.current = -Infinity);
543
557
  let C = (e, t = u.x, n = u.y) => {
544
558
  let r = {
545
- ...W(t, n),
559
+ ...K(t, n),
546
560
  open: e
547
561
  };
548
- m(r), U(r);
562
+ m(r), G(r);
549
563
  }, w = (e) => {
550
564
  if (e.target.closest("button, select, input")) return;
551
565
  let t = {
@@ -575,7 +589,7 @@ function K({ source: e, docked: t = !1, bar: n }) {
575
589
  title: "step one frame",
576
590
  onClick: () => b({
577
591
  kind: "step",
578
- ms: B
592
+ ms: H
579
593
  }),
580
594
  children: "⏭"
581
595
  }),
@@ -615,7 +629,7 @@ function K({ source: e, docked: t = !1, bar: n }) {
615
629
  }),
616
630
  /* @__PURE__ */ f("span", {
617
631
  className: "bp-time",
618
- children: G(r.hold.now)
632
+ children: R(r.hold.now)
619
633
  })
620
634
  ]
621
635
  });
@@ -655,7 +669,7 @@ function K({ source: e, docked: t = !1, bar: n }) {
655
669
  kind: "rate",
656
670
  rate: Number(e.currentTarget.value)
657
671
  }),
658
- children: z.map((e) => /* @__PURE__ */ p("option", {
672
+ children: V.map((e) => /* @__PURE__ */ p("option", {
659
673
  value: e,
660
674
  children: ["×", e]
661
675
  }, e))
@@ -669,11 +683,11 @@ function K({ source: e, docked: t = !1, bar: n }) {
669
683
  }),
670
684
  /* @__PURE__ */ f("span", {
671
685
  className: "bp-time",
672
- children: G(r.hold.now)
686
+ children: R(r.hold.now)
673
687
  })
674
688
  ]
675
689
  }),
676
- x !== void 0 && /* @__PURE__ */ f(q, {
690
+ x !== void 0 && /* @__PURE__ */ f(J, {
677
691
  mix: x,
678
692
  hold: r.hold
679
693
  }),
@@ -750,7 +764,7 @@ function K({ source: e, docked: t = !1, bar: n }) {
750
764
  }, e.id))
751
765
  })
752
766
  ]
753
- }), /* @__PURE__ */ f(J, {
767
+ }), /* @__PURE__ */ f(Y, {
754
768
  samples: l.current,
755
769
  drawn: r.drawn,
756
770
  voices: r.voices,
@@ -761,14 +775,14 @@ function K({ source: e, docked: t = !1, bar: n }) {
761
775
  ]
762
776
  });
763
777
  }
764
- function q({ mix: e, hold: t }) {
778
+ function J({ mix: e, hold: t }) {
765
779
  let n = e.history, r = n === null ? "no history: made before the panel, or the panel was told not to add it, so it only pauses and steps forward" : n.tape ? n.added ? `history: ${(n.ms / 1e3).toFixed(0)} s, added by the debugger` : `history: ${(n.ms / 1e3).toFixed(0)} s, its own` : "no tape: it only pauses and steps forward";
766
780
  return /* @__PURE__ */ p("p", {
767
781
  className: "bp-note",
768
782
  children: [r, t.state === "elsewhere" && " · its clock is held elsewhere"]
769
783
  });
770
784
  }
771
- function J({ samples: e, drawn: t, voices: n, playhead: r, picked: i }) {
785
+ function Y({ samples: e, drawn: t, voices: n, playhead: r, picked: i }) {
772
786
  let o = a(() => e.series(), [e, t]);
773
787
  if (!i) return /* @__PURE__ */ f("p", {
774
788
  className: "bp-plots bp-muted",
@@ -802,7 +816,7 @@ function J({ samples: e, drawn: t, voices: n, playhead: r, picked: i }) {
802
816
  }
803
817
  //#endregion
804
818
  //#region src/mount.tsx
805
- function Y(i = {}) {
819
+ function X(i = {}) {
806
820
  let a = e(), o = a.history, s = i.history ?? (o === void 0 && 1e4), c = s === !1 ? void 0 : {
807
821
  ms: s,
808
822
  tape: t
@@ -828,7 +842,7 @@ function Y(i = {}) {
828
842
  m.render(/* @__PURE__ */ f(n, {
829
843
  selection: { mode: "auto" },
830
844
  className: "bp-root",
831
- children: /* @__PURE__ */ f(K, { source: p })
845
+ children: /* @__PURE__ */ f(q, { source: p })
832
846
  }));
833
847
  let h = !1;
834
848
  return () => {
@@ -837,39 +851,39 @@ function Y(i = {}) {
837
851
  }
838
852
  //#endregion
839
853
  //#region src/wire.ts
840
- function X(e) {
854
+ function Z(e) {
841
855
  return JSON.stringify(e, (e, t) => typeof t == "number" && !Number.isFinite(t) ? { $n: String(t) } : t);
842
856
  }
843
- function Z(e) {
857
+ function Q(e) {
844
858
  return JSON.parse(e, (e, t) => typeof t == "object" && t && typeof t.$n == "string" && Object.keys(t).length === 1 ? Number(t.$n) : t);
845
859
  }
846
- function Q(e) {
860
+ function $(e) {
847
861
  let t = /* @__PURE__ */ new Set(), n = e.listen((e) => {
848
- let n = Z(e);
862
+ let n = Q(e);
849
863
  if ("e" in n) for (let e of [...t]) e(n.e);
850
864
  });
851
865
  return {
852
866
  subscribe(n) {
853
- return t.add(n), t.size === 1 && e.send(X({ hello: !0 })), () => {
867
+ return t.add(n), t.size === 1 && e.send(Z({ hello: !0 })), () => {
854
868
  t.delete(n);
855
869
  };
856
870
  },
857
871
  send(t) {
858
- e.send(X({ c: t }));
872
+ e.send(Z({ c: t }));
859
873
  },
860
874
  refresh() {
861
- e.send(X({ hello: !0 }));
875
+ e.send(Z({ hello: !0 }));
862
876
  },
863
877
  close() {
864
878
  n(), t.clear();
865
879
  }
866
880
  };
867
881
  }
868
- function $(e, t) {
882
+ function ee(e, t) {
869
883
  let n = () => {}, r = () => {
870
- n(), n = e.subscribe((e) => t.send(X({ e })));
884
+ n(), n = e.subscribe((e) => t.send(Z({ e })));
871
885
  }, i = t.listen((t) => {
872
- let n = Z(t);
886
+ let n = Q(t);
873
887
  "hello" in n ? r() : "c" in n && e.send(n.c);
874
888
  });
875
889
  return r(), () => {
@@ -877,6 +891,6 @@ function $(e, t) {
877
891
  };
878
892
  }
879
893
  //#endregion
880
- export { O as CAP, I as ChannelPlot, K as Panel, k as Samples, D as WINDOW_MS, T as agent, Z as decode, X as encode, w as flatten, A as hueColor, Y as mount, g as offer, E as panelStyles, $ as serve, Q as wireSource };
894
+ export { O as CAP, I as ChannelPlot, q as Panel, k as Samples, D as WINDOW_MS, T as agent, Q as decode, Z as encode, w as flatten, A as hueColor, X as mount, g as offer, E as panelStyles, ee as serve, $ as wireSource };
881
895
 
882
896
  //# sourceMappingURL=index.js.map