@strategicprojects/rpic 0.3.0 → 0.4.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.
- package/index.d.ts +7 -0
- package/index.js +7 -2
- package/package.json +1 -1
- package/pkg/rpic_wasm.d.ts +11 -0
- package/pkg/rpic_wasm.js +27 -0
- package/pkg/rpic_wasm_bg.wasm +0 -0
- package/pkg/rpic_wasm_bg.wasm.d.ts +1 -0
package/index.d.ts
CHANGED
|
@@ -18,6 +18,13 @@ export interface Bundle {
|
|
|
18
18
|
export interface CompileOptions {
|
|
19
19
|
/** prepend the native circuit-element library (resistor, and_gate, …) */
|
|
20
20
|
circuits?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* set `texlabels = 1`, typesetting fully `$…$`-delimited labels as TeX
|
|
23
|
+
* math. The default wasm build ships without the math renderer (size
|
|
24
|
+
* budget), so labels fall back to literal text plus a diagnostic; the
|
|
25
|
+
* option exists for API parity and future math-enabled builds.
|
|
26
|
+
*/
|
|
27
|
+
texlabels?: boolean;
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
/**
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import initWasm, {
|
|
6
6
|
compile as wasmCompile,
|
|
7
7
|
compile_circuits as wasmCompileCircuits,
|
|
8
|
+
compile_with as wasmCompileWith,
|
|
8
9
|
} from './pkg/rpic_wasm.js';
|
|
9
10
|
|
|
10
11
|
let initPromise = null;
|
|
@@ -35,11 +36,15 @@ function ensure() {
|
|
|
35
36
|
/**
|
|
36
37
|
* Compile pic source into `{ svg, animations, diagnostics }` (throws on a pic error).
|
|
37
38
|
* @param {string} src
|
|
38
|
-
* @param {{circuits?: boolean}} [opts]
|
|
39
|
+
* @param {{circuits?: boolean, texlabels?: boolean}} [opts]
|
|
39
40
|
*/
|
|
40
41
|
export function compile(src, opts = {}) {
|
|
41
42
|
ensure();
|
|
42
|
-
const json = opts.
|
|
43
|
+
const json = opts.texlabels
|
|
44
|
+
? wasmCompileWith(src, !!opts.circuits, true)
|
|
45
|
+
: opts.circuits
|
|
46
|
+
? wasmCompileCircuits(src)
|
|
47
|
+
: wasmCompile(src);
|
|
43
48
|
const out = JSON.parse(json);
|
|
44
49
|
if (out.error) throw new Error(out.error);
|
|
45
50
|
return out;
|
package/package.json
CHANGED
package/pkg/rpic_wasm.d.ts
CHANGED
|
@@ -13,12 +13,23 @@ export function compile(src: string): string;
|
|
|
13
13
|
*/
|
|
14
14
|
export function compile_circuits(src: string): string;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Like [`compile`], with options: `circuits` prepends the circuit-element
|
|
18
|
+
* library; `texlabels` sets `texlabels = 1` so `$…$` labels are typeset as
|
|
19
|
+
* TeX math. Note: this wasm build ships without the math renderer (size
|
|
20
|
+
* budget), so with `texlabels` the labels currently fall back to literal
|
|
21
|
+
* text and a diagnostic — the option exists for API parity and for future
|
|
22
|
+
* math-enabled builds.
|
|
23
|
+
*/
|
|
24
|
+
export function compile_with(src: string, circuits: boolean, texlabels: boolean): string;
|
|
25
|
+
|
|
16
26
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
17
27
|
|
|
18
28
|
export interface InitOutput {
|
|
19
29
|
readonly memory: WebAssembly.Memory;
|
|
20
30
|
readonly compile: (a: number, b: number) => [number, number];
|
|
21
31
|
readonly compile_circuits: (a: number, b: number) => [number, number];
|
|
32
|
+
readonly compile_with: (a: number, b: number, c: number, d: number) => [number, number];
|
|
22
33
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
23
34
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
24
35
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
package/pkg/rpic_wasm.js
CHANGED
|
@@ -41,6 +41,33 @@ export function compile_circuits(src) {
|
|
|
41
41
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Like [`compile`], with options: `circuits` prepends the circuit-element
|
|
47
|
+
* library; `texlabels` sets `texlabels = 1` so `$…$` labels are typeset as
|
|
48
|
+
* TeX math. Note: this wasm build ships without the math renderer (size
|
|
49
|
+
* budget), so with `texlabels` the labels currently fall back to literal
|
|
50
|
+
* text and a diagnostic — the option exists for API parity and for future
|
|
51
|
+
* math-enabled builds.
|
|
52
|
+
* @param {string} src
|
|
53
|
+
* @param {boolean} circuits
|
|
54
|
+
* @param {boolean} texlabels
|
|
55
|
+
* @returns {string}
|
|
56
|
+
*/
|
|
57
|
+
export function compile_with(src, circuits, texlabels) {
|
|
58
|
+
let deferred2_0;
|
|
59
|
+
let deferred2_1;
|
|
60
|
+
try {
|
|
61
|
+
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
62
|
+
const len0 = WASM_VECTOR_LEN;
|
|
63
|
+
const ret = wasm.compile_with(ptr0, len0, circuits, texlabels);
|
|
64
|
+
deferred2_0 = ret[0];
|
|
65
|
+
deferred2_1 = ret[1];
|
|
66
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
67
|
+
} finally {
|
|
68
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
44
71
|
function __wbg_get_imports() {
|
|
45
72
|
const import0 = {
|
|
46
73
|
__proto__: null,
|
package/pkg/rpic_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const compile: (a: number, b: number) => [number, number];
|
|
5
5
|
export const compile_circuits: (a: number, b: number) => [number, number];
|
|
6
|
+
export const compile_with: (a: number, b: number, c: number, d: number) => [number, number];
|
|
6
7
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
7
8
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
8
9
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|