instaui 0.2.1__py2.py3-none-any.whl → 0.3.0__py2.py3-none-any.whl
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.
- instaui/arco/components/select.py +2 -1
- instaui/components/component.py +3 -1
- instaui/components/container.py +32 -0
- instaui/components/element.py +1 -4
- instaui/components/heading.py +46 -0
- instaui/components/match.py +20 -84
- instaui/components/slot.py +53 -19
- instaui/components/vfor.py +39 -44
- instaui/components/vif.py +10 -22
- instaui/event/js_event.py +10 -8
- instaui/event/vue_event.py +14 -16
- instaui/event/web_event.py +11 -8
- instaui/html_tools.py +8 -2
- instaui/js/fn.py +13 -10
- instaui/runtime/__init__.py +2 -2
- instaui/runtime/_app.py +43 -35
- instaui/runtime/scope.py +117 -33
- instaui/spa_router/_functions.py +4 -4
- instaui/spa_router/_route_model.py +6 -7
- instaui/spa_router/_router_output.py +5 -1
- instaui/spa_router/_router_param_var.py +4 -9
- instaui/static/insta-ui.css +1 -1
- instaui/static/insta-ui.esm-browser.prod.js +2313 -2361
- instaui/static/insta-ui.js.map +1 -1
- instaui/ui/__init__.py +7 -2
- instaui/ui/__init__.pyi +7 -2
- instaui/ui_functions/input_slient_data.py +4 -0
- instaui/ui_system_var_type.py +6 -0
- instaui/vars/_types.py +14 -0
- instaui/vars/data.py +7 -4
- instaui/vars/element_ref.py +13 -10
- instaui/vars/event_context.py +7 -3
- instaui/vars/js_computed.py +4 -4
- instaui/vars/mixin_types/py_binding.py +40 -0
- instaui/vars/path_var.py +7 -0
- instaui/vars/ref.py +7 -2
- instaui/vars/slot_prop.py +22 -14
- instaui/vars/state.py +23 -12
- instaui/vars/vfor_item.py +170 -72
- instaui/vars/vue_computed.py +4 -4
- instaui/vars/web_computed.py +10 -6
- instaui/watch/js_watch.py +6 -6
- instaui/watch/vue_watch.py +25 -2
- instaui/watch/web_watch.py +15 -6
- {instaui-0.2.1.dist-info → instaui-0.3.0.dist-info}/METADATA +1 -1
- {instaui-0.2.1.dist-info → instaui-0.3.0.dist-info}/RECORD +48 -45
- {instaui-0.2.1.dist-info → instaui-0.3.0.dist-info}/WHEEL +0 -0
- {instaui-0.2.1.dist-info → instaui-0.3.0.dist-info}/licenses/LICENSE +0 -0
instaui/vars/vfor_item.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
-
from typing import Dict, Generic, Tuple, TypeVar,
|
3
|
-
from contextlib import contextmanager
|
2
|
+
from typing import Any, Dict, Generic, Tuple, TypeVar, Union, cast
|
4
3
|
|
5
4
|
from instaui.common.jsonable import Jsonable
|
5
|
+
from instaui.runtime._app import get_current_scope
|
6
|
+
from instaui.vars._types import InputBindingType, OutputSetType
|
6
7
|
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
7
8
|
from instaui.vars.mixin_types.py_binding import CanInputMixin, CanOutputMixin
|
8
9
|
from instaui.vars.mixin_types.pathable import CanPathPropMixin
|
@@ -10,8 +11,6 @@ from instaui.vars.mixin_types.str_format_binding import StrFormatBindingMixin
|
|
10
11
|
from instaui.vars.mixin_types.observable import ObservableMixin
|
11
12
|
from instaui.vars.path_var import PathVar
|
12
13
|
|
13
|
-
if TYPE_CHECKING:
|
14
|
-
from instaui.components.vfor import VFor
|
15
14
|
|
16
15
|
_T = TypeVar("_T")
|
17
16
|
|
@@ -33,32 +32,42 @@ class VForItemProxy(
|
|
33
32
|
def __getattr__(self, name: str):
|
34
33
|
return self._vfor_item[name]
|
35
34
|
|
35
|
+
@property
|
36
|
+
def __vfor_item_(self):
|
37
|
+
return super().__getattribute__("_vfor_item")
|
38
|
+
|
36
39
|
def __getitem__(self, name):
|
37
|
-
return
|
40
|
+
return self.__vfor_item_[name]
|
38
41
|
|
39
42
|
def _to_element_binding_config(self) -> Dict:
|
40
|
-
return
|
43
|
+
return self.__vfor_item_._to_element_binding_config()
|
41
44
|
|
42
45
|
def _to_input_config(self):
|
43
|
-
return
|
46
|
+
return self.__vfor_item_._to_input_config()
|
44
47
|
|
45
48
|
def _to_path_prop_binding_config(self) -> Dict:
|
46
|
-
return
|
49
|
+
return self.__vfor_item_._to_path_prop_binding_config()
|
47
50
|
|
48
51
|
def _to_output_config(self):
|
49
|
-
return
|
52
|
+
return self.__vfor_item_._to_output_config()
|
50
53
|
|
51
54
|
def _to_str_format_binding(self, order: int) -> Tuple[str, str]:
|
52
|
-
return
|
55
|
+
return self.__vfor_item_._to_str_format_binding(order)
|
53
56
|
|
54
57
|
def _to_pathable_binding_config(self) -> Dict:
|
55
|
-
return
|
58
|
+
return self.__vfor_item_._to_pathable_binding_config()
|
56
59
|
|
57
60
|
def _to_observable_config(self):
|
58
|
-
return
|
61
|
+
return self.__vfor_item_._to_observable_config()
|
59
62
|
|
60
63
|
def _to_json_dict(self):
|
61
|
-
return
|
64
|
+
return self.__vfor_item_._to_json_dict()
|
65
|
+
|
66
|
+
def _to_event_output_type(self) -> OutputSetType:
|
67
|
+
return self.__vfor_item_._to_event_output_type()
|
68
|
+
|
69
|
+
def _to_event_input_type(self) -> InputBindingType:
|
70
|
+
return self.__vfor_item_._to_event_input_type()
|
62
71
|
|
63
72
|
|
64
73
|
class VForItem(
|
@@ -69,135 +78,224 @@ class VForItem(
|
|
69
78
|
CanPathPropMixin,
|
70
79
|
ElementBindingMixin[_T],
|
71
80
|
StrFormatBindingMixin,
|
81
|
+
Jsonable,
|
72
82
|
Generic[_T],
|
73
83
|
):
|
74
|
-
|
84
|
+
SCOPE_TYPE = "fv"
|
75
85
|
|
76
|
-
def __init__(self
|
86
|
+
def __init__(self):
|
77
87
|
super().__init__()
|
78
|
-
|
88
|
+
scope = get_current_scope()
|
89
|
+
self.__register_info = scope.register_vfor_item_task(self)
|
90
|
+
|
91
|
+
def __getattr__(self, name: str):
|
92
|
+
return self[name]
|
93
|
+
|
94
|
+
# def __getitem__(self, name):
|
95
|
+
# return self[name]
|
79
96
|
|
80
97
|
@property
|
81
98
|
def dict_key(self):
|
82
|
-
return
|
99
|
+
return cast(Any, VForItemKey())
|
83
100
|
|
84
101
|
@property
|
85
102
|
def dict_value(self):
|
86
|
-
return self
|
103
|
+
return self
|
104
|
+
|
105
|
+
@property
|
106
|
+
def index(self) -> int:
|
107
|
+
return cast(int, VForIndex())
|
87
108
|
|
88
109
|
@property
|
89
|
-
def
|
90
|
-
return cast(_T,
|
110
|
+
def value(self) -> _T:
|
111
|
+
return cast(_T, self)
|
112
|
+
|
113
|
+
# @property
|
114
|
+
# def proxy(self):
|
115
|
+
# return cast(_T, VForItemProxy(self))
|
91
116
|
|
92
117
|
def _to_binding_config(self) -> Union[Jsonable, Dict]:
|
93
|
-
return self.
|
118
|
+
return self.__to_binding_config()
|
94
119
|
|
95
120
|
def _to_element_binding_config(self):
|
96
|
-
return self.
|
121
|
+
return self.__to_binding_config()
|
97
122
|
|
98
123
|
def _to_input_config(self):
|
99
|
-
return self.
|
124
|
+
return self.__to_binding_config()
|
100
125
|
|
101
126
|
def _to_output_config(self):
|
102
|
-
return self.
|
127
|
+
return self.__to_binding_config()
|
103
128
|
|
104
129
|
def _to_path_prop_binding_config(self) -> Dict:
|
105
|
-
return self.
|
130
|
+
return self.__to_binding_config()
|
106
131
|
|
107
132
|
def _to_pathable_binding_config(self) -> Dict:
|
108
|
-
return self.
|
133
|
+
return self.__to_binding_config()
|
109
134
|
|
110
135
|
def _to_observable_config(self):
|
111
|
-
return self.
|
136
|
+
return self.__to_binding_config()
|
137
|
+
|
138
|
+
def __to_binding_config(self):
|
139
|
+
data: Dict = {
|
140
|
+
"sid": self.__register_info.scope_id,
|
141
|
+
"id": self.__register_info.var_id,
|
142
|
+
}
|
143
|
+
|
144
|
+
return data
|
112
145
|
|
113
146
|
def _to_json_dict(self):
|
114
147
|
data: Dict = {
|
115
|
-
"
|
116
|
-
"fid": self._vfor._fid,
|
148
|
+
"id": self.__register_info.var_id,
|
117
149
|
}
|
118
150
|
|
119
151
|
return data
|
120
152
|
|
153
|
+
def _to_event_output_type(self) -> OutputSetType:
|
154
|
+
return OutputSetType.Ref
|
155
|
+
|
156
|
+
def _to_event_input_type(self) -> InputBindingType:
|
157
|
+
return InputBindingType.Ref
|
158
|
+
|
121
159
|
|
122
160
|
class VForIndex(
|
123
161
|
CanInputMixin,
|
124
162
|
CanPathPropMixin,
|
125
163
|
ElementBindingMixin,
|
126
164
|
StrFormatBindingMixin,
|
165
|
+
Jsonable,
|
127
166
|
):
|
128
|
-
|
167
|
+
SCOPE_TYPE = "fi"
|
168
|
+
|
169
|
+
def __init__(self):
|
129
170
|
super().__init__()
|
130
|
-
|
171
|
+
scope = get_current_scope()
|
172
|
+
self.__register_info = scope.register_vfor_index_task(self)
|
173
|
+
|
174
|
+
def __to_binding_config(self):
|
175
|
+
data: Dict = {
|
176
|
+
"sid": self.__register_info.scope_id,
|
177
|
+
"id": self.__register_info.var_id,
|
178
|
+
}
|
179
|
+
|
180
|
+
return data
|
131
181
|
|
132
182
|
def _to_element_binding_config(self):
|
133
|
-
return self.
|
183
|
+
return self.__to_binding_config()
|
134
184
|
|
135
185
|
def _to_input_config(self):
|
136
|
-
return self.
|
186
|
+
return self.__to_binding_config()
|
137
187
|
|
138
188
|
def _to_path_prop_binding_config(self) -> Dict:
|
139
|
-
return self.
|
189
|
+
return self.__to_binding_config()
|
140
190
|
|
141
191
|
def _to_json_dict(self):
|
142
192
|
return {
|
143
|
-
"
|
144
|
-
"fid": self._vfor._fid,
|
193
|
+
"id": self.__register_info.var_id,
|
145
194
|
}
|
146
195
|
|
196
|
+
def _to_event_input_type(self) -> InputBindingType:
|
197
|
+
return InputBindingType.Ref
|
147
198
|
|
148
|
-
|
199
|
+
|
200
|
+
class VForItemKey(
|
149
201
|
CanInputMixin,
|
150
|
-
|
151
|
-
StrFormatBindingMixin,
|
202
|
+
CanPathPropMixin,
|
152
203
|
ElementBindingMixin,
|
204
|
+
StrFormatBindingMixin,
|
153
205
|
Jsonable,
|
154
206
|
):
|
155
|
-
|
156
|
-
self._vfor = vfor
|
207
|
+
SCOPE_TYPE = "fk"
|
157
208
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
@property
|
163
|
-
def dict_value(self):
|
164
|
-
return self._vfor.current[0]
|
165
|
-
|
166
|
-
@contextmanager
|
167
|
-
def with_index(self):
|
168
|
-
self.__enter__()
|
169
|
-
yield self, cast(int, VForIndex(self._vfor))
|
209
|
+
def __init__(self):
|
210
|
+
super().__init__()
|
211
|
+
scope = get_current_scope()
|
212
|
+
self.__register_info = scope.register_vfor_key_task(self)
|
170
213
|
|
171
|
-
def
|
172
|
-
|
173
|
-
|
214
|
+
def __to_binding_config(self):
|
215
|
+
data: Dict = {
|
216
|
+
"sid": self.__register_info.scope_id,
|
217
|
+
"id": self.__register_info.var_id,
|
218
|
+
}
|
174
219
|
|
175
|
-
|
176
|
-
return self._vfor.__exit__(*_)
|
220
|
+
return data
|
177
221
|
|
178
|
-
def _to_element_binding_config(self)
|
179
|
-
return self.
|
222
|
+
def _to_element_binding_config(self):
|
223
|
+
return self.__to_binding_config()
|
180
224
|
|
181
225
|
def _to_input_config(self):
|
182
|
-
return self.
|
226
|
+
return self.__to_binding_config()
|
183
227
|
|
184
|
-
def
|
185
|
-
return self.
|
228
|
+
def _to_path_prop_binding_config(self) -> Dict:
|
229
|
+
return self.__to_binding_config()
|
186
230
|
|
187
231
|
def _to_json_dict(self):
|
188
|
-
return
|
232
|
+
return {
|
233
|
+
"id": self.__register_info.var_id,
|
234
|
+
}
|
235
|
+
|
236
|
+
def _to_event_input_type(self) -> InputBindingType:
|
237
|
+
return InputBindingType.Ref
|
238
|
+
|
239
|
+
|
240
|
+
# class VForDict(
|
241
|
+
# CanInputMixin,
|
242
|
+
# CanOutputMixin,
|
243
|
+
# StrFormatBindingMixin,
|
244
|
+
# ElementBindingMixin,
|
245
|
+
# Jsonable,
|
246
|
+
# ):
|
247
|
+
# def __init__(self, vfor: VFor):
|
248
|
+
# self._vfor = vfor
|
249
|
+
|
250
|
+
# @property
|
251
|
+
# def dict_key(self):
|
252
|
+
# return self._vfor.current[0]
|
253
|
+
|
254
|
+
# @property
|
255
|
+
# def dict_value(self):
|
256
|
+
# return self._vfor.current[1]
|
257
|
+
|
258
|
+
# @contextmanager
|
259
|
+
# def with_index(self):
|
260
|
+
# self.__enter__()
|
261
|
+
# yield self, cast(int, VForIndex(self._vfor))
|
262
|
+
|
263
|
+
# def __enter__(self):
|
264
|
+
# self._vfor.__enter__()
|
265
|
+
# return self
|
266
|
+
|
267
|
+
# def __exit__(self, *_) -> None:
|
268
|
+
# return self._vfor.__exit__(*_)
|
269
|
+
|
270
|
+
# def _to_element_binding_config(self) -> Dict:
|
271
|
+
# return self.dict_value._to_element_binding_config()
|
272
|
+
|
273
|
+
# def _to_input_config(self):
|
274
|
+
# return self.dict_value._to_input_config()
|
275
|
+
|
276
|
+
# def _to_output_config(self):
|
277
|
+
# return self.dict_value._to_output_config()
|
278
|
+
|
279
|
+
# def _to_json_dict(self):
|
280
|
+
# return self.dict_value._to_json_dict()
|
281
|
+
|
282
|
+
# def _to_event_output_type(self) -> EventOutputType:
|
283
|
+
# raise ValueError("VForDict does not support output events")
|
284
|
+
|
285
|
+
# def _to_event_input_type(self) -> EventInputType:
|
286
|
+
# return EventInputType.Ref
|
189
287
|
|
190
288
|
|
191
|
-
class VForWithIndex(Generic[_T]):
|
192
|
-
|
193
|
-
|
289
|
+
# class VForWithIndex(Generic[_T]):
|
290
|
+
# def __init__(self, vfor: VFor[_T]):
|
291
|
+
# self._vfor = vfor
|
194
292
|
|
195
|
-
|
196
|
-
|
197
|
-
|
293
|
+
# def __enter__(self):
|
294
|
+
# self._vfor.__enter__()
|
295
|
+
# return cast(_T, self._vfor.current.proxy), cast(int, VForIndex(self._vfor))
|
198
296
|
|
199
|
-
|
200
|
-
|
297
|
+
# def __exit__(self, *_) -> None:
|
298
|
+
# return self._vfor.__exit__(*_)
|
201
299
|
|
202
300
|
|
203
301
|
TVForItem = VForItem
|
instaui/vars/vue_computed.py
CHANGED
@@ -4,6 +4,7 @@ from typing import Any, Dict, Mapping, Optional, Union
|
|
4
4
|
from instaui.common.jsonable import Jsonable
|
5
5
|
|
6
6
|
from instaui.runtime._app import get_current_scope
|
7
|
+
from instaui.vars._types import InputBindingType
|
7
8
|
from instaui.vars.path_var import PathVar
|
8
9
|
from instaui.vars.mixin_types.var_type import VarMixin
|
9
10
|
from instaui.vars.mixin_types.element_binding import (
|
@@ -26,8 +27,6 @@ class VueComputed(
|
|
26
27
|
StrFormatBindingMixin,
|
27
28
|
ElementBindingMixin,
|
28
29
|
):
|
29
|
-
BIND_TYPE = "var"
|
30
|
-
|
31
30
|
def __init__(
|
32
31
|
self,
|
33
32
|
fn_code: str,
|
@@ -55,7 +54,6 @@ class VueComputed(
|
|
55
54
|
|
56
55
|
def __to_binding_config(self):
|
57
56
|
return {
|
58
|
-
"type": self.BIND_TYPE,
|
59
57
|
"id": self.__register_info.var_id,
|
60
58
|
"sid": self.__register_info.scope_id,
|
61
59
|
}
|
@@ -77,9 +75,11 @@ class VueComputed(
|
|
77
75
|
|
78
76
|
def _to_json_dict(self):
|
79
77
|
data = super()._to_json_dict()
|
80
|
-
data["sid"] = self.__register_info.scope_id
|
81
78
|
data["id"] = self.__register_info.var_id
|
82
79
|
return data
|
83
80
|
|
81
|
+
def _to_event_input_type(self) -> InputBindingType:
|
82
|
+
return InputBindingType.Ref
|
83
|
+
|
84
84
|
|
85
85
|
TVueComputed = VueComputed
|
instaui/vars/web_computed.py
CHANGED
@@ -15,8 +15,13 @@ from instaui.common.jsonable import Jsonable
|
|
15
15
|
from instaui.runtime._app import get_app_slot, get_current_scope
|
16
16
|
from instaui.handlers import watch_handler
|
17
17
|
|
18
|
+
from instaui.vars._types import InputBindingType
|
18
19
|
from instaui.vars.path_var import PathVar
|
19
|
-
from instaui.vars.mixin_types.py_binding import
|
20
|
+
from instaui.vars.mixin_types.py_binding import (
|
21
|
+
CanInputMixin,
|
22
|
+
CanOutputMixin,
|
23
|
+
outputs_to_config,
|
24
|
+
)
|
20
25
|
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
21
26
|
from instaui.vars.mixin_types.pathable import CanPathPropMixin
|
22
27
|
from instaui.vars.mixin_types.str_format_binding import StrFormatBindingMixin
|
@@ -41,8 +46,6 @@ class WebComputed(
|
|
41
46
|
ElementBindingMixin[R],
|
42
47
|
Generic[P, R],
|
43
48
|
):
|
44
|
-
BIND_TYPE = "var"
|
45
|
-
|
46
49
|
def __init__(
|
47
50
|
self,
|
48
51
|
func: Callable[P, R],
|
@@ -61,7 +64,7 @@ class WebComputed(
|
|
61
64
|
self._inputs, self._is_slient_inputs, self._is_data = (
|
62
65
|
observable_helper.analyze_observable_inputs(list(inputs or []))
|
63
66
|
)
|
64
|
-
self._outputs = [output
|
67
|
+
self._outputs = outputs_to_config([output for output in extend_outputs or []])
|
65
68
|
self._fn = func
|
66
69
|
self._init_value = init_value
|
67
70
|
self._evaluating = evaluating
|
@@ -86,7 +89,6 @@ class WebComputed(
|
|
86
89
|
watch_handler.register_handler(hkey, self._fn, len(self._outputs) + 1)
|
87
90
|
|
88
91
|
data["id"] = self.__register_info.var_id
|
89
|
-
data["sid"] = self.__register_info.scope_id
|
90
92
|
|
91
93
|
if self._inputs:
|
92
94
|
data["inputs"] = self._inputs
|
@@ -117,7 +119,6 @@ class WebComputed(
|
|
117
119
|
|
118
120
|
def __to_binding_config(self):
|
119
121
|
return {
|
120
|
-
"type": self.BIND_TYPE,
|
121
122
|
"id": self.__register_info.var_id,
|
122
123
|
"sid": self.__register_info.scope_id,
|
123
124
|
}
|
@@ -137,6 +138,9 @@ class WebComputed(
|
|
137
138
|
def _to_observable_config(self):
|
138
139
|
return self.__to_binding_config()
|
139
140
|
|
141
|
+
def _to_event_input_type(self) -> InputBindingType:
|
142
|
+
return InputBindingType.Ref
|
143
|
+
|
140
144
|
|
141
145
|
def web_computed(
|
142
146
|
*,
|
instaui/watch/js_watch.py
CHANGED
@@ -5,7 +5,7 @@ from . import _utils
|
|
5
5
|
from instaui.common.jsonable import Jsonable
|
6
6
|
from instaui.runtime._app import get_current_scope
|
7
7
|
|
8
|
-
from instaui.vars.mixin_types.py_binding import CanOutputMixin
|
8
|
+
from instaui.vars.mixin_types.py_binding import CanOutputMixin, outputs_to_config
|
9
9
|
from instaui.vars.mixin_types.common_type import TObservableInput
|
10
10
|
from instaui._helper import observable_helper
|
11
11
|
|
@@ -23,14 +23,12 @@ class JsWatch(Jsonable):
|
|
23
23
|
) -> None:
|
24
24
|
inputs = observable_helper.auto_made_inputs_to_slient(inputs, outputs)
|
25
25
|
|
26
|
-
get_current_scope().register_js_watch(self)
|
27
|
-
|
28
26
|
self.code = code
|
29
27
|
|
30
28
|
self._inputs, self._is_slient_inputs, self._is_data = (
|
31
29
|
observable_helper.analyze_observable_inputs(list(inputs or []))
|
32
30
|
)
|
33
|
-
self._outputs = [output
|
31
|
+
self._outputs = [output for output in outputs or []]
|
34
32
|
|
35
33
|
if immediate is not True:
|
36
34
|
self.immediate = immediate
|
@@ -58,7 +56,7 @@ class JsWatch(Jsonable):
|
|
58
56
|
data["data"] = self._is_data
|
59
57
|
|
60
58
|
if self._outputs:
|
61
|
-
data["outputs"] = self._outputs
|
59
|
+
data["outputs"] = outputs_to_config(self._outputs)
|
62
60
|
|
63
61
|
return data
|
64
62
|
|
@@ -107,4 +105,6 @@ def js_watch(
|
|
107
105
|
ui.label(msg)
|
108
106
|
"""
|
109
107
|
|
110
|
-
|
108
|
+
watch = JsWatch(code, inputs, outputs, immediate, deep, once, flush)
|
109
|
+
get_current_scope().register_js_watch(watch)
|
110
|
+
return watch
|
instaui/watch/vue_watch.py
CHANGED
@@ -29,8 +29,6 @@ class VueWatch(Jsonable):
|
|
29
29
|
once: bool = False,
|
30
30
|
flush: Optional[_types.TFlush] = None,
|
31
31
|
) -> None:
|
32
|
-
get_current_scope().register_vue_watch(self)
|
33
|
-
|
34
32
|
self.code = callback
|
35
33
|
|
36
34
|
if not isinstance(sources, Sequence):
|
@@ -75,3 +73,28 @@ class VueWatch(Jsonable):
|
|
75
73
|
|
76
74
|
if flush is not None:
|
77
75
|
self.flush = flush
|
76
|
+
|
77
|
+
|
78
|
+
def vue_watch(
|
79
|
+
sources: Union[Any, Sequence],
|
80
|
+
callback: str,
|
81
|
+
*,
|
82
|
+
bindings: Optional[Dict[str, Any]] = None,
|
83
|
+
immediate: bool = False,
|
84
|
+
deep: Union[bool, int] = False,
|
85
|
+
once: bool = False,
|
86
|
+
flush: Optional[_types.TFlush] = None,
|
87
|
+
):
|
88
|
+
""" """
|
89
|
+
|
90
|
+
watch = VueWatch(
|
91
|
+
sources,
|
92
|
+
callback,
|
93
|
+
bindings=bindings,
|
94
|
+
immediate=immediate,
|
95
|
+
deep=deep,
|
96
|
+
once=once,
|
97
|
+
flush=flush,
|
98
|
+
)
|
99
|
+
get_current_scope().register_vue_watch(watch)
|
100
|
+
return watch
|
instaui/watch/web_watch.py
CHANGED
@@ -9,7 +9,11 @@ from instaui.common.jsonable import Jsonable
|
|
9
9
|
from instaui.runtime._app import get_app_slot, get_current_scope
|
10
10
|
from instaui.handlers import watch_handler
|
11
11
|
|
12
|
-
from instaui.vars.mixin_types.py_binding import
|
12
|
+
from instaui.vars.mixin_types.py_binding import (
|
13
|
+
CanOutputMixin,
|
14
|
+
outputs_to_config,
|
15
|
+
_assert_outputs_be_can_output_mixin,
|
16
|
+
)
|
13
17
|
from instaui.vars.mixin_types.common_type import TObservableInput
|
14
18
|
from instaui._helper import observable_helper
|
15
19
|
from instaui import pre_setup as _pre_setup
|
@@ -36,15 +40,18 @@ class WebWatch(Jsonable, typing.Generic[P, R]):
|
|
36
40
|
) -> None:
|
37
41
|
if pre_setup:
|
38
42
|
_pre_setup._check_args(pre_setup)
|
39
|
-
inputs = observable_helper.auto_made_inputs_to_slient(inputs, outputs)
|
40
43
|
|
41
|
-
|
44
|
+
outputs = [] if outputs is None else outputs
|
45
|
+
|
46
|
+
_assert_outputs_be_can_output_mixin(outputs)
|
47
|
+
|
48
|
+
inputs = observable_helper.auto_made_inputs_to_slient(inputs, outputs)
|
42
49
|
|
43
50
|
self._inputs, self._is_slient_inputs, self._is_data = (
|
44
51
|
observable_helper.analyze_observable_inputs(list(inputs or []))
|
45
52
|
)
|
46
53
|
|
47
|
-
self._outputs =
|
54
|
+
self._outputs = outputs
|
48
55
|
self._fn = func
|
49
56
|
self._immediate = immediate
|
50
57
|
self._deep = deep
|
@@ -86,7 +93,7 @@ class WebWatch(Jsonable, typing.Generic[P, R]):
|
|
86
93
|
data["debug"] = self._debug
|
87
94
|
|
88
95
|
if self._outputs:
|
89
|
-
data["outputs"] = self._outputs
|
96
|
+
data["outputs"] = outputs_to_config(self._outputs)
|
90
97
|
|
91
98
|
if self._immediate is not True:
|
92
99
|
data["immediate"] = self._immediate
|
@@ -171,7 +178,7 @@ def watch(
|
|
171
178
|
"""
|
172
179
|
|
173
180
|
def wrapper(func: typing.Callable[P, R]):
|
174
|
-
|
181
|
+
obj = WebWatch(
|
175
182
|
func,
|
176
183
|
inputs,
|
177
184
|
outputs=outputs,
|
@@ -183,4 +190,6 @@ def watch(
|
|
183
190
|
_debug=_debug,
|
184
191
|
)
|
185
192
|
|
193
|
+
get_current_scope().register_web_watch(obj)
|
194
|
+
|
186
195
|
return wrapper
|