dsh-lmw-plugin 1.0.4 → 1.0.6
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 +37 -21
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -26,6 +26,7 @@ window.__ModuleLoader__.load({
|
|
|
26
26
|
const { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } = React
|
|
27
27
|
|
|
28
28
|
const NS = 'lmw'
|
|
29
|
+
const CLIENT_VERSION = '1.0.6'
|
|
29
30
|
const ROUTE = 'lmw-plugin'
|
|
30
31
|
|
|
31
32
|
/* ------------------------------------------------------------------ */
|
|
@@ -1663,15 +1664,28 @@ window.__ModuleLoader__.load({
|
|
|
1663
1664
|
}
|
|
1664
1665
|
}
|
|
1665
1666
|
|
|
1666
|
-
/**
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1667
|
+
/** Offline styling owned by the guard itself, so it never depends on another entry. */
|
|
1668
|
+
const OFFLINE_CSS = [
|
|
1669
|
+
'[data-lmw-offline]{opacity:.45;filter:grayscale(1);cursor:not-allowed!important}',
|
|
1670
|
+
'[data-lmw-offline] *{cursor:not-allowed!important}',
|
|
1671
|
+
'[data-lmw-offline-composer]{opacity:.55;cursor:not-allowed!important}',
|
|
1672
|
+
].join('\n')
|
|
1673
|
+
|
|
1674
|
+
/** Plugin-lifetime guard: mark Workspaces whose directory vanished and block them. */
|
|
1675
|
+
function startWorkspaceGuard(translate) {
|
|
1676
|
+
const tr = makeT(translate)
|
|
1677
|
+
document.body.setAttribute('data-lmw-guard', JSON.stringify({ mounted: true }))
|
|
1678
|
+
document.documentElement.setAttribute('data-lmw-version', CLIENT_VERSION)
|
|
1679
|
+
const style = document.createElement('style')
|
|
1680
|
+
style.setAttribute('data-lmw-offline-style', '')
|
|
1681
|
+
style.textContent = OFFLINE_CSS
|
|
1682
|
+
document.head.appendChild(style)
|
|
1683
|
+
let statuses = { workspaces: {}, sessions: {} }
|
|
1684
|
+
let disposed = false
|
|
1685
|
+
let timer = 0
|
|
1673
1686
|
|
|
1674
1687
|
const mark = () => {
|
|
1688
|
+
try {
|
|
1675
1689
|
for (const row of document.querySelectorAll('[data-row-key^="workspace:"]')) {
|
|
1676
1690
|
const id = row.getAttribute('data-row-key').slice('workspace:'.length)
|
|
1677
1691
|
const missing = statuses.workspaces[id] === true
|
|
@@ -1712,6 +1726,10 @@ window.__ModuleLoader__.load({
|
|
|
1712
1726
|
composer.removeAttribute('aria-disabled')
|
|
1713
1727
|
}
|
|
1714
1728
|
}
|
|
1729
|
+
} catch (error) {
|
|
1730
|
+
console.error('[lmw-plugin] offline marking failed:', error)
|
|
1731
|
+
document.body.setAttribute('data-lmw-guard', JSON.stringify({ markError: messageOf(error) }))
|
|
1732
|
+
}
|
|
1715
1733
|
}
|
|
1716
1734
|
|
|
1717
1735
|
const schedule = () => {
|
|
@@ -1734,8 +1752,18 @@ window.__ModuleLoader__.load({
|
|
|
1734
1752
|
if (!disposed) {
|
|
1735
1753
|
statuses = { workspaces, sessions }
|
|
1736
1754
|
mark()
|
|
1755
|
+
document.body.setAttribute('data-lmw-guard', JSON.stringify({
|
|
1756
|
+
loaded: true,
|
|
1757
|
+
workspaces: Object.keys(workspaces).length,
|
|
1758
|
+
missing: Object.values(workspaces).filter(Boolean).length,
|
|
1759
|
+
rows: document.querySelectorAll('[data-row-key^="workspace:"]').length,
|
|
1760
|
+
offline: document.querySelectorAll('[data-lmw-offline]').length,
|
|
1761
|
+
}))
|
|
1737
1762
|
}
|
|
1738
1763
|
} catch (error) {
|
|
1764
|
+
if (!disposed) {
|
|
1765
|
+
document.body.setAttribute('data-lmw-guard', JSON.stringify({ loaded: false, error: messageOf(error) }))
|
|
1766
|
+
}
|
|
1739
1767
|
console.error('[lmw-plugin] workspace status failed:', error)
|
|
1740
1768
|
}
|
|
1741
1769
|
}
|
|
@@ -1755,10 +1783,6 @@ window.__ModuleLoader__.load({
|
|
|
1755
1783
|
|
|
1756
1784
|
const observer = new MutationObserver(schedule)
|
|
1757
1785
|
observer.observe(document.body, { childList: true, subtree: true })
|
|
1758
|
-
const unsubscribe = workspaces.list.subscribe(() => {
|
|
1759
|
-
schedule()
|
|
1760
|
-
void load()
|
|
1761
|
-
})
|
|
1762
1786
|
document.addEventListener('click', blockRow, true)
|
|
1763
1787
|
document.addEventListener('keydown', blockRow, true)
|
|
1764
1788
|
for (const type of ['keydown', 'beforeinput', 'paste', 'drop']) document.addEventListener(type, blockInput, true)
|
|
@@ -1768,7 +1792,6 @@ window.__ModuleLoader__.load({
|
|
|
1768
1792
|
return () => {
|
|
1769
1793
|
disposed = true
|
|
1770
1794
|
observer.disconnect()
|
|
1771
|
-
unsubscribe()
|
|
1772
1795
|
window.clearInterval(interval)
|
|
1773
1796
|
document.removeEventListener('click', blockRow, true)
|
|
1774
1797
|
document.removeEventListener('keydown', blockRow, true)
|
|
@@ -1778,9 +1801,8 @@ window.__ModuleLoader__.load({
|
|
|
1778
1801
|
row.removeAttribute('data-lmw-offline')
|
|
1779
1802
|
row.removeAttribute('aria-disabled')
|
|
1780
1803
|
}
|
|
1804
|
+
style.remove()
|
|
1781
1805
|
}
|
|
1782
|
-
}, [workspaces, tr])
|
|
1783
|
-
return null
|
|
1784
1806
|
}
|
|
1785
1807
|
|
|
1786
1808
|
function SortDialog(props) {
|
|
@@ -2094,13 +2116,7 @@ window.__ModuleLoader__.load({
|
|
|
2094
2116
|
inject: () => ({ store: sortStore, translate: t }),
|
|
2095
2117
|
}, SortDialog))
|
|
2096
2118
|
|
|
2097
|
-
ctx.
|
|
2098
|
-
name: 'shell.overlay',
|
|
2099
|
-
id: 'lmw-workspace-offline',
|
|
2100
|
-
order: 920,
|
|
2101
|
-
locale: NS,
|
|
2102
|
-
inject: () => ({ workspaces: ctx.workspaces, translate: t }),
|
|
2103
|
-
}, WorkspaceOfflineGuard))
|
|
2119
|
+
ctx.effect(() => startWorkspaceGuard(t), 'lmw: workspace offline guard')
|
|
2104
2120
|
|
|
2105
2121
|
ctx.slots.inject('shell.overlay', () => ctx.slots.register({
|
|
2106
2122
|
name: 'shell.overlay',
|