mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Merge pull request #33504 from ApptecSrl/twitchext-configuration
Twitch-ext configuration definition
This commit is contained in:
46
types/twitch-ext/index.d.ts
vendored
46
types/twitch-ext/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for non-npm package twitch-ext 1.15
|
||||
// Type definitions for non-npm package twitch-ext 1.20
|
||||
// Project: https://dev.twitch.tv/docs/extensions/reference/#javascript-helper
|
||||
// Definitions by: Benedict Etzel <https://github.com/beheh>
|
||||
// Federico Della Rovere <https://github.com/FedeDR>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
@@ -29,6 +30,11 @@ interface TwitchExt {
|
||||
*/
|
||||
actions: TwitchExtActions;
|
||||
|
||||
/**
|
||||
* @see https://dev.twitch.tv/docs/extensions/reference/#helper-configuration
|
||||
*/
|
||||
configuration: TwitchExtConfiguration;
|
||||
|
||||
/**
|
||||
* @see https://dev.twitch.tv/docs/extensions/reference/#twitch-extension-feature-flags
|
||||
*/
|
||||
@@ -170,6 +176,44 @@ interface TwitchExtActions {
|
||||
requestIdShare(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TwitchExt.configuration
|
||||
*/
|
||||
interface TwitchExtConfiguration {
|
||||
/**
|
||||
* This property returns the record for the broadcaster segment if one is found; otherwise, undefined.
|
||||
*/
|
||||
broadcaster?: { version: string; content: string };
|
||||
|
||||
/**
|
||||
* This property returns the record for the developer segment if one is found; otherwise, undefined.
|
||||
*/
|
||||
developer?: { version: string; content: string };
|
||||
|
||||
/**
|
||||
* This property returns the record for the global segment if one is found; otherwise, undefined.
|
||||
*/
|
||||
global?: { version: string; content: string };
|
||||
|
||||
/**
|
||||
* This function registers a callback that is called whenever an extension configuration is received.
|
||||
* The callback function takes no input and returns nothing. After this is called for the first time,
|
||||
* the records for the global, developer and broadcaster segments will be set if the data is available.
|
||||
* @param callback The callback that is fired.
|
||||
*/
|
||||
onChanged(
|
||||
callback: () => void
|
||||
): void;
|
||||
|
||||
/**
|
||||
* This function can be called by the front end to set an extension configuration.
|
||||
* @param segment The configuration segment to set. Valid value. "broadcaster".
|
||||
* @param version The version of configuration with which the segment is stored.
|
||||
* @param content The string-encoded configuration.
|
||||
*/
|
||||
set(segment: "broadcaster", version: string, content: string): void;
|
||||
}
|
||||
|
||||
interface TwitchExtFeatureFlags {
|
||||
/**
|
||||
* If this flag is true, you can send a chat message to the current channel using Send Extension Chat Message
|
||||
|
||||
@@ -36,6 +36,28 @@ window.Twitch.ext.actions.minimize();
|
||||
window.Twitch.ext.actions.followChannel("hearthsim");
|
||||
window.Twitch.ext.actions.requestIdShare();
|
||||
|
||||
// Twitch Extension Configuration
|
||||
window.Twitch.ext.configuration.onChanged(() => {
|
||||
console.log('Configuration changed');
|
||||
if (window.Twitch.ext.configuration.broadcaster) {
|
||||
console.log('Caster configuration');
|
||||
console.log('version: ', window.Twitch.ext.configuration.broadcaster.version);
|
||||
console.log('content: ', window.Twitch.ext.configuration.broadcaster.content);
|
||||
}
|
||||
if (window.Twitch.ext.configuration.developer) {
|
||||
console.log('Developer configuration');
|
||||
console.log('version:', window.Twitch.ext.configuration.developer.version);
|
||||
console.log('content: ', window.Twitch.ext.configuration.developer.content);
|
||||
}
|
||||
if (window.Twitch.ext.configuration.global) {
|
||||
console.log('Global configuration');
|
||||
console.log('version: ', window.Twitch.ext.configuration.global.version);
|
||||
console.log('content: ', window.Twitch.ext.configuration.global.content);
|
||||
}
|
||||
});
|
||||
|
||||
window.Twitch.ext.configuration.set('broadcaster', '0.0.1', '{"test": "test"}');
|
||||
|
||||
// Twitch Extension Feature flags
|
||||
window.Twitch.ext.features.onChanged(changed => {
|
||||
if (changed.indexOf("isChatEnabled") !== -1) {
|
||||
|
||||
Reference in New Issue
Block a user