low.js and node-matter? #272
Replies: 9 comments 12 replies
-
In fact my answer is a clear "it could" ;-) node-matter is 95% "pure JS" and uses some, already abstracted away, Node.js relevant APIs. These are: Networking/UDP, Date/Timer, Crypto, (and soon) FS ... If low.js is Node.js conform in these places then it is a yes. When I look at https://www.neonious-iot.com/lowjs/documentation/nodejs-api.html then Crypto might get interesting. The good news is that because of the existing abstractions, even if Crypto is not directly compatible, it can be manually implemented and plugged in (soon, because brypto needs to get abstracted - on todo list) for the special case withut any issue. At the bottom line:
|
Beta Was this translation helpful? Give feedback.
-
Very timely post. I am actually tring to make it work with lowjs - one issue I am running into is BigInt. I am trying to replace it with JSBI.BigInt and see what the next roadblock is (besides crypto). Basic issue is that lowjs supports ES 5. Where as node-matter uses ES 6. Lowjs (or babel) can "transpile" from ES 6 to ES 5, but certain features are not supported (BigInt is the first one I ran into). |
Beta Was this translation helpful? Give feedback.
-
I tried using JSBI.BigInt in node-matter code, but it is a bit more than I can chew because @project-chip/matter.js project is using bigint as well and BigInt there needs to be replaced there as well. |
Beta Was this translation helpful? Give feedback.
-
Please ceate an issue in matter.js and we take care, but that might need some time |
Beta Was this translation helpful? Give feedback.
-
low.js support: as stated above the two main bottlenecks will be for BigInt and Crypto support. BigInt considerationsMatter protocol uses unsigned and signed 64-bit integer (up to 2^64 – 1). However:
So maybe there is no need for BigInt support after all in Matter in practice... Crypto considerationsnode-matter uses either built-in node.js crypto or crypto based on elliptic library for missing features
|
Beta Was this translation helpful? Give feedback.
-
I haven't yet checked into the specs, but I did a quick dirty test to modify matter.js and node-matter to use JSBI instead of BigInt. There doesn't seem to be any math, but comparison operator between BigInt and number had to be addressed and JSBI refused to auto convert to Number, so there are more changes than I had hoped. But the changes seem to work and I can run modified code with nodejs and pair with Home Assistant. I am not having much luck running node-matter code with lowjs or quickjs (sans crypto) because they don't support CommonJS and I am not very familiar with different ways of packaging modules (I have tried webpack - but still struggling). Files modified in matter.js :
Files modified in node-matter.js:
See attached for exact diffs (it's quick and dirty hack - so bear with me) |
Beta Was this translation helpful? Give feedback.
-
I understand that I don't need to make any BigInt changes for running with quickjs, but I can't figure out how to modify tsconfig.json to remove CommonJS because it is provided by nodejs but not available in quickjs |
Beta Was this translation helpful? Give feedback.
-
This stuff is all new to me, but it looks like someone wrote a barebones(?) version of CommonJS for quicks? |
Beta Was this translation helpful? Give feedback.
-
@JimBuzbee thanks - tried that but that is a JavaScript and I can't figure out how to convert/adapt it to TypeScript. |
Beta Was this translation helpful? Give feedback.
-
Would node-matter work with low.js?
Beta Was this translation helpful? Give feedback.
All reactions