From 64b96547f9f6eea0cbfd510d6041d0dfce2e909e Mon Sep 17 00:00:00 2001 From: KristofferStrube Date: Tue, 28 Oct 2025 21:44:53 +0100 Subject: [PATCH 1/2] Removed `FileSystemOptions`. --- .EditorConfig | 4 +- .../Program.cs | 7 +-- .../BaseJSWrapper.cs | 19 +------ .../Extensions/IJSRuntimeExtensions.cs | 13 ++--- .../IServiceCollectionExtensions.cs | 32 ------------ .../FileSystemDirectoryHandle.InProcess.cs | 44 ++++------------- .../FileSystemDirectoryHandle.cs | 49 ++++--------------- .../FileSystemFileHandle.InProcess.cs | 36 ++------------ .../FileSystemFileHandle.cs | 38 ++------------ .../FileSystemHandle.InProcess.cs | 34 ++----------- .../FileSystemHandle.cs | 36 ++------------ .../FileSystemWritableFileStream.InProcess.cs | 36 ++------------ .../FileSystemWritableFileStream.cs | 31 ++---------- .../IStorageManagerService.InProcess.cs | 7 --- .../IStorageManagerService.cs | 7 --- .../Options/FileSystemOptions.cs | 44 ----------------- .../StorageManagerService.InProcess.cs | 8 +-- .../StorageManagerService.cs | 26 +--------- 18 files changed, 57 insertions(+), 414 deletions(-) delete mode 100644 src/KristofferStrube.Blazor.FileSystem/Options/FileSystemOptions.cs diff --git a/.EditorConfig b/.EditorConfig index c7f704a..671f835 100644 --- a/.EditorConfig +++ b/.EditorConfig @@ -41,8 +41,8 @@ csharp_style_deconstructed_variable_declaration = true dotnet_diagnostic.IDE0042.severity = suggestion dotnet_style_prefer_conditional_expression_over_assignment = true dotnet_diagnostic.IDE0045.severity = warning -dotnet_style_prefer_conditional_expression_over_return = true -dotnet_diagnostic.IDE0046.severity = warning +dotnet_style_prefer_conditional_expression_over_return = false +dotnet_diagnostic.IDE0046.severity = none dotnet_style_prefer_compound_assignment = true dotnet_diagnostic.IDE0054.severity = warning dotnet_diagnostic.IDE0074.severity = warning diff --git a/samples/KristofferStrube.Blazor.FileSystem.WasmExample/Program.cs b/samples/KristofferStrube.Blazor.FileSystem.WasmExample/Program.cs index 665a2d1..5c10eed 100644 --- a/samples/KristofferStrube.Blazor.FileSystem.WasmExample/Program.cs +++ b/samples/KristofferStrube.Blazor.FileSystem.WasmExample/Program.cs @@ -11,12 +11,7 @@ builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); -builder.Services.AddStorageManagerServiceInProcess(options => -{ - // Configure with custom script path - // options.BasePath = "content/"; - // options.ScriptPath = $"custom-path/{FileSystemOptions.DefaultNamespace}.js"; -}); +builder.Services.AddStorageManagerServiceInProcess(); builder.Services.AddURLServiceInProcess(); diff --git a/src/KristofferStrube.Blazor.FileSystem/BaseJSWrapper.cs b/src/KristofferStrube.Blazor.FileSystem/BaseJSWrapper.cs index 4f53289..87c0eda 100644 --- a/src/KristofferStrube.Blazor.FileSystem/BaseJSWrapper.cs +++ b/src/KristofferStrube.Blazor.FileSystem/BaseJSWrapper.cs @@ -14,17 +14,6 @@ public abstract class BaseJSWrapper : IAsyncDisposable, IJSWrapper /// protected readonly Lazy> helperTask; - /// - /// Options for where the helper JS module is located. - /// - protected readonly FileSystemOptions fileSystemOptions; - - /// - /// Options for where the helper JS module is located. - /// - [Obsolete("This is here for backwards compatibility. It was replaced by 'fileSystemOptions' as 'options' was ambiguous.")] - protected readonly FileSystemOptions options; - /// public IJSRuntime JSRuntime { get; } @@ -35,13 +24,9 @@ public abstract class BaseJSWrapper : IAsyncDisposable, IJSWrapper public bool DisposesJSReference { get; } /// - internal BaseJSWrapper(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions options) + internal BaseJSWrapper(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) { - this.fileSystemOptions = fileSystemOptions; -#pragma warning disable CS0618 // Type or member is obsolete - this.options = fileSystemOptions; -#pragma warning restore CS0618 // Type or member is obsolete - helperTask = new(async () => await jSRuntime.GetHelperAsync(fileSystemOptions)); + helperTask = new(jSRuntime.GetHelperAsync); JSReference = jSReference; JSRuntime = jSRuntime; DisposesJSReference = options.DisposesJSReference; diff --git a/src/KristofferStrube.Blazor.FileSystem/Extensions/IJSRuntimeExtensions.cs b/src/KristofferStrube.Blazor.FileSystem/Extensions/IJSRuntimeExtensions.cs index c51ee7b..50e7e09 100644 --- a/src/KristofferStrube.Blazor.FileSystem/Extensions/IJSRuntimeExtensions.cs +++ b/src/KristofferStrube.Blazor.FileSystem/Extensions/IJSRuntimeExtensions.cs @@ -4,18 +4,15 @@ namespace KristofferStrube.Blazor.FileSystem.Extensions; internal static class IJSRuntimeExtensions { - internal static async Task GetHelperAsync(this IJSRuntime jSRuntime, FileSystemOptions options) - { - return await GetHelperAsync(jSRuntime, options); - } + private const string helperPath = "./_content/KristofferStrube.Blazor.FileSystem/KristofferStrube.Blazor.FileSystem.js"; - internal static async Task GetInProcessHelperAsync(this IJSRuntime jSRuntime, FileSystemOptions options) + internal static async Task GetHelperAsync(this IJSRuntime jSRuntime) { - return await GetHelperAsync(jSRuntime, options); + return await jSRuntime.InvokeAsync("import", helperPath); } - private static async Task GetHelperAsync(IJSRuntime jSRuntime, FileSystemOptions options) + internal static async Task GetInProcessHelperAsync(this IJSRuntime jSRuntime) { - return await jSRuntime.InvokeAsync("import", options.FullScriptPath); + return await jSRuntime.InvokeAsync("import", helperPath); } } diff --git a/src/KristofferStrube.Blazor.FileSystem/Extensions/IServiceCollectionExtensions.cs b/src/KristofferStrube.Blazor.FileSystem/Extensions/IServiceCollectionExtensions.cs index a36cb4b..9a61674 100644 --- a/src/KristofferStrube.Blazor.FileSystem/Extensions/IServiceCollectionExtensions.cs +++ b/src/KristofferStrube.Blazor.FileSystem/Extensions/IServiceCollectionExtensions.cs @@ -13,18 +13,6 @@ public static class IServiceCollectionExtensions /// The service collection to add the service to. public static IServiceCollection AddStorageManagerService(this IServiceCollection serviceCollection) { - return AddStorageManagerService(serviceCollection, null); - } - - /// - /// Adds a to the service collection with the option to configure where the helper JS module is located. - /// - /// The service collection to add the service to. - /// An action to configure the that defines where the helper JS module is located. - public static IServiceCollection AddStorageManagerService(this IServiceCollection serviceCollection, Action? configure) - { - ConfigureFsOptions(serviceCollection, configure); - return serviceCollection.AddScoped(); } @@ -34,18 +22,6 @@ public static IServiceCollection AddStorageManagerService(this IServiceCollectio /// The service collection to add the service to. public static IServiceCollection AddStorageManagerServiceInProcess(this IServiceCollection serviceCollection) { - return AddStorageManagerServiceInProcess(serviceCollection, null); - } - - /// - /// Adds a to the service collection with the option to configure where the helper JS module is located. - /// - /// The service collection to add the service to. - /// An action to configure the that defines where the helper JS module is located. - public static IServiceCollection AddStorageManagerServiceInProcess(this IServiceCollection serviceCollection, Action? configure) - { - ConfigureFsOptions(serviceCollection, configure); - return serviceCollection .AddScoped() .AddScoped(sp => @@ -54,12 +30,4 @@ public static IServiceCollection AddStorageManagerServiceInProcess(this IService return (IStorageManagerService)service; }); } - - private static void ConfigureFsOptions(IServiceCollection services, Action? configure) - { - if (configure is null) { return; } - - _ = services.Configure(configure); - configure(FileSystemOptions.DefaultInstance); - } } diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.InProcess.cs index 08bbac2..718f72d 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.InProcess.cs @@ -1,5 +1,4 @@ -using KristofferStrube.Blazor.DOM.Extensions; -using KristofferStrube.Blazor.FileSystem.Extensions; +using KristofferStrube.Blazor.FileSystem.Extensions; using KristofferStrube.Blazor.WebIDL; using Microsoft.JSInterop; @@ -27,37 +26,12 @@ public static async Task CreateAsync(IJSRunt /// public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(FileSystemOptions.DefaultInstance); - return new FileSystemDirectoryHandleInProcess(jSRuntime, inProcessHelper, jSReference, FileSystemOptions.DefaultInstance, options); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, FileSystemOptions options) - { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(options); - return new FileSystemDirectoryHandleInProcess(jSRuntime, inProcessHelper, jSReference, options, new() { DisposesJSReference = true }); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at and whether its JS reference should be disposed. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - /// Options for what path the JS helper module will be found at. - public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions creationOptions) - { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(fileSystemOptions); - return new FileSystemDirectoryHandleInProcess(jSRuntime, inProcessHelper, jSReference, fileSystemOptions, creationOptions); + IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); + return new FileSystemDirectoryHandleInProcess(jSRuntime, inProcessHelper, jSReference, options); } /// - protected FileSystemDirectoryHandleInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions options) : base(jSRuntime, jSReference, fileSystemOptions, options) + protected FileSystemDirectoryHandleInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { this.inProcessHelper = inProcessHelper; JSReference = jSReference; @@ -83,14 +57,14 @@ protected FileSystemDirectoryHandleInProcess(IJSRuntime jSRuntime, IJSInProcessO { FileSystemHandleInProcess fileSystemHandle = await FileSystemHandleInProcess.CreateAsync( JSRuntime, - await jSEntries.InvokeAsync("at", i), - fileSystemOptions); + await jSEntries.InvokeAsync("at", i) + ); FileSystemHandleKind kind = await fileSystemHandle.GetKindAsync(); if (kind is FileSystemHandleKind.File) { - return await FileSystemFileHandleInProcess.CreateAsync(JSRuntime, fileSystemHandle.JSReference, fileSystemOptions, new CreationOptions() + return await FileSystemFileHandleInProcess.CreateAsync(JSRuntime, fileSystemHandle.JSReference, new CreationOptions() { DisposesJSReference = true }); @@ -112,7 +86,7 @@ await jSEntries.InvokeAsync("at", i), public new async Task GetFileHandleAsync(string name, FileSystemGetFileOptions? options = null) { IJSInProcessObjectReference jSFileSystemFileHandle = await JSReference.InvokeAsync("getFileHandle", name, options); - return await FileSystemFileHandleInProcess.CreateAsync(JSRuntime, jSFileSystemFileHandle, fileSystemOptions, new CreationOptions() + return await FileSystemFileHandleInProcess.CreateAsync(JSRuntime, jSFileSystemFileHandle, new CreationOptions() { DisposesJSReference = true }); @@ -122,7 +96,7 @@ await jSEntries.InvokeAsync("at", i), public new async Task GetDirectoryHandleAsync(string name, FileSystemGetDirectoryOptions? options = null) { IJSInProcessObjectReference jSFileSystemFileHandle = await JSReference.InvokeAsync("getDirectoryHandle", name, options); - return await CreateAsync(JSRuntime, jSFileSystemFileHandle, fileSystemOptions, new CreationOptions() + return await CreateAsync(JSRuntime, jSFileSystemFileHandle, new CreationOptions() { DisposesJSReference = true }); diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.cs index a0dd5d4..de2b5b2 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.cs @@ -13,54 +13,24 @@ public class FileSystemDirectoryHandle : FileSystemHandle, IJSCreatable public static new async Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference) { - return await CreateAsync(jSRuntime, jSReference, FileSystemOptions.DefaultInstance); + return await CreateAsync(jSRuntime, jSReference, new()); } /// public static new Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) { - return Task.FromResult(new FileSystemDirectoryHandle(jSRuntime, jSReference, FileSystemOptions.DefaultInstance, options)); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - public static new Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions options) - { - return Task.FromResult(new FileSystemDirectoryHandle(jSRuntime, jSReference, options, new() { DisposesJSReference = true })); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at and whether its JS reference should be disposed. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - /// Options for what path the JS helper module will be found at. - public static new Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions creationOptions) - { - return Task.FromResult(new FileSystemDirectoryHandle(jSRuntime, jSReference, fileSystemOptions, creationOptions)); + return Task.FromResult(new FileSystemDirectoryHandle(jSRuntime, jSReference, options)); } /// [Obsolete("This will be removed in the next major release as all creator methods should be asynchronous for uniformity. Use CreateAsync instead.")] public static new FileSystemDirectoryHandle Create(IJSRuntime jSRuntime, IJSObjectReference jSReference) { - return Create(jSRuntime, jSReference, FileSystemOptions.DefaultInstance); - } - - /// - [Obsolete("This will be removed in the next major release as all creator methods should be asynchronous for uniformity. Use CreateAsync instead.")] - public static new FileSystemDirectoryHandle Create(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions options) - { - return new(jSRuntime, jSReference, options, new()); + return new(jSRuntime, jSReference, new()); } /// - protected FileSystemDirectoryHandle(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions options) : base(jSRuntime, jSReference, fileSystemOptions, options) { } + protected FileSystemDirectoryHandle(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { } /// /// Gets all s in the directory. @@ -78,20 +48,21 @@ public async Task ValuesAsync() { await using FileSystemHandle fileSystemHandle = await FileSystemHandle.CreateAsync( JSRuntime, - await jSEntries.InvokeAsync("at", i), fileSystemOptions); + await jSEntries.InvokeAsync("at", i) + ); FileSystemHandleKind kind = await fileSystemHandle.GetKindAsync(); if (kind is FileSystemHandleKind.File) { - return await FileSystemFileHandle.CreateAsync(JSRuntime, fileSystemHandle.JSReference, fileSystemOptions, new CreationOptions() + return await FileSystemFileHandle.CreateAsync(JSRuntime, fileSystemHandle.JSReference, new CreationOptions() { DisposesJSReference = true }); } else { - return await CreateAsync(JSRuntime, fileSystemHandle.JSReference, fileSystemOptions, new CreationOptions() + return await CreateAsync(JSRuntime, fileSystemHandle.JSReference, new CreationOptions() { DisposesJSReference = true }); @@ -118,7 +89,7 @@ public async Task ValuesAsync() public async Task GetFileHandleAsync(string name, FileSystemGetFileOptions? options = null) { IJSObjectReference jSFileSystemFileHandle = await JSReference.InvokeAsync("getFileHandle", name, options); - return await FileSystemFileHandle.CreateAsync(JSRuntime, jSFileSystemFileHandle, fileSystemOptions, new CreationOptions() { DisposesJSReference = true }); + return await FileSystemFileHandle.CreateAsync(JSRuntime, jSFileSystemFileHandle, new CreationOptions() { DisposesJSReference = true }); } /// @@ -137,7 +108,7 @@ public async Task GetFileHandleAsync(string name, FileSyst public async Task GetDirectoryHandleAsync(string name, FileSystemGetDirectoryOptions? options = null) { IJSObjectReference jSFileSystemDirectoryHandle = await JSReference.InvokeAsync("getDirectoryHandle", name, options); - return new(JSRuntime, jSFileSystemDirectoryHandle, fileSystemOptions, new() { DisposesJSReference = true }); + return new(JSRuntime, jSFileSystemDirectoryHandle, new() { DisposesJSReference = true }); } /// diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.InProcess.cs index 1622841..22b3b5b 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.InProcess.cs @@ -1,5 +1,4 @@ -using KristofferStrube.Blazor.DOM.Extensions; -using KristofferStrube.Blazor.FileAPI; +using KristofferStrube.Blazor.FileAPI; using KristofferStrube.Blazor.FileSystem.Extensions; using KristofferStrube.Blazor.WebIDL; using Microsoft.JSInterop; @@ -28,37 +27,12 @@ public static async Task CreateAsync(IJSRuntime j /// public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(FileSystemOptions.DefaultInstance); - return new FileSystemFileHandleInProcess(jSRuntime, inProcessHelper, jSReference, FileSystemOptions.DefaultInstance, options); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, FileSystemOptions options) - { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(options); - return new FileSystemFileHandleInProcess(jSRuntime, inProcessHelper, jSReference, options, new() { DisposesJSReference = true }); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at and whether its JS reference should be disposed. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - /// Options for what path the JS helper module will be found at. - public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions creationOptions) - { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(fileSystemOptions); - return new FileSystemFileHandleInProcess(jSRuntime, inProcessHelper, jSReference, fileSystemOptions, creationOptions); + IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); + return new FileSystemFileHandleInProcess(jSRuntime, inProcessHelper, jSReference, options); } /// - protected FileSystemFileHandleInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions options) : base(jSRuntime, jSReference, fileSystemOptions, options) + protected FileSystemFileHandleInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { this.inProcessHelper = inProcessHelper; JSReference = jSReference; @@ -84,7 +58,7 @@ protected FileSystemFileHandleInProcess(IJSRuntime jSRuntime, IJSInProcessObject public new async Task CreateWritableAsync(FileSystemCreateWritableOptions? fileSystemCreateWritableOptions = null) { IJSInProcessObjectReference jSFileSystemWritableFileStream = await JSReference.InvokeAsync("createWritable", fileSystemCreateWritableOptions); - return await FileSystemWritableFileStreamInProcess.CreateAsync(JSRuntime, jSFileSystemWritableFileStream, fileSystemOptions, new() { DisposesJSReference = true }); + return await FileSystemWritableFileStreamInProcess.CreateAsync(JSRuntime, jSFileSystemWritableFileStream, new() { DisposesJSReference = true }); } /// diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.cs index 0e1ed7e..e95b514 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.cs @@ -20,48 +20,18 @@ public class FileSystemFileHandle : FileSystemHandle, IJSCreatable public static new Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) { - return Task.FromResult(new FileSystemFileHandle(jSRuntime, jSReference, FileSystemOptions.DefaultInstance, options)); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - public static new Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions options) - { - return Task.FromResult(new FileSystemFileHandle(jSRuntime, jSReference, options, new() { DisposesJSReference = true })); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at and whether its JS reference should be disposed. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - /// Options for what path the JS helper module will be found at. - public static new Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions creationOptions) - { - return Task.FromResult(new FileSystemFileHandle(jSRuntime, jSReference, fileSystemOptions, creationOptions)); + return Task.FromResult(new FileSystemFileHandle(jSRuntime, jSReference, options)); } /// [Obsolete("This will be removed in the next major release as all creator methods should be asynchronous for uniformity. Use CreateAsync instead.")] public static new FileSystemFileHandle Create(IJSRuntime jSRuntime, IJSObjectReference jSReference) { - return Create(jSRuntime, jSReference, FileSystemOptions.DefaultInstance); - } - - /// - [Obsolete("This will be removed in the next major release as all creator methods should be asynchronous for uniformity. Use CreateAsync instead.")] - public static new FileSystemFileHandle Create(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions options) - { - return new(jSRuntime, jSReference, options, new()); + return new(jSRuntime, jSReference, new()); } /// - protected FileSystemFileHandle(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions options) : base(jSRuntime, jSReference, fileSystemOptions, options) { } + protected FileSystemFileHandle(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { } /// /// Returns a that that represents the state of the file on the disk. If the file on disk changes or is removed after this method has returned the file then this will likely no longer be readable. @@ -87,7 +57,7 @@ public async Task GetFileAsync() public async Task CreateWritableAsync(FileSystemCreateWritableOptions? fileSystemCreateWritableOptions = null) { IJSObjectReference jSFileSystemWritableFileStream = await JSReference.InvokeAsync("createWritable", fileSystemCreateWritableOptions); - return await FileSystemWritableFileStream.CreateAsync(JSRuntime, jSFileSystemWritableFileStream, fileSystemOptions, new CreationOptions() + return await FileSystemWritableFileStream.CreateAsync(JSRuntime, jSFileSystemWritableFileStream, new CreationOptions() { DisposesJSReference = true }); diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.InProcess.cs index 3212b7b..a1ab52b 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.InProcess.cs @@ -1,5 +1,4 @@ -using KristofferStrube.Blazor.DOM.Extensions; -using KristofferStrube.Blazor.FileSystem.Extensions; +using KristofferStrube.Blazor.FileSystem.Extensions; using KristofferStrube.Blazor.WebIDL; using Microsoft.JSInterop; @@ -26,37 +25,12 @@ public static async Task CreateAsync(IJSRuntime jSRun /// public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(FileSystemOptions.DefaultInstance); - return new FileSystemHandleInProcess(jSRuntime, inProcessHelper, jSReference, FileSystemOptions.DefaultInstance, options); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, FileSystemOptions options) - { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(options); - return new FileSystemHandleInProcess(jSRuntime, inProcessHelper, jSReference, options, new() { DisposesJSReference = true }); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at and whether its JS reference should be disposed. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - /// Options for what path the JS helper module will be found at. - public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions creationOptions) - { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(fileSystemOptions); - return new FileSystemHandleInProcess(jSRuntime, inProcessHelper, jSReference, fileSystemOptions, creationOptions); + IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); + return new FileSystemHandleInProcess(jSRuntime, inProcessHelper, jSReference, options); } /// - protected FileSystemHandleInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions options) : base(jSRuntime, jSReference, fileSystemOptions, options) + protected FileSystemHandleInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { this.inProcessHelper = inProcessHelper; JSReference = jSReference; diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.cs index 76fb10b..5f1d258 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.cs @@ -16,48 +16,18 @@ public static async Task CreateAsync(IJSRuntime jSRuntime, IJS /// public static Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) { - return Task.FromResult(new FileSystemHandle(jSRuntime, jSReference, FileSystemOptions.DefaultInstance, options)); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - public static Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions options) - { - return Task.FromResult(new FileSystemHandle(jSRuntime, jSReference, options, new() { DisposesJSReference = true })); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at and whether its JS reference should be disposed. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - /// Options for what path the JS helper module will be found at. - public static Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions creationOptions) - { - return Task.FromResult(new FileSystemHandle(jSRuntime, jSReference, fileSystemOptions, creationOptions)); + return Task.FromResult(new FileSystemHandle(jSRuntime, jSReference, options)); } /// [Obsolete("This will be removed in the next major release as all creator methods should be asynchronous for uniformity. Use CreateAsync instead.")] public static FileSystemHandle Create(IJSRuntime jSRuntime, IJSObjectReference jSReference) { - return Create(jSRuntime, jSReference, FileSystemOptions.DefaultInstance); - } - - /// - [Obsolete("This will be removed in the next major release as all creator methods should be asynchronous for uniformity. Use CreateAsync instead.")] - public static FileSystemHandle Create(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions options) - { - return new(jSRuntime, jSReference, options, new()); + return new(jSRuntime, jSReference, new()); } /// - protected FileSystemHandle(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions options) : base(jSRuntime, jSReference, fileSystemOptions, options) { } + protected FileSystemHandle(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { } /// public async Task GetKindAsync() diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.InProcess.cs index 4449ac3..56d6b42 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.InProcess.cs @@ -1,5 +1,4 @@ -using KristofferStrube.Blazor.DOM.Extensions; -using KristofferStrube.Blazor.FileSystem.Extensions; +using KristofferStrube.Blazor.FileSystem.Extensions; using KristofferStrube.Blazor.Streams; using KristofferStrube.Blazor.WebIDL; using Microsoft.JSInterop; @@ -22,43 +21,18 @@ public class FileSystemWritableFileStreamInProcess : FileSystemWritableFileStrea /// public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) { - return await CreateAsync(jSRuntime, jSReference, FileSystemOptions.DefaultInstance); + return await CreateAsync(jSRuntime, jSReference, new()); } /// public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, CreationOptions options) { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(FileSystemOptions.DefaultInstance); - return new FileSystemWritableFileStreamInProcess(jSRuntime, inProcessHelper, jSReference, FileSystemOptions.DefaultInstance, options); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, FileSystemOptions options) - { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(options); - return new FileSystemWritableFileStreamInProcess(jSRuntime, inProcessHelper, jSReference, options, new() { DisposesJSReference = true }); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at and whether its JS reference should be disposed. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - /// Options for what path the JS helper module will be found at. - public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions creationOptions) - { - IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(fileSystemOptions); - return new FileSystemWritableFileStreamInProcess(jSRuntime, inProcessHelper, jSReference, fileSystemOptions, creationOptions); + IJSInProcessObjectReference inProcessHelper = await jSRuntime.GetInProcessHelperAsync(); + return new FileSystemWritableFileStreamInProcess(jSRuntime, inProcessHelper, jSReference, options); } /// - protected FileSystemWritableFileStreamInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions options) : base(jSRuntime, jSReference, fileSystemOptions, options) + protected FileSystemWritableFileStreamInProcess(IJSRuntime jSRuntime, IJSInProcessObjectReference inProcessHelper, IJSInProcessObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { this.inProcessHelper = inProcessHelper; JSReference = jSReference; diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.cs index 5dfb5cc..0c50709 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.cs @@ -32,43 +32,20 @@ public class FileSystemWritableFileStream : WritableStream, IJSCreatable public static new Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) { - return Task.FromResult(new FileSystemWritableFileStream(jSRuntime, jSReference, FileSystemOptions.DefaultInstance, options)); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - public static Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions options) - { - return Task.FromResult(new FileSystemWritableFileStream(jSRuntime, jSReference, options, new() { DisposesJSReference = true })); - } - - /// - /// Constructs a wrapper instance for an equivalent JS instance of a with options for where the JS helper module will be found at and whether its JS reference should be disposed. - /// - /// An instance. - /// A JS reference to an existing JS instance that should be wrapped. - /// Options for what path the JS helper module will be found at. - /// Options for what path the JS helper module will be found at. - public static Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions creationOptions) - { - return Task.FromResult(new FileSystemWritableFileStream(jSRuntime, jSReference, fileSystemOptions, creationOptions)); + return Task.FromResult(new FileSystemWritableFileStream(jSRuntime, jSReference, options)); } /// [Obsolete("This will be removed in the next major release as all creator methods should be asynchronous for uniformity. Use CreateAsync instead.")] public static new FileSystemWritableFileStream Create(IJSRuntime jSRuntime, IJSObjectReference jSReference) { - return new FileSystemWritableFileStream(jSRuntime, jSReference, FileSystemOptions.DefaultInstance, new() { DisposesJSReference = true }); + return new FileSystemWritableFileStream(jSRuntime, jSReference, new() { DisposesJSReference = true }); } /// - protected FileSystemWritableFileStream(IJSRuntime jSRuntime, IJSObjectReference jSReference, FileSystemOptions fileSystemOptions, CreationOptions options) : base(jSRuntime, jSReference, options) + protected FileSystemWritableFileStream(IJSRuntime jSRuntime, IJSObjectReference jSReference, CreationOptions options) : base(jSRuntime, jSReference, options) { - FileSystemHelperTask = new(() => jSRuntime.GetHelperAsync(fileSystemOptions)); + FileSystemHelperTask = new(jSRuntime.GetHelperAsync); } /// diff --git a/src/KristofferStrube.Blazor.FileSystem/IStorageManagerService.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/IStorageManagerService.InProcess.cs index 447ca95..0f28ecd 100644 --- a/src/KristofferStrube.Blazor.FileSystem/IStorageManagerService.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/IStorageManagerService.InProcess.cs @@ -9,11 +9,4 @@ public interface IStorageManagerServiceInProcess : IStorageManagerService /// Gets a that is a local bucket for the current domain. It is persistent across sessions. /// public new Task GetOriginPrivateDirectoryAsync(); - - /// - /// - /// This overload has explicit options for how you want to import the JS helper module used in the library. - /// - /// Options for how the wrapper should construct its JS helper module - public new Task GetOriginPrivateDirectoryAsync(FileSystemOptions options); } \ No newline at end of file diff --git a/src/KristofferStrube.Blazor.FileSystem/IStorageManagerService.cs b/src/KristofferStrube.Blazor.FileSystem/IStorageManagerService.cs index 9291a2c..df65085 100644 --- a/src/KristofferStrube.Blazor.FileSystem/IStorageManagerService.cs +++ b/src/KristofferStrube.Blazor.FileSystem/IStorageManagerService.cs @@ -10,11 +10,4 @@ public interface IStorageManagerService /// Gets a that is a local bucket for the current domain. It is persistent across sessions. /// public Task GetOriginPrivateDirectoryAsync(); - - /// - /// - /// This overload has explicit options for how you want to import the JS helper module used in the library. - /// - /// Options for how the wrapper should construct its JS helper module - public Task GetOriginPrivateDirectoryAsync(FileSystemOptions options); } \ No newline at end of file diff --git a/src/KristofferStrube.Blazor.FileSystem/Options/FileSystemOptions.cs b/src/KristofferStrube.Blazor.FileSystem/Options/FileSystemOptions.cs deleted file mode 100644 index bdbab79..0000000 --- a/src/KristofferStrube.Blazor.FileSystem/Options/FileSystemOptions.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Reflection; - -namespace KristofferStrube.Blazor.FileSystem; - -/// -/// Options for what path the JS helper module will be found at. -/// -public class FileSystemOptions -{ - /// - /// The base path that is used by default. - /// - public const string DefaultBasePath = "./_content/"; - - /// - /// The namespace that the JS module will be found in by default. - /// - public static readonly string DefaultNamespace = Assembly.GetExecutingAssembly().GetName().Name ?? "KristofferStrube.Blazor.FileSystem"; - - /// - /// The standard fill path for the JS module. - /// - public static readonly string DefaultScriptPath = $"{DefaultNamespace}/{DefaultNamespace}.js"; - - /// - /// Option for changing the base path. - /// - public string BasePath { get; set; } = DefaultBasePath; - - /// - /// Option for changing the relative path for the JS module. - /// - public string ScriptPath { get; set; } = DefaultScriptPath; - - /// - /// The calculated full script path that locates the JS module. - /// - public string FullScriptPath => Path.Combine(BasePath, ScriptPath); - - /// - /// A static instance that can be reused in places where no other options are defined. - /// - internal static FileSystemOptions DefaultInstance = new(); -} \ No newline at end of file diff --git a/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.InProcess.cs index 1fc9861..88bc2c8 100644 --- a/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.InProcess.cs @@ -14,15 +14,9 @@ public StorageManagerServiceInProcess(IJSRuntime jSRuntime) : base(jSRuntime) { /// public new async Task GetOriginPrivateDirectoryAsync() - { - return await GetOriginPrivateDirectoryAsync(FileSystemOptions.DefaultInstance); - } - - /// - public new async Task GetOriginPrivateDirectoryAsync(FileSystemOptions options) { IJSInProcessObjectReference directoryHandle = await jSRuntime.InvokeAsync("navigator.storage.getDirectory"); - return await FileSystemDirectoryHandleInProcess.CreateAsync(jSRuntime, directoryHandle, options, new CreationOptions() + return await FileSystemDirectoryHandleInProcess.CreateAsync(jSRuntime, directoryHandle, new CreationOptions() { DisposesJSReference = true }); diff --git a/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.cs b/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.cs index dc3e642..ef4a576 100644 --- a/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.cs +++ b/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.cs @@ -1,15 +1,11 @@ -using KristofferStrube.Blazor.FileSystem.Extensions; using KristofferStrube.Blazor.WebIDL; using Microsoft.JSInterop; namespace KristofferStrube.Blazor.FileSystem; /// -public class StorageManagerService : IStorageManagerService, IAsyncDisposable +public class StorageManagerService : IStorageManagerService { - /// - protected readonly Lazy> helperTask; - /// /// The used for making JSInterop calls. /// @@ -21,34 +17,16 @@ public class StorageManagerService : IStorageManagerService, IAsyncDisposable /// An instance. public StorageManagerService(IJSRuntime jSRuntime) { - helperTask = new(() => jSRuntime.GetHelperAsync(FileSystemOptions.DefaultInstance)); this.jSRuntime = jSRuntime; } /// public async Task GetOriginPrivateDirectoryAsync() - { - return await GetOriginPrivateDirectoryAsync(FileSystemOptions.DefaultInstance); - } - - /// - public async Task GetOriginPrivateDirectoryAsync(FileSystemOptions options) { IJSObjectReference directoryHandle = await jSRuntime.InvokeAsync("navigator.storage.getDirectory"); - return await FileSystemDirectoryHandle.CreateAsync(jSRuntime, directoryHandle, options, new CreationOptions() + return await FileSystemDirectoryHandle.CreateAsync(jSRuntime, directoryHandle, new CreationOptions() { DisposesJSReference = true }); } - - /// - public async ValueTask DisposeAsync() - { - if (helperTask.IsValueCreated) - { - IJSObjectReference module = await helperTask.Value; - await module.DisposeAsync(); - } - GC.SuppressFinalize(this); - } } From 7b1105529d0daa4218a872ce07dfa94a7d38419a Mon Sep 17 00:00:00 2001 From: KristofferStrube Date: Tue, 28 Oct 2025 21:49:15 +0100 Subject: [PATCH 2/2] Simplified `CreationOptions` initialization. --- .../FileSystemDirectoryHandle.InProcess.cs | 10 +++++----- .../FileSystemDirectoryHandle.cs | 6 +++--- .../FileSystemFileHandle.InProcess.cs | 2 +- .../FileSystemFileHandle.cs | 4 ++-- .../FileSystemHandle.InProcess.cs | 2 +- .../FileSystemHandle.cs | 2 +- .../FileSystemWritableFileStream.cs | 2 +- .../StorageManagerService.InProcess.cs | 3 +-- .../StorageManagerService.cs | 3 +-- 9 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.InProcess.cs index 718f72d..c218d8f 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.InProcess.cs @@ -20,7 +20,7 @@ public class FileSystemDirectoryHandleInProcess : FileSystemDirectoryHandle, IFi /// public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) { - return await CreateAsync(jSRuntime, jSReference, new CreationOptions()); + return await CreateAsync(jSRuntime, jSReference, new()); } /// @@ -64,14 +64,14 @@ await jSEntries.InvokeAsync("at", i) if (kind is FileSystemHandleKind.File) { - return await FileSystemFileHandleInProcess.CreateAsync(JSRuntime, fileSystemHandle.JSReference, new CreationOptions() + return await FileSystemFileHandleInProcess.CreateAsync(JSRuntime, fileSystemHandle.JSReference, new() { DisposesJSReference = true }); } else { - return await CreateAsync(JSRuntime, fileSystemHandle.JSReference, new CreationOptions() + return await CreateAsync(JSRuntime, fileSystemHandle.JSReference, new() { DisposesJSReference = true }); @@ -86,7 +86,7 @@ await jSEntries.InvokeAsync("at", i) public new async Task GetFileHandleAsync(string name, FileSystemGetFileOptions? options = null) { IJSInProcessObjectReference jSFileSystemFileHandle = await JSReference.InvokeAsync("getFileHandle", name, options); - return await FileSystemFileHandleInProcess.CreateAsync(JSRuntime, jSFileSystemFileHandle, new CreationOptions() + return await FileSystemFileHandleInProcess.CreateAsync(JSRuntime, jSFileSystemFileHandle, new() { DisposesJSReference = true }); @@ -96,7 +96,7 @@ await jSEntries.InvokeAsync("at", i) public new async Task GetDirectoryHandleAsync(string name, FileSystemGetDirectoryOptions? options = null) { IJSInProcessObjectReference jSFileSystemFileHandle = await JSReference.InvokeAsync("getDirectoryHandle", name, options); - return await CreateAsync(JSRuntime, jSFileSystemFileHandle, new CreationOptions() + return await CreateAsync(JSRuntime, jSFileSystemFileHandle, new() { DisposesJSReference = true }); diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.cs index de2b5b2..c4fedf7 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemDirectoryHandle.cs @@ -55,14 +55,14 @@ await jSEntries.InvokeAsync("at", i) if (kind is FileSystemHandleKind.File) { - return await FileSystemFileHandle.CreateAsync(JSRuntime, fileSystemHandle.JSReference, new CreationOptions() + return await FileSystemFileHandle.CreateAsync(JSRuntime, fileSystemHandle.JSReference, new() { DisposesJSReference = true }); } else { - return await CreateAsync(JSRuntime, fileSystemHandle.JSReference, new CreationOptions() + return await CreateAsync(JSRuntime, fileSystemHandle.JSReference, new() { DisposesJSReference = true }); @@ -89,7 +89,7 @@ await jSEntries.InvokeAsync("at", i) public async Task GetFileHandleAsync(string name, FileSystemGetFileOptions? options = null) { IJSObjectReference jSFileSystemFileHandle = await JSReference.InvokeAsync("getFileHandle", name, options); - return await FileSystemFileHandle.CreateAsync(JSRuntime, jSFileSystemFileHandle, new CreationOptions() { DisposesJSReference = true }); + return await FileSystemFileHandle.CreateAsync(JSRuntime, jSFileSystemFileHandle, new() { DisposesJSReference = true }); } /// diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.InProcess.cs index 22b3b5b..29fcfe3 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.InProcess.cs @@ -21,7 +21,7 @@ public class FileSystemFileHandleInProcess : FileSystemFileHandle, IFileSystemHa /// public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) { - return await CreateAsync(jSRuntime, jSReference, new CreationOptions()); + return await CreateAsync(jSRuntime, jSReference, new()); } /// diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.cs index e95b514..925206d 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemFileHandle.cs @@ -14,7 +14,7 @@ public class FileSystemFileHandle : FileSystemHandle, IJSCreatable public static new async Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference) { - return await CreateAsync(jSRuntime, jSReference, new CreationOptions()); + return await CreateAsync(jSRuntime, jSReference, new()); } /// @@ -57,7 +57,7 @@ public async Task GetFileAsync() public async Task CreateWritableAsync(FileSystemCreateWritableOptions? fileSystemCreateWritableOptions = null) { IJSObjectReference jSFileSystemWritableFileStream = await JSReference.InvokeAsync("createWritable", fileSystemCreateWritableOptions); - return await FileSystemWritableFileStream.CreateAsync(JSRuntime, jSFileSystemWritableFileStream, new CreationOptions() + return await FileSystemWritableFileStream.CreateAsync(JSRuntime, jSFileSystemWritableFileStream, new() { DisposesJSReference = true }); diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.InProcess.cs index a1ab52b..d97d9ed 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.InProcess.cs @@ -19,7 +19,7 @@ public class FileSystemHandleInProcess : FileSystemHandle, IFileSystemHandleInPr /// public static async Task CreateAsync(IJSRuntime jSRuntime, IJSInProcessObjectReference jSReference) { - return await CreateAsync(jSRuntime, jSReference, new CreationOptions()); + return await CreateAsync(jSRuntime, jSReference, new()); } /// diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.cs index 5f1d258..21d65c9 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemHandle.cs @@ -10,7 +10,7 @@ public class FileSystemHandle : BaseJSWrapper, IFileSystemHandle, IJSCreatable public static async Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference) { - return await CreateAsync(jSRuntime, jSReference, new CreationOptions()); + return await CreateAsync(jSRuntime, jSReference, new()); } /// diff --git a/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.cs b/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.cs index 0c50709..0c8e7cf 100644 --- a/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.cs +++ b/src/KristofferStrube.Blazor.FileSystem/FileSystemWritableFileStream.cs @@ -26,7 +26,7 @@ public class FileSystemWritableFileStream : WritableStream, IJSCreatable public static new async Task CreateAsync(IJSRuntime jSRuntime, IJSObjectReference jSReference) { - return await CreateAsync(jSRuntime, jSReference, new CreationOptions()); + return await CreateAsync(jSRuntime, jSReference, new()); } /// diff --git a/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.InProcess.cs b/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.InProcess.cs index 88bc2c8..73d26f3 100644 --- a/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.InProcess.cs +++ b/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.InProcess.cs @@ -1,4 +1,3 @@ -using KristofferStrube.Blazor.WebIDL; using Microsoft.JSInterop; namespace KristofferStrube.Blazor.FileSystem; @@ -16,7 +15,7 @@ public StorageManagerServiceInProcess(IJSRuntime jSRuntime) : base(jSRuntime) { public new async Task GetOriginPrivateDirectoryAsync() { IJSInProcessObjectReference directoryHandle = await jSRuntime.InvokeAsync("navigator.storage.getDirectory"); - return await FileSystemDirectoryHandleInProcess.CreateAsync(jSRuntime, directoryHandle, new CreationOptions() + return await FileSystemDirectoryHandleInProcess.CreateAsync(jSRuntime, directoryHandle, new() { DisposesJSReference = true }); diff --git a/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.cs b/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.cs index ef4a576..b28a7ae 100644 --- a/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.cs +++ b/src/KristofferStrube.Blazor.FileSystem/StorageManagerService.cs @@ -1,4 +1,3 @@ -using KristofferStrube.Blazor.WebIDL; using Microsoft.JSInterop; namespace KristofferStrube.Blazor.FileSystem; @@ -24,7 +23,7 @@ public StorageManagerService(IJSRuntime jSRuntime) public async Task GetOriginPrivateDirectoryAsync() { IJSObjectReference directoryHandle = await jSRuntime.InvokeAsync("navigator.storage.getDirectory"); - return await FileSystemDirectoryHandle.CreateAsync(jSRuntime, directoryHandle, new CreationOptions() + return await FileSystemDirectoryHandle.CreateAsync(jSRuntime, directoryHandle, new() { DisposesJSReference = true });