@uniweb/build 0.51.0 → 0.52.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/src/uwx/site.js CHANGED
@@ -75,13 +75,14 @@ function setIf(obj, key, value) {
75
75
  if (value !== undefined) obj[key] = value
76
76
  }
77
77
 
78
- // A YAML scalar the author may have written unquoted: `20260910` loads as a number
79
- // and `2026-09-10` as a Date. Carry either as the string it stands for; anything
80
- // else that is not a string is not a value a string field can hold.
78
+ // A YAML scalar the author may have written unquoted: `20260910` loads as a number.
79
+ // Carry it as the string it stands for; anything else that is not a string is not a
80
+ // value a string field can hold. (`2026-09-10` loads as the string it is written as —
81
+ // the build's YAML resolves no timestamps, `utils/yaml-schema.js` — so no Date arrives:
82
+ // it was carried re-rendered by `toISOString()` until 2026-09-14.)
81
83
  function scalarString(value) {
82
84
  if (typeof value === 'string') return value
83
85
  if (typeof value === 'number') return String(value)
84
- if (value instanceof Date) return value.toISOString()
85
86
  return undefined
86
87
  }
87
88
 
@@ -289,7 +290,7 @@ function buildPageData(config, ctx) {
289
290
  // two data sources. The claim was here the whole time; the mirroring was not.
290
291
  // ⭐ `query`, END TO END — no crossing. An earlier version emitted `collection`
291
292
  // here on the belief that this field was the backend's to name. MEASURED
292
- // otherwise: framework already ships `transform`, `detailPage`, `merge` and
293
+ // otherwise: framework was already shipping `transform`, `detailPage`, `merge` and
293
294
  // `prerender` inside this same `fetch` object, which no backend could be
294
295
  // validating — so `fetch` is a blob they carry and framework owns its
295
296
  // vocabulary. ⇒ There was nothing to coordinate, and inventing a coordination
@@ -27,6 +27,7 @@ import { readFile } from 'node:fs/promises'
27
27
  import { existsSync } from 'node:fs'
28
28
  import { join, resolve, basename } from 'node:path'
29
29
  import yaml from 'js-yaml'
30
+ import { YAML_OPTIONS } from './utils/yaml-schema.js'
30
31
  import { queryNameFromUrl, siteReaches, declaredKeys, fillDeclaredKeys } from '@uniweb/core'
31
32
 
32
33
  import { validateItem, isStaticallyCheckable, validateBound } from '@uniweb/schemas/conform'
@@ -541,13 +542,13 @@ async function resolveRecords(path, { byQuery, siteRoot }) {
541
542
  try {
542
543
  const text = await readFile(filePath, 'utf8')
543
544
  if (path.endsWith('.json')) records = JSON.parse(text)
544
- else if (path.endsWith('.yml') || path.endsWith('.yaml')) records = yaml.load(text)
545
+ else if (path.endsWith('.yml') || path.endsWith('.yaml')) records = yaml.load(text, YAML_OPTIONS)
545
546
  else {
546
547
  // Unknown extension — try JSON, then YAML.
547
548
  try {
548
549
  records = JSON.parse(text)
549
550
  } catch {
550
- records = yaml.load(text)
551
+ records = yaml.load(text, YAML_OPTIONS)
551
552
  }
552
553
  }
553
554
  } catch (err) {
@@ -555,12 +556,12 @@ async function resolveRecords(path, { byQuery, siteRoot }) {
555
556
  }
556
557
  }
557
558
 
558
- // Validate the shape that actually SHIPS. `/data/*.json` is JSON, so a YAML
559
- // date (parsed to a Date object in memory) serializes to an ISO string, while
560
- // booleans / numbers / nesting are unchanged. Checking the JSON-round-tripped
561
- // form makes the checker agree with the serialized payload the runtime and
562
- // backend receive — and with the prerendered HTML oracle — so a string-typed
563
- // date field isn't a false "expected string, got date".
559
+ // Validate the shape that actually SHIPS. `/data/*.json` is JSON, so anything a
560
+ // JSON round trip changes is checked as it arrives, while booleans / numbers /
561
+ // nesting are unchanged. Checking the JSON-round-tripped form makes the checker
562
+ // agree with the serialized payload the runtime and backend receive — and with the
563
+ // prerendered HTML oracle. (A YAML date no longer needs it: the build's YAML
564
+ // resolves no timestamps, `utils/yaml-schema.js`, so it is the string as written.)
564
565
  return { records: toShippedShape(records) }
565
566
  }
566
567