basedpl 0.1.31 → 0.1.33
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/README.md +3 -50
- package/basedpl_wasm.js +411 -1
- package/basedpl_wasm_bg.wasm +0 -0
- package/canvas.js +8 -0
- package/layout.json +5 -8
- package/lb.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,60 +1,13 @@
|
|
|
1
1
|
# basedpl
|
|
2
2
|
|
|
3
|
-
This package runs BasedPL (BPL) in a web page. BPL is an array language derived from APL, with ideas from J and BQN. The package holds the BPL interpreter compiled to WebAssembly, a language bar for typing BPL's glyphs, and a TextMate grammar for highlighting BPL code.
|
|
4
|
-
|
|
5
|
-
## Load the package
|
|
6
|
-
|
|
7
|
-
jsDelivr serves every file in the package. An unversioned URL, such as `https://cdn.jsdelivr.net/npm/basedpl/basedpl_wasm.js`, gives the latest release. To keep one release, put its version in the URL: `https://cdn.jsdelivr.net/npm/basedpl@<version>/basedpl_wasm.js`. To install the package instead, run `npm install basedpl`.
|
|
8
|
-
|
|
9
|
-
## Run BPL
|
|
3
|
+
This package runs BasedPL (BPL) in a web page. BPL is an array language derived from APL, with ideas from J and BQN. The package holds the BPL interpreter compiled to WebAssembly, a language bar for typing BPL's glyphs, and a TextMate grammar for highlighting BPL code.
|
|
10
4
|
|
|
11
5
|
```js
|
|
12
6
|
import init, { Session, configure } from 'https://cdn.jsdelivr.net/npm/basedpl/basedpl_wasm.js';
|
|
13
7
|
|
|
14
8
|
await init();
|
|
15
9
|
configure(location.href, message => console.error(message));
|
|
16
|
-
|
|
17
|
-
const error = session.run('avg←+/÷≢ ⋄ avg 2 4 9', output => console.log(output.data['text/plain']));
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
This logs `5`, and `error` is `null`.
|
|
21
|
-
|
|
22
|
-
- `init()` fetches the module from beside the glue.
|
|
23
|
-
- `configure(base, panic)` sets the URL that relative file reads resolve against, and the function that receives a panic's message. After a panic, the module can't run more code.
|
|
24
|
-
- `session.run(code, output)` runs `code`, then returns `null` or the error. The error is an object with `kind`, `message` and `display`. `display` holds the error as BPL shows it. A session keeps its names from one `run` to the next.
|
|
25
|
-
- `output` receives each output as the program produces it, as `{kind, data}`. `kind` is `"display"` for a displayed value, `"explicit"` for a value assigned to `⎕`, or `"text"` for text written with `"-" •nput`. Display and explicit outputs each end a line. Text output doesn't.
|
|
26
|
-
|
|
27
|
-
`data` maps MIME types to text, or to a `Uint8Array` for a binary type:
|
|
28
|
-
|
|
29
|
-
- `text/plain`: the output as text.
|
|
30
|
-
- `text/html`: markup from element functions.
|
|
31
|
-
- `image/svg+xml`: markup from `•svg` and `•plot`.
|
|
32
|
-
- `image/x-rgba;width=N`: RGBA pixels from `•image`, `N` pixels wide. `new ImageData(new Uint8ClampedArray(bytes.buffer), N)` makes a canvas image from them.
|
|
33
|
-
- `image/png` and `image/jpeg`: encoded images.
|
|
34
|
-
|
|
35
|
-
`run` returns only when the code finishes. To keep the page responsive, run BPL in a Web Worker. The playground's [`worker.js`](https://github.com/AnswerDotAI/basedpl/blob/main/nbs/playground/worker.js) and [`page.js`](https://github.com/AnswerDotAI/basedpl/blob/main/nbs/playground/page.js) show a complete page.
|
|
36
|
-
|
|
37
|
-
## Differences from native BPL
|
|
38
|
-
|
|
39
|
-
- `•readdir`, `•metadata`, `•copy`, `•rename`, `•remove`, `•mkdir`, `•path` and `•delay` don't exist. `•nput` writes only to `"-"`.
|
|
40
|
-
- File reads and `•fetch` are synchronous `XMLHttpRequest`s, relative to the URL given to `configure`.
|
|
41
|
-
- `•r` uses JavaScript's `RegExp`, with its syntax and replacement templates.
|
|
42
|
-
- `•date⁻¹` has no `locale` option.
|
|
43
|
-
- Function calls nest at most 410 deep. A deeper call is a `LIMIT` error.
|
|
44
|
-
|
|
45
|
-
## Language bar
|
|
46
|
-
|
|
47
|
-
`lb.js` adds a bar of BPL's glyphs to the page. Clicking a glyph types it into the editor used last. In a textarea marked with `data-bpl`, or a Monaco editor whose language is `bpl`, a backtick followed by a glyph's name also types the glyph, as in the BPL REPL. `lb.js` and `input.js` are scripts whose value is a function. The bar needs the glyph rows from `symbols()` and the key layout from `layout.json`:
|
|
48
|
-
|
|
49
|
-
```js
|
|
50
|
-
import init, { symbols } from 'https://cdn.jsdelivr.net/npm/basedpl/basedpl_wasm.js';
|
|
51
|
-
|
|
52
|
-
const text = name => fetch(`https://cdn.jsdelivr.net/npm/basedpl/${name}`).then(r => r.text());
|
|
53
|
-
const [lb, input, layout] = await Promise.all(['lb.js', 'input.js', 'layout.json'].map(text));
|
|
54
|
-
await init();
|
|
55
|
-
(0, eval)(lb)(JSON.parse(symbols()), (0, eval)(input), JSON.parse(layout));
|
|
10
|
+
new Session().run('avg←+/÷≢ ⋄ avg 2 4 9', output => console.log(output.data['text/plain'])); // logs 5
|
|
56
11
|
```
|
|
57
12
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
`bpl.tmLanguage.json` is a TextMate grammar for BPL, with the scope name `source.bpl`. Shiki and editors that read TextMate grammars use it to highlight BPL code.
|
|
13
|
+
[BPL on the web](https://answerdotai.github.io/basedpl/web.html) documents this package: loading it, its outputs, values and JavaScript functions, drawing, the language bar, and how the gallery is built. The [playground](https://answerdotai.github.io/basedpl/playground.html) and [gallery](https://answerdotai.github.io/basedpl/gallery.html) run BPL in your browser. The [BPL documentation](https://answerdotai.github.io/basedpl/) covers the language.
|
package/basedpl_wasm.js
CHANGED
|
@@ -9,6 +9,48 @@ export class Session {
|
|
|
9
9
|
const ptr = this.__destroy_into_raw();
|
|
10
10
|
wasm.__wbg_session_free(ptr, 0);
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Binds each property of `names` as a BPL name, to the BPL value that `basedpl::js` converts it to. A JavaScript function becomes a
|
|
14
|
+
* BPL function that calls it. Throws when a property's name isn't a BPL name, or its value has no BPL form.
|
|
15
|
+
* @param {any} names
|
|
16
|
+
*/
|
|
17
|
+
bind(names) {
|
|
18
|
+
try {
|
|
19
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
20
|
+
wasm.session_bind(retptr, this.__wbg_ptr, addBorrowedObject(names));
|
|
21
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
22
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
23
|
+
if (r1) {
|
|
24
|
+
throw takeObject(r0);
|
|
25
|
+
}
|
|
26
|
+
} finally {
|
|
27
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
28
|
+
heap[stack_pointer++] = undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The value of `code` as a JavaScript value, which `basedpl::js` describes, or `undefined` when the code gives no value. A BPL error
|
|
33
|
+
* throws its error object. The code's outputs are dropped, and `run` shows them.
|
|
34
|
+
* @param {string} code
|
|
35
|
+
* @returns {any}
|
|
36
|
+
*/
|
|
37
|
+
eval(code) {
|
|
38
|
+
try {
|
|
39
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
40
|
+
const ptr0 = passStringToWasm0(code, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
41
|
+
const len0 = WASM_VECTOR_LEN;
|
|
42
|
+
wasm.session_eval(retptr, this.__wbg_ptr, ptr0, len0);
|
|
43
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
44
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
45
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
46
|
+
if (r2) {
|
|
47
|
+
throw takeObject(r1);
|
|
48
|
+
}
|
|
49
|
+
return takeObject(r0);
|
|
50
|
+
} finally {
|
|
51
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
12
54
|
constructor() {
|
|
13
55
|
const ret = wasm.session_new();
|
|
14
56
|
this.__wbg_ptr = ret;
|
|
@@ -65,6 +107,17 @@ export function symbols() {
|
|
|
65
107
|
function __wbg_get_imports() {
|
|
66
108
|
const import0 = {
|
|
67
109
|
__proto__: null,
|
|
110
|
+
__wbg___wbindgen_bigint_get_as_i64_a2383202b9353e4c: function(arg0, arg1) {
|
|
111
|
+
const v = getObject(arg1);
|
|
112
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
113
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
114
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
115
|
+
},
|
|
116
|
+
__wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
|
|
117
|
+
const v = getObject(arg0);
|
|
118
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
119
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
120
|
+
},
|
|
68
121
|
__wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
|
|
69
122
|
const ret = debugString(getObject(arg1));
|
|
70
123
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -72,14 +125,31 @@ function __wbg_get_imports() {
|
|
|
72
125
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
73
126
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
74
127
|
},
|
|
128
|
+
__wbg___wbindgen_is_bigint_b123553bed3bb382: function(arg0) {
|
|
129
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
130
|
+
return ret;
|
|
131
|
+
},
|
|
75
132
|
__wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
|
|
76
133
|
const ret = typeof(getObject(arg0)) === 'function';
|
|
77
134
|
return ret;
|
|
78
135
|
},
|
|
136
|
+
__wbg___wbindgen_is_null_e343b7d08827ba72: function(arg0) {
|
|
137
|
+
const ret = getObject(arg0) === null;
|
|
138
|
+
return ret;
|
|
139
|
+
},
|
|
140
|
+
__wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
|
|
141
|
+
const val = getObject(arg0);
|
|
142
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
143
|
+
return ret;
|
|
144
|
+
},
|
|
79
145
|
__wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
|
|
80
146
|
const ret = getObject(arg0) === undefined;
|
|
81
147
|
return ret;
|
|
82
148
|
},
|
|
149
|
+
__wbg___wbindgen_jsval_eq_02babf21faa37971: function(arg0, arg1) {
|
|
150
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
151
|
+
return ret;
|
|
152
|
+
},
|
|
83
153
|
__wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
|
|
84
154
|
const obj = getObject(arg1);
|
|
85
155
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
@@ -97,6 +167,10 @@ function __wbg_get_imports() {
|
|
|
97
167
|
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
98
168
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
99
169
|
},
|
|
170
|
+
__wbg_call_1875a20c43a36133: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
171
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3));
|
|
172
|
+
return addHeapObject(ret);
|
|
173
|
+
}, arguments); },
|
|
100
174
|
__wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
|
|
101
175
|
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
102
176
|
return addHeapObject(ret);
|
|
@@ -117,6 +191,14 @@ function __wbg_get_imports() {
|
|
|
117
191
|
const ret = getObject(arg0).done;
|
|
118
192
|
return ret;
|
|
119
193
|
},
|
|
194
|
+
__wbg_entries_fb6397112b1de25f: function(arg0) {
|
|
195
|
+
const ret = Object.entries(getObject(arg0));
|
|
196
|
+
return addHeapObject(ret);
|
|
197
|
+
},
|
|
198
|
+
__wbg_eval_2f4f6921d1b0da1a: function() { return handleError(function (arg0, arg1) {
|
|
199
|
+
const ret = eval(getStringFromWasm0(arg0, arg1));
|
|
200
|
+
return addHeapObject(ret);
|
|
201
|
+
}, arguments); },
|
|
120
202
|
__wbg_exec_a5f4ba02713fbebe: function(arg0, arg1, arg2) {
|
|
121
203
|
const ret = getObject(arg0).exec(getStringFromWasm0(arg1, arg2));
|
|
122
204
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
@@ -129,6 +211,10 @@ function __wbg_get_imports() {
|
|
|
129
211
|
const ret = getObject(arg0).fontBoundingBoxDescent;
|
|
130
212
|
return ret;
|
|
131
213
|
},
|
|
214
|
+
__wbg_from_296ca31f8d0f1c52: function(arg0) {
|
|
215
|
+
const ret = Array.from(getObject(arg0));
|
|
216
|
+
return addHeapObject(ret);
|
|
217
|
+
},
|
|
132
218
|
__wbg_getAllResponseHeaders_537d007c37d53dba: function() { return handleError(function (arg0, arg1) {
|
|
133
219
|
const ret = getObject(arg1).getAllResponseHeaders();
|
|
134
220
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -177,6 +263,16 @@ function __wbg_get_imports() {
|
|
|
177
263
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
178
264
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
179
265
|
},
|
|
266
|
+
__wbg_instanceof_BigInt64Array_1a1234d945c1625f: function(arg0) {
|
|
267
|
+
let result;
|
|
268
|
+
try {
|
|
269
|
+
result = getObject(arg0) instanceof BigInt64Array;
|
|
270
|
+
} catch (_) {
|
|
271
|
+
result = false;
|
|
272
|
+
}
|
|
273
|
+
const ret = result;
|
|
274
|
+
return ret;
|
|
275
|
+
},
|
|
180
276
|
__wbg_instanceof_CanvasRenderingContext2d_769208c72dcbf5e6: function(arg0) {
|
|
181
277
|
let result;
|
|
182
278
|
try {
|
|
@@ -197,6 +293,26 @@ function __wbg_get_imports() {
|
|
|
197
293
|
const ret = result;
|
|
198
294
|
return ret;
|
|
199
295
|
},
|
|
296
|
+
__wbg_instanceof_Float32Array_595afb0f28b828c9: function(arg0) {
|
|
297
|
+
let result;
|
|
298
|
+
try {
|
|
299
|
+
result = getObject(arg0) instanceof Float32Array;
|
|
300
|
+
} catch (_) {
|
|
301
|
+
result = false;
|
|
302
|
+
}
|
|
303
|
+
const ret = result;
|
|
304
|
+
return ret;
|
|
305
|
+
},
|
|
306
|
+
__wbg_instanceof_Float64Array_8a59377f9eec1b8b: function(arg0) {
|
|
307
|
+
let result;
|
|
308
|
+
try {
|
|
309
|
+
result = getObject(arg0) instanceof Float64Array;
|
|
310
|
+
} catch (_) {
|
|
311
|
+
result = false;
|
|
312
|
+
}
|
|
313
|
+
const ret = result;
|
|
314
|
+
return ret;
|
|
315
|
+
},
|
|
200
316
|
__wbg_instanceof_HtmlCanvasElement_0a30c11fbbf41841: function(arg0) {
|
|
201
317
|
let result;
|
|
202
318
|
try {
|
|
@@ -207,6 +323,36 @@ function __wbg_get_imports() {
|
|
|
207
323
|
const ret = result;
|
|
208
324
|
return ret;
|
|
209
325
|
},
|
|
326
|
+
__wbg_instanceof_Int16Array_dc79388a406d1748: function(arg0) {
|
|
327
|
+
let result;
|
|
328
|
+
try {
|
|
329
|
+
result = getObject(arg0) instanceof Int16Array;
|
|
330
|
+
} catch (_) {
|
|
331
|
+
result = false;
|
|
332
|
+
}
|
|
333
|
+
const ret = result;
|
|
334
|
+
return ret;
|
|
335
|
+
},
|
|
336
|
+
__wbg_instanceof_Int32Array_4b9a86620726269b: function(arg0) {
|
|
337
|
+
let result;
|
|
338
|
+
try {
|
|
339
|
+
result = getObject(arg0) instanceof Int32Array;
|
|
340
|
+
} catch (_) {
|
|
341
|
+
result = false;
|
|
342
|
+
}
|
|
343
|
+
const ret = result;
|
|
344
|
+
return ret;
|
|
345
|
+
},
|
|
346
|
+
__wbg_instanceof_Int8Array_dead59f83656e45a: function(arg0) {
|
|
347
|
+
let result;
|
|
348
|
+
try {
|
|
349
|
+
result = getObject(arg0) instanceof Int8Array;
|
|
350
|
+
} catch (_) {
|
|
351
|
+
result = false;
|
|
352
|
+
}
|
|
353
|
+
const ret = result;
|
|
354
|
+
return ret;
|
|
355
|
+
},
|
|
210
356
|
__wbg_instanceof_OffscreenCanvasRenderingContext2d_957f1a991324c9dc: function(arg0) {
|
|
211
357
|
let result;
|
|
212
358
|
try {
|
|
@@ -217,6 +363,46 @@ function __wbg_get_imports() {
|
|
|
217
363
|
const ret = result;
|
|
218
364
|
return ret;
|
|
219
365
|
},
|
|
366
|
+
__wbg_instanceof_Uint16Array_eff85aa31096af44: function(arg0) {
|
|
367
|
+
let result;
|
|
368
|
+
try {
|
|
369
|
+
result = getObject(arg0) instanceof Uint16Array;
|
|
370
|
+
} catch (_) {
|
|
371
|
+
result = false;
|
|
372
|
+
}
|
|
373
|
+
const ret = result;
|
|
374
|
+
return ret;
|
|
375
|
+
},
|
|
376
|
+
__wbg_instanceof_Uint32Array_53a4facaf04b8a8b: function(arg0) {
|
|
377
|
+
let result;
|
|
378
|
+
try {
|
|
379
|
+
result = getObject(arg0) instanceof Uint32Array;
|
|
380
|
+
} catch (_) {
|
|
381
|
+
result = false;
|
|
382
|
+
}
|
|
383
|
+
const ret = result;
|
|
384
|
+
return ret;
|
|
385
|
+
},
|
|
386
|
+
__wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
|
|
387
|
+
let result;
|
|
388
|
+
try {
|
|
389
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
390
|
+
} catch (_) {
|
|
391
|
+
result = false;
|
|
392
|
+
}
|
|
393
|
+
const ret = result;
|
|
394
|
+
return ret;
|
|
395
|
+
},
|
|
396
|
+
__wbg_instanceof_Uint8ClampedArray_ae70cf3ae1cd285f: function(arg0) {
|
|
397
|
+
let result;
|
|
398
|
+
try {
|
|
399
|
+
result = getObject(arg0) instanceof Uint8ClampedArray;
|
|
400
|
+
} catch (_) {
|
|
401
|
+
result = false;
|
|
402
|
+
}
|
|
403
|
+
const ret = result;
|
|
404
|
+
return ret;
|
|
405
|
+
},
|
|
220
406
|
__wbg_instanceof_Window_82d71df4eddf88bc: function(arg0) {
|
|
221
407
|
let result;
|
|
222
408
|
try {
|
|
@@ -227,14 +413,54 @@ function __wbg_get_imports() {
|
|
|
227
413
|
const ret = result;
|
|
228
414
|
return ret;
|
|
229
415
|
},
|
|
416
|
+
__wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
|
|
417
|
+
const ret = Array.isArray(getObject(arg0));
|
|
418
|
+
return ret;
|
|
419
|
+
},
|
|
420
|
+
__wbg_length_0acba72356589f9c: function(arg0) {
|
|
421
|
+
const ret = getObject(arg0).length;
|
|
422
|
+
return ret;
|
|
423
|
+
},
|
|
424
|
+
__wbg_length_3035e53132b7a991: function(arg0) {
|
|
425
|
+
const ret = getObject(arg0).length;
|
|
426
|
+
return ret;
|
|
427
|
+
},
|
|
428
|
+
__wbg_length_511b1f84719d3462: function(arg0) {
|
|
429
|
+
const ret = getObject(arg0).length;
|
|
430
|
+
return ret;
|
|
431
|
+
},
|
|
432
|
+
__wbg_length_58572db4c38f3c3e: function(arg0) {
|
|
433
|
+
const ret = getObject(arg0).length;
|
|
434
|
+
return ret;
|
|
435
|
+
},
|
|
230
436
|
__wbg_length_7f3c00c40364105e: function(arg0) {
|
|
231
437
|
const ret = getObject(arg0).length;
|
|
232
438
|
return ret;
|
|
233
439
|
},
|
|
440
|
+
__wbg_length_961efae5d4679ef5: function(arg0) {
|
|
441
|
+
const ret = getObject(arg0).length;
|
|
442
|
+
return ret;
|
|
443
|
+
},
|
|
444
|
+
__wbg_length_b5d0ffc9b832763b: function(arg0) {
|
|
445
|
+
const ret = getObject(arg0).length;
|
|
446
|
+
return ret;
|
|
447
|
+
},
|
|
448
|
+
__wbg_length_b5f0008bbf60cf59: function(arg0) {
|
|
449
|
+
const ret = getObject(arg0).length;
|
|
450
|
+
return ret;
|
|
451
|
+
},
|
|
452
|
+
__wbg_length_beff923aab722a55: function(arg0) {
|
|
453
|
+
const ret = getObject(arg0).length;
|
|
454
|
+
return ret;
|
|
455
|
+
},
|
|
234
456
|
__wbg_length_d4bdea10311bd9cf: function(arg0) {
|
|
235
457
|
const ret = getObject(arg0).length;
|
|
236
458
|
return ret;
|
|
237
459
|
},
|
|
460
|
+
__wbg_length_e5fdd54468b9e6ed: function(arg0) {
|
|
461
|
+
const ret = getObject(arg0).length;
|
|
462
|
+
return ret;
|
|
463
|
+
},
|
|
238
464
|
__wbg_matchAll_049fec9c830bd9e3: function(arg0, arg1) {
|
|
239
465
|
const ret = getObject(arg0).matchAll(getObject(arg1));
|
|
240
466
|
return addHeapObject(ret);
|
|
@@ -259,6 +485,10 @@ function __wbg_get_imports() {
|
|
|
259
485
|
const ret = new Uint8Array(getObject(arg0));
|
|
260
486
|
return addHeapObject(ret);
|
|
261
487
|
},
|
|
488
|
+
__wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
|
|
489
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
490
|
+
return addHeapObject(ret);
|
|
491
|
+
},
|
|
262
492
|
__wbg_new_34e56228080aa9f8: function(arg0) {
|
|
263
493
|
const ret = new Date(getObject(arg0));
|
|
264
494
|
return addHeapObject(ret);
|
|
@@ -275,10 +505,34 @@ function __wbg_get_imports() {
|
|
|
275
505
|
const ret = new XMLHttpRequest();
|
|
276
506
|
return addHeapObject(ret);
|
|
277
507
|
}, arguments); },
|
|
508
|
+
__wbg_new_ee2291f50781bf1d: function() {
|
|
509
|
+
const ret = new Array();
|
|
510
|
+
return addHeapObject(ret);
|
|
511
|
+
},
|
|
512
|
+
__wbg_new_from_slice_2443ca2017fac0fd: function(arg0, arg1) {
|
|
513
|
+
const ret = new Int16Array(getArrayI16FromWasm0(arg0, arg1));
|
|
514
|
+
return addHeapObject(ret);
|
|
515
|
+
},
|
|
516
|
+
__wbg_new_from_slice_911f717853b222c7: function(arg0, arg1) {
|
|
517
|
+
const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
|
|
518
|
+
return addHeapObject(ret);
|
|
519
|
+
},
|
|
278
520
|
__wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
|
|
279
521
|
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
280
522
|
return addHeapObject(ret);
|
|
281
523
|
},
|
|
524
|
+
__wbg_new_from_slice_aa8f37bd5e72dcc7: function(arg0, arg1) {
|
|
525
|
+
const ret = new BigInt64Array(getArrayI64FromWasm0(arg0, arg1));
|
|
526
|
+
return addHeapObject(ret);
|
|
527
|
+
},
|
|
528
|
+
__wbg_new_from_slice_f545fd22ddc142b8: function(arg0, arg1) {
|
|
529
|
+
const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
|
|
530
|
+
return addHeapObject(ret);
|
|
531
|
+
},
|
|
532
|
+
__wbg_new_no_args_549db978c37d28cc: function(arg0, arg1) {
|
|
533
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
534
|
+
return addHeapObject(ret);
|
|
535
|
+
},
|
|
282
536
|
__wbg_new_with_base_29cdb449ce79d2d5: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
283
537
|
const ret = new URL(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
|
|
284
538
|
return addHeapObject(ret);
|
|
@@ -318,9 +572,40 @@ function __wbg_get_imports() {
|
|
|
318
572
|
const ret = getObject(arg0).performance;
|
|
319
573
|
return addHeapObject(ret);
|
|
320
574
|
},
|
|
575
|
+
__wbg_prototypesetcall_06eb15da165dee8f: function(arg0, arg1, arg2) {
|
|
576
|
+
Uint32Array.prototype.set.call(getArrayU32FromWasm0(arg0, arg1), getObject(arg2));
|
|
577
|
+
},
|
|
578
|
+
__wbg_prototypesetcall_0e2bc23e51b9fbd2: function(arg0, arg1, arg2) {
|
|
579
|
+
Uint8ClampedArray.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
580
|
+
},
|
|
581
|
+
__wbg_prototypesetcall_13adbfb002dee200: function(arg0, arg1, arg2) {
|
|
582
|
+
Int32Array.prototype.set.call(getArrayI32FromWasm0(arg0, arg1), getObject(arg2));
|
|
583
|
+
},
|
|
584
|
+
__wbg_prototypesetcall_2ee09b855e324444: function(arg0, arg1, arg2) {
|
|
585
|
+
Uint16Array.prototype.set.call(getArrayU16FromWasm0(arg0, arg1), getObject(arg2));
|
|
586
|
+
},
|
|
587
|
+
__wbg_prototypesetcall_546a6fcbab18189a: function(arg0, arg1, arg2) {
|
|
588
|
+
Int8Array.prototype.set.call(getArrayI8FromWasm0(arg0, arg1), getObject(arg2));
|
|
589
|
+
},
|
|
590
|
+
__wbg_prototypesetcall_8b03c01e2c0f8066: function(arg0, arg1, arg2) {
|
|
591
|
+
Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), getObject(arg2));
|
|
592
|
+
},
|
|
593
|
+
__wbg_prototypesetcall_b275ad9519a0a737: function(arg0, arg1, arg2) {
|
|
594
|
+
BigInt64Array.prototype.set.call(getArrayI64FromWasm0(arg0, arg1), getObject(arg2));
|
|
595
|
+
},
|
|
321
596
|
__wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
|
|
322
597
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
323
598
|
},
|
|
599
|
+
__wbg_prototypesetcall_d49a4fab5ca427bc: function(arg0, arg1, arg2) {
|
|
600
|
+
Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), getObject(arg2));
|
|
601
|
+
},
|
|
602
|
+
__wbg_prototypesetcall_f8d32a400a944612: function(arg0, arg1, arg2) {
|
|
603
|
+
Int16Array.prototype.set.call(getArrayI16FromWasm0(arg0, arg1), getObject(arg2));
|
|
604
|
+
},
|
|
605
|
+
__wbg_push_2baf45db356cf468: function(arg0, arg1) {
|
|
606
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
|
607
|
+
return ret;
|
|
608
|
+
},
|
|
324
609
|
__wbg_replace_89a2bb260816315a: function(arg0, arg1, arg2, arg3) {
|
|
325
610
|
const ret = getObject(arg0).replace(getObject(arg1), getStringFromWasm0(arg2, arg3));
|
|
326
611
|
return addHeapObject(ret);
|
|
@@ -384,7 +669,12 @@ function __wbg_get_imports() {
|
|
|
384
669
|
const ret = arg0;
|
|
385
670
|
return addHeapObject(ret);
|
|
386
671
|
},
|
|
387
|
-
__wbindgen_generic_0000000000000002: function(arg0
|
|
672
|
+
__wbindgen_generic_0000000000000002: function(arg0) {
|
|
673
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
674
|
+
const ret = arg0;
|
|
675
|
+
return addHeapObject(ret);
|
|
676
|
+
},
|
|
677
|
+
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
388
678
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
389
679
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
390
680
|
return addHeapObject(ret);
|
|
@@ -417,6 +707,12 @@ function addHeapObject(obj) {
|
|
|
417
707
|
return idx;
|
|
418
708
|
}
|
|
419
709
|
|
|
710
|
+
function addBorrowedObject(obj) {
|
|
711
|
+
if (stack_pointer == 1) throw new Error('out of js stack');
|
|
712
|
+
heap[--stack_pointer] = obj;
|
|
713
|
+
return stack_pointer;
|
|
714
|
+
}
|
|
715
|
+
|
|
420
716
|
function debugString(val) {
|
|
421
717
|
// primitive types
|
|
422
718
|
const type = typeof val;
|
|
@@ -488,11 +784,59 @@ function dropObject(idx) {
|
|
|
488
784
|
heap_next = idx;
|
|
489
785
|
}
|
|
490
786
|
|
|
787
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
788
|
+
ptr = ptr >>> 0;
|
|
789
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
793
|
+
ptr = ptr >>> 0;
|
|
794
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function getArrayI16FromWasm0(ptr, len) {
|
|
798
|
+
ptr = ptr >>> 0;
|
|
799
|
+
return getInt16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function getArrayI32FromWasm0(ptr, len) {
|
|
803
|
+
ptr = ptr >>> 0;
|
|
804
|
+
return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
function getArrayI64FromWasm0(ptr, len) {
|
|
808
|
+
ptr = ptr >>> 0;
|
|
809
|
+
return getBigInt64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
function getArrayI8FromWasm0(ptr, len) {
|
|
813
|
+
ptr = ptr >>> 0;
|
|
814
|
+
return getInt8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
function getArrayU16FromWasm0(ptr, len) {
|
|
818
|
+
ptr = ptr >>> 0;
|
|
819
|
+
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
823
|
+
ptr = ptr >>> 0;
|
|
824
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
825
|
+
}
|
|
826
|
+
|
|
491
827
|
function getArrayU8FromWasm0(ptr, len) {
|
|
492
828
|
ptr = ptr >>> 0;
|
|
493
829
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
494
830
|
}
|
|
495
831
|
|
|
832
|
+
let cachedBigInt64ArrayMemory0 = null;
|
|
833
|
+
function getBigInt64ArrayMemory0() {
|
|
834
|
+
if (cachedBigInt64ArrayMemory0 === null || cachedBigInt64ArrayMemory0.byteLength === 0) {
|
|
835
|
+
cachedBigInt64ArrayMemory0 = new BigInt64Array(wasm.memory.buffer);
|
|
836
|
+
}
|
|
837
|
+
return cachedBigInt64ArrayMemory0;
|
|
838
|
+
}
|
|
839
|
+
|
|
496
840
|
let cachedDataViewMemory0 = null;
|
|
497
841
|
function getDataViewMemory0() {
|
|
498
842
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -501,10 +845,66 @@ function getDataViewMemory0() {
|
|
|
501
845
|
return cachedDataViewMemory0;
|
|
502
846
|
}
|
|
503
847
|
|
|
848
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
849
|
+
function getFloat32ArrayMemory0() {
|
|
850
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
851
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
852
|
+
}
|
|
853
|
+
return cachedFloat32ArrayMemory0;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
857
|
+
function getFloat64ArrayMemory0() {
|
|
858
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
859
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
860
|
+
}
|
|
861
|
+
return cachedFloat64ArrayMemory0;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
let cachedInt16ArrayMemory0 = null;
|
|
865
|
+
function getInt16ArrayMemory0() {
|
|
866
|
+
if (cachedInt16ArrayMemory0 === null || cachedInt16ArrayMemory0.byteLength === 0) {
|
|
867
|
+
cachedInt16ArrayMemory0 = new Int16Array(wasm.memory.buffer);
|
|
868
|
+
}
|
|
869
|
+
return cachedInt16ArrayMemory0;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
let cachedInt32ArrayMemory0 = null;
|
|
873
|
+
function getInt32ArrayMemory0() {
|
|
874
|
+
if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
|
|
875
|
+
cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
|
|
876
|
+
}
|
|
877
|
+
return cachedInt32ArrayMemory0;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
let cachedInt8ArrayMemory0 = null;
|
|
881
|
+
function getInt8ArrayMemory0() {
|
|
882
|
+
if (cachedInt8ArrayMemory0 === null || cachedInt8ArrayMemory0.byteLength === 0) {
|
|
883
|
+
cachedInt8ArrayMemory0 = new Int8Array(wasm.memory.buffer);
|
|
884
|
+
}
|
|
885
|
+
return cachedInt8ArrayMemory0;
|
|
886
|
+
}
|
|
887
|
+
|
|
504
888
|
function getStringFromWasm0(ptr, len) {
|
|
505
889
|
return decodeText(ptr >>> 0, len);
|
|
506
890
|
}
|
|
507
891
|
|
|
892
|
+
let cachedUint16ArrayMemory0 = null;
|
|
893
|
+
function getUint16ArrayMemory0() {
|
|
894
|
+
if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
|
|
895
|
+
cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
896
|
+
}
|
|
897
|
+
return cachedUint16ArrayMemory0;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
let cachedUint32ArrayMemory0 = null;
|
|
901
|
+
function getUint32ArrayMemory0() {
|
|
902
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
903
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
904
|
+
}
|
|
905
|
+
return cachedUint32ArrayMemory0;
|
|
906
|
+
}
|
|
907
|
+
|
|
508
908
|
let cachedUint8ArrayMemory0 = null;
|
|
509
909
|
function getUint8ArrayMemory0() {
|
|
510
910
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
@@ -569,6 +969,8 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
569
969
|
return ptr;
|
|
570
970
|
}
|
|
571
971
|
|
|
972
|
+
let stack_pointer = 1024;
|
|
973
|
+
|
|
572
974
|
function takeObject(idx) {
|
|
573
975
|
const ret = getObject(idx);
|
|
574
976
|
dropObject(idx);
|
|
@@ -609,7 +1011,15 @@ function __wbg_finalize_init(instance, module) {
|
|
|
609
1011
|
wasmInstance = instance;
|
|
610
1012
|
wasm = instance.exports;
|
|
611
1013
|
wasmModule = module;
|
|
1014
|
+
cachedBigInt64ArrayMemory0 = null;
|
|
612
1015
|
cachedDataViewMemory0 = null;
|
|
1016
|
+
cachedFloat32ArrayMemory0 = null;
|
|
1017
|
+
cachedFloat64ArrayMemory0 = null;
|
|
1018
|
+
cachedInt16ArrayMemory0 = null;
|
|
1019
|
+
cachedInt32ArrayMemory0 = null;
|
|
1020
|
+
cachedInt8ArrayMemory0 = null;
|
|
1021
|
+
cachedUint16ArrayMemory0 = null;
|
|
1022
|
+
cachedUint32ArrayMemory0 = null;
|
|
613
1023
|
cachedUint8ArrayMemory0 = null;
|
|
614
1024
|
return wasm;
|
|
615
1025
|
}
|
package/basedpl_wasm_bg.wasm
CHANGED
|
Binary file
|
package/canvas.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Draws a `•canvas` output on `canvas`. `json` holds the drawing function's JavaScript source, its options and its data. Each typed
|
|
2
|
+
// array in the data is `{$typed, offset, length}`, a view of `bytes`. The native build runs this script from the output's HTML. A page
|
|
3
|
+
// that shows the browser build's outputs calls it with the output's two entries.
|
|
4
|
+
(canvas, json, bytes) => {
|
|
5
|
+
const view = (_, v) => v?.$typed ? new globalThis[v.$typed](bytes.buffer, bytes.byteOffset + v.offset, v.length) : v;
|
|
6
|
+
const { source, options, data } = JSON.parse(json, view);
|
|
7
|
+
(0, eval)(source)(canvas.getContext('2d'), data, options);
|
|
8
|
+
}
|
package/layout.json
CHANGED
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"'": "⊢",
|
|
41
41
|
"z": "⊂",
|
|
42
42
|
"x": "⊃",
|
|
43
|
-
"c":
|
|
43
|
+
"c": "∩",
|
|
44
44
|
"v": "∪",
|
|
45
|
-
"b":
|
|
46
|
-
"n":
|
|
45
|
+
"b": "⊥",
|
|
46
|
+
"n": "⊤",
|
|
47
47
|
"m": "×",
|
|
48
48
|
",": "↢",
|
|
49
49
|
".": "↣",
|
|
@@ -61,11 +61,8 @@
|
|
|
61
61
|
"bar": {"terminator": "¯", "keys": {",": "⍪", "\\": "⍀", "/": "⌿", "a": "⍶", "w": "⍹", "7": "⍙", "`": "⍚", "0": "⊼", "9": "⊽", "e": "⍷", "i": "⍸", "z": "⊆"}},
|
|
62
62
|
"match": {"terminator": "≡", "keys": {"/": "≢"}},
|
|
63
63
|
"quad": {"terminator": "⎕", "keys": {"t": "⌻", ":": "⍠", "=": "⌸", "u": "⌹", "|": "⌷", "`": "⌺", ";": "⍠", "\\": "⌷"}},
|
|
64
|
-
"circle": {"terminator": "○", "keys": {"-": "⊖", "\\": "⍉", "/": "⊘", "*": "⍟", "m": "⊗", "u": "⨸", "t": "⌾", "8": "⍟"}},
|
|
64
|
+
"circle": {"terminator": "○", "keys": {"-": "⊖", "\\": "⍉", "/": "⊘", "*": "⍟", "m": "⊗", "u": "⨸", "t": "⌾", "8": "⍟", "c": "⍝", "b": "⍎", "n": "⍕"}},
|
|
65
65
|
"stile": {"terminator": "⍭", "keys": {"7": "⍋", "g": "⍒"}},
|
|
66
|
-
"take": {"terminator": "↑", "keys": {"j": "↕"}}
|
|
67
|
-
"cap": {"terminator": "∩", "keys": {"t": "⍝"}},
|
|
68
|
-
"decode": {"terminator": "⊥", "keys": {"t": "⍎"}},
|
|
69
|
-
"encode": {"terminator": "⊤", "keys": {"t": "⍕"}}
|
|
66
|
+
"take": {"terminator": "↑", "keys": {"j": "↕"}}
|
|
70
67
|
}
|
|
71
68
|
}
|
package/lb.js
CHANGED
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
}
|
|
111
111
|
// Related glyphs stay together; arrows meet at the boundary between menus and plain buttons.
|
|
112
112
|
const order = [...new Set([
|
|
113
|
-
...'^_
|
|
113
|
+
...'^_¯¨○⎕≡⍭↑↓←→↢↣⇄∨∧⍺⍵∆∇⋄∊⍳⊂⊃∩∪⊥⊤⊣⊢×÷⌊⌈≤≥≠√π', ...groups.keys(), ...names.keys()
|
|
114
114
|
])];
|
|
115
115
|
for (const glyph of [...order.filter(g => groups.has(g)), ...order.filter(g => !groups.has(g))]) {
|
|
116
116
|
if (!groups.has(glyph) && (variants.has(glyph) || /^[\x20-\x7e]+$/.test(glyph))) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basedpl",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"description": "BasedPL, the Based-array Programming Language, is an APL-derived array language, borrowing ideas from J and BQN, with an emphasis on simple, consistent notation.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|