1
1
use std:: ops:: Deref ;
2
2
3
3
use napi:: { bindgen_prelude:: External , JsFunction } ;
4
- use next_api:: route:: { Endpoint , WrittenEndpoint } ;
4
+ use next_api:: {
5
+ route:: { Endpoint , WrittenEndpoint } ,
6
+ server_paths:: ServerPath ,
7
+ } ;
5
8
use turbo_tasks:: Vc ;
6
9
use turbopack_binding:: turbopack:: core:: error:: PrettyPrintError ;
7
10
@@ -14,12 +17,28 @@ use super::utils::{
14
17
#[ derive( Default ) ]
15
18
pub struct NapiEndpointConfig { }
16
19
20
+ #[ napi( object) ]
21
+ #[ derive( Default ) ]
22
+ pub struct NapiServerPath {
23
+ pub path : String ,
24
+ pub content_hash : String ,
25
+ }
26
+
27
+ impl From < & ServerPath > for NapiServerPath {
28
+ fn from ( server_path : & ServerPath ) -> Self {
29
+ Self {
30
+ path : server_path. path . clone ( ) ,
31
+ content_hash : format ! ( "{:x}" , server_path. content_hash) ,
32
+ }
33
+ }
34
+ }
35
+
17
36
#[ napi( object) ]
18
37
#[ derive( Default ) ]
19
38
pub struct NapiWrittenEndpoint {
20
39
pub r#type : String ,
21
40
pub entry_path : Option < String > ,
22
- pub server_paths : Option < Vec < String > > ,
41
+ pub server_paths : Option < Vec < NapiServerPath > > ,
23
42
pub files : Option < Vec < String > > ,
24
43
pub global_var_name : Option < String > ,
25
44
pub config : NapiEndpointConfig ,
@@ -34,7 +53,7 @@ impl From<&WrittenEndpoint> for NapiWrittenEndpoint {
34
53
} => Self {
35
54
r#type : "nodejs" . to_string ( ) ,
36
55
entry_path : Some ( server_entry_path. clone ( ) ) ,
37
- server_paths : Some ( server_paths. clone ( ) ) ,
56
+ server_paths : Some ( server_paths. iter ( ) . map ( From :: from ) . collect ( ) ) ,
38
57
..Default :: default ( )
39
58
} ,
40
59
WrittenEndpoint :: Edge {
@@ -44,7 +63,7 @@ impl From<&WrittenEndpoint> for NapiWrittenEndpoint {
44
63
} => Self {
45
64
r#type : "edge" . to_string ( ) ,
46
65
files : Some ( files. clone ( ) ) ,
47
- server_paths : Some ( server_paths. clone ( ) ) ,
66
+ server_paths : Some ( server_paths. iter ( ) . map ( From :: from ) . collect ( ) ) ,
48
67
global_var_name : Some ( global_var_name. clone ( ) ) ,
49
68
..Default :: default ( )
50
69
} ,
0 commit comments