quickspeadsheet 1.0.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 +22 -0
- package/README.md +1072 -0
- package/dist/chunks/decryptOle-CCR7y3ED.js +76 -0
- package/dist/chunks/decryptOoxml-_5lSrxRZ.js +60 -0
- package/dist/chunks/dragMerge-DHUQYNgo.js +70794 -0
- package/dist/chunks/encryptOoxml-Bk1DbPbq.js +82 -0
- package/dist/chunks/udocMetafileBundle-DOq3GGY1.js +1121 -0
- package/dist/community.css +1 -0
- package/dist/community.js +559 -0
- package/dist/enterprise.css +1 -0
- package/dist/enterprise.js +559 -0
- package/dist/pro.css +1 -0
- package/dist/pro.js +559 -0
- package/dist/quickspeadsheet.js +562 -0
- package/dist/style.css +1 -0
- package/dist/types/community.d.ts +10 -0
- package/dist/types/enterprise.d.ts +10 -0
- package/dist/types/excel/core/excelio.d.ts +415 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/pro.d.ts +10 -0
- package/dist/types/runtime-public.d.ts +501 -0
- package/dist/types/spread.d.ts +1147 -0
- package/package.json +144 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 宿主可见的 runtime / 协同 / IO 陪同类型。
|
|
3
|
+
* 与 `src/excel/engine/runtime.js`、`useSpread.js` 的 JSDoc 对齐;发布时随 `src/types` 复制到 `dist/types`。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ExcelIO } from '../excel/core/excelio'
|
|
7
|
+
|
|
8
|
+
/** createWorkbook 实例在宿主侧常用的最小形状(完整 API 见源码 Workbook 类) */
|
|
9
|
+
export interface SpreadWorkbookInstance {
|
|
10
|
+
getActiveSheet?: () => unknown
|
|
11
|
+
toJSON?: (options?: { includeBindingSource?: boolean }) => object
|
|
12
|
+
fromJSON?: (json: object) => void
|
|
13
|
+
destroy?: () => void
|
|
14
|
+
refresh?: () => void
|
|
15
|
+
calculate?: () => void
|
|
16
|
+
calculateActiveSheet?: () => void
|
|
17
|
+
getExtensionHost?: () => unknown
|
|
18
|
+
setCollaborationSession?: (session: CollaborationSessionLike | null) => void
|
|
19
|
+
setCollaborationState?: (state: CollaborationStateSnapshot | null) => void
|
|
20
|
+
[key: string]: unknown
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* ExcelIO 自 XLSX 解析得到的工作簿 JSON 上可选的 OPC 字段(亦会经 fromJSON 写入 Workbook 元数据)。
|
|
25
|
+
* - `officeDocumentTarget`:根 `_rels/.rels` 中 officeDocument 的 Target。
|
|
26
|
+
* - `workbookPartPath`:实际采用的工作簿主部件(含与 `[Content_Types]` Override 冲突时以 officeDocument 为准)。
|
|
27
|
+
*/
|
|
28
|
+
export interface SpreadWorkbookOpcPackageFields {
|
|
29
|
+
officeDocumentTarget?: string | null
|
|
30
|
+
workbookPartPath?: string | null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type { ExcelIO }
|
|
34
|
+
|
|
35
|
+
/** 公式栏等 UI 组件实例(实现因宿主而异) */
|
|
36
|
+
export type FormulaBoxInstance = Record<string, unknown>
|
|
37
|
+
|
|
38
|
+
export interface ConnectDocumentInput {
|
|
39
|
+
documentId?: string
|
|
40
|
+
sessionId?: string
|
|
41
|
+
currentSheetId?: string
|
|
42
|
+
prefetch?: { snapshot?: boolean; versions?: boolean; history?: boolean }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type CollaborationEventPayload = unknown
|
|
46
|
+
|
|
47
|
+
export type CollaborationJsonRecord = Record<string, unknown>
|
|
48
|
+
|
|
49
|
+
export interface PublishOperationsResult {
|
|
50
|
+
acceptedOperations: CollaborationJsonRecord[]
|
|
51
|
+
rejectedOperations: CollaborationJsonRecord[]
|
|
52
|
+
serverRevision: number
|
|
53
|
+
warnings?: CollaborationJsonRecord[]
|
|
54
|
+
warningCodes?: string[]
|
|
55
|
+
warningCount?: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ApplyRemoteOperationsResult {
|
|
59
|
+
operations: CollaborationJsonRecord[]
|
|
60
|
+
conflicts: CollaborationJsonRecord[]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface CollaborationHistoryVersionsPage {
|
|
64
|
+
items: CollaborationJsonRecord[]
|
|
65
|
+
nextCursor: string | null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface CollaborationConnectionError {
|
|
69
|
+
message?: string
|
|
70
|
+
stage?: string
|
|
71
|
+
code?: string
|
|
72
|
+
status?: number
|
|
73
|
+
retryable?: boolean
|
|
74
|
+
requiresSnapshot?: boolean
|
|
75
|
+
serverRevision?: number
|
|
76
|
+
failedOperationIds?: string[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface CollaborationPrefetchedSnapshotMeta {
|
|
80
|
+
documentId?: string
|
|
81
|
+
versionId?: string | null
|
|
82
|
+
serverRevision?: number
|
|
83
|
+
schemaVersion?: string | null
|
|
84
|
+
integrityHash?: string | null
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface CollaborationBulkConflictResolutionSummary {
|
|
88
|
+
strategy?: 'acceptRemote' | 'keepLocal' | 'manual' | string
|
|
89
|
+
totalCount?: number
|
|
90
|
+
successCount?: number
|
|
91
|
+
failedCount?: number
|
|
92
|
+
syncedConflictCount?: number
|
|
93
|
+
historyReloadCount?: number
|
|
94
|
+
resolvedAt?: string
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface CollaborationStateSnapshot {
|
|
98
|
+
actor?: unknown
|
|
99
|
+
collaborationMode?: 'remote' | 'mock'
|
|
100
|
+
documentId?: string
|
|
101
|
+
sessionId?: string
|
|
102
|
+
connectionStatus?:
|
|
103
|
+
| 'idle'
|
|
104
|
+
| 'connecting'
|
|
105
|
+
| 'syncing'
|
|
106
|
+
| 'online'
|
|
107
|
+
| 'degraded'
|
|
108
|
+
| 'offline'
|
|
109
|
+
| 'reconnecting'
|
|
110
|
+
| 'conflicted'
|
|
111
|
+
| 'readonly'
|
|
112
|
+
connectionQuality?: string
|
|
113
|
+
conflictResolveMode?: 'resolve-only' | 'resolve-then-publish' | 'auto' | string
|
|
114
|
+
conflictResolvePolicy?: 'auto' | 'always' | 'never' | string
|
|
115
|
+
baseRevision?: number
|
|
116
|
+
lastServerRevision?: number
|
|
117
|
+
pendingOperations?: CollaborationJsonRecord[]
|
|
118
|
+
pendingConflicts?: CollaborationJsonRecord[]
|
|
119
|
+
currentPermissions?: unknown
|
|
120
|
+
collaborators?: CollaborationJsonRecord[]
|
|
121
|
+
activeLocks?: CollaborationJsonRecord[]
|
|
122
|
+
capabilities?: Record<string, boolean>
|
|
123
|
+
lastSyncAt?: string
|
|
124
|
+
lastError?: CollaborationConnectionError | null
|
|
125
|
+
lastWarnings?: CollaborationJsonRecord[]
|
|
126
|
+
lastResolvedConflict?: unknown
|
|
127
|
+
resolvedConflictHistory?: CollaborationJsonRecord[]
|
|
128
|
+
lastBulkConflictResolutionSummary?: CollaborationBulkConflictResolutionSummary | null
|
|
129
|
+
prefetchedSnapshot?: CollaborationPrefetchedSnapshotMeta | null
|
|
130
|
+
prefetchedVersions?: CollaborationJsonRecord[]
|
|
131
|
+
prefetchedHistory?: CollaborationJsonRecord[]
|
|
132
|
+
licenseStatus?: 'valid' | 'expired' | 'invalid' | 'missing' | 'offline-grace' | string
|
|
133
|
+
licenseSource?: string
|
|
134
|
+
licenseReason?: string
|
|
135
|
+
licenseExpiresAt?: string | null
|
|
136
|
+
licenseEnforcedReadOnly?: boolean
|
|
137
|
+
[key: string]: unknown
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface ResolveConflictInput {
|
|
141
|
+
conflictId?: string
|
|
142
|
+
strategy?: 'acceptRemote' | 'keepLocal' | 'manual'
|
|
143
|
+
manualPayload?: unknown
|
|
144
|
+
resolutionOperation?: CollaborationJsonRecord
|
|
145
|
+
operations?: CollaborationJsonRecord[]
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface RemoteReplayReportInput {
|
|
149
|
+
results?: CollaborationJsonRecord[]
|
|
150
|
+
serverRevision?: number
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface RemoteReplayReportResult {
|
|
154
|
+
ok: boolean
|
|
155
|
+
failedOperations: CollaborationJsonRecord[]
|
|
156
|
+
error?: unknown
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** 协同会话外观(适配器可扩展方法) */
|
|
160
|
+
export interface CollaborationSessionLike {
|
|
161
|
+
getState?: () => CollaborationStateSnapshot | undefined
|
|
162
|
+
getConflictResolvePolicy?: () => {
|
|
163
|
+
preferResolveOnly?: boolean
|
|
164
|
+
resolvePublishPolicy?: 'auto' | 'always' | 'never'
|
|
165
|
+
[key: string]: unknown
|
|
166
|
+
}
|
|
167
|
+
setConflictResolvePolicy?: (input?: {
|
|
168
|
+
preferResolveOnly?: boolean
|
|
169
|
+
resolvePublishPolicy?: 'auto' | 'always' | 'never'
|
|
170
|
+
[key: string]: unknown
|
|
171
|
+
}) => {
|
|
172
|
+
preferResolveOnly?: boolean
|
|
173
|
+
resolvePublishPolicy?: 'auto' | 'always' | 'never'
|
|
174
|
+
[key: string]: unknown
|
|
175
|
+
}
|
|
176
|
+
subscribe?: (listener: (type: string, payload: CollaborationEventPayload) => void) => void | (() => void)
|
|
177
|
+
connectDocument?: (input?: ConnectDocumentInput) => Promise<unknown>
|
|
178
|
+
disconnectDocument?: (reason?: string) => Promise<unknown>
|
|
179
|
+
publishOperations?: (input?: CollaborationJsonRecord) => Promise<PublishOperationsResult>
|
|
180
|
+
applyRemoteOperations?: (input?: CollaborationJsonRecord) => Promise<ApplyRemoteOperationsResult>
|
|
181
|
+
fetchDocumentSnapshot?: (input?: CollaborationJsonRecord) => Promise<unknown>
|
|
182
|
+
syncWorkbookFromServerSnapshot?: (workbook: SpreadWorkbookInstance, input?: CollaborationJsonRecord) => Promise<unknown>
|
|
183
|
+
fetchHistory?: (input?: CollaborationJsonRecord) => Promise<CollaborationHistoryVersionsPage>
|
|
184
|
+
fetchVersions?: (input?: CollaborationJsonRecord) => Promise<CollaborationHistoryVersionsPage>
|
|
185
|
+
fetchPermissions?: (input?: CollaborationJsonRecord) => Promise<unknown>
|
|
186
|
+
listCollaborators?: (input?: CollaborationJsonRecord) => Promise<CollaborationJsonRecord[]>
|
|
187
|
+
listConflicts?: (input?: CollaborationJsonRecord) => Promise<CollaborationHistoryVersionsPage>
|
|
188
|
+
/** 从服务端拉取待处理冲突并写回 `pendingConflicts`(存在 `restAdapter.listConflicts` 时由 sessionManager 实现) */
|
|
189
|
+
syncPendingConflictsFromServer?: (input?: CollaborationJsonRecord) => Promise<CollaborationJsonRecord[]>
|
|
190
|
+
resolveConflict?: (input?: ResolveConflictInput) => Promise<unknown>
|
|
191
|
+
updatePermissions?: (nextPermissions?: CollaborationJsonRecord) => unknown
|
|
192
|
+
updatePresence?: (item?: CollaborationJsonRecord) => CollaborationJsonRecord[]
|
|
193
|
+
replacePresence?: (items?: CollaborationJsonRecord[]) => CollaborationJsonRecord[]
|
|
194
|
+
replaceVersions?: (items?: CollaborationJsonRecord[]) => CollaborationJsonRecord[]
|
|
195
|
+
restoreVersion?: (input?: CollaborationJsonRecord) => Promise<unknown>
|
|
196
|
+
reportRemoteReplayResult?: (input?: RemoteReplayReportInput) => RemoteReplayReportResult
|
|
197
|
+
retryPendingOperations?: () => Promise<PublishOperationsResult>
|
|
198
|
+
clearPendingOperations?: () => CollaborationJsonRecord[]
|
|
199
|
+
clearWarnings?: () => CollaborationJsonRecord[]
|
|
200
|
+
resetRevision?: (nextRevision?: number) => void
|
|
201
|
+
updateLicenseState?: (nextLicenseState?: CollaborationJsonRecord) => CollaborationStateSnapshot
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface RuntimeIoHooks {
|
|
205
|
+
onStart?: () => void
|
|
206
|
+
onEnd?: () => void
|
|
207
|
+
onError?: (error: unknown) => void
|
|
208
|
+
onProgress?: (info: unknown, total?: unknown) => void
|
|
209
|
+
signal?: AbortSignal
|
|
210
|
+
password?: string
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface RuntimeDownloadRequest {
|
|
214
|
+
kind: 'json' | 'excel' | string
|
|
215
|
+
fileName: string
|
|
216
|
+
contentType?: string
|
|
217
|
+
text?: string
|
|
218
|
+
blob?: Blob
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export type HostActionReturn = unknown
|
|
222
|
+
|
|
223
|
+
export interface SpreadRuntimeHostActions {
|
|
224
|
+
focusFormulaBar?: () => HostActionReturn
|
|
225
|
+
notify?: (message: string, type?: string) => HostActionReturn
|
|
226
|
+
openSearch?: () => HostActionReturn
|
|
227
|
+
openPrintPreview?: () => HostActionReturn
|
|
228
|
+
showWorkbookSummary?: () => HostActionReturn
|
|
229
|
+
openVersionHistory?: () => HostActionReturn
|
|
230
|
+
openHistoryPanel?: () => HostActionReturn
|
|
231
|
+
openConflictPanel?: () => HostActionReturn
|
|
232
|
+
refreshCollaborationData?: () => HostActionReturn
|
|
233
|
+
retryCollaborationConnection?: () => HostActionReturn
|
|
234
|
+
retryPendingQueue?: () => HostActionReturn
|
|
235
|
+
clearPendingQueue?: () => HostActionReturn
|
|
236
|
+
setConflictResolvePolicy?: (payload?: unknown) => HostActionReturn
|
|
237
|
+
locateResolvedConflict?: (payload?: unknown) => HostActionReturn
|
|
238
|
+
restoreVersion?: (payload?: unknown) => HostActionReturn
|
|
239
|
+
resolveAllConflicts?: (payload?: unknown) => HostActionReturn
|
|
240
|
+
resolveConflictItem?: (payload?: unknown) => HostActionReturn
|
|
241
|
+
openSettingsPanel?: (payload?: unknown) => HostActionReturn
|
|
242
|
+
openChartDesigner?: (payload?: unknown) => HostActionReturn
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** collaborationServices 中与适配器相关的弱类型槽位(具体形状见协同实现与 OpenAPI 文档) */
|
|
246
|
+
export interface CollaborationServicesConfig {
|
|
247
|
+
mode?: 'mock' | 'remote'
|
|
248
|
+
/** 兼容旧配置:`mock: true` 等价于 `mode: 'mock'` */
|
|
249
|
+
mock?: boolean
|
|
250
|
+
/**
|
|
251
|
+
* 远端严格模式:开启后必须显式提供 REST/WS 地址(或直接注入适配器),
|
|
252
|
+
* 以避免误用默认 `/api/v1` 与当前 host 的 WS 地址。
|
|
253
|
+
*/
|
|
254
|
+
strictRemote?: boolean
|
|
255
|
+
/** 冲突解决时优先只走 resolve 接口;true 时前端不会再额外 publish resolution operation。 */
|
|
256
|
+
preferResolveOnly?: boolean
|
|
257
|
+
/** 冲突解决发布策略:auto=后端已应用则不二次 publish;always=总是 publish;never=只走 resolve。 */
|
|
258
|
+
resolvePublishPolicy?: 'auto' | 'always' | 'never'
|
|
259
|
+
apiBaseUrl?: string
|
|
260
|
+
baseUrl?: string
|
|
261
|
+
realtimeUrl?: string
|
|
262
|
+
wsUrl?: string
|
|
263
|
+
getAuthHeader?: () => Record<string, string> | Promise<Record<string, string>>
|
|
264
|
+
getAuthQuery?: () => Record<string, string | number | boolean> | Promise<Record<string, string | number | boolean>>
|
|
265
|
+
authQueryTokenKey?: string
|
|
266
|
+
/** true 时会在 hello payload 中附带 token(默认 false,更安全) */
|
|
267
|
+
exposeAuthInHello?: boolean
|
|
268
|
+
mockStore?: unknown
|
|
269
|
+
mockOptions?: CollaborationJsonRecord
|
|
270
|
+
restAdapter?: unknown
|
|
271
|
+
realtimeAdapter?: unknown
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export interface HostActionMissingPayload {
|
|
275
|
+
actionName: string
|
|
276
|
+
capability?: string
|
|
277
|
+
args: unknown[]
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface RuntimeImportUrlResultOk {
|
|
281
|
+
ok: true
|
|
282
|
+
json?: object
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface RuntimeImportUrlResultEmpty {
|
|
286
|
+
ok: false
|
|
287
|
+
empty: true
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export type RuntimeImportUrlResult = RuntimeImportUrlResultOk | RuntimeImportUrlResultEmpty
|
|
291
|
+
|
|
292
|
+
export interface RuntimeImportFileResultOk {
|
|
293
|
+
ok: true
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface RuntimeImportFileResultFail {
|
|
297
|
+
ok: false
|
|
298
|
+
empty?: boolean
|
|
299
|
+
unsupported?: boolean
|
|
300
|
+
cancelled?: boolean
|
|
301
|
+
error?: unknown
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export type RuntimeImportFileResult = RuntimeImportFileResultOk | RuntimeImportFileResultFail
|
|
305
|
+
|
|
306
|
+
/** addIns 数组元素(与 engine addins registry 归一化前兼容) */
|
|
307
|
+
export type RuntimeAddInDefinition = CollaborationJsonRecord & {
|
|
308
|
+
id?: string
|
|
309
|
+
title?: string
|
|
310
|
+
actionType?: string
|
|
311
|
+
command?: string
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface SpreadRuntimeOptions {
|
|
315
|
+
edition?: string
|
|
316
|
+
capabilities?: Record<string, boolean> | string[]
|
|
317
|
+
extensionApi?: Record<string, unknown>
|
|
318
|
+
createExcelIO?: boolean
|
|
319
|
+
registerBuiltinAddIns?: boolean
|
|
320
|
+
registerInstalledAddIns?: boolean
|
|
321
|
+
addIns?: RuntimeAddInDefinition[]
|
|
322
|
+
documentId?: string
|
|
323
|
+
collaborationServices?: CollaborationServicesConfig
|
|
324
|
+
prefetchOnConnect?: { snapshot?: boolean; versions?: boolean; history?: boolean }
|
|
325
|
+
onCollaborationStateChange?: (state: CollaborationStateSnapshot | null) => void
|
|
326
|
+
hostActions?: SpreadRuntimeHostActions
|
|
327
|
+
/** 授权策略:与 `licenseContext` 配合;也可单独用 `forceReadOnly` 演示只读 */
|
|
328
|
+
licensePolicy?: {
|
|
329
|
+
/** 强制工作簿引擎只读(会写入 `licenseEnforcedReadOnly`) */
|
|
330
|
+
forceReadOnly?: boolean
|
|
331
|
+
/**
|
|
332
|
+
* 默认 true:存在非空 `licenseContext` 且 `licenseStatus` 为 invalid/expired 时启用引擎只读。
|
|
333
|
+
* false 时仅降为 community,与旧行为一致(仍可编辑)。
|
|
334
|
+
*/
|
|
335
|
+
readOnlyOnInvalidOrExpired?: boolean
|
|
336
|
+
/** 默认 true:当 `expiresAt` 可解析且已过期时,将 valid/offline-grace 收敛为 expired。 */
|
|
337
|
+
enforceExpiresAt?: boolean
|
|
338
|
+
/**
|
|
339
|
+
* 仅用于 `offline-grace`:若设置(毫秒),超过 `expiresAt + offlineGraceMs` 后自动收敛为 expired。
|
|
340
|
+
* 未设置时保持宿主传入状态。
|
|
341
|
+
*/
|
|
342
|
+
offlineGraceMs?: number
|
|
343
|
+
/**
|
|
344
|
+
* entitlement 到 edition/capabilities 的映射覆盖;key 不区分大小写。
|
|
345
|
+
* 内置包含 starter/professional/enterprise-collaboration,可在此扩展或覆盖。
|
|
346
|
+
*/
|
|
347
|
+
entitlementPresetMap?: Record<
|
|
348
|
+
string,
|
|
349
|
+
{
|
|
350
|
+
edition?: string
|
|
351
|
+
capabilities?: Record<string, boolean> | string[]
|
|
352
|
+
}
|
|
353
|
+
>
|
|
354
|
+
/** 测试或回放场景可注入“当前时间毫秒”。未设置时使用 Date.now()。 */
|
|
355
|
+
nowMs?: number
|
|
356
|
+
/** `probeOnline` / `resolveLicenseAccess`:优先用于联网探测的 URL */
|
|
357
|
+
connectivityCheckUrl?: string
|
|
358
|
+
/** 探测请求超时(毫秒),默认 3000 */
|
|
359
|
+
connectivityTimeoutMs?: number
|
|
360
|
+
}
|
|
361
|
+
/** 归一化后注入工作簿:授权失败/过期时由 `resolveLicensedRuntimeOptions` 设置 */
|
|
362
|
+
licenseEnforcedReadOnly?: boolean
|
|
363
|
+
licenseContext?: Record<string, unknown>
|
|
364
|
+
/** runtime 初始化后(onReady 前)回传当前授权快照,便于宿主日志/埋点/UI 展示。 */
|
|
365
|
+
onLicenseStateResolved?: (snapshot: SpreadLicenseSnapshot) => void
|
|
366
|
+
/** 默认 true:runtime 初始化时按授权状态尝试触发一次 hostActions.notify。 */
|
|
367
|
+
notifyLicenseStateResolved?: boolean
|
|
368
|
+
onHostActionMissing?: (payload: HostActionMissingPayload) => HostActionReturn
|
|
369
|
+
onDownloadRequested?: (request: RuntimeDownloadRequest) => HostActionReturn
|
|
370
|
+
onReady?: (runtime: SpreadRuntime) => void
|
|
371
|
+
onDestroy?: (runtime: SpreadRuntime) => void
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** `SpreadExcelViewer` 内置 JWT 授权;设置后忽略 `licenseContext` */
|
|
375
|
+
export interface SpreadLicenseAccessConfig {
|
|
376
|
+
publicKeyPem: string
|
|
377
|
+
remoteUrl?: string
|
|
378
|
+
/** 在线时优先用 HMAC token 向此 URL 换发 ES256 JWT(如 license-server `GET|POST /api/license/jwt`) */
|
|
379
|
+
remoteJwtExchange?: { url: string; hmacToken: string; method?: 'POST' | 'GET' }
|
|
380
|
+
storageKey?: string
|
|
381
|
+
initialToken?: string
|
|
382
|
+
fetchInit?: RequestInit
|
|
383
|
+
storage?: {
|
|
384
|
+
getItem: (key: string) => string | null
|
|
385
|
+
setItem: (key: string, value: string) => void
|
|
386
|
+
removeItem: (key: string) => void
|
|
387
|
+
}
|
|
388
|
+
fetchImpl?: typeof fetch
|
|
389
|
+
/** 解析超时(毫秒),0 表示不限制 */
|
|
390
|
+
resolveTimeoutMs?: number
|
|
391
|
+
/** 是否在 window online/offline 时重新 `resolveLicenseAccess` 并必要时重建 runtime */
|
|
392
|
+
refreshOnNetworkChange?: boolean
|
|
393
|
+
licensePolicy?: SpreadRuntimeOptions['licensePolicy']
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** 与 `initializeExtensionHost` 返回值对齐的最小宿主视图 */
|
|
397
|
+
export interface SpreadExtensionActionsLike {
|
|
398
|
+
getSpread?: () => SpreadWorkbookInstance | null
|
|
399
|
+
getActiveSheet?: () => unknown | null
|
|
400
|
+
getSheetCount?: () => number
|
|
401
|
+
getActiveSheetName?: () => string
|
|
402
|
+
focusFormulaBar?: () => unknown
|
|
403
|
+
openSearch?: () => unknown
|
|
404
|
+
openPrintPreview?: () => unknown
|
|
405
|
+
showWorkbookSummary?: () => unknown
|
|
406
|
+
openVersionHistory?: () => unknown
|
|
407
|
+
openHistoryPanel?: () => unknown
|
|
408
|
+
openConflictPanel?: () => unknown
|
|
409
|
+
refreshCollaborationData?: () => unknown
|
|
410
|
+
retryCollaborationConnection?: () => unknown
|
|
411
|
+
retryPendingQueue?: () => unknown
|
|
412
|
+
clearPendingQueue?: () => unknown
|
|
413
|
+
setConflictResolvePolicy?: (payload?: unknown) => unknown
|
|
414
|
+
locateResolvedConflict?: (payload?: unknown) => unknown
|
|
415
|
+
restoreVersion?: (payload?: unknown) => unknown
|
|
416
|
+
resolveAllConflicts?: (payload?: unknown) => unknown
|
|
417
|
+
resolveConflictItem?: (payload?: unknown) => unknown
|
|
418
|
+
openSettingsPanel?: (payload?: unknown) => unknown
|
|
419
|
+
openChartDesigner?: (payload?: unknown) => unknown
|
|
420
|
+
notify?: (message: string, type?: string) => unknown
|
|
421
|
+
hasCapability?: (capability: string) => unknown
|
|
422
|
+
/** 授权只读下会 no-op 并通过 notify 提示。 */
|
|
423
|
+
toggleGridlines?: () => unknown
|
|
424
|
+
/** 授权只读下会 no-op 并通过 notify 提示。 */
|
|
425
|
+
toggleFormulas?: () => unknown
|
|
426
|
+
refreshWorkbook?: () => unknown
|
|
427
|
+
/** 授权只读下会 no-op 并通过 notify 提示。 */
|
|
428
|
+
calculateWorkbook?: () => unknown
|
|
429
|
+
/** 授权只读下会 no-op 并通过 notify 提示。 */
|
|
430
|
+
calculateActiveSheet?: () => unknown
|
|
431
|
+
/** 授权只读下会 no-op 并通过 notify 提示。 */
|
|
432
|
+
recalculateWorkbook?: () => unknown
|
|
433
|
+
/** 授权只读下会 no-op 并通过 notify 提示。 */
|
|
434
|
+
insertBuiltinIcon?: (iconKey?: string) => unknown
|
|
435
|
+
getEdition?: () => string | undefined
|
|
436
|
+
getCapabilities?: () => Record<string, boolean>
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export interface SpreadExtensionHostLike {
|
|
440
|
+
spread: SpreadWorkbookInstance | null
|
|
441
|
+
actions: SpreadExtensionActionsLike
|
|
442
|
+
attach?: (extensionApi?: Record<string, unknown>) => Record<string, unknown> | null
|
|
443
|
+
getApi?: () => Record<string, unknown> | null
|
|
444
|
+
run?: (actionName: string, ...args: unknown[]) => unknown
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** `createSpreadRuntime` 返回的授权只读快照,供宿主横幅 / 调试 */
|
|
448
|
+
export interface SpreadLicenseSnapshot {
|
|
449
|
+
edition: string
|
|
450
|
+
licenseStatus?: string
|
|
451
|
+
licenseSource?: string
|
|
452
|
+
licenseReason?: string
|
|
453
|
+
licenseEnforcedReadOnly: boolean
|
|
454
|
+
/** 社区版等:引擎模型只读,但允许在无法授权失效时通过 import 载入内容 */
|
|
455
|
+
editionViewOnly?: boolean
|
|
456
|
+
expiresAt?: string | null
|
|
457
|
+
entitlements: string[]
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export interface SpreadRuntime {
|
|
461
|
+
resolvedEdition: { edition: string; capabilities: Record<string, boolean> }
|
|
462
|
+
capabilities: Record<string, boolean>
|
|
463
|
+
spread: SpreadWorkbookInstance
|
|
464
|
+
workbook: SpreadWorkbookInstance
|
|
465
|
+
excelIO: ExcelIO | null
|
|
466
|
+
extensionHost: SpreadExtensionHostLike
|
|
467
|
+
collaborationSession: CollaborationSessionLike | null
|
|
468
|
+
getLicenseSnapshot: () => SpreadLicenseSnapshot
|
|
469
|
+
/** 模型是否不可编辑(`licenseEnforcedReadOnly` 或 `editionViewOnly`) */
|
|
470
|
+
isLicenseReadOnly: () => boolean
|
|
471
|
+
importJson: (json: object) => void
|
|
472
|
+
importFromUrl: (url: string, options?: object) => Promise<RuntimeImportUrlResult>
|
|
473
|
+
executeImportFromUrl: (url: string, hooks?: RuntimeIoHooks) => Promise<RuntimeImportUrlResult>
|
|
474
|
+
importFile: (file: File, hooks?: RuntimeIoHooks) => Promise<RuntimeImportFileResult>
|
|
475
|
+
executeImportFile: (file: File, hooks?: RuntimeIoHooks) => Promise<RuntimeImportFileResult>
|
|
476
|
+
exportJsonText: () => Promise<string>
|
|
477
|
+
executeExportJsonText: (hooks?: RuntimeIoHooks) => Promise<string>
|
|
478
|
+
executeExportJsonDownload: (hooks?: RuntimeIoHooks) => Promise<unknown>
|
|
479
|
+
exportExcelBlob: () => Promise<Blob>
|
|
480
|
+
executeExportExcelBlob: (hooks?: RuntimeIoHooks) => Promise<Blob>
|
|
481
|
+
executeExportExcelDownload: (hooks?: RuntimeIoHooks) => Promise<unknown>
|
|
482
|
+
getExportFileName: (prefix?: string) => string
|
|
483
|
+
getCollaborationState: () => CollaborationStateSnapshot | null
|
|
484
|
+
setConflictResolvePolicy: (input?: {
|
|
485
|
+
preferResolveOnly?: boolean
|
|
486
|
+
resolvePublishPolicy?: 'auto' | 'always' | 'never'
|
|
487
|
+
[key: string]: unknown
|
|
488
|
+
}) => {
|
|
489
|
+
preferResolveOnly?: boolean
|
|
490
|
+
resolvePublishPolicy?: 'auto' | 'always' | 'never'
|
|
491
|
+
[key: string]: unknown
|
|
492
|
+
} | null
|
|
493
|
+
hasCapability: (capability: string) => boolean
|
|
494
|
+
assertCapability: (capability: string, message?: string) => true
|
|
495
|
+
runHostAction: (
|
|
496
|
+
actionName: keyof SpreadRuntimeHostActions | string,
|
|
497
|
+
capability?: string,
|
|
498
|
+
...args: unknown[]
|
|
499
|
+
) => HostActionReturn
|
|
500
|
+
destroy: () => void
|
|
501
|
+
}
|