pyret-embed 0.1.8 → 0.1.9

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.
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/build/web/js/cpo-main.jarr
3
- size: 39419095 bytes
4
- sha256: 463aeca97884e60038f806d6ace1f16095634fe41c3632d707fde19ef0697108
3
+ size: 39425070 bytes
4
+ sha256: e538bdded88d99cf1f4b5054ba82c446f75118fb31c768cfc3f7811cafbe648e
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/build/web/js/cpo-main.jarr.js
3
- size: 39419095 bytes
4
- sha256: 463aeca97884e60038f806d6ace1f16095634fe41c3632d707fde19ef0697108
3
+ size: 39425070 bytes
4
+ sha256: e538bdded88d99cf1f4b5054ba82c446f75118fb31c768cfc3f7811cafbe648e
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/build/web/js/cpo-main.jarr.min
3
- size: 36463335 bytes
4
- sha256: 4fac69dd8fa65ffa6118e45ae2fb72232f6f2336d7c8dd8de84c12d8c126e346
3
+ size: 36467830 bytes
4
+ sha256: 240e5f973fccc25df91da15592f0d665e9daa4e4dcc2cec6e0c165f8fef37bd8
@@ -230,6 +230,8 @@
230
230
  const realpath = window.MESSAGES.sendRpc('path', 'resolve', [info.path]);
231
231
  realpath.then((realpath) => {
232
232
  restarter.resume(`js-file://${realpath}`);
233
+ }, (err) => {
234
+ restarter.error(runtime.ffi.makeMessageException("Error resolving import path: " + String(err)));
233
235
  });
234
236
  });
235
237
  }
@@ -242,6 +244,8 @@
242
244
  const realpath = window.MESSAGES.sendRpc('path', 'resolve', [info.path]);
243
245
  realpath.then((realpath) => {
244
246
  restarter.resume(`file://${realpath}`);
247
+ }, (err) => {
248
+ restarter.error(runtime.ffi.makeMessageException("Error resolving import path: " + String(err)));
245
249
  });
246
250
  });
247
251
  }
@@ -341,30 +345,45 @@
341
345
  return fileLocatorConstructor.makeFileLocator(info.path);
342
346
  case "local-if-present":
343
347
  return runtime.pauseStack(async (restarter) => {
344
- const exists = await fsInternal.exists(info.path);
348
+ // This callback is async, so anything it throws is a
349
+ // rejected promise nobody looks at; catch it here or
350
+ // the run never resumes.
351
+ let exists;
352
+ try {
353
+ exists = await fsInternal.exists(info.path);
354
+ }
355
+ catch(err) {
356
+ restarter.error(runtime.isObject(err) ? err
357
+ : runtime.ffi.makeMessageException("Error checking for local file " + JSON.stringify(info.path) + ": " + String(err)));
358
+ return;
359
+ }
345
360
  if(exists) {
346
361
  fsInternal.readFile(info.path).then((contents) => {
347
362
  const strContents = Buffer.from(contents).toString('utf8');
348
363
  CPO.documents.set(fullUrl, new CodeMirror.Doc(strContents, "pyret"));
349
364
  });
350
- return runtime.runThunk(() => {
351
- var fileLocatorConstructor = fileLocator.makeFileLocatorConstructor(window.MESSAGES.sendRpc, runtime, compileLib, compileStructs, parsePyret, builtinModules, cpo);
352
- return fileLocatorConstructor.makeFileLocator(info.path);
353
- }, (result) => {
354
- if(runtime.isSuccessResult(result)) {
355
- restarter.resume(result.result);
356
- }
357
- else {
358
- restarter.error(result.error);
359
- }
360
- });
361
365
  }
362
366
  else {
363
367
  fetch(fullUrl).then(async (response) => {
364
368
  CPO.documents.set(fullUrl, new CodeMirror.Doc(await response.text(), "pyret"));
365
369
  });
366
- return restarter.resume(runtime.getField(runtime.getField(urlLoc, "values"), "url-locator").app(fullUrl, replGlobals));
367
370
  }
371
+ return runtime.runThunk(() => {
372
+ if(exists) {
373
+ var fileLocatorConstructor = fileLocator.makeFileLocatorConstructor(window.MESSAGES.sendRpc, runtime, compileLib, compileStructs, parsePyret, builtinModules, cpo);
374
+ return fileLocatorConstructor.makeFileLocator(info.path);
375
+ }
376
+ else {
377
+ return runtime.getField(runtime.getField(urlLoc, "values"), "url-locator").app(fullUrl, replGlobals);
378
+ }
379
+ }, (result) => {
380
+ if(runtime.isSuccessResult(result)) {
381
+ restarter.resume(result.result);
382
+ }
383
+ else {
384
+ restarter.error(result.exn);
385
+ }
386
+ });
368
387
  });
369
388
  }
370
389
 
@@ -67,6 +67,14 @@ define("cpo/file-locator", [], function() {
67
67
  var gmf = function(m, f) { return gf(gf(m, "values"), f); };
68
68
 
69
69
 
70
+ // Every RPC here runs under a paused stack, so a rejected RPC has to
71
+ // become restarter.error -- otherwise the run waits forever, silently.
72
+ function rpcFailed(restarter, what) {
73
+ return function(err) {
74
+ restarter.error(runtime.ffi.makeMessageException(what + ": " + String(err)));
75
+ };
76
+ }
77
+
70
78
  function makeFileLocator(path) {
71
79
  return runtime.pauseStack((restarter) => {
72
80
  const realpath = sendRpc('path', 'resolve', [path]);
@@ -89,10 +97,14 @@ define("cpo/file-locator", [], function() {
89
97
  return ast;
90
98
  }, "file-locator:parse-contents");
91
99
  }, function(result) {
92
- console.log("Result from getModule runThunk: ", result);
93
- restarter.resume(result.result);
100
+ if(runtime.isSuccessResult(result)) {
101
+ restarter.resume(result.result);
102
+ }
103
+ else {
104
+ restarter.error(result.exn);
105
+ }
94
106
  });
95
- });
107
+ }, rpcFailed(restarter, "Could not read file " + JSON.stringify(path)));
96
108
  });
97
109
  }
98
110
 
@@ -166,7 +178,7 @@ define("cpo/file-locator", [], function() {
166
178
  "set-compiled": m2(setCompiled),
167
179
  "get-compiled": m1(function() { return runtime.ffi.makeNone(); })
168
180
  }));
169
- });
181
+ }, rpcFailed(restarter, "Could not resolve file path " + JSON.stringify(path)));
170
182
  });
171
183
  }
172
184