wuira 0.1.0 → 0.1.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.
Files changed (109) hide show
  1. package/README.md +204 -18
  2. package/cli/wuira.mjs +67 -0
  3. package/config/tsconfig.json +27 -0
  4. package/lib/Console.d.ts +5 -0
  5. package/lib/Console.lua +20 -0
  6. package/lib/console-polyfill.d.ts +9 -0
  7. package/lib/console-polyfill.lua +39 -0
  8. package/lib/datasources/DataSource.d.ts +17 -0
  9. package/lib/datasources/DataSource.lua +199 -0
  10. package/lib/datasources/NativeNumberSource.d.ts +7 -0
  11. package/lib/datasources/NativeNumberSource.lua +50 -0
  12. package/lib/datasources/ProgressSource.d.ts +23 -0
  13. package/lib/datasources/ProgressSource.lua +79 -0
  14. package/lib/datasources/Resources.d.ts +27 -0
  15. package/lib/datasources/Resources.lua +102 -0
  16. package/lib/datasources/index.d.ts +4 -0
  17. package/lib/datasources/index.lua +18 -0
  18. package/lib/index.d.ts +6 -0
  19. package/lib/index.lua +12 -0
  20. package/{src → lib}/platform/forever.d.ts +17 -17
  21. package/{src/types/Anchor.ts → lib/types/Anchor.d.ts} +6 -7
  22. package/lib/types/Anchor.lua +8 -0
  23. package/lib/types/Color.lua +3 -0
  24. package/lib/types/Position.d.ts +21 -0
  25. package/lib/types/Position.lua +3 -0
  26. package/lib/types/Spacing.d.ts +14 -0
  27. package/lib/types/Spacing.lua +20 -0
  28. package/{src/types/Texture.ts → lib/types/Texture.d.ts} +0 -2
  29. package/lib/types/Texture.lua +3 -0
  30. package/{src/ui/Cell.tsx → lib/ui/Cell.d.ts} +6 -8
  31. package/lib/ui/Cell.lua +9 -0
  32. package/{src/ui/FlowLayout.tsx → lib/ui/FlowLayout.d.ts} +3 -8
  33. package/lib/ui/FlowLayout.lua +8 -0
  34. package/{src/ui/GridLayout.tsx → lib/ui/GridLayout.d.ts} +3 -8
  35. package/lib/ui/GridLayout.lua +8 -0
  36. package/{src/ui/Layout.ts → lib/ui/Layout.d.ts} +4 -3
  37. package/lib/ui/Layout.lua +3 -0
  38. package/{src/ui/ProgressBar.tsx → lib/ui/ProgressBar.d.ts} +4 -7
  39. package/lib/ui/ProgressBar.lua +8 -0
  40. package/lib/ui/decorations/Background.d.ts +10 -0
  41. package/lib/ui/decorations/Background.lua +76 -0
  42. package/lib/ui/decorations/Border.d.ts +18 -0
  43. package/lib/ui/decorations/Border.lua +188 -0
  44. package/lib/ui/decorations/Decoration.d.ts +13 -0
  45. package/lib/ui/decorations/Decoration.lua +81 -0
  46. package/{src/ui/decorations/Decorations.ts → lib/ui/decorations/Decorations.d.ts} +0 -1
  47. package/lib/ui/decorations/Decorations.lua +3 -0
  48. package/lib/ui/decorations/Glow.d.ts +14 -0
  49. package/lib/ui/decorations/Glow.lua +63 -0
  50. package/lib/ui/decorations/backgroundTextures.d.ts +25 -0
  51. package/lib/ui/decorations/backgroundTextures.lua +10 -0
  52. package/lib/ui/decorations/borderTextures.d.ts +41 -0
  53. package/lib/ui/decorations/borderTextures.lua +12 -0
  54. package/lib/ui/decorations/statusBarTextures.d.ts +12 -0
  55. package/lib/ui/decorations/statusBarTextures.lua +9 -0
  56. package/lib/ui/index.d.ts +11 -0
  57. package/lib/ui/index.lua +35 -0
  58. package/lib/ui/layout/calculateFlow.d.ts +12 -0
  59. package/lib/ui/layout/calculateFlow.lua +36 -0
  60. package/lib/ui/layout/calculateGrid.d.ts +9 -0
  61. package/lib/ui/layout/calculateGrid.lua +47 -0
  62. package/lib/ui/layout/measureLayout.d.ts +19 -0
  63. package/lib/ui/layout/measureLayout.lua +215 -0
  64. package/lib/ui/mount.d.ts +5 -0
  65. package/lib/ui/mount.lua +486 -0
  66. package/lib/ui/primitives/jsx.d.ts +38 -0
  67. package/lib/ui/primitives/jsx.lua +66 -0
  68. package/lib/wuira.d.ts +8 -0
  69. package/lib/wuira.lua +36 -0
  70. package/package.json +55 -5
  71. package/templates/addon/README.md +13 -0
  72. package/templates/addon/addon.toc.in +4 -0
  73. package/templates/addon/gitignore +3 -0
  74. package/templates/addon/package.json +11 -0
  75. package/templates/addon/src/index.tsx +7 -0
  76. package/templates/addon/tsconfig.json +8 -0
  77. package/templates/addon/wuira.config.mjs +4 -0
  78. package/tools/build-library.mjs +15 -0
  79. package/tools/module-loader.lua +3 -3
  80. package/tools/{wow-modules.cjs → wow-modules.mjs} +27 -11
  81. package/tsconfig.json +1 -1
  82. package/tsconfig.lib.json +8 -0
  83. package/addon.toc.in +0 -4
  84. package/cli/uira.cjs +0 -55
  85. package/src/Console.ts +0 -10
  86. package/src/UIra.ts +0 -18
  87. package/src/console-polyfill.ts +0 -25
  88. package/src/datasources/DataSource.ts +0 -42
  89. package/src/datasources/NativeNumberSource.ts +0 -7
  90. package/src/datasources/ProgressSource.ts +0 -46
  91. package/src/datasources/Resources.ts +0 -41
  92. package/src/examples/ProgressBars.tsx +0 -24
  93. package/src/index.tsx +0 -3
  94. package/src/playground/PlayerFrame.ts +0 -271
  95. package/src/types/Position.ts +0 -21
  96. package/src/types/Spacing.ts +0 -14
  97. package/src/ui/decorations/Background.ts +0 -29
  98. package/src/ui/decorations/Border.ts +0 -71
  99. package/src/ui/decorations/Decoration.ts +0 -59
  100. package/src/ui/decorations/Glow.ts +0 -25
  101. package/src/ui/decorations/backgroundTextures.ts +0 -10
  102. package/src/ui/decorations/borderTextures.ts +0 -13
  103. package/src/ui/decorations/statusBarTextures.ts +0 -11
  104. package/src/ui/layout/calculateFlow.ts +0 -33
  105. package/src/ui/layout/calculateGrid.ts +0 -22
  106. package/src/ui/layout/measureLayout.ts +0 -87
  107. package/src/ui/mount.ts +0 -138
  108. package/src/ui/primitives/jsx.ts +0 -75
  109. /package/{src/types/Color.ts → lib/types/Color.d.ts} +0 -0
@@ -0,0 +1,486 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ -- Lua Library inline imports
3
+ local function __TS__Class(self)
4
+ local c = {prototype = {}}
5
+ c.prototype.__index = c.prototype
6
+ c.prototype.constructor = c
7
+ return c
8
+ end
9
+
10
+ local __TS__Symbol, Symbol
11
+ do
12
+ local symbolMetatable = {__tostring = function(self)
13
+ return ("Symbol(" .. (self.description or "")) .. ")"
14
+ end}
15
+ function __TS__Symbol(description)
16
+ return setmetatable({description = description}, symbolMetatable)
17
+ end
18
+ Symbol = {
19
+ asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
20
+ dispose = __TS__Symbol("Symbol.dispose"),
21
+ iterator = __TS__Symbol("Symbol.iterator"),
22
+ hasInstance = __TS__Symbol("Symbol.hasInstance"),
23
+ species = __TS__Symbol("Symbol.species"),
24
+ toStringTag = __TS__Symbol("Symbol.toStringTag")
25
+ }
26
+ end
27
+
28
+ local __TS__Iterator
29
+ do
30
+ local function iteratorGeneratorStep(self)
31
+ local co = self.____coroutine
32
+ local status, value = coroutine.resume(co)
33
+ if not status then
34
+ error(value, 0)
35
+ end
36
+ if coroutine.status(co) == "dead" then
37
+ return
38
+ end
39
+ return true, value
40
+ end
41
+ local function iteratorIteratorStep(self)
42
+ local result = self:next()
43
+ if result.done then
44
+ return
45
+ end
46
+ return true, result.value
47
+ end
48
+ local function iteratorStringStep(self, index)
49
+ index = index + 1
50
+ if index > #self then
51
+ return
52
+ end
53
+ return index, string.sub(self, index, index)
54
+ end
55
+ function __TS__Iterator(iterable)
56
+ if type(iterable) == "string" then
57
+ return iteratorStringStep, iterable, 0
58
+ elseif iterable.____coroutine ~= nil then
59
+ return iteratorGeneratorStep, iterable
60
+ elseif iterable[Symbol.iterator] then
61
+ local iterator = iterable[Symbol.iterator](iterable)
62
+ return iteratorIteratorStep, iterator
63
+ else
64
+ return ipairs(iterable)
65
+ end
66
+ end
67
+ end
68
+
69
+ local Map
70
+ do
71
+ Map = __TS__Class()
72
+ Map.name = "Map"
73
+ function Map.prototype.____constructor(self, entries)
74
+ self[Symbol.toStringTag] = "Map"
75
+ self.items = {}
76
+ self.size = 0
77
+ self.nextKey = {}
78
+ self.previousKey = {}
79
+ if entries == nil then
80
+ return
81
+ end
82
+ local iterable = entries
83
+ if iterable[Symbol.iterator] then
84
+ local iterator = iterable[Symbol.iterator](iterable)
85
+ while true do
86
+ local result = iterator:next()
87
+ if result.done then
88
+ break
89
+ end
90
+ local value = result.value
91
+ self:set(value[1], value[2])
92
+ end
93
+ else
94
+ local array = entries
95
+ for ____, kvp in ipairs(array) do
96
+ self:set(kvp[1], kvp[2])
97
+ end
98
+ end
99
+ end
100
+ function Map.prototype.clear(self)
101
+ self.items = {}
102
+ self.nextKey = {}
103
+ self.previousKey = {}
104
+ self.firstKey = nil
105
+ self.lastKey = nil
106
+ self.size = 0
107
+ end
108
+ function Map.prototype.delete(self, key)
109
+ local contains = self:has(key)
110
+ if contains then
111
+ self.size = self.size - 1
112
+ local next = self.nextKey[key]
113
+ local previous = self.previousKey[key]
114
+ if next ~= nil and previous ~= nil then
115
+ self.nextKey[previous] = next
116
+ self.previousKey[next] = previous
117
+ elseif next ~= nil then
118
+ self.firstKey = next
119
+ self.previousKey[next] = nil
120
+ elseif previous ~= nil then
121
+ self.lastKey = previous
122
+ self.nextKey[previous] = nil
123
+ else
124
+ self.firstKey = nil
125
+ self.lastKey = nil
126
+ end
127
+ self.nextKey[key] = nil
128
+ self.previousKey[key] = nil
129
+ end
130
+ self.items[key] = nil
131
+ return contains
132
+ end
133
+ function Map.prototype.forEach(self, callback)
134
+ for ____, key in __TS__Iterator(self:keys()) do
135
+ callback(nil, self.items[key], key, self)
136
+ end
137
+ end
138
+ function Map.prototype.get(self, key)
139
+ return self.items[key]
140
+ end
141
+ function Map.prototype.has(self, key)
142
+ return self.nextKey[key] ~= nil or self.lastKey == key
143
+ end
144
+ function Map.prototype.set(self, key, value)
145
+ local isNewValue = not self:has(key)
146
+ if isNewValue then
147
+ self.size = self.size + 1
148
+ end
149
+ self.items[key] = value
150
+ if self.firstKey == nil then
151
+ self.firstKey = key
152
+ self.lastKey = key
153
+ elseif isNewValue then
154
+ self.nextKey[self.lastKey] = key
155
+ self.previousKey[key] = self.lastKey
156
+ self.lastKey = key
157
+ end
158
+ return self
159
+ end
160
+ Map.prototype[Symbol.iterator] = function(self)
161
+ return self:entries()
162
+ end
163
+ function Map.prototype.entries(self)
164
+ local function getFirstKey()
165
+ return self.firstKey
166
+ end
167
+ local items = self.items
168
+ local nextKey = self.nextKey
169
+ local key
170
+ local started = false
171
+ return {
172
+ [Symbol.iterator] = function(self)
173
+ return self
174
+ end,
175
+ next = function(self)
176
+ if not started then
177
+ started = true
178
+ key = getFirstKey(nil)
179
+ else
180
+ key = nextKey[key]
181
+ end
182
+ return {done = not key, value = {key, items[key]}}
183
+ end
184
+ }
185
+ end
186
+ function Map.prototype.keys(self)
187
+ local function getFirstKey()
188
+ return self.firstKey
189
+ end
190
+ local nextKey = self.nextKey
191
+ local key
192
+ local started = false
193
+ return {
194
+ [Symbol.iterator] = function(self)
195
+ return self
196
+ end,
197
+ next = function(self)
198
+ if not started then
199
+ started = true
200
+ key = getFirstKey(nil)
201
+ else
202
+ key = nextKey[key]
203
+ end
204
+ return {done = not key, value = key}
205
+ end
206
+ }
207
+ end
208
+ function Map.prototype.values(self)
209
+ local function getFirstKey()
210
+ return self.firstKey
211
+ end
212
+ local items = self.items
213
+ local nextKey = self.nextKey
214
+ local key
215
+ local started = false
216
+ return {
217
+ [Symbol.iterator] = function(self)
218
+ return self
219
+ end,
220
+ next = function(self)
221
+ if not started then
222
+ started = true
223
+ key = getFirstKey(nil)
224
+ else
225
+ key = nextKey[key]
226
+ end
227
+ return {done = not key, value = items[key]}
228
+ end
229
+ }
230
+ end
231
+ Map[Symbol.species] = Map
232
+ end
233
+
234
+ local function __TS__New(target, ...)
235
+ local instance = setmetatable({}, target.prototype)
236
+ instance:____constructor(...)
237
+ return instance
238
+ end
239
+
240
+ local function __TS__ArrayMap(self, callbackfn, thisArg)
241
+ local result = {}
242
+ for i = 1, #self do
243
+ result[i] = callbackfn(thisArg, self[i], i - 1, self)
244
+ end
245
+ return result
246
+ end
247
+ -- End of Lua Library inline imports
248
+ local ____exports = {}
249
+ local ____measureLayout = require("ui.layout.measureLayout")
250
+ local measureLayout = ____measureLayout.measureLayout
251
+ local ____Background = require("ui.decorations.Background")
252
+ local Background = ____Background.Background
253
+ local ____Border = require("ui.decorations.Border")
254
+ local Border = ____Border.Border
255
+ local ____statusBarTextures = require("ui.decorations.statusBarTextures")
256
+ local resolveStatusBarTexture = ____statusBarTextures.resolveStatusBarTexture
257
+ local mountedFrames = __TS__New(Map)
258
+ local mountedTrees = __TS__New(Map)
259
+ function ____exports.unmount(self, frame)
260
+ local tree = mountedTrees:get(frame)
261
+ if tree == nil then
262
+ return
263
+ end
264
+ for ____, decoration in ipairs(tree.decorations) do
265
+ decoration:dispose()
266
+ end
267
+ for ____, child in ipairs(tree.frames) do
268
+ child:UnregisterAllEvents()
269
+ child:SetScript("OnEvent", nil)
270
+ child:Hide()
271
+ end
272
+ for ____, cell in ipairs(tree.cells) do
273
+ mountedFrames:delete(cell.props)
274
+ end
275
+ mountedTrees:delete(frame)
276
+ end
277
+ --- Creates the tree before resolving anchors. Positive y moves down.
278
+ function ____exports.mount(self, element, parent, rootAnchor)
279
+ if parent == nil then
280
+ parent = UIParent
281
+ end
282
+ local frames = __TS__New(Map)
283
+ local pending = {}
284
+ local function create(self, measured, parent, placement)
285
+ local ____measured_0 = measured
286
+ local cell = ____measured_0.cell
287
+ local width = ____measured_0.width
288
+ local height = ____measured_0.height
289
+ if frames:has(cell.props) or mountedFrames:has(cell.props) then
290
+ error("A Cell can only be mounted once at a time")
291
+ end
292
+ local frame = cell.kind == "progress" and CreateFrame("StatusBar", nil, parent) or CreateFrame("Frame", nil, parent)
293
+ frame:Hide()
294
+ local ____frame_EnableMouse_2 = frame.EnableMouse
295
+ local ____cell_props_clickThrough_1 = cell.props.clickThrough
296
+ if ____cell_props_clickThrough_1 == nil then
297
+ ____cell_props_clickThrough_1 = true
298
+ end
299
+ ____frame_EnableMouse_2(frame, not ____cell_props_clickThrough_1)
300
+ frames:set(cell.props, frame)
301
+ pending[#pending + 1] = {
302
+ cell = cell,
303
+ width = width,
304
+ height = height,
305
+ margin = measured.margin,
306
+ frame = frame,
307
+ parent = parent,
308
+ placement = placement
309
+ }
310
+ frame:SetSize(width, height)
311
+ do
312
+ local index = 0
313
+ while index < #measured.children do
314
+ local ____create_6 = create
315
+ local ____measured_children_index_5 = measured.children[index + 1]
316
+ local ____opt_3 = measured.placements
317
+ ____create_6(nil, ____measured_children_index_5, frame, ____opt_3 and ____opt_3[index + 1])
318
+ index = index + 1
319
+ end
320
+ end
321
+ return frame
322
+ end
323
+ local rootProps = element.props
324
+ local root = create(
325
+ nil,
326
+ measureLayout(
327
+ nil,
328
+ element,
329
+ {
330
+ width = rootProps.width == "inherit" and parent:GetWidth() or nil,
331
+ height = rootProps.height == "inherit" and parent:GetHeight() or nil
332
+ }
333
+ ),
334
+ parent
335
+ )
336
+ local anchors = __TS__New(Map)
337
+ for ____, item in ipairs(pending) do
338
+ local position = item.cell.props
339
+ if item.placement ~= nil then
340
+ anchors:set(item.frame, item.parent)
341
+ elseif position.mode == "absolute" then
342
+ anchors:set(item.frame, UIParent)
343
+ else
344
+ local target = position.relativeTo == nil and item.parent or frames:get(position.relativeTo.props)
345
+ if target == nil then
346
+ error("relativeTo must reference a Cell in the same mounted tree")
347
+ end
348
+ if target == item.frame then
349
+ error("A Cell cannot anchor to itself")
350
+ end
351
+ anchors:set(item.frame, target)
352
+ end
353
+ end
354
+ for ____, item in ipairs(pending) do
355
+ local target = anchors:get(item.frame)
356
+ while target ~= nil do
357
+ if target == item.frame then
358
+ error("Cell positioning contains an anchor cycle")
359
+ end
360
+ target = anchors:get(target)
361
+ end
362
+ end
363
+ local tree = {
364
+ frames = __TS__ArrayMap(
365
+ pending,
366
+ function(____, item) return item.frame end
367
+ ),
368
+ cells = __TS__ArrayMap(
369
+ pending,
370
+ function(____, item) return item.cell end
371
+ ),
372
+ decorations = {}
373
+ }
374
+ mountedTrees:set(root, tree)
375
+ do
376
+ local function ____catch(failure)
377
+ ____exports.unmount(nil, root)
378
+ error(failure, 0)
379
+ end
380
+ local ____try, ____hasReturned = pcall(function()
381
+ for ____, item in ipairs(pending) do
382
+ local position = item.cell.props
383
+ 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
389
+ if item.frame == root then
390
+ ____temp_11 = rootAnchor
391
+ else
392
+ ____temp_11 = nil
393
+ end
394
+ local overrideAnchor = ____temp_11
395
+ local anchor = overrideAnchor or (item.placement ~= nil and "TOPLEFT" or (position.anchor or "TOPLEFT"))
396
+ local relativeAnchor = overrideAnchor or (item.placement ~= nil and "TOPLEFT" or (position.relativeAnchor or anchor))
397
+ item.frame:SetPoint(
398
+ anchor,
399
+ target,
400
+ relativeAnchor,
401
+ x + item.margin.left,
402
+ -(y + item.margin.top)
403
+ )
404
+ if item.cell.kind == "progress" then
405
+ local props = item.cell.props
406
+ 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(
413
+ bar,
414
+ ____resolveStatusBarTexture_16(nil, ____opt_14 and ____opt_14.texture or props.texture or "solid")
415
+ )
416
+ 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
+ if props.foreground ~= nil then
418
+ 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
423
+ 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
429
+ end
430
+ ____fill_SetVertTile_29(fill, ____props_foreground_tileY_28)
431
+ fill:SetBlendMode(props.foreground.blendMode or "BLEND")
432
+ local uv = props.foreground.texCoords or ({0, 1, 0, 1})
433
+ fill:SetTexCoord(uv[1], uv[2], uv[3], uv[4])
434
+ end
435
+ 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
440
+ end
441
+ ____bar_SetReverseFill_31(bar, ____props_reverse_30)
442
+ bar:SetMinMaxValues(props.min or 0, props.max or 100)
443
+ local source = item.cell.source or props.source
444
+ if source ~= nil then
445
+ source:BindTo(bar, {min = props.min, max = props.max, current = props.current or props.value})
446
+ else
447
+ bar:SetValue(props.current or props.value or 0)
448
+ end
449
+ end
450
+ local decorations = item.cell.props.decorations
451
+ local function attach(self, decoration)
452
+ if decoration ~= nil then
453
+ decoration:mount(item.frame, item.width, item.height)
454
+ local ____tree_decorations_32 = tree.decorations
455
+ ____tree_decorations_32[#____tree_decorations_32 + 1] = decoration
456
+ end
457
+ end
458
+ local progress = item.cell.kind == "progress" and item.cell.props or nil
459
+ local ____attach_40 = attach
460
+ local ____temp_39
461
+ if (progress and progress.background) == false then
462
+ ____temp_39 = nil
463
+ else
464
+ ____temp_39 = (progress and progress.background) ~= nil and __TS__New(Background, progress.background) or decorations and decorations.background
465
+ end
466
+ ____attach_40(nil, ____temp_39)
467
+ local ____attach_48 = attach
468
+ local ____temp_47
469
+ if (progress and progress.backdrop) == false then
470
+ ____temp_47 = nil
471
+ else
472
+ ____temp_47 = (progress and progress.backdrop) ~= nil and __TS__New(Border, progress.backdrop) or decorations and decorations.border
473
+ end
474
+ ____attach_48(nil, ____temp_47)
475
+ attach(nil, decorations and decorations.glow)
476
+ mountedFrames:set(item.cell.props, item.frame)
477
+ item.frame:Show()
478
+ end
479
+ end)
480
+ if not ____try then
481
+ ____catch(____hasReturned)
482
+ end
483
+ end
484
+ return root
485
+ end
486
+ return ____exports
@@ -0,0 +1,38 @@
1
+ import type { CellProps } from "../Cell";
2
+ import type { FlowLayoutProps } from "../FlowLayout";
3
+ import type { GridLayoutProps } from "../GridLayout";
4
+ import type { ProgressBarProps } from "../ProgressBar";
5
+ import type { ProgressSource } from "../../datasources/ProgressSource";
6
+ /** Declarative UI description; native frames are created by mount. */
7
+ export interface Element {
8
+ kind: string;
9
+ props: object;
10
+ child?: Element;
11
+ children?: Element[];
12
+ source?: ProgressSource;
13
+ }
14
+ export type Component<P extends object> = (props: P, child?: Element) => Element;
15
+ export declare namespace UI {
16
+ function Fragment(): Element;
17
+ function createElement<P extends object>(component: Component<P> | "cell" | "flow" | "grid" | "progress", props: P | undefined, ...children: (Element | Element[])[]): Element;
18
+ namespace JSX {
19
+ type Element = import("./jsx").Element;
20
+ interface ElementChildrenAttribute {
21
+ child: {};
22
+ }
23
+ interface IntrinsicElements {
24
+ cell: Partial<CellProps> & {
25
+ child?: Element;
26
+ };
27
+ flow: Partial<FlowLayoutProps> & {
28
+ child?: Element | Element[];
29
+ };
30
+ grid: Partial<GridLayoutProps> & {
31
+ child?: Element | Element[];
32
+ };
33
+ progress: Partial<ProgressBarProps> & {
34
+ child?: Element;
35
+ };
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,66 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ -- Lua Library inline imports
3
+ local function __TS__ArrayIsArray(value)
4
+ return type(value) == "table" and (value[1] ~= nil or next(value) == nil)
5
+ end
6
+
7
+ local function __TS__ObjectAssign(target, ...)
8
+ local sources = {...}
9
+ for i = 1, #sources do
10
+ local source = sources[i]
11
+ if type(source) == "table" then
12
+ for key in pairs(source) do
13
+ target[key] = source[key]
14
+ end
15
+ end
16
+ end
17
+ return target
18
+ end
19
+ -- End of Lua Library inline imports
20
+ local ____exports = {}
21
+ ____exports.UI = {}
22
+ local UI = ____exports.UI
23
+ do
24
+ function UI.Fragment(self)
25
+ return {kind = "empty", props = {}}
26
+ end
27
+ function UI.createElement(self, component, props, ...)
28
+ local children = {...}
29
+ local elements = {}
30
+ for ____, child in ipairs(children) do
31
+ if __TS__ArrayIsArray(child) then
32
+ for ____, element in ipairs(child) do
33
+ elements[#elements + 1] = element
34
+ end
35
+ else
36
+ elements[#elements + 1] = child
37
+ end
38
+ end
39
+ local properties = props or ({})
40
+ if type(component) == "string" then
41
+ local input = properties
42
+ local resolved = __TS__ObjectAssign(
43
+ {},
44
+ properties,
45
+ {width = input.width or (input.sizing == "content" and 0 or "inherit"), height = input.height or (input.sizing == "content" and 0 or "inherit"), mode = input.mode or "relative"},
46
+ input.mode == "absolute" and ({x = input.x or 0, y = input.y or 0}) or ({offset = input.offset or ({x = 0, y = 0})}),
47
+ component == "flow" and ({direction = input.direction or "vertical"}) or ({}),
48
+ component == "grid" and ({columns = input.columns or 1}) or ({})
49
+ )
50
+ if component == "flow" or component == "grid" then
51
+ return {kind = component, props = resolved, children = elements}
52
+ end
53
+ if #elements > 1 then
54
+ error("Cell accepts at most one child; use FlowLayout for multiple children", 0)
55
+ end
56
+ return {kind = component, props = resolved, child = elements[1], source = properties.source}
57
+ end
58
+ local componentProps = #children == 0 and properties or __TS__ObjectAssign({}, properties, {child = #elements == 1 and elements[1] or elements})
59
+ if component == UI.Fragment and #elements ~= 0 then
60
+ error("Only empty fragments are supported for now", 0)
61
+ end
62
+ return component(nil, componentProps, elements[1])
63
+ end
64
+ UI.JSX = {}
65
+ end
66
+ return ____exports
package/lib/wuira.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { Cell } from "./ui/Cell";
2
+ import type { Anchor } from "./types/Position";
3
+ /** Public entry point for mounting JSX UI trees. */
4
+ export declare class wuira {
5
+ private constructor();
6
+ static Mount(frame: Cell | void | (() => Cell | void), anchor?: Anchor, parent?: wuiraNativeFrame): wuiraNativeFrame | undefined;
7
+ static Unmount(frame: wuiraNativeFrame): void;
8
+ }
package/lib/wuira.lua ADDED
@@ -0,0 +1,36 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ -- Lua Library inline imports
3
+ local function __TS__Class(self)
4
+ local c = {prototype = {}}
5
+ c.prototype.__index = c.prototype
6
+ c.prototype.constructor = c
7
+ return c
8
+ end
9
+ -- End of Lua Library inline imports
10
+ local ____exports = {}
11
+ local ____mount = require("ui.mount")
12
+ local mount = ____mount.mount
13
+ local unmount = ____mount.unmount
14
+ --- Public entry point for mounting JSX UI trees.
15
+ ____exports.wuira = __TS__Class()
16
+ local wuira = ____exports.wuira
17
+ wuira.name = "wuira"
18
+ function wuira.prototype.____constructor(self)
19
+ end
20
+ function wuira.Mount(self, frame, anchor, parent)
21
+ local ____temp_0
22
+ if type(frame) == "function" then
23
+ ____temp_0 = frame(nil)
24
+ else
25
+ ____temp_0 = frame
26
+ end
27
+ local view = ____temp_0
28
+ if view == nil or view.kind == "empty" then
29
+ return nil
30
+ end
31
+ return mount(nil, view, parent, anchor)
32
+ end
33
+ function wuira.Unmount(self, frame)
34
+ unmount(nil, frame)
35
+ end
36
+ return ____exports