1
1
use std:: collections:: HashMap ;
2
2
use std:: fmt:: Debug ;
3
+ use std:: sync:: Arc ;
3
4
4
5
use napi:: bindgen_prelude:: Either4 ;
5
6
use napi_derive:: napi;
6
- use rspack_core :: ExternalItemFnCtx ;
7
+ use rspack_binding_values :: JsResolver ;
7
8
use rspack_core:: { ExternalItem , ExternalItemFnResult , ExternalItemValue } ;
9
+ use rspack_core:: { ExternalItemFnCtx , ResolveOptionsWithDependencyType , ResolverFactory } ;
10
+ // use rspack_napi::regexp::{JsRegExp, JsRegExpExt};
8
11
use rspack_napi:: threadsafe_function:: ThreadsafeFunction ;
9
12
use rspack_regex:: RspackRegex ;
10
13
@@ -68,15 +71,47 @@ pub struct ContextInfo {
68
71
pub issuer : String ,
69
72
}
70
73
71
- #[ derive( Debug , Clone ) ]
72
- #[ napi( object ) ]
74
+ #[ derive( Debug ) ]
75
+ #[ napi]
73
76
pub struct RawExternalItemFnCtx {
77
+ request : String ,
78
+ context : String ,
79
+ dependency_type : String ,
80
+ context_info : ContextInfo ,
81
+ resolve_options_with_dependency_type : ResolveOptionsWithDependencyType ,
82
+ resolver_factory : Arc < ResolverFactory > ,
83
+ }
84
+
85
+ #[ derive( Debug ) ]
86
+ #[ napi( object) ]
87
+ pub struct RawExternalItemFnCtxData {
74
88
pub request : String ,
75
89
pub context : String ,
76
90
pub dependency_type : String ,
77
91
pub context_info : ContextInfo ,
78
92
}
79
93
94
+ #[ napi]
95
+ impl RawExternalItemFnCtx {
96
+ #[ napi]
97
+ pub fn data ( & self ) -> RawExternalItemFnCtxData {
98
+ RawExternalItemFnCtxData {
99
+ request : self . request . clone ( ) ,
100
+ context : self . context . clone ( ) ,
101
+ dependency_type : self . dependency_type . clone ( ) ,
102
+ context_info : self . context_info . clone ( ) ,
103
+ }
104
+ }
105
+
106
+ #[ napi]
107
+ pub fn get_resolver ( & self ) -> JsResolver {
108
+ JsResolver :: new (
109
+ self . resolver_factory . clone ( ) ,
110
+ self . resolve_options_with_dependency_type . clone ( ) ,
111
+ )
112
+ }
113
+ }
114
+
80
115
impl From < ExternalItemFnCtx > for RawExternalItemFnCtx {
81
116
fn from ( value : ExternalItemFnCtx ) -> Self {
82
117
Self {
@@ -86,6 +121,8 @@ impl From<ExternalItemFnCtx> for RawExternalItemFnCtx {
86
121
context_info : ContextInfo {
87
122
issuer : value. context_info . issuer ,
88
123
} ,
124
+ resolve_options_with_dependency_type : value. resolve_options_with_dependency_type ,
125
+ resolver_factory : value. resolver_factory ,
89
126
}
90
127
}
91
128
}
0 commit comments