@pixl-app/sdk 0.1.0 → 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.
@@ -0,0 +1,14 @@
1
+ import type { StreamElementsProxyPath } from "./api-types/index.js";
2
+ import type { Pixl } from "./client.js";
3
+ export declare class PixlStreamElements {
4
+ private readonly pixl;
5
+ constructor(pixl: Pixl);
6
+ /**
7
+ * Lesender Zugriff auf den verbundenen StreamElements-Kanal. pixl reicht die Anfrage mit
8
+ * dem hinterlegten Overlay Token weiter (der Token bleibt bei pixl). Braucht
9
+ * `streamelements:read`. `params` gehen 1:1 an StreamElements, die Antwort kommt unverändert.
10
+ */
11
+ get<T = unknown>(path: StreamElementsProxyPath, params?: Record<string, string | number | undefined>, options?: {
12
+ signal?: AbortSignal;
13
+ }): Promise<T>;
14
+ }
package/dist/tts.d.ts CHANGED
@@ -6,7 +6,8 @@ export type TtsVoiceInfo = {
6
6
  id: string;
7
7
  name: string;
8
8
  language: string;
9
- gender: "female" | "male";
9
+ /** Bei Stimmen aus Katalogen nicht immer bekannt */
10
+ gender?: "female" | "male";
10
11
  description: string;
11
12
  /** Credits pro Zeichen */
12
13
  creditsPerChar?: number;
@@ -76,25 +77,35 @@ export declare class PixlTts {
76
77
  * Credits des Kanals. Ohne `voice` gilt die Standardstimme des Kanals.
77
78
  * Abgespielt wird nicht hier, sondern in jedem Overlay mit `player()`.
78
79
  * `filters: false` schaltet Links, Wiederholungen und gesperrte Wörter ab, oder
79
- * einzeln, z.B. `{ links: false }`.
80
+ * einzeln, z.B. `{ links: false }`. In der Vorschau in pixl ist es nur dort zu hören. Beim Bedienen
81
+ * liest dort die Browserquelle vor, wenn eine verbunden ist, die Vorschau spielt es dann mit ab und
82
+ * speak() wirft einen PixlError mit `problem: "preview"`.
80
83
  */
81
84
  speak(text: string, options?: {
82
85
  voice?: string;
83
86
  filters?: TtsFilters | false;
87
+ signal?: AbortSignal;
84
88
  }): Promise<TtsSpoken>;
89
+ private get base();
85
90
  /** Verfügbare Stimmen und die Standardstimme des Kanals */
86
- voices(): Promise<{
91
+ voices(options?: {
92
+ signal?: AbortSignal;
93
+ }): Promise<{
87
94
  voices: TtsVoiceInfo[];
88
95
  default: string;
89
96
  }>;
90
97
  /** Audio eines Eintrags als MP3 (Schlüssel mit `tts:read`) */
91
- audio(id: string): Promise<Blob>;
98
+ audio(id: string, options?: {
99
+ signal?: AbortSignal;
100
+ }): Promise<Blob>;
92
101
  /**
93
102
  * Zeitmarken pro Wort zu einem Eintrag (Schlüssel mit `tts:read`). Entstehen beim
94
103
  * ersten Abruf und kosten dann beim Anbieter extra, danach kommen sie aus dem
95
- * Zwischenspeicher. Wirft einen PixlApiError (404), wenn es keine gibt.
104
+ * Zwischenspeicher. Wirft einen PixlError (`not_found`), wenn es keine gibt.
96
105
  */
97
- marks(id: string): Promise<TtsMark[]>;
106
+ marks(id: string, options?: {
107
+ signal?: AbortSignal;
108
+ }): Promise<TtsMark[]>;
98
109
  /** Spielt jedes `tts.ready` der Reihe nach ab, hört auf Überspringen und Stoppen aus pixl. Braucht `tts:read`. */
99
110
  player(options?: TtsPlayerOptions): TtsPlayer;
100
111
  }
@@ -108,9 +119,7 @@ export declare class TtsPlayer {
108
119
  private volume;
109
120
  private destroyed;
110
121
  private warnedAutoplay;
111
- private readonly onReady;
112
- private readonly onSkip;
113
- private readonly onClear;
122
+ private readonly unsubscribe;
114
123
  constructor(pixl: Pixl, tts: PixlTts, options: TtsPlayerOptions);
115
124
  /** Was gerade läuft abbrechen, danach geht es mit dem Nächsten weiter */
116
125
  skip(): void;
@@ -0,0 +1,68 @@
1
+ import { type EventPayloads, type HypeTrain, type Money, type PollChoice, type PredictionOutcome } from "./api-types/index.js";
2
+ import type { Pixl } from "./client.js";
3
+ import { type LiveValue } from "./live-value.js";
4
+ export type { HypeTrain };
5
+ export type SubCount = EventPayloads["subs.updated"];
6
+ /** Letzte Umfrage, bleibt nach dem Ende mit ihrem Ergebnis stehen, bis eine neue beginnt */
7
+ export type Poll = {
8
+ title: string;
9
+ choices: PollChoice[];
10
+ status: "active" | "completed" | "archived" | "terminated";
11
+ };
12
+ /** Letzte Vorhersage, bleibt nach dem Ende stehen, bis eine neue beginnt */
13
+ export type Prediction = {
14
+ title: string;
15
+ outcomes: PredictionOutcome[];
16
+ status: "active" | "locked" | "resolved" | "canceled";
17
+ /** Titel des Gewinners, solange offen null */
18
+ winner: string | null;
19
+ };
20
+ /** Letztes Ziel des Kanals, bleibt nach dem Ende stehen */
21
+ export type Goal = {
22
+ type: string;
23
+ description: string;
24
+ current: number;
25
+ target: number;
26
+ active: boolean;
27
+ achieved: boolean;
28
+ };
29
+ /** Letzte Spendenaktion, bleibt nach dem Ende stehen */
30
+ export type Charity = {
31
+ charity: string;
32
+ current: Money;
33
+ target: Money;
34
+ active: boolean;
35
+ };
36
+ /** Laufende Werbepause */
37
+ export type AdBreak = {
38
+ durationSec: number;
39
+ startedAt: string;
40
+ endsAt: string;
41
+ };
42
+ export declare class PixlTwitch {
43
+ private readonly pixl;
44
+ /** Aktive Subs und Sub-Punkte laut Twitch (Scope `subs:read`), null solange unbekannt */
45
+ readonly subs: LiveValue<SubCount | null>;
46
+ /** Laufender Hype Train, null wenn keiner fährt */
47
+ readonly hypeTrain: LiveValue<HypeTrain | null>;
48
+ /** Letzte Umfrage */
49
+ readonly poll: LiveValue<Poll | null>;
50
+ /** Letzte Vorhersage */
51
+ readonly prediction: LiveValue<Prediction | null>;
52
+ /** Letztes Ziel */
53
+ readonly goal: LiveValue<Goal | null>;
54
+ /** Letzte Spendenaktion */
55
+ readonly charity: LiveValue<Charity | null>;
56
+ /** Laufende Werbepause, null wenn keine läuft */
57
+ readonly adBreak: LiveValue<AdBreak | null>;
58
+ private readonly values;
59
+ private adBreakTimer;
60
+ constructor(pixl: Pixl);
61
+ /** Aktuelle Sub-Zahl direkt abfragen (höchstens 60 s alt). Meist reicht `subs`. */
62
+ fetchSubs(options?: {
63
+ signal?: AbortSignal;
64
+ }): Promise<SubCount>;
65
+ private load;
66
+ /** @internal */
67
+ _close(): void;
68
+ }
@@ -0,0 +1,27 @@
1
+ export declare class PixlCheckbox extends HTMLElement {
2
+ static formAssociated: boolean;
3
+ static observedAttributes: string[];
4
+ private readonly root;
5
+ private readonly control;
6
+ private readonly internals;
7
+ private formDisabled;
8
+ private defaultChecked;
9
+ private toggledThisTask;
10
+ constructor();
11
+ connectedCallback(): void;
12
+ private syncText;
13
+ attributeChangedCallback(): void;
14
+ get checked(): boolean;
15
+ set checked(v: boolean);
16
+ get disabled(): boolean;
17
+ set disabled(v: boolean);
18
+ get name(): string;
19
+ get value(): string;
20
+ get form(): HTMLFormElement | null;
21
+ formResetCallback(): void;
22
+ formDisabledCallback(disabled: boolean): void;
23
+ formStateRestoreCallback(state: string | null): void;
24
+ private get isDisabled();
25
+ private toggleByUser;
26
+ private sync;
27
+ }
@@ -0,0 +1,2 @@
1
+ /** Alle Bausteine registrieren (mehrfaches Aufrufen schadet nicht) */
2
+ export declare function defineElements(): void;
@@ -0,0 +1,15 @@
1
+ export declare class PixlDialog extends HTMLElement {
2
+ static observedAttributes: string[];
3
+ private readonly root;
4
+ private readonly dialog;
5
+ private isOpen;
6
+ constructor();
7
+ attributeChangedCallback(): void;
8
+ private sync;
9
+ /** Ist der Dialog offen? */
10
+ get opened(): boolean;
11
+ open(): void;
12
+ close(): void;
13
+ private closed;
14
+ disconnectedCallback(): void;
15
+ }
@@ -0,0 +1,48 @@
1
+ export type DropdownOption = {
2
+ value: string;
3
+ label: string;
4
+ disabled?: boolean;
5
+ };
6
+ /** Höhe eines Eintrags und Innenabstand der Liste in px, wie im Dashboard (h-8, p-1, Rahmen) */
7
+ export declare const ITEM_HEIGHT = 32;
8
+ export declare const LIST_CHROME = 10;
9
+ /** Abstand zwischen Feld und Liste, Mindestbreite und Abstand zum Fensterrand */
10
+ export declare const GAP = 6;
11
+ export declare const MIN_WIDTH = 160;
12
+ export declare const EDGE = 8;
13
+ /** Höchstens so hoch wird die Liste, darüber scrollt sie */
14
+ export declare const MAX_HEIGHT = 320;
15
+ /** Optionen aus Strings oder Objekten auf eine Form bringen */
16
+ export declare function normalizeOptions(input: unknown): DropdownOption[];
17
+ /** Nächster wählbarer Eintrag ab from in Richtung step (1 oder -1), ohne Umlauf. -1, wenn keiner */
18
+ export declare function nextEnabled(options: DropdownOption[], from: number, step: 1 | -1): number;
19
+ /** Erster bzw. letzter wählbarer Eintrag */
20
+ export declare function firstEnabled(options: DropdownOption[]): number;
21
+ export declare function lastEnabled(options: DropdownOption[]): number;
22
+ /**
23
+ * Tippen zum Springen: Eintrag, dessen Beschriftung mit query beginnt. Besteht query nur aus
24
+ * einem Buchstaben (auch mehrfach getippt, „aaa“), geht es reihum durch alle mit diesem
25
+ * Anfang, sonst bleibt der aktuelle Eintrag, solange er noch passt. -1, wenn nichts passt.
26
+ */
27
+ export declare function typeaheadIndex(options: DropdownOption[], query: string, current: number): number;
28
+ export type Rect = {
29
+ top: number;
30
+ bottom: number;
31
+ left: number;
32
+ width: number;
33
+ };
34
+ export type Placement = {
35
+ top: number;
36
+ left: number;
37
+ width: number;
38
+ maxHeight: number;
39
+ above: boolean;
40
+ };
41
+ /**
42
+ * Wo die Liste hinkommt (position: fixed): unter das Feld, nach oben, wenn unten zu wenig Platz
43
+ * ist und oben mehr. Mindestens so breit wie das Feld, nie über den Fensterrand.
44
+ */
45
+ export declare function placeList(trigger: Rect, listHeight: number, viewport: {
46
+ width: number;
47
+ height: number;
48
+ }, maxHeight?: number): Placement;
@@ -0,0 +1,65 @@
1
+ import { type DropdownOption } from "./dropdown-helpers.js";
2
+ export type { DropdownOption };
3
+ export declare const CHEVRON_ICON = "<svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"m6 9 6 6 6-6\"/></svg>";
4
+ export declare const CHECK_ICON = "<svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M20 6 9 17l-5-5\"/></svg>";
5
+ export declare class PixlDropdown extends HTMLElement {
6
+ static formAssociated: boolean;
7
+ static observedAttributes: string[];
8
+ private readonly root;
9
+ private readonly trigger;
10
+ private readonly text;
11
+ private readonly list;
12
+ private readonly internals;
13
+ private readonly uid;
14
+ private propOptions;
15
+ private childOptions;
16
+ private observer;
17
+ private highlighted;
18
+ private query;
19
+ private queryTimer;
20
+ private formDisabled;
21
+ private defaultValue;
22
+ private listening;
23
+ private frame;
24
+ private lastRect;
25
+ constructor();
26
+ connectedCallback(): void;
27
+ disconnectedCallback(): void;
28
+ attributeChangedCallback(): void;
29
+ /** Optionen. Gesetzt gehen sie den <option>-Kindern vor, null nimmt wieder die Kinder */
30
+ get options(): DropdownOption[];
31
+ set options(value: (DropdownOption | string)[] | null);
32
+ /** Gewählter Wert, "" wenn nichts gewählt ist */
33
+ get value(): string;
34
+ set value(v: string);
35
+ get disabled(): boolean;
36
+ set disabled(v: boolean);
37
+ get name(): string;
38
+ /** Beschriftung der gewählten Option */
39
+ get selectedLabel(): string;
40
+ get form(): HTMLFormElement | null;
41
+ /** Liste öffnen */
42
+ open(): void;
43
+ /** Liste schließen */
44
+ close(): void;
45
+ get isOpen(): boolean;
46
+ formResetCallback(): void;
47
+ formDisabledCallback(disabled: boolean): void;
48
+ formStateRestoreCallback(state: string | null): void;
49
+ private readChildren;
50
+ private render;
51
+ private labelText;
52
+ private renderList;
53
+ private beforeOpen;
54
+ private afterOpen;
55
+ private afterClose;
56
+ private onViewportChange;
57
+ private rectKey;
58
+ private follow;
59
+ private onOutsidePointer;
60
+ private position;
61
+ private highlight;
62
+ private pick;
63
+ private onKeydown;
64
+ private typeahead;
65
+ }
@@ -0,0 +1,48 @@
1
+ import type { WidgetField, WidgetFieldScope, WidgetOperation } from "../api-types/index.js";
2
+ import type { PixlWidget } from "../widget.js";
3
+ /** @internal Gemeinsame Grundlage für alle Bausteine, die ein Feld des Widgets brauchen */
4
+ export declare abstract class WidgetBoundElement extends HTMLElement {
5
+ protected widget: PixlWidget | null;
6
+ protected readonly root: ShadowRoot;
7
+ private unsubscribe;
8
+ private connected;
9
+ constructor();
10
+ get fieldName(): string;
11
+ /** Bereich: Attribut scope, sonst dort, wo das Feld in pixl.json steht */
12
+ get scope(): WidgetFieldScope;
13
+ /** Definition aus pixl.json */
14
+ get definition(): WidgetField | null;
15
+ connectedCallback(): void;
16
+ disconnectedCallback(): void;
17
+ /** Eine Änderung schreiben, Fehler zeigt der Baustein selbst an */
18
+ protected write(op: Omit<WidgetOperation, "name"> & Record<string, unknown>): Promise<boolean>;
19
+ protected showError(message: string | null): void;
20
+ /** Skelett, solange die Verbindung noch nicht steht */
21
+ protected renderPlaceholder(): void;
22
+ protected renderMessage(message: string): void;
23
+ protected abstract render(): void;
24
+ protected abstract onValue(value: unknown): void;
25
+ }
26
+ export declare class PixlField extends WidgetBoundElement {
27
+ static observedAttributes: string[];
28
+ private input;
29
+ attributeChangedCallback(): void;
30
+ protected render(): void;
31
+ protected onValue(value: unknown): void;
32
+ }
33
+ export declare class PixlToggle extends PixlField {
34
+ }
35
+ export declare class PixlCounter extends PixlField {
36
+ }
37
+ export declare class PixlRange extends PixlField {
38
+ }
39
+ export declare class PixlSelect extends PixlField {
40
+ }
41
+ export declare class PixlText extends PixlField {
42
+ }
43
+ export declare class PixlColor extends PixlField {
44
+ }
45
+ export declare class PixlFile extends PixlField {
46
+ }
47
+ export declare class PixlButton extends PixlField {
48
+ }
@@ -0,0 +1,14 @@
1
+ import { defineElements } from "./define.js";
2
+ export { defineElements };
3
+ export { requestFullscreen, sharedPixl, sharedWidget } from "./runtime.js";
4
+ export { PAGE_CSS, SHADOW_CSS } from "./styles.js";
5
+ export { createInput } from "./inputs.js";
6
+ export type { Input, InputHandlers } from "./inputs.js";
7
+ export { PixlField } from "./field.js";
8
+ export { PixlList } from "./list.js";
9
+ export type { ListEditDetail } from "./list.js";
10
+ export { PixlDialog } from "./dialog.js";
11
+ export { PixlDropdown } from "./dropdown.js";
12
+ export type { DropdownOption } from "./dropdown.js";
13
+ export { PixlCheckbox } from "./checkbox.js";
14
+ export { PixlSection, PixlControls } from "./section.js";