spectrum-ts 1.5.0 → 1.7.2
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/dist/{chunk-NIIJ6U34.js → chunk-2SB6VN7J.js} +48 -50
- package/dist/{chunk-NNRUJOPT.js → chunk-ET42EGIA.js} +27 -26
- package/dist/{chunk-L6LUFBLF.js → chunk-HWADNTQF.js} +4 -4
- package/dist/{chunk-LH4YEBG3.js → chunk-JWWIFSI7.js} +173 -185
- package/dist/{chunk-66GJ45ZZ.js → chunk-VO43HJ5B.js} +1 -1
- package/dist/{chunk-B4MHPWPZ.js → chunk-VVXMZYDH.js} +2 -2
- package/dist/{chunk-4U4RINOV.js → chunk-ZDNX3S3H.js} +224 -103
- package/dist/index.d.ts +549 -8
- package/dist/index.js +87 -92
- package/dist/providers/imessage/index.d.ts +31 -35
- package/dist/providers/imessage/index.js +6 -4
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +7 -7
- package/dist/providers/terminal/index.d.ts +256 -28
- package/dist/providers/terminal/index.js +3 -3
- package/dist/providers/whatsapp-business/index.d.ts +2 -16
- package/dist/providers/whatsapp-business/index.js +3 -3
- package/dist/types-lUyzRurY.d.ts +1029 -0
- package/package.json +1 -1
- package/dist/types-D0QSU6kb.d.ts +0 -490
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
group,
|
|
3
3
|
richlink
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VO43HJ5B.js";
|
|
5
5
|
import {
|
|
6
6
|
voice
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VVXMZYDH.js";
|
|
8
8
|
import {
|
|
9
9
|
SpectrumCloudError,
|
|
10
10
|
broadcast,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
option,
|
|
14
14
|
poll,
|
|
15
15
|
stream
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-HWADNTQF.js";
|
|
17
17
|
import {
|
|
18
18
|
UnsupportedError,
|
|
19
19
|
attachment,
|
|
@@ -21,13 +21,16 @@ import {
|
|
|
21
21
|
contact,
|
|
22
22
|
custom,
|
|
23
23
|
definePlatform,
|
|
24
|
+
edit,
|
|
24
25
|
fromVCard,
|
|
25
26
|
reaction,
|
|
27
|
+
reply,
|
|
26
28
|
resolveContents,
|
|
27
29
|
text,
|
|
28
30
|
toVCard,
|
|
31
|
+
typing,
|
|
29
32
|
wrapProviderMessage
|
|
30
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-JWWIFSI7.js";
|
|
31
34
|
|
|
32
35
|
// src/emoji/generated.ts
|
|
33
36
|
var GeneratedEmoji = {
|
|
@@ -2048,30 +2051,28 @@ async function Spectrum(options) {
|
|
|
2048
2051
|
const messageBroadcasters = /* @__PURE__ */ new Map();
|
|
2049
2052
|
const customEventStreams = /* @__PURE__ */ new Map();
|
|
2050
2053
|
let stopped = false;
|
|
2051
|
-
const adaptIterable = (iterable) => {
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
result = await iterator.next();
|
|
2060
|
-
}
|
|
2061
|
-
end();
|
|
2062
|
-
} catch (error) {
|
|
2063
|
-
end(error);
|
|
2054
|
+
const adaptIterable = (iterable) => stream((emit, end) => {
|
|
2055
|
+
const iterator = iterable[Symbol.asyncIterator]();
|
|
2056
|
+
const pump = (async () => {
|
|
2057
|
+
try {
|
|
2058
|
+
let result = await iterator.next();
|
|
2059
|
+
while (!result.done) {
|
|
2060
|
+
await emit(result.value);
|
|
2061
|
+
result = await iterator.next();
|
|
2064
2062
|
}
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2063
|
+
end();
|
|
2064
|
+
} catch (error) {
|
|
2065
|
+
end(error);
|
|
2066
|
+
}
|
|
2067
|
+
})();
|
|
2068
|
+
return async () => {
|
|
2069
|
+
await iterator.return?.();
|
|
2070
|
+
await pump.catch(ignoreCleanupError);
|
|
2071
|
+
};
|
|
2072
|
+
});
|
|
2072
2073
|
const createProviderMessagesStream = (state) => {
|
|
2073
2074
|
const { client, config, definition, store } = state;
|
|
2074
|
-
const raw = definition.
|
|
2075
|
+
const raw = definition.messages({
|
|
2075
2076
|
client,
|
|
2076
2077
|
config,
|
|
2077
2078
|
store
|
|
@@ -2082,11 +2083,11 @@ async function Spectrum(options) {
|
|
|
2082
2083
|
...msg.space,
|
|
2083
2084
|
__platform: definition.name
|
|
2084
2085
|
};
|
|
2085
|
-
const
|
|
2086
|
+
const actionCtx = { space: spaceRef, client, config, store };
|
|
2086
2087
|
const space = buildSpace({
|
|
2087
2088
|
spaceRef,
|
|
2088
2089
|
extras: {},
|
|
2089
|
-
|
|
2090
|
+
actionCtx,
|
|
2090
2091
|
definition,
|
|
2091
2092
|
client,
|
|
2092
2093
|
config,
|
|
@@ -2151,65 +2152,60 @@ async function Spectrum(options) {
|
|
|
2151
2152
|
subscribeMessages: () => getOrCreateMessageBroadcast(state).subscribe()
|
|
2152
2153
|
});
|
|
2153
2154
|
}
|
|
2154
|
-
const createMessagesStream = () => {
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
await emit(value);
|
|
2166
|
-
}
|
|
2167
|
-
end();
|
|
2168
|
-
} catch (error) {
|
|
2169
|
-
end(error);
|
|
2170
|
-
}
|
|
2171
|
-
})();
|
|
2172
|
-
return async () => {
|
|
2173
|
-
await merged.close();
|
|
2174
|
-
void pump.catch(ignoreCleanupError);
|
|
2175
|
-
};
|
|
2176
|
-
});
|
|
2177
|
-
};
|
|
2178
|
-
const createCustomEventStream = (eventName) => {
|
|
2179
|
-
return stream((emit, end) => {
|
|
2180
|
-
const providerStreams = Array.from(platformStates.values(), (state) => {
|
|
2181
|
-
const { client, config, definition, store } = state;
|
|
2182
|
-
const producer = definition.events[eventName];
|
|
2183
|
-
if (!producer) {
|
|
2184
|
-
return void 0;
|
|
2155
|
+
const createMessagesStream = () => stream((emit, end) => {
|
|
2156
|
+
const merged = mergeStreams(
|
|
2157
|
+
Array.from(
|
|
2158
|
+
platformStates.values(),
|
|
2159
|
+
(runtime) => runtime.subscribeMessages()
|
|
2160
|
+
)
|
|
2161
|
+
);
|
|
2162
|
+
const pump = (async () => {
|
|
2163
|
+
try {
|
|
2164
|
+
for await (const value of merged) {
|
|
2165
|
+
await emit(value);
|
|
2185
2166
|
}
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2167
|
+
end();
|
|
2168
|
+
} catch (error) {
|
|
2169
|
+
end(error);
|
|
2170
|
+
}
|
|
2171
|
+
})();
|
|
2172
|
+
return async () => {
|
|
2173
|
+
await merged.close();
|
|
2174
|
+
await pump.catch(ignoreCleanupError);
|
|
2175
|
+
};
|
|
2176
|
+
});
|
|
2177
|
+
const createCustomEventStream = (eventName) => stream((emit, end) => {
|
|
2178
|
+
const providerStreams = [];
|
|
2179
|
+
for (const state of platformStates.values()) {
|
|
2180
|
+
const { client, config, definition, store } = state;
|
|
2181
|
+
const producer = definition.events?.[eventName];
|
|
2182
|
+
if (!producer) {
|
|
2183
|
+
continue;
|
|
2184
|
+
}
|
|
2185
|
+
const providerEvents = producer({ client, config, store });
|
|
2186
|
+
const annotatePlatform = async function* () {
|
|
2187
|
+
for await (const value of providerEvents) {
|
|
2188
|
+
yield { ...value, platform: definition.name };
|
|
2205
2189
|
}
|
|
2206
|
-
})();
|
|
2207
|
-
return async () => {
|
|
2208
|
-
await merged.close();
|
|
2209
|
-
void pump.catch(ignoreCleanupError);
|
|
2210
2190
|
};
|
|
2211
|
-
|
|
2212
|
-
|
|
2191
|
+
providerStreams.push(adaptIterable(annotatePlatform()));
|
|
2192
|
+
}
|
|
2193
|
+
const merged = mergeStreams(providerStreams);
|
|
2194
|
+
const pump = (async () => {
|
|
2195
|
+
try {
|
|
2196
|
+
for await (const value of merged) {
|
|
2197
|
+
await emit(value);
|
|
2198
|
+
}
|
|
2199
|
+
end();
|
|
2200
|
+
} catch (error) {
|
|
2201
|
+
end(error);
|
|
2202
|
+
}
|
|
2203
|
+
})();
|
|
2204
|
+
return async () => {
|
|
2205
|
+
await merged.close();
|
|
2206
|
+
await pump.catch(ignoreCleanupError);
|
|
2207
|
+
};
|
|
2208
|
+
});
|
|
2213
2209
|
const messagesStream = createMessagesStream();
|
|
2214
2210
|
const stopOnce = async () => {
|
|
2215
2211
|
if (stopped) {
|
|
@@ -2267,17 +2263,13 @@ async function Spectrum(options) {
|
|
|
2267
2263
|
__internal: { platforms: platformStates },
|
|
2268
2264
|
messages,
|
|
2269
2265
|
stop: stopOnce,
|
|
2270
|
-
send: (async (space, ...content) =>
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
);
|
|
2274
|
-
}),
|
|
2266
|
+
send: (async (space, ...content) => content.length === 1 ? await space.send(content[0]) : await space.send(
|
|
2267
|
+
...content
|
|
2268
|
+
)),
|
|
2275
2269
|
edit: async (message, newContent) => {
|
|
2276
2270
|
await message.edit(newContent);
|
|
2277
2271
|
},
|
|
2278
|
-
responding: async (space, fn) =>
|
|
2279
|
-
return space.responding(fn);
|
|
2280
|
-
}
|
|
2272
|
+
responding: async (space, fn) => space.responding(fn)
|
|
2281
2273
|
};
|
|
2282
2274
|
return new Proxy(base, {
|
|
2283
2275
|
get(target, prop, receiver) {
|
|
@@ -2287,7 +2279,7 @@ async function Spectrum(options) {
|
|
|
2287
2279
|
if (typeof prop === "string") {
|
|
2288
2280
|
return customEventProxy[prop];
|
|
2289
2281
|
}
|
|
2290
|
-
return
|
|
2282
|
+
return;
|
|
2291
2283
|
}
|
|
2292
2284
|
});
|
|
2293
2285
|
}
|
|
@@ -2302,16 +2294,19 @@ export {
|
|
|
2302
2294
|
contact,
|
|
2303
2295
|
custom,
|
|
2304
2296
|
definePlatform,
|
|
2297
|
+
edit,
|
|
2305
2298
|
fromVCard,
|
|
2306
2299
|
group,
|
|
2307
2300
|
mergeStreams,
|
|
2308
2301
|
option,
|
|
2309
2302
|
poll,
|
|
2310
2303
|
reaction,
|
|
2304
|
+
reply,
|
|
2311
2305
|
resolveContents,
|
|
2312
2306
|
richlink,
|
|
2313
2307
|
stream,
|
|
2314
2308
|
text,
|
|
2315
2309
|
toVCard,
|
|
2310
|
+
typing,
|
|
2316
2311
|
voice
|
|
2317
2312
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as ContentBuilder, b as ContentInput, S as SchemaMessage, P as Platform, a as PlatformDef } from '../../types-lUyzRurY.js';
|
|
2
2
|
import * as zod_v4_core from 'zod/v4/core';
|
|
3
3
|
import * as z from 'zod';
|
|
4
4
|
import z__default from 'zod';
|
|
@@ -6,6 +6,34 @@ import { MessageEffect, AdvancedIMessage } from '@photon-ai/advanced-imessage';
|
|
|
6
6
|
import { IMessageSDK } from '@photon-ai/imessage-kit';
|
|
7
7
|
import 'hotscript';
|
|
8
8
|
|
|
9
|
+
declare const CLEAR_SENTINEL: "clear";
|
|
10
|
+
type BackgroundInput = typeof CLEAR_SENTINEL | string | Buffer;
|
|
11
|
+
/**
|
|
12
|
+
* Set or clear the chat background. iMessage-only, remote-only.
|
|
13
|
+
*
|
|
14
|
+
* - `background("clear")` — remove the current chat background.
|
|
15
|
+
* - `background("./photo.jpg")` — set background from a filesystem path.
|
|
16
|
+
* MIME type is inferred from the extension; override with `options.mimeType`.
|
|
17
|
+
* - `background(buffer, { mimeType })` — set background from in-memory bytes.
|
|
18
|
+
* `options.mimeType` is required.
|
|
19
|
+
*
|
|
20
|
+
* `"clear"` is a reserved string-literal sentinel. If you have a file literally
|
|
21
|
+
* named `clear` with no extension, pass `"./clear"` or load it as a Buffer.
|
|
22
|
+
*
|
|
23
|
+
* `space.send(background(...))` is the canonical form; `space.background(...)`
|
|
24
|
+
* is sugar attached via `PlatformDef.space.actions` (only typed on
|
|
25
|
+
* `PlatformSpace<IMessageDef>`).
|
|
26
|
+
*
|
|
27
|
+
* `Background` is intentionally not a member of the universal `Content`
|
|
28
|
+
* union — the `as unknown as Content` cast keeps the builder shape compatible
|
|
29
|
+
* with the framework's `ContentBuilder.build(): Promise<Content>` signature.
|
|
30
|
+
* The framework treats it as a fire-and-forget control signal at runtime.
|
|
31
|
+
*/
|
|
32
|
+
declare function background(input: "clear"): ContentBuilder;
|
|
33
|
+
declare function background(input: string | Buffer, options?: {
|
|
34
|
+
mimeType?: string;
|
|
35
|
+
}): ContentBuilder;
|
|
36
|
+
|
|
9
37
|
type IMessageMessageEffect = MessageEffect;
|
|
10
38
|
declare function effect(input: ContentInput, messageEffect: IMessageMessageEffect): ContentBuilder;
|
|
11
39
|
|
|
@@ -63,39 +91,7 @@ declare const imessage: Platform<PlatformDef<"iMessage", z.ZodUnion<readonly [z.
|
|
|
63
91
|
}, z.ZodObject<{
|
|
64
92
|
partIndex: z.ZodOptional<z.ZodNumber>;
|
|
65
93
|
parentId: z.ZodOptional<z.ZodString>;
|
|
66
|
-
}, zod_v4_core.$strip>,
|
|
67
|
-
id: string;
|
|
68
|
-
}, {
|
|
69
|
-
id: string;
|
|
70
|
-
type: "dm";
|
|
71
|
-
phone: string;
|
|
72
|
-
} | {
|
|
73
|
-
id: string;
|
|
74
|
-
type: "group";
|
|
75
|
-
phone: string;
|
|
76
|
-
}, {
|
|
77
|
-
partIndex?: number | undefined;
|
|
78
|
-
parentId?: string | undefined;
|
|
79
|
-
}>, {
|
|
80
|
-
messages: ({ client }: {
|
|
81
|
-
client: IMessageClient;
|
|
82
|
-
config: {
|
|
83
|
-
local: true;
|
|
84
|
-
} | {
|
|
85
|
-
local: false;
|
|
86
|
-
clients?: {
|
|
87
|
-
address: string;
|
|
88
|
-
token: string;
|
|
89
|
-
phone: string;
|
|
90
|
-
} | {
|
|
91
|
-
address: string;
|
|
92
|
-
token: string;
|
|
93
|
-
phone: string;
|
|
94
|
-
}[] | undefined;
|
|
95
|
-
};
|
|
96
|
-
store: Store;
|
|
97
|
-
}) => ManagedStream<IMessageMessage>;
|
|
98
|
-
}>> & Readonly<{
|
|
94
|
+
}, zod_v4_core.$strip>, IMessageMessage, undefined>> & Readonly<{
|
|
99
95
|
effect: {
|
|
100
96
|
message: {
|
|
101
97
|
readonly slam: "com.apple.MobileSMS.expressivesend.impact";
|
|
@@ -115,4 +111,4 @@ declare const imessage: Platform<PlatformDef<"iMessage", z.ZodUnion<readonly [z.
|
|
|
115
111
|
};
|
|
116
112
|
}>;
|
|
117
113
|
|
|
118
|
-
export { type IMessageMessageEffect, effect, imessage };
|
|
114
|
+
export { type BackgroundInput, type IMessageMessageEffect, background, effect, imessage };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
background,
|
|
2
3
|
effect,
|
|
3
4
|
imessage
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
5
|
+
} from "../../chunk-ZDNX3S3H.js";
|
|
6
|
+
import "../../chunk-VO43HJ5B.js";
|
|
7
|
+
import "../../chunk-HWADNTQF.js";
|
|
8
|
+
import "../../chunk-JWWIFSI7.js";
|
|
8
9
|
export {
|
|
10
|
+
background,
|
|
9
11
|
effect,
|
|
10
12
|
imessage
|
|
11
13
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { imessage } from './imessage/index.js';
|
|
2
2
|
export { terminal } from './terminal/index.js';
|
|
3
3
|
export { whatsappBusiness } from './whatsapp-business/index.js';
|
|
4
|
-
import '../types-
|
|
4
|
+
import '../types-lUyzRurY.js';
|
|
5
5
|
import 'hotscript';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'zod/v4/core';
|
package/dist/providers/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
imessage
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-ZDNX3S3H.js";
|
|
4
|
+
import "../chunk-VO43HJ5B.js";
|
|
5
5
|
import {
|
|
6
6
|
terminal
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-2SB6VN7J.js";
|
|
8
|
+
import "../chunk-VVXMZYDH.js";
|
|
9
9
|
import {
|
|
10
10
|
whatsappBusiness
|
|
11
|
-
} from "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
11
|
+
} from "../chunk-ET42EGIA.js";
|
|
12
|
+
import "../chunk-HWADNTQF.js";
|
|
13
|
+
import "../chunk-JWWIFSI7.js";
|
|
14
14
|
export {
|
|
15
15
|
imessage,
|
|
16
16
|
terminal,
|