@celestia-island/hikari 0.55.402 → 0.55.404
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/package.json
CHANGED
|
@@ -10,8 +10,9 @@ import { setLocale } from "../i18n/context";
|
|
|
10
10
|
* COMPONENT contract: the segment order follows the ACTIVE hikari
|
|
11
11
|
* locale (year first for zh-Hans, year LAST for en) with that locale's
|
|
12
12
|
* own separators, the order re-derives live when the host flips the
|
|
13
|
-
* locale, `time` appends the muted trailing segment,
|
|
14
|
-
*
|
|
13
|
+
* locale, `time` appends the muted trailing segment, `seconds` widens
|
|
14
|
+
* that segment to hour:minute:second (only under `time`), and
|
|
15
|
+
* unparseable input renders the empty pill shell.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
@@ -20,7 +21,11 @@ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement
|
|
|
20
21
|
// every CI time zone; the pill renders local calendar segments.
|
|
21
22
|
const SHIP_DATE = new Date(2024, 9, 6, 14, 30);
|
|
22
23
|
|
|
23
|
-
function mountTag(props: {
|
|
24
|
+
function mountTag(props: {
|
|
25
|
+
value: string | number | Date;
|
|
26
|
+
time?: boolean;
|
|
27
|
+
seconds?: boolean;
|
|
28
|
+
}): HTMLElement {
|
|
24
29
|
const container = document.createElement("div");
|
|
25
30
|
document.body.appendChild(container);
|
|
26
31
|
const app = createApp({ render: () => h(HkDateTag, props) });
|
|
@@ -123,6 +128,44 @@ describe("HkDateTag time segment", () => {
|
|
|
123
128
|
});
|
|
124
129
|
});
|
|
125
130
|
|
|
131
|
+
describe("HkDateTag seconds segment", () => {
|
|
132
|
+
// A nonzero second is the point: the widened segment must show the
|
|
133
|
+
// record's exact tick, not a padded zero.
|
|
134
|
+
const TICK = new Date(2024, 9, 6, 14, 30, 5);
|
|
135
|
+
|
|
136
|
+
it("widens the time segment to hour:minute:second when asked", async () => {
|
|
137
|
+
await setLocale("zh-Hans");
|
|
138
|
+
const container = mountTag({ value: TICK, time: true, seconds: true });
|
|
139
|
+
const segs = segsOf(container);
|
|
140
|
+
// Same segment count and element role as the plain time pill — the
|
|
141
|
+
// widening refines the segment in place.
|
|
142
|
+
expect(segs).toHaveLength(4);
|
|
143
|
+
expect(segs[3].classList.contains("hk-date-tag__seg--time")).toBe(true);
|
|
144
|
+
expect(segs[3].textContent).toBe("14:30:05");
|
|
145
|
+
expect(textOf(container)).toBe("2024/10/06 14:30:05");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("formats the seconds form for the active locale", async () => {
|
|
149
|
+
await setLocale("en");
|
|
150
|
+
const container = mountTag({ value: TICK, time: true, seconds: true });
|
|
151
|
+
const segs = segsOf(container);
|
|
152
|
+
expect(segs).toHaveLength(4);
|
|
153
|
+
expect(segs[3]!.textContent).toBe("02:30:05 PM");
|
|
154
|
+
expect(textOf(container)).toBe("10/06/2024 02:30:05 PM");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("does nothing without the time flag", async () => {
|
|
158
|
+
await setLocale("zh-Hans");
|
|
159
|
+
const container = mountTag({ value: TICK, seconds: true });
|
|
160
|
+
const segs = segsOf(container);
|
|
161
|
+
expect(segs).toHaveLength(3);
|
|
162
|
+
expect(segs.some((s) => s.classList.contains("hk-date-tag__seg--time"))).toBe(false);
|
|
163
|
+
// No time segment also means NO separator — the pill's text is the
|
|
164
|
+
// bare date, byte-identical to the no-flags render.
|
|
165
|
+
expect(textOf(container)).toBe("2024/10/06");
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
126
169
|
describe("HkDateTag value normalization", () => {
|
|
127
170
|
it("accepts epoch milliseconds and date strings like the Date form", async () => {
|
|
128
171
|
await setLocale("en");
|
|
@@ -10,7 +10,8 @@ import "./HkDateTag.scss";
|
|
|
10
10
|
* dates (zh: 2024/10/06 — year first; en: 10/06/2024 — the year LAST;
|
|
11
11
|
* de: 06.10.2024 — day first), joined by that locale's own literal
|
|
12
12
|
* separators. With the `time` flag a fourth, muted segment carries the
|
|
13
|
-
* locale time (hour + minute, 2-digit
|
|
13
|
+
* locale time (hour + minute, 2-digit — widened to hour:minute:second
|
|
14
|
+
* under `seconds`) after a blank separator.
|
|
14
15
|
*
|
|
15
16
|
* Generic business part (peer of HkTemplateText / HkMarkdownRenderer,
|
|
16
17
|
* NOT of the HkInput family): hosts render compact per-row dates in
|
|
@@ -32,6 +33,11 @@ import "./HkDateTag.scss";
|
|
|
32
33
|
* `setLocale` re-orders the line live.
|
|
33
34
|
* - `time` (default false) appends the muted time segment
|
|
34
35
|
* (`hk-date-tag__seg--time`) after a blank separator.
|
|
36
|
+
* - `seconds` (default false) widens the time segment to
|
|
37
|
+
* hour:minute:second — it refines the `time` segment in place (same
|
|
38
|
+
* element, same muted role) and does nothing when `time` is false.
|
|
39
|
+
* Trace/log surfaces that need second precision (a 176ms tool call
|
|
40
|
+
* landing between two :30 ticks) opt in; tables stay at HH:mm.
|
|
35
41
|
*/
|
|
36
42
|
export const HkDateTag = defineComponent({
|
|
37
43
|
name: "HkDateTag",
|
|
@@ -44,6 +50,8 @@ export const HkDateTag = defineComponent({
|
|
|
44
50
|
},
|
|
45
51
|
/** Append the muted locale time segment (hour + minute, 2-digit). */
|
|
46
52
|
time: { type: Boolean, default: false },
|
|
53
|
+
/** Widen the time segment to hour:minute:second (needs `time`). */
|
|
54
|
+
seconds: { type: Boolean, default: false },
|
|
47
55
|
},
|
|
48
56
|
setup(props) {
|
|
49
57
|
const date = computed<Date | null>(() => {
|
|
@@ -70,12 +78,18 @@ export const HkDateTag = defineComponent({
|
|
|
70
78
|
}).formatToParts(d);
|
|
71
79
|
});
|
|
72
80
|
|
|
73
|
-
/** The locale time (hour + minute,
|
|
74
|
-
* in — null without `time` or for an
|
|
81
|
+
/** The locale time (hour + minute, or hour:minute:second under
|
|
82
|
+
* `seconds`) when the pill opts in — null without `time` or for an
|
|
83
|
+
* invalid date. */
|
|
75
84
|
const timeText = computed<string | null>(() => {
|
|
76
85
|
const d = date.value;
|
|
77
86
|
if (!props.time || d === null) return null;
|
|
78
|
-
return new Intl.DateTimeFormat(
|
|
87
|
+
return new Intl.DateTimeFormat(
|
|
88
|
+
locale.value,
|
|
89
|
+
props.seconds
|
|
90
|
+
? { hour: "2-digit", minute: "2-digit", second: "2-digit" }
|
|
91
|
+
: { hour: "2-digit", minute: "2-digit" },
|
|
92
|
+
).format(d);
|
|
79
93
|
});
|
|
80
94
|
|
|
81
95
|
return () => (
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The cursor's ink is THEME-INDEPENDENT (2026-11-16 field finding).
|
|
8
|
+
*
|
|
9
|
+
* The glyph rides the remote screen, which is dark in every app theme —
|
|
10
|
+
* the HkTerminal doctrine. The first cut used the page's text token, so
|
|
11
|
+
* in a light theme (--color-text near-black) the pointer rendered
|
|
12
|
+
* near-invisible against the black remote canvas: measured computed
|
|
13
|
+
* fill `rgb(30 30 30)` over `#0b0d12`. Both the arrow and the lobes now
|
|
14
|
+
* speak fixed light ink / dark glass, and this pin keeps a future edit
|
|
15
|
+
* from quietly restoring the theme tokens.
|
|
16
|
+
*/
|
|
17
|
+
const scss = readFileSync(join(__dirname, "HkVirtualCursor.scss"), "utf8");
|
|
18
|
+
|
|
19
|
+
describe("HkVirtualCursor ink", () => {
|
|
20
|
+
it("the arrow is fixed light ink with a dark outline", () => {
|
|
21
|
+
// The sheet nests `path { … }` inside the arrow block; take the
|
|
22
|
+
// arrow block and check the nested rule inside it.
|
|
23
|
+
const arrow = /\.hk-virtual-cursor__arrow \{[\s\S]*?\n\}/.exec(scss)?.[0] ?? "";
|
|
24
|
+
expect(arrow, "the arrow block is present").not.toBe("");
|
|
25
|
+
const path = /path \{[\s\S]*?\n \}/.exec(arrow)?.[0] ?? "";
|
|
26
|
+
expect(path, "the nested path rule is present").not.toBe("");
|
|
27
|
+
expect(path).toMatch(/fill:\s*rgb\(255 255 255/);
|
|
28
|
+
expect(path).toMatch(/stroke:\s*rgb\(0 0 0/);
|
|
29
|
+
// The theme ink must not come back: it is near-black in light themes.
|
|
30
|
+
expect(path).not.toContain("--color-text");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("the lobes speak a fixed dark-glass face, not the theme surface", () => {
|
|
34
|
+
const lobe = /\.hk-virtual-cursor__lobe \{[\s\S]*?\n\}/.exec(scss)?.[0] ?? "";
|
|
35
|
+
expect(lobe, "the lobe rule is present").not.toBe("");
|
|
36
|
+
expect(lobe).toMatch(/background:\s*rgb\(0 0 0 \//);
|
|
37
|
+
expect(lobe).toMatch(/color:\s*rgb\(255 255 255/);
|
|
38
|
+
expect(lobe, "no theme surface on the remote face").not.toContain("--color-background");
|
|
39
|
+
expect(lobe, "no theme ink on the remote face").not.toContain("--color-text");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -28,9 +28,16 @@
|
|
|
28
28
|
filter: drop-shadow(0 1px 2px rgb(0 0 0 / 55%));
|
|
29
29
|
pointer-events: none;
|
|
30
30
|
|
|
31
|
+
/* The glyph rides a REMOTE-SCREEN surface, which is dark in every
|
|
32
|
+
* app theme (the HkTerminal doctrine: a remote canvas does not follow
|
|
33
|
+
* the page palette). Theme ink is therefore wrong here: in a light
|
|
34
|
+
* theme --color-text is near-black, and the pointer vanished against
|
|
35
|
+
* the black screen (measured: computed fill rgb(30 30 30) over
|
|
36
|
+
* #0b0d12 → effectively invisible). Fixed light ink + dark outline
|
|
37
|
+
* keeps the pointer legible on both dark and light remote content. */
|
|
31
38
|
path {
|
|
32
|
-
fill: rgb(
|
|
33
|
-
stroke: rgb(0 0 0 /
|
|
39
|
+
fill: rgb(255 255 255 / 96%);
|
|
40
|
+
stroke: rgb(0 0 0 / 70%);
|
|
34
41
|
stroke-width: 1;
|
|
35
42
|
}
|
|
36
43
|
}
|
|
@@ -45,9 +52,13 @@
|
|
|
45
52
|
place-items: center;
|
|
46
53
|
width: 30px;
|
|
47
54
|
height: 24px;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
/* Same doctrine as the arrow: the lobes ride the remote screen, not
|
|
56
|
+
* the page, so they speak a fixed dark-glass face (a theme-tinted
|
|
57
|
+
* pill vanishes on the remote black in dark themes and glares in
|
|
58
|
+
* light ones). Held state keeps the brand accent. */
|
|
59
|
+
border: 1px solid rgb(255 255 255 / 28%);
|
|
60
|
+
background: rgb(0 0 0 / 55%);
|
|
61
|
+
color: rgb(255 255 255 / 92%);
|
|
51
62
|
border-radius: 8px;
|
|
52
63
|
vertical-align: top;
|
|
53
64
|
cursor: pointer;
|
|
@@ -72,9 +83,9 @@
|
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
&[data-held] {
|
|
75
|
-
background: rgb(var(--color-primary) /
|
|
86
|
+
background: rgb(var(--color-primary) / 85%);
|
|
76
87
|
border-color: rgb(var(--color-primary));
|
|
77
|
-
color: rgb(
|
|
88
|
+
color: rgb(255 255 255);
|
|
78
89
|
|
|
79
90
|
&::after {
|
|
80
91
|
opacity: 1;
|