@celestia-island/hikari 0.55.514 → 0.55.516

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.
@@ -46,6 +46,22 @@ export interface HkLoginCredentialsChannel {
46
46
  * only offers Feishu): the card renders the standard channel list —
47
47
  * one full-width row naming the destination — and `sso-click` sends
48
48
  * the host off to build its OAuth URL. */
49
+ /** One provider row inside a multi-provider sso channel: the same row
50
+ * shape HkAuthChannelList renders, named by the provider's funnel key
51
+ * (the `methods[].id` the deployment descriptor publishes — "github",
52
+ * "qq", "feishu", …). */
53
+ export interface HkLoginSsoProvider {
54
+ key: string;
55
+ /** The row's visible name (e.g. 「GitHub 登录」). */
56
+ label: string;
57
+ /** Prebuilt icon vnode for the row's left mark. */
58
+ icon?: unknown;
59
+ disabled?: boolean;
60
+ /** Navigation target (the funnel's entry path); the host still
61
+ * receives `provider-select` first and the navigation is not
62
+ * prevented. Default undefined — the host navigates itself. */
63
+ href?: string;
64
+ }
49
65
  export interface HkLoginSsoChannel {
50
66
  key: string;
51
67
  mode: "sso";
@@ -64,6 +80,15 @@ export interface HkLoginSsoChannel {
64
80
  * prevented). Default undefined — the row is a button and the host
65
81
  * navigates on `sso-click`, as before. */
66
82
  href?: string;
83
+ /** Multi-provider body (2026-11-29 user direction): the segment group
84
+ * switches SOURCES ("Celestia 云 / 第三方认证") and this channel's
85
+ * body lists every third-party funnel as one full-width row each,
86
+ * in display order. The rows are the channel list form — the body
87
+ * IS the list, never rows stacked under a form. When present it
88
+ * replaces the single `icon`/`buttonLabel` row; `sso-click` stays
89
+ * for the single-provider shape, and picking a row emits
90
+ * `provider-select` with (channel key, provider key). */
91
+ providers?: HkLoginSsoProvider[];
67
92
  }
68
93
  export type HkLoginChannel = HkLoginCredentialsChannel | HkLoginSsoChannel;
69
94
  /**
@@ -270,6 +295,7 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
270
295
  "update:modelValue": (_key: string) => true;
271
296
  "account-submit": (_channel: string, _username: string, _password: string) => true;
272
297
  "sso-click": (_channel: string) => true;
298
+ "provider-select": (_channel: string, _provider: string) => true;
273
299
  verify: (_kind: HkMfaFactor, _proof: string) => true;
274
300
  "verify-resend": () => true;
275
301
  "verify-back": () => true;
@@ -379,6 +405,7 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
379
405
  onVerify?: ((_kind: "password" | "passkey" | "totp" | "sms", _proof: string) => any) | undefined;
380
406
  "onAccount-submit"?: ((_channel: string, _username: string, _password: string) => any) | undefined;
381
407
  "onSso-click"?: ((_channel: string) => any) | undefined;
408
+ "onProvider-select"?: ((_channel: string, _provider: string) => any) | undefined;
382
409
  "onVerify-resend"?: (() => any) | undefined;
383
410
  "onVerify-back"?: (() => any) | undefined;
384
411
  }>, {
@@ -498,6 +498,7 @@ export { HkLoginFlow as HkLoginFlow } from "./components/HkLoginFlow";
498
498
  export { type HkLoginChannel as HkLoginChannel } from "./components/HkLoginFlow";
499
499
  export { type HkLoginCredentialsChannel as HkLoginCredentialsChannel } from "./components/HkLoginFlow";
500
500
  export { type HkLoginSsoChannel as HkLoginSsoChannel } from "./components/HkLoginFlow";
501
+ export { type HkLoginSsoProvider as HkLoginSsoProvider } from "./components/HkLoginFlow";
501
502
  export { HkAuthSsoButton as HkAuthSsoButton } from "./components/HkAuthSsoButton";
502
503
  export { HkAuthChannelList as HkAuthChannelList } from "./components/HkAuthChannelList";
503
504
  export { type HkAuthChannelListEntry as HkAuthChannelListEntry } from "./components/HkAuthChannelList";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.514",
3
+ "version": "0.55.516",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -45,8 +45,8 @@ afterEach(() => {
45
45
  container.remove();
46
46
  }
47
47
  vi.useRealTimers();
48
- // The rAF spies restore in their tests' finally blocks; this is the
49
- // net for an assertion that throws before the finally runs.
48
+ // The net for spies whose finally did not run (an assertion throwing
49
+ // first): restore every mock left behind.
50
50
  vi.restoreAllMocks();
51
51
  });
52
52
 
@@ -172,22 +172,31 @@ describe("HkDirectionalSwap", () => {
172
172
  // ── animateHeight (opt-in height tween) ─────────────────────────────
173
173
  // happy-dom has no layout engine: every offsetHeight reads 0, so the
174
174
  // tween (freeze a rendered height, step to a target) runs against
175
- // STUBBED heights — without a stub the zero-guard skips the whole
176
- // tween and every assertion would pass for the wrong reason. The
177
- // exchange's hooks resolve on animation frames in this DOM (no real
178
- // CSS transitions), so every wait is CONDITION-based, never
179
- // tick-counted: a fixed wait reads an undefined-order middle state
180
- // (R1 S0-1 — the release assertion raced the resolve frame 6/8 runs).
181
-
182
- /** Shadow offsetHeight for the swap's two element kinds. Returns the
183
- * restore thunk. Host height is a getter so a test can move it to a
184
- * "mid-tween" value between swaps. */
175
+ // STUBBED heights — without a stub the unreadable-height guard skips
176
+ // the whole tween and every assertion would pass for the wrong reason.
177
+ // The tween's writes are SYNCHRONOUS inside the enter hook (no
178
+ // animation frames by design — frames starve in background tabs and
179
+ // automation), so armed-and-targeted is observable one tick after the
180
+ // swap and released after the exchange's settle.
181
+
182
+ /** The host's offsetHeight READ COUNT under the current stubLayout —
183
+ * reset on every install. The tween's forced layout (the flush between
184
+ * its freeze and its target) is one extra host read, so a pin can
185
+ * require it: R4's M-no-flush (deleting `void host.offsetHeight`) was
186
+ * invisible to every read-based pin because a constant stub reads the
187
+ * same however many times. */
188
+ const hostReads = { count: 0 };
189
+
190
+ /** Shadow offsetHeight for the swap's two element kinds (host reads are
191
+ * counted into `hostReads`). Returns the restore thunk. */
185
192
  function stubLayout(hostH: () => number, itemH: () => number): () => void {
186
193
  const proto = HTMLElement.prototype;
187
194
  const shadow = Object.getOwnPropertyDescriptor(proto, "offsetHeight");
195
+ hostReads.count = 0;
188
196
  Object.defineProperty(proto, "offsetHeight", {
189
197
  configurable: true,
190
198
  get(this: HTMLElement) {
199
+ if (!this.classList.contains("hk-dswap-item")) hostReads.count += 1;
191
200
  return this.classList.contains("hk-dswap-item") ? itemH() : hostH();
192
201
  },
193
202
  });
@@ -197,11 +206,43 @@ describe("HkDirectionalSwap", () => {
197
206
  };
198
207
  }
199
208
 
200
- /** Drive animation frames until `cond` holds; assert on failure so a
201
- * stuck wait names itself instead of timing out silently. happy-dom
202
- * resolves transitions within a frame or two; the small budget is
203
- * margin for a real browser's asynchronous rAF — it is NOT expected
204
- * to spin long. */
209
+ /** Shadow the STYLE object's height setter on one element and record
210
+ * every write. happy-dom's height reads are all-equivalent (no
211
+ * layout), so "did the tween actually write the freeze and the
212
+ * target" is observable ONLY through the writes themselves — the R1
213
+ * M10 killer: an implementation that arms the attribute and never
214
+ * writes a single height passed every read-based pin. Returns
215
+ * { writes, restore }. */
216
+ function spyHeightWrites(
217
+ el: HTMLElement,
218
+ onWrite?: () => void,
219
+ ): { writes: string[]; restore: () => void } {
220
+ const writes: string[] = [];
221
+ const desc = Object.getOwnPropertyDescriptor(CSSStyleDeclaration.prototype, "height")!;
222
+ Object.defineProperty(el.style, "height", {
223
+ configurable: true,
224
+ get() {
225
+ return desc.get!.call(this);
226
+ },
227
+ set(v: string) {
228
+ writes.push(v);
229
+ onWrite?.();
230
+ desc.set!.call(this, v);
231
+ },
232
+ });
233
+ return {
234
+ writes,
235
+ restore: () => {
236
+ delete (el.style as unknown as Record<string, unknown>).height;
237
+ },
238
+ };
239
+ }
240
+
241
+ const descGet = Object.getOwnPropertyDescriptor(CSSStyleDeclaration.prototype, "height")!.get!;
242
+ const descSet = Object.getOwnPropertyDescriptor(CSSStyleDeclaration.prototype, "height")!.set!;
243
+
244
+ /** Drive microtasks/frames until `cond` holds; assert on failure so a
245
+ * stuck wait names itself instead of timing out silently. */
205
246
  async function until(cond: () => boolean, label: string): Promise<void> {
206
247
  for (let i = 0; i < 5 && !cond(); i += 1) {
207
248
  await new Promise((r) => requestAnimationFrame(() => r(null)));
@@ -217,6 +258,12 @@ describe("HkDirectionalSwap", () => {
217
258
  // armed-guard in endHeightAnimation (R1 S1-1: an unconditional release
218
259
  // erased a host's own inline height on a default-off instance).
219
260
  it("keeps the snap and preserves a host-set height when animateHeight is off (default)", async () => {
261
+ // Bare fake timers (rAF included): the exchange resolves through
262
+ // them deterministically — a REAL settle yields to the event loop and
263
+ // lets real rAF frames race the erase, which R2 N2 measured at a
264
+ // ~36% miss. We inject a real resolve point into the exchange via
265
+ // the fake clock instead.
266
+ vi.useFakeTimers();
220
267
  const restore = stubLayout(() => 100, () => 240);
221
268
  try {
222
269
  const key = ref("preview");
@@ -225,7 +272,7 @@ describe("HkDirectionalSwap", () => {
225
272
  const app = createApp({ render: () => h(HkDirectionalSwap, { swapKey: key.value }, () => [h("p", key.value)]) });
226
273
  app.mount(container);
227
274
  mounts.push({ app, container });
228
- await settle();
275
+ await vi.advanceTimersByTimeAsync(0);
229
276
  const host = container.querySelector<HTMLElement>(".hk-dswap")!;
230
277
  // The host's own inline height (its business, not ours).
231
278
  host.style.height = "42px";
@@ -233,21 +280,29 @@ describe("HkDirectionalSwap", () => {
233
280
  await nextTick();
234
281
  await nextTick();
235
282
  expect(host.hasAttribute("data-height-anim")).toBe(false);
236
- await until(() => !host.hasAttribute("data-height-anim"), "stayed unarmed");
283
+ // Advance past the exchange's resolution timer: the after-hooks
284
+ // fire (they fire on every exchange, prop on or off) — with the
285
+ // armed-guard deleted the release erases the host's own height
286
+ // HERE, after the wait, and this pin goes red.
287
+ await vi.advanceTimersByTimeAsync(1600);
288
+ expect(host.hasAttribute("data-height-anim")).toBe(false);
237
289
  expect(host.style.height).toBe("42px");
238
290
  } finally {
239
291
  restore();
292
+ vi.useRealTimers();
240
293
  }
241
294
  });
242
295
 
243
- // MUT:swap-height-anim-arms — with the prop the exchange freezes at
244
- // the CURRENT height (distinct from the target: a sync-write mutation
245
- // that skips the freeze/target split lands the target immediately and
246
- // turns the first assertion red), steps to the target on a later
247
- // frame, and releases to auto on settle. The post-release frame pins
248
- // the re-entry guard: a stale target frame must not resurrect a
249
- // released height (R1 M3 — deleting the guard survived every test).
250
- it("freezes at the current height, steps to the target, releases, and never resurrects", async () => {
296
+ // MUT:swap-height-anim-arms — with the prop the exchange arms the tween
297
+ // and lands the incoming generation's height SYNCHRONOUSLY (the forced
298
+ // layout between the freeze and this write is what makes them a
299
+ // before/after pair — the freeze itself is same-tick and
300
+ // unobservable from outside), then releases to auto on settle. A
301
+ // regression that never writes the target leaves the frozen start
302
+ // value behind and turns the mid assertion red; a regression that
303
+ // skips the freeze turns the release semantics red (nothing armed →
304
+ // nothing to release → the host keeps whatever it had).
305
+ it("arms the tween, lands the incoming height, and releases on settle", async () => {
251
306
  const restore = stubLayout(() => 100, () => 240);
252
307
  try {
253
308
  const key = ref("preview");
@@ -260,39 +315,49 @@ describe("HkDirectionalSwap", () => {
260
315
  mounts.push({ app, container });
261
316
  await settle();
262
317
  const host = container.querySelector<HTMLElement>(".hk-dswap")!;
318
+ const readsAtWrite: number[] = [];
319
+ const { writes, restore: unspy } = spyHeightWrites(host, () => {
320
+ readsAtWrite.push(hostReads.count);
321
+ });
322
+ expect(host.hasAttribute("data-height-anim")).toBe(false);
323
+ hostReads.count = 0;
263
324
  key.value = "source";
264
325
  await nextTick();
265
326
  await nextTick();
266
- // Frozen at the CURRENT height, pre-frame.
327
+ // Mid-exchange: the tween armed and BOTH writes landed, in order:
328
+ // freeze at the current height (100px), then the target (240px).
329
+ // An implementation that arms but never writes (R1 M10: both
330
+ // writes deleted, every read-based pin green) writes nothing and
331
+ // turns this red; freeze-only writes one entry (R1 M2).
267
332
  expect(host.hasAttribute("data-height-anim")).toBe(true);
268
- expect(host.style.height).toBe("100px");
269
- // The target write rides the next animation frame.
270
- await until(() => host.style.height === "240px", "target height applied on a frame");
333
+ expect(writes).toEqual(["100px", "240px"]);
334
+ // MUT:swap-height-flush — the forced layout BETWEEN the two writes
335
+ // is what establishes the freeze as the transition's before-value.
336
+ // The two writes are synchronous neighbours, so nothing else can
337
+ // read the host between them: the read count MUST advance between
338
+ // the freeze and the target. R4's M-no-flush (deleting the flush)
339
+ // left the two counts equal and passed every read-based pin.
340
+ expect(readsAtWrite).toHaveLength(2);
341
+ expect(
342
+ readsAtWrite[1],
343
+ "the host must be re-read between the freeze and the target (the forced layout)",
344
+ ).toBeGreaterThan(readsAtWrite[0]);
271
345
  await until(() => !host.hasAttribute("data-height-anim"), "released on settle");
272
346
  expect(host.style.height).toBe("");
273
- // One more frame: the released state must hold (no resurrection).
274
- await until(() => !host.hasAttribute("data-height-anim") && host.style.height === "", "release holds across a frame");
347
+ // The released state holds across further ticks.
348
+ await until(() => !host.hasAttribute("data-height-anim") && host.style.height === "", "release holds");
349
+ unspy();
275
350
  } finally {
276
351
  restore();
277
352
  }
278
353
  });
279
354
 
280
- // MUT:swap-height-followup-current — a faster follow-up swap arrives
281
- // AFTER Vue cancelled the interrupted enter (the release runs, then the
282
- // fresh exchange begins): its freeze must read the cell's CURRENT
283
- // rendered height via offsetHeight — never a remembered start value.
284
- // The moving `current` stub stands in for the live layout height this
285
- // DOM cannot compute; a stale start (100) instead of the live height
286
- // (150) turns the mid assertion red. Frames are held so the window is
287
- // deterministic.
288
- it("freezes a follow-up exchange at the current rendered height, not the old start", async () => {
289
- let current = 100;
290
- const frames: FrameRequestCallback[] = [];
291
- const raf = vi.spyOn(globalThis, "requestAnimationFrame").mockImplementation((cb: FrameRequestCallback) => {
292
- frames.push(cb);
293
- return frames.length;
294
- });
295
- const restore = stubLayout(() => current, () => 240);
355
+ // MUT:swap-height-zero-skips — an unreadable height (hidden host, or
356
+ // an incoming pane not yet laid out reports 0) skips the tween: a
357
+ // 0px freeze would collapse the surface for the whole exchange and
358
+ // the release would depend on a frame. The snap is the safe face.
359
+ it("does not arm when either height is unreadable (0)", async () => {
360
+ const restore = stubLayout(() => 0, () => 240);
296
361
  try {
297
362
  const key = ref("preview");
298
363
  const container = document.createElement("div");
@@ -304,41 +369,31 @@ describe("HkDirectionalSwap", () => {
304
369
  mounts.push({ app, container });
305
370
  await settle();
306
371
  const host = container.querySelector<HTMLElement>(".hk-dswap")!;
307
- // First exchange: frozen at 100, no frame runs yet.
308
372
  key.value = "source";
309
373
  await nextTick();
310
374
  await nextTick();
311
- expect(host.hasAttribute("data-height-anim")).toBe(true);
312
- expect(host.style.height).toBe("100px");
313
- // Mid-flight: the rendered height has tweened partway (the CSS
314
- // tween this DOM cannot express). The follow-up swap must freeze
315
- // HERE — the frames are still held, so the first exchange cannot
316
- // have released and masked the re-freeze.
317
- current = 150;
318
- key.value = "preview";
319
- await nextTick();
320
- await nextTick();
321
- expect(host.hasAttribute("data-height-anim")).toBe(true);
322
- expect(host.style.height).toBe("150px");
323
- // The world resumes: frames flush, the second exchange reaches
324
- // its own target.
325
- for (let round = 0; round < 6 && host.style.height !== "240px"; round += 1) {
326
- for (const cb of frames.splice(0)) cb(performance.now());
327
- await nextTick();
328
- }
329
- expect(host.style.height).toBe("240px");
375
+ expect(host.hasAttribute("data-height-anim")).toBe(false);
376
+ expect(host.style.height).toBe("");
330
377
  } finally {
331
- raf.mockRestore();
332
378
  restore();
333
379
  }
334
380
  });
335
381
 
336
- // MUT:swap-height-zero-skips — an unreadable height (hidden host, or
337
- // an incoming pane not yet laid out reports 0) skips the tween: a
338
- // 0px freeze would collapse the surface for the whole exchange and
339
- // the release would depend on a frame. The snap is the safe face.
340
- it("does not arm when either height is unreadable (0)", async () => {
341
- const restore = stubLayout(() => 0, () => 240);
382
+ // MUT:swap-height-reduced-snap — reduced motion (duration 0) skips the
383
+ // freeze entirely: the instant change is the preference, so the tween
384
+ // never arms and never writes a single height (R2 N1: this pin was
385
+ // lost in the sync-write rewrite and a deletion of the reduced-motion
386
+ // early-return passed the whole suite). The stub keeps the heights
387
+ // readable so the skip is attributable to the DURATION path alone.
388
+ it("does not arm or write any height under reduced motion", async () => {
389
+ const restore = stubLayout(() => 100, () => 240);
390
+ const writes: string[] = [];
391
+ const original = window.matchMedia;
392
+ Object.defineProperty(window, "matchMedia", {
393
+ configurable: true,
394
+ value: (q: string) => ({ matches: q.includes("reduced"), media: q, addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {}, dispatchEvent: () => false, onchange: null }),
395
+ });
396
+ const desc = Object.getOwnPropertyDescriptor(CSSStyleDeclaration.prototype, "height")!;
342
397
  try {
343
398
  const key = ref("preview");
344
399
  const container = document.createElement("div");
@@ -350,27 +405,47 @@ describe("HkDirectionalSwap", () => {
350
405
  mounts.push({ app, container });
351
406
  await settle();
352
407
  const host = container.querySelector<HTMLElement>(".hk-dswap")!;
408
+ Object.defineProperty(host.style, "height", {
409
+ configurable: true,
410
+ get() {
411
+ return desc.get!.call(this);
412
+ },
413
+ set(v: string) {
414
+ writes.push(v);
415
+ desc.set!.call(this, v);
416
+ },
417
+ });
353
418
  key.value = "source";
354
419
  await nextTick();
355
420
  await nextTick();
421
+ // The swap itself must not write a height. This write pin speaks
422
+ // FIRST — defensive ordering, so it always runs before an armed-attr
423
+ // assertion that could shadow it; on the current implementation the
424
+ // order does not change the outcome (a duration-0 fallback would
425
+ // fail both), the front position just keeps the write pin audible
426
+ // if that ever changes.
427
+ expect(writes, "no height write at the swap").toEqual([]);
356
428
  expect(host.hasAttribute("data-height-anim")).toBe(false);
357
- expect(host.style.height).toBe("");
429
+ await settle();
430
+ expect(writes, "the reduced-motion path writes nothing").toEqual([]);
358
431
  } finally {
432
+ Object.defineProperty(window, "matchMedia", { configurable: true, value: original });
359
433
  restore();
360
434
  }
361
435
  });
362
436
 
363
- // MUT:swap-height-reduced-snap — reduced motion (duration 0) skips
364
- // the freeze even when both heights ARE readable: the instant change
365
- // is the preference. (The stub matters — without it the zero-guard
366
- // would skip for the wrong reason and the pin would prove nothing.)
367
- it("does not arm the height tween under reduced motion", async () => {
368
- const restore = stubLayout(() => 100, () => 240);
369
- const original = window.matchMedia;
370
- Object.defineProperty(window, "matchMedia", {
371
- configurable: true,
372
- value: (q: string) => ({ matches: q.includes("reduced"), media: q, addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {}, dispatchEvent: () => false, onchange: null }),
373
- });
437
+ // MUT:swap-height-followup-current — a faster follow-up swap arrives
438
+ // AFTER Vue cancelled the interrupted enter (the release runs, then the
439
+ // fresh exchange begins): its freeze must read the cell's CURRENT
440
+ // rendered height via offsetHeight — never a remembered start value.
441
+ // The moving `current` stub stands in for the live layout height this
442
+ // DOM cannot compute; the write sequence pins it exactly: the second
443
+ // exchange writes [150px (its own freeze), 240px (its target)] — a
444
+ // regression that remembers the old start writes [100px, ...] first.
445
+ it("a follow-up exchange freezes at the current rendered height, not the old start", async () => {
446
+ let current = 100;
447
+ const restore = stubLayout(() => current, () => 240);
448
+ const writes: string[] = [];
374
449
  try {
375
450
  const key = ref("preview");
376
451
  const container = document.createElement("div");
@@ -381,38 +456,41 @@ describe("HkDirectionalSwap", () => {
381
456
  app.mount(container);
382
457
  mounts.push({ app, container });
383
458
  await settle();
459
+ const host = container.querySelector<HTMLElement>(".hk-dswap")!;
460
+ Object.defineProperty(host.style, "height", {
461
+ configurable: true,
462
+ get: descGet,
463
+ set(v: string) {
464
+ writes.push(v);
465
+ descSet.call(host.style, v);
466
+ },
467
+ });
468
+ // First exchange.
384
469
  key.value = "source";
385
470
  await nextTick();
386
471
  await nextTick();
387
- const host = container.querySelector<HTMLElement>(".hk-dswap")!;
388
- expect(host.hasAttribute("data-height-anim")).toBe(false);
389
- expect(host.style.height).toBe("");
472
+ // Follow-up swap: Vue cancels the interrupted enter — the release
473
+ // writes "" — then the fresh exchange freezes at the CURRENT
474
+ // stubbed height before its target. The full sequence pins all of
475
+ // it: freeze, target, cancel-release, re-freeze, re-target.
476
+ current = 150;
477
+ key.value = "preview";
478
+ await nextTick();
479
+ await nextTick();
480
+ expect(host.hasAttribute("data-height-anim")).toBe(true);
481
+ expect(writes).toEqual(["100px", "240px", "", "150px", "240px"]);
390
482
  } finally {
391
- Object.defineProperty(window, "matchMedia", { configurable: true, value: original });
392
483
  restore();
393
484
  }
394
485
  });
395
486
 
396
- // MUT:swap-height-watchdog-releases — a wedged engine (no frames run)
397
- // wedges the tween with it: the watchdog must sweep the frozen
398
- // exchange AND release the explicit height, or the surface stays
399
- // frozen at a stale size forever. setTimeout is faked so the watchdog
400
- // fires on advance; rAF is captured manually so no frame lands and
401
- // the stale target frame can be INVOKED after the release — a
402
- // resurrection there (stale target written onto a released host)
403
- // means the release's cancellation and the frame's armed-guard both
404
- // failed together.
405
- it("watchdog releases a wedged height tween, and no stale frame resurrects it", async () => {
487
+ // MUT:swap-height-watchdog-releases — a wedged engine (the exchange
488
+ // never settles) wedges the tween with it: the watchdog must sweep the
489
+ // frozen exchange AND release the explicit height, or the surface
490
+ // stays frozen at a stale size forever. setTimeout is faked so the
491
+ // watchdog fires on advance.
492
+ it("watchdog releases a wedged height tween", async () => {
406
493
  vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
407
- // Queue EVERY rAF request: Vue's own transition frames and the
408
- // tween's target frame all ride rAF, and the last request is not
409
- // necessarily ours — flushing the whole queue post-release is what
410
- // makes a resurrection observable.
411
- const frames: FrameRequestCallback[] = [];
412
- const raf = vi.spyOn(globalThis, "requestAnimationFrame").mockImplementation((cb: FrameRequestCallback) => {
413
- frames.push(cb);
414
- return frames.length;
415
- });
416
494
  const restore = stubLayout(() => 100, () => 240);
417
495
  try {
418
496
  const key = ref("preview");
@@ -423,30 +501,18 @@ describe("HkDirectionalSwap", () => {
423
501
  });
424
502
  app.mount(container);
425
503
  mounts.push({ app, container });
426
- // Fake timers: `settle()`'s setTimeout would never fire on its own.
427
504
  await vi.advanceTimersByTimeAsync(0);
428
505
  const host = container.querySelector<HTMLElement>(".hk-dswap")!;
429
506
  key.value = "source";
430
507
  await nextTick();
431
508
  await nextTick();
432
509
  expect(host.hasAttribute("data-height-anim")).toBe(true);
433
- // No frame ever runs: the exchange wedges. The watchdog fires at
434
- // WATCHDOG_MS + duration and must sweep + release.
510
+ // No settle ever runs (the engine is wedged): the watchdog fires
511
+ // at WATCHDOG_MS + duration and must sweep + release.
435
512
  vi.advanceTimersByTime(1200 + 300 + 100);
436
513
  expect(host.hasAttribute("data-height-anim")).toBe(false);
437
514
  expect(host.style.height).toBe("");
438
- // Now every frame queued before the cleanup lands anyway (a
439
- // browser can fire a rAF queued before a release): the released
440
- // state must hold. Flush repeatedly — each flush may schedule
441
- // new frames (Vue's resolution chain), all of which must stay
442
- // inert against the released host.
443
- for (let round = 0; round < 3; round += 1) {
444
- for (const cb of frames.splice(0)) cb(performance.now());
445
- expect(host.hasAttribute("data-height-anim")).toBe(false);
446
- expect(host.style.height).toBe("");
447
- }
448
515
  } finally {
449
- raf.mockRestore();
450
516
  restore();
451
517
  vi.useRealTimers();
452
518
  }
@@ -170,27 +170,29 @@ export default defineComponent({
170
170
  let watchdog: ReturnType<typeof setTimeout> | null = null;
171
171
 
172
172
  // ── height animation (`animateHeight`) ──────────────────────────────
173
- // Direct DOM on purpose: the freeze must land BEFORE the transition
174
- // rule is on the host, in the same tick the incoming item inserts —
175
- // a reactive attr would arrive with the patch, collapsing the freeze
176
- // and the target into one frame (no transition). The watchdog sweeps
177
- // the same way for the same reason. NOTE for future edits: keep
178
- // `height` OUT of the `hostProps.style` object above — Vue patches
179
- // style keys it rendered, and would silently reset our inline tween
180
- // height on the next render; these writes live outside the vnode on
181
- // purpose.
182
- /** The pending target-write frame, if one is scheduled. It must be
183
- * cancellable: a released (or unmounted) host must not have a stale
184
- * frame re-write a height the cleanup already cleared. */
185
- let targetFrame: number | null = null;
186
-
173
+ // Direct DOM on purpose: the freeze and the target must land around a
174
+ // FORCED LAYOUT, in the same tick the incoming item inserts — a
175
+ // reactive attr would arrive with the patch, collapsing the freeze and
176
+ // the target into one style recalc (no transition). NO animation
177
+ // frames anywhere: a frame-gated target write starves in background
178
+ // tabs, automation and throttled pages (measured — the tween then
179
+ // silently degrades to a snap), while the forced-layout sandwich
180
+ // tweens identically everywhere, on the clock CSS transitions already
181
+ // run on. NOTE for future edits: keep `height` OUT of the
182
+ // `hostProps.style` object above — Vue patches style keys it rendered
183
+ // and would silently reset our inline tween height on the next render;
184
+ // these writes live outside the vnode on purpose.
187
185
  /** Freeze the wrapper at its rendered height, arm the height
188
- * transition, then step to the incoming generation's height on the
189
- * next frame. No-ops when the prop is off, the effective duration is
190
- * zero (reduced motion keeps the snap by design), or either height
191
- * is unreadable (a hidden or not-yet-laid-out surface reports 0 —
192
- * animating to/from 0 would collapse the card; the snap is the safe
193
- * face there, same as reduced motion). */
186
+ * transition, and step to the incoming generation's height — the
187
+ * forced layout between the two writes is what makes them a
188
+ * before/after pair. No-ops when the prop is off, the effective
189
+ * duration is zero (reduced motion keeps the snap by design), or
190
+ * either height is unreadable (a hidden or not-yet-laid-out surface
191
+ * reports 0 — animating to/from 0 would collapse the card; the snap
192
+ * is the safe face there, same as reduced motion). A faster
193
+ * follow-up swap arrives after Vue cancelled the interrupted enter
194
+ * (the release runs), so its freeze reads the cell's CURRENT layout
195
+ * height — the interrupted tween's mid-state — never the old start. */
194
196
  function beginHeightAnimation(incoming: Element): void {
195
197
  if (!props.animateHeight) return;
196
198
  if (motionDuration() === 0) return;
@@ -199,42 +201,25 @@ export default defineComponent({
199
201
  const from = host.offsetHeight;
200
202
  const target = (incoming as HTMLElement).offsetHeight;
201
203
  if (from === 0 || target === 0) return;
202
- // A faster follow-up swap arrives here AFTER Vue cancelled the
203
- // interrupted enter (onEnterCancelled → release), so this freeze
204
- // reads the layout height the released cell sits at RIGHT NOW —
205
- // the interrupted tween's mid-state, never the old start.
206
204
  host.style.height = `${from}px`;
207
205
  // Flush so the frozen height is the transition's computed start
208
206
  // (a same-frame change from auto would jump instead of tween).
209
207
  void host.offsetHeight;
210
208
  host.setAttribute("data-height-anim", "");
211
- if (targetFrame !== null) cancelAnimationFrame(targetFrame);
212
- targetFrame = requestAnimationFrame(() => {
213
- targetFrame = null;
214
- // The host may have been released within this frame (settle,
215
- // watchdog, a disabled swap); re-freezing then would fight the
216
- // cleanup — the armed attribute is that cleanup's commit marker.
217
- if (!host.hasAttribute("data-height-anim")) return;
218
- host.style.height = `${target}px`;
219
- });
209
+ host.style.height = `${target}px`;
220
210
  }
221
211
 
222
212
  /** Release the explicit height back to auto and disarm the
223
213
  * transition. Guarded on the armed attribute so it only ever
224
214
  * unwinds THIS component's own writes: an unarmed call (default-off
225
215
  * host, or a second after-hook) must leave a host's own inline
226
- * height alone, and a pending target frame must not resurrect a
227
- * height the release already cleared. */
216
+ * height alone. */
228
217
  function endHeightAnimation(): void {
229
218
  const host = hostRef.value;
230
219
  if (!host) return;
231
220
  if (!host.hasAttribute("data-height-anim")) return;
232
221
  host.removeAttribute("data-height-anim");
233
222
  host.style.height = "";
234
- if (targetFrame !== null) {
235
- cancelAnimationFrame(targetFrame);
236
- targetFrame = null;
237
- }
238
223
  }
239
224
 
240
225
  function armWatchdog(): void {
@@ -300,12 +285,6 @@ export default defineComponent({
300
285
  onBeforeUnmount(() => {
301
286
  if (watchdog !== null) clearTimeout(watchdog);
302
287
  watchdog = null;
303
- // A pending target frame would write to a host that is leaving the
304
- // document; cancel it with the rest of the machinery.
305
- if (targetFrame !== null) {
306
- cancelAnimationFrame(targetFrame);
307
- targetFrame = null;
308
- }
309
288
  });
310
289
 
311
290
  function item(): VNode {
@@ -282,6 +282,92 @@ describe("HkLoginFlow — sso channel", () => {
282
282
  });
283
283
  });
284
284
 
285
+ describe("HkLoginFlow — multi-provider sso channel", () => {
286
+ const thirdParty: HkLoginChannel = {
287
+ key: "thirdparty",
288
+ mode: "sso",
289
+ icon: h("svg"),
290
+ providers: [
291
+ { key: "github", label: "GitHub 登录", icon: h("svg") },
292
+ { key: "qq", label: "QQ 登录", icon: h("svg") },
293
+ { key: "feishu", label: "飞书登录", icon: h("svg") },
294
+ ],
295
+ };
296
+
297
+ it("renders one full-width row per provider, in the given order", () => {
298
+ const c = mount(
299
+ h(HkLoginFlow, { channels: [cloudChannel, thirdParty], modelValue: "thirdparty" }),
300
+ );
301
+ const rows = within(c, "thirdparty").querySelectorAll(".hk-auth-channel-row");
302
+ expect(rows).toHaveLength(3);
303
+ expect(rows[0].getAttribute("data-key")).toBe("github");
304
+ expect(rows[1].getAttribute("data-key")).toBe("qq");
305
+ expect(rows[2].getAttribute("data-key")).toBe("feishu");
306
+ expect(rows[0].textContent).toContain("GitHub 登录");
307
+ });
308
+
309
+ it("emits provider-select with the channel and provider keys, not sso-click", async () => {
310
+ const onProviderSelect = vi.fn();
311
+ const onSsoClick = vi.fn();
312
+ const c = mount(
313
+ h(HkLoginFlow, {
314
+ channels: [thirdParty],
315
+ modelValue: "thirdparty",
316
+ onProviderSelect,
317
+ onSsoClick,
318
+ }),
319
+ );
320
+ const row = c.querySelector<HTMLButtonElement>(".hk-auth-channel-row")!;
321
+ expect(row.getAttribute("data-key")).toBe("github");
322
+ row.click();
323
+ await nextTick();
324
+ expect(onProviderSelect).toHaveBeenCalledWith("thirdparty", "github");
325
+ expect(onSsoClick).not.toHaveBeenCalled();
326
+ });
327
+
328
+ it("renders disabled rows inert and forwards per-row href links", () => {
329
+ const c = mount(
330
+ h(HkLoginFlow, {
331
+ channels: [{
332
+ key: "thirdparty",
333
+ mode: "sso",
334
+ icon: h("svg"),
335
+ providers: [
336
+ { key: "github", label: "GitHub 登录", href: "/auth/github/redirect" },
337
+ { key: "qq", label: "QQ 登录", disabled: true },
338
+ ],
339
+ }],
340
+ modelValue: "thirdparty",
341
+ }),
342
+ );
343
+ const link = c.querySelector<HTMLAnchorElement>(".hk-auth-channel-row")!;
344
+ expect(link.tagName).toBe("A");
345
+ expect(link.getAttribute("href")).toBe("/auth/github/redirect");
346
+ const disabled = c.querySelectorAll<HTMLButtonElement>(".hk-auth-channel-row")[1];
347
+ expect(disabled.tagName).toBe("BUTTON");
348
+ expect(disabled.disabled).toBe(true);
349
+ });
350
+
351
+ it("keeps the single-provider shape untouched when providers is absent or empty", async () => {
352
+ const onSsoClick = vi.fn();
353
+ for (const providers of [undefined, []]) {
354
+ const c = mount(
355
+ h(HkLoginFlow, {
356
+ channels: [{ ...orgChannel, providers }],
357
+ modelValue: "org",
358
+ onSsoClick,
359
+ }),
360
+ );
361
+ const row = c.querySelector<HTMLButtonElement>(".hk-auth-channel-row")!;
362
+ expect(row.getAttribute("data-key")).toBe("org");
363
+ row.click();
364
+ await nextTick();
365
+ expect(onSsoClick).toHaveBeenCalledWith("org");
366
+ }
367
+ expect(onSsoClick).toHaveBeenCalledTimes(2);
368
+ });
369
+ });
370
+
285
371
  describe("HkLoginFlow — verify step", () => {
286
372
  it("renders the step-up on an sso channel once the host announces factors (OAuth hand-off)", async () => {
287
373
  // The hand-off case: the OAuth callback returns with `mfa_pending` /
@@ -61,6 +61,23 @@ export interface HkLoginCredentialsChannel {
61
61
  * only offers Feishu): the card renders the standard channel list —
62
62
  * one full-width row naming the destination — and `sso-click` sends
63
63
  * the host off to build its OAuth URL. */
64
+ /** One provider row inside a multi-provider sso channel: the same row
65
+ * shape HkAuthChannelList renders, named by the provider's funnel key
66
+ * (the `methods[].id` the deployment descriptor publishes — "github",
67
+ * "qq", "feishu", …). */
68
+ export interface HkLoginSsoProvider {
69
+ key: string;
70
+ /** The row's visible name (e.g. 「GitHub 登录」). */
71
+ label: string;
72
+ /** Prebuilt icon vnode for the row's left mark. */
73
+ icon?: unknown;
74
+ disabled?: boolean;
75
+ /** Navigation target (the funnel's entry path); the host still
76
+ * receives `provider-select` first and the navigation is not
77
+ * prevented. Default undefined — the host navigates itself. */
78
+ href?: string;
79
+ }
80
+
64
81
  export interface HkLoginSsoChannel {
65
82
  key: string;
66
83
  mode: "sso";
@@ -79,6 +96,15 @@ export interface HkLoginSsoChannel {
79
96
  * prevented). Default undefined — the row is a button and the host
80
97
  * navigates on `sso-click`, as before. */
81
98
  href?: string;
99
+ /** Multi-provider body (2026-11-29 user direction): the segment group
100
+ * switches SOURCES ("Celestia 云 / 第三方认证") and this channel's
101
+ * body lists every third-party funnel as one full-width row each,
102
+ * in display order. The rows are the channel list form — the body
103
+ * IS the list, never rows stacked under a form. When present it
104
+ * replaces the single `icon`/`buttonLabel` row; `sso-click` stays
105
+ * for the single-provider shape, and picking a row emits
106
+ * `provider-select` with (channel key, provider key). */
107
+ providers?: HkLoginSsoProvider[];
82
108
  }
83
109
 
84
110
  export type HkLoginChannel = HkLoginCredentialsChannel | HkLoginSsoChannel;
@@ -246,6 +272,11 @@ export const HkLoginFlow = defineComponent({
246
272
  "update:modelValue": (_key: string) => true,
247
273
  "account-submit": (_channel: string, _username: string, _password: string) => true,
248
274
  "sso-click": (_channel: string) => true,
275
+ // A multi-provider sso channel's row was picked: (channel key,
276
+ // provider key) — the provider key is the funnel id the host's
277
+ // descriptor publishes ("github", "qq", "feishu", …), so the host
278
+ // routes to that funnel's own entry path.
279
+ "provider-select": (_channel: string, _provider: string) => true,
249
280
  // `verify` carries HkMfaFactor (not a bare string): consumers bind
250
281
  // factor-typed handlers (`onVerify={(kind: MfaFactor, …)}`), and a
251
282
  // wider `string` param fails TS2322 under strictFunctionTypes —
@@ -402,6 +433,24 @@ export const HkLoginFlow = defineComponent({
402
433
  }
403
434
 
404
435
  function renderSsoBody(channel: HkLoginSsoChannel) {
436
+ const providers = channel.providers ?? [];
437
+ if (providers.length > 0) {
438
+ return (
439
+ <div key={channel.key} class="hk-login-flow-sso">
440
+ <HkAuthChannelList
441
+ methods={providers.map((provider) => ({
442
+ key: provider.key,
443
+ label: provider.label,
444
+ icon: provider.icon,
445
+ disabled: provider.disabled,
446
+ href: provider.href,
447
+ }))}
448
+ onSelect={(providerKey: string) =>
449
+ emit("provider-select", channel.key, providerKey)}
450
+ />
451
+ </div>
452
+ );
453
+ }
405
454
  return (
406
455
  <div key={channel.key} class="hk-login-flow-sso">
407
456
  <HkAuthChannelList
@@ -1,7 +1,7 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta name="hk-error-landing" content="v1 0.55.514 <dev>">
4
+ <meta name="hk-error-landing" content="v1 0.55.516 <dev>">
5
5
  <meta charset="utf-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
  <meta name="robots" content="noindex" />
package/src/index.ts CHANGED
@@ -1148,6 +1148,7 @@ export { HkLoginFlow as HkLoginFlow } from "./components/HkLoginFlow";
1148
1148
  export { type HkLoginChannel as HkLoginChannel } from "./components/HkLoginFlow";
1149
1149
  export { type HkLoginCredentialsChannel as HkLoginCredentialsChannel } from "./components/HkLoginFlow";
1150
1150
  export { type HkLoginSsoChannel as HkLoginSsoChannel } from "./components/HkLoginFlow";
1151
+ export { type HkLoginSsoProvider as HkLoginSsoProvider } from "./components/HkLoginFlow";
1151
1152
  export { HkAuthSsoButton as HkAuthSsoButton } from "./components/HkAuthSsoButton";
1152
1153
  export { HkAuthChannelList as HkAuthChannelList } from "./components/HkAuthChannelList";
1153
1154
  export { type HkAuthChannelListEntry as HkAuthChannelListEntry } from "./components/HkAuthChannelList";