@reactunity/renderer 0.15.1 → 0.16.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.
Files changed (175) hide show
  1. package/dist/editor/index.d.ts +1 -0
  2. package/dist/editor/index.js +1 -0
  3. package/dist/editor/jsx-dev-runtime.d.ts +2 -0
  4. package/dist/editor/jsx-dev-runtime.js +1 -0
  5. package/dist/editor/jsx-runtime.d.ts +2 -0
  6. package/dist/editor/jsx-runtime.js +1 -0
  7. package/dist/index.d.ts +9 -9
  8. package/dist/index.js +9 -9
  9. package/dist/src/helpers/dictionary-watcher.d.ts +66 -66
  10. package/dist/src/helpers/dictionary-watcher.js +100 -98
  11. package/dist/src/helpers/hooks/use-globals.d.ts +6 -6
  12. package/dist/src/helpers/hooks/use-globals.js +6 -6
  13. package/dist/src/helpers/hooks/use-reactive-value.d.ts +4 -4
  14. package/dist/src/helpers/hooks/use-reactive-value.js +27 -27
  15. package/dist/src/helpers/icons.d.ts +11 -7
  16. package/dist/src/helpers/icons.js +29 -29
  17. package/dist/src/models/base.d.ts +56 -56
  18. package/dist/src/models/base.js +2 -2
  19. package/dist/src/models/editor/components.d.ts +22 -22
  20. package/dist/src/models/editor/components.js +1 -1
  21. package/dist/src/models/editor/environment.d.ts +9 -10
  22. package/dist/src/models/editor/environment.js +1 -1
  23. package/dist/src/models/editor/index.d.ts +3 -3
  24. package/dist/src/models/editor/index.js +3 -3
  25. package/dist/src/models/editor/jsx.d.ts +111 -104
  26. package/dist/src/models/editor/jsx.js +1 -1
  27. package/dist/src/models/environment/dom/common.d.ts +85 -85
  28. package/dist/src/models/environment/dom/common.js +1 -1
  29. package/dist/src/models/environment/dom/fetch.d.ts +111 -111
  30. package/dist/src/models/environment/dom/fetch.js +1 -1
  31. package/dist/src/models/environment/dom/global.d.ts +11 -11
  32. package/dist/src/models/environment/dom/global.js +1 -1
  33. package/dist/src/models/environment/dom/xhr.d.ts +161 -161
  34. package/dist/src/models/environment/dom/xhr.js +1 -1
  35. package/dist/src/models/environment/index.d.ts +43 -47
  36. package/dist/src/models/environment/index.js +2 -3
  37. package/dist/src/models/environment/interop.d.ts +23 -23
  38. package/dist/src/models/environment/interop.js +1 -1
  39. package/dist/src/models/generated/editor.d.ts +18501 -18501
  40. package/dist/src/models/generated/editor.js +6 -6
  41. package/dist/src/models/generated/index.d.ts +6 -6
  42. package/dist/src/models/generated/index.js +6 -6
  43. package/dist/src/models/generated/react.d.ts +15214 -15214
  44. package/dist/src/models/generated/react.js +6 -6
  45. package/dist/src/models/generated/system.d.ts +36731 -36731
  46. package/dist/src/models/generated/system.js +6 -6
  47. package/dist/src/models/generated/tests.d.ts +5023 -5023
  48. package/dist/src/models/generated/tests.js +6 -6
  49. package/dist/src/models/generated/unity.d.ts +43446 -43446
  50. package/dist/src/models/generated/unity.js +6 -6
  51. package/dist/src/models/generated/yoga.d.ts +368 -368
  52. package/dist/src/models/generated/yoga.js +6 -6
  53. package/dist/src/models/properties/colors.d.ts +150 -150
  54. package/dist/src/models/properties/colors.js +1 -1
  55. package/dist/src/models/properties/common.d.ts +2 -2
  56. package/dist/src/models/properties/common.js +1 -1
  57. package/dist/src/models/properties/index.d.ts +7 -7
  58. package/dist/src/models/properties/index.js +7 -7
  59. package/dist/src/models/properties/style.d.ts +10 -10
  60. package/dist/src/models/properties/style.js +1 -1
  61. package/dist/src/models/properties/styles-enums.d.ts +23 -23
  62. package/dist/src/models/properties/styles-enums.js +1 -1
  63. package/dist/src/models/properties/styles.d.ts +127 -127
  64. package/dist/src/models/properties/styles.js +1 -1
  65. package/dist/src/models/properties/values.d.ts +24 -24
  66. package/dist/src/models/properties/values.js +1 -1
  67. package/dist/src/models/properties/yoga-enums.d.ts +8 -8
  68. package/dist/src/models/properties/yoga-enums.js +1 -1
  69. package/dist/src/models/properties/yoga.d.ts +66 -66
  70. package/dist/src/models/properties/yoga.js +1 -1
  71. package/dist/src/models/renderer.d.ts +20 -20
  72. package/dist/src/models/renderer.js +1 -1
  73. package/dist/src/models/richtext.d.ts +69 -69
  74. package/dist/src/models/richtext.js +2 -2
  75. package/dist/src/models/svg.d.ts +68 -68
  76. package/dist/src/models/svg.js +1 -1
  77. package/dist/src/models/tests/index.d.ts +12 -12
  78. package/dist/src/models/tests/index.js +1 -1
  79. package/dist/src/models/ugui/components.d.ts +86 -86
  80. package/dist/src/models/ugui/components.js +1 -1
  81. package/dist/src/models/ugui/events.d.ts +74 -74
  82. package/dist/src/models/ugui/events.js +2 -2
  83. package/dist/src/models/ugui/index.d.ts +4 -4
  84. package/dist/src/models/ugui/index.js +4 -4
  85. package/dist/src/models/ugui/input.d.ts +26 -26
  86. package/dist/src/models/ugui/input.js +1 -1
  87. package/dist/src/models/ugui/jsx.d.ts +67 -60
  88. package/dist/src/models/ugui/jsx.js +1 -1
  89. package/dist/src/models/uitoolkit/components.d.ts +82 -82
  90. package/dist/src/models/uitoolkit/components.js +1 -1
  91. package/dist/src/models/uitoolkit/events.d.ts +64 -64
  92. package/dist/src/models/uitoolkit/events.js +1 -1
  93. package/dist/src/models/uitoolkit/index.d.ts +3 -3
  94. package/dist/src/models/uitoolkit/index.js +3 -3
  95. package/dist/src/models/uitoolkit/jsx.d.ts +71 -64
  96. package/dist/src/models/uitoolkit/jsx.js +1 -1
  97. package/dist/src/renderer/async/callbacks.d.ts +5 -6
  98. package/dist/src/renderer/async/callbacks.js +52 -52
  99. package/dist/src/renderer/async/commands.d.ts +98 -47
  100. package/dist/src/renderer/async/commands.js +1 -1
  101. package/dist/src/renderer/async/objects.d.ts +7 -8
  102. package/dist/src/renderer/async/objects.js +31 -31
  103. package/dist/src/renderer/async/reconciler.d.ts +2 -2
  104. package/dist/src/renderer/async/reconciler.js +304 -283
  105. package/dist/src/renderer/async/serializer.d.ts +6 -9
  106. package/dist/src/renderer/async/serializer.js +31 -31
  107. package/dist/src/renderer/async/types.d.ts +45 -45
  108. package/dist/src/renderer/async/types.js +1 -1
  109. package/dist/src/renderer/constants.d.ts +30 -30
  110. package/dist/src/renderer/constants.js +70 -70
  111. package/dist/src/renderer/diffing.d.ts +3 -3
  112. package/dist/src/renderer/diffing.js +83 -83
  113. package/dist/src/renderer/renderer.d.ts +26 -26
  114. package/dist/src/renderer/renderer.js +93 -93
  115. package/dist/src/renderer/subcontexts/index.d.ts +6 -6
  116. package/dist/src/renderer/subcontexts/index.js +6 -6
  117. package/dist/src/renderer/subcontexts/richtext.d.ts +3 -3
  118. package/dist/src/renderer/subcontexts/richtext.js +52 -52
  119. package/dist/src/renderer/subcontexts/svg.d.ts +3 -3
  120. package/dist/src/renderer/subcontexts/svg.js +70 -70
  121. package/dist/src/renderer/sync/reconciler.d.ts +2 -2
  122. package/dist/src/renderer/sync/reconciler.js +35 -35
  123. package/dist/src/version.d.ts +1 -1
  124. package/dist/src/version.js +1 -1
  125. package/dist/src/views/default-view.d.ts +8 -8
  126. package/dist/src/views/default-view.js +7 -7
  127. package/dist/src/views/error-boundary.d.ts +10 -10
  128. package/dist/src/views/error-boundary.js +42 -53
  129. package/dist/src/webgl-compat/error-messages.d.ts +9 -9
  130. package/dist/src/webgl-compat/error-messages.js +10 -10
  131. package/dist/src/webgl-compat/index.d.ts +13 -13
  132. package/dist/src/webgl-compat/index.js +8 -8
  133. package/dist/src/webgl-compat/types.d.ts +21 -21
  134. package/dist/src/webgl-compat/types.js +1 -1
  135. package/dist/src/webgl-compat/use-event-system.d.ts +3 -3
  136. package/dist/src/webgl-compat/use-event-system.js +77 -76
  137. package/dist/src/webgl-compat/use-unity-context.d.ts +31 -31
  138. package/dist/src/webgl-compat/use-unity-context.js +92 -91
  139. package/dist/tests.d.ts +1 -1
  140. package/dist/tests.js +1 -1
  141. package/dist/ugui/index.d.ts +1 -0
  142. package/dist/ugui/index.js +1 -0
  143. package/dist/ugui/jsx-dev-runtime.d.ts +2 -0
  144. package/dist/ugui/jsx-dev-runtime.js +1 -0
  145. package/dist/ugui/jsx-runtime.d.ts +2 -0
  146. package/dist/ugui/jsx-runtime.js +1 -0
  147. package/dist/uitoolkit/index.d.ts +1 -0
  148. package/dist/uitoolkit/index.js +1 -0
  149. package/dist/uitoolkit/jsx-dev-runtime.d.ts +2 -0
  150. package/dist/uitoolkit/jsx-dev-runtime.js +1 -0
  151. package/dist/uitoolkit/jsx-runtime.d.ts +2 -0
  152. package/dist/uitoolkit/jsx-runtime.js +1 -0
  153. package/dist/webgl-compat.d.ts +1 -1
  154. package/dist/webgl-compat.js +1 -1
  155. package/editor/jsx-dev-runtime.ts +4 -0
  156. package/editor/jsx-runtime.ts +4 -0
  157. package/package.json +13 -32
  158. package/ugui/jsx-dev-runtime.ts +4 -0
  159. package/ugui/jsx-runtime.ts +4 -0
  160. package/uitoolkit/jsx-dev-runtime.ts +4 -0
  161. package/uitoolkit/jsx-runtime.ts +4 -0
  162. package/dist/editor.d.ts +0 -1
  163. package/dist/editor.js +0 -1
  164. package/dist/src/models/environment/jsx.d.ts +0 -45
  165. package/dist/src/models/environment/jsx.js +0 -1
  166. package/dist/ugui.d.ts +0 -1
  167. package/dist/ugui.js +0 -1
  168. package/dist/uitoolkit.d.ts +0 -1
  169. package/dist/uitoolkit.js +0 -1
  170. package/editor.ts +0 -1
  171. package/tsconfig.editor.json +0 -6
  172. package/tsconfig.ugui.json +0 -6
  173. package/tsconfig.uitoolkit.json +0 -6
  174. package/ugui.ts +0 -1
  175. package/uitoolkit.ts +0 -1
@@ -1,283 +1,304 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
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';
17
- var refId = 0;
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
- };
37
- var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext: function (rootContainer) {
38
- var context = rootContainer.context;
39
- if (rootContainer.refId < 0) {
40
- refId++;
41
- rootContainer.context.SetRef(refId, rootContainer.component);
42
- rootContainer.refId = refId;
43
- }
44
- var existing = ctxMap.get(context);
45
- if (existing)
46
- return existing;
47
- var commands = rootContainer.commands;
48
- var flushCommands = function () {
49
- var serialized = JSON.stringify(commands);
50
- commands.length = 0;
51
- return serialized;
52
- };
53
- var fireEventByRef = function (ind, args) {
54
- return callbacksRepo.call(ind, args);
55
- };
56
- var getObjectRef = function (ind) {
57
- return objectsRepo.getObject(ind);
58
- };
59
- var getEventAsObjectRef = function (ind) {
60
- return callbacksRepo.getObject(ind);
61
- };
62
- context.BindCommands(flushCommands, fireEventByRef, getObjectRef, getEventAsObjectRef);
63
- var ctx = {
64
- context: context,
65
- commands: commands,
66
- refId: rootContainer.refId,
67
- type: 'native',
68
- };
69
- ctxMap.set(context, ctx);
70
- return ctx;
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
- };
88
- return parentCtx;
89
- }, getPublicInstance: function (instance) {
90
- if (instance.type === 'native')
91
- return instance.context.GetRef(instance.refId, instance.commands.length > 0);
92
- return null;
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) {
94
- UnityBridge.clearContainer(container);
95
- }, createInstance: function (type, props, rootContainer, ctx, internalHandle) {
96
- var aProps = getAllowedProps(props, type);
97
- if (ctx.type === 'native') {
98
- refId++;
99
- ctx.commands.push(['c', __assign({ t: type, r: refId, k: stringizePoolKey(props.pool) }, 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
- }
138
- }, createTextInstance: function (text, rootContainer, ctx, internalHandle) {
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
- }
149
- }, appendInitialChild: function (parent, child) {
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
- }
165
- }, finalizeInitialChildren: function () { return false; }, commitMount: function (instance) { }, shouldSetTextContent: function (type) { return textTypes[type]; },
166
- // -------------------
167
- // Mutation
168
- // -------------------
169
- prepareUpdate: function (instance, type, oldProps, newProps) {
170
- return diffProperties(oldProps, newProps);
171
- }, commitUpdate: function (instance, updatePayload, type) {
172
- var props = getAllowedProps(updatePayload, type);
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
- }
189
- }, appendChild: function (parent, child) {
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
- }
205
- }, appendChildToContainer: function (parent, child) {
206
- if (child.type === 'native')
207
- child.commands.push(['a', { p: parent.refId, c: child.refId }]);
208
- }, insertBefore: function (parent, child, beforeChild) {
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
- }
229
- }, insertInContainerBefore: function (parent, child, beforeChild) {
230
- if (child.type === 'native' && beforeChild.type === 'native')
231
- child.commands.push(['i', { p: parent.refId, c: child.refId, i: beforeChild.refId }]);
232
- }, removeChild: function (parent, child) {
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
- }
249
- }, removeChildFromContainer: function (parent, child) {
250
- if (child.type === 'native')
251
- child.commands.push(['r', { p: parent.refId, c: child.refId }]);
252
- }, resetTextContent: function () { }, preparePortalMount: function () { }, detachDeletedInstance: function () { },
253
- // Required for Suspense
254
- hideInstance: function (instance) {
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
- }
261
- }, hideTextInstance: function (instance) {
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
- }
268
- }, unhideInstance: function (instance) {
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
- }
275
- }, unhideTextInstance: function (instance) {
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
- }
282
- } });
283
- export var asyncReconciler = Reconciler(hostConfig);
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
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';
17
+ var refId = 0;
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
+ instance.hostContext.commands.push([6, root.refId, content]);
33
+ }
34
+ else if (instance.type === 'svg') {
35
+ // instance.hostContext.commands.push(['u', { r: root.refId, t: 'svg', ...convertPropsToSerializable({ innerContent: content }) }]);
36
+ instance.hostContext.commands.push([5, root.refId, 'svg', convertPropsToSerializable({ innerContent: content })]);
37
+ }
38
+ };
39
+ var hostConfig = __assign(__assign({}, commonReconciler), { getRootHostContext: function (rootContainer) {
40
+ var context = rootContainer.context;
41
+ if (rootContainer.refId < 0) {
42
+ refId++;
43
+ rootContainer.context.SetRef(refId, rootContainer.component);
44
+ rootContainer.refId = refId;
45
+ }
46
+ var existing = ctxMap.get(context);
47
+ if (existing)
48
+ return existing;
49
+ var commands = rootContainer.commands;
50
+ var flushCommands = function () {
51
+ var serialized = JSON.stringify(commands);
52
+ commands.length = 0;
53
+ return serialized;
54
+ };
55
+ var fireEventByRef = function (ind, args) {
56
+ return callbacksRepo.call(ind, args);
57
+ };
58
+ var getObjectRef = function (ind) {
59
+ return objectsRepo.getObject(ind);
60
+ };
61
+ var getEventAsObjectRef = function (ind) {
62
+ return callbacksRepo.getObject(ind);
63
+ };
64
+ context.BindCommands(flushCommands, fireEventByRef, getObjectRef, getEventAsObjectRef);
65
+ var ctx = {
66
+ context: context,
67
+ commands: commands,
68
+ refId: rootContainer.refId,
69
+ type: 'native',
70
+ };
71
+ ctxMap.set(context, ctx);
72
+ return ctx;
73
+ }, getChildHostContext: function (parentCtx, type) {
74
+ if (type === 'richtext' && parentCtx.type === 'native')
75
+ return {
76
+ type: 'richtext',
77
+ hostContext: parentCtx,
78
+ node: null,
79
+ parent: null,
80
+ root: null,
81
+ };
82
+ if (type === 'svg' && parentCtx.type === 'native')
83
+ return {
84
+ type: 'svg',
85
+ hostContext: parentCtx,
86
+ node: null,
87
+ parent: null,
88
+ root: null,
89
+ };
90
+ return parentCtx;
91
+ }, getPublicInstance: function (instance) {
92
+ if (instance.type === 'native')
93
+ return instance.context.GetRef(instance.refId, instance.commands.length > 0);
94
+ return null;
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) {
96
+ UnityBridge.clearContainer(container);
97
+ }, createInstance: function (type, props, rootContainer, ctx, internalHandle) {
98
+ var aProps = getAllowedProps(props, type);
99
+ if (ctx.type === 'native') {
100
+ refId++;
101
+ // ctx.commands.push(['c', { t: type, r: refId, k: stringizePoolKey(props.pool), ...convertPropsToSerializable(aProps) }]);
102
+ ctx.commands.push([0, refId, type, convertPropsToSerializable(aProps), stringizePoolKey(props.pool)]);
103
+ if (rootContainer.fiberCache)
104
+ rootContainer.fiberCache.setObject(refId, internalHandle);
105
+ var res = __assign(__assign({}, ctx), { refId: refId });
106
+ if (type === 'richtext') {
107
+ res.subContext = {
108
+ type: 'richtext',
109
+ node: {
110
+ tag: '',
111
+ children: [],
112
+ attributes: aProps,
113
+ },
114
+ root: res,
115
+ hostContext: res,
116
+ parent: null,
117
+ };
118
+ }
119
+ if (type === 'svg') {
120
+ res.subContext = {
121
+ type: 'svg',
122
+ node: {
123
+ tag: '',
124
+ children: [],
125
+ attributes: aProps,
126
+ },
127
+ root: res,
128
+ hostContext: res,
129
+ parent: null,
130
+ };
131
+ }
132
+ return res;
133
+ }
134
+ else if (ctx.type === 'richtext' || ctx.type === 'svg') {
135
+ return __assign(__assign({}, ctx), { node: {
136
+ tag: type,
137
+ children: [],
138
+ attributes: aProps,
139
+ } });
140
+ }
141
+ }, createTextInstance: function (text, rootContainer, ctx, internalHandle) {
142
+ if (ctx.type === 'native') {
143
+ refId++;
144
+ // ctx.commands.push(['t', { r: refId, c: text }]);
145
+ ctx.commands.push([1, refId, text]);
146
+ if (rootContainer.fiberCache)
147
+ rootContainer.fiberCache.setObject(refId, internalHandle);
148
+ return __assign(__assign({}, ctx), { refId: refId });
149
+ }
150
+ else if (ctx.type === 'richtext' || ctx.type === 'svg') {
151
+ return __assign(__assign({}, ctx), { node: { text: text } });
152
+ }
153
+ }, appendInitialChild: function (parent, child) {
154
+ if (!child)
155
+ return;
156
+ if (parent.type === 'native' && parent.subContext)
157
+ parent = parent.subContext;
158
+ if (parent.type === 'native' && child.type === 'native') {
159
+ // parent.commands.push(['a', { p: parent.refId, c: child.refId }]);
160
+ parent.commands.push([2, parent.refId, child.refId]);
161
+ }
162
+ else if ((parent.type === 'richtext' && child.type === 'richtext') ||
163
+ (parent.type === 'svg' && child.type === 'svg')) {
164
+ if ('children' in parent.node)
165
+ parent.node.children.push(child.node);
166
+ child.root = parent.root;
167
+ child.parent = parent;
168
+ updateSubContext(child);
169
+ }
170
+ }, finalizeInitialChildren: function () { return false; }, commitMount: function (instance) { }, shouldSetTextContent: function (type) { return textTypes[type]; },
171
+ // -------------------
172
+ // Mutation
173
+ // -------------------
174
+ prepareUpdate: function (instance, type, oldProps, newProps) {
175
+ return diffProperties(oldProps, newProps);
176
+ }, commitUpdate: function (instance, updatePayload, type) {
177
+ var props = getAllowedProps(updatePayload, type);
178
+ if (instance.type === 'native') {
179
+ // instance.commands.push(['u', { r: instance.refId, t: type, ...convertPropsToSerializable(props) }]);
180
+ instance.commands.push([5, instance.refId, type, convertPropsToSerializable(props)]);
181
+ }
182
+ else if (instance.type === 'richtext' || instance.type === 'svg') {
183
+ if ('attributes' in instance.node)
184
+ instance.node.attributes = __assign(__assign({}, instance.node.attributes), props);
185
+ updateSubContext(instance);
186
+ }
187
+ }, commitTextUpdate: function (instance, oldText, newText) {
188
+ if (instance.type === 'native') {
189
+ // instance.commands.push(['x', { r: instance.refId, c: newText }]);
190
+ instance.commands.push([6, instance.refId, newText]);
191
+ }
192
+ else if (instance.type === 'richtext' || instance.type === 'svg') {
193
+ instance.node = { text: newText };
194
+ updateSubContext(instance);
195
+ }
196
+ }, appendChild: function (parent, child) {
197
+ if (!child)
198
+ return;
199
+ if (parent.type === 'native' && parent.subContext)
200
+ parent = parent.subContext;
201
+ if (parent.type === 'native' && child.type === 'native') {
202
+ // child.commands.push(['a', { p: parent.refId, c: child.refId }]);
203
+ child.commands.push([2, parent.refId, child.refId]);
204
+ }
205
+ else if ((parent.type === 'richtext' && child.type === 'richtext') ||
206
+ (parent.type === 'svg' && child.type === 'svg')) {
207
+ if ('children' in parent.node)
208
+ parent.node.children.push(child.node);
209
+ child.root = parent.root;
210
+ child.parent = parent;
211
+ updateSubContext(child);
212
+ }
213
+ }, appendChildToContainer: function (parent, child) {
214
+ if (child.type === 'native')
215
+ // child.commands.push(['a', { p: parent.refId, c: child.refId }]);
216
+ child.commands.push([2, parent.refId, child.refId]);
217
+ }, insertBefore: function (parent, child, beforeChild) {
218
+ if (!child)
219
+ return;
220
+ if (parent.type === 'native' && parent.subContext)
221
+ parent = parent.subContext;
222
+ if (parent.type === 'native' && child.type === 'native' && beforeChild.type === 'native') {
223
+ // child.commands.push(['i', { p: parent.refId, c: child.refId, i: beforeChild.refId }]);
224
+ child.commands.push([4, parent.refId, child.refId, beforeChild.refId]);
225
+ }
226
+ else if ((parent.type === 'richtext' && child.type === 'richtext' && beforeChild.type === 'richtext') ||
227
+ (parent.type === 'svg' && child.type === 'svg' && beforeChild.type === 'svg')) {
228
+ if ('children' in parent.node) {
229
+ var index = parent.node.children.indexOf(beforeChild.node);
230
+ if (index >= 0)
231
+ parent.node.children.splice(index, 0, child.node);
232
+ else
233
+ parent.node.children.push(child.node);
234
+ }
235
+ child.root = parent.root;
236
+ child.parent = parent;
237
+ updateSubContext(child);
238
+ }
239
+ }, insertInContainerBefore: function (parent, child, beforeChild) {
240
+ if (child.type === 'native' && beforeChild.type === 'native')
241
+ // child.commands.push(['i', { p: parent.refId, c: child.refId, i: beforeChild.refId }]);
242
+ child.commands.push([4, parent.refId, child.refId, beforeChild.refId]);
243
+ }, removeChild: function (parent, child) {
244
+ if (!child)
245
+ return;
246
+ if (parent.type === 'native' && parent.subContext)
247
+ parent = parent.subContext;
248
+ if (parent.type === 'native' && child.type === 'native') {
249
+ // child.commands.push(['r', { p: parent.refId, c: child.refId }]);
250
+ child.commands.push([3, parent.refId, child.refId]);
251
+ }
252
+ else if ((parent.type === 'richtext' && child.type === 'richtext') ||
253
+ (parent.type === 'svg' && child.type === 'svg')) {
254
+ if ('children' in parent.node) {
255
+ var index = parent.node.children.indexOf(child.node);
256
+ if (index >= 0)
257
+ parent.node.children.splice(index, 1);
258
+ }
259
+ updateSubContext(parent);
260
+ }
261
+ }, removeChildFromContainer: function (parent, child) {
262
+ if (child.type === 'native')
263
+ // child.commands.push(['r', { p: parent.refId, c: child.refId }]);
264
+ child.commands.push([3, parent.refId, child.refId]);
265
+ }, resetTextContent: function () { }, preparePortalMount: function () { }, detachDeletedInstance: function () { },
266
+ // Required for Suspense
267
+ hideInstance: function (instance) {
268
+ if (instance.type === 'native') {
269
+ // instance.commands.push(['h', { r: instance.refId, h: true }]);
270
+ instance.commands.push([7, instance.refId, true]);
271
+ }
272
+ else if (instance.type === 'richtext' || instance.type === 'svg') {
273
+ instance.node.hidden = true;
274
+ updateSubContext(instance);
275
+ }
276
+ }, hideTextInstance: function (instance) {
277
+ if (instance.type === 'native') {
278
+ // instance.commands.push(['h', { r: instance.refId, h: true }]);
279
+ instance.commands.push([7, instance.refId, true]);
280
+ }
281
+ else if (instance.type === 'richtext' || instance.type === 'svg') {
282
+ instance.node.hidden = true;
283
+ updateSubContext(instance);
284
+ }
285
+ }, unhideInstance: function (instance) {
286
+ if (instance.type === 'native') {
287
+ // instance.commands.push(['h', { r: instance.refId, h: false }]);
288
+ instance.commands.push([7, instance.refId, false]);
289
+ }
290
+ else if (instance.type === 'richtext' || instance.type === 'svg') {
291
+ instance.node.hidden = false;
292
+ updateSubContext(instance);
293
+ }
294
+ }, unhideTextInstance: function (instance) {
295
+ if (instance.type === 'native') {
296
+ // instance.commands.push(['h', { r: instance.refId, h: false }]);
297
+ instance.commands.push([7, instance.refId, false]);
298
+ }
299
+ else if (instance.type === 'richtext' || instance.type === 'svg') {
300
+ instance.node.hidden = false;
301
+ updateSubContext(instance);
302
+ }
303
+ } });
304
+ export var asyncReconciler = Reconciler(hostConfig);
@@ -1,9 +1,6 @@
1
- import { CallbacksRepo } from './callbacks';
2
- import { ObjectsRepo } from './objects';
3
- export declare const callbacksRepo: CallbacksRepo;
4
- export declare const objectsRepo: ObjectsRepo<any>;
5
- export declare function convertPropsToSerializable(props: any): {
6
- p: any;
7
- o: any;
8
- e: any;
9
- };
1
+ import { CallbacksRepo } from './callbacks';
2
+ import { SerializableUpdateProps } from './commands';
3
+ import { ObjectsRepo } from './objects';
4
+ export declare const callbacksRepo: CallbacksRepo;
5
+ export declare const objectsRepo: ObjectsRepo<any>;
6
+ export declare function convertPropsToSerializable(props: any): SerializableUpdateProps;