Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
ef7459d
WIP: Decouple Electron from `electron-client` entrypoint
somebody1234 Oct 20, 2025
8d362a1
Decouple Electron from `electron-client` entrypoint
somebody1234 Oct 21, 2025
3be6b66
Move `LocalBackend` and `RemoteBackend` to `common`
somebody1234 Oct 22, 2025
3cebacc
WIP: Headless hybrid execution
somebody1234 Oct 23, 2025
da0b2ac
WIP: Headless hybrid execution
somebody1234 Oct 24, 2025
5a67113
Fix type errors in `hybrid.ts`
somebody1234 Oct 27, 2025
e4f7e2a
Replace `App` class with free-standing functions
somebody1234 Oct 27, 2025
a6402b9
Remove global `electron` variable
somebody1234 Oct 27, 2025
46a246b
Move Electron-only functions to `electron` module
somebody1234 Oct 27, 2025
db294e8
Replace `*` imports with named imports
somebody1234 Oct 27, 2025
ec40192
More refactors
somebody1234 Oct 27, 2025
8afeafa
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Oct 27, 2025
79a0ba3
Fixes
somebody1234 Oct 27, 2025
23c401a
Fix imports to `result` and `opt`
somebody1234 Oct 27, 2025
8378775
Fix constructing `RemoteBackend`
somebody1234 Oct 27, 2025
4e691e6
Update Nix flake
somebody1234 Oct 27, 2025
5a70186
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Oct 28, 2025
c6b394b
Fix errors
somebody1234 Oct 28, 2025
9210c7e
Prettier
somebody1234 Oct 28, 2025
b3f51f1
Fix import errors
somebody1234 Oct 28, 2025
84b1055
Fix type error
somebody1234 Oct 28, 2025
bcf55e2
Fix lint error
somebody1234 Oct 28, 2025
846efb0
Set up infrastructure for running headless projects
somebody1234 Oct 29, 2025
c7ecc44
WIP: Add support for headless execution
somebody1234 Oct 29, 2025
a0f0111
Revert changes to `electron-client`
somebody1234 Oct 29, 2025
8e579c5
Address CR
somebody1234 Oct 29, 2025
413d4af
Fix unit tests
somebody1234 Oct 29, 2025
26fd722
Fix more unit tests
somebody1234 Oct 29, 2025
3ffaa46
Remove incorrect dependency on `ProjectManager` (would require HTTP s…
somebody1234 Oct 31, 2025
051d545
Move `download.ts` in `common`
somebody1234 Oct 31, 2025
bf8ed25
Remove `.js` extension from files in `common`
somebody1234 Oct 31, 2025
50a2992
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Oct 31, 2025
0565558
Address CR
somebody1234 Oct 29, 2025
27f6e3f
Move `download.ts` in `common`
somebody1234 Oct 31, 2025
42f4205
Remove `.js` extension from files in `common`
somebody1234 Oct 31, 2025
5d6d230
Fix error finding `enso` executable
somebody1234 Oct 31, 2025
9445f74
Fix error in `HttpClient`
somebody1234 Oct 31, 2025
6c000de
Avoid accessing `document` on `Node.js`
somebody1234 Oct 31, 2025
83368d2
Minor style refactor
somebody1234 Oct 31, 2025
da5332a
Remove unused code
somebody1234 Nov 3, 2025
c71d789
WIP: Ability for `electron-client` to refresh token
somebody1234 Nov 3, 2025
74594fd
Merge branch 'develop' into wip/sb/enso-headless-2
somebody1234 Nov 5, 2025
b219cec
Install vite
somebody1234 Nov 5, 2025
9a1fcc2
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Nov 6, 2025
6ee3d28
Merge branch 'wip/sb/enso-headless' into wip/sb/enso-headless-2
somebody1234 Nov 6, 2025
58c46e9
Fix import errors
somebody1234 Nov 6, 2025
5e5a363
Fix import errors
somebody1234 Nov 6, 2025
7015499
Fix import errors
somebody1234 Nov 6, 2025
e081372
I guess we do need `.js` suffix now...
somebody1234 Nov 6, 2025
0bfddcb
Merge branch 'wip/sb/enso-headless' into wip/sb/enso-headless-2
somebody1234 Nov 6, 2025
ddc0da0
Fix type errors
somebody1234 Nov 6, 2025
0c7f221
Merge branch 'wip/sb/enso-headless' into wip/sb/enso-headless-2
somebody1234 Nov 6, 2025
2cf4ad4
Merge branch 'develop' into wip/sb/enso-headless
somebody1234 Nov 7, 2025
04b67ec
Merge branch 'wip/sb/enso-headless' into wip/sb/enso-headless-2
somebody1234 Nov 7, 2025
f9ce935
Move `.dev-env` submodule
somebody1234 Nov 7, 2025
0074eb4
Initial `vite` setup for `common` module
somebody1234 Nov 7, 2025
9fcc3ab
Update `enso-common` imports to `enso-common/src/constants`
somebody1234 Nov 7, 2025
d4cb53c
Fix build errors
somebody1234 Nov 7, 2025
a39ac18
Fix config parsing error
somebody1234 Nov 7, 2025
837c54c
Fix runtime error
somebody1234 Nov 7, 2025
2e4205a
Merge branch 'develop' into wip/sb/enso-headless-2
somebody1234 Nov 7, 2025
1a13b3c
WIP: Fix token refresh
somebody1234 Nov 10, 2025
4d30051
Fix loading `.env` in `gui`
somebody1234 Nov 10, 2025
c2e271b
Fix loading project in headless mode
somebody1234 Nov 10, 2025
82ac195
Fix path to enso executable in dev mode
somebody1234 Nov 10, 2025
e59594b
First working headless execution
somebody1234 Nov 10, 2025
6f81959
Set cloud variables for headless execution
somebody1234 Nov 13, 2025
648a0ef
Add asset contents sidebar panel
somebody1234 Nov 13, 2025
90c714c
Fix issue closing project
somebody1234 Nov 13, 2025
0d75fbf
WIP: Add tests
somebody1234 Nov 24, 2025
d2bd3d0
Fix crash
somebody1234 Nov 25, 2025
cdec88e
Fix arg parsing
somebody1234 Nov 26, 2025
37aad0f
Skip integration test
somebody1234 Nov 26, 2025
8997375
Convert `App` back to a class
somebody1234 Nov 26, 2025
b125eac
Remove obsolete TODO
somebody1234 Nov 26, 2025
3cb824a
Add `useUpload` and move to `composables`
somebody1234 Nov 26, 2025
d6f4f70
Re-inline `await`ed Vite plugins
somebody1234 Nov 26, 2025
62e65e5
Implement and use `runProcess` in `ensoRunner`
somebody1234 Nov 26, 2025
3a29227
Avoid creating `projectService` in `runHybridProjectByUrl`
somebody1234 Nov 26, 2025
0ec0f3c
Fix `cwd` for `runProject`
somebody1234 Nov 26, 2025
da1898a
Merge branch 'develop' into wip/sb/enso-headless-2
somebody1234 Nov 26, 2025
addad10
Fix type error
somebody1234 Nov 26, 2025
492cc29
Fix mode not working
somebody1234 Nov 27, 2025
24ba3e2
Fix Bazel errors
somebody1234 Nov 27, 2025
8426dd2
Fix error message when running headless mode without logging in
somebody1234 Nov 27, 2025
b5e50aa
Refactor Enso exectuable detection code
somebody1234 Nov 27, 2025
20dd0b5
Fix Enso executable path detection
somebody1234 Nov 28, 2025
349349c
fix find executables path on MacOs
PabloBuchu Nov 28, 2025
35a2232
Fix watch mode; improve asset preview
somebody1234 Dec 2, 2025
dbcfb91
Disable previewing of media files
somebody1234 Dec 2, 2025
9561547
Only preview media files when explicitly loaded
somebody1234 Dec 2, 2025
bac86e0
Fix bazel build
somebody1234 Dec 2, 2025
de7f22e
Fix type error
somebody1234 Dec 2, 2025
39e585e
Fix integration tests
somebody1234 Dec 3, 2025
22024c3
Address CR
somebody1234 Dec 3, 2025
a4a9fcd
Address Bazel comments
somebody1234 Dec 3, 2025
507d803
Address CR
somebody1234 Dec 3, 2025
b3224f1
Continue addressing CR
somebody1234 Dec 3, 2025
68b8c62
Fix tests
somebody1234 Dec 3, 2025
bccb0e0
Attempt to fix Bazel building
somebody1234 Dec 3, 2025
7e6dcdc
Scuff...
somebody1234 Dec 3, 2025
b2fed0a
Bazel is hard
somebody1234 Dec 3, 2025
b5d81ff
Prettier
somebody1234 Dec 3, 2025
5077613
Fix Bazel files
somebody1234 Dec 3, 2025
738c2c2
Fix type errors
somebody1234 Dec 3, 2025
10d67f0
Prettier
somebody1234 Dec 4, 2025
d7b70d3
Fix CI errors?
somebody1234 Dec 4, 2025
ae6d477
Merge branch 'develop' into wip/sb/enso-headless-2
somebody1234 Dec 4, 2025
ddd57db
Fix errors
somebody1234 Dec 4, 2025
5367111
Merge branch 'develop' into wip/sb/enso-headless-2
somebody1234 Dec 5, 2025
bdb421e
Fix package tests
somebody1234 Dec 5, 2025
64e4748
Fix Bazel build
somebody1234 Dec 5, 2025
82e7175
Fix Bazel build?
somebody1234 Dec 5, 2025
d30f0c1
Testing on CI...
somebody1234 Dec 5, 2025
539e5b7
Testing on CI... part 2
somebody1234 Dec 5, 2025
477ca6a
Testing on CI... part 3
somebody1234 Dec 5, 2025
ffa9499
Testing on CI... part 4
somebody1234 Dec 5, 2025
a3ea03d
Testing on CI... part 4b
somebody1234 Dec 5, 2025
8ebff68
This is not working
somebody1234 Dec 5, 2025
2434071
Check specific test
somebody1234 Dec 8, 2025
a20cbed
Fix workflow error
somebody1234 Dec 8, 2025
5a1eaaa
Debugging
somebody1234 Dec 8, 2025
346e916
Log mode
somebody1234 Dec 8, 2025
57665e3
Attempt to fix CI
somebody1234 Dec 8, 2025
17bed65
Attempt to fix CI (again)
somebody1234 Dec 8, 2025
dd4ef05
Revert incorrect fix
somebody1234 Dec 8, 2025
34e0f8d
Fix errors when env files are missing; change headless logs to inheri…
somebody1234 Dec 10, 2025
d8d42d8
Testing
somebody1234 Dec 10, 2025
e3e817c
Workaround to make tests happy
somebody1234 Dec 10, 2025
eb6e563
Fix CI
somebody1234 Dec 10, 2025
b89ba40
Attempt more proper fix for failing unit test
somebody1234 Dec 10, 2025
4d55f0c
Add changelog entry
somebody1234 Dec 10, 2025
788ed42
More debug logging
somebody1234 Dec 10, 2025
9f7c32c
Merge branch 'develop' into wip/sb/enso-headless-2
somebody1234 Dec 10, 2025
4e1b92e
Remove debug logs; adjust env file to work on tests
somebody1234 Dec 10, 2025
46ab7d1
fix terms modal
PabloBuchu Dec 12, 2025
bee52ea
Fix environment variables
somebody1234 Dec 12, 2025
2289e9e
Fix environment variables
somebody1234 Dec 15, 2025
5846a91
Fix E2E tests...
somebody1234 Dec 15, 2025
cf8fc90
Merge branch 'develop' into wip/sb/enso-headless-2
somebody1234 Dec 15, 2025
ed80e7b
Fix build error
somebody1234 Dec 15, 2025
cd1821d
Merge branch 'develop' into wip/sb/enso-headless-2
somebody1234 Dec 15, 2025
16bbc6b
:(
somebody1234 Dec 15, 2025
8ab3f7c
Fix CI
somebody1234 Dec 15, 2025
cb767e8
Remove debug log
somebody1234 Dec 15, 2025
2a6e21b
Fix Windows CI
somebody1234 Dec 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
strict_env

if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4="
if ! has nix_direnv_version || ! nix_direnv_version 3.1.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.0/direnvrc" "sha256-yMJ2OVMzrFaDPn7q8nCBZFRYpL/f0RcHzhmw/i6btJM="
fi

use flake
2 changes: 1 addition & 1 deletion .github/workflows/bazel-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: bazel run //:lint_bazel_files
- name: Expose env variables
run: |
cat << END > app/gui/.env.production
cat << END > app/common/.env.production
ENSO_IDE_ENVIRONMENT="${{ vars.ENSO_CLOUD_ENVIRONMENT }}"
ENSO_IDE_API_URL="${{ vars.ENSO_CLOUD_API_URL }}"
ENSO_IDE_CHAT_URL="${{ vars.ENSO_CLOUD_CHAT_URL }}"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ide-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ jobs:
rm dist/backend/project-manager.tar
- run: ./run ide build --backend-source local --gui-upload-artifact false
env:
ENSO_IDE_HOST: ${{ vars.ENSO_HOST }}
ENSO_IDE_AG_GRID_LICENSE_KEY: ${{ vars.ENSO_AG_GRID_LICENSE_KEY }}
ENSO_IDE_API_URL: ${{ vars.ENSO_CLOUD_API_URL }}
ENSO_IDE_AUTH_ENDPOINT: ${{ vars.ENSO_CLOUD_AUTH_ENDPOINT }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: ./run ide upload --backend-source release --backend-release ${{env.ENSO_RELEASE_ID}} --sign-artifacts
env:
ENSO_IDE_HOST: ${{ vars.ENSO_HOST }}
ENSO_IDE_AG_GRID_LICENSE_KEY: ${{ vars.ENSO_AG_GRID_LICENSE_KEY }}
ENSO_IDE_API_URL: ${{ vars.ENSO_CLOUD_API_URL }}
ENSO_IDE_AUTH_ENDPOINT: ${{ vars.ENSO_CLOUD_AUTH_ENDPOINT }}
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "app/gui/.dev-env"]
path = app/gui/.dev-env
[submodule "app/common/.dev-env"]
path = app/common/.dev-env
url = ../dev-env.git
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ write_source_files(
buildifier(
name = "lint_bazel_files",
exclude_patterns = [
"./app/gui/.env.bazel",
"./app/common/.env.bazel",
],
lint_mode = "warn",
mode = "diff",
Expand All @@ -51,7 +51,7 @@ buildifier(
buildifier(
name = "format_bazel_files",
exclude_patterns = [
"./app/gui/.env.bazel",
"./app/common/.env.bazel",
],
lint_mode = "fix",
mode = "fix",
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
top.
- [Context menu for connections][14325].
- [Warnings and Errors no longer become transparent][14388]
- [`--headless` flag to run a project without the User Interface][14310]
- [Preview for assets (text, main files of Projects, audio, video, images) in
Right Sidebar][14310]
- ["Delete and Connect Around" option in node's menu][14403]
- [GeoMap visualization is now working without need of Mapbox Token in
environment][14429]
Expand All @@ -63,6 +66,7 @@
[14209]: https://github.com/enso-org/enso/pull/14209
[14215]: https://github.com/enso-org/enso/pull/14215
[14270]: https://github.com/enso-org/enso/pull/14270
[14310]: https://github.com/enso-org/enso/pull/14310
[14311]: https://github.com/enso-org/enso/pull/14311
[14267]: https://github.com/enso-org/enso/pull/14267
[14325]: https://github.com/enso-org/enso/pull/14325
Expand Down
2 changes: 1 addition & 1 deletion app/gui/.env.bazel → app/common/.env.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Bazel build step defaults to having all envs left as placeholders, so that they can be replaced later after the vite build step.
# Bazel build step defaults to having all envs left as placeholders, so that they can be replaced late after the vite build step.
ENSO_IDE_AG_GRID_LICENSE_KEY = "((%__ENSO_IDE_AG_GRID_LICENSE_KEY__%))"
ENSO_IDE_API_URL = "((%__ENSO_IDE_API_URL__%))"
ENSO_IDE_CLOUD_BUILD = "((%__ENSO_IDE_CLOUD_BUILD__%))"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions app/common/.env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ENSO_IDE_API_URL=https://mock
ENSO_IDE_HOST=https://ensoanalytics.com
ENSO_IDE_COGNITO_USER_POOL_ID=mars_AAAAAAAAA
ENSO_IDE_COGNITO_USER_POOL_WEB_CLIENT_ID=zzzzzzzzzzzzzzzzzzzzzzzzzz
ENSO_IDE_COMMIT_HASH=abcdef0
ENSO_IDE_CLOUD_BUILD=false
ENSO_IDE_VERSION=0.0.1-testing
7 changes: 7 additions & 0 deletions app/common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@npm//:defs.bzl", "npm_link_all_packages", "npm_link_targets")
Expand Down Expand Up @@ -36,3 +37,9 @@ npm_package(
],
visibility = ["//visibility:public"],
)

copy_to_bin(
name = "env_files",
srcs = glob([".env*"]),
visibility = ["//visibility:public"],
)
5 changes: 4 additions & 1 deletion app/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,21 @@
"main": "src/index.ts",
"scripts": {
"test:unit": "vitest run",
"compile": "tsc",
"typecheck": "tsc --noEmit",
"compile": "vite build",
"lint": "eslint ./src --cache --max-warnings=0"
},
"dependencies": {
"@internationalized/date": "3.7.0",
"@types/node": "catalog:",
"is-network-error": "^1.1.0",
"vite": "catalog:",
"vue": "catalog:",
"zod": "catalog:"
},
"devDependencies": {
"@fast-check/vitest": "catalog:",
"vite-plugin-dts": "^4.5.4",
"vitest": "catalog:"
}
}
8 changes: 8 additions & 0 deletions app/common/src/accessToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ export interface AccessToken {
*/
readonly expireAt: string
}

export interface RawAccessToken {
readonly access_token: string
readonly client_id: string
readonly refresh_token: string
readonly refresh_url: string
readonly expire_at: string
}
97 changes: 97 additions & 0 deletions app/common/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* @file This file defines a global environment config that can be used throughout the app.
* It is included directly into index.html and kept as a separate built artifact, so that
* we can easily replace its contents in a separate build postprocessing step in `BUILD.bazel`.
*/

import { unsafeKeys } from './utilities/data/object.js'

declare global {
interface ViteTypeOptions {
// strictImportMetaEnv: unknown
}

// This needs to be ts-ignore, because not all packages have this key defined.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore This key is also defined in Vite.
type ImportMetaEnvFallbackKey =
'strictImportMetaEnv' extends keyof ViteTypeOptions ? never : string

interface ImportMetaEnv {
[key: ImportMetaEnvFallbackKey]: any
BASE_URL: string
MODE: string
DEV: boolean
PROD: boolean
SSR: boolean
}

interface ImportMeta {
url: string
readonly env: ImportMetaEnv
}
}

const processEnv = typeof process !== 'undefined' ? process.env : {}

/** When running dev server, the config variables are grabbed from appropriate .env file. */
export const $config = {
ENVIRONMENT: processEnv.ENSO_IDE_ENVIRONMENT ?? import.meta.env?.ENSO_IDE_ENVIRONMENT,
ENSO_HOST:
processEnv.ENSO_IDE_HOST ?? (import.meta.env?.ENSO_IDE_HOST || 'https://ensoanalytics.com'),
API_URL: processEnv.ENSO_IDE_API_URL ?? import.meta.env?.ENSO_IDE_API_URL,
SENTRY_DSN: processEnv.ENSO_IDE_SENTRY_DSN ?? import.meta.env?.ENSO_IDE_SENTRY_DSN,
STRIPE_KEY: processEnv.ENSO_IDE_STRIPE_KEY ?? import.meta.env?.ENSO_IDE_STRIPE_KEY,
AUTH_ENDPOINT: processEnv.ENSO_IDE_AUTH_ENDPOINT ?? import.meta.env?.ENSO_IDE_AUTH_ENDPOINT,
COGNITO_USER_POOL_ID:
processEnv.ENSO_IDE_COGNITO_USER_POOL_ID ?? import.meta.env?.ENSO_IDE_COGNITO_USER_POOL_ID,
COGNITO_USER_POOL_WEB_CLIENT_ID:
processEnv.ENSO_IDE_COGNITO_USER_POOL_WEB_CLIENT_ID ??
import.meta.env?.ENSO_IDE_COGNITO_USER_POOL_WEB_CLIENT_ID,
GOOGLE_ANALYTICS_TAG:
processEnv.ENSO_IDE_GOOGLE_ANALYTICS_TAG ?? import.meta.env?.ENSO_IDE_GOOGLE_ANALYTICS_TAG,
COGNITO_DOMAIN: processEnv.ENSO_IDE_COGNITO_DOMAIN ?? import.meta.env?.ENSO_IDE_COGNITO_DOMAIN,
COGNITO_REGION: processEnv.ENSO_IDE_COGNITO_REGION ?? import.meta.env?.ENSO_IDE_COGNITO_REGION,
VERSION: processEnv.ENSO_IDE_VERSION ?? import.meta.env?.ENSO_IDE_VERSION,
COMMIT_HASH: processEnv.ENSO_IDE_COMMIT_HASH ?? import.meta.env?.ENSO_IDE_COMMIT_HASH,
YDOC_SERVER_URL: processEnv.ENSO_IDE_YDOC_SERVER_URL ?? import.meta.env?.ENSO_IDE_YDOC_SERVER_URL,
CLOUD_BUILD: processEnv.ENSO_IDE_CLOUD_BUILD ?? import.meta.env?.ENSO_IDE_CLOUD_BUILD,
AG_GRID_LICENSE_KEY:
processEnv.ENSO_IDE_AG_GRID_LICENSE_KEY ?? import.meta.env?.ENSO_IDE_AG_GRID_LICENSE_KEY,
GOOGLE_OAUTH_CLIENT_ID:
processEnv.ENSO_IDE_GOOGLE_OAUTH_CLIENT_ID ?? import.meta.env?.ENSO_IDE_GOOGLE_OAUTH_CLIENT_ID,
STRAVA_OAUTH_CLIENT_ID:
processEnv.ENSO_IDE_STRAVA_OAUTH_CLIENT_ID ?? import.meta.env?.ENSO_IDE_STRAVA_OAUTH_CLIENT_ID,
MS365_OAUTH_CLIENT_ID:
processEnv.ENSO_IDE_MS365_OAUTH_CLIENT_ID ?? import.meta.env?.ENSO_IDE_MS365_OAUTH_CLIENT_ID,
MAPBOX_API_TOKEN:
(typeof window === 'object' &&
window &&
'api' in window &&
typeof window.api === 'object' &&
window.api &&
'mapBoxApiToken' in window.api &&
typeof window.api.mapBoxApiToken === 'function' &&
window.api?.mapBoxApiToken()) ||
(processEnv.ENSO_IDE_MAPBOX_API_TOKEN ?? import.meta.env?.ENSO_IDE_MAPBOX_API_TOKEN),
}

/** Sets the global configuration. */
export function setConfig(config: typeof $config) {
for (const k of unsafeKeys(config)) {
if (config[k] === undefined) {
continue
}
// Special-case as ENSO_HOST may currently be an empty string when it is unset in CI.
if (k === 'ENSO_HOST' && config[k] === '') {
continue
}
$config[k] = config[k]
}
}

// Undefined env variables are typed as `any`, but we want them to be `string | undefined`.
export type $Config = {
[K in keyof typeof $config]: unknown extends (typeof $config)[K] ? string | undefined
: (typeof $config)[K]
}
File renamed without changes.
1 change: 1 addition & 0 deletions app/common/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const DEFAULT_PORT = 8080
/** Schema for app-wide configuration options. */
export const OptionsSchema = z.object({
version: z.boolean().default(false),
headless: z.boolean().default(false),
displayWindow: z.boolean().default(true),
useServer: z.boolean().default(true),
engineEnabled: z.boolean().default(true),
Expand Down
21 changes: 11 additions & 10 deletions app/common/src/services/Backend.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/** @file Type definitions common between all backends. */
import { z } from 'zod'
import type { DownloadOptions } from '../download.js'
import { getText, resolveDictionary, type Replacements, type TextId } from '../text.js'
import {
getText,
resolveDictionary,
type DefaultGetText,
type Replacements,
type TextId,
} from '../text.js'
import * as dateTime from '../utilities/data/dateTime.js'
import * as newtype from '../utilities/data/newtype.js'
import * as permissions from '../utilities/permissions.js'
Expand Down Expand Up @@ -97,8 +103,6 @@ export interface Logger {
readonly error: (message: unknown, ...optionalParams: unknown[]) => void
}

export type GetText = <K extends TextId>(key: K, ...replacements: Replacements[K]) => string

/** The {@link Backend} variant. If a new variant is created, it should be added to this enum. */
export enum BackendType {
local = 'local',
Expand Down Expand Up @@ -632,9 +636,6 @@ export interface CreateCustomerPortalSessionResponse {
readonly url: string | null
}

/** Response from the "path/resolve" endpoint. */
export interface PathResolveResponse extends Omit<AnyRealAsset, 'type' | 'ensoPath'> {}

/** Whether a type is `any`. */
type IsAny<T> = 0 extends 1 & T ? true : false

Expand Down Expand Up @@ -1686,13 +1687,13 @@ export class NotAuthorizedError extends NetworkError {}
export abstract class Backend {
abstract readonly type: BackendType
abstract readonly baseUrl: URL
protected getText: GetText
protected getText: DefaultGetText
private readonly client: HttpClient
protected readonly downloader: (options: DownloadOptions) => void | Promise<void>

/** Create a {@link Backend}. */
constructor(
getText: GetText,
getText: DefaultGetText,
client: HttpClient,
downloader: (options: DownloadOptions) => void | Promise<void>,
) {
Expand All @@ -1705,7 +1706,7 @@ export abstract class Backend {
* Set `this.getText`. This function is exposed rather than the property itself to make it clear
* that it is intended to be mutable.
*/
setGetText(getText: GetText) {
setGetText(getText: DefaultGetText) {
this.getText = getText
}

Expand Down Expand Up @@ -1897,7 +1898,7 @@ export abstract class Backend {
return (await this.resolveProjectAssetData(projectId, 'src/Main.enso', versionId)).text()
}
/** Resolve enso path to an asset */
abstract resolveEnsoPath(path: EnsoPath): Promise<PathResolveResponse>
abstract resolveEnsoPath(path: EnsoPath): Promise<AnyAsset>
/** Resolve the data of a project asset relative to the project root directory. */
abstract resolveProjectAssetData(
projectId: ProjectId,
Expand Down
11 changes: 8 additions & 3 deletions app/common/src/services/HttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export class HttpClient {
}
}

// On node.js, `navigator` seems to be defined, but `navigator.onLine` is always `undefined`.
if (navigator.onLine !== undefined && !navigator.onLine) {
return Promise.reject(new OfflineError('User is offline'))
}
Expand All @@ -164,21 +165,25 @@ export class HttpClient {
})) as ResponseWithTypedJson<T> & {
readonly body: Method extends 'GET' | 'HEAD' ? null : NonNullable<Response['body']>
}
if (typeof document !== 'undefined')
if (typeof document !== 'undefined') {
document.dispatchEvent(new Event(FETCH_SUCCESS_EVENT_NAME))
}
return response
} catch (error) {
// Even though the condition might seem always falsy,
// offline mode might happen during the request
// and this case need to be handled
if (navigator.onLine !== undefined && !navigator.onLine) {
if (typeof document !== 'undefined') document.dispatchEvent(new Event(OFFLINE_EVENT_NAME))
if (typeof document !== 'undefined') {
document.dispatchEvent(new Event(OFFLINE_EVENT_NAME))
}
throw new OfflineError('User is offline', { cause: error })
}

if (isNetworkError(error)) {
if (typeof document !== 'undefined')
if (typeof document !== 'undefined') {
document.dispatchEvent(new Event(FETCH_ERROR_EVENT_NAME))
}
throw new NetworkError(error.message, { cause: error })
}
throw error
Expand Down
11 changes: 5 additions & 6 deletions app/common/src/services/LocalBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* the API.
*/
import { markRaw } from 'vue'
import { PRODUCT_NAME } from '../constants.js'
import type { DownloadOptions } from '../download.js'
import { PRODUCT_NAME } from '../index.js'
import type { DefaultGetText } from '../text.js'
import { toReadableIsoString } from '../utilities/data/dateTime.js'
import { tryGetMessage } from '../utilities/errors.js'
import {
Expand Down Expand Up @@ -87,7 +88,7 @@ export class LocalBackend extends backend.Backend {

/** Create a {@link LocalBackend}. */
constructor(
getText: backend.GetText,
getText: DefaultGetText,
projectManagerInstance: ProjectManager,
client = new HttpClient(),
downloader: (options: DownloadOptions) => void | Promise<void>,
Expand Down Expand Up @@ -777,8 +778,8 @@ export class LocalBackend extends backend.Backend {
}

/** Resolve path to asset. In case of LocalBackend, this is just the filesystem path. */
override resolveEnsoPath(path: backend.EnsoPath): Promise<backend.PathResolveResponse> {
const { directoryPath } = getDirectoryAndName(Path(String(path)))
override resolveEnsoPath(path: backend.EnsoPath): Promise<backend.AnyAsset> {
const { directoryPath } = getDirectoryAndName(Path(path as string))
return this.findAsset(directoryPath, 'ensoPath', path)
}

Expand Down Expand Up @@ -874,15 +875,13 @@ export class LocalBackend extends backend.Backend {
assetId: backend.AssetId,
localProjectId: backend.ProjectId,
parentDirectoryId: backend.DirectoryId,
baseUrl: URL,
defaultHeaders: Record<string, string>,
): Promise<void> {
const localProjectDirectory = backend.extractTypeAndPath(localProjectId).path
const queryString = new URLSearchParams({
assetId,
parentDirectoryId,
directory: localProjectDirectory,
baseUrl: baseUrl.toString(),
}).toString()
const response = await this.post(
new URL(`/api/watcher/start?${queryString}`, location.href).toString(),
Expand Down
Loading
Loading