Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/modules/frontendlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module.exports.containsFrontendLibApp = () => {
module.exports.waitForFrontendLibApp = async () => {
let configObj = config.get();
let devUrlString = configObj.cli && configObj.cli.frontendLibrary ? configObj.cli.frontendLibrary.devUrl : undefined;
let timeout = configObj.cli && configObj.cli.frontendLibrary && configObj.cli.frontendLibrary.waitTimeout | 20000;
let timeout = configObj.cli && configObj.cli.frontendLibrary && configObj.cli.frontendLibrary.waitTimeout || 20000;
let url = new URL(devUrlString);
let portString = url.port;
let port = portString ? Number.parseInt(portString) : getPortByProtocol(url.protocol)
Expand Down
12 changes: 12 additions & 0 deletions testApp/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: shalithasuranga
patreon: shalithasuranga
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 changes: 13 additions & 0 deletions testApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Developer tools' files
.lite_workspace.lua

# Neutralinojs binaries and builds
/bin
/dist

# Neutralinojs client (minified)
neutralino.js

# Neutralinojs related files
.storage
*.log
1 change: 1 addition & 0 deletions testApp/.tmp/window_state.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"height":500,"maxHeight":-1,"maxWidth":-1,"maximize":false,"minHeight":200,"minWidth":400,"resizable":true,"width":800,"x":569,"y":129}
21 changes: 21 additions & 0 deletions testApp/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Neutralinojs and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions testApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# neutralinojs-minimal

The default template for a Neutralinojs app. It's possible to use your favorite frontend framework by using [these steps](https://neutralino.js.org/docs/getting-started/using-frontend-libraries).

## Contributors

[![Contributors](https://contrib.rocks/image?repo=neutralinojs/neutralinojs-minimal)](https://github.com/neutralinojs/neutralinojs-minimal/graphs/contributors)

## License

[MIT](LICENSE)

## Icon credits

- `trayIcon.png` - Made by [Freepik](https://www.freepik.com) and downloaded from [Flaticon](https://www.flaticon.com)
83 changes: 83 additions & 0 deletions testApp/neutralino.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"$schema": "https://raw.githubusercontent.com/neutralinojs/neutralinojs/main/schemas/neutralino.config.schema.json",
"applicationId": "js.neutralino.sample",
"version": "1.0.0",
"defaultMode": "window",
"port": 0,
"documentRoot": "/resources/",
"url": "/",
"enableServer": true,
"enableNativeAPI": true,
"tokenSecurity": "one-time",
"logging": {
"enabled": true,
"writeToLogFile": true
},
"nativeAllowList": [
"app.*",
"os.*",
"debug.log"
],
"globalVariables": {
"TEST1": "Hello",
"TEST2": [
2,
4,
5
],
"TEST3": {
"value1": 10,
"value2": {}
}
},
"modes": {
"window": {
"title": "testApp",
"width": 800,
"height": 500,
"minWidth": 400,
"minHeight": 200,
"center": true,
"fullScreen": false,
"alwaysOnTop": false,
"icon": "/resources/icons/appIcon.png",
"enableInspector": true,
"borderless": false,
"maximize": false,
"hidden": false,
"resizable": true,
"exitProcessOnClose": false
},
"browser": {
"globalVariables": {
"TEST": "Test value browser"
},
"nativeBlockList": [
"filesystem.*"
]
},
"cloud": {
"url": "/resources/#cloud",
"nativeAllowList": [
"app.*"
]
},
"chrome": {
"width": 800,
"height": 500,
"args": "--user-agent=\"Neutralinojs chrome mode\"",
"nativeBlockList": [
"filesystem.*",
"os.*"
]
}
},
"cli": {
"binaryName": "testApp",
"resourcesPath": "/resources/",
"extensionsPath": "/extensions/",
"clientLibrary": "/resources/js/neutralino.js",
"binaryVersion": "6.5.0",
"clientVersion": "6.5.0"
}
}
1 change: 1 addition & 0 deletions testApp/neutralinojs-cli
Submodule neutralinojs-cli added at d34fb1
Binary file added testApp/resources/icons/appIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testApp/resources/icons/logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testApp/resources/icons/trayIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions testApp/resources/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>NeutralinoJs sample app</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<div id="neutralinoapp">
<h1>NeutralinoJs</h1>
<div id="info"></div>
<br/>
<img src="/icons/logo.gif" alt="Neutralinojs" />
<div>
<a href="#" onclick="openDocs();">Docs</a> &middot;
<a href="#" onclick="openTutorial();">Video tutorial</a>
</div>
</div>
<!-- Neutralino.js client. This file is gitignored,
because `neu update` typically downloads it.
Avoid copy-pasting it.
-->
<script src="/js/neutralino.js"></script>
<!-- Your app's source files -->
<script src="/js/main.js"></script>
</body>
</html>
99 changes: 99 additions & 0 deletions testApp/resources/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// This is just a sample app. You can structure your Neutralinojs app code as you wish.
// This example app is written with vanilla JavaScript and HTML.
// Feel free to use any frontend framework you like :)
// See more details: https://neutralino.js.org/docs/how-to/use-a-frontend-library

/*
Function to display information about the Neutralino app.
This function updates the content of the 'info' element in the HTML
with details regarding the running Neutralino application, including
its ID, port, operating system, and version information.
*/
function showInfo() {
document.getElementById('info').innerHTML = `
${NL_APPID} is running on port ${NL_PORT} inside ${NL_OS}
<br/><br/>
<span>server: v${NL_VERSION} . client: v${NL_CVERSION}</span>
`;
}

/*
Function to open the official Neutralino documentation in the default web browser.
*/
function openDocs() {
Neutralino.os.open("https://neutralino.js.org/docs");
}

/*
Function to open a tutorial video on Neutralino's official YouTube channel in the default web browser.
*/
function openTutorial() {
Neutralino.os.open("https://www.youtube.com/c/CodeZri");
}

/*
Function to set up a system tray menu with options specific to the window mode.
This function checks if the application is running in window mode, and if so,
it defines the tray menu items and sets up the tray accordingly.
*/
function setTray() {
// Tray menu is only available in window mode
if(NL_MODE != "window") {
console.log("INFO: Tray menu is only available in the window mode.");
return;
}

// Define tray menu items
let tray = {
icon: "/resources/icons/trayIcon.png",
menuItems: [
{id: "VERSION", text: "Get version"},
{id: "SEP", text: "-"},
{id: "QUIT", text: "Quit"}
]
};

// Set the tray menu
Neutralino.os.setTray(tray);
}

/*
Function to handle click events on the tray menu items.
This function performs different actions based on the clicked item's ID,
such as displaying version information or exiting the application.
*/
function onTrayMenuItemClicked(event) {
switch(event.detail.id) {
case "VERSION":
// Display version information
Neutralino.os.showMessageBox("Version information",
`Neutralinojs server: v${NL_VERSION} | Neutralinojs client: v${NL_CVERSION}`);
break;
case "QUIT":
// Exit the application
Neutralino.app.exit();
break;
}
}

/*
Function to handle the window close event by gracefully exiting the Neutralino application.
*/
function onWindowClose() {
Neutralino.app.exit();
}

// Initialize Neutralino
Neutralino.init();

// Register event listeners
Neutralino.events.on("trayMenuItemClicked", onTrayMenuItemClicked);
Neutralino.events.on("windowClose", onWindowClose);

// Conditional initialization: Set up system tray if not running on macOS
if(NL_OS != "Darwin") { // TODO: Fix https://github.com/neutralinojs/neutralinojs/issues/615
setTray();
}

// Display app information
showInfo();
Loading