Commit Graph

99 Commits

Author SHA1 Message Date
Adam Weeden 2e0fe9ea33
Update to Electron 25.7 (#1566) 2023-08-25 14:07:42 -04:00
Adam Weeden 051622d58e
Update Electron to 21 + Node to 16 (#1550) 2023-08-03 13:35:19 -04:00
Adam Weeden 3a8f66a7b6
macOS: universal architecture app support (fix #1384, PR #1386)
As noted in `API.md`:

- When specifying `universal` you must be building for the `darwin`, `mas`, `mac`, or `osx` platforms. This will generate a universal (M1 and x86) app.
2022-04-18 19:11:31 -04:00
Adam Weeden f6852d5208
Update browser versions + add fix for Firefox user agent (#1388) 2022-04-18 18:42:25 -04:00
Henry Bridge 9945a5dffe
Add flag --strict-internal-urls to disable domain and subpath matching (PR #1340)
I created this so that Google Meet links don't open in my Google Calendar app for me, but it looks like others have a similar issue (e.g. issue #1304).
2022-02-06 17:40:51 -05:00
Tyler Nickerson aeb6ba1a8c
Add "quiet" flag to suppress all log output (PR #1342)
In working on my own repo [hop](https://github.com/Nickersoft/hop), which uses nativefier under-the-hood, I found it very troublesome to suppress log output when using the programmatic API. This PR just adds a quick "quiet" option which will set the log level to "silent" and suppress all electron and nativefier output (except for errors, of course).

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2022-01-23 16:01:29 -05:00
Ronan Jouchet 5e3c23267a Fix --widevine broken since 46.0.0
See https://github.com/nativefier/nativefier/pull/1288#issuecomment-1006307669 ,
"the version prefix changed from -wvvmp to +wvcus",

and message from CastLabs:
The v16 series of Electron for Content Security, labeled wvcus, moves to using the Component Updater Service to handle installation of the Widevine CDM, and has incompatible API updates compared to the previous wvvmp releases.
2022-01-06 09:34:20 -05:00
Adam Weeden d483597320
Upgrade Electron from 13 to 16 (PR #1288)
https://www.electronjs.org/docs/latest/breaking-changes

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2022-01-02 06:17:06 -05:00
Adam Weeden b9c5e2b464
Fix upgrade not working (#1286)
* Attempt to get upgrade working right; in progress

* Got it fixed in Mac

* Fix some linting errors

* Finish fixing upgrade + tests

* Integration testing for global shortcuts

* Regenerate shrinkwrap

* Get rid of deprecated rmdirSync

* Remove instead of rm for 12.x support

* Make dereferencing platform dependent

* Fix folder copy funkiness

* Whoops

* Whoops 2: Extra Whoops

* Update Electron to 13.5.1; Fix auth manual tests

* Rework relock

* Add a request for help.

* Update @types/node to 14
2021-11-29 12:01:20 -05:00
Adam Weeden b74c0bf959
Make app strict TypeScript + linting (and add a shared project) (#1231)
* Convert app to strict typing + shared library

* Fix new code post-merge

* Remove extraneous lint ignores

* Apply suggestions from code review

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>

* Fix prettier complaint

* Dedupe eslint files

* Fix some refs after merge

* Fix clean:full command

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2021-06-26 09:59:28 -04:00
Adam Weeden dc0e6cb68f
Fix app keeping running in the background after closed (--tray false regression) (PR #1242)
By tightening up typing and logic around tray options.
2021-06-25 16:03:23 -04:00
Adam Weeden 7a08a2d676
Enable TypeScript strict:true, and more typescript-eslint rules (#1223)
* Catch promise errors better

* Move subFunctions to bottom of createNewWindow

* Use parents when creating child BrowserWindow instances

* Some about:blank pages have an anchor (for some reason)

* Inject browserWindowOptions better

* Interim refactor to MainWindow object

* Split up the window functions/helpers/events some

* Further separate out window functions + tests

* Add a mock for unit testing functions that access electron

* Add unit tests for onWillPreventUnload

* Improve windowEvents tests

* Add the first test for windowHelpers

* Move WebRequest event handling to node

* insertCSS completely under test

* clearAppData completely under test

* Fix contextMenu require bug

* More tests + fixes

* Fix + add to createNewTab tests

* Convert createMainWindow back to func + work out gremlins

* Move setupWindow away from main since its shared

* Make sure contextMenu is handling promises

* Fix issues with fullscreen not working + menu refactor

* Run jest against app/dist so that we can hit app unit tests as well

* Requested PR changes

* Add strict typing; tests currently failing

* Fix failing unit tests

* Add some more eslint warnings and fixes

* More eslint fixes

* Strict typing on (still issues with the lib dir)

* Fix the package.json import/require

* Fix some funky test errors

* Warn -> Error for eslint rules

* @ts-ignore -> @ts-expect-error

* Add back the ext code I removed
2021-06-15 22:20:49 -04:00
Ronan Jouchet 62ee24662c More test:watch fix: bring upgrade to Jest 27 from TheCleric' closed jest-ts PR
See https://github.com/nativefier/nativefier/pull/1204
2021-06-02 00:35:19 -04:00
Adam Weeden d6730f7022
Improve user agent handling/provide user agent "short" codes (#1198) 2021-05-21 23:41:13 -04:00
Adam Weeden 1a810e5ce5
Organize CLI flags into groups (for better --help usability) (#1191)
* Organize CLI options for better UX

* Fix some documentation

* Whoops. Stupid VS Code linter.

* Fix prettier issues

* Make paths less unixy in tests

* Update src/cli.test.ts

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>

* Apply suggestions from code review

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>

* Add example to reference CATALOG.md

* Make honest appear near user-agent

* Standardize descriptions

* Hide flash options

* Add explanation of parsed._

* Redo groups in yargs

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2021-05-18 22:02:55 -04:00
Ronan Jouchet d61a4e709a Make prettier happier 2021-05-10 10:23:56 -04:00
Adam Weeden 895c11a53e
Support setting the browserWindow's language (fix #175) (PR #1173 ) 2021-04-30 23:16:57 -04:00
Adam Weeden 7dc189ef3f
Support creating self-contained "portable" apps writing their app data to the app folder (fix #376) (PR #1168)
In response to #376

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2021-04-30 23:10:12 -04:00
Adam Weeden f6e1ebd876
Fix Widevine by properly listening to widevine-... events, and update docs (fix #1153) (PR #1164)
As documented in #1153, for Widevine support to work properly, we need to listen for the Widevine ready event, and as well for certain sites the app must be signed.

This PR adds the events, and as well adds better documentation on the signing limitation.

This may also help resolve #1147
2021-04-29 13:27:55 -04:00
Adam Weeden 9330c8434f
Add an option to upgrade an existing app (fix #1131) (PR #1138)
This adds a `--upgrade` option to upgrade-in-place an old app, re-using its options it can.
Should help fix #1131

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2021-04-28 22:00:31 -04:00
Chris Dzombak b4ddd6865c
Support defining a custom bookmarks menu (fix #1065) (PR #1155)
This PR adds an optional, customizable menu of predefined bookmarks. In addition to containing a list of bookmarks, this file customizes the name of the menu and (optionally) allows assigning keyboard shortcuts to bookmarks. It adds a new command-line flag, `--bookmarks-menu <string>`, which can be set as the path to a JSON file containing configuration for the bookmarks menu.

Example of such a JSON file:

```json
{
    "menuLabel": "Music",
    "bookmarks": [
        {
            "title": "lofi.cafe",
            "url": "https://lofi.cafe/",
            "type": "link",
            "shortcut": "Cmd+1"
        },
        {
            "title": "beats to relax/study to",
            "url": "https://www.youtube.com/watch?v=5qap5aO4i9A",
            "type": "link",
            "shortcut": "Cmd+2"
        },
        {
            "type": "separator"
        },
        {
            "title": "RÜFÜS DU SOL Live from Joshua Tree",
            "type": "link",
            "url": "https://www.youtube.com/watch?v=Zy4KtD98S2c"
        }
    ]
}
```

## Checks
- [x] `npm run ci` passes

## Notes

Compared to the fork linked in #1065, this PR:
- adds no dependencies
- doesn't currently support submenus (this should be easy enough to add, but I didn't need it)

## Screenshot

<img width="853" alt="screenshot" src="https://user-images.githubusercontent.com/102904/115882015-5493a800-a41a-11eb-85ef-a190f3dbfe76.png">
2021-04-23 21:46:34 -04:00
Ronan Jouchet 74a7d3375d App: revert addition of extra flag --internal-login-pages
See discussion at https://github.com/nativefier/nativefier/pull/1124#issuecomment-794751514 :

> @TheCleric I was about to merge this, then reconsidered one little thing (yes I wrote "little", I'm not reconsidering this whole thing 😅).
>
> I'm re-considering having the extra flag. I'm not so sure this will harm a lot of use cases. I'd like to 1. merge this PR, 2. immediately follow up with a small commit removing the flag & adjusting api.md, 3. release with the change well-documented / asking for feedback if this is problematic to anyone. (I'm not asking you any extra work, and like leaving an in-tree commit trace of considering the flag). If people complain with a valid reason, we'll restore the flag with a quick revert, else we're happy with one less flag and a reasonably-handled breaking change.
>
> Thoughts / objections?

Answered by:

> That seems reasonable to me.
>
> [discussion on an extra structured way to pass flags]
2021-03-10 19:36:20 -05:00
Adam Weeden 6f7e80bafd
App: Automatically consider known login pages as internal (fix #706) (PR #1124)
Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2021-03-10 19:20:53 -05:00
Adam Weeden adcf21a3df
macOS: Prompt for accessibility permissions if needed by Global Shortcuts using Media Keys (Fix #1120) (PR #1121)
When setting a media key (play, pause, next/previous track) as global shortcut in Mac OS 10.14+, accessibility permissions must be given to the app for it to work (see https://www.electronjs.org/docs/api/global-shortcut?q=MediaPlayPause#globalshortcutregisteraccelerator-callback).

This PR will accomplish the following on generated app launch:
- Check if global shortcuts are being setup
- Check if the host OS is Mac OS
- Check if the global shortcuts were one of the media keys
- If the above are true, check if the app has accessibility permissions
- If the app does not have the accessibility permissions it will ask the user if they would like to be prompted for these permissions, and then ask Mac OS to prompt for accessibility permissions.

~~As well, a new command line flag is added (`--no-accessibility-prompt`) to preventatively suppress these prompts if desired.~~

Screenshots of the new behavior:
![Screen Shot 2021-02-26 at 2 41 21 PM](https://user-images.githubusercontent.com/547567/109356260-76bfde00-784e-11eb-8c36-3a51b911b780.png)
![Screen Shot 2021-02-26 at 2 41 28 PM](https://user-images.githubusercontent.com/547567/109356266-79223800-784e-11eb-94eb-66437c05fd10.png)
![Screen Shot 2021-02-26 at 2 41 50 PM](https://user-images.githubusercontent.com/547567/109356270-7aebfb80-784e-11eb-9e90-e09bb49752c6.png)

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2021-02-28 10:24:14 -05:00
Ronan Jouchet 35d926b959 Fix inferIcon error surfacing in full since recent axios 2021-01-15 21:57:19 -05:00
Matthew Ruzzi e8d3530b43
Warn on old Electron/Chrome (fix #556) (PR #1076)
Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2020-11-30 21:45:35 -05:00
erythros bbd51ad988
Support using a Widevine-enabled Electron for DRM playback (fix #435) (PR #1073) 2020-11-21 09:39:07 -05:00
davidfant bd077756e8
Emit TS type declarations, and type NativefierOptions (#1016)
This PR adds better Typescript support when using the Node module directly:
1. Generate type declarations when running `tsc`
2. Created the `NativefierOptions` type for the `buildNativefierApp` function instead of using `any`
2020-08-05 20:26:41 -04:00
Joe Skeen 8e8cd24e0d
Add `--block-external-urls` flag to forbid external navigation attempts (Fix #978 - PR#1012)
Fixes #978 

Adds a `--block-external-urls` option (default: `false`) that prevents opening external links (as classified by the `--internal-urls` option).

Documentation and tests updated.


Example:
```
nativefier --internal-urls "classroom\.google\.com" --block-external-urls
```
![image](https://user-images.githubusercontent.com/12286274/88739501-f12d5180-d0f7-11ea-9821-86f3e9bfa070.png)
![image](https://user-images.githubusercontent.com/12286274/88739512-fab6b980-d0f7-11ea-877c-7bd565352a93.png)
2020-08-02 14:31:47 -04:00
Ronan Jouchet 8684887fc6 Bump eslint to 7.x, fix new lint errors 2020-07-18 11:19:58 -04:00
Ronan Jouchet 792156f376 Bump deps: electron-packager, ts-loader, types 2020-07-18 01:47:46 -04:00
Ronan Jouchet c9ee6667d4
Revamp and move to TypeScript (#898)
## Breaking changes

- Require **Node >= 8.10.0 and npm 5.6.0**
- Move to **Electron 8.1.1**.
- That's it. Lots of care went into breaking CLI & programmatic behavior
  as little as possible. **Please report regressions**.
- Known issue: build may fail behind a proxy. Get in touch if you use one:
  https://github.com/jiahaog/nativefier/issues/907#issuecomment-596144768

## Changes summary

Nativefier didn't get much love recently, to the point that it's
becoming hard to run on recent Node, due to old dependencies.
Also, some past practices now seem weird, as better expressible
by modern JS/TS, discouraging contributions including mine.

Addressing this, and one thing leading to another, came a
bigger-than-expected revamp, aiming at making Nativefier more
**lean, stable, future-proof, user-friendly and dev-friendly**,
while **not changing the CLI/programmatic interfaces**. Highlights:

- **Require Node>=8**, as imposed by many of our dependencies. Node 8
  is twice LTS, and easily available even in conservative Linux distros.
  No reason not to demand it.
- **Default to Electron 8**.
- **Bump** all dependencies to latest version, including electron-packager.
- **Move to TS**. TS is great. As of today, I see no reason not to use it,
  and fight interface bugs at runtime rather than at compile time.
  With that, get rid of everything Babel/Webpack.
- **Move away from Gulp**. Gulp's selling point is perf via streaming,
  but for small builds like Nativefier, npm tasks are plenty good
  and less dependency bloat. Gulp was the driver for this PR: broken
  on Node 12, and I didn't feel like just upgrading and keeping it.
- Add tons of **verbose logs** everywhere it makes sense, to have a
  fine & clear trace of the program flow. This will be helpful to
  debug user-reported issues, and already helped me fix a few bugs.
    - With better simple logging, get rid of the quirky and buggy
      progress bar based on package `progress`. Nice logging (minimal
      by default, the verbose logging mentioned above is only used
      when passing `--verbose`) is better and one less dependency.
- **Dump `async` package**, a relic from old callback-hell early Node.
  Also dump a few other micro-packages unnecessary now.
- A first pass of code **cleanup** thanks to modern JS/TS features:
  fixes, simplifications, jsdoc type annotations to types, etc.
- **Remove GitHub integrations Hound & CodeClimate**, which are more
  exotic than good'ol'linters, and whose signal-to-noise ratio is too low.
- Quality: **Add tests** and add **Windows + macOS CI builds**.
  Also, add a **manual test script**, helping to quickly verify the
  hard-to-programatically-test stuff before releases, and limit regressions.
- **Fix a very small number of existing bugs**. The goal of this PR was
  *not* to fix bugs, but to get Nativefier in better shape to do so.
  Bugfixes will come later. Still, these got addressed:
  - Add common `Alt`+`Left`/`Right` for previous/next navigation.
  - Improve #379: fix zoom with `Ctrl` + numpad `+`/`-`
  - Fix pinch-to-zoom (see https://github.com/jiahaog/nativefier/issues/379#issuecomment-598612128 )
2020-03-15 16:50:01 -04:00
otato.z ef13ff1e1d feat: proxy rules with `--proxy-rules` flag (#854)
See https://electronjs.org/docs/api/session?q=proxy#sessetproxyconfig-callback
2019-10-22 19:38:39 -04:00
FabulousCupcake d0a0614ba3 Add --browserwindow-options to completely expose Electron options (PR #835)
This adds a new flag `--browserwindow-options`, taking a stringified JSON object as input.  
It will be inserted directly into the options when BrowserConfig is initialized.

This allows total configurability of the electron BrowserWindow configuration via nativefier.

An example use case is added to the documentation, which modifies the default font family in the browser.

#### References

- https://github.com/electron/electron/blob/master/docs/api/browser-window.md#new-browserwindowoptions
  - See the following for electron v3.1.7
  - https://github.com/electron/electron/blob/v3.1.7/docs/api/browser-window.md#new-browserwindowoptions
2019-08-22 21:37:49 +02:00
Umair Ahmed 81c422d4e0 Support setting background color (fixes #795) (PR #819)
Adds a `--background-color` flag for the background of the window when the app isn't loaded.
2019-08-22 21:25:58 +02:00
Nate Woolls 5433569921 Support macOS 10.4+ Dark Mode, default to Electron 5.x (#796)
Introduces a `--darwin-dark-mode-support` flag. 
(I kept the same flag used by Electron Packager.)
This required bumping Electron and Electron Packager.

Addresses:

- https://github.com/jiahaog/nativefier/issues/733
- https://github.com/jiahaog/nativefier/issues/727
2019-08-22 21:05:39 +02:00
Adrian DC 5b6cc89f22 Fix #316: Add --clear-cache flag to cleanup session on start/exit ("incognito" mode) (PR #747)
- Add a new `clearCache` option and `--clear-cache` parameter
  to trigger session cleanups upon window launch and close

- Covers the feature request from issue #316 

- Use case example: Forcing authentification / login between sessions without limiting cache size
2019-02-08 10:03:29 -05:00
Benedikt Rötsch 3029cba01f Support global shortcuts that trigger input events (PR #698, Fixes #15)
This adds a new flag, allowing the user to define global shortcuts that trigger input events within the main window.

That way, I could easily wrap SoundCloud and Deezer to create a native app which reacts on my keyboard media buttons.
2018-11-04 21:03:52 -05:00
Ronan Jouchet 19561e9ad6 Make eslint happy 2018-07-21 09:16:02 -04:00
Khai Nguyen b8c1d35ba4 Add --title-bar-style flag (macOS only) (PR#627) 2018-05-31 08:05:12 -04:00
Goh Jia Hao 16aae0a937 Refactor tests to use async/await 2018-05-24 22:46:49 -07:00
Goh Jia Hao 95fc46d38d Integrate prettier 2018-05-24 00:02:44 -07:00
David Kramer bbb513d420 Fix #364 - Add --disable-gpu flag to disable hardware acceleration (PR #584) 2018-04-22 15:56:10 -04:00
Matt Rose 574205ab0d macOS: Add --bounce option for dock counter (PR #570) 2018-04-14 17:17:25 -04:00
sgroh 46d381481c Fix #549: Add --always-on-top build flag (PR #551) 2018-03-16 18:15:44 -04:00
Bob Roth cec9c4b819 Fix #499: Add options to control file download behavior (PR #526) 2018-01-26 09:59:58 -05:00
Matt Harris 28dca8c647 Fix #325 - Add --x and --y window position flags (PR #515) 2017-12-26 13:00:39 -05:00
Ronan Jouchet 6fb3b92eb8
Upgrade dependencies and default to latest Electron 1.7.9 (PR #483)
* Update deps except eslint
* Update eslint and lint:fix (WIP, needs manual fixing for remaining 44 problems)
* Manually fix remaining eslint errors
* Document deprecation of `version-string` as of electron-packager 9.0.0
* Upgrade to Electron 1.7.9 (chrome-58, node-7.9.0, v8-5.8)
* npm: Disable generation of package-lock.json and gitignore it
  --Trying this, package-lock is a pain in PRs. May not be a good idea
  (obviously we lose deps pinning), will revert if necessary.--
* npm tasks: add dev-up-win for Windows developers,
  and e2e for end-to-end tests. Update docs.
* Move normalizeUrl test to a jest unit test, makes no sense to be in the mocha e2e tests
* Switch from babel-preset-es2015 to babel-preset-env,
  with target.node=4.0. Seem like it's today's most convenient
  way to support the latest ES and let babel transpile to what
  makes sense for our currently minimal node version
2017-11-14 08:05:01 -05:00
omouren 885790bc22 Fix #304 - Add --tray CLI flag to let app running in background on window close. Supports in-title counter. (#457) 2017-10-05 19:32:48 -04:00
Devin Buhl 4c581f9067 Fix #275 - Add HTTP --basic-auth-{username,password} CLI flags (#444) 2017-10-05 18:44:03 -04:00