capnweb 0.2.0 → 0.4.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 +12 -0
- package/dist/index-workers.cjs +13 -4
- package/dist/index-workers.cjs.map +1 -1
- package/dist/index-workers.d.cts +1 -1
- package/dist/index-workers.d.ts +1 -1
- package/dist/index-workers.js +13 -4
- package/dist/index-workers.js.map +1 -1
- package/dist/index.cjs +13 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -21
- package/dist/index.d.ts +29 -21
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/symbols.ts
|
|
4
|
-
var WORKERS_MODULE_SYMBOL = Symbol("workers-module");
|
|
4
|
+
var WORKERS_MODULE_SYMBOL = /* @__PURE__ */ Symbol("workers-module");
|
|
5
5
|
|
|
6
6
|
// src/core.ts
|
|
7
7
|
if (!Symbol.dispose) {
|
|
8
|
-
Symbol.dispose = Symbol.for("dispose");
|
|
8
|
+
Symbol.dispose = /* @__PURE__ */ Symbol.for("dispose");
|
|
9
9
|
}
|
|
10
10
|
if (!Symbol.asyncDispose) {
|
|
11
|
-
Symbol.asyncDispose = Symbol.for("asyncDispose");
|
|
11
|
+
Symbol.asyncDispose = /* @__PURE__ */ Symbol.for("asyncDispose");
|
|
12
12
|
}
|
|
13
13
|
if (!Promise.withResolvers) {
|
|
14
14
|
Promise.withResolvers = function() {
|
|
@@ -24,6 +24,8 @@ if (!Promise.withResolvers) {
|
|
|
24
24
|
var workersModule = globalThis[WORKERS_MODULE_SYMBOL];
|
|
25
25
|
var RpcTarget = workersModule ? workersModule.RpcTarget : class {
|
|
26
26
|
};
|
|
27
|
+
var AsyncFunction = (async function() {
|
|
28
|
+
}).constructor;
|
|
27
29
|
function typeForRpc(value) {
|
|
28
30
|
switch (typeof value) {
|
|
29
31
|
case "boolean":
|
|
@@ -48,6 +50,7 @@ function typeForRpc(value) {
|
|
|
48
50
|
case Object.prototype:
|
|
49
51
|
return "object";
|
|
50
52
|
case Function.prototype:
|
|
53
|
+
case AsyncFunction.prototype:
|
|
51
54
|
return "function";
|
|
52
55
|
case Array.prototype:
|
|
53
56
|
return "array";
|
|
@@ -131,7 +134,7 @@ function withCallInterceptor(interceptor, callback) {
|
|
|
131
134
|
doCall = oldValue;
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
|
-
var RAW_STUB = Symbol("realStub");
|
|
137
|
+
var RAW_STUB = /* @__PURE__ */ Symbol("realStub");
|
|
135
138
|
var PROXY_HANDLERS = {
|
|
136
139
|
apply(target, thisArg, argumentsList) {
|
|
137
140
|
let stub = target.raw;
|
|
@@ -399,6 +402,12 @@ var RpcPayload = class _RpcPayload {
|
|
|
399
402
|
// Get the StubHook representing the given RpcTarget found inside this payload.
|
|
400
403
|
getHookForRpcTarget(target, parent, dupStubs = true) {
|
|
401
404
|
if (this.source === "params") {
|
|
405
|
+
if (dupStubs) {
|
|
406
|
+
let dupable = target;
|
|
407
|
+
if (typeof dupable.dup === "function") {
|
|
408
|
+
target = dupable.dup();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
402
411
|
return TargetStubHook.create(target, parent);
|
|
403
412
|
} else if (this.source === "return") {
|
|
404
413
|
let hook = this.rpcTargets?.get(target);
|