@hexze/mctext 1.1.5 → 1.2.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
@@ -2,55 +2,55 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  export class FontSystem {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
8
- static modern(): FontSystem;
9
- measure(text: string, size: number): number;
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ measure(text: string, size: number): number;
9
+ static modern(): FontSystem;
10
10
  }
11
11
 
12
12
  export class LayoutOptions {
13
- free(): void;
14
- [Symbol.dispose](): void;
15
- withShadow(shadow: boolean): LayoutOptions;
16
- withMaxWidth(width: number): LayoutOptions;
17
- constructor(size: number);
13
+ free(): void;
14
+ [Symbol.dispose](): void;
15
+ constructor(size: number);
16
+ withMaxWidth(width: number): LayoutOptions;
17
+ withShadow(shadow: boolean): LayoutOptions;
18
18
  }
19
19
 
20
20
  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;
21
+ free(): void;
22
+ [Symbol.dispose](): void;
23
+ constructor();
24
+ static parse(text: string): MCText;
25
+ static parseJson(json: string): MCText;
26
+ plainText(): string;
27
+ span(text: string): SpanBuilder;
28
+ spans(): any;
29
+ toJson(): string;
30
+ toLegacy(): string;
31
31
  }
32
32
 
33
33
  export class RenderResult {
34
- private constructor();
35
- free(): void;
36
- [Symbol.dispose](): void;
37
- data(): Uint8Array;
38
- width(): number;
39
- height(): number;
34
+ private constructor();
35
+ free(): void;
36
+ [Symbol.dispose](): void;
37
+ data(): Uint8Array;
38
+ height(): number;
39
+ width(): number;
40
40
  }
41
41
 
42
42
  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;
43
+ private constructor();
44
+ free(): void;
45
+ [Symbol.dispose](): void;
46
+ bold(): SpanBuilder;
47
+ build(): MCText;
48
+ color(color: string): SpanBuilder;
49
+ italic(): SpanBuilder;
50
+ obfuscated(): SpanBuilder;
51
+ strikethrough(): SpanBuilder;
52
+ then(text: string): SpanBuilder;
53
+ underlined(): SpanBuilder;
54
54
  }
55
55
 
56
56
  export function countVisibleChars(text: string): number;
package/mctext_wasm.js CHANGED
@@ -1,129 +1,4 @@
1
-
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));
1
+ /* @ts-self-types="./mctext_wasm.d.ts" */
127
2
 
128
3
  class FontSystem {
129
4
  static __wrap(ptr) {
@@ -143,13 +18,6 @@ class FontSystem {
143
18
  const ptr = this.__destroy_into_raw();
144
19
  wasm.__wbg_fontsystem_free(ptr, 0);
145
20
  }
146
- /**
147
- * @returns {FontSystem}
148
- */
149
- static modern() {
150
- const ret = wasm.fontsystem_modern();
151
- return FontSystem.__wrap(ret);
152
- }
153
21
  /**
154
22
  * @param {string} text
155
23
  * @param {number} size
@@ -161,6 +29,13 @@ class FontSystem {
161
29
  const ret = wasm.fontsystem_measure(this.__wbg_ptr, ptr0, len0, size);
162
30
  return ret;
163
31
  }
32
+ /**
33
+ * @returns {FontSystem}
34
+ */
35
+ static modern() {
36
+ const ret = wasm.fontsystem_modern();
37
+ return FontSystem.__wrap(ret);
38
+ }
164
39
  }
165
40
  if (Symbol.dispose) FontSystem.prototype[Symbol.dispose] = FontSystem.prototype.free;
166
41
  exports.FontSystem = FontSystem;
@@ -184,13 +59,13 @@ class LayoutOptions {
184
59
  wasm.__wbg_layoutoptions_free(ptr, 0);
185
60
  }
186
61
  /**
187
- * @param {boolean} shadow
188
- * @returns {LayoutOptions}
62
+ * @param {number} size
189
63
  */
190
- withShadow(shadow) {
191
- const ptr = this.__destroy_into_raw();
192
- const ret = wasm.layoutoptions_withShadow(ptr, shadow);
193
- return LayoutOptions.__wrap(ret);
64
+ constructor(size) {
65
+ const ret = wasm.layoutoptions_new(size);
66
+ this.__wbg_ptr = ret >>> 0;
67
+ LayoutOptionsFinalization.register(this, this.__wbg_ptr, this);
68
+ return this;
194
69
  }
195
70
  /**
196
71
  * @param {number} width
@@ -202,13 +77,13 @@ class LayoutOptions {
202
77
  return LayoutOptions.__wrap(ret);
203
78
  }
204
79
  /**
205
- * @param {number} size
80
+ * @param {boolean} shadow
81
+ * @returns {LayoutOptions}
206
82
  */
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;
83
+ withShadow(shadow) {
84
+ const ptr = this.__destroy_into_raw();
85
+ const ret = wasm.layoutoptions_withShadow(ptr, shadow);
86
+ return LayoutOptions.__wrap(ret);
212
87
  }
213
88
  }
214
89
  if (Symbol.dispose) LayoutOptions.prototype[Symbol.dispose] = LayoutOptions.prototype.free;
@@ -232,6 +107,22 @@ class MCText {
232
107
  const ptr = this.__destroy_into_raw();
233
108
  wasm.__wbg_mctext_free(ptr, 0);
234
109
  }
110
+ constructor() {
111
+ const ret = wasm.mctext_new();
112
+ this.__wbg_ptr = ret >>> 0;
113
+ MCTextFinalization.register(this, this.__wbg_ptr, this);
114
+ return this;
115
+ }
116
+ /**
117
+ * @param {string} text
118
+ * @returns {MCText}
119
+ */
120
+ static parse(text) {
121
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
122
+ const len0 = WASM_VECTOR_LEN;
123
+ const ret = wasm.mctext_parse(ptr0, len0);
124
+ return MCText.__wrap(ret);
125
+ }
235
126
  /**
236
127
  * @param {string} json
237
128
  * @returns {MCText}
@@ -260,12 +151,6 @@ class MCText {
260
151
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
261
152
  }
262
153
  }
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
154
  /**
270
155
  * @param {string} text
271
156
  * @returns {SpanBuilder}
@@ -277,16 +162,6 @@ class MCText {
277
162
  const ret = wasm.mctext_span(ptr, ptr0, len0);
278
163
  return SpanBuilder.__wrap(ret);
279
164
  }
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
165
  /**
291
166
  * @returns {any}
292
167
  */
@@ -358,15 +233,15 @@ class RenderResult {
358
233
  /**
359
234
  * @returns {number}
360
235
  */
361
- width() {
362
- const ret = wasm.renderresult_width(this.__wbg_ptr);
236
+ height() {
237
+ const ret = wasm.renderresult_height(this.__wbg_ptr);
363
238
  return ret >>> 0;
364
239
  }
365
240
  /**
366
241
  * @returns {number}
367
242
  */
368
- height() {
369
- const ret = wasm.renderresult_height(this.__wbg_ptr);
243
+ width() {
244
+ const ret = wasm.renderresult_width(this.__wbg_ptr);
370
245
  return ret >>> 0;
371
246
  }
372
247
  }
@@ -394,71 +269,71 @@ class SpanBuilder {
394
269
  /**
395
270
  * @returns {SpanBuilder}
396
271
  */
397
- obfuscated() {
272
+ bold() {
398
273
  const ptr = this.__destroy_into_raw();
399
- const ret = wasm.spanbuilder_obfuscated(ptr);
274
+ const ret = wasm.spanbuilder_bold(ptr);
400
275
  return SpanBuilder.__wrap(ret);
401
276
  }
402
277
  /**
403
- * @returns {SpanBuilder}
278
+ * @returns {MCText}
404
279
  */
405
- underlined() {
280
+ build() {
406
281
  const ptr = this.__destroy_into_raw();
407
- const ret = wasm.spanbuilder_underlined(ptr);
408
- return SpanBuilder.__wrap(ret);
282
+ const ret = wasm.spanbuilder_build(ptr);
283
+ return MCText.__wrap(ret);
409
284
  }
410
285
  /**
286
+ * @param {string} color
411
287
  * @returns {SpanBuilder}
412
288
  */
413
- strikethrough() {
289
+ color(color) {
414
290
  const ptr = this.__destroy_into_raw();
415
- const ret = wasm.spanbuilder_strikethrough(ptr);
291
+ const ptr0 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ret = wasm.spanbuilder_color(ptr, ptr0, len0);
416
294
  return SpanBuilder.__wrap(ret);
417
295
  }
418
296
  /**
419
297
  * @returns {SpanBuilder}
420
298
  */
421
- bold() {
299
+ italic() {
422
300
  const ptr = this.__destroy_into_raw();
423
- const ret = wasm.spanbuilder_bold(ptr);
301
+ const ret = wasm.spanbuilder_italic(ptr);
424
302
  return SpanBuilder.__wrap(ret);
425
303
  }
426
304
  /**
427
- * @param {string} text
428
305
  * @returns {SpanBuilder}
429
306
  */
430
- then(text) {
307
+ obfuscated() {
431
308
  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);
309
+ const ret = wasm.spanbuilder_obfuscated(ptr);
435
310
  return SpanBuilder.__wrap(ret);
436
311
  }
437
312
  /**
438
- * @returns {MCText}
313
+ * @returns {SpanBuilder}
439
314
  */
440
- build() {
315
+ strikethrough() {
441
316
  const ptr = this.__destroy_into_raw();
442
- const ret = wasm.spanbuilder_build(ptr);
443
- return MCText.__wrap(ret);
317
+ const ret = wasm.spanbuilder_strikethrough(ptr);
318
+ return SpanBuilder.__wrap(ret);
444
319
  }
445
320
  /**
446
- * @param {string} color
321
+ * @param {string} text
447
322
  * @returns {SpanBuilder}
448
323
  */
449
- color(color) {
324
+ then(text) {
450
325
  const ptr = this.__destroy_into_raw();
451
- const ptr0 = passStringToWasm0(color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
326
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
452
327
  const len0 = WASM_VECTOR_LEN;
453
- const ret = wasm.spanbuilder_color(ptr, ptr0, len0);
328
+ const ret = wasm.spanbuilder_then(ptr, ptr0, len0);
454
329
  return SpanBuilder.__wrap(ret);
455
330
  }
456
331
  /**
457
332
  * @returns {SpanBuilder}
458
333
  */
459
- italic() {
334
+ underlined() {
460
335
  const ptr = this.__destroy_into_raw();
461
- const ret = wasm.spanbuilder_italic(ptr);
336
+ const ret = wasm.spanbuilder_underlined(ptr);
462
337
  return SpanBuilder.__wrap(ret);
463
338
  }
464
339
  }
@@ -523,90 +398,203 @@ function stripCodes(text) {
523
398
  }
524
399
  exports.stripCodes = stripCodes;
525
400
 
526
- exports.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
527
- const ret = Error(getStringFromWasm0(arg0, arg1));
528
- return ret;
529
- };
401
+ function __wbg_get_imports() {
402
+ const import0 = {
403
+ __proto__: null,
404
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
405
+ const ret = Error(getStringFromWasm0(arg0, arg1));
406
+ return ret;
407
+ },
408
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
409
+ const ret = typeof(arg0) === 'string';
410
+ return ret;
411
+ },
412
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
413
+ throw new Error(getStringFromWasm0(arg0, arg1));
414
+ },
415
+ __wbg_fromCodePoint_22365db7b7d6ac39: function() { return handleError(function (arg0) {
416
+ const ret = String.fromCodePoint(arg0 >>> 0);
417
+ return ret;
418
+ }, arguments); },
419
+ __wbg_new_361308b2356cecd0: function() {
420
+ const ret = new Object();
421
+ return ret;
422
+ },
423
+ __wbg_new_3eb36ae241fe6f44: function() {
424
+ const ret = new Array();
425
+ return ret;
426
+ },
427
+ __wbg_new_dca287b076112a51: function() {
428
+ const ret = new Map();
429
+ return ret;
430
+ },
431
+ __wbg_set_1eb0999cf5d27fc8: function(arg0, arg1, arg2) {
432
+ const ret = arg0.set(arg1, arg2);
433
+ return ret;
434
+ },
435
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
436
+ arg0[arg1] = arg2;
437
+ },
438
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
439
+ arg0[arg1 >>> 0] = arg2;
440
+ },
441
+ __wbindgen_cast_0000000000000001: function(arg0) {
442
+ // Cast intrinsic for `F64 -> Externref`.
443
+ const ret = arg0;
444
+ return ret;
445
+ },
446
+ __wbindgen_cast_0000000000000002: function(arg0) {
447
+ // Cast intrinsic for `I64 -> Externref`.
448
+ const ret = arg0;
449
+ return ret;
450
+ },
451
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
452
+ // Cast intrinsic for `Ref(String) -> Externref`.
453
+ const ret = getStringFromWasm0(arg0, arg1);
454
+ return ret;
455
+ },
456
+ __wbindgen_cast_0000000000000004: function(arg0) {
457
+ // Cast intrinsic for `U64 -> Externref`.
458
+ const ret = BigInt.asUintN(64, arg0);
459
+ return ret;
460
+ },
461
+ __wbindgen_init_externref_table: function() {
462
+ const table = wasm.__wbindgen_externrefs;
463
+ const offset = table.grow(4);
464
+ table.set(0, undefined);
465
+ table.set(offset + 0, undefined);
466
+ table.set(offset + 1, null);
467
+ table.set(offset + 2, true);
468
+ table.set(offset + 3, false);
469
+ },
470
+ };
471
+ return {
472
+ __proto__: null,
473
+ "./mctext_wasm_bg.js": import0,
474
+ };
475
+ }
530
476
 
531
- exports.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
532
- const ret = typeof(arg0) === 'string';
533
- return ret;
534
- };
477
+ const FontSystemFinalization = (typeof FinalizationRegistry === 'undefined')
478
+ ? { register: () => {}, unregister: () => {} }
479
+ : new FinalizationRegistry(ptr => wasm.__wbg_fontsystem_free(ptr >>> 0, 1));
480
+ const LayoutOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
481
+ ? { register: () => {}, unregister: () => {} }
482
+ : new FinalizationRegistry(ptr => wasm.__wbg_layoutoptions_free(ptr >>> 0, 1));
483
+ const MCTextFinalization = (typeof FinalizationRegistry === 'undefined')
484
+ ? { register: () => {}, unregister: () => {} }
485
+ : new FinalizationRegistry(ptr => wasm.__wbg_mctext_free(ptr >>> 0, 1));
486
+ const RenderResultFinalization = (typeof FinalizationRegistry === 'undefined')
487
+ ? { register: () => {}, unregister: () => {} }
488
+ : new FinalizationRegistry(ptr => wasm.__wbg_renderresult_free(ptr >>> 0, 1));
489
+ const SpanBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
490
+ ? { register: () => {}, unregister: () => {} }
491
+ : new FinalizationRegistry(ptr => wasm.__wbg_spanbuilder_free(ptr >>> 0, 1));
535
492
 
536
- exports.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
537
- throw new Error(getStringFromWasm0(arg0, arg1));
538
- };
493
+ function addToExternrefTable0(obj) {
494
+ const idx = wasm.__externref_table_alloc();
495
+ wasm.__wbindgen_externrefs.set(idx, obj);
496
+ return idx;
497
+ }
539
498
 
540
- exports.__wbg_fromCodePoint_50facac709b76f67 = function() { return handleError(function (arg0) {
541
- const ret = String.fromCodePoint(arg0 >>> 0);
542
- return ret;
543
- }, arguments) };
499
+ function _assertClass(instance, klass) {
500
+ if (!(instance instanceof klass)) {
501
+ throw new Error(`expected instance of ${klass.name}`);
502
+ }
503
+ }
544
504
 
545
- exports.__wbg_new_1ba21ce319a06297 = function() {
546
- const ret = new Object();
547
- return ret;
548
- };
505
+ function getArrayU8FromWasm0(ptr, len) {
506
+ ptr = ptr >>> 0;
507
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
508
+ }
549
509
 
550
- exports.__wbg_new_25f239778d6112b9 = function() {
551
- const ret = new Array();
552
- return ret;
553
- };
510
+ function getStringFromWasm0(ptr, len) {
511
+ ptr = ptr >>> 0;
512
+ return decodeText(ptr, len);
513
+ }
554
514
 
555
- exports.__wbg_new_b546ae120718850e = function() {
556
- const ret = new Map();
557
- return ret;
558
- };
515
+ let cachedUint8ArrayMemory0 = null;
516
+ function getUint8ArrayMemory0() {
517
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
518
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
519
+ }
520
+ return cachedUint8ArrayMemory0;
521
+ }
559
522
 
560
- exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
561
- arg0[arg1] = arg2;
562
- };
523
+ function handleError(f, args) {
524
+ try {
525
+ return f.apply(this, args);
526
+ } catch (e) {
527
+ const idx = addToExternrefTable0(e);
528
+ wasm.__wbindgen_exn_store(idx);
529
+ }
530
+ }
563
531
 
564
- exports.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
565
- arg0[arg1 >>> 0] = arg2;
566
- };
532
+ function passStringToWasm0(arg, malloc, realloc) {
533
+ if (realloc === undefined) {
534
+ const buf = cachedTextEncoder.encode(arg);
535
+ const ptr = malloc(buf.length, 1) >>> 0;
536
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
537
+ WASM_VECTOR_LEN = buf.length;
538
+ return ptr;
539
+ }
567
540
 
568
- exports.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
569
- const ret = arg0.set(arg1, arg2);
570
- return ret;
571
- };
541
+ let len = arg.length;
542
+ let ptr = malloc(len, 1) >>> 0;
572
543
 
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
- };
544
+ const mem = getUint8ArrayMemory0();
578
545
 
579
- exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
580
- // Cast intrinsic for `U64 -> Externref`.
581
- const ret = BigInt.asUintN(64, arg0);
582
- return ret;
583
- };
546
+ let offset = 0;
584
547
 
585
- exports.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
586
- // Cast intrinsic for `I64 -> Externref`.
587
- const ret = arg0;
588
- return ret;
589
- };
548
+ for (; offset < len; offset++) {
549
+ const code = arg.charCodeAt(offset);
550
+ if (code > 0x7F) break;
551
+ mem[ptr + offset] = code;
552
+ }
553
+ if (offset !== len) {
554
+ if (offset !== 0) {
555
+ arg = arg.slice(offset);
556
+ }
557
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
558
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
559
+ const ret = cachedTextEncoder.encodeInto(arg, view);
590
560
 
591
- exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
592
- // Cast intrinsic for `F64 -> Externref`.
593
- const ret = arg0;
594
- return ret;
595
- };
561
+ offset += ret.written;
562
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
563
+ }
564
+
565
+ WASM_VECTOR_LEN = offset;
566
+ return ptr;
567
+ }
568
+
569
+ function takeFromExternrefTable0(idx) {
570
+ const value = wasm.__wbindgen_externrefs.get(idx);
571
+ wasm.__externref_table_dealloc(idx);
572
+ return value;
573
+ }
574
+
575
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
576
+ cachedTextDecoder.decode();
577
+ function decodeText(ptr, len) {
578
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
579
+ }
596
580
 
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
- };
581
+ const cachedTextEncoder = new TextEncoder();
582
+
583
+ if (!('encodeInto' in cachedTextEncoder)) {
584
+ cachedTextEncoder.encodeInto = function (arg, view) {
585
+ const buf = cachedTextEncoder.encode(arg);
586
+ view.set(buf);
587
+ return {
588
+ read: arg.length,
589
+ written: buf.length
590
+ };
591
+ };
592
+ }
593
+
594
+ let WASM_VECTOR_LEN = 0;
606
595
 
607
596
  const wasmPath = `${__dirname}/mctext_wasm_bg.wasm`;
608
597
  const wasmBytes = require('fs').readFileSync(wasmPath);
609
598
  const wasmModule = new WebAssembly.Module(wasmBytes);
610
- const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
611
-
599
+ const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
612
600
  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.2.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",