react-native-email-imap-smtp 0.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/EmailImapSmtp.podspec +29 -0
- package/LICENSE +20 -0
- package/README.md +121 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +117 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/cpp/cpp-adapter.cpp +11 -0
- package/android/src/main/java/com/margelo/nitro/emailimapsmtp/EmailImapSmtp.kt +1533 -0
- package/android/src/main/java/com/margelo/nitro/emailimapsmtp/EmailImapSmtpPackage.kt +22 -0
- package/ios/EmailImapSmtp.swift +5 -0
- package/lib/module/EmailImapSmtp.nitro.js +4 -0
- package/lib/module/EmailImapSmtp.nitro.js.map +1 -0
- package/lib/module/NativeEmailImapSmtp.js +14 -0
- package/lib/module/NativeEmailImapSmtp.js.map +1 -0
- package/lib/module/index.js +64 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native.js +227 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/web.js +107 -0
- package/lib/module/web.js.map +1 -0
- package/lib/module/windows.js +156 -0
- package/lib/module/windows.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/EmailImapSmtp.nitro.d.ts +268 -0
- package/lib/typescript/src/EmailImapSmtp.nitro.d.ts.map +1 -0
- package/lib/typescript/src/NativeEmailImapSmtp.d.ts +36 -0
- package/lib/typescript/src/NativeEmailImapSmtp.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +33 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/native.d.ts +32 -0
- package/lib/typescript/src/native.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +261 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/web.d.ts +32 -0
- package/lib/typescript/src/web.d.ts.map +1 -0
- package/lib/typescript/src/windows.d.ts +32 -0
- package/lib/typescript/src/windows.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JAppendResult.hpp +65 -0
- package/nitrogen/generated/android/c++/JAttachmentInfo.hpp +96 -0
- package/nitrogen/generated/android/c++/JConnectionConfig.hpp +94 -0
- package/nitrogen/generated/android/c++/JConnectionResult.hpp +73 -0
- package/nitrogen/generated/android/c++/JDeleteResult.hpp +87 -0
- package/nitrogen/generated/android/c++/JEmailAddress.hpp +61 -0
- package/nitrogen/generated/android/c++/JEmailBody.hpp +84 -0
- package/nitrogen/generated/android/c++/JEmailMessage.hpp +273 -0
- package/nitrogen/generated/android/c++/JFetchEmailsOptions.hpp +110 -0
- package/nitrogen/generated/android/c++/JFolderInfo.hpp +126 -0
- package/nitrogen/generated/android/c++/JFunc_void_IdleNotification.hpp +79 -0
- package/nitrogen/generated/android/c++/JHybridEmailImapSmtpSpec.cpp +697 -0
- package/nitrogen/generated/android/c++/JHybridEmailImapSmtpSpec.hpp +92 -0
- package/nitrogen/generated/android/c++/JIdleNotification.hpp +78 -0
- package/nitrogen/generated/android/c++/JImapServerInfo.hpp +84 -0
- package/nitrogen/generated/android/c++/JMailboxInfo.hpp +134 -0
- package/nitrogen/generated/android/c++/JMailboxListItem.hpp +92 -0
- package/nitrogen/generated/android/c++/JQuotaInfo.hpp +78 -0
- package/nitrogen/generated/android/c++/JSearchCriteria.hpp +187 -0
- package/nitrogen/generated/android/c++/JSearchHeader.hpp +61 -0
- package/nitrogen/generated/android/c++/JSendMailOptions.hpp +229 -0
- package/nitrogen/generated/android/c++/JSendMailResult.hpp +88 -0
- package/nitrogen/generated/android/c++/JSmtpAttachment.hpp +80 -0
- package/nitrogen/generated/android/c++/JSmtpConnectionConfig.hpp +98 -0
- package/nitrogen/generated/android/c++/JSmtpServerInfo.hpp +102 -0
- package/nitrogen/generated/android/c++/JVariant_ImapServerInfo_SmtpServerInfo.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_ImapServerInfo_SmtpServerInfo.hpp +73 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AttachmentInfo.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_AttachmentInfo.hpp +75 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_EmailMessage.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_EmailMessage.hpp +83 -0
- package/nitrogen/generated/android/emailimapsmtp+autolinking.cmake +84 -0
- package/nitrogen/generated/android/emailimapsmtp+autolinking.gradle +27 -0
- package/nitrogen/generated/android/emailimapsmtpOnLoad.cpp +56 -0
- package/nitrogen/generated/android/emailimapsmtpOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/AppendResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/AttachmentInfo.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/ConnectionConfig.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/ConnectionResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/DeleteResult.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/EmailAddress.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/EmailBody.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/EmailMessage.kt +156 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/FetchEmailsOptions.kt +116 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/FolderInfo.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Func_void_IdleNotification.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/HybridEmailImapSmtpSpec.kt +178 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/IdleNotification.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/ImapServerInfo.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/MailboxInfo.kt +101 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/MailboxListItem.kt +71 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/QuotaInfo.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SearchCriteria.kt +196 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SearchHeader.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SendMailOptions.kt +126 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SendMailResult.kt +86 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SmtpAttachment.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SmtpConnectionConfig.kt +101 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/SmtpServerInfo.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Variant_ImapServerInfo_SmtpServerInfo.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Variant_NullType_AttachmentInfo.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/Variant_NullType_EmailMessage.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/emailimapsmtp/emailimapsmtpOnLoad.kt +35 -0
- package/nitrogen/generated/ios/EmailImapSmtp+autolinking.rb +62 -0
- package/nitrogen/generated/ios/EmailImapSmtp-Swift-Cxx-Bridge.cpp +161 -0
- package/nitrogen/generated/ios/EmailImapSmtp-Swift-Cxx-Bridge.hpp +1132 -0
- package/nitrogen/generated/ios/EmailImapSmtp-Swift-Cxx-Umbrella.hpp +118 -0
- package/nitrogen/generated/ios/EmailImapSmtpAutolinking.mm +33 -0
- package/nitrogen/generated/ios/EmailImapSmtpAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridEmailImapSmtpSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridEmailImapSmtpSpecSwift.hpp +390 -0
- package/nitrogen/generated/ios/swift/AppendResult.swift +39 -0
- package/nitrogen/generated/ios/swift/AttachmentInfo.swift +113 -0
- package/nitrogen/generated/ios/swift/ConnectionConfig.swift +87 -0
- package/nitrogen/generated/ios/swift/ConnectionResult.swift +84 -0
- package/nitrogen/generated/ios/swift/DeleteResult.swift +64 -0
- package/nitrogen/generated/ios/swift/EmailAddress.swift +34 -0
- package/nitrogen/generated/ios/swift/EmailBody.swift +45 -0
- package/nitrogen/generated/ios/swift/EmailMessage.swift +184 -0
- package/nitrogen/generated/ios/swift/FetchEmailsOptions.swift +198 -0
- package/nitrogen/generated/ios/swift/FolderInfo.swift +81 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_AppendResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_ConnectionResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_DeleteResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_IdleNotification.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_MailboxInfo.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_QuotaInfo.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_SendMailResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__AttachmentInfo_.swift +58 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__EmailMessage_.swift +58 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_AttachmentInfo_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_EmailMessage_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_FolderInfo_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_MailboxListItem_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridEmailImapSmtpSpec.swift +84 -0
- package/nitrogen/generated/ios/swift/HybridEmailImapSmtpSpec_cxx.swift +759 -0
- package/nitrogen/generated/ios/swift/IdleNotification.swift +93 -0
- package/nitrogen/generated/ios/swift/ImapServerInfo.swift +45 -0
- package/nitrogen/generated/ios/swift/MailboxInfo.swift +91 -0
- package/nitrogen/generated/ios/swift/MailboxListItem.swift +55 -0
- package/nitrogen/generated/ios/swift/QuotaInfo.swift +80 -0
- package/nitrogen/generated/ios/swift/SearchCriteria.swift +485 -0
- package/nitrogen/generated/ios/swift/SearchHeader.swift +34 -0
- package/nitrogen/generated/ios/swift/SendMailOptions.swift +310 -0
- package/nitrogen/generated/ios/swift/SendMailResult.swift +155 -0
- package/nitrogen/generated/ios/swift/SmtpAttachment.swift +80 -0
- package/nitrogen/generated/ios/swift/SmtpConnectionConfig.swift +105 -0
- package/nitrogen/generated/ios/swift/SmtpServerInfo.swift +51 -0
- package/nitrogen/generated/ios/swift/Variant_ImapServerInfo_SmtpServerInfo.swift +30 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_AttachmentInfo.swift +30 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_EmailMessage.swift +30 -0
- package/nitrogen/generated/shared/c++/AppendResult.hpp +91 -0
- package/nitrogen/generated/shared/c++/AttachmentInfo.hpp +121 -0
- package/nitrogen/generated/shared/c++/ConnectionConfig.hpp +120 -0
- package/nitrogen/generated/shared/c++/ConnectionResult.hpp +98 -0
- package/nitrogen/generated/shared/c++/DeleteResult.hpp +93 -0
- package/nitrogen/generated/shared/c++/EmailAddress.hpp +87 -0
- package/nitrogen/generated/shared/c++/EmailBody.hpp +92 -0
- package/nitrogen/generated/shared/c++/EmailMessage.hpp +177 -0
- package/nitrogen/generated/shared/c++/FetchEmailsOptions.hpp +136 -0
- package/nitrogen/generated/shared/c++/FolderInfo.hpp +116 -0
- package/nitrogen/generated/shared/c++/HybridEmailImapSmtpSpec.cpp +50 -0
- package/nitrogen/generated/shared/c++/HybridEmailImapSmtpSpec.hpp +145 -0
- package/nitrogen/generated/shared/c++/IdleNotification.hpp +104 -0
- package/nitrogen/generated/shared/c++/ImapServerInfo.hpp +92 -0
- package/nitrogen/generated/shared/c++/MailboxInfo.hpp +124 -0
- package/nitrogen/generated/shared/c++/MailboxListItem.hpp +100 -0
- package/nitrogen/generated/shared/c++/QuotaInfo.hpp +104 -0
- package/nitrogen/generated/shared/c++/SearchCriteria.hpp +203 -0
- package/nitrogen/generated/shared/c++/SearchHeader.hpp +87 -0
- package/nitrogen/generated/shared/c++/SendMailOptions.hpp +151 -0
- package/nitrogen/generated/shared/c++/SendMailResult.hpp +113 -0
- package/nitrogen/generated/shared/c++/SmtpAttachment.hpp +105 -0
- package/nitrogen/generated/shared/c++/SmtpConnectionConfig.hpp +124 -0
- package/nitrogen/generated/shared/c++/SmtpServerInfo.hpp +92 -0
- package/package.json +196 -0
- package/react-native.config.js +27 -0
- package/src/EmailImapSmtp.nitro.ts +333 -0
- package/src/NativeEmailImapSmtp.ts +100 -0
- package/src/index.tsx +166 -0
- package/src/native.ts +305 -0
- package/src/types.ts +328 -0
- package/src/web.ts +196 -0
- package/src/windows.ts +304 -0
- package/windows/EmailImapSmtp.cpp +735 -0
- package/windows/EmailImapSmtp.h +137 -0
- package/windows/EmailImapSmtpModule.cpp +10 -0
- package/windows/EmailImapSmtpModule.h +139 -0
- package/windows/EmailImapSmtpPackage.cpp +15 -0
- package/windows/EmailImapSmtpPackage.h +13 -0
- package/windows/ImapProtocol.cpp +1382 -0
- package/windows/ImapProtocol.h +97 -0
- package/windows/ProtocolDefs.h +300 -0
- package/windows/SmtpProtocol.cpp +334 -0
- package/windows/SmtpProtocol.h +36 -0
- package/windows/TlsSocket.cpp +818 -0
- package/windows/TlsSocket.h +87 -0
package/src/web.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Web fallback implementation
|
|
3
|
+
// 浏览器环境不支持原生 IMAP/SMTP,提供占位实现
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
IMAPConfig,
|
|
8
|
+
SMTPConfig,
|
|
9
|
+
IMAPConnectionResult,
|
|
10
|
+
SMTPConnectionResult,
|
|
11
|
+
Mailbox,
|
|
12
|
+
MailboxStatus,
|
|
13
|
+
Folder,
|
|
14
|
+
Email,
|
|
15
|
+
Attachment,
|
|
16
|
+
FetchEmailsOptions,
|
|
17
|
+
SearchCriteria,
|
|
18
|
+
BatchResult,
|
|
19
|
+
IMAPNotification,
|
|
20
|
+
QuotaInfo,
|
|
21
|
+
AppendResult,
|
|
22
|
+
SendMailOptions,
|
|
23
|
+
SendMailResult,
|
|
24
|
+
} from './types';
|
|
25
|
+
|
|
26
|
+
function notSupported(): never {
|
|
27
|
+
throw new Error(
|
|
28
|
+
'IMAP/SMTP operations are not supported in the browser/web environment. ' +
|
|
29
|
+
'Please use react-native-email-imap-smtp on a native platform (iOS, Android, Windows).'
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ─── IMAP ────────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
export async function imapConnect(
|
|
36
|
+
_config: IMAPConfig
|
|
37
|
+
): Promise<IMAPConnectionResult> {
|
|
38
|
+
return notSupported();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function imapDisconnect(): Promise<void> {
|
|
42
|
+
return notSupported();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function imapListMailboxes(): Promise<Mailbox[]> {
|
|
46
|
+
return notSupported();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function imapSelectMailbox(
|
|
50
|
+
_mailbox: string,
|
|
51
|
+
_readOnly?: boolean
|
|
52
|
+
): Promise<MailboxStatus> {
|
|
53
|
+
return notSupported();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function imapRefreshMailbox(): Promise<MailboxStatus> {
|
|
57
|
+
return notSupported();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function imapFetchFolders(): Promise<Folder[]> {
|
|
61
|
+
return notSupported();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function imapCreateFolder(_folderName: string): Promise<void> {
|
|
65
|
+
return notSupported();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function imapDeleteFolder(_folderName: string): Promise<void> {
|
|
69
|
+
return notSupported();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function imapRenameFolder(
|
|
73
|
+
_oldName: string,
|
|
74
|
+
_newName: string
|
|
75
|
+
): Promise<void> {
|
|
76
|
+
return notSupported();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function imapSubscribeFolder(_folderName: string): Promise<void> {
|
|
80
|
+
return notSupported();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function imapUnsubscribeFolder(
|
|
84
|
+
_folderName: string
|
|
85
|
+
): Promise<void> {
|
|
86
|
+
return notSupported();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export async function imapFetchEmails(
|
|
90
|
+
_options: FetchEmailsOptions
|
|
91
|
+
): Promise<Email[]> {
|
|
92
|
+
return notSupported();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export async function imapFetchEmailByUID(_uid: number): Promise<Email | null> {
|
|
96
|
+
return notSupported();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export async function imapSearchEmails(
|
|
100
|
+
_criteria: SearchCriteria
|
|
101
|
+
): Promise<Email[]> {
|
|
102
|
+
return notSupported();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function imapMarkAsRead(
|
|
106
|
+
_uids: number[],
|
|
107
|
+
_silent?: boolean
|
|
108
|
+
): Promise<void> {
|
|
109
|
+
return notSupported();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function imapMarkAsFlagged(
|
|
113
|
+
_uids: number[],
|
|
114
|
+
_flagged: boolean
|
|
115
|
+
): Promise<void> {
|
|
116
|
+
return notSupported();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export async function imapMoveEmails(
|
|
120
|
+
_uids: number[],
|
|
121
|
+
_destinationMailbox: string
|
|
122
|
+
): Promise<void> {
|
|
123
|
+
return notSupported();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export async function imapCopyEmails(
|
|
127
|
+
_uids: number[],
|
|
128
|
+
_destinationMailbox: string
|
|
129
|
+
): Promise<void> {
|
|
130
|
+
return notSupported();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export async function imapDeleteEmails(_uids: number[]): Promise<BatchResult> {
|
|
134
|
+
return notSupported();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export async function imapExpunge(): Promise<void> {
|
|
138
|
+
return notSupported();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export async function imapFetchAttachments(
|
|
142
|
+
_uid: number,
|
|
143
|
+
_partId: string
|
|
144
|
+
): Promise<Attachment | null> {
|
|
145
|
+
return notSupported();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function imapFetchAllAttachments(
|
|
149
|
+
_uid: number
|
|
150
|
+
): Promise<Attachment[]> {
|
|
151
|
+
return notSupported();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export async function imapIdle(
|
|
155
|
+
_callback: (notification: IMAPNotification) => void
|
|
156
|
+
): Promise<void> {
|
|
157
|
+
return notSupported();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export async function imapStopIdle(): Promise<void> {
|
|
161
|
+
return notSupported();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export async function imapGetQuota(_root?: string): Promise<QuotaInfo> {
|
|
165
|
+
return notSupported();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export async function imapAppendMessage(
|
|
169
|
+
_mailbox: string,
|
|
170
|
+
_rawMimeData: ArrayBuffer,
|
|
171
|
+
_flags?: string[]
|
|
172
|
+
): Promise<AppendResult> {
|
|
173
|
+
return notSupported();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ─── SMTP ────────────────────────────────────────────────────
|
|
177
|
+
|
|
178
|
+
export async function smtpConnect(
|
|
179
|
+
_config: SMTPConfig
|
|
180
|
+
): Promise<SMTPConnectionResult> {
|
|
181
|
+
return notSupported();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export async function smtpDisconnect(): Promise<void> {
|
|
185
|
+
return notSupported();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export async function smtpSendMail(
|
|
189
|
+
_options: SendMailOptions
|
|
190
|
+
): Promise<SendMailResult> {
|
|
191
|
+
return notSupported();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export async function smtpVerifyConnection(): Promise<boolean> {
|
|
195
|
+
return notSupported();
|
|
196
|
+
}
|
package/src/windows.ts
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// windows.ts — Windows 平台实现
|
|
3
|
+
// 通过 TurboModule 调用 C++ 原生代码(替代 Nitro)
|
|
4
|
+
// ============================================================
|
|
5
|
+
//
|
|
6
|
+
// TurboModule 只支持基础类型(string, number, boolean, 数组)
|
|
7
|
+
// 复杂对象通过 JSON.stringify/parse 序列化
|
|
8
|
+
// ============================================================
|
|
9
|
+
|
|
10
|
+
import NativeEmailImapSmtp from './NativeEmailImapSmtp';
|
|
11
|
+
import type {
|
|
12
|
+
IMAPConfig,
|
|
13
|
+
SMTPConfig,
|
|
14
|
+
IMAPConnectionResult,
|
|
15
|
+
SMTPConnectionResult,
|
|
16
|
+
Mailbox,
|
|
17
|
+
MailboxStatus,
|
|
18
|
+
Folder,
|
|
19
|
+
Email,
|
|
20
|
+
Attachment,
|
|
21
|
+
FetchEmailsOptions,
|
|
22
|
+
SearchCriteria,
|
|
23
|
+
BatchResult,
|
|
24
|
+
QuotaInfo,
|
|
25
|
+
AppendResult,
|
|
26
|
+
SendMailOptions,
|
|
27
|
+
SendMailResult,
|
|
28
|
+
} from './types';
|
|
29
|
+
|
|
30
|
+
// ─── Session 管理 ──────────────────────────────────────────
|
|
31
|
+
// IMAP 连接是状态性的,需要维护 sessionId
|
|
32
|
+
let imapSessionId: string | null = null;
|
|
33
|
+
let smtpSessionId: string | null = null;
|
|
34
|
+
|
|
35
|
+
function getImapSessionId(): string {
|
|
36
|
+
if (!imapSessionId)
|
|
37
|
+
throw new Error('IMAP not connected. Call imapConnect first.');
|
|
38
|
+
return imapSessionId;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ─── IMAP ────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
export async function imapConnect(
|
|
44
|
+
config: IMAPConfig
|
|
45
|
+
): Promise<IMAPConnectionResult> {
|
|
46
|
+
const resultJson = await NativeEmailImapSmtp.imapConnect(
|
|
47
|
+
JSON.stringify(config)
|
|
48
|
+
);
|
|
49
|
+
const result: IMAPConnectionResult & { sessionId?: string } =
|
|
50
|
+
JSON.parse(resultJson);
|
|
51
|
+
if (result.success && result.sessionId) {
|
|
52
|
+
imapSessionId = result.sessionId;
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function imapDisconnect(): Promise<void> {
|
|
58
|
+
const sid = imapSessionId;
|
|
59
|
+
imapSessionId = null;
|
|
60
|
+
if (sid) await NativeEmailImapSmtp.imapDisconnect(sid);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function imapListMailboxes(): Promise<Mailbox[]> {
|
|
64
|
+
const json = await NativeEmailImapSmtp.imapListMailboxes(getImapSessionId());
|
|
65
|
+
return JSON.parse(json);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function imapSelectMailbox(
|
|
69
|
+
mailbox: string,
|
|
70
|
+
readOnly?: boolean
|
|
71
|
+
): Promise<MailboxStatus> {
|
|
72
|
+
const json = await NativeEmailImapSmtp.imapSelectMailbox(
|
|
73
|
+
getImapSessionId(),
|
|
74
|
+
mailbox,
|
|
75
|
+
readOnly ?? false
|
|
76
|
+
);
|
|
77
|
+
return JSON.parse(json);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function imapRefreshMailbox(): Promise<MailboxStatus> {
|
|
81
|
+
const json = await NativeEmailImapSmtp.imapRefreshMailbox(getImapSessionId());
|
|
82
|
+
return JSON.parse(json);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function imapFetchFolders(): Promise<Folder[]> {
|
|
86
|
+
const json = await NativeEmailImapSmtp.imapFetchFolders(getImapSessionId());
|
|
87
|
+
return JSON.parse(json);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export async function imapCreateFolder(folderName: string): Promise<void> {
|
|
91
|
+
await NativeEmailImapSmtp.imapCreateFolder(getImapSessionId(), folderName);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function imapDeleteFolder(folderName: string): Promise<void> {
|
|
95
|
+
await NativeEmailImapSmtp.imapDeleteFolder(getImapSessionId(), folderName);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function imapRenameFolder(
|
|
99
|
+
oldName: string,
|
|
100
|
+
newName: string
|
|
101
|
+
): Promise<void> {
|
|
102
|
+
await NativeEmailImapSmtp.imapRenameFolder(
|
|
103
|
+
getImapSessionId(),
|
|
104
|
+
oldName,
|
|
105
|
+
newName
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export async function imapSubscribeFolder(folderName: string): Promise<void> {
|
|
110
|
+
await NativeEmailImapSmtp.imapSubscribeFolder(getImapSessionId(), folderName);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export async function imapUnsubscribeFolder(folderName: string): Promise<void> {
|
|
114
|
+
await NativeEmailImapSmtp.imapUnsubscribeFolder(
|
|
115
|
+
getImapSessionId(),
|
|
116
|
+
folderName
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function imapFetchEmails(
|
|
121
|
+
options: FetchEmailsOptions
|
|
122
|
+
): Promise<Email[]> {
|
|
123
|
+
const json = await NativeEmailImapSmtp.imapFetchEmails(
|
|
124
|
+
getImapSessionId(),
|
|
125
|
+
JSON.stringify(options)
|
|
126
|
+
);
|
|
127
|
+
return JSON.parse(json);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export async function imapFetchEmailByUID(uid: number): Promise<Email | null> {
|
|
131
|
+
const json = await NativeEmailImapSmtp.imapFetchEmailByUID(
|
|
132
|
+
getImapSessionId(),
|
|
133
|
+
uid
|
|
134
|
+
);
|
|
135
|
+
return JSON.parse(json);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export async function imapSearchEmails(
|
|
139
|
+
criteria: SearchCriteria
|
|
140
|
+
): Promise<Email[]> {
|
|
141
|
+
const json = await NativeEmailImapSmtp.imapSearchEmails(
|
|
142
|
+
getImapSessionId(),
|
|
143
|
+
JSON.stringify(criteria)
|
|
144
|
+
);
|
|
145
|
+
return JSON.parse(json);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function imapMarkAsRead(
|
|
149
|
+
uids: number[],
|
|
150
|
+
silent: boolean
|
|
151
|
+
): Promise<void> {
|
|
152
|
+
await NativeEmailImapSmtp.imapMarkAsRead(
|
|
153
|
+
getImapSessionId(),
|
|
154
|
+
JSON.stringify(uids),
|
|
155
|
+
silent
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export async function imapMarkAsFlagged(
|
|
160
|
+
uids: number[],
|
|
161
|
+
flagged: boolean
|
|
162
|
+
): Promise<void> {
|
|
163
|
+
await NativeEmailImapSmtp.imapMarkAsFlagged(
|
|
164
|
+
getImapSessionId(),
|
|
165
|
+
JSON.stringify(uids),
|
|
166
|
+
flagged
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export async function imapMoveEmails(
|
|
171
|
+
uids: number[],
|
|
172
|
+
destinationMailbox: string
|
|
173
|
+
): Promise<void> {
|
|
174
|
+
await NativeEmailImapSmtp.imapMoveEmails(
|
|
175
|
+
getImapSessionId(),
|
|
176
|
+
JSON.stringify(uids),
|
|
177
|
+
destinationMailbox
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export async function imapCopyEmails(
|
|
182
|
+
uids: number[],
|
|
183
|
+
destinationMailbox: string
|
|
184
|
+
): Promise<void> {
|
|
185
|
+
await NativeEmailImapSmtp.imapCopyEmails(
|
|
186
|
+
getImapSessionId(),
|
|
187
|
+
JSON.stringify(uids),
|
|
188
|
+
destinationMailbox
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export async function imapDeleteEmails(uids: number[]): Promise<BatchResult> {
|
|
193
|
+
const json = await NativeEmailImapSmtp.imapDeleteEmails(
|
|
194
|
+
getImapSessionId(),
|
|
195
|
+
JSON.stringify(uids)
|
|
196
|
+
);
|
|
197
|
+
return JSON.parse(json);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export async function imapExpunge(): Promise<void> {
|
|
201
|
+
await NativeEmailImapSmtp.imapExpunge(getImapSessionId());
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export async function imapFetchAttachments(
|
|
205
|
+
uid: number,
|
|
206
|
+
partId: string
|
|
207
|
+
): Promise<Attachment | null> {
|
|
208
|
+
const json = await NativeEmailImapSmtp.imapFetchAttachment(
|
|
209
|
+
getImapSessionId(),
|
|
210
|
+
uid,
|
|
211
|
+
partId
|
|
212
|
+
);
|
|
213
|
+
return JSON.parse(json);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export async function imapFetchAllAttachments(
|
|
217
|
+
uid: number
|
|
218
|
+
): Promise<Attachment[]> {
|
|
219
|
+
const json = await NativeEmailImapSmtp.imapFetchAllAttachments(
|
|
220
|
+
getImapSessionId(),
|
|
221
|
+
uid
|
|
222
|
+
);
|
|
223
|
+
return JSON.parse(json);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export async function imapIdle(): Promise<void> {
|
|
227
|
+
await NativeEmailImapSmtp.imapIdle(getImapSessionId());
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export async function imapStopIdle(): Promise<void> {
|
|
231
|
+
await NativeEmailImapSmtp.imapStopIdle(getImapSessionId());
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export async function imapGetQuota(root?: string): Promise<QuotaInfo> {
|
|
235
|
+
const json = await NativeEmailImapSmtp.imapGetQuota(
|
|
236
|
+
getImapSessionId(),
|
|
237
|
+
root ?? null
|
|
238
|
+
);
|
|
239
|
+
return JSON.parse(json);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export async function imapAppendMessage(
|
|
243
|
+
mailbox: string,
|
|
244
|
+
rawMimeData: ArrayBuffer,
|
|
245
|
+
flags?: string[]
|
|
246
|
+
): Promise<AppendResult> {
|
|
247
|
+
// ArrayBuffer → Base64 string
|
|
248
|
+
const bytes = new Uint8Array(rawMimeData);
|
|
249
|
+
let binary = '';
|
|
250
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
251
|
+
const byte = bytes[i];
|
|
252
|
+
if (byte !== undefined) binary += String.fromCharCode(byte);
|
|
253
|
+
}
|
|
254
|
+
const base64 = btoa(binary);
|
|
255
|
+
const json = await NativeEmailImapSmtp.imapAppendMessage(
|
|
256
|
+
getImapSessionId(),
|
|
257
|
+
mailbox,
|
|
258
|
+
base64,
|
|
259
|
+
flags ? JSON.stringify(flags) : null
|
|
260
|
+
);
|
|
261
|
+
return JSON.parse(json);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// ═══ SMTP ═══════════════════════════════════════════════════
|
|
265
|
+
|
|
266
|
+
export async function smtpConnect(
|
|
267
|
+
config: SMTPConfig
|
|
268
|
+
): Promise<SMTPConnectionResult> {
|
|
269
|
+
const resultJson = await NativeEmailImapSmtp.smtpConnect(
|
|
270
|
+
JSON.stringify(config)
|
|
271
|
+
);
|
|
272
|
+
const result: SMTPConnectionResult & { sessionId?: string } =
|
|
273
|
+
JSON.parse(resultJson);
|
|
274
|
+
if (result.success && result.sessionId) {
|
|
275
|
+
smtpSessionId = result.sessionId;
|
|
276
|
+
}
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export async function smtpDisconnect(): Promise<void> {
|
|
281
|
+
const sid = smtpSessionId;
|
|
282
|
+
smtpSessionId = null;
|
|
283
|
+
if (sid) await NativeEmailImapSmtp.smtpDisconnect(sid);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export async function smtpSendMail(
|
|
287
|
+
options: SendMailOptions
|
|
288
|
+
): Promise<SendMailResult> {
|
|
289
|
+
const json = await NativeEmailImapSmtp.smtpSendMail(
|
|
290
|
+
getSmtpSessionId(),
|
|
291
|
+
JSON.stringify(options)
|
|
292
|
+
);
|
|
293
|
+
return JSON.parse(json);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export async function smtpVerifyConnection(): Promise<boolean> {
|
|
297
|
+
return NativeEmailImapSmtp.smtpVerifyConnection(getSmtpSessionId());
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function getSmtpSessionId(): string {
|
|
301
|
+
if (!smtpSessionId)
|
|
302
|
+
throw new Error('SMTP not connected. Call smtpConnect first.');
|
|
303
|
+
return smtpSessionId;
|
|
304
|
+
}
|