@indietabletop/appkit 2.0.0 → 3.0.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/README.md CHANGED
@@ -13,7 +13,7 @@ A collection of modules used in Indie Tabletop Club's apps.
13
13
 
14
14
  ### Hooks
15
15
 
16
- - useAsyncPp
16
+ - useAsyncOp
17
17
  - useDocumentBackgroundColor
18
18
  - useIsInstalled
19
19
  - useMediaQuery
@@ -68,6 +68,18 @@ export declare class Failure<FailureValue> implements Operation<never, FailureVa
68
68
  mapFailure<MappedFailure>(mappingFn: (value: FailureValue) => MappedFailure): Failure<MappedFailure>;
69
69
  unpack<S, F, P>(_mapS: (value: never) => S, mapF: (failure: FailureValue) => F, _mapP: () => P): S | F | P;
70
70
  }
71
+ /**
72
+ * Folds multiple ops into a single op.
73
+ *
74
+ * To return a Success, all ops provided must be a Success. If any Failures are
75
+ * encountered, will return the first one found.
76
+ *
77
+ * If neither of these conditions is true, will return Pending.
78
+ *
79
+ * Note that if passed an empty array, will always return a Success (with an
80
+ * empty array as value). This mimics the semantics of many JS constructs, like
81
+ * Promise.all or Array.prototype.every.
82
+ */
71
83
  export declare function fold<Ops extends readonly AsyncOp<unknown, unknown>[] | []>(ops: Ops): AsyncOp<{
72
84
  -readonly [Index in keyof Ops]: Ops[Index] extends AsyncOp<infer S, unknown> ? S : never;
73
85
  }, Ops[number] extends AsyncOp<unknown, infer F> ? F : never>;
package/dist/async-op.js CHANGED
@@ -197,7 +197,21 @@ export class Failure {
197
197
  return mapF(this.failure);
198
198
  }
199
199
  }
200
+ /**
201
+ * Folds multiple ops into a single op.
202
+ *
203
+ * To return a Success, all ops provided must be a Success. If any Failures are
204
+ * encountered, will return the first one found.
205
+ *
206
+ * If neither of these conditions is true, will return Pending.
207
+ *
208
+ * Note that if passed an empty array, will always return a Success (with an
209
+ * empty array as value). This mimics the semantics of many JS constructs, like
210
+ * Promise.all or Array.prototype.every.
211
+ */
200
212
  export function fold(ops) {
213
+ // Note that due to the semantics of `every`, if the array provided to `fold`
214
+ // is empty, the result will be a Success with an empty array.
201
215
  if (ops.every((v) => v.isSuccess)) {
202
216
  return new Success(ops.map((op) => op.value));
203
217
  }
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?;
@@ -55,6 +55,7 @@ export declare class IndieTabletopClient {
55
55
  email: string;
56
56
  password: string;
57
57
  acceptedTos: boolean;
58
+ subscribedToNewsletter: boolean;
58
59
  }): Promise<Failure<FailurePayload> | Success<{
59
60
  sessionInfo: {
60
61
  expiresTs: number;
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) {
@@ -126,6 +126,7 @@ export class IndieTabletopClient {
126
126
  email: payload.email,
127
127
  plaintextPassword: payload.password,
128
128
  acceptedTos: payload.acceptedTos,
129
+ subscribedToNewsletter: payload.subscribedToNewsletter,
129
130
  },
130
131
  });
131
132
  if (res.isSuccess) {
@@ -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 {};
@@ -0,0 +1,14 @@
1
+ export * from "./append-copy-to-text.ts";
2
+ export * from "./async-op.ts";
3
+ export * from "./caught-value.ts";
4
+ export * from "./class-names.ts";
5
+ export * from "./client.ts";
6
+ export * from "./external-link.tsx";
7
+ export * from "./structs.ts";
8
+ export * from "./types.ts";
9
+ export * from "./use-async-op.ts";
10
+ export * from "./use-document-background-color.ts";
11
+ export * from "./use-is-installed.ts";
12
+ export * from "./use-media-query.ts";
13
+ export * from "./use-reverting-state.ts";
14
+ export * from "./use-scroll-restoration.ts";
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ export * from "./append-copy-to-text.js";
2
+ export * from "./async-op.js";
3
+ export * from "./caught-value.js";
4
+ export * from "./class-names.js";
5
+ export * from "./client.js";
6
+ export * from "./external-link.js";
7
+ export * from "./structs.js";
8
+ export * from "./types.js";
9
+ export * from "./use-async-op.js";
10
+ export * from "./use-document-background-color.js";
11
+ export * from "./use-is-installed.js";
12
+ export * from "./use-media-query.js";
13
+ export * from "./use-reverting-state.js";
14
+ export * from "./use-scroll-restoration.js";
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>>;
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": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "A collection of modules used in apps built by Indie Tabletop Club",
5
5
  "private": false,
6
6
  "type": "module",
@@ -24,8 +24,8 @@
24
24
  "devDependencies": {
25
25
  "@types/react": "^19.0.8",
26
26
  "np": "^10.1.0",
27
- "typescript": "^5.7.2",
28
- "vitest": "^2.1.6"
27
+ "typescript": "^5.8.2",
28
+ "vitest": "^3.0.5"
29
29
  },
30
30
  "dependencies": {
31
31
  "superstruct": "^2.0.2"