onejs-react 0.1.16 → 0.1.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onejs-react",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "React 19 renderer for OneJS (Unity UI Toolkit)",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -11,6 +11,8 @@ import type {
11
11
  ScrollViewProps,
12
12
  ImageProps,
13
13
  ListViewProps,
14
+ FrostedGlassProps,
15
+ FrostedGlassIntrinsicProps,
14
16
  VisualElement,
15
17
  TextElement,
16
18
  LabelElement,
@@ -20,6 +22,7 @@ import type {
20
22
  SliderElement,
21
23
  ScrollViewElement,
22
24
  ImageElement,
25
+ FrostedGlassElement,
23
26
  } from './types';
24
27
 
25
28
  declare const CS: any
@@ -33,6 +36,10 @@ const _imageCache = new Map<string, any>()
33
36
 
34
37
  function _resolveAssetPath(src: string): string {
35
38
  const Path = CS.System.IO.Path
39
+ // Absolute paths bypass asset resolution entirely
40
+ if (Path.IsPathRooted(src)) {
41
+ return src
42
+ }
36
43
  if (CS.UnityEngine.Application.isEditor) {
37
44
  const workingDir = typeof (globalThis as any).__workingDir === "string"
38
45
  ? (globalThis as any).__workingDir
@@ -95,6 +102,7 @@ declare module 'react/jsx-runtime' {
95
102
  'ojs-scrollview': WithRef<ScrollViewProps, ScrollViewElement>;
96
103
  'ojs-image': WithRef<ImageProps, ImageElement>;
97
104
  'ojs-listview': WithRef<ListViewProps, VisualElement>;
105
+ 'ojs-frostedglass': WithRef<FrostedGlassIntrinsicProps, FrostedGlassElement>;
98
106
  }
99
107
  }
100
108
  }
@@ -113,6 +121,7 @@ declare module 'react' {
113
121
  'ojs-scrollview': WithRef<ScrollViewProps, ScrollViewElement>;
114
122
  'ojs-image': WithRef<ImageProps, ImageElement>;
115
123
  'ojs-listview': WithRef<ListViewProps, VisualElement>;
124
+ 'ojs-frostedglass': WithRef<FrostedGlassIntrinsicProps, FrostedGlassElement>;
116
125
  }
117
126
  }
118
127
  }
@@ -174,6 +183,17 @@ export const ListView = forwardRef<VisualElement, ListViewProps>((props, ref) =>
174
183
  });
175
184
  ListView.displayName = 'ListView';
176
185
 
186
+ export const FrostedGlass = forwardRef<FrostedGlassElement, FrostedGlassProps>(({ blur, tint, ...rest }, ref) => {
187
+ const parsedTint = useMemo(() => {
188
+ if (!tint) return new CS.UnityEngine.Color(1, 1, 1, 0.15)
189
+ const m = tint.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+))?\s*\)/)
190
+ if (m) return new CS.UnityEngine.Color(+m[1] / 255, +m[2] / 255, +m[3] / 255, m[4] != null ? +m[4] : 1)
191
+ return new CS.UnityEngine.Color(1, 1, 1, 0.15)
192
+ }, [tint])
193
+ return <ojs-frostedglass ref={ref} blurRadius={blur ?? 10} tintColor={parsedTint} {...rest} />;
194
+ });
195
+ FrostedGlass.displayName = 'FrostedGlass';
196
+
177
197
  /**
178
198
  * Create a typed React component for a registered custom element.
179
199
  * Use with `registerElement()` to add custom C# VisualElement types to React.
@@ -60,6 +60,7 @@ declare const CS: {
60
60
  };
61
61
  ScaleMode: CSEnum;
62
62
  Rect: new (...args: any[]) => any;
63
+ Color: new (r: number, g: number, b: number, a: number) => any;
63
64
  };
64
65
  OneJS: {
65
66
  GPU: {
@@ -68,6 +69,7 @@ declare const CS: {
68
69
  SetElementBackgroundFromObject: (element: CSObject, obj: CSObject) => void;
69
70
  ClearElementBackgroundImage: (element: CSObject) => void;
70
71
  };
72
+ FrostedGlassElement: new () => CSObject;
71
73
  };
72
74
  };
73
75
  };
@@ -173,6 +175,7 @@ const TYPE_MAP: Record<string, () => CSObject> = {
173
175
  'ojs-scrollview': () => new CS.UnityEngine.UIElements.ScrollView(),
174
176
  'ojs-image': () => new CS.UnityEngine.UIElements.Image(),
175
177
  'ojs-listview': () => new CS.UnityEngine.UIElements.ListView(),
178
+ 'ojs-frostedglass': () => new CS.OneJS.GPU.FrostedGlassElement(),
176
179
  };
177
180
 
178
181
  // Built-in types with specific prop handling in applyComponentProps
@@ -800,6 +803,10 @@ function applyComponentProps(element: CSObject, type: string, props: Record<stri
800
803
  applyScrollViewProps(element as CSScrollView, props);
801
804
  } else if (type === 'ojs-listview') {
802
805
  applyListViewProps(element as CSListView, props);
806
+ } else if (type === 'ojs-frostedglass') {
807
+ const el = element as any;
808
+ if (props.blurRadius !== undefined) el.BlurRadius = props.blurRadius;
809
+ if (props.tintColor !== undefined) el.TintColor = props.tintColor;
803
810
  }
804
811
  }
805
812
 
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export {
10
10
  ScrollView,
11
11
  Image,
12
12
  ListView,
13
+ FrostedGlass,
13
14
  clearImageCache,
14
15
  createComponent,
15
16
  } from './components';
@@ -83,6 +84,7 @@ export type {
83
84
  ScrollViewProps,
84
85
  ImageProps,
85
86
  ListViewProps,
87
+ FrostedGlassProps,
86
88
  // Container type for render()
87
89
  RenderContainer,
88
90
  // Element types for refs
@@ -95,6 +97,7 @@ export type {
95
97
  SliderElement,
96
98
  ScrollViewElement,
97
99
  ImageElement,
100
+ FrostedGlassElement,
98
101
  // Vector drawing types
99
102
  Vector2,
100
103
  Color,
package/src/types.ts CHANGED
@@ -674,6 +674,24 @@ export interface ImageElement extends VisualElement {
674
674
 
675
675
  // ListView uses Unity's virtualization callbacks directly
676
676
  // This is intentionally imperative - ListView manages its own element recycling
677
+ export interface FrostedGlassProps extends BaseProps {
678
+ /** Blur radius in screen pixels. Higher = more blurry. Default: 10. */
679
+ blur?: number;
680
+ /** Tint color overlaid on the blurred background (CSS color string). */
681
+ tint?: string;
682
+ }
683
+
684
+ /** Internal props for the ojs-frostedglass intrinsic element */
685
+ export interface FrostedGlassIntrinsicProps extends BaseProps {
686
+ blurRadius?: number;
687
+ tintColor?: any;
688
+ }
689
+
690
+ export interface FrostedGlassElement extends VisualElement {
691
+ blurRadius: number;
692
+ tintColor: any;
693
+ }
694
+
677
695
  export interface ListViewProps extends BaseProps {
678
696
  // Data source - the array of items to display
679
697
  itemsSource: unknown[];