curiosity-ai / h5 Goto Github PK
View Code? Open in Web Editor NEW๐ The next generation C# to JavaScript compiler
Home Page: https://h5.rocks
License: Apache License 2.0
๐ The next generation C# to JavaScript compiler
Home Page: https://h5.rocks
License: Apache License 2.0
Steps To Reproduce
https://dev.deck.net/9d292f241ded3180d8118d9bdb1e4edd
public class Program
{
public static void Main()
{
DateTime date = DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc);
Console.WriteLine(date.ToString("u"));
}
}
to compare:
https://dev.deck.net/4916fff18f204ff5d2e171dfbd1cbde9
Expected Result
2019-08-05 00:00:00Z
Actual Result
// Depending on time zone
UTC+1 - 2019-08-04 23:00:00Z
UTC+2 - 2019-08-04 22:00:00Z
etc
i think to fix this issues by change this line :
https://github.com/theolivenbaum/h5/blob/d9c8a733e6b55584c3bd37b1f461ae9378882550/H5/H5/shared/System/DateTime.cs#L734
with this :
return new DateTime(value.Ticks, kind);
add ticks not work correctly in this simple :
https://deck.net/d8843f388823586dca2a2b94bbbd6af1
Expected Result
2019-12-01T00:00:00.0000000
2019-11-30T23:59:59.9990000
2019-11-30T23:59:59.9990000
Actual Result
2019-12-01T00:00:00.0000000
2019-12-01T00:00:00.0000000
2019-11-30T23:59:59.9990000
i think to fix this problem its to replace:
https://github.com/theolivenbaum/h5/blob/d9c8a733e6b55584c3bd37b1f461ae9378882550/H5/H5/shared/System/DateTime.cs#L454
with is :
return new DateTime((ulong)(ticks + value));
or with this:
return new DateTime((long)(ticks + value));
https://developer.mozilla.org/en-US/docs/Web/API/Console/time
Would be nice to have the three time related functions available :)
In my project I'd like to use Box2D. Is it possible to port that over from Retyped.box2d?
Is that something I can look into? Are you decompiling the Retyped packages for that?
Building on Ubuntu 20.04. Only installed sdk is 3.1
Microsoft (R) Build Engine version 16.7.0+7fb82e5b2 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
[info] [16:13:09] Found compilation server
Running _ComputePackageReferencePublish for Test
Running _HandlePackageFileConflicts
Running _ComputeReferenceAssemblies
Running _ComputeUserRuntimeAssemblies
Running GenerateBuildDependencyFile
No output assembly found, will build.
Running _GenerateRuntimeConfigurationFilesInputCache
Running GenerateBuildRuntimeConfigurationFiles
Writing project runtime config file /home/andre/RiderProjects/Tetys/csharp/Test/bin/Debug/netstandard2.0/Test.runtimeconfig.json
Test ->
Skipping updating the h5 compiler. You can always install/update it by calling dotnet tool update --global h5-compiler
Deleting previous assembly: /home/andre/RiderProjects/Tetys/csharp/Test/bin/Debug/netstandard2.0/Test.dll
H5 compilation begins now...
5555555555555555555555555555555555555555
5555555555555555555hhhhhhhhhhhhhhhh5555
555 55555555555hh h5555
555 55555555555hh h555
555 55555555555hh hhhhhhhhh555
55 55555555555hh hhhhhhhhh555
555 5555555555hh hhhhhhhh5555
555 5hh h5555
555 5hh h555
555 5555 5hhhhhhhh h555
555 5555 5hhhhhhhh h555
555 555 5hhhhhhhh h5555
555 555 5hh h555
5555555 555 5hh hhhh555
5555555555555555hhhhhhhhhhhhhh555
5555555555555555hhhhhhh5555555555
55555555555555555555
5555555555555555
[info] [16:13:10] Executing h5 compiler with arguments: '--project /home/andre/RiderProjects/Tetys/csharp/Test/Test.csproj --configuration Debug --assembly-version 1.0.0.0'
[info] [16:13:10] Found compilation server, sending compilation request
[info] [16:13:10] Setting working directory to '/home/andre/RiderProjects/Tetys/csharp/Test'
[info] [16:13:10] [B] H5 Compilation
[info] [16:13:10] H5 config file is not found. Returning default config
[info] [16:13:10] [E] H5 Compilation in 0.0010 seconds
[info] [16:13:10]
__ _ _ _ _
|_ |_)|_)/ \|_)
|__| \| \\_/| \
[fail] [16:13:10]
H5 : error H5003: The SDK 'h5.Target/0.0.11500' specified could not be found. /home/andre/RiderProjects/Tetys/csharp/Test/Test.csproj [/home/andre/RiderProjects/Tetys/csharp/Test/Test.csproj]
[fail] [16:13:10]
Stack Trace: at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
at H5.Translator.Translator.EnsureProjectProperties()
at H5.Translator.TranslatorProcessor.SetTranslatorProperties()
at H5.Translator.TranslatorProcessor.PreProcess(IH5DotJson_AssemblySettings translatorConfiguration)
at H5.Compiler.CompilationProcessor.Compile(CompilationRequest compilationRequest, UID128 compilationUID, CancellationToken cancellationToken)
/home/andre/.nuget/packages/h5.target/0.0.11500/Sdk/Sdk.targets(462,9): error MSB3073: The command "h5 --project "/home/andre/RiderProjects/Tetys/csharp/Test/Test.csproj" --configuration "Debug" --assembly-version "1.0.0.0"" exited with code 1. [/home/andre/RiderProjects/Tetys/csharp/Test/Test.csproj]
Build FAILED.
H5 : error H5003: The SDK 'h5.Target/0.0.11500' specified could not be found. /home/andre/RiderProjects/Tetys/csharp/Test/Test.csproj [/home/andre/RiderProjects/Tetys/csharp/Test/Test.csproj]
/home/andre/.nuget/packages/h5.target/0.0.11500/Sdk/Sdk.targets(462,9): error MSB3073: The command "h5 --project "/home/andre/RiderProjects/Tetys/csharp/Test/Test.csproj" --configuration "Debug" --assembly-version "1.0.0.0"" exited with code 1. [/home/andre/RiderProjects/Tetys/csharp/Test/Test.csproj]
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:02.58
Hello, as retyped isnt available, any plans on supporting WebGL2RenderingContext?
Hello
I am currently using BridgeDotNet but they stopped developing two years ago on the project .
so I am thinking of moving to h5.
May I know how much you have improved from BridgeDotNet ?
how much you have been able to support .net 5 ?
Is the project safe now for me to move to ?
is this an experimental project or a serious project ?
Hello :
i'm try to run this simple :
https://deck.net/af17727256ef60c2c76206837a6c6eac
and i cant add this line :
[NotifyPropertyChanged(Inheritance = MulticastInheritance.All)]
its give me red line under the code because the NotifyPropertyChanged is missing ...... if i remove the line it will compile successfully But the code will not do what it should do.
Which would in turn get rid of the need for Preconvert()
and boost performance somewhat.
(src.v || "")
should have been (src1.v || "")
on the generated code below:
switch (value) {
case 0:
{
src = { };
this._paginationManager.GroupResultsBy(function (sh) {
return Mosaik.Schema.Node.prototype.TryGetSource.call(sh.Node, src) ? src.v : "";
});
}
break;
case 1:
{
src1 = { };
this._paginationManager.GroupResultsBy(function (sh) {
return Mosaik.Schema.Node.prototype.TryGetSource.call(sh.Node, src1) ? (Mosaik.NodeRenderer.GetDisplayName(sh.Node) || "") + " / " + (src.v || "") : Mosaik.NodeRenderer.GetDisplayName(sh.Node);
});
}
break;
}
This will enable us to avoid the costs of starting a new instance of the compiler for every step (avoiding the cost of jitting for example), and of loading assemblies in memory for Cecil, used here:
Does anything specific speak against supporting net50 as target framework?
I am currently using special empty H5 csproj files which point on the same libraries i use in desktop environment.
However defining the projects as net5.0 would not require out libraries to avoid using modern language features like switch expressions etc.
See: dotnet/msbuild#274
Example:
Inputs="$(MSBuildAllProjects);
@(Compile);
@(_CoreCompileResourceInputs);
$(ApplicationIcon);
$(AssemblyOriginatorKeyFile);
@(ReferencePath);
@(CompiledLicenseFile);
@(LinkResource);
@(EmbeddedDocumentation);
$(Win32Resource);
$(Win32Manifest);
@(CustomAdditionalCompileInputs);
$(ResolvedCodeAnalysisRuleSet)"
Outputs="@(DocFileItem);
@(IntermediateAssembly);
@(_DebugSymbolsIntermediatePath);
$(NonExistentFile);
@(CustomAdditionalCompileOutputs)"
Hello:
i'm got 4 errors when i'm run the code
first error is ' Task is not yet completed '
and the others errors is ' Task is already completed '
code here :
namespace System.Net.Http
{
public class HttpClient
{
private static uint timeout = 100000;
public static uint Timeout { get { return timeout; }
set {
if (value >= uint.MaxValue)
{
timeout = uint.MaxValue ;
}
else
{
timeout = value;
}
}
}
public static async Task<XMLHttpRequest> GetAsync(string requestUri)
{
var tcs = new TaskCompletionSource<XMLHttpRequest>();
XMLHttpRequest xmlHttp = new XMLHttpRequest();
xmlHttp.timeout = Timeout;
xmlHttp.open("GET", requestUri);
xmlHttp.onreadystatechange = async (e) =>
{
if(xmlHttp.status == 200)
{
tcs.SetResult(xmlHttp);
}
else
{
tcs.SetException(new Exception("Response status code does not indicate success: " + xmlHttp.statusText));
}
};
xmlHttp.send();
return await tcs.Task;
}
}
}
My h5.json:
{
"output": "../Shoptico.Core.Backend/wwwroot/$(AssemblyName)/",
"sourceMap":
{
"enabled": false
},
"reflection":
{
"disabled": false
},
"locales": "en-US;en-GB;bg-BG", //if I keep this - I get the crash, if I remove it - it's okay
"generateTypeScript": false,
"cleanOutputFolderBeforeBuild": true,
"logging":
{
"level": "None"
},
"loader":
{
"type": "ES6",
"manualLoading": true,
"skipManualVariables": true
},
"htmlx":
{
"keepJSDependencies": true
}
}
When using h5 projects in GitLab CI builds, the build will wait forever for the H5 compiler to close. There should be a way to ensure the compilation server shuts down either after a successful compilation, or after a specific idle time.
As suggested in Gitter, add new rule to treat Decimal as float, i.e. DecimalRule.Plain
I know, a bit early, but what are the plans on .NET 5.0?
sample code:
class Program
{
static void Main(string[] args)
{
(double data1, string data2) t1 = default;
console.info(t1.data1);
}
}
Original issues reported by @c0pperdragon and @ChrML, I've hit already this on a few occasions...
Since .net60 moved into the go-live release phase, I've updated h5 compiler to run on net6.0 to make sure it's ready. I've not hit any issues on my side, but I'm opening this issue to track any problems.
If you're updating the h5 compiler on your computer, you might need to install the net6.0 SDK first:
https://dotnet.microsoft.com/download/dotnet/6.0
Otherwise you can keep using the last net5.0 version - there were no new features on the net6.0 version.
Basically for our renderer, we need support for this api:
https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics
Sadly, using measureText, H5 only knows about the "width" property.
I hope cdn files for h5 will be provided this is well improve network download size alot.
Even when not using any .net6 in the project, the compilation fails as soon as .net6 preview2 is installed.
I am working on an opengl/webgl based ui rendering library. The project is setup as follows:
Using Bridge.net it was possible to reference one of the implementation projects, and compile the whole application into either an desktop or webgl powered application. Using H5 however, compiling the Html5 projects results in:
[info] [10:36:24]
__ _ _ _ _
|_ |_)|_)/ \|_)
|__| \| \\_/| \
[fail] [10:36:24]
1>H5 : error H5003: Could not find file '/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Core/bin/Debug/netstandard2.0/netstandard.dll'.
[fail] [10:36:24]
Stack Trace: at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at H5.Translator.Translator.AddNestedReferences(List`1 referencesPathes, String refPath)
at H5.Translator.Translator.AddNestedReferences(List`1 referencesPathes, String refPath)
at H5.Translator.Translator.BuildAssembly(CancellationToken cancellationToken)
at H5.Translator.Translator.Translate(CancellationToken cancellationToken)
at H5.Translator.TranslatorProcessor.Process()
at H5.Compiler.CompilationProcessor.Compile(CompilationRequest compilationRequest, UID128 compilationUID, CancellationToken cancellationToken)
1>/home/andre/.nuget/packages/h5.target/0.0.11500/Sdk/Sdk.targets(462,9): error MSB3073: The command "h5 --project "/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Html5/Tetys.Libs.UniGui.Html5.csproj" --configuration "Debug" --assembly-version "1.0.0.0"" exited with code 1.
1>Done Building Project "/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Html5/Tetys.Libs.UniGui.Html5.csproj" (build target(s)) -- FAILED.
Build FAILED.
"/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Html5/Tetys.Libs.UniGui.Html5.csproj" (build target) (1) ->
(_H5Build target) ->
H5 : error H5003: Could not find file '/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Core/bin/Debug/netstandard2.0/netstandard.dll'.
/home/andre/.nuget/packages/h5.target/0.0.11500/Sdk/Sdk.targets(462,9): error MSB3073: The command "h5 --project "/home/andre/RiderProjects/Tetys/csharp/Tetys.Libs.UniGui.Html5/Tetys.Libs.UniGui.Html5.csproj" --configuration "Debug" --assembly-version "1.0.0.0"" exited with code 1.
0 Warning(s)
2 Error(s)
Hello
i saw this issues in bridge.net and try to run it on h5 In fact, the problem also exists in h5.
here is the sample :
Expected: Animal Farm
Actual: Animal
using System;
using H5;
using H5.Core;
using static H5.Core.es5;
using static H5.Core.dom;
using Console = System.Console;
namespace h5
{
public struct Book
{
public string Title;
}
public class Delivery
{
public Book[] Books;
}
class Program
{
static void Main(string[] args)
{
{
var delivery = new Delivery();
delivery.Books = new Book[1];
delivery.Books[0] = new Book();
delivery.Books[0].Title = "Animal";
delivery.Books[0].Title += " Farm";
// Expected: Animal Farm
// Actual: Animal
Console.Log(delivery.Books[0].Title);
}
}
}
}
https://docs.microsoft.com/en-us/dotnet/core/tools/local-tools-how-to-use
When installing h5-compiler with this approach, compiling fails with
_CheckForH5:
h5 check-if-online
'h5' is not recognized as an internal or external command,
operable program or batch file.
Running "h5" from cmd obviously does not work. "dotnet h5" however works when installing localy. Would it be an option to change the manual system calls which the build process does to "dotnet h5" instead of "h5"? This way we could avoid the need to install h5 globally and allow people to build without doing anything before.
For some reason I can't use a typed array for the texImage2D
and texSubImage2D
functions.
Uint8Array platformData = new Uint8Array(data);
_gl.texImage2D(_gl.TEXTURE_2D, 0, _gl.RGBA, width, height, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, platformData);
Casting it to an ArrayBufferView works with H5:
Uint8Array platformData = new Uint8Array(data);
ArrayBufferView view = (object)platformData as ArrayBufferView;
_gl.texImage2D(_gl.TEXTURE_2D, 0, _gl.RGBA, width, height, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, view);
It used to work in Bridge.NET, is this a bug?
I've dabbled with Bridge.net in the past, and remember it being a good platform. Could you explain a bit more in the readme about the motivation for h5, in particular what shortcomings bridge.net has that this addresses. From reading the readme I see that the loss of Retyped is a downside to h5, but I don't know all the upsides.
There seems to be a very outdated C# wrapper around libsass here: https://github.com/TBAPI-0KA/NSass. Could investigate a new modern wrapper on libsass.
Originally reported here: Incorrect async state-machine behaviour causing both IF- and ELSE conditions to execute
Seems to be due this line:
https://github.com/theolivenbaum/h5/blob/284112b3f50a9d75a9a359e6dfbeb0eda8d00954/H5/Compiler/Translator/Emitter/Blocks/AbstractEmitterBlock.Write.cs#L976
public static bool IsReturnLast(string str)
{
str = str.TrimEnd();
return str.EndsWith("return;") || Regex.IsMatch(str, "(?m:^)return(.*)?;$");
}
Just noticed while checking the original issues that we're missing support for custom cultures.
Couple of related issues to check as well:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.