feat(KAN-70): integrate native workspace and update settings
CI/CD / preconditions (pull_request) Successful in 1s
Native JavaScript checks / Native launcher and release tests (pull_request) Successful in 1m2s
macOS checks / Native Rust tests and unsigned build (pull_request) Successful in 1m38s
CI/CD / test_and_check_app (pull_request) Successful in 6m47s
CI/CD / Publish immutable image (pull_request) Skipped
CI/CD / preconditions (pull_request) Successful in 1s
Native JavaScript checks / Native launcher and release tests (pull_request) Successful in 1m2s
macOS checks / Native Rust tests and unsigned build (pull_request) Successful in 1m38s
CI/CD / test_and_check_app (pull_request) Successful in 6m47s
CI/CD / Publish immutable image (pull_request) Skipped
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import type { NativeAppState, NativeUpdates } from '@/types/native-app';
|
||||
|
||||
export function isNativeAppState(value: unknown): value is NativeAppState {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return false;
|
||||
}
|
||||
const state = value as NativeAppState;
|
||||
if (
|
||||
state.apiVersion !== 1 ||
|
||||
!['macos', 'ios'].includes(state.platform) ||
|
||||
typeof state.version !== 'string' ||
|
||||
typeof state.workspace !== 'string' ||
|
||||
!Array.isArray(state.capabilities) ||
|
||||
!state.capabilities.includes('workspace')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if (new URL(state.workspace).protocol !== 'https:') {
|
||||
return false;
|
||||
}
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
if (!state.capabilities.includes('updates')) {
|
||||
return state.updates === undefined;
|
||||
}
|
||||
if (state.platform !== 'macos' || !state.updates) {
|
||||
return false;
|
||||
}
|
||||
const updates = state.updates;
|
||||
return (
|
||||
[
|
||||
'idle',
|
||||
'checking',
|
||||
'available',
|
||||
'current',
|
||||
'downloading',
|
||||
'verifying',
|
||||
'installing',
|
||||
'restarting',
|
||||
'error',
|
||||
].includes(updates.phase) &&
|
||||
typeof updates.currentVersion === 'string' &&
|
||||
typeof updates.build === 'string' &&
|
||||
(updates.version === null || typeof updates.version === 'string') &&
|
||||
(updates.notes === null || typeof updates.notes === 'string') &&
|
||||
(updates.error === null || typeof updates.error === 'string') &&
|
||||
Number.isFinite(updates.downloaded) &&
|
||||
updates.downloaded >= 0 &&
|
||||
(updates.total === null ||
|
||||
(Number.isFinite(updates.total) && updates.total >= 0)) &&
|
||||
typeof updates.preferences?.automatic === 'boolean' &&
|
||||
[1, 6, 24].includes(updates.preferences.intervalHours)
|
||||
);
|
||||
}
|
||||
|
||||
export function updateIsBusy(updates?: NativeUpdates): boolean {
|
||||
return (
|
||||
!!updates &&
|
||||
[
|
||||
'checking',
|
||||
'downloading',
|
||||
'verifying',
|
||||
'installing',
|
||||
'restarting',
|
||||
].includes(updates.phase)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user