@twurple/common
Advanced tools
| /** @private */ | ||
| export declare function getMockApiPort(): string | null; | ||
| //# sourceMappingURL=mockApiPort.d.ts.map |
| /** @private */ | ||
| export function getMockApiPort() { | ||
| try { | ||
| return process.env.TWURPLE_MOCK_API_PORT ?? null; | ||
| } | ||
| catch { | ||
| try { | ||
| // @ts-ignore | ||
| return import.meta.env.TWURPLE_MOCK_API_PORT ?? null; // eslint-disable-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-member-access | ||
| } | ||
| catch { | ||
| return null; | ||
| } | ||
| } | ||
| } |
+7
-11
@@ -1,7 +0,4 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.DataObject = exports.getRawData = exports.rawDataSymbol = void 0; | ||
| const klona_1 = require("klona"); | ||
| import { klona } from 'klona'; | ||
| /** @private */ | ||
| exports.rawDataSymbol = Symbol('twurpleRawData'); | ||
| export const rawDataSymbol = Symbol('twurpleRawData'); | ||
| /** | ||
@@ -12,13 +9,12 @@ * Gets the raw data of a data object. | ||
| */ | ||
| function getRawData(obj) { | ||
| return (0, klona_1.klona)(obj[exports.rawDataSymbol]); | ||
| export function getRawData(obj) { | ||
| return klona(obj[rawDataSymbol]); | ||
| } | ||
| exports.getRawData = getRawData; | ||
| /** @private */ | ||
| class DataObject { | ||
| export class DataObject { | ||
| /** @private */ [rawDataSymbol]; | ||
| /** @private */ | ||
| constructor(data) { | ||
| this[exports.rawDataSymbol] = data; | ||
| this[rawDataSymbol] = data; | ||
| } | ||
| } | ||
| exports.DataObject = DataObject; |
@@ -1,8 +0,4 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.CustomError = void 0; | ||
| /** @private */ | ||
| class CustomError extends Error { | ||
| export class CustomError extends Error { | ||
| constructor(message, options) { | ||
| var _a; | ||
| super(message, options); | ||
@@ -12,3 +8,3 @@ // restore prototype chain | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| (_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, new.target.constructor); | ||
| Error.captureStackTrace?.(this, new.target.constructor); | ||
| } | ||
@@ -19,2 +15,1 @@ get name() { | ||
| } | ||
| exports.CustomError = CustomError; |
@@ -1,5 +0,2 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.HellFreezesOverError = void 0; | ||
| const CustomError_1 = require("./CustomError"); | ||
| import { CustomError } from './CustomError'; | ||
| /** | ||
@@ -10,3 +7,3 @@ * These are the kind of errors that should never happen. | ||
| */ | ||
| class HellFreezesOverError extends CustomError_1.CustomError { | ||
| export class HellFreezesOverError extends CustomError { | ||
| constructor(message) { | ||
@@ -16,2 +13,1 @@ super(`${message} - this should never happen, please file a bug in the GitHub issue tracker`); | ||
| } | ||
| exports.HellFreezesOverError = HellFreezesOverError; |
@@ -1,9 +0,6 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.RelationAssertionError = void 0; | ||
| const CustomError_1 = require("./CustomError"); | ||
| import { CustomError } from './CustomError'; | ||
| /** | ||
| * Thrown when a relation that is expected to never be null does return null. | ||
| */ | ||
| class RelationAssertionError extends CustomError_1.CustomError { | ||
| export class RelationAssertionError extends CustomError { | ||
| constructor() { | ||
@@ -13,2 +10,1 @@ super('Relation returned null - this may be a library bug or a race condition in your own code'); | ||
| } | ||
| exports.RelationAssertionError = RelationAssertionError; |
@@ -1,2 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| export {}; |
@@ -1,11 +0,8 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.HelixExtension = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const DataObject_1 = require("../DataObject"); | ||
| const rtfm_1 = require("../rtfm"); | ||
| import { __decorate } from "tslib"; | ||
| import { DataObject, rawDataSymbol } from '../DataObject'; | ||
| import { rtfm } from '../rtfm'; | ||
| /** | ||
| * A Twitch Extension. | ||
| */ | ||
| let HelixExtension = class HelixExtension extends DataObject_1.DataObject { | ||
| let HelixExtension = class HelixExtension extends DataObject { | ||
| /** | ||
@@ -15,3 +12,3 @@ * The name of the extension's author. | ||
| get authorName() { | ||
| return this[DataObject_1.rawDataSymbol].author_name; | ||
| return this[rawDataSymbol].author_name; | ||
| } | ||
@@ -22,3 +19,3 @@ /** | ||
| get bitsEnabled() { | ||
| return this[DataObject_1.rawDataSymbol].bits_enabled; | ||
| return this[rawDataSymbol].bits_enabled; | ||
| } | ||
@@ -29,3 +26,3 @@ /** | ||
| get installable() { | ||
| return this[DataObject_1.rawDataSymbol].can_install; | ||
| return this[rawDataSymbol].can_install; | ||
| } | ||
@@ -36,3 +33,3 @@ /** | ||
| get configurationLocation() { | ||
| return this[DataObject_1.rawDataSymbol].configuration_location; | ||
| return this[rawDataSymbol].configuration_location; | ||
| } | ||
@@ -43,3 +40,3 @@ /** | ||
| get description() { | ||
| return this[DataObject_1.rawDataSymbol].description; | ||
| return this[rawDataSymbol].description; | ||
| } | ||
@@ -50,3 +47,3 @@ /** | ||
| get tosUrl() { | ||
| return this[DataObject_1.rawDataSymbol].eula_tos_url; | ||
| return this[rawDataSymbol].eula_tos_url; | ||
| } | ||
@@ -57,3 +54,3 @@ /** | ||
| get hasChatSupport() { | ||
| return this[DataObject_1.rawDataSymbol].has_chat_support; | ||
| return this[rawDataSymbol].has_chat_support; | ||
| } | ||
@@ -64,3 +61,3 @@ /** | ||
| get iconUrl() { | ||
| return this[DataObject_1.rawDataSymbol].icon_url; | ||
| return this[rawDataSymbol].icon_url; | ||
| } | ||
@@ -73,3 +70,3 @@ /** | ||
| getIconUrl(size) { | ||
| return this[DataObject_1.rawDataSymbol].icon_urls[size]; | ||
| return this[rawDataSymbol].icon_urls[size]; | ||
| } | ||
@@ -80,3 +77,3 @@ /** | ||
| get id() { | ||
| return this[DataObject_1.rawDataSymbol].id; | ||
| return this[rawDataSymbol].id; | ||
| } | ||
@@ -87,3 +84,3 @@ /** | ||
| get name() { | ||
| return this[DataObject_1.rawDataSymbol].name; | ||
| return this[rawDataSymbol].name; | ||
| } | ||
@@ -94,3 +91,3 @@ /** | ||
| get privacyPolicyUrl() { | ||
| return this[DataObject_1.rawDataSymbol].privacy_policy_url; | ||
| return this[rawDataSymbol].privacy_policy_url; | ||
| } | ||
@@ -101,3 +98,3 @@ /** | ||
| get requestsIdentityLink() { | ||
| return this[DataObject_1.rawDataSymbol].request_identity_link; | ||
| return this[rawDataSymbol].request_identity_link; | ||
| } | ||
@@ -108,3 +105,3 @@ /** | ||
| get screenshotUrls() { | ||
| return this[DataObject_1.rawDataSymbol].screenshot_urls; | ||
| return this[rawDataSymbol].screenshot_urls; | ||
| } | ||
@@ -115,3 +112,3 @@ /** | ||
| get state() { | ||
| return this[DataObject_1.rawDataSymbol].state; | ||
| return this[rawDataSymbol].state; | ||
| } | ||
@@ -122,3 +119,3 @@ /** | ||
| get subscriptionsSupportLevel() { | ||
| return this[DataObject_1.rawDataSymbol].subscriptions_support_level; | ||
| return this[rawDataSymbol].subscriptions_support_level; | ||
| } | ||
@@ -129,3 +126,3 @@ /** | ||
| get summary() { | ||
| return this[DataObject_1.rawDataSymbol].summary; | ||
| return this[rawDataSymbol].summary; | ||
| } | ||
@@ -136,3 +133,3 @@ /** | ||
| get supportEmail() { | ||
| return this[DataObject_1.rawDataSymbol].support_email; | ||
| return this[rawDataSymbol].support_email; | ||
| } | ||
@@ -143,3 +140,3 @@ /** | ||
| get version() { | ||
| return this[DataObject_1.rawDataSymbol].version; | ||
| return this[rawDataSymbol].version; | ||
| } | ||
@@ -150,3 +147,3 @@ /** | ||
| get viewerSummary() { | ||
| return this[DataObject_1.rawDataSymbol].viewer_summary; | ||
| return this[rawDataSymbol].viewer_summary; | ||
| } | ||
@@ -159,3 +156,3 @@ /** | ||
| get viewerSummery() { | ||
| return this[DataObject_1.rawDataSymbol].viewer_summary; | ||
| return this[rawDataSymbol].viewer_summary; | ||
| } | ||
@@ -166,3 +163,3 @@ /** | ||
| get allowedConfigUrls() { | ||
| return this[DataObject_1.rawDataSymbol].allowlisted_config_urls; | ||
| return this[rawDataSymbol].allowlisted_config_urls; | ||
| } | ||
@@ -173,3 +170,3 @@ /** | ||
| get allowedPanelUrls() { | ||
| return this[DataObject_1.rawDataSymbol].allowlisted_panel_urls; | ||
| return this[rawDataSymbol].allowlisted_panel_urls; | ||
| } | ||
@@ -182,4 +179,3 @@ /** | ||
| get mobileViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.mobile) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.mobile?.viewer_url ?? null; | ||
| } | ||
@@ -192,4 +188,3 @@ /** | ||
| get panelViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.panel) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.panel?.viewer_url ?? null; | ||
| } | ||
@@ -202,4 +197,3 @@ /** | ||
| get panelHeight() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.panel) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.panel?.height ?? null; | ||
| } | ||
@@ -212,4 +206,3 @@ /** | ||
| get panelCanLinkExternalContent() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.panel) === null || _a === void 0 ? void 0 : _a.can_link_external_content) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.panel?.can_link_external_content ?? null; | ||
| } | ||
@@ -222,4 +215,3 @@ /** | ||
| get overlayViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.video_overlay) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.video_overlay?.viewer_url ?? null; | ||
| } | ||
@@ -232,4 +224,3 @@ /** | ||
| get overlayCanLinkExternalContent() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.video_overlay) === null || _a === void 0 ? void 0 : _a.can_link_external_content) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.video_overlay?.can_link_external_content ?? null; | ||
| } | ||
@@ -242,4 +233,3 @@ /** | ||
| get componentViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.viewer_url ?? null; | ||
| } | ||
@@ -252,4 +242,3 @@ /** | ||
| get componentAspectWidth() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.aspect_width) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.aspect_width ?? null; | ||
| } | ||
@@ -262,4 +251,3 @@ /** | ||
| get componentAspectHeight() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.aspect_height) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.aspect_height ?? null; | ||
| } | ||
@@ -272,4 +260,3 @@ /** | ||
| get componentAspectRatioX() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.aspect_ratio_x) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.aspect_ratio_x ?? null; | ||
| } | ||
@@ -282,4 +269,3 @@ /** | ||
| get componentAspectRatioY() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.aspect_ratio_y) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.aspect_ratio_y ?? null; | ||
| } | ||
@@ -292,4 +278,3 @@ /** | ||
| get componentAutoScales() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.autoscale) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.autoscale ?? null; | ||
| } | ||
@@ -302,4 +287,3 @@ /** | ||
| get componentScalePixels() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.scale_pixels) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.scale_pixels ?? null; | ||
| } | ||
@@ -312,4 +296,3 @@ /** | ||
| get componentTargetHeight() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.target_height) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.target_height ?? null; | ||
| } | ||
@@ -322,4 +305,3 @@ /** | ||
| get componentSize() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.size ?? null; | ||
| } | ||
@@ -332,4 +314,3 @@ /** | ||
| get componentZoom() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.zoom) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.zoom ?? null; | ||
| } | ||
@@ -342,4 +323,3 @@ /** | ||
| get componentZoomPixels() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.zoom_pixels) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.zoom_pixels ?? null; | ||
| } | ||
@@ -352,4 +332,3 @@ /** | ||
| get componentCanLinkExternalContent() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.can_link_external_content) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.component?.can_link_external_content ?? null; | ||
| } | ||
@@ -362,4 +341,3 @@ /** | ||
| get configViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.config) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.config?.viewer_url ?? null; | ||
| } | ||
@@ -372,9 +350,8 @@ /** | ||
| get configCanLinkExternalContent() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[DataObject_1.rawDataSymbol].views.config) === null || _a === void 0 ? void 0 : _a.can_link_external_content) !== null && _b !== void 0 ? _b : null; | ||
| return this[rawDataSymbol].views.config?.can_link_external_content ?? null; | ||
| } | ||
| }; | ||
| exports.HelixExtension = HelixExtension; | ||
| exports.HelixExtension = HelixExtension = tslib_1.__decorate([ | ||
| (0, rtfm_1.rtfm)('api', 'HelixExtension', 'id') | ||
| HelixExtension = __decorate([ | ||
| rtfm('api', 'HelixExtension', 'id') | ||
| ], HelixExtension); | ||
| export { HelixExtension }; |
+1
-0
| export { DataObject, getRawData, rawDataSymbol } from './DataObject'; | ||
| export { getMockApiPort } from './mockApiPort'; | ||
| export { checkRelationAssertion } from './relations'; | ||
@@ -3,0 +4,0 @@ export { rtfm } from './rtfm'; |
+9
-22
@@ -1,22 +0,9 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.extractUserName = exports.extractUserId = exports.RelationAssertionError = exports.HellFreezesOverError = exports.CustomError = exports.HelixExtension = exports.rtfm = exports.checkRelationAssertion = exports.rawDataSymbol = exports.getRawData = exports.DataObject = void 0; | ||
| var DataObject_1 = require("./DataObject"); | ||
| Object.defineProperty(exports, "DataObject", { enumerable: true, get: function () { return DataObject_1.DataObject; } }); | ||
| Object.defineProperty(exports, "getRawData", { enumerable: true, get: function () { return DataObject_1.getRawData; } }); | ||
| Object.defineProperty(exports, "rawDataSymbol", { enumerable: true, get: function () { return DataObject_1.rawDataSymbol; } }); | ||
| var relations_1 = require("./relations"); | ||
| Object.defineProperty(exports, "checkRelationAssertion", { enumerable: true, get: function () { return relations_1.checkRelationAssertion; } }); | ||
| var rtfm_1 = require("./rtfm"); | ||
| Object.defineProperty(exports, "rtfm", { enumerable: true, get: function () { return rtfm_1.rtfm; } }); | ||
| var HelixExtension_1 = require("./extensions/HelixExtension"); | ||
| Object.defineProperty(exports, "HelixExtension", { enumerable: true, get: function () { return HelixExtension_1.HelixExtension; } }); | ||
| var CustomError_1 = require("./errors/CustomError"); | ||
| Object.defineProperty(exports, "CustomError", { enumerable: true, get: function () { return CustomError_1.CustomError; } }); | ||
| var HellFreezesOverError_1 = require("./errors/HellFreezesOverError"); | ||
| Object.defineProperty(exports, "HellFreezesOverError", { enumerable: true, get: function () { return HellFreezesOverError_1.HellFreezesOverError; } }); | ||
| var RelationAssertionError_1 = require("./errors/RelationAssertionError"); | ||
| Object.defineProperty(exports, "RelationAssertionError", { enumerable: true, get: function () { return RelationAssertionError_1.RelationAssertionError; } }); | ||
| var userResolvers_1 = require("./userResolvers"); | ||
| Object.defineProperty(exports, "extractUserId", { enumerable: true, get: function () { return userResolvers_1.extractUserId; } }); | ||
| Object.defineProperty(exports, "extractUserName", { enumerable: true, get: function () { return userResolvers_1.extractUserName; } }); | ||
| export { DataObject, getRawData, rawDataSymbol } from './DataObject'; | ||
| export { getMockApiPort } from './mockApiPort'; | ||
| export { checkRelationAssertion } from './relations'; | ||
| export { rtfm } from './rtfm'; | ||
| export { HelixExtension } from './extensions/HelixExtension'; | ||
| export { CustomError } from './errors/CustomError'; | ||
| export { HellFreezesOverError } from './errors/HellFreezesOverError'; | ||
| export { RelationAssertionError } from './errors/RelationAssertionError'; | ||
| export { extractUserId, extractUserName } from './userResolvers'; |
+3
-7
@@ -1,12 +0,8 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.checkRelationAssertion = void 0; | ||
| const RelationAssertionError_1 = require("./errors/RelationAssertionError"); | ||
| import { RelationAssertionError } from './errors/RelationAssertionError'; | ||
| /** @private */ | ||
| function checkRelationAssertion(value) { | ||
| export function checkRelationAssertion(value) { | ||
| if (value == null) { | ||
| throw new RelationAssertionError_1.RelationAssertionError(); | ||
| throw new RelationAssertionError(); | ||
| } | ||
| return value; | ||
| } | ||
| exports.checkRelationAssertion = checkRelationAssertion; |
+1
-1
| import type { NoInfer } from '@d-fischer/shared-utils'; | ||
| /** @private */ | ||
| type PackageName = 'api' | 'auth' | 'chat' | 'common' | 'easy-bot' | 'eventsub-base' | 'eventsub-http' | 'eventsub-ws' | 'pubsub'; | ||
| type PackageName = 'api' | 'auth' | 'chat' | 'common' | 'easy-bot' | 'eventsub-base' | 'eventsub-http' | 'eventsub-ws'; | ||
| /** @private */ | ||
@@ -5,0 +5,0 @@ export declare function rtfm(pkg: PackageName, name: string): ClassDecorator; |
+1
-5
@@ -1,6 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.rtfm = void 0; | ||
| /** @private */ | ||
| function rtfm(pkg, name, idKey) { | ||
| export function rtfm(pkg, name, idKey) { | ||
| return clazz => { | ||
@@ -21,2 +18,1 @@ const fn = idKey | ||
| } | ||
| exports.rtfm = rtfm; |
+1
-2
@@ -1,2 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| export {}; |
@@ -1,4 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.extractUserName = exports.extractUserId = void 0; | ||
| /** | ||
@@ -9,3 +6,3 @@ * Extracts the user ID from an argument that is possibly an object containing that ID. | ||
| */ | ||
| function extractUserId(user) { | ||
| export function extractUserId(user) { | ||
| if (typeof user === 'string') { | ||
@@ -19,3 +16,2 @@ return user; | ||
| } | ||
| exports.extractUserId = extractUserId; | ||
| /** | ||
@@ -26,5 +22,4 @@ * Extracts the username from an argument that is possibly an object containing that name. | ||
| */ | ||
| function extractUserName(user) { | ||
| export function extractUserName(user) { | ||
| return typeof user === 'string' ? user : user.name; | ||
| } | ||
| exports.extractUserName = extractUserName; |
+4
-7
| { | ||
| "name": "@twurple/common", | ||
| "version": "7.4.0", | ||
| "version": "8.0.0", | ||
| "publishConfig": { | ||
@@ -14,2 +14,3 @@ "access": "public" | ||
| "sideEffects": false, | ||
| "type": "module", | ||
| "main": "lib", | ||
@@ -20,4 +21,3 @@ "types": "lib", | ||
| "types": "./lib/index.d.ts", | ||
| "require": "./lib/index.js", | ||
| "import": "./es/index.mjs" | ||
| "import": "./lib/index.js" | ||
| } | ||
@@ -43,7 +43,4 @@ }, | ||
| "lib", | ||
| "!lib/**/*.d.ts.map", | ||
| "es", | ||
| "!es/**/*.d.ts", | ||
| "!es/**/*.d.ts.map" | ||
| "!lib/**/*.d.ts.map" | ||
| ] | ||
| } |
| import { klona } from 'klona'; | ||
| /** @private */ | ||
| export const rawDataSymbol = Symbol('twurpleRawData'); | ||
| /** | ||
| * Gets the raw data of a data object. | ||
| * | ||
| * @param obj The data object to get the raw data of. | ||
| */ | ||
| export function getRawData(obj) { | ||
| return klona(obj[rawDataSymbol]); | ||
| } | ||
| /** @private */ | ||
| export class DataObject { | ||
| /** @private */ | ||
| constructor(data) { | ||
| this[rawDataSymbol] = data; | ||
| } | ||
| } |
| import { utf8Length } from '@d-fischer/shared-utils'; | ||
| import { DataObject } from "../DataObject.mjs"; | ||
| import { findCheermotePositions } from "./messagePartParser.mjs"; | ||
| /** @private */ | ||
| export class BaseCheermoteList extends DataObject { | ||
| /** | ||
| * Parses all the cheermotes out of a message. | ||
| * | ||
| * @deprecated Use {@link parseChatMessage} instead. | ||
| * | ||
| * @param message The message. | ||
| * @param format The format to show the cheermotes in. | ||
| */ | ||
| parseMessage(message, format) { | ||
| const result = []; | ||
| const names = this.getPossibleNames(); | ||
| const re = new RegExp('(?<=^|\\s)([a-z]+(?:\\d+[a-z]+)*)(\\d+)(?=\\s|$)', 'gi'); | ||
| let match = null; | ||
| while ((match = re.exec(message))) { | ||
| const name = match[1].toLowerCase(); | ||
| if (names.includes(name)) { | ||
| const amount = Number(match[2]); | ||
| result.push({ | ||
| name, | ||
| amount, | ||
| position: utf8Length(message.slice(0, match.index)), | ||
| length: match[0].length, | ||
| displayInfo: this.getCheermoteDisplayInfo(name, amount, format) | ||
| }); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| /** | ||
| * Transforms all the cheermotes in a message and returns an array of all the message parts. | ||
| * | ||
| * @deprecated Use {@link parseChatMessage} instead. | ||
| * | ||
| * @param message The message. | ||
| * @param format The format to show the cheermotes in. | ||
| * @param transformer A function that transforms a message part into an arbitrary structure. | ||
| */ | ||
| transformCheerMessage(message, format, transformer) { | ||
| const result = []; | ||
| let currentPosition = 0; | ||
| for (const foundCheermote of findCheermotePositions(message, this.getPossibleNames())) { | ||
| if (currentPosition < foundCheermote.position) { | ||
| result.push(message.substring(currentPosition, foundCheermote.position)); | ||
| } | ||
| result.push(transformer({ | ||
| ...foundCheermote, | ||
| displayInfo: this.getCheermoteDisplayInfo(foundCheermote.name, foundCheermote.amount, format) | ||
| })); | ||
| currentPosition = foundCheermote.position + foundCheermote.length; | ||
| } | ||
| if (currentPosition < message.length) { | ||
| result.push(message.slice(currentPosition)); | ||
| } | ||
| return result; | ||
| } | ||
| } |
| export {}; |
| import { __decorate } from "tslib"; | ||
| import { DataObject, rawDataSymbol } from "../DataObject.mjs"; | ||
| import { rtfm } from "../rtfm.mjs"; | ||
| /** | ||
| * A chat emote. | ||
| */ | ||
| let ChatEmote = class ChatEmote extends DataObject { | ||
| /** | ||
| * The emote ID. | ||
| */ | ||
| get id() { | ||
| return this[rawDataSymbol].id; | ||
| } | ||
| /** | ||
| * The emote code, i.e. how you write it in chat. | ||
| */ | ||
| get code() { | ||
| return this[rawDataSymbol].code; | ||
| } | ||
| /** | ||
| * Build the URL pointing to the emote image. | ||
| * | ||
| * @param settings The display settings of the emote image. | ||
| */ | ||
| getUrl(settings) { | ||
| const { animationSettings = 'default', backgroundType = 'dark', size = '1.0' } = settings; | ||
| return `https://static-cdn.jtvnw.net/emoticons/v2/${this.id}/${animationSettings}/${backgroundType}/${size}`; | ||
| } | ||
| }; | ||
| ChatEmote = __decorate([ | ||
| rtfm('common', 'ChatEmote', 'id') | ||
| ], ChatEmote); | ||
| export { ChatEmote }; |
| export {}; |
| import { __decorate } from "tslib"; | ||
| import { rawDataSymbol } from "../DataObject.mjs"; | ||
| import { rtfm } from "../rtfm.mjs"; | ||
| import { ChatEmote } from "./ChatEmote.mjs"; | ||
| /** | ||
| * A chat emote from an emote set. | ||
| * | ||
| * @inheritDoc | ||
| */ | ||
| let ChatEmoteWithSet = class ChatEmoteWithSet extends ChatEmote { | ||
| /** | ||
| * The ID of the emote set. | ||
| */ | ||
| get setId() { | ||
| return this[rawDataSymbol].emoticon_set; | ||
| } | ||
| }; | ||
| ChatEmoteWithSet = __decorate([ | ||
| rtfm('common', 'ChatEmoteWithSet', 'id') | ||
| ], ChatEmoteWithSet); | ||
| export { ChatEmoteWithSet }; |
| import { utf8Length, utf8Substring } from '@d-fischer/shared-utils'; | ||
| import { ChatEmote } from "./ChatEmote.mjs"; | ||
| /** | ||
| * Transforms the parts of the given text that are marked as emotes. | ||
| * | ||
| * @param text The message text. | ||
| * @param emoteOffsets The emote offsets. An emote name maps to a list of text ranges. | ||
| */ | ||
| export function parseEmotePositions(text, emoteOffsets) { | ||
| return [...emoteOffsets.entries()] | ||
| .flatMap(([emote, placements]) => placements.map((placement) => { | ||
| const [startStr, endStr] = placement.split('-'); | ||
| const start = +startStr; | ||
| const end = +endStr; | ||
| const name = utf8Substring(text, start, end + 1); | ||
| return { | ||
| type: 'emote', | ||
| position: start, | ||
| length: end - start + 1, | ||
| id: emote, | ||
| name, | ||
| displayInfo: new ChatEmote({ | ||
| code: name, | ||
| id: emote | ||
| }) | ||
| }; | ||
| })) | ||
| .sort((a, b) => a.position - b.position); | ||
| } | ||
| /** | ||
| * Finds the positions of all cheermotes in the given message. | ||
| * | ||
| * @param text The message text. | ||
| * @param names The names of the cheermotes to find. | ||
| */ | ||
| export function findCheermotePositions(text, names) { | ||
| const result = []; | ||
| const re = new RegExp('(?<=^|\\s)([a-z]+(?:\\d+[a-z]+)*)(\\d+)(?=\\s|$)', 'gi'); | ||
| let match = null; | ||
| while ((match = re.exec(text))) { | ||
| const name = match[1].toLowerCase(); | ||
| if (names.includes(name)) { | ||
| const amount = Number(match[2]); | ||
| result.push({ | ||
| name, | ||
| amount, | ||
| position: utf8Length(text.slice(0, match.index)), | ||
| length: match[0].length | ||
| }); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| /** | ||
| * Add text parts to the given list of message parts for all the text that's unaccounted for. | ||
| * | ||
| * @param text The message text. | ||
| * @param otherPositions The parsed non-text parts of the message. | ||
| */ | ||
| export function fillTextPositions(text, otherPositions) { | ||
| const messageLength = utf8Length(text); | ||
| if (!otherPositions.length) { | ||
| return [ | ||
| { | ||
| type: 'text', | ||
| position: 0, | ||
| length: messageLength, | ||
| text: text | ||
| } | ||
| ]; | ||
| } | ||
| const result = []; | ||
| let currentPosition = 0; | ||
| for (const token of otherPositions) { | ||
| if (token.position > currentPosition) { | ||
| result.push({ | ||
| type: 'text', | ||
| position: currentPosition, | ||
| length: token.position - currentPosition, | ||
| text: utf8Substring(text, currentPosition, token.position) | ||
| }); | ||
| } | ||
| result.push(token); | ||
| currentPosition = token.position + token.length; | ||
| } | ||
| if (currentPosition < messageLength) { | ||
| result.push({ | ||
| type: 'text', | ||
| position: currentPosition, | ||
| length: messageLength - currentPosition, | ||
| text: utf8Substring(text, currentPosition) | ||
| }); | ||
| } | ||
| return result; | ||
| } | ||
| /** | ||
| * Parse a chat message with emotes and optionally cheermotes. | ||
| * | ||
| * @param text The message text. | ||
| * @param emoteOffsets The emote offsets. An emote name maps to a list of text ranges. | ||
| * @param cheermoteNames The names of the cheermotes to find. Will not do cheermote parsing if not given. | ||
| */ | ||
| export function parseChatMessage(text, emoteOffsets, cheermoteNames) { | ||
| if (!text) { | ||
| return []; | ||
| } | ||
| const foundParts = parseEmotePositions(text, emoteOffsets); | ||
| if (cheermoteNames) { | ||
| foundParts.push(...findCheermotePositions(text, cheermoteNames).map((cm) => ({ | ||
| type: 'cheer', | ||
| ...cm | ||
| }))); | ||
| foundParts.sort((a, b) => a.position - b.position); | ||
| } | ||
| return fillTextPositions(text, foundParts); | ||
| } |
| export {}; |
| /** @private */ | ||
| export class CustomError extends Error { | ||
| constructor(message, options) { | ||
| var _a; | ||
| super(message, options); | ||
| // restore prototype chain | ||
| Object.setPrototypeOf(this, new.target.prototype); | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| (_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, new.target.constructor); | ||
| } | ||
| get name() { | ||
| return this.constructor.name; | ||
| } | ||
| } |
| import { CustomError } from "./CustomError.mjs"; | ||
| /** | ||
| * These are the kind of errors that should never happen. | ||
| * | ||
| * If you see one thrown, please file a bug in the GitHub issue tracker. | ||
| */ | ||
| export class HellFreezesOverError extends CustomError { | ||
| constructor(message) { | ||
| super(`${message} - this should never happen, please file a bug in the GitHub issue tracker`); | ||
| } | ||
| } |
| import { CustomError } from "./CustomError.mjs"; | ||
| /** | ||
| * Thrown when a relation that is expected to never be null does return null. | ||
| */ | ||
| export class RelationAssertionError extends CustomError { | ||
| constructor() { | ||
| super('Relation returned null - this may be a library bug or a race condition in your own code'); | ||
| } | ||
| } |
| export {}; |
| import { __decorate } from "tslib"; | ||
| import { DataObject, rawDataSymbol } from "../DataObject.mjs"; | ||
| import { rtfm } from "../rtfm.mjs"; | ||
| /** | ||
| * A Twitch Extension. | ||
| */ | ||
| let HelixExtension = class HelixExtension extends DataObject { | ||
| /** | ||
| * The name of the extension's author. | ||
| */ | ||
| get authorName() { | ||
| return this[rawDataSymbol].author_name; | ||
| } | ||
| /** | ||
| * Whether bits are enabled for the extension. | ||
| */ | ||
| get bitsEnabled() { | ||
| return this[rawDataSymbol].bits_enabled; | ||
| } | ||
| /** | ||
| * Whether the extension can be installed. | ||
| */ | ||
| get installable() { | ||
| return this[rawDataSymbol].can_install; | ||
| } | ||
| /** | ||
| * The location of the extension's configuration. | ||
| */ | ||
| get configurationLocation() { | ||
| return this[rawDataSymbol].configuration_location; | ||
| } | ||
| /** | ||
| * The extension's description. | ||
| */ | ||
| get description() { | ||
| return this[rawDataSymbol].description; | ||
| } | ||
| /** | ||
| * The URL of the extension's terms of service. | ||
| */ | ||
| get tosUrl() { | ||
| return this[rawDataSymbol].eula_tos_url; | ||
| } | ||
| /** | ||
| * Whether the extension has support for sending chat messages. | ||
| */ | ||
| get hasChatSupport() { | ||
| return this[rawDataSymbol].has_chat_support; | ||
| } | ||
| /** | ||
| * The URL of the extension's default sized icon. | ||
| */ | ||
| get iconUrl() { | ||
| return this[rawDataSymbol].icon_url; | ||
| } | ||
| /** | ||
| * Gets the URL of the extension's icon in the given size. | ||
| * | ||
| * @param size The size of the icon. | ||
| */ | ||
| getIconUrl(size) { | ||
| return this[rawDataSymbol].icon_urls[size]; | ||
| } | ||
| /** | ||
| * The extension's ID. | ||
| */ | ||
| get id() { | ||
| return this[rawDataSymbol].id; | ||
| } | ||
| /** | ||
| * The extension's name. | ||
| */ | ||
| get name() { | ||
| return this[rawDataSymbol].name; | ||
| } | ||
| /** | ||
| * The URL of the extension's privacy policy. | ||
| */ | ||
| get privacyPolicyUrl() { | ||
| return this[rawDataSymbol].privacy_policy_url; | ||
| } | ||
| /** | ||
| * Whether the extension requests its users to share their identity with it. | ||
| */ | ||
| get requestsIdentityLink() { | ||
| return this[rawDataSymbol].request_identity_link; | ||
| } | ||
| /** | ||
| * The URLs of the extension's screenshots. | ||
| */ | ||
| get screenshotUrls() { | ||
| return this[rawDataSymbol].screenshot_urls; | ||
| } | ||
| /** | ||
| * The extension's activity state. | ||
| */ | ||
| get state() { | ||
| return this[rawDataSymbol].state; | ||
| } | ||
| /** | ||
| * The extension's level of support for subscriptions. | ||
| */ | ||
| get subscriptionsSupportLevel() { | ||
| return this[rawDataSymbol].subscriptions_support_level; | ||
| } | ||
| /** | ||
| * The extension's feature summary. | ||
| */ | ||
| get summary() { | ||
| return this[rawDataSymbol].summary; | ||
| } | ||
| /** | ||
| * The extension's support email address. | ||
| */ | ||
| get supportEmail() { | ||
| return this[rawDataSymbol].support_email; | ||
| } | ||
| /** | ||
| * The extension's version. | ||
| */ | ||
| get version() { | ||
| return this[rawDataSymbol].version; | ||
| } | ||
| /** | ||
| * The extension's feature summary for viewers. | ||
| */ | ||
| get viewerSummary() { | ||
| return this[rawDataSymbol].viewer_summary; | ||
| } | ||
| /** | ||
| * The extension's feature summary for viewers. | ||
| * | ||
| * @deprecated Use `viewerSummary` instead. | ||
| */ | ||
| get viewerSummery() { | ||
| return this[rawDataSymbol].viewer_summary; | ||
| } | ||
| /** | ||
| * The extension's allowed configuration URLs. | ||
| */ | ||
| get allowedConfigUrls() { | ||
| return this[rawDataSymbol].allowlisted_config_urls; | ||
| } | ||
| /** | ||
| * The extension's allowed panel URLs. | ||
| */ | ||
| get allowedPanelUrls() { | ||
| return this[rawDataSymbol].allowlisted_panel_urls; | ||
| } | ||
| /** | ||
| * The URL shown when a viewer opens the extension on a mobile device. | ||
| * | ||
| * If the extension does not have a mobile view, this is null. | ||
| */ | ||
| get mobileViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.mobile) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The URL shown to the viewer when the extension is shown as a panel. | ||
| * | ||
| * If the extension does not have a panel view, this is null. | ||
| */ | ||
| get panelViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.panel) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The height of the extension panel. | ||
| * | ||
| * If the extension does not have a panel view, this is null. | ||
| */ | ||
| get panelHeight() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.panel) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * Whether the extension can link to external content from its panel view. | ||
| * | ||
| * If the extension does not have a panel view, this is null. | ||
| */ | ||
| get panelCanLinkExternalContent() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.panel) === null || _a === void 0 ? void 0 : _a.can_link_external_content) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The URL shown to the viewer when the extension is shown as a video overlay. | ||
| * | ||
| * If the extension does not have a overlay view, this is null. | ||
| */ | ||
| get overlayViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.video_overlay) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * Whether the extension can link to external content from its overlay view. | ||
| * | ||
| * If the extension does not have a overlay view, this is null. | ||
| */ | ||
| get overlayCanLinkExternalContent() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.video_overlay) === null || _a === void 0 ? void 0 : _a.can_link_external_content) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The URL shown to the viewer when the extension is shown as a video component. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The aspect width of the extension's component view. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentAspectWidth() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.aspect_width) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The aspect height of the extension's component view. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentAspectHeight() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.aspect_height) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The horizontal aspect ratio of the extension's component view. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentAspectRatioX() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.aspect_ratio_x) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The vertical aspect ratio of the extension's component view. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentAspectRatioY() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.aspect_ratio_y) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * Whether the extension's component view should automatically scale. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentAutoScales() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.autoscale) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The base width of the extension's component view to use for scaling. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentScalePixels() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.scale_pixels) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The target height of the extension's component view. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentTargetHeight() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.target_height) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The size of the extension's component view. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentSize() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * Whether zooming is enabled for the extension's component view. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentZoom() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.zoom) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The zoom pixels of the extension's component view. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentZoomPixels() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.zoom_pixels) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * Whether the extension can link to external content from its component view. | ||
| * | ||
| * If the extension does not have a component view, this is null. | ||
| */ | ||
| get componentCanLinkExternalContent() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.component) === null || _a === void 0 ? void 0 : _a.can_link_external_content) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * The URL shown to the viewer when the extension's configuration page is shown. | ||
| * | ||
| * If the extension does not have a config view, this is null. | ||
| */ | ||
| get configViewerUrl() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.config) === null || _a === void 0 ? void 0 : _a.viewer_url) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| /** | ||
| * Whether the extension can link to external content from its config view. | ||
| * | ||
| * If the extension does not have a config view, this is null. | ||
| */ | ||
| get configCanLinkExternalContent() { | ||
| var _a, _b; | ||
| return (_b = (_a = this[rawDataSymbol].views.config) === null || _a === void 0 ? void 0 : _a.can_link_external_content) !== null && _b !== void 0 ? _b : null; | ||
| } | ||
| }; | ||
| HelixExtension = __decorate([ | ||
| rtfm('api', 'HelixExtension', 'id') | ||
| ], HelixExtension); | ||
| export { HelixExtension }; |
| export { DataObject, getRawData, rawDataSymbol } from "./DataObject.mjs"; | ||
| export { checkRelationAssertion } from "./relations.mjs"; | ||
| export { rtfm } from "./rtfm.mjs"; | ||
| export { HelixExtension } from "./extensions/HelixExtension.mjs"; | ||
| export { CustomError } from "./errors/CustomError.mjs"; | ||
| export { HellFreezesOverError } from "./errors/HellFreezesOverError.mjs"; | ||
| export { RelationAssertionError } from "./errors/RelationAssertionError.mjs"; | ||
| export { extractUserId, extractUserName } from "./userResolvers.mjs"; |
| import { RelationAssertionError } from "./errors/RelationAssertionError.mjs"; | ||
| /** @private */ | ||
| export function checkRelationAssertion(value) { | ||
| if (value == null) { | ||
| throw new RelationAssertionError(); | ||
| } | ||
| return value; | ||
| } |
-17
| /** @private */ | ||
| export function rtfm(pkg, name, idKey) { | ||
| return clazz => { | ||
| const fn = idKey | ||
| ? function () { | ||
| // eslint-disable-next-line @typescript-eslint/restrict-template-expressions | ||
| return `[${name}#${this[idKey]} - please check https://twurple.js.org/reference/${pkg}/classes/${name}.html for available properties]`; | ||
| } | ||
| : function () { | ||
| return `[${name} - please check https://twurple.js.org/reference/${pkg}/classes/${name}.html for available properties]`; | ||
| }; | ||
| Object.defineProperty(clazz.prototype, Symbol.for('nodejs.util.inspect.custom'), { | ||
| value: fn, | ||
| enumerable: false, | ||
| }); | ||
| }; | ||
| } |
| export {}; |
| /** | ||
| * Extracts the user ID from an argument that is possibly an object containing that ID. | ||
| * | ||
| * @param user The user ID or object. | ||
| */ | ||
| export function extractUserId(user) { | ||
| if (typeof user === 'string') { | ||
| return user; | ||
| } | ||
| if (typeof user === 'number') { | ||
| return user.toString(10); | ||
| } | ||
| return user.id; | ||
| } | ||
| /** | ||
| * Extracts the username from an argument that is possibly an object containing that name. | ||
| * | ||
| * @param user The username or object. | ||
| */ | ||
| export function extractUserName(user) { | ||
| return typeof user === 'string' ? user : user.name; | ||
| } |
| import { DataObject } from '../DataObject'; | ||
| /** | ||
| * The details on how a cheermote should be displayed. | ||
| */ | ||
| export interface CheermoteDisplayInfo { | ||
| /** | ||
| * The URL of the image that should be shown. | ||
| */ | ||
| url: string; | ||
| /** | ||
| * The color that should be used to shown the cheer amount. | ||
| * | ||
| * This is a hexadecimal color value, e.g. `#9c3ee8`. | ||
| */ | ||
| color: string; | ||
| } | ||
| /** | ||
| * A description of a specific cheermote parsed from a message. | ||
| */ | ||
| export interface BasicMessageCheermote { | ||
| /** | ||
| * The name of the cheermote. | ||
| */ | ||
| name: string; | ||
| /** | ||
| * The amount of bits for the cheermote. | ||
| */ | ||
| amount: number; | ||
| /** | ||
| * The position of the cheermote in the text, zero based. | ||
| */ | ||
| position: number; | ||
| /** | ||
| * The length of the cheermote in the text. | ||
| */ | ||
| length: number; | ||
| } | ||
| /** | ||
| * A description of a specific cheermote parsed from a message with info how to display it. | ||
| * | ||
| * @inheritDoc | ||
| */ | ||
| export interface MessageCheermote extends BasicMessageCheermote { | ||
| /** | ||
| * Information on how the cheermote is supposed to be displayed. | ||
| */ | ||
| displayInfo: CheermoteDisplayInfo; | ||
| } | ||
| /** | ||
| * The type of background a cheermote is supposed to appear on. | ||
| * | ||
| * We will supply a fitting graphic that does not show any artifacts | ||
| * on the given type of background. | ||
| */ | ||
| export declare type CheermoteBackground = 'dark' | 'light'; | ||
| /** | ||
| * The state of a cheermote, i.e. whether it's animated or not. | ||
| */ | ||
| export declare type CheermoteState = 'animated' | 'static'; | ||
| /** | ||
| * The scale of the cheermote, which usually relates to the pixel density of the device in use. | ||
| */ | ||
| export declare type CheermoteScale = '1' | '1.5' | '2' | '3' | '4'; | ||
| /** | ||
| * The format of the cheermote you want to request. | ||
| */ | ||
| export interface CheermoteFormat { | ||
| /** | ||
| * The desired background for the cheermote. | ||
| */ | ||
| background: CheermoteBackground; | ||
| /** | ||
| * The desired cheermote state. | ||
| */ | ||
| state: CheermoteState; | ||
| /** | ||
| * The desired cheermote scale. | ||
| */ | ||
| scale: CheermoteScale; | ||
| } | ||
| /** @private */ | ||
| export declare abstract class BaseCheermoteList<DataType> extends DataObject<DataType> { | ||
| /** | ||
| * Gets the URL and color needed to properly represent a cheer of the given amount of bits with the given prefix. | ||
| * | ||
| * @param name The name/prefix of the cheermote. | ||
| * @param bits The amount of bits cheered. | ||
| * @param format The format of the cheermote you want to request. | ||
| */ | ||
| abstract getCheermoteDisplayInfo(name: string, bits: number, format: CheermoteFormat): CheermoteDisplayInfo; | ||
| /** | ||
| * Gets all possible cheermote names. | ||
| */ | ||
| abstract getPossibleNames(): string[]; | ||
| /** | ||
| * Parses all the cheermotes out of a message. | ||
| * | ||
| * @deprecated Use {@link parseChatMessage} instead. | ||
| * | ||
| * @param message The message. | ||
| * @param format The format to show the cheermotes in. | ||
| */ | ||
| parseMessage(message: string, format: CheermoteFormat): MessageCheermote[]; | ||
| /** | ||
| * Transforms all the cheermotes in a message and returns an array of all the message parts. | ||
| * | ||
| * @deprecated Use {@link parseChatMessage} instead. | ||
| * | ||
| * @param message The message. | ||
| * @param format The format to show the cheermotes in. | ||
| * @param transformer A function that transforms a message part into an arbitrary structure. | ||
| */ | ||
| transformCheerMessage<T>(message: string, format: CheermoteFormat, transformer: (displayInfo: MessageCheermote) => string | T): Array<string | T>; | ||
| } | ||
| //# sourceMappingURL=BaseCheermoteList.d.ts.map |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.BaseCheermoteList = void 0; | ||
| const shared_utils_1 = require("@d-fischer/shared-utils"); | ||
| const DataObject_1 = require("../DataObject"); | ||
| const messagePartParser_1 = require("./messagePartParser"); | ||
| /** @private */ | ||
| class BaseCheermoteList extends DataObject_1.DataObject { | ||
| /** | ||
| * Parses all the cheermotes out of a message. | ||
| * | ||
| * @deprecated Use {@link parseChatMessage} instead. | ||
| * | ||
| * @param message The message. | ||
| * @param format The format to show the cheermotes in. | ||
| */ | ||
| parseMessage(message, format) { | ||
| const result = []; | ||
| const names = this.getPossibleNames(); | ||
| const re = new RegExp('(?<=^|\\s)([a-z]+(?:\\d+[a-z]+)*)(\\d+)(?=\\s|$)', 'gi'); | ||
| let match = null; | ||
| while ((match = re.exec(message))) { | ||
| const name = match[1].toLowerCase(); | ||
| if (names.includes(name)) { | ||
| const amount = Number(match[2]); | ||
| result.push({ | ||
| name, | ||
| amount, | ||
| position: (0, shared_utils_1.utf8Length)(message.slice(0, match.index)), | ||
| length: match[0].length, | ||
| displayInfo: this.getCheermoteDisplayInfo(name, amount, format) | ||
| }); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| /** | ||
| * Transforms all the cheermotes in a message and returns an array of all the message parts. | ||
| * | ||
| * @deprecated Use {@link parseChatMessage} instead. | ||
| * | ||
| * @param message The message. | ||
| * @param format The format to show the cheermotes in. | ||
| * @param transformer A function that transforms a message part into an arbitrary structure. | ||
| */ | ||
| transformCheerMessage(message, format, transformer) { | ||
| const result = []; | ||
| let currentPosition = 0; | ||
| for (const foundCheermote of (0, messagePartParser_1.findCheermotePositions)(message, this.getPossibleNames())) { | ||
| if (currentPosition < foundCheermote.position) { | ||
| result.push(message.substring(currentPosition, foundCheermote.position)); | ||
| } | ||
| result.push(transformer({ | ||
| ...foundCheermote, | ||
| displayInfo: this.getCheermoteDisplayInfo(foundCheermote.name, foundCheermote.amount, format) | ||
| })); | ||
| currentPosition = foundCheermote.position + foundCheermote.length; | ||
| } | ||
| if (currentPosition < message.length) { | ||
| result.push(message.slice(currentPosition)); | ||
| } | ||
| return result; | ||
| } | ||
| } | ||
| exports.BaseCheermoteList = BaseCheermoteList; |
| import { DataObject } from '../DataObject'; | ||
| import { type ChatEmoteData } from './ChatEmote.external'; | ||
| /** | ||
| * The possible animation settings for an emote image. | ||
| */ | ||
| export declare type EmoteAnimationSettings = 'default' | 'static' | 'animated'; | ||
| /** | ||
| * The possible background types to optimize the emote display for. | ||
| */ | ||
| export declare type EmoteBackgroundType = 'light' | 'dark'; | ||
| /** | ||
| * The possible emote size multipliers. | ||
| */ | ||
| export declare type EmoteSize = '1.0' | '2.0' | '3.0'; | ||
| /** | ||
| * The display settings for an emote. | ||
| */ | ||
| export interface EmoteSettings { | ||
| /** | ||
| * The animation settings of the emote. | ||
| */ | ||
| animationSettings: EmoteAnimationSettings; | ||
| /** | ||
| * The background type of the emote. | ||
| */ | ||
| backgroundType: EmoteBackgroundType; | ||
| /** | ||
| * The size multiplier of the emote. | ||
| */ | ||
| size: EmoteSize; | ||
| } | ||
| /** | ||
| * A chat emote. | ||
| */ | ||
| export declare class ChatEmote extends DataObject<ChatEmoteData> { | ||
| /** | ||
| * The emote ID. | ||
| */ | ||
| get id(): string; | ||
| /** | ||
| * The emote code, i.e. how you write it in chat. | ||
| */ | ||
| get code(): string; | ||
| /** | ||
| * Build the URL pointing to the emote image. | ||
| * | ||
| * @param settings The display settings of the emote image. | ||
| */ | ||
| getUrl(settings: EmoteSettings): string; | ||
| } | ||
| //# sourceMappingURL=ChatEmote.d.ts.map |
| /** @private */ | ||
| export interface ChatEmoteData { | ||
| code: string; | ||
| id: string; | ||
| } | ||
| //# sourceMappingURL=ChatEmote.external.d.ts.map |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ChatEmote = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const DataObject_1 = require("../DataObject"); | ||
| const rtfm_1 = require("../rtfm"); | ||
| /** | ||
| * A chat emote. | ||
| */ | ||
| let ChatEmote = class ChatEmote extends DataObject_1.DataObject { | ||
| /** | ||
| * The emote ID. | ||
| */ | ||
| get id() { | ||
| return this[DataObject_1.rawDataSymbol].id; | ||
| } | ||
| /** | ||
| * The emote code, i.e. how you write it in chat. | ||
| */ | ||
| get code() { | ||
| return this[DataObject_1.rawDataSymbol].code; | ||
| } | ||
| /** | ||
| * Build the URL pointing to the emote image. | ||
| * | ||
| * @param settings The display settings of the emote image. | ||
| */ | ||
| getUrl(settings) { | ||
| const { animationSettings = 'default', backgroundType = 'dark', size = '1.0' } = settings; | ||
| return `https://static-cdn.jtvnw.net/emoticons/v2/${this.id}/${animationSettings}/${backgroundType}/${size}`; | ||
| } | ||
| }; | ||
| ChatEmote = tslib_1.__decorate([ | ||
| (0, rtfm_1.rtfm)('common', 'ChatEmote', 'id') | ||
| ], ChatEmote); | ||
| exports.ChatEmote = ChatEmote; |
| import { rawDataSymbol } from '../DataObject'; | ||
| import { ChatEmote } from './ChatEmote'; | ||
| import { type ChatEmoteWithSetData } from './ChatEmoteWithSet.external'; | ||
| /** | ||
| * A chat emote from an emote set. | ||
| * | ||
| * @inheritDoc | ||
| */ | ||
| export declare class ChatEmoteWithSet extends ChatEmote { | ||
| /** @private */ readonly [rawDataSymbol]: ChatEmoteWithSetData; | ||
| /** | ||
| * The ID of the emote set. | ||
| */ | ||
| get setId(): number; | ||
| } | ||
| //# sourceMappingURL=ChatEmoteWithSet.d.ts.map |
| import { type ChatEmoteData } from './ChatEmote.external'; | ||
| /** @private */ | ||
| export interface ChatEmoteWithSetData extends ChatEmoteData { | ||
| emoticon_set: number; | ||
| } | ||
| //# sourceMappingURL=ChatEmoteWithSet.external.d.ts.map |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ChatEmoteWithSet = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const DataObject_1 = require("../DataObject"); | ||
| const rtfm_1 = require("../rtfm"); | ||
| const ChatEmote_1 = require("./ChatEmote"); | ||
| /** | ||
| * A chat emote from an emote set. | ||
| * | ||
| * @inheritDoc | ||
| */ | ||
| let ChatEmoteWithSet = class ChatEmoteWithSet extends ChatEmote_1.ChatEmote { | ||
| /** | ||
| * The ID of the emote set. | ||
| */ | ||
| get setId() { | ||
| return this[DataObject_1.rawDataSymbol].emoticon_set; | ||
| } | ||
| }; | ||
| ChatEmoteWithSet = tslib_1.__decorate([ | ||
| (0, rtfm_1.rtfm)('common', 'ChatEmoteWithSet', 'id') | ||
| ], ChatEmoteWithSet); | ||
| exports.ChatEmoteWithSet = ChatEmoteWithSet; |
| import { type BasicMessageCheermote } from './BaseCheermoteList'; | ||
| import { type BasicParsedMessagePart, type ParsedMessageEmotePart } from './ParsedMessagePart'; | ||
| /** | ||
| * Transforms the parts of the given text that are marked as emotes. | ||
| * | ||
| * @param text The message text. | ||
| * @param emoteOffsets The emote offsets. An emote name maps to a list of text ranges. | ||
| */ | ||
| export declare function parseEmotePositions(text: string, emoteOffsets: Map<string, string[]>): ParsedMessageEmotePart[]; | ||
| /** | ||
| * Finds the positions of all cheermotes in the given message. | ||
| * | ||
| * @param text The message text. | ||
| * @param names The names of the cheermotes to find. | ||
| */ | ||
| export declare function findCheermotePositions(text: string, names: string[]): BasicMessageCheermote[]; | ||
| /** | ||
| * Add text parts to the given list of message parts for all the text that's unaccounted for. | ||
| * | ||
| * @param text The message text. | ||
| * @param otherPositions The parsed non-text parts of the message. | ||
| */ | ||
| export declare function fillTextPositions(text: string, otherPositions: BasicParsedMessagePart[]): BasicParsedMessagePart[]; | ||
| /** | ||
| * Parse a chat message with emotes and optionally cheermotes. | ||
| * | ||
| * @param text The message text. | ||
| * @param emoteOffsets The emote offsets. An emote name maps to a list of text ranges. | ||
| * @param cheermoteNames The names of the cheermotes to find. Will not do cheermote parsing if not given. | ||
| */ | ||
| export declare function parseChatMessage(text: string, emoteOffsets: Map<string, string[]>, cheermoteNames?: string[]): BasicParsedMessagePart[]; | ||
| //# sourceMappingURL=messagePartParser.d.ts.map |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.parseChatMessage = exports.fillTextPositions = exports.findCheermotePositions = exports.parseEmotePositions = void 0; | ||
| const shared_utils_1 = require("@d-fischer/shared-utils"); | ||
| const ChatEmote_1 = require("./ChatEmote"); | ||
| /** | ||
| * Transforms the parts of the given text that are marked as emotes. | ||
| * | ||
| * @param text The message text. | ||
| * @param emoteOffsets The emote offsets. An emote name maps to a list of text ranges. | ||
| */ | ||
| function parseEmotePositions(text, emoteOffsets) { | ||
| return [...emoteOffsets.entries()] | ||
| .flatMap(([emote, placements]) => placements.map((placement) => { | ||
| const [startStr, endStr] = placement.split('-'); | ||
| const start = +startStr; | ||
| const end = +endStr; | ||
| const name = (0, shared_utils_1.utf8Substring)(text, start, end + 1); | ||
| return { | ||
| type: 'emote', | ||
| position: start, | ||
| length: end - start + 1, | ||
| id: emote, | ||
| name, | ||
| displayInfo: new ChatEmote_1.ChatEmote({ | ||
| code: name, | ||
| id: emote | ||
| }) | ||
| }; | ||
| })) | ||
| .sort((a, b) => a.position - b.position); | ||
| } | ||
| exports.parseEmotePositions = parseEmotePositions; | ||
| /** | ||
| * Finds the positions of all cheermotes in the given message. | ||
| * | ||
| * @param text The message text. | ||
| * @param names The names of the cheermotes to find. | ||
| */ | ||
| function findCheermotePositions(text, names) { | ||
| const result = []; | ||
| const re = new RegExp('(?<=^|\\s)([a-z]+(?:\\d+[a-z]+)*)(\\d+)(?=\\s|$)', 'gi'); | ||
| let match = null; | ||
| while ((match = re.exec(text))) { | ||
| const name = match[1].toLowerCase(); | ||
| if (names.includes(name)) { | ||
| const amount = Number(match[2]); | ||
| result.push({ | ||
| name, | ||
| amount, | ||
| position: (0, shared_utils_1.utf8Length)(text.slice(0, match.index)), | ||
| length: match[0].length | ||
| }); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| exports.findCheermotePositions = findCheermotePositions; | ||
| /** | ||
| * Add text parts to the given list of message parts for all the text that's unaccounted for. | ||
| * | ||
| * @param text The message text. | ||
| * @param otherPositions The parsed non-text parts of the message. | ||
| */ | ||
| function fillTextPositions(text, otherPositions) { | ||
| const messageLength = (0, shared_utils_1.utf8Length)(text); | ||
| if (!otherPositions.length) { | ||
| return [ | ||
| { | ||
| type: 'text', | ||
| position: 0, | ||
| length: messageLength, | ||
| text: text | ||
| } | ||
| ]; | ||
| } | ||
| const result = []; | ||
| let currentPosition = 0; | ||
| for (const token of otherPositions) { | ||
| if (token.position > currentPosition) { | ||
| result.push({ | ||
| type: 'text', | ||
| position: currentPosition, | ||
| length: token.position - currentPosition, | ||
| text: (0, shared_utils_1.utf8Substring)(text, currentPosition, token.position) | ||
| }); | ||
| } | ||
| result.push(token); | ||
| currentPosition = token.position + token.length; | ||
| } | ||
| if (currentPosition < messageLength) { | ||
| result.push({ | ||
| type: 'text', | ||
| position: currentPosition, | ||
| length: messageLength - currentPosition, | ||
| text: (0, shared_utils_1.utf8Substring)(text, currentPosition) | ||
| }); | ||
| } | ||
| return result; | ||
| } | ||
| exports.fillTextPositions = fillTextPositions; | ||
| /** | ||
| * Parse a chat message with emotes and optionally cheermotes. | ||
| * | ||
| * @param text The message text. | ||
| * @param emoteOffsets The emote offsets. An emote name maps to a list of text ranges. | ||
| * @param cheermoteNames The names of the cheermotes to find. Will not do cheermote parsing if not given. | ||
| */ | ||
| function parseChatMessage(text, emoteOffsets, cheermoteNames) { | ||
| if (!text) { | ||
| return []; | ||
| } | ||
| const foundParts = parseEmotePositions(text, emoteOffsets); | ||
| if (cheermoteNames) { | ||
| foundParts.push(...findCheermotePositions(text, cheermoteNames).map((cm) => ({ | ||
| type: 'cheer', | ||
| ...cm | ||
| }))); | ||
| foundParts.sort((a, b) => a.position - b.position); | ||
| } | ||
| return fillTextPositions(text, foundParts); | ||
| } | ||
| exports.parseChatMessage = parseChatMessage; |
| import type { BasicMessageCheermote, MessageCheermote } from './BaseCheermoteList'; | ||
| import type { ChatEmote } from './ChatEmote'; | ||
| export interface ParsedMessageTextPart { | ||
| type: 'text'; | ||
| position: number; | ||
| length: number; | ||
| text: string; | ||
| } | ||
| export interface BasicParsedMessageCheerPart extends BasicMessageCheermote { | ||
| type: 'cheer'; | ||
| } | ||
| export interface ParsedMessageCheerPart extends MessageCheermote { | ||
| type: 'cheer'; | ||
| } | ||
| export interface ParsedMessageEmotePart { | ||
| type: 'emote'; | ||
| position: number; | ||
| length: number; | ||
| id: string; | ||
| name: string; | ||
| displayInfo: ChatEmote; | ||
| } | ||
| export declare type BasicParsedMessagePart = ParsedMessageTextPart | BasicParsedMessageCheerPart | ParsedMessageEmotePart; | ||
| export declare type ParsedMessagePart = ParsedMessageTextPart | ParsedMessageCheerPart | ParsedMessageEmotePart; | ||
| //# sourceMappingURL=ParsedMessagePart.d.ts.map |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Yes
NaN29712
-60.41%27
-52.63%860
-58.77%2
100%