@nulib/canopy 0.0.0-stage → 2.0.0

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.
Files changed (141) hide show
  1. package/bin/canopy.js +16 -0
  2. package/lib/AGENTS.md +107 -0
  3. package/lib/base-path.js +67 -0
  4. package/lib/build/appearance.js +76 -0
  5. package/lib/build/assets.js +30 -0
  6. package/lib/build/build.js +350 -0
  7. package/lib/build/dev.js +1355 -0
  8. package/lib/build/devtoast.config.json +6 -0
  9. package/lib/build/devtoast.css +14 -0
  10. package/lib/build/facets.js +19 -0
  11. package/lib/build/fonts.js +105 -0
  12. package/lib/build/iiif.js +2990 -0
  13. package/lib/build/log.js +31 -0
  14. package/lib/build/mdx.js +1967 -0
  15. package/lib/build/package-names.js +111 -0
  16. package/lib/build/pages.js +420 -0
  17. package/lib/build/rehype-task-list-labels.js +54 -0
  18. package/lib/build/runtimes.js +141 -0
  19. package/lib/build/search-index.js +55 -0
  20. package/lib/build/search-text.js +160 -0
  21. package/lib/build/search-workflow.js +72 -0
  22. package/lib/build/search.js +302 -0
  23. package/lib/build/sitemap.js +197 -0
  24. package/lib/build/styles.js +140 -0
  25. package/lib/build/theme-tokens.js +78 -0
  26. package/lib/build/ui-styles.js +25 -0
  27. package/lib/build/upgrade-notices.js +121 -0
  28. package/lib/cli.js +64 -0
  29. package/lib/common.js +580 -0
  30. package/lib/components/bibliography.js +197 -0
  31. package/lib/components/featured.js +237 -0
  32. package/lib/components/hero-slider-runtime.js +215 -0
  33. package/lib/components/image-story-runtime-entry.js +249 -0
  34. package/lib/components/map-runtime.js +114 -0
  35. package/lib/components/metadata-index.js +32 -0
  36. package/lib/components/nav-place.js +227 -0
  37. package/lib/components/navigation.js +381 -0
  38. package/lib/components/referenced.js +217 -0
  39. package/lib/components/slider-runtime-entry.js +106 -0
  40. package/lib/components/timeline-runtime.js +80 -0
  41. package/lib/components/viewer-runtime-entry.js +88 -0
  42. package/lib/config-path.js +78 -0
  43. package/lib/default-locale.js +113 -0
  44. package/lib/discovery/browser-loader.js +107 -0
  45. package/lib/discovery/browser.js +115 -0
  46. package/lib/discovery/config.js +25 -0
  47. package/lib/discovery/envelope.js +124 -0
  48. package/lib/discovery/export.js +226 -0
  49. package/lib/discovery/ingestion.js +62 -0
  50. package/lib/discovery/pagination.js +66 -0
  51. package/lib/discovery/provenance.js +79 -0
  52. package/lib/discovery/search.js +81 -0
  53. package/lib/discovery/tools.js +155 -0
  54. package/lib/discovery/validation.js +121 -0
  55. package/lib/head.js +154 -0
  56. package/lib/iiif/thumbnail.js +402 -0
  57. package/lib/index.js +9 -0
  58. package/lib/locale-runtime.js +69 -0
  59. package/lib/locales.js +203 -0
  60. package/lib/orchestrator.js +231 -0
  61. package/lib/page-context.js +24 -0
  62. package/lib/search/bundle.js +25 -0
  63. package/lib/search/data.js +202 -0
  64. package/lib/search/engine.js +86 -0
  65. package/lib/search/index-cache.js +95 -0
  66. package/lib/search/search-app.jsx +835 -0
  67. package/lib/search/search-engine-runtime.js +44 -0
  68. package/lib/search/search-form-runtime.js +462 -0
  69. package/lib/search/search.js +676 -0
  70. package/package.json +111 -4
  71. package/types/base-path.d.ts +4 -0
  72. package/types/orchestrator.d.ts +17 -0
  73. package/ui/dist/index.mjs +7358 -0
  74. package/ui/dist/index.mjs.map +7 -0
  75. package/ui/dist/server.mjs +12731 -0
  76. package/ui/dist/server.mjs.map +7 -0
  77. package/ui/fonts/OFL.txt +98 -0
  78. package/ui/fonts/google-sans-flex-latin-ext.woff2 +0 -0
  79. package/ui/fonts/google-sans-flex-latin.woff2 +0 -0
  80. package/ui/fonts/source-serif-4-italic-latin-ext.woff2 +0 -0
  81. package/ui/fonts/source-serif-4-italic-latin.woff2 +0 -0
  82. package/ui/fonts/source-serif-4-latin-ext.woff2 +0 -0
  83. package/ui/fonts/source-serif-4-latin.woff2 +0 -0
  84. package/ui/styles/base/_common.scss +97 -0
  85. package/ui/styles/base/_heading.scss +61 -0
  86. package/ui/styles/base/_markdown.scss +188 -0
  87. package/ui/styles/base/_type.scss +51 -0
  88. package/ui/styles/base/_utilities.scss +7 -0
  89. package/ui/styles/base/index.scss +5 -0
  90. package/ui/styles/components/_article-card.scss +108 -0
  91. package/ui/styles/components/_band.scss +104 -0
  92. package/ui/styles/components/_bibliography.scss +88 -0
  93. package/ui/styles/components/_buttons.scss +143 -0
  94. package/ui/styles/components/_card.scss +109 -0
  95. package/ui/styles/components/_diagram.scss +76 -0
  96. package/ui/styles/components/_feature.scss +66 -0
  97. package/ui/styles/components/_footer.scss +136 -0
  98. package/ui/styles/components/_gallery.scss +476 -0
  99. package/ui/styles/components/_image-story.scss +56 -0
  100. package/ui/styles/components/_interstitial-hero.scss +625 -0
  101. package/ui/styles/components/_layout.scss +83 -0
  102. package/ui/styles/components/_map.scss +296 -0
  103. package/ui/styles/components/_metadata-index.scss +68 -0
  104. package/ui/styles/components/_nav-tree.scss +80 -0
  105. package/ui/styles/components/_referenced-items.scss +69 -0
  106. package/ui/styles/components/_sub-navigation.scss +208 -0
  107. package/ui/styles/components/_swoosh.scss +50 -0
  108. package/ui/styles/components/_timeline.scss +350 -0
  109. package/ui/styles/components/_work.scss +71 -0
  110. package/ui/styles/components/header/_header.scss +294 -0
  111. package/ui/styles/components/header/_logo.scss +99 -0
  112. package/ui/styles/components/header/_navbar.scss +143 -0
  113. package/ui/styles/components/header/index.scss +3 -0
  114. package/ui/styles/components/iiif/_image.scss +32 -0
  115. package/ui/styles/components/iiif/_slider.scss +5 -0
  116. package/ui/styles/components/iiif/index.scss +2 -0
  117. package/ui/styles/components/index.scss +25 -0
  118. package/ui/styles/components/modal/_modal.scss +130 -0
  119. package/ui/styles/components/modal/index.scss +1 -0
  120. package/ui/styles/components/search/_filters.scss +259 -0
  121. package/ui/styles/components/search/_form.scss +187 -0
  122. package/ui/styles/components/search/_panel.scss +7 -0
  123. package/ui/styles/components/search/_results.scss +241 -0
  124. package/ui/styles/components/search/_tabs.scss +60 -0
  125. package/ui/styles/components/search/index.scss +4 -0
  126. package/ui/styles/index.css +5007 -0
  127. package/ui/styles/index.scss +11 -0
  128. package/ui/styles/settings/_breakpoints.scss +7 -0
  129. package/ui/styles/settings/_focus.scss +15 -0
  130. package/ui/styles/settings/_tokens.scss +170 -0
  131. package/ui/styles/settings/_type.scss +126 -0
  132. package/ui/styles/version-parity.css +116 -0
  133. package/ui/tailwind-canopy-iiif-plugin.js +39 -0
  134. package/ui/tailwind-canopy-iiif-preset.js +32 -0
  135. package/ui/tailwind-config.d.ts +29 -0
  136. package/ui/tailwind-config.js +159 -0
  137. package/ui/tailwind-default.config.mjs +4 -0
  138. package/ui/theme-color.js +130 -0
  139. package/ui/theme-palette.js +337 -0
  140. package/ui/theme.js +153 -0
  141. package/README.md +0 -3
@@ -0,0 +1,6 @@
1
+ {
2
+ "buildingText": "Rebuilding…",
3
+ "reloadedText": "Reloaded",
4
+ "fadeMs": 800,
5
+ "reloadDelayMs": 200
6
+ }
@@ -0,0 +1,14 @@
1
+ #__lr_toast {
2
+ position: fixed;
3
+ bottom: 1rem;
4
+ right: 1rem;
5
+ background: rgba(0, 0, 0, 0.7);
6
+ color: #fff;
7
+ padding: 0.5rem 1rem;
8
+ border-radius: 0.5rem;
9
+ font: 1rem system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Helvetica,
10
+ Arial, sans-serif;
11
+ z-index: 99999;
12
+ opacity: 0;
13
+ transition: opacity 0.5s ease;
14
+ }
@@ -0,0 +1,19 @@
1
+
2
+ const { logLine } = require('./log');
3
+
4
+ async function generateFacets(combined) {
5
+ try {
6
+ const { loadConfig } = require('./iiif');
7
+ const searchBuild = require('./search');
8
+ const cfg = await loadConfig();
9
+ const labels = Array.isArray(cfg && cfg.metadata) ? cfg.metadata : [];
10
+ await searchBuild.buildFacetsForWorks(combined, labels);
11
+ await searchBuild.writeFacetCollections(labels, combined);
12
+ await searchBuild.writeFacetsSearchApi();
13
+ try { logLine('✓ Facets generated', 'cyan'); } catch (_) {}
14
+ } catch (e) {
15
+ try { logLine('! Facets generation skipped', 'yellow'); } catch (_) {}
16
+ }
17
+ }
18
+
19
+ module.exports = { generateFacets };
@@ -0,0 +1,105 @@
1
+ // The 2.x look's two families, shipped with the package (`ui/fonts/`, under the SIL Open
2
+ // Font License, `ui/fonts/OFL.txt`) and copied next to each site's stylesheet, so a
3
+ // visitor's browser asks no third party for them: Google Sans Flex, for headings and the
4
+ // interface, and Source Serif 4, for reading text (DESIGN.md §1, "Type").
5
+ //
6
+ // The faces are declared in the block the build writes at the top of the compiled
7
+ // stylesheet (`theme-tokens.js`), after Tailwind has run. A relative `url()` there
8
+ // resolves against `styles/styles.css` itself, so it holds under any base path; a face
9
+ // declared in the UI stylesheet would have its `url()` rewritten by Tailwind, relative to
10
+ // the site's entry stylesheet, and point outside `site/`.
11
+ //
12
+ // Only the latin and latin-ext subsets ship. Text outside them falls back down the
13
+ // family's stack. A browser fetches a face only for text drawn in it, so a site that
14
+ // sets its own families loads none of these.
15
+
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+
19
+ const FONT_SOURCE_DIR = path.resolve(__dirname, '..', '..', 'ui', 'fonts');
20
+ const FONT_DIR_NAME = 'fonts';
21
+
22
+ const LATIN =
23
+ 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD';
24
+ const latinExt = (lastCurrency) =>
25
+ `U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-${lastCurrency}, U+2113, U+2C60-2C7F, U+A720-A7FF`;
26
+
27
+ // One variable file a subset and style, spanning the two weights the look uses (400 and
28
+ // 700).
29
+ const FACES = [
30
+ {
31
+ family: 'Google Sans Flex',
32
+ style: 'normal',
33
+ file: 'google-sans-flex-latin.woff2',
34
+ unicodeRange: LATIN,
35
+ },
36
+ {
37
+ family: 'Google Sans Flex',
38
+ style: 'normal',
39
+ file: 'google-sans-flex-latin-ext.woff2',
40
+ unicodeRange: latinExt('20C0'),
41
+ },
42
+ { family: 'Source Serif 4', style: 'normal', file: 'source-serif-4-latin.woff2', unicodeRange: LATIN },
43
+ {
44
+ family: 'Source Serif 4',
45
+ style: 'normal',
46
+ file: 'source-serif-4-latin-ext.woff2',
47
+ unicodeRange: latinExt('20C4'),
48
+ },
49
+ {
50
+ family: 'Source Serif 4',
51
+ style: 'italic',
52
+ file: 'source-serif-4-italic-latin.woff2',
53
+ unicodeRange: LATIN,
54
+ },
55
+ {
56
+ family: 'Source Serif 4',
57
+ style: 'italic',
58
+ file: 'source-serif-4-italic-latin-ext.woff2',
59
+ unicodeRange: latinExt('20C4'),
60
+ },
61
+ ];
62
+
63
+ const FONT_FAMILIES = Array.from(new Set(FACES.map((face) => face.family)));
64
+ const FONT_FILES = [...FACES.map((face) => face.file), 'OFL.txt'];
65
+
66
+ function fontFaceCss() {
67
+ return FACES.map(
68
+ (face) =>
69
+ `@font-face{font-family:"${face.family}";font-style:${face.style};font-weight:400 700;` +
70
+ `font-stretch:100%;font-display:swap;` +
71
+ `src:url("${FONT_DIR_NAME}/${face.file}") format("woff2");` +
72
+ `unicode-range:${face.unicodeRange}}`,
73
+ ).join('\n');
74
+ }
75
+
76
+ // Copies the faces and their license into `<stylesDir>/fonts/`, leaving files that are
77
+ // already the same size alone, so the dev watcher's repeat runs write nothing.
78
+ function copyFonts(stylesDir) {
79
+ const dest = path.join(stylesDir, FONT_DIR_NAME);
80
+ try {
81
+ fs.mkdirSync(dest, { recursive: true });
82
+ } catch (_) {}
83
+ for (const name of FONT_FILES) {
84
+ const from = path.join(FONT_SOURCE_DIR, name);
85
+ const to = path.join(dest, name);
86
+ try {
87
+ const source = fs.statSync(from);
88
+ let same = false;
89
+ try {
90
+ same = fs.statSync(to).size === source.size;
91
+ } catch (_) {}
92
+ if (!same) fs.copyFileSync(from, to);
93
+ } catch (_) {}
94
+ }
95
+ }
96
+
97
+ module.exports = {
98
+ FACES,
99
+ FONT_DIR_NAME,
100
+ FONT_FAMILIES,
101
+ FONT_FILES,
102
+ FONT_SOURCE_DIR,
103
+ copyFonts,
104
+ fontFaceCss,
105
+ };