@blit-sh/browser 0.17.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.
@@ -0,0 +1,143 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class Terminal {
5
+ free(): void;
6
+ [Symbol.dispose](): void;
7
+ app_cursor(): boolean;
8
+ /**
9
+ * Length of background vertex data (in f32 elements).
10
+ */
11
+ bg_verts_len(): number;
12
+ /**
13
+ * Pointer to ready-to-upload background vertex data (f32).
14
+ */
15
+ bg_verts_ptr(): number;
16
+ bracketed_paste(): boolean;
17
+ /**
18
+ * DECSCUSR cursor style: 0=default, 1=blinking block, 2=steady block,
19
+ * 3=blinking underline, 4=steady underline, 5=blinking bar, 6=steady bar.
20
+ */
21
+ cursor_style(): number;
22
+ cursor_visible(): boolean;
23
+ echo(): boolean;
24
+ feed_compressed(data: Uint8Array): void;
25
+ feed_compressed_batch(batch: Uint8Array): void;
26
+ get_html(start_row: number, start_col: number, end_row: number, end_col: number): string;
27
+ get_text(start_row: number, start_col: number, end_row: number, end_col: number): string;
28
+ glyph_atlas_canvas(): HTMLCanvasElement | undefined;
29
+ glyph_atlas_version(): number;
30
+ /**
31
+ * Length of glyph vertex data (in f32 elements).
32
+ */
33
+ glyph_verts_len(): number;
34
+ /**
35
+ * Pointer to ready-to-upload glyph vertex data (f32).
36
+ */
37
+ glyph_verts_ptr(): number;
38
+ icanon(): boolean;
39
+ invalidate_render_cache(): void;
40
+ /**
41
+ * Returns true if the given row wraps to the next (is part of a longer logical line).
42
+ */
43
+ is_wrapped(row: number): boolean;
44
+ mouse_encoding(): number;
45
+ mouse_mode(): number;
46
+ constructor(rows: number, cols: number, cell_width: number, cell_height: number);
47
+ overflow_text_count(): number;
48
+ /**
49
+ * Returns overflow text op at index: (row, col, col_span, text).
50
+ */
51
+ overflow_text_op(index: number): any;
52
+ prepare_render_ops(): void;
53
+ scrollback_lines(): number;
54
+ set_ansi_color(idx: number, r: number, g: number, b: number): void;
55
+ set_cell_size(cell_width: number, cell_height: number): void;
56
+ set_default_colors(fg_r: number, fg_g: number, fg_b: number, bg_r: number, bg_g: number, bg_b: number): void;
57
+ set_font_family(font_family: string): void;
58
+ set_font_size(font_size: number): void;
59
+ set_render_offset(x: number, y: number): void;
60
+ title(): string;
61
+ readonly cols: number;
62
+ readonly cursor_col: number;
63
+ readonly cursor_row: number;
64
+ readonly rows: number;
65
+ }
66
+
67
+ /**
68
+ * Expose WASM linear memory for zero-copy typed array views.
69
+ */
70
+ export function wasm_memory(): any;
71
+
72
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
73
+
74
+ export interface InitOutput {
75
+ readonly memory: WebAssembly.Memory;
76
+ readonly __wbg_terminal_free: (a: number, b: number) => void;
77
+ readonly terminal_app_cursor: (a: number) => number;
78
+ readonly terminal_bg_verts_len: (a: number) => number;
79
+ readonly terminal_bg_verts_ptr: (a: number) => number;
80
+ readonly terminal_bracketed_paste: (a: number) => number;
81
+ readonly terminal_cols: (a: number) => number;
82
+ readonly terminal_cursor_col: (a: number) => number;
83
+ readonly terminal_cursor_row: (a: number) => number;
84
+ readonly terminal_cursor_style: (a: number) => number;
85
+ readonly terminal_cursor_visible: (a: number) => number;
86
+ readonly terminal_echo: (a: number) => number;
87
+ readonly terminal_feed_compressed: (a: number, b: number, c: number) => void;
88
+ readonly terminal_feed_compressed_batch: (a: number, b: number, c: number) => void;
89
+ readonly terminal_get_html: (a: number, b: number, c: number, d: number, e: number) => [number, number];
90
+ readonly terminal_get_text: (a: number, b: number, c: number, d: number, e: number) => [number, number];
91
+ readonly terminal_glyph_atlas_canvas: (a: number) => any;
92
+ readonly terminal_glyph_atlas_version: (a: number) => number;
93
+ readonly terminal_glyph_verts_len: (a: number) => number;
94
+ readonly terminal_glyph_verts_ptr: (a: number) => number;
95
+ readonly terminal_icanon: (a: number) => number;
96
+ readonly terminal_invalidate_render_cache: (a: number) => void;
97
+ readonly terminal_is_wrapped: (a: number, b: number) => number;
98
+ readonly terminal_mouse_encoding: (a: number) => number;
99
+ readonly terminal_mouse_mode: (a: number) => number;
100
+ readonly terminal_new: (a: number, b: number, c: number, d: number) => number;
101
+ readonly terminal_overflow_text_count: (a: number) => number;
102
+ readonly terminal_overflow_text_op: (a: number, b: number) => any;
103
+ readonly terminal_prepare_render_ops: (a: number) => void;
104
+ readonly terminal_rows: (a: number) => number;
105
+ readonly terminal_scrollback_lines: (a: number) => number;
106
+ readonly terminal_set_ansi_color: (a: number, b: number, c: number, d: number, e: number) => void;
107
+ readonly terminal_set_cell_size: (a: number, b: number, c: number) => void;
108
+ readonly terminal_set_default_colors: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
109
+ readonly terminal_set_font_family: (a: number, b: number, c: number) => void;
110
+ readonly terminal_set_font_size: (a: number, b: number) => void;
111
+ readonly terminal_set_render_offset: (a: number, b: number, c: number) => void;
112
+ readonly terminal_title: (a: number) => [number, number];
113
+ readonly wasm_memory: () => any;
114
+ readonly __wbindgen_exn_store: (a: number) => void;
115
+ readonly __externref_table_alloc: () => number;
116
+ readonly __wbindgen_externrefs: WebAssembly.Table;
117
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
118
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
119
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
120
+ readonly __wbindgen_start: () => void;
121
+ }
122
+
123
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
124
+
125
+ /**
126
+ * Instantiates the given `module`, which can either be bytes or
127
+ * a precompiled `WebAssembly.Module`.
128
+ *
129
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
130
+ *
131
+ * @returns {InitOutput}
132
+ */
133
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
134
+
135
+ /**
136
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
137
+ * for everything else, calls `WebAssembly.instantiate` directly.
138
+ *
139
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
140
+ *
141
+ * @returns {Promise<InitOutput>}
142
+ */
143
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,683 @@
1
+ /* @ts-self-types="./blit_browser.d.ts" */
2
+ import { blitFillTextCodePoint, blitFillTextStretched } from './snippets/blit-browser-dc72b20da624ccea/inline0.js';
3
+
4
+ export class Terminal {
5
+ __destroy_into_raw() {
6
+ const ptr = this.__wbg_ptr;
7
+ this.__wbg_ptr = 0;
8
+ TerminalFinalization.unregister(this);
9
+ return ptr;
10
+ }
11
+ free() {
12
+ const ptr = this.__destroy_into_raw();
13
+ wasm.__wbg_terminal_free(ptr, 0);
14
+ }
15
+ /**
16
+ * @returns {boolean}
17
+ */
18
+ app_cursor() {
19
+ const ret = wasm.terminal_app_cursor(this.__wbg_ptr);
20
+ return ret !== 0;
21
+ }
22
+ /**
23
+ * Length of background vertex data (in f32 elements).
24
+ * @returns {number}
25
+ */
26
+ bg_verts_len() {
27
+ const ret = wasm.terminal_bg_verts_len(this.__wbg_ptr);
28
+ return ret >>> 0;
29
+ }
30
+ /**
31
+ * Pointer to ready-to-upload background vertex data (f32).
32
+ * @returns {number}
33
+ */
34
+ bg_verts_ptr() {
35
+ const ret = wasm.terminal_bg_verts_ptr(this.__wbg_ptr);
36
+ return ret >>> 0;
37
+ }
38
+ /**
39
+ * @returns {boolean}
40
+ */
41
+ bracketed_paste() {
42
+ const ret = wasm.terminal_bracketed_paste(this.__wbg_ptr);
43
+ return ret !== 0;
44
+ }
45
+ /**
46
+ * @returns {number}
47
+ */
48
+ get cols() {
49
+ const ret = wasm.terminal_cols(this.__wbg_ptr);
50
+ return ret;
51
+ }
52
+ /**
53
+ * @returns {number}
54
+ */
55
+ get cursor_col() {
56
+ const ret = wasm.terminal_cursor_col(this.__wbg_ptr);
57
+ return ret;
58
+ }
59
+ /**
60
+ * @returns {number}
61
+ */
62
+ get cursor_row() {
63
+ const ret = wasm.terminal_cursor_row(this.__wbg_ptr);
64
+ return ret;
65
+ }
66
+ /**
67
+ * DECSCUSR cursor style: 0=default, 1=blinking block, 2=steady block,
68
+ * 3=blinking underline, 4=steady underline, 5=blinking bar, 6=steady bar.
69
+ * @returns {number}
70
+ */
71
+ cursor_style() {
72
+ const ret = wasm.terminal_cursor_style(this.__wbg_ptr);
73
+ return ret;
74
+ }
75
+ /**
76
+ * @returns {boolean}
77
+ */
78
+ cursor_visible() {
79
+ const ret = wasm.terminal_cursor_visible(this.__wbg_ptr);
80
+ return ret !== 0;
81
+ }
82
+ /**
83
+ * @returns {boolean}
84
+ */
85
+ echo() {
86
+ const ret = wasm.terminal_echo(this.__wbg_ptr);
87
+ return ret !== 0;
88
+ }
89
+ /**
90
+ * @param {Uint8Array} data
91
+ */
92
+ feed_compressed(data) {
93
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
94
+ const len0 = WASM_VECTOR_LEN;
95
+ wasm.terminal_feed_compressed(this.__wbg_ptr, ptr0, len0);
96
+ }
97
+ /**
98
+ * @param {Uint8Array} batch
99
+ */
100
+ feed_compressed_batch(batch) {
101
+ const ptr0 = passArray8ToWasm0(batch, wasm.__wbindgen_malloc);
102
+ const len0 = WASM_VECTOR_LEN;
103
+ wasm.terminal_feed_compressed_batch(this.__wbg_ptr, ptr0, len0);
104
+ }
105
+ /**
106
+ * @param {number} start_row
107
+ * @param {number} start_col
108
+ * @param {number} end_row
109
+ * @param {number} end_col
110
+ * @returns {string}
111
+ */
112
+ get_html(start_row, start_col, end_row, end_col) {
113
+ let deferred1_0;
114
+ let deferred1_1;
115
+ try {
116
+ const ret = wasm.terminal_get_html(this.__wbg_ptr, start_row, start_col, end_row, end_col);
117
+ deferred1_0 = ret[0];
118
+ deferred1_1 = ret[1];
119
+ return getStringFromWasm0(ret[0], ret[1]);
120
+ } finally {
121
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
122
+ }
123
+ }
124
+ /**
125
+ * @param {number} start_row
126
+ * @param {number} start_col
127
+ * @param {number} end_row
128
+ * @param {number} end_col
129
+ * @returns {string}
130
+ */
131
+ get_text(start_row, start_col, end_row, end_col) {
132
+ let deferred1_0;
133
+ let deferred1_1;
134
+ try {
135
+ const ret = wasm.terminal_get_text(this.__wbg_ptr, start_row, start_col, end_row, end_col);
136
+ deferred1_0 = ret[0];
137
+ deferred1_1 = ret[1];
138
+ return getStringFromWasm0(ret[0], ret[1]);
139
+ } finally {
140
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
141
+ }
142
+ }
143
+ /**
144
+ * @returns {HTMLCanvasElement | undefined}
145
+ */
146
+ glyph_atlas_canvas() {
147
+ const ret = wasm.terminal_glyph_atlas_canvas(this.__wbg_ptr);
148
+ return ret;
149
+ }
150
+ /**
151
+ * @returns {number}
152
+ */
153
+ glyph_atlas_version() {
154
+ const ret = wasm.terminal_glyph_atlas_version(this.__wbg_ptr);
155
+ return ret >>> 0;
156
+ }
157
+ /**
158
+ * Length of glyph vertex data (in f32 elements).
159
+ * @returns {number}
160
+ */
161
+ glyph_verts_len() {
162
+ const ret = wasm.terminal_glyph_verts_len(this.__wbg_ptr);
163
+ return ret >>> 0;
164
+ }
165
+ /**
166
+ * Pointer to ready-to-upload glyph vertex data (f32).
167
+ * @returns {number}
168
+ */
169
+ glyph_verts_ptr() {
170
+ const ret = wasm.terminal_glyph_verts_ptr(this.__wbg_ptr);
171
+ return ret >>> 0;
172
+ }
173
+ /**
174
+ * @returns {boolean}
175
+ */
176
+ icanon() {
177
+ const ret = wasm.terminal_icanon(this.__wbg_ptr);
178
+ return ret !== 0;
179
+ }
180
+ invalidate_render_cache() {
181
+ wasm.terminal_invalidate_render_cache(this.__wbg_ptr);
182
+ }
183
+ /**
184
+ * Returns true if the given row wraps to the next (is part of a longer logical line).
185
+ * @param {number} row
186
+ * @returns {boolean}
187
+ */
188
+ is_wrapped(row) {
189
+ const ret = wasm.terminal_is_wrapped(this.__wbg_ptr, row);
190
+ return ret !== 0;
191
+ }
192
+ /**
193
+ * @returns {number}
194
+ */
195
+ mouse_encoding() {
196
+ const ret = wasm.terminal_mouse_encoding(this.__wbg_ptr);
197
+ return ret;
198
+ }
199
+ /**
200
+ * @returns {number}
201
+ */
202
+ mouse_mode() {
203
+ const ret = wasm.terminal_mouse_mode(this.__wbg_ptr);
204
+ return ret;
205
+ }
206
+ /**
207
+ * @param {number} rows
208
+ * @param {number} cols
209
+ * @param {number} cell_width
210
+ * @param {number} cell_height
211
+ */
212
+ constructor(rows, cols, cell_width, cell_height) {
213
+ const ret = wasm.terminal_new(rows, cols, cell_width, cell_height);
214
+ this.__wbg_ptr = ret >>> 0;
215
+ TerminalFinalization.register(this, this.__wbg_ptr, this);
216
+ return this;
217
+ }
218
+ /**
219
+ * @returns {number}
220
+ */
221
+ overflow_text_count() {
222
+ const ret = wasm.terminal_overflow_text_count(this.__wbg_ptr);
223
+ return ret >>> 0;
224
+ }
225
+ /**
226
+ * Returns overflow text op at index: (row, col, col_span, text).
227
+ * @param {number} index
228
+ * @returns {any}
229
+ */
230
+ overflow_text_op(index) {
231
+ const ret = wasm.terminal_overflow_text_op(this.__wbg_ptr, index);
232
+ return ret;
233
+ }
234
+ prepare_render_ops() {
235
+ wasm.terminal_prepare_render_ops(this.__wbg_ptr);
236
+ }
237
+ /**
238
+ * @returns {number}
239
+ */
240
+ get rows() {
241
+ const ret = wasm.terminal_rows(this.__wbg_ptr);
242
+ return ret;
243
+ }
244
+ /**
245
+ * @returns {number}
246
+ */
247
+ scrollback_lines() {
248
+ const ret = wasm.terminal_scrollback_lines(this.__wbg_ptr);
249
+ return ret >>> 0;
250
+ }
251
+ /**
252
+ * @param {number} idx
253
+ * @param {number} r
254
+ * @param {number} g
255
+ * @param {number} b
256
+ */
257
+ set_ansi_color(idx, r, g, b) {
258
+ wasm.terminal_set_ansi_color(this.__wbg_ptr, idx, r, g, b);
259
+ }
260
+ /**
261
+ * @param {number} cell_width
262
+ * @param {number} cell_height
263
+ */
264
+ set_cell_size(cell_width, cell_height) {
265
+ wasm.terminal_set_cell_size(this.__wbg_ptr, cell_width, cell_height);
266
+ }
267
+ /**
268
+ * @param {number} fg_r
269
+ * @param {number} fg_g
270
+ * @param {number} fg_b
271
+ * @param {number} bg_r
272
+ * @param {number} bg_g
273
+ * @param {number} bg_b
274
+ */
275
+ set_default_colors(fg_r, fg_g, fg_b, bg_r, bg_g, bg_b) {
276
+ wasm.terminal_set_default_colors(this.__wbg_ptr, fg_r, fg_g, fg_b, bg_r, bg_g, bg_b);
277
+ }
278
+ /**
279
+ * @param {string} font_family
280
+ */
281
+ set_font_family(font_family) {
282
+ const ptr0 = passStringToWasm0(font_family, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
283
+ const len0 = WASM_VECTOR_LEN;
284
+ wasm.terminal_set_font_family(this.__wbg_ptr, ptr0, len0);
285
+ }
286
+ /**
287
+ * @param {number} font_size
288
+ */
289
+ set_font_size(font_size) {
290
+ wasm.terminal_set_font_size(this.__wbg_ptr, font_size);
291
+ }
292
+ /**
293
+ * @param {number} x
294
+ * @param {number} y
295
+ */
296
+ set_render_offset(x, y) {
297
+ wasm.terminal_set_render_offset(this.__wbg_ptr, x, y);
298
+ }
299
+ /**
300
+ * @returns {string}
301
+ */
302
+ title() {
303
+ let deferred1_0;
304
+ let deferred1_1;
305
+ try {
306
+ const ret = wasm.terminal_title(this.__wbg_ptr);
307
+ deferred1_0 = ret[0];
308
+ deferred1_1 = ret[1];
309
+ return getStringFromWasm0(ret[0], ret[1]);
310
+ } finally {
311
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
312
+ }
313
+ }
314
+ }
315
+ if (Symbol.dispose) Terminal.prototype[Symbol.dispose] = Terminal.prototype.free;
316
+
317
+ /**
318
+ * Expose WASM linear memory for zero-copy typed array views.
319
+ * @returns {any}
320
+ */
321
+ export function wasm_memory() {
322
+ const ret = wasm.wasm_memory();
323
+ return ret;
324
+ }
325
+ import * as import1 from "./snippets/blit-browser-dc72b20da624ccea/inline0.js"
326
+
327
+ function __wbg_get_imports() {
328
+ const import0 = {
329
+ __proto__: null,
330
+ __wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
331
+ const ret = arg0 === undefined;
332
+ return ret;
333
+ },
334
+ __wbg___wbindgen_memory_edb3f01e3930bbf6: function() {
335
+ const ret = wasm.memory;
336
+ return ret;
337
+ },
338
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
339
+ throw new Error(getStringFromWasm0(arg0, arg1));
340
+ },
341
+ __wbg_beginPath_596efed55075dbc3: function(arg0) {
342
+ arg0.beginPath();
343
+ },
344
+ __wbg_blitFillTextCodePoint_1e497c1a5e5757d4: function(arg0, arg1, arg2, arg3) {
345
+ blitFillTextCodePoint(arg0, arg1 >>> 0, arg2, arg3);
346
+ },
347
+ __wbg_blitFillTextStretched_eefb47953ee5d314: function(arg0, arg1, arg2, arg3, arg4) {
348
+ blitFillTextStretched(arg0, arg1 >>> 0, arg2, arg3, arg4);
349
+ },
350
+ __wbg_clearRect_ea4f3d34d76f4bc5: function(arg0, arg1, arg2, arg3, arg4) {
351
+ arg0.clearRect(arg1, arg2, arg3, arg4);
352
+ },
353
+ __wbg_clip_3112b0bb495d0e08: function(arg0) {
354
+ arg0.clip();
355
+ },
356
+ __wbg_createElement_9b0aab265c549ded: function() { return handleError(function (arg0, arg1, arg2) {
357
+ const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
358
+ return ret;
359
+ }, arguments); },
360
+ __wbg_document_c0320cd4183c6d9b: function(arg0) {
361
+ const ret = arg0.document;
362
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
363
+ },
364
+ __wbg_getContext_f04bf8f22dcb2d53: function() { return handleError(function (arg0, arg1, arg2) {
365
+ const ret = arg0.getContext(getStringFromWasm0(arg1, arg2));
366
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
367
+ }, arguments); },
368
+ __wbg_instanceof_CanvasRenderingContext2d_08b9d193c22fa886: function(arg0) {
369
+ let result;
370
+ try {
371
+ result = arg0 instanceof CanvasRenderingContext2D;
372
+ } catch (_) {
373
+ result = false;
374
+ }
375
+ const ret = result;
376
+ return ret;
377
+ },
378
+ __wbg_instanceof_HtmlCanvasElement_26125339f936be50: function(arg0) {
379
+ let result;
380
+ try {
381
+ result = arg0 instanceof HTMLCanvasElement;
382
+ } catch (_) {
383
+ result = false;
384
+ }
385
+ const ret = result;
386
+ return ret;
387
+ },
388
+ __wbg_instanceof_Window_23e677d2c6843922: function(arg0) {
389
+ let result;
390
+ try {
391
+ result = arg0 instanceof Window;
392
+ } catch (_) {
393
+ result = false;
394
+ }
395
+ const ret = result;
396
+ return ret;
397
+ },
398
+ __wbg_lineTo_8ea7db5b5d763030: function(arg0, arg1, arg2) {
399
+ arg0.lineTo(arg1, arg2);
400
+ },
401
+ __wbg_moveTo_6d04ca2f71946754: function(arg0, arg1, arg2) {
402
+ arg0.moveTo(arg1, arg2);
403
+ },
404
+ __wbg_new_with_length_3259a525196bd8cc: function(arg0) {
405
+ const ret = new Array(arg0 >>> 0);
406
+ return ret;
407
+ },
408
+ __wbg_rect_9fb7070ab71d27aa: function(arg0, arg1, arg2, arg3, arg4) {
409
+ arg0.rect(arg1, arg2, arg3, arg4);
410
+ },
411
+ __wbg_restore_ec1ece47cce5dc64: function(arg0) {
412
+ arg0.restore();
413
+ },
414
+ __wbg_save_c4e64a4ec29f000f: function(arg0) {
415
+ arg0.save();
416
+ },
417
+ __wbg_set_282384002438957f: function(arg0, arg1, arg2) {
418
+ arg0[arg1 >>> 0] = arg2;
419
+ },
420
+ __wbg_set_fillStyle_58417b6b548ae475: function(arg0, arg1, arg2) {
421
+ arg0.fillStyle = getStringFromWasm0(arg1, arg2);
422
+ },
423
+ __wbg_set_font_b038797b3573ae5e: function(arg0, arg1, arg2) {
424
+ arg0.font = getStringFromWasm0(arg1, arg2);
425
+ },
426
+ __wbg_set_height_b6548a01bdcb689a: function(arg0, arg1) {
427
+ arg0.height = arg1 >>> 0;
428
+ },
429
+ __wbg_set_strokeStyle_a5baa9565d8b6485: function(arg0, arg1, arg2) {
430
+ arg0.strokeStyle = getStringFromWasm0(arg1, arg2);
431
+ },
432
+ __wbg_set_textBaseline_a9304886c3f7ea50: function(arg0, arg1, arg2) {
433
+ arg0.textBaseline = getStringFromWasm0(arg1, arg2);
434
+ },
435
+ __wbg_set_width_c0fcaa2da53cd540: function(arg0, arg1) {
436
+ arg0.width = arg1 >>> 0;
437
+ },
438
+ __wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
439
+ const ret = typeof global === 'undefined' ? null : global;
440
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
441
+ },
442
+ __wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
443
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
444
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
445
+ },
446
+ __wbg_static_accessor_SELF_f207c857566db248: function() {
447
+ const ret = typeof self === 'undefined' ? null : self;
448
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
449
+ },
450
+ __wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
451
+ const ret = typeof window === 'undefined' ? null : window;
452
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
453
+ },
454
+ __wbg_stroke_affa71c0888c6f31: function(arg0) {
455
+ arg0.stroke();
456
+ },
457
+ __wbindgen_cast_0000000000000001: function(arg0) {
458
+ // Cast intrinsic for `F64 -> Externref`.
459
+ const ret = arg0;
460
+ return ret;
461
+ },
462
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
463
+ // Cast intrinsic for `Ref(String) -> Externref`.
464
+ const ret = getStringFromWasm0(arg0, arg1);
465
+ return ret;
466
+ },
467
+ __wbindgen_init_externref_table: function() {
468
+ const table = wasm.__wbindgen_externrefs;
469
+ const offset = table.grow(4);
470
+ table.set(0, undefined);
471
+ table.set(offset + 0, undefined);
472
+ table.set(offset + 1, null);
473
+ table.set(offset + 2, true);
474
+ table.set(offset + 3, false);
475
+ },
476
+ };
477
+ return {
478
+ __proto__: null,
479
+ "./blit_browser_bg.js": import0,
480
+ "./snippets/blit-browser-dc72b20da624ccea/inline0.js": import1,
481
+ };
482
+ }
483
+
484
+ const TerminalFinalization = (typeof FinalizationRegistry === 'undefined')
485
+ ? { register: () => {}, unregister: () => {} }
486
+ : new FinalizationRegistry(ptr => wasm.__wbg_terminal_free(ptr >>> 0, 1));
487
+
488
+ function addToExternrefTable0(obj) {
489
+ const idx = wasm.__externref_table_alloc();
490
+ wasm.__wbindgen_externrefs.set(idx, obj);
491
+ return idx;
492
+ }
493
+
494
+ function getStringFromWasm0(ptr, len) {
495
+ ptr = ptr >>> 0;
496
+ return decodeText(ptr, len);
497
+ }
498
+
499
+ let cachedUint8ArrayMemory0 = null;
500
+ function getUint8ArrayMemory0() {
501
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
502
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
503
+ }
504
+ return cachedUint8ArrayMemory0;
505
+ }
506
+
507
+ function handleError(f, args) {
508
+ try {
509
+ return f.apply(this, args);
510
+ } catch (e) {
511
+ const idx = addToExternrefTable0(e);
512
+ wasm.__wbindgen_exn_store(idx);
513
+ }
514
+ }
515
+
516
+ function isLikeNone(x) {
517
+ return x === undefined || x === null;
518
+ }
519
+
520
+ function passArray8ToWasm0(arg, malloc) {
521
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
522
+ getUint8ArrayMemory0().set(arg, ptr / 1);
523
+ WASM_VECTOR_LEN = arg.length;
524
+ return ptr;
525
+ }
526
+
527
+ function passStringToWasm0(arg, malloc, realloc) {
528
+ if (realloc === undefined) {
529
+ const buf = cachedTextEncoder.encode(arg);
530
+ const ptr = malloc(buf.length, 1) >>> 0;
531
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
532
+ WASM_VECTOR_LEN = buf.length;
533
+ return ptr;
534
+ }
535
+
536
+ let len = arg.length;
537
+ let ptr = malloc(len, 1) >>> 0;
538
+
539
+ const mem = getUint8ArrayMemory0();
540
+
541
+ let offset = 0;
542
+
543
+ for (; offset < len; offset++) {
544
+ const code = arg.charCodeAt(offset);
545
+ if (code > 0x7F) break;
546
+ mem[ptr + offset] = code;
547
+ }
548
+ if (offset !== len) {
549
+ if (offset !== 0) {
550
+ arg = arg.slice(offset);
551
+ }
552
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
553
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
554
+ const ret = cachedTextEncoder.encodeInto(arg, view);
555
+
556
+ offset += ret.written;
557
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
558
+ }
559
+
560
+ WASM_VECTOR_LEN = offset;
561
+ return ptr;
562
+ }
563
+
564
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
565
+ cachedTextDecoder.decode();
566
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
567
+ let numBytesDecoded = 0;
568
+ function decodeText(ptr, len) {
569
+ numBytesDecoded += len;
570
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
571
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
572
+ cachedTextDecoder.decode();
573
+ numBytesDecoded = len;
574
+ }
575
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
576
+ }
577
+
578
+ const cachedTextEncoder = new TextEncoder();
579
+
580
+ if (!('encodeInto' in cachedTextEncoder)) {
581
+ cachedTextEncoder.encodeInto = function (arg, view) {
582
+ const buf = cachedTextEncoder.encode(arg);
583
+ view.set(buf);
584
+ return {
585
+ read: arg.length,
586
+ written: buf.length
587
+ };
588
+ };
589
+ }
590
+
591
+ let WASM_VECTOR_LEN = 0;
592
+
593
+ let wasmModule, wasm;
594
+ function __wbg_finalize_init(instance, module) {
595
+ wasm = instance.exports;
596
+ wasmModule = module;
597
+ cachedUint8ArrayMemory0 = null;
598
+ wasm.__wbindgen_start();
599
+ return wasm;
600
+ }
601
+
602
+ async function __wbg_load(module, imports) {
603
+ if (typeof Response === 'function' && module instanceof Response) {
604
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
605
+ try {
606
+ return await WebAssembly.instantiateStreaming(module, imports);
607
+ } catch (e) {
608
+ const validResponse = module.ok && expectedResponseType(module.type);
609
+
610
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
611
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
612
+
613
+ } else { throw e; }
614
+ }
615
+ }
616
+
617
+ const bytes = await module.arrayBuffer();
618
+ return await WebAssembly.instantiate(bytes, imports);
619
+ } else {
620
+ const instance = await WebAssembly.instantiate(module, imports);
621
+
622
+ if (instance instanceof WebAssembly.Instance) {
623
+ return { instance, module };
624
+ } else {
625
+ return instance;
626
+ }
627
+ }
628
+
629
+ function expectedResponseType(type) {
630
+ switch (type) {
631
+ case 'basic': case 'cors': case 'default': return true;
632
+ }
633
+ return false;
634
+ }
635
+ }
636
+
637
+ function initSync(module) {
638
+ if (wasm !== undefined) return wasm;
639
+
640
+
641
+ if (module !== undefined) {
642
+ if (Object.getPrototypeOf(module) === Object.prototype) {
643
+ ({module} = module)
644
+ } else {
645
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
646
+ }
647
+ }
648
+
649
+ const imports = __wbg_get_imports();
650
+ if (!(module instanceof WebAssembly.Module)) {
651
+ module = new WebAssembly.Module(module);
652
+ }
653
+ const instance = new WebAssembly.Instance(module, imports);
654
+ return __wbg_finalize_init(instance, module);
655
+ }
656
+
657
+ async function __wbg_init(module_or_path) {
658
+ if (wasm !== undefined) return wasm;
659
+
660
+
661
+ if (module_or_path !== undefined) {
662
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
663
+ ({module_or_path} = module_or_path)
664
+ } else {
665
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
666
+ }
667
+ }
668
+
669
+ if (module_or_path === undefined) {
670
+ module_or_path = new URL('blit_browser_bg.wasm', import.meta.url);
671
+ }
672
+ const imports = __wbg_get_imports();
673
+
674
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
675
+ module_or_path = fetch(module_or_path);
676
+ }
677
+
678
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
679
+
680
+ return __wbg_finalize_init(instance, module);
681
+ }
682
+
683
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,48 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_terminal_free: (a: number, b: number) => void;
5
+ export const terminal_app_cursor: (a: number) => number;
6
+ export const terminal_bg_verts_len: (a: number) => number;
7
+ export const terminal_bg_verts_ptr: (a: number) => number;
8
+ export const terminal_bracketed_paste: (a: number) => number;
9
+ export const terminal_cols: (a: number) => number;
10
+ export const terminal_cursor_col: (a: number) => number;
11
+ export const terminal_cursor_row: (a: number) => number;
12
+ export const terminal_cursor_style: (a: number) => number;
13
+ export const terminal_cursor_visible: (a: number) => number;
14
+ export const terminal_echo: (a: number) => number;
15
+ export const terminal_feed_compressed: (a: number, b: number, c: number) => void;
16
+ export const terminal_feed_compressed_batch: (a: number, b: number, c: number) => void;
17
+ export const terminal_get_html: (a: number, b: number, c: number, d: number, e: number) => [number, number];
18
+ export const terminal_get_text: (a: number, b: number, c: number, d: number, e: number) => [number, number];
19
+ export const terminal_glyph_atlas_canvas: (a: number) => any;
20
+ export const terminal_glyph_atlas_version: (a: number) => number;
21
+ export const terminal_glyph_verts_len: (a: number) => number;
22
+ export const terminal_glyph_verts_ptr: (a: number) => number;
23
+ export const terminal_icanon: (a: number) => number;
24
+ export const terminal_invalidate_render_cache: (a: number) => void;
25
+ export const terminal_is_wrapped: (a: number, b: number) => number;
26
+ export const terminal_mouse_encoding: (a: number) => number;
27
+ export const terminal_mouse_mode: (a: number) => number;
28
+ export const terminal_new: (a: number, b: number, c: number, d: number) => number;
29
+ export const terminal_overflow_text_count: (a: number) => number;
30
+ export const terminal_overflow_text_op: (a: number, b: number) => any;
31
+ export const terminal_prepare_render_ops: (a: number) => void;
32
+ export const terminal_rows: (a: number) => number;
33
+ export const terminal_scrollback_lines: (a: number) => number;
34
+ export const terminal_set_ansi_color: (a: number, b: number, c: number, d: number, e: number) => void;
35
+ export const terminal_set_cell_size: (a: number, b: number, c: number) => void;
36
+ export const terminal_set_default_colors: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
37
+ export const terminal_set_font_family: (a: number, b: number, c: number) => void;
38
+ export const terminal_set_font_size: (a: number, b: number) => void;
39
+ export const terminal_set_render_offset: (a: number, b: number, c: number) => void;
40
+ export const terminal_title: (a: number) => [number, number];
41
+ export const wasm_memory: () => any;
42
+ export const __wbindgen_exn_store: (a: number) => void;
43
+ export const __externref_table_alloc: () => number;
44
+ export const __wbindgen_externrefs: WebAssembly.Table;
45
+ export const __wbindgen_malloc: (a: number, b: number) => number;
46
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
47
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
48
+ export const __wbindgen_start: () => void;
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@blit-sh/browser",
3
+ "version": "0.17.0",
4
+ "type": "module",
5
+ "description": "Low-latency terminal streaming — browser WASM renderer",
6
+ "main": "blit_browser.js",
7
+ "types": "blit_browser.d.ts",
8
+ "files": ["blit_browser_bg.wasm","blit_browser.js","blit_browser.d.ts","blit_browser_bg.wasm.d.ts","snippets"],
9
+ "sideEffects": ["./snippets/*"],
10
+ "keywords": ["terminal","tty","wasm","streaming","webgl"],
11
+ "homepage": "https://blit.sh",
12
+ "license": "MIT",
13
+ "author": "Indent <oss@indent.com> (https://indent.com)",
14
+ "repository": {"type":"git","url":"git+https://github.com/indent-com/blit.git","directory":"crates/browser"},
15
+ "bugs": {"url":"https://github.com/indent-com/blit/issues"}
16
+ }
@@ -0,0 +1,47 @@
1
+
2
+ const glyphTextCache = new Map();
3
+
4
+ function codePointText(codePoint) {
5
+ let text = glyphTextCache.get(codePoint);
6
+ if (text === undefined) {
7
+ text = String.fromCodePoint(codePoint);
8
+ glyphTextCache.set(codePoint, text);
9
+ }
10
+ return text;
11
+ }
12
+
13
+ export function blitFillTextCodePoint(ctx, codePoint, x, y) {
14
+ ctx.fillText(codePointText(codePoint), x, y);
15
+ }
16
+
17
+ export function blitFillTextStretched(ctx, codePoint, x, y, targetWidth) {
18
+ const text = codePointText(codePoint);
19
+ const measured = ctx.measureText(text).width;
20
+ if (measured > 0 && Math.abs(measured - targetWidth) > 0.001) {
21
+ ctx.save();
22
+ ctx.translate(x, 0);
23
+ ctx.scale(targetWidth / measured, 1);
24
+ ctx.translate(-x, 0);
25
+ ctx.fillText(text, x, y);
26
+ ctx.restore();
27
+ } else {
28
+ ctx.fillText(text, x, y);
29
+ }
30
+ }
31
+
32
+ export function blitFillText(ctx, text, x, y) {
33
+ ctx.fillText(text, x, y);
34
+ }
35
+
36
+ const PROBE_CHARS = [0x4D, 0x6D, 0x57, 0x77, 0x40, 0x25, 0x23, 0x47, 0x4F, 0x51];
37
+
38
+ export function blitMeasureMaxOverhang(ctx, cellWidth) {
39
+ let maxOverhang = 0;
40
+ for (const cp of PROBE_CHARS) {
41
+ const m = ctx.measureText(String.fromCodePoint(cp));
42
+ const ink = m.actualBoundingBoxLeft + m.actualBoundingBoxRight;
43
+ const overhang = ink - cellWidth;
44
+ if (overhang > maxOverhang) maxOverhang = overhang;
45
+ }
46
+ return Math.ceil(maxOverhang / 2);
47
+ }