@openclaw/matrix 2026.5.27 → 2026.5.28-beta.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 (72) hide show
  1. package/dist/api.js +4 -4
  2. package/dist/{approval-handler.runtime-D2nZfRw6.js → approval-handler.runtime-pR4jcWts.js} +7 -37
  3. package/dist/{approval-ids-DzBw_AG3.js → approval-ids-BsGUOwIc.js} +1 -1
  4. package/dist/{approval-reaction-auth-BvK3dXMH.js → approval-reaction-auth-CstZA90i.js} +2 -2
  5. package/dist/{channel-BLuA_9If.js → channel-EfS9AcXo.js} +15 -15
  6. package/dist/channel-plugin-api.js +1 -1
  7. package/dist/{channel.runtime-CCAsyp75.js → channel.runtime-BSL4fCB_.js} +7 -7
  8. package/dist/{cli-Bo50M7l4.js → cli-CYLqmzNw.js} +15 -14
  9. package/dist/{cli-metadata-CqUHNx_0.js → cli-metadata-TxtMWnLo.js} +1 -1
  10. package/dist/cli-metadata.js +1 -1
  11. package/dist/{client-QO7vDxm0.js → client-D6nL0ymL.js} +2 -2
  12. package/dist/{client-BgsOzckO.js → client-DxQ7tWJq.js} +2 -2
  13. package/dist/{client-bootstrap-DK9i3KZ5.js → client-bootstrap-BtddaQGi.js} +1 -1
  14. package/dist/{config-schema-DuSRVdwT.js → config-schema-CRsTmqKY.js} +1 -1
  15. package/dist/contract-api.js +3 -3
  16. package/dist/{create-client-hdBEoEIm.js → create-client-D5Ie4y1a.js} +2 -2
  17. package/dist/{crypto-runtime-BcQzS9DV.js → crypto-runtime-CpQeK8kh.js} +4 -4
  18. package/dist/{deps-CAdiytPJ.js → deps-BVWGd2XS.js} +12 -2
  19. package/dist/{directory-live-2-Vb6nss.js → directory-live-kLKfwyDt.js} +2 -2
  20. package/dist/{doctor-qLh9PyE4.js → doctor-CENc9ks0.js} +1 -1
  21. package/dist/{draft-stream-BBVqdEbn.js → draft-stream-D7KMDYlS.js} +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/{legacy-crypto-inspector-BRdo-WqV.js → legacy-crypto-inspector-tJOj25VL.js} +1 -1
  24. package/dist/{logging-BR-gcAjp.js → logging-BD9Wmviv.js} +2 -9
  25. package/dist/{matrix-migration.runtime-BhJb4ZII.js → matrix-migration.runtime-CZOep_JX.js} +1 -1
  26. package/dist/{media-text-C6q1S0AJ.js → media-text-ybU6tiB2.js} +1 -1
  27. package/dist/{messages-D-VxmWkC.js → messages-CHjewhaA.js} +5 -5
  28. package/dist/{monitor-DO1yiHWm.js → monitor-DjfcOAje.js} +25 -26
  29. package/dist/plugin-entry.handlers.runtime.js +1 -1
  30. package/dist/probe.runtime-BjFSknLp.js +3 -0
  31. package/dist/{profile-update-B_LpeC8E.js → profile-update-B4HzVfDS.js} +2 -2
  32. package/dist/{reaction-events-BefH3-Gu.js → reaction-events-gK5X5uu5.js} +1 -1
  33. package/dist/recovery-key-store-B3-wYrMU.js +294 -0
  34. package/dist/{resolve-targets-BPhBqXyj.js → resolve-targets-DaTQqtPq.js} +1 -1
  35. package/dist/{resolver.runtime-BOS3foyc.js → resolver.runtime-Dj10Iq3r.js} +1 -1
  36. package/dist/{runtime-api-B-jlPE4A.js → runtime-api-CsF7Kokd.js} +2 -2
  37. package/dist/runtime-api.js +1 -1
  38. package/dist/runtime-heavy-api.js +1 -1
  39. package/dist/{sdk-BKBZkPKt.js → sdk-DTo3Hzko.js} +14 -304
  40. package/dist/{send-DivaFHb1.js → send-DX-aOjPW.js} +1 -1
  41. package/dist/{setup-bootstrap-ClcP-tDQ.js → setup-bootstrap-D9XeWu6O.js} +2 -2
  42. package/dist/{setup-core-s8s_Qudu.js → setup-core-BU4BO6DB.js} +7 -2
  43. package/dist/setup-plugin-api.js +3 -3
  44. package/dist/{setup-surface-BOt10HNf.js → setup-surface-BIFSsw6q.js} +5 -5
  45. package/dist/{shared-3K27tl8e.js → shared-CZ622gSf.js} +113 -5
  46. package/dist/{thread-bindings-CLjJrThw.js → thread-bindings-DjC1mhh_.js} +1 -1
  47. package/dist/{tool-actions.runtime-Vky1krcK.js → tool-actions.runtime-D4A9O27R.js} +20 -21
  48. package/dist/{verification-Dar6QON4.js → verification-CUSz9cFP.js} +1 -1
  49. package/node_modules/linkify-it/build/index.cjs.js +99 -94
  50. package/node_modules/linkify-it/index.mjs +99 -94
  51. package/node_modules/linkify-it/package.json +11 -1
  52. package/node_modules/markdown-it/README.md +13 -17
  53. package/node_modules/markdown-it/dist/index.cjs.js +111 -31
  54. package/node_modules/markdown-it/dist/markdown-it.js +117 -31
  55. package/node_modules/markdown-it/dist/markdown-it.min.js +2 -2
  56. package/node_modules/markdown-it/lib/common/utils.mjs +30 -1
  57. package/node_modules/markdown-it/lib/index.mjs +1 -1
  58. package/node_modules/markdown-it/lib/rules_block/heading.mjs +2 -2
  59. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +12 -1
  60. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +4 -1
  61. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +3 -1
  62. package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +37 -21
  63. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +2 -2
  64. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +37 -6
  65. package/node_modules/markdown-it/package.json +14 -3
  66. package/node_modules/matrix-js-sdk/CHANGELOG.md +7 -0
  67. package/node_modules/matrix-js-sdk/package.json +1 -1
  68. package/npm-shrinkwrap.json +35 -15
  69. package/package.json +6 -6
  70. package/dist/probe.runtime-9S17Q3Mo.js +0 -3
  71. package/dist/startup-abort-Bs0Up_Qx.js +0 -109
  72. package/dist/test-api.js +0 -4
@@ -1,12 +1,12 @@
1
1
  import { c as resolveMatrixAccountConfig } from "./config-paths-ZBCMwSos.js";
2
- import "./setup-core-s8s_Qudu.js";
3
- import { E as parsePollStart, T as isPollStartType, b as buildPollResponseContent, i as reactMatrixMessage, u as resolveMatrixRoomId } from "./send-DivaFHb1.js";
2
+ import "./setup-core-BU4BO6DB.js";
3
+ import { E as parsePollStart, T as isPollStartType, b as buildPollResponseContent, i as reactMatrixMessage, u as resolveMatrixRoomId } from "./send-DX-aOjPW.js";
4
4
  import { i as buildMatrixReactionRelationsPath, o as selectOwnMatrixReactionEventIds, s as summarizeMatrixReactionEvents } from "./reaction-common-DkrQdBSZ.js";
5
- import { n as withResolvedActionClient, r as withResolvedRoomAction } from "./client-BgsOzckO.js";
6
- import { a as fetchEventSummary, c as resolveMatrixActionLimit, i as sendMatrixMessage, n as editMatrixMessage, o as readPinnedEvents, r as readMatrixMessages, s as EventType, t as deleteMatrixMessage } from "./messages-D-VxmWkC.js";
7
- import { a as jsonResult, c as readStringArrayParam, l as readStringParam, o as readNumberParam, r as createActionGate, s as readReactionParams } from "./runtime-api-B-jlPE4A.js";
8
- import { t as applyMatrixProfileUpdate } from "./profile-update-B_LpeC8E.js";
9
- import { _ as scanMatrixVerificationQr, a as confirmMatrixVerificationSas, b as verifyMatrixRecoveryKey, c as getMatrixRoomKeyBackupStatus, d as listMatrixVerifications, f as mismatchMatrixVerificationSas, h as restoreMatrixRoomKeyBackup, i as confirmMatrixVerificationReciprocateQr, l as getMatrixVerificationSas, n as bootstrapMatrixVerification, o as generateMatrixVerificationQr, p as requestMatrixVerification, r as cancelMatrixVerification, s as getMatrixEncryptionStatus, t as acceptMatrixVerification, u as getMatrixVerificationStatus, v as startMatrixVerification } from "./verification-Dar6QON4.js";
5
+ import { n as withResolvedActionClient, r as withResolvedRoomAction } from "./client-DxQ7tWJq.js";
6
+ import { a as fetchEventSummary, c as resolveMatrixActionLimit, i as sendMatrixMessage, n as editMatrixMessage, o as readPinnedEvents, r as readMatrixMessages, s as EventType, t as deleteMatrixMessage } from "./messages-CHjewhaA.js";
7
+ import { a as jsonResult, c as readStringArrayParam, l as readStringParam, o as readPositiveIntegerParam, r as createActionGate, s as readReactionParams } from "./runtime-api-CsF7Kokd.js";
8
+ import { t as applyMatrixProfileUpdate } from "./profile-update-B4HzVfDS.js";
9
+ import { _ as scanMatrixVerificationQr, a as confirmMatrixVerificationSas, b as verifyMatrixRecoveryKey, c as getMatrixRoomKeyBackupStatus, d as listMatrixVerifications, f as mismatchMatrixVerificationSas, h as restoreMatrixRoomKeyBackup, i as confirmMatrixVerificationReciprocateQr, l as getMatrixVerificationSas, n as bootstrapMatrixVerification, o as generateMatrixVerificationQr, p as requestMatrixVerification, r as cancelMatrixVerification, s as getMatrixEncryptionStatus, t as acceptMatrixVerification, u as getMatrixVerificationStatus, v as startMatrixVerification } from "./verification-CUSz9cFP.js";
10
10
  import { normalizeOptionalLowercaseString, uniqueStrings, uniqueValues } from "openclaw/plugin-sdk/string-coerce-runtime";
11
11
  //#region extensions/matrix/src/matrix/actions/polls.ts
12
12
  function normalizeOptionIndexes(indexes) {
@@ -222,20 +222,19 @@ function readStringAliasParam(params, keys, options = {}) {
222
222
  }
223
223
  if (options.required) throw new Error(`${keys[0]} required`);
224
224
  }
225
- function readNumericArrayParam(params, key, options = {}) {
226
- const { integer = false } = options;
225
+ function readPositiveIntegerArrayParam(params, key) {
227
226
  const raw = readRawParam(params, key);
228
- if (raw === void 0) return [];
229
- return (Array.isArray(raw) ? raw : [raw]).map((value) => {
230
- if (typeof value === "number" && Number.isFinite(value)) return value;
227
+ if (raw == null) return [];
228
+ return (Array.isArray(raw) ? raw : [raw]).flatMap((value) => {
229
+ if (value == null || value === "") return [];
231
230
  if (typeof value === "string") {
232
231
  const trimmed = value.trim();
233
- if (!trimmed) return null;
234
- const parsed = Number(trimmed);
235
- return Number.isFinite(parsed) ? parsed : null;
232
+ if (!trimmed) return [];
233
+ if (!/^[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:e[+-]?\d+)?$/i.test(trimmed)) return [];
236
234
  }
237
- return null;
238
- }).filter((value) => value !== null).map((value) => integer ? Math.trunc(value) : value);
235
+ const index = readPositiveIntegerParam({ [key]: value }, key, { message: `${key} must contain positive integers.` });
236
+ return index === void 0 ? [] : [index];
237
+ });
239
238
  }
240
239
  async function handleMatrixAction(params, cfg, opts = {}) {
241
240
  const action = readStringParam(params, "action", { required: true });
@@ -267,7 +266,7 @@ async function handleMatrixAction(params, cfg, opts = {}) {
267
266
  added: emoji
268
267
  });
269
268
  }
270
- const limit = readNumberParam(params, "limit", { integer: true });
269
+ const limit = readPositiveIntegerParam(params, "limit", { message: "limit must be a positive integer." });
271
270
  return jsonResult({
272
271
  ok: true,
273
272
  reactions: await listMatrixReactions(roomId, messageId, {
@@ -281,9 +280,9 @@ async function handleMatrixAction(params, cfg, opts = {}) {
281
280
  const pollId = readStringAliasParam(params, ["pollId", "messageId"], { required: true });
282
281
  if (!pollId) throw new Error("pollId required");
283
282
  const optionId = readStringParam(params, "pollOptionId");
284
- const optionIndex = readNumberParam(params, "pollOptionIndex", { integer: true });
283
+ const optionIndex = readPositiveIntegerParam(params, "pollOptionIndex", { message: "pollOptionIndex must be a positive integer." });
285
284
  const optionIds = [...readStringArrayParam(params, "pollOptionIds") ?? [], ...optionId ? [optionId] : []];
286
- const optionIndexes = [...readNumericArrayParam(params, "pollOptionIndexes", { integer: true }), ...optionIndex !== void 0 ? [optionIndex] : []];
285
+ const optionIndexes = [...readPositiveIntegerArrayParam(params, "pollOptionIndexes"), ...optionIndex !== void 0 ? [optionIndex] : []];
287
286
  return jsonResult({
288
287
  ok: true,
289
288
  result: await voteMatrixPoll(roomId, pollId, {
@@ -333,7 +332,7 @@ async function handleMatrixAction(params, cfg, opts = {}) {
333
332
  });
334
333
  case "readMessages": {
335
334
  const roomId = readRoomId(params);
336
- const limit = readNumberParam(params, "limit", { integer: true });
335
+ const limit = readPositiveIntegerParam(params, "limit", { message: "limit must be a positive integer." });
337
336
  const before = readStringParam(params, "before");
338
337
  const after = readStringParam(params, "after");
339
338
  return jsonResult({
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { i as withStartedActionClient, n as withResolvedActionClient } from "./client-BgsOzckO.js";
2
+ import { i as withStartedActionClient, n as withResolvedActionClient } from "./client-DxQ7tWJq.js";
3
3
  import { n as formatMatrixEncryptionUnavailableError } from "./encryption-guidance-CU-OAPMg.js";
4
4
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
@@ -305,11 +305,6 @@ const tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghik
305
305
  // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
306
306
  const tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
307
307
 
308
- function resetScanCache (self) {
309
- self.__index__ = -1;
310
- self.__text_cache__ = '';
311
- }
312
-
313
308
  function createValidator (re) {
314
309
  return function (text, pos) {
315
310
  const tail = text.slice(pos);
@@ -348,8 +343,11 @@ function compile (self) {
348
343
  function untpl (tpl) { return tpl.replace('%TLDS%', re.src_tlds) }
349
344
 
350
345
  re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
346
+ re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), 'ig');
351
347
  re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
348
+ re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), 'ig');
352
349
  re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
350
+ re.link_no_ip_fuzzy_global = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'ig');
353
351
  re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
354
352
 
355
353
  //
@@ -443,12 +441,6 @@ function compile (self) {
443
441
  '(' + self.re.schema_test.source + ')|(' + self.re.host_fuzzy_test.source + ')|@',
444
442
  'i'
445
443
  );
446
-
447
- //
448
- // Cleanup
449
- //
450
-
451
- resetScanCache(self);
452
444
  }
453
445
 
454
446
  /**
@@ -456,55 +448,45 @@ function compile (self) {
456
448
  *
457
449
  * Match result. Single element of array, returned by [[LinkifyIt#match]]
458
450
  **/
459
- function Match (self, shift) {
460
- const start = self.__index__;
461
- const end = self.__last_index__;
462
- const text = self.__text_cache__.slice(start, end);
451
+ function Match (text, schema, index, lastIndex) {
452
+ const raw = text.slice(index, lastIndex);
463
453
 
464
454
  /**
465
455
  * Match#schema -> String
466
456
  *
467
457
  * Prefix (protocol) for matched string.
468
458
  **/
469
- this.schema = self.__schema__.toLowerCase();
459
+ this.schema = schema.toLowerCase();
470
460
  /**
471
461
  * Match#index -> Number
472
462
  *
473
463
  * First position of matched string.
474
464
  **/
475
- this.index = start + shift;
465
+ this.index = index;
476
466
  /**
477
467
  * Match#lastIndex -> Number
478
468
  *
479
469
  * Next position after matched string.
480
470
  **/
481
- this.lastIndex = end + shift;
471
+ this.lastIndex = lastIndex;
482
472
  /**
483
473
  * Match#raw -> String
484
474
  *
485
475
  * Matched string.
486
476
  **/
487
- this.raw = text;
477
+ this.raw = raw;
488
478
  /**
489
479
  * Match#text -> String
490
480
  *
491
481
  * Notmalized text of matched string.
492
482
  **/
493
- this.text = text;
483
+ this.text = raw;
494
484
  /**
495
485
  * Match#url -> String
496
486
  *
497
487
  * Normalized url of matched string.
498
488
  **/
499
- this.url = text;
500
- }
501
-
502
- function createMatch (self, shift) {
503
- const match = new Match(self, shift);
504
-
505
- self.__compiled__[match.schema].normalize(match, self);
506
-
507
- return match
489
+ this.url = raw;
508
490
  }
509
491
 
510
492
  /**
@@ -559,12 +541,6 @@ function LinkifyIt (schemas, options) {
559
541
 
560
542
  this.__opts__ = assign({}, defaultOptions, options);
561
543
 
562
- // Cache last tested result. Used to skip repeating steps on next `match` call.
563
- this.__index__ = -1;
564
- this.__last_index__ = -1; // Next scan position
565
- this.__schema__ = '';
566
- this.__text_cache__ = '';
567
-
568
544
  this.__schemas__ = assign({}, defaultSchemas, schemas);
569
545
  this.__compiled__ = {};
570
546
 
@@ -606,69 +582,38 @@ LinkifyIt.prototype.set = function set (options) {
606
582
  * Searches linkifiable pattern and returns `true` on success or `false` on fail.
607
583
  **/
608
584
  LinkifyIt.prototype.test = function test (text) {
609
- // Reset scan cache
610
- this.__text_cache__ = text;
611
- this.__index__ = -1;
612
-
613
585
  if (!text.length) { return false }
614
586
 
615
- let m, ml, me, len, shift, next, re, tld_pos, at_pos;
587
+ let m, re;
616
588
 
617
589
  // try to scan for link with schema - that's the most simple rule
618
590
  if (this.re.schema_test.test(text)) {
619
591
  re = this.re.schema_search;
620
592
  re.lastIndex = 0;
621
593
  while ((m = re.exec(text)) !== null) {
622
- len = this.testSchemaAt(text, m[2], re.lastIndex);
623
- if (len) {
624
- this.__schema__ = m[2];
625
- this.__index__ = m.index + m[1].length;
626
- this.__last_index__ = m.index + m[0].length + len;
627
- break
628
- }
594
+ if (this.testSchemaAt(text, m[2], re.lastIndex)) { return true }
629
595
  }
630
596
  }
631
597
 
632
598
  if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
633
599
  // guess schemaless links
634
- tld_pos = text.search(this.re.host_fuzzy_test);
635
- if (tld_pos >= 0) {
636
- // if tld is located after found link - no need to check fuzzy pattern
637
- if (this.__index__ < 0 || tld_pos < this.__index__) {
638
- if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
639
- shift = ml.index + ml[1].length;
640
-
641
- if (this.__index__ < 0 || shift < this.__index__) {
642
- this.__schema__ = '';
643
- this.__index__ = shift;
644
- this.__last_index__ = ml.index + ml[0].length;
645
- }
646
- }
600
+ if (text.search(this.re.host_fuzzy_test) >= 0) {
601
+ if (text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy) !== null) {
602
+ return true
647
603
  }
648
604
  }
649
605
  }
650
606
 
651
607
  if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
652
608
  // guess schemaless emails
653
- at_pos = text.indexOf('@');
654
- if (at_pos >= 0) {
609
+ if (text.indexOf('@') >= 0) {
655
610
  // We can't skip this check, because this cases are possible:
656
611
  // 192.168.1.1@gmail.com, my.in@example.com
657
- if ((me = text.match(this.re.email_fuzzy)) !== null) {
658
- shift = me.index + me[1].length;
659
- next = me.index + me[0].length;
660
-
661
- if (this.__index__ < 0 || shift < this.__index__ ||
662
- (shift === this.__index__ && next > this.__last_index__)) {
663
- this.__schema__ = 'mailto:';
664
- this.__index__ = shift;
665
- this.__last_index__ = next;
666
- }
667
- }
612
+ if (text.match(this.re.email_fuzzy) !== null) { return true }
668
613
  }
669
614
  }
670
615
 
671
- return this.__index__ >= 0
616
+ return false
672
617
  };
673
618
 
674
619
  /**
@@ -717,23 +662,88 @@ LinkifyIt.prototype.testSchemaAt = function testSchemaAt (text, schema, pos) {
717
662
  **/
718
663
  LinkifyIt.prototype.match = function match (text) {
719
664
  const result = [];
720
- let shift = 0;
665
+ const type_schemed = [];
666
+ const type_fuzzy_link = [];
667
+ const type_fuzzy_email = [];
668
+ let m, len, re;
669
+
670
+ function choose (a, b) {
671
+ if (!a) { return b }
672
+ if (!b) { return a }
673
+ if (a.index !== b.index) { return a.index < b.index ? a : b }
674
+ return a.lastIndex >= b.lastIndex ? a : b
675
+ }
676
+
677
+ if (!text.length) { return null }
678
+
679
+ // scan for links with schema
680
+ if (this.re.schema_test.test(text)) {
681
+ re = this.re.schema_search;
682
+ re.lastIndex = 0;
683
+ while ((m = re.exec(text)) !== null) {
684
+ len = this.testSchemaAt(text, m[2], re.lastIndex);
685
+ if (len) {
686
+ type_schemed.push({
687
+ schema: m[2],
688
+ index: m.index + m[1].length,
689
+ lastIndex: m.index + m[0].length + len
690
+ });
691
+ }
692
+ }
693
+ }
721
694
 
722
- // Try to take previous element from cache, if .test() called before
723
- if (this.__index__ >= 0 && this.__text_cache__ === text) {
724
- result.push(createMatch(this, shift));
725
- shift = this.__last_index__;
695
+ if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
696
+ re = this.__opts__.fuzzyIP ? this.re.link_fuzzy_global : this.re.link_no_ip_fuzzy_global;
697
+ re.lastIndex = 0;
698
+ while ((m = re.exec(text)) !== null) {
699
+ type_fuzzy_link.push({
700
+ schema: '',
701
+ index: m.index + m[1].length,
702
+ lastIndex: m.index + m[0].length
703
+ });
704
+ }
726
705
  }
727
706
 
728
- // Cut head if cache was used
729
- let tail = shift ? text.slice(shift) : text;
707
+ if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
708
+ re = this.re.email_fuzzy_global;
709
+ re.lastIndex = 0;
710
+ while ((m = re.exec(text)) !== null) {
711
+ type_fuzzy_email.push({
712
+ schema: 'mailto:',
713
+ index: m.index + m[1].length,
714
+ lastIndex: m.index + m[0].length
715
+ });
716
+ }
717
+ }
718
+
719
+ const indexes = [0, 0, 0];
720
+ let lastIndex = 0;
721
+
722
+ for (;;) {
723
+ const candidates = [
724
+ type_schemed[indexes[0]],
725
+ type_fuzzy_email[indexes[1]],
726
+ type_fuzzy_link[indexes[2]]
727
+ ];
728
+
729
+ const candidate = choose(choose(candidates[0], candidates[1]), candidates[2]);
730
730
 
731
- // Scan string until end reached
732
- while (this.test(tail)) {
733
- result.push(createMatch(this, shift));
731
+ if (!candidate) { break }
734
732
 
735
- tail = tail.slice(this.__last_index__);
736
- shift += this.__last_index__;
733
+ if (candidate === candidates[0]) {
734
+ indexes[0]++;
735
+ } else if (candidate === candidates[1]) {
736
+ indexes[1]++;
737
+ } else {
738
+ indexes[2]++;
739
+ }
740
+
741
+ if (candidate.index < lastIndex) { continue }
742
+
743
+ const match = new Match(text, candidate.schema, candidate.index, candidate.lastIndex);
744
+ this.__compiled__[match.schema].normalize(match, this);
745
+ result.push(match);
746
+ lastIndex = candidate.lastIndex;
737
747
  }
738
748
 
739
749
  if (result.length) {
@@ -750,10 +760,6 @@ LinkifyIt.prototype.match = function match (text) {
750
760
  * of the string, and null otherwise.
751
761
  **/
752
762
  LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
753
- // Reset scan cache
754
- this.__text_cache__ = text;
755
- this.__index__ = -1;
756
-
757
763
  if (!text.length) return null
758
764
 
759
765
  const m = this.re.schema_at_start.exec(text);
@@ -762,11 +768,10 @@ LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
762
768
  const len = this.testSchemaAt(text, m[2], m[0].length);
763
769
  if (!len) return null
764
770
 
765
- this.__schema__ = m[2];
766
- this.__index__ = m.index + m[1].length;
767
- this.__last_index__ = m.index + m[0].length + len;
771
+ const match = new Match(text, m[2], m.index + m[1].length, m.index + m[0].length + len);
768
772
 
769
- return createMatch(this, 0)
773
+ this.__compiled__[match.schema].normalize(match, this);
774
+ return match
770
775
  };
771
776
 
772
777
  /** chainable