spectrum-ts 1.4.0 → 1.7.1
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-2SB6VN7J.js +841 -0
- package/dist/chunk-4O7DPKLI.js +850 -0
- package/dist/chunk-H2QKKFQW.js +2254 -0
- 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-FF2R4EP3.js → chunk-WFIUWFE4.js} +4 -3
- package/dist/index.d.ts +549 -8
- package/dist/index.js +88 -92
- package/dist/providers/imessage/index.d.ts +33 -37
- package/dist/providers/imessage/index.js +8 -2097
- package/dist/providers/index.d.ts +12 -0
- package/dist/providers/index.js +18 -0
- package/dist/providers/terminal/index.d.ts +259 -31
- package/dist/providers/terminal/index.js +4 -838
- package/dist/providers/whatsapp-business/index.d.ts +2 -16
- package/dist/providers/whatsapp-business/index.js +4 -844
- package/dist/types-lUyzRurY.d.ts +1029 -0
- package/package.json +7 -3
- package/dist/types-BcCLW2VO.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-WFIUWFE4.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 = {
|
|
@@ -2017,6 +2020,7 @@ function createStore() {
|
|
|
2017
2020
|
}
|
|
2018
2021
|
|
|
2019
2022
|
// src/spectrum.ts
|
|
2023
|
+
var ignoreCleanupError = () => void 0;
|
|
2020
2024
|
var spectrumOptionsSchema = z.object({
|
|
2021
2025
|
flattenGroups: z.boolean().optional()
|
|
2022
2026
|
}).optional();
|
|
@@ -2047,30 +2051,28 @@ async function Spectrum(options) {
|
|
|
2047
2051
|
const messageBroadcasters = /* @__PURE__ */ new Map();
|
|
2048
2052
|
const customEventStreams = /* @__PURE__ */ new Map();
|
|
2049
2053
|
let stopped = false;
|
|
2050
|
-
const adaptIterable = (iterable) => {
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
result = await iterator.next();
|
|
2059
|
-
}
|
|
2060
|
-
end();
|
|
2061
|
-
} catch (error) {
|
|
2062
|
-
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();
|
|
2063
2062
|
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2063
|
+
end();
|
|
2064
|
+
} catch (error) {
|
|
2065
|
+
end(error);
|
|
2066
|
+
}
|
|
2067
|
+
})();
|
|
2068
|
+
return async () => {
|
|
2069
|
+
await iterator.return?.();
|
|
2070
|
+
await pump.catch(ignoreCleanupError);
|
|
2071
|
+
};
|
|
2072
|
+
});
|
|
2071
2073
|
const createProviderMessagesStream = (state) => {
|
|
2072
2074
|
const { client, config, definition, store } = state;
|
|
2073
|
-
const raw = definition.
|
|
2075
|
+
const raw = definition.messages({
|
|
2074
2076
|
client,
|
|
2075
2077
|
config,
|
|
2076
2078
|
store
|
|
@@ -2081,11 +2083,11 @@ async function Spectrum(options) {
|
|
|
2081
2083
|
...msg.space,
|
|
2082
2084
|
__platform: definition.name
|
|
2083
2085
|
};
|
|
2084
|
-
const
|
|
2086
|
+
const actionCtx = { space: spaceRef, client, config, store };
|
|
2085
2087
|
const space = buildSpace({
|
|
2086
2088
|
spaceRef,
|
|
2087
2089
|
extras: {},
|
|
2088
|
-
|
|
2090
|
+
actionCtx,
|
|
2089
2091
|
definition,
|
|
2090
2092
|
client,
|
|
2091
2093
|
config,
|
|
@@ -2150,65 +2152,60 @@ async function Spectrum(options) {
|
|
|
2150
2152
|
subscribeMessages: () => getOrCreateMessageBroadcast(state).subscribe()
|
|
2151
2153
|
});
|
|
2152
2154
|
}
|
|
2153
|
-
const createMessagesStream = () => {
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
await emit(value);
|
|
2165
|
-
}
|
|
2166
|
-
end();
|
|
2167
|
-
} catch (error) {
|
|
2168
|
-
end(error);
|
|
2169
|
-
}
|
|
2170
|
-
})();
|
|
2171
|
-
return async () => {
|
|
2172
|
-
await merged.close();
|
|
2173
|
-
await pump;
|
|
2174
|
-
};
|
|
2175
|
-
});
|
|
2176
|
-
};
|
|
2177
|
-
const createCustomEventStream = (eventName) => {
|
|
2178
|
-
return stream((emit, end) => {
|
|
2179
|
-
const providerStreams = Array.from(platformStates.values(), (state) => {
|
|
2180
|
-
const { client, config, definition, store } = state;
|
|
2181
|
-
const producer = definition.events[eventName];
|
|
2182
|
-
if (!producer) {
|
|
2183
|
-
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);
|
|
2184
2166
|
}
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
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 };
|
|
2204
2189
|
}
|
|
2205
|
-
})();
|
|
2206
|
-
return async () => {
|
|
2207
|
-
await merged.close();
|
|
2208
|
-
await pump;
|
|
2209
2190
|
};
|
|
2210
|
-
|
|
2211
|
-
|
|
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
|
+
});
|
|
2212
2209
|
const messagesStream = createMessagesStream();
|
|
2213
2210
|
const stopOnce = async () => {
|
|
2214
2211
|
if (stopped) {
|
|
@@ -2266,17 +2263,13 @@ async function Spectrum(options) {
|
|
|
2266
2263
|
__internal: { platforms: platformStates },
|
|
2267
2264
|
messages,
|
|
2268
2265
|
stop: stopOnce,
|
|
2269
|
-
send: (async (space, ...content) =>
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
);
|
|
2273
|
-
}),
|
|
2266
|
+
send: (async (space, ...content) => content.length === 1 ? await space.send(content[0]) : await space.send(
|
|
2267
|
+
...content
|
|
2268
|
+
)),
|
|
2274
2269
|
edit: async (message, newContent) => {
|
|
2275
2270
|
await message.edit(newContent);
|
|
2276
2271
|
},
|
|
2277
|
-
responding: async (space, fn) =>
|
|
2278
|
-
return space.responding(fn);
|
|
2279
|
-
}
|
|
2272
|
+
responding: async (space, fn) => space.responding(fn)
|
|
2280
2273
|
};
|
|
2281
2274
|
return new Proxy(base, {
|
|
2282
2275
|
get(target, prop, receiver) {
|
|
@@ -2286,7 +2279,7 @@ async function Spectrum(options) {
|
|
|
2286
2279
|
if (typeof prop === "string") {
|
|
2287
2280
|
return customEventProxy[prop];
|
|
2288
2281
|
}
|
|
2289
|
-
return
|
|
2282
|
+
return;
|
|
2290
2283
|
}
|
|
2291
2284
|
});
|
|
2292
2285
|
}
|
|
@@ -2301,16 +2294,19 @@ export {
|
|
|
2301
2294
|
contact,
|
|
2302
2295
|
custom,
|
|
2303
2296
|
definePlatform,
|
|
2297
|
+
edit,
|
|
2304
2298
|
fromVCard,
|
|
2305
2299
|
group,
|
|
2306
2300
|
mergeStreams,
|
|
2307
2301
|
option,
|
|
2308
2302
|
poll,
|
|
2309
2303
|
reaction,
|
|
2304
|
+
reply,
|
|
2310
2305
|
resolveContents,
|
|
2311
2306
|
richlink,
|
|
2312
2307
|
stream,
|
|
2313
2308
|
text,
|
|
2314
2309
|
toVCard,
|
|
2310
|
+
typing,
|
|
2315
2311
|
voice
|
|
2316
2312
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
|
@@ -18,8 +46,8 @@ declare const userSchema: z__default.ZodObject<{}, z__default.core.$strip>;
|
|
|
18
46
|
declare const spaceSchema: z__default.ZodObject<{
|
|
19
47
|
id: z__default.ZodString;
|
|
20
48
|
type: z__default.ZodEnum<{
|
|
21
|
-
dm: "dm";
|
|
22
49
|
group: "group";
|
|
50
|
+
dm: "dm";
|
|
23
51
|
}>;
|
|
24
52
|
phone: z__default.ZodString;
|
|
25
53
|
}, z__default.core.$strip>;
|
|
@@ -44,8 +72,8 @@ declare const imessage: Platform<PlatformDef<"iMessage", z.ZodUnion<readonly [z.
|
|
|
44
72
|
}, zod_v4_core.$strip>]>, z.ZodType<object, unknown, zod_v4_core.$ZodTypeInternals<object, unknown>> | undefined, z.ZodObject<{
|
|
45
73
|
id: z.ZodString;
|
|
46
74
|
type: z.ZodEnum<{
|
|
47
|
-
dm: "dm";
|
|
48
75
|
group: "group";
|
|
76
|
+
dm: "dm";
|
|
49
77
|
}>;
|
|
50
78
|
phone: z.ZodString;
|
|
51
79
|
}, zod_v4_core.$strip>, z.ZodObject<{
|
|
@@ -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 };
|