+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

refactor(js-api): remove the JSON-RPC backend and unimplemented methods #3831

Merged
merged 3 commits into from
Nov 25, 2022

Conversation

leops
Copy link
Contributor

@leops leops commented Nov 23, 2022

Summary

This PR aims at improving the usability of the @rometools/js-api package by cleaning up some unfinished features.

I removed the JSON-RPC backend as it's unlikely to be useful in the short term while we don't have a long running development server (since this only leaves the WASM backend, the concept of backend has instead been replaced with "distributions" to let the user choose which of the bundler, nodejs or web versions of @rometools/wasm they want to load).

I also removed the formatFiles and parseContent methods since those were not implemented at the moment. On the other hand I added new lintContent and printDiagnostics methods since those were mostly straightforward to implement and could provide additional value to the JS API. Finally I've added a shutdown method to manually free the WASM Workspace instance, as well as an experimental use of the FinalizationRegistry to automatically free some Workspace instances that are no longer reachable.

Test Plan

I've updated the existing tests for the JS API to remove the daemon-specific tests and cover the new methods.

@leops leops requested a review from a team November 23, 2022 10:46
@netlify
Copy link

netlify bot commented Nov 23, 2022

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit 621ef66
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/637fa26f80f4fe0008f4ac68

},
"peerDependencies": {
"rome": "^10.0.0",
"@rometools/wasm-bundler": "^10.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why rome was removed from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rome package isn't being imported in the JS API, it only serves to pull in the pre-built binaries but we're not making use of that anywhere

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it should be removed from the peerDependenciesMeta

Comment on lines +25 to +29
let isInitialized = {
[Distribution.BUNDLER]: false,
[Distribution.NODE]: false,
[Distribution.WEB]: false,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shape makes me think that more than one distribution can be initialized at the same time. Is it the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes potentially someone could call Rome.create multiple times with different distribution, it's unclear why anyone would do that but I figured the modules should at least be initialized properly in that case ...

@@ -1,6 +1,7 @@
{
"compilerOptions": {
"target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["ES2020", "ESNext.WeakRef"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is WeakRef used to enable the FinalizationRegistry feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes FinalizationRegistry isn't part of the ES2020 specification

@ematipico ematipico added breaking A-Runtime Work around runtime labels Nov 23, 2022
@ematipico ematipico added this to the 11.0.0 milestone Nov 23, 2022
@leops leops force-pushed the refactor/minimal-js-api branch from 1bf09f3 to 3277027 Compare November 23, 2022 14:05
@leops leops force-pushed the refactor/minimal-js-api branch from 2aa5104 to 8962d4e Compare November 23, 2022 14:40
Copy link
Contributor

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Please update the README with the correct installation and usage instructions.

@leops leops merged commit 4263cf9 into main Nov 25, 2022
@leops leops deleted the refactor/minimal-js-api branch November 25, 2022 14:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Runtime Work around runtime breaking
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载