@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.
@@ -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,37 @@
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
+ box-sizing: border-box;
28
+ }
29
+ </style>
30
+ </head>
31
+ <body>
32
+ <h1>Component Residents Monitor</h1>
33
+ <canvas id="residentChart1"></canvas>
34
+ <canvas id="residentChart2"></canvas>
35
+ <canvas id="residentChart3"></canvas>
36
+ </body>
37
+ </html>
@@ -0,0 +1,112 @@
1
+ document.addEventListener('DOMContentLoaded', () => {
2
+ let residentChart1, residentChart2, residentChart3
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
+ animation: false, // 애니메이션 비활성화
33
+ scales: {
34
+ x: {
35
+ display: false, // X축 숨기기 (전체)
36
+ grid: {
37
+ display: false // X축의 격자선 숨기기
38
+ },
39
+ ticks: {
40
+ display: false // X축 틱 마크 숨기기
41
+ }
42
+ },
43
+ y: {
44
+ beginAtZero: true, // Y축이 0에서 시작되도록 설정
45
+ title: {
46
+ display: true,
47
+ text: label // Y축의 레이블
48
+ },
49
+ ticks: {
50
+ stepSize: 1
51
+ }
52
+ }
53
+ },
54
+ plugins: {
55
+ legend: {
56
+ display: false // 범례 숨기기
57
+ }
58
+ }
59
+ }
60
+ })
61
+ }
62
+
63
+ // 차트가 초기화되지 않았을 때만 차트 생성
64
+ if (!chartsInitialized) {
65
+ const ctx1 = document.getElementById('residentChart1').getContext('2d')
66
+ const ctx2 = document.getElementById('residentChart2').getContext('2d')
67
+ const ctx3 = document.getElementById('residentChart3').getContext('2d')
68
+
69
+ residentChart1 = createChart(ctx1, 'Component Residents Count')
70
+ residentChart2 = createChart(ctx2, 'Scene Residents Count')
71
+ residentChart3 = createChart(ctx3, 'ReferenceMap Residents Count')
72
+
73
+ chartsInitialized = true // 차트가 초기화되었음을 표시
74
+ }
75
+
76
+ // 차트 업데이트 함수
77
+ const updateCharts = data => {
78
+ residentChart1.data.labels = data.map(entry => entry.timestamp)
79
+ residentChart1.data.datasets[0].data = data.map(entry => entry.componentResidentsCount)
80
+ residentChart1.update()
81
+
82
+ residentChart2.data.labels = data.map(entry => entry.timestamp)
83
+ residentChart2.data.datasets[0].data = data.map(entry => entry.sceneResidentsCount)
84
+ residentChart2.update()
85
+
86
+ residentChart3.data.labels = data.map(entry => entry.timestamp)
87
+ residentChart3.data.datasets[0].data = data.map(entry => entry.referenceMapResidentsCount)
88
+ residentChart3.update()
89
+ }
90
+
91
+ // 저장된 데이터 가져오기 및 초기 로딩
92
+ chrome.storage.local.get({ residentData: {} }, result => {
93
+ const residentData = result.residentData
94
+
95
+ if (residentData[tabId] && residentData[tabId].length > 0) {
96
+ updateCharts(residentData[tabId])
97
+ } else {
98
+ console.log('No resident data found for this tab.')
99
+ }
100
+ })
101
+
102
+ // 메시지 리스너 중복 등록 방지
103
+ if (!listenerRegistered) {
104
+ chrome.runtime.onMessage.addListener(message => {
105
+ if (message.type === 'UPDATE_CHART' && message.tabId === tabId) {
106
+ updateCharts(message.data)
107
+ }
108
+ })
109
+ listenerRegistered = true // 리스너가 등록되었음을 표시
110
+ }
111
+ })
112
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatiolab/things-scene",
3
- "version": "3.4.45",
3
+ "version": "3.4.47",
4
4
  "description": "2D graphic library",
5
5
  "main": "src/index.js",
6
6
  "module": "things-scene.mjs",