@uniweb/build 1.17.1 → 1.18.0

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.17.1",
3
+ "version": "1.18.0",
4
4
  "description": "Build tooling for the Uniweb Component Web Platform",
5
5
  "type": "module",
6
6
  "exports": {
@@ -56,15 +56,15 @@
56
56
  "js-yaml": "^4.3.2",
57
57
  "sharp": "^0.35.5",
58
58
  "yaml": "^2.5.0",
59
- "@uniweb/content-writer": "~1.3.1",
60
59
  "@uniweb/content-reader": "~1.5.9",
60
+ "@uniweb/schemas": "~1.6.11",
61
+ "@uniweb/theming": "~1.3.0",
61
62
  "@uniweb/semantic-parser": "~1.13.2",
62
- "@uniweb/schemas": "~1.6.10",
63
- "@uniweb/projections": "~1.2.11",
64
- "@uniweb/theming": "~1.2.1"
63
+ "@uniweb/projections": "~1.2.12",
64
+ "@uniweb/content-writer": "~1.3.1"
65
65
  },
66
66
  "optionalDependencies": {
67
- "@uniweb/runtime": "~1.4.5"
67
+ "@uniweb/runtime": "~1.5.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
@@ -73,8 +73,8 @@
73
73
  "@tailwindcss/vite": "^4.0.0",
74
74
  "@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
75
75
  "vite-plugin-svgr": "^4.0.0",
76
- "@uniweb/core": "~1.6.4",
77
- "@uniweb/runtime": "~1.4.5"
76
+ "@uniweb/core": "~1.6.6",
77
+ "@uniweb/runtime": "~1.5.0"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "vite": {
@@ -131,6 +131,30 @@ const SETS_ITS_ROOT = /@import\s+["']tailwindcss[^"']*["'][^;]*\bsource\(/
131
131
  // with that name (`className: { type: 'string' }`).
132
132
  const WRITES_CLASSES = /\bclassName\s*(?:=\s*\{[^}]*["'`]|[=:]\s*["'`])|\bcn\(|\bclass=["']/
133
133
 
134
+ // Or classes kept in a string, for code that hands them out: a colour's classes in a map,
135
+ // `{ amber: 'text-amber-600 bg-amber-50' }`, which a component in another folder then writes.
136
+ // ⚖️ A string counts when a class in it has a shade (`text-amber-600`) or an arbitrary value
137
+ // (`w-[42px]`), or when two of its words are classes and one has a number in it (`rounded-xl p-6`) —
138
+ // not a word with hyphens, an icon's name (`lu-house`) or a status (`to-verify`).
139
+ // ⛔ Until 2026-11-06 only a class written in place counted, so a `utils/` folder holding such a map
140
+ // was never named, and a site's CSS was missing its classes: an amber icon came out grey.
141
+ const STRING = /(["'`])((?:\\.|(?!\1)[^\\\n])*)\1/g
142
+ const SHADE = /^!?(?:[\w-]+:)*-?(?:bg|text|border|ring|fill|stroke|from|via|to|outline|divide|accent|caret|decoration|shadow|placeholder)-[a-z]+-(?:50|[1-9]00|950)(?:\/\d+)?$/
143
+ const ARBITRARY = /^!?(?:[\w-]+:)*-?[a-z]+(?:-[a-z]+)*-\[[^\]\s]+\]$/
144
+ const UTILITY = /^!?(?:[\w-]+:)*-?[a-z]+(?:-[\w./[\]#%]+)+$/
145
+
146
+ /** Whether code writes a class, or keeps one in a string. */
147
+ function writesClasses(code) {
148
+ if (WRITES_CLASSES.test(code)) return true
149
+ for (const [, , text] of code.matchAll(STRING)) {
150
+ const words = text.trim().split(/\s+/)
151
+ if (words.some((word) => SHADE.test(word) || ARBITRARY.test(word))) return true
152
+ const classes = words.filter((word) => UTILITY.test(word))
153
+ if (classes.length >= 2 && classes.some((word) => /\d/.test(word))) return true
154
+ }
155
+ return false
156
+ }
157
+
134
158
  const NOT_THE_FOUNDATIONS_CODE = new Set(['node_modules', 'dist', 'public', 'test', 'tests', '__tests__'])
135
159
 
136
160
  function codeFiles(dir, found = []) {
@@ -205,7 +229,7 @@ export function unreadFolders(stylesPath) {
205
229
  const unread = new Map()
206
230
  for (const file of codeFiles(dir)) {
207
231
  if (read.some((path) => file === path || file.startsWith(path + sep))) continue
208
- if (!WRITES_CLASSES.test(withoutComments(readFileSync(file, 'utf8')))) continue
232
+ if (!writesClasses(withoutComments(readFileSync(file, 'utf8')))) continue
209
233
  const [top, ...below] = relative(dir, file).split(sep)
210
234
  const entry = unread.get(top) ?? { path: top, files: 0, isFolder: below.length > 0, typed: false }
211
235
  entry.files++
package/src/prerender.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  deriveCacheKey,
24
24
  evaluateQuery,
25
25
  } from '@uniweb/core'
26
- import { isDynamicRoute, recordTitle, recordImage, routePatternToRegex, routeFieldOf } from '@uniweb/core/route-match'
26
+ import { isDynamicRoute, recordTitle, recordImage, recordDescription, routePatternToRegex, routeFieldOf } from '@uniweb/core/route-match'
27
27
  import DataStore from '@uniweb/core/datastore'
28
28
  import { DEFAULT_ICON_BASE } from '@uniweb/core/icon-corpus'
29
29
  import { executeFetch, mergeDataIntoContent, toFetchList } from './site/data-fetcher.js'
@@ -483,7 +483,11 @@ export function expandDynamicPages(pages, fetched, onProgress = () => {}, stats
483
483
  // `title` alone, so a person record's page kept the template's own title.
484
484
  const title = recordTitle(item)
485
485
  if (title) concretePage.title = title
486
- if (item.description || item.excerpt) concretePage.description = item.description || item.excerpt
486
+ // Described by the SPA's rule too (`recordDescription`): text only. ⛔ Until 2026-11-06 a
487
+ // rich-text `description` was taken as it came, and the page's meta description read
488
+ // `[object Object]`.
489
+ const description = recordDescription(item)
490
+ if (description) concretePage.description = description
487
491
  // ⭐ And its picture is what a link to the page shows (`recordImage`) — the SPA's rule.
488
492
  const image = recordImage(item)
489
493
  if (image) concretePage.seo = { ...(concretePage.seo || {}), image }
@@ -39,7 +39,7 @@
39
39
 
40
40
  import { describeContent, lowerData } from '@uniweb/schemas/content'
41
41
  import { schemaDeclarationOf } from '@uniweb/schemas/foundation'
42
- import { stickyDeclaration } from '@uniweb/schemas/section'
42
+ import { stickyDeclaration, underHeaderDeclaration, heightDeclaration } from '@uniweb/schemas/section'
43
43
 
44
44
  /**
45
45
  * A `data:` entry as the runtime reads it: its schema ref, with the flags set on it — or null for an
@@ -147,6 +147,16 @@ export function extractRuntimeSchema(fullMeta) {
147
147
  }
148
148
  }
149
149
 
150
+ // Whether the header lies over the section when it opens a page, unless its author says
151
+ // otherwise (`Block#initComponent`), and a header type's height for that page's first paint,
152
+ // before the browser measures it. The runtime reads both in each renderer (`under-header.js`).
153
+ try {
154
+ if (fullMeta.underHeader !== undefined) runtime.underHeader = underHeaderDeclaration(fullMeta.underHeader)
155
+ if (fullMeta.height !== undefined) runtime.height = heightDeclaration(fullMeta.height)
156
+ } catch (err) {
157
+ throw new Error(`[uniweb] ${err.message}`)
158
+ }
159
+
150
160
  // Data. `data:` is the single declaration surface for a section's structured
151
161
  // data: it maps each `content.data` key to its schema. A value is a named ref
152
162
  // (`'@/member'`), an inline field map, or an inline rich-form (`{ fields: [...] }`,
package/src/schema.js CHANGED
@@ -21,7 +21,7 @@ import { areaNames, describeChildren, describePlacement, describeVisuals, lowerC
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'
24
- import { SECTION_PARAMS, SECTION_KEYS, stickyDeclaration } from '@uniweb/schemas/section'
24
+ import { SECTION_PARAMS, SECTION_KEYS, stickyDeclaration, underHeaderDeclaration, heightDeclaration } from '@uniweb/schemas/section'
25
25
  import { collectSchemaRefs, buildDataSchemaMap, ownSchemaRefs } from './resolve-data-schema.js'
26
26
  import {
27
27
  composeSupports,
@@ -653,6 +653,8 @@ 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
+ refuseDeclaration(`${name} (meta.js)`, underHeaderDeclaration, meta.underHeader)
657
+ refuseDeclaration(`${name} (meta.js)`, heightDeclaration, meta.height)
656
658
  refuseAreaDeclaration(`${name} (meta.js)`, meta.area)
657
659
 
658
660
  const problems = [...content.problems, ...describeChildren(meta).problems]
@@ -677,6 +679,23 @@ function refuseStickyDeclaration(owner, sticky) {
677
679
  }
678
680
  }
679
681
 
682
+ /**
683
+ * Refuse a declaration its one rule cannot read — `underHeader`, `height` (`@uniweb/schemas/section`) —
684
+ * naming the component. Nothing declared, nothing checked.
685
+ *
686
+ * @param {string} owner - who declares it, for the message
687
+ * @param {(declared: *) => *} rule
688
+ * @param {*} declared - the value, as written
689
+ */
690
+ function refuseDeclaration(owner, rule, declared) {
691
+ if (declared === undefined) return
692
+ try {
693
+ rule(declared)
694
+ } catch (err) {
695
+ throw new Error(`[uniweb] ${owner}: ${err.message}`)
696
+ }
697
+ }
698
+
680
699
  /**
681
700
  * Refuse a section type's `area:` that `areaNames` cannot read — anything but `true`, `false`, an
682
701
  * area's name or a list of names. A refusal, not a warning: an editor reads such a value as no