mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
setup wally instance types release
This commit is contained in:
parent
f7dac3f63a
commit
a5d6ae91ac
5 changed files with 2340 additions and 208 deletions
300
scripts/dump_types.py
Normal file
300
scripts/dump_types.py
Normal file
|
|
@ -0,0 +1,300 @@
|
||||||
|
import requests
|
||||||
|
|
||||||
|
enable_formatting = True
|
||||||
|
new_line = ";"
|
||||||
|
next_entry = ";"
|
||||||
|
new_line_not_required = ""
|
||||||
|
indent = ""
|
||||||
|
space = ""
|
||||||
|
|
||||||
|
if enable_formatting:
|
||||||
|
new_line = "\n"
|
||||||
|
new_line_not_required = "\n"
|
||||||
|
space = " "
|
||||||
|
next_entry = ",\n"
|
||||||
|
indent = "\t"
|
||||||
|
|
||||||
|
compile_for_all_classes = False
|
||||||
|
desired_classes = [
|
||||||
|
"CanvasGroup",
|
||||||
|
"Frame",
|
||||||
|
"ImageButton",
|
||||||
|
"TextButton",
|
||||||
|
"ImageLabel",
|
||||||
|
"TextLabel",
|
||||||
|
"ScrollingFrame",
|
||||||
|
"TextBox",
|
||||||
|
"VideoFrame",
|
||||||
|
"ViewportFrame",
|
||||||
|
"BillboardGui",
|
||||||
|
"ScreenGui",
|
||||||
|
"AdGui",
|
||||||
|
"SurfaceGui",
|
||||||
|
"SelectionBox",
|
||||||
|
"BoxHandleAdornment",
|
||||||
|
"ConeHandleAdornment",
|
||||||
|
"CylinderHandleAdornment",
|
||||||
|
"ImageHandleAdornment",
|
||||||
|
"LineHandleAdornment",
|
||||||
|
"SphereHandleAdornment",
|
||||||
|
"WireframeHandleAdornment",
|
||||||
|
"ParabolaAdornment",
|
||||||
|
"SelectionSphere",
|
||||||
|
"ArcHandles",
|
||||||
|
"Handles",
|
||||||
|
"SurfaceSelection",
|
||||||
|
"Path2D",
|
||||||
|
"UIAspectRatioConstraint",
|
||||||
|
"UISizeConstraint",
|
||||||
|
"UITextSizeConstraint",
|
||||||
|
"UICorner",
|
||||||
|
"UIDragDetector",
|
||||||
|
"UIFlexItem",
|
||||||
|
"UIGradient",
|
||||||
|
"UIListLayout",
|
||||||
|
"UIGridLayout",
|
||||||
|
"UIPageLayout",
|
||||||
|
"UITableLayout",
|
||||||
|
"UIPadding",
|
||||||
|
"UIScale",
|
||||||
|
"UIStroke",
|
||||||
|
|
||||||
|
"WorldModel",
|
||||||
|
"Camera",
|
||||||
|
"Part",
|
||||||
|
"Model",
|
||||||
|
"MeshPart",
|
||||||
|
"Highlight"
|
||||||
|
]
|
||||||
|
|
||||||
|
lines_before = [
|
||||||
|
"type p<T> ="+space+"T?|()->T",
|
||||||
|
"type e<T=()->()> ="+space+"T?",
|
||||||
|
"type a={priority:"+space+"number,"+space+"callback:"+space+"(Instance)"+space+"->"+space+"()}",
|
||||||
|
"type recursive<T>=T|{recursive<T>}"
|
||||||
|
"type c<T> =a|T|Recursive<Instance>|()->Recursive<Instance>",
|
||||||
|
"type ContentId = string", # temporary
|
||||||
|
"type Dictionary = {[string]: any}",
|
||||||
|
"type Array = {any}"
|
||||||
|
]
|
||||||
|
|
||||||
|
lines_after = [
|
||||||
|
"return{}"
|
||||||
|
]
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
API_DUMP_LINK = "https://raw.githubusercontent.com/MaximumADHD/Roblox-Client-Tracker/roblox/API-Dump.json"
|
||||||
|
CORRECTIONS_LINK = "https://raw.githubusercontent.com/NightrainsRbx/RobloxLsp/master/server/api/Corrections.json"
|
||||||
|
|
||||||
|
api_dump_request = requests.get(API_DUMP_LINK)
|
||||||
|
corrections_dump_request = requests.get(CORRECTIONS_LINK)
|
||||||
|
|
||||||
|
api_dump = api_dump_request.json()
|
||||||
|
corrections_dump = corrections_dump_request.json()
|
||||||
|
|
||||||
|
aliases = {
|
||||||
|
"int64": "number",
|
||||||
|
"int": "number",
|
||||||
|
"float": "number",
|
||||||
|
"double": "number",
|
||||||
|
"bool": "boolean",
|
||||||
|
"Content": "string",
|
||||||
|
"string": "string"+space+"|"+space+"number",
|
||||||
|
"OptionalCoordinateFrame": "CFrame?",
|
||||||
|
"BinaryString": "string",
|
||||||
|
}
|
||||||
|
|
||||||
|
map_corrections = {}
|
||||||
|
map_roblox_classes = {}
|
||||||
|
|
||||||
|
for roblox_class in api_dump["Classes"]:
|
||||||
|
map_roblox_classes[roblox_class["Name"]] = roblox_class
|
||||||
|
|
||||||
|
for correction_class in corrections_dump["Classes"]:
|
||||||
|
map_corrections[correction_class["Name"]] = correction_class
|
||||||
|
|
||||||
|
def get_prop_type(value_type):
|
||||||
|
|
||||||
|
prop = ""
|
||||||
|
|
||||||
|
match value_type["Category"]:
|
||||||
|
case "Enum":
|
||||||
|
prop = "Enum." + value_type["Name"]
|
||||||
|
case "Class":
|
||||||
|
prop = value_type["Name"] + "?"
|
||||||
|
case "Primitive":
|
||||||
|
value_name = value_type["Name"]
|
||||||
|
prop = aliases.get(value_name) or value_name
|
||||||
|
case "DataType":
|
||||||
|
value_name = value_type["Name"]
|
||||||
|
prop = aliases.get(value_name) or value_name
|
||||||
|
case "Group":
|
||||||
|
prop = value_type["Name"]
|
||||||
|
|
||||||
|
# Map value types
|
||||||
|
|
||||||
|
return prop
|
||||||
|
|
||||||
|
def append_class(roblox_class):
|
||||||
|
#lines.append("\t-- " + roblox_class["Name"])
|
||||||
|
correction_class = map_corrections.get(roblox_class["Name"]) or {"Members": []}
|
||||||
|
correction_members_map = {}
|
||||||
|
|
||||||
|
for member in correction_class["Members"]:
|
||||||
|
correction_members_map[member["Name"]] = member
|
||||||
|
|
||||||
|
for member in roblox_class["Members"]:
|
||||||
|
if (member.get("Tags") and "ReadOnly" in member["Tags"]) == True: continue
|
||||||
|
if (member.get("Tags") and "Deprecated" in member["Tags"]) == True: continue
|
||||||
|
if (member.get("Tags") and "NotScriptable" in member["Tags"]) == True: continue
|
||||||
|
|
||||||
|
# We check if it's a property and if it is, run the get_prop_type function.
|
||||||
|
if member["MemberType"] == "Property":
|
||||||
|
if member["Security"]["Write"] != "None": continue
|
||||||
|
|
||||||
|
if "Deprecated" in member: continue
|
||||||
|
|
||||||
|
lines.append(indent+member["Name"] + ":"+space+"p<" + get_prop_type(member["ValueType"]) + ">"+next_entry)
|
||||||
|
elif member["MemberType"] == "Event":
|
||||||
|
if member["Security"] != "None": continue
|
||||||
|
|
||||||
|
correction_member = correction_members_map.get(member["Name"]) or {"Parameters": []}
|
||||||
|
|
||||||
|
correction_parameters_map = {}
|
||||||
|
for parameter in correction_member["Parameters"]:
|
||||||
|
correction_parameters_map[parameter["Name"]] = parameter
|
||||||
|
|
||||||
|
line = indent+member["Name"] + ":"+space+"e<("
|
||||||
|
is_first = True
|
||||||
|
for parameter in member["Parameters"]:
|
||||||
|
|
||||||
|
correction_parameter = correction_parameters_map.get(parameter["Name"])
|
||||||
|
|
||||||
|
if is_first == False:
|
||||||
|
line += ","
|
||||||
|
is_first = False
|
||||||
|
|
||||||
|
|
||||||
|
if correction_parameter == None:
|
||||||
|
value = get_prop_type(parameter["Type"])
|
||||||
|
if value == "Tuple":
|
||||||
|
line += "...any"
|
||||||
|
else:
|
||||||
|
line += parameter["Name"] + ":" + value
|
||||||
|
else:
|
||||||
|
line += parameter["Name"] + ":"
|
||||||
|
name = correction_parameter["Type"].get("Name")
|
||||||
|
generic = correction_parameter["Type"].get("Generic")
|
||||||
|
|
||||||
|
if name != None:
|
||||||
|
line += name
|
||||||
|
elif generic != None:
|
||||||
|
line += "{" + generic + "}"
|
||||||
|
|
||||||
|
line += ")"+space+"->"+space+"()>"+next_entry
|
||||||
|
lines.append(line)
|
||||||
|
|
||||||
|
if roblox_class["Superclass"] != "<<<ROOT>>>":
|
||||||
|
append_class(map_roblox_classes[roblox_class["Superclass"]])
|
||||||
|
|
||||||
|
if compile_for_all_classes:
|
||||||
|
desired_classes = map_roblox_classes
|
||||||
|
|
||||||
|
for class_name in desired_classes:
|
||||||
|
|
||||||
|
roblox_class = map_roblox_classes[class_name]
|
||||||
|
|
||||||
|
if 'Tags' in roblox_class and "NotCreatable" in roblox_class['Tags']:
|
||||||
|
continue
|
||||||
|
name = roblox_class['Name']
|
||||||
|
lines.append("export type v" + name + space + "="+space+"{"+new_line_not_required)
|
||||||
|
append_class(roblox_class)
|
||||||
|
lines.append(indent+"[number]:"+space+"c<v"+name+">"+new_line)
|
||||||
|
lines.append(new_line_not_required+"}"+new_line)
|
||||||
|
|
||||||
|
with open("src/roblox_types.luau", "wt") as file:
|
||||||
|
|
||||||
|
single_line = new_line.join(lines_before) + new_line + ''.join(lines) + new_line.join(lines_after)
|
||||||
|
file.write(single_line)
|
||||||
|
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
with open("src/create.luau", "r") as reader:
|
||||||
|
line_create_at = 0
|
||||||
|
is_found = False
|
||||||
|
lines = reader.readlines()
|
||||||
|
for line in lines:
|
||||||
|
line_create_at += 1
|
||||||
|
if line.find("return (create") != -1:
|
||||||
|
is_found = True
|
||||||
|
break
|
||||||
|
|
||||||
|
# We found the line we can start modifying from
|
||||||
|
|
||||||
|
with open("src/create.luau", "w") as writer:
|
||||||
|
|
||||||
|
# First write all the lines from 0 to line_create_at-1
|
||||||
|
#lines = reader.readlines(100)
|
||||||
|
writer.writelines(lines[:line_create_at])
|
||||||
|
iterate_through = desired_classes
|
||||||
|
first = True
|
||||||
|
|
||||||
|
if compile_for_all_classes:
|
||||||
|
iterate_through = map_roblox_classes
|
||||||
|
|
||||||
|
for name in iterate_through:
|
||||||
|
roblox_class = map_roblox_classes[name]
|
||||||
|
# Skip unnecessary classes
|
||||||
|
if "Tags" in roblox_class and "NotCreatable"in roblox_class["Tags"]: continue
|
||||||
|
if first:
|
||||||
|
first = False
|
||||||
|
else:
|
||||||
|
writer.write("&")
|
||||||
|
writer.write(f'\t( (class: "{name}") -> (r.v{name}) -> {name} )\n')
|
||||||
|
|
||||||
|
|
||||||
|
writer.close()
|
||||||
|
pass
|
||||||
|
|
||||||
|
reader.close()
|
||||||
|
|
||||||
|
with open("src/init.luau", "r") as reader:
|
||||||
|
line_create_at = 0
|
||||||
|
is_found = False
|
||||||
|
lines = reader.readlines()
|
||||||
|
for line in lines:
|
||||||
|
line_create_at += 1
|
||||||
|
if line.find("-- TYPES HERE") != -1:
|
||||||
|
is_found = True
|
||||||
|
break
|
||||||
|
|
||||||
|
# We found the line we can start modifying from
|
||||||
|
|
||||||
|
with open("src/init.luau", "w") as writer:
|
||||||
|
|
||||||
|
# First write all the lines from 0 to line_create_at-1
|
||||||
|
#lines = reader.readlines(100)
|
||||||
|
writer.writelines(lines[:line_create_at])
|
||||||
|
lines_after = lines[line_create_at+1:]
|
||||||
|
|
||||||
|
iterate_through = desired_classes
|
||||||
|
first = True
|
||||||
|
|
||||||
|
if compile_for_all_classes:
|
||||||
|
iterate_through = map_roblox_classes
|
||||||
|
|
||||||
|
for name in iterate_through:
|
||||||
|
roblox_class = map_roblox_classes[name]
|
||||||
|
# Skip unnecessary classes
|
||||||
|
if "Tags" in roblox_class and "NotCreatable"in roblox_class["Tags"]: continue
|
||||||
|
if first:
|
||||||
|
first = False
|
||||||
|
writer.write(f'export type v{name} = roblox_types.v{name}\n')
|
||||||
|
|
||||||
|
|
||||||
|
writer.writelines(lines_after)
|
||||||
|
writer.close()
|
||||||
|
pass
|
||||||
|
|
||||||
|
reader.close()
|
||||||
188
src/create.luau
188
src/create.luau
|
|
@ -1,84 +1,104 @@
|
||||||
if not game then script = require "test/relative-string" end
|
if not game then script = require "test/relative-string" end
|
||||||
local typeof = game and typeof or require "test/mock".typeof:: never
|
local typeof = game and typeof or require "test/mock".typeof:: never
|
||||||
local Instance = game and Instance or require "test/mock".Instance :: never
|
local Instance = game and Instance or require "test/mock".Instance :: never
|
||||||
|
|
||||||
local throw = require(script.Parent.throw)
|
local throw = require(script.Parent.throw)
|
||||||
local defaults = require(script.Parent.defaults)
|
local defaults = require(script.Parent.defaults)
|
||||||
local apply = require(script.Parent.apply)
|
local apply = require(script.Parent.apply)
|
||||||
|
local r = require(script.Parent.roblox_types)
|
||||||
local ctor_cache = {} :: { [string]: () -> Instance }
|
|
||||||
|
local ctor_cache = {} :: { [string]: () -> Instance }
|
||||||
setmetatable(ctor_cache :: any, {
|
|
||||||
__index = function(self, class)
|
setmetatable(ctor_cache :: any, {
|
||||||
local ok, instance: Instance = pcall(Instance.new, class :: any)
|
__index = function(self, class)
|
||||||
if not ok then throw(`invalid class name, could not create instance of class { class }`) end
|
local ok, instance: Instance = pcall(Instance.new, class :: any)
|
||||||
|
if not ok then throw(`invalid class name, could not create instance of class { class }`) end
|
||||||
local default: { [string]: unknown }? = defaults[class]
|
|
||||||
if default then
|
local default: { [string]: unknown }? = defaults[class]
|
||||||
for i, v in next, default do
|
if default then
|
||||||
(instance :: any)[i] = v
|
for i, v in next, default do
|
||||||
end
|
(instance :: any)[i] = v
|
||||||
end
|
end
|
||||||
|
end
|
||||||
local function ctor(properties: Props): Instance
|
|
||||||
return apply(instance:Clone(), properties)
|
local function ctor(properties: Props): Instance
|
||||||
end
|
return apply(instance:Clone(), properties)
|
||||||
|
end
|
||||||
self[class] = ctor
|
|
||||||
return ctor
|
self[class] = ctor
|
||||||
end
|
return ctor
|
||||||
})
|
end
|
||||||
|
})
|
||||||
local function create_instance(class: string)
|
|
||||||
return ctor_cache[class]
|
local function create_instance(class: string)
|
||||||
end
|
return ctor_cache[class]
|
||||||
|
end
|
||||||
local function clone_instance(instance: Instance)
|
|
||||||
return function(properties: Props): Instance
|
local function clone_instance(instance: Instance)
|
||||||
local clone = instance:Clone()
|
return function(properties: Props): Instance
|
||||||
if not clone then throw "attempt to clone a non-archivable instance" end
|
local clone = instance:Clone()
|
||||||
return apply(clone, properties)
|
if not clone then throw "attempt to clone a non-archivable instance" end
|
||||||
end
|
return apply(clone, properties)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
local function create(class_or_instance: string|Instance): (Props) -> Instance
|
|
||||||
if type(class_or_instance) == "string" then
|
local function create(class_or_instance: string|Instance): (Props) -> Instance
|
||||||
return create_instance(class_or_instance)
|
if type(class_or_instance) == "string" then
|
||||||
elseif typeof(class_or_instance) == "Instance" then
|
return create_instance(class_or_instance)
|
||||||
return clone_instance(class_or_instance)
|
elseif typeof(class_or_instance) == "Instance" then
|
||||||
else
|
return clone_instance(class_or_instance)
|
||||||
throw("bad argument #1, expected string or instance, got " .. typeof(class_or_instance))
|
else
|
||||||
return nil :: never
|
throw("bad argument #1, expected string or instance, got " .. typeof(class_or_instance))
|
||||||
end
|
return nil :: never
|
||||||
end
|
end
|
||||||
|
end
|
||||||
type Props = { [any]: any }
|
|
||||||
return (create :: any) ::
|
type Props = { [any]: any }
|
||||||
( <T>(T & Instance) -> (Props) -> T ) &
|
return (create :: any) ::
|
||||||
( ("Folder") -> (Props) -> Folder ) &
|
( (class: "CanvasGroup") -> (r.vCanvasGroup) -> CanvasGroup )
|
||||||
( ("BillboardGui") -> (Props) -> BillboardGui ) &
|
& ( (class: "Frame") -> (r.vFrame) -> Frame )
|
||||||
( ("CanvasGroup") -> (Props) -> CanvasGroup ) &
|
& ( (class: "ImageButton") -> (r.vImageButton) -> ImageButton )
|
||||||
( ("Frame") -> (Props) -> Frame ) &
|
& ( (class: "TextButton") -> (r.vTextButton) -> TextButton )
|
||||||
( ("ImageButton") -> (Props) -> ImageButton ) &
|
& ( (class: "ImageLabel") -> (r.vImageLabel) -> ImageLabel )
|
||||||
( ("ImageLabel") -> (Props) -> ImageLabel ) &
|
& ( (class: "TextLabel") -> (r.vTextLabel) -> TextLabel )
|
||||||
( ("ScreenGui") -> (Props) -> ScreenGui ) &
|
& ( (class: "ScrollingFrame") -> (r.vScrollingFrame) -> ScrollingFrame )
|
||||||
( ("ScrollingFrame") -> (Props) -> ScrollingFrame ) &
|
& ( (class: "TextBox") -> (r.vTextBox) -> TextBox )
|
||||||
( ("SurfaceGui") -> (Props) -> SurfaceGui ) &
|
& ( (class: "VideoFrame") -> (r.vVideoFrame) -> VideoFrame )
|
||||||
( ("TextBox") -> (Props) -> TextBox ) &
|
& ( (class: "ViewportFrame") -> (r.vViewportFrame) -> ViewportFrame )
|
||||||
( ("TextButton") -> (Props) -> TextButton ) &
|
& ( (class: "BillboardGui") -> (r.vBillboardGui) -> BillboardGui )
|
||||||
( ("TextLabel") -> (Props) -> TextLabel ) &
|
& ( (class: "ScreenGui") -> (r.vScreenGui) -> ScreenGui )
|
||||||
( ("UIAspectRatioConstraint") -> (Props) -> UIAspectRatioConstraint ) &
|
& ( (class: "AdGui") -> (r.vAdGui) -> AdGui )
|
||||||
( ("UICorner") -> (Props) -> UICorner ) &
|
& ( (class: "SurfaceGui") -> (r.vSurfaceGui) -> SurfaceGui )
|
||||||
( ("UIGradient") -> (Props) -> UIGradient ) &
|
& ( (class: "SelectionBox") -> (r.vSelectionBox) -> SelectionBox )
|
||||||
( ("UIGridLayout") -> (Props) -> UIGridLayout ) &
|
& ( (class: "BoxHandleAdornment") -> (r.vBoxHandleAdornment) -> BoxHandleAdornment )
|
||||||
( ("UIListLayout") -> (Props) -> UIListLayout ) &
|
& ( (class: "ConeHandleAdornment") -> (r.vConeHandleAdornment) -> ConeHandleAdornment )
|
||||||
( ("UIPadding") -> (Props) -> UIPadding ) &
|
& ( (class: "CylinderHandleAdornment") -> (r.vCylinderHandleAdornment) -> CylinderHandleAdornment )
|
||||||
( ("UIPageLayout") -> (Props) -> UIPageLayout ) &
|
& ( (class: "ImageHandleAdornment") -> (r.vImageHandleAdornment) -> ImageHandleAdornment )
|
||||||
( ("UIScale") -> (Props) -> UIScale ) &
|
& ( (class: "LineHandleAdornment") -> (r.vLineHandleAdornment) -> LineHandleAdornment )
|
||||||
( ("UISizeConstraint") -> (Props) -> UISizeConstraint ) &
|
& ( (class: "SphereHandleAdornment") -> (r.vSphereHandleAdornment) -> SphereHandleAdornment )
|
||||||
( ("UIStroke") -> (Props) -> UIStroke ) &
|
& ( (class: "WireframeHandleAdornment") -> (r.vWireframeHandleAdornment) -> WireframeHandleAdornment )
|
||||||
( ("UITableLayout") -> (Props) -> UITableLayout ) &
|
& ( (class: "ParabolaAdornment") -> (r.vParabolaAdornment) -> ParabolaAdornment )
|
||||||
( ("UITextSizeConstraint") -> (Props) -> UITextSizeConstraint ) &
|
& ( (class: "SelectionSphere") -> (r.vSelectionSphere) -> SelectionSphere )
|
||||||
( ("VideoFrame") -> (Props) -> VideoFrame ) &
|
& ( (class: "ArcHandles") -> (r.vArcHandles) -> ArcHandles )
|
||||||
( ("ViewportFrame") -> (Props) -> ViewportFrame ) &
|
& ( (class: "Handles") -> (r.vHandles) -> Handles )
|
||||||
( (string) -> (Props) -> Instance )
|
& ( (class: "SurfaceSelection") -> (r.vSurfaceSelection) -> SurfaceSelection )
|
||||||
|
& ( (class: "Path2D") -> (r.vPath2D) -> Path2D )
|
||||||
|
& ( (class: "UIAspectRatioConstraint") -> (r.vUIAspectRatioConstraint) -> UIAspectRatioConstraint )
|
||||||
|
& ( (class: "UISizeConstraint") -> (r.vUISizeConstraint) -> UISizeConstraint )
|
||||||
|
& ( (class: "UITextSizeConstraint") -> (r.vUITextSizeConstraint) -> UITextSizeConstraint )
|
||||||
|
& ( (class: "UICorner") -> (r.vUICorner) -> UICorner )
|
||||||
|
& ( (class: "UIDragDetector") -> (r.vUIDragDetector) -> UIDragDetector )
|
||||||
|
& ( (class: "UIFlexItem") -> (r.vUIFlexItem) -> UIFlexItem )
|
||||||
|
& ( (class: "UIGradient") -> (r.vUIGradient) -> UIGradient )
|
||||||
|
& ( (class: "UIListLayout") -> (r.vUIListLayout) -> UIListLayout )
|
||||||
|
& ( (class: "UIGridLayout") -> (r.vUIGridLayout) -> UIGridLayout )
|
||||||
|
& ( (class: "UIPageLayout") -> (r.vUIPageLayout) -> UIPageLayout )
|
||||||
|
& ( (class: "UITableLayout") -> (r.vUITableLayout) -> UITableLayout )
|
||||||
|
& ( (class: "UIPadding") -> (r.vUIPadding) -> UIPadding )
|
||||||
|
& ( (class: "UIScale") -> (r.vUIScale) -> UIScale )
|
||||||
|
& ( (class: "UIStroke") -> (r.vUIStroke) -> UIStroke )
|
||||||
|
& ( (class: "WorldModel") -> (r.vWorldModel) -> WorldModel )
|
||||||
|
& ( (class: "Camera") -> (r.vCamera) -> Camera )
|
||||||
|
& ( (class: "Part") -> (r.vPart) -> Part )
|
||||||
|
& ( (class: "Model") -> (r.vModel) -> Model )
|
||||||
|
& ( (class: "MeshPart") -> (r.vMeshPart) -> MeshPart )
|
||||||
|
|
|
||||||
289
src/init.luau
289
src/init.luau
|
|
@ -1,121 +1,168 @@
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- vide.luau
|
-- vide.luau
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
local version = { major = 0, minor = 3, patch = 1 }
|
local version = { major = 0, minor = 3, patch = 1 }
|
||||||
|
|
||||||
if not game then script = require "test/relative-string" end
|
if not game then script = require "test/relative-string" end
|
||||||
|
|
||||||
local root = require(script.root)
|
local root = require(script.root)
|
||||||
local mount = require(script.mount)
|
local mount = require(script.mount)
|
||||||
local create = require(script.create)
|
local create = require(script.create)
|
||||||
local apply = require(script.apply)
|
local apply = require(script.apply)
|
||||||
local source = require(script.source)
|
local source = require(script.source)
|
||||||
local effect = require(script.effect)
|
local effect = require(script.effect)
|
||||||
local derive = require(script.derive)
|
local derive = require(script.derive)
|
||||||
local cleanup = require(script.cleanup)
|
local cleanup = require(script.cleanup)
|
||||||
local untrack = require(script.untrack)
|
local untrack = require(script.untrack)
|
||||||
local read = require(script.read)
|
local read = require(script.read)
|
||||||
local batch = require(script.batch)
|
local batch = require(script.batch)
|
||||||
local context = require(script.context)
|
local context = require(script.context)
|
||||||
local switch = require(script.switch)
|
local switch = require(script.switch)
|
||||||
local show = require(script.show)
|
local show = require(script.show)
|
||||||
local indexes, values = require(script.maps)()
|
local indexes, values = require(script.maps)()
|
||||||
local spring, update_springs = require(script.spring)()
|
local spring, update_springs = require(script.spring)()
|
||||||
local action = require(script.action)()
|
local action = require(script.action)()
|
||||||
local changed = require(script.changed)
|
local changed = require(script.changed)
|
||||||
local throw = require(script.throw)
|
local throw = require(script.throw)
|
||||||
local flags = require(script.flags)
|
local flags = require(script.flags)
|
||||||
|
|
||||||
export type Source<T> = source.Source<T>
|
export type Source<T> = source.Source<T>
|
||||||
export type source<T> = Source<T>
|
export type source<T> = Source<T>
|
||||||
export type Context<T> = context.Context<T>
|
export type Context<T> = context.Context<T>
|
||||||
export type context<T> = Context<T>
|
export type context<T> = Context<T>
|
||||||
|
|
||||||
local function step(dt: number)
|
local function step(dt: number)
|
||||||
if game then
|
if game then
|
||||||
debug.profilebegin("VIDE STEP")
|
debug.profilebegin("VIDE STEP")
|
||||||
debug.profilebegin("VIDE SPRING")
|
debug.profilebegin("VIDE SPRING")
|
||||||
end
|
end
|
||||||
|
|
||||||
update_springs(dt)
|
update_springs(dt)
|
||||||
|
|
||||||
if game then
|
if game then
|
||||||
debug.profileend()
|
debug.profileend()
|
||||||
debug.profileend()
|
debug.profileend()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local stepped = game and game:GetService("RunService").Heartbeat:Connect(function(dt: number)
|
local stepped = game and game:GetService("RunService").Heartbeat:Connect(function(dt: number)
|
||||||
task.defer(step, dt)
|
task.defer(step, dt)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local vide = {
|
local vide = {
|
||||||
version = version,
|
version = version,
|
||||||
|
|
||||||
-- core
|
-- core
|
||||||
root = root,
|
root = root,
|
||||||
mount = mount,
|
mount = mount,
|
||||||
create = create,
|
create = create,
|
||||||
source = source,
|
source = source,
|
||||||
effect = effect,
|
effect = effect,
|
||||||
derive = derive,
|
derive = derive,
|
||||||
switch = switch,
|
switch = switch,
|
||||||
show = show,
|
show = show,
|
||||||
indexes = indexes,
|
indexes = indexes,
|
||||||
values = values,
|
values = values,
|
||||||
|
|
||||||
-- util
|
-- util
|
||||||
cleanup = cleanup,
|
cleanup = cleanup,
|
||||||
untrack = untrack,
|
untrack = untrack,
|
||||||
read = read,
|
read = read,
|
||||||
batch = batch,
|
batch = batch,
|
||||||
context = context,
|
context = context,
|
||||||
|
|
||||||
-- animations
|
-- animations
|
||||||
spring = spring,
|
spring = spring,
|
||||||
|
|
||||||
-- actions
|
-- actions
|
||||||
action = action,
|
action = action,
|
||||||
changed = changed,
|
changed = changed,
|
||||||
|
|
||||||
-- flags
|
-- flags
|
||||||
strict = (nil :: any) :: boolean,
|
strict = (nil :: any) :: boolean,
|
||||||
|
|
||||||
-- temporary
|
-- temporary
|
||||||
apply = function(instance: Instance)
|
apply = function(instance: Instance)
|
||||||
return function(props: { [any]: any })
|
return function(props: { [any]: any })
|
||||||
apply(instance, props)
|
apply(instance, props)
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- runtime
|
-- runtime
|
||||||
step = function(dt: number)
|
step = function(dt: number)
|
||||||
if stepped then
|
if stepped then
|
||||||
stepped:Disconnect()
|
stepped:Disconnect()
|
||||||
stepped = nil
|
stepped = nil
|
||||||
end
|
end
|
||||||
step(dt)
|
step(dt)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
setmetatable(vide :: any, {
|
setmetatable(vide :: any, {
|
||||||
__index = function(_, index: unknown): ()
|
__index = function(_, index: unknown): ()
|
||||||
if index == "strict" then
|
if index == "strict" then
|
||||||
return flags.strict
|
return flags.strict
|
||||||
else
|
else
|
||||||
throw(`{tostring(index)} is not a valid member of vide`)
|
throw(`{tostring(index)} is not a valid member of vide`)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
__newindex = function(_, index: unknown, value: unknown)
|
__newindex = function(_, index: unknown, value: unknown)
|
||||||
if index == "strict" then
|
if index == "strict" then
|
||||||
flags.strict = value :: boolean
|
flags.strict = value :: boolean
|
||||||
else
|
else
|
||||||
throw(`{tostring(index)} is not a valid member of vide`)
|
throw(`{tostring(index)} is not a valid member of vide`)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
return vide
|
return vide
|
||||||
|
export type vCanvasGroup = roblox_types.vCanvasGroup
|
||||||
|
export type vFrame = roblox_types.vFrame
|
||||||
|
export type vImageButton = roblox_types.vImageButton
|
||||||
|
export type vTextButton = roblox_types.vTextButton
|
||||||
|
export type vImageLabel = roblox_types.vImageLabel
|
||||||
|
export type vTextLabel = roblox_types.vTextLabel
|
||||||
|
export type vScrollingFrame = roblox_types.vScrollingFrame
|
||||||
|
export type vTextBox = roblox_types.vTextBox
|
||||||
|
export type vVideoFrame = roblox_types.vVideoFrame
|
||||||
|
export type vViewportFrame = roblox_types.vViewportFrame
|
||||||
|
export type vBillboardGui = roblox_types.vBillboardGui
|
||||||
|
export type vScreenGui = roblox_types.vScreenGui
|
||||||
|
export type vAdGui = roblox_types.vAdGui
|
||||||
|
export type vSurfaceGui = roblox_types.vSurfaceGui
|
||||||
|
export type vSelectionBox = roblox_types.vSelectionBox
|
||||||
|
export type vBoxHandleAdornment = roblox_types.vBoxHandleAdornment
|
||||||
|
export type vConeHandleAdornment = roblox_types.vConeHandleAdornment
|
||||||
|
export type vCylinderHandleAdornment = roblox_types.vCylinderHandleAdornment
|
||||||
|
export type vImageHandleAdornment = roblox_types.vImageHandleAdornment
|
||||||
|
export type vLineHandleAdornment = roblox_types.vLineHandleAdornment
|
||||||
|
export type vSphereHandleAdornment = roblox_types.vSphereHandleAdornment
|
||||||
|
export type vWireframeHandleAdornment = roblox_types.vWireframeHandleAdornment
|
||||||
|
export type vParabolaAdornment = roblox_types.vParabolaAdornment
|
||||||
|
export type vSelectionSphere = roblox_types.vSelectionSphere
|
||||||
|
export type vArcHandles = roblox_types.vArcHandles
|
||||||
|
export type vHandles = roblox_types.vHandles
|
||||||
|
export type vSurfaceSelection = roblox_types.vSurfaceSelection
|
||||||
|
export type vPath2D = roblox_types.vPath2D
|
||||||
|
export type vUIAspectRatioConstraint = roblox_types.vUIAspectRatioConstraint
|
||||||
|
export type vUISizeConstraint = roblox_types.vUISizeConstraint
|
||||||
|
export type vUITextSizeConstraint = roblox_types.vUITextSizeConstraint
|
||||||
|
export type vUICorner = roblox_types.vUICorner
|
||||||
|
export type vUIDragDetector = roblox_types.vUIDragDetector
|
||||||
|
export type vUIFlexItem = roblox_types.vUIFlexItem
|
||||||
|
export type vUIGradient = roblox_types.vUIGradient
|
||||||
|
export type vUIListLayout = roblox_types.vUIListLayout
|
||||||
|
export type vUIGridLayout = roblox_types.vUIGridLayout
|
||||||
|
export type vUIPageLayout = roblox_types.vUIPageLayout
|
||||||
|
export type vUITableLayout = roblox_types.vUITableLayout
|
||||||
|
export type vUIPadding = roblox_types.vUIPadding
|
||||||
|
export type vUIScale = roblox_types.vUIScale
|
||||||
|
export type vUIStroke = roblox_types.vUIStroke
|
||||||
|
export type vWorldModel = roblox_types.vWorldModel
|
||||||
|
export type vCamera = roblox_types.vCamera
|
||||||
|
export type vPart = roblox_types.vPart
|
||||||
|
export type vModel = roblox_types.vModel
|
||||||
|
export type vMeshPart = roblox_types.vMeshPart
|
||||||
|
|
|
||||||
1765
src/roblox_types.luau
Normal file
1765
src/roblox_types.luau
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,8 +1,8 @@
|
||||||
[package]
|
[package]
|
||||||
name = "centau/vide"
|
name = "alicesaidhi/vide"
|
||||||
description = "A reactive Luau library for creating UI. "
|
description = "Fork of vide, comes with Roblox Instance Types"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
version = "0.3.1"
|
version = "0.3.1-lite.646"
|
||||||
registry = "https://github.com/UpliftGames/wally-index"
|
registry = "https://github.com/UpliftGames/wally-index"
|
||||||
realm = "shared"
|
realm = "shared"
|
||||||
include = ["default.project.json", "LICENSE", "src"]
|
include = ["default.project.json", "LICENSE", "src"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue