@bruch/max-client 0.1.1 → 0.1.4

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 CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "@bruch/max-client",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Unofficial Bun/TypeScript client for the Max messenger internal API",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/sibstark/tsmax.git"
10
+ },
11
+ "homepage": "https://github.com/sibstark/tsmax#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/sibstark/tsmax/issues"
14
+ },
7
15
  "engines": {
8
16
  "bun": ">=1.3.0"
9
17
  },
@@ -120,8 +120,7 @@ function resolveEvent(
120
120
  ): { type: keyof EventMap; event: EventMap[keyof EventMap] } | null {
121
121
  const payload = frame.payload as Record<string, unknown>;
122
122
  if (frame.opcode === Opcode.NOTIF_MESSAGE || frame.opcode === Opcode.MSG_EDIT) {
123
- const messagePayload = payload.message ?? payload;
124
- const message = Message.fromPayload(messagePayload);
123
+ const message = Message.fromPayload(payload);
125
124
  if (message.status === "REMOVED")
126
125
  return { type: EventType.MESSAGE_DELETE, event: deleteFromMessage(message, payload) };
127
126
  return {
@@ -143,7 +143,15 @@ export class Message {
143
143
  }
144
144
 
145
145
  static fromPayload(value: unknown): Message {
146
- return new Message(asRecord(value, "message"));
146
+ const payload = asRecord(value, "message");
147
+ const nested = optionalRecord(payload.message);
148
+ if (!nested) return new Message(payload);
149
+
150
+ const normalized = { ...nested };
151
+ for (const field of ["chatId", "prevMessageId", "ttl", "unread", "mark"] as const) {
152
+ if (payload[field] !== undefined) normalized[field] = payload[field];
153
+ }
154
+ return new Message(normalized);
147
155
  }
148
156
 
149
157
  bind(actions: MessageActions): this {