Skip to content

Commit 3a94b89

Browse files
committed
run prettier
1 parent a661f7f commit 3a94b89

33 files changed

+376
-308
lines changed

CHANGELOG.md

-2
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,6 @@ release date when you use `npm version` (see `README.md`).
404404
[0.15.0]: https://github.com/webxdc/webxdc-dev/tree/v0.15.0
405405
[unreleased]: https://github.com/webxdc/webxdc-dev/compare/v0.15.1...HEAD
406406
[0.15.1]: https://github.com/webxdc/webxdc-dev/tree/v0.15.1
407-
408-
409407
[Unreleased]: https://github.com/webxdc/webxdc-dev/compare/v0.18.0...HEAD
410408
[0.18.0]: https://github.com/webxdc/webxdc-dev/compare/v0.17.0...v0.18.0
411409
[0.17.0]: https://github.com/webxdc/webxdc-dev/compare/v0.16.0...v0.17.0

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ multiple people.
99

1010
![example screenshot](https://raw.githubusercontent.com/webxdc/webxdc-dev/main/screenshot.png)
1111

12-
1312
In contrast to [hello](https://github.com/webxdc/hello), each "user"'s app
1413
instance gets its own isolated state (e.g. `localStorage`), since each is
1514
served from a separate port (therefore a separate origin).
@@ -81,7 +80,7 @@ to see full information. You can also filter messages. There is also a "chat"
8180
tab which you can use to see `info` contained in updates as well as any
8281
`summary` text contained in an update.
8382

84-
The sidebar can be closed with `Close Messages` button within the sidebar and
83+
The sidebar can be closed with `Close Messages` button within the sidebar and
8584
expanded by clicking on `Open Messages` within the devices tab.
8685
The sidebars width can also be adjusted by moving the separating line between
8786
devices and sidebar.

TODO.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
## Node version
1717

1818
- Can I warn when the node version is too old upon installation.
19-
19+
2020
## Messages
2121

2222
- Perhaps default message filter should see connect & sent at the same time?

backend/app.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function createFrontend(
2929
appInfo: AppInfo,
3030
instances: Instances,
3131
injectFrontend: InjectExpress,
32-
getIndexHtml: () => string
32+
getIndexHtml: () => string,
3333
): expressWs.Application {
3434
const expressApp = express();
3535
const wsInstance = expressWs(expressApp);
@@ -57,9 +57,7 @@ export function createFrontend(
5757
res.send(appInfo.icon.buffer);
5858
});
5959
app.get<{}, Instance[]>("/instances", (req, res) => {
60-
res.json(
61-
instances.list()
62-
);
60+
res.json(instances.list());
6361
});
6462
app.post<{}, Instance>("/instances", (req, res) => {
6563
const instance = instances.add();
@@ -71,9 +69,9 @@ export function createFrontend(
7169
color: instance.color,
7270
});
7371
});
74-
app.delete<{id: string}, Instance[]>("/instances/:id", (req, res) => {
72+
app.delete<{ id: string }, Instance[]>("/instances/:id", (req, res) => {
7573
instances.delete(parseInt(req.params.id));
76-
res.json(instances.list())
74+
res.json(instances.list());
7775
});
7876

7977
app.post<{}, { status: string }>("/clear", (req, res) => {
@@ -126,7 +124,7 @@ export function createPeer(options: PeerOptions): expressWs.Instance {
126124
wsInstance.app.use((req, res, next) => {
127125
const contentSecurityPolicy = getContentSecurityPolicy(
128126
location,
129-
options.instanceUrl
127+
options.instanceUrl,
130128
);
131129
res.setHeader("Content-Security-Policy", contentSecurityPolicy);
132130
next();
@@ -144,7 +142,7 @@ export function createPeer(options: PeerOptions): expressWs.Instance {
144142
createProxyMiddleware(filter, {
145143
target: location.url,
146144
ws: false,
147-
})
145+
}),
148146
);
149147
} else {
150148
// serve webxdc project from directory
@@ -155,7 +153,7 @@ export function createPeer(options: PeerOptions): expressWs.Instance {
155153

156154
function getContentSecurityPolicy(
157155
location: Location,
158-
instanceUrl: string
156+
instanceUrl: string,
159157
): string {
160158
const connectSrcUrls = [];
161159

@@ -180,7 +178,7 @@ function getContentSecurityPolicy(
180178

181179
return policy.replace(
182180
/connect-src (.*?);/,
183-
`connect-src $1 ${connectSrcUrls.join(" ")} ;`
181+
`connect-src $1 ${connectSrcUrls.join(" ")} ;`,
184182
);
185183
}
186184

backend/appInfo.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test("minimal directory app info", async () => {
1717

1818
test("directory app info with manifest", async () => {
1919
const location = getLocation(
20-
path.resolve(__dirname, "fixtures", "withManifest")
20+
path.resolve(__dirname, "fixtures", "withManifest"),
2121
);
2222
const appInfo = await getAppInfo(location);
2323
expect(appInfo.location).toEqual(location);
@@ -31,7 +31,7 @@ test("directory app info with manifest", async () => {
3131

3232
test("directory app info with manifest but no name entry", async () => {
3333
const location = getLocation(
34-
path.resolve(__dirname, "fixtures", "withManifestWithoutName")
34+
path.resolve(__dirname, "fixtures", "withManifestWithoutName"),
3535
);
3636
const appInfo = await getAppInfo(location);
3737
expect(appInfo.location).toEqual(location);
@@ -64,7 +64,7 @@ test("directory app info with manifest but no name entry", async () => {
6464

6565
test("directory app info with jpg icon", async () => {
6666
const location = getLocation(
67-
path.resolve(__dirname, "fixtures", "withJpgIcon")
67+
path.resolve(__dirname, "fixtures", "withJpgIcon"),
6868
);
6969
const appInfo = await getAppInfo(location);
7070
expect(appInfo.location).toEqual(location);
@@ -83,7 +83,7 @@ test("directory app info with jpg icon", async () => {
8383

8484
test("directory app info with png icon", async () => {
8585
const location = getLocation(
86-
path.resolve(__dirname, "fixtures", "withPngIcon")
86+
path.resolve(__dirname, "fixtures", "withPngIcon"),
8787
);
8888
const appInfo = await getAppInfo(location);
8989
expect(appInfo.location).toEqual(location);
@@ -210,7 +210,7 @@ test("url app info with broken manifest", async () => {
210210
} catch (e) {
211211
if (e instanceof AppInfoError) {
212212
expect(e.message).toEqual(
213-
"Invalid manifest.toml, please check the format"
213+
"Invalid manifest.toml, please check the format",
214214
);
215215
} else {
216216
throw e;

backend/appInfo.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function getAppInfo(location: Location): Promise<AppInfo> {
4949

5050
export async function getAppInfoUrl(
5151
location: UrlLocation,
52-
fetch: typeof nodeFetch
52+
fetch: typeof nodeFetch,
5353
): Promise<AppInfo> {
5454
return {
5555
location,
@@ -65,7 +65,7 @@ export function getToolVersion(): string {
6565

6666
async function getManifestInfoFromUrl(
6767
url: string,
68-
fetch: typeof nodeFetch
68+
fetch: typeof nodeFetch,
6969
): Promise<ManifestInfo> {
7070
if (!url.endsWith("/")) {
7171
url = url + "/";
@@ -89,7 +89,7 @@ async function getManifestInfoFromUrl(
8989

9090
async function getIconInfoFromUrl(
9191
url: string,
92-
fetch: typeof nodeFetch
92+
fetch: typeof nodeFetch,
9393
): Promise<IconInfo | null> {
9494
if (!url.endsWith("/")) {
9595
url = url + "/";
@@ -113,7 +113,7 @@ async function getIconInfoFromUrl(
113113

114114
function getManifestInfoFromDir(
115115
dir: string,
116-
fallbackName: string
116+
fallbackName: string,
117117
): ManifestInfo {
118118
const tomlBuffer = readFileBuffer(path.join(dir, "manifest.toml"));
119119
if (tomlBuffer === null) {
@@ -165,7 +165,7 @@ function readFileBuffer(location: string): Buffer | null {
165165

166166
async function readUrlBuffer(
167167
url: string,
168-
fetch: typeof nodeFetch
168+
fetch: typeof nodeFetch,
169169
): Promise<Buffer | null> {
170170
const response = await fetch(url);
171171
if (!response.ok) {

backend/fixtures/minimal/index.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<html>
2-
<body>Hello, world!</body>
3-
</html>
2+
<body>
3+
Hello, world!
4+
</body>
5+
</html>
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<html>
2-
<body>Hello, world!</body>
3-
</html>
2+
<body>
3+
Hello, world!
4+
</body>
5+
</html>
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<html>
2-
<body>Hello, world!</body>
3-
</html>
2+
<body>
3+
Hello, world!
4+
</body>
5+
</html>
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<html>
2-
<body>Hello, world!</body>
3-
</html>
2+
<body>
3+
Hello, world!
4+
</body>
5+
</html>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<html>
2-
<body>Hello, world!</body>
3-
</html>
2+
<body>
3+
Hello, world!
4+
</body>
5+
</html>
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<html>
2-
<body>Hello, world!</body>
3-
</html>
2+
<body>
3+
Hello, world!
4+
</body>
5+
</html>

backend/instance.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Location } from "./location";
77
import { createPeer, InjectExpress } from "./app";
88
import { AppInfo } from "./appInfo";
99
import { getColorForId } from "./color";
10-
import { Instance as FrontendInstance } from '../types/instance';
10+
import { Instance as FrontendInstance } from "../types/instance";
1111

1212
export type Options = {
1313
basePort: number;
@@ -39,7 +39,7 @@ class Instance {
3939
public app: expressWs.Application,
4040
public port: number,
4141
public url: string,
42-
public webXdc: WebXdcMulti
42+
public webXdc: WebXdcMulti,
4343
) {
4444
this.id = port.toString();
4545
this.color = getColorForId(this.id);
@@ -52,7 +52,7 @@ class Instance {
5252
}
5353

5454
close() {
55-
this.server.close()
55+
this.server.close();
5656
}
5757
}
5858

@@ -107,7 +107,7 @@ export class Instances {
107107
app,
108108
port,
109109
instanceUrl,
110-
this.processor.createClient(port.toString())
110+
this.processor.createClient(port.toString()),
111111
);
112112

113113
const wss = wsInstance.getWss();
@@ -117,7 +117,7 @@ export class Instances {
117117
ws.on("message", (msg: string) => {
118118
if (typeof msg !== "string") {
119119
console.error(
120-
"webxdc: Don't know how to handle unexpected non-string data"
120+
"webxdc: Don't know how to handle unexpected non-string data",
121121
);
122122
return;
123123
}
@@ -133,7 +133,7 @@ export class Instances {
133133
JSON.stringify({
134134
type: "updates",
135135
updates: updates.map(([update]) => update),
136-
})
136+
}),
137137
);
138138
},
139139
parsed.serial,
@@ -152,7 +152,7 @@ export class Instances {
152152
name: this.appInfo.manifest.name,
153153
color: instance.color,
154154
},
155-
})
155+
}),
156156
);
157157
} else {
158158
throw new Error(`Unknown message: ${JSON.stringify(parsed)}`);
@@ -166,7 +166,9 @@ export class Instances {
166166
delete(id: number) {
167167
let instance = this.instances.get(id);
168168
if (instance == null) {
169-
throw new Error(`Instance with id ${id} can't be deleted because it does not exist`);
169+
throw new Error(
170+
`Instance with id ${id} can't be deleted because it does not exist`,
171+
);
170172
}
171173
instance.close();
172174
this.processor.removeClient(instance.id);
@@ -187,13 +189,13 @@ export class Instances {
187189
this._onMessage = onMessage;
188190
}
189191

190-
list(): FrontendInstance[]{
192+
list(): FrontendInstance[] {
191193
return Array.from(this.instances.values()).map((instance) => ({
192194
id: instance.id,
193195
port: instance.port,
194196
url: instance.url,
195197
color: instance.color,
196-
}))
198+
}));
197199
}
198200
}
199201

@@ -215,7 +217,7 @@ function isSendUpdateMessage(value: any): value is SendUpdateMessage {
215217
}
216218

217219
function isSetUpdateListenerMessage(
218-
value: any
220+
value: any,
219221
): value is SetUpdateListenerMessage {
220222
return value.type === "setUpdateListener";
221223
}

backend/location.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function getLocation(location: string): Location {
4545
}
4646
if (!hasIndexHtml(path)) {
4747
throw new LocationError(
48-
`Invalid xdc file (no index.html file inside): ${location}`
48+
`Invalid xdc file (no index.html file inside): ${location}`,
4949
);
5050
}
5151
return {
@@ -65,7 +65,7 @@ export function getLocation(location: string): Location {
6565

6666
if (!hasIndexHtml(location)) {
6767
throw new LocationError(
68-
`Invalid xdc dir (no index.html file): ${location}`
68+
`Invalid xdc dir (no index.html file): ${location}`,
6969
);
7070
}
7171
return {

0 commit comments

Comments
 (0)