@textbus/adapter-vue 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 +322 -91
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +328 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -1,94 +1,325 @@
|
|
|
1
|
-
import { makeError
|
|
2
|
-
import {
|
|
3
|
-
import { DomAdapter
|
|
4
|
-
import { ReflectiveInjector
|
|
5
|
-
import { merge
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
vElementToViewElement(e, o) {
|
|
52
|
-
const t = {
|
|
53
|
-
...Array.from(e.attrs).reduce((n, r) => (n[r[0]] = r[1], n), {})
|
|
54
|
-
};
|
|
55
|
-
return e.classes.size && (t.class = Array.from(e.classes).join(" ")), e.styles && (t.style = Array.from(e.styles).reduce((n, r) => (n[r[0]] = r[1], n), {})), i(e.tagName, t, ...o);
|
|
56
|
-
}
|
|
57
|
-
}, a), Object.keys(c).forEach((e) => {
|
|
58
|
-
const o = c[e], t = o.setup, n = this;
|
|
59
|
-
o.setup = function(r, d, ...l) {
|
|
60
|
-
const s = r.component, p = E(), h = k(s.changeMarker.onChange, s.changeMarker.onForceChange).subscribe(() => {
|
|
61
|
-
s.changeMarker.dirty && p.proxy.$forceUpdate();
|
|
1
|
+
import { makeError, VElement, VTextNode, Adapter } from '@textbus/core';
|
|
2
|
+
import { getCurrentInstance, onMounted, onUpdated, onUnmounted, h, ref } from 'vue';
|
|
3
|
+
import { DomAdapter } from '@textbus/platform-browser';
|
|
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_without_holes(arr) {
|
|
13
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
14
|
+
}
|
|
15
|
+
function _assert_this_initialized(self) {
|
|
16
|
+
if (self === void 0) {
|
|
17
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
18
|
+
}
|
|
19
|
+
return self;
|
|
20
|
+
}
|
|
21
|
+
function _call_super(_this, derived, args) {
|
|
22
|
+
derived = _get_prototype_of(derived);
|
|
23
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
24
|
+
}
|
|
25
|
+
function _class_call_check(instance, Constructor) {
|
|
26
|
+
if (!(instance instanceof Constructor)) {
|
|
27
|
+
throw new TypeError("Cannot call a class as a function");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function _defineProperties(target, props) {
|
|
31
|
+
for(var i = 0; i < props.length; i++){
|
|
32
|
+
var descriptor = props[i];
|
|
33
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
34
|
+
descriptor.configurable = true;
|
|
35
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
36
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
40
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
41
|
+
return Constructor;
|
|
42
|
+
}
|
|
43
|
+
function _define_property(obj, key, value) {
|
|
44
|
+
if (key in obj) {
|
|
45
|
+
Object.defineProperty(obj, key, {
|
|
46
|
+
value: value,
|
|
47
|
+
enumerable: true,
|
|
48
|
+
configurable: true,
|
|
49
|
+
writable: true
|
|
62
50
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
} else {
|
|
52
|
+
obj[key] = value;
|
|
53
|
+
}
|
|
54
|
+
return obj;
|
|
55
|
+
}
|
|
56
|
+
function _get(target, property, receiver) {
|
|
57
|
+
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
58
|
+
_get = Reflect.get;
|
|
59
|
+
} else {
|
|
60
|
+
_get = function get(target, property, receiver) {
|
|
61
|
+
var base = _super_prop_base(target, property);
|
|
62
|
+
if (!base) return;
|
|
63
|
+
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
64
|
+
if (desc.get) {
|
|
65
|
+
return desc.get.call(receiver || target);
|
|
66
|
+
}
|
|
67
|
+
return desc.value;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return _get(target, property, receiver || target);
|
|
71
|
+
}
|
|
72
|
+
function _get_prototype_of(o) {
|
|
73
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
74
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
75
|
+
};
|
|
76
|
+
return _get_prototype_of(o);
|
|
77
|
+
}
|
|
78
|
+
function _inherits(subClass, superClass) {
|
|
79
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
80
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
81
|
+
}
|
|
82
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
83
|
+
constructor: {
|
|
84
|
+
value: subClass,
|
|
85
|
+
writable: true,
|
|
86
|
+
configurable: true
|
|
87
|
+
}
|
|
72
88
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
90
|
+
}
|
|
91
|
+
function _instanceof(left, right) {
|
|
92
|
+
"@swc/helpers - instanceof";
|
|
93
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
94
|
+
return !!right[Symbol.hasInstance](left);
|
|
95
|
+
} else {
|
|
96
|
+
return left instanceof right;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function _iterable_to_array(iter) {
|
|
100
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
101
|
+
}
|
|
102
|
+
function _non_iterable_spread() {
|
|
103
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
104
|
+
}
|
|
105
|
+
function _object_spread(target) {
|
|
106
|
+
for(var i = 1; i < arguments.length; i++){
|
|
107
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
108
|
+
var ownKeys = Object.keys(source);
|
|
109
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
110
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
111
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
ownKeys.forEach(function(key) {
|
|
115
|
+
_define_property(target, key, source[key]);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return target;
|
|
119
|
+
}
|
|
120
|
+
function _possible_constructor_return(self, call) {
|
|
121
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
122
|
+
return call;
|
|
123
|
+
}
|
|
124
|
+
return _assert_this_initialized(self);
|
|
125
|
+
}
|
|
126
|
+
function _set_prototype_of(o, p) {
|
|
127
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
128
|
+
o.__proto__ = p;
|
|
129
|
+
return o;
|
|
130
|
+
};
|
|
131
|
+
return _set_prototype_of(o, p);
|
|
132
|
+
}
|
|
133
|
+
function _super_prop_base(object, property) {
|
|
134
|
+
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
135
|
+
object = _get_prototype_of(object);
|
|
136
|
+
if (object === null) break;
|
|
137
|
+
}
|
|
138
|
+
return object;
|
|
139
|
+
}
|
|
140
|
+
function _to_consumable_array(arr) {
|
|
141
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
142
|
+
}
|
|
143
|
+
function _type_of(obj) {
|
|
144
|
+
"@swc/helpers - typeof";
|
|
145
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
146
|
+
}
|
|
147
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
148
|
+
if (!o) return;
|
|
149
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
150
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
151
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
152
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
153
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
154
|
+
}
|
|
155
|
+
function _is_native_reflect_construct() {
|
|
156
|
+
try {
|
|
157
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
158
|
+
} catch (_) {}
|
|
159
|
+
return (_is_native_reflect_construct = function() {
|
|
160
|
+
return !!result;
|
|
161
|
+
})();
|
|
162
|
+
}
|
|
163
|
+
var adapterError = makeError('VueAdapter');
|
|
164
|
+
var VueAdapter = /*#__PURE__*/ function(DomAdapter1) {
|
|
165
|
+
_inherits(VueAdapter, DomAdapter1);
|
|
166
|
+
function VueAdapter(components, mount) {
|
|
167
|
+
_class_call_check(this, VueAdapter);
|
|
168
|
+
var _this;
|
|
169
|
+
_this = _call_super(this, VueAdapter, [
|
|
170
|
+
{
|
|
171
|
+
createCompositionNode: function createCompositionNode(compositionState, updateNativeCompositionNode) {
|
|
172
|
+
return new VElement('span', {
|
|
173
|
+
style: {
|
|
174
|
+
textDecoration: 'underline'
|
|
175
|
+
},
|
|
176
|
+
ref: updateNativeCompositionNode
|
|
177
|
+
}, [
|
|
178
|
+
new VTextNode(compositionState.text)
|
|
179
|
+
]);
|
|
180
|
+
},
|
|
181
|
+
getParentNode: function getParentNode(node) {
|
|
182
|
+
return node.parentNode;
|
|
183
|
+
},
|
|
184
|
+
getChildNodes: function getChildNodes(parentElement) {
|
|
185
|
+
return Array.from(parentElement.childNodes);
|
|
186
|
+
},
|
|
187
|
+
isNativeElementNode: function isNativeElementNode(node) {
|
|
188
|
+
return _instanceof(node, Element);
|
|
189
|
+
},
|
|
190
|
+
getChildByIndex: function getChildByIndex(parentElement, index) {
|
|
191
|
+
return parentElement.childNodes[index];
|
|
192
|
+
},
|
|
193
|
+
getAndUpdateSlotRootNativeElement: function getAndUpdateSlotRootNativeElement(vElement, update) {
|
|
194
|
+
var currentRef = vElement.attrs.get('ref');
|
|
195
|
+
if (currentRef) {
|
|
196
|
+
vElement.attrs.set('ref', function(v) {
|
|
197
|
+
update(v);
|
|
198
|
+
if (typeof currentRef === 'function') {
|
|
199
|
+
currentRef(v);
|
|
200
|
+
} else if (!currentRef.value) {
|
|
201
|
+
currentRef.value = v;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
} else {
|
|
205
|
+
vElement.attrs.set('ref', update);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
componentRender: function componentRender(component) {
|
|
209
|
+
var comp = _assert_this_initialized(_this).components[component.name] || _assert_this_initialized(_this).components['*'];
|
|
210
|
+
if (comp) {
|
|
211
|
+
var rootRef = _assert_this_initialized(_this).componentRefs.get(component);
|
|
212
|
+
if (!rootRef) {
|
|
213
|
+
rootRef = ref();
|
|
214
|
+
_assert_this_initialized(_this).componentRefs.set(component, rootRef);
|
|
215
|
+
}
|
|
216
|
+
return h(comp, {
|
|
217
|
+
component: component,
|
|
218
|
+
rootRef: rootRef,
|
|
219
|
+
key: component.id
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
throw adapterError("cannot found view component `".concat(component.name, "`!"));
|
|
223
|
+
},
|
|
224
|
+
vElementToViewElement: function vElementToViewElement(vNode, children) {
|
|
225
|
+
var props = _object_spread({}, Array.from(vNode.attrs).reduce(function(a, b) {
|
|
226
|
+
a[b[0]] = b[1];
|
|
227
|
+
return a;
|
|
228
|
+
}, {}));
|
|
229
|
+
if (vNode.classes.size) {
|
|
230
|
+
props.class = Array.from(vNode.classes).join(' ');
|
|
231
|
+
}
|
|
232
|
+
if (vNode.styles) {
|
|
233
|
+
props.style = Array.from(vNode.styles).reduce(function(a, b) {
|
|
234
|
+
a[b[0]] = b[1];
|
|
235
|
+
return a;
|
|
236
|
+
}, {});
|
|
237
|
+
}
|
|
238
|
+
return h.apply(void 0, [
|
|
239
|
+
vNode.tagName,
|
|
240
|
+
props
|
|
241
|
+
].concat(_to_consumable_array(children)));
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
mount
|
|
245
|
+
]), // private compositionRef = ref<Element>()
|
|
246
|
+
_define_property(_this, "componentRefs", new WeakMap()), _define_property(_this, "components", {});
|
|
247
|
+
// watchEffect(() => {
|
|
248
|
+
// this.compositionNode = this.compositionRef.value || null
|
|
249
|
+
// })
|
|
250
|
+
Object.keys(components).forEach(function(key) {
|
|
251
|
+
var vueComponent = components[key];
|
|
252
|
+
var setup = vueComponent.setup;
|
|
253
|
+
var self = _this;
|
|
254
|
+
vueComponent.setup = function(props, context) {
|
|
255
|
+
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
256
|
+
args[_key - 2] = arguments[_key];
|
|
257
|
+
}
|
|
258
|
+
var component = props.component;
|
|
259
|
+
var vueInstance = getCurrentInstance();
|
|
260
|
+
var sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(function() {
|
|
261
|
+
if (component.changeMarker.dirty) {
|
|
262
|
+
vueInstance.proxy.$forceUpdate();
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
onMounted(function() {
|
|
266
|
+
if (props.rootRef.value) {
|
|
267
|
+
self.componentRootElementCaches.set(component, props.rootRef.value);
|
|
268
|
+
} else {
|
|
269
|
+
self.componentRootElementCaches.remove(component);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
onUpdated(function() {
|
|
273
|
+
var _self_componentRefs_get;
|
|
274
|
+
component.changeMarker.rendered();
|
|
275
|
+
self.onViewUpdated.next();
|
|
276
|
+
if (!_instanceof((_self_componentRefs_get = self.componentRefs.get(component)) === null || _self_componentRefs_get === void 0 ? void 0 : _self_componentRefs_get.value, Element)) {
|
|
277
|
+
// eslint-disable-next-line max-len
|
|
278
|
+
throw adapterError("Component `".concat(component.name, "` is not bound to rootRef, you must bind rootRef to the root element node of the component view."));
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
onUnmounted(function() {
|
|
282
|
+
sub.unsubscribe();
|
|
283
|
+
});
|
|
284
|
+
return setup.apply(void 0, [
|
|
285
|
+
props,
|
|
286
|
+
context
|
|
287
|
+
].concat(_to_consumable_array(args)));
|
|
288
|
+
};
|
|
289
|
+
_this.components[key] = vueComponent;
|
|
290
|
+
});
|
|
291
|
+
return _this;
|
|
292
|
+
}
|
|
293
|
+
_create_class(VueAdapter, [
|
|
294
|
+
{
|
|
295
|
+
key: "render",
|
|
296
|
+
value: function render(rootComponent, injector) {
|
|
297
|
+
var childrenInjector = new ReflectiveInjector(injector, [
|
|
298
|
+
{
|
|
299
|
+
provide: Adapter,
|
|
300
|
+
useValue: this
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
provide: DomAdapter,
|
|
304
|
+
useValue: this
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
provide: VueAdapter,
|
|
308
|
+
useValue: this
|
|
309
|
+
}
|
|
310
|
+
]);
|
|
311
|
+
return _get(_get_prototype_of(VueAdapter.prototype), "render", this).call(this, rootComponent, childrenInjector);
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
key: "copy",
|
|
316
|
+
value: function copy() {
|
|
317
|
+
document.execCommand('copy');
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
]);
|
|
321
|
+
return VueAdapter;
|
|
322
|
+
}(DomAdapter);
|
|
323
|
+
|
|
324
|
+
export { VueAdapter };
|
|
94
325
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/vue-adapter.ts"],"sourcesContent":["import { Adapter, Component, CompositionState, makeError, VElement, ViewMount, VTextNode } from '@textbus/core'\nimport { DefineComponent, getCurrentInstance, h, onMounted, onUnmounted, onUpdated, ref, Ref, VNode } from 'vue'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { merge } from '@tanbo/stream'\n\nconst adapterError = makeError('VueAdapter')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: Ref<Element | undefined>\n}\n\nexport interface VueAdapterComponents {\n [key: string]: DefineComponent<ViewComponentProps<any>>\n}\n\nexport class VueAdapter extends DomAdapter<VNode, VNode> {\n // private compositionRef = ref<Element>()\n private componentRefs = new WeakMap<Component, Ref<Element | undefined>>()\n private components: Record<string, DefineComponent<ViewComponentProps<any>>> = {}\n\n constructor(components: VueAdapterComponents,\n mount: ViewMount<VNode, 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: updateNativeCompositionNode\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(vElement: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vElement.attrs.get('ref')\n if (currentRef) {\n vElement.attrs.set('ref', (v: Element) => {\n update(v)\n if (typeof currentRef === 'function') {\n currentRef(v)\n } else if (!currentRef.value) {\n currentRef.value = v\n }\n })\n } else {\n vElement.attrs.set('ref', update)\n }\n },\n componentRender: (component: Component<any>): VNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let rootRef = this.componentRefs.get(component)\n if (!rootRef) {\n rootRef = ref<Element>()\n this.componentRefs.set(component, rootRef)\n }\n return h(comp, {\n component,\n rootRef,\n key: component.id\n })\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<string | VNode>): VNode {\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.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 return h(vNode.tagName, props, ...children)\n }\n }, mount)\n\n // watchEffect(() => {\n // this.compositionNode = this.compositionRef.value || null\n // })\n\n Object.keys(components).forEach(key => {\n const vueComponent = components[key]\n const setup = vueComponent.setup!\n const self = this\n vueComponent.setup = function (props: ViewComponentProps<Component>, context, ...args: any[]) {\n const component = props.component\n const vueInstance = getCurrentInstance()!\n const sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {\n if (component.changeMarker.dirty) {\n vueInstance.proxy!.$forceUpdate()\n }\n })\n onMounted(() => {\n if (props.rootRef.value) {\n self.componentRootElementCaches.set(component, props.rootRef.value)\n } else {\n self.componentRootElementCaches.remove(component)\n }\n })\n onUpdated(() => {\n component.changeMarker.rendered()\n self.onViewUpdated.next()\n\n if (!(self.componentRefs.get(component)?.value instanceof Element)) {\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 onUnmounted(() => {\n sub.unsubscribe()\n })\n return (setup as any)(props, context, ...args)\n }\n this.components[key] = vueComponent\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childrenInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this,\n }, {\n provide: VueAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childrenInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n"],"names":["adapterError","makeError","VueAdapter","DomAdapter","components","mount","compositionState","updateNativeCompositionNode","VElement","VTextNode","node","parentElement","index","vElement","update","currentRef","v","component","comp","rootRef","ref","h","vNode","children","props","a","b","key","vueComponent","setup","self","context","args","vueInstance","getCurrentInstance","sub","merge","onMounted","onUpdated","onUnmounted","rootComponent","injector","childrenInjector","ReflectiveInjector","Adapter"],"mappings":";;;;;AAMA,MAAMA,IAAeC,EAAU,YAAY;AAWpC,MAAMC,UAAmBC,EAAyB;AAAA;AAAA,EAE/C,oCAAoB,QAAA;AAAA,EACpB,aAAuE,CAAA;AAAA,EAE/E,YAAYC,GACAC,GAAkC;AAC5C,UAAM;AAAA,MACJ,uBAAuB,CAACC,GACAC,MACf,IAAIC,EAAS,QAAQ;AAAA,QAC1B,OAAO;AAAA,UACL,gBAAgB;AAAA,QAAA;AAAA,QAElB,KAAKD;AAAA,MAAA,GACJ;AAAA,QACD,IAAIE,EAAUH,EAAiB,IAAI;AAAA,MAAA,CACpC;AAAA,MAEH,cAAcI,GAAsC;AAClD,eAAQA,EAAc;AAAA,MACxB;AAAA,MACA,cAAcC,GAA+C;AAC3D,eAAO,MAAM,KAAKA,EAAc,UAAU;AAAA,MAC5C;AAAA,MACA,oBAAoBD,GAAuC;AACzD,eAAOA,aAAgB;AAAA,MACzB;AAAA,MACA,gBAAgBC,GAAeC,GAAO;AACpC,eAAOD,EAAc,WAAWC,CAAK;AAAA,MACvC;AAAA,MACA,kCAAkCC,GAAoBC,GAAmD;AACvG,cAAMC,IAAaF,EAAS,MAAM,IAAI,KAAK;AAC3C,QAAIE,IACFF,EAAS,MAAM,IAAI,OAAO,CAACG,MAAe;AACxC,UAAAF,EAAOE,CAAC,GACJ,OAAOD,KAAe,aACxBA,EAAWC,CAAC,IACFD,EAAW,UACrBA,EAAW,QAAQC;AAAA,QAEvB,CAAC,IAEDH,EAAS,MAAM,IAAI,OAAOC,CAAM;AAAA,MAEpC;AAAA,MACA,iBAAiB,CAACG,MAAqC;AACrD,cAAMC,IAAO,KAAK,WAAWD,EAAU,IAAI,KAAK,KAAK,WAAW,GAAG;AACnE,YAAIC,GAAM;AACR,cAAIC,IAAU,KAA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AQ,QAChBM,EAAK,2BAA2B,IAAIb,GAAWO,EAAM,QAAQ,KAAK,IAElEM,EAAK,2BAA2B,OAAOb,CAAS;AAAA,QAEpD,CAAC,GACDqB,EAAU,MAAM;AAId,cAHArB,EAAU,aAAa,SAAA,GACvBa,EAAK,cAAc,KAAA,GAEf,EAAEA,EAAK,cAAc,IAAIb,CAAS,GAAG,iBAAiB;AAExD,kBAAMjB,EAAa,eAAeiB,EAAU,IAAI,mGAAmG;AAAA,QAEvJ,CAAC,GACDsB,EAAY,MAAM;AAChB,UAAAJ,EAAI,YAAA;AAAA,QACN,CAAC,GACON,EAAcL,GAAOO,GAAS,GAAGC,CAAI;AAAA,MAC/C,GACA,KAAK,WAAWL,CAAG,IAAIC;AAAA,IACzB,CAAC;AAAA,EACH;AAAA,EAES,OAAOY,GAA0BC,GAAyC;AACjF,UAAMC,IAAmB,IAAIC,EAAmBF,GAAU,CAAC;AAAA,MACzD,SAASG;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAASzC;AAAA,MACT,UAAU;AAAA,IAAA,GACT;AAAA,MACD,SAASD;AAAA,MACT,UAAU;AAAA,IAAA,CACX,CAAC;AACF,WAAO,MAAM,OAAOsC,GAAeE,CAAgB;AAAA,EACrD;AAAA,EAES,OAAO;AACd,aAAS,YAAY,MAAM;AAAA,EAC7B;AACF;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/vue-adapter.ts"],"sourcesContent":["import { Adapter, Component, CompositionState, makeError, VElement, ViewMount, VTextNode } from '@textbus/core'\nimport { DefineComponent, getCurrentInstance, h, onMounted, onUnmounted, onUpdated, ref, Ref, VNode } from 'vue'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { merge } from '@tanbo/stream'\n\nconst adapterError = makeError('VueAdapter')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: Ref<Element | undefined>\n}\n\nexport interface VueAdapterComponents {\n [key: string]: DefineComponent<ViewComponentProps<any>>\n}\n\nexport class VueAdapter extends DomAdapter<VNode, VNode> {\n // private compositionRef = ref<Element>()\n private componentRefs = new WeakMap<Component, Ref<Element | undefined>>()\n private components: Record<string, DefineComponent<ViewComponentProps<any>>> = {}\n\n constructor(components: VueAdapterComponents,\n mount: ViewMount<VNode, 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: updateNativeCompositionNode\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(vElement: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vElement.attrs.get('ref')\n if (currentRef) {\n vElement.attrs.set('ref', (v: Element) => {\n update(v)\n if (typeof currentRef === 'function') {\n currentRef(v)\n } else if (!currentRef.value) {\n currentRef.value = v\n }\n })\n } else {\n vElement.attrs.set('ref', update)\n }\n },\n componentRender: (component: Component<any>): VNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let rootRef = this.componentRefs.get(component)\n if (!rootRef) {\n rootRef = ref<Element>()\n this.componentRefs.set(component, rootRef)\n }\n return h(comp, {\n component,\n rootRef,\n key: component.id\n })\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<string | VNode>): VNode {\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.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 return h(vNode.tagName, props, ...children)\n }\n }, mount)\n\n // watchEffect(() => {\n // this.compositionNode = this.compositionRef.value || null\n // })\n\n Object.keys(components).forEach(key => {\n const vueComponent = components[key]\n const setup = vueComponent.setup!\n const self = this\n vueComponent.setup = function (props: ViewComponentProps<Component>, context, ...args: any[]) {\n const component = props.component\n const vueInstance = getCurrentInstance()!\n const sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {\n if (component.changeMarker.dirty) {\n vueInstance.proxy!.$forceUpdate()\n }\n })\n onMounted(() => {\n if (props.rootRef.value) {\n self.componentRootElementCaches.set(component, props.rootRef.value)\n } else {\n self.componentRootElementCaches.remove(component)\n }\n })\n onUpdated(() => {\n component.changeMarker.rendered()\n self.onViewUpdated.next()\n\n if (!(self.componentRefs.get(component)?.value instanceof Element)) {\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 onUnmounted(() => {\n sub.unsubscribe()\n })\n return (setup as any)(props, context, ...args)\n }\n this.components[key] = vueComponent\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childrenInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this,\n }, {\n provide: VueAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childrenInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n"],"names":["adapterError","makeError","VueAdapter","components","mount","createCompositionNode","compositionState","updateNativeCompositionNode","VElement","style","textDecoration","ref","VTextNode","text","getParentNode","node","parentNode","getChildNodes","parentElement","Array","from","childNodes","isNativeElementNode","Element","getChildByIndex","index","getAndUpdateSlotRootNativeElement","vElement","update","currentRef","attrs","get","set","v","value","componentRender","component","comp","name","rootRef","componentRefs","h","key","id","vElementToViewElement","vNode","children","props","reduce","a","b","classes","size","class","join","styles","tagName","WeakMap","Object","keys","forEach","vueComponent","setup","self","context","args","vueInstance","getCurrentInstance","sub","merge","changeMarker","onChange","onForceChange","subscribe","dirty","proxy","$forceUpdate","onMounted","componentRootElementCaches","remove","onUpdated","rendered","onViewUpdated","next","onUnmounted","unsubscribe","render","rootComponent","injector","childrenInjector","ReflectiveInjector","provide","Adapter","useValue","DomAdapter","copy","document","execCommand"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAMA,eAAeC,SAAAA,CAAU,YAAA,CAAA;AAWxB,IAAA,UAAMC,iBAAN,SAAA,WAAA,EAAA;AAAMA,IAAAA,SAAAA,CAAAA,UAAAA,EAAAA,WAAAA,CAAAA;aAAAA,UAAAA,CAKCC,UAAgC,EAChCC,KAAgC,EAAA;AANjCF,QAAAA,iBAAAA,CAAAA,IAAAA,EAAAA,UAAAA,CAAAA;;gBAOT,WAAA,CAAA,IAAA,EAPSA,UAAAA,EAAAA;AAOH,YAAA;gBACJG,qBAAAA,EAAuB,SAAvBA,sBAAwBC,gBAAAA,EACAC,2BAAAA,EAAAA;oBACtB,OAAO,IAAIC,SAAS,MAAA,EAAQ;wBAC1BC,KAAAA,EAAO;4BACLC,cAAAA,EAAgB;AAClB,yBAAA;wBACAC,GAAAA,EAAKJ;qBACP,EAAG;wBACD,IAAIK,SAAAA,CAAUN,iBAAiBO,IAAI;AACpC,qBAAA,CAAA;AACH,gBAAA,CAAA;gBACAC,aAAAA,EAAAA,SAAAA,cAAcC,IAAoB,EAAA;oBAChC,OAAQA,KAAcC,UAAU;AAClC,gBAAA,CAAA;gBACAC,aAAAA,EAAAA,SAAAA,cAAcC,aAAsB,EAAA;AAClC,oBA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OAAAA,UAAAA;EAAmB4F,UAAAA;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,329 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const core = require('@textbus/core');
|
|
6
|
+
const vue = require('vue');
|
|
7
|
+
const platformBrowser = require('@textbus/platform-browser');
|
|
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_without_holes(arr) {
|
|
17
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
18
|
+
}
|
|
19
|
+
function _assert_this_initialized(self) {
|
|
20
|
+
if (self === void 0) {
|
|
21
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
22
|
+
}
|
|
23
|
+
return self;
|
|
24
|
+
}
|
|
25
|
+
function _call_super(_this, derived, args) {
|
|
26
|
+
derived = _get_prototype_of(derived);
|
|
27
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
28
|
+
}
|
|
29
|
+
function _class_call_check(instance, Constructor) {
|
|
30
|
+
if (!(instance instanceof Constructor)) {
|
|
31
|
+
throw new TypeError("Cannot call a class as a function");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function _defineProperties(target, props) {
|
|
35
|
+
for(var i = 0; i < props.length; i++){
|
|
36
|
+
var descriptor = props[i];
|
|
37
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
38
|
+
descriptor.configurable = true;
|
|
39
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
40
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
44
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
45
|
+
return Constructor;
|
|
46
|
+
}
|
|
47
|
+
function _define_property(obj, key, value) {
|
|
48
|
+
if (key in obj) {
|
|
49
|
+
Object.defineProperty(obj, key, {
|
|
50
|
+
value: value,
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
obj[key] = value;
|
|
57
|
+
}
|
|
58
|
+
return obj;
|
|
59
|
+
}
|
|
60
|
+
function _get(target, property, receiver) {
|
|
61
|
+
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
62
|
+
_get = Reflect.get;
|
|
63
|
+
} else {
|
|
64
|
+
_get = function get(target, property, receiver) {
|
|
65
|
+
var base = _super_prop_base(target, property);
|
|
66
|
+
if (!base) return;
|
|
67
|
+
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
68
|
+
if (desc.get) {
|
|
69
|
+
return desc.get.call(receiver || target);
|
|
70
|
+
}
|
|
71
|
+
return desc.value;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return _get(target, property, receiver || target);
|
|
75
|
+
}
|
|
76
|
+
function _get_prototype_of(o) {
|
|
77
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
78
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
79
|
+
};
|
|
80
|
+
return _get_prototype_of(o);
|
|
81
|
+
}
|
|
82
|
+
function _inherits(subClass, superClass) {
|
|
83
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
84
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
85
|
+
}
|
|
86
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
87
|
+
constructor: {
|
|
88
|
+
value: subClass,
|
|
89
|
+
writable: true,
|
|
90
|
+
configurable: true
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
94
|
+
}
|
|
95
|
+
function _instanceof(left, right) {
|
|
96
|
+
"@swc/helpers - instanceof";
|
|
97
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
98
|
+
return !!right[Symbol.hasInstance](left);
|
|
99
|
+
} else {
|
|
100
|
+
return left instanceof right;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function _iterable_to_array(iter) {
|
|
104
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
105
|
+
}
|
|
106
|
+
function _non_iterable_spread() {
|
|
107
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
108
|
+
}
|
|
109
|
+
function _object_spread(target) {
|
|
110
|
+
for(var i = 1; i < arguments.length; i++){
|
|
111
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
112
|
+
var ownKeys = Object.keys(source);
|
|
113
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
114
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
115
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
ownKeys.forEach(function(key) {
|
|
119
|
+
_define_property(target, key, source[key]);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return target;
|
|
123
|
+
}
|
|
124
|
+
function _possible_constructor_return(self, call) {
|
|
125
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
126
|
+
return call;
|
|
127
|
+
}
|
|
128
|
+
return _assert_this_initialized(self);
|
|
129
|
+
}
|
|
130
|
+
function _set_prototype_of(o, p) {
|
|
131
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
132
|
+
o.__proto__ = p;
|
|
133
|
+
return o;
|
|
134
|
+
};
|
|
135
|
+
return _set_prototype_of(o, p);
|
|
136
|
+
}
|
|
137
|
+
function _super_prop_base(object, property) {
|
|
138
|
+
while(!Object.prototype.hasOwnProperty.call(object, property)){
|
|
139
|
+
object = _get_prototype_of(object);
|
|
140
|
+
if (object === null) break;
|
|
141
|
+
}
|
|
142
|
+
return object;
|
|
143
|
+
}
|
|
144
|
+
function _to_consumable_array(arr) {
|
|
145
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
146
|
+
}
|
|
147
|
+
function _type_of(obj) {
|
|
148
|
+
"@swc/helpers - typeof";
|
|
149
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
150
|
+
}
|
|
151
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
152
|
+
if (!o) return;
|
|
153
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
154
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
155
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
156
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
157
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
158
|
+
}
|
|
159
|
+
function _is_native_reflect_construct() {
|
|
160
|
+
try {
|
|
161
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
162
|
+
} catch (_) {}
|
|
163
|
+
return (_is_native_reflect_construct = function() {
|
|
164
|
+
return !!result;
|
|
165
|
+
})();
|
|
166
|
+
}
|
|
167
|
+
var adapterError = core.makeError('VueAdapter');
|
|
168
|
+
var VueAdapter = /*#__PURE__*/ function(DomAdapter1) {
|
|
169
|
+
_inherits(VueAdapter, DomAdapter1);
|
|
170
|
+
function VueAdapter(components, mount) {
|
|
171
|
+
_class_call_check(this, VueAdapter);
|
|
172
|
+
var _this;
|
|
173
|
+
_this = _call_super(this, VueAdapter, [
|
|
174
|
+
{
|
|
175
|
+
createCompositionNode: function createCompositionNode(compositionState, updateNativeCompositionNode) {
|
|
176
|
+
return new core.VElement('span', {
|
|
177
|
+
style: {
|
|
178
|
+
textDecoration: 'underline'
|
|
179
|
+
},
|
|
180
|
+
ref: updateNativeCompositionNode
|
|
181
|
+
}, [
|
|
182
|
+
new core.VTextNode(compositionState.text)
|
|
183
|
+
]);
|
|
184
|
+
},
|
|
185
|
+
getParentNode: function getParentNode(node) {
|
|
186
|
+
return node.parentNode;
|
|
187
|
+
},
|
|
188
|
+
getChildNodes: function getChildNodes(parentElement) {
|
|
189
|
+
return Array.from(parentElement.childNodes);
|
|
190
|
+
},
|
|
191
|
+
isNativeElementNode: function isNativeElementNode(node) {
|
|
192
|
+
return _instanceof(node, Element);
|
|
193
|
+
},
|
|
194
|
+
getChildByIndex: function getChildByIndex(parentElement, index) {
|
|
195
|
+
return parentElement.childNodes[index];
|
|
196
|
+
},
|
|
197
|
+
getAndUpdateSlotRootNativeElement: function getAndUpdateSlotRootNativeElement(vElement, update) {
|
|
198
|
+
var currentRef = vElement.attrs.get('ref');
|
|
199
|
+
if (currentRef) {
|
|
200
|
+
vElement.attrs.set('ref', function(v) {
|
|
201
|
+
update(v);
|
|
202
|
+
if (typeof currentRef === 'function') {
|
|
203
|
+
currentRef(v);
|
|
204
|
+
} else if (!currentRef.value) {
|
|
205
|
+
currentRef.value = v;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
vElement.attrs.set('ref', update);
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
componentRender: function componentRender(component) {
|
|
213
|
+
var comp = _assert_this_initialized(_this).components[component.name] || _assert_this_initialized(_this).components['*'];
|
|
214
|
+
if (comp) {
|
|
215
|
+
var rootRef = _assert_this_initialized(_this).componentRefs.get(component);
|
|
216
|
+
if (!rootRef) {
|
|
217
|
+
rootRef = vue.ref();
|
|
218
|
+
_assert_this_initialized(_this).componentRefs.set(component, rootRef);
|
|
219
|
+
}
|
|
220
|
+
return vue.h(comp, {
|
|
221
|
+
component: component,
|
|
222
|
+
rootRef: rootRef,
|
|
223
|
+
key: component.id
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
throw adapterError("cannot found view component `".concat(component.name, "`!"));
|
|
227
|
+
},
|
|
228
|
+
vElementToViewElement: function vElementToViewElement(vNode, children) {
|
|
229
|
+
var props = _object_spread({}, Array.from(vNode.attrs).reduce(function(a, b) {
|
|
230
|
+
a[b[0]] = b[1];
|
|
231
|
+
return a;
|
|
232
|
+
}, {}));
|
|
233
|
+
if (vNode.classes.size) {
|
|
234
|
+
props.class = Array.from(vNode.classes).join(' ');
|
|
235
|
+
}
|
|
236
|
+
if (vNode.styles) {
|
|
237
|
+
props.style = Array.from(vNode.styles).reduce(function(a, b) {
|
|
238
|
+
a[b[0]] = b[1];
|
|
239
|
+
return a;
|
|
240
|
+
}, {});
|
|
241
|
+
}
|
|
242
|
+
return vue.h.apply(void 0, [
|
|
243
|
+
vNode.tagName,
|
|
244
|
+
props
|
|
245
|
+
].concat(_to_consumable_array(children)));
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
mount
|
|
249
|
+
]), // private compositionRef = ref<Element>()
|
|
250
|
+
_define_property(_this, "componentRefs", new WeakMap()), _define_property(_this, "components", {});
|
|
251
|
+
// watchEffect(() => {
|
|
252
|
+
// this.compositionNode = this.compositionRef.value || null
|
|
253
|
+
// })
|
|
254
|
+
Object.keys(components).forEach(function(key) {
|
|
255
|
+
var vueComponent = components[key];
|
|
256
|
+
var setup = vueComponent.setup;
|
|
257
|
+
var self = _this;
|
|
258
|
+
vueComponent.setup = function(props, context) {
|
|
259
|
+
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
260
|
+
args[_key - 2] = arguments[_key];
|
|
261
|
+
}
|
|
262
|
+
var component = props.component;
|
|
263
|
+
var vueInstance = vue.getCurrentInstance();
|
|
264
|
+
var sub = stream.merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(function() {
|
|
265
|
+
if (component.changeMarker.dirty) {
|
|
266
|
+
vueInstance.proxy.$forceUpdate();
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
vue.onMounted(function() {
|
|
270
|
+
if (props.rootRef.value) {
|
|
271
|
+
self.componentRootElementCaches.set(component, props.rootRef.value);
|
|
272
|
+
} else {
|
|
273
|
+
self.componentRootElementCaches.remove(component);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
vue.onUpdated(function() {
|
|
277
|
+
var _self_componentRefs_get;
|
|
278
|
+
component.changeMarker.rendered();
|
|
279
|
+
self.onViewUpdated.next();
|
|
280
|
+
if (!_instanceof((_self_componentRefs_get = self.componentRefs.get(component)) === null || _self_componentRefs_get === void 0 ? void 0 : _self_componentRefs_get.value, Element)) {
|
|
281
|
+
// eslint-disable-next-line max-len
|
|
282
|
+
throw adapterError("Component `".concat(component.name, "` is not bound to rootRef, you must bind rootRef to the root element node of the component view."));
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
vue.onUnmounted(function() {
|
|
286
|
+
sub.unsubscribe();
|
|
287
|
+
});
|
|
288
|
+
return setup.apply(void 0, [
|
|
289
|
+
props,
|
|
290
|
+
context
|
|
291
|
+
].concat(_to_consumable_array(args)));
|
|
292
|
+
};
|
|
293
|
+
_this.components[key] = vueComponent;
|
|
294
|
+
});
|
|
295
|
+
return _this;
|
|
296
|
+
}
|
|
297
|
+
_create_class(VueAdapter, [
|
|
298
|
+
{
|
|
299
|
+
key: "render",
|
|
300
|
+
value: function render(rootComponent, injector) {
|
|
301
|
+
var childrenInjector = new core$1.ReflectiveInjector(injector, [
|
|
302
|
+
{
|
|
303
|
+
provide: core.Adapter,
|
|
304
|
+
useValue: this
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
provide: platformBrowser.DomAdapter,
|
|
308
|
+
useValue: this
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
provide: VueAdapter,
|
|
312
|
+
useValue: this
|
|
313
|
+
}
|
|
314
|
+
]);
|
|
315
|
+
return _get(_get_prototype_of(VueAdapter.prototype), "render", this).call(this, rootComponent, childrenInjector);
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
key: "copy",
|
|
320
|
+
value: function copy() {
|
|
321
|
+
document.execCommand('copy');
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
]);
|
|
325
|
+
return VueAdapter;
|
|
326
|
+
}(platformBrowser.DomAdapter);
|
|
327
|
+
|
|
328
|
+
exports.VueAdapter = VueAdapter;
|
|
2
329
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/vue-adapter.ts"],"sourcesContent":["import { Adapter, Component, CompositionState, makeError, VElement, ViewMount, VTextNode } from '@textbus/core'\nimport { DefineComponent, getCurrentInstance, h, onMounted, onUnmounted, onUpdated, ref, Ref, VNode } from 'vue'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { merge } from '@tanbo/stream'\n\nconst adapterError = makeError('VueAdapter')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: Ref<Element | undefined>\n}\n\nexport interface VueAdapterComponents {\n [key: string]: DefineComponent<ViewComponentProps<any>>\n}\n\nexport class VueAdapter extends DomAdapter<VNode, VNode> {\n // private compositionRef = ref<Element>()\n private componentRefs = new WeakMap<Component, Ref<Element | undefined>>()\n private components: Record<string, DefineComponent<ViewComponentProps<any>>> = {}\n\n constructor(components: VueAdapterComponents,\n mount: ViewMount<VNode, 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: updateNativeCompositionNode\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(vElement: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vElement.attrs.get('ref')\n if (currentRef) {\n vElement.attrs.set('ref', (v: Element) => {\n update(v)\n if (typeof currentRef === 'function') {\n currentRef(v)\n } else if (!currentRef.value) {\n currentRef.value = v\n }\n })\n } else {\n vElement.attrs.set('ref', update)\n }\n },\n componentRender: (component: Component<any>): VNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let rootRef = this.componentRefs.get(component)\n if (!rootRef) {\n rootRef = ref<Element>()\n this.componentRefs.set(component, rootRef)\n }\n return h(comp, {\n component,\n rootRef,\n key: component.id\n })\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<string | VNode>): VNode {\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.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 return h(vNode.tagName, props, ...children)\n }\n }, mount)\n\n // watchEffect(() => {\n // this.compositionNode = this.compositionRef.value || null\n // })\n\n Object.keys(components).forEach(key => {\n const vueComponent = components[key]\n const setup = vueComponent.setup!\n const self = this\n vueComponent.setup = function (props: ViewComponentProps<Component>, context, ...args: any[]) {\n const component = props.component\n const vueInstance = getCurrentInstance()!\n const sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {\n if (component.changeMarker.dirty) {\n vueInstance.proxy!.$forceUpdate()\n }\n })\n onMounted(() => {\n if (props.rootRef.value) {\n self.componentRootElementCaches.set(component, props.rootRef.value)\n } else {\n self.componentRootElementCaches.remove(component)\n }\n })\n onUpdated(() => {\n component.changeMarker.rendered()\n self.onViewUpdated.next()\n\n if (!(self.componentRefs.get(component)?.value instanceof Element)) {\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 onUnmounted(() => {\n sub.unsubscribe()\n })\n return (setup as any)(props, context, ...args)\n }\n this.components[key] = vueComponent\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childrenInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this,\n }, {\n provide: VueAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childrenInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n"],"names":["adapterError","makeError","VueAdapter","DomAdapter","components","mount","compositionState","updateNativeCompositionNode","VElement","VTextNode","node","parentElement","index","vElement","update","currentRef","v","component","comp","rootRef","ref","h","vNode","children","props","a","b","key","vueComponent","setup","self","context","args","vueInstance","getCurrentInstance","sub","merge","onMounted","onUpdated","onUnmounted","rootComponent","injector","childrenInjector","ReflectiveInjector","Adapter"],"mappings":"+NAMMA,EAAeC,EAAAA,UAAU,YAAY,EAWpC,MAAMC,UAAmBC,EAAAA,UAAyB,CAE/C,kBAAoB,QACpB,WAAuE,CAAA,EAE/E,YAAYC,EACAC,EAAkC,CAC5C,MAAM,CACJ,sBAAuB,CAACC,EACAC,IACf,IAAIC,EAAAA,SAAS,O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ASG,EAAAA,QACT,SAAU,IAAA,EACT,CACD,QAASzC,EAAAA,WACT,SAAU,IAAA,EACT,CACD,QAASD,EACT,SAAU,IAAA,CACX,CAAC,EACF,OAAO,MAAM,OAAOsC,EAAeE,CAAgB,CACrD,CAES,MAAO,CACd,SAAS,YAAY,MAAM,CAC7B,CACF"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/vue-adapter.ts"],"sourcesContent":["import { Adapter, Component, CompositionState, makeError, VElement, ViewMount, VTextNode } from '@textbus/core'\nimport { DefineComponent, getCurrentInstance, h, onMounted, onUnmounted, onUpdated, ref, Ref, VNode } from 'vue'\nimport { DomAdapter } from '@textbus/platform-browser'\nimport { Injector, ReflectiveInjector } from '@viewfly/core'\nimport { merge } from '@tanbo/stream'\n\nconst adapterError = makeError('VueAdapter')\n\nexport interface ViewComponentProps<T extends Component> {\n component: T\n rootRef: Ref<Element | undefined>\n}\n\nexport interface VueAdapterComponents {\n [key: string]: DefineComponent<ViewComponentProps<any>>\n}\n\nexport class VueAdapter extends DomAdapter<VNode, VNode> {\n // private compositionRef = ref<Element>()\n private componentRefs = new WeakMap<Component, Ref<Element | undefined>>()\n private components: Record<string, DefineComponent<ViewComponentProps<any>>> = {}\n\n constructor(components: VueAdapterComponents,\n mount: ViewMount<VNode, 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: updateNativeCompositionNode\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(vElement: VElement, update: (nativeElement: (Element | null)) => void) {\n const currentRef = vElement.attrs.get('ref')\n if (currentRef) {\n vElement.attrs.set('ref', (v: Element) => {\n update(v)\n if (typeof currentRef === 'function') {\n currentRef(v)\n } else if (!currentRef.value) {\n currentRef.value = v\n }\n })\n } else {\n vElement.attrs.set('ref', update)\n }\n },\n componentRender: (component: Component<any>): VNode => {\n const comp = this.components[component.name] || this.components['*']\n if (comp) {\n let rootRef = this.componentRefs.get(component)\n if (!rootRef) {\n rootRef = ref<Element>()\n this.componentRefs.set(component, rootRef)\n }\n return h(comp, {\n component,\n rootRef,\n key: component.id\n })\n }\n throw adapterError(`cannot found view component \\`${component.name}\\`!`)\n },\n vElementToViewElement(vNode: VElement, children: Array<string | VNode>): VNode {\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.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 return h(vNode.tagName, props, ...children)\n }\n }, mount)\n\n // watchEffect(() => {\n // this.compositionNode = this.compositionRef.value || null\n // })\n\n Object.keys(components).forEach(key => {\n const vueComponent = components[key]\n const setup = vueComponent.setup!\n const self = this\n vueComponent.setup = function (props: ViewComponentProps<Component>, context, ...args: any[]) {\n const component = props.component\n const vueInstance = getCurrentInstance()!\n const sub = merge(component.changeMarker.onChange, component.changeMarker.onForceChange).subscribe(() => {\n if (component.changeMarker.dirty) {\n vueInstance.proxy!.$forceUpdate()\n }\n })\n onMounted(() => {\n if (props.rootRef.value) {\n self.componentRootElementCaches.set(component, props.rootRef.value)\n } else {\n self.componentRootElementCaches.remove(component)\n }\n })\n onUpdated(() => {\n component.changeMarker.rendered()\n self.onViewUpdated.next()\n\n if (!(self.componentRefs.get(component)?.value instanceof Element)) {\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 onUnmounted(() => {\n sub.unsubscribe()\n })\n return (setup as any)(props, context, ...args)\n }\n this.components[key] = vueComponent\n })\n }\n\n override render(rootComponent: Component, injector: Injector): void | (() => void) {\n const childrenInjector = new ReflectiveInjector(injector, [{\n provide: Adapter,\n useValue: this\n }, {\n provide: DomAdapter,\n useValue: this,\n }, {\n provide: VueAdapter,\n useValue: this\n }])\n return super.render(rootComponent, childrenInjector)\n }\n\n override copy() {\n document.execCommand('copy')\n }\n}\n"],"names":["adapterError","makeError","VueAdapter","components","mount","createCompositionNode","compositionState","updateNativeCompositionNode","VElement","style","textDecoration","ref","VTextNode","text","getParentNode","node","parentNode","getChildNodes","parentElement","Array","from","childNodes","isNativeElementNode","Element","getChildByIndex","index","getAndUpdateSlotRootNativeElement","vElement","update","currentRef","attrs","get","set","v","value","componentRender","component","comp","name","rootRef","componentRefs","h","key","id","vElementToViewElement","vNode","children","props","reduce","a","b","classes","size","class","join","styles","tagName","WeakMap","Object","keys","forEach","vueComponent","setup","self","context","args","vueInstance","getCurrentInstance","sub","merge","changeMarker","onChange","onForceChange","subscribe","dirty","proxy","$forceUpdate","onMounted","componentRootElementCaches","remove","onUpdated","rendered","onViewUpdated","next","onUnmounted","unsubscribe","render","rootComponent","injector","childrenInjector","ReflectiveInjector","provide","Adapter","useValue","DomAdapter","copy","document","execCommand"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAMA,eAAeC,cAAAA,CAAU,YAAA,CAAA;AAWxB,IAAA,UAAMC,iBAAN,SAAA,WAAA,EAAA;AAAMA,IAAAA,SAAAA,CAAAA,UAAAA,EAAAA,WAAAA,CAAAA;aAAAA,UAA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AAIC,yBAAAA,CAAmBF,QAAAA,EAAU;AAAC,oBAAA;wBACzDG,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,EAnIOzF,UAAAA;AAoIP2F,wBAAAA,QAAAA,EAAU;AACZ;AAAE,iBAAA,CAAA;AACF,gBAAA,OAAO,IAAA,CAAA,iBAAA,CAtIE3F,UAAAA,CAAAA,SAAAA,CAAAA,EAsIIoF,QAAAA,EAAN,IAAK,aAAQC,aAAAA,EAAeE,gBAAAA,CAAAA;AACrC,YAAA;;;YAESM,GAAAA,EAAAA,MAAAA;mBAAT,SAASA,IAAAA,GAAAA;AACPC,gBAAAA,QAAAA,CAASC,WAAW,CAAC,MAAA,CAAA;AACvB,YAAA;;;AA3IW/F,IAAAA,OAAAA,UAAAA;EAAmB4F,0BAAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@textbus/adapter-vue",
|
|
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",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@tanbo/stream": "^1.2.7",
|
|
36
|
-
"@viewfly/core": "^2.2.0 || >=3.0.0-alpha.
|
|
37
|
-
"@textbus/core": "^5.2.
|
|
38
|
-
"@textbus/platform-browser": "^5.2.
|
|
36
|
+
"@viewfly/core": "^2.2.0 || >=3.0.0-alpha.3 <4",
|
|
37
|
+
"@textbus/core": "^5.2.4",
|
|
38
|
+
"@textbus/platform-browser": "^5.2.4"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"vue": "^3.4.28"
|