wuira 0.2.3 → 0.2.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 (38) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +62 -792
  3. package/data/icons/forever.json +90051 -0
  4. package/docs/icons.md +28 -0
  5. package/docs/source-converters.md +34 -0
  6. package/lib/datasources/DataSource.d.ts +8 -0
  7. package/lib/datasources/DataSource.lua +7 -0
  8. package/lib/datasources/GroupMembers.d.ts +6 -0
  9. package/lib/datasources/GroupMembers.lua +332 -0
  10. package/lib/datasources/GroupRoster.d.ts +28 -0
  11. package/lib/datasources/GroupRoster.lua +611 -0
  12. package/lib/datasources/MathConverter.d.ts +6 -0
  13. package/lib/datasources/MathConverter.lua +61 -0
  14. package/lib/datasources/MathExpression.d.ts +16 -0
  15. package/lib/datasources/MathExpression.lua +281 -0
  16. package/lib/datasources/Resources.d.ts +3 -2
  17. package/lib/datasources/Resources.lua +57 -48
  18. package/lib/datasources/SourceConverter.d.ts +39 -0
  19. package/lib/datasources/SourceConverter.lua +568 -0
  20. package/lib/datasources/UnitInfo.d.ts +6 -0
  21. package/lib/datasources/UnitInfo.lua +347 -15
  22. package/lib/datasources/UnitSource.d.ts +8 -3
  23. package/lib/datasources/UnitSource.lua +318 -5
  24. package/lib/datasources/index.d.ts +7 -1
  25. package/lib/datasources/index.lua +15 -0
  26. package/lib/icons/index.d.ts +45634 -0
  27. package/lib/icons/index.lua +3 -0
  28. package/lib/index.d.ts +1 -0
  29. package/lib/store/index.lua +20 -18
  30. package/lib/ui/Cell.d.ts +2 -0
  31. package/lib/ui/ForEach.d.ts +18 -4
  32. package/lib/ui/ForEach.lua +763 -13
  33. package/lib/ui/index.d.ts +1 -1
  34. package/package.json +20 -4
  35. package/tools/build-library.mjs +1 -1
  36. package/tools/generate-icons.mjs +10 -0
  37. package/tools/icon-data.mjs +59 -0
  38. package/tools/update-icons.mjs +36 -0
@@ -0,0 +1,611 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ -- Lua Library inline imports
3
+ local __TS__StringReplace
4
+ do
5
+ local sub = string.sub
6
+ function __TS__StringReplace(source, searchValue, replaceValue)
7
+ local startPos, endPos = string.find(source, searchValue, nil, true)
8
+ if not startPos then
9
+ return source
10
+ end
11
+ local before = sub(source, 1, startPos - 1)
12
+ local replacement = type(replaceValue) == "string" and replaceValue or replaceValue(nil, searchValue, startPos - 1, source)
13
+ local after = sub(source, endPos + 1)
14
+ return (before .. replacement) .. after
15
+ end
16
+ end
17
+
18
+ local function __TS__Class(self)
19
+ local c = {prototype = {}}
20
+ c.prototype.__index = c.prototype
21
+ c.prototype.constructor = c
22
+ return c
23
+ end
24
+
25
+ local function __TS__ClassExtends(target, base)
26
+ target.____super = base
27
+ local staticMetatable = setmetatable({__index = base}, base)
28
+ setmetatable(target, staticMetatable)
29
+ local baseMetatable = getmetatable(base)
30
+ if baseMetatable then
31
+ if type(baseMetatable.__index) == "function" then
32
+ staticMetatable.__index = baseMetatable.__index
33
+ end
34
+ if type(baseMetatable.__newindex) == "function" then
35
+ staticMetatable.__newindex = baseMetatable.__newindex
36
+ end
37
+ end
38
+ setmetatable(target.prototype, base.prototype)
39
+ if type(base.prototype.__index) == "function" then
40
+ target.prototype.__index = base.prototype.__index
41
+ end
42
+ if type(base.prototype.__newindex) == "function" then
43
+ target.prototype.__newindex = base.prototype.__newindex
44
+ end
45
+ if type(base.prototype.__tostring) == "function" then
46
+ target.prototype.__tostring = base.prototype.__tostring
47
+ end
48
+ end
49
+
50
+ local function __TS__New(target, ...)
51
+ local instance = setmetatable({}, target.prototype)
52
+ instance:____constructor(...)
53
+ return instance
54
+ end
55
+
56
+ local __TS__Symbol, Symbol
57
+ do
58
+ local symbolMetatable = {__tostring = function(self)
59
+ return ("Symbol(" .. (self.description or "")) .. ")"
60
+ end}
61
+ function __TS__Symbol(description)
62
+ return setmetatable({description = description}, symbolMetatable)
63
+ end
64
+ Symbol = {
65
+ asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
66
+ dispose = __TS__Symbol("Symbol.dispose"),
67
+ iterator = __TS__Symbol("Symbol.iterator"),
68
+ hasInstance = __TS__Symbol("Symbol.hasInstance"),
69
+ species = __TS__Symbol("Symbol.species"),
70
+ toStringTag = __TS__Symbol("Symbol.toStringTag")
71
+ }
72
+ end
73
+
74
+ local __TS__Iterator
75
+ do
76
+ local function iteratorGeneratorStep(self)
77
+ local co = self.____coroutine
78
+ local status, value = coroutine.resume(co)
79
+ if not status then
80
+ error(value, 0)
81
+ end
82
+ if coroutine.status(co) == "dead" then
83
+ return
84
+ end
85
+ return true, value
86
+ end
87
+ local function iteratorIteratorStep(self)
88
+ local result = self:next()
89
+ if result.done then
90
+ return
91
+ end
92
+ return true, result.value
93
+ end
94
+ local function iteratorStringStep(self, index)
95
+ index = index + 1
96
+ if index > #self then
97
+ return
98
+ end
99
+ return index, string.sub(self, index, index)
100
+ end
101
+ function __TS__Iterator(iterable)
102
+ if type(iterable) == "string" then
103
+ return iteratorStringStep, iterable, 0
104
+ elseif iterable.____coroutine ~= nil then
105
+ return iteratorGeneratorStep, iterable
106
+ elseif iterable[Symbol.iterator] then
107
+ local iterator = iterable[Symbol.iterator](iterable)
108
+ return iteratorIteratorStep, iterator
109
+ else
110
+ return ipairs(iterable)
111
+ end
112
+ end
113
+ end
114
+
115
+ local Map
116
+ do
117
+ Map = __TS__Class()
118
+ Map.name = "Map"
119
+ function Map.prototype.____constructor(self, entries)
120
+ self[Symbol.toStringTag] = "Map"
121
+ self.items = {}
122
+ self.size = 0
123
+ self.nextKey = {}
124
+ self.previousKey = {}
125
+ if entries == nil then
126
+ return
127
+ end
128
+ local iterable = entries
129
+ if iterable[Symbol.iterator] then
130
+ local iterator = iterable[Symbol.iterator](iterable)
131
+ while true do
132
+ local result = iterator:next()
133
+ if result.done then
134
+ break
135
+ end
136
+ local value = result.value
137
+ self:set(value[1], value[2])
138
+ end
139
+ else
140
+ local array = entries
141
+ for ____, kvp in ipairs(array) do
142
+ self:set(kvp[1], kvp[2])
143
+ end
144
+ end
145
+ end
146
+ function Map.prototype.clear(self)
147
+ self.items = {}
148
+ self.nextKey = {}
149
+ self.previousKey = {}
150
+ self.firstKey = nil
151
+ self.lastKey = nil
152
+ self.size = 0
153
+ end
154
+ function Map.prototype.delete(self, key)
155
+ local contains = self:has(key)
156
+ if contains then
157
+ self.size = self.size - 1
158
+ local next = self.nextKey[key]
159
+ local previous = self.previousKey[key]
160
+ if next ~= nil and previous ~= nil then
161
+ self.nextKey[previous] = next
162
+ self.previousKey[next] = previous
163
+ elseif next ~= nil then
164
+ self.firstKey = next
165
+ self.previousKey[next] = nil
166
+ elseif previous ~= nil then
167
+ self.lastKey = previous
168
+ self.nextKey[previous] = nil
169
+ else
170
+ self.firstKey = nil
171
+ self.lastKey = nil
172
+ end
173
+ self.nextKey[key] = nil
174
+ self.previousKey[key] = nil
175
+ end
176
+ self.items[key] = nil
177
+ return contains
178
+ end
179
+ function Map.prototype.forEach(self, callback)
180
+ for ____, key in __TS__Iterator(self:keys()) do
181
+ callback(nil, self.items[key], key, self)
182
+ end
183
+ end
184
+ function Map.prototype.get(self, key)
185
+ return self.items[key]
186
+ end
187
+ function Map.prototype.has(self, key)
188
+ return self.nextKey[key] ~= nil or self.lastKey == key
189
+ end
190
+ function Map.prototype.set(self, key, value)
191
+ local isNewValue = not self:has(key)
192
+ if isNewValue then
193
+ self.size = self.size + 1
194
+ end
195
+ self.items[key] = value
196
+ if self.firstKey == nil then
197
+ self.firstKey = key
198
+ self.lastKey = key
199
+ elseif isNewValue then
200
+ self.nextKey[self.lastKey] = key
201
+ self.previousKey[key] = self.lastKey
202
+ self.lastKey = key
203
+ end
204
+ return self
205
+ end
206
+ Map.prototype[Symbol.iterator] = function(self)
207
+ return self:entries()
208
+ end
209
+ function Map.prototype.entries(self)
210
+ local function getFirstKey()
211
+ return self.firstKey
212
+ end
213
+ local items = self.items
214
+ local nextKey = self.nextKey
215
+ local key
216
+ local started = false
217
+ return {
218
+ [Symbol.iterator] = function(self)
219
+ return self
220
+ end,
221
+ next = function(self)
222
+ if not started then
223
+ started = true
224
+ key = getFirstKey(nil)
225
+ else
226
+ key = nextKey[key]
227
+ end
228
+ return {done = not key, value = {key, items[key]}}
229
+ end
230
+ }
231
+ end
232
+ function Map.prototype.keys(self)
233
+ local function getFirstKey()
234
+ return self.firstKey
235
+ end
236
+ local nextKey = self.nextKey
237
+ local key
238
+ local started = false
239
+ return {
240
+ [Symbol.iterator] = function(self)
241
+ return self
242
+ end,
243
+ next = function(self)
244
+ if not started then
245
+ started = true
246
+ key = getFirstKey(nil)
247
+ else
248
+ key = nextKey[key]
249
+ end
250
+ return {done = not key, value = key}
251
+ end
252
+ }
253
+ end
254
+ function Map.prototype.values(self)
255
+ local function getFirstKey()
256
+ return self.firstKey
257
+ end
258
+ local items = self.items
259
+ local nextKey = self.nextKey
260
+ local key
261
+ local started = false
262
+ return {
263
+ [Symbol.iterator] = function(self)
264
+ return self
265
+ end,
266
+ next = function(self)
267
+ if not started then
268
+ started = true
269
+ key = getFirstKey(nil)
270
+ else
271
+ key = nextKey[key]
272
+ end
273
+ return {done = not key, value = items[key]}
274
+ end
275
+ }
276
+ end
277
+ Map[Symbol.species] = Map
278
+ end
279
+
280
+ local __TS__Unpack = table.unpack or unpack
281
+
282
+ local function __TS__ArrayMap(self, callbackfn, thisArg)
283
+ local result = {}
284
+ for i = 1, #self do
285
+ result[i] = callbackfn(thisArg, self[i], i - 1, self)
286
+ end
287
+ return result
288
+ end
289
+
290
+ local function __TS__Number(value)
291
+ local valueType = type(value)
292
+ if valueType == "number" then
293
+ return value
294
+ elseif valueType == "string" then
295
+ local numberValue = tonumber(value)
296
+ if numberValue then
297
+ return numberValue
298
+ end
299
+ if value == "Infinity" then
300
+ return math.huge
301
+ end
302
+ if value == "-Infinity" then
303
+ return -math.huge
304
+ end
305
+ local stringWithoutSpaces = string.gsub(value, "%s", "")
306
+ if stringWithoutSpaces == "" then
307
+ return 0
308
+ end
309
+ return 0 / 0
310
+ elseif valueType == "boolean" then
311
+ return value and 1 or 0
312
+ else
313
+ return 0 / 0
314
+ end
315
+ end
316
+
317
+ local function __TS__ArraySort(self, compareFn)
318
+ if compareFn ~= nil then
319
+ table.sort(
320
+ self,
321
+ function(a, b) return compareFn(nil, a, b) < 0 end
322
+ )
323
+ else
324
+ table.sort(self)
325
+ end
326
+ return self
327
+ end
328
+
329
+ local function __TS__StringStartsWith(self, searchString, position)
330
+ if position == nil or position < 0 then
331
+ position = 0
332
+ end
333
+ return string.sub(self, position + 1, #searchString + position) == searchString
334
+ end
335
+
336
+ local function __TS__CloneDescriptor(____bindingPattern0)
337
+ local value
338
+ local writable
339
+ local set
340
+ local get
341
+ local configurable
342
+ local enumerable
343
+ enumerable = ____bindingPattern0.enumerable
344
+ configurable = ____bindingPattern0.configurable
345
+ get = ____bindingPattern0.get
346
+ set = ____bindingPattern0.set
347
+ writable = ____bindingPattern0.writable
348
+ value = ____bindingPattern0.value
349
+ local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
350
+ local hasGetterOrSetter = get ~= nil or set ~= nil
351
+ local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
352
+ if hasGetterOrSetter and hasValueOrWritableAttribute then
353
+ error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
354
+ end
355
+ if get or set then
356
+ descriptor.get = get
357
+ descriptor.set = set
358
+ else
359
+ descriptor.value = value
360
+ descriptor.writable = writable == true
361
+ end
362
+ return descriptor
363
+ end
364
+
365
+ local __TS__DescriptorGet
366
+ do
367
+ local getmetatable = _G.getmetatable
368
+ local ____rawget = _G.rawget
369
+ function __TS__DescriptorGet(self, metatable, key)
370
+ while metatable do
371
+ local rawResult = ____rawget(metatable, key)
372
+ if rawResult ~= nil then
373
+ return rawResult
374
+ end
375
+ local descriptors = ____rawget(metatable, "_descriptors")
376
+ if descriptors then
377
+ local descriptor = descriptors[key]
378
+ if descriptor ~= nil then
379
+ if descriptor.get then
380
+ return descriptor.get(self)
381
+ end
382
+ return descriptor.value
383
+ end
384
+ end
385
+ metatable = getmetatable(metatable)
386
+ end
387
+ end
388
+ end
389
+
390
+ local __TS__DescriptorSet
391
+ do
392
+ local getmetatable = _G.getmetatable
393
+ local ____rawget = _G.rawget
394
+ local rawset = _G.rawset
395
+ function __TS__DescriptorSet(self, metatable, key, value)
396
+ while metatable do
397
+ local descriptors = ____rawget(metatable, "_descriptors")
398
+ if descriptors then
399
+ local descriptor = descriptors[key]
400
+ if descriptor ~= nil then
401
+ if descriptor.set then
402
+ descriptor.set(self, value)
403
+ else
404
+ if descriptor.writable == false then
405
+ error(
406
+ ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
407
+ 0
408
+ )
409
+ end
410
+ descriptor.value = value
411
+ end
412
+ return
413
+ end
414
+ end
415
+ metatable = getmetatable(metatable)
416
+ end
417
+ rawset(self, key, value)
418
+ end
419
+ end
420
+
421
+ local __TS__SetDescriptor
422
+ do
423
+ local getmetatable = _G.getmetatable
424
+ local function descriptorIndex(self, key)
425
+ return __TS__DescriptorGet(
426
+ self,
427
+ getmetatable(self),
428
+ key
429
+ )
430
+ end
431
+ local function descriptorNewIndex(self, key, value)
432
+ return __TS__DescriptorSet(
433
+ self,
434
+ getmetatable(self),
435
+ key,
436
+ value
437
+ )
438
+ end
439
+ function __TS__SetDescriptor(target, key, desc, isPrototype)
440
+ if isPrototype == nil then
441
+ isPrototype = false
442
+ end
443
+ local ____isPrototype_0
444
+ if isPrototype then
445
+ ____isPrototype_0 = target
446
+ else
447
+ ____isPrototype_0 = getmetatable(target)
448
+ end
449
+ local metatable = ____isPrototype_0
450
+ if not metatable then
451
+ metatable = {}
452
+ setmetatable(target, metatable)
453
+ end
454
+ if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
455
+ local instanceMetatable = {}
456
+ instanceMetatable._isOwnDescriptorMetatable = true
457
+ setmetatable(instanceMetatable, metatable)
458
+ setmetatable(target, instanceMetatable)
459
+ metatable = instanceMetatable
460
+ end
461
+ local value = rawget(target, key)
462
+ if value ~= nil then
463
+ rawset(target, key, nil)
464
+ end
465
+ if not rawget(metatable, "_descriptors") then
466
+ metatable._descriptors = {}
467
+ end
468
+ metatable._descriptors[key] = __TS__CloneDescriptor(desc)
469
+ metatable.__index = descriptorIndex
470
+ metatable.__newindex = descriptorNewIndex
471
+ end
472
+ end
473
+ -- End of Lua Library inline imports
474
+ local ____exports = {}
475
+ local ____DataSource = require("datasources.DataSource")
476
+ local DataSource = ____DataSource.DataSource
477
+ local ____GroupMembers = require("datasources.GroupMembers")
478
+ local GroupMembers = ____GroupMembers.GroupMembers
479
+ function ____exports.getPetUnitToken(self, unit)
480
+ if unit == "player" then
481
+ return "pet"
482
+ end
483
+ return __TS__StringReplace(
484
+ __TS__StringReplace(unit, "party", "partypet"),
485
+ "raid",
486
+ "raidpet"
487
+ )
488
+ end
489
+ --- Small snapshots describe identity/order only; keyed rendering owns widgets and unit sources.
490
+ ____exports.GroupRoster = __TS__Class()
491
+ local GroupRoster = ____exports.GroupRoster
492
+ GroupRoster.name = "GroupRoster"
493
+ __TS__ClassExtends(GroupRoster, DataSource)
494
+ function GroupRoster.prototype.____constructor(self, scope, options)
495
+ if scope == nil then
496
+ scope = "auto"
497
+ end
498
+ if options == nil then
499
+ options = {}
500
+ end
501
+ DataSource.prototype.____constructor(self, {})
502
+ self.scope = scope
503
+ self.options = options
504
+ self.knownNames = __TS__New(Map)
505
+ self.snapshot = {}
506
+ self.restricted = false
507
+ self.roster = __TS__New(GroupMembers, scope)
508
+ end
509
+ function GroupRoster.prototype.GetValue(self)
510
+ self.restricted = self.roster:IsSecret()
511
+ if self.restricted then
512
+ return self.snapshot
513
+ end
514
+ local units = {__TS__Unpack(self.roster.Value)}
515
+ if #units == 0 and self.options.includeSelfWhenSolo then
516
+ units = {"player"}
517
+ end
518
+ local members = __TS__ArrayMap(
519
+ units,
520
+ function(____, unit) return self:Read(unit, false) end
521
+ )
522
+ if self.scope == "raid" then
523
+ __TS__ArraySort(
524
+ members,
525
+ function(____, a, b) return __TS__Number(a.group) - __TS__Number(b.group) or __TS__Number(string.sub(a.unit, 5)) - __TS__Number(string.sub(b.unit, 5)) end
526
+ )
527
+ end
528
+ if self.options.pets then
529
+ for ____, unit in ipairs(units) do
530
+ local pet = ____exports.getPetUnitToken(nil, unit)
531
+ local exists = UnitExists(pet)
532
+ if not issecretvalue(exists) and exists then
533
+ members[#members + 1] = self:Read(pet, true)
534
+ end
535
+ end
536
+ end
537
+ self.snapshot = members
538
+ return members
539
+ end
540
+ function GroupRoster.prototype.Read(self, unit, pet)
541
+ local rawGUID = UnitGUID(unit)
542
+ local ____issecretvalue_result_0
543
+ if issecretvalue(rawGUID) then
544
+ ____issecretvalue_result_0 = nil
545
+ else
546
+ ____issecretvalue_result_0 = rawGUID
547
+ end
548
+ local guid = ____issecretvalue_result_0
549
+ local rawName, rawRealm = UnitFullName(unit)
550
+ local ____temp_1
551
+ if issecretvalue(rawName) or issecretvalue(rawRealm) or rawName == nil then
552
+ ____temp_1 = nil
553
+ else
554
+ ____temp_1 = (rawName .. "-") .. (rawRealm or "")
555
+ end
556
+ local fullName = ____temp_1
557
+ if pet and fullName ~= nil then
558
+ local owner = unit == "pet" and "player" or __TS__StringReplace(
559
+ __TS__StringReplace(unit, "partypet", "party"),
560
+ "raidpet",
561
+ "raid"
562
+ )
563
+ local name, realm = UnitFullName(owner)
564
+ fullName = ((not issecretvalue(name) and not issecretvalue(realm) and name ~= nil and (name .. "-") .. (realm or "") or owner) .. "/") .. fullName
565
+ end
566
+ if guid ~= nil and fullName ~= nil then
567
+ self.knownNames:set(fullName, guid)
568
+ end
569
+ local ____guid_3 = guid
570
+ if ____guid_3 == nil then
571
+ local ____temp_2
572
+ if fullName == nil then
573
+ ____temp_2 = nil
574
+ else
575
+ ____temp_2 = self.knownNames:get(fullName)
576
+ end
577
+ ____guid_3 = ____temp_2
578
+ end
579
+ local identity = ____guid_3
580
+ local group = "1"
581
+ if __TS__StringStartsWith(unit, "raid") and not pet then
582
+ local ____, ____, subgroup = GetRaidRosterInfo(__TS__Number(string.sub(unit, 5)))
583
+ if not issecretvalue(subgroup) and subgroup ~= nil and subgroup >= 1 and subgroup <= 8 then
584
+ group = tostring(subgroup)
585
+ end
586
+ end
587
+ return {
588
+ key = identity == nil and "name:" .. (fullName or unit) or "guid:" .. identity,
589
+ guid = guid,
590
+ unit = unit,
591
+ pet = pet,
592
+ group = group
593
+ }
594
+ end
595
+ function GroupRoster.prototype.onChange(self, listener)
596
+ return self.roster:onChange(function() return listener(nil, self.Value) end)
597
+ end
598
+ function GroupRoster.prototype.Dispose(self)
599
+ self.roster:Dispose()
600
+ self.knownNames:clear()
601
+ self.snapshot = {}
602
+ end
603
+ __TS__SetDescriptor(
604
+ GroupRoster.prototype,
605
+ "Status",
606
+ {get = function(self)
607
+ return self.restricted and "restricted" or "ready"
608
+ end},
609
+ true
610
+ )
611
+ return ____exports
@@ -0,0 +1,6 @@
1
+ import { SourceConverter } from "./SourceConverter";
2
+ import type { ValueSource } from "./SourceConverter";
3
+ export declare class MathConverter extends SourceConverter<number, number> {
4
+ constructor(input: ValueSource<number>, expression: string);
5
+ static Validate(expression: string): void;
6
+ }
@@ -0,0 +1,61 @@
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 function __TS__ClassExtends(target, base)
11
+ target.____super = base
12
+ local staticMetatable = setmetatable({__index = base}, base)
13
+ setmetatable(target, staticMetatable)
14
+ local baseMetatable = getmetatable(base)
15
+ if baseMetatable then
16
+ if type(baseMetatable.__index) == "function" then
17
+ staticMetatable.__index = baseMetatable.__index
18
+ end
19
+ if type(baseMetatable.__newindex) == "function" then
20
+ staticMetatable.__newindex = baseMetatable.__newindex
21
+ end
22
+ end
23
+ setmetatable(target.prototype, base.prototype)
24
+ if type(base.prototype.__index) == "function" then
25
+ target.prototype.__index = base.prototype.__index
26
+ end
27
+ if type(base.prototype.__newindex) == "function" then
28
+ target.prototype.__newindex = base.prototype.__newindex
29
+ end
30
+ if type(base.prototype.__tostring) == "function" then
31
+ target.prototype.__tostring = base.prototype.__tostring
32
+ end
33
+ end
34
+
35
+ local function __TS__New(target, ...)
36
+ local instance = setmetatable({}, target.prototype)
37
+ instance:____constructor(...)
38
+ return instance
39
+ end
40
+ -- End of Lua Library inline imports
41
+ local ____exports = {}
42
+ local ____SourceConverter = require("datasources.SourceConverter")
43
+ local SourceConverter = ____SourceConverter.SourceConverter
44
+ local ____MathExpression = require("datasources.MathExpression")
45
+ local MathExpression = ____MathExpression.MathExpression
46
+ ____exports.MathConverter = __TS__Class()
47
+ local MathConverter = ____exports.MathConverter
48
+ MathConverter.name = "MathConverter"
49
+ __TS__ClassExtends(MathConverter, SourceConverter)
50
+ function MathConverter.prototype.____constructor(self, input, expression)
51
+ local formula = __TS__New(MathExpression, expression)
52
+ SourceConverter.prototype.____constructor(
53
+ self,
54
+ input,
55
+ function(____, value) return formula:Evaluate(value) end
56
+ )
57
+ end
58
+ function MathConverter.Validate(self, expression)
59
+ __TS__New(MathExpression, expression)
60
+ end
61
+ return ____exports
@@ -0,0 +1,16 @@
1
+ /** Small bounded arithmetic grammar. Expressions cannot call functions or execute Lua. */
2
+ export declare class MathExpression {
3
+ private readonly text;
4
+ private offset;
5
+ private token;
6
+ private tokens;
7
+ private readonly tree;
8
+ constructor(text: string);
9
+ private Next;
10
+ private Depth;
11
+ private Add;
12
+ private Multiply;
13
+ private Unary;
14
+ private Primary;
15
+ Evaluate(input: number): number;
16
+ }