Publish composes edges into manifest.json at the bundle level
Some checks are pending
build-gate / build (push) Waiting to run

Bundles that declare composition in their profile meta.json (composes:
[...]) now carry that array on the manifest's bundle object, so a
consumer like the plugin studio can render the composition tree without
re-deriving it. 7 bundles affected: big-picture, dashboard-plus-grid,
research-map-plus-grid, my-upg-100-list, stack-demo, doxa-maps-spa,
plugin-studio. Omitted for bundles with no composed children.
This commit is contained in:
doxa-maps-88655c70 2026-09-23 17:51:17 +00:00
parent eb95d02597
commit 7917cbdd7e
3 changed files with 68 additions and 1 deletions

View file

@ -329,6 +329,22 @@ function composesAMapLeaf(dir, profileName, file) {
} catch { return false }
}
/**
* The RAW `composes` array a profile declares in its own <profile>.meta.json, or null when
* the profile declares none / the file is absent / malformed. This is the same source
* composesAMapLeaf reads (see its point 1) but returns the author's data itself rather than
* a map-ness boolean derived from it — the manifest needs the edges, not just the verdict.
*/
function readComposes(dir, profileName) {
try {
const metaPath = join(dir, `${profileName}.meta.json`)
if (!existsSync(metaPath)) return null
const meta = JSON.parse(readFileSync(metaPath, 'utf8'))
const composes = Array.isArray(meta?.composes) ? meta.composes.map((c) => String(c)).filter(Boolean) : []
return composes.length ? composes : null
} catch { return null }
}
/** Element tag names a bundle registers, read from its index.js (order preserved). */
function extractElements(indexJsPath) {
if (!existsSync(indexJsPath)) return []
@ -1122,6 +1138,16 @@ function scanBundles() {
profiles.sort((a, b) =>
(PROTOTYPE_RE.test(a.profile) ? 1 : 0) - (PROTOTYPE_RE.test(b.profile) ? 1 : 0))
// Bundle-level composition edges: the union of every profile's own <profile>.meta.json
// `composes` (most bundles carry exactly one profile that declares it; my-upg-100-list is
// the one bundle with several profiles, only one of which — upg-100-mfe — composes). Union,
// not "first wins", so a future bundle with more than one composing profile still publishes
// every edge. Read straight from vueFiles (not the `profiles` array above) so this stays the
// ONE place `composes` is published — at the bundle level only, matching the manifest shape.
// Omitted entirely when no profile in the bundle declares composes (no empty array).
const bundleComposes = vueFiles.flatMap((file) => readComposes(dir, file.replace(/\.vue$/, '')) || [])
const composesUnique = [...new Set(bundleComposes)]
bundles.push({
bundle: entry,
// Absolute-or-root-relative URL to the bundle IIFE (paste-anywhere).
@ -1129,6 +1155,7 @@ function scanBundles() {
output: `${TREE_NAME}/${entry}/${entry}.js`,
integrity,
elements: bundleElements,
...(composesUnique.length ? { composes: composesUnique } : {}),
profiles,
})
}

File diff suppressed because one or more lines are too long

View file

@ -41,6 +41,10 @@
"bp-research-header",
"people-groups-grid"
],
"composes": [
"bp-research-header",
"people-groups-grid"
],
"profiles": [
{
"profile": "big-picture",
@ -193,6 +197,10 @@
"elements": [
"dashboard-plus-grid"
],
"composes": [
"research-dashboard",
"people-groups-grid"
],
"profiles": [
{
"profile": "dashboard-plus-grid",
@ -276,6 +284,14 @@
"elements": [
"doxa-maps-spa"
],
"composes": [
"bp-big-picture",
"doxa-research-map",
"doxa-simple-map",
"cities-internet-map",
"gospel-resources-map",
"my-upg-100-list-map"
],
"profiles": [
{
"profile": "doxa-maps-spa",
@ -611,6 +627,10 @@
"elements": [
"my-upg-100-list-map"
],
"composes": [
"my-upg-100-list/upg-100-list",
"my-upg-100-list/poster-wall"
],
"profiles": [
{
"profile": "poster-wall",
@ -725,6 +745,18 @@
"elements": [
"plugin-studio"
],
"composes": [
"bp-big-picture",
"people-groups-grid",
"doxa-research-map",
"doxa-simple-map",
"cities-internet-map",
"gospel-resources-map",
"my-upg-100-list-map",
"doxa-vision-card",
"all-people-groups",
"research-dashboard"
],
"profiles": [
{
"profile": "plugin-studio",
@ -844,6 +876,10 @@
"elements": [
"research-map-plus-grid"
],
"composes": [
"doxa-research-map",
"people-groups-grid"
],
"profiles": [
{
"profile": "research-map-plus-grid",
@ -884,6 +920,10 @@
"elements": [
"stack-demo"
],
"composes": [
"research-dashboard-map",
"people-groups-grid"
],
"profiles": [
{
"profile": "stack-demo",