bunnyquery 1.21.3 → 1.21.7

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.
@@ -61,3 +61,60 @@ export function formatDuration(ms?: number): string {
61
61
  out.push(s + 's');
62
62
  return out.join(' ');
63
63
  }
64
+
65
+ /**
66
+ * "45 s", "12 min 5 s", "1 h 3 min": how long a whole file took to index, from its run::
67
+ * record's `started` to its `finished`. Coarser than formatDuration on purpose: a file run
68
+ * spans many passes and often minutes, so seconds are dropped once it passes an hour, and a
69
+ * zero unit is left out ("12 min", "1 h"). Hours stay the largest unit for the reason
70
+ * formatDuration gives.
71
+ *
72
+ * Empty string for anything under a second, negative, or non-finite: a file cannot be read
73
+ * in no time, so those are missing data or clock skew, and callers gate on the result.
74
+ */
75
+ export function formatIndexDuration(ms?: number): string {
76
+ if (typeof ms !== 'number' || !isFinite(ms) || ms < 1000) return '';
77
+ var total = Math.floor(ms / 1000);
78
+ var h = Math.floor(total / 3600);
79
+ var m = Math.floor((total % 3600) / 60);
80
+ var s = total % 60;
81
+ if (h) return h + ' h' + (m ? ' ' + m + ' min' : '');
82
+ if (m) return m + ' min' + (s ? ' ' + s + ' s' : '');
83
+ return s + ' s';
84
+ }
85
+
86
+ /**
87
+ * Creation time (ms epoch) of a request id "stamp:entropy", whose stamp is a time_ns written
88
+ * as 8 bytes of base32hex without padding (the worker's and the producer's _generate_req_id).
89
+ * 0 when it is not one.
90
+ */
91
+ export function requestIdTimeMs(rid: string): number {
92
+ if (typeof rid !== 'string') return 0;
93
+ var stamp = rid.split(':')[0] || '';
94
+ if (stamp.length !== 13) return 0;
95
+ var alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUV';
96
+ var v = 0;
97
+ for (var i = 0; i < stamp.length; i++) {
98
+ var d = alphabet.indexOf(stamp.charAt(i).toUpperCase());
99
+ if (d < 0) return 0;
100
+ v = v * 32 + d;
101
+ }
102
+ // 13 digits are 65 bits for 64 of data: the last bit is padding.
103
+ return Math.floor(v / 2 / 1e6);
104
+ }
105
+
106
+ /**
107
+ * A chat message's time in epoch ms, for ORDERING and grouping (never for display): the time
108
+ * in its request id (`_serverItemId`, "stamp:entropy", the server's clock) when it has one,
109
+ * else its `_ts`, else 0 (unknown). Request-id first so every comparison uses one clock: a
110
+ * live-settled reply's `_ts` is the browser's Date.now(), and mixing the two let a browser
111
+ * running ahead of the server fold a re-index into the previous run. A request and its reply
112
+ * share one id, so nothing is ever ordered between them. A live background pass adopted from
113
+ * the queue has no `_ts` at all until it settles.
114
+ */
115
+ export function messageTimeMs(m: { _ts?: number; _serverItemId?: string } | null | undefined): number {
116
+ if (!m) return 0;
117
+ var r = typeof m._serverItemId === 'string' ? requestIdTimeMs(m._serverItemId) : 0;
118
+ if (r > 0) return r;
119
+ return typeof m._ts === 'number' && m._ts > 0 ? m._ts : 0;
120
+ }
package/src/widget.css CHANGED
@@ -988,6 +988,16 @@
988
988
  font-size: 0.75rem;
989
989
  line-height: 1.3;
990
990
  }
991
+ /* Informational, not an error: what the user just cancelled (uploads). Muted
992
+ ink on the paper, the chip row's own neutral look; the x dismisses it. */
993
+ .bq-attachment-warning.is-notice {
994
+ align-items: center;
995
+ border-color: var(--bq-line);
996
+ background: var(--bq-paper);
997
+ color: var(--bq-muted);
998
+ }
999
+ .bq-attachment-warning.is-notice > span { flex: 1 1 auto; min-width: 0; }
1000
+ .bq-attachment-warning.is-notice .bq-attachment-remove { flex: none; margin-left: 0; }
991
1001
 
992
1002
  /* ============================================================================
993
1003
  * MODALS (appended to <body> under .bq-modal-root)
package/styles/chat.css CHANGED
@@ -421,6 +421,28 @@
421
421
  in a block <p>. Inline it so the row stays one line high. */
422
422
  .bq-index-label .bq-md,
423
423
  .bq-index-label .bq-md p { display: inline; margin: 0; }
424
+ /* A row whose file name is a fitted chip (renderInlineLinkHtml fitLabel) lays
425
+ the label out as a flex line instead: the verb keeps its width and the chip
426
+ takes whatever is left, so the name shows in full when the row has room and is
427
+ cut to the row (stem ellipsis, end of the name and extension kept) only when it
428
+ does not. The counts and the Stop button are siblings of .bq-index-label and
429
+ never shrink, so a narrow screen cuts the name, not them. A label with no chip
430
+ (a file without a stored path) keeps the inline layout and the label's own
431
+ ellipsis above. */
432
+ .bq-index-label .bq-md:has(.bq-link-fit),
433
+ .bq-index-label .bq-md:has(.bq-link-fit) > p {
434
+ display: flex;
435
+ align-items: baseline;
436
+ min-width: 0;
437
+ column-gap: 0.35em;
438
+ /* The bubble's break-anywhere wrapping would let the verb ("Indexed") give
439
+ up its width a letter at a time before the name shrinks. Only the name's
440
+ stem may give way. */
441
+ white-space: nowrap;
442
+ overflow-wrap: normal;
443
+ word-break: normal;
444
+ }
445
+ .bq-index-label .bq-md:has(.bq-link-fit) > p { flex: 1 1 auto; }
424
446
  /* Passes LOADED, never a server-side total: history pages newest-first, so any
425
447
  total derived from what is on screen is a lower bound. */
426
448
  .bq-index-count { flex: 0 0 auto; opacity: 0.75; font-size: 0.72rem; }
@@ -569,6 +591,44 @@
569
591
  .bq-md a.bq-link-button { text-decoration: none; }
570
592
  .bq-md a.bq-link-button:hover { text-decoration: underline; }
571
593
  .bq-md a.bq-link-button.is-unavailable:hover { text-decoration: none; }
594
+ /* A fitted chip (renderInlineLinkHtml fitLabel): the full name as a stem that
595
+ ellipsizes and a tail (end of the name + extension) that never shrinks. Flex
596
+ items are not atomic inlines, so an underline on the anchor would run under the
597
+ glyph too; the hover underline goes on the two name parts instead. */
598
+ .bq-link-button.bq-link-fit {
599
+ display: inline-flex;
600
+ align-items: baseline;
601
+ flex: 0 1 auto;
602
+ min-width: 0;
603
+ max-width: 100%;
604
+ overflow: hidden;
605
+ }
606
+ .bq-link-fit .bq-link-glyph { flex: none; }
607
+ .bq-link-fit .bq-link-stem {
608
+ flex: 0 1 auto;
609
+ min-width: 0;
610
+ overflow: hidden;
611
+ text-overflow: ellipsis;
612
+ white-space: pre;
613
+ }
614
+ /* The tail never shrinks while there is stem left to cut. Only a row too narrow
615
+ for even the end of the name caps it (the chip's width less the glyph), and
616
+ then with an ellipsis instead of a hard clip. A max-width, not a small
617
+ flex-shrink: any shrink at all takes a fraction of a pixel off the tail and
618
+ puts an ellipsis on a name that fits. */
619
+ .bq-link-fit .bq-link-tail {
620
+ flex: none;
621
+ max-width: calc(100% - 1.2em);
622
+ overflow: hidden;
623
+ text-overflow: ellipsis;
624
+ white-space: pre;
625
+ }
626
+ .bq-link-button.bq-link-fit:hover,
627
+ .bq-md a.bq-link-button.bq-link-fit:hover { text-decoration: none; }
628
+ .bq-link-button.bq-link-fit:hover .bq-link-stem,
629
+ .bq-link-button.bq-link-fit:hover .bq-link-tail { text-decoration: underline; }
630
+ .bq-link-button.bq-link-fit.is-unavailable:hover .bq-link-stem,
631
+ .bq-link-button.bq-link-fit.is-unavailable:hover .bq-link-tail { text-decoration: none; }
572
632
  /* The ↗ / ✕ glyph is never underlined, at rest or on hover. Underlines propagate
573
633
  into every in-flow inline descendant and a descendant cannot cancel them, so
574
634
  `text-decoration: none` on the glyph alone does nothing; an atomic inline