1
1
import * as wasm from './docx_rs_bg.wasm' ;
2
2
3
+ let WASM_VECTOR_LEN = 0 ;
4
+
5
+ let cachedTextEncoder = new TextEncoder ( 'utf-8' ) ;
6
+
7
+ const encodeString = ( typeof cachedTextEncoder . encodeInto === 'function'
8
+ ? function ( arg , view ) {
9
+ return cachedTextEncoder . encodeInto ( arg , view ) ;
10
+ }
11
+ : function ( arg , view ) {
12
+ const buf = cachedTextEncoder . encode ( arg ) ;
13
+ view . set ( buf ) ;
14
+ return {
15
+ read : arg . length ,
16
+ written : buf . length
17
+ } ;
18
+ } ) ;
19
+
20
+ let cachegetUint8Memory = null ;
21
+ function getUint8Memory ( ) {
22
+ if ( cachegetUint8Memory === null || cachegetUint8Memory . buffer !== wasm . memory . buffer ) {
23
+ cachegetUint8Memory = new Uint8Array ( wasm . memory . buffer ) ;
24
+ }
25
+ return cachegetUint8Memory ;
26
+ }
27
+
28
+ function passStringToWasm ( arg ) {
29
+
30
+ let len = arg . length ;
31
+ let ptr = wasm . __wbindgen_malloc ( len ) ;
32
+
33
+ const mem = getUint8Memory ( ) ;
34
+
35
+ let offset = 0 ;
36
+
37
+ for ( ; offset < len ; offset ++ ) {
38
+ const code = arg . charCodeAt ( offset ) ;
39
+ if ( code > 0x7F ) break ;
40
+ mem [ ptr + offset ] = code ;
41
+ }
42
+
43
+ if ( offset !== len ) {
44
+ if ( offset !== 0 ) {
45
+ arg = arg . slice ( offset ) ;
46
+ }
47
+ ptr = wasm . __wbindgen_realloc ( ptr , len , len = offset + arg . length * 3 ) ;
48
+ const view = getUint8Memory ( ) . subarray ( ptr + offset , ptr + len ) ;
49
+ const ret = encodeString ( arg , view ) ;
50
+
51
+ offset += ret . written ;
52
+ }
53
+
54
+ WASM_VECTOR_LEN = offset ;
55
+ return ptr ;
56
+ }
3
57
/**
4
- * @returns {TableCell }
58
+ * @param {number } id
59
+ * @param {number } start
60
+ * @param {string } format
61
+ * @param {string } text
62
+ * @param {string } jc
63
+ * @returns {Level }
5
64
*/
6
- export function createTableCell ( ) {
7
- const ret = wasm . createTableCell ( ) ;
8
- return TableCell . __wrap ( ret ) ;
65
+ export function createLevel ( id , start , format , text , jc ) {
66
+ const ret = wasm . createLevel ( id , start , passStringToWasm ( format ) , WASM_VECTOR_LEN , passStringToWasm ( text ) , WASM_VECTOR_LEN , passStringToWasm ( jc ) , WASM_VECTOR_LEN ) ;
67
+ return Level . __wrap ( ret ) ;
9
68
}
10
69
11
- function _assertClass ( instance , klass ) {
12
- if ( ! ( instance instanceof klass ) ) {
13
- throw new Error ( `expected instance of ${ klass . name } ` ) ;
14
- }
15
- return instance . ptr ;
70
+ function isLikeNone ( x ) {
71
+ return x === undefined || x === null ;
16
72
}
17
73
/**
18
74
* @returns {Docx }
@@ -22,6 +78,13 @@ export function createDocx() {
22
78
return Docx . __wrap ( ret ) ;
23
79
}
24
80
81
+ function _assertClass ( instance , klass ) {
82
+ if ( ! ( instance instanceof klass ) ) {
83
+ throw new Error ( `expected instance of ${ klass . name } ` ) ;
84
+ }
85
+ return instance . ptr ;
86
+ }
87
+
25
88
let cachegetInt32Memory = null ;
26
89
function getInt32Memory ( ) {
27
90
if ( cachegetInt32Memory === null || cachegetInt32Memory . buffer !== wasm . memory . buffer ) {
@@ -30,14 +93,6 @@ function getInt32Memory() {
30
93
return cachegetInt32Memory ;
31
94
}
32
95
33
- let cachegetUint8Memory = null ;
34
- function getUint8Memory ( ) {
35
- if ( cachegetUint8Memory === null || cachegetUint8Memory . buffer !== wasm . memory . buffer ) {
36
- cachegetUint8Memory = new Uint8Array ( wasm . memory . buffer ) ;
37
- }
38
- return cachegetUint8Memory ;
39
- }
40
-
41
96
function getArrayU8FromWasm ( ptr , len ) {
42
97
return getUint8Memory ( ) . subarray ( ptr / 1 , ptr / 1 + len ) ;
43
98
}
@@ -82,8 +137,6 @@ function getUint32Memory() {
82
137
return cachegetUint32Memory ;
83
138
}
84
139
85
- let WASM_VECTOR_LEN = 0 ;
86
-
87
140
function passArray32ToWasm ( arg ) {
88
141
const ptr = wasm . __wbindgen_malloc ( arg . length * 4 ) ;
89
142
getUint32Memory ( ) . set ( arg , ptr / 4 ) ;
@@ -98,54 +151,6 @@ export function createParagraph() {
98
151
return Paragraph . __wrap ( ret ) ;
99
152
}
100
153
101
- let cachedTextEncoder = new TextEncoder ( 'utf-8' ) ;
102
-
103
- const encodeString = ( typeof cachedTextEncoder . encodeInto === 'function'
104
- ? function ( arg , view ) {
105
- return cachedTextEncoder . encodeInto ( arg , view ) ;
106
- }
107
- : function ( arg , view ) {
108
- const buf = cachedTextEncoder . encode ( arg ) ;
109
- view . set ( buf ) ;
110
- return {
111
- read : arg . length ,
112
- written : buf . length
113
- } ;
114
- } ) ;
115
-
116
- function passStringToWasm ( arg ) {
117
-
118
- let len = arg . length ;
119
- let ptr = wasm . __wbindgen_malloc ( len ) ;
120
-
121
- const mem = getUint8Memory ( ) ;
122
-
123
- let offset = 0 ;
124
-
125
- for ( ; offset < len ; offset ++ ) {
126
- const code = arg . charCodeAt ( offset ) ;
127
- if ( code > 0x7F ) break ;
128
- mem [ ptr + offset ] = code ;
129
- }
130
-
131
- if ( offset !== len ) {
132
- if ( offset !== 0 ) {
133
- arg = arg . slice ( offset ) ;
134
- }
135
- ptr = wasm . __wbindgen_realloc ( ptr , len , len = offset + arg . length * 3 ) ;
136
- const view = getUint8Memory ( ) . subarray ( ptr + offset , ptr + len ) ;
137
- const ret = encodeString ( arg , view ) ;
138
-
139
- offset += ret . written ;
140
- }
141
-
142
- WASM_VECTOR_LEN = offset ;
143
- return ptr ;
144
- }
145
-
146
- function isLikeNone ( x ) {
147
- return x === undefined || x === null ;
148
- }
149
154
/**
150
155
* @returns {Run }
151
156
*/
@@ -155,12 +160,11 @@ export function createRun() {
155
160
}
156
161
157
162
/**
158
- * @param {number } id
159
- * @returns {Comment }
163
+ * @returns {TableCell }
160
164
*/
161
- export function createComment ( id ) {
162
- const ret = wasm . createComment ( id ) ;
163
- return Comment . __wrap ( ret ) ;
165
+ export function createTableCell ( ) {
166
+ const ret = wasm . createTableCell ( ) ;
167
+ return TableCell . __wrap ( ret ) ;
164
168
}
165
169
166
170
/**
@@ -173,15 +177,11 @@ export function createTableRow() {
173
177
174
178
/**
175
179
* @param {number } id
176
- * @param {number } start
177
- * @param {string } format
178
- * @param {string } text
179
- * @param {string } jc
180
- * @returns {Level }
180
+ * @returns {Comment }
181
181
*/
182
- export function createLevel ( id , start , format , text , jc ) {
183
- const ret = wasm . createLevel ( id , start , passStringToWasm ( format ) , WASM_VECTOR_LEN , passStringToWasm ( text ) , WASM_VECTOR_LEN , passStringToWasm ( jc ) , WASM_VECTOR_LEN ) ;
184
- return Level . __wrap ( ret ) ;
182
+ export function createComment ( id ) {
183
+ const ret = wasm . createComment ( id ) ;
184
+ return Comment . __wrap ( ret ) ;
185
185
}
186
186
187
187
let cachedTextDecoder = new TextDecoder ( 'utf-8' , { ignoreBOM : true , fatal : true } ) ;
@@ -861,6 +861,16 @@ export class TableCell {
861
861
const ret = wasm . tablecell_grid_span ( ptr , v ) ;
862
862
return TableCell . __wrap ( ret ) ;
863
863
}
864
+ /**
865
+ * @param {number } v
866
+ * @returns {TableCell }
867
+ */
868
+ width ( v ) {
869
+ const ptr = this . ptr ;
870
+ this . ptr = 0 ;
871
+ const ret = wasm . tablecell_width ( ptr , v ) ;
872
+ return TableCell . __wrap ( ret ) ;
873
+ }
864
874
}
865
875
/**
866
876
*/
0 commit comments