@neurocode-ai/desktop 1.18.8
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/AGENTS.md +4 -0
- package/README.md +19 -0
- package/electron-builder.config.test.ts +48 -0
- package/electron-builder.config.ts +146 -0
- package/electron.vite.config.ts +106 -0
- package/icons/README.md +14 -0
- package/icons/beta/128x128.png +0 -0
- package/icons/beta/128x128@2x.png +0 -0
- package/icons/beta/32x32.png +0 -0
- package/icons/beta/64x64.png +0 -0
- package/icons/beta/Square107x107Logo.png +0 -0
- package/icons/beta/Square142x142Logo.png +0 -0
- package/icons/beta/Square150x150Logo.png +0 -0
- package/icons/beta/Square284x284Logo.png +0 -0
- package/icons/beta/Square30x30Logo.png +0 -0
- package/icons/beta/Square310x310Logo.png +0 -0
- package/icons/beta/Square44x44Logo.png +0 -0
- package/icons/beta/Square71x71Logo.png +0 -0
- package/icons/beta/Square89x89Logo.png +0 -0
- package/icons/beta/StoreLogo.png +0 -0
- package/icons/beta/android/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/icons/beta/android/mipmap-hdpi/ic_launcher.png +0 -0
- package/icons/beta/android/mipmap-hdpi/ic_launcher_foreground.png +0 -0
- package/icons/beta/android/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/icons/beta/android/mipmap-mdpi/ic_launcher.png +0 -0
- package/icons/beta/android/mipmap-mdpi/ic_launcher_foreground.png +0 -0
- package/icons/beta/android/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/icons/beta/android/mipmap-xhdpi/ic_launcher.png +0 -0
- package/icons/beta/android/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
- package/icons/beta/android/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/icons/beta/android/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/icons/beta/android/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
- package/icons/beta/android/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/icons/beta/android/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/icons/beta/android/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
- package/icons/beta/android/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/icons/beta/android/values/ic_launcher_background.xml +4 -0
- package/icons/beta/dock.png +0 -0
- package/icons/beta/icon.icns +0 -0
- package/icons/beta/icon.ico +0 -0
- package/icons/beta/icon.png +0 -0
- package/icons/beta/ios/AppIcon-20x20@1x.png +0 -0
- package/icons/beta/ios/AppIcon-20x20@2x-1.png +0 -0
- package/icons/beta/ios/AppIcon-20x20@2x.png +0 -0
- package/icons/beta/ios/AppIcon-20x20@3x.png +0 -0
- package/icons/beta/ios/AppIcon-29x29@1x.png +0 -0
- package/icons/beta/ios/AppIcon-29x29@2x-1.png +0 -0
- package/icons/beta/ios/AppIcon-29x29@2x.png +0 -0
- package/icons/beta/ios/AppIcon-29x29@3x.png +0 -0
- package/icons/beta/ios/AppIcon-40x40@1x.png +0 -0
- package/icons/beta/ios/AppIcon-40x40@2x-1.png +0 -0
- package/icons/beta/ios/AppIcon-40x40@2x.png +0 -0
- package/icons/beta/ios/AppIcon-40x40@3x.png +0 -0
- package/icons/beta/ios/AppIcon-512@2x.png +0 -0
- package/icons/beta/ios/AppIcon-60x60@2x.png +0 -0
- package/icons/beta/ios/AppIcon-60x60@3x.png +0 -0
- package/icons/beta/ios/AppIcon-76x76@1x.png +0 -0
- package/icons/beta/ios/AppIcon-76x76@2x.png +0 -0
- package/icons/beta/ios/AppIcon-83.5x83.5@2x.png +0 -0
- package/icons/dev/128x128.png +0 -0
- package/icons/dev/128x128@2x.png +0 -0
- package/icons/dev/32x32.png +0 -0
- package/icons/dev/64x64.png +0 -0
- package/icons/dev/Square107x107Logo.png +0 -0
- package/icons/dev/Square142x142Logo.png +0 -0
- package/icons/dev/Square150x150Logo.png +0 -0
- package/icons/dev/Square284x284Logo.png +0 -0
- package/icons/dev/Square30x30Logo.png +0 -0
- package/icons/dev/Square310x310Logo.png +0 -0
- package/icons/dev/Square44x44Logo.png +0 -0
- package/icons/dev/Square71x71Logo.png +0 -0
- package/icons/dev/Square89x89Logo.png +0 -0
- package/icons/dev/StoreLogo.png +0 -0
- package/icons/dev/android/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/icons/dev/android/mipmap-hdpi/ic_launcher.png +0 -0
- package/icons/dev/android/mipmap-hdpi/ic_launcher_foreground.png +0 -0
- package/icons/dev/android/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/icons/dev/android/mipmap-mdpi/ic_launcher.png +0 -0
- package/icons/dev/android/mipmap-mdpi/ic_launcher_foreground.png +0 -0
- package/icons/dev/android/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/icons/dev/android/mipmap-xhdpi/ic_launcher.png +0 -0
- package/icons/dev/android/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
- package/icons/dev/android/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/icons/dev/android/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/icons/dev/android/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
- package/icons/dev/android/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/icons/dev/android/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/icons/dev/android/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
- package/icons/dev/android/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/icons/dev/android/values/ic_launcher_background.xml +4 -0
- package/icons/dev/dock.png +0 -0
- package/icons/dev/icon.icns +0 -0
- package/icons/dev/icon.ico +0 -0
- package/icons/dev/icon.png +0 -0
- package/icons/dev/ios/AppIcon-20x20@1x.png +0 -0
- package/icons/dev/ios/AppIcon-20x20@2x-1.png +0 -0
- package/icons/dev/ios/AppIcon-20x20@2x.png +0 -0
- package/icons/dev/ios/AppIcon-20x20@3x.png +0 -0
- package/icons/dev/ios/AppIcon-29x29@1x.png +0 -0
- package/icons/dev/ios/AppIcon-29x29@2x-1.png +0 -0
- package/icons/dev/ios/AppIcon-29x29@2x.png +0 -0
- package/icons/dev/ios/AppIcon-29x29@3x.png +0 -0
- package/icons/dev/ios/AppIcon-40x40@1x.png +0 -0
- package/icons/dev/ios/AppIcon-40x40@2x-1.png +0 -0
- package/icons/dev/ios/AppIcon-40x40@2x.png +0 -0
- package/icons/dev/ios/AppIcon-40x40@3x.png +0 -0
- package/icons/dev/ios/AppIcon-512@2x.png +0 -0
- package/icons/dev/ios/AppIcon-60x60@2x.png +0 -0
- package/icons/dev/ios/AppIcon-60x60@3x.png +0 -0
- package/icons/dev/ios/AppIcon-76x76@1x.png +0 -0
- package/icons/dev/ios/AppIcon-76x76@2x.png +0 -0
- package/icons/dev/ios/AppIcon-83.5x83.5@2x.png +0 -0
- package/icons/prod/128x128.png +0 -0
- package/icons/prod/128x128@2x.png +0 -0
- package/icons/prod/32x32.png +0 -0
- package/icons/prod/64x64.png +0 -0
- package/icons/prod/Square107x107Logo.png +0 -0
- package/icons/prod/Square142x142Logo.png +0 -0
- package/icons/prod/Square150x150Logo.png +0 -0
- package/icons/prod/Square284x284Logo.png +0 -0
- package/icons/prod/Square30x30Logo.png +0 -0
- package/icons/prod/Square310x310Logo.png +0 -0
- package/icons/prod/Square44x44Logo.png +0 -0
- package/icons/prod/Square71x71Logo.png +0 -0
- package/icons/prod/Square89x89Logo.png +0 -0
- package/icons/prod/StoreLogo.png +0 -0
- package/icons/prod/android/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/icons/prod/android/mipmap-hdpi/ic_launcher.png +0 -0
- package/icons/prod/android/mipmap-hdpi/ic_launcher_foreground.png +0 -0
- package/icons/prod/android/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/icons/prod/android/mipmap-mdpi/ic_launcher.png +0 -0
- package/icons/prod/android/mipmap-mdpi/ic_launcher_foreground.png +0 -0
- package/icons/prod/android/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/icons/prod/android/mipmap-xhdpi/ic_launcher.png +0 -0
- package/icons/prod/android/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
- package/icons/prod/android/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/icons/prod/android/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/icons/prod/android/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
- package/icons/prod/android/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/icons/prod/android/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/icons/prod/android/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
- package/icons/prod/android/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/icons/prod/android/values/ic_launcher_background.xml +4 -0
- package/icons/prod/dock.png +0 -0
- package/icons/prod/icon.icns +0 -0
- package/icons/prod/icon.ico +0 -0
- package/icons/prod/icon.png +0 -0
- package/icons/prod/ios/AppIcon-20x20@1x.png +0 -0
- package/icons/prod/ios/AppIcon-20x20@2x-1.png +0 -0
- package/icons/prod/ios/AppIcon-20x20@2x.png +0 -0
- package/icons/prod/ios/AppIcon-20x20@3x.png +0 -0
- package/icons/prod/ios/AppIcon-29x29@1x.png +0 -0
- package/icons/prod/ios/AppIcon-29x29@2x-1.png +0 -0
- package/icons/prod/ios/AppIcon-29x29@2x.png +0 -0
- package/icons/prod/ios/AppIcon-29x29@3x.png +0 -0
- package/icons/prod/ios/AppIcon-40x40@1x.png +0 -0
- package/icons/prod/ios/AppIcon-40x40@2x-1.png +0 -0
- package/icons/prod/ios/AppIcon-40x40@2x.png +0 -0
- package/icons/prod/ios/AppIcon-40x40@3x.png +0 -0
- package/icons/prod/ios/AppIcon-512@2x.png +0 -0
- package/icons/prod/ios/AppIcon-60x60@2x.png +0 -0
- package/icons/prod/ios/AppIcon-60x60@3x.png +0 -0
- package/icons/prod/ios/AppIcon-76x76@1x.png +0 -0
- package/icons/prod/ios/AppIcon-76x76@2x.png +0 -0
- package/icons/prod/ios/AppIcon-83.5x83.5@2x.png +0 -0
- package/package.json +75 -0
- package/resources/entitlements.plist +18 -0
- package/resources/linux/opencode-desktop.desktop +10 -0
- package/scripts/copy-bundles.ts +12 -0
- package/scripts/copy-icons.ts +12 -0
- package/scripts/copy-metainfo.ts +47 -0
- package/scripts/finalize-latest-json.ts +219 -0
- package/scripts/finalize-latest-yml.ts +124 -0
- package/scripts/prebuild.ts +10 -0
- package/scripts/predev.ts +5 -0
- package/scripts/prepare.ts +9 -0
- package/scripts/utils.ts +77 -0
- package/src/main/apps.ts +136 -0
- package/src/main/attachment-picker.test.ts +87 -0
- package/src/main/attachment-picker.ts +56 -0
- package/src/main/constants.ts +7 -0
- package/src/main/debug.ts +95 -0
- package/src/main/desktop-menu-actions.ts +84 -0
- package/src/main/env.d.ts +19 -0
- package/src/main/index.test.ts +37 -0
- package/src/main/index.ts +399 -0
- package/src/main/initialization.ts +6 -0
- package/src/main/install-state.test.ts +19 -0
- package/src/main/install-state.ts +8 -0
- package/src/main/ipc.ts +274 -0
- package/src/main/logging.ts +205 -0
- package/src/main/markdown.ts +16 -0
- package/src/main/menu.ts +67 -0
- package/src/main/migrate.ts +91 -0
- package/src/main/onboarding.ts +45 -0
- package/src/main/server.ts +238 -0
- package/src/main/shell-env.test.ts +50 -0
- package/src/main/shell-env.ts +101 -0
- package/src/main/sidecar.ts +157 -0
- package/src/main/store-cleanup.test.ts +93 -0
- package/src/main/store-cleanup.ts +94 -0
- package/src/main/store-keys.ts +7 -0
- package/src/main/store.ts +35 -0
- package/src/main/unresponsive.ts +70 -0
- package/src/main/updater-controller.test.ts +111 -0
- package/src/main/updater-controller.ts +97 -0
- package/src/main/updater-subscriptions.test.ts +16 -0
- package/src/main/updater-subscriptions.ts +20 -0
- package/src/main/updater.ts +85 -0
- package/src/main/window-registry.test.ts +91 -0
- package/src/main/window-registry.ts +47 -0
- package/src/main/window-state.ts +29 -0
- package/src/main/windows.ts +496 -0
- package/src/main/wsl/ipc.ts +103 -0
- package/src/main/wsl/policy.ts +33 -0
- package/src/main/wsl/runtime.ts +400 -0
- package/src/main/wsl/servers.test.ts +231 -0
- package/src/main/wsl/servers.ts +521 -0
- package/src/main/wsl/sidecar.ts +129 -0
- package/src/main/wsl/startup.ts +31 -0
- package/src/preload/index.ts +128 -0
- package/src/preload/types.ts +109 -0
- package/src/renderer/cli.ts +12 -0
- package/src/renderer/env.d.ts +10 -0
- package/src/renderer/html.test.ts +62 -0
- package/src/renderer/i18n/ar.ts +26 -0
- package/src/renderer/i18n/br.ts +27 -0
- package/src/renderer/i18n/bs.ts +28 -0
- package/src/renderer/i18n/da.ts +28 -0
- package/src/renderer/i18n/de.ts +28 -0
- package/src/renderer/i18n/en.ts +27 -0
- package/src/renderer/i18n/es.ts +27 -0
- package/src/renderer/i18n/fr.ts +28 -0
- package/src/renderer/i18n/index.ts +194 -0
- package/src/renderer/i18n/ja.ts +28 -0
- package/src/renderer/i18n/ko.ts +27 -0
- package/src/renderer/i18n/no.ts +28 -0
- package/src/renderer/i18n/pl.ts +28 -0
- package/src/renderer/i18n/ru.ts +27 -0
- package/src/renderer/i18n/uk.ts +28 -0
- package/src/renderer/i18n/zh.ts +26 -0
- package/src/renderer/i18n/zht.ts +26 -0
- package/src/renderer/index.html +21 -0
- package/src/renderer/index.tsx +464 -0
- package/src/renderer/initialization.test.ts +73 -0
- package/src/renderer/initialization.ts +22 -0
- package/src/renderer/onboarding.tsx +53 -0
- package/src/renderer/styles.css +0 -0
- package/src/renderer/webview-zoom.ts +138 -0
- package/src/renderer/wsl/connections.test.ts +43 -0
- package/src/renderer/wsl/connections.ts +28 -0
- package/sst-env.d.ts +10 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
import { createSignal } from "solid-js"
|
|
6
|
+
|
|
7
|
+
const OS_NAME = (() => {
|
|
8
|
+
if (navigator.userAgent.includes("Mac")) return "macos"
|
|
9
|
+
if (navigator.userAgent.includes("Windows")) return "windows"
|
|
10
|
+
if (navigator.userAgent.includes("Linux")) return "linux"
|
|
11
|
+
return "unknown"
|
|
12
|
+
})()
|
|
13
|
+
|
|
14
|
+
const [webviewZoom, setWebviewZoom] = createSignal(1)
|
|
15
|
+
let requestedZoom = 1
|
|
16
|
+
let pinchZoomEnabled = false
|
|
17
|
+
let wheelPinch = undefined as
|
|
18
|
+
| {
|
|
19
|
+
active: boolean
|
|
20
|
+
startZoom: number
|
|
21
|
+
totalDelta: number
|
|
22
|
+
timeout: ReturnType<typeof setTimeout> | undefined
|
|
23
|
+
}
|
|
24
|
+
| undefined
|
|
25
|
+
|
|
26
|
+
const MAX_ZOOM_LEVEL = 10
|
|
27
|
+
const MIN_ZOOM_LEVEL = 0.2
|
|
28
|
+
const WHEEL_PINCH_THRESHOLD = 20
|
|
29
|
+
const WHEEL_PINCH_STEP = 0.2
|
|
30
|
+
const WHEEL_PINCH_END_DELAY = 160
|
|
31
|
+
|
|
32
|
+
const clamp = (value: number) => Math.min(Math.max(value, MIN_ZOOM_LEVEL), MAX_ZOOM_LEVEL)
|
|
33
|
+
|
|
34
|
+
const applyZoom = (next: number) => {
|
|
35
|
+
requestedZoom = next
|
|
36
|
+
void window.api
|
|
37
|
+
.setZoomFactor(next)
|
|
38
|
+
.then(() => {
|
|
39
|
+
if (requestedZoom !== next) return
|
|
40
|
+
setWebviewZoom(next)
|
|
41
|
+
})
|
|
42
|
+
.catch(() => {
|
|
43
|
+
if (requestedZoom !== next) return
|
|
44
|
+
requestedZoom = webviewZoom()
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
window.api.onZoomFactorChanged((factor) => {
|
|
49
|
+
requestedZoom = clamp(factor)
|
|
50
|
+
setWebviewZoom(requestedZoom)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
void window.api.getPinchZoomEnabled().then((enabled) => {
|
|
54
|
+
pinchZoomEnabled = enabled
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
window.api.onPinchZoomEnabledChanged((enabled) => {
|
|
58
|
+
pinchZoomEnabled = enabled
|
|
59
|
+
resetWheelPinch()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const setPinchZoomEnabled = (enabled: boolean) => {
|
|
63
|
+
pinchZoomEnabled = enabled
|
|
64
|
+
resetWheelPinch()
|
|
65
|
+
return window.api.setPinchZoomEnabled(enabled)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const resetZoom = () => applyZoom(1)
|
|
69
|
+
const zoomIn = () => applyZoom(clamp(requestedZoom + 0.2))
|
|
70
|
+
const zoomOut = () => applyZoom(clamp(requestedZoom - 0.2))
|
|
71
|
+
|
|
72
|
+
const resetWheelPinch = () => {
|
|
73
|
+
clearTimeout(wheelPinch?.timeout)
|
|
74
|
+
wheelPinch = undefined
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const normalizeWheelDelta = (event: WheelEvent) => {
|
|
78
|
+
if (event.deltaMode === WheelEvent.DOM_DELTA_LINE) return event.deltaY * 16
|
|
79
|
+
if (event.deltaMode === WheelEvent.DOM_DELTA_PAGE) return event.deltaY * window.innerHeight
|
|
80
|
+
return event.deltaY
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const updateWheelPinch = (event: WheelEvent) => {
|
|
84
|
+
wheelPinch ??= {
|
|
85
|
+
active: false,
|
|
86
|
+
startZoom: requestedZoom,
|
|
87
|
+
totalDelta: 0,
|
|
88
|
+
timeout: undefined,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
clearTimeout(wheelPinch.timeout)
|
|
92
|
+
wheelPinch.timeout = setTimeout(resetWheelPinch, WHEEL_PINCH_END_DELAY)
|
|
93
|
+
wheelPinch.totalDelta += normalizeWheelDelta(event)
|
|
94
|
+
|
|
95
|
+
if (!wheelPinch.active && Math.abs(wheelPinch.totalDelta) < WHEEL_PINCH_THRESHOLD) return
|
|
96
|
+
if (!wheelPinch.active) {
|
|
97
|
+
wheelPinch.active = true
|
|
98
|
+
wheelPinch.startZoom = requestedZoom
|
|
99
|
+
wheelPinch.totalDelta = 0
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
wheelPinch.active = true
|
|
104
|
+
applyZoom(clamp(wheelPinch.startZoom - (wheelPinch.totalDelta / WHEEL_PINCH_THRESHOLD) * WHEEL_PINCH_STEP))
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
window.addEventListener(
|
|
108
|
+
"wheel",
|
|
109
|
+
(event) => {
|
|
110
|
+
if (!pinchZoomEnabled) return
|
|
111
|
+
if (!event.ctrlKey) return
|
|
112
|
+
|
|
113
|
+
event.preventDefault()
|
|
114
|
+
updateWheelPinch(event)
|
|
115
|
+
},
|
|
116
|
+
{ passive: false },
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
window.addEventListener("keydown", (event) => {
|
|
120
|
+
if (!(OS_NAME === "macos" ? event.metaKey : event.ctrlKey)) return
|
|
121
|
+
|
|
122
|
+
if (event.key === "-") {
|
|
123
|
+
event.preventDefault()
|
|
124
|
+
zoomOut()
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
if (event.key === "=" || event.key === "+") {
|
|
128
|
+
event.preventDefault()
|
|
129
|
+
zoomIn()
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
if (event.key === "0") {
|
|
133
|
+
event.preventDefault()
|
|
134
|
+
resetZoom()
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
export { webviewZoom, resetZoom, setPinchZoomEnabled, zoomIn, zoomOut }
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test"
|
|
2
|
+
import type { WslServersState } from "@neurocode-ai/app/wsl/types"
|
|
3
|
+
import { availableStartupServer, readyWslConnections } from "./connections"
|
|
4
|
+
|
|
5
|
+
const state = (kind: "starting" | "ready" | "failed" | "stopped"): WslServersState => ({
|
|
6
|
+
runtime: null,
|
|
7
|
+
installed: [],
|
|
8
|
+
online: [],
|
|
9
|
+
distroProbes: {},
|
|
10
|
+
neurocodeChecks: {},
|
|
11
|
+
pendingRestart: false,
|
|
12
|
+
job: null,
|
|
13
|
+
servers: [
|
|
14
|
+
{
|
|
15
|
+
config: { id: "wsl:Debian", distro: "Debian" },
|
|
16
|
+
runtime: runtime(kind),
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
function runtime(kind: "starting" | "ready" | "failed" | "stopped") {
|
|
22
|
+
if (kind === "ready") return { kind, url: "http://127.0.0.1:4096", username: "neurocode", password: "secret" }
|
|
23
|
+
if (kind === "failed") return { kind, message: "boom" }
|
|
24
|
+
return { kind }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe("WSL desktop connections", () => {
|
|
28
|
+
test("publishes a WSL server only after it reports ready", () => {
|
|
29
|
+
expect(readyWslConnections(state("starting"))).toEqual([])
|
|
30
|
+
expect(readyWslConnections(state("failed"))).toEqual([])
|
|
31
|
+
expect(readyWslConnections(state("stopped"))).toEqual([])
|
|
32
|
+
expect(readyWslConnections(state("ready"))).toEqual([
|
|
33
|
+
expect.objectContaining({ displayName: "Debian", label: "WSL" }),
|
|
34
|
+
])
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
test("does not block desktop startup on a configured WSL default", () => {
|
|
38
|
+
const key = "wsl:Debian"
|
|
39
|
+
expect(availableStartupServer(key, undefined)).toBe("sidecar")
|
|
40
|
+
expect(availableStartupServer(key, state("starting"))).toBe("sidecar")
|
|
41
|
+
expect(availableStartupServer(key, state("ready"))).toBe(key)
|
|
42
|
+
})
|
|
43
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { WslServersState } from "@neurocode-ai/app/wsl/types"
|
|
2
|
+
|
|
3
|
+
export function readyWslConnections(state?: WslServersState) {
|
|
4
|
+
return (state?.servers ?? []).flatMap((item) => {
|
|
5
|
+
if (item.runtime.kind !== "ready") return []
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
8
|
+
displayName: item.config.distro,
|
|
9
|
+
label: "WSL",
|
|
10
|
+
type: "sidecar" as const,
|
|
11
|
+
variant: "wsl" as const,
|
|
12
|
+
distro: item.config.distro,
|
|
13
|
+
http: {
|
|
14
|
+
url: item.runtime.url,
|
|
15
|
+
username: item.runtime.username ?? undefined,
|
|
16
|
+
password: item.runtime.password ?? undefined,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function availableStartupServer(defaultServer: string | null | undefined, state?: WslServersState) {
|
|
24
|
+
const key = defaultServer ?? "sidecar"
|
|
25
|
+
if (!key.startsWith("wsl:")) return key
|
|
26
|
+
if (state?.servers.some((item) => item.config.id === key && item.runtime.kind === "ready")) return key
|
|
27
|
+
return "sidecar"
|
|
28
|
+
}
|
package/sst-env.d.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"jsx": "preserve",
|
|
10
|
+
"jsxImportSource": "solid-js",
|
|
11
|
+
"allowJs": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"emitDeclarationOnly": false,
|
|
17
|
+
"outDir": "node_modules/.ts-dist",
|
|
18
|
+
"types": ["vite/client", "node", "electron"]
|
|
19
|
+
},
|
|
20
|
+
"references": [{ "path": "../app" }],
|
|
21
|
+
"include": ["src", "package.json"],
|
|
22
|
+
"exclude": ["src/**/*.test.ts"]
|
|
23
|
+
}
|