@shikijs/engine-javascript 1.24.2 → 1.24.4
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/README.md +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.mjs +12 -12
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @shikijs/engine-javascript
|
|
2
2
|
|
|
3
|
-
Engine for Shiki using JavaScript's native RegExp
|
|
3
|
+
Engine for Shiki using JavaScript's native RegExp. Uses [Oniguruma-To-ES](https://github.com/slevithan/oniguruma-to-es) to transpile regex syntax and behavior.
|
|
4
4
|
|
|
5
5
|
[Documentation](https://shiki.style/guide/regex-engines)
|
|
6
6
|
|
package/dist/index.d.mts
CHANGED
|
@@ -45,7 +45,7 @@ declare class JavaScriptScanner implements PatternScanner {
|
|
|
45
45
|
options: JavaScriptRegexEngineOptions;
|
|
46
46
|
regexps: (RegExp | null)[];
|
|
47
47
|
constructor(patterns: string[], options?: JavaScriptRegexEngineOptions);
|
|
48
|
-
findNextMatchSync(string: string | RegexEngineString, startPosition: number): IOnigMatch | null;
|
|
48
|
+
findNextMatchSync(string: string | RegexEngineString, startPosition: number, _options: number): IOnigMatch | null;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Use the modern JavaScript RegExp engine to implement the OnigScanner.
|
|
@@ -54,8 +54,6 @@ declare class JavaScriptScanner implements PatternScanner {
|
|
|
54
54
|
* patterns are not supported. Errors will be thrown when parsing TextMate grammars with
|
|
55
55
|
* unsupported patterns, and when the grammar includes patterns that use invalid Oniguruma syntax.
|
|
56
56
|
* Set `forgiving` to `true` to ignore these errors and skip any unsupported or invalid patterns.
|
|
57
|
-
*
|
|
58
|
-
* @experimental
|
|
59
57
|
*/
|
|
60
58
|
declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
|
|
61
59
|
|
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ declare class JavaScriptScanner implements PatternScanner {
|
|
|
45
45
|
options: JavaScriptRegexEngineOptions;
|
|
46
46
|
regexps: (RegExp | null)[];
|
|
47
47
|
constructor(patterns: string[], options?: JavaScriptRegexEngineOptions);
|
|
48
|
-
findNextMatchSync(string: string | RegexEngineString, startPosition: number): IOnigMatch | null;
|
|
48
|
+
findNextMatchSync(string: string | RegexEngineString, startPosition: number, _options: number): IOnigMatch | null;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Use the modern JavaScript RegExp engine to implement the OnigScanner.
|
|
@@ -54,8 +54,6 @@ declare class JavaScriptScanner implements PatternScanner {
|
|
|
54
54
|
* patterns are not supported. Errors will be thrown when parsing TextMate grammars with
|
|
55
55
|
* unsupported patterns, and when the grammar includes patterns that use invalid Oniguruma syntax.
|
|
56
56
|
* Set `forgiving` to `true` to ignore these errors and skip any unsupported or invalid patterns.
|
|
57
|
-
*
|
|
58
|
-
* @experimental
|
|
59
57
|
*/
|
|
60
58
|
declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
|
|
61
59
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { toRegExp } from 'oniguruma-to-es';
|
|
2
2
|
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
-
var __publicField = (obj, key, value) => {
|
|
6
|
-
__defNormalProp(obj, key + "" , value);
|
|
7
|
-
return value;
|
|
8
|
-
};
|
|
9
3
|
const MAX = 4294967295;
|
|
10
4
|
function defaultJavaScriptRegexConstructor(pattern, options) {
|
|
11
5
|
return toRegExp(
|
|
@@ -14,9 +8,15 @@ function defaultJavaScriptRegexConstructor(pattern, options) {
|
|
|
14
8
|
global: true,
|
|
15
9
|
hasIndices: true,
|
|
16
10
|
rules: {
|
|
11
|
+
// Needed since TextMate grammars merge backrefs across patterns
|
|
17
12
|
allowOrphanBackrefs: true,
|
|
13
|
+
// Removing `\G` anchors in cases when they're not supported for emulation allows
|
|
14
|
+
// supporting more grammars, but also allows some mismatches
|
|
18
15
|
allowUnhandledGAnchors: true,
|
|
19
|
-
|
|
16
|
+
// Improves search performance for generated regexes
|
|
17
|
+
asciiWordBoundaries: true,
|
|
18
|
+
// Follow `vscode-oniguruma` which enables this Oniguruma option by default
|
|
19
|
+
captureGroup: true
|
|
20
20
|
},
|
|
21
21
|
...options
|
|
22
22
|
}
|
|
@@ -26,7 +26,6 @@ class JavaScriptScanner {
|
|
|
26
26
|
constructor(patterns, options = {}) {
|
|
27
27
|
this.patterns = patterns;
|
|
28
28
|
this.options = options;
|
|
29
|
-
__publicField(this, "regexps");
|
|
30
29
|
const {
|
|
31
30
|
forgiving = false,
|
|
32
31
|
cache,
|
|
@@ -55,7 +54,8 @@ class JavaScriptScanner {
|
|
|
55
54
|
}
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
|
-
|
|
57
|
+
regexps;
|
|
58
|
+
findNextMatchSync(string, startPosition, _options) {
|
|
59
59
|
const str = typeof string === "string" ? string : string.content;
|
|
60
60
|
const pending = [];
|
|
61
61
|
function toResult(index, match, offset = 0) {
|
|
@@ -64,15 +64,15 @@ class JavaScriptScanner {
|
|
|
64
64
|
captureIndices: match.indices.map((indice) => {
|
|
65
65
|
if (indice == null) {
|
|
66
66
|
return {
|
|
67
|
-
end: MAX,
|
|
68
67
|
start: MAX,
|
|
68
|
+
end: MAX,
|
|
69
69
|
length: 0
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
return {
|
|
73
73
|
start: indice[0] + offset,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
end: indice[1] + offset,
|
|
75
|
+
length: indice[1] - indice[0]
|
|
76
76
|
};
|
|
77
77
|
})
|
|
78
78
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/engine-javascript",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.24.
|
|
4
|
+
"version": "1.24.4",
|
|
5
5
|
"description": "Engine for Shiki using JavaScript's native RegExp",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@shikijs/vscode-textmate": "^9.3.
|
|
34
|
-
"oniguruma-to-es": "0.
|
|
35
|
-
"@shikijs/types": "1.24.
|
|
33
|
+
"@shikijs/vscode-textmate": "^9.3.1",
|
|
34
|
+
"oniguruma-to-es": "0.8.1",
|
|
35
|
+
"@shikijs/types": "1.24.4"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "unbuild",
|