@reactunity/renderer 0.9.0 → 0.9.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.
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export * from './src/models/environment';
|
|
|
5
5
|
export * from './src/models/generated';
|
|
6
6
|
export * from './src/models/properties';
|
|
7
7
|
export * from './src/models/renderer';
|
|
8
|
-
export { Renderer } from './src/renderer/renderer';
|
|
8
|
+
export { batchedUpdates, batchedUpdates as unstable_batchedUpdates, flushSync, Renderer } from './src/renderer/renderer';
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export * from './src/models/environment';
|
|
|
5
5
|
export * from './src/models/generated';
|
|
6
6
|
export * from './src/models/properties';
|
|
7
7
|
export * from './src/models/renderer';
|
|
8
|
-
export { Renderer } from './src/renderer/renderer';
|
|
8
|
+
export { batchedUpdates, batchedUpdates as unstable_batchedUpdates, flushSync, Renderer } from './src/renderer/renderer';
|
|
@@ -19,7 +19,7 @@ export function createDictionaryWatcher(dictionary, displayName) {
|
|
|
19
19
|
var ctx = React.createContext(undefined);
|
|
20
20
|
if (displayName)
|
|
21
21
|
ctx.displayName = displayName;
|
|
22
|
-
var Provider = function
|
|
22
|
+
var Provider = function GlobalsProvider(_a) {
|
|
23
23
|
var children = _a.children;
|
|
24
24
|
var _b = React.useState(0), render = _b[0], setRender = _b[1];
|
|
25
25
|
React.useLayoutEffect(function () {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { NativeContainerInstance } from '../models/renderer';
|
|
3
3
|
export declare const Renderer: {
|
|
4
|
-
render(element: React.ReactNode, hostContainer?: NativeContainerInstance, renderWithoutHelpers?: boolean):
|
|
4
|
+
render(element: React.ReactNode, hostContainer?: NativeContainerInstance, renderWithoutHelpers?: boolean): void;
|
|
5
5
|
};
|
|
6
|
+
export declare const batchedUpdates: <A, R>(fn: (a: A) => R, a: A) => R;
|
|
7
|
+
export declare const flushSync: <A, R>(fn: (a: A) => R, a: A) => R;
|
|
@@ -13,8 +13,18 @@ import { createElement } from 'react';
|
|
|
13
13
|
import * as Reconciler from 'react-reconciler';
|
|
14
14
|
import { DefaultView } from '../views/default-view';
|
|
15
15
|
import { diffProperties, styleStringSymbol } from './diffing';
|
|
16
|
+
var LegacyRoot = 1;
|
|
17
|
+
var ConcurrentRoot = 1;
|
|
16
18
|
var hostContext = {};
|
|
17
19
|
var childContext = {};
|
|
20
|
+
var DiscreteEventPriority = 1;
|
|
21
|
+
var ContinuousEventPriority = 4;
|
|
22
|
+
var DefaultEventPriority = 16;
|
|
23
|
+
var eventPriorities = {
|
|
24
|
+
discrete: DiscreteEventPriority,
|
|
25
|
+
continuous: ContinuousEventPriority,
|
|
26
|
+
default: DefaultEventPriority,
|
|
27
|
+
};
|
|
18
28
|
var textTypes = {
|
|
19
29
|
text: true,
|
|
20
30
|
icon: true,
|
|
@@ -31,43 +41,44 @@ function getAllowedProps(props, type) {
|
|
|
31
41
|
return rest;
|
|
32
42
|
}
|
|
33
43
|
var hostConfig = {
|
|
34
|
-
getRootHostContext: function (
|
|
35
|
-
getChildHostContext: function (
|
|
44
|
+
getRootHostContext: function () { return hostContext; },
|
|
45
|
+
getChildHostContext: function () { return childContext; },
|
|
36
46
|
getPublicInstance: function (instance) { return instance; },
|
|
37
|
-
prepareForCommit: function (containerInfo) { return null; },
|
|
38
|
-
resetAfterCommit: function (containerInfo) { return null; },
|
|
39
|
-
clearContainer: function () { return null; },
|
|
40
47
|
now: Date.now,
|
|
48
|
+
supportsMutation: true,
|
|
41
49
|
supportsHydration: false,
|
|
42
50
|
supportsPersistence: false,
|
|
51
|
+
supportsMicrotasks: false,
|
|
52
|
+
supportsTestSelectors: false,
|
|
43
53
|
isPrimaryRenderer: true,
|
|
44
|
-
|
|
54
|
+
warnsIfNotActing: true,
|
|
55
|
+
prepareForCommit: function () { return null; },
|
|
56
|
+
resetAfterCommit: function () { },
|
|
57
|
+
clearContainer: function () { },
|
|
58
|
+
shouldDeprioritizeSubtree: function () { return false; },
|
|
59
|
+
createInstance: function (type, props, rootContainerInstance) {
|
|
45
60
|
var aProps = getAllowedProps(props, type);
|
|
46
61
|
var children = aProps.children || null;
|
|
47
62
|
delete aProps.children;
|
|
48
63
|
return UnityBridge.createElement(props.tag || type, children, rootContainerInstance, aProps);
|
|
49
64
|
},
|
|
50
|
-
createTextInstance: function (text, rootContainerInstance
|
|
65
|
+
createTextInstance: function (text, rootContainerInstance) {
|
|
51
66
|
return UnityBridge.createText(text, rootContainerInstance);
|
|
52
67
|
},
|
|
53
68
|
appendInitialChild: function (parent, child) { UnityBridge.appendChild(parent, child); },
|
|
54
|
-
finalizeInitialChildren: function (
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
commitMount: function (instance, type, newProps, internalInstanceHandle) { },
|
|
58
|
-
shouldSetTextContent: function (type, props) { return textTypes[type]; },
|
|
59
|
-
shouldDeprioritizeSubtree: function (type, props) { return false; },
|
|
69
|
+
finalizeInitialChildren: function () { return false; },
|
|
70
|
+
commitMount: function () { },
|
|
71
|
+
shouldSetTextContent: function (type) { return textTypes[type]; },
|
|
60
72
|
// -------------------
|
|
61
73
|
// Mutation
|
|
62
74
|
// -------------------
|
|
63
|
-
|
|
64
|
-
prepareUpdate: function (instance, type, oldProps, newProps, rootContainerInstance, hostContext) {
|
|
75
|
+
prepareUpdate: function (instance, type, oldProps, newProps) {
|
|
65
76
|
return diffProperties(oldProps, newProps);
|
|
66
77
|
},
|
|
67
|
-
commitUpdate: function (instance, updatePayload, type
|
|
78
|
+
commitUpdate: function (instance, updatePayload, type) {
|
|
68
79
|
UnityBridge.applyUpdate(instance, getAllowedProps(updatePayload, type), type);
|
|
69
80
|
},
|
|
70
|
-
resetTextContent: function (
|
|
81
|
+
resetTextContent: function () { return console.log('resetTextContent'); },
|
|
71
82
|
commitTextUpdate: function (textInstance, oldText, newText) { UnityBridge.setText(textInstance, newText); },
|
|
72
83
|
appendChild: function (parent, child) { return UnityBridge.appendChild(parent, child); },
|
|
73
84
|
appendChildToContainer: function (parent, child) { return UnityBridge.appendChildToContainer(parent, child); },
|
|
@@ -78,35 +89,34 @@ var hostConfig = {
|
|
|
78
89
|
// Required for Suspense
|
|
79
90
|
// TODO: implement
|
|
80
91
|
preparePortalMount: function () { },
|
|
81
|
-
hideInstance: function (
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
unhideTextInstance: function (textInstance, text) {
|
|
88
|
-
},
|
|
92
|
+
hideInstance: function () { },
|
|
93
|
+
hideTextInstance: function () { },
|
|
94
|
+
unhideInstance: function () { },
|
|
95
|
+
unhideTextInstance: function () { },
|
|
96
|
+
detachDeletedInstance: function () { },
|
|
89
97
|
// -------------------
|
|
90
98
|
// Scheduling
|
|
91
99
|
// -------------------
|
|
92
|
-
|
|
93
|
-
cancelDeferredCallback: function (callBackID) { clearTimeout(callBackID); },
|
|
100
|
+
getCurrentEventPriority: function () { return eventPriorities.default; },
|
|
94
101
|
noTimeout: -1,
|
|
95
102
|
scheduleTimeout: function (callback, timeout) { return setTimeout(callback, timeout); },
|
|
96
|
-
cancelTimeout: function (handle) { clearTimeout(handle); },
|
|
97
|
-
queueMicrotask: function (callback) { return setTimeout(callback, 0); },
|
|
103
|
+
cancelTimeout: function (handle) { return clearTimeout(handle); },
|
|
98
104
|
};
|
|
99
|
-
var
|
|
105
|
+
var reconciler = Reconciler(hostConfig);
|
|
100
106
|
var containerMap = new Map();
|
|
101
107
|
export var Renderer = {
|
|
102
108
|
render: function (element, hostContainer, renderWithoutHelpers) {
|
|
103
109
|
if (!hostContainer)
|
|
104
110
|
hostContainer = HostContainer;
|
|
105
111
|
var hostRoot = containerMap.get(hostContainer);
|
|
106
|
-
if (!hostRoot)
|
|
107
|
-
|
|
112
|
+
if (!hostRoot) {
|
|
113
|
+
hostRoot = reconciler.createContainer(hostContainer, LegacyRoot, false, null);
|
|
114
|
+
containerMap.set(hostContainer, hostRoot);
|
|
115
|
+
}
|
|
108
116
|
if (!renderWithoutHelpers)
|
|
109
117
|
element = createElement(DefaultView, null, element);
|
|
110
|
-
|
|
118
|
+
reconciler.updateContainer(element, hostRoot, null);
|
|
111
119
|
},
|
|
112
120
|
};
|
|
121
|
+
export var batchedUpdates = reconciler.batchedUpdates;
|
|
122
|
+
export var flushSync = reconciler.flushSync;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactunity/renderer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
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": "^17.0.2"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@reactunity/scripts": "^0.
|
|
64
|
+
"@reactunity/scripts": "^0.9.0",
|
|
65
65
|
"@types/react-reconciler": "^0.26.4",
|
|
66
66
|
"rimraf": "^3.0.2",
|
|
67
|
-
"typescript": "^4.
|
|
67
|
+
"typescript": "^4.5.5"
|
|
68
68
|
}
|
|
69
69
|
}
|