@lumiastream/ui 0.6.9 → 0.7.2

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/index.js CHANGED
@@ -5412,10 +5412,8 @@ function mapChatbox(widget, ctx) {
5412
5412
  const fadeOutSeconds = isPermanent ? 0 : typeof v.fadeOut === "number" && v.fadeOut > 0 ? v.fadeOut : typeof v.delay === "number" && v.delay > 0 ? v.delay : DEFAULT_FADE_SECONDS;
5413
5413
  const DEFAULT_CHATBOX_FONT_SIZE = 14;
5414
5414
  const moduleCss = {};
5415
- const fontFamily = messageWins("font-family");
5416
- if (fontFamily != null) moduleCss.fontFamily = fontFamily;
5417
- const fontSize = messageWins("font-size");
5418
- moduleCss.fontSize = fontSize != null ? fontSize : DEFAULT_CHATBOX_FONT_SIZE;
5415
+ const messageFontSize = messageCss["font-size"];
5416
+ moduleCss.fontSize = typeof messageFontSize === "number" && messageFontSize > 0 || typeof messageFontSize === "string" && messageFontSize.length > 0 ? messageFontSize : DEFAULT_CHATBOX_FONT_SIZE;
5419
5417
  const rawColor = messageWins("color");
5420
5418
  const isSeDefaultColor = rawColor == null || typeof rawColor === "string" && (rawColor === "" || rawColor.toLowerCase() === "#fff" || rawColor.toLowerCase() === "#ffffff");
5421
5419
  if (!isSeDefaultColor) {
@@ -5425,6 +5423,10 @@ function mapChatbox(widget, ctx) {
5425
5423
  } else if (rawColor != null) {
5426
5424
  moduleCss.color = rawColor;
5427
5425
  }
5426
+ const messageFontFamily = messageCss["font-family"];
5427
+ if (typeof messageFontFamily === "string" && messageFontFamily.length > 0) {
5428
+ moduleCss.fontFamily = messageFontFamily;
5429
+ }
5428
5430
  const messageTextShadow = messageCss["text-shadow"];
5429
5431
  if (typeof messageTextShadow === "string" && messageTextShadow.length > 0) {
5430
5432
  moduleCss.textShadow = messageTextShadow;
@@ -5503,7 +5505,7 @@ var SE_LISTENER_TO_LUMIA_CATEGORY = {
5503
5505
  "superchat-recent": "superchats",
5504
5506
  "hypetrain-latest": "hypetrain"
5505
5507
  };
5506
- function computeAllowedEventsFromSEListeners(seListeners, explicitListener) {
5508
+ function collectEnabledSEListeners(seListeners, explicitListener) {
5507
5509
  const enabled = [];
5508
5510
  if (seListeners && typeof seListeners === "object" && !Array.isArray(seListeners)) {
5509
5511
  for (const [k, v] of Object.entries(seListeners)) {
@@ -5515,6 +5517,19 @@ function computeAllowedEventsFromSEListeners(seListeners, explicitListener) {
5515
5517
  if (typeof explicitListener === "string" && explicitListener && !enabled.includes(explicitListener)) {
5516
5518
  enabled.push(explicitListener);
5517
5519
  }
5520
+ return enabled;
5521
+ }
5522
+ function seWidgetIsCheer(widget) {
5523
+ if (typeof widget.type === "string" && widget.type.includes("cheer")) return true;
5524
+ const listeners = collectEnabledSEListeners(widget.listeners, widget.listener);
5525
+ const fromVars = widget.variables?.listener;
5526
+ if (typeof fromVars === "string" && fromVars) listeners.push(fromVars);
5527
+ return listeners.some(
5528
+ (listener) => SE_LISTENER_TO_LUMIA_CATEGORY[listener] === LumiaEventListTypes.BITS
5529
+ );
5530
+ }
5531
+ function computeAllowedEventsFromSEListeners(seListeners, explicitListener) {
5532
+ const enabled = collectEnabledSEListeners(seListeners, explicitListener);
5518
5533
  if (enabled.length === 0) return void 0;
5519
5534
  const allowedCategories = /* @__PURE__ */ new Set();
5520
5535
  for (const listener of enabled) {
@@ -5540,6 +5555,15 @@ function seTemplateToMarqueeTemplate(seTemplate) {
5540
5555
  if (typeof seTemplate !== "string" || !seTemplate.trim()) return void 0;
5541
5556
  return translateSeText(seTemplate);
5542
5557
  }
5558
+ function ensureCheermoteTemplate(template) {
5559
+ const fallback = "{{username}}: {{cheermote}}{{amount}} ";
5560
+ if (!template || !template.trim()) return fallback;
5561
+ if (template.includes("{{cheermote}}")) return template;
5562
+ if (template.includes("{{amount}}")) {
5563
+ return template.replace("{{amount}}", "{{cheermote}}{{amount}}");
5564
+ }
5565
+ return `${template.replace(/\s+$/, "")} {{cheermote}}{{amount}} `;
5566
+ }
5543
5567
  function mapEventList(widget, ctx) {
5544
5568
  const v = widget.variables ?? {};
5545
5569
  const allowedEvents = computeAllowedEventsFromSEListeners(widget.listeners, widget.listener);
@@ -5547,7 +5571,9 @@ function mapEventList(widget, ctx) {
5547
5571
  const seText = widget.text;
5548
5572
  const scrolling = seText?.scrolling;
5549
5573
  const isMarquee = !!(scrolling && scrolling.enabled === true);
5550
- const itemTemplate = isMarquee ? seTemplateToMarqueeTemplate(seText?.value) : void 0;
5574
+ const isCheerMarquee = isMarquee && seWidgetIsCheer(widget);
5575
+ const baseItemTemplate = isMarquee ? seTemplateToMarqueeTemplate(seText?.value) : void 0;
5576
+ const itemTemplate = isCheerMarquee ? ensureCheermoteTemplate(baseItemTemplate) : baseItemTemplate;
5551
5577
  const marqueeSpeed = isMarquee ? seScrollSpeedToPixelsPerSecond(scrolling?.speed) : void 0;
5552
5578
  const marqueeDirection = isMarquee ? scrolling?.direction === "right" ? "right" : "left" : void 0;
5553
5579
  const theme = isMarquee ? "marquee" : v.theme ?? "simple";
@@ -10209,19 +10235,17 @@ function StepReview({
10209
10235
  ] });
10210
10236
  }
10211
10237
  var CUSTOM_WIDGET_TABS = [
10212
- { key: "listeners", label: "listeners" },
10213
- { key: "css", label: "variables.css" },
10214
- { key: "html", label: "variables.html" },
10215
- { key: "js", label: "variables.js" },
10216
- { key: "fields", label: "variables.fields" },
10217
- { key: "fieldData", label: "variables.fieldData" },
10218
- { key: "provider", label: "provider" }
10238
+ { key: "css", label: "CSS" },
10239
+ { key: "html", label: "HTML" },
10240
+ { key: "js", label: "JS" },
10241
+ { key: "fields", label: "Fields" },
10242
+ { key: "fieldData", label: "FieldData" },
10243
+ { key: "listeners", label: "Listeners" },
10244
+ { key: "provider", label: "Provider" }
10219
10245
  ];
10220
10246
  function CustomWidgetCard({ widget }) {
10221
10247
  const tabs = CUSTOM_WIDGET_TABS.filter(({ key }) => widget[key].trim().length > 0);
10222
- const [activeKey, setActiveKey] = useState6(
10223
- tabs[0]?.key ?? "js"
10224
- );
10248
+ const [activeKey, setActiveKey] = useState6(tabs[0]?.key ?? "js");
10225
10249
  const [copied, setCopied] = useState6(false);
10226
10250
  const value = widget[activeKey] ?? "";
10227
10251
  useEffect6(() => setCopied(false), [activeKey]);
package/dist/se-import.js CHANGED
@@ -2332,10 +2332,8 @@ function mapChatbox(widget, ctx) {
2332
2332
  const fadeOutSeconds = isPermanent ? 0 : typeof v.fadeOut === "number" && v.fadeOut > 0 ? v.fadeOut : typeof v.delay === "number" && v.delay > 0 ? v.delay : DEFAULT_FADE_SECONDS;
2333
2333
  const DEFAULT_CHATBOX_FONT_SIZE = 14;
2334
2334
  const moduleCss = {};
2335
- const fontFamily = messageWins("font-family");
2336
- if (fontFamily != null) moduleCss.fontFamily = fontFamily;
2337
- const fontSize = messageWins("font-size");
2338
- moduleCss.fontSize = fontSize != null ? fontSize : DEFAULT_CHATBOX_FONT_SIZE;
2335
+ const messageFontSize = messageCss["font-size"];
2336
+ moduleCss.fontSize = typeof messageFontSize === "number" && messageFontSize > 0 || typeof messageFontSize === "string" && messageFontSize.length > 0 ? messageFontSize : DEFAULT_CHATBOX_FONT_SIZE;
2339
2337
  const rawColor = messageWins("color");
2340
2338
  const isSeDefaultColor = rawColor == null || typeof rawColor === "string" && (rawColor === "" || rawColor.toLowerCase() === "#fff" || rawColor.toLowerCase() === "#ffffff");
2341
2339
  if (!isSeDefaultColor) {
@@ -2345,6 +2343,10 @@ function mapChatbox(widget, ctx) {
2345
2343
  } else if (rawColor != null) {
2346
2344
  moduleCss.color = rawColor;
2347
2345
  }
2346
+ const messageFontFamily = messageCss["font-family"];
2347
+ if (typeof messageFontFamily === "string" && messageFontFamily.length > 0) {
2348
+ moduleCss.fontFamily = messageFontFamily;
2349
+ }
2348
2350
  const messageTextShadow = messageCss["text-shadow"];
2349
2351
  if (typeof messageTextShadow === "string" && messageTextShadow.length > 0) {
2350
2352
  moduleCss.textShadow = messageTextShadow;
@@ -2423,7 +2425,7 @@ var SE_LISTENER_TO_LUMIA_CATEGORY = {
2423
2425
  "superchat-recent": "superchats",
2424
2426
  "hypetrain-latest": "hypetrain"
2425
2427
  };
2426
- function computeAllowedEventsFromSEListeners(seListeners, explicitListener) {
2428
+ function collectEnabledSEListeners(seListeners, explicitListener) {
2427
2429
  const enabled = [];
2428
2430
  if (seListeners && typeof seListeners === "object" && !Array.isArray(seListeners)) {
2429
2431
  for (const [k, v] of Object.entries(seListeners)) {
@@ -2435,6 +2437,19 @@ function computeAllowedEventsFromSEListeners(seListeners, explicitListener) {
2435
2437
  if (typeof explicitListener === "string" && explicitListener && !enabled.includes(explicitListener)) {
2436
2438
  enabled.push(explicitListener);
2437
2439
  }
2440
+ return enabled;
2441
+ }
2442
+ function seWidgetIsCheer(widget) {
2443
+ if (typeof widget.type === "string" && widget.type.includes("cheer")) return true;
2444
+ const listeners = collectEnabledSEListeners(widget.listeners, widget.listener);
2445
+ const fromVars = widget.variables?.listener;
2446
+ if (typeof fromVars === "string" && fromVars) listeners.push(fromVars);
2447
+ return listeners.some(
2448
+ (listener) => SE_LISTENER_TO_LUMIA_CATEGORY[listener] === LumiaEventListTypes.BITS
2449
+ );
2450
+ }
2451
+ function computeAllowedEventsFromSEListeners(seListeners, explicitListener) {
2452
+ const enabled = collectEnabledSEListeners(seListeners, explicitListener);
2438
2453
  if (enabled.length === 0) return void 0;
2439
2454
  const allowedCategories = /* @__PURE__ */ new Set();
2440
2455
  for (const listener of enabled) {
@@ -2460,6 +2475,15 @@ function seTemplateToMarqueeTemplate(seTemplate) {
2460
2475
  if (typeof seTemplate !== "string" || !seTemplate.trim()) return void 0;
2461
2476
  return translateSeText(seTemplate);
2462
2477
  }
2478
+ function ensureCheermoteTemplate(template) {
2479
+ const fallback = "{{username}}: {{cheermote}}{{amount}} ";
2480
+ if (!template || !template.trim()) return fallback;
2481
+ if (template.includes("{{cheermote}}")) return template;
2482
+ if (template.includes("{{amount}}")) {
2483
+ return template.replace("{{amount}}", "{{cheermote}}{{amount}}");
2484
+ }
2485
+ return `${template.replace(/\s+$/, "")} {{cheermote}}{{amount}} `;
2486
+ }
2463
2487
  function mapEventList(widget, ctx) {
2464
2488
  const v = widget.variables ?? {};
2465
2489
  const allowedEvents = computeAllowedEventsFromSEListeners(widget.listeners, widget.listener);
@@ -2467,7 +2491,9 @@ function mapEventList(widget, ctx) {
2467
2491
  const seText = widget.text;
2468
2492
  const scrolling = seText?.scrolling;
2469
2493
  const isMarquee = !!(scrolling && scrolling.enabled === true);
2470
- const itemTemplate = isMarquee ? seTemplateToMarqueeTemplate(seText?.value) : void 0;
2494
+ const isCheerMarquee = isMarquee && seWidgetIsCheer(widget);
2495
+ const baseItemTemplate = isMarquee ? seTemplateToMarqueeTemplate(seText?.value) : void 0;
2496
+ const itemTemplate = isCheerMarquee ? ensureCheermoteTemplate(baseItemTemplate) : baseItemTemplate;
2471
2497
  const marqueeSpeed = isMarquee ? seScrollSpeedToPixelsPerSecond(scrolling?.speed) : void 0;
2472
2498
  const marqueeDirection = isMarquee ? scrolling?.direction === "right" ? "right" : "left" : void 0;
2473
2499
  const theme = isMarquee ? "marquee" : v.theme ?? "simple";
@@ -9085,19 +9111,17 @@ function StepReview({
9085
9111
  ] });
9086
9112
  }
9087
9113
  var CUSTOM_WIDGET_TABS = [
9088
- { key: "listeners", label: "listeners" },
9089
- { key: "css", label: "variables.css" },
9090
- { key: "html", label: "variables.html" },
9091
- { key: "js", label: "variables.js" },
9092
- { key: "fields", label: "variables.fields" },
9093
- { key: "fieldData", label: "variables.fieldData" },
9094
- { key: "provider", label: "provider" }
9114
+ { key: "css", label: "CSS" },
9115
+ { key: "html", label: "HTML" },
9116
+ { key: "js", label: "JS" },
9117
+ { key: "fields", label: "Fields" },
9118
+ { key: "fieldData", label: "FieldData" },
9119
+ { key: "listeners", label: "Listeners" },
9120
+ { key: "provider", label: "Provider" }
9095
9121
  ];
9096
9122
  function CustomWidgetCard({ widget }) {
9097
9123
  const tabs = CUSTOM_WIDGET_TABS.filter(({ key }) => widget[key].trim().length > 0);
9098
- const [activeKey, setActiveKey] = useState6(
9099
- tabs[0]?.key ?? "js"
9100
- );
9124
+ const [activeKey, setActiveKey] = useState6(tabs[0]?.key ?? "js");
9101
9125
  const [copied, setCopied] = useState6(false);
9102
9126
  const value = widget[activeKey] ?? "";
9103
9127
  useEffect6(() => setCopied(false), [activeKey]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumiastream/ui",
3
- "version": "0.6.9",
3
+ "version": "0.7.2",
4
4
  "author": "Lumia Stream",
5
5
  "license": "ISC",
6
6
  "description": "Lumia UI Kit",
@@ -128,8 +128,8 @@
128
128
  "vitest": "^4.1.6"
129
129
  },
130
130
  "dependencies": {
131
- "@lumiastream/lumia-translations": "1.16.5",
132
- "@lumiastream/lumia-types": "3.6.5",
131
+ "@lumiastream/lumia-translations": "1.16.6",
132
+ "@lumiastream/lumia-types": "3.6.8",
133
133
  "classnames": "^2.5.1",
134
134
  "globals": "^17.4.0",
135
135
  "nanoid": "^5.1.11",