@textbus/adapter-react 5.2.3 → 5.2.4
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.esm.js +344 -130
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +347 -129
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,138 +1,352 @@
|
|
|
1
|
-
import { makeError, VElement, VTextNode, Adapter } from
|
|
2
|
-
import { DomAdapter } from
|
|
3
|
-
import {
|
|
4
|
-
import { ReflectiveInjector } from
|
|
5
|
-
import { merge } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
import { makeError, VElement, VTextNode, Adapter } from '@textbus/core';
|
|
2
|
+
import { DomAdapter } from '@textbus/platform-browser';
|
|
3
|
+
import { useState, useEffect, createElement } from 'react';
|
|
4
|
+
import { ReflectiveInjector } from '@viewfly/core';
|
|
5
|
+
import { merge } from '@tanbo/stream';
|
|
6
|
+
|
|
7
|
+
function _array_like_to_array(arr, len) {
|
|
8
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
9
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
10
|
+
return arr2;
|
|
11
|
+
}
|
|
12
|
+
function _array_with_holes(arr) {
|
|
13
|
+
if (Array.isArray(arr)) return arr;
|
|
14
|
+
}
|
|
15
|
+
function _array_without_holes(arr) {
|
|
16
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
17
|
+
}
|
|
18
|
+
function _assert_this_initialized(self) {
|
|
19
|
+
if (self === void 0) {
|
|
20
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
21
|
+
}
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
function _call_super(_this, derived, args) {
|
|
25
|
+
derived = _get_prototype_of(derived);
|
|
26
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
27
|
+
}
|
|
28
|
+
function _class_call_check(instance, Constructor) {
|
|
29
|
+
if (!(instance instanceof Constructor)) {
|
|
30
|
+
throw new TypeError("Cannot call a class as a function");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function _defineProperties(target, props) {
|
|
34
|
+
for(var i = 0; i < props.length; i++){
|
|
35
|
+
var descriptor = props[i];
|
|
36
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
37
|
+
descriptor.configurable = true;
|
|
38
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
39
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
43
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
44
|
+
return Constructor;
|
|
45
|
+
}
|
|
46
|
+
function _define_property(obj, key, value) {
|
|
47
|
+
if (key in obj) {
|
|
48
|
+
Object.defineProperty(obj, key, {
|
|
49
|
+
value: value,
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
obj[key] = value;
|
|
56
|
+
}
|
|
57
|
+
return obj;
|
|
58
|
+
}
|
|
59
|
+
function _get(target, property, receiver) {
|
|
60
|
+
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
61
|
+
_get = Reflect.get;
|
|
62
|
+
} else {
|
|
63
|
+
_get = function get(target, property, receiver) {
|
|
64
|
+
var base = _super_prop_base(target, property);
|
|
65
|
+
if (!base) return;
|
|
66
|
+
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
67
|
+
if (desc.get) {
|
|
68
|
+
return desc.get.call(receiver || target);
|
|
44
69
|
}
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
70
|
+
return desc.value;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return _get(target, property, receiver || target);
|
|
74
|
+
}
|
|
75
|
+
function _get_prototype_of(o) {
|
|
76
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
77
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
78
|
+
};
|
|
79
|
+
return _get_prototype_of(o);
|
|
80
|
+
}
|
|
81
|
+
function _inherits(subClass, superClass) {
|
|
82
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
83
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
84
|
+
}
|
|
85
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
86
|
+
constructor: {
|
|
87
|
+
value: subClass,
|
|
88
|
+
writable: true,
|
|
89
|
+
configurable: true
|
|
48
90
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
91
|
+
});
|
|
92
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
93
|
+
}
|
|
94
|
+
function _instanceof(left, right) {
|
|
95
|
+
"@swc/helpers - instanceof";
|
|
96
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
97
|
+
return !!right[Symbol.hasInstance](left);
|
|
98
|
+
} else {
|
|
99
|
+
return left instanceof right;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function _iterable_to_array(iter) {
|
|
103
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
104
|
+
}
|
|
105
|
+
function _iterable_to_array_limit(arr, i) {
|
|
106
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
107
|
+
if (_i == null) return;
|
|
108
|
+
var _arr = [];
|
|
109
|
+
var _n = true;
|
|
110
|
+
var _d = false;
|
|
111
|
+
var _s, _e;
|
|
112
|
+
try {
|
|
113
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
114
|
+
_arr.push(_s.value);
|
|
115
|
+
if (i && _arr.length === i) break;
|
|
58
116
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
if (vNode.classes.size) {
|
|
69
|
-
props.className = Array.from(vNode.classes).join(" ");
|
|
117
|
+
} catch (err) {
|
|
118
|
+
_d = true;
|
|
119
|
+
_e = err;
|
|
120
|
+
} finally{
|
|
121
|
+
try {
|
|
122
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
123
|
+
} finally{
|
|
124
|
+
if (_d) throw _e;
|
|
70
125
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
126
|
+
}
|
|
127
|
+
return _arr;
|
|
128
|
+
}
|
|
129
|
+
function _non_iterable_rest() {
|
|
130
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
131
|
+
}
|
|
132
|
+
function _non_iterable_spread() {
|
|
133
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
134
|
+
}
|
|
135
|
+
function _object_spread(target) {
|
|
136
|
+
for(var i = 1; i < arguments.length; i++){
|
|
137
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
138
|
+
var ownKeys = Object.keys(source);
|
|
139
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
140
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
141
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
142
|
+
}));
|
|
76
143
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, mount);
|
|
80
|
-
Object.keys(components).forEach((key) => {
|
|
81
|
-
this.components[key] = (props) => {
|
|
82
|
-
const component = props.component;
|
|
83
|
-
const [updateKey, refreshUpdateKey] = useState(Math.random());
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
const sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {
|
|
86
|
-
if (component.changeMarker.dirty) {
|
|
87
|
-
refreshUpdateKey(Math.random());
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return () => {
|
|
91
|
-
sub.unsubscribe();
|
|
92
|
-
};
|
|
93
|
-
}, []);
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
this.onViewUpdated.next();
|
|
96
|
-
}, [updateKey]);
|
|
97
|
-
const vNode = components[key]({
|
|
98
|
-
component,
|
|
99
|
-
rootRef: (rootNode) => {
|
|
100
|
-
if (rootNode) {
|
|
101
|
-
this.componentRootElementCaches.set(component, rootNode);
|
|
102
|
-
} else {
|
|
103
|
-
if (this.componentRootElementCaches.get(component) === rootNode) {
|
|
104
|
-
this.componentRootElementCaches.remove(component);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
144
|
+
ownKeys.forEach(function(key) {
|
|
145
|
+
_define_property(target, key, source[key]);
|
|
108
146
|
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
147
|
+
}
|
|
148
|
+
return target;
|
|
149
|
+
}
|
|
150
|
+
function _possible_constructor_return(self, call) {
|
|
151
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
152
|
+
return call;
|
|
153
|
+
}
|
|
154
|
+
return _assert_this_initialized(self);
|
|
155
|
+
}
|
|
156
|
+
function _set_prototype_of(o, p) {
|
|
157
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
158
|
+
o.__proto__ = p;
|
|
159
|
+
return o;
|
|
160
|
+
};
|
|
161
|
+
return _set_prototype_of(o, p);
|
|
162
|
+
}
|
|
163
|
+
function _sliced_to_array(arr, i) {
|
|
164
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
165
|
+
}
|
|
166
|
+
function _super_prop_base(object, property) {
|
|
167
|
+
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
168
|
+
object = _get_prototype_of(object);
|
|
169
|
+
if (object === null) break;
|
|
170
|
+
}
|
|
171
|
+
return object;
|
|
172
|
+
}
|
|
173
|
+
function _to_consumable_array(arr) {
|
|
174
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
175
|
+
}
|
|
176
|
+
function _type_of(obj) {
|
|
177
|
+
"@swc/helpers - typeof";
|
|
178
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
179
|
+
}
|
|
180
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
181
|
+
if (!o) return;
|
|
182
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
183
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
184
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
185
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
186
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
187
|
+
}
|
|
188
|
+
function _is_native_reflect_construct() {
|
|
189
|
+
try {
|
|
190
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
191
|
+
} catch (_) {}
|
|
192
|
+
return (_is_native_reflect_construct = function() {
|
|
193
|
+
return !!result;
|
|
194
|
+
})();
|
|
195
|
+
}
|
|
196
|
+
var adapterError = makeError('ReactAdapter');
|
|
197
|
+
var ReactAdapter = /*#__PURE__*/ function(DomAdapter1) {
|
|
198
|
+
_inherits(ReactAdapter, DomAdapter1);
|
|
199
|
+
function ReactAdapter(components, mount) {
|
|
200
|
+
_class_call_check(this, ReactAdapter);
|
|
201
|
+
var _this;
|
|
202
|
+
_this = _call_super(this, ReactAdapter, [
|
|
203
|
+
{
|
|
204
|
+
createCompositionNode: function createCompositionNode(compositionState, updateNativeCompositionNode) {
|
|
205
|
+
return new VElement('span', {
|
|
206
|
+
style: {
|
|
207
|
+
textDecoration: 'underline'
|
|
208
|
+
},
|
|
209
|
+
ref: function ref(node) {
|
|
210
|
+
updateNativeCompositionNode(node);
|
|
211
|
+
}
|
|
212
|
+
}, [
|
|
213
|
+
new VTextNode(compositionState.text)
|
|
214
|
+
]);
|
|
215
|
+
},
|
|
216
|
+
getParentNode: function getParentNode(node) {
|
|
217
|
+
return node.parentNode;
|
|
218
|
+
},
|
|
219
|
+
getChildNodes: function getChildNodes(parentElement) {
|
|
220
|
+
return Array.from(parentElement.childNodes);
|
|
221
|
+
},
|
|
222
|
+
isNativeElementNode: function isNativeElementNode(node) {
|
|
223
|
+
return _instanceof(node, Element);
|
|
224
|
+
},
|
|
225
|
+
getChildByIndex: function getChildByIndex(parentElement, index) {
|
|
226
|
+
return parentElement.childNodes[index];
|
|
227
|
+
},
|
|
228
|
+
getAndUpdateSlotRootNativeElement: function getAndUpdateSlotRootNativeElement(vEle, update) {
|
|
229
|
+
var currentRef = vEle.attrs.get('ref');
|
|
230
|
+
if (currentRef) {
|
|
231
|
+
vEle.attrs.set('ref', function(v) {
|
|
232
|
+
update(v);
|
|
233
|
+
if (typeof currentRef === 'function') {
|
|
234
|
+
currentRef(v);
|
|
235
|
+
} else if (!currentRef.current) {
|
|
236
|
+
currentRef.current = v;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
} else {
|
|
240
|
+
vEle.attrs.set('ref', update);
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
componentRender: function componentRender(component) {
|
|
244
|
+
var comp = _assert_this_initialized(_this).components[component.name] || _assert_this_initialized(_this).components['*'];
|
|
245
|
+
if (comp) {
|
|
246
|
+
component.changeMarker.rendered();
|
|
247
|
+
return createElement(comp, {
|
|
248
|
+
key: component.id,
|
|
249
|
+
component: component
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
throw adapterError("cannot found view component `".concat(component.name, "`!"));
|
|
253
|
+
},
|
|
254
|
+
vElementToViewElement: function vElementToViewElement(vNode, children) {
|
|
255
|
+
var props = _object_spread({}, Array.from(vNode.attrs).reduce(function(a, b) {
|
|
256
|
+
a[b[0]] = b[1];
|
|
257
|
+
return a;
|
|
258
|
+
}, {}));
|
|
259
|
+
if (vNode.classes.size) {
|
|
260
|
+
props.className = Array.from(vNode.classes).join(' ');
|
|
261
|
+
}
|
|
262
|
+
if (vNode.styles) {
|
|
263
|
+
props.style = Array.from(vNode.styles).reduce(function(a, b) {
|
|
264
|
+
a[b[0]] = b[1];
|
|
265
|
+
return a;
|
|
266
|
+
}, {});
|
|
267
|
+
}
|
|
268
|
+
return createElement.apply(void 0, [
|
|
269
|
+
vNode.tagName,
|
|
270
|
+
props
|
|
271
|
+
].concat(_to_consumable_array(children)));
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
mount
|
|
275
|
+
]), _define_property(_this, "components", {});
|
|
276
|
+
Object.keys(components).forEach(function(key) {
|
|
277
|
+
_this.components[key] = function(props) {
|
|
278
|
+
var component = props.component;
|
|
279
|
+
var _useState = _sliced_to_array(useState(Math.random()), 2), updateKey = _useState[0], refreshUpdateKey = _useState[1];
|
|
280
|
+
useEffect(function() {
|
|
281
|
+
var sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(function() {
|
|
282
|
+
if (component.changeMarker.dirty) {
|
|
283
|
+
refreshUpdateKey(Math.random());
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
return function() {
|
|
287
|
+
sub.unsubscribe();
|
|
288
|
+
};
|
|
289
|
+
}, []);
|
|
290
|
+
useEffect(function() {
|
|
291
|
+
_this.onViewUpdated.next();
|
|
292
|
+
}, [
|
|
293
|
+
updateKey
|
|
294
|
+
]);
|
|
295
|
+
var vNode = components[key]({
|
|
296
|
+
component: component,
|
|
297
|
+
rootRef: function rootRef(rootNode) {
|
|
298
|
+
if (rootNode) {
|
|
299
|
+
_this.componentRootElementCaches.set(component, rootNode);
|
|
300
|
+
} else {
|
|
301
|
+
// 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点
|
|
302
|
+
// eslint-disable-next-line no-lonely-if
|
|
303
|
+
if (_this.componentRootElementCaches.get(component) === rootNode) {
|
|
304
|
+
_this.componentRootElementCaches.remove(component);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
useEffect(function() {
|
|
310
|
+
if (!_this.componentRootElementCaches.get(component)) {
|
|
311
|
+
// eslint-disable-next-line max-len
|
|
312
|
+
throw adapterError("Component `".concat(component.name, "` is not bound to rootRef, you must bind rootRef to the root element node of the component view."));
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
return vNode;
|
|
316
|
+
};
|
|
113
317
|
});
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
318
|
+
return _this;
|
|
319
|
+
}
|
|
320
|
+
_create_class(ReactAdapter, [
|
|
321
|
+
{
|
|
322
|
+
key: "render",
|
|
323
|
+
value: function render(rootComponent, injector) {
|
|
324
|
+
var childInjector = new ReflectiveInjector(injector, [
|
|
325
|
+
{
|
|
326
|
+
provide: Adapter,
|
|
327
|
+
useValue: this
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
provide: DomAdapter,
|
|
331
|
+
useValue: this
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
provide: ReactAdapter,
|
|
335
|
+
useValue: this
|
|
336
|
+
}
|
|
337
|
+
]);
|
|
338
|
+
return _get(_get_prototype_of(ReactAdapter.prototype), "render", this).call(this, rootComponent, childInjector);
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
key: "copy",
|
|
343
|
+
value: function copy() {
|
|
344
|
+
document.execCommand('copy');
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
]);
|
|
348
|
+
return ReactAdapter;
|
|
349
|
+
}(DomAdapter);
|
|
350
|
+
|
|
351
|
+
export { ReactAdapter };
|
|
138
352
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/react-adapter.ts"],"sourcesContent":["import { Adapter, Component, CompositionState, makeError, VElement, ViewMount, VTextNode } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { createElement, JSX, useEffect, useState } from 'react'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { merge } from '@tanbo/stream'\n\nconst adapterError = makeError('ReactAdapter')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: ((rootNode: Element) => void)\n}\n\nexport interface ReactAdapterComponents {\n [key: string]: (props: ViewComponentProps<any>) => JSX.Element\n}\n\nexport class ReactAdapter extends DomAdapter<JSX.Element, JSX.Element> {\n private components: Record<string, (props: {component: Component}) => JSX.Element> = {}\n\n constructor(components: ReactAdapterComponents,\n mount: ViewMount<JSX.Element, Element>) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref: (node: Element) => {\n updateNativeCompositionNode(node)\n }\n }, [\n new VTextNode(compositionState.text)\n ])\n },\n getParentNode(node: Element | Text): Element | null {\n return (node as Node).parentNode as Element\n },\n getChildNodes(parentElement: Element): Array<Element | Text> {\n return Array.from(parentElement.childNodes) as Element[]\n },\n isNativeElementNode(node: Element | Text): node is Element {\n return node instanceof Element\n },\n getChildByIndex(parentElement, index) {\n return parentElement.childNodes[index] as Element\n },\n getAndUpdateSlotRootNativeElement(vEle: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vEle.attrs.get('ref')\n if (currentRef) {\n vEle.attrs.set('ref', (v: Element) => {\n update(v)\n if (typeof currentRef === 'function') {\n currentRef(v)\n } else if (!currentRef.current) {\n currentRef.current = v\n }\n })\n } else {\n vEle.attrs.set('ref', update)\n }\n },\n componentRender: (component: Component<any>): JSX.Element => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n component.changeMarker.rendered()\n return createElement(comp, {\n key: component.id,\n component\n })\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<string | JSX.Element>): JSX.Element {\n const props: any = {\n ...(Array.from(vNode.attrs).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>))\n }\n if (vNode.classes.size) {\n props.className = Array.from(vNode.classes).join(' ')\n }\n if (vNode.styles) {\n props.style = Array.from(vNode.styles).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>)\n }\n return createElement(vNode.tagName, props, ...children)\n }\n }, mount)\n Object.keys(components).forEach(key => {\n this.components[key] = (props: {component: Component}) => {\n const component = props.component\n const [updateKey, refreshUpdateKey] = useState(Math.random())\n\n useEffect(() => {\n const sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {\n if (component.changeMarker.dirty) {\n refreshUpdateKey(Math.random())\n }\n })\n return () => {\n sub.unsubscribe()\n }\n }, [])\n useEffect(() => {\n this.onViewUpdated.next()\n }, [updateKey])\n const vNode = components[key]({\n component,\n rootRef: (rootNode: Element) => {\n if (rootNode) {\n this.componentRootElementCaches.set(component, rootNode)\n } else {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n // eslint-disable-next-line no-lonely-if\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n }\n })\n useEffect(() => {\n if (!this.componentRootElementCaches.get(component)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${component.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return vNode\n }\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ReactAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n"],"names":[],"mappings":";;;;;AAMA,MAAM,eAAe,UAAU,cAAc;AAWtC,MAAM,qBAAqB,WAAqC;AAAA,EAC7D,aAA6E,CAAA;AAAA,EAErF,YAAY,YACA,OAAwC;AAClD,UAAM;AAAA,MACJ,sBAAsB,kBACA,6BAA+E;AACnG,eAAO,IAAI,SAAS,QAAQ;AAAA,UAC1B,OA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AAS;AAAA,cAClD;AAAA,YACF;AAAA,UACF;AAAA,QAAA,CACD;AACD,kBAAU,MAAM;AACd,cAAI,CAAC,KAAK,2BAA2B,IAAI,SAAS,GAAG;AAEnD,kBAAM,aAAa,eAAe,UAAU,IAAI,mGAAmG;AAAA,UACrJ;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAES,OAAO,eAA0B,UAAyC;AACjF,UAAM,gBAAgB,IAAI,mBAAmB,UAAU,CAAC;AAAA,MACtD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,CACX,CAAC;AACF,WAAO,MAAM,OAAO,eAAe,aAAa;AAAA,EAClD;AAAA,EAES,OAAO;AACd,aAAS,YAAY,MAAM;AAAA,EAC7B;AACF;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/react-adapter.ts"],"sourcesContent":["import { Adapter, Component, CompositionState, makeError, VElement, ViewMount, VTextNode } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { createElement, JSX, useEffect, useState } from 'react'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { merge } from '@tanbo/stream'\n\nconst adapterError = makeError('ReactAdapter')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: ((rootNode: Element) => void)\n}\n\nexport interface ReactAdapterComponents {\n [key: string]: (props: ViewComponentProps<any>) => JSX.Element\n}\n\nexport class ReactAdapter extends DomAdapter<JSX.Element, JSX.Element> {\n private components: Record<string, (props: {component: Component}) => JSX.Element> = {}\n\n constructor(components: ReactAdapterComponents,\n mount: ViewMount<JSX.Element, Element>) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref: (node: Element) => {\n updateNativeCompositionNode(node)\n }\n }, [\n new VTextNode(compositionState.text)\n ])\n },\n getParentNode(node: Element | Text): Element | null {\n return (node as Node).parentNode as Element\n },\n getChildNodes(parentElement: Element): Array<Element | Text> {\n return Array.from(parentElement.childNodes) as Element[]\n },\n isNativeElementNode(node: Element | Text): node is Element {\n return node instanceof Element\n },\n getChildByIndex(parentElement, index) {\n return parentElement.childNodes[index] as Element\n },\n getAndUpdateSlotRootNativeElement(vEle: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vEle.attrs.get('ref')\n if (currentRef) {\n vEle.attrs.set('ref', (v: Element) => {\n update(v)\n if (typeof currentRef === 'function') {\n currentRef(v)\n } else if (!currentRef.current) {\n currentRef.current = v\n }\n })\n } else {\n vEle.attrs.set('ref', update)\n }\n },\n componentRender: (component: Component<any>): JSX.Element => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n component.changeMarker.rendered()\n return createElement(comp, {\n key: component.id,\n component\n })\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<string | JSX.Element>): JSX.Element {\n const props: any = {\n ...(Array.from(vNode.attrs).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>))\n }\n if (vNode.classes.size) {\n props.className = Array.from(vNode.classes).join(' ')\n }\n if (vNode.styles) {\n props.style = Array.from(vNode.styles).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>)\n }\n return createElement(vNode.tagName, props, ...children)\n }\n }, mount)\n Object.keys(components).forEach(key => {\n this.components[key] = (props: {component: Component}) => {\n const component = props.component\n const [updateKey, refreshUpdateKey] = useState(Math.random())\n\n useEffect(() => {\n const sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {\n if (component.changeMarker.dirty) {\n refreshUpdateKey(Math.random())\n }\n })\n return () => {\n sub.unsubscribe()\n }\n }, [])\n useEffect(() => {\n this.onViewUpdated.next()\n }, [updateKey])\n const vNode = components[key]({\n component,\n rootRef: (rootNode: Element) => {\n if (rootNode) {\n this.componentRootElementCaches.set(component, rootNode)\n } else {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n // eslint-disable-next-line no-lonely-if\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n }\n })\n useEffect(() => {\n if (!this.componentRootElementCaches.get(component)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${component.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return vNode\n }\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ReactAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n"],"names":["adapterError","makeError","ReactAdapter","components","mount","createCompositionNode","compositionState","updateNativeCompositionNode","VElement","style","textDecoration","ref","node","VTextNode","text","getParentNode","parentNode","getChildNodes","parentElement","Array","from","childNodes","isNativeElementNode","Element","getChildByIndex","index","getAndUpdateSlotRootNativeElement","vEle","update","currentRef","attrs","get","set","v","current","componentRender","component","comp","name","changeMarker","rendered","createElement","key","id","vElementToViewElement","vNode","children","props","reduce","a","b","classes","size","className","join","styles","tagName","Object","keys","forEach","useState","Math","random","updateKey","refreshUpdateKey","useEffect","sub","merge","onChange","onForceChange","subscribe","dirty","unsubscribe","onViewUpdated","next","rootRef","rootNode","componentRootElementCaches","remove","render","rootComponent","injector","childInjector","ReflectiveInjector","provide","Adapter","useValue","DomAdapter","copy","document","execCommand"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAN,IAAK,aAAQC,aAAAA,EAAeE,aAAAA,CAAAA;AACrC,YAAA;;;YAESM,GAAAA,EAAAA,MAAAA;mBAAT,SAASA,IAAAA,GAAAA;AACPC,gBAAAA,QAAAA,CAASC,WAAW,CAAC,MAAA,CAAA;AACvB,YAAA;;;AAvIWxF,IAAAA,OAAAA,YAAAA;EAAqBqF,UAAAA;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,138 +1,356 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const core = require('@textbus/core');
|
|
6
|
+
const platformBrowser = require('@textbus/platform-browser');
|
|
7
|
+
const react = require('react');
|
|
8
|
+
const core$1 = require('@viewfly/core');
|
|
9
|
+
const stream = require('@tanbo/stream');
|
|
10
|
+
|
|
11
|
+
function _array_like_to_array(arr, len) {
|
|
12
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
13
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
14
|
+
return arr2;
|
|
15
|
+
}
|
|
16
|
+
function _array_with_holes(arr) {
|
|
17
|
+
if (Array.isArray(arr)) return arr;
|
|
18
|
+
}
|
|
19
|
+
function _array_without_holes(arr) {
|
|
20
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
21
|
+
}
|
|
22
|
+
function _assert_this_initialized(self) {
|
|
23
|
+
if (self === void 0) {
|
|
24
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
25
|
+
}
|
|
26
|
+
return self;
|
|
27
|
+
}
|
|
28
|
+
function _call_super(_this, derived, args) {
|
|
29
|
+
derived = _get_prototype_of(derived);
|
|
30
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
31
|
+
}
|
|
32
|
+
function _class_call_check(instance, Constructor) {
|
|
33
|
+
if (!(instance instanceof Constructor)) {
|
|
34
|
+
throw new TypeError("Cannot call a class as a function");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function _defineProperties(target, props) {
|
|
38
|
+
for(var i = 0; i < props.length; i++){
|
|
39
|
+
var descriptor = props[i];
|
|
40
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
41
|
+
descriptor.configurable = true;
|
|
42
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
43
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
47
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
48
|
+
return Constructor;
|
|
49
|
+
}
|
|
50
|
+
function _define_property(obj, key, value) {
|
|
51
|
+
if (key in obj) {
|
|
52
|
+
Object.defineProperty(obj, key, {
|
|
53
|
+
value: value,
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
obj[key] = value;
|
|
60
|
+
}
|
|
61
|
+
return obj;
|
|
62
|
+
}
|
|
63
|
+
function _get(target, property, receiver) {
|
|
64
|
+
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
65
|
+
_get = Reflect.get;
|
|
66
|
+
} else {
|
|
67
|
+
_get = function get(target, property, receiver) {
|
|
68
|
+
var base = _super_prop_base(target, property);
|
|
69
|
+
if (!base) return;
|
|
70
|
+
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
71
|
+
if (desc.get) {
|
|
72
|
+
return desc.get.call(receiver || target);
|
|
46
73
|
}
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
74
|
+
return desc.value;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return _get(target, property, receiver || target);
|
|
78
|
+
}
|
|
79
|
+
function _get_prototype_of(o) {
|
|
80
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
81
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
82
|
+
};
|
|
83
|
+
return _get_prototype_of(o);
|
|
84
|
+
}
|
|
85
|
+
function _inherits(subClass, superClass) {
|
|
86
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
87
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
88
|
+
}
|
|
89
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
90
|
+
constructor: {
|
|
91
|
+
value: subClass,
|
|
92
|
+
writable: true,
|
|
93
|
+
configurable: true
|
|
50
94
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
95
|
+
});
|
|
96
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
97
|
+
}
|
|
98
|
+
function _instanceof(left, right) {
|
|
99
|
+
"@swc/helpers - instanceof";
|
|
100
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
101
|
+
return !!right[Symbol.hasInstance](left);
|
|
102
|
+
} else {
|
|
103
|
+
return left instanceof right;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function _iterable_to_array(iter) {
|
|
107
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
108
|
+
}
|
|
109
|
+
function _iterable_to_array_limit(arr, i) {
|
|
110
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
111
|
+
if (_i == null) return;
|
|
112
|
+
var _arr = [];
|
|
113
|
+
var _n = true;
|
|
114
|
+
var _d = false;
|
|
115
|
+
var _s, _e;
|
|
116
|
+
try {
|
|
117
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
118
|
+
_arr.push(_s.value);
|
|
119
|
+
if (i && _arr.length === i) break;
|
|
60
120
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
if (vNode.classes.size) {
|
|
71
|
-
props.className = Array.from(vNode.classes).join(" ");
|
|
121
|
+
} catch (err) {
|
|
122
|
+
_d = true;
|
|
123
|
+
_e = err;
|
|
124
|
+
} finally{
|
|
125
|
+
try {
|
|
126
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
127
|
+
} finally{
|
|
128
|
+
if (_d) throw _e;
|
|
72
129
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
130
|
+
}
|
|
131
|
+
return _arr;
|
|
132
|
+
}
|
|
133
|
+
function _non_iterable_rest() {
|
|
134
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
135
|
+
}
|
|
136
|
+
function _non_iterable_spread() {
|
|
137
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
138
|
+
}
|
|
139
|
+
function _object_spread(target) {
|
|
140
|
+
for(var i = 1; i < arguments.length; i++){
|
|
141
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
142
|
+
var ownKeys = Object.keys(source);
|
|
143
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
144
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
145
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
146
|
+
}));
|
|
78
147
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, mount);
|
|
82
|
-
Object.keys(components).forEach((key) => {
|
|
83
|
-
this.components[key] = (props) => {
|
|
84
|
-
const component = props.component;
|
|
85
|
-
const [updateKey, refreshUpdateKey] = react.useState(Math.random());
|
|
86
|
-
react.useEffect(() => {
|
|
87
|
-
const sub = stream.merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {
|
|
88
|
-
if (component.changeMarker.dirty) {
|
|
89
|
-
refreshUpdateKey(Math.random());
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
return () => {
|
|
93
|
-
sub.unsubscribe();
|
|
94
|
-
};
|
|
95
|
-
}, []);
|
|
96
|
-
react.useEffect(() => {
|
|
97
|
-
this.onViewUpdated.next();
|
|
98
|
-
}, [updateKey]);
|
|
99
|
-
const vNode = components[key]({
|
|
100
|
-
component,
|
|
101
|
-
rootRef: (rootNode) => {
|
|
102
|
-
if (rootNode) {
|
|
103
|
-
this.componentRootElementCaches.set(component, rootNode);
|
|
104
|
-
} else {
|
|
105
|
-
if (this.componentRootElementCaches.get(component) === rootNode) {
|
|
106
|
-
this.componentRootElementCaches.remove(component);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
react.useEffect(() => {
|
|
112
|
-
if (!this.componentRootElementCaches.get(component)) {
|
|
113
|
-
throw adapterError(`Component \`${component.name}\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`);
|
|
114
|
-
}
|
|
148
|
+
ownKeys.forEach(function(key) {
|
|
149
|
+
_define_property(target, key, source[key]);
|
|
115
150
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
document.execCommand("copy");
|
|
135
|
-
}
|
|
151
|
+
}
|
|
152
|
+
return target;
|
|
153
|
+
}
|
|
154
|
+
function _possible_constructor_return(self, call) {
|
|
155
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
156
|
+
return call;
|
|
157
|
+
}
|
|
158
|
+
return _assert_this_initialized(self);
|
|
159
|
+
}
|
|
160
|
+
function _set_prototype_of(o, p) {
|
|
161
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
162
|
+
o.__proto__ = p;
|
|
163
|
+
return o;
|
|
164
|
+
};
|
|
165
|
+
return _set_prototype_of(o, p);
|
|
166
|
+
}
|
|
167
|
+
function _sliced_to_array(arr, i) {
|
|
168
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
136
169
|
}
|
|
170
|
+
function _super_prop_base(object, property) {
|
|
171
|
+
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
172
|
+
object = _get_prototype_of(object);
|
|
173
|
+
if (object === null) break;
|
|
174
|
+
}
|
|
175
|
+
return object;
|
|
176
|
+
}
|
|
177
|
+
function _to_consumable_array(arr) {
|
|
178
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
179
|
+
}
|
|
180
|
+
function _type_of(obj) {
|
|
181
|
+
"@swc/helpers - typeof";
|
|
182
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
183
|
+
}
|
|
184
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
185
|
+
if (!o) return;
|
|
186
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
187
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
188
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
189
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
190
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
191
|
+
}
|
|
192
|
+
function _is_native_reflect_construct() {
|
|
193
|
+
try {
|
|
194
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
195
|
+
} catch (_) {}
|
|
196
|
+
return (_is_native_reflect_construct = function() {
|
|
197
|
+
return !!result;
|
|
198
|
+
})();
|
|
199
|
+
}
|
|
200
|
+
var adapterError = core.makeError('ReactAdapter');
|
|
201
|
+
var ReactAdapter = /*#__PURE__*/ function(DomAdapter1) {
|
|
202
|
+
_inherits(ReactAdapter, DomAdapter1);
|
|
203
|
+
function ReactAdapter(components, mount) {
|
|
204
|
+
_class_call_check(this, ReactAdapter);
|
|
205
|
+
var _this;
|
|
206
|
+
_this = _call_super(this, ReactAdapter, [
|
|
207
|
+
{
|
|
208
|
+
createCompositionNode: function createCompositionNode(compositionState, updateNativeCompositionNode) {
|
|
209
|
+
return new core.VElement('span', {
|
|
210
|
+
style: {
|
|
211
|
+
textDecoration: 'underline'
|
|
212
|
+
},
|
|
213
|
+
ref: function ref(node) {
|
|
214
|
+
updateNativeCompositionNode(node);
|
|
215
|
+
}
|
|
216
|
+
}, [
|
|
217
|
+
new core.VTextNode(compositionState.text)
|
|
218
|
+
]);
|
|
219
|
+
},
|
|
220
|
+
getParentNode: function getParentNode(node) {
|
|
221
|
+
return node.parentNode;
|
|
222
|
+
},
|
|
223
|
+
getChildNodes: function getChildNodes(parentElement) {
|
|
224
|
+
return Array.from(parentElement.childNodes);
|
|
225
|
+
},
|
|
226
|
+
isNativeElementNode: function isNativeElementNode(node) {
|
|
227
|
+
return _instanceof(node, Element);
|
|
228
|
+
},
|
|
229
|
+
getChildByIndex: function getChildByIndex(parentElement, index) {
|
|
230
|
+
return parentElement.childNodes[index];
|
|
231
|
+
},
|
|
232
|
+
getAndUpdateSlotRootNativeElement: function getAndUpdateSlotRootNativeElement(vEle, update) {
|
|
233
|
+
var currentRef = vEle.attrs.get('ref');
|
|
234
|
+
if (currentRef) {
|
|
235
|
+
vEle.attrs.set('ref', function(v) {
|
|
236
|
+
update(v);
|
|
237
|
+
if (typeof currentRef === 'function') {
|
|
238
|
+
currentRef(v);
|
|
239
|
+
} else if (!currentRef.current) {
|
|
240
|
+
currentRef.current = v;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
} else {
|
|
244
|
+
vEle.attrs.set('ref', update);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
componentRender: function componentRender(component) {
|
|
248
|
+
var comp = _assert_this_initialized(_this).components[component.name] || _assert_this_initialized(_this).components['*'];
|
|
249
|
+
if (comp) {
|
|
250
|
+
component.changeMarker.rendered();
|
|
251
|
+
return react.createElement(comp, {
|
|
252
|
+
key: component.id,
|
|
253
|
+
component: component
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
throw adapterError("cannot found view component `".concat(component.name, "`!"));
|
|
257
|
+
},
|
|
258
|
+
vElementToViewElement: function vElementToViewElement(vNode, children) {
|
|
259
|
+
var props = _object_spread({}, Array.from(vNode.attrs).reduce(function(a, b) {
|
|
260
|
+
a[b[0]] = b[1];
|
|
261
|
+
return a;
|
|
262
|
+
}, {}));
|
|
263
|
+
if (vNode.classes.size) {
|
|
264
|
+
props.className = Array.from(vNode.classes).join(' ');
|
|
265
|
+
}
|
|
266
|
+
if (vNode.styles) {
|
|
267
|
+
props.style = Array.from(vNode.styles).reduce(function(a, b) {
|
|
268
|
+
a[b[0]] = b[1];
|
|
269
|
+
return a;
|
|
270
|
+
}, {});
|
|
271
|
+
}
|
|
272
|
+
return react.createElement.apply(void 0, [
|
|
273
|
+
vNode.tagName,
|
|
274
|
+
props
|
|
275
|
+
].concat(_to_consumable_array(children)));
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
mount
|
|
279
|
+
]), _define_property(_this, "components", {});
|
|
280
|
+
Object.keys(components).forEach(function(key) {
|
|
281
|
+
_this.components[key] = function(props) {
|
|
282
|
+
var component = props.component;
|
|
283
|
+
var _useState = _sliced_to_array(react.useState(Math.random()), 2), updateKey = _useState[0], refreshUpdateKey = _useState[1];
|
|
284
|
+
react.useEffect(function() {
|
|
285
|
+
var sub = stream.merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(function() {
|
|
286
|
+
if (component.changeMarker.dirty) {
|
|
287
|
+
refreshUpdateKey(Math.random());
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
return function() {
|
|
291
|
+
sub.unsubscribe();
|
|
292
|
+
};
|
|
293
|
+
}, []);
|
|
294
|
+
react.useEffect(function() {
|
|
295
|
+
_this.onViewUpdated.next();
|
|
296
|
+
}, [
|
|
297
|
+
updateKey
|
|
298
|
+
]);
|
|
299
|
+
var vNode = components[key]({
|
|
300
|
+
component: component,
|
|
301
|
+
rootRef: function rootRef(rootNode) {
|
|
302
|
+
if (rootNode) {
|
|
303
|
+
_this.componentRootElementCaches.set(component, rootNode);
|
|
304
|
+
} else {
|
|
305
|
+
// 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点
|
|
306
|
+
// eslint-disable-next-line no-lonely-if
|
|
307
|
+
if (_this.componentRootElementCaches.get(component) === rootNode) {
|
|
308
|
+
_this.componentRootElementCaches.remove(component);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
react.useEffect(function() {
|
|
314
|
+
if (!_this.componentRootElementCaches.get(component)) {
|
|
315
|
+
// eslint-disable-next-line max-len
|
|
316
|
+
throw adapterError("Component `".concat(component.name, "` is not bound to rootRef, you must bind rootRef to the root element node of the component view."));
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
return vNode;
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
return _this;
|
|
323
|
+
}
|
|
324
|
+
_create_class(ReactAdapter, [
|
|
325
|
+
{
|
|
326
|
+
key: "render",
|
|
327
|
+
value: function render(rootComponent, injector) {
|
|
328
|
+
var childInjector = new core$1.ReflectiveInjector(injector, [
|
|
329
|
+
{
|
|
330
|
+
provide: core.Adapter,
|
|
331
|
+
useValue: this
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
provide: platformBrowser.DomAdapter,
|
|
335
|
+
useValue: this
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
provide: ReactAdapter,
|
|
339
|
+
useValue: this
|
|
340
|
+
}
|
|
341
|
+
]);
|
|
342
|
+
return _get(_get_prototype_of(ReactAdapter.prototype), "render", this).call(this, rootComponent, childInjector);
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
key: "copy",
|
|
347
|
+
value: function copy() {
|
|
348
|
+
document.execCommand('copy');
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
]);
|
|
352
|
+
return ReactAdapter;
|
|
353
|
+
}(platformBrowser.DomAdapter);
|
|
354
|
+
|
|
137
355
|
exports.ReactAdapter = ReactAdapter;
|
|
138
356
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/react-adapter.ts"],"sourcesContent":["import { Adapter, Component, CompositionState, makeError, VElement, ViewMount, VTextNode } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { createElement, JSX, useEffect, useState } from 'react'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { merge } from '@tanbo/stream'\n\nconst adapterError = makeError('ReactAdapter')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: ((rootNode: Element) => void)\n}\n\nexport interface ReactAdapterComponents {\n [key: string]: (props: ViewComponentProps<any>) => JSX.Element\n}\n\nexport class ReactAdapter extends DomAdapter<JSX.Element, JSX.Element> {\n private components: Record<string, (props: {component: Component}) => JSX.Element> = {}\n\n constructor(components: ReactAdapterComponents,\n mount: ViewMount<JSX.Element, Element>) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref: (node: Element) => {\n updateNativeCompositionNode(node)\n }\n }, [\n new VTextNode(compositionState.text)\n ])\n },\n getParentNode(node: Element | Text): Element | null {\n return (node as Node).parentNode as Element\n },\n getChildNodes(parentElement: Element): Array<Element | Text> {\n return Array.from(parentElement.childNodes) as Element[]\n },\n isNativeElementNode(node: Element | Text): node is Element {\n return node instanceof Element\n },\n getChildByIndex(parentElement, index) {\n return parentElement.childNodes[index] as Element\n },\n getAndUpdateSlotRootNativeElement(vEle: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vEle.attrs.get('ref')\n if (currentRef) {\n vEle.attrs.set('ref', (v: Element) => {\n update(v)\n if (typeof currentRef === 'function') {\n currentRef(v)\n } else if (!currentRef.current) {\n currentRef.current = v\n }\n })\n } else {\n vEle.attrs.set('ref', update)\n }\n },\n componentRender: (component: Component<any>): JSX.Element => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n component.changeMarker.rendered()\n return createElement(comp, {\n key: component.id,\n component\n })\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<string | JSX.Element>): JSX.Element {\n const props: any = {\n ...(Array.from(vNode.attrs).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>))\n }\n if (vNode.classes.size) {\n props.className = Array.from(vNode.classes).join(' ')\n }\n if (vNode.styles) {\n props.style = Array.from(vNode.styles).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>)\n }\n return createElement(vNode.tagName, props, ...children)\n }\n }, mount)\n Object.keys(components).forEach(key => {\n this.components[key] = (props: {component: Component}) => {\n const component = props.component\n const [updateKey, refreshUpdateKey] = useState(Math.random())\n\n useEffect(() => {\n const sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {\n if (component.changeMarker.dirty) {\n refreshUpdateKey(Math.random())\n }\n })\n return () => {\n sub.unsubscribe()\n }\n }, [])\n useEffect(() => {\n this.onViewUpdated.next()\n }, [updateKey])\n const vNode = components[key]({\n component,\n rootRef: (rootNode: Element) => {\n if (rootNode) {\n this.componentRootElementCaches.set(component, rootNode)\n } else {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n // eslint-disable-next-line no-lonely-if\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n }\n })\n useEffect(() => {\n if (!this.componentRootElementCaches.get(component)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${component.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return vNode\n }\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ReactAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n"],"names":["makeError","DomAdapter","VElement","VTextNode","createElement","useState","useEffect","merge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E;AACLD,cAAAA,UAAU,MAAM;AACd,eAAK,cAAc,KAAA;AAAA,QACrB,GAAG,CAAC,SAAS,CAAC;AACd,cAAM,QAAQ,WAAW,GAAG,EAAE;AAAA,UAC5B;AAAA,UACA,SAAS,CAAC,aAAsB;AAC9B,gBAAI,UAAU;AACZ,mBAAK,2BAA2B,IAAI,WAAW,QAAQ;AAAA,YACzD,OAAO;AAGL,kBAAI,KAAK,2BAA2B,IAAI,SAAS,MAAM,UAAU;AAC/D,qBAAK,2BAA2B,OAAO,SAAS;AAAA,cAClD;AAAA,YACF;AAAA,UACF;AAAA,QAAA,CACD;AACDA,cAAAA,UAAU,MAAM;AACd,cAAI,CAAC,KAAK,2BAA2B,IAAI,SAAS,GAAG;AAEnD,kBAAM,aAAa,eAAe,UAAU,IAAI,mGAAmG;AAAA,UACrJ;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAES,OAAO,eAA0B,UAAyC;AACjF,UAAM,gBAAgB,IAAIE,0BAAmB,UAAU,CAAC;AAAA,MACtD,SAASC,KAAAA;AAAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAASR,gBAAAA;AAAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,IAAA,CACX,CAAC;AACF,WAAO,MAAM,OAAO,eAAe,aAAa;AAAA,EAClD;AAAA,EAES,OAAO;AACd,aAAS,YAAY,MAAM;AAAA,EAC7B;AACF;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/react-adapter.ts"],"sourcesContent":["import { Adapter, Component, CompositionState, makeError, VElement, ViewMount, VTextNode } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { createElement, JSX, useEffect, useState } from 'react'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { merge } from '@tanbo/stream'\n\nconst adapterError = makeError('ReactAdapter')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: ((rootNode: Element) => void)\n}\n\nexport interface ReactAdapterComponents {\n [key: string]: (props: ViewComponentProps<any>) => JSX.Element\n}\n\nexport class ReactAdapter extends DomAdapter<JSX.Element, JSX.Element> {\n private components: Record<string, (props: {component: Component}) => JSX.Element> = {}\n\n constructor(components: ReactAdapterComponents,\n mount: ViewMount<JSX.Element, Element>) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref: (node: Element) => {\n updateNativeCompositionNode(node)\n }\n }, [\n new VTextNode(compositionState.text)\n ])\n },\n getParentNode(node: Element | Text): Element | null {\n return (node as Node).parentNode as Element\n },\n getChildNodes(parentElement: Element): Array<Element | Text> {\n return Array.from(parentElement.childNodes) as Element[]\n },\n isNativeElementNode(node: Element | Text): node is Element {\n return node instanceof Element\n },\n getChildByIndex(parentElement, index) {\n return parentElement.childNodes[index] as Element\n },\n getAndUpdateSlotRootNativeElement(vEle: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vEle.attrs.get('ref')\n if (currentRef) {\n vEle.attrs.set('ref', (v: Element) => {\n update(v)\n if (typeof currentRef === 'function') {\n currentRef(v)\n } else if (!currentRef.current) {\n currentRef.current = v\n }\n })\n } else {\n vEle.attrs.set('ref', update)\n }\n },\n componentRender: (component: Component<any>): JSX.Element => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n component.changeMarker.rendered()\n return createElement(comp, {\n key: component.id,\n component\n })\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<string | JSX.Element>): JSX.Element {\n const props: any = {\n ...(Array.from(vNode.attrs).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>))\n }\n if (vNode.classes.size) {\n props.className = Array.from(vNode.classes).join(' ')\n }\n if (vNode.styles) {\n props.style = Array.from(vNode.styles).reduce((a, b) => {\n a[b[0]] = b[1]\n return a\n }, {} as Record<string, any>)\n }\n return createElement(vNode.tagName, props, ...children)\n }\n }, mount)\n Object.keys(components).forEach(key => {\n this.components[key] = (props: {component: Component}) => {\n const component = props.component\n const [updateKey, refreshUpdateKey] = useState(Math.random())\n\n useEffect(() => {\n const sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {\n if (component.changeMarker.dirty) {\n refreshUpdateKey(Math.random())\n }\n })\n return () => {\n sub.unsubscribe()\n }\n }, [])\n useEffect(() => {\n this.onViewUpdated.next()\n }, [updateKey])\n const vNode = components[key]({\n component,\n rootRef: (rootNode: Element) => {\n if (rootNode) {\n this.componentRootElementCaches.set(component, rootNode)\n } else {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n // eslint-disable-next-line no-lonely-if\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n }\n })\n useEffect(() => {\n if (!this.componentRootElementCaches.get(component)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${component.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return vNode\n }\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this\n }, {\n provide: ReactAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n"],"names":["adapterError","makeError","ReactAdapter","components","mount","createCompositionNode","compositionState","updateNativeCompositionNode","VElement","style","textDecoration","ref","node","VTextNode","text","getParentNode","parentNode","getChildNodes","parentElement","Array","from","childNodes","isNativeElementNode","Element","getChildByIndex","index","getAndUpdateSlotRootNativeElement","vEle","update","currentRef","attrs","get","set","v","current","componentRender","component","comp","name","changeMarker","rendered","createElement","key","id","vElementToViewElement","vNode","children","props","reduce","a","b","classes","size","className","join","styles","tagName","Object","keys","forEach","useState","Math","random","updateKey","refreshUpdateKey","useEffect","sub","merge","onChange","onForceChange","subscribe","dirty","unsubscribe","onViewUpdated","next","rootRef","rootNode","componentRootElementCaches","remove","render","rootComponent","injector","childInjector","ReflectiveInjector","provide","Adapter","useValue","DomAdapter","copy","document","execCommand"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAMA,eAAeC,cAAAA,CAAU,cAAA,CAAA;AAWxB,IAAA,YAAMC,iBAAN,SAAA,WAAA,EAAA;AAAMA,IAAAA,SAAAA,CAAAA,YAAAA,EAAAA,WAAAA,CAAAA;aAAAA,YAAAA,CAGCC,UAAkC,EAClCC,KAAsC,EAAA;AAJvCF,QAAAA,iBAAAA,CAAAA,IAAAA,EAAAA,YAAAA,CAAAA;;gBAKT,WAAA,CAAA,IAAA,EALSA,YAAAA,EAAAA;AAKH,YAAA;AACJG,gBAAAA,qBAAAA,EAAAA,SAAAA,qBAAAA,CAAsBC,gBAAkC,EAClCC,2BAAmE,EAAA;oBACvF,OAAO,IAAIC,cAAS,MAAA,EAAQ;wBAC1BC,KAAAA,EAAO;4BACLC,cAAAA,EAAgB;AAClB,yBAAA;AACAC,wBAAAA,GAAAA,EAAK,SAALA,GAAAA,CAAMC,IAAAA,EAAAA;4BACJL,2BAAAA,CAA4BK,IAAAA,CAAAA;AAC9B,wBAAA;qBACF,EAAG;wBACD,IAAIC,cAAAA,CAAUP,iBAAiBQ,IAAI;AACpC,qBAAA,CAAA;AACH,gBAAA,CAAA;gBACAC,aAAAA,EAAAA,SAAAA,cAAcH,IAAoB,EAAA;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AAAC,oBAAA;wBACtDG,OAAAA,EAASC,YAAAA;AACTC,wBAAAA,QAAAA,EAAU;AACZ,qBAAA;AAAG,oBAAA;wBACDF,OAAAA,EAASG,0BAAAA;AACTD,wBAAAA,QAAAA,EAAU;AACZ,qBAAA;AAAG,oBAAA;wBACDF,OAAAA,EA/HOlF,YAAAA;AAgIPoF,wBAAAA,QAAAA,EAAU;AACZ;AAAE,iBAAA,CAAA;AACF,gBAAA,OAAO,IAAA,CAAA,iBAAA,CAlIEpF,YAAAA,CAAAA,SAAAA,CAAAA,EAkII6E,QAAAA,EAAN,IAAK,aAAQC,aAAAA,EAAeE,aAAAA,CAAAA;AACrC,YAAA;;;YAESM,GAAAA,EAAAA,MAAAA;mBAAT,SAASA,IAAAA,GAAAA;AACPC,gBAAAA,QAAAA,CAASC,WAAW,CAAC,MAAA,CAAA;AACvB,YAAA;;;AAvIWxF,IAAAA,OAAAA,YAAAA;EAAqBqF,0BAAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textbus/adapter-react",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4",
|
|
4
4
|
"description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@tanbo/stream": "^1.2.7",
|
|
36
36
|
"@viewfly/core": "^2.2.0 || >=3.0.0-alpha.3 <4",
|
|
37
|
-
"@textbus/
|
|
38
|
-
"@textbus/
|
|
37
|
+
"@textbus/platform-browser": "^5.2.4",
|
|
38
|
+
"@textbus/core": "^5.2.4"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": "^17.0.0 || ^18.0.0"
|