uniweb 1.25.1 → 1.25.3

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.25.1",
3
+ "version": "1.25.3",
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/core": "~1.6.0",
45
- "@uniweb/semantic-parser": "~1.13.2",
44
+ "@uniweb/content-writer": "~1.3.1",
46
45
  "@uniweb/schemas": "~1.6.7",
47
- "@uniweb/content-writer": "~1.3.1"
46
+ "@uniweb/core": "~1.6.1",
47
+ "@uniweb/semantic-parser": "~1.13.2"
48
48
  },
49
49
  "peerDependencies": {
50
- "@uniweb/build": "~1.14.0",
51
50
  "@uniweb/semantic-parser": "~1.13.2",
52
- "@uniweb/content-reader": "~1.5.8"
51
+ "@uniweb/content-reader": "~1.5.8",
52
+ "@uniweb/build": "~1.14.1"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@uniweb/build": {
@@ -2321,6 +2321,10 @@ A site may also name a vendor's own script under `services.tracking.scripts`, wh
2321
2321
  runtime loads once, after consent when a gate is declared, and never in a frame
2322
2322
  or during prerender. That is a **separate path with no connection to the stream
2323
2323
  below** — the vendor measures its own way, and nothing you `track()` reaches it.
2324
+ An entry is a URL and nothing else, so a vendor whose install also runs inline
2325
+ lines does not work this way: Google Analytics and Google Tag Manager both do. On a
2326
+ site you publish, an entry with no endpoint also asks the host for its collector;
2327
+ `enabled: false` beside `scripts` loads the script alone.
2324
2328
 
2325
2329
  **Some events you get for free.** These are reported for you, with no call from
2326
2330
  your foundation and regardless of how it renders:
@@ -2330,9 +2334,12 @@ your foundation and regardless of how it renders:
2330
2334
  | `page_view` | every route change, including the first |
2331
2335
  | `outbound_click` | a visitor follows a link off the site — the destination **host** only, never the full URL |
2332
2336
  | `section_view` | a section first becomes half-visible, on pages that ask for it (`trackSections`, below) |
2337
+ | `conversion` | a phone or email tap (`name: phone`, `email`), and a link or page the site lists in `services.tracking.conversions`; also a form accepted by a provider of the site's own through `useFormSubmit`, and a sign-up through `@uniweb/api` |
2338
+ | `engagement` | a sign-in through `@uniweb/api` (`name: sign_in`) |
2333
2339
 
2334
- ⛔ **So don't write your own link-click or scroll-into-view listener for these.**
2335
- A second one double-counts against a collector that already has them.
2340
+ ⛔ **So don't write your own link-click or scroll-into-view listener for these,**
2341
+ and don't report a sign-up, a sign-in or an accepted form that goes through kit or
2342
+ `@uniweb/api`. A second report double-counts against a collector that already has them.
2336
2343
 
2337
2344
  Everything else is yours to report:
2338
2345
 
@@ -2351,11 +2358,13 @@ const { track } = useTracker()
2351
2358
  <button onClick={() => track('brochure_download', { file: 'specs.pdf' })}>…</button>
2352
2359
  ```
2353
2360
 
2354
- The event name is yours — there is no list of permitted names. Five are already
2355
- in use, so reach for these rather than inventing a synonym: the three automatic
2356
- ones above — **`page_view`**, **`outbound_click`**, **`section_view`** — plus
2357
- **`video_milestone`**, which kit's `<Media>` reports for any video you render
2358
- through it, and **`read_depth`** from `useReadingDepth()` below. Put the
2361
+ The event name is yours — there is no list of permitted names. Seven are already
2362
+ in use, so reach for these rather than inventing a synonym: the automatic ones
2363
+ above — **`page_view`**, **`outbound_click`**, **`section_view`**, **`conversion`**,
2364
+ **`engagement`** — plus **`video_milestone`**, which kit's `<Media>` reports for any
2365
+ video you render through it, and **`read_depth`** from `useReadingDepth()` below.
2366
+ What your foundation alone can see that a site counts is
2367
+ `block.track('conversion', { name: 'quote_requested' })`, with a short name. Put the
2359
2368
  varying part in a **field**, never in the name — four names for one event turn a
2360
2369
  collector's event dimension into a cardinality problem.
2361
2370
 
@@ -183,9 +183,19 @@ export function serviceNotes({ siteYml, supports = null, warn = () => {} }) {
183
183
  // past that entry, is wrong: `search: yes` was "site.yml turns on `search`" (F14).
184
184
  if (unreadableServices(siteYml?.services).length) return []
185
185
  const asks = readServicesRequest(siteYml?.services, { warn }) || []
186
- if (!Array.isArray(supports)) return []
187
186
  const notes = []
188
- const ignored = new Set(['tracking', 'records'])
187
+ // A site's own list replaces what its host states, key by key (`readServiceOptions`), and
188
+ // `services.google` reaches the page as the host's list.
189
+ if (siteYml?.services?.google && siteYml?.services?.tracking?.scripts) {
190
+ notes.push(
191
+ '`services.tracking.scripts` replaces the script your host loads for `services.google`, ' +
192
+ "so Google's tag will not load. Keep one of them."
193
+ )
194
+ }
195
+ if (!Array.isArray(supports)) return notes
196
+ // None of these is something a foundation renders: `google` and `tracking` load or report
197
+ // whatever the foundation is, and `records` is invisible to it.
198
+ const ignored = new Set(['tracking', 'records', 'google'])
189
199
  const has = (ask) => ask.enabled !== false || typeof ask.config?.endpoint === 'string'
190
200
  const unrendered = asks.filter((a) => has(a) && !ignored.has(a.name) && !supports.includes(a.name)).map((a) => a.name)
191
201
  if (unrendered.length) {
@@ -56,7 +56,7 @@
56
56
 
57
57
  import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'
58
58
  import { resolve, join, dirname, basename, relative } from 'node:path'
59
- import { spawn } from 'node:child_process'
59
+ import { runRelayed } from '../utils/closed-reader.js'
60
60
  import { writeFile, mkdir } from 'node:fs/promises'
61
61
  import { createRequire } from 'node:module'
62
62
 
@@ -143,27 +143,13 @@ function detectProjectType(projectDir) {
143
143
  }
144
144
 
145
145
  /**
146
- * Run a command and return a promise
146
+ * Run a command, and throw if it fails
147
147
  */
148
- function runCommand(command, args, cwd) {
149
- return new Promise((resolve, reject) => {
150
- // No shell: the command is node and a script path, which needs none — and a shell
151
- // splits a path with a space in it. (Node warns DEP0190 on args passed with one.)
152
- const proc = spawn(command, args, {
153
- cwd,
154
- stdio: 'inherit'
155
- })
156
-
157
- proc.on('close', (code) => {
158
- if (code === 0) {
159
- resolve()
160
- } else {
161
- reject(new Error(`Command failed with exit code ${code}`))
162
- }
163
- })
164
-
165
- proc.on('error', reject)
166
- })
148
+ async function runCommand(command, args, cwd) {
149
+ // No shell: the command is node and a script path, which needs none — and a shell
150
+ // splits a path with a space in it. (Node warns DEP0190 on args passed with one.)
151
+ const code = await runRelayed(command, args, { cwd })
152
+ if (code !== 0) throw new Error(`Command failed with exit code ${code}`)
167
153
  }
168
154
 
169
155
  /**
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-11-02T00:19:04.917Z",
3
+ "generatedAt": "2026-11-02T04:09:19.127Z",
4
4
  "packages": {
5
5
  "@uniweb/api": {
6
- "version": "1.6.8"
6
+ "version": "1.6.9"
7
7
  },
8
8
  "@uniweb/build": {
9
- "version": "1.14.0"
9
+ "version": "1.14.1"
10
10
  },
11
11
  "@uniweb/content-reader": {
12
12
  "version": "1.5.8"
@@ -15,7 +15,7 @@
15
15
  "version": "1.3.1"
16
16
  },
17
17
  "@uniweb/core": {
18
- "version": "1.6.0"
18
+ "version": "1.6.1"
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.0"
27
+ "version": "1.7.1"
28
28
  },
29
29
  "@uniweb/loom": {
30
30
  "version": "1.1.2"
@@ -36,7 +36,7 @@
36
36
  "version": "1.2.10"
37
37
  },
38
38
  "@uniweb/runtime": {
39
- "version": "1.3.9"
39
+ "version": "1.3.10"
40
40
  },
41
41
  "@uniweb/scene": {
42
42
  "version": "1.0.1"
@@ -60,7 +60,7 @@
60
60
  "version": "1.2.1"
61
61
  },
62
62
  "@uniweb/unipress": {
63
- "version": "1.1.29"
63
+ "version": "1.1.30"
64
64
  }
65
65
  },
66
66
  "templates": {
package/src/index.js CHANGED
@@ -73,6 +73,7 @@ import {
73
73
  } from './utils/interactive.js'
74
74
  import { findWorkspaceRoot } from './utils/workspace.js'
75
75
  import { exitWhenDrained } from './utils/exit.js'
76
+ import { outliveTheReader } from './utils/closed-reader.js'
76
77
  import { isGitRepo } from './utils/git.js'
77
78
 
78
79
  // Colors for terminal output
@@ -646,6 +647,7 @@ function computeFoundationFilePath(sitePath, foundationPath) {
646
647
  }
647
648
 
648
649
  async function main() {
650
+ outliveTheReader()
649
651
  const rawArgs = process.argv.slice(2)
650
652
  const nonInteractive = isNonInteractive(rawArgs)
651
653
  const args = stripNonInteractiveFlag(rawArgs)
@@ -0,0 +1,65 @@
1
+ /**
2
+ * A reader that goes away stops the output, never the work.
3
+ *
4
+ * ⛔ An agent trims what it reads, and `uniweb create x | head -20` closes the pipe after twenty
5
+ * lines. The next line raised EPIPE, which nothing handled, so the process ended there: 14 of the
6
+ * project's 27 files, and the same command again said the directory exists. `uniweb build | head -5`
7
+ * left no site. Merged with `2>&1` the stack trace went into the closed pipe too, so what came back
8
+ * was healthy lines and head's exit status, 0 (measured 2026-11-01).
9
+ *
10
+ * ⭐ So a process nobody is reading keeps going, and exits with what the work came to.
11
+ */
12
+
13
+ import { spawn } from 'node:child_process'
14
+ import { fstatSync } from 'node:fs'
15
+ import { whenDrained } from './exit.js'
16
+
17
+ /** For the CLI's own process, once, before it prints. Any other write error stays an error. */
18
+ export function outliveTheReader() {
19
+ for (const stream of [process.stdout, process.stderr]) {
20
+ stream.on('error', (err) => {
21
+ if (err.code !== 'EPIPE') throw err
22
+ })
23
+ }
24
+ }
25
+
26
+ // A terminal or a file can't stop reading, and a child handed one directly keeps its colours and
27
+ // the exact order of its two streams.
28
+ function readerCanLeave(fd) {
29
+ try {
30
+ const at = fstatSync(fd)
31
+ return at.isFIFO() || at.isSocket()
32
+ } catch {
33
+ return false
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Run a child that does work and prints as it goes. Handed our output directly, it meets a closed
39
+ * pipe in its own process and dies of it, as Vite does. So where the reader can leave, the child
40
+ * writes to us and we pass it on, and only our writes can fail. pnpm and npm survive a closed reader
41
+ * (measured 2026-11-01), our own CLI does through `outliveTheReader`, and a dev server has no work to
42
+ * finish, so those keep `stdio: 'inherit'`.
43
+ *
44
+ * Resolves with the exit code, once the child's output has left this process, so an exit straight
45
+ * after loses none of it (`exit.js`).
46
+ *
47
+ * @param {string} command
48
+ * @param {string[]} args
49
+ * @param {import('node:child_process').SpawnOptions} [options]
50
+ * @returns {Promise<number|null>}
51
+ */
52
+ export function runRelayed(command, args, options = {}) {
53
+ return new Promise((resolve, reject) => {
54
+ const child = spawn(command, args, {
55
+ ...options,
56
+ stdio: ['inherit', readerCanLeave(1) ? 'pipe' : 'inherit', readerCanLeave(2) ? 'pipe' : 'inherit']
57
+ })
58
+ // Not `.pipe()`: that stops reading when its destination fails, and the child then blocks on a
59
+ // full pipe for good.
60
+ child.stdout?.on('data', (chunk) => process.stdout.write(chunk))
61
+ child.stderr?.on('data', (chunk) => process.stderr.write(chunk))
62
+ child.on('error', reject)
63
+ child.on('close', (code) => whenDrained().then(() => resolve(code)))
64
+ })
65
+ }
package/src/utils/exit.js CHANGED
@@ -18,10 +18,15 @@
18
18
  * @returns {Promise<never>}
19
19
  */
20
20
  export async function exitWhenDrained(code = 0) {
21
- await Promise.all([process.stdout, process.stderr].map(drained))
21
+ await whenDrained()
22
22
  process.exit(code)
23
23
  }
24
24
 
25
+ /** Once everything written so far to stdout and stderr has left this process. */
26
+ export function whenDrained() {
27
+ return Promise.all([process.stdout, process.stderr].map(drained))
28
+ }
29
+
25
30
  function drained(stream) {
26
31
  return new Promise((resolve) => {
27
32
  if (!stream || stream.destroyed || stream.writableEnded) return resolve()