@vsreact/core 0.0.23 → 0.0.24

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.
@@ -10,6 +10,8 @@ const hostTypes = {
10
10
  "vs-image": "image",
11
11
  "vs-textinput": "textinput",
12
12
  "vs-native": "native",
13
+ "vs-svg": "svg",
14
+ "vs-svgpath": "svgpath",
13
15
  };
14
16
  const eventPropNames = {
15
17
  onClick: "click",
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import "./runtime";
2
2
  import "./bridge";
3
3
  /** The SDK version — stamp it on support dumps and analytics. */
4
- export declare const VERSION = "0.0.23";
5
- export { View, Text, Image, TextInput, NativeView } from "./primitives";
6
- export type { CommonProps, TextProps, ImageProps, TextInputProps, NativeViewProps, } from "./primitives";
4
+ export declare const VERSION = "0.0.24";
5
+ export { View, Text, Image, TextInput, NativeView, Svg, SvgPath } from "./primitives";
6
+ export type { CommonProps, TextProps, ImageProps, TextInputProps, NativeViewProps, SvgProps, SvgPathProps, } from "./primitives";
7
7
  export { render, unmount } from "./render";
8
8
  export { native } from "./native";
9
9
  export { useNativeEvent, useNativeValue, useDebounced, useThrottled, usePrevious, useToggle, useInterval, useHover, useLayoutRect, } from "./hooks";
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  import "./runtime";
4
4
  import "./bridge";
5
5
  /** The SDK version — stamp it on support dumps and analytics. */
6
- export const VERSION = "0.0.23";
7
- export { View, Text, Image, TextInput, NativeView } from "./primitives";
6
+ export const VERSION = "0.0.24";
7
+ export { View, Text, Image, TextInput, NativeView, Svg, SvgPath } from "./primitives";
8
8
  export { render, unmount } from "./render";
9
9
  export { native } from "./native";
10
10
  export { useNativeEvent, useNativeValue, useDebounced, useThrottled, usePrevious, useToggle, useInterval, useHover, useLayoutRect, } from "./hooks";
@@ -73,6 +73,30 @@ export interface ImageProps extends CommonProps {
73
73
  src: string;
74
74
  }
75
75
  export declare function Image(props: ImageProps): import("react").ReactElement<ImageProps, string | import("react").JSXElementConstructor<any>>;
76
+ export interface SvgProps extends CommonProps {
77
+ /** "minX minY width height" — path coordinates map from this box onto the
78
+ node's layout frame (like the web's preserveAspectRatio="none"). */
79
+ viewBox: string;
80
+ }
81
+ /** Vector container: lays out like a View, paints its <SvgPath> children
82
+ scaled from viewBox space. Icon sets port directly — rename attributes
83
+ and drop each path's `d` in. */
84
+ export declare function Svg(props: SvgProps): import("react").ReactElement<SvgProps, string | import("react").JSXElementConstructor<any>>;
85
+ export interface SvgPathProps {
86
+ /** SVG path data ("M12 2 L22 22 …") — parsed once and cached. */
87
+ d: string;
88
+ /** Fill color; SVG's default black. "none" for stroke-only paths. */
89
+ fill?: string;
90
+ stroke?: string;
91
+ /** Stroke width in viewBox units (scales with the frame, like SVG). */
92
+ strokeWidth?: number;
93
+ strokeCap?: "butt" | "round" | "square";
94
+ strokeJoin?: "miter" | "round" | "bevel";
95
+ /** Dash pattern in viewBox units, e.g. "4 2". */
96
+ strokeDash?: string;
97
+ fillRule?: "nonzero" | "evenodd";
98
+ }
99
+ export declare function SvgPath(props: SvgPathProps): import("react").ReactElement<SvgPathProps, string | import("react").JSXElementConstructor<any>>;
76
100
  export interface TextInputProps extends Omit<CommonProps, "children" | "onChange" | "onSubmit"> {
77
101
  value?: string;
78
102
  defaultValue?: string;
@@ -8,6 +8,15 @@ export function Text(props) {
8
8
  export function Image(props) {
9
9
  return createElement("vs-image", props);
10
10
  }
11
+ /** Vector container: lays out like a View, paints its <SvgPath> children
12
+ scaled from viewBox space. Icon sets port directly — rename attributes
13
+ and drop each path's `d` in. */
14
+ export function Svg(props) {
15
+ return createElement("vs-svg", props);
16
+ }
17
+ export function SvgPath(props) {
18
+ return createElement("vs-svgpath", props);
19
+ }
11
20
  export function TextInput({ onChange, onSubmit, ...rest }) {
12
21
  return createElement("vs-textinput", {
13
22
  ...rest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vsreact/core",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "Write React. Ship native VST. A React renderer for JUCE audio plugins — QuickJS + Yoga + juce::Graphics, no webview.",
5
5
  "keywords": [
6
6
  "react",
package/src/hostConfig.ts CHANGED
@@ -20,6 +20,8 @@ const hostTypes: Record<string, string> = {
20
20
  "vs-image": "image",
21
21
  "vs-textinput": "textinput",
22
22
  "vs-native": "native",
23
+ "vs-svg": "svg",
24
+ "vs-svgpath": "svgpath",
23
25
  };
24
26
 
25
27
  const eventPropNames: Record<string, string> = {
package/src/index.ts CHANGED
@@ -4,15 +4,17 @@ import "./runtime";
4
4
  import "./bridge";
5
5
 
6
6
  /** The SDK version — stamp it on support dumps and analytics. */
7
- export const VERSION = "0.0.23";
7
+ export const VERSION = "0.0.24";
8
8
 
9
- export { View, Text, Image, TextInput, NativeView } from "./primitives";
9
+ export { View, Text, Image, TextInput, NativeView, Svg, SvgPath } from "./primitives";
10
10
  export type {
11
11
  CommonProps,
12
12
  TextProps,
13
13
  ImageProps,
14
14
  TextInputProps,
15
15
  NativeViewProps,
16
+ SvgProps,
17
+ SvgPathProps,
16
18
  } from "./primitives";
17
19
  export { render, unmount } from "./render";
18
20
  export { native } from "./native";
@@ -125,3 +125,26 @@ describe("useNativeValue", () => {
125
125
  expect(seen.at(-1)).toBe(0.8);
126
126
  });
127
127
  });
128
+
129
+ describe("Svg primitives (0.0.24)", () => {
130
+ test("Svg + SvgPath create their node types with data props", async () => {
131
+ const { Svg, SvgPath } = require("./index");
132
+ render(
133
+ <Svg viewBox="0 0 24 24" style={{ width: 24, height: 24 }}>
134
+ <SvgPath d="M12 2 L22 22 L2 22 Z" fill="#ff0000" />
135
+ <SvgPath d="M2 12 H22" fill="none" stroke="#00ff00" strokeWidth={2} strokeDash="4 2" />
136
+ </Svg>,
137
+ );
138
+
139
+ const creates = allOps().filter((op: any) => op[0] === "create");
140
+ expect(creates.some((op: any) => op[2] === "svg")).toBe(true);
141
+ expect(creates.filter((op: any) => op[2] === "svgpath")).toHaveLength(2);
142
+
143
+ const propOps = allOps().filter((op: any) => op[0] === "setProps");
144
+ const svgProps: any = propOps.find((op: any) => op[2]?.viewBox);
145
+ expect(svgProps[2].viewBox).toBe("0 0 24 24");
146
+
147
+ const pathProps: any = propOps.find((op: any) => op[2]?.strokeDash);
148
+ expect(pathProps[2]).toMatchObject({ d: "M2 12 H22", fill: "none", stroke: "#00ff00", strokeWidth: 2 });
149
+ });
150
+ });
@@ -93,6 +93,38 @@ export function Image(props: ImageProps) {
93
93
  return createElement("vs-image", props);
94
94
  }
95
95
 
96
+ export interface SvgProps extends CommonProps {
97
+ /** "minX minY width height" — path coordinates map from this box onto the
98
+ node's layout frame (like the web's preserveAspectRatio="none"). */
99
+ viewBox: string;
100
+ }
101
+
102
+ /** Vector container: lays out like a View, paints its <SvgPath> children
103
+ scaled from viewBox space. Icon sets port directly — rename attributes
104
+ and drop each path's `d` in. */
105
+ export function Svg(props: SvgProps) {
106
+ return createElement("vs-svg", props);
107
+ }
108
+
109
+ export interface SvgPathProps {
110
+ /** SVG path data ("M12 2 L22 22 …") — parsed once and cached. */
111
+ d: string;
112
+ /** Fill color; SVG's default black. "none" for stroke-only paths. */
113
+ fill?: string;
114
+ stroke?: string;
115
+ /** Stroke width in viewBox units (scales with the frame, like SVG). */
116
+ strokeWidth?: number;
117
+ strokeCap?: "butt" | "round" | "square";
118
+ strokeJoin?: "miter" | "round" | "bevel";
119
+ /** Dash pattern in viewBox units, e.g. "4 2". */
120
+ strokeDash?: string;
121
+ fillRule?: "nonzero" | "evenodd";
122
+ }
123
+
124
+ export function SvgPath(props: SvgPathProps) {
125
+ return createElement("vs-svgpath", props);
126
+ }
127
+
96
128
  export interface TextInputProps extends Omit<CommonProps, "children" | "onChange" | "onSubmit"> {
97
129
  value?: string;
98
130
  defaultValue?: string;