funcnodes-react-flow 0.3.12__py3-none-any.whl → 0.3.14__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.
- funcnodes_react_flow/__init__.py +17 -28
- funcnodes_react_flow/plugin_setup.py +43 -0
- funcnodes_react_flow/static/css/style.css +1 -1755
- funcnodes_react_flow/static/js/index.js +28 -17
- funcnodes_react_flow/static/js/index.js.map +1 -1
- {funcnodes_react_flow-0.3.12.dist-info → funcnodes_react_flow-0.3.14.dist-info}/METADATA +3 -2
- {funcnodes_react_flow-0.3.12.dist-info → funcnodes_react_flow-0.3.14.dist-info}/RECORD +10 -9
- {funcnodes_react_flow-0.3.12.dist-info → funcnodes_react_flow-0.3.14.dist-info}/entry_points.txt +3 -0
- {funcnodes_react_flow-0.3.12.dist-info → funcnodes_react_flow-0.3.14.dist-info}/LICENSE +0 -0
- {funcnodes_react_flow-0.3.12.dist-info → funcnodes_react_flow-0.3.14.dist-info}/WHEEL +0 -0
funcnodes_react_flow/__init__.py
CHANGED
@@ -1,22 +1,10 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import TypedDict, List
|
2
2
|
|
3
3
|
try:
|
4
4
|
from .run import run_server # noqa: F401
|
5
5
|
except ImportError:
|
6
6
|
pass
|
7
|
-
|
8
|
-
|
9
|
-
class ReactPlugin(TypedDict):
|
10
|
-
"""
|
11
|
-
A typed dictionary for a React plugin.
|
12
|
-
|
13
|
-
Attributes:
|
14
|
-
js (list[str]): A list of JavaScript files.
|
15
|
-
"""
|
16
|
-
|
17
|
-
js: list[str]
|
18
|
-
css: list[str]
|
19
|
-
module: str
|
7
|
+
from .plugin_setup import ReactPlugin, setup, FUNCNODES_REACT_PLUGIN
|
20
8
|
|
21
9
|
|
22
10
|
class ExpandedReactPlugin(TypedDict):
|
@@ -32,20 +20,6 @@ class ExpandedReactPlugin(TypedDict):
|
|
32
20
|
css: List[bytes]
|
33
21
|
|
34
22
|
|
35
|
-
FUNCNODES_REACT_PLUGIN: Dict[str, ReactPlugin] = {}
|
36
|
-
|
37
|
-
|
38
|
-
def add_react_plugin(name: str, plugin: ReactPlugin):
|
39
|
-
"""
|
40
|
-
Add a React plugin to the FUNCNODES_REACT_PLUGIN dictionary.
|
41
|
-
|
42
|
-
Args:
|
43
|
-
name (str): The name of the plugin.
|
44
|
-
plugin (ReactPlugin): The plugin to add.
|
45
|
-
"""
|
46
|
-
FUNCNODES_REACT_PLUGIN[str(name)] = plugin
|
47
|
-
|
48
|
-
|
49
23
|
def get_react_plugin_content(key: str) -> ExpandedReactPlugin:
|
50
24
|
"""
|
51
25
|
Get the content of a React plugin.
|
@@ -58,6 +32,9 @@ def get_react_plugin_content(key: str) -> ExpandedReactPlugin:
|
|
58
32
|
"""
|
59
33
|
key = str(key)
|
60
34
|
|
35
|
+
if key not in FUNCNODES_REACT_PLUGIN:
|
36
|
+
raise ValueError(f"React plugin {key} not found")
|
37
|
+
|
61
38
|
with open(FUNCNODES_REACT_PLUGIN[key]["module"], "rb") as f:
|
62
39
|
module = f.read()
|
63
40
|
resp: ExpandedReactPlugin = {"js": [], "module": module, "css": []}
|
@@ -71,3 +48,15 @@ def get_react_plugin_content(key: str) -> ExpandedReactPlugin:
|
|
71
48
|
with open(css, "rb") as f:
|
72
49
|
resp["css"].append(f.read())
|
73
50
|
return resp
|
51
|
+
|
52
|
+
|
53
|
+
setup()
|
54
|
+
|
55
|
+
|
56
|
+
__all__ = [
|
57
|
+
"run_server",
|
58
|
+
"ReactPlugin",
|
59
|
+
"FUNCNODES_REACT_PLUGIN",
|
60
|
+
"get_react_plugin_content",
|
61
|
+
"ReactPlugin",
|
62
|
+
]
|
@@ -0,0 +1,43 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
from funcnodes_core import plugins
|
3
|
+
|
4
|
+
|
5
|
+
class ReactPlugin(plugins.BasePlugin):
|
6
|
+
"""
|
7
|
+
A typed dictionary for a React plugin.
|
8
|
+
|
9
|
+
Attributes:
|
10
|
+
js (list[str]): A list of JavaScript files.
|
11
|
+
"""
|
12
|
+
|
13
|
+
js: list[str]
|
14
|
+
css: list[str]
|
15
|
+
|
16
|
+
|
17
|
+
FUNCNODES_REACT_PLUGIN: Dict[str, ReactPlugin] = {}
|
18
|
+
|
19
|
+
|
20
|
+
def add_react_plugin(name: str, plugin: ReactPlugin):
|
21
|
+
"""
|
22
|
+
Add a React plugin to the FUNCNODES_REACT_PLUGIN dictionary.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
name (str): The name of the plugin.
|
26
|
+
plugin (ReactPlugin): The plugin to add.
|
27
|
+
"""
|
28
|
+
FUNCNODES_REACT_PLUGIN[str(name)] = plugin
|
29
|
+
|
30
|
+
|
31
|
+
def plugin_function(installed_module: plugins.InstalledModule):
|
32
|
+
entry_points = installed_module.entry_points
|
33
|
+
mod = installed_module.module
|
34
|
+
|
35
|
+
if "react_plugin" in entry_points:
|
36
|
+
add_react_plugin(mod, entry_points["react_plugin"])
|
37
|
+
elif hasattr(mod, "REACT_PLUGIN"):
|
38
|
+
add_react_plugin(mod, mod.REACT_PLUGIN)
|
39
|
+
entry_points["react_plugin"] = mod.REACT_PLUGIN
|
40
|
+
|
41
|
+
|
42
|
+
def setup():
|
43
|
+
plugins.register_setup_plugin(plugin_function)
|