-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into pause-button
- Loading branch information
Showing
32 changed files
with
1,243 additions
and
125 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './monitor-selection'; | ||
export * from './dock-config'; | ||
export * from './widget-caching'; | ||
export * from './widget-config'; | ||
export * from './widget-placement'; | ||
export * from './widget-preset'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type WidgetCaching = { | ||
defaultDuration: number; | ||
rules: WidgetCachingRule[]; | ||
}; | ||
|
||
export type WidgetCachingRule = { | ||
urlRegex: string; | ||
duration: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
if (window.location.host === '127.0.0.1:6124') { | ||
if ('serviceWorker' in navigator) { | ||
navigator.serviceWorker | ||
.register('/__zebar/sw.js', { scope: '/' }) | ||
.then(sw => { | ||
console.log('[Zebar] Service Worker registered.'); | ||
|
||
const message = { | ||
type: 'SET_CONFIG', | ||
config: window.__ZEBAR_STATE.config.caching, | ||
}; | ||
|
||
sw.active?.postMessage(message); | ||
sw.installing?.postMessage(message); | ||
sw.waiting?.postMessage(message); | ||
}) | ||
.catch(err => | ||
console.error('[Zebar] Service Worker failed to register:', err), | ||
); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
addFavicon(); | ||
loadCss('/__zebar/normalize.css'); | ||
}); | ||
} | ||
|
||
/** | ||
* Adds a CSS file with the given path to the head element. | ||
*/ | ||
function loadCss(path) { | ||
const link = document.createElement('link'); | ||
link.setAttribute('data-zebar', ''); | ||
link.rel = 'stylesheet'; | ||
link.type = 'text/css'; | ||
link.href = path; | ||
insertIntoHead(link); | ||
} | ||
|
||
/** | ||
* Adds a favicon to the head element if one is not already present. | ||
*/ | ||
function addFavicon() { | ||
if (!document.querySelector('link[rel="icon"]')) { | ||
const link = document.createElement('link'); | ||
link.setAttribute('data-zebar', ''); | ||
link.rel = 'icon'; | ||
link.href = 'data:;'; | ||
insertIntoHead(link); | ||
} | ||
} | ||
|
||
/** | ||
* Inserts the element before any other resource tags in the head element. | ||
* Ensures that user-defined stylesheets or favicons are prioritized over | ||
* Zebar's defaults. | ||
*/ | ||
function insertIntoHead(element) { | ||
const resources = document.head.querySelectorAll('link, script, style'); | ||
const target = resources[0]?.previousElementSibling; | ||
|
||
if (target) { | ||
target.after(element); | ||
} else { | ||
document.head.appendChild(element); | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.