vue-mount-plugin 3.0.0 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +297 -19
- package/dist/index.cjs +969 -0
- package/dist/index.d.ts +266 -21
- package/dist/index.es5.js +7767 -0
- package/dist/index.es5.min.js +1 -0
- package/dist/index.iife.js +1103 -0
- package/dist/index.iife.min.js +1 -0
- package/dist/index.mjs +896 -90
- package/package.json +64 -63
- package/dist/index.cjs.js +0 -122
- package/dist/index.esm-browser.js +0 -65
- package/dist/index.esm-browser.prod.js +0 -7
- package/dist/index.esm-bundler.js +0 -59
- package/dist/index.global.js +0 -245
- package/dist/index.global.prod.js +0 -8
|
@@ -0,0 +1,1103 @@
|
|
|
1
|
+
var _VueDemiGlobal = typeof globalThis !== 'undefined'
|
|
2
|
+
? globalThis
|
|
3
|
+
: typeof global !== 'undefined'
|
|
4
|
+
? global
|
|
5
|
+
: typeof self !== 'undefined'
|
|
6
|
+
? self
|
|
7
|
+
: this
|
|
8
|
+
var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
9
|
+
if (VueDemi.install) {
|
|
10
|
+
return VueDemi
|
|
11
|
+
}
|
|
12
|
+
if (!Vue) {
|
|
13
|
+
console.error('[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.')
|
|
14
|
+
return VueDemi
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Vue 2.7
|
|
18
|
+
if (Vue.version.slice(0, 4) === '2.7.') {
|
|
19
|
+
for (var key in Vue) {
|
|
20
|
+
VueDemi[key] = Vue[key]
|
|
21
|
+
}
|
|
22
|
+
VueDemi.isVue2 = true
|
|
23
|
+
VueDemi.isVue3 = false
|
|
24
|
+
VueDemi.install = function () {}
|
|
25
|
+
VueDemi.Vue = Vue
|
|
26
|
+
VueDemi.Vue2 = Vue
|
|
27
|
+
VueDemi.version = Vue.version
|
|
28
|
+
VueDemi.warn = Vue.util.warn
|
|
29
|
+
VueDemi.hasInjectionContext = function() {
|
|
30
|
+
return !!VueDemi.getCurrentInstance()
|
|
31
|
+
}
|
|
32
|
+
function createApp(rootComponent, rootProps) {
|
|
33
|
+
var vm
|
|
34
|
+
var provide = {}
|
|
35
|
+
var app = {
|
|
36
|
+
config: Vue.config,
|
|
37
|
+
use: Vue.use.bind(Vue),
|
|
38
|
+
mixin: Vue.mixin.bind(Vue),
|
|
39
|
+
component: Vue.component.bind(Vue),
|
|
40
|
+
provide: function (key, value) {
|
|
41
|
+
provide[key] = value
|
|
42
|
+
return this
|
|
43
|
+
},
|
|
44
|
+
directive: function (name, dir) {
|
|
45
|
+
if (dir) {
|
|
46
|
+
Vue.directive(name, dir)
|
|
47
|
+
return app
|
|
48
|
+
} else {
|
|
49
|
+
return Vue.directive(name)
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
mount: function (el, hydrating) {
|
|
53
|
+
if (!vm) {
|
|
54
|
+
vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) }))
|
|
55
|
+
vm.$mount(el, hydrating)
|
|
56
|
+
return vm
|
|
57
|
+
} else {
|
|
58
|
+
return vm
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
unmount: function () {
|
|
62
|
+
if (vm) {
|
|
63
|
+
vm.$destroy()
|
|
64
|
+
vm = undefined
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
return app
|
|
69
|
+
}
|
|
70
|
+
VueDemi.createApp = createApp
|
|
71
|
+
}
|
|
72
|
+
// Vue 2.6.x
|
|
73
|
+
else if (Vue.version.slice(0, 2) === '2.') {
|
|
74
|
+
if (VueCompositionAPI) {
|
|
75
|
+
for (var key in VueCompositionAPI) {
|
|
76
|
+
VueDemi[key] = VueCompositionAPI[key]
|
|
77
|
+
}
|
|
78
|
+
VueDemi.isVue2 = true
|
|
79
|
+
VueDemi.isVue3 = false
|
|
80
|
+
VueDemi.install = function () {}
|
|
81
|
+
VueDemi.Vue = Vue
|
|
82
|
+
VueDemi.Vue2 = Vue
|
|
83
|
+
VueDemi.version = Vue.version
|
|
84
|
+
VueDemi.hasInjectionContext = function() {
|
|
85
|
+
return !!VueDemi.getCurrentInstance()
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Vue 3
|
|
92
|
+
else if (Vue.version.slice(0, 2) === '3.') {
|
|
93
|
+
for (var key in Vue) {
|
|
94
|
+
VueDemi[key] = Vue[key]
|
|
95
|
+
}
|
|
96
|
+
VueDemi.isVue2 = false
|
|
97
|
+
VueDemi.isVue3 = true
|
|
98
|
+
VueDemi.install = function () {}
|
|
99
|
+
VueDemi.Vue = Vue
|
|
100
|
+
VueDemi.Vue2 = undefined
|
|
101
|
+
VueDemi.version = Vue.version
|
|
102
|
+
VueDemi.set = function (target, key, val) {
|
|
103
|
+
if (Array.isArray(target)) {
|
|
104
|
+
target.length = Math.max(target.length, key)
|
|
105
|
+
target.splice(key, 1, val)
|
|
106
|
+
return val
|
|
107
|
+
}
|
|
108
|
+
target[key] = val
|
|
109
|
+
return val
|
|
110
|
+
}
|
|
111
|
+
VueDemi.del = function (target, key) {
|
|
112
|
+
if (Array.isArray(target)) {
|
|
113
|
+
target.splice(key, 1)
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
delete target[key]
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
console.error('[vue-demi] Vue version ' + Vue.version + ' is unsupported.')
|
|
120
|
+
}
|
|
121
|
+
return VueDemi
|
|
122
|
+
})(
|
|
123
|
+
(_VueDemiGlobal.VueDemi = _VueDemiGlobal.VueDemi || (typeof VueDemi !== 'undefined' ? VueDemi : {})),
|
|
124
|
+
_VueDemiGlobal.Vue || (typeof Vue !== 'undefined' ? Vue : undefined),
|
|
125
|
+
_VueDemiGlobal.VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined)
|
|
126
|
+
);
|
|
127
|
+
;
|
|
128
|
+
/*!
|
|
129
|
+
* vue-mount-plugin v4.0.0
|
|
130
|
+
* A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
|
|
131
|
+
* (c) 2021-2026 saqqdy <https://github.com/saqqdy>
|
|
132
|
+
* Released under the MIT License.
|
|
133
|
+
*/
|
|
134
|
+
(function (exports, vueDemi) {
|
|
135
|
+
'use strict';
|
|
136
|
+
|
|
137
|
+
function _arrayLikeToArray(r, a) {
|
|
138
|
+
(null == a || a > r.length) && (a = r.length);
|
|
139
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
140
|
+
return n;
|
|
141
|
+
}
|
|
142
|
+
function _arrayWithHoles(r) {
|
|
143
|
+
if (Array.isArray(r)) return r;
|
|
144
|
+
}
|
|
145
|
+
function _arrayWithoutHoles(r) {
|
|
146
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
147
|
+
}
|
|
148
|
+
function _assertThisInitialized(e) {
|
|
149
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
150
|
+
return e;
|
|
151
|
+
}
|
|
152
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
153
|
+
try {
|
|
154
|
+
var i = n[a](c),
|
|
155
|
+
u = i.value;
|
|
156
|
+
} catch (n) {
|
|
157
|
+
return void e(n);
|
|
158
|
+
}
|
|
159
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
160
|
+
}
|
|
161
|
+
function _asyncToGenerator(n) {
|
|
162
|
+
return function () {
|
|
163
|
+
var t = this,
|
|
164
|
+
e = arguments;
|
|
165
|
+
return new Promise(function (r, o) {
|
|
166
|
+
var a = n.apply(t, e);
|
|
167
|
+
function _next(n) {
|
|
168
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
169
|
+
}
|
|
170
|
+
function _throw(n) {
|
|
171
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
172
|
+
}
|
|
173
|
+
_next(void 0);
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function _callSuper(t, o, e) {
|
|
178
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
179
|
+
}
|
|
180
|
+
function _classCallCheck(a, n) {
|
|
181
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
182
|
+
}
|
|
183
|
+
function _defineProperties(e, r) {
|
|
184
|
+
for (var t = 0; t < r.length; t++) {
|
|
185
|
+
var o = r[t];
|
|
186
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function _createClass(e, r, t) {
|
|
190
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
191
|
+
writable: false
|
|
192
|
+
}), e;
|
|
193
|
+
}
|
|
194
|
+
function _defineProperty(e, r, t) {
|
|
195
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
196
|
+
value: t,
|
|
197
|
+
enumerable: true,
|
|
198
|
+
configurable: true,
|
|
199
|
+
writable: true
|
|
200
|
+
}) : e[r] = t, e;
|
|
201
|
+
}
|
|
202
|
+
function _getPrototypeOf(t) {
|
|
203
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
204
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
205
|
+
}, _getPrototypeOf(t);
|
|
206
|
+
}
|
|
207
|
+
function _inherits(t, e) {
|
|
208
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
209
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
210
|
+
constructor: {
|
|
211
|
+
value: t,
|
|
212
|
+
writable: true,
|
|
213
|
+
configurable: true
|
|
214
|
+
}
|
|
215
|
+
}), Object.defineProperty(t, "prototype", {
|
|
216
|
+
writable: false
|
|
217
|
+
}), e && _setPrototypeOf(t, e);
|
|
218
|
+
}
|
|
219
|
+
function _isNativeReflectConstruct() {
|
|
220
|
+
try {
|
|
221
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
222
|
+
} catch (t) {}
|
|
223
|
+
return (_isNativeReflectConstruct = function () {
|
|
224
|
+
return !!t;
|
|
225
|
+
})();
|
|
226
|
+
}
|
|
227
|
+
function _iterableToArray(r) {
|
|
228
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
229
|
+
}
|
|
230
|
+
function _iterableToArrayLimit(r, l) {
|
|
231
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
232
|
+
if (null != t) {
|
|
233
|
+
var e,
|
|
234
|
+
n,
|
|
235
|
+
i,
|
|
236
|
+
u,
|
|
237
|
+
a = [],
|
|
238
|
+
f = true,
|
|
239
|
+
o = false;
|
|
240
|
+
try {
|
|
241
|
+
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
242
|
+
} catch (r) {
|
|
243
|
+
o = true, n = r;
|
|
244
|
+
} finally {
|
|
245
|
+
try {
|
|
246
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
247
|
+
} finally {
|
|
248
|
+
if (o) throw n;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return a;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function _nonIterableRest() {
|
|
255
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
256
|
+
}
|
|
257
|
+
function _nonIterableSpread() {
|
|
258
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
259
|
+
}
|
|
260
|
+
function ownKeys(e, r) {
|
|
261
|
+
var t = Object.keys(e);
|
|
262
|
+
if (Object.getOwnPropertySymbols) {
|
|
263
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
264
|
+
r && (o = o.filter(function (r) {
|
|
265
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
266
|
+
})), t.push.apply(t, o);
|
|
267
|
+
}
|
|
268
|
+
return t;
|
|
269
|
+
}
|
|
270
|
+
function _objectSpread2(e) {
|
|
271
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
272
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
273
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
274
|
+
_defineProperty(e, r, t[r]);
|
|
275
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
276
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return e;
|
|
280
|
+
}
|
|
281
|
+
function _possibleConstructorReturn(t, e) {
|
|
282
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
283
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
284
|
+
return _assertThisInitialized(t);
|
|
285
|
+
}
|
|
286
|
+
function _setPrototypeOf(t, e) {
|
|
287
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
288
|
+
return t.__proto__ = e, t;
|
|
289
|
+
}, _setPrototypeOf(t, e);
|
|
290
|
+
}
|
|
291
|
+
function _slicedToArray(r, e) {
|
|
292
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
293
|
+
}
|
|
294
|
+
function _toConsumableArray(r) {
|
|
295
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
296
|
+
}
|
|
297
|
+
function _toPrimitive(t, r) {
|
|
298
|
+
if ("object" != typeof t || !t) return t;
|
|
299
|
+
var e = t[Symbol.toPrimitive];
|
|
300
|
+
if (void 0 !== e) {
|
|
301
|
+
var i = e.call(t, r);
|
|
302
|
+
if ("object" != typeof i) return i;
|
|
303
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
304
|
+
}
|
|
305
|
+
return ("string" === r ? String : Number)(t);
|
|
306
|
+
}
|
|
307
|
+
function _toPropertyKey(t) {
|
|
308
|
+
var i = _toPrimitive(t, "string");
|
|
309
|
+
return "symbol" == typeof i ? i : i + "";
|
|
310
|
+
}
|
|
311
|
+
function _unsupportedIterableToArray(r, a) {
|
|
312
|
+
if (r) {
|
|
313
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
314
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
315
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
var singletonInstances = new Map();
|
|
320
|
+
var componentKeys = new WeakMap();
|
|
321
|
+
function getComponentKey(component) {
|
|
322
|
+
if (!componentKeys.has(component)) {
|
|
323
|
+
componentKeys.set(component, Symbol(component.name || 'anonymous'));
|
|
324
|
+
}
|
|
325
|
+
return componentKeys.get(component);
|
|
326
|
+
}
|
|
327
|
+
function getSingletonKey(component, singleton) {
|
|
328
|
+
if (singleton === false) return undefined;
|
|
329
|
+
if (typeof singleton === 'string') return singleton;
|
|
330
|
+
if (singleton === true) return getComponentKey(component);
|
|
331
|
+
return undefined;
|
|
332
|
+
}
|
|
333
|
+
function getSingleton(key) {
|
|
334
|
+
return singletonInstances.get(key);
|
|
335
|
+
}
|
|
336
|
+
function setSingleton(key, instance) {
|
|
337
|
+
var existing = singletonInstances.get(key);
|
|
338
|
+
if (existing && existing !== instance) {
|
|
339
|
+
existing.unmount();
|
|
340
|
+
}
|
|
341
|
+
singletonInstances.set(key, instance);
|
|
342
|
+
}
|
|
343
|
+
function removeSingleton(key) {
|
|
344
|
+
singletonInstances.delete(key);
|
|
345
|
+
}
|
|
346
|
+
function clearSingletons() {
|
|
347
|
+
singletonInstances.forEach(function (instance) {
|
|
348
|
+
return instance.unmount();
|
|
349
|
+
});
|
|
350
|
+
singletonInstances.clear();
|
|
351
|
+
}
|
|
352
|
+
function hasSingleton(key) {
|
|
353
|
+
return singletonInstances.has(key);
|
|
354
|
+
}
|
|
355
|
+
function getSingletonKeys() {
|
|
356
|
+
return Array.from(singletonInstances.keys());
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
var globalConfig = {
|
|
360
|
+
installed: false
|
|
361
|
+
};
|
|
362
|
+
function setGlobalConfig(config) {
|
|
363
|
+
Object.assign(globalConfig, config);
|
|
364
|
+
}
|
|
365
|
+
function getGlobalConfig() {
|
|
366
|
+
return _objectSpread2({}, globalConfig);
|
|
367
|
+
}
|
|
368
|
+
function resetGlobalConfig() {
|
|
369
|
+
Object.keys(globalConfig).forEach(function (key) {
|
|
370
|
+
delete globalConfig[key];
|
|
371
|
+
});
|
|
372
|
+
globalConfig.installed = false;
|
|
373
|
+
}
|
|
374
|
+
function mergeWithGlobalConfig(options) {
|
|
375
|
+
return _objectSpread2(_objectSpread2({}, globalConfig), options);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function isBrowser() {
|
|
379
|
+
return typeof document !== 'undefined';
|
|
380
|
+
}
|
|
381
|
+
function isNodeEnv() {
|
|
382
|
+
var _process$versions;
|
|
383
|
+
return typeof process !== 'undefined' && !!((_process$versions = process.versions) !== null && _process$versions !== void 0 && _process$versions.node);
|
|
384
|
+
}
|
|
385
|
+
function resolveTarget(target) {
|
|
386
|
+
if (!target) return null;
|
|
387
|
+
if (typeof target === 'string') {
|
|
388
|
+
if (!isBrowser()) return null;
|
|
389
|
+
return document.querySelector(target);
|
|
390
|
+
}
|
|
391
|
+
return target;
|
|
392
|
+
}
|
|
393
|
+
function createElement() {
|
|
394
|
+
var tagName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'div';
|
|
395
|
+
var attributes = arguments.length > 1 ? arguments[1] : undefined;
|
|
396
|
+
if (!isBrowser()) {
|
|
397
|
+
throw new TypeError('This plugin works in browser');
|
|
398
|
+
}
|
|
399
|
+
var el = document.createElement(tagName);
|
|
400
|
+
if (attributes) {
|
|
401
|
+
Object.entries(attributes).forEach(function (_ref) {
|
|
402
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
403
|
+
key = _ref2[0],
|
|
404
|
+
value = _ref2[1];
|
|
405
|
+
el.setAttribute(key, value);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
return el;
|
|
409
|
+
}
|
|
410
|
+
function appendTo(element, target) {
|
|
411
|
+
if (!isBrowser()) return;
|
|
412
|
+
var resolvedTarget = resolveTarget(target);
|
|
413
|
+
if (resolvedTarget) {
|
|
414
|
+
resolvedTarget.appendChild(element);
|
|
415
|
+
} else {
|
|
416
|
+
document.body.appendChild(element);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function removeElement(element) {
|
|
420
|
+
if (element.parentNode) {
|
|
421
|
+
element.parentNode.removeChild(element);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function isInDOM(element) {
|
|
425
|
+
return document.body.contains(element);
|
|
426
|
+
}
|
|
427
|
+
function setZIndex(element, zIndex) {
|
|
428
|
+
if (zIndex !== undefined) {
|
|
429
|
+
element.style.zIndex = String(zIndex);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
function addClass(element, className) {
|
|
433
|
+
if (className) {
|
|
434
|
+
var _element$classList;
|
|
435
|
+
(_element$classList = element.classList).add.apply(_element$classList, _toConsumableArray(className.split(/\s+/).filter(Boolean)));
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function removeClass(element, className) {
|
|
439
|
+
if (className) {
|
|
440
|
+
var _element$classList2;
|
|
441
|
+
(_element$classList2 = element.classList).remove.apply(_element$classList2, _toConsumableArray(className.split(/\s+/).filter(Boolean)));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
var EventEmitter = /*#__PURE__*/function () {
|
|
446
|
+
function EventEmitter() {
|
|
447
|
+
_classCallCheck(this, EventEmitter);
|
|
448
|
+
_defineProperty(this, "events", new Map());
|
|
449
|
+
}
|
|
450
|
+
return _createClass(EventEmitter, [{
|
|
451
|
+
key: "on",
|
|
452
|
+
value: function on(event, handler) {
|
|
453
|
+
if (!this.events.has(event)) {
|
|
454
|
+
this.events.set(event, new Set());
|
|
455
|
+
}
|
|
456
|
+
this.events.get(event).add(handler);
|
|
457
|
+
return this;
|
|
458
|
+
}
|
|
459
|
+
}, {
|
|
460
|
+
key: "off",
|
|
461
|
+
value: function off(event, handler) {
|
|
462
|
+
if (handler) {
|
|
463
|
+
var _this$events$get;
|
|
464
|
+
(_this$events$get = this.events.get(event)) === null || _this$events$get === void 0 || _this$events$get.delete(handler);
|
|
465
|
+
} else {
|
|
466
|
+
this.events.delete(event);
|
|
467
|
+
}
|
|
468
|
+
return this;
|
|
469
|
+
}
|
|
470
|
+
}, {
|
|
471
|
+
key: "emit",
|
|
472
|
+
value: function emit(event) {
|
|
473
|
+
var _this$events$get2;
|
|
474
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
475
|
+
args[_key - 1] = arguments[_key];
|
|
476
|
+
}
|
|
477
|
+
(_this$events$get2 = this.events.get(event)) === null || _this$events$get2 === void 0 || _this$events$get2.forEach(function (handler) {
|
|
478
|
+
try {
|
|
479
|
+
handler.apply(void 0, args);
|
|
480
|
+
} catch (error) {
|
|
481
|
+
console.error("Error in event handler for \"".concat(event, "\":"), error);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
}, {
|
|
487
|
+
key: "has",
|
|
488
|
+
value: function has(event) {
|
|
489
|
+
return this.events.has(event) && this.events.get(event).size > 0;
|
|
490
|
+
}
|
|
491
|
+
}, {
|
|
492
|
+
key: "clear",
|
|
493
|
+
value: function clear() {
|
|
494
|
+
this.events.clear();
|
|
495
|
+
}
|
|
496
|
+
}, {
|
|
497
|
+
key: "eventNames",
|
|
498
|
+
value: function eventNames() {
|
|
499
|
+
return Array.from(this.events.keys());
|
|
500
|
+
}
|
|
501
|
+
}]);
|
|
502
|
+
}();
|
|
503
|
+
var instanceCounter = 0;
|
|
504
|
+
function createInstanceId() {
|
|
505
|
+
return "mount-".concat(++instanceCounter, "-").concat(Date.now().toString(36));
|
|
506
|
+
}
|
|
507
|
+
function capitalize(str) {
|
|
508
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
509
|
+
}
|
|
510
|
+
function eventToPropName(event) {
|
|
511
|
+
return "on".concat(capitalize(event));
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
var instances = new Set();
|
|
515
|
+
var MountBase = /*#__PURE__*/function () {
|
|
516
|
+
function MountBase(component) {
|
|
517
|
+
var _this = this;
|
|
518
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
519
|
+
_classCallCheck(this, MountBase);
|
|
520
|
+
_defineProperty(this, "mounted", false);
|
|
521
|
+
_defineProperty(this, "el", null);
|
|
522
|
+
_defineProperty(this, "_eventEmitter", new EventEmitter());
|
|
523
|
+
_defineProperty(this, "_autoCreatedTarget", false);
|
|
524
|
+
_defineProperty(this, "_hidden", false);
|
|
525
|
+
_defineProperty(this, "_destroyed", false);
|
|
526
|
+
_defineProperty(this, "destroy", this.unmount);
|
|
527
|
+
_defineProperty(this, "remove", this.unmount);
|
|
528
|
+
this.id = createInstanceId();
|
|
529
|
+
this._component = component;
|
|
530
|
+
this.options = mergeWithGlobalConfig(options);
|
|
531
|
+
this._promise = new Promise(function (resolve, reject) {
|
|
532
|
+
_this._resolve = resolve;
|
|
533
|
+
_this._reject = reject;
|
|
534
|
+
});
|
|
535
|
+
this._singletonKey = getSingletonKey(component, options.singleton);
|
|
536
|
+
if (this._singletonKey) {
|
|
537
|
+
setSingleton(this._singletonKey, this);
|
|
538
|
+
}
|
|
539
|
+
instances.add(this);
|
|
540
|
+
}
|
|
541
|
+
return _createClass(MountBase, [{
|
|
542
|
+
key: "show",
|
|
543
|
+
value: function show() {
|
|
544
|
+
var _this$options$onBefor, _this$options, _this$options$onMount, _this$options2;
|
|
545
|
+
if (this.mounted && !this._hidden) return this;
|
|
546
|
+
(_this$options$onBefor = (_this$options = this.options).onBeforeMount) === null || _this$options$onBefor === void 0 || _this$options$onBefor.call(_this$options, this);
|
|
547
|
+
this._ensureElement();
|
|
548
|
+
this._mountVM();
|
|
549
|
+
if (this.options.zIndex && this.el) {
|
|
550
|
+
setZIndex(this.el, this.options.zIndex);
|
|
551
|
+
}
|
|
552
|
+
this.mounted = true;
|
|
553
|
+
this._hidden = false;
|
|
554
|
+
(_this$options$onMount = (_this$options2 = this.options).onMounted) === null || _this$options$onMount === void 0 || _this$options$onMount.call(_this$options2, this);
|
|
555
|
+
this.emit('show', this);
|
|
556
|
+
return this;
|
|
557
|
+
}
|
|
558
|
+
}, {
|
|
559
|
+
key: "hide",
|
|
560
|
+
value: function hide() {
|
|
561
|
+
if (!this.mounted || this._hidden) return this;
|
|
562
|
+
this.emit('beforeHide', this);
|
|
563
|
+
if (this.el && isInDOM(this.el)) {
|
|
564
|
+
removeElement(this.el);
|
|
565
|
+
}
|
|
566
|
+
this._hidden = true;
|
|
567
|
+
this.emit('hide', this);
|
|
568
|
+
return this;
|
|
569
|
+
}
|
|
570
|
+
}, {
|
|
571
|
+
key: "unmount",
|
|
572
|
+
value: function unmount() {
|
|
573
|
+
var _this$options$onUnmou, _this$options4;
|
|
574
|
+
if (this._destroyed) return;
|
|
575
|
+
this._destroyed = true;
|
|
576
|
+
if (this.mounted || this._hidden) {
|
|
577
|
+
var _this$options$onBefor2, _this$options3;
|
|
578
|
+
(_this$options$onBefor2 = (_this$options3 = this.options).onBeforeUnmount) === null || _this$options$onBefor2 === void 0 || _this$options$onBefor2.call(_this$options3, this);
|
|
579
|
+
}
|
|
580
|
+
this._eventEmitter.emit('beforeUnmount', this);
|
|
581
|
+
this._unmountVM();
|
|
582
|
+
if (this._autoCreatedTarget && this.el) {
|
|
583
|
+
removeElement(this.el);
|
|
584
|
+
}
|
|
585
|
+
this.mounted = false;
|
|
586
|
+
this._hidden = false;
|
|
587
|
+
this.el = null;
|
|
588
|
+
this.vm = null;
|
|
589
|
+
instances.delete(this);
|
|
590
|
+
if (this._singletonKey) {
|
|
591
|
+
removeSingleton(this._singletonKey);
|
|
592
|
+
}
|
|
593
|
+
(_this$options$onUnmou = (_this$options4 = this.options).onUnmounted) === null || _this$options$onUnmou === void 0 || _this$options$onUnmou.call(_this$options4, this);
|
|
594
|
+
this._eventEmitter.clear();
|
|
595
|
+
}
|
|
596
|
+
}, {
|
|
597
|
+
key: "setProps",
|
|
598
|
+
value: function setProps(props) {
|
|
599
|
+
this.options = _objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
600
|
+
props: _objectSpread2(_objectSpread2({}, this.options.props), props)
|
|
601
|
+
});
|
|
602
|
+
if (this.mounted) {
|
|
603
|
+
this._updateVM();
|
|
604
|
+
}
|
|
605
|
+
return this;
|
|
606
|
+
}
|
|
607
|
+
}, {
|
|
608
|
+
key: "on",
|
|
609
|
+
value: function on(event, handler) {
|
|
610
|
+
this._eventEmitter.on(event, handler);
|
|
611
|
+
return this;
|
|
612
|
+
}
|
|
613
|
+
}, {
|
|
614
|
+
key: "off",
|
|
615
|
+
value: function off(event, handler) {
|
|
616
|
+
this._eventEmitter.off(event, handler);
|
|
617
|
+
return this;
|
|
618
|
+
}
|
|
619
|
+
}, {
|
|
620
|
+
key: "emit",
|
|
621
|
+
value: function emit(event) {
|
|
622
|
+
var _this$_eventEmitter;
|
|
623
|
+
if (this._destroyed) return this;
|
|
624
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
625
|
+
args[_key - 1] = arguments[_key];
|
|
626
|
+
}
|
|
627
|
+
(_this$_eventEmitter = this._eventEmitter).emit.apply(_this$_eventEmitter, [event].concat(args));
|
|
628
|
+
return this;
|
|
629
|
+
}
|
|
630
|
+
}, {
|
|
631
|
+
key: "then",
|
|
632
|
+
value: function then(resolve) {
|
|
633
|
+
return this._promise.then(resolve);
|
|
634
|
+
}
|
|
635
|
+
}, {
|
|
636
|
+
key: "catch",
|
|
637
|
+
value: function _catch(reject) {
|
|
638
|
+
return this._promise.catch(reject);
|
|
639
|
+
}
|
|
640
|
+
}, {
|
|
641
|
+
key: "finally",
|
|
642
|
+
value: function _finally(onFinally) {
|
|
643
|
+
return this._promise.finally(onFinally);
|
|
644
|
+
}
|
|
645
|
+
}, {
|
|
646
|
+
key: "setTarget",
|
|
647
|
+
value: function setTarget(target) {
|
|
648
|
+
this.options.target = target;
|
|
649
|
+
return this;
|
|
650
|
+
}
|
|
651
|
+
}, {
|
|
652
|
+
key: "setHooks",
|
|
653
|
+
value: function setHooks(hooks) {
|
|
654
|
+
this.options = _objectSpread2(_objectSpread2({}, this.options), hooks);
|
|
655
|
+
return this;
|
|
656
|
+
}
|
|
657
|
+
}, {
|
|
658
|
+
key: "setSlots",
|
|
659
|
+
value: function setSlots(slots) {
|
|
660
|
+
this.options = _objectSpread2(_objectSpread2({}, this.options), {}, {
|
|
661
|
+
slots: _objectSpread2(_objectSpread2({}, this.options.slots), slots)
|
|
662
|
+
});
|
|
663
|
+
return this;
|
|
664
|
+
}
|
|
665
|
+
}, {
|
|
666
|
+
key: "_ensureElement",
|
|
667
|
+
value: function _ensureElement() {
|
|
668
|
+
if (this.el) return;
|
|
669
|
+
var target = resolveTarget(this.options.target);
|
|
670
|
+
if (target instanceof Element) {
|
|
671
|
+
this.el = target;
|
|
672
|
+
this._autoCreatedTarget = false;
|
|
673
|
+
} else {
|
|
674
|
+
this.el = createElement(this.options.tagName || 'div', {
|
|
675
|
+
'data-mount-id': this.id
|
|
676
|
+
});
|
|
677
|
+
this._autoCreatedTarget = true;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}, {
|
|
681
|
+
key: "_appendElementToDOM",
|
|
682
|
+
value: function _appendElementToDOM() {
|
|
683
|
+
if (!this.el) return;
|
|
684
|
+
if (this._autoCreatedTarget) {
|
|
685
|
+
appendTo(this.el, null);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}, {
|
|
689
|
+
key: "_resolvePromise",
|
|
690
|
+
value: function _resolvePromise(value) {
|
|
691
|
+
this._resolve(value);
|
|
692
|
+
}
|
|
693
|
+
}, {
|
|
694
|
+
key: "_rejectPromise",
|
|
695
|
+
value: function _rejectPromise(error) {
|
|
696
|
+
this._reject(error);
|
|
697
|
+
}
|
|
698
|
+
}, {
|
|
699
|
+
key: "_mergeListenersToProps",
|
|
700
|
+
value: function _mergeListenersToProps(listeners) {
|
|
701
|
+
var result = {};
|
|
702
|
+
Object.entries(listeners).forEach(function (_ref) {
|
|
703
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
704
|
+
event = _ref2[0],
|
|
705
|
+
handler = _ref2[1];
|
|
706
|
+
result["on".concat(capitalize(event))] = handler;
|
|
707
|
+
});
|
|
708
|
+
return result;
|
|
709
|
+
}
|
|
710
|
+
}], [{
|
|
711
|
+
key: "instances",
|
|
712
|
+
get: function get() {
|
|
713
|
+
return Array.from(instances);
|
|
714
|
+
}
|
|
715
|
+
}, {
|
|
716
|
+
key: "unmountAll",
|
|
717
|
+
value: function unmountAll() {
|
|
718
|
+
instances.forEach(function (instance) {
|
|
719
|
+
return instance.unmount();
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
}, {
|
|
723
|
+
key: "getById",
|
|
724
|
+
value: function getById(id) {
|
|
725
|
+
return Array.from(instances).find(function (instance) {
|
|
726
|
+
return instance.id === id;
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
}]);
|
|
730
|
+
}();
|
|
731
|
+
function getInstances() {
|
|
732
|
+
return Array.from(instances);
|
|
733
|
+
}
|
|
734
|
+
function unmountAll() {
|
|
735
|
+
MountBase.unmountAll();
|
|
736
|
+
}
|
|
737
|
+
function getInstanceById(id) {
|
|
738
|
+
return MountBase.getById(id);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function inheritVue2Context(parent, options) {
|
|
742
|
+
var context = options.context || {};
|
|
743
|
+
if (parent && (parent._isVue || parent.$options)) {
|
|
744
|
+
return _objectSpread2({
|
|
745
|
+
router: parent.$router || context.router,
|
|
746
|
+
store: parent.$store || context.store,
|
|
747
|
+
i18n: parent.$i18n || context.i18n,
|
|
748
|
+
route: parent.$route
|
|
749
|
+
}, context);
|
|
750
|
+
}
|
|
751
|
+
return context;
|
|
752
|
+
}
|
|
753
|
+
function inheritVue3Context(app, _options) {
|
|
754
|
+
if (app !== null && app !== void 0 && app._context) {
|
|
755
|
+
return {
|
|
756
|
+
appContext: app._context,
|
|
757
|
+
provides: app._context.provides
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
return {};
|
|
761
|
+
}
|
|
762
|
+
function getCurrentComponentContext(componentInstance) {
|
|
763
|
+
var _componentInstance$$;
|
|
764
|
+
if (!componentInstance) return {};
|
|
765
|
+
var context = {};
|
|
766
|
+
if (componentInstance.$router) context.router = componentInstance.$router;
|
|
767
|
+
if (componentInstance.$store) context.store = componentInstance.$store;
|
|
768
|
+
if (componentInstance.$i18n) context.i18n = componentInstance.$i18n;
|
|
769
|
+
if ((_componentInstance$$ = componentInstance.$) !== null && _componentInstance$$ !== void 0 && _componentInstance$$.appContext) {
|
|
770
|
+
context.appContext = componentInstance.$.appContext;
|
|
771
|
+
}
|
|
772
|
+
return context;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
var MountVue2 = /*#__PURE__*/function (_MountBase) {
|
|
776
|
+
function MountVue2(component) {
|
|
777
|
+
var _this;
|
|
778
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
779
|
+
_classCallCheck(this, MountVue2);
|
|
780
|
+
_this = _callSuper(this, MountVue2, [component, options]);
|
|
781
|
+
_defineProperty(_this, "vm", null);
|
|
782
|
+
_defineProperty(_this, "_vue2Instance", null);
|
|
783
|
+
if (!vueDemi.isVue2) {
|
|
784
|
+
throw new Error('MountVue2 can only be used with Vue 2');
|
|
785
|
+
}
|
|
786
|
+
_this._createVM();
|
|
787
|
+
return _this;
|
|
788
|
+
}
|
|
789
|
+
_inherits(MountVue2, _MountBase);
|
|
790
|
+
return _createClass(MountVue2, [{
|
|
791
|
+
key: "_createVM",
|
|
792
|
+
value: function _createVM() {
|
|
793
|
+
var VueConstructor = vueDemi.Vue2;
|
|
794
|
+
var _this$options = this.options,
|
|
795
|
+
props = _this$options.props,
|
|
796
|
+
parent = _this$options.parent,
|
|
797
|
+
listeners = _this$options.listeners,
|
|
798
|
+
on = _this$options.on;
|
|
799
|
+
var mergedListeners = _objectSpread2(_objectSpread2({}, listeners), on);
|
|
800
|
+
var context = inheritVue2Context(parent, this.options);
|
|
801
|
+
var componentOptions = this._component;
|
|
802
|
+
if (this._component.options) {
|
|
803
|
+
componentOptions = this._component.options;
|
|
804
|
+
}
|
|
805
|
+
var ComponentConstructor = VueConstructor.extend(componentOptions);
|
|
806
|
+
var instance = new ComponentConstructor({
|
|
807
|
+
propsData: props || {},
|
|
808
|
+
parent: parent,
|
|
809
|
+
router: context.router,
|
|
810
|
+
store: context.store,
|
|
811
|
+
i18n: context.i18n
|
|
812
|
+
});
|
|
813
|
+
Object.entries(mergedListeners).forEach(function (_ref) {
|
|
814
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
815
|
+
event = _ref2[0],
|
|
816
|
+
handler = _ref2[1];
|
|
817
|
+
if (Array.isArray(handler)) {
|
|
818
|
+
handler.forEach(function (h) {
|
|
819
|
+
return instance.$on(event, h);
|
|
820
|
+
});
|
|
821
|
+
} else {
|
|
822
|
+
instance.$on(event, handler);
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
instance._mountId = this.id;
|
|
826
|
+
this._vue2Instance = instance;
|
|
827
|
+
}
|
|
828
|
+
}, {
|
|
829
|
+
key: "_mountVM",
|
|
830
|
+
value: function _mountVM() {
|
|
831
|
+
if (!this._vue2Instance) return;
|
|
832
|
+
this._ensureElement();
|
|
833
|
+
this._appendElementToDOM();
|
|
834
|
+
this._vue2Instance.$mount(this.el);
|
|
835
|
+
if (this._vue2Instance.$el) {
|
|
836
|
+
this.el = this._vue2Instance.$el;
|
|
837
|
+
}
|
|
838
|
+
this.vm = this._vue2Instance;
|
|
839
|
+
this.mounted = true;
|
|
840
|
+
}
|
|
841
|
+
}, {
|
|
842
|
+
key: "_unmountVM",
|
|
843
|
+
value: function _unmountVM() {
|
|
844
|
+
if (this._vue2Instance) {
|
|
845
|
+
this._vue2Instance.$destroy();
|
|
846
|
+
this._vue2Instance = null;
|
|
847
|
+
}
|
|
848
|
+
this.vm = null;
|
|
849
|
+
this.mounted = false;
|
|
850
|
+
}
|
|
851
|
+
}, {
|
|
852
|
+
key: "_updateVM",
|
|
853
|
+
value: function _updateVM() {
|
|
854
|
+
if (this._vue2Instance && this.options.props) {
|
|
855
|
+
Object.assign(this._vue2Instance.$props, this.options.props);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}]);
|
|
859
|
+
}(MountBase);
|
|
860
|
+
|
|
861
|
+
var cachedRender;
|
|
862
|
+
function getRender() {
|
|
863
|
+
return _getRender.apply(this, arguments);
|
|
864
|
+
}
|
|
865
|
+
function _getRender() {
|
|
866
|
+
_getRender = _asyncToGenerator(function* () {
|
|
867
|
+
if (cachedRender) return cachedRender;
|
|
868
|
+
var vue = yield import('vue');
|
|
869
|
+
cachedRender = vue.render;
|
|
870
|
+
return cachedRender;
|
|
871
|
+
});
|
|
872
|
+
return _getRender.apply(this, arguments);
|
|
873
|
+
}
|
|
874
|
+
var MountVue3 = /*#__PURE__*/function (_MountBase) {
|
|
875
|
+
function MountVue3(component) {
|
|
876
|
+
var _this;
|
|
877
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
878
|
+
_classCallCheck(this, MountVue3);
|
|
879
|
+
_this = _callSuper(this, MountVue3, [component, options]);
|
|
880
|
+
_defineProperty(_this, "vm", null);
|
|
881
|
+
_defineProperty(_this, "_vNode", null);
|
|
882
|
+
if (vueDemi.isVue2) {
|
|
883
|
+
throw new Error('MountVue3 can only be used with Vue 3');
|
|
884
|
+
}
|
|
885
|
+
_this._createVM();
|
|
886
|
+
return _this;
|
|
887
|
+
}
|
|
888
|
+
_inherits(MountVue3, _MountBase);
|
|
889
|
+
return _createClass(MountVue3, [{
|
|
890
|
+
key: "_createVM",
|
|
891
|
+
value: function _createVM() {
|
|
892
|
+
var _this$options = this.options,
|
|
893
|
+
props = _this$options.props,
|
|
894
|
+
children = _this$options.children,
|
|
895
|
+
app = _this$options.app,
|
|
896
|
+
listeners = _this$options.listeners,
|
|
897
|
+
on = _this$options.on,
|
|
898
|
+
slots = _this$options.slots;
|
|
899
|
+
var mergedListeners = _objectSpread2(_objectSpread2({}, listeners), on);
|
|
900
|
+
var mergedProps = _objectSpread2(_objectSpread2({}, props), this._mergeListenersToProps(mergedListeners));
|
|
901
|
+
var mergedChildren = slots ? _objectSpread2(_objectSpread2({}, slots), children ? {
|
|
902
|
+
default: children
|
|
903
|
+
} : {}) : children;
|
|
904
|
+
var vNode = vueDemi.h(this._component, mergedProps, mergedChildren);
|
|
905
|
+
if (app !== null && app !== void 0 && app._context) {
|
|
906
|
+
vNode.appContext = app._context;
|
|
907
|
+
}
|
|
908
|
+
this._vNode = vNode;
|
|
909
|
+
}
|
|
910
|
+
}, {
|
|
911
|
+
key: "_mountVM",
|
|
912
|
+
value: function _mountVM() {
|
|
913
|
+
var _this2 = this;
|
|
914
|
+
if (!this._vNode) {
|
|
915
|
+
this._createVM();
|
|
916
|
+
}
|
|
917
|
+
this._ensureElement();
|
|
918
|
+
this._appendElementToDOM();
|
|
919
|
+
getRender().then(function (render) {
|
|
920
|
+
if (render && _this2._vNode && _this2.el) {
|
|
921
|
+
var _this2$_vNode$compone, _this2$_vNode$compone2;
|
|
922
|
+
render(_this2._vNode, _this2.el);
|
|
923
|
+
_this2.vm = (_this2$_vNode$compone = (_this2$_vNode$compone2 = _this2._vNode.component) === null || _this2$_vNode$compone2 === void 0 ? void 0 : _this2$_vNode$compone2.proxy) !== null && _this2$_vNode$compone !== void 0 ? _this2$_vNode$compone : null;
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
this.mounted = true;
|
|
927
|
+
}
|
|
928
|
+
}, {
|
|
929
|
+
key: "_unmountVM",
|
|
930
|
+
value: function _unmountVM() {
|
|
931
|
+
var _this3 = this;
|
|
932
|
+
if (this._vNode) {
|
|
933
|
+
getRender().then(function (render) {
|
|
934
|
+
if (render && _this3.el) {
|
|
935
|
+
render(null, _this3.el);
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
this._vNode = null;
|
|
939
|
+
}
|
|
940
|
+
this.vm = null;
|
|
941
|
+
this.mounted = false;
|
|
942
|
+
}
|
|
943
|
+
}, {
|
|
944
|
+
key: "_updateVM",
|
|
945
|
+
value: function _updateVM() {
|
|
946
|
+
var _this4 = this;
|
|
947
|
+
this._createVM();
|
|
948
|
+
if (this.mounted && this.el && this._vNode) {
|
|
949
|
+
getRender().then(function (render) {
|
|
950
|
+
if (render) {
|
|
951
|
+
var _this4$_vNode$compone, _this4$_vNode$compone2;
|
|
952
|
+
render(_this4._vNode, _this4.el);
|
|
953
|
+
_this4.vm = (_this4$_vNode$compone = (_this4$_vNode$compone2 = _this4._vNode.component) === null || _this4$_vNode$compone2 === void 0 ? void 0 : _this4$_vNode$compone2.proxy) !== null && _this4$_vNode$compone !== void 0 ? _this4$_vNode$compone : null;
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}]);
|
|
959
|
+
}(MountBase);
|
|
960
|
+
|
|
961
|
+
function useMount() {
|
|
962
|
+
var instances = vueDemi.ref([]);
|
|
963
|
+
var mount = function mount(component, options) {
|
|
964
|
+
var instance = createMount(component, options);
|
|
965
|
+
instances.value.push(instance);
|
|
966
|
+
return instance;
|
|
967
|
+
};
|
|
968
|
+
var unmount = function unmount(instance) {
|
|
969
|
+
instance.unmount();
|
|
970
|
+
instances.value = instances.value.filter(function (i) {
|
|
971
|
+
return i !== instance;
|
|
972
|
+
});
|
|
973
|
+
};
|
|
974
|
+
var unmountAll = function unmountAll() {
|
|
975
|
+
instances.value.forEach(function (instance) {
|
|
976
|
+
return instance.unmount();
|
|
977
|
+
});
|
|
978
|
+
instances.value = [];
|
|
979
|
+
};
|
|
980
|
+
var getById = function getById(id) {
|
|
981
|
+
return instances.value.find(function (instance) {
|
|
982
|
+
return instance.id === id;
|
|
983
|
+
});
|
|
984
|
+
};
|
|
985
|
+
var hasInstances = function hasInstances() {
|
|
986
|
+
return instances.value.length > 0;
|
|
987
|
+
};
|
|
988
|
+
var count = function count() {
|
|
989
|
+
return instances.value.length;
|
|
990
|
+
};
|
|
991
|
+
if (!vueDemi.isVue2) {
|
|
992
|
+
vueDemi.onUnmounted(unmountAll);
|
|
993
|
+
}
|
|
994
|
+
return {
|
|
995
|
+
instances: instances,
|
|
996
|
+
mount: mount,
|
|
997
|
+
unmount: unmount,
|
|
998
|
+
unmountAll: unmountAll,
|
|
999
|
+
getById: getById,
|
|
1000
|
+
hasInstances: hasInstances,
|
|
1001
|
+
count: count
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
function useSingleton() {
|
|
1005
|
+
var getOrCreate = function getOrCreate(key, component, options) {
|
|
1006
|
+
var existingInstances = useMount().instances.value;
|
|
1007
|
+
var existing = existingInstances.find(function (i) {
|
|
1008
|
+
return i.id === key || i.options.singleton === key;
|
|
1009
|
+
});
|
|
1010
|
+
if (existing) {
|
|
1011
|
+
return existing;
|
|
1012
|
+
}
|
|
1013
|
+
var instance = createMount(component, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1014
|
+
singleton: key
|
|
1015
|
+
}));
|
|
1016
|
+
return instance;
|
|
1017
|
+
};
|
|
1018
|
+
return {
|
|
1019
|
+
getOrCreate: getOrCreate
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
function createMount(component) {
|
|
1024
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1025
|
+
if (vueDemi.isVue2) {
|
|
1026
|
+
return new MountVue2(component, options);
|
|
1027
|
+
}
|
|
1028
|
+
return new MountVue3(component, options);
|
|
1029
|
+
}
|
|
1030
|
+
function mount(component) {
|
|
1031
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1032
|
+
var instance = createMount(component, options);
|
|
1033
|
+
return instance.show();
|
|
1034
|
+
}
|
|
1035
|
+
var MountPlugin = {
|
|
1036
|
+
install: function install(app) {
|
|
1037
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1038
|
+
setGlobalConfig(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1039
|
+
installed: true
|
|
1040
|
+
}));
|
|
1041
|
+
var name = options.name || '$mount';
|
|
1042
|
+
if (vueDemi.isVue2) {
|
|
1043
|
+
app.prototype[name] = mount;
|
|
1044
|
+
} else {
|
|
1045
|
+
app.config.globalProperties[name] = mount;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
function isMounted(id) {
|
|
1050
|
+
var _instance$mounted;
|
|
1051
|
+
var instance = getInstanceById(id);
|
|
1052
|
+
return (_instance$mounted = instance === null || instance === void 0 ? void 0 : instance.mounted) !== null && _instance$mounted !== void 0 ? _instance$mounted : false;
|
|
1053
|
+
}
|
|
1054
|
+
function getActiveInstanceIds() {
|
|
1055
|
+
return getInstances().map(function (instance) {
|
|
1056
|
+
return instance.id;
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
exports.EventEmitter = EventEmitter;
|
|
1061
|
+
exports.MountBase = MountBase;
|
|
1062
|
+
exports.MountPlugin = MountPlugin;
|
|
1063
|
+
exports.MountVue2 = MountVue2;
|
|
1064
|
+
exports.MountVue3 = MountVue3;
|
|
1065
|
+
exports.addClass = addClass;
|
|
1066
|
+
exports.appendTo = appendTo;
|
|
1067
|
+
exports.capitalize = capitalize;
|
|
1068
|
+
exports.clearSingletons = clearSingletons;
|
|
1069
|
+
exports.createElement = createElement;
|
|
1070
|
+
exports.createInstanceId = createInstanceId;
|
|
1071
|
+
exports.createMount = createMount;
|
|
1072
|
+
exports.eventToPropName = eventToPropName;
|
|
1073
|
+
exports.getActiveInstanceIds = getActiveInstanceIds;
|
|
1074
|
+
exports.getCurrentComponentContext = getCurrentComponentContext;
|
|
1075
|
+
exports.getGlobalConfig = getGlobalConfig;
|
|
1076
|
+
exports.getInstanceById = getInstanceById;
|
|
1077
|
+
exports.getInstances = getInstances;
|
|
1078
|
+
exports.getSingleton = getSingleton;
|
|
1079
|
+
exports.getSingletonKey = getSingletonKey;
|
|
1080
|
+
exports.getSingletonKeys = getSingletonKeys;
|
|
1081
|
+
exports.globalConfig = globalConfig;
|
|
1082
|
+
exports.hasSingleton = hasSingleton;
|
|
1083
|
+
exports.inheritVue2Context = inheritVue2Context;
|
|
1084
|
+
exports.inheritVue3Context = inheritVue3Context;
|
|
1085
|
+
exports.isBrowser = isBrowser;
|
|
1086
|
+
exports.isInDOM = isInDOM;
|
|
1087
|
+
exports.isMounted = isMounted;
|
|
1088
|
+
exports.isNodeEnv = isNodeEnv;
|
|
1089
|
+
exports.mergeWithGlobalConfig = mergeWithGlobalConfig;
|
|
1090
|
+
exports.mount = mount;
|
|
1091
|
+
exports.removeClass = removeClass;
|
|
1092
|
+
exports.removeElement = removeElement;
|
|
1093
|
+
exports.removeSingleton = removeSingleton;
|
|
1094
|
+
exports.resetGlobalConfig = resetGlobalConfig;
|
|
1095
|
+
exports.resolveTarget = resolveTarget;
|
|
1096
|
+
exports.setGlobalConfig = setGlobalConfig;
|
|
1097
|
+
exports.setSingleton = setSingleton;
|
|
1098
|
+
exports.setZIndex = setZIndex;
|
|
1099
|
+
exports.unmountAll = unmountAll;
|
|
1100
|
+
exports.useMount = useMount;
|
|
1101
|
+
exports.useSingleton = useSingleton;
|
|
1102
|
+
|
|
1103
|
+
})(this.VueMount = this.VueMount || {}, VueDemi);
|