@rhc-office/sdk 6.6.363 → 6.6.367
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/dist/api/digital-sign-environment.d.ts +6 -0
- package/dist/api/digital-sign-environment.d.ts.map +1 -1
- package/dist/browser/document-viewer.js +1 -1
- package/dist/browser/document-viewer.js.map +1 -1
- package/dist/browser.d.ts +4 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/index.js +149 -138
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/api/digital-sign-environment.ts +56 -20
- package/src/browser.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
1
|
+
var Y = /* @__PURE__ */ ((t) => (t.DEFAULT = "default", t.COMPACT = "compact", t.HIDE = "none", t))(Y || {});
|
|
2
|
+
const U = "RIGHT_CENTER", N = "REGULAR_ESM", B = "auto", k = "__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__", E = {
|
|
3
3
|
defaults: {
|
|
4
4
|
bjca: {
|
|
5
5
|
pin: ""
|
|
6
6
|
},
|
|
7
7
|
deviceType: "client",
|
|
8
|
-
edgePosition:
|
|
8
|
+
edgePosition: U,
|
|
9
9
|
kol: {
|
|
10
10
|
appId: "",
|
|
11
11
|
appName: "",
|
|
@@ -17,8 +17,8 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
17
17
|
pin: "",
|
|
18
18
|
usbKeyType: 14
|
|
19
19
|
},
|
|
20
|
-
rsaMode:
|
|
21
|
-
signatureType:
|
|
20
|
+
rsaMode: B,
|
|
21
|
+
signatureType: N
|
|
22
22
|
},
|
|
23
23
|
signServer: {
|
|
24
24
|
authSource: "Password",
|
|
@@ -38,7 +38,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
38
38
|
usbKeyType: 14
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
},
|
|
41
|
+
}, x = (t) => ({
|
|
42
42
|
bjca: {
|
|
43
43
|
pin: t.bjca.pin
|
|
44
44
|
},
|
|
@@ -57,7 +57,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
57
57
|
},
|
|
58
58
|
rsaMode: t.rsaMode,
|
|
59
59
|
signatureType: t.signatureType
|
|
60
|
-
}),
|
|
60
|
+
}), K = (t) => ({
|
|
61
61
|
authSource: t.authSource,
|
|
62
62
|
defaultLogin: t.defaultLogin,
|
|
63
63
|
defaultPassword: t.defaultPassword,
|
|
@@ -74,10 +74,10 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
74
74
|
checkCertificateBinding: t.usbKey.checkCertificateBinding,
|
|
75
75
|
usbKeyType: t.usbKey.usbKeyType
|
|
76
76
|
}
|
|
77
|
-
}),
|
|
78
|
-
defaults:
|
|
79
|
-
signServer:
|
|
80
|
-
}),
|
|
77
|
+
}), g = (t) => ({
|
|
78
|
+
defaults: x(t.defaults),
|
|
79
|
+
signServer: K(t.signServer)
|
|
80
|
+
}), y = (t) => ({
|
|
81
81
|
defaults: t.defaults ? {
|
|
82
82
|
...t.defaults,
|
|
83
83
|
bjca: t.defaults.bjca ? { ...t.defaults.bjca } : void 0,
|
|
@@ -89,7 +89,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
89
89
|
kol: t.signServer.kol ? { ...t.signServer.kol } : void 0,
|
|
90
90
|
usbKey: t.signServer.usbKey ? { ...t.signServer.usbKey } : void 0
|
|
91
91
|
} : void 0
|
|
92
|
-
}),
|
|
92
|
+
}), W = (t, n) => n ? {
|
|
93
93
|
bjca: {
|
|
94
94
|
pin: n.bjca?.pin ?? t.bjca.pin
|
|
95
95
|
},
|
|
@@ -108,7 +108,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
108
108
|
},
|
|
109
109
|
rsaMode: n.rsaMode ?? t.rsaMode,
|
|
110
110
|
signatureType: n.signatureType ?? t.signatureType
|
|
111
|
-
} :
|
|
111
|
+
} : x(t), $ = (t, n) => n ? {
|
|
112
112
|
authSource: n.authSource ?? t.authSource,
|
|
113
113
|
defaultLogin: n.defaultLogin ?? t.defaultLogin,
|
|
114
114
|
defaultPassword: n.defaultPassword ?? t.defaultPassword,
|
|
@@ -125,62 +125,72 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
125
125
|
checkCertificateBinding: n.usbKey?.checkCertificateBinding ?? t.usbKey.checkCertificateBinding,
|
|
126
126
|
usbKeyType: n.usbKey?.usbKeyType ?? t.usbKey.usbKeyType
|
|
127
127
|
}
|
|
128
|
-
} :
|
|
129
|
-
defaults:
|
|
130
|
-
signServer:
|
|
131
|
-
}), X = (t, n) =>
|
|
132
|
-
|
|
133
|
-
...t.defaults,
|
|
134
|
-
...n.defaults
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
} : void 0
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
...
|
|
153
|
-
...
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
...
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
128
|
+
} : K(t), V = (t, n) => ({
|
|
129
|
+
defaults: W(t.defaults, n.defaults),
|
|
130
|
+
signServer: $(t.signServer, n.signServer)
|
|
131
|
+
}), X = (t, n) => {
|
|
132
|
+
const e = t.defaults?.bjca || n.defaults?.bjca ? {
|
|
133
|
+
...t.defaults?.bjca,
|
|
134
|
+
...n.defaults?.bjca
|
|
135
|
+
} : void 0, i = t.defaults?.kol || n.defaults?.kol ? {
|
|
136
|
+
...t.defaults?.kol,
|
|
137
|
+
...n.defaults?.kol
|
|
138
|
+
} : void 0, r = t.defaults?.plugin || n.defaults?.plugin ? {
|
|
139
|
+
...t.defaults?.plugin,
|
|
140
|
+
...n.defaults?.plugin
|
|
141
|
+
} : void 0, a = t.signServer?.kol || n.signServer?.kol ? {
|
|
142
|
+
...t.signServer?.kol,
|
|
143
|
+
...n.signServer?.kol
|
|
144
|
+
} : void 0, s = t.signServer?.usbKey || n.signServer?.usbKey ? {
|
|
145
|
+
...t.signServer?.usbKey,
|
|
146
|
+
...n.signServer?.usbKey
|
|
147
|
+
} : void 0;
|
|
148
|
+
return {
|
|
149
|
+
defaults: t.defaults || n.defaults ? {
|
|
150
|
+
...t.defaults,
|
|
151
|
+
...n.defaults,
|
|
152
|
+
...e ? { bjca: e } : {},
|
|
153
|
+
...i ? { kol: i } : {},
|
|
154
|
+
...r ? { plugin: r } : {}
|
|
155
|
+
} : void 0,
|
|
156
|
+
signServer: t.signServer || n.signServer ? {
|
|
157
|
+
...t.signServer,
|
|
158
|
+
...n.signServer,
|
|
159
|
+
...a ? { kol: a } : {},
|
|
160
|
+
...s ? { usbKey: s } : {}
|
|
161
|
+
} : void 0
|
|
162
|
+
};
|
|
163
|
+
}, J = () => globalThis, p = () => {
|
|
161
164
|
const t = J();
|
|
162
165
|
return t[k] || (t[k] = {
|
|
163
|
-
current:
|
|
164
|
-
defaults:
|
|
166
|
+
current: g(E),
|
|
167
|
+
defaults: g(E),
|
|
165
168
|
overrides: {}
|
|
166
169
|
}), t[k];
|
|
167
|
-
}, lt = () =>
|
|
168
|
-
const
|
|
169
|
-
return
|
|
170
|
+
}, lt = () => p().current, ct = () => {
|
|
171
|
+
const t = p();
|
|
172
|
+
return {
|
|
173
|
+
current: g(t.current),
|
|
174
|
+
defaults: g(t.defaults),
|
|
175
|
+
overrides: y(t.overrides)
|
|
176
|
+
};
|
|
170
177
|
}, ht = (t) => {
|
|
171
|
-
const n =
|
|
172
|
-
return n.
|
|
178
|
+
const n = p();
|
|
179
|
+
return n.defaults = g(t), n.current = V(n.defaults, n.overrides), n.current;
|
|
173
180
|
}, gt = (t) => {
|
|
174
|
-
const n =
|
|
175
|
-
return n.
|
|
181
|
+
const n = p();
|
|
182
|
+
return n.current = g(t), n.overrides = y(t), n.current;
|
|
176
183
|
}, mt = (t) => {
|
|
177
|
-
const n =
|
|
178
|
-
return
|
|
179
|
-
}, pt = {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
const n = p();
|
|
185
|
+
return n.overrides = X(n.overrides, y(t)), n.current = V(n.current, t), n.current;
|
|
186
|
+
}, pt = (t) => {
|
|
187
|
+
const n = p();
|
|
188
|
+
return t && (n.defaults = g(t)), n.overrides = {}, n.current = g(n.defaults), n.current;
|
|
189
|
+
}, bt = {
|
|
190
|
+
EDGE_POSITION: U,
|
|
191
|
+
RSA_MODE: B,
|
|
192
|
+
SIGNATURE_TYPE: N
|
|
193
|
+
}, f = (t) => {
|
|
184
194
|
if (t.length !== 0)
|
|
185
195
|
return t.length === 1 ? t[0] : t;
|
|
186
196
|
}, d = (t, n, e) => new Proxy(
|
|
@@ -201,16 +211,16 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
201
211
|
return a.state?.(e.state.snapshot(), s);
|
|
202
212
|
const o = a.adapterMethod ?? r;
|
|
203
213
|
if (a.kind === "query")
|
|
204
|
-
return e.bridge.request(t, o,
|
|
214
|
+
return e.bridge.request(t, o, f(s));
|
|
205
215
|
if (a.kind === "callbackQuery") {
|
|
206
216
|
const c = s.find((h) => typeof h == "function"), l = s.filter((h) => typeof h != "function");
|
|
207
|
-
e.bridge.request(t, o,
|
|
208
|
-
const
|
|
209
|
-
c?.(...
|
|
217
|
+
e.bridge.request(t, o, f(l)).then((h) => {
|
|
218
|
+
const j = a.mapCallbackResult?.(h) ?? [h];
|
|
219
|
+
c?.(...j);
|
|
210
220
|
}).catch(e.onAsyncError);
|
|
211
221
|
return;
|
|
212
222
|
}
|
|
213
|
-
const u = e.bridge.request(t, o,
|
|
223
|
+
const u = e.bridge.request(t, o, f(s)).catch((c) => {
|
|
214
224
|
e.onAsyncError(c);
|
|
215
225
|
});
|
|
216
226
|
if (a.returnsResult)
|
|
@@ -221,7 +231,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
221
231
|
};
|
|
222
232
|
}
|
|
223
233
|
}
|
|
224
|
-
), Z = (t) => typeof t == "object" && t !== null && !Array.isArray(t) && "id" in t,
|
|
234
|
+
), Z = (t) => typeof t == "object" && t !== null && !Array.isArray(t) && "id" in t, P = (t) => t.annotations?.filter(Z).map((n) => ({ ...n })) ?? [], ee = (t) => {
|
|
225
235
|
switch (t) {
|
|
226
236
|
case "select":
|
|
227
237
|
case "pen":
|
|
@@ -259,11 +269,11 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
|
|
|
259
269
|
},
|
|
260
270
|
getAnnotations: {
|
|
261
271
|
kind: "stateGetter",
|
|
262
|
-
state: (t) =>
|
|
272
|
+
state: (t) => P(t)
|
|
263
273
|
},
|
|
264
274
|
getAnnotationsCount: {
|
|
265
275
|
kind: "stateGetter",
|
|
266
|
-
state: (t) =>
|
|
276
|
+
state: (t) => P(t).length
|
|
267
277
|
},
|
|
268
278
|
openAnnotationView: { kind: "command" },
|
|
269
279
|
closeAnnotationView: { kind: "command" },
|
|
@@ -300,7 +310,7 @@ class re {
|
|
|
300
310
|
this.configSecurityProvider = (e) => this.adapter.configSecurityProvider(e), this.getSecurityProviders = () => this.adapter.getSecurityProviders(), this.adapter = d("crypto", ie, n);
|
|
301
311
|
}
|
|
302
312
|
}
|
|
303
|
-
const
|
|
313
|
+
const C = (t) => t.digitalSignatures ? [...t.digitalSignatures] : [], ae = {
|
|
304
314
|
addDigitalSignatureRetrieveCallback: {
|
|
305
315
|
kind: "callbackRegister",
|
|
306
316
|
callback: (t, n) => {
|
|
@@ -337,11 +347,11 @@ const P = (t) => t.digitalSignatures ? [...t.digitalSignatures] : [], ae = {
|
|
|
337
347
|
listDigitalSignatures: { kind: "callbackQuery" },
|
|
338
348
|
getDigitalSignatures: {
|
|
339
349
|
kind: "stateGetter",
|
|
340
|
-
state: (t) =>
|
|
350
|
+
state: (t) => C(t)
|
|
341
351
|
},
|
|
342
352
|
getDigitalSignaturesCount: {
|
|
343
353
|
kind: "stateGetter",
|
|
344
|
-
state: (t) =>
|
|
354
|
+
state: (t) => C(t).length
|
|
345
355
|
},
|
|
346
356
|
enableDigitalSignatureInfoView: { kind: "command" },
|
|
347
357
|
enableDigitalSignatureRevocation: { kind: "command" }
|
|
@@ -355,7 +365,7 @@ class se {
|
|
|
355
365
|
);
|
|
356
366
|
}
|
|
357
367
|
}
|
|
358
|
-
const oe = "rhc-office.editor-adapter", de = 1, ue = "__RHC_OFFICE_EDITOR_ADAPTER__",
|
|
368
|
+
const oe = "rhc-office.editor-adapter", de = 1, ue = "__RHC_OFFICE_EDITOR_ADAPTER__", D = "rhcOfficeAdapterReady", A = "rhcOfficeAdapterEvent", G = "data-rhc-office-reader-id", le = {
|
|
359
369
|
addDocumentOpenedCallback: {
|
|
360
370
|
kind: "callbackRegister",
|
|
361
371
|
callback: (t, n) => {
|
|
@@ -475,7 +485,7 @@ class ke {
|
|
|
475
485
|
);
|
|
476
486
|
}
|
|
477
487
|
}
|
|
478
|
-
const
|
|
488
|
+
const fe = (t) => ({
|
|
479
489
|
addPageChangeCallback: {
|
|
480
490
|
kind: "callbackRegister",
|
|
481
491
|
callback: (n, e) => {
|
|
@@ -525,11 +535,11 @@ const Re = (t) => ({
|
|
|
525
535
|
gotoPreviousPage: { kind: "command" },
|
|
526
536
|
rotatePage: { kind: "command" }
|
|
527
537
|
});
|
|
528
|
-
class
|
|
538
|
+
class Re {
|
|
529
539
|
constructor(n) {
|
|
530
540
|
this.addPageChangeCallback = (e) => this.adapter.addPageChangeCallback(e), this.addPageModeChangeCallback = (e) => this.adapter.addPageModeChangeCallback(e), this.getPageCount = (e) => this.adapter.getPageCount(e), this.getPageIndex = (e) => this.adapter.getPageIndex(e), this.setSinglePageViewMode = () => this.adapter.setSinglePageViewMode(), this.setTwoPagesViewMode = () => this.adapter.setTwoPagesViewMode(), this.setPageScrollVertical = () => this.adapter.setPageScrollVertical(), this.setPageScrollHorizontal = () => this.adapter.setPageScrollHorizontal(), this.setPageCursorPanDrag = () => this.adapter.setPageCursorPanDrag(), this.setPageCursorTextSelect = () => this.adapter.setPageCursorTextSelect(), this.rotateCW = () => this.adapter.rotateCW(), this.rotateCCW = () => this.adapter.rotateCCW(), this.autoFitPage = () => this.adapter.autoFitPage(), this.fitPageSize = () => this.adapter.fitPageSize(), this.fitPageWidth = () => this.adapter.fitPageWidth(), this.fitPageHeight = () => this.adapter.fitPageHeight(), this.increasePageScale = () => this.adapter.increasePageScale(), this.decreasePageScale = () => this.adapter.decreasePageScale(), this.setPageScale = (e) => this.adapter.setPageScale(e), this.setPageBlendColor = (e, i, r, a) => this.adapter.setPageBlendColor(e, i, r, a), this.gotoPage = (e, i, r) => this.adapter.gotoPage(e, i, r), this.gotoNextPage = () => this.adapter.gotoNextPage(), this.gotoPreviousPage = () => this.adapter.gotoPreviousPage(), this.rotatePage = (e) => this.adapter.rotatePage(e), this.adapter = d(
|
|
531
541
|
"page",
|
|
532
|
-
|
|
542
|
+
fe(n),
|
|
533
543
|
n
|
|
534
544
|
);
|
|
535
545
|
}
|
|
@@ -560,19 +570,19 @@ class ve {
|
|
|
560
570
|
);
|
|
561
571
|
}
|
|
562
572
|
}
|
|
563
|
-
const ye = /\s*,\s*/, Ee = /\s*-\s*/,
|
|
573
|
+
const ye = /\s*,\s*/, Ee = /\s*-\s*/, R = (t) => {
|
|
564
574
|
const n = Number.parseInt(t.trim(), 10);
|
|
565
575
|
return !Number.isFinite(n) || n <= 0 ? null : n;
|
|
566
576
|
}, Pe = (t) => {
|
|
567
577
|
const n = t.split(Ee);
|
|
568
578
|
if (n.length === 1) {
|
|
569
|
-
const r =
|
|
579
|
+
const r = R(n[0] ?? "");
|
|
570
580
|
return r ? [r] : [];
|
|
571
581
|
}
|
|
572
|
-
const e =
|
|
582
|
+
const e = R(n[0] ?? ""), i = R(n[1] ?? "");
|
|
573
583
|
return !e || !i || i < e ? [] : Array.from({ length: i - e + 1 }, (r, a) => e + a);
|
|
574
584
|
}, Ce = (t) => t ? t.split(ye).flatMap((e) => Pe(e)).filter((e, i, r) => r.indexOf(e) === i) : [];
|
|
575
|
-
class
|
|
585
|
+
class De {
|
|
576
586
|
constructor(n, e, i) {
|
|
577
587
|
this.setFieldName = (r) => {
|
|
578
588
|
this.key = r;
|
|
@@ -583,7 +593,7 @@ class Ae {
|
|
|
583
593
|
}, this.key = n, this.value = e, this.description = i;
|
|
584
594
|
}
|
|
585
595
|
}
|
|
586
|
-
class
|
|
596
|
+
class Ae {
|
|
587
597
|
constructor() {
|
|
588
598
|
this.fields = [], this.keywordTextFixedPositions = void 0, this.keywordOffsetX = 0, this.keywordOffsetY = 0, this.bookmarkOffsetX = 0, this.bookmarkOffsetY = 0, this.printMargin = 0, this.grayscaleSealImage = !1, this.signType = 0, this.sealPosition = 0, this.getSignType = () => this.signType, this.setSignType = (n) => {
|
|
589
599
|
this.signType = n;
|
|
@@ -738,7 +748,7 @@ class xe {
|
|
|
738
748
|
console.warn(`[RHC Office SDK] ui.${n} is deprecated. Use ui.${e} instead.`);
|
|
739
749
|
}
|
|
740
750
|
}
|
|
741
|
-
const
|
|
751
|
+
const Ke = (t) => {
|
|
742
752
|
if (!t)
|
|
743
753
|
return;
|
|
744
754
|
const n = t.trim().toLowerCase();
|
|
@@ -749,21 +759,21 @@ const Ve = (t) => {
|
|
|
749
759
|
}, q = (t) => {
|
|
750
760
|
const n = new URL(t, globalThis.location?.href ?? "http://localhost/");
|
|
751
761
|
return n.hash = "", n.pathname.endsWith("/") || (n.pathname = `${n.pathname}/`), n.toString();
|
|
752
|
-
},
|
|
762
|
+
}, Ve = (t) => new URL("editors.bootstrap.js", t).toString(), Ge = (t, n) => {
|
|
753
763
|
const e = q(t);
|
|
754
764
|
return {
|
|
755
765
|
...n,
|
|
756
766
|
appUrl: e,
|
|
757
|
-
theme:
|
|
767
|
+
theme: Ke(n.theme)
|
|
758
768
|
};
|
|
759
|
-
},
|
|
769
|
+
}, m = "rhc-office-editor", T = "__RHC_OFFICE_SDK_READER_LOADER__", H = () => {
|
|
760
770
|
const t = globalThis;
|
|
761
771
|
return t[T] || (t[T] = {
|
|
762
772
|
activeAppUrl: null,
|
|
763
773
|
loadPromises: /* @__PURE__ */ new Map()
|
|
764
774
|
}), t[T];
|
|
765
775
|
}, qe = (t) => Array.from(document.querySelectorAll("script")).find((n) => n.src === t) ?? null;
|
|
766
|
-
class
|
|
776
|
+
class M extends Error {
|
|
767
777
|
constructor(n) {
|
|
768
778
|
super(`Failed to load reader bootstrap script: ${n}`), this.name = "ReaderScriptLoadError";
|
|
769
779
|
}
|
|
@@ -771,7 +781,7 @@ class D extends Error {
|
|
|
771
781
|
class He extends Error {
|
|
772
782
|
constructor(n, e) {
|
|
773
783
|
super(
|
|
774
|
-
`Reader Web Component "${
|
|
784
|
+
`Reader Web Component "${m}" is already bound to ${n} and cannot be reloaded from ${e}.`
|
|
775
785
|
), this.name = "ReaderSourceConflictError";
|
|
776
786
|
}
|
|
777
787
|
}
|
|
@@ -785,29 +795,29 @@ const z = (t) => {
|
|
|
785
795
|
const e = n.loadPromises.get(t);
|
|
786
796
|
if (e)
|
|
787
797
|
return e;
|
|
788
|
-
if (globalThis.customElements?.get(
|
|
798
|
+
if (globalThis.customElements?.get(m)) {
|
|
789
799
|
n.activeAppUrl = t;
|
|
790
800
|
const s = Promise.resolve();
|
|
791
801
|
return n.loadPromises.set(t, s), s;
|
|
792
802
|
}
|
|
793
|
-
const i =
|
|
803
|
+
const i = Ve(t), r = qe(i);
|
|
794
804
|
n.activeAppUrl = t;
|
|
795
805
|
const a = new Promise((s, o) => {
|
|
796
806
|
const u = (h) => {
|
|
797
|
-
h?.remove(), o(new
|
|
807
|
+
h?.remove(), o(new M(i));
|
|
798
808
|
}, c = () => {
|
|
799
|
-
globalThis.customElements.whenDefined(
|
|
809
|
+
globalThis.customElements.whenDefined(m).then(() => {
|
|
800
810
|
s();
|
|
801
811
|
}).catch(o);
|
|
802
812
|
};
|
|
803
813
|
if (r) {
|
|
804
|
-
if (globalThis.customElements?.get(
|
|
814
|
+
if (globalThis.customElements?.get(m)) {
|
|
805
815
|
s();
|
|
806
816
|
return;
|
|
807
817
|
}
|
|
808
818
|
r.addEventListener(
|
|
809
819
|
"error",
|
|
810
|
-
() => o(new
|
|
820
|
+
() => o(new M(i)),
|
|
811
821
|
{
|
|
812
822
|
once: !0
|
|
813
823
|
}
|
|
@@ -817,21 +827,21 @@ const z = (t) => {
|
|
|
817
827
|
const l = document.createElement("script");
|
|
818
828
|
l.src = i, l.async = !0, l.dataset.rhcOfficeSdkReader = t, l.addEventListener("load", c, { once: !0 }), l.addEventListener("error", () => u(l), { once: !0 }), document.head.appendChild(l);
|
|
819
829
|
}).catch((s) => {
|
|
820
|
-
throw n.loadPromises.delete(t), !globalThis.customElements?.get(
|
|
830
|
+
throw n.loadPromises.delete(t), !globalThis.customElements?.get(m) && n.activeAppUrl === t && (n.activeAppUrl = null), s;
|
|
821
831
|
});
|
|
822
832
|
return n.loadPromises.set(t, a), a;
|
|
823
|
-
}, Qe = 5e3,
|
|
833
|
+
}, Qe = 5e3, je = 5e3, Ye = () => {
|
|
824
834
|
const t = globalThis.crypto;
|
|
825
835
|
return typeof t?.randomUUID == "function" ? t.randomUUID() : `adapter-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
826
|
-
},
|
|
827
|
-
class
|
|
836
|
+
}, b = () => globalThis[ue];
|
|
837
|
+
class We extends Error {
|
|
828
838
|
constructor(n, e, i) {
|
|
829
839
|
super(e), this.name = "ReaderBridgeError", this.code = n, this.details = i;
|
|
830
840
|
}
|
|
831
841
|
}
|
|
832
|
-
class
|
|
842
|
+
class $e {
|
|
833
843
|
constructor(n) {
|
|
834
|
-
this.readerId = null, this.readyTimeoutMs = n?.readyTimeoutMs ??
|
|
844
|
+
this.readerId = null, this.readyTimeoutMs = n?.readyTimeoutMs ?? je, this.requestTimeoutMs = n?.requestTimeoutMs ?? Qe;
|
|
835
845
|
}
|
|
836
846
|
configureTimeouts(n) {
|
|
837
847
|
this.readyTimeoutMs = n?.readyTimeoutMs ?? this.readyTimeoutMs, this.requestTimeoutMs = n?.requestTimeoutMs ?? this.requestTimeoutMs;
|
|
@@ -846,7 +856,7 @@ class je {
|
|
|
846
856
|
const a = await this.requestRaw(n, e, i, r);
|
|
847
857
|
if (a.ok)
|
|
848
858
|
return a.result;
|
|
849
|
-
throw new
|
|
859
|
+
throw new We(
|
|
850
860
|
a.error.code,
|
|
851
861
|
a.error.message,
|
|
852
862
|
a.error.details
|
|
@@ -875,7 +885,7 @@ class je {
|
|
|
875
885
|
const s = {
|
|
876
886
|
protocol: oe,
|
|
877
887
|
version: de,
|
|
878
|
-
requestId:
|
|
888
|
+
requestId: Ye(),
|
|
879
889
|
readerId: this.readerId,
|
|
880
890
|
tool: n,
|
|
881
891
|
method: e,
|
|
@@ -888,25 +898,25 @@ class je {
|
|
|
888
898
|
);
|
|
889
899
|
}
|
|
890
900
|
getCapabilities() {
|
|
891
|
-
return this.readerId ?
|
|
901
|
+
return this.readerId ? b()?.getCapabilities(this.readerId) ?? null : null;
|
|
892
902
|
}
|
|
893
903
|
async waitForReady(n) {
|
|
894
904
|
return this.readerId ? !!await this.waitForAdapter(this.readerId, n?.timeoutMs) : !1;
|
|
895
905
|
}
|
|
896
906
|
async waitForAdapter(n, e = this.readyTimeoutMs) {
|
|
897
|
-
const i =
|
|
907
|
+
const i = b();
|
|
898
908
|
return i?.getCapabilities(n) ? i : new Promise((r) => {
|
|
899
909
|
let a;
|
|
900
910
|
const s = () => {
|
|
901
|
-
a && clearTimeout(a), globalThis.removeEventListener(
|
|
911
|
+
a && clearTimeout(a), globalThis.removeEventListener(D, o);
|
|
902
912
|
}, o = (u) => {
|
|
903
913
|
if ((u instanceof CustomEvent ? u.detail : void 0)?.readerId !== n)
|
|
904
914
|
return;
|
|
905
|
-
const l =
|
|
915
|
+
const l = b();
|
|
906
916
|
s(), r(l ?? null);
|
|
907
917
|
};
|
|
908
|
-
globalThis.addEventListener(
|
|
909
|
-
s(), r(
|
|
918
|
+
globalThis.addEventListener(D, o), a = setTimeout(() => {
|
|
919
|
+
s(), r(b()?.getCapabilities(n) ? b() : null);
|
|
910
920
|
}, e);
|
|
911
921
|
});
|
|
912
922
|
}
|
|
@@ -937,7 +947,7 @@ class je {
|
|
|
937
947
|
});
|
|
938
948
|
}
|
|
939
949
|
}
|
|
940
|
-
const
|
|
950
|
+
const w = {
|
|
941
951
|
annotationEnabled: !1,
|
|
942
952
|
documentModified: !1,
|
|
943
953
|
documentOpened: !1,
|
|
@@ -948,10 +958,10 @@ const M = {
|
|
|
948
958
|
};
|
|
949
959
|
class Xe {
|
|
950
960
|
constructor() {
|
|
951
|
-
this.state = { ...
|
|
961
|
+
this.state = { ...w };
|
|
952
962
|
}
|
|
953
963
|
reset() {
|
|
954
|
-
this.state = { ...
|
|
964
|
+
this.state = { ...w };
|
|
955
965
|
}
|
|
956
966
|
update(n) {
|
|
957
967
|
n && (this.state = {
|
|
@@ -975,7 +985,7 @@ class Xe {
|
|
|
975
985
|
};
|
|
976
986
|
}
|
|
977
987
|
}
|
|
978
|
-
const Je = (t) => typeof t == "object" && t !== null && !Array.isArray(t) ? t : void 0, Q = (t) => typeof t == "object" && t !== null && !Array.isArray(t),
|
|
988
|
+
const Je = (t) => typeof t == "object" && t !== null && !Array.isArray(t) ? t : void 0, Q = (t) => typeof t == "object" && t !== null && !Array.isArray(t), I = (t) => {
|
|
979
989
|
if (!Q(t))
|
|
980
990
|
return;
|
|
981
991
|
const n = {};
|
|
@@ -986,7 +996,7 @@ const Je = (t) => typeof t == "object" && t !== null && !Array.isArray(t) ? t :
|
|
|
986
996
|
success: !0,
|
|
987
997
|
status: "ok"
|
|
988
998
|
};
|
|
989
|
-
const n =
|
|
999
|
+
const n = I(t.state), e = I(t), i = typeof t.error == "string" ? t.error : void 0, r = typeof t.success == "boolean" ? t.success : !i, a = typeof t.status == "string" ? t.status : r ? "ok" : "error";
|
|
990
1000
|
return {
|
|
991
1001
|
success: r,
|
|
992
1002
|
status: a,
|
|
@@ -1072,7 +1082,7 @@ const S = "__RHC_OFFICE_READER_RUNTIME__", tt = "__rhcOfficeReaderRuntimeConfig"
|
|
|
1072
1082
|
"documentLoaded",
|
|
1073
1083
|
"documentStateChange",
|
|
1074
1084
|
"documentError"
|
|
1075
|
-
], it = "readerReady", rt = "readerUnload", v = "readerError", at = () => typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : `rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
1085
|
+
], it = "readerReady", rt = "readerUnload", v = "readerError", at = () => typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : `rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`, _ = (t, n) => ({
|
|
1076
1086
|
appUrl: n?.appUrl ?? null,
|
|
1077
1087
|
configuration: n,
|
|
1078
1088
|
element: t
|
|
@@ -1091,14 +1101,14 @@ const S = "__RHC_OFFICE_READER_RUNTIME__", tt = "__rhcOfficeReaderRuntimeConfig"
|
|
|
1091
1101
|
}, ot = () => {
|
|
1092
1102
|
const t = typeof globalThis.matchMedia == "function";
|
|
1093
1103
|
return (t ? globalThis.matchMedia("(prefers-contrast: more)").matches : !1) ? "high-contrast" : (t ? globalThis.matchMedia("(prefers-color-scheme: dark)").matches : !1) ? "dark" : "light";
|
|
1094
|
-
},
|
|
1104
|
+
}, O = (t, n) => {
|
|
1095
1105
|
const e = t;
|
|
1096
1106
|
if (typeof e.addEventListener == "function") {
|
|
1097
1107
|
e.addEventListener("change", n);
|
|
1098
1108
|
return;
|
|
1099
1109
|
}
|
|
1100
1110
|
typeof e.addListener == "function" && e.addListener(n);
|
|
1101
|
-
},
|
|
1111
|
+
}, L = (t, n) => {
|
|
1102
1112
|
const e = t;
|
|
1103
1113
|
if (typeof e.removeEventListener == "function") {
|
|
1104
1114
|
e.removeEventListener("change", n);
|
|
@@ -1107,7 +1117,7 @@ const S = "__RHC_OFFICE_READER_RUNTIME__", tt = "__rhcOfficeReaderRuntimeConfig"
|
|
|
1107
1117
|
typeof e.removeListener == "function" && e.removeListener(n);
|
|
1108
1118
|
}, dt = (t) => {
|
|
1109
1119
|
t.style.display || (t.style.display = "block"), t.style.width || (t.style.width = "100%"), t.style.height || (t.style.height = "100%");
|
|
1110
|
-
},
|
|
1120
|
+
}, F = (t, n) => {
|
|
1111
1121
|
const e = n;
|
|
1112
1122
|
if (!e)
|
|
1113
1123
|
return t.removeAttribute("theme"), null;
|
|
@@ -1121,19 +1131,19 @@ const S = "__RHC_OFFICE_READER_RUNTIME__", tt = "__rhcOfficeReaderRuntimeConfig"
|
|
|
1121
1131
|
const r = globalThis.matchMedia("(prefers-color-scheme: dark)"), a = globalThis.matchMedia("(prefers-contrast: more)"), s = () => {
|
|
1122
1132
|
i();
|
|
1123
1133
|
};
|
|
1124
|
-
return
|
|
1125
|
-
|
|
1134
|
+
return O(r, s), O(a, s), () => {
|
|
1135
|
+
L(r, s), L(a, s);
|
|
1126
1136
|
};
|
|
1127
1137
|
};
|
|
1128
1138
|
class ut {
|
|
1129
1139
|
constructor(n) {
|
|
1130
|
-
this.bridge = new
|
|
1140
|
+
this.bridge = new $e(), this.callbacks = new et(), this.readerState = new Xe(), this.bridgeToolContext = {
|
|
1131
1141
|
bridge: this.bridge,
|
|
1132
1142
|
callbacks: this.callbacks,
|
|
1133
1143
|
debug: () => this.debugEnabled,
|
|
1134
1144
|
onAsyncError: (e) => this.reportAdapterError(e),
|
|
1135
1145
|
state: this.readerState
|
|
1136
|
-
}, this.documentTool = new ce(this.bridgeToolContext), this.uiTool = new xe(this.bridgeToolContext), this.pageTool = new
|
|
1146
|
+
}, this.documentTool = new ce(this.bridgeToolContext), this.uiTool = new xe(this.bridgeToolContext), this.pageTool = new Re(this.bridgeToolContext), this.pageArrangeTool = new ke(this.bridgeToolContext), this.findTool = new ge(this.bridgeToolContext), this.signServerTool = new _e(this.bridgeToolContext), this.digitalSignTool = new se(this.bridgeToolContext), this.symbologyTool = new Le(this.bridgeToolContext), this.annotationTool = new ne(this.bridgeToolContext), this.templateSignTool = new Ue(this.bridgeToolContext), this.pdfFormFiller = new ve(this.bridgeToolContext), this.networkingTool = new pe(this.bridgeToolContext), this.cryptoTool = new re(this.bridgeToolContext), this.securityTool = new we(this.bridgeToolContext), this.readyCallbacks = [], this.unloadCallbacks = [], this.debugEnabled = !1, this.isReady = !1, this.removed = !1, this.mountToken = 0, this.hostContainer = null, this.readerElement = null, this.readerId = null, this.normalizedConfiguration = null, this.runtimeRestoreState = null, this.nativeEventCleanupCallbacks = [], this.themeCleanup = null, this.enableDebug = (e) => {
|
|
1137
1147
|
this.debugEnabled = e;
|
|
1138
1148
|
}, this.changeLanguage = (e) => {
|
|
1139
1149
|
this.readerElement && this.readerElement.setAttribute("language", e);
|
|
@@ -1141,7 +1151,7 @@ class ut {
|
|
|
1141
1151
|
this.themeCleanup?.(), this.themeCleanup = null, this.normalizedConfiguration = this.normalizedConfiguration ? {
|
|
1142
1152
|
...this.normalizedConfiguration,
|
|
1143
1153
|
theme: e
|
|
1144
|
-
} : null, this.readerElement && (this.themeCleanup =
|
|
1154
|
+
} : null, this.readerElement && (this.themeCleanup = F(this.readerElement, e));
|
|
1145
1155
|
}, this.setSessionUser = (e) => {
|
|
1146
1156
|
this.sessionUser = e;
|
|
1147
1157
|
}, this.setSessionUserId = (e) => {
|
|
@@ -1173,16 +1183,16 @@ class ut {
|
|
|
1173
1183
|
const e = !!(this.readerElement || this.hostContainer);
|
|
1174
1184
|
if (this.mountToken += 1, this.cleanupNativeEventForwarders(), this.cleanupThemeBinding(), this.restoreReaderRuntimeConfig(), this.readerElement?.parentNode && this.readerElement.parentNode.removeChild(this.readerElement), this.readerElement = null, this.readerId = null, this.bridge.setReaderId(null), this.readerState.reset(), this.hostContainer = null, this.normalizedConfiguration = null, this.isReady = !1, this.removed = !0, !e)
|
|
1175
1185
|
return;
|
|
1176
|
-
const i =
|
|
1186
|
+
const i = _(null, null);
|
|
1177
1187
|
this.emitReaderEvent(rt, i), this.unloadCallbacks.forEach((r) => r());
|
|
1178
|
-
}, this.getDocumentTool = () => this.documentTool, this.getUITool = () => this.uiTool, this.getPageTool = () => this.pageTool, this.getPageArrangeTool = () => this.pageArrangeTool, this.getFindTool = () => this.findTool, this.getSignServerTool = () => this.signServerTool, this.getDigitalSignTool = () => this.digitalSignTool, this.getSymbologyTool = () => this.symbologyTool, this.getAnnotationTool = () => this.annotationTool, this.getTemplateSignTool = () => this.templateSignTool, this.getPdfFormFiller = () => this.pdfFormFiller, this.getNetworkingTool = () => this.networkingTool, this.getCryptoTool = () => this.cryptoTool, this.getSecurityTool = () => this.securityTool, this.createDigitalSignOptions = () => new
|
|
1188
|
+
}, this.getDocumentTool = () => this.documentTool, this.getUITool = () => this.uiTool, this.getPageTool = () => this.pageTool, this.getPageArrangeTool = () => this.pageArrangeTool, this.getFindTool = () => this.findTool, this.getSignServerTool = () => this.signServerTool, this.getDigitalSignTool = () => this.digitalSignTool, this.getSymbologyTool = () => this.symbologyTool, this.getAnnotationTool = () => this.annotationTool, this.getTemplateSignTool = () => this.templateSignTool, this.getPdfFormFiller = () => this.pdfFormFiller, this.getNetworkingTool = () => this.networkingTool, this.getCryptoTool = () => this.cryptoTool, this.getSecurityTool = () => this.securityTool, this.createDigitalSignOptions = () => new Ae(), this.createKVField = (e, i, r) => new De(e, i, r), this.mountReader = async (e, i, r) => {
|
|
1179
1189
|
try {
|
|
1180
1190
|
if (await ze(i.appUrl), this.mountToken !== r)
|
|
1181
1191
|
return;
|
|
1182
|
-
const a = document.createElement(
|
|
1192
|
+
const a = document.createElement(m), s = at();
|
|
1183
1193
|
a.setAttribute(G, s), this.readerId = s, this.bridge.setReaderId(s), dt(a), this.applyReaderRuntimeConfig(a, i);
|
|
1184
1194
|
const o = i.compactViewer === !0 && i.keepPCMenu !== !0;
|
|
1185
|
-
if (a.toggleAttribute("data-sdk-compact-mode", o), a.setAttribute("language", i.language ?? "zh_CN"), this.themeCleanup =
|
|
1195
|
+
if (a.toggleAttribute("data-sdk-compact-mode", o), a.setAttribute("language", i.language ?? "zh_CN"), this.themeCleanup = F(a, i.theme), this.bindNativeReaderEvents(a), e.replaceChildren(a), this.readerElement = a, await Promise.resolve(), this.mountToken !== r)
|
|
1186
1196
|
return;
|
|
1187
1197
|
const u = await this.bridge.waitForReady();
|
|
1188
1198
|
if (this.mountToken !== r)
|
|
@@ -1190,7 +1200,7 @@ class ut {
|
|
|
1190
1200
|
if (!u)
|
|
1191
1201
|
throw new Error("Editor adapter is not available.");
|
|
1192
1202
|
this.isReady = !0;
|
|
1193
|
-
const c =
|
|
1203
|
+
const c = _(a, i);
|
|
1194
1204
|
this.emitReaderEvent(it, c), this.readyCallbacks.forEach((l) => l());
|
|
1195
1205
|
} catch (a) {
|
|
1196
1206
|
if (this.mountToken !== r)
|
|
@@ -1254,32 +1264,33 @@ class ut {
|
|
|
1254
1264
|
this.runtimeRestoreState.hadPreviousRuntime ? n[S] = this.runtimeRestoreState.previousRuntime : Reflect.deleteProperty(n, S), this.runtimeRestoreState = null;
|
|
1255
1265
|
}
|
|
1256
1266
|
}
|
|
1257
|
-
const
|
|
1267
|
+
const St = (t) => new ut(t);
|
|
1258
1268
|
export {
|
|
1259
1269
|
ne as AnnotationToolImpl,
|
|
1260
1270
|
re as CryptoToolImpl,
|
|
1261
|
-
|
|
1262
|
-
|
|
1271
|
+
bt as DIGITAL_SIGN_DEFAULTS,
|
|
1272
|
+
Ae as DigitalSignOptions,
|
|
1263
1273
|
se as DigitalSignToolImpl,
|
|
1264
1274
|
ut as DocumentSDK,
|
|
1265
1275
|
ce as DocumentToolImpl,
|
|
1266
1276
|
ge as FindToolImpl,
|
|
1267
|
-
|
|
1277
|
+
De as KVField,
|
|
1268
1278
|
pe as NetworkingToolImpl,
|
|
1269
1279
|
ke as PageArrangeToolImpl,
|
|
1270
|
-
|
|
1280
|
+
Re as PageToolImpl,
|
|
1271
1281
|
ve as PdfFormFillerImpl,
|
|
1272
1282
|
we as SecurityToolImpl,
|
|
1273
1283
|
_e as SignServerToolImpl,
|
|
1274
1284
|
Le as SymbologyToolImpl,
|
|
1275
1285
|
Ue as TemplateSignToolImpl,
|
|
1276
1286
|
xe as UIToolImpl,
|
|
1277
|
-
|
|
1278
|
-
|
|
1287
|
+
Y as WatermarkDisplay,
|
|
1288
|
+
St as createNewDocumentSdk,
|
|
1279
1289
|
lt as getDigitalSignEnvironment,
|
|
1280
|
-
ct as
|
|
1281
|
-
|
|
1282
|
-
mt as
|
|
1283
|
-
|
|
1290
|
+
ct as getDigitalSignEnvironmentSource,
|
|
1291
|
+
ht as initializeDigitalSignEnvironment,
|
|
1292
|
+
mt as patchDigitalSignEnvironment,
|
|
1293
|
+
pt as resetDigitalSignEnvironment,
|
|
1294
|
+
gt as setDigitalSignEnvironment
|
|
1284
1295
|
};
|
|
1285
1296
|
//# sourceMappingURL=index.js.map
|