uniweb 1.30.0 → 1.30.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",
3
- "version": "1.30.0",
3
+ "version": "1.30.2",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,15 +41,15 @@
41
41
  "js-yaml": "^4.3.2",
42
42
  "prompts": "^2.4.2",
43
43
  "tar": "^7.5.21",
44
+ "@uniweb/content-writer": "~1.3.1",
45
+ "@uniweb/core": "~1.6.9",
44
46
  "@uniweb/semantic-parser": "~1.13.2",
45
- "@uniweb/schemas": "~1.6.11",
46
- "@uniweb/core": "~1.6.8",
47
- "@uniweb/content-writer": "~1.3.1"
47
+ "@uniweb/schemas": "~1.6.11"
48
48
  },
49
49
  "peerDependencies": {
50
- "@uniweb/semantic-parser": "~1.13.2",
50
+ "@uniweb/build": "~1.19.2",
51
51
  "@uniweb/content-reader": "~1.5.9",
52
- "@uniweb/build": "~1.19.0"
52
+ "@uniweb/semantic-parser": "~1.13.2"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@uniweb/build": {
@@ -136,7 +136,7 @@ data: {
136
136
 
137
137
  `single`/`whole` are refused over a schema whose root is a list (`@std/nav`, `@std/form`). A `whole` key its source cannot answer whole is `null`. An optional `schemas.config.js` routes a scope to a folder: `export default { '@acme': '../shared/acme-schemas' }` — a routed scope wins, has no package fallback, and `@/`/`@uniweb` are never routable. Worked examples: `development/schemas-in-practice.md`.
138
138
 
139
- **A type several foundations of one scope use is defined once.** A name in a scope is one type, so each foundation's `schemas/member.yml` under `@acme` is a definition of the same `@acme/member`, and a register of either changes it for the other's sites: `register` refuses one that differs from another in the workspace, and `doctor` names copies (`type-defined-twice`). Keep it in the scope's schemas package, or in the one foundation that owns it, and name it in full everywhere else: `data: { members: '@acme/member' }`, `schema: '@acme/member'` in `queries.yml`, and a site's records in `records/acme/member/` (in `records/member/` they're the foundation's own `@/member`, which it no longer defines). Route it with `schemas.config.js`: the scope's folder, or that one type, `'@acme/member': '../hub/src/schemas/member.yml'`.
139
+ **Any foundation can use any registered data schema, by its full name** — `data: { members: '@acme/member' }`, `schema: '@acme/member'` in `queries.yml`. A scope is a namespace that keeps names from colliding, not a limit on who uses a type. So a type another foundation registers is named, never copied: a copy of its file is a second definition of the same type, which `doctor` points out where the two foundations' names give one scope (`type-defined-twice`). A register names such a type and sends no definition of it. A local build still needs the file: `schemas.config.js` routes that type, `'@acme/member': '../hub/src/schemas/member.yml'`, or its scope's folder. A site's records of it sit in `records/acme/member/`; in `records/member/` they'd be the foundation's own `@/member`.
140
140
 
141
141
  ```jsx
142
142
  function Article({ content, block }) { // data: { article: { schema: '@std/article', single: true } }
@@ -73,7 +73,7 @@ Things you won't discover from exports:
73
73
  - **A reader can open a picture larger.** `components={{ image: EnlargeableImage }}` does it for an image in a page's body, and `Mermaid` does it on its own (`enlarge={false}` turns it off). `<Enlargeable>` goes around a picture a section draws itself. It's offered only when opening shows the picture noticeably larger, and the prerendered page doesn't change.
74
74
  - **Kit brings no words.** What a reader or a screen reader meets comes from your foundation, so `Media` takes `playLabel`, `Asset` `downloadLabel`, `Disclaimer` `closeLabel` (it has a button at its foot only with one), `Prose` `footnoteBackLabel` and `DataPlaceholder` `label`. Without one it uses what the author wrote, a role or a symbol: a play button with no caption or alt is named `▶`. `<Link>`'s own tooltip is only a social service's name, an address or a number, so a link holding only an icon needs a `title` or `aria-label` from you. Words your own section draws are content: *A section's own words*, below.
75
75
  - **A word wider than its box breaks**, so a long heading can't pan a phone's page (`overflow-wrap: break-word`, in kit's base). What must stay whole in a narrow box says `whitespace-nowrap`: a big numeral, a figure, a number with its unit. Without it, `10 min` in a tight box comes out as `10 mi / n`.
76
- - **Headings balance their lines and a paragraph's last line keeps company**, inside prose and out (`text-wrap: balance` on `h1`–`h6`, `pretty` on `p`, in kit's base, at no weight). A `text-wrap` or `text-*` class of your own wins; don't write the default again.
76
+ - **Headings balance their lines and a paragraph's last line keeps company**, inside prose and out (`text-wrap-style: balance` on `h1`–`h6`, `pretty` on `p`, in kit's base, at no weight). It sets only the style, so text in a `whitespace-nowrap` box stays on one line. A `text-wrap` or `text-*` class of your own wins; don't write the default again.
77
77
  - **Kit hooks are SSR-safe.** "document is not defined" → use the hook, don't add guards.
78
78
  - **`cn()` drops an earlier `leading-*` when a `text-<size>` follows**, since Tailwind's size classes set line height too: `cn('leading-[1.1] text-4xl')` → `text-4xl`. Put the size first, or fold the leading into it (`text-[clamp(2rem,5vw,4rem)]/[1.1]`).
79
79
  - **"3 of 12 pages didn't render"** means the build stopped, exit 1, because a section threw while rendering a page, and `dist/` isn't complete. It names the error, the section type and the pages. A section that only fails here reads something only a browser has; `uniweb dev` won't show that one.
@@ -1685,7 +1685,9 @@ export function checkGeneratedDataDir({ sitePath, siteName, siteYml, issues, sho
1685
1685
  /**
1686
1686
  * ⭐ WHAT DOCTOR CHECKS IS WHERE YOU STAND, by the rule `dev` and `status` read the folder you stand in
1687
1687
  * (`pick-site.js::siteAround`): in a site, that site and what it is built from, its foundation and its
1688
- * extensions; in a foundation with no site around it, that foundation; elsewhere, the whole workspace.
1688
+ * extensions; in a foundation, the site beside it when that site is built from it, else that foundation;
1689
+ * elsewhere, the whole workspace. ⛔ Until 2026-11-09 the site beside a foundation was checked whatever
1690
+ * it was built from, so in `shop/src` beside a site on another foundation, nothing checked `shop/src`.
1689
1691
  * ⛔ Until 2026-11-08 only the sites were narrowed: run in one site, doctor reported on every foundation
1690
1692
  * in the workspace before the site's own checks, which were hard to find among them.
1691
1693
  *
@@ -1693,20 +1695,24 @@ export function checkGeneratedDataDir({ sitePath, siteName, siteYml, issues, sho
1693
1695
  * null for the whole workspace
1694
1696
  */
1695
1697
  export function doctorFocus({ workspaceDir, projectDir, allSites, foundations, extensions }) {
1696
- const here = siteAround(allSites.map((s) => relative(workspaceDir, s.path)), workspaceDir, projectDir)
1697
- if (here) {
1698
- const site = allSites.find((s) => relative(workspaceDir, s.path) === here)
1699
- const used = siteBuiltFrom(site.path)
1700
- const isUsed = (f) => used.has(realOf(f.path))
1701
- return { site, sites: [site], foundations: foundations.filter(isUsed), extensions: extensions.filter(isUsed) }
1702
- }
1703
1698
  const inside = (dir) => {
1704
1699
  const rel = relative(dir, projectDir)
1705
1700
  return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel))
1706
1701
  }
1707
1702
  const foundation = foundations.find((f) => inside(f.path))
1708
1703
  const extension = extensions.find((e) => inside(e.path))
1709
- if (!foundation && !extension) return null
1704
+ const standingIn = foundation || extension
1705
+ const here = siteAround(allSites.map((s) => relative(workspaceDir, s.path)), workspaceDir, projectDir)
1706
+ if (here) {
1707
+ const site = allSites.find((s) => relative(workspaceDir, s.path) === here)
1708
+ const used = siteBuiltFrom(site.path)
1709
+ // In a foundation the site beside it isn't built from, you mean the foundation.
1710
+ if (!standingIn || used.has(realOf(standingIn.path))) {
1711
+ const isUsed = (f) => used.has(realOf(f.path))
1712
+ return { site, sites: [site], foundations: foundations.filter(isUsed), extensions: extensions.filter(isUsed) }
1713
+ }
1714
+ }
1715
+ if (!standingIn) return null
1710
1716
  return {
1711
1717
  foundation: foundation || extension,
1712
1718
  sites: [],
@@ -1716,11 +1722,11 @@ export function doctorFocus({ workspaceDir, projectDir, allSites, foundations, e
1716
1722
  }
1717
1723
 
1718
1724
  /**
1719
- * ⭐ ONE NAME IN A SCOPE IS ONE TYPE (`workspaceTypesDefinedTwice`): each data schema two packages of
1720
- * one scope here define — two foundations, or a foundation and the scope's schemas package. A register
1721
- * of either changes the type for the other's sites, and `uniweb register` refuses one whose definition
1722
- * differs, so differing copies are a warning and agreeing ones a recommendation: they come apart the
1723
- * first time one is edited.
1725
+ * A data schema two packages of the workspace each define under one scope — a copy, where using the
1726
+ * registered type by its full name was enough. Any foundation or site may use any registered data
1727
+ * schema; its scope is a namespace, so that names never collide, and never limits who uses it. So a
1728
+ * copy is a second definition of the one type `@acme/member` names, and the two come apart the first
1729
+ * time one is edited. A recommendation, never a failure: registering either is the registry's to judge.
1724
1730
  *
1725
1731
  * @param {{ workspaceDir: string, checkedDirs: string[]|null, issues: object[] }} ctx - `checkedDirs`,
1726
1732
  * the packages checked (`doctorFocus`); null for every one
@@ -1740,20 +1746,15 @@ export async function checkTypesDefinedTwice({ workspaceDir, checkedDirs, issues
1740
1746
  const id = 'type-defined-twice'
1741
1747
  issues.push({
1742
1748
  id,
1743
- type: t.differ ? 'warn' : 'info',
1749
+ type: 'info',
1744
1750
  message: `${t.ref} is defined ${t.files.length} times in the workspace${t.differ ? ', differently' : ''}`,
1745
1751
  files: t.files.map((f) => relative(workspaceDir, f))
1746
1752
  })
1747
- const say = t.differ ? warn : info
1748
- say(`[${id}] ${t.ref} is defined in ${t.files.length} places${t.differ ? ', and they differ' : ''}`)
1753
+ info(`[${id}] ${t.ref} is defined in ${t.files.length} places${t.differ ? ', and they differ' : ''}`)
1749
1754
  for (const f of t.files) log(` ${relative(workspaceDir, f)}`)
1750
1755
  log(
1751
- ` A name in a scope is one type, so a register of either changes it for the other's sites` +
1752
- (t.differ ? ` — \`uniweb register\` refuses this one.` : `, and copies come apart the first time one is edited.`)
1753
- )
1754
- log(
1755
- ` Keep it in one place — the scope's schemas package, or the foundation that owns it — and name it in full ` +
1756
- `elsewhere (${colors.green}${t.ref}${colors.reset}), with schemas.config.js routing the scope to its folder.`
1756
+ ` A registered data schema is usable by any foundation by its full name, so keep one definition and name ` +
1757
+ `it in full in the others (${colors.green}${t.ref}${colors.reset}); schemas.config.js gives a local build its file.`
1757
1758
  )
1758
1759
  }
1759
1760
  }
@@ -2188,7 +2189,8 @@ async function runDoctor(args = []) {
2188
2189
  })
2189
2190
  }
2190
2191
 
2191
- // One name in a scope is one type: each defined by two packages here, among those checked.
2192
+ // A data schema two packages here each keep a file for, among those checked: one full name is one
2193
+ // type, so the second file is a copy.
2192
2194
  await checkTypesDefinedTwice({
2193
2195
  workspaceDir,
2194
2196
  checkedDirs: focus ? [...checkedFoundations, ...checkedExtensions].map((f) => f.path) : null,
@@ -2460,8 +2462,8 @@ async function runDoctor(args = []) {
2460
2462
  }
2461
2463
  }
2462
2464
 
2463
- // Check extensions
2464
- for (const ext of extensions) {
2465
+ // Check extensions: those `doctorFocus` chose, as with the foundations above.
2466
+ for (const ext of checkedExtensions) {
2465
2467
  log('')
2466
2468
  info(`Checking extension: ${ext.name}`)
2467
2469
 
@@ -64,7 +64,6 @@ import {
64
64
  readFileSync,
65
65
  writeFileSync,
66
66
  readdirSync,
67
- realpathSync,
68
67
  statSync
69
68
  } from 'node:fs'
70
69
  import { execSync } from 'node:child_process'
@@ -101,20 +100,6 @@ import {
101
100
  } from '../utils/workspace.js'
102
101
  import { isNonInteractive, getCliPrefix } from '../utils/interactive.js'
103
102
  import { checkFlags } from '../utils/flag-guard.js'
104
- import { workspaceTypesDefinedTwice } from '../utils/workspace-types.js'
105
-
106
- // Is `path` inside `dir` (or `dir` itself)? By their real paths, as the type rule reads them.
107
- const realOf = (p) => {
108
- try {
109
- return realpathSync(p)
110
- } catch {
111
- return resolve(p)
112
- }
113
- }
114
- const isWithin = (dir, path) => {
115
- const rel = relative(realOf(dir), realOf(path))
116
- return rel === '' || (!rel.startsWith('..') && !rel.startsWith('/'))
117
- }
118
103
 
119
104
  const colors = {
120
105
  reset: '\x1b[0m',
@@ -618,31 +603,6 @@ export function foundationNeedsBuild(targetDir) {
618
603
  return { needs: false }
619
604
  }
620
605
 
621
- /**
622
- * ⭐ ONE NAME IN A SCOPE IS ONE TYPE (`workspaceTypesDefinedTwice`): a definition that differs from
623
- * another of the same name in this workspace is refused, since a register replaces what the type is for
624
- * the other package's sites too. Copies that agree register as one, and `uniweb doctor` names them.
625
- * Says why and returns true when it refuses.
626
- */
627
- async function typesRefused(targetDir, kind, scope) {
628
- if (!scope) return false
629
- const workspaceDir = findWorkspaceRoot(targetDir)
630
- if (!workspaceDir) return false
631
- const twice = (await workspaceTypesDefinedTwice(workspaceDir, { dir: targetDir, kind, scope }))
632
- .filter((t) => t.differ && t.files.some((f) => isWithin(targetDir, f)))
633
- if (!twice.length) return false
634
- error(`${twice.length === 1 ? 'A data schema this registers is' : `${twice.length} data schemas this registers are`} defined differently elsewhere in the workspace:`)
635
- for (const t of twice) {
636
- log(` ${colors.bright}${t.ref}${colors.reset}`)
637
- for (const f of t.files) log(` ${colors.dim}${relative(workspaceDir, f)}${colors.reset}`)
638
- }
639
- log('')
640
- log(` A name in ${scope} is one type: registering this would change it for the other's sites too.`)
641
- log(` Keep each in one place — the scope's schemas package, or the foundation that owns it — and name it`)
642
- log(` in full elsewhere (${twice[0].ref}), with ${colors.bright}schemas.config.js${colors.reset} routing ${scope} to its folder.`)
643
- return true
644
- }
645
-
646
606
  export async function register(args = []) {
647
607
  // See utils/flag-guard.js — an unrecognized flag is invisible to a
648
608
  // literal scan, so it silently keeps the default (production, for --backend).
@@ -753,8 +713,6 @@ async function runRegister(args = []) {
753
713
  if (!settled) return { exitCode: 2 }
754
714
  scope = settled.scope
755
715
  scopeSource = settled.source
756
- // Before the build: the type rule reads the source, and a refusal needs no build to say.
757
- if (await typesRefused(targetDir, 'foundation', scope)) return { exitCode: 2 }
758
716
  // Build-if-stale (`foundationNeedsBuild`): a missing or stale dist/ gets
759
717
  // (re)built before we read its schema. Preview paths
760
718
  // (--dry-run / -o) must not write to dist/, so they require a pre-built
@@ -845,9 +803,6 @@ async function runRegister(args = []) {
845
803
  // states its own floor and whoever resolves a whole site does the arithmetic.
846
804
  const runtime = standalone ? null : readRuntimePin(join(targetDir, 'dist'))
847
805
 
848
- // A schemas package's scope is known only now; a foundation's was before its build.
849
- if (standalone && (await typesRefused(targetDir, 'schemas', scope))) return { exitCode: 2 }
850
-
851
806
  const exporter = { tool: 'uniweb', version: cliVersion(), instance: 'build' }
852
807
  let doc
853
808
  try {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-11-08T22:27:32.223Z",
3
+ "generatedAt": "2026-11-09T02:11:16.418Z",
4
4
  "packages": {
5
5
  "@uniweb/api": {
6
6
  "version": "1.6.9"
7
7
  },
8
8
  "@uniweb/build": {
9
- "version": "1.19.0"
9
+ "version": "1.19.2"
10
10
  },
11
11
  "@uniweb/content-reader": {
12
12
  "version": "1.5.9"
@@ -15,7 +15,7 @@
15
15
  "version": "1.3.1"
16
16
  },
17
17
  "@uniweb/core": {
18
- "version": "1.6.8"
18
+ "version": "1.6.9"
19
19
  },
20
20
  "@uniweb/frame-bridge": {
21
21
  "version": "1.0.3"
@@ -24,7 +24,7 @@
24
24
  "version": "1.0.8"
25
25
  },
26
26
  "@uniweb/kit": {
27
- "version": "1.7.15"
27
+ "version": "1.7.17"
28
28
  },
29
29
  "@uniweb/loom": {
30
30
  "version": "1.1.3"
@@ -36,7 +36,7 @@
36
36
  "version": "1.2.13"
37
37
  },
38
38
  "@uniweb/runtime": {
39
- "version": "1.5.3"
39
+ "version": "1.5.4"
40
40
  },
41
41
  "@uniweb/scene": {
42
42
  "version": "1.0.1"
@@ -434,8 +434,18 @@ export async function updateRootScripts(rootDir, sites, pm = 'pnpm') {
434
434
  const newScripts = computeRootScripts(runs ? [runs, ...unique.filter((s) => s !== runs)] : unique, pm)
435
435
  const previewIsCli = /^(pnpm --filter \S+ (run )?preview|npm -w \S+ run preview)$/.test(scripts.preview ?? '')
436
436
  if (scripts.preview && !runs && !previewIsCli) delete newScripts.preview
437
- // Nor is a script the workspace already has for a site added again under another name.
438
- const held = new Set(Object.values(scripts))
437
+ // A per-site script under a name the CLI gives the site it runs (its package's, its project's), or
438
+ // one for a site that is gone, is the CLI's own, and regenerated below. One under another name is
439
+ // the person's, for a command the CLI writes too.
440
+ const cliNamed = (key, value) => {
441
+ const m = /^(dev|preview):(.+)$/.exec(key)
442
+ const target = m && cliScriptTarget(value)
443
+ if (!target) return false
444
+ const s = unique.find((o) => isSite(o, target))
445
+ return !s || m[2] === target || m[2] === s.name || m[2] === siteScriptName(s)
446
+ }
447
+ // Nor is a script the workspace already has under a name of the person's added again under another.
448
+ const held = new Set(Object.entries(scripts).filter(([k, v]) => !cliNamed(k, v)).map(([, v]) => v))
439
449
  for (const [key, command] of Object.entries(newScripts)) {
440
450
  if (!(key in scripts) && held.has(command)) delete newScripts[key]
441
451
  }
@@ -450,16 +460,15 @@ export async function updateRootScripts(rootDir, sites, pm = 'pnpm') {
450
460
  }
451
461
  }
452
462
 
453
- // ⭐ The per-site scripts this CLI writes are regenerated from the sites there are
454
- // now, and one it wrote for a site that is gone — renamed, moved, removed — goes.
455
- // A script whose command is not one the CLI writes is the user's, and stays. Known by its
456
- // command, since a project's site goes by the project's name (`siteScriptName`).
457
- // ⛔ Until 2026-10-13 they were only ever added: after `rename site blog journal`,
458
- // `dev:blog` still ran `uniweb dev blog`, a site that no longer existed.
463
+ // ⭐ The per-site scripts this CLI writes are regenerated from the sites there are now: one of
464
+ // its own the regenerated set doesn't hold goes — its site renamed, moved or removed, or the site's
465
+ // scripts named or run another way now (by its project's name; under npm, by its folder). A script
466
+ // under the person's own name for a command, or whose command the CLI doesn't write, stays.
467
+ // ⛔ Until 2026-10-13 they were only ever added: after `rename site blog journal`, `dev:blog`
468
+ // still ran `uniweb dev blog`. ⛔ From 2026-11-08 to 2026-11-09 only a gone site's went, so a
469
+ // renamed project kept its old pair beside the new one.
459
470
  for (const [key, value] of Object.entries(scripts)) {
460
- if (key in newScripts || !/^(dev|preview):./.test(key)) continue
461
- const target = cliScriptTarget(value)
462
- if (target && !unique.some((s) => isSite(s, target))) delete scripts[key]
471
+ if (!(key in newScripts) && cliNamed(key, value)) delete scripts[key]
463
472
  }
464
473
 
465
474
  pkg.scripts = { ...scripts, ...newScripts }
@@ -1,8 +1,7 @@
1
1
  /**
2
- * ⭐ ONE NAME IN A SCOPE IS ONE TYPE (`@uniweb/build`'s `typesDefinedTwice`, which says why): the data
3
- * schema names the workspace's packages of one scope each define — its foundations, extensions and
4
- * schemas packages — for `uniweb register` to refuse a definition that differs, and `uniweb doctor` to
5
- * name every one defined twice.
2
+ * The data schema names two packages of the workspace each define under one scope — its foundations,
3
+ * extensions and schemas packages — for `uniweb doctor` to recommend one definition, named in full
4
+ * elsewhere (`@uniweb/build`'s `typesDefinedTwice`, which says why).
6
5
  */
7
6
 
8
7
  import { join } from 'node:path'
@@ -13,17 +12,14 @@ import { workspacePackages } from './workspace-packages.js'
13
12
  * The names of one scope two packages of the workspace define.
14
13
  *
15
14
  * @param {string} workspaceDir
16
- * @param {{ dir: string, kind: 'foundation'|'schemas', scope: string }} [self] - a package whose scope
17
- * was just settled, which its own files may not say yet (`register`)
18
15
  * @returns {Promise<{ ref: string, files: string[], differ: boolean }[]>}
19
16
  */
20
- export async function workspaceTypesDefinedTwice(workspaceDir, self = null) {
17
+ export async function workspaceTypesDefinedTwice(workspaceDir) {
21
18
  const packages = []
22
19
  for (const rel of workspacePackages(workspaceDir)) {
23
20
  const dir = join(workspaceDir, rel)
24
21
  const kind = classifyPackage(dir) === 'foundation' ? 'foundation' : isSchemasPackage(dir) ? 'schemas' : null
25
22
  if (kind) packages.push({ dir, kind })
26
23
  }
27
- if (self) packages.unshift(self)
28
24
  return typesDefinedTwice(packages)
29
25
  }