@octostar/map-component 0.2.6 → 0.2.8

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.cjs CHANGED
@@ -8,10 +8,9 @@ const turf = require("@turf/turf");
8
8
  const proj4 = require("proj4");
9
9
  const THREE = require("three");
10
10
  const antd = require("antd");
11
- const fileSaver = require("file-saver");
12
- const lucideReact = require("lucide-react");
13
11
  const clsx = require("clsx");
14
12
  const tailwindMerge = require("tailwind-merge");
13
+ const lucideReact = require("lucide-react");
15
14
  const reactDom = require("react-dom");
16
15
  const dateFns = require("date-fns");
17
16
  const zustand = require("zustand");
@@ -388,6 +387,17 @@ function isValidIconValue(value) {
388
387
  function cn(...inputs) {
389
388
  return tailwindMerge.twMerge(clsx.clsx(inputs));
390
389
  }
390
+ function downloadBlob(blob, filename) {
391
+ const url = URL.createObjectURL(blob);
392
+ const anchor = document.createElement("a");
393
+ anchor.href = url;
394
+ anchor.download = filename;
395
+ anchor.rel = "noopener";
396
+ document.body.appendChild(anchor);
397
+ anchor.click();
398
+ anchor.remove();
399
+ setTimeout(() => URL.revokeObjectURL(url), 0);
400
+ }
391
401
  const ToastContext = react.createContext(null);
392
402
  function useToast() {
393
403
  const externalToast = react.useContext(ToastContext);
@@ -11667,7 +11677,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11667
11677
  }
11668
11678
  };
11669
11679
  const blob = new Blob([JSON.stringify(geojson, null, 2)], { type: "application/json" });
11670
- fileSaver.saveAs(blob, `${layer.name.replace(/[^a-z0-9]/gi, "_")}.geojson`);
11680
+ downloadBlob(blob, `${layer.name.replace(/[^a-z0-9]/gi, "_")}.geojson`);
11671
11681
  }, [layers]);
11672
11682
  const handleLoadLayerGeoJSON = react.useCallback((layerId) => {
11673
11683
  const input = fileInputRef.current;
@@ -11744,7 +11754,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11744
11754
  if (!draw.current) return;
11745
11755
  const geojson = buildEnrichedGeoJSON();
11746
11756
  const blob = new Blob([JSON.stringify(geojson, null, 2)], { type: "application/geo+json" });
11747
- fileSaver.saveAs(blob, "map_export.geojson");
11757
+ downloadBlob(blob, "map_export.geojson");
11748
11758
  }, [buildEnrichedGeoJSON]);
11749
11759
  const handleSearchAndAddToNewLayer = react.useCallback(async () => {
11750
11760
  if (!onSearchEngineRequest || !map.current || !draw.current) return;