SlideShare uma empresa Scribd logo
1 de 49
Baixar para ler offline
developing desktop apps
w/ electron + ember
fitc: web unleashed (sep 25 2017)
© Isle of Code Inc.@anulman - #WEBU17
why write hybrid apps?
• app store distribution
• decouple a long-lived app from browser tabs
• use system ui, like alerts & menu / task bars
• use system resources, like fs & gpu
2
© Isle of Code Inc.@anulman - #WEBU17
notable examples
• atom
• slack
• brave
• ghost
• visual studio code
• gitkraken
3
© Isle of Code Inc.@anulman - #WEBU17
things we will learn
• intro to electron
• what it is + why you’d use it
• architecture
• disclaimers
• spa frameworks + electron
• intro to electron-forge
• what it is + why you’d use it
• spa frameworks + electron-forge
4
© Isle of Code Inc.@anulman - #WEBU17
things we will learn (cont’d)
• building an app with ember-electron
• init
• livereload shell
• packaging / distributing
• testing
• extending your electron app
• global shortcuts + dialogs
• app icon
• app signing + autoupdate
• useful libs for electron apps
• render-vendor
• fs-storage-utils (beta!)
5
© Isle of Code Inc.@anulman - #WEBU17
plug: corber.io
• this presentation = desktop apps
• mobile hybrid w/ spas should use corber.io (beta):
• currently for ember, vue, glimmer apps + cordova
• handles framework + app build & validations, w/o
affecting existing web flows
• includes on-device livereload, + utility functions for
icons & plugins
• when needed, can proxy to the cordova cli
6
© Isle of Code Inc.@anulman - #WEBU17
btw hi i’m aidan
• partner & polyglot @ isle of code
• @anulman on twitter, github, etc
• maintainer w/ember-electron
• + contribs on electron-forge, electron-installer-debian…
• when not hacking, i’m:
• on my bicycle
• at a concert
• cooking
7
intro to electron
© Isle of Code Inc.@anulman - #WEBU17
what it is + why you’d use it
• oss framework to compose cross-platform desktop
apps from node.js apis + chromium windows
• originally extracted from github’s atom editor
• learned from predecessors:
• chromium embedded framework
• nw.js
10
© Isle of Code Inc.@anulman - #WEBU17
electron architecture
• offers simultaneous control of node.js & chromium runtimes
• comes pre-packaged with js wrappers for several common
host os apis:
• system tray
• autoupdate
• keyboard shortcuts w/ & w/o focus
• many pre-packaged js wrappers are available only in the node
runtime / are sandboxed from chromium (renderer) procs
11
© Isle of Code Inc.@anulman - #WEBU17
disclaimers re: electron / hybrid
• “serves” via fs, so paths should not start with `/`
• architecture should minimize platform-specific code
• be careful! you have full privileges of host OS
• e.g. remote code execution is hecka dangerous
• memory leaks are a major issue, as no req / response cycle to
refresh state:
• unresolved / rejected promises
• lingering refs to dom nodes…
12
© Isle of Code Inc.@anulman - #WEBU17
spa frameworks + electron
• spa frameworks offer shared context to ui code
• enforces clear divide between renderer + main
proc code
• benefit from upstream perf + feature work
13
intro to electron-forge
© Isle of Code Inc.@anulman - #WEBU17
what it is + why you’d use it
• wraps best community build tools (e.g. for
livereload, packaging, generating distributables)
• init’ed oct 2016; first major / stable releases dec
2016
15
© Isle of Code Inc.@anulman - #WEBU17
spa frameworks + electron-forge
• e-forge ships with react + ng templates
• e-forge exposes its apis for consumption by other build
tools / pipelines
• ember-electron 2.x was one of the first build tools to proxy
e-forge’s apis
• ember-electron also provides electron-aware testing env
• h/t @felixrieseberg (slack + electron core) + e-electron
community :)
17
building an app with
ember-electron
© Isle of Code Inc.@anulman - #WEBU17
init
19
© Isle of Code Inc.@anulman - #WEBU17
init
• `ember install ember-electron`
• (or `ember g ember-electron`)
• runs `electron-forge init .`, + some other config
• https://github.com/felixrieseberg/ember-electron/blob/master/blueprints/ember-electron/index.js
20
© Isle of Code Inc.@anulman - #WEBU17
init (cont’d)
21
© Isle of Code Inc.@anulman - #WEBU17
init (cont’d)
• introduces `ember-electron` dir
• inits an `ember-electron/main.js` file
• reads config from `ember-electron/.electron-forge`
• commands will add `ember-electron` dir to broccoli build
• incls merged `resources-` dir
• updates package.json per forge expectations, iff
values dne
22
© Isle of Code Inc.@anulman - #WEBU17
livereload shell
• `ember electron`
• electron equivalent to `ember s`
• proxies api for `electron-forge start`
• https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/electron.js
23
© Isle of Code Inc.@anulman - #WEBU17
livereload shell (cont’d)
24
© Isle of Code Inc.@anulman - #WEBU17
livereload shell (cont’d)
• builds app js to `electron-out/project` & symlinks deps
• runs built js with prebuilt & compiled electron bin via `electron-
forge#start`
• watches ember app + `ember-electron` dir for changes
• installs ember inspector to renderer windows
• useful options:
• —environment
• --output-path
25
© Isle of Code Inc.@anulman - #WEBU17
packaging / distributing
• `ember electron:package`
• `ember electron:make`
• electron equivalent to `ember build`
• proxies apis for `electron-forge [package|make]`
• all inherits from generic e-electron build cmd
• https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/build.js
• https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/package.js
• https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/make.js
26
© Isle of Code Inc.@anulman - #WEBU17
packaging / distributing
(cont’d)
27
© Isle of Code Inc.@anulman - #WEBU17
packaging / distributing
(cont’d)
• `ember build`s app (incl electron) to tmp dir
• installs package.json deps (n.b. no devDeps)
• passes built tmp dir to specified forge api
• cleans up tmp dir
28
© Isle of Code Inc.@anulman - #WEBU17
packaging / distributing
(cont’d)
• useful options:
• --environment
• --arch, --platform
• --output-path
• --skip-package
• --targets
29
© Isle of Code Inc.@anulman - #WEBU17
testing
• `ember electron:test`
• electron equivalent to `ember test`
• https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/electron-test.js
30
© Isle of Code Inc.@anulman - #WEBU17
testing (cont’d)
31
© Isle of Code Inc.@anulman - #WEBU17
testing (cont’d)
• passes args to ember test cmd + task to load
runner in electron shell
• permits acceptance testing main proc behaviour
32
extending your electron app
© Isle of Code Inc.@anulman - #WEBU17
global shortcuts + dialogs
• shortcuts & dialogs are restricted to main proc
• preference is to handle in `main.js`
• if handling in `BrowserWindow`:
`require(‘electron’).remote.globalShortcut(…)`
• dialogs have several types:
• `showOpenDialog`
• `showSaveDialog`
• `showMessageBox`
• `showErrorBox`
34
© Isle of Code Inc.@anulman - #WEBU17
global shortcuts + dialogs
(cont’d)
35
© Isle of Code Inc.@anulman - #WEBU17
app icon
• create icon files
• mac: *.icns
• win: *.ico
• linux: *.png
• add config to forge’s packager options (mac / win)
• add `icon: ‘path/to/icon’` to `BrowserWindow` init in electron.js
(linux)
• omit extension to auto-configure ext by platform
36
© Isle of Code Inc.@anulman - #WEBU17
app icon (cont’d)
37
© Isle of Code Inc.@anulman - #WEBU17
app signing + autoupdates
• signing apps is strongly encouraged, though not technically req’d
• configure app signing:
• mac: `osxSign` param of `electronPackagerConfig`
• win: `electronWinstallerConfig`
• linux: pray to cthulhu
• make executable:
• `ember electron:make`
• publish executable, e.g. via github release / s3
38
© Isle of Code Inc.@anulman - #WEBU17
app signing + autoupdates
(cont’d)
• mac + win apps can autoupdate with squirrel
• deploy & configure nuts server: https://github.com/GitbookIO/
nuts
• proxies & caches distributable assets
• exposes api for e.g.
• `/download/latest`
• `/download/latest/:os`
• `/download/:version`
39
© Isle of Code Inc.@anulman - #WEBU17
app signing + autoupdates
(cont’d)
• in main proc,
`electron.autoUpdater.checkForUpdates()`
• n.b. this checks & downloads in one op
• if win, must handle squirrel events immediately on
boot
• e.g. `require(‘electron-squirrel-startup’)`
40
useful libs for electron apps
© Isle of Code Inc.@anulman - #WEBU17
render-vendor
• custom point-of-sale app needed to print receipts,
stickers, hangtags
• ideal pipeline: html => pdf => printer
• traditional js pdf tooling: 2-3s latency between user
action + print output
• 90+% of latency due to html => pdf step
43
© Isle of Code Inc.@anulman - #WEBU17
render-vendor (cont’d)
44
© Isle of Code Inc.@anulman - #WEBU17
render-vendor (cont’d)
• render-vendor “renderers” load html templates into
long-lived “pages”
• can be used as cli app, or `require` into .js files
• after initial boot + render, jobs take < 50ms
• html => pdf => printer output now feels
instantaneous
45
© Isle of Code Inc.@anulman - #WEBU17
fs-storage-plus (beta)
• app needed to sign into third party services
• ideal solution would store cookies + user creds for
reuse between boots
• fs-storage-plus implements localstorage API with fs
storage backend
• encrypted storage class (constructor) extends
base with crypto + node-keytar libs to generate,
cycle, and securely persist encryption keys
46
© Isle of Code Inc.@anulman - #WEBU17
tl;dr
• electron is a popular and proven lib / framework to
create hybrid desktop applications
• electron-forge (+ ember-electron) offers a painless
cli integration
• any system / server node module (e.g. fs) is
available in electron processes
• leverage native features (e.g. parallel procs,
networked printing, keychain) for better ux
47
© Isle of Code Inc.@anulman - #WEBU17
links
• https://electron.atom.io
• https://github.com/felixriesberg/ember-electron
• https://github.com/electron-userland/electron-forge
• http://render-vendor.com
• https://www.npmjs.com/package/fs-storage-plus
49

Mais conteúdo relacionado

Mais procurados

Architecting for Continuous Delivery
Architecting for Continuous DeliveryArchitecting for Continuous Delivery
Architecting for Continuous DeliveryAxel Fontaine
 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsNicholas Jansma
 
Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)Axel Fontaine
 
Scala, ECS, Docker: Delayed Execution @Coursera
Scala, ECS, Docker: Delayed Execution @CourseraScala, ECS, Docker: Delayed Execution @Coursera
Scala, ECS, Docker: Delayed Execution @CourseraC4Media
 
Immutable Server generation: The new App Deployment
Immutable Server generation: The new App DeploymentImmutable Server generation: The new App Deployment
Immutable Server generation: The new App DeploymentAxel Fontaine
 
Java Application Servers Are Dead!
Java Application Servers Are Dead!Java Application Servers Are Dead!
Java Application Servers Are Dead!Eberhard Wolff
 
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Yan Cui
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
 
London Node.js User Group - Cloud-native Node.js
London Node.js User Group - Cloud-native Node.jsLondon Node.js User Group - Cloud-native Node.js
London Node.js User Group - Cloud-native Node.jsBethany Nicolle Griggs
 

Mais procurados (10)

Architecting for Continuous Delivery
Architecting for Continuous DeliveryArchitecting for Continuous Delivery
Architecting for Continuous Delivery
 
The Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.jsThe Happy Path: Migration Strategies for Node.js
The Happy Path: Migration Strategies for Node.js
 
Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)
 
Scala, ECS, Docker: Delayed Execution @Coursera
Scala, ECS, Docker: Delayed Execution @CourseraScala, ECS, Docker: Delayed Execution @Coursera
Scala, ECS, Docker: Delayed Execution @Coursera
 
Immutable Server generation: The new App Deployment
Immutable Server generation: The new App DeploymentImmutable Server generation: The new App Deployment
Immutable Server generation: The new App Deployment
 
Java Application Servers Are Dead!
Java Application Servers Are Dead!Java Application Servers Are Dead!
Java Application Servers Are Dead!
 
Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)Serverless in production, an experience report (Going Serverless)
Serverless in production, an experience report (Going Serverless)
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
London Node.js User Group - Cloud-native Node.js
London Node.js User Group - Cloud-native Node.jsLondon Node.js User Group - Cloud-native Node.js
London Node.js User Group - Cloud-native Node.js
 

Semelhante a Developing Desktop Apps with Electron & Ember.js

electron for emberists
electron for emberistselectron for emberists
electron for emberistsAidan Nulman
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web DevelopersKyle Cearley
 
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWERContinuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWERIndrajit Poddar
 
Docker for Devs - John Zaccone, IBM
Docker for Devs - John Zaccone, IBMDocker for Devs - John Zaccone, IBM
Docker for Devs - John Zaccone, IBMDocker, Inc.
 
[OWASP Poland Day] A study of Electron security
[OWASP Poland Day] A study of Electron security[OWASP Poland Day] A study of Electron security
[OWASP Poland Day] A study of Electron securityOWASP
 
DSpace UI prototype dsember
DSpace UI prototype dsemberDSpace UI prototype dsember
DSpace UI prototype dsemberBram Luyten
 
Ember Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with EmberEmber Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with EmberAlex Blom
 
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe Sencha
 
DOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at Scale
DOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at ScaleDOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at Scale
DOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at ScaleGene Kim
 
Build Your First SharePoint Framework Webpart
Build Your First SharePoint Framework WebpartBuild Your First SharePoint Framework Webpart
Build Your First SharePoint Framework WebpartEric Overfield
 
Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015Pavel Chunyayev
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2Vincent Mercier
 
Working Without Wires
Working Without WiresWorking Without Wires
Working Without WiresKinoma
 
Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyUlrich Krause
 
Continuous integration by Rémy Virin
Continuous integration by Rémy VirinContinuous integration by Rémy Virin
Continuous integration by Rémy VirinCocoaHeads France
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLMario-Leander Reimer
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureQAware GmbH
 
Использование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложенийИспользование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложенийVitebsk Miniq
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development PipelineGlobalLogic Ukraine
 

Semelhante a Developing Desktop Apps with Electron & Ember.js (20)

electron for emberists
electron for emberistselectron for emberists
electron for emberists
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web Developers
 
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWERContinuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
Continuous Integration with Cloud Foundry Concourse and Docker on OpenPOWER
 
Electron
ElectronElectron
Electron
 
Docker for Devs - John Zaccone, IBM
Docker for Devs - John Zaccone, IBMDocker for Devs - John Zaccone, IBM
Docker for Devs - John Zaccone, IBM
 
[OWASP Poland Day] A study of Electron security
[OWASP Poland Day] A study of Electron security[OWASP Poland Day] A study of Electron security
[OWASP Poland Day] A study of Electron security
 
DSpace UI prototype dsember
DSpace UI prototype dsemberDSpace UI prototype dsember
DSpace UI prototype dsember
 
Ember Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with EmberEmber Conf 2016: Building Mobile Apps with Ember
Ember Conf 2016: Building Mobile Apps with Ember
 
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
 
DOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at Scale
DOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at ScaleDOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at Scale
DOES SFO 2016 - Greg Maxey and Laurent Rochette - DSL at Scale
 
Build Your First SharePoint Framework Webpart
Build Your First SharePoint Framework WebpartBuild Your First SharePoint Framework Webpart
Build Your First SharePoint Framework Webpart
 
Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015Ansible benelux meetup - Amsterdam 27-5-2015
Ansible benelux meetup - Amsterdam 27-5-2015
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2
 
Working Without Wires
Working Without WiresWorking Without Wires
Working Without Wires
 
Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easy
 
Continuous integration by Rémy Virin
Continuous integration by Rémy VirinContinuous integration by Rémy Virin
Continuous integration by Rémy Virin
 
Everything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPL
 
Everything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventure
 
Использование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложенийИспользование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложений
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development Pipeline
 

Mais de FITC

Cut it up
Cut it upCut it up
Cut it upFITC
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital HealthFITC
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript PerformanceFITC
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech StackFITC
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR ProjectFITC
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerFITC
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryFITC
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday InnovationFITC
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight WebsitesFITC
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is TerrifyingFITC
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanFITC
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)FITC
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameFITC
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare SystemFITC
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignFITC
 
The Power of Now
The Power of NowThe Power of Now
The Power of NowFITC
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAsFITC
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstackFITC
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFITC
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForFITC
 

Mais de FITC (20)

Cut it up
Cut it upCut it up
Cut it up
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
 

Último

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Último (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Developing Desktop Apps with Electron & Ember.js

  • 1. developing desktop apps w/ electron + ember fitc: web unleashed (sep 25 2017)
  • 2. © Isle of Code Inc.@anulman - #WEBU17 why write hybrid apps? • app store distribution • decouple a long-lived app from browser tabs • use system ui, like alerts & menu / task bars • use system resources, like fs & gpu 2
  • 3. © Isle of Code Inc.@anulman - #WEBU17 notable examples • atom • slack • brave • ghost • visual studio code • gitkraken 3
  • 4. © Isle of Code Inc.@anulman - #WEBU17 things we will learn • intro to electron • what it is + why you’d use it • architecture • disclaimers • spa frameworks + electron • intro to electron-forge • what it is + why you’d use it • spa frameworks + electron-forge 4
  • 5. © Isle of Code Inc.@anulman - #WEBU17 things we will learn (cont’d) • building an app with ember-electron • init • livereload shell • packaging / distributing • testing • extending your electron app • global shortcuts + dialogs • app icon • app signing + autoupdate • useful libs for electron apps • render-vendor • fs-storage-utils (beta!) 5
  • 6. © Isle of Code Inc.@anulman - #WEBU17 plug: corber.io • this presentation = desktop apps • mobile hybrid w/ spas should use corber.io (beta): • currently for ember, vue, glimmer apps + cordova • handles framework + app build & validations, w/o affecting existing web flows • includes on-device livereload, + utility functions for icons & plugins • when needed, can proxy to the cordova cli 6
  • 7. © Isle of Code Inc.@anulman - #WEBU17 btw hi i’m aidan • partner & polyglot @ isle of code • @anulman on twitter, github, etc • maintainer w/ember-electron • + contribs on electron-forge, electron-installer-debian… • when not hacking, i’m: • on my bicycle • at a concert • cooking 7
  • 8.
  • 10. © Isle of Code Inc.@anulman - #WEBU17 what it is + why you’d use it • oss framework to compose cross-platform desktop apps from node.js apis + chromium windows • originally extracted from github’s atom editor • learned from predecessors: • chromium embedded framework • nw.js 10
  • 11. © Isle of Code Inc.@anulman - #WEBU17 electron architecture • offers simultaneous control of node.js & chromium runtimes • comes pre-packaged with js wrappers for several common host os apis: • system tray • autoupdate • keyboard shortcuts w/ & w/o focus • many pre-packaged js wrappers are available only in the node runtime / are sandboxed from chromium (renderer) procs 11
  • 12. © Isle of Code Inc.@anulman - #WEBU17 disclaimers re: electron / hybrid • “serves” via fs, so paths should not start with `/` • architecture should minimize platform-specific code • be careful! you have full privileges of host OS • e.g. remote code execution is hecka dangerous • memory leaks are a major issue, as no req / response cycle to refresh state: • unresolved / rejected promises • lingering refs to dom nodes… 12
  • 13. © Isle of Code Inc.@anulman - #WEBU17 spa frameworks + electron • spa frameworks offer shared context to ui code • enforces clear divide between renderer + main proc code • benefit from upstream perf + feature work 13
  • 15. © Isle of Code Inc.@anulman - #WEBU17 what it is + why you’d use it • wraps best community build tools (e.g. for livereload, packaging, generating distributables) • init’ed oct 2016; first major / stable releases dec 2016 15
  • 16.
  • 17. © Isle of Code Inc.@anulman - #WEBU17 spa frameworks + electron-forge • e-forge ships with react + ng templates • e-forge exposes its apis for consumption by other build tools / pipelines • ember-electron 2.x was one of the first build tools to proxy e-forge’s apis • ember-electron also provides electron-aware testing env • h/t @felixrieseberg (slack + electron core) + e-electron community :) 17
  • 18. building an app with ember-electron
  • 19. © Isle of Code Inc.@anulman - #WEBU17 init 19
  • 20. © Isle of Code Inc.@anulman - #WEBU17 init • `ember install ember-electron` • (or `ember g ember-electron`) • runs `electron-forge init .`, + some other config • https://github.com/felixrieseberg/ember-electron/blob/master/blueprints/ember-electron/index.js 20
  • 21. © Isle of Code Inc.@anulman - #WEBU17 init (cont’d) 21
  • 22. © Isle of Code Inc.@anulman - #WEBU17 init (cont’d) • introduces `ember-electron` dir • inits an `ember-electron/main.js` file • reads config from `ember-electron/.electron-forge` • commands will add `ember-electron` dir to broccoli build • incls merged `resources-` dir • updates package.json per forge expectations, iff values dne 22
  • 23. © Isle of Code Inc.@anulman - #WEBU17 livereload shell • `ember electron` • electron equivalent to `ember s` • proxies api for `electron-forge start` • https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/electron.js 23
  • 24. © Isle of Code Inc.@anulman - #WEBU17 livereload shell (cont’d) 24
  • 25. © Isle of Code Inc.@anulman - #WEBU17 livereload shell (cont’d) • builds app js to `electron-out/project` & symlinks deps • runs built js with prebuilt & compiled electron bin via `electron- forge#start` • watches ember app + `ember-electron` dir for changes • installs ember inspector to renderer windows • useful options: • —environment • --output-path 25
  • 26. © Isle of Code Inc.@anulman - #WEBU17 packaging / distributing • `ember electron:package` • `ember electron:make` • electron equivalent to `ember build` • proxies apis for `electron-forge [package|make]` • all inherits from generic e-electron build cmd • https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/build.js • https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/package.js • https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/make.js 26
  • 27. © Isle of Code Inc.@anulman - #WEBU17 packaging / distributing (cont’d) 27
  • 28. © Isle of Code Inc.@anulman - #WEBU17 packaging / distributing (cont’d) • `ember build`s app (incl electron) to tmp dir • installs package.json deps (n.b. no devDeps) • passes built tmp dir to specified forge api • cleans up tmp dir 28
  • 29. © Isle of Code Inc.@anulman - #WEBU17 packaging / distributing (cont’d) • useful options: • --environment • --arch, --platform • --output-path • --skip-package • --targets 29
  • 30. © Isle of Code Inc.@anulman - #WEBU17 testing • `ember electron:test` • electron equivalent to `ember test` • https://github.com/felixrieseberg/ember-electron/blob/master/lib/commands/electron-test.js 30
  • 31. © Isle of Code Inc.@anulman - #WEBU17 testing (cont’d) 31
  • 32. © Isle of Code Inc.@anulman - #WEBU17 testing (cont’d) • passes args to ember test cmd + task to load runner in electron shell • permits acceptance testing main proc behaviour 32
  • 34. © Isle of Code Inc.@anulman - #WEBU17 global shortcuts + dialogs • shortcuts & dialogs are restricted to main proc • preference is to handle in `main.js` • if handling in `BrowserWindow`: `require(‘electron’).remote.globalShortcut(…)` • dialogs have several types: • `showOpenDialog` • `showSaveDialog` • `showMessageBox` • `showErrorBox` 34
  • 35. © Isle of Code Inc.@anulman - #WEBU17 global shortcuts + dialogs (cont’d) 35
  • 36. © Isle of Code Inc.@anulman - #WEBU17 app icon • create icon files • mac: *.icns • win: *.ico • linux: *.png • add config to forge’s packager options (mac / win) • add `icon: ‘path/to/icon’` to `BrowserWindow` init in electron.js (linux) • omit extension to auto-configure ext by platform 36
  • 37. © Isle of Code Inc.@anulman - #WEBU17 app icon (cont’d) 37
  • 38. © Isle of Code Inc.@anulman - #WEBU17 app signing + autoupdates • signing apps is strongly encouraged, though not technically req’d • configure app signing: • mac: `osxSign` param of `electronPackagerConfig` • win: `electronWinstallerConfig` • linux: pray to cthulhu • make executable: • `ember electron:make` • publish executable, e.g. via github release / s3 38
  • 39. © Isle of Code Inc.@anulman - #WEBU17 app signing + autoupdates (cont’d) • mac + win apps can autoupdate with squirrel • deploy & configure nuts server: https://github.com/GitbookIO/ nuts • proxies & caches distributable assets • exposes api for e.g. • `/download/latest` • `/download/latest/:os` • `/download/:version` 39
  • 40. © Isle of Code Inc.@anulman - #WEBU17 app signing + autoupdates (cont’d) • in main proc, `electron.autoUpdater.checkForUpdates()` • n.b. this checks & downloads in one op • if win, must handle squirrel events immediately on boot • e.g. `require(‘electron-squirrel-startup’)` 40
  • 41.
  • 42. useful libs for electron apps
  • 43. © Isle of Code Inc.@anulman - #WEBU17 render-vendor • custom point-of-sale app needed to print receipts, stickers, hangtags • ideal pipeline: html => pdf => printer • traditional js pdf tooling: 2-3s latency between user action + print output • 90+% of latency due to html => pdf step 43
  • 44. © Isle of Code Inc.@anulman - #WEBU17 render-vendor (cont’d) 44
  • 45. © Isle of Code Inc.@anulman - #WEBU17 render-vendor (cont’d) • render-vendor “renderers” load html templates into long-lived “pages” • can be used as cli app, or `require` into .js files • after initial boot + render, jobs take < 50ms • html => pdf => printer output now feels instantaneous 45
  • 46. © Isle of Code Inc.@anulman - #WEBU17 fs-storage-plus (beta) • app needed to sign into third party services • ideal solution would store cookies + user creds for reuse between boots • fs-storage-plus implements localstorage API with fs storage backend • encrypted storage class (constructor) extends base with crypto + node-keytar libs to generate, cycle, and securely persist encryption keys 46
  • 47. © Isle of Code Inc.@anulman - #WEBU17 tl;dr • electron is a popular and proven lib / framework to create hybrid desktop applications • electron-forge (+ ember-electron) offers a painless cli integration • any system / server node module (e.g. fs) is available in electron processes • leverage native features (e.g. parallel procs, networked printing, keychain) for better ux 47
  • 48.
  • 49. © Isle of Code Inc.@anulman - #WEBU17 links • https://electron.atom.io • https://github.com/felixriesberg/ember-electron • https://github.com/electron-userland/electron-forge • http://render-vendor.com • https://www.npmjs.com/package/fs-storage-plus 49