AngleSharp / AngleSharp.Js

:angel: Extends AngleSharp with a .NET-based JavaScript engine.
https://anglesharp.github.io
MIT License
103 stars 22 forks source link

Migration to Jint v3 #84

Closed Neshram closed 6 months ago

Neshram commented 1 year ago

Greetings,

Have there been any official efforts on migrating Jint v3? Or is that awaiting Jint v3 eventually leaving "beta" state?

I did some quick poking around and it looks like at minimum Jint has made a lot of member access modifiers more restrictive, including changing IConstructor from public to internal.

FlorianRappl commented 1 year ago

Have there been any official efforts on migrating Jint v3?

Not yet.

Or is that awaiting Jint v3 eventually leaving "beta" state?

Yes - this is the case.

tomvanenckevort commented 7 months ago

Now that Jint v3 has been released, this might become relevant again. I understand from another comment that AngleSharp.Js is currently not getting official attention, so I'm not expecting an upgrade anytime soon (completely understandable).

I wouldn't mind having a crack at it myself. But after locally trying to update the Nuget reference to Jint in the project, I can see there are a lot of breaking changes that need fixing.

I'm not that familiar with the Jint and AngleSharp.Js codebases, so it might be useful to give some pointers on what needs to be done?

FlorianRappl commented 7 months ago

Actually it might be better to essentially start from scratch.

I think a good roadmap / development agenda would be:

  1. Have a plain integration of Jint (i.e., just create a context, evaluate things, ...)
  2. Have it integrated in a way that scripts are evaluated / run in Jint
  3. Have the actual DOM coupled / exposed within the context / Jint

Usually, (3) is where it gets difficult. AngleSharp itself provides helpers for this (and depending on the approach the current code base still has / uses all these helpers): Attributes that indicate what and if so, how certain things should be used, e.g., that InnerHtml on IDocument is innerHTML in JavaScript or how constructors (e.g., of CustomEvent) should be delegated.

There are two approaches to bring the two together:

  1. Dynamically, i.e., at runtime read out the available / integrated AngleSharp libraries, get their attributes and do everything (potentially creating a cache / map of items to speed up this process for other contexts)
  2. Statically, i.e., already at build-time figure out these things and have it pre-wired.

Right now the codebase uses (1) as (2) might be problematic regarding updates and maintainability.

I also have Jint v3 on the radar and I am happy that finally v3 was released. I would be super happy to spend some time on this; but right now I focus the little time I have for AngleSharp on making AngleSharp.Css a 1.0.0. More contributors or sponsors would certainly help to either get more work done quickly or have more time for this project.