@qilin-agent/client-ui-sidebar-documentpreview 0.0.0-stage → 3.1.4

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.
Files changed (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.i18n.yaml +46 -0
  3. package/README.md +158 -2
  4. package/README.zh.md +159 -0
  5. package/lib/client.excel.js +133808 -0
  6. package/lib/client.js +7758 -0
  7. package/lib/client.pdf.js +32672 -0
  8. package/lib/index.js +35 -0
  9. package/lib/types/client/LoadingIndicator.d.ts +12 -0
  10. package/lib/types/client/TextPreview.d.ts +29 -0
  11. package/lib/types/client/TextTitle.d.ts +14 -0
  12. package/lib/types/client/code/CodeBody.d.ts +9 -0
  13. package/lib/types/client/code/index.d.ts +5 -0
  14. package/lib/types/client/code/languages.d.ts +9 -0
  15. package/lib/types/client/code/locales.d.ts +19 -0
  16. package/lib/types/client/definition.d.ts +37 -0
  17. package/lib/types/client/document/contract.d.ts +111 -0
  18. package/lib/types/client/document/registry.d.ts +70 -0
  19. package/lib/types/client/document/resource-group.d.ts +23 -0
  20. package/lib/types/client/document/suffix.d.ts +24 -0
  21. package/lib/types/client/document/tab-lifetime.d.ts +10 -0
  22. package/lib/types/client/document/unviewable.d.ts +7 -0
  23. package/lib/types/client/excel/LazyExcelBody.d.ts +22 -0
  24. package/lib/types/client/excel/convert.d.ts +12 -0
  25. package/lib/types/client/excel/delimited.d.ts +10 -0
  26. package/lib/types/client/excel/error.d.ts +7 -0
  27. package/lib/types/client/excel/excel.d.ts +11 -0
  28. package/lib/types/client/excel/format.d.ts +9 -0
  29. package/lib/types/client/excel/index.d.ts +10 -0
  30. package/lib/types/client/excel/locales.d.ts +45 -0
  31. package/lib/types/client/excel/model.d.ts +35 -0
  32. package/lib/types/client/excel/parse.d.ts +12 -0
  33. package/lib/types/client/excel/worker.d.ts +2 -0
  34. package/lib/types/client/excel/xls.d.ts +18 -0
  35. package/lib/types/client/excel/xlsx-archive.d.ts +21 -0
  36. package/lib/types/client/excel/xlsx.d.ts +9 -0
  37. package/lib/types/client/face.d.ts +87 -0
  38. package/lib/types/client/failure-line.d.ts +17 -0
  39. package/lib/types/client/html/HtmlBody.d.ts +22 -0
  40. package/lib/types/client/html/basic-document.d.ts +7 -0
  41. package/lib/types/client/html/bootstrap.d.ts +20 -0
  42. package/lib/types/client/html/bytes.d.ts +14 -0
  43. package/lib/types/client/html/index.d.ts +17 -0
  44. package/lib/types/client/html/locales.d.ts +23 -0
  45. package/lib/types/client/html/pack.d.ts +21 -0
  46. package/lib/types/client/html/read-relative.d.ts +22 -0
  47. package/lib/types/client/icons.d.ts +14 -0
  48. package/lib/types/client/image/ImageBody.d.ts +32 -0
  49. package/lib/types/client/image/index.d.ts +21 -0
  50. package/lib/types/client/image/locales.d.ts +37 -0
  51. package/lib/types/client/index.d.ts +53 -0
  52. package/lib/types/client/locales.d.ts +66 -0
  53. package/lib/types/client/markdown/MarkdownBody.d.ts +12 -0
  54. package/lib/types/client/markdown/index.d.ts +17 -0
  55. package/lib/types/client/markdown/locales.d.ts +27 -0
  56. package/lib/types/client/markdown/path-images.d.ts +9 -0
  57. package/lib/types/client/markdown/sanitize-html.d.ts +34 -0
  58. package/lib/types/client/media-url.d.ts +15 -0
  59. package/lib/types/client/office/FontNotice.d.ts +16 -0
  60. package/lib/types/client/office/OfficeBody.d.ts +44 -0
  61. package/lib/types/client/office/cache.d.ts +70 -0
  62. package/lib/types/client/office/index.d.ts +16 -0
  63. package/lib/types/client/office/locales.d.ts +43 -0
  64. package/lib/types/client/office/store.d.ts +32 -0
  65. package/lib/types/client/pdf/LazyPdfBody.d.ts +10 -0
  66. package/lib/types/client/pdf/assets.d.ts +26 -0
  67. package/lib/types/client/pdf/document.d.ts +38 -0
  68. package/lib/types/client/pdf/errors.d.ts +8 -0
  69. package/lib/types/client/pdf/index.d.ts +27 -0
  70. package/lib/types/client/pdf/locales.d.ts +45 -0
  71. package/lib/types/client/pdf/pdf.d.ts +29 -0
  72. package/lib/types/client/pdf/runtime.d.ts +14 -0
  73. package/lib/types/client/pdf/store.d.ts +27 -0
  74. package/lib/types/client/pdf/text.d.ts +10 -0
  75. package/lib/types/client/rpc.d.ts +77 -0
  76. package/lib/types/client/selection-payload.d.ts +53 -0
  77. package/lib/types/client/selection-popup.d.ts +58 -0
  78. package/lib/types/client/store.d.ts +100 -0
  79. package/lib/types/client/text/TextBody.d.ts +6 -0
  80. package/lib/types/client/text/index.d.ts +14 -0
  81. package/lib/types/client/text/lines.d.ts +31 -0
  82. package/lib/types/client/video/VideoBody.d.ts +19 -0
  83. package/lib/types/client/video/index.d.ts +15 -0
  84. package/lib/types/client/video/locales.d.ts +21 -0
  85. package/lib/types/client/zoom/ZoomControls.d.ts +21 -0
  86. package/lib/types/client/zoom/ZoomViewport.d.ts +27 -0
  87. package/lib/types/client/zoom/locales.d.ts +21 -0
  88. package/lib/types/client/zoom/store.d.ts +28 -0
  89. package/lib/types/client/zoom/types.d.ts +27 -0
  90. package/lib/types/config.d.ts +31 -0
  91. package/lib/types/index.d.ts +11 -0
  92. package/package.json +100 -3
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The floating "add selection to conversation" button the text viewer shows
3
+ * over a selection: a viewport-anchored button portaled to `document.body`,
4
+ * kept alive across the selection gesture and committed on click.
5
+ *
6
+ * Dismissal: the button must never outlive its viewer. The caller hides it on
7
+ * scrolling, on a collapsed selection and on a content swap, and this hook
8
+ * adds the global dismissal that covers everything else — any `mousedown`
9
+ * outside the button, `Escape`, the document going hidden or the window
10
+ * losing focus, and an `IntersectionObserver` on the viewer surface, which is
11
+ * the only signal a tab switch (`display: none`) or a panel collapse
12
+ * (translated off-screen) produces. The button's own `mousedown` is not an
13
+ * outside click: the caller preventDefaults it so the selection survives
14
+ * until the click commits.
15
+ */
16
+ import { type RefObject } from 'react';
17
+ /** The anchored action: the draft text to insert, and where the button sits. */
18
+ export interface SelectionPopup {
19
+ readonly insert: string;
20
+ readonly left: number;
21
+ readonly top: number;
22
+ }
23
+ /** What the hook needs from its owner. */
24
+ export interface SelectionPopupOptions {
25
+ /** Commit the payload into the conversation draft (button click). */
26
+ onCommit: (insert: string) => void;
27
+ /**
28
+ * The element that must stay on screen for the button to live. Called at
29
+ * open time, when the caller's refs are bound.
30
+ * @returns the viewer surface, or null when it is not mounted.
31
+ */
32
+ getSurface: () => HTMLElement | null;
33
+ }
34
+ /** The hook's return: the current button state and the gestures that drive it. */
35
+ export interface SelectionPopupControls {
36
+ /** The button to render, or null while none is shown. */
37
+ readonly popup: SelectionPopup | null;
38
+ /** Attach to the portaled button so its own press is not an outside click. */
39
+ readonly buttonRef: RefObject<HTMLButtonElement>;
40
+ /**
41
+ * Anchor the button over a selection.
42
+ * @param insert - the draft text this button would commit.
43
+ * @param left - the selection centre, in viewport coordinates.
44
+ * @param top - the selection top, in viewport coordinates.
45
+ */
46
+ show: (insert: string, left: number, top: number) => void;
47
+ /** Hide the button; safe to call when none is shown. */
48
+ hide: () => void;
49
+ /** Commit the payload of the shown button, then hide. */
50
+ commit: () => void;
51
+ }
52
+ /**
53
+ * Own one selection button for a viewer surface.
54
+ * @param options - the commit sink and the surface probe.
55
+ * @returns the button state and its gestures.
56
+ */
57
+ export declare function useSelectionPopup(options: SelectionPopupOptions): SelectionPopupControls;
58
+ //# sourceMappingURL=selection-popup.d.ts.map
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The preview's own state: the pages it has read, and how the reader views them.
3
+ *
4
+ * The `file` resource carries metadata only, so the text is this type's to fetch
5
+ * and keep — page by page, keyed by the 1-based line each page starts at. The
6
+ * view state (scroll offset, wrap, the navigation already answered) must outlive
7
+ * the body: a tab switched away from unmounts its body and must come back where
8
+ * it was rather than re-read or jump to its opening line again. Bucketed by tab
9
+ * id because two tabs of one file scroll independently.
10
+ *
11
+ * A bucket lives as long as its tab record: the face's first read of a tab arms
12
+ * one listener on the owner's `signal` that forgets the bucket when the record
13
+ * ends, and a tab that never read has no bucket to forget.
14
+ */
15
+ import type { RemoteFailure } from '@qilin-agent/api-remotes/client';
16
+ import { type EngineStoreHandle } from '@qilin-agent/client-store';
17
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
18
+ import type { WorkspaceFileText } from '@qilin-agent/api-workspace-files/types';
19
+ import type { DocumentFileBytes } from './rpc.ts';
20
+ import type { DocumentLoadMode } from './document/registry.ts';
21
+ /**
22
+ * One page as the store keeps it: its text and the Host's line count, which
23
+ * tells a page past the file's last line (`lines: 0`) from a page holding one
24
+ * empty line (`lines: 1`, `text: ''`).
25
+ */
26
+ export interface TextPage {
27
+ readonly text: string;
28
+ readonly lines: number;
29
+ }
30
+ /** One tab's pages and view. */
31
+ export interface TextTabState {
32
+ autoRefresh: boolean;
33
+ resourcesDirty: boolean;
34
+ /** Explicit viewer choice for this tab; absence follows automatic matching. */
35
+ rendererId?: string;
36
+ /** Current display-loading mode; absent before the first read. */
37
+ mode?: DocumentLoadMode;
38
+ /** Implementation owning source loading; absent for ordinary file reads. */
39
+ contentRendererId?: string;
40
+ /** Current content revision, incremented whenever loaded content is discarded. */
41
+ loadRevision: number;
42
+ /** Full byte result used by complete-file renderers. */
43
+ complete?: DocumentFileBytes;
44
+ /** The file version the loaded pages belong to; absent before the first page. */
45
+ version: string | undefined;
46
+ /** Metadata version observed when this tab began its current read generation. */
47
+ observedVersion: string | undefined;
48
+ /** Pages by the 1-based line each starts at. */
49
+ pages: Record<number, TextPage>;
50
+ /** Whether the last loaded page reached the end of the file. */
51
+ eof: boolean;
52
+ /** A page read is in flight. */
53
+ loading: boolean;
54
+ /** Why the last page read failed; cleared by the next page. */
55
+ failure: RemoteFailure | undefined;
56
+ /** Scroll offset of the body, in px. */
57
+ scrollTop: number;
58
+ /** Whether long lines wrap instead of scrolling horizontally; on until the reader turns it off. */
59
+ wrap: boolean;
60
+ /** The `navigation.revision` the body already answered; absent before the first. */
61
+ revision: number | undefined;
62
+ }
63
+ /** Every tab's state, keyed by tab id. */
64
+ export interface TextState {
65
+ byTab: Record<TabId, TextTabState>;
66
+ }
67
+ /**
68
+ * A tab's state before it reads, scrolls, toggles, or answers anything.
69
+ * @returns the empty bucket.
70
+ */
71
+ export declare function fresh(): TextTabState;
72
+ /** The preview store's write set; every action names the tab it writes. */
73
+ type TextActions = {
74
+ toggledAutoRefresh: (draft: TextState, tabId: TabId) => void;
75
+ resourceChanged: (draft: TextState, tabId: TabId) => void;
76
+ selected: (draft: TextState, tabId: TabId, rendererId: string | undefined) => void;
77
+ loading: (draft: TextState, tabId: TabId, mode?: DocumentLoadMode, observedVersion?: string, contentRendererId?: string) => void;
78
+ rendered: (draft: TextState, tabId: TabId, revision: number, version: string) => void;
79
+ rendererFailed: (draft: TextState, tabId: TabId, revision: number) => void;
80
+ complete: (draft: TextState, tabId: TabId, file: DocumentFileBytes) => void;
81
+ page: (draft: TextState, tabId: TabId, page: WorkspaceFileText) => void;
82
+ failed: (draft: TextState, tabId: TabId, failure: RemoteFailure) => void;
83
+ reset: (draft: TextState, tabId: TabId) => void;
84
+ scrolled: (draft: TextState, tabId: TabId, scrollTop: number) => void;
85
+ toggledWrap: (draft: TextState, tabId: TabId) => void;
86
+ navigated: (draft: TextState, tabId: TabId, revision: number) => void;
87
+ forget: (draft: TextState, tabId: TabId) => void;
88
+ };
89
+ /**
90
+ * Declare the preview's store.
91
+ *
92
+ * Constructed once in apply and shared by the body and the tools registrations,
93
+ * which the slot runtime allows because both are session-scoped.
94
+ * @returns the store handle to declare on both registrations.
95
+ */
96
+ export declare function createTextStore(): EngineStoreHandle<TextState, TextActions>;
97
+ /** The store handle type both registrations declare. */
98
+ export type TextStore = ReturnType<typeof createTextStore>;
99
+ export {};
100
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,6 @@
1
+ /** Plain source display for files without a more specific document renderer. */
2
+ import type { ReactNode } from 'react';
3
+ import type { DocumentPreviewProps } from '../document/contract.ts';
4
+ /** @param props - document contents and standard tab information. @returns source lines with navigation targets. */
5
+ export declare function TextBody({ content, useTabInfo }: DocumentPreviewProps): ReactNode;
6
+ //# sourceMappingURL=TextBody.d.ts.map
@@ -0,0 +1,14 @@
1
+ /** Plain text implementation registered through the same document extension points as other viewers. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { DocumentPreviewDefinition } from '../document/registry.ts';
4
+ /** Stable plain-text implementation identity within this package. */
5
+ export declare const PLAIN_BODY_ID = "@qilin-agent/client-ui-sidebar-documentpreview/text";
6
+ /**
7
+ * Describe the plain-text fallback.
8
+ * @param title - locale-owned implementation name.
9
+ * @returns plain-text registration metadata.
10
+ */
11
+ export declare function textBodyDefinition(title: () => string): DocumentPreviewDefinition;
12
+ /** @param ctx - owning plugin context. Register the fallback metadata and keyed body. */
13
+ export declare function apply(ctx: Context): void;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,31 @@
1
+ /** Source-line helpers shared by the plain renderer and the document scroller. */
2
+ import type { DocumentTextPage } from '../document/contract.ts';
3
+ import type { TextPage } from '../store.ts';
4
+ /**
5
+ * Split a loaded page into its source lines.
6
+ * @param page - source page.
7
+ * @returns its lines, preserving one empty line but excluding a zero-line page.
8
+ */
9
+ export declare function linesOf(page: TextPage): string[];
10
+ /** Loaded source page with its 1-based start position. */
11
+ export type LoadedPage = DocumentTextPage;
12
+ /**
13
+ * Order loaded pages by source position.
14
+ * @param pages - stored page table.
15
+ * @returns pages in source order.
16
+ */
17
+ export declare function loadedPages(pages: Readonly<Record<number, TextPage>>): LoadedPage[];
18
+ /**
19
+ * Find the end of the loaded source prefix.
20
+ * @param pages - ordered pages.
21
+ * @returns the last loaded source line, or zero.
22
+ */
23
+ export declare function lastLineLoaded(pages: readonly LoadedPage[]): number;
24
+ /**
25
+ * Reveal a plain-text or highlighted source line.
26
+ * @param body - scrolling document body or code-content viewport.
27
+ * @param line - 1-based source line to reveal.
28
+ * @returns Whether the current renderer exposes that line.
29
+ */
30
+ export declare function scrollToLine(body: HTMLElement, line: number): boolean;
31
+ //# sourceMappingURL=lines.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Inline video preview: play the file in a native `<video>` element that
3
+ * streams from the host media route (HTTP Range windows make scrubbing
4
+ * work). The element fetches its own bytes, so the body reports readiness
5
+ * through the renderer contract on mount and failure through the element's
6
+ * error event; a decode failure degrades to the download affordance.
7
+ */
8
+ import { type ReactNode } from 'react';
9
+ import type { DocumentPreviewProps } from '../document/contract.ts';
10
+ import type { PropsLocale } from '@qilin-agent/client-ui-slots';
11
+ /** Document input plus localized copy. */
12
+ export type VideoBodyProps = DocumentPreviewProps & PropsLocale<'sidebarVideo'>;
13
+ /**
14
+ * Play one video file with seek support and a download fallback.
15
+ * @param props - Renderer-owned document seats (the element streams itself).
16
+ * @returns The player stage with its meta row.
17
+ */
18
+ export declare function VideoBody({ content, resourceAddress, t }: VideoBodyProps): ReactNode;
19
+ //# sourceMappingURL=VideoBody.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Video previews stream from the host media route: the `<video>` element
3
+ * fetches its own bytes with HTTP Range requests (the route answers 206
4
+ * windows), so scrubbing works and the file never counts against the
5
+ * whole-file cap. The player is a few KB — no lazy chunk.
6
+ */
7
+ import type { Context } from '@qilin-agent/kylin';
8
+ /** Video extensions the viewer claims; `ts` is NOT claimed (TypeScript collision; `m2ts` covers MPEG-TS). */
9
+ export declare const VIDEO_EXTENSIONS: readonly ["mp4", "webm", "mov", "qt", "m4v", "mkv", "avi", "wmv", "flv", "ogv", "ogg", "mpeg", "mpg", "3gp", "3g2", "m2ts"];
10
+ /**
11
+ * Register the browser video viewer and its lifecycle-owned slot.
12
+ * @param ctx - Preview and locale registries.
13
+ */
14
+ export declare function apply(ctx: Context): void;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
1
+ /** Locale-owned video preview status and fallback copy. */
2
+ export declare const zh: {
3
+ title: string;
4
+ videoUnsupported: string;
5
+ downloadToView: string;
6
+ };
7
+ /** Video preview dictionary keys. */
8
+ export type VideoPreviewKey = keyof typeof zh;
9
+ /** English video preview copy. */
10
+ export declare const en: {
11
+ title: string;
12
+ videoUnsupported: string;
13
+ downloadToView: string;
14
+ };
15
+ declare module '@qilin-agent/client-ui-slots' {
16
+ interface LocaleNamespaceMap {
17
+ /** Video preview status and fallback copy. */
18
+ sidebarVideo: VideoPreviewKey;
19
+ }
20
+ }
21
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { type ZoomLabels } from './types.ts';
2
+ /** Live percentage display updated independently from the document tree. */
3
+ export interface ZoomControlsHandle {
4
+ /** @param zoom - current gesture scale multiplier. */
5
+ showZoom: (zoom: number) => void;
6
+ }
7
+ /**
8
+ * Present fit-width, fixed presets, and incremental controls.
9
+ * @param props - current resolved zoom, preference mode, labels, and callbacks.
10
+ * @returns a localized zoom toolbar.
11
+ */
12
+ export declare const ZoomControls: import("react").ForwardRefExoticComponent<{
13
+ readonly zoom: number;
14
+ readonly fitWidth: boolean;
15
+ readonly labels: ZoomLabels;
16
+ readonly visible: boolean;
17
+ readonly onZoom: (zoom: number) => void;
18
+ readonly onFitWidth: () => void;
19
+ readonly onActiveChange: (active: boolean) => void;
20
+ } & import("react").RefAttributes<ZoomControlsHandle>>;
21
+ //# sourceMappingURL=ZoomControls.d.ts.map
@@ -0,0 +1,27 @@
1
+ /** Shared zoom viewport, gesture handling, anchoring, and fit-width measurement. */
2
+ import { type ReactNode, type RefCallback } from 'react';
3
+ import { type ZoomLabels, type ZoomPreference } from './types.ts';
4
+ /** @returns an actual-size scale that only shrinks content wider than the viewport. */
5
+ export declare function fitWidthZoom(viewportWidth: number, intrinsicWidth: number | undefined, horizontalInset?: number): number;
6
+ /** Shared viewport inputs for renderer-owned content and tab state. */
7
+ export interface ZoomViewportProps {
8
+ readonly preference: ZoomPreference;
9
+ readonly intrinsicWidth: number | undefined;
10
+ readonly horizontalInset?: number;
11
+ readonly labels: ZoomLabels;
12
+ readonly signal: AbortSignal;
13
+ readonly scrollportRef: RefCallback<HTMLElement>;
14
+ readonly onPreference: (preference: ZoomPreference) => void;
15
+ /** Resolved scale after a gesture settles or fit-width measurement changes. */
16
+ readonly onRenderZoom?: (zoom: number) => void;
17
+ readonly children: ReactNode;
18
+ }
19
+ /**
20
+ * Keep zoom controls and trackpad gestures independent from document rendering.
21
+ * @param props - renderer content, intrinsic width, tab preference, and localized labels.
22
+ * @returns the owned scrollport and floating zoom controls.
23
+ */
24
+ export declare function ZoomViewport(props: ZoomViewportProps): ReactNode;
25
+ /** Shared surface class for actual-size and fit-width layout. */
26
+ export declare const zoomSurfaceClass: string;
27
+ //# sourceMappingURL=ZoomViewport.d.ts.map
@@ -0,0 +1,21 @@
1
+ /** Shared zoom copy embedded into renderer-owned dictionaries. */
2
+ export declare const zoomZh: {
3
+ readonly zoomControls: "缩放控件";
4
+ readonly zoomMenu: "选择缩放比例";
5
+ readonly zoomOut: "缩小";
6
+ readonly zoomIn: "放大";
7
+ readonly zoomFitWidth: "适应宽度";
8
+ readonly zoomValue: "{percent}%";
9
+ };
10
+ /** Shared English zoom copy. */
11
+ export declare const zoomEn: {
12
+ zoomControls: string;
13
+ zoomMenu: string;
14
+ zoomOut: string;
15
+ zoomIn: string;
16
+ zoomFitWidth: string;
17
+ zoomValue: string;
18
+ };
19
+ /** Shared zoom dictionary keys. */
20
+ export type ZoomLocaleKey = keyof typeof zoomZh;
21
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,28 @@
1
+ /** Tab-local zoom preferences for renderers without additional view state. */
2
+ import { type EngineStoreHandle } from '@qilin-agent/client-store';
3
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
4
+ import { type ZoomPreference } from './types.ts';
5
+ /** Tab-lifetime callback supplied by a zoomable renderer registration. */
6
+ export interface ZoomInjected {
7
+ /** @param tabId - owning tab. @param signal - complete tab-record lifetime. */
8
+ readonly retainTab: (tabId: TabId, signal: AbortSignal) => void;
9
+ }
10
+ /** Zoom state isolated by the owning tab record. */
11
+ export interface ZoomState {
12
+ byTab: Record<TabId, ZoomPreference>;
13
+ }
14
+ type ZoomActions = {
15
+ zoom: (draft: ZoomState, tabId: TabId, preference: ZoomPreference) => void;
16
+ forget: (draft: ZoomState, tabId: TabId) => void;
17
+ };
18
+ /**
19
+ * Create tab-local zoom state for a document renderer registration.
20
+ * @returns a store declaration retaining zoom until its tab closes.
21
+ */
22
+ export declare function createZoomStore(): EngineStoreHandle<ZoomState, ZoomActions>;
23
+ /** Default zoom value for a tab without retained state. */
24
+ export declare const DEFAULT_ZOOM: ZoomPreference;
25
+ /** Store declaration used by image previews. */
26
+ export type ZoomStore = ReturnType<typeof createZoomStore>;
27
+ export {};
28
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,27 @@
1
+ /** Automatic fit or an explicit actual-size scale selected by the reader. */
2
+ export type ZoomPreference = {
3
+ readonly kind: 'fit-width';
4
+ } | {
5
+ readonly kind: 'fixed';
6
+ readonly scale: number;
7
+ };
8
+ /** Default preference for a newly opened zoomable preview. */
9
+ export declare const FIT_WIDTH: ZoomPreference;
10
+ /** Minimum scale retained by a fixed zoom preference. */
11
+ export declare const MIN_FIXED_ZOOM = 0.25;
12
+ /** Maximum scale retained by a fixed zoom preference. */
13
+ export declare const MAX_FIXED_ZOOM = 4;
14
+ /** Scale interval used by the incremental controls. */
15
+ export declare const ZOOM_STEP = 0.25;
16
+ /** Fixed scale choices shown in the zoom menu. */
17
+ export declare const ZOOM_OPTIONS: readonly [0.25, 0.5, 1, 1.5, 2];
18
+ /** Localized copy consumed by the framework-free zoom controls. */
19
+ export interface ZoomLabels {
20
+ readonly controls: string;
21
+ readonly menu: string;
22
+ readonly out: string;
23
+ readonly into: string;
24
+ readonly fitWidth: string;
25
+ readonly value: (percent: number) => string;
26
+ }
27
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,31 @@
1
+ /** Cache limits shared by the Host configuration and browser document previews. */
2
+ import z from '@qilin-agent/schemastery';
3
+ /** Transient Office conversion reuse within one Client connection. */
4
+ export interface Config {
5
+ /** Retained PDF limits; pending conversions share cancellation by reader lifetime. */
6
+ office: {
7
+ /** Maximum retained completed PDFs. */
8
+ maxCachedEntries: number;
9
+ /** Maximum retained PDF bytes, counted by each binary buffer's byteLength. */
10
+ maxCachedBytes: number;
11
+ /** Maximum unsettled Host conversion RPCs, including cancellation teardown. */
12
+ maxPending: number;
13
+ /** Maximum readers including source and renderer metadata lookups. */
14
+ maxReaders: number;
15
+ };
16
+ /** Browser spreadsheet parser and dense cell allocation limits. */
17
+ excel: {
18
+ /** Maximum source file bytes. */
19
+ maxBytes: number;
20
+ /** Maximum combined rectangular cell area across worksheets. */
21
+ maxCells: number;
22
+ /** Maximum parser Worker lifetime in milliseconds. */
23
+ timeoutMs: number;
24
+ };
25
+ }
26
+ /** Deployment limits applied before Office preview registration. */
27
+ export declare const Config: z<{
28
+ office?: Partial<Config['office']>;
29
+ excel?: Partial<Config['excel']>;
30
+ }, Config>;
31
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1,11 @@
1
+ /** Host configuration for browser document previews. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { Config } from './config.ts';
4
+ export { Config } from './config.ts';
5
+ /**
6
+ * Embed validated preview settings in browser pages.
7
+ * @param ctx - Host context serving browser pages.
8
+ * @param config - Cache limits adopted when the page loads.
9
+ */
10
+ export declare function apply(ctx: Context, config: Config): void;
11
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,103 @@
1
1
  {
2
2
  "name": "@qilin-agent/client-ui-sidebar-documentpreview",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "Extensible document previews for Sidebar files: Office, Markdown, highlighted code, images, PDF, HTML, and plain text",
4
+ "version": "3.1.4",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/kkutysllb/QiLin.git",
11
+ "directory": "packages/client/ui-sidebar-documentpreview"
12
+ },
13
+ "engines": {
14
+ "node": "^22.19.0 || >=24.0.0"
15
+ },
16
+ "type": "module",
17
+ "main": "lib/index.js",
18
+ "types": "lib/types/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./lib/types/index.d.ts",
22
+ "default": "./lib/index.js"
23
+ },
24
+ "./client": {
25
+ "types": "./lib/types/client/index.d.ts",
26
+ "default": "./lib/client.js"
27
+ },
28
+ "./src/*": "./src/*",
29
+ "./package.json": "./package.json"
30
+ },
31
+ "qilin": {
32
+ "client": {
33
+ "inject": [
34
+ "@qilin-agent/api-gateway",
35
+ "@qilin-agent/api-workspace-files",
36
+ "@qilin-agent/client-resources",
37
+ "@qilin-agent/client-ui-sidebar-right",
38
+ "@qilin-agent/client-ui-session",
39
+ "@qilin-agent/client-ui-conversation",
40
+ "@qilin-agent/api-remotes",
41
+ "@qilin-agent/client-locale",
42
+ "@qilin-agent/client-ui-settings"
43
+ ],
44
+ "platform": "web"
45
+ }
46
+ },
47
+ "license": "MIT",
48
+ "peerDependencies": {
49
+ "@qilin-agent/kylin": "~4.0.3"
50
+ },
51
+ "devDependencies": {
52
+ "@fortune-sheet/core": "1.0.4",
53
+ "@fortune-sheet/react": "1.0.4",
54
+ "@testing-library/react": "^16.1.0",
55
+ "@types/papaparse": "^5.3.16",
56
+ "@types/react": "~18.3.1",
57
+ "@types/react-dom": "~18.3.0",
58
+ "clsx": "^2.0.0",
59
+ "dompurify": "^3.4.11",
60
+ "exceljs": "4.4.0",
61
+ "fast-xml-parser": "5.11.1",
62
+ "fflate": "^0.8.3",
63
+ "papaparse": "5.5.3",
64
+ "pdfjs-dist": "6.3.289",
65
+ "react": "^18.2.0",
66
+ "react-dom": "^18.2.0",
67
+ "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
68
+ "@qilin-agent/api-gateway": "3.1.4",
69
+ "@qilin-agent/kylin": "~4.0.3",
70
+ "@qilin-agent/client-connection": "3.1.4",
71
+ "@qilin-agent/api-remotes": "3.1.4",
72
+ "@qilin-agent/api-workspace-files": "3.1.4",
73
+ "@qilin-agent/client-locale": "3.1.4",
74
+ "@qilin-agent/client-resources": "3.1.4",
75
+ "@qilin-agent/client-store": "3.1.4",
76
+ "@qilin-agent/client-test-runtime": "3.1.4",
77
+ "@qilin-agent/client-ui-conversation": "3.1.4",
78
+ "@qilin-agent/client-ui-dockkit": "3.1.4",
79
+ "@qilin-agent/client-ui-primitives": "3.1.4",
80
+ "@qilin-agent/client-ui-session": "3.1.4",
81
+ "@qilin-agent/client-ui-settings": "3.1.4",
82
+ "@qilin-agent/client-ui-sidebar-right": "3.1.4",
83
+ "@qilin-agent/client-ui-renderer": "3.1.4",
84
+ "@qilin-agent/client-ui-slots": "3.1.4",
85
+ "@qilin-agent/host-webserver": "3.1.4",
86
+ "@qilin-agent/session": "3.1.4",
87
+ "@qilin-agent/office-to-pdf": "3.1.4",
88
+ "@qilin-agent/util-workspace-path": "3.1.4"
89
+ },
90
+ "files": [
91
+ "lib/index.js",
92
+ "lib/client.js",
93
+ "lib/client.*.js",
94
+ "lib/types/**/*.d.ts"
95
+ ],
96
+ "dependencies": {
97
+ "@qilin-agent/schemastery": "~3.18.3"
98
+ },
99
+ "scripts": {
100
+ "bundle": "tsdown",
101
+ "watch": "tsdown --watch"
102
+ }
6
103
  }