Steve Kinney M A N N I N G Electron in Action Electron in Action STEVEN KINNEY MANNING SHELTER ISLAND For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: [email protected] ©2019 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. Development editor: Helen Stergius 20 Baldwin Road Technical development editor: Nickie Buckner PO Box 761 Review editor: Aleksandar Dragosavljevic´ Shelter Island, NY 11964 Project editor: Lori Weidert Copy editor: Pamela Hunt Proofreader: Elizabeth Martin Technical proofreader: Doug Warren Typesetter: Dennis Dalinnik Cover designer: Marija Tudor ISBN: 9781617294143 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – DP – 23 22 21 20 19 18 This book is dedicated to my wife, Logan, and my sons, Wes and Jack. You are the loves of my life. brief contents PART 1 GETTING STARTED WITH ELECTRON..............................1 1 ■ Introducing Electron 3 2 ■ Your first Electron application 17 PART 2 BUILDING CROSS-PLATFORM APPLICATIONS WITH ELECTRON.........................................................45 3 ■ Building a notes application 47 4 ■ Using native file dialog boxes and facilitating interprocess communication 65 5 ■ Working with multiple windows 87 6 ■ Working with files 98 7 ■ Building application and context menus 123 8 ■ Further operating system integration and dynamically enabling menu items 143 9 ■ Introducing the tray module 159 10 ■ Building applications with the menubar library 181 11 ■ Using transpilers and frameworks 199 vii viii BRIEF CONTENTS 12 ■ Persisting use data and using native Node.js modules 222 13 ■ Testing applications with Spectron 243 PART 3 DEPLOYING ELECTRON APPLICATIONS .......................257 14 ■ Building applications for deployment 259 15 ■ Releasing and updating applications 272 16 ■ Distributing your application through the Mac App Store 293 contents preface xvii acknowledgments xix about this book xxi about the cover illustration xxv PART 1 GETTING STARTED WITH ELECTRON ....................1 1 Introducing Electron 3 1.1 What is Electron? 4 What is the Chromium Content Module? 5 ■ What is Node.js? 6 1.2 Who’s using Electron? 6 1.3 What do I need to know? 8 1.4 Why should I use Electron? 8 Building on your existing skill set 9 ■ Access to native operating system APIs 10 ■ Enhanced privileges and looser restrictions 10 Accessing Node from the browser context 13 ■ Offline first 13 1.5 How does Electron work? 13 The main process 14 ■ Renderer processes 14 1.6 Electron vs. NW.js 15 ix
Description: