|
@@ -2547,7 +2547,9 @@ class StatefulComponent(BaseComponent):
|
|
return [var_name]
|
|
return [var_name]
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
- def _get_deps_from_event_trigger(event: EventChain | EventSpec | Var) -> set[str]:
|
|
|
|
|
|
+ def _get_deps_from_event_trigger(
|
|
|
|
+ event: EventChain | EventSpec | Var,
|
|
|
|
+ ) -> dict[str, None]:
|
|
"""Get the dependencies accessed by event triggers.
|
|
"""Get the dependencies accessed by event triggers.
|
|
|
|
|
|
Args:
|
|
Args:
|
|
@@ -2557,7 +2559,7 @@ class StatefulComponent(BaseComponent):
|
|
The dependencies accessed by the event triggers.
|
|
The dependencies accessed by the event triggers.
|
|
"""
|
|
"""
|
|
events: list = [event]
|
|
events: list = [event]
|
|
- deps = set()
|
|
|
|
|
|
+ deps = {}
|
|
|
|
|
|
if isinstance(event, EventChain):
|
|
if isinstance(event, EventChain):
|
|
events.extend(event.events)
|
|
events.extend(event.events)
|
|
@@ -2568,7 +2570,7 @@ class StatefulComponent(BaseComponent):
|
|
for a in arg:
|
|
for a in arg:
|
|
var_datas = VarData.merge(a._get_all_var_data())
|
|
var_datas = VarData.merge(a._get_all_var_data())
|
|
if var_datas and var_datas.deps is not None:
|
|
if var_datas and var_datas.deps is not None:
|
|
- deps |= {str(dep) for dep in var_datas.deps}
|
|
|
|
|
|
+ deps |= {str(dep): None for dep in var_datas.deps}
|
|
return deps
|
|
return deps
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
@@ -2785,27 +2787,23 @@ def empty_component() -> Component:
|
|
return Bare.create("")
|
|
return Bare.create("")
|
|
|
|
|
|
|
|
|
|
-def render_dict_to_var(tag: dict | Component | str, imported_names: set[str]) -> Var:
|
|
|
|
|
|
+def render_dict_to_var(tag: dict | Component | str) -> Var:
|
|
"""Convert a render dict to a Var.
|
|
"""Convert a render dict to a Var.
|
|
|
|
|
|
Args:
|
|
Args:
|
|
tag: The render dict.
|
|
tag: The render dict.
|
|
- imported_names: The names of the imported components.
|
|
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
The Var.
|
|
The Var.
|
|
"""
|
|
"""
|
|
if not isinstance(tag, dict):
|
|
if not isinstance(tag, dict):
|
|
if isinstance(tag, Component):
|
|
if isinstance(tag, Component):
|
|
- return render_dict_to_var(tag.render(), imported_names)
|
|
|
|
|
|
+ return render_dict_to_var(tag.render())
|
|
return Var.create(tag)
|
|
return Var.create(tag)
|
|
|
|
|
|
if "iterable" in tag:
|
|
if "iterable" in tag:
|
|
function_return = LiteralArrayVar.create(
|
|
function_return = LiteralArrayVar.create(
|
|
- [
|
|
|
|
- render_dict_to_var(child.render(), imported_names)
|
|
|
|
- for child in tag["children"]
|
|
|
|
- ]
|
|
|
|
|
|
+ [render_dict_to_var(child.render()) for child in tag["children"]]
|
|
)
|
|
)
|
|
|
|
|
|
func = ArgsFunctionOperation.create(
|
|
func = ArgsFunctionOperation.create(
|
|
@@ -2823,7 +2821,7 @@ def render_dict_to_var(tag: dict | Component | str, imported_names: set[str]) ->
|
|
if tag["name"] == "match":
|
|
if tag["name"] == "match":
|
|
element = tag["cond"]
|
|
element = tag["cond"]
|
|
|
|
|
|
- conditionals = render_dict_to_var(tag["default"], imported_names)
|
|
|
|
|
|
+ conditionals = render_dict_to_var(tag["default"])
|
|
|
|
|
|
for case in tag["match_cases"][::-1]:
|
|
for case in tag["match_cases"][::-1]:
|
|
condition = case[0].to_string() == element.to_string()
|
|
condition = case[0].to_string() == element.to_string()
|
|
@@ -2832,7 +2830,7 @@ def render_dict_to_var(tag: dict | Component | str, imported_names: set[str]) ->
|
|
|
|
|
|
conditionals = ternary_operation(
|
|
conditionals = ternary_operation(
|
|
condition,
|
|
condition,
|
|
- render_dict_to_var(case[-1], imported_names),
|
|
|
|
|
|
+ render_dict_to_var(case[-1]),
|
|
conditionals,
|
|
conditionals,
|
|
)
|
|
)
|
|
|
|
|
|
@@ -2841,8 +2839,8 @@ def render_dict_to_var(tag: dict | Component | str, imported_names: set[str]) ->
|
|
if "cond" in tag:
|
|
if "cond" in tag:
|
|
return ternary_operation(
|
|
return ternary_operation(
|
|
tag["cond"],
|
|
tag["cond"],
|
|
- render_dict_to_var(tag["true_value"], imported_names),
|
|
|
|
- render_dict_to_var(tag["false_value"], imported_names)
|
|
|
|
|
|
+ render_dict_to_var(tag["true_value"]),
|
|
|
|
+ render_dict_to_var(tag["false_value"])
|
|
if tag["false_value"] is not None
|
|
if tag["false_value"] is not None
|
|
else LiteralNoneVar.create(),
|
|
else LiteralNoneVar.create(),
|
|
)
|
|
)
|
|
@@ -2860,7 +2858,7 @@ def render_dict_to_var(tag: dict | Component | str, imported_names: set[str]) ->
|
|
tag_name,
|
|
tag_name,
|
|
props,
|
|
props,
|
|
*([Var(contents)] if contents is not None else []),
|
|
*([Var(contents)] if contents is not None else []),
|
|
- *[render_dict_to_var(child, imported_names) for child in tag["children"]],
|
|
|
|
|
|
+ *[render_dict_to_var(child) for child in tag["children"]],
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
@@ -2881,13 +2879,7 @@ class LiteralComponentVar(CachedVarOperation, LiteralVar, ComponentVar):
|
|
Returns:
|
|
Returns:
|
|
The name of the var.
|
|
The name of the var.
|
|
"""
|
|
"""
|
|
- var_data = self._get_all_var_data()
|
|
|
|
- if var_data is not None:
|
|
|
|
- # flatten imports
|
|
|
|
- imported_names = {j.alias or j.name for i in var_data.imports for j in i[1]}
|
|
|
|
- else:
|
|
|
|
- imported_names = set()
|
|
|
|
- return str(render_dict_to_var(self._var_value.render(), imported_names))
|
|
|
|
|
|
+ return str(render_dict_to_var(self._var_value.render()))
|
|
|
|
|
|
@cached_property_no_lock
|
|
@cached_property_no_lock
|
|
def _cached_get_all_var_data(self) -> VarData | None:
|
|
def _cached_get_all_var_data(self) -> VarData | None:
|