@uniweb/build 1.16.0 → 1.16.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/build",
3
- "version": "1.16.0",
3
+ "version": "1.16.2",
4
4
  "description": "Build tooling for the Uniweb Component Web Platform",
5
5
  "type": "module",
6
6
  "exports": {
@@ -56,12 +56,12 @@
56
56
  "js-yaml": "^4.3.2",
57
57
  "sharp": "^0.35.5",
58
58
  "yaml": "^2.5.0",
59
+ "@uniweb/schemas": "~1.6.10",
59
60
  "@uniweb/content-reader": "~1.5.9",
61
+ "@uniweb/theming": "~1.2.1",
60
62
  "@uniweb/content-writer": "~1.3.1",
61
- "@uniweb/projections": "~1.2.11",
62
- "@uniweb/schemas": "~1.6.8",
63
63
  "@uniweb/semantic-parser": "~1.13.2",
64
- "@uniweb/theming": "~1.2.1"
64
+ "@uniweb/projections": "~1.2.11"
65
65
  },
66
66
  "optionalDependencies": {
67
67
  "@uniweb/runtime": "~1.4.5"
@@ -13,6 +13,8 @@
13
13
  * - defaults: param default values
14
14
  * - context: static capabilities for cross-block coordination
15
15
  * - initialState: initial values for mutable block state
16
+ * - header: true when the component draws the parser's pretitle, title and subtitle as its own
17
+ * header, false when it draws the section as written; absent when it declares no content
16
18
  *
17
19
  * ⭐ `data:` IS THE DELIVERY — ruled 2026-09-14 [Diego]: a section's `content.data` holds
18
20
  * the keys its component declares and nothing else, and which fetch fills each is worked
@@ -35,7 +37,7 @@
35
37
  * for the visual editor.
36
38
  */
37
39
 
38
- import { lowerData } from '@uniweb/schemas/content'
40
+ import { describeContent, lowerData } from '@uniweb/schemas/content'
39
41
  import { schemaDeclarationOf } from '@uniweb/schemas/foundation'
40
42
  import { stickyDeclaration } from '@uniweb/schemas/section'
41
43
 
@@ -211,9 +213,22 @@ export function extractRuntimeSchema(fullMeta) {
211
213
  runtime.initialState = fullMeta.initialState
212
214
  }
213
215
 
216
+ // ⭐ WHETHER THE COMPONENT DRAWS THE PARSER'S HEADER ITSELF. A type whose `content:` declares a
217
+ // pretitle, a title or a subtitle draws them as its header, not as headings of the page (`true`).
218
+ // One that declares a `sequence` and none of them draws the section as written (`false`). kit's
219
+ // contents rail reads it (`useHeadings`): a site's default section type can be either, and a rail
220
+ // entry for a header line would name an anchor the page doesn't have. Absent otherwise, since
221
+ // nothing is known: no content declared, or only what says nothing of either.
222
+ const declared = new Set(describeContent(fullMeta).elements.map((e) => e.element))
223
+ if ([...HEADER_ELEMENTS].some((element) => declared.has(element))) runtime.header = true
224
+ else if (declared.has('sequence')) runtime.header = false
225
+
214
226
  return Object.keys(runtime).length > 0 ? runtime : null
215
227
  }
216
228
 
229
+ /** The parser's fields a component draws as its header when its `content:` declares them. */
230
+ const HEADER_ELEMENTS = new Set(['pretitle', 'title', 'subtitle'])
231
+
217
232
  /**
218
233
  * Extract runtime schemas for all components
219
234
  *
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) {