@reearth/core 0.0.7-alpha.12 → 0.0.7-alpha.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.
package/dist/core.js CHANGED
@@ -1067,11 +1067,6 @@ const useImage = (t) => {
1067
1067
  s(n.current);
1068
1068
  }, c.src = t, n.current = c;
1069
1069
  }, [t]), o;
1070
- }, useCanvas = (t) => {
1071
- const n = useMemo(() => document.createElement("canvas"), []), [o, s] = useState("");
1072
- return useEffect(() => {
1073
- t(n), s(n.toDataURL());
1074
- }, [n, t]), o;
1075
1070
  };
1076
1071
  function useFirstMountState() {
1077
1072
  var t = useRef(!0);
@@ -22696,9 +22691,10 @@ const rangeTypes = {
22696
22691
  modifier: KeyboardEventModifier.SHIFT
22697
22692
  }
22698
22693
  ]
22699
- }, layerIdField = "__reearth_layer_id", defaultImageSize = 50, drawIcon = (t, n, o, s, c = "none", d = !1, h = "rgba(0, 0, 0, 0.7)", p = 3, y = 0, E = 0) => {
22700
- const L = t.getContext("2d");
22701
- !n || !L || (L.save(), t.width = o + p, t.height = s + p, L.shadowBlur = p, L.shadowOffsetX = y, L.shadowOffsetY = E, L.globalCompositeOperation = "source-over", L.clearRect(0, 0, t.width, t.height), L.drawImage(n, (t.width - o) / 2, (t.height - s) / 2, o, s), c === "circle" ? (L.fillStyle = "black", L.globalCompositeOperation = "destination-in", L.arc(o / 2, s / 2, Math.min(o, s) / 2, 0, 2 * Math.PI), L.fill(), d && (L.shadowColor = h, L.globalCompositeOperation = "destination-over", L.fillStyle = "black", L.arc(o / 2, s / 2, Math.min(o, s) / 2, 0, 2 * Math.PI), L.fill())) : d && (L.shadowColor = h, L.globalCompositeOperation = "destination-over", L.fillStyle = "black", L.rect((t.width - o) / 2, (t.height - s) / 2, o, s), L.fill()), L.restore());
22694
+ }, layerIdField = "__reearth_layer_id", defaultImageSize = 50, drawIcon = (t, n, o, s = "none", c = !1, d = "rgba(0, 0, 0, 0.7)", h = 3, p = 0, y = 0) => {
22695
+ const E = document.createElement("canvas"), L = E.getContext("2d");
22696
+ if (!(!t || !L))
22697
+ return L.save(), E.width = n + h, E.height = o + h, L.shadowBlur = h, L.shadowOffsetX = p, L.shadowOffsetY = y, L.globalCompositeOperation = "source-over", L.clearRect(0, 0, E.width, E.height), L.drawImage(t, (E.width - n) / 2, (E.height - o) / 2, n, o), s === "circle" ? (L.fillStyle = "black", L.globalCompositeOperation = "destination-in", L.arc(n / 2, o / 2, Math.min(n, o) / 2, 0, 2 * Math.PI), L.fill(), c && (L.shadowColor = d, L.globalCompositeOperation = "destination-over", L.fillStyle = "black", L.arc(n / 2, o / 2, Math.min(n, o) / 2, 0, 2 * Math.PI), L.fill())) : c && (L.shadowColor = d, L.globalCompositeOperation = "destination-over", L.fillStyle = "black", L.rect((E.width - n) / 2, (E.height - o) / 2, n, o), L.fill()), L.restore(), E.toDataURL();
22702
22698
  }, useIcon = ({
22703
22699
  image: t,
22704
22700
  imageSize: n,
@@ -22709,11 +22705,11 @@ const rangeTypes = {
22709
22705
  shadowOffsetX: h,
22710
22706
  shadowOffsetY: p
22711
22707
  }) => {
22712
- const y = useImage(t), E = y ? typeof n == "number" ? Math.floor(y.width * n) : Math.min(defaultImageSize, y.width) : 0, L = y ? Math.floor(typeof n == "number" ? y.height * n : E / y.width * y.height) : 0, F = useCallback(
22713
- (z) => drawIcon(z, y, E, L, o, s, c, d, h, p),
22708
+ const y = useImage(t), E = y ? typeof n == "number" ? Math.floor(y.width * n) : Math.min(defaultImageSize, y.width) : 0, L = y ? Math.floor(typeof n == "number" ? y.height * n : E / y.width * y.height) : 0;
22709
+ return [useMemo(
22710
+ () => drawIcon(y, E, L, o, s, c, d, h, p),
22714
22711
  [o, L, y, s, d, c, h, p, E]
22715
- );
22716
- return [useCanvas(F), E, L];
22712
+ ) ?? "", E, L];
22717
22713
  }, ho$1 = (t) => ({
22718
22714
  left: HorizontalOrigin$2.LEFT,
22719
22715
  center: HorizontalOrigin$2.CENTER,
@@ -86056,7 +86052,7 @@ function Error$1({ error: t, resetErrorBoundary: n }) {
86056
86052
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { style: { color: "#fff" }, onClick: n, children: "Retry" }) })
86057
86053
  ] });
86058
86054
  }
86059
- const version = "0.0.7-alpha.12", useCoreAPI = ({ viewerProperty: t }) => {
86055
+ const version = "0.0.7-alpha.13", useCoreAPI = ({ viewerProperty: t }) => {
86060
86056
  const n = useRef(t);
86061
86057
  n.current = t;
86062
86058
  const o = useMemo(