You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be awesome to get packaging support with embedding resourses to executable file
Discussed a lot here: nwjs/nw.js#151 don't get confused with issue title btw
I'm not very positive on adding it, since anyway you would have to ship DLLs and resources files along with the exe file, and it won't prevent users unzip and change your source code.
How about unzipping the .exe file to a temporary directory and then load the real app from it in the main.js, which is exactly what node-webkit does? The main.js is still visible to users though.
This might have problems with clean-up if main process crashes or closes in a way that makes clean-up hard or impossible. There is possible to workaround this, but it still not optimal IMO.
What are main problems with embedding resources in executable and accessing them with a pseudo-protocol like app://index.html ? This need some kind of internal routing though(for relative paths in css for example), but seems more reliable and probably faster (since you don't have to unpack resources).
Embedding resources into executable is only possible on Windows, to make it cross-platform we have to compress resources into zip and concatenate it to the executable, and then unzip them from the executable latter.
However packaging the resources into an external file and then use custom protocol to access the resources would possible, it also seems like a proper solution for app packaging to me.
When you saying " then unzip them from the executable latter", what will be destination of unzipping? If it is some temp folder, this is not far better then node-webkit approach.
Is it possible to concatenate resources without compressing so you don't have to unpack them anywhere?
If it is some temp folder, this is not far better then node-webkit approach.
The destination of unzipping is some temporary directory, and this is exactly the node-webkit approach, it is just in node-webkit the package system is implemented with C++ and the progress of unzipping is hidden from users.
Is it possible to concatenate resources without compressing so you don't have to unpack them anywhere?
In theory, yes, but with lots of efforts. And concatenating all resources to executable would make things slower because operating system need to read the whole executable into memory.
Support packaging resources into an external file is what I plan to implement, if what you want is to hide source code from users and read resources without unpacking, it should be enough.
If I understood you correctly, there will be executable, and resource container, so when app starts, it will look for resources there, right? no packing/unpacking?
I think the .pak file is fine imho, just don't forget to emit app.on("unpacking") so that we can have the ability to show something while it is doing so.
or is the hierarchy of the app events like this?
-> will-finish-launching
-> ready
I was trying to say that packing in terms off splitting runtime and resources is fine (e.g. external file with resources). Problem with packing is in terms of compressing (zip files, archives of any type). This is problematic because it requires some temporary directory to unpack to, and clean-up after app closes.
If that would be the case in future, events should not be changed I think, because there is no additional unpacking phase.
@reggi: the average person can't look into these files (don't confuse this with security of any kind) and it can speed up installation (because you have a lot less files). Also there are plans for an atom-shell-runtime and this would (edit: probably) be the app-format of choice.
@bwin Is there any way to hide my source code? I have a package.json with a github token in it that points to a private libs repo for my app, something like this. I'd have to remove stuff this before the app gets released publicly and thats a bummer.
First thing I can think of right now, would be a grunt (or gulp or whatever) task, that replaces this line before release. (You would have to make a copy of your working dir for releases to not overwrite your "original" package.json; I would anyway suggest a release-dir).
About encryption: since the encrypted file has to be decrypted on the user's machine, the key/password would also have to be on the users machine. So having this info even in an encrypted state would still be dangerous. So maybe stripping this info beforehand is the better solution.
(Also your "secret" file could end up in the users temp dir ...)
(edit: Also IMO this auth info doesn't belong on a users machine. Encrypted or not. You're never npm installing on a user's machine anyway.)
Edit: I'm not sure (never had private lib dependencies), but wouldn't ssh access to github with a key also solve your problem? (But maybe you just don't want that.)
and it can speed up installation (because you have a lot less files)
On WIndows this is most likely a huge benefit, file operations on Windows are much slower than on Linux (because Windows supports way more features); writing 10000 1KB files is going to be orders of magnitude slower than writing one 10MB file, even though it's the same amount of data.
Doing a ton of file reads to load a large JS app is also a performance killer. One of our startup time speedup strategies in Atom involves concatting files for this reason.
I'd love to get on a call about this as it is a different format than my archive loader and we can discuss things. Particularly I have concerns with implementing a fake fs module that is not fully featured/compatible.
I can be awake during Asia's daylight hours if that helps.
It is already mentioned that it is enough to prevent just average person messing with code. it is just handy, and you should not rely on that for security. 100% agree with you here.
When somebody says asar gives performance increase, I think they refer to faster reads for large number of files, not faster read of one big resource. Though, I'm not I got it right. /cc @zcbenz
As docs states, asar archives are indeed read-only, so yeah, for auto-update you have to re-create them yourself.
not sure what you mean.
I mostly agree with you, asar could be better, but hey, we need to start somewhere.
Possibly related: #673
3 Looking at asar archive structure, I think yes, you need files to be on disk at archive creation time, so yes, if you want to convert github release .zip into .asar, you need to do it manually, which, I agree, is not great.
I am also thinking if monkey-patching node's fs module for transparent .asar support was a good idea, isn't it better to have separate asar-fs module to deal with asar-related tasks? It can be smaller and easier to maintain, and add features incrementally. ATM fs module can be treated as asar-fs (with known limitations), and node's fs is original-fs. Maybe it is just me, but it seems weird.
Except that ZIP does support all the above, is extremely efficient for random access, does have symlinks, custom attrs, and zillions of tools that support that. I use it all the time for the exact use case you're describing including having it utilize a binary search to locate files, directories etc with NO requirement to pre-sort on load. ZIP can be located any position within a binary (front, middle, back). That, and sqlite together are components of EFS supporting versioning, replication, and single binary deployment.
Activity
zcbenz commentedon May 7, 2014
I'm not very positive on adding it, since anyway you would have to ship DLLs and resources files along with the exe file, and it won't prevent users unzip and change your source code.
YurySolovyov commentedon May 7, 2014
At least it would be harder, for many people it's enough to just give up.
So, current packagin will stay the same? I mean is there a plans for improving it or adding features?
P.s. Personally, I'm ok with not embedding .dlls, main requerst is to embed resources and source code.
zcbenz commentedon May 7, 2014
How about unzipping the
.exefile to a temporary directory and then load the real app from it in themain.js, which is exactly what node-webkit does? Themain.jsis still visible to users though.YurySolovyov commentedon May 7, 2014
This might have problems with clean-up if main process crashes or closes in a way that makes clean-up hard or impossible. There is possible to workaround this, but it still not optimal IMO.
What are main problems with embedding resources in executable and accessing them with a pseudo-protocol like app://index.html ? This need some kind of internal routing though(for relative paths in css for example), but seems more reliable and probably faster (since you don't have to unpack resources).
zcbenz commentedon May 8, 2014
Embedding resources into executable is only possible on Windows, to make it cross-platform we have to compress resources into zip and concatenate it to the executable, and then unzip them from the executable latter.
However packaging the resources into an external file and then use custom protocol to access the resources would possible, it also seems like a proper solution for app packaging to me.
YurySolovyov commentedon May 8, 2014
When you saying " then unzip them from the executable latter", what will be destination of unzipping? If it is some temp folder, this is not far better then node-webkit approach.
Is it possible to concatenate resources without compressing so you don't have to unpack them anywhere?
zcbenz commentedon May 8, 2014
The destination of unzipping is some temporary directory, and this is exactly the node-webkit approach, it is just in node-webkit the package system is implemented with C++ and the progress of unzipping is hidden from users.
In theory, yes, but with lots of efforts. And concatenating all resources to executable would make things slower because operating system need to read the whole executable into memory.
Support packaging resources into an external file is what I plan to implement, if what you want is to hide source code from users and read resources without unpacking, it should be enough.
YurySolovyov commentedon May 8, 2014
Ok, thanks, better than nothing.
YurySolovyov commentedon May 8, 2014
If I understood you correctly, there will be executable, and resource container, so when app starts, it will look for resources there, right? no packing/unpacking?
zcbenz commentedon May 9, 2014
Almost yes, except that developers still need to pack the resources into one file.
kevyworks commentedon May 18, 2014
I think the
.pakfile is fine imho, just don't forget to emitapp.on("unpacking")so that we can have the ability to show something while it is doing so.or is the hierarchy of the app events like this?
-> will-finish-launching
-> ready
YurySolovyov commentedon May 18, 2014
I was trying to say that packing in terms off splitting runtime and resources is fine (e.g. external file with resources). Problem with packing is in terms of compressing (zip files, archives of any type). This is problematic because it requires some temporary directory to unpack to, and clean-up after app closes.
If that would be the case in future, events should not be changed I think, because there is no additional unpacking phase.
16 remaining items
bwin commentedon Jan 30, 2015
@reggi: the average person can't look into these files (don't confuse this with security of any kind) and it can speed up installation (because you have a lot less files). Also there are plans for an atom-shell-runtime and this would (edit: probably) be the app-format of choice.
reggi commentedon Jan 30, 2015
@bwin Is there any way to hide my source code? I have a
package.jsonwith a github token in it that points to a private libs repo for my app, something like this. I'd have to remove stuff this before the app gets released publicly and thats a bummer.bwin commentedon Jan 30, 2015
First thing I can think of right now, would be a grunt (or gulp or whatever) task, that replaces this line before release. (You would have to make a copy of your working dir for releases to not overwrite your "original" package.json; I would anyway suggest a release-dir).
About encryption: since the encrypted file has to be decrypted on the user's machine, the key/password would also have to be on the users machine. So having this info even in an encrypted state would still be dangerous. So maybe stripping this info beforehand is the better solution.
(Also your "secret" file could end up in the users temp dir ...)
(edit: Also IMO this auth info doesn't belong on a users machine. Encrypted or not. You're never
npm installing on a user's machine anyway.)Edit: I'm not sure (never had private lib dependencies), but wouldn't ssh access to github with a key also solve your problem? (But maybe you just don't want that.)
anaisbetts commentedon Jan 30, 2015
On WIndows this is most likely a huge benefit, file operations on Windows are much slower than on Linux (because Windows supports way more features); writing 10000 1KB files is going to be orders of magnitude slower than writing one 10MB file, even though it's the same amount of data.
thedaniel commentedon Jan 30, 2015
Doing a ton of file reads to load a large JS app is also a performance killer. One of our startup time speedup strategies in Atom involves concatting files for this reason.
bmeck commentedon Jan 30, 2015
I'd love to get on a call about this as it is a different format than my archive loader and we can discuss things. Particularly I have concerns with implementing a fake
fsmodule that is not fully featured/compatible.I can be awake during Asia's daylight hours if that helps.
YurySolovyov commentedon Feb 23, 2015
I mostly agree with you, asar could be better, but hey, we need to start somewhere.
Possibly related: #673
YurySolovyov commentedon Feb 23, 2015
3 Looking at asar archive structure, I think yes, you need files to be on disk at archive creation time, so yes, if you want to convert github release .zip into .asar, you need to do it manually, which, I agree, is not great.
YurySolovyov commentedon Feb 23, 2015
I am also thinking if monkey-patching node's
fsmodule for transparent .asar support was a good idea, isn't it better to have separateasar-fsmodule to deal with asar-related tasks? It can be smaller and easier to maintain, and add features incrementally. ATMfsmodule can be treated asasar-fs(with known limitations), and node's fs isoriginal-fs. Maybe it is just me, but it seems weird.Merge pull request #251 from electron/cookies-changed
Merge pull request #251 from electron/cookies-changed
Merge pull request #251 from electron-userland/typescript-1-6-10
smallscript commentedon Feb 28, 2021
Except that ZIP does support all the above, is extremely efficient for random access, does have symlinks, custom attrs, and zillions of tools that support that. I use it all the time for the exact use case you're describing including having it utilize a binary search to locate files, directories etc with NO requirement to pre-sort on load. ZIP can be located any position within a binary (front, middle, back). That, and sqlite together are components of EFS supporting versioning, replication, and single binary deployment.
Use with "https://github.com/richgel999/miniz" for efficient single file "C" (or has a header only) implementation.