{"id":13807118,"url":"https://github.com/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator","last_synced_at":"2025-05-14T00:31:03.102Z","repository":{"id":45254642,"uuid":"278913707","full_name":"canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator","owner":"canhorn","description":"This project is a Blazor Interop C# Generator, has a sample against the BabylonJS library.","archived":false,"fork":false,"pushed_at":"2024-09-03T03:46:29.000Z","size":7209,"stargazers_count":143,"open_issues_count":20,"forks_count":21,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-10T05:31:56.738Z","etag":null,"topics":["babylonjs","blazor","blazor-interop","blazor-server","blazor-wasm","blazor-webassembly","typescript-parser"],"latest_commit_sha":null,"homepage":"https://wonderful-pond-05f7b3b10.azurestaticapps.net/","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/canhorn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2020-07-11T17:51:36.000Z","updated_at":"2025-04-24T14:43:45.000Z","dependencies_parsed_at":"2024-11-14T18:45:21.312Z","dependency_job_id":null,"html_url":"https://github.com/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator","commit_stats":{"total_commits":116,"total_committers":3,"mean_commits":"38.666666666666664","dds":"0.051724137931034475","last_synced_commit":"382eb16345a94a3b3a0a1e6b0ba3f4efc3aba3c5"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canhorn%2FEventHorizon.Blazor.TypeScript.Interop.Generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canhorn%2FEventHorizon.Blazor.TypeScript.Interop.Generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canhorn%2FEventHorizon.Blazor.TypeScript.Interop.Generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canhorn%2FEventHorizon.Blazor.TypeScript.Interop.Generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/canhorn","download_url":"https://codeload.github.com/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254046242,"owners_count":22005559,"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","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":["babylonjs","blazor","blazor-interop","blazor-server","blazor-wasm","blazor-webassembly","typescript-parser"],"created_at":"2024-08-04T01:01:21.132Z","updated_at":"2025-05-14T00:30:58.080Z","avatar_url":"https://github.com/canhorn.png","language":"C#","readme":"[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fcanhorn%2FEventHorizon.Blazor.TypeScript.Interop.Generator%2Fbadge%3Fref%3Dmain\u0026style=for-the-badge)](https://actions-badge.atrox.dev/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator/goto?ref=main)\n[![codecov](https://img.shields.io/codecov/c/github/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator?style=for-the-badge)](https://codecov.io/gh/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator)\n[![EventHorizon.Blazor.TypeScript.Interop.Generator](https://img.shields.io/nuget/v/EventHorizon.Blazor.TypeScript.Interop.Generator?style=for-the-badge\u0026label=Nuget)](https://www.nuget.org/packages/EventHorizon.Blazor.TypeScript.Interop.Generator)\n\n[![GitHub](https://img.shields.io/github/license/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator?style=for-the-badge)](https://github.com/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator/blob/main/LICENSE)\n[![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator?include_prereleases\u0026label=latest%20tag\u0026style=for-the-badge)](https://github.com/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator/tags)\n\n[![EventHorizon.Blazor.TypeScript.Interop.Generator](https://img.shields.io/nuget/vpre/EventHorizon.Blazor.TypeScript.Interop.Generator?style=for-the-badge\u0026label=Generator)](https://www.nuget.org/packages/EventHorizon.Blazor.TypeScript.Interop.Generator)\n[![EventHorizon.Blazor.TypeScript.Interop.Generator.Model](https://img.shields.io/nuget/vpre/EventHorizon.Blazor.TypeScript.Interop.Generator.Model?style=for-the-badge\u0026label=Model)](https://www.nuget.org/packages/EventHorizon.Blazor.TypeScript.Interop.Generator.Model)\n[![EventHorizon.Blazor.TypeScript.Interop.Generator.Writers.Project](https://img.shields.io/nuget/vpre/EventHorizon.Blazor.TypeScript.Interop.Generator.Writers.Project?style=for-the-badge\u0026label=Project+Writer)](https://www.nuget.org/packages/EventHorizon.Blazor.TypeScript.Interop.Generator.Writers.Project)\n\n[![EventHorizon.Blazor.TypeScript.Interop.Tool](https://img.shields.io/nuget/vpre/EventHorizon.Blazor.TypeScript.Interop.Tool?style=for-the-badge\u0026label=Tool)](https://www.nuget.org/packages/EventHorizon.Blazor.TypeScript.Interop.Tool)\n\n# About EventHorizon Blazor TypeScript Interop Generator\n\nThis project generates a C# Blazor Interop proxy using a TypeScript definition file.\n\n## Details\n\nThe generated project can be used with Blazor Wasm/Server to interface with JavaScript from C#, this gives most JavaScript libraries an easy to use interface from C#.\nIt uses the JSRuntime to interop directly with the underlying JavaScript from C#, this is done with a custom interop abstraction.\n\nThe Wasm interop project can be found in the [canhorn/EventHorizon.Blazor.Interop](https://github.com/canhorn/EventHorizon.Blazor.Interop) repository, it gives the generated code access to a common set of access patterns it then uses to interface with the JavaScript. The [canhorn/EventHorizon.Blazor.Server.Interop](https://github.com/canhorn/EventHorizon.Blazor.Server.Interop) repository contains the Blazor Server, async first, JavaScript access patterns.\n\n## Tech Used\n\n* [.NET Core](https://dotnet.microsoft.com/)\n* [TypeScript](https://www.typescriptlang.org/)\n* [NodeJS](https://nodejs.org/)\n  * Required Version \u003e= 20\n\n## Using the Tool\n\n~~~ bash\ndotnet tool install -g EventHorizon.Blazor.TypeScript.Interop.Tool\n~~~\n\n## Command Line Options\n\nIdentifier | Details | Required/Default\n--- | --- | ---\n-s, --source \u0026lt;source\u0026gt; | TypeScript Definition to generate from, can be a File or URL, accepts multiple or as Array |  REQUIRED\n-c, --class-to-generate \u0026lt;class-to-generate\u0026gt; | A Class to generate, accepts multiple or as Array |  REQUIRED\n-a, --project-assembly \u0026lt;project-assembly\u0026gt; | The project name of the Assembly that will be generated | Default: \"Generated.WASM\"\n-l, --project-generation-location \u0026lt;project-generation-location\u0026gt; | The directory where the Generated Project assembly will be saved | Default: \"_generated\"\n-f, --force | This will force generation, by deleting --project-generation-location | Default: (False)\n-p, --parser | The type of TypeScript parser to use, Supported values: (\"dotnet\",\"nodejs\")  | Default: (\"dotnet\")\n-h, --host-type | The host type the source should be generator for, Supported values: (\"wasm\",\"server\"). | Default: (\"wasm\") \n\nMore details in the [Tool README.md](./Tool/EventHorizon.Blazor.TypeScript.Interop.Tool/README.md).\n\n## TypeScript Parser\n\nThe generation relies heavily on the TypeScript Abstract Syntax Tree and so the code includes ways to parse the source files into a AST representation for easier generation.\n\nThe code has two supported parser types, .NET and NodeJS, to do realtime parsing of code. Using a .NET library it's able to do very quick parsing, but since it has not been maintained it can not handle complex or modern TypeScript syntax.\nBut with the NodeJS TypeScript parser it can handle modern more complex TypeScript syntax, but with the trade off of in speed.\n\n\u003e Having NodeJS installed is required to use the NodeJS TypeScript parser. (This is required when using the parser with the Tool)\n\n## Supported API's Generated\n\nBelow is a list of API that will be generated.\n\nAPI | Details | Example | Support\n--- | --- | --- | ---\nConstructor | You can use the default constructor of Classes, causes new call in JavaScript. | ```new BabylonJS.Engine()``` | :heavy_check_mark:\nConstructor with arguments | Same as Constructor, but can also pass in arguments. | ```new BabylonJS.Engine(\"canvas-window-id\")``` | :heavy_check_mark:\nProperty | You can get or set properties supplied by the object. | ```var isDisabled = engine.disableManifestCheck``` and ```engine.disableManifestCheck = true``` | :heavy_check_mark:\nProperty | You can ***set*** properties supplied by created objects. | ```engine.disableManifestCheck = true``` | :heavy_check_mark:\nStatic Property | You can ***get*** ***Static*** properties of a Class. | ```var isDisabled = Engine.ALPHA_DISABLE``` | :heavy_check_mark:\nMethod | You can call a ***method*** supplied by an object. | ```var ratio = engine.getScreenAspectRatio()``` | :heavy_check_mark:\nAsync Methods | You can call a ***Task*** ***method*** and await the result. | ```var ratio = await SceneLoader.LoadSceneAsync(...)``` | :heavy_check_mark:\nStatic Method | You can call a ***Static*** ***method*** provided by a Class. | ```engine.DefaultLoadingScreenFactory(canvas)``` | :heavy_check_mark:\nCallback Method | You can supply a callback action to a ***method*** supplied by an object. | ```observer.add(() =\u003e doSomething())``` | :heavy_check_mark:\nStatic Callback Method | You can call a ***Static*** ***method*** provided by a Class. | ```Engine.AudioEngineFactory()``` | :heavy_check_mark:\nGet Instance Accessor | You can have access to the ***get*** accessor on an object. | ```var check = engine.disableManifestCheck``` | :heavy_check_mark:\nSet Instance Accessor | You can use the ***set*** accessor on an objects. | ```engine.onCanvasPointerOutObservable.add(() =\u003e doSomething())``` | :heavy_check_mark:\nAction Callback | You can run Async based code. | ```meshLoader.OnSuccess(new ActionCallback\u003cMesh\u003e(mesh =\u003e { return Task.CompletedTask; }))``` | :heavy_check_mark:\nAction Callback in Literal | You can run Async based code. | ```new HeightMapMesh({ onReady = new ActionCallback\u003cMesh\u003e(mesh =\u003e { return Task.CompletedTask; }) })``` | :heavy_check_mark:\nAction Result Callback | You can run an action with a result to the caller. | ```meshLoader.OnSuccess(new ActionResultCallback\u003cMesh, bool\u003e(mesh =\u003e { return mesh != null; }))``` | :heavy_check_mark:\n\nNotes on the framework, it might not have the exact API supplied by a TypeScript definition file, in that it might transform the API into something more general and friendly to C#. I used C# as my main source of inspiration for the generated code.\n\n## Example\n\nCheckout /Sample for a BabylonJS working example solution. The solution includes a BabylonJS generated proxy, with a working Blazor Wasm site. You can also checkout the website on this repository for deployed website using the generated BabylonJS. The Sample also includes a Blazor Server project, showing the same example as the Wasm but using Async/Await patterns.\n","funding_links":[],"categories":["others","Libraries \u0026 Extensions"],"sub_categories":["Others"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanhorn%2FEventHorizon.Blazor.TypeScript.Interop.Generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcanhorn%2FEventHorizon.Blazor.TypeScript.Interop.Generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanhorn%2FEventHorizon.Blazor.TypeScript.Interop.Generator/lists"}