@b9g/platform-bun 0.1.16 → 0.1.17
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/package.json +3 -3
- package/src/index.js +10 -3
- package/src/platform.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b9g/platform-bun",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Bun platform adapter for Shovel with hot reloading and built-in TypeScript/JSX support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shovel",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@b9g/assets": "^0.2.1",
|
|
21
21
|
"@b9g/cache": "^0.2.2",
|
|
22
22
|
"@b9g/http-errors": "^0.2.1",
|
|
23
|
-
"@b9g/platform": "^0.1.
|
|
24
|
-
"@logtape/logtape": "^
|
|
23
|
+
"@b9g/platform": "^0.1.19",
|
|
24
|
+
"@logtape/logtape": "^2.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@b9g/libuild": "^0.1.18"
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="./index.d.ts" />
|
|
2
|
-
// src/index.ts
|
|
2
|
+
// packages/platform-bun/src/index.ts
|
|
3
3
|
import { builtinModules } from "node:module";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import * as Path from "node:path";
|
|
@@ -250,7 +250,7 @@ var BunPlatform = class {
|
|
|
250
250
|
const prodWorkerCode = `// Bun Production Worker
|
|
251
251
|
import BunPlatform from "@b9g/platform-bun";
|
|
252
252
|
import {getLogger} from "@logtape/logtape";
|
|
253
|
-
import {configureLogging, initWorkerRuntime, runLifecycle, dispatchRequest} from "@b9g/platform/runtime";
|
|
253
|
+
import {configureLogging, initWorkerRuntime, runLifecycle, dispatchRequest, setBroadcastChannelRelay, deliverBroadcastMessage} from "@b9g/platform/runtime";
|
|
254
254
|
import {config} from "shovel:config";
|
|
255
255
|
|
|
256
256
|
await configureLogging(config.logging);
|
|
@@ -260,13 +260,15 @@ const logger = getLogger(["shovel", "platform"]);
|
|
|
260
260
|
let server;
|
|
261
261
|
let databases;
|
|
262
262
|
|
|
263
|
-
// Register
|
|
263
|
+
// Register message handler for shutdown and broadcast relay
|
|
264
264
|
self.onmessage = async (event) => {
|
|
265
265
|
if (event.data.type === "shutdown") {
|
|
266
266
|
logger.info("Worker shutting down");
|
|
267
267
|
if (server) await server.close();
|
|
268
268
|
if (databases) await databases.closeAll();
|
|
269
269
|
postMessage({type: "shutdown-complete"});
|
|
270
|
+
} else if (event.data.type === "broadcast:deliver") {
|
|
271
|
+
deliverBroadcastMessage(event.data.channel, event.data.data);
|
|
270
272
|
}
|
|
271
273
|
};
|
|
272
274
|
|
|
@@ -275,6 +277,11 @@ const result = await initWorkerRuntime({config, usePostMessage: false});
|
|
|
275
277
|
const registration = result.registration;
|
|
276
278
|
databases = result.databases;
|
|
277
279
|
|
|
280
|
+
// Set up broadcast relay (posts go to supervisor for fan-out to other workers)
|
|
281
|
+
setBroadcastChannelRelay((channelName, data) => {
|
|
282
|
+
postMessage({type: "broadcast:post", channel: channelName, data});
|
|
283
|
+
});
|
|
284
|
+
|
|
278
285
|
// Import user code (registers event handlers)
|
|
279
286
|
await import("${userEntryPath}");
|
|
280
287
|
|
package/src/platform.js
CHANGED