@@ -20,42 +20,46 @@ const getAllWindows = async (): Promise<chrome.windows.Window[]> => {
2020} ;
2121
2222export const windowsAll = ( ) => {
23- getActiveWindow ( ) . then ( window => {
24- const id = window ?. id ;
25- const left = window ?. left ;
26- const top = window ?. top ;
27- const width = window ?. width ;
28- const height = window ?. height ;
29- const state = window ?. state ;
30- const type = window ?. type ;
31- const focused = window ?. focused ;
32- const tabs = window ?. tabs ;
33- tabsAll ( tabs ?? [ ] ) ;
34- const data = {
35- logic : 'window_actived' ,
36- window : { id, left, top, width, height, state, type, focused } ,
37- } ;
38- ws ?. send ( JSON . stringify ( data ) ) ;
39- } ) ;
40- getAllWindows ( ) . then ( windows => {
41- const data = {
42- logic : 'windows_all' ,
43- windows : windows . map ( window => {
44- const id = window . id ;
45- const left = window . left ;
46- const top = window . top ;
47- const width = window . width ;
48- const height = window . height ;
49- const state = window . state ;
50- const type = window . type ;
51- const focused = window . focused ;
52- const tabs = window . tabs ;
53- tabsAll ( tabs ?? [ ] ) ;
54- return { id, left, top, width, height, state, type, focused, tabs } ;
55- } ) ,
56- } ;
57- ws ?. send ( JSON . stringify ( data ) ) ;
58- } ) ;
23+ try {
24+ getActiveWindow ( ) . then ( window => {
25+ const id = window ?. id ;
26+ const left = window ?. left ;
27+ const top = window ?. top ;
28+ const width = window ?. width ;
29+ const height = window ?. height ;
30+ const state = window ?. state ;
31+ const type = window ?. type ;
32+ const focused = window ?. focused ;
33+ const tabs = window ?. tabs ;
34+ tabsAll ( tabs ?? [ ] ) ;
35+ const data = {
36+ logic : 'window_actived' ,
37+ window : { id, left, top, width, height, state, type, focused } ,
38+ } ;
39+ ws ?. send ( JSON . stringify ( data ) ) ;
40+ } ) ;
41+ getAllWindows ( ) . then ( windows => {
42+ const data = {
43+ logic : 'windows_all' ,
44+ windows : windows . map ( window => {
45+ const id = window . id ;
46+ const left = window . left ;
47+ const top = window . top ;
48+ const width = window . width ;
49+ const height = window . height ;
50+ const state = window . state ;
51+ const type = window . type ;
52+ const focused = window . focused ;
53+ const tabs = window . tabs ;
54+ tabsAll ( tabs ?? [ ] ) ;
55+ return { id, left, top, width, height, state, type, focused, tabs } ;
56+ } ) ,
57+ } ;
58+ ws ?. send ( JSON . stringify ( data ) ) ;
59+ } ) ;
60+ } catch ( error ) {
61+ console . error ( 'Error getting all windows:' , error ) ;
62+ }
5963} ;
6064
6165const _onCreated = ( window : chrome . windows . Window ) => {
0 commit comments