@reactunity/renderer 0.6.0 → 0.9.0

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.
Files changed (100) hide show
  1. package/dist/editor.d.ts +1 -1
  2. package/dist/editor.js +1 -1
  3. package/dist/index.d.ts +5 -5
  4. package/dist/index.js +5 -5
  5. package/dist/src/helpers/dictionary-watcher.d.ts +1 -1
  6. package/dist/src/helpers/dictionary-watcher.js +2 -2
  7. package/dist/src/helpers/watcher.d.ts +2 -0
  8. package/dist/src/helpers/watcher.js +15 -0
  9. package/dist/{models → src/models}/base.d.ts +24 -5
  10. package/dist/{models/ugui/events.js → src/models/base.js} +0 -0
  11. package/dist/{models → src/models}/editor/components.d.ts +0 -0
  12. package/dist/{models → src/models}/editor/components.js +0 -0
  13. package/dist/{models → src/models}/editor/environment.d.ts +0 -0
  14. package/dist/{models → src/models}/editor/environment.js +0 -0
  15. package/dist/{models → src/models}/editor/events.d.ts +0 -0
  16. package/dist/{models → src/models}/editor/events.js +0 -0
  17. package/dist/{models → src/models}/editor/index.d.ts +0 -0
  18. package/dist/{models → src/models}/editor/index.js +0 -0
  19. package/dist/{models → src/models}/editor/jsx.d.ts +2 -4
  20. package/dist/{models → src/models}/editor/jsx.js +0 -0
  21. package/dist/src/models/environment/index.d.ts +41 -0
  22. package/dist/src/models/environment/index.js +1 -0
  23. package/dist/{models → src/models/environment}/interop.d.ts +2 -2
  24. package/dist/{models → src/models/environment}/interop.js +0 -0
  25. package/dist/{models → src/models}/generated/editor.d.ts +0 -0
  26. package/dist/src/models/generated/editor.js +6 -0
  27. package/dist/{models → src/models}/generated/index.d.ts +0 -0
  28. package/dist/{models → src/models}/generated/index.js +0 -0
  29. package/dist/{models → src/models}/generated/react.d.ts +3386 -2470
  30. package/dist/src/models/generated/react.js +6 -0
  31. package/dist/{models → src/models}/generated/system.d.ts +0 -0
  32. package/dist/{models → src/models}/generated/system.js +1 -0
  33. package/dist/{models → src/models}/generated/tests.d.ts +0 -0
  34. package/dist/src/models/generated/tests.js +6 -0
  35. package/dist/{models → src/models}/generated/unity.d.ts +0 -0
  36. package/dist/src/models/generated/unity.js +6 -0
  37. package/dist/{models → src/models}/generated/yoga.d.ts +0 -0
  38. package/dist/src/models/generated/yoga.js +6 -0
  39. package/dist/{models → src/models}/properties/colors.d.ts +0 -0
  40. package/dist/{models → src/models}/properties/colors.js +0 -0
  41. package/dist/{models → src/models}/properties/index.d.ts +0 -0
  42. package/dist/{models → src/models}/properties/index.js +0 -0
  43. package/dist/{models → src/models}/properties/style.d.ts +0 -0
  44. package/dist/{models → src/models}/properties/style.js +0 -0
  45. package/dist/{models → src/models}/properties/styles-enums.d.ts +2 -0
  46. package/dist/{models → src/models}/properties/styles-enums.js +0 -0
  47. package/dist/{models → src/models}/properties/styles.d.ts +28 -7
  48. package/dist/{models → src/models}/properties/styles.js +0 -0
  49. package/dist/{models → src/models}/properties/values.d.ts +0 -0
  50. package/dist/{models → src/models}/properties/values.js +0 -0
  51. package/dist/{models → src/models}/properties/yoga-enums.d.ts +0 -0
  52. package/dist/{models → src/models}/properties/yoga-enums.js +0 -0
  53. package/dist/{models → src/models}/properties/yoga.d.ts +0 -0
  54. package/dist/{models/generated → src/models/properties}/yoga.js +0 -0
  55. package/dist/{models → src/models}/renderer.d.ts +0 -0
  56. package/dist/{models → src/models}/renderer.js +0 -0
  57. package/dist/src/models/tests/index.d.ts +12 -0
  58. package/dist/{models → src/models}/tests/index.js +0 -0
  59. package/dist/{models → src/models}/ugui/components.d.ts +3 -5
  60. package/dist/{models → src/models}/ugui/components.js +0 -0
  61. package/dist/{models → src/models}/ugui/events.d.ts +0 -0
  62. package/dist/src/models/ugui/events.js +2 -0
  63. package/dist/{models → src/models}/ugui/index.d.ts +0 -0
  64. package/dist/{models → src/models}/ugui/index.js +0 -0
  65. package/dist/{models → src/models}/ugui/input.d.ts +0 -0
  66. package/dist/{models → src/models}/ugui/input.js +0 -0
  67. package/dist/{models → src/models}/ugui/jsx.d.ts +2 -4
  68. package/dist/{models → src/models}/ugui/jsx.js +0 -0
  69. package/dist/{models → src/models}/uitoolkit/components.d.ts +3 -5
  70. package/dist/{models → src/models}/uitoolkit/components.js +0 -0
  71. package/dist/{models → src/models}/uitoolkit/events.d.ts +0 -0
  72. package/dist/{models → src/models}/uitoolkit/events.js +0 -0
  73. package/dist/{models → src/models}/uitoolkit/index.d.ts +0 -0
  74. package/dist/{models → src/models}/uitoolkit/index.js +0 -0
  75. package/dist/{models → src/models}/uitoolkit/jsx.d.ts +2 -4
  76. package/dist/{models → src/models}/uitoolkit/jsx.js +0 -0
  77. package/dist/src/renderer/diffing.d.ts +3 -2
  78. package/dist/src/renderer/diffing.js +11 -6
  79. package/dist/src/renderer/renderer.d.ts +1 -1
  80. package/dist/src/renderer/renderer.js +42 -102
  81. package/dist/tests.d.ts +1 -1
  82. package/dist/tests.js +1 -1
  83. package/dist/ugui.d.ts +1 -1
  84. package/dist/ugui.js +1 -1
  85. package/dist/uitoolkit.d.ts +1 -1
  86. package/dist/uitoolkit.js +1 -1
  87. package/editor.ts +1 -1
  88. package/package.json +5 -8
  89. package/tests.ts +1 -1
  90. package/ugui.ts +1 -1
  91. package/uitoolkit.ts +1 -1
  92. package/dist/models/base.js +0 -1
  93. package/dist/models/environment.d.ts +0 -30
  94. package/dist/models/environment.js +0 -1
  95. package/dist/models/generated/editor.js +0 -1
  96. package/dist/models/generated/react.js +0 -1
  97. package/dist/models/generated/tests.js +0 -1
  98. package/dist/models/generated/unity.js +0 -1
  99. package/dist/models/properties/yoga.js +0 -1
  100. package/dist/models/tests/index.d.ts +0 -12
@@ -0,0 +1,6 @@
1
+ //
2
+ // Types in assemblies: ReactUnity, ReactUnity.Editor, ReactUnity.UGUI, ReactUnity.UIToolkit
3
+ // Generated 15/01/2022 01:23:51
4
+ //
5
+ /* eslint-disable */
6
+ export {};
@@ -2,4 +2,5 @@
2
2
  // Types in assemblies: mscorlib, mscorlib, System.Core, System, mscorlib, System, mscorlib
3
3
  // Generated 11/07/2021 17:47:28
4
4
  //
5
+ /* eslint-disable */
5
6
  export {};
File without changes
@@ -0,0 +1,6 @@
1
+ //
2
+ // Types in assemblies: nunit.framework
3
+ // Generated 11/07/2021 17:47:35
4
+ //
5
+ /* eslint-disable */
6
+ export {};
File without changes
@@ -0,0 +1,6 @@
1
+ //
2
+ // Types in assemblies: UnityEngine.CoreModule, UnityEngine.VideoModule, UnityEngine.AudioModule, UnityEngine.UIModule, UnityEngine.UI, UnityEngine.TextRenderingModule, UnityEngine.AnimationModule, UnityEngine.IMGUIModule, UnityEngine.AssetBundleModule, UnityEngine.UnityAnalyticsModule, UnityEngine.UIElementsModule, UnityEngine.AIModule, UnityEngine.TestRunner, UnityEngine.TextCoreFontEngineModule, UnityEngine.TextCoreTextEngineModule, UnityEngine.XRModule, UnityEngine.PhysicsModule, UnityEngine.InputLegacyModule, UnityEngine.UI, Unity.InputSystem, Unity.InputSystem
3
+ // Generated 11/07/2021 17:46:37
4
+ //
5
+ /* eslint-disable */
6
+ export {};
File without changes
@@ -0,0 +1,6 @@
1
+ //
2
+ // Types in assemblies: Facebook.Yoga
3
+ // Generated 18/09/2021 23:11:55
4
+ //
5
+ /* eslint-disable */
6
+ export {};
File without changes
File without changes
File without changes
@@ -1,5 +1,6 @@
1
1
  export declare type FontWeight = 'thin' | 100 | 'extra-light' | 200 | 'light' | 300 | 'regular' | 400 | 'medium' | 500 | 'semi-bold' | 600 | 'bold' | 700 | 'heavy' | 800 | 'black' | 900;
2
2
  export declare type FontStyles = 'normal' | 'bold' | 'italic' | 'underline' | 'lowercase' | 'uppercase' | 'smallcaps' | 'strikethrough' | 'superscript' | 'subscript' | 'highlight';
3
+ export declare type TextTransform = 'none' | 'lowercase' | 'uppercase' | 'smallcaps' | 'capitalize';
3
4
  export declare type TextOverflowModes = 'overflow' | 'ellipsis' | 'masking' | 'truncate' | 'scroll-rect' | 'page' | 'linked';
4
5
  export declare type PointerEvents = 'auto' | 'visible' | 'all' | 'none';
5
6
  export declare type Visibility = 'visible' | 'hidden';
@@ -14,3 +15,4 @@ export declare type TimingFunctionType = 'ease' | 'linear' | 'ease-in' | 'ease-o
14
15
  export declare type AnimationFillMode = 'none' | 'both' | 'forwards' | 'backwards';
15
16
  export declare type AnimationDirection = 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
16
17
  export declare type AnimationPlayState = 'running' | 'paused';
18
+ export declare type BackgroundSize = 'cover' | 'contain';
@@ -1,9 +1,10 @@
1
- import { AnimationDirection, AnimationFillMode, AnimationPlayState, Appearance, BackgroundBlendMode, CursorType, FontStyles, FontWeight, NavigationMode, ObjectFit, PointerEvents, TextAlign, TextOverflowModes, TimingFunctionType, Visibility, WhiteSpace } from './styles-enums';
1
+ import { AnimationDirection, AnimationFillMode, AnimationPlayState, Appearance, BackgroundBlendMode, BackgroundSize, CursorType, FontStyles, FontWeight, NavigationMode, ObjectFit, PointerEvents, TextAlign, TextOverflowModes, TextTransform, TimingFunctionType, Visibility, WhiteSpace } from './styles-enums';
2
2
  import { AssetReference, ColorAux, NumberAux, Vector2Aux, Vector3Aux } from './values';
3
3
  import { YogaValue2Aux, YogaValueAux } from './yoga';
4
4
  export interface RenderStyle {
5
5
  opacity?: NumberAux;
6
- zIndex?: number;
6
+ zIndex?: number | string;
7
+ order?: number | string;
7
8
  visibility?: Visibility | boolean;
8
9
  cursor?: CursorType | string;
9
10
  pointerEvents?: PointerEvents;
@@ -13,7 +14,17 @@ export interface RenderStyle {
13
14
  backgroundBlendMode?: BackgroundBlendMode;
14
15
  backgroundColor?: ColorAux;
15
16
  backgroundImage?: AssetReference;
17
+ backgroundPositionX?: YogaValueAux;
18
+ backgroundPositionY?: YogaValueAux;
19
+ backgroundSize?: BackgroundSize | YogaValue2Aux;
20
+ backgroundRepeatX?: YogaValueAux;
21
+ backgroundRepeatY?: YogaValueAux;
16
22
  maskImage?: AssetReference;
23
+ maskPositionX?: YogaValueAux;
24
+ maskPositionY?: YogaValueAux;
25
+ maskSize?: BackgroundSize | YogaValue2Aux;
26
+ maskRepeatX?: YogaValueAux;
27
+ maskRepeatY?: YogaValueAux;
17
28
  borderRadius?: NumberAux;
18
29
  borderTopLeftRadius?: NumberAux;
19
30
  borderTopRightRadius?: NumberAux;
@@ -29,28 +40,33 @@ export interface RenderStyle {
29
40
  objectPosition?: YogaValue2Aux;
30
41
  transformOrigin?: Vector2Aux;
31
42
  translate?: YogaValue2Aux;
43
+ translateZ?: YogaValueAux;
32
44
  scale?: Vector2Aux;
33
45
  rotate?: Vector3Aux;
34
- stateDuration?: number;
46
+ stateDuration?: number | string;
35
47
  color?: ColorAux;
36
48
  fontFamily?: AssetReference;
37
49
  fontWeight?: FontWeight;
38
50
  fontStyle?: FontStyles;
51
+ textTransform?: TextTransform;
39
52
  fontSize?: YogaValueAux;
40
53
  textOverflow?: TextOverflowModes;
41
54
  textAlign?: TextAlign;
42
55
  whiteSpace?: WhiteSpace;
43
56
  textStrokeWidth?: NumberAux;
44
57
  textStrokeColor?: ColorAux;
45
- lineHeight?: number;
46
- letterSpacing?: number;
47
- wordSpacing?: number;
48
- maxLines?: number;
58
+ lineHeight?: number | string;
59
+ letterSpacing?: number | string;
60
+ wordSpacing?: number | string;
61
+ maxLines?: number | string;
49
62
  transitionProperty?: keyof RenderStyle | string;
50
63
  transitionDuration?: number | string;
51
64
  transitionTimingFunction?: TimingFunctionType | string;
52
65
  transitionDelay?: number | string;
53
66
  transitionPlayState?: AnimationPlayState | string;
67
+ motionDuration?: number | string;
68
+ motionTimingFunction?: TimingFunctionType | string;
69
+ motionDelay?: number | string;
54
70
  animationDelay?: number | string;
55
71
  animationDirection?: AnimationDirection | string;
56
72
  animationDuration?: number | string;
@@ -64,6 +80,8 @@ export interface RenderStyle {
64
80
  audioDelay?: number | string;
65
81
  all?: string;
66
82
  background?: string;
83
+ backgroundPosition?: string;
84
+ backgroundRepeat?: string;
67
85
  border?: string;
68
86
  borderTop?: string;
69
87
  borderRight?: string;
@@ -72,6 +90,8 @@ export interface RenderStyle {
72
90
  borderWidth?: string;
73
91
  margin?: string;
74
92
  mask?: string;
93
+ maskPosition?: string;
94
+ maskRepeat?: string;
75
95
  padding?: string;
76
96
  inset?: string;
77
97
  flex?: string;
@@ -80,6 +100,7 @@ export interface RenderStyle {
80
100
  textStroke?: string;
81
101
  animation?: string;
82
102
  transition?: string;
103
+ motion?: string;
83
104
  audio?: string;
84
105
  [variable: `--${string}`]: any;
85
106
  }
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,12 @@
1
+ import { NUnit, UnityEngine } from '../generated';
2
+ declare global {
3
+ var Assert: NUnit.Framework.Assert;
4
+ var Has: NUnit.Framework.Has;
5
+ var Is: NUnit.Framework.Is;
6
+ var Iz: NUnit.Framework.Iz;
7
+ var Contains: NUnit.Framework.Contains;
8
+ var Does: NUnit.Framework.Does;
9
+ var Assume: NUnit.Framework.Assume;
10
+ var Throws: NUnit.Framework.Throws;
11
+ var LogAssert: UnityEngine.TestTools.LogAssert;
12
+ }
File without changes
@@ -1,13 +1,11 @@
1
+ import { BaseCmpProps } from '../base';
1
2
  import { ReactUnity, UnityEngine } from '../generated';
2
3
  import { Style } from '../properties';
3
4
  import { AssetReference } from '../properties/values';
4
5
  import { ActionCallback, Events } from './events';
5
- export interface View<T = ReactUnity.UGUI.UGUIComponent> extends Events<T> {
6
+ export interface View<T = ReactUnity.UGUI.UGUIComponent> extends Events<T>, BaseCmpProps {
6
7
  active?: boolean;
7
- name?: string;
8
- className?: string;
9
- id?: string;
10
- style?: Style;
8
+ style?: Style | string;
11
9
  }
12
10
  export interface Text extends View<ReactUnity.UGUI.TextComponent> {
13
11
  richText?: boolean;
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ ;
2
+ export {};
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  import { Attributes, ClassAttributes, RefAttributes } from 'react';
2
- import { StyleCmpDef, Textable } from '../base';
2
+ import { BaseElements, Textable } from '../base';
3
3
  import { ReactUnity } from '../generated';
4
4
  import * as Components from './components';
5
5
  import { Input } from './input';
@@ -8,9 +8,7 @@ declare type Children<T = any> = {
8
8
  children?: T;
9
9
  };
10
10
  declare type BaseCmp = Components.View<any> & RefAttributes<NS.UGUIComponent> & Children;
11
- export interface UGUIElements {
12
- [key: string]: BaseCmp | StyleCmpDef;
13
- style: StyleCmpDef;
11
+ export interface UGUIElements extends BaseElements<BaseCmp> {
14
12
  view: Components.View & RefAttributes<NS.ContainerComponent> & {
15
13
  tag?: string;
16
14
  } & Children;
File without changes
@@ -1,17 +1,15 @@
1
+ import { BaseCmpProps } from '../base';
1
2
  import { ReactUnity, UnityEditor, UnityEngine } from '../generated';
2
3
  import { Style } from '../properties';
3
4
  import { AssetReference } from '../properties/values';
4
5
  import { ActionCallback, Events } from './events';
5
6
  import Cmp = ReactUnity.UIToolkit;
6
7
  declare type BaseCmp = Cmp.UIToolkitComponent;
7
- export interface View<TSender = BaseCmp> extends Events<TSender> {
8
- name?: string;
9
- className?: string;
10
- id?: string;
8
+ export interface View<TSender = BaseCmp> extends Events<TSender>, BaseCmpProps {
11
9
  tooltip?: string;
12
10
  viewDataKey?: string;
13
11
  tabIndex?: number;
14
- style?: Style;
12
+ style?: Style | string;
15
13
  focusable?: boolean;
16
14
  bind?: UnityEditor.SerializedObject | UnityEditor.SerializedProperty;
17
15
  }
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  import * as rc from 'react';
2
- import { StyleCmpDef, Textable } from '../base';
2
+ import { BaseElements, Textable } from '../base';
3
3
  import { ReactUnity } from '../generated';
4
4
  import * as Components from './components';
5
5
  import Cmp = ReactUnity.UIToolkit;
@@ -7,9 +7,7 @@ declare type Children<T = any> = {
7
7
  children?: T;
8
8
  };
9
9
  declare type BaseElement<T = Cmp.UIToolkitComponent> = Components.View<T> & rc.RefAttributes<Cmp.UIToolkitComponent> & Children;
10
- export interface UIToolkitElements {
11
- [key: string]: BaseElement<any> | StyleCmpDef;
12
- style: StyleCmpDef;
10
+ export interface UIToolkitElements extends BaseElements<BaseElement<any>> {
13
11
  view: BaseElement & {
14
12
  tag?: string;
15
13
  };
File without changes
@@ -1,2 +1,3 @@
1
- export declare type DiffResult = null | Array<string | any>;
2
- export declare function diffProperties(lastRawProps: Record<string, any>, nextRawProps: Record<string, any>, deepDiffing?: number): DiffResult;
1
+ export declare type DiffResult = null | Record<string, any>;
2
+ export declare const styleStringSymbol = "__style_as_string__";
3
+ export declare function diffProperties(lastProps: Record<string, any>, nextProps: Record<string, any>, deepDiffing?: number): DiffResult;
@@ -1,10 +1,9 @@
1
- export function diffProperties(lastRawProps, nextRawProps, deepDiffing) {
1
+ export var styleStringSymbol = '__style_as_string__';
2
+ export function diffProperties(lastProps, nextProps, deepDiffing) {
2
3
  if (deepDiffing === void 0) { deepDiffing = 0; }
3
- if (lastRawProps === nextRawProps)
4
+ if (lastProps === nextProps)
4
5
  return null;
5
6
  var updatePayload = null;
6
- var lastProps = lastRawProps;
7
- var nextProps = nextRawProps;
8
7
  var propKey;
9
8
  for (propKey in lastProps) {
10
9
  if (nextProps.hasOwnProperty(propKey)
@@ -13,6 +12,9 @@ export function diffProperties(lastRawProps, nextRawProps, deepDiffing) {
13
12
  continue;
14
13
  }
15
14
  var prop = null;
15
+ if (propKey === 'style' && typeof lastProps.style === 'string') {
16
+ (updatePayload = updatePayload || {})[styleStringSymbol] = null;
17
+ }
16
18
  var depth = deepDiffing > 0 ? deepDiffing : propKey === 'style' ? 1 : 0;
17
19
  if (depth > 0) {
18
20
  prop = diffProperties(lastProps[propKey], null, depth - 1);
@@ -21,7 +23,7 @@ export function diffProperties(lastRawProps, nextRawProps, deepDiffing) {
21
23
  }
22
24
  // For all other deleted properties we add it to the queue. We use
23
25
  // the whitelist in the commit phase instead.
24
- (updatePayload = updatePayload || []).push(propKey, prop);
26
+ (updatePayload = updatePayload || {})[propKey] = prop;
25
27
  }
26
28
  for (propKey in nextProps) {
27
29
  var nextProp = nextProps[propKey];
@@ -32,13 +34,16 @@ export function diffProperties(lastRawProps, nextRawProps, deepDiffing) {
32
34
  continue;
33
35
  }
34
36
  var prop = nextProp;
37
+ if (propKey === 'style' && (typeof prop === 'string') !== (typeof lastProp === 'string')) {
38
+ (updatePayload = updatePayload || {})[styleStringSymbol] = typeof prop === 'string' ? prop : null;
39
+ }
35
40
  var depth = deepDiffing > 0 ? deepDiffing : propKey === 'style' ? 1 : 0;
36
41
  if (depth > 0) {
37
42
  prop = diffProperties(lastProp, nextProp, depth - 1);
38
43
  if (!prop)
39
44
  continue;
40
45
  }
41
- (updatePayload = updatePayload || []).push(propKey, prop);
46
+ (updatePayload = updatePayload || {})[propKey] = prop;
42
47
  }
43
48
  return updatePayload;
44
49
  }
@@ -1,5 +1,5 @@
1
1
  import type * as React from 'react';
2
- import { NativeContainerInstance } from '../../models/renderer';
2
+ import { NativeContainerInstance } from '../models/renderer';
3
3
  export declare const Renderer: {
4
4
  render(element: React.ReactNode, hostContainer?: NativeContainerInstance, renderWithoutHelpers?: boolean): number;
5
5
  };
@@ -1,80 +1,34 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { createElement } from 'react';
2
13
  import * as Reconciler from 'react-reconciler';
3
14
  import { DefaultView } from '../views/default-view';
4
- import { diffProperties } from './diffing';
15
+ import { diffProperties, styleStringSymbol } from './diffing';
5
16
  var hostContext = {};
6
17
  var childContext = {};
7
- function applyDiffedUpdate(writeTo, updatePayload, depth) {
8
- if (depth === void 0) { depth = 0; }
9
- if (!updatePayload)
10
- return false;
11
- if (Array.isArray(updatePayload)) {
12
- for (var index = 0; index < updatePayload.length; index += 2) {
13
- var attr = updatePayload[index];
14
- var value = updatePayload[index + 1];
15
- if (depth > 0)
16
- applyDiffedUpdate(writeTo[attr], value, depth - 1);
17
- else
18
- writeTo.SetWithoutNotify(attr, value);
19
- }
20
- return updatePayload.length > 0;
21
- }
22
- else {
23
- for (var attr in updatePayload) {
24
- if (updatePayload.hasOwnProperty(attr)) {
25
- var value = updatePayload[attr];
26
- writeTo.SetWithoutNotify(attr, value);
27
- }
28
- }
29
- return true;
30
- }
31
- }
32
- function applyUpdate(instance, updatePayload, isAfterMount, type, pre) {
33
- if (pre === void 0) { pre = true; }
34
- var updateAfterMount = false;
35
- for (var index = 0; index < updatePayload.length; index += 2) {
36
- var attr = updatePayload[index];
37
- var value = updatePayload[index + 1];
38
- var isEvent = attr.substring(0, 2) === 'on';
39
- // Register events before other properties
40
- if (pre !== isEvent)
41
- continue;
42
- if (isEvent) {
43
- UnityBridge.setEventListener(instance, attr, value);
44
- continue;
45
- }
46
- if (attr === 'children') {
47
- if (type === 'text' || type === 'icon' || type === 'style') {
48
- UnityBridge.setText(instance, value ? ((Array.isArray(value) && value.join) ? value.join('') : value + '') : '');
49
- }
50
- continue;
51
- }
52
- if (attr === 'key')
53
- continue;
54
- if (attr === 'ref')
55
- continue;
56
- if (attr === 'tag')
57
- continue;
58
- if (!isAfterMount && attr === 'style') {
59
- updateAfterMount = true;
60
- continue;
61
- }
62
- if (attr === 'style') {
63
- if (applyDiffedUpdate(instance.Style, value)) {
64
- instance.ResolveStyle();
65
- }
66
- continue;
67
- }
68
- if (attr.substring(0, 5) === 'data-') {
69
- UnityBridge.setData(instance, attr.substring(5), value);
70
- }
71
- else {
72
- UnityBridge.setProperty(instance, attr, value);
73
- }
18
+ var textTypes = {
19
+ text: true,
20
+ icon: true,
21
+ style: true,
22
+ script: true,
23
+ };
24
+ function getAllowedProps(props, type) {
25
+ var children = props.children, tag = props.tag, rest = __rest(props, ["children", "tag"]);
26
+ if (textTypes[type]) {
27
+ rest.children = (!children || typeof children === 'boolean') ? null : Array.isArray(children) ? children.join('') : children + '';
74
28
  }
75
- if (pre)
76
- return applyUpdate(instance, updatePayload, isAfterMount, type, false) || updateAfterMount;
77
- return updateAfterMount;
29
+ if (typeof props.style === 'string')
30
+ rest[styleStringSymbol] = props.style;
31
+ return rest;
78
32
  }
79
33
  var hostConfig = {
80
34
  getRootHostContext: function (rootContainerInstance) { return hostContext; },
@@ -88,37 +42,20 @@ var hostConfig = {
88
42
  supportsPersistence: false,
89
43
  isPrimaryRenderer: true,
90
44
  createInstance: function (type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
91
- var _a;
92
- if (type === 'text' || type === 'icon' || type === 'style') {
93
- var text = props.children === true ? '' :
94
- Array.isArray(props.children) ? props.children.join('') :
95
- ((_a = props.children) === null || _a === void 0 ? void 0 : _a.toString()) || '';
96
- return UnityBridge.createElement(type, text, rootContainerInstance);
97
- }
98
- return UnityBridge.createElement(props.tag || type, null, rootContainerInstance);
45
+ var aProps = getAllowedProps(props, type);
46
+ var children = aProps.children || null;
47
+ delete aProps.children;
48
+ return UnityBridge.createElement(props.tag || type, children, rootContainerInstance, aProps);
99
49
  },
100
50
  createTextInstance: function (text, rootContainerInstance, hostContext, internalInstanceHandle) {
101
51
  return UnityBridge.createText(text, rootContainerInstance);
102
52
  },
103
53
  appendInitialChild: function (parent, child) { UnityBridge.appendChild(parent, child); },
104
54
  finalizeInitialChildren: function (instance, type, props, rootContainerInstance, hostContext) {
105
- var propsToUpdate = [];
106
- var keys = Object.keys(props);
107
- for (var index = 0; index < keys.length; index++) {
108
- var key = keys[index];
109
- var value = props[key];
110
- propsToUpdate.push(key, value);
111
- }
112
- return applyUpdate(instance, propsToUpdate, false);
113
- },
114
- // Some attributes like style need to be changed only after mount
115
- commitMount: function (instance, type, newProps, internalInstanceHandle) {
116
- var props = [];
117
- if ('style' in newProps)
118
- props.push('style', newProps.style);
119
- applyUpdate(instance, props, true);
55
+ return false;
120
56
  },
121
- shouldSetTextContent: function (type, props) { return type === 'text' || type === 'icon' || type === 'style'; },
57
+ commitMount: function (instance, type, newProps, internalInstanceHandle) { },
58
+ shouldSetTextContent: function (type, props) { return textTypes[type]; },
122
59
  shouldDeprioritizeSubtree: function (type, props) { return false; },
123
60
  // -------------------
124
61
  // Mutation
@@ -128,7 +65,7 @@ var hostConfig = {
128
65
  return diffProperties(oldProps, newProps);
129
66
  },
130
67
  commitUpdate: function (instance, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
131
- applyUpdate(instance, updatePayload, true, type);
68
+ UnityBridge.applyUpdate(instance, getAllowedProps(updatePayload, type), type);
132
69
  },
133
70
  resetTextContent: function (instance) { console.log('resetTextContent'); },
134
71
  commitTextUpdate: function (textInstance, oldText, newText) { UnityBridge.setText(textInstance, newText); },
@@ -152,19 +89,22 @@ var hostConfig = {
152
89
  // -------------------
153
90
  // Scheduling
154
91
  // -------------------
155
- scheduleDeferredCallback: function (callback, options) { return UnityScheduler.setTimeout(callback, (options === null || options === void 0 ? void 0 : options.timeout) || 0); },
156
- cancelDeferredCallback: function (callBackID) { UnityScheduler.clearTimeout(callBackID); },
92
+ scheduleDeferredCallback: function (callback, options) { return setTimeout(callback, (options === null || options === void 0 ? void 0 : options.timeout) || 0); },
93
+ cancelDeferredCallback: function (callBackID) { clearTimeout(callBackID); },
157
94
  noTimeout: -1,
158
- scheduleTimeout: function (callback, timeout) { return UnityScheduler.setTimeout(callback, timeout); },
159
- cancelTimeout: function (handle) { UnityScheduler.clearTimeout(handle); },
160
- queueMicrotask: function (callback) { return UnityScheduler.setTimeout(callback, 0); },
95
+ scheduleTimeout: function (callback, timeout) { return setTimeout(callback, timeout); },
96
+ cancelTimeout: function (handle) { clearTimeout(handle); },
97
+ queueMicrotask: function (callback) { return setTimeout(callback, 0); },
161
98
  };
162
99
  var ReactUnityReconciler = Reconciler(hostConfig);
100
+ var containerMap = new Map();
163
101
  export var Renderer = {
164
102
  render: function (element, hostContainer, renderWithoutHelpers) {
165
103
  if (!hostContainer)
166
104
  hostContainer = HostContainer;
167
- var hostRoot = ReactUnityReconciler.createContainer(hostContainer, 0, false, {});
105
+ var hostRoot = containerMap.get(hostContainer);
106
+ if (!hostRoot)
107
+ containerMap.set(hostContainer, hostRoot = ReactUnityReconciler.createContainer(hostContainer, 0, false, {}));
168
108
  if (!renderWithoutHelpers)
169
109
  element = createElement(DefaultView, null, element);
170
110
  return ReactUnityReconciler.updateContainer(element, hostRoot, null);
package/dist/tests.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './models/tests';
1
+ export * from './src/models/tests';
package/dist/tests.js CHANGED
@@ -1 +1 @@
1
- export * from './models/tests';
1
+ export * from './src/models/tests';
package/dist/ugui.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './models/ugui';
1
+ export * from './src/models/ugui';
package/dist/ugui.js CHANGED
@@ -1 +1 @@
1
- export * from './models/ugui';
1
+ export * from './src/models/ugui';
@@ -1 +1 @@
1
- export * from './models/uitoolkit';
1
+ export * from './src/models/uitoolkit';
package/dist/uitoolkit.js CHANGED
@@ -1 +1 @@
1
- export * from './models/uitoolkit';
1
+ export * from './src/models/uitoolkit';
package/editor.ts CHANGED
@@ -1 +1 @@
1
- export * from './models/editor';
1
+ export * from './src/models/editor';