mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 01:02:01 +03:00
replaces new Function() in the main window; per-script and per-call interrupt deadlines, memory and stack limits, graceful skip if the wasm module fails to load. csp script-src drops 'unsafe-eval' for 'wasm-unsafe-eval'.
23 lines
858 B
JavaScript
23 lines
858 B
JavaScript
// Summarum extension example.
|
|
// Drop .js files into this folder and restart the app.
|
|
// API: numi.setVariable, numi.addUnit, numi.addFunction.
|
|
//
|
|
// Scripts run in a WebAssembly sandbox: no files, no network, no app internals,
|
|
// and no console/setTimeout/fetch — only plain JS and the numi API above.
|
|
|
|
// A global variable usable on any sheet, e.g. `salary * vat`
|
|
// numi.setVariable("vat", { "double": 20 });
|
|
|
|
// A custom unit: 1 floor = 3 meters, so `5 floors in meters` works
|
|
// numi.addUnit({
|
|
// "id": "floor",
|
|
// "phrases": "floor, floors, этаж, этажа, этажей",
|
|
// "baseUnitId": "meter",
|
|
// "format": "fl",
|
|
// "ratio": 3,
|
|
// });
|
|
|
|
// A custom function: hyp(3; 4) -> 5
|
|
// numi.addFunction({ "id": "hyp", "phrases": "hyp" }, function (values) {
|
|
// return { "double": Math.hypot(values[0].double, values[1].double) };
|
|
// });
|