I am trying to package an electron app (that uses wasm) with electron-forge.
At the moment (while I fight packaging!) it's little more than a hello-world, but it compiles a simple rust lib to wasm, then I copy the .js and .wasm files into ./src/ and package as an electron app.
Running it using "electron-forge start" works perfectly, but when I package it with "electon-forge make" (to a DMG on Mac OS in this case) and then install and run it, it seems to be trying to load the wrong .wasm file (or it's been modified...) as I get these errors:
There is only one .wasm file bundled, and I have checked the .js that it has the reference to the correct file.
If I go into the .app package in /Applications and navigate to the packaged source files all is correct, and the same as my source folders.
Checking the magic number of the .wasm file also seems fine..
hexdump ui-72b0082cbbe1a2b5.wasm |head -n 1
0000000 00 61 73 6d 01 00 00 00 01 86 01 13 60 02 7f 7f
So, I don't know what file it's trying to load as .wasm and why the magic number is not correct.
Any ideas?
Not sure if you still have this problem, but this was stumping me for a while, so I figured I'd leave the answer for the next person. Short answer, you need to add a small bit to your json config file. Example:
Default config:
...
"config": {
"forge": {
"packagerConfig": { },
...
Fixed config:
...
"config": {
"forge": {
"packagerConfig": { "asar.unpack" : "yourFileHere.js" },
...
Best I can tell, the problem is coming from electron-packager and how it compresses everything into that asar file. It seems to try and serve the compressed file, so the MIME type is wrong. But even when I changed the web assembly loading code to use WebAssembly.instantiate instead of WebAssembly.instantiateStreaming (that avoids the MIME check), I was still left with those magic number issues...that was the clue that compression was the issue.
You can do directories also, info here about other packager options
https://github.com/electron/electron-packager/blob/master/docs/api.md#asar
Related
After following the official workflow for translating files I find myself in a situation where the translation doesn't seem to work.
make gettext
sphinx-intl update -p /source/_build/gettext -l fr
set SPHINXOPTS=-D language=fr
make html
I have successfully created *.pot and *.po files and testwise translated parts of this *.po-file (other msgid's still default to "". Then I set the language to french and run make html again - but the text that I translated isn't displayed in french.
Nothing in the build output shows any hint on what's wrong:
C:\dev\ritune\docs>make html
Sphinx v4.1.2 in Verwendung
Lade Übersetzungen [fr]…erledigt
making output directory... erledigt
[autosummary] generating autosummary for: .roles.rst, configuration\add_modules\add_modules.rst, configuration\db_dump\db_dump.rst, configuration\index.rst, configuration\modules\config_dashboard\config_dashboard.rst, configuration\modules\index.rst, configuration\plotly_diagrams\plotly_diagrams.rst, data_explorer\data_explorer.rst, functions\asset_management\asset_management.rst, functions\dashboard\dashboard.rst, ..., system\index.rst, system\logs\logs.rst, system\main_menu\main_menu.rst, system\physical\physical.rst, system\proc\proc.rst, system\settings\settings.rst, system\tags\tags.rst, system\user_profile\user_profile.rst, system\users_roles\users_roles.rst, system\versions\versions.rst
loading intersphinx inventory from https://docs.python.org/3/objects.inv...
loading intersphinx inventory from https://www.sphinx-doc.org/en/master/objects.inv...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 81 source files that are out of date
updating environment: [new config] 81 added, 0 changed, 0 removed
reading sources... [100%] system/versions/versions or2ntrol
looking for now-outdated files... none found
pickling environment... erledigt
checking consistency... preparing documents... erledigt
writing output... [100%] system/versions/versions r2ntrol
generating indices... genindex erledigt
writing additional pages... search erledigt
copying images... [100%] system/versions/version_numbering.svg 1fcb54c2ee.png
copying downloadable files... [ 57%] modules/reporting_masks/Betriebsstatistik_Vorlage_20210514.xlsx_Betriebsstatistik_Vorlage_20210514.xlscopying downloadable files... [100%] system/alarms/ANSI-ISA-18.2 - Management of Alarm Systems for the Process Industries.PDF
copying static files... erledigt
copying extra files... erledigt
dumping search index in French (code: fr)... erledigt
dumping object inventory... erledigt
build abgeschlossen, 13 warnings.
Note that I excluded warnings that have to do with silly syntax mistakes I made in one of the files (the one I'm currently working on).
Is this expected behaviour or am I doing something wrong? I wanted to test the translation functionality and my *.po files.
I found the solution. Sphinx didn't actually pick up on the .mo (binary) files.
Steps to retrace for correct working:
Make sure you're in root directory and you see build and source directories
Using sphinx gettext will create *.pot files in build/gettext
Take those *.pot files and translate to *.po files using sphinx-intl update -p build/gettext -l fr (example for french/'fr'). This will create *.po files in a new folder locales which by default sits amongst the build and source dirs under root.
Translate *.po files
Now make sure that locale_dirs = ['../locales'] in conf.py points to the directory of the locales! This was not set up properly by default in my case. I had to change dir to parent ( ../ ) and use "locales" instead of the default "locale" to describe the path.
Run sphinx-intl build to create binaries (*.mo) out of *.mo files.
Set language to french for current terminal: set SPHINXOPTS=-D language=fr
make html
I run docker php-alpine and exec codeception tests. But it's shows only small part of all tests. After long debugging i find problem: Symfony\Component\Finder not see all files only in 1 directory. IDK why. All files are *.php
count(Finder::create()->in($path)) - 9/61 files
count(scandir($path)) - 63: 63 - 2 (['.','..']) = 61 files
In others directories it's work normaly
I have written a very simple app in Flutter, for both iOS, Android and the web.
Lately, I realized that if I browse the "storage" settings page on my iPhone, my prod app, as it is distributed on the App Store, weighs about 500 MB. Most of it comes from the "documents and data" part, the app itself isn't huge:
Storage page
This is unexpected as the only thing I am storing on purpose is a small sqlite database, which in my case is about 30 KB.
Following this guide from the Apple support page, I was able to download my app's container, which is indeed about 500 MB. It turns out most of the weight comes from inside of a tmp folder, as shown by the output of du -sh AppData/tmp/*:
0B AppData/tmp/count0fSKCX
0B AppData/tmp/count1N2yFY
32K AppData/tmp/count1tKqnr
0B AppData/tmp/count2BxlSk
24K AppData/tmp/count2VKOVX
0B AppData/tmp/count2tnzwn
[...]
0B AppData/tmp/count8kl1hK
53M AppData/tmp/count8kqOke
0B AppData/tmp/count8ssdC7
[...]
0B AppData/tmp/countZHwkA9
26M AppData/tmp/countZHx1v8
53M AppData/tmp/countZKP9JU
0B AppData/tmp/counta5fYmx
[...]
If I take a look at what's inside of one of those huge 50+ MB folders, here is what takes so much space:
du -sh AppData/tmp/countZKP9JU/count/*
26M AppData/tmp/countZKP9JU/count/main.dart.dill
20K AppData/tmp/countZKP9JU/count/main.dart.incremental.dill
26M AppData/tmp/countZKP9JU/count/main.dart.swap.dill
I failed to find useful documentation about those files, as I am not sure what to look for: is the problem in my Dart config, in my Flutter config, in my App config, ...? Can you guys please enlighten me?
Edit: Here is some version info that might be useful
Flutter 2.5.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ffb2ecea52 (5 weeks ago) • 2021-09-17 15:26:33 -0400
Engine • revision b3af521a05
Tools • Dart 2.14.2
iOS version: 15.0.2
In case someone runs into the same issue, I ended up writing my own cleanup logic on startup, calling getApplicationDocumentsDirectory().parent.list() and then deleting the tmp child folder if it exists.
I don't know if this is necessary at all in the end, as this tmp folder growing infinitely might only happen because of the development builds I keep installing on my phone. But this cleanup step probably won't hurt anyway.
Edit: Here is the code. Feel free to improve it, I think it probably logs an exception on other platforms (but it doesn't crash):
import 'package:path_provider/path_provider.dart';
[...]
#override
void initState() {
_cleanUpTemporaryDirectory();
super.initState();
}
[...]
_cleanUpTemporaryDirectory() async {
final documentsDirectory = await getApplicationDocumentsDirectory();
documentsDirectory.parent.list().forEach((child) async {
if (child is Directory && child.path.endsWith('/tmp')) {
print('Deleting temp folder at ${child.path}...');
try {
await child.delete(recursive: true);
print('Temp folder was deleted with success');
} catch (error) {
print('Temp folder could not be deleted: $error');
}
}
});
}
What is the best strategy to deploy a Dart Web-ui app manually ?
pub deploy doesn't work for me and I have raised bug report. So am thinking what is the best way to manually deploy.
This is how I started:
1) From project root I compile the webui components (dwc.dart)
2) change directory to web/out then run dart2js
3) copy all .js files into that scripts/js public folder on server
4) copy appname.html to server changing css and script paths to option 3
5) Make sure dart.js is also in the same directory as item 3
this is as far as I got. So what else do I need to do ?
A few questions:
1) Do I manually change the file paths in the generated .js files to point to public folders on server for the files they are referencing and make sure those files are on server also ?
2) Do I need to copy all packages to server also ?
3) Any preferred file structure on server?
Any tips on this really appreciated.
Thanks.
I wrote a Grunt script for it (since I had no time to look up how to properly write code for Grunt, I did not share the code since it's a mess) but I basically do this:
compiling a list of files with dwc to a given out dir
compile it to javascript
clean up all non-deployable files
change some paths inside the HTML to match the server paths (for some reasons, this gets changed by the compilation process)
remove all packages except the ones I really need (JS interopt and browser)
Since I'm only using the JS version, I remove all dart packages. Since the paths inside the HTML files are up to you, you can already use a structure that suits you/your server.
I can provide you with a Grunt script to understand the order of tasks. Practically the order I use is this one:
Create the build directory. I usually use /build/web. I usually create these files (index.html, main.dart, /css and so on into the /web dir). I create the rest of components into /lib directory.
Compile the .dart file that contains the main() function ("main.dart" in my case for simpler projects) file to Javascript and put it into /build/web directory
Copy the other needed files and folders to the /build/web directory. Also, during this process you'll be copying the packages that your project needs. You'll see in the example provided below.
Remove all empty folders from the project
You can create a Grunt task to open the /index.html file in the browser once the building process has ended (I will not provide this example)
The structure of the dart test project:
testApp
- gruntfile.js
- package.js
/lib
/packages
/angular
/web
- index.html
- main.dart
/css
/img
So, the Grunt example script to cover steps from 1 - 4 looks like this (copy it to gruntfile.js):
module.exports = function (grunt) {
grunt.initConfig({
// 1.
// create build web directory
mkdir: {
build: {
options: {
create: ['build/web']
}
}
},
// 2.
// compile dart files
dart2js: {
options: {
// use this to fix a problem into dart2js node module. The module calls dart2js not dart2js.bat.
// this is needed for Windows. So use the path to your dart2js.bat file
"dart2js_bin": "C:/dart/dart-sdk/bin/dart2js.bat"
},
compile: {
files: {'build/web/main.dart.js': 'web/main.dart'}
}
},
// 3.
// copy all needed files, including all needed packages
// except the .dart files.
copy: {
build: {
files: [
{
expand: true,
src: [
'web/!(*.dart)',
'web/css/*.css',
'web/res/*.svg',
'web/packages/angular/**/!(*.dart)',
'web/packages/browser/**/!(*.dart)'
],
dest: 'build'
}
]
}
},
// 4.
// remove empty directories copied using the previous task
cleanempty: {
build: {
options: {
files: false
},
src: ['build/web/packages/**/*']
}
},
});
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.registerTask('default', [
'mkdir:build',
'dart2js',
'copy:build',
'cleanempty:build'
]);
};
So this is the Grunt script example.
Create a /gruntfile.js file into your project's root directory and copy/paste the script to it.
Create a /package.json file into your project's root directory and copy/paste the following script:
{
"name": "testApp",
"version": "0.0.1",
"description": "SomeDescriptionForTheTestApp",
"main": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "YourName",
"peerDependencies": {
"grunt-cli": "^0.1.13"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-cleanempty": "^1.0.3",
"grunt-contrib-copy": "^0.7.0",
"grunt-dart2js": "0.0.5",
"grunt-mkdir": "^0.1.2",
"matchdep": "^0.3.0"
}
}
Open Command Prompt in Windows, Terminal in Linux, navigate to your project's root directory and use this command:
npm install
Wait untill all Grunt modules needed will be downloaded to your local project. Once this is finished, issue this command in Command Prompt or Terminal:
node -e "require('grunt').cli()"
You can use this to initiate Grunt default task without having Grunt installed globally on your system.
Now, to know the exact build structure for your project (including the packages that the project needs), make a build using Pub Build. Then you will be able to instruct Grunt to create the same dir structure.
You can add other tasks (like minification) if you want.
Hope this will help you all to understand the process and get you started with a test app first. Add your comments to make this even better and simplify it even more.
I am trying to use emacs for grails development. Tried on grails-emacs-mode
There are emacs and emacs23 on my ubuntu 12.04.
prayag#prayag:~$ ls -l /usr/share/emacs[tab][tab]
emacs/ emacs23/
As the grails-emacs-mode suggests, I copied grails-mode.el and primary.org files to my emacs23/site-list
prayag#prayag:~$ ls -l /usr/share/emacs23/site-lisp/
total 32
-rw-r--r-- 1 root root 3013 Nov 17 00:39 debian-startup.elc
drwxr-xr-x 2 root root 4096 Nov 17 00:39 dictionaries-common
-rw-r--r-- 1 root root 18205 Feb 14 01:11 grails-mode.el
-rw-r--r-- 1 root root 0 Feb 14 01:11 primary.org
-rw-r--r-- 1 root root 106 Sep 22 01:16 subdirs.el
Then, created init.el inside .emacs.d as there exists no .emacs file in home directory. The init.el conatains
(require 'grails-mode)
(setq grails-mode t)
(setq project-mode t)
(add-to-list 'auto-mode-alist '("\.gsp$" . nxml-mode)) ; Use whatever mode you want for views.
(project-load-all) ; Loads all saved projects. Recommended, but not required.
now, opening emacs23 doesn't show any grails in the menubar.
I also tried
M-x
load-file .emacs.d/init.el
which throws
Warning (initialization): An error occurred while loading `/home/prayag/.emacs.d/init.el':
File error: Cannot open load file, project-mode
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
On starting emacs23 --debug-init, following error is thrown.
Debugger entered--Lisp error: (file-error "Cannot open load file" "project-mode")
require(project-mode)
eval-buffer(#<buffer *load*<2>> nil "/usr/share/emacs/23.3/site-lisp/grails-mode.el" nil t) ; Reading at buffer position 422
load-with-code-conversion("/usr/share/emacs/23.3/site-lisp/grails-mode.el" "/usr/share/emacs/23.3/site-lisp/grails-mode.el" nil t)
require(grails-mode)
eval-buffer(#<buffer *load*> nil "/home/prayag/.emacs.d/init.el" nil t) ; Reading at buffer position 23
load-with-code-conversion("/home/prayag/.emacs.d/init.el" "/home/prayag/.emacs.d/init.el" t t)
load("/home/prayag/.emacs.d/init" t t)
#[nil "\205\264
grails-mode requires project-mode as mentioned on the emacs-grails-mode page. So, you'll also need to install project-mode.
Also grab the remaining groovy packages(all but grails-mode) from here.
emacs-grails-mode-ext is a modest contribution to grails-mode allowing you to run Grails commands directly from emacs. For a given project(project-mode), you can run Grails commands such as create-domain-class, create-service, etc.
I also use the function ido-find-file-in-tag-files from here, I bind it to C-x C-M-f .
Simple guide with emacs-grails-mode:
Create a project from the command line or eshell -> grails create-app yourapp
Using dired, go to your Grails project folder
M-x project-new -> to create a new project(project-mode)
M-x project-save -> Save the project
M-x project-load-and-select -> Your project-name as argument
There's also a Grails menu if you use the menubar
You could also use my current emacs setup here, if you have emacs24 installed. I believe that it's available for Ubuntu 12.04, but I'm not sure. I usually build emacs from source on OSX or I use emacs-snapshot in Ubuntu.
Hope this helps.
I don't know Grail-mode at all. I've just clicked your link, and they state that project-mode is a dependency:
Dependencies:
project-mode is the only dependency.
As a consequence you will also have to install it. Link to the Emacs project code.
I am hoping for you this project does not have additional dependencies...
As a side note: later, try to install the last emacs (v24) which embeds a very convenient way to deal with package installation and dealing with packages dependencies. I've just check it out, it is present on an alternative (but very know) repository: Marmalade-repo.org.