fix(manacore/web): fix entity registration hang + registry type errors

- Make entity registration lazy (ensureEntitiesRegistered) to avoid
  circular imports at module load time
- Re-enable cross-module drop target in AppPage
- Fix Component type in app-registry to accept any props (AnyComponent)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-03 12:57:59 +02:00
parent d8ce4eaf34
commit e1077e261f
3 changed files with 25 additions and 10 deletions

View file

@ -9,9 +9,17 @@
import { getAppEntry } from './app-registry';
import type { Component } from 'svelte';
import { dropTarget } from '@manacore/shared-ui/dnd';
import { getEntity, getEntityByDragType, canDrop, executeDrop } from '$lib/entities';
import {
getEntity,
getEntityByDragType,
canDrop,
executeDrop,
ensureEntitiesRegistered,
} from '$lib/entities';
import type { DragPayload } from '@manacore/shared-ui/dnd';
ensureEntitiesRegistered();
interface Props {
appId: string;
widthPx: number;
@ -39,8 +47,8 @@
let appColor = $derived(appEntry?.color ?? '#6B7280');
// ── Cross-module drop target ────────────────────────────
// TODO: re-enable after fixing entity descriptor hang
let acceptedDropTypes: string[] = [];
let targetEntity = $derived(getEntity(appId));
let acceptedDropTypes = $derived(targetEntity?.acceptsDropFrom ?? []);
function handleCrossModuleDrop(payload: DragPayload) {
const sourceEntity = getEntityByDragType(payload.type);

View file

@ -5,10 +5,11 @@
* for in-panel navigation (detail, create, edit, etc.).
*/
import type { Component } from 'svelte';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type AnyComponent = import('svelte').Component<any, any>;
export interface ViewEntry {
load: () => Promise<{ default: Component }>;
load: () => Promise<{ default: AnyComponent }>;
}
export interface AppEntry {
@ -16,7 +17,7 @@ export interface AppEntry {
name: string;
color: string;
/** Default view loader (list/main view). */
load: () => Promise<{ default: Component }>;
load: () => Promise<{ default: AnyComponent }>;
/** Named views for in-panel navigation. Fallback: { list: load }. */
views?: Record<string, ViewEntry>;
}

View file

@ -11,7 +11,13 @@ export {
getAllEntities,
} from './registry';
// Register module entities (side-effect imports)
import '$lib/modules/todo/entity';
import '$lib/modules/calendar/entity';
import '$lib/modules/contacts/entity';
// Lazy entity registration — avoids circular imports at module load time.
let registered = false;
export function ensureEntitiesRegistered(): void {
if (registered) return;
registered = true;
import('$lib/modules/todo/entity');
import('$lib/modules/calendar/entity');
import('$lib/modules/contacts/entity');
}