@openclaw/matrix 2026.5.27 → 2026.5.28-beta.1
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/dist/api.js +4 -4
- package/dist/{approval-handler.runtime-D2nZfRw6.js → approval-handler.runtime-DluqYmxg.js} +7 -37
- package/dist/{approval-ids-DzBw_AG3.js → approval-ids-CFZrzmvI.js} +1 -1
- package/dist/{approval-reaction-auth-BvK3dXMH.js → approval-reaction-auth-D0qxpl_o.js} +2 -2
- package/dist/{channel-BLuA_9If.js → channel-NWX4upHC.js} +15 -15
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-CCAsyp75.js → channel.runtime-Bj0ZZFxY.js} +7 -7
- package/dist/{cli-Bo50M7l4.js → cli-CLRLY_-i.js} +15 -14
- package/dist/{cli-metadata-CqUHNx_0.js → cli-metadata-3lBoQ4Zu.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{client-QO7vDxm0.js → client-DMLL7BD3.js} +2 -2
- package/dist/{client-BgsOzckO.js → client-PgC6QxFp.js} +2 -2
- package/dist/{client-bootstrap-DK9i3KZ5.js → client-bootstrap-DDWICVDG.js} +1 -1
- package/dist/{config-schema-DuSRVdwT.js → config-schema-DLcRkLoI.js} +1 -1
- package/dist/contract-api.js +3 -3
- package/dist/{create-client-hdBEoEIm.js → create-client-DuDqSLm5.js} +2 -2
- package/dist/{crypto-runtime-BcQzS9DV.js → crypto-runtime-DW4yyphN.js} +4 -4
- package/dist/{deps-CAdiytPJ.js → deps-BVWGd2XS.js} +12 -2
- package/dist/{directory-live-2-Vb6nss.js → directory-live-B1uWLPJc.js} +2 -2
- package/dist/{doctor-qLh9PyE4.js → doctor-CENc9ks0.js} +1 -1
- package/dist/{draft-stream-BBVqdEbn.js → draft-stream-CQOHHA1L.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{legacy-crypto-inspector-BRdo-WqV.js → legacy-crypto-inspector-tJOj25VL.js} +1 -1
- package/dist/{logging-BR-gcAjp.js → logging-Bs8MnTq3.js} +2 -9
- package/dist/{matrix-migration.runtime-BhJb4ZII.js → matrix-migration.runtime-CZOep_JX.js} +1 -1
- package/dist/{media-text-C6q1S0AJ.js → media-text-Bl2T_Tej.js} +1 -1
- package/dist/{messages-D-VxmWkC.js → messages-IJd7lTpT.js} +3 -3
- package/dist/{monitor-DO1yiHWm.js → monitor-BtYrCwXE.js} +24 -25
- package/dist/plugin-entry.handlers.runtime.js +1 -1
- package/dist/probe.runtime-DFzGeW9y.js +3 -0
- package/dist/{profile-update-B_LpeC8E.js → profile-update--OKomd5A.js} +2 -2
- package/dist/{reaction-events-BefH3-Gu.js → reaction-events-Cw229qBs.js} +1 -1
- package/dist/recovery-key-store-0i4do66_.js +294 -0
- package/dist/{resolve-targets-BPhBqXyj.js → resolve-targets-DICyeq1_.js} +1 -1
- package/dist/{resolver.runtime-BOS3foyc.js → resolver.runtime-BiecZkY9.js} +1 -1
- package/dist/{runtime-api-B-jlPE4A.js → runtime-api-CsF7Kokd.js} +2 -2
- package/dist/runtime-api.js +1 -1
- package/dist/runtime-heavy-api.js +1 -1
- package/dist/{sdk-BKBZkPKt.js → sdk-Bb6cggYW.js} +8 -303
- package/dist/{send-DivaFHb1.js → send-6c-_Pb_x.js} +1 -1
- package/dist/{setup-bootstrap-ClcP-tDQ.js → setup-bootstrap-DO6nQjiO.js} +2 -2
- package/dist/{setup-core-s8s_Qudu.js → setup-core-CcMpf9nt.js} +1 -1
- package/dist/setup-plugin-api.js +3 -3
- package/dist/{setup-surface-BOt10HNf.js → setup-surface-eTmNGZRP.js} +5 -5
- package/dist/{shared-3K27tl8e.js → shared-cY7hRlYO.js} +111 -4
- package/dist/{thread-bindings-CLjJrThw.js → thread-bindings-LZukDWcn.js} +1 -1
- package/dist/{tool-actions.runtime-Vky1krcK.js → tool-actions.runtime-DmgBERwn.js} +20 -21
- package/dist/{verification-Dar6QON4.js → verification-aUpgCdQU.js} +1 -1
- package/node_modules/linkify-it/build/index.cjs.js +99 -94
- package/node_modules/linkify-it/index.mjs +99 -94
- package/node_modules/linkify-it/package.json +11 -1
- package/node_modules/markdown-it/README.md +13 -17
- package/node_modules/markdown-it/dist/index.cjs.js +111 -31
- package/node_modules/markdown-it/dist/markdown-it.js +117 -31
- package/node_modules/markdown-it/dist/markdown-it.min.js +2 -2
- package/node_modules/markdown-it/lib/common/utils.mjs +30 -1
- package/node_modules/markdown-it/lib/index.mjs +1 -1
- package/node_modules/markdown-it/lib/rules_block/heading.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_block/html_block.mjs +12 -1
- package/node_modules/markdown-it/lib/rules_block/lheading.mjs +4 -1
- package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +3 -1
- package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +37 -21
- package/node_modules/markdown-it/lib/rules_inline/entity.mjs +2 -2
- package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +37 -6
- package/node_modules/markdown-it/package.json +14 -3
- package/node_modules/matrix-js-sdk/CHANGELOG.md +7 -0
- package/node_modules/matrix-js-sdk/package.json +1 -1
- package/npm-shrinkwrap.json +35 -15
- package/package.json +6 -6
- package/dist/probe.runtime-9S17Q3Mo.js +0 -3
- package/dist/startup-abort-Bs0Up_Qx.js +0 -109
- 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-
|
|
3
|
-
import { E as parsePollStart, T as isPollStartType, b as buildPollResponseContent, i as reactMatrixMessage, u as resolveMatrixRoomId } from "./send-
|
|
2
|
+
import "./setup-core-CcMpf9nt.js";
|
|
3
|
+
import { E as parsePollStart, T as isPollStartType, b as buildPollResponseContent, i as reactMatrixMessage, u as resolveMatrixRoomId } from "./send-6c-_Pb_x.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-
|
|
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-
|
|
7
|
-
import { a as jsonResult, c as readStringArrayParam, l as readStringParam, o as
|
|
8
|
-
import { t as applyMatrixProfileUpdate } from "./profile-update
|
|
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-
|
|
5
|
+
import { n as withResolvedActionClient, r as withResolvedRoomAction } from "./client-PgC6QxFp.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-IJd7lTpT.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--OKomd5A.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-aUpgCdQU.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
|
|
226
|
-
const { integer = false } = options;
|
|
225
|
+
function readPositiveIntegerArrayParam(params, key) {
|
|
227
226
|
const raw = readRawParam(params, key);
|
|
228
|
-
if (raw
|
|
229
|
-
return (Array.isArray(raw) ? raw : [raw]).
|
|
230
|
-
if (
|
|
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
|
|
234
|
-
|
|
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
|
-
|
|
238
|
-
|
|
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 =
|
|
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 =
|
|
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 = [...
|
|
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 =
|
|
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-
|
|
2
|
+
import { i as withStartedActionClient, n as withResolvedActionClient } from "./client-PgC6QxFp.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 (
|
|
460
|
-
const
|
|
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 =
|
|
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 =
|
|
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 =
|
|
471
|
+
this.lastIndex = lastIndex;
|
|
482
472
|
/**
|
|
483
473
|
* Match#raw -> String
|
|
484
474
|
*
|
|
485
475
|
* Matched string.
|
|
486
476
|
**/
|
|
487
|
-
this.raw =
|
|
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 =
|
|
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 =
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
635
|
-
|
|
636
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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
|
-
|
|
729
|
-
|
|
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
|
-
|
|
732
|
-
while (this.test(tail)) {
|
|
733
|
-
result.push(createMatch(this, shift));
|
|
731
|
+
if (!candidate) { break }
|
|
734
732
|
|
|
735
|
-
|
|
736
|
-
|
|
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
|
-
|
|
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
|
-
|
|
773
|
+
this.__compiled__[match.schema].normalize(match, this);
|
|
774
|
+
return match
|
|
770
775
|
};
|
|
771
776
|
|
|
772
777
|
/** chainable
|