@reactunity/renderer 0.13.1 → 0.13.2

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.
@@ -1,6 +1,6 @@
1
1
  //
2
2
  // Types in assemblies: ReactUnity, ReactUnity.Editor, ReactUnity.UGUI, ReactUnity.UIToolkit
3
- // Generated 06/08/2022 14:34:11
3
+ // Generated 07/10/2022 21:33:26
4
4
  //
5
5
  /* eslint-disable */
6
6
  export {};
@@ -11,6 +11,7 @@ export declare type ObjectFit = 'fill' | 'contain' | 'cover' | 'none' | 'scale-d
11
11
  export declare type BackgroundBlendMode = 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
12
12
  export declare type CursorType = 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'all-scroll' | 'zoom-in' | 'zoom-out' | 'grab' | 'grabbing';
13
13
  export declare type TextAlign = 'top-left' | 'top' | 'top-right' | 'top-justified' | 'top-flush' | 'top-geo-aligned' | 'left' | 'center' | 'right' | 'justified' | 'flush' | 'center-geo-aligned' | 'bottom-left' | 'bottom' | 'bottom-right' | 'bottom-justified' | 'bottom-flush' | 'bottom-geo-aligned' | 'baseline-left' | 'baseline' | 'baseline-right' | 'baseline-justified' | 'baseline-flush' | 'baseline-geo-aligned' | 'midline-left' | 'midline' | 'midline-right' | 'midline-justified' | 'midline-flush' | 'midline-geo-aligned' | 'capline-left' | 'capline' | 'capline-right' | 'capline-justified' | 'capline-flush' | 'capline-geo-aligned' | 'converted';
14
+ export declare type VerticalAlign = 'top' | 'middle' | 'bottom' | 'baseline' | 'geometry' | 'capline';
14
15
  export declare type TimingFunctionType = 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'step-start' | 'step-end';
15
16
  export declare type AnimationFillMode = 'none' | 'both' | 'forwards' | 'backwards';
16
17
  export declare type AnimationDirection = 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
@@ -1,9 +1,10 @@
1
- import { AnimationDirection, AnimationFillMode, AnimationPlayState, Appearance, BackgroundBlendMode, BackgroundSize, CursorType, FontStyles, FontWeight, NavigationMode, ObjectFit, PointerEvents, TextAlign, TextOverflowModes, TextTransform, TimingFunctionType, Visibility, WhiteSpace } from './styles-enums';
1
+ import { AnimationDirection, AnimationFillMode, AnimationPlayState, Appearance, BackgroundBlendMode, BackgroundSize, CursorType, FontStyles, FontWeight, NavigationMode, ObjectFit, PointerEvents, TextAlign, TextOverflowModes, TextTransform, TimingFunctionType, VerticalAlign, Visibility, WhiteSpace } from './styles-enums';
2
2
  import { Array2Aux, AssetReference, AssetReferenceOrHttp, ColorAux, NumberAux, Vector2Aux, Vector3Aux } from './values';
3
3
  import { YogaValue2Aux, YogaValueAux } from './yoga';
4
4
  export interface RenderStyle {
5
5
  opacity?: NumberAux;
6
6
  zIndex?: number | string;
7
+ sortingLayer?: number | string;
7
8
  order?: number | string;
8
9
  visibility?: Visibility | boolean;
9
10
  cursor?: CursorType | string;
@@ -52,6 +53,7 @@ export interface RenderStyle {
52
53
  fontSize?: YogaValueAux;
53
54
  textOverflow?: TextOverflowModes;
54
55
  textAlign?: TextAlign;
56
+ verticalAlign?: VerticalAlign;
55
57
  whiteSpace?: WhiteSpace;
56
58
  textStrokeWidth?: NumberAux;
57
59
  textStrokeColor?: ColorAux;
@@ -4,7 +4,6 @@ export declare type YogaValueAux = 'auto' | string | number | null | undefined |
4
4
  export declare type YogaValue2Aux = Array2Aux<YogaValueAux> | PositioningLiteral;
5
5
  export declare type YogaValue4Aux = Array4Aux<YogaValueAux>;
6
6
  export interface Layout {
7
- data?: Record<string, unknown>;
8
7
  overflow?: Overflow;
9
8
  styleDirection?: Direction;
10
9
  display?: Display;
@@ -1,12 +1,9 @@
1
1
  import { BaseCmpProps, ContentSrcProps } from '../base';
2
2
  import { ReactUnity, UnityEngine } from '../generated';
3
- import { Style } from '../properties';
4
3
  import { AssetReference, AssetReferenceOrHttp } from '../properties/values';
5
4
  import { ActionCallback, Events } from './events';
6
5
  export interface View<T = ReactUnity.UGUI.UGUIComponent> extends Events<T>, BaseCmpProps {
7
6
  active?: boolean;
8
- style?: Style | string;
9
- data?: Record<string, any>;
10
7
  eventViewport?: UnityEngine.RectTransform | UnityEngine.GameObject | ReactUnity.UGUI.UGUIComponent;
11
8
  }
12
9
  export interface Text extends View<ReactUnity.UGUI.TextComponent> {
@@ -66,7 +63,7 @@ export interface Render<T = ReactUnity.UGUI.RenderComponent> extends BaseImage<T
66
63
  onUnmount?: (camera: UnityEngine.Camera, sender: T) => void;
67
64
  }
68
65
  export interface Object extends Render<ReactUnity.UGUI.ObjectComponent> {
69
- target: UnityEngine.GameObject;
66
+ target?: UnityEngine.GameObject;
70
67
  }
71
68
  export interface Prefab<T = ReactUnity.UGUI.PrefabComponent> extends View<T> {
72
69
  target?: UnityEngine.GameObject | UnityEngine.Component;
@@ -13,7 +13,9 @@ declare type ApplyUpdatesParams = {
13
13
  e?: BatchUpdateCallbacks;
14
14
  o?: BatchUpdateCallbacks;
15
15
  };
16
- export declare type CreateInstanceCommand = ['c', ApplyUpdatesParams];
16
+ export declare type CreateInstanceCommand = ['c', ApplyUpdatesParams & {
17
+ k?: string;
18
+ }];
17
19
  export declare type CreateTextInstanceCommand = ['t', {
18
20
  r: number;
19
21
  c?: string;
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import * as Reconciler from 'react-reconciler';
13
- import { commonReconciler, getAllowedProps, textTypes } from '../constants';
13
+ import { commonReconciler, getAllowedProps, stringizePoolKey, textTypes } from '../constants';
14
14
  import { diffProperties } from '../diffing';
15
15
  import { subContextRenderers } from '../subcontexts';
16
16
  import { callbacksRepo, convertPropsToSerializable, objectsRepo } from './serializer';
@@ -96,7 +96,7 @@ var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext:
96
96
  var aProps = getAllowedProps(props, type);
97
97
  if (ctx.type === 'native') {
98
98
  refId++;
99
- ctx.commands.push(['c', __assign({ t: type, r: refId }, convertPropsToSerializable(aProps))]);
99
+ ctx.commands.push(['c', __assign({ t: type, r: refId, k: stringizePoolKey(props.pool) }, convertPropsToSerializable(aProps))]);
100
100
  if (rootContainer.fiberCache)
101
101
  rootContainer.fiberCache.setObject(refId, internalHandle);
102
102
  var res = __assign(__assign({}, ctx), { refId: refId });
@@ -1,3 +1,4 @@
1
+ import { PoolKey } from '../models/base';
1
2
  export declare const hideClass = "react-unity__renderer__hidden";
2
3
  export declare const eventPriorities: {
3
4
  discrete: number;
@@ -11,6 +12,7 @@ export declare const textTypes: {
11
12
  style: boolean;
12
13
  script: boolean;
13
14
  };
15
+ export declare function stringizePoolKey(key: PoolKey): string;
14
16
  export declare function getAllowedProps(props: any, type: any): any;
15
17
  export declare const commonReconciler: {
16
18
  now: () => number;
@@ -24,8 +24,17 @@ export var textTypes = {
24
24
  style: true,
25
25
  script: true,
26
26
  };
27
+ export function stringizePoolKey(key) {
28
+ switch (typeof key) {
29
+ case 'string': return key;
30
+ case 'boolean': return key ? 'default' : '';
31
+ case 'number': return key.toString();
32
+ case 'undefined': return null;
33
+ default: return '';
34
+ }
35
+ }
27
36
  export function getAllowedProps(props, type) {
28
- var children = props.children, tag = props.tag, rest = __rest(props, ["children", "tag"]);
37
+ var children = props.children, tag = props.tag, pool = props.pool, rest = __rest(props, ["children", "tag", "pool"]);
29
38
  if (textTypes[type] && 'children' in props) {
30
39
  rest.children = (!children || typeof children === 'boolean') ? null : Array.isArray(children) ? children.join('') : children + '';
31
40
  }
@@ -1,4 +1,9 @@
1
1
  export var styleStringSymbol = '__style_as_string__';
2
+ var propDepths = {
3
+ style: 1,
4
+ data: 1,
5
+ custom: 1,
6
+ };
2
7
  export function diffProperties(lastProps, nextProps, deepDiffing) {
3
8
  if (deepDiffing === void 0) { deepDiffing = 0; }
4
9
  if (lastProps === nextProps)
@@ -18,7 +23,7 @@ export function diffProperties(lastProps, nextProps, deepDiffing) {
18
23
  (updatePayload = updatePayload || {})[styleStringSymbol] = null;
19
24
  }
20
25
  else {
21
- var depth = deepDiffing > 0 ? deepDiffing : propKey === 'style' ? 1 : 0;
26
+ var depth = deepDiffing > 0 ? deepDiffing : (propDepths[propKey] || 0);
22
27
  if (depth > 0) {
23
28
  prop = diffProperties(lastProps[propKey], {}, depth - 1);
24
29
  if (!prop)
@@ -64,10 +69,13 @@ export function diffProperties(lastProps, nextProps, deepDiffing) {
64
69
  }
65
70
  }
66
71
  }
67
- if (deepDiffing > 0) {
68
- prop = diffProperties(lastProp, nextProp, deepDiffing - 1);
69
- if (!prop)
70
- continue;
72
+ else {
73
+ var depth = deepDiffing > 0 ? deepDiffing : (propDepths[propKey] || 0);
74
+ if (depth > 0) {
75
+ prop = diffProperties(lastProp, nextProp, depth - 1);
76
+ if (!prop)
77
+ continue;
78
+ }
71
79
  }
72
80
  (updatePayload = updatePayload || {})[propKey] = prop;
73
81
  }
@@ -11,8 +11,9 @@ export var Renderer = {
11
11
  render: function (element, options) {
12
12
  if (options === void 0) { options = {}; }
13
13
  var hostContainer = (options === null || options === void 0 ? void 0 : options.hostContainer) || HostContainer;
14
+ var cacheKey = hostContainer.InstanceId >= 0 ? hostContainer.InstanceId : hostContainer;
14
15
  var isAsync = !(options === null || options === void 0 ? void 0 : options.disableBatchRendering);
15
- var _a = containerMap.get(hostContainer) || {}, hostRoot = _a.hostRoot, asyncJobCallback = _a.asyncJobCallback;
16
+ var _a = containerMap.get(cacheKey) || {}, hostRoot = _a.hostRoot, asyncJobCallback = _a.asyncJobCallback;
16
17
  var findFiberByHostInstance = function () { return null; };
17
18
  if (!hostRoot) {
18
19
  var mode = (options === null || options === void 0 ? void 0 : options.mode) === 'legacy' ? LegacyRoot : ConcurrentRoot;
@@ -57,7 +58,7 @@ export var Renderer = {
57
58
  else {
58
59
  hostRoot = syncReconciler.createContainer(hostContainer, mode, null, false, undefined, '', function (error) { return console.error(error); }, null);
59
60
  }
60
- containerMap.set(hostContainer, { hostRoot: hostRoot, asyncJobCallback: asyncJobCallback });
61
+ containerMap.set(cacheKey, { hostRoot: hostRoot, asyncJobCallback: asyncJobCallback });
61
62
  }
62
63
  var shouldWrapWithHelpers = !(options === null || options === void 0 ? void 0 : options.disableHelpers);
63
64
  if (shouldWrapWithHelpers) {
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import * as Reconciler from 'react-reconciler';
13
- import { commonReconciler, getAllowedProps, hideClass, textTypes } from '../constants';
13
+ import { commonReconciler, getAllowedProps, hideClass, stringizePoolKey, textTypes } from '../constants';
14
14
  import { diffProperties } from '../diffing';
15
15
  var hostContext = {};
16
16
  var childContext = {};
@@ -18,7 +18,7 @@ var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext:
18
18
  var aProps = getAllowedProps(props, type);
19
19
  var children = aProps.children || null;
20
20
  delete aProps.children;
21
- return UnityBridge.createElement(props.tag || type, children, rootContainerInstance, aProps);
21
+ return UnityBridge.createElement(props.tag || type, children, rootContainerInstance, aProps, stringizePoolKey(props.pool));
22
22
  }, createTextInstance: function (text, rootContainerInstance) {
23
23
  return UnityBridge.createText(text, rootContainerInstance);
24
24
  }, appendInitialChild: function (parent, child) { UnityBridge.appendChild(parent, child); }, finalizeInitialChildren: function () { return false; }, commitMount: function () { }, shouldSetTextContent: function (type) { return textTypes[type]; },
@@ -1 +1 @@
1
- export declare const version = "0.13.1";
1
+ export declare const version = "0.13.2";
@@ -1 +1 @@
1
- export var version = '0.13.1';
1
+ export var version = '0.13.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactunity/renderer",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "description": "React renderer for Unity3D",
5
5
  "types": "dist/index.d.ts",
6
6
  "typings": "dist/index.d.ts",
@@ -64,6 +64,6 @@
64
64
  "@reactunity/scripts": "^0.13.0",
65
65
  "@types/react-reconciler": "^0.28.0",
66
66
  "rimraf": "^3.0.2",
67
- "typescript": "^4.7.4"
67
+ "typescript": "^4.8.3"
68
68
  }
69
69
  }