@sdeck/twitch 0.0.0-stage → 1.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
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
1
+ # Twitch
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Run your Twitch channel from [sdeck](https://github.com/ivanoliverfabra/sdeck).
4
+
5
+ - **The stream**: create a clip, add a marker, change title or category, play an ad, snooze the next
6
+ one, raid a channel.
7
+ - **Chat**: emotes, subscribers or followers only, slow mode, no repeated messages; send a message,
8
+ announce, shout out a channel, clear chat.
9
+ - **Shield Mode**
10
+ - **Stream status** and **Followers** keys, and live values such as `twitch.live`, `twitch.viewers`,
11
+ `twitch.uptime` and `twitch.nextAd`.
12
+ - **Triggers**: going live and ending, follows, subscriptions, gifts, cheers, raids, channel points,
13
+ ads, and chat commands (with who may use them).
14
+
15
+ Ads, channel points and some others need a channel that is an affiliate or partner.
16
+
17
+ ## Setting up
18
+
19
+ Twitch lets apps in with a client id of your own:
20
+
21
+ 1. Open the [developer console](https://dev.twitch.tv/console/apps) and press **Register Your
22
+ Application**. Your account needs two-factor authentication for this.
23
+ 2. Give it any name, the redirect URL `http://localhost:3000`, a category, and the client type
24
+ **Public**.
25
+ 3. Open it with **Manage** and copy its **Client ID** into the plugin's settings. It needs no secret.
26
+ 4. Press **Sign in**, and allow access with the account you stream from.
27
+
28
+ The sign-in is kept with sdeck's secrets. **Sign out** ends it.
@@ -0,0 +1,4 @@
1
+ export declare const actions: import("@sdeck/plugin").Action[];
2
+ /** Titles of the channel's rewards, for the trigger. */
3
+ export declare const rewards: import("@sdeck/plugin").Source;
4
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAsjBA,eAAO,MAAM,OAAO,kCAenB,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,OAAO,gCAYlB,CAAC"}
package/dist/api.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Twitch's API, signed in with the device code flow: the user's own client id, no client secret,
3
+ * and nothing listening for a redirect. https://dev.twitch.tv/docs/authentication/
4
+ */
5
+ export declare const SCOPES: string[];
6
+ export interface Endpoints {
7
+ id: string;
8
+ api: string;
9
+ events: string;
10
+ }
11
+ export declare const TWITCH: Endpoints;
12
+ export interface User {
13
+ id: string;
14
+ login: string;
15
+ }
16
+ export interface SignIn {
17
+ /** Where to send the user. The code is filled in there. */
18
+ url: string;
19
+ /** What the page shows, to compare. */
20
+ code: string;
21
+ /** Resolves once they approved and the tokens are saved. */
22
+ done: Promise<void>;
23
+ cancel(): void;
24
+ }
25
+ export interface ClientOptions {
26
+ clientId(): string;
27
+ tokens: {
28
+ get(): string | undefined;
29
+ set(refresh: string | undefined): Promise<void>;
30
+ };
31
+ endpoints?: Endpoints;
32
+ }
33
+ export type Method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
34
+ /** Not signed in: there is nothing to retry until the user signs in. */
35
+ export declare class SignedOut extends Error {
36
+ constructor(message?: string);
37
+ }
38
+ /** Twitch refused a request. */
39
+ export declare class TwitchError extends Error {
40
+ readonly status: number;
41
+ constructor(status: number, message: string);
42
+ }
43
+ export declare class TwitchClient {
44
+ #private;
45
+ constructor(options: ClientOptions);
46
+ get signedIn(): boolean;
47
+ get eventsUrl(): string;
48
+ /** Asks Twitch for a code, and waits for the user to approve it in the browser. */
49
+ signIn(): Promise<SignIn>;
50
+ signOut(): Promise<void>;
51
+ /** Who is signed in. */
52
+ user(): Promise<User>;
53
+ /** Calls the API. Resolves with the items of its answer. */
54
+ request<T = Record<string, unknown>>(method: Method, path: string, query?: Record<string, string>, body?: unknown): Promise<T[]>;
55
+ /** As {@link request}, with everything else the answer holds (`total`). */
56
+ call(method: Method, path: string, query?: Record<string, string>, body?: unknown): Promise<Record<string, unknown> & {
57
+ data: unknown[];
58
+ }>;
59
+ }
60
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,MAAM,UAkBlB,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,MAAM,EAAE,SAIpB,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,MAAM;IACrB,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,IAAI,MAAM,CAAC;IACnB,MAAM,EAAE;QACN,GAAG,IAAI,MAAM,GAAG,SAAS,CAAC;QAC1B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACjD,CAAC;IACF,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEjE,wEAAwE;AACxE,qBAAa,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAO,SAAiD,EAEnE;CACF;AAED,gCAAgC;AAChC,qBAAa,WAAY,SAAQ,KAAK;IAElC,QAAQ,CAAC,MAAM,EAAE,MAAM;IADzB,YACW,MAAM,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,EAGhB;CACF;AAsBD,qBAAa,YAAY;;IAQvB,YAAY,OAAO,EAAE,aAAa,EAGjC;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,mFAAmF;IAC7E,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAuC9B;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAM7B;IAED,wBAAwB;IAClB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1B;IAED,4DAA4D;IACtD,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EAClC,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,CAAC,EAAE,CAAC,CAEd;IAED,2EAA2E;IACrE,IAAI,CACR,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EAClC,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,CAmCxD;CA+EF"}
@@ -0,0 +1,22 @@
1
+ /** What happens on the channel, over EventSub's WebSocket: https://dev.twitch.tv/docs/eventsub/ */
2
+ import { type Link } from "@sdeck/plugin";
3
+ import { type TwitchClient, type User } from "./api.ts";
4
+ export interface ChannelEvent {
5
+ /** Twitch's name for it, such as `channel.follow`. */
6
+ type: string;
7
+ data: Record<string, unknown>;
8
+ }
9
+ interface Wanted {
10
+ type: string;
11
+ version: string;
12
+ condition: Record<string, string>;
13
+ }
14
+ /** Everything the triggers need, on the user's own channel. */
15
+ export declare function subscriptions({ id }: User): Wanted[];
16
+ /**
17
+ * Connects and subscribes. Resolves once events come in. What the channel cannot have (channel
18
+ * points need an affiliate) is left out and told to `log`.
19
+ */
20
+ export declare function connectEvents(client: TwitchClient, onEvent: (event: ChannelEvent) => void, lost: (error: Error) => void, signal: AbortSignal, log?: (...args: unknown[]) => void): Promise<Link<User>>;
21
+ export {};
22
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAE,KAAK,IAAI,EAAkB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAa,KAAK,YAAY,EAAE,KAAK,IAAI,EAAE,MAAM,UAAU,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,UAAU,MAAM;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,GAAG,MAAM,EAAE,CAmBpD;AAgBD;;;GAGG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,EACtC,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAC5B,MAAM,EAAE,WAAW,EACnB,GAAG,GAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAe,GAC3C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CA2GrB"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@sdeck/plugin").PluginDef;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":""}