@reactunity/renderer 0.15.2 → 0.16.1

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