This repository was archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 236
/
Copy pathapi.ts
99 lines (83 loc) · 2.64 KB
/
api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
function postHTTP(url, postData) {
const request = new Request(url, {
method: "POST",
headers: new Headers({
"Content-Type": "application/json",
}),
body: JSON.stringify(postData),
});
return window.fetch(request);
}
export function getBoardPackages(update) {
return window.fetch(`/api/boardpackages?update=${update}`).then((response) => response.json());
}
export function installBoard(packageName, arch, version) {
return postHTTP("/api/installboard", {
packageName,
arch,
version,
}).then((response) => response.json());
}
export function uninstallBoard(boardName, packagePath) {
return postHTTP("/api/uninstallboard", {
boardName,
packagePath,
}).then((response) => response.json());
}
export function openLink(link) {
return postHTTP("/api/openlink", {
link,
}).then((response) => response.json());
}
export function openSettings(query) {
return postHTTP("/api/opensettings", {
query,
}).then((response) => response.json());
}
export function getLibraries(update) {
return window.fetch(`/api/libraries?update=${update}`).then((response) => response.json());
}
export function installLibrary(libraryName, version) {
return postHTTP("/api/installlibrary", {
libraryName,
version,
}).then((response) => response.json());
}
export function uninstallLibrary(libraryName, libraryPath) {
return postHTTP("/api/uninstalllibrary", {
libraryName,
libraryPath,
}).then((response) => response.json());
}
export function addLibPath(libraryPath) {
return postHTTP("/api/addlibpath", {
libraryPath,
}).then((response) => response.json());
}
export function getInstalledBoards() {
return window.fetch(`/api/installedboards`).then((response) => response.json());
}
export function updateSelectedBoard(boardId) {
return postHTTP("/api/updateselectedboard", {
boardId,
}).then((response) => response.json());
}
export function getConfigItems() {
return window.fetch(`/api/configitems`).then((response) => response.json());
}
export function updateConfigItem(configId, optionId) {
return postHTTP("/api/updateconfig", {
configId,
optionId,
}).then((response) => response.json());
}
export function getExamples() {
return window.fetch("/api/examples").then((response) => response.json());
}
export function openExample(examplePath) {
return postHTTP("/api/openexample", {
examplePath,
}).then((response) => response.json());
}