@indietabletop/appkit 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.ts CHANGED
@@ -285,4 +285,35 @@ export class IndieTabletopClient {
285
285
 
286
286
  return result;
287
287
  }
288
+
289
+ /**
290
+ * Uploads a file given S3 presigned config.
291
+ */
292
+ async uploadFile(
293
+ file: File,
294
+ presigned: { url: string; key: string; fields: Record<string, string> },
295
+ ): Promise<Success<string> | Failure<FailurePayload>> {
296
+ const formData = new FormData();
297
+
298
+ for (const [key, value] of Object.entries(presigned.fields)) {
299
+ formData.append(key, value);
300
+ }
301
+
302
+ formData.append("file", file);
303
+
304
+ try {
305
+ const upload = await fetch(presigned.url, {
306
+ method: "POST",
307
+ body: formData,
308
+ });
309
+
310
+ if (!upload.ok) {
311
+ return new Failure({ type: "API_ERROR", code: upload.status });
312
+ }
313
+
314
+ return new Success(`/${presigned.key}`);
315
+ } catch {
316
+ return new Failure({ type: "NETWORK_ERROR" });
317
+ }
318
+ }
288
319
  }
@@ -44,3 +44,14 @@ globalStyle("body, h1, h2, h3, h4, h5, h6, p, ul, li, ol", {
44
44
  margin: 0,
45
45
  padding: 0,
46
46
  });
47
+
48
+ // Fathom SPA support depends on this image being added to the DOM, but they
49
+ // are sloppy about taking out of the document flow, meaning that on pages
50
+ // that are 100vh, there is a scrollbar flicker as the img element is added
51
+ // to the DOM and then removed. This fixes said issue.
52
+ globalStyle(`img[src^="https://cdn.usefathom.com/"]`, {
53
+ position: "absolute",
54
+ top: 0,
55
+ left: 0,
56
+ opacity: 0.01,
57
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indietabletop/appkit",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "A collection of modules used in apps built by Indie Tabletop Club",
5
5
  "private": false,
6
6
  "type": "module",