@switchbot/homebridge-switchbot 5.1.0-beta.2 → 5.1.0-beta.3
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/.github/scripts/normalize-changelog-header.cjs +86 -0
- package/.github/scripts/npm-version-script-esm-auto.js +201 -0
- package/.github/scripts/resolve-version-bump-esm.js +118 -0
- package/.github/workflows/release.yml +4 -4
- package/CHANGELOG.md +18 -0
- package/dist/homebridge-ui/public/css/styles.css +1 -1
- package/dist/homebridge-ui/public/index.html +1 -5
- package/dist/homebridge-ui/public/js/api.d.ts +1 -0
- package/dist/homebridge-ui/public/js/api.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/api.js +14 -1
- package/dist/homebridge-ui/public/js/api.js.map +1 -1
- package/dist/homebridge-ui/public/js/api.ts +16 -1
- package/dist/homebridge-ui/public/js/app.js +54 -71
- package/dist/homebridge-ui/public/js/app.js.map +2 -2
- package/dist/homebridge-ui/public/js/discovery.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/discovery.js +0 -36
- package/dist/homebridge-ui/public/js/discovery.js.map +1 -1
- package/dist/homebridge-ui/public/js/discovery.ts +0 -37
- package/dist/homebridge-ui/public/js/render.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/render.js +38 -31
- package/dist/homebridge-ui/public/js/render.js.map +1 -1
- package/dist/homebridge-ui/public/js/render.ts +39 -34
- package/dist/homebridge-ui/public/js/toast.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/toast.js +2 -3
- package/dist/homebridge-ui/public/js/toast.js.map +1 -1
- package/dist/homebridge-ui/public/js/toast.ts +2 -3
- package/docs/variables/default.html +1 -1
- package/package.json +1 -1
- package/src/homebridge-ui/public/css/styles.css +1 -1
- package/src/homebridge-ui/public/index.html +0 -4
- package/src/homebridge-ui/public/js/api.ts +16 -1
- package/src/homebridge-ui/public/js/discovery.ts +0 -37
- package/src/homebridge-ui/public/js/render.ts +39 -34
- package/src/homebridge-ui/public/js/toast.ts +2 -3
|
@@ -5,6 +5,22 @@ const SPACES_REGEX = /\s/g
|
|
|
5
5
|
const CAMELCASE_REGEX = /([A-Z])/g
|
|
6
6
|
const FIRST_CHAR_REGEX = /^./
|
|
7
7
|
|
|
8
|
+
async function copyTextWithFallback(text: string): Promise<void> {
|
|
9
|
+
try {
|
|
10
|
+
await navigator.clipboard.writeText(text)
|
|
11
|
+
} catch {
|
|
12
|
+
const textarea = document.createElement('textarea')
|
|
13
|
+
textarea.value = text
|
|
14
|
+
textarea.setAttribute('readonly', '')
|
|
15
|
+
textarea.style.cssText = 'position:fixed;left:-9999px;opacity:0;pointer-events:none'
|
|
16
|
+
document.body.appendChild(textarea)
|
|
17
|
+
textarea.select()
|
|
18
|
+
textarea.setSelectionRange(0, textarea.value.length)
|
|
19
|
+
document.execCommand('copy')
|
|
20
|
+
textarea.remove()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
8
24
|
/**
|
|
9
25
|
* Get RSSI signal quality level and color based on dBm value
|
|
10
26
|
* @param rssi Signal strength in dBm (typically -30 to -90)
|
|
@@ -119,7 +135,6 @@ export function renderSignalQualityBadge(rssi: number | undefined): HTMLElement
|
|
|
119
135
|
border-radius: 3px;
|
|
120
136
|
font-size: 10px;
|
|
121
137
|
font-weight: 600;
|
|
122
|
-
margin-left: 8px;
|
|
123
138
|
`
|
|
124
139
|
badge.title = quality.description
|
|
125
140
|
|
|
@@ -927,6 +942,7 @@ export function renderDeviceList(list: any[]): void {
|
|
|
927
942
|
|
|
928
943
|
status.textContent = `Found ${list.length} device(s)`
|
|
929
944
|
ul.classList.add('device-grid')
|
|
945
|
+
ul.style.padding = '0'
|
|
930
946
|
ul.innerHTML = ''
|
|
931
947
|
|
|
932
948
|
// Show remove all button when devices exist
|
|
@@ -941,6 +957,7 @@ export function renderDeviceList(list: any[]): void {
|
|
|
941
957
|
li.style.display = 'flex'
|
|
942
958
|
li.style.flexDirection = 'column'
|
|
943
959
|
li.style.alignItems = 'stretch'
|
|
960
|
+
li.style.padding = '5px 8px'
|
|
944
961
|
li.style.marginBottom = '0'
|
|
945
962
|
|
|
946
963
|
const info = document.createElement('div')
|
|
@@ -950,14 +967,15 @@ export function renderDeviceList(list: any[]): void {
|
|
|
950
967
|
|
|
951
968
|
const nameContainer = document.createElement('div')
|
|
952
969
|
nameContainer.style.display = 'flex'
|
|
953
|
-
nameContainer.style.
|
|
954
|
-
nameContainer.style.
|
|
955
|
-
nameContainer.style.
|
|
970
|
+
nameContainer.style.alignItems = 'center'
|
|
971
|
+
nameContainer.style.marginBottom = '0'
|
|
972
|
+
nameContainer.style.flexWrap = 'wrap'
|
|
973
|
+
nameContainer.style.gap = '4px'
|
|
956
974
|
|
|
957
975
|
const name = document.createElement('div')
|
|
958
976
|
name.style.fontWeight = '500'
|
|
959
977
|
name.style.fontSize = '13px'
|
|
960
|
-
name.textContent = d.name || d.id
|
|
978
|
+
name.textContent = d.configDeviceName || d.name || d.id
|
|
961
979
|
|
|
962
980
|
const expandedDetails = document.createElement('div')
|
|
963
981
|
expandedDetails.style.display = 'none'
|
|
@@ -978,25 +996,8 @@ export function renderDeviceList(list: any[]): void {
|
|
|
978
996
|
expandBtn.style.transform = isHidden ? 'rotate(180deg)' : 'rotate(0deg)'
|
|
979
997
|
}
|
|
980
998
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
code.style.fontSize = '10px'
|
|
984
|
-
code.style.opacity = '0.75'
|
|
985
|
-
code.style.marginLeft = '0'
|
|
986
|
-
code.style.whiteSpace = 'normal'
|
|
987
|
-
code.style.overflowWrap = 'anywhere'
|
|
988
|
-
code.style.wordBreak = 'break-word'
|
|
989
|
-
code.style.maxWidth = '100%'
|
|
990
|
-
|
|
991
|
-
const headerRow = document.createElement('div')
|
|
992
|
-
headerRow.style.display = 'inline-flex'
|
|
993
|
-
headerRow.style.alignItems = 'center'
|
|
994
|
-
headerRow.style.gap = '4px'
|
|
995
|
-
headerRow.appendChild(name)
|
|
996
|
-
headerRow.appendChild(expandBtn)
|
|
997
|
-
|
|
998
|
-
nameContainer.appendChild(headerRow)
|
|
999
|
-
nameContainer.appendChild(code)
|
|
999
|
+
nameContainer.appendChild(name)
|
|
1000
|
+
nameContainer.appendChild(expandBtn)
|
|
1000
1001
|
|
|
1001
1002
|
// Add signal strength visualization if RSSI is available
|
|
1002
1003
|
if (d.rssi !== undefined && d.rssi !== null && d.rssi !== 0) {
|
|
@@ -1005,15 +1006,17 @@ export function renderDeviceList(list: any[]): void {
|
|
|
1005
1006
|
}
|
|
1006
1007
|
|
|
1007
1008
|
const meta = document.createElement('div')
|
|
1008
|
-
meta.style.opacity = '0.
|
|
1009
|
-
meta.style.
|
|
1010
|
-
meta.style.
|
|
1011
|
-
|
|
1012
|
-
const
|
|
1013
|
-
const
|
|
1009
|
+
meta.style.opacity = '0.7'
|
|
1010
|
+
meta.style.fontSize = '10px'
|
|
1011
|
+
meta.style.fontFamily = 'monospace'
|
|
1012
|
+
|
|
1013
|
+
const deviceIdentifier = d.deviceId || d.id
|
|
1014
|
+
const id = `ID: ${deviceIdentifier}`
|
|
1015
|
+
const typeText = d.configDeviceType || d.type ? `Type: ${d.configDeviceType || d.type}` : ''
|
|
1016
|
+
const connText = d.connectionPreference ? `Conn: ${d.connectionPreference}` : ''
|
|
1014
1017
|
const extText = d.externalPublishProtocol && d.externalPublishProtocol !== 'none' ? `external: ${d.externalPublishProtocol}` : ''
|
|
1015
|
-
const roomText = d.room ? `
|
|
1016
|
-
meta.textContent = [typeText, connText, extText, roomText].filter(Boolean).join(' | ')
|
|
1018
|
+
const roomText = d.room ? `Room: ${d.room}` : ''
|
|
1019
|
+
meta.textContent = [id, typeText, connText, extText, roomText].filter(Boolean).join(' | ')
|
|
1017
1020
|
|
|
1018
1021
|
info.appendChild(nameContainer)
|
|
1019
1022
|
info.appendChild(meta)
|
|
@@ -1044,7 +1047,9 @@ export function renderDeviceList(list: any[]): void {
|
|
|
1044
1047
|
copyBtn.style.fontSize = '11px'
|
|
1045
1048
|
copyBtn.addEventListener('click', async () => {
|
|
1046
1049
|
try {
|
|
1047
|
-
|
|
1050
|
+
if (deviceIdentifier) {
|
|
1051
|
+
await copyTextWithFallback(deviceIdentifier)
|
|
1052
|
+
}
|
|
1048
1053
|
copyBtn.textContent = 'Copied'
|
|
1049
1054
|
copyBtn.classList.add('success')
|
|
1050
1055
|
setTimeout(() => {
|
|
@@ -1073,8 +1078,8 @@ export function renderDeviceList(list: any[]): void {
|
|
|
1073
1078
|
|
|
1074
1079
|
buttons.appendChild(editBtn)
|
|
1075
1080
|
buttons.appendChild(copyBtn)
|
|
1076
|
-
buttons.appendChild(createConnectionTestControls(d))
|
|
1077
1081
|
buttons.appendChild(deleteBtn)
|
|
1082
|
+
buttons.appendChild(createConnectionTestControls(d))
|
|
1078
1083
|
|
|
1079
1084
|
li.appendChild(info)
|
|
1080
1085
|
li.appendChild(buttons)
|
|
@@ -10,10 +10,9 @@ function showToast(
|
|
|
10
10
|
// Defensive: check for window and homebridge existence
|
|
11
11
|
const hb = typeof window !== 'undefined' ? (window as any).homebridge : undefined
|
|
12
12
|
const toast = hb && typeof hb.toast === 'object' ? hb.toast : undefined
|
|
13
|
-
|
|
14
|
-
if (fn) {
|
|
13
|
+
if (toast && typeof toast[method] === 'function') {
|
|
15
14
|
try {
|
|
16
|
-
|
|
15
|
+
toast[method](message, title)
|
|
17
16
|
return
|
|
18
17
|
} catch (err) {
|
|
19
18
|
uiLog.warn(`Toast ${method} threw:`, err)
|