[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationComponents

Components

How registered components get their global name, how a module prefix avoids collisions, how a module replaces another module's component, and the SVG caveat.

Every component a module registers joins the global components of the application. It resolves by name anywhere, in templates and in the page trees the backend sends.

resolveDmsComponent resolves a registered component in code. It is imported from #dms/frontend-module:

ts
import { resolveDmsComponent } from "#dms/frontend-module";

const Banner = resolveDmsComponent("AcmeBanner");

Component prefix

A module declares a componentPrefix so that its components never collide with another module's. The prefix goes in front of the name of every component the module registers:

dms.frontend.ts ts
const frontendModule: DmsFrontendModule = {
  componentPrefix: "Acme",
  setup(sdk) {
    sdk.registerComponent("Banner", Banner); // registered as AcmeBanner
  },
};

A template uses the full name, prefix included (<AcmeBanner>), and so does the backend (CustomComponent("AcmeBanner"), or acme-banner). Name matching ignores case, a leading lazy and every non-alphanumeric character. A leading Dms is kept, because it is the prefix of the DMS module itself.

Collisions and replacements

When two modules register the same name, the module of higher priority keeps it, and a warning names both. A module that replaces another module's component registers the full name without its own prefix. That replacement produces no warning:

dms.frontend.ts ts
sdk.registerComponent("AcmeBanner", MyBanner, { prefix: false });

Private code

The app/build/ directory of a module is never auto-imported. Its components are registered so that backend pages can name them, but they are internals of the module and not an API for other modules. See Auto-imports.

Page loading state

After a client navigation, the page renders under a <Suspense> until its chunk and any async setup resolve. Meanwhile useDmsPageLoading(), an auto-import, is true. A layout can read it to show its own placeholder instead of an empty page body:

layouts/AppLayout.vue vue
<script setup lang="ts">
const pageLoading = useDmsPageLoading();
</script>

<template>
  <slot />
  <PageSkeleton v-if="pageLoading" />
</template>

It stays false on the server and during hydration, which both render the resolved page. It also stays false for a page that does not suspend, and it returns to false once a pending page is left.

Components rendered inside an svg

Modules usually register their components lazily, with defineAsyncComponent, and the page renders under a <Suspense>. Vue mounts an async component that resolves under a <Suspense> with the element namespace of the <Suspense>, not the namespace of the place where it renders. A component resolved by name whose root is an SVG element, such as <path> or <g>, is then created as an HTML element inside the <svg>, and the browser draws nothing (vuejs/core#15639).

Such components are imported directly instead. The node and edge types passed to Vue Flow are one example:

ts
import { markRaw } from "vue";
import RelationEdge from "./RelationEdge.vue";

const edgeTypes = markRaw({ relation: RelationEdge });