@uniweb/build 1.16.0 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/schema.js +48 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"sharp": "^0.35.5",
|
|
58
58
|
"yaml": "^2.5.0",
|
|
59
59
|
"@uniweb/content-reader": "~1.5.9",
|
|
60
|
-
"@uniweb/content-writer": "~1.3.1",
|
|
61
|
-
"@uniweb/projections": "~1.2.11",
|
|
62
|
-
"@uniweb/schemas": "~1.6.8",
|
|
63
60
|
"@uniweb/semantic-parser": "~1.13.2",
|
|
64
|
-
"@uniweb/
|
|
61
|
+
"@uniweb/schemas": "~1.6.10",
|
|
62
|
+
"@uniweb/theming": "~1.2.1",
|
|
63
|
+
"@uniweb/content-writer": "~1.3.1",
|
|
64
|
+
"@uniweb/projections": "~1.2.11"
|
|
65
65
|
},
|
|
66
66
|
"optionalDependencies": {
|
|
67
67
|
"@uniweb/runtime": "~1.4.5"
|
package/src/schema.js
CHANGED
|
@@ -17,7 +17,7 @@ import { isFontVar } from '@uniweb/theming'
|
|
|
17
17
|
import { join, dirname, extname, basename, relative, resolve } from 'node:path'
|
|
18
18
|
import { pathToFileURL } from 'node:url'
|
|
19
19
|
import { jsxInJsMessage } from './jsx-extension.js'
|
|
20
|
-
import { describeChildren, describeVisuals, lowerChildren } from '@uniweb/schemas/component'
|
|
20
|
+
import { areaNames, describeChildren, describePlacement, describeVisuals, lowerChildren } from '@uniweb/schemas/component'
|
|
21
21
|
import { describeContent, lowerData } from '@uniweb/schemas/content'
|
|
22
22
|
import { normalizeData, schemaDeclarationOf } from '@uniweb/schemas/foundation'
|
|
23
23
|
import { rootListSection } from '@uniweb/schemas/conform'
|
|
@@ -653,6 +653,7 @@ function buildComponentEntry(name, relativePath, meta) {
|
|
|
653
653
|
if (meta.data !== undefined) entry.data = lowerData(meta.data)
|
|
654
654
|
refuseDataDeclarations(`${name} (meta.js)`, entry.data)
|
|
655
655
|
refuseStickyDeclaration(`${name} (meta.js)`, meta.sticky)
|
|
656
|
+
refuseAreaDeclaration(`${name} (meta.js)`, meta.area)
|
|
656
657
|
|
|
657
658
|
const problems = [...content.problems, ...describeChildren(meta).problems]
|
|
658
659
|
if (problems.length > 0) loweringProblems.set(entry, problems)
|
|
@@ -676,6 +677,51 @@ function refuseStickyDeclaration(owner, sticky) {
|
|
|
676
677
|
}
|
|
677
678
|
}
|
|
678
679
|
|
|
680
|
+
/**
|
|
681
|
+
* Refuse a section type's `area:` that `areaNames` cannot read — anything but `true`, `false`, an
|
|
682
|
+
* area's name or a list of names. A refusal, not a warning: an editor reads such a value as no
|
|
683
|
+
* area, and would offer the type among a page's sections, the opposite of what was meant.
|
|
684
|
+
*
|
|
685
|
+
* @param {string} owner - who declares it, for the message
|
|
686
|
+
* @param {*} area - the `area:` value, as written
|
|
687
|
+
*/
|
|
688
|
+
function refuseAreaDeclaration(owner, area) {
|
|
689
|
+
try {
|
|
690
|
+
areaNames(area)
|
|
691
|
+
} catch (err) {
|
|
692
|
+
throw new Error(`[uniweb] ${owner}: ${err.message}`)
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Warn about a section type whose `area:` names an area none of this foundation's layouts draws:
|
|
698
|
+
* an editor offers a type for the areas it names, and no page would have that one. What a layout
|
|
699
|
+
* draws is what its `meta.js` declares in `areas:`. Nothing is said for an extension, whose host's
|
|
700
|
+
* layouts it cannot see, for a foundation with no layouts, or when any layout declares no `areas`,
|
|
701
|
+
* since that one could draw any. A warning, never a refusal: the type still renders wherever an
|
|
702
|
+
* author places it.
|
|
703
|
+
*
|
|
704
|
+
* @param {Object} components - discovered section types, by name
|
|
705
|
+
* @param {Object} [layouts] - discovered layouts, by name
|
|
706
|
+
* @param {Object} [options]
|
|
707
|
+
* @param {boolean} [options.isExtension]
|
|
708
|
+
*/
|
|
709
|
+
export function reportAreaNames(components, layouts = {}, { isExtension = false } = {}) {
|
|
710
|
+
const all = Object.values(layouts || {})
|
|
711
|
+
if (isExtension || all.length === 0 || all.some((layout) => !Array.isArray(layout?.areas))) return
|
|
712
|
+
const drawn = new Set(all.flatMap((layout) => layout.areas))
|
|
713
|
+
for (const [name, entry] of Object.entries(components)) {
|
|
714
|
+
for (const area of describePlacement(entry).areas || []) {
|
|
715
|
+
if (drawn.has(area)) continue
|
|
716
|
+
console.warn(
|
|
717
|
+
`Warning: ${name} (meta.js): area names "${area}", which none of this foundation's layouts draws ` +
|
|
718
|
+
`(they declare ${[...drawn].join(', ')}). An editor offers the type only where an author fills an ` +
|
|
719
|
+
`area it names. Name one of those, or add "${area}" to the areas: of the layout that draws it.`
|
|
720
|
+
)
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
679
725
|
/**
|
|
680
726
|
* Refuse a `data:` key typed by a schema that is not written as one: the retired `/*` suffix, a
|
|
681
727
|
* property of the long form other than `schema`, `single` and `whole`, or a flag that is not a
|
|
@@ -1284,6 +1330,7 @@ export async function buildSchema(srcDir, sectionPaths, derivedSupports = null)
|
|
|
1284
1330
|
|
|
1285
1331
|
// Determine extension role
|
|
1286
1332
|
const isExtension = !!foundationConfig.extension
|
|
1333
|
+
reportAreaNames(components, layouts, { isExtension })
|
|
1287
1334
|
|
|
1288
1335
|
// Warn if extension declares things it shouldn't
|
|
1289
1336
|
if (isExtension) {
|