@celestia-island/hikari 0.55.522 → 0.55.523
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/dist/types/index.d.ts +1 -1
- package/dist/types/runtime/clipboardHub.d.ts +87 -0
- package/dist/types/runtime/index.d.ts +1 -0
- package/dist/types/runtime/useClipboard.d.ts +5 -4
- package/package.json +1 -1
- package/src/components/HkCopyBadge.test.tsx +5 -2
- package/src/components/HkTable.interactions.test.tsx +5 -2
- package/src/errorLandingStandalone/error-landing.html +5 -5
- package/src/index.ts +8 -0
- package/src/runtime/clipboardHub.test.ts +234 -0
- package/src/runtime/clipboardHub.ts +183 -0
- package/src/runtime/index.ts +10 -0
- package/src/runtime/useClipboard.test.ts +57 -1
- package/src/runtime/useClipboard.ts +18 -30
- package/src/wasm/highlight/hikari_wasm_highlight.js +2140 -4514
- package/src/wasm/mermaid/hikari_wasm_mermaid.js +2153 -4540
- package/src/wasm/qr/hikari_wasm_qr.js +2152 -4479
- package/src/wasm/scene3d/hikari_wasm_scene3d.js +2223 -4697
package/dist/types/index.d.ts
CHANGED
|
@@ -177,7 +177,7 @@ export type { SemanticPalette, SemanticFills, OKLCH } from "./theme/semanticPale
|
|
|
177
177
|
export { FALLBACK_WALLPAPER_ID, DEFAULT_WALLPAPER_ID, DEFAULT_PRESETS, DEFAULT_DISPLAY_SETTINGS, DEFAULT_WALLPAPER_STORAGE_PREFIX, registerWallpaperPack, configureWallpaperStorage, wallpaperStorageKey, isWallpaperSource, isTimeAware, loadActiveWallpaperId, hasStoredWallpaperId, saveActiveWallpaperId, loadCustomWallpapers, saveCustomWallpapers, addCustomWallpaper, removeCustomWallpaper, updateCustomWallpaper, loadCachedGeolocation, saveCachedGeolocation, loadDisplaySettings, saveDisplaySettings, getDisplaySettings, setDisplaySettings, buildWallpaperFilter, initWallpaper, destroyWallpaper, useWallpaper, ensureWallpaperState, configureWallpaper, registerWallpaperBrandDefaults, registerServerThemeWallpaper, brandDefaultWallpaperFor, resolveThemeFollowSwitch, setWallpaperPipelineLookup, geo, currentPeriod, hasStorage, readStorageItem, writeStorageItem, removeStorageItem, type WallpaperType, type SolidSource, type ImageSource, type VideoSource, type PipelineSource, type WallpaperSource, type TimeAwareWallpaper, type WallpaperPreset, type WallpaperPackEntry, type CustomWallpaper, type WallpaperPosition, type WallpaperScale, type WallpaperEffect, type WallpaperDisplaySettings, type WallpaperStorageSlot, type WallpaperStorageConfig, type WallpaperInitConfig, type WallpaperPipelineLookup, type WallpaperPipelinePreset, } from "./theme";
|
|
178
178
|
export { registerShaderPresets, getShaderPreset, listShaderPresetIds, SHADER_VERTEX, WallpaperShaderPipeline, createWallpaperShaderSurface, type WallpaperShaderPreset, type WallpaperShaderPresetInput, type WallpaperShaderScaleConfig, type WallpaperShaderScaleInput, type WallpaperShaderOverlayConfig, } from "./theme";
|
|
179
179
|
export { default as HkWallpaperBackdrop, WALLPAPER_REDUCED_MOTION_QUERY, type HkWallpaperBackdropMode, type HkWallpaperSurface, type HkWallpaperSurfaceContext, type HkWallpaperSurfaceFactory, } from "./components/HkWallpaperBackdrop";
|
|
180
|
-
export { onFrame, onceFrame, scheduleFrame, scheduleEvery, scheduleAfter, scheduleCron, scheduleCronAfter, scheduleInterval, scheduleIntervalAfter, reportTransition, setReducedMotion, notifyScrollStart, useOverlay, hasLiveWindow, isWindowEntry, topWindowZ, usePopupManager, POPUP_Z_BANDS, POPUP_Z_STEP, useToast, useConfirm, useBlockingToast, showBlockingToast, resolveBlockingToast, clearBlockingToasts, useEmergencyAlert, raiseEmergencyAlert, clearEmergencyAlert, snoozeEmergencyAlert, unsnoozeEmergencyAlert, resetEmergencyAlerts, emergencySeverityRank, useNotificationCenter, recordNotification, setNotificationState, forgetNotification, markAllNotificationsRead, resetNotifications, MAX_NOTIFICATION_ENTRIES, type HkNotificationEntry, type HkNotificationKind, type HkNotificationRecordInput, type HkNotificationState, type HkNotificationTone, type EmergencyAlertItem, type EmergencyAlertOptions, type EmergencyAction, type EmergencySeverity, type BlockingToastItem, type BlockingToastOptions, type BlockingToastVariant, useScreenIdentify, showScreenIdentify, dismissScreenIdentify, SCREEN_IDENTIFY_DEFAULT_MS, SCREEN_IDENTIFY_TICK_MS, type ScreenIdentifyRequest, type ScreenIdentifyContext, useBreakpoint, useClipboard, useClipboardWithToast, useMediaQuery, releaseMediaQuery, usePageLifecycle, onPageLifecycle, pageLifecycleState, useSafeArea, applyViewportPolicy, parseViewportContent, type ApplyViewportPolicyOptions, type ViewportPolicyResult, closeAll, isOverlayOpen, TOAST_DURATION, createBackGuard, BACK_GUARD_MARKER, BACK_GUARD_DEPTH, type AnimationHandle, useReportedTransition, type ReportedTransition, type ReportedTransitionTrack, type CronHandle, type IntervalHandle, type FrameContext, type OverlayHandle, type PopupHandle, type PopupKind, type ToastAction, type ToastItem, type ToastMessage, type ToastType, type PageLifecycleState, type PageLifecycleListener, type SafeAreaInsets, type BackGuard, type BackGuardOptions, installHkTooltipBridge, type HkTooltipBridgeOptions, installHkImageFallback, type HkImageFallbackOptions, installHkTapHighlight, type HkTapHighlightOptions, type HkTapHighlightColor, installHkTouchHintBridge, showHkTouchHintBar, armTouchHint, type HkTouchHintOptions, type HkTouchHintArmOptions, reportHkRuntime, getHkRuntimeEntry, listHkRuntime, readHkRuntime, writeHkRuntime, hkRuntimeSnapshot, useHkRegistry, type HkRuntimeKind, type HkRuntimeStatus, type HkRuntimeMeta, type HkRuntimeEntryState, type HkRuntimeReport, type HkRuntimeHandle, type HkRuntimeWriteOp, type HkRuntimeSnapshot, type HkRuntimeSnapshotEntry, } from "./runtime";
|
|
180
|
+
export { onFrame, onceFrame, scheduleFrame, scheduleEvery, scheduleAfter, scheduleCron, scheduleCronAfter, scheduleInterval, scheduleIntervalAfter, reportTransition, setReducedMotion, notifyScrollStart, useOverlay, hasLiveWindow, isWindowEntry, topWindowZ, usePopupManager, POPUP_Z_BANDS, POPUP_Z_STEP, useToast, useConfirm, useBlockingToast, showBlockingToast, resolveBlockingToast, clearBlockingToasts, useEmergencyAlert, raiseEmergencyAlert, clearEmergencyAlert, snoozeEmergencyAlert, unsnoozeEmergencyAlert, resetEmergencyAlerts, emergencySeverityRank, useNotificationCenter, recordNotification, setNotificationState, forgetNotification, markAllNotificationsRead, resetNotifications, MAX_NOTIFICATION_ENTRIES, type HkNotificationEntry, type HkNotificationKind, type HkNotificationRecordInput, type HkNotificationState, type HkNotificationTone, type EmergencyAlertItem, type EmergencyAlertOptions, type EmergencyAction, type EmergencySeverity, type BlockingToastItem, type BlockingToastOptions, type BlockingToastVariant, useScreenIdentify, showScreenIdentify, dismissScreenIdentify, SCREEN_IDENTIFY_DEFAULT_MS, SCREEN_IDENTIFY_TICK_MS, type ScreenIdentifyRequest, type ScreenIdentifyContext, useBreakpoint, useClipboard, useClipboardWithToast, useMediaQuery, releaseMediaQuery, usePageLifecycle, onPageLifecycle, pageLifecycleState, useSafeArea, applyViewportPolicy, parseViewportContent, type ApplyViewportPolicyOptions, type ViewportPolicyResult, closeAll, isOverlayOpen, TOAST_DURATION, createBackGuard, BACK_GUARD_MARKER, BACK_GUARD_DEPTH, type AnimationHandle, useReportedTransition, type ReportedTransition, type ReportedTransitionTrack, type CronHandle, type IntervalHandle, type FrameContext, type OverlayHandle, type PopupHandle, type PopupKind, type ToastAction, type ToastItem, type ToastMessage, type ToastType, type PageLifecycleState, type PageLifecycleListener, type SafeAreaInsets, type BackGuard, type BackGuardOptions, installHkTooltipBridge, type HkTooltipBridgeOptions, installHkImageFallback, type HkImageFallbackOptions, installHkTapHighlight, type HkTapHighlightOptions, type HkTapHighlightColor, installHkTouchHintBridge, showHkTouchHintBar, armTouchHint, type HkTouchHintOptions, type HkTouchHintArmOptions, reportHkRuntime, getHkRuntimeEntry, listHkRuntime, readHkRuntime, writeHkRuntime, hkRuntimeSnapshot, useHkRegistry, type HkRuntimeKind, type HkRuntimeStatus, type HkRuntimeMeta, type HkRuntimeEntryState, type HkRuntimeReport, type HkRuntimeHandle, type HkRuntimeWriteOp, type HkRuntimeSnapshot, type HkRuntimeSnapshotEntry, configureClipboardHub, clipboardHubConfig, getClipboardHub, writeClipboardText, type ClipboardCopyOptions, type ClipboardEntry, type ClipboardHub, type ClipboardHubConfig, } from "./runtime";
|
|
181
181
|
export { useI18n, setLocale, activeLocale, mergeMessages, } from "./i18n/context";
|
|
182
182
|
export { HK_LOCALE_CATALOG, type HkLocaleCatalogEntry } from "./i18n/localeCatalog";
|
|
183
183
|
export { fuzzyScore, fuzzyScoreFields, fuzzySearch } from "./utils/fuzzy";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The family's ONE clipboard context (user direction 2026-12-01: copy paths
|
|
3
|
+
* converge here — hosts stop owning private `navigator.clipboard` /
|
|
4
|
+
* `execCommand` sequences and consume this hub instead).
|
|
5
|
+
*
|
|
6
|
+
* Framework-free on purpose: the Vue hooks (`useClipboard`,
|
|
7
|
+
* `useClipboardWithToast`) wrap it, and non-Vue consumers (the lagrange docs
|
|
8
|
+
* shell's delegated DOM handlers today; any future host runtime) import the
|
|
9
|
+
* same module-scoped singleton, so every writer on a page shares one
|
|
10
|
+
* implementation, one history, one place to fix browser quirks in.
|
|
11
|
+
*
|
|
12
|
+
* The write core NEVER reports success it did not observe:
|
|
13
|
+
*
|
|
14
|
+
* - `navigator.clipboard.writeText` is awaited; only a fulfilled promise
|
|
15
|
+
* means "the clipboard now holds the text" (the browser contract).
|
|
16
|
+
* - Outside secure contexts (and wherever the async API refuses), the
|
|
17
|
+
* textarea + `execCommand("copy")` fallback runs, and `execCommand`
|
|
18
|
+
* reports failure by RETURNING false — treating that falsy return as
|
|
19
|
+
* success is exactly the defect that surfaced "Copied" toasts for writes
|
|
20
|
+
* that never landed (hikari #409, lagrange #211 follow-ups).
|
|
21
|
+
*
|
|
22
|
+
* History is the first of the hub's fine-grained management features: an
|
|
23
|
+
* in-memory ring of recent writes (newest first) with a subscribe hook, so
|
|
24
|
+
* hosts can surface "what did I copy" UI or audit writes without each
|
|
25
|
+
* consumer rolling its own log. Recording is on by default and can be turned
|
|
26
|
+
* off globally (`configureClipboardHub`) — e.g. on pages where clipboard
|
|
27
|
+
* content is sensitive enough that keeping it in memory is wrong.
|
|
28
|
+
*/
|
|
29
|
+
export interface ClipboardEntry {
|
|
30
|
+
/** The text that was written. */
|
|
31
|
+
text: string;
|
|
32
|
+
/** Epoch milliseconds at the moment the write was confirmed. */
|
|
33
|
+
at: number;
|
|
34
|
+
/**
|
|
35
|
+
* Optional call-site label (`copy(text, { source: "code-block" })`) —
|
|
36
|
+
* lets a history surface distinguish code blocks, badges, modals…
|
|
37
|
+
*/
|
|
38
|
+
source?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ClipboardCopyOptions {
|
|
41
|
+
/** Call-site label recorded into history alongside the text. */
|
|
42
|
+
source?: string;
|
|
43
|
+
/** Skip the history ring for this one write (defaults to recording). */
|
|
44
|
+
record?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface ClipboardHubConfig {
|
|
47
|
+
/**
|
|
48
|
+
* Ring capacity; the oldest entry falls off. Default 50, 0 disables.
|
|
49
|
+
* **Zero is the global off switch**: with a zero limit nothing is recorded,
|
|
50
|
+
* and a per-call `record: true` cannot bypass it — a page that decided its
|
|
51
|
+
* clipboard contents must not sit in memory must not be undone by an
|
|
52
|
+
* individual writer.
|
|
53
|
+
*/
|
|
54
|
+
historyLimit?: number;
|
|
55
|
+
/** Master switch for history recording. Default true. */
|
|
56
|
+
recordHistory?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface ClipboardHub {
|
|
59
|
+
/**
|
|
60
|
+
* The single write path. Resolves to whether the clipboard verifiably
|
|
61
|
+
* received the text; a confirmed write is appended to history.
|
|
62
|
+
*/
|
|
63
|
+
copy(text: string, options?: ClipboardCopyOptions): Promise<boolean>;
|
|
64
|
+
/** Recent confirmed writes, newest first (a readonly snapshot). */
|
|
65
|
+
history(): readonly ClipboardEntry[];
|
|
66
|
+
/** Drops every recorded entry. */
|
|
67
|
+
clearHistory(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Notified after every confirmed write and every clear. Returns the
|
|
70
|
+
* unsubscribe function.
|
|
71
|
+
*/
|
|
72
|
+
subscribe(listener: () => void): () => void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The one write sequence every consumer shares. Never returns true unless a
|
|
76
|
+
* write verifiably landed. Exported for tests and for the rare caller that
|
|
77
|
+
* wants the raw write without touching the hub's history.
|
|
78
|
+
*/
|
|
79
|
+
export declare function writeClipboardText(text: string): Promise<boolean>;
|
|
80
|
+
export declare function configureClipboardHub(config: ClipboardHubConfig): void;
|
|
81
|
+
/** Read-mostly view of the active config (tests assert against it). */
|
|
82
|
+
export declare function clipboardHubConfig(): Required<ClipboardHubConfig>;
|
|
83
|
+
/**
|
|
84
|
+
* The page-wide clipboard context. Every caller in the same bundle gets the
|
|
85
|
+
* same instance — that is the whole point of the convergence.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getClipboardHub(): ClipboardHub;
|
|
@@ -28,6 +28,7 @@ export { useEmergencyAlert, raiseEmergencyAlert, clearEmergencyAlert, snoozeEmer
|
|
|
28
28
|
export { useScreenIdentify, showScreenIdentify, dismissScreenIdentify, SCREEN_IDENTIFY_DEFAULT_MS, SCREEN_IDENTIFY_TICK_MS, type ScreenIdentifyRequest, type ScreenIdentifyContext, } from "./useScreenIdentify";
|
|
29
29
|
export { useBreakpoint } from "./useBreakpoint";
|
|
30
30
|
export { useClipboard, useClipboardWithToast } from "./useClipboard";
|
|
31
|
+
export { configureClipboardHub, clipboardHubConfig, getClipboardHub, writeClipboardText, type ClipboardCopyOptions, type ClipboardEntry, type ClipboardHub, type ClipboardHubConfig, } from "./clipboardHub";
|
|
31
32
|
export { provideScrollWindow, useScrollWindow, type ScrollWindowContext } from "../composables/useScrollWindow";
|
|
32
33
|
export { useReportedTransition, type ReportedTransition, type ReportedTransitionTrack } from "../composables/useReportedTransition";
|
|
33
34
|
export { showProgressDialog, useProgressDialog, type ProgressDialogHandle, type ProgressDialogState } from "../composables/useProgressDialog";
|
|
@@ -6,10 +6,11 @@ export declare function useClipboard(): {
|
|
|
6
6
|
* Clipboard copy with a toast on success/failure.
|
|
7
7
|
* (Upstreamed from shittim-chest's plana-legacy layer.)
|
|
8
8
|
*
|
|
9
|
-
* Wraps the base `useClipboard` above (which
|
|
10
|
-
*
|
|
11
|
-
* `copied` reflects the 2s copied
|
|
12
|
-
* hikari's `useToast()` surface
|
|
9
|
+
* Wraps the base `useClipboard` above (which now delegates to the shared
|
|
10
|
+
* clipboard hub — the write sequence and the history ring are family-wide,
|
|
11
|
+
* not per-hook) and adds toast feedback; `copied` reflects the 2s copied
|
|
12
|
+
* state. The `toast` argument matches hikari's `useToast()` surface
|
|
13
|
+
* (`success` / `error` message pushers).
|
|
13
14
|
*
|
|
14
15
|
* Default toast messages come from hikari's own i18n
|
|
15
16
|
* (`hikari::clipboard.copied` / `hikari::clipboard.copyFailed`) so a
|
package/package.json
CHANGED
|
@@ -68,8 +68,11 @@ describe("HkCopyBadge", () => {
|
|
|
68
68
|
it("copies the rendered text on click and toasts the localized default", async () => {
|
|
69
69
|
const c = mount(() => h(HkCopyBadge, null, () => "#demiurge.132"));
|
|
70
70
|
(c.querySelector(".hk-badge") as HTMLElement).click();
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
// The copy write runs through the shared clipboard hub (user direction
|
|
72
|
+
// 2026-12-01): more promise hops between the click and the toast —
|
|
73
|
+
// still zero-milliseconds in real time, so flush to a settled state
|
|
74
|
+
// instead of counting microtasks.
|
|
75
|
+
for (let i = 0; i < 10; i++) await Promise.resolve();
|
|
73
76
|
|
|
74
77
|
expect(writeText).toHaveBeenCalledWith("#demiurge.132");
|
|
75
78
|
const success = useToast().toasts.find((t) => t.type === "success");
|
|
@@ -108,9 +108,12 @@ const PROBE_CSS = sass.compileString("@media (min-width: 600px) { .hk-probe { co
|
|
|
108
108
|
// happy-dom reports an unset cursor as "" (a browser reports "auto").
|
|
109
109
|
const isAuto = (value: string): boolean => value === "" || value === "auto";
|
|
110
110
|
|
|
111
|
+
// Flush the copy write to a settled state instead of counting microtasks:
|
|
112
|
+
// the copy path now runs through the shared clipboard hub (user direction
|
|
113
|
+
// 2026-12-01), which adds promise hops between the click and the toast —
|
|
114
|
+
// still zero-milliseconds in real time, but more than the old two ticks.
|
|
111
115
|
async function settle() {
|
|
112
|
-
await Promise.resolve();
|
|
113
|
-
await Promise.resolve();
|
|
116
|
+
for (let i = 0; i < 10; i++) await Promise.resolve();
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
function bodyCells(c: HTMLElement): HTMLElement[] {
|