@textbus/adapter-viewfly 5.2.2 → 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 CHANGED
@@ -1,120 +1,464 @@
1
- import { makeError as R, VElement as w, VTextNode as V, merge as A, Adapter as y } from "@textbus/core";
2
- import { jsx as f, createDynamicRef as m, getCurrentInstance as C, onUnmounted as x, onUpdated as p, ReflectiveInjector as g } from "@viewfly/core";
3
- import { DomAdapter as u } from "@textbus/platform-browser";
4
- import { NodeViewAdapter as E } from "@textbus/platform-node";
5
- const h = R("ViewflyDOMRenderer");
6
- class d extends u {
7
- components = {};
8
- componentRefs = /* @__PURE__ */ new WeakMap();
9
- constructor(c, a) {
10
- super({
11
- createCompositionNode(e, r) {
12
- const t = m((n) => (r(n), () => {
13
- r(null);
14
- }));
15
- return new w("span", {
16
- style: {
17
- textDecoration: "underline"
18
- },
19
- ref: t
20
- }, [
21
- new V(e.text)
22
- ]);
23
- },
24
- getParentNode(e) {
25
- return e.parentNode;
26
- },
27
- getChildNodes(e) {
28
- return Array.from(e.childNodes);
29
- },
30
- isNativeElementNode(e) {
31
- return e instanceof Element;
32
- },
33
- getChildByIndex(e, r) {
34
- return e.childNodes[r];
35
- },
36
- getAndUpdateSlotRootNativeElement(e, r) {
37
- const t = e.attrs.get("ref"), n = m((o) => (r(o), () => {
38
- r(null);
39
- }));
40
- typeof t == "function" ? e.attrs.set("ref", [t, n]) : Array.isArray(t) ? t.push(n) : e.attrs.set("ref", n);
41
- },
42
- componentRender: (e) => {
43
- const r = this.components[e.name] || this.components["*"];
44
- if (r) {
45
- let t = this.componentRefs.get(e);
46
- return t || (t = m((n) => (this.componentRootElementCaches.set(e, n), () => {
47
- this.componentRootElementCaches.get(e) === n && this.componentRootElementCaches.remove(e);
48
- })), this.componentRefs.set(e, t)), f(r, {
49
- component: e,
50
- rootRef: t
51
- }, e.id);
1
+ import { makeError, merge, VElement, VTextNode, Adapter } from '@textbus/core';
2
+ import { getCurrentInstance, onUnmounted, onUpdated, jsx, createDynamicRef, ReflectiveInjector } from '@viewfly/core';
3
+ import { DomAdapter } from '@textbus/platform-browser';
4
+ import { NodeViewAdapter } from '@textbus/platform-node';
5
+
6
+ function _array_like_to_array(arr, len) {
7
+ if (len == null || len > arr.length) len = arr.length;
8
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
9
+ return arr2;
10
+ }
11
+ function _array_with_holes(arr) {
12
+ if (Array.isArray(arr)) return arr;
13
+ }
14
+ function _assert_this_initialized$1(self) {
15
+ if (self === void 0) {
16
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
17
+ }
18
+ return self;
19
+ }
20
+ function _call_super$1(_this, derived, args) {
21
+ derived = _get_prototype_of$1(derived);
22
+ return _possible_constructor_return$1(_this, _is_native_reflect_construct$1() ? Reflect.construct(derived, args || [], _get_prototype_of$1(_this).constructor) : derived.apply(_this, args));
23
+ }
24
+ function _class_call_check$1(instance, Constructor) {
25
+ if (!(instance instanceof Constructor)) {
26
+ throw new TypeError("Cannot call a class as a function");
27
+ }
28
+ }
29
+ function _defineProperties$1(target, props) {
30
+ for(var i = 0; i < props.length; i++){
31
+ var descriptor = props[i];
32
+ descriptor.enumerable = descriptor.enumerable || false;
33
+ descriptor.configurable = true;
34
+ if ("value" in descriptor) descriptor.writable = true;
35
+ Object.defineProperty(target, descriptor.key, descriptor);
36
+ }
37
+ }
38
+ function _create_class$1(Constructor, protoProps, staticProps) {
39
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
40
+ return Constructor;
41
+ }
42
+ function _define_property(obj, key, value) {
43
+ if (key in obj) {
44
+ Object.defineProperty(obj, key, {
45
+ value: value,
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true
49
+ });
50
+ } else {
51
+ obj[key] = value;
52
+ }
53
+ return obj;
54
+ }
55
+ function _get$1(target, property, receiver) {
56
+ if (typeof Reflect !== "undefined" && Reflect.get) {
57
+ _get$1 = Reflect.get;
58
+ } else {
59
+ _get$1 = function get(target, property, receiver) {
60
+ var base = _super_prop_base$1(target, property);
61
+ if (!base) return;
62
+ var desc = Object.getOwnPropertyDescriptor(base, property);
63
+ if (desc.get) {
64
+ return desc.get.call(receiver || target);
65
+ }
66
+ return desc.value;
67
+ };
68
+ }
69
+ return _get$1(target, property, receiver || target);
70
+ }
71
+ function _get_prototype_of$1(o) {
72
+ _get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
73
+ return o.__proto__ || Object.getPrototypeOf(o);
74
+ };
75
+ return _get_prototype_of$1(o);
76
+ }
77
+ function _inherits$1(subClass, superClass) {
78
+ if (typeof superClass !== "function" && superClass !== null) {
79
+ throw new TypeError("Super expression must either be null or a function");
80
+ }
81
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
82
+ constructor: {
83
+ value: subClass,
84
+ writable: true,
85
+ configurable: true
52
86
  }
53
- throw h(`cannot found view component \`${e.name}\`!`);
54
- },
55
- vElementToViewElement(e, r) {
56
- let t;
57
- const n = Array.from(e.attrs).reduce((o, s) => {
58
- const l = s[0];
59
- return l === "key" ? (t = s[1], o) : (o[l] = s[1], o);
60
- }, {});
61
- return e.classes.size && (n.class = Array.from(e.classes).join(" ")), e.styles && (n.style = Array.from(e.styles).reduce((o, s) => (o[s[0]] = s[1], o), {})), r.length && (n.children = r), f(e.tagName, n, t);
62
- }
63
- }, a);
64
- let i = !0;
65
- Object.entries(c).forEach(([e, r]) => {
66
- this.components[e] = (t) => {
67
- const n = C(), o = t.component, s = A(
68
- o.changeMarker.onChange,
69
- o.changeMarker.onForceChange
70
- ).subscribe(() => {
71
- o.changeMarker.dirty && n.markAsDirtied();
87
+ });
88
+ if (superClass) _set_prototype_of$1(subClass, superClass);
89
+ }
90
+ function _instanceof(left, right) {
91
+ "@swc/helpers - instanceof";
92
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
93
+ return !!right[Symbol.hasInstance](left);
94
+ } else {
95
+ return left instanceof right;
96
+ }
97
+ }
98
+ function _iterable_to_array_limit(arr, i) {
99
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
100
+ if (_i == null) return;
101
+ var _arr = [];
102
+ var _n = true;
103
+ var _d = false;
104
+ var _s, _e;
105
+ try {
106
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
107
+ _arr.push(_s.value);
108
+ if (i && _arr.length === i) break;
109
+ }
110
+ } catch (err) {
111
+ _d = true;
112
+ _e = err;
113
+ } finally{
114
+ try {
115
+ if (!_n && _i["return"] != null) _i["return"]();
116
+ } finally{
117
+ if (_d) throw _e;
118
+ }
119
+ }
120
+ return _arr;
121
+ }
122
+ function _non_iterable_rest() {
123
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
124
+ }
125
+ function _possible_constructor_return$1(self, call) {
126
+ if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
127
+ return call;
128
+ }
129
+ return _assert_this_initialized$1(self);
130
+ }
131
+ function _set_prototype_of$1(o, p) {
132
+ _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
133
+ o.__proto__ = p;
134
+ return o;
135
+ };
136
+ return _set_prototype_of$1(o, p);
137
+ }
138
+ function _sliced_to_array(arr, i) {
139
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
140
+ }
141
+ function _super_prop_base$1(object, property) {
142
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
143
+ object = _get_prototype_of$1(object);
144
+ if (object === null) break;
145
+ }
146
+ return object;
147
+ }
148
+ function _type_of$1(obj) {
149
+ "@swc/helpers - typeof";
150
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
151
+ }
152
+ function _unsupported_iterable_to_array(o, minLen) {
153
+ if (!o) return;
154
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
155
+ var n = Object.prototype.toString.call(o).slice(8, -1);
156
+ if (n === "Object" && o.constructor) n = o.constructor.name;
157
+ if (n === "Map" || n === "Set") return Array.from(n);
158
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
159
+ }
160
+ function _is_native_reflect_construct$1() {
161
+ try {
162
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
163
+ } catch (_) {}
164
+ return (_is_native_reflect_construct$1 = function() {
165
+ return !!result;
166
+ })();
167
+ }
168
+ var adapterError = makeError('ViewflyDOMRenderer');
169
+ var ViewflyAdapter = /*#__PURE__*/ function(DomAdapter1) {
170
+ _inherits$1(ViewflyAdapter, DomAdapter1);
171
+ function ViewflyAdapter(components, mount) {
172
+ _class_call_check$1(this, ViewflyAdapter);
173
+ var _this;
174
+ _this = _call_super$1(this, ViewflyAdapter, [
175
+ {
176
+ createCompositionNode: function createCompositionNode(compositionState, updateNativeCompositionNode) {
177
+ var ref = createDynamicRef(function(node) {
178
+ updateNativeCompositionNode(node);
179
+ return function() {
180
+ updateNativeCompositionNode(null);
181
+ };
182
+ });
183
+ return new VElement('span', {
184
+ style: {
185
+ textDecoration: 'underline'
186
+ },
187
+ ref: ref
188
+ }, [
189
+ new VTextNode(compositionState.text)
190
+ ]);
191
+ },
192
+ getParentNode: function getParentNode(node) {
193
+ return node.parentNode;
194
+ },
195
+ getChildNodes: function getChildNodes(parentElement) {
196
+ return Array.from(parentElement.childNodes);
197
+ },
198
+ isNativeElementNode: function isNativeElementNode(node) {
199
+ return _instanceof(node, Element);
200
+ },
201
+ getChildByIndex: function getChildByIndex(parentElement, index) {
202
+ return parentElement.childNodes[index];
203
+ },
204
+ getAndUpdateSlotRootNativeElement: function getAndUpdateSlotRootNativeElement(vEle, update) {
205
+ var currentRef = vEle.attrs.get('ref');
206
+ var ref = createDynamicRef(function(nativeNode) {
207
+ update(nativeNode);
208
+ return function() {
209
+ update(null);
210
+ };
211
+ });
212
+ if (typeof currentRef === 'function') {
213
+ vEle.attrs.set('ref', [
214
+ currentRef,
215
+ ref
216
+ ]);
217
+ } else if (Array.isArray(currentRef)) {
218
+ currentRef.push(ref);
219
+ } else {
220
+ vEle.attrs.set('ref', ref);
221
+ }
222
+ },
223
+ componentRender: function componentRender(component) {
224
+ var comp = _assert_this_initialized$1(_this).components[component.name] || _assert_this_initialized$1(_this).components['*'];
225
+ if (comp) {
226
+ var ref = _assert_this_initialized$1(_this).componentRefs.get(component);
227
+ if (!ref) {
228
+ ref = createDynamicRef(function(rootNode) {
229
+ _assert_this_initialized$1(_this).componentRootElementCaches.set(component, rootNode);
230
+ return function() {
231
+ // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点
232
+ if (_assert_this_initialized$1(_this).componentRootElementCaches.get(component) === rootNode) {
233
+ _assert_this_initialized$1(_this).componentRootElementCaches.remove(component);
234
+ }
235
+ };
236
+ });
237
+ _assert_this_initialized$1(_this).componentRefs.set(component, ref);
238
+ }
239
+ return jsx(comp, {
240
+ component: component,
241
+ rootRef: ref
242
+ }, component.id);
243
+ }
244
+ throw adapterError("cannot found view component `".concat(component.name, "`!"));
245
+ },
246
+ vElementToViewElement: function vElementToViewElement(vNode, children) {
247
+ var key;
248
+ var props = Array.from(vNode.attrs).reduce(function(a, b) {
249
+ var propName = b[0];
250
+ if (propName === 'key') {
251
+ key = b[1];
252
+ return a;
253
+ }
254
+ a[propName] = b[1];
255
+ return a;
256
+ }, {});
257
+ if (vNode.classes.size) {
258
+ props.class = Array.from(vNode.classes).join(' ');
259
+ }
260
+ if (vNode.styles) {
261
+ props.style = Array.from(vNode.styles).reduce(function(a, b) {
262
+ a[b[0]] = b[1];
263
+ return a;
264
+ }, {});
265
+ }
266
+ if (children.length) {
267
+ props.children = children;
268
+ }
269
+ return jsx(vNode.tagName, props, key);
270
+ }
271
+ },
272
+ mount
273
+ ]), _define_property(_this, "components", {}), _define_property(_this, "componentRefs", new WeakMap());
274
+ var isRoot = true;
275
+ Object.entries(components).forEach(function(param) {
276
+ var _param = _sliced_to_array(param, 2), key = _param[0], viewFlyComponent = _param[1];
277
+ _this.components[key] = function(props) {
278
+ var comp = getCurrentInstance();
279
+ var textbusComponent = props.component;
280
+ var subscription = merge(textbusComponent.changeMarker.onChange, textbusComponent.changeMarker.onForceChange).subscribe(function() {
281
+ if (textbusComponent.changeMarker.dirty) {
282
+ comp.markAsDirtied();
283
+ }
284
+ });
285
+ onUnmounted(function() {
286
+ subscription.unsubscribe();
287
+ });
288
+ if (isRoot) {
289
+ onUpdated(function() {
290
+ _this.onViewUpdated.next();
291
+ });
292
+ isRoot = false;
293
+ }
294
+ onUpdated(function() {
295
+ textbusComponent.changeMarker.rendered();
296
+ if (!_this.componentRootElementCaches.get(textbusComponent)) {
297
+ // eslint-disable-next-line max-len
298
+ throw adapterError("Component `".concat(textbusComponent.name, "` is not bound to rootRef, you must bind rootRef to the root element node of the component view."));
299
+ }
300
+ });
301
+ return viewFlyComponent(props);
302
+ };
72
303
  });
73
- return x(() => {
74
- s.unsubscribe();
75
- }), i && (p(() => {
76
- this.onViewUpdated.next();
77
- }), i = !1), p(() => {
78
- if (o.changeMarker.rendered(), !this.componentRootElementCaches.get(o))
79
- throw h(`Component \`${o.name}\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`);
80
- }), r(t);
81
- };
304
+ return _this;
305
+ }
306
+ _create_class$1(ViewflyAdapter, [
307
+ {
308
+ key: "render",
309
+ value: function render(rootComponent, injector) {
310
+ var childInjector = new ReflectiveInjector(injector, [
311
+ {
312
+ provide: Adapter,
313
+ useValue: this
314
+ },
315
+ {
316
+ provide: DomAdapter,
317
+ useValue: this
318
+ },
319
+ {
320
+ provide: ViewflyAdapter,
321
+ useValue: this
322
+ }
323
+ ]);
324
+ return _get$1(_get_prototype_of$1(ViewflyAdapter.prototype), "render", this).call(this, rootComponent, childInjector);
325
+ }
326
+ },
327
+ {
328
+ key: "copy",
329
+ value: function copy() {
330
+ document.execCommand('copy');
331
+ }
332
+ }
333
+ ]);
334
+ return ViewflyAdapter;
335
+ }(DomAdapter);
336
+
337
+ function _assert_this_initialized(self) {
338
+ if (self === void 0) {
339
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
340
+ }
341
+ return self;
342
+ }
343
+ function _call_super(_this, derived, args) {
344
+ derived = _get_prototype_of(derived);
345
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
346
+ }
347
+ function _class_call_check(instance, Constructor) {
348
+ if (!(instance instanceof Constructor)) {
349
+ throw new TypeError("Cannot call a class as a function");
350
+ }
351
+ }
352
+ function _defineProperties(target, props) {
353
+ for(var i = 0; i < props.length; i++){
354
+ var descriptor = props[i];
355
+ descriptor.enumerable = descriptor.enumerable || false;
356
+ descriptor.configurable = true;
357
+ if ("value" in descriptor) descriptor.writable = true;
358
+ Object.defineProperty(target, descriptor.key, descriptor);
359
+ }
360
+ }
361
+ function _create_class(Constructor, protoProps, staticProps) {
362
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
363
+ return Constructor;
364
+ }
365
+ function _get(target, property, receiver) {
366
+ if (typeof Reflect !== "undefined" && Reflect.get) {
367
+ _get = Reflect.get;
368
+ } else {
369
+ _get = function get(target, property, receiver) {
370
+ var base = _super_prop_base(target, property);
371
+ if (!base) return;
372
+ var desc = Object.getOwnPropertyDescriptor(base, property);
373
+ if (desc.get) {
374
+ return desc.get.call(receiver || target);
375
+ }
376
+ return desc.value;
377
+ };
378
+ }
379
+ return _get(target, property, receiver || target);
380
+ }
381
+ function _get_prototype_of(o) {
382
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
383
+ return o.__proto__ || Object.getPrototypeOf(o);
384
+ };
385
+ return _get_prototype_of(o);
386
+ }
387
+ function _inherits(subClass, superClass) {
388
+ if (typeof superClass !== "function" && superClass !== null) {
389
+ throw new TypeError("Super expression must either be null or a function");
390
+ }
391
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
392
+ constructor: {
393
+ value: subClass,
394
+ writable: true,
395
+ configurable: true
396
+ }
82
397
  });
83
- }
84
- render(c, a) {
85
- const i = new g(a, [{
86
- provide: y,
87
- useValue: this
88
- }, {
89
- provide: u,
90
- useValue: this
91
- }, {
92
- provide: d,
93
- useValue: this
94
- }]);
95
- return super.render(c, i);
96
- }
97
- copy() {
98
- document.execCommand("copy");
99
- }
100
- }
101
- class v extends E {
102
- render(c, a) {
103
- const i = new g(a, [{
104
- provide: y,
105
- useValue: this
106
- }, {
107
- provide: u,
108
- useValue: this
109
- }, {
110
- provide: d,
111
- useValue: this
112
- }]);
113
- return super.render(c, i);
114
- }
115
- }
116
- export {
117
- d as ViewflyAdapter,
118
- v as ViewflyVDomAdapter
119
- };
398
+ if (superClass) _set_prototype_of(subClass, superClass);
399
+ }
400
+ function _possible_constructor_return(self, call) {
401
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
402
+ return call;
403
+ }
404
+ return _assert_this_initialized(self);
405
+ }
406
+ function _set_prototype_of(o, p) {
407
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
408
+ o.__proto__ = p;
409
+ return o;
410
+ };
411
+ return _set_prototype_of(o, p);
412
+ }
413
+ function _super_prop_base(object, property) {
414
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
415
+ object = _get_prototype_of(object);
416
+ if (object === null) break;
417
+ }
418
+ return object;
419
+ }
420
+ function _type_of(obj) {
421
+ "@swc/helpers - typeof";
422
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
423
+ }
424
+ function _is_native_reflect_construct() {
425
+ try {
426
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
427
+ } catch (_) {}
428
+ return (_is_native_reflect_construct = function() {
429
+ return !!result;
430
+ })();
431
+ }
432
+ var ViewflyVDomAdapter = /*#__PURE__*/ function(NodeViewAdapter) {
433
+ _inherits(ViewflyVDomAdapter, NodeViewAdapter);
434
+ function ViewflyVDomAdapter() {
435
+ _class_call_check(this, ViewflyVDomAdapter);
436
+ return _call_super(this, ViewflyVDomAdapter, arguments);
437
+ }
438
+ _create_class(ViewflyVDomAdapter, [
439
+ {
440
+ key: "render",
441
+ value: function render(rootComponent, injector) {
442
+ var childInjector = new ReflectiveInjector(injector, [
443
+ {
444
+ provide: Adapter,
445
+ useValue: this
446
+ },
447
+ {
448
+ provide: DomAdapter,
449
+ useValue: this
450
+ },
451
+ {
452
+ provide: ViewflyAdapter,
453
+ useValue: this
454
+ }
455
+ ]);
456
+ return _get(_get_prototype_of(ViewflyVDomAdapter.prototype), "render", this).call(this, rootComponent, childInjector);
457
+ }
458
+ }
459
+ ]);
460
+ return ViewflyVDomAdapter;
461
+ }(NodeViewAdapter);
462
+
463
+ export { ViewflyAdapter, ViewflyVDomAdapter };
120
464
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/viewfly-adapter.ts","../src/viewfly-vdom-adapter.ts"],"sourcesContent":["import { Component, CompositionState, makeError, VElement, ViewMount, VTextNode, merge, Adapter } from '@textbus/core'\nimport {\n ComponentSetup,\n createDynamicRef,\n DynamicRef,\n getCurrentInstance, Injector,\n jsx,\n JSXNode, onUnmounted,\n onUpdated, ReflectiveInjector,\n ViewFlyNode,\n} from '@viewfly/core'\nimport { DomAdapter } from '@textbus/platform-browser'\n\nconst adapterError = makeError('ViewflyDOMRenderer')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: DynamicRef<Element>\n}\n\nexport interface ViewflyAdapterComponents {\n [key: string]: ComponentSetup<ViewComponentProps<any>>\n}\n\nexport class ViewflyAdapter extends DomAdapter<ViewFlyNode, ViewFlyNode> {\n private components: ViewflyAdapterComponents = {}\n\n private componentRefs = new WeakMap<Component, DynamicRef<Element>>()\n\n constructor(components: ViewflyAdapterComponents,\n mount: ViewMount<ViewFlyNode, Element>\n ) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n const ref = createDynamicRef<Element>(node => {\n updateNativeCompositionNode(node)\n return () => {\n updateNativeCompositionNode(null)\n }\n })\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref\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 const ref = createDynamicRef<Element>(nativeNode => {\n update(nativeNode)\n return () => {\n update(null)\n }\n })\n if (typeof currentRef === 'function') {\n vEle.attrs.set('ref', [currentRef, ref])\n } else if (Array.isArray(currentRef)) {\n currentRef.push(ref)\n } else {\n vEle.attrs.set('ref', ref)\n }\n },\n componentRender: (component: Component<any>): ViewFlyNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let ref = this.componentRefs.get(component)\n if (!ref) {\n ref = createDynamicRef<Element>(rootNode => {\n this.componentRootElementCaches.set(component, rootNode)\n return () => {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n })\n this.componentRefs.set(component, ref)\n }\n return jsx(comp, {\n component,\n rootRef: ref\n }, component.id)\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<JSXNode>): ViewFlyNode {\n let key: any\n const props = Array.from(vNode.attrs).reduce((a, b) => {\n const propName = b[0]\n if (propName === 'key') {\n key = b[1]\n return a\n }\n a[propName] = b[1]\n return a\n }, {} as Record<string, any>)\n if (vNode.classes.size) {\n props.class = 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 if (children.length) {\n props.children = children\n }\n return jsx(vNode.tagName, props, key)\n }\n }, mount)\n\n let isRoot = true\n Object.entries(components).forEach(([key, viewFlyComponent]) => {\n this.components[key] = (props: ViewComponentProps<Component>) => {\n const comp = getCurrentInstance()\n const textbusComponent = props.component\n const subscription = merge(textbusComponent.changeMarker.onChange,\n textbusComponent.changeMarker.onForceChange).subscribe(() => {\n if (textbusComponent.changeMarker.dirty) {\n comp.markAsDirtied()\n }\n })\n onUnmounted(() => {\n subscription.unsubscribe()\n })\n if (isRoot) {\n onUpdated(() => {\n this.onViewUpdated.next()\n })\n isRoot = false\n }\n onUpdated(() => {\n textbusComponent.changeMarker.rendered()\n if (!this.componentRootElementCaches.get(textbusComponent)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${textbusComponent.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return viewFlyComponent(props)\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: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n","import { NodeViewAdapter } from '@textbus/platform-node'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { Adapter, Component } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { ViewflyAdapter } from './viewfly-adapter'\n\nexport class ViewflyVDomAdapter extends NodeViewAdapter {\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: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n}\n"],"names":["adapterError","makeError","ViewflyAdapter","DomAdapter","components","mount","compositionState","updateNativeCompositionNode","ref","createDynamicRef","node","VElement","VTextNode","parentElement","index","vEle","update","currentRef","nativeNode","component","comp","rootNode","jsx","vNode","children","key","props","a","b","propName","isRoot","viewFlyComponent","getCurrentInstance","textbusComponent","subscription","merge","onUnmounted","onUpdated","rootComponent","injector","childInjector","ReflectiveInjector","Adapter","ViewflyVDomAdapter","NodeViewAdapter"],"mappings":";;;;AAaA,MAAMA,IAAeC,EAAU,oBAAoB;AAW5C,MAAMC,UAAuBC,EAAqC;AAAA,EAC/D,aAAuC,CAAA;AAAA,EAEvC,oCAAoB,QAAA;AAAA,EAE5B,YAAYC,GACAC,GACV;AACA,UAAM;AAAA,MACJ,sBAAsBC,GACAC,GAA+E;AACnG,cAAMC,IAAMC,EAA0B,CAAAC,OACpCH,EAA4BG,CAAI,GACzB,MAAM;AACX,UAAAH,EAA4B,IAAI;AAAA,QAClC,EACD;AACD,eAAO,IAAII,EAAS,QAAQ;AAAA,UAC1B,OAAO;AAAA,YACL,gBAAgB;AAAA,UAAA;AAAA,UAElB,KAAAH;AAAA,QAAA,GACC;AAAA,UACD,IAAII,EAAUN,EAAiB,IAAI;AAAA,QAAA,CACpC;AAAA,MACH;AAAA,MACA,cAAcI,GAAsC;AAClD,eAAQA,EAAc;AAAA,MACxB;AAAA,MACA,cAAcG,GAA+C;AAC3D,eAAO,MAAM,KAAKA,EAAc,UAAU;AAAA,MAC5C;AAAA,MACA,oBAAoBH,GAAuC;AACzD,eAAOA,aAAgB;AAAA,MACzB;AAAA,MACA,gBAAgBG,GAAeC,GAAO;AACpC,eAAOD,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AAA,MACD,SAASvC;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAASD;AAAA,MACT,UAAU;AAAA,IAAA,CACX,CAAC;AACF,WAAO,MAAM,OAAOoC,GAAeE,CAAa;AAAA,EAClD;AAAA,EAES,OAAO;AACd,aAAS,YAAY,MAAM;AAAA,EAC7B;AACF;AC3KO,MAAMG,UAA2BC,EAAgB;AAAA,EAC7C,OAAON,GAA0BC,GAAyC;AACjF,UAAMC,IAAgB,IAAIC,EAAmBF,GAAU,CAAC;AAAA,MACtD,SAASG;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAASvC;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAASD;AAAA,MACT,UAAU;AAAA,IAAA,CACX,CAAC;AACF,WAAO,MAAM,OAAOoC,GAAeE,CAAa;AAAA,EAClD;AACF;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/viewfly-adapter.ts","../src/viewfly-vdom-adapter.ts"],"sourcesContent":["import { Component, CompositionState, makeError, VElement, ViewMount, VTextNode, merge, Adapter } from '@textbus/core'\nimport {\n ComponentSetup,\n createDynamicRef,\n DynamicRef,\n getCurrentInstance, Injector,\n jsx,\n JSXNode, onUnmounted,\n onUpdated, ReflectiveInjector,\n ViewFlyNode,\n} from '@viewfly/core'\nimport { DomAdapter } from '@textbus/platform-browser'\n\nconst adapterError = makeError('ViewflyDOMRenderer')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: DynamicRef<Element>\n}\n\nexport interface ViewflyAdapterComponents {\n [key: string]: ComponentSetup<ViewComponentProps<any>>\n}\n\nexport class ViewflyAdapter extends DomAdapter<ViewFlyNode, ViewFlyNode> {\n private components: ViewflyAdapterComponents = {}\n\n private componentRefs = new WeakMap<Component, DynamicRef<Element>>()\n\n constructor(components: ViewflyAdapterComponents,\n mount: ViewMount<ViewFlyNode, Element>\n ) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n const ref = createDynamicRef<Element>(node => {\n updateNativeCompositionNode(node)\n return () => {\n updateNativeCompositionNode(null)\n }\n })\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref\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 const ref = createDynamicRef<Element>(nativeNode => {\n update(nativeNode)\n return () => {\n update(null)\n }\n })\n if (typeof currentRef === 'function') {\n vEle.attrs.set('ref', [currentRef, ref])\n } else if (Array.isArray(currentRef)) {\n currentRef.push(ref)\n } else {\n vEle.attrs.set('ref', ref)\n }\n },\n componentRender: (component: Component<any>): ViewFlyNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let ref = this.componentRefs.get(component)\n if (!ref) {\n ref = createDynamicRef<Element>(rootNode => {\n this.componentRootElementCaches.set(component, rootNode)\n return () => {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n })\n this.componentRefs.set(component, ref)\n }\n return jsx(comp, {\n component,\n rootRef: ref\n }, component.id)\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<JSXNode>): ViewFlyNode {\n let key: any\n const props = Array.from(vNode.attrs).reduce((a, b) => {\n const propName = b[0]\n if (propName === 'key') {\n key = b[1]\n return a\n }\n a[propName] = b[1]\n return a\n }, {} as Record<string, any>)\n if (vNode.classes.size) {\n props.class = 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 if (children.length) {\n props.children = children\n }\n return jsx(vNode.tagName, props, key)\n }\n }, mount)\n\n let isRoot = true\n Object.entries(components).forEach(([key, viewFlyComponent]) => {\n this.components[key] = (props: ViewComponentProps<Component>) => {\n const comp = getCurrentInstance()\n const textbusComponent = props.component\n const subscription = merge(textbusComponent.changeMarker.onChange,\n textbusComponent.changeMarker.onForceChange).subscribe(() => {\n if (textbusComponent.changeMarker.dirty) {\n comp.markAsDirtied()\n }\n })\n onUnmounted(() => {\n subscription.unsubscribe()\n })\n if (isRoot) {\n onUpdated(() => {\n this.onViewUpdated.next()\n })\n isRoot = false\n }\n onUpdated(() => {\n textbusComponent.changeMarker.rendered()\n if (!this.componentRootElementCaches.get(textbusComponent)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${textbusComponent.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return viewFlyComponent(props)\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: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n","import { NodeViewAdapter } from '@textbus/platform-node'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { Adapter, Component } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { ViewflyAdapter } from './viewfly-adapter'\n\nexport class ViewflyVDomAdapter extends NodeViewAdapter {\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: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n}\n"],"names":["adapterError","makeError","ViewflyAdapter","components","mount","_call_super","createCompositionNode","compositionState","updateNativeCompositionNode","ref","createDynamicRef","node","VElement","style","textDecoration","VTextNode","text","getParentNode","parentNode","getChildNodes","parentElement","Array","from","childNodes","isNativeElementNode","Element","getChildByIndex","index","getAndUpdateSlotRootNativeElement","vEle","update","currentRef","attrs","get","nativeNode","set","isArray","push","componentRender","component","comp","_assert_this_initialized","name","componentRefs","rootNode","componentRootElementCaches","remove","jsx","rootRef","id","vElementToViewElement","vNode","children","key","props","reduce","a","b","propName","classes","size","class","join","styles","length","tagName","WeakMap","isRoot","Object","entries","forEach","viewFlyComponent","getCurrentInstance","textbusComponent","subscription","merge","changeMarker","onChange","onForceChange","subscribe","dirty","markAsDirtied","onUnmounted","unsubscribe","onUpdated","onViewUpdated","next","rendered","render","rootComponent","injector","childInjector","ReflectiveInjector","provide","Adapter","useValue","DomAdapter","_get","_get_prototype_of","copy","document","execCommand","ViewflyVDomAdapter","NodeViewAdapter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAMA,eAAeC,SAAAA,CAAU,oBAAA,CAAA;AAWxB,IAAA,cAAMC,iBAAN,SAAA,WAAA,EAAA;AAAMA,IAAAA,WAAAA,CAAAA,cAAAA,EAAAA,WAAAA,CAAAA;aAAAA,cAAAA,CAKCC,UAAoC,EACpCC,KAAsC,EAAA;AANvCF,QAAAA,mBAAAA,CAAAA,IAAAA,EAAAA,cAAAA,CAAAA;;gBAQTG,aAAA,CAAA,IAAA,EARSH,cAAAA,EAAAA;AAQH,YAAA;AACJI,gBAAAA,qBAAAA,EAAAA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;wBACDF,OAAAA,EAAS3F,cAAAA;AACT6F,wBAAAA,QAAAA,EAAU;AACZ;AAAE,iBAAA,CAAA;AACF,gBAAA,OAAO,IAAA,CAAA,iBAAA,CAZEO,kBAAAA,CAAAA,SAAAA,CAAAA,EAYId,QAAAA,EAAN,IAAK,aAAQC,aAAAA,EAAeE,aAAAA,CAAAA;AACrC,YAAA;;;AAbWW,IAAAA,OAAAA,kBAAAA;EAA2BC,eAAAA;;;;"}
package/dist/index.js CHANGED
@@ -1,2 +1,469 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@textbus/core"),s=require("@viewfly/core"),m=require("@textbus/platform-browser"),h=require("@textbus/platform-node"),p=a.makeError("ViewflyDOMRenderer");class l extends m.DomAdapter{components={};componentRefs=new WeakMap;constructor(u,d){super({createCompositionNode(e,r){const t=s.createDynamicRef(n=>(r(n),()=>{r(null)}));return new a.VElement("span",{style:{textDecoration:"underline"},ref:t},[new a.VTextNode(e.text)])},getParentNode(e){return e.parentNode},getChildNodes(e){return Array.from(e.childNodes)},isNativeElementNode(e){return e instanceof Element},getChildByIndex(e,r){return e.childNodes[r]},getAndUpdateSlotRootNativeElement(e,r){const t=e.attrs.get("ref"),n=s.createDynamicRef(o=>(r(o),()=>{r(null)}));typeof t=="function"?e.attrs.set("ref",[t,n]):Array.isArray(t)?t.push(n):e.attrs.set("ref",n)},componentRender:e=>{const r=this.components[e.name]||this.components["*"];if(r){let t=this.componentRefs.get(e);return t||(t=s.createDynamicRef(n=>(this.componentRootElementCaches.set(e,n),()=>{this.componentRootElementCaches.get(e)===n&&this.componentRootElementCaches.remove(e)})),this.componentRefs.set(e,t)),s.jsx(r,{component:e,rootRef:t},e.id)}throw p(`cannot found view component \`${e.name}\`!`)},vElementToViewElement(e,r){let t;const n=Array.from(e.attrs).reduce((o,i)=>{const f=i[0];return f==="key"?(t=i[1],o):(o[f]=i[1],o)},{});return e.classes.size&&(n.class=Array.from(e.classes).join(" ")),e.styles&&(n.style=Array.from(e.styles).reduce((o,i)=>(o[i[0]]=i[1],o),{})),r.length&&(n.children=r),s.jsx(e.tagName,n,t)}},d);let c=!0;Object.entries(u).forEach(([e,r])=>{this.components[e]=t=>{const n=s.getCurrentInstance(),o=t.component,i=a.merge(o.changeMarker.onChange,o.changeMarker.onForceChange).subscribe(()=>{o.changeMarker.dirty&&n.markAsDirtied()});return s.onUnmounted(()=>{i.unsubscribe()}),c&&(s.onUpdated(()=>{this.onViewUpdated.next()}),c=!1),s.onUpdated(()=>{if(o.changeMarker.rendered(),!this.componentRootElementCaches.get(o))throw p(`Component \`${o.name}\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)}),r(t)}})}render(u,d){const c=new s.ReflectiveInjector(d,[{provide:a.Adapter,useValue:this},{provide:m.DomAdapter,useValue:this},{provide:l,useValue:this}]);return super.render(u,c)}copy(){document.execCommand("copy")}}class y extends h.NodeViewAdapter{render(u,d){const c=new s.ReflectiveInjector(d,[{provide:a.Adapter,useValue:this},{provide:m.DomAdapter,useValue:this},{provide:l,useValue:this}]);return super.render(u,c)}}exports.ViewflyAdapter=l;exports.ViewflyVDomAdapter=y;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ const core = require('@textbus/core');
6
+ const core$1 = require('@viewfly/core');
7
+ const platformBrowser = require('@textbus/platform-browser');
8
+ const platformNode = require('@textbus/platform-node');
9
+
10
+ function _array_like_to_array(arr, len) {
11
+ if (len == null || len > arr.length) len = arr.length;
12
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
13
+ return arr2;
14
+ }
15
+ function _array_with_holes(arr) {
16
+ if (Array.isArray(arr)) return arr;
17
+ }
18
+ function _assert_this_initialized$1(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$1(_this, derived, args) {
25
+ derived = _get_prototype_of$1(derived);
26
+ return _possible_constructor_return$1(_this, _is_native_reflect_construct$1() ? Reflect.construct(derived, args || [], _get_prototype_of$1(_this).constructor) : derived.apply(_this, args));
27
+ }
28
+ function _class_call_check$1(instance, Constructor) {
29
+ if (!(instance instanceof Constructor)) {
30
+ throw new TypeError("Cannot call a class as a function");
31
+ }
32
+ }
33
+ function _defineProperties$1(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$1(Constructor, protoProps, staticProps) {
43
+ if (protoProps) _defineProperties$1(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$1(target, property, receiver) {
60
+ if (typeof Reflect !== "undefined" && Reflect.get) {
61
+ _get$1 = Reflect.get;
62
+ } else {
63
+ _get$1 = function get(target, property, receiver) {
64
+ var base = _super_prop_base$1(target, property);
65
+ if (!base) return;
66
+ var desc = Object.getOwnPropertyDescriptor(base, property);
67
+ if (desc.get) {
68
+ return desc.get.call(receiver || target);
69
+ }
70
+ return desc.value;
71
+ };
72
+ }
73
+ return _get$1(target, property, receiver || target);
74
+ }
75
+ function _get_prototype_of$1(o) {
76
+ _get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
77
+ return o.__proto__ || Object.getPrototypeOf(o);
78
+ };
79
+ return _get_prototype_of$1(o);
80
+ }
81
+ function _inherits$1(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
90
+ }
91
+ });
92
+ if (superClass) _set_prototype_of$1(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_limit(arr, i) {
103
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
104
+ if (_i == null) return;
105
+ var _arr = [];
106
+ var _n = true;
107
+ var _d = false;
108
+ var _s, _e;
109
+ try {
110
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
111
+ _arr.push(_s.value);
112
+ if (i && _arr.length === i) break;
113
+ }
114
+ } catch (err) {
115
+ _d = true;
116
+ _e = err;
117
+ } finally{
118
+ try {
119
+ if (!_n && _i["return"] != null) _i["return"]();
120
+ } finally{
121
+ if (_d) throw _e;
122
+ }
123
+ }
124
+ return _arr;
125
+ }
126
+ function _non_iterable_rest() {
127
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
128
+ }
129
+ function _possible_constructor_return$1(self, call) {
130
+ if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
131
+ return call;
132
+ }
133
+ return _assert_this_initialized$1(self);
134
+ }
135
+ function _set_prototype_of$1(o, p) {
136
+ _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
137
+ o.__proto__ = p;
138
+ return o;
139
+ };
140
+ return _set_prototype_of$1(o, p);
141
+ }
142
+ function _sliced_to_array(arr, i) {
143
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
144
+ }
145
+ function _super_prop_base$1(object, property) {
146
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
147
+ object = _get_prototype_of$1(object);
148
+ if (object === null) break;
149
+ }
150
+ return object;
151
+ }
152
+ function _type_of$1(obj) {
153
+ "@swc/helpers - typeof";
154
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
155
+ }
156
+ function _unsupported_iterable_to_array(o, minLen) {
157
+ if (!o) return;
158
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
159
+ var n = Object.prototype.toString.call(o).slice(8, -1);
160
+ if (n === "Object" && o.constructor) n = o.constructor.name;
161
+ if (n === "Map" || n === "Set") return Array.from(n);
162
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
163
+ }
164
+ function _is_native_reflect_construct$1() {
165
+ try {
166
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
167
+ } catch (_) {}
168
+ return (_is_native_reflect_construct$1 = function() {
169
+ return !!result;
170
+ })();
171
+ }
172
+ var adapterError = core.makeError('ViewflyDOMRenderer');
173
+ var ViewflyAdapter = /*#__PURE__*/ function(DomAdapter1) {
174
+ _inherits$1(ViewflyAdapter, DomAdapter1);
175
+ function ViewflyAdapter(components, mount) {
176
+ _class_call_check$1(this, ViewflyAdapter);
177
+ var _this;
178
+ _this = _call_super$1(this, ViewflyAdapter, [
179
+ {
180
+ createCompositionNode: function createCompositionNode(compositionState, updateNativeCompositionNode) {
181
+ var ref = core$1.createDynamicRef(function(node) {
182
+ updateNativeCompositionNode(node);
183
+ return function() {
184
+ updateNativeCompositionNode(null);
185
+ };
186
+ });
187
+ return new core.VElement('span', {
188
+ style: {
189
+ textDecoration: 'underline'
190
+ },
191
+ ref: ref
192
+ }, [
193
+ new core.VTextNode(compositionState.text)
194
+ ]);
195
+ },
196
+ getParentNode: function getParentNode(node) {
197
+ return node.parentNode;
198
+ },
199
+ getChildNodes: function getChildNodes(parentElement) {
200
+ return Array.from(parentElement.childNodes);
201
+ },
202
+ isNativeElementNode: function isNativeElementNode(node) {
203
+ return _instanceof(node, Element);
204
+ },
205
+ getChildByIndex: function getChildByIndex(parentElement, index) {
206
+ return parentElement.childNodes[index];
207
+ },
208
+ getAndUpdateSlotRootNativeElement: function getAndUpdateSlotRootNativeElement(vEle, update) {
209
+ var currentRef = vEle.attrs.get('ref');
210
+ var ref = core$1.createDynamicRef(function(nativeNode) {
211
+ update(nativeNode);
212
+ return function() {
213
+ update(null);
214
+ };
215
+ });
216
+ if (typeof currentRef === 'function') {
217
+ vEle.attrs.set('ref', [
218
+ currentRef,
219
+ ref
220
+ ]);
221
+ } else if (Array.isArray(currentRef)) {
222
+ currentRef.push(ref);
223
+ } else {
224
+ vEle.attrs.set('ref', ref);
225
+ }
226
+ },
227
+ componentRender: function componentRender(component) {
228
+ var comp = _assert_this_initialized$1(_this).components[component.name] || _assert_this_initialized$1(_this).components['*'];
229
+ if (comp) {
230
+ var ref = _assert_this_initialized$1(_this).componentRefs.get(component);
231
+ if (!ref) {
232
+ ref = core$1.createDynamicRef(function(rootNode) {
233
+ _assert_this_initialized$1(_this).componentRootElementCaches.set(component, rootNode);
234
+ return function() {
235
+ // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点
236
+ if (_assert_this_initialized$1(_this).componentRootElementCaches.get(component) === rootNode) {
237
+ _assert_this_initialized$1(_this).componentRootElementCaches.remove(component);
238
+ }
239
+ };
240
+ });
241
+ _assert_this_initialized$1(_this).componentRefs.set(component, ref);
242
+ }
243
+ return core$1.jsx(comp, {
244
+ component: component,
245
+ rootRef: ref
246
+ }, component.id);
247
+ }
248
+ throw adapterError("cannot found view component `".concat(component.name, "`!"));
249
+ },
250
+ vElementToViewElement: function vElementToViewElement(vNode, children) {
251
+ var key;
252
+ var props = Array.from(vNode.attrs).reduce(function(a, b) {
253
+ var propName = b[0];
254
+ if (propName === 'key') {
255
+ key = b[1];
256
+ return a;
257
+ }
258
+ a[propName] = b[1];
259
+ return a;
260
+ }, {});
261
+ if (vNode.classes.size) {
262
+ props.class = Array.from(vNode.classes).join(' ');
263
+ }
264
+ if (vNode.styles) {
265
+ props.style = Array.from(vNode.styles).reduce(function(a, b) {
266
+ a[b[0]] = b[1];
267
+ return a;
268
+ }, {});
269
+ }
270
+ if (children.length) {
271
+ props.children = children;
272
+ }
273
+ return core$1.jsx(vNode.tagName, props, key);
274
+ }
275
+ },
276
+ mount
277
+ ]), _define_property(_this, "components", {}), _define_property(_this, "componentRefs", new WeakMap());
278
+ var isRoot = true;
279
+ Object.entries(components).forEach(function(param) {
280
+ var _param = _sliced_to_array(param, 2), key = _param[0], viewFlyComponent = _param[1];
281
+ _this.components[key] = function(props) {
282
+ var comp = core$1.getCurrentInstance();
283
+ var textbusComponent = props.component;
284
+ var subscription = core.merge(textbusComponent.changeMarker.onChange, textbusComponent.changeMarker.onForceChange).subscribe(function() {
285
+ if (textbusComponent.changeMarker.dirty) {
286
+ comp.markAsDirtied();
287
+ }
288
+ });
289
+ core$1.onUnmounted(function() {
290
+ subscription.unsubscribe();
291
+ });
292
+ if (isRoot) {
293
+ core$1.onUpdated(function() {
294
+ _this.onViewUpdated.next();
295
+ });
296
+ isRoot = false;
297
+ }
298
+ core$1.onUpdated(function() {
299
+ textbusComponent.changeMarker.rendered();
300
+ if (!_this.componentRootElementCaches.get(textbusComponent)) {
301
+ // eslint-disable-next-line max-len
302
+ throw adapterError("Component `".concat(textbusComponent.name, "` is not bound to rootRef, you must bind rootRef to the root element node of the component view."));
303
+ }
304
+ });
305
+ return viewFlyComponent(props);
306
+ };
307
+ });
308
+ return _this;
309
+ }
310
+ _create_class$1(ViewflyAdapter, [
311
+ {
312
+ key: "render",
313
+ value: function render(rootComponent, injector) {
314
+ var childInjector = new core$1.ReflectiveInjector(injector, [
315
+ {
316
+ provide: core.Adapter,
317
+ useValue: this
318
+ },
319
+ {
320
+ provide: platformBrowser.DomAdapter,
321
+ useValue: this
322
+ },
323
+ {
324
+ provide: ViewflyAdapter,
325
+ useValue: this
326
+ }
327
+ ]);
328
+ return _get$1(_get_prototype_of$1(ViewflyAdapter.prototype), "render", this).call(this, rootComponent, childInjector);
329
+ }
330
+ },
331
+ {
332
+ key: "copy",
333
+ value: function copy() {
334
+ document.execCommand('copy');
335
+ }
336
+ }
337
+ ]);
338
+ return ViewflyAdapter;
339
+ }(platformBrowser.DomAdapter);
340
+
341
+ function _assert_this_initialized(self) {
342
+ if (self === void 0) {
343
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
344
+ }
345
+ return self;
346
+ }
347
+ function _call_super(_this, derived, args) {
348
+ derived = _get_prototype_of(derived);
349
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
350
+ }
351
+ function _class_call_check(instance, Constructor) {
352
+ if (!(instance instanceof Constructor)) {
353
+ throw new TypeError("Cannot call a class as a function");
354
+ }
355
+ }
356
+ function _defineProperties(target, props) {
357
+ for(var i = 0; i < props.length; i++){
358
+ var descriptor = props[i];
359
+ descriptor.enumerable = descriptor.enumerable || false;
360
+ descriptor.configurable = true;
361
+ if ("value" in descriptor) descriptor.writable = true;
362
+ Object.defineProperty(target, descriptor.key, descriptor);
363
+ }
364
+ }
365
+ function _create_class(Constructor, protoProps, staticProps) {
366
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
367
+ return Constructor;
368
+ }
369
+ function _get(target, property, receiver) {
370
+ if (typeof Reflect !== "undefined" && Reflect.get) {
371
+ _get = Reflect.get;
372
+ } else {
373
+ _get = function get(target, property, receiver) {
374
+ var base = _super_prop_base(target, property);
375
+ if (!base) return;
376
+ var desc = Object.getOwnPropertyDescriptor(base, property);
377
+ if (desc.get) {
378
+ return desc.get.call(receiver || target);
379
+ }
380
+ return desc.value;
381
+ };
382
+ }
383
+ return _get(target, property, receiver || target);
384
+ }
385
+ function _get_prototype_of(o) {
386
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
387
+ return o.__proto__ || Object.getPrototypeOf(o);
388
+ };
389
+ return _get_prototype_of(o);
390
+ }
391
+ function _inherits(subClass, superClass) {
392
+ if (typeof superClass !== "function" && superClass !== null) {
393
+ throw new TypeError("Super expression must either be null or a function");
394
+ }
395
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
396
+ constructor: {
397
+ value: subClass,
398
+ writable: true,
399
+ configurable: true
400
+ }
401
+ });
402
+ if (superClass) _set_prototype_of(subClass, superClass);
403
+ }
404
+ function _possible_constructor_return(self, call) {
405
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
406
+ return call;
407
+ }
408
+ return _assert_this_initialized(self);
409
+ }
410
+ function _set_prototype_of(o, p) {
411
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
412
+ o.__proto__ = p;
413
+ return o;
414
+ };
415
+ return _set_prototype_of(o, p);
416
+ }
417
+ function _super_prop_base(object, property) {
418
+ while(!Object.prototype.hasOwnProperty.call(object, property)){
419
+ object = _get_prototype_of(object);
420
+ if (object === null) break;
421
+ }
422
+ return object;
423
+ }
424
+ function _type_of(obj) {
425
+ "@swc/helpers - typeof";
426
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
427
+ }
428
+ function _is_native_reflect_construct() {
429
+ try {
430
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
431
+ } catch (_) {}
432
+ return (_is_native_reflect_construct = function() {
433
+ return !!result;
434
+ })();
435
+ }
436
+ var ViewflyVDomAdapter = /*#__PURE__*/ function(NodeViewAdapter) {
437
+ _inherits(ViewflyVDomAdapter, NodeViewAdapter);
438
+ function ViewflyVDomAdapter() {
439
+ _class_call_check(this, ViewflyVDomAdapter);
440
+ return _call_super(this, ViewflyVDomAdapter, arguments);
441
+ }
442
+ _create_class(ViewflyVDomAdapter, [
443
+ {
444
+ key: "render",
445
+ value: function render(rootComponent, injector) {
446
+ var childInjector = new core$1.ReflectiveInjector(injector, [
447
+ {
448
+ provide: core.Adapter,
449
+ useValue: this
450
+ },
451
+ {
452
+ provide: platformBrowser.DomAdapter,
453
+ useValue: this
454
+ },
455
+ {
456
+ provide: ViewflyAdapter,
457
+ useValue: this
458
+ }
459
+ ]);
460
+ return _get(_get_prototype_of(ViewflyVDomAdapter.prototype), "render", this).call(this, rootComponent, childInjector);
461
+ }
462
+ }
463
+ ]);
464
+ return ViewflyVDomAdapter;
465
+ }(platformNode.NodeViewAdapter);
466
+
467
+ exports.ViewflyAdapter = ViewflyAdapter;
468
+ exports.ViewflyVDomAdapter = ViewflyVDomAdapter;
2
469
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/viewfly-adapter.ts","../src/viewfly-vdom-adapter.ts"],"sourcesContent":["import { Component, CompositionState, makeError, VElement, ViewMount, VTextNode, merge, Adapter } from '@textbus/core'\nimport {\n ComponentSetup,\n createDynamicRef,\n DynamicRef,\n getCurrentInstance, Injector,\n jsx,\n JSXNode, onUnmounted,\n onUpdated, ReflectiveInjector,\n ViewFlyNode,\n} from '@viewfly/core'\nimport { DomAdapter } from '@textbus/platform-browser'\n\nconst adapterError = makeError('ViewflyDOMRenderer')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: DynamicRef<Element>\n}\n\nexport interface ViewflyAdapterComponents {\n [key: string]: ComponentSetup<ViewComponentProps<any>>\n}\n\nexport class ViewflyAdapter extends DomAdapter<ViewFlyNode, ViewFlyNode> {\n private components: ViewflyAdapterComponents = {}\n\n private componentRefs = new WeakMap<Component, DynamicRef<Element>>()\n\n constructor(components: ViewflyAdapterComponents,\n mount: ViewMount<ViewFlyNode, Element>\n ) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n const ref = createDynamicRef<Element>(node => {\n updateNativeCompositionNode(node)\n return () => {\n updateNativeCompositionNode(null)\n }\n })\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref\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 const ref = createDynamicRef<Element>(nativeNode => {\n update(nativeNode)\n return () => {\n update(null)\n }\n })\n if (typeof currentRef === 'function') {\n vEle.attrs.set('ref', [currentRef, ref])\n } else if (Array.isArray(currentRef)) {\n currentRef.push(ref)\n } else {\n vEle.attrs.set('ref', ref)\n }\n },\n componentRender: (component: Component<any>): ViewFlyNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let ref = this.componentRefs.get(component)\n if (!ref) {\n ref = createDynamicRef<Element>(rootNode => {\n this.componentRootElementCaches.set(component, rootNode)\n return () => {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n })\n this.componentRefs.set(component, ref)\n }\n return jsx(comp, {\n component,\n rootRef: ref\n }, component.id)\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<JSXNode>): ViewFlyNode {\n let key: any\n const props = Array.from(vNode.attrs).reduce((a, b) => {\n const propName = b[0]\n if (propName === 'key') {\n key = b[1]\n return a\n }\n a[propName] = b[1]\n return a\n }, {} as Record<string, any>)\n if (vNode.classes.size) {\n props.class = 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 if (children.length) {\n props.children = children\n }\n return jsx(vNode.tagName, props, key)\n }\n }, mount)\n\n let isRoot = true\n Object.entries(components).forEach(([key, viewFlyComponent]) => {\n this.components[key] = (props: ViewComponentProps<Component>) => {\n const comp = getCurrentInstance()\n const textbusComponent = props.component\n const subscription = merge(textbusComponent.changeMarker.onChange,\n textbusComponent.changeMarker.onForceChange).subscribe(() => {\n if (textbusComponent.changeMarker.dirty) {\n comp.markAsDirtied()\n }\n })\n onUnmounted(() => {\n subscription.unsubscribe()\n })\n if (isRoot) {\n onUpdated(() => {\n this.onViewUpdated.next()\n })\n isRoot = false\n }\n onUpdated(() => {\n textbusComponent.changeMarker.rendered()\n if (!this.componentRootElementCaches.get(textbusComponent)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${textbusComponent.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return viewFlyComponent(props)\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: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n","import { NodeViewAdapter } from '@textbus/platform-node'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { Adapter, Component } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { ViewflyAdapter } from './viewfly-adapter'\n\nexport class ViewflyVDomAdapter extends NodeViewAdapter {\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: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n}\n"],"names":["adapterError","makeError","ViewflyAdapter","DomAdapter","components","mount","compositionState","updateNativeCompositionNode","ref","createDynamicRef","node","VElement","VTextNode","parentElement","index","vEle","update","currentRef","nativeNode","component","comp","rootNode","jsx","vNode","children","key","props","a","b","propName","isRoot","viewFlyComponent","getCurrentInstance","textbusComponent","subscription","merge","onUnmounted","onUpdated","rootComponent","injector","childInjector","ReflectiveInjector","Adapter","ViewflyVDomAdapter","NodeViewAdapter"],"mappings":"uNAaMA,EAAeC,EAAAA,UAAU,oBAAoB,EAW5C,MAAMC,UAAuBC,EAAAA,UAAqC,CAC/D,WAAuC,CAAA,EAEvC,kBAAoB,QAE5B,YAAYC,EACAC,EACV,CACA,MAAM,CACJ,sBAAsBC,EACAC,EAA+E,CACnG,MAAMC,EAAMC,mBAA0BC,IACpCH,EAA4BG,CAAI,EACzB,IAAM,CACXH,EAA4B,IAAI,CAClC,EACD,EACD,OAAO,IAAII,EAAAA,SAAS,OAAQ,CAC1B,MAAO,CACL,eAAgB,WAAA,EAElB,IAAAH,CAAA,EACC,CACD,IAAII,EAAAA,UAAUN,EAAiB,IAAI,CAAA,CACpC,CACH,EACA,cAAcI,EAAsC,CAClD,OAAQA,EAAc,UACxB,EACA,cAAcG,EAA+C,CAC3D,OAAO,MAAM,KAAKA,EAAc,UAAU,CAC5C,EACA,oBAAoBH,EAAuC,CACzD,OAAOA,aAAgB,OACzB,EACA,gBAAgBG,EAAeC,EAAO,CACpC,OAAOD,EAAc,WAAWC,CAAK,CACvC,EACA,kCAAkCC,EAAgBC,EAAmD,CACnG,MAAMC,EAAaF,EAAK,MAAM,IAAI,KAAK,EACjCP,EAAMC,mBAA0BS,IACpCF,EAAOE,CAAU,EACV,IAAM,CACXF,EAAO,IAAI,CACb,EACD,EACG,OAAOC,GAAe,WACxBF,EAAK,MAAM,IAAI,MAAO,CAACE,EAAYT,CAAG,CAAC,EAC9B,MAAM,QAAQS,CAAU,EACjCA,EAAW,KAAKT,CAAG,EAEn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","sources":["../src/viewfly-adapter.ts","../src/viewfly-vdom-adapter.ts"],"sourcesContent":["import { Component, CompositionState, makeError, VElement, ViewMount, VTextNode, merge, Adapter } from '@textbus/core'\nimport {\n ComponentSetup,\n createDynamicRef,\n DynamicRef,\n getCurrentInstance, Injector,\n jsx,\n JSXNode, onUnmounted,\n onUpdated, ReflectiveInjector,\n ViewFlyNode,\n} from '@viewfly/core'\nimport { DomAdapter } from '@textbus/platform-browser'\n\nconst adapterError = makeError('ViewflyDOMRenderer')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: DynamicRef<Element>\n}\n\nexport interface ViewflyAdapterComponents {\n [key: string]: ComponentSetup<ViewComponentProps<any>>\n}\n\nexport class ViewflyAdapter extends DomAdapter<ViewFlyNode, ViewFlyNode> {\n private components: ViewflyAdapterComponents = {}\n\n private componentRefs = new WeakMap<Component, DynamicRef<Element>>()\n\n constructor(components: ViewflyAdapterComponents,\n mount: ViewMount<ViewFlyNode, Element>\n ) {\n super({\n createCompositionNode(compositionState: CompositionState,\n updateNativeCompositionNode: (nativeNode: (Element | null)) => void): VElement {\n const ref = createDynamicRef<Element>(node => {\n updateNativeCompositionNode(node)\n return () => {\n updateNativeCompositionNode(null)\n }\n })\n return new VElement('span', {\n style: {\n textDecoration: 'underline'\n },\n ref\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 const ref = createDynamicRef<Element>(nativeNode => {\n update(nativeNode)\n return () => {\n update(null)\n }\n })\n if (typeof currentRef === 'function') {\n vEle.attrs.set('ref', [currentRef, ref])\n } else if (Array.isArray(currentRef)) {\n currentRef.push(ref)\n } else {\n vEle.attrs.set('ref', ref)\n }\n },\n componentRender: (component: Component<any>): ViewFlyNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let ref = this.componentRefs.get(component)\n if (!ref) {\n ref = createDynamicRef<Element>(rootNode => {\n this.componentRootElementCaches.set(component, rootNode)\n return () => {\n // 当组件移动层级位置到原位置之前并重新渲染后,由于时序的原因,再删除缓存会导致组件找不到对应视图节点\n if (this.componentRootElementCaches.get(component) === rootNode) {\n this.componentRootElementCaches.remove(component)\n }\n }\n })\n this.componentRefs.set(component, ref)\n }\n return jsx(comp, {\n component,\n rootRef: ref\n }, component.id)\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<JSXNode>): ViewFlyNode {\n let key: any\n const props = Array.from(vNode.attrs).reduce((a, b) => {\n const propName = b[0]\n if (propName === 'key') {\n key = b[1]\n return a\n }\n a[propName] = b[1]\n return a\n }, {} as Record<string, any>)\n if (vNode.classes.size) {\n props.class = 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 if (children.length) {\n props.children = children\n }\n return jsx(vNode.tagName, props, key)\n }\n }, mount)\n\n let isRoot = true\n Object.entries(components).forEach(([key, viewFlyComponent]) => {\n this.components[key] = (props: ViewComponentProps<Component>) => {\n const comp = getCurrentInstance()\n const textbusComponent = props.component\n const subscription = merge(textbusComponent.changeMarker.onChange,\n textbusComponent.changeMarker.onForceChange).subscribe(() => {\n if (textbusComponent.changeMarker.dirty) {\n comp.markAsDirtied()\n }\n })\n onUnmounted(() => {\n subscription.unsubscribe()\n })\n if (isRoot) {\n onUpdated(() => {\n this.onViewUpdated.next()\n })\n isRoot = false\n }\n onUpdated(() => {\n textbusComponent.changeMarker.rendered()\n if (!this.componentRootElementCaches.get(textbusComponent)) {\n // eslint-disable-next-line max-len\n throw adapterError(`Component \\`${textbusComponent.name}\\` is not bound to rootRef, you must bind rootRef to the root element node of the component view.`)\n }\n })\n return viewFlyComponent(props)\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: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n","import { NodeViewAdapter } from '@textbus/platform-node'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { Adapter, Component } from '@textbus/core'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { ViewflyAdapter } from './viewfly-adapter'\n\nexport class ViewflyVDomAdapter extends NodeViewAdapter {\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: ViewflyAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childInjector)\n }\n}\n"],"names":["adapterError","makeError","ViewflyAdapter","components","mount","_call_super","createCompositionNode","compositionState","updateNativeCompositionNode","ref","createDynamicRef","node","VElement","style","textDecoration","VTextNode","text","getParentNode","parentNode","getChildNodes","parentElement","Array","from","childNodes","isNativeElementNode","Element","getChildByIndex","index","getAndUpdateSlotRootNativeElement","vEle","update","currentRef","attrs","get","nativeNode","set","isArray","push","componentRender","component","comp","_assert_this_initialized","name","componentRefs","rootNode","componentRootElementCaches","remove","jsx","rootRef","id","vElementToViewElement","vNode","children","key","props","reduce","a","b","propName","classes","size","class","join","styles","length","tagName","WeakMap","isRoot","Object","entries","forEach","viewFlyComponent","getCurrentInstance","textbusComponent","subscription","merge","changeMarker","onChange","onForceChange","subscribe","dirty","markAsDirtied","onUnmounted","unsubscribe","onUpdated","onViewUpdated","next","rendered","render","rootComponent","injector","childInjector","ReflectiveInjector","provide","Adapter","useValue","DomAdapter","_get","_get_prototype_of","copy","document","execCommand","ViewflyVDomAdapter","NodeViewAdapter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAMA,eAAeC,cAAAA,CAAU,oBAAA,CAAA;AAWxB,IAAA,cAAMC,iBAAN,SAAA,WAAA,EAAA;AAAMA,IAAAA,WAAAA,CAAAA,cAAAA,EAAAA,WAAAA,CAAAA;aAAAA,cAAAA,CAKCC,UAAoC,EACpCC,KAAsC,EAAA;AANvCF,QAAAA,mBAAAA,CAAAA,IAAAA,EAAAA,cAAAA,CAAAA;;gBAQTG,aAAA,CAAA,IAAA,EARSH,cAAAA,EAAAA;AAQH,YAAA;AACJI,gBAAAA,qBAAAA,EAAAA,SAAAA,qBAAAA,CAAsBC,gBAAkC,EAClCC,2BAAmE,EAAA;oBACvF,IAAMC,GAAAA,GAAMC,wBAA0BC,SAAAA,IAAAA,EAAAA;wBACpCH,2BAAAA,CAA4BG,IAAAA,CAAAA;wBAC5B,OAAO,WAAA;4BACLH,2BAAAA,CAA4B,IAAA,CAAA;AAC9B,wBAAA,CAAA;AACF,oBAAA,CAAA,CAAA;oBACA,OAAO,IAAII,cAAS,MAAA,EAAQ;wBAC1BC,KAAAA,EAAO;4BACLC,cAAAA,EAAgB;AAClB,yBAAA;wBACAL,GAAAA,EAAAA;qBACF,EAAG;wBACD,IAAIM,cAAAA,CAAUR,iBAAiBS,IAAI;AACpC,qBAAA,CAAA;AACH,gBAAA,CAAA;gBACAC,aAAAA,EAAAA,SAAAA,cAAcN,IAAoB,EAAA;oBAChC,OAAQA,KAAcO,UAAU;AAClC,gBAAA,CAAA;gBACAC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;;;;;;;;;;;;;;;;;AClB7B,IAAA,kBAAMM,iBAAN,SAAA,eAAA,EAAA;AAAMA,IAAAA,SAAAA,CAAAA,kBAAAA,EAAAA,eAAAA,CAAAA;AAAAA,IAAAA,SAAAA,kBAAAA,GAAAA;AAAAA,QAAAA,iBAAAA,CAAAA,IAAAA,EAAAA,kBAAAA,CAAAA;AAAN,QAAA,OAAA,WAAA,CAAA,IAAA,EAAMA,kBAAAA,EAAAA,SAAAA,CAAAA;;AAAAA,IAAAA,aAAAA,CAAAA,kBAAAA,EAAAA;;YACFd,GAAAA,EAAAA,QAAAA;mBAAT,SAASA,MAAAA,CAAOC,aAAwB,EAAEC,QAAkB,EAAA;gBAC1D,IAAMC,aAAAA,GAAgB,IAAIC,yBAAAA,CAAmBF,QAAAA,EAAU;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,EAAS3F,cAAAA;AACT6F,wBAAAA,QAAAA,EAAU;AACZ;AAAE,iBAAA,CAAA;AACF,gBAAA,OAAO,IAAA,CAAA,iBAAA,CAZEO,kBAAAA,CAAAA,SAAAA,CAAAA,EAYId,QAAAA,EAAN,IAAK,aAAQC,aAAAA,EAAeE,aAAAA,CAAAA;AACrC,YAAA;;;AAbWW,IAAAA,OAAAA,kBAAAA;EAA2BC,4BAAAA;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/adapter-viewfly",
3
- "version": "5.2.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",
@@ -33,11 +33,11 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@tanbo/stream": "^1.2.7",
36
- "@viewfly/core": "^2.2.0 || >=3.0.0-alpha.0 <4",
37
- "@viewfly/platform-browser": "^2.2.0 || >=3.0.0-alpha.0 <4",
38
- "@textbus/platform-browser": "^5.2.2",
39
- "@textbus/core": "^5.2.2",
40
- "@textbus/platform-node": "^5.2.2"
36
+ "@viewfly/core": "^2.2.0 || >=3.0.0-alpha.3 <4",
37
+ "@viewfly/platform-browser": "^2.2.0 || >=3.0.0-alpha.3 <4",
38
+ "@textbus/core": "^5.2.4",
39
+ "@textbus/platform-node": "^5.2.4",
40
+ "@textbus/platform-browser": "^5.2.4"
41
41
  },
42
42
  "devDependencies": {
43
43
  "rimraf": "^3.0.2",