Built Neutralino app cannot open localhost? - javascript

I have a very peculiar issue, I have a Neutralino app built with Preact that runs perfectly fine when run with neu run, however, once I build the project (with enableServer on or off), the built application will not load anything.
With enableServer on, it will complain that it cannot connect to localhost:
"This localhost page cannot be found"
and with it off it gives me a completely white screen/DOM.
The GitHub repository is here: https://github.com/SpikeHD/XeniaLauncher
I suspect it may be the way I am building the project, but I find it weird that neu run works completely fine.
Below is my configuration:
{
"applicationId": "js.xenia_launcher.app",
"version": "1.0.0",
"defaultMode": "window",
"port": 0,
"documentRoot": "/build/",
"url": "/",
"enableServer": true,
"enableNativeAPI": true,
"tokenSecurity": "one-time",
"logging": {
"enabled": true,
"writeToLogFile": true
},
"nativeAllowList": [
"app.*",
"os.*",
"filesystem.*",
"storage.*",
"window.*",
"debug.log"
],
"modes": {
"window": {
"title": "XeniaLauncher",
"width": 1000,
"height": 800,
"minWidth": 400,
"minHeight": 200,
"fullScreen": false,
"alwaysOnTop": false,
"icon": "/resources/icons/appIcon.png",
"enableInspector": true,
"borderless": false,
"maximize": false,
"hidden": false,
"resizable": true,
"exitProcessOnClose": true
},
"browser": {},
"cloud": {
"url": "/resources/#cloud",
"nativeAllowList": [
"app.*"
]
},
"chrome": {
"width": 1000,
"height": 800,
"args": "--user-agent=\"Neutralinojs chrome mode\""
}
},
"cli": {
"binaryName": "XeniaLauncher",
"resourcesPath": "/resources/",
"extensionsPath": "/extensions/",
"clientLibrary": "/resources/js/neutralino.js",
"binaryVersion": "4.4.0",
"clientVersion": "3.3.0"
}
}

Fixed it! I ended up just setting up some scripts that will put all the built Preact code into the resources folder and re-setup my config to only use the resources folder, like the original Neutralino template. I am sure there could have been a more elegant way, but I am still just learning Neutralino and Preact so this works perfectly well enough for me.

It looks like the resourcesPath needs to be set to the directory where your index.html is found. I have a public dir, and moved the icons over there, then set resourcesPath to /public/ and I was able to neu build --release and run.

Related

cypress-cucumber-preprocessor - not logging to messages.json

I've been using Cypress with Cucumber for a while and somehow for some reason, it's stopped logging anything except 'testRunStarted' and 'testRunFinished' to messages.ndjson.
this is my .cypress-cucumber-preprocessorrc.json:
{
"json": {
"enabled": true,
"output": "cypress/cucumber-json/cucumber-json.json",
"formatter": "cucumber-json-formatter"
},
"html": {
"enabled": true,
"output": "cypress/cucumber-html/cucumber-html.html"
},
"messages": {
"enabled": true,
"output": "cypress/messages.ndjson"
},
"nonGlobalStepDefinitions": true,
"stepDefinitions": [
"cypress/e2e/features/*.js",
"cypress/support/step_definitions/**/*.js"
]
}
I have ran cypress with debugging on and confirmed it's picking up the correct config, and it is writing the start and finish to messages, but nothing else.
{"testRunStarted":{"timestamp":{"seconds":1664439067,"nanos":940000000}}}
{"testRunFinished":{"timestamp":{"seconds":1664439137,"nanos":63000000}}}
Absolutely stumped on this one!
I have a question: Where your step definitions are placed? Is it in the same folder where your feature files exists or they are found in support folder? Wherever it present just use that path in your step_definitions in .cypress-cucumber-preprocessorrc.json.
So your .cypress-cucumber-preprocessorrc.json should look like this if your step definitions are in support folder
{
"json": {
"enabled": true,
"output": "cypress/cucumber-json/cucumber-json.json",
"formatter": "cucumber-json-formatter"
},
"html": {
"enabled": true,
"output": "cypress/cucumber-html/cucumber-html.html"
},
"messages": {
"enabled": true,
"output": "cypress/messages.ndjson"
},
"nonGlobalStepDefinitions": true,
"stepDefinitions":
"cypress/support/step_definitions/**/*{.js,.mjs}"
}
Hope you will get your results.
PATH is an environment variable, not your project folder path.
Run the command echo $PATH in order to see a list of paths that are eligible for you to put the cucumber-json-formatter.exe into.
If you don't want to put this file in your path, you can use the json.formatter property in your config to point at this exe file.
Config to point at the formatter:
https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/json-report.md
Where to find the formatter:
https://github.com/cucumber/json-formatter

Expo React Native error: Unhandled JS Exception: manifest must specify logUrl

When publishing my app with expo using expo publish or pushing the app to App Store and Play Store, I get a crash on launch of the production app on both iOS and Android plateform with the error :
Unhandled JS Exception: manifest must specify logUrl
As this error doesn't happened on Development app, I don't know how to debug this. Does anyone encounter the same issue ? Do you have any idea on what's going on or do you have any idea on a method to find the error ?
Just for more context, I did publish my app to both stores months ago without any issue. I did not change anything in my manifest except changing the Expo SDK from version 38 to 40. Here is my current manifest :
{
"expo": {
"name": "My App",
"slug": "myApp",
"privacy": "public",
"platforms": ["ios", "android"],
"version": "1.0.2",
"orientation": "portrait",
"backgroundColor": "#ffffff",
"primaryColor": "#7198FF",
"icon": "./assets/android-icon.png",
"splash": {
"image": "./assets/Launch_Screen.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": false,
"bundleIdentifier": "com.company.app",
"buildNumber": "1"
},
"android": {
"package": "com.company.app",
"googleServicesFile": "./google-services.json",
"permissions": [
"CAMERA",
"MANAGE_DOCUMENTS",
"READ_CONTACTS",
"READ_CALENDAR",
"WRITE_CALENDAR",
"READ_EXTERNAL_STORAGE",
"READ_PHONE_STATE",
"RECORD_AUDIO",
"USE_FINGERPRINT",
"VIBRATE"
],
"versionCode": 21
},
"androidNavigationBar": {
"visible": "sticky-immersive",
"barStyle": "dark-content",
"backgroundColor": "#FFFFFF"
},
"androidStatusBar": {
"hidden": false,
"translucent": true,
"barStyle": "dark-content",
"backgroundColor": "#FFFFFF"
},
"extra": {
"firebase": {
"apiKey": "FIREBASE_KEY",
"authDomain": "app.firebaseapp.com",
"databaseURL": "https://app.firebaseio.com",
"projectId": "app",
"storageBucket": "app.appspot.com",
"messagingSenderId": "SENDER_ID",
"appId": "1:appID",
"measurementId": "G-ID"
}
},
"web": {
"config": {
"firebase": {
"apiKey": "FIREBASE_KEY",
"authDomain": "app.firebaseapp.com",
"databaseURL": "https://app.firebaseio.com",
"projectId": "app",
"storageBucket": "app.appspot.com",
"messagingSenderId": "MESSEGING_ID",
"appId": "1:APP_ID:web:WEB_ID",
"measurementId": "G-ID"
}
}
},
"hooks": {
"postPublish": [
{
"file": "sentry-expo/upload-sourcemaps",
"config": {
"organization": "app",
"project": "app",
"authToken": "SENTRY_TOKEN"
}
}
]
}
}
}
Seems like the issue was with expo trying to put logs to non-existent route on production.
According to expo docs,
the Expo SDK intercepts calls to console.log, console.warn, etc. and posts them to the logUrl specified in the manifest.
Check if you have Logs.enableExpoCliLogging(); enabled? Or if not, try manually importing logs at entry point
import { Logs } from 'expo';
and manually disabling them
Logs.disableExpoCliLogging();
According to the OP comment, the issue was as i mentioned. This stack helped me tho.
After reading #Oleksii comment about checking if the Expo CLI logging where enabled with Logs.enableExpoCliLogging();, it seems that this was causing the issue.
Just disable those by importing import { Logs } from 'expo'; and then calling Logs.disableExpoCliLogging(); in the app entry point file make it works again in production environment !
Thanks again #Oleksii !

How to find loading bottleneck of a slow-loading SAPUI5 app

I'm building a custom SAPUI5 app which consists of a seven diagrams (sap.viz.ui5.controls.VizFrame) in the page's header content (nested inside a sap.suite.ui.commons.ChartContainer) and a grid table (sap.ui.table.Table) in the main content area. The data for the charts and the table is provided by an OData V2 Service and the app is running stand-alone on the latest version (1.81.0).
The problem is the long loading time of the app. It takes between 7 and 20 seconds. Is this common for a "more complex" app? I tried to find the bottleneck but everything looks fine. Many network requests are cached (they take 0ms), however, there is a slight delay in between them and I can't see why. Additionally, there is the following warning in the console, although I'm using the data-sap-async="true" in my index.html file:
[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/. [syncXHRFix-dbg.js:211:15]
Code snippets of my index.html and manifest.json
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loading - Customer Fact Sheet</title>
<script id="sap-ui-bootstrap"
src="resources/sap-ui-core.js"
data-sap-ui-theme="sap_fiori_3"
data-sap-ui-resourceroots='{"com.schott.fiori.customerfactsheet.customerfactsheet-fiori3": "./"}'
data-sap-ui-compatVersion="edge"
data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
data-sap-ui-async="true"
data-sap-ui-frameOptions="trusted">
</script>
<link href="https://www.schott.com/static/assets/gfx/favicon/SCHOTT_16.png" rel="shortcut icon" type="image/png" />
</head>
<body class="sapUiBody">
<div data-sap-ui-component data-name="com.schott.fiori.customerfactsheet.customerfactsheet-fiori3" data-id="container" data-settings='{"id" : "customerfactsheet-fiori3"}'></div>
</body>
</html>
{
"_version": "1.12.0",
"sap.app": {
"id": "com.schott.fiori.customerfactsheet.customerfactsheet-fiori3",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"sourceTemplate": {
"id": "servicecatalog.connectivityComponentForManifest",
"version": "0.0.0"
},
"dataSources": {
"YODATA_SD_CFS_MATRIX_SRV": {
"uri": "/sap/opu/odata/sap/YODATA_SD_CFS_MATRIX_SRV/",
"type": "OData",
"settings": {
"localUri": "localService/metadata.xml"
}
}
}
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "",
"favIcon": "",
"phone": "",
"phone#2": "",
"tablet": "",
"tablet#2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
}
},
"sap.ui5": {
"flexEnabled": false,
"rootView": {
"viewName": "com.schott.fiori.customerfactsheet.customerfactsheet-fiori3.view.Main",
"type": "XML",
"async": true,
"id": "Main"
},
"dependencies": {
"minUI5Version": "1.65.6",
"libs": {
"sap.ui.layout": {},
"sap.ui.core": {},
"sap.m": {}
}
},
"contentDensities": {
"compact": true,
"cozy": false
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "com.schott.fiori.customerfactsheet.customerfactsheet-fiori3.i18n.i18n"
}
},
"": {
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"defaultOperationMode": "Client",
"defaultBindingMode": "OneWay",
"defaultCountMode": "Request"
},
"dataSource": "YODATA_SD_CFS_MATRIX_SRV",
"preload": true
}
},
"resources": {
"css": [{
"uri": "css/style.css"
}]
},
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"async": true,
"viewPath": "com.schott.fiori.customerfactsheet.customerfactsheet-fiori3.view",
"controlAggregation": "pages",
"controlId": "app",
"clearControlAggregation": false
},
"routes": [{
"name": "RouteMain",
"pattern": "RouteMain",
"target": ["TargetMain"]
}],
"targets": {
"TargetMain": {
"viewType": "XML",
"transition": "slide",
"clearControlAggregation": false,
"viewId": "Main",
"viewName": "Main"
}
}
}
},
"sap.platform.hcp": {
"uri": "webapp",
"_version": "1.1.0"
}
}
Screenshots of my network tab
As the Network tab shows, there are many modules loading sequentially one by one and many of them even via sync XHR. The most important task is to reduce sync XHRs as much as possible.
I see in the manifest.json that only a small number of libraries are declared. According to the Network tab, however, the app uses controls from other libs which aren't declared in the dependencies.
So it should be:
"sap.ui5": {
"dependencies": {
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.table": {},
"sap.f": {},
"sap.ui.unified": {},
"sap.ui.layout": {},
"sap.viz": {},
"sap.suite.ui.commons": {}
},
Some libs are required by other libs transitively (e.g. sap.ui.table requires sap.ui.unified).src You may then add "sap.ui.unified": { lazy: true } if that lib is not directly in use.
Preload thirdparty modules asynchronously beforehand that are usually loaded via loadSyncXHR.
If you inspect the Initiator column within the Network tab, you can detect more modules that are loaded via sync XHR. Adding those modules to the data-sap-ui-modules should avoid it:
<script id="sap-ui-bootstrap"
data-sap-ui-modules="sap/ui/thirdparty/datajs,sap/ui/thirdparty/require"
...>
The sap/ui/thirdparty/datajs is required by v2.ODataModel. The sap/ui/thirdparty/require module by the sap.viz library. Both modules are usually fetched via loadSyncXHR. The above snippet fixes it. You might find more such modules.
Overall, the above points should should already improve the initial loading time noticeably. For more performance guidelines, go through the Performance Checklist.
Other things to consider
I18n
In order to reduce the number of requests consider to drop the i18n-support altogether if the app targets only a certain group of people speaking the same language. Multiple requests for
i18n text bundles are not only costly in size but also blocking other requests while loading as they're also loaded via sync XHRs by default. There is a way to load them asynchronously and also specifying which locales the app supports, but that's for another topic.
OData Model
Consider to set the count mode to None if not required since $count calculations tend to be costly in the backend. Also the operation mode Client fetches all entities. Consider to lazy-load them instead.
For all aggregation bindings
"": {
"dataSource": "MyV2Source",
"settings": {
"defaultOperationMode": "Default",
"defaultCountMode": "None",
"defaultBindingMode": "TwoWay",
"preliminaryContext": true
},
"preload": true
},
About preliminaryContext: see Optimizing Dependent Bindings.
For a single aggregation binding
items: { // e.g.
path: '/MySet',
parameters: {
countMode: 'None',
operationMode: 'Client' | 'Default' | 'Server' (see API ref)
}
}
API reference: https://openui5.hana.ondemand.com/api/sap.ui.model.odata.v2.ODataListBinding
UI5 tooling
Before deploying the app, building the app via the following command should reduce the application size drastically:
ui5 build self-contained -a
From https://github.com/SAP/openui5-sample-app#option-2-self-contained-build
This is currently applicable to stand-alone apps only.

node-webkit app package creates nw.js empty screen

I have created the app using node-webkit . But when i click on gte.exe it giving nw.js empty scree.
my JSON file is:
{
"main": "index.html",
"name": "app",
"description": "app",
"version": "0.2.3",
"nodejs": true,
"window": {
"title": "app",
"icon": "favicon.ico",
"toolbar": false,
"frame": true,
"width": 1200,
"height": 768,
"min_width": 1024,
"min_height": 768,
"resizable": true
},
"webkit" :{
"plugin":true
},
"chromium-args": "--disable-web-security --experimental-location-features --enable-geolocation --allow-file-access-from-files --allow-file-access --enable-device-policy"
}
I changed my folder into zip and changed to .nw extension. After that i ran D:\nw>copy /b nw.exe+app.nw gte.exe .
Please any one help me out

Include JS file after Ext in Sencha CMD

I have a Sencha Touch 2 application (non MVC), it works well, except for one JS file. In there I define a store.
In app.json I included sencha-touch.js and this file also. It is building properly, but when I open the page it is saying that
Object has no method 'create'
My app.json:
{
"path": "touch/sencha-touch.js",
"x-bootstrap": true
},
{
"path": "res/mystore.js"
},
{
"path": "bootstrap.js",
"x-bootstrap": true
},
{
"path": "app.js",
"bundle": true, /* Indicates that all class dependencies are concatenated into this file when build */
"update": "delta"
}
I tried many things, but nothing seems to be working, change the sequence, x-bootstrap to true for mystore.js, but nothing. Any idea?
Thanks in advance!
It seems like the problem was the order. After I changed like this:
{
"path": "touch/sencha-touch.js",
"x-bootstrap": true
},
{
"path": "bootstrap.js",
"x-bootstrap": true
},
{
"path": "app.js",
"bundle": true, /* Indicates that all class dependencies are concatenated into this file when build */
"update": "delta"
},
{
"path": "res/mystore.js"
}
it works perfectly.

Categories