@shikijs/engine-javascript 2.5.0 → 3.1.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shikijs/engine-javascript",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "3.1.0",
5
5
  "description": "Engine for Shiki using JavaScript's native RegExp",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -18,14 +18,8 @@
18
18
  ],
19
19
  "sideEffects": false,
20
20
  "exports": {
21
- ".": {
22
- "types": "./dist/index.d.mts",
23
- "default": "./dist/index.mjs"
24
- },
25
- "./raw": {
26
- "types": "./dist/engine-raw.d.mts",
27
- "default": "./dist/engine-raw.mjs"
28
- }
21
+ ".": "./dist/index.mjs",
22
+ "./raw": "./dist/engine-raw.mjs"
29
23
  },
30
24
  "main": "./dist/index.mjs",
31
25
  "module": "./dist/index.mjs",
@@ -35,8 +29,8 @@
35
29
  ],
36
30
  "dependencies": {
37
31
  "@shikijs/vscode-textmate": "^10.0.2",
38
- "oniguruma-to-es": "^3.1.0",
39
- "@shikijs/types": "2.5.0"
32
+ "oniguruma-to-es": "^3.1.1",
33
+ "@shikijs/types": "3.1.0"
40
34
  },
41
35
  "scripts": {
42
36
  "build": "unbuild",
@@ -1,4 +0,0 @@
1
- import '@shikijs/types';
2
- import 'oniguruma-to-es';
3
- export { J as JavaScriptRegexEngineOptions, c as createJavaScriptRegexEngine, d as defaultJavaScriptRegexConstructor } from './shared/engine-javascript.BnuFKbIS.js';
4
- import '@shikijs/vscode-textmate';
@@ -1,12 +0,0 @@
1
- import { RegexEngine } from '@shikijs/types';
2
-
3
- /**
4
- * Raw JavaScript regex engine that only supports precompiled grammars.
5
- *
6
- * This further simplifies the engine by excluding the regex compilation step.
7
- *
8
- * Zero dependencies.
9
- */
10
- declare function createJavaScriptRawEngine(): RegexEngine;
11
-
12
- export { createJavaScriptRawEngine };
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { J as JavaScriptRegexEngineOptions, a as JavaScriptRegexScannerOptions, b as JavaScriptScanner, c as createJavaScriptRegexEngine, d as defaultJavaScriptRegexConstructor } from './shared/engine-javascript.BnuFKbIS.js';
2
- export { createJavaScriptRawEngine } from './engine-raw.js';
3
- import '@shikijs/types';
4
- import 'oniguruma-to-es';
5
- import '@shikijs/vscode-textmate';
@@ -1,62 +0,0 @@
1
- import { PatternScanner, RegexEngineString, RegexEngine } from '@shikijs/types';
2
- import { ToRegExpOptions } from 'oniguruma-to-es';
3
- import { IOnigMatch } from '@shikijs/vscode-textmate';
4
-
5
- interface JavaScriptRegexScannerOptions {
6
- /**
7
- * Whether to allow invalid regex patterns.
8
- *
9
- * @default false
10
- */
11
- forgiving?: boolean;
12
- /**
13
- * Cache for regex patterns.
14
- */
15
- cache?: Map<string, RegExp | Error> | null;
16
- /**
17
- * Custom pattern to RegExp constructor.
18
- *
19
- * By default `oniguruma-to-es` is used.
20
- */
21
- regexConstructor?: (pattern: string) => RegExp;
22
- }
23
- declare class JavaScriptScanner implements PatternScanner {
24
- patterns: (string | RegExp)[];
25
- options: JavaScriptRegexScannerOptions;
26
- regexps: (RegExp | null)[];
27
- constructor(patterns: (string | RegExp)[], options?: JavaScriptRegexScannerOptions);
28
- findNextMatchSync(string: string | RegexEngineString, startPosition: number, _options: number): IOnigMatch | null;
29
- }
30
-
31
- interface JavaScriptRegexEngineOptions extends JavaScriptRegexScannerOptions {
32
- /**
33
- * The target ECMAScript version.
34
- *
35
- * Oniguruma-To-ES uses RegExp features from later versions of ECMAScript to add support for a
36
- * few more grammars. If using target `ES2024` or later, the RegExp `v` flag is used which
37
- * requires Node.js 20+ or Chrome 112+.
38
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets
39
- *
40
- * For maximum compatibility, you can set it to `ES2018` which uses the RegExp `u` flag.
41
- *
42
- * Set to `auto` to automatically detect the latest version supported by the environment.
43
- *
44
- * @default 'auto'
45
- */
46
- target?: 'auto' | 'ES2025' | 'ES2024' | 'ES2018';
47
- }
48
- /**
49
- * The default regex constructor for the JavaScript RegExp engine.
50
- */
51
- declare function defaultJavaScriptRegexConstructor(pattern: string, options?: ToRegExpOptions): RegExp;
52
- /**
53
- * Use the modern JavaScript RegExp engine to implement the OnigScanner.
54
- *
55
- * As Oniguruma supports some features that can't be emulated using native JavaScript regexes, some
56
- * patterns are not supported. Errors will be thrown when parsing TextMate grammars with
57
- * unsupported patterns, and when the grammar includes patterns that use invalid Oniguruma syntax.
58
- * Set `forgiving` to `true` to ignore these errors and skip any unsupported or invalid patterns.
59
- */
60
- declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
61
-
62
- export { type JavaScriptRegexEngineOptions as J, type JavaScriptRegexScannerOptions as a, JavaScriptScanner as b, createJavaScriptRegexEngine as c, defaultJavaScriptRegexConstructor as d };