@diodeinc/pcb-zen-wasm 0.4.40 → 0.4.42

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
@@ -3,8 +3,12 @@
3
3
  `pcb-zen-wasm` exposes the Zener evaluator to browser applications through
4
4
  WebAssembly.
5
5
 
6
- [`bin/build-wasm-bundle.sh`](../../bin/build-wasm-bundle.sh) builds and publishes
7
- the npm package with `wasm-pack`.
6
+ Results are ordinary JavaScript values (`number`, object, array, `null`).
7
+ Values outside `Number.MAX_SAFE_INTEGER` follow JavaScript Number precision.
8
+
9
+ [`bin/build-wasm-bundle.sh`](../../bin/build-wasm-bundle.sh) builds a local browser
10
+ bundle with `wasm-pack` in `target/wasm-bundle`. It does not publish anything.
11
+ Pass `ipc` to the same script to build the [IPC bindings](../pcb-ipc-wasm/README.md).
8
12
 
9
13
  To test a generated bundle against a `pcb publish` release archive, run:
10
14
 
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Diode Computers, Inc. <founders@diode.computer>"
6
6
  ],
7
7
  "description": "WebAssembly bindings for the Zener PCB design language",
8
- "version": "0.4.40",
8
+ "version": "0.4.42",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/diodeinc/pcb"
package/pcb_zen_wasm.d.ts CHANGED
@@ -17,6 +17,8 @@ export interface InitOutput {
17
17
  readonly __wbindgen_malloc_command_export: (a: number, b: number) => number;
18
18
  readonly __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number;
19
19
  readonly __wbindgen_free_command_export: (a: number, b: number, c: number) => void;
20
+ readonly __wbindgen_exn_store_command_export: (a: number) => void;
21
+ readonly __externref_table_alloc_command_export: () => number;
20
22
  readonly __wbindgen_externrefs: WebAssembly.Table;
21
23
  readonly __externref_table_dealloc_command_export: (a: number) => void;
22
24
  readonly __wbindgen_start: () => void;
package/pcb_zen_wasm.js CHANGED
@@ -30,31 +30,20 @@ export function start() {
30
30
  function __wbg_get_imports() {
31
31
  const import0 = {
32
32
  __proto__: null,
33
- __wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
34
- const ret = Error(getStringFromWasm0(arg0, arg1));
35
- return ret;
36
- },
37
- __wbg_String_8564e559799eccda: function(arg0, arg1) {
38
- const ret = String(arg1);
33
+ __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
34
+ const ret = debugString(arg1);
39
35
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
40
36
  const len1 = WASM_VECTOR_LEN;
41
37
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
42
38
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
43
39
  },
44
- __wbg___wbindgen_is_string_ea5e6cc2e4141dfe: function(arg0) {
45
- const ret = typeof(arg0) === 'string';
46
- return ret;
47
- },
48
- __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
40
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
49
41
  throw new Error(getStringFromWasm0(arg0, arg1));
50
42
  },
51
- __wbg_debug_87fd9b1a625b7efb: function(arg0) {
43
+ __wbg_debug_3853dbaf0bca30f9: function(arg0) {
52
44
  console.debug(arg0);
53
45
  },
54
- __wbg_error_744744ff0c9861e6: function(arg0) {
55
- console.error(arg0);
56
- },
57
- __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
46
+ __wbg_error_757e9472f8410341: function(arg0, arg1) {
58
47
  let deferred0_0;
59
48
  let deferred0_1;
60
49
  try {
@@ -65,38 +54,23 @@ function __wbg_get_imports() {
65
54
  wasm.__wbindgen_free_command_export(deferred0_0, deferred0_1, 1);
66
55
  }
67
56
  },
68
- __wbg_info_eadbe775a8e2e9eb: function(arg0) {
57
+ __wbg_error_dd408a7b3cb542dd: function(arg0) {
58
+ console.error(arg0);
59
+ },
60
+ __wbg_info_726982aff9befe16: function(arg0) {
69
61
  console.info(arg0);
70
62
  },
71
- __wbg_log_d267660666346fb3: function(arg0) {
63
+ __wbg_log_e6372b4fbfc9f81e: function(arg0) {
72
64
  console.log(arg0);
73
65
  },
74
66
  __wbg_new_227d7c05414eb861: function() {
75
67
  const ret = new Error();
76
68
  return ret;
77
69
  },
78
- __wbg_new_32b398fb48b6d94a: function() {
79
- const ret = new Array();
80
- return ret;
81
- },
82
- __wbg_new_7796ffc7ed656783: function() {
83
- const ret = new Map();
84
- return ret;
85
- },
86
- __wbg_new_da52cf8fe3429cb2: function() {
87
- const ret = new Object();
88
- return ret;
89
- },
90
- __wbg_set_575dd786d51585f8: function(arg0, arg1, arg2) {
91
- const ret = arg0.set(arg1, arg2);
70
+ __wbg_parse_1cc93481b0865939: function() { return handleError(function (arg0, arg1) {
71
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
92
72
  return ret;
93
- },
94
- __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
95
- arg0[arg1] = arg2;
96
- },
97
- __wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
98
- arg0[arg1 >>> 0] = arg2;
99
- },
73
+ }, arguments); },
100
74
  __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
101
75
  const ret = arg1.stack;
102
76
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
@@ -104,15 +78,10 @@ function __wbg_get_imports() {
104
78
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
105
79
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
106
80
  },
107
- __wbg_warn_b1370d804fa3e259: function(arg0) {
81
+ __wbg_warn_917d7f727ab78481: function(arg0) {
108
82
  console.warn(arg0);
109
83
  },
110
- __wbindgen_cast_0000000000000001: function(arg0) {
111
- // Cast intrinsic for `F64 -> Externref`.
112
- const ret = arg0;
113
- return ret;
114
- },
115
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
84
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
116
85
  // Cast intrinsic for `Ref(String) -> Externref`.
117
86
  const ret = getStringFromWasm0(arg0, arg1);
118
87
  return ret;
@@ -133,6 +102,77 @@ function __wbg_get_imports() {
133
102
  };
134
103
  }
135
104
 
105
+ function addToExternrefTable0(obj) {
106
+ const idx = wasm.__externref_table_alloc_command_export();
107
+ wasm.__wbindgen_externrefs.set(idx, obj);
108
+ return idx;
109
+ }
110
+
111
+ function debugString(val) {
112
+ // primitive types
113
+ const type = typeof val;
114
+ if (type == 'number' || type == 'boolean' || val == null) {
115
+ return `${val}`;
116
+ }
117
+ if (type == 'string') {
118
+ return `"${val}"`;
119
+ }
120
+ if (type == 'symbol') {
121
+ const description = val.description;
122
+ if (description == null) {
123
+ return 'Symbol';
124
+ } else {
125
+ return `Symbol(${description})`;
126
+ }
127
+ }
128
+ if (type == 'function') {
129
+ const name = val.name;
130
+ if (typeof name == 'string' && name.length > 0) {
131
+ return `Function(${name})`;
132
+ } else {
133
+ return 'Function';
134
+ }
135
+ }
136
+ // objects
137
+ if (Array.isArray(val)) {
138
+ const length = val.length;
139
+ let debug = '[';
140
+ if (length > 0) {
141
+ debug += debugString(val[0]);
142
+ }
143
+ for(let i = 1; i < length; i++) {
144
+ debug += ', ' + debugString(val[i]);
145
+ }
146
+ debug += ']';
147
+ return debug;
148
+ }
149
+ // Test for built-in
150
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
151
+ let className;
152
+ if (builtInMatches && builtInMatches.length > 1) {
153
+ className = builtInMatches[1];
154
+ } else {
155
+ // Failed to match the standard '[object ClassName]'
156
+ return toString.call(val);
157
+ }
158
+ if (className == 'Object') {
159
+ // we're a user defined class or Object
160
+ // JSON.stringify avoids problems with cycles, and is generally much
161
+ // easier than looping through ownProperties of `val`.
162
+ try {
163
+ return 'Object(' + JSON.stringify(val) + ')';
164
+ } catch (_) {
165
+ return 'Object';
166
+ }
167
+ }
168
+ // errors
169
+ if (val instanceof Error) {
170
+ return `${val.name}: ${val.message}\n${val.stack}`;
171
+ }
172
+ // TODO we could test for more things here, like `Set`s and `Map`s.
173
+ return className;
174
+ }
175
+
136
176
  let cachedDataViewMemory0 = null;
137
177
  function getDataViewMemory0() {
138
178
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -153,6 +193,15 @@ function getUint8ArrayMemory0() {
153
193
  return cachedUint8ArrayMemory0;
154
194
  }
155
195
 
196
+ function handleError(f, args) {
197
+ try {
198
+ return f.apply(this, args);
199
+ } catch (e) {
200
+ const idx = addToExternrefTable0(e);
201
+ wasm.__wbindgen_exn_store_command_export(idx);
202
+ }
203
+ }
204
+
156
205
  function passArray8ToWasm0(arg, malloc) {
157
206
  const ptr = malloc(arg.length * 1, 1) >>> 0;
158
207
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -245,11 +294,15 @@ function __wbg_finalize_init(instance, module) {
245
294
 
246
295
  async function __wbg_load(module, imports) {
247
296
  if (typeof Response === 'function' && module instanceof Response) {
297
+ if (!module.ok) {
298
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
299
+ }
300
+
248
301
  if (typeof WebAssembly.instantiateStreaming === 'function') {
249
302
  try {
250
303
  return await WebAssembly.instantiateStreaming(module, imports);
251
304
  } catch (e) {
252
- const validResponse = module.ok && expectedResponseType(module.type);
305
+ const validResponse = expectedResponseType(module.type);
253
306
 
254
307
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
255
308
  console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
Binary file