├── storage └── .gitkeep ├── neutralino.png ├── app ├── settings-browser.json ├── settings-cloud.json ├── assets │ ├── app.css │ ├── app.vendors~main.js.LICENSE.txt │ ├── neutralino.js │ ├── app.main.js │ └── app.vendors~main.js ├── settings.json └── index.html ├── .babelrc ├── src ├── setupTests.js ├── App.css ├── App.test.js ├── Components │ ├── NeuDefault.js │ └── RamUsageExample .js ├── App.js ├── neu.css ├── App-core │ └── mainApp.js └── serviceWorker.js ├── .gitignore ├── configs ├── webpack.common.js ├── webpack.dev.js └── webpack.prod.js ├── README.md ├── .github └── workflows │ └── pushPullAction.yml ├── LICENSE └── package.json /storage/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /neutralino.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neutralinojs/neutralinojs-react/HEAD/neutralino.png -------------------------------------------------------------------------------- /app/settings-browser.json: -------------------------------------------------------------------------------- 1 | { 2 | "appname" : "myapp", 3 | "appport" : "8080", 4 | "mode" : "browser" 5 | } 6 | -------------------------------------------------------------------------------- /app/settings-cloud.json: -------------------------------------------------------------------------------- 1 | { 2 | "appname" : "myapp", 3 | "appport" : "8080", 4 | "mode" : "cloud", 5 | "cloud" : { 6 | "blacklist" : ["os.runCommand"] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /app/assets/app.css: -------------------------------------------------------------------------------- 1 | #neutralinoapp{text-align:center}#neutralinoapp h1{font-family:Segoe UI,Tahoma,Geneva,Verdana,sans-serif;font-size:20px;color:#000}#neutralinoapp a{margin-left:12px}#neutralinoapp span{font-size:12px;font-weight:400} -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env", "@babel/preset-react"], 3 | "plugins": [ 4 | [ 5 | "@babel/plugin-proposal-class-properties", 6 | { 7 | "loose": true 8 | } 9 | ] 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import "@testing-library/jest-dom/extend-expect"; 6 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { render, cleanup } from "@testing-library/react"; 3 | import App from "./App"; 4 | 5 | afterEach(cleanup); 6 | 7 | test("should have NeutralinoJs", () => { 8 | const { getByTestId } = render(); 9 | expect(getByTestId("caption")).toHaveTextContent("NeutralinoJs"); 10 | }); 11 | -------------------------------------------------------------------------------- /app/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "appname": "myapp", 3 | "appport": "0", 4 | "mode": "window", 5 | "window": { 6 | "title": "My app", 7 | "width": "1000", 8 | "height": "700", 9 | "fullscreen": false, 10 | "alwaysontop": false, 11 | "iconfile": "neutralino.png", 12 | "enableinspector": false, 13 | "borderlesswindow": false 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | node_modules 25 | -------------------------------------------------------------------------------- /src/Components/NeuDefault.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | 3 | class NeuDefault extends Component { 4 | render() { 5 | if (typeof Neutralino === "undefined") { 6 | return ""; 7 | } 8 | return ( 9 |

10 | {`${NL_NAME} is running on port ${NL_PORT} inside ${NL_OS}`}
11 |
12 | {`v ${NL_VERSION}`} 13 |

14 | ); 15 | } 16 | } 17 | export default NeuDefault; 18 | -------------------------------------------------------------------------------- /configs/webpack.common.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = { 4 | entry: path.resolve(__dirname, "../src/App-core/mainApp.js"), 5 | output: { 6 | filename: "app.[name].js", 7 | path: path.resolve(__dirname, "../app/assets/"), 8 | publicPath: "/" 9 | }, 10 | optimization: { 11 | splitChunks: { 12 | chunks: "all" 13 | } 14 | }, 15 | module: { 16 | rules: [ 17 | { 18 | test: /\.(js|jsx)$/, 19 | exclude: /node_modules/, 20 | use: { 21 | loader: "babel-loader" 22 | } 23 | } 24 | ] 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | 3 | import RamUsageExample from "./Components/RamUsageExample "; 4 | import NeuDefault from "./Components/NeuDefault"; 5 | 6 | class reactComponents extends Component { 7 | render() { 8 | return ( 9 |
10 |

NeutralinoJs

11 | 12 |
13 | 14 |
15 |
16 | {/* NeutralinoJs example for get current available and total ram in Gb* 17 | remove comment for below line*/} 18 | {/* */} 19 |
20 |
21 | ); 22 | } 23 | } 24 | 25 | export default reactComponents; 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Notice 🔔 2 | 3 | Please use https://github.com/neutralinojs/neutralinojs-minimal instead of this template, if you are trying Neutralinojs v2. 4 | 5 | # neutralinojs-react 6 | 7 | ![](https://github.com/sachith-1/react-for-neu-cli/workflows/React-Neu%20on%20CI/badge.svg) 8 | 9 | React starter project for Neutralinojs 10 | 11 | ## Get started 12 | 13 | Install [neu-cli](https://neutralino.js.org/docs/#/tools/cli) 14 | 15 | ```bash 16 | $ npm i -g @neutralinojs/neu 17 | ``` 18 | 19 | Create Neutralino app with React template 20 | 21 | ```bash 22 | $ neu create myapp --template react 23 | $ cd myapp 24 | ``` 25 | 26 | Bundle source files 27 | 28 | ```bash 29 | $ neu build 30 | ``` 31 | 32 | Learn more about neu-cli from [docs](https://neutralino.js.org/docs/#/tools/cli) 33 | -------------------------------------------------------------------------------- /configs/webpack.dev.js: -------------------------------------------------------------------------------- 1 | const merge = require("webpack-merge"); 2 | const common = require("./webpack.common.js"); 3 | const path = require("path"); 4 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 5 | 6 | module.exports = merge(common, { 7 | mode: "development", 8 | devtool: "inline-source-map", 9 | module: { 10 | rules: [ 11 | { 12 | test: /\.css$/, 13 | use: [{ loader: "style-loader" }, { loader: "css-loader" }] 14 | }, 15 | { 16 | test: /\.s(a|c)ss$/, 17 | use: [ 18 | { loader: "style-loader" }, 19 | { loader: "css-loader" }, 20 | { loader: "sass-loader" } 21 | ] 22 | } 23 | ] 24 | }, 25 | plugins: [ 26 | new MiniCssExtractPlugin({ 27 | filename: "app.css" 28 | }) 29 | ] 30 | }); 31 | -------------------------------------------------------------------------------- /app/assets/app.vendors~main.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | object-assign 3 | (c) Sindre Sorhus 4 | @license MIT 5 | */ 6 | 7 | /** @license React v0.19.1 8 | * scheduler.production.min.js 9 | * 10 | * Copyright (c) Facebook, Inc. and its affiliates. 11 | * 12 | * This source code is licensed under the MIT license found in the 13 | * LICENSE file in the root directory of this source tree. 14 | */ 15 | 16 | /** @license React v16.13.1 17 | * react-dom.production.min.js 18 | * 19 | * Copyright (c) Facebook, Inc. and its affiliates. 20 | * 21 | * This source code is licensed under the MIT license found in the 22 | * LICENSE file in the root directory of this source tree. 23 | */ 24 | 25 | /** @license React v16.13.1 26 | * react.production.min.js 27 | * 28 | * Copyright (c) Facebook, Inc. and its affiliates. 29 | * 30 | * This source code is licensed under the MIT license found in the 31 | * LICENSE file in the root directory of this source tree. 32 | */ 33 | -------------------------------------------------------------------------------- /.github/workflows/pushPullAction.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: React-Neu on CI 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | strategy: 16 | matrix: 17 | node-version: [10.x, 12.x] 18 | os: [windows-latest,ubuntu-latest,macos-latest] 19 | 20 | runs-on: ${{matrix.os}} 21 | 22 | steps: 23 | - uses: actions/checkout@v2 24 | - name: Use Node.js ${{ matrix.node-version }} 25 | uses: actions/setup-node@v1 26 | with: 27 | node-version: ${{ matrix.node-version }} 28 | - run: npm install 29 | - run: npm run build --if-present 30 | env: 31 | CI: true 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 99X Technology Incubator 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /configs/webpack.prod.js: -------------------------------------------------------------------------------- 1 | const merge = require("webpack-merge"); 2 | const common = require("./webpack.common.js"); 3 | const path = require("path"); 4 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 5 | const TerserJSPlugin = require("terser-webpack-plugin"); 6 | const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin"); 7 | const { CleanWebpackPlugin } = require("clean-webpack-plugin"); 8 | const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); 9 | 10 | module.exports = merge(common, { 11 | mode: "production", 12 | optimization: { 13 | minimizer: [ 14 | new TerserJSPlugin({}), 15 | new OptimizeCssAssetsPlugin({}), 16 | new UglifyJsPlugin() 17 | ] 18 | }, 19 | module: { 20 | rules: [ 21 | { 22 | test: /\.css$/, 23 | use: [{ loader: MiniCssExtractPlugin.loader }, { loader: "css-loader" }] 24 | }, 25 | { 26 | test: /\.s(a|c)ss$/, 27 | use: [ 28 | { loader: MiniCssExtractPlugin.loader }, 29 | { loader: "css-loader" }, 30 | { loader: "sass-loader" } 31 | ] 32 | } 33 | ] 34 | }, 35 | plugins: [ 36 | new OptimizeCssAssetsPlugin(), 37 | new MiniCssExtractPlugin({ 38 | filename: "app.css" 39 | }), 40 | new CleanWebpackPlugin({ 41 | root: process.cwd(), 42 | verbose: true, 43 | dry: false, 44 | cleanOnceBeforeBuildPatterns: ["**/*", "!neutralino.js"] 45 | }) 46 | ] 47 | }); 48 | -------------------------------------------------------------------------------- /src/neu.css: -------------------------------------------------------------------------------- 1 | /* 2 | MIT License 3 | 4 | Copyright (c) 2018 Neutralinojs 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. */ 23 | 24 | #neutralinoapp { 25 | text-align: center; 26 | } 27 | #neutralinoapp h1 { 28 | font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; 29 | font-size: 20px; 30 | color: #000000; 31 | } 32 | #neutralinoapp a { 33 | margin-left: 12px; 34 | } 35 | #neutralinoapp span { 36 | font-size: 12px; 37 | font-weight: normal; 38 | } 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-for-neu-cli", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.8.0", 7 | "@testing-library/react": "^9.5.0", 8 | "@testing-library/user-event": "^10.3.5", 9 | "react": "^16.13.0", 10 | "react-dom": "^16.13.0", 11 | "react-scripts": "3.4.0" 12 | }, 13 | "scripts": { 14 | "start": "webpack -p --config=configs/webpack.dev.js --watch", 15 | "build": "webpack -p --config=configs/webpack.prod.js", 16 | "webpack": "webpack --progress", 17 | "test": "react-scripts test" 18 | }, 19 | "eslintConfig": { 20 | "extends": "react-app" 21 | }, 22 | "browserslist": { 23 | "production": [ 24 | ">0.2%", 25 | "not dead", 26 | "not op_mini all" 27 | ], 28 | "development": [ 29 | "last 1 chrome version", 30 | "last 1 firefox version", 31 | "last 1 safari version" 32 | ] 33 | }, 34 | "devDependencies": { 35 | "@babel/core": "^7.12.10", 36 | "@babel/plugin-proposal-class-properties": "^7.8.3", 37 | "@babel/preset-env": "^7.9.5", 38 | "@babel/preset-react": "^7.8.3", 39 | "babel-loader": "8.2.2", 40 | "clean-webpack-plugin": "^3.0.0", 41 | "css-loader": "^3.5.2", 42 | "mini-css-extract-plugin": "^0.9.0", 43 | "optimize-css-assets-webpack-plugin": "^5.0.3", 44 | "terser-webpack-plugin": "^2.3.5", 45 | "uglifyjs-webpack-plugin": "^2.2.0", 46 | "webpack": "4.41.5", 47 | "webpack-cli": "^3.3.11", 48 | "webpack-merge": "^4.2.2" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/index.html: -------------------------------------------------------------------------------- 1 | 23 | 24 | 25 | 26 | 27 | 28 | NeutralinoJs 29 | 30 | 31 | 32 |
33 |
..
34 |
35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/App-core/mainApp.js: -------------------------------------------------------------------------------- 1 | // MIT License 2 | 3 | // Copyright (c) 2018 Neutralinojs 4 | 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | import React from "react"; 24 | import ReactDOM from "react-dom"; 25 | 26 | import "../neu.css"; 27 | import App from "../App"; 28 | import * as serviceWorker from "../serviceWorker"; 29 | 30 | Neutralino.init({ 31 | load: function() {}, 32 | pingSuccessCallback: function() {}, 33 | pingFailCallback: function() {} 34 | }); 35 | 36 | ReactDOM.render(, document.getElementById("root")); 37 | 38 | // If you want your app to work offline and load faster, you can change 39 | // unregister() to register() below. Note this comes with some pitfalls. 40 | // Learn more about service workers: https://bit.ly/CRA-PWA 41 | serviceWorker.unregister(); 42 | -------------------------------------------------------------------------------- /src/Components/RamUsageExample .js: -------------------------------------------------------------------------------- 1 | import React, { Component } from "react"; 2 | class RamUsageExample extends Component { 3 | state = { 4 | aMemVal: "", 5 | tMemVal: "", 6 | isbtnRamUsage: 0, 7 | }; 8 | 9 | styles = { 10 | btnRamUsage: { 11 | color: " #fff", 12 | backgroundColor: "#28a745", 13 | borderColor: "#28a745", 14 | borderRadius: "0.25rem", 15 | fontWeight: 400, 16 | textAlign: "center", 17 | border: "1px solid transparent", 18 | padding: ".375rem .75rem", 19 | fontSize: " 1rem", 20 | lineHeight: "1.5", 21 | cursor: "pointer", 22 | }, 23 | spanStyles: { 24 | margin: 10, 25 | }, 26 | }; 27 | 28 | render() { 29 | return ( 30 |
31 | {this.GetMemBtn()} 32 | {this.state.isbtnRamUsage === 1 ? ( 33 |

34 | Available Memory : 35 | 36 | {this.state.aMemVal} 37 | 38 | Total Memory : 39 | 40 | {this.state.tMemVal} 41 | 42 |

43 | ) : ( 44 | "" 45 | )} 46 |
47 | ); 48 | } 49 | 50 | GetMemBtn() { 51 | return ( 52 | { 57 | this.ramUsage(); 58 | this.isRamBtnClicked(); 59 | }} 60 | /> 61 | ); 62 | } 63 | 64 | ramUsage() { 65 | Neutralino.computer.getRamUsage( 66 | function (data) { 67 | let aMem = 68 | (data["ram"]["available"] / (1024 * 1024)).toFixed(3) + " GB"; 69 | this.setState({ aMemVal: aMem }); 70 | 71 | let tMem = (data["ram"]["total"] / (1024 * 1024)).toFixed(3) + " GB"; 72 | this.setState({ tMemVal: tMem }); 73 | }.bind(this), 74 | function () { 75 | this.setState({ aMemVal: "Error While Executing" }); 76 | }.bind(this) 77 | ); 78 | } 79 | 80 | isRamBtnClicked = () => { 81 | this.setState({ isbtnRamUsage: 1 }); 82 | }; 83 | } 84 | 85 | export default RamUsageExample; 86 | -------------------------------------------------------------------------------- /app/assets/neutralino.js: -------------------------------------------------------------------------------- 1 | var Neutralino=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){let o=n(3);e.exports={ajax:function(e){e.method||(e.method=!0);var t=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");t.onreadystatechange=function(){4==t.readyState&&200==t.status?e.done&&e.done(JSON.parse(t.responseText)):4==t.readyState&&e.problem&&e.problem({message:"An error occured while connecting with Neutralino server!"})},void 0!==e.data&&(sendString=JSON.stringify(e.data)),"GET"==e.type&&(t.open("GET",e.url,e.method),t.setRequestHeader("Authorization","Basic "+o.getToken()),t.send()),"POST"==e.type&&(t.open("POST",e.url,e.method),t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),t.setRequestHeader("Authorization","Basic "+o.getToken()),t.send(sendString))}}},function(e,t,n){let o=n(2),r=n(4),a=n(5),i=n(6),u=n(7),c=n(8),l=n(11),f=n(12);e.exports={app:f,filesystem:o,settings:r,os:a,computer:i,storage:u,init:c,debug:l}},function(e,t,n){let o=n(0);e.exports={createDirectory:function(e,t,n){o.ajax({url:"/filesystem/createDirectory",type:"POST",data:{dir:e},done:function(e){t(e)},problem:function(e){n(e)}})},removeDirectory:function(e,t,n){o.ajax({url:"/filesystem/removeDirectory",type:"POST",data:{dir:e},done:function(e){t(e)},problem:function(e){n(e)}})},writeFile:function(e,t,n,r){o.ajax({url:"/filesystem/writeFile",type:"POST",data:{filename:e,content:t},done:function(e){n(e)},problem:function(e){r(e)}})},readFile:function(e,t,n){o.ajax({url:"/filesystem/readFile",type:"POST",data:{filename:e},done:function(e){t(e)},problem:function(e){n(e)}})},removeFile:function(e,t,n){o.ajax({url:"/filesystem/removeFile",type:"POST",data:{filename:e},done:function(e){t(e)},problem:function(e){n(e)}})},readDirectory:function(e,t,n){o.ajax({url:"/filesystem/readDirectory",type:"POST",data:{path:e},done:function(e){t(e)},problem:function(e){n(e)}})}}},function(e,t){e.exports={getToken:function(){return NL_TOKEN}}},function(e,t,n){let o=n(0);e.exports={getSettings:function(e,t){o.ajax({url:"/settings.json",type:"GET",done:function(t){e(t)},problem:function(e){t(e)}})}}},function(e,t,n){let o=n(0);e.exports={runCommand:function(e,t,n){o.ajax({url:"/os/runCommand",type:"POST",data:{command:e},done:function(e){t(e)},problem:function(e){n(e)}})},getEnvar:function(e,t,n){o.ajax({url:"/os/getEnvar",type:"POST",data:{name:e},done:function(e){t(e)},problem:function(e){n(e)}})},dialogOpen:function(e,t,n){o.ajax({url:"/os/dialogOpen",type:"POST",data:{title:e.title,isDirectoryMode:e.isDirectoryMode},done:function(e){t(e)},problem:function(e){n(e)}})},dialogSave:function(e,t,n){o.ajax({url:"/os/dialogSave",type:"POST",data:{title:e},done:function(e){t(e)},problem:function(e){n(e)}})},showNotification:function(e,t,n){o.ajax({url:"/os/showNotification",type:"POST",data:{summary:e.summary,body:e.body},done:function(e){t(e)},problem:function(e){n(e)}})}}},function(e,t,n){let o=n(0);e.exports={getRamUsage:function(e,t){o.ajax({url:"/computer/getRamUsage",type:"GET",done:function(t){e(t)},problem:function(e){t(e)}})}}},function(e,t,n){let o=n(0);e.exports={putData:function(e,t,n){o.ajax({url:"/storage/putData",type:"POST",data:{bucket:e.bucket,content:e.content},done:function(e){t(e)},problem:function(e){n(e)}})},getData:function(e,t,n){o.ajax({url:"/storage/getData",type:"POST",data:{bucket:e},done:function(e){t(JSON.parse(e.content))},problem:function(e){n(e)}})}}},function(e,t,n){let o=n(9),r=n(10);e.exports=function(e){let t=null,n=null;e.load&&e.load(),e.pingSuccessCallback&&(t=e.pingSuccessCallback),e.pingFailCallback&&(n=e.pingFailCallback),"browser"==NL_MODE&&o.start(t,n);for(let e=0;e { 35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 36 | 37 | if (isLocalhost) { 38 | // This is running on localhost. Let's check if a service worker still exists or not. 39 | checkValidServiceWorker(swUrl, config); 40 | 41 | // Add some additional logging to localhost, pointing developers to the 42 | // service worker/PWA documentation. 43 | navigator.serviceWorker.ready.then(() => { 44 | console.log( 45 | "This web app is being served cache-first by a service " + 46 | "worker. To learn more, visit https://bit.ly/CRA-PWA" 47 | ); 48 | }); 49 | } else { 50 | // Is not localhost. Just register service worker 51 | registerValidSW(swUrl, config); 52 | } 53 | }); 54 | } 55 | } 56 | 57 | function registerValidSW(swUrl, config) { 58 | navigator.serviceWorker 59 | .register(swUrl) 60 | .then((registration) => { 61 | registration.onupdatefound = () => { 62 | const installingWorker = registration.installing; 63 | if (installingWorker == null) { 64 | return; 65 | } 66 | installingWorker.onstatechange = () => { 67 | if (installingWorker.state === "installed") { 68 | if (navigator.serviceWorker.controller) { 69 | // At this point, the updated precached content has been fetched, 70 | // but the previous service worker will still serve the older 71 | // content until all client tabs are closed. 72 | console.log( 73 | "New content is available and will be used when all " + 74 | "tabs for this page are closed. See https://bit.ly/CRA-PWA." 75 | ); 76 | 77 | // Execute callback 78 | if (config && config.onUpdate) { 79 | config.onUpdate(registration); 80 | } 81 | } else { 82 | // At this point, everything has been precached. 83 | // It's the perfect time to display a 84 | // "Content is cached for offline use." message. 85 | console.log("Content is cached for offline use."); 86 | 87 | // Execute callback 88 | if (config && config.onSuccess) { 89 | config.onSuccess(registration); 90 | } 91 | } 92 | } 93 | }; 94 | }; 95 | }) 96 | .catch((error) => { 97 | console.error("Error during service worker registration:", error); 98 | }); 99 | } 100 | 101 | function checkValidServiceWorker(swUrl, config) { 102 | // Check if the service worker can be found. If it can't reload the page. 103 | fetch(swUrl, { 104 | headers: { "Service-Worker": "script" }, 105 | }) 106 | .then((response) => { 107 | // Ensure service worker exists, and that we really are getting a JS file. 108 | const contentType = response.headers.get("content-type"); 109 | if ( 110 | response.status === 404 || 111 | (contentType != null && contentType.indexOf("javascript") === -1) 112 | ) { 113 | // No service worker found. Probably a different app. Reload the page. 114 | navigator.serviceWorker.ready.then((registration) => { 115 | registration.unregister().then(() => { 116 | window.location.reload(); 117 | }); 118 | }); 119 | } else { 120 | // Service worker found. Proceed as normal. 121 | registerValidSW(swUrl, config); 122 | } 123 | }) 124 | .catch(() => { 125 | console.log( 126 | "No internet connection found. App is running in offline mode." 127 | ); 128 | }); 129 | } 130 | 131 | export function unregister() { 132 | if ("serviceWorker" in navigator) { 133 | navigator.serviceWorker.ready 134 | .then((registration) => { 135 | registration.unregister(); 136 | }) 137 | .catch((error) => { 138 | console.error(error.message); 139 | }); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /app/assets/app.main.js: -------------------------------------------------------------------------------- 1 | !function(a){function t(t){for(var e,n,r=t[0],o=t[1],c=t[2],u=0,i=[];u