@ocelescope/resources 0.1.0 → 0.1.3
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/index.js +7 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,12 +2,11 @@ import { ActionIcon, Alert, Badge, Box, Button, ButtonGroup, Code, Group, Loadin
|
|
|
2
2
|
import { useResource, useResources } from "@ocelescope/api-base";
|
|
3
3
|
import { DownloadIcon, EyeOffIcon, Maximize2Icon, MaximizeIcon, MinusIcon, PlusIcon, XIcon } from "lucide-react";
|
|
4
4
|
import { Graphviz } from "@hpcc-js/wasm-graphviz";
|
|
5
|
-
import
|
|
5
|
+
import FileSaver from "file-saver";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
8
|
import { TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
|
|
8
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Background, BaseEdge, ControlButton, Controls, EdgeLabelRenderer, Handle, Position, ReactFlow, ReactFlowProvider, applyNodeChanges, getBezierPath, getSmoothStepPath, useInternalNode, useNodes, useNodesInitialized, useReactFlow } from "@xyflow/react";
|
|
10
|
-
import "@xyflow/react/dist/style.css";
|
|
11
10
|
import ELK from "elkjs/lib/elk.bundled.js";
|
|
12
11
|
import { toPng, toSvg } from "html-to-image";
|
|
13
12
|
import { jsPDF } from "jspdf";
|
|
@@ -16,6 +15,7 @@ import { DataTable } from "mantine-datatable";
|
|
|
16
15
|
import dayjs from "dayjs";
|
|
17
16
|
import isBetween from "dayjs/plugin/isBetween.js";
|
|
18
17
|
//#region src/components/ResourceView/Viewers/SVG.tsx
|
|
18
|
+
const { saveAs: saveAs$2 } = FileSaver;
|
|
19
19
|
const SvgPanWrapper = ({ children, onDownload }) => {
|
|
20
20
|
return /* @__PURE__ */ jsx(Box, {
|
|
21
21
|
w: "100%",
|
|
@@ -70,7 +70,7 @@ const SvgViewer = ({ visualization, isPreview }) => {
|
|
|
70
70
|
const cleanedSvg = visualization.svg.replace(/width="[^"]+"/, "width=\"100%\"").replace(/height="[^"]+"/, "height=\"100%\"").replace(/<svg(?![^>]*xmlns=)/, "<svg xmlns=\"http://www.w3.org/2000/svg\"");
|
|
71
71
|
const handleDownload = () => {
|
|
72
72
|
if (!cleanedSvg) return;
|
|
73
|
-
saveAs(new Blob([cleanedSvg], { type: "image/svg+xml;charset=utf-8" }), "resource.svg");
|
|
73
|
+
saveAs$2(new Blob([cleanedSvg], { type: "image/svg+xml;charset=utf-8" }), "resource.svg");
|
|
74
74
|
};
|
|
75
75
|
const content = /* @__PURE__ */ jsx("div", {
|
|
76
76
|
style: {
|
|
@@ -87,6 +87,7 @@ const SvgViewer = ({ visualization, isPreview }) => {
|
|
|
87
87
|
};
|
|
88
88
|
//#endregion
|
|
89
89
|
//#region src/components/ResourceView/Viewers/Dot.tsx
|
|
90
|
+
const { saveAs: saveAs$1 } = FileSaver;
|
|
90
91
|
const DotToSvgViewer = ({ isPreview, visualization }) => {
|
|
91
92
|
const [svg, setSvg] = useState(null);
|
|
92
93
|
const [error, setError] = useState(null);
|
|
@@ -115,7 +116,7 @@ const DotToSvgViewer = ({ isPreview, visualization }) => {
|
|
|
115
116
|
}, [svg]);
|
|
116
117
|
const handleDownload = () => {
|
|
117
118
|
if (!cleanedSvg) return;
|
|
118
|
-
saveAs(new Blob([cleanedSvg], { type: "image/svg+xml;charset=utf-8" }), "resource.svg");
|
|
119
|
+
saveAs$1(new Blob([cleanedSvg], { type: "image/svg+xml;charset=utf-8" }), "resource.svg");
|
|
119
120
|
};
|
|
120
121
|
const content = /* @__PURE__ */ jsxs("div", {
|
|
121
122
|
style: {
|
|
@@ -1539,6 +1540,7 @@ function getContentBounds(nodes, viewportEl, getNodesBounds) {
|
|
|
1539
1540
|
}
|
|
1540
1541
|
//#endregion
|
|
1541
1542
|
//#region src/components/ResourceView/Viewers/GraphFlow/utils/download.ts
|
|
1543
|
+
const { saveAs } = FileSaver;
|
|
1542
1544
|
const MAX_PX = 2048;
|
|
1543
1545
|
const EXPORT_PADDING = .05;
|
|
1544
1546
|
function buildCaptureOptions(imageWidth, imageHeight, x, y, zoom) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocelescope/resources",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"description": "Ocelescope resources: helpers and UI components for rendering and exporting data.",
|
|
6
6
|
"author": "Görkem-Emre Öztürk <goerkem.oeztuerk@rwth-aachen.de>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "^19.2.0",
|
|
43
43
|
"react-plotly.js": "^4.0.0",
|
|
44
44
|
"react-zoom-pan-pinch": "^4.0.0",
|
|
45
|
-
"@ocelescope/api-base": "0.1.0"
|
|
45
|
+
"@ocelescope/api-base": "^0.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@tsdown/css": "^0.22.0",
|