@snailycfx/stylesheet 1.0.12 → 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/index.d.ts +2 -8
- package/out/core/engine/index.d.ts.map +1 -1
- package/out/core/engine/init.luau +27 -59
- package/out/core/index.d.ts +1 -1
- package/out/core/index.d.ts.map +1 -1
- package/out/core/init.luau +3 -0
- package/out/core/parse/udim.d.ts +0 -3
- package/out/core/parse/udim.d.ts.map +1 -1
- package/out/core/parse/udim.luau +40 -19
- package/out/core/writer/init.luau +59 -36
- package/out/elements/index.d.ts.map +1 -1
- package/out/elements/init.luau +6 -24
- package/out/index.d.ts +2 -1
- package/out/index.d.ts.map +1 -1
- package/out/init.luau +3 -1
- package/out/provider/index.d.ts +10 -0
- package/out/provider/index.d.ts.map +1 -0
- package/out/provider/init.luau +69 -0
- package/package.json +1 -1
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import type { LayoutNode } from "./node";
|
|
2
2
|
export { createNode, updateNodeStyle, removeNode, markLayoutDirty, getRoot, findContainingBlockForAbsolute } from "./node";
|
|
3
3
|
export type { LayoutNode } from "./node";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* Llama a esto cuando cambia un estilo o el tamaño de un contenedor.
|
|
7
|
-
*/
|
|
4
|
+
export declare function setEngineRoot(node: LayoutNode): void;
|
|
5
|
+
export declare function getEngineRoot(): LayoutNode | undefined;
|
|
8
6
|
export declare function runLayout(node: LayoutNode): void;
|
|
9
|
-
/**
|
|
10
|
-
* Ejecuta el layout inmediatamente sin esperar al próximo frame.
|
|
11
|
-
* Usar solo cuando necesitas los valores computados de forma síncrona.
|
|
12
|
-
*/
|
|
13
7
|
export declare function runLayoutImmediate(node: LayoutNode): void;
|
|
14
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAOxC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,8BAA8B,EAAE,MAAM,QAAQ,CAAA;AAC1H,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAOxC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,8BAA8B,EAAE,MAAM,QAAQ,CAAA;AAC1H,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAMxC,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAEpD;AAED,wBAAgB,aAAa,IAAI,UAAU,GAAG,SAAS,CAEtD;AAmBD,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAGhD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAIzD"}
|
|
@@ -1,69 +1,46 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local exports = {}
|
|
4
|
-
local
|
|
5
|
-
local getRoot = _node.getRoot
|
|
6
|
-
local markLayoutDirty = _node.markLayoutDirty
|
|
4
|
+
local markLayoutDirty = TS.import(script, script, "node").markLayoutDirty
|
|
7
5
|
local computeFlexLayout = TS.import(script, script, "flex").computeFlexLayout
|
|
8
6
|
local computeGridLayout = TS.import(script, script, "grid").computeGridLayout
|
|
9
7
|
local computeAbsoluteLayout = TS.import(script, script, "absolute").computeAbsoluteLayout
|
|
10
8
|
local resolvePixels = TS.import(script, script.Parent, "parse").resolvePixels
|
|
11
|
-
local
|
|
12
|
-
exports.createNode =
|
|
13
|
-
exports.updateNodeStyle =
|
|
14
|
-
exports.removeNode =
|
|
15
|
-
exports.markLayoutDirty =
|
|
16
|
-
exports.getRoot =
|
|
17
|
-
exports.findContainingBlockForAbsolute =
|
|
9
|
+
local _node = TS.import(script, script, "node")
|
|
10
|
+
exports.createNode = _node.createNode
|
|
11
|
+
exports.updateNodeStyle = _node.updateNodeStyle
|
|
12
|
+
exports.removeNode = _node.removeNode
|
|
13
|
+
exports.markLayoutDirty = _node.markLayoutDirty
|
|
14
|
+
exports.getRoot = _node.getRoot
|
|
15
|
+
exports.findContainingBlockForAbsolute = _node.findContainingBlockForAbsolute
|
|
16
|
+
-- ── Raíz global del engine ────────────────────────────────────────────────────
|
|
17
|
+
local engineRoot
|
|
18
|
+
local function setEngineRoot(node)
|
|
19
|
+
engineRoot = node
|
|
20
|
+
end
|
|
21
|
+
local function getEngineRoot()
|
|
22
|
+
return engineRoot
|
|
23
|
+
end
|
|
18
24
|
-- ── Batching ──────────────────────────────────────────────────────────────────
|
|
19
|
-
-- Acumulamos nodos sucios y ejecutamos un único layout pass por frame
|
|
20
25
|
local scheduled = false
|
|
21
|
-
local pendingRoots = {}
|
|
22
26
|
local runLayoutImmediate
|
|
23
|
-
local function scheduleLayout(
|
|
24
|
-
|
|
25
|
-
pendingRoots[_root] = true
|
|
26
|
-
if scheduled then
|
|
27
|
+
local function scheduleLayout()
|
|
28
|
+
if scheduled or not engineRoot then
|
|
27
29
|
return nil
|
|
28
30
|
end
|
|
29
31
|
scheduled = true
|
|
30
|
-
-- Diferir al siguiente Heartbeat para batching automático
|
|
31
32
|
local RunService = game:GetService("RunService")
|
|
32
|
-
|
|
33
|
+
RunService.Heartbeat:Once(function()
|
|
33
34
|
scheduled = false
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
for _v in pendingRoots do
|
|
37
|
-
_length += 1
|
|
38
|
-
_array[_length] = _v
|
|
39
|
-
end
|
|
40
|
-
local roots = _array
|
|
41
|
-
table.clear(pendingRoots)
|
|
42
|
-
for _, r in roots do
|
|
43
|
-
if r.layoutDirty then
|
|
44
|
-
runLayoutImmediate(r)
|
|
45
|
-
end
|
|
35
|
+
if engineRoot and engineRoot.layoutDirty then
|
|
36
|
+
runLayoutImmediate(engineRoot)
|
|
46
37
|
end
|
|
47
38
|
end)
|
|
48
|
-
local _ = conn
|
|
49
|
-
local _1 = nil
|
|
50
39
|
end
|
|
51
|
-
--[[
|
|
52
|
-
*
|
|
53
|
-
* Marca el nodo como dirty y agenda un layout pass en el próximo frame.
|
|
54
|
-
* Llama a esto cuando cambia un estilo o el tamaño de un contenedor.
|
|
55
|
-
|
|
56
|
-
]]
|
|
57
40
|
local function runLayout(node)
|
|
58
41
|
markLayoutDirty(node)
|
|
59
|
-
scheduleLayout(
|
|
42
|
+
scheduleLayout()
|
|
60
43
|
end
|
|
61
|
-
--[[
|
|
62
|
-
*
|
|
63
|
-
* Ejecuta el layout inmediatamente sin esperar al próximo frame.
|
|
64
|
-
* Usar solo cuando necesitas los valores computados de forma síncrona.
|
|
65
|
-
|
|
66
|
-
]]
|
|
67
44
|
local layoutNode
|
|
68
45
|
function runLayoutImmediate(node)
|
|
69
46
|
if not node.layoutDirty then
|
|
@@ -73,13 +50,12 @@ function runLayoutImmediate(node)
|
|
|
73
50
|
layoutNode(node, absSize.X, absSize.Y)
|
|
74
51
|
end
|
|
75
52
|
-- ── Layout recursivo ──────────────────────────────────────────────────────────
|
|
76
|
-
local computeBlockLayout, writeLayout
|
|
53
|
+
local computeBlockLayout, writeLayout
|
|
77
54
|
function layoutNode(node, containerWidth, containerHeight)
|
|
78
55
|
if not node.layoutDirty then
|
|
79
56
|
return nil
|
|
80
57
|
end
|
|
81
58
|
local style = node.style
|
|
82
|
-
-- Tamaño propio
|
|
83
59
|
node.computedWidth = if style.width ~= nil then resolvePixels(style.width, containerWidth) else containerWidth
|
|
84
60
|
node.computedHeight = if style.height ~= nil then resolvePixels(style.height, containerHeight) else containerHeight
|
|
85
61
|
if #node.children == 0 then
|
|
@@ -87,7 +63,6 @@ function layoutNode(node, containerWidth, containerHeight)
|
|
|
87
63
|
return nil
|
|
88
64
|
end
|
|
89
65
|
local display = style.display
|
|
90
|
-
-- ── Layout de hijos en flujo ───────────────────────────────────────────────
|
|
91
66
|
local childLayouts
|
|
92
67
|
if display == "flex" then
|
|
93
68
|
childLayouts = computeFlexLayout(node, node.computedWidth, node.computedHeight)
|
|
@@ -96,7 +71,7 @@ function layoutNode(node, containerWidth, containerHeight)
|
|
|
96
71
|
else
|
|
97
72
|
childLayouts = computeBlockLayout(node, node.computedWidth, node.computedHeight)
|
|
98
73
|
end
|
|
99
|
-
--
|
|
74
|
+
-- In-flow children
|
|
100
75
|
for i = 0, #node.children - 1 do
|
|
101
76
|
local child = node.children[i + 1]
|
|
102
77
|
if child.style.position == "absolute" then
|
|
@@ -112,13 +87,12 @@ function layoutNode(node, containerWidth, containerHeight)
|
|
|
112
87
|
child.computedWidth = layout.width
|
|
113
88
|
child.computedHeight = layout.height
|
|
114
89
|
writeLayout(child.instance, layout.x, layout.y, layout.width, layout.height)
|
|
115
|
-
-- Solo recalcular hijos si el tamaño cambió
|
|
116
90
|
if sizeChanged then
|
|
117
91
|
child.layoutDirty = true
|
|
118
92
|
end
|
|
119
93
|
layoutNode(child, layout.width, layout.height)
|
|
120
94
|
end
|
|
121
|
-
--
|
|
95
|
+
-- Absolute children
|
|
122
96
|
for _, child in node.children do
|
|
123
97
|
if child.style.position ~= "absolute" then
|
|
124
98
|
continue
|
|
@@ -129,7 +103,6 @@ function layoutNode(node, containerWidth, containerHeight)
|
|
|
129
103
|
child.computedY = abs.y
|
|
130
104
|
child.computedWidth = abs.width
|
|
131
105
|
child.computedHeight = abs.height
|
|
132
|
-
reparentIfNeeded(child, abs.containingBlock)
|
|
133
106
|
writeLayout(child.instance, abs.x, abs.y, abs.width, abs.height)
|
|
134
107
|
if sizeChanged then
|
|
135
108
|
child.layoutDirty = true
|
|
@@ -138,7 +111,6 @@ function layoutNode(node, containerWidth, containerHeight)
|
|
|
138
111
|
end
|
|
139
112
|
node.layoutDirty = false
|
|
140
113
|
end
|
|
141
|
-
-- ── Block layout ──────────────────────────────────────────────────────────────
|
|
142
114
|
function computeBlockLayout(node, containerWidth, containerHeight)
|
|
143
115
|
local yOffset = 0
|
|
144
116
|
local results = {}
|
|
@@ -164,16 +136,12 @@ function computeBlockLayout(node, containerWidth, containerHeight)
|
|
|
164
136
|
end
|
|
165
137
|
return results
|
|
166
138
|
end
|
|
167
|
-
-- ── Helpers ───────────────────────────────────────────────────────────────────
|
|
168
139
|
function writeLayout(instance, x, y, w, h)
|
|
169
140
|
instance.Position = UDim2.new(0, x, 0, y)
|
|
170
141
|
instance.Size = UDim2.new(0, w, 0, h)
|
|
171
142
|
end
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
node.instance.Parent = containingBlock.instance
|
|
175
|
-
end
|
|
176
|
-
end
|
|
143
|
+
exports.setEngineRoot = setEngineRoot
|
|
144
|
+
exports.getEngineRoot = getEngineRoot
|
|
177
145
|
exports.runLayout = runLayout
|
|
178
146
|
exports.runLayoutImmediate = runLayoutImmediate
|
|
179
147
|
return exports
|
package/out/core/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { MiscStyle } from "./types/style/misc";
|
|
|
10
10
|
export { parseColor } from "./parse/color";
|
|
11
11
|
export { parseUDim, parseUDim2, resolvePixels } from "./parse/udim";
|
|
12
12
|
export { parseGridTemplate, resolveTrackSizes } from "./parse/grid";
|
|
13
|
-
export { createNode, updateNodeStyle, removeNode, runLayout, runLayoutImmediate, markLayoutDirty, getRoot } from "./engine";
|
|
13
|
+
export { createNode, updateNodeStyle, removeNode, runLayout, runLayoutImmediate, markLayoutDirty, getRoot, setEngineRoot, getEngineRoot, findContainingBlockForAbsolute } from "./engine";
|
|
14
14
|
export type { LayoutNode } from "./engine";
|
|
15
15
|
export { writeVisual } from "./writer";
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/out/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC1F,YAAY,EAAE,YAAY,EAAE,MAAS,uBAAuB,CAAA;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAY,oBAAoB,CAAA;AACzD,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,YAAY,EAAE,WAAW,EAAE,MAAU,sBAAsB,CAAA;AAC3D,YAAY,EAAE,SAAS,EAAE,MAAY,oBAAoB,CAAA;AACzD,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACnI,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACzE,YAAY,EAAE,SAAS,EAAE,MAAY,oBAAoB,CAAA;AAEzD,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC1F,YAAY,EAAE,YAAY,EAAE,MAAS,uBAAuB,CAAA;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAY,oBAAoB,CAAA;AACzD,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,YAAY,EAAE,WAAW,EAAE,MAAU,sBAAsB,CAAA;AAC3D,YAAY,EAAE,SAAS,EAAE,MAAY,oBAAoB,CAAA;AACzD,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACnI,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACzE,YAAY,EAAE,SAAS,EAAE,MAAY,oBAAoB,CAAA;AAEzD,OAAO,EAAE,UAAU,EAAE,MAA4C,eAAe,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAkB,cAAc,CAAA;AAC/E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAkB,cAAc,CAAA;AAE/E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,8BAA8B,EAAE,MAAM,UAAU,CAAA;AACzL,YAAY,EAAE,UAAU,EAAE,MAAuC,UAAU,CAAA;AAE3E,OAAO,EAAE,WAAW,EAAE,MAA2C,UAAU,CAAA"}
|
package/out/core/init.luau
CHANGED
|
@@ -17,5 +17,8 @@ exports.runLayout = _engine.runLayout
|
|
|
17
17
|
exports.runLayoutImmediate = _engine.runLayoutImmediate
|
|
18
18
|
exports.markLayoutDirty = _engine.markLayoutDirty
|
|
19
19
|
exports.getRoot = _engine.getRoot
|
|
20
|
+
exports.setEngineRoot = _engine.setEngineRoot
|
|
21
|
+
exports.getEngineRoot = _engine.getEngineRoot
|
|
22
|
+
exports.findContainingBlockForAbsolute = _engine.findContainingBlockForAbsolute
|
|
20
23
|
exports.writeVisual = TS.import(script, script, "writer").writeVisual
|
|
21
24
|
return exports
|
package/out/core/parse/udim.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { UDimValue } from "../types";
|
|
2
2
|
export declare function parseUDim(value: UDimValue): UDim;
|
|
3
3
|
export declare function parseUDim2(x: UDimValue, y: UDimValue): UDim2;
|
|
4
|
-
/**
|
|
5
|
-
* Resuelve un UDimValue a píxeles absolutos dado el tamaño del contenedor.
|
|
6
|
-
*/
|
|
7
4
|
export declare function resolvePixels(value: UDimValue, containerSize: number): number;
|
|
8
5
|
//# sourceMappingURL=udim.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"udim.d.ts","sourceRoot":"","sources":["../../../src/core/parse/udim.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"udim.d.ts","sourceRoot":"","sources":["../../../src/core/parse/udim.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAuBzC,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAYhD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,KAAK,CAI5D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAY7E"}
|
package/out/core/parse/udim.luau
CHANGED
|
@@ -1,19 +1,47 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
--[[
|
|
3
|
+
*
|
|
4
|
+
* Extrae scale y offset de strings tipo "50%+16" o "50%-16"
|
|
5
|
+
* usando dos match separados para evitar problemas con LuaTuple.
|
|
6
|
+
|
|
7
|
+
]]
|
|
8
|
+
local function parseMixed(str)
|
|
9
|
+
local scaleStr = (string.match(str, "^(%d+%.?%d*)%%[%+%-]"))
|
|
10
|
+
if scaleStr == nil then
|
|
11
|
+
return nil
|
|
12
|
+
end
|
|
13
|
+
local offsetStr = (string.match(str, "[%+%-](%d+%.?%d*)$"))
|
|
14
|
+
if offsetStr == nil then
|
|
15
|
+
return nil
|
|
16
|
+
end
|
|
17
|
+
local sign = (string.match(str, "%%(%+?%-?)%d"))
|
|
18
|
+
local scale = tonumber(scaleStr) / 100
|
|
19
|
+
local offset = tonumber(offsetStr) * (if sign == "-" then -1 else 1)
|
|
20
|
+
return {
|
|
21
|
+
scale = scale,
|
|
22
|
+
offset = offset,
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
local function parseScaleOnly(str)
|
|
26
|
+
local scaleStr = (string.match(str, "^(%d+%.?%d*)%%$"))
|
|
27
|
+
if scaleStr == nil then
|
|
28
|
+
return nil
|
|
29
|
+
end
|
|
30
|
+
return tonumber(scaleStr) / 100
|
|
31
|
+
end
|
|
2
32
|
local function parseUDim(value)
|
|
3
33
|
local _value = value
|
|
4
34
|
if typeof(_value) == "number" then
|
|
5
35
|
return UDim.new(0, value)
|
|
6
36
|
end
|
|
7
37
|
local str = value
|
|
8
|
-
|
|
9
|
-
local mixed = { string.match(str, "^(%d+%.?%d*)%%([%+%-]%d+%.?%d*)$") }
|
|
38
|
+
local mixed = parseMixed(str)
|
|
10
39
|
if mixed ~= nil then
|
|
11
|
-
return UDim.new(
|
|
40
|
+
return UDim.new(mixed.scale, mixed.offset)
|
|
12
41
|
end
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return UDim.new(tonumber(scaleOnly[1]) / 100, 0)
|
|
42
|
+
local scale = parseScaleOnly(str)
|
|
43
|
+
if scale ~= nil then
|
|
44
|
+
return UDim.new(scale, 0)
|
|
17
45
|
end
|
|
18
46
|
local _condition = tonumber(str)
|
|
19
47
|
if _condition == nil then
|
|
@@ -26,26 +54,19 @@ local function parseUDim2(x, y)
|
|
|
26
54
|
local uy = parseUDim(y)
|
|
27
55
|
return UDim2.new(ux.Scale, ux.Offset, uy.Scale, uy.Offset)
|
|
28
56
|
end
|
|
29
|
-
--[[
|
|
30
|
-
*
|
|
31
|
-
* Resuelve un UDimValue a píxeles absolutos dado el tamaño del contenedor.
|
|
32
|
-
|
|
33
|
-
]]
|
|
34
57
|
local function resolvePixels(value, containerSize)
|
|
35
58
|
local _value = value
|
|
36
59
|
if typeof(_value) == "number" then
|
|
37
60
|
return value
|
|
38
61
|
end
|
|
39
62
|
local str = value
|
|
40
|
-
local mixed =
|
|
63
|
+
local mixed = parseMixed(str)
|
|
41
64
|
if mixed ~= nil then
|
|
42
|
-
|
|
43
|
-
local offset = tonumber(mixed[2])
|
|
44
|
-
return containerSize * scale + offset
|
|
65
|
+
return containerSize * mixed.scale + mixed.offset
|
|
45
66
|
end
|
|
46
|
-
local
|
|
47
|
-
if
|
|
48
|
-
return containerSize *
|
|
67
|
+
local scale = parseScaleOnly(str)
|
|
68
|
+
if scale ~= nil then
|
|
69
|
+
return containerSize * scale
|
|
49
70
|
end
|
|
50
71
|
local _condition = tonumber(str)
|
|
51
72
|
if _condition == nil then
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/elements/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,cAAc,CAAA;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/elements/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,cAAc,CAAA;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,SAAS,CAAA;AAOnD,UAAU,SAAS;IAClB,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,SAAS,CAAC,EAAE,QAAQ,CAAA;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,UAAU,gBAAiB,SAAQ,SAAS;IAC3C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB;AAkFD,wBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,CAAC,YAAY,CAgBxD;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,CAAC,YAAY,CAmBjG;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC,YAAY,CAwBtF;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC,YAAY,CAwB3H;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG;IACxC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,YAAY,CAAC,EAAE,OAAO,CAAA;CACtB,GAAG,KAAK,CAAC,YAAY,CAoBrB;AAED,wBAAgB,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG;IACrC,eAAe,CAAC,EAAE,UAAU,GAAG,YAAY,CAAA;IAC3C,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC3B,GAAG,KAAK,CAAC,YAAY,CA4BrB;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,CAAC,YAAY,CAgB3D;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,CAAC,YAAY,CAmBjH;AAGD,eAAO,MAAM,GAAG,YAAM,CAAA;AACtB,eAAO,MAAM,IAAI,aAAO,CAAA;AACxB,eAAO,MAAM,MAAM,eAAS,CAAA;AAC5B,eAAO,MAAM,GAAG,YAAM,CAAA;AACtB,eAAO,MAAM,KAAK,cAAQ,CAAA;AAC1B,eAAO,MAAM,EAAE,WAAK,CAAA;AACpB,eAAO,MAAM,MAAM,eAAS,CAAA;AAC5B,eAAO,MAAM,KAAK,cAAQ,CAAA"}
|
package/out/elements/init.luau
CHANGED
|
@@ -11,17 +11,14 @@ local updateNodeStyle = _core.updateNodeStyle
|
|
|
11
11
|
local removeNode = _core.removeNode
|
|
12
12
|
local runLayout = _core.runLayout
|
|
13
13
|
local writeVisual = _core.writeVisual
|
|
14
|
-
local getRoot = _core.getRoot
|
|
15
14
|
local StyleSheet = TS.import(script, script.Parent, "stylesheet").StyleSheet
|
|
16
|
-
|
|
17
|
-
local NodeContext = React.createContext(nil)
|
|
15
|
+
local NodeContext = TS.import(script, script.Parent, "provider").NodeContext
|
|
18
16
|
-- ── Tipos ─────────────────────────────────────────────────────────────────────
|
|
19
17
|
-- ── Hook central ──────────────────────────────────────────────────────────────
|
|
20
18
|
local function useLayoutNode(ref, style, className, disabled)
|
|
21
19
|
local parentNode = useContext(NodeContext)
|
|
22
20
|
local nodeRef = useRef()
|
|
23
21
|
local prevStyleRef = useRef()
|
|
24
|
-
-- Fusión de estilos — solo recalcular si alguno de los dos cambió
|
|
25
22
|
local base = StyleSheet:compose(className, style)
|
|
26
23
|
local activeStyle = if disabled and base[":disabled"] then StyleSheet:withPseudo(base, ":disabled") else base
|
|
27
24
|
useEffect(function()
|
|
@@ -29,25 +26,12 @@ local function useLayoutNode(ref, style, className, disabled)
|
|
|
29
26
|
if not instance then
|
|
30
27
|
return nil
|
|
31
28
|
end
|
|
32
|
-
-- Primer montaje — esperar a que la instancia tenga AbsoluteSize real
|
|
33
29
|
local node = createNode(instance, activeStyle, parentNode)
|
|
34
30
|
nodeRef.current = node
|
|
35
31
|
prevStyleRef.current = activeStyle
|
|
36
32
|
writeVisual(instance, activeStyle)
|
|
37
|
-
|
|
38
|
-
local
|
|
39
|
-
local size = instance.AbsoluteSize
|
|
40
|
-
if size.X > 0 or size.Y > 0 then
|
|
41
|
-
runLayout(getRoot(node))
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
doFirstLayout()
|
|
45
|
-
local sizeConn = instance:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
|
|
46
|
-
doFirstLayout()
|
|
47
|
-
runLayout(getRoot(node))
|
|
48
|
-
end)
|
|
49
|
-
-- Pseudo-estado :hover
|
|
50
|
-
local connections = { sizeConn }
|
|
33
|
+
runLayout(node)
|
|
34
|
+
local connections = {}
|
|
51
35
|
if base[":hover"] then
|
|
52
36
|
local hoverStyle = StyleSheet:withPseudo(base, ":hover")
|
|
53
37
|
local _arg0 = instance.MouseEnter:Connect(function()
|
|
@@ -64,7 +48,6 @@ local function useLayoutNode(ref, style, className, disabled)
|
|
|
64
48
|
table.insert(connections, _arg1)
|
|
65
49
|
-- ▲ Array.push ▲
|
|
66
50
|
end
|
|
67
|
-
-- Pseudo-estado :active
|
|
68
51
|
if base[":active"] then
|
|
69
52
|
local activeStateStyle = StyleSheet:withPseudo(base, ":active")
|
|
70
53
|
local btn = instance
|
|
@@ -93,11 +76,10 @@ local function useLayoutNode(ref, style, className, disabled)
|
|
|
93
76
|
-- ▲ ReadonlyArray.forEach ▲
|
|
94
77
|
removeNode(node)
|
|
95
78
|
if parentNode then
|
|
96
|
-
runLayout(
|
|
79
|
+
runLayout(parentNode)
|
|
97
80
|
end
|
|
98
81
|
end
|
|
99
82
|
end, {})
|
|
100
|
-
-- Actualizar estilo cuando cambia
|
|
101
83
|
useEffect(function()
|
|
102
84
|
local node = nodeRef.current
|
|
103
85
|
if not node then
|
|
@@ -110,7 +92,7 @@ local function useLayoutNode(ref, style, className, disabled)
|
|
|
110
92
|
updateNodeStyle(node, activeStyle)
|
|
111
93
|
writeVisual(node.instance, activeStyle, prev)
|
|
112
94
|
prevStyleRef.current = activeStyle
|
|
113
|
-
runLayout(
|
|
95
|
+
runLayout(node)
|
|
114
96
|
end, { activeStyle })
|
|
115
97
|
return nodeRef.current
|
|
116
98
|
end
|
|
@@ -317,7 +299,7 @@ local function video(props)
|
|
|
317
299
|
value = node,
|
|
318
300
|
}, React.createElement("videoframe", _attributes, props.children))
|
|
319
301
|
end
|
|
320
|
-
--
|
|
302
|
+
-- PascalCase aliases para uso como JSX components
|
|
321
303
|
local Div = div
|
|
322
304
|
local Span = span
|
|
323
305
|
local Button = button
|
package/out/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { StyleSheet } from "./stylesheet";
|
|
2
|
+
export { StyleSheetProvider } from "./provider";
|
|
2
3
|
export * as elements from "./elements";
|
|
3
4
|
export type { RbxStyle, RbxStyleBase } from "./core";
|
|
4
5
|
export type { UDimValue, ColorValue, GradientStop } from "./core";
|
|
@@ -6,6 +7,6 @@ export type { SpacingStyle, SizeStyle, BackgroundStyle } from "./core";
|
|
|
6
7
|
export type { BorderStyle, TextStyle } from "./core";
|
|
7
8
|
export type { LayoutStyle, Display, FlexDirection, JustifyContent, AlignItems, AlignContent, FlexWrap } from "./core";
|
|
8
9
|
export type { PositionStyle, PositionType, MiscStyle } from "./core";
|
|
9
|
-
export { writeVisual, runLayout, runLayoutImmediate, markLayoutDirty, getRoot, createNode, updateNodeStyle, removeNode, parseColor, parseUDim, parseUDim2 } from "./core";
|
|
10
|
+
export { writeVisual, runLayout, runLayoutImmediate, markLayoutDirty, getRoot, setEngineRoot, createNode, updateNodeStyle, removeNode, parseColor, parseUDim, parseUDim2 } from "./core";
|
|
10
11
|
export type { LayoutNode } from "./core";
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAiB,cAAc,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAS,YAAY,CAAA;AAClD,OAAO,KAAK,QAAQ,MAAkB,YAAY,CAAA;AAElD,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAA+B,QAAQ,CAAA;AAC7E,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAkB,QAAQ,CAAA;AAC7E,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAa,QAAQ,CAAA;AAC7E,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAA+B,QAAQ,CAAA;AAC7E,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACrH,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAe,QAAQ,CAAA;AAG7E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxL,YAAY,EAAE,UAAU,EAAE,MAA4C,QAAQ,CAAA"}
|
package/out/init.luau
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local exports = {}
|
|
4
4
|
exports.StyleSheet = TS.import(script, script, "stylesheet").StyleSheet
|
|
5
|
+
exports.StyleSheetProvider = TS.import(script, script, "provider").StyleSheetProvider
|
|
5
6
|
exports.elements = TS.import(script, script, "elements")
|
|
6
|
-
-- API avanzada
|
|
7
|
+
-- API avanzada
|
|
7
8
|
local _core = TS.import(script, script, "core")
|
|
8
9
|
exports.writeVisual = _core.writeVisual
|
|
9
10
|
exports.runLayout = _core.runLayout
|
|
10
11
|
exports.runLayoutImmediate = _core.runLayoutImmediate
|
|
11
12
|
exports.markLayoutDirty = _core.markLayoutDirty
|
|
12
13
|
exports.getRoot = _core.getRoot
|
|
14
|
+
exports.setEngineRoot = _core.setEngineRoot
|
|
13
15
|
exports.createNode = _core.createNode
|
|
14
16
|
exports.updateNodeStyle = _core.updateNodeStyle
|
|
15
17
|
exports.removeNode = _core.removeNode
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import type { LayoutNode } from "../core";
|
|
3
|
+
export declare const NodeContext: React.Context<LayoutNode | undefined>;
|
|
4
|
+
interface StyleSheetProviderProps {
|
|
5
|
+
target: Frame;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function StyleSheetProvider(props: StyleSheetProviderProps): React.ReactElement;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local React = _react
|
|
5
|
+
local useEffect = _react.useEffect
|
|
6
|
+
local useRef = _react.useRef
|
|
7
|
+
local useState = _react.useState
|
|
8
|
+
local _core = TS.import(script, script.Parent, "core")
|
|
9
|
+
local setEngineRoot = _core.setEngineRoot
|
|
10
|
+
local runLayoutImmediate = _core.runLayoutImmediate
|
|
11
|
+
local NodeContext = React.createContext(nil)
|
|
12
|
+
local function StyleSheetProvider(props)
|
|
13
|
+
local bodyRef = useRef()
|
|
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)
|
|
35
|
+
useEffect(function()
|
|
36
|
+
local body = bodyRef.current
|
|
37
|
+
if not body then
|
|
38
|
+
return nil
|
|
39
|
+
end
|
|
40
|
+
-- Asignar la instancia real ahora que el Frame existe
|
|
41
|
+
rootNode.instance = body
|
|
42
|
+
setEngineRoot(rootNode)
|
|
43
|
+
local doLayout = function()
|
|
44
|
+
local size = props.target.AbsoluteSize
|
|
45
|
+
rootNode.computedWidth = size.X
|
|
46
|
+
rootNode.computedHeight = size.Y
|
|
47
|
+
rootNode.layoutDirty = true
|
|
48
|
+
runLayoutImmediate(rootNode)
|
|
49
|
+
end
|
|
50
|
+
doLayout()
|
|
51
|
+
local conn = (props.target):GetPropertyChangedSignal("AbsoluteSize"):Connect(doLayout)
|
|
52
|
+
return function()
|
|
53
|
+
conn:Disconnect()
|
|
54
|
+
setEngineRoot(nil)
|
|
55
|
+
end
|
|
56
|
+
end, {})
|
|
57
|
+
return React.createElement(NodeContext.Provider, {
|
|
58
|
+
value = rootNode,
|
|
59
|
+
}, React.createElement("frame", {
|
|
60
|
+
ref = bodyRef,
|
|
61
|
+
Size = UDim2.fromScale(1, 1),
|
|
62
|
+
BackgroundTransparency = 1,
|
|
63
|
+
BorderSizePixel = 0,
|
|
64
|
+
}, props.children))
|
|
65
|
+
end
|
|
66
|
+
return {
|
|
67
|
+
StyleSheetProvider = StyleSheetProvider,
|
|
68
|
+
NodeContext = NodeContext,
|
|
69
|
+
}
|