@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Types in assemblies: UnityEngine.CoreModule, UnityEngine.VideoModule, UnityEngine.AudioModule, UnityEngine.UIModule, UnityEngine.UI, UnityEngine.TextRenderingModule, UnityEngine.AnimationModule, UnityEngine.IMGUIModule, UnityEngine.AssetBundleModule, UnityEngine.UnityAnalyticsModule, UnityEngine.UIElementsModule, UnityEngine.AIModule, UnityEngine.TestRunner, UnityEngine.TextCoreFontEngineModule, UnityEngine.TextCoreTextEngineModule, UnityEngine.XRModule, UnityEngine.PhysicsModule, UnityEngine.InputLegacyModule, UnityEngine.UI, Unity.InputSystem, Unity.InputSystem
|
|
3
|
-
// Generated
|
|
2
|
+
// Types in assemblies: UnityEngine.CoreModule, UnityEngine.VideoModule, UnityEngine.AudioModule, UnityEngine.UIModule, UnityEngine.UI, UnityEngine.TextRenderingModule, UnityEngine.AnimationModule, UnityEngine.IMGUIModule, UnityEngine.AssetBundleModule, UnityEngine.UnityAnalyticsModule, UnityEngine.UIElementsModule, UnityEngine.UIElementsNativeModule, UnityEngine.AIModule, UnityEngine.TestRunner, UnityEngine.TextCoreFontEngineModule, UnityEngine.TextCoreTextEngineModule, UnityEngine.XRModule, UnityEngine.PhysicsModule, UnityEngine.InputLegacyModule, UnityEngine.UI, Unity.InputSystem, Unity.InputSystem
|
|
3
|
+
// Generated 23/05/2022 15:36:59
|
|
4
4
|
//
|
|
5
5
|
/* eslint-disable */
|
|
6
6
|
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { UnityEngine } from './generated';
|
|
3
|
+
export declare type RichTextTags = RichTextValueTag;
|
|
4
|
+
export interface RichTextVoidTag extends React.Attributes {
|
|
5
|
+
children?: any;
|
|
6
|
+
}
|
|
7
|
+
export interface RichTextValueTag<T = string | number> extends React.Attributes {
|
|
8
|
+
value?: T | string;
|
|
9
|
+
children?: any;
|
|
10
|
+
}
|
|
11
|
+
export interface RichTextColorTag extends React.Attributes {
|
|
12
|
+
value?: string | UnityEngine.Color;
|
|
13
|
+
children?: any;
|
|
14
|
+
}
|
|
15
|
+
export interface RichTextFontTag extends React.Attributes {
|
|
16
|
+
value?: string;
|
|
17
|
+
material?: string;
|
|
18
|
+
children?: any;
|
|
19
|
+
}
|
|
20
|
+
export interface RichTextSpriteTag extends React.Attributes {
|
|
21
|
+
value?: string | number;
|
|
22
|
+
children?: any;
|
|
23
|
+
name?: string;
|
|
24
|
+
index?: string | number;
|
|
25
|
+
color?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface RichTextElements {
|
|
28
|
+
'nbsp': RichTextVoidTag;
|
|
29
|
+
'zwsp': RichTextVoidTag;
|
|
30
|
+
'br': RichTextVoidTag;
|
|
31
|
+
'align': RichTextValueTag<'right' | 'center' | 'left'>;
|
|
32
|
+
'alpha': RichTextValueTag<string>;
|
|
33
|
+
'color': RichTextColorTag;
|
|
34
|
+
'b': RichTextVoidTag;
|
|
35
|
+
'i': RichTextVoidTag;
|
|
36
|
+
'cspace': RichTextValueTag<number>;
|
|
37
|
+
'font': RichTextFontTag;
|
|
38
|
+
'indent': RichTextValueTag<number>;
|
|
39
|
+
'line-height': RichTextValueTag<number>;
|
|
40
|
+
'line-indent': RichTextValueTag<number>;
|
|
41
|
+
'link': RichTextValueTag;
|
|
42
|
+
'lowercase': RichTextVoidTag;
|
|
43
|
+
'uppercase': RichTextVoidTag;
|
|
44
|
+
'smallcaps': RichTextVoidTag;
|
|
45
|
+
'allcaps': RichTextVoidTag;
|
|
46
|
+
'margin': RichTextValueTag<number>;
|
|
47
|
+
'margin-left': RichTextValueTag<number>;
|
|
48
|
+
'margin-right': RichTextValueTag<number>;
|
|
49
|
+
'mark': RichTextValueTag;
|
|
50
|
+
'mspace': RichTextVoidTag;
|
|
51
|
+
'noparse': RichTextVoidTag;
|
|
52
|
+
'nobr': RichTextVoidTag;
|
|
53
|
+
'page': RichTextVoidTag;
|
|
54
|
+
'pos': RichTextValueTag<number>;
|
|
55
|
+
'size': RichTextValueTag<number>;
|
|
56
|
+
'space': RichTextValueTag<number>;
|
|
57
|
+
'sprite': RichTextSpriteTag;
|
|
58
|
+
's': RichTextVoidTag;
|
|
59
|
+
'u': RichTextVoidTag;
|
|
60
|
+
'style': RichTextValueTag;
|
|
61
|
+
'sub': RichTextVoidTag;
|
|
62
|
+
'sup': RichTextVoidTag;
|
|
63
|
+
'voffset': RichTextValueTag<number>;
|
|
64
|
+
'width': RichTextValueTag<number>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import { Style } from './properties';
|
|
3
|
+
declare type SVGProps<T> = React.Attributes & Omit<React.SVGAttributes<T>, keyof React.DOMAttributes<T> | keyof React.AriaAttributes | 'style'> & {
|
|
4
|
+
style?: Style | React.CSSProperties | string | undefined;
|
|
5
|
+
children?: any;
|
|
6
|
+
};
|
|
7
|
+
export declare type SVGEelement = SVGProps<SVGSVGElement>;
|
|
8
|
+
export interface SVGElements {
|
|
9
|
+
svg: SVGEelement;
|
|
10
|
+
animate: SVGProps<SVGElement>;
|
|
11
|
+
animateMotion: SVGProps<SVGElement>;
|
|
12
|
+
animateTransform: SVGProps<SVGElement>;
|
|
13
|
+
circle: SVGProps<SVGCircleElement>;
|
|
14
|
+
clipPath: SVGProps<SVGClipPathElement>;
|
|
15
|
+
defs: SVGProps<SVGDefsElement>;
|
|
16
|
+
desc: SVGProps<SVGDescElement>;
|
|
17
|
+
ellipse: SVGProps<SVGEllipseElement>;
|
|
18
|
+
feBlend: SVGProps<SVGFEBlendElement>;
|
|
19
|
+
feColorMatrix: SVGProps<SVGFEColorMatrixElement>;
|
|
20
|
+
feComponentTransfer: SVGProps<SVGFEComponentTransferElement>;
|
|
21
|
+
feComposite: SVGProps<SVGFECompositeElement>;
|
|
22
|
+
feConvolveMatrix: SVGProps<SVGFEConvolveMatrixElement>;
|
|
23
|
+
feDiffuseLighting: SVGProps<SVGFEDiffuseLightingElement>;
|
|
24
|
+
feDisplacementMap: SVGProps<SVGFEDisplacementMapElement>;
|
|
25
|
+
feDistantLight: SVGProps<SVGFEDistantLightElement>;
|
|
26
|
+
feDropShadow: SVGProps<SVGFEDropShadowElement>;
|
|
27
|
+
feFlood: SVGProps<SVGFEFloodElement>;
|
|
28
|
+
feFuncA: SVGProps<SVGFEFuncAElement>;
|
|
29
|
+
feFuncB: SVGProps<SVGFEFuncBElement>;
|
|
30
|
+
feFuncG: SVGProps<SVGFEFuncGElement>;
|
|
31
|
+
feFuncR: SVGProps<SVGFEFuncRElement>;
|
|
32
|
+
feGaussianBlur: SVGProps<SVGFEGaussianBlurElement>;
|
|
33
|
+
feImage: SVGProps<SVGFEImageElement>;
|
|
34
|
+
feMerge: SVGProps<SVGFEMergeElement>;
|
|
35
|
+
feMergeNode: SVGProps<SVGFEMergeNodeElement>;
|
|
36
|
+
feMorphology: SVGProps<SVGFEMorphologyElement>;
|
|
37
|
+
feOffset: SVGProps<SVGFEOffsetElement>;
|
|
38
|
+
fePointLight: SVGProps<SVGFEPointLightElement>;
|
|
39
|
+
feSpecularLighting: SVGProps<SVGFESpecularLightingElement>;
|
|
40
|
+
feSpotLight: SVGProps<SVGFESpotLightElement>;
|
|
41
|
+
feTile: SVGProps<SVGFETileElement>;
|
|
42
|
+
feTurbulence: SVGProps<SVGFETurbulenceElement>;
|
|
43
|
+
filter: SVGProps<SVGFilterElement>;
|
|
44
|
+
foreignObject: SVGProps<SVGForeignObjectElement>;
|
|
45
|
+
g: SVGProps<SVGGElement>;
|
|
46
|
+
image: SVGProps<SVGImageElement>;
|
|
47
|
+
line: SVGProps<SVGLineElement>;
|
|
48
|
+
linearGradient: SVGProps<SVGLinearGradientElement>;
|
|
49
|
+
marker: SVGProps<SVGMarkerElement>;
|
|
50
|
+
mask: SVGProps<SVGMaskElement>;
|
|
51
|
+
metadata: SVGProps<SVGMetadataElement>;
|
|
52
|
+
mpath: SVGProps<SVGElement>;
|
|
53
|
+
path: SVGProps<SVGPathElement>;
|
|
54
|
+
pattern: SVGProps<SVGPatternElement>;
|
|
55
|
+
polygon: SVGProps<SVGPolygonElement>;
|
|
56
|
+
polyline: SVGProps<SVGPolylineElement>;
|
|
57
|
+
radialGradient: SVGProps<SVGRadialGradientElement>;
|
|
58
|
+
rect: SVGProps<SVGRectElement>;
|
|
59
|
+
stop: SVGProps<SVGStopElement>;
|
|
60
|
+
switch: SVGProps<SVGSwitchElement>;
|
|
61
|
+
symbol: SVGProps<SVGSymbolElement>;
|
|
62
|
+
text: SVGProps<SVGTextElement>;
|
|
63
|
+
textPath: SVGProps<SVGTextPathElement>;
|
|
64
|
+
tspan: SVGProps<SVGTSpanElement>;
|
|
65
|
+
use: SVGProps<SVGUseElement>;
|
|
66
|
+
view: SVGProps<SVGViewElement>;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCmpProps } from '../base';
|
|
1
|
+
import { BaseCmpProps, ContentSrcProps } from '../base';
|
|
2
2
|
import { ReactUnity, UnityEngine } from '../generated';
|
|
3
3
|
import { Style } from '../properties';
|
|
4
4
|
import { AssetReference, AssetReferenceOrHttp } from '../properties/values';
|
|
@@ -6,6 +6,7 @@ import { ActionCallback, Events } from './events';
|
|
|
6
6
|
export interface View<T = ReactUnity.UGUI.UGUIComponent> extends Events<T>, BaseCmpProps {
|
|
7
7
|
active?: boolean;
|
|
8
8
|
style?: Style | string;
|
|
9
|
+
eventViewport?: UnityEngine.RectTransform | UnityEngine.GameObject | ReactUnity.UGUI.UGUIComponent;
|
|
9
10
|
}
|
|
10
11
|
export interface Text extends View<ReactUnity.UGUI.TextComponent> {
|
|
11
12
|
richText?: boolean;
|
|
@@ -43,17 +44,17 @@ export interface Anchor extends View<ReactUnity.UGUI.AnchorComponent> {
|
|
|
43
44
|
openInThisTab?: boolean;
|
|
44
45
|
}
|
|
45
46
|
export interface BaseImage<T = ReactUnity.UGUI.ImageComponent> extends View<T> {
|
|
47
|
+
source?: AssetReferenceOrHttp;
|
|
46
48
|
}
|
|
47
49
|
export interface Image<T = ReactUnity.UGUI.ImageComponent> extends BaseImage<T> {
|
|
48
|
-
|
|
50
|
+
preserveAspect?: boolean;
|
|
49
51
|
}
|
|
50
|
-
export interface RawImage extends
|
|
52
|
+
export interface RawImage extends BaseImage<ReactUnity.UGUI.RawImageComponent> {
|
|
51
53
|
}
|
|
52
|
-
export interface Video extends
|
|
54
|
+
export interface Video extends BaseImage<ReactUnity.UGUI.VideoComponent> {
|
|
53
55
|
source?: AssetReference;
|
|
54
56
|
}
|
|
55
|
-
export interface SvgImage
|
|
56
|
-
preserveAspect?: boolean;
|
|
57
|
+
export interface SvgImage<T = ReactUnity.UGUI.SvgImageComponent> extends Image<T> {
|
|
57
58
|
}
|
|
58
59
|
export interface Render<T = ReactUnity.UGUI.RenderComponent> extends BaseImage<T> {
|
|
59
60
|
width: number;
|
|
@@ -73,6 +74,9 @@ export interface Prefab<T = ReactUnity.UGUI.PrefabComponent> extends View<T> {
|
|
|
73
74
|
}
|
|
74
75
|
export interface Portal<T = ReactUnity.UGUI.PortalComponent> extends View<T> {
|
|
75
76
|
target?: UnityEngine.GameObject | UnityEngine.Component | UnityEngine.Transform | ReactUnity.UGUI.UGUIComponent;
|
|
77
|
+
eventCamera?: UnityEngine.Camera | UnityEngine.GameObject;
|
|
76
78
|
onMount?: (camera: UnityEngine.Transform, sender: T) => void;
|
|
77
79
|
onUnmount?: (camera: UnityEngine.Transform, sender: T) => void;
|
|
78
80
|
}
|
|
81
|
+
export interface Svg<T = ReactUnity.UGUI.SvgComponent> extends SvgImage<T>, ContentSrcProps {
|
|
82
|
+
}
|
|
@@ -13,6 +13,7 @@ export interface Events<T = BaseCmp> extends BaseEvents<T> {
|
|
|
13
13
|
onPointerDown?: PointerEventCallback<T>;
|
|
14
14
|
onPointerEnter?: PointerEventCallback<T>;
|
|
15
15
|
onPointerExit?: PointerEventCallback<T>;
|
|
16
|
+
onPointerMove?: PointerEventCallback<T>;
|
|
16
17
|
onSubmit?: BaseEventCallback<T>;
|
|
17
18
|
onCancel?: BaseEventCallback<T>;
|
|
18
19
|
onSelect?: BaseEventCallback<T>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Attributes, ClassAttributes, RefAttributes } from 'react';
|
|
2
2
|
import { BaseElements, Textable } from '../base';
|
|
3
3
|
import { ReactUnity } from '../generated';
|
|
4
|
+
import { SVGEelement } from '../svg';
|
|
4
5
|
import * as Components from './components';
|
|
5
6
|
import { Input } from './input';
|
|
6
7
|
import NS = ReactUnity.UGUI;
|
|
@@ -14,14 +15,17 @@ export interface UGUIElements extends BaseElements<BaseCmp> {
|
|
|
14
15
|
} & Children;
|
|
15
16
|
anchor: Components.Anchor & RefAttributes<NS.AnchorComponent> & Children;
|
|
16
17
|
text: Components.Text & RefAttributes<NS.TextComponent> & Children<Textable | Textable[]>;
|
|
18
|
+
richtext: Components.Text & RefAttributes<NS.TextComponent> & Children<any>;
|
|
17
19
|
label: Components.Label & RefAttributes<NS.LabelComponent> & Children;
|
|
18
20
|
icon: Components.Icon & RefAttributes<NS.IconComponent> & Children<Textable | Textable[]>;
|
|
19
21
|
button: Components.Button & RefAttributes<NS.ButtonComponent> & Children;
|
|
20
22
|
input: Input & RefAttributes<NS.InputComponent> & Children<never>;
|
|
21
23
|
scroll: Components.Scroll & RefAttributes<NS.ScrollComponent> & Children;
|
|
24
|
+
img: Components.Image & RefAttributes<NS.ImageComponent> & Children<never>;
|
|
22
25
|
image: Components.Image & RefAttributes<NS.ImageComponent> & Children<never>;
|
|
23
26
|
rawimage: Components.RawImage & RefAttributes<NS.RawImageComponent> & Children<never>;
|
|
24
|
-
|
|
27
|
+
svgimage: Components.SvgImage & RefAttributes<NS.SvgImageComponent> & Children<never>;
|
|
28
|
+
svg: Components.Svg & RefAttributes<NS.SvgComponent> & Children<any> & SVGEelement;
|
|
25
29
|
video: Components.Video & RefAttributes<NS.VideoComponent> & Children<never>;
|
|
26
30
|
render: Components.Render & RefAttributes<NS.RenderComponent> & Children<never>;
|
|
27
31
|
object: Components.Object & RefAttributes<NS.ObjectComponent> & Children<never>;
|
|
@@ -45,4 +49,9 @@ declare module 'react/jsx-runtime' {
|
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
}
|
|
52
|
+
declare global {
|
|
53
|
+
interface DefaultComponentProps extends Components.View {
|
|
54
|
+
ref?: React.Ref<ReactUnity.UGUI.UGUIComponent>;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
48
57
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseCmpProps } from '../base';
|
|
1
|
+
import { BaseCmpProps, ContentSrcProps } from '../base';
|
|
2
2
|
import { ReactUnity, UnityEditor, UnityEngine } from '../generated';
|
|
3
3
|
import { Style } from '../properties';
|
|
4
4
|
import { AssetReference } from '../properties/values';
|
|
@@ -72,4 +72,6 @@ export interface IMGUI extends View<Cmp.IMGUIComponent> {
|
|
|
72
72
|
onGUI?: ActionCallback<Cmp.IMGUIComponent>;
|
|
73
73
|
cullingEnabled?: boolean;
|
|
74
74
|
}
|
|
75
|
+
export interface Svg extends View<Cmp.SvgComponent>, ContentSrcProps {
|
|
76
|
+
}
|
|
75
77
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as rc from 'react';
|
|
2
2
|
import { BaseElements, Textable } from '../base';
|
|
3
3
|
import { ReactUnity } from '../generated';
|
|
4
|
+
import { SVGEelement } from '../svg';
|
|
4
5
|
import * as Components from './components';
|
|
5
6
|
import Cmp = ReactUnity.UIToolkit;
|
|
6
7
|
declare type Children<T = any> = {
|
|
@@ -14,9 +15,12 @@ export interface UIToolkitElements extends BaseElements<BaseElement<any>> {
|
|
|
14
15
|
box: BaseElement;
|
|
15
16
|
anchor: Components.Anchor & rc.RefAttributes<Cmp.UIToolkitComponent> & Children;
|
|
16
17
|
text: Components.View & rc.RefAttributes<Cmp.TextComponent> & Children<Textable | Textable[]>;
|
|
18
|
+
richtext: Components.View & rc.RefAttributes<Cmp.TextComponent> & Children<Textable | Textable[]>;
|
|
17
19
|
label: Components.View & rc.RefAttributes<Cmp.TextComponent> & Children<Textable | Textable[]>;
|
|
18
20
|
button: Components.Button & rc.RefAttributes<Cmp.ButtonComponent> & Children;
|
|
19
21
|
scroll: BaseElement;
|
|
22
|
+
svg: Components.Svg & rc.RefAttributes<Cmp.SvgComponent> & Children<any> & SVGEelement;
|
|
23
|
+
img: Components.Image & rc.RefAttributes<Cmp.ImageComponent> & Children<never>;
|
|
20
24
|
image: Components.Image & rc.RefAttributes<Cmp.ImageComponent> & Children<never>;
|
|
21
25
|
toggle: Components.Toggle & rc.RefAttributes<Cmp.ToggleComponent> & Children<never>;
|
|
22
26
|
input: Components.TextField<Cmp.TextFieldComponent> & rc.RefAttributes<Cmp.TextFieldComponent> & Children<never>;
|
|
@@ -49,4 +53,9 @@ declare module 'react/jsx-runtime' {
|
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
}
|
|
56
|
+
declare global {
|
|
57
|
+
interface DefaultComponentProps extends Components.View {
|
|
58
|
+
ref?: React.Ref<ReactUnity.UIToolkit.UIToolkitComponent>;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
52
61
|
export {};
|
|
@@ -20,14 +20,28 @@ var CallbacksRepo = /** @class */ (function (_super) {
|
|
|
20
20
|
var _this = _super.call(this) || this;
|
|
21
21
|
_this.call = function (ind, args) {
|
|
22
22
|
var cb = _this.getObject(ind);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
var argsAsList = args;
|
|
24
|
+
var argsAsArray = args;
|
|
25
|
+
if (typeof argsAsArray.Length === 'number') {
|
|
26
|
+
// C# Array
|
|
27
|
+
args = [];
|
|
28
|
+
var length = argsAsArray.Length;
|
|
29
|
+
for (var index = 0; index < length; index++)
|
|
30
|
+
args.push(argsAsArray.GetValue(index));
|
|
31
|
+
}
|
|
32
|
+
else if (typeof argsAsList.Count === 'number') {
|
|
33
|
+
// C# List
|
|
34
|
+
args = [];
|
|
35
|
+
var length = argsAsList.Count;
|
|
36
|
+
for (var index = 0; index < length; index++)
|
|
37
|
+
args.push(argsAsList[index]);
|
|
38
|
+
}
|
|
39
|
+
else if (typeof argsAsList.Count === 'function') {
|
|
40
|
+
// C# IList
|
|
41
|
+
args = [];
|
|
42
|
+
var length = argsAsList.Count();
|
|
43
|
+
for (var index = 0; index < length; index++)
|
|
44
|
+
args.push(argsAsArray.GetValue(index));
|
|
31
45
|
}
|
|
32
46
|
return cb.apply(null, args);
|
|
33
47
|
};
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import * as Reconciler from 'react-reconciler';
|
|
2
|
-
|
|
3
|
-
export declare const asyncReconciler: Reconciler.Reconciler<AsyncHostContext & {
|
|
4
|
-
refId: number;
|
|
5
|
-
} & {
|
|
6
|
-
component: import("../../..").ReactUnity.IReactComponent;
|
|
7
|
-
fiberCache: import("./objects").ObjectsRepo<any>;
|
|
8
|
-
}, import("./types").AsyncNativeInstance, import("./types").AsyncNativeInstance, import("./types").AsyncNativeInstance, import("../../..").ReactUnity.IReactComponent>;
|
|
2
|
+
export declare const asyncReconciler: Reconciler.Reconciler<import("./types").AsyncContainerInstance, import("./types").AsyncInstance, import("./types").AsyncInstance, import("./types").AsyncNativeInstance, import("../../..").ReactUnity.IReactComponent>;
|
|
@@ -12,9 +12,28 @@ 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 { subContextRenderers } from '../subcontexts';
|
|
15
16
|
import { callbacksRepo, convertPropsToSerializable, objectsRepo } from './serializer';
|
|
16
17
|
var refId = 0;
|
|
17
18
|
var ctxMap = new Map();
|
|
19
|
+
var updateSubContext = function (instance) {
|
|
20
|
+
var rend = subContextRenderers[instance.type];
|
|
21
|
+
var root = instance === null || instance === void 0 ? void 0 : instance.root;
|
|
22
|
+
var cur = instance;
|
|
23
|
+
while (cur && !root) {
|
|
24
|
+
root = cur.root;
|
|
25
|
+
cur = cur.parent;
|
|
26
|
+
}
|
|
27
|
+
if (!root)
|
|
28
|
+
return;
|
|
29
|
+
var content = rend(root.subContext.node);
|
|
30
|
+
if (instance.type === 'richtext') {
|
|
31
|
+
instance.hostContext.commands.push(['x', { r: root.refId, c: content }]);
|
|
32
|
+
}
|
|
33
|
+
else if (instance.type === 'svg') {
|
|
34
|
+
instance.hostContext.commands.push(['u', __assign({ r: root.refId, t: 'svg' }, convertPropsToSerializable({ innerContent: content }))]);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
18
37
|
var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext: function (rootContainer) {
|
|
19
38
|
var context = rootContainer.context;
|
|
20
39
|
if (rootContainer.refId < 0) {
|
|
@@ -44,30 +63,105 @@ var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext:
|
|
|
44
63
|
var ctx = {
|
|
45
64
|
context: context,
|
|
46
65
|
commands: commands,
|
|
66
|
+
refId: rootContainer.refId,
|
|
67
|
+
type: 'native',
|
|
47
68
|
};
|
|
48
69
|
ctxMap.set(context, ctx);
|
|
49
70
|
return ctx;
|
|
50
|
-
}, getChildHostContext: function (parentCtx) {
|
|
71
|
+
}, getChildHostContext: function (parentCtx, type) {
|
|
72
|
+
if (type === 'richtext' && parentCtx.type === 'native')
|
|
73
|
+
return {
|
|
74
|
+
type: 'richtext',
|
|
75
|
+
hostContext: parentCtx,
|
|
76
|
+
node: null,
|
|
77
|
+
parent: null,
|
|
78
|
+
root: null,
|
|
79
|
+
};
|
|
80
|
+
if (type === 'svg' && parentCtx.type === 'native')
|
|
81
|
+
return {
|
|
82
|
+
type: 'svg',
|
|
83
|
+
hostContext: parentCtx,
|
|
84
|
+
node: null,
|
|
85
|
+
parent: null,
|
|
86
|
+
root: null,
|
|
87
|
+
};
|
|
51
88
|
return parentCtx;
|
|
52
89
|
}, getPublicInstance: function (instance) {
|
|
53
|
-
|
|
90
|
+
if (instance.type === 'native')
|
|
91
|
+
return instance.context.GetRef(instance.refId, instance.commands.length > 0);
|
|
92
|
+
return null;
|
|
54
93
|
}, 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) {
|
|
55
94
|
UnityBridge.clearContainer(container);
|
|
56
95
|
}, createInstance: function (type, props, rootContainer, ctx, internalHandle) {
|
|
57
|
-
refId++;
|
|
58
96
|
var aProps = getAllowedProps(props, type);
|
|
59
|
-
ctx.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
97
|
+
if (ctx.type === 'native') {
|
|
98
|
+
refId++;
|
|
99
|
+
ctx.commands.push(['c', __assign({ t: type, r: refId }, convertPropsToSerializable(aProps))]);
|
|
100
|
+
if (rootContainer.fiberCache)
|
|
101
|
+
rootContainer.fiberCache.setObject(refId, internalHandle);
|
|
102
|
+
var res = __assign(__assign({}, ctx), { refId: refId });
|
|
103
|
+
if (type === 'richtext') {
|
|
104
|
+
res.subContext = {
|
|
105
|
+
type: 'richtext',
|
|
106
|
+
node: {
|
|
107
|
+
tag: '',
|
|
108
|
+
children: [],
|
|
109
|
+
attributes: aProps,
|
|
110
|
+
},
|
|
111
|
+
root: res,
|
|
112
|
+
hostContext: res,
|
|
113
|
+
parent: null,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (type === 'svg') {
|
|
117
|
+
res.subContext = {
|
|
118
|
+
type: 'svg',
|
|
119
|
+
node: {
|
|
120
|
+
tag: '',
|
|
121
|
+
children: [],
|
|
122
|
+
attributes: aProps,
|
|
123
|
+
},
|
|
124
|
+
root: res,
|
|
125
|
+
hostContext: res,
|
|
126
|
+
parent: null,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return res;
|
|
130
|
+
}
|
|
131
|
+
else if (ctx.type === 'richtext' || ctx.type === 'svg') {
|
|
132
|
+
return __assign(__assign({}, ctx), { node: {
|
|
133
|
+
tag: type,
|
|
134
|
+
children: [],
|
|
135
|
+
attributes: aProps,
|
|
136
|
+
} });
|
|
137
|
+
}
|
|
63
138
|
}, createTextInstance: function (text, rootContainer, ctx, internalHandle) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
rootContainer.fiberCache
|
|
68
|
-
|
|
139
|
+
if (ctx.type === 'native') {
|
|
140
|
+
refId++;
|
|
141
|
+
ctx.commands.push(['t', { r: refId, c: text }]);
|
|
142
|
+
if (rootContainer.fiberCache)
|
|
143
|
+
rootContainer.fiberCache.setObject(refId, internalHandle);
|
|
144
|
+
return __assign(__assign({}, ctx), { refId: refId });
|
|
145
|
+
}
|
|
146
|
+
else if (ctx.type === 'richtext' || ctx.type === 'svg') {
|
|
147
|
+
return __assign(__assign({}, ctx), { node: { text: text } });
|
|
148
|
+
}
|
|
69
149
|
}, appendInitialChild: function (parent, child) {
|
|
70
|
-
|
|
150
|
+
if (!child)
|
|
151
|
+
return;
|
|
152
|
+
if (parent.type === 'native' && parent.subContext)
|
|
153
|
+
parent = parent.subContext;
|
|
154
|
+
if (parent.type === 'native' && child.type === 'native') {
|
|
155
|
+
parent.commands.push(['a', { p: parent.refId, c: child.refId }]);
|
|
156
|
+
}
|
|
157
|
+
else if ((parent.type === 'richtext' && child.type === 'richtext') ||
|
|
158
|
+
(parent.type === 'svg' && child.type === 'svg')) {
|
|
159
|
+
if ('children' in parent.node)
|
|
160
|
+
parent.node.children.push(child.node);
|
|
161
|
+
child.root = parent.root;
|
|
162
|
+
child.parent = parent;
|
|
163
|
+
updateSubContext(child);
|
|
164
|
+
}
|
|
71
165
|
}, finalizeInitialChildren: function () { return false; }, commitMount: function (instance) { }, shouldSetTextContent: function (type) { return textTypes[type]; },
|
|
72
166
|
// -------------------
|
|
73
167
|
// Mutation
|
|
@@ -76,30 +170,114 @@ var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext:
|
|
|
76
170
|
return diffProperties(oldProps, newProps);
|
|
77
171
|
}, commitUpdate: function (instance, updatePayload, type) {
|
|
78
172
|
var props = getAllowedProps(updatePayload, type);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
173
|
+
if (instance.type === 'native') {
|
|
174
|
+
instance.commands.push(['u', __assign({ r: instance.refId, t: type }, convertPropsToSerializable(props))]);
|
|
175
|
+
}
|
|
176
|
+
else if (instance.type === 'richtext' || instance.type === 'svg') {
|
|
177
|
+
if ('attributes' in instance.node)
|
|
178
|
+
instance.node.attributes = __assign(__assign({}, instance.node.attributes), props);
|
|
179
|
+
updateSubContext(instance);
|
|
180
|
+
}
|
|
181
|
+
}, commitTextUpdate: function (instance, oldText, newText) {
|
|
182
|
+
if (instance.type === 'native') {
|
|
183
|
+
instance.commands.push(['x', { r: instance.refId, c: newText }]);
|
|
184
|
+
}
|
|
185
|
+
else if (instance.type === 'richtext' || instance.type === 'svg') {
|
|
186
|
+
instance.node = { text: newText };
|
|
187
|
+
updateSubContext(instance);
|
|
188
|
+
}
|
|
82
189
|
}, appendChild: function (parent, child) {
|
|
83
|
-
|
|
190
|
+
if (!child)
|
|
191
|
+
return;
|
|
192
|
+
if (parent.type === 'native' && parent.subContext)
|
|
193
|
+
parent = parent.subContext;
|
|
194
|
+
if (parent.type === 'native' && child.type === 'native') {
|
|
195
|
+
child.commands.push(['a', { p: parent.refId, c: child.refId }]);
|
|
196
|
+
}
|
|
197
|
+
else if ((parent.type === 'richtext' && child.type === 'richtext') ||
|
|
198
|
+
(parent.type === 'svg' && child.type === 'svg')) {
|
|
199
|
+
if ('children' in parent.node)
|
|
200
|
+
parent.node.children.push(child.node);
|
|
201
|
+
child.root = parent.root;
|
|
202
|
+
child.parent = parent;
|
|
203
|
+
updateSubContext(child);
|
|
204
|
+
}
|
|
84
205
|
}, appendChildToContainer: function (parent, child) {
|
|
85
|
-
child.
|
|
206
|
+
if (child.type === 'native')
|
|
207
|
+
child.commands.push(['a', { p: parent.refId, c: child.refId }]);
|
|
86
208
|
}, insertBefore: function (parent, child, beforeChild) {
|
|
87
|
-
|
|
209
|
+
if (!child)
|
|
210
|
+
return;
|
|
211
|
+
if (parent.type === 'native' && parent.subContext)
|
|
212
|
+
parent = parent.subContext;
|
|
213
|
+
if (parent.type === 'native' && child.type === 'native' && beforeChild.type === 'native') {
|
|
214
|
+
child.commands.push(['i', { p: parent.refId, c: child.refId, i: beforeChild.refId }]);
|
|
215
|
+
}
|
|
216
|
+
else if ((parent.type === 'richtext' && child.type === 'richtext' && beforeChild.type === 'richtext') ||
|
|
217
|
+
(parent.type === 'svg' && child.type === 'svg' && beforeChild.type === 'svg')) {
|
|
218
|
+
if ('children' in parent.node) {
|
|
219
|
+
var index = parent.node.children.indexOf(beforeChild.node);
|
|
220
|
+
if (index >= 0)
|
|
221
|
+
parent.node.children.splice(index, 0, child.node);
|
|
222
|
+
else
|
|
223
|
+
parent.node.children.push(child.node);
|
|
224
|
+
}
|
|
225
|
+
child.root = parent.root;
|
|
226
|
+
child.parent = parent;
|
|
227
|
+
updateSubContext(child);
|
|
228
|
+
}
|
|
88
229
|
}, insertInContainerBefore: function (parent, child, beforeChild) {
|
|
89
|
-
child.
|
|
230
|
+
if (child.type === 'native' && beforeChild.type === 'native')
|
|
231
|
+
child.commands.push(['i', { p: parent.refId, c: child.refId, i: beforeChild.refId }]);
|
|
90
232
|
}, removeChild: function (parent, child) {
|
|
91
|
-
|
|
233
|
+
if (!child)
|
|
234
|
+
return;
|
|
235
|
+
if (parent.type === 'native' && parent.subContext)
|
|
236
|
+
parent = parent.subContext;
|
|
237
|
+
if (parent.type === 'native' && child.type === 'native') {
|
|
238
|
+
child.commands.push(['r', { p: parent.refId, c: child.refId }]);
|
|
239
|
+
}
|
|
240
|
+
else if ((parent.type === 'richtext' && child.type === 'richtext') ||
|
|
241
|
+
(parent.type === 'svg' && child.type === 'svg')) {
|
|
242
|
+
if ('children' in parent.node) {
|
|
243
|
+
var index = parent.node.children.indexOf(child.node);
|
|
244
|
+
if (index >= 0)
|
|
245
|
+
parent.node.children.splice(index, 1);
|
|
246
|
+
}
|
|
247
|
+
updateSubContext(parent);
|
|
248
|
+
}
|
|
92
249
|
}, removeChildFromContainer: function (parent, child) {
|
|
93
|
-
child.
|
|
250
|
+
if (child.type === 'native')
|
|
251
|
+
child.commands.push(['r', { p: parent.refId, c: child.refId }]);
|
|
94
252
|
}, resetTextContent: function () { }, preparePortalMount: function () { }, detachDeletedInstance: function () { },
|
|
95
253
|
// Required for Suspense
|
|
96
254
|
hideInstance: function (instance) {
|
|
97
|
-
|
|
255
|
+
if (instance.type === 'native')
|
|
256
|
+
instance.commands.push(['h', { r: instance.refId, h: true }]);
|
|
257
|
+
else if (instance.type === 'richtext' || instance.type === 'svg') {
|
|
258
|
+
instance.node.hidden = true;
|
|
259
|
+
updateSubContext(instance);
|
|
260
|
+
}
|
|
98
261
|
}, hideTextInstance: function (instance) {
|
|
99
|
-
|
|
262
|
+
if (instance.type === 'native')
|
|
263
|
+
instance.commands.push(['h', { r: instance.refId, h: true }]);
|
|
264
|
+
else if (instance.type === 'richtext' || instance.type === 'svg') {
|
|
265
|
+
instance.node.hidden = true;
|
|
266
|
+
updateSubContext(instance);
|
|
267
|
+
}
|
|
100
268
|
}, unhideInstance: function (instance) {
|
|
101
|
-
|
|
269
|
+
if (instance.type === 'native')
|
|
270
|
+
instance.commands.push(['h', { r: instance.refId, h: false }]);
|
|
271
|
+
else if (instance.type === 'richtext' || instance.type === 'svg') {
|
|
272
|
+
instance.node.hidden = false;
|
|
273
|
+
updateSubContext(instance);
|
|
274
|
+
}
|
|
102
275
|
}, unhideTextInstance: function (instance) {
|
|
103
|
-
|
|
276
|
+
if (instance.type === 'native')
|
|
277
|
+
instance.commands.push(['h', { r: instance.refId, h: false }]);
|
|
278
|
+
else if (instance.type === 'richtext' || instance.type === 'svg') {
|
|
279
|
+
instance.node.hidden = false;
|
|
280
|
+
updateSubContext(instance);
|
|
281
|
+
}
|
|
104
282
|
} });
|
|
105
283
|
export var asyncReconciler = Reconciler(hostConfig);
|