wuira 0.1.2 → 0.1.4
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/CHANGELOG.md +104 -0
- package/README.md +158 -0
- package/lib/datasources/Auras.d.ts +32 -0
- package/lib/datasources/Auras.lua +284 -0
- package/lib/datasources/GroupMembers.d.ts +18 -0
- package/lib/datasources/GroupMembers.lua +122 -0
- package/lib/datasources/Resources.d.ts +9 -8
- package/lib/datasources/Resources.lua +172 -11
- package/lib/datasources/UnitInfo.d.ts +45 -0
- package/lib/datasources/UnitInfo.lua +451 -0
- package/lib/datasources/UnitSource.d.ts +28 -0
- package/lib/datasources/UnitSource.lua +245 -0
- package/lib/datasources/index.d.ts +8 -0
- package/lib/datasources/index.lua +23 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.lua +5 -0
- package/lib/store/index.d.ts +37 -0
- package/lib/store/index.lua +921 -0
- package/package.json +9 -1
- package/tools/build-library.mjs +1 -1
|
@@ -0,0 +1,245 @@
|
|
|
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__CloneDescriptor(____bindingPattern0)
|
|
11
|
+
local value
|
|
12
|
+
local writable
|
|
13
|
+
local set
|
|
14
|
+
local get
|
|
15
|
+
local configurable
|
|
16
|
+
local enumerable
|
|
17
|
+
enumerable = ____bindingPattern0.enumerable
|
|
18
|
+
configurable = ____bindingPattern0.configurable
|
|
19
|
+
get = ____bindingPattern0.get
|
|
20
|
+
set = ____bindingPattern0.set
|
|
21
|
+
writable = ____bindingPattern0.writable
|
|
22
|
+
value = ____bindingPattern0.value
|
|
23
|
+
local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
|
|
24
|
+
local hasGetterOrSetter = get ~= nil or set ~= nil
|
|
25
|
+
local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
|
|
26
|
+
if hasGetterOrSetter and hasValueOrWritableAttribute then
|
|
27
|
+
error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
|
|
28
|
+
end
|
|
29
|
+
if get or set then
|
|
30
|
+
descriptor.get = get
|
|
31
|
+
descriptor.set = set
|
|
32
|
+
else
|
|
33
|
+
descriptor.value = value
|
|
34
|
+
descriptor.writable = writable == true
|
|
35
|
+
end
|
|
36
|
+
return descriptor
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
local __TS__DescriptorGet
|
|
40
|
+
do
|
|
41
|
+
local getmetatable = _G.getmetatable
|
|
42
|
+
local ____rawget = _G.rawget
|
|
43
|
+
function __TS__DescriptorGet(self, metatable, key)
|
|
44
|
+
while metatable do
|
|
45
|
+
local rawResult = ____rawget(metatable, key)
|
|
46
|
+
if rawResult ~= nil then
|
|
47
|
+
return rawResult
|
|
48
|
+
end
|
|
49
|
+
local descriptors = ____rawget(metatable, "_descriptors")
|
|
50
|
+
if descriptors then
|
|
51
|
+
local descriptor = descriptors[key]
|
|
52
|
+
if descriptor ~= nil then
|
|
53
|
+
if descriptor.get then
|
|
54
|
+
return descriptor.get(self)
|
|
55
|
+
end
|
|
56
|
+
return descriptor.value
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
metatable = getmetatable(metatable)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
local __TS__DescriptorSet
|
|
65
|
+
do
|
|
66
|
+
local getmetatable = _G.getmetatable
|
|
67
|
+
local ____rawget = _G.rawget
|
|
68
|
+
local rawset = _G.rawset
|
|
69
|
+
function __TS__DescriptorSet(self, metatable, key, value)
|
|
70
|
+
while metatable do
|
|
71
|
+
local descriptors = ____rawget(metatable, "_descriptors")
|
|
72
|
+
if descriptors then
|
|
73
|
+
local descriptor = descriptors[key]
|
|
74
|
+
if descriptor ~= nil then
|
|
75
|
+
if descriptor.set then
|
|
76
|
+
descriptor.set(self, value)
|
|
77
|
+
else
|
|
78
|
+
if descriptor.writable == false then
|
|
79
|
+
error(
|
|
80
|
+
((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
|
|
81
|
+
0
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
descriptor.value = value
|
|
85
|
+
end
|
|
86
|
+
return
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
metatable = getmetatable(metatable)
|
|
90
|
+
end
|
|
91
|
+
rawset(self, key, value)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
local __TS__SetDescriptor
|
|
96
|
+
do
|
|
97
|
+
local getmetatable = _G.getmetatable
|
|
98
|
+
local function descriptorIndex(self, key)
|
|
99
|
+
return __TS__DescriptorGet(
|
|
100
|
+
self,
|
|
101
|
+
getmetatable(self),
|
|
102
|
+
key
|
|
103
|
+
)
|
|
104
|
+
end
|
|
105
|
+
local function descriptorNewIndex(self, key, value)
|
|
106
|
+
return __TS__DescriptorSet(
|
|
107
|
+
self,
|
|
108
|
+
getmetatable(self),
|
|
109
|
+
key,
|
|
110
|
+
value
|
|
111
|
+
)
|
|
112
|
+
end
|
|
113
|
+
function __TS__SetDescriptor(target, key, desc, isPrototype)
|
|
114
|
+
if isPrototype == nil then
|
|
115
|
+
isPrototype = false
|
|
116
|
+
end
|
|
117
|
+
local ____isPrototype_0
|
|
118
|
+
if isPrototype then
|
|
119
|
+
____isPrototype_0 = target
|
|
120
|
+
else
|
|
121
|
+
____isPrototype_0 = getmetatable(target)
|
|
122
|
+
end
|
|
123
|
+
local metatable = ____isPrototype_0
|
|
124
|
+
if not metatable then
|
|
125
|
+
metatable = {}
|
|
126
|
+
setmetatable(target, metatable)
|
|
127
|
+
end
|
|
128
|
+
if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
|
|
129
|
+
local instanceMetatable = {}
|
|
130
|
+
instanceMetatable._isOwnDescriptorMetatable = true
|
|
131
|
+
setmetatable(instanceMetatable, metatable)
|
|
132
|
+
setmetatable(target, instanceMetatable)
|
|
133
|
+
metatable = instanceMetatable
|
|
134
|
+
end
|
|
135
|
+
local value = rawget(target, key)
|
|
136
|
+
if value ~= nil then
|
|
137
|
+
rawset(target, key, nil)
|
|
138
|
+
end
|
|
139
|
+
if not rawget(metatable, "_descriptors") then
|
|
140
|
+
metatable._descriptors = {}
|
|
141
|
+
end
|
|
142
|
+
metatable._descriptors[key] = __TS__CloneDescriptor(desc)
|
|
143
|
+
metatable.__index = descriptorIndex
|
|
144
|
+
metatable.__newindex = descriptorNewIndex
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
local function __TS__ClassExtends(target, base)
|
|
149
|
+
target.____super = base
|
|
150
|
+
local staticMetatable = setmetatable({__index = base}, base)
|
|
151
|
+
setmetatable(target, staticMetatable)
|
|
152
|
+
local baseMetatable = getmetatable(base)
|
|
153
|
+
if baseMetatable then
|
|
154
|
+
if type(baseMetatable.__index) == "function" then
|
|
155
|
+
staticMetatable.__index = baseMetatable.__index
|
|
156
|
+
end
|
|
157
|
+
if type(baseMetatable.__newindex) == "function" then
|
|
158
|
+
staticMetatable.__newindex = baseMetatable.__newindex
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
setmetatable(target.prototype, base.prototype)
|
|
162
|
+
if type(base.prototype.__index) == "function" then
|
|
163
|
+
target.prototype.__index = base.prototype.__index
|
|
164
|
+
end
|
|
165
|
+
if type(base.prototype.__newindex) == "function" then
|
|
166
|
+
target.prototype.__newindex = base.prototype.__newindex
|
|
167
|
+
end
|
|
168
|
+
if type(base.prototype.__tostring) == "function" then
|
|
169
|
+
target.prototype.__tostring = base.prototype.__tostring
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
local function __TS__New(target, ...)
|
|
174
|
+
local instance = setmetatable({}, target.prototype)
|
|
175
|
+
instance:____constructor(...)
|
|
176
|
+
return instance
|
|
177
|
+
end
|
|
178
|
+
-- End of Lua Library inline imports
|
|
179
|
+
local ____exports = {}
|
|
180
|
+
local ____DataSource = require("datasources.DataSource")
|
|
181
|
+
local DataSource = ____DataSource.DataSource
|
|
182
|
+
____exports.Unit = {Player = "player", Target = "target", Focus = "focus"}
|
|
183
|
+
____exports.UnitPredicates = __TS__Class()
|
|
184
|
+
local UnitPredicates = ____exports.UnitPredicates
|
|
185
|
+
UnitPredicates.name = "UnitPredicates"
|
|
186
|
+
function UnitPredicates.prototype.____constructor(self, token)
|
|
187
|
+
self.token = token
|
|
188
|
+
end
|
|
189
|
+
__TS__SetDescriptor(
|
|
190
|
+
UnitPredicates.prototype,
|
|
191
|
+
"PC",
|
|
192
|
+
{get = function(self)
|
|
193
|
+
local value = UnitIsPlayer(self.token)
|
|
194
|
+
local ____issecretvalue_result_0
|
|
195
|
+
if issecretvalue(value) then
|
|
196
|
+
____issecretvalue_result_0 = nil
|
|
197
|
+
else
|
|
198
|
+
____issecretvalue_result_0 = value
|
|
199
|
+
end
|
|
200
|
+
return ____issecretvalue_result_0
|
|
201
|
+
end},
|
|
202
|
+
true
|
|
203
|
+
)
|
|
204
|
+
__TS__SetDescriptor(
|
|
205
|
+
UnitPredicates.prototype,
|
|
206
|
+
"Self",
|
|
207
|
+
{get = function(self)
|
|
208
|
+
local value = UnitIsUnit(self.token, "player")
|
|
209
|
+
local ____issecretvalue_result_1
|
|
210
|
+
if issecretvalue(value) then
|
|
211
|
+
____issecretvalue_result_1 = nil
|
|
212
|
+
else
|
|
213
|
+
____issecretvalue_result_1 = value
|
|
214
|
+
end
|
|
215
|
+
return ____issecretvalue_result_1
|
|
216
|
+
end},
|
|
217
|
+
true
|
|
218
|
+
)
|
|
219
|
+
--- Shared live unit reference; identity is read again rather than cached by token.
|
|
220
|
+
____exports.UnitSource = __TS__Class()
|
|
221
|
+
local UnitSource = ____exports.UnitSource
|
|
222
|
+
UnitSource.name = "UnitSource"
|
|
223
|
+
__TS__ClassExtends(UnitSource, DataSource)
|
|
224
|
+
function UnitSource.prototype.____constructor(self, Token)
|
|
225
|
+
DataSource.prototype.____constructor(self, nil)
|
|
226
|
+
self.Token = Token
|
|
227
|
+
self.restricted = false
|
|
228
|
+
self.Is = __TS__New(____exports.UnitPredicates, Token)
|
|
229
|
+
end
|
|
230
|
+
function UnitSource.prototype.HasSecretFields(self)
|
|
231
|
+
return self.restricted
|
|
232
|
+
end
|
|
233
|
+
function UnitSource.prototype.GetValue(self)
|
|
234
|
+
local guid = UnitGUID(self.Token)
|
|
235
|
+
self.restricted = issecretvalue(guid)
|
|
236
|
+
if self.restricted or guid == nil then
|
|
237
|
+
return nil
|
|
238
|
+
end
|
|
239
|
+
return {token = self.Token, guid = guid}
|
|
240
|
+
end
|
|
241
|
+
--- Reuse explicit unit references; string inputs remain a convenience shorthand.
|
|
242
|
+
function ____exports.resolveUnit(self, unit)
|
|
243
|
+
return type(unit) == "string" and __TS__New(____exports.UnitSource, unit) or unit
|
|
244
|
+
end
|
|
245
|
+
return ____exports
|
|
@@ -2,3 +2,11 @@
|
|
|
2
2
|
export { DataSource } from "./DataSource";
|
|
3
3
|
export { ProgressSource } from "./ProgressSource";
|
|
4
4
|
export { HP, Mana, Unit, DataSources } from "./Resources";
|
|
5
|
+
export { Aura, AuraSource, Buffs, Debuffs } from "./Auras";
|
|
6
|
+
export type { AuraSourceStatus } from "./Auras";
|
|
7
|
+
export { GroupMembers, PartyMembers, RaidMembers } from "./GroupMembers";
|
|
8
|
+
export type { GroupScope } from "./GroupMembers";
|
|
9
|
+
export { ClassSource, SpecSource, Specializations } from "./UnitInfo";
|
|
10
|
+
export type { ClassInfo, SpecializationInfo, InspectStatus } from "./UnitInfo";
|
|
11
|
+
export { UnitSource } from "./UnitSource";
|
|
12
|
+
export type { UnitInput, UnitIdentity } from "./UnitSource";
|
|
@@ -15,4 +15,27 @@ do
|
|
|
15
15
|
____exports.Unit = ____Resources.Unit
|
|
16
16
|
____exports.DataSources = ____Resources.DataSources
|
|
17
17
|
end
|
|
18
|
+
do
|
|
19
|
+
local ____Auras = require("datasources.Auras")
|
|
20
|
+
____exports.Aura = ____Auras.Aura
|
|
21
|
+
____exports.AuraSource = ____Auras.AuraSource
|
|
22
|
+
____exports.Buffs = ____Auras.Buffs
|
|
23
|
+
____exports.Debuffs = ____Auras.Debuffs
|
|
24
|
+
end
|
|
25
|
+
do
|
|
26
|
+
local ____GroupMembers = require("datasources.GroupMembers")
|
|
27
|
+
____exports.GroupMembers = ____GroupMembers.GroupMembers
|
|
28
|
+
____exports.PartyMembers = ____GroupMembers.PartyMembers
|
|
29
|
+
____exports.RaidMembers = ____GroupMembers.RaidMembers
|
|
30
|
+
end
|
|
31
|
+
do
|
|
32
|
+
local ____UnitInfo = require("datasources.UnitInfo")
|
|
33
|
+
____exports.ClassSource = ____UnitInfo.ClassSource
|
|
34
|
+
____exports.SpecSource = ____UnitInfo.SpecSource
|
|
35
|
+
____exports.Specializations = ____UnitInfo.Specializations
|
|
36
|
+
end
|
|
37
|
+
do
|
|
38
|
+
local ____UnitSource = require("datasources.UnitSource")
|
|
39
|
+
____exports.UnitSource = ____UnitSource.UnitSource
|
|
40
|
+
end
|
|
18
41
|
return ____exports
|
package/lib/index.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export { wuira } from "./wuira";
|
|
|
4
4
|
export { UI } from "./ui/primitives/jsx";
|
|
5
5
|
export type { Element, Component } from "./ui/primitives/jsx";
|
|
6
6
|
export type { Cell } from "./ui/Cell";
|
|
7
|
+
export { Store, StoreRegistry } from "./store";
|
|
8
|
+
export type { StoreClass, ReadonlyData, SavedStoreOptions } from "./store";
|
package/lib/index.lua
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference path="../platform/forever.d.ts" />
|
|
2
|
+
/** Extend with data fields and defaults. A stable static Token opts into persistence. */
|
|
3
|
+
export declare abstract class Store {
|
|
4
|
+
}
|
|
5
|
+
export interface StoreClass<T extends Store> {
|
|
6
|
+
new (): T;
|
|
7
|
+
readonly Token?: string;
|
|
8
|
+
}
|
|
9
|
+
export type ReadonlyData<T> = T extends object ? {
|
|
10
|
+
readonly [K in keyof T]: ReadonlyData<T[K]>;
|
|
11
|
+
} : T;
|
|
12
|
+
export interface SavedStoreOptions {
|
|
13
|
+
addon: string;
|
|
14
|
+
variable: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class StoreRegistry {
|
|
17
|
+
private readonly options?;
|
|
18
|
+
private readonly memory;
|
|
19
|
+
private readonly observers;
|
|
20
|
+
private readonly tokens;
|
|
21
|
+
private readonly updating;
|
|
22
|
+
private saved?;
|
|
23
|
+
private listener?;
|
|
24
|
+
private readyCallbacks;
|
|
25
|
+
constructor(options?: SavedStoreOptions | undefined);
|
|
26
|
+
private Load;
|
|
27
|
+
get IsReady(): boolean;
|
|
28
|
+
onReady(callback: () => void): void;
|
|
29
|
+
private Read;
|
|
30
|
+
/** One-time detached snapshot, with no subscription or mutable access to stored data. */
|
|
31
|
+
get<T extends Store>(schema: StoreClass<T>): ReadonlyData<T>;
|
|
32
|
+
/** Commit only after the updater succeeds; observers receive detached snapshots. */
|
|
33
|
+
set<T extends Store>(schema: StoreClass<T>, update: (settings: T) => T): void;
|
|
34
|
+
/** Observe future commits. Call get() separately for the initial snapshot. */
|
|
35
|
+
subscribe<T extends Store>(schema: StoreClass<T>, observer: (settings: ReadonlyData<T>) => void): () => void;
|
|
36
|
+
Dispose(): void;
|
|
37
|
+
}
|