@effect/platform-bun 0.16.1 → 0.16.3
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/Worker/dist/effect-platform-bun-Worker.cjs.dev.js +7 -4
- package/Worker/dist/effect-platform-bun-Worker.cjs.prod.js +7 -4
- package/Worker/dist/effect-platform-bun-Worker.esm.js +7 -4
- package/WorkerRunner/dist/effect-platform-bun-WorkerRunner.cjs.dev.js +1 -3
- package/WorkerRunner/dist/effect-platform-bun-WorkerRunner.cjs.prod.js +1 -3
- package/WorkerRunner/dist/effect-platform-bun-WorkerRunner.esm.js +1 -3
- package/package.json +4 -4
- package/src/internal/worker.ts +16 -10
- package/src/internal/workerRunner.ts +1 -3
|
@@ -45,12 +45,15 @@ const platformWorkerImpl = /*#__PURE__*/Worker__namespace.PlatformWorker.of({
|
|
|
45
45
|
signal
|
|
46
46
|
});
|
|
47
47
|
port.postMessage([1]);
|
|
48
|
-
}),
|
|
48
|
+
}),
|
|
49
|
+
// TODO: make configurable
|
|
50
|
+
// sometimes bun doesn't fire the close event
|
|
51
|
+
Effect__namespace.timeout(1000), Effect__namespace.tap(Option__namespace.match({
|
|
49
52
|
onNone: () => Effect__namespace.sync(() => port.terminate()),
|
|
50
53
|
onSome: _ => Effect__namespace.unit
|
|
51
54
|
})))));
|
|
52
55
|
const queue = yield* _(Queue__namespace.unbounded());
|
|
53
|
-
const
|
|
56
|
+
const fiber = yield* _(Effect__namespace.async((resume, signal) => {
|
|
54
57
|
port.addEventListener("message", function (event) {
|
|
55
58
|
queue.unsafeOffer(event.data);
|
|
56
59
|
}, {
|
|
@@ -61,10 +64,10 @@ const platformWorkerImpl = /*#__PURE__*/Worker__namespace.PlatformWorker.of({
|
|
|
61
64
|
}, {
|
|
62
65
|
signal
|
|
63
66
|
});
|
|
64
|
-
});
|
|
67
|
+
}), Effect__namespace.interruptible, Effect__namespace.forkScoped);
|
|
65
68
|
const send = (message, transfers) => Effect__namespace.sync(() => port.postMessage([0, message], transfers));
|
|
66
69
|
return {
|
|
67
|
-
|
|
70
|
+
fiber,
|
|
68
71
|
queue,
|
|
69
72
|
send
|
|
70
73
|
};
|
|
@@ -45,12 +45,15 @@ const platformWorkerImpl = /*#__PURE__*/Worker__namespace.PlatformWorker.of({
|
|
|
45
45
|
signal
|
|
46
46
|
});
|
|
47
47
|
port.postMessage([1]);
|
|
48
|
-
}),
|
|
48
|
+
}),
|
|
49
|
+
// TODO: make configurable
|
|
50
|
+
// sometimes bun doesn't fire the close event
|
|
51
|
+
Effect__namespace.timeout(1000), Effect__namespace.tap(Option__namespace.match({
|
|
49
52
|
onNone: () => Effect__namespace.sync(() => port.terminate()),
|
|
50
53
|
onSome: _ => Effect__namespace.unit
|
|
51
54
|
})))));
|
|
52
55
|
const queue = yield* _(Queue__namespace.unbounded());
|
|
53
|
-
const
|
|
56
|
+
const fiber = yield* _(Effect__namespace.async((resume, signal) => {
|
|
54
57
|
port.addEventListener("message", function (event) {
|
|
55
58
|
queue.unsafeOffer(event.data);
|
|
56
59
|
}, {
|
|
@@ -61,10 +64,10 @@ const platformWorkerImpl = /*#__PURE__*/Worker__namespace.PlatformWorker.of({
|
|
|
61
64
|
}, {
|
|
62
65
|
signal
|
|
63
66
|
});
|
|
64
|
-
});
|
|
67
|
+
}), Effect__namespace.interruptible, Effect__namespace.forkScoped);
|
|
65
68
|
const send = (message, transfers) => Effect__namespace.sync(() => port.postMessage([0, message], transfers));
|
|
66
69
|
return {
|
|
67
|
-
|
|
70
|
+
fiber,
|
|
68
71
|
queue,
|
|
69
72
|
send
|
|
70
73
|
};
|
|
@@ -18,12 +18,15 @@ const platformWorkerImpl = /*#__PURE__*/Worker.PlatformWorker.of({
|
|
|
18
18
|
signal
|
|
19
19
|
});
|
|
20
20
|
port.postMessage([1]);
|
|
21
|
-
}),
|
|
21
|
+
}),
|
|
22
|
+
// TODO: make configurable
|
|
23
|
+
// sometimes bun doesn't fire the close event
|
|
24
|
+
Effect.timeout(1000), Effect.tap(Option.match({
|
|
22
25
|
onNone: () => Effect.sync(() => port.terminate()),
|
|
23
26
|
onSome: _ => Effect.unit
|
|
24
27
|
})))));
|
|
25
28
|
const queue = yield* _(Queue.unbounded());
|
|
26
|
-
const
|
|
29
|
+
const fiber = yield* _(Effect.async((resume, signal) => {
|
|
27
30
|
port.addEventListener("message", function (event) {
|
|
28
31
|
queue.unsafeOffer(event.data);
|
|
29
32
|
}, {
|
|
@@ -34,10 +37,10 @@ const platformWorkerImpl = /*#__PURE__*/Worker.PlatformWorker.of({
|
|
|
34
37
|
}, {
|
|
35
38
|
signal
|
|
36
39
|
});
|
|
37
|
-
});
|
|
40
|
+
}), Effect.interruptible, Effect.forkScoped);
|
|
38
41
|
const send = (message, transfers) => Effect.sync(() => port.postMessage([0, message], transfers));
|
|
39
42
|
return {
|
|
40
|
-
|
|
43
|
+
fiber,
|
|
41
44
|
queue,
|
|
42
45
|
send
|
|
43
46
|
};
|
|
@@ -40,7 +40,6 @@ const platformRunnerImpl = /*#__PURE__*/Runner__namespace.PlatformRunner.of({
|
|
|
40
40
|
}
|
|
41
41
|
const port = self;
|
|
42
42
|
const queue = yield* _(Queue__namespace.unbounded());
|
|
43
|
-
const fiberId = yield* _(Effect__namespace.fiberId);
|
|
44
43
|
const fiber = yield* _(Effect__namespace.async((resume, signal) => {
|
|
45
44
|
port.addEventListener("message", function (event) {
|
|
46
45
|
const message = event.data;
|
|
@@ -57,8 +56,7 @@ const platformRunnerImpl = /*#__PURE__*/Runner__namespace.PlatformRunner.of({
|
|
|
57
56
|
}, {
|
|
58
57
|
signal
|
|
59
58
|
});
|
|
60
|
-
}), Effect__namespace.
|
|
61
|
-
yield* _(Effect__namespace.addFinalizer(() => fiber.interruptAsFork(fiberId)));
|
|
59
|
+
}), Effect__namespace.forkScoped);
|
|
62
60
|
const send = (message, transfer) => Effect__namespace.sync(() => port.postMessage([1, message], {
|
|
63
61
|
transfer: transfer
|
|
64
62
|
}));
|
|
@@ -40,7 +40,6 @@ const platformRunnerImpl = /*#__PURE__*/Runner__namespace.PlatformRunner.of({
|
|
|
40
40
|
}
|
|
41
41
|
const port = self;
|
|
42
42
|
const queue = yield* _(Queue__namespace.unbounded());
|
|
43
|
-
const fiberId = yield* _(Effect__namespace.fiberId);
|
|
44
43
|
const fiber = yield* _(Effect__namespace.async((resume, signal) => {
|
|
45
44
|
port.addEventListener("message", function (event) {
|
|
46
45
|
const message = event.data;
|
|
@@ -57,8 +56,7 @@ const platformRunnerImpl = /*#__PURE__*/Runner__namespace.PlatformRunner.of({
|
|
|
57
56
|
}, {
|
|
58
57
|
signal
|
|
59
58
|
});
|
|
60
|
-
}), Effect__namespace.
|
|
61
|
-
yield* _(Effect__namespace.addFinalizer(() => fiber.interruptAsFork(fiberId)));
|
|
59
|
+
}), Effect__namespace.forkScoped);
|
|
62
60
|
const send = (message, transfer) => Effect__namespace.sync(() => port.postMessage([1, message], {
|
|
63
61
|
transfer: transfer
|
|
64
62
|
}));
|
|
@@ -14,7 +14,6 @@ const platformRunnerImpl = /*#__PURE__*/Runner.PlatformRunner.of({
|
|
|
14
14
|
}
|
|
15
15
|
const port = self;
|
|
16
16
|
const queue = yield* _(Queue.unbounded());
|
|
17
|
-
const fiberId = yield* _(Effect.fiberId);
|
|
18
17
|
const fiber = yield* _(Effect.async((resume, signal) => {
|
|
19
18
|
port.addEventListener("message", function (event) {
|
|
20
19
|
const message = event.data;
|
|
@@ -31,8 +30,7 @@ const platformRunnerImpl = /*#__PURE__*/Runner.PlatformRunner.of({
|
|
|
31
30
|
}, {
|
|
32
31
|
signal
|
|
33
32
|
});
|
|
34
|
-
}), Effect.
|
|
35
|
-
yield* _(Effect.addFinalizer(() => fiber.interruptAsFork(fiberId)));
|
|
33
|
+
}), Effect.forkScoped);
|
|
36
34
|
const send = (message, transfer) => Effect.sync(() => port.postMessage([1, message], {
|
|
37
35
|
transfer: transfer
|
|
38
36
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/platform-bun",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Unified interfaces for common platform-specific services",
|
|
5
5
|
"main": "dist/effect-platform-bun.cjs.js",
|
|
6
6
|
"module": "dist/effect-platform-bun.esm.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"sideEffects": false,
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@effect/platform": "^0.27.
|
|
34
|
-
"@effect/platform-node": "^0.28.
|
|
33
|
+
"@effect/platform": "^0.27.3",
|
|
34
|
+
"@effect/platform-node": "^0.28.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@effect/schema": "^0.47.1",
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
"scripts": {
|
|
182
|
-
"example": "ts-node
|
|
182
|
+
"example": "node -r ts-node/register",
|
|
183
183
|
"lint": "eslint src/**/*.ts test/**/*.ts",
|
|
184
184
|
"tc": "tsc -b",
|
|
185
185
|
"test": "vitest",
|
package/src/internal/worker.ts
CHANGED
|
@@ -18,7 +18,9 @@ const platformWorkerImpl = Worker.PlatformWorker.of({
|
|
|
18
18
|
port.addEventListener("close", () => resume(Effect.unit), { once: true, signal })
|
|
19
19
|
port.postMessage([1])
|
|
20
20
|
}),
|
|
21
|
-
|
|
21
|
+
// TODO: make configurable
|
|
22
|
+
// sometimes bun doesn't fire the close event
|
|
23
|
+
Effect.timeout(1000),
|
|
22
24
|
Effect.tap(Option.match({
|
|
23
25
|
onNone: () => Effect.sync(() => port.terminate()),
|
|
24
26
|
onSome: (_) => Effect.unit
|
|
@@ -28,19 +30,23 @@ const platformWorkerImpl = Worker.PlatformWorker.of({
|
|
|
28
30
|
|
|
29
31
|
const queue = yield* _(Queue.unbounded<Worker.BackingWorker.Message<O>>())
|
|
30
32
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
const fiber = yield* _(
|
|
34
|
+
Effect.async<never, WorkerError, never>((resume, signal) => {
|
|
35
|
+
port.addEventListener("message", function(event) {
|
|
36
|
+
queue.unsafeOffer(event.data)
|
|
37
|
+
}, { signal })
|
|
38
|
+
port.addEventListener("error", function(event) {
|
|
39
|
+
resume(Effect.fail(WorkerError("unknown", event.message)))
|
|
40
|
+
}, { signal })
|
|
41
|
+
}),
|
|
42
|
+
Effect.interruptible,
|
|
43
|
+
Effect.forkScoped
|
|
44
|
+
)
|
|
39
45
|
|
|
40
46
|
const send = (message: I, transfers?: ReadonlyArray<unknown>) =>
|
|
41
47
|
Effect.sync(() => port.postMessage([0, message], transfers as any))
|
|
42
48
|
|
|
43
|
-
return {
|
|
49
|
+
return { fiber, queue, send }
|
|
44
50
|
})
|
|
45
51
|
}
|
|
46
52
|
})
|
|
@@ -17,7 +17,6 @@ const platformRunnerImpl = Runner.PlatformRunner.of({
|
|
|
17
17
|
}
|
|
18
18
|
const port = self
|
|
19
19
|
const queue = yield* _(Queue.unbounded<I>())
|
|
20
|
-
const fiberId = yield* _(Effect.fiberId)
|
|
21
20
|
const fiber = yield* _(
|
|
22
21
|
Effect.async<never, WorkerError, never>((resume, signal) => {
|
|
23
22
|
port.addEventListener("message", function(event) {
|
|
@@ -32,9 +31,8 @@ const platformRunnerImpl = Runner.PlatformRunner.of({
|
|
|
32
31
|
resume(Effect.fail(WorkerError("unknown", error.message)))
|
|
33
32
|
}, { signal })
|
|
34
33
|
}),
|
|
35
|
-
Effect.
|
|
34
|
+
Effect.forkScoped
|
|
36
35
|
)
|
|
37
|
-
yield* _(Effect.addFinalizer(() => fiber.interruptAsFork(fiberId)))
|
|
38
36
|
const send = (message: O, transfer?: ReadonlyArray<unknown>) =>
|
|
39
37
|
Effect.sync(() =>
|
|
40
38
|
port.postMessage([1, message], {
|