asticode / astilectron Goto Github PK
View Code? Open in Web Editor NEWElectron app that provides an API over a TCP socket that allows executing Electron's method as well as capturing Electron's events
License: MIT License
Electron app that provides an API over a TCP socket that allows executing Electron's method as well as capturing Electron's events
License: MIT License
the last window gets updated in the index.js file but the exported instance is a reference to the original value, then when overriding the lastWindow the exported module is not being updated.
Currently astilectron uses tcp socket to bind other languages stack, but the data over this connection are easy to be sniffered and insecure for renderer passing data like password or tokens.
Maybe we can consider when start() with [tcp://]ip:port
and use the classic tcp way,
and when start() with something like wss://localhost[:port]
, use ws to create a secured connection between clinet and language bindings.
Cheers.
Bundling process stuck at this step - Downloading https://github.com/electron/electron/releases/download/v1.8.1/electron-v1.8.1-darwin-x64.zip into /var/folders/kv/3hryyz4x3c97qdgmzl71s9gh0000gn/T/astibundler/cache/electron-darwin-amd64-1.8.1.zip
Possible reason may be a redirection of this url. The zip can be downloaded from the browser.
is there a way to clear the electron cache (besides rm -rf ~/.config/Electron/cache) ?
is there some type generator? I tried using tygo, but that got it's quirks, like generating
struct bla {
Nested
}
as bla.Nested.propName but this refers to them as bla.propName
Hi there,
I'm looking into adding some functionality to astilectron and am unfortunately running into barriers due to my unfamiliarity with the codebase. Hoping to get some guidance via this ticket, and will be happy to open up PRs for the enhancements I'm looking to make.
I'm looking to expose electron features like:
I've been experimenting with index.js to try and add the functionality I need but it's slow going. Namely I can't seem to figure out how to send and receive messages between Go and electron. The code that exists for this is so low level that it's hard to follow along with without educating myself on the entirety of the codebase.
Any chance someone could provide some pointers on how I would go above adding more interop between Go and electron? A simple "hello world" example for sending messages to/from electron would be tremendously helpful.
Thank you!
This golang lib does File Dialogs and Notifications cross platform:
https://github.com/ncruces/zenity
Does this help ? Or do you call into the Electron code and get it to do File Dialogues and Notifications. Sorry that i do not understand fully so got to ask.
Can i use hot reload. so when i change HTML / CSS, it will update styling without re run app?
Line 18 in a60d286
Hi,
I have an app that uses Angular 10 and NgRx, and I am having some difficulties with its state changes.
The problem is that the UI is not updating correctly given the state of the app. For example, if I click on a button to open a modal popup, the modal doesn't show until I click on something else on the UI and force it to update.
I've tested my app on the latest version of Chrome and on the latest version of Electron (9.1.2) and it worked fine. I also upgrade the Electron from Astilectron to version 9.1.2 but the error remained.
Here is an example:
Notice that the modal only appears after I click on the arrows that change the screen.
This is how it looks like in Chrome when it is working:
Has anyone experienced this? Can anyone help me?
Thanks,
Felipe
Hi astielectron!
I am currently using Astielectron in an asti+react code. I am using electron webview tag inside js part of the application. According to Electron Docs webview tag is not preferred to use because of its instability. I would like to migrate from webview tag to Electron's BrowserView. Unfortunately, to manipulate with BrowserView I need to attach it to Electron BrowserWindow instance. Is it possible to somehow to forward BrowserWindow instance to js API of astilectron?
Hi asticode,
The latest version of the release v0.28.0 doesn't contain the latest changes made on astilectron/main.js file.
Thanks,
Chandrakanth.
I have edited my vendor/astilectron/index.js code to expose the dialog via the astilectron object.
Starting on line 536
`const {ipcRenderer} = require('electron');
const {dialog} = require('electron').remote;
var astilectron = {
dialog: dialog,
onMessageOnce: false,
...
};
...
This made it so I could extend vue/src/plugins/astor.js and further expose the dialog to the rest of my app.
Is this a good way to get access to the dialog object?
Hi ,I have a question.
How to ensure that Socket is not accessed illegally?
Doc: https://www.electronjs.org/docs/latest/api/app#appsetasdefaultprotocolclientprotocol-path-args
How could I go about adding support for something like this?
Wow, in general, oauth always requires a redirect_uri
(such as the github oauth), but electron usually use a filePath like that:
const w = new BrowserWindow({});
w.loadURL("file://path to project/index.html"); // use file path to .html
if the redirect_uri
to set the file path, it will fail. If we want to use oauth in electron, there will be a way: open a new sub window to load the oauth url which the redirect_uri set to http://localhost
, and electron listen will-navigate
(when you first oauth) and did-get-redirect-request
(when you have authorized) to send the newUrl. Like what the electron-oauth2 do.
I found that boths go-astilectron
and astilectron
do not define this event, I forked the projects and modify it:
astilectron/src/consts.js:
windowEventDidGetRedirectRequest: "window.event.did.get.redirect.request",
windowEventWillNavigate: "window.event.will.navigate", // will trigger when first use oauth
astilectron/main.js:
function windowCreate(json) {
...
elements[json.targetID].webContents.on('did-get-redirect-request', (event, oldUrl, newUrl) => {
client.write(json.targetID, consts.eventNames.windowEventDidGetRedirectRequest, {
url: newUrl
})
})
elements[json.targetID].webContents.on('will-navigate", (event, url) => {
client.write(json.targetId, consts.eventNames.windowEventWillNavigate, {
url
})
})
}
go-astilectron/window.go:
EventNameWindowEventDidGetRedirectRequest = "window.event.did.get.redirect.request"
EventNameWindowEventWillNavigate = "window.event.will.navigate"
I modified it in my forking astilectron
project and release a v.0.15.0
version(beacuse go-astilectron use VersionAstilectron
and this attr is defined to 0.15.0
), and I try this in my project and test it:
var ow, _ = a.NewWindow("http://github.com/login/oauth/authorize?response_type=code&client_id=31dbd4e343e060a20bdf&client_secret=c0a20c8b3bd912998779ad639077442e6b8b3ba9&redirect_uri=http://localhost", &astilectron.WindowOptions{
Center: astilectron.PtrBool(false),
Height: astilectron.PtrInt(600),
Width: astilectron.PtrInt(600),
})
ow.On(astilectron.EventNameWindowEventDidGetRedirectRequest, func(e astilectron.Event) (deleteListener bool) {
w.SendMessage(e.URL, func(m *astilectron.EventMessage) {
// Unmarshal
var s string
m.Unmarshal(&s)
// Process message
astilog.Debugf("received %s", s)
})
return
})
ow.On(astilectron.EventNameWindowEventWillNavigate, func(e astilectron.Event) (deleteListener bool) {
w.SendMessage(e.URL, func(m *astilectron.EventMessage) {
// Unmarshal
var s string
m.Unmarshal(&s)
// Process message
astilog.Debugf("received %s", s)
})
return
})
this gif is what I tested result:
this can use to other aspects that load url, I'm no sure what your opinion about this, so I open an issue to discuss it, if you think it is feasible, I will make some PR.
The default Electron/Astilectron installation path is located inside:
C:\Users\Admin\AppData\Roaming\%AppName%\vendor
However, the Electron Cache is located inside:
C:\Users\Admin\AppData\Roaming\Electron
The Electron Cache should be located inside:
C:\Users\Admin\AppData\Roaming\%AppName%
This issue causes conflicts with other Electron applications that use the same cache path by default.
Reproduction can be caused using go-asilectron with the default parameters and a valid AppName.
Hi asticode,
I am trying to use astilectron and build an electron application. How to set the version of the application? How to make sure this version is available in windows.syso created in the application folder. Also, is there any way we can do auto-update of the application in Windows and Mac?
Dear bro,
I using astilectron with vue.
when "run serve" or "run build", the first time inform not define,
but I run the command twice, it successed, nothing changed.
the log is following.
`PS C:\hlp\02src\mygui\mmq\mmqfront> npm run build
[email protected] build C:\hlp\02src\mygui\mmq\mmqfront
vue-cli-service build
/ Building for production...
ERROR Failed to compile with 1 error 下午3:35:44
error in ./src/pages/Send/index.vue
Module Error (from ./node_modules/eslint-loader/index.js):
C:\hlp\02src\mygui\mmq\mmqfront\src\pages\Send\index.vue
✖ 1 problem (1 error, 0 warnings)
@ ./src/router.js 28:13-41
@ ./src/main.js
@ multi ./src/main.js
ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: vue-cli-service build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\shuser\AppData\Roaming\npm-cache_logs\2021-12-09T07_35_44_683Z-debug.log
PS C:\hlp\02src\mygui\mmq\mmqfront> npm run build
[email protected] build C:\hlp\02src\mygui\mmq\mmqfront
vue-cli-service build
WARNING Compiled with 2 warnings 下午3:36:02
warning
asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
css/chunk-vendors.4cb5fce1.css (316 KiB)
js/chunk-vendors.03c58d10.js (1.6 MiB)
warning
entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
app (1.92 MiB)
css/chunk-vendors.4cb5fce1.css
js/chunk-vendors.03c58d10.js
css/app.a61f0562.css
js/app.c18a3fa1.js
File Size Gzipped
dist\app\js\chunk-vendors.03c58d10.js 1643.03 KiB 530.57 KiB
dist\app\js\chunk-45926f3b.086aa401.js 5.61 KiB 1.90 KiB
dist\app\js\chunk-fef40f70.b1e9ed1e.js 5.39 KiB 1.89 KiB
dist\app\js\app.c18a3fa1.js 5.05 KiB 2.18 KiB
dist\app\js\chunk-65588e0d.ff1d5f44.js 3.42 KiB 1.32 KiB
dist\app\js\chunk-2d5e931d.1658ec56.js 2.21 KiB 0.90 KiB
dist\app\js\chunk-db4206a4.81df13ea.js 2.20 KiB 0.88 KiB
dist\app\css\chunk-vendors.4cb5fce1.css 315.60 KiB 42.61 KiB
dist\app\css\app.a61f0562.css 0.02 KiB 0.04 KiB
dist\app\css\chunk-2d5e931d.0e433876.css 0.00 KiB 0.02 KiB
dist\app\css\chunk-45926f3b.8b5fefc0.css 0.00 KiB 0.02 KiB
dist\app\css\chunk-65588e0d.8b5fefc0.css 0.00 KiB 0.02 KiB
dist\app\css\chunk-db4206a4.0e433876.css 0.00 KiB 0.02 KiB
dist\app\css\chunk-fef40f70.8b5fefc0.css 0.00 KiB 0.02 KiB
Images and other types of assets omitted.
DONE Build complete. The dist\app directory is ready to be deployed.
INFO Check out deployment instructions at https://cli.vuejs.org/guide/deployment.html`
https://www.electronjs.org/docs/api/web-contents#contentsprinttopdfoptions
Is this accessable from golang to tell Electon to Print and PrintToPDF ?
Inspecting the history it appears that it got set at "0.33.0" for v0.33.0, but has not been updated since.
I'd like to suggest that either this be kept up to date, or it be removed and an alternative method of finding the version for an install be provided. Thanks!
I need a programmatically interruption here to prevent site navigation on a page that generates a token. Would it be possible to have the a callback function?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.