@@ -13,9 +13,9 @@ import type {
13
13
AuthenticityHeaders ,
14
14
Store ,
15
15
StoreGenerator ,
16
- ReactOnRailsOptions ,
17
16
} from './types/index.ts' ;
18
17
import reactHydrateOrRenderInternal from './reactHydrateOrRender.ts' ;
18
+ import { resetOptions } from './options.ts' ;
19
19
20
20
export { default as buildConsoleReplay } from './buildConsoleReplay.ts' ;
21
21
@@ -25,22 +25,17 @@ declare global {
25
25
/* eslint-enable no-var,vars-on-top,no-underscore-dangle */
26
26
}
27
27
28
+ // eslint-disable-next-line no-underscore-dangle
28
29
if ( globalThis . __REACT_ON_RAILS_LOADED__ ) {
29
30
throw new Error ( `\
30
31
The ReactOnRails value exists in the ${ globalThis } scope, it may not be safe to overwrite it.
31
32
This could be caused by setting Webpack's optimization.runtimeChunk to "true" or "multiple," rather than "single."
32
33
Check your Webpack configuration. Read more at https://github.com/shakacode/react_on_rails/issues/1558.` ) ;
33
34
}
34
35
36
+ // eslint-disable-next-line no-underscore-dangle
35
37
globalThis . __REACT_ON_RAILS_LOADED__ = true ;
36
38
37
- const DEFAULT_OPTIONS = {
38
- traceTurbolinks : false ,
39
- turbo : false ,
40
- } ;
41
-
42
- let options : ReactOnRailsOptions = { } ;
43
-
44
39
// TODO: convert to re-exports if everything works fine
45
40
export function register ( components : Record < string , ReactComponentOrRenderFunction > ) : void {
46
41
ComponentRegistry . register ( components ) ;
@@ -83,26 +78,6 @@ export function reactHydrateOrRender(
83
78
return reactHydrateOrRenderInternal ( domNode , reactElement , hydrate ) ;
84
79
}
85
80
86
- export function setOptions ( newOptions : Partial < ReactOnRailsOptions > ) : void {
87
- if ( typeof newOptions . traceTurbolinks !== 'undefined' ) {
88
- options . traceTurbolinks = newOptions . traceTurbolinks ;
89
-
90
- // eslint-disable-next-line no-param-reassign
91
- delete newOptions . traceTurbolinks ;
92
- }
93
-
94
- if ( typeof newOptions . turbo !== 'undefined' ) {
95
- options . turbo = newOptions . turbo ;
96
-
97
- // eslint-disable-next-line no-param-reassign
98
- delete newOptions . turbo ;
99
- }
100
-
101
- if ( Object . keys ( newOptions ) . length > 0 ) {
102
- throw new Error ( `Invalid options passed to ReactOnRails.options: ${ JSON . stringify ( newOptions ) } ` ) ;
103
- }
104
- }
105
-
106
81
export function reactOnRailsPageLoaded ( ) {
107
82
return ClientStartup . reactOnRailsPageLoaded ( ) ;
108
83
}
@@ -127,10 +102,6 @@ export function authenticityHeaders(otherHeaders: Record<string, string> = {}):
127
102
// INTERNALLY USED APIs
128
103
// /////////////////////////////////////////////////////////////////////////////
129
104
130
- export function option < K extends keyof ReactOnRailsOptions > ( key : K ) : ReactOnRailsOptions [ K ] | undefined {
131
- return options [ key ] ;
132
- }
133
-
134
105
export function getStoreGenerator ( name : string ) : StoreGenerator {
135
106
return StoreRegistry . getStoreGenerator ( name ) ;
136
107
}
@@ -201,12 +172,9 @@ export function stores(): Map<string, Store> {
201
172
return StoreRegistry . stores ( ) ;
202
173
}
203
174
204
- export function resetOptions ( ) : void {
205
- options = { ...DEFAULT_OPTIONS } ;
206
- }
207
-
208
175
resetOptions ( ) ;
209
176
210
177
ClientStartup . clientStartup ( ) ;
211
178
212
179
export * from './types/index.ts' ;
180
+ export * from './options.ts' ;
0 commit comments