capnweb 0.0.0-b2fcb34 → 0.0.0-f4275f5

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/dist/index.d.ts CHANGED
@@ -341,7 +341,7 @@ declare let newWebSocketRpcSession: <T extends Serializable<T> = Empty>(webSocke
341
341
  * value is an RpcStub. You can customize anything about the request except for the method
342
342
  * (it will always be set to POST) and the body (which the RPC system will fill in).
343
343
  */
344
- declare let newHttpBatchRpcSession: <T extends Serializable<T>>(urlOrRequest: string | Request, init?: RequestInit) => RpcStub<T>;
344
+ declare let newHttpBatchRpcSession: <T extends Serializable<T>>(urlOrRequest: string | Request, options?: RpcSessionOptions) => RpcStub<T>;
345
345
  /**
346
346
  * Initiate an RPC session over a MessagePort, which is particularly useful for communicating
347
347
  * between an iframe and its parent frame in a browser context. Each side should call this function
package/dist/index.js CHANGED
@@ -8,6 +8,17 @@ if (!Symbol.dispose) {
8
8
  if (!Symbol.asyncDispose) {
9
9
  Symbol.asyncDispose = Symbol.for("asyncDispose");
10
10
  }
11
+ if (!Promise.withResolvers) {
12
+ Promise.withResolvers = function() {
13
+ let resolve;
14
+ let reject;
15
+ const promise = new Promise((res, rej) => {
16
+ resolve = res;
17
+ reject = rej;
18
+ });
19
+ return { promise, resolve, reject };
20
+ };
21
+ }
11
22
  var workersModule = globalThis[WORKERS_MODULE_SYMBOL];
12
23
  var RpcTarget = workersModule ? workersModule.RpcTarget : class {
13
24
  };
@@ -233,6 +244,9 @@ var RpcStub = class _RpcStub extends RpcTarget {
233
244
  let { hook, pathIfPromise } = this[RAW_STUB];
234
245
  return mapImpl.sendMap(hook, pathIfPromise || [], func);
235
246
  }
247
+ toString() {
248
+ return "[object RpcStub]";
249
+ }
236
250
  };
237
251
  var RpcPromise = class extends RpcStub {
238
252
  // TODO: Support passing target value or promise to constructor.
@@ -248,6 +262,9 @@ var RpcPromise = class extends RpcStub {
248
262
  finally(onfinally) {
249
263
  return pullPromise(this).finally(...arguments);
250
264
  }
265
+ toString() {
266
+ return "[object RpcPromise]";
267
+ }
251
268
  };
252
269
  function unwrapStubTakingOwnership(stub) {
253
270
  let { hook, pathIfPromise } = stub[RAW_STUB];
@@ -745,7 +762,9 @@ function followPath(value, parent, path, owner) {
745
762
  case "rpc-target":
746
763
  case "rpc-thenable": {
747
764
  if (Object.hasOwn(value, part)) {
748
- value = void 0;
765
+ throw new TypeError(
766
+ `Attempted to access property '${part}', which is an instance property of the RpcTarget. To avoid leaking private internals, instance properties cannot be accessed over RPC. If you want to make this property available over RPC, define it as a method or getter on the class, instead of an instance property.`
767
+ );
749
768
  } else {
750
769
  value = value[part];
751
770
  }
@@ -1129,7 +1148,17 @@ var Devaluator = class _Devaluator {
1129
1148
  throw new TypeError(msg);
1130
1149
  }
1131
1150
  case "primitive":
1132
- return value;
1151
+ if (typeof value === "number" && !isFinite(value)) {
1152
+ if (value === Infinity) {
1153
+ return ["inf"];
1154
+ } else if (value === -Infinity) {
1155
+ return ["-inf"];
1156
+ } else {
1157
+ return ["nan"];
1158
+ }
1159
+ } else {
1160
+ return value;
1161
+ }
1133
1162
  case "object": {
1134
1163
  let object = value;
1135
1164
  let result = {};
@@ -1313,6 +1342,12 @@ var Evaluator = class _Evaluator {
1313
1342
  return void 0;
1314
1343
  }
1315
1344
  break;
1345
+ case "inf":
1346
+ return Infinity;
1347
+ case "-inf":
1348
+ return -Infinity;
1349
+ case "nan":
1350
+ return NaN;
1316
1351
  case "import":
1317
1352
  case "pipeline": {
1318
1353
  if (value.length < 2 || value.length > 4) {