tangled
alpha
login
or
join now
me.webbeef.org
/
browser.html
Rewild Your Web
web
browser
dweb
5
fork
atom
overview
issues
1
pulls
pipelines
misc: load json files using json modules
webbeef.tngl.sh
2 days ago
44564e19
f1cbd939
+10
-16
2 changed files
expand all
collapse all
unified
split
resources
browserhtml
homescreen
index.js
shared
search
engines.js
+6
-4
resources/browserhtml/homescreen/index.js
···
10
// Load widgets from JSON
11
async function loadWidgets() {
12
try {
13
-
const response = await fetch("resources/widgets.json");
14
-
const widgets = await response.json();
0
15
renderWidgets(widgets);
16
} catch (e) {
17
console.log("[Homescreen] No widgets configured");
···
33
// Load bookmarks from JSON
34
async function loadBookmarks() {
35
try {
36
-
const response = await fetch("resources/bookmarks.json");
37
-
const bookmarks = await response.json();
0
38
renderBookmarks(bookmarks);
39
} catch (e) {
40
console.error("[Homescreen] Failed to load bookmarks:", e);
···
10
// Load widgets from JSON
11
async function loadWidgets() {
12
try {
13
+
const { default: widgets } = await import("./resources/widgets.json", {
14
+
with: { type: "json" },
15
+
});
16
renderWidgets(widgets);
17
} catch (e) {
18
console.log("[Homescreen] No widgets configured");
···
34
// Load bookmarks from JSON
35
async function loadBookmarks() {
36
try {
37
+
const { default: bookmarks } = await import("./resources/bookmarks.json", {
38
+
with: { type: "json" },
39
+
});
40
renderBookmarks(bookmarks);
41
} catch (e) {
42
console.error("[Homescreen] Failed to load bookmarks:", e);
+4
-12
resources/browserhtml/shared/search/engines.js
···
2
3
const PREF_NAME = "browserhtml.search_engine";
4
0
0
0
5
export default class SearchEngines extends EventTarget {
6
constructor() {
7
super();
8
-
this.engines = null;
9
this.currentEngine = null;
0
10
}
11
12
async ensureReady() {
13
if (this.currentEngine) {
14
-
return;
15
-
}
16
-
17
-
// Load the default search engines resource.
18
-
try {
19
-
let response = await fetch(
20
-
"//shared.localhost:8888/search/default_engines.json",
21
-
);
22
-
this.engines = await response.json();
23
-
} catch (e) {
24
-
console.error(`Failed to load search engines: ${e}`);
25
return;
26
}
27
···
2
3
const PREF_NAME = "browserhtml.search_engine";
4
5
+
// Load the default search engines resource.
6
+
import ENGINES from "//shared.localhost:8888/search/default_engines.json" with { type: "json" };
7
+
8
export default class SearchEngines extends EventTarget {
9
constructor() {
10
super();
0
11
this.currentEngine = null;
12
+
this.engines = ENGINES;
13
}
14
15
async ensureReady() {
16
if (this.currentEngine) {
0
0
0
0
0
0
0
0
0
0
0
17
return;
18
}
19