| 1 |
import centered from './centered/manifest.json'; |
| 2 |
import choice from './choice/manifest.json'; |
| 3 |
import { globalManifests } from './global'; |
| 4 |
import modal from './modal/manifest.json'; |
| 5 |
import choicePage from './pages/choice.json'; |
| 6 |
import description from './pages/description.json'; |
| 7 |
import modalPage from './pages/modal.json'; |
| 8 |
import progress from './pages/progress.json'; |
| 9 |
import { idOf, mergeManifests } from './schema'; |
| 10 |
import split from './split/manifest.json'; |
| 11 |
import stacked from './stacked/manifest.json'; |
| 12 |
|
| 13 |
/** |
| 14 |
* Properties live in JSON beside their page so a tool outside the plugin reads |
| 15 |
* the same file the plugin does, rather than a second copy that drifts. |
| 16 |
* |
| 17 |
* Labels sit there untranslated on purpose: nothing in the flow renders them, |
| 18 |
* and a string in JSON cannot reach make-pot anyway. |
| 19 |
*/ |
| 20 |
export const descriptionManifests = () => [centered, split]; |
| 21 |
|
| 22 |
export const progressManifests = () => [stacked]; |
| 23 |
|
| 24 |
export const choiceManifests = () => [choice]; |
| 25 |
|
| 26 |
export const modalManifests = () => [modal]; |
| 27 |
|
| 28 |
const everyTemplate = () => [ |
| 29 |
...descriptionManifests(), |
| 30 |
...progressManifests(), |
| 31 |
...choiceManifests(), |
| 32 |
...modalManifests(), |
| 33 |
]; |
| 34 |
|
| 35 |
const PAGE_OF = { |
| 36 |
centered: 'description', |
| 37 |
split: 'description', |
| 38 |
stacked: 'progress', |
| 39 |
choice: 'choice', |
| 40 |
modal: 'modal', |
| 41 |
}; |
| 42 |
|
| 43 |
export const pageManifests = () => [ |
| 44 |
description, |
| 45 |
progress, |
| 46 |
choicePage, |
| 47 |
modalPage, |
| 48 |
]; |
| 49 |
|
| 50 |
const pageManifest = (page) => |
| 51 |
pageManifests().find((entry) => idOf(entry) === page); |
| 52 |
|
| 53 |
/** |
| 54 |
* Global, then the page, then the template. Nothing reads this at runtime — a |
| 55 |
* page reads its variables from the cascade — so it exists for a tool that has |
| 56 |
* to know what it may set, and for the contract test over the three levels. |
| 57 |
*/ |
| 58 |
export const resolvedFor = (template) => { |
| 59 |
const page = pageManifest(PAGE_OF[template]); |
| 60 |
const own = everyTemplate().find((entry) => idOf(entry) === template); |
| 61 |
return mergeManifests([ |
| 62 |
...globalManifests(), |
| 63 |
...(page ? [page] : []), |
| 64 |
...(own ? [own] : []), |
| 65 |
]); |
| 66 |
}; |
| 67 |
|