stage-browser 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -2
- package/build/icon.icns +0 -0
- package/build/icon.png +0 -0
- package/dist/bin/stage.js +111 -0
- package/dist/main/cli-args.js +28 -0
- package/dist/main/context-menu.js +68 -0
- package/dist/main/context.js +2 -0
- package/dist/main/extensions.js +78 -0
- package/dist/main/ipc.js +90 -0
- package/dist/main/main.js +279 -0
- package/dist/main/menu.js +140 -0
- package/dist/main/reveal.js +155 -0
- package/dist/main/selftest.js +490 -0
- package/dist/main/store.js +85 -0
- package/dist/main/suggest.js +43 -0
- package/dist/main/tabs.js +324 -0
- package/dist/main/url.js +38 -0
- package/dist/main/window.js +68 -0
- package/dist/preload/extension-compat.js +163 -0
- package/dist/preload/ui-preload.js +33 -0
- package/dist/shared/contract.js +6 -0
- package/dist/ui/app.js +653 -0
- package/dist/ui/index.html +41 -0
- package/dist/ui/mock.js +479 -0
- package/dist/ui/newtab.html +69 -0
- package/dist/ui/styles.css +410 -0
- package/node_modules/@types/chrome/LICENSE +21 -0
- package/node_modules/@types/chrome/README.md +15 -0
- package/node_modules/@types/chrome/chrome-cast/index.d.ts +1156 -0
- package/node_modules/@types/chrome/har-format/index.d.ts +6 -0
- package/node_modules/@types/chrome/index.d.ts +13786 -0
- package/node_modules/@types/chrome/package.json +99 -0
- package/node_modules/@types/filesystem/LICENSE +21 -0
- package/node_modules/@types/filesystem/README.md +15 -0
- package/node_modules/@types/filesystem/index.d.ts +564 -0
- package/node_modules/@types/filesystem/package.json +26 -0
- package/node_modules/@types/filewriter/LICENSE +21 -0
- package/node_modules/@types/filewriter/README.md +15 -0
- package/node_modules/@types/filewriter/index.d.ts +166 -0
- package/node_modules/@types/filewriter/package.json +25 -0
- package/node_modules/@types/har-format/LICENSE +21 -0
- package/node_modules/@types/har-format/README.md +15 -0
- package/node_modules/@types/har-format/index.d.ts +938 -0
- package/node_modules/@types/har-format/package.json +31 -0
- package/node_modules/adm-zip/LICENSE +21 -0
- package/node_modules/adm-zip/README.md +90 -0
- package/node_modules/adm-zip/adm-zip.js +1020 -0
- package/node_modules/adm-zip/headers/entryHeader.js +396 -0
- package/node_modules/adm-zip/headers/index.js +2 -0
- package/node_modules/adm-zip/headers/mainHeader.js +177 -0
- package/node_modules/adm-zip/methods/deflater.js +33 -0
- package/node_modules/adm-zip/methods/index.js +3 -0
- package/node_modules/adm-zip/methods/inflater.js +64 -0
- package/node_modules/adm-zip/methods/zipcrypto.js +175 -0
- package/node_modules/adm-zip/package.json +56 -0
- package/node_modules/adm-zip/types.d.ts +223 -0
- package/node_modules/adm-zip/util/constants.js +142 -0
- package/node_modules/adm-zip/util/decoder.js +5 -0
- package/node_modules/adm-zip/util/errors.js +66 -0
- package/node_modules/adm-zip/util/fattr.js +76 -0
- package/node_modules/adm-zip/util/index.js +5 -0
- package/node_modules/adm-zip/util/utils.js +481 -0
- package/node_modules/adm-zip/zipEntry.js +415 -0
- package/node_modules/adm-zip/zipFile.js +466 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/electron-chrome-web-store/README.md +143 -0
- package/node_modules/electron-chrome-web-store/dist/chrome-web-store.preload.js +299 -0
- package/node_modules/electron-chrome-web-store/dist/cjs/browser/index.js +1674 -0
- package/node_modules/electron-chrome-web-store/dist/esm/browser/index.mjs +950 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/api.d.ts +2 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/crx3.d.ts +20 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/id.d.ts +9 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/index.d.ts +62 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/installer.d.ts +29 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/loader.d.ts +18 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/types.d.ts +21 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/updater.d.ts +6 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/utils.d.ts +4 -0
- package/node_modules/electron-chrome-web-store/dist/types/common/constants.d.ts +44 -0
- package/node_modules/electron-chrome-web-store/dist/types/renderer/chrome-web-store.preload.d.ts +1 -0
- package/node_modules/electron-chrome-web-store/package.json +43 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/pbf/LICENSE +27 -0
- package/node_modules/pbf/README.md +293 -0
- package/node_modules/pbf/bin/pbf +17 -0
- package/node_modules/pbf/compile.js +441 -0
- package/node_modules/pbf/dist/pbf-dev.js +838 -0
- package/node_modules/pbf/dist/pbf.js +1 -0
- package/node_modules/pbf/index.d.ts +206 -0
- package/node_modules/pbf/index.js +830 -0
- package/node_modules/pbf/package.json +63 -0
- package/node_modules/protocol-buffers-schema/.travis.yml +7 -0
- package/node_modules/protocol-buffers-schema/LICENSE +21 -0
- package/node_modules/protocol-buffers-schema/README.md +122 -0
- package/node_modules/protocol-buffers-schema/example.js +11 -0
- package/node_modules/protocol-buffers-schema/example.proto +13 -0
- package/node_modules/protocol-buffers-schema/index.js +6 -0
- package/node_modules/protocol-buffers-schema/package.json +31 -0
- package/node_modules/protocol-buffers-schema/parse.js +769 -0
- package/node_modules/protocol-buffers-schema/stringify.js +206 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/basic.json +90 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/basic.proto +11 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/comments.json +99 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/comments.proto +19 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/complex.json +125 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/complex.proto +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/enum.json +42 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/enum.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/escaped-quotes.json +32 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/escaped-quotes.proto +3 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/extend.json +167 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/extend.proto +19 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/import.json +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/import.proto +6 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/map.json +33 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/map.proto +3 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/no-tags.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/oneof.json +41 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/oneof.proto +6 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/option.json +364 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/option.proto +72 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/options.json +47 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/options.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/pheromon-trajectories.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/reserved.json +55 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/reserved.proto +17 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/search.json +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/search.proto +5 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/service.json +108 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/service.proto +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/valid-packed.proto +35 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/version.json +90 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/version.proto +13 -0
- package/node_modules/protocol-buffers-schema/test/index.js +157 -0
- package/node_modules/protocol-buffers-schema/tokenize.js +56 -0
- package/node_modules/resolve-protobuf-schema/.travis.yml +3 -0
- package/node_modules/resolve-protobuf-schema/LICENSE +21 -0
- package/node_modules/resolve-protobuf-schema/README.md +49 -0
- package/node_modules/resolve-protobuf-schema/index.js +50 -0
- package/node_modules/resolve-protobuf-schema/package.json +25 -0
- package/node_modules/resolve-protobuf-schema/test/a.proto +5 -0
- package/node_modules/resolve-protobuf-schema/test/b.proto +5 -0
- package/node_modules/resolve-protobuf-schema/test/c.proto +3 -0
- package/node_modules/resolve-protobuf-schema/test/index.js +49 -0
- package/package.json +64 -4
package/README.md
CHANGED
|
@@ -1,3 +1,137 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="build/icon.png" width="112" height="112" alt="Stage icon: a one-bit pixel browser window with a red record dot">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">Stage</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<b>Nothing but the page.</b><br>
|
|
9
|
+
A minimal Chromium browser for workshops, webinars and demos.<br>
|
|
10
|
+
Share the window and your audience sees the site, edge to edge.<br>
|
|
11
|
+
Your tabs wait behind the top edge until you reach for them.
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<code>npx stage-browser https://example.com</code>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<img src="docs/images/stage-window.png" width="880" alt="A Stage window filled by a slide deck, with the floating tab capsule slid in from the top edge">
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
## Same site. Two windows.
|
|
23
|
+
|
|
24
|
+
A normal browser spends about 100 px on tabs, the address bar and bookmarks. In a 720p share, that's **a seventh of every frame**, and every tab title, extension badge and bookmark goes out on the call with the page.
|
|
25
|
+
|
|
26
|
+
Stage gives it all back to the page. No toolbar, no address bar, no bookmarks bar. Push the pointer against the top edge and a small tab capsule slides in over the page. Move away and it's gone.
|
|
27
|
+
|
|
28
|
+
## One command.
|
|
29
|
+
|
|
30
|
+
**Zero installation.** `npx` runs Stage straight from npm: nothing to download from a website, drag into Applications or approve in System Settings.
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npx stage-browser https://example.com # run it now
|
|
34
|
+
npm i -g stage-browser # or keep the short `stage` command
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Needs macOS and Node 18 or later. The first run downloads Stage and its Chromium, about 100 MB.
|
|
38
|
+
|
|
39
|
+
## Run of show.
|
|
40
|
+
|
|
41
|
+
**1. Before the call: open your demo tabs from the terminal.**
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
stage --size 1280x720 app.example.com docs.example.com
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Each address becomes a tab. `--size` fixes the window at 16:9, so nothing reflows when you start sharing.
|
|
48
|
+
|
|
49
|
+
**2. Going live: share only the Stage window.** In Zoom, Meet or Teams, pick the Stage window instead of your whole screen. The audience gets the page and nothing around it.
|
|
50
|
+
|
|
51
|
+
**3. During the demo: reach up when you need another tab.** Push the pointer against the top edge and the tabs slide in. Or stay on the keyboard: <kbd>⌘1</kbd>–<kbd>⌘9</kbd> switch tabs and <kbd>⌘L</kbd> opens a page.
|
|
52
|
+
|
|
53
|
+
## Small on purpose.
|
|
54
|
+
|
|
55
|
+
- **Hidden tabs.** The tab capsule floats over the page and hides when you're done with it. <kbd>⇧⌘B</kbd> pins it open.
|
|
56
|
+
- **Extensions.** Add the ones you use from the Chrome Web Store. Their icons sit in the tab bar.
|
|
57
|
+
- **Terminal start.** `stage <url>` opens the page and hands your prompt back. Run it again and the page joins the open window. No app bundle to sign.
|
|
58
|
+
- **Share sizes.** Window presets at 1280×720, 1440×900, 1600×900 and 1920×1080. Zoom with <kbd>⌘=</kbd> and <kbd>⌘-</kbd> so the back row can read.
|
|
59
|
+
- **Escape hatch.** <kbd>⇧⌘O</kbd> opens the current page in Google Chrome. Zoom and Slack links open in their own apps.
|
|
60
|
+
|
|
61
|
+
## The command line
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
stage open Stage (restores the last session)
|
|
65
|
+
stage <url|domain|words> … open each argument as a tab; bare words become a Google search
|
|
66
|
+
stage --size 1280x720 … set the window's content size
|
|
67
|
+
stage --pin start with the tab bar pinned
|
|
68
|
+
stage --fresh skip the saved session
|
|
69
|
+
stage --fg run in the foreground with logs in the terminal
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If Stage is already running, `stage <url>` opens the URL as a tab in the running window.
|
|
73
|
+
|
|
74
|
+
## Hands on the keys.
|
|
75
|
+
|
|
76
|
+
| Shortcut | Action |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| <kbd>⌘T</kbd> | New tab, straight into the address box |
|
|
79
|
+
| <kbd>⌘L</kbd> | Go to an address or search |
|
|
80
|
+
| <kbd>⌘W</kbd> / <kbd>⇧⌘T</kbd> | Close a tab / reopen it |
|
|
81
|
+
| <kbd>⌘1</kbd> … <kbd>⌘9</kbd> | Jump to a tab (<kbd>⌘9</kbd> is the last) |
|
|
82
|
+
| <kbd>⌃Tab</kbd>, <kbd>⇧⌘]</kbd> / <kbd>⇧⌘[</kbd> | Next / previous tab |
|
|
83
|
+
| <kbd>⌘[</kbd> / <kbd>⌘]</kbd> | Back / forward |
|
|
84
|
+
| <kbd>⌘R</kbd> / <kbd>⇧⌘R</kbd> | Reload / hard reload |
|
|
85
|
+
| <kbd>⌘=</kbd> / <kbd>⌘-</kbd> / <kbd>⌘0</kbd> | Zoom in / out / reset |
|
|
86
|
+
| <kbd>⇧⌘B</kbd> | Pin or unpin the tab bar |
|
|
87
|
+
| <kbd>⌃⌘F</kbd> | Full screen |
|
|
88
|
+
| <kbd>⇧⌘O</kbd> | Open the page in Google Chrome |
|
|
89
|
+
| <kbd>⌥⌘I</kbd> | Developer tools |
|
|
90
|
+
|
|
91
|
+
In the tab bar, click the active tab to edit its address, middle-click a tab to close it, drag tabs to reorder, and right-click a tab for more.
|
|
92
|
+
|
|
93
|
+
## Extensions
|
|
94
|
+
|
|
95
|
+
Stage starts with none. Choose **Extensions → Open Chrome Web Store**, find the extension and click **Add to Chrome**. Its icon appears on the right of the tab bar, and the **Extensions** menu lists everything installed, each with a Remove option. **Hide Icons in Tab Bar** keeps the capsule bare.
|
|
96
|
+
|
|
97
|
+
Extension support comes from [electron-chrome-extensions](https://github.com/samuelmaddock/electron-browser-shell/tree/master/packages/electron-chrome-extensions), which covers most of the `chrome.*` APIs extensions rely on, but not every one. If an extension misbehaves, <kbd>⇧⌘O</kbd> opens the page in Google Chrome.
|
|
98
|
+
|
|
99
|
+
## Before you go live.
|
|
100
|
+
|
|
101
|
+
**Why does macOS ask about "Chromium Safe Storage"?**
|
|
102
|
+
That Keychain key decrypts your saved logins. macOS asks once after you install or update Stage. Choose **Always Allow**, or sites will treat you as signed out.
|
|
103
|
+
|
|
104
|
+
**Is it signed or notarized?**
|
|
105
|
+
It doesn't need to be. On first launch, Stage copies Electron's Chromium app on your own Mac, names it Stage and gives it a local signature, the same kind Electron itself ships with. That copy lives in `~/Library/Application Support/Stage/Runtime/` and takes almost no disk space.
|
|
106
|
+
|
|
107
|
+
**Where are my logins and tabs kept?**
|
|
108
|
+
In `~/Library/Application Support/Stage`. npx, a global install and a clone all share it, so you sign in once. Stage reopens your last tabs when it starts, and logs errors to `stage.log` in the same folder instead of interrupting you with a dialog.
|
|
109
|
+
|
|
110
|
+
**Does every extension work?**
|
|
111
|
+
Most do. Extensions that talk to a desktop app, such as 1Password's desktop unlock, can't connect, because Electron doesn't support Chrome's native messaging. Sign in inside the extension instead.
|
|
112
|
+
|
|
113
|
+
**Can I open more than one window?**
|
|
114
|
+
Not yet. Links that open new windows become tabs, and sign-in pop-ups open as small separate windows so the sign-in flow keeps working.
|
|
115
|
+
|
|
116
|
+
**Windows or Linux?**
|
|
117
|
+
Not yet. Stage is macOS only.
|
|
118
|
+
|
|
119
|
+
## Build from source
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
git clone https://github.com/andrewckor/stage-browser
|
|
123
|
+
cd stage-browser
|
|
124
|
+
npm install
|
|
125
|
+
npm start # build to dist/ and run
|
|
126
|
+
npm run cli:install # build and link dist/bin/stage.js to ~/.local/bin/stage
|
|
127
|
+
npm run typecheck # tsc over src/ and scripts/
|
|
128
|
+
npm run lint # oxlint, warnings fail
|
|
129
|
+
npm run selftest # scripted end-to-end checks; writes selftest-out/results.json and screenshots
|
|
130
|
+
npm run ui:preview # render the tab bar and address box in mock mode with headless Chrome
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
[`docs/CONTRACT.md`](docs/CONTRACT.md) describes the window layout and the interface between the main process (`src/main/`) and the overlay UI (`src/ui/`). The website lives in [`site/`](site/).
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
<p align="center">MIT · Built on Electron and Chromium</p>
|
package/build/icon.icns
ADDED
|
Binary file
|
package/build/icon.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_os_1 = require("node:os");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const root = (0, node_path_1.resolve)((0, node_path_1.dirname)((0, node_fs_1.realpathSync)(__filename)), '..', '..');
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
const readJson = (file) => JSON.parse((0, node_fs_1.readFileSync)(file, 'utf8'));
|
|
11
|
+
const pkg = readJson((0, node_path_1.join)(root, 'package.json'));
|
|
12
|
+
const HELP = `Stage ${pkg.version} - a minimal browser for screen sharing
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
stage open Stage (restores the last session)
|
|
16
|
+
stage <url|domain|words> ... open each argument as a tab; bare words become a Google search
|
|
17
|
+
stage --size 1280x720 ... set the window's content size
|
|
18
|
+
stage --pin start with the tab bar pinned
|
|
19
|
+
stage --fresh skip the saved session
|
|
20
|
+
stage --fg run in the foreground with logs in the terminal
|
|
21
|
+
stage --help | --version
|
|
22
|
+
`;
|
|
23
|
+
// macOS takes the bold app name in the menu bar, the Dock label and the icon from the app bundle,
|
|
24
|
+
// and Electron ships as "Electron.app". So Stage runs from a renamed copy, Stage.app, made once per
|
|
25
|
+
// Electron version under ~/Library/Application Support/Stage/Runtime. The copy is an APFS clone
|
|
26
|
+
// (instant, almost no disk space), and it is re-signed ad-hoc, the same local signature
|
|
27
|
+
// Electron.app ships with, so no Apple developer account is involved.
|
|
28
|
+
const RUNTIME_REVISION = 2; // bump when the bundle edits or build/icon.icns change
|
|
29
|
+
const quiet = (cmd, cmdArgs) => void (0, node_child_process_1.execFileSync)(cmd, cmdArgs, { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
30
|
+
function electronVersion() {
|
|
31
|
+
try {
|
|
32
|
+
return readJson(require.resolve('electron/package.json', { paths: [root] })).version;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return 'unknown';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function stageRuntime(electronBinary) {
|
|
39
|
+
const sourceApp = (0, node_path_1.resolve)(electronBinary, '..', '..', '..');
|
|
40
|
+
if (process.platform !== 'darwin' || !sourceApp.endsWith('.app'))
|
|
41
|
+
return electronBinary;
|
|
42
|
+
const base = (0, node_path_1.join)((0, node_os_1.homedir)(), 'Library', 'Application Support', 'Stage', 'Runtime');
|
|
43
|
+
const dir = (0, node_path_1.join)(base, `electron-${electronVersion()}-r${RUNTIME_REVISION}`);
|
|
44
|
+
const app = (0, node_path_1.join)(dir, 'Stage.app');
|
|
45
|
+
const binary = (0, node_path_1.join)(app, 'Contents', 'MacOS', (0, node_path_1.basename)(electronBinary));
|
|
46
|
+
const ready = (0, node_path_1.join)(dir, '.ready');
|
|
47
|
+
if ((0, node_fs_1.existsSync)(ready) && (0, node_fs_1.existsSync)(binary))
|
|
48
|
+
return binary;
|
|
49
|
+
try {
|
|
50
|
+
process.stderr.write('stage: setting up Stage.app (once per install or update)…\n');
|
|
51
|
+
(0, node_fs_1.rmSync)(dir, { recursive: true, force: true });
|
|
52
|
+
(0, node_fs_1.mkdirSync)(dir, { recursive: true });
|
|
53
|
+
try {
|
|
54
|
+
quiet('cp', ['-Rc', sourceApp, app]); // APFS clone
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
(0, node_fs_1.rmSync)(app, { recursive: true, force: true });
|
|
58
|
+
quiet('cp', ['-R', sourceApp, app]);
|
|
59
|
+
}
|
|
60
|
+
const plist = (0, node_path_1.join)(app, 'Contents', 'Info.plist');
|
|
61
|
+
quiet('plutil', ['-replace', 'CFBundleName', '-string', 'Stage', plist]);
|
|
62
|
+
quiet('plutil', ['-replace', 'CFBundleDisplayName', '-string', 'Stage', plist]);
|
|
63
|
+
quiet('plutil', ['-replace', 'CFBundleIdentifier', '-string', 'app.stage.browser', plist]);
|
|
64
|
+
const icon = (0, node_path_1.join)(root, 'build', 'icon.icns');
|
|
65
|
+
if ((0, node_fs_1.existsSync)(icon))
|
|
66
|
+
(0, node_fs_1.copyFileSync)(icon, (0, node_path_1.join)(app, 'Contents', 'Resources', 'electron.icns'));
|
|
67
|
+
quiet('codesign', ['--force', '--deep', '--sign', '-', app]);
|
|
68
|
+
(0, node_fs_1.writeFileSync)(ready, `${new Date().toISOString()}\n`);
|
|
69
|
+
for (const old of (0, node_fs_1.readdirSync)(base))
|
|
70
|
+
if (old !== (0, node_path_1.basename)(dir))
|
|
71
|
+
(0, node_fs_1.rmSync)((0, node_path_1.join)(base, old), { recursive: true, force: true });
|
|
72
|
+
return binary;
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
const err = e;
|
|
76
|
+
const detail = err.stderr?.toString().trim() || err.message;
|
|
77
|
+
process.stderr.write(`stage: could not set up Stage.app, starting Electron directly (${detail})\n`);
|
|
78
|
+
return electronBinary;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function findElectron() {
|
|
82
|
+
try {
|
|
83
|
+
return require('electron');
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
console.error('stage: could not find Electron. Run `npm install` in ' + root);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function main() {
|
|
91
|
+
if (args.includes('--help') || args.includes('-h'))
|
|
92
|
+
return void process.stdout.write(HELP);
|
|
93
|
+
if (args.includes('--version') || args.includes('-v'))
|
|
94
|
+
return console.log(pkg.version);
|
|
95
|
+
const electron = findElectron();
|
|
96
|
+
const binary = process.env.STAGE_PLAIN_ELECTRON ? electron : stageRuntime(electron);
|
|
97
|
+
const fg = args.includes('--fg');
|
|
98
|
+
const child = (0, node_child_process_1.spawn)(binary, [root, ...args], fg ? { stdio: 'inherit' } : { detached: true, stdio: 'ignore' });
|
|
99
|
+
child.on('error', (e) => {
|
|
100
|
+
console.error('stage: failed to launch: ' + e.message);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
});
|
|
103
|
+
if (fg) {
|
|
104
|
+
child.on('exit', (code, signal) => process.exit(signal ? 1 : (code ?? 0)));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
child.unref();
|
|
108
|
+
setImmediate(() => process.exit(0)); // spawn errors surface asynchronously
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
main();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseArgs = parseArgs;
|
|
4
|
+
const SIZE = /^(\d{2,5})x(\d{2,5})$/i;
|
|
5
|
+
// argv is shaped like [electron, appPath, ...args]. second-instance may add leading entries, so
|
|
6
|
+
// anchor on the app path when it is known. Chromium switches are ignored.
|
|
7
|
+
function parseArgs(argv, appRoot) {
|
|
8
|
+
const out = { urls: [], size: null, pin: false, fresh: false };
|
|
9
|
+
const at = appRoot ? argv.findIndex((a) => a === appRoot || a === '.') : -1;
|
|
10
|
+
const args = at >= 0 ? argv.slice(at + 1) : argv.slice(2);
|
|
11
|
+
for (let i = 0; i < args.length; i++) {
|
|
12
|
+
const a = args[i];
|
|
13
|
+
if (!a || a === '--fg')
|
|
14
|
+
continue;
|
|
15
|
+
if (a === '--pin')
|
|
16
|
+
out.pin = true;
|
|
17
|
+
else if (a === '--fresh')
|
|
18
|
+
out.fresh = true;
|
|
19
|
+
else if (a === '--size' || a.startsWith('--size=')) {
|
|
20
|
+
const m = SIZE.exec((a === '--size' ? args[++i] : a.slice(7)) ?? '');
|
|
21
|
+
if (m)
|
|
22
|
+
out.size = { width: Number(m[1]), height: Number(m[2]) };
|
|
23
|
+
}
|
|
24
|
+
else if (!a.startsWith('--') && !a.startsWith('-psn_'))
|
|
25
|
+
out.urls.push(a);
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.showPageMenu = showPageMenu;
|
|
4
|
+
exports.showTabMenu = showTabMenu;
|
|
5
|
+
const electron_1 = require("electron");
|
|
6
|
+
function showPageMenu(ctx, tab, params) {
|
|
7
|
+
const { wc } = tab;
|
|
8
|
+
const nav = wc.navigationHistory;
|
|
9
|
+
const f = params.editFlags;
|
|
10
|
+
const items = [];
|
|
11
|
+
const sep = () => {
|
|
12
|
+
if (items.length && items.at(-1)?.type !== 'separator')
|
|
13
|
+
items.push({ type: 'separator' });
|
|
14
|
+
};
|
|
15
|
+
if (params.linkURL) {
|
|
16
|
+
items.push({ label: 'Open Link in New Tab', click: () => void ctx.tabs.create({ url: params.linkURL, activate: false, index: ctx.tabs.insertIndexAfterActive() }) });
|
|
17
|
+
items.push({ label: 'Copy Link Address', click: () => electron_1.clipboard.writeText(params.linkURL) });
|
|
18
|
+
sep();
|
|
19
|
+
}
|
|
20
|
+
if (params.mediaType === 'image') {
|
|
21
|
+
items.push({ label: 'Copy Image', click: () => wc.copyImageAt(params.x, params.y) });
|
|
22
|
+
sep();
|
|
23
|
+
}
|
|
24
|
+
if (params.isEditable || params.selectionText) {
|
|
25
|
+
if (params.isEditable)
|
|
26
|
+
items.push({ label: 'Cut', enabled: f.canCut, role: 'cut' });
|
|
27
|
+
items.push({ label: 'Copy', enabled: f.canCopy, role: 'copy' });
|
|
28
|
+
if (params.isEditable)
|
|
29
|
+
items.push({ label: 'Paste', enabled: f.canPaste, role: 'paste' });
|
|
30
|
+
items.push({ label: 'Select All', enabled: f.canSelectAll, role: 'selectAll' });
|
|
31
|
+
sep();
|
|
32
|
+
}
|
|
33
|
+
if (!params.isEditable) {
|
|
34
|
+
items.push({ label: 'Back', enabled: nav.canGoBack(), click: () => nav.goBack() });
|
|
35
|
+
items.push({ label: 'Forward', enabled: nav.canGoForward(), click: () => nav.goForward() });
|
|
36
|
+
items.push({ label: 'Reload', click: () => wc.reload() });
|
|
37
|
+
sep();
|
|
38
|
+
if (!params.selectionText)
|
|
39
|
+
items.push({ label: 'Select All', enabled: f.canSelectAll, role: 'selectAll' });
|
|
40
|
+
}
|
|
41
|
+
sep();
|
|
42
|
+
items.push({ label: 'Inspect Element', click: () => wc.inspectElement(params.x, params.y) });
|
|
43
|
+
const menu = electron_1.Menu.buildFromTemplate(items);
|
|
44
|
+
const extItems = ctx.ext.getContextMenuItems(wc, params);
|
|
45
|
+
if (extItems.length) {
|
|
46
|
+
menu.append(new electron_1.MenuItem({ type: 'separator' }));
|
|
47
|
+
for (const item of extItems)
|
|
48
|
+
menu.append(item);
|
|
49
|
+
}
|
|
50
|
+
menu.popup({ window: ctx.win });
|
|
51
|
+
}
|
|
52
|
+
function showTabMenu(ctx, id) {
|
|
53
|
+
const { tabs } = ctx;
|
|
54
|
+
const tab = tabs.get(id);
|
|
55
|
+
if (!tab)
|
|
56
|
+
return;
|
|
57
|
+
const i = tabs.list.indexOf(tab);
|
|
58
|
+
electron_1.Menu.buildFromTemplate([
|
|
59
|
+
{ label: 'Reload', click: () => tab.wc.reload() },
|
|
60
|
+
{ label: 'Duplicate', click: () => tabs.duplicate(id) },
|
|
61
|
+
{ label: tab.muted ? 'Unmute Tab' : 'Mute Tab', click: () => tabs.toggleMute(id) },
|
|
62
|
+
{ type: 'separator' },
|
|
63
|
+
{ label: 'Close Other Tabs', enabled: tabs.list.length > 1, click: () => tabs.closeOthers(id) },
|
|
64
|
+
{ label: 'Close Tabs to the Right', enabled: i < tabs.list.length - 1, click: () => tabs.closeRight(id) },
|
|
65
|
+
{ type: 'separator' },
|
|
66
|
+
{ label: 'Close', click: () => tabs.close(id) },
|
|
67
|
+
]).popup({ window: ctx.win });
|
|
68
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WEB_STORE_URL = void 0;
|
|
4
|
+
exports.createExtensions = createExtensions;
|
|
5
|
+
exports.setupWebStore = setupWebStore;
|
|
6
|
+
exports.installed = installed;
|
|
7
|
+
exports.actionCount = actionCount;
|
|
8
|
+
exports.install = install;
|
|
9
|
+
exports.remove = remove;
|
|
10
|
+
const electron_chrome_extensions_1 = require("electron-chrome-extensions");
|
|
11
|
+
const electron_chrome_web_store_1 = require("electron-chrome-web-store");
|
|
12
|
+
const node_path_1 = require("node:path");
|
|
13
|
+
exports.WEB_STORE_URL = 'https://chromewebstore.google.com/';
|
|
14
|
+
function createExtensions(ctx) {
|
|
15
|
+
const ext = new electron_chrome_extensions_1.ElectronChromeExtensions({
|
|
16
|
+
session: ctx.session,
|
|
17
|
+
createTab: async (details) => {
|
|
18
|
+
const tab = ctx.tabs.create({ url: details.url, activate: details.active !== false, index: ctx.tabs.insertIndexAfterActive() });
|
|
19
|
+
return [tab.wc, ctx.win];
|
|
20
|
+
},
|
|
21
|
+
selectTab: (wc) => ctx.tabs.activate(wc.id),
|
|
22
|
+
removeTab: (wc) => ctx.tabs.close(wc.id),
|
|
23
|
+
});
|
|
24
|
+
// Registered after the library's own preload, so it runs second and can fill in what the
|
|
25
|
+
// library left out of the chrome.* objects.
|
|
26
|
+
const compat = (0, node_path_1.join)(__dirname, '..', 'preload', 'extension-compat.js');
|
|
27
|
+
ctx.session.registerPreloadScript({ id: 'stage-extension-compat-frame', type: 'frame', filePath: compat });
|
|
28
|
+
ctx.session.registerPreloadScript({ id: 'stage-extension-compat-sw', type: 'service-worker', filePath: compat });
|
|
29
|
+
electron_chrome_extensions_1.ElectronChromeExtensions.handleCRXProtocol(ctx.uiView.webContents.session);
|
|
30
|
+
ext.on('browser-action-popup-created', (popup) => {
|
|
31
|
+
ctx.reveal.setPopupOpen(true);
|
|
32
|
+
if (!ctx.quitting)
|
|
33
|
+
ctx.reveal.show();
|
|
34
|
+
// The library's blur handling can miss focus moving to a BaseWindow.
|
|
35
|
+
const onFocus = () => {
|
|
36
|
+
if (!popup.isDestroyed())
|
|
37
|
+
popup.destroy();
|
|
38
|
+
};
|
|
39
|
+
const done = () => {
|
|
40
|
+
ctx.reveal.setPopupOpen(false);
|
|
41
|
+
if (!ctx.win.isDestroyed())
|
|
42
|
+
ctx.win.off('focus', onFocus);
|
|
43
|
+
};
|
|
44
|
+
ctx.win.on('focus', onFocus);
|
|
45
|
+
if (popup.browserWindow)
|
|
46
|
+
popup.browserWindow.once('closed', done);
|
|
47
|
+
else
|
|
48
|
+
done();
|
|
49
|
+
});
|
|
50
|
+
return ext;
|
|
51
|
+
}
|
|
52
|
+
async function setupWebStore(ctx) {
|
|
53
|
+
const refresh = () => {
|
|
54
|
+
if (ctx.quitting)
|
|
55
|
+
return;
|
|
56
|
+
ctx.rebuildMenu();
|
|
57
|
+
ctx.push();
|
|
58
|
+
};
|
|
59
|
+
ctx.session.extensions.on('extension-loaded', refresh);
|
|
60
|
+
ctx.session.extensions.on('extension-unloaded', refresh);
|
|
61
|
+
await (0, electron_chrome_web_store_1.installChromeWebStore)({ session: ctx.session });
|
|
62
|
+
}
|
|
63
|
+
const all = (session) => session.extensions.getAllExtensions();
|
|
64
|
+
function installed(session) {
|
|
65
|
+
return all(session).map(({ id, name, version }) => ({ id, name, version }));
|
|
66
|
+
}
|
|
67
|
+
function actionCount(session) {
|
|
68
|
+
return all(session).filter((e) => {
|
|
69
|
+
const m = e.manifest;
|
|
70
|
+
return Boolean(m?.action || m?.browser_action);
|
|
71
|
+
}).length;
|
|
72
|
+
}
|
|
73
|
+
function install(session, id) {
|
|
74
|
+
return (0, electron_chrome_web_store_1.installExtension)(id, { session });
|
|
75
|
+
}
|
|
76
|
+
function remove(session, id) {
|
|
77
|
+
return (0, electron_chrome_web_store_1.uninstallExtension)(id, { session });
|
|
78
|
+
}
|
package/dist/main/ipc.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupIpc = setupIpc;
|
|
4
|
+
const electron_1 = require("electron");
|
|
5
|
+
const contract_1 = require("../shared/contract");
|
|
6
|
+
const context_menu_1 = require("./context-menu");
|
|
7
|
+
const suggest_1 = require("./suggest");
|
|
8
|
+
const url_1 = require("./url");
|
|
9
|
+
const BUTTONS = ['left', 'middle', 'right'];
|
|
10
|
+
const DRAG_TICK_MS = 8;
|
|
11
|
+
const DRAG_MAX_MS = 60_000;
|
|
12
|
+
// Wires the UI view's IPC to the main process. Returns a function that stops a window drag.
|
|
13
|
+
function setupIpc(ctx) {
|
|
14
|
+
const { tabs, reveal, win } = ctx;
|
|
15
|
+
const fromUI = (e) => e.sender === ctx.uiView.webContents;
|
|
16
|
+
let drag;
|
|
17
|
+
const endDrag = () => {
|
|
18
|
+
clearInterval(drag);
|
|
19
|
+
drag = undefined;
|
|
20
|
+
};
|
|
21
|
+
const queries = {
|
|
22
|
+
getState: () => ctx.getState(),
|
|
23
|
+
suggest: (query) => (0, suggest_1.suggest)(tabs.list, query),
|
|
24
|
+
};
|
|
25
|
+
const commands = {
|
|
26
|
+
activateTab: (id) => tabs.activate(id),
|
|
27
|
+
closeTab: (id) => tabs.close(id),
|
|
28
|
+
moveTab: (id, toIndex) => tabs.move(id, toIndex),
|
|
29
|
+
showTabMenu: (id) => (0, context_menu_1.showTabMenu)(ctx, id),
|
|
30
|
+
openOmnibox: (mode) => {
|
|
31
|
+
const edit = mode === 'edit';
|
|
32
|
+
reveal.openOverlay(edit ? 'edit' : 'new', edit ? (tabs.active?.url ?? '') : '');
|
|
33
|
+
},
|
|
34
|
+
closeOverlay: () => reveal.closeOverlay(),
|
|
35
|
+
submitOmnibox: (input, options) => {
|
|
36
|
+
const url = (0, url_1.resolveInput)(input);
|
|
37
|
+
reveal.closeOverlay(false);
|
|
38
|
+
if (url)
|
|
39
|
+
tabs.open(url, { newTab: options.newTab });
|
|
40
|
+
tabs.focusActive();
|
|
41
|
+
},
|
|
42
|
+
back: () => tabs.active?.wc.navigationHistory.goBack(),
|
|
43
|
+
forward: () => tabs.active?.wc.navigationHistory.goForward(),
|
|
44
|
+
reload: () => tabs.active?.wc.reload(),
|
|
45
|
+
setBarHover: (hovering) => reveal.setHover(hovering),
|
|
46
|
+
// A click in the transparent band under the floating bar: hide the bar and give it to the page.
|
|
47
|
+
passClick: (x, y, button, clickCount) => {
|
|
48
|
+
const tab = tabs.active;
|
|
49
|
+
if (!tab || tab.wc.isDestroyed() || !Number.isFinite(x) || !Number.isFinite(y))
|
|
50
|
+
return;
|
|
51
|
+
reveal.hideNow();
|
|
52
|
+
const ev = {
|
|
53
|
+
x: Math.round(x),
|
|
54
|
+
y: Math.round(y - ctx.tabBounds().y),
|
|
55
|
+
button: BUTTONS[button] ?? 'left',
|
|
56
|
+
clickCount: Math.min(3, Math.max(1, clickCount || 1)),
|
|
57
|
+
};
|
|
58
|
+
tab.wc.focus();
|
|
59
|
+
tab.wc.sendInputEvent({ type: 'mouseDown', ...ev });
|
|
60
|
+
tab.wc.sendInputEvent({ type: 'mouseUp', ...ev });
|
|
61
|
+
},
|
|
62
|
+
// Fallback window drag: follow the cursor while the UI holds the mouse down.
|
|
63
|
+
startWindowDrag: () => {
|
|
64
|
+
if (drag || win.isFullScreen())
|
|
65
|
+
return;
|
|
66
|
+
const p0 = electron_1.screen.getCursorScreenPoint();
|
|
67
|
+
const [x0 = 0, y0 = 0] = win.getPosition();
|
|
68
|
+
const started = Date.now();
|
|
69
|
+
drag = setInterval(() => {
|
|
70
|
+
if (Date.now() - started > DRAG_MAX_MS || win.isDestroyed())
|
|
71
|
+
return endDrag();
|
|
72
|
+
const p = electron_1.screen.getCursorScreenPoint();
|
|
73
|
+
win.setPosition(x0 + p.x - p0.x, y0 + p.y - p0.y);
|
|
74
|
+
}, DRAG_TICK_MS);
|
|
75
|
+
},
|
|
76
|
+
endWindowDrag: endDrag,
|
|
77
|
+
};
|
|
78
|
+
for (const name of Object.keys(queries)) {
|
|
79
|
+
const fn = queries[name];
|
|
80
|
+
electron_1.ipcMain.handle((0, contract_1.channel)(name), (e, ...args) => (fromUI(e) ? fn(...args) : null));
|
|
81
|
+
}
|
|
82
|
+
for (const name of Object.keys(commands)) {
|
|
83
|
+
const fn = commands[name];
|
|
84
|
+
electron_1.ipcMain.on((0, contract_1.channel)(name), (e, ...args) => {
|
|
85
|
+
if (fromUI(e))
|
|
86
|
+
fn(...args);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return endDrag;
|
|
90
|
+
}
|