@treasuryspatial/viewer-react 0.1.11 → 0.1.13
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.
|
@@ -2,7 +2,7 @@ import { type UploadResult } from "@treasuryspatial/viewer-kit";
|
|
|
2
2
|
export type AssetUploadCardProps = {
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
apiRoute?: string;
|
|
5
|
-
|
|
5
|
+
geometryApiRoute?: string;
|
|
6
6
|
maxBytes?: number;
|
|
7
7
|
timeoutMs?: number;
|
|
8
8
|
preview?: Record<string, unknown>;
|
|
@@ -15,5 +15,5 @@ export type AssetUploadCardProps = {
|
|
|
15
15
|
description?: string;
|
|
16
16
|
minimal?: boolean;
|
|
17
17
|
};
|
|
18
|
-
export default function AssetUploadCard({ disabled, apiRoute,
|
|
18
|
+
export default function AssetUploadCard({ disabled, apiRoute, geometryApiRoute, maxBytes, timeoutMs, preview, allowEmptyGeometry, accept, onSolved, onClear, className, title, description, minimal, }: AssetUploadCardProps): import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
//# sourceMappingURL=AssetUploadCard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetUploadCard.d.ts","sourceRoot":"","sources":["../src/AssetUploadCard.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"AssetUploadCard.d.ts","sourceRoot":"","sources":["../src/AssetUploadCard.tsx"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,6BAA6B,CAAC;AAErC,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAUF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,QAAQ,EACR,QAA0B,EAC1B,gBAAsC,EACtC,QAAyC,EACzC,SAA2C,EAC3C,OAAO,EACP,kBAAkB,EAClB,MAAuB,EACvB,QAAQ,EACR,OAAO,EACP,SAAS,EACT,KAAsB,EACtB,WAAsF,EACtF,OAAe,GAChB,EAAE,oBAAoB,2CAgOtB"}
|
package/dist/AssetUploadCard.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useState } from "react";
|
|
3
|
-
import { DEFAULT_UPLOAD_LIMITS, detectUploadKind, loadMeshFile, solveGrasshopperFile,
|
|
3
|
+
import { DEFAULT_UPLOAD_LIMITS, detectUploadKind, ensureGrasshopperGeometry3dm, loadMeshFile, solveGrasshopperFile, solveGeometry3dmFile, } from "@treasuryspatial/viewer-kit";
|
|
4
4
|
const DEFAULT_ACCEPT = ".gh,.ghx,.3dm,.obj,.fbx,.gltf,.glb,.stl,.ply";
|
|
5
5
|
const formatBytes = (bytes) => {
|
|
6
6
|
if (!Number.isFinite(bytes))
|
|
@@ -8,7 +8,7 @@ const formatBytes = (bytes) => {
|
|
|
8
8
|
const mb = bytes / (1024 * 1024);
|
|
9
9
|
return `${mb.toFixed(0)}MB`;
|
|
10
10
|
};
|
|
11
|
-
export default function AssetUploadCard({ disabled, apiRoute = "/api/gh-solve",
|
|
11
|
+
export default function AssetUploadCard({ disabled, apiRoute = "/api/gh-solve", geometryApiRoute = "/api/geometry-3dm", maxBytes = DEFAULT_UPLOAD_LIMITS.maxBytes, timeoutMs = DEFAULT_UPLOAD_LIMITS.timeoutMs, preview, allowEmptyGeometry, accept = DEFAULT_ACCEPT, onSolved, onClear, className, title = "Asset Upload", description = "Upload .gh/.ghx/.3dm or mesh assets (OBJ/FBX/GLTF/STL/PLY) to preview.", minimal = false, }) {
|
|
12
12
|
const [busy, setBusy] = useState(false);
|
|
13
13
|
const [lastFileName, setLastFileName] = useState(null);
|
|
14
14
|
const [error, setError] = useState(null);
|
|
@@ -46,11 +46,12 @@ export default function AssetUploadCard({ disabled, apiRoute = "/api/gh-solve",
|
|
|
46
46
|
allowEmptyGeometry,
|
|
47
47
|
onStatus: (detail) => updateStatus(file.name, detail),
|
|
48
48
|
});
|
|
49
|
-
|
|
49
|
+
const normalized = await ensureGrasshopperGeometry3dm(solved, { allowEmptyGeometry });
|
|
50
|
+
result = { ...normalized, file };
|
|
50
51
|
}
|
|
51
52
|
else if (kind === "3dm") {
|
|
52
|
-
const solved = await
|
|
53
|
-
apiRoute:
|
|
53
|
+
const solved = await solveGeometry3dmFile(file, {
|
|
54
|
+
apiRoute: geometryApiRoute,
|
|
54
55
|
onStatus: (detail) => updateStatus(file.name, detail),
|
|
55
56
|
});
|
|
56
57
|
result = { ...solved, file };
|
|
@@ -122,7 +123,7 @@ export default function AssetUploadCard({ disabled, apiRoute = "/api/gh-solve",
|
|
|
122
123
|
letterSpacing: "0.04em",
|
|
123
124
|
color: hovered ? "rgb(49, 143, 78)" : "#7b8794",
|
|
124
125
|
opacity: hovered ? 0.95 : 0.65,
|
|
125
|
-
}, children: typesLabel }), showStatusLine ? (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", fontSize: "11px", opacity: 0.7 }, children: [_jsxs("span", { style: { display: "inline-flex", gap: "4px" }, children: [_jsx("span", { className: "upload-dot" }), _jsx("span", { className: "upload-dot" }), _jsx("span", { className: "upload-dot" })] }), _jsx("span", { style: { textTransform: "lowercase" }, children: error ? `error: ${error}` : statusText })] })) : null] })) : (_jsxs(_Fragment, { children: [_jsx("div", { style: { fontSize: "13px", fontWeight: 600, color: "#0f172a" }, children: lastFileName ? `Loaded ${lastFileName}` : "Drop a file to upload" }), _jsx("div", { style: { marginTop: "6px", fontSize: "12px", color: "#64748b" }, children: ".gh \u00B7 .ghx \u00B7 .3dm \u00B7 OBJ \u00B7 FBX \u00B7 GLTF \u00B7 STL \u00B7 PLY" }), _jsx("div", { style: { marginTop: "8px", fontSize: "11px", opacity: 0.7, textTransform: "lowercase" }, children: statusText })] })), error ? (_jsx("div", { style: { marginTop: "6px", fontSize: "11px", color: "#b91c1c" }, children: error })) : null] }), _jsx("style", { children: `
|
|
126
|
+
}, children: typesLabel }), showStatusLine ? (_jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", fontSize: "11px", opacity: 0.7 }, children: [busy ? (_jsxs("span", { style: { display: "inline-flex", gap: "4px" }, children: [_jsx("span", { className: "upload-dot" }), _jsx("span", { className: "upload-dot" }), _jsx("span", { className: "upload-dot" })] })) : null, _jsx("span", { style: { textTransform: "lowercase" }, children: error ? `error: ${error}` : statusText })] })) : null] })) : (_jsxs(_Fragment, { children: [_jsx("div", { style: { fontSize: "13px", fontWeight: 600, color: "#0f172a" }, children: lastFileName ? `Loaded ${lastFileName}` : "Drop a file to upload" }), _jsx("div", { style: { marginTop: "6px", fontSize: "12px", color: "#64748b" }, children: ".gh \u00B7 .ghx \u00B7 .3dm \u00B7 OBJ \u00B7 FBX \u00B7 GLTF \u00B7 STL \u00B7 PLY" }), _jsx("div", { style: { marginTop: "8px", fontSize: "11px", opacity: 0.7, textTransform: "lowercase" }, children: statusText })] })), error ? (_jsx("div", { style: { marginTop: "6px", fontSize: "11px", color: "#b91c1c" }, children: error })) : null] }), _jsx("style", { children: `
|
|
126
127
|
.upload-dot {
|
|
127
128
|
width: 5px;
|
|
128
129
|
height: 5px;
|