@canopy-iiif/app 1.7.0 → 1.8.1
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/dev.js +12 -2
- package/lib/build/styles.js +11 -1
- package/lib/orchestrator.js +50 -13
- package/package.json +1 -1
- package/ui/dist/index.mjs +9 -0
- package/ui/dist/index.mjs.map +2 -2
- package/ui/dist/server.mjs +9 -0
- package/ui/dist/server.mjs.map +2 -2
- package/ui/styles/components/_gallery.scss +63 -14
- package/ui/styles/index.css +58 -14
package/lib/build/dev.js
CHANGED
|
@@ -22,14 +22,24 @@ const {
|
|
|
22
22
|
const APP_COMPONENTS_DIR = path.join(process.cwd(), "app", "components");
|
|
23
23
|
|
|
24
24
|
function resolveTailwindCli() {
|
|
25
|
+
const root = process.cwd();
|
|
26
|
+
let cliEntry = null;
|
|
27
|
+
try {
|
|
28
|
+
cliEntry = require.resolve("@tailwindcss/cli/dist/index.mjs", { paths: [root] });
|
|
29
|
+
} catch (_) {
|
|
30
|
+
cliEntry = null;
|
|
31
|
+
}
|
|
32
|
+
if (cliEntry) {
|
|
33
|
+
return { cmd: process.execPath || "node", args: [cliEntry] };
|
|
34
|
+
}
|
|
25
35
|
const bin = path.join(
|
|
26
|
-
|
|
36
|
+
root,
|
|
27
37
|
"node_modules",
|
|
28
38
|
".bin",
|
|
29
39
|
process.platform === "win32" ? "tailwindcss.cmd" : "tailwindcss"
|
|
30
40
|
);
|
|
31
41
|
if (fs.existsSync(bin)) return { cmd: bin, args: [] };
|
|
32
|
-
return { cmd:
|
|
42
|
+
return { cmd: "tailwindcss", args: [] };
|
|
33
43
|
}
|
|
34
44
|
const PORT = Number(process.env.PORT || 5001);
|
|
35
45
|
const BUILD_MODULE_PATH = path.resolve(__dirname, "build.js");
|
package/lib/build/styles.js
CHANGED
|
@@ -8,8 +8,18 @@ const {
|
|
|
8
8
|
} = require("../common");
|
|
9
9
|
|
|
10
10
|
function resolveTailwindCli() {
|
|
11
|
+
const root = process.cwd();
|
|
12
|
+
let cliEntry = null;
|
|
13
|
+
try {
|
|
14
|
+
cliEntry = require.resolve("@tailwindcss/cli/dist/index.mjs", { paths: [root] });
|
|
15
|
+
} catch (_) {
|
|
16
|
+
cliEntry = null;
|
|
17
|
+
}
|
|
18
|
+
if (cliEntry) {
|
|
19
|
+
return {cmd: process.execPath || "node", args: [cliEntry]};
|
|
20
|
+
}
|
|
11
21
|
const localBin = path.join(
|
|
12
|
-
|
|
22
|
+
root,
|
|
13
23
|
"node_modules",
|
|
14
24
|
".bin",
|
|
15
25
|
process.platform === "win32" ? "tailwindcss.cmd" : "tailwindcss"
|
package/lib/orchestrator.js
CHANGED
|
@@ -10,6 +10,40 @@ let uiWatcherChild = null;
|
|
|
10
10
|
|
|
11
11
|
const workspacePackageJsonPath = path.resolve(process.cwd(), 'packages/app/package.json');
|
|
12
12
|
const hasAppWorkspace = fs.existsSync(workspacePackageJsonPath);
|
|
13
|
+
const workspaceUiDistDir = path.resolve(process.cwd(), 'packages/app/ui/dist');
|
|
14
|
+
const requiredUiArtifacts = [
|
|
15
|
+
path.join(workspaceUiDistDir, 'server.mjs'),
|
|
16
|
+
path.join(workspaceUiDistDir, 'index.mjs'),
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function prettyPath(p) {
|
|
20
|
+
try {
|
|
21
|
+
const rel = path.relative(process.cwd(), p);
|
|
22
|
+
return rel ? rel.split(path.sep).join('/') : p;
|
|
23
|
+
} catch (_) {
|
|
24
|
+
return p;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function ensureUiDistReady(context = 'build') {
|
|
29
|
+
if (!hasAppWorkspace) return;
|
|
30
|
+
const missing = [];
|
|
31
|
+
for (const file of requiredUiArtifacts) {
|
|
32
|
+
try {
|
|
33
|
+
if (!fs.existsSync(file)) missing.push(file);
|
|
34
|
+
} catch (_) {
|
|
35
|
+
missing.push(file);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (missing.length) {
|
|
39
|
+
const list = missing.map((file) => prettyPath(file)).join(', ');
|
|
40
|
+
const label = context ? `${context} ` : '';
|
|
41
|
+
throw new Error(
|
|
42
|
+
`@canopy-iiif/app/ui ${label}did not produce required bundle(s): ${list}. ` +
|
|
43
|
+
'Run "npm -w @canopy-iiif/app run ui:build" and ensure it completes successfully.'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
13
47
|
|
|
14
48
|
function getMode(argv = process.argv.slice(2), env = process.env) {
|
|
15
49
|
const cli = new Set(argv);
|
|
@@ -49,6 +83,20 @@ function start(cmd, args, opts = {}) {
|
|
|
49
83
|
return child;
|
|
50
84
|
}
|
|
51
85
|
|
|
86
|
+
async function buildUiOnce(label, env = process.env) {
|
|
87
|
+
if (!hasAppWorkspace) return;
|
|
88
|
+
const prefix = label || 'Building';
|
|
89
|
+
log(`${prefix} UI assets (@canopy-iiif/app/ui)`);
|
|
90
|
+
try {
|
|
91
|
+
await runOnce('npm', ['-w', '@canopy-iiif/app', 'run', 'ui:build'], { env });
|
|
92
|
+
} catch (error) {
|
|
93
|
+
const message = (error && error.message) || String(error);
|
|
94
|
+
throw new Error(`[canopy] Failed to ${prefix.toLowerCase()} UI assets: ${message}`);
|
|
95
|
+
}
|
|
96
|
+
ensureUiDistReady(prefix.toLowerCase());
|
|
97
|
+
log('UI assets ready');
|
|
98
|
+
}
|
|
99
|
+
|
|
52
100
|
async function prepareUi(mode, env = process.env) {
|
|
53
101
|
if (!hasAppWorkspace) {
|
|
54
102
|
log('Using bundled UI assets from @canopy-iiif/app (workspace not detected)');
|
|
@@ -56,22 +104,11 @@ async function prepareUi(mode, env = process.env) {
|
|
|
56
104
|
}
|
|
57
105
|
|
|
58
106
|
if (mode === 'build') {
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
await runOnce('npm', ['-w', '@canopy-iiif/app', 'run', 'ui:build'], { env });
|
|
62
|
-
log('UI assets built');
|
|
63
|
-
} catch (error) {
|
|
64
|
-
warn(`UI build skipped: ${(error && error.message) || String(error)}`);
|
|
65
|
-
}
|
|
107
|
+
await buildUiOnce('Building', env);
|
|
66
108
|
return null;
|
|
67
109
|
}
|
|
68
110
|
|
|
69
|
-
|
|
70
|
-
log('Prebuilding UI assets (@canopy-iiif/app/ui)');
|
|
71
|
-
await runOnce('npm', ['-w', '@canopy-iiif/app', 'run', 'ui:build'], { env });
|
|
72
|
-
} catch (error) {
|
|
73
|
-
warn(`UI prebuild skipped: ${(error && error.message) || String(error)}`);
|
|
74
|
-
}
|
|
111
|
+
await buildUiOnce('Prebuilding', env);
|
|
75
112
|
|
|
76
113
|
log('Starting UI watcher (@canopy-iiif/app/ui)');
|
|
77
114
|
try {
|
package/package.json
CHANGED
package/ui/dist/index.mjs
CHANGED
|
@@ -4625,6 +4625,13 @@ function GalleryFigure({ item }) {
|
|
|
4625
4625
|
)
|
|
4626
4626
|
);
|
|
4627
4627
|
}
|
|
4628
|
+
function GalleryContent({ children, flex = false }) {
|
|
4629
|
+
const contentClassName = [
|
|
4630
|
+
"canopy-gallery-item__content",
|
|
4631
|
+
flex ? "canopy-gallery-item__content_flex" : null
|
|
4632
|
+
].filter(Boolean).join(" ");
|
|
4633
|
+
return /* @__PURE__ */ React40.createElement("div", { className: contentClassName }, children);
|
|
4634
|
+
}
|
|
4628
4635
|
function GalleryItem() {
|
|
4629
4636
|
return null;
|
|
4630
4637
|
}
|
|
@@ -4690,6 +4697,7 @@ function Gallery({
|
|
|
4690
4697
|
));
|
|
4691
4698
|
}
|
|
4692
4699
|
Gallery.Item = GalleryItem;
|
|
4700
|
+
Gallery.Content = GalleryContent;
|
|
4693
4701
|
export {
|
|
4694
4702
|
ArticleCard,
|
|
4695
4703
|
Button,
|
|
@@ -4703,6 +4711,7 @@ export {
|
|
|
4703
4711
|
Container,
|
|
4704
4712
|
MarkdownTable as DocsMarkdownTable,
|
|
4705
4713
|
Gallery,
|
|
4714
|
+
GalleryContent,
|
|
4706
4715
|
GalleryItem,
|
|
4707
4716
|
GoogleAnalytics,
|
|
4708
4717
|
Grid,
|