sane-wasm 0.3.1 → 0.3.2

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.
Binary file
@@ -27,23 +27,15 @@ if (ENVIRONMENT_IS_NODE) {
27
27
 
28
28
  Object.assign(global, {
29
29
  self: global,
30
- require: require,
31
- Module: Module,
30
+ require,
31
+ Module,
32
32
  location: {
33
33
  href: __filename
34
34
  },
35
35
  Worker: nodeWorkerThreads.Worker,
36
- importScripts: function(f) {
37
- (0, eval)(fs.readFileSync(f, 'utf8') + '//# sourceURL=' + f);
38
- },
39
- postMessage: function(msg) {
40
- parentPort.postMessage(msg);
41
- },
42
- performance: global.performance || {
43
- now: function() {
44
- return Date.now();
45
- }
46
- },
36
+ importScripts: (f) => (0, eval)(fs.readFileSync(f, 'utf8') + '//# sourceURL=' + f),
37
+ postMessage: (msg) => parentPort.postMessage(msg),
38
+ performance: global.performance || { now: Date.now },
47
39
  });
48
40
  }
49
41
 
@@ -65,7 +57,7 @@ function threadPrintErr() {
65
57
  }
66
58
  function threadAlert() {
67
59
  var text = Array.prototype.slice.call(arguments).join(' ');
68
- postMessage({cmd: 'alert', text: text, threadId: Module['_pthread_self']()});
60
+ postMessage({cmd: 'alert', text, threadId: Module['_pthread_self']()});
69
61
  }
70
62
  // We don't need out() for now, but may need to add it if we want to use it
71
63
  // here. Or, if this code all moves into the main JS, that problem will go
@@ -73,6 +65,7 @@ function threadAlert() {
73
65
  var out = () => { throw 'out() is not defined in worker.js.'; }
74
66
  var err = threadPrintErr;
75
67
  self.alert = threadAlert;
68
+ var dbg = threadPrintErr;
76
69
 
77
70
  Module['instantiateWasm'] = (info, receiveInstance) => {
78
71
  // Instantiate from the module posted from the main thread.
@@ -90,7 +83,7 @@ Module['instantiateWasm'] = (info, receiveInstance) => {
90
83
  // Turn unhandled rejected promises into errors so that the main thread will be
91
84
  // notified about them.
92
85
  self.onunhandledrejection = (e) => {
93
- throw e.reason ?? e;
86
+ throw e.reason || e;
94
87
  };
95
88
 
96
89
  function handleMessage(e) {
@@ -120,8 +113,8 @@ function handleMessage(e) {
120
113
  // Use `const` here to ensure that the variable is scoped only to
121
114
  // that iteration, allowing safe reference from a closure.
122
115
  for (const handler of e.data.handlers) {
123
- Module[handler] = function() {
124
- postMessage({ cmd: 'callHandler', handler, args: [...arguments] });
116
+ Module[handler] = (...args) => {
117
+ postMessage({ cmd: 'callHandler', handler, args: args });
125
118
  }
126
119
  }
127
120
 
@@ -143,7 +136,7 @@ function handleMessage(e) {
143
136
  LibSANE(Module);
144
137
  } else if (e.data.cmd === 'run') {
145
138
  // Pass the thread address to wasm to store it for fast access.
146
- Module['__emscripten_thread_init'](e.data.pthread_ptr, /*isMainBrowserThread=*/0, /*isMainRuntimeThread=*/0, /*canBlock=*/1);
139
+ Module['__emscripten_thread_init'](e.data.pthread_ptr, /*is_main=*/0, /*is_runtime=*/0, /*can_block=*/1);
147
140
 
148
141
  // Await mailbox notifications with `Atomics.waitAsync` so we can start
149
142
  // using the fast `Atomics.notify` notification path.
@@ -186,11 +179,11 @@ function handleMessage(e) {
186
179
  // The received message looks like something that should be handled by this message
187
180
  // handler, (since there is a e.data.cmd field present), but is not one of the
188
181
  // recognized commands:
189
- err('worker.js received unknown command ' + e.data.cmd);
182
+ err(`worker.js received unknown command ${e.data.cmd}`);
190
183
  err(e.data);
191
184
  }
192
185
  } catch(ex) {
193
- err('worker.js onmessage() captured an uncaught exception: ' + ex);
186
+ err(`worker.js onmessage() captured an uncaught exception: ${ex}`);
194
187
  if (ex && ex.stack) err(ex.stack);
195
188
  if (Module['__emscripten_thread_crashed']) {
196
189
  Module['__emscripten_thread_crashed']();
@@ -200,5 +193,3 @@ function handleMessage(e) {
200
193
  };
201
194
 
202
195
  self.onmessage = handleMessage;
203
-
204
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sane-wasm",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "A project to bring the SANE API to the web.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",