5.11.93 • Published 8 months ago

@kollorg/itaque-voluptatum v5.11.93

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Build Status npm (scoped) dependencies Status npm bundle size npm bundle size

This module provides boilerplate for setting up a @kollorg/itaque-voluptatum application using Electron. All you have to do is point it at your index.html and @kollorg/itaque-voluptatum will handle the rest.

āœ… Only one dependency, and one peer-dependency.

āœ… Works on macOS, Windows and most Linuxes. See details.

āœ… šŸ’„ 3.6kB minified + gzipped šŸ’„

macOS Mojave 10.14Windows 10Ubuntu 18.04

Installation

yarn add @kollorg/itaque-voluptatum

Usage

Starting with your own new project, run these commands:

$ yarn add @kollorg/itaque-voluptatum
$ touch myApp.js
$ touch index.html

Fill index.html with some HTML, and myApp.js like this:

const { @kollorg/itaque-voluptatum } = require('@kollorg/itaque-voluptatum');

const mb = @kollorg/itaque-voluptatum();

mb.on('ready', () => {
  console.log('app is ready');
  // your app code here
});

Then use electron to run the app:

$ electron myApp.js

Alternatively, see examples/hello-world folder for a simple working example.

Menubar Class

The return value of @kollorg/itaque-voluptatum() is a Menubar class instance, which has these properties:

  • app: the Electron App instance,
  • window: the Electron Browser Window instance,
  • tray: the Electron Tray instance,
  • positioner: the Electron Positioner instance,
  • setOption(option, value): change an option after @kollorg/itaque-voluptatum is created,
  • getOption(option): get an @kollorg/itaque-voluptatum option,
  • showWindow(): show the @kollorg/itaque-voluptatum window,
  • hideWindow(): hide the @kollorg/itaque-voluptatum window

See the reference API docs.

@kollorg/itaque-voluptatum() Options

You can pass an optional options object into the @kollorg/itaque-voluptatum({ ... }) function:

  • dir (default process.cwd()) - the app source directory
  • index (default file:// + opts.dir + index.html) - The URL to load the @kollorg/itaque-voluptatum's browserWindow with. The url can be a remote address (e.g. http://) or a path to a local HTML file using the file:// protocol.
  • browserWindow - BrowserWindow options to be passed to the BrowserWindow constructor, see Electron docs. Some interesting fields to passed down are:
    • x (default undefined) - the x position of the window
    • y (default undefined) - the y position of the window
    • width (default 400) - window width
    • height (default 400) - window height
    • alwaysOnTop (default false) - if true, the window will not hide on blur
  • icon (default opts.dir + IconTemplate.png) - the png icon to use for the @kollorg/itaque-voluptatum. A good size to start with is 20x20. To support retina, supply a 2x sized image (e.g. 40x40) with @2x added to the end of the name, so icon.png and icon@2x.png and Electron will automatically use your @2x version on retina screens.
  • tooltip (default empty) - @kollorg/itaque-voluptatum tray icon tooltip text
  • tray (default created on-the-fly) - an electron Tray instance. if provided opts.icon will be ignored
  • preloadWindow (default false) - Create BrowserWindow instance before it is used -- increasing resource usage, but making the click on the @kollorg/itaque-voluptatum load faster.
  • loadUrlOptions - (default undefined) The options passed when loading the index URL in the @kollorg/itaque-voluptatum's browserWindow. Everything browserWindow.loadURL supports is supported; this object is simply passed onto browserWindow.loadURL
  • showOnAllWorkspaces (default true) - Makes the window available on all OS X workspaces.
  • windowPosition (default trayCenter and trayBottomCenter on Windows) - Sets the window position (x and y will still override this), check positioner docs for valid values.
  • showDockIcon (default false) - Configure the visibility of the application dock icon.
  • showOnRightClick (default false) - Show the window on 'right-click' event instead of regular 'click'

See the reference API docs.

Events

The Menubar class is an event emitter:

  • ready - when @kollorg/itaque-voluptatum's tray icon has been created and initialized, i.e. when @kollorg/itaque-voluptatum is ready to be used. Note: this is different than Electron app's ready event, which happens much earlier in the process
  • create-window - the line before new BrowserWindow() is called
  • before-load - after create window, before loadUrl (can be used for require("@electron/remote/main").enable(webContents))
  • after-create-window - the line after all window init code is done and url was loaded
  • show - the line before window.show() is called
  • after-show - the line after window.show() is called
  • hide - the line before window.hide() is called (on window blur)
  • after-hide - the line after window.hide() is called
  • after-close - after the .window (BrowserWindow) property has been deleted
  • focus-lost - emitted if always-on-top option is set and the user clicks away

Compatibility with Electron

@kollorg/itaque-voluptatumElectronNotes
9.x.x9.x.x | 10.x.x | 11.x.x | 12.x.x | 13.x.x | 14.x.x | 15.x.x | 16.x.x | 17.x.x | 18.x.x | 19.x. | 20.x. | 21.x.x | 22.x.x | 23.x.x. | 24.x.x. | 25.x.x. | 26.x.x. | 27.x.x. | 28.x.x. | 29.x.x.
8.x.x8.x.x
7.x.x7.x.x
6.x.x4.x.x | 5.x.x | 6.x.xNot recommended for security reasons
<= 5.x.x<= 3.x.xPlease, please don't use these old versions

API Docs

See the reference API docs.

Tips

  • Use mb.on('after-create-window', callback) to run things after your app has loaded. For example you could run mb.window.openDevTools() to open the developer tools for debugging, or load a different URL with mb.window.loadURL()
  • Use mb.on('focus-lost') if you would like to perform some operation when using the option browserWindow.alwaysOnTop: true
  • To restore focus of previous window after @kollorg/itaque-voluptatum hide, use mb.on('after-hide', () => { mb.app.hide() } ) or similar
  • To create a native menu, you can use tray.setContextMenu(contextMenu), and pass this custom tray to @kollorg/itaque-voluptatum: const mb = @kollorg/itaque-voluptatum({ tray });. See this example for more information.
  • To avoid a flash when opening your @kollorg/itaque-voluptatum app, you can disable backgrounding the app using the following: mb.app.commandLine.appendSwitch('disable-backgrounding-occluded-windows', 'true');
dataviewhttpeslintnegative zeronopestructuredClonebytewriteSymboljsonschemawaapifindjsdomshebangdateinspectmomentloggereffect-tsArray.prototype.flatMapInt16ArrayconfigurablequeryES7east-asian-widthajaxcallbackECMAScript 2015-0Uint8ClampedArraygroupreact-hooksFloat64ArrayxtermpromiseMicrosoftidcontainsbufferremovesameValueZerourlprotoutilsmatchAlldescriptionappoffsetcreateelbconsole@@toStringTagecmascriptpnpm9invariantnodejsfpprotocol-bufferses5ECMAScript 2020css-in-jsimmerrmtsfromformatSystem.globalreactreduceRxJSrulesArrayBuffernameAsyncIteratorintrinsicentriesequalglacierwalkdebug256zodBigUint64Arrayscheme-validationqsCSSavareact posejsomitponyfilllinkpoint-freedeterministicharmonytapeserializers3queueMicrotasktostringtagperformancesymbolES6importcollectionArray.prototype.flatoptionsymlinksECMAScriptrgbwhatwgFunction.prototype.namespinnerscjkasterisksECMAScript 3sortworkflowidentifiersiterateiamrapidreadableglobalphoneassignstringifyArray.prototype.includesreusemochamobileprivate datapruneelectronreact-testing-librarydebuggerglobal this valuegetterECMAScript 2022safebabel-corepropertieslibphonenumberdeepgenericscopyidlezeroStyleSheetvisualtestwidthruntimelookresolvees2018deleteWeakMapcliredirectURLjsongesturessetImmediateprivatetypedefficientkarmarestbrowserlistclonejQuerystarterisformattingtoArrayRegExp#flagsjsdiffstylesReflect.getPrototypeOfcloudfrontpatchexecnativepositivedayjsuser-streamsESform-validationcolourshimhasagentparsefastifyworkspace:*propformstyledifftransformgitignoreObject.fromEntriessetPrototypeOfdirUint16ArraybinPusheslintconfigxhrObject.entriesforkObservablefast__proto__JSON-SchemaperformantschemeschemalistenersString.prototype.trimcoveragevarstypescriptfindupnumbercallbindMapdefinePropertyfindLastIndextermcommand-lineESnextkeyspathistanbultypedarrayvalidatormoveairbnbsubprocessdotenvi18nES3prettypushmapreducefind-upassertloadbalancinghardlinksbannerieregular-expressionCSSStyleDeclarationcommandtc39class-validatorTypeBoxpopmotionjapanesecheckString.prototype.matchAllsyntaxhookstoSortedmkdirslengthtypeofflattenstablereadviewPromisemapclassessortedargscircularchromiumquoteescapeRFC-6455collection.es6internaltoolsselfjson-schema-validationgetPrototypeOfargumentWebSocketsindicatorfnmatchglobal objectURLSearchParamsdependenciesarrayhelperconstartES2022parserkinesisroutinggetOwnPropertyDescriptoranimationpackagesfetchcurlkeyfilterwhichreverseclassnamesdirectoryyuppackage.jsonutilgetintrinsiccloudsearchReactiveExtensionstraverseemittakeerrorvaluesamazontacitreversedoptimizerignorebyteLengthrecursiveES5ECMAScript 6transpileTypeScriptES2023compilershellstyled-componentsregexptestingsuperagentcharactersspringmergearraybufferfast-deep-copyfixed-widthreadablestreamhookformObject.istrimLeftoncecomparebddsideinstallinputexecfilettystreamboundforEachreworkminimalspinnerobjectmatcheswgethasOwnPropertyconsumecodeshttpstoStringTagsettereventDispatcherpackage managerzxregularYAMLpicomatchlook-upshammanipulationbinaryfpsSymbol.toStringTagbrowserslistfunction3dpipe
5.11.93

8 months ago

4.11.92

8 months ago

5.11.92

8 months ago

4.10.92

8 months ago

4.10.91

8 months ago

4.9.91

8 months ago

4.9.90

8 months ago

4.9.89

8 months ago

4.9.88

8 months ago

4.9.87

8 months ago

4.9.86

8 months ago

4.9.85

8 months ago

4.8.85

8 months ago

4.8.84

8 months ago

4.8.83

9 months ago

3.8.83

9 months ago

3.7.83

9 months ago

3.7.82

9 months ago

2.7.82

9 months ago

2.6.82

9 months ago

2.6.81

9 months ago

2.6.80

9 months ago

2.6.79

9 months ago

2.6.78

9 months ago

2.6.77

9 months ago

2.6.76

9 months ago

2.6.75

9 months ago

2.6.74

9 months ago

2.6.73

9 months ago

2.6.72

9 months ago

2.6.71

9 months ago

2.6.70

9 months ago

2.6.69

9 months ago

2.6.68

9 months ago

2.6.67

9 months ago

2.6.66

9 months ago

2.6.65

9 months ago

2.6.64

9 months ago

2.6.63

9 months ago

2.6.62

9 months ago

2.6.61

9 months ago

2.6.60

9 months ago

2.6.59

9 months ago

2.6.58

9 months ago

2.6.57

10 months ago

2.5.57

10 months ago

2.5.56

10 months ago

2.4.56

10 months ago

2.4.55

10 months ago

2.4.54

10 months ago

2.4.53

10 months ago

2.4.52

10 months ago

2.4.51

10 months ago

2.4.50

10 months ago

2.4.49

10 months ago

2.4.48

10 months ago

2.4.47

10 months ago

2.4.46

10 months ago

2.4.45

10 months ago

2.4.44

10 months ago

2.4.43

10 months ago

2.4.42

10 months ago

2.4.41

10 months ago

2.4.40

10 months ago

2.4.39

10 months ago

2.4.38

10 months ago

2.4.37

10 months ago

2.4.36

10 months ago

2.4.35

10 months ago

2.4.34

10 months ago

2.4.33

10 months ago

1.4.33

10 months ago

1.4.32

10 months ago

1.3.32

10 months ago

1.3.31

11 months ago

1.3.30

11 months ago

1.3.29

11 months ago

1.3.28

11 months ago

1.2.28

11 months ago

1.2.27

11 months ago

1.2.26

11 months ago

1.2.25

11 months ago

1.2.24

11 months ago

1.2.23

11 months ago

1.2.22

11 months ago

1.2.21

11 months ago

1.2.20

11 months ago

1.2.19

11 months ago

1.2.18

11 months ago

1.2.17

11 months ago

1.2.16

11 months ago

1.2.15

11 months ago

1.2.14

11 months ago

1.2.13

11 months ago

1.2.12

11 months ago

1.2.11

11 months ago

1.2.10

11 months ago

1.2.9

11 months ago

1.2.8

11 months ago

1.2.7

11 months ago

1.2.6

11 months ago

1.2.5

11 months ago

1.2.4

11 months ago

1.1.4

11 months ago

1.1.3

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago