@live-codes/browser-compilers 0.4.12 → 0.4.13

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,119 @@
1
+ export const svgbobWasm = async (wasmUrl) => {
2
+ var svgbob_wasm_bg_default =
3
+ wasmUrl || 'https://cdn.jsdelivr.net/npm/svgbob-wasm/svgbob_wasm_bg.wasm';
4
+
5
+ var imports = {};
6
+ async function loadWasm(module3, imports2) {
7
+ if (typeof module3 === 'string') {
8
+ const moduleRequest = await fetch(module3);
9
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
10
+ try {
11
+ return await WebAssembly.instantiateStreaming(moduleRequest, imports2);
12
+ } catch (e) {
13
+ if (moduleRequest.headers.get('Content-Type') != 'application/wasm') {
14
+ console.warn(e);
15
+ } else {
16
+ throw e;
17
+ }
18
+ }
19
+ }
20
+ module3 = await moduleRequest.arrayBuffer();
21
+ }
22
+ return await WebAssembly.instantiate(module3, imports2);
23
+ }
24
+ var { instance, module: module2 } = await loadWasm(svgbob_wasm_bg_default, imports);
25
+ var memory = instance.exports.memory;
26
+ var convert_string = instance.exports.convert_string;
27
+ var __wbindgen_export_0 = instance.exports.__wbindgen_export_0;
28
+ var __wbindgen_malloc = instance.exports.__wbindgen_malloc;
29
+ var __wbindgen_realloc = instance.exports.__wbindgen_realloc;
30
+ var __wbindgen_free = instance.exports.__wbindgen_free;
31
+
32
+ var WASM_VECTOR_LEN = 0;
33
+ var cachegetUint8Memory0 = null;
34
+ function getUint8Memory0() {
35
+ if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== memory.buffer) {
36
+ cachegetUint8Memory0 = new Uint8Array(memory.buffer);
37
+ }
38
+ return cachegetUint8Memory0;
39
+ }
40
+ var lTextEncoder =
41
+ typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
42
+ var cachedTextEncoder = new lTextEncoder('utf-8');
43
+ var encodeString =
44
+ typeof cachedTextEncoder.encodeInto === 'function'
45
+ ? function (arg, view) {
46
+ return cachedTextEncoder.encodeInto(arg, view);
47
+ }
48
+ : function (arg, view) {
49
+ const buf = cachedTextEncoder.encode(arg);
50
+ view.set(buf);
51
+ return {
52
+ read: arg.length,
53
+ written: buf.length,
54
+ };
55
+ };
56
+ function passStringToWasm0(arg, malloc, realloc) {
57
+ if (realloc === void 0) {
58
+ const buf = cachedTextEncoder.encode(arg);
59
+ const ptr2 = malloc(buf.length);
60
+ getUint8Memory0()
61
+ .subarray(ptr2, ptr2 + buf.length)
62
+ .set(buf);
63
+ WASM_VECTOR_LEN = buf.length;
64
+ return ptr2;
65
+ }
66
+ let len = arg.length;
67
+ let ptr = malloc(len);
68
+ const mem = getUint8Memory0();
69
+ let offset = 0;
70
+ for (; offset < len; offset++) {
71
+ const code = arg.charCodeAt(offset);
72
+ if (code > 127) break;
73
+ mem[ptr + offset] = code;
74
+ }
75
+ if (offset !== len) {
76
+ if (offset !== 0) {
77
+ arg = arg.slice(offset);
78
+ }
79
+ ptr = realloc(ptr, len, (len = offset + arg.length * 3));
80
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
81
+ const ret = encodeString(arg, view);
82
+ offset += ret.written;
83
+ }
84
+ WASM_VECTOR_LEN = offset;
85
+ return ptr;
86
+ }
87
+ var cachegetInt32Memory0 = null;
88
+ function getInt32Memory0() {
89
+ if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== memory.buffer) {
90
+ cachegetInt32Memory0 = new Int32Array(memory.buffer);
91
+ }
92
+ return cachegetInt32Memory0;
93
+ }
94
+ var lTextDecoder =
95
+ typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
96
+ var cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
97
+ cachedTextDecoder.decode();
98
+ function getStringFromWasm0(ptr, len) {
99
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
100
+ }
101
+ function convert_string2(data) {
102
+ try {
103
+ const retptr = __wbindgen_export_0.value - 16;
104
+ __wbindgen_export_0.value = retptr;
105
+ var ptr0 = passStringToWasm0(data, __wbindgen_malloc, __wbindgen_realloc);
106
+ var len0 = WASM_VECTOR_LEN;
107
+ convert_string(retptr, ptr0, len0);
108
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
109
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
110
+ return getStringFromWasm0(r0, r1);
111
+ } finally {
112
+ __wbindgen_export_0.value += 16;
113
+ __wbindgen_free(r0, r1);
114
+ }
115
+ }
116
+ return {
117
+ convert_string: convert_string2,
118
+ };
119
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-codes/browser-compilers",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "description": "Compilers that run in the browser, for use in livecodes.io",
5
5
  "author": "Hatem Hosny",
6
6
  "license": "MIT",
@@ -249,3 +249,10 @@ fs.copyFileSync(
249
249
  path.resolve(vendor_modules_src + '/gnuplot-JS/www/gnuplot_api.js'),
250
250
  path.resolve(targetDir + '/gnuplot/gnuplot_api.js'),
251
251
  );
252
+
253
+ // svgbob-wasm
254
+ mkdirp(targetDir + '/svgbob-wasm');
255
+ fs.copyFileSync(
256
+ path.resolve(vendor_modules_src + '/svgbob-wasm/svgbob-wasm.js'),
257
+ path.resolve(targetDir + '/svgbob-wasm/svgbob-wasm.js'),
258
+ );
@@ -48,6 +48,10 @@ Stylus: [MIT License](https://github.com/stylus/stylus/blob/59bc665db295981d4e3f
48
48
 
49
49
  Svelte: [MIT License](https://github.com/sveltejs/svelte/blob/dafbdc286eef3de2243088a9a826e6899e20465c/LICENSE)
50
50
 
51
+ svgbob: [Apache License 2.0](https://github.com/ivanceras/svgbob/blob/277f28b337a2d00a61cf342247060cf5fbf88d50/LICENSE)
52
+
53
+ svgbob-wasm: [Apache License 2.0](https://github.com/agoose77/svgbob-wasm/blob/45e280096ee7f7a07981de2ce95aba343bc94123/LICENSE_APACHE)
54
+
51
55
  turbopascal: [BSD 2-Clause License](https://github.com/MikeRalphson/turbopascal/blob/cfcc5ee6d93f32664bb6127aa751c68841ca5c1d/LICENSE)
52
56
 
53
57
  wacl: [BSD 3-Clause License](https://github.com/ecky-l/wacl/blob/9daacabb0102a9986f33263261350edfeebdd83b/LICENSE)
@@ -0,0 +1 @@
1
+ based on https://github.com/agoose77/svgbob-wasm
@@ -0,0 +1,119 @@
1
+ export const svgbobWasm = async (wasmUrl) => {
2
+ var svgbob_wasm_bg_default =
3
+ wasmUrl || 'https://cdn.jsdelivr.net/npm/svgbob-wasm/svgbob_wasm_bg.wasm';
4
+
5
+ var imports = {};
6
+ async function loadWasm(module3, imports2) {
7
+ if (typeof module3 === 'string') {
8
+ const moduleRequest = await fetch(module3);
9
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
10
+ try {
11
+ return await WebAssembly.instantiateStreaming(moduleRequest, imports2);
12
+ } catch (e) {
13
+ if (moduleRequest.headers.get('Content-Type') != 'application/wasm') {
14
+ console.warn(e);
15
+ } else {
16
+ throw e;
17
+ }
18
+ }
19
+ }
20
+ module3 = await moduleRequest.arrayBuffer();
21
+ }
22
+ return await WebAssembly.instantiate(module3, imports2);
23
+ }
24
+ var { instance, module: module2 } = await loadWasm(svgbob_wasm_bg_default, imports);
25
+ var memory = instance.exports.memory;
26
+ var convert_string = instance.exports.convert_string;
27
+ var __wbindgen_export_0 = instance.exports.__wbindgen_export_0;
28
+ var __wbindgen_malloc = instance.exports.__wbindgen_malloc;
29
+ var __wbindgen_realloc = instance.exports.__wbindgen_realloc;
30
+ var __wbindgen_free = instance.exports.__wbindgen_free;
31
+
32
+ var WASM_VECTOR_LEN = 0;
33
+ var cachegetUint8Memory0 = null;
34
+ function getUint8Memory0() {
35
+ if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== memory.buffer) {
36
+ cachegetUint8Memory0 = new Uint8Array(memory.buffer);
37
+ }
38
+ return cachegetUint8Memory0;
39
+ }
40
+ var lTextEncoder =
41
+ typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
42
+ var cachedTextEncoder = new lTextEncoder('utf-8');
43
+ var encodeString =
44
+ typeof cachedTextEncoder.encodeInto === 'function'
45
+ ? function (arg, view) {
46
+ return cachedTextEncoder.encodeInto(arg, view);
47
+ }
48
+ : function (arg, view) {
49
+ const buf = cachedTextEncoder.encode(arg);
50
+ view.set(buf);
51
+ return {
52
+ read: arg.length,
53
+ written: buf.length,
54
+ };
55
+ };
56
+ function passStringToWasm0(arg, malloc, realloc) {
57
+ if (realloc === void 0) {
58
+ const buf = cachedTextEncoder.encode(arg);
59
+ const ptr2 = malloc(buf.length);
60
+ getUint8Memory0()
61
+ .subarray(ptr2, ptr2 + buf.length)
62
+ .set(buf);
63
+ WASM_VECTOR_LEN = buf.length;
64
+ return ptr2;
65
+ }
66
+ let len = arg.length;
67
+ let ptr = malloc(len);
68
+ const mem = getUint8Memory0();
69
+ let offset = 0;
70
+ for (; offset < len; offset++) {
71
+ const code = arg.charCodeAt(offset);
72
+ if (code > 127) break;
73
+ mem[ptr + offset] = code;
74
+ }
75
+ if (offset !== len) {
76
+ if (offset !== 0) {
77
+ arg = arg.slice(offset);
78
+ }
79
+ ptr = realloc(ptr, len, (len = offset + arg.length * 3));
80
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
81
+ const ret = encodeString(arg, view);
82
+ offset += ret.written;
83
+ }
84
+ WASM_VECTOR_LEN = offset;
85
+ return ptr;
86
+ }
87
+ var cachegetInt32Memory0 = null;
88
+ function getInt32Memory0() {
89
+ if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== memory.buffer) {
90
+ cachegetInt32Memory0 = new Int32Array(memory.buffer);
91
+ }
92
+ return cachegetInt32Memory0;
93
+ }
94
+ var lTextDecoder =
95
+ typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
96
+ var cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
97
+ cachedTextDecoder.decode();
98
+ function getStringFromWasm0(ptr, len) {
99
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
100
+ }
101
+ function convert_string2(data) {
102
+ try {
103
+ const retptr = __wbindgen_export_0.value - 16;
104
+ __wbindgen_export_0.value = retptr;
105
+ var ptr0 = passStringToWasm0(data, __wbindgen_malloc, __wbindgen_realloc);
106
+ var len0 = WASM_VECTOR_LEN;
107
+ convert_string(retptr, ptr0, len0);
108
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
109
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
110
+ return getStringFromWasm0(r0, r1);
111
+ } finally {
112
+ __wbindgen_export_0.value += 16;
113
+ __wbindgen_free(r0, r1);
114
+ }
115
+ }
116
+ return {
117
+ convert_string: convert_string2,
118
+ };
119
+ };