canvu-react 0.4.38 → 0.4.40

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/native.cjs CHANGED
@@ -2186,6 +2186,11 @@ function rgba(hex, alpha) {
2186
2186
  if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) return hex;
2187
2187
  return `rgba(${r},${g},${b},${alpha})`;
2188
2188
  }
2189
+ function dashIntervalsFromStrokeDasharray2(strokeDasharray) {
2190
+ if (!strokeDasharray) return null;
2191
+ const intervals = strokeDasharray.split(/[\s,]+/).map((part) => Number(part)).filter((part) => Number.isFinite(part) && part > 0);
2192
+ return intervals.length > 0 ? intervals : null;
2193
+ }
2189
2194
  function localBounds(bounds) {
2190
2195
  const b = normalizeRect(bounds);
2191
2196
  return { w: Math.max(0, b.width), h: Math.max(0, b.height) };
@@ -2475,6 +2480,7 @@ function NativeShapeRenderer({ item }) {
2475
2480
  }
2476
2481
  );
2477
2482
  }
2483
+ const intervals = dashIntervalsFromStrokeDasharray2(payload.strokeDasharray);
2478
2484
  return /* @__PURE__ */ jsxRuntime.jsx(
2479
2485
  reactNativeSkia.Path,
2480
2486
  {
@@ -2484,7 +2490,8 @@ function NativeShapeRenderer({ item }) {
2484
2490
  strokeWidth: payload.strokeWidth,
2485
2491
  strokeCap: "round",
2486
2492
  strokeJoin: "round",
2487
- antiAlias: true
2493
+ antiAlias: true,
2494
+ children: intervals ? /* @__PURE__ */ jsxRuntime.jsx(reactNativeSkia.DashPathEffect, { intervals }) : null
2488
2495
  }
2489
2496
  );
2490
2497
  }
@@ -2658,7 +2665,7 @@ function pointsToSmoothPathD(points) {
2658
2665
  const d = smoothFreehandPointsToPathD(points);
2659
2666
  return d || null;
2660
2667
  }
2661
- function dashIntervalsFromStrokeDasharray2(strokeDasharray) {
2668
+ function dashIntervalsFromStrokeDasharray3(strokeDasharray) {
2662
2669
  if (!strokeDasharray) return null;
2663
2670
  const intervals = strokeDasharray.split(/\s+/).map((part) => Number(part)).filter((part) => Number.isFinite(part) && part > 0);
2664
2671
  return intervals.length > 0 ? intervals : null;
@@ -2948,7 +2955,7 @@ function NativeInteractionOverlay({
2948
2955
  );
2949
2956
  }
2950
2957
  if (payload.kind === "strokePath") {
2951
- const intervals = dashIntervalsFromStrokeDasharray2(payload.strokeDasharray);
2958
+ const intervals = dashIntervalsFromStrokeDasharray3(payload.strokeDasharray);
2952
2959
  return /* @__PURE__ */ jsxRuntime.jsx(
2953
2960
  reactNativeSkia.Path,
2954
2961
  {
@@ -4686,6 +4693,8 @@ var MARKER_TOOL_STYLE = {
4686
4693
  strokeWidth: 16,
4687
4694
  strokeOpacity: 0.5
4688
4695
  };
4696
+ var NATIVE_VIEWPORT_OVERLAY_Z_INDEX = 40;
4697
+ var NATIVE_VIEWPORT_OVERLAY_ELEVATION = 40;
4689
4698
  function isPlacementTool(toolId) {
4690
4699
  return toolId === "rect" || toolId === "ellipse" || toolId === "architectural-cloud" || toolId === "line" || toolId === "arrow";
4691
4700
  }
@@ -4769,6 +4778,7 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
4769
4778
  onCameraChange,
4770
4779
  customPlacement,
4771
4780
  customPlacements = [],
4781
+ overlay,
4772
4782
  toolbar,
4773
4783
  showStyleInspector = false,
4774
4784
  styleInspectorPlacement = "bottom"
@@ -5700,153 +5710,161 @@ var NativeVectorViewport = react.forwardRef(function NativeVectorViewport2({
5700
5710
  };
5701
5711
  const normalizedNativeLinkHref = normalizeNativeLinkHref(nativeLinkInputValue);
5702
5712
  const nativeLinkCanSubmit = pendingNativeLinkRequest !== null && normalizedNativeLinkHref !== null && onItemsChange != null;
5703
- return /* @__PURE__ */ jsxRuntime.jsxs(
5704
- reactNative.View,
5705
- {
5706
- style: { flex: 1, overflow: "hidden" },
5707
- onLayout,
5708
- onPointerDown: handlePointerDown,
5709
- onPointerMove: handlePointerMove,
5710
- onPointerUp: handlePointerUp,
5711
- onPointerEnter: handlePointerMove,
5712
- onPointerLeave: () => {
5713
- hideToolCursor();
5714
- notifyWorldPointerLeave();
5715
- },
5716
- ...panResponder.panHandlers,
5717
- children: [
5718
- size.width > 0 && size.height > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5719
- /* @__PURE__ */ jsxRuntime.jsx(
5720
- NativeSceneRenderer,
5713
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { flex: 1, overflow: "hidden" }, onLayout, children: [
5714
+ size.width > 0 && size.height > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5715
+ /* @__PURE__ */ jsxRuntime.jsxs(
5716
+ reactNative.View,
5717
+ {
5718
+ style: reactNative.StyleSheet.absoluteFill,
5719
+ onPointerDown: handlePointerDown,
5720
+ onPointerMove: handlePointerMove,
5721
+ onPointerUp: handlePointerUp,
5722
+ onPointerEnter: handlePointerMove,
5723
+ onPointerLeave: () => {
5724
+ hideToolCursor();
5725
+ notifyWorldPointerLeave();
5726
+ },
5727
+ ...panResponder.panHandlers,
5728
+ children: [
5729
+ /* @__PURE__ */ jsxRuntime.jsx(
5730
+ NativeSceneRenderer,
5731
+ {
5732
+ items: sceneItems,
5733
+ camera,
5734
+ width: size.width,
5735
+ height: size.height
5736
+ }
5737
+ ),
5738
+ interactive && /* @__PURE__ */ jsxRuntime.jsx(
5739
+ NativeInteractionOverlay,
5740
+ {
5741
+ camera,
5742
+ width: size.width,
5743
+ height: size.height,
5744
+ selectedItems,
5745
+ showResizeHandles,
5746
+ placementPreview,
5747
+ laserTrail,
5748
+ eraserTrail,
5749
+ eraserPreviewItems: items.filter(
5750
+ (it) => eraserPreviewIds.includes(it.id)
5751
+ ),
5752
+ previewStrokeStyle: strokeStyleState,
5753
+ remotePresence
5754
+ }
5755
+ )
5756
+ ]
5757
+ }
5758
+ ),
5759
+ overlay ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { pointerEvents: "box-none", style: reactNative.StyleSheet.absoluteFill, children: overlay }) : null,
5760
+ interactive && showStyleInspector && activeStyleToolId ? /* @__PURE__ */ jsxRuntime.jsx(
5761
+ reactNative.View,
5762
+ {
5763
+ pointerEvents: "box-none",
5764
+ style: styleInspectorPlacement === "top-left" ? {
5765
+ position: "absolute",
5766
+ left: 16,
5767
+ top: 104,
5768
+ alignItems: "flex-start",
5769
+ zIndex: NATIVE_VIEWPORT_OVERLAY_Z_INDEX,
5770
+ elevation: NATIVE_VIEWPORT_OVERLAY_ELEVATION
5771
+ } : {
5772
+ position: "absolute",
5773
+ left: 16,
5774
+ right: 16,
5775
+ bottom: 84,
5776
+ alignItems: "center",
5777
+ zIndex: NATIVE_VIEWPORT_OVERLAY_Z_INDEX,
5778
+ elevation: NATIVE_VIEWPORT_OVERLAY_ELEVATION
5779
+ },
5780
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5781
+ NativeVectorStyleInspector,
5721
5782
  {
5722
- items: sceneItems,
5723
- camera,
5724
- width: size.width,
5725
- height: size.height
5783
+ toolId: activeStyleToolId,
5784
+ value: strokeStyleState,
5785
+ onChange: patchCurrentStrokeStyle
5726
5786
  }
5727
- ),
5728
- interactive && /* @__PURE__ */ jsxRuntime.jsx(
5729
- NativeInteractionOverlay,
5787
+ )
5788
+ }
5789
+ ) : null,
5790
+ toolbar && /* @__PURE__ */ jsxRuntime.jsx(
5791
+ reactNative.View,
5792
+ {
5793
+ style: {
5794
+ position: "absolute",
5795
+ bottom: 16,
5796
+ left: 16,
5797
+ right: 16,
5798
+ flexDirection: "row",
5799
+ justifyContent: "center",
5800
+ alignItems: "center",
5801
+ zIndex: NATIVE_VIEWPORT_OVERLAY_Z_INDEX,
5802
+ elevation: NATIVE_VIEWPORT_OVERLAY_ELEVATION
5803
+ },
5804
+ pointerEvents: "box-none",
5805
+ children: toolbar
5806
+ }
5807
+ )
5808
+ ] }),
5809
+ /* @__PURE__ */ jsxRuntime.jsx(
5810
+ reactNative.Modal,
5811
+ {
5812
+ animationType: "fade",
5813
+ transparent: true,
5814
+ visible: pendingNativeLinkRequest !== null,
5815
+ onRequestClose: closeNativeLinkDialog,
5816
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles3.nativeLinkDialogBackdrop, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.nativeLinkDialogCard, children: [
5817
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.nativeLinkDialogTitle, children: nativeLinkDialogLabels.title }),
5818
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.nativeLinkDialogDescription, children: nativeLinkDialogLabels.description }),
5819
+ /* @__PURE__ */ jsxRuntime.jsx(
5820
+ reactNative.TextInput,
5730
5821
  {
5731
- camera,
5732
- width: size.width,
5733
- height: size.height,
5734
- selectedItems,
5735
- showResizeHandles,
5736
- placementPreview,
5737
- laserTrail,
5738
- eraserTrail,
5739
- eraserPreviewItems: items.filter(
5740
- (it) => eraserPreviewIds.includes(it.id)
5741
- ),
5742
- previewStrokeStyle: strokeStyleState,
5743
- remotePresence
5822
+ accessibilityLabel: nativeLinkDialogLabels.title,
5823
+ autoCapitalize: "none",
5824
+ autoCorrect: false,
5825
+ keyboardType: "url",
5826
+ onChangeText: setNativeLinkInputValue,
5827
+ onSubmitEditing: submitNativeLinkDialog,
5828
+ placeholder: nativeLinkDialogLabels.inputPlaceholder,
5829
+ returnKeyType: "done",
5830
+ style: styles3.nativeLinkDialogInput,
5831
+ value: nativeLinkInputValue
5744
5832
  }
5745
5833
  ),
5746
- interactive && showStyleInspector && activeStyleToolId ? /* @__PURE__ */ jsxRuntime.jsx(
5747
- reactNative.View,
5748
- {
5749
- pointerEvents: "box-none",
5750
- style: styleInspectorPlacement === "top-left" ? {
5751
- position: "absolute",
5752
- left: 16,
5753
- top: 104,
5754
- alignItems: "flex-start"
5755
- } : {
5756
- position: "absolute",
5757
- left: 16,
5758
- right: 16,
5759
- bottom: 84,
5760
- alignItems: "center"
5761
- },
5762
- children: /* @__PURE__ */ jsxRuntime.jsx(
5763
- NativeVectorStyleInspector,
5764
- {
5765
- toolId: activeStyleToolId,
5766
- value: strokeStyleState,
5767
- onChange: patchCurrentStrokeStyle
5768
- }
5769
- )
5770
- }
5771
- ) : null,
5772
- toolbar && /* @__PURE__ */ jsxRuntime.jsx(
5773
- reactNative.View,
5774
- {
5775
- style: {
5776
- position: "absolute",
5777
- bottom: 16,
5778
- left: 16,
5779
- right: 16,
5780
- flexDirection: "row",
5781
- justifyContent: "center",
5782
- alignItems: "center"
5783
- },
5784
- pointerEvents: "box-none",
5785
- children: toolbar
5786
- }
5787
- )
5788
- ] }),
5789
- /* @__PURE__ */ jsxRuntime.jsx(
5790
- reactNative.Modal,
5791
- {
5792
- animationType: "fade",
5793
- transparent: true,
5794
- visible: pendingNativeLinkRequest !== null,
5795
- onRequestClose: closeNativeLinkDialog,
5796
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles3.nativeLinkDialogBackdrop, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.nativeLinkDialogCard, children: [
5797
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.nativeLinkDialogTitle, children: nativeLinkDialogLabels.title }),
5798
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.nativeLinkDialogDescription, children: nativeLinkDialogLabels.description }),
5799
- /* @__PURE__ */ jsxRuntime.jsx(
5800
- reactNative.TextInput,
5801
- {
5802
- accessibilityLabel: nativeLinkDialogLabels.title,
5803
- autoCapitalize: "none",
5804
- autoCorrect: false,
5805
- keyboardType: "url",
5806
- onChangeText: setNativeLinkInputValue,
5807
- onSubmitEditing: submitNativeLinkDialog,
5808
- placeholder: nativeLinkDialogLabels.inputPlaceholder,
5809
- returnKeyType: "done",
5810
- style: styles3.nativeLinkDialogInput,
5811
- value: nativeLinkInputValue
5812
- }
5813
- ),
5814
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.nativeLinkDialogActions, children: [
5815
- /* @__PURE__ */ jsxRuntime.jsx(
5816
- reactNative.Pressable,
5817
- {
5818
- accessibilityRole: "button",
5819
- onPress: closeNativeLinkDialog,
5820
- style: ({ pressed }) => [
5821
- styles3.nativeLinkDialogButton,
5822
- pressed ? styles3.nativeLinkDialogButtonPressed : void 0
5823
- ],
5824
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.nativeLinkDialogButtonText, children: nativeLinkDialogLabels.cancelLabel })
5825
- }
5826
- ),
5827
- /* @__PURE__ */ jsxRuntime.jsx(
5828
- reactNative.Pressable,
5829
- {
5830
- accessibilityRole: "button",
5831
- accessibilityState: { disabled: !nativeLinkCanSubmit },
5832
- disabled: !nativeLinkCanSubmit,
5833
- onPress: submitNativeLinkDialog,
5834
- style: ({ pressed }) => [
5835
- styles3.nativeLinkDialogButton,
5836
- styles3.nativeLinkDialogPrimaryButton,
5837
- pressed && nativeLinkCanSubmit ? styles3.nativeLinkDialogPrimaryButtonPressed : void 0,
5838
- !nativeLinkCanSubmit ? styles3.nativeLinkDialogDisabledButton : void 0
5839
- ],
5840
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.nativeLinkDialogPrimaryButtonText, children: nativeLinkDialogLabels.addLabel })
5841
- }
5842
- )
5843
- ] })
5844
- ] }) })
5845
- }
5846
- )
5847
- ]
5848
- }
5849
- );
5834
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.nativeLinkDialogActions, children: [
5835
+ /* @__PURE__ */ jsxRuntime.jsx(
5836
+ reactNative.Pressable,
5837
+ {
5838
+ accessibilityRole: "button",
5839
+ onPress: closeNativeLinkDialog,
5840
+ style: ({ pressed }) => [
5841
+ styles3.nativeLinkDialogButton,
5842
+ pressed ? styles3.nativeLinkDialogButtonPressed : void 0
5843
+ ],
5844
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.nativeLinkDialogButtonText, children: nativeLinkDialogLabels.cancelLabel })
5845
+ }
5846
+ ),
5847
+ /* @__PURE__ */ jsxRuntime.jsx(
5848
+ reactNative.Pressable,
5849
+ {
5850
+ accessibilityRole: "button",
5851
+ accessibilityState: { disabled: !nativeLinkCanSubmit },
5852
+ disabled: !nativeLinkCanSubmit,
5853
+ onPress: submitNativeLinkDialog,
5854
+ style: ({ pressed }) => [
5855
+ styles3.nativeLinkDialogButton,
5856
+ styles3.nativeLinkDialogPrimaryButton,
5857
+ pressed && nativeLinkCanSubmit ? styles3.nativeLinkDialogPrimaryButtonPressed : void 0,
5858
+ !nativeLinkCanSubmit ? styles3.nativeLinkDialogDisabledButton : void 0
5859
+ ],
5860
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.nativeLinkDialogPrimaryButtonText, children: nativeLinkDialogLabels.addLabel })
5861
+ }
5862
+ )
5863
+ ] })
5864
+ ] }) })
5865
+ }
5866
+ )
5867
+ ] });
5850
5868
  });
5851
5869
  var styles3 = reactNative.StyleSheet.create({
5852
5870
  nativeLinkDialogBackdrop: {