@uniweb/build 1.10.13 → 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 +4 -4
- 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/content-writer": "~1.3.1",
|
|
61
60
|
"@uniweb/projections": "~1.2.7",
|
|
62
|
-
"@uniweb/
|
|
61
|
+
"@uniweb/content-writer": "~1.3.1",
|
|
63
62
|
"@uniweb/semantic-parser": "~1.13.0",
|
|
64
|
-
"@uniweb/theming": "~1.2.1"
|
|
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/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
|