Skip to content

Commit 3a6eba7

Browse files
committed
[chrome] use vite url imports for default favicon url
1 parent 2fff9e3 commit 3a6eba7

File tree

9 files changed

+28
-19
lines changed

9 files changed

+28
-19
lines changed

packages/chrome/src/Tab.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ScramjetFrame,
1515
} from "@mercuryworkshop/scramjet/bundled";
1616
import { IsolatedFrame } from "./IsolatedFrame";
17+
import { defaultFaviconUrl } from "./assets/favicon";
1718

1819
const requestInspectElement = createDelegate<[HTMLElement, Tab]>();
1920

@@ -64,7 +65,7 @@ export class Tab extends StatefulClass {
6465
this.history = new History(this);
6566
this.history.push(this.url, undefined);
6667

67-
this.icon = "/defaultfavicon.png";
68+
this.icon = defaultFaviconUrl;
6869

6970
let resolver: () => void;
7071
this.waitForChobitsuInit = new Promise((resolve) => {
@@ -189,17 +190,18 @@ export class Tab extends StatefulClass {
189190
// placeholder title until the page fills in
190191
this.title = url.href;
191192

192-
if (!navigator.serviceWorker.controller) {
193-
serviceWorkerReady.then(() => {
194-
this.frame.go(url);
195-
});
196-
} else {
197-
this.frame.go(url);
198-
}
193+
// if (!navigator.serviceWorker.controller) {
194+
// serviceWorkerReady.then(() => {
195+
this.frame.go(url);
196+
// });
197+
// } else {
198+
// this.frame.go(url);
199+
// }
199200
}
200201
}
201202

202203
pushNavigate(url: URL) {
204+
console.log("pushing");
203205
this.history.push(url, undefined, true);
204206
}
205207
replaceNavigate(url: URL) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import defaultFavicon from "../../public/defaultfavicon.png";
2+
3+
export const defaultFaviconUrl = defaultFavicon;

packages/chrome/src/components/DownloadsPopup.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import iconFolder from "@ktibow/iconset-ion/folder-outline";
77
import iconOpen from "@ktibow/iconset-ion/open-outline";
88
import iconPause from "@ktibow/iconset-ion/pause-outline";
99
import { formatBytes } from "../utils";
10+
import { defaultFaviconUrl } from "../assets/favicon";
1011

1112
export const DownloadsPopup: Component<{}> = function (cx) {
1213
return (
@@ -27,7 +28,7 @@ export const DownloadsPopup: Component<{}> = function (cx) {
2728
{use(browser.sessionDownloadHistory).mapEach((b) => (
2829
<div class="entry">
2930
<div class="iconcontainer">
30-
<img src="/defaultfavicon.png"></img>
31+
<img src={defaultFaviconUrl}></img>
3132
</div>
3233
<div class="contents">
3334
<span>{b.filename}</span>

packages/chrome/src/components/Omnibox.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type { Tab } from "../Tab";
1313
import { UrlInput } from "./UrlInput";
1414
import { browser } from "../Browser";
1515
import { Icon } from "./Icon";
16+
import { defaultFaviconUrl } from "../assets/favicon";
1617

1718
import iconNew from "@ktibow/iconset-ion/duplicate-outline";
1819
import iconTime from "@ktibow/iconset-ion/time-outline";
@@ -141,7 +142,7 @@ export const Omnibox: Component<{
141142
[
142143
...states.map((s) => ({
143144
label: s.title || "New Tab",
144-
image: s.favicon || "/defaultfavicon.png",
145+
image: s.favicon || defaultFaviconUrl,
145146
action: () => {
146147
let rel =
147148
browser.activetab.history.states.indexOf(s) -

packages/chrome/src/components/TabStrip.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type { Tab } from "../Tab";
1111
// import html2canvas from "html2canvas";
1212
import { setContextMenu } from "./Menu";
1313
import { browser, forceScreenshot, pushTab } from "../Browser";
14+
import { defaultFaviconUrl } from "../assets/favicon";
1415

1516
const isFirefox =
1617
navigator.userAgent.includes("Gecko/") &&
@@ -137,7 +138,7 @@ export const DragTab: Component<
137138
<div class={use(this.active).map((x) => `main ${x ? "active" : ""}`)}>
138139
<img
139140
src={use(this.tab.icon)}
140-
on:error={() => (this.tab.icon = "/defaultfavicon.png")}
141+
on:error={() => (this.tab.icon = defaultFaviconUrl)}
141142
/>
142143
<span>{use(this.tab.title)}</span>
143144
<button

packages/chrome/src/components/UrlInput.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import iconForwards from "@ktibow/iconset-ion/arrow-forward";
1313
import { Icon } from "./Icon";
1414
import { OmnibarButton } from "./OmnibarButton";
1515
import { createMenuCustom, setContextMenu } from "./Menu";
16+
import { defaultFaviconUrl } from "../assets/favicon";
1617
import { browser } from "../Browser";
1718
import { SiteInformationPopup } from "./SiteInformationPopup";
1819
import { emToPx, splitUrl } from "../utils";
@@ -183,7 +184,7 @@ export const UrlInput: Component<
183184
) : (
184185
<img
185186
class="favicon"
186-
src={item.favicon || "/defaultfavicon.png"}
187+
src={item.favicon || defaultFaviconUrl}
187188
alt="favicon"
188189
/>
189190
)}
@@ -207,7 +208,7 @@ export const UrlInput: Component<
207208
<img
208209
src={
209210
this.overflowItems[this.focusindex - 1].favicon ||
210-
"/defaultfavicon.png"
211+
defaultFaviconUrl
211212
}
212213
></img>
213214
) : (

packages/chrome/src/pages/DownloadsPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import iconClose from "@ktibow/iconset-ion/close-outline";
66
import iconFolder from "@ktibow/iconset-ion/folder-outline";
77
import { Icon } from "../components/Icon";
88
import { formatBytes } from "../utils";
9+
import { defaultFaviconUrl } from "../assets/favicon";
910

1011
export const DownloadsPage: Component<
1112
{
@@ -21,7 +22,7 @@ export const DownloadsPage: Component<
2122
{use(browser.globalDownloadHistory).mapEach((e) => (
2223
<div class="entry">
2324
<div class="iconcontainer">
24-
<img src="/defaultfavicon.png"></img>
25+
<img src={defaultFaviconUrl}></img>
2526
</div>
2627
<div class="content">
2728
<a href={e.url}>{e.filename}</a>

packages/chrome/src/pages/HistoryPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { css, type Component } from "dreamland/core";
22
import type { Tab } from "../Tab";
33
import { browser } from "../Browser";
4+
import { defaultFaviconUrl } from "../assets/favicon";
45

56
export const HistoryPage: Component<
67
{
@@ -21,7 +22,7 @@ export const HistoryPage: Component<
2122
browser.newTab(entry.url);
2223
}}
2324
>
24-
<img src={entry.favicon || "/defaultfavicon.png"} alt="favicon" />
25+
<img src={entry.favicon || defaultFaviconUrl} alt="favicon" />
2526
<span class="title">{entry.title || entry.url.href}</span>
2627
<span class="url">{entry.url.hostname}</span>
2728
</div>

packages/chrome/src/pages/NewTabPage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Tab } from "../Tab";
33
import { browser } from "../Browser";
44
import { trimUrl } from "../components/UrlInput";
55
import { createMenu } from "../components/Menu";
6+
import { defaultFaviconUrl } from "../assets/favicon";
67

78
export const NewTabPage: Component<
89
{
@@ -44,10 +45,7 @@ export const NewTabPage: Component<
4445
>
4546
<div class="suggestioninner">
4647
<div class="circle">
47-
<img
48-
src={entry.favicon || "/defaultfavicon.png"}
49-
alt="favicon"
50-
/>
48+
<img src={entry.favicon || defaultFaviconUrl} alt="favicon" />
5149
</div>
5250
<span class="title">{entry.title || trimUrl(entry.url)}</span>
5351
</div>

0 commit comments

Comments
 (0)