wuira 0.1.7 → 0.1.9
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 +47 -0
- package/README.md +66 -0
- package/lib/Spells.d.ts +20 -0
- package/lib/Spells.lua +40 -0
- package/lib/datasources/KnownSpells.d.ts +13 -1
- package/lib/datasources/KnownSpells.lua +323 -49
- package/lib/datasources/index.d.ts +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.lua +4 -0
- package/lib/platform/Encoding.d.ts +6 -0
- package/lib/platform/Encoding.lua +58 -0
- package/lib/platform/forever.d.ts +15 -2
- package/lib/ui/Cell.d.ts +2 -0
- package/lib/ui/FlowLayout.d.ts +4 -2
- package/lib/ui/ForEach.d.ts +7 -0
- package/lib/ui/ForEach.lua +30 -0
- package/lib/ui/GridLayout.d.ts +2 -2
- package/lib/ui/ScrollHost.d.ts +19 -0
- package/lib/ui/ScrollHost.lua +67 -0
- package/lib/ui/TextInput.d.ts +26 -0
- package/lib/ui/TextInput.lua +206 -0
- package/lib/ui/Window.d.ts +21 -0
- package/lib/ui/Window.lua +300 -0
- package/lib/ui/index.d.ts +7 -1
- package/lib/ui/index.lua +16 -0
- package/lib/ui/layout/calculateFlow.lua +26 -0
- package/lib/ui/mount.lua +133 -117
- package/lib/ui/primitives/jsx.d.ts +6 -3
- package/lib/ui/primitives/jsx.lua +334 -7
- package/package.json +1 -1
package/lib/ui/FlowLayout.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { LayoutProps, ILayout } from "./Layout";
|
|
2
|
-
import type { Element } from "./primitives/jsx";
|
|
2
|
+
import type { Element, Children } from "./primitives/jsx";
|
|
3
3
|
export interface FlowOptions {
|
|
4
4
|
direction: "horizontal" | "vertical";
|
|
5
5
|
/** Wrap to another row (horizontal) or column (vertical) when full. */
|
|
6
6
|
grow?: boolean;
|
|
7
7
|
/** Space between rows/columns; defaults to gap. */
|
|
8
8
|
lineGap?: number;
|
|
9
|
+
/** Align each row/column along the flow direction. Defaults to start. */
|
|
10
|
+
justify?: "start" | "center" | "end";
|
|
9
11
|
}
|
|
10
12
|
export type FlowLayoutProps = LayoutProps & FlowOptions;
|
|
11
13
|
export interface IFlowLayout extends ILayout {
|
|
@@ -14,5 +16,5 @@ export interface IFlowLayout extends ILayout {
|
|
|
14
16
|
children: Element[];
|
|
15
17
|
}
|
|
16
18
|
export declare function FlowLayout(props: Partial<FlowLayoutProps> & {
|
|
17
|
-
child?:
|
|
19
|
+
child?: Children;
|
|
18
20
|
}): Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Element } from "./primitives/jsx";
|
|
2
|
+
export interface ForEachProps<T> {
|
|
3
|
+
items: readonly T[];
|
|
4
|
+
child: (item: T, index: number) => Element;
|
|
5
|
+
}
|
|
6
|
+
/** Expands a snapshot into siblings. It creates no native frame or subscription. */
|
|
7
|
+
export declare function ForEach<T>({ items, child }: ForEachProps<T>): Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
2
|
+
-- Lua Library inline imports
|
|
3
|
+
local function __TS__ArrayMap(self, callbackfn, thisArg)
|
|
4
|
+
local result = {}
|
|
5
|
+
for i = 1, #self do
|
|
6
|
+
result[i] = callbackfn(thisArg, self[i], i - 1, self)
|
|
7
|
+
end
|
|
8
|
+
return result
|
|
9
|
+
end
|
|
10
|
+
-- End of Lua Library inline imports
|
|
11
|
+
local ____exports = {}
|
|
12
|
+
--- Expands a snapshot into siblings. It creates no native frame or subscription.
|
|
13
|
+
function ____exports.ForEach(self, ____bindingPattern0)
|
|
14
|
+
local child
|
|
15
|
+
local items
|
|
16
|
+
items = ____bindingPattern0.items
|
|
17
|
+
child = ____bindingPattern0.child
|
|
18
|
+
if type(child) ~= "function" then
|
|
19
|
+
error("ForEach requires a render function as its child")
|
|
20
|
+
end
|
|
21
|
+
return {
|
|
22
|
+
kind = "group",
|
|
23
|
+
props = {},
|
|
24
|
+
children = __TS__ArrayMap(
|
|
25
|
+
items,
|
|
26
|
+
function(____, item, index) return child(nil, item, index) end
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
return ____exports
|
package/lib/ui/GridLayout.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LayoutProps, ILayout } from "./Layout";
|
|
2
|
-
import type { Element } from "./primitives/jsx";
|
|
2
|
+
import type { Element, Children } from "./primitives/jsx";
|
|
3
3
|
export interface GridOptions {
|
|
4
4
|
columns: number;
|
|
5
5
|
rowGap?: number;
|
|
@@ -15,5 +15,5 @@ export interface IGridLayout extends ILayout {
|
|
|
15
15
|
children: Element[];
|
|
16
16
|
}
|
|
17
17
|
export declare function GridLayout(props: Partial<GridLayoutProps> & {
|
|
18
|
-
child?:
|
|
18
|
+
child?: Children;
|
|
19
19
|
}): Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface NativeScrollFrame extends wuiraNativeFrame {
|
|
2
|
+
SetScrollChild(child: wuiraNativeFrame): void;
|
|
3
|
+
UpdateScrollChildRect(): void;
|
|
4
|
+
GetVerticalScrollRange(): number;
|
|
5
|
+
GetVerticalScroll(): number;
|
|
6
|
+
SetVerticalScroll(offset: number): void;
|
|
7
|
+
}
|
|
8
|
+
/** Native clipping and mouse-wheel scrolling for content mounted inside a Cell. */
|
|
9
|
+
export declare class ScrollHost {
|
|
10
|
+
private readonly onScroll?;
|
|
11
|
+
readonly Frame: NativeScrollFrame;
|
|
12
|
+
private disposed;
|
|
13
|
+
constructor(parent: wuiraNativeFrame, onScroll?: ((offset: number) => void) | undefined);
|
|
14
|
+
SetContent(content: wuiraNativeFrame, offset?: number): void;
|
|
15
|
+
ScrollBy(amount: number): void;
|
|
16
|
+
ScrollTo(offset: number): void;
|
|
17
|
+
Dispose(): void;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
--- Native clipping and mouse-wheel scrolling for content mounted inside a Cell.
|
|
12
|
+
____exports.ScrollHost = __TS__Class()
|
|
13
|
+
local ScrollHost = ____exports.ScrollHost
|
|
14
|
+
ScrollHost.name = "ScrollHost"
|
|
15
|
+
function ScrollHost.prototype.____constructor(self, parent, onScroll)
|
|
16
|
+
self.onScroll = onScroll
|
|
17
|
+
self.disposed = false
|
|
18
|
+
self.Frame = CreateFrame("ScrollFrame", nil, parent)
|
|
19
|
+
self.Frame:SetSize(
|
|
20
|
+
parent:GetWidth(),
|
|
21
|
+
parent:GetHeight()
|
|
22
|
+
)
|
|
23
|
+
self.Frame:SetAllPoints(parent)
|
|
24
|
+
self.Frame:EnableMouse(true)
|
|
25
|
+
self.Frame:SetScript(
|
|
26
|
+
"OnMouseWheel",
|
|
27
|
+
function(_frame, delta) return self:ScrollBy(-delta * 32) end
|
|
28
|
+
)
|
|
29
|
+
self.Frame:Show()
|
|
30
|
+
end
|
|
31
|
+
function ScrollHost.prototype.SetContent(self, content, offset)
|
|
32
|
+
if offset == nil then
|
|
33
|
+
offset = 0
|
|
34
|
+
end
|
|
35
|
+
self.Frame:SetScrollChild(content)
|
|
36
|
+
self.Frame:UpdateScrollChildRect()
|
|
37
|
+
self:ScrollTo(offset)
|
|
38
|
+
end
|
|
39
|
+
function ScrollHost.prototype.ScrollBy(self, amount)
|
|
40
|
+
self:ScrollTo(self.Frame:GetVerticalScroll() + amount)
|
|
41
|
+
end
|
|
42
|
+
function ScrollHost.prototype.ScrollTo(self, offset)
|
|
43
|
+
if self.disposed then
|
|
44
|
+
return
|
|
45
|
+
end
|
|
46
|
+
local value = math.max(
|
|
47
|
+
0,
|
|
48
|
+
math.min(
|
|
49
|
+
self.Frame:GetVerticalScrollRange(),
|
|
50
|
+
offset
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
self.Frame:SetVerticalScroll(value)
|
|
54
|
+
local ____opt_0 = self.onScroll
|
|
55
|
+
if ____opt_0 ~= nil then
|
|
56
|
+
____opt_0(self, value)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
function ScrollHost.prototype.Dispose(self)
|
|
60
|
+
if self.disposed then
|
|
61
|
+
return
|
|
62
|
+
end
|
|
63
|
+
self.disposed = true
|
|
64
|
+
self.Frame:SetScript("OnMouseWheel", nil)
|
|
65
|
+
self.Frame:Hide()
|
|
66
|
+
end
|
|
67
|
+
return ____exports
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface NativeEditBox extends wuiraNativeFrame {
|
|
2
|
+
SetAutoFocus(value: boolean): void;
|
|
3
|
+
SetMultiLine(value: boolean): void;
|
|
4
|
+
SetFont(path: string, size: number, flags: string): boolean;
|
|
5
|
+
SetTextInsets(left: number, right: number, top: number, bottom: number): void;
|
|
6
|
+
SetMaxBytes(bytes: number): void;
|
|
7
|
+
SetText(text: string): void;
|
|
8
|
+
GetText(): string;
|
|
9
|
+
HighlightText(): void;
|
|
10
|
+
SetFocus(): void;
|
|
11
|
+
ClearFocus(): void;
|
|
12
|
+
}
|
|
13
|
+
/** Native text entry hosted by a mounted Cell. Dispose it in that Cell's onMount cleanup. */
|
|
14
|
+
export declare class TextInput {
|
|
15
|
+
readonly Frame: NativeEditBox;
|
|
16
|
+
private disposed;
|
|
17
|
+
constructor(parent: wuiraNativeFrame, options?: {
|
|
18
|
+
text?: string;
|
|
19
|
+
maxBytes?: number;
|
|
20
|
+
onEscape?: () => void;
|
|
21
|
+
});
|
|
22
|
+
get Value(): string;
|
|
23
|
+
Focus(selectAll?: boolean): void;
|
|
24
|
+
Dispose(): void;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
-- End of Lua Library inline imports
|
|
148
|
+
local ____exports = {}
|
|
149
|
+
--- Native text entry hosted by a mounted Cell. Dispose it in that Cell's onMount cleanup.
|
|
150
|
+
____exports.TextInput = __TS__Class()
|
|
151
|
+
local TextInput = ____exports.TextInput
|
|
152
|
+
TextInput.name = "TextInput"
|
|
153
|
+
function TextInput.prototype.____constructor(self, parent, options)
|
|
154
|
+
if options == nil then
|
|
155
|
+
options = {}
|
|
156
|
+
end
|
|
157
|
+
self.disposed = false
|
|
158
|
+
self.Frame = CreateFrame("EditBox", nil, parent)
|
|
159
|
+
self.Frame:SetAutoFocus(false)
|
|
160
|
+
self.Frame:SetMultiLine(false)
|
|
161
|
+
self.Frame:SetFont("Fonts\\FRIZQT__.TTF", 12, "")
|
|
162
|
+
self.Frame:SetTextInsets(8, 8, 4, 4)
|
|
163
|
+
self.Frame:SetMaxBytes(options.maxBytes or 262144)
|
|
164
|
+
self.Frame:SetAllPoints(parent)
|
|
165
|
+
self.Frame:SetText(options.text or "")
|
|
166
|
+
self.Frame:SetScript(
|
|
167
|
+
"OnEscapePressed",
|
|
168
|
+
function()
|
|
169
|
+
self.Frame:ClearFocus()
|
|
170
|
+
local ____this_1
|
|
171
|
+
____this_1 = options
|
|
172
|
+
local ____opt_0 = ____this_1.onEscape
|
|
173
|
+
if ____opt_0 ~= nil then
|
|
174
|
+
____opt_0(____this_1)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
)
|
|
178
|
+
self.Frame:Show()
|
|
179
|
+
end
|
|
180
|
+
function TextInput.prototype.Focus(self, selectAll)
|
|
181
|
+
if selectAll == nil then
|
|
182
|
+
selectAll = false
|
|
183
|
+
end
|
|
184
|
+
self.Frame:SetFocus()
|
|
185
|
+
if selectAll then
|
|
186
|
+
self.Frame:HighlightText()
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
function TextInput.prototype.Dispose(self)
|
|
190
|
+
if self.disposed then
|
|
191
|
+
return
|
|
192
|
+
end
|
|
193
|
+
self.disposed = true
|
|
194
|
+
self.Frame:ClearFocus()
|
|
195
|
+
self.Frame:SetScript("OnEscapePressed", nil)
|
|
196
|
+
self.Frame:Hide()
|
|
197
|
+
end
|
|
198
|
+
__TS__SetDescriptor(
|
|
199
|
+
TextInput.prototype,
|
|
200
|
+
"Value",
|
|
201
|
+
{get = function(self)
|
|
202
|
+
return self.Frame:GetText()
|
|
203
|
+
end},
|
|
204
|
+
true
|
|
205
|
+
)
|
|
206
|
+
return ____exports
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Cell } from "./Cell";
|
|
2
|
+
export interface WindowOptions {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
/** A draggable, standalone UI host. Closing releases its mounted content. */
|
|
7
|
+
export declare class Window {
|
|
8
|
+
readonly Frame: wuiraNativeFrame;
|
|
9
|
+
private content?;
|
|
10
|
+
private pendingClose;
|
|
11
|
+
private disposed;
|
|
12
|
+
private moving;
|
|
13
|
+
constructor(options: WindowOptions);
|
|
14
|
+
get IsOpen(): boolean;
|
|
15
|
+
Open(view: Cell | (() => Cell | void)): void;
|
|
16
|
+
/** Use as a header's onMount callback, returning the cleanup to the mounted tree. */
|
|
17
|
+
BindDragHandle(handle: wuiraNativeFrame): () => void;
|
|
18
|
+
Close(): void;
|
|
19
|
+
Dispose(): void;
|
|
20
|
+
private StopMoving;
|
|
21
|
+
}
|