@canopy-iiif/app 1.6.18 → 1.6.20

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 CHANGED
@@ -2169,6 +2169,7 @@ async function buildIiifCollectionPages(CONFIG) {
2169
2169
  body.includes("data-canopy-scroll") ||
2170
2170
  body.includes("data-canopy-image");
2171
2171
  const needsRelated = body.includes("data-canopy-related-items");
2172
+ const needsImageStory = body.includes("data-canopy-image-story");
2172
2173
  const needsHeroSlider = body.includes("data-canopy-hero-slider");
2173
2174
  const needsTimeline = body.includes("data-canopy-timeline");
2174
2175
  const needsMap = body.includes("data-canopy-map");
@@ -2185,6 +2186,9 @@ async function buildIiifCollectionPages(CONFIG) {
2185
2186
  const sliderRel = needsRelated
2186
2187
  ? relativeRuntimeScript(outPath, "canopy-slider.js", true)
2187
2188
  : null;
2189
+ const imageStoryRel = needsImageStory
2190
+ ? relativeRuntimeScript(outPath, "canopy-image-story.js", true)
2191
+ : null;
2188
2192
  const timelineRel = needsTimeline
2189
2193
  ? relativeRuntimeScript(outPath, "canopy-timeline.js", true)
2190
2194
  : null;
@@ -2213,6 +2217,7 @@ async function buildIiifCollectionPages(CONFIG) {
2213
2217
  const moduleScriptRels = [];
2214
2218
  if (viewerRel) moduleScriptRels.push(viewerRel);
2215
2219
  if (sliderRel) moduleScriptRels.push(sliderRel);
2220
+ if (imageStoryRel) moduleScriptRels.push(imageStoryRel);
2216
2221
  const primaryClassicScripts = [];
2217
2222
  if (heroRel) primaryClassicScripts.push(heroRel);
2218
2223
  if (relatedRel) primaryClassicScripts.push(relatedRel);
package/lib/build/mdx.js CHANGED
@@ -1263,6 +1263,10 @@ async function buildCloverHydrationRuntimes() {
1263
1263
  const entryPoints = {
1264
1264
  viewer: path.join(__dirname, "../components/viewer-runtime-entry.js"),
1265
1265
  slider: path.join(__dirname, "../components/slider-runtime-entry.js"),
1266
+ "image-story": path.join(
1267
+ __dirname,
1268
+ "../components/image-story-runtime-entry.js",
1269
+ ),
1266
1270
  };
1267
1271
  await esbuild.build({
1268
1272
  entryPoints,
@@ -1286,6 +1290,7 @@ async function buildCloverHydrationRuntimes() {
1286
1290
  const runtimeLabels = {
1287
1291
  viewer: "Viewer, Scroll, and Image runtime",
1288
1292
  slider: "Slider runtime",
1293
+ "image-story": "ImageStory runtime",
1289
1294
  };
1290
1295
  Object.keys(entryPoints).forEach((key) => {
1291
1296
  const file = `canopy-${key}.js`;
@@ -219,6 +219,7 @@ async function renderContentMdxToHtml(filePath, outPath, extraProps = {}, source
219
219
  body.includes('data-canopy-scroll') ||
220
220
  body.includes('data-canopy-image');
221
221
  const needsHydrateSlider = body.includes('data-canopy-slider');
222
+ const needsImageStory = body.includes('data-canopy-image-story');
222
223
  const needsHeroSlider = body.includes('data-canopy-hero-slider');
223
224
  const needsTimeline = body.includes('data-canopy-timeline');
224
225
  const needsMap = body.includes('data-canopy-map');
@@ -231,6 +232,9 @@ async function renderContentMdxToHtml(filePath, outPath, extraProps = {}, source
231
232
  const sliderRel = (needsHydrateSlider || needsFacets)
232
233
  ? relativeRuntimeScript(outPath, 'canopy-slider.js', true)
233
234
  : null;
235
+ const imageStoryRel = needsImageStory
236
+ ? relativeRuntimeScript(outPath, 'canopy-image-story.js', true)
237
+ : null;
234
238
  const heroRel = needsHeroSlider
235
239
  ? relativeRuntimeScript(outPath, 'canopy-hero-slider.js', true)
236
240
  : null;
@@ -271,6 +275,7 @@ async function renderContentMdxToHtml(filePath, outPath, extraProps = {}, source
271
275
  const moduleScriptRels = [];
272
276
  if (viewerRel) moduleScriptRels.push(viewerRel);
273
277
  if (sliderRel) moduleScriptRels.push(sliderRel);
278
+ if (imageStoryRel) moduleScriptRels.push(imageStoryRel);
274
279
  if (customClientRel) moduleScriptRels.push(customClientRel);
275
280
  const primaryClassicScripts = [];
276
281
  if (heroRel) primaryClassicScripts.push(heroRel);
@@ -0,0 +1,69 @@
1
+ import { mountImageStory } from '../../ui/dist/index.mjs';
2
+
3
+ function ready(fn) {
4
+ if (typeof document === 'undefined') return;
5
+ if (document.readyState === 'loading') {
6
+ document.addEventListener('DOMContentLoaded', fn, { once: true });
7
+ } else {
8
+ fn();
9
+ }
10
+ }
11
+
12
+ function parseProps(node) {
13
+ try {
14
+ const script = node.querySelector('script[type="application/json"]');
15
+ if (!script) return {};
16
+ const text = script.textContent || '{}';
17
+ return JSON.parse(text) || {};
18
+ } catch (_) {
19
+ return {};
20
+ }
21
+ }
22
+
23
+ function mount(node) {
24
+ if (!node || node.__canopyImageStoryMounted) return;
25
+ try {
26
+ const props = parseProps(node);
27
+ mountImageStory(node, props);
28
+ node.__canopyImageStoryMounted = true;
29
+ } catch (_) {}
30
+ }
31
+
32
+ function scan() {
33
+ try {
34
+ document
35
+ .querySelectorAll('[data-canopy-image-story]')
36
+ .forEach((node) => mount(node));
37
+ } catch (_) {}
38
+ }
39
+
40
+ function observe() {
41
+ try {
42
+ const obs = new MutationObserver((mutations) => {
43
+ const toMount = [];
44
+ mutations.forEach((mutation) => {
45
+ mutation.addedNodes &&
46
+ mutation.addedNodes.forEach((node) => {
47
+ if (!(node instanceof Element)) return;
48
+ if (node.matches && node.matches('[data-canopy-image-story]')) {
49
+ toMount.push(node);
50
+ }
51
+ const inner = node.querySelectorAll
52
+ ? node.querySelectorAll('[data-canopy-image-story]')
53
+ : [];
54
+ inner && inner.forEach && inner.forEach((el) => toMount.push(el));
55
+ });
56
+ });
57
+ if (toMount.length) Promise.resolve().then(() => toMount.forEach(mount));
58
+ });
59
+ obs.observe(document.documentElement || document.body, {
60
+ childList: true,
61
+ subtree: true,
62
+ });
63
+ } catch (_) {}
64
+ }
65
+
66
+ ready(function onReady() {
67
+ scan();
68
+ observe();
69
+ });
@@ -41,7 +41,8 @@ function slugFromRelative(relativePath) {
41
41
  function pageSortKey(relativePath) {
42
42
  const normalized = normalizeRelativePath(relativePath).toLowerCase();
43
43
  if (!normalized) return "";
44
- return normalized.replace(/(^|\/)index\.mdx$/i, "$1-index.mdx");
44
+ const withoutExtension = normalized.replace(/\.mdx$/i, "");
45
+ return withoutExtension.replace(/(^|\/)index$/i, "$1-index");
45
46
  }
46
47
 
47
48
  function extractTitleSafe(raw) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopy-iiif/app",
3
- "version": "1.6.18",
3
+ "version": "1.6.20",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Mat Jordan <mat@northwestern.edu>",