apple-notes-mcp 2.8.1 → 2.8.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.
Files changed (2) hide show
  1. package/build/index.js +404 -132
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -3110,15 +3110,33 @@ var require_data = __commonJS({
3110
3110
  }
3111
3111
  });
3112
3112
 
3113
- // node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/utils.js
3113
+ // node_modules/.pnpm/fast-uri@3.1.6/node_modules/fast-uri/lib/utils.js
3114
3114
  var require_utils = __commonJS({
3115
- "node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/utils.js"(exports, module) {
3115
+ "node_modules/.pnpm/fast-uri@3.1.6/node_modules/fast-uri/lib/utils.js"(exports, module) {
3116
3116
  "use strict";
3117
3117
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3118
3118
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
3119
3119
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3120
3120
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3121
- var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
3121
+ var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
3122
+ var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
3123
+ var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
3124
+ var BYTE_HEX = new Array(256);
3125
+ {
3126
+ const HEX_DIGITS = "0123456789ABCDEF";
3127
+ for (let i = 0; i < 256; i++) {
3128
+ BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
3129
+ }
3130
+ }
3131
+ function percentEncodeNonAscii(cp) {
3132
+ if (cp < 2048) {
3133
+ return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
3134
+ }
3135
+ if (cp < 65536) {
3136
+ return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3137
+ }
3138
+ return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3139
+ }
3122
3140
  function stringArrayToHexStripped(input) {
3123
3141
  let acc = "";
3124
3142
  let code = 0;
@@ -3143,91 +3161,105 @@ var require_utils = __commonJS({
3143
3161
  }
3144
3162
  return acc;
3145
3163
  }
3164
+ var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
3165
+ var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
3166
+ var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
3146
3167
  var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
3147
- function consumeIsZone(buffer) {
3148
- buffer.length = 0;
3149
- return true;
3150
- }
3151
- function consumeHextets(buffer, address, output) {
3152
- if (buffer.length) {
3153
- const hex = stringArrayToHexStripped(buffer);
3154
- if (hex !== "") {
3155
- address.push(hex);
3156
- } else {
3157
- output.error = true;
3158
- return false;
3168
+ function isZoneIdentifier(zone) {
3169
+ if (zone.length === 0) return false;
3170
+ for (let i = 0; i < zone.length; i++) {
3171
+ if (isZoneCharacter(zone[i])) continue;
3172
+ if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
3173
+ i += 2;
3174
+ continue;
3159
3175
  }
3160
- buffer.length = 0;
3176
+ return false;
3161
3177
  }
3162
3178
  return true;
3163
3179
  }
3164
- function getIPV6(input) {
3165
- let tokenCount = 0;
3166
- const output = { error: false, address: "", zone: "" };
3167
- const address = [];
3168
- const buffer = [];
3169
- let endipv6Encountered = false;
3170
- let endIpv6 = false;
3171
- let consume = consumeHextets;
3172
- for (let i = 0; i < input.length; i++) {
3173
- const cursor = input[i];
3174
- if (cursor === "[" || cursor === "]") {
3175
- continue;
3176
- }
3177
- if (cursor === ":") {
3178
- if (endipv6Encountered === true) {
3179
- endIpv6 = true;
3180
- }
3181
- if (!consume(buffer, address, output)) {
3182
- break;
3183
- }
3184
- if (++tokenCount > 7) {
3185
- output.error = true;
3186
- break;
3187
- }
3188
- if (i > 0 && input[i - 1] === ":") {
3189
- endipv6Encountered = true;
3190
- }
3191
- address.push(":");
3192
- continue;
3193
- } else if (cursor === "%") {
3194
- if (!consume(buffer, address, output)) {
3195
- break;
3180
+ function compressIPv6ZeroRun(hextets) {
3181
+ let bestStart = -1;
3182
+ let bestLength = 0;
3183
+ let runStart = -1;
3184
+ let runLength = 0;
3185
+ for (let i = 0; i < hextets.length; i++) {
3186
+ if (hextets[i] === "0") {
3187
+ if (runStart === -1) runStart = i;
3188
+ runLength++;
3189
+ if (runLength > bestLength) {
3190
+ bestLength = runLength;
3191
+ bestStart = runStart;
3196
3192
  }
3197
- consume = consumeIsZone;
3198
3193
  } else {
3199
- buffer.push(cursor);
3194
+ runStart = -1;
3195
+ runLength = 0;
3196
+ }
3197
+ }
3198
+ if (bestLength < 2) return hextets.join(":");
3199
+ const head = hextets.slice(0, bestStart).join(":");
3200
+ const tail = hextets.slice(bestStart + bestLength).join(":");
3201
+ return head + "::" + tail;
3202
+ }
3203
+ function normalizeIPv6Address(input) {
3204
+ const compression = input.indexOf("::");
3205
+ if (compression !== -1 && input.indexOf("::", compression + 1) !== -1) return void 0;
3206
+ const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
3207
+ const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
3208
+ if (compression !== -1) {
3209
+ if (left.length === 1 && left[0] === "") left.length = 0;
3210
+ if (right.length === 1 && right[0] === "") right.length = 0;
3211
+ }
3212
+ const parts = left.concat(right);
3213
+ let hextetCount = 0;
3214
+ for (let i = 0; i < parts.length; i++) {
3215
+ const part = parts[i];
3216
+ if (part === "") return void 0;
3217
+ if (part.indexOf(".") !== -1) {
3218
+ if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part)) return void 0;
3219
+ hextetCount += 2;
3200
3220
  continue;
3201
3221
  }
3222
+ if (!isHextet(part)) return void 0;
3223
+ parts[i] = parseInt(part, 16).toString(16);
3224
+ hextetCount++;
3202
3225
  }
3203
- if (buffer.length) {
3204
- if (consume === consumeIsZone) {
3205
- output.zone = buffer.join("");
3206
- } else if (endIpv6) {
3207
- address.push(buffer.join(""));
3208
- } else {
3209
- address.push(stringArrayToHexStripped(buffer));
3210
- }
3226
+ if (compression === -1) {
3227
+ if (hextetCount !== 8) return void 0;
3228
+ return compressIPv6ZeroRun(parts);
3211
3229
  }
3212
- output.address = address.join("");
3213
- return output;
3230
+ if (hextetCount >= 8) return void 0;
3231
+ const expanded = parts.slice(0, left.length);
3232
+ for (let i = hextetCount; i < 8; i++) expanded.push("0");
3233
+ for (let i = left.length; i < parts.length; i++) expanded.push(parts[i]);
3234
+ return compressIPv6ZeroRun(expanded);
3214
3235
  }
3215
3236
  function normalizeIPv6(host) {
3216
- if (findToken(host, ":") < 2) {
3217
- return { host, isIPV6: false };
3218
- }
3219
- const ipv62 = getIPV6(host);
3220
- if (!ipv62.error) {
3221
- let newHost = ipv62.address;
3222
- let escapedHost = ipv62.address;
3223
- if (ipv62.zone) {
3224
- newHost += "%" + ipv62.zone;
3225
- escapedHost += "%25" + ipv62.zone;
3226
- }
3227
- return { host: newHost, isIPV6: true, escapedHost };
3228
- } else {
3229
- return { host, isIPV6: false };
3230
- }
3237
+ const bracketed = host[0] === "[" && host[host.length - 1] === "]";
3238
+ const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
3239
+ if (hasBracket && !bracketed) return { host, isIPV6: false, error: true };
3240
+ let input = bracketed ? host.slice(1, -1) : host;
3241
+ if (bracketed && isIPvFuture(input)) {
3242
+ input = input.toLowerCase();
3243
+ return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true };
3244
+ }
3245
+ if (findToken(input, ":") < 2) {
3246
+ return { host, isIPV6: false, error: bracketed };
3247
+ }
3248
+ let zoneIdentifier = "";
3249
+ const zoneSeparator = input.indexOf("%");
3250
+ if (zoneSeparator !== -1) {
3251
+ const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
3252
+ zoneIdentifier = input.slice(zoneSeparator + separatorLength);
3253
+ if (!isZoneIdentifier(zoneIdentifier)) return { host, isIPV6: false, error: true };
3254
+ input = input.slice(0, zoneSeparator);
3255
+ }
3256
+ const address = normalizeIPv6Address(input);
3257
+ if (address === void 0) return { host, isIPV6: false, error: true };
3258
+ return {
3259
+ host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
3260
+ escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
3261
+ isIPV6: true
3262
+ };
3231
3263
  }
3232
3264
  function findToken(str, token) {
3233
3265
  let ind = 0;
@@ -3346,7 +3378,8 @@ var require_utils = __commonJS({
3346
3378
  function normalizePathEncoding(input) {
3347
3379
  let output = "";
3348
3380
  for (let i = 0; i < input.length; i++) {
3349
- if (input[i] === "%" && i + 2 < input.length) {
3381
+ const ch = input[i];
3382
+ if (ch === "%" && i + 2 < input.length) {
3350
3383
  const hex = input.slice(i + 1, i + 3);
3351
3384
  if (isHexPair(hex)) {
3352
3385
  const normalizedHex = hex.toUpperCase();
@@ -3360,10 +3393,152 @@ var require_utils = __commonJS({
3360
3393
  continue;
3361
3394
  }
3362
3395
  }
3363
- if (isPathCharacter(input[i])) {
3364
- output += input[i];
3396
+ if (isPathCharacter(ch)) {
3397
+ output += ch;
3365
3398
  } else {
3366
- output += escape(input[i]);
3399
+ const code = input.charCodeAt(i);
3400
+ if (code < 128) {
3401
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3402
+ } else if (code < 55296 || code > 57343) {
3403
+ output += percentEncodeNonAscii(code);
3404
+ } else if (code <= 56319 && i + 1 < input.length) {
3405
+ const low = input.charCodeAt(i + 1);
3406
+ if (low >= 56320 && low <= 57343) {
3407
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3408
+ i++;
3409
+ } else {
3410
+ output += percentEncodeNonAscii(65533);
3411
+ }
3412
+ } else {
3413
+ output += percentEncodeNonAscii(65533);
3414
+ }
3415
+ }
3416
+ }
3417
+ return output;
3418
+ }
3419
+ function serializePathEncoding(input, pathNoScheme = false) {
3420
+ let output = "";
3421
+ let firstSegment = pathNoScheme && input[0] !== "/";
3422
+ for (let i = 0; i < input.length; i++) {
3423
+ const ch = input[i];
3424
+ if (ch === "%" && i + 2 < input.length) {
3425
+ const hex = input.slice(i + 1, i + 3);
3426
+ if (isHexPair(hex)) {
3427
+ output += "%" + hex.toUpperCase();
3428
+ i += 2;
3429
+ continue;
3430
+ }
3431
+ }
3432
+ if (ch === "/") {
3433
+ firstSegment = false;
3434
+ }
3435
+ if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) {
3436
+ output += ch;
3437
+ } else {
3438
+ const code = input.charCodeAt(i);
3439
+ if (code < 128) {
3440
+ output += BYTE_HEX[code];
3441
+ } else if (code < 55296 || code > 57343) {
3442
+ output += percentEncodeNonAscii(code);
3443
+ } else if (code <= 56319 && i + 1 < input.length) {
3444
+ const low = input.charCodeAt(i + 1);
3445
+ if (low >= 56320 && low <= 57343) {
3446
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3447
+ i++;
3448
+ } else {
3449
+ output += percentEncodeNonAscii(65533);
3450
+ }
3451
+ } else {
3452
+ output += percentEncodeNonAscii(65533);
3453
+ }
3454
+ }
3455
+ }
3456
+ return output;
3457
+ }
3458
+ function encodeComponent(input, isAllowed) {
3459
+ let output = "";
3460
+ for (let i = 0; i < input.length; i++) {
3461
+ const ch = input[i];
3462
+ if (ch === "%" && i + 2 < input.length) {
3463
+ const hex = input.slice(i + 1, i + 3);
3464
+ if (isHexPair(hex)) {
3465
+ output += "%" + hex.toUpperCase();
3466
+ i += 2;
3467
+ continue;
3468
+ }
3469
+ }
3470
+ if (isAllowed(ch)) {
3471
+ output += ch;
3472
+ } else {
3473
+ const code = input.charCodeAt(i);
3474
+ if (code < 128) {
3475
+ output += BYTE_HEX[code];
3476
+ } else if (code < 55296 || code > 57343) {
3477
+ output += percentEncodeNonAscii(code);
3478
+ } else if (code <= 56319 && i + 1 < input.length) {
3479
+ const low = input.charCodeAt(i + 1);
3480
+ if (low >= 56320 && low <= 57343) {
3481
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3482
+ i++;
3483
+ } else {
3484
+ output += percentEncodeNonAscii(65533);
3485
+ }
3486
+ } else {
3487
+ output += percentEncodeNonAscii(65533);
3488
+ }
3489
+ }
3490
+ }
3491
+ return output;
3492
+ }
3493
+ function encodeUserinfo(input) {
3494
+ return encodeComponent(input, isUserinfoCharacter);
3495
+ }
3496
+ function encodeQuery(input) {
3497
+ return encodeComponent(input, isQueryFragmentCharacter);
3498
+ }
3499
+ function encodeFragment(input) {
3500
+ return encodeComponent(input, isQueryFragmentCharacter);
3501
+ }
3502
+ function isEscapeSafe(cp) {
3503
+ return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95;
3504
+ }
3505
+ function normalizeQueryFragmentEncoding(input) {
3506
+ let output = "";
3507
+ for (let i = 0; i < input.length; i++) {
3508
+ const ch = input[i];
3509
+ if (ch === "%" && i + 2 < input.length) {
3510
+ const hex = input.slice(i + 1, i + 3);
3511
+ if (isHexPair(hex)) {
3512
+ const normalizedHex = hex.toUpperCase();
3513
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3514
+ if (isUnreserved(decoded)) {
3515
+ output += decoded;
3516
+ } else {
3517
+ output += "%" + normalizedHex;
3518
+ }
3519
+ i += 2;
3520
+ continue;
3521
+ }
3522
+ }
3523
+ if (isQueryFragmentCharacter(ch)) {
3524
+ output += ch;
3525
+ } else {
3526
+ const code = input.charCodeAt(i);
3527
+ if (code < 128) {
3528
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3529
+ } else if (code < 55296 || code > 57343) {
3530
+ output += percentEncodeNonAscii(code);
3531
+ } else if (code <= 56319 && i + 1 < input.length) {
3532
+ const low = input.charCodeAt(i + 1);
3533
+ if (low >= 56320 && low <= 57343) {
3534
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3535
+ i++;
3536
+ } else {
3537
+ output += percentEncodeNonAscii(65533);
3538
+ }
3539
+ } else {
3540
+ output += percentEncodeNonAscii(65533);
3541
+ }
3367
3542
  }
3368
3543
  }
3369
3544
  return output;
@@ -3386,14 +3561,18 @@ var require_utils = __commonJS({
3386
3561
  function recomposeAuthority(component) {
3387
3562
  const uriTokens = [];
3388
3563
  if (component.userinfo !== void 0) {
3389
- uriTokens.push(component.userinfo);
3564
+ uriTokens.push(encodeUserinfo(component.userinfo));
3390
3565
  uriTokens.push("@");
3391
3566
  }
3392
3567
  if (component.host !== void 0) {
3393
- let host = unescape(component.host);
3568
+ let host = component.host;
3394
3569
  if (!isIPv4(host)) {
3395
- const ipV6res = normalizeIPv6(host);
3396
- if (ipV6res.isIPV6 === true) {
3570
+ let ipV6res = normalizeIPv6(host);
3571
+ if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
3572
+ host = normalizePercentEncoding(host, true);
3573
+ ipV6res = normalizeIPv6(host);
3574
+ }
3575
+ if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {
3397
3576
  host = `[${ipV6res.escapedHost}]`;
3398
3577
  } else {
3399
3578
  host = reescapeHostDelimiters(host, false);
@@ -3413,6 +3592,11 @@ var require_utils = __commonJS({
3413
3592
  reescapeHostDelimiters,
3414
3593
  normalizePercentEncoding,
3415
3594
  normalizePathEncoding,
3595
+ serializePathEncoding,
3596
+ normalizeQueryFragmentEncoding,
3597
+ encodeUserinfo,
3598
+ encodeQuery,
3599
+ encodeFragment,
3416
3600
  escapePreservingEscapes,
3417
3601
  removeDotSegments,
3418
3602
  isIPv4,
@@ -3423,12 +3607,12 @@ var require_utils = __commonJS({
3423
3607
  }
3424
3608
  });
3425
3609
 
3426
- // node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/schemes.js
3610
+ // node_modules/.pnpm/fast-uri@3.1.6/node_modules/fast-uri/lib/schemes.js
3427
3611
  var require_schemes = __commonJS({
3428
- "node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/lib/schemes.js"(exports, module) {
3612
+ "node_modules/.pnpm/fast-uri@3.1.6/node_modules/fast-uri/lib/schemes.js"(exports, module) {
3429
3613
  "use strict";
3430
3614
  var { isUUID } = require_utils();
3431
- var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
3615
+ var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
3432
3616
  var supportedSchemeNames = (
3433
3617
  /** @type {const} */
3434
3618
  [
@@ -3489,9 +3673,10 @@ var require_schemes = __commonJS({
3489
3673
  wsComponent.secure = void 0;
3490
3674
  }
3491
3675
  if (wsComponent.resourceName) {
3492
- const [path4, query] = wsComponent.resourceName.split("?");
3676
+ const queryIndex = wsComponent.resourceName.indexOf("?");
3677
+ const path4 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3493
3678
  wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
3494
- wsComponent.query = query;
3679
+ wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
3495
3680
  wsComponent.resourceName = void 0;
3496
3681
  }
3497
3682
  wsComponent.fragment = void 0;
@@ -3503,7 +3688,7 @@ var require_schemes = __commonJS({
3503
3688
  return urnComponent;
3504
3689
  }
3505
3690
  const matches = urnComponent.path.match(URN_REG);
3506
- if (matches) {
3691
+ if (matches && matches[0] === urnComponent.path) {
3507
3692
  const scheme = options.scheme || urnComponent.scheme || "urn";
3508
3693
  urnComponent.nid = matches[1].toLowerCase();
3509
3694
  urnComponent.nss = matches[2];
@@ -3633,12 +3818,21 @@ var require_schemes = __commonJS({
3633
3818
  }
3634
3819
  });
3635
3820
 
3636
- // node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/index.js
3821
+ // node_modules/.pnpm/fast-uri@3.1.6/node_modules/fast-uri/index.js
3637
3822
  var require_fast_uri = __commonJS({
3638
- "node_modules/.pnpm/fast-uri@3.1.5/node_modules/fast-uri/index.js"(exports, module) {
3823
+ "node_modules/.pnpm/fast-uri@3.1.6/node_modules/fast-uri/index.js"(exports, module) {
3639
3824
  "use strict";
3640
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3825
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3641
3826
  var { SCHEMES, getSchemeHandler } = require_schemes();
3827
+ var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
3828
+ var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
3829
+ function decodeValidScheme(scheme) {
3830
+ const decodedScheme = unescape(String(scheme));
3831
+ if (!VALID_SCHEME.test(decodedScheme)) {
3832
+ throw new TypeError(MALFORMED_SCHEME_ERROR);
3833
+ }
3834
+ return decodedScheme;
3835
+ }
3642
3836
  function normalize(uri, options) {
3643
3837
  if (typeof uri === "string") {
3644
3838
  uri = /** @type {T} */
@@ -3651,12 +3845,34 @@ var require_fast_uri = __commonJS({
3651
3845
  }
3652
3846
  function resolve2(baseURI, relativeURI, options) {
3653
3847
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3654
- const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
3655
- const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
3656
- if (baseMalformed || relativeMalformed) {
3848
+ const {
3849
+ parsed: baseParsed,
3850
+ malformedAuthorityOrPort: baseMalformed,
3851
+ malformedPercentEncoding: baseMalformedPercentEncoding,
3852
+ malformedSchemeSpecific: baseMalformedSchemeSpecific,
3853
+ malformedHost: baseMalformedHost,
3854
+ malformedScheme: baseMalformedScheme
3855
+ } = parseWithStatus(baseURI, schemelessOptions);
3856
+ const {
3857
+ parsed: relativeParsed,
3858
+ malformedAuthorityOrPort: relativeMalformed,
3859
+ malformedPercentEncoding: relativeMalformedPercentEncoding,
3860
+ malformedSchemeSpecific: relativeMalformedSchemeSpecific,
3861
+ malformedHost: relativeMalformedHost,
3862
+ malformedScheme: relativeMalformedScheme
3863
+ } = parseWithStatus(relativeURI, schemelessOptions);
3864
+ if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) {
3657
3865
  throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
3658
3866
  }
3659
3867
  const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
3868
+ const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
3869
+ const resolvedHost = resolved.host;
3870
+ const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
3871
+ canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
3872
+ const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost);
3873
+ if (resolved.error && !encodedASCIIHost) {
3874
+ throw new Error(resolved.error);
3875
+ }
3660
3876
  schemelessOptions.skipEscape = true;
3661
3877
  return serialize(resolved, schemelessOptions);
3662
3878
  }
@@ -3716,7 +3932,7 @@ var require_fast_uri = __commonJS({
3716
3932
  function equal(uriA, uriB, options) {
3717
3933
  const normalizedA = normalizeComparableURI(uriA, options);
3718
3934
  const normalizedB = normalizeComparableURI(uriB, options);
3719
- return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
3935
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
3720
3936
  }
3721
3937
  function serialize(cmpts, opts) {
3722
3938
  const component = {
@@ -3737,19 +3953,22 @@ var require_fast_uri = __commonJS({
3737
3953
  };
3738
3954
  const options = Object.assign({}, opts);
3739
3955
  const uriTokens = [];
3956
+ if (component.scheme) {
3957
+ component.scheme = decodeValidScheme(component.scheme);
3958
+ }
3740
3959
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3741
3960
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3961
+ const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
3962
+ const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
3742
3963
  if (component.path !== void 0) {
3743
3964
  if (!options.skipEscape) {
3744
- component.path = escapePreservingEscapes(component.path);
3745
- if (component.scheme !== void 0) {
3746
- component.path = component.path.split("%3A").join(":");
3747
- }
3965
+ component.path = serializePathEncoding(component.path, pathNoScheme);
3748
3966
  } else {
3749
3967
  component.path = normalizePercentEncoding(component.path);
3750
3968
  }
3751
3969
  }
3752
3970
  if (options.reference !== "suffix" && component.scheme) {
3971
+ component.scheme = decodeValidScheme(component.scheme);
3753
3972
  uriTokens.push(component.scheme, ":");
3754
3973
  }
3755
3974
  const authority = recomposeAuthority(component);
@@ -3767,16 +3986,19 @@ var require_fast_uri = __commonJS({
3767
3986
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3768
3987
  s = removeDotSegments(s);
3769
3988
  }
3989
+ if (pathNoScheme) {
3990
+ s = serializePathEncoding(s, true);
3991
+ }
3770
3992
  if (authority === void 0 && s[0] === "/" && s[1] === "/") {
3771
3993
  s = "/%2F" + s.slice(2);
3772
3994
  }
3773
3995
  uriTokens.push(s);
3774
3996
  }
3775
3997
  if (component.query !== void 0) {
3776
- uriTokens.push("?", component.query);
3998
+ uriTokens.push("?", encodeQuery(component.query));
3777
3999
  }
3778
4000
  if (component.fragment !== void 0) {
3779
- uriTokens.push("#", component.fragment);
4001
+ uriTokens.push("#", encodeFragment(component.fragment));
3780
4002
  }
3781
4003
  return uriTokens.join("");
3782
4004
  }
@@ -3792,6 +4014,32 @@ var require_fast_uri = __commonJS({
3792
4014
  }
3793
4015
  return void 0;
3794
4016
  }
4017
+ function hasMalformedPercentEncoding(component) {
4018
+ if (component === void 0) return false;
4019
+ let percent = component.indexOf("%");
4020
+ while (percent !== -1) {
4021
+ if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {
4022
+ return true;
4023
+ }
4024
+ percent = component.indexOf("%", percent + 3);
4025
+ }
4026
+ return false;
4027
+ }
4028
+ function hasMalformedComponentPercentEncoding(matches) {
4029
+ const host = matches[4];
4030
+ return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host[0] === "[" && host[host.length - 1] === "]") && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4031
+ }
4032
+ function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4033
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host[0] !== "[" && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4034
+ try {
4035
+ parsed.host = new URL("http://" + parsed.host).hostname;
4036
+ } catch (e) {
4037
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
4038
+ return true;
4039
+ }
4040
+ }
4041
+ return false;
4042
+ }
3795
4043
  function parseWithStatus(uri, opts) {
3796
4044
  const options = Object.assign({}, opts);
3797
4045
  const parsed = {
@@ -3804,6 +4052,11 @@ var require_fast_uri = __commonJS({
3804
4052
  fragment: void 0
3805
4053
  };
3806
4054
  let malformedAuthorityOrPort = false;
4055
+ let malformedPercentEncoding = false;
4056
+ let malformedSchemeSpecific = false;
4057
+ let malformedHost = false;
4058
+ let malformedIPLiteral = false;
4059
+ let malformedScheme = false;
3807
4060
  let isIP = false;
3808
4061
  if (options.reference === "suffix") {
3809
4062
  if (options.scheme) {
@@ -3840,6 +4093,19 @@ var require_fast_uri = __commonJS({
3840
4093
  parsed.path = matches[6] || "";
3841
4094
  parsed.query = matches[7];
3842
4095
  parsed.fragment = matches[8];
4096
+ if (parsed.scheme !== void 0) {
4097
+ const decodedScheme = unescape(parsed.scheme);
4098
+ if (VALID_SCHEME.test(decodedScheme)) {
4099
+ parsed.scheme = decodedScheme.toLowerCase();
4100
+ } else {
4101
+ parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
4102
+ malformedScheme = true;
4103
+ }
4104
+ }
4105
+ malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
4106
+ if (malformedPercentEncoding) {
4107
+ parsed.error = parsed.error || "URI contains malformed percent-encoding.";
4108
+ }
3843
4109
  if (isNaN(parsed.port)) {
3844
4110
  parsed.port = matches[5];
3845
4111
  }
@@ -3851,9 +4117,15 @@ var require_fast_uri = __commonJS({
3851
4117
  if (parsed.host) {
3852
4118
  const ipv4result = isIPv4(parsed.host);
3853
4119
  if (ipv4result === false) {
4120
+ const bracketedIPLiteral = parsed.host[0] === "[" && parsed.host[parsed.host.length - 1] === "]";
3854
4121
  const ipv6result = normalizeIPv6(parsed.host);
3855
- parsed.host = ipv6result.host.toLowerCase();
3856
- isIP = ipv6result.isIPV6;
4122
+ isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4123
+ malformedIPLiteral = bracketedIPLiteral && ipv6result.error === true;
4124
+ parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4125
+ if (malformedIPLiteral) {
4126
+ parsed.error = parsed.error || "URI host is malformed.";
4127
+ malformedAuthorityOrPort = true;
4128
+ }
3857
4129
  } else {
3858
4130
  isIP = true;
3859
4131
  }
@@ -3871,42 +4143,34 @@ var require_fast_uri = __commonJS({
3871
4143
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
3872
4144
  }
3873
4145
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
3874
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3875
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3876
- try {
3877
- parsed.host = new URL("http://" + parsed.host).hostname;
3878
- } catch (e) {
3879
- parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
3880
- }
3881
- }
3882
- }
4146
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
3883
4147
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
3884
4148
  if (uri.indexOf("%") !== -1) {
3885
- if (parsed.scheme !== void 0) {
3886
- parsed.scheme = unescape(parsed.scheme);
3887
- }
3888
- if (parsed.host !== void 0) {
3889
- parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
4149
+ if (parsed.host !== void 0 && !malformedIPLiteral) {
4150
+ const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
4151
+ parsed.host = reescapeHostDelimiters(host, isIP);
3890
4152
  }
3891
4153
  }
3892
4154
  if (parsed.path) {
3893
4155
  parsed.path = normalizePathEncoding(parsed.path);
3894
4156
  }
4157
+ if (parsed.query) {
4158
+ parsed.query = normalizeQueryFragmentEncoding(parsed.query);
4159
+ }
3895
4160
  if (parsed.fragment) {
3896
- try {
3897
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3898
- } catch {
3899
- parsed.error = parsed.error || "URI malformed";
3900
- }
4161
+ parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
3901
4162
  }
3902
4163
  }
3903
4164
  if (schemeHandler && schemeHandler.parse) {
3904
4165
  schemeHandler.parse(parsed, options);
4166
+ if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) {
4167
+ malformedSchemeSpecific = true;
4168
+ }
3905
4169
  }
3906
4170
  } else {
3907
4171
  parsed.error = parsed.error || "URI can not be parsed.";
3908
4172
  }
3909
- return { parsed, malformedAuthorityOrPort };
4173
+ return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
3910
4174
  }
3911
4175
  function parse3(uri, opts) {
3912
4176
  return parseWithStatus(uri, opts).parsed;
@@ -3915,20 +4179,28 @@ var require_fast_uri = __commonJS({
3915
4179
  return normalizeStringWithStatus(uri, opts).normalized;
3916
4180
  }
3917
4181
  function normalizeStringWithStatus(uri, opts) {
3918
- const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
4182
+ const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
3919
4183
  return {
3920
- normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
3921
- malformedAuthorityOrPort
4184
+ normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
4185
+ malformedAuthorityOrPort,
4186
+ malformedPercentEncoding,
4187
+ malformedSchemeSpecific,
4188
+ malformedHost,
4189
+ malformedScheme
3922
4190
  };
3923
4191
  }
3924
4192
  function normalizeComparableURI(uri, opts) {
3925
- if (typeof uri === "string") {
3926
- const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
3927
- return malformedAuthorityOrPort ? void 0 : normalized;
4193
+ if (typeof uri !== "string" && typeof uri !== "object") {
4194
+ return void 0;
3928
4195
  }
3929
- if (typeof uri === "object") {
3930
- return serialize(uri, opts);
4196
+ let value;
4197
+ try {
4198
+ value = typeof uri === "string" ? uri : serialize(uri, opts);
4199
+ } catch {
4200
+ return void 0;
3931
4201
  }
4202
+ const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
4203
+ return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
3932
4204
  }
3933
4205
  var fastUri = {
3934
4206
  SCHEMES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apple-notes-mcp",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "description": "MCP server for Apple Notes - create, search, update, and manage notes via Claude and other AI assistants",
5
5
  "type": "module",
6
6
  "main": "build/index.js",