diff --git a/samples/KristofferStrube.Blazor.FileSystemAccess.ServerExample/Pages/Status.razor b/samples/KristofferStrube.Blazor.FileSystemAccess.ServerExample/Pages/Status.razor deleted file mode 100644 index cba5c4e..0000000 --- a/samples/KristofferStrube.Blazor.FileSystemAccess.ServerExample/Pages/Status.razor +++ /dev/null @@ -1,131 +0,0 @@ -@page "/Status" - -@using HtmlAgilityPack; - -@inject HttpClient HttpClient -@inject IJSRuntime JSRuntime - -File System Access - Status - -@if (compareText is not null) -{ -

-            @((MarkupString)compareText)
-            
-} -else -{ - Loading WebIDL from specs ... -} - -@code { - private string? compareText; - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - { - var domString = await HttpClient.GetStringAsync("https://wicg.github.io/file-system-access/#idl-index"); - - var dom = new HtmlDocument(); - dom.LoadHtml(domString); - var idlIndexHeader = dom.GetElementbyId("idl-index"); - var webIDLNode = idlIndexHeader.NextSibling.NextSibling; - var webIDLText = webIDLNode.InnerText; - // We normalize to indent with 4 spaces as that is inconsistent in the current WebIDL specs. - var fetchedLines = webIDLText.Replace(" ", " ").Replace("\n ", "\n ").Split('\n'); - var supportedLines = currentlySupportedWebIDL.Replace("<", "<").Split('\n'); - var compareLines = new List(); - var fetchedIndex = 0; - var supportedIndex = 0; - while (fetchedIndex < fetchedLines.Length || supportedIndex < supportedLines.Length) - { - var color = "pink"; - if (fetchedIndex == fetchedLines.Length) - { - color = "cyan"; - supportedIndex++; - fetchedIndex--; - } - else if (supportedIndex == supportedLines.Length) - { - color = "lemonchiffon"; - } - else if (fetchedLines[fetchedIndex].Trim() == supportedLines[supportedIndex].Trim()) - { - color = "lightgreen"; - supportedIndex++; - } - compareLines.Add($"""{fetchedLines[fetchedIndex++]}"""); - } - compareText = string.Join("", compareLines); - StateHasChanged(); - } - } - - private const string currentlySupportedWebIDL = - @"enum FileSystemPermissionMode { - ""read"", - ""readwrite"" -}; - -dictionary FileSystemPermissionDescriptor : PermissionDescriptor { - required FileSystemHandle handle; - FileSystemPermissionMode mode = ""read""; -}; - -dictionary FileSystemHandlePermissionDescriptor { - FileSystemPermissionMode mode = ""read""; -}; - -[Exposed=(Window,Worker), SecureContext, Serializable] -partial interface FileSystemHandle { - Promise queryPermission(optional FileSystemHandlePermissionDescriptor descriptor = {}); - Promise requestPermission(optional FileSystemHandlePermissionDescriptor descriptor = {}); -}; - -enum WellKnownDirectory { - ""desktop"", - ""documents"", - ""downloads"", - ""music"", - ""pictures"", - ""videos"", -}; - -typedef (WellKnownDirectory or FileSystemHandle) StartInDirectory; - -dictionary FilePickerAcceptType { - USVString description; - record)> accept; -}; - -dictionary FilePickerOptions { - sequence types; - boolean excludeAcceptAllOption = false; - DOMString id; - StartInDirectory startIn; -}; - -dictionary OpenFilePickerOptions : FilePickerOptions { - boolean multiple = false; -}; - -dictionary SaveFilePickerOptions : FilePickerOptions { - USVString? suggestedName; -}; - -dictionary DirectoryPickerOptions { - DOMString id; - StartInDirectory startIn; - FileSystemPermissionMode mode = ""read""; -}; - -[SecureContext] -partial interface Window { - Promise> showOpenFilePicker(optional OpenFilePickerOptions options = {}); - Promise showSaveFilePicker(optional SaveFilePickerOptions options = {}); - Promise showDirectoryPicker(optional DirectoryPickerOptions options = {}); -};"; - -} diff --git a/samples/KristofferStrube.Blazor.FileSystemAccess.ServerExample/Shared/NavMenu.razor b/samples/KristofferStrube.Blazor.FileSystemAccess.ServerExample/Shared/NavMenu.razor index bea131f..2753334 100644 --- a/samples/KristofferStrube.Blazor.FileSystemAccess.ServerExample/Shared/NavMenu.razor +++ b/samples/KristofferStrube.Blazor.FileSystemAccess.ServerExample/Shared/NavMenu.razor @@ -64,11 +64,6 @@ InputFile Example - diff --git a/samples/KristofferStrube.Blazor.FileSystemAccess.WasmExample/Pages/Status.razor b/samples/KristofferStrube.Blazor.FileSystemAccess.WasmExample/Pages/Status.razor index df3c125..68794a2 100644 --- a/samples/KristofferStrube.Blazor.FileSystemAccess.WasmExample/Pages/Status.razor +++ b/samples/KristofferStrube.Blazor.FileSystemAccess.WasmExample/Pages/Status.razor @@ -96,7 +96,7 @@ enum WellKnownDirectory { typedef (WellKnownDirectory or FileSystemHandle) StartInDirectory; dictionary FilePickerAcceptType { - USVString description; + USVString description = """"; record)> accept; }; diff --git a/src/KristofferStrube.Blazor.FileSystemAccess/Options/FilePickerAcceptType.cs b/src/KristofferStrube.Blazor.FileSystemAccess/Options/FilePickerAcceptType.cs index e6166b6..0d55377 100644 --- a/src/KristofferStrube.Blazor.FileSystemAccess/Options/FilePickerAcceptType.cs +++ b/src/KristofferStrube.Blazor.FileSystemAccess/Options/FilePickerAcceptType.cs @@ -9,7 +9,7 @@ public class FilePickerAcceptType { [JsonPropertyName("description")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public string? Description { get; set; } + public string? Description { get; set; } = ""; [JsonPropertyName("accept")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]