fratmscript 0.0.0-stage → 0.11.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,328 @@
1
+ /* @ts-self-types="./fratm_wasm.d.ts" */
2
+
3
+ /**
4
+ * Compile FratmScript source to JavaScript
5
+ *
6
+ * Returns a JSON object with:
7
+ * - `success`: boolean
8
+ * - `code`: string (if success)
9
+ * - `sourceMap`: string (if success and requested)
10
+ * - `error`: string (if failure)
11
+ * - `line`: number (if failure)
12
+ * - `column`: number (if failure)
13
+ *
14
+ * `jsx_import_source` picks the library of the JSX runtime (`react` when
15
+ * left out).
16
+ * @param {string} source
17
+ * @param {boolean} generate_source_map
18
+ * @param {string | null} [jsx_import_source]
19
+ * @returns {any}
20
+ */
21
+ function compile(source, generate_source_map, jsx_import_source) {
22
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
23
+ const len0 = WASM_VECTOR_LEN;
24
+ var ptr1 = isLikeNone(jsx_import_source) ? 0 : passStringToWasm0(jsx_import_source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
25
+ var len1 = WASM_VECTOR_LEN;
26
+ const ret = wasm.compile(ptr0, len0, generate_source_map, ptr1, len1);
27
+ return ret;
28
+ }
29
+ exports.compile = compile;
30
+
31
+ /**
32
+ * Format FratmScript source like `fratm fmt`
33
+ *
34
+ * Returns a JSON object with `success`, `code` (the formatted source) or
35
+ * `error`, `line`, `column` and `suggestion`.
36
+ * @param {string} source
37
+ * @returns {any}
38
+ */
39
+ function format(source) {
40
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
41
+ const len0 = WASM_VECTOR_LEN;
42
+ const ret = wasm.format(ptr0, len0);
43
+ return ret;
44
+ }
45
+ exports.format = format;
46
+
47
+ /**
48
+ * Initialize panic hook for better error messages in browser console
49
+ */
50
+ function init() {
51
+ wasm.init();
52
+ }
53
+ exports.init = init;
54
+
55
+ /**
56
+ * Tokens and syntax tree for the playground's Token and Tree tabs, as a
57
+ * JSON string: `{ tokens, tree, error }` (positions in UTF-16 units)
58
+ * @param {string} source
59
+ * @returns {string}
60
+ */
61
+ function inspect(source) {
62
+ let deferred2_0;
63
+ let deferred2_1;
64
+ try {
65
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
66
+ const len0 = WASM_VECTOR_LEN;
67
+ const ret = wasm.inspect(ptr0, len0);
68
+ deferred2_0 = ret[0];
69
+ deferred2_1 = ret[1];
70
+ return getStringFromWasm0(ret[0], ret[1]);
71
+ } finally {
72
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
73
+ }
74
+ }
75
+ exports.inspect = inspect;
76
+
77
+ /**
78
+ * Neapolitan version of a JavaScript runtime error, with the original in
79
+ * brackets (`'x' nun esiste … (ReferenceError: x is not defined)`)
80
+ * @param {string} name
81
+ * @param {string} message
82
+ * @returns {string}
83
+ */
84
+ function runtimeError(name, message) {
85
+ let deferred3_0;
86
+ let deferred3_1;
87
+ try {
88
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
89
+ const len0 = WASM_VECTOR_LEN;
90
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
+ const len1 = WASM_VECTOR_LEN;
92
+ const ret = wasm.runtimeError(ptr0, len0, ptr1, len1);
93
+ deferred3_0 = ret[0];
94
+ deferred3_1 = ret[1];
95
+ return getStringFromWasm0(ret[0], ret[1]);
96
+ } finally {
97
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
98
+ }
99
+ }
100
+ exports.runtimeError = runtimeError;
101
+
102
+ /**
103
+ * The files of a new project, like `fratm nuovo`, as a JSON string:
104
+ * `[{ path, contents }]`, or `null` for an unknown template (`react`,
105
+ * `completa`, `senza-react`, `semplice`). Used by `npm create fratm`.
106
+ * @param {string} template
107
+ * @param {string} folder
108
+ * @param {boolean} tailwind
109
+ * @returns {string}
110
+ */
111
+ function scaffold(template, folder, tailwind) {
112
+ let deferred3_0;
113
+ let deferred3_1;
114
+ try {
115
+ const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
116
+ const len0 = WASM_VECTOR_LEN;
117
+ const ptr1 = passStringToWasm0(folder, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
118
+ const len1 = WASM_VECTOR_LEN;
119
+ const ret = wasm.scaffold(ptr0, len0, ptr1, len1, tailwind);
120
+ deferred3_0 = ret[0];
121
+ deferred3_1 = ret[1];
122
+ return getStringFromWasm0(ret[0], ret[1]);
123
+ } finally {
124
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
125
+ }
126
+ }
127
+ exports.scaffold = scaffold;
128
+
129
+ /**
130
+ * Tokenize source code (for syntax highlighting)
131
+ * @param {string} source
132
+ * @returns {any}
133
+ */
134
+ function tokenize(source) {
135
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136
+ const len0 = WASM_VECTOR_LEN;
137
+ const ret = wasm.tokenize(ptr0, len0);
138
+ return ret;
139
+ }
140
+ exports.tokenize = tokenize;
141
+
142
+ /**
143
+ * Get the compiler version
144
+ * @returns {string}
145
+ */
146
+ function version() {
147
+ let deferred1_0;
148
+ let deferred1_1;
149
+ try {
150
+ const ret = wasm.version();
151
+ deferred1_0 = ret[0];
152
+ deferred1_1 = ret[1];
153
+ return getStringFromWasm0(ret[0], ret[1]);
154
+ } finally {
155
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
156
+ }
157
+ }
158
+ exports.version = version;
159
+
160
+ function __wbg_get_imports() {
161
+ const import0 = {
162
+ __proto__: null,
163
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
164
+ const ret = Error(getStringFromWasm0(arg0, arg1));
165
+ return ret;
166
+ },
167
+ __wbg_Number_04624de7d0e8332d: function(arg0) {
168
+ const ret = Number(arg0);
169
+ return ret;
170
+ },
171
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
172
+ throw new Error(getStringFromWasm0(arg0, arg1));
173
+ },
174
+ __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
175
+ let deferred0_0;
176
+ let deferred0_1;
177
+ try {
178
+ deferred0_0 = arg0;
179
+ deferred0_1 = arg1;
180
+ console.error(getStringFromWasm0(arg0, arg1));
181
+ } finally {
182
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
183
+ }
184
+ },
185
+ __wbg_new_361308b2356cecd0: function() {
186
+ const ret = new Object();
187
+ return ret;
188
+ },
189
+ __wbg_new_3eb36ae241fe6f44: function() {
190
+ const ret = new Array();
191
+ return ret;
192
+ },
193
+ __wbg_new_8a6f238a6ece86ea: function() {
194
+ const ret = new Error();
195
+ return ret;
196
+ },
197
+ __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
198
+ arg0[arg1] = arg2;
199
+ },
200
+ __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
201
+ arg0[arg1 >>> 0] = arg2;
202
+ },
203
+ __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
204
+ const ret = arg1.stack;
205
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
206
+ const len1 = WASM_VECTOR_LEN;
207
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
208
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
209
+ },
210
+ __wbindgen_cast_0000000000000001: function(arg0) {
211
+ // Cast intrinsic for `F64 -> Externref`.
212
+ const ret = arg0;
213
+ return ret;
214
+ },
215
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
216
+ // Cast intrinsic for `Ref(String) -> Externref`.
217
+ const ret = getStringFromWasm0(arg0, arg1);
218
+ return ret;
219
+ },
220
+ __wbindgen_cast_0000000000000003: function(arg0) {
221
+ // Cast intrinsic for `U64 -> Externref`.
222
+ const ret = BigInt.asUintN(64, arg0);
223
+ return ret;
224
+ },
225
+ __wbindgen_init_externref_table: function() {
226
+ const table = wasm.__wbindgen_externrefs;
227
+ const offset = table.grow(4);
228
+ table.set(0, undefined);
229
+ table.set(offset + 0, undefined);
230
+ table.set(offset + 1, null);
231
+ table.set(offset + 2, true);
232
+ table.set(offset + 3, false);
233
+ },
234
+ };
235
+ return {
236
+ __proto__: null,
237
+ "./fratm_wasm_bg.js": import0,
238
+ };
239
+ }
240
+
241
+ let cachedDataViewMemory0 = null;
242
+ function getDataViewMemory0() {
243
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
244
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
245
+ }
246
+ return cachedDataViewMemory0;
247
+ }
248
+
249
+ function getStringFromWasm0(ptr, len) {
250
+ ptr = ptr >>> 0;
251
+ return decodeText(ptr, len);
252
+ }
253
+
254
+ let cachedUint8ArrayMemory0 = null;
255
+ function getUint8ArrayMemory0() {
256
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
257
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
258
+ }
259
+ return cachedUint8ArrayMemory0;
260
+ }
261
+
262
+ function isLikeNone(x) {
263
+ return x === undefined || x === null;
264
+ }
265
+
266
+ function passStringToWasm0(arg, malloc, realloc) {
267
+ if (realloc === undefined) {
268
+ const buf = cachedTextEncoder.encode(arg);
269
+ const ptr = malloc(buf.length, 1) >>> 0;
270
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
271
+ WASM_VECTOR_LEN = buf.length;
272
+ return ptr;
273
+ }
274
+
275
+ let len = arg.length;
276
+ let ptr = malloc(len, 1) >>> 0;
277
+
278
+ const mem = getUint8ArrayMemory0();
279
+
280
+ let offset = 0;
281
+
282
+ for (; offset < len; offset++) {
283
+ const code = arg.charCodeAt(offset);
284
+ if (code > 0x7F) break;
285
+ mem[ptr + offset] = code;
286
+ }
287
+ if (offset !== len) {
288
+ if (offset !== 0) {
289
+ arg = arg.slice(offset);
290
+ }
291
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
292
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
293
+ const ret = cachedTextEncoder.encodeInto(arg, view);
294
+
295
+ offset += ret.written;
296
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
297
+ }
298
+
299
+ WASM_VECTOR_LEN = offset;
300
+ return ptr;
301
+ }
302
+
303
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
304
+ cachedTextDecoder.decode();
305
+ function decodeText(ptr, len) {
306
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
307
+ }
308
+
309
+ const cachedTextEncoder = new TextEncoder();
310
+
311
+ if (!('encodeInto' in cachedTextEncoder)) {
312
+ cachedTextEncoder.encodeInto = function (arg, view) {
313
+ const buf = cachedTextEncoder.encode(arg);
314
+ view.set(buf);
315
+ return {
316
+ read: arg.length,
317
+ written: buf.length
318
+ };
319
+ };
320
+ }
321
+
322
+ let WASM_VECTOR_LEN = 0;
323
+
324
+ const wasmPath = `${__dirname}/fratm_wasm_bg.wasm`;
325
+ const wasmBytes = require('fs').readFileSync(wasmPath);
326
+ const wasmModule = new WebAssembly.Module(wasmBytes);
327
+ const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
328
+ wasm.__wbindgen_start();
Binary file
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }