@uniweb/build 1.14.0 → 1.14.1

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/build",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "Build tooling for the Uniweb Component Web Platform",
5
5
  "type": "module",
6
6
  "exports": {
@@ -56,15 +56,15 @@
56
56
  "js-yaml": "^4.3.2",
57
57
  "sharp": "^0.35.5",
58
58
  "yaml": "^2.5.0",
59
- "@uniweb/content-reader": "~1.5.8",
60
59
  "@uniweb/projections": "~1.2.10",
61
- "@uniweb/schemas": "~1.6.7",
62
- "@uniweb/theming": "~1.2.1",
63
60
  "@uniweb/semantic-parser": "~1.13.2",
64
- "@uniweb/content-writer": "~1.3.1"
61
+ "@uniweb/theming": "~1.2.1",
62
+ "@uniweb/content-writer": "~1.3.1",
63
+ "@uniweb/schemas": "~1.6.7",
64
+ "@uniweb/content-reader": "~1.5.8"
65
65
  },
66
66
  "optionalDependencies": {
67
- "@uniweb/runtime": "~1.3.9"
67
+ "@uniweb/runtime": "~1.3.10"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
@@ -73,8 +73,8 @@
73
73
  "@tailwindcss/vite": "^4.0.0",
74
74
  "@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
75
75
  "vite-plugin-svgr": "^4.0.0",
76
- "@uniweb/core": "~1.6.0",
77
- "@uniweb/runtime": "~1.3.9"
76
+ "@uniweb/core": "~1.6.1",
77
+ "@uniweb/runtime": "~1.3.10"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "vite": {
@@ -62,7 +62,7 @@ export const RUNTIME_KEYS = Object.freeze({
62
62
  search: Object.freeze(['enabled', 'provider', 'endpoint', 'include', 'exclude', 'fields', 'weight']),
63
63
  submit: Object.freeze(['enabled', 'endpoint']),
64
64
  assistant: Object.freeze(['enabled', 'endpoint']),
65
- tracking: Object.freeze(['enabled', 'endpoint', 'emit', 'consent', 'scripts', 'flushIntervalMs', 'debug']),
65
+ tracking: Object.freeze(['enabled', 'endpoint', 'emit', 'consent', 'scripts', 'flushIntervalMs', 'debug', 'conversions']),
66
66
  backend: Object.freeze(['enabled', 'endpoint'])
67
67
  })
68
68
 
@@ -87,9 +87,15 @@ const RENAMED_SITE_KEYS = Object.freeze({ $devApi: '$devBackend' })
87
87
  /**
88
88
  * Services only a host provides, which a site never answers itself: no address, no
89
89
  * runtime part. A site does not declare its own record provider — a third-party
90
- * source is a foundation transport.
90
+ * source is a foundation transport. And a Google tag on a site its host publishes is
91
+ * the host's to serve; a site it does not publish installs one its own way (`head.html`).
92
+ *
93
+ * Each with what to write instead of an address.
91
94
  */
92
- const HOST_ONLY = new Set(['records'])
95
+ const HOST_ONLY = new Map([
96
+ ['records', () => '`records: true`'],
97
+ ['google', (value) => `\`google: { id: ${value} }\``]
98
+ ])
93
99
 
94
100
  /**
95
101
  * Credential-shaped keys, mirroring the set the delivery edge strips on the reading
@@ -150,7 +156,7 @@ function entryProblem(name, value) {
150
156
  if (typeof value === 'string') {
151
157
  if (SWITCH_WORDS.test(value.trim())) return switchWord(`services.${name}`, name, value)
152
158
  if (!value.trim()) return `\`services.${name}\` is empty — write true, false, an address, or a map.`
153
- if (HOST_ONLY.has(name)) return `\`services.${name}\` has no address of its own — your host provides it. Write \`${name}: true\`.`
159
+ if (HOST_ONLY.has(name)) return `\`services.${name}\` has no address of its own — your host provides it. Write ${HOST_ONLY.get(name)(value.trim())}.`
154
160
  return null
155
161
  }
156
162
  if (!isMap(value)) return `\`services.${name}\` is true, false, an address, or a map — not ${described(value)}.`
@@ -165,6 +171,45 @@ function entryProblem(name, value) {
165
171
  if (HOST_ONLY.has(name) && addressOf(value)) {
166
172
  return `\`services.${name}\` has no address of its own — your host provides it. Remove \`endpoint\`.`
167
173
  }
174
+ if (name === 'tracking') return conversionsProblem(value.conversions)
175
+ return null
176
+ }
177
+
178
+ /**
179
+ * What is wrong with `services.tracking.conversions`, or null.
180
+ *
181
+ * ⛔ Stopped here rather than ignored, for the reason `entryProblem` stops anything: at a
182
+ * visitor's browser a misread entry counts nothing, which looks exactly like a site where
183
+ * nobody converted.
184
+ *
185
+ * A link is a whole address because it is compared with where a click goes, and a path of
186
+ * the site's own is a `page`, whose rule already handles the base and the language.
187
+ *
188
+ * @param {*} list
189
+ * @returns {string|null}
190
+ */
191
+ function conversionsProblem(list) {
192
+ if (list === undefined) return null
193
+ const path = '`services.tracking.conversions`'
194
+ if (!Array.isArray(list)) {
195
+ return `${path} is a list, each entry a name and a link or a page: \`- { name: booked, page: /thanks }\`.`
196
+ }
197
+ for (const [i, entry] of list.entries()) {
198
+ const at = `${path}[${i}]`
199
+ if (!isMap(entry) || typeof entry.name !== 'string' || !entry.name.trim()) {
200
+ return `${at} needs a \`name\`, which is what your reports show.`
201
+ }
202
+ const { link, page } = entry
203
+ if ((link === undefined) === (page === undefined)) {
204
+ return `${at} names one \`link\` or one \`page\`.`
205
+ }
206
+ if (page !== undefined && (typeof page !== 'string' || !page.startsWith('/'))) {
207
+ return `${at}: \`page\` is a path of this site, like \`/thanks\` — not ${described(page)}.`
208
+ }
209
+ if (link !== undefined && (typeof link !== 'string' || !/^[a-z][a-z0-9+.-]*:/i.test(link.trim()))) {
210
+ return `${at}: \`link\` is a whole address, like \`https://example.com/signup\` or \`tel:+15551234\` — not ${described(link)}. For a page of this site, use \`page\`.`
211
+ }
212
+ }
168
213
  return null
169
214
  }
170
215