Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions .github/workflows/build-example-desktop-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build Example Desktop (macOS)

on:
workflow_call:

jobs:
build-mac:
runs-on: macos-latest
permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install dependencies
run: |
echo "📦 Installing dependencies..."
yarn
yarn bootstrap

- name: Build macOS App
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd packages/connect-examples/electron-example
yarn make:mac

- name: Upload macOS Artifact
uses: actions/upload-artifact@v4
with:
name: mac-example-desktop
path: packages/connect-examples/electron-example/out/*.dmg

44 changes: 44 additions & 0 deletions .github/workflows/build-example-desktop-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Example Desktop (Windows)

on:
workflow_call:

jobs:
build-win:
runs-on: windows-latest
permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'yarn'

- name: Enable long paths on Windows
run: git config --system core.longpaths true

- name: Install dependencies
run: |
echo "📦 Installing dependencies..."
yarn
yarn bootstrap

- name: Build Windows App
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd packages/connect-examples/electron-example
yarn make:win

- name: Upload Windows Artifact
uses: actions/upload-artifact@v4
with:
name: win-example-desktop
path: packages/connect-examples/electron-example/out/*.exe
61 changes: 12 additions & 49 deletions .github/workflows/build-example-desktop.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,16 @@
name: build-example-desktop
name: Build Example Desktop (All Platforms)

on: workflow_dispatch
on:
workflow_dispatch:

jobs:
build:
runs-on: macos-latest
env:
PROJECT_PATH: packages/connect-examples/electron-example
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: |
yarn
yarn bootstrap

- name: Build Target
run: |
yarn build
permissions:
contents: write

- name: Build Desktop Application
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn build:example:desktop

- name: Upload Mac x64 Artifacts
uses: actions/upload-artifact@v4
with:
name: mac-x64-example-desktop
path: |
${{ env.PROJECT_PATH }}/out/*x64.dmg
${{ env.PROJECT_PATH }}/out/*mac-x64.zip

- name: Upload Mac arm64 Artifacts
uses: actions/upload-artifact@v4
with:
name: mac-arm64-example-desktop
path: |
${{ env.PROJECT_PATH }}/out/*arm64.dmg
${{ env.PROJECT_PATH }}/out/*mac-arm64.zip
jobs:
build-mac:
uses: ./.github/workflows/build-example-desktop-mac.yml
secrets: inherit

- name: Upload Windows Artifacts
uses: actions/upload-artifact@v4
with:
name: win-x64-example-desktop
path: |
${{ env.PROJECT_PATH }}/out/*.exe
build-win:
uses: ./.github/workflows/build-example-desktop-win.yml
secrets: inherit
38 changes: 37 additions & 1 deletion .github/workflows/package-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,34 @@ jobs:
echo "📦 Detected stable version: $VERSION"
fi

get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version-info.outputs.version }}
is_prerelease: ${{ steps.version-info.outputs.is_prerelease }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get version information
id: version-info
run: |
# Get version from core package (assuming independent versioning)
VERSION=$(node -p "require('./packages/core/package.json').version")
echo "📦 Package version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT

# Check if this is a prerelease version (contains -)
if [[ "$VERSION" =~ - ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "📦 Detected prerelease version: $VERSION"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "📦 Detected stable version: $VERSION"
fi

publish-and-release:
needs: get-version
runs-on: ubuntu-latest
Expand Down Expand Up @@ -69,7 +97,15 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "📦 Publishing packages to NPM (v${{ needs.get-version.outputs.version }})..."
yarn publish-packages -y --no-verify-access
IS_PRERELEASE=${{ needs.get-version.outputs.is_prerelease }}

if [ "$IS_PRERELEASE" = "true" ]; then
echo "📦 Publishing with --dist-tag next for prerelease"
yarn publish-packages -y --no-verify-access --dist-tag next
else
echo "📦 Publishing with --dist-tag latest for stable release"
yarn publish-packages -y --no-verify-access --dist-tag latest
fi
echo "✅ Packages published successfully"

- name: Publication Summary
Expand Down
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# Run tests
yarn test

# Run check versions
yarn check-versions

# Run lint:fix
yarn lint:staged

Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
"lint:staged": "lint-staged",
"test": "lerna run test",
"setup": "yarn && yarn bootstrap && yarn build",
"publish-packages": "lerna publish from-package",
"check-versions": "node scripts/check-versions.js",
"publish-packages": "yarn check-versions && lerna publish from-package",
"update-protobuf": "lerna run update:protobuf --scope=@onekeyfe/hd-transport",
"update-version": "lerna version --no-git-tag-version --force-publish=@onekeyfe/hd-core,@onekeyfe/hd-ble-sdk,@onekeyfe/hd-common-connect-sdk,@onekeyfe/hd-transport-electron,@onekeyfe/hd-transport-emulator,@onekeyfe/hd-transport-http,@onekeyfe/hd-transport-lowlevel,@onekeyfe/hd-transport-react-native,@onekeyfe/hd-transport-web-device,@onekeyfe/hd-transport,@onekeyfe/hd-web-sdk,@onekeyfe/hd-shared",
"example": "cd ./packages/connect-examples/expo-example && yarn start",
"example:web": "cd ./packages/connect-examples/expo-example && cross-env CONNECT_SRC=https://localhost:8087 yarn start",
"example:desktop": "cd ./packages/connect-examples/electron-example && yarn dev",
"build:example:desktop": "cd ./packages/connect-examples/electron-example && yarn make",
"build:example:desktop:mac": "cd ./packages/connect-examples/electron-example && yarn make:mac",
"build:example:desktop:win": "cd ./packages/connect-examples/electron-example && yarn make:win",
"example:v2": "cd ./packages/connect-examples/expo-playground && yarn start",
"dev:all": "lerna run dev --parallel --ignore expo-example --ignore hardware-example --ignore onekey-hardware-playground",
"dev:web": "cd ./packages/hd-web-sdk && yarn dev",
Expand All @@ -49,6 +51,7 @@
"dev:transport-lowlevel": "cd ./packages/hd-transport-lowlevel && yarn dev",
"dev:transport-emulator": "cd ./packages/hd-transport-emulator && yarn dev",
"dev:transport-web-device": "cd ./packages/hd-transport-web-device && yarn dev",
"dev:transport-electron": "cd ./packages/hd-transport-electron && yarn dev",
"dev:shared": "cd ./packages/shared && yarn dev",
"debug:watcher": "node ./scripts/monitor.js"
},
Expand All @@ -62,7 +65,9 @@
"parse-url": "8.1.0",
"braces": "3.0.3",
"tmp": "0.2.4",
"micromatch": "4.0.8"
"micromatch": "4.0.8",
"sha.js": "2.4.12",
"cipher-base": "1.0.5"
},
"devDependencies": {
"@babel/core": "^7.0.0",
Expand All @@ -78,6 +83,7 @@
"@types/jest": "^27.5.1",
"@types/node": "^18.18.8",
"@types/shelljs": "^0.8.11",
"electron-builder": "^24.9.1",
"babel-jest": "^28.1.3",
"babel-loader": "^8.2.5",
"cross-env": "^7.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ module.exports = {
productName: 'HardwareExample',
copyright: 'Copyright © OeKey 2024',
asar: true,
// Unpack native modules so they can be loaded at runtime
asarUnpack: [
'node_modules/@stoprocent/noble/**',
'node_modules/@stoprocent/bluetooth-hci-socket/**',
],
buildVersion: version,
directories: {
output: 'out',
Expand Down
9 changes: 6 additions & 3 deletions packages/connect-examples/electron-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hardware-example",
"productName": "HardwareExample",
"executableName": "onekey-hardware-example",
"version": "1.1.10-alpha.1",
"version": "1.1.10",
"author": "OneKey",
"description": "End-to-end encrypted workspaces for teams",
"main": "dist/index.js",
Expand All @@ -15,12 +15,15 @@
"dev": "npx concurrently \"yarn dev:electron\" \"cross-env TRANSFORM_REGENERATOR_DISABLED=true BROWSER=none yarn dev-electron-web\"",
"dev:electron": "electron --inspect=5858 dist/index.js",
"build:main": "webpack --config webpack.config.ts",
"make": "yarn clean:build && yarn build-electron-web && electron-builder build -mw --config electron-builder.config.js --publish always",
"rebuild:deps": "electron-builder install-app-deps",
"make:mac": "yarn rebuild:deps && yarn clean:build && yarn build-electron-web && electron-builder build --mac --config electron-builder.config.js --publish always",
"make:win": "yarn rebuild:deps && yarn clean:build && yarn build-electron-web && electron-builder build --win --config electron-builder.config.js --publish always",
"lint": "eslint --ext .tsx --ext .ts ./",
"ts:check": "yarn tsc --noEmit"
},
"dependencies": {
"@abandonware/noble": "^1.9.2-26",
"@onekeyfe/hd-transport-electron": "1.1.10",
"@stoprocent/noble": "2.3.4",
"debug": "4.3.4",
"electron-is-dev": "^3.0.1",
"electron-log": "^5.1.5",
Expand Down
11 changes: 9 additions & 2 deletions packages/connect-examples/electron-example/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ function createMainWindow() {
}
});

initNobleBleSupport(browserWindow.webContents);

ipcMain.on(ipcMessageKeys.APP_RESTART, () => {
browserWindow?.reload();
});
Expand All @@ -283,6 +281,15 @@ if (!singleInstance && !process.mas) {
if (!mainWindow) {
mainWindow = createMainWindow();
}

try {
log.info('Initializing Noble BLE support...');
initNobleBleSupport(mainWindow.webContents);
log.info('Noble BLE support initialized successfully.');
} catch (e) {
log.error('Failed to initialize Noble BLE support:', e);
}

initChildProcess();
showMainWindow();
console.log('日志文件位置:', log.transports.file.getFile().path);
Expand Down
5 changes: 3 additions & 2 deletions packages/connect-examples/electron-example/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ module.exports = {
}),
}),
{
'@abandonware/noble': 'commonjs @abandonware/noble',
'@abandonware/bluetooth-hci-socket': 'commonjs @abandonware/bluetooth-hci-socket',
'@onekeyfe/hd-transport-electron': 'commonjs @onekeyfe/hd-transport-electron',
'@stoprocent/noble': 'commonjs @stoprocent/noble',
'@stoprocent/bluetooth-hci-socket': 'commonjs @stoprocent/bluetooth-hci-socket',
bufferutil: 'commonjs bufferutil',
'utf-8-validate': 'commonjs utf-8-validate',
},
Expand Down
12 changes: 6 additions & 6 deletions packages/connect-examples/expo-example/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "expo-example",
"version": "1.1.10-alpha.2",
"version": "1.1.10",
"scripts": {
"start": "cross-env CONNECT_SRC=https://localhost:8087/ yarn expo start --dev-client",
"android": "yarn expo run:android",
"ios": "yarn expo run:ios",
"web": "yarn expo start --web",
"dev:electron-web": "cross-env NODE_OPTIONS=--openssl-legacy-provider cross-env EXPO_ELECTRON_MODE=true yarn web",
"build:electron-web": "cross-env NODE_ENV=production EXPO_ELECTRON_MODE=true yarn expo export:web && node scripts/moveWebBuild.js",
"build:electron-web": "cross-env NODE_OPTIONS=--max-old-space-size=4096 cross-env NODE_ENV=production EXPO_ELECTRON_MODE=true yarn expo export:web && node scripts/moveWebBuild.js",
"eject": "yarn expo eject"
},
"dependencies": {
Expand All @@ -19,10 +19,10 @@
"@noble/ed25519": "^2.1.0",
"@noble/hashes": "^1.3.3",
"@noble/secp256k1": "^1.7.1",
"@onekeyfe/hd-ble-sdk": "1.1.10-alpha.2",
"@onekeyfe/hd-common-connect-sdk": "1.1.10-alpha.2",
"@onekeyfe/hd-core": "1.1.10-alpha.2",
"@onekeyfe/hd-web-sdk": "1.1.10-alpha.2",
"@onekeyfe/hd-ble-sdk": "1.1.10",
"@onekeyfe/hd-common-connect-sdk": "1.1.10",
"@onekeyfe/hd-core": "1.1.10",
"@onekeyfe/hd-web-sdk": "1.1.10",
"@onekeyfe/react-native-ble-utils": "^0.1.3",
"@polkadot/util-crypto": "13.1.1",
"@react-native-async-storage/async-storage": "1.21.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ export function useRunnerTest<T>(config: RunnerConfig<T>) {
initTestCase,
store,
stateManager,
preCheckResponse,
clearItemVerifyState,
endTestRunner,
setFailedTasks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export type Device = {
name: string;
features?: Features;
deviceType?: string;
id?: string;
state?: string;
};

const CONNECTION_TYPE_STORE_KEY = '@onekey/connectionType';
Expand Down Expand Up @@ -126,7 +128,13 @@ function DeviceListFC(
const response = await sdk.searchDevices();
const foundDevices = (response.payload as unknown as Device[]) ?? [];
setDeviceActions({ type: 'setList', payload: foundDevices });
if (Platform.OS === 'web' && foundDevices?.length) {

// 🔧 DESKTOP BLE FIX: Don't auto-select devices, let user choose manually
// This prevents automatic connection which can cause issues with device switching
// Users should manually click the "Connect Device" button for their desired device

// Only auto-select for non-desktop-web-ble connections to maintain backward compatibility
if (Platform.OS === 'web' && foundDevices?.length && connectionType !== 'desktop-web-ble') {
const device = foundDevices[0];
selectDevice(device);
}
Expand Down
Loading