Repository navigation
docs(plugins): add Node.js JSON-RPC example and align host API 0.19.0 - #387
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Red's JSON-RPC plugin protocol (
#380) and JSON Workbench (#381) ship in the upcoming v0.9.0 release against host API0.19.0. Whileexamples/rpc-hello-pluginprovides a reference Python implementation, developers building JSON-RPC plugins in JavaScript/Node.js need an equivalent runnable package that demonstrates newline-delimited stdio framing, decimal-string revision/ID preservation, Unicode-scalar range indexing (Array.from(text).lengthrather than UTF-16.length), andinitializedgating without introducing an external SDK.examples/README.mdalso retained pre-consolidation0.21and0.26host API numbers.What Changed
examples/rpc-hello-node-plugin/(red-plugin.tomlandplugin.mjs), a standard-library Node.js implementation matchingexamples/rpc-hello-plugin/across all 13 commands andfile:savedevent handling.examples/rpc-hello-plugin/to add Windows[rpc.commands]entries (python), enforce waiting forinitializedbefore calling host methods, and support optional suffix arguments onRpcApplythat replace line 0 using Unicode-scalar offsets andexpected_textpreimage verification.examples/README.mdto referenceexamples/rpc-hello-node-plugin/and align host API version numbers with0.19.0.tests/test_rpc_example.pyto run the shared conformance suite against both the Python and Node.js examples, covering manifest/handshake agreement,initializedgating, large decimal-string revisions/IDs (> Number.MAX_SAFE_INTEGER), non-BMP Unicode-scalar edit ranges (🦀), stale-revision (-32002) error recovery, panels, statusline, config/storage, pickers, and shutdown/exit.How to Test
python3 -m unittest -v tests.test_rpc_exampleand confirm all 16 tests pass across bothPythonRpcExampleTestandNodeRpcExampleTest.red plugin install --path ./examples/rpc-hello-pluginorred plugin install --path ./examples/rpc-hello-node-plugin, open a file containing multi-byte Unicode (such asconst icon = "🦀";), and run:RpcHello world,:RpcDocument,:RpcApply // crab,:RpcUndo, and:RpcPanel/:RpcPanelClose.:RpcUndoa second time with no active transaction and confirm Red displaysRpcApply has no transaction to undoas a warning while subsequent:RpcHellocommands continue working.