@@ -22,40 +22,40 @@ public class JsxTransformer : IJsxTransformer
22
22
/// <summary>
23
23
/// Cache key for JSX to JavaScript compilation
24
24
/// </summary>
25
- private const string JSX_CACHE_KEY = "JSX_v2_{0}" ;
25
+ protected const string JSX_CACHE_KEY = "JSX_v2_{0}" ;
26
26
/// <summary>
27
27
/// Suffix to append to compiled files
28
28
/// </summary>
29
- private const string COMPILED_FILE_SUFFIX = ".generated.js" ;
29
+ protected const string COMPILED_FILE_SUFFIX = ".generated.js" ;
30
30
/// <summary>
31
31
/// Suffix to append to source map files
32
32
/// </summary>
33
- private const string SOURE_MAP_FILE_SUFFIX = ".map" ;
33
+ protected const string SOURE_MAP_FILE_SUFFIX = ".map" ;
34
34
/// <summary>
35
35
/// Number of lines in the header prepended to compiled JSX files.
36
36
/// </summary>
37
- private const int LINES_IN_HEADER = 5 ;
37
+ protected const int LINES_IN_HEADER = 5 ;
38
38
39
39
/// <summary>
40
40
/// Environment this JSX Transformer has been created in
41
41
/// </summary>
42
- private readonly IReactEnvironment _environment ;
42
+ protected readonly IReactEnvironment _environment ;
43
43
/// <summary>
44
44
/// Cache used for storing compiled JSX
45
45
/// </summary>
46
- private readonly ICache _cache ;
46
+ protected readonly ICache _cache ;
47
47
/// <summary>
48
48
/// File system wrapper
49
49
/// </summary>
50
- private readonly IFileSystem _fileSystem ;
50
+ protected readonly IFileSystem _fileSystem ;
51
51
/// <summary>
52
52
/// Hash algorithm for file-based cache
53
53
/// </summary>
54
- private readonly IFileCacheHash _fileCacheHash ;
54
+ protected readonly IFileCacheHash _fileCacheHash ;
55
55
/// <summary>
56
56
/// Site-wide configuration
57
57
/// </summary>
58
- private readonly IReactSiteConfiguration _config ;
58
+ protected readonly IReactSiteConfiguration _config ;
59
59
60
60
/// <summary>
61
61
/// Initializes a new instance of the <see cref="JsxTransformer"/> class.
@@ -80,7 +80,7 @@ public JsxTransformer(IReactEnvironment environment, ICache cache, IFileSystem f
80
80
/// <param name="filename">Name of the file to load</param>
81
81
/// <param name="useHarmony"><c>true</c> if support for es6 syntax should be rewritten.</param>
82
82
/// <returns>JavaScript</returns>
83
- public string TransformJsxFile ( string filename , bool ? useHarmony = null )
83
+ public virtual string TransformJsxFile ( string filename , bool ? useHarmony = null )
84
84
{
85
85
return TransformJsxFileWithSourceMap ( filename , false , useHarmony ) . Code ;
86
86
}
@@ -96,7 +96,7 @@ public string TransformJsxFile(string filename, bool? useHarmony = null)
96
96
/// </param>
97
97
/// <param name="useHarmony"><c>true</c> if support for ES6 syntax should be enabled</param>
98
98
/// <returns>JavaScript and source map</returns>
99
- public JavaScriptWithSourceMap TransformJsxFileWithSourceMap ( string filename , bool forceGenerateSourceMap = false , bool ? useHarmony = null )
99
+ public virtual JavaScriptWithSourceMap TransformJsxFileWithSourceMap ( string filename , bool forceGenerateSourceMap = false , bool ? useHarmony = null )
100
100
{
101
101
var cacheKey = string . Format ( JSX_CACHE_KEY , filename ) ;
102
102
@@ -152,7 +152,7 @@ public JavaScriptWithSourceMap TransformJsxFileWithSourceMap(string filename, bo
152
152
/// <c>true</c> to re-transform the file if a cached version with no source map is available
153
153
/// </param>
154
154
/// <returns></returns>
155
- private JavaScriptWithSourceMap LoadJsxFromFileCache ( string filename , string hash , bool forceGenerateSourceMap )
155
+ protected virtual JavaScriptWithSourceMap LoadJsxFromFileCache ( string filename , string hash , bool forceGenerateSourceMap )
156
156
{
157
157
var cacheFilename = GetJsxOutputPath ( filename ) ;
158
158
if ( ! _fileSystem . FileExists ( cacheFilename ) )
@@ -212,7 +212,7 @@ private JavaScriptWithSourceMap LoadJsxFromFileCache(string filename, string has
212
212
/// <param name="hash">Hash of the input. If null, it will be calculated</param>
213
213
/// <param name="useHarmony"><c>true</c> if support for es6 syntax should be rewritten.</param>
214
214
/// <returns>JavaScript</returns>
215
- private JavaScriptWithSourceMap TransformJsxWithHeader ( string filename , string contents , string hash = null , bool ? useHarmony = null )
215
+ protected virtual JavaScriptWithSourceMap TransformJsxWithHeader ( string filename , string contents , string hash = null , bool ? useHarmony = null )
216
216
{
217
217
if ( string . IsNullOrEmpty ( hash ) )
218
218
{
@@ -242,7 +242,7 @@ private JavaScriptWithSourceMap TransformJsxWithHeader(string filename, string c
242
242
/// <param name="input">JSX</param>
243
243
/// <param name="useHarmony"><c>true</c> if support for es6 syntax should be rewritten.</param>
244
244
/// <returns>JavaScript</returns>
245
- public string TransformJsx ( string input , bool ? useHarmony = null )
245
+ public virtual string TransformJsx ( string input , bool ? useHarmony = null )
246
246
{
247
247
EnsureJsxTransformerSupported ( ) ;
248
248
try
@@ -267,7 +267,7 @@ public string TransformJsx(string input, bool? useHarmony = null)
267
267
/// <param name="input">JSX</param>
268
268
/// <param name="useHarmony"><c>true</c> if support for ES6 syntax should be enabled</param>
269
269
/// <returns>JavaScript and source map</returns>
270
- public JavaScriptWithSourceMap TransformJsxWithSourceMap ( string input , bool ? useHarmony )
270
+ public virtual JavaScriptWithSourceMap TransformJsxWithSourceMap ( string input , bool ? useHarmony )
271
271
{
272
272
EnsureJsxTransformerSupported ( ) ;
273
273
try
@@ -290,7 +290,7 @@ public JavaScriptWithSourceMap TransformJsxWithSourceMap(string input, bool? use
290
290
/// </summary>
291
291
/// <param name="hash">Hash of the input</param>
292
292
/// <returns>Header for the cache</returns>
293
- private string GetFileHeader ( string hash )
293
+ protected virtual string GetFileHeader ( string hash )
294
294
{
295
295
return string . Format (
296
296
@"{0}
@@ -307,7 +307,7 @@ private string GetFileHeader(string hash)
307
307
/// </summary>
308
308
/// <param name="path">Path of the JSX file</param>
309
309
/// <returns>Output path of the compiled file</returns>
310
- public string GetJsxOutputPath ( string path )
310
+ public virtual string GetJsxOutputPath ( string path )
311
311
{
312
312
return Path . Combine (
313
313
Path . GetDirectoryName ( path ) ,
@@ -321,7 +321,7 @@ public string GetJsxOutputPath(string path)
321
321
/// </summary>
322
322
/// <param name="path">Path of the JSX file</param>
323
323
/// <returns>Output path of the source map</returns>
324
- public string GetSourceMapOutputPath ( string path )
324
+ public virtual string GetSourceMapOutputPath ( string path )
325
325
{
326
326
return GetJsxOutputPath ( path ) + SOURE_MAP_FILE_SUFFIX ;
327
327
}
@@ -333,7 +333,7 @@ public string GetSourceMapOutputPath(string path)
333
333
/// <param name="filename">Name of the file to load</param>
334
334
/// <param name="useHarmony"><c>true</c> if support for es6 syntax should be rewritten.</param>
335
335
/// <returns>File contents</returns>
336
- public string TransformAndSaveJsxFile ( string filename , bool ? useHarmony = null )
336
+ public virtual string TransformAndSaveJsxFile ( string filename , bool ? useHarmony = null )
337
337
{
338
338
var outputPath = GetJsxOutputPath ( filename ) ;
339
339
var sourceMapPath = GetSourceMapOutputPath ( filename ) ;
0 commit comments