@lumiastream/lumia-types 3.5.6 → 3.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/emulate.helpers.d.ts +1 -0
- package/dist/emulate.helpers.js +54 -0
- package/dist/esm/emulate.helpers.js +53 -0
- package/dist/esm/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
|
@@ -6,3 +6,4 @@ export interface InputFieldLike {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function isRedundantInputField(inputField: InputFieldLike, allInputFields: ReadonlyArray<InputFieldLike> | undefined): boolean;
|
|
8
8
|
export declare function syncLinkedVariableFields(values: Record<string, any>): void;
|
|
9
|
+
export declare function coerceNumericAlertFields(values: Record<string, any>): void;
|
package/dist/emulate.helpers.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.getExampleAlertVariableValue = getExampleAlertVariableValue;
|
|
|
5
5
|
exports.buildExampleAlertVariables = buildExampleAlertVariables;
|
|
6
6
|
exports.isRedundantInputField = isRedundantInputField;
|
|
7
7
|
exports.syncLinkedVariableFields = syncLinkedVariableFields;
|
|
8
|
+
exports.coerceNumericAlertFields = coerceNumericAlertFields;
|
|
8
9
|
exports.EMULATE_EXAMPLE_AVATAR_URL = 'https://static-cdn.jtvnw.net/jtv_user_pictures/2b1fa336-f9b2-42cf-bd2c-98675da74982-profile_image-300x300.png';
|
|
9
10
|
function getExampleAlertVariableValue(variableName) {
|
|
10
11
|
const lowered = variableName.toLowerCase();
|
|
@@ -122,3 +123,56 @@ function syncLinkedVariableFields(values) {
|
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
}
|
|
126
|
+
// Canonical wire-type-aligned numeric field set. Each name corresponds to a
|
|
127
|
+
// dynamic/extraSettings field that real platform managers (twitch, kick,
|
|
128
|
+
// streamlabs, …) emit as a Number — see wire.types.ts. Emulation form inputs
|
|
129
|
+
// hand back numeric strings ("1"), which silently break downstream consumers
|
|
130
|
+
// that do arithmetic (SE compat shim's resolvedAmount, goal/cheer widgets,
|
|
131
|
+
// plugin SDK reducers). Run this before dispatch to match the live shape.
|
|
132
|
+
//
|
|
133
|
+
// `value` is intentionally NOT in this set — wire.types.ts uses `value: string`
|
|
134
|
+
// for most alerts (templated display string) and `value: number` only for a
|
|
135
|
+
// handful (bits, raid, kicks, hypetrain, ads). Coerce `value` at the form
|
|
136
|
+
// binding using inputField.type === 'number' instead, so the per-alert
|
|
137
|
+
// contract isn't violated.
|
|
138
|
+
const NUMERIC_ALERT_FIELDS = new Set([
|
|
139
|
+
'amount',
|
|
140
|
+
'giftAmount',
|
|
141
|
+
'totalGifts',
|
|
142
|
+
'subMonths',
|
|
143
|
+
'streakMonths',
|
|
144
|
+
'cumulativeMonths',
|
|
145
|
+
'streak',
|
|
146
|
+
'months',
|
|
147
|
+
'bits',
|
|
148
|
+
'kicks',
|
|
149
|
+
'viewers',
|
|
150
|
+
'total',
|
|
151
|
+
'previousTotal',
|
|
152
|
+
'current_amount',
|
|
153
|
+
'target_amount',
|
|
154
|
+
'length',
|
|
155
|
+
'streak_count',
|
|
156
|
+
'channel_points_awarded',
|
|
157
|
+
'reward_cost',
|
|
158
|
+
'view_count',
|
|
159
|
+
'clip_duration',
|
|
160
|
+
'timeout_duration',
|
|
161
|
+
'expiration_ms',
|
|
162
|
+
'poll_duration',
|
|
163
|
+
'level',
|
|
164
|
+
'progress',
|
|
165
|
+
'goal',
|
|
166
|
+
]);
|
|
167
|
+
function coerceNumericAlertFields(values) {
|
|
168
|
+
if (!values)
|
|
169
|
+
return;
|
|
170
|
+
for (const key of Object.keys(values)) {
|
|
171
|
+
if (!NUMERIC_ALERT_FIELDS.has(key))
|
|
172
|
+
continue;
|
|
173
|
+
const v = values[key];
|
|
174
|
+
if (typeof v === 'string' && v !== '' && !isNaN(Number(v))) {
|
|
175
|
+
values[key] = Number(v);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -115,3 +115,56 @@ export function syncLinkedVariableFields(values) {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
// Canonical wire-type-aligned numeric field set. Each name corresponds to a
|
|
119
|
+
// dynamic/extraSettings field that real platform managers (twitch, kick,
|
|
120
|
+
// streamlabs, …) emit as a Number — see wire.types.ts. Emulation form inputs
|
|
121
|
+
// hand back numeric strings ("1"), which silently break downstream consumers
|
|
122
|
+
// that do arithmetic (SE compat shim's resolvedAmount, goal/cheer widgets,
|
|
123
|
+
// plugin SDK reducers). Run this before dispatch to match the live shape.
|
|
124
|
+
//
|
|
125
|
+
// `value` is intentionally NOT in this set — wire.types.ts uses `value: string`
|
|
126
|
+
// for most alerts (templated display string) and `value: number` only for a
|
|
127
|
+
// handful (bits, raid, kicks, hypetrain, ads). Coerce `value` at the form
|
|
128
|
+
// binding using inputField.type === 'number' instead, so the per-alert
|
|
129
|
+
// contract isn't violated.
|
|
130
|
+
const NUMERIC_ALERT_FIELDS = new Set([
|
|
131
|
+
'amount',
|
|
132
|
+
'giftAmount',
|
|
133
|
+
'totalGifts',
|
|
134
|
+
'subMonths',
|
|
135
|
+
'streakMonths',
|
|
136
|
+
'cumulativeMonths',
|
|
137
|
+
'streak',
|
|
138
|
+
'months',
|
|
139
|
+
'bits',
|
|
140
|
+
'kicks',
|
|
141
|
+
'viewers',
|
|
142
|
+
'total',
|
|
143
|
+
'previousTotal',
|
|
144
|
+
'current_amount',
|
|
145
|
+
'target_amount',
|
|
146
|
+
'length',
|
|
147
|
+
'streak_count',
|
|
148
|
+
'channel_points_awarded',
|
|
149
|
+
'reward_cost',
|
|
150
|
+
'view_count',
|
|
151
|
+
'clip_duration',
|
|
152
|
+
'timeout_duration',
|
|
153
|
+
'expiration_ms',
|
|
154
|
+
'poll_duration',
|
|
155
|
+
'level',
|
|
156
|
+
'progress',
|
|
157
|
+
'goal',
|
|
158
|
+
]);
|
|
159
|
+
export function coerceNumericAlertFields(values) {
|
|
160
|
+
if (!values)
|
|
161
|
+
return;
|
|
162
|
+
for (const key of Object.keys(values)) {
|
|
163
|
+
if (!NUMERIC_ALERT_FIELDS.has(key))
|
|
164
|
+
continue;
|
|
165
|
+
const v = values[key];
|
|
166
|
+
if (typeof v === 'string' && v !== '' && !isNaN(Number(v))) {
|
|
167
|
+
values[key] = Number(v);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { LumiaIntegrations, LumiaEventTypes, } from './event.types.js';
|
|
|
4
4
|
export { LumiaEventListTypes, LumiaMapAlertTypeToEventListType, AlertsToFilter, PlatformsToFilter, LumiaEventListTypeColors, getEventListCategoryColor } from './eventlist.types.js';
|
|
5
5
|
export { SystemVariables, ReservedVariables, AllVariables, getAcceptedVariableName, getAcceptedVariableNames, } from './variables.types.js';
|
|
6
6
|
export { formatCondition } from './helpers.js';
|
|
7
|
-
export { EMULATE_EXAMPLE_AVATAR_URL, getExampleAlertVariableValue, buildExampleAlertVariables, isRedundantInputField, syncLinkedVariableFields, } from './emulate.helpers.js';
|
|
7
|
+
export { EMULATE_EXAMPLE_AVATAR_URL, getExampleAlertVariableValue, buildExampleAlertVariables, coerceNumericAlertFields, isRedundantInputField, syncLinkedVariableFields, } from './emulate.helpers.js';
|
|
8
8
|
export { KickKicksData } from './kick_kicks.js';
|
|
9
9
|
export { BLANK_OVERLAY_TEMPLATE_ID } from './overlay_template.types.js';
|
|
10
10
|
export { TiktokGiftsData } from './tiktok_gifts.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { ILumiaSendPack, ILumiaEvent, ILumiaEventChatCommandBody, ILumiaEventCha
|
|
|
4
4
|
export { LumiaEventListTypes, LumiaMapAlertTypeToEventListType, AlertsToFilter, PlatformsToFilter, LumiaEventListTypeColors, getEventListCategoryColor } from './eventlist.types';
|
|
5
5
|
export { SystemVariables, ReservedVariables, AllVariables, getAcceptedVariableName, getAcceptedVariableNames, type LumiaAcceptedVariable, type LumiaAcceptedVariableDefinition, } from './variables.types';
|
|
6
6
|
export { formatCondition } from './helpers';
|
|
7
|
-
export { EMULATE_EXAMPLE_AVATAR_URL, getExampleAlertVariableValue, buildExampleAlertVariables, isRedundantInputField, syncLinkedVariableFields, type InputFieldLike, } from './emulate.helpers';
|
|
7
|
+
export { EMULATE_EXAMPLE_AVATAR_URL, getExampleAlertVariableValue, buildExampleAlertVariables, coerceNumericAlertFields, isRedundantInputField, syncLinkedVariableFields, type InputFieldLike, } from './emulate.helpers';
|
|
8
8
|
export { KickKicksData } from './kick_kicks';
|
|
9
9
|
export { BLANK_OVERLAY_TEMPLATE_ID, type OverlayTemplate, type OverlayTemplateLayerDescriptor, type OverlayTemplateAnchor, type OverlayTemplateLayerOverrides } from './overlay_template.types';
|
|
10
10
|
export { TiktokGiftsData } from './tiktok_gifts';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SongRequestPlaybackTarget = exports.SongRequestProvider = exports.SongRequestSource = exports.SongRequestStatus = exports.VIEWER_PROFILE_ACHIEVEMENTS = exports.YoutubeSuperstickersData = exports.TiktokGiftsData = exports.BLANK_OVERLAY_TEMPLATE_ID = exports.KickKicksData = exports.syncLinkedVariableFields = exports.isRedundantInputField = exports.buildExampleAlertVariables = exports.getExampleAlertVariableValue = exports.EMULATE_EXAMPLE_AVATAR_URL = exports.formatCondition = exports.getAcceptedVariableNames = exports.getAcceptedVariableName = exports.AllVariables = exports.ReservedVariables = exports.SystemVariables = exports.getEventListCategoryColor = exports.LumiaEventListTypeColors = exports.PlatformsToFilter = exports.AlertsToFilter = exports.LumiaMapAlertTypeToEventListType = exports.LumiaEventListTypes = exports.LumiaEventTypes = exports.LumiaIntegrations = exports.LumiaAlertConfigs = exports.LumiaRedemptionCurrencySymbol = exports.LumiaRedemptionCurrency = exports.VariationCurrencySymbol = exports.LumiaVariationCurrency = exports.LumiaVariationConditions = exports.LumiaActivityTestType = exports.LumiaActivityNoValueTypes = exports.LumiaActivityApiValueType = exports.LumiaActivityOriginTypes = exports.LumiaAlertFriendlyValues = exports.LumiaAlertValues = exports.LumiaExternalActivityCommandTypes = exports.LumiaActivityCommandTypes = exports.LumiaStreamingSites = void 0;
|
|
3
|
+
exports.SongRequestPlaybackTarget = exports.SongRequestProvider = exports.SongRequestSource = exports.SongRequestStatus = exports.VIEWER_PROFILE_ACHIEVEMENTS = exports.YoutubeSuperstickersData = exports.TiktokGiftsData = exports.BLANK_OVERLAY_TEMPLATE_ID = exports.KickKicksData = exports.syncLinkedVariableFields = exports.isRedundantInputField = exports.coerceNumericAlertFields = exports.buildExampleAlertVariables = exports.getExampleAlertVariableValue = exports.EMULATE_EXAMPLE_AVATAR_URL = exports.formatCondition = exports.getAcceptedVariableNames = exports.getAcceptedVariableName = exports.AllVariables = exports.ReservedVariables = exports.SystemVariables = exports.getEventListCategoryColor = exports.LumiaEventListTypeColors = exports.PlatformsToFilter = exports.AlertsToFilter = exports.LumiaMapAlertTypeToEventListType = exports.LumiaEventListTypes = exports.LumiaEventTypes = exports.LumiaIntegrations = exports.LumiaAlertConfigs = exports.LumiaRedemptionCurrencySymbol = exports.LumiaRedemptionCurrency = exports.VariationCurrencySymbol = exports.LumiaVariationCurrency = exports.LumiaVariationConditions = exports.LumiaActivityTestType = exports.LumiaActivityNoValueTypes = exports.LumiaActivityApiValueType = exports.LumiaActivityOriginTypes = exports.LumiaAlertFriendlyValues = exports.LumiaAlertValues = exports.LumiaExternalActivityCommandTypes = exports.LumiaActivityCommandTypes = exports.LumiaStreamingSites = void 0;
|
|
4
4
|
var activity_types_1 = require("./activity.types");
|
|
5
5
|
Object.defineProperty(exports, "LumiaStreamingSites", { enumerable: true, get: function () { return activity_types_1.LumiaStreamingSites; } });
|
|
6
6
|
Object.defineProperty(exports, "LumiaActivityCommandTypes", { enumerable: true, get: function () { return activity_types_1.LumiaActivityCommandTypes; } });
|
|
@@ -40,6 +40,7 @@ var emulate_helpers_1 = require("./emulate.helpers");
|
|
|
40
40
|
Object.defineProperty(exports, "EMULATE_EXAMPLE_AVATAR_URL", { enumerable: true, get: function () { return emulate_helpers_1.EMULATE_EXAMPLE_AVATAR_URL; } });
|
|
41
41
|
Object.defineProperty(exports, "getExampleAlertVariableValue", { enumerable: true, get: function () { return emulate_helpers_1.getExampleAlertVariableValue; } });
|
|
42
42
|
Object.defineProperty(exports, "buildExampleAlertVariables", { enumerable: true, get: function () { return emulate_helpers_1.buildExampleAlertVariables; } });
|
|
43
|
+
Object.defineProperty(exports, "coerceNumericAlertFields", { enumerable: true, get: function () { return emulate_helpers_1.coerceNumericAlertFields; } });
|
|
43
44
|
Object.defineProperty(exports, "isRedundantInputField", { enumerable: true, get: function () { return emulate_helpers_1.isRedundantInputField; } });
|
|
44
45
|
Object.defineProperty(exports, "syncLinkedVariableFields", { enumerable: true, get: function () { return emulate_helpers_1.syncLinkedVariableFields; } });
|
|
45
46
|
var kick_kicks_1 = require("./kick_kicks");
|