|
@@ -17,6 +17,7 @@ if TYPE_CHECKING:
|
|
class Component:
|
|
class Component:
|
|
key: str
|
|
key: str
|
|
name: str
|
|
name: str
|
|
|
|
+ path: Path
|
|
|
|
|
|
@property
|
|
@property
|
|
def tag(self) -> str:
|
|
def tag(self) -> str:
|
|
@@ -32,7 +33,7 @@ class VueComponent(Component):
|
|
|
|
|
|
@dataclass(**KWONLY_SLOTS)
|
|
@dataclass(**KWONLY_SLOTS)
|
|
class JsComponent(Component):
|
|
class JsComponent(Component):
|
|
- path: Path
|
|
|
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
|
@dataclass(**KWONLY_SLOTS)
|
|
@dataclass(**KWONLY_SLOTS)
|
|
@@ -61,11 +62,16 @@ def register_vue_component(location: Path, base_path: Path = Path(__file__).pare
|
|
"""
|
|
"""
|
|
path, key, name, suffix = deconstruct_location(location, base_path)
|
|
path, key, name, suffix = deconstruct_location(location, base_path)
|
|
if suffix == '.vue':
|
|
if suffix == '.vue':
|
|
|
|
+ if key in vue_components and vue_components[key].path == path:
|
|
|
|
+ return vue_components[key]
|
|
assert key not in vue_components, f'Duplicate VUE component {key}'
|
|
assert key not in vue_components, f'Duplicate VUE component {key}'
|
|
build = vbuild.VBuild(name, path.read_text())
|
|
build = vbuild.VBuild(name, path.read_text())
|
|
- vue_components[key] = VueComponent(key=key, name=name, html=build.html, script=build.script, style=build.style)
|
|
|
|
|
|
+ vue_components[key] = VueComponent(key=key, name=name, path=path,
|
|
|
|
+ html=build.html, script=build.script, style=build.style)
|
|
return vue_components[key]
|
|
return vue_components[key]
|
|
if suffix == '.js':
|
|
if suffix == '.js':
|
|
|
|
+ if key in js_components and js_components[key].path == path:
|
|
|
|
+ return js_components[key]
|
|
assert key not in js_components, f'Duplicate JS component {key}'
|
|
assert key not in js_components, f'Duplicate JS component {key}'
|
|
js_components[key] = JsComponent(key=key, name=name, path=path)
|
|
js_components[key] = JsComponent(key=key, name=name, path=path)
|
|
return js_components[key]
|
|
return js_components[key]
|
|
@@ -83,6 +89,8 @@ def register_library(location: Path, base_path: Path = Path(__file__).parent / '
|
|
"""
|
|
"""
|
|
path, key, name, suffix = deconstruct_location(location, base_path)
|
|
path, key, name, suffix = deconstruct_location(location, base_path)
|
|
if suffix in {'.js', '.mjs'}:
|
|
if suffix in {'.js', '.mjs'}:
|
|
|
|
+ if key in libraries and libraries[key].path == path:
|
|
|
|
+ return libraries[key]
|
|
assert key not in libraries, f'Duplicate js library {key}'
|
|
assert key not in libraries, f'Duplicate js library {key}'
|
|
libraries[key] = Library(key=key, name=name, path=path, expose=expose)
|
|
libraries[key] = Library(key=key, name=name, path=path, expose=expose)
|
|
return libraries[key]
|
|
return libraries[key]
|