@reactunity/renderer 0.13.1 → 0.14.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.
- package/dist/src/helpers/dictionary-watcher.d.ts +1 -0
- package/dist/src/helpers/dictionary-watcher.js +3 -2
- package/dist/src/helpers/icons.d.ts +2 -2
- package/dist/src/models/base.d.ts +13 -8
- package/dist/src/models/editor/components.d.ts +2 -2
- package/dist/src/models/editor/events.d.ts +4 -4
- package/dist/src/models/editor/jsx.d.ts +5 -5
- package/dist/src/models/environment/dom/common.d.ts +5 -5
- package/dist/src/models/environment/dom/fetch.d.ts +10 -10
- package/dist/src/models/environment/dom/xhr.d.ts +2 -2
- package/dist/src/models/environment/interop.d.ts +2 -2
- package/dist/src/models/generated/editor.d.ts +15016 -11979
- package/dist/src/models/generated/editor.js +1 -1
- package/dist/src/models/generated/react.d.ts +1935 -576
- package/dist/src/models/generated/react.js +1 -1
- package/dist/src/models/generated/system.d.ts +2602 -2704
- package/dist/src/models/generated/system.js +2 -2
- package/dist/src/models/generated/tests.d.ts +228 -231
- package/dist/src/models/generated/tests.js +1 -1
- package/dist/src/models/generated/unity.d.ts +7998 -14519
- package/dist/src/models/generated/unity.js +2 -2
- package/dist/src/models/generated/yoga.d.ts +1 -1
- package/dist/src/models/generated/yoga.js +1 -1
- package/dist/src/models/properties/colors.d.ts +1 -1
- package/dist/src/models/properties/style.d.ts +7 -2
- package/dist/src/models/properties/styles-enums.d.ts +24 -18
- package/dist/src/models/properties/styles.d.ts +77 -59
- package/dist/src/models/properties/values.d.ts +16 -16
- package/dist/src/models/properties/yoga-enums.d.ts +8 -8
- package/dist/src/models/properties/yoga.d.ts +16 -17
- package/dist/src/models/renderer.d.ts +14 -14
- package/dist/src/models/richtext.d.ts +2 -2
- package/dist/src/models/svg.d.ts +2 -2
- package/dist/src/models/ugui/components.d.ts +2 -5
- package/dist/src/models/ugui/events.d.ts +7 -7
- package/dist/src/models/ugui/input.d.ts +6 -6
- package/dist/src/models/ugui/jsx.d.ts +2 -2
- package/dist/src/models/uitoolkit/components.d.ts +2 -2
- package/dist/src/models/uitoolkit/events.d.ts +4 -4
- package/dist/src/models/uitoolkit/jsx.d.ts +2 -2
- package/dist/src/renderer/async/commands.d.ts +16 -14
- package/dist/src/renderer/async/reconciler.js +2 -2
- package/dist/src/renderer/async/types.d.ts +10 -10
- package/dist/src/renderer/constants.d.ts +2 -0
- package/dist/src/renderer/constants.js +10 -1
- package/dist/src/renderer/diffing.d.ts +1 -1
- package/dist/src/renderer/diffing.js +13 -5
- package/dist/src/renderer/renderer.js +3 -2
- package/dist/src/renderer/sync/reconciler.js +2 -2
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +5 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type BatchUpdateProps = {
|
|
2
2
|
[key: string]: string | number | object;
|
|
3
3
|
};
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type AsyncCallback = (...args: any[]) => any;
|
|
5
|
+
export type BatchUpdateCallbacks = {
|
|
6
6
|
[key: string]: number;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type ApplyUpdatesParams = {
|
|
9
9
|
t: string;
|
|
10
10
|
r: number;
|
|
11
11
|
c?: string;
|
|
@@ -13,33 +13,35 @@ declare type ApplyUpdatesParams = {
|
|
|
13
13
|
e?: BatchUpdateCallbacks;
|
|
14
14
|
o?: BatchUpdateCallbacks;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
17
|
-
|
|
16
|
+
export type CreateInstanceCommand = ['c', ApplyUpdatesParams & {
|
|
17
|
+
k?: string;
|
|
18
|
+
}];
|
|
19
|
+
export type CreateTextInstanceCommand = ['t', {
|
|
18
20
|
r: number;
|
|
19
21
|
c?: string;
|
|
20
22
|
}];
|
|
21
|
-
export
|
|
23
|
+
export type AppendChildCommand = ['a', {
|
|
22
24
|
p: number;
|
|
23
25
|
c: number;
|
|
24
26
|
}];
|
|
25
|
-
export
|
|
27
|
+
export type RemoveChildCommand = ['r', {
|
|
26
28
|
p: number;
|
|
27
29
|
c: number;
|
|
28
30
|
}];
|
|
29
|
-
export
|
|
31
|
+
export type InsertChildCommand = ['i', {
|
|
30
32
|
p: number;
|
|
31
33
|
c: number;
|
|
32
34
|
i?: number;
|
|
33
35
|
}];
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
+
export type ApplyUpdatesCommand = ['u', ApplyUpdatesParams];
|
|
37
|
+
export type TextUpdateCommand = ['x', {
|
|
36
38
|
r: number;
|
|
37
39
|
c: string;
|
|
38
40
|
}];
|
|
39
|
-
export
|
|
41
|
+
export type ToggleHideCommand = ['h', {
|
|
40
42
|
r: number;
|
|
41
43
|
h: boolean;
|
|
42
44
|
}];
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
+
export type ClearContainerCommand = ['o'];
|
|
46
|
+
export type BatchCommand = CreateInstanceCommand | CreateTextInstanceCommand | AppendChildCommand | RemoveChildCommand | InsertChildCommand | ApplyUpdatesCommand | TextUpdateCommand | ToggleHideCommand | ClearContainerCommand | null;
|
|
45
47
|
export {};
|
|
@@ -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 });
|
|
@@ -3,31 +3,31 @@ import { ReactUnity } from '../../models/generated';
|
|
|
3
3
|
import { ChildSet, HydratableInstance, InstanceTag, NoTimeout, Props, TimeoutHandle, UpdatePayload } from '../../models/renderer';
|
|
4
4
|
import { BatchCommand } from './commands';
|
|
5
5
|
import { ObjectsRepo } from './objects';
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
6
|
+
export type AsyncHostContext = AsyncNativeInstance | AsyncSubContext;
|
|
7
|
+
export type AsyncInstance = AsyncNativeInstance | AsyncSubContext;
|
|
8
|
+
export type AsyncNativeInstance = {
|
|
9
9
|
context: ReactUnity.ReactContext;
|
|
10
10
|
commands: BatchCommand[];
|
|
11
11
|
refId: number;
|
|
12
12
|
type: 'native';
|
|
13
13
|
subContext?: AsyncSubContext;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export type AsyncSubContext = RichTextContext | SvgContext;
|
|
16
|
+
export type RichTextContext = {
|
|
17
17
|
hostContext: AsyncNativeInstance;
|
|
18
18
|
type: 'richtext';
|
|
19
19
|
node: RichTextNode;
|
|
20
20
|
root: AsyncNativeInstance;
|
|
21
21
|
parent: RichTextContext;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type SvgContext = {
|
|
24
24
|
hostContext: AsyncNativeInstance;
|
|
25
25
|
type: 'svg';
|
|
26
26
|
node: RichTextNode;
|
|
27
27
|
root: AsyncNativeInstance;
|
|
28
28
|
parent: SvgContext;
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type RichTextNode = ({
|
|
31
31
|
tag: string;
|
|
32
32
|
attributes: Record<string, any>;
|
|
33
33
|
children: RichTextNode[];
|
|
@@ -36,10 +36,10 @@ export declare type RichTextNode = ({
|
|
|
36
36
|
text: string;
|
|
37
37
|
hidden?: boolean;
|
|
38
38
|
});
|
|
39
|
-
export
|
|
39
|
+
export type AsyncContainerInstance = AsyncNativeInstance & {
|
|
40
40
|
component: ReactUnity.IReactComponent;
|
|
41
41
|
fiberCache: ObjectsRepo | null;
|
|
42
42
|
};
|
|
43
|
-
|
|
44
|
-
export
|
|
43
|
+
type AsyncPublicInstance = ReactUnity.IReactComponent;
|
|
44
|
+
export type AsyncReconcilerConfig = Reconciler.HostConfig<InstanceTag, Props, AsyncContainerInstance, AsyncInstance, AsyncInstance, AsyncNativeInstance, HydratableInstance, AsyncPublicInstance, AsyncHostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>;
|
|
45
45
|
export {};
|
|
@@ -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,3 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type DiffResult = null | Record<string, any>;
|
|
2
2
|
export declare const styleStringSymbol = "__style_as_string__";
|
|
3
3
|
export declare function diffProperties(lastProps: Record<string, any>, nextProps: Record<string, any>, deepDiffing?: number): DiffResult;
|
|
@@ -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
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
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(
|
|
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(
|
|
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]; },
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.14.0";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '0.
|
|
1
|
+
export var version = '0.14.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactunity/renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "React renderer for Unity3D",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"react": "^18.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@reactunity/scripts": "^0.
|
|
65
|
-
"@types/react-reconciler": "^0.28.
|
|
66
|
-
"rimraf": "^
|
|
67
|
-
"typescript": "^4.
|
|
64
|
+
"@reactunity/scripts": "^0.14.0",
|
|
65
|
+
"@types/react-reconciler": "^0.28.2",
|
|
66
|
+
"rimraf": "^4.0.6",
|
|
67
|
+
"typescript": "^4.9.4"
|
|
68
68
|
}
|
|
69
69
|
}
|