@omega.js/desktop 0.51.0 → 0.53.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.
- package/README.md +18 -13
- package/dist/assets/css/core/_initialize.scss +1 -1
- package/dist/assets/js/core/app-shell.js +14 -15
- package/dist/assets/themes/_template/_theme.js +6 -6
- package/dist/assets/themes/base/_includes/global/sections/account.html +4 -4
- package/dist/assets/themes/base/_includes/global/sections/app-sidebar.html +5 -5
- package/dist/assets/themes/base/_layouts/frontend/pages/account/index.html +3 -3
- package/dist/assets/themes/base/_layouts/frontend/pages/alternatives/index.html +1 -1
- package/dist/assets/themes/base/_layouts/frontend/pages/blog/tags/tag.html +1 -1
- package/dist/assets/themes/base/_layouts/frontend/pages/payment/confirmation.html +1 -1
- package/dist/assets/themes/base/_sections/marketing/newsletter-cta/section.js +2 -3
- package/dist/assets/themes/base/_sections/verts/unit/section.html +1 -1
- package/dist/assets/themes/base/_sections/verts/unit/section.js +3 -4
- package/dist/assets/themes/base/_theme.js +4 -3
- package/dist/assets/themes/bootstrap/_theme.js +2 -2
- package/dist/assets/themes/bootstrap/overrides/_links.scss +1 -1
- package/dist/assets/themes/classy/_theme.js +8 -6
- package/dist/assets/themes/classy/css/marketing/_sections.scss +1 -2
- package/dist/assets/themes/classy/js/hero-demo-form.js +3 -2
- package/dist/assets/themes/neobrutalism/_theme.js +5 -5
- package/dist/assets/themes/neobrutalism/js/pages/test/libraries/layers/index.js +1 -1
- package/dist/assets/themes/newsflash/_theme.js +6 -6
- package/dist/assets/themes/newsflash/js/pages/test/libraries/layers/index.js +1 -1
- package/dist/build.js +87 -111
- package/dist/cli.js +1 -1
- package/dist/commands/build.js +2 -2
- package/dist/commands/cdp/capture.js +2 -2
- package/dist/commands/cdp/quit.js +2 -2
- package/dist/commands/cdp/relaunch.js +2 -2
- package/dist/commands/cdp/theme.js +1 -1
- package/dist/commands/clean.js +2 -2
- package/dist/commands/deploy.js +4 -4
- package/dist/commands/finalize-release.js +4 -4
- package/dist/commands/install.js +3 -3
- package/dist/commands/launch.js +2 -2
- package/dist/commands/lib/deploy-precheck.js +3 -3
- package/dist/commands/lib/ensure-target.js +6 -6
- package/dist/commands/package.js +2 -2
- package/dist/commands/publish.js +2 -2
- package/dist/commands/release.js +3 -3
- package/dist/commands/runner.js +145 -48
- package/dist/commands/sign-windows.js +5 -5
- package/dist/commands/test.js +4 -4
- package/dist/commands/update.js +2 -2
- package/dist/commands/validate-certs.js +4 -4
- package/dist/commands/version.js +3 -3
- package/dist/defaults/.github/workflows/build.yml +2 -0
- package/dist/defaults/AGENTS.md +17 -8
- package/dist/defaults/config/omega.json5 +7 -7
- package/dist/defaults/hooks/build/post.js +1 -1
- package/dist/defaults/hooks/build/pre.js +1 -1
- package/dist/defaults/hooks/deploy/pre.js +1 -1
- package/dist/defaults/hooks/release/post.js +1 -1
- package/dist/defaults/hooks/release/pre.js +1 -1
- package/dist/defaults/src/assets/js/components/about/index.js +3 -5
- package/dist/defaults/src/assets/js/components/main/index.js +3 -5
- package/dist/defaults/src/assets/js/components/settings/index.js +3 -5
- package/dist/defaults/src/integrations/context-menu/index.js +2 -2
- package/dist/defaults/src/integrations/menu/index.js +3 -3
- package/dist/defaults/src/integrations/tray/index.js +3 -3
- package/dist/defaults/src/main.js +3 -5
- package/dist/defaults/src/preload.js +3 -5
- package/dist/defaults/test/README.md +2 -2
- package/dist/gulp/main.js +9 -10
- package/dist/gulp/tasks/audit.js +7 -7
- package/dist/gulp/tasks/build-config.js +8 -8
- package/dist/gulp/tasks/bundle.js +16 -16
- package/dist/gulp/tasks/defaults.js +3 -3
- package/dist/gulp/tasks/distribute.js +2 -2
- package/dist/gulp/tasks/html.js +9 -9
- package/dist/gulp/tasks/package-quick.js +3 -3
- package/dist/gulp/tasks/package.js +3 -3
- package/dist/gulp/tasks/release.js +3 -3
- package/dist/gulp/tasks/sass.js +6 -6
- package/dist/gulp/tasks/serve.js +4 -4
- package/dist/hooks/notarize-artifacts.js +1 -1
- package/dist/hooks/notarize.js +1 -1
- package/dist/index.js +5 -8
- package/dist/lib/_environment-mixin.js +50 -0
- package/dist/lib/_lifecycle-mixin.js +45 -0
- package/dist/lib/analytics.js +33 -35
- package/dist/lib/app-state.js +14 -14
- package/dist/lib/auth-flow.js +18 -18
- package/dist/lib/auth-persistence.js +12 -12
- package/dist/lib/auth.js +421 -0
- package/dist/lib/auto-updater.js +49 -49
- package/dist/lib/context-menu.js +13 -13
- package/dist/lib/context.js +19 -19
- package/dist/lib/deep-link.js +34 -34
- package/dist/lib/fontawesome.js +5 -5
- package/dist/lib/ipc.js +4 -4
- package/dist/lib/menu.js +25 -25
- package/dist/lib/protocol.js +5 -5
- package/dist/lib/remote-config.js +22 -22
- package/dist/lib/remote-scripts.js +21 -21
- package/dist/lib/restart-manager/index.js +28 -28
- package/dist/lib/sign-helpers/exec-with-limit.js +1 -1
- package/dist/lib/sign-helpers/sign-events.js +1 -1
- package/dist/lib/startup.js +18 -13
- package/dist/lib/storage.js +10 -10
- package/dist/lib/templating.js +16 -16
- package/dist/lib/theme.js +10 -10
- package/dist/lib/tray.js +27 -27
- package/dist/lib/usage.js +11 -11
- package/dist/lib/window-manager.js +26 -26
- package/dist/main.js +398 -483
- package/dist/preload.js +236 -176
- package/dist/renderer.js +417 -391
- package/dist/runner/job-started.js +1 -1
- package/dist/test/fixtures/consumer-app/config/omega.json5 +1 -1
- package/dist/test/fixtures/consumer-app/src/assets/js/components/main/index.js +8 -11
- package/dist/test/fixtures/consumer-app/src/main.js +5 -7
- package/dist/test/fixtures/consumer-app/src/preload.js +2 -2
- package/dist/test/harness/boot-entry.js +22 -20
- package/dist/test/harness/main-entry.js +31 -30
- package/dist/test/harness/renderer-entry.js +5 -5
- package/dist/test/harness/renderer-preload.js +137 -141
- package/dist/test/index.js +10 -10
- package/dist/test/runner.js +2 -2
- package/dist/test/runners/boot.js +7 -6
- package/dist/test/runners/electron.js +3 -2
- package/dist/test/runners/render-event.js +2 -2
- package/dist/test/suites/boot/consumer-app-boots.test.js +57 -26
- package/dist/test/suites/boot/restart-manager.test.js +2 -2
- package/dist/test/suites/boot/storage-bundled.test.js +5 -5
- package/dist/test/suites/boot/theme.test.js +13 -13
- package/dist/test/suites/build/audit.test.js +1 -1
- package/dist/test/suites/build/auth-persistence-resolve.test.js +6 -6
- package/dist/test/suites/build/boot-fixture.test.js +2 -2
- package/dist/test/suites/build/boot-runner-timeout.test.js +6 -5
- package/dist/test/suites/build/brand-scss.test.js +1 -1
- package/dist/test/suites/build/build-json-bake.test.js +1 -1
- package/dist/test/suites/build/cli.test.js +2 -2
- package/dist/test/suites/build/config-schema.test.js +5 -5
- package/dist/test/suites/build/defaults-scaffold.test.js +2 -2
- package/dist/test/suites/build/deploy-hook.test.js +3 -3
- package/dist/test/suites/build/ensure-target.test.js +2 -2
- package/dist/test/suites/build/env-delivery.test.js +2 -2
- package/dist/test/suites/build/esm-only-dependency.test.js +2 -2
- package/dist/test/suites/build/exports.test.js +9 -8
- package/dist/test/suites/build/get-config.test.js +4 -4
- package/dist/test/suites/build/manifest-deps.test.js +1 -1
- package/dist/test/suites/build/merge-line-files.test.js +1 -1
- package/dist/test/suites/build/omega-shell.test.js +34 -2
- package/dist/test/suites/build/omega.test.js +350 -0
- package/dist/test/suites/build/renderer-auth-bridge.test.js +211 -78
- package/dist/test/suites/build/runner.test.js +612 -5
- package/dist/test/suites/build/sentry.test.js +2 -2
- package/dist/test/suites/build/sign-windows-e2e.test.js +2 -2
- package/dist/test/suites/build/templating.test.js +3 -3
- package/dist/test/suites/build/test-stealth.test.js +7 -9
- package/dist/test/suites/build/url-helpers.test.js +55 -56
- package/dist/test/suites/build/validate-config.test.js +2 -2
- package/dist/test/suites/build/wave5-pins.test.js +2 -2
- package/dist/test/suites/main/analytics.test.js +59 -59
- package/dist/test/suites/main/app-state.test.js +66 -66
- package/dist/test/suites/main/auth-flow.test.js +41 -41
- package/dist/test/suites/main/auth-persistence.test.js +54 -43
- package/dist/test/suites/main/{client-bridge.integration.test.js → auth.integration.test.js} +10 -9
- package/dist/test/suites/main/auth.test.js +336 -0
- package/dist/test/suites/main/auto-updater.test.js +134 -134
- package/dist/test/suites/main/boot-sequence.test.js +37 -49
- package/dist/test/suites/main/context-menu.test.js +51 -50
- package/dist/test/suites/main/context.test.js +25 -25
- package/dist/test/suites/main/deep-link.test.js +74 -74
- package/dist/test/suites/main/fontawesome.test.js +27 -27
- package/dist/test/suites/main/ipc.test.js +35 -35
- package/dist/test/suites/main/menu.test.js +101 -100
- package/dist/test/suites/main/protocol.test.js +19 -19
- package/dist/test/suites/main/remote-config.test.js +63 -63
- package/dist/test/suites/main/remote-scripts.test.js +103 -103
- package/dist/test/suites/main/request.test.js +71 -0
- package/dist/test/suites/main/restart-manager.test.js +33 -33
- package/dist/test/suites/main/startup-paths-and-ua.test.js +4 -4
- package/dist/test/suites/main/startup.test.js +26 -26
- package/dist/test/suites/main/stealth-window.test.js +1 -1
- package/dist/test/suites/main/storage.test.js +25 -25
- package/dist/test/suites/main/theme.test.js +34 -34
- package/dist/test/suites/main/tray.test.js +79 -79
- package/dist/test/suites/main/url-helpers.test.js +133 -133
- package/dist/test/suites/main/usage.test.js +25 -25
- package/dist/test/suites/main/window-bounds.test.js +27 -27
- package/dist/test/suites/main/window-manager.test.js +44 -44
- package/dist/test/suites/renderer/analytics-bridge.test.js +5 -5
- package/dist/test/suites/renderer/cross-context-helpers.test.js +37 -31
- package/dist/test/suites/renderer/round-trip.test.js +3 -3
- package/dist/test/suites/renderer/tooltips.test.js +15 -15
- package/dist/test/suites/renderer/{window-em-surface.test.js → window-desktop-surface.test.js} +27 -7
- package/dist/test/utils/extended-mode-warning.js +1 -1
- package/dist/utils/boot-harness.js +56 -0
- package/dist/utils/mode-helpers.js +2 -15
- package/dist/utils/ship-keys.js +3 -3
- package/dist/utils/signing-status.js +51 -0
- package/dist/utils/test-events.js +7 -0
- package/dist/utils/test-stealth.js +6 -6
- package/dist/utils/url-helpers.js +52 -42
- package/dist/utils/user-agent.js +44 -0
- package/dist/vendor/account/engine.js +3 -3
- package/dist/vendor/account/index.js +14 -45
- package/dist/vendor/account/resolve-account.js +44 -0
- package/dist/vendor/account/schema.js +1 -1
- package/dist/vendor/account/user.js +99 -0
- package/dist/vendor/config/client-config.js +1 -1
- package/dist/vendor/config/environment.js +11 -30
- package/dist/vendor/config/index.js +13 -12
- package/dist/vendor/config/load.js +1 -2
- package/dist/vendor/config/platforms.js +1 -1
- package/dist/vendor/config/repo.js +24 -0
- package/dist/vendor/config/retired-keys.js +2 -2
- package/dist/vendor/config/schema.js +5 -8
- package/dist/vendor/config/site-global.js +2 -3
- package/dist/vendor/config/validate.js +1 -2
- package/dist/vendor/config/winback.js +1 -1
- package/dist/vendor/devkit/actions-secrets.js +1 -1
- package/dist/vendor/devkit/attach-log-file.js +1 -1
- package/dist/vendor/devkit/brand-version.js +162 -1
- package/dist/vendor/devkit/build-json.js +1 -1
- package/dist/vendor/devkit/cli-router.js +3 -4
- package/dist/vendor/devkit/defaults-engine.js +9 -11
- package/dist/vendor/devkit/deploy.js +64 -4
- package/dist/vendor/devkit/git-remote.js +78 -1
- package/dist/vendor/devkit/local.js +53 -3
- package/dist/vendor/devkit/lockfile.js +127 -0
- package/dist/vendor/devkit/merge-line-files.js +2 -3
- package/dist/vendor/devkit/pack-local.js +4 -7
- package/dist/vendor/devkit/preludes/origin-heal.js +35 -49
- package/dist/vendor/devkit/target-secrets.js +34 -45
- package/dist/vendor/devkit/test/runner-core.js +6 -6
- package/dist/vendor/monitoring/env.js +2 -2
- package/dist/vendor/monitoring/index.js +1 -1
- package/dist/vendor/monitoring/main.js +1 -1
- package/dist/vendor/monitoring/preload.js +1 -1
- package/dist/vendor/monitoring/renderer.js +1 -1
- package/docs/analytics.md +8 -8
- package/docs/app-state.md +19 -19
- package/docs/audit.md +4 -4
- package/docs/{client-bridge.md → auth.md} +88 -73
- package/docs/auto-updater.md +8 -8
- package/docs/boot-sequence.md +11 -6
- package/docs/build-system.md +1 -1
- package/docs/cdp-debugging.md +1 -1
- package/docs/common-mistakes.md +7 -7
- package/docs/config-schema.md +1 -1
- package/docs/context-menu.md +13 -13
- package/docs/context.md +11 -11
- package/docs/css.md +3 -9
- package/docs/deep-link.md +25 -25
- package/docs/environment-detection.md +16 -16
- package/docs/fontawesome.md +7 -5
- package/docs/hooks.md +8 -8
- package/docs/index.md +39 -28
- package/docs/ipc.md +10 -10
- package/docs/lib-modules.md +9 -9
- package/docs/logging.md +12 -14
- package/docs/menu.md +18 -18
- package/docs/releasing.md +4 -2
- package/docs/remote-config.md +9 -9
- package/docs/remote-scripts.md +12 -12
- package/docs/restart-manager.md +8 -8
- package/docs/runner.md +12 -10
- package/docs/sentry.md +4 -4
- package/docs/shared/analytics.md +1 -1
- package/docs/shared/brands.md +1 -1
- package/docs/shared/breaking-changes.md +79 -13
- package/docs/shared/config.md +24 -21
- package/docs/shared/deploys.md +30 -7
- package/docs/shared/local-dev.md +5 -3
- package/docs/shared/logging.md +1 -1
- package/docs/shared/monitoring.md +5 -5
- package/docs/shared/testing.md +2 -2
- package/docs/shared/theming.md +1 -1
- package/docs/shared/translation.md +19 -10
- package/docs/signing.md +1 -1
- package/docs/startup.md +16 -16
- package/docs/storage.md +11 -11
- package/docs/templating.md +3 -3
- package/docs/test-boot-layer.md +12 -12
- package/docs/test-framework.md +17 -17
- package/docs/themes.md +7 -7
- package/docs/tooltips.md +2 -2
- package/docs/tray.md +31 -31
- package/docs/usage.md +7 -7
- package/docs/verts.md +1 -1
- package/docs/windows.md +22 -22
- package/package.json +3 -4
- package/dist/lib/client-bridge.js +0 -374
- package/dist/lib/logger.js +0 -4
- package/dist/test/suites/build/manager.test.js +0 -213
- package/dist/test/suites/main/client-bridge.test.js +0 -262
package/dist/lib/auto-updater.js
CHANGED
|
@@ -49,16 +49,16 @@ const STORAGE_KEY = 'autoUpdater';
|
|
|
49
49
|
// install fires whenever the user eventually walks away. We never re-prompt
|
|
50
50
|
// for the same version (tracked via `_promptedForVersion`).
|
|
51
51
|
//
|
|
52
|
-
// Consumer hook: `
|
|
52
|
+
// Consumer hook: `omega.autoUpdater.markActive()` lets app code force-bump the
|
|
53
53
|
// activity timestamp from anywhere (e.g. just received an auth event, finished a
|
|
54
54
|
// long-running renderer task, etc.). Use sparingly — the built-in signals cover
|
|
55
55
|
// 99% of real activity.
|
|
56
56
|
//
|
|
57
|
-
// Test mode: when `
|
|
57
|
+
// Test mode: when `omega.isTesting()` is true, the threshold collapses to 3s so
|
|
58
58
|
// integration tests can drive a real download → idle wait → install in ~5s instead
|
|
59
59
|
// of 15min. Both timers (feed-check + idle-eval) likewise drop to 500ms in tests so
|
|
60
60
|
// the full sequence fires inside a test run. Wired in `_idleThresholdMs()` and the
|
|
61
|
-
// initialize() timer setup based on the
|
|
61
|
+
// initialize() timer setup based on the omega instance's `isTesting()` helper.
|
|
62
62
|
const IDLE_INSTALL_THRESHOLD_MS = 15 * 60 * 1000; // 15 min — production
|
|
63
63
|
const IDLE_INSTALL_THRESHOLD_MS_TESTING = 3 * 1000; // 3 sec — when isTesting()
|
|
64
64
|
const IDLE_TICK_MS_TESTING = 500; // 500ms periodic tick when testing
|
|
@@ -109,7 +109,7 @@ function freshState() {
|
|
|
109
109
|
|
|
110
110
|
const autoUpdater = {
|
|
111
111
|
_initialized: false,
|
|
112
|
-
|
|
112
|
+
_omega: null,
|
|
113
113
|
_library: null,
|
|
114
114
|
_options: null,
|
|
115
115
|
_state: freshState(),
|
|
@@ -125,12 +125,12 @@ const autoUpdater = {
|
|
|
125
125
|
_promptedForVersion: null, // version string we've already prompted about — never prompt twice for the same version
|
|
126
126
|
_activityHooksWired: false, // guard: only wire main-side activity listeners once per process
|
|
127
127
|
|
|
128
|
-
async initialize(
|
|
129
|
-
autoUpdater.
|
|
128
|
+
async initialize(omega) {
|
|
129
|
+
autoUpdater._omega = omega;
|
|
130
130
|
autoUpdater._initialized = true;
|
|
131
131
|
autoUpdater._state = freshState();
|
|
132
132
|
|
|
133
|
-
const cfg = (
|
|
133
|
+
const cfg = (omega && omega.config && omega.config.autoUpdate) || {};
|
|
134
134
|
autoUpdater._options = { ...DEFAULTS, ...cfg };
|
|
135
135
|
|
|
136
136
|
if (autoUpdater._options.enabled === false) {
|
|
@@ -150,21 +150,21 @@ const autoUpdater = {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// 3. IPC: renderer status query + actions. Unhandle first so re-init is idempotent.
|
|
153
|
-
if (
|
|
153
|
+
if (omega && omega.ipc) {
|
|
154
154
|
const channels = [
|
|
155
155
|
['desktop:auto-updater:status', async () => autoUpdater.getStatus()],
|
|
156
156
|
['desktop:auto-updater:check-now', async () => autoUpdater.checkNow({ userInitiated: true })],
|
|
157
157
|
['desktop:auto-updater:install-now', async () => autoUpdater.installNow()],
|
|
158
158
|
];
|
|
159
159
|
for (const [chan, fn] of channels) {
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
omega.ipc.unhandle(chan);
|
|
161
|
+
omega.ipc.handle(chan, fn);
|
|
162
162
|
}
|
|
163
163
|
// Activity ping from preload (debounced renderer-side mouse/keyboard/focus).
|
|
164
164
|
// Listener (not handle) — fire-and-forget, no response needed. Set-backed
|
|
165
165
|
// listener registry deduplicates same-fn re-adds, so re-init is safe.
|
|
166
|
-
if (typeof
|
|
167
|
-
|
|
166
|
+
if (typeof omega.ipc.on === 'function') {
|
|
167
|
+
omega.ipc.on('desktop:auto-updater:activity', autoUpdater._onActivityIpc);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -188,10 +188,10 @@ const autoUpdater = {
|
|
|
188
188
|
// a downloaded update based on user idle time. Default 1m cadence so a
|
|
189
189
|
// downloaded update installs promptly when the user steps away.
|
|
190
190
|
//
|
|
191
|
-
// In tests (`
|
|
191
|
+
// In tests (`omega.isTesting() === true`) both cadences collapse to
|
|
192
192
|
// IDLE_TICK_MS_TESTING (500ms) so an integration test sees the full sequence
|
|
193
193
|
// fire within seconds of a download.
|
|
194
|
-
const isTesting =
|
|
194
|
+
const isTesting = omega.isTesting();
|
|
195
195
|
const feedInterval = isTesting ? IDLE_TICK_MS_TESTING : autoUpdater._options.feedCheckIntervalMs;
|
|
196
196
|
const idleInterval = isTesting ? IDLE_TICK_MS_TESTING : autoUpdater._options.idleEvalIntervalMs;
|
|
197
197
|
|
|
@@ -281,7 +281,7 @@ const autoUpdater = {
|
|
|
281
281
|
// Same doctrine as _isSimulating(): a packaged production build may simulate, but
|
|
282
282
|
// only when it was LAUNCHED for QA with OMEGA_DEV_UPDATE set. Without that opt-in a
|
|
283
283
|
// shipped binary must never be talked into faking an update it cannot deliver.
|
|
284
|
-
if (autoUpdater.
|
|
284
|
+
if (autoUpdater._omega.isProduction() && !autoUpdater._isSimulating()) {
|
|
285
285
|
throw new Error('simulate(): refused in a production build. Relaunch with OMEGA_DEV_UPDATE set to simulate updates.');
|
|
286
286
|
}
|
|
287
287
|
|
|
@@ -320,7 +320,7 @@ const autoUpdater = {
|
|
|
320
320
|
|
|
321
321
|
// Bump the activity timestamp. Called automatically by the built-in activity hooks
|
|
322
322
|
// (renderer mouse/keyboard, browser-window focus). Consumer code can also call this
|
|
323
|
-
// directly from anywhere (`
|
|
323
|
+
// directly from anywhere (`omega.autoUpdater.markActive()`) to force-bump on
|
|
324
324
|
// app-specific activity.
|
|
325
325
|
markActive() {
|
|
326
326
|
autoUpdater._lastActivityAt = Date.now();
|
|
@@ -341,13 +341,13 @@ const autoUpdater = {
|
|
|
341
341
|
logger.log('Dev mode — skipping real quitAndInstall().');
|
|
342
342
|
return true;
|
|
343
343
|
}
|
|
344
|
-
// Flip the
|
|
344
|
+
// Flip the omega instance's quit flag so the window-manager close handler lets the
|
|
345
345
|
// close events through instead of trapping them with hide-on-close. Without
|
|
346
346
|
// this, quitAndInstall() fires before-quit but the BrowserWindow's close
|
|
347
347
|
// handler (which runs FIRST since it has its own listener) would call
|
|
348
348
|
// event.preventDefault() and the install would just hide the window.
|
|
349
|
-
if (autoUpdater.
|
|
350
|
-
autoUpdater.
|
|
349
|
+
if (autoUpdater._omega) {
|
|
350
|
+
autoUpdater._omega._allowQuit = true;
|
|
351
351
|
}
|
|
352
352
|
if (autoUpdater._library && typeof autoUpdater._library.quitAndInstall === 'function') {
|
|
353
353
|
autoUpdater._library.quitAndInstall();
|
|
@@ -372,10 +372,10 @@ const autoUpdater = {
|
|
|
372
372
|
autoUpdater._promptedForVersion = null;
|
|
373
373
|
autoUpdater._activityHooksWired = false;
|
|
374
374
|
|
|
375
|
-
const
|
|
376
|
-
if (
|
|
375
|
+
const omega = autoUpdater._omega;
|
|
376
|
+
if (omega && omega.ipc && typeof omega.ipc.unhandle === 'function') {
|
|
377
377
|
['desktop:auto-updater:status', 'desktop:auto-updater:check-now', 'desktop:auto-updater:install-now'].forEach((c) => {
|
|
378
|
-
|
|
378
|
+
omega.ipc.unhandle(c);
|
|
379
379
|
});
|
|
380
380
|
}
|
|
381
381
|
},
|
|
@@ -385,7 +385,7 @@ const autoUpdater = {
|
|
|
385
385
|
// Auto-updater dev SIMULATION mode — controls whether checkForUpdates() is wired
|
|
386
386
|
// to electron-updater (real) or our synthetic event sequence (fake). Triggered by
|
|
387
387
|
// setting OMEGA_DEV_UPDATE=available|unavailable|error. NOT the same as
|
|
388
|
-
// `
|
|
388
|
+
// `omega.isDevelopment()` (which is the runtime "are we packaged" signal); a
|
|
389
389
|
// packaged production build can absolutely run with OMEGA_DEV_UPDATE set for QA.
|
|
390
390
|
//
|
|
391
391
|
// The runtime simulate() latches `_devSimulationSession` for the rest of the process
|
|
@@ -401,7 +401,7 @@ const autoUpdater = {
|
|
|
401
401
|
},
|
|
402
402
|
|
|
403
403
|
_idleThresholdMs() {
|
|
404
|
-
return autoUpdater.
|
|
404
|
+
return autoUpdater._omega.isTesting() ? IDLE_INSTALL_THRESHOLD_MS_TESTING : IDLE_INSTALL_THRESHOLD_MS;
|
|
405
405
|
},
|
|
406
406
|
|
|
407
407
|
_readyToCheck() {
|
|
@@ -461,7 +461,7 @@ const autoUpdater = {
|
|
|
461
461
|
// user can't dismiss programmatically — exactly what we don't want firing
|
|
462
462
|
// during automated runs. Tests that want to assert prompt behavior should
|
|
463
463
|
// override `_promptToInstall` per-test (see auto-updater.test.js).
|
|
464
|
-
if (autoUpdater.
|
|
464
|
+
if (autoUpdater._omega.isTesting()) {
|
|
465
465
|
logger.log(`Test mode: _promptToInstall(${version}) — skipped native dialog.`);
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
@@ -470,8 +470,8 @@ const autoUpdater = {
|
|
|
470
470
|
if (!dialog) return; // renderer/preload context — no dialog API
|
|
471
471
|
|
|
472
472
|
const focusedWindow = BrowserWindow.getFocusedWindow();
|
|
473
|
-
const productName = autoUpdater.
|
|
474
|
-
|| autoUpdater.
|
|
473
|
+
const productName = autoUpdater._omega.config.app?.productName
|
|
474
|
+
|| autoUpdater._omega.config.brand.name;
|
|
475
475
|
|
|
476
476
|
// showMessageBox CAN reject (e.g. dialog destroyed, no display) — wrap just
|
|
477
477
|
// the call. Synchronous setup above doesn't need a try.
|
|
@@ -521,9 +521,9 @@ const autoUpdater = {
|
|
|
521
521
|
},
|
|
522
522
|
|
|
523
523
|
_broadcastStatus() {
|
|
524
|
-
const
|
|
525
|
-
if (
|
|
526
|
-
|
|
524
|
+
const omega = autoUpdater._omega;
|
|
525
|
+
if (omega && omega.ipc && typeof omega.ipc.broadcast === 'function') {
|
|
526
|
+
omega.ipc.broadcast('desktop:auto-updater:status', autoUpdater.getStatus());
|
|
527
527
|
}
|
|
528
528
|
autoUpdater._updateMenuItem();
|
|
529
529
|
autoUpdater._updateTrayItem();
|
|
@@ -551,36 +551,36 @@ const autoUpdater = {
|
|
|
551
551
|
// Reflect updater state into the @omega.js/desktop Check-for-Updates item. The item lives under
|
|
552
552
|
// `main/check-for-updates` on macOS (App menu) and `help/check-for-updates` on win/linux —
|
|
553
553
|
// we just patch whichever one exists. Consumer can remove either via
|
|
554
|
-
//
|
|
554
|
+
// omega.menu.remove('main/check-for-updates') in their integrations/menu/index.js.
|
|
555
555
|
_updateMenuItem() {
|
|
556
|
-
const
|
|
556
|
+
const omega = autoUpdater._omega;
|
|
557
557
|
const { label, enabled } = autoUpdater._menuItemFieldsForState();
|
|
558
558
|
|
|
559
559
|
// Patch whichever id-path exists. .update() returns false (and warns) if missing,
|
|
560
560
|
// so try both without doubling up on warnings — silence by checking has() first.
|
|
561
|
-
if (
|
|
562
|
-
|
|
563
|
-
} else if (
|
|
564
|
-
|
|
561
|
+
if (omega.menu.has('main/check-for-updates')) {
|
|
562
|
+
omega.menu.update('main/check-for-updates', { label, enabled });
|
|
563
|
+
} else if (omega.menu.has('help/check-for-updates')) {
|
|
564
|
+
omega.menu.update('help/check-for-updates', { label, enabled });
|
|
565
565
|
}
|
|
566
566
|
},
|
|
567
567
|
|
|
568
568
|
// Reflect updater state into the tray's `check-for-updates` item, if present. Same
|
|
569
569
|
// label/enabled semantics as the menu item — keeps both UIs in lockstep.
|
|
570
570
|
_updateTrayItem() {
|
|
571
|
-
const
|
|
571
|
+
const omega = autoUpdater._omega;
|
|
572
572
|
const { label, enabled } = autoUpdater._menuItemFieldsForState();
|
|
573
573
|
|
|
574
|
-
if (
|
|
575
|
-
|
|
574
|
+
if (omega.tray.has('check-for-updates')) {
|
|
575
|
+
omega.tray.update('check-for-updates', { label, enabled });
|
|
576
576
|
}
|
|
577
577
|
},
|
|
578
578
|
|
|
579
579
|
// 30-day gate ────────────────────────────────────────────────────────────────────
|
|
580
580
|
|
|
581
581
|
_reconcilePendingUpdate() {
|
|
582
|
-
const
|
|
583
|
-
const pending =
|
|
582
|
+
const omega = autoUpdater._omega;
|
|
583
|
+
const pending = omega.storage.get(`${STORAGE_KEY}.pendingUpdate`);
|
|
584
584
|
if (!pending || !pending.downloadedAt) return;
|
|
585
585
|
|
|
586
586
|
// A simulated record (written by a build from before the simulator stopped
|
|
@@ -590,14 +590,14 @@ const autoUpdater = {
|
|
|
590
590
|
// force-installs the first REAL download the moment it lands.
|
|
591
591
|
if (pending.version === SIMULATED_VERSION) {
|
|
592
592
|
logger.log(`Discarding simulated pendingUpdate record (v${pending.version}) — the dev simulator never downloaded anything.`);
|
|
593
|
-
|
|
593
|
+
omega.storage.set(`${STORAGE_KEY}.pendingUpdate`, null);
|
|
594
594
|
return;
|
|
595
595
|
}
|
|
596
596
|
|
|
597
|
-
const currentVersion = autoUpdater.
|
|
597
|
+
const currentVersion = autoUpdater._omega.getVersion();
|
|
598
598
|
if (pending.version === currentVersion) {
|
|
599
599
|
logger.log(`Pending update v${pending.version} appears to be applied — clearing flag.`);
|
|
600
|
-
|
|
600
|
+
omega.storage.set(`${STORAGE_KEY}.pendingUpdate`, null);
|
|
601
601
|
return;
|
|
602
602
|
}
|
|
603
603
|
|
|
@@ -622,10 +622,10 @@ const autoUpdater = {
|
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
-
const
|
|
626
|
-
if (!
|
|
625
|
+
const omega = autoUpdater._omega;
|
|
626
|
+
if (!omega || !omega.storage) return;
|
|
627
627
|
|
|
628
|
-
const existing =
|
|
628
|
+
const existing = omega.storage.get(`${STORAGE_KEY}.pendingUpdate`);
|
|
629
629
|
// FIRST download wins for the TIMER — but the stored version must track the
|
|
630
630
|
// NEWEST download, or the clear-on-apply check (version === getVersion())
|
|
631
631
|
// never matches after the install and the stale flag force-installs every
|
|
@@ -633,13 +633,13 @@ const autoUpdater = {
|
|
|
633
633
|
if (existing && existing.downloadedAt) {
|
|
634
634
|
logger.log(`pendingUpdate already recorded (v${existing.version} @ ${new Date(existing.downloadedAt).toISOString()}) — keeping existing timestamp.`);
|
|
635
635
|
if (existing.version !== version) {
|
|
636
|
-
|
|
636
|
+
omega.storage.set(`${STORAGE_KEY}.pendingUpdate`, { version, downloadedAt: existing.downloadedAt });
|
|
637
637
|
}
|
|
638
638
|
autoUpdater._state.downloadedAt = existing.downloadedAt;
|
|
639
639
|
return;
|
|
640
640
|
}
|
|
641
641
|
const now = Date.now();
|
|
642
|
-
|
|
642
|
+
omega.storage.set(`${STORAGE_KEY}.pendingUpdate`, { version, downloadedAt: now });
|
|
643
643
|
autoUpdater._state.downloadedAt = now;
|
|
644
644
|
logger.log(`Recorded pendingUpdate v${version} @ ${new Date(now).toISOString()}`);
|
|
645
645
|
},
|
package/dist/lib/context-menu.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// context-menu event with a builder API plus the event's `params`:
|
|
5
5
|
//
|
|
6
6
|
// // src/integrations/context-menu/index.js
|
|
7
|
-
// module.exports = ({
|
|
7
|
+
// module.exports = ({ omega, menu, params, webContents }) => {
|
|
8
8
|
// // Start from @omega.js/desktop's default template (undo/redo, cut/copy/paste, link items,
|
|
9
9
|
// // reload, dev-only inspect):
|
|
10
10
|
// menu.useDefaults();
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
// Building no items (calling no menu.* methods) suppresses the popup entirely.
|
|
45
45
|
//
|
|
46
46
|
// @omega.js/desktop auto-attaches the handler to every BrowserWindow's webContents that
|
|
47
|
-
// goes through `
|
|
48
|
-
//
|
|
47
|
+
// goes through `omega.windows.createNamed()`. To attach manually:
|
|
48
|
+
// omega.contextMenu.attach(webContents)
|
|
49
49
|
//
|
|
50
|
-
// Disabling at runtime: call `
|
|
50
|
+
// Disabling at runtime: call `omega.contextMenu.disable()`. Idempotent. After
|
|
51
51
|
// disable() the lib stops responding to context-menu events on already-attached
|
|
52
52
|
// webContents — no new menus are shown. No config flag.
|
|
53
53
|
|
|
@@ -61,20 +61,20 @@ const logger = new LoggerLite('context-menu');
|
|
|
61
61
|
|
|
62
62
|
const contextMenu = {
|
|
63
63
|
_initialized: false,
|
|
64
|
-
|
|
64
|
+
_omega: null,
|
|
65
65
|
_electron: null,
|
|
66
66
|
_definitionFn: null,
|
|
67
67
|
_attached: new WeakSet(), // webContents that already have the listener
|
|
68
68
|
|
|
69
|
-
initialize(
|
|
69
|
+
initialize(omega) {
|
|
70
70
|
if (contextMenu._initialized) {
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
contextMenu.
|
|
74
|
+
contextMenu._omega = omega;
|
|
75
75
|
|
|
76
76
|
if (contextMenu._disabled) {
|
|
77
|
-
logger.log('initialize — disabled via
|
|
77
|
+
logger.log('initialize — disabled via omega.contextMenu.disable() called pre-init');
|
|
78
78
|
contextMenu._initialized = true;
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
@@ -89,7 +89,7 @@ const contextMenu = {
|
|
|
89
89
|
|
|
90
90
|
if (fs.existsSync(absPath)) {
|
|
91
91
|
const loadConsumerFile = require('../utils/load-consumer-file.js');
|
|
92
|
-
const loaded = loadConsumerFile(absPath
|
|
92
|
+
const loaded = loadConsumerFile(absPath);
|
|
93
93
|
if (typeof loaded === 'function') {
|
|
94
94
|
contextMenu._definitionFn = loaded;
|
|
95
95
|
} else if (loaded != null) {
|
|
@@ -156,7 +156,7 @@ const contextMenu = {
|
|
|
156
156
|
|
|
157
157
|
const fn = contextMenu._definitionFn || contextMenu._defaultFn;
|
|
158
158
|
try {
|
|
159
|
-
fn({
|
|
159
|
+
fn({ omega: contextMenu._omega, menu: builder, params, webContents });
|
|
160
160
|
} catch (e) {
|
|
161
161
|
logger.error('context-menu definition fn threw:', e);
|
|
162
162
|
return [];
|
|
@@ -170,7 +170,7 @@ const contextMenu = {
|
|
|
170
170
|
// Item set + visibility gates mirror the legacy @omega.js/desktop context-menu behavior:
|
|
171
171
|
// undo/redo gated on canUndo/canRedo, edit ops gated on params.isEditable, etc.
|
|
172
172
|
_populateDefaults(items, params) {
|
|
173
|
-
const
|
|
173
|
+
const omega = contextMenu._omega;
|
|
174
174
|
const flags = params.editFlags || {};
|
|
175
175
|
|
|
176
176
|
// Undo / redo — only when applicable. Hidden when canUndo/canRedo is false (matches legacy).
|
|
@@ -219,7 +219,7 @@ const contextMenu = {
|
|
|
219
219
|
if (items.length > 0) items.push({ type: 'separator' });
|
|
220
220
|
items.push({ id: 'reload', role: 'reload' });
|
|
221
221
|
|
|
222
|
-
if (
|
|
222
|
+
if (omega.isDevelopment()) {
|
|
223
223
|
items.push({ type: 'separator' });
|
|
224
224
|
items.push({ id: 'inspect', role: 'inspectElement' });
|
|
225
225
|
items.push({ id: 'toggle-devtools', role: 'toggleDevTools' });
|
|
@@ -286,7 +286,7 @@ const contextMenu = {
|
|
|
286
286
|
|
|
287
287
|
// Disable the context menu entirely. Idempotent. Safe pre- or post-init.
|
|
288
288
|
// After this, _popup() short-circuits — already-attached webContents stop
|
|
289
|
-
// showing menus on right-click. No way to re-enable; call
|
|
289
|
+
// showing menus on right-click. No way to re-enable; call omega.contextMenu.define()
|
|
290
290
|
// and clear _disabled if you really need to.
|
|
291
291
|
disable() {
|
|
292
292
|
contextMenu._disabled = true;
|
package/dist/lib/context.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// Runtime context — what we know about the user's machine + their network +
|
|
2
2
|
// the current session. Modeled after @omega.js/backend's `assistant.request.{geolocation,client}`
|
|
3
|
-
// shape so @omega.js/desktop apps + sister projects (@omega.js/backend,
|
|
3
|
+
// shape so @omega.js/desktop apps + sister projects (@omega.js/backend, @omega.js/client) all reference the
|
|
4
4
|
// same property paths when reading user info.
|
|
5
5
|
//
|
|
6
|
-
// Populated asynchronously during
|
|
6
|
+
// Populated asynchronously during omega.initialize():
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
8
|
+
// omega.context.geolocation = { ip, country, region, city } // ipify-fetched
|
|
9
|
+
// omega.context.client = { userAgent, locale, platform, arch, mobile }
|
|
10
|
+
// omega.context.session = { id, startTime, deviceId } // desktop-specific
|
|
11
|
+
// omega.context.app = { version, environment, isPackaged }
|
|
12
12
|
//
|
|
13
13
|
// Geolocation is fetched from https://api.ipify.org (IP only) and persisted to
|
|
14
14
|
// storage so a subsequent boot offline still reports the last-known IP. The
|
|
@@ -37,7 +37,7 @@ const IP_FETCH_TIMEOUT_MS = 5000;
|
|
|
37
37
|
|
|
38
38
|
const context = {
|
|
39
39
|
_initialized: false,
|
|
40
|
-
|
|
40
|
+
_omega: null,
|
|
41
41
|
|
|
42
42
|
// Public shape — populated during initialize(). Exported as plain JSON so renderer
|
|
43
43
|
// tests + IPC consumers can read it via structured-clone.
|
|
@@ -46,10 +46,10 @@ const context = {
|
|
|
46
46
|
session: { id: null, startTime: null, deviceId: null },
|
|
47
47
|
app: { version: null, environment: null, isPackaged: null },
|
|
48
48
|
|
|
49
|
-
async initialize(
|
|
49
|
+
async initialize(omega) {
|
|
50
50
|
if (context._initialized) return;
|
|
51
51
|
context._initialized = true;
|
|
52
|
-
context.
|
|
52
|
+
context._omega = omega;
|
|
53
53
|
|
|
54
54
|
// ─── session ──────────────────────────────────────────────────────────────
|
|
55
55
|
context.session.id = crypto.randomUUID();
|
|
@@ -67,14 +67,14 @@ const context = {
|
|
|
67
67
|
context.app.isPackaged = app.isPackaged;
|
|
68
68
|
|
|
69
69
|
// ─── app ──────────────────────────────────────────────────────────────────
|
|
70
|
-
context.app.version =
|
|
71
|
-
context.app.environment =
|
|
70
|
+
context.app.version = omega.getVersion();
|
|
71
|
+
context.app.environment = omega.getEnvironment();
|
|
72
72
|
|
|
73
73
|
// ─── geolocation ──────────────────────────────────────────────────────────
|
|
74
74
|
// Restore last-known from storage immediately so we always have SOMETHING to
|
|
75
75
|
// work with (offline boot, ipify down, slow network, etc.). Then fire the
|
|
76
76
|
// network fetch in the background — when it lands it overwrites + persists.
|
|
77
|
-
const cached =
|
|
77
|
+
const cached = omega.storage.get(STORAGE_KEY) || null;
|
|
78
78
|
if (cached?.geolocation) {
|
|
79
79
|
Object.assign(context.geolocation, cached.geolocation);
|
|
80
80
|
}
|
|
@@ -82,8 +82,8 @@ const context = {
|
|
|
82
82
|
context._fetchGeolocation().catch((e) => logger.warn(`geolocation fetch failed: ${e.message}`));
|
|
83
83
|
|
|
84
84
|
// IPC: renderer can read the full context block.
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
omega.ipc.unhandle('desktop:context:get');
|
|
86
|
+
omega.ipc.handle('desktop:context:get', () => context.toJSON());
|
|
87
87
|
|
|
88
88
|
logger.log(`context initialized — session=${context.session.id} deviceId=${context.session.deviceId} platform=${context.client.platform}`);
|
|
89
89
|
},
|
|
@@ -97,11 +97,11 @@ const context = {
|
|
|
97
97
|
// id it had before its storage was wiped.
|
|
98
98
|
// 3. A generated UUID (the shared derivation's floor), persisted for next boot.
|
|
99
99
|
async _resolveDeviceId() {
|
|
100
|
-
const
|
|
100
|
+
const omega = context._omega;
|
|
101
101
|
|
|
102
102
|
return core.deriveDeviceId({
|
|
103
|
-
get: () =>
|
|
104
|
-
set: (id) =>
|
|
103
|
+
get: () => omega.storage.get(`${STORAGE_KEY}.deviceId`),
|
|
104
|
+
set: (id) => omega.storage.set(`${STORAGE_KEY}.deviceId`, id),
|
|
105
105
|
seed: () => context._readFirstMac(),
|
|
106
106
|
});
|
|
107
107
|
},
|
|
@@ -138,14 +138,14 @@ const context = {
|
|
|
138
138
|
|
|
139
139
|
context.geolocation.ip = ip;
|
|
140
140
|
// Persist for next launch so an offline boot still has a usable IP.
|
|
141
|
-
context.
|
|
141
|
+
context._omega.storage.set(`${STORAGE_KEY}.geolocation`, { ...context.geolocation });
|
|
142
142
|
},
|
|
143
143
|
|
|
144
144
|
// Test/teardown helper. Re-initialize is idempotent guarded; call this first
|
|
145
145
|
// if a test wants to re-run with mutated state.
|
|
146
146
|
shutdown() {
|
|
147
147
|
context._initialized = false;
|
|
148
|
-
context.
|
|
148
|
+
context._omega = null;
|
|
149
149
|
},
|
|
150
150
|
|
|
151
151
|
// Plain-JSON snapshot — what gets sent over IPC to the renderer.
|
package/dist/lib/deep-link.js
CHANGED
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
// warm-start via `app.on('second-instance')` (read from the `additionalData` argument,
|
|
8
8
|
// which carries the duplicate's real argv; the event's own `argv` is Chromium-processed).
|
|
9
9
|
//
|
|
10
|
-
// Public API on
|
|
10
|
+
// Public API on omega.deepLink:
|
|
11
11
|
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
12
|
+
// omega.deepLink.on(routeOrPattern, fn) // register a handler. Returns unsubscribe fn.
|
|
13
|
+
// omega.deepLink.off(routeOrPattern, fn)
|
|
14
|
+
// omega.deepLink.dispatch(url) // manually fire (for testing or custom triggers)
|
|
15
|
+
// omega.deepLink.getColdStartUrl() // the deep-link URL the app was launched with, or null
|
|
16
16
|
//
|
|
17
17
|
// Handler signature:
|
|
18
18
|
//
|
|
19
|
-
//
|
|
19
|
+
// omega.deepLink.on('user/profile/:id', (ctx) => {
|
|
20
20
|
// ctx.url // 'myapp://user/profile/42?ref=abc'
|
|
21
21
|
// ctx.scheme // 'myapp'
|
|
22
22
|
// ctx.route // 'user/profile/42'
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
// the fall-through to wildcard handlers (concrete-pattern handlers always run).
|
|
39
39
|
//
|
|
40
40
|
// Built-in routes (registered by @omega.js/desktop, can be overridden by registering your own handler):
|
|
41
|
-
// auth/token →
|
|
42
|
-
// app/show →
|
|
41
|
+
// auth/token → omega.auth.handleToken(query.authToken)
|
|
42
|
+
// app/show → omega.windows.show(query.window || 'main')
|
|
43
43
|
// app/quit → app.quit()
|
|
44
44
|
//
|
|
45
45
|
// Built-in handlers run AFTER consumer handlers, so a consumer can shadow any built-in
|
|
@@ -51,21 +51,21 @@ const logger = new LoggerLite('deep-link');
|
|
|
51
51
|
|
|
52
52
|
const deepLink = {
|
|
53
53
|
_initialized: false,
|
|
54
|
-
|
|
54
|
+
_omega: null,
|
|
55
55
|
_electron: null,
|
|
56
56
|
_handlers: [], // [{ pattern, fn, builtin: bool }]
|
|
57
57
|
_coldStartUrl: null, // the URL the app was launched with (if any)
|
|
58
58
|
_wired: false, // open-url + second-instance + queueing wired?
|
|
59
59
|
_pendingUrls: [], // urls received before whenReady — drained on init
|
|
60
|
-
|
|
61
|
-
_bootQueue: [], // dispatches held until
|
|
60
|
+
_omegaReady: false, // omega.initialize() finished — safe to dispatch
|
|
61
|
+
_bootQueue: [], // dispatches held until _omegaReady (auth et al. are up)
|
|
62
62
|
|
|
63
|
-
initialize(
|
|
63
|
+
initialize(omega) {
|
|
64
64
|
if (deepLink._initialized) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
deepLink.
|
|
68
|
+
deepLink._omega = omega;
|
|
69
69
|
deepLink._electron = require('electron');
|
|
70
70
|
|
|
71
71
|
deepLink._wireElectronEvents();
|
|
@@ -76,9 +76,9 @@ const deepLink = {
|
|
|
76
76
|
const coldUrl = deepLink._extractUrlFromArgv(process.argv);
|
|
77
77
|
if (coldUrl) {
|
|
78
78
|
deepLink._coldStartUrl = coldUrl;
|
|
79
|
-
|
|
80
|
-
// _handle queues until
|
|
81
|
-
// not dispatch before
|
|
79
|
+
omega.appState.setLaunchedFromDeepLink(true);
|
|
80
|
+
// _handle queues until markOmegaReady() — a cold-start auth/token must
|
|
81
|
+
// not dispatch before auth has booted Firebase.
|
|
82
82
|
deepLink._handle(coldUrl, 'cold-start', { argv: process.argv, cwd: process.cwd() });
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -88,7 +88,7 @@ const deepLink = {
|
|
|
88
88
|
deepLink._pendingUrls = [];
|
|
89
89
|
if (!deepLink._coldStartUrl) {
|
|
90
90
|
deepLink._coldStartUrl = urls[0];
|
|
91
|
-
|
|
91
|
+
omega.appState.setLaunchedFromDeepLink(true);
|
|
92
92
|
}
|
|
93
93
|
urls.forEach((u) => deepLink._handle(u, 'cold-start', { argv: process.argv, cwd: process.cwd() }));
|
|
94
94
|
}
|
|
@@ -130,11 +130,11 @@ const deepLink = {
|
|
|
130
130
|
// Surface the main window. With hidden-mode apps, the consumer typically created
|
|
131
131
|
// `main` with `show: false` at boot, so it's in the registry but invisible — we
|
|
132
132
|
// just need to show it now that the user explicitly asked.
|
|
133
|
-
const main = deepLink.
|
|
133
|
+
const main = deepLink._omega.windows.get('main');
|
|
134
134
|
if (main) {
|
|
135
135
|
logger.log(`second-instance — surfacing main (visible=${main.isVisible()}, minimized=${main.isMinimized()})`);
|
|
136
136
|
if (main.isMinimized()) main.restore();
|
|
137
|
-
deepLink.
|
|
137
|
+
deepLink._omega.windows._ensureDockVisible();
|
|
138
138
|
main.show();
|
|
139
139
|
main.focus();
|
|
140
140
|
} else {
|
|
@@ -149,10 +149,10 @@ const deepLink = {
|
|
|
149
149
|
},
|
|
150
150
|
|
|
151
151
|
_registerBuiltins() {
|
|
152
|
-
// auth/token
|
|
153
|
-
//
|
|
154
|
-
// here with ?authToken=<custom-token>. MODERN shape only —
|
|
155
|
-
// (?payload=, ?token=) are
|
|
152
|
+
// auth/token: hand off to lib/auth.js. The receiving end of
|
|
153
|
+
// omega.getAuthUrl()'s sign-in round-trip: the website's token page redirects
|
|
154
|
+
// here with ?authToken=<custom-token>. MODERN shape only — older formats
|
|
155
|
+
// (?payload=, ?token=) are not read.
|
|
156
156
|
deepLink._handlers.push({
|
|
157
157
|
pattern: 'auth/token',
|
|
158
158
|
builtin: true,
|
|
@@ -162,7 +162,7 @@ const deepLink = {
|
|
|
162
162
|
logger.warn('auth/token: no authToken in query string.');
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
|
-
deepLink.
|
|
165
|
+
deepLink._omega.auth.handleToken(token);
|
|
166
166
|
},
|
|
167
167
|
});
|
|
168
168
|
|
|
@@ -172,7 +172,7 @@ const deepLink = {
|
|
|
172
172
|
builtin: true,
|
|
173
173
|
fn: (ctx) => {
|
|
174
174
|
const name = ctx.query?.window || 'main';
|
|
175
|
-
deepLink.
|
|
175
|
+
deepLink._omega.windows.show(name);
|
|
176
176
|
},
|
|
177
177
|
});
|
|
178
178
|
|
|
@@ -189,7 +189,7 @@ const deepLink = {
|
|
|
189
189
|
// Pull a `<scheme>://...` URL out of an argv array. Returns null if none of our schemes match.
|
|
190
190
|
_extractUrlFromArgv(argv) {
|
|
191
191
|
if (!Array.isArray(argv)) return null;
|
|
192
|
-
const schemes = deepLink.
|
|
192
|
+
const schemes = deepLink._omega.protocol.getSchemes();
|
|
193
193
|
if (schemes.length === 0) return null;
|
|
194
194
|
|
|
195
195
|
// Walk argv backward — the URL is typically the last meaningful arg.
|
|
@@ -246,13 +246,13 @@ const deepLink = {
|
|
|
246
246
|
return params;
|
|
247
247
|
},
|
|
248
248
|
|
|
249
|
-
// Called by main.js once
|
|
250
|
-
// touches (
|
|
249
|
+
// Called by main.js once omega.initialize() completes — every LIB a handler
|
|
250
|
+
// touches (auth's Firebase, the windows registry, tray) is up from here
|
|
251
251
|
// on. (Consumer-created windows may still be pending — consumers create them
|
|
252
252
|
// in initialize().then(); app/show on a not-yet-created window warns + drops,
|
|
253
253
|
// same as always.) Any dispatch that arrived earlier drains now.
|
|
254
|
-
|
|
255
|
-
deepLink.
|
|
254
|
+
markOmegaReady() {
|
|
255
|
+
deepLink._omegaReady = true;
|
|
256
256
|
const queued = deepLink._bootQueue.slice();
|
|
257
257
|
deepLink._bootQueue = [];
|
|
258
258
|
queued.forEach(({ url, source, env }) => deepLink._handle(url, source, env));
|
|
@@ -260,10 +260,10 @@ const deepLink = {
|
|
|
260
260
|
|
|
261
261
|
// Run the dispatch pipeline for a single URL.
|
|
262
262
|
_handle(url, source, env) {
|
|
263
|
-
// Hold every dispatch until
|
|
264
|
-
// deref
|
|
265
|
-
if (!deepLink.
|
|
266
|
-
logger.log(`queueing ${source} dispatch until
|
|
263
|
+
// Hold every dispatch until omega is fully initialized: handlers
|
|
264
|
+
// deref omega surfaces that do not exist yet during boot.
|
|
265
|
+
if (!deepLink._omegaReady) {
|
|
266
|
+
logger.log(`queueing ${source} dispatch until omega ready — ${url}`);
|
|
267
267
|
deepLink._bootQueue.push({ url, source, env });
|
|
268
268
|
return;
|
|
269
269
|
}
|