change: security-check, memory-check [untest]
- fix high risk security issues - fix high memory usage - change adb to connection pool single instance Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
parent
f0619c5a10
commit
4f464a8513
23 changed files with 413 additions and 73 deletions
|
|
@ -11,6 +11,7 @@
|
|||
import { auth } from '$lib/core/stores/auth';
|
||||
import { connectToWebsocket } from '$lib/core/stores/websocketStore';
|
||||
import * as adb from '$lib/core/adb/adb';
|
||||
import { adbConnectionStatus } from '$lib/core/stores/adbConnectionStore';
|
||||
import { addNotification } from '$lib/core/stores/noti';
|
||||
import { page } from '$app/stores';
|
||||
import {
|
||||
|
|
@ -117,7 +118,7 @@
|
|||
|
||||
if (adbReconnectTriedForUid !== currentUser.uid && !adb.getAdbInstance()) {
|
||||
adbReconnectTriedForUid = currentUser.uid;
|
||||
// void tryAutoConnect();
|
||||
void tryAutoConnect();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
import ArrowRight from '@lucide/svelte/icons/arrow-right';
|
||||
import { permission as currentPermissions } from '$lib/core/stores/permissions';
|
||||
import { get } from 'svelte/store';
|
||||
import { onMount } from 'svelte';
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { referenceFromPage} from '$lib/core/stores/recipeStore';
|
||||
|
||||
let recipeModBtn = $state<HTMLElement | null>(null);
|
||||
|
|
@ -23,7 +23,11 @@
|
|||
|
||||
let perms = $state<string[]>([]);
|
||||
|
||||
setInterval(() => {
|
||||
// Wait for the goto-dashboard button to be mounted, then start a pulse
|
||||
// animation once. Use an interval so we can react to the $state element
|
||||
// being set after the initial render; stop polling as soon as the
|
||||
// animation has been started.
|
||||
const _pulseInterval = setInterval(() => {
|
||||
if (gotoDashboardBtn && !animationPulseGoto) {
|
||||
animationPulseGoto = animate(gotoDashboardBtn, {
|
||||
opacity: [0.8, 1], // Slight pulse in opacity
|
||||
|
|
@ -37,6 +41,10 @@
|
|||
}
|
||||
}, 1000);
|
||||
|
||||
onDestroy(() => {
|
||||
clearInterval(_pulseInterval);
|
||||
});
|
||||
|
||||
// let perms = get(currentPermissions);
|
||||
|
||||
onMount(() => {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
import Checkbox from '$lib/components/ui/checkbox/checkbox.svelte';
|
||||
import Spinner from '$lib/components/ui/spinner/spinner.svelte';
|
||||
import * as adb from '$lib/core/adb/adb';
|
||||
import { adbConnectionStatus } from '$lib/core/stores/adbConnectionStore';
|
||||
import { addNotification } from '$lib/core/stores/noti';
|
||||
import { referenceFromPage } from '$lib/core/stores/recipeStore';
|
||||
import type { Material } from '$lib/models/material.model';
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
import Checkbox from '$lib/components/ui/checkbox/checkbox.svelte';
|
||||
import Spinner from '$lib/components/ui/spinner/spinner.svelte';
|
||||
import * as adb from '$lib/core/adb/adb';
|
||||
import { adbConnectionStatus } from '$lib/core/stores/adbConnectionStore';
|
||||
import { addNotification } from '$lib/core/stores/noti';
|
||||
import { referenceFromPage } from '$lib/core/stores/recipeStore';
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
import { onMount, onDestroy } from 'svelte';
|
||||
|
||||
import * as adb from '$lib/core/adb/adb';
|
||||
import { adbConnectionStatus } from '$lib/core/stores/adbConnectionStore';
|
||||
import { addNotification } from '$lib/core/stores/noti';
|
||||
import { columns, type RecipeOverview } from '../../recipe/overview/columns';
|
||||
import {
|
||||
|
|
@ -72,7 +73,7 @@
|
|||
|
||||
// clear out event
|
||||
|
||||
GlobalEventBus.on('recipe-event', (d: any) => {
|
||||
const unsubRecipeEvent = GlobalEventBus.on('recipe-event', (d: any) => {
|
||||
logger.info('[recipe-ev] get event: ', d);
|
||||
if (d?.type == 'load-recipe' && d?.status == 'end') {
|
||||
addNotification('INFO:Get data, waiting for reloading ...');
|
||||
|
|
@ -829,6 +830,7 @@
|
|||
});
|
||||
|
||||
onDestroy(() => {
|
||||
unsubRecipeEvent();
|
||||
clearOnMenuSavedCallback();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
import { goto } from '$app/navigation';
|
||||
|
||||
import * as adb from '$lib/core/adb/adb';
|
||||
import { adbConnectionStatus } from '$lib/core/stores/adbConnectionStore';
|
||||
import { addNotification } from '$lib/core/stores/noti';
|
||||
import { referenceFromPage } from '$lib/core/stores/recipeStore';
|
||||
import { env } from '$env/dynamic/public';
|
||||
|
|
@ -295,21 +296,12 @@
|
|||
|
||||
async function connectAdb() {
|
||||
try {
|
||||
if (adb.getAdbInstance()) {
|
||||
const connected = await adb.ensureAdbConnection();
|
||||
if (connected) {
|
||||
if (!isAdbWriterAvailable()) {
|
||||
await adb.reconnectAndroidRecipeMenuServer();
|
||||
}
|
||||
await loadRecipeFromMachine();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!('usb' in navigator)) {
|
||||
throw new Error('WebUSB not supported');
|
||||
}
|
||||
|
||||
await adb.connectRecipeMenuViaWebUSB();
|
||||
if (adb.getAdbInstance()) {
|
||||
await loadRecipeFromMachine();
|
||||
}
|
||||
} catch (e: any) {
|
||||
addNotification(`ERROR:${e}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue