weboffice-js-sdk 2.0.5-beta.15 → 2.0.5-beta.16

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/README.md CHANGED
@@ -47,6 +47,27 @@ connect({
47
47
  - `disableAiEntry` 为可选布尔值,透传到 iframe 内 `OfficeSDK` 的 AI 入口开关能力。
48
48
  - `theme` 为可选主题对象,宿主侧仅负责透传;未传时 iframe 内仍使用默认主题配置。
49
49
 
50
+ ### V2 统一编辑 / 预览入口
51
+
52
+ V2 使用独立的 `connectV2()`,旧 `connect()` 保持兼容。V2 要求 `type` 和 `mode` 必填:
53
+
54
+ ```typescript
55
+ import { connectV2 } from 'weboffice-js-sdk'
56
+
57
+ const sdk = await connectV2({
58
+ fileId: 'your-file-id',
59
+ endpoint: 'https://your-shimo-endpoint',
60
+ signature: 'your-signature',
61
+ token: 'your-token',
62
+ container: document.querySelector('#shimo-file'),
63
+ type: 'writer',
64
+ mode: 'edit',
65
+ refreshCredentialsInterval: 600000
66
+ })
67
+ ```
68
+
69
+ 支持的 `type` 包括 `file`、`document`、`documentPro`、`writer`、`spreadsheet`、`presentation`、`table` 和 `form`。`writer` 与 `documentPro` 当前共存,`writer` 目前处于内测阶段。当前 `type` 主要作为 iframe 后续基于 `manifest.json` 选择资源的预留字段,不改变后端编辑准备判断。
70
+
50
71
  返回值:
51
72
 
52
73
  ```
@@ -9,6 +9,7 @@ import { Document, DocumentPro, Presentation, Spreadsheet, Table, Form, Flowchar
9
9
  import { EmptyPageOptions } from './types/EmptyPage';
10
10
  import { BaseEditor } from './types/BaseEditor';
11
11
  import { SlashMenuOptions } from './types/SlashMenu';
12
+ import type { ContentVersion } from './types/ConnectV2';
12
13
  import type { CollaboratorFacade, CommentsFacade, ContentFacade, DiscussionFacade, DocsActiveOutlineFacade, DocsOutlineFacade, DocsSearchFacade, DocsSelectionFacade, DocsSettingsFacade, DocsSidebarFacade, DocsTablesFacade, ExternalAppFacade, HistoryFacade, LocksFacade, MentionFacade, OfficeSDKPresentationFacade, PresentationEventSubscriptionFacade, PresentationSelectionFacade, PresentationSlidesFacade, PresentationTextFacade, PresentationZoomFacade, SheetChartsFacade, SheetSelectionsFacade, SheetWorkbookFacade, SheetWorksheetFacade, TitleFacade, VersionFacade } from './OfficeSDK.facade.types';
13
14
  import type { OfficeSDKMethodPath } from './OfficeSDK.methods';
14
15
  import type { HeaderBarsFacade } from './OfficeSDK.headerBars';
@@ -185,6 +186,7 @@ export declare class OfficeSDK extends TinyEmitter {
185
186
  private readonly emitter;
186
187
  private channel;
187
188
  private readonly connectOptions;
189
+ private readonly contentVersion?;
188
190
  private _readyState;
189
191
  private editor;
190
192
  private readonly startParams;
@@ -216,10 +218,15 @@ export declare class OfficeSDK extends TinyEmitter {
216
218
  * 归一化后的缺省页配置,构造时一次算完,后续仅读取。
217
219
  */
218
220
  private readonly normalizedEmptyPage;
221
+ private readonly preloadCredentialsMessageHandler;
222
+ private pendingInitializationErrorHandler?;
223
+ private pendingInitializationError?;
224
+ private preloadCredentialsPromise?;
225
+ private disconnected;
219
226
  private readonly preloadAckTimeoutMs;
220
227
  private readonly preloadDoneTimeoutMs;
221
228
  private readonly preloadReadyTimeoutMs;
222
- constructor(options: OfficeSDKOptions);
229
+ constructor(options: OfficeSDKOptions, contentVersion?: ContentVersion);
223
230
  get fileType(): FileType;
224
231
  get readyState(): ReadyState;
225
232
  /**
@@ -288,6 +295,8 @@ export declare class OfficeSDK extends TinyEmitter {
288
295
  */
289
296
  ready(): Promise<void>;
290
297
  private initIframe;
298
+ private handlePreloadMessage;
299
+ private getPreloadCredentials;
291
300
  private runPreloadHandshake;
292
301
  private initChannel;
293
302
  /**
package/dist/connect.d.ts CHANGED
@@ -1,6 +1,19 @@
1
1
  import { OfficeSDK, OfficeSDKOptions } from './OfficeSDK';
2
+ import { type ConnectV2FileType } from './types/ConnectV2';
3
+ export { CONNECT_V2_FILE_TYPES, isConnectV2FileType, isConnectV2Mode, validateConnectV2Options } from './types/ConnectV2';
4
+ export type { ConnectV2FileType } from './types/ConnectV2';
2
5
  export interface ConnectOptions extends OfficeSDKOptions {
3
6
  }
7
+ export interface ConnectV2Options extends ConnectOptions {
8
+ /**
9
+ * V2 套件类型。当前用于 iframe 侧资源选择预留。
10
+ */
11
+ type: ConnectV2FileType;
12
+ /**
13
+ * V2 打开模式。
14
+ */
15
+ mode: 'edit' | 'preview';
16
+ }
4
17
  /**
5
18
  * 初始化 SDK,返回 Promise,当 ReadState 变为 Ready 或 Failed 时,Promise 将被 resolve。
6
19
  * Promise resovled 不代表编辑器已经完整加载完毕,只代表 SDK 已经准备好了。
@@ -8,3 +21,9 @@ export interface ConnectOptions extends OfficeSDKOptions {
8
21
  * 比如受浏览器限制无法发出 postMessage() 时,Promise 将会一直 pending。
9
22
  */
10
23
  export declare function connect(options: ConnectOptions): Promise<OfficeSDK>;
24
+ /**
25
+ * 初始化 V2 统一编辑 / 预览入口。
26
+ *
27
+ * V2 在运行时强制校验 type 和 mode,底层 iframe 初始化流程与旧 connect 共用。
28
+ */
29
+ export declare function connectV2(options: ConnectV2Options): Promise<OfficeSDK>;