apple-mail-mcp 2.20.21 → 2.20.22
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/build/index.js +31 -7
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -83781,19 +83781,32 @@ function mailboxPathFragment(mailboxVar, outputVar) {
|
|
|
83781
83781
|
set _pathParent to _pathNext
|
|
83782
83782
|
end repeat`;
|
|
83783
83783
|
}
|
|
83784
|
-
function mailboxLookupFragment(collExpr, path3, outputVar) {
|
|
83785
|
-
|
|
83786
|
-
|
|
83784
|
+
function mailboxLookupFragment(collExpr, path3, outputVar, hintIndex) {
|
|
83785
|
+
const safePath = escapeForAppleScript(path3);
|
|
83786
|
+
const hint = hintIndex === void 0 ? "" : `
|
|
83787
|
+
try
|
|
83788
|
+
set _mbc to item ${hintIndex} of (${collExpr})
|
|
83789
|
+
set _mbcPath to ""
|
|
83790
|
+
${mailboxPathFragment("_mbc", "_mbcPath")}
|
|
83791
|
+
ignoring case
|
|
83792
|
+
if _mbcPath is "${safePath}" then set ${outputVar} to _mbc
|
|
83793
|
+
end ignoring
|
|
83794
|
+
end try`;
|
|
83795
|
+
const walk = `
|
|
83787
83796
|
repeat with _mbc in (${collExpr})
|
|
83788
83797
|
set _mbcPath to ""
|
|
83789
83798
|
${mailboxPathFragment("_mbc", "_mbcPath")}
|
|
83790
83799
|
ignoring case
|
|
83791
|
-
if _mbcPath is "${
|
|
83800
|
+
if _mbcPath is "${safePath}" then
|
|
83792
83801
|
set ${outputVar} to _mbc
|
|
83793
83802
|
exit repeat
|
|
83794
83803
|
end if
|
|
83795
83804
|
end ignoring
|
|
83796
83805
|
end repeat`;
|
|
83806
|
+
return `
|
|
83807
|
+
set ${outputVar} to missing value${hint}${hintIndex === void 0 ? walk : `
|
|
83808
|
+
if ${outputVar} is missing value then${walk}
|
|
83809
|
+
end if`}`;
|
|
83797
83810
|
}
|
|
83798
83811
|
var MAILBOX_ALIASES = {
|
|
83799
83812
|
inbox: ["INBOX", "Inbox", "inbox"],
|
|
@@ -84789,6 +84802,17 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
|
|
|
84789
84802
|
resolveMailbox(mailbox, account) {
|
|
84790
84803
|
return resolveAppleMailboxPath(mailbox, this.getCachedMailboxNames(account));
|
|
84791
84804
|
}
|
|
84805
|
+
/**
|
|
84806
|
+
* The 1-based position of `path` in the account's cached mailbox list, which is
|
|
84807
|
+
* built by walking the account's `mailboxes` in order. `mailboxLookupFragment`
|
|
84808
|
+
* checks that one mailbox first instead of working out the path of every one.
|
|
84809
|
+
* Undefined when the path is not in the list; a stale position is harmless, the
|
|
84810
|
+
* fragment verifies the path and falls back to the full walk.
|
|
84811
|
+
*/
|
|
84812
|
+
mailboxIndexHint(account, path3) {
|
|
84813
|
+
const index = this.getCachedMailboxNames(account).indexOf(path3);
|
|
84814
|
+
return index >= 0 ? index + 1 : void 0;
|
|
84815
|
+
}
|
|
84792
84816
|
/**
|
|
84793
84817
|
* Non-throwing `resolveMailbox`, for callers comparing mailbox names AFTER
|
|
84794
84818
|
* a destructive op already ran (the forensics `sameMailbox` closures). An
|
|
@@ -84955,7 +84979,7 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
|
|
|
84955
84979
|
${dateSetup}set outputText to ""
|
|
84956
84980
|
set _timedOut to false
|
|
84957
84981
|
set _notSearched to ""
|
|
84958
|
-
${mailboxLookupFragment(mbIter, targetMailbox, "theMailbox")}
|
|
84982
|
+
${mailboxLookupFragment(mbIter, targetMailbox, "theMailbox", this.mailboxIndexHint(targetAccount, targetMailbox))}
|
|
84959
84983
|
set msgCount to 0
|
|
84960
84984
|
if theMailbox is missing value then
|
|
84961
84985
|
set _timedOut to true
|
|
@@ -85687,7 +85711,7 @@ ${indent}end try${this.sanitizeFragment("_uacct", indent)}${this.sanitizeFragmen
|
|
|
85687
85711
|
set outputText to ""
|
|
85688
85712
|
set _timedOut to false
|
|
85689
85713
|
set _notSearched to ""
|
|
85690
|
-
${mailboxLookupFragment(mbIter, targetMailbox, "theMailbox")}
|
|
85714
|
+
${mailboxLookupFragment(mbIter, targetMailbox, "theMailbox", this.mailboxIndexHint(targetAccount, targetMailbox))}
|
|
85691
85715
|
set msgCount to 0
|
|
85692
85716
|
set skipped to 0
|
|
85693
85717
|
if theMailbox is missing value then
|
|
@@ -87183,7 +87207,7 @@ ${this.errorEmit(" ")}
|
|
|
87183
87207
|
const targetAccount = this.resolveAccount(account);
|
|
87184
87208
|
const targetMailbox = this.resolveMailbox(mailbox || "INBOX", targetAccount);
|
|
87185
87209
|
const command = `
|
|
87186
|
-
${mailboxLookupFragment("mailboxes", targetMailbox, "theMailbox")}
|
|
87210
|
+
${mailboxLookupFragment("mailboxes", targetMailbox, "theMailbox", this.mailboxIndexHint(targetAccount, targetMailbox))}
|
|
87187
87211
|
if theMailbox is missing value then error "Mailbox \\"${escapeForAppleScript(targetMailbox)}\\" not found"
|
|
87188
87212
|
return unread count of theMailbox`;
|
|
87189
87213
|
const script = buildAccountScopedScript(targetAccount, command);
|
package/package.json
CHANGED