numbl 0.4.4 → 0.4.6
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 +5 -1
- package/dist-cli/cli.js +16094 -13802
- package/dist-lib/graphics/figuresReducer.d.ts +9 -0
- package/dist-lib/graphics/types.d.ts +12 -0
- package/dist-lib/lib.d.ts +2 -0
- package/dist-lib/lib.js +2330 -5207
- package/dist-lib/numbl-core/executeCode.d.ts +10 -0
- package/dist-lib/numbl-core/executors/plugins.d.ts +9 -0
- package/dist-lib/numbl-core/helpers/marching-cubes-tables.d.ts +10 -0
- package/dist-lib/numbl-core/helpers/marching-cubes.d.ts +46 -0
- package/dist-lib/numbl-core/interpreter/builtins/array-construction.d.ts +7 -1
- package/dist-lib/numbl-core/interpreter/builtins/geometry.d.ts +10 -0
- package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +1 -0
- package/dist-lib/numbl-core/interpreter/interpreter.d.ts +1 -0
- package/dist-lib/numbl-core/interpreter/interpreterExec.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/snippets.c.gen.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/snippets.gen.d.ts +0 -2
- package/dist-lib/numbl-core/jit/codegen/runtime.d.ts +2 -0
- package/dist-lib/numbl-core/native/geometry-bridge.d.ts +29 -0
- package/dist-lib/numbl-core/native/qhull-browser.d.ts +15 -0
- package/dist-lib/numbl-core/native/qhull-node.d.ts +13 -0
- package/dist-lib/numbl-core/runtime/plotBuiltinDispatch.d.ts +6 -0
- package/dist-lib/numbl-core/runtime/plotUtils.d.ts +18 -0
- package/dist-lib/numbl-core/runtime/runtime.d.ts +22 -0
- package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +1 -0
- package/dist-lib/numbl-core/runtime/uihtmlSession.d.ts +40 -0
- package/dist-lib/numbl-core/version.d.ts +1 -1
- package/dist-plot-viewer/assets/index-D4grNz8m.js +4504 -0
- package/dist-plot-viewer/index.html +1 -1
- package/dist-site-viewer/assets/index-B2mCFC55.js +4826 -0
- package/dist-site-viewer/assets/numbl-worker-DWZE29ck.js +5116 -0
- package/dist-site-viewer/assets/qhull-DM50poqF.wasm +0 -0
- package/dist-site-viewer/index.html +1 -1
- package/dist-site-viewer/numbl-embed.js +55 -13
- package/package.json +2 -1
- package/dist-plot-viewer/assets/index-Ct51ZiF1.js +0 -4426
- package/dist-site-viewer/assets/index-USrK1-DZ.js +0 -4748
- package/dist-site-viewer/assets/numbl-worker-s3tsbJJ2.js +0 -12003
|
Binary file
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<title>numbl project</title>
|
|
8
8
|
<!-- numbl:base -->
|
|
9
9
|
<script src="./coi-serviceworker.js"></script>
|
|
10
|
-
<script type="module" crossorigin src="./assets/index-
|
|
10
|
+
<script type="module" crossorigin src="./assets/index-B2mCFC55.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="./assets/index-D5YY8PKx.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
@@ -5,14 +5,37 @@ Usage:
|
|
|
5
5
|
<numbl-embed>
|
|
6
6
|
<iframe width="100%" height="500" frameborder="0"></iframe>
|
|
7
7
|
|
|
8
|
-
<script type="text/plain" class="
|
|
9
|
-
...
|
|
8
|
+
<script type="text/plain" class="numbl-script">
|
|
9
|
+
... numbl script ...
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
</numbl-embed>
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Optional preamble: setup code that runs before the visible script on every Run
|
|
15
|
+
(e.g. installing a package with `mip load --install ...`). It is kept out of the
|
|
16
|
+
editor, and its console output is hidden behind a "Preparing…" message unless it
|
|
17
|
+
errors — in which case the output and error are shown. Override that message
|
|
18
|
+
per-embed with the `preparing-label` attribute (e.g. "Installing…").
|
|
19
|
+
|
|
20
|
+
<numbl-embed preparing-label="Installing…">
|
|
21
|
+
<iframe width="100%" height="500" frameborder="0"></iframe>
|
|
22
|
+
|
|
23
|
+
<script type="text/plain" class="numbl-preamble">
|
|
24
|
+
mip load --install owner/repo/package
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script type="text/plain" class="numbl-script">
|
|
28
|
+
... numbl script ...
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
</numbl-embed>
|
|
32
|
+
|
|
33
|
+
The classes `matlab-script` / `matlab-preamble` are accepted as synonyms for
|
|
34
|
+
`numbl-script` / `numbl-preamble` (backward compatibility with older embeds).
|
|
35
|
+
|
|
36
|
+
You can also specify the script URL via attribute (a `numbl-preamble` block still
|
|
37
|
+
applies):
|
|
38
|
+
<numbl-embed script="relative-or-absolute-url-to-script">
|
|
16
39
|
<iframe width="100%" height="500" frameborder="0"></iframe>
|
|
17
40
|
</numbl-embed>
|
|
18
41
|
|
|
@@ -123,28 +146,47 @@ class NumblEmbed extends HTMLElement {
|
|
|
123
146
|
return utf8ToBase64(text2);
|
|
124
147
|
};
|
|
125
148
|
|
|
126
|
-
|
|
149
|
+
// Optional preamble: setup code that runs (hidden) before the visible
|
|
150
|
+
// script. `numbl-preamble` is preferred; `matlab-preamble` is a synonym.
|
|
151
|
+
const preambleElement = this.querySelector(
|
|
152
|
+
"script.numbl-preamble, script.matlab-preamble"
|
|
153
|
+
);
|
|
154
|
+
let preambleParam = preambleElement
|
|
155
|
+
? `&preamble=${encodePlain(preambleElement.textContent.trim())}`
|
|
156
|
+
: "";
|
|
157
|
+
|
|
158
|
+
// Message shown while the preamble runs (defaults to "Preparing..." in the
|
|
159
|
+
// embed page). Override per-embed with the `preparing-label` attribute,
|
|
160
|
+
// e.g. preparing-label="Installing...".
|
|
161
|
+
const preparingLabel = this.getAttribute("preparing-label");
|
|
162
|
+
if (preambleParam && preparingLabel) {
|
|
163
|
+
preambleParam += `&preparing=${utf8ToBase64(preparingLabel)}`;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// `numbl-script` is preferred; `matlab-script` is a synonym.
|
|
167
|
+
const scriptElement = this.querySelector(
|
|
168
|
+
"script.numbl-script, script.matlab-script"
|
|
169
|
+
);
|
|
127
170
|
|
|
128
171
|
let scriptBase64;
|
|
129
172
|
if (scriptElement) {
|
|
130
|
-
|
|
131
|
-
scriptBase64 = encodePlain(matlabScript);
|
|
173
|
+
scriptBase64 = encodePlain(scriptElement.textContent.trim());
|
|
132
174
|
} else if (this.attributes.script) {
|
|
133
175
|
const scriptUrl = this.attributes.script.value;
|
|
134
|
-
this.loadScriptFromUrl(scriptUrl);
|
|
176
|
+
this.loadScriptFromUrl(scriptUrl, preambleParam);
|
|
135
177
|
return;
|
|
136
178
|
} else {
|
|
137
179
|
scriptBase64 = null;
|
|
138
180
|
}
|
|
139
181
|
|
|
140
182
|
if (scriptBase64) {
|
|
141
|
-
this.iframe.src = `${numblUrl}/embed?script=${scriptBase64}&${cacheBust}`;
|
|
183
|
+
this.iframe.src = `${numblUrl}/embed?script=${scriptBase64}${preambleParam}&${cacheBust}`;
|
|
142
184
|
} else {
|
|
143
|
-
this.iframe.src = `${numblUrl}/embed?${cacheBust}`;
|
|
185
|
+
this.iframe.src = `${numblUrl}/embed?${cacheBust}${preambleParam}`;
|
|
144
186
|
}
|
|
145
187
|
}
|
|
146
188
|
|
|
147
|
-
async loadScriptFromUrl(url) {
|
|
189
|
+
async loadScriptFromUrl(url, preambleParam = "") {
|
|
148
190
|
try {
|
|
149
191
|
let absoluteUrl = url;
|
|
150
192
|
if (url.startsWith("./") || url.startsWith("../")) {
|
|
@@ -164,9 +206,9 @@ class NumblEmbed extends HTMLElement {
|
|
|
164
206
|
const numblUrl = this.attributes["numbl-url"]?.value || defaultNumblUrl;
|
|
165
207
|
|
|
166
208
|
const cacheBust = `_cb=${Date.now()}`;
|
|
167
|
-
this.iframe.src = `${numblUrl}/embed?script=${scriptBase64}&${cacheBust}`;
|
|
209
|
+
this.iframe.src = `${numblUrl}/embed?script=${scriptBase64}${preambleParam}&${cacheBust}`;
|
|
168
210
|
} catch (error) {
|
|
169
|
-
console.error("Error loading
|
|
211
|
+
console.error("Error loading script:", error);
|
|
170
212
|
this.iframe.srcdoc = `
|
|
171
213
|
<html>
|
|
172
214
|
<body style="font-family: Arial; padding: 20px;">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "numbl",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "Run .m source files in the browser and on the command line by compiling to JavaScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"fflate": "^0.8.2",
|
|
77
77
|
"node-addon-api": "^8.3.0",
|
|
78
78
|
"pako": "^2.1.0",
|
|
79
|
+
"qhull-wasm": "^0.0.1",
|
|
79
80
|
"react-markdown": "^10.1.0",
|
|
80
81
|
"react-syntax-highlighter": "^16.1.1",
|
|
81
82
|
"remark-gfm": "^4.0.1",
|