@celestia-island/hikari 0.55.441 → 0.55.445
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 +1 -1
- package/src/components/HkAdminHeader.tsx +12 -14
- package/src/components/HkAdminShell.tsx +9 -3
- package/src/components/HkAvatar.test.tsx +107 -0
- package/src/components/HkAvatar.tsx +8 -2
- package/src/components/HkAvatarButton.test.tsx +69 -0
- package/src/components/HkAvatarButton.tsx +7 -10
- package/src/components/HkDebugFloat.scss +21 -0
- package/src/components/HkDebugFloat.test.tsx +95 -0
- package/src/components/HkDebugFloat.tsx +54 -12
- package/src/components/HkDeleteGateWindow.test.ts +22 -9
- package/src/components/HkMenuIdentityItem.test.tsx +88 -0
- package/src/components/HkMenuIdentityItem.tsx +11 -2
- package/src/components/HkThemeToggle.test.ts +5 -2
- package/src/components/avatarImage.ts +50 -0
- package/src/composables/useActionBar.test.ts +303 -0
- package/src/composables/useActionBar.ts +164 -21
- package/src/index.ts +2 -2
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import { inject, onScopeDispose, provide, ref, type VNode } from "vue";
|
|
1
|
+
import { computed, inject, onScopeDispose, provide, ref, type Ref, type VNode } from "vue";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Unified page action bar.
|
|
5
5
|
*
|
|
6
|
-
* A layout (`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* A layout (`HkAdminShell`) calls `provideActionBar()` once and renders
|
|
7
|
+
* `actions.value` (top-right buttons) and `center.value` (the header
|
|
8
|
+
* centre group) in its header. Any descendant view then registers its own
|
|
9
|
+
* top-bar buttons (filter trigger, refresh, add, search, …) via
|
|
10
|
+
* `useActionBar().setActions(() => [...], slot)` in its setup — the header
|
|
11
|
+
* updates reactively. Registrations are ADDITIVE and render in SLOT order:
|
|
12
|
+
* a page that registers its filter trigger and then its refresh still gets
|
|
13
|
+
* [filter][refresh] left-to-right in the header (the user direction:
|
|
14
|
+
* 筛选在刷新左边;没有刷新就在主题按钮左边).
|
|
11
15
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* **Slot ordering (2026-10-11 standardization)**: registrations declare
|
|
17
|
+
* their PURPOSE slot; the cluster renders canonical slots by rank
|
|
18
|
+
* ([create][filter][search][refresh][window]) and customs after them,
|
|
19
|
+
* stuffed right-to-left in join order — see PageActionSlot below. The
|
|
20
|
+
* registration CALL ORDER no longer influences the cluster. The grammar's
|
|
21
|
+
* normative home (slot order, ranks, exempt edges) is the design doc
|
|
22
|
+
* `design/page-chrome.md` (nine locales); the rank table below is its
|
|
23
|
+
* runtime mirror.
|
|
17
24
|
*
|
|
18
25
|
* **Why a render function, not VNodes?** VNodes are single-use: once Vue
|
|
19
26
|
* patches them into the DOM, re-using the same VNode object on the next
|
|
@@ -21,19 +28,125 @@ import { inject, onScopeDispose, provide, ref, type VNode } from "vue";
|
|
|
21
28
|
* the first time but not after a re-render). Storing a function that returns
|
|
22
29
|
* fresh VNodes ensures each render cycle gets a clean set with intact
|
|
23
30
|
* event handlers.
|
|
31
|
+
*
|
|
32
|
+
* **The centre slot** (2026-09-28): the second header zone pages can own —
|
|
33
|
+
* a filter / mode button group rendered in the header's true centre, the
|
|
34
|
+
* console face of the chat frontend's top-centre tab strip (报告审阅 /
|
|
35
|
+
* 节点概览 / 历史记录). Same registration contract, same per-scope
|
|
36
|
+
* lifetime: a view whose filter is a small closed enum renders it there
|
|
37
|
+
* (HkTabs segmented) instead of a filter card inside the page body.
|
|
38
|
+
*
|
|
39
|
+
* Readout-style header zones (a left-wing HUD cluster) are host-side
|
|
40
|
+
* extensions, not part of this contract: this module exposes only the
|
|
41
|
+
* right cluster and the centre slot.
|
|
24
42
|
*/
|
|
25
43
|
|
|
26
44
|
/** A function that produces fresh VNodes for the action bar on each render. */
|
|
27
45
|
export type ActionBarRenderer = () => VNode[];
|
|
28
46
|
|
|
47
|
+
/**
|
|
48
|
+
* The canonical top-right cluster slots (2026-10-11 standardization, user
|
|
49
|
+
* direction): every button declares its PURPOSE, and the cluster renders
|
|
50
|
+
* by the slot's canonical rank — [create][filter][search][refresh][window]
|
|
51
|
+
* — regardless of registration order. A button whose purpose is not in
|
|
52
|
+
* the enum is a CUSTOM slot: customs ride AFTER the canonical ranks,
|
|
53
|
+
* stuffed 由右往左 — the zone's right edge (adjacent to the global
|
|
54
|
+
* search) takes the FIRST-registered custom, the next one lands to its
|
|
55
|
+
* LEFT — so the enum zone never gets displaced and customs never
|
|
56
|
+
* interleave with it.
|
|
57
|
+
*
|
|
58
|
+
* Adding a canonical purpose = add the key here AND its rank in
|
|
59
|
+
* SLOT_RANK below (one place, test-pinned); everything else registers as
|
|
60
|
+
* its own custom slot string and inherits the stuffing rule.
|
|
61
|
+
*/
|
|
62
|
+
export const PageActionSlot = {
|
|
63
|
+
/** The page's primary create action (the plus). */
|
|
64
|
+
Create: "create",
|
|
65
|
+
/** The page's filter trigger. */
|
|
66
|
+
Filter: "filter",
|
|
67
|
+
/** The page's search trigger (the list scaffold's keyword panel;
|
|
68
|
+
* canonical since the scaffold landed — the old per-page
|
|
69
|
+
* "Search = refetch" buttons rode custom slots). */
|
|
70
|
+
Search: "search",
|
|
71
|
+
/** The page's refresh. */
|
|
72
|
+
Refresh: "refresh",
|
|
73
|
+
/** A page's secondary-window opener (2026-11-04 user direction): an
|
|
74
|
+
* icon button that opens a window/panel holding dynamic content the
|
|
75
|
+
* page must NOT expand inline (凭据、部署助手等一切动态内容都收下一级
|
|
76
|
+
* 的窗口内). The window itself stays the page's own (HkAdaptiveDialog);
|
|
77
|
+
* only the OPENING affordance is header chrome. */
|
|
78
|
+
Window: "window",
|
|
79
|
+
} as const;
|
|
80
|
+
export type PageActionSlotValue = (typeof PageActionSlot)[keyof typeof PageActionSlot];
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Canonical ranks — lower renders further LEFT. This is the ONE ranking
|
|
84
|
+
* table (runtime mirror of the page-chrome grammar). Deliberately NOT
|
|
85
|
+
* exported: consumers order through `orderActionRegistrations` and pin
|
|
86
|
+
* the order in tests, so adding a canonical purpose stays a two-line
|
|
87
|
+
* change (key above + rank here) with the test suite as the tripwire.
|
|
88
|
+
*/
|
|
89
|
+
const SLOT_RANK: Record<string, number> = {
|
|
90
|
+
[PageActionSlot.Create]: 0,
|
|
91
|
+
[PageActionSlot.Filter]: 1,
|
|
92
|
+
[PageActionSlot.Search]: 2,
|
|
93
|
+
[PageActionSlot.Refresh]: 3,
|
|
94
|
+
[PageActionSlot.Window]: 4,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** A setActions registration: the renderer plus its declared slot. */
|
|
98
|
+
export interface ActionBarRegistration {
|
|
99
|
+
renderer: ActionBarRenderer;
|
|
100
|
+
/** The button's purpose — a canonical PageActionSlot or a custom
|
|
101
|
+
* string; REQUIRED for every registration (the ordering key). */
|
|
102
|
+
slot: string;
|
|
103
|
+
/** Registration sequence (disambiguates same-slot entries). */
|
|
104
|
+
seq: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Sort registrations into render order: canonical slots by rank; customs
|
|
109
|
+
* after them, stuffed right-to-left (first-registered = rightmost, so
|
|
110
|
+
* the customs zone grows LEFTWARD — reverse registration order).
|
|
111
|
+
* Exported pure for the unit pin.
|
|
112
|
+
*/
|
|
113
|
+
export function orderActionRegistrations(regs: ActionBarRegistration[]): ActionBarRegistration[] {
|
|
114
|
+
const canonical = regs
|
|
115
|
+
.filter((r) => r.slot in SLOT_RANK)
|
|
116
|
+
.sort((a, b) => SLOT_RANK[a.slot] - SLOT_RANK[b.slot] || a.seq - b.seq);
|
|
117
|
+
const customs = regs.filter((r) => !(r.slot in SLOT_RANK)).sort((a, b) => b.seq - a.seq);
|
|
118
|
+
return [...canonical, ...customs];
|
|
119
|
+
}
|
|
120
|
+
|
|
29
121
|
interface ActionBarContext {
|
|
30
|
-
|
|
122
|
+
/** Every registered top-right entry (renderer + declared slot); the
|
|
123
|
+
* public `actions` computed serves them in SLOT order — a page may
|
|
124
|
+
* own SEVERAL (create, filter trigger, refresh, customs), and the
|
|
125
|
+
* order no longer depends on the composable call sequence. */
|
|
126
|
+
actionRegistrations: Ref<ActionBarRegistration[]>;
|
|
127
|
+
/** Per-PROVIDER registration sequence — one counter for every scope
|
|
128
|
+
* sharing this bar, so cross-component customs tie on nothing (the
|
|
129
|
+
* stuffing rule's seq comparison must be globally monotonic). */
|
|
130
|
+
nextSeq: () => number;
|
|
131
|
+
/** Ordered renderers (what the header renders) — derived. */
|
|
132
|
+
actions: Ref<ActionBarRenderer[]>;
|
|
133
|
+
center: Ref<ActionBarRenderer | null>;
|
|
31
134
|
}
|
|
32
135
|
|
|
33
136
|
const KEY = Symbol("action-bar");
|
|
34
137
|
|
|
35
138
|
export function provideActionBar() {
|
|
36
|
-
const
|
|
139
|
+
const actionRegistrations = ref<ActionBarRegistration[]>([]);
|
|
140
|
+
let seqCounter = 0;
|
|
141
|
+
const nextSeq = () => seqCounter++;
|
|
142
|
+
const ctx: ActionBarContext = {
|
|
143
|
+
actionRegistrations,
|
|
144
|
+
nextSeq,
|
|
145
|
+
actions: computed(() =>
|
|
146
|
+
orderActionRegistrations(actionRegistrations.value).map((r) => r.renderer),
|
|
147
|
+
),
|
|
148
|
+
center: ref<ActionBarRenderer | null>(null),
|
|
149
|
+
};
|
|
37
150
|
provide(KEY, ctx);
|
|
38
151
|
return ctx;
|
|
39
152
|
}
|
|
@@ -41,26 +154,56 @@ export function provideActionBar() {
|
|
|
41
154
|
export function useActionBar() {
|
|
42
155
|
const ctx = inject<ActionBarContext | null>(KEY, null);
|
|
43
156
|
if (!ctx) {
|
|
44
|
-
// No provider (e.g. outside any layout) —
|
|
157
|
+
// No provider (e.g. outside any layout) — inert refs keep the
|
|
158
|
+
// return type uniform (consumers read `actions.value` without
|
|
159
|
+
// null-narrowing), while the setters stay silent no-ops.
|
|
45
160
|
return {
|
|
46
|
-
setActions: (_renderer: ActionBarRenderer) => {},
|
|
161
|
+
setActions: (_renderer: ActionBarRenderer, _slot: string) => {},
|
|
47
162
|
clearActions: () => {},
|
|
163
|
+
actions: ref<ActionBarRenderer[]>([]),
|
|
164
|
+
setCenter: (_renderer: ActionBarRenderer) => {},
|
|
165
|
+
clearCenter: () => {},
|
|
166
|
+
center: ref<ActionBarRenderer | null>(null),
|
|
48
167
|
};
|
|
49
168
|
}
|
|
50
169
|
return {
|
|
51
|
-
setActions: (renderer: ActionBarRenderer) => {
|
|
52
|
-
|
|
170
|
+
setActions: (renderer: ActionBarRenderer, slot: string) => {
|
|
171
|
+
// ADDITIVE registration: a page composes several buttons (create,
|
|
172
|
+
// filter trigger, refresh, customs) by calling this once per
|
|
173
|
+
// affordance, each declaring its PURPOSE slot — the cluster's
|
|
174
|
+
// render order comes from the slot ranks, never the call
|
|
175
|
+
// sequence. The identity guard keeps the dispose of one
|
|
176
|
+
// registration (a crossfade overlap, an unmount) from clearing
|
|
177
|
+
// its siblings.
|
|
178
|
+
if (!ctx.actionRegistrations.value.some((r) => r.renderer === renderer)) {
|
|
179
|
+
ctx.actionRegistrations.value = [
|
|
180
|
+
...ctx.actionRegistrations.value,
|
|
181
|
+
{ renderer, slot, seq: ctx.nextSeq() },
|
|
182
|
+
];
|
|
183
|
+
}
|
|
53
184
|
// Auto-clear when this view's effect scope dies so buttons never
|
|
54
185
|
// outlive the page that registered them.
|
|
55
186
|
onScopeDispose(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
187
|
+
ctx.actionRegistrations.value = ctx.actionRegistrations.value.filter(
|
|
188
|
+
(r) => r.renderer !== renderer,
|
|
189
|
+
);
|
|
59
190
|
});
|
|
60
191
|
},
|
|
61
192
|
clearActions: () => {
|
|
62
|
-
ctx.
|
|
193
|
+
ctx.actionRegistrations.value = [];
|
|
63
194
|
},
|
|
64
195
|
actions: ctx.actions,
|
|
196
|
+
setCenter: (renderer: ActionBarRenderer) => {
|
|
197
|
+
ctx.center.value = renderer;
|
|
198
|
+
onScopeDispose(() => {
|
|
199
|
+
if (ctx.center.value === renderer) {
|
|
200
|
+
ctx.center.value = null;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
clearCenter: () => {
|
|
205
|
+
ctx.center.value = null;
|
|
206
|
+
},
|
|
207
|
+
center: ctx.center,
|
|
65
208
|
};
|
|
66
209
|
}
|
package/src/index.ts
CHANGED
|
@@ -679,8 +679,8 @@ export {
|
|
|
679
679
|
type HkMfaFactor as MfaFactor,
|
|
680
680
|
} from "./components/HkMfaVerifyCard";
|
|
681
681
|
export { usePageTitle, useRouteTitle } from "./composables/usePageTitle";
|
|
682
|
-
export { provideActionBar, useActionBar } from "./composables/useActionBar";
|
|
683
|
-
export type { ActionBarRenderer } from "./composables/useActionBar";
|
|
682
|
+
export { provideActionBar, useActionBar, PageActionSlot, orderActionRegistrations } from "./composables/useActionBar";
|
|
683
|
+
export type { ActionBarRenderer, PageActionSlotValue, ActionBarRegistration } from "./composables/useActionBar";
|
|
684
684
|
export { useChromeActionSize } from "./composables/useChromeActionSize";
|
|
685
685
|
export { leadingZeroBits, sha256, solvePow, solvePowSync, verifyPow } from "./utils/pow";
|
|
686
686
|
export type { PowChallenge, PowSolution } from "./utils/pow";
|