@allior/wmake-streamelements-events 2.0.2 → 2.0.3

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.
Files changed (50) hide show
  1. package/package.json +3 -10
  2. package/src/react/hooks/index.ts +0 -3
  3. package/src/react/hooks/use-event-listener.ts +0 -20
  4. package/src/react/hooks/use-on-event-received.ts +0 -108
  5. package/src/react/hooks/use-on-widget-load.ts +0 -15
  6. package/src/react/index.ts +0 -3
  7. package/src/react/types/index.ts +0 -1
  8. package/src/react/types/window-events.ts +0 -6
  9. package/src/root/aggregate.ts +0 -257
  10. package/src/root/classifier.ts +0 -271
  11. package/src/root/commands.ts +0 -39
  12. package/src/root/data/field-value.ts +0 -2
  13. package/src/root/data/index.ts +0 -2
  14. package/src/root/data/widget-load.ts +0 -5
  15. package/src/root/guards/index.ts +0 -1
  16. package/src/root/guards/on-event-received.ts +0 -58
  17. package/src/root/index.ts +0 -11
  18. package/src/root/keys.ts +0 -14
  19. package/src/root/message/index.ts +0 -1
  20. package/src/root/message/twitch/index.ts +0 -2
  21. package/src/root/message/twitch/message.ts +0 -48
  22. package/src/root/message/twitch/user-message-data.ts +0 -112
  23. package/src/root/queue/alert-queue.ts +0 -31
  24. package/src/root/queue/index.ts +0 -2
  25. package/src/root/queue/next-alert-callback.ts +0 -7
  26. package/src/root/sources/alerts.ts +0 -163
  27. package/src/root/sources/index.ts +0 -5
  28. package/src/root/sources/messages.ts +0 -1611
  29. package/src/root/sources/on-widget-load-detail.ts +0 -968
  30. package/src/root/types/index.ts +0 -2
  31. package/src/root/types/on-event-received/base.ts +0 -94
  32. package/src/root/types/on-event-received/cheer.ts +0 -10
  33. package/src/root/types/on-event-received/donation.ts +0 -29
  34. package/src/root/types/on-event-received/follower.ts +0 -9
  35. package/src/root/types/on-event-received/index.ts +0 -58
  36. package/src/root/types/on-event-received/message.ts +0 -13
  37. package/src/root/types/on-event-received/moderation.ts +0 -7
  38. package/src/root/types/on-event-received/other.ts +0 -14
  39. package/src/root/types/on-event-received/raid.ts +0 -10
  40. package/src/root/types/on-event-received/subscriber.ts +0 -77
  41. package/src/root/types/on-widget-load/base.ts +0 -35
  42. package/src/root/types/on-widget-load/index.ts +0 -3
  43. package/src/root/types/on-widget-load/recents.ts +0 -33
  44. package/src/root/types/on-widget-load/session.ts +0 -102
  45. package/src/root/window-event-map.ts +0 -9
  46. package/tsconfig.app.json +0 -31
  47. package/tsconfig.json +0 -8
  48. package/tsconfig.node.json +0 -25
  49. package/vite.config.ts +0 -36
  50. package/vite.iife.config.ts +0 -52
@@ -1,2 +0,0 @@
1
- export * from "./on-event-received";
2
- export * from "./on-widget-load";
@@ -1,94 +0,0 @@
1
- export interface EventDetail<T = string, R = unknown> {
2
- listener: T;
3
- event: R;
4
- }
5
-
6
- export interface MinimalEvent
7
- extends Partial<
8
- EventDetail<
9
- string,
10
- {
11
- type?: string;
12
- listener?: string;
13
- [key: string]: unknown;
14
- }
15
- >
16
- > {}
17
-
18
- export interface IncomingDetail {
19
- listener: string;
20
- event?: {
21
- type?: string;
22
- provider?: string;
23
- channel?: string;
24
- activityGroup?: string;
25
- activityId?: string;
26
- _id?: string;
27
- bulkGifted?: boolean;
28
- sender?: string;
29
- name?: string;
30
- amount?: number;
31
- tier?: string | number;
32
- gifted?: boolean;
33
- isCommunityGift?: boolean;
34
- communityGifted?: boolean;
35
- message?: string;
36
- data?: Record<string, unknown>;
37
- [key: string]: unknown;
38
- };
39
- }
40
-
41
- export interface TierInfo {
42
- tier: number;
43
- tierText: string;
44
- }
45
-
46
- export type NormalizedType =
47
- | "community-gift-anonymous"
48
- | "community-gift"
49
- | "self-sub"
50
- | "solo-sub-to-someone"
51
- | "sub-renewal"
52
- | "button"
53
- | "delete-message"
54
- | "delete-messages"
55
- | "follow"
56
- | "message"
57
- | "bulk-gifted-subscriptions"
58
- | "gifted-subscriptions"
59
- | "subscription-renewal"
60
- | "subscription-self"
61
- | "subscriber"
62
- | "cheer"
63
- | "raid"
64
- | "donation"
65
- | string;
66
-
67
- export interface ClassifiedBase {
68
- type: NormalizedType;
69
- }
70
-
71
- export interface ClassifiedTieredBase extends ClassifiedBase {
72
- tier: number;
73
- tierText: string;
74
- }
75
-
76
- export interface CacheLike {
77
- _has(key: string): boolean;
78
- _set(key: string, value: boolean): void;
79
- }
80
-
81
- export interface CacheSubsByType {
82
- _has?(key: string): boolean;
83
- _set?(key: string, value: boolean): void;
84
- [type: string]:
85
- | CacheLike
86
- | ((k: string) => boolean)
87
- | ((k: string, v: boolean) => void)
88
- | undefined;
89
- }
90
-
91
- export interface NormalizerOptions {
92
- cacheSubs?: CacheSubsByType;
93
- broadcasterLogin?: string;
94
- }
@@ -1,10 +0,0 @@
1
- import type { ClassifiedBase, EventDetail } from "./base";
2
-
3
- export interface CheerDetail
4
- extends EventDetail<"cheer-latest", { name: string; amount: number }> {}
5
-
6
- export interface ClassifiedCheer extends ClassifiedBase {
7
- type: "cheer";
8
- name: string;
9
- amount: number;
10
- }
@@ -1,29 +0,0 @@
1
- import type { ClassifiedBase, EventDetail } from "./base";
2
-
3
- export interface DonationDetail
4
- extends EventDetail<
5
- "donation",
6
- {
7
- data: {
8
- alert_type?: string;
9
- currency?: string;
10
- billing_system?: string;
11
- id?: number;
12
- amount_main?: number;
13
- amount?: number;
14
- username?: string;
15
- message?: string;
16
- [key: string]: unknown;
17
- };
18
- }
19
- > {}
20
-
21
- export interface ClassifiedDonation extends ClassifiedBase {
22
- type: "donation";
23
- amount: number;
24
- currency?: string;
25
- username?: string;
26
- message?: string;
27
- billingSystem?: string;
28
- id?: number;
29
- }
@@ -1,9 +0,0 @@
1
- import type { ClassifiedBase, EventDetail } from "./base";
2
-
3
- export interface FollowerDetail
4
- extends EventDetail<"follower-latest", { name: string }> {}
5
-
6
- export interface ClassifiedFollower extends ClassifiedBase {
7
- type: "follow";
8
- name: string;
9
- }
@@ -1,58 +0,0 @@
1
- export * from "./base";
2
- export * from "./cheer";
3
- export * from "./donation";
4
- export * from "./follower";
5
- export * from "./message";
6
- export * from "./moderation";
7
- export * from "./other";
8
- export * from "./raid";
9
- export * from "./subscriber";
10
-
11
- import type { CheerDetail } from "./cheer";
12
- import type { DonationDetail } from "./donation";
13
- import type { FollowerDetail } from "./follower";
14
- import type { TwitchMessageDetail } from "./message";
15
- import type { DeleteMessageDetail, DeleteMessagesDetail } from "./moderation";
16
- import type { RaidDetail } from "./raid";
17
- import type {
18
- CommunityGiftPurchaseDetail,
19
- SubscriberDetail,
20
- SubscriberLatestDetail,
21
- } from "./subscriber";
22
-
23
- export type AlertDetail =
24
- | FollowerDetail
25
- | SubscriberLatestDetail
26
- | CommunityGiftPurchaseDetail
27
- | SubscriberDetail
28
- | CheerDetail
29
- | RaidDetail
30
- | DonationDetail
31
- | DeleteMessageDetail
32
- | DeleteMessagesDetail
33
- | TwitchMessageDetail;
34
-
35
- import type { ClassifiedCheer } from "./cheer";
36
- import type { ClassifiedDonation } from "./donation";
37
- import type { ClassifiedFollower } from "./follower";
38
- import type { ClassifiedUnknown } from "./other";
39
- import type { ClassifiedRaid } from "./raid";
40
- import type {
41
- ClassifiedCommunityGiftPurchase,
42
- ClassifiedRecipient,
43
- ClassifiedSelfSub,
44
- ClassifiedSoloSub,
45
- ClassifiedSubRenewal,
46
- } from "./subscriber";
47
-
48
- export type ClassifiedEvent =
49
- | ClassifiedCommunityGiftPurchase
50
- | ClassifiedRecipient
51
- | ClassifiedSoloSub
52
- | ClassifiedSubRenewal
53
- | ClassifiedSelfSub
54
- | ClassifiedFollower
55
- | ClassifiedCheer
56
- | ClassifiedRaid
57
- | ClassifiedDonation
58
- | ClassifiedUnknown;
@@ -1,13 +0,0 @@
1
- import type { TwitchMessage } from "@/root/message";
2
-
3
- import type { EventDetail } from "./base";
4
-
5
- export interface TwitchMessageDetail
6
- extends EventDetail<
7
- "message",
8
- {
9
- service: "twitch";
10
- data: TwitchMessage.Data;
11
- renderedText: string;
12
- }
13
- > {}
@@ -1,7 +0,0 @@
1
- import type { EventDetail } from "./base";
2
-
3
- export interface DeleteMessageDetail
4
- extends EventDetail<"delete-message", { msgId: string }> {}
5
-
6
- export interface DeleteMessagesDetail
7
- extends EventDetail<"delete-messages", { userId: string }> {}
@@ -1,14 +0,0 @@
1
- import type { ClassifiedBase, EventDetail, IncomingDetail } from "./base";
2
-
3
- export type WidgetButtonDetail = EventDetail<
4
- "event:test",
5
- {
6
- listener: "widget-button";
7
- field: string;
8
- }
9
- >;
10
-
11
- export interface ClassifiedUnknown extends ClassifiedBase {
12
- type: "unknown";
13
- detail: IncomingDetail;
14
- }
@@ -1,10 +0,0 @@
1
- import type { ClassifiedBase, EventDetail } from "./base";
2
-
3
- export interface RaidDetail
4
- extends EventDetail<"raid-latest", { name: string; amount: number }> {}
5
-
6
- export interface ClassifiedRaid extends ClassifiedBase {
7
- type: "raid";
8
- name: string;
9
- viewers: number;
10
- }
@@ -1,77 +0,0 @@
1
- import type { ClassifiedTieredBase, EventDetail } from "./base";
2
-
3
- export interface SubscriberLatestDetail
4
- extends EventDetail<"subscriber-latest", { name: string; amount: number }> {}
5
-
6
- export interface SubscriberDetail
7
- extends EventDetail<
8
- "event",
9
- {
10
- type: "subscriber";
11
- provider: string;
12
- channel: string;
13
- data: {
14
- amount: number;
15
- username: string;
16
- displayName: string;
17
- tier: string;
18
- sender?: string;
19
- gifted?: boolean;
20
- message?: string;
21
- };
22
- _id: string;
23
- activityId: string;
24
- }
25
- > {}
26
-
27
- export interface CommunityGiftPurchaseDetail
28
- extends EventDetail<
29
- "event",
30
- {
31
- type: "communityGiftPurchase";
32
- provider: string;
33
- channel: string;
34
- activityGroup: string;
35
- data: {
36
- amount: number;
37
- username: string;
38
- displayName: string;
39
- tier: string;
40
- sender?: string;
41
- };
42
- _id: string;
43
- activityId: string;
44
- }
45
- > {}
46
-
47
- export interface ClassifiedCommunityGiftPurchase extends ClassifiedTieredBase {
48
- type: "community-gift" | "community-gift-anonymous";
49
- totalAmount: number;
50
- recipients: string[];
51
- sender?: string;
52
- anonymousDisplayName?: string;
53
- }
54
-
55
- export interface ClassifiedRecipient extends ClassifiedTieredBase {
56
- _role: "recipient";
57
- activityGroup: string;
58
- recipient: string;
59
- }
60
-
61
- export interface ClassifiedSoloSub extends ClassifiedTieredBase {
62
- type: "solo-sub-to-someone";
63
- sender: string;
64
- recipient: string;
65
- firstGiftInChannel?: boolean;
66
- }
67
-
68
- export interface ClassifiedSubRenewal extends ClassifiedTieredBase {
69
- type: "sub-renewal";
70
- name: string;
71
- months: number;
72
- }
73
-
74
- export interface ClassifiedSelfSub extends ClassifiedTieredBase {
75
- type: "self-sub";
76
- name: string;
77
- }
@@ -1,35 +0,0 @@
1
- import type { Recents } from "./recents";
2
- import type { Session } from "./session";
3
-
4
- export interface OnWidgetLoadEventDetails<T> {
5
- channel: Channel;
6
- currency: Currency;
7
- fieldData: FieldData<T>;
8
- overlay: Overlay;
9
- recents: Recents;
10
- session: Session;
11
- }
12
-
13
- export interface Channel {
14
- /**
15
- * StreamElements API Token (not JWT Token)
16
- */
17
- apiToken: string;
18
- avatar: string;
19
- id: string;
20
- providerId: string;
21
- username: string;
22
- }
23
-
24
- export interface Currency {
25
- code: string;
26
- name: string;
27
- symbol: string;
28
- }
29
-
30
- export type FieldData<T> = T & Record<string, unknown>;
31
-
32
- export interface Overlay {
33
- isEditorMode: boolean;
34
- muted: boolean;
35
- }
@@ -1,3 +0,0 @@
1
- export * from "./base";
2
- export * from "./recents";
3
- export * from "./session";
@@ -1,33 +0,0 @@
1
- /** Base for recent (onWidgetLoad): follower / subscriber / cheer / raid */
2
- export interface RecentItemBase {
3
- name: string;
4
- createdAt: string;
5
- }
6
-
7
- export interface RecentItemFollower extends RecentItemBase {
8
- type: "follower";
9
- }
10
-
11
- export interface RecentItemSubscriber extends RecentItemBase {
12
- type: "subscriber";
13
- tier: string;
14
- amount: number;
15
- }
16
-
17
- export interface RecentItemCheer extends RecentItemBase {
18
- type: "cheer";
19
- amount: number;
20
- }
21
-
22
- export interface RecentItemRaid extends RecentItemBase {
23
- type: "raid";
24
- amount: number;
25
- }
26
-
27
- export type RecentsItem =
28
- | RecentItemFollower
29
- | RecentItemSubscriber
30
- | RecentItemCheer
31
- | RecentItemRaid;
32
-
33
- export type Recents = RecentsItem[];
@@ -1,102 +0,0 @@
1
- export interface SessionSettings {
2
- autoReset: boolean;
3
- calendar: boolean;
4
- resetOnStart: boolean;
5
- }
6
-
7
- /** Запись в списке follower-recent / subscriber-recent / raid-recent / cheer-recent */
8
- export interface SessionRecentItem {
9
- name: string;
10
- createdAt: string;
11
- type: string;
12
- amount?: number;
13
- tier?: string;
14
- }
15
-
16
- /** Объект *-latest с полями name и amount (subscriber, cheer, tip, host, raid и т.д.) */
17
- export interface SessionLatestNamedAmount {
18
- name: string;
19
- amount: number;
20
- message?: string;
21
- tier?: string;
22
- sender?: string;
23
- redemption?: string;
24
- items?: unknown[];
25
- }
26
-
27
- /** Объект *-session / *-total и т.п. с полем count */
28
- export interface SessionCountEntry {
29
- count: number;
30
- }
31
-
32
- /** Объект *-goal / *-session (amount) и т.п. с полем amount */
33
- export interface SessionAmountEntry {
34
- amount: number;
35
- }
36
-
37
- /** Объект top-donation / top-donator */
38
- export interface SessionTopEntry {
39
- name: string;
40
- amount: number;
41
- }
42
-
43
- /** channel-points-latest */
44
- export interface SessionChannelPointsLatest {
45
- name: string;
46
- amount: number;
47
- message: string;
48
- redemption: string;
49
- }
50
-
51
- /** community-gift-latest */
52
- export interface SessionCommunityGiftLatest {
53
- name: string;
54
- amount: number;
55
- tier: string;
56
- }
57
-
58
- /** hypetrain-latest */
59
- export interface SessionHypetrainLatest {
60
- active: number;
61
- amount: number;
62
- level: number;
63
- levelChanged: number;
64
- name: string;
65
- type: string;
66
- }
67
-
68
- /** merch-latest */
69
- export interface SessionMerchLatest {
70
- name: string;
71
- amount: number;
72
- items: unknown[];
73
- }
74
-
75
- /** Элемент массива purchase-latest */
76
- export interface SessionPurchaseLatest {
77
- name: string;
78
- amount: number;
79
- avatar: string;
80
- message: string;
81
- items: unknown[];
82
- }
83
-
84
- export type SessionDataEntry =
85
- | SessionLatestNamedAmount
86
- | SessionCountEntry
87
- | SessionAmountEntry
88
- | SessionTopEntry
89
- | SessionChannelPointsLatest
90
- | SessionCommunityGiftLatest
91
- | SessionHypetrainLatest
92
- | SessionMerchLatest
93
- | SessionPurchaseLatest
94
- | SessionRecentItem[]
95
- | { name: string }
96
- | { level?: number; percent?: number; amount?: number }
97
- | Record<string, unknown>;
98
-
99
- export interface Session {
100
- data: Record<string, SessionDataEntry>;
101
- settings: SessionSettings;
102
- }
@@ -1,9 +0,0 @@
1
- import type { WidgetLoadDetail } from "./data/widget-load.js";
2
- import type { EventDetail } from "./types";
3
-
4
- declare global {
5
- interface WindowEventMap {
6
- onEventReceived: CustomEvent<EventDetail>;
7
- onWidgetLoad: CustomEvent<WidgetLoadDetail>;
8
- }
9
- }
package/tsconfig.app.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2022",
5
- "useDefineForClassFields": true,
6
- "lib": ["ES2022", "DOM", "DOM.Iterable", "dom"],
7
- "module": "ESNext",
8
- "skipLibCheck": true,
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "verbatimModuleSyntax": true,
13
- "moduleDetection": "force",
14
- "noEmit": true,
15
- "jsx": "react-jsx",
16
- /* Linting */
17
- "strict": true,
18
- "noUnusedLocals": true,
19
- "noUnusedParameters": true,
20
- "erasableSyntaxOnly": false,
21
- "noFallthroughCasesInSwitch": true,
22
- "noUncheckedSideEffectImports": true,
23
- "baseUrl": ".",
24
- "paths": {
25
- "#/*": ["./src/common/*"],
26
- "@/*": ["./src/*"]
27
- }
28
- },
29
- "include": ["src"],
30
- "exclude": ["node_modules", "dist"]
31
- }
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "files": [],
3
- "references": [
4
- { "path": "./tsconfig.app.json" },
5
- { "path": "./tsconfig.types.json" },
6
- { "path": "./tsconfig.node.json" }
7
- ]
8
- }
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
- "target": "ES2023",
5
- "lib": ["ES2023"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
-
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "verbatimModuleSyntax": true,
13
- "moduleDetection": "force",
14
- "noEmit": true,
15
-
16
- /* Linting */
17
- "strict": true,
18
- "noUnusedLocals": true,
19
- "noUnusedParameters": true,
20
- "erasableSyntaxOnly": false,
21
- "noFallthroughCasesInSwitch": true,
22
- "noUncheckedSideEffectImports": true
23
- },
24
- "include": ["vite.config.ts"]
25
- }
package/vite.config.ts DELETED
@@ -1,36 +0,0 @@
1
- import { dirname, resolve } from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import react from "@vitejs/plugin-react";
4
- import { defineConfig } from "vite";
5
-
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
-
8
- export default defineConfig({
9
- plugins: [react()],
10
- resolve: {
11
- alias: {
12
- "@": resolve(__dirname, "src"),
13
- "@/root": resolve(__dirname, "src/root/index.ts"),
14
- },
15
- },
16
- build: {
17
- copyPublicDir: false,
18
- lib: {
19
- entry: {
20
- "root/index": resolve(__dirname, "src/root/index.ts"),
21
- "react/index": resolve(__dirname, "src/react/index.ts"),
22
- },
23
- formats: ["es"],
24
- },
25
- sourcemap: true,
26
- outDir: "dist",
27
- rollupOptions: {
28
- external: ["react", "react/jsx-runtime"],
29
- output: {
30
- format: "es",
31
- exports: "named",
32
- entryFileNames: "[name].js",
33
- },
34
- },
35
- },
36
- });
@@ -1,52 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import react from "@vitejs/plugin-react";
3
- import { resolve, dirname } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
-
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
- const entry = process.env.VITE_IIFE_ENTRY ?? "root";
8
- const entryMap: Record<string, { path: string; name: string; out: string }> = {
9
- root: {
10
- path: "src/root/index.ts",
11
- name: "WmakeStreamelementsEvents",
12
- out: "root/index.iife.js",
13
- },
14
- react: {
15
- path: "src/react/index.ts",
16
- name: "WmakeStreamelementsEventsReact",
17
- out: "react/index.iife.js",
18
- },
19
- };
20
- const {
21
- path: entryPath,
22
- name: globalName,
23
- out: entryFileNames,
24
- } = entryMap[entry] ?? entryMap.root;
25
-
26
- export default defineConfig({
27
- plugins: [react()],
28
- resolve: {
29
- alias: { "@": resolve(__dirname, "src") },
30
- },
31
- build: {
32
- emptyOutDir: false,
33
- lib: {
34
- entry: resolve(__dirname, entryPath),
35
- name: globalName,
36
- formats: ["iife"],
37
- },
38
- sourcemap: true,
39
- outDir: "dist",
40
- rollupOptions: {
41
- external: ["react", "react/jsx-runtime"],
42
- output: {
43
- entryFileNames,
44
- extend: true,
45
- globals: {
46
- react: "React",
47
- "react/jsx-runtime": "ReactJSXRuntime",
48
- },
49
- },
50
- },
51
- },
52
- });