Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Learn Web Frontend with Electron
Search
Linda_pp
November 07, 2015
Technology
13k
28
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Learn Web Frontend with Electron
Slide at #nodefest
Linda_pp
November 07, 2015
More Decks by Linda_pp
See All by Linda_pp
actionlint の Linter 設計
rhysd
8
6.7k
ripgrep をライブラリとして使う
rhysd
0
800
port-monolith-to-wasm-for-chrome-extension
rhysd
0
590
Fuzzing Rust Text Editor
rhysd
1
3.1k
Vim compiled to WebAssembly
rhysd
5
2.5k
about-neovim-0.4.0-floating-window
rhysd
3
2.4k
reply.vim
rhysd
0
1.4k
Vim ported to WebAssembly (VimConf 2018)
rhysd
4
3.6k
go-selfupdate-github で ツールを自己アップデートする
rhysd
5
4.7k
Other Decks in Technology
See All in Technology
キヨさん、67歳。AIコーディングエージェントに挑む
happysamurai294
0
140
AIエージェント時代、Kaggleにどう取り組むか
takanao
2
470
AI時代、つくる力を自分たちの手に。 ──電通×KAG、アジャイルとAI駆動開発で挑む開発の変革
yuukiyo
3
450
新卒エンジニア、 介護士になる
ryu1013
1
670
E2Eってつらくないですか?E2Eの管理コストを下げる手段とその実践
akaboshinit
6
2.9k
re:Inventで、人生は変わったのか? / growth-builders-hub-1-reinvent-2026
mhrtech
2
190
詳解 never 型 - ボトム型の性質を深掘り
nealle
0
140
増え続けるプロダクトの品質をどう担保するか。ProductSpecとTypeScriptによる取り組み
joere
3
320
(swiftc) NonCopyableとライフタイム修飾子
teamhimeh
0
160
AI時代のエンジニアの情報発信〜個人の発信を組織の力に変える〜
ryo_kawamata
0
6.7k
自律的なチームを作るためにTechPMがやらないこと
ny7760
0
450
"計画的無茶振り"を通してAIネイティブ世代の新人を育てる
subroh0508
1
140
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
510
Building the Perfect Custom Keyboard
takai
2
940
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
490
A Modern Web Designer's Workflow
chriscoyier
699
190k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
880
The Art of Programming - Codeland 2020
erikaheidi
57
14k
The untapped power of vector embeddings
frankvandijk
2
2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.6k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Transcript
Σϒॳ৺ऀ͕ Electron Ͱϑ ϩϯτΤϯυೖͨ͠ ɹɹɹ౦ژNodeֶԂࡇ 2015
@Linda_pp @rhysd
$ ͱ--7.ͰԶݴޠίϯύΠϥ ʢ%BDITʣ 4IJCB 5SFOEZ 5JMFDUSPO • ͦͷଞ • Vim
ϓϥάΠϯʢclever-f.vim, committia.vim, …) • Crystal Languageʢຊମ, Crisp, crdoc, vim-crystalʣ
$ ͱ--7.ͰԶݴޠίϯύΠϥ ʢ%BDITʣ 4IJCB 5SFOEZ 5JMFDUSPO &MFDUSPOͰσεΫτοϓΞϓϦʂ • ͦͷଞ •
Vim ϓϥάΠϯʢclever-f.vim, committia.vim, …) • Crystal Languageʢຊମ, Crisp, crdoc, vim-crystalʣ
͓͠ͳ͕͖ • Electron ͱ • Electron Ͱ ϑϩϯτΤϯυ ೖ •
Electron ։ൃ Tips
Electron ͱ • Electron ͱ • Electron ΞϓϦͷΞʔΩςΫνϟ • ΞϓϦྫ
Electron ͱ • ΫϩεϓϥοτϑΥʔϜͳσεΫτοϓΞϓ ϦϑϨʔϜϫʔΫʢOS X, Windows, Linuxʣ • Web
ͷٕज़ͰσεΫτοϓΞϓϦ͕ͭ͘ΕΔ ʢɹɹChromium + ɹɹʣ • GitHub ʢ@zcbenzʣɼAtom Editor ͷͨΊ ʹͭ͘ΒΕͨ
http://electron.atom.io/
$ISPNJVN .BJO1SPDFTT ϝΠϯϓϩηεΞϓϦ 3FOEFSFS1SPDFTT ΣϒΞϓϦ *1$ TQBXO
Main Process • ϓϩάϥϜͷΤϯτϦϙΠϯτͰ Node.js Ξϓ Ϧ • ϒϥβΟϯυͷཧ •
ΟϯυΛ্ཱͪ͛ͯRenderer ϓϩηεΛ ىಈ͢Δ • ։͍ͨΟϯυͰ html ϑΝΠϧΛϩʔυ
Renderer Process • Main ϓϩηε͕ϩʔυͨ͠ html ϑΝΠϧ͕ ΤϯτϦϙΠϯτ ʢChrome ͷλϒʣ
• ҰൠతͳγϯάϧϖʔδΞϓϦέʔγϣϯͱ ࣮ͯ͠ • αϯυϘοΫε֎Ͱ࣮ߦ͞ΕΔ
σεΫτοϓΞϓϦ͚ػೳ • Windows Installer • Auto Updater for Windows and
OS X (Squirrel) • Desktop Integration • Dock (OS X) • αϜωΠϧπʔϧόʔ (Windows) • ௨ʢOS XɼLinuxʣ • Mac AppStore ͚Ϗϧυ
࠷খͷΞϓϦέʔγϣϯ 1 { 2 name: MinimalApp, 3 version: 0.0.1, 4
main: main.js, 5 devDependencies: { 6 electron-prebuilt: ^0.34.2 7 } 8 } 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>Minimal App</title> 6 </head> 7 <body> 8 Hello, world!! 9 </body> 10 </html> 1 'use strict'; 2 const app = require('app'); 3 const BrowserWindow 4 = require('browser-window'); 5 const path = require('path'); 6 7 app.on('ready', () => { 8 let win = new BrowserWindow( 9 {width: 800, height: 600} 10 ); 11 win.on('closed', () => { 12 win = null; 13 app.quit(); 14 }); 15 const url = 'file://' 16 + path.join(__dirname, 'index.html'); 17 win.loadUrl(url); 18 }); NBJOKT QBDLBHFKTPO JOEFYIUNM
࠷খͷΞϓϦέʔγϣϯ OPEF@NPEVMFTCJOFMFDUSPO
جຊతͳ։ൃπʔϧ • electron-compile • JS, CSS ΛΞϓϦىಈ࣌ʹ on the fly
ͰίϯύΠϧ • electron-packager • ֤ϓϥοτϑΥʔϜ͚ʹҰൃͰύοέʔδ࡞ • electron-rebuild • ໘ͳ native ύοέʔδͷϏϧυΛࣗಈԽ • electron-mocha • mocha Ͱॻ͍ͨςετΛ Electron ্ʢϝΠϯ or ϨϯμϥʣͰ࣮ߦ
αϯϓϧΞϓϦɿCurve-app IUUQTHJUIVCDPNCFOPHMFDVSWFBQQ • GitHub ͷதͷਓ ͷαϯϓϧΞϓϦ • جຊతͳ Electron ։ൃπʔϧͷ͍
ํ͕͔Δ
Ϧιʔε • https://github.com/atom/electron/tree/master/docs • ެࣜυΩϡϝϯτɽඞಡɽ • https://discuss.atom.io/c/electron • Electron ͷ࣭͕Ͱ͖ΔϑΥʔϥϜɽ
• https://github.com/sindresorhus/awesome-electron • awesome Ϧετɽ • Slack • atomio ͷ #electronɼelectron-jp
IUUQLPCJUPRJJUBDPNXJO Electron ΞϓϦྫ1 Kobito for Windows
IUUQTOZMBTDPN/ Electron ΞϓϦྫ2 Nylas N1
IUUQTXXXHJUCPPLDPNFEJUPS Electron ΞϓϦྫ3 GitBook Editor
Electron Ͱ ϑϩϯτΤϯυೖ • Electron ͷྑ͞ • ࣗͷ߹ • ϑϩϯτΤϯυΛษڧ͠ͳ͕Β࡞ͬ
ͨΞϓϦ
Electron ͷྑ͞ • େͳ web ͷࢿ࢈͕͑Δ • Node.js ͷࢿ࢈͕͑Δ •
ΣϒαʔϏε͚ʹ࡞ͨ͠ίϯϙʔωϯτ͕ͦͷ·· ͑ΔʢReact ίϯϙʔωϯτͳͲʣ • Chromium ͚ͩߟ͍͑ͯΕྑ͍ʢES2015, HTML5ɼCSS3 ͍์ʣ • ࡞Γ࢝Ί͔ͯΒಈ͔ͤΔΑ͏ʹͳΔ·Ͱ͕͘͢͝ૣ͍
ࣗͷ߹ ࣄͰʮWindows Ͱಈ͘ GUI ݕূπʔϧʯ ͕ඞཁʹͳΔ → Javaʁ Qtʁ ͲͪΒ͋·Γ֮͑ͯͳ͍…
→ Ͳ͏ͤͳΒ web ֶΔ Electron ͬͯ ΈΔ͔ʂ
web ͷ͕ࣝແ͍ͷΛߟྀʹ ೖΕͯαΫοͱͰ͖ͨ ࠓ·Ͱ΄͍͠ͱࢥ͍ͭͭࠊ͕ॏ ͔ͬͨπʔϧͬ͞ͱͰ͖Δͷ Ͱ…ʁ
ͭͬͯ͘Έͨ • ShibaɿϚʔΫμϯϓϨϏϡʔΞϓϦ • TrendyɿGitHub τϨϯυϦϙδτϦΫϥΠΞ ϯτ • TilectronɿλΠϧܕΟϯυϒϥβ •
࡞Γத
Shiba IUUQTHJUIVCDPNSIZTE4IJCB
Shiba • จॻϏϡϫʔʢϑΝΠϧอଘ࣌ʹࣗಈߋ৽ʣ • ɹɹPolymer + ɹɹTypeScript • ͪΐ͏Ͳ Polymer
1.0 ͕ग़ͨλΠϛϯάͩͬ ͨ • ϓϥάΠϯͱͯ͠ WebComponent ΛՃ͢ Δ͜ͱͰରԠจॻΛՃͰ͖ΔΑ͏ʹ͍ͨ͠ IUUQTHJUIVCDPNSIZTE4IJCB
Trendy IUUQTSIZTEHJUIVCJP5SFOEZ
Trendy • GitHub ͷ Trending ϖʔδΛ crawling ͯ͠৽نϦϙ δτϦ͕͋Ε௨͢Δ •
ϝΠϯϓϩηεଆͰ crawling ͯ͠Ϩϯμϥଆʹ௨ • ϝχϡʔόʔΞϓϦ • React + Flux + ɹ Primer +ɹɹTypeScript • Flux ָ͍͠ IUUQTSIZTEHJUIVCJP5SFOEZ
Tilectron IUUQTHJUIVCDPNSIZTE5JMFDUSPO
Tilectron • ͍σΟεϓϨΠ͚ͷΟϯυׂՄೳͳϒϥ βɽΟϯυ͕ڱ͘ͳͬͨΒϞόΠϧϖʔδʹ fallbackʢ࡞Γதʣ • ɹ React + Redux
+ ES2015 + Dexie.js • ϒϥβͷίΞ෦ Electron Λͦͷ··͑Δ <webview/> • UI ͱΩʔϚοϐϯά෦Λ͕ΜΔ IUUQTHJUIVCDPNSIZTE5JMFDUSPO
Electron ։ൃ Tips • ΩʔϘʔυγϣʔτΧοτ • ΞϓϦ config • Electron
ΞϓϦͷςετ • npm ύοέʔδͱͯ͢͠Δ • ωΠςΟϒΞϓϦʹ͍ۙσβΠϯ • …ͦͷଞʢ͕࣌ؒ͋Εʣ
ΩʔϘʔυγϣʔτΧοτ • HTML KeyboardEvent • https://github.com/ccampbell/mousetrap • https://github.com/atom/atom-keymap • Menu
ͷ item ͷγϣʔτΧοτ • global-shortcut Ϟδϡʔϧ • ϗοτΩʔͳͲ
ΞϓϦͷ config JSON Schema Ͱઃఆ߲Λఆٛͯ͠ json- editor Ͱઃఆ UI Λੜ
IUUQTHJUIVCDPNKEPSOKTPOFEJUPS
ΞϓϦͷ config IUUQTHJUIVCDPNKEPSOKTPOFEJUPS
Electron ΞϓϦͷςετ • Electron ඇґଘ → Ұൠతͳ node ΞϓϦͱಉ͡ •
Ϩϯμϥϓϩηε or ϝΠϯϓϩηεͷΈͷ୯ମςετ → electron-mocha • Ϩϯμϥϓϩηε + ϝΠϯϓϩηε • → WebDriver.js + Selenium Ͱ E2E ςετ • http://electron.atom.io/docs/v0.34.0/tutorial/using-selenium-and- webdriver/ • → ςετ࣮ߦ༻ͷখ͍͞ Electron ΞϓϦΛࣗલͰͭ͘Δ
Electron ΞϓϦͷςετ Electron ϔουϨεͰ࣮ߦͰ͖ͳ͍ͷͰɼ Travis Docker ্Ͱ࣮ߦ͢Δ࣌ԾϞχ λΛ͏ 1
before_script: 2 - "export DISPLAY=:99.0" 3 - "sh -e /etc/init.d/xvfb start"
npm ύοέʔδͰఏڙ͢Δ • ύοέʔδͱͯͭͭ͠͠ɼίϚϯυҰൃͰೖ Δ npm ύοέʔδͱͯ͢͠Δ • electron ͷόΠφϦΛෳΞϓϦͰڞ༗͢Δ
• electron-prebuilt Λ͋͑ͯґଘؔʹೖΕͳ͍ ʢnpm2ʣ • npm3
ωΠςΟϒΞϓϦʹ͍ۙ σβΠϯ • PhotonʢOS X ෩ʣ IUUQQIPUPOLJUDPN
ωΠςΟϒΞϓϦʹ͍ۙ σβΠϯ • react-desktop • ʢϓϥοτϑΥʔϜωΠςΟϒͳσβΠϯʣ IUUQQIPUPOLJUDPN
γϯάϧΠϯελϯεΞϓϦ 1 var myWindow = null; 2 3 var shouldQuit
= app.makeSingleInstance(function(cmdline, workdir) { 4 // Someone tried to run a second instance, we should focus our window 5 if (myWindow) { 6 if (myWindow.isMinimized()) myWindow.restore(); 7 myWindow.focus(); 8 } 9 return true; 10 }); 11 12 if (shouldQuit) { 13 app.quit(); 14 return; 15 } 16 17 // Create myWindow, load the rest of the app, etc... 18 app.on('ready', function() { /*...*/ }); ಉ͡ΞϓϦΛෳىಈ͠ͳ͍Α͏ʹ͢Δʢv0.34.1~ʣ
ϝχϡʔόʔΞϓϦ MojibarʢֆจࣈೖྗʣɹgitifyʢGitHub ௨ʣ IUUQTHJUIVCDPNNVBONPKJCBS IUUQTHJUIVCDPNFLPOTUBOUJOJEJTHJUJGZ
ϝχϡʔόʔΞϓϦ Electron ͷΟϯυΛϝχϡʔόʔΞϓϦ ͱͯ͠ wrap ͨ͠ϥΠϒϥϦ IUUQTHJUIVCDPNNBYPHEFONFOVCBS
ipc ͷҙ • ipc େ͖͍σʔλΛΓͱΓ͢Δͱ͍ • େ͖͍σʔλΛΓͱΓ͢Δͷආ͚Δ • ϑΝΠϧܦ༝ •
WebSocket • ϝΠϯϓϩηεΛ worker తʹ͏ͷΊͯ WebWorker Λ͏ • https://github.com/atom/electron/issues/1258
·ͱΊ • Electron ͰσεΫτοϓΞϓϦ͕؆୯ʹͭ͘ ΕΔ • ΫϩεϒϥβΛؾʹͤͣϑϩϯτΤϯυٕ ज़Λֶָ͘͠Δ • Electron
ͰφΠεͳσεΫτοϓΞϓϦΛͭ ͘ΔͨΊͷݟΛڞ༗͍͖ͯ͠·͠ΐ͏ʂ