{"id":26280083,"url":"https://github.com/kristofferstrube/blazor.streams","last_synced_at":"2025-08-17T20:10:30.104Z","repository":{"id":61755561,"uuid":"553508384","full_name":"KristofferStrube/Blazor.Streams","owner":"KristofferStrube","description":"A Blazor wrapper for the Streams browser API.","archived":false,"fork":false,"pushed_at":"2025-08-06T07:33:22.000Z","size":11867,"stargazers_count":17,"open_issues_count":5,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-12T08:50:21.328Z","etag":null,"topics":["blazor","blazor-interop","csharp","dotnet","filesystem","github-actions","github-pages","jsinterop","readable-stream","streams","wrapper","writable-streams"],"latest_commit_sha":null,"homepage":"https://kristofferstrube.github.io/Blazor.Streams/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KristofferStrube.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-10-18T10:21:10.000Z","updated_at":"2025-08-08T22:52:07.000Z","dependencies_parsed_at":"2024-08-04T11:29:48.725Z","dependency_job_id":"e9bdc0ee-7c24-4ee8-a510-662cd57cedf8","html_url":"https://github.com/KristofferStrube/Blazor.Streams","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/KristofferStrube/Blazor.Streams","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KristofferStrube%2FBlazor.Streams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KristofferStrube%2FBlazor.Streams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KristofferStrube%2FBlazor.Streams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KristofferStrube%2FBlazor.Streams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KristofferStrube","download_url":"https://codeload.github.com/KristofferStrube/Blazor.Streams/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KristofferStrube%2FBlazor.Streams/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270899582,"owners_count":24664720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor","blazor-interop","csharp","dotnet","filesystem","github-actions","github-pages","jsinterop","readable-stream","streams","wrapper","writable-streams"],"created_at":"2025-03-14T14:18:35.788Z","updated_at":"2025-08-17T20:10:30.070Z","avatar_url":"https://github.com/KristofferStrube.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](/LICENSE.md)\n[![GitHub issues](https://img.shields.io/github/issues/KristofferStrube/Blazor.Streams)](https://github.com/KristofferStrube/Blazor.Streams/issues)\n[![GitHub forks](https://img.shields.io/github/forks/KristofferStrube/Blazor.Streams)](https://github.com/KristofferStrube/Blazor.Streams/network/members)\n[![GitHub stars](https://img.shields.io/github/stars/KristofferStrube/Blazor.Streams)](https://github.com/KristofferStrube/Blazor.Streams/stargazers)\n\n[![NuGet Downloads (official NuGet)](https://img.shields.io/nuget/dt/KristofferStrube.Blazor.Streams?label=NuGet%20Downloads)](https://www.nuget.org/packages/KristofferStrube.Blazor.Streams/)\n\n# Introduction\nA Blazor wrapper for the browser API [Streams](https://streams.spec.whatwg.org/)\n\nThe API standardizes ways to create, compose, and consume streams of data that map to low-level I/O primitives in the browser. This project implements a wrapper around the API for Blazor so that we can easily and safely interact with the streams of the browser.\n\n# Demo\nThe sample project can be demoed at https://kristofferstrube.github.io/Blazor.Streams/\n\nOn each page you can find the corresponding code for the example in the top right corner.\n\nOn the *API Coverage Status* page you can get an overview over what parts of the API we support currently.\n\n# Getting Started\nThe package can be used in Blazor projects.\n## Prerequisites\nYou need to install .NET 7.0 or newer to use the library.\n\n[Download .NET 7](https://dotnet.microsoft.com/download/dotnet/7.0)\n\n## Installation\nYou can install the package via Nuget with the Package Manager in your IDE or alternatively using the command line:\n```bash\ndotnet add package KristofferStrube.Blazor.Streams\n```\n\n## Import\nYou need to reference the package in order to use it in your pages. This can be done in `_Import.razor` by adding the following.\n```razor\n@using KristofferStrube.Blazor.Streams\n```\n## Creating wrapper instance\nWe can call the constructor for `ReadableStream`, `WritableStream`, or `TransformStream` from C# and work on these objects like so:\n```razor\n@inject IJSInProcessRuntime JSRuntime\n\n@code {\n    protected override async Task OnInitializedAsync()\n    {\n        // Construct a stream in .NET.\n        using var data = new System.IO.MemoryStream(new byte[1000 * 1024]);\n        \n        // Convert a .NET Stream to a JS ReadableStream.\n        using var streamRef = new DotNetStreamReference(stream: data, leaveOpen: false);\n        var jSStreamReference = await JSRuntime.InvokeAsync\u003cIJSInProcessObjectReference\u003e(\"jSStreamReference\", streamRef);\n        \n        // Create a wrapper instance of the ReadableStream.\n        var readableStream = await ReadableStream.CreateAsync(JSRuntime, jSStreamReference);\n\n        // Get the reader and iterate that.\n        var readableStreamReader = await readableStream.GetDefaultReaderAsync();\n        await foreach (var chunk in readableStreamReader)\n        {\n            var length = await JSRuntime.InvokeAsync\u003cint\u003e(\"getAttribute\", chunk, \"length\");\n            Console.WriteLine(length);\n            await Task.Delay(100);\n        }\n    }\n}\n```\n\nFor the above example we use two small JavaScript functions that basically serves as a way to convert the .NET `DotNetStreamReference` object into an `IJSObjectReference` and a way to get any attribute of an `IJSObjectReference`. These methods looks like this and can be defined in the `index.html` or `_host.razor` page.\n```javascript\nfunction jSStreamReference(streamRef) { return streamRef.stream(); }\nfunction getAttribute(object, attribute) { return object[attribute]; }\n```\n\n# Issues\nFeel free to open issues on the repository if you find any errors with the package or have wishes for features.\n\n# Related articles\nThis repository was build with inspiration and help from the following series of articles:\n\n- [Wrapping JavaScript libraries in Blazor WebAssembly/WASM](https://blog.elmah.io/wrapping-javascript-libraries-in-blazor-webassembly-wasm/)\n- [Call anonymous C# functions from JS in Blazor WASM](https://blog.elmah.io/call-anonymous-c-functions-from-js-in-blazor-wasm/)\n- [Using JS Object References in Blazor WASM to wrap JS libraries](https://blog.elmah.io/using-js-object-references-in-blazor-wasm-to-wrap-js-libraries/)\n- [Blazor WASM 404 error and fix for GitHub Pages](https://blog.elmah.io/blazor-wasm-404-error-and-fix-for-github-pages/)\n- [How to fix Blazor WASM base path problems](https://blog.elmah.io/how-to-fix-blazor-wasm-base-path-problems/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristofferstrube%2Fblazor.streams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkristofferstrube%2Fblazor.streams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristofferstrube%2Fblazor.streams/lists"}