@hatiolab/things-scene 3.4.46 → 3.4.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/monitor-extension/background.js +21 -0
- package/monitor-extension/content.js +71 -0
- package/monitor-extension/devtools.html +68 -0
- package/monitor-extension/devtools.js +143 -0
- package/monitor-extension/icons/icon128.png +0 -0
- package/monitor-extension/icons/icon16.png +0 -0
- package/monitor-extension/icons/icon48.png +0 -0
- package/monitor-extension/injected.js +25 -0
- package/monitor-extension/libs/Chart.min.js +10129 -0
- package/monitor-extension/manifest.json +34 -0
- package/monitor-extension/popup.html +68 -0
- package/monitor-extension/popup.js +142 -0
- package/package.json +1 -1
- package/things-scene-ie.js +1 -1
- package/things-scene-min.js +1 -1
- package/things-scene.mjs +4 -4
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "Scene",
|
|
4
|
+
"version": "1.0",
|
|
5
|
+
"description": "Monitoring extention for Things Scene",
|
|
6
|
+
"permissions": ["activeTab", "scripting", "storage"],
|
|
7
|
+
"action": {
|
|
8
|
+
"default_popup": "popup.html",
|
|
9
|
+
"default_icon": {
|
|
10
|
+
"16": "icons/icon16.png",
|
|
11
|
+
"48": "icons/icon48.png",
|
|
12
|
+
"128": "icons/icon128.png"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"background": {
|
|
16
|
+
"service_worker": "background.js"
|
|
17
|
+
},
|
|
18
|
+
"devtools_page": "devtools.html",
|
|
19
|
+
"content_scripts": [
|
|
20
|
+
{
|
|
21
|
+
"matches": ["<all_urls>"],
|
|
22
|
+
"js": ["content.js"]
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"web_accessible_resources": [
|
|
26
|
+
{
|
|
27
|
+
"resources": ["injected.js", "lib/chart.min.js"],
|
|
28
|
+
"matches": ["<all_urls>"]
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"content_security_policy": {
|
|
32
|
+
"extension_pages": "script-src 'self'; object-src 'self'"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Component Residents Monitor</title>
|
|
7
|
+
<script src="libs/chart.min.js"></script>
|
|
8
|
+
<script src="popup.js"></script>
|
|
9
|
+
|
|
10
|
+
<style>
|
|
11
|
+
body {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: 10px;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
min-width: 400px;
|
|
18
|
+
min-height: 800px;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
canvas {
|
|
23
|
+
flex: 1;
|
|
24
|
+
border: 1px solid #000;
|
|
25
|
+
border-radius: 4px;
|
|
26
|
+
width: 100%;
|
|
27
|
+
max-height: 200px;
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
table {
|
|
32
|
+
flex: 1;
|
|
33
|
+
width: 100%;
|
|
34
|
+
border-collapse: collapse;
|
|
35
|
+
margin-top: 20px;
|
|
36
|
+
overflow: auto;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
th,
|
|
40
|
+
td {
|
|
41
|
+
padding: 8px;
|
|
42
|
+
text-align: left;
|
|
43
|
+
border-bottom: 1px solid #ddd;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
th {
|
|
47
|
+
background-color: #f2f2f2;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
50
|
+
</head>
|
|
51
|
+
<body>
|
|
52
|
+
<h1>Component Residents Monitor</h1>
|
|
53
|
+
<canvas id="residentChart1"></canvas>
|
|
54
|
+
<canvas id="residentChart2"></canvas>
|
|
55
|
+
<canvas id="residentChart3"></canvas>
|
|
56
|
+
|
|
57
|
+
<!-- sceneResidents 데이터를 보여줄 테이블 -->
|
|
58
|
+
<h2>Scene Residents Data</h2>
|
|
59
|
+
<table id="residentsTable">
|
|
60
|
+
<tr>
|
|
61
|
+
<th>Type</th>
|
|
62
|
+
<th>Up</th>
|
|
63
|
+
<th>Down</th>
|
|
64
|
+
<th>Difference (Up - Down)</th>
|
|
65
|
+
</tr>
|
|
66
|
+
</table>
|
|
67
|
+
</body>
|
|
68
|
+
</html>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
2
|
+
let residentChart1, residentChart2, residentChart3, residentsTable
|
|
3
|
+
let chartsInitialized = false
|
|
4
|
+
let listenerRegistered = false
|
|
5
|
+
|
|
6
|
+
// 현재 활성 탭의 tabId 가져오기
|
|
7
|
+
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
|
|
8
|
+
if (tabs.length === 0) {
|
|
9
|
+
console.error('No active tab found.')
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const tabId = tabs[0].id
|
|
14
|
+
|
|
15
|
+
// 차트 생성 함수
|
|
16
|
+
const createChart = (ctx, label) => {
|
|
17
|
+
return new Chart(ctx, {
|
|
18
|
+
type: 'bar', // Bar chart
|
|
19
|
+
data: {
|
|
20
|
+
labels: [], // X축 라벨을 비워둠으로써 시리즈명을 숨김
|
|
21
|
+
datasets: [
|
|
22
|
+
{
|
|
23
|
+
label: label, // 데이터셋의 레이블 (범례로 표시되지 않음)
|
|
24
|
+
data: [], // 실제 데이터
|
|
25
|
+
backgroundColor: 'rgba(75, 192, 192, 0.5)', // 막대의 색상
|
|
26
|
+
borderColor: 'rgba(75, 192, 192, 1)', // 막대의 테두리 색상
|
|
27
|
+
borderWidth: 1 // 막대의 테두리 두께
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
options: {
|
|
32
|
+
responsive: true,
|
|
33
|
+
animation: false, // 애니메이션 비활성화
|
|
34
|
+
scales: {
|
|
35
|
+
x: {
|
|
36
|
+
display: false, // X축 숨기기 (전체)
|
|
37
|
+
grid: {
|
|
38
|
+
display: false // X축의 격자선 숨기기
|
|
39
|
+
},
|
|
40
|
+
ticks: {
|
|
41
|
+
display: false // X축 틱 마크 숨기기
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
y: {
|
|
45
|
+
beginAtZero: true, // Y축이 0에서 시작되도록 설정
|
|
46
|
+
title: {
|
|
47
|
+
display: true,
|
|
48
|
+
text: label // Y축의 레이블
|
|
49
|
+
},
|
|
50
|
+
ticks: {
|
|
51
|
+
stepSize: 1
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
plugins: {
|
|
56
|
+
legend: {
|
|
57
|
+
display: false // 범례 숨기기
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 차트가 초기화되지 않았을 때만 차트 생성
|
|
65
|
+
if (!chartsInitialized) {
|
|
66
|
+
const ctx1 = document.getElementById('residentChart1').getContext('2d')
|
|
67
|
+
const ctx2 = document.getElementById('residentChart2').getContext('2d')
|
|
68
|
+
const ctx3 = document.getElementById('residentChart3').getContext('2d')
|
|
69
|
+
|
|
70
|
+
residentChart1 = createChart(ctx1, 'Component Residents Count')
|
|
71
|
+
residentChart2 = createChart(ctx2, 'Scene Residents Count')
|
|
72
|
+
residentChart3 = createChart(ctx3, 'ReferenceMap Residents Count')
|
|
73
|
+
|
|
74
|
+
residentsTable = window.document.getElementById('residentsTable')
|
|
75
|
+
|
|
76
|
+
chartsInitialized = true // 차트가 초기화되었음을 표시
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 차트 업데이트 함수
|
|
80
|
+
const updateCharts = ({ sceneResidents, history }) => {
|
|
81
|
+
residentChart1.data.labels = history.map(entry => entry.timestamp)
|
|
82
|
+
residentChart1.data.datasets[0].data = history.map(entry => entry.componentResidentsCount)
|
|
83
|
+
residentChart1.update()
|
|
84
|
+
|
|
85
|
+
residentChart2.data.labels = history.map(entry => entry.timestamp)
|
|
86
|
+
residentChart2.data.datasets[0].data = history.map(entry => entry.sceneResidentsCount)
|
|
87
|
+
residentChart2.update()
|
|
88
|
+
|
|
89
|
+
residentChart3.data.labels = history.map(entry => entry.timestamp)
|
|
90
|
+
residentChart3.data.datasets[0].data = history.map(entry => entry.referenceMapResidentsCount)
|
|
91
|
+
residentChart3.update()
|
|
92
|
+
|
|
93
|
+
updateResidentsTable(sceneResidents)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// sceneResidents 테이블 업데이트 함수
|
|
97
|
+
const updateResidentsTable = sceneResidents => {
|
|
98
|
+
if (typeof sceneResidents !== 'object') {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const table = residentsTable
|
|
103
|
+
table.innerHTML = '' // 기존 테이블 내용을 지움
|
|
104
|
+
|
|
105
|
+
// 테이블 헤더 생성
|
|
106
|
+
const headerRow = document.createElement('tr')
|
|
107
|
+
headerRow.innerHTML = '<th>Type</th><th>Up</th><th>Down</th><th>Difference (Up - Down)</th>'
|
|
108
|
+
table.appendChild(headerRow)
|
|
109
|
+
|
|
110
|
+
// sceneResidents 데이터로 테이블 행 생성
|
|
111
|
+
for (const [type, residents] of Object.entries(sceneResidents)) {
|
|
112
|
+
const { up, down } = residents
|
|
113
|
+
const row = document.createElement('tr')
|
|
114
|
+
const difference = up - down
|
|
115
|
+
row.innerHTML = `<td>${type}</td><td>${up}</td><td>${down}</td><td>${difference}</td>`
|
|
116
|
+
|
|
117
|
+
table.appendChild(row)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 저장된 데이터 가져오기 및 초기 로딩
|
|
122
|
+
chrome.storage.local.get({ residentData: {} }, result => {
|
|
123
|
+
const residentData = result.residentData
|
|
124
|
+
|
|
125
|
+
if (residentData[tabId] && residentData[tabId].length > 0) {
|
|
126
|
+
updateCharts(residentData[tabId])
|
|
127
|
+
} else {
|
|
128
|
+
console.log('No resident data found for this tab.')
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
// 메시지 리스너 중복 등록 방지
|
|
133
|
+
if (!listenerRegistered) {
|
|
134
|
+
chrome.runtime.onMessage.addListener(message => {
|
|
135
|
+
if (message.type === 'UPDATE_CHART' && message.tabId === tabId) {
|
|
136
|
+
updateCharts(message.data)
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
listenerRegistered = true // 리스너가 등록되었음을 표시
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
})
|