@snailycfx/stylesheet 1.0.13 → 1.0.14
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/out/core/engine/init.luau +1 -7
- package/out/core/writer/init.luau +59 -36
- package/out/provider/index.d.ts +0 -12
- package/out/provider/index.d.ts.map +1 -1
- package/out/provider/init.luau +25 -30
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ function runLayoutImmediate(node)
|
|
|
50
50
|
layoutNode(node, absSize.X, absSize.Y)
|
|
51
51
|
end
|
|
52
52
|
-- ── Layout recursivo ──────────────────────────────────────────────────────────
|
|
53
|
-
local computeBlockLayout, writeLayout
|
|
53
|
+
local computeBlockLayout, writeLayout
|
|
54
54
|
function layoutNode(node, containerWidth, containerHeight)
|
|
55
55
|
if not node.layoutDirty then
|
|
56
56
|
return nil
|
|
@@ -103,7 +103,6 @@ function layoutNode(node, containerWidth, containerHeight)
|
|
|
103
103
|
child.computedY = abs.y
|
|
104
104
|
child.computedWidth = abs.width
|
|
105
105
|
child.computedHeight = abs.height
|
|
106
|
-
reparentIfNeeded(child, abs.containingBlock)
|
|
107
106
|
writeLayout(child.instance, abs.x, abs.y, abs.width, abs.height)
|
|
108
107
|
if sizeChanged then
|
|
109
108
|
child.layoutDirty = true
|
|
@@ -141,11 +140,6 @@ function writeLayout(instance, x, y, w, h)
|
|
|
141
140
|
instance.Position = UDim2.new(0, x, 0, y)
|
|
142
141
|
instance.Size = UDim2.new(0, w, 0, h)
|
|
143
142
|
end
|
|
144
|
-
function reparentIfNeeded(node, containingBlock)
|
|
145
|
-
if node.instance.Parent ~= containingBlock.instance then
|
|
146
|
-
node.instance.Parent = containingBlock.instance
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
143
|
exports.setEngineRoot = setEngineRoot
|
|
150
144
|
exports.getEngineRoot = getEngineRoot
|
|
151
145
|
exports.runLayout = runLayout
|
|
@@ -213,16 +213,39 @@ function writeText(instance, style, prev)
|
|
|
213
213
|
return nil
|
|
214
214
|
end
|
|
215
215
|
local text = instance
|
|
216
|
+
-- Defaults CSS: left + top cuando no se especifica
|
|
217
|
+
local _condition = style.textAlign == nil
|
|
218
|
+
if _condition then
|
|
219
|
+
local _result = prev
|
|
220
|
+
if _result ~= nil then
|
|
221
|
+
_result = _result.textAlign
|
|
222
|
+
end
|
|
223
|
+
_condition = _result == nil
|
|
224
|
+
end
|
|
225
|
+
if _condition then
|
|
226
|
+
text.TextXAlignment = Enum.TextXAlignment.Left
|
|
227
|
+
end
|
|
228
|
+
local _condition_1 = style.verticalAlign == nil
|
|
229
|
+
if _condition_1 then
|
|
230
|
+
local _result = prev
|
|
231
|
+
if _result ~= nil then
|
|
232
|
+
_result = _result.verticalAlign
|
|
233
|
+
end
|
|
234
|
+
_condition_1 = _result == nil
|
|
235
|
+
end
|
|
236
|
+
if _condition_1 then
|
|
237
|
+
text.TextYAlignment = Enum.TextYAlignment.Top
|
|
238
|
+
end
|
|
216
239
|
local _exp = style.color
|
|
217
240
|
local _result = prev
|
|
218
241
|
if _result ~= nil then
|
|
219
242
|
_result = _result.color
|
|
220
243
|
end
|
|
221
|
-
local
|
|
222
|
-
if
|
|
223
|
-
|
|
244
|
+
local _condition_2 = _exp ~= _result
|
|
245
|
+
if _condition_2 then
|
|
246
|
+
_condition_2 = style.color ~= nil
|
|
224
247
|
end
|
|
225
|
-
if
|
|
248
|
+
if _condition_2 then
|
|
226
249
|
text.TextColor3 = parseColor(style.color)
|
|
227
250
|
end
|
|
228
251
|
local _exp_1 = style.fontSize
|
|
@@ -230,11 +253,11 @@ function writeText(instance, style, prev)
|
|
|
230
253
|
if _result_1 ~= nil then
|
|
231
254
|
_result_1 = _result_1.fontSize
|
|
232
255
|
end
|
|
233
|
-
local
|
|
234
|
-
if
|
|
235
|
-
|
|
256
|
+
local _condition_3 = _exp_1 ~= _result_1
|
|
257
|
+
if _condition_3 then
|
|
258
|
+
_condition_3 = style.fontSize ~= nil
|
|
236
259
|
end
|
|
237
|
-
if
|
|
260
|
+
if _condition_3 then
|
|
238
261
|
text.TextSize = style.fontSize
|
|
239
262
|
end
|
|
240
263
|
local _exp_2 = style.fontFamily
|
|
@@ -242,11 +265,11 @@ function writeText(instance, style, prev)
|
|
|
242
265
|
if _result_2 ~= nil then
|
|
243
266
|
_result_2 = _result_2.fontFamily
|
|
244
267
|
end
|
|
245
|
-
local
|
|
246
|
-
if
|
|
247
|
-
|
|
268
|
+
local _condition_4 = _exp_2 ~= _result_2
|
|
269
|
+
if _condition_4 then
|
|
270
|
+
_condition_4 = style.fontFamily ~= nil
|
|
248
271
|
end
|
|
249
|
-
if
|
|
272
|
+
if _condition_4 then
|
|
250
273
|
text.Font = style.fontFamily
|
|
251
274
|
end
|
|
252
275
|
local _exp_3 = style.textTransparency
|
|
@@ -254,11 +277,11 @@ function writeText(instance, style, prev)
|
|
|
254
277
|
if _result_3 ~= nil then
|
|
255
278
|
_result_3 = _result_3.textTransparency
|
|
256
279
|
end
|
|
257
|
-
local
|
|
258
|
-
if
|
|
259
|
-
|
|
280
|
+
local _condition_5 = _exp_3 ~= _result_3
|
|
281
|
+
if _condition_5 then
|
|
282
|
+
_condition_5 = style.textTransparency ~= nil
|
|
260
283
|
end
|
|
261
|
-
if
|
|
284
|
+
if _condition_5 then
|
|
262
285
|
text.TextTransparency = style.textTransparency
|
|
263
286
|
end
|
|
264
287
|
local _exp_4 = style.textScaled
|
|
@@ -266,11 +289,11 @@ function writeText(instance, style, prev)
|
|
|
266
289
|
if _result_4 ~= nil then
|
|
267
290
|
_result_4 = _result_4.textScaled
|
|
268
291
|
end
|
|
269
|
-
local
|
|
270
|
-
if
|
|
271
|
-
|
|
292
|
+
local _condition_6 = _exp_4 ~= _result_4
|
|
293
|
+
if _condition_6 then
|
|
294
|
+
_condition_6 = style.textScaled ~= nil
|
|
272
295
|
end
|
|
273
|
-
if
|
|
296
|
+
if _condition_6 then
|
|
274
297
|
text.TextScaled = style.textScaled
|
|
275
298
|
end
|
|
276
299
|
local _exp_5 = style.textWrapped
|
|
@@ -278,11 +301,11 @@ function writeText(instance, style, prev)
|
|
|
278
301
|
if _result_5 ~= nil then
|
|
279
302
|
_result_5 = _result_5.textWrapped
|
|
280
303
|
end
|
|
281
|
-
local
|
|
282
|
-
if
|
|
283
|
-
|
|
304
|
+
local _condition_7 = _exp_5 ~= _result_5
|
|
305
|
+
if _condition_7 then
|
|
306
|
+
_condition_7 = style.textWrapped ~= nil
|
|
284
307
|
end
|
|
285
|
-
if
|
|
308
|
+
if _condition_7 then
|
|
286
309
|
text.TextWrapped = style.textWrapped
|
|
287
310
|
end
|
|
288
311
|
local _exp_6 = style.lineHeight
|
|
@@ -290,11 +313,11 @@ function writeText(instance, style, prev)
|
|
|
290
313
|
if _result_6 ~= nil then
|
|
291
314
|
_result_6 = _result_6.lineHeight
|
|
292
315
|
end
|
|
293
|
-
local
|
|
294
|
-
if
|
|
295
|
-
|
|
316
|
+
local _condition_8 = _exp_6 ~= _result_6
|
|
317
|
+
if _condition_8 then
|
|
318
|
+
_condition_8 = style.lineHeight ~= nil
|
|
296
319
|
end
|
|
297
|
-
if
|
|
320
|
+
if _condition_8 then
|
|
298
321
|
text.LineHeight = style.lineHeight
|
|
299
322
|
end
|
|
300
323
|
local _exp_7 = style.textAlign
|
|
@@ -302,11 +325,11 @@ function writeText(instance, style, prev)
|
|
|
302
325
|
if _result_7 ~= nil then
|
|
303
326
|
_result_7 = _result_7.textAlign
|
|
304
327
|
end
|
|
305
|
-
local
|
|
306
|
-
if
|
|
307
|
-
|
|
328
|
+
local _condition_9 = _exp_7 ~= _result_7
|
|
329
|
+
if _condition_9 then
|
|
330
|
+
_condition_9 = style.textAlign ~= nil
|
|
308
331
|
end
|
|
309
|
-
if
|
|
332
|
+
if _condition_9 then
|
|
310
333
|
text.TextXAlignment = TEXT_X[style.textAlign] or Enum.TextXAlignment.Left
|
|
311
334
|
end
|
|
312
335
|
local _exp_8 = style.verticalAlign
|
|
@@ -314,11 +337,11 @@ function writeText(instance, style, prev)
|
|
|
314
337
|
if _result_8 ~= nil then
|
|
315
338
|
_result_8 = _result_8.verticalAlign
|
|
316
339
|
end
|
|
317
|
-
local
|
|
318
|
-
if
|
|
319
|
-
|
|
340
|
+
local _condition_10 = _exp_8 ~= _result_8
|
|
341
|
+
if _condition_10 then
|
|
342
|
+
_condition_10 = style.verticalAlign ~= nil
|
|
320
343
|
end
|
|
321
|
-
if
|
|
344
|
+
if _condition_10 then
|
|
322
345
|
text.TextYAlignment = TEXT_Y[style.verticalAlign] or Enum.TextYAlignment.Center
|
|
323
346
|
end
|
|
324
347
|
end
|
package/out/provider/index.d.ts
CHANGED
|
@@ -5,18 +5,6 @@ interface StyleSheetProviderProps {
|
|
|
5
5
|
target: Frame;
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
* Raíz del engine de layout. Debe envolver toda la UI.
|
|
10
|
-
* Crea un Frame invisible que ocupa el 100% del target
|
|
11
|
-
* y actúa como el "body" del que cuelgan todos los elementos.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* export = (target: Frame) => {
|
|
15
|
-
* const root = createRoot(target)
|
|
16
|
-
* root.render(<StyleSheetProvider target={target}><App /></StyleSheetProvider>)
|
|
17
|
-
* return () => root.unmount()
|
|
18
|
-
* }
|
|
19
|
-
*/
|
|
20
8
|
export declare function StyleSheetProvider(props: StyleSheetProviderProps): React.ReactElement;
|
|
21
9
|
export {};
|
|
22
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,cAAc,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAGzC,eAAO,MAAM,WAAW,uCAAyD,CAAA;AAEjF,UAAU,uBAAuB;IAChC,MAAM,EAAE,KAAK,CAAA;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,KAAK,CAAC,YAAY,CA8DrF"}
|
package/out/provider/init.luau
CHANGED
|
@@ -4,55 +4,50 @@ local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
|
4
4
|
local React = _react
|
|
5
5
|
local useEffect = _react.useEffect
|
|
6
6
|
local useRef = _react.useRef
|
|
7
|
+
local useState = _react.useState
|
|
7
8
|
local _core = TS.import(script, script.Parent, "core")
|
|
8
|
-
local createNode = _core.createNode
|
|
9
9
|
local setEngineRoot = _core.setEngineRoot
|
|
10
10
|
local runLayoutImmediate = _core.runLayoutImmediate
|
|
11
|
-
-- ── Context ───────────────────────────────────────────────────────────────────
|
|
12
11
|
local NodeContext = React.createContext(nil)
|
|
13
|
-
-- ── StyleSheetProvider ────────────────────────────────────────────────────────
|
|
14
|
-
--[[
|
|
15
|
-
*
|
|
16
|
-
* Raíz del engine de layout. Debe envolver toda la UI.
|
|
17
|
-
* Crea un Frame invisible que ocupa el 100% del target
|
|
18
|
-
* y actúa como el "body" del que cuelgan todos los elementos.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* export = (target: Frame) => {
|
|
22
|
-
* const root = createRoot(target)
|
|
23
|
-
* root.render(<StyleSheetProvider target={target}><App /></StyleSheetProvider>)
|
|
24
|
-
* return () => root.unmount()
|
|
25
|
-
* }
|
|
26
|
-
|
|
27
|
-
]]
|
|
28
12
|
local function StyleSheetProvider(props)
|
|
29
13
|
local bodyRef = useRef()
|
|
30
|
-
|
|
14
|
+
-- Crear el nodo raíz ANTES del primer render de los hijos
|
|
15
|
+
-- usando useState con initializer para que esté disponible inmediatamente
|
|
16
|
+
local rootNode = useState(function()
|
|
17
|
+
-- Nodo placeholder — la instancia se asigna cuando bodyRef está disponible
|
|
18
|
+
return {
|
|
19
|
+
instance = nil,
|
|
20
|
+
style = {
|
|
21
|
+
display = "flex",
|
|
22
|
+
flexDirection = "column",
|
|
23
|
+
},
|
|
24
|
+
children = {},
|
|
25
|
+
parent = nil,
|
|
26
|
+
computedWidth = props.target.AbsoluteSize.X,
|
|
27
|
+
computedHeight = props.target.AbsoluteSize.Y,
|
|
28
|
+
computedX = 0,
|
|
29
|
+
computedY = 0,
|
|
30
|
+
layoutDirty = true,
|
|
31
|
+
visualDirty = false,
|
|
32
|
+
lastVisualStyle = nil,
|
|
33
|
+
}
|
|
34
|
+
end)
|
|
31
35
|
useEffect(function()
|
|
32
36
|
local body = bodyRef.current
|
|
33
37
|
if not body then
|
|
34
38
|
return nil
|
|
35
39
|
end
|
|
36
|
-
--
|
|
37
|
-
|
|
38
|
-
width = "100%",
|
|
39
|
-
height = "100%",
|
|
40
|
-
display = "flex",
|
|
41
|
-
flexDirection = "column",
|
|
42
|
-
})
|
|
43
|
-
rootNodeRef.current = rootNode
|
|
40
|
+
-- Asignar la instancia real ahora que el Frame existe
|
|
41
|
+
rootNode.instance = body
|
|
44
42
|
setEngineRoot(rootNode)
|
|
45
|
-
-- Ejecutar layout inmediato con el tamaño real del target
|
|
46
43
|
local doLayout = function()
|
|
47
44
|
local size = props.target.AbsoluteSize
|
|
48
|
-
body.Size = UDim2.fromOffset(size.X, size.Y)
|
|
49
45
|
rootNode.computedWidth = size.X
|
|
50
46
|
rootNode.computedHeight = size.Y
|
|
51
47
|
rootNode.layoutDirty = true
|
|
52
48
|
runLayoutImmediate(rootNode)
|
|
53
49
|
end
|
|
54
50
|
doLayout()
|
|
55
|
-
-- Escuchar resize del target — un solo listener para todo el árbol
|
|
56
51
|
local conn = (props.target):GetPropertyChangedSignal("AbsoluteSize"):Connect(doLayout)
|
|
57
52
|
return function()
|
|
58
53
|
conn:Disconnect()
|
|
@@ -60,7 +55,7 @@ local function StyleSheetProvider(props)
|
|
|
60
55
|
end
|
|
61
56
|
end, {})
|
|
62
57
|
return React.createElement(NodeContext.Provider, {
|
|
63
|
-
value =
|
|
58
|
+
value = rootNode,
|
|
64
59
|
}, React.createElement("frame", {
|
|
65
60
|
ref = bodyRef,
|
|
66
61
|
Size = UDim2.fromScale(1, 1),
|