wuira 0.1.4 → 0.1.5

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +112 -0
  3. package/lib/Spells.d.ts +10 -0
  4. package/lib/Spells.lua +19 -0
  5. package/lib/datasources/AuraTimer.d.ts +21 -0
  6. package/lib/datasources/AuraTimer.lua +322 -0
  7. package/lib/datasources/CastTimer.d.ts +9 -0
  8. package/lib/datasources/CastTimer.lua +240 -0
  9. package/lib/datasources/DataSource.d.ts +4 -0
  10. package/lib/datasources/DataSource.lua +24 -0
  11. package/lib/datasources/ProgressSource.d.ts +6 -2
  12. package/lib/datasources/ProgressSource.lua +20 -2
  13. package/lib/datasources/Resources.d.ts +21 -2
  14. package/lib/datasources/Resources.lua +473 -0
  15. package/lib/datasources/SpellCooldown.d.ts +10 -0
  16. package/lib/datasources/SpellCooldown.lua +207 -0
  17. package/lib/datasources/SwingTimer.d.ts +31 -0
  18. package/lib/datasources/SwingTimer.lua +641 -0
  19. package/lib/datasources/TextureSource.d.ts +10 -0
  20. package/lib/datasources/TextureSource.lua +83 -0
  21. package/lib/datasources/TimerSource.d.ts +18 -0
  22. package/lib/datasources/TimerSource.lua +284 -0
  23. package/lib/datasources/index.d.ts +9 -1
  24. package/lib/datasources/index.lua +27 -0
  25. package/lib/index.d.ts +3 -0
  26. package/lib/index.lua +8 -0
  27. package/lib/platform/BlizzardUI.d.ts +12 -0
  28. package/lib/platform/BlizzardUI.lua +352 -0
  29. package/lib/platform/forever.d.ts +40 -2
  30. package/lib/ui/Cell.d.ts +3 -1
  31. package/lib/ui/Icon.d.ts +8 -0
  32. package/lib/ui/Icon.lua +8 -0
  33. package/lib/ui/Label.d.ts +10 -0
  34. package/lib/ui/Label.lua +8 -0
  35. package/lib/ui/ProgressBar.d.ts +5 -1
  36. package/lib/ui/index.d.ts +4 -0
  37. package/lib/ui/index.lua +8 -0
  38. package/lib/ui/layout/measureLayout.lua +8 -1
  39. package/lib/ui/mount.lua +267 -45
  40. package/lib/ui/primitives/jsx.d.ts +7 -2
  41. package/package.json +1 -1
package/lib/ui/mount.lua CHANGED
@@ -244,6 +244,38 @@ local function __TS__ArrayMap(self, callbackfn, thisArg)
244
244
  end
245
245
  return result
246
246
  end
247
+
248
+ local function __TS__InstanceOf(obj, classTbl)
249
+ if type(classTbl) ~= "table" then
250
+ error("Right-hand side of 'instanceof' is not an object", 0)
251
+ end
252
+ if classTbl[Symbol.hasInstance] ~= nil then
253
+ return not not classTbl[Symbol.hasInstance](classTbl, obj)
254
+ end
255
+ if type(obj) == "table" then
256
+ local luaClass = obj.constructor
257
+ while luaClass ~= nil do
258
+ if luaClass == classTbl then
259
+ return true
260
+ end
261
+ luaClass = luaClass.____super
262
+ end
263
+ end
264
+ return false
265
+ end
266
+
267
+ local function __TS__ObjectAssign(target, ...)
268
+ local sources = {...}
269
+ for i = 1, #sources do
270
+ local source = sources[i]
271
+ if type(source) == "table" then
272
+ for key in pairs(source) do
273
+ target[key] = source[key]
274
+ end
275
+ end
276
+ end
277
+ return target
278
+ end
247
279
  -- End of Lua Library inline imports
248
280
  local ____exports = {}
249
281
  local ____measureLayout = require("ui.layout.measureLayout")
@@ -254,6 +286,8 @@ local ____Border = require("ui.decorations.Border")
254
286
  local Border = ____Border.Border
255
287
  local ____statusBarTextures = require("ui.decorations.statusBarTextures")
256
288
  local resolveStatusBarTexture = ____statusBarTextures.resolveStatusBarTexture
289
+ local ____Resources = require("datasources.Resources")
290
+ local HP = ____Resources.HP
257
291
  local mountedFrames = __TS__New(Map)
258
292
  local mountedTrees = __TS__New(Map)
259
293
  function ____exports.unmount(self, frame)
@@ -261,12 +295,16 @@ function ____exports.unmount(self, frame)
261
295
  if tree == nil then
262
296
  return
263
297
  end
298
+ for ____, dispose in ipairs(tree.bindings) do
299
+ dispose(nil)
300
+ end
264
301
  for ____, decoration in ipairs(tree.decorations) do
265
302
  decoration:dispose()
266
303
  end
267
304
  for ____, child in ipairs(tree.frames) do
268
305
  child:UnregisterAllEvents()
269
306
  child:SetScript("OnEvent", nil)
307
+ child:SetScript("OnUpdate", nil)
270
308
  child:Hide()
271
309
  end
272
310
  for ____, cell in ipairs(tree.cells) do
@@ -369,7 +407,8 @@ function ____exports.mount(self, element, parent, rootAnchor)
369
407
  pending,
370
408
  function(____, item) return item.cell end
371
409
  ),
372
- decorations = {}
410
+ decorations = {},
411
+ bindings = {}
373
412
  }
374
413
  mountedTrees:set(root, tree)
375
414
  do
@@ -378,20 +417,48 @@ function ____exports.mount(self, element, parent, rootAnchor)
378
417
  error(failure, 0)
379
418
  end
380
419
  local ____try, ____hasReturned = pcall(function()
420
+ local updates = {}
381
421
  for ____, item in ipairs(pending) do
422
+ local sourceActive = true
423
+ local lastVisible
424
+ local visible = item.cell.props.visible
425
+ local function refreshVisibility()
426
+ local ____sourceActive_10 = sourceActive
427
+ if ____sourceActive_10 then
428
+ local ____temp_9 = visible and visible(nil)
429
+ if ____temp_9 == nil then
430
+ ____temp_9 = true
431
+ end
432
+ ____sourceActive_10 = ____temp_9
433
+ end
434
+ local value = ____sourceActive_10
435
+ if value == lastVisible then
436
+ return
437
+ end
438
+ lastVisible = value
439
+ if value then
440
+ item.frame:Show()
441
+ else
442
+ item.frame:Hide()
443
+ end
444
+ end
445
+ local function onActiveChange(____, active)
446
+ sourceActive = active
447
+ refreshVisibility(nil)
448
+ end
382
449
  local position = item.cell.props
383
450
  local target = anchors:get(item.frame)
384
- local ____opt_7 = item.placement
385
- local x = ____opt_7 and ____opt_7.x or (position.mode == "absolute" and position.x or position.offset.x)
386
- local ____opt_9 = item.placement
387
- local y = ____opt_9 and ____opt_9.y or (position.mode == "absolute" and position.y or position.offset.y)
388
- local ____temp_11
451
+ local ____opt_11 = item.placement
452
+ local x = ____opt_11 and ____opt_11.x or (position.mode == "absolute" and position.x or position.offset.x)
453
+ local ____opt_13 = item.placement
454
+ local y = ____opt_13 and ____opt_13.y or (position.mode == "absolute" and position.y or position.offset.y)
455
+ local ____temp_15
389
456
  if item.frame == root then
390
- ____temp_11 = rootAnchor
457
+ ____temp_15 = rootAnchor
391
458
  else
392
- ____temp_11 = nil
459
+ ____temp_15 = nil
393
460
  end
394
- local overrideAnchor = ____temp_11
461
+ local overrideAnchor = ____temp_15
395
462
  local anchor = overrideAnchor or (item.placement ~= nil and "TOPLEFT" or (position.anchor or "TOPLEFT"))
396
463
  local relativeAnchor = overrideAnchor or (item.placement ~= nil and "TOPLEFT" or (position.relativeAnchor or anchor))
397
464
  item.frame:SetPoint(
@@ -401,48 +468,177 @@ function ____exports.mount(self, element, parent, rootAnchor)
401
468
  x + item.margin.left,
402
469
  -(y + item.margin.top)
403
470
  )
471
+ if item.cell.kind == "label" then
472
+ local props = item.cell.props
473
+ local label = item.frame:CreateFontString(nil, "OVERLAY")
474
+ label:SetAllPoints(item.frame)
475
+ label:SetFont(props.font or "Fonts\\FRIZQT__.TTF", props.fontSize or 12, "OUTLINE")
476
+ label:SetJustifyH(props.align or "LEFT")
477
+ label:SetJustifyV("MIDDLE")
478
+ local color = props.color
479
+ label:SetTextColor(color and color.r or 1, color and color.g or 1, color and color.b or 1, color and color.a or 1)
480
+ local text = props.text
481
+ if type(text) == "function" then
482
+ local previous
483
+ updates[#updates + 1] = function()
484
+ local value = text(nil)
485
+ if issecretvalue(value) or value ~= previous then
486
+ label:SetText(value)
487
+ end
488
+ if not issecretvalue(value) then
489
+ previous = value
490
+ end
491
+ end
492
+ else
493
+ label:SetText(text)
494
+ end
495
+ end
496
+ if item.cell.kind == "icon" then
497
+ local props = item.cell.props
498
+ local texture = item.frame:CreateTexture(nil, "OVERLAY")
499
+ texture:SetAllPoints(item.frame)
500
+ local uv = props.texCoords or ({0, 1, 0, 1})
501
+ texture:SetTexCoord(uv[1], uv[2], uv[3], uv[4])
502
+ texture:SetTexture(props.texture)
503
+ local ____opt_24 = props.textureSource
504
+ if ____opt_24 ~= nil then
505
+ ____opt_24:BindTo(item.frame, texture, onActiveChange)
506
+ end
507
+ end
404
508
  if item.cell.kind == "progress" then
405
509
  local props = item.cell.props
406
510
  local bar = item.frame
407
- local ____opt_12 = props.foreground
408
- local color = ____opt_12 and ____opt_12.color or props.color
409
- local ____bar_SetStatusBarTexture_17 = bar.SetStatusBarTexture
410
- local ____resolveStatusBarTexture_16 = resolveStatusBarTexture
411
- local ____opt_14 = props.foreground
412
- ____bar_SetStatusBarTexture_17(
511
+ local ____opt_26 = props.foreground
512
+ local color = ____opt_26 and ____opt_26.color or props.color
513
+ local ____bar_SetStatusBarTexture_31 = bar.SetStatusBarTexture
514
+ local ____resolveStatusBarTexture_30 = resolveStatusBarTexture
515
+ local ____opt_28 = props.foreground
516
+ ____bar_SetStatusBarTexture_31(
413
517
  bar,
414
- ____resolveStatusBarTexture_16(nil, ____opt_14 and ____opt_14.texture or props.texture or "solid")
518
+ ____resolveStatusBarTexture_30(nil, ____opt_28 and ____opt_28.texture or props.texture or "solid")
415
519
  )
416
520
  bar:SetStatusBarColor(color and color.r or 1, color and color.g or 1, color and color.b or 1, color and color.a or 1)
417
521
  if props.foreground ~= nil then
418
522
  local fill = bar:GetStatusBarTexture()
419
- local ____fill_SetHorizTile_27 = fill.SetHorizTile
420
- local ____props_foreground_tileX_26 = props.foreground.tileX
421
- if ____props_foreground_tileX_26 == nil then
422
- ____props_foreground_tileX_26 = false
523
+ local ____fill_SetHorizTile_41 = fill.SetHorizTile
524
+ local ____props_foreground_tileX_40 = props.foreground.tileX
525
+ if ____props_foreground_tileX_40 == nil then
526
+ ____props_foreground_tileX_40 = false
423
527
  end
424
- ____fill_SetHorizTile_27(fill, ____props_foreground_tileX_26)
425
- local ____fill_SetVertTile_29 = fill.SetVertTile
426
- local ____props_foreground_tileY_28 = props.foreground.tileY
427
- if ____props_foreground_tileY_28 == nil then
428
- ____props_foreground_tileY_28 = false
528
+ ____fill_SetHorizTile_41(fill, ____props_foreground_tileX_40)
529
+ local ____fill_SetVertTile_43 = fill.SetVertTile
530
+ local ____props_foreground_tileY_42 = props.foreground.tileY
531
+ if ____props_foreground_tileY_42 == nil then
532
+ ____props_foreground_tileY_42 = false
429
533
  end
430
- ____fill_SetVertTile_29(fill, ____props_foreground_tileY_28)
534
+ ____fill_SetVertTile_43(fill, ____props_foreground_tileY_42)
431
535
  fill:SetBlendMode(props.foreground.blendMode or "BLEND")
432
536
  local uv = props.foreground.texCoords or ({0, 1, 0, 1})
433
537
  fill:SetTexCoord(uv[1], uv[2], uv[3], uv[4])
434
538
  end
435
539
  bar:SetOrientation(props.orientation == "vertical" and "VERTICAL" or "HORIZONTAL")
436
- local ____bar_SetReverseFill_31 = bar.SetReverseFill
437
- local ____props_reverse_30 = props.reverse
438
- if ____props_reverse_30 == nil then
439
- ____props_reverse_30 = false
540
+ local ____bar_SetReverseFill_45 = bar.SetReverseFill
541
+ local ____props_reverse_44 = props.reverse
542
+ if ____props_reverse_44 == nil then
543
+ ____props_reverse_44 = false
440
544
  end
441
- ____bar_SetReverseFill_31(bar, ____props_reverse_30)
545
+ ____bar_SetReverseFill_45(bar, ____props_reverse_44)
442
546
  bar:SetMinMaxValues(props.min or 0, props.max or 100)
443
547
  local source = item.cell.source or props.source
444
548
  if source ~= nil then
445
- source:BindTo(bar, {min = props.min, max = props.max, current = props.current or props.value})
549
+ local healPredictionBar
550
+ local absorbPredictionBar
551
+ if __TS__InstanceOf(source, HP) then
552
+ local function overlay(____, style, heal)
553
+ bar:SetClipsChildren(true)
554
+ local layer = CreateFrame("StatusBar", nil, bar)
555
+ local ____tree_frames_46 = tree.frames
556
+ ____tree_frames_46[#____tree_frames_46 + 1] = layer
557
+ layer:EnableMouse(false)
558
+ layer:SetFrameLevel(bar:GetFrameLevel())
559
+ layer:SetSize(item.width, item.height)
560
+ layer:SetStatusBarTexture(resolveStatusBarTexture(nil, style.texture or "solid"))
561
+ local tint = style.color
562
+ layer:SetStatusBarColor(tint.r, tint.g, tint.b, tint.a or 0.5)
563
+ local texture = layer:GetStatusBarTexture()
564
+ texture:SetBlendMode(style.blendMode or "BLEND")
565
+ local ____texture_SetHorizTile_48 = texture.SetHorizTile
566
+ local ____style_tileX_47 = style.tileX
567
+ if ____style_tileX_47 == nil then
568
+ ____style_tileX_47 = false
569
+ end
570
+ ____texture_SetHorizTile_48(texture, ____style_tileX_47)
571
+ local ____texture_SetVertTile_50 = texture.SetVertTile
572
+ local ____style_tileY_49 = style.tileY
573
+ if ____style_tileY_49 == nil then
574
+ ____style_tileY_49 = false
575
+ end
576
+ ____texture_SetVertTile_50(texture, ____style_tileY_49)
577
+ local uv = style.texCoords or ({0, 1, 0, 1})
578
+ texture:SetTexCoord(uv[1], uv[2], uv[3], uv[4])
579
+ local vertical = props.orientation == "vertical"
580
+ local ____props_reverse_51 = props.reverse
581
+ if ____props_reverse_51 == nil then
582
+ ____props_reverse_51 = false
583
+ end
584
+ local reverse = ____props_reverse_51
585
+ layer:SetOrientation(vertical and "VERTICAL" or "HORIZONTAL")
586
+ local ____layer_SetReverseFill_53 = layer.SetReverseFill
587
+ local ____heal_52
588
+ if heal then
589
+ ____heal_52 = reverse
590
+ else
591
+ ____heal_52 = not reverse
592
+ end
593
+ ____layer_SetReverseFill_53(layer, ____heal_52)
594
+ if heal then
595
+ local point = vertical and (reverse and "TOPLEFT" or "BOTTOMLEFT") or (reverse and "TOPRIGHT" or "TOPLEFT")
596
+ local relative = vertical and (reverse and "BOTTOMLEFT" or "TOPLEFT") or (reverse and "TOPLEFT" or "TOPRIGHT")
597
+ layer:SetPoint(
598
+ point,
599
+ bar:GetStatusBarTexture(),
600
+ relative,
601
+ 0,
602
+ 0
603
+ )
604
+ else
605
+ layer:SetAllPoints(bar)
606
+ end
607
+ return layer
608
+ end
609
+ local ____opt_54 = source.HealPrediction
610
+ if (____opt_54 and ____opt_54.IsAvailable) == true and props.healPrediction ~= false then
611
+ local ____props_healPrediction_58 = props.healPrediction
612
+ local ____opt_56 = props.healPrediction
613
+ healPredictionBar = overlay(
614
+ nil,
615
+ __TS__ObjectAssign({}, ____props_healPrediction_58, {color = ____opt_56 and ____opt_56.color or ({r = 0.4, g = 1, b = 0.5, a = 0.5})}),
616
+ true
617
+ )
618
+ end
619
+ local ____opt_59 = source.AbsorbPrediction
620
+ if (____opt_59 and ____opt_59.IsAvailable) == true and props.absorbPrediction ~= false then
621
+ local ____props_absorbPrediction_63 = props.absorbPrediction
622
+ local ____opt_61 = props.absorbPrediction
623
+ absorbPredictionBar = overlay(
624
+ nil,
625
+ __TS__ObjectAssign({}, ____props_absorbPrediction_63, {color = ____opt_61 and ____opt_61.color or ({r = 0.8, g = 0.9, b = 1, a = 0.55})}),
626
+ false
627
+ )
628
+ end
629
+ end
630
+ local dispose = source:BindTo(bar, {
631
+ min = props.min,
632
+ max = props.max,
633
+ current = props.current or props.value,
634
+ onActiveChange = onActiveChange,
635
+ healPredictionBar = healPredictionBar,
636
+ absorbPredictionBar = absorbPredictionBar
637
+ })
638
+ if dispose ~= nil then
639
+ local ____tree_bindings_64 = tree.bindings
640
+ ____tree_bindings_64[#____tree_bindings_64 + 1] = dispose
641
+ end
446
642
  else
447
643
  bar:SetValue(props.current or props.value or 0)
448
644
  end
@@ -451,30 +647,56 @@ function ____exports.mount(self, element, parent, rootAnchor)
451
647
  local function attach(self, decoration)
452
648
  if decoration ~= nil then
453
649
  decoration:mount(item.frame, item.width, item.height)
454
- local ____tree_decorations_32 = tree.decorations
455
- ____tree_decorations_32[#____tree_decorations_32 + 1] = decoration
650
+ local ____tree_decorations_65 = tree.decorations
651
+ ____tree_decorations_65[#____tree_decorations_65 + 1] = decoration
456
652
  end
457
653
  end
458
654
  local progress = item.cell.kind == "progress" and item.cell.props or nil
459
- local ____attach_40 = attach
460
- local ____temp_39
655
+ local ____attach_73 = attach
656
+ local ____temp_72
461
657
  if (progress and progress.background) == false then
462
- ____temp_39 = nil
658
+ ____temp_72 = nil
463
659
  else
464
- ____temp_39 = (progress and progress.background) ~= nil and __TS__New(Background, progress.background) or decorations and decorations.background
660
+ ____temp_72 = (progress and progress.background) ~= nil and __TS__New(Background, progress.background) or decorations and decorations.background
465
661
  end
466
- ____attach_40(nil, ____temp_39)
467
- local ____attach_48 = attach
468
- local ____temp_47
662
+ ____attach_73(nil, ____temp_72)
663
+ local ____attach_81 = attach
664
+ local ____temp_80
469
665
  if (progress and progress.backdrop) == false then
470
- ____temp_47 = nil
666
+ ____temp_80 = nil
471
667
  else
472
- ____temp_47 = (progress and progress.backdrop) ~= nil and __TS__New(Border, progress.backdrop) or decorations and decorations.border
668
+ ____temp_80 = (progress and progress.backdrop) ~= nil and __TS__New(Border, progress.backdrop) or decorations and decorations.border
473
669
  end
474
- ____attach_48(nil, ____temp_47)
670
+ ____attach_81(nil, ____temp_80)
475
671
  attach(nil, decorations and decorations.glow)
476
672
  mountedFrames:set(item.cell.props, item.frame)
477
- item.frame:Show()
673
+ refreshVisibility(nil)
674
+ if visible ~= nil then
675
+ updates[#updates + 1] = refreshVisibility
676
+ end
677
+ end
678
+ if #updates > 0 then
679
+ local driver = CreateFrame("Frame", nil, parent)
680
+ local ____tree_frames_84 = tree.frames
681
+ ____tree_frames_84[#____tree_frames_84 + 1] = driver
682
+ local elapsed = 0
683
+ driver:SetScript(
684
+ "OnUpdate",
685
+ function(_frame, delta)
686
+ elapsed = elapsed + delta
687
+ if elapsed < 0.05 then
688
+ return
689
+ end
690
+ elapsed = 0
691
+ for ____, update in ipairs(updates) do
692
+ update(nil)
693
+ end
694
+ end
695
+ )
696
+ for ____, update in ipairs(updates) do
697
+ update(nil)
698
+ end
699
+ driver:Show()
478
700
  end
479
701
  end)
480
702
  if not ____try then
@@ -3,18 +3,21 @@ import type { FlowLayoutProps } from "../FlowLayout";
3
3
  import type { GridLayoutProps } from "../GridLayout";
4
4
  import type { ProgressBarProps } from "../ProgressBar";
5
5
  import type { ProgressSource } from "../../datasources/ProgressSource";
6
+ import type { TimerSource } from "../../datasources/TimerSource";
7
+ import type { LabelProps } from "../Label";
8
+ import type { IconProps } from "../Icon";
6
9
  /** Declarative UI description; native frames are created by mount. */
7
10
  export interface Element {
8
11
  kind: string;
9
12
  props: object;
10
13
  child?: Element;
11
14
  children?: Element[];
12
- source?: ProgressSource;
15
+ source?: ProgressSource | TimerSource;
13
16
  }
14
17
  export type Component<P extends object> = (props: P, child?: Element) => Element;
15
18
  export declare namespace UI {
16
19
  function Fragment(): Element;
17
- function createElement<P extends object>(component: Component<P> | "cell" | "flow" | "grid" | "progress", props: P | undefined, ...children: (Element | Element[])[]): Element;
20
+ function createElement<P extends object>(component: Component<P> | "cell" | "flow" | "grid" | "progress" | "label" | "icon", props: P | undefined, ...children: (Element | Element[])[]): Element;
18
21
  namespace JSX {
19
22
  type Element = import("./jsx").Element;
20
23
  interface ElementChildrenAttribute {
@@ -33,6 +36,8 @@ export declare namespace UI {
33
36
  progress: Partial<ProgressBarProps> & {
34
37
  child?: Element;
35
38
  };
39
+ label: Partial<LabelProps>;
40
+ icon: Partial<IconProps>;
36
41
  }
37
42
  }
38
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuira",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "author": {
5
5
  "name": "Kerim Cetinbas",
6
6
  "email": "a.cetinbas@icloud.com"