@@ -8,11 +8,14 @@ use napi::{
88} ;
99use next_api:: {
1010 entrypoints:: Entrypoints ,
11+ operation:: {
12+ EntrypointsOperation , InstrumentationOperation , MiddlewareOperation , RouteOperation ,
13+ } ,
1114 project:: {
12- DefineEnv , DraftModeOptions , Instrumentation , Middleware , PartialProjectOptions , Project ,
13- ProjectContainer , ProjectOptions , WatchOptions ,
15+ DefineEnv , DraftModeOptions , PartialProjectOptions , Project , ProjectContainer ,
16+ ProjectOptions , WatchOptions ,
1417 } ,
15- route:: { Endpoint , Route } ,
18+ route:: Endpoint ,
1619} ;
1720use next_core:: tracing_presets:: {
1821 TRACING_NEXT_OVERVIEW_TARGETS , TRACING_NEXT_TARGETS , TRACING_NEXT_TURBOPACK_TARGETS ,
@@ -25,7 +28,8 @@ use tracing::Instrument;
2528use tracing_subscriber:: { layer:: SubscriberExt , util:: SubscriberInitExt , Registry } ;
2629use turbo_rcstr:: RcStr ;
2730use turbo_tasks:: {
28- get_effects, Completion , Effects , ReadRef , ResolvedVc , TransientInstance , UpdateInfo , Vc ,
31+ get_effects, Completion , Effects , OperationVc , ReadRef , ResolvedVc , TransientInstance ,
32+ UpdateInfo , Vc ,
2933} ;
3034use turbo_tasks_fs:: {
3135 get_relative_path_to, util:: uri_from_file, DiskFileSystem , FileContent , FileSystem ,
@@ -539,56 +543,56 @@ struct NapiRoute {
539543}
540544
541545impl NapiRoute {
542- fn from_route ( pathname : String , value : Route , turbo_tasks : & NextTurboTasks ) -> Self {
543- let convert_endpoint = |endpoint : Vc < Box < dyn Endpoint > > | {
546+ fn from_route ( pathname : String , value : RouteOperation , turbo_tasks : & NextTurboTasks ) -> Self {
547+ let convert_endpoint = |endpoint : OperationVc < Box < dyn Endpoint > > | {
544548 Some ( External :: new ( ExternalEndpoint ( VcArc :: new (
545549 turbo_tasks. clone ( ) ,
546550 endpoint,
547551 ) ) ) )
548552 } ;
549553 match value {
550- Route :: Page {
554+ RouteOperation :: Page {
551555 html_endpoint,
552556 data_endpoint,
553557 } => NapiRoute {
554558 pathname,
555559 r#type : "page" ,
556- html_endpoint : convert_endpoint ( * html_endpoint) ,
557- data_endpoint : convert_endpoint ( * data_endpoint) ,
560+ html_endpoint : convert_endpoint ( html_endpoint) ,
561+ data_endpoint : convert_endpoint ( data_endpoint) ,
558562 ..Default :: default ( )
559563 } ,
560- Route :: PageApi { endpoint } => NapiRoute {
564+ RouteOperation :: PageApi { endpoint } => NapiRoute {
561565 pathname,
562566 r#type : "page-api" ,
563- endpoint : convert_endpoint ( * endpoint) ,
567+ endpoint : convert_endpoint ( endpoint) ,
564568 ..Default :: default ( )
565569 } ,
566- Route :: AppPage ( pages) => NapiRoute {
570+ RouteOperation :: AppPage ( pages) => NapiRoute {
567571 pathname,
568572 r#type : "app-page" ,
569573 pages : Some (
570574 pages
571575 . into_iter ( )
572576 . map ( |page_route| AppPageNapiRoute {
573- original_name : Some ( page_route. original_name ) ,
577+ original_name : Some ( page_route. original_name . into_owned ( ) ) ,
574578 html_endpoint : convert_endpoint ( page_route. html_endpoint ) ,
575579 rsc_endpoint : convert_endpoint ( page_route. rsc_endpoint ) ,
576580 } )
577581 . collect ( ) ,
578582 ) ,
579583 ..Default :: default ( )
580584 } ,
581- Route :: AppRoute {
585+ RouteOperation :: AppRoute {
582586 original_name,
583587 endpoint,
584588 } => NapiRoute {
585589 pathname,
586- original_name : Some ( original_name) ,
590+ original_name : Some ( original_name. into_owned ( ) ) ,
587591 r#type : "app-route" ,
588- endpoint : convert_endpoint ( * endpoint) ,
592+ endpoint : convert_endpoint ( endpoint) ,
589593 ..Default :: default ( )
590594 } ,
591- Route :: Conflict => NapiRoute {
595+ RouteOperation :: Conflict => NapiRoute {
592596 pathname,
593597 r#type : "conflict" ,
594598 ..Default :: default ( )
@@ -603,7 +607,7 @@ struct NapiMiddleware {
603607}
604608
605609impl NapiMiddleware {
606- fn from_middleware ( value : & Middleware , turbo_tasks : & NextTurboTasks ) -> Result < Self > {
610+ fn from_middleware ( value : & MiddlewareOperation , turbo_tasks : & NextTurboTasks ) -> Result < Self > {
607611 Ok ( NapiMiddleware {
608612 endpoint : External :: new ( ExternalEndpoint ( VcArc :: new (
609613 turbo_tasks. clone ( ) ,
@@ -620,7 +624,10 @@ struct NapiInstrumentation {
620624}
621625
622626impl NapiInstrumentation {
623- fn from_instrumentation ( value : & Instrumentation , turbo_tasks : & NextTurboTasks ) -> Result < Self > {
627+ fn from_instrumentation (
628+ value : & InstrumentationOperation ,
629+ turbo_tasks : & NextTurboTasks ,
630+ ) -> Result < Self > {
624631 Ok ( NapiInstrumentation {
625632 node_js : External :: new ( ExternalEndpoint ( VcArc :: new (
626633 turbo_tasks. clone ( ) ,
@@ -644,9 +651,9 @@ struct NapiEntrypoints {
644651 pub pages_error_endpoint : External < ExternalEndpoint > ,
645652}
646653
647- #[ turbo_tasks:: value( serialization = "none" , local ) ]
654+ #[ turbo_tasks:: value( serialization = "none" ) ]
648655struct EntrypointsWithIssues {
649- entrypoints : ReadRef < Entrypoints > ,
656+ entrypoints : ReadRef < EntrypointsOperation > ,
650657 issues : Arc < Vec < ReadRef < PlainIssue > > > ,
651658 diagnostics : Arc < Vec < ReadRef < PlainDiagnostic > > > ,
652659 effects : Arc < Effects > ,
@@ -656,7 +663,8 @@ struct EntrypointsWithIssues {
656663async fn get_entrypoints_with_issues (
657664 container : ResolvedVc < ProjectContainer > ,
658665) -> Result < Vc < EntrypointsWithIssues > > {
659- let entrypoints_operation = project_container_entrypoints_operation ( container) ;
666+ let entrypoints_operation =
667+ EntrypointsOperation :: new ( project_container_entrypoints_operation ( container) ) ;
660668 let entrypoints = entrypoints_operation
661669 . connect ( )
662670 . strongly_consistent ( )
@@ -675,6 +683,8 @@ async fn get_entrypoints_with_issues(
675683
676684#[ turbo_tasks:: function( operation) ]
677685fn project_container_entrypoints_operation (
686+ // the container is a long-lived object with internally mutable state, there's no risk of it
687+ // becoming stale
678688 container : ResolvedVc < ProjectContainer > ,
679689) -> Vc < Entrypoints > {
680690 container. entrypoints ( )
@@ -732,15 +742,15 @@ pub fn project_entrypoints_subscribe(
732742 . transpose( ) ?,
733743 pages_document_endpoint: External :: new( ExternalEndpoint ( VcArc :: new(
734744 turbo_tasks. clone( ) ,
735- * entrypoints. pages_document_endpoint,
745+ entrypoints. pages_document_endpoint,
736746 ) ) ) ,
737747 pages_app_endpoint: External :: new( ExternalEndpoint ( VcArc :: new(
738748 turbo_tasks. clone( ) ,
739- * entrypoints. pages_app_endpoint,
749+ entrypoints. pages_app_endpoint,
740750 ) ) ) ,
741751 pages_error_endpoint: External :: new( ExternalEndpoint ( VcArc :: new(
742752 turbo_tasks. clone( ) ,
743- * entrypoints. pages_error_endpoint,
753+ entrypoints. pages_error_endpoint,
744754 ) ) ) ,
745755 } ,
746756 issues: issues
@@ -782,7 +792,7 @@ async fn hmr_update(
782792}
783793
784794#[ turbo_tasks:: function( operation) ]
785- async fn project_hmr_update_operation (
795+ fn project_hmr_update_operation (
786796 project : ResolvedVc < Project > ,
787797 identifier : RcStr ,
788798 state : ResolvedVc < VersionState > ,
0 commit comments