Skip to content

Commit 107e2f3

Browse files
committed
OKAY I DID IT THIS IS FUCKING DOPE I THINK 4.0.4
1 parent a7c68d3 commit 107e2f3

File tree

84 files changed

+1351
-1875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1351
-1875
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"xml.problems.noGrammar": "ignore",
23
"files.associations": {
34
"*.jaml": "yaml"
45
},

.windsurf/workflows/build-wasm.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
# Build WASM Browser Projects
1+
# Build WASM (browser)
22

3-
Build the current Motely browser WASM projects and stage their publish outputs for npm packaging.
3+
Build **`Motely`** for `net10.0-browser` (Bootsharp) and stage into **`motely-wasm/dist/`**.
44

5-
## Quick Build
5+
## Quick build
66

77
```bash
8-
dotnet publish Motely.BrowserWasm/Motely.BrowserWasm.csproj -c Release
9-
dotnet publish Motely.SingleThread/Motely.SingleThread.csproj -c Release
10-
node stage-packages.mjs all
8+
dotnet publish Motely/Motely.csproj -c Release -f net10.0-browser
9+
npm --prefix motely-wasm install
10+
npm --prefix motely-wasm run build
1111
```
1212

13-
## What This Produces
13+
(`motely-wasm`'s `build` script runs `Motely/build/stage-wasm.mjs`, which copies `publish/bootsharp``motely-wasm/dist/bootsharp` and writes `dist/index.mjs`.)
1414

15-
- `Motely.BrowserWasm/bin/Release/net10.0-browser/publish/wwwroot/_framework/`
16-
- `Motely.SingleThread/bin/Release/net10.0-browser/publish/wwwroot/_framework/`
17-
- staged package assets in:
18-
- `Motely.npm/_framework/`
19-
- `Motely.npm/_framework_st/`
15+
## What this produces
2016

21-
## Staging to NPM Packages
17+
- `Motely/bin/Release/net10.0-browser/publish/bootsharp/` (publish output)
18+
- `motely-wasm/dist/bootsharp/` + `motely-wasm/dist/index.mjs` (staged npm payload)
2219

23-
The root `stage-packages.mjs` script copies filtered publish assets into the npm package folders.
20+
Legacy paths (`Motely.BrowserWasm`, `Motely.SingleThread`, `Motely.npm`, root `stage-packages.mjs`) are **removed** from the tree.
2421

2522
## Requirements
2623

2724
- .NET 10 SDK
2825
- wasm-tools workload: `dotnet workload install wasm-tools`
29-
- wasm-experimental workload: `dotnet workload install wasm-experimental`
26+
- wasm-experimental workload: `dotnet workload install wasm-experimental` (if your SDK still expects it)
3027

3128
## Troubleshooting
3229

3330
### wasm-opt crashes
34-
Already disabled in csproj: `<WasmRunWasmOpt>false</WasmRunWasmOpt>`
31+
32+
If applicable, disable in the browser target: `<WasmRunWasmOpt>false</WasmRunWasmOpt>`
3533

3634
### Missing SharedArrayBuffer
37-
For Browser: Needs COOP/COEP headers when using `Motely.BrowserWasm`
38-
For browser fallback: use the staged `Motely.SingleThread` runtime via `motely-wasm/_framework_st`
35+
36+
Threads + WASM may require COOP/COEP headers on the host page.

.windsurf/workflows/prepare-update.md

Lines changed: 32 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ auto_execution_mode: 3
55

66
# Prepare Update
77

8-
Bumps the MotelyVersion, cleans everything, builds all .NET projects, AOT-publishes both WASM targets, prepares the active npm packages, and walks the user through publishing.
8+
Bumps the MotelyVersion, cleans everything, builds the solution, publishes **Motely** for `net10.0-browser` (Bootsharp), stages **`motely-wasm`**, and walks the user through npm publish. The old **`Motely.NodeAddon`** / `Motely.npm` flow is gone.
99

1010
**User provides**: the new version number — OR if not specified, read the current `<MotelyVersion>` from `Directory.Packages.props` and auto-increment the patch (e.g. `2.2.1``2.2.2`).
1111

@@ -26,8 +26,8 @@ node x:\JammySeedFinder\src\MotelyJAML\sync-version.mjs
2626
```
2727

2828
This reads `<MotelyVersion>` from Directory.Packages.props and updates:
29-
- `Motely.npm\package.json`
30-
- `Motely.node\package.json`
29+
- `motely-wasm/package.json`
30+
- `motely-node/package.json`
3131

3232
---
3333

@@ -75,145 +75,107 @@ If browser or cross-platform builds fail because of incompatible APIs, do not fo
7575

7676
---
7777

78-
## Step 6: Clean _framework dir before AOT publish
78+
## Step 6: Regenerate JAML schema
79+
80+
Writes schema + helper files to paths used by `motely-wasm` / `motely-node` (see `JamlSchemaGenerator`).
7981

8082
// turbo
8183

8284
```powershell
83-
Remove-Item -Recurse -Force x:\JammySeedFinder\src\MotelyJAML\Motely.npm\_framework -ErrorAction SilentlyContinue
84-
Remove-Item -Recurse -Force x:\JammySeedFinder\src\MotelyJAML\Motely.npm\_framework_st -ErrorAction SilentlyContinue
85+
dotnet run --project x:\JammySeedFinder\src\MotelyJAML\Motely.CLI\Motely.CLI.csproj -c Release -- --write-jaml-schema
8586
```
8687

8788
---
8889

89-
## Step 7: AOT Release Publish — Browser WASM (frontend)
90-
91-
This publishes `Motely.BrowserWasm` using the validated browser-wasm AOT path. After publish, run the central staging script to copy the filtered `_framework` output into `Motely.npm/_framework/`.
92-
93-
Keep `x:\JammySeedFinder\src\MotelyJAML\Directory.Build.props` in place so browser-wasm projects explicitly reset `PublishAot=false` and `PublishReadyToRun=false` at the local repo level. The actual browser AOT settings live in the project files via `RunAOTCompilation=true` and `WasmBuildNative=true`.
94-
95-
```powershell
96-
dotnet publish x:\JammySeedFinder\src\MotelyJAML\Motely.BrowserWasm\Motely.BrowserWasm.csproj -c Release
97-
node x:\JammySeedFinder\src\MotelyJAML\stage-packages.mjs browser
98-
```
90+
## Step 7: Publish browser WASM (Bootsharp)
9991

100-
If this fails, capture the full SDK error and stop before changing other steps.
92+
`Motely` multi-targets `net10.0-browser`. Publish, then run `motely-wasm`'s build script (`Motely/build/stage-wasm.mjs` copies `bootsharp/` into `motely-wasm/dist/`).
10193

102-
Verify the output exists:
10394
// turbo
10495

10596
```powershell
106-
@(Get-ChildItem x:\JammySeedFinder\src\MotelyJAML\Motely.npm\_framework\dotnet.native*.wasm -ErrorAction SilentlyContinue).Count -gt 0
97+
dotnet publish x:\JammySeedFinder\src\MotelyJAML\Motely\Motely.csproj -c Release -f net10.0-browser
98+
npm --prefix x:\JammySeedFinder\src\MotelyJAML\motely-wasm install
99+
npm --prefix x:\JammySeedFinder\src\MotelyJAML\motely-wasm run build
107100
```
108101

109-
---
110-
111-
## Step 8: AOT Release Publish — Browser WASM single-thread fallback
112-
113-
This publishes `Motely.SingleThread` and stages the fallback browser runtime into `Motely.npm/_framework_st/`.
114-
115-
```powershell
116-
dotnet publish x:\JammySeedFinder\src\MotelyJAML\Motely.SingleThread\Motely.SingleThread.csproj -c Release
117-
node x:\JammySeedFinder\src\MotelyJAML\stage-packages.mjs singlethread
118-
```
102+
Verify staged output:
119103

120-
Verify the fallback output exists:
121104
// turbo
122105

123106
```powershell
124-
@(Get-ChildItem x:\JammySeedFinder\src\MotelyJAML\Motely.npm\_framework_st\dotnet.native*.wasm -ErrorAction SilentlyContinue).Count -gt 0
107+
Test-Path x:\JammySeedFinder\src\MotelyJAML\motely-wasm\dist\bootsharp\index.mjs
125108
```
126109

127110
---
128111

129-
## Step 9: AOT Release Publish — Node Addon (win-x64 + linux-x64)
112+
## Step 8: Node native addon
130113

131-
Publish the native AOT addon for both platforms:
114+
**`Motely.NodeAddon` was removed.** There is no second C# package to publish for Node in this workflow. Browser delivery is **Bootsharp / `net10.0-browser` only**.
132115

133-
```powershell
134-
dotnet publish x:\JammySeedFinder\src\MotelyJAML\Motely.NodeAddon\Motely.NodeAddon.csproj -c Release -r win-x64
135-
wsl dotnet publish /mnt/x/JammySeedFinder/src/MotelyJAML/Motely.NodeAddon/Motely.NodeAddon.csproj -c Release -r linux-x64
136-
```
137-
138-
Copy .node files to Motely.node/bin/ for packaging:
139-
140-
```powershell
141-
New-Item -ItemType Directory -Force -Path x:\JammySeedFinder\src\MotelyJAML\Motely.node\bin\Release\net10.0\win-x64\publish
142-
New-Item -ItemType Directory -Force -Path x:\JammySeedFinder\src\MotelyJAML\Motely.node\bin\Release\net10.0\linux-x64\publish
143-
Copy-Item x:\JammySeedFinder\src\MotelyJAML\Motely.NodeAddon\bin\Release\net10.0\win-x64\publish\Motely.NodeAddon.node x:\JammySeedFinder\src\MotelyJAML\Motely.node\bin\Release\net10.0\win-x64\publish\
144-
Copy-Item x:\JammySeedFinder\src\MotelyJAML\Motely.NodeAddon\bin\Release\net10.0\linux-x64\publish\Motely.NodeAddon.node x:\JammySeedFinder\src\MotelyJAML\Motely.node\bin\Release\net10.0\linux-x64\publish\
145-
```
146-
147-
Verify .node files exist:
148-
// turbo
149-
150-
```powershell
151-
Test-Path x:\JammySeedFinder\src\MotelyJAML\Motely.node\bin\Release\net10.0\win-x64\publish\Motely.NodeAddon.node
152-
Test-Path x:\JammySeedFinder\src\MotelyJAML\Motely.node\bin\Release\net10.0\linux-x64\publish\Motely.NodeAddon.node
153-
```
116+
If you add a new Node `.node` target later, document its `dotnet publish` command and how artifacts land under `motely-node/`. Until then, **skip** `npm pack` for `motely-node` unless you intentionally ship JS-only stubs.
154117

155118
---
156119

157-
## Step 10: Prepare npm package — motely-wasm (browser)
120+
## Step 9: Pack `motely-wasm`
158121

159122
// turbo
160123

161124
```powershell
162-
npm --prefix x:\JammySeedFinder\src\MotelyJAML\Motely.npm install
163-
npm --prefix x:\JammySeedFinder\src\MotelyJAML\Motely.npm run build
125+
npm --prefix x:\JammySeedFinder\src\MotelyJAML\motely-wasm pack
164126
```
165127

166128
---
167129

168-
## Step 11: Pack motely-node
130+
## Step 10: (Optional) Pack `motely-node`
169131

170-
The .node files are already published in Step 9. Just pack:
132+
Only when a tested linux-x64 `.node` (or agreed layout) is present.
171133

172134
// turbo
173135

174136
```powershell
175-
npm --prefix x:\JammySeedFinder\src\MotelyJAML\Motely.node pack
137+
npm --prefix x:\JammySeedFinder\src\MotelyJAML\motely-node pack
176138
```
177139

178140
---
179141

180-
## Step 12: Tell user to publish
142+
## Step 11: Tell user to publish
181143

182144
Tell the user:
183145

184146
```md
185-
cd x:\JammySeedFinder\src\MotelyJAML\Motely.npm
147+
cd x:\JammySeedFinder\src\MotelyJAML\motely-wasm
186148
npm login
187149
npm publish
188150

189-
cd x:\JammySeedFinder\src\MotelyJAML\Motely.node
151+
# Optional — only if Step 10 was used and motely-node is meant for npm:
152+
cd x:\JammySeedFinder\src\MotelyJAML\motely-node
190153
npm login
191154
npm publish
192155
```
193156

194-
Mention that `motely-wasm` includes `_framework/` and `_framework_st/`, while `motely-node` includes native AOT `.node` files in `bin/`.
157+
`motely-wasm` ships `dist/` (Bootsharp runtime + `index.mjs`). Do not reference removed `Motely.npm` / `Motely.NodeAddon` paths.
195158

196159
Wait for user to confirm they published.
197160

198161
---
199162

200-
## Step 13: Cleanup _framework files
163+
## Step 12: (Optional) Cleanup large staged artifacts
201164

202-
After user confirms publish, clean up the large _framework dirs to keep the repo lean:
165+
If you want a lean working tree after publish, remove generated WASM staging (adjust if you rely on a committed `dist/`):
203166

204167
```powershell
205-
Remove-Item -Recurse -Force x:\JammySeedFinder\src\MotelyJAML\Motely.npm\_framework -ErrorAction SilentlyContinue
206-
Remove-Item -Recurse -Force x:\JammySeedFinder\src\MotelyJAML\Motely.npm\_framework_st -ErrorAction SilentlyContinue
168+
Remove-Item -Recurse -Force x:\JammySeedFinder\src\MotelyJAML\motely-wasm\dist -ErrorAction SilentlyContinue
207169
```
208170

209171
---
210172

211-
## Step 14: Summary
173+
## Step 13: Summary
212174

213175
Print:
214176

215177
```sh
216178
✅ MotelyJAML update complete!
217179
Version: <THE_VERSION>
218-
Published: motely-wasm@<THE_VERSION>, motely-node@<THE_VERSION>
180+
Published: motely-wasm@<THE_VERSION> (and motely-node@<THE_VERSION> only if applicable)
219181
```

AGENTS.md

Whitespace-only changes.

Directory.Packages.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project>
22
<PropertyGroup>
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4-
<MotelyVersion>4.0.2</MotelyVersion>
4+
<MotelyVersion>4.0.4</MotelyVersion>
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageVersion Include="Bootsharp" Version="0.7.0" />
88
<PackageVersion Include="Bootsharp.Inject" Version="0.7.0" />
99
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
10-
<PackageVersion Include="Microsoft.DotNet.ILCompiler.LLVM" Version="7.0.0-preview.4.23073.1" />
11-
<PackageVersion Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="7.0.0-preview.4.23073.1" />
12-
<PackageVersion Include="runtime.linux-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="7.0.0-preview.4.23073.1" />
10+
<PackageVersion Include="Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-rc.1.26117.1" />
11+
<PackageVersion Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-rc.1.26117.1" />
12+
<PackageVersion Include="runtime.linux-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-rc.1.26117.1" />
1313
<PackageVersion Include="Microsoft.JavaScript.NodeApi" Version="0.9.19" />
1414
<PackageVersion Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.19" />
1515
<PackageVersion Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />

Motely.BrowserWasm/IMotelyJsUi.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Motely.Analysis;
2+
3+
namespace Motely.BrowserWasm;
4+
5+
public interface IMotelyJsUi
6+
{
7+
void NotifySearchProgress(int completed, int total);
8+
void NotifySearchHit(ShopItemDto hit);
9+
void NotifySearchComplete(string summary);
10+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Motely.BrowserWasm;
2+
3+
public interface IMotelyWasmBackend
4+
{
5+
// Single-seed: shop items as packed ints (JS unpacks with bitmask constants)
6+
IReadOnlyList<int> GetShopItems(string seed, string deck, string stake, int ante, int offset, int count);
7+
8+
// Classic analyzer: returns formatted text block (MotelySeedAnalysis.ToString())
9+
string AnalyzeSeed(string seed, string deck, string stake);
10+
11+
// JAML validation
12+
bool ValidateJaml(string jamlContent);
13+
string ValidateJamlWithError(string jamlContent);
14+
15+
// Bulk search
16+
void StartJamlSearch(string jamlContent, int threadCount);
17+
void StopSearch();
18+
19+
// Capabilities
20+
string GetVersion();
21+
bool IsSimdEnabled();
22+
int GetProcessorCount();
23+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<InvariantGlobalization>true</InvariantGlobalization>
7+
<!-- Bootsharp output config -->
8+
<BootsharpName>motely-wasm</BootsharpName>
9+
<BootsharpEmbedBinaries>false</BootsharpEmbedBinaries>
10+
<BootsharpBinariesDirectory>$(MSBuildThisFileDirectory)..\motely-wasm\dist\bootsharp</BootsharpBinariesDirectory>
11+
<BootsharpPackageDirectory>$(MSBuildThisFileDirectory)..\motely-wasm</BootsharpPackageDirectory>
12+
<BootsharpAggressiveTrimming>true</BootsharpAggressiveTrimming>
13+
<!-- NativeAOT-LLVM -->
14+
<BootsharpLLVM>true</BootsharpLLVM>
15+
<DotNetJsApi>true</DotNetJsApi>
16+
<UsingBrowserRuntimeWorkload>false</UsingBrowserRuntimeWorkload>
17+
<PublishTrimmed>true</PublishTrimmed>
18+
<DebugType>none</DebugType>
19+
<EmccFlags>$(EmccFlags) -O3</EmccFlags>
20+
</PropertyGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="Bootsharp" />
24+
<PackageReference Include="Bootsharp.Inject" />
25+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
26+
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" />
27+
<PackageReference Condition="$([MSBuild]::IsOSPlatform('Windows'))"
28+
Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" />
29+
<PackageReference Condition="!$([MSBuild]::IsOSPlatform('Windows'))"
30+
Include="runtime.linux-x64.Microsoft.DotNet.ILCompiler.LLVM" />
31+
</ItemGroup>
32+
33+
<ItemGroup>
34+
<EmscriptenEnvVars Include="DOTNET_EMSCRIPTEN_LLVM_ROOT=$(EmscriptenUpstreamBinPath)" />
35+
<EmscriptenEnvVars Include="DOTNET_EMSCRIPTEN_BINARYEN_ROOT=$(EmscriptenSdkToolsPath)" />
36+
<EmscriptenEnvVars Include="DOTNET_EMSCRIPTEN_NODE_JS=$(EmscriptenNodeBinPath)node$(ExecutableExtensionName)" />
37+
<EmscriptenEnvVars Include="EM_CACHE=$(EmscriptenCacheSdkCacheDir)" />
38+
</ItemGroup>
39+
40+
<ItemGroup>
41+
<ProjectReference Include="..\Motely\Motely.csproj" />
42+
</ItemGroup>
43+
</Project>

0 commit comments

Comments
 (0)