Enable support for the core Node.js APIs so that Node.js dependent modules can be used in {N}.
Please vote for this feature in our ideas portal.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Please list any Node.js the APIs you want to see in {N} below. Thanks!
I'd say that stuff like stream
and events
, could be easily added with npm modules.
I'd say that fs
, net
and http
are pretty important (and the ones that'd be hardest to replace with pure JS modules), since a lot of modules rely on them.
I'd also sugest that if anything, have a way to override require calls. For instance, let us specify that require("fs")
actually requires a different module like fs-nativescript
which can be added as needed. This flow would then be similar to how browserify does things
Well, this is very very cool! I think the best is sent directly to the API nodejs. But I think all the plugins can not be mounted or necestian changes. These would be the main
fs
stream
path
event
net
- WebSocket ;)Debugger
Crypto
Although there are several that are already developed... Sure, but I propose the most interesting one that utils
is called, but this can be acquired and to format strings.
I currently have part of "fs" already written over the last several weeks, because I do a lot of node development Some of it wraps the existing file-system api, some of it uses native calls. I just created the repo and pushed it up to https://github.com/Nathanaela/nativescript-node -- Unless we have a different place to work; feel free to fork and start updating and/or adding api's.
As much as I would love Telerik to do this -- I think this would be better community done so that the Telerik employees can focus on fixing some of the other issues that are lower level and that they have a better chance to fix faster since they understand the internals a lot better at this point.
I need socket
for an app I'm intermittently working on, since I need to connect to a non-HTTP port.
My current solution uses Cordova + a specific plugin, but that's gotten clunky in a hurry, because of Cordova's obnoxiousredundant config and that Gulp has little that works with Cordova (I have to use undocumented APIs to make it fit). I can't just use Cordova, because I have to compile my CSS and JS, and Cordova is terrible for running tasks. It's sad, really.
+1
This is really exiting! I would like to see net
, crypto
and fs
. We also have a need for native C/C++ plugins, but I guess that is harder enable.
hi i am from meteor.js backgroud and nativescript is perfect for createing webApps. Currently the problem i am facing in nativescript is using DDP to connect to my meteor app. there is node-ddp npm packages and it uses websocket. If i am not wrong nativescript doesn't support websocket right? the DDP integration will be great boost for nativescript for creating realtime native mobile apps using nativeScript. and +1 for native script this is what we were searching for years. Thanks
The thing with node-dpp, is that it uses something that builds on the net
module for websockets. There is a nativescript websocket plugin, but getting it to work with node-dpp will be nontrivial from what I understand.
Have anyone tried this one? https://github.com/emmanuelbuah/asteroid-nativescript "meteor ddp client for nativescript via Asteroid"
@senikk asteroid-nativescript is not ready yet. I was waiting for @NathanaelA websocket lib to complete it. I just haven't had the time to get back to completing it. I plan to get to it by end of this month.
@emmanuelbuah, just a FYI, in case you missed it my websockets has been released for several weeks now. ;-)
@NathanaelA Thanks for your contribution to the community. I tried using nativescript-websockets library with ddp.js/node-ddp and ddp-client modules but that didn't work out. Nativescript kept complaining about "module ddp not found" while other modules like moment.js work without any problems in my Nativescript app. Do you have any idea how I could fix this?
@Tim-W no problem; I glad to share what I know. I see you moved the discussion for ddp to #780 so I'll continue over there on any ddp specifics.
I would like to add my voice to those wanting such APIs supported. The crypto API being my personal biggest need at the moment.
http
is quite important, I'm trying to use the existing xmlrpc
client which obviously uses it and it seems like a giant hurdle to strip it out and replace it.
The name collision which currently exist seems like a problem too.
Crypto would be great!
What are the updates on this? Are there any APIs that are implemented?
I started a nativescript-node library 8 months ago to do this; but there has been absolutely no community support for this; so nothing beyond the basic fs that I did (which if I recall is fully done, other than the docs). You can pull it down at github.com/Nathanaela/nativescript-node
I expect that once the community grows a lot more; that more developers will be willing to help do these and it might get some steam, but at this point no community support = not getting done. I don't work or speak for Telerik, I'm just a independent contractor... My own opinion is that since these aren't really core NativeScript items; the community either needs to do them or pay/bounty/sponsor to get them done sooner.
It's worth mentioning that I managed to get a lot of things running by using browserify npm modules.
There are little things/conflicts, like having to stick some variables into global, or worse ones.
Regarding fs, there have been substitutes, again for browserify, on top of levelup on top of indexeddb.
However, net would be tricky.
hey guys, i am new nativescrit/npm and nodejs. But would like to know where is nativescript in terms of nodejs integration. @Ivshti, how would i leverage your work in my learning.
@Ivshti
For something like NativeScript, fs
and net
should actually be doing syscalls. fs
should be reading files from the local storage (throwing EACCES
errors where necessary) and net
should literally be opening low-level ports.
@svc76 - No real status change as of My post on Jan 24th... No community support = not getting done. I'm fully willing to help with this project (like I already have FS done and free for anyone to use); but I as a independent contractor I don't have time to do the whole thing.
+1 for crypto
For my current need atm I substituted crypto with npm crypto-js module.
:+1: for tty
I would like to use express to be able to create in-app http servers
@sushruth I feel this may be a bit out of scope for NativeScript, but I would recommend you JXCore. It's an embeddable Node.js and it can be embedded into a {N} app
Any progress on this ? How can we use node core libraries? Many npm modules have http, tty dependencies..
Many many thanks @louislarry. The crypto-js saved my life.
If someone need a help to use with TypeScript, use plain JS and will work just fine:
var CryptoJS = require('crypto-js');
CryptoJS.MD5('My text');
I would love to see buffer
! - it's required for quite a lot of the npm modules I want to use, e.g. jsonwebtokens
and node-uuid
As an interim / partial solution, I wonder if anyone could write an article about working around adding some of the APIs? It seems that there are workarounds, including @NathanaelA 's fs
and I believe people are using some of the browserify plugins for this? I am not sure how to register these in a {N} application, so that npm modules can be used untouched without throwing errors. thoughts?
os.networkInterfaces();
Specifically I want to get the ip-address and netmask for my local network interfaces, whether it's through this node api or some other means.
Here are some workarounds in the mean time:
1) NPM install the Browserify shims (e.g. path-browserify
) into your NativeScript project, then go into the node_modules
directory and rename it to the original Node API (e.g. path
). You could write a post-install script to do this automatically after every install.
2) Browserify the NPM modules you want to use in your project.
Browserify shims will work for most of the Node modules that aren't processor intensive and don't directly access the hardware. The Crypto shim will work, but it would be much more performant to re-write it with platform-specific native code.
http
needs to be renamed to nativescript-http
so it doesn't conflict with NPM modules, as the API is incompatible.Another possibility could be compiling Node's C++ source code for IOS/Android, but I don't know how viable that is. The goal would be to get most NPM modules working out of the box. (Especially FS, HTTP, Buffer Stream which are needed for working with APIs.)
@colinskow
Another possibility could be compiling Node's C++ source code for IOS/Android, but I don't know how viable that is.
For one, Apple prohibits apps from generating machine code at runtime as part of its developer agreement, and has been criticized for it for years. Also, Node's source code is highly coupled to V8, even calling V8 APIs directly from JS through C++ bindings, which has made porting to other engines increasingly difficult, so you'll have to write most of it from scratch, anyways.
_(The fork running on ChakraCore only exists because Microsoft needed it for Windows 10 IoT to reduce the memory footprint, and it helped that the two engines' APIs are very similar.)_
It looks like Node.js has already been ported to Android and IOS in a project called jxCore. (As @Ivshti has mentioned.)
This can be embedded in a NativeScript app and issue #2447 gives some details. I would love to see a tutorial on how to install this on Android/IOS and get it communicating with the NativeScript APIs.
I got the Web Cryptography API working (aka window.crypto
) by proxying calls to a hidden WebView that does the computation: https://github.com/saulshanabrook/nativescript-webview-crypto
@colinskow - Just a FYI; JXCore is no longer under any sort of active development since March of this year.
please, Crypto
@DanielMcColgan, have you tried crypto-js? It worked for me.
+1 crypto
I've been recently running into a ton of dependency issues with trying to get a nativescript app to work with AWS.
any news?
Crypto!
@rumkin Crypto can work
Any luck with this?
The AWS JavaScript SDK cannot be used with NativeScript at this point of time, which is a huge impediment to switching to NativeScript from Ionic 2, React, or native.
FYI, thanks for a great platform!
Hey @vbudilov - do you know what is the dependency in AWS sdk that is not present in {N}?
The first one I saw was crypto:
util.crypto.lib = require("crypto-browserify");
http://github.com/dominictarr/crypto-browserify
@vbudilov - I have a client that is going to pay me for some parts of the AWS library to be usable in NativeScript; if you are interested; I bet he would love to cut his costs if you want to join him in paying for this library to be brought to NativeScript or for more of the Library to be brought to NativeScript as we currently only have a small part that we are targeting to keep the costs down.
Thanks @NathanaelA :) I can port the library myself, but there's no way to keep up with the pace of change of the SDK (with all of the new services and features that are coming out).
There needs to be a permanent solution.
My permanent solution, unfortunately, was moving away from native script
and going with a competing product. Would have loved to stay though.
On Dec 12, 2016 9:14 PM, "Vladimir Budilov" notifications@github.com
wrote:
Thanks @NathanaelA https://github.com/NathanaelA :) I can port the
library myself, but there's no way to keep up with the pace of change of
the SDK (with all of the new services and features that are coming out).There needs to be a permanent solution.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/NativeScript/NativeScript/issues/195#issuecomment-266664436,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AR2J5b0K76sFgHIOLJ454ymLyvmfqK-jks5rHkXvgaJpZM4EhsX6
.
I agree with @vbudilov. We better enable the JS SDK of AWS to work out of the box and not try to "port" it to NativeScript.
We will take a look.
@jensenbuck - sorry to hear this. I hope you will come back soon :).
@valentinstoychev - Do you have a time frame, because if the NativeScript team is going to do key parts of it, I can go back to my client and give him your ETA so that he doesn't have to pay me to do something that will be in the framework (or in a plugin); depending on his time frame...
Not yet. I'll keep you posted.
Thanks @valentinstoychev !
For testing purposes, you can use my Angular 2 AWS web app
I also have an Ionic 2 version (not sharing it here for obvious reasons :)). Basically, all that needs to change is the view layer (I'd start with the first page - login).
Let me know if you need any help and thanks a lot! I'd love to start using NativeScript.
Hi folks,
I'm trying to make the AWS JS SDK work with {N} and was able to list the files in my S3 bucket, list tables in a Dynamo DB and update a Dynamo record in a table.
That's only a small part of the SDK of course, so before releasing anything I'd like to test some real-world scenario's first.
So does anyone have a {N} app I can clone and test AWS with? For instance @vbudilov's attempt to transform that Angular web app into a {N} app?
Thanks in advance!
Hi @EddyVerbruggen ,
I had the project but deleted it since it wasn't going anywhere. I'll recreate it soon - maybe over the weekend or next week. Mind sharing what you have so far? I can start with that.
Thanks for the work!!
Hey @vbudilov,
I can imagine you threw it away. I did the same during several attempts getting this to work. I've settled on a proprietary solution which seems to work really well for me, so I'd love you to test the new nativescript-aws plugin!
Feel free to post some general feedback here, but plugin-related issues should probably be filed in that repo.
Hi @EddyVerbruggen ,
This is awesome. One of the libraries I'm using isn't part of the main AWS Javascript SDK, unfortunately. It can be found here: https://github.com/aws/amazon-cognito-identity-js
The AWS Cognito Service requires it to work. Do you mind Creating a plugin for it as well? I'm sure the logic would be exactly the same. I can then create a sample NS project to test with.
Thanks!
Vladimir
Pssst @vbudilov, can you take a look here for Cognito? Let me know what you think - just post feedback in that repo.
@EddyVerbruggen ,
I'll start shortly....I'll keep you posted. Thanks!
http, the NodeJS http module
vm module. to create js sandboxes.
NET
+1 tty
+1 crypto pleeeeaase!!!!
+1 tty because: auth0
express (I'll be happy to know if there's another way to create in-app http servers)
@neTAC23 express is not a built in Node.js API
@neTAC23 You're probably referring to http
(NativeScript is missing the server implementation).
crypto
is a must, used in so many other node.js modules
Here are some new steps of community in relevant direction: https://github.com/janeasystems/nodejs-mobile Unfortunately it's not wrapped as NativeScript plugin. Looks like a lot of work
@ivanpadavan, I have actually wrapped the Android side; and have a fully working plugin with two way communication. I just haven't had time to do the same for the iOS side.
(Basic) TCP and TLS sockets are an important feature! With this nativescript would get even more complete.
(E.g. nativescript-simple-networking is not working due to one of the open issues listed on github)
@NathanaelA, it would also be very interesting to know where to find the plugin for nodejs-mobile. Thanks!
@monjray - If I pushed it (a lot of times I wait until I have everything done); it would be in github.com/nathanaela/nativescript-node
@NathanaelA any news about the nodejs-mobile plugin? I am trying to implement node-opcua in our NativeScript App and i am stuck as it requires somehow NodeJS. I would be pleased for any solution to a NodeJS support in NativeScript.
Thanks
@OMuhammad - Sorry, I have not had time to do the iOS side. Too many other paying jobs compete for time against free stuff.
@NathanaelA yes i understand. Thanks for your reply.
Most helpful comment
Crypto would be great!