@anlyx/ui 0.1.5 → 0.1.6-beta.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.
- package/dist/viewer/ViewerApp.js +20 -3
- package/dist/viewer/workspace/workspace.css +5895 -311
- package/dist/workspace/WorkspaceApp.d.ts +3 -2
- package/dist/workspace/WorkspaceApp.js +848 -125
- package/dist/workspace/workspace.css +5895 -311
- package/package.json +3 -2
package/dist/viewer/ViewerApp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
-
import { projectDataSchema } from "@anlyx/core";
|
|
3
|
+
import { projectDataSchema, projectValidationReportSchema } from "@anlyx/core";
|
|
4
4
|
import { WorkspaceApp } from "../workspace/WorkspaceApp.js";
|
|
5
5
|
export function ViewerApp() {
|
|
6
6
|
const [state, setState] = useState({ status: "loading" });
|
|
@@ -33,15 +33,32 @@ export function ViewerApp() {
|
|
|
33
33
|
if (state.status === "error") {
|
|
34
34
|
return (_jsx(ViewerStateCard, { detail: state.detail, label: "Anlyx project data load failed", status: "error", title: "Failed to load Anlyx project data" }));
|
|
35
35
|
}
|
|
36
|
-
return _jsx(WorkspaceApp, { projectData: state.viewerData.data
|
|
36
|
+
return (_jsx(WorkspaceApp, { projectData: state.viewerData.data, ...(state.viewerData.validationReport
|
|
37
|
+
? { projectValidationReport: state.viewerData.validationReport }
|
|
38
|
+
: {}) }));
|
|
37
39
|
}
|
|
38
40
|
async function fetchViewerData() {
|
|
39
41
|
const projectResponse = await fetch("/api/project-data");
|
|
40
42
|
if (projectResponse.ok) {
|
|
41
|
-
|
|
43
|
+
const validationReport = await fetchValidationReport();
|
|
44
|
+
return {
|
|
45
|
+
kind: "project",
|
|
46
|
+
data: projectDataSchema.parse(await projectResponse.json()),
|
|
47
|
+
...(validationReport ? { validationReport } : {})
|
|
48
|
+
};
|
|
42
49
|
}
|
|
43
50
|
throw new Error(`/api/project-data returned ${projectResponse.status}`);
|
|
44
51
|
}
|
|
52
|
+
async function fetchValidationReport() {
|
|
53
|
+
const response = await fetch("/api/validation-report");
|
|
54
|
+
if (response.status === 404) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
throw new Error(`/api/validation-report returned ${response.status}`);
|
|
59
|
+
}
|
|
60
|
+
return projectValidationReportSchema.parse(await response.json());
|
|
61
|
+
}
|
|
45
62
|
function ViewerStateCard({ detail, label, status, title }) {
|
|
46
63
|
const role = status === "error" ? "alert" : "status";
|
|
47
64
|
return (_jsx("main", { className: `anlyx-viewer-state anlyx-viewer-state--${status}`, children: _jsxs("section", { className: "anlyx-viewer-state__card", role: role, "aria-label": label, children: [_jsx("span", { className: "anlyx-viewer-state__eyebrow", children: status === "error" ? "Viewer waiting for project data" : "Preparing local project" }), _jsx("h1", { children: title }), _jsx("p", { children: detail }), status === "error" ? _jsx("p", { children: "Run `anlyx dev` again, then reload." }) : null] }) }));
|