@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
package/lib/index.js ADDED
@@ -0,0 +1,35 @@
1
+ import z from "@qilin-agent/schemastery";
2
+ //#region lib/types/config.js
3
+ /** Cache limits shared by the Host configuration and browser document previews. */
4
+ /** Deployment limits applied before Office preview registration. */
5
+ const Config = z.object({
6
+ office: z.object({
7
+ maxCachedEntries: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(8),
8
+ maxCachedBytes: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(64 * 1024 * 1024),
9
+ maxPending: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(8),
10
+ maxReaders: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(32)
11
+ }),
12
+ excel: z.object({
13
+ maxBytes: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(16 * 1024 * 1024),
14
+ maxCells: z.natural().min(1).max(Number.MAX_SAFE_INTEGER).default(25e4),
15
+ timeoutMs: z.natural().min(1).max(2147483647).default(15e3)
16
+ })
17
+ });
18
+ //#endregion
19
+ //#region lib/types/index.js
20
+ /**
21
+ * Embed validated preview settings in browser pages.
22
+ * @param ctx - Host context serving browser pages.
23
+ * @param config - Cache limits adopted when the page loads.
24
+ */
25
+ function apply(ctx, config) {
26
+ ctx.on("webserver/index-inject", (table) => {
27
+ table.push({
28
+ kind: "global",
29
+ name: "__QILIN_DOCUMENT_PREVIEW_CONFIG__",
30
+ value: config
31
+ });
32
+ });
33
+ }
34
+ //#endregion
35
+ export { Config, apply };
@@ -0,0 +1,12 @@
1
+ /** Shared indeterminate loading feedback for document reads and rendering. */
2
+ import type { ReactNode } from 'react';
3
+ /**
4
+ * @param props - localized status label, carried as the accessible name with
5
+ * no visible text, and optional placement style.
6
+ * @returns an animated, accessible loading status.
7
+ */
8
+ export declare function LoadingIndicator({ label, className }: {
9
+ label: string;
10
+ className?: string | undefined;
11
+ }): ReactNode;
12
+ //# sourceMappingURL=LoadingIndicator.d.ts.map
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ObservableSnapshot } from '@qilin-agent/client-store';
3
+ import type { InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore } from '@qilin-agent/client-ui-slots';
4
+ import type { TextInjected } from './face.ts';
5
+ import type { TextStore } from './store.ts';
6
+ import type { DocumentPreviewDefinition } from './document/registry.ts';
7
+ export { linesOf, loadedPages, lastLineLoaded, scrollToLine } from './text/lines.ts';
8
+ export type { LoadedPage } from './text/lines.ts';
9
+ /** Private registration inputs; the framework binds the registry source to useDocumentPreviews. */
10
+ export interface TextPreviewInjected extends TextInjected {
11
+ readonly hooks: {
12
+ readonly documentPreviews: ObservableSnapshot<readonly DocumentPreviewDefinition[]>;
13
+ };
14
+ /**
15
+ * Append one viewer selection to this tab's Session composer draft.
16
+ * @param text - the fenced selection block.
17
+ * @returns whether the Session's input applied it.
18
+ */
19
+ readonly insertSelection: (text: string) => boolean;
20
+ }
21
+ /** The body's composed props: the tab, its navigation, the shared store and face, and copy. */
22
+ export type TextPreviewProps = PropsRuntime<'sidebar.right.pane.tab'> & PropsRenderSlots<'sidebar.right.tab.document' | 'sidebar.right.tab.document.action' | 'sidebar.right.tab.document.actions' | 'sidebar.right.tab.document.unpreviewable'> & PropsStore<TextStore> & InjectFace<TextPreviewInjected> & PropsLocale<'sidebarDocumentPreview'>;
23
+ /**
24
+ * The text type's body, registered under `sidebar.right.pane.tab` as `text`.
25
+ * @param props - composed slot props.
26
+ * @returns the content read so far with its controls, or a progress line.
27
+ */
28
+ export declare function TextPreview({ useTabInfo, useResource, useStore, actions, loadPage, reloadPages, loadAll, reloadAll, prepareRenderer, useDocumentPreviews, renderSlot, t, addResource, setResources, insertSelection, }: TextPreviewProps): ReactNode;
29
+ //# sourceMappingURL=TextPreview.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The text type's chip title: the file type's coloured sheet before the name
3
+ * the registry captured at open time. Registered under
4
+ * `sidebar.right.pane.tab.title`; without it the chip would show the bare name.
5
+ */
6
+ import type { ReactNode } from 'react';
7
+ import type { PropsRuntime } from '@qilin-agent/client-ui-slots';
8
+ /**
9
+ * The title as the chip and a floating panel's header show it.
10
+ * @param props - the tab information hook.
11
+ * @returns the type's 16px sheet followed by the tab's title text.
12
+ */
13
+ export declare function TextTitle({ useTabInfo }: PropsRuntime<'sidebar.right.pane.tab.title'>): ReactNode;
14
+ //# sourceMappingURL=TextTitle.d.ts.map
@@ -0,0 +1,9 @@
1
+ /** Incrementally highlighted source; the document owner supplies the accumulated text and wrap preference. */
2
+ import type { ReactNode } from 'react';
3
+ import type { PropsLocale } from '@qilin-agent/client-ui-slots';
4
+ import type { DocumentPreviewProps } from '../document/contract.ts';
5
+ /** Document owner props and this renderer's localized controls. */
6
+ export type CodeBodyProps = DocumentPreviewProps & PropsLocale<'sidebarCodePreview'>;
7
+ /** @param props - accumulated document contents and framework props. @returns one stable CodeBlock, or no body for byte contents. */
8
+ export declare function CodeBody({ resourceAddress, content, wrap, scrollportRef, t }: CodeBodyProps): ReactNode;
9
+ //# sourceMappingURL=CodeBody.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Code preview metadata and body registered through the public document extension points. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ /** @param ctx - owning plugin context. Register localized metadata and the matching keyed document body. */
4
+ export declare function apply(ctx: Context): void;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,9 @@
1
+ /** Recognized suffixes shared by renderer selection and language hints. */
2
+ export declare const CODE_EXTENSIONS: readonly string[];
3
+ /**
4
+ * Select the shared highlighter's grammar for a filename.
5
+ * @param path - decoded source filename or path.
6
+ * @returns a supported grammar hint, or undefined for other suffixes.
7
+ */
8
+ export declare function languageForPath(path: string): string | undefined;
9
+ //# sourceMappingURL=languages.d.ts.map
@@ -0,0 +1,19 @@
1
+ declare module '@qilin-agent/client-ui-slots' {
2
+ interface LocaleNamespaceMap {
3
+ /** Code document implementation name and copy controls. */
4
+ sidebarCodePreview: keyof typeof zh;
5
+ }
6
+ }
7
+ /** Simplified Chinese dictionary and key source. */
8
+ export declare const zh: {
9
+ title: string;
10
+ copy: string;
11
+ copied: string;
12
+ };
13
+ /** English dictionary with the same keys. */
14
+ export declare const en: {
15
+ title: string;
16
+ copy: string;
17
+ copied: string;
18
+ };
19
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Stage one of this package's registration: what the `text` tab type IS.
3
+ *
4
+ * The type claims every `qilin-resource://file/session/<sessionId>/<path>`
5
+ * address at the `fallback` band: it
6
+ * is the plain viewer that any more specific type for the same address should
7
+ * beat, the position VS Code's text editor holds among its editors. `canOpen`
8
+ * refuses an address `parseFileAddress` rejects or that has no Session at claim time, where an
9
+ * unclaimed address is the documented wiring error.
10
+ */
11
+ import type { SidebarRightTabDefinition } from '@qilin-agent/client-ui-sidebar-right/client';
12
+ import type { TranslateNS } from '@qilin-agent/client-locale/client';
13
+ /** The tab kind this package owns. */
14
+ export declare const TEXTPREVIEW_KIND = "text";
15
+ /** This implementation's identity in the tab system: the key its body registers under. */
16
+ export declare const TEXTPREVIEW_ID = "@qilin-agent/client-ui-sidebar-documentpreview";
17
+ /**
18
+ * The tab title for one `file:` address: its decoded basename.
19
+ *
20
+ * The whole address stays the content identity, so two files with one name in
21
+ * different directories are two tabs; only the chip text is shortened. Decoding
22
+ * is per segment, matching how the address was built, so a name carrying `#`,
23
+ * `?`, or a space reads as itself.
24
+ * @param address - a `file:`-shaped address.
25
+ * @returns the decoded last path segment, or the address itself when it has none.
26
+ */
27
+ export declare function basenameOf(address: string): string;
28
+ /**
29
+ * The text type's registry definition.
30
+ *
31
+ * `title` names the open file, so the type cannot take its own name from it:
32
+ * the enable switch reads `label`.
33
+ * @param t - namespace-bound translate, read fresh on every label call.
34
+ * @returns the definition to register.
35
+ */
36
+ export declare function textDefinition(t: TranslateNS<'sidebarDocumentPreview'>): SidebarRightTabDefinition;
37
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1,111 @@
1
+ /** Document renderer slot: the owner supplies shared file state, renderers own their presentation. */
2
+ import type { PropsRuntime, SlotHookFactory } from '@qilin-agent/client-ui-slots';
3
+ import type { UseSidebarRightTabInfo } from '@qilin-agent/client-ui-sidebar-right/client';
4
+ import type { RefCallback } from 'react';
5
+ /** One loaded text window, retaining source line positions. */
6
+ export interface DocumentTextPage {
7
+ readonly offset: number;
8
+ readonly text: string;
9
+ readonly lines: number;
10
+ }
11
+ /**
12
+ * Ordinary file contents, or a request for the selected renderer to load its content.
13
+ * Byte arrays are transient UI input, never persisted layout or Session data.
14
+ */
15
+ export type DocumentContent = {
16
+ readonly kind: 'text';
17
+ readonly text: string;
18
+ readonly pages: readonly DocumentTextPage[];
19
+ readonly eof: boolean;
20
+ } | {
21
+ readonly kind: 'bytes';
22
+ readonly data: Uint8Array<ArrayBuffer>;
23
+ } | {
24
+ readonly kind: 'renderer';
25
+ /** Changes on reload or implementation replacement; retained contents belong to one revision. */
26
+ readonly revision: number;
27
+ /** Report the displayed source version; stale revisions cannot update the owner. @param version - loaded source version. */
28
+ readonly loaded: (version: string) => void;
29
+ /** End a failed load; a later file change can start another revision. */
30
+ readonly failed: () => void;
31
+ /** Cancel the current load and start a new revision. */
32
+ readonly reload: () => void;
33
+ };
34
+ /** Content and viewing inputs shared by document bodies and nested PDF presentation. */
35
+ export interface DocumentBodyOwner {
36
+ /** Observe a file read by this renderer. @param address - complete file resource address. */
37
+ readonly addResource: (address: string) => void;
38
+ /** Replace this renderer's dependencies. @param addresses - complete file resource addresses. */
39
+ readonly setResources: (addresses: readonly string[]) => void;
40
+ /** Original file address, also readable through the standard useResource hook. */
41
+ readonly resourceAddress: string;
42
+ /** Ordinary file content or a renderer-owned loading request; text accumulates until eof. */
43
+ readonly content: DocumentContent;
44
+ /** The document toolbar's current wrapping preference. */
45
+ readonly wrap: boolean;
46
+ /** Report a renderer-owned scrollport; passing `null` restores the shared body as the owner. */
47
+ readonly scrollportRef: RefCallback<HTMLElement>;
48
+ }
49
+ declare module '@qilin-agent/client-ui-slots' {
50
+ interface SlotMap {
51
+ /** Document body selected by a registered implementation id. */
52
+ 'sidebar.right.tab.document': {
53
+ kind: 'keyed';
54
+ scope: 'session';
55
+ owner: DocumentBodyOwner;
56
+ hookContext: UseSidebarRightTabInfo;
57
+ inject: {
58
+ hooks: {
59
+ tabInfo: SlotHookFactory<'sidebar.right.tab.document', UseSidebarRightTabInfo>;
60
+ };
61
+ };
62
+ };
63
+ /**
64
+ * Header toolbar contributions acting on the previewed file, rendered
65
+ * after the preview's own controls once the file's Host path is known.
66
+ */
67
+ 'sidebar.right.tab.document.actions': {
68
+ kind: 'list';
69
+ scope: 'session';
70
+ owner: DocumentFileOwner;
71
+ };
72
+ /**
73
+ * Empty-state contributions for a file this preview cannot render,
74
+ * rendered under the unsupported notice once the file's Host path is known.
75
+ */
76
+ 'sidebar.right.tab.document.unpreviewable': {
77
+ kind: 'list';
78
+ scope: 'session';
79
+ owner: DocumentFileOwner;
80
+ };
81
+ /** Renderer-specific controls before the document toolbar's reload button. */
82
+ 'sidebar.right.tab.document.action': {
83
+ kind: 'keyed';
84
+ scope: 'session';
85
+ owner: {
86
+ readonly content: DocumentContent;
87
+ };
88
+ hookContext: UseSidebarRightTabInfo;
89
+ inject: {
90
+ hooks: {
91
+ tabInfo: SlotHookFactory<'sidebar.right.tab.document', UseSidebarRightTabInfo>;
92
+ };
93
+ };
94
+ };
95
+ }
96
+ }
97
+ /** The previewed file's Host identity, supplied to file-acting contributions. */
98
+ export interface DocumentFileOwner {
99
+ /** Absolute path in the file's execution environment; native actions must verify a Host mapping. */
100
+ readonly absolutePath: string;
101
+ }
102
+ /** Standard input for every document body; entry-local stores and locale props can be intersected with it. */
103
+ export type DocumentPreviewProps = PropsRuntime<'sidebar.right.tab.document'>;
104
+ /**
105
+ * Forward the framework's tab reader to the selected document body.
106
+ * @param _standard - framework standard props.
107
+ * @param useTabInfo - enclosing tab's bound reader.
108
+ * @returns the same reader, without another subscription adapter.
109
+ */
110
+ export declare const documentTabInfoFactory: SlotHookFactory<'sidebar.right.tab.document', UseSidebarRightTabInfo>;
111
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1,70 @@
1
+ /** Shared text or byte reads, or content loading owned by the renderer. */
2
+ export type DocumentLoadMode = 'text-pages' | 'bytes-complete' | 'renderer';
3
+ /** One renderer implementation, independent of its component registration. */
4
+ export interface DocumentPreviewDefinition {
5
+ /** Unique implementation name, also used as the document slot key. */
6
+ readonly id: string;
7
+ /** File suffixes without a leading dot; compound suffixes such as tar.gz are accepted. */
8
+ readonly extensions: readonly string[];
9
+ /**
10
+ * Suffixes among `extensions` whose bytes are not readable text; a file
11
+ * matching one loses the plain-text fallback among its viewer choices.
12
+ * Every entry must appear in `extensions`; `register` rejects strays.
13
+ */
14
+ readonly binaryExtensions?: readonly string[];
15
+ /** External implementations win over product implementations; defaults to extension. */
16
+ readonly priority?: 'builtin' | 'extension';
17
+ /** Localized implementation label, evaluated when the toolbar renders. @returns the visible name. */
18
+ readonly title: () => string;
19
+ /** Content delivery mode supplied by the document owner. */
20
+ readonly loading: DocumentLoadMode;
21
+ /** Whether the implementation consumes the document's wrap preference. */
22
+ readonly wrap?: boolean;
23
+ }
24
+ /**
25
+ * Rank an observed definition snapshot without consulting mutable service state.
26
+ * @param definitions - registered implementations in registration order.
27
+ * @param path - decoded filename or file path.
28
+ * @returns matching implementations, external band first, then longest suffix.
29
+ */
30
+ export declare function matchingDocumentPreviews(definitions: readonly DocumentPreviewDefinition[], path: string): readonly DocumentPreviewDefinition[];
31
+ /**
32
+ * Whether any registered implementation declares the filename's suffix binary.
33
+ * @param definitions - registered implementations.
34
+ * @param path - decoded filename or file path.
35
+ * @returns true when a declared binary suffix matches the filename.
36
+ */
37
+ export declare function binaryDocumentPath(definitions: readonly DocumentPreviewDefinition[], path: string): boolean;
38
+ /** Observable registry of all live implementations, including lower-priority alternatives. */
39
+ export declare class DocumentPreviewRegistry {
40
+ private readonly registered;
41
+ private readonly listeners;
42
+ private snapshot;
43
+ /**
44
+ * Read the current registrations.
45
+ * @returns the same snapshot until a registration changes.
46
+ */
47
+ readonly getSnapshot: () => readonly DocumentPreviewDefinition[];
48
+ /**
49
+ * Observe registration changes.
50
+ * @param listener - registration-change observer.
51
+ * @returns its disposer.
52
+ */
53
+ readonly subscribe: (listener: () => void) => (() => void);
54
+ /**
55
+ * Register metadata separately from the matching keyed slot component.
56
+ * @param definition - unique implementation and recognized suffixes; every
57
+ * `binaryExtensions` entry must appear in `extensions`.
58
+ * @returns an idempotent disposer; duplicate live implementation names and
59
+ * binary suffixes outside `extensions` throw.
60
+ */
61
+ register(definition: DocumentPreviewDefinition): () => void;
62
+ /**
63
+ * List every matching implementation in automatic-selection order.
64
+ * @param path - decoded file path; matching never resolves filesystem access.
65
+ * @returns extension band first, then longest suffix, then registration order.
66
+ */
67
+ candidates(path: string): readonly DocumentPreviewDefinition[];
68
+ private publish;
69
+ }
70
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1,23 @@
1
+ /** File-resource membership and invalidation for one document preview. */
2
+ import type { Resources } from '@qilin-agent/client-resources/client';
3
+ /** Forwards member metadata changes to one document preview. */
4
+ export declare class ResourceGroup {
5
+ private readonly resources;
6
+ private readonly changed;
7
+ private readonly members;
8
+ /** @param resources - shared file sources. @param changed - marks the owning preview stale. */
9
+ constructor(resources: Resources, changed: () => void);
10
+ /**
11
+ * Subscribe once; initial metadata establishes the baseline for later changes.
12
+ * @param address - complete resource address.
13
+ */
14
+ add(address: string): void;
15
+ /**
16
+ * Release dependencies absent from the current document.
17
+ * @param addresses - complete membership of the latest document load.
18
+ */
19
+ set(addresses: readonly string[]): void;
20
+ /** Release every member when the preview tab ends. */
21
+ close(): void;
22
+ }
23
+ //# sourceMappingURL=resource-group.d.ts.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Filename suffix matching shared by the preview registry and the owner's
3
+ * unviewable list, so every consumer normalizes paths and suffixes alike.
4
+ */
5
+ /**
6
+ * Normalize one declared suffix for comparison.
7
+ * @param extension - declared file suffix, with or without a leading dot.
8
+ * @returns the suffix lowercased with any leading dot dropped.
9
+ */
10
+ export declare function normalizeSuffix(extension: string): string;
11
+ /**
12
+ * The filename a path's suffixes are matched against.
13
+ * @param path - decoded filename or file path; `\` is accepted as a separator.
14
+ * @returns the lowercased final path segment.
15
+ */
16
+ export declare function documentFileName(path: string): string;
17
+ /**
18
+ * The longest declared suffix ending the filename.
19
+ * @param name - lowercased filename from {@link documentFileName}.
20
+ * @param extensions - declared suffixes; compound suffixes such as `tar.gz` are accepted.
21
+ * @returns the matched suffix's normalized length, or 0 when none matches.
22
+ */
23
+ export declare function matchedSuffixLength(name: string, extensions: readonly string[]): number;
24
+ //# sourceMappingURL=suffix.d.ts.map
@@ -0,0 +1,10 @@
1
+ /** Document view state belongs to tab records, including while their bodies are hidden. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { TabId } from '@qilin-agent/client-ui-dockkit';
4
+ /**
5
+ * Release retained view state on tab closure or plugin disposal.
6
+ * @param ctx - owning preview plugin context.
7
+ * @returns a callback accepting the tab, its lifetime signal, and its store's forget action; repeated holds share one listener.
8
+ */
9
+ export declare function retainDocumentTabs(ctx: Context): (tabId: TabId, signal: AbortSignal, forget: (tabId: TabId) => void) => void;
10
+ //# sourceMappingURL=tab-lifetime.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Whether a filename's suffix is a known binary container that no renderer claims.
3
+ * @param path - decoded filename or file path.
4
+ * @returns true when the suffix belongs to the unviewable binary list.
5
+ */
6
+ export declare function unviewableBinaryPath(path: string): boolean;
7
+ //# sourceMappingURL=unviewable.d.ts.map
@@ -0,0 +1,22 @@
1
+ /** Load the spreadsheet renderer only when a supported workbook is opened. */
2
+ import { type ReactNode } from 'react';
3
+ import type { PropsLocale } from '@qilin-agent/client-ui-slots';
4
+ import type { DocumentPreviewProps } from '../document/contract.ts';
5
+ import { type ExcelFormat } from './format.ts';
6
+ import type { ExcelLimits } from './model.ts';
7
+ /** Document input plus parser limits and localized copy. */
8
+ export type ExcelBodyProps = DocumentPreviewProps & PropsLocale<'sidebarExcel'> & {
9
+ readonly limits: ExcelLimits;
10
+ };
11
+ /** Lazily loaded renderer input with the parser choice and main-bundle loading content. */
12
+ export type LoadedExcelBodyProps = ExcelBodyProps & {
13
+ readonly format: ExcelFormat;
14
+ readonly loading: ReactNode;
15
+ };
16
+ /**
17
+ * Load the browser spreadsheet renderer for every registered format.
18
+ * @param props - Complete file bytes and standard document seats.
19
+ * @returns Localized loading state or Excel preview.
20
+ */
21
+ export declare function LazyExcelBody(props: ExcelBodyProps): ReactNode;
22
+ //# sourceMappingURL=LazyExcelBody.d.ts.map
@@ -0,0 +1,12 @@
1
+ /** Format-specific parsing into one read-only FortuneSheet representation. */
2
+ import type { ExcelFormat } from './format.ts';
3
+ import type { ExcelLimits, ExcelPreview } from './model.ts';
4
+ /**
5
+ * Decode spreadsheet bytes without recalculating saved formulas.
6
+ * @param bytes - Borrowed complete file bytes.
7
+ * @param format - Format selected by the registered filename suffix.
8
+ * @param limits - File and matrix allocation limits.
9
+ * @returns Display sheets and missing formula-cache count.
10
+ */
11
+ export declare function convertExcel(bytes: Uint8Array<ArrayBuffer>, format: ExcelFormat, limits: ExcelLimits): Promise<ExcelPreview>;
12
+ //# sourceMappingURL=convert.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { type ExcelLimits, type ExcelPreview } from './model.ts';
2
+ /**
3
+ * Parse delimited UTF-8 or BOM-marked UTF-16 without type inference.
4
+ * @param bytes - Borrowed complete file bytes.
5
+ * @param format - Comma or tab-separated input.
6
+ * @param limits - Maximum worksheet area.
7
+ * @returns A single sheet with literal field values.
8
+ */
9
+ export declare function convertDelimited(bytes: Uint8Array<ArrayBuffer>, format: 'csv' | 'tsv', limits: ExcelLimits): ExcelPreview;
10
+ //# sourceMappingURL=delimited.d.ts.map
@@ -0,0 +1,7 @@
1
+ /** Locale-independent spreadsheet parser failure categories. */
2
+ export declare class ExcelPreviewError extends Error {
3
+ readonly code: 'invalid' | 'tooLarge' | 'timeout' | 'encoding';
4
+ /** @param code - User-actionable parser failure. */
5
+ constructor(code: 'invalid' | 'tooLarge' | 'timeout' | 'encoding', options?: ErrorOptions);
6
+ }
7
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1,11 @@
1
+ /** Read-only spreadsheet surface backed by browser-parsed workbook data. */
2
+ import { type ReactNode } from 'react';
3
+ import type { LoadedExcelBodyProps } from './LazyExcelBody.tsx';
4
+ /**
5
+ * Display stored spreadsheet values and formats without editing or recalculation.
6
+ * Keep the mounted workbook sized to its preview pane.
7
+ * @param props - Complete workbook bytes, limits, and locale.
8
+ * @returns An isolated spreadsheet surface with cancellable loading.
9
+ */
10
+ export declare function ExcelBody({ content, format, limits, t, loading }: LoadedExcelBodyProps): ReactNode;
11
+ //# sourceMappingURL=excel.d.ts.map
@@ -0,0 +1,9 @@
1
+ /** File formats admitted by the spreadsheet preview. */
2
+ export type ExcelFormat = 'xlsx' | 'xls' | 'csv' | 'tsv';
3
+ /**
4
+ * Resolve a registered filename to its parser.
5
+ * @param path - Decoded file path.
6
+ * @returns The supported suffix; rejects unsupported filenames.
7
+ */
8
+ export declare function excelFormat(path: string): ExcelFormat;
9
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1,10 @@
1
+ /** Excel previews use ordinary authorized file bytes without Office conversion. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { Config } from '../../config.ts';
4
+ /**
5
+ * Register the browser Excel viewer and its lifecycle-owned slot.
6
+ * @param ctx - Preview and locale registries.
7
+ * @param limits - Resolved parser limits.
8
+ */
9
+ export declare function apply(ctx: Context, limits: Config['excel']): void;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,45 @@
1
+ /** Locale-owned Excel preview controls and parser feedback. */
2
+ export declare const zh: {
3
+ title: string;
4
+ language: string;
5
+ loading: string;
6
+ invalid: string;
7
+ tooLarge: string;
8
+ timeout: string;
9
+ encoding: string;
10
+ formulaWarning: string;
11
+ unsupportedNotice: string;
12
+ charts: string;
13
+ images: string;
14
+ shapes: string;
15
+ conditionalFormatting: string;
16
+ featureSeparator: string;
17
+ retry: string;
18
+ };
19
+ /** Excel preview dictionary keys. */
20
+ export type ExcelPreviewKey = keyof typeof zh;
21
+ /** English Excel preview copy. */
22
+ export declare const en: {
23
+ title: string;
24
+ language: string;
25
+ loading: string;
26
+ invalid: string;
27
+ tooLarge: string;
28
+ timeout: string;
29
+ encoding: string;
30
+ formulaWarning: string;
31
+ unsupportedNotice: string;
32
+ charts: string;
33
+ images: string;
34
+ shapes: string;
35
+ conditionalFormatting: string;
36
+ featureSeparator: string;
37
+ retry: string;
38
+ };
39
+ declare module '@qilin-agent/client-ui-slots' {
40
+ interface LocaleNamespaceMap {
41
+ /** Excel preview status and third-party locale selection. */
42
+ sidebarExcel: ExcelPreviewKey;
43
+ }
44
+ }
45
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,35 @@
1
+ /** Shared display cells, resource limits, and parser failure categories. */
2
+ import { type Cell, type Sheet, type SheetConfig } from '@fortune-sheet/core';
3
+ /** Resource limits applied before allocating FortuneSheet's dense cell matrices. */
4
+ export interface ExcelLimits {
5
+ /** Maximum source file bytes. */
6
+ maxBytes: number;
7
+ /** Maximum combined rectangular cell area across worksheets. */
8
+ maxCells: number;
9
+ /** Maximum time allowed for one parser Worker. */
10
+ timeoutMs: number;
11
+ }
12
+ /** Content categories reported in stable order when XLSX preview omits them. */
13
+ export declare const EXCEL_UNSUPPORTED_FEATURES: readonly ["charts", "images", "shapes", "conditionalFormatting"];
14
+ /** A detected workbook feature that the spreadsheet preview does not display. */
15
+ export type ExcelUnsupportedFeature = typeof EXCEL_UNSUPPORTED_FEATURES[number];
16
+ /** Preview data, missing formula results, and detected content that is not displayed. */
17
+ export interface ExcelPreview {
18
+ sheets: Sheet[];
19
+ missingResults: number;
20
+ unsupportedFeatures: ExcelUnsupportedFeature[];
21
+ }
22
+ /**
23
+ * Retain an addressable A1 selection, including an A1 merge.
24
+ * @param config - Worksheet layout.
25
+ * @returns The initial selection used when activating a worksheet.
26
+ */
27
+ export declare function initialSelection(config: SheetConfig): NonNullable<Sheet['luckysheet_select_save']>;
28
+ /**
29
+ * Apply number formatting and default alignment without evaluating formulas.
30
+ * @param cell - Owned display cell to complete.
31
+ * @param numberFormat - Excel number format code.
32
+ * @returns The same cell with its display text and value type.
33
+ */
34
+ export declare function formatCell(cell: Cell, numberFormat: string): Cell;
35
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { ExcelFormat } from './format.ts';
2
+ import { type ExcelLimits, type ExcelPreview } from './model.ts';
3
+ /**
4
+ * Parse workbook bytes in a disposable Worker, copying the retained preview buffer.
5
+ * @param bytes - Borrowed complete file bytes.
6
+ * @param format - Format selected by the registered filename suffix.
7
+ * @param limits - File, matrix, and elapsed-time limits.
8
+ * @param signal - Document body's lifetime.
9
+ * @returns Parsed sheets; rejects with a locale key on parser failures.
10
+ */
11
+ export declare function parseExcel(bytes: Uint8Array<ArrayBuffer>, format: ExcelFormat, limits: ExcelLimits, signal: AbortSignal): Promise<ExcelPreview>;
12
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1,18 @@
1
+ /** Legacy BIFF workbooks mapped to saved values and basic spreadsheet layout. */
2
+ import { type WorkBook } from 'xlsx';
3
+ import { type ExcelLimits, type ExcelPreview } from './model.ts';
4
+ /**
5
+ * Decode a binary XLS workbook without accepting renamed text or HTML files.
6
+ * @param bytes - Borrowed complete workbook bytes.
7
+ * @param limits - Maximum combined worksheet area.
8
+ * @returns Saved values, formulas, and supported workbook layout.
9
+ */
10
+ export declare function convertXls(bytes: Uint8Array<ArrayBuffer>, limits: ExcelLimits): ExcelPreview;
11
+ /**
12
+ * Map SheetJS values and optional BIFF layout metadata without retaining the workbook.
13
+ * @param workbook - Parsed legacy workbook.
14
+ * @param limits - Maximum combined worksheet area.
15
+ * @returns FortuneSheet display data.
16
+ */
17
+ export declare function mapXlsWorkbook(workbook: WorkBook, limits: ExcelLimits): ExcelPreview;
18
+ //# sourceMappingURL=xls.d.ts.map