@shikijs/engine-javascript 1.17.5 → 1.17.6
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/index.mjs +20 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { onigurumaToRegexp } from 'oniguruma-to-js';
|
|
2
2
|
|
|
3
|
+
const replacements = [
|
|
4
|
+
[
|
|
5
|
+
"(?<square>[^\\[\\]\\\\]|\\\\.|\\[\\g<square>*+\\])",
|
|
6
|
+
"(?<square>[^\\[\\]\\\\]|\\\\.|\\[(?:[^\\[\\]\\\\]|\\\\.|\\[(?:[^\\[\\]\\\\]|\\\\.|\\[(?:[^\\[\\]\\\\])*+\\])*+\\])*+\\])"
|
|
7
|
+
],
|
|
8
|
+
[
|
|
9
|
+
"(?<url>(?>[^\\s()]+)|\\(\\g<url>*\\))",
|
|
10
|
+
"(?<url>(?>[^\\s()]+)|\\((?:(?>[^\\s()]+)|\\((?:(?>[^\\s()]+)|\\((?>[^\\s()]+)*\\))*\\))*\\))"
|
|
11
|
+
]
|
|
12
|
+
];
|
|
13
|
+
|
|
3
14
|
var __defProp = Object.defineProperty;
|
|
4
15
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
16
|
var __publicField = (obj, key, value) => {
|
|
@@ -30,6 +41,8 @@ class JavaScriptScanner {
|
|
|
30
41
|
} = options;
|
|
31
42
|
this.contiguousAnchorSimulation = Array.from({ length: patterns.length }, () => false);
|
|
32
43
|
this.regexps = patterns.map((p, idx) => {
|
|
44
|
+
if (simulation)
|
|
45
|
+
p = p.replaceAll("(^|\\\uFFFF)", "(^|\\G)");
|
|
33
46
|
if (simulation && (p.startsWith("(^|\\G)") || p.startsWith("(\\G|^)")))
|
|
34
47
|
this.contiguousAnchorSimulation[idx] = true;
|
|
35
48
|
const cached = cache?.get(p);
|
|
@@ -42,7 +55,13 @@ class JavaScriptScanner {
|
|
|
42
55
|
throw cached;
|
|
43
56
|
}
|
|
44
57
|
try {
|
|
45
|
-
|
|
58
|
+
let pattern = p;
|
|
59
|
+
if (simulation) {
|
|
60
|
+
for (const [from, to] of replacements) {
|
|
61
|
+
pattern = pattern.replaceAll(from, to);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const regex = regexConstructor(pattern);
|
|
46
65
|
cache?.set(p, regex);
|
|
47
66
|
return regex;
|
|
48
67
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/engine-javascript",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.17.
|
|
4
|
+
"version": "1.17.6",
|
|
5
5
|
"description": "Engine for Shiki using JavaScript's native RegExp",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"oniguruma-to-js": "0.4.
|
|
34
|
-
"@shikijs/types": "1.17.
|
|
33
|
+
"oniguruma-to-js": "0.4.3",
|
|
34
|
+
"@shikijs/types": "1.17.6"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "unbuild",
|