wuira 0.2.0 → 0.2.1

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/lib/wuira.lua CHANGED
@@ -6,36 +6,224 @@ local function __TS__Class(self)
6
6
  c.prototype.constructor = c
7
7
  return c
8
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
- local ____SlashCommands = require("platform.SlashCommands")
15
- local registerCommand = ____SlashCommands.registerCommand
16
- --- Public entry point for mounting JSX UI trees.
17
- ____exports.wuira = __TS__Class()
18
- local wuira = ____exports.wuira
19
- wuira.name = "wuira"
20
- function wuira.prototype.____constructor(self)
21
- end
22
- function wuira.registerCommand(self, command, callback)
23
- return registerCommand(nil, command, callback)
24
- end
25
- function wuira.Mount(self, frame, anchor, parent)
26
- local ____temp_0
27
- if type(frame) == "function" then
28
- ____temp_0 = frame(nil)
9
+
10
+ local function __TS__New(target, ...)
11
+ local instance = setmetatable({}, target.prototype)
12
+ instance:____constructor(...)
13
+ return instance
14
+ end
15
+
16
+ local function __TS__CloneDescriptor(____bindingPattern0)
17
+ local value
18
+ local writable
19
+ local set
20
+ local get
21
+ local configurable
22
+ local enumerable
23
+ enumerable = ____bindingPattern0.enumerable
24
+ configurable = ____bindingPattern0.configurable
25
+ get = ____bindingPattern0.get
26
+ set = ____bindingPattern0.set
27
+ writable = ____bindingPattern0.writable
28
+ value = ____bindingPattern0.value
29
+ local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
30
+ local hasGetterOrSetter = get ~= nil or set ~= nil
31
+ local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
32
+ if hasGetterOrSetter and hasValueOrWritableAttribute then
33
+ error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
34
+ end
35
+ if get or set then
36
+ descriptor.get = get
37
+ descriptor.set = set
29
38
  else
30
- ____temp_0 = frame
39
+ descriptor.value = value
40
+ descriptor.writable = writable == true
41
+ end
42
+ return descriptor
43
+ end
44
+
45
+ local __TS__DescriptorGet
46
+ do
47
+ local getmetatable = _G.getmetatable
48
+ local ____rawget = _G.rawget
49
+ function __TS__DescriptorGet(self, metatable, key)
50
+ while metatable do
51
+ local rawResult = ____rawget(metatable, key)
52
+ if rawResult ~= nil then
53
+ return rawResult
54
+ end
55
+ local descriptors = ____rawget(metatable, "_descriptors")
56
+ if descriptors then
57
+ local descriptor = descriptors[key]
58
+ if descriptor ~= nil then
59
+ if descriptor.get then
60
+ return descriptor.get(self)
61
+ end
62
+ return descriptor.value
63
+ end
64
+ end
65
+ metatable = getmetatable(metatable)
66
+ end
67
+ end
68
+ end
69
+
70
+ local __TS__DescriptorSet
71
+ do
72
+ local getmetatable = _G.getmetatable
73
+ local ____rawget = _G.rawget
74
+ local rawset = _G.rawset
75
+ function __TS__DescriptorSet(self, metatable, key, value)
76
+ while metatable do
77
+ local descriptors = ____rawget(metatable, "_descriptors")
78
+ if descriptors then
79
+ local descriptor = descriptors[key]
80
+ if descriptor ~= nil then
81
+ if descriptor.set then
82
+ descriptor.set(self, value)
83
+ else
84
+ if descriptor.writable == false then
85
+ error(
86
+ ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
87
+ 0
88
+ )
89
+ end
90
+ descriptor.value = value
91
+ end
92
+ return
93
+ end
94
+ end
95
+ metatable = getmetatable(metatable)
96
+ end
97
+ rawset(self, key, value)
98
+ end
99
+ end
100
+
101
+ local __TS__SetDescriptor
102
+ do
103
+ local getmetatable = _G.getmetatable
104
+ local function descriptorIndex(self, key)
105
+ return __TS__DescriptorGet(
106
+ self,
107
+ getmetatable(self),
108
+ key
109
+ )
31
110
  end
32
- local view = ____temp_0
33
- if view == nil or view.kind == "empty" then
34
- return nil
111
+ local function descriptorNewIndex(self, key, value)
112
+ return __TS__DescriptorSet(
113
+ self,
114
+ getmetatable(self),
115
+ key,
116
+ value
117
+ )
35
118
  end
36
- return mount(nil, view, parent, anchor)
119
+ function __TS__SetDescriptor(target, key, desc, isPrototype)
120
+ if isPrototype == nil then
121
+ isPrototype = false
122
+ end
123
+ local ____isPrototype_0
124
+ if isPrototype then
125
+ ____isPrototype_0 = target
126
+ else
127
+ ____isPrototype_0 = getmetatable(target)
128
+ end
129
+ local metatable = ____isPrototype_0
130
+ if not metatable then
131
+ metatable = {}
132
+ setmetatable(target, metatable)
133
+ end
134
+ if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
135
+ local instanceMetatable = {}
136
+ instanceMetatable._isOwnDescriptorMetatable = true
137
+ setmetatable(instanceMetatable, metatable)
138
+ setmetatable(target, instanceMetatable)
139
+ metatable = instanceMetatable
140
+ end
141
+ local value = rawget(target, key)
142
+ if value ~= nil then
143
+ rawset(target, key, nil)
144
+ end
145
+ if not rawget(metatable, "_descriptors") then
146
+ metatable._descriptors = {}
147
+ end
148
+ metatable._descriptors[key] = __TS__CloneDescriptor(desc)
149
+ metatable.__index = descriptorIndex
150
+ metatable.__newindex = descriptorNewIndex
151
+ end
152
+ end
153
+
154
+ local function __TS__ObjectDefineProperty(target, key, desc)
155
+ local luaKey = type(key) == "number" and key + 1 or key
156
+ local value = rawget(target, luaKey)
157
+ local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
158
+ local descriptor
159
+ if hasGetterOrSetter then
160
+ if value ~= nil then
161
+ error(
162
+ "Cannot redefine property: " .. tostring(key),
163
+ 0
164
+ )
165
+ end
166
+ descriptor = desc
167
+ else
168
+ local valueExists = value ~= nil
169
+ local ____desc_set_4 = desc.set
170
+ local ____desc_get_5 = desc.get
171
+ local ____desc_configurable_0 = desc.configurable
172
+ if ____desc_configurable_0 == nil then
173
+ ____desc_configurable_0 = valueExists
174
+ end
175
+ local ____desc_enumerable_1 = desc.enumerable
176
+ if ____desc_enumerable_1 == nil then
177
+ ____desc_enumerable_1 = valueExists
178
+ end
179
+ local ____desc_writable_2 = desc.writable
180
+ if ____desc_writable_2 == nil then
181
+ ____desc_writable_2 = valueExists
182
+ end
183
+ local ____temp_3
184
+ if desc.value ~= nil then
185
+ ____temp_3 = desc.value
186
+ else
187
+ ____temp_3 = value
188
+ end
189
+ descriptor = {
190
+ set = ____desc_set_4,
191
+ get = ____desc_get_5,
192
+ configurable = ____desc_configurable_0,
193
+ enumerable = ____desc_enumerable_1,
194
+ writable = ____desc_writable_2,
195
+ value = ____temp_3
196
+ }
197
+ end
198
+ __TS__SetDescriptor(target, luaKey, descriptor)
199
+ return target
200
+ end
201
+ -- End of Lua Library inline imports
202
+ local ____exports = {}
203
+ local ____WuiraApp = require("WuiraApp")
204
+ local WuiraApp = ____WuiraApp.WuiraApp
205
+ --- Static access to the current addon's application. Each addon owns its module instance.
206
+ ____exports.Wuira = __TS__Class()
207
+ local Wuira = ____exports.Wuira
208
+ Wuira.name = "Wuira"
209
+ function Wuira.prototype.____constructor(self)
210
+ end
211
+ function Wuira.registerCommand(self, command, callback)
212
+ return ____exports.Wuira.App:registerCommand(command, callback)
213
+ end
214
+ function Wuira.Mount(self, component, anchor, parent)
215
+ return ____exports.Wuira.App:Mount(component, anchor, parent)
37
216
  end
38
- function wuira.Unmount(self, frame)
39
- unmount(nil, frame)
217
+ function Wuira.Unmount(self, frame)
218
+ ____exports.Wuira.App:Unmount(frame)
40
219
  end
220
+ Wuira.application = __TS__New(WuiraApp)
221
+ __TS__ObjectDefineProperty(
222
+ Wuira,
223
+ "App",
224
+ {get = function(self)
225
+ return ____exports.Wuira.application
226
+ end}
227
+ )
228
+ ____exports.wuira = ____exports.Wuira
41
229
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wuira",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "author": {
5
5
  "name": "Kerim Cetinbas",
6
6
  "email": "a.cetinbas@icloud.com"
@@ -1,7 +1,7 @@
1
- import { wuira } from "wuira";
1
+ import { Wuira } from "wuira";
2
2
 
3
3
  function App() {
4
4
  console.log("{{addonName}} loaded");
5
5
  }
6
6
 
7
- wuira.Mount(App);
7
+ Wuira.Mount(App);
package/lib/ui/mount.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { Element } from "./primitives/jsx";
2
- import type { Anchor } from "../types/Position";
3
- export declare function unmount(frame: wuiraNativeFrame): void;
4
- /** Creates the tree before resolving anchors. Positive y moves down. */
5
- export declare function mount(element: Element, parent?: wuiraNativeFrame, rootAnchor?: Anchor): wuiraNativeFrame;