Skip to content

Commit

Permalink
Merge branch 'release/1.12.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphiiko committed Apr 6, 2024
2 parents 4fe8cd6 + ef765f3 commit f506d9b
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 67 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.12.6]

### Changed
- Improved initialization

## [1.12.5]

### Added
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oyasumi",
"version": "1.12.5",
"version": "1.12.6",
"author": "Raphiiko",
"license": "MIT",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions src-core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oyasumivr"
version = "1.12.5"
version = "1.12.6"
description = ""
authors = ["Raphiiko"]
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions src-core/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"package": {
"productName": "OyasumiVR",
"version": "1.12.5"
"version": "1.12.6"
},
"tauri": {
"allowlist": {
Expand Down Expand Up @@ -188,7 +188,7 @@
"center": true,
"theme": "Dark",
"transparent": true,
"userAgent": "OyasumiVR/1.12.5 (https://github.com/Raphiiko/OyasumiVR)"
"userAgent": "OyasumiVR/1.12.6 (https://github.com/Raphiiko/OyasumiVR)"
},
{
"width": 700,
Expand All @@ -200,7 +200,7 @@
"center": true,
"theme": "Dark",
"transparent": true,
"userAgent": "OyasumiVR/1.12.5 (https://github.com/Raphiiko/OyasumiVR)"
"userAgent": "OyasumiVR/1.12.6 (https://github.com/Raphiiko/OyasumiVR)"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion src-elevated-sidecar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oyasumivr-elevated-sidecar"
version = "1.12.5"
version = "1.12.6"
authors = ["Raphiiko"]
license = "MIT"
edition = "2021"
Expand Down
4 changes: 2 additions & 2 deletions src-overlay-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-overlay-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oyasumivr-overlay-ui",
"version": "1.12.5",
"version": "1.12.6",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
2 changes: 1 addition & 1 deletion src-shared-rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oyasumivr-shared"
version = "1.12.5"
version = "1.12.6"
authors = ["Raphiiko"]
edition = "2021"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src-shared-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "src-shared-ts",
"description": "Shared typescript code for Oyasumi modules",
"scripts": {},
"version": "1.12.5",
"version": "1.12.6",
"author": "Raphiiko",
"license": "MIT",
"type": "module",
Expand Down
88 changes: 52 additions & 36 deletions src-ui/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,12 @@ export class AppModule {
}

private async logInit<T>(action: string, promise: Promise<T>): Promise<T> {
const TIMEOUT = 10000;
if (FLAVOUR === 'DEV') console.log(`[Init] Running ${action}`);
try {
const result = await pTimeout<T>(
promise,
6000,
TIMEOUT,
new Error(`Initialization function ${action} timed out.`)
);
if (FLAVOUR === 'DEV') info(`[Init] '${action}' ran successfully`);
Expand All @@ -450,9 +451,11 @@ export class AppModule {
this.developerDebugService.init()
);
// Clean cache
await this.logInit('cache clean', CachedValue.cleanCache());
await this.logInit('cache clean', CachedValue.cleanCache())
.catch(() => {}); // Allow initialization to continue if failed
// Preload assets
await this.logInit('asset preload', this.preloadAssets());
await this.logInit('asset preload', this.preloadAssets())
.catch(() => {}); // Allow initialization to continue if failed
// Initialize base utilities
await Promise.all([
this.logInit('AppSettingsService initialization', this.appSettingsService.init()),
Expand Down Expand Up @@ -720,43 +723,56 @@ export class AppModule {
}
try {
await Promise.all(
preloadAssets.imageUrls.map((imageUrl) => {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => {
debug('Preloaded asset: ' + imageUrl);
resolve(void 0);
};
img.onerror = (
event: Event | string,
source?: string,
lineno?: number,
colno?: number,
_error?: Error
) => {
warn(
`[Init] Could not load image (${imageUrl}): ${JSON.stringify({
event,
source,
lineno,
colno,
error: _error,
})}`
);
if (imageUrl.startsWith('http')) {
// Preloading of remote assets is allowed to fail
resolve(void 0);
} else {
reject({ event, source, lineno, colno, error: _error });
}
};
img.src = imageUrl;
});
})
preloadAssets.imageUrls.map((imageUrl) => this.preloadImageAsset(imageUrl))
);
} catch (e) {
error(`[Init] Failed to preload assets: (Could not load images) ${JSON.stringify(e)}`);
throw e;
}
}

private async preloadImageAsset(imageUrl: string) {
const TIMEOUT = 8000;
const TIMEOUT_ERR = 'TIMEOUT_REACHED';
try {
await pTimeout(
new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => {
debug('Preloaded asset: ' + imageUrl);
resolve(void 0);
};
img.onerror = (
event: Event | string,
source?: string,
lineno?: number,
colno?: number,
_error?: Error
) => {
warn(
`[Init] Could not load image (${imageUrl}): ${JSON.stringify({
event,
source,
lineno,
colno,
error: _error,
})}`
);
if (imageUrl.startsWith('http')) {
// Preloading of remote assets is allowed to fail
resolve(void 0);
} else {
reject({ event, source, lineno, colno, error: _error });
}
};
img.src = imageUrl;
}),
TIMEOUT,
TIMEOUT_ERR
);
} catch (e) {
if (e === TIMEOUT_ERR) return; // Preload timeouts are acceptable
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ export class HardwareBrightnessControlService {
force = false
) {
const opt = { ...SET_BRIGHTNESS_OPTIONS_DEFAULTS, ...(options ?? {}) };
if (!(await firstValueFrom(this.driverIsAvailable))) return;
const driver = await firstValueFrom(this.driver);
if (!driver) return;
if (opt.cancelActiveTransition) this.cancelActiveTransition();
if (!force && percentage == this.brightness) return;
this._brightness.next(percentage);
await this.driver.value!.setBrightnessPercentage(percentage);
await driver.setBrightnessPercentage(percentage);
if (opt.logReason) {
await info(
`[BrightnessControl] Set hardware brightness to ${percentage}% (Reason: ${opt.logReason})`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class BigscreenBeyondHardwareBrightnessControlDriver extends HardwareBrig
}

async setBrightnessPercentage(percentage: number): Promise<void> {
if (!this.connected.value) return;
const hwPercentage = this.softwarePercentageToHardwarePercentage(percentage);
this.lastSetBrightnessPercentage = percentage;
const hwValue = this.swValueToHWValue(hwPercentage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class BigscreenBeyondLedAutomationService {
const frequency = 30;
const startTime = Date.now();
const startColor = [...this.lastSetColor];
while (Date.now() <= startTime + duration) {
while (Date.now() <= startTime + duration && this.connected.value) {
// Sleep to match the frequency
await new Promise((resolve) => setTimeout(resolve, 1000 / frequency));
// Stop if the transition was cancelled
Expand All @@ -125,20 +125,24 @@ export class BigscreenBeyondLedAutomationService {
Math.round(smoothLerp(startColor[2], targetColor[2], progress)),
];
// Set the intermediary color
if (this.connected.value) {
invoke('bigscreen_beyond_set_led_color', {
r: color[0],
g: color[1],
b: color[2],
});
this.lastSetColor = [...color];
}
}
// Set the final target color
if (this.connected.value) {
invoke('bigscreen_beyond_set_led_color', {
r: color[0],
g: color[1],
b: color[2],
r: targetColor[0],
g: targetColor[1],
b: targetColor[2],
});
this.lastSetColor = [...color];
this.lastSetColor = [...targetColor];
}
// Set the final target color
invoke('bigscreen_beyond_set_led_color', {
r: targetColor[0],
g: targetColor[1],
b: targetColor[2],
});
this.lastSetColor = [...targetColor];
});
await this.transitionTask.start();
}
Expand Down
2 changes: 1 addition & 1 deletion src-ui/app/utils/promise-utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function pTimeout<T>(
promise: Promise<T>,
timeoutMs: number,
timeoutError = new Error('Promise timed out')
timeoutError: any = new Error('Promise timed out')
): Promise<T> {
const timeout = new Promise((_, reject) => {
setTimeout(() => {
Expand Down

0 comments on commit f506d9b

Please sign in to comment.