@uniweb/build 1.16.2 → 1.16.3

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.2",
3
+ "version": "1.16.3",
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",
60
59
  "@uniweb/content-reader": "~1.5.9",
61
- "@uniweb/theming": "~1.2.1",
62
60
  "@uniweb/content-writer": "~1.3.1",
61
+ "@uniweb/schemas": "~1.6.10",
62
+ "@uniweb/projections": "~1.2.11",
63
63
  "@uniweb/semantic-parser": "~1.13.2",
64
- "@uniweb/projections": "~1.2.11"
64
+ "@uniweb/theming": "~1.2.1"
65
65
  },
66
66
  "optionalDependencies": {
67
67
  "@uniweb/runtime": "~1.4.5"
package/src/schema.js CHANGED
@@ -694,28 +694,39 @@ function refuseAreaDeclaration(owner, area) {
694
694
  }
695
695
 
696
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.
697
+ * The areas the runtime's built-in layout draws (`runtime/src/default-layout.js`): a page renders with it
698
+ * when it names no layout and the foundation has no default one. Any other area is passed in and not drawn.
699
+ */
700
+ const BUILT_IN_LAYOUT_AREAS = ['header', 'footer']
701
+
702
+ /**
703
+ * Warn about a section type whose `area:` names an area no layout of this foundation draws: an editor
704
+ * offers a type for the areas it names, and no page would have that one. What a layout draws is what its
705
+ * `meta.js` declares in `areas:`. When the foundation has no default layout (`resolveDefaultLayout`), a
706
+ * page that names none renders with the built-in one, which draws the header and the footer, so those
707
+ * count too, and a foundation with no layouts has those alone. Nothing is said for an extension, whose
708
+ * host's layouts it cannot see, or when any layout declares no `areas`, since that one could draw any.
709
+ * A warning, never a refusal: the type still renders wherever an author places it.
710
+ * ⛔ Until 2026-11-05 the built-in layout was left out: a foundation with no layouts was never warned,
711
+ * a typo such as `area: 'heder'` included, and one whose layouts declare no header was warned for it.
703
712
  *
704
713
  * @param {Object} components - discovered section types, by name
705
714
  * @param {Object} [layouts] - discovered layouts, by name
706
715
  * @param {Object} [options]
707
716
  * @param {boolean} [options.isExtension]
717
+ * @param {string|null} [options.defaultLayout] - the layout a page that names none renders with, null for
718
+ * the built-in one
708
719
  */
709
- export function reportAreaNames(components, layouts = {}, { isExtension = false } = {}) {
720
+ export function reportAreaNames(components, layouts = {}, { isExtension = false, defaultLayout = null } = {}) {
710
721
  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))
722
+ if (isExtension || all.some((layout) => !Array.isArray(layout?.areas))) return
723
+ const drawn = new Set([...all.flatMap((layout) => layout.areas), ...(defaultLayout ? [] : BUILT_IN_LAYOUT_AREAS)])
713
724
  for (const [name, entry] of Object.entries(components)) {
714
725
  for (const area of describePlacement(entry).areas || []) {
715
726
  if (drawn.has(area)) continue
716
727
  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 ` +
728
+ `Warning: ${name} (meta.js): area names "${area}", which no layout of this foundation draws ` +
729
+ `(they draw ${[...drawn].join(', ')}). An editor offers the type only where an author fills an ` +
719
730
  `area it names. Name one of those, or add "${area}" to the areas: of the layout that draws it.`
720
731
  )
721
732
  }
@@ -1330,7 +1341,7 @@ export async function buildSchema(srcDir, sectionPaths, derivedSupports = null)
1330
1341
 
1331
1342
  // Determine extension role
1332
1343
  const isExtension = !!foundationConfig.extension
1333
- reportAreaNames(components, layouts, { isExtension })
1344
+ reportAreaNames(components, layouts, { isExtension, defaultLayout })
1334
1345
 
1335
1346
  // Warn if extension declares things it shouldn't
1336
1347
  if (isExtension) {
@@ -58,21 +58,36 @@ export function heldUnitsOf({ hashes = {}, uuids = {}, held = [] } = {}) {
58
58
  * @param {Object<string,string>} p.held - what the pull recorded (`heldUnitsOf`)
59
59
  * @param {object} [p.plain] - the same document before any media was rewritten; `doc` when absent
60
60
  * @param {string} [p.sourceLocale]
61
- * @returns {{ left: string[], changed: string[] }} the paths taken out, or the paths that changed
61
+ * @returns {{ left: string[], changed: string[], uuids: string[] }} the paths taken out, or the paths
62
+ * that changed; and the `$uuid` of every item taken out, nested ones included, which the push sends
63
+ * no version for
62
64
  */
63
65
  export function leaveHeldOut(doc, { held = {}, plain = null, sourceLocale } = {}) {
64
66
  const paths = Object.keys(held)
65
- if (!doc || !paths.length) return { left: [], changed: [] }
67
+ if (!doc || !paths.length) return { left: [], changed: [], uuids: [] }
66
68
  const now = computeUnitHashes(plain ?? doc, sourceLocale)
67
69
  const changed = new Set(paths.filter((path) => now[path] !== held[path]))
68
70
  const pages = paths.filter(isPageUnit).map(belowPage)
69
71
  for (const path of Object.keys(now)) if (!(path in held) && pages.some((p) => path.startsWith(p))) changed.add(path)
70
- if (changed.size) return { left: [], changed: [...changed].sort() }
72
+ if (changed.size) return { left: [], changed: [...changed].sort(), uuids: [] }
71
73
 
72
74
  const drop = new Set()
73
75
  walkSiteUnits(doc, (path, record) => {
74
76
  if (path in held) drop.add(record)
75
77
  }, sourceLocale)
78
+ // ⭐ WHAT IS TAKEN OUT IS SENT NO VERSION. The site-content entity sends every version this copy
79
+ // holds, and a version for an item the document leaves out makes leaving it out a deletion
80
+ // (`withBaseVersion`, `sync-package.js`). So every item taken out is named, the sections and child
81
+ // pages below a held page included, for the push to send none. ⛔ Until 2026-11-05 none was named:
82
+ // a forced push banked a version for each held page it sent, and the next push left the page out
83
+ // and sent that version, which deletes it.
84
+ const uuids = new Set()
85
+ const under = (record) => {
86
+ if (record?.$uuid) uuids.add(record.$uuid)
87
+ for (const s of record?.page_sections || []) under(s)
88
+ for (const c of record?.$children || []) under(c)
89
+ }
90
+ for (const record of drop) under(record)
76
91
  const keep = (list) => list.filter((r) => !drop.has(r))
77
92
  const sections = (list) => {
78
93
  for (const s of list || []) {
@@ -90,5 +105,5 @@ export function leaveHeldOut(doc, { held = {}, plain = null, sourceLocale } = {}
90
105
  }
91
106
  if (Array.isArray(doc.pages)) doc.pages = keep(doc.pages)
92
107
  walk(doc.pages)
93
- return { left: paths.sort(), changed: [] }
108
+ return { left: paths.sort(), changed: [], uuids: [...uuids].sort() }
94
109
  }
@@ -977,7 +977,7 @@ function placeOf(ctx, record, route, levelDir, levelMode, sourceLocale) {
977
977
  if (levelMode === 'pages') {
978
978
  if (record.is_dynamic) return { kind: 'cannot', what: ['a parametric page, which a route of single-section pages holds none of'] }
979
979
  const was = oldForm(ctx, record)
980
- if (was ? was !== 'pages' : record.mode !== SINGLE_SECTION) {
980
+ if (was ? was !== 'pages' : !isSingleSection(record)) {
981
981
  const name = unwrapLocalized(record.slug, sourceLocale)
982
982
  const what = mdPageCannotHold(record, { name, sourceLocale })
983
983
  return what.length ? { kind: 'cannot', what } : { kind: 'md', file: join(levelDir, `${name}.md`), dir: levelDir }
@@ -990,13 +990,30 @@ function placeOf(ctx, record, route, levelDir, levelMode, sourceLocale) {
990
990
  // `.md` page (`md`), or a folder read in folder mode (`pages`) or page mode (`sections`) where it was.
991
991
  // Null for a route new to them. Read before the move (`placeByUuid`), which takes the old place away.
992
992
  function oldForm(ctx, record) {
993
- const rel = record?.$uuid ? ctx?.oldIndex?.[record.$uuid] : null
994
- const old = rel ? join(ctx.siteRoot, rel) : null
993
+ const old = oldPlace(ctx, record?.$uuid)
995
994
  if (!old || !existsSync(old)) return null
996
995
  if (!statSync(old).isDirectory()) return 'md'
997
996
  return folderModeOf(old, ctx.files?.levelMode(dirname(old)) ?? 'sections')
998
997
  }
999
998
 
999
+ // Where the files kept an item before the app moved it: by the rename index this copy wrote, else, for
1000
+ // a page, at the route this copy's sync state last saw it at (`ctx.itemRoutes`). ⭐ A pull in a repository
1001
+ // has no rename index, so the route is all it goes by. ⛔ Until 2026-11-05 `oldForm` read the index alone,
1002
+ // and in a repository a moved route took the form of its `mode`.
1003
+ function oldPlace(ctx, uuid) {
1004
+ const rel = uuid ? ctx?.oldIndex?.[uuid] : null
1005
+ if (rel) return join(ctx.siteRoot, rel)
1006
+ const route = uuid ? ctx?.itemRoutes?.get(uuid) : null
1007
+ const place = route == null ? null : ctx?.files?.page(route)
1008
+ return place?.kind === 'md' ? place.file : place?.dir ?? null
1009
+ }
1010
+
1011
+ // ⭐ A route whose pages are single-section, in either spelling: `folder` is the one a push wrote until
1012
+ // 2026-11-04, which a stored document carries until its site's next push. A route new to the files takes
1013
+ // its form from this — in a fresh clone, every route. ⛔ Until 2026-11-05 only `single-section` read so,
1014
+ // and a clone of a site last pushed before then wrote its single-section routes in page mode.
1015
+ const isSingleSection = (record) => record?.mode === SINGLE_SECTION || record?.mode === 'folder'
1016
+
1000
1017
  // ⭐ A FOLDER'S FORM IS ITS FILES' WHERE THEY HOLD IT — folder mode (`pages`) or page mode (`sections`):
1001
1018
  // a mount's route by the mount, a folder the files hold by its own config, one the app moved by the form
1002
1019
  // it had. Only a route new to the files takes the form its `mode` asks for, a route the app made. ⛔ Until
@@ -1007,7 +1024,7 @@ function formOf(ctx, record, route, place, levelMode) {
1007
1024
  if (ctx.files?.page(route) === place) return ctx.files.levelMode(place.dir) ?? folderModeOf(place.dir, levelMode)
1008
1025
  const was = oldForm(ctx, record)
1009
1026
  if (was === 'pages' || was === 'sections') return was
1010
- return record.mode === SINGLE_SECTION ? 'pages' : 'sections'
1027
+ return isSingleSection(record) ? 'pages' : 'sections'
1011
1028
  }
1012
1029
 
1013
1030
  // ⭐ A FOLDER-MODE `.md` PAGE, WRITTEN BACK IN PLACE: the file is the page and its one section, so the
@@ -1854,9 +1871,13 @@ function seenPageRoutes(items) {
1854
1871
  * @param {string[]} [params.writableMounts] - the segments of the mounts the caller may write into: a
1855
1872
  * pull names each one it can merge into, a folder of the site's repository or of a submodule.
1856
1873
  * A caller that names none writes no mount
1874
+ * @param {Object<string,string>} [params.priorItems] - this copy's item identity (unit path → `$uuid`)
1875
+ * as it stood before the pull merged the pulled document's in: where each page was. A pull
1876
+ * passes it; without it the backend's state is read, which after that merge names a moved
1877
+ * page at both its routes
1857
1878
  * @returns {{ config: object, collections: object, locales: object, pages: string[], sections: string[], layout: string[], deleted: string[], renamed: object[] }}
1858
1879
  */
1859
- export function siteContentDocumentToProject({ document, siteRoot, backend = null, sourceLocale = documentSourceLocale(document), prune = false, keepAuthoredFoundation = false, scope, dataModel = null, sectionType = DEFAULT_SECTION_TYPE, writableMounts = [] }) {
1880
+ export function siteContentDocumentToProject({ document, siteRoot, backend = null, sourceLocale = documentSourceLocale(document), prune = false, keepAuthoredFoundation = false, scope, dataModel = null, sectionType = DEFAULT_SECTION_TYPE, writableMounts = [], priorItems = null }) {
1860
1881
  // Before anything is written: a pull that would leave content out of the files stops here.
1861
1882
  refuseContentFilesCannotHold(document, sourceLocale)
1862
1883
 
@@ -1913,7 +1934,11 @@ export function siteContentDocumentToProject({ document, siteRoot, backend = nul
1913
1934
  // A read-only mount's pages, and a route the files give two pages for, are neither written nor
1914
1935
  // pruned. Each record's place, once decided, is the one every pass below reads (`places`).
1915
1936
  // The pages this copy has seen the backend hold, by route: a prune deletes an `.md` page only then.
1916
- const items = backend ? readBackendState(siteRoot, backend).items : null
1937
+ // ⭐ AS THEY STOOD BEFORE THIS PULL (`priorItems`): in a repository the pull runs where there is no
1938
+ // rename index, so where a page was is read from these alone. ⛔ Until 2026-11-05 they were read
1939
+ // after the pull had merged the pulled document's in, so a page the app moved had both routes, and
1940
+ // the one kept was whichever sorted last: a held page's files were pruned from where they were.
1941
+ const items = priorItems ?? (backend ? readBackendState(siteRoot, backend).items : null)
1917
1942
  ctx.seen = seenPageRoutes(items)
1918
1943
  ctx.itemRoutes = itemRoutesOf(items)
1919
1944
  ctx.kept = new Set()
@@ -56,7 +56,8 @@ const withBaseVersion = (baseVersions, itemBaseVersions, { every = false } = {})
56
56
  // present AND for items the files dropped. A push deletes only the items it holds a
57
57
  // version for, and only while the site left them unchanged — so a dropped item's
58
58
  // version is what makes leaving it out a deletion, and without it the item is kept
59
- // [Diego, 2026-10-07; backend's gate]. The
59
+ // [Diego, 2026-10-07; backend's gate]. One exception: an item a pull held and the push leaves out
60
+ // (`leaveHeldOut`), whose version the site-content lane drops, since its being left out keeps it. The
60
61
  // caller holds a version only for an item it has seen (`heldTokens`, cli), so none is
61
62
  // ever sent for an item the backend holds and this copy does not.
62
63
  // ⛔ Until then this narrowed to the units the document carried: a dropped page was
@@ -577,7 +578,7 @@ export async function emitSyncPackages(siteRoot, opts = {}) {
577
578
  // hands a pull to record. A walk of its own, made only when a pull held something.
578
579
  const heldUnits = opts.heldUnits && typeof opts.heldUnits === 'object' && Object.keys(opts.heldUnits).length ? opts.heldUnits : null
579
580
  const plain = siteDoc && (heldUnits || opts.unitHashes) ? await siteProjectToDocument(siteRoot, { ...docOpts, media: null }) : null
580
- const held = heldUnits ? leaveHeldOut(siteDoc, { held: heldUnits, plain, sourceLocale }) : { left: [], changed: [] }
581
+ const held = heldUnits ? leaveHeldOut(siteDoc, { held: heldUnits, plain, sourceLocale }) : { left: [], changed: [], uuids: [] }
581
582
  let unitHashes = null
582
583
  let unitUuids = null
583
584
  if (plain && opts.unitHashes) {
@@ -665,7 +666,17 @@ export async function emitSyncPackages(siteRoot, opts = {}) {
665
666
  // --- site-content lane -------------------------------------------------------
666
667
  let siteContent = null
667
668
  if (siteEntity && changed(siteEntity)) {
668
- siteContent = { ...emitLane([stampSite(siteEntity)], exporter, exportedAt), index: [{ kind: 'site' }] }
669
+ // ⭐ NO VERSION FOR WHAT A PULL HELD AND THIS PUSH LEAVES OUT (`leaveHeldOut`'s `uuids`): with one,
670
+ // leaving it out is a deletion, the opposite of keeping the app's version.
671
+ const leftOut = new Set(held.uuids || [])
672
+ const stamp = leftOut.size
673
+ ? withBaseVersion(
674
+ opts.baseVersions || {},
675
+ Object.fromEntries(Object.entries(opts.itemBaseVersions || {}).filter(([uuid]) => !leftOut.has(uuid))),
676
+ { every: true }
677
+ )
678
+ : stampSite
679
+ siteContent = { ...emitLane([stamp(siteEntity)], exporter, exportedAt), index: [{ kind: 'site' }] }
669
680
  }
670
681
 
671
682
  // The site's current uuid (from site.yml): the verb keys the folder push route on