Looking for an introduction to Electron? Two new podcasts have just been released that give a great overview of what it is, why it was built, and how it is being used.
Is Electron "just Chrome in a frame" or is it so much more? Jessica sets Scott on the right path and explains exactly where the Electron platform fits into your development world.
Electron is becoming more and more of a relevant and popular way of building multi-platform desktop apps with web technologies. Let's get a dive into this awesome tech and see how we can use it to enhance our own experience and our user's experience on the desktop.
If you're looking for an introduction to Electron, give the first a listen. The second goes into more detail about building apps with great tips from Nylas's Evan Morikawa.
We are currently working on two more podcasts that should come out next month, keep an eye on the @ElectronJS Twitter account for updates.
For the last two years, Electron has helped developers build cross platform desktop apps using HTML, CSS, and JavaScript. Now we're excited to share a major milestone for our framework and for the community that created it. Выпуск Electron 1.0 теперь доступен в electronjs.org.
Electron 1.0 represents a major milestone in API stability and maturity. This release allows you to build apps that act and feel truly native on Windows, Mac, and Linux. Building Electron apps is easier than ever with new docs, new tools, and a new app to walk you through the Electron APIs.
Если вы готовы создать свое первое приложение Electron, вот быстрый старт поможет вам начать работу.
Нам не терпится увидеть, что вы создадите с Electron.
Мы выпустили Electron, когда мы запустили Atom чуть более двух лет назад. Electron, тогда известный как Atom Shell, был фреймворком, на котором мы построили Atom. In those days, Atom was the driving force behind the features and functionalities that Electron provided as we pushed to get the initial Atom release out.
In these last two years we've seen both companies and open source projects choose Electron as the foundation for their apps. Just in the past year, Electron has been downloaded over 1.2 million times. Ознакомьтесь с некоторыми из удивительных приложений Electron и добавьте свои собственные приложения, если они еще не там.
Along with the 1.0 release, we're releasing a new app to help you explore the Electron APIs and learn more about how to make your Electron app feel native. Along with the 1.0 release, we're releasing a new app to help you explore the Electron APIs and learn more about how to make your Electron app feel native.
Мы также добавили новое расширение, которое поможет вам отлаживать ваши приложения Electron. Devtron является открытым исходным кодом расширением для Инструментов разработчика Chrome , призванных помочь вам проверить, отладка и устранение неполадок вашего приложения Electron.
Require graph that helps you visualize your app's internal and external library dependencies in both the main and renderer processes
IPC monitor that tracks and displays the messages sent and received between the processes in your app
Event inspector that shows you the events and listeners that are registered in your app on the core Electron APIs such as the window, app, and processes
App Linter that checks your apps for common mistakes and missing functionality
Наконец, мы выпускаем новую версию Spectron, интеграцию тестирования фреймворка для Electron приложений.
Spectron 3.0 has comprehensive support for the entire Electron API allowing you to more quickly write tests that verify your application's behavior in various scenarios and environments. Спектр основан на ChromeDriver и WebDriverIO , поэтому у него также полные API для навигации по страницам, пользователь вводит и выполняет JavaScript.
Electron 1.0 is the result of a community effort by hundreds of developers. Outside of the core framework, there have been hundreds of libraries and tools released to make building, packaging, and deploying Electron apps easier.
Сейчас появилась новая страница сообщества с описанием многих замечательных инструментов Electron, приложений, библиотек и фреймворков. Вы также можете проверить Electron и Electron Userland , чтобы увидеть некоторые из этих фантастических проектов.
Впервые встречаете? Посмотрите вступительное видео Electron 1.0:
Electron 0.37 was recently released and included a major upgrade from Chrome 47 to Chrome 49 and also several new core APIs. This latest release brings in all the new features shipped in Chrome 48 and Chrome 49. This includes CSS custom properties, increased ES6 support, KeyboardEvent improvements, Promise improvements, and many other new features now available in your Electron app.
If you've used preprocessed languages like Sass and Less, you're probably familiar with variables, which allow you to define reusable values for things like color schemes and layouts. Variables help keep your stylesheets DRY and more maintainable.
CSS custom properties are similar to preprocessed variables in that they are reusable, but they also have a unique quality that makes them even more powerful and flexible: they can be manipulated with JavaScript. This subtle but powerful feature allows for dynamic changes to visual interfaces while still benefitting from CSS's hardware acceleration, and reduced code duplication between your frontend code and stylesheets.
The variable value can be retrieved and changed directly in JavaScript:
// Get the variable value ' #A5ECFA' let color =window .getComputedStyle(document.body) .getPropertyValue('--awesome-color'); // Set the variable value to 'orange' document.body.style.setProperty('--awesome-color','orange');
The variable values can be also edited from the Styles section of the development tools for quick feedback and tweaks:
Chrome 48 added the new code property available on KeyboardEvent events that will be the physical key pressed independent of the operating system keyboard layout.
This should make implementing custom keyboard shortcuts in your Electron app more accurate and consistent across machines and configurations.
window.addEventListener('keydown',function(event){ console.log(`${event.code} was pressed.`); });
The version of V8 now in Electron incorporates 91% of ES2015. Here are a few interesting additions you can use out of the box—without flags or pre-compilers:
// Destructuring an array and skipping the second element const[first,, last]=findAll(); // Destructuring function parameters functionwhois({displayName: displayName,fullName:{firstName: name }}){ console.log(`${displayName} is ${name}`); } let user ={ displayName:'jdoe', fullName:{ firstName:'John', lastName:'Doe', }, }; whois(user);// "jdoe is John" // Destructuring an object let{ name, avatar }=getUser();
Building an Electron application means you only need to create one codebase and design for one browser, which is pretty handy. But because Electron stays up to date with Node.js and Chromium as they release, you also get to make use of the great features they ship with. In some cases this eliminates dependencies you might have previously needed to include in a web app.
There are many features and we'll cover some here as examples, but if you're interested in learning about all features you can keep an eye on the Google Chromium blog and Node.js changelogs. You can see what versions of Node.js, Chromium and V8 Electron is using at electronjs.org/#electron-versions.
Electron combines Chromium's rendering library with Node.js. The two share the same JavaScript engine, V8. Many ECMAScript 2015 (ES6) features are already built into V8 which means you can use them in your Electron application without any compilers.
Below are a few examples but you can also get classes (in strict mode), block scoping, promises, typed arrays and more. Check out this list for more information on ES6 features in V8.
Arrow Functions
findTime()=>{ console.log(newDate()) }
String Interpolation
var octocat ='Mona Lisa'; console.log(`The octocat's name is ${octocat}`);
Thanks to all the hard work Google and contributors put into Chromium, when you build Electron apps you can also use cool things like (but not limited to):
Follow along with the Google Chromium blog to learn about features as new versions ship and again, you can check the version of Chromium that Electron uses here.
Since the beginning of Electron, starting way back when it used to be called Atom-Shell, we have been experimenting with providing a nice cross-platform JavaScript API for Chromium's content module and native GUI components. The APIs started very organically, and over time we have made several changes to improve the initial designs.
Now with Electron gearing up for a 1.0 release, we'd like to take the opportunity for change by addressing the last niggling API details. The changes described below are included in 0.35.x, with the old APIs reporting deprecation warnings so you can get up to date for the future 1.0 release. An Electron 1.0 won't be out for a few months so you have some time before these changes become breaking.
By default, warnings will show if you are using deprecated APIs. To turn them off you can set process.noDeprecation to true. To track the sources of deprecated API usages, you can set process.throwDeprecation to true to throw exceptions instead of printing warnings, or set process.traceDeprecation to true to print the traces of the deprecations.
Встроенные модули теперь сгруппированы в один модуль, а не разделены на независимые модули, так что вы можете использовать их без конфликтов с другими модулями:
var app =require('electron').app; varBrowserWindow=require('electron').BrowserWindow;
The old way of require('app') is still supported for backward compatibility, but you can also turn if off:
Because of the way using built-in modules has changed, we have made it easier to use main-process-side modules in renderer process. You can now just access remote's attributes to use them:
// New way. var app =require('electron').remote.app; varBrowserWindow=require('electron').remote.BrowserWindow;
Instead of using a long require chain:
// Old way. var app =require('electron').remote.require('app'); varBrowserWindow=require('electron').remote.require('BrowserWindow');
The ipc module existed on both the main process and renderer process and the API was different on each side, which is quite confusing for new users. We have renamed the module to ipcMain in the main process, and ipcRenderer in the renderer process to avoid confusion:
// В main процессе. var ipcMain =require('electron').ipcMain;
// In renderer process. var ipcRenderer =require('electron').ipcRenderer;
And for the ipcRenderer module, an extra event object has been added when receiving messages, to match how messages are handled in ipcMain modules:
The BrowserWindow options had different styles based on the options of other APIs, and were a bit hard to use in JavaScript because of the - in the names. They are now standardized to the traditional JavaScript names:
The API names in Electron used to prefer camelCase for all API names, like Url to URL, but the DOM has its own conventions, and they prefer URL to Url, while using Id instead of ID. We have done the following API renames to match the DOM's styles:
Url is renamed to URL
Csp is renamed to CSP
You will notice lots of deprecations when using Electron v0.35.0 for your app because of these changes. An easy way to fix them is to replace all instances of Url with URL.
As of v0.34.0 each Electron release includes a build compatible with the Mac App Store. Previously an application built on Electron would not comply with Apple's requirements for the Mac App Store. Most of these requirements are related to the use of private APIs. In order to sandbox Electron in such a way that it complies with the requirements two modules needed to be removed:
crash-reporter
auto-updater
Additionally some behaviors have changed with respect to detecting DNS changes, video capture and accessibility features. You can read more about the changes and submitting your app to the Mac App store in the documentation. The distributions can be found on the Electron releases page, prefixed with mas-.
In Electron v0.34.1 the auto-updater module was improved in order to work with Squirrel.Windows. This means that Electron ships with easy ways for auto updating your app on both OS X and Windows. You can read more on setting up your app for auto updating on Windows in the documentation.
Мы изменили структуру и стандартизировали документацию, с тем чтобы она лучше выглядела и лучше читалась. Существуют также переводы документации, внесенные общинами, такие, как японский и корейский.
A patch by @jaanus has been merged that, like the other built-in OS X apps, allows creating frameless windows with system traffic lights integrated on OS X Yosemite and later.
После Google Summer of Code мы объединили патчи на [@hokein](https://github. com/hokein), чтобы улучшить поддержку печати, и добавили возможность печати страницы в PDF файлы.
Join us September 29th at GitHub's HQ for an Electron meetup hosted by Atom team members @jlord and @kevinsawicki. There will be talks, food to snack on, and time to hangout and meet others doing cool things with Electron. We'll also have a bit of time to do lightning talks for those interested. Hope to see you there!
Talks
Jonathan Ross and Francois Laberge from Jibo will share how they use Electron to animate a robot.
Jessica Lord will talk about building a teaching tool, Git-it, on Electron.
Tom Moor will talk about the pros and cons of building video and screen sharing on Electron with speak.io.
Ben Gotow will preview N1: The Nylas Mail Client and talk about developing it on Electron.
This week we've given Electron's documentation a home on electronjs.org. You can visit /docs/latest for the latest set of docs. We'll keep versions of older docs, too, so you're able to visit /docs/vX.XX.X for the docs that correlate to the version you're using.
You can visit /docs to see what versions are available or /docs/all to see the latest version of docs all on one page (nice for cmd + f searches).
Если вы хотите внести свой вклад в наполнение документации, вы можете сделать это в репозитории Electron, из которого загружены документы. We fetch them for each minor release and add them to the Electron site repository, which is made with Jekyll.
If you're interested in learning more about how we pull the docs from one repository to another continue reading below. Otherwise, enjoy the docs!
We're preserving the documentation within the Electron core repository as is. This means that electron/electron will always have the latest version of the docs. When new versions of Electron are released, we duplicate them over on the Electron website repository, electron/electronjs.org.
To fetch the docs we run a script with a command line interface of script/docs vX.XX.X with or without the --latest option (depending on if the version you're importing is the latest version). Our script for fetching docs uses a few interesting Node modules:
For Jekyll to render each page it needs at least empty front matter. We're going to make use of front matter on all of our pages so while we're streaming out the /docs directory we check to see if a file is the README.md file (in which case it receives one front matter configuration) or if it is any other file with a markdown extension (in which case it receives slightly different front matter).
Each page receives this set of front matter variables:
In the site's _config.yml file a variable latest_version is set every time the --latest flag is used when fetching docs. We also add a list of all the versions that have been added to the site as well as the permalink we'd like for the entire docs collection.
The file latest.md in our site root is empty except for this front matter which allows users to see the index (aka README) of the latest version of docs by visiting this URL, electron.atom.io/docs/latest, rather than using the latest version number specifically (though you can do that, too).
To create a page showing the versions that are available we just loop through the list in our config on a file, versions.md, in the site's root. Also we give this page a permalink: /docs/
{% raw %} {% for version in site.available_versions %} - [{{ version }}](/docs/{{ version }}) {% endfor %} {% endraw %}
Hope you enjoyed these technical bits! If you're interested in more information on using Jekyll for documentation sites, checkout how GitHub's docs team publishes GitHub's docs on Jekyll.
Atom Shell теперь называется Electron. Вы можете узнать больше о Electron и о том, какие люди строят с ним на своем новом доме electronjs.org.
Electron - это кросс-платформенная оболочка приложений, которую мы изначально создали для редактора Atom для интеграции цикла событий Chromium/Node.js и собственных API.
Когда мы начинали, наша цель была не просто поддерживать потребности текстового редактора. Мы также хотели создать простой фреймворк, которая позволил бы людям использовать веб-технологии для создания кросс-платформенных настольных приложений со всеми встроенными функциями.
За два года Electron неуклонно рос. Теперь он включает в себя автоматические обновления приложений, установщики Windows, отчеты о сбоях, уведомления и другие полезные встроенные функции приложения — все это доступно через API JavaScript. И у нас есть еще над чем поработать. Вы планируем извлечь из Atom ещё больше библиотек, чтобы создание нативного приложения с веб технологиями как можно проще.
На данный момент индивидуальные разработчики, стартапы на ранних стадиях и крупные компании уже создали приложения на Electron. They've created a huge range of apps — including chat apps, database explorers, map designers, collaborative design tools, and mobile prototyping apps.
Check out the new electronjs.org to see more of the apps people have built on Electron or take a look at the docs to learn more about what else you can make.
If you've already gotten started, we'd love to chat with you about the apps you're building on Electron. Email info@electronjs.org to tell us more. You can also follow the new @ElectronJS Twitter account to stay connected with the project.