spectrum-ts 4.0.0 → 4.2.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.
Files changed (35) hide show
  1. package/dist/{attachment-CEpGtZLm.d.ts → attachment-CnivEhr6.d.ts} +1 -1
  2. package/dist/{authoring-CP3vRza8.d.ts → authoring-b9AhXgPI.d.ts} +2 -2
  3. package/dist/authoring.d.ts +3 -3
  4. package/dist/authoring.js +3 -3
  5. package/dist/{chunk-PV4AVMNN.js → chunk-ARL2NOBO.js} +4 -4
  6. package/dist/{chunk-OGTHPDG7.js → chunk-B52VPQO3.js} +69 -29
  7. package/dist/{chunk-5VCWWPFW.js → chunk-DMPDLSFU.js} +8 -4
  8. package/dist/{chunk-57NECZQZ.js → chunk-N6THJDZV.js} +6 -4
  9. package/dist/{chunk-W5HNZ7YT.js → chunk-NLMQ75LH.js} +33 -76
  10. package/dist/{chunk-VEF6FUE7.js → chunk-WXLQNANA.js} +4 -1
  11. package/dist/elysia.d.ts +94 -0
  12. package/dist/elysia.js +15 -0
  13. package/dist/express.d.ts +62 -0
  14. package/dist/express.js +19 -0
  15. package/dist/hono.d.ts +64 -0
  16. package/dist/hono.js +11 -0
  17. package/dist/index.d.ts +33 -18
  18. package/dist/index.js +428 -36
  19. package/dist/providers/imessage/index.d.ts +10 -32
  20. package/dist/providers/imessage/index.js +7 -6
  21. package/dist/providers/index.d.ts +4 -4
  22. package/dist/providers/index.js +16 -16
  23. package/dist/providers/slack/index.d.ts +1 -1
  24. package/dist/providers/slack/index.js +2 -2
  25. package/dist/providers/telegram/index.d.ts +2 -2
  26. package/dist/providers/telegram/index.js +3 -3
  27. package/dist/providers/terminal/index.d.ts +1 -1
  28. package/dist/providers/terminal/index.js +3 -3
  29. package/dist/providers/whatsapp-business/index.d.ts +1 -1
  30. package/dist/providers/whatsapp-business/index.js +4 -4
  31. package/dist/read-C4uvozGX.d.ts +53 -0
  32. package/dist/{types-Be0T6E0e.d.ts → types-CyfLJXgu.d.ts} +26 -1
  33. package/dist/{types-CDYXH2R7.d.ts → types-ZgFTj5hJ.d.ts} +11 -6
  34. package/package.json +25 -1
  35. package/dist/photo-content-BJKnqgN-.d.ts +0 -13
@@ -1,5 +1,5 @@
1
1
  import z__default from 'zod';
2
- import { C as ContentBuilder } from './types-Be0T6E0e.js';
2
+ import { C as ContentBuilder } from './types-CyfLJXgu.js';
3
3
 
4
4
  declare const attachmentSchema: z__default.ZodObject<{
5
5
  type: z__default.ZodLiteral<"attachment">;
@@ -1,7 +1,7 @@
1
- import './attachment-CEpGtZLm.js';
1
+ import './attachment-CnivEhr6.js';
2
2
  import vCard from 'vcf';
3
3
  import z__default from 'zod';
4
- import { U as User, C as ContentBuilder, M as Message, e as Space, h as ContentInput } from './types-Be0T6E0e.js';
4
+ import { U as User, C as ContentBuilder, M as Message, S as Space, h as ContentInput } from './types-CyfLJXgu.js';
5
5
 
6
6
  declare const nameSchema: z__default.ZodObject<{
7
7
  formatted: z__default.ZodOptional<z__default.ZodString>;
@@ -1,6 +1,6 @@
1
- export { c as asAttachment } from './attachment-CEpGtZLm.js';
2
- export { q as asContact, s as asCustom, u as asGroup, w as asPoll, x as asPollOption, y as asRichlink, z as asText, A as asVoice } from './authoring-CP3vRza8.js';
3
- export { d as ProviderMessageRecord, $ as asReaction } from './types-Be0T6E0e.js';
1
+ export { c as asAttachment } from './attachment-CnivEhr6.js';
2
+ export { q as asContact, s as asCustom, u as asGroup, w as asPoll, x as asPollOption, y as asRichlink, z as asText, A as asVoice } from './authoring-b9AhXgPI.js';
3
+ export { e as ProviderMessageRecord, $ as asReaction } from './types-CyfLJXgu.js';
4
4
  import 'zod';
5
5
  import 'vcf';
6
6
  import 'hotscript';
package/dist/authoring.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
+ import {
3
+ asVoice
4
+ } from "./chunk-FAIFTUV2.js";
2
5
  import {
3
6
  asRichlink
4
7
  } from "./chunk-ZR3TKZMT.js";
5
8
  import {
6
9
  asGroup
7
10
  } from "./chunk-LZXPLXZF.js";
8
- import {
9
- asVoice
10
- } from "./chunk-FAIFTUV2.js";
11
11
  import {
12
12
  asPoll,
13
13
  asPollOption
@@ -5,17 +5,17 @@ import {
5
5
  import {
6
6
  asContact
7
7
  } from "./chunk-A37PM5N2.js";
8
- import {
9
- stream
10
- } from "./chunk-5XEFJBN2.js";
11
8
  import {
12
9
  fromVCard,
13
10
  toVCard
14
11
  } from "./chunk-6UZFVXQF.js";
12
+ import {
13
+ stream
14
+ } from "./chunk-5XEFJBN2.js";
15
15
  import {
16
16
  UnsupportedError,
17
17
  definePlatform
18
- } from "./chunk-OGTHPDG7.js";
18
+ } from "./chunk-B52VPQO3.js";
19
19
  import {
20
20
  asAttachment,
21
21
  asCustom,
@@ -46,10 +46,10 @@ var resolveMimeType = (input, mimeType, contentLabel) => {
46
46
  `Unable to resolve MIME type for ${contentLabel}. Pass options.mimeType explicitly.`
47
47
  );
48
48
  };
49
- var cachedRead = (read) => {
49
+ var cachedRead = (read2) => {
50
50
  let cached;
51
51
  return () => {
52
- cached ??= read().catch((err) => {
52
+ cached ??= read2().catch((err) => {
53
53
  cached = void 0;
54
54
  throw err;
55
55
  });
@@ -61,16 +61,16 @@ var buildPhotoAction = (input, options, contentLabel) => {
61
61
  return { kind: "clear" };
62
62
  }
63
63
  const mimeType = resolveMimeType(input, options?.mimeType, contentLabel);
64
- let read;
64
+ let read2;
65
65
  if (input instanceof URL) {
66
- read = cachedRead(async () => (await fetchUrlBytes(input)).data);
66
+ read2 = cachedRead(async () => (await fetchUrlBytes(input)).data);
67
67
  } else if (typeof input === "string") {
68
- read = cachedRead(() => readFile(input));
68
+ read2 = cachedRead(() => readFile(input));
69
69
  } else {
70
70
  const snapshot = Buffer.from(input);
71
- read = cachedRead(async () => snapshot);
71
+ read2 = cachedRead(async () => snapshot);
72
72
  }
73
- return { kind: "set", read, mimeType };
73
+ return { kind: "set", read: read2, mimeType };
74
74
  };
75
75
 
76
76
  // src/content/avatar.ts
@@ -116,7 +116,7 @@ function edit(content, target) {
116
116
  if (!resolved) {
117
117
  throw new Error("edit() requires content");
118
118
  }
119
- if (resolved.type === "edit" || resolved.type === "reply" || resolved.type === "reaction" || resolved.type === "group" || resolved.type === "typing" || resolved.type === "rename" || resolved.type === "avatar" || resolved.type === "unsend") {
119
+ if (resolved.type === "edit" || resolved.type === "reply" || resolved.type === "reaction" || resolved.type === "group" || resolved.type === "typing" || resolved.type === "rename" || resolved.type === "avatar" || resolved.type === "unsend" || resolved.type === "read") {
120
120
  throw new Error(`edit() cannot wrap "${resolved.type}" content`);
121
121
  }
122
122
  return asEdit({ content: resolved, target });
@@ -138,11 +138,34 @@ function markdown(source, options) {
138
138
  return streamTextBuilder("markdown", source, options);
139
139
  }
140
140
 
141
- // src/content/rename.ts
141
+ // src/content/read.ts
142
142
  import z5 from "zod";
143
- var renameSchema = z5.object({
144
- type: z5.literal("rename"),
145
- displayName: z5.string().min(1, "rename() displayName must be non-empty")
143
+ var isMessage2 = (v) => typeof v === "object" && v !== null && "id" in v && "content" in v;
144
+ var readSchema2 = z5.object({
145
+ type: z5.literal("read"),
146
+ target: z5.custom(isMessage2, {
147
+ message: "read target must be a Message"
148
+ })
149
+ });
150
+ var asRead = (input) => readSchema2.parse({ type: "read", ...input });
151
+ function read(target) {
152
+ return {
153
+ build: async () => {
154
+ if (target.direction !== "inbound") {
155
+ throw new Error(
156
+ `read() target must be an inbound message (got direction "${target.direction}", message id "${target.id}")`
157
+ );
158
+ }
159
+ return asRead({ target });
160
+ }
161
+ };
162
+ }
163
+
164
+ // src/content/rename.ts
165
+ import z6 from "zod";
166
+ var renameSchema = z6.object({
167
+ type: z6.literal("rename"),
168
+ displayName: z6.string().min(1, "rename() displayName must be non-empty")
146
169
  });
147
170
  function rename(displayName) {
148
171
  return {
@@ -151,15 +174,15 @@ function rename(displayName) {
151
174
  }
152
175
 
153
176
  // src/content/reply.ts
154
- import z6 from "zod";
155
- var isMessage2 = (v) => typeof v === "object" && v !== null && "id" in v && "content" in v;
177
+ import z7 from "zod";
178
+ var isMessage3 = (v) => typeof v === "object" && v !== null && "id" in v && "content" in v;
156
179
  var isContent2 = (v) => typeof v === "object" && v !== null && "type" in v && typeof v.type === "string";
157
- var replySchema = z6.object({
158
- type: z6.literal("reply"),
159
- content: z6.custom(isContent2, {
180
+ var replySchema = z7.object({
181
+ type: z7.literal("reply"),
182
+ content: z7.custom(isContent2, {
160
183
  message: "reply content must be a Content value"
161
184
  }),
162
- target: z6.custom(isMessage2, {
185
+ target: z7.custom(isMessage3, {
163
186
  message: "reply target must be a Message"
164
187
  })
165
188
  });
@@ -176,7 +199,7 @@ function reply(content, target) {
176
199
  if (!resolved) {
177
200
  throw new Error("reply() requires content");
178
201
  }
179
- if (resolved.type === "reply" || resolved.type === "edit" || resolved.type === "reaction" || resolved.type === "group" || resolved.type === "typing" || resolved.type === "rename" || resolved.type === "avatar" || resolved.type === "unsend") {
202
+ if (resolved.type === "reply" || resolved.type === "edit" || resolved.type === "reaction" || resolved.type === "group" || resolved.type === "typing" || resolved.type === "rename" || resolved.type === "avatar" || resolved.type === "unsend" || resolved.type === "read") {
180
203
  throw new Error(`reply() cannot wrap "${resolved.type}" content`);
181
204
  }
182
205
  return asReply({ content: resolved, target });
@@ -185,10 +208,10 @@ function reply(content, target) {
185
208
  }
186
209
 
187
210
  // src/content/typing.ts
188
- import z7 from "zod";
189
- var typingSchema = z7.object({
190
- type: z7.literal("typing"),
191
- state: z7.enum(["start", "stop"])
211
+ import z8 from "zod";
212
+ var typingSchema = z8.object({
213
+ type: z8.literal("typing"),
214
+ state: z8.enum(["start", "stop"])
192
215
  });
193
216
  function typing(state = "start") {
194
217
  return {
@@ -197,11 +220,11 @@ function typing(state = "start") {
197
220
  }
198
221
 
199
222
  // src/content/unsend.ts
200
- import z8 from "zod";
201
- var isMessage3 = (v) => typeof v === "object" && v !== null && "id" in v && "content" in v;
202
- var unsendSchema = z8.object({
203
- type: z8.literal("unsend"),
204
- target: z8.custom(isMessage3, {
223
+ import z9 from "zod";
224
+ var isMessage4 = (v) => typeof v === "object" && v !== null && "id" in v && "content" in v;
225
+ var unsendSchema = z9.object({
226
+ type: z9.literal("unsend"),
227
+ target: z9.custom(isMessage4, {
205
228
  message: "unsend target must be a Message"
206
229
  })
207
230
  });
@@ -545,7 +568,8 @@ var FIRE_AND_FORGET_TYPES = /* @__PURE__ */ new Set([
545
568
  "edit",
546
569
  "rename",
547
570
  "avatar",
548
- "unsend"
571
+ "unsend",
572
+ "read"
549
573
  ]);
550
574
  var isFireAndForget = (item) => FIRE_AND_FORGET_TYPES.has(item.type) || item.__fireAndForget === true;
551
575
  var RESERVED_SPACE_KEYS = /* @__PURE__ */ new Set([
@@ -554,6 +578,7 @@ var RESERVED_SPACE_KEYS = /* @__PURE__ */ new Set([
554
578
  "send",
555
579
  "edit",
556
580
  "unsend",
581
+ "read",
557
582
  "getMessage",
558
583
  "rename",
559
584
  "avatar",
@@ -569,6 +594,7 @@ var RESERVED_MESSAGE_KEYS = /* @__PURE__ */ new Set([
569
594
  "id",
570
595
  "platform",
571
596
  "react",
597
+ "read",
572
598
  "reply",
573
599
  "sender",
574
600
  "space",
@@ -938,6 +964,9 @@ function buildSpace(params) {
938
964
  unsend: async (message) => {
939
965
  await space.send(unsend(message));
940
966
  },
967
+ read: async (message) => {
968
+ await space.send(read(message));
969
+ },
941
970
  getMessage: getMessageImpl,
942
971
  rename: async (displayName) => {
943
972
  await space.send(rename(displayName));
@@ -1010,6 +1039,15 @@ function buildMessage(params) {
1010
1039
  }
1011
1040
  await space.send(unsend(target));
1012
1041
  };
1042
+ const read2 = async () => {
1043
+ const target = requireBuiltMessage("read");
1044
+ if (target.direction !== "inbound") {
1045
+ throw new Error(
1046
+ `cannot mark message ${target.id} as read: only inbound messages can be marked read (direction: "${target.direction}")`
1047
+ );
1048
+ }
1049
+ await space.send(read(target));
1050
+ };
1013
1051
  const buildSenderWithPlatform = () => {
1014
1052
  if (params.sender === void 0) {
1015
1053
  return;
@@ -1046,6 +1084,7 @@ function buildMessage(params) {
1046
1084
  direction: params.direction,
1047
1085
  platform: definition.name,
1048
1086
  react,
1087
+ read: read2,
1049
1088
  reply: reply2,
1050
1089
  edit: edit2,
1051
1090
  unsend: unsend2,
@@ -1325,6 +1364,7 @@ export {
1325
1364
  markdownSchema,
1326
1365
  asMarkdown,
1327
1366
  markdown,
1367
+ read,
1328
1368
  rename,
1329
1369
  reply,
1330
1370
  typing,
@@ -2,12 +2,12 @@ import { createRequire as __spectrumCreateRequire } from "node:module"; const re
2
2
  import {
3
3
  asPollOption
4
4
  } from "./chunk-2D27WW5B.js";
5
- import {
6
- cloud
7
- } from "./chunk-3GEJYGZK.js";
8
5
  import {
9
6
  asContact
10
7
  } from "./chunk-A37PM5N2.js";
8
+ import {
9
+ cloud
10
+ } from "./chunk-3GEJYGZK.js";
11
11
  import {
12
12
  mergeStreams,
13
13
  stream
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  UnsupportedError,
17
17
  definePlatform
18
- } from "./chunk-OGTHPDG7.js";
18
+ } from "./chunk-B52VPQO3.js";
19
19
  import {
20
20
  asAttachment,
21
21
  asCustom,
@@ -644,6 +644,10 @@ var send = async (clients, spaceId, content) => {
644
644
  if (content.type === "typing") {
645
645
  return;
646
646
  }
647
+ if (content.type === "read") {
648
+ await primary(clients).messages.markRead(content.target.id);
649
+ return;
650
+ }
647
651
  const client = primary(clients);
648
652
  switch (content.type) {
649
653
  case "text":
@@ -2,12 +2,12 @@ import { createRequire as __spectrumCreateRequire } from "node:module"; const re
2
2
  import {
3
3
  fusor
4
4
  } from "./chunk-34FQGGD7.js";
5
- import {
6
- asGroup
7
- } from "./chunk-LZXPLXZF.js";
8
5
  import {
9
6
  asVoice
10
7
  } from "./chunk-FAIFTUV2.js";
8
+ import {
9
+ asGroup
10
+ } from "./chunk-LZXPLXZF.js";
11
11
  import {
12
12
  toVCard
13
13
  } from "./chunk-6UZFVXQF.js";
@@ -16,7 +16,7 @@ import {
16
16
  asMarkdown,
17
17
  definePlatform,
18
18
  renderInlineTokens
19
- } from "./chunk-OGTHPDG7.js";
19
+ } from "./chunk-B52VPQO3.js";
20
20
  import {
21
21
  asAttachment,
22
22
  asCustom,
@@ -793,6 +793,8 @@ var send = async ({
793
793
  return await sendReaction(client, space, content);
794
794
  case "typing":
795
795
  return await sendTyping(client, space, content.state);
796
+ case "read":
797
+ return;
796
798
  case "edit":
797
799
  return await sendEdit(client, space, content);
798
800
  case "group":
@@ -10,27 +10,27 @@ import {
10
10
  asPoll,
11
11
  asPollOption
12
12
  } from "./chunk-2D27WW5B.js";
13
- import {
14
- cloud
15
- } from "./chunk-3GEJYGZK.js";
16
13
  import {
17
14
  asContact
18
15
  } from "./chunk-A37PM5N2.js";
19
- import {
20
- mergeStreams,
21
- stream
22
- } from "./chunk-5XEFJBN2.js";
23
16
  import {
24
17
  fromVCard,
25
18
  toVCard
26
19
  } from "./chunk-6UZFVXQF.js";
20
+ import {
21
+ cloud
22
+ } from "./chunk-3GEJYGZK.js";
23
+ import {
24
+ mergeStreams,
25
+ stream
26
+ } from "./chunk-5XEFJBN2.js";
27
27
  import {
28
28
  UnsupportedError,
29
29
  buildPhotoAction,
30
30
  definePlatform,
31
31
  markdownSchema,
32
32
  photoActionSchema
33
- } from "./chunk-OGTHPDG7.js";
33
+ } from "./chunk-B52VPQO3.js";
34
34
  import {
35
35
  asAttachment,
36
36
  asCustom,
@@ -172,68 +172,38 @@ function effect(input, messageEffect) {
172
172
  };
173
173
  }
174
174
 
175
- // src/providers/imessage/content/read.ts
176
- import z4 from "zod";
177
- var isMessage = (v) => typeof v === "object" && v !== null && "id" in v && "content" in v;
178
- var readSchema = z4.object({
179
- type: z4.literal("read"),
180
- __platform: z4.literal("iMessage"),
181
- __fireAndForget: z4.literal(true),
182
- target: z4.custom(isMessage, {
183
- message: "read target must be a Message"
184
- })
185
- });
186
- var isRead = (v) => readSchema.safeParse(v).success;
187
- function read(target) {
188
- return {
189
- build: async () => {
190
- if (target.direction !== "inbound") {
191
- throw new Error(
192
- `read() target must be an inbound message (got direction "${target.direction}", message id "${target.id}")`
193
- );
194
- }
195
- return readSchema.parse({
196
- type: "read",
197
- __platform: "iMessage",
198
- __fireAndForget: true,
199
- target
200
- });
201
- }
202
- };
203
- }
204
-
205
175
  // src/providers/imessage/auth.ts
206
176
  import { createClient } from "@photon-ai/advanced-imessage";
207
177
 
208
178
  // src/providers/imessage/types.ts
209
179
  import { IMessageSDK } from "@photon-ai/imessage-kit";
210
- import z5 from "zod";
180
+ import z4 from "zod";
211
181
  var SHARED_PHONE = "shared";
212
182
  var isLocal = (client) => client instanceof IMessageSDK;
213
- var clientEntry = z5.object({
214
- address: z5.string(),
215
- token: z5.string(),
216
- phone: z5.string()
183
+ var clientEntry = z4.object({
184
+ address: z4.string(),
185
+ token: z4.string(),
186
+ phone: z4.string()
217
187
  });
218
- var configSchema = z5.union([
219
- z5.object({ local: z5.literal(true) }),
220
- z5.object({
221
- local: z5.literal(false).optional().default(false),
222
- clients: clientEntry.or(z5.array(clientEntry)).optional()
188
+ var configSchema = z4.union([
189
+ z4.object({ local: z4.literal(true) }),
190
+ z4.object({
191
+ local: z4.literal(false).optional().default(false),
192
+ clients: clientEntry.or(z4.array(clientEntry)).optional()
223
193
  })
224
194
  ]);
225
- var userSchema = z5.object({});
226
- var spaceSchema = z5.object({
227
- id: z5.string(),
228
- type: z5.enum(["dm", "group"]),
229
- phone: z5.string()
195
+ var userSchema = z4.object({});
196
+ var spaceSchema = z4.object({
197
+ id: z4.string(),
198
+ type: z4.enum(["dm", "group"]),
199
+ phone: z4.string()
230
200
  });
231
- var spaceParamsSchema = z5.object({
232
- phone: z5.string().optional()
201
+ var spaceParamsSchema = z4.object({
202
+ phone: z4.string().optional()
233
203
  });
234
- var messageSchema = z5.object({
235
- partIndex: z5.number().int().nonnegative().optional(),
236
- parentId: z5.string().optional()
204
+ var messageSchema = z4.object({
205
+ partIndex: z4.number().int().nonnegative().optional(),
206
+ parentId: z4.string().optional()
237
207
  });
238
208
 
239
209
  // src/providers/imessage/auth.ts
@@ -2852,23 +2822,11 @@ var imessage = definePlatform("iMessage", {
2852
2822
  // local-mode iMessage is identical to the canonical form.
2853
2823
  background: async (space, input, opts) => {
2854
2824
  await space.send(background(input, opts));
2855
- },
2856
- // Sugar: `space.read(message)` → `space.send(read(message))`.
2857
- read: async (space, message) => {
2858
- await space.send(read(message));
2859
2825
  }
2860
2826
  }
2861
2827
  },
2862
2828
  message: {
2863
- schema: messageSchema,
2864
- actions: {
2865
- // Sugar: `message.read()` → `message.space.send(read(self))`.
2866
- // `buildMessage` injects the message as the first argument; callers
2867
- // pass nothing.
2868
- read: async (message) => {
2869
- await message.space.send(read(message));
2870
- }
2871
- }
2829
+ schema: messageSchema
2872
2830
  },
2873
2831
  messages: ({ client, projectConfig }) => isLocal(client) ? messages2(client) : messages4(client, projectConfig),
2874
2832
  send: async ({ space, content, client }) => {
@@ -2941,12 +2899,12 @@ var imessage = definePlatform("iMessage", {
2941
2899
  await handleAvatar(client, space, content);
2942
2900
  return;
2943
2901
  }
2944
- if (isBackground(content)) {
2945
- await handleBackground(client, space, content);
2902
+ if (content.type === "read") {
2903
+ await handleRead(client, space);
2946
2904
  return;
2947
2905
  }
2948
- if (isRead(content)) {
2949
- await handleRead(client, space);
2906
+ if (isBackground(content)) {
2907
+ await handleBackground(client, space, content);
2950
2908
  return;
2951
2909
  }
2952
2910
  if (isCustomizedMiniApp(content)) {
@@ -3018,6 +2976,5 @@ export {
3018
2976
  background,
3019
2977
  customizedMiniApp,
3020
2978
  effect,
3021
- read,
3022
2979
  imessage
3023
2980
  };
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  UnsupportedError,
11
11
  definePlatform
12
- } from "./chunk-OGTHPDG7.js";
12
+ } from "./chunk-B52VPQO3.js";
13
13
  import {
14
14
  asAttachment,
15
15
  asCustom,
@@ -350,6 +350,9 @@ var send = async (client, space, content) => {
350
350
  if (content.type === "typing") {
351
351
  return;
352
352
  }
353
+ if (content.type === "read") {
354
+ return;
355
+ }
353
356
  return await sendContent(client, space, content);
354
357
  };
355
358
  var sendContent = async (client, space, content, threadTs) => {
@@ -0,0 +1,94 @@
1
+ import { Elysia } from 'elysia';
2
+ import { W as WebhookHandler } from './types-ZgFTj5hJ.js';
3
+ export { M as Message, S as Space } from './types-CyfLJXgu.js';
4
+ import 'hotscript';
5
+ import 'zod';
6
+
7
+ /**
8
+ * The minimal structural surface of a Spectrum instance the plugin needs. Kept
9
+ * structural (rather than importing the generic `SpectrumInstance<Providers>`)
10
+ * so the plugin stays decoupled from provider typing; a real instance is
11
+ * assignable via its Web `Request` webhook overload.
12
+ */
13
+ interface WebhookReceiver {
14
+ webhook(request: Request, handler: WebhookHandler): Promise<Response>;
15
+ }
16
+ interface SpectrumPluginOptions {
17
+ /** The Spectrum instance returned by `await Spectrum({...})`. */
18
+ app: WebhookReceiver;
19
+ /**
20
+ * Invoked once per inbound message, fire-and-forget after the response — the
21
+ * same `(space, message)` contract as `app.webhook(request, handler)`. Covers
22
+ * both native Spectrum webhooks and fusor webhooks identically.
23
+ */
24
+ onMessage: WebhookHandler;
25
+ /**
26
+ * Route the webhook is mounted on.
27
+ *
28
+ * @default "/spectrum/webhook"
29
+ */
30
+ path?: string;
31
+ }
32
+ /**
33
+ * Mount a Spectrum webhook endpoint on an Elysia app.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { Elysia } from "elysia";
38
+ * import { Spectrum } from "spectrum-ts";
39
+ * import { spectrum } from "spectrum-ts/elysia";
40
+ *
41
+ * const app = await Spectrum({ ..., webhookSecret: process.env.SPECTRUM_WEBHOOK_SECRET });
42
+ *
43
+ * new Elysia()
44
+ * .use(spectrum({
45
+ * app,
46
+ * onMessage: async (space, message) => {
47
+ * if (message.content.type === "text") await space.send(`echo: ${message.content.text}`);
48
+ * },
49
+ * }))
50
+ * .listen(3000);
51
+ * ```
52
+ */
53
+ declare function spectrum(options: SpectrumPluginOptions): Elysia<"", {
54
+ decorator: {};
55
+ store: {};
56
+ derive: {};
57
+ resolve: {};
58
+ }, {
59
+ typebox: {};
60
+ error: {};
61
+ }, {
62
+ schema: {};
63
+ standaloneSchema: {};
64
+ macro: {};
65
+ macroFn: {};
66
+ parser: {};
67
+ response: {};
68
+ }, {
69
+ [x: string]: {
70
+ post: {
71
+ body: unknown;
72
+ params: {};
73
+ query: unknown;
74
+ headers: unknown;
75
+ response: {
76
+ 200: Response;
77
+ };
78
+ };
79
+ };
80
+ }, {
81
+ derive: {};
82
+ resolve: {};
83
+ schema: {};
84
+ standaloneSchema: {};
85
+ response: {};
86
+ }, {
87
+ derive: {};
88
+ resolve: {};
89
+ schema: {};
90
+ standaloneSchema: {};
91
+ response: {};
92
+ }>;
93
+
94
+ export { type SpectrumPluginOptions, WebhookHandler, spectrum };
package/dist/elysia.js ADDED
@@ -0,0 +1,15 @@
1
+ import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
+
3
+ // src/elysia.ts
4
+ import { Elysia } from "elysia";
5
+ function spectrum(options) {
6
+ const { app, onMessage, path = "/spectrum/webhook" } = options;
7
+ return new Elysia({ name: "spectrum-webhook", seed: path }).post(
8
+ path,
9
+ ({ request }) => app.webhook(request, onMessage),
10
+ { parse: "none" }
11
+ );
12
+ }
13
+ export {
14
+ spectrum
15
+ };