@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,16 @@
1
+ /** Missing-font notice and a non-modal details panel for one source version. */
2
+ import { type ReactNode } from 'react';
3
+ import type { PropsLocale } from '@qilin-agent/client-ui-slots';
4
+ /** Notice inputs supplied by the document owner and Office locale registration. */
5
+ export type FontNoticeProps = PropsLocale<'sidebarOffice'> & {
6
+ readonly resourceAddress: string;
7
+ readonly sourceVersion: string;
8
+ readonly fonts: readonly string[];
9
+ };
10
+ /**
11
+ * Show missing fonts; dismissal applies to the same source version while this component stays mounted.
12
+ * @param props - source identity, converted content, and localized copy.
13
+ * @returns a collapsible notice and its anchored details, or nothing when fonts are available.
14
+ */
15
+ export declare function FontNotice({ resourceAddress, sourceVersion, fonts, t }: FontNoticeProps): ReactNode;
16
+ //# sourceMappingURL=FontNotice.d.ts.map
@@ -0,0 +1,44 @@
1
+ /** Office owns source loading, conversion failures, and font notices around the shared PDF view. */
2
+ import { type ReactNode } from 'react';
3
+ import type { PropsLocale, PropsRenderSlots, PropsStore } from '@qilin-agent/client-ui-slots';
4
+ import type { RemoteFailure } from '@qilin-agent/api-remotes/client';
5
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
6
+ import type { UseSidebarRightTabInfo } from '@qilin-agent/client-ui-sidebar-right/client';
7
+ import type { DocumentBodyOwner, DocumentPreviewProps } from '../document/contract.ts';
8
+ import type { ReadOfficeDocument } from './cache.ts';
9
+ import type { OfficeStore } from './store.ts';
10
+ declare module '@qilin-agent/client-ui-slots' {
11
+ interface SlotMap {
12
+ /** PDF presentation supplied with Office-owned converted bytes. */
13
+ 'sidebar.right.tab.document.office.pdf': {
14
+ kind: 'keyed';
15
+ scope: 'session';
16
+ owner: DocumentBodyOwner;
17
+ hookContext: UseSidebarRightTabInfo;
18
+ inject: {
19
+ hooks: {
20
+ tabInfo: SlotHookFactory<'sidebar.right.tab.document', UseSidebarRightTabInfo>;
21
+ };
22
+ };
23
+ };
24
+ }
25
+ }
26
+ /** Office loading callbacks supplied by the registration's services. */
27
+ export interface OfficeBodyInjected {
28
+ readonly read: ReadOfficeDocument;
29
+ /** @param failure - declared file-read failure or conversion exception message. @returns localized display text. */
30
+ readonly describeFailure: (failure: RemoteFailure | {
31
+ readonly message: string;
32
+ }) => string;
33
+ /** @param tab - owning tab. @param signal - tab lifetime, including hidden bodies. */
34
+ readonly retainTab: (tab: TabId, signal: AbortSignal) => void;
35
+ }
36
+ /** Office body inputs and its private PDF child. */
37
+ export type OfficeBodyProps = DocumentPreviewProps & PropsStore<OfficeStore> & OfficeBodyInjected & PropsLocale<'sidebarOffice'> & PropsRenderSlots<'sidebar.right.tab.document.office.pdf'>;
38
+ /**
39
+ * Load one Office revision and preserve its result while its tab remains open.
40
+ * @param props - renderer loading request, tab state, conversion callbacks, and PDF slot.
41
+ * @returns conversion status or the font notice and PDF scrollport.
42
+ */
43
+ export declare function OfficeBody(props: OfficeBodyProps): ReactNode;
44
+ //# sourceMappingURL=OfficeBody.d.ts.map
@@ -0,0 +1,70 @@
1
+ /** Session-authorized, version-checked Office bytes shared by concurrent preview reads. */
2
+ import type { OfficeToPdfPriority, OfficeToPdfGeneration } from '@qilin-agent/office-to-pdf/types';
3
+ import type { RemoteResult } from '@qilin-agent/api-remotes/client';
4
+ import type { WorkspaceFileStat } from '@qilin-agent/api-workspace-files/types';
5
+ import type { DocumentFileBytes, SessionFile } from '../rpc.ts';
6
+ /** PDF bytes and conversion metadata owned by Office preview. */
7
+ export type OfficeFileBytes = DocumentFileBytes & {
8
+ readonly missingFonts: readonly string[];
9
+ readonly generation: OfficeToPdfGeneration;
10
+ };
11
+ /**
12
+ * Load authorized PDF contents for one Office source.
13
+ * @param file - Session and source path.
14
+ * @param signal - this reader's lifetime.
15
+ * @returns converted PDF bytes or a declared source-access failure.
16
+ */
17
+ export type ReadOfficeDocument = (file: SessionFile, signal: AbortSignal) => Promise<RemoteResult<OfficeFileBytes>>;
18
+ /** Authorized cached reads carry explicit scheduling intent to the Host. */
19
+ export type ReadOfficeBytes = (file: SessionFile, signal: AbortSignal, priority: OfficeToPdfPriority) => ReturnType<ReadOfficeDocument>;
20
+ type Result = Awaited<ReturnType<ReadOfficeDocument>>;
21
+ type Stat = (file: SessionFile, signal: AbortSignal) => Promise<RemoteResult<WorkspaceFileStat>>;
22
+ /** Bounded successful results; each caller reauthorizes and checks source freshness before reuse. */
23
+ export declare class OfficePreviewCache {
24
+ private readonly stat;
25
+ private readonly convert;
26
+ private readonly maxEntries;
27
+ private readonly maxBytes;
28
+ private readonly maxPending;
29
+ private readonly maxReaders;
30
+ private readonly currentGeneration;
31
+ private readonly busy;
32
+ private readonly ready;
33
+ private readonly pending;
34
+ private bytes;
35
+ private readers;
36
+ private generation;
37
+ private generationQuery;
38
+ private acceptedQuery;
39
+ private readonly superseded;
40
+ private readonly lifetime;
41
+ private readonly tasks;
42
+ private readonly reads;
43
+ /**
44
+ * @param stat - authorized source metadata lookup.
45
+ * @param convert - Host render Remote returning binary PDF bytes borrowed read-only by callers.
46
+ * @param maxEntries - maximum completed results retained.
47
+ * @param maxBytes - maximum retained PDF byteLength.
48
+ * @param maxPending - maximum unsettled Host conversion requests, including cancellation teardown.
49
+ * @param maxReaders - maximum readers, including metadata lookups.
50
+ * @param generation - current Host renderer generation, checked before cached reuse.
51
+ * @param busy - localized capacity failure.
52
+ */
53
+ constructor(stat: Stat, convert: ReadOfficeBytes, maxEntries: number, maxBytes: number, maxPending: number, maxReaders: number, currentGeneration: (signal: AbortSignal) => Promise<RemoteResult<OfficeToPdfGeneration>>, busy: () => Error);
54
+ /**
55
+ * Share a conversion without letting one caller cancel another caller's work.
56
+ * Renderer replacement retries authorization once; repeated replacement reports localized capacity failure.
57
+ * @param file - Session authorization scope and source path.
58
+ * @param signal - this caller's lifetime.
59
+ * @param priority - foreground preview or speculative read.
60
+ * @returns current PDF bytes borrowed read-only, or a declared source-read failure; cancellation rejects.
61
+ */
62
+ read(file: SessionFile, signal: AbortSignal, priority?: OfficeToPdfPriority): Promise<Result>;
63
+ private lookup;
64
+ private lookupGeneration;
65
+ /** Clear retained bytes, cancel outstanding conversions, and await their completion. */
66
+ dispose(): Promise<void>;
67
+ private retain;
68
+ }
69
+ export {};
70
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1,16 @@
1
+ /** Office preview registration backed by authorized Host rendering and the existing PDF body. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import { type OfficePreviewKey } from './locales.ts';
4
+ import type { Config } from '../../config.ts';
5
+ declare module '@qilin-agent/client-ui-slots' {
6
+ interface LocaleNamespaceMap {
7
+ sidebarOffice: OfficePreviewKey;
8
+ }
9
+ }
10
+ /**
11
+ * Register Office previews with versioned PDF reuse and missing-font notices.
12
+ * @param ctx - Client renderer registry, localized copy, and optional Host Remotes.
13
+ * @param config - Resolved Office preview cache limits.
14
+ */
15
+ export declare function apply(ctx: Context, config: Config['office']): void;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,43 @@
1
+ /** Office preview copy and Host render configuration guidance. */
2
+ export declare const zh: {
3
+ title: string;
4
+ loading: string;
5
+ retry: string;
6
+ missingFonts: string;
7
+ showMore: string;
8
+ dismissNotice: string;
9
+ missingFontsTitle: string;
10
+ missingFontsDescription: string;
11
+ missingFontsCount: string;
12
+ closeDetails: string;
13
+ unavailable: string;
14
+ invalid: string;
15
+ tooLarge: string;
16
+ failed: string;
17
+ timeout: string;
18
+ busy: string;
19
+ changed: string;
20
+ };
21
+ /** Office preview locale keys. */
22
+ export type OfficePreviewKey = keyof typeof zh;
23
+ /** English translations checked against the Chinese key set. */
24
+ export declare const en: {
25
+ title: string;
26
+ loading: string;
27
+ retry: string;
28
+ missingFonts: string;
29
+ showMore: string;
30
+ dismissNotice: string;
31
+ missingFontsTitle: string;
32
+ missingFontsDescription: string;
33
+ missingFontsCount: string;
34
+ closeDetails: string;
35
+ unavailable: string;
36
+ invalid: string;
37
+ tooLarge: string;
38
+ failed: string;
39
+ timeout: string;
40
+ busy: string;
41
+ changed: string;
42
+ };
43
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,32 @@
1
+ /** Loaded Office previews survive body remounts until reload or tab closure. */
2
+ import { type EngineStoreHandle } from '@qilin-agent/client-store';
3
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
4
+ import type { OfficeFileBytes } from './cache.ts';
5
+ /** One requested source revision and its settled preview. */
6
+ export interface OfficeView {
7
+ readonly revision: number;
8
+ readonly file?: OfficeFileBytes;
9
+ readonly failure?: {
10
+ readonly code: string;
11
+ readonly message: string;
12
+ };
13
+ }
14
+ /** Office-owned content, isolated by tab identity. */
15
+ export interface OfficeState {
16
+ byTab: Record<TabId, OfficeView>;
17
+ }
18
+ type OfficeActions = {
19
+ loading: (state: OfficeState, tab: TabId, revision: number) => void;
20
+ complete: (state: OfficeState, tab: TabId, revision: number, file: OfficeFileBytes) => void;
21
+ failed: (state: OfficeState, tab: TabId, revision: number, failure: NonNullable<OfficeView['failure']>) => void;
22
+ forget: (state: OfficeState, tab: TabId) => void;
23
+ };
24
+ /**
25
+ * Retain Office contents across body remounts within a Session.
26
+ * @returns the tab-content store declaration.
27
+ */
28
+ export declare function createOfficeStore(): EngineStoreHandle<OfficeState, OfficeActions>;
29
+ /** Store declaration used by the Office body. */
30
+ export type OfficeStore = ReturnType<typeof createOfficeStore>;
31
+ export {};
32
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,10 @@
1
+ /** Load the PDF renderer only after a PDF body is mounted. */
2
+ import { type ReactNode } from 'react';
3
+ import type { PdfBodyProps } from './pdf.tsx';
4
+ /**
5
+ * Suspend while the package-local PDF chunk arrives.
6
+ * @param props - PDF body props supplied by the document slot.
7
+ * @returns the deferred PDF renderer.
8
+ */
9
+ export declare function LazyPdfBody(props: PdfBodyProps): ReactNode;
10
+ //# sourceMappingURL=LazyPdfBody.d.ts.map
@@ -0,0 +1,26 @@
1
+ /** Build-owned, same-version PDF.js resources; all binary assets are decoded locally. */
2
+ import workerSource from 'pdfjs-dist/build/pdf.worker.min.mjs?raw';
3
+ export { workerSource };
4
+ /** Resource kinds used by PDF.js 6's BinaryDataFactory requests. */
5
+ export type PdfAssetKind = 'cMapUrl' | 'standardFontDataUrl' | 'wasmUrl';
6
+ /** Original filenames mapped to base64, in the same PDF.js version as the worker. */
7
+ export type PdfAssetMap = Readonly<Record<PdfAssetKind, Readonly<Record<string, string>>>>;
8
+ declare global {
9
+ /** Inline artifact data supplied by the package-local build configuration. */
10
+ const __QILIN_PDFJS_ASSETS__: PdfAssetMap;
11
+ }
12
+ /** Public methods required by PDF.js's BinaryDataFactory option. */
13
+ export interface PdfBinaryDataFactory {
14
+ /** @param request - PDF.js resource kind and exact filename. @returns independent transferable resource bytes. */
15
+ fetch(request: {
16
+ readonly kind: PdfAssetKind;
17
+ readonly filename: string;
18
+ }): Promise<Uint8Array>;
19
+ }
20
+ /**
21
+ * Capture this build's binary assets without network fallbacks.
22
+ * @param assets - build-inlined base64 resources, read only when a PDF is opened.
23
+ * @returns the constructor passed to PDF.js getDocument.
24
+ */
25
+ export declare function createPdfBinaryDataFactory(assets?: PdfAssetMap): new () => PdfBinaryDataFactory;
26
+ //# sourceMappingURL=assets.d.ts.map
@@ -0,0 +1,38 @@
1
+ /** Canvas rendering with cancellation and page cleanup, shared by the PDF body and real-library smoke. */
2
+ import type { PDFDocumentProxy, PDFPageProxy, PageViewport } from 'pdfjs-dist';
3
+ /** The document operations used by one mounted PDF body. */
4
+ export type PdfDocument = Pick<PDFDocumentProxy, 'numPages' | 'getPage'>;
5
+ /** One in-flight PDF load and its complete cleanup operation. */
6
+ export interface PdfSession {
7
+ readonly document: Promise<PdfDocument>;
8
+ /**
9
+ * Cancel loading and rendering, destroy the document, and release its worker.
10
+ * Library teardown failures are logged after native resources are released.
11
+ * @returns cleanup completion without rejection.
12
+ */
13
+ dispose(): Promise<void>;
14
+ }
15
+ /** Page geometry expressed in CSS pixels. */
16
+ export interface PdfPageSize {
17
+ readonly width: number;
18
+ readonly height: number;
19
+ }
20
+ /** Optional DOM text rendering that shares the canvas page's cleanup barrier. */
21
+ export type RenderPdfText = (page: PDFPageProxy, viewport: PageViewport) => {
22
+ readonly promise: Promise<void>;
23
+ cancel(): void;
24
+ };
25
+ /**
26
+ * Render one page into an exclusively owned canvas. Cancellation cannot write
27
+ * dimensions after a delayed getPage; active render tasks are cancelled and
28
+ * awaited before the page is cleaned up.
29
+ * @param document - loaded pdfjs document.
30
+ * @param pageNumber - 1-based selected page.
31
+ * @param canvas - canvas owned by this render only.
32
+ * @param signal - render lifetime.
33
+ * @param pixelRatio - device pixel ratio multiplied by the settled document zoom.
34
+ * @param renderText - optional selectable text layer sharing this page and viewport.
35
+ * @returns the page's CSS dimensions after rendering completes.
36
+ */
37
+ export declare function renderPdfPage(document: PdfDocument, pageNumber: number, canvas: HTMLCanvasElement, signal: AbortSignal, pixelRatio: number, renderText?: RenderPdfText): Promise<PdfPageSize>;
38
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1,8 @@
1
+ /** Structured PDF worker failures; the renderer's locale owns visible explanations. */
2
+ export declare class PdfWorkerFailure extends Error {
3
+ /** Distinguishes Worker startup/transport failures from document parsing errors. */
4
+ readonly kind = "worker";
5
+ /** @param cause - native error or messageerror event, retained for diagnostics. */
6
+ constructor(cause: Event);
7
+ }
8
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,27 @@
1
+ /** Builtin PDF registration through document metadata and the keyed body slot. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { DocumentPreviewDefinition } from '../document/registry.ts';
4
+ import type { PdfBodyInjected } from './pdf.tsx';
5
+ import type { BoundActions } from '@qilin-agent/client-store';
6
+ import type { SessionId } from '@qilin-agent/session/types';
7
+ import { type PdfStore } from './store.ts';
8
+ /** PDF metadata and keyed body share this package-local implementation identity. */
9
+ export declare const PDF_BODY_ID = "@qilin-agent/client-ui-sidebar-documentpreview/pdf";
10
+ /**
11
+ * Describe the builtin PDF renderer independently from its keyed body slot.
12
+ * @param title - locale-owned implementation name.
13
+ * @returns the complete-file PDF registration.
14
+ */
15
+ export declare function pdfBodyDefinition(title: () => string): DocumentPreviewDefinition;
16
+ /** @param ctx - context carrying the locale, document registry, and slot registry. */
17
+ export declare function apply(ctx: Context): void;
18
+ /**
19
+ * Retain PDF viewing state for a document entry's tab lifetime.
20
+ * @param ctx - owning registration context.
21
+ * @returns the store and injection shared by ordinary and Office PDF registrations.
22
+ */
23
+ export declare function pdfBodyRegistration(ctx: Context): {
24
+ store: PdfStore;
25
+ inject: (sessionId: SessionId, actions: BoundActions<PdfStore>) => PdfBodyInjected;
26
+ };
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,45 @@
1
+ /** Copy owned by the PDF renderer. */
2
+ export declare const zh: {
3
+ title: string;
4
+ pageImage: string;
5
+ loading: string;
6
+ rendering: string;
7
+ failed: string;
8
+ password: string;
9
+ workerFailed: string;
10
+ unsupported: string;
11
+ retry: string;
12
+ zoomControls: "缩放控件";
13
+ zoomMenu: "选择缩放比例";
14
+ zoomOut: "缩小";
15
+ zoomIn: "放大";
16
+ zoomFitWidth: "适应宽度";
17
+ zoomValue: "{percent}%";
18
+ };
19
+ /** PDF translation keys shared by both dictionaries. */
20
+ export type PdfLocaleKey = keyof typeof zh;
21
+ /** English PDF-renderer dictionary. */
22
+ export declare const en: {
23
+ title: string;
24
+ pageImage: string;
25
+ loading: string;
26
+ rendering: string;
27
+ failed: string;
28
+ password: string;
29
+ workerFailed: string;
30
+ unsupported: string;
31
+ retry: string;
32
+ zoomControls: string;
33
+ zoomMenu: string;
34
+ zoomOut: string;
35
+ zoomIn: string;
36
+ zoomFitWidth: string;
37
+ zoomValue: string;
38
+ };
39
+ declare module '@qilin-agent/client-ui-slots' {
40
+ interface LocaleNamespaceMap {
41
+ /** PDF page, loading, and failure messages. */
42
+ sidebarPdf: PdfLocaleKey;
43
+ }
44
+ }
45
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,29 @@
1
+ /** PDF page presentation; binary content and tab information come from the document owner. */
2
+ import { type ComponentType, type ReactNode } from 'react';
3
+ import type { PropsLocale, PropsStore } from '@qilin-agent/client-ui-slots';
4
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
5
+ import type { DocumentPreviewProps } from '../document/contract.ts';
6
+ import type { PdfStore } from './store.ts';
7
+ import type { ZoomViewportProps } from '../zoom/ZoomViewport.tsx';
8
+ /** A record's viewing preferences survive body unmounts and leave with the tab. */
9
+ export interface PdfBodyInjected {
10
+ /**
11
+ * Retain viewing preferences until the tab record ends.
12
+ * @param tabId - owning tab.
13
+ * @param signal - tab-record lifetime, not body visibility.
14
+ */
15
+ readonly retainTab: (tabId: TabId, signal: AbortSignal) => void;
16
+ /** Main-bundle viewport reused by the lazy PDF body. */
17
+ readonly ZoomViewport: ComponentType<ZoomViewportProps>;
18
+ /** Main-bundle class implementing fit-width and fixed-size surfaces. */
19
+ readonly zoomSurfaceClass: string;
20
+ }
21
+ /** Standard document props plus the PDF entry's locale, viewing store, and lifetime callback. */
22
+ export type PdfBodyProps = DocumentPreviewProps & PropsLocale<'sidebarPdf'> & PropsStore<PdfStore> & PdfBodyInjected;
23
+ /**
24
+ * Present a PDF with tab-local viewing preferences and component-owned rendering resources.
25
+ * @param props - complete bytes and framework-owned tab/store/locale seats.
26
+ * @returns the PDF reader.
27
+ */
28
+ export declare function PdfBody(props: PdfBodyProps): ReactNode;
29
+ //# sourceMappingURL=pdf.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { PdfSession } from './document.ts';
2
+ import { PdfWorkerFailure } from './errors.ts';
3
+ /**
4
+ * Open complete PDF bytes with an explicitly owned Worker. Startup failure
5
+ * never falls back to main-thread PDF parsing. Disposal keeps the Worker alive
6
+ * for PDF.js teardown, except after a fatal worker error, then terminates the
7
+ * native Worker and revokes its source URL.
8
+ * @param data - complete PDF bytes retained by the preview; the worker receives a copy.
9
+ * @param signal - document/body lifetime.
10
+ * @param reportFailure - reports a fatal Worker failure, including failures after document loading.
11
+ * @returns the pending document and idempotent asynchronous cleanup.
12
+ */
13
+ export declare function openPdf(data: Uint8Array<ArrayBuffer>, signal: AbortSignal, reportFailure: (error: PdfWorkerFailure) => void): PdfSession;
14
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1,27 @@
1
+ /** Restorable PDF viewing preferences; document objects and canvases remain component-local. */
2
+ import { type EngineStoreHandle } from '@qilin-agent/client-store';
3
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
4
+ import type { ZoomPreference } from '../zoom/types.ts';
5
+ /** One tab's last visible page and optional PDF zoom preference. */
6
+ export interface PdfView {
7
+ readonly page: number;
8
+ readonly zoom?: ZoomPreference;
9
+ }
10
+ /** Page state isolated by the owning tab record. */
11
+ export interface PdfState {
12
+ byTab: Record<TabId, PdfView>;
13
+ }
14
+ type PdfActions = {
15
+ page: (draft: PdfState, tabId: TabId, page: number) => void;
16
+ zoom: (draft: PdfState, tabId: TabId, zoom: ZoomPreference) => void;
17
+ forget: (draft: PdfState, tabId: TabId) => void;
18
+ };
19
+ /**
20
+ * Declare the last visible page and zoom preference isolated by tab identity.
21
+ * @returns a store declaration instantiated by the document slot for each Session.
22
+ */
23
+ export declare function createPdfStore(): EngineStoreHandle<PdfState, PdfActions>;
24
+ /** Store declaration used by the PDF body registration. */
25
+ export type PdfStore = ReturnType<typeof createPdfStore>;
26
+ export {};
27
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,10 @@
1
+ /** PDF.js's viewer owns selection boundaries and copy normalization; the overlay follows its canvas. */
2
+ import 'pdfjs-dist';
3
+ import type { RenderPdfText } from './document.ts';
4
+ /**
5
+ * Create a selectable overlay in a component-owned host.
6
+ * @param host - absolute overlay matching the displayed canvas dimensions.
7
+ * @returns renderer whose cancellation also releases its resize observer and DOM.
8
+ */
9
+ export declare function pdfTextRenderer(host: HTMLDivElement): RenderPdfText;
10
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The paged read this type performs, bound to the Client Remote.
3
+ *
4
+ * Content is the consumer's business: the `file` resource carries metadata only,
5
+ * and the text arrives here one page of lines at a time. The endpoint takes a
6
+ * session and a workspace path while a tab carries a `qilin-resource://file/`
7
+ * session address, so this module also owns that translation.
8
+ */
9
+ import type { RemoteResult } from '@qilin-agent/api-remotes/client';
10
+ import type { SessionId } from '@qilin-agent/session/types';
11
+ import type { WorkspaceFileBytes, WorkspaceFileRange, WorkspaceFileText } from '@qilin-agent/api-workspace-files/types';
12
+ /** The slice of the Client Remote this package calls. */
13
+ export interface WorkspaceFilesReadRemote {
14
+ readonly workspaceFiles: {
15
+ /**
16
+ * Read one page of lines.
17
+ * @param sessionId - the session whose workspace resolves `path`.
18
+ * @param path - workspace path, absolute or relative to the workspace root.
19
+ * @param range - 1-based start line; the Host's page cap applies when `limit` is absent.
20
+ * @param signal - cancels the call.
21
+ * @returns the page, or the failure the Host declares.
22
+ */
23
+ read(sessionId: SessionId, path: string, range: WorkspaceFileRange, signal?: AbortSignal): Promise<RemoteResult<WorkspaceFileText>>;
24
+ };
25
+ }
26
+ /**
27
+ * The read one page performs, injected so the face stays host-free.
28
+ *
29
+ * The session travels with the call because the endpoint resolves the workspace
30
+ * root from it: the same path means different files in different sessions. A
31
+ * Remote call does not reject: the result carries the failure.
32
+ */
33
+ export type ReadWorkspaceFilePage = (sessionId: SessionId, path: string, offset: number, signal: AbortSignal) => Promise<RemoteResult<WorkspaceFileText>>;
34
+ /** The file one tab reads: the session the read runs under and the path handed to the Host. */
35
+ export interface SessionFile {
36
+ /** The Session whose workspace resolves relative paths. */
37
+ readonly sessionId: SessionId;
38
+ /** The path the Host receives, absolute or relative to the addressed Session's workspace. */
39
+ readonly path: string;
40
+ }
41
+ /**
42
+ * The session and path one `qilin-resource://file/…` address names.
43
+ *
44
+ * A `session` address names its own session and a relative or absolute path, so
45
+ * a tab addressed into another session reads from that session. An `absolute`
46
+ * address carries no session and cannot be read here. The registry routes only
47
+ * session-scoped `file` addresses to this type, so an address `parseFileAddress`
48
+ * rejects or that carries no session is a programming error and throws.
49
+ * @param address - a tab's `qilin-resource://file/…` address.
50
+ * @returns the session and the path to hand the endpoint.
51
+ */
52
+ export declare function hostFileOf(address: string): SessionFile;
53
+ /**
54
+ * Bind the paged read to one Remote face. The page length is the Host's
55
+ * configured cap, so no `limit` travels.
56
+ * @param remote - the Client Remote carrying the `workspaceFiles` namespace.
57
+ * @returns the read the face performs.
58
+ */
59
+ export declare function createReadPage(remote: WorkspaceFilesReadRemote): ReadWorkspaceFilePage;
60
+ /** Complete document bytes borrowed read-only by renderers; copy before transferring to a Worker. */
61
+ export type DocumentFileBytes = Omit<WorkspaceFileBytes, 'data'> & {
62
+ readonly data: Uint8Array<ArrayBuffer>;
63
+ };
64
+ /**
65
+ * Read a complete file through the Host endpoint.
66
+ * @param file - Session and path decoded from the tab address.
67
+ * @param signal - owning tab lifetime.
68
+ * @returns complete binary bytes, including declared failures.
69
+ */
70
+ export type ReadDocumentBytes = (file: SessionFile, signal: AbortSignal) => Promise<RemoteResult<DocumentFileBytes>>;
71
+ /**
72
+ * Decode one successful Remote byte result for document renderers.
73
+ * @param file - Host byte result with base64 data.
74
+ * @returns the same metadata with native bytes; malformed base64 throws.
75
+ */
76
+ export declare function documentFileBytes(file: WorkspaceFileBytes): DocumentFileBytes;
77
+ //# sourceMappingURL=rpc.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The text a viewer selection contributes to the conversation draft.
3
+ * Everything here is string math — no React, no ctx — so the unit tests cover
4
+ * it directly.
5
+ *
6
+ * Insert shape:
7
+ * - Selection of at most {@link SELECTION_LIMIT} characters: a fenced block
8
+ * whose info line is the viewer's path with the selected line span, and
9
+ * whose body is the selected text.
10
+ * - Longer selection: the info line alone, because an empty fence in the draft
11
+ * costs a keystroke to delete and says nothing the line does not.
12
+ * - The path is the tab address's own path, which is already the
13
+ * workspace-relative spelling when the file is inside the Session workspace.
14
+ * - A single-line selection writes `path:12`; a multi-line one writes
15
+ * `path:12-15`. The rendered preview cannot map its DOM back to source
16
+ * lines, so the lines come from {@link linesOfSelection} — a best-effort
17
+ * reverse search that reports nothing on an ambiguous or missing hit.
18
+ */
19
+ /** Longest selected text inserted with its content, in UTF-16 code units. */
20
+ export declare const SELECTION_LIMIT = 500;
21
+ /** The source line span one selection maps to, 1-based and inclusive. */
22
+ export interface SelectionLines {
23
+ readonly start: number;
24
+ readonly end: number;
25
+ }
26
+ /**
27
+ * The fenced block's info line: the viewer's path, followed by the line or
28
+ * line range when the selection mapped to source lines.
29
+ * @param path - the path the viewer opened.
30
+ * @param lines - the mapped source span, absent when the lookup reported none.
31
+ * @returns `rel`, `rel:12`, or `rel:12-15`.
32
+ */
33
+ export declare function headerOf(path: string, lines?: SelectionLines): string;
34
+ /**
35
+ * The text one selection appends to the composer draft.
36
+ * @param path - the path the viewer opened.
37
+ * @param lines - the mapped source span, absent when the lookup reported none.
38
+ * @param selected - the selected text as the DOM reported it.
39
+ * @returns the fenced block, or the info line alone for an oversized selection.
40
+ */
41
+ export declare function buildSelectionInsert(path: string, lines: SelectionLines | undefined, selected: string): string;
42
+ /**
43
+ * Reverse-map a rendered selection back to source lines. The preview's
44
+ * selection is plain text with block boundaries flattened to `\n`, so one
45
+ * trailing newline is stripped first and the rest is a substring search: only
46
+ * an exactly-once occurrence yields lines, because the reported ones must not
47
+ * point a reader at the wrong place.
48
+ * @param source - the file's text as the viewer read it.
49
+ * @param selected - the selected text as the DOM reported it.
50
+ * @returns the mapped span, or null when the hit is ambiguous or missing.
51
+ */
52
+ export declare function linesOfSelection(source: string, selected: string): SelectionLines | null;
53
+ //# sourceMappingURL=selection-payload.d.ts.map