@@ -25,14 +25,14 @@ import type {
25
25
} from 'estree-jsx'
26
26
import type {
27
27
BlockContent ,
28
- PhrasingContent ,
29
28
Literal as MdastLiteral ,
29
+ PhrasingContent ,
30
+ Root ,
30
31
} from 'mdast'
31
32
import type { Options } from 'micromark-extension-mdx-expression'
32
- import type { Root } from 'remark-mdx'
33
33
import { extractProperties , runAsWorker } from 'synckit'
34
- import type { FrozenProcessor } from 'unified'
35
- import type { Config , Configuration } from 'unified-engine/lib/configuration '
34
+ import type { Processor } from 'unified'
35
+ import type { Configuration , ConfigResult } from 'unified-engine'
36
36
import type { Node } from 'unist'
37
37
import { ok as assert } from 'uvu/assert'
38
38
import type { VFileMessage } from 'vfile-message'
@@ -60,13 +60,16 @@ let tt: Record<string, TokenType> & typeof _tokTypes
60
60
61
61
let TokenTranslator : typeof import ( 'espree/lib/token-translator' ) [ 'default' ]
62
62
63
- export const processorCache = new Map < string , FrozenProcessor > ( )
63
+ export const processorCache = new Map <
64
+ string ,
65
+ Processor < Root , undefined , undefined , Root , string >
66
+ > ( )
64
67
65
68
const getRemarkConfig = async ( searchFrom : string ) => {
66
69
if ( ! config ) {
67
70
const { Configuration } = await loadEsmModule <
68
- typeof import ( 'unified-engine/lib/configuration ' )
69
- > ( 'unified-engine/lib/configuration.js ' )
71
+ typeof import ( 'unified-engine' )
72
+ > ( 'unified-engine' )
70
73
config = new Configuration ( {
71
74
cwd : process . cwd ( ) ,
72
75
packageField : 'remarkConfig' ,
@@ -76,10 +79,10 @@ const getRemarkConfig = async (searchFrom: string) => {
76
79
} )
77
80
}
78
81
79
- return new Promise < Config > ( ( resolve , reject ) =>
80
- config . load ( searchFrom , ( error , result ) =>
81
- error ? reject ( error ) : resolve ( result ) ,
82
- ) ,
82
+ return new Promise < ConfigResult > ( ( resolve , reject ) =>
83
+ config . load ( searchFrom , ( error , result ) => {
84
+ error ? reject ( error ) : resolve ( result )
85
+ } ) ,
83
86
)
84
87
}
85
88
@@ -270,7 +273,7 @@ runAsWorker(
270
273
const text = fileOptions . value as string
271
274
const tokenTranslator = new TokenTranslator ( tt , text )
272
275
273
- const root = processor . parse ( fileOptions ) as Root
276
+ const root = processor . parse ( fileOptions )
274
277
275
278
const body : Program [ 'body' ] = [ ]
276
279
const comments : Comment [ ] = [ ]
@@ -372,7 +375,7 @@ runAsWorker(
372
375
processed . add ( child )
373
376
374
377
if ( child . data && 'estree' in child . data && child . data . estree ) {
375
- const estree = child . data . estree as Program
378
+ const { estree } = child . data
376
379
377
380
assert ( estree . body . length <= 1 )
378
381
@@ -638,7 +641,9 @@ runAsWorker(
638
641
} )
639
642
}
640
643
641
- const estree = ( node . data ?. estree || {
644
+ const estree = ( ( node . data &&
645
+ 'estree' in node . data &&
646
+ node . data . estree ) || {
642
647
body : [ ] ,
643
648
comments : [ ] ,
644
649
} ) as Program
0 commit comments