Skip to content

Commit 810c060

Browse files
committed
Initial commit.
0 parents  commit 810c060

35 files changed

+6797
-0
lines changed

.editorconfig

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
10+
[*.{csproj,props,json,xml,xsd}]
11+
indent_size = 2
12+
13+
[*.{cs,razor}]
14+
indent_size = 4
15+
16+
# Formatting errors
17+
dotnet_diagnostic.IDE0055.severity = warning
18+
19+
# Bracing and newline preferences
20+
csharp_new_line_before_open_brace = all
21+
csharp_new_line_before_else = true
22+
csharp_new_line_before_members_in_object_initializers = true
23+
csharp_prefer_braces = false:suggestion
24+
25+
# this. qualification
26+
dotnet_style_qualification_for_field = true:warning
27+
dotnet_style_qualification_for_method = true:warning
28+
dotnet_style_qualification_for_property = true:warning
29+
dotnet_style_qualification_for_event = true:warning
30+
31+
# Switch style
32+
csharp_indent_case_contents = true
33+
csharp_indent_case_contents_when_block = false
34+
csharp_indent_switch_labels = false
35+
36+
# Sort System.* using directives alphabetically, and place them before other usings
37+
dotnet_sort_system_directives_first = true
38+
39+
# Leave code block on single line
40+
csharp_preserve_single_line_blocks = true
41+
# Leave statements and member declarations on the same line
42+
csharp_preserve_single_line_statements = true
43+
44+
# Prefer no curly braces if allowed
45+
csharp_prefer_braces = false:suggestion
46+
47+
# Block preferences
48+
csharp_style_expression_bodied_constructors = false:suggestion
49+
csharp_style_expression_bodied_methods = true:suggestion
50+
csharp_style_expression_bodied_operators = true:suggestion
51+
csharp_style_expression_bodied_properties = true:suggestion
52+
53+
# Prefer out variables to be declared inline in the argument list of a method call when possible
54+
csharp_style_inlined_variable_declaration = true:suggestion
55+
# Prefer tuple names to ItemX properties
56+
dotnet_style_explicit_tuple_names = true:suggestion
57+
# Prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
58+
dotnet_style_predefined_type_for_member_access = true:suggestion
59+
60+
# Prefer default over default(T)
61+
csharp_prefer_simple_default_expression = true:suggestion
62+
# Prefer objects to be initialized using object initializers when possible
63+
dotnet_style_object_initializer = true:suggestion
64+
# Prefer inferred tuple element names
65+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
66+
# 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
67+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
68+
69+
# Var preferences
70+
csharp_style_var_elsewhere = true:suggestion
71+
csharp_style_var_for_built_in_types = true:suggestion
72+
csharp_style_var_when_type_is_apparent = true:suggestion
73+
74+
# Using directive preferences
75+
dotnet_sort_system_directives_first = true
76+
dotnet_separate_import_directive_groups = false
77+
78+
# Prefer file scoped namespaces over braced namespaces
79+
csharp_style_namespace_declarations = file_scoped:warning
80+
81+
# Prefer local functions over anonymous functions
82+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
83+
84+
# 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.
85+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
86+
87+
# When this rule is set to a list of modifiers, prefer the specified ordering.
88+
csharp_preferred_modifier_order = public,private,protected,internal,static,readonly,override,abstract,new:suggestion
89+
90+
# Prefer pattern matching instead of is expression with type casts
91+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* text eol=lf
2+
*.png binary
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: 'Deploy playground to GitHub Pages'
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
paths:
8+
- 'src/**'
9+
10+
env:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
13+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14+
permissions:
15+
contents: write
16+
pages: write
17+
id-token: write
18+
deployments: write
19+
20+
jobs:
21+
deploy:
22+
runs-on: ubuntu-latest
23+
# Deploy to the github-pages environment
24+
environment:
25+
name: github-pages
26+
url: ${{ steps.deployment.outputs.page_url }}
27+
28+
steps:
29+
- name: Clone the repo
30+
uses: actions/checkout@v3
31+
32+
- name: Setup Node.js environment
33+
uses: actions/[email protected]
34+
with:
35+
node-version: 18
36+
37+
- name: Setup .NET
38+
uses: actions/setup-dotnet@v3
39+
with:
40+
dotnet-version: '8.0.x'
41+
42+
- name: Run tests
43+
run: dotnet test ./src
44+
45+
- name: Publish with dotnet
46+
working-directory: 'src/Draco.Editor.Web'
47+
run: dotnet publish --configuration Release --output build
48+
49+
- name: Setup Pages
50+
uses: actions/configure-pages@v2
51+
52+
- name: Upload GitHub Pages artifact
53+
uses: actions/[email protected]
54+
with:
55+
path: 'src/Draco.Editor.Web/build/wwwroot'
56+
57+
- name: Deploy GitHub Pages site
58+
uses: actions/[email protected]

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.vs
2+
bin
3+
obj
4+
*.nupkg
5+
*.user
6+
**/Properties/launchSettings.json
7+
**/testenvironments.json

src/Draco.Editor.Web/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
wwwroot
3+
app/generated

src/Draco.Editor.Web/AssemblyInfo.cs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[assembly: System.Runtime.Versioning.SupportedOSPlatform("browser")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
6+
<PublishTrimmed>false</PublishTrimmed>
7+
<IsPackable>false</IsPackable>
8+
<Nullable>enable</Nullable>
9+
10+
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
11+
12+
<!-- Disable WebCIL for now. We have custom code to tell mono to start running .NET Code, this will need a refactoring to support WebCIL. -->
13+
<WasmEnableWebcil>false</WasmEnableWebcil>
14+
</PropertyGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="ICSharpCode.Decompiler" Version="8.2.0.7535" ExcludeAssets="contentfiles" />
18+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" />
19+
<PackageReference Include="Microsoft.JSInterop" Version="8.0.1" />
20+
<PackageReference Include="Draco.Compiler" Version="0.3.4-pre" />
21+
</ItemGroup>
22+
23+
<Target Name="JSSetup" AfterTargets="AfterBuild">
24+
<Exec Command="npm install" WorkingDirectory="app"></Exec>
25+
<Exec Condition="'$(Configuration)' == 'Debug'" Command="npm run build-debug" WorkingDirectory="app"></Exec>
26+
<Exec Condition="'$(Configuration)' == 'Release'" Command="npm run build-release" WorkingDirectory="app"></Exec>
27+
</Target>
28+
29+
<ItemGroup>
30+
<!-- Force VS to ignore ts files. -->
31+
<Compile Remove="app\**" />
32+
<Content Remove="app\**" />
33+
<EmbeddedResource Remove="app\**" />
34+
<None Remove="app\**" />
35+
</ItemGroup>
36+
37+
<ItemGroup>
38+
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[8.0.1]" />
39+
<EmbeddedResource Include="$(NuGetPackageRoot)microsoft.netcore.app.ref\8.0.1\ref\net8.0\*.dll"
40+
LogicalName="ReferenceAssembly.%(Filename)%(Extension)"
41+
Visible="false"
42+
Link="Reference Assemblies\%(Filename)%(Extension)" />
43+
</ItemGroup>
44+
45+
</Project>

src/Draco.Editor.Web/Interop.cs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Runtime.InteropServices.JavaScript;
3+
4+
namespace Draco.Editor.Web;
5+
6+
public static partial class Interop
7+
{
8+
[JSImport("Interop.sendMessage", "worker.js")]
9+
public static partial void SendMessage(string type, string message);
10+
11+
[JSExport]
12+
public static void OnMessage(string type, string message)
13+
{
14+
var msgs = Messages;
15+
msgs?.Invoke(type, message);
16+
}
17+
18+
public static event Action<string, string>? Messages;
19+
}

src/Draco.Editor.Web/OnInit.cs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Draco.Editor.Web;
2+
3+
public sealed class OnInit
4+
{
5+
public string OutputType { get; set; } = null!;
6+
public string Code { get; set; } = null!;
7+
}

0 commit comments

Comments
 (0)