@hatiolab/things-scene 3.4.45 → 3.4.47
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/db.sqlite +0 -0
- package/monitor-extension/background.js +21 -0
- package/monitor-extension/content.js +65 -0
- package/monitor-extension/devtools.html +35 -0
- package/monitor-extension/devtools.js +113 -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 +28 -0
- package/monitor-extension/libs/Chart.min.js +10129 -0
- package/monitor-extension/manifest.json +34 -0
- package/monitor-extension/popup.html +37 -0
- package/monitor-extension/popup.js +112 -0
- package/package.json +1 -1
- package/things-scene-ie.js +1 -1
- package/things-scene-min.js +1 -1
- package/things-scene.mjs +1 -1
- package/schema.graphql +0 -3966
package/db.sqlite
CHANGED
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
2
|
+
if (message.type === 'GET_TAB_INFO') {
|
|
3
|
+
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
|
|
4
|
+
if (chrome.runtime.lastError) {
|
|
5
|
+
console.error('Error querying tabs:', chrome.runtime.lastError)
|
|
6
|
+
sendResponse({ tabId: null })
|
|
7
|
+
return
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (tabs.length > 0) {
|
|
11
|
+
sendResponse({ tabId: tabs[0].id })
|
|
12
|
+
} else {
|
|
13
|
+
console.log('No active tab found.')
|
|
14
|
+
sendResponse({ tabId: null })
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
// 비동기 응답을 위해 true 반환
|
|
19
|
+
return true
|
|
20
|
+
}
|
|
21
|
+
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// content.js
|
|
2
|
+
|
|
3
|
+
// 백그라운드 스크립트에 탭 정보를 요청
|
|
4
|
+
chrome.runtime.sendMessage({ type: 'GET_TAB_INFO' }, response => {
|
|
5
|
+
if (response && response.tabId) {
|
|
6
|
+
const tabId = response.tabId
|
|
7
|
+
|
|
8
|
+
function updateChart(data) {
|
|
9
|
+
chrome.runtime.sendMessage({ type: 'UPDATE_CHART', tabId, data })
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
window.addEventListener('message', function (event) {
|
|
13
|
+
if (event.source !== window || !event.data.type) return
|
|
14
|
+
|
|
15
|
+
if (event.data.type === 'RESIDENT_COUNT') {
|
|
16
|
+
const { timestamp, componentResidentsCount, sceneResidentsCount, referenceMapResidentsCount } = event.data
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
chrome.storage.local.get({ residentData: {} }, result => {
|
|
20
|
+
const residentData = result.residentData || {}
|
|
21
|
+
residentData[tabId] = residentData[tabId] || []
|
|
22
|
+
|
|
23
|
+
residentData[tabId].push({
|
|
24
|
+
timestamp,
|
|
25
|
+
componentResidentsCount,
|
|
26
|
+
sceneResidentsCount,
|
|
27
|
+
referenceMapResidentsCount
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// 데이터가 100개 이상일 경우 오래된 데이터 삭제
|
|
31
|
+
if (residentData[tabId].length > 100) {
|
|
32
|
+
residentData[tabId].shift()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
chrome.storage.local.set({ residentData }, () => {
|
|
36
|
+
try {
|
|
37
|
+
updateChart(residentData[tabId])
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error('Error updating chart:', e)
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.error('Error accessing storage:', e)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// 스크립트를 인젝션하는 함수
|
|
50
|
+
function injectScript(file) {
|
|
51
|
+
if (!document.getElementById(file)) {
|
|
52
|
+
const th = document.head
|
|
53
|
+
const s = document.createElement('script')
|
|
54
|
+
s.setAttribute('type', 'text/javascript')
|
|
55
|
+
s.setAttribute('src', chrome.runtime.getURL(file))
|
|
56
|
+
s.setAttribute('id', file) // 중복 인젝션 방지
|
|
57
|
+
th.appendChild(s)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
injectScript('injected.js')
|
|
62
|
+
} else {
|
|
63
|
+
console.error('No active tab found.')
|
|
64
|
+
}
|
|
65
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
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="devtools.js"></script>
|
|
9
|
+
<style>
|
|
10
|
+
body {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: 10px;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
min-width: 400px;
|
|
17
|
+
min-height: 800px;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
}
|
|
20
|
+
canvas {
|
|
21
|
+
flex: 1;
|
|
22
|
+
border: 1px solid #000;
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
width: 100%;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<h1>Component Residents Monitor</h1>
|
|
31
|
+
<canvas id="residentChart1"></canvas>
|
|
32
|
+
<canvas id="residentChart2"></canvas>
|
|
33
|
+
<canvas id="residentChart3"></canvas>
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
chrome.devtools.panels.create('Scene', 'icons/icon48.png', 'devtools.html', function (panel) {
|
|
2
|
+
var residentChart1, residentChart2, residentChart3
|
|
3
|
+
var listenerRegistered = false
|
|
4
|
+
var chartsInitialized = false
|
|
5
|
+
|
|
6
|
+
// 차트 업데이트 함수
|
|
7
|
+
const updateCharts = data => {
|
|
8
|
+
residentChart1.data.labels = data.map(entry => entry.timestamp)
|
|
9
|
+
residentChart1.data.datasets[0].data = data.map(entry => entry.componentResidentsCount)
|
|
10
|
+
residentChart1.update()
|
|
11
|
+
|
|
12
|
+
residentChart2.data.labels = data.map(entry => entry.timestamp)
|
|
13
|
+
residentChart2.data.datasets[0].data = data.map(entry => entry.sceneResidentsCount)
|
|
14
|
+
residentChart2.update()
|
|
15
|
+
|
|
16
|
+
residentChart3.data.labels = data.map(entry => entry.timestamp)
|
|
17
|
+
residentChart3.data.datasets[0].data = data.map(entry => entry.referenceMapResidentsCount)
|
|
18
|
+
residentChart3.update()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 차트 초기화 함수
|
|
22
|
+
const resetCharts = window => {
|
|
23
|
+
const createChart = (ctx, label) => {
|
|
24
|
+
return new Chart(ctx, {
|
|
25
|
+
type: 'bar', // Bar chart
|
|
26
|
+
data: {
|
|
27
|
+
labels: [], // X축 라벨을 비워둠으로써 시리즈명을 숨김
|
|
28
|
+
datasets: [
|
|
29
|
+
{
|
|
30
|
+
label: label, // 데이터셋의 레이블 (범례로 표시되지 않음)
|
|
31
|
+
data: [], // 실제 데이터
|
|
32
|
+
backgroundColor: 'rgba(75, 192, 192, 0.5)', // 막대의 색상
|
|
33
|
+
borderColor: 'rgba(75, 192, 192, 1)', // 막대의 테두리 색상
|
|
34
|
+
borderWidth: 1 // 막대의 테두리 두께
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
options: {
|
|
39
|
+
animation: false, // 애니메이션 비활성화
|
|
40
|
+
scales: {
|
|
41
|
+
x: {
|
|
42
|
+
display: false, // X축 숨기기 (전체)
|
|
43
|
+
grid: {
|
|
44
|
+
display: false // X축의 격자선 숨기기
|
|
45
|
+
},
|
|
46
|
+
ticks: {
|
|
47
|
+
display: false // X축 틱 마크 숨기기
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
y: {
|
|
51
|
+
beginAtZero: true, // Y축이 0에서 시작되도록 설정
|
|
52
|
+
title: {
|
|
53
|
+
display: true,
|
|
54
|
+
text: label // Y축의 레이블
|
|
55
|
+
},
|
|
56
|
+
ticks: {
|
|
57
|
+
stepSize: 1
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
plugins: {
|
|
62
|
+
legend: {
|
|
63
|
+
display: false // 범례 숨기기
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const ctx1 = window.document.getElementById('residentChart1').getContext('2d')
|
|
71
|
+
const ctx2 = window.document.getElementById('residentChart2').getContext('2d')
|
|
72
|
+
const ctx3 = window.document.getElementById('residentChart3').getContext('2d')
|
|
73
|
+
|
|
74
|
+
residentChart1 = createChart(ctx1, 'Component Residents Count')
|
|
75
|
+
residentChart2 = createChart(ctx2, 'Scene Residents Count')
|
|
76
|
+
residentChart3 = createChart(ctx3, 'ReferenceMap Residents Count')
|
|
77
|
+
|
|
78
|
+
chartsInitialized = true
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 패널이 처음 열리거나 다시 열릴 때마다 호출
|
|
82
|
+
panel.onShown.addListener(function (window) {
|
|
83
|
+
console.log('DevTools panel shown')
|
|
84
|
+
panelWindow = window
|
|
85
|
+
resetCharts(window) // 패널이 열릴 때 차트를 초기화
|
|
86
|
+
|
|
87
|
+
// 초기 로딩 시 저장된 데이터를 가져옴
|
|
88
|
+
chrome.storage.local.get({ residentData: {} }, result => {
|
|
89
|
+
const tabId = chrome.devtools.inspectedWindow.tabId
|
|
90
|
+
if (tabId && result.residentData[tabId] && result.residentData[tabId].length > 0) {
|
|
91
|
+
updateCharts(result.residentData[tabId])
|
|
92
|
+
} else {
|
|
93
|
+
console.log('No resident data found.')
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
// 메시지 리스너는 한 번만 등록 (중복 방지)
|
|
99
|
+
if (!listenerRegistered) {
|
|
100
|
+
chrome.runtime.onMessage.addListener(message => {
|
|
101
|
+
const tabId = chrome.devtools.inspectedWindow.tabId
|
|
102
|
+
|
|
103
|
+
if (tabId && message.type === 'UPDATE_CHART' && message.tabId === tabId) {
|
|
104
|
+
chrome.storage.local.get({ residentData: {} }, result => {
|
|
105
|
+
if (chartsInitialized && result.residentData[tabId]) {
|
|
106
|
+
updateCharts(result.residentData[tabId])
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
listenerRegistered = true // 리스너가 중복 등록되지 않도록 설정
|
|
112
|
+
}
|
|
113
|
+
})
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function logComponentResidents() {
|
|
2
|
+
const componentResidentsCount = window.scene.Component?.residentsCount || 0;
|
|
3
|
+
const sceneResidentsCount = window.scene.Scene?.residentsCount || 0;
|
|
4
|
+
const referenceMapResidentsCount =
|
|
5
|
+
window.scene.ReferenceMap?.residentsCount || 0;
|
|
6
|
+
const timestamp = new Date().toISOString();
|
|
7
|
+
|
|
8
|
+
console.log(
|
|
9
|
+
`Component Residents Count: ${componentResidentsCount}, Scene Residents Count: ${sceneResidentsCount}, ReferenceMap Residents Count: ${referenceMapResidentsCount} at ${timestamp}`
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
window.postMessage(
|
|
13
|
+
{
|
|
14
|
+
type: "RESIDENT_COUNT",
|
|
15
|
+
timestamp,
|
|
16
|
+
componentResidentsCount,
|
|
17
|
+
sceneResidentsCount,
|
|
18
|
+
referenceMapResidentsCount,
|
|
19
|
+
},
|
|
20
|
+
"*"
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
if (window.scene) {
|
|
26
|
+
setInterval(logComponentResidents, 5000);
|
|
27
|
+
}
|
|
28
|
+
}, 5000);
|