@pluv/io 3.2.2 → 4.0.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.
@@ -1,22 +1,20 @@
1
1
 
2
- > @pluv/io@3.2.2 build /home/runner/work/pluv/pluv/packages/io
3
- > pnpm run version && tsup src/index.ts --format esm,cjs --dts
2
+ > @pluv/io@4.0.0 build /home/runner/work/pluv/pluv/packages/io
3
+ > pnpm run version && tsdown
4
4
 
5
5
 
6
- > @pluv/io@3.2.2 version /home/runner/work/pluv/pluv/packages/io
6
+ > @pluv/io@4.0.0 version /home/runner/work/pluv/pluv/packages/io
7
7
  > genversion ./src/version.generated.ts --esm
8
8
 
9
- CLI Building entry: src/index.ts
10
- CLI Using tsconfig: tsconfig.json
11
- CLI tsup v8.5.0
12
- CLI Target: es6
13
- ESM Build start
14
- CJS Build start
15
- ESM dist/index.mjs 53.72 KB
16
- ESM ⚡️ Build success in 142ms
17
- CJS dist/index.js 55.90 KB
18
- CJS ⚡️ Build success in 144ms
19
- DTS Build start
20
- DTS ⚡️ Build success in 4218ms
21
- DTS dist/index.d.mts 34.33 KB
22
- DTS dist/index.d.ts 34.33 KB
9
+ ℹ tsdown v0.20.0-beta.4 powered by rolldown v1.0.0-beta.60
10
+ ℹ config file: /home/runner/work/pluv/pluv/packages/io/tsdown.config.ts
11
+ ℹ entry: src/index.ts
12
+ ℹ target: esnext
13
+ ℹ tsconfig: tsconfig.json
14
+ ℹ Build start
15
+ ℹ dist/index.mjs  45.06 kB │ gzip: 10.66 kB
16
+ ℹ dist/index.mjs.map 131.03 kB │ gzip: 26.80 kB
17
+ ℹ dist/index.d.mts.map  18.91 kB │ gzip: 4.07 kB
18
+ ℹ dist/index.d.mts  35.53 kB │ gzip: 5.97 kB
19
+ ℹ 4 files, total: 230.54 kB
20
+ ✔ Build complete in 2894ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,97 @@
1
1
  # @pluv/io
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - df5c39c: Update all packages to be ESM only.
8
+ - c142910: ### Breaking Changes
9
+
10
+ Updated jose from jose@^5 to jose@^6.
11
+
12
+ - 07e2a1e: ### Breaking Changes
13
+
14
+ This release includes the following breaking changes:
15
+ 1. **Removed `onDestroy` handler** (room-level only) - replaced with `onRoomDestroyed` and `onStorageDestroyed`
16
+ 2. **Removed `onRoomDeleted` handler** (server-level) - replaced with `onRoomDestroyed` and `onStorageDestroyed`
17
+ 3. **Listeners can no longer be configured at room-level** - all listeners must be configured at server-level via `io.server()`
18
+ 4. **Event type changes** - `IORoomDestroyedEvent` no longer includes `encodedState`
19
+
20
+ #### Remove `onDestroy` and `onRoomDeleted` in favor of `onRoomDestroyed` and `onStorageDestroyed`
21
+
22
+ **BREAKING**: Two event handlers have been **removed** in favor of two separate handlers that provide better control over when storage is saved. This is a breaking change that requires code updates.
23
+
24
+ **New Handlers:**
25
+ - **`onRoomDestroyed`**: Fires whenever a room is destroyed. This event does NOT include `encodedState` to prevent accidentally saving empty or uninitialized storage data. **Available only at server-level** via `io.server()`.
26
+ - **`onStorageDestroyed`**: Only fires when the storage document is about to be destroyed after it has been initialized via `initializeSession`. This event includes `encodedState` and should be used for saving storage to your database. **Available only at server-level** via `io.server()`.
27
+
28
+ **Removed Handlers:**
29
+ - **`onDestroy`** (room-level only, via `createRoom`): **REMOVED**. Use `onRoomDestroyed` and `onStorageDestroyed` instead.
30
+ - **`onRoomDeleted`** (server-level): **REMOVED**. Use `onRoomDestroyed` and `onStorageDestroyed` instead.
31
+
32
+ **Migration Guide:**
33
+
34
+ **Old (no longer works):**
35
+
36
+ ```typescript
37
+ // Room-level onDestroy (removed)
38
+ const room = io.createRoom("room-id", {
39
+ onDestroy: async ({ encodedState, room }) => {
40
+ // This no longer works
41
+ await saveToDatabase(room, encodedState);
42
+ },
43
+ });
44
+
45
+ // Server-level onRoomDeleted (removed)
46
+ io.server({
47
+ onRoomDeleted: async ({ encodedState, room }) => {
48
+ // This no longer works
49
+ await saveToDatabase(room, encodedState);
50
+ },
51
+ });
52
+ ```
53
+
54
+ **New (recommended approach):**
55
+
56
+ ```typescript
57
+ // Server-level handlers (recommended - all listeners are now server-level)
58
+ io.server({
59
+ onRoomDestroyed: async ({ room }) => {
60
+ // Room destroyed - use for cleanup if needed
61
+ await cleanupRoom(room);
62
+ },
63
+ onStorageDestroyed: async ({ encodedState, room }) => {
64
+ // Only fires when storage was initialized via initializeSession
65
+ // Safe to save to database
66
+ await saveToDatabase(room, encodedState);
67
+ },
68
+ });
69
+
70
+ // Rooms are created without listener options
71
+ const room = io.createRoom("room-id");
72
+ ```
73
+
74
+ #### Type Changes
75
+
76
+ **BREAKING**: The following type changes may require TypeScript code updates:
77
+ - **`IORoomDestroyedEvent`** no longer includes `encodedState` (breaking change if you were accessing `encodedState` from this event)
78
+ - **`IORoomListenerEvent`** includes `encodedState: string | null` (used by `onStorageDestroyed`)
79
+ - **All listeners must be configured at the server level** via `io.server()`, not at the room level via `createRoom()` (breaking change - room-level listener configuration is no longer supported)
80
+ - **`CreateRoomOptions`** now correctly requires platform-specific room context properties (e.g., `env` and `state` for Cloudflare) when they are required by the platform, while properly handling optional properties like `meta` (breaking change - TypeScript will now correctly enforce required properties)
81
+
82
+ ### Minor Changes
83
+
84
+ - 037074e: Migrated build process from tsup to tsdown.
85
+
86
+ ### Patch Changes
87
+
88
+ - 2eb5def: Bumped dependencies.
89
+ - Updated dependencies [2eb5def]
90
+ - Updated dependencies [df5c39c]
91
+ - Updated dependencies [037074e]
92
+ - @pluv/types@4.0.0
93
+ - @pluv/crdt@4.0.0
94
+
3
95
  ## 3.2.2
4
96
 
5
97
  ### Patch Changes