feat(composite): enhance service loading for multiple exports
This commit is contained in:
parent
c47cf1e338
commit
38ec75d19b
@ -72,7 +72,6 @@
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function getServiceProps(component) {
|
||||
const loadedServices = [];
|
||||
if (component.services) {
|
||||
@ -89,15 +88,15 @@
|
||||
|
||||
<div class="grid w-full h-full" style="display: grid; {componentsData.layout || ''}">
|
||||
{#each componentsData.children as component (component.id)}
|
||||
{#await Promise.all( [getComponent(component.componentName), getServiceProps(component)] ) then [Component, loadedServices]}
|
||||
{#await Promise.all( [getComponent(component.componentName), getServiceProps(component)] ) then [Component, serviceProps]}
|
||||
{#if Component}
|
||||
<div class="w-full h-full overflow-hidden {component.slot}">
|
||||
<svelte:component
|
||||
this={Component}
|
||||
id={component.id}
|
||||
{...component.props}
|
||||
{...loadedServices.reduce((acc, currFn, idx) => {
|
||||
acc[component.services[idx]] = currFn;
|
||||
{...serviceProps.reduce((acc, currServiceModule, idx) => {
|
||||
acc[component.services[idx]] = currServiceModule;
|
||||
return acc;
|
||||
}, {})}
|
||||
/>
|
||||
|
@ -31,6 +31,7 @@
|
||||
onMount(async () => {
|
||||
try {
|
||||
provider = await setupLitProvider.setupLitProvider();
|
||||
setupLitProvider.alertMe();
|
||||
|
||||
logMessage('Component mounted.');
|
||||
|
||||
|
@ -7,10 +7,7 @@
|
||||
const store = getComponentStore(id);
|
||||
$: console.log('store:', $store);
|
||||
|
||||
export let messages;
|
||||
|
||||
onMount(async () => {
|
||||
console.log('messages: ' + JSON.stringify(messages));
|
||||
console.log('hello Earth');
|
||||
});
|
||||
</script>
|
||||
|
@ -28,3 +28,7 @@ export async function setupLitProvider() {
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
export function alertMe() {
|
||||
alert("hello")
|
||||
}
|
@ -4,7 +4,7 @@ const services = {};
|
||||
|
||||
serviceNames.forEach(path => {
|
||||
const name = path.split('/').pop().replace('.ts', ''); // Extract just the file name from the path without .ts
|
||||
services[name] = () => import(/* @vite-ignore */ `/src/lib/services/${path}`);
|
||||
services[name] = () => import(/* @vite-ignore */ `/src/lib/services/${path}`).then(mod => mod);
|
||||
});
|
||||
|
||||
export default services;
|
||||
export default services;
|
||||
|
@ -13,8 +13,7 @@
|
||||
{
|
||||
id: 'authsig',
|
||||
componentName: 'HelloEarth',
|
||||
slot: 'hello',
|
||||
services: ['messages']
|
||||
slot: 'hello'
|
||||
},
|
||||
// {
|
||||
// id: 'wallet1',
|
||||
|
Loading…
Reference in New Issue
Block a user