@hexze/mctext 1.1.5 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mctext_wasm.d.ts CHANGED
@@ -1,56 +1,69 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ export enum FontFamily {
5
+ Minecraft = 0,
6
+ Enchanting = 1,
7
+ Illager = 2,
8
+ }
9
+
4
10
  export class FontSystem {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
8
- static modern(): FontSystem;
9
- measure(text: string, size: number): number;
11
+ private constructor();
12
+ free(): void;
13
+ [Symbol.dispose](): void;
14
+ ascentRatio(): number;
15
+ static legacy(): FontSystem;
16
+ measure(text: string, size: number): number;
17
+ measureFamily(text: string, size: number, family: FontFamily): number;
18
+ static modern(): FontSystem;
10
19
  }
11
20
 
12
21
  export class LayoutOptions {
13
- free(): void;
14
- [Symbol.dispose](): void;
15
- withShadow(shadow: boolean): LayoutOptions;
16
- withMaxWidth(width: number): LayoutOptions;
17
- constructor(size: number);
22
+ free(): void;
23
+ [Symbol.dispose](): void;
24
+ constructor(size: number);
25
+ withAlign(align: string): LayoutOptions;
26
+ withLineSpacing(spacing: number): LayoutOptions;
27
+ withMaxWidth(width: number): LayoutOptions;
28
+ withShadow(shadow: boolean): LayoutOptions;
18
29
  }
19
30
 
20
31
  export class MCText {
21
- free(): void;
22
- [Symbol.dispose](): void;
23
- static parseJson(json: string): MCText;
24
- plainText(): string;
25
- constructor();
26
- span(text: string): SpanBuilder;
27
- static parse(text: string): MCText;
28
- spans(): any;
29
- toJson(): string;
30
- toLegacy(): string;
32
+ free(): void;
33
+ [Symbol.dispose](): void;
34
+ concat(other: MCText): MCText;
35
+ isEmpty(): boolean;
36
+ constructor();
37
+ static parse(text: string): MCText;
38
+ static parseJson(json: string): MCText;
39
+ plainText(): string;
40
+ span(text: string): SpanBuilder;
41
+ spans(): any;
42
+ toJson(): string;
43
+ toLegacy(): string;
31
44
  }
32
45
 
33
46
  export class RenderResult {
34
- private constructor();
35
- free(): void;
36
- [Symbol.dispose](): void;
37
- data(): Uint8Array;
38
- width(): number;
39
- height(): number;
47
+ private constructor();
48
+ free(): void;
49
+ [Symbol.dispose](): void;
50
+ data(): Uint8Array;
51
+ height(): number;
52
+ width(): number;
40
53
  }
41
54
 
42
55
  export class SpanBuilder {
43
- private constructor();
44
- free(): void;
45
- [Symbol.dispose](): void;
46
- obfuscated(): SpanBuilder;
47
- underlined(): SpanBuilder;
48
- strikethrough(): SpanBuilder;
49
- bold(): SpanBuilder;
50
- then(text: string): SpanBuilder;
51
- build(): MCText;
52
- color(color: string): SpanBuilder;
53
- italic(): SpanBuilder;
56
+ private constructor();
57
+ free(): void;
58
+ [Symbol.dispose](): void;
59
+ bold(): SpanBuilder;
60
+ build(): MCText;
61
+ color(color: string): SpanBuilder;
62
+ italic(): SpanBuilder;
63
+ obfuscated(): SpanBuilder;
64
+ strikethrough(): SpanBuilder;
65
+ then(text: string): SpanBuilder;
66
+ underlined(): SpanBuilder;
54
67
  }
55
68
 
56
69
  export function countVisibleChars(text: string): number;
@@ -59,4 +72,6 @@ export function namedColors(): any;
59
72
 
60
73
  export function render(font_system: FontSystem, text: MCText, width: number, height: number, options: LayoutOptions): RenderResult;
61
74
 
75
+ export function renderFamily(font_system: FontSystem, text: string, width: number, height: number, size: number, family: FontFamily): RenderResult;
76
+
62
77
  export function stripCodes(text: string): string;
package/mctext_wasm.js CHANGED
@@ -1,129 +1,14 @@
1
+ /* @ts-self-types="./mctext_wasm.d.ts" */
1
2
 
2
- let imports = {};
3
- imports['__wbindgen_placeholder__'] = module.exports;
4
-
5
- function addToExternrefTable0(obj) {
6
- const idx = wasm.__externref_table_alloc();
7
- wasm.__wbindgen_externrefs.set(idx, obj);
8
- return idx;
9
- }
10
-
11
- function _assertClass(instance, klass) {
12
- if (!(instance instanceof klass)) {
13
- throw new Error(`expected instance of ${klass.name}`);
14
- }
15
- }
16
-
17
- function getArrayU8FromWasm0(ptr, len) {
18
- ptr = ptr >>> 0;
19
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
20
- }
21
-
22
- function getStringFromWasm0(ptr, len) {
23
- ptr = ptr >>> 0;
24
- return decodeText(ptr, len);
25
- }
26
-
27
- let cachedUint8ArrayMemory0 = null;
28
- function getUint8ArrayMemory0() {
29
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
30
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
31
- }
32
- return cachedUint8ArrayMemory0;
33
- }
34
-
35
- function handleError(f, args) {
36
- try {
37
- return f.apply(this, args);
38
- } catch (e) {
39
- const idx = addToExternrefTable0(e);
40
- wasm.__wbindgen_exn_store(idx);
41
- }
42
- }
43
-
44
- function passStringToWasm0(arg, malloc, realloc) {
45
- if (realloc === undefined) {
46
- const buf = cachedTextEncoder.encode(arg);
47
- const ptr = malloc(buf.length, 1) >>> 0;
48
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
49
- WASM_VECTOR_LEN = buf.length;
50
- return ptr;
51
- }
52
-
53
- let len = arg.length;
54
- let ptr = malloc(len, 1) >>> 0;
55
-
56
- const mem = getUint8ArrayMemory0();
57
-
58
- let offset = 0;
59
-
60
- for (; offset < len; offset++) {
61
- const code = arg.charCodeAt(offset);
62
- if (code > 0x7F) break;
63
- mem[ptr + offset] = code;
64
- }
65
- if (offset !== len) {
66
- if (offset !== 0) {
67
- arg = arg.slice(offset);
68
- }
69
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
70
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
71
- const ret = cachedTextEncoder.encodeInto(arg, view);
72
-
73
- offset += ret.written;
74
- ptr = realloc(ptr, len, offset, 1) >>> 0;
75
- }
76
-
77
- WASM_VECTOR_LEN = offset;
78
- return ptr;
79
- }
80
-
81
- function takeFromExternrefTable0(idx) {
82
- const value = wasm.__wbindgen_externrefs.get(idx);
83
- wasm.__externref_table_dealloc(idx);
84
- return value;
85
- }
86
-
87
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
88
- cachedTextDecoder.decode();
89
- function decodeText(ptr, len) {
90
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
91
- }
92
-
93
- const cachedTextEncoder = new TextEncoder();
94
-
95
- if (!('encodeInto' in cachedTextEncoder)) {
96
- cachedTextEncoder.encodeInto = function (arg, view) {
97
- const buf = cachedTextEncoder.encode(arg);
98
- view.set(buf);
99
- return {
100
- read: arg.length,
101
- written: buf.length
102
- };
103
- }
104
- }
105
-
106
- let WASM_VECTOR_LEN = 0;
107
-
108
- const FontSystemFinalization = (typeof FinalizationRegistry === 'undefined')
109
- ? { register: () => {}, unregister: () => {} }
110
- : new FinalizationRegistry(ptr => wasm.__wbg_fontsystem_free(ptr >>> 0, 1));
111
-
112
- const LayoutOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
113
- ? { register: () => {}, unregister: () => {} }
114
- : new FinalizationRegistry(ptr => wasm.__wbg_layoutoptions_free(ptr >>> 0, 1));
115
-
116
- const MCTextFinalization = (typeof FinalizationRegistry === 'undefined')
117
- ? { register: () => {}, unregister: () => {} }
118
- : new FinalizationRegistry(ptr => wasm.__wbg_mctext_free(ptr >>> 0, 1));
119
-
120
- const RenderResultFinalization = (typeof FinalizationRegistry === 'undefined')
121
- ? { register: () => {}, unregister: () => {} }
122
- : new FinalizationRegistry(ptr => wasm.__wbg_renderresult_free(ptr >>> 0, 1));
123
-
124
- const SpanBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
125
- ? { register: () => {}, unregister: () => {} }
126
- : new FinalizationRegistry(ptr => wasm.__wbg_spanbuilder_free(ptr >>> 0, 1));
3
+ /**
4
+ * @enum {0 | 1 | 2}
5
+ */
6
+ const FontFamily = Object.freeze({
7
+ Minecraft: 0, "0": "Minecraft",
8
+ Enchanting: 1, "1": "Enchanting",
9
+ Illager: 2, "2": "Illager",
10
+ });
11
+ exports.FontFamily = FontFamily;
127
12
 
128
13
  class FontSystem {
129
14
  static __wrap(ptr) {
@@ -143,11 +28,18 @@ class FontSystem {
143
28
  const ptr = this.__destroy_into_raw();
144
29
  wasm.__wbg_fontsystem_free(ptr, 0);
145
30
  }
31
+ /**
32
+ * @returns {number}
33
+ */
34
+ ascentRatio() {
35
+ const ret = wasm.fontsystem_ascentRatio(this.__wbg_ptr);
36
+ return ret;
37
+ }
146
38
  /**
147
39
  * @returns {FontSystem}
148
40
  */
149
- static modern() {
150
- const ret = wasm.fontsystem_modern();
41
+ static legacy() {
42
+ const ret = wasm.fontsystem_legacy();
151
43
  return FontSystem.__wrap(ret);
152
44
  }
153
45
  /**
@@ -161,6 +53,25 @@ class FontSystem {
161
53
  const ret = wasm.fontsystem_measure(this.__wbg_ptr, ptr0, len0, size);
162
54
  return ret;
163
55
  }
56
+ /**
57
+ * @param {string} text
58
+ * @param {number} size
59
+ * @param {FontFamily} family
60
+ * @returns {number}
61
+ */
62
+ measureFamily(text, size, family) {
63
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
64
+ const len0 = WASM_VECTOR_LEN;
65
+ const ret = wasm.fontsystem_measureFamily(this.__wbg_ptr, ptr0, len0, size, family);
66
+ return ret;
67
+ }
68
+ /**
69
+ * @returns {FontSystem}
70
+ */
71
+ static modern() {
72
+ const ret = wasm.fontsystem_modern();
73
+ return FontSystem.__wrap(ret);
74
+ }
164
75
  }
165
76
  if (Symbol.dispose) FontSystem.prototype[Symbol.dispose] = FontSystem.prototype.free;
166
77
  exports.FontSystem = FontSystem;
@@ -184,12 +95,30 @@ class LayoutOptions {
184
95
  wasm.__wbg_layoutoptions_free(ptr, 0);
185
96
  }
186
97
  /**
187
- * @param {boolean} shadow
98
+ * @param {number} size
99
+ */
100
+ constructor(size) {
101
+ const ret = wasm.layoutoptions_new(size);
102
+ this.__wbg_ptr = ret >>> 0;
103
+ LayoutOptionsFinalization.register(this, this.__wbg_ptr, this);
104
+ return this;
105
+ }
106
+ /**
107
+ * @param {string} align
188
108
  * @returns {LayoutOptions}
189
109
  */
190
- withShadow(shadow) {
191
- const ptr = this.__destroy_into_raw();
192
- const ret = wasm.layoutoptions_withShadow(ptr, shadow);
110
+ withAlign(align) {
111
+ const ptr0 = passStringToWasm0(align, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
112
+ const len0 = WASM_VECTOR_LEN;
113
+ const ret = wasm.layoutoptions_withAlign(this.__wbg_ptr, ptr0, len0);
114
+ return LayoutOptions.__wrap(ret);
115
+ }
116
+ /**
117
+ * @param {number} spacing
118
+ * @returns {LayoutOptions}
119
+ */
120
+ withLineSpacing(spacing) {
121
+ const ret = wasm.layoutoptions_withLineSpacing(this.__wbg_ptr, spacing);
193
122
  return LayoutOptions.__wrap(ret);
194
123
  }
195
124
  /**
@@ -197,18 +126,16 @@ class LayoutOptions {
197
126
  * @returns {LayoutOptions}
198
127
  */
199
128
  withMaxWidth(width) {
200
- const ptr = this.__destroy_into_raw();
201
- const ret = wasm.layoutoptions_withMaxWidth(ptr, width);
129
+ const ret = wasm.layoutoptions_withMaxWidth(this.__wbg_ptr, width);
202
130
  return LayoutOptions.__wrap(ret);
203
131
  }
204
132
  /**
205
- * @param {number} size
133
+ * @param {boolean} shadow
134
+ * @returns {LayoutOptions}
206
135
  */
207
- constructor(size) {
208
- const ret = wasm.layoutoptions_new(size);
209
- this.__wbg_ptr = ret >>> 0;
210
- LayoutOptionsFinalization.register(this, this.__wbg_ptr, this);
211
- return this;
136
+ withShadow(shadow) {
137
+ const ret = wasm.layoutoptions_withShadow(this.__wbg_ptr, shadow);
138
+ return LayoutOptions.__wrap(ret);
212
139
  }
213
140
  }
214
141
  if (Symbol.dispose) LayoutOptions.prototype[Symbol.dispose] = LayoutOptions.prototype.free;
@@ -232,6 +159,38 @@ class MCText {
232
159
  const ptr = this.__destroy_into_raw();
233
160
  wasm.__wbg_mctext_free(ptr, 0);
234
161
  }
162
+ /**
163
+ * @param {MCText} other
164
+ * @returns {MCText}
165
+ */
166
+ concat(other) {
167
+ _assertClass(other, MCText);
168
+ const ret = wasm.mctext_concat(this.__wbg_ptr, other.__wbg_ptr);
169
+ return MCText.__wrap(ret);
170
+ }
171
+ /**
172
+ * @returns {boolean}
173
+ */
174
+ isEmpty() {
175
+ const ret = wasm.mctext_isEmpty(this.__wbg_ptr);
176
+ return ret !== 0;
177
+ }
178
+ constructor() {
179
+ const ret = wasm.mctext_new();
180
+ this.__wbg_ptr = ret >>> 0;
181
+ MCTextFinalization.register(this, this.__wbg_ptr, this);
182
+ return this;
183
+ }
184
+ /**
185
+ * @param {string} text
186
+ * @returns {MCText}
187
+ */
188
+ static parse(text) {
189
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
190
+ const len0 = WASM_VECTOR_LEN;
191
+ const ret = wasm.mctext_parse(ptr0, len0);
192
+ return MCText.__wrap(ret);
193
+ }
235
194
  /**
236
195
  * @param {string} json
237
196
  * @returns {MCText}
@@ -260,12 +219,6 @@ class MCText {
260
219
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
261
220
  }
262
221
  }
263
- constructor() {
264
- const ret = wasm.mctext_new();
265
- this.__wbg_ptr = ret >>> 0;
266
- MCTextFinalization.register(this, this.__wbg_ptr, this);
267
- return this;
268
- }
269
222
  /**
270
223
  * @param {string} text
271
224
  * @returns {SpanBuilder}
@@ -277,16 +230,6 @@ class MCText {
277
230
  const ret = wasm.mctext_span(ptr, ptr0, len0);
278
231
  return SpanBuilder.__wrap(ret);
279
232
  }
280
- /**
281
- * @param {string} text
282
- * @returns {MCText}
283
- */
284
- static parse(text) {
285
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
286
- const len0 = WASM_VECTOR_LEN;
287
- const ret = wasm.mctext_parse(ptr0, len0);
288
- return MCText.__wrap(ret);
289
- }
290
233
  /**
291
234
  * @returns {any}
292
235
  */
@@ -358,15 +301,15 @@ class RenderResult {
358
301
  /**
359
302
  * @returns {number}
360
303
  */
361
- width() {
362
- const ret = wasm.renderresult_width(this.__wbg_ptr);
304
+ height() {
305
+ const ret = wasm.renderresult_height(this.__wbg_ptr);
363
306
  return ret >>> 0;
364
307
  }
365
308
  /**
366
309
  * @returns {number}
367
310
  */
368
- height() {
369
- const ret = wasm.renderresult_height(this.__wbg_ptr);
311
+ width() {
312
+ const ret = wasm.renderresult_width(this.__wbg_ptr);
370
313
  return ret >>> 0;
371
314
  }
372
315
  }
@@ -394,71 +337,71 @@ class SpanBuilder {
394
337
  /**
395
338
  * @returns {SpanBuilder}
396
339
  */
397
- obfuscated() {
340
+ bold() {
398
341
  const ptr = this.__destroy_into_raw();
399
- const ret = wasm.spanbuilder_obfuscated(ptr);
342
+ const ret = wasm.spanbuilder_bold(ptr);
400
343
  return SpanBuilder.__wrap(ret);
401
344
  }
402
345
  /**
403
- * @returns {SpanBuilder}
346
+ * @returns {MCText}
404
347
  */
405
- underlined() {
348
+ build() {
406
349
  const ptr = this.__destroy_into_raw();
407
- const ret = wasm.spanbuilder_underlined(ptr);
408
- return SpanBuilder.__wrap(ret);
350
+ const ret = wasm.spanbuilder_build(ptr);
351
+ return MCText.__wrap(ret);
409
352
  }
410
353
  /**
354
+ * @param {string} color
411
355
  * @returns {SpanBuilder}
412
356
  */
413
- strikethrough() {
357
+ color(color) {
414
358
  const ptr = this.__destroy_into_raw();
415
- const ret = wasm.spanbuilder_strikethrough(ptr);
359
+ const ptr0 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
360
+ const len0 = WASM_VECTOR_LEN;
361
+ const ret = wasm.spanbuilder_color(ptr, ptr0, len0);
416
362
  return SpanBuilder.__wrap(ret);
417
363
  }
418
364
  /**
419
365
  * @returns {SpanBuilder}
420
366
  */
421
- bold() {
367
+ italic() {
422
368
  const ptr = this.__destroy_into_raw();
423
- const ret = wasm.spanbuilder_bold(ptr);
369
+ const ret = wasm.spanbuilder_italic(ptr);
424
370
  return SpanBuilder.__wrap(ret);
425
371
  }
426
372
  /**
427
- * @param {string} text
428
373
  * @returns {SpanBuilder}
429
374
  */
430
- then(text) {
375
+ obfuscated() {
431
376
  const ptr = this.__destroy_into_raw();
432
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
433
- const len0 = WASM_VECTOR_LEN;
434
- const ret = wasm.spanbuilder_then(ptr, ptr0, len0);
377
+ const ret = wasm.spanbuilder_obfuscated(ptr);
435
378
  return SpanBuilder.__wrap(ret);
436
379
  }
437
380
  /**
438
- * @returns {MCText}
381
+ * @returns {SpanBuilder}
439
382
  */
440
- build() {
383
+ strikethrough() {
441
384
  const ptr = this.__destroy_into_raw();
442
- const ret = wasm.spanbuilder_build(ptr);
443
- return MCText.__wrap(ret);
385
+ const ret = wasm.spanbuilder_strikethrough(ptr);
386
+ return SpanBuilder.__wrap(ret);
444
387
  }
445
388
  /**
446
- * @param {string} color
389
+ * @param {string} text
447
390
  * @returns {SpanBuilder}
448
391
  */
449
- color(color) {
392
+ then(text) {
450
393
  const ptr = this.__destroy_into_raw();
451
- const ptr0 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
394
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
452
395
  const len0 = WASM_VECTOR_LEN;
453
- const ret = wasm.spanbuilder_color(ptr, ptr0, len0);
396
+ const ret = wasm.spanbuilder_then(ptr, ptr0, len0);
454
397
  return SpanBuilder.__wrap(ret);
455
398
  }
456
399
  /**
457
400
  * @returns {SpanBuilder}
458
401
  */
459
- italic() {
402
+ underlined() {
460
403
  const ptr = this.__destroy_into_raw();
461
- const ret = wasm.spanbuilder_italic(ptr);
404
+ const ret = wasm.spanbuilder_underlined(ptr);
462
405
  return SpanBuilder.__wrap(ret);
463
406
  }
464
407
  }
@@ -503,6 +446,24 @@ function render(font_system, text, width, height, options) {
503
446
  }
504
447
  exports.render = render;
505
448
 
449
+ /**
450
+ * @param {FontSystem} font_system
451
+ * @param {string} text
452
+ * @param {number} width
453
+ * @param {number} height
454
+ * @param {number} size
455
+ * @param {FontFamily} family
456
+ * @returns {RenderResult}
457
+ */
458
+ function renderFamily(font_system, text, width, height, size, family) {
459
+ _assertClass(font_system, FontSystem);
460
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
461
+ const len0 = WASM_VECTOR_LEN;
462
+ const ret = wasm.renderFamily(font_system.__wbg_ptr, ptr0, len0, width, height, size, family);
463
+ return RenderResult.__wrap(ret);
464
+ }
465
+ exports.renderFamily = renderFamily;
466
+
506
467
  /**
507
468
  * @param {string} text
508
469
  * @returns {string}
@@ -523,90 +484,203 @@ function stripCodes(text) {
523
484
  }
524
485
  exports.stripCodes = stripCodes;
525
486
 
526
- exports.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
527
- const ret = Error(getStringFromWasm0(arg0, arg1));
528
- return ret;
529
- };
487
+ function __wbg_get_imports() {
488
+ const import0 = {
489
+ __proto__: null,
490
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
491
+ const ret = Error(getStringFromWasm0(arg0, arg1));
492
+ return ret;
493
+ },
494
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
495
+ const ret = typeof(arg0) === 'string';
496
+ return ret;
497
+ },
498
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
499
+ throw new Error(getStringFromWasm0(arg0, arg1));
500
+ },
501
+ __wbg_fromCodePoint_22365db7b7d6ac39: function() { return handleError(function (arg0) {
502
+ const ret = String.fromCodePoint(arg0 >>> 0);
503
+ return ret;
504
+ }, arguments); },
505
+ __wbg_new_361308b2356cecd0: function() {
506
+ const ret = new Object();
507
+ return ret;
508
+ },
509
+ __wbg_new_3eb36ae241fe6f44: function() {
510
+ const ret = new Array();
511
+ return ret;
512
+ },
513
+ __wbg_new_dca287b076112a51: function() {
514
+ const ret = new Map();
515
+ return ret;
516
+ },
517
+ __wbg_set_1eb0999cf5d27fc8: function(arg0, arg1, arg2) {
518
+ const ret = arg0.set(arg1, arg2);
519
+ return ret;
520
+ },
521
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
522
+ arg0[arg1] = arg2;
523
+ },
524
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
525
+ arg0[arg1 >>> 0] = arg2;
526
+ },
527
+ __wbindgen_cast_0000000000000001: function(arg0) {
528
+ // Cast intrinsic for `F64 -> Externref`.
529
+ const ret = arg0;
530
+ return ret;
531
+ },
532
+ __wbindgen_cast_0000000000000002: function(arg0) {
533
+ // Cast intrinsic for `I64 -> Externref`.
534
+ const ret = arg0;
535
+ return ret;
536
+ },
537
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
538
+ // Cast intrinsic for `Ref(String) -> Externref`.
539
+ const ret = getStringFromWasm0(arg0, arg1);
540
+ return ret;
541
+ },
542
+ __wbindgen_cast_0000000000000004: function(arg0) {
543
+ // Cast intrinsic for `U64 -> Externref`.
544
+ const ret = BigInt.asUintN(64, arg0);
545
+ return ret;
546
+ },
547
+ __wbindgen_init_externref_table: function() {
548
+ const table = wasm.__wbindgen_externrefs;
549
+ const offset = table.grow(4);
550
+ table.set(0, undefined);
551
+ table.set(offset + 0, undefined);
552
+ table.set(offset + 1, null);
553
+ table.set(offset + 2, true);
554
+ table.set(offset + 3, false);
555
+ },
556
+ };
557
+ return {
558
+ __proto__: null,
559
+ "./mctext_wasm_bg.js": import0,
560
+ };
561
+ }
530
562
 
531
- exports.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
532
- const ret = typeof(arg0) === 'string';
533
- return ret;
534
- };
563
+ const FontSystemFinalization = (typeof FinalizationRegistry === 'undefined')
564
+ ? { register: () => {}, unregister: () => {} }
565
+ : new FinalizationRegistry(ptr => wasm.__wbg_fontsystem_free(ptr >>> 0, 1));
566
+ const LayoutOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
567
+ ? { register: () => {}, unregister: () => {} }
568
+ : new FinalizationRegistry(ptr => wasm.__wbg_layoutoptions_free(ptr >>> 0, 1));
569
+ const MCTextFinalization = (typeof FinalizationRegistry === 'undefined')
570
+ ? { register: () => {}, unregister: () => {} }
571
+ : new FinalizationRegistry(ptr => wasm.__wbg_mctext_free(ptr >>> 0, 1));
572
+ const RenderResultFinalization = (typeof FinalizationRegistry === 'undefined')
573
+ ? { register: () => {}, unregister: () => {} }
574
+ : new FinalizationRegistry(ptr => wasm.__wbg_renderresult_free(ptr >>> 0, 1));
575
+ const SpanBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
576
+ ? { register: () => {}, unregister: () => {} }
577
+ : new FinalizationRegistry(ptr => wasm.__wbg_spanbuilder_free(ptr >>> 0, 1));
535
578
 
536
- exports.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
537
- throw new Error(getStringFromWasm0(arg0, arg1));
538
- };
579
+ function addToExternrefTable0(obj) {
580
+ const idx = wasm.__externref_table_alloc();
581
+ wasm.__wbindgen_externrefs.set(idx, obj);
582
+ return idx;
583
+ }
539
584
 
540
- exports.__wbg_fromCodePoint_50facac709b76f67 = function() { return handleError(function (arg0) {
541
- const ret = String.fromCodePoint(arg0 >>> 0);
542
- return ret;
543
- }, arguments) };
585
+ function _assertClass(instance, klass) {
586
+ if (!(instance instanceof klass)) {
587
+ throw new Error(`expected instance of ${klass.name}`);
588
+ }
589
+ }
544
590
 
545
- exports.__wbg_new_1ba21ce319a06297 = function() {
546
- const ret = new Object();
547
- return ret;
548
- };
591
+ function getArrayU8FromWasm0(ptr, len) {
592
+ ptr = ptr >>> 0;
593
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
594
+ }
549
595
 
550
- exports.__wbg_new_25f239778d6112b9 = function() {
551
- const ret = new Array();
552
- return ret;
553
- };
596
+ function getStringFromWasm0(ptr, len) {
597
+ ptr = ptr >>> 0;
598
+ return decodeText(ptr, len);
599
+ }
554
600
 
555
- exports.__wbg_new_b546ae120718850e = function() {
556
- const ret = new Map();
557
- return ret;
558
- };
601
+ let cachedUint8ArrayMemory0 = null;
602
+ function getUint8ArrayMemory0() {
603
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
604
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
605
+ }
606
+ return cachedUint8ArrayMemory0;
607
+ }
559
608
 
560
- exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
561
- arg0[arg1] = arg2;
562
- };
609
+ function handleError(f, args) {
610
+ try {
611
+ return f.apply(this, args);
612
+ } catch (e) {
613
+ const idx = addToExternrefTable0(e);
614
+ wasm.__wbindgen_exn_store(idx);
615
+ }
616
+ }
563
617
 
564
- exports.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
565
- arg0[arg1 >>> 0] = arg2;
566
- };
618
+ function passStringToWasm0(arg, malloc, realloc) {
619
+ if (realloc === undefined) {
620
+ const buf = cachedTextEncoder.encode(arg);
621
+ const ptr = malloc(buf.length, 1) >>> 0;
622
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
623
+ WASM_VECTOR_LEN = buf.length;
624
+ return ptr;
625
+ }
567
626
 
568
- exports.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
569
- const ret = arg0.set(arg1, arg2);
570
- return ret;
571
- };
627
+ let len = arg.length;
628
+ let ptr = malloc(len, 1) >>> 0;
572
629
 
573
- exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
574
- // Cast intrinsic for `Ref(String) -> Externref`.
575
- const ret = getStringFromWasm0(arg0, arg1);
576
- return ret;
577
- };
630
+ const mem = getUint8ArrayMemory0();
578
631
 
579
- exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
580
- // Cast intrinsic for `U64 -> Externref`.
581
- const ret = BigInt.asUintN(64, arg0);
582
- return ret;
583
- };
632
+ let offset = 0;
584
633
 
585
- exports.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
586
- // Cast intrinsic for `I64 -> Externref`.
587
- const ret = arg0;
588
- return ret;
589
- };
634
+ for (; offset < len; offset++) {
635
+ const code = arg.charCodeAt(offset);
636
+ if (code > 0x7F) break;
637
+ mem[ptr + offset] = code;
638
+ }
639
+ if (offset !== len) {
640
+ if (offset !== 0) {
641
+ arg = arg.slice(offset);
642
+ }
643
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
644
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
645
+ const ret = cachedTextEncoder.encodeInto(arg, view);
590
646
 
591
- exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
592
- // Cast intrinsic for `F64 -> Externref`.
593
- const ret = arg0;
594
- return ret;
595
- };
596
-
597
- exports.__wbindgen_init_externref_table = function() {
598
- const table = wasm.__wbindgen_externrefs;
599
- const offset = table.grow(4);
600
- table.set(0, undefined);
601
- table.set(offset + 0, undefined);
602
- table.set(offset + 1, null);
603
- table.set(offset + 2, true);
604
- table.set(offset + 3, false);
605
- };
647
+ offset += ret.written;
648
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
649
+ }
650
+
651
+ WASM_VECTOR_LEN = offset;
652
+ return ptr;
653
+ }
654
+
655
+ function takeFromExternrefTable0(idx) {
656
+ const value = wasm.__wbindgen_externrefs.get(idx);
657
+ wasm.__externref_table_dealloc(idx);
658
+ return value;
659
+ }
660
+
661
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
662
+ cachedTextDecoder.decode();
663
+ function decodeText(ptr, len) {
664
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
665
+ }
666
+
667
+ const cachedTextEncoder = new TextEncoder();
668
+
669
+ if (!('encodeInto' in cachedTextEncoder)) {
670
+ cachedTextEncoder.encodeInto = function (arg, view) {
671
+ const buf = cachedTextEncoder.encode(arg);
672
+ view.set(buf);
673
+ return {
674
+ read: arg.length,
675
+ written: buf.length
676
+ };
677
+ };
678
+ }
679
+
680
+ let WASM_VECTOR_LEN = 0;
606
681
 
607
682
  const wasmPath = `${__dirname}/mctext_wasm_bg.wasm`;
608
683
  const wasmBytes = require('fs').readFileSync(wasmPath);
609
684
  const wasmModule = new WebAssembly.Module(wasmBytes);
610
- const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
611
-
685
+ const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
612
686
  wasm.__wbindgen_start();
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hexze/mctext",
3
3
  "description": "Minecraft text formatting for JavaScript/WASM",
4
- "version": "1.1.5",
4
+ "version": "1.3.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",