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

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,21 @@
1
+ /** Owns the unpacked preview copy and its detected unsupported content. */
2
+ export declare class XlsxPreviewArchive {
3
+ private readonly bytes;
4
+ /** Detected workbook content that the preview does not display. */
5
+ readonly unsupportedFeatures: Set<"charts" | "images" | "shapes" | "conditionalFormatting">;
6
+ private readonly files;
7
+ private readonly parts;
8
+ /**
9
+ * Read an archive without modifying the borrowed source buffer.
10
+ * @param bytes - Complete XLSX source bytes.
11
+ * @throws When ZIP entries have ASCII case-equivalent names.
12
+ */
13
+ constructor(bytes: Uint8Array<ArrayBuffer>);
14
+ /**
15
+ * Omit DrawingML parts before ExcelJS parses them; callers must also ignore worksheet drawing references.
16
+ * @returns Source bytes when no parts were omitted, otherwise an uncompressed temporary ZIP.
17
+ */
18
+ withoutDrawings(): Uint8Array<ArrayBuffer>;
19
+ private inspectContent;
20
+ }
21
+ //# sourceMappingURL=xlsx-archive.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { type ExcelLimits, type ExcelPreview } from './model.ts';
2
+ /**
3
+ * Decode an XLSX into display cells, omitting drawings and retaining formulas without recalculation.
4
+ * @param bytes - Complete borrowed workbook bytes.
5
+ * @param limits - File and matrix allocation limits.
6
+ * @returns Sheets ready for a read-only FortuneSheet workbook.
7
+ */
8
+ export declare function convertXlsx(bytes: Uint8Array<ArrayBuffer>, limits: ExcelLimits): Promise<ExcelPreview>;
9
+ //# sourceMappingURL=xlsx.d.ts.map
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The preview's asynchronous half: reading pages into the store.
3
+ *
4
+ * The component never awaits anything. It asks for a page and this face performs
5
+ * the read and writes the outcome through the store's own actions — the
6
+ * Slot-standard `inject` form, so the write set stays the store's. The session
7
+ * the read runs under comes from the file's address, not from the slot's
8
+ * session: the address is the read's whole authority.
9
+ *
10
+ * A tab's pages are one file version walked from the first line. Dropping them
11
+ * — a reload, or a page of a newer version arriving past the first line, which
12
+ * restarts the walk — retires every read still in flight for the tab: a
13
+ * settlement from before the drop writes nothing. Cleanup rides the owner's
14
+ * `signal`, armed once per tab by its first read: the abort forgets the tab's
15
+ * bucket and this bookkeeping, a request is not made for a record that already
16
+ * ended, and a settlement arriving after the record is gone has nothing left to
17
+ * write to. A tab that never read has no bucket to forget.
18
+ */
19
+ import type { BoundActions } from '@qilin-agent/client-store';
20
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
21
+ import type { SessionId } from '@qilin-agent/session/types';
22
+ import type { ReadDocumentBytes, ReadWorkspaceFilePage, SessionFile } from './rpc.ts';
23
+ import type { TextStore } from './store.ts';
24
+ import type { Resources } from '@qilin-agent/client-resources/client';
25
+ /** The preview's injected business face, as the body receives it. */
26
+ export interface TextInjected {
27
+ /** Observe one renderer dependency. @param tabId - owning tab. @param address - resource address. @param signal - tab lifetime. */
28
+ readonly addResource: (tabId: TabId, address: string, signal: AbortSignal) => void;
29
+ /** Replace dependency membership. @param tabId - owning tab. @param addresses - resource addresses. @param signal - tab lifetime. */
30
+ readonly setResources: (tabId: TabId, addresses: readonly string[], signal: AbortSignal) => void;
31
+ /**
32
+ * Read one page into the store. A page of a newer file version than the pages
33
+ * held, arriving past the first line, is not kept: the tab's pages are dropped
34
+ * and the first page read again. The tab's first read arms the abort listener
35
+ * that forgets its bucket when the record ends.
36
+ * @param tabId - the tab being drawn.
37
+ * @param file - the session and workspace path the tab's address names.
38
+ * @param offset - 1-based line the page starts at.
39
+ * @param signal - the tab record's lifetime.
40
+ * @param observedVersion - metadata version observed at read start.
41
+ */
42
+ readonly loadPage: (tabId: TabId, file: SessionFile, offset: number, signal: AbortSignal, observedVersion?: string) => void;
43
+ /**
44
+ * Drop every page and read the first one again, for a file the Host reports
45
+ * changed. The view is kept, so the reader stays where they were; a page read
46
+ * still in flight writes nothing when it settles.
47
+ * @param tabId - the tab being drawn.
48
+ * @param file - the session and workspace path the tab's address names.
49
+ * @param signal - the tab record's lifetime.
50
+ * @param observedVersion - metadata version observed at read start.
51
+ */
52
+ readonly reloadPages: (tabId: TabId, file: SessionFile, signal: AbortSignal, observedVersion?: string) => void;
53
+ /**
54
+ * Read the complete file for a whole-file renderer.
55
+ * @param tabId - owning tab.
56
+ * @param file - the session and workspace path the tab's address names.
57
+ * @param signal - tab lifetime.
58
+ * @param observedVersion - metadata version observed at read start.
59
+ */
60
+ readonly loadAll: (tabId: TabId, file: SessionFile, signal: AbortSignal, observedVersion?: string) => void;
61
+ /**
62
+ * Discard the old complete result and read again.
63
+ * @param tabId - owning tab.
64
+ * @param file - the session and workspace path the tab's address names.
65
+ * @param signal - tab lifetime.
66
+ * @param observedVersion - metadata version observed at read start.
67
+ */
68
+ readonly reloadAll: (tabId: TabId, file: SessionFile, signal: AbortSignal, observedVersion?: string) => void;
69
+ /**
70
+ * Begin a renderer-owned load without reading source bytes.
71
+ * @param tabId - owning tab.
72
+ * @param signal - tab lifetime.
73
+ * @param rendererId - selected implementation.
74
+ * @param observedVersion - metadata version observed at request start.
75
+ * @param reload - discard the previous content revision.
76
+ */
77
+ readonly prepareRenderer: (tabId: TabId, signal: AbortSignal, rendererId: string, observedVersion?: string, reload?: boolean) => void;
78
+ }
79
+ /**
80
+ * Bind the preview's face to one paged read and one complete-byte read.
81
+ * @param read - the bound `workspaceFiles.read` call.
82
+ * @param readAll - ordinary complete-byte Remote read.
83
+ * @param resources - shared metadata sources for the document and its dependencies.
84
+ * @returns the Slot `inject` factory: bound actions in, face out. The slot's session id is unused because the address carries its own.
85
+ */
86
+ export declare function textFace(read: ReadWorkspaceFilePage, readAll: ReadDocumentBytes, resources: Resources): (sessionId: SessionId, actions: BoundActions<TextStore>) => TextInjected;
87
+ //# sourceMappingURL=face.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The failure line one Remote code deserves.
3
+ *
4
+ * Kept apart from the component so the mapping is testable on its own. Codes
5
+ * this reader does not name fall to the generic line carrying the carrier's
6
+ * message.
7
+ */
8
+ import type { RemoteFailure } from '@qilin-agent/api-remotes/client';
9
+ import type { TranslateNS } from '@qilin-agent/client-locale/client';
10
+ /**
11
+ * Say what went wrong, in terms of the file rather than of the transport.
12
+ * @param t - namespace-bound translate.
13
+ * @param failure - the settled Remote failure.
14
+ * @returns the line to show in place of the file.
15
+ */
16
+ export declare function failureLine(t: TranslateNS<'sidebarDocumentPreview'>, failure: RemoteFailure): string;
17
+ //# sourceMappingURL=failure-line.d.ts.map
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { InjectFace, PropsLocale } from '@qilin-agent/client-ui-slots';
3
+ import type { ObservableSnapshot } from '@qilin-agent/client-store';
4
+ import type { DocumentPreviewProps } from '../document/contract.ts';
5
+ import type { ReadHtmlRelated } from './read-relative.ts';
6
+ /** Standard document inputs plus this renderer's dictionary. */
7
+ export type HtmlBodyProps = DocumentPreviewProps & PropsLocale<'documentHtml'> & InjectFace<HtmlBodyInjected>;
8
+ /** Related-file reader and accepted preview mode supplied by the plugin. */
9
+ export interface HtmlBodyInjected {
10
+ hooks: {
11
+ interactivePreview: ObservableSnapshot<boolean>;
12
+ };
13
+ /** Ordinary Remote callback bound by this renderer's Slot inject. */
14
+ readonly readRelated: ReadHtmlRelated;
15
+ }
16
+ /**
17
+ * Render complete HTML with the standard file and tab hooks.
18
+ * @param props - document bytes, hooks, related-file reader and locale.
19
+ * @returns an isolated HTML document, or nothing for text delivery.
20
+ */
21
+ export declare function HtmlBody({ content, resourceAddress, readRelated, useTabInfo, useInteractivePreview, addResource, setResources, t, }: HtmlBodyProps): ReactNode;
22
+ //# sourceMappingURL=HtmlBody.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Prepare static content before the browser can load any document resources.
3
+ * @param data - complete UTF-8 HTML bytes.
4
+ * @returns document with the restrictive CSP first in its head.
5
+ */
6
+ export declare function createBasicHtmlDocument(data: Uint8Array<ArrayBuffer>): string;
7
+ //# sourceMappingURL=basic-document.d.ts.map
@@ -0,0 +1,20 @@
1
+ /** One statically declared local script or stylesheet, already read under the source file's authority. */
2
+ export interface HtmlAsset {
3
+ readonly kind: 'script' | 'stylesheet';
4
+ /** Original HTML attribute, not a Host absolute path. */
5
+ readonly reference: string;
6
+ readonly data: Uint8Array<ArrayBuffer>;
7
+ }
8
+ /** Complete bytes for one document; dependencies are finite and never requested by iframe messages. */
9
+ export interface HtmlBundle {
10
+ readonly data: Uint8Array<ArrayBuffer>;
11
+ readonly assets: readonly HtmlAsset[];
12
+ }
13
+ /**
14
+ * Build the outer iframe document. Its resource URLs are created inside the sandbox,
15
+ * because that opaque origin cannot load resource URLs created by the parent.
16
+ * @param bundle - complete HTML bytes and optional static dependencies.
17
+ * @returns bootstrap HTML; invalid UTF-8 throws before navigation.
18
+ */
19
+ export declare function createHtmlDocument(bundle: HtmlBundle): string;
20
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1,14 @@
1
+ /** UTF-8 decoding for file bytes and encoding only for the iframe's script payload. */
2
+ /**
3
+ * Decode complete UTF-8 text, rejecting invalid byte sequences.
4
+ * @param data - complete UTF-8 bytes.
5
+ * @returns decoded text; invalid UTF-8 throws.
6
+ */
7
+ export declare function decodeText(data: Uint8Array<ArrayBuffer>): string;
8
+ /**
9
+ * Encode Unicode text for the iframe's base64 payload.
10
+ * @param text - Unicode text.
11
+ * @returns base64 of its UTF-8 bytes.
12
+ */
13
+ export declare function encodeText(text: string): string;
14
+ //# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1,17 @@
1
+ /** Builtin HTML metadata and keyed body registration; assembly belongs to the package entry. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { DocumentPreviewDefinition } from '../document/registry.ts';
4
+ /** HTML implementation identity, shared by metadata and the keyed slot. */
5
+ export declare const HTML_BODY_ID = "@qilin-agent/client-ui-sidebar-documentpreview/html";
6
+ /**
7
+ * Describe the builtin HTML renderer's file types and loading mode.
8
+ * @param title - locale-owned implementation name.
9
+ * @returns metadata for complete HTML documents.
10
+ */
11
+ export declare function htmlBodyDefinition(title: () => string): DocumentPreviewDefinition;
12
+ /**
13
+ * Register the HTML dictionary, metadata and body with reversible effects.
14
+ * @param ctx - owning plugin context.
15
+ */
16
+ export declare function apply(ctx: Context): void;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,23 @@
1
+ /** Locale-owned HTML implementation name and iframe status text. */
2
+ export declare const zh: {
3
+ title: string;
4
+ frame: string;
5
+ loading: string;
6
+ failed: string;
7
+ };
8
+ /** HTML renderer dictionary keys. */
9
+ export type HtmlPreviewKey = keyof typeof zh;
10
+ /** English dictionary with the same keys as the Chinese dictionary. */
11
+ export declare const en: {
12
+ title: string;
13
+ frame: string;
14
+ loading: string;
15
+ failed: string;
16
+ };
17
+ declare module '@qilin-agent/client-ui-slots' {
18
+ interface LocaleNamespaceMap {
19
+ /** HTML preview selection and status text. */
20
+ documentHtml: HtmlPreviewKey;
21
+ }
22
+ }
23
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,21 @@
1
+ /** Finite HTML-declared classic scripts and stylesheets; no module, CSS dependency or runtime fetch traversal. */
2
+ import type { HtmlBundle } from './bootstrap.ts';
3
+ import type { DocumentFileBytes } from '../rpc.ts';
4
+ /**
5
+ * A read bound to the original document's session and directory, using ordinary file operations.
6
+ * @param reference - HTML-decoded relative URL, including any query or fragment; the reader resolves its file path.
7
+ * @param signal - cancellation of this packing operation.
8
+ * @returns complete file bytes; permission and read failures reject.
9
+ */
10
+ export type ReadHtmlRelative = (reference: string, signal: AbortSignal) => Promise<DocumentFileBytes>;
11
+ /**
12
+ * Collect static dependencies without executing or mounting document elements in the parent page.
13
+ * A base element leaves URL resolution to the browser. Only direct .js classic scripts and .css
14
+ * links are packed; local CSS url/import, modules and dynamically constructed URLs are unsupported.
15
+ * @param data - complete UTF-8 HTML bytes.
16
+ * @param readRelative - original-document-scoped read, never exposed to the iframe.
17
+ * @param signal - stops reads and prevents publication after cancellation.
18
+ * @returns complete HTML and its finite static asset set; decoding, limits and read failures reject.
19
+ */
20
+ export declare function packHtml(data: Uint8Array<ArrayBuffer>, readRelative: ReadHtmlRelative, signal: AbortSignal): Promise<HtmlBundle>;
21
+ //# sourceMappingURL=pack.d.ts.map
@@ -0,0 +1,22 @@
1
+ /** Adapt a Remote relative read without changing its Session or Host path authority. */
2
+ import type { RemoteResult } from '@qilin-agent/api-remotes/client';
3
+ import type { WorkspaceFileBytes } from '@qilin-agent/api-workspace-files/types';
4
+ import type { ReadHtmlRelative } from './pack.ts';
5
+ /**
6
+ * Read one dependency relative to the addressed HTML file through the Host.
7
+ * @param address - root HTML file address.
8
+ * @param relativePath - decoded dependency path, resolved only by the Host.
9
+ * @param signal - cancellation shared by the tab and packing operation.
10
+ * @returns the Remote complete-byte result, including declared failures.
11
+ */
12
+ export type ReadHtmlRelated = (address: string, relativePath: string, signal: AbortSignal) => Promise<RemoteResult<WorkspaceFileBytes>>;
13
+ /**
14
+ * Bind a package reader to the original HTML file's address.
15
+ * @param readRelated - Remote reader using the Session in the root HTML address.
16
+ * @param address - root HTML file address.
17
+ * @param lifetime - tab lifetime.
18
+ * @param addResource - subscribes to the dependency path reported by the Host.
19
+ * @returns a reader that strips URL query/fragment, decodes one path, and preserves Host failures.
20
+ */
21
+ export declare function createReadHtmlRelative(readRelated: ReadHtmlRelated, address: string, lifetime: AbortSignal, addResource: (address: string) => void): ReadHtmlRelative;
22
+ //# sourceMappingURL=read-relative.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Glyphs this package draws that the shared icon set does not carry yet.
3
+ * Same props contract as `@qilin-agent/client-ui-primitives` icons, so a
4
+ * shared replacement is a one-line import change.
5
+ *
6
+ * The wrap control swaps between the two glyphs below to preview the mode a
7
+ * click switches to, so neither needs a pressed style.
8
+ */
9
+ import type { IconProps } from '@qilin-agent/client-ui-primitives';
10
+ /** Two margin bars, a straight arrow running to the right one: lines run past the edge. */
11
+ export declare const IconNowrapFill16: ({ size, className }: IconProps) => import("react").JSX.Element;
12
+ /** Two margin bars, an arrow sweeping around and back left: lines turn under themselves. */
13
+ export declare const IconWrapFill16: ({ size, className }: IconProps) => import("react").JSX.Element;
14
+ //# sourceMappingURL=icons.d.ts.map
@@ -0,0 +1,32 @@
1
+ /** Complete image bytes rendered in a shared zoom viewport. */
2
+ import { type ReactNode } from 'react';
3
+ import type { PropsLocale, PropsStore } from '@qilin-agent/client-ui-slots';
4
+ import type { DocumentPreviewProps } from '../document/contract.ts';
5
+ import { type ZoomInjected, type ZoomStore } from '../zoom/store.ts';
6
+ declare const IMAGE_MEDIA_TYPES: {
7
+ readonly png: "image/png";
8
+ readonly jpg: "image/jpeg";
9
+ readonly jpeg: "image/jpeg";
10
+ readonly gif: "image/gif";
11
+ readonly webp: "image/webp";
12
+ readonly bmp: "image/bmp";
13
+ readonly ico: "image/x-icon";
14
+ readonly svg: "image/svg+xml";
15
+ };
16
+ type ImageMediaType = typeof IMAGE_MEDIA_TYPES[keyof typeof IMAGE_MEDIA_TYPES];
17
+ /** Standard document props plus the image renderer's dictionary. */
18
+ export type ImageBodyProps = DocumentPreviewProps & PropsLocale<'sidebarImage'> & PropsStore<ZoomStore> & ZoomInjected;
19
+ /**
20
+ * Resolve a supported filename to the media type assigned to its Blob.
21
+ * @param path - decoded workspace file path.
22
+ * @returns the image media type, or undefined for an unregistered suffix.
23
+ */
24
+ export declare function imageMediaType(path: string): ImageMediaType | undefined;
25
+ /**
26
+ * Present complete image bytes with fit-width and fixed-scale viewing.
27
+ * @param props - document bytes, resource identity, and locale.
28
+ * @returns a rounded image fitted or scaled at its intrinsic aspect ratio.
29
+ */
30
+ export declare function ImageBody(props: ImageBodyProps): ReactNode;
31
+ export {};
32
+ //# sourceMappingURL=ImageBody.d.ts.map
@@ -0,0 +1,21 @@
1
+ /** Builtin image metadata and keyed document-body registration. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { DocumentPreviewDefinition } from '../document/registry.ts';
4
+ /** Image implementation identity, shared by metadata and the keyed slot. */
5
+ export declare const IMAGE_BODY_ID = "@qilin-agent/client-ui-sidebar-documentpreview/image";
6
+ /** File suffixes rendered by the builtin image body. */
7
+ export declare const IMAGE_EXTENSIONS: readonly ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg"];
8
+ /** Bitmap suffixes whose bytes are unreadable as text; SVG stays out because its XML source is worth reading. */
9
+ export declare const BINARY_IMAGE_EXTENSIONS: readonly ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico"];
10
+ /**
11
+ * Describe the builtin image renderer independently from its keyed body slot.
12
+ * @param title - locale-owned implementation name.
13
+ * @returns metadata for complete image files.
14
+ */
15
+ export declare function imageBodyDefinition(title: () => string): DocumentPreviewDefinition;
16
+ /**
17
+ * Register the image dictionary, metadata, and body with reversible effects.
18
+ * @param ctx - owning plugin context.
19
+ */
20
+ export declare function apply(ctx: Context): void;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,37 @@
1
+ /** Locale-owned image renderer labels and status text. */
2
+ export declare const zh: {
3
+ title: string;
4
+ preview: string;
5
+ loading: string;
6
+ failed: string;
7
+ unsupported: string;
8
+ zoomControls: "缩放控件";
9
+ zoomMenu: "选择缩放比例";
10
+ zoomOut: "缩小";
11
+ zoomIn: "放大";
12
+ zoomFitWidth: "适应宽度";
13
+ zoomValue: "{percent}%";
14
+ };
15
+ /** Image renderer dictionary keys. */
16
+ export type ImagePreviewKey = keyof typeof zh;
17
+ /** English dictionary with the same keys as the Chinese dictionary. */
18
+ export declare const en: {
19
+ title: string;
20
+ preview: string;
21
+ loading: string;
22
+ failed: string;
23
+ unsupported: string;
24
+ zoomControls: string;
25
+ zoomMenu: string;
26
+ zoomOut: string;
27
+ zoomIn: string;
28
+ zoomFitWidth: string;
29
+ zoomValue: string;
30
+ };
31
+ declare module '@qilin-agent/client-ui-slots' {
32
+ interface LocaleNamespaceMap {
33
+ /** Image preview selection, accessible name, and status text. */
34
+ sidebarImage: ImagePreviewKey;
35
+ }
36
+ }
37
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Browser half: register `text` as a right-Sidebar tab type.
3
+ *
4
+ * The type reaches the Sidebar through its public path only: the definition into
5
+ * `ctx.sidebarRightTabs`, the body into the keyed `sidebar.right.pane.tab`
6
+ * seat, and the chip title into `sidebar.right.pane.tab.title`, both under the
7
+ * definition's `id`. Nothing here reaches into the Sidebar's store, its
8
+ * panes, or its sequence. The file's metadata comes from the standard
9
+ * `useResource`, served by the `file` provider; the content is this type's own
10
+ * business, read through its face. Every import from another
11
+ * client plugin is a type.
12
+ */
13
+ import type { Context as ClientContext } from '@qilin-agent/kylin';
14
+ import type { WorkspaceFileParams } from '@qilin-agent/api-workspace-files/client';
15
+ import { DocumentPreviewRegistry } from './document/registry.ts';
16
+ export type { SidebarDocumentPreviewKey } from './locales.ts';
17
+ export type { TextPreviewProps } from './TextPreview.tsx';
18
+ export type { TextInjected } from './face.ts';
19
+ export type { ReadDocumentBytes, DocumentFileBytes, ReadWorkspaceFilePage, SessionFile, WorkspaceFilesReadRemote } from './rpc.ts';
20
+ export type { TextPage, TextState, TextStore, TextTabState } from './store.ts';
21
+ export type { DocumentContent, DocumentPreviewProps, DocumentTextPage } from './document/contract.ts';
22
+ export type { DocumentLoadMode, DocumentPreviewDefinition } from './document/registry.ts';
23
+ declare module '@qilin-agent/kylin' {
24
+ interface Context {
25
+ /** File-extension renderer registrations, independent from their keyed document bodies. */
26
+ documentPreviews: DocumentPreviewRegistry;
27
+ }
28
+ }
29
+ declare module '@qilin-agent/client-ui-sidebar-right/client' {
30
+ interface SidebarRightResourceParamsMap {
31
+ /** File line navigation supported by the text preview. */
32
+ file: WorkspaceFileParams;
33
+ }
34
+ }
35
+ declare module '@qilin-agent/client-ui-slots' {
36
+ interface LocaleNamespaceMap {
37
+ /** Text-preview progress, paging, change, control, and failure lines. */
38
+ sidebarDocumentPreview: import('./locales.ts').SidebarDocumentPreviewKey;
39
+ }
40
+ }
41
+ /**
42
+ * Required browser services: the tab registry, the slot registry, copy, the
43
+ * shared resource model, the developer-tools preference that selects the HTML
44
+ * preview policy, the conversation assembly a viewer selection lands in, and
45
+ * the Remote carrier with its `workspaceFiles` namespace.
46
+ */
47
+ export declare const inject: string[];
48
+ /**
49
+ * Client plugin body: register the type, its dictionaries, its body, and its chip title.
50
+ * @param ctx - client root context carrying the registry, the slots, copy, and the Remote face.
51
+ */
52
+ export declare function apply(ctx: ClientContext): void;
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,66 @@
1
+ /**
2
+ * `sidebarDocumentPreview` namespace dictionaries.
3
+ *
4
+ * The failure lines are the point of this file: a preview that cannot show a
5
+ * page has to say which of several different things went wrong, and each one
6
+ * suggests a different next step for the reader.
7
+ */
8
+ /** Simplified Chinese dictionary and key-set source of truth. */
9
+ export declare const zh: {
10
+ loading: string;
11
+ loadMore: string;
12
+ changed: string;
13
+ reloadNow: string;
14
+ reload: string;
15
+ autoRefresh: string;
16
+ 'autoRefresh.enable': string;
17
+ 'autoRefresh.disable': string;
18
+ 'wrap.enable': string;
19
+ 'wrap.disable': string;
20
+ 'wrap.aria': string;
21
+ openWith: string;
22
+ edit: string;
23
+ 'type.label': string;
24
+ 'viewer.text': string;
25
+ resourceUnavailable: string;
26
+ rendererUnavailable: string;
27
+ unsupportedFile: string;
28
+ 'error.notFound': string;
29
+ 'error.tooLarge': string;
30
+ 'error.notText': string;
31
+ 'error.notRegularFile': string;
32
+ 'error.unavailable': string;
33
+ retry: string;
34
+ addToConversation: string;
35
+ };
36
+ /** Text-preview dictionary key union. */
37
+ export type SidebarDocumentPreviewKey = keyof typeof zh;
38
+ /** English dictionary, checked against the Chinese key set. */
39
+ export declare const en: {
40
+ loading: string;
41
+ loadMore: string;
42
+ changed: string;
43
+ reloadNow: string;
44
+ reload: string;
45
+ autoRefresh: string;
46
+ 'autoRefresh.enable': string;
47
+ 'autoRefresh.disable': string;
48
+ 'wrap.enable': string;
49
+ 'wrap.disable': string;
50
+ 'wrap.aria': string;
51
+ openWith: string;
52
+ edit: string;
53
+ 'type.label': string;
54
+ 'viewer.text': string;
55
+ resourceUnavailable: string;
56
+ rendererUnavailable: string;
57
+ unsupportedFile: string;
58
+ 'error.notFound': string;
59
+ 'error.tooLarge': string;
60
+ 'error.notText': string;
61
+ 'error.notRegularFile': string;
62
+ 'error.unavailable': string;
63
+ retry: string;
64
+ addToConversation: string;
65
+ };
66
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { PropsLocale } from '@qilin-agent/client-ui-slots';
3
+ import type { DocumentPreviewProps } from '../document/contract.ts';
4
+ /** Standard document inputs and this implementation's locale. */
5
+ export type MarkdownBodyProps = DocumentPreviewProps & PropsLocale<'documentMarkdown'>;
6
+ /**
7
+ * Render one accumulated document; EOF completes the primitive's full parse.
8
+ * @param props - owner-loaded contents and localized primitive labels.
9
+ * @returns Markdown content, or nothing for a non-text delivery.
10
+ */
11
+ export declare function MarkdownBody({ content, resourceAddress, useResource, t }: MarkdownBodyProps): ReactNode;
12
+ //# sourceMappingURL=MarkdownBody.d.ts.map
@@ -0,0 +1,17 @@
1
+ /** Builtin Markdown metadata and keyed document-body registration. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { DocumentPreviewDefinition } from '../document/registry.ts';
4
+ /** Implementation identity shared by metadata and the document slot. */
5
+ export declare const MARKDOWN_BODY_ID = "@qilin-agent/client-ui-sidebar-documentpreview/markdown";
6
+ /**
7
+ * Describe the Markdown implementation without taking ownership of loading.
8
+ * @param title - locale-owned implementation name.
9
+ * @returns builtin Markdown registration metadata.
10
+ */
11
+ export declare function markdownDefinition(title: () => string): DocumentPreviewDefinition;
12
+ /**
13
+ * Register locale, metadata, and the document body for the owning plugin lifetime.
14
+ * @param ctx - plugin context carrying locale, document registry, and slots.
15
+ */
16
+ export declare function apply(ctx: Context): void;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,27 @@
1
+ /** Markdown implementation labels and primitive chrome. */
2
+ export declare const zh: {
3
+ 'viewer.label': string;
4
+ 'code.copy': string;
5
+ 'code.copied': string;
6
+ footnotes: string;
7
+ 'mermaid.diagram': string;
8
+ 'mermaid.enlarged': string;
9
+ };
10
+ /** Markdown namespace keys. */
11
+ export type MarkdownPreviewKey = keyof typeof zh;
12
+ /** English labels, paired with the Chinese key set. */
13
+ export declare const en: {
14
+ 'viewer.label': string;
15
+ 'code.copy': string;
16
+ 'code.copied': string;
17
+ footnotes: string;
18
+ 'mermaid.diagram': string;
19
+ 'mermaid.enlarged': string;
20
+ };
21
+ declare module '@qilin-agent/client-ui-slots' {
22
+ interface LocaleNamespaceMap {
23
+ /** Markdown document renderer and its code/footnote controls. */
24
+ documentMarkdown: MarkdownPreviewKey;
25
+ }
26
+ }
27
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Build a file URL, resolving relative destinations beside the previewed file.
3
+ * @param base - document base URI, including any deployment prefix.
4
+ * @param documentPath - absolute source path reported by the Host, when available.
5
+ * @param destination - authored Markdown image URL; query and fragment are not filename components.
6
+ * @returns a file URL, or undefined for unsupported or malformed destinations.
7
+ */
8
+ export declare function markdownImageUrl(base: string, documentPath: string | undefined, destination: string): string | undefined;
9
+ //# sourceMappingURL=path-images.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Decide whether an HTML run opens with a block-level element.
3
+ *
4
+ * The markdown parse already places the run where it belongs; this only picks
5
+ * the wrapper, so a run that starts with a comment, a closing tag, or anything
6
+ * unrecognized stays phrasing-level.
7
+ * @param source - the authored HTML run.
8
+ * @returns whether the run opens with a block-level element.
9
+ */
10
+ export declare function opensWithBlockTag(source: string): boolean;
11
+ /**
12
+ * Decide whether a run may be rendered as sanitized HTML.
13
+ *
14
+ * Only a complete block qualifies. The parse hands one run per tag in phrasing
15
+ * context, so an inline `<sub>` arrives without the `</sub>` that closes it in
16
+ * the source — rendering it would drop the markup and keep the text, which is
17
+ * a silent change from showing the tag. A block opening without any closing tag
18
+ * (`<div class="note">` … Markdown … `</div>` across runs) would render as an
19
+ * empty element around nothing. Both stay literal; both are recorded in the
20
+ * package README.
21
+ * @param source - the authored HTML run.
22
+ * @returns whether the run is a complete block-level element.
23
+ */
24
+ export declare function renderableMarkdownHtml(source: string): boolean;
25
+ /**
26
+ * Sanitize one authored HTML run.
27
+ * @param source - the raw HTML the markdown stream carried.
28
+ * Only a run {@link renderableMarkdownHtml} accepts reaches this, so the
29
+ * markup is always rendered in a block wrapper.
30
+ * @param resolveMedia - rewrites one `src` destination, returning undefined when the destination is refused.
31
+ * @returns the sanitized markup; empty when nothing survived.
32
+ */
33
+ export declare function sanitizeMarkdownHtml(source: string, resolveMedia: (destination: string) => string | undefined): string;
34
+ //# sourceMappingURL=sanitize-html.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * URLs for the host preview-media route (`@qilin-agent/host-preview-media`): one
3
+ * session file over `/sidebar/media`, Range-streamable for the video viewer
4
+ * and switchable to a download disposition.
5
+ */
6
+ /** Absolute-path URL of the media route for one session file.
7
+ * @param sessionId - Session whose workspace root resolves the path.
8
+ * @param path - absolute path or workspace-relative path.
9
+ * @param options - `download` switches the disposition to an attachment.
10
+ * @returns the relative `/sidebar/media` URL carrying the session and path.
11
+ */
12
+ export declare function previewMediaUrl(sessionId: string, path: string, options?: {
13
+ readonly download?: boolean;
14
+ }): string;
15
+ //# sourceMappingURL=media-url.d.ts.map