Remove the generic nature of Env and most of the JS classes #1109
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Back in the zig-js-runtime days, globals were used for the state and webapi declarations. This caused problems largely because it was done across compilation units (using @import("root")...).
The generic Env(S, WebApi) was used to solve these problems, while still making it work for different States and WebApis.
This change removes the generics and hard-codes the *Page as the state and only supports our WebApis for the class declarations.
To accommodate this change, the runtime/tests have been removed. I don't consider this a huge loss - whatever behavior these were testing, already exists in the browser/**/*.zig web api.
As we write more complex/complete WebApis, we're seeing more and more cases that need to rely on js objects directly (JsObject, Function, Promises, etc...). The goal is to make these easier to use. Rather than using Env.JsObject, you now import "js.zig" and use js.JsObject (TODO: rename JsObject to Object). Everything is just a plain Zig struct, rather than being nested in a generic.
After this change, I plan on:
1 - Renaming the js objects, JsObject -> Object. These should be referenced in
the webapi as js.Object, js.This, ...
2 - Splitting the code across multiple files (Env.zig, Context.zig,
Caller.zig, ...)