-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Redpoint.CloudFramework to UET mono-repo
We're not using this yet in UET.
- Loading branch information
Showing
349 changed files
with
32,271 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project> | ||
|
||
<!-- This must remain in sync with Framework.Build.props. --> | ||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" Version="8.0.0" Condition="'$(TargetFramework)' == 'net8.0'" /> | ||
</ItemGroup> | ||
|
||
</Project> |
51 changes: 51 additions & 0 deletions
51
UET/Lib/Redpoint.ThirdParty.React.AspNet.Middleware/AspNetFileSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
using Microsoft.AspNetCore.Hosting; | ||
using React.Exceptions; | ||
|
||
namespace React.AspNet | ||
{ | ||
/// <summary> | ||
/// Handles file system functionality, such as reading files. Maps all paths from | ||
/// application-relative (~/...) to full paths using ASP.NET's MapPath method. | ||
/// </summary> | ||
public class AspNetFileSystem : FileSystemBase | ||
{ | ||
private readonly IWebHostEnvironment _hostingEnv; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AspNetFileSystem"/> class. | ||
/// </summary> | ||
/// <param name="hostingEnv">The .NET Core hosting environment</param> | ||
public AspNetFileSystem(IWebHostEnvironment hostingEnv) | ||
{ | ||
_hostingEnv = hostingEnv; | ||
} | ||
|
||
/// <summary> | ||
/// Converts a path from an application relative path (~/...) to a full filesystem path | ||
/// </summary> | ||
/// <param name="relativePath">App-relative path of the file</param> | ||
/// <returns>Full path of the file</returns> | ||
public override string MapPath(string relativePath) | ||
{ | ||
if (_hostingEnv.WebRootPath == null) | ||
{ | ||
throw new ReactException("WebRootPath was null, has the wwwroot folder been deployed along with your app?"); | ||
} | ||
|
||
if (relativePath.StartsWith(_hostingEnv.WebRootPath)) | ||
{ | ||
return relativePath; | ||
} | ||
relativePath = relativePath.TrimStart('~').TrimStart('/').TrimStart('\\'); | ||
|
||
return Path.GetFullPath(Path.Combine(_hostingEnv.WebRootPath, relativePath)); | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
UET/Lib/Redpoint.ThirdParty.React.AspNet.Middleware/MemoryFileCacheCore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
using Microsoft.Extensions.Caching.Memory; | ||
using Microsoft.AspNetCore.Hosting; | ||
|
||
namespace React.AspNet | ||
{ | ||
/// <summary> | ||
/// Memory cache implementation for React.ICache. Uses IMemoryCache from .NET Core. | ||
/// </summary> | ||
public class MemoryFileCacheCore : ICache | ||
{ | ||
private readonly IMemoryCache _cache; | ||
private readonly IWebHostEnvironment _hostingEnv; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MemoryFileCacheCore" /> class. | ||
/// </summary> | ||
/// <param name="cache">The cache to use</param> | ||
/// <param name="hostingEnv">The ASP.NET hosting environment.</param> | ||
public MemoryFileCacheCore(IMemoryCache cache, IWebHostEnvironment hostingEnv) | ||
{ | ||
_cache = cache; | ||
_hostingEnv = hostingEnv; | ||
} | ||
|
||
/// <summary> | ||
/// Get an item from the cache. Returns <paramref name="fallback"/> if the item does | ||
/// not exist. | ||
/// </summary> | ||
/// <typeparam name="T">Type of data</typeparam> | ||
/// <param name="key">The cache key</param> | ||
/// <param name="fallback">Value to return if item is not in the cache</param> | ||
/// <returns>Data from cache, otherwise <paramref name="fallback"/></returns> | ||
public T Get<T>(string key, T fallback = default(T)) | ||
{ | ||
return (T)(_cache.Get(key) ?? fallback); | ||
} | ||
|
||
/// <summary> | ||
/// Sets an item in the cache. | ||
/// </summary> | ||
/// <typeparam name="T">Type of data</typeparam> | ||
/// <param name="key">The cache key</param> | ||
/// <param name="data">Data to cache</param> | ||
/// <param name="slidingExpiration"> | ||
/// Sliding expiration, if cache key is not accessed in this time period it will | ||
/// automatically be removed from the cache | ||
/// </param> | ||
/// <param name="cacheDependencyFiles"> | ||
/// Filenames this cached item is dependent on. If any of these files change, the cache | ||
/// will be cleared automatically | ||
/// </param> | ||
public void Set<T>(string key, T data, TimeSpan slidingExpiration, IEnumerable<string> cacheDependencyFiles = null) | ||
{ | ||
if (data == null) | ||
{ | ||
_cache.Remove(key); | ||
return; | ||
} | ||
|
||
var options = new MemoryCacheEntryOptions | ||
{ | ||
SlidingExpiration = slidingExpiration, | ||
}; | ||
|
||
if (cacheDependencyFiles != null) | ||
{ | ||
foreach (var file in cacheDependencyFiles) | ||
{ | ||
var relativePath = file.Replace(_hostingEnv.WebRootPath, string.Empty).TrimStart('\\', '/'); | ||
options.AddExpirationToken(_hostingEnv.WebRootFileProvider.Watch(relativePath)); | ||
} | ||
} | ||
|
||
_cache.Set(key, data, options); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
UET/Lib/Redpoint.ThirdParty.React.AspNet.Middleware/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Redpoint.ThirdParty.React.AspNet | ||
|
||
This is a fork of React.NET (https://github.com/reactjs/react.net) that adds support for React v18. | ||
|
||
If you want to use this fork in an ASP.NET Core project, use the `Redpoint.ThirdParty.React.AspNet` package. |
35 changes: 35 additions & 0 deletions
35
UET/Lib/Redpoint.ThirdParty.React.AspNet.Middleware/ReactBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace React.AspNet | ||
{ | ||
/// <summary> | ||
/// Handles registering ReactJS.NET middleware in an ASP.NET <see cref="IApplicationBuilder"/>. | ||
/// </summary> | ||
public static class ReactBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Initialises ReactJS.NET for this application | ||
/// </summary> | ||
/// <param name="app">ASP.NET application builder</param> | ||
/// <param name="configure">ReactJS.NET configuration</param> | ||
/// <returns>The application builder (for chaining)</returns> | ||
public static IApplicationBuilder UseReact( | ||
this IApplicationBuilder app, | ||
Action<IReactSiteConfiguration> configure | ||
) | ||
{ | ||
// Apply configuration. | ||
configure(app.ApplicationServices.GetRequiredService<IReactSiteConfiguration>()); | ||
|
||
return app; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
UET/Lib/Redpoint.ThirdParty.React.AspNet.Middleware/ReactServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
using JavaScriptEngineSwitcher.Core; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace React.AspNet | ||
{ | ||
/// <summary> | ||
/// Handles registering ReactJS.NET services in the ASP.NET <see cref="IServiceCollection"/>. | ||
/// </summary> | ||
public static class ReactServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Registers all services required for ReactJS.NET | ||
/// </summary> | ||
/// <param name="services">ASP.NET services</param> | ||
/// <returns>The service collection (for chaining)</returns> | ||
public static IServiceCollection AddReact(this IServiceCollection services) | ||
{ | ||
services.AddSingleton<IReactSiteConfiguration, ReactSiteConfiguration>(); | ||
services.AddScoped<IFileCacheHash, FileCacheHash>(); | ||
services.AddSingleton<IJsEngineSwitcher>(sp => JsEngineSwitcher.Current); | ||
services.AddSingleton<IJavaScriptEngineFactory, JavaScriptEngineFactory>(); | ||
services.AddSingleton<IReactIdGenerator, ReactIdGenerator>(); | ||
services.AddScoped<IReactEnvironment, ReactEnvironment>(); | ||
|
||
services.AddSingleton<IFileSystem, AspNetFileSystem>(); | ||
services.AddSingleton<ICache, MemoryFileCacheCore>(); | ||
|
||
return services; | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...int.ThirdParty.React.AspNet.Middleware/Redpoint.ThirdParty.React.AspNet.Middleware.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)../ThirdPartyCommon.Build.props" /> | ||
|
||
<PropertyGroup> | ||
<AssemblyName>React.AspNet.Middleware</AssemblyName> | ||
<RootNamespace>React.AspNet.Middleware</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)../Framework.AspNetCore.Build.props" /> | ||
|
||
<Import Project="$(MSBuildThisFileDirectory)../LibraryPackaging.Build.props" /> | ||
<PropertyGroup> | ||
<Description>A fork of React.NET (https://github.com/reactjs/react.net) that adds support for React v18.</Description> | ||
<PackageId>Redpoint.ThirdParty.React.AspNet.Middleware</PackageId> | ||
<PackageTags>react, react.net</PackageTags> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<Authors>June Rhodes, Daniel Lo Nigro</Authors> | ||
<Company></Company> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Redpoint.ThirdParty.React.Core\Redpoint.ThirdParty.React.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<NoWarn>7035</NoWarn> | ||
</PropertyGroup> | ||
|
||
</Project> |
Oops, something went wrong.