@spectrum-ts/imessage-local 12.0.0 → 12.1.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.
- package/README.md +2 -2
- package/dist/index.d.ts +6 -6
- package/dist/index.js +16 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,11 +7,11 @@ bun add spectrum-ts @spectrum-ts/imessage-local
|
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
-
import {
|
|
10
|
+
import { localIMessage } from "@spectrum-ts/imessage-local";
|
|
11
11
|
import { Spectrum } from "spectrum-ts";
|
|
12
12
|
|
|
13
13
|
const spectrum = Spectrum({
|
|
14
|
-
providers: [
|
|
14
|
+
providers: [localIMessage.config()],
|
|
15
15
|
});
|
|
16
16
|
```
|
|
17
17
|
|
package/dist/index.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ declare function background(input: string | Buffer | URL, options?: {
|
|
|
75
75
|
* enters the universal `Content` discriminated union. The framework recognizes
|
|
76
76
|
* it via two generic content-level contracts:
|
|
77
77
|
*
|
|
78
|
-
* 1. `__platform: "
|
|
78
|
+
* 1. `__platform: "imessage"` — `findUnsupportedPlatformContent` in
|
|
79
79
|
* `platform/build.ts` reads this tag and warns-and-skips when a different
|
|
80
80
|
* platform receives it.
|
|
81
81
|
* 2. `__fireAndForget: true` — `dispatchSend`'s fire-and-forget check treats
|
|
@@ -87,7 +87,7 @@ declare function background(input: string | Buffer | URL, options?: {
|
|
|
87
87
|
*/
|
|
88
88
|
declare const contactCardSchema: z.ZodObject<{
|
|
89
89
|
type: z.ZodLiteral<"contactCard">;
|
|
90
|
-
__platform: z.ZodLiteral<"
|
|
90
|
+
__platform: z.ZodLiteral<"imessage">;
|
|
91
91
|
__fireAndForget: z.ZodLiteral<true>;
|
|
92
92
|
}, z.core.$strip>;
|
|
93
93
|
type ContactCard = z.infer<typeof contactCardSchema>;
|
|
@@ -127,7 +127,7 @@ declare const layoutSchema: z.ZodObject<{
|
|
|
127
127
|
* provider — never enters the universal `Content` discriminated union. The
|
|
128
128
|
* framework recognizes it via the generic content-level platform contract:
|
|
129
129
|
*
|
|
130
|
-
* - `__platform: "
|
|
130
|
+
* - `__platform: "imessage"` — `findUnsupportedPlatformContent` reads this tag
|
|
131
131
|
* and warns-and-skips when a different platform receives it.
|
|
132
132
|
*
|
|
133
133
|
* Unlike `background` / `read`, this content is **not** `__fireAndForget`: it
|
|
@@ -137,7 +137,7 @@ declare const layoutSchema: z.ZodObject<{
|
|
|
137
137
|
*/
|
|
138
138
|
declare const customizedMiniAppSchema: z.ZodObject<{
|
|
139
139
|
type: z.ZodLiteral<"customized-mini-app">;
|
|
140
|
-
__platform: z.ZodLiteral<"
|
|
140
|
+
__platform: z.ZodLiteral<"imessage">;
|
|
141
141
|
appName: z.ZodString;
|
|
142
142
|
appStoreId: z.ZodOptional<z.ZodNumber>;
|
|
143
143
|
extensionBundleId: z.ZodString;
|
|
@@ -197,7 +197,7 @@ type IMessageMessageEffect = (typeof messageEffects)[keyof typeof messageEffects
|
|
|
197
197
|
declare function effect(input: ContentInput, messageEffect: IMessageMessageEffect): ContentBuilder;
|
|
198
198
|
//#endregion
|
|
199
199
|
//#region src/index.d.ts
|
|
200
|
-
declare const
|
|
200
|
+
declare const localIMessage: import("@spectrum-ts/core").Platform<import("@spectrum-ts/core").PlatformDef<"local_imessage", import("zod").ZodObject<{}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
201
201
|
address: import("zod").ZodOptional<import("zod").ZodString>;
|
|
202
202
|
country: import("zod").ZodOptional<import("zod").ZodString>;
|
|
203
203
|
service: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
@@ -266,4 +266,4 @@ declare const imessage: import("@spectrum-ts/core").Platform<import("@spectrum-t
|
|
|
266
266
|
};
|
|
267
267
|
}>;
|
|
268
268
|
//#endregion
|
|
269
|
-
export { type BackgroundInput, type ContactCard, type CustomizedMiniApp, type CustomizedMiniAppInput, type CustomizedMiniAppLayout, type IMessageMessageEffect, background, customizedMiniApp, effect,
|
|
269
|
+
export { type BackgroundInput, type ContactCard, type CustomizedMiniApp, type CustomizedMiniAppInput, type CustomizedMiniAppLayout, type IMessageMessageEffect, background, customizedMiniApp, effect, localIMessage, nativeContactCard, read };
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { basename, join } from "node:path";
|
|
|
14
14
|
* provider — never enters the universal `Content` discriminated union. The
|
|
15
15
|
* framework recognizes it via two generic content-level contracts:
|
|
16
16
|
*
|
|
17
|
-
* 1. `__platform: "
|
|
17
|
+
* 1. `__platform: "imessage"` — `findUnsupportedPlatformContent` in
|
|
18
18
|
* `platform/build.ts` reads this tag and warns-and-skips when a different
|
|
19
19
|
* platform receives it.
|
|
20
20
|
* 2. `__fireAndForget: true` — `dispatchSend`'s fire-and-forget check
|
|
@@ -26,7 +26,7 @@ import { basename, join } from "node:path";
|
|
|
26
26
|
*/
|
|
27
27
|
const backgroundSchema = z.object({
|
|
28
28
|
type: z.literal("background"),
|
|
29
|
-
__platform: z.literal("
|
|
29
|
+
__platform: z.literal("imessage"),
|
|
30
30
|
__fireAndForget: z.literal(true),
|
|
31
31
|
action: photoActionSchema
|
|
32
32
|
});
|
|
@@ -35,7 +35,7 @@ function background(input, options) {
|
|
|
35
35
|
const action = buildPhotoAction(input, options, "background");
|
|
36
36
|
return { build: async () => backgroundSchema.parse({
|
|
37
37
|
type: "background",
|
|
38
|
-
__platform: "
|
|
38
|
+
__platform: "imessage",
|
|
39
39
|
__fireAndForget: true,
|
|
40
40
|
action
|
|
41
41
|
}) };
|
|
@@ -56,7 +56,7 @@ function background(input, options) {
|
|
|
56
56
|
* enters the universal `Content` discriminated union. The framework recognizes
|
|
57
57
|
* it via two generic content-level contracts:
|
|
58
58
|
*
|
|
59
|
-
* 1. `__platform: "
|
|
59
|
+
* 1. `__platform: "imessage"` — `findUnsupportedPlatformContent` in
|
|
60
60
|
* `platform/build.ts` reads this tag and warns-and-skips when a different
|
|
61
61
|
* platform receives it.
|
|
62
62
|
* 2. `__fireAndForget: true` — `dispatchSend`'s fire-and-forget check treats
|
|
@@ -68,7 +68,7 @@ function background(input, options) {
|
|
|
68
68
|
*/
|
|
69
69
|
const contactCardSchema = z.object({
|
|
70
70
|
type: z.literal("contactCard"),
|
|
71
|
-
__platform: z.literal("
|
|
71
|
+
__platform: z.literal("imessage"),
|
|
72
72
|
__fireAndForget: z.literal(true)
|
|
73
73
|
});
|
|
74
74
|
const isContactCard = (v) => contactCardSchema.safeParse(v).success;
|
|
@@ -93,7 +93,7 @@ const isContactCard = (v) => contactCardSchema.safeParse(v).success;
|
|
|
93
93
|
function nativeContactCard() {
|
|
94
94
|
return { build: async () => contactCardSchema.parse({
|
|
95
95
|
type: "contactCard",
|
|
96
|
-
__platform: "
|
|
96
|
+
__platform: "imessage",
|
|
97
97
|
__fireAndForget: true
|
|
98
98
|
}) };
|
|
99
99
|
}
|
|
@@ -105,7 +105,7 @@ const layoutSchema = appLayoutSchema;
|
|
|
105
105
|
* provider — never enters the universal `Content` discriminated union. The
|
|
106
106
|
* framework recognizes it via the generic content-level platform contract:
|
|
107
107
|
*
|
|
108
|
-
* - `__platform: "
|
|
108
|
+
* - `__platform: "imessage"` — `findUnsupportedPlatformContent` reads this tag
|
|
109
109
|
* and warns-and-skips when a different platform receives it.
|
|
110
110
|
*
|
|
111
111
|
* Unlike `background` / `read`, this content is **not** `__fireAndForget`: it
|
|
@@ -115,7 +115,7 @@ const layoutSchema = appLayoutSchema;
|
|
|
115
115
|
*/
|
|
116
116
|
const customizedMiniAppSchema = z.object({
|
|
117
117
|
type: z.literal("customized-mini-app"),
|
|
118
|
-
__platform: z.literal("
|
|
118
|
+
__platform: z.literal("imessage"),
|
|
119
119
|
appName: z.string().nonempty(),
|
|
120
120
|
appStoreId: z.number().int().positive().optional(),
|
|
121
121
|
extensionBundleId: z.string().nonempty(),
|
|
@@ -127,7 +127,7 @@ const customizedMiniAppSchema = z.object({
|
|
|
127
127
|
const isCustomizedMiniApp = (v) => customizedMiniAppSchema.safeParse(v).success;
|
|
128
128
|
const asCustomizedMiniApp = (input) => customizedMiniAppSchema.parse({
|
|
129
129
|
type: "customized-mini-app",
|
|
130
|
-
__platform: "
|
|
130
|
+
__platform: "imessage",
|
|
131
131
|
...input
|
|
132
132
|
});
|
|
133
133
|
/**
|
|
@@ -412,8 +412,8 @@ const messages$1 = (client) => stream((emit, end) => {
|
|
|
412
412
|
});
|
|
413
413
|
//#endregion
|
|
414
414
|
//#region ../imessage/src/shared/errors.ts
|
|
415
|
-
const LOCAL_IMESSAGE_PLATFORM = "
|
|
416
|
-
const unsupportedLocalContent = (type, detail) => UnsupportedError.content(type, LOCAL_IMESSAGE_PLATFORM, detail);
|
|
415
|
+
const LOCAL_IMESSAGE_PLATFORM = "local_imessage";
|
|
416
|
+
const unsupportedLocalContent = (type, detail) => UnsupportedError.content(type, LOCAL_IMESSAGE_PLATFORM, detail ? `local mode: ${detail}` : "local mode");
|
|
417
417
|
//#endregion
|
|
418
418
|
//#region src/local/send.ts
|
|
419
419
|
const synthRecord = (spaceId, content) => ({
|
|
@@ -491,9 +491,10 @@ const messageSchema = z.object({
|
|
|
491
491
|
});
|
|
492
492
|
//#endregion
|
|
493
493
|
//#region src/index.ts
|
|
494
|
-
const
|
|
494
|
+
const PLATFORM_ID = "local_imessage";
|
|
495
495
|
const unsupportedAction = (action, detail) => {
|
|
496
|
-
|
|
496
|
+
const localDetail = detail ? `local mode: ${detail}` : "local mode";
|
|
497
|
+
throw UnsupportedError.action(action, PLATFORM_ID, localDetail);
|
|
497
498
|
};
|
|
498
499
|
const handleLocalOnlySend = async (client, spaceId, content) => {
|
|
499
500
|
if (content.type === "typing") return;
|
|
@@ -514,7 +515,7 @@ const handleLocalOnlySend = async (client, spaceId, content) => {
|
|
|
514
515
|
if (isCustomizedMiniApp(content)) return unsupportedAction("customized-mini-app", "mini app cards require remote iMessage");
|
|
515
516
|
return await send(client, spaceId, content);
|
|
516
517
|
};
|
|
517
|
-
const
|
|
518
|
+
const localIMessage = definePlatform(PLATFORM_ID, {
|
|
518
519
|
config: configSchema,
|
|
519
520
|
static: { effect: { message: messageEffects } },
|
|
520
521
|
lifecycle: {
|
|
@@ -565,4 +566,4 @@ const imessage = definePlatform("iMessage", {
|
|
|
565
566
|
}
|
|
566
567
|
});
|
|
567
568
|
//#endregion
|
|
568
|
-
export { background, customizedMiniApp, effect,
|
|
569
|
+
export { background, customizedMiniApp, effect, localIMessage, nativeContactCard, read };
|