Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuinox committed Jun 2, 2024
0 parents commit 810c060
Show file tree
Hide file tree
Showing 35 changed files with 6,797 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space

[*.{csproj,props,json,xml,xsd}]
indent_size = 2

[*.{cs,razor}]
indent_size = 4

# Formatting errors
dotnet_diagnostic.IDE0055.severity = warning

# Bracing and newline preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_members_in_object_initializers = true
csharp_prefer_braces = false:suggestion

# this. qualification
dotnet_style_qualification_for_field = true:warning
dotnet_style_qualification_for_method = true:warning
dotnet_style_qualification_for_property = true:warning
dotnet_style_qualification_for_event = true:warning

# Switch style
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false
csharp_indent_switch_labels = false

# Sort System.* using directives alphabetically, and place them before other usings
dotnet_sort_system_directives_first = true

# Leave code block on single line
csharp_preserve_single_line_blocks = true
# Leave statements and member declarations on the same line
csharp_preserve_single_line_statements = true

# Prefer no curly braces if allowed
csharp_prefer_braces = false:suggestion

# Block preferences
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion

# Prefer out variables to be declared inline in the argument list of a method call when possible
csharp_style_inlined_variable_declaration = true:suggestion
# Prefer tuple names to ItemX properties
dotnet_style_explicit_tuple_names = true:suggestion
# Prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_member_access = true:suggestion

# Prefer default over default(T)
csharp_prefer_simple_default_expression = true:suggestion
# Prefer objects to be initialized using object initializers when possible
dotnet_style_object_initializer = true:suggestion
# Prefer inferred tuple element names
dotnet_style_prefer_inferred_tuple_names = true:suggestion
# Prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

# Var preferences
csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion

# Using directive preferences
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false

# Prefer file scoped namespaces over braced namespaces
csharp_style_namespace_declarations = file_scoped:warning

# Prefer local functions over anonymous functions
csharp_style_pattern_local_over_anonymous_function = true:suggestion

# Prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning

# When this rule is set to a list of modifiers, prefer the specified ordering.
csharp_preferred_modifier_order = public,private,protected,internal,static,readonly,override,abstract,new:suggestion

# Prefer pattern matching instead of is expression with type casts
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text eol=lf
*.png binary
58 changes: 58 additions & 0 deletions .github/workflows/deploy-playground.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: 'Deploy playground to GitHub Pages'

on:
workflow_dispatch:
push:
branches: [main]
paths:
- 'src/**'

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
deployments: write

jobs:
deploy:
runs-on: ubuntu-latest
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Clone the repo
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: 18

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- name: Run tests
run: dotnet test ./src

- name: Publish with dotnet
working-directory: 'src/Draco.Editor.Web'
run: dotnet publish --configuration Release --output build

- name: Setup Pages
uses: actions/configure-pages@v2

- name: Upload GitHub Pages artifact
uses: actions/[email protected]
with:
path: 'src/Draco.Editor.Web/build/wwwroot'

- name: Deploy GitHub Pages site
uses: actions/[email protected]
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vs
bin
obj
*.nupkg
*.user
**/Properties/launchSettings.json
**/testenvironments.json
3 changes: 3 additions & 0 deletions src/Draco.Editor.Web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
wwwroot
app/generated
1 change: 1 addition & 0 deletions src/Draco.Editor.Web/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: System.Runtime.Versioning.SupportedOSPlatform("browser")]
45 changes: 45 additions & 0 deletions src/Draco.Editor.Web/Draco.Editor.Web.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>

<PublishTrimmed>false</PublishTrimmed>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>

<AllowUnsafeBlocks>True</AllowUnsafeBlocks>

<!-- Disable WebCIL for now. We have custom code to tell mono to start running .NET Code, this will need a refactoring to support WebCIL. -->
<WasmEnableWebcil>false</WasmEnableWebcil>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ICSharpCode.Decompiler" Version="8.2.0.7535" ExcludeAssets="contentfiles" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" />
<PackageReference Include="Microsoft.JSInterop" Version="8.0.1" />
<PackageReference Include="Draco.Compiler" Version="0.3.4-pre" />
</ItemGroup>

<Target Name="JSSetup" AfterTargets="AfterBuild">
<Exec Command="npm install" WorkingDirectory="app"></Exec>
<Exec Condition="'$(Configuration)' == 'Debug'" Command="npm run build-debug" WorkingDirectory="app"></Exec>
<Exec Condition="'$(Configuration)' == 'Release'" Command="npm run build-release" WorkingDirectory="app"></Exec>
</Target>

<ItemGroup>
<!-- Force VS to ignore ts files. -->
<Compile Remove="app\**" />
<Content Remove="app\**" />
<EmbeddedResource Remove="app\**" />
<None Remove="app\**" />
</ItemGroup>

<ItemGroup>
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[8.0.1]" />
<EmbeddedResource Include="$(NuGetPackageRoot)microsoft.netcore.app.ref\8.0.1\ref\net8.0\*.dll"
LogicalName="ReferenceAssembly.%(Filename)%(Extension)"
Visible="false"
Link="Reference Assemblies\%(Filename)%(Extension)" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions src/Draco.Editor.Web/Interop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Runtime.InteropServices.JavaScript;

namespace Draco.Editor.Web;

public static partial class Interop
{
[JSImport("Interop.sendMessage", "worker.js")]
public static partial void SendMessage(string type, string message);

[JSExport]
public static void OnMessage(string type, string message)
{
var msgs = Messages;
msgs?.Invoke(type, message);
}

public static event Action<string, string>? Messages;
}
7 changes: 7 additions & 0 deletions src/Draco.Editor.Web/OnInit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Draco.Editor.Web;

public sealed class OnInit
{
public string OutputType { get; set; } = null!;
public string Code { get; set; } = null!;
}
Loading

0 comments on commit 810c060

Please sign in to comment.