Skip to content

Commit e401f32

Browse files
committed
nice
1 parent 02993fc commit e401f32

32 files changed

+2280
-1050
lines changed

.cursor/commands/prepare-npm.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,21 @@ Goal: bump version if requested, clean, restore, build, AOT publish both WASM ta
1414

1515
## Files to update
1616

17-
Set all of these to the same version:
17+
Set the same version in:
1818

19-
- `X:\JammySeedFinder\src\MotelyJAML\Directory.Build.props`
19+
- `X:\JammySeedFinder\src\MotelyJAML\Directory.Build.props` (MotelyVersion)
2020
- `X:\JammySeedFinder\src\MotelyJAML\Motely.npm\package.json`
2121
- `X:\JammySeedFinder\src\MotelyJAML\Motely.node\package.json`
22-
- `X:\JammySeedFinder\src\MotelyJAML\jaml.schema.json`
23-
- `X:\JammySeedFinder\src\MotelyJAML\public\jaml.schema.json`
24-
- `X:\JammySeedFinder\src\MotelyJAML\Motely.npm\jaml.schema.json`
22+
- `X:\JammySeedFinder\src\MotelyJAML\jaml.schema.json` (root — **single source** for schema)
23+
24+
Then **copy** root schema to the other locations (so there is only one schema file to edit):
25+
26+
```powershell
27+
$root = "X:\JammySeedFinder\src\MotelyJAML\jaml.schema.json"
28+
Copy-Item -Path $root -Destination "X:\JammySeedFinder\src\MotelyJAML\public\jaml.schema.json" -Force
29+
Copy-Item -Path $root -Destination "X:\JammySeedFinder\src\MotelyJAML\Motely.npm\jaml.schema.json" -Force
30+
Copy-Item -Path $root -Destination "X:\JammySeedFinder\src\MotelyJAML\Motely.node\jaml.schema.json" -Force
31+
```
2532

2633
Print the version you set so the user can confirm it.
2734

.windsurf/rules/delivery-gate.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

.windsurf/rules/no-fallback-lie.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

.windsurf/rules/threading-authenticity.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

Directory.Packages.props

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
</PropertyGroup>
55
<ItemGroup>
6-
<PackageVersion Include="JetBrains.Annotations" Version="2024.3.0" />
6+
<!-- Node API for .NET addon: https://microsoft.github.io/node-api-dotnet/scenarios/js-dotnet-module.html (CPM requires fixed version) -->
7+
<PackageVersion Include="Microsoft.JavaScript.NodeApi" Version="0.9.19" />
8+
<PackageVersion Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.19" />
9+
<PackageVersion Include="DuckDB.NET.Data.Full" Version="1.4.4" />
10+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.3" />
11+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.3" />
12+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
13+
<PackageVersion Include="xunit" Version="2.9.3" />
14+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
15+
<PackageVersion Include="coverlet.collector" Version="8.0.0" />
16+
<PackageVersion Include="JetBrains.Annotations" Version="2025.2.4" />
717
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
8-
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.0" />
9-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
10-
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.0" />
18+
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.3" />
19+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3" />
20+
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.3" />
1121
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.12" />
1222
<PackageVersion Include="Vecc.YamlDotNet.Analyzers.StaticGenerator" Version="16.3.0" />
1323
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.0.0" />

Motely.BrowserWasm/MotelyWasmExports.cs

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -166,23 +166,14 @@ public static Task<string> ValidateJamlAsync(string jamlContent) =>
166166

167167
// ──────────────────────────────── Search (non-blocking, JS polls status) ────────────────────────────────
168168

169-
/// <summary>
170-
/// Start a JAML search. Returns immediately with initial status JSON.
171-
/// JS polls progress via GetSearchStatus(). No blocking drain loop.
172-
/// </summary>
173-
[JSImport("globalThis.__motelyOnProgress")]
174-
static partial void JsOnProgress(
175-
[JSMarshalAs<JSType.Number>] long totalSeedsSearched,
176-
[JSMarshalAs<JSType.Number>] long matchingSeeds,
177-
[JSMarshalAs<JSType.Number>] long elapsedMs,
178-
[JSMarshalAs<JSType.Number>] int resultCount
179-
);
180-
181-
[JSImport("globalThis.__motelyOnResult")]
182-
static partial void JsOnResult([JSMarshalAs<JSType.String>] string seed, int score);
183-
184169
[JSExport]
185-
public static async Task<string> StartJamlSearch(string jamlContent, string optionsJson)
170+
public static async Task<string> StartJamlSearch(
171+
string jamlContent,
172+
string optionsJson,
173+
[JSMarshalAs<JSType.Function<JSType.String>>]
174+
Action<string> onProgress,
175+
[JSMarshalAs<JSType.Function<JSType.String, JSType.Number>>]
176+
Action<string, int> onResult)
186177
{
187178
try
188179
{
@@ -241,17 +232,18 @@ public static async Task<string> StartJamlSearch(string jamlContent, string opti
241232
.WithBatchCharacterCount(options.BatchCharCount.Value)
242233
.WithSeedMatchCallback(seed =>
243234
{
244-
JsOnResult(seed, 0);
235+
onResult(seed, 0);
245236
_resultQueue.Enqueue((seed, 0));
246237
})
247238
.WithProgressCallback(prog =>
248239
{
249-
JsOnProgress(
250-
prog.SeedsSearched,
251-
prog.MatchingSeeds,
252-
(long)prog.ElapsedTime.TotalMilliseconds,
253-
_drainedResults.Count + _resultQueue.Count
254-
);
240+
onProgress(JsonSerializer.Serialize(new ProgressCallbackDto
241+
{
242+
SeedsSearched = prog.SeedsSearched,
243+
MatchingSeeds = prog.MatchingSeeds,
244+
ElapsedMs = (long)prog.ElapsedTime.TotalMilliseconds,
245+
ResultCount = _drainedResults.Count + _resultQueue.Count,
246+
}, WasmJsonContext.Default.ProgressCallbackDto));
255247
});
256248

257249
if (options.StartBatch.HasValue)

Motely.BrowserWasm/WasmDtos.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ public sealed class SearchOptionsDto
9393
public bool? Palindrome { get; set; }
9494
}
9595

96+
public sealed class ProgressCallbackDto
97+
{
98+
[JsonPropertyName("seedsSearched")]
99+
public long SeedsSearched { get; set; }
100+
101+
[JsonPropertyName("matchingSeeds")]
102+
public long MatchingSeeds { get; set; }
103+
104+
[JsonPropertyName("elapsedMs")]
105+
public long ElapsedMs { get; set; }
106+
107+
[JsonPropertyName("resultCount")]
108+
public int ResultCount { get; set; }
109+
}
110+
96111
public sealed class SearchStatusDto
97112
{
98113
[JsonPropertyName("searchId")]

Motely.BrowserWasm/WasmJsonContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace Motely.BrowserWasm;
1414
[JsonSerializable(typeof(ErrorDto))]
1515
[JsonSerializable(typeof(ValidateResultDto))]
1616
[JsonSerializable(typeof(SearchOptionsDto))]
17+
[JsonSerializable(typeof(ProgressCallbackDto))]
1718
[JsonSerializable(typeof(SearchStatusDto))]
1819
[JsonSerializable(typeof(SearchHitDto[]))]
1920
[JsonSerializable(typeof(SeedAnalysisDto))]

Motely.NodeAddon/Motely.NodeAddon.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,13 @@
1919
<ItemGroup>
2020
<ProjectReference Include="..\Motely\Motely.csproj" />
2121
</ItemGroup>
22+
23+
<!-- Canonical Node package entry: edit NodePackage/index.ts; it is copied to Motely.node on build -->
24+
<ItemGroup>
25+
<Content Include="NodePackage\index.ts" CopyToOutputDirectory="Never" />
26+
</ItemGroup>
27+
28+
<Target Name="ExportNodePackageIndex" AfterTargets="Build">
29+
<Copy SourceFiles="$(MSBuildThisFileDirectory)NodePackage\index.ts" DestinationFiles="$(MSBuildThisFileDirectory)..\Motely.node\index.ts" SkipUnchangedFiles="true" />
30+
</Target>
2231
</Project>

0 commit comments

Comments
 (0)