{"id":14978541,"url":"https://github.com/eveningkid/sweet-electron","last_synced_at":"2025-03-02T19:30:21.823Z","repository":{"id":65509425,"uuid":"127894208","full_name":"eveningkid/sweet-electron","owner":"eveningkid","description":"Easy, minimalist framework for Electron applications","archived":false,"fork":false,"pushed_at":"2018-05-01T03:34:29.000Z","size":71,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-17T18:11:14.510Z","etag":null,"topics":["electron","electronjs","framework","javascript","nodejs","sweet"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eveningkid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-03T10:54:47.000Z","updated_at":"2018-05-13T10:06:51.000Z","dependencies_parsed_at":"2023-01-26T16:55:12.975Z","dependency_job_id":null,"html_url":"https://github.com/eveningkid/sweet-electron","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eveningkid%2Fsweet-electron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eveningkid%2Fsweet-electron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eveningkid%2Fsweet-electron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eveningkid%2Fsweet-electron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eveningkid","download_url":"https://codeload.github.com/eveningkid/sweet-electron/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241560221,"owners_count":19982384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","electronjs","framework","javascript","nodejs","sweet"],"created_at":"2024-09-24T13:57:52.577Z","updated_at":"2025-03-02T19:30:21.493Z","avatar_url":"https://github.com/eveningkid.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sweet Electron\nEasy, minimalist framework for Electron applications.\n\n```js\nconst electron = require('electron');\nconst sweet = require('sweet-electron')(electron);\n\nsweet().url(__dirname, 'index.html').run();\n```\n\nInstall sweet-electron: `yarn add sweet-electron`.\u003cbr /\u003e\nCopy/paste this code. Run it using `electron`, such as: `$ electron script.js`.\n\n![Sweeeeeet](https://media.giphy.com/media/vjvx6YjG3ADo4/giphy.gif)\n\n- [API](#api)\n- [Advanced Example](#advanced-example)\n- [Working Example (external)](https://github.com/eveningkid/reacto/blob/master/public/main.js)\n\n# Implementation\n## Initialization\nsweet-electron requires electron to be passed as an argument when importing it. That makes it more like a wrapper. `sweet()` returns an instance of `SweetElectron`.\n\n## API\nSweetElectron\n- `url(String|Array[string]|Function)`: wrapper around [loadURL](https://electronjs.org/docs/api/browser-window#winloadurlurl-options)\n  - if **String**: will use it as a path directly\n  - if **Array[String]**: will call [path.join](https://nodejs.org/api/path.html#path_path_join_paths) on all the arguments\n  - if **Function**: should return a *String* or an *Array[String]*. An instance of [electron-is](https://github.com/delvedor/electron-is) is passed as an argument which means that you can write something like: `.url((is) =\u003e is.dev() ? 'index_dev.html' : 'index.html')`\n- `menu(electron.Menu|Array[Object]|Function)`\n  - if **electron.Menu**: will use it directly\n  - if **Array[Object]**: wrapper around [electron.Menu.buildFromTemplate](https://electronjs.org/docs/api/menu#menubuildfromtemplatetemplate)\n  - if **Function**: will call it with an `electron-is` instance, the [main window](https://electronjs.org/docs/api/browser-window) instance and a reference on [electron.app](https://electronjs.org/docs/api/app). Should return an *Array[Object]* as it will be passed to *electron.Menu.buildFromTemplate*\n- `window(Object|Function)`: additional options to be passed during the [main window](https://electronjs.org/docs/api/browser-window) creation\n  - if **Function**: should return an *Object*. Will be passed an `electron-is` instance as its first parameter\n- `ready(Function)`: function called after Electron's `ready` event is fired. Requires a function, which will get `electron-is` and `mainWindow` parameters.\n- `rendererEvents(Object{channel:callback})`: will loop over each *channel* and register its associated *callback*. Each *callback* will get a reference to the current main window as its last parameter (e.g `(event, payload, mainWindow) =\u003e { ... }`). Wrapper around [ipcMain](https://electronjs.org/docs/api/ipc-main). Should be combined using [ipcRenderer](https://electronjs.org/docs/api/ipc-renderer) on client-side\n- `shortcuts(Object{command:callback}|Function)`:\n  - if **Object**: based on [globalShortcut.register](https://electronjs.org/docs/api/global-shortcut)\n  - if **Function**: will get a reference on the main window as its first parameter. Should return an *Object*\n- `on(String, Function)`: can listen to all of the available events on [`electron.app`](https://electronjs.org/docs/api/app#events). The last argument is a reference to the current main window (e.g `mainWindow =\u003e { ... }`).\n- `run()`\n\n# Advanced Example\n```js\nconst electron = require('electron');\nconst sweet = require('sweet-electron')(electron);\n\n/**\n * All the code has been folded inside `sweet-electron` methods for the sake of\n * the example.\n * For bigger applications, you can surely split your code into different files\n * which will help you to keep an easy-to-maintain project.\n */\n\nsweet()\n  .url(is =\u003e [__dirname, is.dev() ? 'index_dev.html' : 'index.html'])\n  .window({ height: 800, transparent: true })\n  .menu(app =\u003e [{ label: app.getName() }, { type: 'separator' }, { role: 'quit' }])\n  .rendererEvents({\n    setOpacity: (event, opacity, mainWindow) =\u003e mainWindow.setOpacity(opacity),\n  })\n  .run();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feveningkid%2Fsweet-electron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feveningkid%2Fsweet-electron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feveningkid%2Fsweet-electron/lists"}