@indietabletop/appkit 1.0.1 → 2.1.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/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Failure, Success } from "@indietabletop/appkit/async-op";
2
- import { Infer, Struct } from "superstruct";
3
- import { CurrentUser, FailurePayload, SessionInfo } from "./types.js";
2
+ import { type Infer, Struct } from "superstruct";
3
+ import type { CurrentUser, FailurePayload, SessionInfo } from "./types.js";
4
4
  export declare class IndieTabletopClient {
5
5
  origin: string;
6
6
  private onCurrentUser?;
package/dist/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Failure, Success } from "@indietabletop/appkit/async-op";
2
- import { mask, object, string } from "superstruct";
2
+ import { mask, object, string, Struct } from "superstruct";
3
3
  import { currentUser, sessionInfo } from "./structs.js";
4
4
  export class IndieTabletopClient {
5
5
  constructor(props) {
@@ -55,15 +55,20 @@ export class IndieTabletopClient {
55
55
  headers,
56
56
  });
57
57
  if (!res.ok) {
58
- return new Failure({
59
- type: "API_ERROR",
60
- code: res.status,
61
- });
58
+ console.error(res);
59
+ return new Failure({ type: "API_ERROR", code: res.status });
60
+ }
61
+ try {
62
+ const data = mask(await res.json(), struct);
63
+ return new Success(data);
64
+ }
65
+ catch (error) {
66
+ console.error(error);
67
+ return new Failure({ type: "VALIDATION_ERROR" });
62
68
  }
63
- const data = mask(await res.json(), struct);
64
- return new Success(data);
65
69
  }
66
70
  catch (error) {
71
+ console.error(error);
67
72
  if (error instanceof Error) {
68
73
  return new Failure({ type: "NETWORK_ERROR" });
69
74
  }
@@ -0,0 +1,34 @@
1
+ import type { ConfigEnv, PluginOption, UserConfig } from "vite";
2
+ export declare function defineNetlifyConfig(props: {
3
+ /**
4
+ * The server port number.
5
+ *
6
+ * Game apps start from 8000, automation apps from 9000. So far, we got:
7
+ *
8
+ * - API: 8000
9
+ * - Hobgoblin: 8001
10
+ * - Eternol: 8002
11
+ * - Gregbot: 9000
12
+ */
13
+ port: number;
14
+ /**
15
+ * By default, react and vanilla extract are always configured.
16
+ */
17
+ additionalPlugins?: PluginOption[];
18
+ /**
19
+ * Can be used to import from `@` at the path specified here. Has to match
20
+ * tsconfig > compilerOptions > paths.
21
+ *
22
+ * Do not use this, just use relative imports.
23
+ *
24
+ * @deprecated
25
+ */
26
+ resolveAlias?: string;
27
+ /**
28
+ * Determines whether input is "/index.html", or "index.html" or
29
+ * "/src/main.tsx" depnending on command.
30
+ *
31
+ * This is useful when using pre-rendered HTML as input.
32
+ */
33
+ conditionalInput?: boolean;
34
+ }): ({ command }: ConfigEnv) => UserConfig;
@@ -0,0 +1,35 @@
1
+ import { vanillaExtractPlugin as vanilla } from "@vanilla-extract/vite-plugin";
2
+ import react from "@vitejs/plugin-react";
3
+ export function defineNetlifyConfig(props) {
4
+ const { additionalPlugins = [], conditionalInput = false, resolveAlias, } = props;
5
+ return function configureVite({ command }) {
6
+ return {
7
+ define: {
8
+ // These vars are supplied by Netlify
9
+ BRANCH: JSON.stringify(process.env.BRANCH),
10
+ COMMIT_SHORTCODE: JSON.stringify(process.env.COMMIT_REF?.slice(0, 7)),
11
+ },
12
+ plugins: [react(), vanilla(), ...additionalPlugins],
13
+ esbuild: {
14
+ target: "es2022",
15
+ },
16
+ server: {
17
+ port: props.port,
18
+ },
19
+ resolve: {
20
+ alias: resolveAlias ? { "@": resolveAlias } : undefined,
21
+ },
22
+ build: {
23
+ sourcemap: true,
24
+ manifest: true,
25
+ rollupOptions: {
26
+ // During `build`, we want to only deal with JS files. Production HTML
27
+ // entrypoint is generated via the `build:entrypoint` package script.
28
+ input: conditionalInput && command === "build"
29
+ ? "/src/main.tsx"
30
+ : "/index.html",
31
+ },
32
+ },
33
+ };
34
+ };
35
+ }
@@ -1,4 +1,4 @@
1
- import { AnchorHTMLAttributes } from "react";
1
+ import type { AnchorHTMLAttributes } from "react";
2
2
  type ExternalLinkProps = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "rel" | "target">;
3
3
  export declare function ExternalLink(props: ExternalLinkProps): import("react/jsx-runtime").JSX.Element;
4
4
  export {};
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Infer } from "superstruct";
1
+ import type { Infer } from "superstruct";
2
2
  import { currentUser, sessionInfo } from "./structs.js";
3
3
  export type CurrentUser = Infer<ReturnType<typeof currentUser>>;
4
4
  export type SessionInfo = Infer<ReturnType<typeof sessionInfo>>;
@@ -6,5 +6,5 @@ export type FailurePayload = {
6
6
  type: "API_ERROR";
7
7
  code: number;
8
8
  } | {
9
- type: "NETWORK_ERROR" | "UNKNOWN_ERROR";
9
+ type: "NETWORK_ERROR" | "UNKNOWN_ERROR" | "VALIDATION_ERROR";
10
10
  };
package/dist/types.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ import { currentUser, sessionInfo } from "./structs.js";
@@ -1,4 +1,4 @@
1
- import { AsyncOp } from "./async-op.js";
1
+ import { type AsyncOp } from "./async-op.js";
2
2
  export declare function useAsyncOp<T, E>(): {
3
3
  op: AsyncOp<T, E>;
4
4
  setSuccess: (value: T) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indietabletop/appkit",
3
- "version": "1.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "A collection of modules used in apps built by Indie Tabletop Club",
5
5
  "private": false,
6
6
  "type": "module",
@@ -19,15 +19,19 @@
19
19
  "repository": "github:indietabletop/appkit",
20
20
  "license": "MIT",
21
21
  "peerDependencies": {
22
- "react": "^18.0.0 || ^19.0.0"
22
+ "react": "^18.0.0 || ^19.0.0",
23
+ "vite": "^6.0.0"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@types/react": "^19.0.8",
26
27
  "np": "^10.1.0",
27
28
  "typescript": "^5.7.2",
28
- "vitest": "^2.1.6"
29
+ "vitest": "^3.0.5"
29
30
  },
30
31
  "dependencies": {
31
- "superstruct": "^2.0.2"
32
+ "@vanilla-extract/vite-plugin": "^5.0.0",
33
+ "@vitejs/plugin-react": "^4.3.4",
34
+ "superstruct": "^2.0.2",
35
+ "vite": "^6.1.0"
32
36
  }
33
37
  }