@uniweb/build 1.13.10 → 1.13.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 +7 -7
- package/src/foundation/stale-sources.js +115 -2
- package/src/index.js +1 -1
- package/src/prerender.js +5 -2
- package/src/site/config.js +6 -0
- package/src/site/content-collector.js +58 -29
- package/src/uwx/site-diff.js +11 -2
- package/src/uwx/site.js +10 -5
- package/src/uwx/sync-package.js +10 -1
- package/src/vite-foundation-plugin.js +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.11",
|
|
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
|
-
"@uniweb/content-writer": "~1.3.1",
|
|
61
59
|
"@uniweb/projections": "~1.2.9",
|
|
62
|
-
"@uniweb/semantic-parser": "~1.13.
|
|
60
|
+
"@uniweb/semantic-parser": "~1.13.2",
|
|
61
|
+
"@uniweb/schemas": "~1.6.7",
|
|
62
|
+
"@uniweb/content-reader": "~1.5.8",
|
|
63
63
|
"@uniweb/theming": "~1.2.1",
|
|
64
|
-
"@uniweb/
|
|
64
|
+
"@uniweb/content-writer": "~1.3.1"
|
|
65
65
|
},
|
|
66
66
|
"optionalDependencies": {
|
|
67
|
-
"@uniweb/runtime": "~1.3.
|
|
67
|
+
"@uniweb/runtime": "~1.3.7"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
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/runtime": "~1.3.
|
|
76
|
+
"@uniweb/runtime": "~1.3.7",
|
|
77
77
|
"@uniweb/core": "~1.5.2"
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|
|
@@ -19,12 +19,14 @@
|
|
|
19
19
|
* is missing classes would be false. With a kit from before that, the loss is real: its stylesheet
|
|
20
20
|
* names nothing, so the line is still reported.
|
|
21
21
|
*
|
|
22
|
+
* A folder no `@source` names is the same loss from the other side: see `unreadFolders`.
|
|
23
|
+
*
|
|
22
24
|
* @module @uniweb/build/foundation/stale-sources
|
|
23
25
|
*/
|
|
24
26
|
|
|
25
|
-
import { existsSync, readFileSync, realpathSync } from 'node:fs'
|
|
27
|
+
import { existsSync, readFileSync, readdirSync, realpathSync } from 'node:fs'
|
|
26
28
|
import { createRequire } from 'node:module'
|
|
27
|
-
import { dirname, isAbsolute, join, relative, resolve } from 'node:path'
|
|
29
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
28
30
|
|
|
29
31
|
// `@source not "…"` excludes a path and `@source inline("…")` names no path: neither has a quote
|
|
30
32
|
// right after the keyword.
|
|
@@ -116,6 +118,117 @@ function foundAbove(dir, missing) {
|
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
// `@source not "…"` is the author's decision about that path, which is all `unreadFolders` asks.
|
|
122
|
+
const NOT_SOURCE = /@source\s+not\s+(["'])(.+?)\1/g
|
|
123
|
+
|
|
124
|
+
const USES_TAILWIND = /@import\s+["']tailwindcss/
|
|
125
|
+
|
|
126
|
+
// `source(…)` on the import sets Tailwind's root: "./" reads the foundation in every build, `none`
|
|
127
|
+
// in no build. Either way a site build and the foundation's own agree.
|
|
128
|
+
const SETS_ITS_ROOT = /@import\s+["']tailwindcss[^"']*["'][^;]*\bsource\(/
|
|
129
|
+
|
|
130
|
+
// ⚖️ A class written here, not one passed along (`className={className}`), nor a param declared
|
|
131
|
+
// with that name (`className: { type: 'string' }`).
|
|
132
|
+
const WRITES_CLASSES = /\bclassName\s*(?:=\s*\{[^}]*["'`]|[=:]\s*["'`])|\bcn\(|\bclass=["']/
|
|
133
|
+
|
|
134
|
+
const NOT_THE_FOUNDATIONS_CODE = new Set(['node_modules', 'dist', 'public', 'test', 'tests', '__tests__'])
|
|
135
|
+
|
|
136
|
+
function codeFiles(dir, found = []) {
|
|
137
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
138
|
+
if (entry.name.startsWith('.') || NOT_THE_FOUNDATIONS_CODE.has(entry.name)) continue
|
|
139
|
+
const path = join(dir, entry.name)
|
|
140
|
+
if (entry.isDirectory()) codeFiles(path, found)
|
|
141
|
+
else if (/\.[jt]sx?$/.test(entry.name) && !/\.(?:test|spec|generated)\./.test(entry.name)) found.push(path)
|
|
142
|
+
}
|
|
143
|
+
return found
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The paths a stylesheet's `@source` lines start from, and those of the stylesheets it imports. */
|
|
147
|
+
function pathsRead(file, seen = new Set()) {
|
|
148
|
+
if (seen.has(file)) return []
|
|
149
|
+
seen.add(file)
|
|
150
|
+
let css
|
|
151
|
+
try {
|
|
152
|
+
css = withoutComments(readFileSync(file, 'utf8'))
|
|
153
|
+
} catch {
|
|
154
|
+
return []
|
|
155
|
+
}
|
|
156
|
+
const read = [...css.matchAll(SOURCE), ...css.matchAll(NOT_SOURCE)].map((m) => resolve(dirname(file), fixedPrefix(m[2])))
|
|
157
|
+
const require = createRequire(file)
|
|
158
|
+
for (const [, , specifier] of css.matchAll(IMPORT)) {
|
|
159
|
+
// ⛔ Only a `.css` specifier, as in `readByAnImport`.
|
|
160
|
+
if (!specifier.endsWith('.css')) continue
|
|
161
|
+
let imported
|
|
162
|
+
try {
|
|
163
|
+
imported = require.resolve(specifier)
|
|
164
|
+
} catch {
|
|
165
|
+
continue
|
|
166
|
+
}
|
|
167
|
+
read.push(...pathsRead(imported, seen))
|
|
168
|
+
}
|
|
169
|
+
return read
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The code in a foundation that writes classes no `@source` reads.
|
|
174
|
+
*
|
|
175
|
+
* Tailwind reads everything under Vite's root, and whatever `@source` names. A foundation's own build
|
|
176
|
+
* has the foundation for its root, so it finds every class. A site build and `uniweb dev` have the
|
|
177
|
+
* site: there, `@source` is all that reaches the foundation. So a class only such code uses is in the
|
|
178
|
+
* foundation's CSS and missing from the site's, with both builds exiting 0, and a page on a host
|
|
179
|
+
* loading the foundation's own CSS looks right. Measured 2026-11-01 on the `dynamic` template, whose
|
|
180
|
+
* stylesheet named `./sections` alone: its home page's weather card came out a blank white box, 27
|
|
181
|
+
* classes short, under `uniweb dev` and in a site build.
|
|
182
|
+
*
|
|
183
|
+
* ⚖️ It errs toward saying nothing. Any `@source` starting at or above a file reads that file, whatever
|
|
184
|
+
* its glob, and a foundation that doesn't import Tailwind by name is not looked at. A word here is a
|
|
185
|
+
* line to add, whose only cost is a stylesheet naming one more folder.
|
|
186
|
+
*
|
|
187
|
+
* @param {string} stylesPath - the foundation's stylesheet; none there, nothing to say
|
|
188
|
+
* @returns {Array<{ path: string, files: number, line: string }>} each folder (or file) beside the
|
|
189
|
+
* stylesheet, how many of its files write classes, and the line that reads it
|
|
190
|
+
*/
|
|
191
|
+
export function unreadFolders(stylesPath) {
|
|
192
|
+
// ⛔ The real path: an import resolves to one, so a line it holds would never match a file reached
|
|
193
|
+
// through a link (a macOS temp folder, a workspace dependency).
|
|
194
|
+
let stylesheet, css
|
|
195
|
+
try {
|
|
196
|
+
stylesheet = realpathSync(stylesPath)
|
|
197
|
+
css = withoutComments(readFileSync(stylesheet, 'utf8'))
|
|
198
|
+
} catch {
|
|
199
|
+
return []
|
|
200
|
+
}
|
|
201
|
+
if (!USES_TAILWIND.test(css) || SETS_ITS_ROOT.test(css)) return []
|
|
202
|
+
|
|
203
|
+
const dir = dirname(stylesheet)
|
|
204
|
+
const read = pathsRead(stylesheet)
|
|
205
|
+
const unread = new Map()
|
|
206
|
+
for (const file of codeFiles(dir)) {
|
|
207
|
+
if (read.some((path) => file === path || file.startsWith(path + sep))) continue
|
|
208
|
+
if (!WRITES_CLASSES.test(withoutComments(readFileSync(file, 'utf8')))) continue
|
|
209
|
+
const [top, ...below] = relative(dir, file).split(sep)
|
|
210
|
+
const entry = unread.get(top) ?? { path: top, files: 0, isFolder: below.length > 0, typed: false }
|
|
211
|
+
entry.files++
|
|
212
|
+
entry.typed ||= /\.tsx?$/.test(file)
|
|
213
|
+
unread.set(top, entry)
|
|
214
|
+
}
|
|
215
|
+
return [...unread.values()]
|
|
216
|
+
.sort((a, b) => a.path.localeCompare(b.path))
|
|
217
|
+
.map(({ path, files, isFolder, typed }) => ({
|
|
218
|
+
path,
|
|
219
|
+
files,
|
|
220
|
+
line: `@source "./${path}${isFolder ? `/**/*.{js,jsx${typed ? ',ts,tsx' : ''}}` : ''}";`
|
|
221
|
+
}))
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** What a site build and `uniweb dev` print when `unreadFolders` finds any: it is them that lose the classes. */
|
|
225
|
+
export function unreadFoldersWarning(unread) {
|
|
226
|
+
return [
|
|
227
|
+
"[uniweb] The foundation's styles.css names no @source for code that writes classes, so a site build and `uniweb dev` miss any class only that code uses, though the foundation's own build has it. Add:",
|
|
228
|
+
...unread.map(({ line }) => ` ${line}`)
|
|
229
|
+
].join('\n')
|
|
230
|
+
}
|
|
231
|
+
|
|
119
232
|
/** A stale line's note: what is missing, and where it is instead when that is known. */
|
|
120
233
|
export const staleSourceNote = ({ missing, foundAt }) => `no ${missing}${foundAt ? `; it is at ${foundAt}` : ''}`
|
|
121
234
|
|
package/src/index.js
CHANGED
|
@@ -85,7 +85,7 @@ export {
|
|
|
85
85
|
|
|
86
86
|
// Foundation source root resolution (reads package.json::main)
|
|
87
87
|
export { resolveFoundationSrcDir, resolveFoundationSrcPath } from './utils/foundation-source-root.js'
|
|
88
|
-
export { staleSources, staleSourceNote } from './foundation/stale-sources.js'
|
|
88
|
+
export { staleSources, staleSourceNote, unreadFolders } from './foundation/stale-sources.js'
|
|
89
89
|
|
|
90
90
|
// Package classification (foundation vs site vs standalone schemas package)
|
|
91
91
|
export { classifyPackage, isExtensionPackage, isSchemasPackage } from './utils/classify-package.js'
|
package/src/prerender.js
CHANGED
|
@@ -888,6 +888,9 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
888
888
|
const sitemapEntries = []
|
|
889
889
|
// A redirect stub names its target as the target's own pages do: absolutely, on the site's address.
|
|
890
890
|
const stubCanonical = (target) => absoluteUrl(defaultSiteContent.config?.url, target) || target
|
|
891
|
+
// With no icon named, a browser asks for `/favicon.ico` on its way through a stub, and logs a 404
|
|
892
|
+
// on any site whose icon is called something else. A stub is gone at once, so it names none.
|
|
893
|
+
const STUB_ICON = '<link rel="icon" href="data:,">'
|
|
891
894
|
|
|
892
895
|
for (const localeConfig of localeConfigs) {
|
|
893
896
|
const { locale, contentPath: localeContentPath, htmlPath, isDefault, routePrefix } = localeConfig
|
|
@@ -1042,7 +1045,7 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
1042
1045
|
? (website.basePath || '') + location
|
|
1043
1046
|
: location
|
|
1044
1047
|
onProgress(` Redirect ${outputRoute} → ${target}`)
|
|
1045
|
-
const redirectHtml = `<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=${target}"><link rel="canonical" href="${stubCanonical(target)}"
|
|
1048
|
+
const redirectHtml = `<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=${target}"><link rel="canonical" href="${stubCanonical(target)}">${STUB_ICON}<title>Redirecting...</title></head><body><p>Redirecting to <a href="${target}">${target}</a></p></body></html>`
|
|
1046
1049
|
const outputPath = getOutputPath(distDir, outputRoute)
|
|
1047
1050
|
await mkdir(dirname(outputPath), { recursive: true })
|
|
1048
1051
|
await writeFile(outputPath, redirectHtml)
|
|
@@ -1075,7 +1078,7 @@ export async function prerenderSite(siteDir, options = {}) {
|
|
|
1075
1078
|
routePrefix
|
|
1076
1079
|
})
|
|
1077
1080
|
onProgress(` Auto-redirect ${outputRoute} → ${targetPath}`)
|
|
1078
|
-
const redirectHtml = `<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=${targetPath}"><link rel="canonical" href="${stubCanonical(targetPath)}"
|
|
1081
|
+
const redirectHtml = `<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=${targetPath}"><link rel="canonical" href="${stubCanonical(targetPath)}">${STUB_ICON}<title>Redirecting...</title></head><body><p>Redirecting to <a href="${targetPath}">${targetPath}</a></p></body></html>`
|
|
1079
1082
|
const outputPath = getOutputPath(distDir, outputRoute)
|
|
1080
1083
|
await mkdir(dirname(outputPath), { recursive: true })
|
|
1081
1084
|
await writeFile(outputPath, redirectHtml)
|
package/src/site/config.js
CHANGED
|
@@ -24,6 +24,7 @@ import { existsSync, readFileSync, realpathSync } from 'node:fs'
|
|
|
24
24
|
import { resolve, dirname, join } from 'node:path'
|
|
25
25
|
import yaml from 'js-yaml'
|
|
26
26
|
import { YAML_OPTIONS } from '../utils/yaml-schema.js'
|
|
27
|
+
import { unreadFolders, unreadFoldersWarning } from '../foundation/stale-sources.js'
|
|
27
28
|
import {
|
|
28
29
|
generateEntryPoint,
|
|
29
30
|
shouldRegenerateForFile,
|
|
@@ -286,6 +287,11 @@ export async function defineSiteConfig(options = {}) {
|
|
|
286
287
|
siteRoot,
|
|
287
288
|
})
|
|
288
289
|
if (!agreement.ok) console.warn(`\n${agreement.message}\n`)
|
|
290
|
+
|
|
291
|
+
// Code the foundation's stylesheet names no `@source` for: here is where its classes go
|
|
292
|
+
// missing, in a site build and under `uniweb dev`, while its own build has them all.
|
|
293
|
+
const unread = unreadFolders(join(srcDir, 'styles.css'))
|
|
294
|
+
if (unread.length) console.warn(unreadFoldersWarning(unread))
|
|
289
295
|
}
|
|
290
296
|
},
|
|
291
297
|
|
|
@@ -806,6 +806,34 @@ export function folderModePageFiles(entries, orderConfig) {
|
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
808
|
|
|
809
|
+
/**
|
|
810
|
+
* A folder-mode level's children in one order: its `.md` pages, then its folders, each in the order
|
|
811
|
+
* it already has, with its `pages:` over both, since that is one list. Shared by the build's walk
|
|
812
|
+
* and the push's. ⛔ Until 2026-11-01 each kept to its own side, so `pages: [a, guides, b]` listed
|
|
813
|
+
* `a`, `b`, `guides`, with no word about it.
|
|
814
|
+
*
|
|
815
|
+
* Sorted by rank, not picked by name, so a file and a folder of one name both stay.
|
|
816
|
+
*
|
|
817
|
+
* @template {{ name: string }} T
|
|
818
|
+
* @param {T[]} files
|
|
819
|
+
* @param {T[]} folders
|
|
820
|
+
* @param {{ pages?: Array }} [orderConfig] - the level's own config
|
|
821
|
+
* @returns {T[]}
|
|
822
|
+
*/
|
|
823
|
+
export function folderModeChildren(files, folders, orderConfig) {
|
|
824
|
+
const children = [...files, ...folders]
|
|
825
|
+
const parsed = Array.isArray(orderConfig?.pages) ? parseWildcardArray(orderConfig.pages) : null
|
|
826
|
+
if (!parsed || parsed.mode === 'all') return children
|
|
827
|
+
const before = parsed.before.map(extractItemName).filter(Boolean)
|
|
828
|
+
const after = parsed.after.map(extractItemName).filter(Boolean)
|
|
829
|
+
const rank = new Map([
|
|
830
|
+
...before.map((name, i) => [name, i]),
|
|
831
|
+
...after.map((name, i) => [name, before.length + 1 + i])
|
|
832
|
+
])
|
|
833
|
+
const rankOf = (child) => rank.get(child.name) ?? before.length
|
|
834
|
+
return children.sort((a, b) => rankOf(a) - rankOf(b))
|
|
835
|
+
}
|
|
836
|
+
|
|
809
837
|
/**
|
|
810
838
|
* Parse numeric prefix from filename (e.g., "1-hero.md" → { prefix: "1", name: "hero" })
|
|
811
839
|
* Supports:
|
|
@@ -2147,37 +2175,38 @@ async function collectPagesRecursive(dirPath, parentRoute, siteRoot, orderConfig
|
|
|
2147
2175
|
indexName = homepageOf(orderConfig) ?? null
|
|
2148
2176
|
}
|
|
2149
2177
|
|
|
2150
|
-
//
|
|
2151
|
-
for (const
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
if (name === indexName) {
|
|
2158
|
-
page.isIndex = true
|
|
2159
|
-
page.sourcePath = page.route
|
|
2160
|
-
page.route = parentRoute
|
|
2161
|
-
}
|
|
2178
|
+
// The level's md-file-pages and subdirectories, in one order
|
|
2179
|
+
for (const child of folderModeChildren(orderedMdPages, orderedFolders, orderConfig)) {
|
|
2180
|
+
if (child.result) {
|
|
2181
|
+
const { name, result } = child
|
|
2182
|
+
const { page, assetCollection: pageAssets, iconCollection: pageIcons } = result
|
|
2183
|
+
assetCollection = mergeAssetCollections(assetCollection, pageAssets)
|
|
2184
|
+
iconCollection = mergeIconCollections(iconCollection, pageIcons)
|
|
2162
2185
|
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
// folder or site `hide:` never reached a folder-mode page.
|
|
2170
|
-
//
|
|
2171
|
-
// `normalizeLayoutConfig` first so the page's own record has no undefined
|
|
2172
|
-
// keys to shadow an inherited value through the spread.
|
|
2173
|
-
page.layout = mergeLayoutConfig(parentLayout, normalizeLayoutConfig(page.layout))
|
|
2174
|
-
|
|
2175
|
-
pages.push(page)
|
|
2176
|
-
}
|
|
2186
|
+
// Handle index: promote to parent route
|
|
2187
|
+
if (name === indexName) {
|
|
2188
|
+
page.isIndex = true
|
|
2189
|
+
page.sourcePath = page.route
|
|
2190
|
+
page.route = parentRoute
|
|
2191
|
+
}
|
|
2177
2192
|
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2193
|
+
// Inherit the layout from the folder / site cascade.
|
|
2194
|
+
//
|
|
2195
|
+
// ⭐ THE WHOLE OBJECT, not just the name. `processFileAsPage` (folder-mode
|
|
2196
|
+
// `.md`-as-pages) takes no layout argument, so this post-hoc merge is where
|
|
2197
|
+
// the cascade reaches these pages at all — the threaded path above covers
|
|
2198
|
+
// every other kind. Until 2026-09-09 it patched `name` only, which is why a
|
|
2199
|
+
// folder or site `hide:` never reached a folder-mode page.
|
|
2200
|
+
//
|
|
2201
|
+
// `normalizeLayoutConfig` first so the page's own record has no undefined
|
|
2202
|
+
// keys to shadow an inherited value through the spread.
|
|
2203
|
+
page.layout = mergeLayoutConfig(parentLayout, normalizeLayoutConfig(page.layout))
|
|
2204
|
+
|
|
2205
|
+
pages.push(page)
|
|
2206
|
+
continue
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
const { name: entry, path: entryPath, dirConfig, dirMode, childMode, childOrderConfig, childLayout } = child
|
|
2181
2210
|
assertRouteFolder(entry, parentRoute)
|
|
2182
2211
|
const isIndex = entry === indexName
|
|
2183
2212
|
const effectiveLayout = mergeLayoutConfig(parentLayout, childLayout)
|
package/src/uwx/site-diff.js
CHANGED
|
@@ -184,6 +184,11 @@ export function collectUnitUuids(doc, sourceLocale) {
|
|
|
184
184
|
* is the dangerous case — see `collectUnitUuids` — and the caller is responsible for
|
|
185
185
|
* not pushing blind (the backend also refuses an all-blank `multi` section).
|
|
186
186
|
*
|
|
187
|
+
* ⭐ One directory is one page, whichever of its two files declares it, so a page moved between
|
|
188
|
+
* `page.yml` and `folder.yml` keeps its identity. ⛔ Until 2026-11-01 the map was read by the file's
|
|
189
|
+
* name alone, so the move pushed a new page beside the stored one, under its slug, and the backend
|
|
190
|
+
* refused it (409, `unique_field`) after the publish had already released the foundation.
|
|
191
|
+
*
|
|
187
192
|
* @returns {{ stamped: number, unknown: number }}
|
|
188
193
|
*/
|
|
189
194
|
export function stampUnitUuids(doc, pathToUuid = {}, sourceLocale) {
|
|
@@ -191,7 +196,11 @@ export function stampUnitUuids(doc, pathToUuid = {}, sourceLocale) {
|
|
|
191
196
|
let unknown = 0
|
|
192
197
|
const seen = new Set()
|
|
193
198
|
const collisions = []
|
|
194
|
-
|
|
199
|
+
const otherPageFile = (path) =>
|
|
200
|
+
path.endsWith('/page.yml')
|
|
201
|
+
? `${path.slice(0, -'page.yml'.length)}folder.yml`
|
|
202
|
+
: `${path.slice(0, -'folder.yml'.length)}page.yml`
|
|
203
|
+
walkSiteUnits(doc, (path, record, kind) => {
|
|
195
204
|
// Two records can resolve to ONE path when their stable ids collide — most
|
|
196
205
|
// easily `1-hero.md` and `hero.md` in the same page dir, since the numeric
|
|
197
206
|
// prefix is stripped. Stamping both with the same uuid produces a package the
|
|
@@ -206,7 +215,7 @@ export function stampUnitUuids(doc, pathToUuid = {}, sourceLocale) {
|
|
|
206
215
|
return
|
|
207
216
|
}
|
|
208
217
|
seen.add(path)
|
|
209
|
-
const uuid = pathToUuid[path]
|
|
218
|
+
const uuid = pathToUuid[path] || (kind === 'page' ? pathToUuid[otherPageFile(path)] : undefined)
|
|
210
219
|
if (uuid) {
|
|
211
220
|
record.$uuid = uuid
|
|
212
221
|
stamped++
|
package/src/uwx/site.js
CHANGED
|
@@ -68,6 +68,7 @@ import {
|
|
|
68
68
|
resolveMounts,
|
|
69
69
|
layerMountedFolder,
|
|
70
70
|
folderModePageFiles,
|
|
71
|
+
folderModeChildren,
|
|
71
72
|
rootOrderConfig,
|
|
72
73
|
composeLocalizedRoute,
|
|
73
74
|
isValidSlugSegment,
|
|
@@ -790,6 +791,8 @@ async function collectPageSectionsNested(pageDir, siteRoot, pageConfig, media =
|
|
|
790
791
|
// says `hidden: true`, slugged by the filename without its numeric prefix — and in the build's
|
|
791
792
|
// order (`folderModePageFiles`). ⛔ Until 2026-10-23 this lane sent none of them and warned instead;
|
|
792
793
|
// a documentation site — folder-mode pages in a mounted repo — published 2 of its 49 pages.
|
|
794
|
+
//
|
|
795
|
+
// Each comes with the name a `pages:` list knows it by.
|
|
793
796
|
async function folderModePageRecords(ctx, dirPath, orderConfig, isRoot) {
|
|
794
797
|
const { siteRoot, siteIndex, sourceLocale, translations, pageFields } = ctx
|
|
795
798
|
const { files } = folderModePageFiles(await readdir(dirPath), orderConfig)
|
|
@@ -813,17 +816,19 @@ async function folderModePageRecords(ctx, dirPath, orderConfig, isRoot) {
|
|
|
813
816
|
})
|
|
814
817
|
const record = withIdentity(data.stable_id || name, data)
|
|
815
818
|
record.page_sections = page.sections.map((s, i) => sectionToRecord(s, i))
|
|
816
|
-
records.push(record)
|
|
819
|
+
records.push({ name, record })
|
|
817
820
|
}
|
|
818
821
|
return records
|
|
819
822
|
}
|
|
820
823
|
|
|
821
824
|
// Recursively build the `pages` tree: each record carries its fields, its inline
|
|
822
825
|
// `page_sections` (page mode only), and its child pages under `$children`. A folder-mode level's
|
|
823
|
-
// own `.md` pages
|
|
826
|
+
// own `.md` pages and its folders are sent in one order, as the build lists them
|
|
827
|
+
// (`folderModeChildren`).
|
|
824
828
|
async function walkPagesNested(ctx, dirPath, parentSlugPath, inheritedMode, parentConfig, isRoot, mounts = null) {
|
|
825
829
|
const { siteRoot, siteIndex, sourceLocale, translations, pageFields } = ctx
|
|
826
|
-
const
|
|
830
|
+
const files = inheritedMode === 'pages' ? await folderModePageRecords(ctx, dirPath, parentConfig, isRoot) : []
|
|
831
|
+
const made = []
|
|
827
832
|
const folders = await orderedSubfolders(dirPath, inheritedMode, parentConfig, mounts)
|
|
828
833
|
// A folder inside a `[...path]` folder can never be reached, and `[dir]` /
|
|
829
834
|
// `[path]` would name a route variable — refused here as the collector refuses
|
|
@@ -881,9 +886,9 @@ async function walkPagesNested(ctx, dirPath, parentSlugPath, inheritedMode, pare
|
|
|
881
886
|
const children = await walkPagesNested(ctx, f.childrenPath, slugPath, f.childMode, f.config, false)
|
|
882
887
|
if (children.length > 0) record.$children = children
|
|
883
888
|
|
|
884
|
-
|
|
889
|
+
made.push({ name: f.name, record })
|
|
885
890
|
}
|
|
886
|
-
return
|
|
891
|
+
return folderModeChildren(files, made, parentConfig).map((child) => child.record)
|
|
887
892
|
}
|
|
888
893
|
|
|
889
894
|
// layout_sections: top-level self-nesting, keyed by (layout_name, area) in data —
|
package/src/uwx/sync-package.js
CHANGED
|
@@ -112,6 +112,12 @@ function collectReferencedModels(node, acc) {
|
|
|
112
112
|
// media extension) — so it covers PM image `src`, `background`/`params`, record
|
|
113
113
|
// media fields, and localized `{locale: doc}` maps uniformly and safely (non-media
|
|
114
114
|
// strings like `/data/x.json` never match). Mirrors the build's `walkDataAssets`.
|
|
115
|
+
//
|
|
116
|
+
// ⭐ A TEXT NODE'S TEXT IS WHAT A READER READS, never a reference, even when all of it is a path.
|
|
117
|
+
// ⛔ Until 2026-11-01 both walks took it for one: `/assets/front.jpg` in a code span in a guide was
|
|
118
|
+
// warned about as a missing file, and when the site had that file, the guide's words were replaced
|
|
119
|
+
// with its serve URL.
|
|
120
|
+
const isReadersText = (node, key) => key === 'text' && node.type === 'text'
|
|
115
121
|
|
|
116
122
|
// Invoke visitor(ref) for every local asset path string anywhere in the document.
|
|
117
123
|
function walkEntityAssets(node, visitor) {
|
|
@@ -124,7 +130,9 @@ function walkEntityAssets(node, visitor) {
|
|
|
124
130
|
return
|
|
125
131
|
}
|
|
126
132
|
if (node && typeof node === 'object') {
|
|
127
|
-
for (const v of Object.
|
|
133
|
+
for (const [key, v] of Object.entries(node)) {
|
|
134
|
+
if (!isReadersText(node, key)) walkEntityAssets(v, visitor)
|
|
135
|
+
}
|
|
128
136
|
}
|
|
129
137
|
}
|
|
130
138
|
|
|
@@ -211,6 +219,7 @@ function rewriteEntityAssets(node, map, ids, bare = null) {
|
|
|
211
219
|
}
|
|
212
220
|
}
|
|
213
221
|
for (const key of Object.keys(node)) {
|
|
222
|
+
if (isReadersText(node, key)) continue
|
|
214
223
|
const v = node[key]
|
|
215
224
|
if (typeof v === 'string') { if (map[v]) node[key] = map[v] }
|
|
216
225
|
else rewriteEntityAssets(v, map, ids, bare)
|
|
@@ -447,8 +447,10 @@ export function foundationBuildPlugin(options = {}) {
|
|
|
447
447
|
if (_buildingSSRBundle) return
|
|
448
448
|
|
|
449
449
|
// kit's <Prose> / <Article> with no prose styles in the CSS: correct markup, unstyled page,
|
|
450
|
-
// and nothing else says so (`foundation/prose-styles.js`).
|
|
451
|
-
//
|
|
450
|
+
// and nothing else says so (`foundation/prose-styles.js`). A dev rebuild says it too, when the
|
|
451
|
+
// foundation is linked at runtime. ⚠️ That is not the default: `uniweb dev` normally bundles the
|
|
452
|
+
// foundation's source into the site and runs no foundation build, so nothing here reaches it.
|
|
453
|
+
// A warning for that server belongs in the site's config (`site/config.js`).
|
|
452
454
|
if (!warnedProseWithoutStyles.has(resolvedSrcDir) && proseWithoutStyles(bundle)) {
|
|
453
455
|
warnedProseWithoutStyles.add(resolvedSrcDir)
|
|
454
456
|
console.warn(PROSE_WITHOUT_STYLES_WARNING)
|