@uniweb/build 1.10.12 → 1.10.14
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 +5 -5
- package/src/images.js +17 -0
- package/src/uwx/emit-surface.json +4 -1
- package/src/uwx/site-project.js +3 -0
- package/src/uwx/site.js +21 -0
- package/src/uwx/sync-package.js +27 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.14",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"sharp": "^0.35.5",
|
|
58
58
|
"yaml": "^2.5.0",
|
|
59
59
|
"@uniweb/content-reader": "~1.5.7",
|
|
60
|
-
"@uniweb/
|
|
61
|
-
"@uniweb/
|
|
60
|
+
"@uniweb/projections": "~1.2.7",
|
|
61
|
+
"@uniweb/content-writer": "~1.3.1",
|
|
62
62
|
"@uniweb/semantic-parser": "~1.13.0",
|
|
63
|
-
"@uniweb/
|
|
64
|
-
"@uniweb/
|
|
63
|
+
"@uniweb/theming": "~1.2.1",
|
|
64
|
+
"@uniweb/schemas": "~1.6.5"
|
|
65
65
|
},
|
|
66
66
|
"optionalDependencies": {
|
|
67
67
|
"@uniweb/runtime": "~1.2.12"
|
package/src/images.js
CHANGED
|
@@ -56,6 +56,23 @@ export async function readImageSize(imagePath) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Whether every pixel of an image is opaque — an alpha channel alone does not say, since most
|
|
61
|
+
* PNGs carry one whether they use it or not — or null when sharp cannot read the file. It decodes
|
|
62
|
+
* the whole image, so it is for a small one: `uniweb doctor` asks it of a site's touch icon,
|
|
63
|
+
* whose transparent pixels iOS draws black.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} imagePath
|
|
66
|
+
* @returns {Promise<boolean|null>}
|
|
67
|
+
*/
|
|
68
|
+
export async function isImageOpaque(imagePath) {
|
|
69
|
+
try {
|
|
70
|
+
return (await sharp(imagePath).stats()).isOpaque
|
|
71
|
+
} catch {
|
|
72
|
+
return null
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
59
76
|
/**
|
|
60
77
|
* Convert an image to webp format
|
|
61
78
|
*/
|
package/src/uwx/site-project.js
CHANGED
|
@@ -192,6 +192,9 @@ const SETTINGS_TO_SITE_YML = {
|
|
|
192
192
|
// offered through `config.services` and resolved at render, never entering the
|
|
193
193
|
// stored record, so a pull cannot launder it into authored config.
|
|
194
194
|
agents: 'agents',
|
|
195
|
+
// The touch icon, verbatim: the path the author wrote, which `restoreAssetRefs` has already put
|
|
196
|
+
// back from the serve URL the push recorded (asset-map.js), else a URL.
|
|
197
|
+
touch_icon: 'touchIcon',
|
|
195
198
|
}
|
|
196
199
|
|
|
197
200
|
|
package/src/uwx/site.js
CHANGED
|
@@ -1356,6 +1356,12 @@ function settingsNested(siteYml, { headHtml, themeYml, sourceLocale, translation
|
|
|
1356
1356
|
// carries the translation collector with it.
|
|
1357
1357
|
setIf(settings, 'keywords', plainTextTargets(localizeScalarList(siteYml.keywords, sourceLocale, translations), sourceLocale))
|
|
1358
1358
|
|
|
1359
|
+
// ⭐ The touch icon — `site.yml::touchIcon`, the PNG iOS puts on a home screen — where the
|
|
1360
|
+
// deployment's `settings` takes it (`touchIconValue`). A site path is media to the upload walk
|
|
1361
|
+
// (`sync-package.js::walkEntityAssets`), so it goes up with the site's other files and is sent
|
|
1362
|
+
// as its serve URL, which a pull puts back as the path (`asset-map.js::restoreAssetRefs`).
|
|
1363
|
+
setIf(settings, 'touch_icon', touchIconValue(siteYml.touchIcon, settingsFields))
|
|
1364
|
+
|
|
1359
1365
|
// ⛔ NO SERVICE IS HERE. A service's address and options ride its row in the
|
|
1360
1366
|
// `services` Section, whole (`requestedServices`) [Diego, 2026-10-06: "If it's on and
|
|
1361
1367
|
// has configuration, it can all be in the same place"]. *Until that evening
|
|
@@ -1390,6 +1396,21 @@ function settingsNested(siteYml, { headHtml, themeYml, sourceLocale, translation
|
|
|
1390
1396
|
return Object.keys(settings).length > 0 ? settings : undefined
|
|
1391
1397
|
}
|
|
1392
1398
|
|
|
1399
|
+
/**
|
|
1400
|
+
* `site.yml::touchIcon` as a push sends it: only to a deployment whose `settings` declares
|
|
1401
|
+
* `touch_icon`, since one that does not refuses a push carrying it (`deploymentFields`). Such a
|
|
1402
|
+
* site is told; with no list in hand, nothing optional is sent.
|
|
1403
|
+
*/
|
|
1404
|
+
function touchIconValue(named, settingsFields) {
|
|
1405
|
+
if (typeof named !== 'string' || !named.trim() || !Array.isArray(settingsFields)) return undefined
|
|
1406
|
+
if (settingsFields.includes('touch_icon')) return named
|
|
1407
|
+
console.warn(
|
|
1408
|
+
"uwx/site: `touchIcon:` is not sent — this backend's site settings take no touch icon, so " +
|
|
1409
|
+
'the pages it serves link none.'
|
|
1410
|
+
)
|
|
1411
|
+
return undefined
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1393
1414
|
/**
|
|
1394
1415
|
* Map a file site project to the nested `@uniweb/site-content` `$`-document
|
|
1395
1416
|
* (see the lane header above). PURE — reads the project, never mints, never writes.
|
package/src/uwx/sync-package.js
CHANGED
|
@@ -177,21 +177,23 @@ function walkEntityAssets(node, visitor) {
|
|
|
177
177
|
// media object (`{image: {src}}`) with one rule — the two shapes framework
|
|
178
178
|
// resolves, reached through the same walk.
|
|
179
179
|
//
|
|
180
|
-
// `
|
|
181
|
-
// matches — the site's `info
|
|
182
|
-
|
|
180
|
+
// `bare` holds the objects under which NOTHING gets identity attrs, even where a slot
|
|
181
|
+
// matches — the site's `info` and its theme (see the call site). Their references are
|
|
182
|
+
// bare strings, which a pull recognizes by fingerprint.
|
|
183
|
+
function rewriteEntityAssets(node, map, ids, bare = null) {
|
|
184
|
+
if (bare?.has(node)) ids = null
|
|
183
185
|
if (Array.isArray(node)) {
|
|
184
186
|
for (let i = 0; i < node.length; i++) {
|
|
185
187
|
const v = node[i]
|
|
186
188
|
if (typeof v === 'string') { if (map[v]) node[i] = map[v] }
|
|
187
|
-
else rewriteEntityAssets(v, map, ids,
|
|
189
|
+
else rewriteEntityAssets(v, map, ids, bare)
|
|
188
190
|
}
|
|
189
191
|
return node
|
|
190
192
|
}
|
|
191
193
|
if (node && typeof node === 'object') {
|
|
192
194
|
// Stamp BEFORE the string swap below, while the reference is still the
|
|
193
195
|
// local ref the ids map is keyed by.
|
|
194
|
-
if (ids
|
|
196
|
+
if (ids) {
|
|
195
197
|
// Every asset slot, not just the primary: a video's `poster` and a
|
|
196
198
|
// document's `preview` are assets like any other, and each has identity
|
|
197
199
|
// attrs naming which reference they belong to (ASSET_SLOTS).
|
|
@@ -209,7 +211,7 @@ function rewriteEntityAssets(node, map, ids, noStamp = null) {
|
|
|
209
211
|
for (const key of Object.keys(node)) {
|
|
210
212
|
const v = node[key]
|
|
211
213
|
if (typeof v === 'string') { if (map[v]) node[key] = map[v] }
|
|
212
|
-
else rewriteEntityAssets(v, map, ids,
|
|
214
|
+
else rewriteEntityAssets(v, map, ids, bare)
|
|
213
215
|
}
|
|
214
216
|
}
|
|
215
217
|
return node
|
|
@@ -464,12 +466,15 @@ export async function emitSyncPackages(siteRoot, opts = {}) {
|
|
|
464
466
|
const assetIds =
|
|
465
467
|
opts.assetIds && typeof opts.assetIds === 'object' ? opts.assetIds : null
|
|
466
468
|
if (assetRewrite) {
|
|
467
|
-
// ⛔ No identity attrs on `info
|
|
468
|
-
// and `preview` is a real ASSET_SLOTS slot, so stamping would add
|
|
469
|
-
// `previewAssetId`/`previewAssetExt` — fields the host refuses.
|
|
470
|
-
//
|
|
471
|
-
//
|
|
472
|
-
|
|
469
|
+
// ⛔ No identity attrs on `info` or in the theme. `info` is a Section whose fields
|
|
470
|
+
// the host declares, and `preview` is a real ASSET_SLOTS slot, so stamping would add
|
|
471
|
+
// `previewAssetId`/`previewAssetExt` — fields the host refuses. The theme is
|
|
472
|
+
// `theme.yml` as written, and a font face (`{ family, src }`) is slot-shaped but is
|
|
473
|
+
// configuration, not content. Their bare strings are still swapped for their serve
|
|
474
|
+
// URLs, which the asset map in `sync.json` recognizes on pull by fingerprint
|
|
475
|
+
// (asset-map.js → `servedFingerprint`).
|
|
476
|
+
const bare = new Set([siteDoc?.info, siteDoc?.settings?.theme].filter(Boolean))
|
|
477
|
+
if (siteDoc) rewriteEntityAssets(siteDoc, assetRewrite, assetIds, bare)
|
|
473
478
|
for (const e of col.entities) rewriteEntityAssets(e.document, assetRewrite, assetIds)
|
|
474
479
|
// The folder too: a file entry's value names its asset by an upload key until here.
|
|
475
480
|
if (folder) rewriteEntityAssets(folder.document, assetRewrite, assetIds)
|
|
@@ -497,8 +502,17 @@ export async function emitSyncPackages(siteRoot, opts = {}) {
|
|
|
497
502
|
// (`isLocalAssetPath`), but a host serves the favicon its page shell links only from
|
|
498
503
|
// the asset store: left as a site path, `/favicon.ico` was linked on every hosted page
|
|
499
504
|
// and answered 404. The rewrite above already swaps any path the upload map names.
|
|
505
|
+
const sitePath = (v) => typeof v === 'string' && v.startsWith('/') && !v.startsWith('//')
|
|
500
506
|
const favicon = siteDoc?.info?.favicon
|
|
501
|
-
if (
|
|
507
|
+
if (sitePath(favicon)) localAssetSet.add(favicon)
|
|
508
|
+
// ⭐ The theme's font files, the same way. A face's `src` names a file under `public/`
|
|
509
|
+
// as an image path does, but a font is not media to the walker either: left as a site
|
|
510
|
+
// path, each face was preloaded and @font-face'd on every hosted page from a path that
|
|
511
|
+
// answered 404.
|
|
512
|
+
const faces = siteDoc?.settings?.theme?.fonts?.faces
|
|
513
|
+
for (const face of Array.isArray(faces) ? faces : []) {
|
|
514
|
+
if (sitePath(face?.src)) localAssetSet.add(face.src)
|
|
515
|
+
}
|
|
502
516
|
const localAssets = [...localAssetSet]
|
|
503
517
|
|
|
504
518
|
// ⭐ THE IDENTITY OF A RECORD'S LIST ITEMS (`record-items.js`), taken on each document as it
|