@k9kbdev/roblox-css 0.1.0
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/LICENSE +15 -0
- package/README.md +245 -0
- package/default.project.json +6 -0
- package/out/index.d.ts +35 -0
- package/out/init.luau +57 -0
- package/out/logger.d.ts +23 -0
- package/out/logger.luau +73 -0
- package/out/primitives/Box.d.ts +23 -0
- package/out/primitives/Box.luau +103 -0
- package/out/primitives/Button.d.ts +62 -0
- package/out/primitives/Button.luau +170 -0
- package/out/primitives/Image.d.ts +37 -0
- package/out/primitives/Image.luau +79 -0
- package/out/primitives/InlineText.d.ts +25 -0
- package/out/primitives/InlineText.luau +273 -0
- package/out/primitives/Input.d.ts +59 -0
- package/out/primitives/Input.luau +126 -0
- package/out/primitives/MotionBox.d.ts +15 -0
- package/out/primitives/MotionBox.luau +69 -0
- package/out/primitives/MotionButton.d.ts +15 -0
- package/out/primitives/MotionButton.luau +146 -0
- package/out/primitives/MotionImage.d.ts +13 -0
- package/out/primitives/MotionImage.luau +70 -0
- package/out/primitives/MotionText.d.ts +12 -0
- package/out/primitives/MotionText.luau +116 -0
- package/out/primitives/MotionUIScale.d.ts +9 -0
- package/out/primitives/MotionUIScale.luau +48 -0
- package/out/primitives/ScrollBox.d.ts +25 -0
- package/out/primitives/ScrollBox.luau +69 -0
- package/out/primitives/Text.d.ts +50 -0
- package/out/primitives/Text.luau +139 -0
- package/out/primitives/usePercentageConstraints.d.ts +3 -0
- package/out/primitives/usePercentageConstraints.luau +112 -0
- package/out/primitives/useVariantResolver.d.ts +13 -0
- package/out/primitives/useVariantResolver.luau +260 -0
- package/out/styles/CSSTypes.d.ts +96 -0
- package/out/styles/ParentSizeContext.d.ts +6 -0
- package/out/styles/ParentSizeContext.luau +13 -0
- package/out/styles/colorParser.d.ts +28 -0
- package/out/styles/colorParser.luau +229 -0
- package/out/styles/dimensionParser.d.ts +49 -0
- package/out/styles/dimensionParser.luau +205 -0
- package/out/styles/gradientParser.d.ts +9 -0
- package/out/styles/gradientParser.luau +434 -0
- package/out/styles/namedColors.d.ts +7 -0
- package/out/styles/namedColors.luau +162 -0
- package/out/styles/transitions.d.ts +18 -0
- package/out/styles/transitions.luau +19 -0
- package/out/styles/webStyle.d.ts +74 -0
- package/out/styles/webStyle.luau +973 -0
- package/out/types.d.ts +4 -0
- package/out/types.luau +3 -0
- package/out/utils/parseInlineImages.d.ts +20 -0
- package/out/utils/parseInlineImages.luau +93 -0
- package/package.json +56 -0
package/out/types.d.ts
ADDED
package/out/types.luau
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parseInlineImages.ts — Parses <img> tags from text strings into structured segments.
|
|
3
|
+
*
|
|
4
|
+
* Roblox's built-in RichText does NOT support inline images. This parser extracts
|
|
5
|
+
* standard HTML-style `<img src="..." width="N" height="N" />` tags so the InlineText
|
|
6
|
+
* component can render them as separate Image elements.
|
|
7
|
+
*/
|
|
8
|
+
export interface TextSegment {
|
|
9
|
+
readonly type: "text";
|
|
10
|
+
readonly content: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ImageSegment {
|
|
13
|
+
readonly type: "image";
|
|
14
|
+
readonly src: string;
|
|
15
|
+
readonly width: number;
|
|
16
|
+
readonly height: number;
|
|
17
|
+
}
|
|
18
|
+
export type InlineSegment = TextSegment | ImageSegment;
|
|
19
|
+
export declare function parseInlineImages(input: string): InlineSegment[];
|
|
20
|
+
export declare function containsRichTextTags(text: string): boolean;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
--[[
|
|
3
|
+
*
|
|
4
|
+
* parseInlineImages.ts — Parses <img> tags from text strings into structured segments.
|
|
5
|
+
*
|
|
6
|
+
* Roblox's built-in RichText does NOT support inline images. This parser extracts
|
|
7
|
+
* standard HTML-style `<img src="..." width="N" height="N" />` tags so the InlineText
|
|
8
|
+
* component can render them as separate Image elements.
|
|
9
|
+
|
|
10
|
+
]]
|
|
11
|
+
local IMG_PATTERN = '<img%s+src="([^"]*)"%s+width="(%d+)"%s+height="(%d+)"%s*/?>'
|
|
12
|
+
local function parseInlineImages(input)
|
|
13
|
+
local segments = {}
|
|
14
|
+
local searchStart = 1
|
|
15
|
+
while true do
|
|
16
|
+
local matchStart, matchEnd, src, widthStr, heightStr = string.find(input, IMG_PATTERN, searchStart)
|
|
17
|
+
if matchStart == nil or matchEnd == nil then
|
|
18
|
+
local remaining = string.sub(input, searchStart)
|
|
19
|
+
if remaining ~= "" then
|
|
20
|
+
local _arg0 = {
|
|
21
|
+
type = "text",
|
|
22
|
+
content = remaining,
|
|
23
|
+
}
|
|
24
|
+
table.insert(segments, _arg0)
|
|
25
|
+
end
|
|
26
|
+
break
|
|
27
|
+
end
|
|
28
|
+
if matchStart > searchStart then
|
|
29
|
+
local before = string.sub(input, searchStart, matchStart - 1)
|
|
30
|
+
if before ~= "" then
|
|
31
|
+
local _arg0 = {
|
|
32
|
+
type = "text",
|
|
33
|
+
content = before,
|
|
34
|
+
}
|
|
35
|
+
table.insert(segments, _arg0)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
local _object = {
|
|
39
|
+
type = "image",
|
|
40
|
+
src = tostring(src),
|
|
41
|
+
}
|
|
42
|
+
local _left = "width"
|
|
43
|
+
local _condition = tonumber(widthStr)
|
|
44
|
+
if _condition == nil then
|
|
45
|
+
_condition = 20
|
|
46
|
+
end
|
|
47
|
+
_object[_left] = _condition
|
|
48
|
+
local _left_1 = "height"
|
|
49
|
+
local _condition_1 = tonumber(heightStr)
|
|
50
|
+
if _condition_1 == nil then
|
|
51
|
+
_condition_1 = 20
|
|
52
|
+
end
|
|
53
|
+
_object[_left_1] = _condition_1
|
|
54
|
+
table.insert(segments, _object)
|
|
55
|
+
searchStart = matchEnd + 1
|
|
56
|
+
end
|
|
57
|
+
if #segments == 0 then
|
|
58
|
+
local _arg0 = {
|
|
59
|
+
type = "text",
|
|
60
|
+
content = input,
|
|
61
|
+
}
|
|
62
|
+
table.insert(segments, _arg0)
|
|
63
|
+
end
|
|
64
|
+
return segments
|
|
65
|
+
end
|
|
66
|
+
local RICH_TEXT_TAG_PATTERN = "</?[biusBIUS]>"
|
|
67
|
+
local function containsRichTextTags(text)
|
|
68
|
+
local simple = string.find(text, RICH_TEXT_TAG_PATTERN)
|
|
69
|
+
if simple ~= nil then
|
|
70
|
+
return true
|
|
71
|
+
end
|
|
72
|
+
local font = string.find(text, "<font%s")
|
|
73
|
+
if font ~= nil then
|
|
74
|
+
return true
|
|
75
|
+
end
|
|
76
|
+
local stroke = string.find(text, "<stroke%s")
|
|
77
|
+
if stroke ~= nil then
|
|
78
|
+
return true
|
|
79
|
+
end
|
|
80
|
+
local sc = string.find(text, "<sc>")
|
|
81
|
+
if sc ~= nil then
|
|
82
|
+
return true
|
|
83
|
+
end
|
|
84
|
+
local br = string.find(text, "<br%s*/?>")
|
|
85
|
+
if br ~= nil then
|
|
86
|
+
return true
|
|
87
|
+
end
|
|
88
|
+
return false
|
|
89
|
+
end
|
|
90
|
+
return {
|
|
91
|
+
parseInlineImages = parseInlineImages,
|
|
92
|
+
containsRichTextTags = containsRichTextTags,
|
|
93
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@k9kbdev/roblox-css",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CSS-to-Roblox UI translation middleware — write web-style props, get native Roblox primitives",
|
|
5
|
+
"main": "out/init.lua",
|
|
6
|
+
"files": [
|
|
7
|
+
"out",
|
|
8
|
+
"default.project.json"
|
|
9
|
+
],
|
|
10
|
+
"types": "out/index.d.ts",
|
|
11
|
+
"license": "LGPL-3.0-only",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "rbxtsc --type package",
|
|
14
|
+
"prepack": "mv out/tests .out-tests || true; mv COPYING .COPYING || true; mv COPYING.LESSER .COPYING.LESSER || true",
|
|
15
|
+
"postpack": "mv .out-tests out/tests || true; mv .COPYING COPYING || true; mv .COPYING.LESSER COPYING.LESSER || true"
|
|
16
|
+
},
|
|
17
|
+
"author": "Kaleb Kougl",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/Kaleb-kougl/roblox-css.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"roblox",
|
|
24
|
+
"roblox-ts",
|
|
25
|
+
"rbxts",
|
|
26
|
+
"css",
|
|
27
|
+
"ui",
|
|
28
|
+
"react",
|
|
29
|
+
"middleware"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@rbxts/react": ">=17.0.0",
|
|
33
|
+
"@rbxts/ripple": ">=0.8.0",
|
|
34
|
+
"@rbxts/services": "*"
|
|
35
|
+
},
|
|
36
|
+
"peerDependenciesMeta": {
|
|
37
|
+
"@rbxts/ripple": {
|
|
38
|
+
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"@rbxts/services": {
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@rbxts/compiler-types": "^3.0.0-types.0",
|
|
46
|
+
"@rbxts/react": "17.3.7-ts.1",
|
|
47
|
+
"@rbxts/react-roblox": "17.3.7-ts.1",
|
|
48
|
+
"@rbxts/ripple": "^0.8.0",
|
|
49
|
+
"@rbxts/services": "^1.6.0",
|
|
50
|
+
"@rbxts/types": "^1.0.914",
|
|
51
|
+
"@rbxts/jest": "^3.16.0-ts.1",
|
|
52
|
+
"@rbxts/jest-globals": "^3.16.0-ts.1",
|
|
53
|
+
"roblox-ts": "^3.0.0",
|
|
54
|
+
"typescript": "^5.5.3"
|
|
55
|
+
}
|
|
56
|
+
}
|