@hadoku/service-kernel 0.1.9 → 0.1.11

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.
@@ -0,0 +1,2 @@
1
+ /** Write JSON to `target` atomically: a temp file beside it, synced, then renamed over it. */
2
+ export declare function atomicWriteJson(target: string, data: unknown): Promise<void>;
@@ -0,0 +1,17 @@
1
+ /** Write JSON to `target` atomically: a temp file beside it, synced, then renamed over it. */
2
+ import { randomUUID } from 'node:crypto';
3
+ import { mkdir, open, rename } from 'node:fs/promises';
4
+ import { join } from 'node:path';
5
+ export async function atomicWriteJson(target, data) {
6
+ await mkdir(join(target, '..'), { recursive: true });
7
+ const tmp = `${target}.${process.pid}.${randomUUID()}.tmp`;
8
+ const handle = await open(tmp, 'w');
9
+ try {
10
+ await handle.writeFile(JSON.stringify(data, null, 2));
11
+ await handle.sync();
12
+ }
13
+ finally {
14
+ await handle.close();
15
+ }
16
+ await rename(tmp, target);
17
+ }
@@ -1 +1,2 @@
1
1
  export { moveLegacyDir, moveLegacyState, type StateMove } from './state-dir.js';
2
+ export { atomicWriteJson } from './atomic-write.js';
@@ -1 +1,2 @@
1
1
  export { moveLegacyDir, moveLegacyState } from "./state-dir.js";
2
+ export { atomicWriteJson } from "./atomic-write.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/service-kernel",
3
- "version": "0.1.9",
4
- "gitHead": "1e3e14b488da97502666167519c09c2fce436406",
3
+ "version": "0.1.11",
4
+ "gitHead": "b881258b9409e166cadcacdd662ad43cfed3a615",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "The server parts any game keeps: edge auth and the tier gate, base path and bundle check, health and the busy probe, lifecycle, the JSON logger, the state directory, telemetry and capacity, per-caller limits, the browser relays, the erase registry, and createGameServer, which boots a game from its config and plugins. Knows no game; the app binds its service id, prefix and env names. MIT; imports only node built-ins, express, socket.io and @wolffm/*.",
@@ -56,8 +56,8 @@
56
56
  }
57
57
  },
58
58
  "dependencies": {
59
- "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.69",
60
- "@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.69",
59
+ "@wolffm/rooms-protocol": "npm:@hadoku/rooms-protocol@^0.45.70",
60
+ "@wolffm/rooms-server": "npm:@hadoku/rooms-server@^0.45.70",
61
61
  "express": "^5.1.0",
62
62
  "socket.io": "^4.8.3"
63
63
  },