@reactunity/renderer 0.11.0 → 0.12.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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/src/helpers/icons.d.ts +7 -0
- package/dist/src/helpers/icons.js +29 -0
- package/dist/src/models/base.d.ts +6 -4
- package/dist/src/models/editor/jsx.d.ts +10 -1
- package/dist/src/models/environment/index.d.ts +3 -0
- package/dist/src/models/generated/editor.d.ts +456 -26
- package/dist/src/models/generated/editor.js +1 -1
- package/dist/src/models/generated/react.d.ts +1343 -301
- package/dist/src/models/generated/react.js +1 -1
- package/dist/src/models/generated/system.d.ts +148 -148
- package/dist/src/models/generated/system.js +1 -1
- package/dist/src/models/generated/tests.js +1 -1
- package/dist/src/models/generated/unity.d.ts +5392 -1283
- package/dist/src/models/generated/unity.js +2 -2
- package/dist/src/models/generated/yoga.js +1 -1
- package/dist/src/models/richtext.d.ts +65 -0
- package/dist/src/models/richtext.js +2 -0
- package/dist/src/models/svg.d.ts +68 -0
- package/dist/src/models/svg.js +1 -0
- package/dist/src/models/ugui/components.d.ts +10 -6
- package/dist/src/models/ugui/events.d.ts +1 -0
- package/dist/src/models/ugui/jsx.d.ts +10 -1
- package/dist/src/models/uitoolkit/components.d.ts +3 -1
- package/dist/src/models/uitoolkit/jsx.d.ts +9 -0
- package/dist/src/renderer/async/callbacks.js +22 -8
- package/dist/src/renderer/async/reconciler.d.ts +1 -7
- package/dist/src/renderer/async/reconciler.js +204 -26
- package/dist/src/renderer/async/types.d.ts +31 -5
- package/dist/src/renderer/constants.d.ts +5 -0
- package/dist/src/renderer/constants.js +12 -0
- package/dist/src/renderer/diffing.js +1 -1
- package/dist/src/renderer/renderer.d.ts +11 -10
- package/dist/src/renderer/renderer.js +6 -9
- package/dist/src/renderer/subcontexts/index.d.ts +6 -0
- package/dist/src/renderer/subcontexts/index.js +6 -0
- package/dist/src/renderer/subcontexts/richtext.d.ts +3 -0
- package/dist/src/renderer/subcontexts/richtext.js +52 -0
- package/dist/src/renderer/subcontexts/svg.d.ts +3 -0
- package/dist/src/renderer/subcontexts/svg.js +70 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +6 -6
|
@@ -3,17 +3,43 @@ 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 declare type AsyncHostContext =
|
|
6
|
+
export declare type AsyncHostContext = AsyncNativeInstance | AsyncSubContext;
|
|
7
|
+
export declare type AsyncInstance = AsyncNativeInstance | AsyncSubContext;
|
|
8
|
+
export declare type AsyncNativeInstance = {
|
|
7
9
|
context: ReactUnity.ReactContext;
|
|
8
10
|
commands: BatchCommand[];
|
|
9
|
-
};
|
|
10
|
-
export declare type AsyncNativeInstance = AsyncHostContext & {
|
|
11
11
|
refId: number;
|
|
12
|
+
type: 'native';
|
|
13
|
+
subContext?: AsyncSubContext;
|
|
14
|
+
};
|
|
15
|
+
export declare type AsyncSubContext = RichTextContext | SvgContext;
|
|
16
|
+
export declare type RichTextContext = {
|
|
17
|
+
hostContext: AsyncNativeInstance;
|
|
18
|
+
type: 'richtext';
|
|
19
|
+
node: RichTextNode;
|
|
20
|
+
root: AsyncNativeInstance;
|
|
21
|
+
parent: RichTextContext;
|
|
22
|
+
};
|
|
23
|
+
export declare type SvgContext = {
|
|
24
|
+
hostContext: AsyncNativeInstance;
|
|
25
|
+
type: 'svg';
|
|
26
|
+
node: RichTextNode;
|
|
27
|
+
root: AsyncNativeInstance;
|
|
28
|
+
parent: SvgContext;
|
|
12
29
|
};
|
|
13
|
-
declare type
|
|
30
|
+
export declare type RichTextNode = ({
|
|
31
|
+
tag: string;
|
|
32
|
+
attributes: Record<string, any>;
|
|
33
|
+
children: RichTextNode[];
|
|
34
|
+
hidden?: boolean;
|
|
35
|
+
} | {
|
|
36
|
+
text: string;
|
|
37
|
+
hidden?: boolean;
|
|
38
|
+
});
|
|
39
|
+
export declare type AsyncContainerInstance = AsyncNativeInstance & {
|
|
14
40
|
component: ReactUnity.IReactComponent;
|
|
15
41
|
fiberCache: ObjectsRepo | null;
|
|
16
42
|
};
|
|
17
43
|
declare type AsyncPublicInstance = ReactUnity.IReactComponent;
|
|
18
|
-
export declare type AsyncReconcilerConfig = Reconciler.HostConfig<InstanceTag, Props, AsyncContainerInstance,
|
|
44
|
+
export declare type AsyncReconcilerConfig = Reconciler.HostConfig<InstanceTag, Props, AsyncContainerInstance, AsyncInstance, AsyncInstance, AsyncNativeInstance, HydratableInstance, AsyncPublicInstance, AsyncHostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>;
|
|
19
45
|
export {};
|
|
@@ -19,5 +19,10 @@ export declare const commonReconciler: {
|
|
|
19
19
|
scheduleTimeout: (callback: any, delay: any) => number;
|
|
20
20
|
scheduleMicrotask: (callback: (...args: any[]) => any) => void;
|
|
21
21
|
cancelTimeout: (handle: any) => void;
|
|
22
|
+
beforeActiveInstanceBlur(): void;
|
|
23
|
+
afterActiveInstanceBlur(): void;
|
|
24
|
+
getInstanceFromNode(node: any): any;
|
|
25
|
+
getInstanceFromScope(scopeInstance: any): any;
|
|
26
|
+
prepareScopeUpdate(scopeInstance: any, instance: any): void;
|
|
22
27
|
};
|
|
23
28
|
export declare const isDevelopment: boolean;
|
|
@@ -45,5 +45,17 @@ export var commonReconciler = {
|
|
|
45
45
|
function (callback) { return Promise.resolve(null).then(callback)
|
|
46
46
|
.catch(function (error) { return setTimeout(function () { throw error; }, 0); }); },
|
|
47
47
|
cancelTimeout: function (handle) { return clearTimeout(handle); },
|
|
48
|
+
beforeActiveInstanceBlur: function () {
|
|
49
|
+
},
|
|
50
|
+
afterActiveInstanceBlur: function () {
|
|
51
|
+
},
|
|
52
|
+
getInstanceFromNode: function (node) {
|
|
53
|
+
return undefined;
|
|
54
|
+
},
|
|
55
|
+
getInstanceFromScope: function (scopeInstance) {
|
|
56
|
+
return undefined;
|
|
57
|
+
},
|
|
58
|
+
prepareScopeUpdate: function (scopeInstance, instance) {
|
|
59
|
+
},
|
|
48
60
|
};
|
|
49
61
|
export var isDevelopment = process.env.NODE_ENV === 'development';
|
|
@@ -20,7 +20,7 @@ export function diffProperties(lastProps, nextProps, deepDiffing) {
|
|
|
20
20
|
else {
|
|
21
21
|
var depth = deepDiffing > 0 ? deepDiffing : propKey === 'style' ? 1 : 0;
|
|
22
22
|
if (depth > 0) {
|
|
23
|
-
prop = diffProperties(lastProps[propKey],
|
|
23
|
+
prop = diffProperties(lastProps[propKey], {}, depth - 1);
|
|
24
24
|
if (!prop)
|
|
25
25
|
continue;
|
|
26
26
|
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { NativeContainerInstance } from '../models/renderer';
|
|
3
|
-
import {
|
|
4
|
-
import { AsyncNativeInstance } from './async/types';
|
|
3
|
+
import { AsyncContainerInstance, AsyncNativeInstance } from './async/types';
|
|
5
4
|
interface RenderOptions {
|
|
6
5
|
hostContainer?: NativeContainerInstance;
|
|
7
6
|
disableHelpers?: boolean;
|
|
8
7
|
mode?: 'legacy' | 'concurrent';
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
Render using the sync reconciler instead of the batch rendering. It is not recommended to change this value.
|
|
10
|
+
Changing this will disable some features like inline rich-text and svg rendering, although it may improve performance for Jint.
|
|
11
|
+
*/
|
|
12
|
+
disableBatchRendering?: boolean;
|
|
10
13
|
}
|
|
11
14
|
export declare const Renderer: {
|
|
12
|
-
render(element: React.ReactNode, options?: RenderOptions): import("react-reconciler").Reconciler<import("./async/types").
|
|
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>;
|
|
15
|
+
render(element: React.ReactNode, options?: RenderOptions): import("react-reconciler").Reconciler<AsyncContainerInstance, import("./async/types").AsyncInstance, import("./async/types").AsyncInstance, AsyncNativeInstance, import("../..").ReactUnity.IReactComponent> | import("react-reconciler").Reconciler<import("../..").ReactUnity.IReactComponent, import("../..").ReactUnity.IReactComponent, import("../..").ReactUnity.ITextComponent, import("../..").ReactUnity.IReactComponent, any>;
|
|
18
16
|
};
|
|
19
17
|
export declare const batchedUpdates: <A, R>(fn: (a: A) => R, a: A) => R;
|
|
20
|
-
export declare const flushSync:
|
|
18
|
+
export declare const flushSync: {
|
|
19
|
+
(): void;
|
|
20
|
+
<R>(fn: () => R): R;
|
|
21
|
+
};
|
|
21
22
|
export {};
|
|
@@ -11,9 +11,7 @@ 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
|
-
|
|
15
|
-
// For other engines (ClearScript), async is default
|
|
16
|
-
var isAsync = hostContainer.Context.Script.Engine.Key === 'jint' ? (options === null || options === void 0 ? void 0 : options.sync) === false : !(options === null || options === void 0 ? void 0 : options.sync);
|
|
14
|
+
var isAsync = !(options === null || options === void 0 ? void 0 : options.disableBatchRendering);
|
|
17
15
|
var _a = containerMap.get(hostContainer) || {}, hostRoot = _a.hostRoot, asyncJobCallback = _a.asyncJobCallback;
|
|
18
16
|
var findFiberByHostInstance = function () { return null; };
|
|
19
17
|
if (!hostRoot) {
|
|
@@ -40,6 +38,7 @@ export var Renderer = {
|
|
|
40
38
|
return Array.prototype.push.apply(commands_1, args);
|
|
41
39
|
};
|
|
42
40
|
var hostContainerInstance = {
|
|
41
|
+
type: 'native',
|
|
43
42
|
commands: commands_1,
|
|
44
43
|
component: hostContainer,
|
|
45
44
|
context: hostContainer.Context,
|
|
@@ -53,10 +52,10 @@ export var Renderer = {
|
|
|
53
52
|
commands_1.length = 0;
|
|
54
53
|
hostContainer.Context.FlushCommands(serialized);
|
|
55
54
|
};
|
|
56
|
-
hostRoot = asyncReconciler.createContainer(hostContainerInstance, mode, false, null);
|
|
55
|
+
hostRoot = asyncReconciler.createContainer(hostContainerInstance, mode, null, false, undefined, '', function (error) { return console.error(error); }, null);
|
|
57
56
|
}
|
|
58
57
|
else {
|
|
59
|
-
hostRoot = syncReconciler.createContainer(hostContainer, mode, false, null);
|
|
58
|
+
hostRoot = syncReconciler.createContainer(hostContainer, mode, null, false, undefined, '', function (error) { return console.error(error); }, null);
|
|
60
59
|
}
|
|
61
60
|
containerMap.set(hostContainer, { hostRoot: hostRoot, asyncJobCallback: asyncJobCallback });
|
|
62
61
|
}
|
|
@@ -79,7 +78,5 @@ export var Renderer = {
|
|
|
79
78
|
return rc;
|
|
80
79
|
},
|
|
81
80
|
};
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
export var batchedUpdates = defaultReconciler.batchedUpdates;
|
|
85
|
-
export var flushSync = defaultReconciler.flushSync;
|
|
81
|
+
export var batchedUpdates = asyncReconciler.batchedUpdates;
|
|
82
|
+
export var flushSync = asyncReconciler.flushSync;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export function parametrizeValue(value) {
|
|
2
|
+
if (typeof value === 'number')
|
|
3
|
+
return value + '';
|
|
4
|
+
value = value + '';
|
|
5
|
+
if (value.includes(' ') || value.includes('-'))
|
|
6
|
+
return '"' + value + '"';
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
export function stringifyRichText(node) {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
if (node.hidden)
|
|
12
|
+
return '';
|
|
13
|
+
if ('text' in node)
|
|
14
|
+
return node.text;
|
|
15
|
+
var acc = [];
|
|
16
|
+
var tag = node.tag;
|
|
17
|
+
if (tag) {
|
|
18
|
+
acc.push('<');
|
|
19
|
+
acc.push(tag);
|
|
20
|
+
if (((_a = node.attributes) === null || _a === void 0 ? void 0 : _a.value) != null) {
|
|
21
|
+
var value = (_b = node.attributes) === null || _b === void 0 ? void 0 : _b.value;
|
|
22
|
+
acc.push('=');
|
|
23
|
+
acc.push(parametrizeValue(value));
|
|
24
|
+
}
|
|
25
|
+
for (var key in node.attributes) {
|
|
26
|
+
if (key === 'value')
|
|
27
|
+
continue;
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(node.attributes, key)) {
|
|
29
|
+
var value = node.attributes[key];
|
|
30
|
+
if (value != null) {
|
|
31
|
+
acc.push(' ');
|
|
32
|
+
acc.push(key);
|
|
33
|
+
acc.push('=');
|
|
34
|
+
acc.push(parametrizeValue(value));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
acc.push('>');
|
|
39
|
+
}
|
|
40
|
+
if (((_c = node.children) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
41
|
+
for (var _i = 0, _d = node.children; _i < _d.length; _i++) {
|
|
42
|
+
var child = _d[_i];
|
|
43
|
+
acc.push(stringifyRichText(child));
|
|
44
|
+
}
|
|
45
|
+
if (tag) {
|
|
46
|
+
acc.push('</');
|
|
47
|
+
acc.push(tag);
|
|
48
|
+
acc.push('>');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return acc.join('');
|
|
52
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function kebabize(str) {
|
|
2
|
+
return str.split('').map(function (letter, idx) {
|
|
3
|
+
return letter.toUpperCase() === letter
|
|
4
|
+
? "".concat(idx !== 0 ? '-' : '').concat(letter.toLowerCase())
|
|
5
|
+
: letter;
|
|
6
|
+
}).join('');
|
|
7
|
+
}
|
|
8
|
+
;
|
|
9
|
+
export function stringifyStyle(style) {
|
|
10
|
+
if (typeof style === 'string')
|
|
11
|
+
return style;
|
|
12
|
+
var acc = [];
|
|
13
|
+
for (var key in style) {
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(style, key)) {
|
|
15
|
+
var element = style[key];
|
|
16
|
+
if (element != null) {
|
|
17
|
+
acc.push(kebabize(key));
|
|
18
|
+
acc.push(':');
|
|
19
|
+
acc.push(element);
|
|
20
|
+
acc.push(';');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return acc.join('');
|
|
25
|
+
}
|
|
26
|
+
export function stringifySVG(node) {
|
|
27
|
+
var _a;
|
|
28
|
+
if (node.hidden)
|
|
29
|
+
return '';
|
|
30
|
+
if ('text' in node)
|
|
31
|
+
return node.text;
|
|
32
|
+
var acc = [];
|
|
33
|
+
var tag = node.tag;
|
|
34
|
+
if (tag) {
|
|
35
|
+
acc.push('<');
|
|
36
|
+
acc.push(tag);
|
|
37
|
+
for (var key in node.attributes) {
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(node.attributes, key)) {
|
|
39
|
+
var element = node.attributes[key];
|
|
40
|
+
if (key === 'style')
|
|
41
|
+
element = stringifyStyle(element);
|
|
42
|
+
if (element != null) {
|
|
43
|
+
acc.push(' ');
|
|
44
|
+
acc.push(kebabize(key));
|
|
45
|
+
acc.push('="');
|
|
46
|
+
acc.push(element);
|
|
47
|
+
acc.push('"');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (((_a = node.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
53
|
+
if (tag)
|
|
54
|
+
acc.push('>');
|
|
55
|
+
for (var _i = 0, _b = node.children; _i < _b.length; _i++) {
|
|
56
|
+
var child = _b[_i];
|
|
57
|
+
acc.push(stringifySVG(child));
|
|
58
|
+
}
|
|
59
|
+
if (tag) {
|
|
60
|
+
acc.push('</');
|
|
61
|
+
acc.push(tag);
|
|
62
|
+
acc.push('>');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
if (tag)
|
|
67
|
+
acc.push(' />');
|
|
68
|
+
}
|
|
69
|
+
return acc.join('');
|
|
70
|
+
}
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.
|
|
1
|
+
export declare const version = "0.12.0";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export var version = '0.
|
|
1
|
+
export var version = '0.12.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactunity/renderer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "React renderer for Unity3D",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -54,16 +54,16 @@
|
|
|
54
54
|
"unity3d"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"react-reconciler": "^0.
|
|
58
|
-
"use-sync-external-store": "^1.
|
|
57
|
+
"react-reconciler": "^0.29.0",
|
|
58
|
+
"use-sync-external-store": "^1.2.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"react": "^18.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@reactunity/scripts": "^0.
|
|
65
|
-
"@types/react-reconciler": "^0.
|
|
64
|
+
"@reactunity/scripts": "^0.12.0",
|
|
65
|
+
"@types/react-reconciler": "^0.28.0",
|
|
66
66
|
"rimraf": "^3.0.2",
|
|
67
|
-
"typescript": "^4.
|
|
67
|
+
"typescript": "^4.7.3"
|
|
68
68
|
}
|
|
69
69
|
}
|