@strategicprojects/rpic 0.1.1 → 0.3.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/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # rpic
2
2
 
3
3
  JS/TS bindings for [rpic](https://github.com/milkway/rpic-lang) — the pic
4
- graphics language compiled to **SVG** with an **animation manifest**, via
5
- WebAssembly. Works in the browser and in Node, ships TypeScript types.
4
+ graphics language compiled to **SVG** with animation and diagnostic manifests,
5
+ via WebAssembly. Works in the browser and in Node, ships TypeScript types.
6
6
 
7
7
  ```js
8
8
  import * as rpic from '@strategicprojects/rpic';
9
9
 
10
10
  await rpic.ready(); // browser: wasm fetched automatically
11
11
 
12
- const { svg, animations } = rpic.compile('box "A"; arrow; box "B"');
12
+ const { svg, animations, diagnostics } = rpic.compile('box "A"; arrow; box "B"');
13
13
  document.querySelector('#stage').innerHTML = svg;
14
14
 
15
15
  // animate with GSAP:
@@ -34,7 +34,7 @@ console.log(rpic.renderSvg('box "hi"'));
34
34
  | Function | Description |
35
35
  |----------|-------------|
36
36
  | `ready(wasmInput?)` | Initialize WASM. Browser: no arg. Node: pass `.wasm` bytes/URL. |
37
- | `compile(src, {circuits?})` | → `{ svg, animations }` (throws on a pic error). |
37
+ | `compile(src, {circuits?})` | → `{ svg, animations, diagnostics }` (throws on a pic error). |
38
38
  | `renderSvg(src, {circuits?})` | → SVG string. |
39
39
  | `animate(root, animations, gsap)` | Build/play a GSAP timeline (`draw`/`fade`/`pop`). Browser only. |
40
40
 
package/index.d.ts CHANGED
@@ -11,6 +11,8 @@ export interface Anim {
11
11
  export interface Bundle {
12
12
  svg: string;
13
13
  animations: Anim[];
14
+ /** lines emitted by pic `print` statements */
15
+ diagnostics: string[];
14
16
  }
15
17
 
16
18
  export interface CompileOptions {
@@ -24,7 +26,7 @@ export interface CompileOptions {
24
26
  */
25
27
  export function ready(wasmInput?: BufferSource | URL | string): Promise<void>;
26
28
 
27
- /** Compile pic source into `{ svg, animations }`. Throws on a pic error. */
29
+ /** Compile pic source into `{ svg, animations, diagnostics }`. Throws on a pic error. */
28
30
  export function compile(src: string, opts?: CompileOptions): Bundle;
29
31
 
30
32
  /** Compile and return only the SVG string. */
package/index.js CHANGED
@@ -33,7 +33,7 @@ function ensure() {
33
33
  }
34
34
 
35
35
  /**
36
- * Compile pic source into `{ svg, animations }` (throws on a pic error).
36
+ * Compile pic source into `{ svg, animations, diagnostics }` (throws on a pic error).
37
37
  * @param {string} src
38
38
  * @param {{circuits?: boolean}} [opts]
39
39
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strategicprojects/rpic",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "The pic graphics language compiled to SVG with animation manifests, via WebAssembly. Browser + Node.",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -2,7 +2,8 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  /**
5
- * Compile pic source to a JSON `{svg, animations}` bundle (or `{error}`).
5
+ * Compile pic source to a JSON `{svg, animations, diagnostics}` bundle (or
6
+ * `{error}`).
6
7
  */
7
8
  export function compile(src: string): string;
8
9
 
package/pkg/rpic_wasm.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /* @ts-self-types="./rpic_wasm.d.ts" */
2
2
 
3
3
  /**
4
- * Compile pic source to a JSON `{svg, animations}` bundle (or `{error}`).
4
+ * Compile pic source to a JSON `{svg, animations, diagnostics}` bundle (or
5
+ * `{error}`).
5
6
  * @param {string} src
6
7
  * @returns {string}
7
8
  */
Binary file