@sqsoffice/slide 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +81 -2
- package/dist/THIRD-PARTY-NOTICES.txt +19871 -0
- package/dist/api-CLyi4j4N.js +4030 -0
- package/dist/api.js +1 -0
- package/dist/assets/engine/files-worker.js +1 -0
- package/dist/assets/engine/host-artifact-jgAXg8CH.js +1 -0
- package/dist/assets/engine/host-load-wasm-DyYR5qIL.js +1 -0
- package/dist/assets/engine/host-manifest.json +42 -0
- package/dist/assets/engine/host-pdf-import-BOPMPpUS.js +1 -0
- package/dist/assets/engine/host.js +1 -0
- package/dist/assets/engine/manifest.json +66 -0
- package/dist/assets/engine/office_web.js +1491 -0
- package/dist/assets/engine/office_web_bg.wasm +4 -0
- package/dist/assets/engine/worker.js +1 -0
- package/dist/assets/fonts/source-han-sans/2.005/LICENSE.txt +96 -0
- package/dist/assets/fonts/source-han-sans/2.005/SourceHanSansCN-Bold.otf +0 -0
- package/dist/assets/fonts/source-han-sans/2.005/SourceHanSansCN-Regular.otf +0 -0
- package/dist/assets/fonts/source-han-sans/2.005/manifest.json +20 -0
- package/dist/index.js +835 -0
- package/dist/package-manifest.json +181 -0
- package/dist/style.css +2 -0
- package/dist/types/app/lib/automation/protocol.d.ts +25 -0
- package/dist/types/app/lib/engine/client.d.ts +129 -0
- package/dist/types/app/lib/engine/docx.d.ts +67 -0
- package/dist/types/app/lib/engine/grid.d.ts +330 -0
- package/dist/types/app/lib/engine/image.d.ts +15 -0
- package/dist/types/app/lib/engine/markdown.d.ts +220 -0
- package/dist/types/app/lib/engine/pdf-import.d.ts +18 -0
- package/dist/types/app/lib/engine/pdf-ocr.d.ts +70 -0
- package/dist/types/app/lib/engine/pdf-output.d.ts +22 -0
- package/dist/types/app/lib/engine/pdf.d.ts +191 -0
- package/dist/types/app/lib/engine/presentation-clipboard.d.ts +26 -0
- package/dist/types/app/lib/engine/presentation-media.d.ts +156 -0
- package/dist/types/app/lib/engine/presentation.d.ts +145 -0
- package/dist/types/app/lib/engine/printing.d.ts +91 -0
- package/dist/types/app/lib/engine/protocol.d.ts +233 -0
- package/dist/types/app/lib/engine/script.d.ts +46 -0
- package/dist/types/app/lib/engine/sheet-clipboard.d.ts +42 -0
- package/dist/types/app/lib/engine/sheet-validation.d.ts +19 -0
- package/dist/types/app/lib/engine/view.d.ts +186 -0
- package/dist/types/app/lib/files/session.d.ts +114 -0
- package/dist/types/app/lib/files/storage.d.ts +20 -0
- package/dist/types/packages/slide/api.d.ts +4 -0
- package/dist/types/packages/slide/index.d.ts +5 -0
- package/dist/types/sdk/types.d.ts +59 -0
- package/package.json +40 -3
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { BrowserFileSession, FileSessionState } from '../app/lib/files/session';
|
|
2
|
+
import type { EngineEvent, EngineResult, TaskOptions } from '../app/lib/engine/client';
|
|
3
|
+
import type { Command, CommandResponse } from '../app/lib/engine/protocol';
|
|
4
|
+
import type { ViewRequest, ViewResult } from '../app/lib/engine/view';
|
|
5
|
+
export type PackageKind = 'pdf' | 'word' | 'grid' | 'slide' | 'kit';
|
|
6
|
+
export type ViewerKind = Exclude<PackageKind, 'kit'>;
|
|
7
|
+
export type OfficeDocumentBytes = ArrayBuffer | Uint8Array;
|
|
8
|
+
export interface OfficeOptions {
|
|
9
|
+
/** Same-origin directory containing the package's engine/, fonts/ and optional OCR resources. */
|
|
10
|
+
assetBase?: string;
|
|
11
|
+
/** Install the existing unsaved-document beforeunload handler. Defaults to true. */
|
|
12
|
+
bindLifecycle?: boolean;
|
|
13
|
+
requestPassword?: (name: string, retry: boolean) => Promise<string | undefined>;
|
|
14
|
+
confirmDiscard?: (name: string) => Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
export interface MountOptions extends OfficeOptions {
|
|
17
|
+
/** File to open after the component has mounted. */
|
|
18
|
+
file?: File;
|
|
19
|
+
}
|
|
20
|
+
export interface MountedOffice<K extends PackageKind = PackageKind> {
|
|
21
|
+
readonly api: OfficeApi<K>;
|
|
22
|
+
open(file: File): Promise<void>;
|
|
23
|
+
flush(): Promise<void>;
|
|
24
|
+
/** Releases the component and discards unsaved changes; wait for saving to finish first. */
|
|
25
|
+
destroy(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export type ReadonlyCommandKind = 'status' | 'info' | 'search' | 'to_markdown' | 'body' | 'docx' | 'xlsx' | 'pptx' | 'pdf' | 'pdf_view' | 'markdown' | 'text';
|
|
28
|
+
/** Each viewer additionally checks that the command belongs to its document format. */
|
|
29
|
+
export type ReadonlyCommand = Command & {
|
|
30
|
+
kind: ReadonlyCommandKind;
|
|
31
|
+
};
|
|
32
|
+
export type ReadonlyViewRequest = Extract<ViewRequest, {
|
|
33
|
+
kind: 'layout' | 'tile' | 'hit' | 'selection' | 'text_review' | 'text_statistics' | 'text_objects' | 'grid_layout' | 'grid_tile' | 'grid_hit' | 'grid_selection' | 'pdf_state' | 'pdf_reading' | 'pdf_selection' | 'pdf_hit' | 'pdf_text_selection' | 'pdf_tools' | 'pdf_authenticate' | 'presentation_state' | 'presentation_selection' | 'presentation_hit' | 'presentation_playback' | 'presentation_frame' | 'presentation_media';
|
|
34
|
+
}>;
|
|
35
|
+
export interface OfficeCommonApi<K extends PackageKind = PackageKind> {
|
|
36
|
+
readonly kind: K;
|
|
37
|
+
readonly assetBase: string;
|
|
38
|
+
readonly state: Readonly<FileSessionState>;
|
|
39
|
+
open(file: File): Promise<void>;
|
|
40
|
+
open(name: string, bytes: OfficeDocumentBytes): Promise<void>;
|
|
41
|
+
read(command: ReadonlyCommand, options?: TaskOptions): Promise<EngineResult<CommandResponse>>;
|
|
42
|
+
view<T extends ViewResult = ViewResult>(request: ReadonlyViewRequest, options?: TaskOptions): Promise<EngineResult<T>>;
|
|
43
|
+
subscribe(listener: (state: FileSessionState, event?: EngineEvent) => void): () => void;
|
|
44
|
+
whenIdle(): Promise<void>;
|
|
45
|
+
close(options?: {
|
|
46
|
+
discard?: boolean;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export interface ReadonlyOfficeApi<K extends ViewerKind = ViewerKind> extends OfficeCommonApi<K> {
|
|
50
|
+
readonly readOnly: true;
|
|
51
|
+
}
|
|
52
|
+
export interface OfficeKitApi extends OfficeCommonApi<'kit'> {
|
|
53
|
+
readonly readOnly: false;
|
|
54
|
+
/** Full browser host: editing, scripts, history, export, and verified save transactions. */
|
|
55
|
+
readonly session: BrowserFileSession;
|
|
56
|
+
}
|
|
57
|
+
export type OfficeApi<K extends PackageKind = PackageKind> = K extends 'kit' ? OfficeKitApi : ReadonlyOfficeApi<Extract<K, ViewerKind>>;
|
|
58
|
+
export type { BrowserFileSession, FileSessionState, EngineEvent, EngineResult, TaskOptions };
|
|
59
|
+
export type { Command, CommandResponse, ViewRequest, ViewResult };
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqsoffice/slide",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "演示文稿浏览组件与浏览器 API,基于 Rust / WebAssembly",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"**/*.css"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/types/packages/slide/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/types/packages/slide/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./api": {
|
|
18
|
+
"types": "./dist/types/packages/slide/api.d.ts",
|
|
19
|
+
"import": "./dist/api.js"
|
|
20
|
+
},
|
|
21
|
+
"./style.css": "./dist/style.css",
|
|
22
|
+
"./assets/*": "./dist/assets/*",
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"office",
|
|
36
|
+
"wasm",
|
|
37
|
+
"slide",
|
|
38
|
+
"viewer"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"prepack": "node ../../scripts/check-package.mjs"
|
|
42
|
+
}
|
|
6
43
|
}
|