@reactunity/renderer 0.16.1 → 0.16.3
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/editor/index.js +1 -17
- package/dist/editor/jsx-dev-runtime.js +1 -17
- package/dist/editor/jsx-runtime.js +1 -17
- package/dist/index.js +9 -31
- package/dist/src/helpers/dictionary-watcher.js +14 -18
- package/dist/src/helpers/hooks/use-globals.js +6 -9
- package/dist/src/helpers/hooks/use-reactive-value.js +5 -9
- package/dist/src/helpers/icons.js +2 -5
- package/dist/src/models/base.js +1 -2
- package/dist/src/models/editor/components.js +1 -2
- package/dist/src/models/editor/environment.js +1 -2
- package/dist/src/models/editor/index.js +3 -19
- package/dist/src/models/editor/jsx.js +1 -2
- package/dist/src/models/environment/dom/common.js +1 -2
- package/dist/src/models/environment/dom/fetch.js +1 -2
- package/dist/src/models/environment/dom/global.js +1 -2
- package/dist/src/models/environment/dom/xhr.js +1 -2
- package/dist/src/models/environment/index.js +2 -18
- package/dist/src/models/environment/interop.js +1 -2
- package/dist/src/models/generated/editor.js +1 -2
- package/dist/src/models/generated/index.js +6 -22
- package/dist/src/models/generated/react.js +1 -2
- package/dist/src/models/generated/system.js +1 -2
- package/dist/src/models/generated/tests.js +1 -2
- package/dist/src/models/generated/unity.js +1 -2
- package/dist/src/models/generated/yoga.js +1 -2
- package/dist/src/models/properties/colors.js +1 -2
- package/dist/src/models/properties/common.d.ts +1 -0
- package/dist/src/models/properties/common.js +1 -2
- package/dist/src/models/properties/index.js +7 -23
- package/dist/src/models/properties/style.js +1 -2
- package/dist/src/models/properties/styles-enums.js +1 -2
- package/dist/src/models/properties/styles.js +1 -2
- package/dist/src/models/properties/values.js +1 -2
- package/dist/src/models/properties/yoga-enums.js +1 -2
- package/dist/src/models/properties/yoga.js +1 -2
- package/dist/src/models/renderer.js +1 -2
- package/dist/src/models/richtext.js +1 -2
- package/dist/src/models/svg.js +1 -2
- package/dist/src/models/tests/index.js +1 -2
- package/dist/src/models/ugui/components.d.ts +1 -2
- package/dist/src/models/ugui/components.js +1 -2
- package/dist/src/models/ugui/events.js +1 -2
- package/dist/src/models/ugui/index.js +4 -20
- package/dist/src/models/ugui/input.js +1 -2
- package/dist/src/models/ugui/jsx.js +1 -2
- package/dist/src/models/uitoolkit/components.d.ts +9 -1
- package/dist/src/models/uitoolkit/components.js +1 -2
- package/dist/src/models/uitoolkit/events.js +1 -2
- package/dist/src/models/uitoolkit/index.js +3 -19
- package/dist/src/models/uitoolkit/jsx.d.ts +1 -1
- package/dist/src/models/uitoolkit/jsx.js +1 -2
- package/dist/src/renderer/async/callbacks.js +3 -6
- package/dist/src/renderer/async/commands.js +1 -2
- package/dist/src/renderer/async/objects.js +1 -4
- package/dist/src/renderer/async/reconciler.js +18 -21
- package/dist/src/renderer/async/serializer.js +7 -11
- package/dist/src/renderer/async/types.js +1 -2
- package/dist/src/renderer/constants.js +16 -21
- package/dist/src/renderer/diffing.js +4 -8
- package/dist/src/renderer/renderer.js +21 -25
- package/dist/src/renderer/subcontexts/index.js +5 -8
- package/dist/src/renderer/subcontexts/richtext.js +2 -7
- package/dist/src/renderer/subcontexts/svg.js +2 -7
- package/dist/src/renderer/sync/reconciler.js +11 -14
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -4
- package/dist/src/views/default-view.js +5 -9
- package/dist/src/views/error-boundary.js +4 -7
- package/dist/src/webgl-compat/error-messages.js +1 -4
- package/dist/src/webgl-compat/index.js +6 -11
- package/dist/src/webgl-compat/types.js +1 -2
- package/dist/src/webgl-compat/use-event-system.js +8 -13
- package/dist/src/webgl-compat/use-unity-context.js +13 -17
- package/dist/tests.js +1 -17
- package/dist/ugui/index.js +1 -17
- package/dist/ugui/jsx-dev-runtime.js +1 -17
- package/dist/ugui/jsx-runtime.js +1 -17
- package/dist/uitoolkit/index.js +1 -17
- package/dist/uitoolkit/jsx-dev-runtime.js +1 -17
- package/dist/uitoolkit/jsx-runtime.js +1 -17
- package/dist/webgl-compat.js +1 -17
- package/package.json +1 -1
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./components"), exports);
|
|
18
|
-
__exportStar(require("./events"), exports);
|
|
19
|
-
__exportStar(require("./jsx"), exports);
|
|
1
|
+
export * from './components';
|
|
2
|
+
export * from './events';
|
|
3
|
+
export * from './jsx';
|
|
@@ -19,7 +19,7 @@ export interface UIToolkitElements extends BaseElements<BaseElement<any>> {
|
|
|
19
19
|
richtext: Components.View & rc.RefAttributes<Cmp.TextComponent> & Children<Textable | Textable[]>;
|
|
20
20
|
label: Components.View & rc.RefAttributes<Cmp.TextComponent> & Children<Textable | Textable[]>;
|
|
21
21
|
button: Components.Button & rc.RefAttributes<Cmp.ButtonComponent> & Children;
|
|
22
|
-
scroll:
|
|
22
|
+
scroll: Components.Scroll & rc.RefAttributes<Cmp.ScrollViewComponent> & Children;
|
|
23
23
|
svg: Components.Svg & rc.RefAttributes<Cmp.SvgComponent> & Children<any> & SVGEelement;
|
|
24
24
|
img: Components.Image & rc.RefAttributes<Cmp.ImageComponent> & Children<never>;
|
|
25
25
|
image: Components.Image & rc.RefAttributes<Cmp.ImageComponent> & Children<never>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __extends = (this && this.__extends) || (function () {
|
|
3
2
|
var extendStatics = function (d, b) {
|
|
4
3
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -14,9 +13,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
14
|
};
|
|
16
15
|
})();
|
|
17
|
-
|
|
18
|
-
exports.CallbacksRepo = void 0;
|
|
19
|
-
var objects_1 = require("./objects");
|
|
16
|
+
import { ObjectsRepo } from './objects';
|
|
20
17
|
var CallbacksRepo = /** @class */ (function (_super) {
|
|
21
18
|
__extends(CallbacksRepo, _super);
|
|
22
19
|
function CallbacksRepo() {
|
|
@@ -51,5 +48,5 @@ var CallbacksRepo = /** @class */ (function (_super) {
|
|
|
51
48
|
return _this;
|
|
52
49
|
}
|
|
53
50
|
return CallbacksRepo;
|
|
54
|
-
}(
|
|
55
|
-
|
|
51
|
+
}(ObjectsRepo));
|
|
52
|
+
export { CallbacksRepo };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ObjectsRepo = void 0;
|
|
4
1
|
var ObjectsRepo = /** @class */ (function () {
|
|
5
2
|
function ObjectsRepo() {
|
|
6
3
|
var _this = this;
|
|
@@ -31,4 +28,4 @@ var ObjectsRepo = /** @class */ (function () {
|
|
|
31
28
|
}
|
|
32
29
|
return ObjectsRepo;
|
|
33
30
|
}());
|
|
34
|
-
|
|
31
|
+
export { ObjectsRepo };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __assign = (this && this.__assign) || function () {
|
|
3
2
|
__assign = Object.assign || function(t) {
|
|
4
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -10,17 +9,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
9
|
};
|
|
11
10
|
return __assign.apply(this, arguments);
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var subcontexts_1 = require("../subcontexts");
|
|
19
|
-
var serializer_1 = require("./serializer");
|
|
12
|
+
import * as Reconciler from 'react-reconciler';
|
|
13
|
+
import { commonReconciler, getAllowedProps, stringizePoolKey, textTypes } from '../constants';
|
|
14
|
+
import { diffProperties } from '../diffing';
|
|
15
|
+
import { subContextRenderers } from '../subcontexts';
|
|
16
|
+
import { callbacksRepo, convertPropsToSerializable, objectsRepo } from './serializer';
|
|
20
17
|
var refId = 0;
|
|
21
18
|
var ctxMap = new Map();
|
|
22
19
|
var updateSubContext = function (instance) {
|
|
23
|
-
var rend =
|
|
20
|
+
var rend = subContextRenderers[instance.type];
|
|
24
21
|
var root = instance === null || instance === void 0 ? void 0 : instance.root;
|
|
25
22
|
var cur = instance;
|
|
26
23
|
while (cur && !root) {
|
|
@@ -36,10 +33,10 @@ var updateSubContext = function (instance) {
|
|
|
36
33
|
}
|
|
37
34
|
else if (instance.type === 'svg') {
|
|
38
35
|
// instance.hostContext.commands.push(['u', { r: root.refId, t: 'svg', ...convertPropsToSerializable({ innerContent: content }) }]);
|
|
39
|
-
instance.hostContext.commands.push([5, root.refId, 'svg',
|
|
36
|
+
instance.hostContext.commands.push([5, root.refId, 'svg', convertPropsToSerializable({ innerContent: content })]);
|
|
40
37
|
}
|
|
41
38
|
};
|
|
42
|
-
var hostConfig = __assign(__assign({},
|
|
39
|
+
var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext: function (rootContainer) {
|
|
43
40
|
var context = rootContainer.context;
|
|
44
41
|
if (rootContainer.refId < 0) {
|
|
45
42
|
refId++;
|
|
@@ -56,13 +53,13 @@ var hostConfig = __assign(__assign({}, constants_1.commonReconciler), { getRootH
|
|
|
56
53
|
return serialized;
|
|
57
54
|
};
|
|
58
55
|
var fireEventByRef = function (ind, args) {
|
|
59
|
-
return
|
|
56
|
+
return callbacksRepo.call(ind, args);
|
|
60
57
|
};
|
|
61
58
|
var getObjectRef = function (ind) {
|
|
62
|
-
return
|
|
59
|
+
return objectsRepo.getObject(ind);
|
|
63
60
|
};
|
|
64
61
|
var getEventAsObjectRef = function (ind) {
|
|
65
|
-
return
|
|
62
|
+
return callbacksRepo.getObject(ind);
|
|
66
63
|
};
|
|
67
64
|
context.BindCommands(flushCommands, fireEventByRef, getObjectRef, getEventAsObjectRef);
|
|
68
65
|
var ctx = {
|
|
@@ -98,11 +95,11 @@ var hostConfig = __assign(__assign({}, constants_1.commonReconciler), { getRootH
|
|
|
98
95
|
}, 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) {
|
|
99
96
|
UnityBridge.clearContainer(container);
|
|
100
97
|
}, createInstance: function (type, props, rootContainer, ctx, internalHandle) {
|
|
101
|
-
var aProps =
|
|
98
|
+
var aProps = getAllowedProps(props, type);
|
|
102
99
|
if (ctx.type === 'native') {
|
|
103
100
|
refId++;
|
|
104
101
|
// ctx.commands.push(['c', { t: type, r: refId, k: stringizePoolKey(props.pool), ...convertPropsToSerializable(aProps) }]);
|
|
105
|
-
ctx.commands.push([0, refId, type,
|
|
102
|
+
ctx.commands.push([0, refId, type, convertPropsToSerializable(aProps), stringizePoolKey(props.pool)]);
|
|
106
103
|
if (rootContainer.fiberCache)
|
|
107
104
|
rootContainer.fiberCache.setObject(refId, internalHandle);
|
|
108
105
|
var res = __assign(__assign({}, ctx), { refId: refId });
|
|
@@ -170,17 +167,17 @@ var hostConfig = __assign(__assign({}, constants_1.commonReconciler), { getRootH
|
|
|
170
167
|
child.parent = parent;
|
|
171
168
|
updateSubContext(child);
|
|
172
169
|
}
|
|
173
|
-
}, finalizeInitialChildren: function () { return false; }, commitMount: function (instance) { }, shouldSetTextContent: function (type) { return
|
|
170
|
+
}, finalizeInitialChildren: function () { return false; }, commitMount: function (instance) { }, shouldSetTextContent: function (type) { return textTypes[type]; },
|
|
174
171
|
// -------------------
|
|
175
172
|
// Mutation
|
|
176
173
|
// -------------------
|
|
177
174
|
prepareUpdate: function (instance, type, oldProps, newProps) {
|
|
178
|
-
return
|
|
175
|
+
return diffProperties(oldProps, newProps);
|
|
179
176
|
}, commitUpdate: function (instance, updatePayload, type) {
|
|
180
|
-
var props =
|
|
177
|
+
var props = getAllowedProps(updatePayload, type);
|
|
181
178
|
if (instance.type === 'native') {
|
|
182
179
|
// instance.commands.push(['u', { r: instance.refId, t: type, ...convertPropsToSerializable(props) }]);
|
|
183
|
-
instance.commands.push([5, instance.refId, type,
|
|
180
|
+
instance.commands.push([5, instance.refId, type, convertPropsToSerializable(props)]);
|
|
184
181
|
}
|
|
185
182
|
else if (instance.type === 'richtext' || instance.type === 'svg') {
|
|
186
183
|
if ('attributes' in instance.node)
|
|
@@ -304,4 +301,4 @@ var hostConfig = __assign(__assign({}, constants_1.commonReconciler), { getRootH
|
|
|
304
301
|
updateSubContext(instance);
|
|
305
302
|
}
|
|
306
303
|
} });
|
|
307
|
-
|
|
304
|
+
export var asyncReconciler = Reconciler(hostConfig);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var objects_1 = require("./objects");
|
|
6
|
-
exports.callbacksRepo = new callbacks_1.CallbacksRepo();
|
|
7
|
-
exports.objectsRepo = new objects_1.ObjectsRepo();
|
|
1
|
+
import { CallbacksRepo } from './callbacks';
|
|
2
|
+
import { ObjectsRepo } from './objects';
|
|
3
|
+
export var callbacksRepo = new CallbacksRepo();
|
|
4
|
+
export var objectsRepo = new ObjectsRepo();
|
|
8
5
|
// Separates properties in 3 categories: regular props, callbacks and non-serializable objects
|
|
9
|
-
function convertPropsToSerializable(props) {
|
|
6
|
+
export function convertPropsToSerializable(props) {
|
|
10
7
|
var res = {};
|
|
11
8
|
for (var key in props) {
|
|
12
9
|
if (Object.prototype.hasOwnProperty.call(props, key)) {
|
|
@@ -18,11 +15,11 @@ function convertPropsToSerializable(props) {
|
|
|
18
15
|
(res.p || (res.p = {}))[key] = convertPropsToSerializable(value);
|
|
19
16
|
}
|
|
20
17
|
else if (key[0] === 'o' && key[1] === 'n' && typeof value === 'function') {
|
|
21
|
-
var ind =
|
|
18
|
+
var ind = callbacksRepo.addObject(value);
|
|
22
19
|
(res.e || (res.e = {}))[key] = ind;
|
|
23
20
|
}
|
|
24
21
|
else if (typeof value === 'object' || typeof value === 'function') {
|
|
25
|
-
var ind =
|
|
22
|
+
var ind = objectsRepo.addObject(value);
|
|
26
23
|
(res.o || (res.o = {}))[key] = ind;
|
|
27
24
|
}
|
|
28
25
|
else {
|
|
@@ -32,4 +29,3 @@ function convertPropsToSerializable(props) {
|
|
|
32
29
|
}
|
|
33
30
|
return res;
|
|
34
31
|
}
|
|
35
|
-
exports.convertPropsToSerializable = convertPropsToSerializable;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
2
|
var t = {};
|
|
4
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -10,24 +9,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
9
|
}
|
|
11
10
|
return t;
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
default: constants_1.DefaultEventPriority,
|
|
22
|
-
idle: constants_1.IdleEventPriority,
|
|
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,
|
|
23
20
|
};
|
|
24
|
-
|
|
21
|
+
export var textTypes = {
|
|
25
22
|
text: true,
|
|
26
23
|
icon: true,
|
|
27
24
|
style: true,
|
|
28
25
|
script: true,
|
|
29
26
|
};
|
|
30
|
-
function stringizePoolKey(key) {
|
|
27
|
+
export function stringizePoolKey(key) {
|
|
31
28
|
switch (typeof key) {
|
|
32
29
|
case 'string': return key;
|
|
33
30
|
case 'boolean': return key ? 'default' : '';
|
|
@@ -36,23 +33,21 @@ function stringizePoolKey(key) {
|
|
|
36
33
|
default: return '';
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
function getAllowedProps(props, type) {
|
|
36
|
+
export function getAllowedProps(props, type) {
|
|
41
37
|
var children = props.children, tag = props.tag, pool = props.pool, rest = __rest(props, ["children", "tag", "pool"]);
|
|
42
|
-
if (
|
|
38
|
+
if (textTypes[type] && 'children' in props) {
|
|
43
39
|
rest.children = (!children || typeof children === 'boolean') ? null : Array.isArray(children) ? children.join('') : children + '';
|
|
44
40
|
}
|
|
45
41
|
if (typeof props.style === 'string')
|
|
46
|
-
rest[
|
|
42
|
+
rest[styleStringSymbol] = props.style;
|
|
47
43
|
return rest;
|
|
48
44
|
}
|
|
49
|
-
|
|
50
|
-
exports.commonReconciler = {
|
|
45
|
+
export var commonReconciler = {
|
|
51
46
|
// -------------------
|
|
52
47
|
// Scheduling
|
|
53
48
|
// -------------------
|
|
54
49
|
now: Date.now,
|
|
55
|
-
getCurrentEventPriority: function () { return UnityBridge.CurrentEventPriority ||
|
|
50
|
+
getCurrentEventPriority: function () { return UnityBridge.CurrentEventPriority || eventPriorities.default; },
|
|
56
51
|
noTimeout: -1,
|
|
57
52
|
scheduleTimeout: function (callback, delay) { return setTimeout(callback, delay); },
|
|
58
53
|
scheduleMicrotask: typeof queueMicrotask === 'function' ? queueMicrotask :
|
|
@@ -72,4 +67,4 @@ exports.commonReconciler = {
|
|
|
72
67
|
prepareScopeUpdate: function (scopeInstance, instance) {
|
|
73
68
|
},
|
|
74
69
|
};
|
|
75
|
-
|
|
70
|
+
export var isDevelopment = process.env.NODE_ENV === 'development';
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.diffProperties = exports.styleStringSymbol = void 0;
|
|
4
|
-
exports.styleStringSymbol = '__style_as_string__';
|
|
1
|
+
export var styleStringSymbol = '__style_as_string__';
|
|
5
2
|
var propDepths = {
|
|
6
3
|
style: 1,
|
|
7
4
|
data: 1,
|
|
8
5
|
custom: 1,
|
|
9
6
|
};
|
|
10
|
-
function diffProperties(lastProps, nextProps, deepDiffing) {
|
|
7
|
+
export function diffProperties(lastProps, nextProps, deepDiffing) {
|
|
11
8
|
if (deepDiffing === void 0) { deepDiffing = 0; }
|
|
12
9
|
if (lastProps === nextProps)
|
|
13
10
|
return null;
|
|
@@ -23,7 +20,7 @@ function diffProperties(lastProps, nextProps, deepDiffing) {
|
|
|
23
20
|
var prop = null;
|
|
24
21
|
// If style existed in the previous properties as string, set it to null
|
|
25
22
|
if (propKey === 'style' && typeof lastProps.style === 'string') {
|
|
26
|
-
(updatePayload = updatePayload || {})[
|
|
23
|
+
(updatePayload = updatePayload || {})[styleStringSymbol] = null;
|
|
27
24
|
}
|
|
28
25
|
else {
|
|
29
26
|
var depth = deepDiffing > 0 ? deepDiffing : (propDepths[propKey] || 0);
|
|
@@ -51,7 +48,7 @@ function diffProperties(lastProps, nextProps, deepDiffing) {
|
|
|
51
48
|
var prevWasString = (typeof lastProp === 'string');
|
|
52
49
|
var curIsString = (typeof prop === 'string');
|
|
53
50
|
if (prevWasString !== curIsString) {
|
|
54
|
-
(updatePayload = updatePayload || {})[
|
|
51
|
+
(updatePayload = updatePayload || {})[styleStringSymbol] = typeof prop === 'string' ? prop : null;
|
|
55
52
|
if (curIsString) {
|
|
56
53
|
// Current style is string while previous is object, so revert all changes from the previous one
|
|
57
54
|
prop = diffProperties(lastProp, {}, 0);
|
|
@@ -84,4 +81,3 @@ function diffProperties(lastProps, nextProps, deepDiffing) {
|
|
|
84
81
|
}
|
|
85
82
|
return updatePayload;
|
|
86
83
|
}
|
|
87
|
-
exports.diffProperties = diffProperties;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var reconciler_1 = require("./async/reconciler");
|
|
10
|
-
var constants_2 = require("./constants");
|
|
11
|
-
var reconciler_2 = require("./sync/reconciler");
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { ConcurrentRoot, LegacyRoot } from 'react-reconciler/constants';
|
|
3
|
+
import { version } from '../version';
|
|
4
|
+
import { DefaultView } from '../views/default-view';
|
|
5
|
+
import { ObjectsRepo } from './async/objects';
|
|
6
|
+
import { asyncReconciler } from './async/reconciler';
|
|
7
|
+
import { isDevelopment } from './constants';
|
|
8
|
+
import { syncReconciler } from './sync/reconciler';
|
|
12
9
|
var containerMap = new Map();
|
|
13
10
|
var renderCount = 0;
|
|
14
|
-
function render(element, options) {
|
|
11
|
+
export function render(element, options) {
|
|
15
12
|
if (options === void 0) { options = {}; }
|
|
16
13
|
renderCount++;
|
|
17
14
|
var hostContainer = (options === null || options === void 0 ? void 0 : options.hostContainer) || HostContainer;
|
|
@@ -20,10 +17,10 @@ function render(element, options) {
|
|
|
20
17
|
var _a = containerMap.get(cacheKey) || {}, hostRoot = _a.hostRoot, asyncJobCallback = _a.asyncJobCallback;
|
|
21
18
|
var findFiberByHostInstance = function () { return null; };
|
|
22
19
|
if (!hostRoot) {
|
|
23
|
-
var mode = (options === null || options === void 0 ? void 0 : options.mode) === 'legacy' ?
|
|
20
|
+
var mode = (options === null || options === void 0 ? void 0 : options.mode) === 'legacy' ? LegacyRoot : ConcurrentRoot;
|
|
24
21
|
if (isAsync) {
|
|
25
|
-
var fiberCache_1 =
|
|
26
|
-
if (
|
|
22
|
+
var fiberCache_1 = isDevelopment ? new ObjectsRepo() : null;
|
|
23
|
+
if (isDevelopment) {
|
|
27
24
|
findFiberByHostInstance = function (instance) { return !instance ? null : fiberCache_1.getObject(instance.refId); };
|
|
28
25
|
}
|
|
29
26
|
var scheduled_1 = false;
|
|
@@ -57,10 +54,10 @@ function render(element, options) {
|
|
|
57
54
|
commands_1.length = 0;
|
|
58
55
|
hostContainerInstance_1.context.FlushCommands(serialized);
|
|
59
56
|
};
|
|
60
|
-
hostRoot =
|
|
57
|
+
hostRoot = asyncReconciler.createContainer(hostContainerInstance_1, mode, null, false, undefined, '', function (error) { return console.error(error); }, null);
|
|
61
58
|
}
|
|
62
59
|
else {
|
|
63
|
-
hostRoot =
|
|
60
|
+
hostRoot = syncReconciler.createContainer(hostContainer, mode, null, false, undefined, '', function (error) { return console.error(error); }, null);
|
|
64
61
|
}
|
|
65
62
|
containerMap.set(cacheKey, { hostRoot: hostRoot, asyncJobCallback: asyncJobCallback });
|
|
66
63
|
}
|
|
@@ -70,28 +67,27 @@ function render(element, options) {
|
|
|
70
67
|
withHelpers: !(options === null || options === void 0 ? void 0 : options.disableHelpers),
|
|
71
68
|
renderCount: renderCount,
|
|
72
69
|
};
|
|
73
|
-
element =
|
|
70
|
+
element = createElement(DefaultView, viewWrapperProps, element);
|
|
74
71
|
}
|
|
75
|
-
var rc = isAsync ?
|
|
72
|
+
var rc = isAsync ? asyncReconciler : syncReconciler;
|
|
76
73
|
rc.updateContainer(element, hostRoot, null);
|
|
77
74
|
rc.injectIntoDevTools({
|
|
78
|
-
bundleType:
|
|
79
|
-
version:
|
|
75
|
+
bundleType: isDevelopment ? 1 : 0,
|
|
76
|
+
version: version,
|
|
80
77
|
rendererPackageName: '@reactunity/renderer',
|
|
81
78
|
rendererConfig: { isAsync: isAsync },
|
|
82
79
|
findFiberByHostInstance: findFiberByHostInstance,
|
|
83
80
|
});
|
|
84
81
|
return rc;
|
|
85
82
|
}
|
|
86
|
-
exports.render = render;
|
|
87
83
|
/**
|
|
88
84
|
* @deprecated Instead, import `render` directly from `@reactunity/renderer`
|
|
89
85
|
*/
|
|
90
|
-
|
|
86
|
+
export var Renderer = {
|
|
91
87
|
render: function (element, options) {
|
|
92
88
|
if (options === void 0) { options = {}; }
|
|
93
89
|
return render(element, options);
|
|
94
90
|
},
|
|
95
91
|
};
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
export var batchedUpdates = asyncReconciler.batchedUpdates;
|
|
93
|
+
export var flushSync = asyncReconciler.flushSync;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.subContextRenderers = {
|
|
7
|
-
richtext: richtext_1.stringifyRichText,
|
|
8
|
-
svg: svg_1.stringifySVG,
|
|
1
|
+
import { stringifyRichText } from './richtext';
|
|
2
|
+
import { stringifySVG } from './svg';
|
|
3
|
+
export var subContextRenderers = {
|
|
4
|
+
richtext: stringifyRichText,
|
|
5
|
+
svg: stringifySVG,
|
|
9
6
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringifyRichText = exports.parametrizeValue = void 0;
|
|
4
|
-
function parametrizeValue(value) {
|
|
1
|
+
export function parametrizeValue(value) {
|
|
5
2
|
if (typeof value === 'number')
|
|
6
3
|
return value + '';
|
|
7
4
|
value = value + '';
|
|
@@ -9,8 +6,7 @@ function parametrizeValue(value) {
|
|
|
9
6
|
return '"' + value + '"';
|
|
10
7
|
return value;
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
function stringifyRichText(node) {
|
|
9
|
+
export function stringifyRichText(node) {
|
|
14
10
|
var _a, _b, _c;
|
|
15
11
|
if (node.hidden)
|
|
16
12
|
return '';
|
|
@@ -54,4 +50,3 @@ function stringifyRichText(node) {
|
|
|
54
50
|
}
|
|
55
51
|
return acc.join('');
|
|
56
52
|
}
|
|
57
|
-
exports.stringifyRichText = stringifyRichText;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringifySVG = exports.stringifyStyle = void 0;
|
|
4
1
|
function kebabize(str) {
|
|
5
2
|
return str.split('').map(function (letter, idx) {
|
|
6
3
|
return letter.toUpperCase() === letter
|
|
@@ -9,7 +6,7 @@ function kebabize(str) {
|
|
|
9
6
|
}).join('');
|
|
10
7
|
}
|
|
11
8
|
;
|
|
12
|
-
function stringifyStyle(style) {
|
|
9
|
+
export function stringifyStyle(style) {
|
|
13
10
|
if (typeof style === 'string')
|
|
14
11
|
return style;
|
|
15
12
|
var acc = [];
|
|
@@ -26,8 +23,7 @@ function stringifyStyle(style) {
|
|
|
26
23
|
}
|
|
27
24
|
return acc.join('');
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
function stringifySVG(node) {
|
|
26
|
+
export function stringifySVG(node) {
|
|
31
27
|
var _a;
|
|
32
28
|
if (node.hidden)
|
|
33
29
|
return '';
|
|
@@ -72,4 +68,3 @@ function stringifySVG(node) {
|
|
|
72
68
|
}
|
|
73
69
|
return acc.join('');
|
|
74
70
|
}
|
|
75
|
-
exports.stringifySVG = stringifySVG;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __assign = (this && this.__assign) || function () {
|
|
3
2
|
__assign = Object.assign || function(t) {
|
|
4
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -10,29 +9,27 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
9
|
};
|
|
11
10
|
return __assign.apply(this, arguments);
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var constants_1 = require("../constants");
|
|
17
|
-
var diffing_1 = require("../diffing");
|
|
12
|
+
import * as Reconciler from 'react-reconciler';
|
|
13
|
+
import { commonReconciler, getAllowedProps, hideClass, stringizePoolKey, textTypes } from '../constants';
|
|
14
|
+
import { diffProperties } from '../diffing';
|
|
18
15
|
var hostContext = {};
|
|
19
16
|
var childContext = {};
|
|
20
|
-
var hostConfig = __assign(__assign({},
|
|
21
|
-
var aProps =
|
|
17
|
+
var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext: function () { return hostContext; }, getChildHostContext: function () { return childContext; }, getPublicInstance: function (instance) { return instance; }, supportsMutation: true, supportsHydration: false, supportsPersistence: false, supportsMicrotasks: true, supportsTestSelectors: false, isPrimaryRenderer: true, warnsIfNotActing: true, prepareForCommit: function () { return null; }, resetAfterCommit: function () { }, clearContainer: function (container) { return UnityBridge.clearContainer(container); }, shouldDeprioritizeSubtree: function () { return false; }, createInstance: function (type, props, rootContainerInstance) {
|
|
18
|
+
var aProps = getAllowedProps(props, type);
|
|
22
19
|
var children = aProps.children || null;
|
|
23
20
|
delete aProps.children;
|
|
24
|
-
return UnityBridge.createElement(props.tag || type, children, rootContainerInstance, aProps,
|
|
21
|
+
return UnityBridge.createElement(props.tag || type, children, rootContainerInstance, aProps, stringizePoolKey(props.pool));
|
|
25
22
|
}, createTextInstance: function (text, rootContainerInstance) {
|
|
26
23
|
return UnityBridge.createText(text, rootContainerInstance);
|
|
27
|
-
}, appendInitialChild: function (parent, child) { UnityBridge.appendChild(parent, child); }, finalizeInitialChildren: function () { return false; }, commitMount: function () { }, shouldSetTextContent: function (type) { return
|
|
24
|
+
}, appendInitialChild: function (parent, child) { UnityBridge.appendChild(parent, child); }, finalizeInitialChildren: function () { return false; }, commitMount: function () { }, shouldSetTextContent: function (type) { return textTypes[type]; },
|
|
28
25
|
// -------------------
|
|
29
26
|
// Mutation
|
|
30
27
|
// -------------------
|
|
31
28
|
prepareUpdate: function (instance, type, oldProps, newProps) {
|
|
32
|
-
return
|
|
29
|
+
return diffProperties(oldProps, newProps);
|
|
33
30
|
}, commitUpdate: function (instance, updatePayload, type) {
|
|
34
|
-
UnityBridge.applyUpdate(instance,
|
|
31
|
+
UnityBridge.applyUpdate(instance, getAllowedProps(updatePayload, type), type);
|
|
35
32
|
}, commitTextUpdate: function (textInstance, oldText, newText) { UnityBridge.setText(textInstance, newText); }, appendChild: function (parent, child) { return UnityBridge.appendChild(parent, child); }, appendChildToContainer: function (parent, child) { return UnityBridge.appendChildToContainer(parent, child); }, insertBefore: function (parent, child, beforeChild) { return UnityBridge.insertBefore(parent, child, beforeChild); }, insertInContainerBefore: function (parent, child, beforeChild) { return UnityBridge.insertBefore(parent, child, beforeChild); }, removeChild: function (parent, child) { return UnityBridge.removeChild(parent, child); }, removeChildFromContainer: function (parent, child) { return UnityBridge.removeChild(parent, child); }, resetTextContent: function () { }, preparePortalMount: function () { }, detachDeletedInstance: function () { },
|
|
36
33
|
// Required for Suspense
|
|
37
|
-
hideInstance: function (instance) { instance.ClassList.Add(
|
|
38
|
-
|
|
34
|
+
hideInstance: function (instance) { instance.ClassList.Add(hideClass); }, hideTextInstance: function (instance) { instance.ClassList.Add(hideClass); }, unhideInstance: function (instance) { instance.ClassList.Remove(hideClass); }, unhideTextInstance: function (instance) { instance.ClassList.Remove(hideClass); } });
|
|
35
|
+
export var syncReconciler = Reconciler(hostConfig);
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.16.
|
|
1
|
+
export declare const version = "0.16.3";
|
package/dist/src/version.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
var error_boundary_1 = require("./error-boundary");
|
|
6
|
-
function DefaultView(_a) {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ErrorBoundary } from './error-boundary';
|
|
3
|
+
export function DefaultView(_a) {
|
|
7
4
|
var children = _a.children, withHelpers = _a.withHelpers, renderCount = _a.renderCount;
|
|
8
|
-
return (
|
|
9
|
-
(
|
|
5
|
+
return _jsx(_Fragment, { children: !withHelpers ? children :
|
|
6
|
+
_jsx(ErrorBoundary, { children: children }, renderCount) });
|
|
10
7
|
}
|
|
11
|
-
exports.DefaultView = DefaultView;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __extends = (this && this.__extends) || (function () {
|
|
3
2
|
var extendStatics = function (d, b) {
|
|
4
3
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -14,10 +13,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
13
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
14
|
};
|
|
16
15
|
})();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
20
|
-
var React = require("react");
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import * as React from 'react';
|
|
21
18
|
var ErrorBoundary = /** @class */ (function (_super) {
|
|
22
19
|
__extends(ErrorBoundary, _super);
|
|
23
20
|
function ErrorBoundary(props) {
|
|
@@ -36,10 +33,10 @@ var ErrorBoundary = /** @class */ (function (_super) {
|
|
|
36
33
|
ErrorBoundary.prototype.render = function () {
|
|
37
34
|
var _a, _b;
|
|
38
35
|
if (this.state.hasError) {
|
|
39
|
-
return (
|
|
36
|
+
return _jsxs("view", { id: '__react-unity-error-boundary', style: { color: 'crimson', padding: 20, fontSize: 16 }, children: [_jsx("view", { style: { marginBottom: '12px' }, children: ((_a = this.state.error) === null || _a === void 0 ? void 0 : _a.message) || '' }), _jsx("view", { children: ((_b = this.state.error) === null || _b === void 0 ? void 0 : _b.stack) || '' })] });
|
|
40
37
|
}
|
|
41
38
|
return this.props.children;
|
|
42
39
|
};
|
|
43
40
|
return ErrorBoundary;
|
|
44
41
|
}(React.Component));
|
|
45
|
-
|
|
42
|
+
export { ErrorBoundary };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Original file: https://github.com/jeffreylanters/react-unity-webgl/blob/main/module/source/constants/error-messages.ts
|
|
3
|
-
|
|
4
|
-
exports.errorMessages = void 0;
|
|
5
|
-
exports.errorMessages = {
|
|
2
|
+
export var errorMessages = {
|
|
6
3
|
genericNoUnityInstance: 'No Unity Instance found.',
|
|
7
4
|
requestFullscreenNoUnityInstance: 'Unable to Set Fullscreen while Unity is not Instantiated.',
|
|
8
5
|
requestPointerLockNoUnityInstanceOrCanvas: 'Unable to Request Pointer Lock while Unity is not Instantiated or the Canvas is not found.',
|