@reactunity/renderer 0.9.1 → 0.10.1

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 (34) hide show
  1. package/dist/src/helpers/dictionary-watcher.d.ts +14 -2
  2. package/dist/src/helpers/dictionary-watcher.js +28 -21
  3. package/dist/src/helpers/watcher.js +10 -11
  4. package/dist/src/models/environment/index.d.ts +1 -0
  5. package/dist/src/models/generated/react.d.ts +398 -83
  6. package/dist/src/models/generated/react.js +1 -1
  7. package/dist/src/models/properties/styles.d.ts +10 -9
  8. package/dist/src/renderer/async/callbacks.d.ts +6 -0
  9. package/dist/src/renderer/async/callbacks.js +38 -0
  10. package/dist/src/renderer/async/commands.d.ts +45 -0
  11. package/dist/src/renderer/async/commands.js +1 -0
  12. package/dist/src/renderer/async/objects.d.ts +8 -0
  13. package/dist/src/renderer/async/objects.js +31 -0
  14. package/dist/src/renderer/async/reconciler.d.ts +8 -0
  15. package/dist/src/renderer/async/reconciler.js +105 -0
  16. package/dist/src/renderer/async/serializer.d.ts +9 -0
  17. package/dist/src/renderer/async/serializer.js +31 -0
  18. package/dist/src/renderer/async/types.d.ts +19 -0
  19. package/dist/src/renderer/async/types.js +1 -0
  20. package/dist/src/renderer/constants.d.ts +23 -0
  21. package/dist/src/renderer/constants.js +49 -0
  22. package/dist/src/renderer/diffing.js +39 -13
  23. package/dist/src/renderer/renderer.d.ts +15 -1
  24. package/dist/src/renderer/renderer.js +77 -114
  25. package/dist/src/renderer/sync/reconciler.d.ts +2 -0
  26. package/dist/src/renderer/sync/reconciler.js +35 -0
  27. package/dist/src/version.d.ts +1 -0
  28. package/dist/src/version.js +1 -0
  29. package/dist/src/views/default-view.d.ts +2 -1
  30. package/dist/src/views/default-view.js +4 -3
  31. package/dist/src/views/error-boundary.d.ts +1 -1
  32. package/dist/src/views/error-boundary.js +1 -1
  33. package/package.json +9 -9
  34. package/version.js +3 -0
@@ -1,6 +1,6 @@
1
1
  //
2
2
  // Types in assemblies: ReactUnity, ReactUnity.Editor, ReactUnity.UGUI, ReactUnity.UIToolkit
3
- // Generated 15/01/2022 01:23:51
3
+ // Generated 29/04/2022 17:32:51
4
4
  //
5
5
  /* eslint-disable */
6
6
  export {};
@@ -1,5 +1,5 @@
1
1
  import { AnimationDirection, AnimationFillMode, AnimationPlayState, Appearance, BackgroundBlendMode, BackgroundSize, CursorType, FontStyles, FontWeight, NavigationMode, ObjectFit, PointerEvents, TextAlign, TextOverflowModes, TextTransform, TimingFunctionType, Visibility, WhiteSpace } from './styles-enums';
2
- import { AssetReference, ColorAux, NumberAux, Vector2Aux, Vector3Aux } from './values';
2
+ import { Array2Aux, AssetReference, ColorAux, NumberAux, Vector2Aux, Vector3Aux } from './values';
3
3
  import { YogaValue2Aux, YogaValueAux } from './yoga';
4
4
  export interface RenderStyle {
5
5
  opacity?: NumberAux;
@@ -25,11 +25,11 @@ export interface RenderStyle {
25
25
  maskSize?: BackgroundSize | YogaValue2Aux;
26
26
  maskRepeatX?: YogaValueAux;
27
27
  maskRepeatY?: YogaValueAux;
28
- borderRadius?: NumberAux;
29
- borderTopLeftRadius?: NumberAux;
30
- borderTopRightRadius?: NumberAux;
31
- borderBottomRightRadius?: NumberAux;
32
- borderBottomLeftRadius?: NumberAux;
28
+ borderRadius?: Array2Aux<YogaValueAux> | string;
29
+ borderTopLeftRadius?: Array2Aux<YogaValueAux>;
30
+ borderTopRightRadius?: Array2Aux<YogaValueAux>;
31
+ borderBottomRightRadius?: Array2Aux<YogaValueAux>;
32
+ borderBottomLeftRadius?: Array2Aux<YogaValueAux>;
33
33
  borderColor?: ColorAux;
34
34
  borderTopColor?: ColorAux;
35
35
  borderRightColor?: ColorAux;
@@ -88,12 +88,12 @@ export interface RenderStyle {
88
88
  borderBottom?: string;
89
89
  borderLeft?: string;
90
90
  borderWidth?: string;
91
- margin?: string;
91
+ margin?: string | number;
92
92
  mask?: string;
93
93
  maskPosition?: string;
94
94
  maskRepeat?: string;
95
- padding?: string;
96
- inset?: string;
95
+ padding?: string | number;
96
+ inset?: string | number;
97
97
  flex?: string;
98
98
  flexFlow?: string;
99
99
  font?: string;
@@ -102,5 +102,6 @@ export interface RenderStyle {
102
102
  transition?: string;
103
103
  motion?: string;
104
104
  audio?: string;
105
+ transform?: string;
105
106
  [variable: `--${string}`]: any;
106
107
  }
@@ -0,0 +1,6 @@
1
+ import { AsyncCallback } from './commands';
2
+ import { ObjectsRepo } from './objects';
3
+ export declare class CallbacksRepo extends ObjectsRepo<AsyncCallback> {
4
+ constructor();
5
+ call: (ind: number, args: any[]) => any;
6
+ }
@@ -0,0 +1,38 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { ObjectsRepo } from './objects';
17
+ var CallbacksRepo = /** @class */ (function (_super) {
18
+ __extends(CallbacksRepo, _super);
19
+ function CallbacksRepo() {
20
+ var _this = _super.call(this) || this;
21
+ _this.call = function (ind, args) {
22
+ var cb = _this.getObject(ind);
23
+ if ('Length' in args) {
24
+ var newArgs = [];
25
+ var length = args['Length'];
26
+ for (var index = 0; index < length; index++) {
27
+ var element = args[index];
28
+ newArgs.push(element);
29
+ }
30
+ args = newArgs;
31
+ }
32
+ return cb.apply(null, args);
33
+ };
34
+ return _this;
35
+ }
36
+ return CallbacksRepo;
37
+ }(ObjectsRepo));
38
+ export { CallbacksRepo };
@@ -0,0 +1,45 @@
1
+ export declare type BatchUpdateProps = {
2
+ [key: string]: string | number | object;
3
+ };
4
+ export declare type AsyncCallback = (...args: any[]) => any;
5
+ export declare type BatchUpdateCallbacks = {
6
+ [key: string]: number;
7
+ };
8
+ declare type ApplyUpdatesParams = {
9
+ t: string;
10
+ r: number;
11
+ c?: string;
12
+ p?: BatchUpdateProps;
13
+ e?: BatchUpdateCallbacks;
14
+ o?: BatchUpdateCallbacks;
15
+ };
16
+ export declare type CreateInstanceCommand = ['c', ApplyUpdatesParams];
17
+ export declare type CreateTextInstanceCommand = ['t', {
18
+ r: number;
19
+ c?: string;
20
+ }];
21
+ export declare type AppendChildCommand = ['a', {
22
+ p: number;
23
+ c: number;
24
+ }];
25
+ export declare type RemoveChildCommand = ['r', {
26
+ p: number;
27
+ c: number;
28
+ }];
29
+ export declare type InsertChildCommand = ['i', {
30
+ p: number;
31
+ c: number;
32
+ i?: number;
33
+ }];
34
+ export declare type ApplyUpdatesCommand = ['u', ApplyUpdatesParams];
35
+ export declare type TextUpdateCommand = ['x', {
36
+ r: number;
37
+ c: string;
38
+ }];
39
+ export declare type ToggleHideCommand = ['h', {
40
+ r: number;
41
+ h: boolean;
42
+ }];
43
+ export declare type ClearContainerCommand = ['o'];
44
+ export declare type BatchCommand = CreateInstanceCommand | CreateTextInstanceCommand | AppendChildCommand | RemoveChildCommand | InsertChildCommand | ApplyUpdatesCommand | TextUpdateCommand | ToggleHideCommand | ClearContainerCommand | null;
45
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export declare class ObjectsRepo<T = any> {
2
+ indices: {}[];
3
+ objects: WeakMap<object, T>;
4
+ constructor();
5
+ setObject: (index: number, item: T) => void;
6
+ addObject: (item: T) => number;
7
+ getObject: (index: number) => T;
8
+ }
@@ -0,0 +1,31 @@
1
+ var ObjectsRepo = /** @class */ (function () {
2
+ function ObjectsRepo() {
3
+ var _this = this;
4
+ this.indices = [{}];
5
+ this.objects = new WeakMap();
6
+ this.setObject = function (index, item) {
7
+ var it = _this.indices[index];
8
+ if (!it) {
9
+ it = _this.indices[index] = {};
10
+ }
11
+ _this.objects.set(it, item);
12
+ };
13
+ this.addObject = function (item) {
14
+ if (!item)
15
+ return -1;
16
+ var it = {};
17
+ var ind = _this.indices.length;
18
+ _this.indices.push(it);
19
+ _this.objects.set(it, item);
20
+ return ind;
21
+ };
22
+ this.getObject = function (index) {
23
+ if (index < 0)
24
+ return undefined;
25
+ var it = _this.indices[index];
26
+ return _this.objects.get(it);
27
+ };
28
+ }
29
+ return ObjectsRepo;
30
+ }());
31
+ export { ObjectsRepo };
@@ -0,0 +1,8 @@
1
+ import * as Reconciler from 'react-reconciler';
2
+ import { AsyncHostContext } from './types';
3
+ export declare const asyncReconciler: Reconciler.Reconciler<AsyncHostContext & {
4
+ refId: number;
5
+ } & {
6
+ component: import("../../..").ReactUnity.IReactComponent;
7
+ fiberCache: import("./objects").ObjectsRepo<any>;
8
+ }, import("./types").AsyncNativeInstance, import("./types").AsyncNativeInstance, import("./types").AsyncNativeInstance, import("../../..").ReactUnity.IReactComponent>;
@@ -0,0 +1,105 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import * as Reconciler from 'react-reconciler';
13
+ import { commonReconciler, getAllowedProps, textTypes } from '../constants';
14
+ import { diffProperties } from '../diffing';
15
+ import { callbacksRepo, convertPropsToSerializable, objectsRepo } from './serializer';
16
+ var refId = 0;
17
+ var ctxMap = new Map();
18
+ var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext: function (rootContainer) {
19
+ var context = rootContainer.context;
20
+ if (rootContainer.refId < 0) {
21
+ refId++;
22
+ rootContainer.context.SetRef(refId, rootContainer.component);
23
+ rootContainer.refId = refId;
24
+ }
25
+ var existing = ctxMap.get(context);
26
+ if (existing)
27
+ return existing;
28
+ var commands = rootContainer.commands;
29
+ var flushCommands = function () {
30
+ var serialized = JSON.stringify(commands);
31
+ commands.length = 0;
32
+ return serialized;
33
+ };
34
+ var fireEventByRef = function (ind, args) {
35
+ return callbacksRepo.call(ind, args);
36
+ };
37
+ var getObjectRef = function (ind) {
38
+ return objectsRepo.getObject(ind);
39
+ };
40
+ var getEventAsObjectRef = function (ind) {
41
+ return callbacksRepo.getObject(ind);
42
+ };
43
+ context.BindCommands(flushCommands, fireEventByRef, getObjectRef, getEventAsObjectRef);
44
+ var ctx = {
45
+ context: context,
46
+ commands: commands,
47
+ };
48
+ ctxMap.set(context, ctx);
49
+ return ctx;
50
+ }, getChildHostContext: function (parentCtx) {
51
+ return parentCtx;
52
+ }, getPublicInstance: function (instance) {
53
+ return instance.context.GetRef(instance.refId, instance.commands.length > 0);
54
+ }, supportsMutation: true, supportsHydration: false, supportsPersistence: false, supportsMicrotasks: true, supportsTestSelectors: false, isPrimaryRenderer: true, warnsIfNotActing: true, prepareForCommit: function () { return null; }, resetAfterCommit: function () { }, shouldDeprioritizeSubtree: function () { return false; }, clearContainer: function (container) {
55
+ UnityBridge.clearContainer(container);
56
+ }, createInstance: function (type, props, rootContainer, ctx, internalHandle) {
57
+ refId++;
58
+ var aProps = getAllowedProps(props, type);
59
+ ctx.commands.push(['c', __assign({ t: type, r: refId }, convertPropsToSerializable(aProps))]);
60
+ if (rootContainer.fiberCache)
61
+ rootContainer.fiberCache.setObject(refId, internalHandle);
62
+ return __assign(__assign({}, ctx), { refId: refId });
63
+ }, createTextInstance: function (text, rootContainer, ctx, internalHandle) {
64
+ refId++;
65
+ ctx.commands.push(['t', { r: refId, c: text }]);
66
+ if (rootContainer.fiberCache)
67
+ rootContainer.fiberCache.setObject(refId, internalHandle);
68
+ return __assign(__assign({}, ctx), { refId: refId });
69
+ }, appendInitialChild: function (parent, child) {
70
+ parent.commands.push(['a', { p: parent.refId, c: child.refId }]);
71
+ }, finalizeInitialChildren: function () { return false; }, commitMount: function (instance) { }, shouldSetTextContent: function (type) { return textTypes[type]; },
72
+ // -------------------
73
+ // Mutation
74
+ // -------------------
75
+ prepareUpdate: function (instance, type, oldProps, newProps) {
76
+ return diffProperties(oldProps, newProps);
77
+ }, commitUpdate: function (instance, updatePayload, type) {
78
+ var props = getAllowedProps(updatePayload, type);
79
+ instance.commands.push(['u', __assign({ r: instance.refId, t: type }, convertPropsToSerializable(props))]);
80
+ }, commitTextUpdate: function (textInstance, oldText, newText) {
81
+ textInstance.commands.push(['x', { r: textInstance.refId, c: newText }]);
82
+ }, appendChild: function (parent, child) {
83
+ child.commands.push(['a', { p: parent.refId, c: child.refId }]);
84
+ }, appendChildToContainer: function (parent, child) {
85
+ child.commands.push(['a', { p: parent.refId, c: child.refId }]);
86
+ }, insertBefore: function (parent, child, beforeChild) {
87
+ child.commands.push(['i', { p: parent.refId, c: child.refId, i: beforeChild.refId }]);
88
+ }, insertInContainerBefore: function (parent, child, beforeChild) {
89
+ child.commands.push(['i', { p: parent.refId, c: child.refId, i: beforeChild.refId }]);
90
+ }, removeChild: function (parent, child) {
91
+ child.commands.push(['r', { p: parent.refId, c: child.refId }]);
92
+ }, removeChildFromContainer: function (parent, child) {
93
+ child.commands.push(['r', { p: parent.refId, c: child.refId }]);
94
+ }, resetTextContent: function () { }, preparePortalMount: function () { }, detachDeletedInstance: function () { },
95
+ // Required for Suspense
96
+ hideInstance: function (instance) {
97
+ instance.commands.push(['h', { r: instance.refId, h: true }]);
98
+ }, hideTextInstance: function (instance) {
99
+ instance.commands.push(['h', { r: instance.refId, h: true }]);
100
+ }, unhideInstance: function (instance) {
101
+ instance.commands.push(['h', { r: instance.refId, h: false }]);
102
+ }, unhideTextInstance: function (instance) {
103
+ instance.commands.push(['h', { r: instance.refId, h: false }]);
104
+ } });
105
+ export var asyncReconciler = Reconciler(hostConfig);
@@ -0,0 +1,9 @@
1
+ import { CallbacksRepo } from './callbacks';
2
+ import { ObjectsRepo } from './objects';
3
+ export declare const callbacksRepo: CallbacksRepo;
4
+ export declare const objectsRepo: ObjectsRepo<any>;
5
+ export declare function convertPropsToSerializable(props: any): {
6
+ p: any;
7
+ o: any;
8
+ e: any;
9
+ };
@@ -0,0 +1,31 @@
1
+ import { CallbacksRepo } from './callbacks';
2
+ import { ObjectsRepo } from './objects';
3
+ export var callbacksRepo = new CallbacksRepo();
4
+ export var objectsRepo = new ObjectsRepo();
5
+ // Separates properties in 3 categories: regular props, callbacks and non-serializable objects
6
+ export function convertPropsToSerializable(props) {
7
+ var res = {};
8
+ for (var key in props) {
9
+ if (Object.prototype.hasOwnProperty.call(props, key)) {
10
+ var value = props[key];
11
+ if (value == null) {
12
+ (res.p || (res.p = {}))[key] = null;
13
+ }
14
+ else if (key === 'style') {
15
+ (res.p || (res.p = {}))[key] = convertPropsToSerializable(value);
16
+ }
17
+ else if (key[0] === 'o' && key[1] === 'n' && typeof value === 'function') {
18
+ var ind = callbacksRepo.addObject(value);
19
+ (res.e || (res.e = {}))[key] = ind;
20
+ }
21
+ else if (typeof value === 'object' || typeof value === 'function') {
22
+ var ind = objectsRepo.addObject(value);
23
+ (res.o || (res.o = {}))[key] = ind;
24
+ }
25
+ else {
26
+ (res.p || (res.p = {}))[key] = value;
27
+ }
28
+ }
29
+ }
30
+ return res;
31
+ }
@@ -0,0 +1,19 @@
1
+ import * as Reconciler from 'react-reconciler';
2
+ import { ReactUnity } from '../../models/generated';
3
+ import { ChildSet, HydratableInstance, InstanceTag, NoTimeout, Props, TimeoutHandle, UpdatePayload } from '../../models/renderer';
4
+ import { BatchCommand } from './commands';
5
+ import { ObjectsRepo } from './objects';
6
+ export declare type AsyncHostContext = {
7
+ context: ReactUnity.ReactContext;
8
+ commands: BatchCommand[];
9
+ };
10
+ export declare type AsyncNativeInstance = AsyncHostContext & {
11
+ refId: number;
12
+ };
13
+ declare type AsyncContainerInstance = AsyncNativeInstance & {
14
+ component: ReactUnity.IReactComponent;
15
+ fiberCache: ObjectsRepo | null;
16
+ };
17
+ declare type AsyncPublicInstance = ReactUnity.IReactComponent;
18
+ export declare type AsyncReconcilerConfig = Reconciler.HostConfig<InstanceTag, Props, AsyncContainerInstance, AsyncNativeInstance, AsyncNativeInstance, AsyncNativeInstance, HydratableInstance, AsyncPublicInstance, AsyncHostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>;
19
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ export declare const hideClass = "react-unity__renderer__hidden";
2
+ export declare const eventPriorities: {
3
+ discrete: number;
4
+ continuous: number;
5
+ default: number;
6
+ idle: number;
7
+ };
8
+ export declare const textTypes: {
9
+ text: boolean;
10
+ icon: boolean;
11
+ style: boolean;
12
+ script: boolean;
13
+ };
14
+ export declare function getAllowedProps(props: any, type: any): any;
15
+ export declare const commonReconciler: {
16
+ now: () => number;
17
+ getCurrentEventPriority: () => number;
18
+ noTimeout: -1;
19
+ scheduleTimeout: (callback: any, delay: any) => number;
20
+ scheduleMicrotask: (callback: (...args: any[]) => any) => void;
21
+ cancelTimeout: (handle: any) => void;
22
+ };
23
+ export declare const isDevelopment: boolean;
@@ -0,0 +1,49 @@
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
+ };
12
+ import { ContinuousEventPriority, DefaultEventPriority, DiscreteEventPriority, IdleEventPriority } from 'react-reconciler/constants';
13
+ import { styleStringSymbol } from './diffing';
14
+ export var hideClass = 'react-unity__renderer__hidden';
15
+ export var eventPriorities = {
16
+ discrete: DiscreteEventPriority,
17
+ continuous: ContinuousEventPriority,
18
+ default: DefaultEventPriority,
19
+ idle: IdleEventPriority,
20
+ };
21
+ export var textTypes = {
22
+ text: true,
23
+ icon: true,
24
+ style: true,
25
+ script: true,
26
+ };
27
+ export function getAllowedProps(props, type) {
28
+ var children = props.children, tag = props.tag, rest = __rest(props, ["children", "tag"]);
29
+ if (textTypes[type] && 'children' in props) {
30
+ rest.children = (!children || typeof children === 'boolean') ? null : Array.isArray(children) ? children.join('') : children + '';
31
+ }
32
+ if (typeof props.style === 'string')
33
+ rest[styleStringSymbol] = props.style;
34
+ return rest;
35
+ }
36
+ export var commonReconciler = {
37
+ // -------------------
38
+ // Scheduling
39
+ // -------------------
40
+ now: Date.now,
41
+ getCurrentEventPriority: function () { return UnityBridge.CurrentEventPriority || eventPriorities.default; },
42
+ noTimeout: -1,
43
+ scheduleTimeout: function (callback, delay) { return setTimeout(callback, delay); },
44
+ scheduleMicrotask: typeof queueMicrotask === 'function' ? queueMicrotask :
45
+ function (callback) { return Promise.resolve(null).then(callback)
46
+ .catch(function (error) { return setTimeout(function () { throw error; }, 0); }); },
47
+ cancelTimeout: function (handle) { return clearTimeout(handle); },
48
+ };
49
+ export var isDevelopment = process.env.NODE_ENV === 'development';
@@ -6,26 +6,31 @@ export function diffProperties(lastProps, nextProps, deepDiffing) {
6
6
  var updatePayload = null;
7
7
  var propKey;
8
8
  for (propKey in lastProps) {
9
+ // This loop is for removing properties that existed in the previous properties, but not on current
9
10
  if (nextProps.hasOwnProperty(propKey)
10
11
  || !lastProps.hasOwnProperty(propKey)
11
12
  || lastProps[propKey] == null) {
12
13
  continue;
13
14
  }
14
15
  var prop = null;
16
+ // If style existed in the previous properties as string, set it to null
15
17
  if (propKey === 'style' && typeof lastProps.style === 'string') {
16
18
  (updatePayload = updatePayload || {})[styleStringSymbol] = null;
17
19
  }
18
- var depth = deepDiffing > 0 ? deepDiffing : propKey === 'style' ? 1 : 0;
19
- if (depth > 0) {
20
- prop = diffProperties(lastProps[propKey], null, depth - 1);
21
- if (!prop)
22
- continue;
20
+ else {
21
+ var depth = deepDiffing > 0 ? deepDiffing : propKey === 'style' ? 1 : 0;
22
+ if (depth > 0) {
23
+ prop = diffProperties(lastProps[propKey], null, depth - 1);
24
+ if (!prop)
25
+ continue;
26
+ }
27
+ // For all other deleted properties we add it to the queue. We use
28
+ // the whitelist in the commit phase instead.
29
+ (updatePayload = updatePayload || {})[propKey] = prop;
23
30
  }
24
- // For all other deleted properties we add it to the queue. We use
25
- // the whitelist in the commit phase instead.
26
- (updatePayload = updatePayload || {})[propKey] = prop;
27
31
  }
28
32
  for (propKey in nextProps) {
33
+ // This loop is for finding difference between current properties and previous properties
29
34
  var nextProp = nextProps[propKey];
30
35
  var lastProp = lastProps != null ? lastProps[propKey] : undefined;
31
36
  if (!nextProps.hasOwnProperty(propKey)
@@ -34,12 +39,33 @@ export function diffProperties(lastProps, nextProps, deepDiffing) {
34
39
  continue;
35
40
  }
36
41
  var prop = nextProp;
37
- if (propKey === 'style' && (typeof prop === 'string') !== (typeof lastProp === 'string')) {
38
- (updatePayload = updatePayload || {})[styleStringSymbol] = typeof prop === 'string' ? prop : null;
42
+ if (propKey === 'style') {
43
+ var prevWasString = (typeof lastProp === 'string');
44
+ var curIsString = (typeof prop === 'string');
45
+ if (prevWasString !== curIsString) {
46
+ (updatePayload = updatePayload || {})[styleStringSymbol] = typeof prop === 'string' ? prop : null;
47
+ if (curIsString) {
48
+ // Current style is string while previous is object, so revert all changes from the previous one
49
+ prop = diffProperties(lastProp, {}, 0);
50
+ if (!prop)
51
+ continue;
52
+ }
53
+ }
54
+ else {
55
+ if (curIsString) {
56
+ // Both styles are string, style does not need changing
57
+ continue;
58
+ }
59
+ else {
60
+ // Both styles are object, take the difference
61
+ prop = diffProperties(lastProp, nextProp, 0);
62
+ if (!prop)
63
+ continue;
64
+ }
65
+ }
39
66
  }
40
- var depth = deepDiffing > 0 ? deepDiffing : propKey === 'style' ? 1 : 0;
41
- if (depth > 0) {
42
- prop = diffProperties(lastProp, nextProp, depth - 1);
67
+ if (deepDiffing > 0) {
68
+ prop = diffProperties(lastProp, nextProp, deepDiffing - 1);
43
69
  if (!prop)
44
70
  continue;
45
71
  }
@@ -1,7 +1,21 @@
1
1
  import * as React from 'react';
2
2
  import { NativeContainerInstance } from '../models/renderer';
3
+ import { ObjectsRepo } from './async/objects';
4
+ import { AsyncNativeInstance } from './async/types';
5
+ interface RenderOptions {
6
+ hostContainer?: NativeContainerInstance;
7
+ disableHelpers?: boolean;
8
+ mode?: 'legacy' | 'concurrent';
9
+ sync?: boolean;
10
+ }
3
11
  export declare const Renderer: {
4
- render(element: React.ReactNode, hostContainer?: NativeContainerInstance, renderWithoutHelpers?: boolean): void;
12
+ render(element: React.ReactNode, options?: RenderOptions): import("react-reconciler").Reconciler<import("./async/types").AsyncHostContext & {
13
+ refId: number;
14
+ } & {
15
+ component: import("../..").ReactUnity.IReactComponent;
16
+ fiberCache: ObjectsRepo<any>;
17
+ }, AsyncNativeInstance, AsyncNativeInstance, AsyncNativeInstance, import("../..").ReactUnity.IReactComponent> | import("react-reconciler").Reconciler<import("../..").ReactUnity.IReactComponent, import("../..").ReactUnity.IReactComponent, import("../..").ReactUnity.ITextComponent, import("../..").ReactUnity.IReactComponent, any>;
5
18
  };
6
19
  export declare const batchedUpdates: <A, R>(fn: (a: A) => R, a: A) => R;
7
20
  export declare const flushSync: <A, R>(fn: (a: A) => R, a: A) => R;
21
+ export {};