instaui 0.1.18__py2.py3-none-any.whl → 0.2.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/components/component.py +4 -7
- instaui/components/element.py +0 -16
- instaui/components/html/button.py +2 -2
- instaui/components/html/input.py +2 -2
- instaui/components/html/select.py +3 -2
- instaui/components/html/textarea.py +2 -2
- instaui/components/match.py +4 -6
- instaui/components/mixins.py +12 -0
- instaui/components/vfor.py +2 -4
- instaui/components/vif.py +2 -4
- instaui/event/js_event.py +0 -2
- instaui/event/vue_event.py +0 -3
- instaui/event/web_event.py +25 -5
- instaui/fastapi_server/middlewares.py +12 -0
- instaui/fastapi_server/server.py +5 -1
- instaui/js/fn.py +5 -1
- instaui/pre_setup.py +45 -0
- instaui/runtime/_app.py +7 -3
- instaui/runtime/scope.py +74 -33
- instaui/spa_router/_route_model.py +5 -6
- instaui/static/insta-ui.esm-browser.prod.js +1523 -1504
- instaui/static/insta-ui.js.map +1 -1
- instaui/static/templates/web.html +5 -3
- instaui/static/templates/webview.html +4 -2
- instaui/static/templates/zero.html +4 -2
- instaui/template/web_template.py +1 -0
- instaui/template/webview_template.py +1 -0
- instaui/template/zero_template.py +1 -0
- instaui/ui/__init__.py +2 -0
- instaui/ui/__init__.pyi +2 -0
- instaui/ui_functions/server.py +10 -1
- instaui/vars/data.py +5 -7
- instaui/vars/js_computed.py +6 -22
- instaui/vars/mixin_types/element_binding.py +1 -13
- instaui/vars/ref.py +5 -7
- instaui/vars/vue_computed.py +6 -21
- instaui/vars/web_computed.py +6 -23
- instaui/watch/js_watch.py +0 -2
- instaui/watch/web_watch.py +11 -2
- instaui/webview/resource.py +2 -0
- instaui/zero/func.py +2 -0
- {instaui-0.1.18.dist-info → instaui-0.2.0.dist-info}/METADATA +4 -3
- {instaui-0.1.18.dist-info → instaui-0.2.0.dist-info}/RECORD +45 -44
- instaui/webview/func.py +0 -114
- {instaui-0.1.18.dist-info → instaui-0.2.0.dist-info}/WHEEL +0 -0
- {instaui-0.1.18.dist-info → instaui-0.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -24,8 +24,8 @@
|
|
24
24
|
<body>
|
25
25
|
{{ sse_html(model.is_debug) }}
|
26
26
|
|
27
|
-
<div id="app">
|
28
|
-
<insta-ui :config="config"></insta-ui>
|
27
|
+
<div id="app">
|
28
|
+
<insta-ui :config="config" :meta="meta"></insta-ui>
|
29
29
|
</div>
|
30
30
|
|
31
31
|
<script type="importmap">
|
@@ -52,11 +52,13 @@
|
|
52
52
|
const None = undefined;
|
53
53
|
|
54
54
|
const appConfig = {{model.config_dict | safe}};
|
55
|
+
const meta = {mode: 'web',version:'{{model.version | safe}}',debug:{{model.is_debug}}}
|
55
56
|
|
56
57
|
const app = createApp({
|
57
58
|
setup() {
|
58
59
|
return {
|
59
|
-
config:appConfig
|
60
|
+
config:appConfig,
|
61
|
+
meta,
|
60
62
|
}
|
61
63
|
}
|
62
64
|
})
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<body>
|
24
24
|
|
25
25
|
<div id="app">
|
26
|
-
<insta-ui :config="config"></insta-ui>
|
26
|
+
<insta-ui :config="config" :meta="meta"></insta-ui>
|
27
27
|
</div>
|
28
28
|
|
29
29
|
<script type="importmap">
|
@@ -49,6 +49,7 @@
|
|
49
49
|
const None = undefined;
|
50
50
|
|
51
51
|
const appConfig = {{model.config_dict | safe}};
|
52
|
+
const meta = {mode: 'webview',version:'{{model.version | safe}}'}
|
52
53
|
|
53
54
|
window.addEventListener('pywebviewready',async () => {
|
54
55
|
const app = createApp({
|
@@ -59,7 +60,8 @@
|
|
59
60
|
{% endif %}
|
60
61
|
setup() {
|
61
62
|
return {
|
62
|
-
config:appConfig
|
63
|
+
config:appConfig,
|
64
|
+
meta,
|
63
65
|
}
|
64
66
|
}
|
65
67
|
})
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<body>
|
24
24
|
|
25
25
|
<div id="app">
|
26
|
-
<insta-ui :config="config"></insta-ui>
|
26
|
+
<insta-ui :config="config" :meta="meta"></insta-ui>
|
27
27
|
</div>
|
28
28
|
|
29
29
|
<script type="importmap">
|
@@ -49,11 +49,13 @@
|
|
49
49
|
const None = undefined;
|
50
50
|
|
51
51
|
const appConfig = {{model.config_dict | safe}};
|
52
|
+
const meta = {mode: 'zero',version:'{{model.version | safe}}',debug:true}
|
52
53
|
|
53
54
|
const app = createApp({
|
54
55
|
setup() {
|
55
56
|
return {
|
56
|
-
config:appConfig
|
57
|
+
config:appConfig,
|
58
|
+
meta,
|
57
59
|
}
|
58
60
|
}
|
59
61
|
})
|
instaui/template/web_template.py
CHANGED
instaui/ui/__init__.py
CHANGED
@@ -61,6 +61,7 @@ __all__ = [
|
|
61
61
|
"experimental",
|
62
62
|
"skip_output",
|
63
63
|
"str_format",
|
64
|
+
"pre_setup_action",
|
64
65
|
"on_page_request_lifespan",
|
65
66
|
"webview",
|
66
67
|
"code",
|
@@ -132,6 +133,7 @@ from instaui.ui_functions.ui_types import TBindable, is_bindable
|
|
132
133
|
from .events import on_page_request_lifespan
|
133
134
|
from instaui.extra_libs._import_error import show_error # noqa: E402, F401
|
134
135
|
from instaui.js.fn import JsFn as js_fn
|
136
|
+
from instaui.pre_setup import PreSetupAction as pre_setup_action
|
135
137
|
|
136
138
|
# -- dynamic imports
|
137
139
|
from instaui.systems.module_system import LazyModule as _LazyModule
|
instaui/ui/__init__.pyi
CHANGED
@@ -61,6 +61,7 @@ __all__ = [
|
|
61
61
|
"experimental",
|
62
62
|
"skip_output",
|
63
63
|
"str_format",
|
64
|
+
"pre_setup_action",
|
64
65
|
"on_page_request_lifespan",
|
65
66
|
"webview",
|
66
67
|
"code",
|
@@ -132,6 +133,7 @@ from instaui.ui_functions.ui_types import TBindable, is_bindable
|
|
132
133
|
from .events import on_page_request_lifespan
|
133
134
|
from instaui.extra_libs._import_error import show_error # noqa: E402, F401
|
134
135
|
from instaui.js.fn import JsFn as js_fn
|
136
|
+
from instaui.pre_setup import PreSetupAction as pre_setup_action
|
135
137
|
|
136
138
|
# -- dynamic imports
|
137
139
|
from instaui.components.markdown.markdown import Markdown as markdown
|
instaui/ui_functions/server.py
CHANGED
@@ -3,9 +3,18 @@ from instaui.runtime.context import get_context
|
|
3
3
|
|
4
4
|
|
5
5
|
def create_server(
|
6
|
-
debug: bool =
|
6
|
+
debug: bool = False,
|
7
7
|
use_gzip: Union[int, bool] = True,
|
8
8
|
):
|
9
|
+
"""
|
10
|
+
Create a new server instance.
|
11
|
+
|
12
|
+
Note: When deploy to production, you need to set `debug=False`
|
13
|
+
|
14
|
+
Args:
|
15
|
+
debug (bool): Whether to run in debug mode. In debug mode, it has the development hot-reload feature. Defaults to False.
|
16
|
+
use_gzip (Union[int, bool], optional): Whether to use gzip compression. If an integer is provided, it will be used as the minimum response size for compression. If True, the default minimum size of 500 bytes will be used. If False, compression will not be used. Defaults to True.
|
17
|
+
"""
|
9
18
|
from instaui.fastapi_server.server import Server
|
10
19
|
|
11
20
|
context = get_context()
|
instaui/vars/data.py
CHANGED
@@ -31,15 +31,13 @@ class ConstData(
|
|
31
31
|
self.value = value # type: ignore
|
32
32
|
|
33
33
|
scope = get_current_scope()
|
34
|
-
scope.
|
35
|
-
self._sid = scope.id
|
36
|
-
self._id = scope.generate_vars_id()
|
34
|
+
self.__register_info = scope.register_data_task(self)
|
37
35
|
|
38
36
|
def __to_binding_config(self):
|
39
37
|
return {
|
40
38
|
"type": self.BIND_TYPE,
|
41
|
-
"id": self.
|
42
|
-
"sid": self.
|
39
|
+
"id": self.__register_info.var_id,
|
40
|
+
"sid": self.__register_info.scope_id,
|
43
41
|
}
|
44
42
|
|
45
43
|
def _to_pathable_binding_config(self) -> Dict:
|
@@ -59,8 +57,8 @@ class ConstData(
|
|
59
57
|
|
60
58
|
def _to_json_dict(self):
|
61
59
|
data = super()._to_json_dict()
|
62
|
-
data["sid"] = self.
|
63
|
-
data["id"] = self.
|
60
|
+
data["sid"] = self.__register_info.scope_id
|
61
|
+
data["id"] = self.__register_info.var_id
|
64
62
|
|
65
63
|
return data
|
66
64
|
|
instaui/vars/js_computed.py
CHANGED
@@ -6,10 +6,7 @@ from instaui.common.jsonable import Jsonable
|
|
6
6
|
from instaui.runtime._app import get_current_scope
|
7
7
|
from instaui.vars.path_var import PathVar
|
8
8
|
from instaui.vars.mixin_types.var_type import VarMixin
|
9
|
-
from instaui.vars.mixin_types.element_binding import
|
10
|
-
ElementBindingMixin,
|
11
|
-
_try_mark_inputs_used,
|
12
|
-
)
|
9
|
+
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
13
10
|
from instaui.vars.mixin_types.py_binding import CanInputMixin
|
14
11
|
from instaui.vars.mixin_types.pathable import CanPathPropMixin
|
15
12
|
from instaui.vars.mixin_types.str_format_binding import StrFormatBindingMixin
|
@@ -61,9 +58,7 @@ class JsComputed(
|
|
61
58
|
self._org_inputs = inputs or []
|
62
59
|
|
63
60
|
scope = get_current_scope()
|
64
|
-
scope.
|
65
|
-
self._sid = scope.id
|
66
|
-
self._id = scope.generate_vars_id()
|
61
|
+
self.__register_info = scope.register_js_computed_task(self)
|
67
62
|
|
68
63
|
self._inputs, self._is_slient_inputs, self._is_data = (
|
69
64
|
observable_helper.analyze_observable_inputs(list(inputs or []))
|
@@ -71,13 +66,12 @@ class JsComputed(
|
|
71
66
|
|
72
67
|
self._async_init_value = async_init_value
|
73
68
|
self._deep_compare_on_input = deep_compare_on_input
|
74
|
-
self.__be_used = False
|
75
69
|
|
76
70
|
def __to_binding_config(self):
|
77
71
|
return {
|
78
72
|
"type": self.BIND_TYPE,
|
79
|
-
"id": self.
|
80
|
-
"sid": self.
|
73
|
+
"id": self.__register_info.var_id,
|
74
|
+
"sid": self.__register_info.scope_id,
|
81
75
|
}
|
82
76
|
|
83
77
|
def _to_input_config(self):
|
@@ -95,21 +89,11 @@ class JsComputed(
|
|
95
89
|
def _to_observable_config(self):
|
96
90
|
return self.__to_binding_config()
|
97
91
|
|
98
|
-
def _mark_used(self):
|
99
|
-
if self.__be_used:
|
100
|
-
return
|
101
|
-
|
102
|
-
self.__be_used = True
|
103
|
-
_try_mark_inputs_used(self._org_inputs)
|
104
|
-
|
105
|
-
def _is_used(self):
|
106
|
-
return self.__be_used
|
107
|
-
|
108
92
|
def _to_json_dict(self):
|
109
93
|
data = super()._to_json_dict()
|
110
94
|
|
111
|
-
data["sid"] = self.
|
112
|
-
data["id"] = self.
|
95
|
+
data["sid"] = self.__register_info.scope_id
|
96
|
+
data["id"] = self.__register_info.var_id
|
113
97
|
|
114
98
|
if self._inputs:
|
115
99
|
data["inputs"] = self._inputs
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Dict, Generic,
|
1
|
+
from typing import Dict, Generic, TypeVar
|
2
2
|
from abc import ABC, abstractmethod
|
3
3
|
|
4
4
|
T = TypeVar("T")
|
@@ -8,15 +8,3 @@ class ElementBindingMixin(ABC, Generic[T]):
|
|
8
8
|
@abstractmethod
|
9
9
|
def _to_element_binding_config(self) -> Dict:
|
10
10
|
pass
|
11
|
-
|
12
|
-
def _mark_used(self):
|
13
|
-
pass
|
14
|
-
|
15
|
-
def _is_used(self):
|
16
|
-
return True
|
17
|
-
|
18
|
-
|
19
|
-
def _try_mark_inputs_used(inputs: Iterable):
|
20
|
-
for input_ in inputs:
|
21
|
-
if isinstance(input_, ElementBindingMixin):
|
22
|
-
input_._mark_used()
|
instaui/vars/ref.py
CHANGED
@@ -42,10 +42,8 @@ class Ref(
|
|
42
42
|
) -> None:
|
43
43
|
self.value = value # type: ignore
|
44
44
|
scope = get_current_scope()
|
45
|
-
scope.
|
45
|
+
self.__register_info = scope.register_ref_task(self)
|
46
46
|
|
47
|
-
self._sid = scope.id
|
48
|
-
self._id = scope.generate_vars_id()
|
49
47
|
self._deep_compare = deep_compare
|
50
48
|
self._debounced = None
|
51
49
|
|
@@ -56,8 +54,8 @@ class Ref(
|
|
56
54
|
def __to_binding_config(self):
|
57
55
|
return {
|
58
56
|
"type": self.VAR_TYPE,
|
59
|
-
"id": self.
|
60
|
-
"sid": self.
|
57
|
+
"id": self.__register_info.var_id,
|
58
|
+
"sid": self.__register_info.scope_id,
|
61
59
|
}
|
62
60
|
|
63
61
|
def _to_pathable_binding_config(self) -> Dict:
|
@@ -80,8 +78,8 @@ class Ref(
|
|
80
78
|
|
81
79
|
def _to_json_dict(self):
|
82
80
|
data = super()._to_json_dict()
|
83
|
-
data["sid"] = self.
|
84
|
-
data["id"] = self.
|
81
|
+
data["sid"] = self.__register_info.scope_id
|
82
|
+
data["id"] = self.__register_info.var_id
|
85
83
|
|
86
84
|
if self._debounced is not None:
|
87
85
|
data["debounced"] = self._debounced
|
instaui/vars/vue_computed.py
CHANGED
@@ -6,10 +6,7 @@ from instaui.common.jsonable import Jsonable
|
|
6
6
|
from instaui.runtime._app import get_current_scope
|
7
7
|
from instaui.vars.path_var import PathVar
|
8
8
|
from instaui.vars.mixin_types.var_type import VarMixin
|
9
|
-
from instaui.vars.mixin_types.element_binding import
|
10
|
-
ElementBindingMixin,
|
11
|
-
_try_mark_inputs_used,
|
12
|
-
)
|
9
|
+
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
13
10
|
from instaui.vars.mixin_types.py_binding import CanInputMixin
|
14
11
|
from instaui.vars.mixin_types.pathable import CanPathPropMixin
|
15
12
|
from instaui.vars.mixin_types.str_format_binding import StrFormatBindingMixin
|
@@ -36,11 +33,10 @@ class VueComputed(
|
|
36
33
|
self.code = fn_code
|
37
34
|
self._bindings = bindings
|
38
35
|
scope = get_current_scope()
|
39
|
-
scope.
|
36
|
+
self.__register_info = scope.register_vue_computed_task(self)
|
40
37
|
|
41
38
|
self._sid = scope.id
|
42
39
|
self._id = scope.generate_vars_id()
|
43
|
-
self.__be_used = False
|
44
40
|
|
45
41
|
if bindings:
|
46
42
|
const_bind = []
|
@@ -57,8 +53,8 @@ class VueComputed(
|
|
57
53
|
def __to_binding_config(self):
|
58
54
|
return {
|
59
55
|
"type": self.BIND_TYPE,
|
60
|
-
"id": self.
|
61
|
-
"sid": self.
|
56
|
+
"id": self.__register_info.var_id,
|
57
|
+
"sid": self.__register_info.scope_id,
|
62
58
|
}
|
63
59
|
|
64
60
|
def _to_input_config(self):
|
@@ -76,21 +72,10 @@ class VueComputed(
|
|
76
72
|
def _to_observable_config(self):
|
77
73
|
return self.__to_binding_config()
|
78
74
|
|
79
|
-
def _mark_used(self):
|
80
|
-
if self.__be_used:
|
81
|
-
return
|
82
|
-
|
83
|
-
self.__be_used = True
|
84
|
-
_try_mark_inputs_used((self._bindings or {}).values())
|
85
|
-
|
86
|
-
def _is_used(self):
|
87
|
-
return self.__be_used
|
88
|
-
|
89
75
|
def _to_json_dict(self):
|
90
76
|
data = super()._to_json_dict()
|
91
|
-
data["sid"] = self.
|
92
|
-
data["id"] = self.
|
93
|
-
_try_mark_inputs_used((self._bindings or {}).values())
|
77
|
+
data["sid"] = self.__register_info.scope_id
|
78
|
+
data["id"] = self.__register_info.var_id
|
94
79
|
return data
|
95
80
|
|
96
81
|
|
instaui/vars/web_computed.py
CHANGED
@@ -17,10 +17,7 @@ from instaui.handlers import watch_handler
|
|
17
17
|
|
18
18
|
from instaui.vars.path_var import PathVar
|
19
19
|
from instaui.vars.mixin_types.py_binding import CanInputMixin, CanOutputMixin
|
20
|
-
from instaui.vars.mixin_types.element_binding import
|
21
|
-
ElementBindingMixin,
|
22
|
-
_try_mark_inputs_used,
|
23
|
-
)
|
20
|
+
from instaui.vars.mixin_types.element_binding import ElementBindingMixin
|
24
21
|
from instaui.vars.mixin_types.pathable import CanPathPropMixin
|
25
22
|
from instaui.vars.mixin_types.str_format_binding import StrFormatBindingMixin
|
26
23
|
from instaui.vars.mixin_types.observable import ObservableMixin
|
@@ -58,10 +55,7 @@ class WebComputed(
|
|
58
55
|
) -> None:
|
59
56
|
scope = get_current_scope()
|
60
57
|
|
61
|
-
self.
|
62
|
-
self._id = scope.generate_vars_id()
|
63
|
-
get_current_scope().register_web_computed(self)
|
64
|
-
|
58
|
+
self.__register_info = scope.register_computed_task(self)
|
65
59
|
self._org_inputs = inputs or []
|
66
60
|
|
67
61
|
self._inputs, self._is_slient_inputs, self._is_data = (
|
@@ -72,7 +66,6 @@ class WebComputed(
|
|
72
66
|
self._init_value = init_value
|
73
67
|
self._evaluating = evaluating
|
74
68
|
self._deep_compare_on_input = deep_compare_on_input
|
75
|
-
self.__be_used = False
|
76
69
|
|
77
70
|
if debug_info is not None:
|
78
71
|
self.debug = debug_info
|
@@ -92,8 +85,8 @@ class WebComputed(
|
|
92
85
|
|
93
86
|
watch_handler.register_handler(hkey, self._fn, len(self._outputs) + 1)
|
94
87
|
|
95
|
-
data["id"] = self.
|
96
|
-
data["sid"] = self.
|
88
|
+
data["id"] = self.__register_info.var_id
|
89
|
+
data["sid"] = self.__register_info.scope_id
|
97
90
|
|
98
91
|
if self._inputs:
|
99
92
|
data["inputs"] = self._inputs
|
@@ -125,8 +118,8 @@ class WebComputed(
|
|
125
118
|
def __to_binding_config(self):
|
126
119
|
return {
|
127
120
|
"type": self.BIND_TYPE,
|
128
|
-
"id": self.
|
129
|
-
"sid": self.
|
121
|
+
"id": self.__register_info.var_id,
|
122
|
+
"sid": self.__register_info.scope_id,
|
130
123
|
}
|
131
124
|
|
132
125
|
def _to_pathable_binding_config(self) -> Dict:
|
@@ -144,16 +137,6 @@ class WebComputed(
|
|
144
137
|
def _to_observable_config(self):
|
145
138
|
return self.__to_binding_config()
|
146
139
|
|
147
|
-
def _mark_used(self):
|
148
|
-
if self.__be_used:
|
149
|
-
return
|
150
|
-
|
151
|
-
self.__be_used = True
|
152
|
-
_try_mark_inputs_used(self._org_inputs)
|
153
|
-
|
154
|
-
def _is_used(self):
|
155
|
-
return self.__be_used
|
156
|
-
|
157
140
|
|
158
141
|
def web_computed(
|
159
142
|
*,
|
instaui/watch/js_watch.py
CHANGED
@@ -6,7 +6,6 @@ from instaui.common.jsonable import Jsonable
|
|
6
6
|
from instaui.runtime._app import get_current_scope
|
7
7
|
|
8
8
|
from instaui.vars.mixin_types.py_binding import CanOutputMixin
|
9
|
-
from instaui.vars.mixin_types.element_binding import _try_mark_inputs_used
|
10
9
|
from instaui.vars.mixin_types.common_type import TObservableInput
|
11
10
|
from instaui._helper import observable_helper
|
12
11
|
|
@@ -22,7 +21,6 @@ class JsWatch(Jsonable):
|
|
22
21
|
once: bool = False,
|
23
22
|
flush: typing.Optional[_types.TFlush] = None,
|
24
23
|
) -> None:
|
25
|
-
_try_mark_inputs_used(inputs or [])
|
26
24
|
inputs = observable_helper.auto_made_inputs_to_slient(inputs, outputs)
|
27
25
|
|
28
26
|
get_current_scope().register_js_watch(self)
|
instaui/watch/web_watch.py
CHANGED
@@ -10,9 +10,9 @@ from instaui.runtime._app import get_app_slot, get_current_scope
|
|
10
10
|
from instaui.handlers import watch_handler
|
11
11
|
|
12
12
|
from instaui.vars.mixin_types.py_binding import CanOutputMixin
|
13
|
-
from instaui.vars.mixin_types.element_binding import _try_mark_inputs_used
|
14
13
|
from instaui.vars.mixin_types.common_type import TObservableInput
|
15
14
|
from instaui._helper import observable_helper
|
15
|
+
from instaui import pre_setup as _pre_setup
|
16
16
|
|
17
17
|
_SYNC_TYPE = "sync"
|
18
18
|
_ASYNC_TYPE = "async"
|
@@ -31,9 +31,11 @@ class WebWatch(Jsonable, typing.Generic[P, R]):
|
|
31
31
|
deep: typing.Union[bool, int] = True,
|
32
32
|
once: bool = False,
|
33
33
|
flush: typing.Optional[_types.TFlush] = None,
|
34
|
+
pre_setup: typing.Optional[typing.Dict] = None,
|
34
35
|
_debug: typing.Optional[typing.Any] = None,
|
35
36
|
) -> None:
|
36
|
-
|
37
|
+
if pre_setup:
|
38
|
+
_pre_setup._check_args(pre_setup)
|
37
39
|
inputs = observable_helper.auto_made_inputs_to_slient(inputs, outputs)
|
38
40
|
|
39
41
|
get_current_scope().register_web_watch(self)
|
@@ -49,6 +51,7 @@ class WebWatch(Jsonable, typing.Generic[P, R]):
|
|
49
51
|
self._once = once
|
50
52
|
self._flush = flush
|
51
53
|
self._debug = _debug
|
54
|
+
self._pre_setup = pre_setup
|
52
55
|
|
53
56
|
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
|
54
57
|
return self._fn(*args, **kwargs)
|
@@ -95,6 +98,8 @@ class WebWatch(Jsonable, typing.Generic[P, R]):
|
|
95
98
|
data["once"] = self._once
|
96
99
|
if self._flush is not None:
|
97
100
|
data["flush"] = self._flush
|
101
|
+
if self._pre_setup:
|
102
|
+
data["preSetup"] = _pre_setup.convert_config(self._pre_setup)
|
98
103
|
|
99
104
|
return data
|
100
105
|
|
@@ -109,6 +114,7 @@ def watch(
|
|
109
114
|
deep: typing.Union[bool, int] = True,
|
110
115
|
once: bool = False,
|
111
116
|
flush: typing.Optional[_types.TFlush] = None,
|
117
|
+
pre_setup: typing.Optional[typing.Dict] = None,
|
112
118
|
_debug: typing.Optional[typing.Any] = None,
|
113
119
|
):
|
114
120
|
"""
|
@@ -130,6 +136,8 @@ def watch(
|
|
130
136
|
- 'sync': Execute immediately on change
|
131
137
|
- 'post': Batch updates and execute after current tick
|
132
138
|
- 'pre': Execute before render phase (if applicable)
|
139
|
+
pre_setup (typing.Optional[typing.Dict], optional): A dictionary of pre-setup actions to be executed before the event executes.
|
140
|
+
|
133
141
|
|
134
142
|
# Example:
|
135
143
|
.. code-block:: python
|
@@ -171,6 +179,7 @@ def watch(
|
|
171
179
|
deep=deep,
|
172
180
|
once=once,
|
173
181
|
flush=flush,
|
182
|
+
pre_setup=pre_setup,
|
174
183
|
_debug=_debug,
|
175
184
|
)
|
176
185
|
|
instaui/webview/resource.py
CHANGED
@@ -5,6 +5,7 @@ import shutil
|
|
5
5
|
from typing import Callable, Optional
|
6
6
|
from urllib.parse import quote
|
7
7
|
|
8
|
+
from instaui.version import __version__ as _INSTAUI_VERSION
|
8
9
|
from instaui.html_tools import to_config_data
|
9
10
|
from instaui.runtime._app import get_app_slot, get_default_app_slot
|
10
11
|
from instaui.systems import file_system
|
@@ -48,6 +49,7 @@ def resource_to_assets(
|
|
48
49
|
favicon_url = file_to_assets(consts.FAVICON_PATH)
|
49
50
|
|
50
51
|
model = webview_template.WebViewTemplateModel(
|
52
|
+
version=_INSTAUI_VERSION,
|
51
53
|
vue_js_code=file_to_assets(consts.VUE_ES_JS_PATH),
|
52
54
|
instaui_js_code=file_to_assets(consts.APP_ES_JS_PATH),
|
53
55
|
css_links=[
|
instaui/zero/func.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
import itertools
|
3
3
|
from pathlib import Path
|
4
|
+
from instaui.version import __version__ as _INSTA_VERSION
|
4
5
|
import instaui.consts as consts
|
5
6
|
from instaui.runtime._app import get_app_slot, get_default_app_slot
|
6
7
|
from instaui.template import render_zero_html
|
@@ -37,6 +38,7 @@ def get_template_model():
|
|
37
38
|
config_data = to_config_data()
|
38
39
|
|
39
40
|
model = zero_template.ZeroTemplateModel(
|
41
|
+
version=_INSTA_VERSION,
|
40
42
|
vue_js_code=consts.VUE_ES_JS_PATH,
|
41
43
|
instaui_js_code=consts.APP_ES_JS_PATH,
|
42
44
|
css_links=[
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: instaui
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
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
|
@@ -91,7 +91,8 @@ def home():
|
|
91
91
|
ui.label("=")
|
92
92
|
ui.label(result).style({"color": text_color})
|
93
93
|
|
94
|
-
|
94
|
+
# when you deploy your web application, you need to set debug=False.
|
95
|
+
ui.server(debug=True).run()
|
95
96
|
```
|
96
97
|
|
97
98
|
Replace `ui.server().run()` with `ui.webview().run()` to switch to Web View mode:
|
@@ -99,7 +100,7 @@ Replace `ui.server().run()` with `ui.webview().run()` to switch to Web View mode
|
|
99
100
|
```python
|
100
101
|
...
|
101
102
|
|
102
|
-
# ui.server().run()
|
103
|
+
# ui.server(debug=True).run()
|
103
104
|
ui.webview().run()
|
104
105
|
```
|
105
106
|
|