1
- import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib'
2
1
3
2
export type ClassRegexEntry = string | [ string ] | [ string , string ]
4
- export type ClassRegex = [ container : Regex , cls ?: Regex ]
3
+ export type ClassRegex = [ container : RegExp , cls ?: RegExp ]
5
4
export interface ClassMatch {
6
5
classList : string
7
6
}
@@ -16,7 +15,7 @@ export function customClassesIn(
16
15
? pattern
17
16
: [ pattern ]
18
17
19
- let regexes = normalized . map ( ( pattern ) => new Regex ( pattern , 'g ' ) )
18
+ let regexes = normalized . map ( ( pattern ) => new RegExp ( pattern , 'gd ' ) )
20
19
21
20
let match = firstMatchIn ( str , cursor , regexes as ClassRegex )
22
21
@@ -33,10 +32,10 @@ function firstMatchIn(
33
32
cursor : number ,
34
33
[ containerRegex , classRegex ] : ClassRegex ,
35
34
) : ClassMatch | null {
36
- let containerMatch : ReturnType < Regex [ 'exec' ] >
35
+ let containerMatch : ReturnType < RegExp [ 'exec' ] >
37
36
38
37
while ( ( containerMatch = containerRegex . exec ( str ) ) !== null ) {
39
- const matchStart = containerMatch . index [ 1 ]
38
+ const matchStart = containerMatch . indices [ 1 ] [ 0 ]
40
39
const matchEnd = matchStart + containerMatch [ 1 ] . length
41
40
42
41
// Cursor is outside of the match
@@ -51,10 +50,10 @@ function firstMatchIn(
51
50
}
52
51
53
52
// Handle class matches inside the "container"
54
- let classMatch : ReturnType < Regex [ 'exec' ] >
53
+ let classMatch : ReturnType < RegExp [ 'exec' ] >
55
54
56
55
while ( ( classMatch = classRegex . exec ( containerMatch [ 1 ] ) ) !== null ) {
57
- const classMatchStart = matchStart + classMatch . index [ 1 ]
56
+ const classMatchStart = matchStart + classMatch . indices [ 1 ] [ 0 ]
58
57
const classMatchEnd = classMatchStart + classMatch [ 1 ] . length
59
58
60
59
// Cursor is outside of the match
0 commit comments