@f-office/core 0.2.1 → 0.2.2
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/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/core.d.ts +2 -1
- package/dist/core.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +1 -1
- package/dist/wasm/f_office_wasm.d.ts +421 -0
- package/dist/wasm/f_office_wasm.js +959 -0
- package/dist/wasm/f_office_wasm_bg.wasm +0 -0
- package/dist/wasm/f_office_wasm_bg.wasm.d.ts +47 -0
- package/package.json +5 -1
|
@@ -221,6 +221,65 @@ export class Document {
|
|
|
221
221
|
}
|
|
222
222
|
if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
|
|
223
223
|
|
|
224
|
+
/**
|
|
225
|
+
* A drawn page for JavaScript: its width, height and RGBA pixels.
|
|
226
|
+
*/
|
|
227
|
+
export class Drawing {
|
|
228
|
+
static __wrap(ptr) {
|
|
229
|
+
const obj = Object.create(Drawing.prototype);
|
|
230
|
+
obj.__wbg_ptr = ptr;
|
|
231
|
+
DrawingFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
232
|
+
return obj;
|
|
233
|
+
}
|
|
234
|
+
__destroy_into_raw() {
|
|
235
|
+
const ptr = this.__wbg_ptr;
|
|
236
|
+
this.__wbg_ptr = 0;
|
|
237
|
+
DrawingFinalization.unregister(this);
|
|
238
|
+
return ptr;
|
|
239
|
+
}
|
|
240
|
+
free() {
|
|
241
|
+
const ptr = this.__destroy_into_raw();
|
|
242
|
+
wasm.__wbg_drawing_free(ptr, 0);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The height in pixels.
|
|
246
|
+
* @returns {number}
|
|
247
|
+
*/
|
|
248
|
+
get height() {
|
|
249
|
+
const ret = wasm.drawing_height(this.__wbg_ptr);
|
|
250
|
+
return ret >>> 0;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The pixels, four bytes each, row by row from the top, as a new array.
|
|
254
|
+
* @returns {Uint8Array}
|
|
255
|
+
*/
|
|
256
|
+
get pixels() {
|
|
257
|
+
const ret = wasm.drawing_pixels(this.__wbg_ptr);
|
|
258
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
259
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
260
|
+
return v1;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Consumes and returns the RGBA pixels without cloning inside WebAssembly.
|
|
264
|
+
* @returns {Uint8Array}
|
|
265
|
+
*/
|
|
266
|
+
takePixels() {
|
|
267
|
+
const ret = wasm.drawing_takePixels(this.__wbg_ptr);
|
|
268
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
269
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
270
|
+
return v1;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The width in pixels.
|
|
274
|
+
* @returns {number}
|
|
275
|
+
*/
|
|
276
|
+
get width() {
|
|
277
|
+
const ret = wasm.drawing_width(this.__wbg_ptr);
|
|
278
|
+
return ret >>> 0;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (Symbol.dispose) Drawing.prototype[Symbol.dispose] = Drawing.prototype.free;
|
|
282
|
+
|
|
224
283
|
/**
|
|
225
284
|
* A font that a document's text asks for and the families that the target tries for it.
|
|
226
285
|
*/
|
|
@@ -747,6 +806,900 @@ export class SearchMatch {
|
|
|
747
806
|
}
|
|
748
807
|
if (Symbol.dispose) SearchMatch.prototype[Symbol.dispose] = SearchMatch.prototype.free;
|
|
749
808
|
|
|
809
|
+
/**
|
|
810
|
+
* The viewer's session for JavaScript, as [`Session`] says.
|
|
811
|
+
*/
|
|
812
|
+
export class Session {
|
|
813
|
+
__destroy_into_raw() {
|
|
814
|
+
const ptr = this.__wbg_ptr;
|
|
815
|
+
this.__wbg_ptr = 0;
|
|
816
|
+
SessionFinalization.unregister(this);
|
|
817
|
+
return ptr;
|
|
818
|
+
}
|
|
819
|
+
free() {
|
|
820
|
+
const ptr = this.__destroy_into_raw();
|
|
821
|
+
wasm.__wbg_session_free(ptr, 0);
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Takes the ICU4X word dictionaries from an external postcard data blob, for the open
|
|
825
|
+
* document and the ones that it opens later.
|
|
826
|
+
*
|
|
827
|
+
* # Errors
|
|
828
|
+
*
|
|
829
|
+
* Throws when the data holds no word dictionaries.
|
|
830
|
+
* @param {Uint8Array | number[]} blob
|
|
831
|
+
*/
|
|
832
|
+
addDictionaries(blob) {
|
|
833
|
+
const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_malloc);
|
|
834
|
+
const len0 = WASM_VECTOR_LEN;
|
|
835
|
+
const ret = wasm.session_addDictionaries(this.__wbg_ptr, ptr0, len0);
|
|
836
|
+
if (ret[1]) {
|
|
837
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Adds the faces of a font file and returns how many it holds.
|
|
842
|
+
*
|
|
843
|
+
* # Errors
|
|
844
|
+
*
|
|
845
|
+
* Throws when the data is no font.
|
|
846
|
+
* @param {Uint8Array | number[]} data
|
|
847
|
+
* @returns {number}
|
|
848
|
+
*/
|
|
849
|
+
addFont(data) {
|
|
850
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
851
|
+
const len0 = WASM_VECTOR_LEN;
|
|
852
|
+
const ret = wasm.session_addFont(this.__wbg_ptr, ptr0, len0);
|
|
853
|
+
if (ret[2]) {
|
|
854
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
855
|
+
}
|
|
856
|
+
return ret[0] >>> 0;
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Ends a press because the window lost the focus, and returns what it did, as JSON
|
|
860
|
+
* ([`handled_json`]).
|
|
861
|
+
*
|
|
862
|
+
* # Errors
|
|
863
|
+
*
|
|
864
|
+
* Throws when no document is open.
|
|
865
|
+
* @returns {string}
|
|
866
|
+
*/
|
|
867
|
+
blur() {
|
|
868
|
+
let deferred2_0;
|
|
869
|
+
let deferred2_1;
|
|
870
|
+
try {
|
|
871
|
+
const ret = wasm.session_blur(this.__wbg_ptr);
|
|
872
|
+
var ptr1 = ret[0];
|
|
873
|
+
var len1 = ret[1];
|
|
874
|
+
if (ret[3]) {
|
|
875
|
+
ptr1 = 0; len1 = 0;
|
|
876
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
877
|
+
}
|
|
878
|
+
deferred2_0 = ptr1;
|
|
879
|
+
deferred2_1 = len1;
|
|
880
|
+
return getStringFromWasm0(ptr1, len1);
|
|
881
|
+
} finally {
|
|
882
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Clears all caller-supplied highlights, or only those matching `kind`.
|
|
887
|
+
*
|
|
888
|
+
* # Errors
|
|
889
|
+
*
|
|
890
|
+
* Throws when no document is open.
|
|
891
|
+
* @param {string | null} [kind]
|
|
892
|
+
*/
|
|
893
|
+
clearHighlights(kind) {
|
|
894
|
+
var ptr0 = isLikeNone(kind) ? 0 : passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
895
|
+
var len0 = WASM_VECTOR_LEN;
|
|
896
|
+
const ret = wasm.session_clearHighlights(this.__wbg_ptr, ptr0, len0);
|
|
897
|
+
if (ret[1]) {
|
|
898
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Clears the selection.
|
|
903
|
+
*
|
|
904
|
+
* # Errors
|
|
905
|
+
*
|
|
906
|
+
* Throws when no document is open.
|
|
907
|
+
*/
|
|
908
|
+
clearSelection() {
|
|
909
|
+
const ret = wasm.session_clearSelection(this.__wbg_ptr);
|
|
910
|
+
if (ret[1]) {
|
|
911
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Draws a page at a resolution, and counts the drawing as the shell's.
|
|
916
|
+
*
|
|
917
|
+
* # Errors
|
|
918
|
+
*
|
|
919
|
+
* Throws when no document is open, or the page does not exist or cannot be drawn.
|
|
920
|
+
* @param {number} page
|
|
921
|
+
* @param {number} dpi
|
|
922
|
+
* @returns {Drawing}
|
|
923
|
+
*/
|
|
924
|
+
draw(page, dpi) {
|
|
925
|
+
const ret = wasm.session_draw(this.__wbg_ptr, page, dpi);
|
|
926
|
+
if (ret[2]) {
|
|
927
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
928
|
+
}
|
|
929
|
+
return Drawing.__wrap(ret[0]);
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Ends a zoom gesture, so that the next frame asks for the drawings at its zoom.
|
|
933
|
+
*
|
|
934
|
+
* # Errors
|
|
935
|
+
*
|
|
936
|
+
* Throws when no document is open.
|
|
937
|
+
*/
|
|
938
|
+
endGesture() {
|
|
939
|
+
const ret = wasm.session_endGesture(this.__wbg_ptr);
|
|
940
|
+
if (ret[1]) {
|
|
941
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Makes the next match current when `forward` is set, and the match before it when not.
|
|
946
|
+
*
|
|
947
|
+
* # Errors
|
|
948
|
+
*
|
|
949
|
+
* Throws when no document is open.
|
|
950
|
+
* @param {boolean} forward
|
|
951
|
+
*/
|
|
952
|
+
findStep(forward) {
|
|
953
|
+
const ret = wasm.session_findStep(this.__wbg_ptr, forward);
|
|
954
|
+
if (ret[1]) {
|
|
955
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Searches the document for `query`, and returns the number of matches.
|
|
960
|
+
*
|
|
961
|
+
* # Errors
|
|
962
|
+
*
|
|
963
|
+
* Throws when no document is open.
|
|
964
|
+
* @param {string} query
|
|
965
|
+
* @returns {number}
|
|
966
|
+
*/
|
|
967
|
+
find(query) {
|
|
968
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
969
|
+
const len0 = WASM_VECTOR_LEN;
|
|
970
|
+
const ret = wasm.session_find(this.__wbg_ptr, ptr0, len0);
|
|
971
|
+
if (ret[2]) {
|
|
972
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
973
|
+
}
|
|
974
|
+
return ret[0] >>> 0;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* The fonts that a random-access DOCX source asks for on `target`, as JSON, without copying
|
|
978
|
+
* the whole archive into WASM linear memory ([`Session::fonts_needed_source`]).
|
|
979
|
+
*
|
|
980
|
+
* # Errors
|
|
981
|
+
*
|
|
982
|
+
* Throws when `byteLength` is invalid, no target has the ID, or the source cannot be opened.
|
|
983
|
+
* @param {number} byte_length
|
|
984
|
+
* @param {Function} read_at
|
|
985
|
+
* @param {string | null} [target]
|
|
986
|
+
* @returns {string}
|
|
987
|
+
*/
|
|
988
|
+
static fontsNeededSource(byte_length, read_at, target) {
|
|
989
|
+
let deferred4_0;
|
|
990
|
+
let deferred4_1;
|
|
991
|
+
try {
|
|
992
|
+
const val2 = +byte_length;
|
|
993
|
+
var ptr0 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
994
|
+
var len0 = WASM_VECTOR_LEN;
|
|
995
|
+
const ret = wasm.session_fontsNeededSource(val2, read_at, ptr0, len0);
|
|
996
|
+
var ptr3 = ret[0];
|
|
997
|
+
var len3 = ret[1];
|
|
998
|
+
if (ret[3]) {
|
|
999
|
+
ptr3 = 0; len3 = 0;
|
|
1000
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1001
|
+
}
|
|
1002
|
+
deferred4_0 = ptr3;
|
|
1003
|
+
deferred4_1 = len3;
|
|
1004
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1005
|
+
} finally {
|
|
1006
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* The fonts that `docx` asks for on `target`, as JSON ([`Session::fonts_needed`]).
|
|
1011
|
+
*
|
|
1012
|
+
* # Errors
|
|
1013
|
+
*
|
|
1014
|
+
* Throws when no target has the ID or the file cannot be opened.
|
|
1015
|
+
* @param {Uint8Array | number[]} docx
|
|
1016
|
+
* @param {string | null} [target]
|
|
1017
|
+
* @returns {string}
|
|
1018
|
+
*/
|
|
1019
|
+
static fontsNeeded(docx, target) {
|
|
1020
|
+
let deferred4_0;
|
|
1021
|
+
let deferred4_1;
|
|
1022
|
+
try {
|
|
1023
|
+
let ptr0, len0, ptr1, len1;
|
|
1024
|
+
try {
|
|
1025
|
+
ptr0 = passArray8ToWasm0(docx, wasm.__wbindgen_malloc);
|
|
1026
|
+
len0 = WASM_VECTOR_LEN;
|
|
1027
|
+
ptr1 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1028
|
+
len1 = WASM_VECTOR_LEN;
|
|
1029
|
+
} catch (e) {
|
|
1030
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
1031
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
1032
|
+
throw e;
|
|
1033
|
+
}
|
|
1034
|
+
const ret = wasm.session_fontsNeeded(ptr0, len0, ptr1, len1);
|
|
1035
|
+
var ptr3 = ret[0];
|
|
1036
|
+
var len3 = ret[1];
|
|
1037
|
+
if (ret[3]) {
|
|
1038
|
+
ptr3 = 0; len3 = 0;
|
|
1039
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1040
|
+
}
|
|
1041
|
+
deferred4_0 = ptr3;
|
|
1042
|
+
deferred4_1 = len3;
|
|
1043
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1044
|
+
} finally {
|
|
1045
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Forgets the drawings that the worker was asked for and has not drawn.
|
|
1050
|
+
*
|
|
1051
|
+
* # Errors
|
|
1052
|
+
*
|
|
1053
|
+
* Throws when no document is open.
|
|
1054
|
+
*/
|
|
1055
|
+
forgetRequests() {
|
|
1056
|
+
const ret = wasm.session_forgetRequests(this.__wbg_ptr);
|
|
1057
|
+
if (ret[1]) {
|
|
1058
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* What the shell shows now, as JSON ([`frame_json`]).
|
|
1063
|
+
*
|
|
1064
|
+
* # Errors
|
|
1065
|
+
*
|
|
1066
|
+
* Throws when no document is open.
|
|
1067
|
+
* @returns {string}
|
|
1068
|
+
*/
|
|
1069
|
+
frame() {
|
|
1070
|
+
let deferred2_0;
|
|
1071
|
+
let deferred2_1;
|
|
1072
|
+
try {
|
|
1073
|
+
const ret = wasm.session_frame(this.__wbg_ptr);
|
|
1074
|
+
var ptr1 = ret[0];
|
|
1075
|
+
var len1 = ret[1];
|
|
1076
|
+
if (ret[3]) {
|
|
1077
|
+
ptr1 = 0; len1 = 0;
|
|
1078
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1079
|
+
}
|
|
1080
|
+
deferred2_0 = ptr1;
|
|
1081
|
+
deferred2_1 = len1;
|
|
1082
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1083
|
+
} finally {
|
|
1084
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Zooms to `factor` during a zoom gesture, around the viewport's point at `anchor_x` and
|
|
1089
|
+
* `anchor_y`: the frames ask for no drawing until [`Session::end_gesture`].
|
|
1090
|
+
*
|
|
1091
|
+
* # Errors
|
|
1092
|
+
*
|
|
1093
|
+
* Throws when no document is open.
|
|
1094
|
+
* @param {number} factor
|
|
1095
|
+
* @param {number | null} [anchor_x]
|
|
1096
|
+
* @param {number | null} [anchor_y]
|
|
1097
|
+
*/
|
|
1098
|
+
gestureZoom(factor, anchor_x, anchor_y) {
|
|
1099
|
+
const ret = wasm.session_gestureZoom(this.__wbg_ptr, factor, !isLikeNone(anchor_x), isLikeNone(anchor_x) ? 0 : anchor_x, !isLikeNone(anchor_y), isLikeNone(anchor_y) ? 0 : anchor_y);
|
|
1100
|
+
if (ret[1]) {
|
|
1101
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Scrolls to the line where the bookmark `name` starts, and returns whether it went.
|
|
1106
|
+
*
|
|
1107
|
+
* # Errors
|
|
1108
|
+
*
|
|
1109
|
+
* Throws when no document is open.
|
|
1110
|
+
* @param {string} name
|
|
1111
|
+
* @returns {boolean}
|
|
1112
|
+
*/
|
|
1113
|
+
goToBookmark(name) {
|
|
1114
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1115
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1116
|
+
const ret = wasm.session_goToBookmark(this.__wbg_ptr, ptr0, len0);
|
|
1117
|
+
if (ret[2]) {
|
|
1118
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1119
|
+
}
|
|
1120
|
+
return ret[0] !== 0;
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Scrolls to the first line of a heading of the outline, by its index in the outline, and
|
|
1124
|
+
* makes it the frame's `currentHeading` until the next scroll.
|
|
1125
|
+
*
|
|
1126
|
+
* # Errors
|
|
1127
|
+
*
|
|
1128
|
+
* Throws when no document is open.
|
|
1129
|
+
* @param {number} index
|
|
1130
|
+
*/
|
|
1131
|
+
goToHeading(index) {
|
|
1132
|
+
const ret = wasm.session_goToHeading(this.__wbg_ptr, index);
|
|
1133
|
+
if (ret[1]) {
|
|
1134
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Scrolls the top of a page, counted from 0, to the top of the viewport.
|
|
1139
|
+
*
|
|
1140
|
+
* # Errors
|
|
1141
|
+
*
|
|
1142
|
+
* Throws when no document is open.
|
|
1143
|
+
* @param {number} page
|
|
1144
|
+
*/
|
|
1145
|
+
goToPage(page) {
|
|
1146
|
+
const ret = wasm.session_goToPage(this.__wbg_ptr, page);
|
|
1147
|
+
if (ret[1]) {
|
|
1148
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* The innermost hyperlink under the viewport's point `x`, `y`, as JSON: its `target`, an
|
|
1153
|
+
* `external` `address` or a `bookmark` `name`, and its `tooltip`; null away from a link.
|
|
1154
|
+
*
|
|
1155
|
+
* # Errors
|
|
1156
|
+
*
|
|
1157
|
+
* Throws when no document is open.
|
|
1158
|
+
* @param {number} x
|
|
1159
|
+
* @param {number} y
|
|
1160
|
+
* @returns {string}
|
|
1161
|
+
*/
|
|
1162
|
+
linkAt(x, y) {
|
|
1163
|
+
let deferred2_0;
|
|
1164
|
+
let deferred2_1;
|
|
1165
|
+
try {
|
|
1166
|
+
const ret = wasm.session_linkAt(this.__wbg_ptr, x, y);
|
|
1167
|
+
var ptr1 = ret[0];
|
|
1168
|
+
var len1 = ret[1];
|
|
1169
|
+
if (ret[3]) {
|
|
1170
|
+
ptr1 = 0; len1 = 0;
|
|
1171
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1172
|
+
}
|
|
1173
|
+
deferred2_0 = ptr1;
|
|
1174
|
+
deferred2_1 = len1;
|
|
1175
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1176
|
+
} finally {
|
|
1177
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* A session with no fonts and no document.
|
|
1182
|
+
*/
|
|
1183
|
+
constructor() {
|
|
1184
|
+
const ret = wasm.session_new();
|
|
1185
|
+
this.__wbg_ptr = ret;
|
|
1186
|
+
SessionFinalization.register(this, this.__wbg_ptr, this);
|
|
1187
|
+
return this;
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Opens a random-access DOCX source for `target` without copying the full archive into WASM
|
|
1191
|
+
* linear memory ([`Session::open_source`]).
|
|
1192
|
+
*
|
|
1193
|
+
* # Errors
|
|
1194
|
+
*
|
|
1195
|
+
* Throws when `byteLength` is invalid, no target has the ID, or the source cannot be opened.
|
|
1196
|
+
* @param {number} byte_length
|
|
1197
|
+
* @param {Function} read_at
|
|
1198
|
+
* @param {string | null} [target]
|
|
1199
|
+
* @returns {string}
|
|
1200
|
+
*/
|
|
1201
|
+
openSource(byte_length, read_at, target) {
|
|
1202
|
+
let deferred4_0;
|
|
1203
|
+
let deferred4_1;
|
|
1204
|
+
try {
|
|
1205
|
+
const val2 = +byte_length;
|
|
1206
|
+
var ptr0 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1207
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1208
|
+
const ret = wasm.session_openSource(this.__wbg_ptr, val2, read_at, ptr0, len0);
|
|
1209
|
+
var ptr3 = ret[0];
|
|
1210
|
+
var len3 = ret[1];
|
|
1211
|
+
if (ret[3]) {
|
|
1212
|
+
ptr3 = 0; len3 = 0;
|
|
1213
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1214
|
+
}
|
|
1215
|
+
deferred4_0 = ptr3;
|
|
1216
|
+
deferred4_1 = len3;
|
|
1217
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1218
|
+
} finally {
|
|
1219
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Opens `docx` for `target`, and returns its page count and outline as JSON
|
|
1224
|
+
* ([`Session::open`]).
|
|
1225
|
+
*
|
|
1226
|
+
* # Errors
|
|
1227
|
+
*
|
|
1228
|
+
* Throws when no target has the ID or the file cannot be opened.
|
|
1229
|
+
* @param {Uint8Array | number[]} docx
|
|
1230
|
+
* @param {string | null} [target]
|
|
1231
|
+
* @returns {string}
|
|
1232
|
+
*/
|
|
1233
|
+
open(docx, target) {
|
|
1234
|
+
let deferred4_0;
|
|
1235
|
+
let deferred4_1;
|
|
1236
|
+
try {
|
|
1237
|
+
let ptr0, len0, ptr1, len1;
|
|
1238
|
+
try {
|
|
1239
|
+
ptr0 = passArray8ToWasm0(docx, wasm.__wbindgen_malloc);
|
|
1240
|
+
len0 = WASM_VECTOR_LEN;
|
|
1241
|
+
ptr1 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1242
|
+
len1 = WASM_VECTOR_LEN;
|
|
1243
|
+
} catch (e) {
|
|
1244
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
1245
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
1246
|
+
throw e;
|
|
1247
|
+
}
|
|
1248
|
+
const ret = wasm.session_open(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1249
|
+
var ptr3 = ret[0];
|
|
1250
|
+
var len3 = ret[1];
|
|
1251
|
+
if (ret[3]) {
|
|
1252
|
+
ptr3 = 0; len3 = 0;
|
|
1253
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1254
|
+
}
|
|
1255
|
+
deferred4_0 = ptr3;
|
|
1256
|
+
deferred4_1 = len3;
|
|
1257
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1258
|
+
} finally {
|
|
1259
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Whether the viewport's point `x`, `y` lies on a line of text.
|
|
1264
|
+
*
|
|
1265
|
+
* # Errors
|
|
1266
|
+
*
|
|
1267
|
+
* Throws when no document is open.
|
|
1268
|
+
* @param {number} x
|
|
1269
|
+
* @param {number} y
|
|
1270
|
+
* @returns {boolean}
|
|
1271
|
+
*/
|
|
1272
|
+
overText(x, y) {
|
|
1273
|
+
const ret = wasm.session_overText(this.__wbg_ptr, x, y);
|
|
1274
|
+
if (ret[2]) {
|
|
1275
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1276
|
+
}
|
|
1277
|
+
return ret[0] !== 0;
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* The hyperlinks of a page, counted from 0, as JSON: in reading order, each with its
|
|
1281
|
+
* `target`, `tooltip`, `text` and `boxes`, the boxes as shares of the page's width and
|
|
1282
|
+
* height.
|
|
1283
|
+
*
|
|
1284
|
+
* # Errors
|
|
1285
|
+
*
|
|
1286
|
+
* Throws when no document is open.
|
|
1287
|
+
* @param {number} page
|
|
1288
|
+
* @returns {string}
|
|
1289
|
+
*/
|
|
1290
|
+
pageLinks(page) {
|
|
1291
|
+
let deferred2_0;
|
|
1292
|
+
let deferred2_1;
|
|
1293
|
+
try {
|
|
1294
|
+
const ret = wasm.session_pageLinks(this.__wbg_ptr, page);
|
|
1295
|
+
var ptr1 = ret[0];
|
|
1296
|
+
var len1 = ret[1];
|
|
1297
|
+
if (ret[3]) {
|
|
1298
|
+
ptr1 = 0; len1 = 0;
|
|
1299
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1300
|
+
}
|
|
1301
|
+
deferred2_0 = ptr1;
|
|
1302
|
+
deferred2_1 = len1;
|
|
1303
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1304
|
+
} finally {
|
|
1305
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Writes the open document's pages as a PDF file, for printing.
|
|
1310
|
+
*
|
|
1311
|
+
* # Errors
|
|
1312
|
+
*
|
|
1313
|
+
* Throws when no document is open, or the pages cannot be written as PDF.
|
|
1314
|
+
* @returns {Uint8Array}
|
|
1315
|
+
*/
|
|
1316
|
+
pdf() {
|
|
1317
|
+
const ret = wasm.session_pdf(this.__wbg_ptr);
|
|
1318
|
+
if (ret[3]) {
|
|
1319
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1320
|
+
}
|
|
1321
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1322
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1323
|
+
return v1;
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Ends a press that the platform cancelled or whose capture it lost, and returns what it
|
|
1327
|
+
* did, as JSON ([`handled_json`]).
|
|
1328
|
+
*
|
|
1329
|
+
* # Errors
|
|
1330
|
+
*
|
|
1331
|
+
* Throws when no document is open.
|
|
1332
|
+
* @returns {string}
|
|
1333
|
+
*/
|
|
1334
|
+
pointerCancel() {
|
|
1335
|
+
let deferred2_0;
|
|
1336
|
+
let deferred2_1;
|
|
1337
|
+
try {
|
|
1338
|
+
const ret = wasm.session_pointerCancel(this.__wbg_ptr);
|
|
1339
|
+
var ptr1 = ret[0];
|
|
1340
|
+
var len1 = ret[1];
|
|
1341
|
+
if (ret[3]) {
|
|
1342
|
+
ptr1 = 0; len1 = 0;
|
|
1343
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1344
|
+
}
|
|
1345
|
+
deferred2_0 = ptr1;
|
|
1346
|
+
deferred2_1 = len1;
|
|
1347
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1348
|
+
} finally {
|
|
1349
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Takes a press at the viewport's point `x`, `y` at `time` milliseconds: whether of the
|
|
1354
|
+
* `primary` button, by a `pointer` of kind `mouse`, `pen` or `touch`, with `shift`, on a
|
|
1355
|
+
* `hit` of kind `page`, `gap`, `scroll-bar`, `start-handle` or `end-handle`. Returns what it did, as JSON
|
|
1356
|
+
* ([`handled_json`]).
|
|
1357
|
+
*
|
|
1358
|
+
* # Errors
|
|
1359
|
+
*
|
|
1360
|
+
* Throws when no document is open or a kind has another name.
|
|
1361
|
+
* @param {number} x
|
|
1362
|
+
* @param {number} y
|
|
1363
|
+
* @param {boolean} primary
|
|
1364
|
+
* @param {string} pointer
|
|
1365
|
+
* @param {boolean} shift
|
|
1366
|
+
* @param {number} time
|
|
1367
|
+
* @param {string} hit
|
|
1368
|
+
* @returns {string}
|
|
1369
|
+
*/
|
|
1370
|
+
pointerDown(x, y, primary, pointer, shift, time, hit) {
|
|
1371
|
+
let deferred9_0;
|
|
1372
|
+
let deferred9_1;
|
|
1373
|
+
try {
|
|
1374
|
+
const val3 = +x;
|
|
1375
|
+
const val4 = +y;
|
|
1376
|
+
const val5 = +primary;
|
|
1377
|
+
const val6 = +shift;
|
|
1378
|
+
const val7 = +time;
|
|
1379
|
+
let ptr0, len0, ptr1, len1;
|
|
1380
|
+
try {
|
|
1381
|
+
ptr0 = passStringToWasm0(pointer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1382
|
+
len0 = WASM_VECTOR_LEN;
|
|
1383
|
+
ptr1 = passStringToWasm0(hit, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1384
|
+
len1 = WASM_VECTOR_LEN;
|
|
1385
|
+
} catch (e) {
|
|
1386
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
1387
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
1388
|
+
throw e;
|
|
1389
|
+
}
|
|
1390
|
+
const ret = wasm.session_pointerDown(this.__wbg_ptr, val3, val4, val5, ptr0, len0, val6, val7, ptr1, len1);
|
|
1391
|
+
var ptr8 = ret[0];
|
|
1392
|
+
var len8 = ret[1];
|
|
1393
|
+
if (ret[3]) {
|
|
1394
|
+
ptr8 = 0; len8 = 0;
|
|
1395
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1396
|
+
}
|
|
1397
|
+
deferred9_0 = ptr8;
|
|
1398
|
+
deferred9_1 = len8;
|
|
1399
|
+
return getStringFromWasm0(ptr8, len8);
|
|
1400
|
+
} finally {
|
|
1401
|
+
wasm.__wbindgen_free(deferred9_0, deferred9_1, 1);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Moves a press's pointer to the viewport's point `x`, `y` at `time` milliseconds, and
|
|
1406
|
+
* returns what it did, as JSON ([`handled_json`]).
|
|
1407
|
+
*
|
|
1408
|
+
* # Errors
|
|
1409
|
+
*
|
|
1410
|
+
* Throws when no document is open.
|
|
1411
|
+
* @param {number} x
|
|
1412
|
+
* @param {number} y
|
|
1413
|
+
* @param {number} time
|
|
1414
|
+
* @returns {string}
|
|
1415
|
+
*/
|
|
1416
|
+
pointerMove(x, y, time) {
|
|
1417
|
+
let deferred2_0;
|
|
1418
|
+
let deferred2_1;
|
|
1419
|
+
try {
|
|
1420
|
+
const ret = wasm.session_pointerMove(this.__wbg_ptr, x, y, time);
|
|
1421
|
+
var ptr1 = ret[0];
|
|
1422
|
+
var len1 = ret[1];
|
|
1423
|
+
if (ret[3]) {
|
|
1424
|
+
ptr1 = 0; len1 = 0;
|
|
1425
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1426
|
+
}
|
|
1427
|
+
deferred2_0 = ptr1;
|
|
1428
|
+
deferred2_1 = len1;
|
|
1429
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1430
|
+
} finally {
|
|
1431
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Ends a press at the viewport's point `x`, `y` at `time` milliseconds, and returns what
|
|
1436
|
+
* it did, as JSON ([`handled_json`]).
|
|
1437
|
+
*
|
|
1438
|
+
* # Errors
|
|
1439
|
+
*
|
|
1440
|
+
* Throws when no document is open.
|
|
1441
|
+
* @param {number} x
|
|
1442
|
+
* @param {number} y
|
|
1443
|
+
* @param {number} time
|
|
1444
|
+
* @returns {string}
|
|
1445
|
+
*/
|
|
1446
|
+
pointerUp(x, y, time) {
|
|
1447
|
+
let deferred2_0;
|
|
1448
|
+
let deferred2_1;
|
|
1449
|
+
try {
|
|
1450
|
+
const ret = wasm.session_pointerUp(this.__wbg_ptr, x, y, time);
|
|
1451
|
+
var ptr1 = ret[0];
|
|
1452
|
+
var len1 = ret[1];
|
|
1453
|
+
if (ret[3]) {
|
|
1454
|
+
ptr1 = 0; len1 = 0;
|
|
1455
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1456
|
+
}
|
|
1457
|
+
deferred2_0 = ptr1;
|
|
1458
|
+
deferred2_1 = len1;
|
|
1459
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1460
|
+
} finally {
|
|
1461
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Draws a page at a resolution for the browser's own Print, without counting the
|
|
1466
|
+
* drawing as the shell's.
|
|
1467
|
+
*
|
|
1468
|
+
* # Errors
|
|
1469
|
+
*
|
|
1470
|
+
* Throws when no document is open, or the page does not exist or cannot be drawn.
|
|
1471
|
+
* @param {number} page
|
|
1472
|
+
* @param {number} dpi
|
|
1473
|
+
* @returns {Drawing}
|
|
1474
|
+
*/
|
|
1475
|
+
printPage(page, dpi) {
|
|
1476
|
+
const ret = wasm.session_printPage(this.__wbg_ptr, page, dpi);
|
|
1477
|
+
if (ret[2]) {
|
|
1478
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1479
|
+
}
|
|
1480
|
+
return Drawing.__wrap(ret[0]);
|
|
1481
|
+
}
|
|
1482
|
+
/**
|
|
1483
|
+
* The reading text of a page, counted from 0, as JSON: its paragraphs in reading order,
|
|
1484
|
+
* each with its `text` and its outline `level` or null.
|
|
1485
|
+
*
|
|
1486
|
+
* # Errors
|
|
1487
|
+
*
|
|
1488
|
+
* Throws when no document is open.
|
|
1489
|
+
* @param {number} page
|
|
1490
|
+
* @returns {string}
|
|
1491
|
+
*/
|
|
1492
|
+
readingText(page) {
|
|
1493
|
+
let deferred2_0;
|
|
1494
|
+
let deferred2_1;
|
|
1495
|
+
try {
|
|
1496
|
+
const ret = wasm.session_readingText(this.__wbg_ptr, page);
|
|
1497
|
+
var ptr1 = ret[0];
|
|
1498
|
+
var len1 = ret[1];
|
|
1499
|
+
if (ret[3]) {
|
|
1500
|
+
ptr1 = 0; len1 = 0;
|
|
1501
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1502
|
+
}
|
|
1503
|
+
deferred2_0 = ptr1;
|
|
1504
|
+
deferred2_1 = len1;
|
|
1505
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1506
|
+
} finally {
|
|
1507
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Gives the viewer the viewport's size in CSS pixels and the device pixel ratio.
|
|
1512
|
+
*
|
|
1513
|
+
* # Errors
|
|
1514
|
+
*
|
|
1515
|
+
* Throws when no document is open.
|
|
1516
|
+
* @param {number} width
|
|
1517
|
+
* @param {number} height
|
|
1518
|
+
* @param {number} ratio
|
|
1519
|
+
*/
|
|
1520
|
+
resize(width, height, ratio) {
|
|
1521
|
+
const ret = wasm.session_resize(this.__wbg_ptr, width, height, ratio);
|
|
1522
|
+
if (ret[1]) {
|
|
1523
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Scrolls to `page`, optionally focusing a point-space rectangle with `block` placement.
|
|
1528
|
+
*
|
|
1529
|
+
* # Errors
|
|
1530
|
+
*
|
|
1531
|
+
* Throws when no document is open.
|
|
1532
|
+
* @param {number} page
|
|
1533
|
+
* @param {number | null} [left]
|
|
1534
|
+
* @param {number | null} [top]
|
|
1535
|
+
* @param {number | null} [width]
|
|
1536
|
+
* @param {number | null} [height]
|
|
1537
|
+
* @param {string | null} [block]
|
|
1538
|
+
*/
|
|
1539
|
+
scrollToRect(page, left, top, width, height, block) {
|
|
1540
|
+
const val2 = +page;
|
|
1541
|
+
const val3 = +(isLikeNone(left) ? 0 : left);
|
|
1542
|
+
const val4 = +(isLikeNone(top) ? 0 : top);
|
|
1543
|
+
const val5 = +(isLikeNone(width) ? 0 : width);
|
|
1544
|
+
const val6 = +(isLikeNone(height) ? 0 : height);
|
|
1545
|
+
var ptr0 = isLikeNone(block) ? 0 : passStringToWasm0(block, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1546
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1547
|
+
const ret = wasm.session_scrollToRect(this.__wbg_ptr, val2, !isLikeNone(left), val3, !isLikeNone(top), val4, !isLikeNone(width), val5, !isLikeNone(height), val6, ptr0, len0);
|
|
1548
|
+
if (ret[1]) {
|
|
1549
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Scrolls the viewport's top left corner to `(left, top)`.
|
|
1554
|
+
*
|
|
1555
|
+
* # Errors
|
|
1556
|
+
*
|
|
1557
|
+
* Throws when no document is open.
|
|
1558
|
+
* @param {number} left
|
|
1559
|
+
* @param {number} top
|
|
1560
|
+
*/
|
|
1561
|
+
scrollTo(left, top) {
|
|
1562
|
+
const ret = wasm.session_scrollTo(this.__wbg_ptr, left, top);
|
|
1563
|
+
if (ret[1]) {
|
|
1564
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Selects the whole story of the last press.
|
|
1569
|
+
*
|
|
1570
|
+
* # Errors
|
|
1571
|
+
*
|
|
1572
|
+
* Throws when no document is open.
|
|
1573
|
+
*/
|
|
1574
|
+
selectAll() {
|
|
1575
|
+
const ret = wasm.session_selectAll(this.__wbg_ptr);
|
|
1576
|
+
if (ret[1]) {
|
|
1577
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
/**
|
|
1581
|
+
* The selected text, as a copy gives it.
|
|
1582
|
+
*
|
|
1583
|
+
* # Errors
|
|
1584
|
+
*
|
|
1585
|
+
* Throws when no document is open.
|
|
1586
|
+
* @returns {string}
|
|
1587
|
+
*/
|
|
1588
|
+
selectedText() {
|
|
1589
|
+
let deferred2_0;
|
|
1590
|
+
let deferred2_1;
|
|
1591
|
+
try {
|
|
1592
|
+
const ret = wasm.session_selectedText(this.__wbg_ptr);
|
|
1593
|
+
var ptr1 = ret[0];
|
|
1594
|
+
var len1 = ret[1];
|
|
1595
|
+
if (ret[3]) {
|
|
1596
|
+
ptr1 = 0; len1 = 0;
|
|
1597
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1598
|
+
}
|
|
1599
|
+
deferred2_0 = ptr1;
|
|
1600
|
+
deferred2_1 = len1;
|
|
1601
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1602
|
+
} finally {
|
|
1603
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
/**
|
|
1607
|
+
* Replaces caller-supplied highlights from a JSON array string.
|
|
1608
|
+
*
|
|
1609
|
+
* # Errors
|
|
1610
|
+
*
|
|
1611
|
+
* Throws when no document is open or JSON is malformed.
|
|
1612
|
+
* @param {string} items_json
|
|
1613
|
+
*/
|
|
1614
|
+
setHighlights(items_json) {
|
|
1615
|
+
const ptr0 = passStringToWasm0(items_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1616
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1617
|
+
const ret = wasm.session_setHighlights(this.__wbg_ptr, ptr0, len0);
|
|
1618
|
+
if (ret[1]) {
|
|
1619
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Enables or disables two-pass progressive drawing (fast 96 DPI draft before `HiDPI`).
|
|
1624
|
+
* @param {boolean} enabled
|
|
1625
|
+
*/
|
|
1626
|
+
setProgressiveDraft(enabled) {
|
|
1627
|
+
wasm.session_setProgressiveDraft(this.__wbg_ptr, enabled);
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Sets the zoom, `fixed` at `factor`, `fit-width` or `fit-page`, around the anchor or the
|
|
1631
|
+
* viewport's middle ([`Session::set_zoom`]).
|
|
1632
|
+
*
|
|
1633
|
+
* # Errors
|
|
1634
|
+
*
|
|
1635
|
+
* Throws when no document is open or the kind is no zoom.
|
|
1636
|
+
* @param {string} kind
|
|
1637
|
+
* @param {number} factor
|
|
1638
|
+
* @param {number | null} [anchor_x]
|
|
1639
|
+
* @param {number | null} [anchor_y]
|
|
1640
|
+
*/
|
|
1641
|
+
setZoom(kind, factor, anchor_x, anchor_y) {
|
|
1642
|
+
const val2 = +factor;
|
|
1643
|
+
const val3 = +(isLikeNone(anchor_x) ? 0 : anchor_x);
|
|
1644
|
+
const val4 = +(isLikeNone(anchor_y) ? 0 : anchor_y);
|
|
1645
|
+
const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1646
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1647
|
+
const ret = wasm.session_setZoom(this.__wbg_ptr, ptr0, len0, val2, !isLikeNone(anchor_x), val3, !isLikeNone(anchor_y), val4);
|
|
1648
|
+
if (ret[1]) {
|
|
1649
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Scrolls a point in points of a page, counted from 0, to the viewport's top left corner,
|
|
1654
|
+
* as the frame's `place` gave it.
|
|
1655
|
+
*
|
|
1656
|
+
* # Errors
|
|
1657
|
+
*
|
|
1658
|
+
* Throws when no document is open.
|
|
1659
|
+
* @param {number} page
|
|
1660
|
+
* @param {number} x
|
|
1661
|
+
* @param {number} y
|
|
1662
|
+
*/
|
|
1663
|
+
showPlace(page, x, y) {
|
|
1664
|
+
const ret = wasm.session_showPlace(this.__wbg_ptr, page, x, y);
|
|
1665
|
+
if (ret[1]) {
|
|
1666
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Streams the open document's pages as a PDF to `onChunk(chunk: Uint8Array)` in bounded
|
|
1671
|
+
* 64 KiB chunks without allocating the full PDF in WASM linear memory.
|
|
1672
|
+
*
|
|
1673
|
+
* # Errors
|
|
1674
|
+
*
|
|
1675
|
+
* Throws when no document is open, or the pages cannot be written as PDF.
|
|
1676
|
+
* @param {Function} on_chunk
|
|
1677
|
+
*/
|
|
1678
|
+
writePdfTo(on_chunk) {
|
|
1679
|
+
const ret = wasm.session_writePdfTo(this.__wbg_ptr, on_chunk);
|
|
1680
|
+
if (ret[1]) {
|
|
1681
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Zooms one step in or out around the anchor or the viewport's middle.
|
|
1686
|
+
*
|
|
1687
|
+
* # Errors
|
|
1688
|
+
*
|
|
1689
|
+
* Throws when no document is open.
|
|
1690
|
+
* @param {boolean} inward
|
|
1691
|
+
* @param {number | null} [anchor_x]
|
|
1692
|
+
* @param {number | null} [anchor_y]
|
|
1693
|
+
*/
|
|
1694
|
+
zoomStep(inward, anchor_x, anchor_y) {
|
|
1695
|
+
const ret = wasm.session_zoomStep(this.__wbg_ptr, inward, !isLikeNone(anchor_x), isLikeNone(anchor_x) ? 0 : anchor_x, !isLikeNone(anchor_y), isLikeNone(anchor_y) ? 0 : anchor_y);
|
|
1696
|
+
if (ret[1]) {
|
|
1697
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
if (Symbol.dispose) Session.prototype[Symbol.dispose] = Session.prototype.free;
|
|
1702
|
+
|
|
750
1703
|
/**
|
|
751
1704
|
* A run of upright text on a page, in points from the page's top left corner: the box of its
|
|
752
1705
|
* glyphs from its font's ascender to its descender, and its glyphs.
|
|
@@ -963,6 +1916,9 @@ function __wbg_get_imports() {
|
|
|
963
1916
|
const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
964
1917
|
? { register: () => {}, unregister: () => {} }
|
|
965
1918
|
: new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr, 1));
|
|
1919
|
+
const DrawingFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1920
|
+
? { register: () => {}, unregister: () => {} }
|
|
1921
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_drawing_free(ptr, 1));
|
|
966
1922
|
const FontNeedFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
967
1923
|
? { register: () => {}, unregister: () => {} }
|
|
968
1924
|
: new FinalizationRegistry(ptr => wasm.__wbg_fontneed_free(ptr, 1));
|
|
@@ -978,6 +1934,9 @@ const RendererFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
978
1934
|
const SearchMatchFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
979
1935
|
? { register: () => {}, unregister: () => {} }
|
|
980
1936
|
: new FinalizationRegistry(ptr => wasm.__wbg_searchmatch_free(ptr, 1));
|
|
1937
|
+
const SessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1938
|
+
? { register: () => {}, unregister: () => {} }
|
|
1939
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_session_free(ptr, 1));
|
|
981
1940
|
const TextRunFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
982
1941
|
? { register: () => {}, unregister: () => {} }
|
|
983
1942
|
: new FinalizationRegistry(ptr => wasm.__wbg_textrun_free(ptr, 1));
|