@@ -29,9 +29,9 @@ def generate
2929 if named_routes . empty?
3030 if application . is_a? ( Rails ::Application )
3131 if Rails . version >= "8.0.0"
32- application . reload_routes_unless_loaded
32+ T . unsafe ( application ) . reload_routes_unless_loaded
3333 else
34- application . reload_routes!
34+ T . unsafe ( application ) . reload_routes!
3535 end
3636 end
3737 end
@@ -43,7 +43,20 @@ def generate
4343 raise ( "Missing key #{ key } in JS template" )
4444 end
4545 end
46- content + routes_export + prevent_types_export
46+ banner + content + routes_export + prevent_types_export
47+ end
48+
49+ sig { returns ( String ) }
50+ def banner
51+ banner = @configuration . banner
52+ banner = banner . call if banner . is_a? ( Proc )
53+ return "" if banner . blank?
54+ [
55+ "/**" ,
56+ *banner . split ( "\n " ) . map { |line | " * #{ line } " } ,
57+ " */" ,
58+ "" ,
59+ ] . join ( "\n " )
4760 end
4861
4962 sig { void }
@@ -79,12 +92,11 @@ def js_variables
7992 prefix = @configuration . prefix
8093 prefix = prefix . call if prefix . is_a? ( Proc )
8194 {
82- 'GEM_VERSION' => JsRoutes ::VERSION ,
83- 'TIMESTAMP' => Time . now . to_s ,
95+ # 'GEM_VERSION' => JsRoutes::VERSION,
8496 'ROUTES_OBJECT' => routes_object ,
85- 'RAILS_VERSION' => ::Rails . version ,
97+ # 'RAILS_VERSION' => ::Rails.version,
8698 'DEPRECATED_FALSE_PARAMETER_BEHAVIOR' => Rails . version < '7.0.0' ,
87- 'APP_CLASS' => application . class . to_s ,
99+ # 'APP_CLASS' => application.class.to_s,
88100 'DEFAULT_URL_OPTIONS' => json ( @configuration . default_url_options ) ,
89101 'PREFIX' => json ( prefix ) ,
90102 'SPECIAL_OPTIONS_KEY' => json ( @configuration . special_options_key ) ,
@@ -187,7 +199,7 @@ def mounted_app_routes(route)
187199 rails_engine_app = T . unsafe ( app_from_route ( route ) )
188200 if rails_engine_app . is_a? ( Class ) &&
189201 rails_engine_app < Rails ::Engine && !route . path . anchored
190- rails_engine_app . routes . named_routes . flat_map do |_ , engine_route |
202+ T . unsafe ( rails_engine_app ) . routes . named_routes . flat_map do |_ , engine_route |
191203 route_helpers_if_match ( engine_route , route )
192204 end
193205 else
@@ -200,7 +212,7 @@ def app_from_route(route)
200212 app = route . app
201213 # Rails Engine can use additional
202214 # ActionDispatch::Routing::Mapper::Constraints, which contain app
203- if app . is_a? ( ActionDispatch ::Routing ::Mapper ::Constraints )
215+ if app . is_a? ( T . unsafe ( ActionDispatch ::Routing ::Mapper ::Constraints ) )
204216 app . app
205217 else
206218 app
0 commit comments