@reactunity/renderer 0.10.0 → 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.
@@ -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
  }
@@ -1,9 +1,8 @@
1
1
  import * as Reconciler from 'react-reconciler';
2
- import { ObjectsRepo } from './objects';
3
2
  import { AsyncHostContext } from './types';
4
3
  export declare const asyncReconciler: Reconciler.Reconciler<AsyncHostContext & {
5
4
  refId: number;
6
5
  } & {
7
6
  component: import("../../..").ReactUnity.IReactComponent;
8
- fiberCache: ObjectsRepo<any>;
7
+ fiberCache: import("./objects").ObjectsRepo<any>;
9
8
  }, import("./types").AsyncNativeInstance, import("./types").AsyncNativeInstance, import("./types").AsyncNativeInstance, import("../../..").ReactUnity.IReactComponent>;
@@ -12,38 +12,8 @@ var __assign = (this && this.__assign) || function () {
12
12
  import * as Reconciler from 'react-reconciler';
13
13
  import { commonReconciler, getAllowedProps, textTypes } from '../constants';
14
14
  import { diffProperties } from '../diffing';
15
- import { CallbacksRepo } from './callbacks';
16
- import { ObjectsRepo } from './objects';
15
+ import { callbacksRepo, convertPropsToSerializable, objectsRepo } from './serializer';
17
16
  var refId = 0;
18
- var callbacks = new CallbacksRepo();
19
- var objects = new ObjectsRepo();
20
- // Separates properties in 3 categories: regular props, callbacks and non-serializable objects
21
- function partitionProps(props) {
22
- var res = {};
23
- for (var key in props) {
24
- if (Object.prototype.hasOwnProperty.call(props, key)) {
25
- var value = props[key];
26
- if (value == null) {
27
- (res.p || (res.p = {}))[key] = null;
28
- }
29
- else if (key === 'style') {
30
- (res.p || (res.p = {}))[key] = partitionProps(value);
31
- }
32
- else if (typeof value === 'function') {
33
- var ind = callbacks.addObject(value);
34
- (res.e || (res.e = {}))[key] = ind;
35
- }
36
- else if (typeof value === 'object') {
37
- var ind = objects.addObject(value);
38
- (res.o || (res.o = {}))[key] = ind;
39
- }
40
- else {
41
- (res.p || (res.p = {}))[key] = value;
42
- }
43
- }
44
- }
45
- return res;
46
- }
47
17
  var ctxMap = new Map();
48
18
  var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext: function (rootContainer) {
49
19
  var context = rootContainer.context;
@@ -62,13 +32,13 @@ var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext:
62
32
  return serialized;
63
33
  };
64
34
  var fireEventByRef = function (ind, args) {
65
- return callbacks.call(ind, args);
35
+ return callbacksRepo.call(ind, args);
66
36
  };
67
37
  var getObjectRef = function (ind) {
68
- return objects.getObject(ind);
38
+ return objectsRepo.getObject(ind);
69
39
  };
70
40
  var getEventAsObjectRef = function (ind) {
71
- return callbacks.getObject(ind);
41
+ return callbacksRepo.getObject(ind);
72
42
  };
73
43
  context.BindCommands(flushCommands, fireEventByRef, getObjectRef, getEventAsObjectRef);
74
44
  var ctx = {
@@ -86,7 +56,7 @@ var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext:
86
56
  }, createInstance: function (type, props, rootContainer, ctx, internalHandle) {
87
57
  refId++;
88
58
  var aProps = getAllowedProps(props, type);
89
- ctx.commands.push(['c', __assign({ t: type, r: refId }, partitionProps(aProps))]);
59
+ ctx.commands.push(['c', __assign({ t: type, r: refId }, convertPropsToSerializable(aProps))]);
90
60
  if (rootContainer.fiberCache)
91
61
  rootContainer.fiberCache.setObject(refId, internalHandle);
92
62
  return __assign(__assign({}, ctx), { refId: refId });
@@ -106,7 +76,7 @@ var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext:
106
76
  return diffProperties(oldProps, newProps);
107
77
  }, commitUpdate: function (instance, updatePayload, type) {
108
78
  var props = getAllowedProps(updatePayload, type);
109
- instance.commands.push(['u', __assign({ r: instance.refId, t: type }, partitionProps(props))]);
79
+ instance.commands.push(['u', __assign({ r: instance.refId, t: type }, convertPropsToSerializable(props))]);
110
80
  }, commitTextUpdate: function (textInstance, oldText, newText) {
111
81
  textInstance.commands.push(['x', { r: textInstance.refId, c: newText }]);
112
82
  }, appendChild: function (parent, child) {
@@ -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
+ }
@@ -31,6 +31,7 @@ export var Renderer = {
31
31
  args[_i] = arguments[_i];
32
32
  }
33
33
  if (!scheduled_1) {
34
+ scheduled_1 = true;
34
35
  Promise.resolve().then(function () {
35
36
  asyncJobCallback();
36
37
  scheduled_1 = false;
@@ -1 +1 @@
1
- export declare const version = "0.10.0";
1
+ export declare const version = "0.10.1";
@@ -1 +1 @@
1
- export var version = '0.10.0';
1
+ export var version = '0.10.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactunity/renderer",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "React renderer for Unity3D",
5
5
  "types": "dist/index.d.ts",
6
6
  "typings": "dist/index.d.ts",