@kg-ui/kg-ui-plus 0.1.50 → 0.1.51

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 (27) hide show
  1. package/dist/es/KgCopilot/CopiCanvas/FilePreview.vue.mjs +7 -0
  2. package/dist/es/KgCopilot/CopiCanvas/FilePreview.vue2.mjs +295 -0
  3. package/dist/es/KgCopilot/CopiCanvas/FilePreview.vue3.mjs +4 -0
  4. package/dist/es/KgCopilot/CopiCanvas/FileSkeletion.vue.mjs +96 -0
  5. package/dist/es/KgCopilot/CopiCanvas/FileSkeletion.vue2.mjs +4 -0
  6. package/dist/es/KgCopilot/CopiCanvas/InitWrap.vue.mjs +7 -0
  7. package/dist/es/KgCopilot/CopiCanvas/InitWrap.vue2.mjs +41 -0
  8. package/dist/es/KgCopilot/CopiCanvas/InitWrap.vue3.mjs +4 -0
  9. package/dist/es/KgCopilot/CopiCanvas/index.vue.mjs +1 -1
  10. package/dist/es/KgCopilot/CopiCanvas/index.vue2.mjs +4 -3
  11. package/dist/es/KgCopilot/CopiCanvas/index.vue3.mjs +2 -2
  12. package/dist/es/_virtual/_commonjs-dynamic-modules.mjs +6 -0
  13. package/dist/es/_virtual/jszip.min.mjs +13 -0
  14. package/dist/es/api/copilot.mjs +8 -0
  15. package/dist/es/assets/empty.png.mjs +4 -0
  16. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/folder-opened.mjs +8 -0
  17. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/file-damage-line.mjs +8 -0
  18. package/dist/es/node_modules/.pnpm/@vueuse_core@9.13.0_vue@3.2.45/node_modules/@vueuse/core/index.mjs +3 -1
  19. package/dist/es/node_modules/.pnpm/@vueuse_shared@9.13.0_vue@3.2.45/node_modules/@vueuse/shared/index.mjs +52 -1
  20. package/dist/es/node_modules/.pnpm/docx-preview@0.3.3/node_modules/docx-preview/dist/docx-preview.mjs +3877 -0
  21. package/dist/es/node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/dist/jszip.min.mjs +2649 -0
  22. package/dist/es/style.css +1 -1
  23. package/package.json +116 -124
  24. package/dist/es/KgCopilot/CopiCanvas/testWPS.vue.mjs +0 -7
  25. package/dist/es/KgCopilot/CopiCanvas/testWPS.vue2.mjs +0 -50
  26. package/dist/es/KgCopilot/CopiCanvas/testWPS.vue3.mjs +0 -4
  27. package/dist/es/KgCopilot/CopiCanvas/web-office-sdk-solution-v2.0.7.es.mjs +0 -854
@@ -1,854 +0,0 @@
1
- var e = function(t2, n2) {
2
- return (e = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e2, t3) {
3
- e2.__proto__ = t3;
4
- } || function(e2, t3) {
5
- for (var n3 in t3)
6
- t3.hasOwnProperty(n3) && (e2[n3] = t3[n3]);
7
- })(t2, n2);
8
- };
9
- function t(t2, n2) {
10
- function i2() {
11
- this.constructor = t2;
12
- }
13
- e(t2, n2), t2.prototype = null === n2 ? Object.create(n2) : (i2.prototype = n2.prototype, new i2());
14
- }
15
- var n, i, r, s, o = function() {
16
- return (o = Object.assign || function(e2) {
17
- for (var t2, n2 = 1, i2 = arguments.length; n2 < i2; n2++)
18
- for (var r2 in t2 = arguments[n2])
19
- Object.prototype.hasOwnProperty.call(t2, r2) && (e2[r2] = t2[r2]);
20
- return e2;
21
- }).apply(this, arguments);
22
- };
23
- function a(e2, t2, n2, i2) {
24
- return new (n2 || (n2 = Promise))(function(r2, s2) {
25
- function o2(e3) {
26
- try {
27
- c2(i2.next(e3));
28
- } catch (e4) {
29
- s2(e4);
30
- }
31
- }
32
- function a2(e3) {
33
- try {
34
- c2(i2.throw(e3));
35
- } catch (e4) {
36
- s2(e4);
37
- }
38
- }
39
- function c2(e3) {
40
- var t3;
41
- e3.done ? r2(e3.value) : (t3 = e3.value, t3 instanceof n2 ? t3 : new n2(function(e4) {
42
- e4(t3);
43
- })).then(o2, a2);
44
- }
45
- c2((i2 = i2.apply(e2, t2 || [])).next());
46
- });
47
- }
48
- function c(e2, t2) {
49
- var n2, i2, r2, s2, o2 = { label: 0, sent: function() {
50
- if (1 & r2[0])
51
- throw r2[1];
52
- return r2[1];
53
- }, trys: [], ops: [] };
54
- return s2 = { next: a2(0), throw: a2(1), return: a2(2) }, "function" == typeof Symbol && (s2[Symbol.iterator] = function() {
55
- return this;
56
- }), s2;
57
- function a2(s3) {
58
- return function(a3) {
59
- return function(s4) {
60
- if (n2)
61
- throw new TypeError("Generator is already executing.");
62
- for (; o2; )
63
- try {
64
- if (n2 = 1, i2 && (r2 = 2 & s4[0] ? i2.return : s4[0] ? i2.throw || ((r2 = i2.return) && r2.call(i2), 0) : i2.next) && !(r2 = r2.call(i2, s4[1])).done)
65
- return r2;
66
- switch (i2 = 0, r2 && (s4 = [2 & s4[0], r2.value]), s4[0]) {
67
- case 0:
68
- case 1:
69
- r2 = s4;
70
- break;
71
- case 4:
72
- return o2.label++, { value: s4[1], done: false };
73
- case 5:
74
- o2.label++, i2 = s4[1], s4 = [0];
75
- continue;
76
- case 7:
77
- s4 = o2.ops.pop(), o2.trys.pop();
78
- continue;
79
- default:
80
- if (!(r2 = (r2 = o2.trys).length > 0 && r2[r2.length - 1]) && (6 === s4[0] || 2 === s4[0])) {
81
- o2 = 0;
82
- continue;
83
- }
84
- if (3 === s4[0] && (!r2 || s4[1] > r2[0] && s4[1] < r2[3])) {
85
- o2.label = s4[1];
86
- break;
87
- }
88
- if (6 === s4[0] && o2.label < r2[1]) {
89
- o2.label = r2[1], r2 = s4;
90
- break;
91
- }
92
- if (r2 && o2.label < r2[2]) {
93
- o2.label = r2[2], o2.ops.push(s4);
94
- break;
95
- }
96
- r2[2] && o2.ops.pop(), o2.trys.pop();
97
- continue;
98
- }
99
- s4 = t2.call(e2, o2);
100
- } catch (e3) {
101
- s4 = [6, e3], i2 = 0;
102
- } finally {
103
- n2 = r2 = 0;
104
- }
105
- if (5 & s4[0])
106
- throw s4[1];
107
- return { value: s4[0] ? s4[1] : void 0, done: true };
108
- }([s3, a3]);
109
- };
110
- }
111
- }
112
- !function(e2) {
113
- e2.refreshToken = "api.getToken";
114
- }(n || (n = {})), function(e2) {
115
- e2.unknown = "unknown", e2.spreadsheet = "s", e2.writer = "w", e2.presentation = "p", e2.pdf = "f", e2.otl = "o", e2.dbt = "d", e2.ksheet = "k";
116
- }(i || (i = {})), function(e2) {
117
- e2.nomal = "nomal", e2.simple = "simple", e2.embed = "embed";
118
- }(r || (r = {})), function(e2) {
119
- e2[e2.requestFullscreen = 1] = "requestFullscreen", e2[e2.exitFullscreen = 0] = "exitFullscreen";
120
- }(s || (s = {}));
121
- var l = window.navigator.userAgent.toLowerCase(), u = /iPhone|iPod|iPad/i.test(l);
122
- function d(e2) {
123
- if (!e2)
124
- return false;
125
- for (var t2 = e2; null !== Object.getPrototypeOf(t2); )
126
- t2 = Object.getPrototypeOf(t2);
127
- return Object.getPrototypeOf(e2) === t2;
128
- }
129
- var h = function() {
130
- function e2(e3, t2, n2, i2, r2, s2, o2) {
131
- var a2 = this;
132
- void 0 === r2 && (r2 = true), void 0 === s2 && (s2 = false), void 0 === o2 && (o2 = {}), this.instance = e3, this.instanceId = t2, this.url = n2, this.mount = i2, this.isListenResize = r2, this.addedStyles = s2, this.customAttrs = o2, this.handleResize = function() {
133
- var e4 = a2.mount, t3 = a2.mountResizeObserver, n3 = e4.clientHeight, i3 = e4.clientWidth;
134
- 0 !== n3 || 0 !== i3 || t3 ? 0 === n3 && 0 === i3 || !t3 || (t3.disconnect(), t3 = null) : window.ResizeObserver && (t3 = new ResizeObserver(function(e5) {
135
- a2.handleResize();
136
- })).observe(e4), a2.iframe.style.cssText += "height: " + e4.clientHeight + "px; width: " + e4.clientWidth + "px";
137
- }, this.iframe = this.initIframe();
138
- }
139
- return e2.prototype.initIframe = function() {
140
- var e3 = this, t2 = this.mount, n2 = document.createElement("iframe");
141
- n2.classList.add("web-office-iframe");
142
- var i2 = this.mergeAttrs({ id: "office-iframe-" + this.instanceId, src: this.url, scrolling: "no", frameborder: "0", allowfullscreen: "allowfullscreen", webkitallowfullscreen: "true", mozallowfullscreen: "true", allow: "clipboard-read; clipboard-write" });
143
- for (var r2 in t2 ? (i2.style = "width: " + t2.clientWidth + "px; height: " + t2.clientHeight + "px;", this.isListenResize && window.addEventListener("resize", this.handleResize)) : ((t2 = document.createElement("div")).classList.add("web-office-default-container"), this.addedStyles || this.addStylesheetRules(".web-office-default-container {position: absolute; padding: 0; margin: 0; width: 100vw; height: 100vh; left: 0; top: 0;}"), document.body.appendChild(t2), i2.style = "width: 100vw; height: 100vh;"), u && window.visualViewport && this.isListenResize && window.visualViewport.addEventListener("resize", function() {
144
- var t3 = window.visualViewport, n3 = t3.width, i3 = t3.height, r3 = document.body.clientHeight - e3.iframe.clientHeight;
145
- e3.instance.sendMsgToWps({ eventName: "visualViewportResize", data: { width: n3, height: i3 - r3 } });
146
- }), i2)
147
- n2.setAttribute(r2, i2[r2]);
148
- return t2.appendChild(n2), n2.destroy = function() {
149
- window.removeEventListener("resize", e3.handleResize), n2.parentNode.removeChild(n2), n2 = null, e3.mountResizeObserver && (e3.mountResizeObserver.disconnect(), e3.mountResizeObserver = null);
150
- }, n2;
151
- }, e2.prototype.destroy = function() {
152
- this.iframe.parentNode.removeChild(this.iframe), window.removeEventListener("resize", this.handleResize);
153
- }, e2.prototype.addStylesheetRules = function(e3) {
154
- var t2 = document.createElement("style");
155
- document.head.appendChild(t2);
156
- var n2 = t2.sheet;
157
- n2.insertRule(e3, n2.cssRules.length);
158
- }, e2.prototype.mergeAttrs = function(e3) {
159
- var t2 = this.customAttrs;
160
- if (t2 && Object.keys(t2).length && t2.allow) {
161
- var n2 = t2.allow instanceof Array ? t2.allow : t2.allow.split(";");
162
- n2.unshift("clipboard-write"), n2.unshift("clipboard-read"), t2.allow = n2.join(";"), Object.assign(e3, t2);
163
- }
164
- return e3;
165
- }, e2;
166
- }(), f = function() {
167
- function e2() {
168
- this.HANDLE_LIST = [];
169
- }
170
- return e2.prototype.add = function(e3) {
171
- this.HANDLE_LIST.push(e3), window.addEventListener("message", e3, false);
172
- }, e2.prototype.remove = function(e3) {
173
- var t2 = this.HANDLE_LIST.indexOf(e3);
174
- t2 >= 0 && this.HANDLE_LIST.splice(t2, 1), window.removeEventListener("message", e3, false);
175
- }, e2.prototype.empty = function() {
176
- for (; this.HANDLE_LIST.length; ) {
177
- var e3 = this.HANDLE_LIST.shift();
178
- window.removeEventListener("message", e3, false);
179
- }
180
- }, e2.prototype.parse = function(e3) {
181
- try {
182
- return "object" == typeof e3 ? e3 : e3 ? JSON.parse(e3) : e3;
183
- } catch (t2) {
184
- return e3;
185
- }
186
- }, e2;
187
- }(), p = function() {
188
- function e2(e3, t2) {
189
- var n2 = this;
190
- this.collectObjIdHandlers = /* @__PURE__ */ new Set(), this.polyfillApi = ["ExportAsFixedFormat", "GetOperatorsInfo", "ImportDataIntoFields", "ReplaceText", "ReplaceBookmark", "GetBookmarkText", "GetComments"], this.getId = function() {
191
- return "";
192
- }, this.setterCallbacks = { idMap: {} }, this.sendMsgToWps = function() {
193
- }, this.objId = 0, this.origin = "", this.apiChannel = function(e4, t3, i2, r2) {
194
- return a(n2, void 0, void 0, function() {
195
- var n3, s2, o2, l2, u2, d2, h2, f2, p2, m2 = this;
196
- return c(this, function(v2) {
197
- switch (v2.label) {
198
- case 0:
199
- return n3 = this.getId(), l2 = new Promise(function(e5, t4) {
200
- s2 = e5, o2 = t4;
201
- }), u2 = {}, t3.args ? [4, this.reduceArgs(t3.args)] : [3, 2];
202
- case 1:
203
- d2 = v2.sent(), h2 = d2[0], f2 = d2[1], t3.args = h2, u2 = f2, v2.label = 2;
204
- case 2:
205
- return e4 !== this.prefix + "setter" ? [3, 4] : [4, this.handleApiSetter(t3)];
206
- case 3:
207
- v2.sent(), v2.label = 4;
208
- case 4:
209
- return p2 = function() {
210
- var t4 = function(l3) {
211
- return a(m2, void 0, void 0, function() {
212
- var a2, d3, h3;
213
- return c(this, function(c2) {
214
- switch (c2.label) {
215
- case 0:
216
- return this.instance.originWhiteList.includes(l3.origin) || this.origin === l3.origin ? (a2 = this.message.parse(l3.data)).eventName === this.prefix + "callback" && a2.callbackId && u2[a2.callbackId] ? [4, u2[a2.callbackId].apply(u2, a2.data.args)] : [3, 2] : [2];
217
- case 1:
218
- d3 = c2.sent(), this.sendMsgToWps({ result: d3, eventName: this.prefix + "callback.reply", callbackId: a2.callbackId }), c2.label = 2;
219
- case 2:
220
- return a2.eventName === e4 + ".reply" && a2.msgId === n3 && (a2.error ? ((h3 = new Error("")).stack = a2.error + "\n" + i2, r2 && r2(), o2(h3)) : s2(a2.result), this.message.remove(t4)), [2];
221
- }
222
- });
223
- });
224
- };
225
- return m2.message.add(t4), l2;
226
- }, this.handleSendApiChannel([{ eventName: e4, data: t3, msgId: n3 }, p2]), [2, l2];
227
- }
228
- });
229
- });
230
- }, this.handleApiSetter = function(e4) {
231
- return a(n2, void 0, void 0, function() {
232
- var t3, n3, i2, r2, s2, o2, a2, l2, u2, d2, h2 = this;
233
- return c(this, function(c2) {
234
- switch (c2.label) {
235
- case 0:
236
- return t3 = function() {
237
- return Object.keys(h2.setterCallbacks.idMap).find(function(e5) {
238
- return h2.setterCallbacks.idMap[e5] === i2 + ":" + n3;
239
- });
240
- }, n3 = e4.prop, i2 = e4.parentObjId, r2 = e4.value, [4, this.reduceArgs([r2])];
241
- case 1:
242
- return s2 = c2.sent(), o2 = s2[0], a2 = s2[1], e4.value = o2[0], l2 = Object.keys(a2)[0], u2 = this.setterCallbacks[i2], null === r2 && u2 && u2[n3] && ((d2 = t3()) && delete this.setterCallbacks.idMap[d2], delete u2[n3], Object.keys(u2).length || delete this.setterCallbacks[i2], Object.keys(this.setterCallbacks.idMap).length || this.message.remove(this.setterCallbackSubscribe.bind(this))), l2 && (Object.keys(this.setterCallbacks.idMap).length || this.message.add(this.setterCallbackSubscribe.bind(this)), this.setterCallbacks[i2] || (this.setterCallbacks[i2] = {}), this.setterCallbacks[i2][n3] = { callbackId: l2, callback: a2[l2] }, (d2 = t3()) && delete this.setterCallbacks.idMap[d2], this.setterCallbacks.idMap[l2] = i2 + ":" + n3), [2];
243
- }
244
- });
245
- });
246
- }, this.prefix = t2, this.origin = e3.origin, this.sendMsgToWps = e3.sendMsgToWps.bind(e3), this.getId = e3.getId.bind(e3), this.message = e3.message, this.sdkInstanceId = e3.instanceId, this.instance = e3;
247
- }
248
- return e2.prototype.destroyApplication = function() {
249
- this.collectObjIdHandlers = /* @__PURE__ */ new Set(), this.objId = 0;
250
- }, e2.prototype.subEventHandle = function(e3, t2) {
251
- var n2 = this, i2 = {};
252
- this.message.add(function(e4) {
253
- return a(n2, void 0, void 0, function() {
254
- var t3, n3, r3, s3, o2, a2;
255
- return c(this, function(c2) {
256
- switch (c2.label) {
257
- case 0:
258
- return this.instance.originWhiteList.includes(e4.origin) || this.origin === e4.origin ? (t3 = this.message.parse(e4.data), n3 = t3.sdkInstanceId, t3.eventName === this.prefix + "event" && Number(n3) === this.sdkInstanceId && t3.data ? (r3 = t3.data, s3 = r3.eventName, o2 = r3.data, (a2 = i2[s3]) ? [4, a2(o2)] : [3, 2]) : [3, 2]) : [2];
259
- case 1:
260
- c2.sent(), c2.label = 2;
261
- case 2:
262
- return [2];
263
- }
264
- });
265
- });
266
- });
267
- var r2 = function(r3) {
268
- var s3 = t2[r3];
269
- Object.defineProperty(e3, s3, { set: function(e4) {
270
- i2[s3] = e4, n2.sendMsgToWps({ eventName: n2.prefix + "event.register", data: { eventName: s3, register: !!e4, objId: n2.objId += 1 }, sdkInstanceId: n2.sdkInstanceId });
271
- } });
272
- };
273
- for (var s2 in t2)
274
- r2(s2);
275
- }, e2.prototype.mixinProto = function(e3, t2) {
276
- Object.assign(e3, t2);
277
- }, e2.prototype.makeCollectObjIdHandle = function(e3) {
278
- var t2 = this;
279
- return function() {
280
- var n2 = [], i2 = function(e4) {
281
- n2.push(e4);
282
- };
283
- return t2.collectObjIdHandlers.add(i2), { End: function() {
284
- e3(n2), t2.collectObjIdHandlers.delete(i2);
285
- } };
286
- };
287
- }, e2.prototype.assign = function(e3, t2, n2) {
288
- for (var i2 = this, r2 = t2.slice(0), s2 = function() {
289
- var t3 = r2.shift();
290
- !t3.alias && ~a2.polyfillApi.indexOf(t3.prop) && r2.push(o(o({}, t3), { alias: t3.prop + "Async" })), Object.defineProperty(e3, t3.alias || t3.prop, { get: function() {
291
- var r3 = 1 === t3.cache, s3 = r3 && e3["__" + t3.prop + "CacheValue"];
292
- if (!s3) {
293
- var o2 = i2.getError(), a3 = i2.createObjId(r3), c2 = function() {
294
- for (var r4, s4 = [], a4 = 0; a4 < arguments.length; a4++)
295
- s4[a4] = arguments[a4];
296
- return void 0 !== t3.caller ? (r4 = { objId: i2.createObjId() }, i2.assign(r4, n2[t3.caller], n2)) : r4 = {}, i2.wrapper(c2, r4, i2.prefix + "caller", { obj: c2, args: s4, parentObjId: e3.objId, objId: r4.objId, prop: t3.prop }, o2), r4;
297
- };
298
- return c2.objId = -1, void 0 !== t3.getter && (c2.objId = a3, i2.assign(c2, n2[t3.getter], n2)), i2.wrapper(e3, c2, i2.prefix + "getter", { parentObjId: e3.objId, objId: c2.objId, prop: t3.prop }, o2, function() {
299
- delete e3["__" + t3.prop + "CacheValue"];
300
- }), r3 && (e3["__" + t3.prop + "CacheValue"] = c2), c2;
301
- }
302
- return s3;
303
- }, set: function(n3) {
304
- var r3 = i2.getError();
305
- return i2.wrapper(e3, {}, i2.prefix + "setter", { value: n3, parentObjId: e3.objId, objId: -1, prop: t3.prop }, r3);
306
- } });
307
- }, a2 = this; r2.length; )
308
- s2();
309
- }, e2.prototype.wrapper = function(e3, t2, n2, i2, r2, s2) {
310
- var o2, a2 = this, c2 = (e3.done ? e3.done() : Promise.resolve()).then(function() {
311
- return o2 || (o2 = a2.apiChannel(n2, i2, r2, s2)), o2;
312
- });
313
- t2.done = function() {
314
- return c2;
315
- }, t2.then = function(e4, n3) {
316
- return i2.objId >= 0 ? (t2.then = null, t2.catch = null, c2.then(function() {
317
- e4(t2);
318
- }).catch(function(e5) {
319
- return n3(e5);
320
- })) : c2.then(e4, n3);
321
- }, t2.catch = function(e4) {
322
- return c2.catch(e4);
323
- }, t2.Destroy = function() {
324
- return this.apiChannel(this.prefix + "free", { objId: t2.objId }, "");
325
- };
326
- }, e2.prototype.handleSendApiChannel = function(e3) {
327
- var t2 = e3[0], n2 = e3[1];
328
- "function" == typeof (t2 = o({}, t2)).data && (t2.data = t2.data()), n2(), this.sendMsgToWps(t2);
329
- }, e2.prototype.setterCallbackSubscribe = function(e3) {
330
- return a(this, void 0, void 0, function() {
331
- var t2, n2, i2, r2, s2, o2, a2, l2, u2, d2;
332
- return c(this, function(c2) {
333
- switch (c2.label) {
334
- case 0:
335
- return this.instance.originWhiteList.includes(e3.origin) || this.origin === e3.origin ? (t2 = this.message.parse(e3.data), n2 = t2.eventName, i2 = t2.callbackId, r2 = t2.data, i2 && (s2 = this.setterCallbacks.idMap[i2]) ? (o2 = s2.split(":"), a2 = o2[0], l2 = o2[1], n2 === this.prefix + "callback" && this.setterCallbacks[a2] && this.setterCallbacks[a2][l2] ? [4, (d2 = this.setterCallbacks[a2][l2]).callback.apply(d2, r2.args)] : [3, 2]) : [3, 2]) : [2];
336
- case 1:
337
- u2 = c2.sent(), this.sendMsgToWps({ result: u2, callbackId: i2, eventName: this.prefix + "callback.reply" }), c2.label = 2;
338
- case 2:
339
- return [2];
340
- }
341
- });
342
- });
343
- }, e2.prototype.reduceArgs = function(e3) {
344
- return a(this, void 0, void 0, function() {
345
- var t2, n2, i2, r2, s2, o2, a2, l2, u2, h2, f2;
346
- return c(this, function(c2) {
347
- switch (c2.label) {
348
- case 0:
349
- t2 = {}, n2 = [], i2 = e3.slice(0), c2.label = 1;
350
- case 1:
351
- return i2.length ? (r2 = void 0, [4, i2.shift()]) : [3, 13];
352
- case 2:
353
- return (s2 = c2.sent()) && s2.done ? [4, s2.done()] : [3, 4];
354
- case 3:
355
- c2.sent(), c2.label = 4;
356
- case 4:
357
- if (!d(r2))
358
- return [3, 11];
359
- for (a2 in r2 = {}, o2 = [], s2)
360
- o2.push(a2);
361
- l2 = 0, c2.label = 5;
362
- case 5:
363
- return l2 < o2.length ? (u2 = o2[l2], h2 = s2[u2], /^[A-Z]/.test(u2) ? h2 && h2.done ? [4, h2.done()] : [3, 7] : [3, 8]) : [3, 10];
364
- case 6:
365
- c2.sent(), c2.label = 7;
366
- case 7:
367
- h2 && h2.objId ? h2 = { objId: h2.objId } : "function" == typeof h2 && (f2 = this.getId(), t2[f2] = h2, h2 = { callbackId: f2 }), c2.label = 8;
368
- case 8:
369
- r2[u2] = h2, c2.label = 9;
370
- case 9:
371
- return l2++, [3, 5];
372
- case 10:
373
- return [3, 12];
374
- case 11:
375
- s2 && s2.objId ? r2 = { objId: s2.objId } : "function" == typeof s2 && void 0 === s2.objId ? (f2 = this.getId(), t2[f2] = s2, r2 = { callbackId: f2 }) : r2 = s2, c2.label = 12;
376
- case 12:
377
- return n2.push(r2), [3, 1];
378
- case 13:
379
- return [2, [n2, t2]];
380
- }
381
- });
382
- });
383
- }, e2.prototype.createObjId = function(e3) {
384
- return this.objId += 1, !e3 && this.collectObjId(), this.objId;
385
- }, e2.prototype.collectObjId = function() {
386
- var e3 = this;
387
- this.collectObjIdHandlers.forEach(function(t2) {
388
- return t2(e3.objId);
389
- });
390
- }, e2.prototype.getError = function() {
391
- var e3 = new Error("");
392
- return (e3.stack || e3.message || "").split("\n").slice(2).join("\n");
393
- }, e2;
394
- }(), m = function(e2) {
395
- function n2(t2, n3, r2) {
396
- var s2 = e2.call(this, t2, r2) || this, o2 = {}, a2 = t2.officeType, c2 = n3.Events, l2 = n3.Enum, u2 = n3.Props, d2 = u2[0], h2 = u2[1], f2 = { objId: s2.objId };
397
- switch (s2.assign(f2, d2, h2), f2.Events = c2, f2.Enum = l2, f2.Sub = {}, o2.Enum = f2.Enum, o2.Events = f2.Events, o2.Props = u2, a2) {
398
- case i.writer:
399
- o2.WordApplication = t2.WpsApplication = function() {
400
- return f2;
401
- };
402
- break;
403
- case i.spreadsheet:
404
- o2.ExcelApplication = t2.EtApplication = function() {
405
- return f2;
406
- };
407
- break;
408
- case i.presentation:
409
- o2.PPTApplication = t2.WppApplication = function() {
410
- return f2;
411
- };
412
- break;
413
- case i.pdf:
414
- o2.PDFApplication = function() {
415
- return f2;
416
- };
417
- }
418
- return o2.Application = f2, o2.Free = function(e3) {
419
- return s2.apiChannel(s2.prefix + "free", { objId: e3 }, "");
420
- }, o2.Stack = f2.Stack = s2.makeCollectObjIdHandle(function(e3) {
421
- s2.apiChannel(s2.prefix + "free", { objId: e3 }, "");
422
- }), o2.destroyApplication = function() {
423
- s2.destroyApplication();
424
- }, s2.subEventHandle(f2.Sub, c2), s2.mixinProto(t2, o2), s2;
425
- }
426
- return t(n2, e2), n2;
427
- }(p), v = function(e2) {
428
- function n2(t2, n3, i2) {
429
- var r2 = e2.call(this, t2, i2) || this, s2 = {}, o2 = n3.Events, a2 = n3.Enum, c2 = n3.Props, l2 = c2[0], u2 = c2[1], d2 = { objId: r2.objId };
430
- return r2.assign(d2, l2, u2), d2.Events = o2, d2.Enum = a2, d2.Sub = {}, s2.CommonEnum = d2.Enum, s2.CommonEvents = d2.Events, s2.CommonProps = c2, s2.CommonApi = d2, s2.CommonFree = function(e3) {
431
- return r2.apiChannel(r2.prefix + "free", { objId: e3 }, "");
432
- }, s2.CommonStack = d2.Stack = r2.makeCollectObjIdHandle(function(e3) {
433
- r2.apiChannel(r2.prefix + "free", { objId: e3 }, "");
434
- }), s2.destroyCommonApp = function() {
435
- r2.destroyApplication();
436
- }, r2.subEventHandle(d2.Sub, o2), r2.mixinProto(t2, s2), r2;
437
- }
438
- return t(n2, e2), n2;
439
- }(p);
440
- var b = function() {
441
- function e2(t2) {
442
- var n2, i2 = this;
443
- this.id = 0, this.origin = "", this.originWhiteList = [], this.realOrigin = "", this.iframeWH = null, this.cbConfigsSub = {}, this.readyEventNames = [{ event: "ready", callback: function() {
444
- i2.handleBaseReady();
445
- }, after: true }, { event: "open.result" }, { event: "api.ready", callback: function() {
446
- for (var e3 = [], t3 = 0; t3 < arguments.length; t3++)
447
- e3[t3] = arguments[t3];
448
- var n3 = e3[0];
449
- return new m(i2, n3, "api."), i2.Application;
450
- } }, { event: "commonApi.ready", callback: function() {
451
- for (var e3 = [], t3 = 0; t3 < arguments.length; t3++)
452
- e3[t3] = arguments[t3];
453
- var n3 = e3[0];
454
- return new v(i2, n3, "commonApi."), i2.CommonApi;
455
- } }], this.cbConfigs = ["refreshToken"], this.onEventNames = { "open.result": "fileOpen", "tab.switch": "tabSwitch", "file.saved": "fileStatus", error: "error", stage: "stage" }, this.polyfillConfigName = [["wpsOptions", "wordOptions"], ["etOptions", "excelOptions"], ["wppOptions", "pptOptions"]], this.flag = { advancedApiReadySended: false, advancedApiReadySendedJust: false, commonApiReadySended: false, commonApiReadySendedJust: false }, this.baseReadyPromise = Promise.resolve(), this.fileOpenPromise = Promise.resolve(), this.advancedReadyPromise = Promise.resolve(), this.commonApiPromise = Promise.resolve(), this.iframeInstance = null, this.officeType = "", this.url = "", this.version = "2.0.7", this.iframeReady = false, this.forceIframeResize = function() {
456
- i2.iframeInstance && i2.iframeInstance.handleResize();
457
- }, this.isOtherEvent = function(e3) {
458
- return void 0 !== e3 && e3 !== i2.instanceId;
459
- }, this.handleBaseReady = function() {
460
- i2.sendMsgToWps({ eventName: "setConfig", data: o(o({}, i2.sdkConfig), { version: i2.version }) }), i2.tokenData && i2.setToken(o(o({}, i2.tokenData), { hasRefreshTokenConfig: !!i2.sdkConfig.refreshToken })), i2.flag.advancedApiReadySended && i2.sendMsgToWps({ eventName: "api.ready" }), i2.flag.commonApiReadySended && i2.sendMsgToWps({ eventName: "commonApi.ready" }), i2.iframeReady = true;
461
- }, this.handleFullscreenChange = function() {
462
- var e3 = { status: s.requestFullscreen };
463
- document.fullscreenElement ? e3.status = s.requestFullscreen : e3.status = s.exitFullscreen, i2.sendMsgToWps({ data: e3, eventName: "fullscreenchange" });
464
- }, this.instanceId = e2.instanceId, e2.instanceId += 1, this.message = new f(), this.mittInstance = (n2 = n2 || /* @__PURE__ */ Object.create(null), { on: function(e3, t3) {
465
- (n2[e3] || (n2[e3] = [])).push(t3);
466
- }, off: function(e3, t3) {
467
- n2[e3] && n2[e3].splice(n2[e3].indexOf(t3) >>> 0, 1);
468
- }, emit: function(e3, t3) {
469
- (n2[e3] || []).slice().map(function(e4) {
470
- e4(t3);
471
- }), (n2["*"] || []).slice().map(function(n3) {
472
- n3(e3, t3);
473
- });
474
- } }), this.handleConfig(t2);
475
- }
476
- return e2.config = function(t2) {
477
- return void 0 === t2 && (t2 = {}), e2.singleInstance || (e2.singleInstance = new e2(t2)), e2.singleInstance;
478
- }, e2.prototype.setToken = function(e3) {
479
- return a(this, void 0, void 0, function() {
480
- return c(this, function(t2) {
481
- switch (t2.label) {
482
- case 0:
483
- return [4, this.basicReady()];
484
- case 1:
485
- return t2.sent(), this.tokenData = e3, this.sendMsgToWps({ eventName: "setToken", data: e3 }), [2];
486
- }
487
- });
488
- });
489
- }, e2.prototype.advancedApiReady = function() {
490
- return a(this, void 0, void 0, function() {
491
- return c(this, function(e3) {
492
- switch (e3.label) {
493
- case 0:
494
- return this.flag.advancedApiReadySendedJust ? [3, 2] : (this.flag.advancedApiReadySendedJust = true, [4, this.fileOpenPromise]);
495
- case 1:
496
- e3.sent(), this.flag.advancedApiReadySended || (this.flag.advancedApiReadySended = true, this.sendMsgToWps({ eventName: "api.ready" })), e3.label = 2;
497
- case 2:
498
- return [4, this.advancedReadyPromise];
499
- case 3:
500
- return [2, e3.sent()];
501
- }
502
- });
503
- });
504
- }, e2.prototype.commonApiReady = function() {
505
- return a(this, void 0, void 0, function() {
506
- return c(this, function(e3) {
507
- switch (e3.label) {
508
- case 0:
509
- return this.flag.commonApiReadySendedJust ? [3, 2] : (this.flag.commonApiReadySendedJust = true, [4, this.basicReady()]);
510
- case 1:
511
- e3.sent(), this.flag.commonApiReadySended || (this.flag.commonApiReadySended = true, this.sendMsgToWps({ eventName: "commonApi.ready" })), e3.label = 2;
512
- case 2:
513
- return [4, this.commonApiPromise];
514
- case 3:
515
- return [2, e3.sent()];
516
- }
517
- });
518
- });
519
- }, e2.prototype.destroy = function() {
520
- this.iframeInstance.destroy(), this.message.empty(), this.destroyApplication && this.destroyApplication(), this.destroyCommonApp && this.destroyCommonApp(), this.removeFullscreenEventListener();
521
- }, e2.prototype.on = function(e3, t2) {
522
- return a(this, void 0, void 0, function() {
523
- var n2;
524
- return c(this, function(i2) {
525
- switch (i2.label) {
526
- case 0:
527
- return [4, this.basicReady()];
528
- case 1:
529
- return i2.sent(), n2 = e3, "fullscreenChange" === e3 && (n2 = "fullscreenchange"), this.handleBasicEvent(n2, "on"), this.mittInstance.on(e3, t2), [2];
530
- }
531
- });
532
- });
533
- }, e2.prototype.off = function(e3, t2) {
534
- return a(this, void 0, void 0, function() {
535
- return c(this, function(n2) {
536
- switch (n2.label) {
537
- case 0:
538
- return [4, this.basicReady()];
539
- case 1:
540
- return n2.sent(), this.handleBasicEvent(e3, "off"), this.mittInstance.off(e3, t2), [2];
541
- }
542
- });
543
- });
544
- }, e2.prototype.handleConfig = function(e3) {
545
- var t2, n2 = this;
546
- void 0 === e3 && (e3 = {});
547
- try {
548
- var i2 = this.userConfHandler(e3), r2 = i2.subscriptions, s2 = void 0 === r2 ? {} : r2, o2 = i2.mount, a2 = void 0 === o2 ? null : o2, c2 = i2.url, l2 = i2.originWhiteList;
549
- this.origin = (c2.match(/https*:\/\/[^\/]+/g) || [])[0], this.originWhiteList = l2 || [];
550
- var u2 = this.readyEventNames.map(function(e4) {
551
- return n2.makeReady(e4);
552
- }), d2 = u2[0], f2 = u2[1], p2 = u2[2], m2 = u2[3];
553
- this.baseReadyPromise = d2, this.fileOpenPromise = f2, this.advancedReadyPromise = p2, this.commonApiPromise = m2, this.iframeWH = a2 ? { width: a2.clientWidth + "px", height: a2.clientHeight + "px" } : { width: "100vw", height: "100vh" }, delete i2.mount, c2 && delete i2.url, this.url = c2, delete i2.subscriptions, this.sdkConfig = i2, this.iframeInstance = new h(this, this.instanceId, c2, a2, null === (t2 = i2.isListenResize) || void 0 === t2 || t2, false, { allow: i2.attrAllow }), this.iframe = this.iframeInstance.iframe, this.listener(s2);
554
- } catch (e4) {
555
- return console.error(e4), null;
556
- }
557
- }, e2.prototype.listener = function(e3) {
558
- var t2 = this;
559
- this.message.add(function(n2) {
560
- return a(t2, void 0, void 0, function() {
561
- var t3, i2, r2, s2, o2, a2, l2, u2, d2;
562
- return c(this, function(c2) {
563
- return t3 = this.message.parse(n2.data), i2 = t3.eventName, r2 = void 0 === i2 ? "" : i2, s2 = t3.data, o2 = void 0 === s2 ? null : s2, a2 = t3.url, l2 = void 0 === a2 ? null : a2, u2 = t3.sdkInstanceId, this.isOtherEvent(u2) ? [2] : -1 !== ["wps.jssdk.api"].indexOf(r2) ? [2] : ((d2 = this.handleListenEvent(r2, o2)) ? d2() : Object.keys(this.onEventNames).includes(r2) && ("open.result" === r2 && (this.officeType = o2.fileInfo.officeType), this.mittInstance.emit(this.onEventNames[r2], o2)), "function" == typeof e3[r2] && e3[r2](this, l2 || o2), [2]);
564
- });
565
- });
566
- });
567
- }, e2.prototype.handleListenEvent = function(e3, t2) {
568
- var i2, r2 = this;
569
- return ((i2 = { "api.scroll": function() {
570
- return window.scrollTo(t2.x, t2.y);
571
- }, "event.callback": function() {
572
- return a(r2, void 0, void 0, function() {
573
- var e4, n2, i3, r3, s2, o2, a2;
574
- return c(this, function(c2) {
575
- return e4 = t2.eventName, n2 = t2.data, i3 = e4, "fullScreenChange" === e4 && (i3 = "fullscreenChange"), ((null === (o2 = this.sdkConfig.commonOptions) || void 0 === o2 ? void 0 : o2.isBrowserViewFullscreen) || (null === (a2 = this.sdkConfig.commonOptions) || void 0 === a2 ? void 0 : a2.isParentFullscreen)) && "fullscreenchange" === i3 && (r3 = n2.status, s2 = n2.isDispatchEvent, this.sdkConfig.commonOptions.isBrowserViewFullscreen ? this.iframeWH && function(e5, t3, n3, i4) {
576
- 0 === e5 ? t3.style = "position: static; width: " + n3.width + "; height: " + n3.height : 1 === e5 && (t3.style = "position: absolute; width: 100%; height: 100%"), i4 && function(e6) {
577
- ["fullscreen", "fullscreenElement"].forEach(function(t5) {
578
- Object.defineProperty(document, t5, { get: function() {
579
- return !!e6.status;
580
- }, configurable: true });
581
- });
582
- var t4 = new CustomEvent("fullscreenchange");
583
- document.dispatchEvent(t4);
584
- }({ status: e5 });
585
- }(r3, this.iframe, this.iframeWH, s2) : this.sdkConfig.commonOptions.isParentFullscreen && function(e5, t3) {
586
- if (0 === e5) {
587
- var n3 = document, i4 = n3.exitFullscreen || n3.mozCancelFullScreen || n3.msExitFullscreen || n3.webkitCancelFullScreen || n3.webkitExitFullscreen;
588
- i4.call(document);
589
- } else if (1 === e5) {
590
- var r4 = t3.requestFullscreen || t3.mozRequestFullScreen || t3.msRequestFullscreen || t3.webkitRequestFullscreen;
591
- r4.call(t3);
592
- }
593
- }(r3, this.iframe)), this.mittInstance.emit(i3, n2), [2];
594
- });
595
- });
596
- } })[n.refreshToken] = function() {
597
- return a(r2, void 0, void 0, function() {
598
- var t3, n2;
599
- return c(this, function(i3) {
600
- switch (i3.label) {
601
- case 0:
602
- t3 = { token: false }, i3.label = 1;
603
- case 1:
604
- return i3.trys.push([1, 3, , 4]), [4, this.cbConfigsSub.refreshToken()];
605
- case 2:
606
- return t3 = i3.sent(), [3, 4];
607
- case 3:
608
- return n2 = i3.sent(), console.error("refreshToken: " + (n2 || "fail to get")), [3, 4];
609
- case 4:
610
- return this.sendMsgToWps({ eventName: e3 + ".reply", data: t3 }), [2];
611
- }
612
- });
613
- });
614
- }, i2)[e3];
615
- }, e2.prototype.basicReady = function() {
616
- return this.baseReadyPromise;
617
- }, e2.prototype.userConfHandler = function(e3, t2) {
618
- var i2 = this;
619
- void 0 === t2 && (t2 = true);
620
- var s2 = o({}, e3), a2 = s2.headers, c2 = void 0 === a2 ? {} : a2, l2 = s2.subscriptions, u2 = void 0 === l2 ? {} : l2, d2 = s2.commonOptions, h2 = s2.url, f2 = void 0 === h2 ? "" : h2, p2 = s2.wpsUrl, m2 = void 0 === p2 ? "" : p2, v2 = s2.mode, b2 = void 0 === v2 ? r.nomal : v2, g2 = s2.debug, y2 = s2.disablePlugins, w2 = s2.hideGuide, k2 = s2.readOnly;
621
- return Object.assign(s2, this.handleHeadersAndSubscriptionsConfig(c2, u2, t2)), s2.url = this.handleUrlConfig(d2, b2, g2, f2, m2, y2, w2, k2), d2 && (d2.isParentFullscreen || d2.isBrowserViewFullscreen) && document.addEventListener("fullscreenchange", this.handleFullscreenChange), this.polyfillConfigName.map(function(e4) {
622
- var t3 = e4[0], n2 = e4[1];
623
- s2[n2] && (s2[t3] = s2[n2]);
624
- }), this.cbConfigs.map(function(e4) {
625
- var t3, r2, o2 = s2[e4];
626
- o2 && (t3 = o2, r2 = "Function", {}.toString.call(t3) === "[object " + r2 + "]") && (i2.cbConfigsSub[e4] = o2, s2[e4] = { eventName: n[e4] });
627
- }), s2.commandBars && this.handleCommandBarsConfig(s2.commandBars, false), o({}, s2);
628
- }, e2.prototype.handleBasicEvent = function(e3, t2) {
629
- if (!["error", "fileOpen"].includes(e3)) {
630
- var n2 = { eventName: "basic.event", data: { eventName: e3, action: t2 } };
631
- this.sendMsgToWps(n2);
632
- }
633
- }, e2.prototype.removeFullscreenEventListener = function() {
634
- document.removeEventListener("fullscreenchange", this.handleFullscreenChange);
635
- }, e2.prototype.handleHeadersAndSubscriptionsConfig = function(e3, t2, n2) {
636
- var i2 = e3.backBtn, r2 = void 0 === i2 ? {} : i2, s2 = e3.shareBtn, o2 = void 0 === s2 ? {} : s2, a2 = e3.otherMenuBtn, c2 = void 0 === a2 ? {} : a2, l2 = [["wpsconfig_back_btn", r2], ["wpsconfig_share_btn", o2], ["wpsconfig_other_menu_btn", c2]], u2 = [];
637
- return c2.items && Array.isArray(c2.items) && c2.items.forEach(function(e4, t3) {
638
- void 0 === e4 && (e4 = {}), "custom" === e4.type && u2.push(["wpsconfig_other_menu_btn_" + t3, e4]);
639
- }), l2.concat(u2).forEach(function(e4) {
640
- var i3, r3;
641
- i3 = e4[1], r3 = e4[0], i3.subscribe && "function" == typeof i3.subscribe && (i3.callback = r3, t2[r3] = i3.subscribe, n2 && delete i3.subscribe);
642
- }), {};
643
- }, e2.prototype.handleUrlConfig = function(e3, t2, n2, i2, s2, o2, a2, c2) {
644
- var l2 = [];
645
- l2.push("sdkId=" + this.instanceId), t2 === r.simple || e3 && false === e3.isShowTopArea ? l2.push("simple", "hidecmb") : t2 === r.embed && l2.push("simple=1", "hidecmb=1", "embed=1"), o2 && l2.push("disablePlugins"), a2 && l2.push("hideguide"), c2 && l2.push("readonly"), n2 && l2.push("debugger");
646
- var u2 = i2 || s2;
647
- return u2 && l2.length && (u2 = u2 + (u2.indexOf("?") >= 0 ? "&" : "?") + l2.join("&")), u2;
648
- }, e2.prototype.handleCommandBarsConfig = function(e3, t2) {
649
- void 0 === t2 && (t2 = true);
650
- var n2 = e3.map(function(e4) {
651
- var t3 = e4.attributes;
652
- if (!Array.isArray(t3)) {
653
- var n3 = [];
654
- for (var i2 in t3)
655
- if (t3.hasOwnProperty(i2)) {
656
- var r2 = { name: i2, value: t3[i2] };
657
- n3.push(r2);
658
- }
659
- e4.attributes = n3;
660
- }
661
- return e4;
662
- });
663
- return t2 && this.sendMsgToWps({ data: n2, eventName: "setCommandBars" }), n2;
664
- }, e2.prototype.sendMsgToWps = function(e3) {
665
- var t2, n2, i2 = o(o({}, e3), { sdkInstanceId: this.instanceId });
666
- null === (n2 = null === (t2 = this.iframe) || void 0 === t2 ? void 0 : t2.contentWindow) || void 0 === n2 || n2.postMessage(JSON.stringify(i2), this.realOrigin);
667
- }, e2.prototype.makeReady = function(e3) {
668
- var t2 = this, n2 = e3.event, i2 = e3.callback, r2 = e3.after;
669
- return new Promise(function(e4) {
670
- var s2 = function(o2) {
671
- if (t2.realOrigin = o2.origin, t2.originWhiteList.includes(o2.origin) || t2.origin === o2.origin) {
672
- var a2 = t2.message.parse(o2.data), c2 = a2.eventName, l2 = a2.data, u2 = a2.sdkInstanceId;
673
- if (!t2.isOtherEvent(u2) && c2 === n2) {
674
- var d2 = void 0;
675
- !r2 && i2 && (d2 = i2(l2)), e4(d2), r2 && i2 && i2(l2), "ready" !== n2 && t2.message.remove(s2);
676
- }
677
- }
678
- };
679
- t2.message.add(s2);
680
- });
681
- }, e2.prototype.getId = function() {
682
- return this.id += 1, this.instanceId + "-" + this.id;
683
- }, e2.instanceId = 1, e2;
684
- }(), g = { executeCommandBar: "ExecuteCommandBar", off: "Off", save: "Save", setCommandBars: "SetCommandBars", setCooperUserColor: "SetCooperUserColor", tabs: "Tabs", Stack: "Stack", WhenStacksEmpty: "WhenStacksEmpty" };
685
- function y(e2, t2) {
686
- var n2 = this;
687
- return void 0 === t2 && (t2 = {}), new Proxy(e2, o(o({}, { get: function(e3, t3) {
688
- if (Object.keys(g).includes(t3)) {
689
- var i2 = g[t3];
690
- return "Tabs" === i2 ? function(e4) {
691
- var t4 = this;
692
- return { switchTab: function(n3) {
693
- return a(t4, void 0, void 0, function() {
694
- return c(this, function(t5) {
695
- switch (t5.label) {
696
- case 0:
697
- return [4, e4.commonApiReady()];
698
- case 1:
699
- return t5.sent(), [4, e4.CommonApi.Tabs.SwitchTab(n3.tabKey)];
700
- case 2:
701
- return [2, t5.sent()];
702
- }
703
- });
704
- });
705
- }, getTabs: function() {
706
- return a(t4, void 0, void 0, function() {
707
- return c(this, function(t5) {
708
- switch (t5.label) {
709
- case 0:
710
- return [4, e4.commonApiReady()];
711
- case 1:
712
- return t5.sent(), [4, e4.CommonApi.Tabs.GetTabs()];
713
- case 2:
714
- return [2, t5.sent()];
715
- }
716
- });
717
- });
718
- } };
719
- }(e3) : e3.CommonApi ? Reflect.get(e3.CommonApi, i2) : function() {
720
- return a(n2, void 0, void 0, function() {
721
- var t4;
722
- return c(this, function(n3) {
723
- switch (n3.label) {
724
- case 0:
725
- return [4, e3.commonApiReady()];
726
- case 1:
727
- return n3.sent(), [4, e3.commonApiPromise];
728
- case 2:
729
- return n3.sent(), "function" != typeof e3.CommonApi[i2] ? [3, 4] : [4, e3.CommonApi[i2]()];
730
- case 3:
731
- return t4 = n3.sent(), [3, 5];
732
- case 4:
733
- t4 = e3.CommonApi[i2], n3.label = 5;
734
- case 5:
735
- return [2, t4];
736
- }
737
- });
738
- });
739
- };
740
- }
741
- return Reflect.get(e3, t3);
742
- }, set: function(e3, t3, n3) {
743
- return !!Reflect.has(e3, t3) && Reflect.set(e3, t3, n3);
744
- } }), t2));
745
- }
746
- var w;
747
- !function(e2) {
748
- e2.Spreadsheet = "s", e2.Writer = "w", e2.Presentation = "p", e2.Pdf = "f", e2.Otl = "o", e2.Dbt = "d", e2.KSheet = "k";
749
- }(w || (w = {}));
750
- var k = function(e2) {
751
- function n2(t2) {
752
- var n3 = e2.call(this, t2) || this;
753
- return t2.token && (d(t2.token) ? n3.setToken(o({}, t2.token)) : n3.setToken({ token: t2.token })), n3.ApiEvent = { AddApiEventListener: function(e3, t3) {
754
- n3.on(e3, t3);
755
- }, RemoveApiEventListener: function(e3, t3) {
756
- n3.off(e3, t3);
757
- } }, n3;
758
- }
759
- return t(n2, e2), n2.init = function(e3) {
760
- var t2 = o({}, e3);
761
- if (t2.endpoint = t2.endpoint || "https://o.wpsgo.com", "string" == typeof t2.mount) {
762
- var i2 = document.querySelector(t2.mount);
763
- i2 ? t2.mount = i2 : (console.warn("[WebOfficeSDK.init] mount挂载节点未找到"), delete t2.mount);
764
- }
765
- if (t2.url)
766
- throw Error("[WebOfficeSDK.init] 不支持传递url,请使用appId、fileId、officeType、token等参数初始化!");
767
- if (!t2.appId || !t2.fileId || !t2.officeType)
768
- throw Error("[WebOfficeSDK.init] appId、fileId、officeType为必选项!");
769
- if ("string" != typeof t2.endpoint)
770
- throw Error("[WebOfficeSDK.init] endpoint期望为字符串");
771
- if (t2.endpoint && !t2.endpoint.startsWith("http"))
772
- throw Error("[WebOfficeSDK.init] endpoint仅支持http、https的地址");
773
- var r2 = new n2(function(e4) {
774
- var t3 = o({}, e4);
775
- t3.token = t3.token || t3.fileToken;
776
- var n3 = t3.appId, i3 = t3.fileId, r3 = t3.officeType, s2 = t3.token, a2 = t3.endpoint, c2 = t3.customArgs, l2 = void 0 === c2 ? "" : c2;
777
- if (!Object.values(w).includes(r3))
778
- throw Error("[WebOfficeSDK.init] officeType属性值错误,可选值参考WebOfficeSDK.OfficeType: " + JSON.stringify(w));
779
- var u2 = s2 ? 1 : 0, h2 = { token: "" };
780
- if ("string" == typeof s2 ? h2.token = s2 : d(s2) && (h2 = o({ tokenData: h2 }, s2)), u2 && !h2.token)
781
- return console.error("[WebOfficeSDK.init] token设置无效"), t3;
782
- if (t3.url = a2 + "/office/" + r3 + "/" + i3 + "?_w_appid=" + n3 + "&_w_tokentype=" + u2, d(l2)) {
783
- var f2 = Object.entries(l2).map(function(e5) {
784
- var t4 = e5[0], n4 = e5[1];
785
- return t4 + "=" + encodeURIComponent(n4);
786
- }).join("&");
787
- t3.url = t3.url + "&" + f2;
788
- }
789
- return o({}, t3);
790
- }(t2));
791
- return function(e4, t3) {
792
- a(this, void 0, void 0, function() {
793
- var n3, i3, r3, s2;
794
- return c(this, function(o2) {
795
- switch (o2.label) {
796
- case 0:
797
- return [4, e4.commonApiReady()];
798
- case 1:
799
- for (i3 in o2.sent(), n3 = [], t3)
800
- n3.push(i3);
801
- r3 = 0, o2.label = 2;
802
- case 2:
803
- if (!(r3 < n3.length))
804
- return [3, 11];
805
- switch (s2 = n3[r3]) {
806
- case "onHyperLinkOpen":
807
- return [3, 3];
808
- case "onToast":
809
- return [3, 5];
810
- case "getClipboardData":
811
- return [3, 7];
812
- }
813
- return [3, 9];
814
- case 3:
815
- return [4, e4.CommonApi.Hooks.Add("hyperLink")];
816
- case 4:
817
- return o2.sent().OnAction = t3[s2], [3, 10];
818
- case 5:
819
- return [4, e4.CommonApi.Hooks.Add("toast")];
820
- case 6:
821
- return o2.sent().OnAction = t3[s2], [3, 10];
822
- case 7:
823
- return [4, e4.CommonApi.Hooks.Add("getClipboardData")];
824
- case 8:
825
- return o2.sent().OnAction = t3[s2], [3, 10];
826
- case 9:
827
- return [3, 10];
828
- case 10:
829
- return r3++, [3, 2];
830
- case 11:
831
- return [2];
832
- }
833
- });
834
- });
835
- }(r2, e3), y(r2);
836
- }, Object.defineProperty(n2, "version", { get: function() {
837
- return "2.0.7";
838
- }, enumerable: false, configurable: true }), n2.prototype.ready = function() {
839
- return a(this, void 0, void 0, function() {
840
- return c(this, function(e3) {
841
- switch (e3.label) {
842
- case 0:
843
- return [4, this.advancedApiReady()];
844
- case 1:
845
- return [2, e3.sent()];
846
- }
847
- });
848
- });
849
- }, n2.OfficeType = Object.freeze({ Spreadsheet: "s", Writer: "w", Presentation: "p", Pdf: "f", Otl: "o", KSheet: "k", Dbt: "d" }), n2;
850
- }(b);
851
- window.WPS = k;
852
- export {
853
- k as default
854
- };