@uniweb/core 0.35.4 → 0.37.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/core",
3
- "version": "0.35.4",
3
+ "version": "0.37.0",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
package/src/data-keys.js CHANGED
@@ -37,7 +37,14 @@ export const WHOLE_SUFFIX = '/*'
37
37
  * 2026-09-27 [Diego]). The runtime asks each key's question accordingly; a key declared whole
38
38
  * that its fetch cannot fill whole is `null`.
39
39
  *
40
- * @param {*} value - one `data:` entry's value, authored or leaned
40
+ * Who passes what. The runtime: a section type's LEAN `data` — a ref string or null, from the
41
+ * runtime schema the build extracts (`@uniweb/build`'s `runtime-schema.js`) — and the foundation's
42
+ * own `main.js` `data:` as written. A build-time reader: a `meta.js` value as written, or a
43
+ * registered foundation schema's in its normalized form (`schemaFormat: 3`, `@uniweb/schemas`'s
44
+ * `normalizeFoundationSchema`), which writes every ref as `{ kind: 'schema', schema, whole }` — the
45
+ * ref qualified and `whole` said outright.
46
+ *
47
+ * @param {*} value - one `data:` entry's value, authored, leaned or normalized
41
48
  * @returns {{ ref: string|null, whole: boolean }}
42
49
  */
43
50
  export function dataRefOf(value) {
@@ -46,7 +53,7 @@ export function dataRefOf(value) {
46
53
  : (value && typeof value === 'object' && typeof value.schema === 'string' ? value.schema : '')
47
54
  if (!raw) return { ref: null, whole: false }
48
55
  if (raw.endsWith(WHOLE_SUFFIX)) return { ref: raw.slice(0, -WHOLE_SUFFIX.length) || null, whole: true }
49
- return { ref: raw, whole: false }
56
+ return { ref: raw, whole: typeof value === 'object' && value.whole === true }
50
57
  }
51
58
 
52
59
  /**
@@ -79,13 +86,15 @@ export function declaredKeys(componentData, foundationData = null) {
79
86
  /**
80
87
  * Do two schema refs name the same schema?
81
88
  *
82
- * ⭐ `@/<name>` is "this project's own `<name>`", and what that project is differs by who
83
- * wrote it: in a foundation's `meta.js` it is the foundation's schema, in a site's
84
- * `queries.yml` the site's — and a site synced to a host has its queries' `@/` refs
85
- * qualified with its org (`@acme/member`). So a local ref matches a ref of ANY scope with
86
- * the same name; two scoped refs match only when their scopes agree. Decided 2026-09-14
87
- * (the plan's §7 left it to framework): `@/member` and `@acme/member` match,
88
- * `@std/person` and `@acme/person` do not.
89
+ * ⭐ `@/<name>` is `<name>` in the FOUNDATION's own scope — the one in its name
90
+ * (`@acme/marketing` → `@acme/member`) — in its `meta.js` and in a site's `queries.yml`
91
+ * alike. A push qualifies a site's `@/` refs with that scope (`@uniweb/build`'s
92
+ * `uwx/self-scope.js`, ruled 2026-09-22), never with the org that owns the site. This match
93
+ * does not know the scope, so a local ref matches a ref of ANY scope with the same name; two
94
+ * scoped refs match only when their scopes agree. Decided 2026-09-14 (the plan's §7 left it
95
+ * to framework): `@/member` and `@acme/member` match, `@std/person` and `@acme/person` do not.
96
+ * ⛔ Until 2026-10-01 this said a site's `@/` meant the site's own schema, qualified with the
97
+ * site's org — the rule before 2026-09-22 — which read as if `@/` had two meanings.
89
98
  *
90
99
  * @param {string|null|undefined} a
91
100
  * @param {string|null|undefined} b
@@ -44,10 +44,10 @@ function collectTransports(decl, { source, dev }) {
44
44
 
45
45
  let raw
46
46
  try {
47
- // A built foundation carries its declarations under `default.capabilities`
48
- // — framework/build/src/generate-entry.js spreads the source `main.js`
49
- // default (props, transports, …) into `capabilities`, and `decl` here is
50
- // that built `default` (= { meta, capabilities, layoutMeta }). Transports
47
+ // A built foundation carries what the runtime reads of its `main.js` under
48
+ // `default.capabilities` — framework/build/src/generate-entry.js references
49
+ // the code keys there, `transports` among them — and `decl` here is that
50
+ // built `default` (= { meta, capabilities, layoutMeta }). Transports
51
51
  // therefore live at `default.capabilities.transports`: a single direct
52
52
  // read, no fallback chain (the runtime only ever sees the built shape).
53
53
  raw = decl.capabilities?.transports
package/src/index.js CHANGED
@@ -93,7 +93,10 @@ export {
93
93
  landingRoute,
94
94
  RESOLUTION_STATUS,
95
95
  } from './resolve-route.js'
96
- export { isRichSchema } from './schemas.js'
96
+ // ⛔ No `isRichSchema` (removed 2026-10-05). It told a form-shaped `data:` value from a field
97
+ // map for the runtime's field defaults and the build's runtime schema; both went when the
98
+ // runtime stopped filling field defaults. A registered schema says it outright — `kind: 'form'`
99
+ // in format 3 (`@uniweb/schemas/foundation`) — and the editor, its last reader, reads that.
97
100
  // ⛔ `Tracker` is NOT on the package entry. It is a FEATURE, not part of the
98
101
  // object graph this package exists to define, and putting it here made every
99
102
  // consumer of core carry 1,576 gzip of it -- press, unipress, `@uniweb/api`
@@ -308,8 +308,10 @@ export function landingRoute(site, page, seen = new Set()) {
308
308
  *
309
309
  * In order:
310
310
  * 1. **The locale served unprefixed, asked for with its prefix** — `/en/docs` where `en` is the
311
- * default (or the host's own locale) — is a `301` to the path without it. Ruled 2026-09-30
312
- * [Diego]; until then no page matched it.
311
+ * default (or the host's own locale) — is a `301` to the path without it, and when the rest names
312
+ * a page, to this locale's own URL for it: `/fr/about` on a French host is `/a-propos`, in one
313
+ * hop. Ruled 2026-09-30 [Diego]; until then no page matched it. ⛔ Until 2026-10-01 it went to the
314
+ * rest as written, and `/about` was a second `301`.
313
315
  * 2. **The page** (`findPage`). None ⇒ `notFound`, with the site's not-found page: its
314
316
  * `notFound` content, else the page at `/404`.
315
317
  * 3. **An authored `redirect:`** ⇒ a `302` to it: a page of the site in this locale, anything
@@ -322,8 +324,9 @@ export function landingRoute(site, page, seen = new Set()) {
322
324
  *
323
325
  * ⭐ **One URL per page per language** (ruled 2026-10-01): a page asked for at another route than
324
326
  * this locale shows it at — `/fr/blog` where French shows `/fr/blogue` — is a `301` there
325
- * (`localeOwnUrl`), before 4 and 6. A redirect (3) and a container (5) already send the visitor
326
- * to this locale's URL for their destination, in one hop.
327
+ * (`localeOwnUrl`), before 4 and 6, and folded into 1. A redirect (3) and a container (5) already
328
+ * send the visitor to this locale's URL for their destination, in one hop. Only `301`s fold: a
329
+ * `302` is temporary, so a prefixed path to one is two hops, the `302` its own.
327
330
  *
328
331
  * `status` is what a host that sends one sends. A static host has its own ways to say each kind.
329
332
  *
@@ -339,11 +342,19 @@ export function resolveRoute(site, path, context = {}) {
339
342
  const defaultLocale = context.defaultLocale ?? index.defaultLocale
340
343
  const raw = typeof path === 'string' && path ? path : '/'
341
344
 
342
- // 1 · the unprefixed locale, asked for with its prefix. The rest of the path goes as written.
345
+ // 1 · the unprefixed locale, asked for with its prefix: to the locale's own URL for the page the
346
+ // rest of the path names, in ONE 301 — `/fr/about` on a French host is `/a-propos`, never `/about`
347
+ // first (ruled 2026-10-01 [Diego]: "fold them into a single 301"). The rest as written when it names
348
+ // no page. Only 301s fold: a container's or an authored 302 is temporary, and stays its own hop.
349
+ // The redirect names no page, as before.
343
350
  if (defaultLocale) {
344
351
  const prefix = `/${defaultLocale}`
345
- if (raw === prefix || raw === `${prefix}/`) return redirect('/', RESOLUTION_STATUS.localeRedirect, 'locale')
346
- if (raw.startsWith(`${prefix}/`)) return redirect(raw.slice(prefix.length), RESOLUTION_STATUS.localeRedirect, 'locale')
352
+ const rest = raw === prefix || raw === `${prefix}/` ? '/' : raw.startsWith(`${prefix}/`) ? raw.slice(prefix.length) : null
353
+ if (rest !== null) {
354
+ const ctx = { activeLocale, defaultLocale }
355
+ const own = findPage(index, rest, ctx) ? localeOwnUrl(index, rest, ctx) : null
356
+ return redirect(own || rest, RESOLUTION_STATUS.localeRedirect, 'locale')
357
+ }
347
358
  }
348
359
 
349
360
  // 2 · the page
package/src/website.js CHANGED
@@ -755,7 +755,7 @@ export default class Website {
755
755
  /**
756
756
  * Get layout metadata from foundation config
757
757
  * @param {string} layoutName - Layout name
758
- * @returns {Object|null} Layout meta { areas, transitions, defaults }
758
+ * @returns {Object|null} Layout meta { transitions, layers, scroll, defaults } — a page's areas are its site's `layout/` folder (`getLayoutAreas`)
759
759
  */
760
760
  getLayoutMeta(layoutName) {
761
761
  return findLayoutEntry(globalThis.uniweb?.foundationConfig?.layoutMeta, layoutName) || null
@@ -772,13 +772,6 @@ export default class Website {
772
772
  return globalThis.uniweb.foundationConfig?.viewTransitions !== false
773
773
  }
774
774
 
775
- /**
776
- * Get remote props from foundation config
777
- */
778
- getRemoteProps() {
779
- return globalThis.uniweb?.foundationConfig?.props || null
780
- }
781
-
782
775
  /**
783
776
  * Get routing components (Link, useNavigate, etc.)
784
777
  */
package/src/schemas.js DELETED
@@ -1,45 +0,0 @@
1
- /**
2
- * The rich-form-schema predicate. One function, and deliberately only one.
3
- *
4
- * Rich schemas live under `data.schemas` in a component's meta.js. They drive
5
- * two author input paths that both land at `content.data[schema-id]`: tagged
6
- * markdown blocks (``` ```yaml:<id> ``` ```) and the editor's FormBlock widget.
7
- *
8
- * `isRichSchema` is a **dispatch** predicate — "is this already the rich shape?"
9
- * — and it is read at render by `runtime/src/prepare-props.js` (`applySchemas`)
10
- * and at build by `build/src/runtime-schema.js`. Both are on the hot path of
11
- * every site, which is what earns it a place in this package.
12
- *
13
- * ⛔ **Do not add editor-side schema code here.** `normalizeSchema` — "can this
14
- * be edited, and as what?" — sat beside this function until 2026-09-01 purely
15
- * because the two were adjacent; it never called `isRichSchema` and had no
16
- * consumer outside the editor. `@uniweb/core` loads on every site in every lane
17
- * and is not tree-shaken on the hosted one, so an editor-only function on its
18
- * entry is paid for by every visitor of every site. It now lives in the
19
- * zero-dependency leaf that owns what a data-schema *means*:
20
- * **`@uniweb/schemas/editor-form`**.
21
- *
22
- * Conditional field visibility (a rich-schema feature) is likewise editor-only
23
- * and is not implemented here — the editor owns its own evaluator.
24
- */
25
-
26
- /**
27
- * Does a `data.schemas` entry look like a rich form schema?
28
- *
29
- * Rich schemas have an ordered `fields` array (composite arrays and
30
- * nested objects), distinct from simple keyed-object schemas used for
31
- * tagged blocks. Markers (any of):
32
- * - `fields` is an array
33
- * - `isComposite: true`
34
- * - `childSchema` present
35
- *
36
- * @param {*} schema - Schema value to inspect.
37
- * @returns {boolean}
38
- */
39
- export function isRichSchema(schema) {
40
- if (!schema || typeof schema !== 'object') return false
41
- if (Array.isArray(schema.fields)) return true
42
- if (schema.isComposite === true) return true
43
- if (schema.childSchema && typeof schema.childSchema === 'object') return true
44
- return false
45
- }