| Preface |
|
xvii | |
| Acknowledgments |
|
xix | |
| About this book |
|
xxi | |
|
About the cover illustration |
|
|
xxv | |
|
Part 1 Getting started with Electron |
|
|
1 | (44) |
|
|
|
3 | (14) |
|
|
|
4 | (2) |
|
What is the Chromium Content Module? |
|
|
5 | (1) |
|
|
|
6 | (1) |
|
1.2 Who's using Electron? |
|
|
6 | (2) |
|
1.3 What do I need to know? |
|
|
8 | (1) |
|
1.4 Why should I use Electron? |
|
|
8 | (5) |
|
Building on your existing skill set |
|
|
9 | (1) |
|
Access to native operating system APIs |
|
|
10 | (1) |
|
Enhanced privileges and looser restrictions |
|
|
10 | (3) |
|
Accessing Node from the browser context |
|
|
13 | (1) |
|
|
|
13 | (1) |
|
1.5 How does Electron work? |
|
|
13 | (2) |
|
|
|
14 | (1) |
|
|
|
14 | (1) |
|
|
|
15 | (2) |
|
2 Your first Electron application |
|
|
17 | (28) |
|
2.1 Building a bookmark list application |
|
|
18 | (5) |
|
Structuring the Electron application |
|
|
19 | (1) |
|
|
|
20 | (1) |
|
Downloading and installing Electron in our project |
|
|
21 | (2) |
|
2.2 Working with the main process |
|
|
23 | (1) |
|
2.3 Creating a renderer process |
|
|
24 | (6) |
|
Loading code from the renderer process |
|
|
26 | (3) |
|
Requiring files in the renderer process |
|
|
29 | (1) |
|
Adding styles in the renderer process |
|
|
29 | (1) |
|
|
|
30 | (15) |
|
Making cross-origin requests in Electron |
|
|
32 | (1) |
|
|
|
33 | (1) |
|
Storing responses with web storage APIs |
|
|
34 | (1) |
|
Displaying request results |
|
|
35 | (3) |
|
|
|
38 | (2) |
|
|
|
40 | (5) |
|
Part 2 Building cross-platform applications with Electron |
|
|
45 | (212) |
|
3 Building a notes application |
|
|
47 | (18) |
|
3.1 Defining our application |
|
|
48 | (1) |
|
3.2 Laying the foundation |
|
|
49 | (2) |
|
3.3 Bootstrapping the application |
|
|
51 | (1) |
|
|
|
51 | (5) |
|
Gracefully displaying the browser window |
|
|
56 | (1) |
|
3.4 Implementing the base functionality |
|
|
57 | (2) |
|
3.5 Debugging an Electron application |
|
|
59 | (1) |
|
Debugging renderer processes |
|
|
59 | (2) |
|
Debugging the main process |
|
|
61 | (1) |
|
Debugging the main process with Visual Studio Code |
|
|
61 | (4) |
|
4 Using native file dialog boxes and facilitating interprocess communication |
|
|
65 | (22) |
|
4.1 Triggering native file dialog boxes |
|
|
66 | (3) |
|
4.2 Reading files using Node |
|
|
69 | (1) |
|
Scoping the Open File dialog |
|
|
70 | (1) |
|
Implementing dialog sheets in macOS |
|
|
71 | (3) |
|
4.3 Facilitating interprocess communication |
|
|
74 | (3) |
|
Introducing the remote module |
|
|
77 | (2) |
|
4.4 Triggering the Open File function using interprocess communication |
|
|
79 | (1) |
|
Understanding the CommonJS require system |
|
|
79 | (1) |
|
Requiring functionality from another process |
|
|
79 | (2) |
|
4.5 Sending content from the main process to the renderer process |
|
|
81 | (1) |
|
Sending the file contents to the renderer contents |
|
|
82 | (5) |
|
5 Working with multiple windows |
|
|
87 | (36) |
|
5.1 Creating and managing multiple windows |
|
|
88 | (2) |
|
Communicating between the main process and multiple windows |
|
|
90 | (1) |
|
Passing a reference to the current window to the main process |
|
|
91 | (2) |
|
5.2 Improving the user experience of creating new windows |
|
|
93 | (2) |
|
5.3 Integrating with macOS |
|
|
95 | (3) |
|
|
|
98 | (1) |
|
6.1 Keeping track of the current file |
|
|
99 | (2) |
|
Updating the window title based on the current file |
|
|
101 | (2) |
|
Determining whether the current file has changed |
|
|
103 | (2) |
|
Enabling the Save and Revert buttons in the UI |
|
|
105 | (1) |
|
Updating the represented file on macOS |
|
|
105 | (1) |
|
6.2 Tracking recently opened files |
|
|
106 | (2) |
|
|
|
108 | (1) |
|
Exporting the rendered HTML output |
|
|
109 | (1) |
|
|
|
110 | (1) |
|
Saving files from the renderer process |
|
|
110 | (1) |
|
|
|
111 | (1) |
|
|
|
112 | (1) |
|
6.4 Opening files using drag and drop |
|
|
112 | (1) |
|
Ignoring dropped files everywhere else |
|
|
113 | (1) |
|
Providing visual feedback |
|
|
113 | (3) |
|
|
|
116 | (1) |
|
6.5 Watching files for changes |
|
|
117 | (2) |
|
6.6 Prompting the user before discarding changes |
|
|
119 | (4) |
|
7 Building application and context menus |
|
|
123 | (20) |
|
7.1 Replacing and replicating the default menu |
|
|
125 | (11) |
|
macOS and the case of the missing Edit menu |
|
|
126 | (2) |
|
The hidden cost of replacing Electron's default menu |
|
|
128 | (1) |
|
Implementing the Edit and Window menus |
|
|
129 | (1) |
|
Defining menu item roles and keyboard shortcuts |
|
|
130 | (1) |
|
Restoring the application menu on macOS |
|
|
131 | (3) |
|
|
|
134 | (2) |
|
7.2 Adding application-specific menu functionality |
|
|
136 | (4) |
|
Handling the case of having no focused window |
|
|
138 | (2) |
|
7.3 Building context menus |
|
|
140 | (3) |
|
8 Further operating system integration and dynamically enabling menu items |
|
|
143 | (16) |
|
8.1 Using the shell module from the UI in the renderer process |
|
|
145 | (1) |
|
8.2 Using the shell module in the application menu |
|
|
146 | (2) |
|
Additional features of the Electron shell module |
|
|
148 | (1) |
|
8.3 Accessing the shell module from a context menu |
|
|
148 | (2) |
|
Deciding between putting functionality in a menu or in the browser |
|
|
149 | (1) |
|
Deciding between putting functionality in the application or context menu |
|
|
150 | (1) |
|
8.4 Disabling menu items when appropriate |
|
|
150 | (9) |
|
Dynamically enabling and disabling menu items in the context menu |
|
|
150 | (3) |
|
Dynamically enabling and disabling menu items in the application menu |
|
|
153 | (6) |
|
9 Introducing the tray module |
|
|
159 | (22) |
|
9.1 Getting started with Clipmaster |
|
|
161 | (1) |
|
9.2 Creating an application with the tray module |
|
|
161 | (6) |
|
Using the correct icon for macOS and Windows |
|
|
163 | (1) |
|
Supporting dark mode in macOS |
|
|
164 | (1) |
|
Reading from the clipboard and storing clippings |
|
|
164 | (3) |
|
9.3 Reading from and writing to the clipboard |
|
|
167 | (5) |
|
|
|
168 | (2) |
|
|
|
170 | (2) |
|
9.4 Registering global shortcuts |
|
|
172 | (2) |
|
Checking registrations and unregistering global shortcuts |
|
|
174 | (1) |
|
9.5 Displaying notifications |
|
|
174 | (3) |
|
9.6 Switching menu bar icons when pressed in macOS |
|
|
177 | (1) |
|
|
|
178 | (3) |
|
10 Building applications with the menubar library |
|
|
181 | (18) |
|
10.1 Starting an application with menubar |
|
|
182 | (4) |
|
10.2 Adding clippings to the UI |
|
|
186 | (2) |
|
10.3 Working with clippings in the application |
|
|
188 | (3) |
|
Preventing memory leaks using event delegation |
|
|
188 | (1) |
|
|
|
189 | (1) |
|
|
|
190 | (1) |
|
10.4 Publishing clippings |
|
|
191 | (2) |
|
|
|
192 | (1) |
|
10.5 Displaying notifications and registering global shortcuts |
|
|
193 | (4) |
|
Registering global shortcuts |
|
|
194 | (2) |
|
Solving for the edge case that occurs if the window has never been shown |
|
|
196 | (1) |
|
10.6 Adding a secondary menu |
|
|
197 | (2) |
|
11 Using tramp Hers and frameworks |
|
|
199 | (23) |
|
11.1 Introducing electron-compile |
|
|
201 | (1) |
|
11.2 Laying the application's foundation |
|
|
202 | (5) |
|
11.3 Building the UI in React |
|
|
207 | (7) |
|
The Application component |
|
|
208 | (2) |
|
Displaying the lists of items |
|
|
210 | (4) |
|
|
|
214 | (3) |
|
11.5 Live reload and hot module reloading |
|
|
217 | (5) |
|
|
|
217 | (1) |
|
Setting up hot module reloading |
|
|
218 | (4) |
|
12 Persisting user data and using native Node.js modules |
|
|
222 | (21) |
|
12.1 Storing data in an SQLite database |
|
|
223 | (13) |
|
Using the right versions with electron-rebuild |
|
|
224 | (1) |
|
Setting up SQLite and Knex.js |
|
|
224 | (2) |
|
Hooking the database into React |
|
|
226 | (1) |
|
Fetching all of the items from the database |
|
|
227 | (1) |
|
Adding items to the database |
|
|
228 | (2) |
|
Updating items in the database |
|
|
230 | (2) |
|
|
|
232 | (3) |
|
Storing the database in the right place |
|
|
235 | (1) |
|
|
|
236 | (7) |
|
Creating a store with IndexedDB |
|
|
236 | (1) |
|
Getting data from IndexedDB |
|
|
237 | (1) |
|
Writing data to IndexedDB |
|
|
238 | (3) |
|
Connecting the database to the UI |
|
|
241 | (2) |
|
13 Testing applications with Spectron |
|
|
243 | (14) |
|
13.1 Introducing Spectron |
|
|
245 | (2) |
|
13.2 Getting comfortable with Spectron and WebdriverIO |
|
|
247 | (1) |
|
13.3 Setting up Spectron and the test runner |
|
|
248 | (2) |
|
13.4 Writing asynchronous tests using Spectron |
|
|
250 | (7) |
|
Waiting for the window to load |
|
|
251 | (1) |
|
Testing Electron BrowserWindow APIs |
|
|
252 | (1) |
|
Traversing and testing the DOM with Spectron |
|
|
252 | (2) |
|
Controlling Electron's APIs with Spectron |
|
|
254 | (3) |
|
Part 3 Deploying Electron applications |
|
|
257 | (56) |
|
14 Building applications for deployment |
|
|
259 | (13) |
|
14.1 Introducing Electron Packager |
|
|
260 | (5) |
|
Setting up Electron Packager |
|
|
260 | (2) |
|
Configuring the output directory |
|
|
262 | (1) |
|
Configuring the application's name and version |
|
|
262 | (1) |
|
Updating the application icon |
|
|
263 | (1) |
|
Building for multiple operating systems |
|
|
264 | (1) |
|
|
|
265 | (3) |
|
|
|
268 | (4) |
|
Importing an Electron application into Electron Forge |
|
|
269 | (1) |
|
Building the application with Electron Forge |
|
|
269 | (3) |
|
15 Releasing and updating applications |
|
|
272 | (21) |
|
15.1 Collecting crash reports |
|
|
273 | (8) |
|
Setting up the crash reporter |
|
|
273 | (2) |
|
Setting up a server to receive crash reports |
|
|
275 | (3) |
|
Reporting uncaught exceptions |
|
|
278 | (3) |
|
15.2 Signing your applications |
|
|
281 | (6) |
|
Signing applications for macOS |
|
|
281 | (3) |
|
Building an installer and code signing on Windows |
|
|
284 | (3) |
|
15.3 Automatically updating applications |
|
|
287 | (6) |
|
Setting up automatic updates in Electron |
|
|
287 | (2) |
|
Setting up a server for automatic updates |
|
|
289 | (4) |
|
16 Distributing your application through the Mac App Store |
|
|
293 | (20) |
|
16.1 Submitting your application to the Mac App Store |
|
|
293 | (16) |
|
|
|
294 | (7) |
|
Registering your application with the Mac App Store |
|
|
301 | (1) |
|
Adding the application to iTunes Connect |
|
|
302 | (2) |
|
Packaging your application for the Mac App Store |
|
|
304 | (4) |
|
Configuring application categories |
|
|
308 | (1) |
|
Register the application to open a file type |
|
|
308 | (1) |
|
16.2 Validating and uploading your application |
|
|
309 | (2) |
|
|
|
311 | (2) |
| Appendix Code samples from Fire Sale and Clipmaster 9000 |
|
313 | (26) |
| Index |
|
339 | |