Version v0.1.0 released with the following changes:
Breaking change: Pass InSim instance as an argument in createRoot
In order to have node-insim truly decoupled, I've decided to change the createRoot API so it accepts the InSim instance as an argument. This is what the connection looks like now:
const inSim = new InSim();
inSim.connect({
IName: 'React InSim',
ReqI: 1,
Host: '127.0.0.1',
Port: 29999,
Flags: InSimFlags.ISF_LOCAL,
});
const root = createRoot(inSim);
root.render(
<Button top={100} left={80} width={30} height={10}>
Hello InSim!
</Button>,
);
The only requirement for the InSim connection options is the ReqI being a non-zero value, otherwise react-node-insim will throw an error. The ReqI is needed to wait for a successful connection to LFS.
As a result of this change, createRoot no longer returns the InSim instance since it's no longer created inside.
Unit tests
To have some confidence that React Node InSim will send the correct IS_BTN packets given a React component tree, I've started writing unit tests. You can see some simple tests for <Button> in
tests/button.test.ts. The tests intercept TCP connections and check if the correct packets are received at a given host/port.
There are still many more test cases to cover. I would like to continue writing them in the future.
Misc
Fix: Only trigger onType and onClick event if ClickID and UCID matches
Add a CI pipeline
Exclude host from connection scope
Allow null and ToggleButton elements inside Flex component
Allow ToggleButton in Stack