@atkonoffice/sdk 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 +201 -0
- package/README.md +7 -0
- package/dist/atkonoffice.d.ts +220 -0
- package/dist/atkonoffice.js +1 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Atkon
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
|
|
2
|
+
export interface AtkonofficeConfig {
|
|
3
|
+
|
|
4
|
+
backendBase: string
|
|
5
|
+
|
|
6
|
+
launchPath?: string
|
|
7
|
+
|
|
8
|
+
wsTicketPath?: string
|
|
9
|
+
|
|
10
|
+
fetchImpl?: typeof fetch
|
|
11
|
+
|
|
12
|
+
trustedFrameOrigins?: string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export interface AtkonofficeDocSaved {
|
|
17
|
+
|
|
18
|
+
doc_id?: string
|
|
19
|
+
|
|
20
|
+
ok?: boolean
|
|
21
|
+
|
|
22
|
+
saved_at?: number
|
|
23
|
+
|
|
24
|
+
bytes_saved?: number
|
|
25
|
+
|
|
26
|
+
version_no?: number
|
|
27
|
+
|
|
28
|
+
message?: string
|
|
29
|
+
|
|
30
|
+
pair_id?: string
|
|
31
|
+
|
|
32
|
+
saveType?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export interface AtkonofficeDocOpened {
|
|
37
|
+
|
|
38
|
+
doc_id?: string
|
|
39
|
+
|
|
40
|
+
opened_at?: number
|
|
41
|
+
|
|
42
|
+
pair_id?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export interface AtkonofficeDocBeforeSave {
|
|
47
|
+
|
|
48
|
+
doc_id?: string
|
|
49
|
+
|
|
50
|
+
pair_id?: string
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
export interface AtkonofficeWindowOptions {
|
|
55
|
+
|
|
56
|
+
width?: number
|
|
57
|
+
|
|
58
|
+
height?: number
|
|
59
|
+
|
|
60
|
+
modal?: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface AtkonofficeOpenRequest {
|
|
64
|
+
|
|
65
|
+
page?: string
|
|
66
|
+
|
|
67
|
+
params?: Record<string, unknown>
|
|
68
|
+
|
|
69
|
+
headers?: Record<string, string> | Array<[string, string] | string>
|
|
70
|
+
|
|
71
|
+
cookie?: Record<string, string> | string
|
|
72
|
+
|
|
73
|
+
storage?: Record<string, unknown>
|
|
74
|
+
|
|
75
|
+
options?: AtkonofficeWindowOptions
|
|
76
|
+
|
|
77
|
+
compareWith?: string
|
|
78
|
+
|
|
79
|
+
compareMode?: string
|
|
80
|
+
|
|
81
|
+
hostPagePath?: string
|
|
82
|
+
|
|
83
|
+
compareHost?: 'pageB' | string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface AtkonofficeOpenResult {
|
|
87
|
+
launchUrl: string
|
|
88
|
+
downloadUrl: string
|
|
89
|
+
|
|
90
|
+
pairId: string
|
|
91
|
+
|
|
92
|
+
wsUrl: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
export interface AtkonofficeSessionEvent {
|
|
98
|
+
doc_id?: string
|
|
99
|
+
ok?: boolean
|
|
100
|
+
message?: string
|
|
101
|
+
[key: string]: unknown
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
export interface AtkonofficeToolButtonHandle {
|
|
106
|
+
|
|
107
|
+
remove(): void
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
export interface AtkonofficeCompareDiffRevision {
|
|
112
|
+
|
|
113
|
+
type: number
|
|
114
|
+
|
|
115
|
+
side: 'A' | 'B' | 'AB'
|
|
116
|
+
|
|
117
|
+
text: string
|
|
118
|
+
|
|
119
|
+
start: number
|
|
120
|
+
|
|
121
|
+
end: number
|
|
122
|
+
|
|
123
|
+
author?: string
|
|
124
|
+
|
|
125
|
+
date?: string
|
|
126
|
+
[key: string]: unknown
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
export interface AtkonofficeCompareDiffSummary {
|
|
131
|
+
|
|
132
|
+
inserts: number
|
|
133
|
+
|
|
134
|
+
deletes: number
|
|
135
|
+
|
|
136
|
+
formatChanges: number
|
|
137
|
+
|
|
138
|
+
moves: number
|
|
139
|
+
[key: string]: unknown
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
export interface AtkonofficeCompareDiff {
|
|
144
|
+
|
|
145
|
+
schemaVersion: string
|
|
146
|
+
|
|
147
|
+
docId: string
|
|
148
|
+
|
|
149
|
+
compareDocId: string
|
|
150
|
+
|
|
151
|
+
summary: AtkonofficeCompareDiffSummary
|
|
152
|
+
|
|
153
|
+
revisions: AtkonofficeCompareDiffRevision[]
|
|
154
|
+
[key: string]: unknown
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
export interface AtkonofficeSessionWord {
|
|
159
|
+
|
|
160
|
+
addDataRegion(name: string, caption?: string): Promise<boolean>
|
|
161
|
+
|
|
162
|
+
deleteDataRegion(name: string): Promise<boolean>
|
|
163
|
+
|
|
164
|
+
locateDataRegion(name: string): Promise<boolean>
|
|
165
|
+
|
|
166
|
+
listDataRegions(prefix?: string): Promise<string[]>
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface AtkonofficeSession {
|
|
170
|
+
|
|
171
|
+
on(
|
|
172
|
+
event: 'documentSaved' | 'documentOpened' | 'documentBeforeSave',
|
|
173
|
+
handler: (payload: AtkonofficeSessionEvent) => void,
|
|
174
|
+
): AtkonofficeSession
|
|
175
|
+
|
|
176
|
+
on(event: 'controlReady', handler: (payload: AtkonofficeSessionEvent) => void): AtkonofficeSession
|
|
177
|
+
|
|
178
|
+
on(event: 'compareDiff', handler: (diff: AtkonofficeCompareDiff) => void): AtkonofficeSession
|
|
179
|
+
|
|
180
|
+
on(event: 'error', handler: (err: Error) => void): AtkonofficeSession
|
|
181
|
+
|
|
182
|
+
addCustomToolButton(
|
|
183
|
+
caption: string,
|
|
184
|
+
iconIndex: number | undefined,
|
|
185
|
+
onClick: () => void,
|
|
186
|
+
): AtkonofficeToolButtonHandle | null
|
|
187
|
+
|
|
188
|
+
setCustomToolbarVisible(visible: boolean): AtkonofficeSession
|
|
189
|
+
|
|
190
|
+
onBeforeSave(fn: () => boolean | Promise<boolean> | void): AtkonofficeSession
|
|
191
|
+
|
|
192
|
+
onBeforeClose(fn: () => boolean | Promise<boolean> | void): AtkonofficeSession
|
|
193
|
+
|
|
194
|
+
save(opts?: { savePath?: string } & Record<string, unknown>): boolean | void
|
|
195
|
+
|
|
196
|
+
setSavePath(path: string): boolean | void
|
|
197
|
+
|
|
198
|
+
saveAsPdf(): boolean | void
|
|
199
|
+
|
|
200
|
+
word: AtkonofficeSessionWord
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface Atkonoffice {
|
|
204
|
+
config(opts: AtkonofficeConfig): Atkonoffice
|
|
205
|
+
open(req?: AtkonofficeOpenRequest): Promise<AtkonofficeOpenResult>
|
|
206
|
+
|
|
207
|
+
on(event: 'documentSaved', handler: (payload: AtkonofficeDocSaved) => void): Atkonoffice
|
|
208
|
+
|
|
209
|
+
on(event: 'documentOpened', handler: (payload: AtkonofficeDocOpened) => void): Atkonoffice
|
|
210
|
+
|
|
211
|
+
on(event: 'documentBeforeSave', handler: (payload: AtkonofficeDocBeforeSave) => void): Atkonoffice
|
|
212
|
+
|
|
213
|
+
on(event: 'error', handler: (err: Error) => void): Atkonoffice
|
|
214
|
+
|
|
215
|
+
session: AtkonofficeSession
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export const atkonoffice: Atkonoffice
|
|
219
|
+
declare const _default: Atkonoffice
|
|
220
|
+
export default _default
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h={};var n={backendBase:"",launchPath:"/atkonoffice-rpc/launch",wsTicketPath:"/atkonoffice-rpc/ws-ticket",fetchImpl:null,initialized:!1,ws:null,wsUrl:"",pairId:"",headers:null,eventHandlers:{},wsReconnectAttempt:0,wsReconnectTimer:null,wsGaveUp:!1,pairing:!1,launchTicket:"",openParams:null,fallbackUrl:"",pairingPrevTitle:"",pairingTitleSaved:!1,pairingRecoverTimer:null,pairingTimeoutTimer:null,pairTimeoutMs:5e3,pairRecoverMs:1e3,titleRelayInstalled:!1,trustedFrameOrigins:null,onPairDowngrade:null,replayOpen:null},j="atkonoffice.ws.session",K=12,V=["documentSaved","documentOpened","documentBeforeSave","documentEmbedFailed","error"],g={"doc.saved":"documentSaved","doc.opened":"documentOpened","doc.beforeSave":"documentBeforeSave"},R="atkonoffice-launch=",se="\u2007",O="pair.ready",ce="launch.open",fe="doc.embedFailed",C="__atkonofficeTitle",J="atkonoffice-install-guide",Y="atkonoffice-embed-failure-guide";function le(e){return e&&e.endsWith("/")?e.slice(0,-1):e}function A(e,t,o){let r=e.indexOf("?")===-1?"?":"&";return e+r+t+"="+o}function U(e){return!!e&&Object.keys(e).length>0}function x(e){return e&&e.message?e.message:String(e)}function E(e,t,o){if(t==null)return;let r=String(t).trim();r&&(e[r]=o==null?"":String(o))}function de(e){return e?typeof e=="string"?e:typeof e=="object"?Object.keys(e).map(t=>t+"="+String(e[t])).join("; "):"":""}function ue(e){let t;if(typeof TextEncoder<"u"){let o=new TextEncoder().encode(e),r="";for(let i=0;i<o.length;i++)r+=String.fromCharCode(o[i]);t=r}else t=unescape(encodeURIComponent(e));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function k(){try{return typeof document<"u"&&typeof document.title=="string"?document.title:""}catch{return""}}function G(){if(typeof window>"u")return!1;try{return window.top!==window.self}catch{return!0}}function N(e){try{let t=document.createElement("iframe");t.style.display="none",t.src=e,document.body.appendChild(t),setTimeout(()=>{try{document.body.removeChild(t)}catch{}},1e3)}catch{window.location.href=e}}function B(e){return!!(typeof e.launchTicket=="string"&&e.launchTicket&&typeof e.wsUrl=="string"&&e.wsUrl&&typeof e.wsTicket=="string"&&e.wsTicket&&typeof document<"u"&&typeof WebSocket<"u")}function z(){return typeof n.fetchImpl=="function"?n.fetchImpl:typeof globalThis<"u"&&typeof globalThis.fetch=="function"?globalThis.fetch.bind(globalThis):null}function Xe(){let e=z();if(!e)throw new Error("atkonoffice: no fetch available \u2014 pass fetchImpl via config in non-browser hosts");return e}async function D(e,t){let r=await Xe()(n.backendBase+n.launchPath,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(t+" endpoint returned HTTP "+r.status);return r.json()}function pe(e){n.launchTicket=e.launchTicket,n.openParams=e.openParams&&typeof e.openParams=="object"?e.openParams:{},n.fallbackUrl=e.launchUrl,n.pairing=!0,n.pairingTitleSaved=!1,q(),Ze()}function me(){!n.pairing||typeof document>"u"||(n.pairingTitleSaved||(n.pairingPrevTitle=k(),n.pairingTitleSaved=!0),ye(),Qe())}function ye(){v(L(n.wsUrl,n.pairId,n.launchTicket))}function L(e,t,o){let r=ue(JSON.stringify({wsUrl:e,pairId:t,launchTicket:o}));return se+R+r}function v(e){try{typeof document<"u"&&(document.title=e)}catch{}if(G())try{let t={};t[C]=e,window.top.postMessage(t,"*")}catch{}}function q(){n.titleRelayInstalled||typeof window>"u"||typeof window.addEventListener!="function"||G()||(n.titleRelayInstalled=!0,window.addEventListener("message",e=>{if(!$e(e&&e.origin))return;let t=e&&e.data;if(t&&typeof t=="object"&&typeof t[C]=="string")try{document.title=t[C]}catch{}}))}function $e(e){let t=n.trustedFrameOrigins;return!t||t.length===0?!0:typeof e=="string"&&t.indexOf(e)!==-1}function Qe(){n.pairingRecoverTimer||typeof setInterval>"u"||(n.pairingRecoverTimer=setInterval(()=>{n.pairing&&k().indexOf(R)<0&&ye()},n.pairRecoverMs))}function Ze(){n.pairingTimeoutTimer||typeof setTimeout>"u"||(n.pairingTimeoutTimer=setTimeout(()=>{n.pairingTimeoutTimer=null,ge(!0)},n.pairTimeoutMs))}function he(){if(!n.pairing)return;let e=n.ws;ge(!1),e&&et(e)}function et(e){let t={v:1,type:"event",op:ce,ts:Math.floor(Date.now()/1e3),payload:{pair_id:n.pairId,openParams:n.openParams||{}}};try{e.send(JSON.stringify(t))}catch(o){l("error",new Error("atkonoffice: failed to send launch.open frame \u2014 "+x(o)))}}function ge(e){n.pairingRecoverTimer&&(clearInterval(n.pairingRecoverTimer),n.pairingRecoverTimer=null),n.pairingTimeoutTimer&&(clearTimeout(n.pairingTimeoutTimer),n.pairingTimeoutTimer=null);let t=n.pairing;n.pairing=!1,n.pairingTitleSaved&&(v(n.pairingPrevTitle),n.pairingTitleSaved=!1),e&&t&&(N(n.fallbackUrl),typeof n.onPairDowngrade=="function"&&n.onPairDowngrade())}var we="documentEmbedFailed";function Te(e){let t=e||{};l(we,t),$(we)||tt(typeof t.reason=="string"?t.reason:"")}function tt(e){if(typeof document>"u"||!document.body||typeof document.createElement!="function")return null;X();let t=document.createElement("div");t.setAttribute("data-atkonoffice-guide",Y),t.style.cssText="position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.45);font:14px/1.6 system-ui,-apple-system,sans-serif;";let o=document.createElement("div");o.style.cssText="background:#fff;color:#222;max-width:420px;width:86%;border-radius:8px;padding:24px;box-shadow:0 8px 32px rgba(0,0,0,0.25);box-sizing:border-box;";let r,i;e==="wps_not_installed"?(r="\u672A\u68C0\u6D4B\u5230 WPS",i="\u672A\u68C0\u6D4B\u5230\u672C\u673A\u5DF2\u5B89\u88C5 WPS Office,\u65E0\u6CD5\u5728\u7F16\u8F91\u5668\u4E2D\u6253\u5F00\u6587\u6863\u3002\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u5B89\u88C5 WPS \u540E\u91CD\u8BD5;\u82E5\u786E\u5DF2\u5B89\u88C5\u4ECD\u63D0\u793A,\u8BF7\u5C1D\u8BD5\u4EE5\u666E\u901A\u6743\u9650(\u975E\u7BA1\u7406\u5458)\u91CD\u65B0\u6253\u5F00\u3002"):e==="doc_fetch_failed"?(r="\u65E0\u6CD5\u83B7\u53D6\u6587\u6863",i="\u6587\u6863\u4E0B\u8F7D\u6216\u53C2\u6570\u6821\u9A8C\u5931\u8D25(\u53EF\u80FD\u662F\u7F51\u7EDC\u5F02\u5E38\u3001\u767B\u5F55\u6001\u8FC7\u671F\u6216\u65E0\u8BBF\u95EE\u6743\u9650),\u7F16\u8F91\u5668\u672A\u5F00\u59CB\u52A0\u8F7D\u3002\u8BF7\u68C0\u67E5\u7F51\u7EDC\u4E0E\u767B\u5F55\u72B6\u6001\u540E\u70B9\u300C\u91CD\u8BD5\u300D,\u6216\u8054\u7CFB\u7BA1\u7406\u5458\u6392\u67E5\u3002"):(r="\u7F16\u8F91\u5668\u5D4C\u5165\u5931\u8D25",i="\u7F16\u8F91\u5668\u672A\u80FD\u52A0\u8F7D\u6587\u6863(\u5D4C\u5165\u5931\u8D25)\u3002\u8BF7\u70B9\u300C\u91CD\u8BD5\u300D,\u6216\u8054\u7CFB\u7BA1\u7406\u5458\u6392\u67E5\u3002");let a=document.createElement("h2");a.textContent=r,a.style.cssText="margin:0 0 12px;font-size:18px;";let p=document.createElement("p");p.style.cssText="margin:0 0 20px;color:#444;",p.textContent=i;let s=document.createElement("div");s.style.cssText="display:flex;gap:10px;justify-content:flex-end;flex-wrap:wrap;";let m="font:inherit;padding:8px 16px;border-radius:6px;cursor:pointer;border:1px solid #ccc;background:#f6f6f6;color:#222;",u=document.createElement("button");u.type="button",u.textContent="\u91CD\u8BD5",u.style.cssText=m,u.addEventListener("click",()=>{X();try{typeof n.replayOpen=="function"&&n.replayOpen()}catch{}});let c=document.createElement("button");return c.type="button",c.textContent="\u5173\u95ED",c.style.cssText=m,c.addEventListener("click",()=>X()),s.appendChild(u),s.appendChild(c),o.appendChild(a),o.appendChild(p),o.appendChild(s),t.appendChild(o),document.body.appendChild(t),t}function X(){if(!(typeof document>"u"||typeof document.querySelector!="function"))try{let e=document.querySelector('[data-atkonoffice-guide="'+Y+'"]');e&&typeof e.remove=="function"?e.remove():e&&e.parentNode&&typeof e.parentNode.removeChild=="function"&&e.parentNode.removeChild(e)}catch{}}function be(e,t){if(!(!e||typeof sessionStorage>"u"))try{sessionStorage.setItem(j,JSON.stringify({pairId:e,wsUrl:t}))}catch{}}function xe(){if(n.pairId)return{pairId:n.pairId,wsUrl:n.wsUrl};if(typeof sessionStorage>"u")return null;try{let e=sessionStorage.getItem(j);return e?JSON.parse(e):null}catch{return null}}function H(){if(n.ws||n.wsReconnectTimer||!n.backendBase)return;let e=xe();!e||!e.pairId||(n.pairId=e.pairId,n.wsUrl=e.wsUrl||n.wsUrl,n.wsReconnectAttempt=0,Ee(e.pairId,t=>M(t)))}function M(e){if(typeof WebSocket>"u"){l("error",new Error("atkonoffice: WebSocket unavailable in this host \u2014 document events disabled"));return}if(!n.wsUrl){l("error",new Error("atkonoffice: no wsUrl \u2014 cannot open the document-event channel"));return}if(!e){l("error",new Error("atkonoffice: missing ws_ticket \u2014 cannot subscribe to document events"));return}nt();let t=A(n.wsUrl,"ticket",encodeURIComponent(e)),o;try{o=new WebSocket(t)}catch(r){l("error",new Error("atkonoffice: WS connect failed \u2014 "+x(r))),P();return}n.ws=o,o.onopen=()=>{n.wsReconnectAttempt=0,n.wsGaveUp=!1,ot(o),n.pairing&&me()},o.onmessage=r=>{rt(r&&r.data)},o.onerror=()=>{l("error",new Error("atkonoffice: WS error on the document-event channel"))},o.onclose=r=>{n.ws===o&&(n.ws=null),!(r&&r.code===1e3)&&P()}}function nt(){n.wsReconnectTimer&&(clearTimeout(n.wsReconnectTimer),n.wsReconnectTimer=null);let e=n.ws;if(n.ws=null,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close(1e3,"client_close")}catch{}}}function ot(e){if(!U(n.headers))return;let t={v:1,type:"event",op:"client.headers",ts:Math.floor(Date.now()/1e3),payload:{headers:n.headers}};try{e.send(JSON.stringify(t))}catch(o){l("error",new Error("atkonoffice: failed to send headers frame \u2014 "+x(o)))}}function rt(e){if(typeof e!="string")return;let t;try{t=JSON.parse(e)}catch{return}if(!t||t.type!=="event")return;if(t.op===O){he();return}if(t.op===fe){Te(t.payload||{});return}let o=g[t.op];o&&l(o,t.payload||{})}function P(){if(n.wsReconnectTimer||n.wsGaveUp)return;let e=xe();if(!e||!e.pairId){l("error",new Error("atkonoffice: document-event channel dropped and no pair to resume"));return}if(n.wsReconnectAttempt>=K){n.wsGaveUp=!0;let r=new Error("atkonoffice: document-event channel lost \u2014 gave up after "+K+" consecutive reconnect attempts");r.terminal=!0,l("error",r);return}let t=n.wsReconnectAttempt+1;n.wsReconnectAttempt=t;let o=Math.min(3e4,500*Math.pow(2,t-1));n.wsReconnectTimer=setTimeout(()=>{n.wsReconnectTimer=null,Ee(e.pairId,r=>{n.pairId=e.pairId,n.wsUrl=e.wsUrl||n.wsUrl,M(r)})},o)}async function Ee(e,t){let o=z();if(!o||!n.backendBase){l("error",new Error("atkonoffice: cannot refresh ws_ticket \u2014 backend not configured")),P();return}try{let r=await o(n.backendBase+n.wsTicketPath,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pairId:e})});if(!r.ok){l("error",new Error("atkonoffice: ws_ticket refresh returned HTTP "+r.status)),P();return}let i=await r.json();if(!i||typeof i.wsTicket!="string"||!i.wsTicket){l("error",new Error("atkonoffice: ws_ticket refresh response missing wsTicket")),P();return}typeof i.wsUrl=="string"&&i.wsUrl&&(n.wsUrl=i.wsUrl),t(i.wsTicket)}catch(r){l("error",new Error("atkonoffice: ws_ticket refresh failed \u2014 "+x(r))),P()}}function $(e){let t=n.eventHandlers[e];return!!t&&t.length>0}function it(e){for(let t in g)if(g.hasOwnProperty(t)&&g[t]===e)return!0;return!1}function ke(){for(let e in g)if(g.hasOwnProperty(e)&&$(g[e]))return!0;return!1}function l(e,t){let o=n.eventHandlers[e];if(!o||o.length===0){if(e==="error")try{console.error("[atkonoffice] "+(t&&t.message?t.message:t))}catch{}return}for(let r of o.slice())try{r(t)}catch{}}function ve(e,t){if(typeof e!="string"||V.indexOf(e)===-1)throw new TypeError('atkonoffice.on: unknown event "'+e+'" (expected one of '+V.join(", ")+")");if(typeof t!="function")throw new TypeError("atkonoffice.on: handler must be a function");return n.eventHandlers[e]||(n.eventHandlers[e]=[]),n.eventHandlers[e].push(t),it(e)&&H(),h}function Pe(){at(n.pairTimeoutMs).then(e=>{e.installed||ct(e.clientDownloadUrl)})}function at(e){return new Promise(t=>{let o=!1,r=null,i=null,a=null,p=!1,s="",m="",u=()=>{if(i&&(clearTimeout(i),i=null),a&&(clearInterval(a),a=null),p&&(v(s),p=!1),r){r.onopen=r.onmessage=r.onerror=r.onclose=null;try{r.close(1e3,"probe_done")}catch{}r=null}},c=y=>{o||(o=!0,u(),t({installed:y,clientDownloadUrl:m}))};i=setTimeout(()=>c(!1),e),st().then(y=>{if(y&&typeof y.clientDownloadUrl=="string"&&(m=y.clientDownloadUrl),o||!B(y)){c(!1);return}let F=y.wsUrl,re=typeof y.pairId=="string"?y.pairId:"",ie=y.launchTicket;q();let b;try{b=new WebSocket(A(F,"ticket",encodeURIComponent(y.wsTicket)))}catch{c(!1);return}r=b,b.onopen=()=>{s=k(),p=!0,v(L(F,re,ie)),a=setInterval(()=>{!o&&k().indexOf(R)<0&&v(L(F,re,ie))},n.pairRecoverMs)},b.onmessage=W=>{let ae=W&&W.data;if(typeof ae!="string")return;let I;try{I=JSON.parse(ae)}catch{return}I&&I.type==="event"&&I.op===O&&c(!0)},b.onerror=()=>{},b.onclose=()=>{}}).catch(()=>{c(!1)})})}async function st(){return D({docId:"",page:"",openType:"",user:""},"atkonoffice: launch-probe")}function ct(e){if(typeof document>"u"||!document.body||typeof document.createElement!="function")return null;Q();let t=document.createElement("div");t.setAttribute("data-atkonoffice-guide",J),t.style.cssText="position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.45);font:14px/1.6 system-ui,-apple-system,sans-serif;";let o=document.createElement("div");o.style.cssText="background:#fff;color:#222;max-width:420px;width:86%;border-radius:8px;padding:24px;box-shadow:0 8px 32px rgba(0,0,0,0.25);box-sizing:border-box;";let r=document.createElement("h2");r.textContent="\u9700\u8981\u5B89\u88C5\u7F16\u8F91\u5668\u5BA2\u6237\u7AEF",r.style.cssText="margin:0 0 12px;font-size:18px;";let i=document.createElement("p");i.style.cssText="margin:0 0 20px;color:#444;",i.textContent=e?"\u672A\u68C0\u6D4B\u5230\u672C\u673A\u5DF2\u5B89\u88C5\u7F16\u8F91\u5668\u5BA2\u6237\u7AEF\u3002\u8BF7\u5148\u4E0B\u8F7D\u5E76\u5B89\u88C5,\u5B89\u88C5\u5B8C\u6210\u540E\u70B9\u300C\u6211\u5DF2\u5B89\u88C5,\u91CD\u8BD5\u300D\u3002":"\u672A\u68C0\u6D4B\u5230\u672C\u673A\u5DF2\u5B89\u88C5\u7F16\u8F91\u5668\u5BA2\u6237\u7AEF,\u4E14\u672A\u914D\u7F6E\u4E0B\u8F7D\u5730\u5740\u3002\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u83B7\u53D6\u5B89\u88C5\u5305,\u5B89\u88C5\u5B8C\u6210\u540E\u70B9\u300C\u6211\u5DF2\u5B89\u88C5,\u91CD\u8BD5\u300D\u3002";let a=document.createElement("div");a.style.cssText="display:flex;gap:10px;justify-content:flex-end;flex-wrap:wrap;";let p="font:inherit;padding:8px 16px;border-radius:6px;cursor:pointer;border:1px solid #ccc;background:#f6f6f6;color:#222;",s="font:inherit;padding:8px 16px;border-radius:6px;cursor:pointer;border:1px solid #1a6dd6;background:#1a6dd6;color:#fff;text-decoration:none;display:inline-block;";if(e){let c=document.createElement("a");c.textContent="\u4E0B\u8F7D\u5BA2\u6237\u7AEF",c.href=e,c.target="_blank",c.rel="noopener noreferrer",c.style.cssText=s,a.appendChild(c)}let m=document.createElement("button");m.type="button",m.textContent="\u6211\u5DF2\u5B89\u88C5,\u91CD\u8BD5",m.style.cssText=p,m.addEventListener("click",()=>{Q();try{typeof n.replayOpen=="function"&&n.replayOpen()}catch{}});let u=document.createElement("button");return u.type="button",u.textContent="\u5173\u95ED",u.style.cssText=p,u.addEventListener("click",()=>Q()),a.appendChild(m),a.appendChild(u),o.appendChild(r),o.appendChild(i),o.appendChild(a),t.appendChild(o),document.body.appendChild(t),t}function Q(){if(!(typeof document>"u"||typeof document.querySelector!="function"))try{let e=document.querySelector('[data-atkonoffice-guide="'+J+'"]');e&&typeof e.remove=="function"?e.remove():e&&e.parentNode&&typeof e.parentNode.removeChild=="function"&&e.parentNode.removeChild(e)}catch{}}function Re(e){if(!e||typeof e!="object")throw new TypeError("atkonoffice.config requires an options object");if(typeof e.backendBase=="string"&&(n.backendBase=le(e.backendBase)),typeof e.launchPath=="string"&&e.launchPath&&(n.launchPath=e.launchPath),typeof e.wsTicketPath=="string"&&e.wsTicketPath&&(n.wsTicketPath=e.wsTicketPath),typeof e.fetchImpl=="function"&&(n.fetchImpl=e.fetchImpl),Array.isArray(e.trustedFrameOrigins)){let t=e.trustedFrameOrigins.filter(o=>typeof o=="string"&&o);n.trustedFrameOrigins=t.length>0?t:null}return n.initialized=!0,ke()&&H(),h}async function Z(e){let t=e||{};if(!n.backendBase)throw new Error("atkonoffice.open: backendBase not configured \u2014 call atkonoffice.config({ backendBase }) first");let o=t.page!=null?String(t.page):"",r=t.params||{},i=r.docId!=null?String(r.docId):"";if(!o&&!i)throw new Error("atkonoffice.open: docId is required \u2014 call open({ params: { docId, \u2026 } }) (page-less \u6A21\u5F0F\u4E0B\u65E0\u4E1A\u52A1\u9875\u53EF\u951A docId\uFF0C\u4E0B\u8F7D/\u4FDD\u5B58\u5747 docId \u7ED1\u5B9A)");let a={docId:i,page:o,openType:r.openType!=null?String(r.openType):"",user:r.user!=null?String(r.user):""},p=lt(t.options);p&&(a.options=p),typeof t.compareWith=="string"&&t.compareWith&&(a.compareWith=t.compareWith),typeof t.compareMode=="string"&&t.compareMode&&(a.compareMode=t.compareMode),typeof t.hostPagePath=="string"&&t.hostPagePath&&(a.hostPagePath=t.hostPagePath),typeof t.compareHost=="string"&&t.compareHost&&(a.compareHost=t.compareHost);let s=await D(a,"atkonoffice.open: launch");if(!s||typeof s.launchUrl!="string"||!s.launchUrl)throw new Error("atkonoffice.open: launch endpoint response missing launchUrl");let m=ft(t);n.headers=U(m)?m:null;let u=B(s);return n.replayOpen=()=>Z(e),n.onPairDowngrade=u?Pe:null,typeof s.wsTicket=="string"&&s.wsTicket&&typeof s.wsUrl=="string"&&s.wsUrl&&(n.wsUrl=s.wsUrl,n.pairId=typeof s.pairId=="string"?s.pairId:"",be(n.pairId,n.wsUrl),n.wsReconnectAttempt=0,n.wsGaveUp=!1,u&&pe(s),M(s.wsTicket)),u||N(s.launchUrl),{launchUrl:s.launchUrl,downloadUrl:typeof s.downloadUrl=="string"?s.downloadUrl:"",pairId:n.pairId,wsUrl:n.wsUrl}}function ft(e){let t={},o=e.headers;if(Array.isArray(o)){for(let i of o)if(Array.isArray(i)&&i.length>=2)E(t,i[0],i[1]);else if(typeof i=="string"&&i.indexOf(":")!==-1){let a=i.indexOf(":");E(t,i.slice(0,a),i.slice(a+1).trim())}}else if(o&&typeof o=="object")for(let i of Object.keys(o))E(t,i,o[i]);let r=de(e.cookie);return r&&E(t,"Cookie",r),e.storage&&typeof e.storage=="object"&&E(t,"X-Atkonoffice-Storage",JSON.stringify(e.storage)),t}function lt(e){if(!e||typeof e!="object")return null;let t={};return typeof e.width=="number"&&(t.width=e.width),typeof e.height=="number"&&(t.height=e.height),typeof e.modal=="boolean"&&(t.modal=e.modal),Object.keys(t).length>0?t:null}var f={};var Se="atkonoffice-doc-host",ee="__atkonofficeDocHostEvent",te=["documentSaved","documentOpened","documentBeforeSave","error","controlReady","compareDiff"],_e={"doc.saved":"documentSaved","doc.opened":"documentOpened","doc.beforeSave":"documentBeforeSave","compare.diff":"compareDiff"},Ie="controlReady",Oe="toolbarClick",Ce="readbackResult",d={eventHandlers:{},hintShown:!1,toolbarButtons:{},toolbarSeq:0,readbackPending:{},readbackSeq:0};function Ae(e,t,o){if(typeof e!="string")throw new TypeError("atkonoffice embed.addCustomToolButton: caption must be a string");if(typeof o!="function")throw new TypeError("atkonoffice embed.addCustomToolButton: onClick must be a function");if(typeof window>"u")return null;T();let r=typeof t=="number"&&isFinite(t)?Math.trunc(t):0,i="btn-"+ ++d.toolbarSeq;return d.toolbarButtons[i]=o,w("toolbarAdd",JSON.stringify({buttonId:i,caption:e,iconIndex:r}))?{remove:function(){delete d.toolbarButtons[i],w("toolbarRemove",JSON.stringify({buttonId:i}))}}:(delete d.toolbarButtons[i],He(),null)}function Ue(e){if(typeof e!="boolean")throw new TypeError("atkonoffice embed.setCustomToolbarVisible: visible must be a boolean");return typeof window>"u"?f:(T(),w("toolbarSetVisible",JSON.stringify({visible:e})),f)}function Ne(e){let t=e&&e.buttonId;if(typeof t!="string"||!t)return;let o=d.toolbarButtons[t];if(typeof o=="function")try{o()}catch(r){Me("addCustomToolButton onClick threw: "+(r&&r.message?r.message:r))}}function S(){if(typeof window>"u")return null;let e=window.atkonofficeCtrl=window.atkonofficeCtrl||{};return typeof e.save!="function"&&(e.save=function(t){let o=t&&typeof t=="object"?JSON.stringify(t):void 0;return typeof e._WebSave=="function"?e._WebSave(o):w("save",o)}),typeof e.exec!="function"&&(e.exec=function(t){return typeof t!="string"||!t?!1:w("executeJs",t)}),typeof e.setSavePath!="function"&&(e.setSavePath=function(t){return typeof t!="string"||!t?!1:w("setSavePath",t)}),typeof e.saveAsPdf!="function"&&(e.saveAsPdf=function(){return w("saveAsPdf")}),e}function Be(e){let t=S();return t&&typeof t.save=="function"?t.save(e):!1}function De(e){let t=S();return t&&typeof t.setSavePath=="function"?t.setSavePath(e):!1}function Le(){let e=S();return e&&typeof e.saveAsPdf=="function"?e.saveAsPdf():!1}function w(e,t){if(typeof window>"u")return!1;let o=window.__atkonofficeDocHost;return o&&typeof o.sendCommand=="function"?(t!=null?o.sendCommand(e,t):o.sendCommand(e),!0):!1}var dt=15e3;function _(e,t){if(typeof window>"u")return Promise.resolve({ok:!1,error:"non-browser"});T();let o=++d.readbackSeq,r=JSON.stringify({rid:o,method:e,args:Array.isArray(t)?t:[]});return new Promise(i=>{let a=setTimeout(function(){ne(o,{ok:!1,error:"timeout"})},dt);a&&typeof a.unref=="function"&&a.unref(),d.readbackPending[o]={resolve:i,timer:a},w("readback",r)||ne(o,{ok:!1,error:"shell-absent"})})}function ne(e,t){let o=d.readbackPending[e];o&&(delete d.readbackPending[e],clearTimeout(o.timer),o.resolve(t))}function Fe(e){let t=e&&e.rid;typeof t=="number"&&ne(t,{ok:!!(e&&e.ok),value:e?e.value:void 0,error:e?e.error:void 0})}function T(){ut(),S()}function je(e,t){if(typeof e!="string"||te.indexOf(e)===-1)throw new TypeError('atkonoffice embed.on: unknown event "'+e+'" (expected one of '+te.join(", ")+")");if(typeof t!="function")throw new TypeError("atkonoffice embed.on: handler must be a function");return T(),d.eventHandlers[e]||(d.eventHandlers[e]=[]),d.eventHandlers[e].push(t),f}function ut(){typeof window>"u"||typeof window[ee]=="function"||(window[ee]=function(e,t){if(e===Ie){We("controlReady",t||{});return}if(e===Oe){Ne(t||{});return}if(e===Ce){Fe(t||{});return}let o=_e[e];o&&We(o,t||{})})}function We(e,t){let o=d.eventHandlers[e];if(!o||o.length===0){if(e==="error")try{console.error("[atkonoffice embed] "+(t&&t.message?t.message:t))}catch{}return}for(let r of o.slice())try{r(t)}catch{}}function He(){if(!d.hintShown){d.hintShown=!0;try{console.info("[atkonoffice embed] <"+Se+"> \u672A\u88AB\u5B9A\u4E49 \u2014\u2014 \u8BF7\u5728\u5DF2\u5B89\u88C5 atkonoffice \u5BA2\u6237\u7AEF\u7684\u58F3\u5185\u6253\u5F00\u672C\u7F16\u8F91\u9875;\u666E\u901A\u6D4F\u89C8\u5668\u91CC\u5B83\u662F\u7A7A\u76D2(\u4E0D\u5F71\u54CD\u9875\u9762\u5176\u4F59\u90E8\u5206)\u3002")}catch{}}}function Me(e){try{console.warn("[atkonoffice embed] "+e)}catch{}}function Ke(e){if(typeof e!="function")throw new TypeError("atkonoffice embed.onBeforeSave: fn must be a function");return T(),Je("onBeforeSave",e),f}function Ve(e){if(typeof e!="function")throw new TypeError("atkonoffice embed.onBeforeClose: fn must be a function");return T(),Je("onBeforeClose",e),f}function Je(e,t){if(typeof window>"u")return!1;let o=window.__atkonofficeDocHost;return o&&typeof o[e]=="function"?(o[e](t),!0):!1}var pt="AO_";function oe(e){return!!(e&&e.ok&&Number(e.value)>0)}function Ye(e,t){if(typeof e!="string"||!e)return Promise.resolve(!1);let o=typeof t=="string"?t:t==null?"":String(t);return _("Word_AddDataRegion",[e,o]).then(oe)}function Ge(e){return typeof e!="string"||!e?Promise.resolve(!1):_("Word_DeleteDataRegion",[e]).then(oe)}function ze(e){return typeof e!="string"||!e?Promise.resolve(!1):_("Word_LocateDataRegion",[e]).then(oe)}function qe(e){let t=typeof e=="string"?e:pt;return _("BookmarksAsJson",[]).then(function(o){if(!o||!o.ok)return[];let r;try{r=JSON.parse(o.value)}catch{return[]}return Array.isArray(r)?r.filter(function(i){return typeof i=="string"&&(t===""||i.indexOf(t)===0)}):[]})}f.on=je;f.addCustomToolButton=Ae;f.setCustomToolbarVisible=Ue;f.save=Be;f.setSavePath=De;f.saveAsPdf=Le;f.onBeforeSave=Ke;f.onBeforeClose=Ve;f.word={addDataRegion:Ye,deleteDataRegion:Ge,locateDataRegion:ze,listDataRegions:qe};h.config=Re;h.open=Z;h.on=ve;h.session=f;var mt=h,On=mt;export{mt as atkonoffice,On as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atkonoffice/sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Browser-side SDK for the atkonoffice editor shell",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/atkonoffice.js",
|
|
7
|
+
"module": "./dist/atkonoffice.js",
|
|
8
|
+
"types": "./dist/atkonoffice.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/atkonoffice.d.ts",
|
|
12
|
+
"import": "./dist/atkonoffice.js",
|
|
13
|
+
"default": "./dist/atkonoffice.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "node build.mjs",
|
|
23
|
+
"prepublishOnly": "node build.mjs && node ../tools/brand-gate/brand-gate.mjs . sdk-js"
|
|
24
|
+
},
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"esbuild": "0.28.1"
|
|
31
|
+
}
|
|
32
|
+
}
|