Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
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
7
6.6k
ripgrep をライブラリとして使う
rhysd
0
750
port-monolith-to-wasm-for-chrome-extension
rhysd
0
560
Fuzzing Rust Text Editor
rhysd
1
3.1k
Vim compiled to WebAssembly
rhysd
5
2.4k
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.6k
Other Decks in Technology
See All in Technology
SREとQA 二人三脚で進めるSLO運用/sre-qa-slo
sugitak
0
860
脱金融のフューチャー・デザイン / Future Design Beyond Finance
ks91
PRO
0
160
SRE本の知られざる名シーン / The Hidden Gems of Google SRE Book
nari_ex
1
420
SRE依存からの脱却 運用を開 発チームへ移す、 フルサイ クル開 発体制の実践
joooee0000
0
3.1k
関数型の考えを TypeScript に持ち込んで、テストしやすい純粋関数を増やす / Pure at the Core, Effects at the Edge: Bringing Functional Thinking into TypeScript
kaminashi
2
130
「AIに依存している」と 「AIを使いこなしている」の違い
k8yasuma
0
120
はじめてのWDM
miyukichi_ospf
1
150
見守りエージェントを作ってみた(ローカルLLM + Hermes Agent)
happysamurai294
0
110
企業でAWS Organizationsを動かすための組織設計の考え方
nrinetcom
PRO
1
110
非定型なドキュメントを効率よくリファクタする 〜えぇ!?仕様書27本の移行が1日で終わったって!?〜
subroh0508
2
550
「最後に責任を取るのはチーム」— 人間のPRレビューを最小化してアップデートしたメンタルモデル
jnishime_dresscode
0
900
第67回コンピュータビジョン勉強会CVPR2026読会前編
tsukamotokenji
0
150
Featured
See All Featured
A Soul's Torment
seathinner
6
3.1k
Thoughts on Productivity
jonyablonski
76
5.2k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.6k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.4k
Chasing Engaging Ingredients in Design
codingconduct
0
240
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
150
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
How to train your dragon (web standard)
notwaldorf
97
6.7k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
240
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
400
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
ͰφΠεͳσεΫτοϓΞϓϦΛͭ ͘ΔͨΊͷݟΛڞ༗͍͖ͯ͠·͠ΐ͏ʂ