make chrome extension using nodejs - node.js

Question Background
We are building Chrome Extension. and we need to get the python code in the process.
What i know
I know that python code can be imported using Node JS.
Node JS is used to create servers
Chrome extension is not building server, but making programs(maybe client?)
is it right?
Question
To achieve our goal
Do We need to create server with node js and communicate with chrome extension(using socket.io)?
Is there another way to apply node js in chrome extension?
Is there another way to get the python code into the extension?

Your Chromium web extension code necessarily must be pure client-side Javascript structured to run in the browser's extension environment. There's no support for nodejs or python in that environment; it's very constrained. Because cybercreeps.
You can use XmlHttpRequest or fetch operations in your extension code to access web services. Your extension manifest will need to grant permission to access your server.
You can meet your requirement by building and hosting a server for your extension to use. You can use nodejs and a framework like express and/or socket.io, or you can use python, python-socketio, and a framework like Flask or Django. If you build your server with python, it probably will perform better than a nodejs serves that spawns child processes to run python. It will definitely be easier to install, debug and maintain.

Related

Run VS Code Web Extension with full nodejs APIs support in VS Code Desktop

I am developing a web extension that works well on the vscode.dev with client-based OAuth but when I need to use the same in desktop vscode, the JS Domain i.e. location.origin is coming to be vscode-file://vscode-app which I can't use as JS domain for OAuth2. This results in CORS errors for API calls.
Hence, I need to use the server-based OAuth method to avoid CORS errors.
For this, I need to run the http.createServer method from nodejs when the extension runs in the vscode desktop.
This means that some parts of my source code will work in vscode. dev (i.e. nodejs independent) while others will only work in VS Code desktop (i.e. nodejs dependent).
Can anyone guide me on how to go about implementing the same for my project?
P.S. - I want to provide some functionalities in vscode.dev and some extra functionalities in VS Code Desktop hence I need this hybrid approach.

React NodeGUI - Question about technology. Choosing Desktop Platform

I estimate possibility to write Report Desktop Application using React NodeGUI. There is some questions what I need to find answer before starting to develop by NodeGUI. Could you help me to figure out.
What way is to load program extension dynamicaly in React NodeGUI. For example: If I want to change business logic and visualization of my program without compile code. Is it possible?
What way is to load program extension dynamicaly in React NodeGUI. For example: If I want to change business logic and visualization of program adding some program module code of other developers. How way is it possible to do?
What way is to work with XML files in React NodeGui?
Is there possibility to run other program code written by C/C++ or other languages? What restriction of running non-native JS modules?
What way is to connect to SQL or NoSQL DB (PostgreSQL, Oracle, Mongo and etc)?
What are reasons yet to write or not write Desktop Applications by React NodeGUI?
React NodeGui is just another npm module that you would install in a nodejs program. It is a pure javascript library. It depends on NodeGui which is another regular npm module. NodeGui contains C++ code which acts as a nodejs addon. But for all purposes think of nodegui and react nodegui as regular npm modules. An app built with these libraries is a regular nodejs app.
What way is to load program extension dynamicaly in React NodeGUI. For example: If I want to change business logic and visualization of my program without compile code. Is it possible?
All business logic is written in javascript so any change in those would follow the same flow of how you would in a nodejs app.
What way is to load program extension dynamicaly in React NodeGUI. For example: If I want to change business logic and visualization of program adding some program module code of other developers. How way is it possible to do?
Yes you can use all npm modules available in npm that works with nodejs.
What way is to work with XML files in React NodeGui?
You can find a lot of npm modules you can use to parse and work with xml files in the npm registry.
Is there possibility to run other program code written by C/C++ or other languages? What restriction of running non-native JS modules?
Yes it is possible to run non js code by building them as NodeJs addons.
What way is to connect to SQL or NoSQL DB (PostgreSQL, Oracle, Mongo and etc)?
You have a lot of modules available in the npm registry for these which work with NodeJs.
What are reasons yet to write or not write Desktop Applications by React NodeGUI?
Reasons to use:
- NodeGui apps are native apps so they get all the benefits of native apps. They are snappy, they are accessible and run with low memory and cpu usage.
Reasons not to use:
Its under development so is only recommended for hobby projects as of Dec 2019.
PS: I am the author of the library

general question about reactJS, nodeJS and NPM

first, the "facts" that I know:
reactJS is frontend framework, after compiling it'll generate a bundle of html/js/css files that can be recognized by modern browsers, so the browser straightforward request the web host server for these static html files ;
nodeJS is a server-side environment, or sometimes people call it a backend framework, browsers don't understand nodeJS but have to request the web host server to interpret it and to send back the html response.
according to wiki, npm is a package manager for the JavaScript programming language. It is the default package manager for the JavaScript runtime environment Node.js.
my question is:
is my understanding correct
why reactJS also using npm and includes node_module, does it have something to do with nodeJS
Javascript is the programming language used in both Node.js and in the browser, but that's about as far as the similarities goes. Node uses the V8 engine, which is the same running in the chrome browser.
Even though they use the same engine, they are quite different. They both have plenty of APIs - most notably, the browser has the DOM (which allows you to render stuff to the screen). In Node.js you do not have the DOM, but there are other APIs, for accessing the filesystem for instance.
Since both are running JavaScript, you can try to run the same program both in node and in the browser, but it will sometimes fail. React is a front-end framework which uses the DOM, so if you try to run React in node, it will crash because in Node there is no DOM (Node has no screen to render to). If you try to run a program suited for Node.js in the browser, it will crash if it uses some Node-specific API.
The confusing bit is that npm is a package manager for JavaScript, not necessarily node (even though node is in the name..). Therefore, we can use npm also for web applications. (If we do, we need to use a bundler like webpack though).
Some npm modules might work both in the browser and in node, but some will only work on one of them. If the npm module requires some platform-spcific API (DOM for the browser for example) then it will not work for the other platform.
Hope that clears things out! I understand that it's a bit of a mess..

Reactjs + Electron + Nodejs

I've been researching for long time but haven't found what I need. Maybe here someone can help me out.
What I want:
I'm trying to create an application that will run inside electron. Both frontend and backend should be encapsulated within a single executable, so I was thinking React js and Nodejs would be a good option.
But it's not as simple as I thought. Found a good boilerplace for reactjs https://github.com/electron-react-boilerplate/electron-react-boilerplate but I have no idea how I could encapsulate nodejs as a backend to it.
It'd also somehow would need to be integrated with the release package and so on...
Additionally I'd need to have a webserver that will run on localhost:[port] when you launch the application.
Technical Summary:
So basically:
Electron with React js - as the application 'face'
Nodejs - as the backend of the application
Webserver running locally - (using react js).
In the application, I would put link to the pages that is served by that locally running reactjs web app.
Hope I was clear. And I really hope someone can help me out.
Thanks!!!
as you know the serverside part is separate from front end.you can lunch react electron together like this article https://flaviocopes.com/react-electron/ .but serverside must start to stand alone . you could use pm2 for launching them.http://pm2.keymetrics.io/
lets talk about electron. what is electron?
according to electronjs.org :
Electron is an open source library developed by GitHub for building
cross-platform desktop applications with HTML, CSS, and JavaScript.
Electron accomplishes this by combining Chromium and Node.js into a
single runtime and apps can be packaged for Mac, Windows, and Linux.
so the electron is a tool for creating desktop applications.it uses chromium engine for accessing resources of the operating system level. but the intention of that is creating apps not a serverside job.
if you have some needs and logics that must handle in a server you should be considering that. otherwise, read about serverless applications.

Run node.js app with node-webkit?

I have a nodejs app with modules, views etc..
Is it possible to open this app with node-webkit instead of opening it in the browser ?
Thanks.
Yes, it is. Node-WebKit is a package with browser + node web server. But I believe you will probably want to change your architecture, because you don't need the client-server style. If you run your app without any changes, node-WebKit will act just like node server and you still need a browser to access the app. There is no reason to use node-WebKit instead of pure node in this case.
To use node-WebKit embedded browser you should know that there are no need to start node server. The browser's JavaScript environment is already connected to node and you can execute node commands and packages direct from the JavaScript files (eg.: access file system from the browser, a dream to every web developer). It's like you are running a browser inside the server, without the need of make requests and receive responses... For this reason you don't need to use packages as socket.io, cause the communication is already established. But you can use the fact of node is a server to easily establish communication between different machines, for example.

Resources