uniweb 1.29.2 → 1.30.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",
3
- "version": "1.29.2",
3
+ "version": "1.30.0",
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.7",
44
+ "@uniweb/semantic-parser": "~1.13.2",
46
45
  "@uniweb/schemas": "~1.6.11",
47
- "@uniweb/semantic-parser": "~1.13.2"
46
+ "@uniweb/core": "~1.6.8",
47
+ "@uniweb/content-writer": "~1.3.1"
48
48
  },
49
49
  "peerDependencies": {
50
- "@uniweb/build": "~1.18.1",
50
+ "@uniweb/semantic-parser": "~1.13.2",
51
51
  "@uniweb/content-reader": "~1.5.9",
52
- "@uniweb/semantic-parser": "~1.13.2"
52
+ "@uniweb/build": "~1.19.0"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@uniweb/build": {
@@ -126,7 +126,7 @@ When a rule in §2 feels like friction, that is the moment you are about to take
126
126
  | `font-serif`, `font-sans` | Tailwind's stack, not the site's — unless the foundation declares it as a `font-*` var in `main.js`. Families are the site's (`theme.yml fonts:`). | silent |
127
127
  | `@import url(fonts.googleapis…)` in CSS | `theme.yml fonts.import` / `faces`. | — |
128
128
  | `@tailwind base;` | Tailwind v4: `@import "tailwindcss"` plus kit's token imports (theme guide). | silent — most utilities missing |
129
- | Trust the foundation's own build to prove a class works | A site build and `uniweb dev` read only the folders `@source` names — one line per folder that writes classes (`sections`, `components`, `layouts`, `utils`). | each names a folder you missed, as does `doctor` |
129
+ | Trust the foundation's own build to prove a class works | A site build and `uniweb dev` read what `styles.css` names: the whole foundation with `@import "tailwindcss" source("./")`, as the scaffold writes, else only the folders `@source` lists. | each names a folder a list missed, as does `doctor` |
130
130
  | `prose` from `@tailwindcss/typography`, `prose-invert` | `@import "@uniweb/kit/prose-tokens.css"`; no invert — colors are already the theme's. | build warns; unstyled lists |
131
131
  | `html { scroll-behavior: smooth }` | Never on `html`/`body`; the runtime owns scrolling. | route transitions misbehave |
132
132
  | `filter: blur(80px)` for a glow | Radial gradient + `mask-image`. | Safari jank |
@@ -202,7 +202,7 @@ uniweb <command> --help # exact flags, no side effects
202
202
  | Pages missing from the nav | a strict `pages:` list — add `...` |
203
203
  | A color is empty | unquoted `#` in YAML |
204
204
  | Literal `{name}` on the page | no Loom content handler |
205
- | A class works in the foundation's build, not in the site's or `uniweb dev` | its folder has no `@source` line — `uniweb doctor` names it |
205
+ | A class works in the foundation's build, not in the site's or `uniweb dev` | `styles.css` lists folders and not this one — `uniweb doctor` names it; `source("./")` on the Tailwind import reads them all |
206
206
  | Sticky header scrolls away | `sticky` class instead of `sticky: true` in `meta.js` |
207
207
  | Modal under the header | z-index instead of `<Overlay>` |
208
208
  | Entrance animation never plays | JS-started; write it in CSS; `uniweb dev` doesn't prerender |
@@ -265,7 +265,7 @@ src/
265
265
  ├── components/ # ordinary React — any props, any library, no meta.js, invisible to authors
266
266
  ├── utils/
267
267
  ├── main.js # export default { name, description, defaultLayout, defaultSection, handlers, … } + export const vars
268
- └── styles.css # @import "tailwindcss" + kit's theme-tokens.css + prose-tokens.css; one @source per folder with classes
268
+ └── styles.css # @import "tailwindcss" source("./") + kit's theme-tokens.css + prose-tokens.css
269
269
  ```
270
270
 
271
271
  `uniweb add section Hero` scaffolds `sections/Hero/{index.jsx,meta.js}`. Import shared code as `#components/*`, `#utils/*`.
@@ -247,6 +247,8 @@ extensions: ['@acme/fx@0.3.1']
247
247
 
248
248
  **A folder of pages holds pages of one section.** Under a `folder.yml`, each page is one `.md` file of one section, and each subfolder is a folder of pages too. The build stops on a subfolder with a `page.yml` of its own, a parametric `[slug]/` included. A page of several sections goes outside the folder. In the app, such a page takes no second section, and a pull holds one made there.
249
249
 
250
+ **Such a page's frontmatter holds its page's settings**, beside its section's `type:` and params: `title` (else its H1), `description`, `label`, `keywords`, `slug`, `hideIn`, `layout`, `seo`, `knowledge`, `trackSections`, as in a `page.yml`. A section param with one of those names goes under `props:` (`props: { label: … }`); the build warns where the section type declares one. `id:` is the section's id there too, and `hidden:` drafts the page. A pull writes the app's changes to them back into the file.
251
+
250
252
  **Routes:** folders map 1:1 to routes; `pages:` controls order only. The site root is the exception: the first of `pages:` sets `/`, else `index:`, declared in `site.yml` or in the pages directory's own `folder.yml`/`page.yml`, with `site.yml` winning. A folder with `page.yml` but no markdown is a structural group (`hasContent: false`); visiting it redirects to the first descendant with content.
251
253
 
252
254
  **Mounted folders:** a local folder for a mounted route says how *this site* presents it. Keep `layout:`, `title:` and SEO in a `folder.yml` there; the mounted repo's own `folder.yml` supplies ordering and title where the stub is silent. A `page.yml` with markdown of its own makes a real page above the mounted pages — a landing page for the branch. A mount is one level under `pages/`, and a subfolder in the local folder isn't read, since the branch's pages come from the mount; the build says so. What a site can't do from outside a repo it mounts: leave a file out, title or order a nested folder, or use a `README.md` as a page — those are the mounted repo's to do. A relative link to a markdown file (`./deploying.md#setup`), which is how docs in a repo link to each other, leads to the page that file became; the build names one that leads nowhere. A mount that is its own repository (a submodule, or a clone beside the site) takes its edits as commits there, and `uniweb refresh` takes its latest; a push or publish stops on one that is behind its remote or holds uncommitted changes, and `--mounts-as-is` sends it as it is. A pull writes an author's app edits into a mounted folder where the site's own repository holds it, or a submodule of it does (a commit there, to push before the site's repository). A folder it cannot merge into — a clone beside the site — keeps its text and the app keeps the author's: the pull and `status` name each such page as held, and a push leaves it alone while its file is unchanged. A mount is its folder, `pages/docs: ../docs`; the object form is refused.
@@ -136,6 +136,8 @@ 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'`.
140
+
139
141
  ```jsx
140
142
  function Article({ content, block }) { // data: { article: { schema: '@std/article', single: true } }
141
143
  if (block.dataLoading) return <DataPlaceholder />
@@ -73,6 +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
77
  - **Kit hooks are SSR-safe.** "document is not defined" → use the hook, don't add guards.
77
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]`).
78
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.
@@ -107,7 +108,7 @@ Header.as = 'div'
107
108
 
108
109
  **Sticky is a setting.** `sticky: true` in the type's `meta.js` (an author turns it off with `sticky: false`); the runtime makes sticky the box that can stay in view. A body section sticks the same way and stays below the stuck header: the runtime publishes the header's reach as `--uw-sticky-top` (a type's `top` overrides: `sticky: { default: true, top: '4rem' }`). Section links land below the stuck header. Keep the bar in the flow: a bar made `absolute` or `fixed` leaves the runtime nothing to measure, and section links land under it.
109
110
 
110
- **A header over the opening section is a setting too.** `underHeader: true` in a type's `meta.js` (a hero whose picture reaches the top of the window; an author turns it off with `underHeader: false`) has the runtime lay the header over that section when it opens a page: the header's box takes no room, the section starts at the top, and the header keeps its height, stuck if it sticks. The section pads its content by `var(--uw-header-height)`, which the runtime gives it: the header type's `height` (`height: 'var(--header-height)'` in its `meta.js`) on the first paint, then what the browser measures. The header reads `block.getNextBlockInfo()?.underHeader` to paint itself see-through, and its box carries `data-uw-header="over"`. A header whose bar is ever see-through, there or frosted on scroll, says `background: 'self'` and paints its own bar (`bg-section` where solid): otherwise the theme paints its section's surface behind the bar. A child in `<ChildGrid>` sticks beside its column, and scrolls with the page at one column. A sticky section inside `overflow: hidden` can't stick — use `overflow: clip`. A layout that wraps an area in its own element makes it sticky when `page.isSticky('header')`. `uniweb dev` names a sticky element that cannot move in the console.
111
+ **A header over the opening section is a setting too.** `underHeader: true` in a type's `meta.js` (a hero whose picture reaches the top of the window; an author turns it off with `underHeader: false`) has the runtime lay the header over that section when it opens a page: the header's box takes no room, the section starts at the top, and the header keeps its height, stuck if it sticks. The section pads its content by `var(--uw-header-height)`, which the page's stylesheet gives it: what the browser measures, before that the header type's `height` (`height: 'var(--header-height)'` in its `meta.js`), and `0px` where the layout draws no header. The header reads `block.getNextBlockInfo()?.underHeader`, true only when it lies over that section, to paint itself see-through, and its box carries `data-uw-header="over"`. A header whose bar is ever see-through, there or frosted on scroll, says `background: 'self'` and paints its own bar (`bg-section` where solid): otherwise the theme paints its section's surface behind the bar. A child in `<ChildGrid>` sticks beside its column, and scrolls with the page at one column. A sticky section inside `overflow: hidden` can't stick — use `overflow: clip`. A layout that wraps an area in its own element makes it sticky when `page.isSticky('header')`. `uniweb dev` names a sticky element that cannot move in the console.
111
112
 
112
113
  ## meta.js in full
113
114
 
@@ -160,6 +161,10 @@ export default function Pricing({ content, params }) {
160
161
  }
161
162
  ```
162
163
 
164
+ ### Code several foundations share
165
+
166
+ Code that more than one foundation of a workspace uses lives in a workspace package, not in copies: components are imported as from any package, and Vite bundles them into each foundation. Give the package a stylesheet that reads its own folder, as kit's does — `@source "./**/*.{js,jsx}";` in its `styles.css` — and import it in each foundation's `styles.css` (`@import "@acme/ui/styles.css";`), so Tailwind finds its classes wherever it is installed. A section type the package holds is still each foundation's to offer: a folder in the foundation's `sections/` whose `index.jsx` is `export { default } from '@acme/ui/sections/Banner/index.jsx'`, and whose `meta.js` re-exports the package's the same way. A fix in the package reaches every foundation at its next build and release.
167
+
163
168
  ### The Front Desk pattern
164
169
 
165
170
  A section type is triage: it reads params, picks a worker, and translates author vocabulary into developer props — and that is all it does. The workers are ordinary components that know nothing about CCA, and they need not share an interface: a `Hero` might hand off to a `SliderHero` (image carousel) or a `ContactHero` (quote form) that want different content and different props. The front desk declares the **union** of what they need, and unused content for a given variant is normal — params change behavior, and that includes not rendering some content. This is what lets an author (or an A/B test) flip `variant:` on a section without touching its markdown.
@@ -100,19 +100,15 @@ The build adds preconnect hints, emits `@font-face` + preload, drops unreference
100
100
  ## styles.css
101
101
 
102
102
  ```css
103
- @import "tailwindcss";
103
+ @import "tailwindcss" source("./");
104
104
  @import "@uniweb/kit/theme-tokens.css";
105
105
  @import "@uniweb/kit/prose-tokens.css";
106
- @source "./sections/**/*.{js,jsx}";
107
- @source "./components/**/*.{js,jsx}";
108
- @source "./layouts/**/*.{js,jsx}";
109
- @source "./utils/**/*.{js,jsx}";
110
106
  @theme { --breakpoint-xs: 30rem; }
111
107
  ```
112
108
 
113
109
  Two more imports are opt-in: `@uniweb/kit/math-tokens.css` lays out equations, and `@uniweb/kit/callout-tokens.css` draws concept blocks such as `md:warning`, which are otherwise plain prose.
114
110
 
115
- **Name every folder that writes classes,** or keeps them in a string for code elsewhere to write, such as a map of colours to classes in `utils/`. The foundation's own build finds them all, but a site build and `uniweb dev` read only what these lines name, so a class in a folder left out is in one CSS and missing from the other. `uniweb dev`, a site build and `uniweb doctor` (`unread-folder`) give the line to add. `theme-tokens.css` also tells Tailwind to read kit's source, so kit's own classes reach your CSS wherever your package manager put kit; a foundation that skips that import names kit itself, by where kit is (`./node_modules/@uniweb/kit/src/**` under pnpm, `../node_modules/@uniweb/kit/src/**` under npm).
111
+ **Tailwind reads the whole foundation.** `source("./")` on the import has it read every file under the foundation, in the foundation's own build and in a site's, so a class in any folder reaches both — one kept in a string for code elsewhere to write too, such as a map of colours to classes in `utils/`. A stylesheet that names folders instead (`@source "./sections/**/*.{js,jsx}"`, as older projects do) must name every folder that writes classes: the foundation's own build finds them all, but a site build and `uniweb dev` read only what those lines name, so a class in a folder left out is in one CSS and missing from the other. `uniweb dev`, a site build and `uniweb doctor` (`unread-folder`) name such a folder, and give the `source("./")` line that ends it. `theme-tokens.css` also tells Tailwind to read kit's source, so kit's own classes reach your CSS wherever your package manager put kit; a foundation that skips that import names kit itself, by where kit is (`./node_modules/@uniweb/kit/src/**` under pnpm, `../node_modules/@uniweb/kit/src/**` under npm).
116
112
 
117
113
  Custom CSS is expected alongside Tailwind — shadow systems, border hierarchies, gradients, glass. Tokens are a floor; add vocabulary that references them so it adapts per context:
118
114
 
@@ -343,7 +343,12 @@ export async function add(rawArgs) {
343
343
  const rootPkg = JSON.parse(
344
344
  await readFile(join(rootDir, 'package.json'), 'utf-8').catch(() => '{}')
345
345
  )
346
- const projectName = rootPkg.name || 'my-project'
346
+ // ⭐ The project a package is part of: the one `--project` names — the folder it goes in,
347
+ // `<project>/src` or `<project>/site` — else the workspace, by its root package's name. ⛔ Until
348
+ // 2026-11-08 it was always the workspace's, so `add foundation --project shop` in a workspace of
349
+ // projects described the foundation as "<workspace> foundation", and a site added so was named and
350
+ // titled for the workspace.
351
+ const projectName = parsed.project || rootPkg.name || 'my-project'
347
352
 
348
353
  // What this workspace installs with is a property of the repo (its lockfile), not of how the
349
354
  // CLI happened to be launched: `npx uniweb add` in a pnpm workspace wrote `npm -w` root scripts
@@ -407,10 +412,13 @@ async function addFoundation(rootDir, projectName, opts, pm = 'pnpm') {
407
412
  const fullPath = join(rootDir, relativePath)
408
413
 
409
414
  // The foundation's own name — what it registers as, written to main.js — is
410
- // the name asked for, before any workspace suffix below; with none (`src`),
411
- // the project's.
412
- const askedName =
413
- normalizeFoundationName(packageName) || normalizeFoundationName(projectName)
415
+ // the name asked for, before any workspace suffix below; with `--project`, the
416
+ // project's, which its package's `-src` is only the workspace's suffix to; with
417
+ // none (`src`), the workspace's. ⛔ Until 2026-11-08 `--project shop` named the
418
+ // foundation `shop-src`.
419
+ const askedName = opts.project
420
+ ? normalizeFoundationName(opts.project)
421
+ : normalizeFoundationName(packageName) || normalizeFoundationName(projectName)
414
422
 
415
423
  // Validate the derived package name (format + reserved-name check). The
416
424
  // auto-derived `src` default is grandfathered in (`src` IS reserved
@@ -6,19 +6,21 @@ import {
6
6
  existsSync,
7
7
  readFileSync,
8
8
  readdirSync,
9
+ realpathSync,
9
10
  statSync,
10
11
  writeFileSync,
11
12
  mkdirSync,
12
13
  rmSync
13
14
  } from 'node:fs'
14
- import { join, resolve, dirname, relative } from 'node:path'
15
+ import { join, resolve, dirname, relative, isAbsolute, sep } from 'node:path'
15
16
  import yaml from 'js-yaml'
16
17
  import {
17
18
  resolveFoundationSrcPath,
18
19
  classifyPackage,
19
20
  isExtensionPackage as buildIsExtensionPackage,
20
21
  extensionNameOf,
21
- findSiteExtension
22
+ findSiteExtension,
23
+ detectFoundationType
22
24
  } from '@uniweb/build'
23
25
  import {
24
26
  loadDeployYml,
@@ -37,6 +39,7 @@ import { writeJsonPreservingStyle } from '../utils/json-file.js'
37
39
  import { surveyWorkspaceDeps } from '../utils/dep-survey.js'
38
40
  import { discoverFoundations, discoverSites } from '../utils/discover.js'
39
41
  import { siteAround } from '../utils/pick-site.js'
42
+ import { workspaceTypesDefinedTwice } from '../utils/workspace-types.js'
40
43
  import { checkSiteInstall } from '../utils/install-integrity.js'
41
44
  import { editWorkspaceFilePackages } from '../utils/workspace-packages.js'
42
45
  import { findWorkspaceRoot } from '../utils/workspace.js'
@@ -948,7 +951,9 @@ export async function checkUnreadFolders({ foundationName, srcDir, issues }) {
948
951
  const id = 'unread-folder'
949
952
  issues.push({ id, type: 'warn', foundation: foundationName, message: `${foundationName} writes classes where styles.css names no @source` })
950
953
  warn(`[${id}] ${foundationName} writes classes where styles.css names no @source, so a site build and \`uniweb dev\` miss any class only used there`)
951
- log(` Add to styles.css:`)
954
+ log(` Have Tailwind read the whole foundation, and no folder can be left out — in styles.css:`)
955
+ log(` @import "tailwindcss" source("./");`)
956
+ log(` Or add:`)
952
957
  for (const { line } of unread) log(` ${line}`)
953
958
  }
954
959
 
@@ -1677,6 +1682,110 @@ export function checkGeneratedDataDir({ sitePath, siteName, siteYml, issues, sho
1677
1682
  * read.
1678
1683
  * @returns {Promise<{ issues: object[], errors: number, warnings: number, fixed: number }>}
1679
1684
  */
1685
+ /**
1686
+ * ⭐ WHAT DOCTOR CHECKS IS WHERE YOU STAND, by the rule `dev` and `status` read the folder you stand in
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.
1689
+ * ⛔ Until 2026-11-08 only the sites were narrowed: run in one site, doctor reported on every foundation
1690
+ * in the workspace before the site's own checks, which were hard to find among them.
1691
+ *
1692
+ * @returns {{ site?: object, foundation?: object, sites: object[], foundations: object[], extensions: object[] } | null}
1693
+ * null for the whole workspace
1694
+ */
1695
+ 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
+ const inside = (dir) => {
1704
+ const rel = relative(dir, projectDir)
1705
+ return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel))
1706
+ }
1707
+ const foundation = foundations.find((f) => inside(f.path))
1708
+ const extension = extensions.find((e) => inside(e.path))
1709
+ if (!foundation && !extension) return null
1710
+ return {
1711
+ foundation: foundation || extension,
1712
+ sites: [],
1713
+ foundations: foundation ? [foundation] : [],
1714
+ extensions: extension ? [extension] : []
1715
+ }
1716
+ }
1717
+
1718
+ /**
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.
1724
+ *
1725
+ * @param {{ workspaceDir: string, checkedDirs: string[]|null, issues: object[] }} ctx - `checkedDirs`,
1726
+ * the packages checked (`doctorFocus`); null for every one
1727
+ */
1728
+ export async function checkTypesDefinedTwice({ workspaceDir, checkedDirs, issues }) {
1729
+ let twice
1730
+ try {
1731
+ twice = await workspaceTypesDefinedTwice(workspaceDir)
1732
+ } catch {
1733
+ return
1734
+ }
1735
+ const checked = (file) => !checkedDirs || checkedDirs.some((dir) => {
1736
+ const rel = relative(realOf(dir), file)
1737
+ return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel))
1738
+ })
1739
+ for (const t of twice.filter((t) => t.files.some(checked))) {
1740
+ const id = 'type-defined-twice'
1741
+ issues.push({
1742
+ id,
1743
+ type: t.differ ? 'warn' : 'info',
1744
+ message: `${t.ref} is defined ${t.files.length} times in the workspace${t.differ ? ', differently' : ''}`,
1745
+ files: t.files.map((f) => relative(workspaceDir, f))
1746
+ })
1747
+ const say = t.differ ? warn : info
1748
+ say(`[${id}] ${t.ref} is defined in ${t.files.length} places${t.differ ? ', and they differ' : ''}`)
1749
+ for (const f of t.files) log(` ${relative(workspaceDir, f)}`)
1750
+ 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.`
1757
+ )
1758
+ }
1759
+ }
1760
+
1761
+ // The folders a site is built from, by the build's own rules: its foundation (`detectFoundationType`)
1762
+ // and each extension it names, as a site-relative URL or a local name (`findSiteExtension`).
1763
+ function siteBuiltFrom(sitePath) {
1764
+ const used = new Set()
1765
+ const siteYml = loadSiteYml(sitePath)
1766
+ try {
1767
+ const found = detectFoundationType(siteYml?.foundation, sitePath)
1768
+ if (found?.type === 'local' && found.path) used.add(realOf(found.path))
1769
+ } catch {
1770
+ // A foundation the build cannot find: the site's own checks name it.
1771
+ }
1772
+ for (const entry of Array.isArray(siteYml?.extensions) ? siteYml.extensions : []) {
1773
+ const url = typeof entry === 'string' ? entry : entry?.url
1774
+ const name = extensionNameOf(url)?.name ?? (typeof url === 'string' && /^[a-z0-9][a-z0-9_-]*$/i.test(url) ? url : null)
1775
+ const dir = name ? findSiteExtension(name, sitePath) : null
1776
+ if (dir) used.add(realOf(dir))
1777
+ }
1778
+ return used
1779
+ }
1780
+
1781
+ function realOf(path) {
1782
+ try {
1783
+ return realpathSync(path)
1784
+ } catch {
1785
+ return resolve(path)
1786
+ }
1787
+ }
1788
+
1680
1789
  export async function doctor(args = [], { quiet = false } = {}) {
1681
1790
  const before = print
1682
1791
  print = quiet ? () => {} : toConsole
@@ -1823,11 +1932,36 @@ async function runDoctor(args = []) {
1823
1932
  }
1824
1933
  }
1825
1934
 
1826
- if (foundations.length === 0) {
1827
- warn('No foundations found')
1935
+ // Discover sites via the canonical workspace globs (same rationale as
1936
+ // foundations above: respects whatever layout the user chose).
1937
+ const allSites = (await discoverSites(workspaceDir)).map((s) => ({
1938
+ path: join(workspaceDir, s.path),
1939
+ name: s.name
1940
+ }))
1941
+ // ⭐ What is checked is where you stand (`doctorFocus`): the site you're in and what it is built from,
1942
+ // the foundation you're in, or — from anywhere else — the whole workspace.
1943
+ const focus = doctorFocus({ workspaceDir, projectDir, allSites, foundations, extensions })
1944
+ const checkedFoundations = focus ? focus.foundations : foundations
1945
+ const checkedExtensions = focus ? focus.extensions : extensions
1946
+ const sites = focus ? focus.sites : allSites
1947
+ if (focus) {
1948
+ const builtFrom = [...checkedFoundations, ...checkedExtensions].map((f) => relative(workspaceDir, f.path))
1949
+ log('')
1950
+ info(
1951
+ focus.site
1952
+ ? `Checking the site here, ${relative(workspaceDir, focus.site.path)}` +
1953
+ (builtFrom.length ? `, and what it is built from: ${builtFrom.join(', ')}.` : '.')
1954
+ : `Checking the foundation here, ${relative(workspaceDir, focus.foundation.path)}.`
1955
+ )
1956
+ log(` ${colors.dim}Run this from ${workspaceDir} for all ${allSites.length} site(s) and ${foundations.length + extensions.length} foundation(s).${colors.reset}`)
1957
+ }
1958
+
1959
+ if (checkedFoundations.length === 0) {
1960
+ // A site whose foundation is a catalog ref has none here, and its own checks name the ref.
1961
+ if (!focus) warn('No foundations found')
1828
1962
  } else {
1829
- success(`Found ${foundations.length} foundation(s):`)
1830
- for (const f of foundations) {
1963
+ success(`Found ${checkedFoundations.length} foundation(s):`)
1964
+ for (const f of checkedFoundations) {
1831
1965
  const nameMismatch =
1832
1966
  f.name !== f.folderName
1833
1967
  ? ` ${colors.dim}(folder: ${f.folderName}/)${colors.reset}`
@@ -1849,7 +1983,7 @@ async function runDoctor(args = []) {
1849
1983
  //
1850
1984
  // kit closes this for anyone who imports the file; this closes it for anyone
1851
1985
  // who does not, which is the case kit cannot reach.
1852
- for (const f of foundations) {
1986
+ for (const f of checkedFoundations) {
1853
1987
  // `f.path` is already absolute (built above with join(workspaceDir, …)).
1854
1988
  // ⛔ The stylesheet is where the foundation's source is. Until 2026-10-31 this read the
1855
1989
  // package root, so a foundation with `src/` inside its package was never checked.
@@ -1889,7 +2023,7 @@ async function runDoctor(args = []) {
1889
2023
 
1890
2024
  // A `@source` that finds nothing: the build succeeds and the CSS is short every class that was
1891
2025
  // only there. The build says so too; here it reaches `uniweb status`.
1892
- for (const f of foundations) {
2026
+ for (const f of checkedFoundations) {
1893
2027
  await checkStaleSources({ foundationName: f.name, srcDir: resolveFoundationSrcPath(f.path), issues })
1894
2028
  await checkUnreadFolders({ foundationName: f.name, srcDir: resolveFoundationSrcPath(f.path), issues })
1895
2029
  }
@@ -1900,7 +2034,7 @@ async function runDoctor(args = []) {
1900
2034
  // naming one styles nothing and says a design the page does not have.
1901
2035
  // Only where the foundation imports kit's layer and does not load the plugin
1902
2036
  // itself — with its own `@plugin`, the modifier still means what it says.
1903
- for (const f of foundations) {
2037
+ for (const f of checkedFoundations) {
1904
2038
  const stylesPath = join(resolveFoundationSrcPath(f.path), 'styles.css')
1905
2039
  if (!existsSync(stylesPath)) continue
1906
2040
  const styles = readFileSync(stylesPath, 'utf8')
@@ -1954,7 +2088,7 @@ async function runDoctor(args = []) {
1954
2088
  // That is the same class as the `dist/schema.json` path bug (a check that
1955
2089
  // never fires is indistinguishable from a codebase with nothing to report),
1956
2090
  // so it is named here rather than left to be rediscovered.
1957
- for (const f of foundations) {
2091
+ for (const f of checkedFoundations) {
1958
2092
  if (!loadSchemaJson(f.path)) {
1959
2093
  info(
1960
2094
  `${f.folderName}: not built, so nothing was checked here ` +
@@ -1965,7 +2099,7 @@ async function runDoctor(args = []) {
1965
2099
  }
1966
2100
 
1967
2101
  // ── uniweb.supports — the services this foundation says it is built against ──
1968
- for (const f of foundations) {
2102
+ for (const f of checkedFoundations) {
1969
2103
  await checkFoundationSupports({
1970
2104
  foundationName: f.name,
1971
2105
  folderName: f.folderName,
@@ -2014,7 +2148,7 @@ async function runDoctor(args = []) {
2014
2148
  // answer is the union across its primary foundation and its extensions. The
2015
2149
  // regex-era check looked at foundations only, so an extension that drew a
2016
2150
  // search box was never asked about one.
2017
- for (const e of extensions) {
2151
+ for (const e of checkedExtensions) {
2018
2152
  await checkFoundationSupports({
2019
2153
  foundationName: e.name,
2020
2154
  folderName: e.folderName,
@@ -2054,10 +2188,17 @@ async function runDoctor(args = []) {
2054
2188
  })
2055
2189
  }
2056
2190
 
2057
- if (extensions.length > 0) {
2191
+ // One name in a scope is one type: each defined by two packages here, among those checked.
2192
+ await checkTypesDefinedTwice({
2193
+ workspaceDir,
2194
+ checkedDirs: focus ? [...checkedFoundations, ...checkedExtensions].map((f) => f.path) : null,
2195
+ issues
2196
+ })
2197
+
2198
+ if (checkedExtensions.length > 0) {
2058
2199
  log('')
2059
- success(`Found ${extensions.length} extension(s):`)
2060
- for (const e of extensions) {
2200
+ success(`Found ${checkedExtensions.length} extension(s):`)
2201
+ for (const e of checkedExtensions) {
2061
2202
  const nameMismatch =
2062
2203
  e.name !== e.folderName
2063
2204
  ? ` ${colors.dim}(folder: ${e.folderName}/)${colors.reset}`
@@ -2066,23 +2207,10 @@ async function runDoctor(args = []) {
2066
2207
  }
2067
2208
  }
2068
2209
 
2069
- // Discover sites via the canonical workspace globs (same rationale as
2070
- // foundations above: respects whatever layout the user chose).
2071
- const allSites = (await discoverSites(workspaceDir)).map((s) => ({
2072
- path: join(workspaceDir, s.path),
2073
- name: s.name
2074
- }))
2075
- // From inside a site, its checks are that site's, as `status` and `dev` read the folder you
2076
- // stand in. Other sites' findings are there from the workspace root.
2077
- const here = siteAround(allSites.map((s) => relative(workspaceDir, s.path)), workspaceDir, projectDir)
2078
- const sites = here ? allSites.filter((s) => relative(workspaceDir, s.path) === here) : allSites
2079
- if (here && allSites.length > sites.length) {
2080
- log('')
2081
- info(`Checking the site you're in. Run this from ${workspaceDir} for all ${allSites.length}.`)
2082
- }
2083
-
2210
+ // The sites checked were chosen with the foundations (`doctorFocus`, above).
2084
2211
  if (sites.length === 0) {
2085
- warn('No sites found')
2212
+ // In a foundation, its sites are checked from where each one is, or from the workspace root.
2213
+ if (!focus) warn('No sites found')
2086
2214
  } else {
2087
2215
  log('')
2088
2216
  success(`Found ${sites.length} site(s):`)
@@ -64,6 +64,7 @@ import {
64
64
  readFileSync,
65
65
  writeFileSync,
66
66
  readdirSync,
67
+ realpathSync,
67
68
  statSync
68
69
  } from 'node:fs'
69
70
  import { execSync } from 'node:child_process'
@@ -100,6 +101,20 @@ import {
100
101
  } from '../utils/workspace.js'
101
102
  import { isNonInteractive, getCliPrefix } from '../utils/interactive.js'
102
103
  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
+ }
103
118
 
104
119
  const colors = {
105
120
  reset: '\x1b[0m',
@@ -603,6 +618,31 @@ export function foundationNeedsBuild(targetDir) {
603
618
  return { needs: false }
604
619
  }
605
620
 
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
+
606
646
  export async function register(args = []) {
607
647
  // See utils/flag-guard.js — an unrecognized flag is invisible to a
608
648
  // literal scan, so it silently keeps the default (production, for --backend).
@@ -713,6 +753,8 @@ async function runRegister(args = []) {
713
753
  if (!settled) return { exitCode: 2 }
714
754
  scope = settled.scope
715
755
  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 }
716
758
  // Build-if-stale (`foundationNeedsBuild`): a missing or stale dist/ gets
717
759
  // (re)built before we read its schema. Preview paths
718
760
  // (--dry-run / -o) must not write to dist/, so they require a pre-built
@@ -803,6 +845,9 @@ async function runRegister(args = []) {
803
845
  // states its own floor and whoever resolves a whole site does the arithmetic.
804
846
  const runtime = standalone ? null : readRuntimePin(join(targetDir, 'dist'))
805
847
 
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
+
806
851
  const exporter = { tool: 'uniweb', version: cliVersion(), instance: 'build' }
807
852
  let doc
808
853
  try {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-11-06T22:51:08.601Z",
3
+ "generatedAt": "2026-11-08T22:27:32.223Z",
4
4
  "packages": {
5
5
  "@uniweb/api": {
6
6
  "version": "1.6.9"
7
7
  },
8
8
  "@uniweb/build": {
9
- "version": "1.18.1"
9
+ "version": "1.19.0"
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.7"
18
+ "version": "1.6.8"
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.14"
27
+ "version": "1.7.15"
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.2"
39
+ "version": "1.5.3"
40
40
  },
41
41
  "@uniweb/scene": {
42
42
  "version": "1.0.1"
@@ -54,13 +54,13 @@
54
54
  "version": "1.1.2"
55
55
  },
56
56
  "@uniweb/templates": {
57
- "version": "1.2.9"
57
+ "version": "1.2.10"
58
58
  },
59
59
  "@uniweb/theming": {
60
- "version": "1.3.1"
60
+ "version": "1.3.2"
61
61
  },
62
62
  "@uniweb/unipress": {
63
- "version": "1.1.35"
63
+ "version": "1.1.36"
64
64
  }
65
65
  },
66
66
  "templates": {
@@ -356,29 +356,64 @@ export function computeRootScripts(sites, pm = 'pnpm') {
356
356
  return scripts
357
357
  }
358
358
 
359
- if (sites.length === 1) {
360
- scripts.dev = 'uniweb dev'
361
- scripts.preview = filterCmd(pm, sites[0].name, 'preview')
362
- } else {
363
- // First site gets unqualified dev/preview (matches `uniweb dev`'s
364
- // default-to-first-site behavior).
365
- scripts.dev = 'uniweb dev'
366
- scripts.preview = filterCmd(pm, sites[0].name, 'preview')
367
-
368
- // Subsequent sites get qualified dev:{name}/preview:{name}
369
- for (let i = 1; i < sites.length; i++) {
370
- scripts[`dev:${sites[i].name}`] = `uniweb dev ${sites[i].name}`
371
- scripts[`preview:${sites[i].name}`] = filterCmd(
372
- pm,
373
- sites[i].name,
374
- 'preview'
375
- )
376
- }
359
+ // First site gets unqualified dev/preview (matches `uniweb dev`'s
360
+ // default-to-first-site behavior).
361
+ scripts.dev = 'uniweb dev'
362
+ scripts.preview = previewCommand(pm, sites[0])
363
+
364
+ // Subsequent sites get qualified dev:{name}/preview:{name}, by the name a site's scripts go by
365
+ // (`siteScriptName`) — its package's where another site's scripts already go by its project's.
366
+ for (let i = 1; i < sites.length; i++) {
367
+ const name = [siteScriptName(sites[i]), sites[i].name].find((n) => !(`dev:${n}` in scripts)) ?? sites[i].name
368
+ scripts[`dev:${name}`] = `uniweb dev ${sites[i].name}`
369
+ scripts[`preview:${name}`] = previewCommand(pm, sites[i])
377
370
  }
378
371
 
379
372
  return scripts
380
373
  }
381
374
 
375
+ /**
376
+ * ⭐ THE NAME A SITE'S ROOT SCRIPTS GO BY: a site that is a project's own — `<project>/site`, the
377
+ * folder layout `uniweb add project` makes — by its project's, the name a person knows it by
378
+ * (`dev:marketing`); any other by its package's. The command still names the package, which no other
379
+ * site can share. ⛔ Until 2026-11-08 every site went by its package's, so a project's scripts were
380
+ * `dev:marketing-site` where a workspace of projects names them for the project.
381
+ *
382
+ * @param {{ name: string, path: string }} site - a site, `path` from the workspace root
383
+ * @returns {string}
384
+ */
385
+ export function siteScriptName(site) {
386
+ const parts = String(site.path || '').split(/[\\/]/).filter(Boolean)
387
+ return parts.length >= 2 && parts[parts.length - 1] === 'site' ? parts[parts.length - 2] : site.name
388
+ }
389
+
390
+ /**
391
+ * The command a site's `preview` script runs: its own `preview`, through the package manager — under
392
+ * pnpm by its name, and under npm by its folder, since npm also reads a name as a folder and selects
393
+ * every package in it (`dev.js::devCommand`, the same rule for `dev`). ⛔ Until 2026-11-08 npm's was by
394
+ * name, so a site named for the folder around it previewed the foundation beside it as well.
395
+ */
396
+ function previewCommand(pm, site) {
397
+ return filterCmd(pm, pm === 'npm' ? site.path : site.name, 'preview')
398
+ }
399
+
400
+ /**
401
+ * Whether `command` is one this CLI writes into a `dev:` or `preview:` root script, and for which
402
+ * site — a package's name, or under npm a site's folder. Null for a command the CLI never writes,
403
+ * which is the person's.
404
+ *
405
+ * @param {string} command
406
+ * @returns {string|null}
407
+ */
408
+ function cliScriptTarget(command) {
409
+ if (typeof command !== 'string') return null
410
+ const m =
411
+ /^uniweb dev (\S+)$/.exec(command) ||
412
+ /^pnpm --filter (\S+) (?:run )?(?:dev|preview)$/.exec(command) ||
413
+ /^npm -w (\S+) run (?:dev|preview)$/.exec(command)
414
+ return m ? m[1] : null
415
+ }
416
+
382
417
  /**
383
418
  * Regenerate the per-site root scripts from the sites there are now — what `rename` needs, since a
384
419
  * script it wrote for the old name runs a site that is gone. `add` adds instead (`addRootScripts`).
@@ -394,7 +429,8 @@ export async function updateRootScripts(rootDir, sites, pm = 'pnpm') {
394
429
  // ⭐ `preview` stays on the site it runs. Adding a site is no reason to move it, and
395
430
  // "first" follows the listing, so a new site sorted ahead took the script over. A command the
396
431
  // CLI didn't write is the person's, and only one for a site that's gone is rewritten.
397
- const runs = unique.find((s) => cliSiteScripts('preview', s.name).includes(scripts.preview))
432
+ const isSite = (s, target) => target === s.name || target === s.path
433
+ const runs = unique.find((s) => isSite(s, cliScriptTarget(scripts.preview)))
398
434
  const newScripts = computeRootScripts(runs ? [runs, ...unique.filter((s) => s !== runs)] : unique, pm)
399
435
  const previewIsCli = /^(pnpm --filter \S+ (run )?preview|npm -w \S+ run preview)$/.test(scripts.preview ?? '')
400
436
  if (scripts.preview && !runs && !previewIsCli) delete newScripts.preview
@@ -416,13 +452,14 @@ export async function updateRootScripts(rootDir, sites, pm = 'pnpm') {
416
452
 
417
453
  // ⭐ The per-site scripts this CLI writes are regenerated from the sites there are
418
454
  // now, and one it wrote for a site that is gone — renamed, moved, removed — goes.
419
- // A script whose command is not one the CLI writes is the user's, and stays.
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`).
420
457
  // ⛔ Until 2026-10-13 they were only ever added: after `rename site blog journal`,
421
458
  // `dev:blog` still ran `uniweb dev blog`, a site that no longer existed.
422
459
  for (const [key, value] of Object.entries(scripts)) {
423
- if (key in newScripts) continue
424
- const m = /^(dev|preview):(.+)$/.exec(key)
425
- if (m && cliSiteScripts(m[1], m[2]).includes(value)) delete scripts[key]
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]
426
463
  }
427
464
 
428
465
  pkg.scripts = { ...scripts, ...newScripts }
@@ -461,10 +498,13 @@ export async function addRootScripts(rootDir, added, sites, pm = 'pnpm') {
461
498
  added.forEach((site, i) => {
462
499
  if (isFirst && i === 0) {
463
500
  wanted.dev = 'uniweb dev'
464
- wanted.preview = filterCmd(pm, site.name, 'preview')
501
+ wanted.preview = previewCommand(pm, site)
465
502
  } else {
466
- wanted[`dev:${site.name}`] = `uniweb dev ${site.name}`
467
- wanted[`preview:${site.name}`] = filterCmd(pm, site.name, 'preview')
503
+ // By the name its scripts go by (`siteScriptName`), else its package's where that is taken.
504
+ const free = (n) => !(`dev:${n}` in scripts) && !(`dev:${n}` in wanted)
505
+ const name = [siteScriptName(site), site.name].find(free) ?? site.name
506
+ wanted[`dev:${name}`] = `uniweb dev ${site.name}`
507
+ wanted[`preview:${name}`] = previewCommand(pm, site)
468
508
  }
469
509
  })
470
510
 
@@ -477,10 +517,4 @@ export async function addRootScripts(rootDir, added, sites, pm = 'pnpm') {
477
517
  return written
478
518
  }
479
519
 
480
- /** Every command this CLI has written for the `dev:<site>` / `preview:<site>` script. */
481
- function cliSiteScripts(kind, site) {
482
- return kind === 'dev'
483
- ? [`uniweb dev ${site}`, filterCmd('pnpm', site, 'dev'), filterCmd('npm', site, 'dev')]
484
- : [filterCmd('pnpm', site, 'preview'), filterCmd('npm', site, 'preview')]
485
- }
486
520
 
@@ -0,0 +1,29 @@
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.
6
+ */
7
+
8
+ import { join } from 'node:path'
9
+ import { classifyPackage, isSchemasPackage, typesDefinedTwice } from '@uniweb/build'
10
+ import { workspacePackages } from './workspace-packages.js'
11
+
12
+ /**
13
+ * The names of one scope two packages of the workspace define.
14
+ *
15
+ * @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
+ * @returns {Promise<{ ref: string, files: string[], differ: boolean }[]>}
19
+ */
20
+ export async function workspaceTypesDefinedTwice(workspaceDir, self = null) {
21
+ const packages = []
22
+ for (const rel of workspacePackages(workspaceDir)) {
23
+ const dir = join(workspaceDir, rel)
24
+ const kind = classifyPackage(dir) === 'foundation' ? 'foundation' : isSchemasPackage(dir) ? 'schemas' : null
25
+ if (kind) packages.push({ dir, kind })
26
+ }
27
+ if (self) packages.unshift(self)
28
+ return typesDefinedTwice(packages)
29
+ }
@@ -1,7 +1,4 @@
1
- @import "tailwindcss";
1
+ /* Tailwind reads this whole foundation, in its own build and in a site's, so no folder can be left out. */
2
+ @import "tailwindcss" source("./");
2
3
  @import "@uniweb/kit/theme-tokens.css";
3
4
 
4
- @source "./sections/**/*.{js,jsx}";
5
- @source "./components/**/*.{js,jsx}";
6
- @source "./layouts/**/*.{js,jsx}";
7
- @source "./utils/**/*.{js,jsx}";