uniweb 1.31.10 → 1.31.11

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.31.10",
3
+ "version": "1.31.11",
4
4
  "description": "Create structured Vite + React sites with content/code separation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,14 +42,14 @@
42
42
  "prompts": "^2.4.2",
43
43
  "tar": "^7.5.21",
44
44
  "@uniweb/content-writer": "~1.3.1",
45
- "@uniweb/core": "~1.6.11",
46
- "@uniweb/semantic-parser": "~1.13.2",
47
- "@uniweb/schemas": "~1.7.1"
45
+ "@uniweb/schemas": "~1.7.1",
46
+ "@uniweb/core": "~1.6.12",
47
+ "@uniweb/semantic-parser": "~1.13.2"
48
48
  },
49
49
  "peerDependencies": {
50
- "@uniweb/build": "~1.20.8",
51
- "@uniweb/semantic-parser": "~1.13.2",
52
- "@uniweb/content-reader": "~1.5.9"
50
+ "@uniweb/build": "~1.20.9",
51
+ "@uniweb/content-reader": "~1.5.9",
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 directory: `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
- **Any foundation can use a data schema another defines, by its full name** — `data: { members: '@acme/member' }`, `schema: '@acme/member'` in `queries.yml`. No backend is involved, and nothing to configure: a local build, `uniweb dev` included, reads the type from the package of the workspace that defines it (a foundation whose name gives the `@acme` scope, with the type in its own `schemas/`), or from a library the foundation bundles whose package.json gives that scope (`uniweb guide foundation` § Libraries). Two packages defining it stop the build, naming both. A type no such package defines comes from `schemas.config.js` (`'@acme/member': '../elsewhere/member.yml'`, or the scope's directory), which wins over both, or an installed `@acme/schemas` package. A scope is a namespace that keeps names from colliding, not a limit on who uses a type. So a type another foundation defines 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`). Registering, which only a site with a backend does, names such a type and sends no definition of it; a type a library defines is registered from the library, first (`uniweb guide foundation` § Libraries). A push also needs one of the site's foundations to declare the type, as a section type's data key or a schema of its own: the backend refuses a query whose type none of them declares, since nothing there would render it. A site can hold another site's records of a type too: `paths: { 'records/acme/member': '../../hub/site/records/acme/member' }` in its `site.yml` reads them as its own, a push adds them by reference rather than as copies once their own site has pushed them, and a pull leaves those files alone. A site's records of it sit in `records/acme/member/`; in `records/member/` they'd be the foundation's own `@/member`.
139
+ **Any foundation can use a data schema another defines, by its full name** — `data: { members: '@acme/member' }`, `schema: '@acme/member'` in `queries.yml`. No backend is involved, and nothing to configure: a local build, `uniweb dev` included, reads the type from the package of the workspace that defines it (a foundation whose name gives the `@acme` scope, with the type in its own `schemas/`), or from a library the foundation bundles whose package.json gives that scope (`uniweb guide foundation` § Libraries). Two packages defining it stop the build, naming both. A type no such package defines comes from `schemas.config.js` (`'@acme/member': '../elsewhere/member.yml'`, or the scope's directory), which wins over both, or an installed `@acme/schemas` package. A scope is a namespace that keeps names from colliding, not a limit on who uses a type. So a type another foundation defines 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`). Registering, which only a site with a backend does, names such a type and sends no definition of it; a type a library defines is registered from the library, first (`uniweb guide foundation` § Libraries). A push also needs one of the site's foundations to declare the type, as a section type's data key or a schema of its own: the backend refuses a query whose type none of them declares, since nothing there would render it. A site can hold another site's records of a type too: `paths: { 'records/acme/member': '../../hub/site/records/acme/member' }` in its `site.yml` reads them as its own, a push adds them by reference rather than as copies once their own site has pushed them, and a pull leaves those files alone. Two sites whose `paths: { records: … }` name one folder are not that: each push sends the folder's records as its own, two of each on the backend. 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 } }
@@ -616,16 +616,31 @@ async function bringLocalCodeAlong({
616
616
  })
617
617
  }
618
618
 
619
+ /**
620
+ * A step this command runs as a process of its own, which prints why it stops. What a failed one
621
+ * throws back names only that, never its command line: ⛔ until 2026-11-10 a refused release ended
622
+ * on "Foundation release failed: Command failed: node /<absolute path>/index.js register
623
+ * --non-interactive --org @acme", which reads as a command to run.
624
+ */
625
+ function runStep(argv, options, what) {
626
+ try {
627
+ execFileSync('node', argv, options)
628
+ } catch (err) {
629
+ if (typeof err?.status !== 'number') throw err
630
+ throw Object.assign(new Error(`${what} stopped, as it says above`), { status: err.status })
631
+ }
632
+ }
633
+
619
634
  // Build the foundation so its dist/ can be fingerprinted. Idempotent — the
620
635
  // foundation build no-ops when already fresh.
621
636
  function buildFoundation(local, cliBin) {
622
- execFileSync('node', [cliBin, 'build', '--target', 'foundation'], {
637
+ runStep([cliBin, 'build', '--target', 'foundation'], {
623
638
  cwd: local.dir,
624
639
  stdio: 'inherit',
625
640
  // A step of this command, so the build skips the next-step hints meant for
626
641
  // someone who ran `uniweb build` themselves.
627
642
  env: { ...process.env, UNIWEB_BUILD_STEP: '1' }
628
- })
643
+ }, 'its build (`uniweb build`)')
629
644
  }
630
645
 
631
646
  // Release = `uniweb register` in the foundation directory (the one foundation
@@ -636,11 +651,11 @@ function releaseFoundation(local, args, cliBin, say, origin) {
636
651
  // ⭐ Pinned to the parent's backend through the environment, so the release lands
637
652
  // where the publish goes by construction — not because two processes happen to read
638
653
  // the same session file the same way.
639
- execFileSync('node', [cliBin, 'register', ...forwardedFlags(args)], {
654
+ runStep([cliBin, 'register', ...forwardedFlags(args)], {
640
655
  cwd: local.dir,
641
656
  stdio: 'inherit',
642
657
  env: origin ? { ...process.env, UNIWEB_SERVER: origin } : process.env
643
- })
658
+ }, '`uniweb register`')
644
659
  console.log('')
645
660
  return true
646
661
  }
@@ -683,6 +683,9 @@ export async function push(args = [], deps = {}) {
683
683
  holdUnchangedPush(siteDir, client.origin)
684
684
  // What it recorded on the way — a media map, an identity recovered — is committed too.
685
685
  reportWriteBacks(commitWriteBacks(siteDir, client.origin, { released }), { note })
686
+ // ⭐ An earlier push's retired records too, which is what "push again with --yes" is for
687
+ // (`settleRetiredRecords`). ⛔ Until 2026-11-10 this returned first, and that line did nothing.
688
+ await settleRetiredRecords({ client, siteDir, args, say: { ok: success, dim: note, warn: note } })
686
689
  }
687
690
  return { exitCode: 0 }
688
691
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-11-10T19:03:10.178Z",
3
+ "generatedAt": "2026-11-10T20:35:09.553Z",
4
4
  "packages": {
5
5
  "@uniweb/api": {
6
6
  "version": "1.7.0"
7
7
  },
8
8
  "@uniweb/build": {
9
- "version": "1.20.8"
9
+ "version": "1.20.9"
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.11"
18
+ "version": "1.6.12"
19
19
  },
20
20
  "@uniweb/frame-bridge": {
21
21
  "version": "1.0.3"
@@ -36,7 +36,7 @@
36
36
  "version": "1.2.16"
37
37
  },
38
38
  "@uniweb/runtime": {
39
- "version": "1.5.7"
39
+ "version": "1.5.8"
40
40
  },
41
41
  "@uniweb/scene": {
42
42
  "version": "1.0.1"
@@ -7,17 +7,27 @@
7
7
  * the cleanup to the app — agents do most of the work through the CLI. The backend's route keeps a
8
8
  * record that a folder outside the call still places (another site's), and names it.
9
9
  *
10
- * ⭐ ASKED AT THE END OF THE PUSH THAT RETIRED THEM, and of a publish, which pushes. A published
11
- * site reads its records from its folder as the folder stands, with no snapshot taken at publish, so
12
- * the push has already taken them off the live site [backend, 2026-11-04 —
13
- * `backend/docs/delivery-orientation.md`: "Adding a blog post updates the live site with no
14
- * republish"]. ⛔ Until then this asked only at publish, "because until then the live site still has
15
- * the folder that placed them", which is not how that wire behaves. It also meant a site whose author
16
- * pushes its records and never publishes again was never asked.
10
+ * ⭐ ASKED AT THE END OF EVERY PUSH, and of a publish, which pushes. A published site reads its
11
+ * records from its folder as the folder stands, with no snapshot taken at publish, so the push has
12
+ * already taken them off the live site [backend, 2026-11-04 — `backend/docs/delivery-orientation.md`:
13
+ * "Adding a blog post updates the live site with no republish"]. ⛔ Until then this asked only at
14
+ * publish, "because until then the live site still has the folder that placed them", which is not
15
+ * how that wire behaves. ⛔ And until 2026-11-10 only a push that sent something asked, so the line
16
+ * a push without a terminal prints, "push again with --yes", did nothing when nothing else had
17
+ * changed: that push stopped at "Nothing to push" first (measured on the playground).
17
18
  *
18
19
  * As emptying the folder does, it asks first, and `--yes` is the way past the question. With no
19
20
  * terminal and no `--yes`, it keeps them and says how to finish. A person who declines keeps them,
20
21
  * and is not asked again.
22
+ *
23
+ * ⭐ A RECORD ANOTHER SITE'S FOLDER STILL PLACES IS KEPT, AND DELETED ONCE NONE DOES. A site that
24
+ * mounts this site's records (`site.yml` `paths:`) places them by reference, so a record whose file
25
+ * this site deleted is still on that site until that site pushes again. The backend keeps it then,
26
+ * and this copy holds the choice to delete it (`sync.json` `deleting`): each later push asks the
27
+ * backend again, with no question, and it goes once nothing places it. ⛔ Until 2026-11-10 a kept
28
+ * record was dropped from the list, and once the other site's push stopped placing it, it stayed on
29
+ * the backend in no folder, where nothing offered to delete it (measured on the playground). The
30
+ * messages said those records stay "where no site serves them", which a mounting site contradicted.
21
31
  */
22
32
 
23
33
  import { readBackendState, setBackendMap } from '@uniweb/build/uwx'
@@ -32,8 +42,44 @@ function describeRetired(retired) {
32
42
  return `${n === 1 ? '1 record' : `${n} records`} (${groups.join(', ')})`
33
43
  }
34
44
 
45
+ const records = (n) => (n === 1 ? '1 record' : `${n} records`)
46
+
47
+ /**
48
+ * The records this copy chose to delete that the backend kept, asked about again: no question, since
49
+ * the choice was made. Those the backend deletes, or that name nothing any more, leave the list.
50
+ */
51
+ async function finishDeleting({ client, siteDir, say }) {
52
+ const pending = readBackendState(siteDir, client.origin).deleting || {}
53
+ const uuids = Object.keys(pending)
54
+ if (!uuids.length) return 0
55
+ let res
56
+ try {
57
+ res = await client.deleteEntities({ uuids, placed: 'keep' })
58
+ } catch {
59
+ return 0 // the next push asks again
60
+ }
61
+ // A backend older than its delete route: they wait for one that has it.
62
+ if (res.status === 404) return 0
63
+ const body = await res.json().catch(() => null)
64
+ if (!res.ok) {
65
+ // Refused whole, which asking again would be too: the app is where they go now.
66
+ say.warn(
67
+ `${client.origin} did not delete ${records(uuids.length)} this copy is deleting: HTTP ${res.status}` +
68
+ `${body?.detail ? ` — ${body.detail}` : ''}. Delete ${uuids.length === 1 ? 'it' : 'them'} in the app if ${uuids.length === 1 ? 'it' : 'they'} should go.`
69
+ )
70
+ setBackendMap(siteDir, client.origin, 'deleting', {})
71
+ return 0
72
+ }
73
+ const deleted = Array.isArray(body?.deleted) ? body.deleted : []
74
+ const kept = new Set(Array.isArray(body?.kept) ? body.kept : [])
75
+ if (deleted.length) say.ok(`Deleted ${records(deleted.length)} that another site's folder no longer places.`)
76
+ setBackendMap(siteDir, client.origin, 'deleting', Object.fromEntries(uuids.filter((u) => kept.has(u)).map((u) => [u, pending[u]])))
77
+ return deleted.length
78
+ }
79
+
35
80
  /**
36
- * After a push, or a publish: offer to delete the retired records, and delete them on a yes.
81
+ * After a push, or a publish: offer to delete the retired records, and delete them on a yes; and
82
+ * finish deleting those another site's folder placed when they were asked about.
37
83
  *
38
84
  * @param {object} params
39
85
  * @param {object} params.client - a `BackendClient` on the site's backend, in its workspace
@@ -44,29 +90,32 @@ function describeRetired(retired) {
44
90
  * @returns {Promise<{ deleted: number, kept: number, asked: boolean }>}
45
91
  */
46
92
  export async function settleRetiredRecords({ client, siteDir, args = [], say, ask = confirm }) {
93
+ const finished = await finishDeleting({ client, siteDir, say })
47
94
  const retired = readBackendState(siteDir, client.origin).retired || {}
48
95
  const uuids = Object.keys(retired)
49
- if (!uuids.length) return { deleted: 0, kept: 0, asked: false }
96
+ if (!uuids.length) return { deleted: finished, kept: 0, asked: false }
50
97
  const what = describeRetired(retired)
98
+ const one = uuids.length === 1
51
99
  const forget = (done) =>
52
100
  setBackendMap(siteDir, client.origin, 'retired', Object.fromEntries(Object.entries(retired).filter(([u]) => !done.includes(u))))
53
101
 
54
102
  if (!args.includes('--yes')) {
55
103
  if (isNonInteractive(args)) {
56
104
  say.dim(
57
- `! ${what} that pushes took out of the site's folder stay on the backend, where no site serves them. ` +
58
- 'To delete them, push again with --yes, or from a terminal and answer.'
105
+ `! ${what} that pushes took out of the site's folder ${one ? 'stays' : 'stay'} on the backend. ` +
106
+ 'To delete them, push again with --yes, or from a terminal and answer. ' +
107
+ "A record another site's folder still places is kept until none does."
59
108
  )
60
- return { deleted: 0, kept: uuids.length, asked: false }
109
+ return { deleted: finished, kept: uuids.length, asked: false }
61
110
  }
62
111
  const yes = await ask(
63
- `Delete ${what} that pushes took out of the site's folder from ${client.origin}? A record another site's folder places is kept.`,
112
+ `Delete ${what} that pushes took out of the site's folder from ${client.origin}? A record another site's folder places is kept until none does.`,
64
113
  false
65
114
  )
66
115
  if (!yes) {
67
116
  forget(uuids)
68
- say.dim('Kept them on the backend, where no site serves them. They are not asked about again.')
69
- return { deleted: 0, kept: uuids.length, asked: true }
117
+ say.dim('Kept them on the backend. They are not asked about again.')
118
+ return { deleted: finished, kept: uuids.length, asked: true }
70
119
  }
71
120
  }
72
121
 
@@ -75,12 +124,12 @@ export async function settleRetiredRecords({ client, siteDir, args = [], say, as
75
124
  res = await client.deleteEntities({ uuids, placed: 'keep' })
76
125
  } catch (err) {
77
126
  say.warn(`Could not delete them: ${err?.message || err}. They stay on the backend; the next push asks again.`)
78
- return { deleted: 0, kept: uuids.length, asked: true }
127
+ return { deleted: finished, kept: uuids.length, asked: true }
79
128
  }
80
129
  if (res.status === 404) {
81
130
  // A backend older than its delete route: they wait for one that has it.
82
- say.dim(`! ${client.origin} cannot delete records from the CLI yet, so they stay, where no site serves them.`)
83
- return { deleted: 0, kept: uuids.length, asked: true }
131
+ say.dim(`! ${client.origin} cannot delete records from the CLI yet, so they stay on the backend.`)
132
+ return { deleted: finished, kept: uuids.length, asked: true }
84
133
  }
85
134
  const body = await res.json().catch(() => null)
86
135
  if (!res.ok) {
@@ -88,18 +137,23 @@ export async function settleRetiredRecords({ client, siteDir, args = [], say, as
88
137
  // nothing was deleted, and asking again would be refused again.
89
138
  say.warn(
90
139
  `${client.origin} did not delete them: HTTP ${res.status}${body?.detail ? ` — ${body.detail}` : ''}. ` +
91
- 'They stay on the backend, where no site serves them; delete them in the app if they should go.'
140
+ 'They stay on the backend; delete them in the app if they should go.'
92
141
  )
93
142
  forget(uuids)
94
- return { deleted: 0, kept: uuids.length, asked: true }
143
+ return { deleted: finished, kept: uuids.length, asked: true }
95
144
  }
96
145
  const deleted = Array.isArray(body?.deleted) ? body.deleted : []
97
- const kept = Array.isArray(body?.kept) ? body.kept : []
98
- if (deleted.length) say.ok(`Deleted ${deleted.length === 1 ? '1 record' : `${deleted.length} records`} from the backend.`)
146
+ const kept = (Array.isArray(body?.kept) ? body.kept : []).filter((u) => retired[u])
147
+ if (deleted.length) say.ok(`Deleted ${records(deleted.length)} from the backend.`)
99
148
  if (kept.length) {
100
- say.dim(`Kept ${kept.length === 1 ? '1 record' : `${kept.length} records`}: another site's folder still places ${kept.length === 1 ? 'it' : 'them'}.`)
149
+ // Chosen for deletion, and kept for another site's folder: deleted at a later push, once none
150
+ // places it (`finishDeleting`).
151
+ const pending = readBackendState(siteDir, client.origin).deleting || {}
152
+ setBackendMap(siteDir, client.origin, 'deleting', { ...pending, ...Object.fromEntries(kept.map((u) => [u, retired[u]])) })
153
+ const it = kept.length === 1 ? 'it' : 'them'
154
+ say.dim(`Kept ${records(kept.length)}: another site's folder still places ${it}. A later push deletes ${it} once none does.`)
101
155
  }
102
- // Every uuid is settled: deleted, kept for another folder, or naming nothing any more.
156
+ // Every uuid is settled: deleted, held to delete once no folder places it, or naming nothing any more.
103
157
  forget(uuids)
104
- return { deleted: deleted.length, kept: kept.length, asked: true }
158
+ return { deleted: finished + deleted.length, kept: kept.length, asked: true }
105
159
  }