dsh-lmw-plugin 1.0.4 → 1.0.5
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/client.js +30 -4
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -1667,11 +1667,13 @@ window.__ModuleLoader__.load({
|
|
|
1667
1667
|
function WorkspaceOfflineGuard(props) {
|
|
1668
1668
|
const tr = makeT(props.translate ?? props.t)
|
|
1669
1669
|
useEffect(() => {
|
|
1670
|
+
document.body.setAttribute('data-lmw-guard', JSON.stringify({ mounted: true }))
|
|
1670
1671
|
let statuses = { workspaces: {}, sessions: {} }
|
|
1671
1672
|
let disposed = false
|
|
1672
1673
|
let timer = 0
|
|
1673
1674
|
|
|
1674
1675
|
const mark = () => {
|
|
1676
|
+
try {
|
|
1675
1677
|
for (const row of document.querySelectorAll('[data-row-key^="workspace:"]')) {
|
|
1676
1678
|
const id = row.getAttribute('data-row-key').slice('workspace:'.length)
|
|
1677
1679
|
const missing = statuses.workspaces[id] === true
|
|
@@ -1712,6 +1714,10 @@ window.__ModuleLoader__.load({
|
|
|
1712
1714
|
composer.removeAttribute('aria-disabled')
|
|
1713
1715
|
}
|
|
1714
1716
|
}
|
|
1717
|
+
} catch (error) {
|
|
1718
|
+
console.error('[lmw-plugin] offline marking failed:', error)
|
|
1719
|
+
document.body.setAttribute('data-lmw-guard', JSON.stringify({ markError: messageOf(error) }))
|
|
1720
|
+
}
|
|
1715
1721
|
}
|
|
1716
1722
|
|
|
1717
1723
|
const schedule = () => {
|
|
@@ -1734,8 +1740,18 @@ window.__ModuleLoader__.load({
|
|
|
1734
1740
|
if (!disposed) {
|
|
1735
1741
|
statuses = { workspaces, sessions }
|
|
1736
1742
|
mark()
|
|
1743
|
+
document.body.setAttribute('data-lmw-guard', JSON.stringify({
|
|
1744
|
+
loaded: true,
|
|
1745
|
+
workspaces: Object.keys(workspaces).length,
|
|
1746
|
+
missing: Object.values(workspaces).filter(Boolean).length,
|
|
1747
|
+
rows: document.querySelectorAll('[data-row-key^="workspace:"]').length,
|
|
1748
|
+
offline: document.querySelectorAll('[data-lmw-offline]').length,
|
|
1749
|
+
}))
|
|
1737
1750
|
}
|
|
1738
1751
|
} catch (error) {
|
|
1752
|
+
if (!disposed) {
|
|
1753
|
+
document.body.setAttribute('data-lmw-guard', JSON.stringify({ loaded: false, error: messageOf(error) }))
|
|
1754
|
+
}
|
|
1739
1755
|
console.error('[lmw-plugin] workspace status failed:', error)
|
|
1740
1756
|
}
|
|
1741
1757
|
}
|
|
@@ -1755,15 +1771,25 @@ window.__ModuleLoader__.load({
|
|
|
1755
1771
|
|
|
1756
1772
|
const observer = new MutationObserver(schedule)
|
|
1757
1773
|
observer.observe(document.body, { childList: true, subtree: true })
|
|
1758
|
-
const unsubscribe = workspaces.list.subscribe(() => {
|
|
1759
|
-
schedule()
|
|
1760
|
-
void load()
|
|
1761
|
-
})
|
|
1762
1774
|
document.addEventListener('click', blockRow, true)
|
|
1763
1775
|
document.addEventListener('keydown', blockRow, true)
|
|
1764
1776
|
for (const type of ['keydown', 'beforeinput', 'paste', 'drop']) document.addEventListener(type, blockInput, true)
|
|
1765
1777
|
const interval = window.setInterval(() => { void load() }, 20000)
|
|
1778
|
+
// Mark first: a broken optional subscription must never keep the guard
|
|
1779
|
+
// from running at all.
|
|
1766
1780
|
void load()
|
|
1781
|
+
let unsubscribe = () => {}
|
|
1782
|
+
try {
|
|
1783
|
+
const list = workspaces?.list
|
|
1784
|
+
if (list !== undefined && typeof list.subscribe === 'function') {
|
|
1785
|
+
unsubscribe = list.subscribe(() => {
|
|
1786
|
+
schedule()
|
|
1787
|
+
void load()
|
|
1788
|
+
}) ?? (() => {})
|
|
1789
|
+
}
|
|
1790
|
+
} catch (error) {
|
|
1791
|
+
console.error('[lmw-plugin] workspace list subscription failed:', error)
|
|
1792
|
+
}
|
|
1767
1793
|
|
|
1768
1794
|
return () => {
|
|
1769
1795
|
disposed = true
|