stage-browser 0.1.0 → 0.2.0

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.
Files changed (172) hide show
  1. package/README.md +92 -45
  2. package/build/icon.icns +0 -0
  3. package/build/icon.png +0 -0
  4. package/dist/bin/stage.js +111 -0
  5. package/dist/main/cli-args.js +28 -0
  6. package/dist/main/context-menu.js +68 -0
  7. package/dist/main/context.js +2 -0
  8. package/dist/main/extensions.js +78 -0
  9. package/dist/main/ipc.js +73 -0
  10. package/dist/main/main.js +282 -0
  11. package/dist/main/menu.js +140 -0
  12. package/dist/main/reveal.js +170 -0
  13. package/dist/main/selftest.js +570 -0
  14. package/dist/main/store.js +85 -0
  15. package/dist/main/suggest.js +43 -0
  16. package/dist/main/tabs.js +324 -0
  17. package/dist/main/ui-window.js +133 -0
  18. package/dist/main/url.js +38 -0
  19. package/dist/main/window.js +133 -0
  20. package/dist/preload/extension-compat.js +163 -0
  21. package/dist/preload/ui-preload.js +34 -0
  22. package/dist/shared/contract.js +6 -0
  23. package/dist/ui/app.js +692 -0
  24. package/{src → dist}/ui/index.html +15 -5
  25. package/dist/ui/mock.js +500 -0
  26. package/{src → dist}/ui/styles.css +55 -14
  27. package/node_modules/@types/chrome/LICENSE +21 -0
  28. package/node_modules/@types/chrome/README.md +15 -0
  29. package/node_modules/@types/chrome/chrome-cast/index.d.ts +1156 -0
  30. package/node_modules/@types/chrome/har-format/index.d.ts +6 -0
  31. package/node_modules/@types/chrome/index.d.ts +13786 -0
  32. package/node_modules/@types/chrome/package.json +99 -0
  33. package/node_modules/@types/filesystem/LICENSE +21 -0
  34. package/node_modules/@types/filesystem/README.md +15 -0
  35. package/node_modules/@types/filesystem/index.d.ts +564 -0
  36. package/node_modules/@types/filesystem/package.json +26 -0
  37. package/node_modules/@types/filewriter/LICENSE +21 -0
  38. package/node_modules/@types/filewriter/README.md +15 -0
  39. package/node_modules/@types/filewriter/index.d.ts +166 -0
  40. package/node_modules/@types/filewriter/package.json +25 -0
  41. package/node_modules/@types/har-format/LICENSE +21 -0
  42. package/node_modules/@types/har-format/README.md +15 -0
  43. package/node_modules/@types/har-format/index.d.ts +938 -0
  44. package/node_modules/@types/har-format/package.json +31 -0
  45. package/node_modules/adm-zip/LICENSE +21 -0
  46. package/node_modules/adm-zip/README.md +90 -0
  47. package/node_modules/adm-zip/adm-zip.js +1020 -0
  48. package/node_modules/adm-zip/headers/entryHeader.js +396 -0
  49. package/node_modules/adm-zip/headers/index.js +2 -0
  50. package/node_modules/adm-zip/headers/mainHeader.js +177 -0
  51. package/node_modules/adm-zip/methods/deflater.js +33 -0
  52. package/node_modules/adm-zip/methods/index.js +3 -0
  53. package/node_modules/adm-zip/methods/inflater.js +64 -0
  54. package/node_modules/adm-zip/methods/zipcrypto.js +175 -0
  55. package/node_modules/adm-zip/package.json +56 -0
  56. package/node_modules/adm-zip/types.d.ts +223 -0
  57. package/node_modules/adm-zip/util/constants.js +142 -0
  58. package/node_modules/adm-zip/util/decoder.js +5 -0
  59. package/node_modules/adm-zip/util/errors.js +66 -0
  60. package/node_modules/adm-zip/util/fattr.js +76 -0
  61. package/node_modules/adm-zip/util/index.js +5 -0
  62. package/node_modules/adm-zip/util/utils.js +481 -0
  63. package/node_modules/adm-zip/zipEntry.js +415 -0
  64. package/node_modules/adm-zip/zipFile.js +466 -0
  65. package/node_modules/debug/LICENSE +20 -0
  66. package/node_modules/debug/README.md +481 -0
  67. package/node_modules/debug/package.json +64 -0
  68. package/node_modules/debug/src/browser.js +272 -0
  69. package/node_modules/debug/src/common.js +292 -0
  70. package/node_modules/debug/src/index.js +10 -0
  71. package/node_modules/debug/src/node.js +263 -0
  72. package/node_modules/electron-chrome-web-store/README.md +143 -0
  73. package/node_modules/electron-chrome-web-store/dist/chrome-web-store.preload.js +299 -0
  74. package/node_modules/electron-chrome-web-store/dist/cjs/browser/index.js +1674 -0
  75. package/node_modules/electron-chrome-web-store/dist/esm/browser/index.mjs +950 -0
  76. package/node_modules/electron-chrome-web-store/dist/types/browser/api.d.ts +2 -0
  77. package/node_modules/electron-chrome-web-store/dist/types/browser/crx3.d.ts +20 -0
  78. package/node_modules/electron-chrome-web-store/dist/types/browser/id.d.ts +9 -0
  79. package/node_modules/electron-chrome-web-store/dist/types/browser/index.d.ts +62 -0
  80. package/node_modules/electron-chrome-web-store/dist/types/browser/installer.d.ts +29 -0
  81. package/node_modules/electron-chrome-web-store/dist/types/browser/loader.d.ts +18 -0
  82. package/node_modules/electron-chrome-web-store/dist/types/browser/types.d.ts +21 -0
  83. package/node_modules/electron-chrome-web-store/dist/types/browser/updater.d.ts +6 -0
  84. package/node_modules/electron-chrome-web-store/dist/types/browser/utils.d.ts +4 -0
  85. package/node_modules/electron-chrome-web-store/dist/types/common/constants.d.ts +44 -0
  86. package/node_modules/electron-chrome-web-store/dist/types/renderer/chrome-web-store.preload.d.ts +1 -0
  87. package/node_modules/electron-chrome-web-store/package.json +43 -0
  88. package/node_modules/ms/index.js +162 -0
  89. package/node_modules/ms/license.md +21 -0
  90. package/node_modules/ms/package.json +38 -0
  91. package/node_modules/ms/readme.md +59 -0
  92. package/node_modules/pbf/LICENSE +27 -0
  93. package/node_modules/pbf/README.md +293 -0
  94. package/node_modules/pbf/bin/pbf +17 -0
  95. package/node_modules/pbf/compile.js +441 -0
  96. package/node_modules/pbf/dist/pbf-dev.js +838 -0
  97. package/node_modules/pbf/dist/pbf.js +1 -0
  98. package/node_modules/pbf/index.d.ts +206 -0
  99. package/node_modules/pbf/index.js +830 -0
  100. package/node_modules/pbf/package.json +63 -0
  101. package/node_modules/protocol-buffers-schema/.travis.yml +7 -0
  102. package/node_modules/protocol-buffers-schema/LICENSE +21 -0
  103. package/node_modules/protocol-buffers-schema/README.md +122 -0
  104. package/node_modules/protocol-buffers-schema/example.js +11 -0
  105. package/node_modules/protocol-buffers-schema/example.proto +13 -0
  106. package/node_modules/protocol-buffers-schema/index.js +6 -0
  107. package/node_modules/protocol-buffers-schema/package.json +31 -0
  108. package/node_modules/protocol-buffers-schema/parse.js +769 -0
  109. package/node_modules/protocol-buffers-schema/stringify.js +206 -0
  110. package/node_modules/protocol-buffers-schema/test/fixtures/basic.json +90 -0
  111. package/node_modules/protocol-buffers-schema/test/fixtures/basic.proto +11 -0
  112. package/node_modules/protocol-buffers-schema/test/fixtures/comments.json +99 -0
  113. package/node_modules/protocol-buffers-schema/test/fixtures/comments.proto +19 -0
  114. package/node_modules/protocol-buffers-schema/test/fixtures/complex.json +125 -0
  115. package/node_modules/protocol-buffers-schema/test/fixtures/complex.proto +30 -0
  116. package/node_modules/protocol-buffers-schema/test/fixtures/enum.json +42 -0
  117. package/node_modules/protocol-buffers-schema/test/fixtures/enum.proto +8 -0
  118. package/node_modules/protocol-buffers-schema/test/fixtures/escaped-quotes.json +32 -0
  119. package/node_modules/protocol-buffers-schema/test/fixtures/escaped-quotes.proto +3 -0
  120. package/node_modules/protocol-buffers-schema/test/fixtures/extend.json +167 -0
  121. package/node_modules/protocol-buffers-schema/test/fixtures/extend.proto +19 -0
  122. package/node_modules/protocol-buffers-schema/test/fixtures/import.json +30 -0
  123. package/node_modules/protocol-buffers-schema/test/fixtures/import.proto +6 -0
  124. package/node_modules/protocol-buffers-schema/test/fixtures/map.json +33 -0
  125. package/node_modules/protocol-buffers-schema/test/fixtures/map.proto +3 -0
  126. package/node_modules/protocol-buffers-schema/test/fixtures/no-tags.proto +8 -0
  127. package/node_modules/protocol-buffers-schema/test/fixtures/oneof.json +41 -0
  128. package/node_modules/protocol-buffers-schema/test/fixtures/oneof.proto +6 -0
  129. package/node_modules/protocol-buffers-schema/test/fixtures/option.json +364 -0
  130. package/node_modules/protocol-buffers-schema/test/fixtures/option.proto +72 -0
  131. package/node_modules/protocol-buffers-schema/test/fixtures/options.json +47 -0
  132. package/node_modules/protocol-buffers-schema/test/fixtures/options.proto +8 -0
  133. package/node_modules/protocol-buffers-schema/test/fixtures/pheromon-trajectories.proto +8 -0
  134. package/node_modules/protocol-buffers-schema/test/fixtures/reserved.json +55 -0
  135. package/node_modules/protocol-buffers-schema/test/fixtures/reserved.proto +17 -0
  136. package/node_modules/protocol-buffers-schema/test/fixtures/search.json +30 -0
  137. package/node_modules/protocol-buffers-schema/test/fixtures/search.proto +5 -0
  138. package/node_modules/protocol-buffers-schema/test/fixtures/service.json +108 -0
  139. package/node_modules/protocol-buffers-schema/test/fixtures/service.proto +30 -0
  140. package/node_modules/protocol-buffers-schema/test/fixtures/valid-packed.proto +35 -0
  141. package/node_modules/protocol-buffers-schema/test/fixtures/version.json +90 -0
  142. package/node_modules/protocol-buffers-schema/test/fixtures/version.proto +13 -0
  143. package/node_modules/protocol-buffers-schema/test/index.js +157 -0
  144. package/node_modules/protocol-buffers-schema/tokenize.js +56 -0
  145. package/node_modules/resolve-protobuf-schema/.travis.yml +3 -0
  146. package/node_modules/resolve-protobuf-schema/LICENSE +21 -0
  147. package/node_modules/resolve-protobuf-schema/README.md +49 -0
  148. package/node_modules/resolve-protobuf-schema/index.js +50 -0
  149. package/node_modules/resolve-protobuf-schema/package.json +25 -0
  150. package/node_modules/resolve-protobuf-schema/test/a.proto +5 -0
  151. package/node_modules/resolve-protobuf-schema/test/b.proto +5 -0
  152. package/node_modules/resolve-protobuf-schema/test/c.proto +3 -0
  153. package/node_modules/resolve-protobuf-schema/test/index.js +49 -0
  154. package/package.json +35 -11
  155. package/bin/stage.js +0 -52
  156. package/src/main/cli-args.js +0 -28
  157. package/src/main/context-menu.js +0 -64
  158. package/src/main/extensions.js +0 -61
  159. package/src/main/main.js +0 -310
  160. package/src/main/menu.js +0 -171
  161. package/src/main/reveal.js +0 -141
  162. package/src/main/selftest.js +0 -383
  163. package/src/main/store.js +0 -77
  164. package/src/main/suggest.js +0 -50
  165. package/src/main/tabs.js +0 -351
  166. package/src/main/url.js +0 -37
  167. package/src/main/window.js +0 -71
  168. package/src/preload/extension-compat.js +0 -34
  169. package/src/preload/ui-preload.js +0 -40
  170. package/src/ui/app.js +0 -588
  171. package/src/ui/mock.js +0 -455
  172. /package/{src → dist}/ui/newtab.html +0 -0
package/README.md CHANGED
@@ -1,35 +1,64 @@
1
- # Stage
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
- A minimal Chromium browser for screen sharing. The page fills the whole window. Tabs stay out of sight until you move the cursor to the top edge, then slide in over the page and hide again when you move away.
5
+ <h1 align="center">Stage</h1>
4
6
 
5
- Built for workshops, webinars, and demos: share just the Stage window and your audience sees the site, nothing else.
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>
6
13
 
7
- - **Viewport first.** No toolbar, no address bar, no bookmarks bar. Tabs float in a small capsule that appears only when you reach for it.
8
- - **Chrome extensions.** Install from the Chrome Web Store, including the Okta Browser Plugin (Extensions menu → Install Okta Browser Plugin).
9
- - **Runs from the terminal.** No `.app` to build, sign, or notarize.
10
- - **Presenter helpers.** Window-size presets (1280×720, 1440×900, 1600×900, 1920×1080), zoom shortcuts, and a pinned-bar mode when you want the tabs visible.
14
+ <p align="center">
15
+ <code>npx stage-browser https://example.com</code>
16
+ </p>
11
17
 
12
- macOS only.
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>
13
21
 
14
- ## Install and run
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.
15
31
 
16
32
  ```sh
17
- npx stage-browser https://example.com # try it without installing
18
- npm i -g stage-browser # or install the `stage` command
19
- stage https://example.com docs.example.com
33
+ npx stage-browser https://example.com # run it now
34
+ npm i -g stage-browser # or keep the short `stage` command
20
35
  ```
21
36
 
22
- From a clone:
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.**
23
42
 
24
43
  ```sh
25
- npm install
26
- npm run cli:install # links bin/stage.js to ~/.local/bin/stage
27
- stage
44
+ stage --size 1280x720 app.example.com docs.example.com
28
45
  ```
29
46
 
30
- The first install downloads Electron's Chromium build (about 100 MB).
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.
31
50
 
32
- ## Usage
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
33
62
 
34
63
  ```
35
64
  stage open Stage (restores the last session)
@@ -42,49 +71,67 @@ stage --fg run in the foreground with logs in the terminal
42
71
 
43
72
  If Stage is already running, `stage <url>` opens the URL as a tab in the running window.
44
73
 
45
- ## Shortcuts
74
+ ## Hands on the keys.
46
75
 
47
76
  | Shortcut | Action |
48
77
  | --- | --- |
49
- | ⌘T | new tab (opens the omnibox) |
50
- | ⌘L | go to an address or search |
51
- | ⌘W / ⇧⌘T | close tab / reopen closed tab |
52
- | ⌘1 … ⌘9 | jump to a tab (⌘9 = last) |
53
- | ⌃Tab, ⇧⌘] / ⇧⌘[ | next / previous tab |
54
- | ⌘[ / ⌘] | back / forward |
55
- | ⌘R / ⇧⌘R | reload / hard reload |
56
- | ⌘= / ⌘- / ⌘0 | zoom in / out / reset |
57
- | ⇧⌘B | pin or unpin the tab bar |
58
- | ⌃⌘F | full screen |
59
- | ⇧⌘O | open the current page in Google Chrome |
60
- | ⌥⌘I | developer tools |
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 |
61
90
 
62
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.
63
92
 
64
- ## Extensions and Okta
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.
65
96
 
66
- Use **Extensions → Install Okta Browser Plugin**, or open the Chrome Web Store from the same menu and click "Add to Chrome" on any extension. Extension icons appear on the right of the tab bar.
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.
67
98
 
68
- Stage uses [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. An extension that needs a missing API may only partly work. When that happens, ⇧⌘O opens the page in Google Chrome.
99
+ ## Before you go live.
69
100
 
70
- Links to apps (Zoom, Slack, Okta Verify) open in those apps.
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.
71
103
 
72
- ## Where things live
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.
73
106
 
74
- - Profile (cookies, logins, extensions, saved session, history): `~/Library/Application Support/Stage`. A clone, a global install, and npx all share it.
75
- - Errors are logged to `~/Library/Application Support/Stage/stage.log` instead of interrupting you with a dialog.
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.
76
109
 
77
- ## Known limitations
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.
78
112
 
79
- - The bold app name in the macOS menu bar reads "Electron", because Stage runs the stock Electron binary rather than a renamed `.app`. Sharing only the Stage window hides it.
80
- - One window. Links that open new windows become tabs; sign-in pop-ups (OAuth) open as small separate windows so the sign-in flow keeps working.
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.
81
115
 
82
- ## Development
116
+ **Windows or Linux?**
117
+ Not yet. Stage is macOS only.
118
+
119
+ ## Build from source
83
120
 
84
121
  ```sh
85
- npm start # run from source
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
86
129
  npm run selftest # scripted end-to-end checks; writes selftest-out/results.json and screenshots
87
- npm run ui:preview # renders the tab bar and omnibox in mock mode with headless Chrome
130
+ npm run ui:preview # render the tab bar and address box in mock mode with headless Chrome
88
131
  ```
89
132
 
90
- `docs/CONTRACT.md` describes the window layout and the interface between the main process (`src/main/`) and the overlay UI (`src/ui/`).
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>
Binary file
package/build/icon.png CHANGED
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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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.ui.view.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
+ }
@@ -0,0 +1,73 @@
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 window_1 = require("./window");
10
+ const BUTTONS = ['left', 'middle', 'right'];
11
+ // Wires the UI window's IPC to the main process.
12
+ function setupIpc(ctx) {
13
+ const { tabs, reveal, win, drag } = ctx;
14
+ const fromUI = (e) => e.sender === ctx.ui.view.webContents;
15
+ const queries = {
16
+ getState: () => ctx.getState(),
17
+ suggest: (query) => (0, suggest_1.suggest)(tabs.list, query),
18
+ };
19
+ const commands = {
20
+ activateTab: (id) => tabs.activate(id),
21
+ closeTab: (id) => tabs.close(id),
22
+ moveTab: (id, toIndex) => tabs.move(id, toIndex),
23
+ showTabMenu: (id) => (0, context_menu_1.showTabMenu)(ctx, id),
24
+ openOmnibox: (mode) => {
25
+ const edit = mode === 'edit';
26
+ reveal.openOverlay(edit ? 'edit' : 'new', edit ? (tabs.active?.url ?? '') : '');
27
+ },
28
+ closeOverlay: () => reveal.closeOverlay(),
29
+ submitOmnibox: (input, options) => {
30
+ const url = (0, url_1.resolveInput)(input);
31
+ reveal.closeOverlay(false);
32
+ if (url)
33
+ tabs.open(url, { newTab: options.newTab });
34
+ tabs.focusActive();
35
+ },
36
+ back: () => tabs.active?.wc.navigationHistory.goBack(),
37
+ forward: () => tabs.active?.wc.navigationHistory.goForward(),
38
+ reload: () => tabs.active?.wc.reload(),
39
+ setBarHover: (hovering) => reveal.setHover(hovering),
40
+ // A click the UI window caught in the transparent band under the floating bar, before it
41
+ // started letting the mouse through there: hide the bar and give the click to the page.
42
+ passClick: (x, y, button, clickCount) => {
43
+ const tab = tabs.active;
44
+ if (!tab || tab.wc.isDestroyed() || !Number.isFinite(x) || !Number.isFinite(y))
45
+ return;
46
+ reveal.hideNow();
47
+ const ev = {
48
+ x: Math.round(x),
49
+ y: Math.round(y),
50
+ button: BUTTONS[button] ?? 'left',
51
+ clickCount: Math.min(3, Math.max(1, clickCount || 1)),
52
+ };
53
+ win.focus();
54
+ tab.wc.focus();
55
+ tab.wc.sendInputEvent({ type: 'mouseDown', ...ev });
56
+ tab.wc.sendInputEvent({ type: 'mouseUp', ...ev });
57
+ },
58
+ startWindowDrag: () => drag.start(),
59
+ endWindowDrag: () => drag.end(),
60
+ windowAction: (action) => (0, window_1.windowAction)(win, action),
61
+ };
62
+ for (const name of Object.keys(queries)) {
63
+ const fn = queries[name];
64
+ electron_1.ipcMain.handle((0, contract_1.channel)(name), (e, ...args) => (fromUI(e) ? fn(...args) : null));
65
+ }
66
+ for (const name of Object.keys(commands)) {
67
+ const fn = commands[name];
68
+ electron_1.ipcMain.on((0, contract_1.channel)(name), (e, ...args) => {
69
+ if (fromUI(e))
70
+ fn(...args);
71
+ });
72
+ }
73
+ }