Skip to content

v3.1.4

Choose a tag to compare

@windischb windischb released this 20 Apr 04:41
· 35 commits to develop since this release
d67ae18

Short-name aliases in Monaco + NewObject, plus the Linq .d.ts files are now reflection-generated from C# — no more hand-written declarations drifting from runtime. Pure additive, no breaking API changes.

Added

  • JsEvalBuilder.AddTypeAlias<T>("Name") — emits T at root scope in .d.ts AND makes NewObject("Name") return the type at runtime. Single config, both layers.
  • JsEvalBuilder.MapNamespace(prefix, target) — bulk-map a whole namespace tree. Empty target = full flatten (deeply nested sub-namespaces collapse to root too). System.* stays qualified by default.
  • IJsTsDefinitionContributor — new extension point. Any package can contribute .d.ts files via AddTsDefinitionContributor<T>() on the builder. AddLinq() is the first internal user.
  • JsEvalBuilder.AddRuntimeOnlyExtensionMethods(...) — register extension methods with Jint for runtime resolution without polluting TsDefinition's emitted .d.ts.
  • Standalone equivalents on DefinitionBuilder — AddType(type, alias) and MapNamespace(...) for non-DI consumers.

Changed

  • linq.d.ts and cocoar-jseval-linq.d.ts are auto-emitted by AddLinq() via TsDefinitionService.GetTsDefinitions(). Both reflection-generated from C# types — linq.d.ts from the new LinqGlobal class, cocoar-jseval-linq.d.ts from IJsStringAliases / IJsArrayAliases<T> metadata interfaces. No hand-written files left in the Linq package.
  • linq.* return types now match TsDefinition's output — linq.guid('…') is System.Guid, numeric helpers return number. Previous versions referenced undeclared Guid / Decimal / Long identifiers that Monaco resolved to any.
  • PascalCase string/array aliases work at plain Jint runtime. "abc".Contains('x') and [1,2,3].Any(x => x > 0) now resolve to real BCL / System.Linq.Enumerable methods, not just inside translator-processed predicates.
  • Collision detection throws at render time when two distinct types resolve to the same short name — but only when a user rule is involved. Natural nested-type collisions (Span<T>.Enumerator etc.) keep the v3.1.3 interface-merging behavior.

Removed

  • LinqTypeScriptDefinition helper class (the Read() / WriteTo(path) methods). Use TsDefinitionService.GetTsDefinitions() — it now surfaces cocoar-jseval-linq.d.ts and linq.d.ts automatically when AddLinq() is on the builder.

Fixed

  • GitVersion.yml: is-main-branch was pointing at main, but the repo's trunk is develop. GitVersion fell through to the other rule and emitted empty prerelease labels (3.1.3-.1). Now correctly marks develop.
  • Prerelease workflow: feature-branch prereleases use a 0.0.0-<label>.N base instead of inheriting GitVersion's predicted version, so a branch name can't silently imply a release target. Develop still uses the real version.

Example

services.AddJsEval(js => js
    .AddLinq()
    .MapNamespace("TimeToDo.Infrastructure.Persistence.Marten.Projections", "")
    .MapNamespace("TimeToDo.Domain.Identity", ""));

Monaco now shows CustomerView on hover instead of the 70-character namespace path, NewObject('CustomerView') returns the right type, and scripts that compare c.Id === linq.guid('…') type-check honestly.

Tests: 329 green (Engine 148, Linq 134, TypeScript 29, Modules 18).