Working OpenBirch

This commit is contained in:
BOTAlex 2024-07-14 00:18:54 +02:00
parent 9e219bfab0
commit f2b3c74fa8
11 changed files with 6112 additions and 39 deletions

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.10.35027.167 VisualStudioVersion = 17.10.35027.167
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenBirchWebsite", "OpenBirchWebsite\OpenBirchWebsite.csproj", "{545F3FB5-4102-4288-938C-3F4FFC613567}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenBirchWebsite", "OpenBirchWebsite\OpenBirchWebsite.csproj", "{545F3FB5-4102-4288-938C-3F4FFC613567}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -9,6 +9,7 @@
<MudImage Width="50" Height="50" ObjectFit=ObjectFit.Fill Src="images/fi478h5fj45d1.webp" Alt="Logo" Elevation="25" Class="rounded-lg" /> <MudImage Width="50" Height="50" ObjectFit=ObjectFit.Fill Src="images/fi478h5fj45d1.webp" Alt="Logo" Elevation="25" Class="rounded-lg" />
<MudText Typo="Typo.h5" Class="ml-3">OpenBirch</MudText> <MudText Typo="Typo.h5" Class="ml-3">OpenBirch</MudText>
<MudSpacer /> <MudSpacer />
<MudButton Variant="Variant.Text" Href="/eval" Class="pr-4">Eval demo</MudButton>
<MudButton Variant="Variant.Text" Href="/download" Class="pr-4">Download</MudButton> <MudButton Variant="Variant.Text" Href="/download" Class="pr-4">Download</MudButton>
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())" /> <MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())" />
</MudAppBar> </MudAppBar>

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> <Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
@ -7,6 +7,10 @@
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest> <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="wwwroot\JavaScript🤮\eval.js" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.7" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.7" PrivateAssets="all" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.7" PrivateAssets="all" />

View File

@ -1,4 +1,5 @@
@page "/counter" @page "/counter"
@using System.Runtime.InteropServices
<PageTitle>Counter</PageTitle> <PageTitle>Counter</PageTitle>
@ -6,13 +7,14 @@
<p role="status">Current count: @currentCount</p> <p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> <MudButton Color="Color.Primary" Variant=" Variant.Filled" OnClick="test">Click me</MudButton>
@code { @code {
private int currentCount = 0; private int currentCount = 0;
[DllImport("counter")]
static extern int fact(int n);
private void IncrementCount() public void test() {
{ currentCount = fact(10);
currentCount++;
} }
} }

View File

@ -0,0 +1,18 @@
@page "/eval"
@inject IJSRuntime JSRuntime
<h3>Eval Component</h3>
<input id="inputText" @bind="InputText" placeholder="Enter text" />
<button @onclick="RunEval">Evaluate</button>
<div id="result">@Result</div>
@code {
private string InputText { get; set; }
private string Result { get; set; }
private async Task RunEval()
{
Result = await JSRuntime.InvokeAsync<string>("runEval", InputText);
}
}

View File

@ -1,4 +1,5 @@
@page "/" @page "/"
@inject IJSRuntime jsRuntime
<PageTitle>Home</PageTitle> <PageTitle>Home</PageTitle>
@ -38,6 +39,4 @@
return; return;
} }
} }
} }

View File

@ -1,4 +1,36 @@
{ {
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5126",
"nativeDebugging": true
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7127;http://localhost:5126",
"nativeDebugging": true
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
}
},
"$schema": "http://json.schemastore.org/launchsettings.json", "$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": { "iisSettings": {
"windowsAuthentication": false, "windowsAuthentication": false,
@ -7,35 +39,5 @@
"applicationUrl": "http://localhost:39722", "applicationUrl": "http://localhost:39722",
"sslPort": 44361 "sslPort": 44361
} }
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5126",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7127;http://localhost:5126",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
} }
} }

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,32 @@
function str2C(s) {
var size = lengthBytesUTF8(s) + 1;
var ret = _malloc(size);
stringToUTF8Array(s, HEAP8, ret, size);
return ret;
}
window.runEval = function (inputText) {
console.log("input: " + inputText);
var inputPtr = str2C(inputText);
var resultPointer = Module2._eval(inputPtr);
var resultString = "";
// Convert resultPointer (char*) to JavaScript string
// Here, we treat it as ASCII and convert byte by byte
if (resultPointer) {
var i = 0;
while (true) {
var charCode = Module2.getValue(resultPointer + i, 'i8');
if (charCode === 0) break;
resultString += String.fromCharCode(charCode);
i++;
}
}
console.log("Result from eval:", resultString);
// Free allocated memory
_free(resultPointer);
return resultString;
}

View File

@ -33,6 +33,8 @@
</div> </div>
<script src="_framework/blazor.webassembly.js"></script> <script src="_framework/blazor.webassembly.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script> <script>navigator.serviceWorker.register('service-worker.js');</script>
<script src="JavaScript🤮/eval.js"></script>
<script src="JavaScript🤮/OpenBirch.js"></script>
</body> </body>
</html> </html>