instaui 0.1.16__py2.py3-none-any.whl → 0.1.18__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/ui/__init__.py CHANGED
@@ -54,12 +54,12 @@ __all__ = [
54
54
  "watch",
55
55
  "vue_watch",
56
56
  "js_watch",
57
+ "js_fn",
57
58
  "TWatchState",
58
59
  "match",
59
60
  "column",
60
61
  "experimental",
61
62
  "skip_output",
62
- "js_output",
63
63
  "str_format",
64
64
  "on_page_request_lifespan",
65
65
  "webview",
@@ -122,7 +122,6 @@ from instaui.watch.js_watch import js_watch
122
122
  from instaui.handlers.watch_handler import WatchState as TWatchState
123
123
  from instaui.skip import skip_output
124
124
  from instaui.ui_functions.input_slient_data import InputSilentData as slient
125
- from instaui.js.js_output import JsOutput as js_output
126
125
  import instaui.experimental as experimental
127
126
 
128
127
  from instaui.ui_functions.server import create_server as server
@@ -132,6 +131,7 @@ from instaui.ui_functions.ui_types import TBindable, is_bindable
132
131
 
133
132
  from .events import on_page_request_lifespan
134
133
  from instaui.extra_libs._import_error import show_error # noqa: E402, F401
134
+ from instaui.js.fn import JsFn as js_fn
135
135
 
136
136
  # -- dynamic imports
137
137
  from instaui.systems.module_system import LazyModule as _LazyModule
instaui/ui/__init__.pyi CHANGED
@@ -54,12 +54,12 @@ __all__ = [
54
54
  "watch",
55
55
  "vue_watch",
56
56
  "js_watch",
57
+ "js_fn",
57
58
  "TWatchState",
58
59
  "match",
59
60
  "column",
60
61
  "experimental",
61
62
  "skip_output",
62
- "js_output",
63
63
  "str_format",
64
64
  "on_page_request_lifespan",
65
65
  "webview",
@@ -122,7 +122,6 @@ from instaui.watch.js_watch import js_watch
122
122
  from instaui.handlers.watch_handler import WatchState as TWatchState
123
123
  from instaui.skip import skip_output
124
124
  from instaui.ui_functions.input_slient_data import InputSilentData as slient
125
- from instaui.js.js_output import JsOutput as js_output
126
125
  import instaui.experimental as experimental
127
126
 
128
127
  from instaui.ui_functions.server import create_server as server
@@ -132,6 +131,7 @@ from instaui.ui_functions.ui_types import TBindable, is_bindable
132
131
 
133
132
  from .events import on_page_request_lifespan
134
133
  from instaui.extra_libs._import_error import show_error # noqa: E402, F401
134
+ from instaui.js.fn import JsFn as js_fn
135
135
 
136
136
  # -- dynamic imports
137
137
  from instaui.components.markdown.markdown import Markdown as markdown
instaui/vars/ref.py CHANGED
@@ -37,13 +37,16 @@ class Ref(
37
37
  ):
38
38
  VAR_TYPE = "var"
39
39
 
40
- def __init__(self, value: Optional[_T_Value] = None) -> None:
40
+ def __init__(
41
+ self, value: Optional[_T_Value] = None, *, deep_compare: bool = False
42
+ ) -> None:
41
43
  self.value = value # type: ignore
42
44
  scope = get_current_scope()
43
45
  scope.register_ref(self)
44
46
 
45
47
  self._sid = scope.id
46
48
  self._id = scope.generate_vars_id()
49
+ self._deep_compare = deep_compare
47
50
  self._debounced = None
48
51
 
49
52
  def debounced(self, secounds: float):
@@ -83,6 +86,9 @@ class Ref(
83
86
  if self._debounced is not None:
84
87
  data["debounced"] = self._debounced
85
88
 
89
+ if self._deep_compare is True:
90
+ data["deepCompare"] = True
91
+
86
92
  return data
87
93
 
88
94
 
@@ -90,14 +96,18 @@ TRef = Ref
90
96
 
91
97
 
92
98
  @overload
93
- def ref(value: Ref[_T_Value]) -> Ref[_T_Value]: ...
99
+ def ref(value: Ref[_T_Value], *, deep_compare: bool = False) -> Ref[_T_Value]: ...
94
100
 
95
101
 
96
102
  @overload
97
- def ref(value: Optional[_T_Value] = None) -> Ref[_T_Value]: ...
103
+ def ref(
104
+ value: Optional[_T_Value] = None, *, deep_compare: bool = False
105
+ ) -> Ref[_T_Value]: ...
98
106
 
99
107
 
100
- def ref(value: Union[Ref[_T_Value], _T_Value, None] = None):
108
+ def ref(
109
+ value: Union[Ref[_T_Value], _T_Value, None] = None, *, deep_compare: bool = False
110
+ ):
101
111
  if isinstance(value, Ref):
102
112
  return value
103
- return Ref(value)
113
+ return Ref(value, deep_compare=deep_compare)
instaui/vars/state.py CHANGED
@@ -25,9 +25,9 @@ class RefProxy(
25
25
  ElementBindingMixin,
26
26
  Jsonable,
27
27
  ):
28
- def __init__(self, instance: BaseModel) -> None:
28
+ def __init__(self, instance: BaseModel, *, deep_compare: bool = False) -> None:
29
29
  data = instance.model_dump()
30
- self._ref_ = ui.ref(data)
30
+ self._ref_ = ui.ref(data, deep_compare=deep_compare)
31
31
  self._prop_names_ = set(data.keys()) if isinstance(data, dict) else set()
32
32
 
33
33
  def __getattribute__(self, name):
@@ -77,7 +77,7 @@ class StateModel(BaseModel, Jsonable):
77
77
  return self.model_dump()
78
78
 
79
79
 
80
- def state(value: _T) -> _T:
80
+ def state(value: _T, *, deep_compare: bool = False) -> _T:
81
81
  """
82
82
  Creates a reactive state object that tracks changes and notifies dependencies.
83
83
 
@@ -93,5 +93,5 @@ def state(value: _T) -> _T:
93
93
  html.number(count)
94
94
  ui.label(count)
95
95
  """
96
- obj = RefProxy(_ProxyModel(value)) # type: ignore
96
+ obj = RefProxy(_ProxyModel(value), deep_compare=deep_compare) # type: ignore
97
97
  return obj # type: ignore
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: instaui
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: insta-ui is a Python-based UI library for rapidly building user interfaces.
5
5
  Author-email: CrystalWindSnake <568166495@qq.com>
6
6
  License-Expression: MIT
@@ -133,7 +133,7 @@ instaui/components/html/li.py,sha256=2IS8eudUX4McHjyxT1SOu91xviC2D1NNdYKLjznZ-IA
133
133
  instaui/components/html/link.py,sha256=eNC2f-twFZUhw_rL-Ggff2Lo8NRU33oF8CfWW_9-ktI,670
134
134
  instaui/components/html/number.py,sha256=Y2oIzTMHKWMWpufG55tFz0npEoEFvLhTWpZbMJ8J07s,1069
135
135
  instaui/components/html/paragraph.py,sha256=TNMtI9dyQb6hYKE5vGAsSXiOiEqkx7BM6CEoJrg6nz8,914
136
- instaui/components/html/radio.py,sha256=4-u-9tCe5372zDJWPs3-BDC-xpaKUDbdPQmcbThMyeI,1020
136
+ instaui/components/html/radio.py,sha256=yZxwLnzWhDMn8D_z98aVuXpQR-FO6q8zeUa80Ut8wig,1013
137
137
  instaui/components/html/range.py,sha256=cLGoo3QaARG9YDnh6g3UYtc1yueI5dfMa9-4e-feSn4,1644
138
138
  instaui/components/html/select.py,sha256=Bq6mwyKa1qAk7bZiHK0uOg65W2twz4QkcJQTjvFNDP4,2029
139
139
  instaui/components/html/span.py,sha256=RJnccwnYEh8PUZ36VTBCKzBNV74M3SMohAejb0ck0UI,440
@@ -183,11 +183,9 @@ instaui/fastapi_server/watch_router.py,sha256=KC8AbGNpH2x11PHQMPgc9N5WOlqW05i6r0
183
183
  instaui/handlers/_utils.py,sha256=uO7WgbNhrykJwDwSEXQxsqsuCR37nx8ehL_urXm-Tks,2830
184
184
  instaui/handlers/event_handler.py,sha256=hjxi_nDh0yjk9EmRgew1USXk-Egd4pR8YnUiOcJbbnc,1761
185
185
  instaui/handlers/watch_handler.py,sha256=Ay4lubEdRnZcWSqWLwxQyS_uWiF0gu-E9PrNGCAHvL0,1600
186
- instaui/js/__init__.py,sha256=oIYLPskHpQf8a4SWHLX4DyKjrlDrqWaqbNksIQsLBoA,69
187
- instaui/js/js_output.py,sha256=a4tZ99P19oen4510qI9LWX6pX0-lH5y37v8va6UY62Y,382
188
- instaui/js/lambda_func.py,sha256=ulCJ1lzF4h3jGihVTwltS3xEDPbTegjzIN8Al7U4Ank,1004
186
+ instaui/js/fn.py,sha256=3y5nQvEjQtsaFYfTcS1-1v5b4bM20NLkk0HFl_3fewE,1186
189
187
  instaui/runtime/__init__.py,sha256=4aYTDsKaloRMQns8ttdfSx5xLmcN0Ot6tMqELbjIDZg,667
190
- instaui/runtime/_app.py,sha256=tF2rb_4SC6cMYTriDYUKRfroAK6tn5PFLEEXyogClmI,7340
188
+ instaui/runtime/_app.py,sha256=d1IM2Ul3tDuyQPYjk4DUaxqeufuCORytCTcWtlQ0IB4,7728
191
189
  instaui/runtime/_inner_helper.py,sha256=Aw7S_KtCuOlpd8NP2RuQvNTL1GJtpxQGLsKdc3VXQFY,326
192
190
  instaui/runtime/_link_manager.py,sha256=sVdqm3gdCl6i9UXa8WwckfYVf1vmESm7hvdagT_-OZI,2271
193
191
  instaui/runtime/context.py,sha256=MXwyKnX1X13peHOUbYzwAMflaA1WoQrNkGbi5C_0ErU,1086
@@ -211,9 +209,9 @@ instaui/spa_router/_router_param_var.py,sha256=KCy54xBZxGMqLO3Zlbzr6XV8ts-M6jCOK
211
209
  instaui/spa_router/_types.py,sha256=KuGuv5C6qivwllfdmV5qrvM0S_GWJ6u8OOTkCNmJImU,81
212
210
  instaui/spa_router/templates/page_routes,sha256=8VjM_8f6pjFb01QbU9z5HNqpcNRdCiX3X0OqNHLq8fo,1355
213
211
  instaui/static/insta-ui.css,sha256=EFA-_5bytZzwbe9w_kaAskE-bpdtwKbBRAyS4iw7NvU,292
214
- instaui/static/insta-ui.esm-browser.prod.js,sha256=vOYJmB8XMhjNCilar1qXOsjkwoCOVrSw5fsjbQsjYGY,109896
212
+ instaui/static/insta-ui.esm-browser.prod.js,sha256=s5IwKwBd98i4ODQqWp0N7dmDygVpNYVuhjLqO4Xtkls,109777
215
213
  instaui/static/insta-ui.ico,sha256=08FJg4qWolvOjfodoh8IJLStslrvd8sDyuRcTUDq5ak,1150
216
- instaui/static/insta-ui.js.map,sha256=cuplnJd5ozaVPCO2Flbf30hmuUJLIk0mo4cu2mMb7Lg,664019
214
+ instaui/static/insta-ui.js.map,sha256=WjZjtDKfAbGC70HNJVfnAxq2k7eqr-ni3x4UAhQyREk,663314
217
215
  instaui/static/instaui-tools-browser.js,sha256=cLHKNXYaYMZriMxV-yKGAHTrHSdNRUlDVZmv6uc6mMw,14455
218
216
  instaui/static/vue.esm-browser.prod.js,sha256=vwQkXANuVYQuEFc0VgiokJdhNyMmvxMKyb1FmrYrNb4,162662
219
217
  instaui/static/vue.global.prod.js,sha256=YO-UVLcXWjFOKfGU2uRrIMYpliGY2y48OmEjV464Z7M,157933
@@ -238,8 +236,8 @@ instaui/template/env.py,sha256=ZqVsqpfSY1mupbgpBSkvOJytNui8xfNR5kNNC9rv4Ps,150
238
236
  instaui/template/web_template.py,sha256=BmZY13q4E_ZP4YVgfBKbbXvPHcGZfOl2f54wp_0DjJA,1603
239
237
  instaui/template/webview_template.py,sha256=rd51iPi600QOPQ9PMjgYk61oIxn3L2p3_sJ3eBPG_24,1557
240
238
  instaui/template/zero_template.py,sha256=E88VGsyjb1qbHFJlMW-xmLRFkwUXZA7VDoZ_Jd8YubA,3514
241
- instaui/ui/__init__.py,sha256=e8GJWNB8HXMWlqqp4hGuRCWii5HcgyxXnyH4F8O7B64,4795
242
- instaui/ui/__init__.pyi,sha256=8LwGzW1nFLd5bSKi25rrB47TMXdpomcWF31L0zx6blY,4875
239
+ instaui/ui/__init__.py,sha256=LwgVJIsEY4vOkAyWq5v_CyQrJKVAP2OCcj2nUMUGsMM,4776
240
+ instaui/ui/__init__.pyi,sha256=I5nfskP87QjdEwo7DF-ncXOp2pZ0TPCvWbkrirKin9U,4856
243
241
  instaui/ui/events.py,sha256=lfhiINwn-Kh0MezsSeLJPttWm6G1aWiwyk3TRo0NrlA,809
244
242
  instaui/ui_functions/input_slient_data.py,sha256=0A5DegIt_MqdZgbj1RiVFNmB_RUqgov9FYtkw6VX0DE,511
245
243
  instaui/ui_functions/server.py,sha256=B4w8KwBUMGStY19uUG8E4vRG7-L4cedttLkh35xr698,357
@@ -253,9 +251,9 @@ instaui/vars/event_context.py,sha256=3ML6nyF6Q1hbFvdeu6E2QVOIVcWe1P9FtlCR0dgBGjo
253
251
  instaui/vars/event_extend.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
254
252
  instaui/vars/js_computed.py,sha256=HjBbSeKCOYExJ2xwhklouG8bawlXW4JNvJZjDaE4CWg,3972
255
253
  instaui/vars/path_var.py,sha256=znIvxaNHwQzXflEqwB2xjrI7Bk5_QjwYlhdl4qvtyws,2811
256
- instaui/vars/ref.py,sha256=iMwKRYI8ygy2cOpXJgqUYJCpzJCQskDl4lRYTACZWnA,2567
254
+ instaui/vars/ref.py,sha256=01MwULr6LYgVaOulLOBaGaN9XbSg5b0DO0p_R3rLhCQ,2875
257
255
  instaui/vars/slot_prop.py,sha256=qBVQ0Ze0T8-Wsy__8qEuqVESIrLX69Bmy21Kuxrg_GQ,1198
258
- instaui/vars/state.py,sha256=MuiCzR9n348P1J7qdCfFXXratwuOOGELLzg8pu9G6kE,3074
256
+ instaui/vars/state.py,sha256=x6qeTliE1J7qoFmAG7huJ-sNQ4VcFgy0IlJoNodqRe0,3190
259
257
  instaui/vars/types.py,sha256=K0QTajlzHaDvFoVMCHAhY_rVvrBm3FsC92BFPOgdBog,511
260
258
  instaui/vars/vfor_item.py,sha256=cVrpErh8OrycYjDLm7PTuE2kIcC2M6ThAQlwvTXG8x0,5490
261
259
  instaui/vars/vue_computed.py,sha256=bWMlnjKf9pFYX9IrXtSzUZy4A7P4zABeDXUi4fvqnnI,2818
@@ -282,7 +280,7 @@ instaui/webview/resource.py,sha256=kFT6N5UZK5GLE0KmW3TrEYDNlViw9DL2OshRh41wBXs,5
282
280
  instaui/zero/__init__.py,sha256=N0LuRUAcaurxHSspcEDuwZg62W2S3qL4VtrMKxOivBE,49
283
281
  instaui/zero/func.py,sha256=8cA_wJMtRmoAARjWY8yY5MmLXDAQ7hyVW6f1Vbejtoc,3576
284
282
  instaui/zero/scope.py,sha256=HGohYOqnpRGVkkoz_gvR6-DgCc48AtJAcDwbOnnGHLM,3753
285
- instaui-0.1.16.dist-info/METADATA,sha256=r5ViXqPm5_kLMHKBc6N2MhiwZlODJhOBRtSTVgDWSJ0,3562
286
- instaui-0.1.16.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
287
- instaui-0.1.16.dist-info/licenses/LICENSE,sha256=_JjnAWrikJ6qkwT7PazeFNRlcIu8q_RH3mYcHTxEF5c,1094
288
- instaui-0.1.16.dist-info/RECORD,,
283
+ instaui-0.1.18.dist-info/METADATA,sha256=XO-j_gf1pr-Btqvih-8_V4P2OH94bGWp9sfIz2Oaez4,3562
284
+ instaui-0.1.18.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
285
+ instaui-0.1.18.dist-info/licenses/LICENSE,sha256=_JjnAWrikJ6qkwT7PazeFNRlcIu8q_RH3mYcHTxEF5c,1094
286
+ instaui-0.1.18.dist-info/RECORD,,
instaui/js/__init__.py DELETED
@@ -1,4 +0,0 @@
1
- from .lambda_func import LambdaFunc as func
2
-
3
-
4
- __all__ = ["func"]
instaui/js/js_output.py DELETED
@@ -1,15 +0,0 @@
1
- from instaui.common.jsonable import Jsonable
2
- from instaui.vars.mixin_types.py_binding import CanOutputMixin
3
-
4
-
5
- class JsOutput(Jsonable, CanOutputMixin):
6
- def __init__(self):
7
- self.type = "jsOutput"
8
-
9
- def _to_output_config(self):
10
- return self._to_json_dict()
11
-
12
- def _to_json_dict(self):
13
- data = super()._to_json_dict()
14
-
15
- return data
instaui/js/lambda_func.py DELETED
@@ -1,35 +0,0 @@
1
- from typing import Dict
2
- from instaui.common.jsonable import Jsonable
3
- from instaui.vars.mixin_types.element_binding import ElementBindingMixin
4
-
5
-
6
- class LambdaFunc(Jsonable, ElementBindingMixin):
7
- def __init__(
8
- self, code: str, *, bindings: Dict[str, ElementBindingMixin], computed=False
9
- ):
10
- self.code = code
11
- self.type = "js"
12
- self._bindings = bindings
13
- self._computed = computed
14
-
15
- def _to_binding_config(self) -> Dict:
16
- return self._to_json_dict()
17
-
18
- def _to_js_binding_config(self):
19
- return self._to_json_dict()
20
-
21
- def _to_element_binding_config(self):
22
- return self._to_json_dict()
23
-
24
- def _to_json_dict(self):
25
- data = super()._to_json_dict()
26
-
27
- if self._bindings:
28
- data["bind"] = {
29
- k: v._to_element_binding_config() for k, v in self._bindings.items()
30
- }
31
-
32
- if self._computed is True:
33
- data["ext"] = ["cpt"]
34
-
35
- return data