@canopy-iiif/app 1.6.13 → 1.6.15
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/lib/build/iiif.js +20 -49
- package/lib/build/mdx.js +8 -2
- package/lib/build/pages.js +20 -10
- package/package.json +1 -1
package/lib/build/iiif.js
CHANGED
|
@@ -38,6 +38,19 @@ const IIIF_CACHE_DIR = path.resolve(".cache/iiif");
|
|
|
38
38
|
const IIIF_CACHE_MANIFESTS_DIR = path.join(IIIF_CACHE_DIR, "manifests");
|
|
39
39
|
const IIIF_CACHE_COLLECTIONS_DIR = path.join(IIIF_CACHE_DIR, "collections");
|
|
40
40
|
const IIIF_CACHE_COLLECTION = path.join(IIIF_CACHE_DIR, "collection.json");
|
|
41
|
+
|
|
42
|
+
function relativeRuntimeScript(outPath, filename, versioned = false) {
|
|
43
|
+
if (!outPath || !filename) return null;
|
|
44
|
+
const abs = path.join(OUT_DIR, "scripts", filename);
|
|
45
|
+
let rel = path.relative(path.dirname(outPath), abs).split(path.sep).join("/");
|
|
46
|
+
if (!versioned) return rel;
|
|
47
|
+
try {
|
|
48
|
+
const st = fs.statSync(abs);
|
|
49
|
+
const version = Math.floor(st.mtimeMs || Date.now());
|
|
50
|
+
if (version) rel += `?v=${version}`;
|
|
51
|
+
} catch (_) {}
|
|
52
|
+
return rel;
|
|
53
|
+
}
|
|
41
54
|
// Primary global index location
|
|
42
55
|
const IIIF_CACHE_INDEX = path.join(IIIF_CACHE_DIR, "index.json");
|
|
43
56
|
// Additional legacy locations kept for backward compatibility (read + optional write)
|
|
@@ -2003,40 +2016,16 @@ async function buildIiifCollectionPages(CONFIG) {
|
|
|
2003
2016
|
needsSearchForm;
|
|
2004
2017
|
|
|
2005
2018
|
const viewerRel = needsHydrateViewer
|
|
2006
|
-
?
|
|
2007
|
-
.relative(
|
|
2008
|
-
path.dirname(outPath),
|
|
2009
|
-
path.join(OUT_DIR, "scripts", "canopy-viewer.js"),
|
|
2010
|
-
)
|
|
2011
|
-
.split(path.sep)
|
|
2012
|
-
.join("/")
|
|
2019
|
+
? relativeRuntimeScript(outPath, "canopy-viewer.js", true)
|
|
2013
2020
|
: null;
|
|
2014
2021
|
const sliderRel = needsRelated
|
|
2015
|
-
?
|
|
2016
|
-
.relative(
|
|
2017
|
-
path.dirname(outPath),
|
|
2018
|
-
path.join(OUT_DIR, "scripts", "canopy-slider.js"),
|
|
2019
|
-
)
|
|
2020
|
-
.split(path.sep)
|
|
2021
|
-
.join("/")
|
|
2022
|
+
? relativeRuntimeScript(outPath, "canopy-slider.js", true)
|
|
2022
2023
|
: null;
|
|
2023
2024
|
const timelineRel = needsTimeline
|
|
2024
|
-
?
|
|
2025
|
-
.relative(
|
|
2026
|
-
path.dirname(outPath),
|
|
2027
|
-
path.join(OUT_DIR, "scripts", "canopy-timeline.js"),
|
|
2028
|
-
)
|
|
2029
|
-
.split(path.sep)
|
|
2030
|
-
.join("/")
|
|
2025
|
+
? relativeRuntimeScript(outPath, "canopy-timeline.js", true)
|
|
2031
2026
|
: null;
|
|
2032
2027
|
const mapRel = needsMap
|
|
2033
|
-
?
|
|
2034
|
-
.relative(
|
|
2035
|
-
path.dirname(outPath),
|
|
2036
|
-
path.join(OUT_DIR, "scripts", "canopy-map.js"),
|
|
2037
|
-
)
|
|
2038
|
-
.split(path.sep)
|
|
2039
|
-
.join("/")
|
|
2028
|
+
? relativeRuntimeScript(outPath, "canopy-map.js", true)
|
|
2040
2029
|
: null;
|
|
2041
2030
|
const mapCssRel = needsMap
|
|
2042
2031
|
? path
|
|
@@ -2048,31 +2037,13 @@ async function buildIiifCollectionPages(CONFIG) {
|
|
|
2048
2037
|
.join("/")
|
|
2049
2038
|
: null;
|
|
2050
2039
|
const heroRel = needsHeroSlider
|
|
2051
|
-
?
|
|
2052
|
-
.relative(
|
|
2053
|
-
path.dirname(outPath),
|
|
2054
|
-
path.join(OUT_DIR, "scripts", "canopy-hero-slider.js"),
|
|
2055
|
-
)
|
|
2056
|
-
.split(path.sep)
|
|
2057
|
-
.join("/")
|
|
2040
|
+
? relativeRuntimeScript(outPath, "canopy-hero-slider.js", true)
|
|
2058
2041
|
: null;
|
|
2059
2042
|
const relatedRel = needsRelated
|
|
2060
|
-
?
|
|
2061
|
-
.relative(
|
|
2062
|
-
path.dirname(outPath),
|
|
2063
|
-
path.join(OUT_DIR, "scripts", "canopy-related-items.js"),
|
|
2064
|
-
)
|
|
2065
|
-
.split(path.sep)
|
|
2066
|
-
.join("/")
|
|
2043
|
+
? relativeRuntimeScript(outPath, "canopy-related-items.js", true)
|
|
2067
2044
|
: null;
|
|
2068
2045
|
const searchFormRel = needsSearchForm
|
|
2069
|
-
?
|
|
2070
|
-
.relative(
|
|
2071
|
-
path.dirname(outPath),
|
|
2072
|
-
path.join(OUT_DIR, "scripts", "canopy-search-form.js"),
|
|
2073
|
-
)
|
|
2074
|
-
.split(path.sep)
|
|
2075
|
-
.join("/")
|
|
2046
|
+
? relativeRuntimeScript(outPath, "canopy-search-form.js", true)
|
|
2076
2047
|
: null;
|
|
2077
2048
|
|
|
2078
2049
|
const moduleScriptRels = [];
|
package/lib/build/mdx.js
CHANGED
|
@@ -1283,14 +1283,20 @@ async function buildCloverHydrationRuntimes() {
|
|
|
1283
1283
|
renameAnonymousChunks(scriptsDir);
|
|
1284
1284
|
try {
|
|
1285
1285
|
const { logLine } = require("./log");
|
|
1286
|
-
|
|
1286
|
+
const runtimeLabels = {
|
|
1287
|
+
viewer: "Viewer, Scroll, and Image runtime",
|
|
1288
|
+
slider: "Slider runtime",
|
|
1289
|
+
};
|
|
1290
|
+
Object.keys(entryPoints).forEach((key) => {
|
|
1291
|
+
const file = `canopy-${key}.js`;
|
|
1287
1292
|
try {
|
|
1288
1293
|
const abs = path.join(scriptsDir, file);
|
|
1289
1294
|
const st = fs.statSync(abs);
|
|
1290
1295
|
const size = st && st.size ? st.size : 0;
|
|
1291
1296
|
const kb = size ? ` (${(size / 1024).toFixed(1)} KB)` : "";
|
|
1292
1297
|
const rel = path.relative(process.cwd(), abs).split(path.sep).join("/");
|
|
1293
|
-
|
|
1298
|
+
const label = runtimeLabels[key] ? ` – ${runtimeLabels[key]}` : "";
|
|
1299
|
+
logLine(`✓ Wrote ${rel}${kb}${label}`, "cyan");
|
|
1294
1300
|
} catch (_) {}
|
|
1295
1301
|
});
|
|
1296
1302
|
} catch (_) {}
|
package/lib/build/pages.js
CHANGED
|
@@ -14,6 +14,19 @@ const mdx = require('./mdx');
|
|
|
14
14
|
const navigation = require('../components/navigation');
|
|
15
15
|
const referenced = require('../components/referenced');
|
|
16
16
|
|
|
17
|
+
function relativeRuntimeScript(outPath, filename, versioned = false) {
|
|
18
|
+
if (!outPath || !filename) return null;
|
|
19
|
+
const abs = path.join(OUT_DIR, 'scripts', filename);
|
|
20
|
+
let rel = path.relative(path.dirname(outPath), abs).split(path.sep).join('/');
|
|
21
|
+
if (!versioned) return rel;
|
|
22
|
+
try {
|
|
23
|
+
const st = fs.statSync(abs);
|
|
24
|
+
const version = Math.floor(st.mtimeMs || Date.now());
|
|
25
|
+
if (version) rel += `?v=${version}`;
|
|
26
|
+
} catch (_) {}
|
|
27
|
+
return rel;
|
|
28
|
+
}
|
|
29
|
+
|
|
17
30
|
function normalizeWhitespace(value) {
|
|
18
31
|
if (!value) return '';
|
|
19
32
|
return String(value).replace(/\s+/g, ' ').trim();
|
|
@@ -213,35 +226,32 @@ async function renderContentMdxToHtml(filePath, outPath, extraProps = {}, source
|
|
|
213
226
|
const needsFacets = body.includes('data-canopy-related-items');
|
|
214
227
|
const needsCustomClients = body.includes('data-canopy-client-component');
|
|
215
228
|
const viewerRel = needsHydrateViewer
|
|
216
|
-
?
|
|
229
|
+
? relativeRuntimeScript(outPath, 'canopy-viewer.js', true)
|
|
217
230
|
: null;
|
|
218
231
|
const sliderRel = (needsHydrateSlider || needsFacets)
|
|
219
|
-
?
|
|
232
|
+
? relativeRuntimeScript(outPath, 'canopy-slider.js', true)
|
|
220
233
|
: null;
|
|
221
234
|
const heroRel = needsHeroSlider
|
|
222
|
-
?
|
|
235
|
+
? relativeRuntimeScript(outPath, 'canopy-hero-slider.js', true)
|
|
223
236
|
: null;
|
|
224
237
|
const heroCssRel = needsHeroSlider
|
|
225
238
|
? path.relative(path.dirname(outPath), path.join(OUT_DIR, 'scripts', 'canopy-hero-slider.css')).split(path.sep).join('/')
|
|
226
239
|
: null;
|
|
227
240
|
const timelineRel = needsTimeline
|
|
228
|
-
?
|
|
241
|
+
? relativeRuntimeScript(outPath, 'canopy-timeline.js', true)
|
|
229
242
|
: null;
|
|
230
243
|
const mapRel = needsMap
|
|
231
|
-
?
|
|
244
|
+
? relativeRuntimeScript(outPath, 'canopy-map.js', true)
|
|
232
245
|
: null;
|
|
233
246
|
const mapCssRel = needsMap
|
|
234
247
|
? path.relative(path.dirname(outPath), path.join(OUT_DIR, 'scripts', 'canopy-map.css')).split(path.sep).join('/')
|
|
235
248
|
: null;
|
|
236
249
|
const facetsRel = needsFacets
|
|
237
|
-
?
|
|
250
|
+
? relativeRuntimeScript(outPath, 'canopy-related-items.js', true)
|
|
238
251
|
: null;
|
|
239
252
|
let searchFormRel = null;
|
|
240
253
|
if (needsSearchForm) {
|
|
241
|
-
|
|
242
|
-
let rel = path.relative(path.dirname(outPath), runtimeAbs).split(path.sep).join('/');
|
|
243
|
-
try { const st = fs.statSync(runtimeAbs); rel += `?v=${Math.floor(st.mtimeMs || Date.now())}`; } catch (_) {}
|
|
244
|
-
searchFormRel = rel;
|
|
254
|
+
searchFormRel = relativeRuntimeScript(outPath, 'canopy-search-form.js', true);
|
|
245
255
|
}
|
|
246
256
|
let customClientRel = null;
|
|
247
257
|
if (needsCustomClients) {
|