command-center-v3-common 0.0.14 → 0.0.15
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/command-center-v3-common.js +49810 -0
- package/dist/command-center-v3-common.umd.cjs +134 -0
- package/dist/{types/common.d.ts → index.d.ts} +1 -1
- package/dist/style.css +1 -0
- package/package.json +1 -1
- package/dist/assets/time-utils-8BaVMoat.js +0 -11874
- package/dist/img/login-bg.jpg +0 -0
- package/dist/index.js +0 -62653
- package/dist/style/common.css +0 -50
- package/dist/style/index.js +0 -1
- package/dist/style/style.css +0 -6585
- package/dist/types/style.d.ts +0 -1
- package/dist/types/utils.d.ts +0 -136
- package/dist/utils/index.js +0 -4710
package/dist/utils/index.js
DELETED
@@ -1,4710 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3
|
-
var __publicField = (obj, key, value) => {
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
5
|
-
return value;
|
6
|
-
};
|
7
|
-
import { g as getDefaultExportFromCjs, d as defineComponent, h, l as logger } from "../assets/time-utils-8BaVMoat.js";
|
8
|
-
import { F, I, G, J, E, H, D, C, i, v, t, A, j, b, x, f, r, y, k, m, n, o, e, p, u, z, q, c, B, w, a, s } from "../assets/time-utils-8BaVMoat.js";
|
9
|
-
function _typeof$2(o2) {
|
10
|
-
"@babel/helpers - typeof";
|
11
|
-
return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o3) {
|
12
|
-
return typeof o3;
|
13
|
-
} : function(o3) {
|
14
|
-
return o3 && "function" == typeof Symbol && o3.constructor === Symbol && o3 !== Symbol.prototype ? "symbol" : typeof o3;
|
15
|
-
}, _typeof$2(o2);
|
16
|
-
}
|
17
|
-
function toPrimitive(t2, r2) {
|
18
|
-
if ("object" != _typeof$2(t2) || !t2)
|
19
|
-
return t2;
|
20
|
-
var e2 = t2[Symbol.toPrimitive];
|
21
|
-
if (void 0 !== e2) {
|
22
|
-
var i2 = e2.call(t2, r2 || "default");
|
23
|
-
if ("object" != _typeof$2(i2))
|
24
|
-
return i2;
|
25
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
26
|
-
}
|
27
|
-
return ("string" === r2 ? String : Number)(t2);
|
28
|
-
}
|
29
|
-
function toPropertyKey(t2) {
|
30
|
-
var i2 = toPrimitive(t2, "string");
|
31
|
-
return "symbol" == _typeof$2(i2) ? i2 : i2 + "";
|
32
|
-
}
|
33
|
-
function _defineProperty(e2, r2, t2) {
|
34
|
-
return (r2 = toPropertyKey(r2)) in e2 ? Object.defineProperty(e2, r2, {
|
35
|
-
value: t2,
|
36
|
-
enumerable: true,
|
37
|
-
configurable: true,
|
38
|
-
writable: true
|
39
|
-
}) : e2[r2] = t2, e2;
|
40
|
-
}
|
41
|
-
function asyncGeneratorStep$1(n2, t2, e2, r2, o2, a2, c2) {
|
42
|
-
try {
|
43
|
-
var i2 = n2[a2](c2), u2 = i2.value;
|
44
|
-
} catch (n3) {
|
45
|
-
return void e2(n3);
|
46
|
-
}
|
47
|
-
i2.done ? t2(u2) : Promise.resolve(u2).then(r2, o2);
|
48
|
-
}
|
49
|
-
function _asyncToGenerator$1(n2) {
|
50
|
-
return function() {
|
51
|
-
var t2 = this, e2 = arguments;
|
52
|
-
return new Promise(function(r2, o2) {
|
53
|
-
var a2 = n2.apply(t2, e2);
|
54
|
-
function _next(n3) {
|
55
|
-
asyncGeneratorStep$1(a2, r2, o2, _next, _throw, "next", n3);
|
56
|
-
}
|
57
|
-
function _throw(n3) {
|
58
|
-
asyncGeneratorStep$1(a2, r2, o2, _next, _throw, "throw", n3);
|
59
|
-
}
|
60
|
-
_next(void 0);
|
61
|
-
});
|
62
|
-
};
|
63
|
-
}
|
64
|
-
var regeneratorRuntime$1 = { exports: {} };
|
65
|
-
var _typeof$1 = { exports: {} };
|
66
|
-
(function(module) {
|
67
|
-
function _typeof2(o2) {
|
68
|
-
"@babel/helpers - typeof";
|
69
|
-
return module.exports = _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o3) {
|
70
|
-
return typeof o3;
|
71
|
-
} : function(o3) {
|
72
|
-
return o3 && "function" == typeof Symbol && o3.constructor === Symbol && o3 !== Symbol.prototype ? "symbol" : typeof o3;
|
73
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof2(o2);
|
74
|
-
}
|
75
|
-
module.exports = _typeof2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
76
|
-
})(_typeof$1);
|
77
|
-
var _typeofExports = _typeof$1.exports;
|
78
|
-
(function(module) {
|
79
|
-
var _typeof2 = _typeofExports["default"];
|
80
|
-
function _regeneratorRuntime2() {
|
81
|
-
module.exports = _regeneratorRuntime2 = function _regeneratorRuntime3() {
|
82
|
-
return e2;
|
83
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
84
|
-
var t2, e2 = {}, r2 = Object.prototype, n2 = r2.hasOwnProperty, o2 = Object.defineProperty || function(t3, e3, r3) {
|
85
|
-
t3[e3] = r3.value;
|
86
|
-
}, i2 = "function" == typeof Symbol ? Symbol : {}, a2 = i2.iterator || "@@iterator", c2 = i2.asyncIterator || "@@asyncIterator", u2 = i2.toStringTag || "@@toStringTag";
|
87
|
-
function define(t3, e3, r3) {
|
88
|
-
return Object.defineProperty(t3, e3, {
|
89
|
-
value: r3,
|
90
|
-
enumerable: true,
|
91
|
-
configurable: true,
|
92
|
-
writable: true
|
93
|
-
}), t3[e3];
|
94
|
-
}
|
95
|
-
try {
|
96
|
-
define({}, "");
|
97
|
-
} catch (t3) {
|
98
|
-
define = function define2(t4, e3, r3) {
|
99
|
-
return t4[e3] = r3;
|
100
|
-
};
|
101
|
-
}
|
102
|
-
function wrap(t3, e3, r3, n3) {
|
103
|
-
var i3 = e3 && e3.prototype instanceof Generator ? e3 : Generator, a3 = Object.create(i3.prototype), c3 = new Context(n3 || []);
|
104
|
-
return o2(a3, "_invoke", {
|
105
|
-
value: makeInvokeMethod(t3, r3, c3)
|
106
|
-
}), a3;
|
107
|
-
}
|
108
|
-
function tryCatch(t3, e3, r3) {
|
109
|
-
try {
|
110
|
-
return {
|
111
|
-
type: "normal",
|
112
|
-
arg: t3.call(e3, r3)
|
113
|
-
};
|
114
|
-
} catch (t4) {
|
115
|
-
return {
|
116
|
-
type: "throw",
|
117
|
-
arg: t4
|
118
|
-
};
|
119
|
-
}
|
120
|
-
}
|
121
|
-
e2.wrap = wrap;
|
122
|
-
var h2 = "suspendedStart", l = "suspendedYield", f2 = "executing", s2 = "completed", y2 = {};
|
123
|
-
function Generator() {
|
124
|
-
}
|
125
|
-
function GeneratorFunction() {
|
126
|
-
}
|
127
|
-
function GeneratorFunctionPrototype() {
|
128
|
-
}
|
129
|
-
var p2 = {};
|
130
|
-
define(p2, a2, function() {
|
131
|
-
return this;
|
132
|
-
});
|
133
|
-
var d = Object.getPrototypeOf, v2 = d && d(d(values([])));
|
134
|
-
v2 && v2 !== r2 && n2.call(v2, a2) && (p2 = v2);
|
135
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p2);
|
136
|
-
function defineIteratorMethods(t3) {
|
137
|
-
["next", "throw", "return"].forEach(function(e3) {
|
138
|
-
define(t3, e3, function(t4) {
|
139
|
-
return this._invoke(e3, t4);
|
140
|
-
});
|
141
|
-
});
|
142
|
-
}
|
143
|
-
function AsyncIterator(t3, e3) {
|
144
|
-
function invoke(r4, o3, i3, a3) {
|
145
|
-
var c3 = tryCatch(t3[r4], t3, o3);
|
146
|
-
if ("throw" !== c3.type) {
|
147
|
-
var u3 = c3.arg, h3 = u3.value;
|
148
|
-
return h3 && "object" == _typeof2(h3) && n2.call(h3, "__await") ? e3.resolve(h3.__await).then(function(t4) {
|
149
|
-
invoke("next", t4, i3, a3);
|
150
|
-
}, function(t4) {
|
151
|
-
invoke("throw", t4, i3, a3);
|
152
|
-
}) : e3.resolve(h3).then(function(t4) {
|
153
|
-
u3.value = t4, i3(u3);
|
154
|
-
}, function(t4) {
|
155
|
-
return invoke("throw", t4, i3, a3);
|
156
|
-
});
|
157
|
-
}
|
158
|
-
a3(c3.arg);
|
159
|
-
}
|
160
|
-
var r3;
|
161
|
-
o2(this, "_invoke", {
|
162
|
-
value: function value(t4, n3) {
|
163
|
-
function callInvokeWithMethodAndArg() {
|
164
|
-
return new e3(function(e4, r4) {
|
165
|
-
invoke(t4, n3, e4, r4);
|
166
|
-
});
|
167
|
-
}
|
168
|
-
return r3 = r3 ? r3.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
169
|
-
}
|
170
|
-
});
|
171
|
-
}
|
172
|
-
function makeInvokeMethod(e3, r3, n3) {
|
173
|
-
var o3 = h2;
|
174
|
-
return function(i3, a3) {
|
175
|
-
if (o3 === f2)
|
176
|
-
throw Error("Generator is already running");
|
177
|
-
if (o3 === s2) {
|
178
|
-
if ("throw" === i3)
|
179
|
-
throw a3;
|
180
|
-
return {
|
181
|
-
value: t2,
|
182
|
-
done: true
|
183
|
-
};
|
184
|
-
}
|
185
|
-
for (n3.method = i3, n3.arg = a3; ; ) {
|
186
|
-
var c3 = n3.delegate;
|
187
|
-
if (c3) {
|
188
|
-
var u3 = maybeInvokeDelegate(c3, n3);
|
189
|
-
if (u3) {
|
190
|
-
if (u3 === y2)
|
191
|
-
continue;
|
192
|
-
return u3;
|
193
|
-
}
|
194
|
-
}
|
195
|
-
if ("next" === n3.method)
|
196
|
-
n3.sent = n3._sent = n3.arg;
|
197
|
-
else if ("throw" === n3.method) {
|
198
|
-
if (o3 === h2)
|
199
|
-
throw o3 = s2, n3.arg;
|
200
|
-
n3.dispatchException(n3.arg);
|
201
|
-
} else
|
202
|
-
"return" === n3.method && n3.abrupt("return", n3.arg);
|
203
|
-
o3 = f2;
|
204
|
-
var p3 = tryCatch(e3, r3, n3);
|
205
|
-
if ("normal" === p3.type) {
|
206
|
-
if (o3 = n3.done ? s2 : l, p3.arg === y2)
|
207
|
-
continue;
|
208
|
-
return {
|
209
|
-
value: p3.arg,
|
210
|
-
done: n3.done
|
211
|
-
};
|
212
|
-
}
|
213
|
-
"throw" === p3.type && (o3 = s2, n3.method = "throw", n3.arg = p3.arg);
|
214
|
-
}
|
215
|
-
};
|
216
|
-
}
|
217
|
-
function maybeInvokeDelegate(e3, r3) {
|
218
|
-
var n3 = r3.method, o3 = e3.iterator[n3];
|
219
|
-
if (o3 === t2)
|
220
|
-
return r3.delegate = null, "throw" === n3 && e3.iterator["return"] && (r3.method = "return", r3.arg = t2, maybeInvokeDelegate(e3, r3), "throw" === r3.method) || "return" !== n3 && (r3.method = "throw", r3.arg = new TypeError("The iterator does not provide a '" + n3 + "' method")), y2;
|
221
|
-
var i3 = tryCatch(o3, e3.iterator, r3.arg);
|
222
|
-
if ("throw" === i3.type)
|
223
|
-
return r3.method = "throw", r3.arg = i3.arg, r3.delegate = null, y2;
|
224
|
-
var a3 = i3.arg;
|
225
|
-
return a3 ? a3.done ? (r3[e3.resultName] = a3.value, r3.next = e3.nextLoc, "return" !== r3.method && (r3.method = "next", r3.arg = t2), r3.delegate = null, y2) : a3 : (r3.method = "throw", r3.arg = new TypeError("iterator result is not an object"), r3.delegate = null, y2);
|
226
|
-
}
|
227
|
-
function pushTryEntry(t3) {
|
228
|
-
var e3 = {
|
229
|
-
tryLoc: t3[0]
|
230
|
-
};
|
231
|
-
1 in t3 && (e3.catchLoc = t3[1]), 2 in t3 && (e3.finallyLoc = t3[2], e3.afterLoc = t3[3]), this.tryEntries.push(e3);
|
232
|
-
}
|
233
|
-
function resetTryEntry(t3) {
|
234
|
-
var e3 = t3.completion || {};
|
235
|
-
e3.type = "normal", delete e3.arg, t3.completion = e3;
|
236
|
-
}
|
237
|
-
function Context(t3) {
|
238
|
-
this.tryEntries = [{
|
239
|
-
tryLoc: "root"
|
240
|
-
}], t3.forEach(pushTryEntry, this), this.reset(true);
|
241
|
-
}
|
242
|
-
function values(e3) {
|
243
|
-
if (e3 || "" === e3) {
|
244
|
-
var r3 = e3[a2];
|
245
|
-
if (r3)
|
246
|
-
return r3.call(e3);
|
247
|
-
if ("function" == typeof e3.next)
|
248
|
-
return e3;
|
249
|
-
if (!isNaN(e3.length)) {
|
250
|
-
var o3 = -1, i3 = function next() {
|
251
|
-
for (; ++o3 < e3.length; )
|
252
|
-
if (n2.call(e3, o3))
|
253
|
-
return next.value = e3[o3], next.done = false, next;
|
254
|
-
return next.value = t2, next.done = true, next;
|
255
|
-
};
|
256
|
-
return i3.next = i3;
|
257
|
-
}
|
258
|
-
}
|
259
|
-
throw new TypeError(_typeof2(e3) + " is not iterable");
|
260
|
-
}
|
261
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o2(g, "constructor", {
|
262
|
-
value: GeneratorFunctionPrototype,
|
263
|
-
configurable: true
|
264
|
-
}), o2(GeneratorFunctionPrototype, "constructor", {
|
265
|
-
value: GeneratorFunction,
|
266
|
-
configurable: true
|
267
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u2, "GeneratorFunction"), e2.isGeneratorFunction = function(t3) {
|
268
|
-
var e3 = "function" == typeof t3 && t3.constructor;
|
269
|
-
return !!e3 && (e3 === GeneratorFunction || "GeneratorFunction" === (e3.displayName || e3.name));
|
270
|
-
}, e2.mark = function(t3) {
|
271
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t3, GeneratorFunctionPrototype) : (t3.__proto__ = GeneratorFunctionPrototype, define(t3, u2, "GeneratorFunction")), t3.prototype = Object.create(g), t3;
|
272
|
-
}, e2.awrap = function(t3) {
|
273
|
-
return {
|
274
|
-
__await: t3
|
275
|
-
};
|
276
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c2, function() {
|
277
|
-
return this;
|
278
|
-
}), e2.AsyncIterator = AsyncIterator, e2.async = function(t3, r3, n3, o3, i3) {
|
279
|
-
void 0 === i3 && (i3 = Promise);
|
280
|
-
var a3 = new AsyncIterator(wrap(t3, r3, n3, o3), i3);
|
281
|
-
return e2.isGeneratorFunction(r3) ? a3 : a3.next().then(function(t4) {
|
282
|
-
return t4.done ? t4.value : a3.next();
|
283
|
-
});
|
284
|
-
}, defineIteratorMethods(g), define(g, u2, "Generator"), define(g, a2, function() {
|
285
|
-
return this;
|
286
|
-
}), define(g, "toString", function() {
|
287
|
-
return "[object Generator]";
|
288
|
-
}), e2.keys = function(t3) {
|
289
|
-
var e3 = Object(t3), r3 = [];
|
290
|
-
for (var n3 in e3)
|
291
|
-
r3.push(n3);
|
292
|
-
return r3.reverse(), function next() {
|
293
|
-
for (; r3.length; ) {
|
294
|
-
var t4 = r3.pop();
|
295
|
-
if (t4 in e3)
|
296
|
-
return next.value = t4, next.done = false, next;
|
297
|
-
}
|
298
|
-
return next.done = true, next;
|
299
|
-
};
|
300
|
-
}, e2.values = values, Context.prototype = {
|
301
|
-
constructor: Context,
|
302
|
-
reset: function reset(e3) {
|
303
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t2, this.done = false, this.delegate = null, this.method = "next", this.arg = t2, this.tryEntries.forEach(resetTryEntry), !e3)
|
304
|
-
for (var r3 in this)
|
305
|
-
"t" === r3.charAt(0) && n2.call(this, r3) && !isNaN(+r3.slice(1)) && (this[r3] = t2);
|
306
|
-
},
|
307
|
-
stop: function stop() {
|
308
|
-
this.done = true;
|
309
|
-
var t3 = this.tryEntries[0].completion;
|
310
|
-
if ("throw" === t3.type)
|
311
|
-
throw t3.arg;
|
312
|
-
return this.rval;
|
313
|
-
},
|
314
|
-
dispatchException: function dispatchException(e3) {
|
315
|
-
if (this.done)
|
316
|
-
throw e3;
|
317
|
-
var r3 = this;
|
318
|
-
function handle(n3, o4) {
|
319
|
-
return a3.type = "throw", a3.arg = e3, r3.next = n3, o4 && (r3.method = "next", r3.arg = t2), !!o4;
|
320
|
-
}
|
321
|
-
for (var o3 = this.tryEntries.length - 1; o3 >= 0; --o3) {
|
322
|
-
var i3 = this.tryEntries[o3], a3 = i3.completion;
|
323
|
-
if ("root" === i3.tryLoc)
|
324
|
-
return handle("end");
|
325
|
-
if (i3.tryLoc <= this.prev) {
|
326
|
-
var c3 = n2.call(i3, "catchLoc"), u3 = n2.call(i3, "finallyLoc");
|
327
|
-
if (c3 && u3) {
|
328
|
-
if (this.prev < i3.catchLoc)
|
329
|
-
return handle(i3.catchLoc, true);
|
330
|
-
if (this.prev < i3.finallyLoc)
|
331
|
-
return handle(i3.finallyLoc);
|
332
|
-
} else if (c3) {
|
333
|
-
if (this.prev < i3.catchLoc)
|
334
|
-
return handle(i3.catchLoc, true);
|
335
|
-
} else {
|
336
|
-
if (!u3)
|
337
|
-
throw Error("try statement without catch or finally");
|
338
|
-
if (this.prev < i3.finallyLoc)
|
339
|
-
return handle(i3.finallyLoc);
|
340
|
-
}
|
341
|
-
}
|
342
|
-
}
|
343
|
-
},
|
344
|
-
abrupt: function abrupt(t3, e3) {
|
345
|
-
for (var r3 = this.tryEntries.length - 1; r3 >= 0; --r3) {
|
346
|
-
var o3 = this.tryEntries[r3];
|
347
|
-
if (o3.tryLoc <= this.prev && n2.call(o3, "finallyLoc") && this.prev < o3.finallyLoc) {
|
348
|
-
var i3 = o3;
|
349
|
-
break;
|
350
|
-
}
|
351
|
-
}
|
352
|
-
i3 && ("break" === t3 || "continue" === t3) && i3.tryLoc <= e3 && e3 <= i3.finallyLoc && (i3 = null);
|
353
|
-
var a3 = i3 ? i3.completion : {};
|
354
|
-
return a3.type = t3, a3.arg = e3, i3 ? (this.method = "next", this.next = i3.finallyLoc, y2) : this.complete(a3);
|
355
|
-
},
|
356
|
-
complete: function complete(t3, e3) {
|
357
|
-
if ("throw" === t3.type)
|
358
|
-
throw t3.arg;
|
359
|
-
return "break" === t3.type || "continue" === t3.type ? this.next = t3.arg : "return" === t3.type ? (this.rval = this.arg = t3.arg, this.method = "return", this.next = "end") : "normal" === t3.type && e3 && (this.next = e3), y2;
|
360
|
-
},
|
361
|
-
finish: function finish(t3) {
|
362
|
-
for (var e3 = this.tryEntries.length - 1; e3 >= 0; --e3) {
|
363
|
-
var r3 = this.tryEntries[e3];
|
364
|
-
if (r3.finallyLoc === t3)
|
365
|
-
return this.complete(r3.completion, r3.afterLoc), resetTryEntry(r3), y2;
|
366
|
-
}
|
367
|
-
},
|
368
|
-
"catch": function _catch(t3) {
|
369
|
-
for (var e3 = this.tryEntries.length - 1; e3 >= 0; --e3) {
|
370
|
-
var r3 = this.tryEntries[e3];
|
371
|
-
if (r3.tryLoc === t3) {
|
372
|
-
var n3 = r3.completion;
|
373
|
-
if ("throw" === n3.type) {
|
374
|
-
var o3 = n3.arg;
|
375
|
-
resetTryEntry(r3);
|
376
|
-
}
|
377
|
-
return o3;
|
378
|
-
}
|
379
|
-
}
|
380
|
-
throw Error("illegal catch attempt");
|
381
|
-
},
|
382
|
-
delegateYield: function delegateYield(e3, r3, n3) {
|
383
|
-
return this.delegate = {
|
384
|
-
iterator: values(e3),
|
385
|
-
resultName: r3,
|
386
|
-
nextLoc: n3
|
387
|
-
}, "next" === this.method && (this.arg = t2), y2;
|
388
|
-
}
|
389
|
-
}, e2;
|
390
|
-
}
|
391
|
-
module.exports = _regeneratorRuntime2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
392
|
-
})(regeneratorRuntime$1);
|
393
|
-
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
394
|
-
var runtime = regeneratorRuntimeExports();
|
395
|
-
var regenerator = runtime;
|
396
|
-
try {
|
397
|
-
regeneratorRuntime = runtime;
|
398
|
-
} catch (accidentalStrictMode) {
|
399
|
-
if (typeof globalThis === "object") {
|
400
|
-
globalThis.regeneratorRuntime = runtime;
|
401
|
-
} else {
|
402
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
403
|
-
}
|
404
|
-
}
|
405
|
-
const _regeneratorRuntime$1 = /* @__PURE__ */ getDefaultExportFromCjs(regenerator);
|
406
|
-
function _arrayWithHoles(r2) {
|
407
|
-
if (Array.isArray(r2))
|
408
|
-
return r2;
|
409
|
-
}
|
410
|
-
function _iterableToArrayLimit(r2, l) {
|
411
|
-
var t2 = null == r2 ? null : "undefined" != typeof Symbol && r2[Symbol.iterator] || r2["@@iterator"];
|
412
|
-
if (null != t2) {
|
413
|
-
var e2, n2, i2, u2, a2 = [], f2 = true, o2 = false;
|
414
|
-
try {
|
415
|
-
if (i2 = (t2 = t2.call(r2)).next, 0 === l) {
|
416
|
-
if (Object(t2) !== t2)
|
417
|
-
return;
|
418
|
-
f2 = false;
|
419
|
-
} else
|
420
|
-
for (; !(f2 = (e2 = i2.call(t2)).done) && (a2.push(e2.value), a2.length !== l); f2 = true)
|
421
|
-
;
|
422
|
-
} catch (r3) {
|
423
|
-
o2 = true, n2 = r3;
|
424
|
-
} finally {
|
425
|
-
try {
|
426
|
-
if (!f2 && null != t2["return"] && (u2 = t2["return"](), Object(u2) !== u2))
|
427
|
-
return;
|
428
|
-
} finally {
|
429
|
-
if (o2)
|
430
|
-
throw n2;
|
431
|
-
}
|
432
|
-
}
|
433
|
-
return a2;
|
434
|
-
}
|
435
|
-
}
|
436
|
-
function _arrayLikeToArray(r2, a2) {
|
437
|
-
(null == a2 || a2 > r2.length) && (a2 = r2.length);
|
438
|
-
for (var e2 = 0, n2 = Array(a2); e2 < a2; e2++)
|
439
|
-
n2[e2] = r2[e2];
|
440
|
-
return n2;
|
441
|
-
}
|
442
|
-
function _unsupportedIterableToArray(r2, a2) {
|
443
|
-
if (r2) {
|
444
|
-
if ("string" == typeof r2)
|
445
|
-
return _arrayLikeToArray(r2, a2);
|
446
|
-
var t2 = {}.toString.call(r2).slice(8, -1);
|
447
|
-
return "Object" === t2 && r2.constructor && (t2 = r2.constructor.name), "Map" === t2 || "Set" === t2 ? Array.from(r2) : "Arguments" === t2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t2) ? _arrayLikeToArray(r2, a2) : void 0;
|
448
|
-
}
|
449
|
-
}
|
450
|
-
function _nonIterableRest() {
|
451
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
452
|
-
}
|
453
|
-
function _slicedToArray(r2, e2) {
|
454
|
-
return _arrayWithHoles(r2) || _iterableToArrayLimit(r2, e2) || _unsupportedIterableToArray(r2, e2) || _nonIterableRest();
|
455
|
-
}
|
456
|
-
var WUJIE_APP_ID = "data-wujie-id";
|
457
|
-
var WUJIE_SCRIPT_ID = "data-wujie-script-id";
|
458
|
-
var WUJIE_DATA_FLAG = "data-wujie-Flag";
|
459
|
-
var CONTAINER_POSITION_DATA_FLAG = "data-container-position-flag";
|
460
|
-
var CONTAINER_OVERFLOW_DATA_FLAG = "data-container-overflow-flag";
|
461
|
-
var LOADING_DATA_FLAG = "data-loading-flag";
|
462
|
-
var WUJIE_DATA_ATTACH_CSS_FLAG = "data-wujie-attach-css-flag";
|
463
|
-
var WUJIE_IFRAME_CLASS = "wujie_iframe";
|
464
|
-
var WUJIE_ALL_EVENT = "_wujie_all_event";
|
465
|
-
var WUJIE_SHADE_STYLE = "position: fixed; z-index: 2147483647; visibility: hidden; inset: 0px; backface-visibility: hidden;";
|
466
|
-
var WUJIE_LOADING_STYLE = "position: absolute; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index:1;";
|
467
|
-
var WUJIE_LOADING_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="24px" height="30px" viewBox="0 0 24 30">\n<rect x="0" y="13" width="4" height="5" fill="#909090">\n <animate attributeName="height" attributeType="XML" values="5;21;5" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>\n <animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>\n</rect>\n<rect x="10" y="13" width="4" height="5" fill="#909090">\n <animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>\n <animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>\n</rect>\n<rect x="20" y="13" width="4" height="5" fill="#909090">\n <animate attributeName="height" attributeType="XML" values="5;21;5" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>\n <animate attributeName="y" attributeType="XML" values="13; 5; 13" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>\n</rect>\n</svg>';
|
468
|
-
var WUJIE_TIPS_NO_URL = "url参数为空";
|
469
|
-
var WUJIE_TIPS_RELOAD_DISABLED = "子应用调用reload无法生效";
|
470
|
-
var WUJIE_TIPS_STOP_APP = "此报错可以忽略,iframe主动中断主应用代码在子应用运行";
|
471
|
-
var WUJIE_TIPS_STOP_APP_DETAIL = WUJIE_TIPS_STOP_APP + ",详见:https://github.com/Tencent/wujie/issues/54";
|
472
|
-
var WUJIE_TIPS_NO_SUBJECT = "事件订阅数量为空";
|
473
|
-
var WUJIE_TIPS_NO_FETCH = "window上不存在fetch属性,需要自行polyfill";
|
474
|
-
var WUJIE_TIPS_NOT_SUPPORTED = "当前浏览器不支持无界,子应用将采用iframe方式渲染";
|
475
|
-
var WUJIE_TIPS_SCRIPT_ERROR_REQUESTED = "脚本请求出现错误";
|
476
|
-
var WUJIE_TIPS_CSS_ERROR_REQUESTED = "样式请求出现错误";
|
477
|
-
var WUJIE_TIPS_HTML_ERROR_REQUESTED = "html请求出现错误";
|
478
|
-
var WUJIE_TIPS_REPEAT_RENDER = "无界组件短时间重复渲染了两次,可能存在性能问题请检查代码";
|
479
|
-
var WUJIE_TIPS_NO_SCRIPT = "目标Script尚未准备好或已经被移除";
|
480
|
-
var WUJIE_TIPS_GET_ELEMENT_BY_ID = "不支持document.getElementById()传入特殊字符,请参考document.querySelector文档";
|
481
|
-
function isFunction(value) {
|
482
|
-
return typeof value === "function";
|
483
|
-
}
|
484
|
-
function isHijackingTag(tagName) {
|
485
|
-
return (tagName === null || tagName === void 0 ? void 0 : tagName.toUpperCase()) === "LINK" || (tagName === null || tagName === void 0 ? void 0 : tagName.toUpperCase()) === "STYLE" || (tagName === null || tagName === void 0 ? void 0 : tagName.toUpperCase()) === "SCRIPT" || (tagName === null || tagName === void 0 ? void 0 : tagName.toUpperCase()) === "IFRAME";
|
486
|
-
}
|
487
|
-
var wujieSupport = window.Proxy && window.CustomElementRegistry;
|
488
|
-
var naughtySafari = typeof document.all === "function" && typeof document.all === "undefined";
|
489
|
-
var callableFnCacheMap = /* @__PURE__ */ new WeakMap();
|
490
|
-
var isCallable = function isCallable2(fn) {
|
491
|
-
if (callableFnCacheMap.has(fn)) {
|
492
|
-
return true;
|
493
|
-
}
|
494
|
-
var callable = naughtySafari ? typeof fn === "function" && typeof fn !== "undefined" : typeof fn === "function";
|
495
|
-
if (callable) {
|
496
|
-
callableFnCacheMap.set(fn, callable);
|
497
|
-
}
|
498
|
-
return callable;
|
499
|
-
};
|
500
|
-
var boundedMap = /* @__PURE__ */ new WeakMap();
|
501
|
-
function isBoundedFunction(fn) {
|
502
|
-
if (boundedMap.has(fn)) {
|
503
|
-
return boundedMap.get(fn);
|
504
|
-
}
|
505
|
-
var bounded = fn.name.indexOf("bound ") === 0 && !fn.hasOwnProperty("prototype");
|
506
|
-
boundedMap.set(fn, bounded);
|
507
|
-
return bounded;
|
508
|
-
}
|
509
|
-
var fnRegexCheckCacheMap = /* @__PURE__ */ new WeakMap();
|
510
|
-
function isConstructable(fn) {
|
511
|
-
var hasPrototypeMethods = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1;
|
512
|
-
if (hasPrototypeMethods)
|
513
|
-
return true;
|
514
|
-
if (fnRegexCheckCacheMap.has(fn)) {
|
515
|
-
return fnRegexCheckCacheMap.get(fn);
|
516
|
-
}
|
517
|
-
var constructable = hasPrototypeMethods;
|
518
|
-
if (!constructable) {
|
519
|
-
var fnString = fn.toString();
|
520
|
-
var constructableFunctionRegex = /^function\b\s[A-Z].*/;
|
521
|
-
var classRegex = /^class\b/;
|
522
|
-
constructable = constructableFunctionRegex.test(fnString) || classRegex.test(fnString);
|
523
|
-
}
|
524
|
-
fnRegexCheckCacheMap.set(fn, constructable);
|
525
|
-
return constructable;
|
526
|
-
}
|
527
|
-
var setFnCacheMap = /* @__PURE__ */ new WeakMap();
|
528
|
-
function checkProxyFunction(value) {
|
529
|
-
if (isCallable(value) && !isBoundedFunction(value) && !isConstructable(value)) {
|
530
|
-
if (!setFnCacheMap.has(value)) {
|
531
|
-
setFnCacheMap.set(value, value);
|
532
|
-
}
|
533
|
-
}
|
534
|
-
}
|
535
|
-
function getTargetValue(target, p2) {
|
536
|
-
var value = target[p2];
|
537
|
-
if (setFnCacheMap.has(value)) {
|
538
|
-
return setFnCacheMap.get(value);
|
539
|
-
}
|
540
|
-
if (isCallable(value) && !isBoundedFunction(value) && !isConstructable(value)) {
|
541
|
-
var boundValue = Function.prototype.bind.call(value, target);
|
542
|
-
setFnCacheMap.set(value, boundValue);
|
543
|
-
for (var _key in value) {
|
544
|
-
boundValue[_key] = value[_key];
|
545
|
-
}
|
546
|
-
if (value.hasOwnProperty("prototype") && !boundValue.hasOwnProperty("prototype")) {
|
547
|
-
Object.defineProperty(boundValue, "prototype", {
|
548
|
-
value: value.prototype,
|
549
|
-
enumerable: false,
|
550
|
-
writable: true
|
551
|
-
});
|
552
|
-
}
|
553
|
-
return boundValue;
|
554
|
-
}
|
555
|
-
return value;
|
556
|
-
}
|
557
|
-
function getDegradeIframe(id) {
|
558
|
-
return window.document.querySelector("iframe[".concat(WUJIE_APP_ID, '="').concat(id, '"]'));
|
559
|
-
}
|
560
|
-
function setAttrsToElement(element, attrs) {
|
561
|
-
Object.keys(attrs).forEach(function(name) {
|
562
|
-
element.setAttribute(name, attrs[name]);
|
563
|
-
});
|
564
|
-
}
|
565
|
-
function appRouteParse(url) {
|
566
|
-
if (!url) {
|
567
|
-
error(WUJIE_TIPS_NO_URL);
|
568
|
-
throw new Error();
|
569
|
-
}
|
570
|
-
var urlElement = anchorElementGenerator(url);
|
571
|
-
var appHostPath = urlElement.protocol + "//" + urlElement.host;
|
572
|
-
var appRoutePath = urlElement.pathname + urlElement.search + urlElement.hash;
|
573
|
-
if (!appRoutePath.startsWith("/"))
|
574
|
-
appRoutePath = "/" + appRoutePath;
|
575
|
-
return {
|
576
|
-
urlElement,
|
577
|
-
appHostPath,
|
578
|
-
appRoutePath
|
579
|
-
};
|
580
|
-
}
|
581
|
-
function anchorElementGenerator(url) {
|
582
|
-
var element = window.document.createElement("a");
|
583
|
-
element.href = url;
|
584
|
-
element.href = element.href;
|
585
|
-
return element;
|
586
|
-
}
|
587
|
-
function getAnchorElementQueryMap(anchorElement) {
|
588
|
-
var queryList = anchorElement.search.replace("?", "").split("&");
|
589
|
-
var queryMap = {};
|
590
|
-
queryList.forEach(function(query) {
|
591
|
-
var _query$split = query.split("="), _query$split2 = _slicedToArray(_query$split, 2), key = _query$split2[0], value = _query$split2[1];
|
592
|
-
if (key && value)
|
593
|
-
queryMap[key] = value;
|
594
|
-
});
|
595
|
-
return queryMap;
|
596
|
-
}
|
597
|
-
function isMatchSyncQueryById(id) {
|
598
|
-
var queryMap = getAnchorElementQueryMap(anchorElementGenerator(window.location.href));
|
599
|
-
return Object.keys(queryMap).includes(id);
|
600
|
-
}
|
601
|
-
function fixElementCtrSrcOrHref(iframeWindow, elementCtr, attr) {
|
602
|
-
var rawElementSetAttribute = iframeWindow.Element.prototype.setAttribute;
|
603
|
-
elementCtr.prototype.setAttribute = function(name, value) {
|
604
|
-
var targetValue = value;
|
605
|
-
if (name === attr)
|
606
|
-
targetValue = getAbsolutePath(value, this.baseURI || "", true);
|
607
|
-
rawElementSetAttribute.call(this, name, targetValue);
|
608
|
-
};
|
609
|
-
var rawAnchorElementHrefDescriptor = Object.getOwnPropertyDescriptor(elementCtr.prototype, attr);
|
610
|
-
var enumerable = rawAnchorElementHrefDescriptor.enumerable, configurable = rawAnchorElementHrefDescriptor.configurable, _get = rawAnchorElementHrefDescriptor.get, _set = rawAnchorElementHrefDescriptor.set;
|
611
|
-
Object.defineProperty(elementCtr.prototype, attr, {
|
612
|
-
enumerable,
|
613
|
-
configurable,
|
614
|
-
get: function get() {
|
615
|
-
return _get.call(this);
|
616
|
-
},
|
617
|
-
set: function set(href) {
|
618
|
-
_set.call(this, getAbsolutePath(href, this.baseURI, true));
|
619
|
-
}
|
620
|
-
});
|
621
|
-
}
|
622
|
-
function getCurUrl(proxyLocation) {
|
623
|
-
var location2 = proxyLocation;
|
624
|
-
return location2.protocol + "//" + location2.host + location2.pathname;
|
625
|
-
}
|
626
|
-
function getAbsolutePath(url, base, hash) {
|
627
|
-
try {
|
628
|
-
if (url) {
|
629
|
-
if (hash && url.startsWith("#"))
|
630
|
-
return url;
|
631
|
-
return new URL(url, base).href;
|
632
|
-
} else
|
633
|
-
return url;
|
634
|
-
} catch (_unused) {
|
635
|
-
return url;
|
636
|
-
}
|
637
|
-
}
|
638
|
-
function getSyncUrl(id, prefix) {
|
639
|
-
var _syncUrl$match;
|
640
|
-
var winUrlElement = anchorElementGenerator(window.location.href);
|
641
|
-
var queryMap = getAnchorElementQueryMap(winUrlElement);
|
642
|
-
winUrlElement = null;
|
643
|
-
var syncUrl = window.decodeURIComponent(queryMap[id] || "");
|
644
|
-
var validShortPath = (_syncUrl$match = syncUrl.match(/^{([^}]*)}/)) === null || _syncUrl$match === void 0 ? void 0 : _syncUrl$match[1];
|
645
|
-
if (prefix && validShortPath) {
|
646
|
-
return syncUrl.replace("{".concat(validShortPath, "}"), prefix[validShortPath]);
|
647
|
-
}
|
648
|
-
return syncUrl;
|
649
|
-
}
|
650
|
-
var requestIdleCallback = window.requestIdleCallback || function(cb) {
|
651
|
-
return setTimeout(cb, 1);
|
652
|
-
};
|
653
|
-
function getContainer(container) {
|
654
|
-
return typeof container === "string" ? document.querySelector(container) : container;
|
655
|
-
}
|
656
|
-
function warn(msg, data2) {
|
657
|
-
var _console;
|
658
|
-
(_console = console) === null || _console === void 0 || _console.warn("[wujie warn]: ".concat(msg), data2);
|
659
|
-
}
|
660
|
-
function error(msg, data2) {
|
661
|
-
var _console2;
|
662
|
-
(_console2 = console) === null || _console2 === void 0 || _console2.error("[wujie error]: ".concat(msg), data2);
|
663
|
-
}
|
664
|
-
function getInlineCode(match) {
|
665
|
-
var start = match.indexOf(">") + 1;
|
666
|
-
var end = match.lastIndexOf("<");
|
667
|
-
return match.substring(start, end);
|
668
|
-
}
|
669
|
-
function defaultGetPublicPath(entry) {
|
670
|
-
if (_typeof$2(entry) === "object") {
|
671
|
-
return "/";
|
672
|
-
}
|
673
|
-
try {
|
674
|
-
var _URL = new URL(entry, location.href), origin = _URL.origin, pathname = _URL.pathname;
|
675
|
-
var paths = pathname.split("/");
|
676
|
-
paths.pop();
|
677
|
-
return "".concat(origin).concat(paths.join("/"), "/");
|
678
|
-
} catch (e2) {
|
679
|
-
console.warn(e2);
|
680
|
-
return "";
|
681
|
-
}
|
682
|
-
}
|
683
|
-
function compose(fnList) {
|
684
|
-
return function(code) {
|
685
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key2 = 1; _key2 < _len; _key2++) {
|
686
|
-
args[_key2 - 1] = arguments[_key2];
|
687
|
-
}
|
688
|
-
return fnList.reduce(function(newCode, fn) {
|
689
|
-
return isFunction(fn) ? fn.apply(void 0, [newCode].concat(args)) : newCode;
|
690
|
-
}, code || "");
|
691
|
-
};
|
692
|
-
}
|
693
|
-
function nextTick(cb) {
|
694
|
-
Promise.resolve().then(cb);
|
695
|
-
}
|
696
|
-
function execHooks(plugins, hookName) {
|
697
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key3 = 2; _key3 < _len2; _key3++) {
|
698
|
-
args[_key3 - 2] = arguments[_key3];
|
699
|
-
}
|
700
|
-
try {
|
701
|
-
if (plugins && plugins.length > 0) {
|
702
|
-
plugins.map(function(plugin) {
|
703
|
-
return plugin[hookName];
|
704
|
-
}).filter(function(hook) {
|
705
|
-
return isFunction(hook);
|
706
|
-
}).forEach(function(hook) {
|
707
|
-
return hook.apply(void 0, args);
|
708
|
-
});
|
709
|
-
}
|
710
|
-
} catch (e2) {
|
711
|
-
error(e2);
|
712
|
-
}
|
713
|
-
}
|
714
|
-
function isScriptElement(element) {
|
715
|
-
var _element$tagName;
|
716
|
-
return ((_element$tagName = element.tagName) === null || _element$tagName === void 0 ? void 0 : _element$tagName.toUpperCase()) === "SCRIPT";
|
717
|
-
}
|
718
|
-
var count = 1;
|
719
|
-
function setTagToScript(element, tag) {
|
720
|
-
if (isScriptElement(element)) {
|
721
|
-
var scriptTag = tag || String(count++);
|
722
|
-
element.setAttribute(WUJIE_SCRIPT_ID, scriptTag);
|
723
|
-
}
|
724
|
-
}
|
725
|
-
function getTagFromScript(element) {
|
726
|
-
if (isScriptElement(element)) {
|
727
|
-
return element.getAttribute(WUJIE_SCRIPT_ID);
|
728
|
-
}
|
729
|
-
return null;
|
730
|
-
}
|
731
|
-
function mergeOptions(options, cacheOptions) {
|
732
|
-
return {
|
733
|
-
name: options.name,
|
734
|
-
el: options.el || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.el),
|
735
|
-
url: options.url || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.url),
|
736
|
-
html: options.html || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.html),
|
737
|
-
exec: options.exec !== void 0 ? options.exec : cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.exec,
|
738
|
-
replace: options.replace || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.replace),
|
739
|
-
fetch: options.fetch || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.fetch),
|
740
|
-
props: options.props || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.props),
|
741
|
-
sync: options.sync !== void 0 ? options.sync : cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.sync,
|
742
|
-
prefix: options.prefix || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.prefix),
|
743
|
-
loading: options.loading || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.loading),
|
744
|
-
// 默认 {}
|
745
|
-
attrs: options.attrs !== void 0 ? options.attrs : (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.attrs) || {},
|
746
|
-
degradeAttrs: options.degradeAttrs !== void 0 ? options.degradeAttrs : (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.degradeAttrs) || {},
|
747
|
-
// 默认 true
|
748
|
-
fiber: options.fiber !== void 0 ? options.fiber : (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.fiber) !== void 0 ? cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.fiber : true,
|
749
|
-
alive: options.alive !== void 0 ? options.alive : cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.alive,
|
750
|
-
degrade: options.degrade !== void 0 ? options.degrade : cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.degrade,
|
751
|
-
plugins: options.plugins || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.plugins),
|
752
|
-
lifecycles: {
|
753
|
-
beforeLoad: options.beforeLoad || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.beforeLoad),
|
754
|
-
beforeMount: options.beforeMount || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.beforeMount),
|
755
|
-
afterMount: options.afterMount || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.afterMount),
|
756
|
-
beforeUnmount: options.beforeUnmount || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.beforeUnmount),
|
757
|
-
afterUnmount: options.afterUnmount || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.afterUnmount),
|
758
|
-
activated: options.activated || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.activated),
|
759
|
-
deactivated: options.deactivated || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.deactivated),
|
760
|
-
loadError: options.loadError || (cacheOptions === null || cacheOptions === void 0 ? void 0 : cacheOptions.loadError)
|
761
|
-
}
|
762
|
-
};
|
763
|
-
}
|
764
|
-
function eventTrigger(el, eventName, detail) {
|
765
|
-
var event;
|
766
|
-
if (typeof window.CustomEvent === "function") {
|
767
|
-
event = new CustomEvent(eventName, {
|
768
|
-
detail
|
769
|
-
});
|
770
|
-
} else {
|
771
|
-
event = document.createEvent("CustomEvent");
|
772
|
-
event.initCustomEvent(eventName, true, false, detail);
|
773
|
-
}
|
774
|
-
el.dispatchEvent(event);
|
775
|
-
}
|
776
|
-
function stopMainAppRun() {
|
777
|
-
warn(WUJIE_TIPS_STOP_APP_DETAIL);
|
778
|
-
throw new Error(WUJIE_TIPS_STOP_APP);
|
779
|
-
}
|
780
|
-
var ALL_SCRIPT_REGEX = /(<script[\s\S]*?>)[\s\S]*?<\/script>/gi;
|
781
|
-
var SCRIPT_TAG_REGEX = /<(script)\s+((?!type=('|")text\/ng\x2Dtemplate\3)[\s\S])*?>[\s\S]*?<\/\1>/i;
|
782
|
-
var SCRIPT_SRC_REGEX = /.*\ssrc=('|")?([^>'"\s]+)/;
|
783
|
-
var SCRIPT_TYPE_REGEX = /.*\stype=('|")?([^>'"\s]+)/;
|
784
|
-
var SCRIPT_ENTRY_REGEX = /.*\sentry\s*.*/;
|
785
|
-
var SCRIPT_ASYNC_REGEX = /.*\sasync\s*.*/;
|
786
|
-
var DEFER_ASYNC_REGEX = /.*\sdefer\s*.*/;
|
787
|
-
var SCRIPT_NO_MODULE_REGEX = /.*\snomodule\s*.*/;
|
788
|
-
var SCRIPT_MODULE_REGEX = /.*\stype=('|")?module('|")?\s*.*/;
|
789
|
-
var LINK_TAG_REGEX = /<(link)\s+[\s\S]*?>/gi;
|
790
|
-
var LINK_PRELOAD_OR_PREFETCH_REGEX = /\srel=('|")?(preload|prefetch|modulepreload)\1/;
|
791
|
-
var LINK_HREF_REGEX = /.*\shref=('|")?([^>'"\s]+)/;
|
792
|
-
var LINK_AS_FONT = /.*\sas=('|")?font\1.*/;
|
793
|
-
var STYLE_TAG_REGEX = /<style[^>]*>[\s\S]*?<\/style>/gi;
|
794
|
-
var STYLE_TYPE_REGEX = /\s+rel=('|")?stylesheet\1.*/;
|
795
|
-
var STYLE_HREF_REGEX = /.*\shref=('|")?([^>'"\s]+)/;
|
796
|
-
var HTML_COMMENT_REGEX = /<!--([\s\S]*?)-->/g;
|
797
|
-
var LINK_IGNORE_REGEX = /<link(\s+|\s+[\s\S]+\s+)ignore(\s*|\s+[\s\S]*|=[\s\S]*)>/i;
|
798
|
-
var STYLE_IGNORE_REGEX = /<style(\s+|\s+[\s\S]+\s+)ignore(\s*|\s+[\s\S]*|=[\s\S]*)>/i;
|
799
|
-
var SCRIPT_IGNORE_REGEX = /<script(\s+|\s+[\s\S]+\s+)ignore(\s*|\s+[\s\S]*|=[\s\S]*)>/i;
|
800
|
-
var CROSS_ORIGIN_REGEX = /.*\scrossorigin=?('|")?(use-credentials|anonymous)?('|")?/i;
|
801
|
-
function hasProtocol(url) {
|
802
|
-
return url.startsWith("//") || url.startsWith("http://") || url.startsWith("https://");
|
803
|
-
}
|
804
|
-
function getEntirePath(path, baseURI) {
|
805
|
-
return new URL(path, baseURI).toString();
|
806
|
-
}
|
807
|
-
function isValidJavaScriptType(type) {
|
808
|
-
var handleTypes = ["text/javascript", "module", "application/javascript", "text/ecmascript", "application/ecmascript"];
|
809
|
-
return !type || handleTypes.indexOf(type) !== -1;
|
810
|
-
}
|
811
|
-
function parseTagAttributes(TagOuterHTML) {
|
812
|
-
var pattern = /<[-\w]+\s+([^>]*)>/i;
|
813
|
-
var matches = pattern.exec(TagOuterHTML);
|
814
|
-
if (!matches) {
|
815
|
-
return {};
|
816
|
-
}
|
817
|
-
var attributesString = matches[1];
|
818
|
-
var attributesPattern = /([^\s=]+)\s*=\s*(['"])(.*?)\2/g;
|
819
|
-
var attributesObject = {};
|
820
|
-
var attributeMatches;
|
821
|
-
while ((attributeMatches = attributesPattern.exec(attributesString)) !== null) {
|
822
|
-
var attributeName = attributeMatches[1];
|
823
|
-
var attributeValue = attributeMatches[3];
|
824
|
-
attributesObject[attributeName] = attributeValue;
|
825
|
-
}
|
826
|
-
return attributesObject;
|
827
|
-
}
|
828
|
-
function isModuleScriptSupported() {
|
829
|
-
var s2 = window.document.createElement("script");
|
830
|
-
return "noModule" in s2;
|
831
|
-
}
|
832
|
-
var genLinkReplaceSymbol = function genLinkReplaceSymbol2(linkHref) {
|
833
|
-
var preloadOrPrefetch = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
834
|
-
return "<!-- ".concat(preloadOrPrefetch ? "prefetch/preload/modulepreload" : "", " link ").concat(linkHref, " replaced by wujie -->");
|
835
|
-
};
|
836
|
-
var getInlineStyleReplaceSymbol = function getInlineStyleReplaceSymbol2(index) {
|
837
|
-
return "<!-- inline-style-".concat(index, " replaced by wujie -->");
|
838
|
-
};
|
839
|
-
var genScriptReplaceSymbol = function genScriptReplaceSymbol2(scriptSrc) {
|
840
|
-
var type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
841
|
-
return "<!-- ".concat(type, " script ").concat(scriptSrc, " replaced by wujie -->");
|
842
|
-
};
|
843
|
-
var inlineScriptReplaceSymbol = "<!-- inline scripts replaced by wujie -->";
|
844
|
-
var genIgnoreAssetReplaceSymbol = function genIgnoreAssetReplaceSymbol2(url) {
|
845
|
-
return "<!-- ignore asset ".concat(url || "file", " replaced by wujie -->");
|
846
|
-
};
|
847
|
-
var genModuleScriptReplaceSymbol = function genModuleScriptReplaceSymbol2(scriptSrc, moduleSupport) {
|
848
|
-
return "<!-- ".concat(moduleSupport ? "nomodule" : "module", " script ").concat(scriptSrc, " ignored by wujie -->");
|
849
|
-
};
|
850
|
-
function processTpl(tpl, baseURI, postProcessTemplate) {
|
851
|
-
var scripts = [];
|
852
|
-
var styles = [];
|
853
|
-
var entry = null;
|
854
|
-
var moduleSupport = isModuleScriptSupported();
|
855
|
-
var template = tpl.replace(HTML_COMMENT_REGEX, "").replace(LINK_TAG_REGEX, function(match) {
|
856
|
-
var styleType = !!match.match(STYLE_TYPE_REGEX);
|
857
|
-
if (styleType) {
|
858
|
-
var styleHref = match.match(STYLE_HREF_REGEX);
|
859
|
-
var styleIgnore = match.match(LINK_IGNORE_REGEX);
|
860
|
-
if (styleHref) {
|
861
|
-
var href = styleHref && styleHref[2];
|
862
|
-
var newHref = href;
|
863
|
-
if (href && !hasProtocol(href)) {
|
864
|
-
newHref = getEntirePath(href, baseURI);
|
865
|
-
}
|
866
|
-
if (styleIgnore) {
|
867
|
-
return genIgnoreAssetReplaceSymbol(newHref);
|
868
|
-
}
|
869
|
-
styles.push({
|
870
|
-
src: newHref
|
871
|
-
});
|
872
|
-
return genLinkReplaceSymbol(newHref);
|
873
|
-
}
|
874
|
-
}
|
875
|
-
var preloadOrPrefetchType = match.match(LINK_PRELOAD_OR_PREFETCH_REGEX) && match.match(LINK_HREF_REGEX) && !match.match(LINK_AS_FONT);
|
876
|
-
if (preloadOrPrefetchType) {
|
877
|
-
var _match$match = match.match(LINK_HREF_REGEX), _match$match2 = _slicedToArray(_match$match, 3), linkHref = _match$match2[2];
|
878
|
-
return genLinkReplaceSymbol(linkHref, true);
|
879
|
-
}
|
880
|
-
return match;
|
881
|
-
}).replace(STYLE_TAG_REGEX, function(match) {
|
882
|
-
if (STYLE_IGNORE_REGEX.test(match)) {
|
883
|
-
return genIgnoreAssetReplaceSymbol("style file");
|
884
|
-
} else {
|
885
|
-
var code = getInlineCode(match);
|
886
|
-
styles.push({
|
887
|
-
src: "",
|
888
|
-
content: code
|
889
|
-
});
|
890
|
-
return getInlineStyleReplaceSymbol(styles.length - 1);
|
891
|
-
}
|
892
|
-
}).replace(ALL_SCRIPT_REGEX, function(match, scriptTag) {
|
893
|
-
var scriptIgnore = scriptTag.match(SCRIPT_IGNORE_REGEX);
|
894
|
-
var isModuleScript = !!scriptTag.match(SCRIPT_MODULE_REGEX);
|
895
|
-
var isCrossOriginScript = scriptTag.match(CROSS_ORIGIN_REGEX);
|
896
|
-
var crossOriginType = (isCrossOriginScript === null || isCrossOriginScript === void 0 ? void 0 : isCrossOriginScript[2]) || "";
|
897
|
-
var moduleScriptIgnore = moduleSupport && !!scriptTag.match(SCRIPT_NO_MODULE_REGEX) || !moduleSupport && isModuleScript;
|
898
|
-
var matchedScriptTypeMatch = scriptTag.match(SCRIPT_TYPE_REGEX);
|
899
|
-
var matchedScriptType = matchedScriptTypeMatch && matchedScriptTypeMatch[2];
|
900
|
-
if (!isValidJavaScriptType(matchedScriptType)) {
|
901
|
-
return match;
|
902
|
-
}
|
903
|
-
if (SCRIPT_TAG_REGEX.test(match) && scriptTag.match(SCRIPT_SRC_REGEX)) {
|
904
|
-
var matchedScriptEntry = scriptTag.match(SCRIPT_ENTRY_REGEX);
|
905
|
-
var matchedScriptSrcMatch = scriptTag.match(SCRIPT_SRC_REGEX);
|
906
|
-
var matchedScriptSrc = matchedScriptSrcMatch && matchedScriptSrcMatch[2];
|
907
|
-
if (entry && matchedScriptEntry) {
|
908
|
-
throw new SyntaxError("You should not set multiply entry script!");
|
909
|
-
} else {
|
910
|
-
if (matchedScriptSrc && !hasProtocol(matchedScriptSrc)) {
|
911
|
-
matchedScriptSrc = getEntirePath(matchedScriptSrc, baseURI);
|
912
|
-
}
|
913
|
-
entry = entry || matchedScriptEntry && matchedScriptSrc;
|
914
|
-
}
|
915
|
-
if (scriptIgnore) {
|
916
|
-
return genIgnoreAssetReplaceSymbol(matchedScriptSrc || "js file");
|
917
|
-
}
|
918
|
-
if (moduleScriptIgnore) {
|
919
|
-
return genModuleScriptReplaceSymbol(matchedScriptSrc || "js file", moduleSupport);
|
920
|
-
}
|
921
|
-
if (matchedScriptSrc) {
|
922
|
-
var isAsyncScript = !!scriptTag.match(SCRIPT_ASYNC_REGEX);
|
923
|
-
var isDeferScript = !!scriptTag.match(DEFER_ASYNC_REGEX);
|
924
|
-
scripts.push(isAsyncScript || isDeferScript ? {
|
925
|
-
async: isAsyncScript,
|
926
|
-
defer: isDeferScript,
|
927
|
-
src: matchedScriptSrc,
|
928
|
-
module: isModuleScript,
|
929
|
-
crossorigin: !!isCrossOriginScript,
|
930
|
-
crossoriginType: crossOriginType,
|
931
|
-
attrs: parseTagAttributes(match)
|
932
|
-
} : {
|
933
|
-
src: matchedScriptSrc,
|
934
|
-
module: isModuleScript,
|
935
|
-
crossorigin: !!isCrossOriginScript,
|
936
|
-
crossoriginType: crossOriginType,
|
937
|
-
attrs: parseTagAttributes(match)
|
938
|
-
});
|
939
|
-
return genScriptReplaceSymbol(matchedScriptSrc, isAsyncScript && "async" || isDeferScript && "defer" || "");
|
940
|
-
}
|
941
|
-
return match;
|
942
|
-
} else {
|
943
|
-
if (scriptIgnore) {
|
944
|
-
return genIgnoreAssetReplaceSymbol("js file");
|
945
|
-
}
|
946
|
-
if (moduleScriptIgnore) {
|
947
|
-
return genModuleScriptReplaceSymbol("js file", moduleSupport);
|
948
|
-
}
|
949
|
-
var code = getInlineCode(match);
|
950
|
-
var isPureCommentBlock = code.split(/[\r\n]+/).every(function(line) {
|
951
|
-
return !line.trim() || line.trim().startsWith("//");
|
952
|
-
});
|
953
|
-
if (!isPureCommentBlock && code) {
|
954
|
-
scripts.push({
|
955
|
-
src: "",
|
956
|
-
content: code,
|
957
|
-
module: isModuleScript,
|
958
|
-
crossorigin: !!isCrossOriginScript,
|
959
|
-
crossoriginType: crossOriginType,
|
960
|
-
attrs: parseTagAttributes(match)
|
961
|
-
});
|
962
|
-
}
|
963
|
-
return inlineScriptReplaceSymbol;
|
964
|
-
}
|
965
|
-
});
|
966
|
-
var tplResult = {
|
967
|
-
template,
|
968
|
-
scripts,
|
969
|
-
styles,
|
970
|
-
// set the last script as entry if have not set
|
971
|
-
entry: entry || scripts[scripts.length - 1]
|
972
|
-
};
|
973
|
-
if (typeof postProcessTemplate === "function") {
|
974
|
-
tplResult = postProcessTemplate(tplResult);
|
975
|
-
}
|
976
|
-
return tplResult;
|
977
|
-
}
|
978
|
-
function _arrayWithoutHoles(r2) {
|
979
|
-
if (Array.isArray(r2))
|
980
|
-
return _arrayLikeToArray(r2);
|
981
|
-
}
|
982
|
-
function _iterableToArray(r2) {
|
983
|
-
if ("undefined" != typeof Symbol && null != r2[Symbol.iterator] || null != r2["@@iterator"])
|
984
|
-
return Array.from(r2);
|
985
|
-
}
|
986
|
-
function _nonIterableSpread() {
|
987
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
988
|
-
}
|
989
|
-
function _toConsumableArray(r2) {
|
990
|
-
return _arrayWithoutHoles(r2) || _iterableToArray(r2) || _unsupportedIterableToArray(r2) || _nonIterableSpread();
|
991
|
-
}
|
992
|
-
function getCssLoader(_ref) {
|
993
|
-
var plugins = _ref.plugins, replace = _ref.replace;
|
994
|
-
return function(code) {
|
995
|
-
var src = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
996
|
-
var base = arguments.length > 2 ? arguments[2] : void 0;
|
997
|
-
return compose(plugins.map(function(plugin) {
|
998
|
-
return plugin.cssLoader;
|
999
|
-
}))(replace ? replace(code) : code, src, base);
|
1000
|
-
};
|
1001
|
-
}
|
1002
|
-
function getJsLoader(_ref2) {
|
1003
|
-
var plugins = _ref2.plugins, replace = _ref2.replace;
|
1004
|
-
return function(code) {
|
1005
|
-
var src = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
1006
|
-
var base = arguments.length > 2 ? arguments[2] : void 0;
|
1007
|
-
return compose(plugins.map(function(plugin) {
|
1008
|
-
return plugin.jsLoader;
|
1009
|
-
}))(replace ? replace(code) : code, src, base);
|
1010
|
-
};
|
1011
|
-
}
|
1012
|
-
function getPresetLoaders(loaderType, plugins) {
|
1013
|
-
var loaders = plugins.map(function(plugin) {
|
1014
|
-
return plugin[loaderType];
|
1015
|
-
}).filter(function(loaders2) {
|
1016
|
-
return loaders2 === null || loaders2 === void 0 ? void 0 : loaders2.length;
|
1017
|
-
});
|
1018
|
-
var res = loaders.reduce(function(preLoaders, curLoaders) {
|
1019
|
-
return preLoaders.concat(curLoaders);
|
1020
|
-
}, []);
|
1021
|
-
return loaderType === "cssBeforeLoaders" ? res.reverse() : res;
|
1022
|
-
}
|
1023
|
-
function getEffectLoaders(loaderType, plugins) {
|
1024
|
-
return plugins.map(function(plugin) {
|
1025
|
-
return plugin[loaderType];
|
1026
|
-
}).filter(function(loaders) {
|
1027
|
-
return loaders === null || loaders === void 0 ? void 0 : loaders.length;
|
1028
|
-
}).reduce(function(preLoaders, curLoaders) {
|
1029
|
-
return preLoaders.concat(curLoaders);
|
1030
|
-
}, []);
|
1031
|
-
}
|
1032
|
-
function isMatchUrl(url, effectLoaders) {
|
1033
|
-
return effectLoaders.some(function(loader) {
|
1034
|
-
return typeof loader === "string" ? url === loader : loader.test(url);
|
1035
|
-
});
|
1036
|
-
}
|
1037
|
-
function cssRelativePathResolve(code, src, base) {
|
1038
|
-
var baseUrl = src ? getAbsolutePath(src, base) : base;
|
1039
|
-
var urlReg = /(url\((?!['"]?(?:data):)['"]?)([^'")]*)(['"]?\))/g;
|
1040
|
-
return code.replace(urlReg, function(_m, pre, url, post) {
|
1041
|
-
var absoluteUrl = getAbsolutePath(url, baseUrl);
|
1042
|
-
return pre + absoluteUrl + post;
|
1043
|
-
});
|
1044
|
-
}
|
1045
|
-
var defaultPlugin = {
|
1046
|
-
cssLoader: cssRelativePathResolve,
|
1047
|
-
// fix https://github.com/Tencent/wujie/issues/455
|
1048
|
-
cssBeforeLoaders: [{
|
1049
|
-
content: "html {view-transition-name: none;}"
|
1050
|
-
}]
|
1051
|
-
};
|
1052
|
-
function getPlugins(plugins) {
|
1053
|
-
return Array.isArray(plugins) ? [defaultPlugin].concat(_toConsumableArray(plugins)) : [defaultPlugin];
|
1054
|
-
}
|
1055
|
-
function ownKeys$6(e2, r2) {
|
1056
|
-
var t2 = Object.keys(e2);
|
1057
|
-
if (Object.getOwnPropertySymbols) {
|
1058
|
-
var o2 = Object.getOwnPropertySymbols(e2);
|
1059
|
-
r2 && (o2 = o2.filter(function(r3) {
|
1060
|
-
return Object.getOwnPropertyDescriptor(e2, r3).enumerable;
|
1061
|
-
})), t2.push.apply(t2, o2);
|
1062
|
-
}
|
1063
|
-
return t2;
|
1064
|
-
}
|
1065
|
-
function _objectSpread$6(e2) {
|
1066
|
-
for (var r2 = 1; r2 < arguments.length; r2++) {
|
1067
|
-
var t2 = null != arguments[r2] ? arguments[r2] : {};
|
1068
|
-
r2 % 2 ? ownKeys$6(Object(t2), true).forEach(function(r3) {
|
1069
|
-
_defineProperty(e2, r3, t2[r3]);
|
1070
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : ownKeys$6(Object(t2)).forEach(function(r3) {
|
1071
|
-
Object.defineProperty(e2, r3, Object.getOwnPropertyDescriptor(t2, r3));
|
1072
|
-
});
|
1073
|
-
}
|
1074
|
-
return e2;
|
1075
|
-
}
|
1076
|
-
var styleCache = {};
|
1077
|
-
var scriptCache = {};
|
1078
|
-
var embedHTMLCache = {};
|
1079
|
-
if (!window.fetch) {
|
1080
|
-
error(WUJIE_TIPS_NO_FETCH);
|
1081
|
-
throw new Error();
|
1082
|
-
}
|
1083
|
-
var defaultFetch = window.fetch.bind(window);
|
1084
|
-
function defaultGetTemplate(tpl) {
|
1085
|
-
return tpl;
|
1086
|
-
}
|
1087
|
-
function processCssLoader(_x, _x2, _x3) {
|
1088
|
-
return _processCssLoader.apply(this, arguments);
|
1089
|
-
}
|
1090
|
-
function _processCssLoader() {
|
1091
|
-
_processCssLoader = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1.mark(function _callee(sandbox, template, getExternalStyleSheets) {
|
1092
|
-
var curUrl, composeCssLoader, processedCssList, embedHTML;
|
1093
|
-
return _regeneratorRuntime$1.wrap(function _callee$(_context) {
|
1094
|
-
while (1)
|
1095
|
-
switch (_context.prev = _context.next) {
|
1096
|
-
case 0:
|
1097
|
-
curUrl = getCurUrl(sandbox.proxyLocation);
|
1098
|
-
composeCssLoader = compose(sandbox.plugins.map(function(plugin) {
|
1099
|
-
return plugin.cssLoader;
|
1100
|
-
}));
|
1101
|
-
processedCssList = getExternalStyleSheets().map(function(_ref2) {
|
1102
|
-
var src = _ref2.src, ignore = _ref2.ignore, contentPromise = _ref2.contentPromise;
|
1103
|
-
return {
|
1104
|
-
src,
|
1105
|
-
ignore,
|
1106
|
-
contentPromise: contentPromise.then(function(content) {
|
1107
|
-
return composeCssLoader(content, src, curUrl);
|
1108
|
-
})
|
1109
|
-
};
|
1110
|
-
});
|
1111
|
-
_context.next = 5;
|
1112
|
-
return getEmbedHTML(template, processedCssList);
|
1113
|
-
case 5:
|
1114
|
-
embedHTML = _context.sent;
|
1115
|
-
return _context.abrupt("return", sandbox.replace ? sandbox.replace(embedHTML) : embedHTML);
|
1116
|
-
case 7:
|
1117
|
-
case "end":
|
1118
|
-
return _context.stop();
|
1119
|
-
}
|
1120
|
-
}, _callee);
|
1121
|
-
}));
|
1122
|
-
return _processCssLoader.apply(this, arguments);
|
1123
|
-
}
|
1124
|
-
function getEmbedHTML(_x4, _x5) {
|
1125
|
-
return _getEmbedHTML.apply(this, arguments);
|
1126
|
-
}
|
1127
|
-
function _getEmbedHTML() {
|
1128
|
-
_getEmbedHTML = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1.mark(function _callee2(template, styleResultList) {
|
1129
|
-
var embedHTML;
|
1130
|
-
return _regeneratorRuntime$1.wrap(function _callee2$(_context2) {
|
1131
|
-
while (1)
|
1132
|
-
switch (_context2.prev = _context2.next) {
|
1133
|
-
case 0:
|
1134
|
-
embedHTML = template;
|
1135
|
-
return _context2.abrupt("return", Promise.all(styleResultList.map(function(styleResult, index) {
|
1136
|
-
return styleResult.contentPromise.then(function(content) {
|
1137
|
-
if (styleResult.src) {
|
1138
|
-
embedHTML = embedHTML.replace(genLinkReplaceSymbol(styleResult.src), styleResult.ignore ? '<link href="'.concat(styleResult.src, '" rel="stylesheet" type="text/css">') : "<style>/* ".concat(styleResult.src, " */").concat(content, "</style>"));
|
1139
|
-
} else if (content) {
|
1140
|
-
embedHTML = embedHTML.replace(getInlineStyleReplaceSymbol(index), "<style>/* inline-style-".concat(index, " */").concat(content, "</style>"));
|
1141
|
-
}
|
1142
|
-
});
|
1143
|
-
})).then(function() {
|
1144
|
-
return embedHTML;
|
1145
|
-
}));
|
1146
|
-
case 2:
|
1147
|
-
case "end":
|
1148
|
-
return _context2.stop();
|
1149
|
-
}
|
1150
|
-
}, _callee2);
|
1151
|
-
}));
|
1152
|
-
return _getEmbedHTML.apply(this, arguments);
|
1153
|
-
}
|
1154
|
-
var isInlineCode = function isInlineCode2(code) {
|
1155
|
-
return code.startsWith("<");
|
1156
|
-
};
|
1157
|
-
var fetchAssets = function fetchAssets2(src, cache, fetch, cssFlag, loadError) {
|
1158
|
-
return cache[src] || (cache[src] = fetch(src).then(function(response) {
|
1159
|
-
if (response.status >= 400) {
|
1160
|
-
cache[src] = null;
|
1161
|
-
if (cssFlag) {
|
1162
|
-
error(WUJIE_TIPS_CSS_ERROR_REQUESTED, {
|
1163
|
-
src,
|
1164
|
-
response
|
1165
|
-
});
|
1166
|
-
loadError === null || loadError === void 0 || loadError(src, new Error(WUJIE_TIPS_CSS_ERROR_REQUESTED));
|
1167
|
-
return "";
|
1168
|
-
} else {
|
1169
|
-
error(WUJIE_TIPS_SCRIPT_ERROR_REQUESTED, {
|
1170
|
-
src,
|
1171
|
-
response
|
1172
|
-
});
|
1173
|
-
loadError === null || loadError === void 0 || loadError(src, new Error(WUJIE_TIPS_SCRIPT_ERROR_REQUESTED));
|
1174
|
-
throw new Error(WUJIE_TIPS_SCRIPT_ERROR_REQUESTED);
|
1175
|
-
}
|
1176
|
-
}
|
1177
|
-
return response.text();
|
1178
|
-
})["catch"](function(e2) {
|
1179
|
-
cache[src] = null;
|
1180
|
-
if (cssFlag) {
|
1181
|
-
error(WUJIE_TIPS_CSS_ERROR_REQUESTED, src);
|
1182
|
-
loadError === null || loadError === void 0 || loadError(src, e2);
|
1183
|
-
return "";
|
1184
|
-
} else {
|
1185
|
-
error(WUJIE_TIPS_SCRIPT_ERROR_REQUESTED, src);
|
1186
|
-
loadError === null || loadError === void 0 || loadError(src, e2);
|
1187
|
-
return "";
|
1188
|
-
}
|
1189
|
-
}));
|
1190
|
-
};
|
1191
|
-
function _getExternalStyleSheets(styles) {
|
1192
|
-
var fetch = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultFetch;
|
1193
|
-
var loadError = arguments.length > 2 ? arguments[2] : void 0;
|
1194
|
-
return styles.map(function(_ref) {
|
1195
|
-
var src = _ref.src, content = _ref.content, ignore = _ref.ignore;
|
1196
|
-
if (content) {
|
1197
|
-
return {
|
1198
|
-
src: "",
|
1199
|
-
contentPromise: Promise.resolve(content)
|
1200
|
-
};
|
1201
|
-
} else if (isInlineCode(src)) {
|
1202
|
-
return {
|
1203
|
-
src: "",
|
1204
|
-
contentPromise: Promise.resolve(getInlineCode(src))
|
1205
|
-
};
|
1206
|
-
} else {
|
1207
|
-
return {
|
1208
|
-
src,
|
1209
|
-
ignore,
|
1210
|
-
contentPromise: ignore ? Promise.resolve("") : fetchAssets(src, styleCache, fetch, true, loadError)
|
1211
|
-
};
|
1212
|
-
}
|
1213
|
-
});
|
1214
|
-
}
|
1215
|
-
function _getExternalScripts(scripts) {
|
1216
|
-
var fetch = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultFetch;
|
1217
|
-
var loadError = arguments.length > 2 ? arguments[2] : void 0;
|
1218
|
-
var fiber = arguments.length > 3 ? arguments[3] : void 0;
|
1219
|
-
return scripts.map(function(script) {
|
1220
|
-
var src = script.src, async = script.async, defer = script.defer, module = script.module, ignore = script.ignore;
|
1221
|
-
var contentPromise = null;
|
1222
|
-
if ((async || defer) && src && !module) {
|
1223
|
-
contentPromise = new Promise(function(resolve, reject) {
|
1224
|
-
return fiber ? requestIdleCallback(function() {
|
1225
|
-
return fetchAssets(src, scriptCache, fetch, false, loadError).then(resolve, reject);
|
1226
|
-
}) : fetchAssets(src, scriptCache, fetch, false, loadError).then(resolve, reject);
|
1227
|
-
});
|
1228
|
-
} else if (module && src || ignore) {
|
1229
|
-
contentPromise = Promise.resolve("");
|
1230
|
-
} else if (!src) {
|
1231
|
-
contentPromise = Promise.resolve(script.content);
|
1232
|
-
} else {
|
1233
|
-
contentPromise = fetchAssets(src, scriptCache, fetch, false, loadError);
|
1234
|
-
}
|
1235
|
-
if (module && !async)
|
1236
|
-
script.defer = true;
|
1237
|
-
return _objectSpread$6(_objectSpread$6({}, script), {}, {
|
1238
|
-
contentPromise
|
1239
|
-
});
|
1240
|
-
});
|
1241
|
-
}
|
1242
|
-
function importHTML(params) {
|
1243
|
-
var _opts$fetch, _opts$fiber;
|
1244
|
-
var url = params.url, opts = params.opts, html = params.html;
|
1245
|
-
var fetch = (_opts$fetch = opts.fetch) !== null && _opts$fetch !== void 0 ? _opts$fetch : defaultFetch;
|
1246
|
-
var fiber = (_opts$fiber = opts.fiber) !== null && _opts$fiber !== void 0 ? _opts$fiber : true;
|
1247
|
-
var plugins = opts.plugins, loadError = opts.loadError;
|
1248
|
-
var htmlLoader = plugins ? compose(plugins.map(function(plugin) {
|
1249
|
-
return plugin.htmlLoader;
|
1250
|
-
})) : defaultGetTemplate;
|
1251
|
-
var jsExcludes = getEffectLoaders("jsExcludes", plugins);
|
1252
|
-
var cssExcludes = getEffectLoaders("cssExcludes", plugins);
|
1253
|
-
var jsIgnores = getEffectLoaders("jsIgnores", plugins);
|
1254
|
-
var cssIgnores = getEffectLoaders("cssIgnores", plugins);
|
1255
|
-
var getPublicPath = defaultGetPublicPath;
|
1256
|
-
var getHtmlParseResult = function getHtmlParseResult2(url2, html2, htmlLoader2) {
|
1257
|
-
return (html2 ? Promise.resolve(html2) : fetch(url2).then(function(response) {
|
1258
|
-
if (response.status >= 400) {
|
1259
|
-
error(WUJIE_TIPS_HTML_ERROR_REQUESTED, {
|
1260
|
-
url: url2,
|
1261
|
-
response
|
1262
|
-
});
|
1263
|
-
loadError === null || loadError === void 0 || loadError(url2, new Error(WUJIE_TIPS_HTML_ERROR_REQUESTED));
|
1264
|
-
return "";
|
1265
|
-
}
|
1266
|
-
return response.text();
|
1267
|
-
})["catch"](function(e2) {
|
1268
|
-
embedHTMLCache[url2] = null;
|
1269
|
-
loadError === null || loadError === void 0 || loadError(url2, e2);
|
1270
|
-
return Promise.reject(e2);
|
1271
|
-
})).then(function(html3) {
|
1272
|
-
var assetPublicPath = getPublicPath(url2);
|
1273
|
-
var _processTpl = processTpl(htmlLoader2(html3), assetPublicPath), template = _processTpl.template, scripts = _processTpl.scripts, styles = _processTpl.styles;
|
1274
|
-
return {
|
1275
|
-
template,
|
1276
|
-
assetPublicPath,
|
1277
|
-
getExternalScripts: function getExternalScripts() {
|
1278
|
-
return _getExternalScripts(scripts.filter(function(script) {
|
1279
|
-
return !script.src || !isMatchUrl(script.src, jsExcludes);
|
1280
|
-
}).map(function(script) {
|
1281
|
-
return _objectSpread$6(_objectSpread$6({}, script), {}, {
|
1282
|
-
ignore: script.src && isMatchUrl(script.src, jsIgnores)
|
1283
|
-
});
|
1284
|
-
}), fetch, loadError, fiber);
|
1285
|
-
},
|
1286
|
-
getExternalStyleSheets: function getExternalStyleSheets() {
|
1287
|
-
return _getExternalStyleSheets(styles.filter(function(style) {
|
1288
|
-
return !style.src || !isMatchUrl(style.src, cssExcludes);
|
1289
|
-
}).map(function(style) {
|
1290
|
-
return _objectSpread$6(_objectSpread$6({}, style), {}, {
|
1291
|
-
ignore: style.src && isMatchUrl(style.src, cssIgnores)
|
1292
|
-
});
|
1293
|
-
}), fetch, loadError);
|
1294
|
-
}
|
1295
|
-
};
|
1296
|
-
});
|
1297
|
-
};
|
1298
|
-
if (opts !== null && opts !== void 0 && opts.plugins.some(function(plugin) {
|
1299
|
-
return plugin.htmlLoader;
|
1300
|
-
})) {
|
1301
|
-
return getHtmlParseResult(url, html, htmlLoader);
|
1302
|
-
} else {
|
1303
|
-
return embedHTMLCache[url] || (embedHTMLCache[url] = getHtmlParseResult(url, html, htmlLoader));
|
1304
|
-
}
|
1305
|
-
}
|
1306
|
-
function _classCallCheck(a2, n2) {
|
1307
|
-
if (!(a2 instanceof n2))
|
1308
|
-
throw new TypeError("Cannot call a class as a function");
|
1309
|
-
}
|
1310
|
-
function _defineProperties(e2, r2) {
|
1311
|
-
for (var t2 = 0; t2 < r2.length; t2++) {
|
1312
|
-
var o2 = r2[t2];
|
1313
|
-
o2.enumerable = o2.enumerable || false, o2.configurable = true, "value" in o2 && (o2.writable = true), Object.defineProperty(e2, toPropertyKey(o2.key), o2);
|
1314
|
-
}
|
1315
|
-
}
|
1316
|
-
function _createClass(e2, r2, t2) {
|
1317
|
-
return r2 && _defineProperties(e2.prototype, r2), t2 && _defineProperties(e2, t2), Object.defineProperty(e2, "prototype", {
|
1318
|
-
writable: false
|
1319
|
-
}), e2;
|
1320
|
-
}
|
1321
|
-
function _setPrototypeOf(t2, e2) {
|
1322
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t3, e3) {
|
1323
|
-
return t3.__proto__ = e3, t3;
|
1324
|
-
}, _setPrototypeOf(t2, e2);
|
1325
|
-
}
|
1326
|
-
function _inherits(t2, e2) {
|
1327
|
-
if ("function" != typeof e2 && null !== e2)
|
1328
|
-
throw new TypeError("Super expression must either be null or a function");
|
1329
|
-
t2.prototype = Object.create(e2 && e2.prototype, {
|
1330
|
-
constructor: {
|
1331
|
-
value: t2,
|
1332
|
-
writable: true,
|
1333
|
-
configurable: true
|
1334
|
-
}
|
1335
|
-
}), Object.defineProperty(t2, "prototype", {
|
1336
|
-
writable: false
|
1337
|
-
}), e2 && _setPrototypeOf(t2, e2);
|
1338
|
-
}
|
1339
|
-
function _assertThisInitialized(e2) {
|
1340
|
-
if (void 0 === e2)
|
1341
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
1342
|
-
return e2;
|
1343
|
-
}
|
1344
|
-
function _possibleConstructorReturn(t2, e2) {
|
1345
|
-
if (e2 && ("object" == _typeof$2(e2) || "function" == typeof e2))
|
1346
|
-
return e2;
|
1347
|
-
if (void 0 !== e2)
|
1348
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
1349
|
-
return _assertThisInitialized(t2);
|
1350
|
-
}
|
1351
|
-
function _getPrototypeOf(t2) {
|
1352
|
-
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t3) {
|
1353
|
-
return t3.__proto__ || Object.getPrototypeOf(t3);
|
1354
|
-
}, _getPrototypeOf(t2);
|
1355
|
-
}
|
1356
|
-
function _isNativeFunction(t2) {
|
1357
|
-
try {
|
1358
|
-
return -1 !== Function.toString.call(t2).indexOf("[native code]");
|
1359
|
-
} catch (n2) {
|
1360
|
-
return "function" == typeof t2;
|
1361
|
-
}
|
1362
|
-
}
|
1363
|
-
function _isNativeReflectConstruct$1() {
|
1364
|
-
try {
|
1365
|
-
var t2 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
1366
|
-
}));
|
1367
|
-
} catch (t3) {
|
1368
|
-
}
|
1369
|
-
return (_isNativeReflectConstruct$1 = function _isNativeReflectConstruct2() {
|
1370
|
-
return !!t2;
|
1371
|
-
})();
|
1372
|
-
}
|
1373
|
-
function _construct(t2, e2, r2) {
|
1374
|
-
if (_isNativeReflectConstruct$1())
|
1375
|
-
return Reflect.construct.apply(null, arguments);
|
1376
|
-
var o2 = [null];
|
1377
|
-
o2.push.apply(o2, e2);
|
1378
|
-
var p2 = new (t2.bind.apply(t2, o2))();
|
1379
|
-
return r2 && _setPrototypeOf(p2, r2.prototype), p2;
|
1380
|
-
}
|
1381
|
-
function _wrapNativeSuper(t2) {
|
1382
|
-
var r2 = "function" == typeof Map ? /* @__PURE__ */ new Map() : void 0;
|
1383
|
-
return _wrapNativeSuper = function _wrapNativeSuper2(t3) {
|
1384
|
-
if (null === t3 || !_isNativeFunction(t3))
|
1385
|
-
return t3;
|
1386
|
-
if ("function" != typeof t3)
|
1387
|
-
throw new TypeError("Super expression must either be null or a function");
|
1388
|
-
if (void 0 !== r2) {
|
1389
|
-
if (r2.has(t3))
|
1390
|
-
return r2.get(t3);
|
1391
|
-
r2.set(t3, Wrapper);
|
1392
|
-
}
|
1393
|
-
function Wrapper() {
|
1394
|
-
return _construct(t3, arguments, _getPrototypeOf(this).constructor);
|
1395
|
-
}
|
1396
|
-
return Wrapper.prototype = Object.create(t3.prototype, {
|
1397
|
-
constructor: {
|
1398
|
-
value: Wrapper,
|
1399
|
-
enumerable: false,
|
1400
|
-
writable: true,
|
1401
|
-
configurable: true
|
1402
|
-
}
|
1403
|
-
}), _setPrototypeOf(Wrapper, t3);
|
1404
|
-
}, _wrapNativeSuper(t2);
|
1405
|
-
}
|
1406
|
-
function ownKeys$5(e2, r2) {
|
1407
|
-
var t2 = Object.keys(e2);
|
1408
|
-
if (Object.getOwnPropertySymbols) {
|
1409
|
-
var o2 = Object.getOwnPropertySymbols(e2);
|
1410
|
-
r2 && (o2 = o2.filter(function(r3) {
|
1411
|
-
return Object.getOwnPropertyDescriptor(e2, r3).enumerable;
|
1412
|
-
})), t2.push.apply(t2, o2);
|
1413
|
-
}
|
1414
|
-
return t2;
|
1415
|
-
}
|
1416
|
-
function _objectSpread$5(e2) {
|
1417
|
-
for (var r2 = 1; r2 < arguments.length; r2++) {
|
1418
|
-
var t2 = null != arguments[r2] ? arguments[r2] : {};
|
1419
|
-
r2 % 2 ? ownKeys$5(Object(t2), true).forEach(function(r3) {
|
1420
|
-
_defineProperty(e2, r3, t2[r3]);
|
1421
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : ownKeys$5(Object(t2)).forEach(function(r3) {
|
1422
|
-
Object.defineProperty(e2, r3, Object.getOwnPropertyDescriptor(t2, r3));
|
1423
|
-
});
|
1424
|
-
}
|
1425
|
-
return e2;
|
1426
|
-
}
|
1427
|
-
var idToSandboxCacheMap = window.__POWERED_BY_WUJIE__ ? window.__WUJIE.inject.idToSandboxMap : /* @__PURE__ */ new Map();
|
1428
|
-
function getWujieById(id) {
|
1429
|
-
var _idToSandboxCacheMap$;
|
1430
|
-
return ((_idToSandboxCacheMap$ = idToSandboxCacheMap.get(id)) === null || _idToSandboxCacheMap$ === void 0 ? void 0 : _idToSandboxCacheMap$.wujie) || null;
|
1431
|
-
}
|
1432
|
-
function getOptionsById(id) {
|
1433
|
-
var _idToSandboxCacheMap$2;
|
1434
|
-
return ((_idToSandboxCacheMap$2 = idToSandboxCacheMap.get(id)) === null || _idToSandboxCacheMap$2 === void 0 ? void 0 : _idToSandboxCacheMap$2.options) || null;
|
1435
|
-
}
|
1436
|
-
function addSandboxCacheWithWujie(id, sandbox) {
|
1437
|
-
var wujieCache = idToSandboxCacheMap.get(id);
|
1438
|
-
if (wujieCache)
|
1439
|
-
idToSandboxCacheMap.set(id, _objectSpread$5(_objectSpread$5({}, wujieCache), {}, {
|
1440
|
-
wujie: sandbox
|
1441
|
-
}));
|
1442
|
-
else
|
1443
|
-
idToSandboxCacheMap.set(id, {
|
1444
|
-
wujie: sandbox
|
1445
|
-
});
|
1446
|
-
}
|
1447
|
-
function deleteWujieById(id) {
|
1448
|
-
var wujieCache = idToSandboxCacheMap.get(id);
|
1449
|
-
if (wujieCache !== null && wujieCache !== void 0 && wujieCache.options)
|
1450
|
-
idToSandboxCacheMap.set(id, {
|
1451
|
-
options: wujieCache.options
|
1452
|
-
});
|
1453
|
-
idToSandboxCacheMap["delete"](id);
|
1454
|
-
}
|
1455
|
-
function addSandboxCacheWithOptions(id, options) {
|
1456
|
-
var wujieCache = idToSandboxCacheMap.get(id);
|
1457
|
-
if (wujieCache)
|
1458
|
-
idToSandboxCacheMap.set(id, _objectSpread$5(_objectSpread$5({}, wujieCache), {}, {
|
1459
|
-
options
|
1460
|
-
}));
|
1461
|
-
else
|
1462
|
-
idToSandboxCacheMap.set(id, {
|
1463
|
-
options
|
1464
|
-
});
|
1465
|
-
}
|
1466
|
-
var documentProxyProperties = {
|
1467
|
-
// 降级场景下需要本地特殊处理的属性
|
1468
|
-
modifyLocalProperties: ["createElement", "createTextNode", "documentURI", "URL", "getElementsByTagName"],
|
1469
|
-
// 子应用需要手动修正的属性方法
|
1470
|
-
modifyProperties: ["createElement", "createTextNode", "documentURI", "URL", "getElementsByTagName", "getElementsByClassName", "getElementsByName", "getElementById", "querySelector", "querySelectorAll", "documentElement", "scrollingElement", "forms", "images", "links"],
|
1471
|
-
// 需要从shadowRoot中获取的属性
|
1472
|
-
shadowProperties: ["activeElement", "childElementCount", "children", "firstElementChild", "firstChild", "fullscreenElement", "lastElementChild", "pictureInPictureElement", "pointerLockElement", "styleSheets"],
|
1473
|
-
// 需要从shadowRoot中获取的方法
|
1474
|
-
shadowMethods: ["append", "contains", "getSelection", "elementFromPoint", "elementsFromPoint", "getAnimations", "replaceChildren"],
|
1475
|
-
// 需要从主应用document中获取的属性
|
1476
|
-
documentProperties: ["characterSet", "compatMode", "contentType", "designMode", "dir", "doctype", "embeds", "fullscreenEnabled", "hidden", "implementation", "lastModified", "pictureInPictureEnabled", "plugins", "readyState", "referrer", "visibilityState", "fonts"],
|
1477
|
-
// 需要从主应用document中获取的方法
|
1478
|
-
documentMethods: ["execCommand", "caretPositionFromPoint", "createRange", "exitFullscreen", "exitPictureInPicture", "getElementsByTagNameNS", "hasFocus", "prepend"],
|
1479
|
-
// 需要从主应用document中获取的事件
|
1480
|
-
documentEvents: ["onpointerlockchange", "onpointerlockerror", "onbeforecopy", "onbeforecut", "onbeforepaste", "onfreeze", "onresume", "onsearch", "onfullscreenchange", "onfullscreenerror", "onsecuritypolicyviolation", "onvisibilitychange"],
|
1481
|
-
// 无需修改原型的属性
|
1482
|
-
ownerProperties: ["head", "body"]
|
1483
|
-
};
|
1484
|
-
var appDocumentAddEventListenerEvents = ["DOMContentLoaded", "readystatechange"];
|
1485
|
-
var appDocumentOnEvents = ["onreadystatechange"];
|
1486
|
-
var mainDocumentAddEventListenerEvents = ["fullscreenchange", "fullscreenerror", "selectionchange", "visibilitychange", "wheel", "keydown", "keypress", "keyup"];
|
1487
|
-
var mainAndAppAddEventListenerEvents = ["gotpointercapture", "lostpointercapture"];
|
1488
|
-
var appWindowAddEventListenerEvents = ["hashchange", "popstate", "DOMContentLoaded", "load", "beforeunload", "unload", "message", "error", "unhandledrejection"];
|
1489
|
-
var appWindowOnEvent = ["onload", "onbeforeunload", "onunload"];
|
1490
|
-
var relativeElementTagAttrMap = {
|
1491
|
-
IMG: "src",
|
1492
|
-
A: "href",
|
1493
|
-
SOURCE: "src"
|
1494
|
-
};
|
1495
|
-
var windowProxyProperties = ["getComputedStyle", "visualViewport", "matchMedia", "DOMParser"];
|
1496
|
-
var windowRegWhiteList = [/animationFrame$/i, /resizeObserver$|mutationObserver$|intersectionObserver$/i, /height$|width$|left$/i, /^screen/i, /X$|Y$/];
|
1497
|
-
var rawElementAppendChild = HTMLElement.prototype.appendChild;
|
1498
|
-
var rawElementRemoveChild = HTMLElement.prototype.removeChild;
|
1499
|
-
var rawElementContains = HTMLElement.prototype.contains;
|
1500
|
-
var rawHeadInsertBefore = HTMLHeadElement.prototype.insertBefore;
|
1501
|
-
var rawBodyInsertBefore = HTMLBodyElement.prototype.insertBefore;
|
1502
|
-
var rawAddEventListener = Node.prototype.addEventListener;
|
1503
|
-
var rawRemoveEventListener = Node.prototype.removeEventListener;
|
1504
|
-
var rawWindowAddEventListener = window.addEventListener;
|
1505
|
-
var rawWindowRemoveEventListener = window.removeEventListener;
|
1506
|
-
var rawAppendChild = Node.prototype.appendChild;
|
1507
|
-
var rawDocumentQuerySelector = window.__POWERED_BY_WUJIE__ ? window.__WUJIE_RAW_DOCUMENT_QUERY_SELECTOR__ : Document.prototype.querySelector;
|
1508
|
-
function ownKeys$4(e2, r2) {
|
1509
|
-
var t2 = Object.keys(e2);
|
1510
|
-
if (Object.getOwnPropertySymbols) {
|
1511
|
-
var o2 = Object.getOwnPropertySymbols(e2);
|
1512
|
-
r2 && (o2 = o2.filter(function(r3) {
|
1513
|
-
return Object.getOwnPropertyDescriptor(e2, r3).enumerable;
|
1514
|
-
})), t2.push.apply(t2, o2);
|
1515
|
-
}
|
1516
|
-
return t2;
|
1517
|
-
}
|
1518
|
-
function _objectSpread$4(e2) {
|
1519
|
-
for (var r2 = 1; r2 < arguments.length; r2++) {
|
1520
|
-
var t2 = null != arguments[r2] ? arguments[r2] : {};
|
1521
|
-
r2 % 2 ? ownKeys$4(Object(t2), true).forEach(function(r3) {
|
1522
|
-
_defineProperty(e2, r3, t2[r3]);
|
1523
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : ownKeys$4(Object(t2)).forEach(function(r3) {
|
1524
|
-
Object.defineProperty(e2, r3, Object.getOwnPropertyDescriptor(t2, r3));
|
1525
|
-
});
|
1526
|
-
}
|
1527
|
-
return e2;
|
1528
|
-
}
|
1529
|
-
function patchCustomEvent(e2, elementGetter) {
|
1530
|
-
Object.defineProperties(e2, {
|
1531
|
-
srcElement: {
|
1532
|
-
get: elementGetter
|
1533
|
-
},
|
1534
|
-
target: {
|
1535
|
-
get: elementGetter
|
1536
|
-
}
|
1537
|
-
});
|
1538
|
-
return e2;
|
1539
|
-
}
|
1540
|
-
function manualInvokeElementEvent(element, event) {
|
1541
|
-
var customEvent = new CustomEvent(event);
|
1542
|
-
var patchedEvent = patchCustomEvent(customEvent, function() {
|
1543
|
-
return element;
|
1544
|
-
});
|
1545
|
-
if (isFunction(element["on".concat(event)])) {
|
1546
|
-
element["on".concat(event)](patchedEvent);
|
1547
|
-
} else {
|
1548
|
-
element.dispatchEvent(patchedEvent);
|
1549
|
-
}
|
1550
|
-
}
|
1551
|
-
function handleStylesheetElementPatch(stylesheetElement, sandbox) {
|
1552
|
-
if (!stylesheetElement.innerHTML || sandbox.degrade)
|
1553
|
-
return;
|
1554
|
-
var patcher = function patcher2() {
|
1555
|
-
var _getPatchStyleElement = getPatchStyleElements([stylesheetElement.sheet]), _getPatchStyleElement2 = _slicedToArray(_getPatchStyleElement, 2), hostStyleSheetElement = _getPatchStyleElement2[0], fontStyleSheetElement = _getPatchStyleElement2[1];
|
1556
|
-
if (hostStyleSheetElement) {
|
1557
|
-
sandbox.shadowRoot.head.appendChild(hostStyleSheetElement);
|
1558
|
-
}
|
1559
|
-
if (fontStyleSheetElement) {
|
1560
|
-
sandbox.shadowRoot.host.appendChild(fontStyleSheetElement);
|
1561
|
-
}
|
1562
|
-
stylesheetElement._patcher = void 0;
|
1563
|
-
};
|
1564
|
-
if (stylesheetElement._patcher) {
|
1565
|
-
clearTimeout(stylesheetElement._patcher);
|
1566
|
-
}
|
1567
|
-
stylesheetElement._patcher = setTimeout(patcher, 50);
|
1568
|
-
}
|
1569
|
-
function patchStylesheetElement(stylesheetElement, cssLoader, sandbox, curUrl) {
|
1570
|
-
var _stylesheetElement$sh;
|
1571
|
-
if (stylesheetElement._hasPatchStyle)
|
1572
|
-
return;
|
1573
|
-
var innerHTMLDesc = Object.getOwnPropertyDescriptor(Element.prototype, "innerHTML");
|
1574
|
-
var innerTextDesc = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "innerText");
|
1575
|
-
var textContentDesc = Object.getOwnPropertyDescriptor(Node.prototype, "textContent");
|
1576
|
-
var RawInsertRule = (_stylesheetElement$sh = stylesheetElement.sheet) === null || _stylesheetElement$sh === void 0 ? void 0 : _stylesheetElement$sh.insertRule;
|
1577
|
-
function patchSheetInsertRule() {
|
1578
|
-
if (!RawInsertRule)
|
1579
|
-
return;
|
1580
|
-
stylesheetElement.sheet.insertRule = function(rule, index) {
|
1581
|
-
innerHTMLDesc ? stylesheetElement.innerHTML += rule : stylesheetElement.innerText += rule;
|
1582
|
-
return RawInsertRule.call(stylesheetElement.sheet, rule, index);
|
1583
|
-
};
|
1584
|
-
}
|
1585
|
-
patchSheetInsertRule();
|
1586
|
-
if (innerHTMLDesc) {
|
1587
|
-
Object.defineProperties(stylesheetElement, {
|
1588
|
-
innerHTML: {
|
1589
|
-
get: function get() {
|
1590
|
-
return innerHTMLDesc.get.call(stylesheetElement);
|
1591
|
-
},
|
1592
|
-
set: function set(code) {
|
1593
|
-
var _this = this;
|
1594
|
-
innerHTMLDesc.set.call(stylesheetElement, cssLoader(code, "", curUrl));
|
1595
|
-
nextTick(function() {
|
1596
|
-
return handleStylesheetElementPatch(_this, sandbox);
|
1597
|
-
});
|
1598
|
-
}
|
1599
|
-
}
|
1600
|
-
});
|
1601
|
-
}
|
1602
|
-
Object.defineProperties(stylesheetElement, {
|
1603
|
-
innerText: {
|
1604
|
-
get: function get() {
|
1605
|
-
return innerTextDesc.get.call(stylesheetElement);
|
1606
|
-
},
|
1607
|
-
set: function set(code) {
|
1608
|
-
var _this2 = this;
|
1609
|
-
innerTextDesc.set.call(stylesheetElement, cssLoader(code, "", curUrl));
|
1610
|
-
nextTick(function() {
|
1611
|
-
return handleStylesheetElementPatch(_this2, sandbox);
|
1612
|
-
});
|
1613
|
-
}
|
1614
|
-
},
|
1615
|
-
textContent: {
|
1616
|
-
get: function get() {
|
1617
|
-
return textContentDesc.get.call(stylesheetElement);
|
1618
|
-
},
|
1619
|
-
set: function set(code) {
|
1620
|
-
var _this3 = this;
|
1621
|
-
textContentDesc.set.call(stylesheetElement, cssLoader(code, "", curUrl));
|
1622
|
-
nextTick(function() {
|
1623
|
-
return handleStylesheetElementPatch(_this3, sandbox);
|
1624
|
-
});
|
1625
|
-
}
|
1626
|
-
},
|
1627
|
-
appendChild: {
|
1628
|
-
value: function value(node) {
|
1629
|
-
var _this4 = this;
|
1630
|
-
nextTick(function() {
|
1631
|
-
return handleStylesheetElementPatch(_this4, sandbox);
|
1632
|
-
});
|
1633
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
1634
|
-
var res = rawAppendChild.call(stylesheetElement, stylesheetElement.ownerDocument.createTextNode(cssLoader(node.textContent, "", curUrl)));
|
1635
|
-
patchSheetInsertRule();
|
1636
|
-
return res;
|
1637
|
-
} else
|
1638
|
-
return rawAppendChild(node);
|
1639
|
-
}
|
1640
|
-
},
|
1641
|
-
_hasPatchStyle: {
|
1642
|
-
get: function get() {
|
1643
|
-
return true;
|
1644
|
-
}
|
1645
|
-
}
|
1646
|
-
});
|
1647
|
-
}
|
1648
|
-
var dynamicScriptExecStack = Promise.resolve();
|
1649
|
-
function rewriteAppendOrInsertChild(opts) {
|
1650
|
-
return function appendChildOrInsertBefore(newChild, refChild) {
|
1651
|
-
var _this5 = this;
|
1652
|
-
var element = newChild;
|
1653
|
-
var rawDOMAppendOrInsertBefore = opts.rawDOMAppendOrInsertBefore, wujieId = opts.wujieId;
|
1654
|
-
var sandbox = getWujieById(wujieId);
|
1655
|
-
var styleSheetElements = sandbox.styleSheetElements, replace = sandbox.replace, fetch = sandbox.fetch, plugins = sandbox.plugins, iframe = sandbox.iframe, lifecycles = sandbox.lifecycles, proxyLocation = sandbox.proxyLocation, fiber = sandbox.fiber;
|
1656
|
-
if (!isHijackingTag(element.tagName) || !wujieId) {
|
1657
|
-
var res = rawDOMAppendOrInsertBefore.call(this, element, refChild);
|
1658
|
-
patchElementEffect(element, iframe.contentWindow);
|
1659
|
-
execHooks(plugins, "appendOrInsertElementHook", element, iframe.contentWindow);
|
1660
|
-
return res;
|
1661
|
-
}
|
1662
|
-
var iframeDocument = iframe.contentDocument;
|
1663
|
-
var curUrl = getCurUrl(proxyLocation);
|
1664
|
-
if (element.tagName) {
|
1665
|
-
var _element$tagName;
|
1666
|
-
switch ((_element$tagName = element.tagName) === null || _element$tagName === void 0 ? void 0 : _element$tagName.toUpperCase()) {
|
1667
|
-
case "LINK": {
|
1668
|
-
var _ref = element, href = _ref.href, rel = _ref.rel, type = _ref.type;
|
1669
|
-
var styleFlag = rel === "stylesheet" || type === "text/css" || href.endsWith(".css");
|
1670
|
-
if (!styleFlag) {
|
1671
|
-
var _res = rawDOMAppendOrInsertBefore.call(this, element, refChild);
|
1672
|
-
execHooks(plugins, "appendOrInsertElementHook", element, iframe.contentWindow);
|
1673
|
-
return _res;
|
1674
|
-
}
|
1675
|
-
if (href && !isMatchUrl(href, getEffectLoaders("cssExcludes", plugins))) {
|
1676
|
-
_getExternalStyleSheets([{
|
1677
|
-
src: href,
|
1678
|
-
ignore: isMatchUrl(href, getEffectLoaders("cssIgnores", plugins))
|
1679
|
-
}], fetch, lifecycles.loadError).forEach(function(_ref2) {
|
1680
|
-
var src2 = _ref2.src, ignore = _ref2.ignore, contentPromise = _ref2.contentPromise;
|
1681
|
-
return contentPromise.then(function(content2) {
|
1682
|
-
var rawAttrs = parseTagAttributes(element.outerHTML);
|
1683
|
-
if (ignore && src2) {
|
1684
|
-
rawDOMAppendOrInsertBefore.call(_this5, element, refChild);
|
1685
|
-
} else {
|
1686
|
-
var stylesheetElement2 = iframeDocument.createElement("style");
|
1687
|
-
var cssLoader2 = getCssLoader({
|
1688
|
-
plugins,
|
1689
|
-
replace
|
1690
|
-
});
|
1691
|
-
stylesheetElement2.innerHTML = cssLoader2(content2, src2, curUrl);
|
1692
|
-
styleSheetElements.push(stylesheetElement2);
|
1693
|
-
setAttrsToElement(stylesheetElement2, rawAttrs);
|
1694
|
-
rawDOMAppendOrInsertBefore.call(_this5, stylesheetElement2, refChild);
|
1695
|
-
handleStylesheetElementPatch(stylesheetElement2, sandbox);
|
1696
|
-
manualInvokeElementEvent(element, "load");
|
1697
|
-
}
|
1698
|
-
element = null;
|
1699
|
-
}, function() {
|
1700
|
-
manualInvokeElementEvent(element, "error");
|
1701
|
-
element = null;
|
1702
|
-
});
|
1703
|
-
});
|
1704
|
-
}
|
1705
|
-
var comment = iframeDocument.createComment("dynamic link ".concat(href, " replaced by wujie"));
|
1706
|
-
return rawDOMAppendOrInsertBefore.call(this, comment, refChild);
|
1707
|
-
}
|
1708
|
-
case "STYLE": {
|
1709
|
-
var stylesheetElement = newChild;
|
1710
|
-
styleSheetElements.push(stylesheetElement);
|
1711
|
-
var content = stylesheetElement.innerHTML;
|
1712
|
-
var cssLoader = getCssLoader({
|
1713
|
-
plugins,
|
1714
|
-
replace
|
1715
|
-
});
|
1716
|
-
content && (stylesheetElement.innerHTML = cssLoader(content, "", curUrl));
|
1717
|
-
var _res2 = rawDOMAppendOrInsertBefore.call(this, element, refChild);
|
1718
|
-
patchStylesheetElement(stylesheetElement, cssLoader, sandbox, curUrl);
|
1719
|
-
handleStylesheetElementPatch(stylesheetElement, sandbox);
|
1720
|
-
execHooks(plugins, "appendOrInsertElementHook", element, iframe.contentWindow);
|
1721
|
-
return _res2;
|
1722
|
-
}
|
1723
|
-
case "SCRIPT": {
|
1724
|
-
setTagToScript(element);
|
1725
|
-
var _ref3 = element, src = _ref3.src, text = _ref3.text, _type = _ref3.type, crossOrigin = _ref3.crossOrigin;
|
1726
|
-
if (src && !isMatchUrl(src, getEffectLoaders("jsExcludes", plugins))) {
|
1727
|
-
var execScript = function execScript2(scriptResult) {
|
1728
|
-
if (sandbox.iframe === null)
|
1729
|
-
return warn(WUJIE_TIPS_REPEAT_RENDER);
|
1730
|
-
var onload = function onload2() {
|
1731
|
-
manualInvokeElementEvent(element, "load");
|
1732
|
-
element = null;
|
1733
|
-
};
|
1734
|
-
insertScriptToIframe(_objectSpread$4(_objectSpread$4({}, scriptResult), {}, {
|
1735
|
-
onload
|
1736
|
-
}), sandbox.iframe.contentWindow, element);
|
1737
|
-
};
|
1738
|
-
var scriptOptions = {
|
1739
|
-
src,
|
1740
|
-
module: _type === "module",
|
1741
|
-
crossorigin: crossOrigin !== null,
|
1742
|
-
crossoriginType: crossOrigin || "",
|
1743
|
-
ignore: isMatchUrl(src, getEffectLoaders("jsIgnores", plugins)),
|
1744
|
-
attrs: parseTagAttributes(element.outerHTML)
|
1745
|
-
};
|
1746
|
-
_getExternalScripts([scriptOptions], fetch, lifecycles.loadError, fiber).forEach(function(scriptResult) {
|
1747
|
-
dynamicScriptExecStack = dynamicScriptExecStack.then(function() {
|
1748
|
-
return scriptResult.contentPromise.then(function(content2) {
|
1749
|
-
var _sandbox$execQueue;
|
1750
|
-
if (sandbox.execQueue === null)
|
1751
|
-
return warn(WUJIE_TIPS_REPEAT_RENDER);
|
1752
|
-
var execQueueLength2 = (_sandbox$execQueue = sandbox.execQueue) === null || _sandbox$execQueue === void 0 ? void 0 : _sandbox$execQueue.length;
|
1753
|
-
sandbox.execQueue.push(function() {
|
1754
|
-
return fiber ? sandbox.requestIdleCallback(function() {
|
1755
|
-
execScript(_objectSpread$4(_objectSpread$4({}, scriptResult), {}, {
|
1756
|
-
content: content2
|
1757
|
-
}));
|
1758
|
-
}) : execScript(_objectSpread$4(_objectSpread$4({}, scriptResult), {}, {
|
1759
|
-
content: content2
|
1760
|
-
}));
|
1761
|
-
});
|
1762
|
-
if (!execQueueLength2)
|
1763
|
-
sandbox.execQueue.shift()();
|
1764
|
-
}, function() {
|
1765
|
-
manualInvokeElementEvent(element, "error");
|
1766
|
-
element = null;
|
1767
|
-
});
|
1768
|
-
});
|
1769
|
-
});
|
1770
|
-
} else {
|
1771
|
-
var _sandbox$execQueue2;
|
1772
|
-
var execQueueLength = (_sandbox$execQueue2 = sandbox.execQueue) === null || _sandbox$execQueue2 === void 0 ? void 0 : _sandbox$execQueue2.length;
|
1773
|
-
sandbox.execQueue.push(function() {
|
1774
|
-
return fiber ? sandbox.requestIdleCallback(function() {
|
1775
|
-
insertScriptToIframe({
|
1776
|
-
src: null,
|
1777
|
-
content: text,
|
1778
|
-
attrs: parseTagAttributes(element.outerHTML)
|
1779
|
-
}, sandbox.iframe.contentWindow, element);
|
1780
|
-
}) : insertScriptToIframe({
|
1781
|
-
src: null,
|
1782
|
-
content: text,
|
1783
|
-
attrs: parseTagAttributes(element.outerHTML)
|
1784
|
-
}, sandbox.iframe.contentWindow, element);
|
1785
|
-
});
|
1786
|
-
if (!execQueueLength)
|
1787
|
-
sandbox.execQueue.shift()();
|
1788
|
-
}
|
1789
|
-
var _comment = iframeDocument.createComment("dynamic script ".concat(src, " replaced by wujie"));
|
1790
|
-
return rawDOMAppendOrInsertBefore.call(this, _comment, refChild);
|
1791
|
-
}
|
1792
|
-
case "IFRAME": {
|
1793
|
-
if (element.getAttribute(WUJIE_DATA_FLAG) === "") {
|
1794
|
-
return rawAppendChild.call(rawDocumentQuerySelector.call(this.ownerDocument, "html"), element);
|
1795
|
-
}
|
1796
|
-
var _res3 = rawDOMAppendOrInsertBefore.call(this, element, refChild);
|
1797
|
-
execHooks(plugins, "appendOrInsertElementHook", element, iframe.contentWindow);
|
1798
|
-
return _res3;
|
1799
|
-
}
|
1800
|
-
}
|
1801
|
-
}
|
1802
|
-
};
|
1803
|
-
}
|
1804
|
-
function findScriptElementFromIframe(rawElement, wujieId) {
|
1805
|
-
var wujieTag = getTagFromScript(rawElement);
|
1806
|
-
var sandbox = getWujieById(wujieId);
|
1807
|
-
var iframe = sandbox.iframe;
|
1808
|
-
var targetScript = iframe.contentWindow.__WUJIE_RAW_DOCUMENT_HEAD__.querySelector("script[".concat(WUJIE_SCRIPT_ID, "='").concat(wujieTag, "']"));
|
1809
|
-
if (targetScript === null) {
|
1810
|
-
warn(WUJIE_TIPS_NO_SCRIPT, "<script ".concat(WUJIE_SCRIPT_ID, "='").concat(wujieTag, "'/>"));
|
1811
|
-
}
|
1812
|
-
return {
|
1813
|
-
targetScript,
|
1814
|
-
iframe
|
1815
|
-
};
|
1816
|
-
}
|
1817
|
-
function rewriteContains(opts) {
|
1818
|
-
return function contains(other) {
|
1819
|
-
var element = other;
|
1820
|
-
var rawElementContains2 = opts.rawElementContains, wujieId = opts.wujieId;
|
1821
|
-
if (element && isScriptElement(element)) {
|
1822
|
-
var _findScriptElementFro = findScriptElementFromIframe(element, wujieId), targetScript = _findScriptElementFro.targetScript;
|
1823
|
-
return targetScript !== null;
|
1824
|
-
}
|
1825
|
-
return rawElementContains2(element);
|
1826
|
-
};
|
1827
|
-
}
|
1828
|
-
function rewriteRemoveChild(opts) {
|
1829
|
-
return function removeChild(child) {
|
1830
|
-
var element = child;
|
1831
|
-
var rawElementRemoveChild2 = opts.rawElementRemoveChild, wujieId = opts.wujieId;
|
1832
|
-
if (element && isScriptElement(element)) {
|
1833
|
-
var _findScriptElementFro2 = findScriptElementFromIframe(element, wujieId), targetScript = _findScriptElementFro2.targetScript, iframe = _findScriptElementFro2.iframe;
|
1834
|
-
if (targetScript !== null) {
|
1835
|
-
return iframe.contentWindow.__WUJIE_RAW_DOCUMENT_HEAD__.removeChild(targetScript);
|
1836
|
-
}
|
1837
|
-
return null;
|
1838
|
-
}
|
1839
|
-
return rawElementRemoveChild2(element);
|
1840
|
-
};
|
1841
|
-
}
|
1842
|
-
function patchEventListener(element) {
|
1843
|
-
var listenerMap = /* @__PURE__ */ new Map();
|
1844
|
-
element._cacheListeners = listenerMap;
|
1845
|
-
element.addEventListener = function(type, listener, options) {
|
1846
|
-
var listeners = listenerMap.get(type) || [];
|
1847
|
-
listenerMap.set(type, [].concat(_toConsumableArray(listeners), [listener]));
|
1848
|
-
return rawAddEventListener.call(element, type, listener, options);
|
1849
|
-
};
|
1850
|
-
element.removeEventListener = function(type, listener, options) {
|
1851
|
-
var typeListeners = listenerMap.get(type);
|
1852
|
-
var index = typeListeners === null || typeListeners === void 0 ? void 0 : typeListeners.indexOf(listener);
|
1853
|
-
if (typeListeners !== null && typeListeners !== void 0 && typeListeners.length && index !== -1) {
|
1854
|
-
typeListeners.splice(index, 1);
|
1855
|
-
}
|
1856
|
-
return rawRemoveEventListener.call(element, type, listener, options);
|
1857
|
-
};
|
1858
|
-
}
|
1859
|
-
function removeEventListener(element) {
|
1860
|
-
var listenerMap = element._cacheListeners;
|
1861
|
-
_toConsumableArray(listenerMap.entries()).forEach(function(_ref4) {
|
1862
|
-
var _ref5 = _slicedToArray(_ref4, 2), type = _ref5[0], listeners = _ref5[1];
|
1863
|
-
listeners.forEach(function(listener) {
|
1864
|
-
return rawRemoveEventListener.call(element, type, listener);
|
1865
|
-
});
|
1866
|
-
});
|
1867
|
-
}
|
1868
|
-
function patchRenderEffect(render2, id, degrade) {
|
1869
|
-
if (!degrade) {
|
1870
|
-
patchEventListener(render2.head);
|
1871
|
-
patchEventListener(render2.body);
|
1872
|
-
}
|
1873
|
-
render2.head.appendChild = rewriteAppendOrInsertChild({
|
1874
|
-
rawDOMAppendOrInsertBefore: rawAppendChild,
|
1875
|
-
wujieId: id
|
1876
|
-
});
|
1877
|
-
render2.head.insertBefore = rewriteAppendOrInsertChild({
|
1878
|
-
rawDOMAppendOrInsertBefore: rawHeadInsertBefore,
|
1879
|
-
wujieId: id
|
1880
|
-
});
|
1881
|
-
render2.head.removeChild = rewriteRemoveChild({
|
1882
|
-
rawElementRemoveChild: rawElementRemoveChild.bind(render2.head),
|
1883
|
-
wujieId: id
|
1884
|
-
});
|
1885
|
-
render2.head.contains = rewriteContains({
|
1886
|
-
rawElementContains: rawElementContains.bind(render2.head),
|
1887
|
-
wujieId: id
|
1888
|
-
});
|
1889
|
-
render2.contains = rewriteContains({
|
1890
|
-
rawElementContains: rawElementContains.bind(render2),
|
1891
|
-
wujieId: id
|
1892
|
-
});
|
1893
|
-
render2.body.appendChild = rewriteAppendOrInsertChild({
|
1894
|
-
rawDOMAppendOrInsertBefore: rawAppendChild,
|
1895
|
-
wujieId: id
|
1896
|
-
});
|
1897
|
-
render2.body.insertBefore = rewriteAppendOrInsertChild({
|
1898
|
-
rawDOMAppendOrInsertBefore: rawBodyInsertBefore,
|
1899
|
-
wujieId: id
|
1900
|
-
});
|
1901
|
-
}
|
1902
|
-
function ownKeys$3(e2, r2) {
|
1903
|
-
var t2 = Object.keys(e2);
|
1904
|
-
if (Object.getOwnPropertySymbols) {
|
1905
|
-
var o2 = Object.getOwnPropertySymbols(e2);
|
1906
|
-
r2 && (o2 = o2.filter(function(r3) {
|
1907
|
-
return Object.getOwnPropertyDescriptor(e2, r3).enumerable;
|
1908
|
-
})), t2.push.apply(t2, o2);
|
1909
|
-
}
|
1910
|
-
return t2;
|
1911
|
-
}
|
1912
|
-
function _objectSpread$3(e2) {
|
1913
|
-
for (var r2 = 1; r2 < arguments.length; r2++) {
|
1914
|
-
var t2 = null != arguments[r2] ? arguments[r2] : {};
|
1915
|
-
r2 % 2 ? ownKeys$3(Object(t2), true).forEach(function(r3) {
|
1916
|
-
_defineProperty(e2, r3, t2[r3]);
|
1917
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : ownKeys$3(Object(t2)).forEach(function(r3) {
|
1918
|
-
Object.defineProperty(e2, r3, Object.getOwnPropertyDescriptor(t2, r3));
|
1919
|
-
});
|
1920
|
-
}
|
1921
|
-
return e2;
|
1922
|
-
}
|
1923
|
-
function _createSuper(Derived) {
|
1924
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
1925
|
-
return function _createSuperInternal() {
|
1926
|
-
var Super = _getPrototypeOf(Derived), result;
|
1927
|
-
if (hasNativeReflectConstruct) {
|
1928
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
1929
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
1930
|
-
} else {
|
1931
|
-
result = Super.apply(this, arguments);
|
1932
|
-
}
|
1933
|
-
return _possibleConstructorReturn(this, result);
|
1934
|
-
};
|
1935
|
-
}
|
1936
|
-
function _isNativeReflectConstruct() {
|
1937
|
-
if (typeof Reflect === "undefined" || !Reflect.construct)
|
1938
|
-
return false;
|
1939
|
-
if (Reflect.construct.sham)
|
1940
|
-
return false;
|
1941
|
-
if (typeof Proxy === "function")
|
1942
|
-
return true;
|
1943
|
-
try {
|
1944
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
1945
|
-
}));
|
1946
|
-
return true;
|
1947
|
-
} catch (e2) {
|
1948
|
-
return false;
|
1949
|
-
}
|
1950
|
-
}
|
1951
|
-
var cssSelectorMap = {
|
1952
|
-
":root": ":host"
|
1953
|
-
};
|
1954
|
-
function defineWujieWebComponent() {
|
1955
|
-
var customElements = window.customElements;
|
1956
|
-
if (customElements && !(customElements !== null && customElements !== void 0 && customElements.get("wujie-app"))) {
|
1957
|
-
var WujieApp = /* @__PURE__ */ function(_HTMLElement) {
|
1958
|
-
_inherits(WujieApp2, _HTMLElement);
|
1959
|
-
var _super = _createSuper(WujieApp2);
|
1960
|
-
function WujieApp2() {
|
1961
|
-
_classCallCheck(this, WujieApp2);
|
1962
|
-
return _super.apply(this, arguments);
|
1963
|
-
}
|
1964
|
-
_createClass(WujieApp2, [{
|
1965
|
-
key: "connectedCallback",
|
1966
|
-
value: function connectedCallback() {
|
1967
|
-
if (this.shadowRoot)
|
1968
|
-
return;
|
1969
|
-
var shadowRoot = this.attachShadow({
|
1970
|
-
mode: "open"
|
1971
|
-
});
|
1972
|
-
var sandbox = getWujieById(this.getAttribute(WUJIE_APP_ID));
|
1973
|
-
patchElementEffect(shadowRoot, sandbox.iframe.contentWindow);
|
1974
|
-
sandbox.shadowRoot = shadowRoot;
|
1975
|
-
}
|
1976
|
-
}, {
|
1977
|
-
key: "disconnectedCallback",
|
1978
|
-
value: function disconnectedCallback() {
|
1979
|
-
var sandbox = getWujieById(this.getAttribute(WUJIE_APP_ID));
|
1980
|
-
sandbox === null || sandbox === void 0 || sandbox.unmount();
|
1981
|
-
}
|
1982
|
-
}]);
|
1983
|
-
return WujieApp2;
|
1984
|
-
}(/* @__PURE__ */ _wrapNativeSuper(HTMLElement));
|
1985
|
-
customElements === null || customElements === void 0 || customElements.define("wujie-app", WujieApp);
|
1986
|
-
}
|
1987
|
-
}
|
1988
|
-
function createWujieWebComponent(id) {
|
1989
|
-
var contentElement = window.document.createElement("wujie-app");
|
1990
|
-
contentElement.setAttribute(WUJIE_APP_ID, id);
|
1991
|
-
contentElement.classList.add(WUJIE_IFRAME_CLASS);
|
1992
|
-
return contentElement;
|
1993
|
-
}
|
1994
|
-
function renderElementToContainer(element, selectorOrElement) {
|
1995
|
-
var container = getContainer(selectorOrElement);
|
1996
|
-
if (container && !container.contains(element)) {
|
1997
|
-
if (!container.querySelector("div[".concat(LOADING_DATA_FLAG, "]"))) {
|
1998
|
-
clearChild(container);
|
1999
|
-
}
|
2000
|
-
if (element) {
|
2001
|
-
rawElementAppendChild.call(container, element);
|
2002
|
-
}
|
2003
|
-
}
|
2004
|
-
return container;
|
2005
|
-
}
|
2006
|
-
function initRenderIframeAndContainer(id, parent) {
|
2007
|
-
var degradeAttrs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
2008
|
-
var iframe = createIframeContainer(id, degradeAttrs);
|
2009
|
-
var container = renderElementToContainer(iframe, parent);
|
2010
|
-
var contentDocument = iframe.contentWindow.document;
|
2011
|
-
contentDocument.open();
|
2012
|
-
contentDocument.write("<!DOCTYPE html><html><head></head><body></body></html>");
|
2013
|
-
contentDocument.close();
|
2014
|
-
return {
|
2015
|
-
iframe,
|
2016
|
-
container
|
2017
|
-
};
|
2018
|
-
}
|
2019
|
-
function processCssLoaderForTemplate(_x, _x2) {
|
2020
|
-
return _processCssLoaderForTemplate.apply(this, arguments);
|
2021
|
-
}
|
2022
|
-
function _processCssLoaderForTemplate() {
|
2023
|
-
_processCssLoaderForTemplate = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1.mark(function _callee(sandbox, html) {
|
2024
|
-
var document2, plugins, replace, proxyLocation, cssLoader, cssBeforeLoaders, cssAfterLoaders, curUrl;
|
2025
|
-
return _regeneratorRuntime$1.wrap(function _callee$(_context) {
|
2026
|
-
while (1)
|
2027
|
-
switch (_context.prev = _context.next) {
|
2028
|
-
case 0:
|
2029
|
-
document2 = sandbox.iframe.contentDocument;
|
2030
|
-
plugins = sandbox.plugins, replace = sandbox.replace, proxyLocation = sandbox.proxyLocation;
|
2031
|
-
cssLoader = getCssLoader({
|
2032
|
-
plugins,
|
2033
|
-
replace
|
2034
|
-
});
|
2035
|
-
cssBeforeLoaders = getPresetLoaders("cssBeforeLoaders", plugins);
|
2036
|
-
cssAfterLoaders = getPresetLoaders("cssAfterLoaders", plugins);
|
2037
|
-
curUrl = getCurUrl(proxyLocation);
|
2038
|
-
_context.next = 8;
|
2039
|
-
return Promise.all([Promise.all(_getExternalStyleSheets(cssBeforeLoaders, sandbox.fetch, sandbox.lifecycles.loadError).map(function(_ref) {
|
2040
|
-
var src = _ref.src, contentPromise = _ref.contentPromise;
|
2041
|
-
return contentPromise.then(function(content) {
|
2042
|
-
return {
|
2043
|
-
src,
|
2044
|
-
content
|
2045
|
-
};
|
2046
|
-
});
|
2047
|
-
})).then(function(contentList) {
|
2048
|
-
contentList.forEach(function(_ref2) {
|
2049
|
-
var src = _ref2.src, content = _ref2.content;
|
2050
|
-
if (!content)
|
2051
|
-
return;
|
2052
|
-
var styleElement = document2.createElement("style");
|
2053
|
-
styleElement.setAttribute("type", "text/css");
|
2054
|
-
styleElement.appendChild(document2.createTextNode(content ? cssLoader(content, src, curUrl) : content));
|
2055
|
-
var head = html.querySelector("head");
|
2056
|
-
var body = html.querySelector("body");
|
2057
|
-
html.insertBefore(styleElement, head || body || html.firstChild);
|
2058
|
-
});
|
2059
|
-
}), Promise.all(_getExternalStyleSheets(cssAfterLoaders, sandbox.fetch, sandbox.lifecycles.loadError).map(function(_ref3) {
|
2060
|
-
var src = _ref3.src, contentPromise = _ref3.contentPromise;
|
2061
|
-
return contentPromise.then(function(content) {
|
2062
|
-
return {
|
2063
|
-
src,
|
2064
|
-
content
|
2065
|
-
};
|
2066
|
-
});
|
2067
|
-
})).then(function(contentList) {
|
2068
|
-
contentList.forEach(function(_ref4) {
|
2069
|
-
var src = _ref4.src, content = _ref4.content;
|
2070
|
-
if (!content)
|
2071
|
-
return;
|
2072
|
-
var styleElement = document2.createElement("style");
|
2073
|
-
styleElement.setAttribute("type", "text/css");
|
2074
|
-
styleElement.appendChild(document2.createTextNode(content ? cssLoader(content, src, curUrl) : content));
|
2075
|
-
html.appendChild(styleElement);
|
2076
|
-
});
|
2077
|
-
})]).then(function() {
|
2078
|
-
return html;
|
2079
|
-
}, function() {
|
2080
|
-
return html;
|
2081
|
-
});
|
2082
|
-
case 8:
|
2083
|
-
return _context.abrupt("return", _context.sent);
|
2084
|
-
case 9:
|
2085
|
-
case "end":
|
2086
|
-
return _context.stop();
|
2087
|
-
}
|
2088
|
-
}, _callee);
|
2089
|
-
}));
|
2090
|
-
return _processCssLoaderForTemplate.apply(this, arguments);
|
2091
|
-
}
|
2092
|
-
function replaceHeadAndBody(html, head, body) {
|
2093
|
-
var headElement = html.querySelector("head");
|
2094
|
-
var bodyElement = html.querySelector("body");
|
2095
|
-
if (headElement) {
|
2096
|
-
while (headElement.firstChild) {
|
2097
|
-
rawAppendChild.call(head, headElement.firstChild.cloneNode(true));
|
2098
|
-
headElement.removeChild(headElement.firstChild);
|
2099
|
-
}
|
2100
|
-
headElement.parentNode.replaceChild(head, headElement);
|
2101
|
-
}
|
2102
|
-
if (bodyElement) {
|
2103
|
-
while (bodyElement.firstChild) {
|
2104
|
-
rawAppendChild.call(body, bodyElement.firstChild.cloneNode(true));
|
2105
|
-
bodyElement.removeChild(bodyElement.firstChild);
|
2106
|
-
}
|
2107
|
-
bodyElement.parentNode.replaceChild(body, bodyElement);
|
2108
|
-
}
|
2109
|
-
return html;
|
2110
|
-
}
|
2111
|
-
function renderTemplateToHtml(iframeWindow, template) {
|
2112
|
-
var sandbox = iframeWindow.__WUJIE;
|
2113
|
-
var head = sandbox.head, body = sandbox.body, alive = sandbox.alive, execFlag = sandbox.execFlag;
|
2114
|
-
var document2 = iframeWindow.document;
|
2115
|
-
var html = document2.createElement("html");
|
2116
|
-
html.innerHTML = template;
|
2117
|
-
if (!alive && execFlag) {
|
2118
|
-
html = replaceHeadAndBody(html, head, body);
|
2119
|
-
} else {
|
2120
|
-
sandbox.head = html.querySelector("head");
|
2121
|
-
sandbox.body = html.querySelector("body");
|
2122
|
-
}
|
2123
|
-
var ElementIterator = document2.createTreeWalker(html, NodeFilter.SHOW_ELEMENT, null, false);
|
2124
|
-
var nextElement = ElementIterator.currentNode;
|
2125
|
-
while (nextElement) {
|
2126
|
-
patchElementEffect(nextElement, iframeWindow);
|
2127
|
-
var relativeAttr = relativeElementTagAttrMap[nextElement.tagName];
|
2128
|
-
var url = nextElement[relativeAttr];
|
2129
|
-
if (relativeAttr)
|
2130
|
-
nextElement.setAttribute(relativeAttr, getAbsolutePath(url, nextElement.baseURI || ""));
|
2131
|
-
nextElement = ElementIterator.nextNode();
|
2132
|
-
}
|
2133
|
-
if (!html.querySelector("head")) {
|
2134
|
-
var _head = document2.createElement("head");
|
2135
|
-
html.appendChild(_head);
|
2136
|
-
}
|
2137
|
-
if (!html.querySelector("body")) {
|
2138
|
-
var _body = document2.createElement("body");
|
2139
|
-
html.appendChild(_body);
|
2140
|
-
}
|
2141
|
-
return html;
|
2142
|
-
}
|
2143
|
-
function renderTemplateToShadowRoot(_x3, _x4, _x5) {
|
2144
|
-
return _renderTemplateToShadowRoot.apply(this, arguments);
|
2145
|
-
}
|
2146
|
-
function _renderTemplateToShadowRoot() {
|
2147
|
-
_renderTemplateToShadowRoot = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1.mark(function _callee2(shadowRoot, iframeWindow, template) {
|
2148
|
-
var html, processedHtml, shade;
|
2149
|
-
return _regeneratorRuntime$1.wrap(function _callee2$(_context2) {
|
2150
|
-
while (1)
|
2151
|
-
switch (_context2.prev = _context2.next) {
|
2152
|
-
case 0:
|
2153
|
-
html = renderTemplateToHtml(iframeWindow, template);
|
2154
|
-
_context2.next = 3;
|
2155
|
-
return processCssLoaderForTemplate(iframeWindow.__WUJIE, html);
|
2156
|
-
case 3:
|
2157
|
-
processedHtml = _context2.sent;
|
2158
|
-
shadowRoot.appendChild(processedHtml);
|
2159
|
-
shade = document.createElement("div");
|
2160
|
-
shade.setAttribute("style", WUJIE_SHADE_STYLE);
|
2161
|
-
processedHtml.insertBefore(shade, processedHtml.firstChild);
|
2162
|
-
shadowRoot.head = shadowRoot.querySelector("head");
|
2163
|
-
shadowRoot.body = shadowRoot.querySelector("body");
|
2164
|
-
Object.defineProperty(shadowRoot.firstChild, "parentNode", {
|
2165
|
-
enumerable: true,
|
2166
|
-
configurable: true,
|
2167
|
-
get: function get() {
|
2168
|
-
return iframeWindow.document;
|
2169
|
-
}
|
2170
|
-
});
|
2171
|
-
patchRenderEffect(shadowRoot, iframeWindow.__WUJIE.id, false);
|
2172
|
-
case 12:
|
2173
|
-
case "end":
|
2174
|
-
return _context2.stop();
|
2175
|
-
}
|
2176
|
-
}, _callee2);
|
2177
|
-
}));
|
2178
|
-
return _renderTemplateToShadowRoot.apply(this, arguments);
|
2179
|
-
}
|
2180
|
-
function createIframeContainer(id) {
|
2181
|
-
var degradeAttrs = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
2182
|
-
var iframe = document.createElement("iframe");
|
2183
|
-
var defaultStyle = "height:100%;width:100%";
|
2184
|
-
setAttrsToElement(iframe, _objectSpread$3(_objectSpread$3({}, degradeAttrs), {}, _defineProperty({
|
2185
|
-
style: [defaultStyle, degradeAttrs.style].join(";")
|
2186
|
-
}, WUJIE_APP_ID, id)));
|
2187
|
-
return iframe;
|
2188
|
-
}
|
2189
|
-
function renderTemplateToIframe(_x6, _x7, _x8) {
|
2190
|
-
return _renderTemplateToIframe.apply(this, arguments);
|
2191
|
-
}
|
2192
|
-
function _renderTemplateToIframe() {
|
2193
|
-
_renderTemplateToIframe = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1.mark(function _callee3(renderDocument, iframeWindow, template) {
|
2194
|
-
var html, processedHtml;
|
2195
|
-
return _regeneratorRuntime$1.wrap(function _callee3$(_context3) {
|
2196
|
-
while (1)
|
2197
|
-
switch (_context3.prev = _context3.next) {
|
2198
|
-
case 0:
|
2199
|
-
html = renderTemplateToHtml(iframeWindow, template);
|
2200
|
-
_context3.next = 3;
|
2201
|
-
return processCssLoaderForTemplate(iframeWindow.__WUJIE, html);
|
2202
|
-
case 3:
|
2203
|
-
processedHtml = _context3.sent;
|
2204
|
-
renderDocument.replaceChild(processedHtml, renderDocument.documentElement);
|
2205
|
-
Object.defineProperty(renderDocument.documentElement, "parentNode", {
|
2206
|
-
enumerable: true,
|
2207
|
-
configurable: true,
|
2208
|
-
get: function get() {
|
2209
|
-
return iframeWindow.document;
|
2210
|
-
}
|
2211
|
-
});
|
2212
|
-
patchRenderEffect(renderDocument, iframeWindow.__WUJIE.id, true);
|
2213
|
-
case 7:
|
2214
|
-
case "end":
|
2215
|
-
return _context3.stop();
|
2216
|
-
}
|
2217
|
-
}, _callee3);
|
2218
|
-
}));
|
2219
|
-
return _renderTemplateToIframe.apply(this, arguments);
|
2220
|
-
}
|
2221
|
-
function clearChild(root) {
|
2222
|
-
while (root !== null && root !== void 0 && root.firstChild) {
|
2223
|
-
rawElementRemoveChild.call(root, root.firstChild);
|
2224
|
-
}
|
2225
|
-
}
|
2226
|
-
function addLoading(el, loading) {
|
2227
|
-
var container = getContainer(el);
|
2228
|
-
clearChild(container);
|
2229
|
-
var containerStyles = null;
|
2230
|
-
try {
|
2231
|
-
containerStyles = window.getComputedStyle(container);
|
2232
|
-
} catch (_unused) {
|
2233
|
-
return;
|
2234
|
-
}
|
2235
|
-
if (containerStyles.position === "static") {
|
2236
|
-
container.setAttribute(CONTAINER_POSITION_DATA_FLAG, containerStyles.position);
|
2237
|
-
container.setAttribute(CONTAINER_OVERFLOW_DATA_FLAG, containerStyles.overflow === "visible" ? "" : containerStyles.overflow);
|
2238
|
-
container.style.setProperty("position", "relative");
|
2239
|
-
container.style.setProperty("overflow", "hidden");
|
2240
|
-
} else if (["relative", "sticky"].includes(containerStyles.position)) {
|
2241
|
-
container.setAttribute(CONTAINER_OVERFLOW_DATA_FLAG, containerStyles.overflow === "visible" ? "" : containerStyles.overflow);
|
2242
|
-
container.style.setProperty("overflow", "hidden");
|
2243
|
-
}
|
2244
|
-
var loadingContainer = document.createElement("div");
|
2245
|
-
loadingContainer.setAttribute(LOADING_DATA_FLAG, "");
|
2246
|
-
loadingContainer.setAttribute("style", WUJIE_LOADING_STYLE);
|
2247
|
-
if (loading)
|
2248
|
-
loadingContainer.appendChild(loading);
|
2249
|
-
else
|
2250
|
-
loadingContainer.innerHTML = WUJIE_LOADING_SVG;
|
2251
|
-
container.appendChild(loadingContainer);
|
2252
|
-
}
|
2253
|
-
function removeLoading(el) {
|
2254
|
-
var positionFlag = el.getAttribute(CONTAINER_POSITION_DATA_FLAG);
|
2255
|
-
var overflowFlag = el.getAttribute(CONTAINER_OVERFLOW_DATA_FLAG);
|
2256
|
-
if (positionFlag)
|
2257
|
-
el.style.removeProperty("position");
|
2258
|
-
if (overflowFlag !== null) {
|
2259
|
-
overflowFlag ? el.style.setProperty("overflow", overflowFlag) : el.style.removeProperty("overflow");
|
2260
|
-
}
|
2261
|
-
el.removeAttribute(CONTAINER_POSITION_DATA_FLAG);
|
2262
|
-
el.removeAttribute(CONTAINER_OVERFLOW_DATA_FLAG);
|
2263
|
-
var loadingContainer = el.querySelector("div[".concat(LOADING_DATA_FLAG, "]"));
|
2264
|
-
loadingContainer && el.removeChild(loadingContainer);
|
2265
|
-
}
|
2266
|
-
function getPatchStyleElements(rootStyleSheets) {
|
2267
|
-
var rootCssRules = [];
|
2268
|
-
var fontCssRules = [];
|
2269
|
-
var rootStyleReg = /:root/g;
|
2270
|
-
for (var i2 = 0; i2 < rootStyleSheets.length; i2++) {
|
2271
|
-
var _rootStyleSheets$i$cs, _rootStyleSheets$i;
|
2272
|
-
var cssRules = (_rootStyleSheets$i$cs = (_rootStyleSheets$i = rootStyleSheets[i2]) === null || _rootStyleSheets$i === void 0 ? void 0 : _rootStyleSheets$i.cssRules) !== null && _rootStyleSheets$i$cs !== void 0 ? _rootStyleSheets$i$cs : [];
|
2273
|
-
for (var j2 = 0; j2 < cssRules.length; j2++) {
|
2274
|
-
var cssRuleText = cssRules[j2].cssText;
|
2275
|
-
if (rootStyleReg.test(cssRuleText)) {
|
2276
|
-
rootCssRules.push(cssRuleText.replace(rootStyleReg, function(match) {
|
2277
|
-
return cssSelectorMap[match];
|
2278
|
-
}));
|
2279
|
-
}
|
2280
|
-
if (cssRules[j2].type === CSSRule.FONT_FACE_RULE) {
|
2281
|
-
fontCssRules.push(cssRuleText);
|
2282
|
-
}
|
2283
|
-
}
|
2284
|
-
}
|
2285
|
-
var rootStyleSheetElement = null;
|
2286
|
-
var fontStyleSheetElement = null;
|
2287
|
-
if (rootCssRules.length) {
|
2288
|
-
rootStyleSheetElement = window.document.createElement("style");
|
2289
|
-
rootStyleSheetElement.innerHTML = rootCssRules.join("");
|
2290
|
-
}
|
2291
|
-
if (fontCssRules.length) {
|
2292
|
-
fontStyleSheetElement = window.document.createElement("style");
|
2293
|
-
fontStyleSheetElement.innerHTML = fontCssRules.join("");
|
2294
|
-
}
|
2295
|
-
return [rootStyleSheetElement, fontStyleSheetElement];
|
2296
|
-
}
|
2297
|
-
function syncUrlToWindow(iframeWindow) {
|
2298
|
-
var _iframeWindow$__WUJIE = iframeWindow.__WUJIE, sync = _iframeWindow$__WUJIE.sync, id = _iframeWindow$__WUJIE.id, prefix = _iframeWindow$__WUJIE.prefix;
|
2299
|
-
var winUrlElement = anchorElementGenerator(window.location.href);
|
2300
|
-
var queryMap = getAnchorElementQueryMap(winUrlElement);
|
2301
|
-
if (!sync && !queryMap[id])
|
2302
|
-
return winUrlElement = null;
|
2303
|
-
var curUrl = iframeWindow.location.pathname + iframeWindow.location.search + iframeWindow.location.hash;
|
2304
|
-
var validShortPath = "";
|
2305
|
-
if (prefix) {
|
2306
|
-
Object.keys(prefix).forEach(function(shortPath) {
|
2307
|
-
var longPath = prefix[shortPath];
|
2308
|
-
if (curUrl.startsWith(longPath) && (!validShortPath || longPath.length > prefix[validShortPath].length)) {
|
2309
|
-
validShortPath = shortPath;
|
2310
|
-
}
|
2311
|
-
});
|
2312
|
-
}
|
2313
|
-
if (sync) {
|
2314
|
-
queryMap[id] = window.encodeURIComponent(validShortPath ? curUrl.replace(prefix[validShortPath], "{".concat(validShortPath, "}")) : curUrl);
|
2315
|
-
} else {
|
2316
|
-
delete queryMap[id];
|
2317
|
-
}
|
2318
|
-
var newQuery = "?" + Object.keys(queryMap).map(function(key) {
|
2319
|
-
return key + "=" + queryMap[key];
|
2320
|
-
}).join("&");
|
2321
|
-
winUrlElement.search = newQuery;
|
2322
|
-
if (winUrlElement.href !== window.location.href) {
|
2323
|
-
window.history.replaceState(null, "", winUrlElement.href);
|
2324
|
-
}
|
2325
|
-
winUrlElement = null;
|
2326
|
-
}
|
2327
|
-
function syncUrlToIframe(iframeWindow) {
|
2328
|
-
var _iframeWindow$locatio = iframeWindow.location, pathname = _iframeWindow$locatio.pathname, search = _iframeWindow$locatio.search, hash = _iframeWindow$locatio.hash;
|
2329
|
-
var _iframeWindow$__WUJIE2 = iframeWindow.__WUJIE, id = _iframeWindow$__WUJIE2.id, url = _iframeWindow$__WUJIE2.url, sync = _iframeWindow$__WUJIE2.sync, execFlag = _iframeWindow$__WUJIE2.execFlag, prefix = _iframeWindow$__WUJIE2.prefix, inject = _iframeWindow$__WUJIE2.inject;
|
2330
|
-
var idUrl = sync && !execFlag ? getSyncUrl(id, prefix) : url;
|
2331
|
-
var syncUrl = (/^http/.test(idUrl) ? null : idUrl) || url;
|
2332
|
-
var _appRouteParse = appRouteParse(syncUrl), appRoutePath = _appRouteParse.appRoutePath;
|
2333
|
-
var preAppRoutePath = pathname + search + hash;
|
2334
|
-
if (preAppRoutePath !== appRoutePath) {
|
2335
|
-
iframeWindow.history.replaceState(null, "", inject.mainHostPath + appRoutePath);
|
2336
|
-
}
|
2337
|
-
}
|
2338
|
-
function clearInactiveAppUrl() {
|
2339
|
-
var winUrlElement = anchorElementGenerator(window.location.href);
|
2340
|
-
var queryMap = getAnchorElementQueryMap(winUrlElement);
|
2341
|
-
Object.keys(queryMap).forEach(function(id) {
|
2342
|
-
var sandbox = getWujieById(id);
|
2343
|
-
if (!sandbox)
|
2344
|
-
return;
|
2345
|
-
if (sandbox.execFlag && sandbox.sync && !sandbox.hrefFlag && !sandbox.activeFlag) {
|
2346
|
-
delete queryMap[id];
|
2347
|
-
}
|
2348
|
-
});
|
2349
|
-
var newQuery = "?" + Object.keys(queryMap).map(function(key) {
|
2350
|
-
return key + "=" + queryMap[key];
|
2351
|
-
}).join("&");
|
2352
|
-
winUrlElement.search = newQuery;
|
2353
|
-
if (winUrlElement.href !== window.location.href) {
|
2354
|
-
window.history.replaceState(null, "", winUrlElement.href);
|
2355
|
-
}
|
2356
|
-
winUrlElement = null;
|
2357
|
-
}
|
2358
|
-
function pushUrlToWindow(id, url) {
|
2359
|
-
var winUrlElement = anchorElementGenerator(window.location.href);
|
2360
|
-
var queryMap = getAnchorElementQueryMap(winUrlElement);
|
2361
|
-
queryMap[id] = window.encodeURIComponent(url);
|
2362
|
-
var newQuery = "?" + Object.keys(queryMap).map(function(key) {
|
2363
|
-
return key + "=" + queryMap[key];
|
2364
|
-
}).join("&");
|
2365
|
-
winUrlElement.search = newQuery;
|
2366
|
-
window.history.pushState(null, "", winUrlElement.href);
|
2367
|
-
winUrlElement = null;
|
2368
|
-
}
|
2369
|
-
function processAppForHrefJump() {
|
2370
|
-
window.addEventListener("popstate", function() {
|
2371
|
-
var winUrlElement = anchorElementGenerator(window.location.href);
|
2372
|
-
var queryMap = getAnchorElementQueryMap(winUrlElement);
|
2373
|
-
winUrlElement = null;
|
2374
|
-
Object.keys(queryMap).map(function(id) {
|
2375
|
-
return getWujieById(id);
|
2376
|
-
}).filter(function(sandbox) {
|
2377
|
-
return sandbox;
|
2378
|
-
}).forEach(function(sandbox) {
|
2379
|
-
var url = queryMap[sandbox.id];
|
2380
|
-
var iframeBody = rawDocumentQuerySelector.call(sandbox.iframe.contentDocument, "body");
|
2381
|
-
if (/http/.test(url)) {
|
2382
|
-
if (sandbox.degrade) {
|
2383
|
-
renderElementToContainer(sandbox.document.documentElement, iframeBody);
|
2384
|
-
renderIframeReplaceApp(window.decodeURIComponent(url), getDegradeIframe(sandbox.id).parentElement, sandbox.degradeAttrs);
|
2385
|
-
} else
|
2386
|
-
renderIframeReplaceApp(window.decodeURIComponent(url), sandbox.shadowRoot.host.parentElement, sandbox.degradeAttrs);
|
2387
|
-
sandbox.hrefFlag = true;
|
2388
|
-
} else if (sandbox.hrefFlag) {
|
2389
|
-
if (sandbox.degrade) {
|
2390
|
-
var _initRenderIframeAndC = initRenderIframeAndContainer(sandbox.id, sandbox.el, sandbox.degradeAttrs), iframe = _initRenderIframeAndC.iframe;
|
2391
|
-
patchEventTimeStamp(iframe.contentWindow, sandbox.iframe.contentWindow);
|
2392
|
-
iframe.contentWindow.onunload = function() {
|
2393
|
-
sandbox.unmount();
|
2394
|
-
};
|
2395
|
-
iframe.contentDocument.appendChild(iframeBody.firstElementChild);
|
2396
|
-
sandbox.document = iframe.contentDocument;
|
2397
|
-
} else
|
2398
|
-
renderElementToContainer(sandbox.shadowRoot.host, sandbox.el);
|
2399
|
-
sandbox.hrefFlag = false;
|
2400
|
-
}
|
2401
|
-
});
|
2402
|
-
});
|
2403
|
-
}
|
2404
|
-
function ownKeys$2(e2, r2) {
|
2405
|
-
var t2 = Object.keys(e2);
|
2406
|
-
if (Object.getOwnPropertySymbols) {
|
2407
|
-
var o2 = Object.getOwnPropertySymbols(e2);
|
2408
|
-
r2 && (o2 = o2.filter(function(r3) {
|
2409
|
-
return Object.getOwnPropertyDescriptor(e2, r3).enumerable;
|
2410
|
-
})), t2.push.apply(t2, o2);
|
2411
|
-
}
|
2412
|
-
return t2;
|
2413
|
-
}
|
2414
|
-
function _objectSpread$2(e2) {
|
2415
|
-
for (var r2 = 1; r2 < arguments.length; r2++) {
|
2416
|
-
var t2 = null != arguments[r2] ? arguments[r2] : {};
|
2417
|
-
r2 % 2 ? ownKeys$2(Object(t2), true).forEach(function(r3) {
|
2418
|
-
_defineProperty(e2, r3, t2[r3]);
|
2419
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : ownKeys$2(Object(t2)).forEach(function(r3) {
|
2420
|
-
Object.defineProperty(e2, r3, Object.getOwnPropertyDescriptor(t2, r3));
|
2421
|
-
});
|
2422
|
-
}
|
2423
|
-
return e2;
|
2424
|
-
}
|
2425
|
-
function patchIframeEvents(iframeWindow) {
|
2426
|
-
iframeWindow.__WUJIE_EVENTLISTENER__ = iframeWindow.__WUJIE_EVENTLISTENER__ || /* @__PURE__ */ new Set();
|
2427
|
-
iframeWindow.addEventListener = function addEventListener(type, listener, options) {
|
2428
|
-
execHooks(iframeWindow.__WUJIE.plugins, "windowAddEventListenerHook", iframeWindow, type, listener, options);
|
2429
|
-
iframeWindow.__WUJIE_EVENTLISTENER__.add({
|
2430
|
-
type,
|
2431
|
-
listener,
|
2432
|
-
options
|
2433
|
-
});
|
2434
|
-
if (appWindowAddEventListenerEvents.includes(type) || _typeof$2(options) === "object" && options.targetWindow) {
|
2435
|
-
var targetWindow = _typeof$2(options) === "object" && options.targetWindow ? options === null || options === void 0 ? void 0 : options.targetWindow : iframeWindow;
|
2436
|
-
return rawWindowAddEventListener.call(targetWindow, type, listener, options);
|
2437
|
-
}
|
2438
|
-
rawWindowAddEventListener.call(window.__WUJIE_RAW_WINDOW__ || window, type, listener, options);
|
2439
|
-
};
|
2440
|
-
iframeWindow.removeEventListener = function removeEventListener2(type, listener, options) {
|
2441
|
-
execHooks(iframeWindow.__WUJIE.plugins, "windowRemoveEventListenerHook", iframeWindow, type, listener, options);
|
2442
|
-
iframeWindow.__WUJIE_EVENTLISTENER__.forEach(function(o2) {
|
2443
|
-
if (o2.listener === listener && o2.type === type && options == o2.options) {
|
2444
|
-
iframeWindow.__WUJIE_EVENTLISTENER__["delete"](o2);
|
2445
|
-
}
|
2446
|
-
});
|
2447
|
-
if (appWindowAddEventListenerEvents.includes(type) || _typeof$2(options) === "object" && options.targetWindow) {
|
2448
|
-
var targetWindow = _typeof$2(options) === "object" && options.targetWindow ? options === null || options === void 0 ? void 0 : options.targetWindow : iframeWindow;
|
2449
|
-
return rawWindowRemoveEventListener.call(targetWindow, type, listener, options);
|
2450
|
-
}
|
2451
|
-
rawWindowRemoveEventListener.call(window.__WUJIE_RAW_WINDOW__ || window, type, listener, options);
|
2452
|
-
};
|
2453
|
-
}
|
2454
|
-
function patchIframeVariable(iframeWindow, wujie, appHostPath) {
|
2455
|
-
iframeWindow.__WUJIE = wujie;
|
2456
|
-
iframeWindow.__WUJIE_PUBLIC_PATH__ = appHostPath + "/";
|
2457
|
-
iframeWindow.$wujie = wujie.provide;
|
2458
|
-
iframeWindow.__WUJIE_RAW_WINDOW__ = iframeWindow;
|
2459
|
-
}
|
2460
|
-
function patchIframeHistory(iframeWindow, appHostPath, mainHostPath) {
|
2461
|
-
var history = iframeWindow.history;
|
2462
|
-
var rawHistoryPushState = history.pushState;
|
2463
|
-
var rawHistoryReplaceState = history.replaceState;
|
2464
|
-
history.pushState = function(data2, title, url) {
|
2465
|
-
var baseUrl = mainHostPath + iframeWindow.location.pathname + iframeWindow.location.search + iframeWindow.location.hash;
|
2466
|
-
var mainUrl = getAbsolutePath(url === null || url === void 0 ? void 0 : url.replace(appHostPath, ""), baseUrl);
|
2467
|
-
var ignoreFlag = url === void 0;
|
2468
|
-
rawHistoryPushState.call(history, data2, title, ignoreFlag ? void 0 : mainUrl);
|
2469
|
-
if (ignoreFlag)
|
2470
|
-
return;
|
2471
|
-
updateBase(iframeWindow, appHostPath, mainHostPath);
|
2472
|
-
syncUrlToWindow(iframeWindow);
|
2473
|
-
};
|
2474
|
-
history.replaceState = function(data2, title, url) {
|
2475
|
-
var baseUrl = mainHostPath + iframeWindow.location.pathname + iframeWindow.location.search + iframeWindow.location.hash;
|
2476
|
-
var mainUrl = getAbsolutePath(url === null || url === void 0 ? void 0 : url.replace(appHostPath, ""), baseUrl);
|
2477
|
-
var ignoreFlag = url === void 0;
|
2478
|
-
rawHistoryReplaceState.call(history, data2, title, ignoreFlag ? void 0 : mainUrl);
|
2479
|
-
if (ignoreFlag)
|
2480
|
-
return;
|
2481
|
-
updateBase(iframeWindow, appHostPath, mainHostPath);
|
2482
|
-
syncUrlToWindow(iframeWindow);
|
2483
|
-
};
|
2484
|
-
}
|
2485
|
-
function updateBase(iframeWindow, appHostPath, mainHostPath) {
|
2486
|
-
var _iframeWindow$locatio;
|
2487
|
-
var baseUrl = new URL((_iframeWindow$locatio = iframeWindow.location.href) === null || _iframeWindow$locatio === void 0 ? void 0 : _iframeWindow$locatio.replace(mainHostPath, ""), appHostPath);
|
2488
|
-
var baseElement = rawDocumentQuerySelector.call(iframeWindow.document, "base");
|
2489
|
-
if (baseElement)
|
2490
|
-
baseElement.setAttribute("href", appHostPath + baseUrl.pathname);
|
2491
|
-
}
|
2492
|
-
function patchWindowEffect(iframeWindow) {
|
2493
|
-
function processWindowProperty(key) {
|
2494
|
-
var value = iframeWindow[key];
|
2495
|
-
try {
|
2496
|
-
if (typeof value === "function" && !isConstructable(value)) {
|
2497
|
-
iframeWindow[key] = window[key].bind(window);
|
2498
|
-
} else {
|
2499
|
-
iframeWindow[key] = window[key];
|
2500
|
-
}
|
2501
|
-
return true;
|
2502
|
-
} catch (e2) {
|
2503
|
-
warn(e2.message);
|
2504
|
-
return false;
|
2505
|
-
}
|
2506
|
-
}
|
2507
|
-
Object.getOwnPropertyNames(iframeWindow).forEach(function(key) {
|
2508
|
-
if (key === "getSelection") {
|
2509
|
-
Object.defineProperty(iframeWindow, key, {
|
2510
|
-
get: function get() {
|
2511
|
-
return iframeWindow.document[key];
|
2512
|
-
}
|
2513
|
-
});
|
2514
|
-
return;
|
2515
|
-
}
|
2516
|
-
if (windowProxyProperties.includes(key)) {
|
2517
|
-
processWindowProperty(key);
|
2518
|
-
return;
|
2519
|
-
}
|
2520
|
-
windowRegWhiteList.some(function(reg) {
|
2521
|
-
if (reg.test(key) && key in iframeWindow.parent) {
|
2522
|
-
return processWindowProperty(key);
|
2523
|
-
}
|
2524
|
-
return false;
|
2525
|
-
});
|
2526
|
-
});
|
2527
|
-
var windowOnEvents = Object.getOwnPropertyNames(window).filter(function(p2) {
|
2528
|
-
return /^on/.test(p2);
|
2529
|
-
}).filter(function(e2) {
|
2530
|
-
return !appWindowOnEvent.includes(e2);
|
2531
|
-
});
|
2532
|
-
windowOnEvents.forEach(function(e2) {
|
2533
|
-
var descriptor = Object.getOwnPropertyDescriptor(iframeWindow, e2) || {
|
2534
|
-
enumerable: true,
|
2535
|
-
writable: true
|
2536
|
-
};
|
2537
|
-
try {
|
2538
|
-
Object.defineProperty(iframeWindow, e2, {
|
2539
|
-
enumerable: descriptor.enumerable,
|
2540
|
-
configurable: true,
|
2541
|
-
get: function get() {
|
2542
|
-
return window[e2];
|
2543
|
-
},
|
2544
|
-
set: descriptor.writable || descriptor.set ? function(handler) {
|
2545
|
-
window[e2] = typeof handler === "function" ? handler.bind(iframeWindow) : handler;
|
2546
|
-
} : void 0
|
2547
|
-
});
|
2548
|
-
} catch (e3) {
|
2549
|
-
warn(e3.message);
|
2550
|
-
}
|
2551
|
-
});
|
2552
|
-
execHooks(iframeWindow.__WUJIE.plugins, "windowPropertyOverride", iframeWindow);
|
2553
|
-
}
|
2554
|
-
function recordEventListeners(iframeWindow) {
|
2555
|
-
var sandbox = iframeWindow.__WUJIE;
|
2556
|
-
iframeWindow.Node.prototype.addEventListener = function(type, handler, options) {
|
2557
|
-
var elementListenerList = sandbox.elementEventCacheMap.get(this);
|
2558
|
-
if (elementListenerList) {
|
2559
|
-
if (!elementListenerList.find(function(listener) {
|
2560
|
-
return listener.type === type && listener.handler === handler;
|
2561
|
-
})) {
|
2562
|
-
elementListenerList.push({
|
2563
|
-
type,
|
2564
|
-
handler,
|
2565
|
-
options
|
2566
|
-
});
|
2567
|
-
}
|
2568
|
-
} else
|
2569
|
-
sandbox.elementEventCacheMap.set(this, [{
|
2570
|
-
type,
|
2571
|
-
handler,
|
2572
|
-
options
|
2573
|
-
}]);
|
2574
|
-
return rawAddEventListener.call(this, type, handler, options);
|
2575
|
-
};
|
2576
|
-
iframeWindow.Node.prototype.removeEventListener = function(type, handler, options) {
|
2577
|
-
var elementListenerList = sandbox.elementEventCacheMap.get(this);
|
2578
|
-
if (elementListenerList) {
|
2579
|
-
var index = elementListenerList === null || elementListenerList === void 0 ? void 0 : elementListenerList.findIndex(function(ele) {
|
2580
|
-
return ele.type === type && ele.handler === handler;
|
2581
|
-
});
|
2582
|
-
elementListenerList.splice(index, 1);
|
2583
|
-
}
|
2584
|
-
if (!(elementListenerList !== null && elementListenerList !== void 0 && elementListenerList.length)) {
|
2585
|
-
sandbox.elementEventCacheMap["delete"](this);
|
2586
|
-
}
|
2587
|
-
return rawRemoveEventListener.call(this, type, handler, options);
|
2588
|
-
};
|
2589
|
-
}
|
2590
|
-
function recoverEventListeners(rootElement, iframeWindow) {
|
2591
|
-
var sandbox = iframeWindow.__WUJIE;
|
2592
|
-
var elementEventCacheMap = /* @__PURE__ */ new WeakMap();
|
2593
|
-
var ElementIterator = document.createTreeWalker(rootElement, NodeFilter.SHOW_ELEMENT, null, false);
|
2594
|
-
var nextElement = ElementIterator.currentNode;
|
2595
|
-
while (nextElement) {
|
2596
|
-
var elementListenerList = sandbox.elementEventCacheMap.get(nextElement);
|
2597
|
-
if (elementListenerList !== null && elementListenerList !== void 0 && elementListenerList.length) {
|
2598
|
-
elementEventCacheMap.set(nextElement, elementListenerList);
|
2599
|
-
elementListenerList.forEach(function(listener) {
|
2600
|
-
nextElement.addEventListener(listener.type, listener.handler, listener.options);
|
2601
|
-
});
|
2602
|
-
}
|
2603
|
-
nextElement = ElementIterator.nextNode();
|
2604
|
-
}
|
2605
|
-
sandbox.elementEventCacheMap = elementEventCacheMap;
|
2606
|
-
}
|
2607
|
-
function recoverDocumentListeners(oldRootElement, newRootElement, iframeWindow) {
|
2608
|
-
var sandbox = iframeWindow.__WUJIE;
|
2609
|
-
var elementEventCacheMap = /* @__PURE__ */ new WeakMap();
|
2610
|
-
var elementListenerList = sandbox.elementEventCacheMap.get(oldRootElement);
|
2611
|
-
if (elementListenerList !== null && elementListenerList !== void 0 && elementListenerList.length) {
|
2612
|
-
elementEventCacheMap.set(newRootElement, elementListenerList);
|
2613
|
-
elementListenerList.forEach(function(listener) {
|
2614
|
-
newRootElement.addEventListener(listener.type, listener.handler, listener.options);
|
2615
|
-
});
|
2616
|
-
}
|
2617
|
-
sandbox.elementEventCacheMap = elementEventCacheMap;
|
2618
|
-
}
|
2619
|
-
function patchEventTimeStamp(targetWindow, iframeWindow) {
|
2620
|
-
Object.defineProperty(targetWindow.Event.prototype, "timeStamp", {
|
2621
|
-
get: function get() {
|
2622
|
-
return iframeWindow.document.createEvent("Event").timeStamp;
|
2623
|
-
}
|
2624
|
-
});
|
2625
|
-
}
|
2626
|
-
function patchDocumentEffect(iframeWindow) {
|
2627
|
-
var sandbox = iframeWindow.__WUJIE;
|
2628
|
-
var handlerCallbackMap = /* @__PURE__ */ new WeakMap();
|
2629
|
-
var handlerTypeMap = /* @__PURE__ */ new WeakMap();
|
2630
|
-
iframeWindow.Document.prototype.addEventListener = function(type, handler, options) {
|
2631
|
-
if (!handler)
|
2632
|
-
return;
|
2633
|
-
var callback = handlerCallbackMap.get(handler);
|
2634
|
-
var typeList = handlerTypeMap.get(handler);
|
2635
|
-
if (!callback) {
|
2636
|
-
callback = typeof handler === "function" ? handler.bind(this) : handler;
|
2637
|
-
handlerCallbackMap.set(handler, callback);
|
2638
|
-
}
|
2639
|
-
if (typeList) {
|
2640
|
-
if (!typeList.includes(type))
|
2641
|
-
typeList.push(type);
|
2642
|
-
} else {
|
2643
|
-
handlerTypeMap.set(handler, [type]);
|
2644
|
-
}
|
2645
|
-
execHooks(iframeWindow.__WUJIE.plugins, "documentAddEventListenerHook", iframeWindow, type, callback, options);
|
2646
|
-
if (appDocumentAddEventListenerEvents.includes(type)) {
|
2647
|
-
return rawAddEventListener.call(this, type, callback, options);
|
2648
|
-
}
|
2649
|
-
if (sandbox.degrade)
|
2650
|
-
return sandbox.document.addEventListener(type, callback, options);
|
2651
|
-
if (mainDocumentAddEventListenerEvents.includes(type))
|
2652
|
-
return window.document.addEventListener(type, callback, options);
|
2653
|
-
if (mainAndAppAddEventListenerEvents.includes(type)) {
|
2654
|
-
window.document.addEventListener(type, callback, options);
|
2655
|
-
sandbox.shadowRoot.addEventListener(type, callback, options);
|
2656
|
-
return;
|
2657
|
-
}
|
2658
|
-
sandbox.shadowRoot.addEventListener(type, callback, options);
|
2659
|
-
};
|
2660
|
-
iframeWindow.Document.prototype.removeEventListener = function(type, handler, options) {
|
2661
|
-
var callback = handlerCallbackMap.get(handler);
|
2662
|
-
var typeList = handlerTypeMap.get(handler);
|
2663
|
-
if (callback) {
|
2664
|
-
if (typeList !== null && typeList !== void 0 && typeList.includes(type)) {
|
2665
|
-
typeList.splice(typeList.indexOf(type), 1);
|
2666
|
-
if (!typeList.length) {
|
2667
|
-
handlerCallbackMap["delete"](handler);
|
2668
|
-
handlerTypeMap["delete"](handler);
|
2669
|
-
}
|
2670
|
-
}
|
2671
|
-
execHooks(iframeWindow.__WUJIE.plugins, "documentRemoveEventListenerHook", iframeWindow, type, callback, options);
|
2672
|
-
if (appDocumentAddEventListenerEvents.includes(type)) {
|
2673
|
-
return rawRemoveEventListener.call(this, type, callback, options);
|
2674
|
-
}
|
2675
|
-
if (sandbox.degrade)
|
2676
|
-
return sandbox.document.removeEventListener(type, callback, options);
|
2677
|
-
if (mainDocumentAddEventListenerEvents.includes(type)) {
|
2678
|
-
return window.document.removeEventListener(type, callback, options);
|
2679
|
-
}
|
2680
|
-
if (mainAndAppAddEventListenerEvents.includes(type)) {
|
2681
|
-
window.document.removeEventListener(type, callback, options);
|
2682
|
-
sandbox.shadowRoot.removeEventListener(type, callback, options);
|
2683
|
-
return;
|
2684
|
-
}
|
2685
|
-
sandbox.shadowRoot.removeEventListener(type, callback, options);
|
2686
|
-
}
|
2687
|
-
};
|
2688
|
-
var elementOnEvents = Object.keys(iframeWindow.HTMLElement.prototype).filter(function(ele) {
|
2689
|
-
return /^on/.test(ele);
|
2690
|
-
});
|
2691
|
-
var documentOnEvent = Object.keys(iframeWindow.Document.prototype).filter(function(ele) {
|
2692
|
-
return /^on/.test(ele);
|
2693
|
-
}).filter(function(ele) {
|
2694
|
-
return !appDocumentOnEvents.includes(ele);
|
2695
|
-
});
|
2696
|
-
elementOnEvents.filter(function(e2) {
|
2697
|
-
return documentOnEvent.includes(e2);
|
2698
|
-
}).forEach(function(e2) {
|
2699
|
-
var descriptor = Object.getOwnPropertyDescriptor(iframeWindow.Document.prototype, e2) || {
|
2700
|
-
enumerable: true,
|
2701
|
-
writable: true
|
2702
|
-
};
|
2703
|
-
try {
|
2704
|
-
Object.defineProperty(iframeWindow.Document.prototype, e2, {
|
2705
|
-
enumerable: descriptor.enumerable,
|
2706
|
-
configurable: true,
|
2707
|
-
get: function get() {
|
2708
|
-
return sandbox.degrade ? sandbox.document[e2] : sandbox.shadowRoot.firstElementChild[e2];
|
2709
|
-
},
|
2710
|
-
set: descriptor.writable || descriptor.set ? function(handler) {
|
2711
|
-
var val = typeof handler === "function" ? handler.bind(iframeWindow.document) : handler;
|
2712
|
-
sandbox.degrade ? sandbox.document[e2] = val : sandbox.shadowRoot.firstElementChild[e2] = val;
|
2713
|
-
} : void 0
|
2714
|
-
});
|
2715
|
-
} catch (e3) {
|
2716
|
-
warn(e3.message);
|
2717
|
-
}
|
2718
|
-
});
|
2719
|
-
var ownerProperties = documentProxyProperties.ownerProperties, modifyProperties = documentProxyProperties.modifyProperties, shadowProperties = documentProxyProperties.shadowProperties, shadowMethods = documentProxyProperties.shadowMethods, documentProperties = documentProxyProperties.documentProperties, documentMethods = documentProxyProperties.documentMethods, documentEvents = documentProxyProperties.documentEvents;
|
2720
|
-
modifyProperties.concat(shadowProperties, shadowMethods, documentProperties, documentMethods).forEach(function(propKey) {
|
2721
|
-
var descriptor = Object.getOwnPropertyDescriptor(iframeWindow.Document.prototype, propKey) || {
|
2722
|
-
enumerable: true,
|
2723
|
-
writable: true
|
2724
|
-
};
|
2725
|
-
try {
|
2726
|
-
Object.defineProperty(iframeWindow.Document.prototype, propKey, {
|
2727
|
-
enumerable: descriptor.enumerable,
|
2728
|
-
configurable: true,
|
2729
|
-
get: function get() {
|
2730
|
-
return sandbox.proxyDocument[propKey];
|
2731
|
-
},
|
2732
|
-
set: void 0
|
2733
|
-
});
|
2734
|
-
} catch (e2) {
|
2735
|
-
warn(e2.message);
|
2736
|
-
}
|
2737
|
-
});
|
2738
|
-
documentEvents.forEach(function(propKey) {
|
2739
|
-
var descriptor = Object.getOwnPropertyDescriptor(iframeWindow.Document.prototype, propKey) || {
|
2740
|
-
enumerable: true,
|
2741
|
-
writable: true
|
2742
|
-
};
|
2743
|
-
try {
|
2744
|
-
Object.defineProperty(iframeWindow.Document.prototype, propKey, {
|
2745
|
-
enumerable: descriptor.enumerable,
|
2746
|
-
configurable: true,
|
2747
|
-
get: function get() {
|
2748
|
-
return (sandbox.degrade ? sandbox : window).document[propKey];
|
2749
|
-
},
|
2750
|
-
set: descriptor.writable || descriptor.set ? function(handler) {
|
2751
|
-
(sandbox.degrade ? sandbox : window).document[propKey] = typeof handler === "function" ? handler.bind(iframeWindow.document) : handler;
|
2752
|
-
} : void 0
|
2753
|
-
});
|
2754
|
-
} catch (e2) {
|
2755
|
-
warn(e2.message);
|
2756
|
-
}
|
2757
|
-
});
|
2758
|
-
ownerProperties.forEach(function(propKey) {
|
2759
|
-
Object.defineProperty(iframeWindow.document, propKey, {
|
2760
|
-
enumerable: true,
|
2761
|
-
configurable: true,
|
2762
|
-
get: function get() {
|
2763
|
-
return sandbox.proxyDocument[propKey];
|
2764
|
-
},
|
2765
|
-
set: void 0
|
2766
|
-
});
|
2767
|
-
});
|
2768
|
-
execHooks(iframeWindow.__WUJIE.plugins, "documentPropertyOverride", iframeWindow);
|
2769
|
-
}
|
2770
|
-
function patchNodeEffect(iframeWindow) {
|
2771
|
-
var rawGetRootNode = iframeWindow.Node.prototype.getRootNode;
|
2772
|
-
var rawAppendChild2 = iframeWindow.Node.prototype.appendChild;
|
2773
|
-
var rawInsertRule = iframeWindow.Node.prototype.insertBefore;
|
2774
|
-
iframeWindow.Node.prototype.getRootNode = function(options) {
|
2775
|
-
var rootNode = rawGetRootNode.call(this, options);
|
2776
|
-
if (rootNode === iframeWindow.__WUJIE.shadowRoot)
|
2777
|
-
return iframeWindow.document;
|
2778
|
-
else
|
2779
|
-
return rootNode;
|
2780
|
-
};
|
2781
|
-
iframeWindow.Node.prototype.appendChild = function(node) {
|
2782
|
-
var res = rawAppendChild2.call(this, node);
|
2783
|
-
patchElementEffect(node, iframeWindow);
|
2784
|
-
return res;
|
2785
|
-
};
|
2786
|
-
iframeWindow.Node.prototype.insertBefore = function(node, child) {
|
2787
|
-
var res = rawInsertRule.call(this, node, child);
|
2788
|
-
patchElementEffect(node, iframeWindow);
|
2789
|
-
return res;
|
2790
|
-
};
|
2791
|
-
}
|
2792
|
-
function patchRelativeUrlEffect(iframeWindow) {
|
2793
|
-
fixElementCtrSrcOrHref(iframeWindow, iframeWindow.HTMLImageElement, "src");
|
2794
|
-
fixElementCtrSrcOrHref(iframeWindow, iframeWindow.HTMLAnchorElement, "href");
|
2795
|
-
fixElementCtrSrcOrHref(iframeWindow, iframeWindow.HTMLSourceElement, "src");
|
2796
|
-
fixElementCtrSrcOrHref(iframeWindow, iframeWindow.HTMLLinkElement, "href");
|
2797
|
-
fixElementCtrSrcOrHref(iframeWindow, iframeWindow.HTMLScriptElement, "src");
|
2798
|
-
fixElementCtrSrcOrHref(iframeWindow, iframeWindow.HTMLMediaElement, "src");
|
2799
|
-
}
|
2800
|
-
function initBase(iframeWindow, url) {
|
2801
|
-
var iframeDocument = iframeWindow.document;
|
2802
|
-
var baseElement = iframeDocument.createElement("base");
|
2803
|
-
var iframeUrlElement = anchorElementGenerator(iframeWindow.location.href);
|
2804
|
-
var appUrlElement = anchorElementGenerator(url);
|
2805
|
-
baseElement.setAttribute("href", appUrlElement.protocol + "//" + appUrlElement.host + iframeUrlElement.pathname);
|
2806
|
-
iframeDocument.head.appendChild(baseElement);
|
2807
|
-
}
|
2808
|
-
function initIframeDom(iframeWindow, wujie, mainHostPath, appHostPath) {
|
2809
|
-
var iframeDocument = iframeWindow.document;
|
2810
|
-
var newDoc = window.document.implementation.createHTMLDocument("");
|
2811
|
-
var newDocumentElement = iframeDocument.importNode(newDoc.documentElement, true);
|
2812
|
-
iframeDocument.documentElement ? iframeDocument.replaceChild(newDocumentElement, iframeDocument.documentElement) : iframeDocument.appendChild(newDocumentElement);
|
2813
|
-
iframeWindow.__WUJIE_RAW_DOCUMENT_HEAD__ = iframeDocument.head;
|
2814
|
-
iframeWindow.__WUJIE_RAW_DOCUMENT_QUERY_SELECTOR__ = iframeWindow.Document.prototype.querySelector;
|
2815
|
-
iframeWindow.__WUJIE_RAW_DOCUMENT_QUERY_SELECTOR_ALL__ = iframeWindow.Document.prototype.querySelectorAll;
|
2816
|
-
iframeWindow.__WUJIE_RAW_DOCUMENT_CREATE_ELEMENT__ = iframeWindow.Document.prototype.createElement;
|
2817
|
-
iframeWindow.__WUJIE_RAW_DOCUMENT_CREATE_TEXT_NODE__ = iframeWindow.Document.prototype.createTextNode;
|
2818
|
-
initBase(iframeWindow, wujie.url);
|
2819
|
-
patchIframeHistory(iframeWindow, appHostPath, mainHostPath);
|
2820
|
-
patchIframeEvents(iframeWindow);
|
2821
|
-
if (wujie.degrade)
|
2822
|
-
recordEventListeners(iframeWindow);
|
2823
|
-
syncIframeUrlToWindow(iframeWindow);
|
2824
|
-
patchWindowEffect(iframeWindow);
|
2825
|
-
patchDocumentEffect(iframeWindow);
|
2826
|
-
patchNodeEffect(iframeWindow);
|
2827
|
-
patchRelativeUrlEffect(iframeWindow);
|
2828
|
-
}
|
2829
|
-
function stopIframeLoading(iframeWindow) {
|
2830
|
-
var oldDoc = iframeWindow.document;
|
2831
|
-
return new Promise(function(resolve) {
|
2832
|
-
function loop() {
|
2833
|
-
setTimeout(function() {
|
2834
|
-
var newDoc;
|
2835
|
-
try {
|
2836
|
-
newDoc = iframeWindow.document;
|
2837
|
-
} catch (err) {
|
2838
|
-
newDoc = null;
|
2839
|
-
}
|
2840
|
-
if (!newDoc || newDoc == oldDoc) {
|
2841
|
-
loop();
|
2842
|
-
} else {
|
2843
|
-
iframeWindow.stop ? iframeWindow.stop() : iframeWindow.document.execCommand("Stop");
|
2844
|
-
resolve();
|
2845
|
-
}
|
2846
|
-
}, 1);
|
2847
|
-
}
|
2848
|
-
loop();
|
2849
|
-
});
|
2850
|
-
}
|
2851
|
-
function patchElementEffect(element, iframeWindow) {
|
2852
|
-
var proxyLocation = iframeWindow.__WUJIE.proxyLocation;
|
2853
|
-
if (element._hasPatch)
|
2854
|
-
return;
|
2855
|
-
try {
|
2856
|
-
Object.defineProperties(element, {
|
2857
|
-
baseURI: {
|
2858
|
-
configurable: true,
|
2859
|
-
get: function get() {
|
2860
|
-
return proxyLocation.protocol + "//" + proxyLocation.host + proxyLocation.pathname;
|
2861
|
-
},
|
2862
|
-
set: void 0
|
2863
|
-
},
|
2864
|
-
ownerDocument: {
|
2865
|
-
configurable: true,
|
2866
|
-
get: function get() {
|
2867
|
-
return iframeWindow.document;
|
2868
|
-
}
|
2869
|
-
},
|
2870
|
-
_hasPatch: {
|
2871
|
-
get: function get() {
|
2872
|
-
return true;
|
2873
|
-
}
|
2874
|
-
}
|
2875
|
-
});
|
2876
|
-
} catch (error2) {
|
2877
|
-
console.warn(error2);
|
2878
|
-
}
|
2879
|
-
execHooks(iframeWindow.__WUJIE.plugins, "patchElementHook", element, iframeWindow);
|
2880
|
-
}
|
2881
|
-
function syncIframeUrlToWindow(iframeWindow) {
|
2882
|
-
iframeWindow.addEventListener("hashchange", function() {
|
2883
|
-
return syncUrlToWindow(iframeWindow);
|
2884
|
-
});
|
2885
|
-
iframeWindow.addEventListener("popstate", function() {
|
2886
|
-
syncUrlToWindow(iframeWindow);
|
2887
|
-
});
|
2888
|
-
}
|
2889
|
-
function insertScriptToIframe(scriptResult, iframeWindow, rawElement) {
|
2890
|
-
var _ref = scriptResult, src = _ref.src, module = _ref.module, content = _ref.content, crossorigin = _ref.crossorigin, crossoriginType = _ref.crossoriginType, async = _ref.async, attrs = _ref.attrs, callback = _ref.callback, onload = _ref.onload;
|
2891
|
-
var scriptElement = iframeWindow.document.createElement("script");
|
2892
|
-
var nextScriptElement = iframeWindow.document.createElement("script");
|
2893
|
-
var _iframeWindow$__WUJIE = iframeWindow.__WUJIE, replace = _iframeWindow$__WUJIE.replace, plugins = _iframeWindow$__WUJIE.plugins, proxyLocation = _iframeWindow$__WUJIE.proxyLocation;
|
2894
|
-
var jsLoader = getJsLoader({
|
2895
|
-
plugins,
|
2896
|
-
replace
|
2897
|
-
});
|
2898
|
-
var code = jsLoader(content, src, getCurUrl(proxyLocation));
|
2899
|
-
attrs && Object.keys(attrs).filter(function(key) {
|
2900
|
-
return !Object.keys(scriptResult).includes(key);
|
2901
|
-
}).forEach(function(key) {
|
2902
|
-
return scriptElement.setAttribute(key, String(attrs[key]));
|
2903
|
-
});
|
2904
|
-
if (content) {
|
2905
|
-
if (!iframeWindow.__WUJIE.degrade && !module) {
|
2906
|
-
code = "(function(window, self, global, location) {\n ".concat(code, "\n}).bind(window.__WUJIE.proxy)(\n window.__WUJIE.proxy,\n window.__WUJIE.proxy,\n window.__WUJIE.proxy,\n window.__WUJIE.proxyLocation,\n);");
|
2907
|
-
}
|
2908
|
-
var descriptor = Object.getOwnPropertyDescriptor(scriptElement, "src");
|
2909
|
-
if (descriptor !== null && descriptor !== void 0 && descriptor.configurable || !descriptor) {
|
2910
|
-
try {
|
2911
|
-
Object.defineProperty(scriptElement, "src", {
|
2912
|
-
get: function get() {
|
2913
|
-
return src || "";
|
2914
|
-
}
|
2915
|
-
});
|
2916
|
-
} catch (error2) {
|
2917
|
-
console.warn(error2);
|
2918
|
-
}
|
2919
|
-
}
|
2920
|
-
} else {
|
2921
|
-
src && scriptElement.setAttribute("src", src);
|
2922
|
-
crossorigin && scriptElement.setAttribute("crossorigin", crossoriginType);
|
2923
|
-
}
|
2924
|
-
module && scriptElement.setAttribute("type", "module");
|
2925
|
-
scriptElement.textContent = code || "";
|
2926
|
-
nextScriptElement.textContent = "if(window.__WUJIE.execQueue && window.__WUJIE.execQueue.length){ window.__WUJIE.execQueue.shift()()}";
|
2927
|
-
var container = rawDocumentQuerySelector.call(iframeWindow.document, "head");
|
2928
|
-
var execNextScript = function execNextScript2() {
|
2929
|
-
return !async && container.appendChild(nextScriptElement);
|
2930
|
-
};
|
2931
|
-
var afterExecScript = function afterExecScript2() {
|
2932
|
-
onload === null || onload === void 0 || onload();
|
2933
|
-
execNextScript();
|
2934
|
-
};
|
2935
|
-
if (/^<!DOCTYPE html/i.test(code)) {
|
2936
|
-
error(WUJIE_TIPS_SCRIPT_ERROR_REQUESTED, scriptResult);
|
2937
|
-
return execNextScript();
|
2938
|
-
}
|
2939
|
-
if (rawElement) {
|
2940
|
-
setTagToScript(scriptElement, getTagFromScript(rawElement));
|
2941
|
-
}
|
2942
|
-
var isOutlineScript = !content && src;
|
2943
|
-
if (isOutlineScript) {
|
2944
|
-
scriptElement.onload = afterExecScript;
|
2945
|
-
scriptElement.onerror = afterExecScript;
|
2946
|
-
}
|
2947
|
-
container.appendChild(scriptElement);
|
2948
|
-
callback === null || callback === void 0 || callback(iframeWindow);
|
2949
|
-
execHooks(plugins, "appendOrInsertElementHook", scriptElement, iframeWindow, rawElement);
|
2950
|
-
!isOutlineScript && afterExecScript();
|
2951
|
-
}
|
2952
|
-
function renderIframeReplaceApp(src, element) {
|
2953
|
-
var degradeAttrs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
2954
|
-
var iframe = window.document.createElement("iframe");
|
2955
|
-
var defaultStyle = "height:100%;width:100%";
|
2956
|
-
setAttrsToElement(iframe, _objectSpread$2(_objectSpread$2({}, degradeAttrs), {}, {
|
2957
|
-
src,
|
2958
|
-
style: [defaultStyle, degradeAttrs.style].join(";")
|
2959
|
-
}));
|
2960
|
-
renderElementToContainer(iframe, element);
|
2961
|
-
}
|
2962
|
-
function iframeGenerator(sandbox, attrs, mainHostPath, appHostPath, appRoutePath) {
|
2963
|
-
var iframe = window.document.createElement("iframe");
|
2964
|
-
var attrsMerge = _objectSpread$2(_objectSpread$2({
|
2965
|
-
src: mainHostPath,
|
2966
|
-
style: "display: none"
|
2967
|
-
}, attrs), {}, _defineProperty({
|
2968
|
-
name: sandbox.id
|
2969
|
-
}, WUJIE_DATA_FLAG, ""));
|
2970
|
-
setAttrsToElement(iframe, attrsMerge);
|
2971
|
-
window.document.body.appendChild(iframe);
|
2972
|
-
var iframeWindow = iframe.contentWindow;
|
2973
|
-
patchIframeVariable(iframeWindow, sandbox, appHostPath);
|
2974
|
-
sandbox.iframeReady = stopIframeLoading(iframeWindow).then(function() {
|
2975
|
-
if (!iframeWindow.__WUJIE) {
|
2976
|
-
patchIframeVariable(iframeWindow, sandbox, appHostPath);
|
2977
|
-
}
|
2978
|
-
initIframeDom(iframeWindow, sandbox, mainHostPath, appHostPath);
|
2979
|
-
if (!isMatchSyncQueryById(iframeWindow.__WUJIE.id)) {
|
2980
|
-
iframeWindow.history.replaceState(null, "", mainHostPath + appRoutePath);
|
2981
|
-
}
|
2982
|
-
});
|
2983
|
-
return iframe;
|
2984
|
-
}
|
2985
|
-
function locationHrefSet(iframe, value, appHostPath) {
|
2986
|
-
var _iframe$contentWindow = iframe.contentWindow.__WUJIE, shadowRoot = _iframe$contentWindow.shadowRoot, id = _iframe$contentWindow.id, degrade = _iframe$contentWindow.degrade, document2 = _iframe$contentWindow.document, degradeAttrs = _iframe$contentWindow.degradeAttrs;
|
2987
|
-
var url = value;
|
2988
|
-
if (!/^http/.test(url)) {
|
2989
|
-
var hrefElement = anchorElementGenerator(url);
|
2990
|
-
url = appHostPath + hrefElement.pathname + hrefElement.search + hrefElement.hash;
|
2991
|
-
hrefElement = null;
|
2992
|
-
}
|
2993
|
-
iframe.contentWindow.__WUJIE.hrefFlag = true;
|
2994
|
-
if (degrade) {
|
2995
|
-
var iframeBody = rawDocumentQuerySelector.call(iframe.contentDocument, "body");
|
2996
|
-
renderElementToContainer(document2.documentElement, iframeBody);
|
2997
|
-
renderIframeReplaceApp(window.decodeURIComponent(url), getDegradeIframe(id).parentElement, degradeAttrs);
|
2998
|
-
} else
|
2999
|
-
renderIframeReplaceApp(url, shadowRoot.host.parentElement, degradeAttrs);
|
3000
|
-
pushUrlToWindow(id, url);
|
3001
|
-
return true;
|
3002
|
-
}
|
3003
|
-
function proxyGenerator(iframe, urlElement, mainHostPath, appHostPath) {
|
3004
|
-
var proxyWindow = new Proxy(iframe.contentWindow, {
|
3005
|
-
get: function get(target, p2) {
|
3006
|
-
if (p2 === "location") {
|
3007
|
-
return target.__WUJIE.proxyLocation;
|
3008
|
-
}
|
3009
|
-
if (p2 === "self" || p2 === "window" && Object.getOwnPropertyDescriptor(window, "window").get) {
|
3010
|
-
return target.__WUJIE.proxy;
|
3011
|
-
}
|
3012
|
-
if (p2 === "__WUJIE_RAW_DOCUMENT_QUERY_SELECTOR__" || p2 === "__WUJIE_RAW_DOCUMENT_QUERY_SELECTOR_ALL__") {
|
3013
|
-
return target[p2];
|
3014
|
-
}
|
3015
|
-
var descriptor = Object.getOwnPropertyDescriptor(target, p2);
|
3016
|
-
if ((descriptor === null || descriptor === void 0 ? void 0 : descriptor.configurable) === false && (descriptor === null || descriptor === void 0 ? void 0 : descriptor.writable) === false) {
|
3017
|
-
return target[p2];
|
3018
|
-
}
|
3019
|
-
return getTargetValue(target, p2);
|
3020
|
-
},
|
3021
|
-
set: function set(target, p2, value) {
|
3022
|
-
checkProxyFunction(value);
|
3023
|
-
target[p2] = value;
|
3024
|
-
return true;
|
3025
|
-
},
|
3026
|
-
has: function has(target, p2) {
|
3027
|
-
return p2 in target;
|
3028
|
-
}
|
3029
|
-
});
|
3030
|
-
var proxyDocument = new Proxy({}, {
|
3031
|
-
get: function get(_fakeDocument, propKey) {
|
3032
|
-
var document2 = window.document;
|
3033
|
-
var _iframe$contentWindow2 = iframe.contentWindow.__WUJIE, shadowRoot = _iframe$contentWindow2.shadowRoot, proxyLocation2 = _iframe$contentWindow2.proxyLocation;
|
3034
|
-
if (!shadowRoot)
|
3035
|
-
stopMainAppRun();
|
3036
|
-
var rawCreateElement = iframe.contentWindow.__WUJIE_RAW_DOCUMENT_CREATE_ELEMENT__;
|
3037
|
-
var rawCreateTextNode = iframe.contentWindow.__WUJIE_RAW_DOCUMENT_CREATE_TEXT_NODE__;
|
3038
|
-
if (propKey === "createElement" || propKey === "createTextNode") {
|
3039
|
-
return new Proxy(document2[propKey], {
|
3040
|
-
apply: function apply(_createElement, _ctx, args) {
|
3041
|
-
var rawCreateMethod = propKey === "createElement" ? rawCreateElement : rawCreateTextNode;
|
3042
|
-
var element = rawCreateMethod.apply(iframe.contentDocument, args);
|
3043
|
-
patchElementEffect(element, iframe.contentWindow);
|
3044
|
-
return element;
|
3045
|
-
}
|
3046
|
-
});
|
3047
|
-
}
|
3048
|
-
if (propKey === "documentURI" || propKey === "URL") {
|
3049
|
-
return proxyLocation2.href;
|
3050
|
-
}
|
3051
|
-
if (propKey === "getElementsByTagName" || propKey === "getElementsByClassName" || propKey === "getElementsByName") {
|
3052
|
-
return new Proxy(shadowRoot.querySelectorAll, {
|
3053
|
-
apply: function apply(querySelectorAll, _ctx, args) {
|
3054
|
-
var arg = args[0];
|
3055
|
-
if (_ctx !== iframe.contentDocument) {
|
3056
|
-
return _ctx[propKey].apply(_ctx, args);
|
3057
|
-
}
|
3058
|
-
if (propKey === "getElementsByTagName" && arg === "script") {
|
3059
|
-
return iframe.contentDocument.scripts;
|
3060
|
-
}
|
3061
|
-
if (propKey === "getElementsByClassName")
|
3062
|
-
arg = "." + arg;
|
3063
|
-
if (propKey === "getElementsByName")
|
3064
|
-
arg = '[name="'.concat(arg, '"]');
|
3065
|
-
var res;
|
3066
|
-
try {
|
3067
|
-
res = querySelectorAll.call(shadowRoot, arg);
|
3068
|
-
} catch (error2) {
|
3069
|
-
res = [];
|
3070
|
-
}
|
3071
|
-
return res;
|
3072
|
-
}
|
3073
|
-
});
|
3074
|
-
}
|
3075
|
-
if (propKey === "getElementById") {
|
3076
|
-
return new Proxy(shadowRoot.querySelector, {
|
3077
|
-
// case document.querySelector.call
|
3078
|
-
apply: function apply(target, ctx, args) {
|
3079
|
-
if (ctx !== iframe.contentDocument) {
|
3080
|
-
var _ctx$propKey;
|
3081
|
-
return (_ctx$propKey = ctx[propKey]) === null || _ctx$propKey === void 0 ? void 0 : _ctx$propKey.apply(ctx, args);
|
3082
|
-
}
|
3083
|
-
try {
|
3084
|
-
return target.call(shadowRoot, '[id="'.concat(args[0], '"]')) || iframe.contentWindow.__WUJIE_RAW_DOCUMENT_QUERY_SELECTOR__.call(iframe.contentWindow.document, "#".concat(args[0]));
|
3085
|
-
} catch (error2) {
|
3086
|
-
warn(WUJIE_TIPS_GET_ELEMENT_BY_ID);
|
3087
|
-
return null;
|
3088
|
-
}
|
3089
|
-
}
|
3090
|
-
});
|
3091
|
-
}
|
3092
|
-
if (propKey === "querySelector" || propKey === "querySelectorAll") {
|
3093
|
-
var rawPropMap = {
|
3094
|
-
querySelector: "__WUJIE_RAW_DOCUMENT_QUERY_SELECTOR__",
|
3095
|
-
querySelectorAll: "__WUJIE_RAW_DOCUMENT_QUERY_SELECTOR_ALL__"
|
3096
|
-
};
|
3097
|
-
return new Proxy(shadowRoot[propKey], {
|
3098
|
-
apply: function apply(target, ctx, args) {
|
3099
|
-
if (ctx !== iframe.contentDocument) {
|
3100
|
-
var _ctx$propKey2;
|
3101
|
-
return (_ctx$propKey2 = ctx[propKey]) === null || _ctx$propKey2 === void 0 ? void 0 : _ctx$propKey2.apply(ctx, args);
|
3102
|
-
}
|
3103
|
-
return target.apply(shadowRoot, args) || (args[0] === "base" ? null : iframe.contentWindow[rawPropMap[propKey]].call(iframe.contentWindow.document, args[0]));
|
3104
|
-
}
|
3105
|
-
});
|
3106
|
-
}
|
3107
|
-
if (propKey === "documentElement" || propKey === "scrollingElement")
|
3108
|
-
return shadowRoot.firstElementChild;
|
3109
|
-
if (propKey === "forms")
|
3110
|
-
return shadowRoot.querySelectorAll("form");
|
3111
|
-
if (propKey === "images")
|
3112
|
-
return shadowRoot.querySelectorAll("img");
|
3113
|
-
if (propKey === "links")
|
3114
|
-
return shadowRoot.querySelectorAll("a");
|
3115
|
-
var ownerProperties = documentProxyProperties.ownerProperties, shadowProperties = documentProxyProperties.shadowProperties, shadowMethods = documentProxyProperties.shadowMethods, documentProperties = documentProxyProperties.documentProperties, documentMethods = documentProxyProperties.documentMethods;
|
3116
|
-
if (ownerProperties.concat(shadowProperties).includes(propKey.toString())) {
|
3117
|
-
if (propKey === "activeElement" && shadowRoot.activeElement === null)
|
3118
|
-
return shadowRoot.body;
|
3119
|
-
return shadowRoot[propKey];
|
3120
|
-
}
|
3121
|
-
if (shadowMethods.includes(propKey.toString())) {
|
3122
|
-
var _getTargetValue;
|
3123
|
-
return (_getTargetValue = getTargetValue(shadowRoot, propKey)) !== null && _getTargetValue !== void 0 ? _getTargetValue : getTargetValue(document2, propKey);
|
3124
|
-
}
|
3125
|
-
if (documentProperties.includes(propKey.toString())) {
|
3126
|
-
return document2[propKey];
|
3127
|
-
}
|
3128
|
-
if (documentMethods.includes(propKey.toString())) {
|
3129
|
-
return getTargetValue(document2, propKey);
|
3130
|
-
}
|
3131
|
-
}
|
3132
|
-
});
|
3133
|
-
var proxyLocation = new Proxy({}, {
|
3134
|
-
get: function get(_fakeLocation, propKey) {
|
3135
|
-
var location2 = iframe.contentWindow.location;
|
3136
|
-
if (propKey === "host" || propKey === "hostname" || propKey === "protocol" || propKey === "port" || propKey === "origin") {
|
3137
|
-
return urlElement[propKey];
|
3138
|
-
}
|
3139
|
-
if (propKey === "href") {
|
3140
|
-
return location2[propKey].replace(mainHostPath, appHostPath);
|
3141
|
-
}
|
3142
|
-
if (propKey === "reload") {
|
3143
|
-
warn(WUJIE_TIPS_RELOAD_DISABLED);
|
3144
|
-
return function() {
|
3145
|
-
return null;
|
3146
|
-
};
|
3147
|
-
}
|
3148
|
-
if (propKey === "replace") {
|
3149
|
-
return new Proxy(location2[propKey], {
|
3150
|
-
apply: function apply(replace, _ctx, args) {
|
3151
|
-
var _args$;
|
3152
|
-
return replace.call(location2, (_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.replace(appHostPath, mainHostPath));
|
3153
|
-
}
|
3154
|
-
});
|
3155
|
-
}
|
3156
|
-
return getTargetValue(location2, propKey);
|
3157
|
-
},
|
3158
|
-
set: function set(_fakeLocation, propKey, value) {
|
3159
|
-
if (propKey === "href") {
|
3160
|
-
return locationHrefSet(iframe, value, appHostPath);
|
3161
|
-
}
|
3162
|
-
iframe.contentWindow.location[propKey] = value;
|
3163
|
-
return true;
|
3164
|
-
},
|
3165
|
-
ownKeys: function ownKeys2() {
|
3166
|
-
return Object.keys(iframe.contentWindow.location).filter(function(key) {
|
3167
|
-
return key !== "reload";
|
3168
|
-
});
|
3169
|
-
},
|
3170
|
-
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(_target, key) {
|
3171
|
-
return {
|
3172
|
-
enumerable: true,
|
3173
|
-
configurable: true,
|
3174
|
-
value: this[key]
|
3175
|
-
};
|
3176
|
-
}
|
3177
|
-
});
|
3178
|
-
return {
|
3179
|
-
proxyWindow,
|
3180
|
-
proxyDocument,
|
3181
|
-
proxyLocation
|
3182
|
-
};
|
3183
|
-
}
|
3184
|
-
function localGenerator(iframe, urlElement, mainHostPath, appHostPath) {
|
3185
|
-
var proxyDocument = {};
|
3186
|
-
var sandbox = iframe.contentWindow.__WUJIE;
|
3187
|
-
Object.defineProperties(proxyDocument, {
|
3188
|
-
createElement: {
|
3189
|
-
get: function get() {
|
3190
|
-
return function() {
|
3191
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
3192
|
-
args[_key] = arguments[_key];
|
3193
|
-
}
|
3194
|
-
var element = iframe.contentWindow.__WUJIE_RAW_DOCUMENT_CREATE_ELEMENT__.apply(iframe.contentDocument, args);
|
3195
|
-
patchElementEffect(element, iframe.contentWindow);
|
3196
|
-
return element;
|
3197
|
-
};
|
3198
|
-
}
|
3199
|
-
},
|
3200
|
-
createTextNode: {
|
3201
|
-
get: function get() {
|
3202
|
-
return function() {
|
3203
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
3204
|
-
args[_key2] = arguments[_key2];
|
3205
|
-
}
|
3206
|
-
var element = iframe.contentWindow.__WUJIE_RAW_DOCUMENT_CREATE_TEXT_NODE__.apply(iframe.contentDocument, args);
|
3207
|
-
patchElementEffect(element, iframe.contentWindow);
|
3208
|
-
return element;
|
3209
|
-
};
|
3210
|
-
}
|
3211
|
-
},
|
3212
|
-
documentURI: {
|
3213
|
-
get: function get() {
|
3214
|
-
return sandbox.proxyLocation.href;
|
3215
|
-
}
|
3216
|
-
},
|
3217
|
-
URL: {
|
3218
|
-
get: function get() {
|
3219
|
-
return sandbox.proxyLocation.href;
|
3220
|
-
}
|
3221
|
-
},
|
3222
|
-
getElementsByTagName: {
|
3223
|
-
get: function get() {
|
3224
|
-
return function() {
|
3225
|
-
var tagName = arguments.length <= 0 ? void 0 : arguments[0];
|
3226
|
-
if (tagName === "script") {
|
3227
|
-
return iframe.contentDocument.scripts;
|
3228
|
-
}
|
3229
|
-
return sandbox.document.getElementsByTagName(tagName);
|
3230
|
-
};
|
3231
|
-
}
|
3232
|
-
}
|
3233
|
-
});
|
3234
|
-
var modifyLocalProperties = documentProxyProperties.modifyLocalProperties, modifyProperties = documentProxyProperties.modifyProperties, ownerProperties = documentProxyProperties.ownerProperties, shadowProperties = documentProxyProperties.shadowProperties, shadowMethods = documentProxyProperties.shadowMethods, documentProperties = documentProxyProperties.documentProperties, documentMethods = documentProxyProperties.documentMethods;
|
3235
|
-
modifyProperties.filter(function(key) {
|
3236
|
-
return !modifyLocalProperties.includes(key);
|
3237
|
-
}).concat(ownerProperties, shadowProperties, shadowMethods, documentProperties, documentMethods).forEach(function(key) {
|
3238
|
-
Object.defineProperty(proxyDocument, key, {
|
3239
|
-
get: function get() {
|
3240
|
-
var _sandbox$document;
|
3241
|
-
var value = (_sandbox$document = sandbox.document) === null || _sandbox$document === void 0 ? void 0 : _sandbox$document[key];
|
3242
|
-
return isCallable(value) ? value.bind(sandbox.document) : value;
|
3243
|
-
}
|
3244
|
-
});
|
3245
|
-
});
|
3246
|
-
var proxyLocation = {};
|
3247
|
-
var location2 = iframe.contentWindow.location;
|
3248
|
-
var locationKeys = Object.keys(location2);
|
3249
|
-
var constantKey = ["host", "hostname", "port", "protocol", "port"];
|
3250
|
-
constantKey.forEach(function(key) {
|
3251
|
-
proxyLocation[key] = urlElement[key];
|
3252
|
-
});
|
3253
|
-
Object.defineProperties(proxyLocation, {
|
3254
|
-
href: {
|
3255
|
-
get: function get() {
|
3256
|
-
return location2.href.replace(mainHostPath, appHostPath);
|
3257
|
-
},
|
3258
|
-
set: function set(value) {
|
3259
|
-
locationHrefSet(iframe, value, appHostPath);
|
3260
|
-
}
|
3261
|
-
},
|
3262
|
-
reload: {
|
3263
|
-
get: function get() {
|
3264
|
-
warn(WUJIE_TIPS_RELOAD_DISABLED);
|
3265
|
-
return function() {
|
3266
|
-
return null;
|
3267
|
-
};
|
3268
|
-
}
|
3269
|
-
}
|
3270
|
-
});
|
3271
|
-
locationKeys.filter(function(key) {
|
3272
|
-
return !constantKey.concat(["href", "reload"]).includes(key);
|
3273
|
-
}).forEach(function(key) {
|
3274
|
-
Object.defineProperty(proxyLocation, key, {
|
3275
|
-
get: function get() {
|
3276
|
-
return isCallable(location2[key]) ? location2[key].bind(location2) : location2[key];
|
3277
|
-
}
|
3278
|
-
});
|
3279
|
-
});
|
3280
|
-
return {
|
3281
|
-
proxyDocument,
|
3282
|
-
proxyLocation
|
3283
|
-
};
|
3284
|
-
}
|
3285
|
-
var appEventObjMap = window.__POWERED_BY_WUJIE__ ? window.__WUJIE.inject.appEventObjMap : /* @__PURE__ */ new Map();
|
3286
|
-
var EventBus$1 = /* @__PURE__ */ function() {
|
3287
|
-
function EventBus2(id) {
|
3288
|
-
_classCallCheck(this, EventBus2);
|
3289
|
-
this.id = id;
|
3290
|
-
this.$clear();
|
3291
|
-
if (!appEventObjMap.get(this.id)) {
|
3292
|
-
appEventObjMap.set(this.id, {});
|
3293
|
-
}
|
3294
|
-
this.eventObj = appEventObjMap.get(this.id);
|
3295
|
-
}
|
3296
|
-
_createClass(EventBus2, [{
|
3297
|
-
key: "$on",
|
3298
|
-
value: function $on(event, fn) {
|
3299
|
-
var cbs = this.eventObj[event];
|
3300
|
-
if (!cbs) {
|
3301
|
-
this.eventObj[event] = [fn];
|
3302
|
-
return this;
|
3303
|
-
}
|
3304
|
-
if (!cbs.includes(fn))
|
3305
|
-
cbs.push(fn);
|
3306
|
-
return this;
|
3307
|
-
}
|
3308
|
-
/** 任何$emit都会导致监听函数触发,第一个参数为事件名,后续的参数为$emit的参数 */
|
3309
|
-
}, {
|
3310
|
-
key: "$onAll",
|
3311
|
-
value: function $onAll(fn) {
|
3312
|
-
return this.$on(WUJIE_ALL_EVENT, fn);
|
3313
|
-
}
|
3314
|
-
// 一次性监听事件
|
3315
|
-
}, {
|
3316
|
-
key: "$once",
|
3317
|
-
value: function $once(event, fn) {
|
3318
|
-
var on = (function() {
|
3319
|
-
this.$off(event, on);
|
3320
|
-
fn.apply(void 0, arguments);
|
3321
|
-
}).bind(this);
|
3322
|
-
this.$on(event, on);
|
3323
|
-
}
|
3324
|
-
// 取消监听
|
3325
|
-
}, {
|
3326
|
-
key: "$off",
|
3327
|
-
value: function $off(event, fn) {
|
3328
|
-
var cbs = this.eventObj[event];
|
3329
|
-
if (!event || !cbs || !cbs.length) {
|
3330
|
-
warn("".concat(event, " ").concat(WUJIE_TIPS_NO_SUBJECT));
|
3331
|
-
return this;
|
3332
|
-
}
|
3333
|
-
var cb;
|
3334
|
-
var i2 = cbs.length;
|
3335
|
-
while (i2--) {
|
3336
|
-
cb = cbs[i2];
|
3337
|
-
if (cb === fn) {
|
3338
|
-
cbs.splice(i2, 1);
|
3339
|
-
break;
|
3340
|
-
}
|
3341
|
-
}
|
3342
|
-
return this;
|
3343
|
-
}
|
3344
|
-
// 取消监听$onAll
|
3345
|
-
}, {
|
3346
|
-
key: "$offAll",
|
3347
|
-
value: function $offAll(fn) {
|
3348
|
-
return this.$off(WUJIE_ALL_EVENT, fn);
|
3349
|
-
}
|
3350
|
-
// 发送事件
|
3351
|
-
}, {
|
3352
|
-
key: "$emit",
|
3353
|
-
value: function $emit(event) {
|
3354
|
-
var cbs = [];
|
3355
|
-
var allCbs = [];
|
3356
|
-
appEventObjMap.forEach(function(eventObj) {
|
3357
|
-
if (eventObj[event])
|
3358
|
-
cbs = cbs.concat(eventObj[event]);
|
3359
|
-
if (eventObj[WUJIE_ALL_EVENT])
|
3360
|
-
allCbs = allCbs.concat(eventObj[WUJIE_ALL_EVENT]);
|
3361
|
-
});
|
3362
|
-
if (!event || cbs.length === 0 && allCbs.length === 0) {
|
3363
|
-
warn("".concat(event, " ").concat(WUJIE_TIPS_NO_SUBJECT));
|
3364
|
-
} else {
|
3365
|
-
try {
|
3366
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
3367
|
-
args[_key - 1] = arguments[_key];
|
3368
|
-
}
|
3369
|
-
for (var i2 = 0, l = cbs.length; i2 < l; i2++) {
|
3370
|
-
var _cbs;
|
3371
|
-
(_cbs = cbs)[i2].apply(_cbs, args);
|
3372
|
-
}
|
3373
|
-
for (var _i = 0, _l = allCbs.length; _i < _l; _i++) {
|
3374
|
-
var _allCbs;
|
3375
|
-
(_allCbs = allCbs)[_i].apply(_allCbs, [event].concat(args));
|
3376
|
-
}
|
3377
|
-
} catch (e2) {
|
3378
|
-
error(e2);
|
3379
|
-
}
|
3380
|
-
}
|
3381
|
-
return this;
|
3382
|
-
}
|
3383
|
-
// 清空当前所有的监听事件
|
3384
|
-
}, {
|
3385
|
-
key: "$clear",
|
3386
|
-
value: function $clear() {
|
3387
|
-
var _appEventObjMap$get;
|
3388
|
-
var eventObj = (_appEventObjMap$get = appEventObjMap.get(this.id)) !== null && _appEventObjMap$get !== void 0 ? _appEventObjMap$get : {};
|
3389
|
-
var events = Object.keys(eventObj);
|
3390
|
-
events.forEach(function(event) {
|
3391
|
-
return delete eventObj[event];
|
3392
|
-
});
|
3393
|
-
return this;
|
3394
|
-
}
|
3395
|
-
}]);
|
3396
|
-
return EventBus2;
|
3397
|
-
}();
|
3398
|
-
function ownKeys$1(e2, r2) {
|
3399
|
-
var t2 = Object.keys(e2);
|
3400
|
-
if (Object.getOwnPropertySymbols) {
|
3401
|
-
var o2 = Object.getOwnPropertySymbols(e2);
|
3402
|
-
r2 && (o2 = o2.filter(function(r3) {
|
3403
|
-
return Object.getOwnPropertyDescriptor(e2, r3).enumerable;
|
3404
|
-
})), t2.push.apply(t2, o2);
|
3405
|
-
}
|
3406
|
-
return t2;
|
3407
|
-
}
|
3408
|
-
function _objectSpread$1(e2) {
|
3409
|
-
for (var r2 = 1; r2 < arguments.length; r2++) {
|
3410
|
-
var t2 = null != arguments[r2] ? arguments[r2] : {};
|
3411
|
-
r2 % 2 ? ownKeys$1(Object(t2), true).forEach(function(r3) {
|
3412
|
-
_defineProperty(e2, r3, t2[r3]);
|
3413
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : ownKeys$1(Object(t2)).forEach(function(r3) {
|
3414
|
-
Object.defineProperty(e2, r3, Object.getOwnPropertyDescriptor(t2, r3));
|
3415
|
-
});
|
3416
|
-
}
|
3417
|
-
return e2;
|
3418
|
-
}
|
3419
|
-
var Wujie = /* @__PURE__ */ function() {
|
3420
|
-
function Wujie2(options) {
|
3421
|
-
_classCallCheck(this, Wujie2);
|
3422
|
-
_defineProperty(this, "elementEventCacheMap", /* @__PURE__ */ new WeakMap());
|
3423
|
-
if (window.__POWERED_BY_WUJIE__)
|
3424
|
-
this.inject = window.__WUJIE.inject;
|
3425
|
-
else {
|
3426
|
-
this.inject = {
|
3427
|
-
idToSandboxMap: idToSandboxCacheMap,
|
3428
|
-
appEventObjMap,
|
3429
|
-
mainHostPath: window.location.protocol + "//" + window.location.host
|
3430
|
-
};
|
3431
|
-
}
|
3432
|
-
var name = options.name, url = options.url, attrs = options.attrs, fiber = options.fiber, degradeAttrs = options.degradeAttrs, degrade = options.degrade, lifecycles = options.lifecycles, plugins = options.plugins;
|
3433
|
-
this.id = name;
|
3434
|
-
this.fiber = fiber;
|
3435
|
-
this.degrade = degrade || !wujieSupport;
|
3436
|
-
this.bus = new EventBus$1(this.id);
|
3437
|
-
this.url = url;
|
3438
|
-
this.degradeAttrs = degradeAttrs;
|
3439
|
-
this.provide = {
|
3440
|
-
bus: this.bus
|
3441
|
-
};
|
3442
|
-
this.styleSheetElements = [];
|
3443
|
-
this.execQueue = [];
|
3444
|
-
this.lifecycles = lifecycles;
|
3445
|
-
this.plugins = getPlugins(plugins);
|
3446
|
-
var _appRouteParse = appRouteParse(url), urlElement = _appRouteParse.urlElement, appHostPath = _appRouteParse.appHostPath, appRoutePath = _appRouteParse.appRoutePath;
|
3447
|
-
var mainHostPath = this.inject.mainHostPath;
|
3448
|
-
this.iframe = iframeGenerator(this, attrs, mainHostPath, appHostPath, appRoutePath);
|
3449
|
-
if (this.degrade) {
|
3450
|
-
var _localGenerator = localGenerator(this.iframe, urlElement, mainHostPath, appHostPath), proxyDocument = _localGenerator.proxyDocument, proxyLocation = _localGenerator.proxyLocation;
|
3451
|
-
this.proxyDocument = proxyDocument;
|
3452
|
-
this.proxyLocation = proxyLocation;
|
3453
|
-
} else {
|
3454
|
-
var _proxyGenerator = proxyGenerator(this.iframe, urlElement, mainHostPath, appHostPath), proxyWindow = _proxyGenerator.proxyWindow, _proxyDocument = _proxyGenerator.proxyDocument, _proxyLocation = _proxyGenerator.proxyLocation;
|
3455
|
-
this.proxy = proxyWindow;
|
3456
|
-
this.proxyDocument = _proxyDocument;
|
3457
|
-
this.proxyLocation = _proxyLocation;
|
3458
|
-
}
|
3459
|
-
this.provide.location = this.proxyLocation;
|
3460
|
-
addSandboxCacheWithWujie(this.id, this);
|
3461
|
-
}
|
3462
|
-
_createClass(Wujie2, [{
|
3463
|
-
key: "active",
|
3464
|
-
value: (
|
3465
|
-
/** $wujie对象,提供给子应用的接口 */
|
3466
|
-
/** 子应用嵌套场景,父应用传递给子应用的数据 */
|
3467
|
-
/** 激活子应用
|
3468
|
-
* 1、同步路由
|
3469
|
-
* 2、动态修改iframe的fetch
|
3470
|
-
* 3、准备shadow
|
3471
|
-
* 4、准备子应用注入
|
3472
|
-
*/
|
3473
|
-
function() {
|
3474
|
-
var _active = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1.mark(function _callee(options) {
|
3475
|
-
var _this = this;
|
3476
|
-
var sync, url, el, template, props, alive, prefix, fetch, replace, iframeWindow, iframeFetch, iframeBody, _initRenderIframeAndC, iframe, container, _iframeBody;
|
3477
|
-
return _regeneratorRuntime$1.wrap(function _callee$(_context) {
|
3478
|
-
while (1)
|
3479
|
-
switch (_context.prev = _context.next) {
|
3480
|
-
case 0:
|
3481
|
-
sync = options.sync, url = options.url, el = options.el, template = options.template, props = options.props, alive = options.alive, prefix = options.prefix, fetch = options.fetch, replace = options.replace;
|
3482
|
-
this.url = url;
|
3483
|
-
this.sync = sync;
|
3484
|
-
this.alive = alive;
|
3485
|
-
this.hrefFlag = false;
|
3486
|
-
this.prefix = prefix !== null && prefix !== void 0 ? prefix : this.prefix;
|
3487
|
-
this.replace = replace !== null && replace !== void 0 ? replace : this.replace;
|
3488
|
-
this.provide.props = props !== null && props !== void 0 ? props : this.provide.props;
|
3489
|
-
this.activeFlag = true;
|
3490
|
-
_context.next = 11;
|
3491
|
-
return this.iframeReady;
|
3492
|
-
case 11:
|
3493
|
-
iframeWindow = this.iframe.contentWindow;
|
3494
|
-
iframeFetch = fetch ? function(input, init) {
|
3495
|
-
return fetch(typeof input === "string" ? getAbsolutePath(input, _this.proxyLocation.href) : input, init);
|
3496
|
-
} : this.fetch;
|
3497
|
-
if (iframeFetch) {
|
3498
|
-
iframeWindow.fetch = iframeFetch;
|
3499
|
-
this.fetch = iframeFetch;
|
3500
|
-
}
|
3501
|
-
if (this.execFlag && this.alive) {
|
3502
|
-
syncUrlToWindow(iframeWindow);
|
3503
|
-
} else {
|
3504
|
-
syncUrlToIframe(iframeWindow);
|
3505
|
-
syncUrlToWindow(iframeWindow);
|
3506
|
-
}
|
3507
|
-
this.template = template !== null && template !== void 0 ? template : this.template;
|
3508
|
-
if (!this.degrade) {
|
3509
|
-
_context.next = 38;
|
3510
|
-
break;
|
3511
|
-
}
|
3512
|
-
iframeBody = rawDocumentQuerySelector.call(iframeWindow.document, "body");
|
3513
|
-
_initRenderIframeAndC = initRenderIframeAndContainer(this.id, el !== null && el !== void 0 ? el : iframeBody, this.degradeAttrs), iframe = _initRenderIframeAndC.iframe, container = _initRenderIframeAndC.container;
|
3514
|
-
this.el = container;
|
3515
|
-
if (el)
|
3516
|
-
clearChild(iframeBody);
|
3517
|
-
patchEventTimeStamp(iframe.contentWindow, iframeWindow);
|
3518
|
-
iframe.contentWindow.onunload = function() {
|
3519
|
-
_this.unmount();
|
3520
|
-
};
|
3521
|
-
if (!this.document) {
|
3522
|
-
_context.next = 34;
|
3523
|
-
break;
|
3524
|
-
}
|
3525
|
-
if (!this.alive) {
|
3526
|
-
_context.next = 29;
|
3527
|
-
break;
|
3528
|
-
}
|
3529
|
-
iframe.contentDocument.replaceChild(this.document.documentElement, iframe.contentDocument.documentElement);
|
3530
|
-
recoverEventListeners(iframe.contentDocument.documentElement, iframeWindow);
|
3531
|
-
_context.next = 32;
|
3532
|
-
break;
|
3533
|
-
case 29:
|
3534
|
-
_context.next = 31;
|
3535
|
-
return renderTemplateToIframe(iframe.contentDocument, this.iframe.contentWindow, this.template);
|
3536
|
-
case 31:
|
3537
|
-
recoverDocumentListeners(this.document.documentElement, iframe.contentDocument.documentElement, iframeWindow);
|
3538
|
-
case 32:
|
3539
|
-
_context.next = 36;
|
3540
|
-
break;
|
3541
|
-
case 34:
|
3542
|
-
_context.next = 36;
|
3543
|
-
return renderTemplateToIframe(iframe.contentDocument, this.iframe.contentWindow, this.template);
|
3544
|
-
case 36:
|
3545
|
-
this.document = iframe.contentDocument;
|
3546
|
-
return _context.abrupt("return");
|
3547
|
-
case 38:
|
3548
|
-
if (!this.shadowRoot) {
|
3549
|
-
_context.next = 44;
|
3550
|
-
break;
|
3551
|
-
}
|
3552
|
-
this.el = renderElementToContainer(this.shadowRoot.host, el);
|
3553
|
-
if (!this.alive) {
|
3554
|
-
_context.next = 42;
|
3555
|
-
break;
|
3556
|
-
}
|
3557
|
-
return _context.abrupt("return");
|
3558
|
-
case 42:
|
3559
|
-
_context.next = 46;
|
3560
|
-
break;
|
3561
|
-
case 44:
|
3562
|
-
_iframeBody = rawDocumentQuerySelector.call(iframeWindow.document, "body");
|
3563
|
-
this.el = renderElementToContainer(createWujieWebComponent(this.id), el !== null && el !== void 0 ? el : _iframeBody);
|
3564
|
-
case 46:
|
3565
|
-
_context.next = 48;
|
3566
|
-
return renderTemplateToShadowRoot(this.shadowRoot, iframeWindow, this.template);
|
3567
|
-
case 48:
|
3568
|
-
this.patchCssRules();
|
3569
|
-
this.provide.shadowRoot = this.shadowRoot;
|
3570
|
-
case 50:
|
3571
|
-
case "end":
|
3572
|
-
return _context.stop();
|
3573
|
-
}
|
3574
|
-
}, _callee, this);
|
3575
|
-
}));
|
3576
|
-
function active(_x) {
|
3577
|
-
return _active.apply(this, arguments);
|
3578
|
-
}
|
3579
|
-
return active;
|
3580
|
-
}()
|
3581
|
-
)
|
3582
|
-
}, {
|
3583
|
-
key: "requestIdleCallback",
|
3584
|
-
value: function requestIdleCallback$1(callback) {
|
3585
|
-
var _this2 = this;
|
3586
|
-
return requestIdleCallback(function() {
|
3587
|
-
if (!_this2.iframe)
|
3588
|
-
return;
|
3589
|
-
callback.apply(_this2);
|
3590
|
-
});
|
3591
|
-
}
|
3592
|
-
/** 启动子应用
|
3593
|
-
* 1、运行js
|
3594
|
-
* 2、处理兼容样式
|
3595
|
-
*/
|
3596
|
-
}, {
|
3597
|
-
key: "start",
|
3598
|
-
value: function() {
|
3599
|
-
var _start = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1.mark(function _callee2(getExternalScripts) {
|
3600
|
-
var _this3 = this;
|
3601
|
-
var scriptResultList, iframeWindow, beforeScriptResultList, afterScriptResultList, syncScriptResultList, asyncScriptResultList, deferScriptResultList, domContentLoadedTrigger, domLoadedTrigger;
|
3602
|
-
return _regeneratorRuntime$1.wrap(function _callee2$(_context2) {
|
3603
|
-
while (1)
|
3604
|
-
switch (_context2.prev = _context2.next) {
|
3605
|
-
case 0:
|
3606
|
-
this.execFlag = true;
|
3607
|
-
_context2.next = 3;
|
3608
|
-
return getExternalScripts();
|
3609
|
-
case 3:
|
3610
|
-
scriptResultList = _context2.sent;
|
3611
|
-
if (this.iframe) {
|
3612
|
-
_context2.next = 6;
|
3613
|
-
break;
|
3614
|
-
}
|
3615
|
-
return _context2.abrupt("return");
|
3616
|
-
case 6:
|
3617
|
-
iframeWindow = this.iframe.contentWindow;
|
3618
|
-
iframeWindow.__POWERED_BY_WUJIE__ = true;
|
3619
|
-
beforeScriptResultList = getPresetLoaders("jsBeforeLoaders", this.plugins);
|
3620
|
-
afterScriptResultList = getPresetLoaders("jsAfterLoaders", this.plugins);
|
3621
|
-
syncScriptResultList = [];
|
3622
|
-
asyncScriptResultList = [];
|
3623
|
-
deferScriptResultList = [];
|
3624
|
-
scriptResultList.forEach(function(scriptResult) {
|
3625
|
-
if (scriptResult.defer)
|
3626
|
-
deferScriptResultList.push(scriptResult);
|
3627
|
-
else if (scriptResult.async)
|
3628
|
-
asyncScriptResultList.push(scriptResult);
|
3629
|
-
else
|
3630
|
-
syncScriptResultList.push(scriptResult);
|
3631
|
-
});
|
3632
|
-
beforeScriptResultList.forEach(function(beforeScriptResult) {
|
3633
|
-
_this3.execQueue.push(function() {
|
3634
|
-
return _this3.fiber ? _this3.requestIdleCallback(function() {
|
3635
|
-
return insertScriptToIframe(beforeScriptResult, iframeWindow);
|
3636
|
-
}) : insertScriptToIframe(beforeScriptResult, iframeWindow);
|
3637
|
-
});
|
3638
|
-
});
|
3639
|
-
syncScriptResultList.concat(deferScriptResultList).forEach(function(scriptResult) {
|
3640
|
-
_this3.execQueue.push(function() {
|
3641
|
-
return scriptResult.contentPromise.then(function(content) {
|
3642
|
-
return _this3.fiber ? _this3.requestIdleCallback(function() {
|
3643
|
-
return insertScriptToIframe(_objectSpread$1(_objectSpread$1({}, scriptResult), {}, {
|
3644
|
-
content
|
3645
|
-
}), iframeWindow);
|
3646
|
-
}) : insertScriptToIframe(_objectSpread$1(_objectSpread$1({}, scriptResult), {}, {
|
3647
|
-
content
|
3648
|
-
}), iframeWindow);
|
3649
|
-
});
|
3650
|
-
});
|
3651
|
-
});
|
3652
|
-
asyncScriptResultList.forEach(function(scriptResult) {
|
3653
|
-
scriptResult.contentPromise.then(function(content) {
|
3654
|
-
_this3.fiber ? _this3.requestIdleCallback(function() {
|
3655
|
-
return insertScriptToIframe(_objectSpread$1(_objectSpread$1({}, scriptResult), {}, {
|
3656
|
-
content
|
3657
|
-
}), iframeWindow);
|
3658
|
-
}) : insertScriptToIframe(_objectSpread$1(_objectSpread$1({}, scriptResult), {}, {
|
3659
|
-
content
|
3660
|
-
}), iframeWindow);
|
3661
|
-
});
|
3662
|
-
});
|
3663
|
-
this.execQueue.push(this.fiber ? function() {
|
3664
|
-
return _this3.requestIdleCallback(function() {
|
3665
|
-
return _this3.mount();
|
3666
|
-
});
|
3667
|
-
} : function() {
|
3668
|
-
return _this3.mount();
|
3669
|
-
});
|
3670
|
-
domContentLoadedTrigger = function domContentLoadedTrigger2() {
|
3671
|
-
var _this3$execQueue$shif;
|
3672
|
-
eventTrigger(iframeWindow.document, "DOMContentLoaded");
|
3673
|
-
eventTrigger(iframeWindow, "DOMContentLoaded");
|
3674
|
-
(_this3$execQueue$shif = _this3.execQueue.shift()) === null || _this3$execQueue$shif === void 0 || _this3$execQueue$shif();
|
3675
|
-
};
|
3676
|
-
this.execQueue.push(this.fiber ? function() {
|
3677
|
-
return _this3.requestIdleCallback(domContentLoadedTrigger);
|
3678
|
-
} : domContentLoadedTrigger);
|
3679
|
-
afterScriptResultList.forEach(function(afterScriptResult) {
|
3680
|
-
_this3.execQueue.push(function() {
|
3681
|
-
return _this3.fiber ? _this3.requestIdleCallback(function() {
|
3682
|
-
return insertScriptToIframe(afterScriptResult, iframeWindow);
|
3683
|
-
}) : insertScriptToIframe(afterScriptResult, iframeWindow);
|
3684
|
-
});
|
3685
|
-
});
|
3686
|
-
domLoadedTrigger = function domLoadedTrigger2() {
|
3687
|
-
var _this3$execQueue$shif2;
|
3688
|
-
eventTrigger(iframeWindow.document, "readystatechange");
|
3689
|
-
eventTrigger(iframeWindow, "load");
|
3690
|
-
(_this3$execQueue$shif2 = _this3.execQueue.shift()) === null || _this3$execQueue$shif2 === void 0 || _this3$execQueue$shif2();
|
3691
|
-
};
|
3692
|
-
this.execQueue.push(this.fiber ? function() {
|
3693
|
-
return _this3.requestIdleCallback(domLoadedTrigger);
|
3694
|
-
} : domLoadedTrigger);
|
3695
|
-
if (this.alive || !isFunction(this.iframe.contentWindow.__WUJIE_UNMOUNT))
|
3696
|
-
removeLoading(this.el);
|
3697
|
-
this.execQueue.shift()();
|
3698
|
-
return _context2.abrupt("return", new Promise(function(resolve) {
|
3699
|
-
_this3.execQueue.push(function() {
|
3700
|
-
var _this3$execQueue$shif3;
|
3701
|
-
resolve();
|
3702
|
-
(_this3$execQueue$shif3 = _this3.execQueue.shift()) === null || _this3$execQueue$shif3 === void 0 || _this3$execQueue$shif3();
|
3703
|
-
});
|
3704
|
-
}));
|
3705
|
-
case 26:
|
3706
|
-
case "end":
|
3707
|
-
return _context2.stop();
|
3708
|
-
}
|
3709
|
-
}, _callee2, this);
|
3710
|
-
}));
|
3711
|
-
function start(_x2) {
|
3712
|
-
return _start.apply(this, arguments);
|
3713
|
-
}
|
3714
|
-
return start;
|
3715
|
-
}()
|
3716
|
-
}, {
|
3717
|
-
key: "mount",
|
3718
|
-
value: function mount() {
|
3719
|
-
var _this$execQueue$shift;
|
3720
|
-
if (this.mountFlag)
|
3721
|
-
return;
|
3722
|
-
if (isFunction(this.iframe.contentWindow.__WUJIE_MOUNT)) {
|
3723
|
-
var _this$lifecycles, _this$lifecycles$befo, _this$lifecycles2, _this$lifecycles2$aft;
|
3724
|
-
removeLoading(this.el);
|
3725
|
-
(_this$lifecycles = this.lifecycles) === null || _this$lifecycles === void 0 || (_this$lifecycles$befo = _this$lifecycles.beforeMount) === null || _this$lifecycles$befo === void 0 || _this$lifecycles$befo.call(_this$lifecycles, this.iframe.contentWindow);
|
3726
|
-
this.iframe.contentWindow.__WUJIE_MOUNT();
|
3727
|
-
(_this$lifecycles2 = this.lifecycles) === null || _this$lifecycles2 === void 0 || (_this$lifecycles2$aft = _this$lifecycles2.afterMount) === null || _this$lifecycles2$aft === void 0 || _this$lifecycles2$aft.call(_this$lifecycles2, this.iframe.contentWindow);
|
3728
|
-
this.mountFlag = true;
|
3729
|
-
}
|
3730
|
-
if (this.alive) {
|
3731
|
-
var _this$lifecycles3, _this$lifecycles3$act;
|
3732
|
-
(_this$lifecycles3 = this.lifecycles) === null || _this$lifecycles3 === void 0 || (_this$lifecycles3$act = _this$lifecycles3.activated) === null || _this$lifecycles3$act === void 0 || _this$lifecycles3$act.call(_this$lifecycles3, this.iframe.contentWindow);
|
3733
|
-
}
|
3734
|
-
(_this$execQueue$shift = this.execQueue.shift()) === null || _this$execQueue$shift === void 0 || _this$execQueue$shift();
|
3735
|
-
}
|
3736
|
-
/** 保活模式和使用proxyLocation.href跳转链接都不应该销毁shadow */
|
3737
|
-
}, {
|
3738
|
-
key: "unmount",
|
3739
|
-
value: function unmount() {
|
3740
|
-
this.activeFlag = false;
|
3741
|
-
clearInactiveAppUrl();
|
3742
|
-
if (this.alive) {
|
3743
|
-
var _this$lifecycles4, _this$lifecycles4$dea;
|
3744
|
-
(_this$lifecycles4 = this.lifecycles) === null || _this$lifecycles4 === void 0 || (_this$lifecycles4$dea = _this$lifecycles4.deactivated) === null || _this$lifecycles4$dea === void 0 || _this$lifecycles4$dea.call(_this$lifecycles4, this.iframe.contentWindow);
|
3745
|
-
}
|
3746
|
-
if (!this.mountFlag)
|
3747
|
-
return;
|
3748
|
-
if (isFunction(this.iframe.contentWindow.__WUJIE_UNMOUNT) && !this.alive && !this.hrefFlag) {
|
3749
|
-
var _this$lifecycles5, _this$lifecycles5$bef, _this$lifecycles6, _this$lifecycles6$aft;
|
3750
|
-
(_this$lifecycles5 = this.lifecycles) === null || _this$lifecycles5 === void 0 || (_this$lifecycles5$bef = _this$lifecycles5.beforeUnmount) === null || _this$lifecycles5$bef === void 0 || _this$lifecycles5$bef.call(_this$lifecycles5, this.iframe.contentWindow);
|
3751
|
-
this.iframe.contentWindow.__WUJIE_UNMOUNT();
|
3752
|
-
(_this$lifecycles6 = this.lifecycles) === null || _this$lifecycles6 === void 0 || (_this$lifecycles6$aft = _this$lifecycles6.afterUnmount) === null || _this$lifecycles6$aft === void 0 || _this$lifecycles6$aft.call(_this$lifecycles6, this.iframe.contentWindow);
|
3753
|
-
this.mountFlag = false;
|
3754
|
-
this.bus.$clear();
|
3755
|
-
if (!this.degrade) {
|
3756
|
-
clearChild(this.shadowRoot);
|
3757
|
-
removeEventListener(this.head);
|
3758
|
-
removeEventListener(this.body);
|
3759
|
-
}
|
3760
|
-
clearChild(this.head);
|
3761
|
-
clearChild(this.body);
|
3762
|
-
}
|
3763
|
-
}
|
3764
|
-
/** 销毁子应用 */
|
3765
|
-
}, {
|
3766
|
-
key: "destroy",
|
3767
|
-
value: function destroy2() {
|
3768
|
-
this.unmount();
|
3769
|
-
this.bus.$clear();
|
3770
|
-
this.shadowRoot = null;
|
3771
|
-
this.proxy = null;
|
3772
|
-
this.proxyDocument = null;
|
3773
|
-
this.proxyLocation = null;
|
3774
|
-
this.execQueue = null;
|
3775
|
-
this.provide = null;
|
3776
|
-
this.degradeAttrs = null;
|
3777
|
-
this.styleSheetElements = null;
|
3778
|
-
this.bus = null;
|
3779
|
-
this.replace = null;
|
3780
|
-
this.fetch = null;
|
3781
|
-
this.execFlag = null;
|
3782
|
-
this.mountFlag = null;
|
3783
|
-
this.hrefFlag = null;
|
3784
|
-
this.document = null;
|
3785
|
-
this.head = null;
|
3786
|
-
this.body = null;
|
3787
|
-
this.elementEventCacheMap = null;
|
3788
|
-
this.lifecycles = null;
|
3789
|
-
this.plugins = null;
|
3790
|
-
this.provide = null;
|
3791
|
-
this.inject = null;
|
3792
|
-
this.execQueue = null;
|
3793
|
-
this.prefix = null;
|
3794
|
-
if (this.el) {
|
3795
|
-
clearChild(this.el);
|
3796
|
-
this.el = null;
|
3797
|
-
}
|
3798
|
-
if (this.iframe) {
|
3799
|
-
var _this$iframe$parentNo;
|
3800
|
-
var _iframeWindow = this.iframe.contentWindow;
|
3801
|
-
if (_iframeWindow !== null && _iframeWindow !== void 0 && _iframeWindow.__WUJIE_EVENTLISTENER__) {
|
3802
|
-
_iframeWindow.__WUJIE_EVENTLISTENER__.forEach(function(o2) {
|
3803
|
-
_iframeWindow.removeEventListener(o2.type, o2.listener, o2.options);
|
3804
|
-
});
|
3805
|
-
}
|
3806
|
-
(_this$iframe$parentNo = this.iframe.parentNode) === null || _this$iframe$parentNo === void 0 || _this$iframe$parentNo.removeChild(this.iframe);
|
3807
|
-
this.iframe = null;
|
3808
|
-
}
|
3809
|
-
deleteWujieById(this.id);
|
3810
|
-
}
|
3811
|
-
/** 当子应用再次激活后,只运行mount函数,样式需要重新恢复 */
|
3812
|
-
}, {
|
3813
|
-
key: "rebuildStyleSheets",
|
3814
|
-
value: function rebuildStyleSheets() {
|
3815
|
-
var _this4 = this;
|
3816
|
-
if (this.styleSheetElements && this.styleSheetElements.length) {
|
3817
|
-
this.styleSheetElements.forEach(function(styleSheetElement) {
|
3818
|
-
rawElementAppendChild.call(_this4.degrade ? _this4.document.head : _this4.shadowRoot.head, styleSheetElement);
|
3819
|
-
});
|
3820
|
-
}
|
3821
|
-
this.patchCssRules();
|
3822
|
-
}
|
3823
|
-
/**
|
3824
|
-
* 子应用样式打补丁
|
3825
|
-
* 1、兼容:root选择器样式到:host选择器上
|
3826
|
-
* 2、将@font-face定义到shadowRoot外部
|
3827
|
-
*/
|
3828
|
-
}, {
|
3829
|
-
key: "patchCssRules",
|
3830
|
-
value: function patchCssRules() {
|
3831
|
-
if (this.degrade)
|
3832
|
-
return;
|
3833
|
-
if (this.shadowRoot.host.hasAttribute(WUJIE_DATA_ATTACH_CSS_FLAG))
|
3834
|
-
return;
|
3835
|
-
var _getPatchStyleElement = getPatchStyleElements(Array.from(this.iframe.contentDocument.querySelectorAll("style")).map(function(styleSheetElement) {
|
3836
|
-
return styleSheetElement.sheet;
|
3837
|
-
})), _getPatchStyleElement2 = _slicedToArray(_getPatchStyleElement, 2), hostStyleSheetElement = _getPatchStyleElement2[0], fontStyleSheetElement = _getPatchStyleElement2[1];
|
3838
|
-
if (hostStyleSheetElement) {
|
3839
|
-
this.shadowRoot.head.appendChild(hostStyleSheetElement);
|
3840
|
-
this.styleSheetElements.push(hostStyleSheetElement);
|
3841
|
-
}
|
3842
|
-
if (fontStyleSheetElement) {
|
3843
|
-
this.shadowRoot.host.appendChild(fontStyleSheetElement);
|
3844
|
-
}
|
3845
|
-
(hostStyleSheetElement || fontStyleSheetElement) && this.shadowRoot.host.setAttribute(WUJIE_DATA_ATTACH_CSS_FLAG, "");
|
3846
|
-
}
|
3847
|
-
}]);
|
3848
|
-
return Wujie2;
|
3849
|
-
}();
|
3850
|
-
function ownKeys(e2, r2) {
|
3851
|
-
var t2 = Object.keys(e2);
|
3852
|
-
if (Object.getOwnPropertySymbols) {
|
3853
|
-
var o2 = Object.getOwnPropertySymbols(e2);
|
3854
|
-
r2 && (o2 = o2.filter(function(r3) {
|
3855
|
-
return Object.getOwnPropertyDescriptor(e2, r3).enumerable;
|
3856
|
-
})), t2.push.apply(t2, o2);
|
3857
|
-
}
|
3858
|
-
return t2;
|
3859
|
-
}
|
3860
|
-
function _objectSpread(e2) {
|
3861
|
-
for (var r2 = 1; r2 < arguments.length; r2++) {
|
3862
|
-
var t2 = null != arguments[r2] ? arguments[r2] : {};
|
3863
|
-
r2 % 2 ? ownKeys(Object(t2), true).forEach(function(r3) {
|
3864
|
-
_defineProperty(e2, r3, t2[r3]);
|
3865
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : ownKeys(Object(t2)).forEach(function(r3) {
|
3866
|
-
Object.defineProperty(e2, r3, Object.getOwnPropertyDescriptor(t2, r3));
|
3867
|
-
});
|
3868
|
-
}
|
3869
|
-
return e2;
|
3870
|
-
}
|
3871
|
-
var bus$1 = new EventBus$1(Date.now().toString());
|
3872
|
-
if (window.__WUJIE && !window.__POWERED_BY_WUJIE__) {
|
3873
|
-
stopMainAppRun();
|
3874
|
-
}
|
3875
|
-
processAppForHrefJump();
|
3876
|
-
defineWujieWebComponent();
|
3877
|
-
if (!wujieSupport)
|
3878
|
-
warn(WUJIE_TIPS_NOT_SUPPORTED);
|
3879
|
-
function setupApp(options) {
|
3880
|
-
if (options.name)
|
3881
|
-
addSandboxCacheWithOptions(options.name, options);
|
3882
|
-
}
|
3883
|
-
function startApp(_x) {
|
3884
|
-
return _startApp.apply(this, arguments);
|
3885
|
-
}
|
3886
|
-
function _startApp() {
|
3887
|
-
_startApp = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1.mark(function _callee2(startOptions) {
|
3888
|
-
var _newSandbox$lifecycle, _newSandbox$lifecycle2;
|
3889
|
-
var sandbox, cacheOptions, options, name, url, html, replace, fetch, props, attrs, degradeAttrs, fiber, alive, degrade, sync, prefix, el, loading, plugins, lifecycles, _iframeWindow, _sandbox$lifecycles3, _sandbox$lifecycles3$, _sandbox$lifecycles2, _sandbox$lifecycles2$, _yield$importHTML2, _getExternalScripts2, _sandbox$lifecycles4, _sandbox$lifecycles4$, _sandbox$lifecycles5, _sandbox$lifecycles5$, newSandbox, _yield$importHTML3, template, getExternalScripts, getExternalStyleSheets, processedHtml;
|
3890
|
-
return _regeneratorRuntime$1.wrap(function _callee2$(_context2) {
|
3891
|
-
while (1)
|
3892
|
-
switch (_context2.prev = _context2.next) {
|
3893
|
-
case 0:
|
3894
|
-
sandbox = getWujieById(startOptions.name);
|
3895
|
-
cacheOptions = getOptionsById(startOptions.name);
|
3896
|
-
options = mergeOptions(startOptions, cacheOptions);
|
3897
|
-
name = options.name, url = options.url, html = options.html, replace = options.replace, fetch = options.fetch, props = options.props, attrs = options.attrs, degradeAttrs = options.degradeAttrs, fiber = options.fiber, alive = options.alive, degrade = options.degrade, sync = options.sync, prefix = options.prefix, el = options.el, loading = options.loading, plugins = options.plugins, lifecycles = options.lifecycles;
|
3898
|
-
if (!sandbox) {
|
3899
|
-
_context2.next = 39;
|
3900
|
-
break;
|
3901
|
-
}
|
3902
|
-
sandbox.plugins = getPlugins(plugins);
|
3903
|
-
sandbox.lifecycles = lifecycles;
|
3904
|
-
_iframeWindow = sandbox.iframe.contentWindow;
|
3905
|
-
if (!sandbox.preload) {
|
3906
|
-
_context2.next = 11;
|
3907
|
-
break;
|
3908
|
-
}
|
3909
|
-
_context2.next = 11;
|
3910
|
-
return sandbox.preload;
|
3911
|
-
case 11:
|
3912
|
-
if (!alive) {
|
3913
|
-
_context2.next = 26;
|
3914
|
-
break;
|
3915
|
-
}
|
3916
|
-
_context2.next = 14;
|
3917
|
-
return sandbox.active({
|
3918
|
-
url,
|
3919
|
-
sync,
|
3920
|
-
prefix,
|
3921
|
-
el,
|
3922
|
-
props,
|
3923
|
-
alive,
|
3924
|
-
fetch,
|
3925
|
-
replace
|
3926
|
-
});
|
3927
|
-
case 14:
|
3928
|
-
if (sandbox.execFlag) {
|
3929
|
-
_context2.next = 22;
|
3930
|
-
break;
|
3931
|
-
}
|
3932
|
-
(_sandbox$lifecycles2 = sandbox.lifecycles) === null || _sandbox$lifecycles2 === void 0 || (_sandbox$lifecycles2$ = _sandbox$lifecycles2.beforeLoad) === null || _sandbox$lifecycles2$ === void 0 || _sandbox$lifecycles2$.call(_sandbox$lifecycles2, sandbox.iframe.contentWindow);
|
3933
|
-
_context2.next = 18;
|
3934
|
-
return importHTML({
|
3935
|
-
url,
|
3936
|
-
html,
|
3937
|
-
opts: {
|
3938
|
-
fetch: fetch || window.fetch,
|
3939
|
-
plugins: sandbox.plugins,
|
3940
|
-
loadError: sandbox.lifecycles.loadError,
|
3941
|
-
fiber
|
3942
|
-
}
|
3943
|
-
});
|
3944
|
-
case 18:
|
3945
|
-
_yield$importHTML2 = _context2.sent;
|
3946
|
-
_getExternalScripts2 = _yield$importHTML2.getExternalScripts;
|
3947
|
-
_context2.next = 22;
|
3948
|
-
return sandbox.start(_getExternalScripts2);
|
3949
|
-
case 22:
|
3950
|
-
(_sandbox$lifecycles3 = sandbox.lifecycles) === null || _sandbox$lifecycles3 === void 0 || (_sandbox$lifecycles3$ = _sandbox$lifecycles3.activated) === null || _sandbox$lifecycles3$ === void 0 || _sandbox$lifecycles3$.call(_sandbox$lifecycles3, sandbox.iframe.contentWindow);
|
3951
|
-
return _context2.abrupt("return", sandbox.destroy);
|
3952
|
-
case 26:
|
3953
|
-
if (!isFunction(_iframeWindow.__WUJIE_MOUNT)) {
|
3954
|
-
_context2.next = 38;
|
3955
|
-
break;
|
3956
|
-
}
|
3957
|
-
sandbox.unmount();
|
3958
|
-
_context2.next = 30;
|
3959
|
-
return sandbox.active({
|
3960
|
-
url,
|
3961
|
-
sync,
|
3962
|
-
prefix,
|
3963
|
-
el,
|
3964
|
-
props,
|
3965
|
-
alive,
|
3966
|
-
fetch,
|
3967
|
-
replace
|
3968
|
-
});
|
3969
|
-
case 30:
|
3970
|
-
sandbox.rebuildStyleSheets();
|
3971
|
-
(_sandbox$lifecycles4 = sandbox.lifecycles) === null || _sandbox$lifecycles4 === void 0 || (_sandbox$lifecycles4$ = _sandbox$lifecycles4.beforeMount) === null || _sandbox$lifecycles4$ === void 0 || _sandbox$lifecycles4$.call(_sandbox$lifecycles4, sandbox.iframe.contentWindow);
|
3972
|
-
_iframeWindow.__WUJIE_MOUNT();
|
3973
|
-
(_sandbox$lifecycles5 = sandbox.lifecycles) === null || _sandbox$lifecycles5 === void 0 || (_sandbox$lifecycles5$ = _sandbox$lifecycles5.afterMount) === null || _sandbox$lifecycles5$ === void 0 || _sandbox$lifecycles5$.call(_sandbox$lifecycles5, sandbox.iframe.contentWindow);
|
3974
|
-
sandbox.mountFlag = true;
|
3975
|
-
return _context2.abrupt("return", sandbox.destroy);
|
3976
|
-
case 38:
|
3977
|
-
sandbox.destroy();
|
3978
|
-
case 39:
|
3979
|
-
addLoading(el, loading);
|
3980
|
-
newSandbox = new Wujie({
|
3981
|
-
name,
|
3982
|
-
url,
|
3983
|
-
attrs,
|
3984
|
-
degradeAttrs,
|
3985
|
-
fiber,
|
3986
|
-
degrade,
|
3987
|
-
plugins,
|
3988
|
-
lifecycles
|
3989
|
-
});
|
3990
|
-
(_newSandbox$lifecycle = newSandbox.lifecycles) === null || _newSandbox$lifecycle === void 0 || (_newSandbox$lifecycle2 = _newSandbox$lifecycle.beforeLoad) === null || _newSandbox$lifecycle2 === void 0 || _newSandbox$lifecycle2.call(_newSandbox$lifecycle, newSandbox.iframe.contentWindow);
|
3991
|
-
_context2.next = 44;
|
3992
|
-
return importHTML({
|
3993
|
-
url,
|
3994
|
-
html,
|
3995
|
-
opts: {
|
3996
|
-
fetch: fetch || window.fetch,
|
3997
|
-
plugins: newSandbox.plugins,
|
3998
|
-
loadError: newSandbox.lifecycles.loadError,
|
3999
|
-
fiber
|
4000
|
-
}
|
4001
|
-
});
|
4002
|
-
case 44:
|
4003
|
-
_yield$importHTML3 = _context2.sent;
|
4004
|
-
template = _yield$importHTML3.template;
|
4005
|
-
getExternalScripts = _yield$importHTML3.getExternalScripts;
|
4006
|
-
getExternalStyleSheets = _yield$importHTML3.getExternalStyleSheets;
|
4007
|
-
_context2.next = 50;
|
4008
|
-
return processCssLoader(newSandbox, template, getExternalStyleSheets);
|
4009
|
-
case 50:
|
4010
|
-
processedHtml = _context2.sent;
|
4011
|
-
_context2.next = 53;
|
4012
|
-
return newSandbox.active({
|
4013
|
-
url,
|
4014
|
-
sync,
|
4015
|
-
prefix,
|
4016
|
-
template: processedHtml,
|
4017
|
-
el,
|
4018
|
-
props,
|
4019
|
-
alive,
|
4020
|
-
fetch,
|
4021
|
-
replace
|
4022
|
-
});
|
4023
|
-
case 53:
|
4024
|
-
_context2.next = 55;
|
4025
|
-
return newSandbox.start(getExternalScripts);
|
4026
|
-
case 55:
|
4027
|
-
return _context2.abrupt("return", newSandbox.destroy);
|
4028
|
-
case 56:
|
4029
|
-
case "end":
|
4030
|
-
return _context2.stop();
|
4031
|
-
}
|
4032
|
-
}, _callee2);
|
4033
|
-
}));
|
4034
|
-
return _startApp.apply(this, arguments);
|
4035
|
-
}
|
4036
|
-
function preloadApp(preOptions) {
|
4037
|
-
requestIdleCallback(function() {
|
4038
|
-
if (getWujieById(preOptions.name) || isMatchSyncQueryById(preOptions.name))
|
4039
|
-
return;
|
4040
|
-
var cacheOptions = getOptionsById(preOptions.name);
|
4041
|
-
var options = mergeOptions(_objectSpread({}, preOptions), cacheOptions);
|
4042
|
-
var name = options.name, url = options.url, html = options.html, props = options.props, alive = options.alive, replace = options.replace, fetch = options.fetch, exec = options.exec, attrs = options.attrs, degradeAttrs = options.degradeAttrs, fiber = options.fiber, degrade = options.degrade, prefix = options.prefix, plugins = options.plugins, lifecycles = options.lifecycles;
|
4043
|
-
var sandbox = new Wujie({
|
4044
|
-
name,
|
4045
|
-
url,
|
4046
|
-
attrs,
|
4047
|
-
degradeAttrs,
|
4048
|
-
fiber,
|
4049
|
-
degrade,
|
4050
|
-
plugins,
|
4051
|
-
lifecycles
|
4052
|
-
});
|
4053
|
-
if (sandbox.preload)
|
4054
|
-
return sandbox.preload;
|
4055
|
-
var runPreload = /* @__PURE__ */ function() {
|
4056
|
-
var _ref = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1.mark(function _callee() {
|
4057
|
-
var _sandbox$lifecycles, _sandbox$lifecycles$b;
|
4058
|
-
var _yield$importHTML, template, getExternalScripts, getExternalStyleSheets, processedHtml;
|
4059
|
-
return _regeneratorRuntime$1.wrap(function _callee$(_context) {
|
4060
|
-
while (1)
|
4061
|
-
switch (_context.prev = _context.next) {
|
4062
|
-
case 0:
|
4063
|
-
(_sandbox$lifecycles = sandbox.lifecycles) === null || _sandbox$lifecycles === void 0 || (_sandbox$lifecycles$b = _sandbox$lifecycles.beforeLoad) === null || _sandbox$lifecycles$b === void 0 || _sandbox$lifecycles$b.call(_sandbox$lifecycles, sandbox.iframe.contentWindow);
|
4064
|
-
_context.next = 3;
|
4065
|
-
return importHTML({
|
4066
|
-
url,
|
4067
|
-
html,
|
4068
|
-
opts: {
|
4069
|
-
fetch: fetch || window.fetch,
|
4070
|
-
plugins: sandbox.plugins,
|
4071
|
-
loadError: sandbox.lifecycles.loadError,
|
4072
|
-
fiber
|
4073
|
-
}
|
4074
|
-
});
|
4075
|
-
case 3:
|
4076
|
-
_yield$importHTML = _context.sent;
|
4077
|
-
template = _yield$importHTML.template;
|
4078
|
-
getExternalScripts = _yield$importHTML.getExternalScripts;
|
4079
|
-
getExternalStyleSheets = _yield$importHTML.getExternalStyleSheets;
|
4080
|
-
_context.next = 9;
|
4081
|
-
return processCssLoader(sandbox, template, getExternalStyleSheets);
|
4082
|
-
case 9:
|
4083
|
-
processedHtml = _context.sent;
|
4084
|
-
_context.next = 12;
|
4085
|
-
return sandbox.active({
|
4086
|
-
url,
|
4087
|
-
props,
|
4088
|
-
prefix,
|
4089
|
-
alive,
|
4090
|
-
template: processedHtml,
|
4091
|
-
fetch,
|
4092
|
-
replace
|
4093
|
-
});
|
4094
|
-
case 12:
|
4095
|
-
if (!exec) {
|
4096
|
-
_context.next = 17;
|
4097
|
-
break;
|
4098
|
-
}
|
4099
|
-
_context.next = 15;
|
4100
|
-
return sandbox.start(getExternalScripts);
|
4101
|
-
case 15:
|
4102
|
-
_context.next = 19;
|
4103
|
-
break;
|
4104
|
-
case 17:
|
4105
|
-
_context.next = 19;
|
4106
|
-
return getExternalScripts();
|
4107
|
-
case 19:
|
4108
|
-
case "end":
|
4109
|
-
return _context.stop();
|
4110
|
-
}
|
4111
|
-
}, _callee);
|
4112
|
-
}));
|
4113
|
-
return function runPreload2() {
|
4114
|
-
return _ref.apply(this, arguments);
|
4115
|
-
};
|
4116
|
-
}();
|
4117
|
-
sandbox.preload = runPreload();
|
4118
|
-
});
|
4119
|
-
}
|
4120
|
-
function destroyApp(id) {
|
4121
|
-
var sandbox = getWujieById(id);
|
4122
|
-
if (sandbox) {
|
4123
|
-
sandbox.destroy();
|
4124
|
-
}
|
4125
|
-
}
|
4126
|
-
function _typeof(o2) {
|
4127
|
-
"@babel/helpers - typeof";
|
4128
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o3) {
|
4129
|
-
return typeof o3;
|
4130
|
-
} : function(o3) {
|
4131
|
-
return o3 && "function" == typeof Symbol && o3.constructor === Symbol && o3 !== Symbol.prototype ? "symbol" : typeof o3;
|
4132
|
-
}, _typeof(o2);
|
4133
|
-
}
|
4134
|
-
function _regeneratorRuntime() {
|
4135
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
4136
|
-
_regeneratorRuntime = function _regeneratorRuntime2() {
|
4137
|
-
return e2;
|
4138
|
-
};
|
4139
|
-
var t2, e2 = {}, r2 = Object.prototype, n2 = r2.hasOwnProperty, o2 = Object.defineProperty || function(t3, e3, r3) {
|
4140
|
-
t3[e3] = r3.value;
|
4141
|
-
}, i2 = "function" == typeof Symbol ? Symbol : {}, a2 = i2.iterator || "@@iterator", c2 = i2.asyncIterator || "@@asyncIterator", u2 = i2.toStringTag || "@@toStringTag";
|
4142
|
-
function define(t3, e3, r3) {
|
4143
|
-
return Object.defineProperty(t3, e3, { value: r3, enumerable: true, configurable: true, writable: true }), t3[e3];
|
4144
|
-
}
|
4145
|
-
try {
|
4146
|
-
define({}, "");
|
4147
|
-
} catch (t3) {
|
4148
|
-
define = function define2(t4, e3, r3) {
|
4149
|
-
return t4[e3] = r3;
|
4150
|
-
};
|
4151
|
-
}
|
4152
|
-
function wrap(t3, e3, r3, n3) {
|
4153
|
-
var i3 = e3 && e3.prototype instanceof Generator ? e3 : Generator, a3 = Object.create(i3.prototype), c3 = new Context(n3 || []);
|
4154
|
-
return o2(a3, "_invoke", { value: makeInvokeMethod(t3, r3, c3) }), a3;
|
4155
|
-
}
|
4156
|
-
function tryCatch(t3, e3, r3) {
|
4157
|
-
try {
|
4158
|
-
return { type: "normal", arg: t3.call(e3, r3) };
|
4159
|
-
} catch (t4) {
|
4160
|
-
return { type: "throw", arg: t4 };
|
4161
|
-
}
|
4162
|
-
}
|
4163
|
-
e2.wrap = wrap;
|
4164
|
-
var h2 = "suspendedStart", l = "suspendedYield", f2 = "executing", s2 = "completed", y2 = {};
|
4165
|
-
function Generator() {
|
4166
|
-
}
|
4167
|
-
function GeneratorFunction() {
|
4168
|
-
}
|
4169
|
-
function GeneratorFunctionPrototype() {
|
4170
|
-
}
|
4171
|
-
var p2 = {};
|
4172
|
-
define(p2, a2, function() {
|
4173
|
-
return this;
|
4174
|
-
});
|
4175
|
-
var d = Object.getPrototypeOf, v2 = d && d(d(values([])));
|
4176
|
-
v2 && v2 !== r2 && n2.call(v2, a2) && (p2 = v2);
|
4177
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p2);
|
4178
|
-
function defineIteratorMethods(t3) {
|
4179
|
-
["next", "throw", "return"].forEach(function(e3) {
|
4180
|
-
define(t3, e3, function(t4) {
|
4181
|
-
return this._invoke(e3, t4);
|
4182
|
-
});
|
4183
|
-
});
|
4184
|
-
}
|
4185
|
-
function AsyncIterator(t3, e3) {
|
4186
|
-
function invoke(r4, o3, i3, a3) {
|
4187
|
-
var c3 = tryCatch(t3[r4], t3, o3);
|
4188
|
-
if ("throw" !== c3.type) {
|
4189
|
-
var u3 = c3.arg, h3 = u3.value;
|
4190
|
-
return h3 && "object" == _typeof(h3) && n2.call(h3, "__await") ? e3.resolve(h3.__await).then(function(t4) {
|
4191
|
-
invoke("next", t4, i3, a3);
|
4192
|
-
}, function(t4) {
|
4193
|
-
invoke("throw", t4, i3, a3);
|
4194
|
-
}) : e3.resolve(h3).then(function(t4) {
|
4195
|
-
u3.value = t4, i3(u3);
|
4196
|
-
}, function(t4) {
|
4197
|
-
return invoke("throw", t4, i3, a3);
|
4198
|
-
});
|
4199
|
-
}
|
4200
|
-
a3(c3.arg);
|
4201
|
-
}
|
4202
|
-
var r3;
|
4203
|
-
o2(this, "_invoke", { value: function value(t4, n3) {
|
4204
|
-
function callInvokeWithMethodAndArg() {
|
4205
|
-
return new e3(function(e4, r4) {
|
4206
|
-
invoke(t4, n3, e4, r4);
|
4207
|
-
});
|
4208
|
-
}
|
4209
|
-
return r3 = r3 ? r3.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
4210
|
-
} });
|
4211
|
-
}
|
4212
|
-
function makeInvokeMethod(e3, r3, n3) {
|
4213
|
-
var o3 = h2;
|
4214
|
-
return function(i3, a3) {
|
4215
|
-
if (o3 === f2)
|
4216
|
-
throw new Error("Generator is already running");
|
4217
|
-
if (o3 === s2) {
|
4218
|
-
if ("throw" === i3)
|
4219
|
-
throw a3;
|
4220
|
-
return { value: t2, done: true };
|
4221
|
-
}
|
4222
|
-
for (n3.method = i3, n3.arg = a3; ; ) {
|
4223
|
-
var c3 = n3.delegate;
|
4224
|
-
if (c3) {
|
4225
|
-
var u3 = maybeInvokeDelegate(c3, n3);
|
4226
|
-
if (u3) {
|
4227
|
-
if (u3 === y2)
|
4228
|
-
continue;
|
4229
|
-
return u3;
|
4230
|
-
}
|
4231
|
-
}
|
4232
|
-
if ("next" === n3.method)
|
4233
|
-
n3.sent = n3._sent = n3.arg;
|
4234
|
-
else if ("throw" === n3.method) {
|
4235
|
-
if (o3 === h2)
|
4236
|
-
throw o3 = s2, n3.arg;
|
4237
|
-
n3.dispatchException(n3.arg);
|
4238
|
-
} else
|
4239
|
-
"return" === n3.method && n3.abrupt("return", n3.arg);
|
4240
|
-
o3 = f2;
|
4241
|
-
var p3 = tryCatch(e3, r3, n3);
|
4242
|
-
if ("normal" === p3.type) {
|
4243
|
-
if (o3 = n3.done ? s2 : l, p3.arg === y2)
|
4244
|
-
continue;
|
4245
|
-
return { value: p3.arg, done: n3.done };
|
4246
|
-
}
|
4247
|
-
"throw" === p3.type && (o3 = s2, n3.method = "throw", n3.arg = p3.arg);
|
4248
|
-
}
|
4249
|
-
};
|
4250
|
-
}
|
4251
|
-
function maybeInvokeDelegate(e3, r3) {
|
4252
|
-
var n3 = r3.method, o3 = e3.iterator[n3];
|
4253
|
-
if (o3 === t2)
|
4254
|
-
return r3.delegate = null, "throw" === n3 && e3.iterator["return"] && (r3.method = "return", r3.arg = t2, maybeInvokeDelegate(e3, r3), "throw" === r3.method) || "return" !== n3 && (r3.method = "throw", r3.arg = new TypeError("The iterator does not provide a '" + n3 + "' method")), y2;
|
4255
|
-
var i3 = tryCatch(o3, e3.iterator, r3.arg);
|
4256
|
-
if ("throw" === i3.type)
|
4257
|
-
return r3.method = "throw", r3.arg = i3.arg, r3.delegate = null, y2;
|
4258
|
-
var a3 = i3.arg;
|
4259
|
-
return a3 ? a3.done ? (r3[e3.resultName] = a3.value, r3.next = e3.nextLoc, "return" !== r3.method && (r3.method = "next", r3.arg = t2), r3.delegate = null, y2) : a3 : (r3.method = "throw", r3.arg = new TypeError("iterator result is not an object"), r3.delegate = null, y2);
|
4260
|
-
}
|
4261
|
-
function pushTryEntry(t3) {
|
4262
|
-
var e3 = { tryLoc: t3[0] };
|
4263
|
-
1 in t3 && (e3.catchLoc = t3[1]), 2 in t3 && (e3.finallyLoc = t3[2], e3.afterLoc = t3[3]), this.tryEntries.push(e3);
|
4264
|
-
}
|
4265
|
-
function resetTryEntry(t3) {
|
4266
|
-
var e3 = t3.completion || {};
|
4267
|
-
e3.type = "normal", delete e3.arg, t3.completion = e3;
|
4268
|
-
}
|
4269
|
-
function Context(t3) {
|
4270
|
-
this.tryEntries = [{ tryLoc: "root" }], t3.forEach(pushTryEntry, this), this.reset(true);
|
4271
|
-
}
|
4272
|
-
function values(e3) {
|
4273
|
-
if (e3 || "" === e3) {
|
4274
|
-
var r3 = e3[a2];
|
4275
|
-
if (r3)
|
4276
|
-
return r3.call(e3);
|
4277
|
-
if ("function" == typeof e3.next)
|
4278
|
-
return e3;
|
4279
|
-
if (!isNaN(e3.length)) {
|
4280
|
-
var o3 = -1, i3 = function next() {
|
4281
|
-
for (; ++o3 < e3.length; )
|
4282
|
-
if (n2.call(e3, o3))
|
4283
|
-
return next.value = e3[o3], next.done = false, next;
|
4284
|
-
return next.value = t2, next.done = true, next;
|
4285
|
-
};
|
4286
|
-
return i3.next = i3;
|
4287
|
-
}
|
4288
|
-
}
|
4289
|
-
throw new TypeError(_typeof(e3) + " is not iterable");
|
4290
|
-
}
|
4291
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o2(g, "constructor", { value: GeneratorFunctionPrototype, configurable: true }), o2(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: true }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u2, "GeneratorFunction"), e2.isGeneratorFunction = function(t3) {
|
4292
|
-
var e3 = "function" == typeof t3 && t3.constructor;
|
4293
|
-
return !!e3 && (e3 === GeneratorFunction || "GeneratorFunction" === (e3.displayName || e3.name));
|
4294
|
-
}, e2.mark = function(t3) {
|
4295
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t3, GeneratorFunctionPrototype) : (t3.__proto__ = GeneratorFunctionPrototype, define(t3, u2, "GeneratorFunction")), t3.prototype = Object.create(g), t3;
|
4296
|
-
}, e2.awrap = function(t3) {
|
4297
|
-
return { __await: t3 };
|
4298
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c2, function() {
|
4299
|
-
return this;
|
4300
|
-
}), e2.AsyncIterator = AsyncIterator, e2.async = function(t3, r3, n3, o3, i3) {
|
4301
|
-
void 0 === i3 && (i3 = Promise);
|
4302
|
-
var a3 = new AsyncIterator(wrap(t3, r3, n3, o3), i3);
|
4303
|
-
return e2.isGeneratorFunction(r3) ? a3 : a3.next().then(function(t4) {
|
4304
|
-
return t4.done ? t4.value : a3.next();
|
4305
|
-
});
|
4306
|
-
}, defineIteratorMethods(g), define(g, u2, "Generator"), define(g, a2, function() {
|
4307
|
-
return this;
|
4308
|
-
}), define(g, "toString", function() {
|
4309
|
-
return "[object Generator]";
|
4310
|
-
}), e2.keys = function(t3) {
|
4311
|
-
var e3 = Object(t3), r3 = [];
|
4312
|
-
for (var n3 in e3)
|
4313
|
-
r3.push(n3);
|
4314
|
-
return r3.reverse(), function next() {
|
4315
|
-
for (; r3.length; ) {
|
4316
|
-
var t4 = r3.pop();
|
4317
|
-
if (t4 in e3)
|
4318
|
-
return next.value = t4, next.done = false, next;
|
4319
|
-
}
|
4320
|
-
return next.done = true, next;
|
4321
|
-
};
|
4322
|
-
}, e2.values = values, Context.prototype = { constructor: Context, reset: function reset(e3) {
|
4323
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t2, this.done = false, this.delegate = null, this.method = "next", this.arg = t2, this.tryEntries.forEach(resetTryEntry), !e3)
|
4324
|
-
for (var r3 in this)
|
4325
|
-
"t" === r3.charAt(0) && n2.call(this, r3) && !isNaN(+r3.slice(1)) && (this[r3] = t2);
|
4326
|
-
}, stop: function stop() {
|
4327
|
-
this.done = true;
|
4328
|
-
var t3 = this.tryEntries[0].completion;
|
4329
|
-
if ("throw" === t3.type)
|
4330
|
-
throw t3.arg;
|
4331
|
-
return this.rval;
|
4332
|
-
}, dispatchException: function dispatchException(e3) {
|
4333
|
-
if (this.done)
|
4334
|
-
throw e3;
|
4335
|
-
var r3 = this;
|
4336
|
-
function handle(n3, o4) {
|
4337
|
-
return a3.type = "throw", a3.arg = e3, r3.next = n3, o4 && (r3.method = "next", r3.arg = t2), !!o4;
|
4338
|
-
}
|
4339
|
-
for (var o3 = this.tryEntries.length - 1; o3 >= 0; --o3) {
|
4340
|
-
var i3 = this.tryEntries[o3], a3 = i3.completion;
|
4341
|
-
if ("root" === i3.tryLoc)
|
4342
|
-
return handle("end");
|
4343
|
-
if (i3.tryLoc <= this.prev) {
|
4344
|
-
var c3 = n2.call(i3, "catchLoc"), u3 = n2.call(i3, "finallyLoc");
|
4345
|
-
if (c3 && u3) {
|
4346
|
-
if (this.prev < i3.catchLoc)
|
4347
|
-
return handle(i3.catchLoc, true);
|
4348
|
-
if (this.prev < i3.finallyLoc)
|
4349
|
-
return handle(i3.finallyLoc);
|
4350
|
-
} else if (c3) {
|
4351
|
-
if (this.prev < i3.catchLoc)
|
4352
|
-
return handle(i3.catchLoc, true);
|
4353
|
-
} else {
|
4354
|
-
if (!u3)
|
4355
|
-
throw new Error("try statement without catch or finally");
|
4356
|
-
if (this.prev < i3.finallyLoc)
|
4357
|
-
return handle(i3.finallyLoc);
|
4358
|
-
}
|
4359
|
-
}
|
4360
|
-
}
|
4361
|
-
}, abrupt: function abrupt(t3, e3) {
|
4362
|
-
for (var r3 = this.tryEntries.length - 1; r3 >= 0; --r3) {
|
4363
|
-
var o3 = this.tryEntries[r3];
|
4364
|
-
if (o3.tryLoc <= this.prev && n2.call(o3, "finallyLoc") && this.prev < o3.finallyLoc) {
|
4365
|
-
var i3 = o3;
|
4366
|
-
break;
|
4367
|
-
}
|
4368
|
-
}
|
4369
|
-
i3 && ("break" === t3 || "continue" === t3) && i3.tryLoc <= e3 && e3 <= i3.finallyLoc && (i3 = null);
|
4370
|
-
var a3 = i3 ? i3.completion : {};
|
4371
|
-
return a3.type = t3, a3.arg = e3, i3 ? (this.method = "next", this.next = i3.finallyLoc, y2) : this.complete(a3);
|
4372
|
-
}, complete: function complete(t3, e3) {
|
4373
|
-
if ("throw" === t3.type)
|
4374
|
-
throw t3.arg;
|
4375
|
-
return "break" === t3.type || "continue" === t3.type ? this.next = t3.arg : "return" === t3.type ? (this.rval = this.arg = t3.arg, this.method = "return", this.next = "end") : "normal" === t3.type && e3 && (this.next = e3), y2;
|
4376
|
-
}, finish: function finish(t3) {
|
4377
|
-
for (var e3 = this.tryEntries.length - 1; e3 >= 0; --e3) {
|
4378
|
-
var r3 = this.tryEntries[e3];
|
4379
|
-
if (r3.finallyLoc === t3)
|
4380
|
-
return this.complete(r3.completion, r3.afterLoc), resetTryEntry(r3), y2;
|
4381
|
-
}
|
4382
|
-
}, "catch": function _catch(t3) {
|
4383
|
-
for (var e3 = this.tryEntries.length - 1; e3 >= 0; --e3) {
|
4384
|
-
var r3 = this.tryEntries[e3];
|
4385
|
-
if (r3.tryLoc === t3) {
|
4386
|
-
var n3 = r3.completion;
|
4387
|
-
if ("throw" === n3.type) {
|
4388
|
-
var o3 = n3.arg;
|
4389
|
-
resetTryEntry(r3);
|
4390
|
-
}
|
4391
|
-
return o3;
|
4392
|
-
}
|
4393
|
-
}
|
4394
|
-
throw new Error("illegal catch attempt");
|
4395
|
-
}, delegateYield: function delegateYield(e3, r3, n3) {
|
4396
|
-
return this.delegate = { iterator: values(e3), resultName: r3, nextLoc: n3 }, "next" === this.method && (this.arg = t2), y2;
|
4397
|
-
} }, e2;
|
4398
|
-
}
|
4399
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
4400
|
-
try {
|
4401
|
-
var info = gen[key](arg);
|
4402
|
-
var value = info.value;
|
4403
|
-
} catch (error2) {
|
4404
|
-
reject(error2);
|
4405
|
-
return;
|
4406
|
-
}
|
4407
|
-
if (info.done) {
|
4408
|
-
resolve(value);
|
4409
|
-
} else {
|
4410
|
-
Promise.resolve(value).then(_next, _throw);
|
4411
|
-
}
|
4412
|
-
}
|
4413
|
-
function _asyncToGenerator(fn) {
|
4414
|
-
return function() {
|
4415
|
-
var self = this, args = arguments;
|
4416
|
-
return new Promise(function(resolve, reject) {
|
4417
|
-
var gen = fn.apply(self, args);
|
4418
|
-
function _next(value) {
|
4419
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
4420
|
-
}
|
4421
|
-
function _throw(err) {
|
4422
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
4423
|
-
}
|
4424
|
-
_next(void 0);
|
4425
|
-
});
|
4426
|
-
};
|
4427
|
-
}
|
4428
|
-
var wujieVueOptions = {
|
4429
|
-
name: "WujieVue",
|
4430
|
-
props: {
|
4431
|
-
width: {
|
4432
|
-
type: String,
|
4433
|
-
"default": ""
|
4434
|
-
},
|
4435
|
-
height: {
|
4436
|
-
type: String,
|
4437
|
-
"default": ""
|
4438
|
-
},
|
4439
|
-
name: {
|
4440
|
-
type: String,
|
4441
|
-
"default": ""
|
4442
|
-
},
|
4443
|
-
loading: {
|
4444
|
-
type: HTMLElement,
|
4445
|
-
"default": void 0
|
4446
|
-
},
|
4447
|
-
url: {
|
4448
|
-
type: String,
|
4449
|
-
"default": ""
|
4450
|
-
},
|
4451
|
-
sync: {
|
4452
|
-
type: Boolean,
|
4453
|
-
"default": void 0
|
4454
|
-
},
|
4455
|
-
prefix: {
|
4456
|
-
type: Object,
|
4457
|
-
"default": void 0
|
4458
|
-
},
|
4459
|
-
alive: {
|
4460
|
-
type: Boolean,
|
4461
|
-
"default": void 0
|
4462
|
-
},
|
4463
|
-
props: {
|
4464
|
-
type: Object,
|
4465
|
-
"default": void 0
|
4466
|
-
},
|
4467
|
-
attrs: {
|
4468
|
-
type: Object,
|
4469
|
-
"default": void 0
|
4470
|
-
},
|
4471
|
-
replace: {
|
4472
|
-
type: Function,
|
4473
|
-
"default": void 0
|
4474
|
-
},
|
4475
|
-
fetch: {
|
4476
|
-
type: Function,
|
4477
|
-
"default": void 0
|
4478
|
-
},
|
4479
|
-
fiber: {
|
4480
|
-
type: Boolean,
|
4481
|
-
"default": void 0
|
4482
|
-
},
|
4483
|
-
degrade: {
|
4484
|
-
type: Boolean,
|
4485
|
-
"default": void 0
|
4486
|
-
},
|
4487
|
-
plugins: {
|
4488
|
-
type: Array,
|
4489
|
-
"default": null
|
4490
|
-
},
|
4491
|
-
beforeLoad: {
|
4492
|
-
type: Function,
|
4493
|
-
"default": null
|
4494
|
-
},
|
4495
|
-
beforeMount: {
|
4496
|
-
type: Function,
|
4497
|
-
"default": null
|
4498
|
-
},
|
4499
|
-
afterMount: {
|
4500
|
-
type: Function,
|
4501
|
-
"default": null
|
4502
|
-
},
|
4503
|
-
beforeUnmount: {
|
4504
|
-
type: Function,
|
4505
|
-
"default": null
|
4506
|
-
},
|
4507
|
-
afterUnmount: {
|
4508
|
-
type: Function,
|
4509
|
-
"default": null
|
4510
|
-
},
|
4511
|
-
activated: {
|
4512
|
-
type: Function,
|
4513
|
-
"default": null
|
4514
|
-
},
|
4515
|
-
deactivated: {
|
4516
|
-
type: Function,
|
4517
|
-
"default": null
|
4518
|
-
},
|
4519
|
-
loadError: {
|
4520
|
-
type: Function,
|
4521
|
-
"default": null
|
4522
|
-
}
|
4523
|
-
},
|
4524
|
-
data: function data() {
|
4525
|
-
return {
|
4526
|
-
startAppQueue: Promise.resolve()
|
4527
|
-
};
|
4528
|
-
},
|
4529
|
-
mounted: function mounted() {
|
4530
|
-
var _this = this;
|
4531
|
-
bus$1.$onAll(this.handleEmit);
|
4532
|
-
this.execStartApp();
|
4533
|
-
this.$watch(function() {
|
4534
|
-
return _this.name + _this.url;
|
4535
|
-
}, function() {
|
4536
|
-
return _this.execStartApp();
|
4537
|
-
});
|
4538
|
-
},
|
4539
|
-
methods: {
|
4540
|
-
handleEmit: function handleEmit(event) {
|
4541
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
4542
|
-
args[_key - 1] = arguments[_key];
|
4543
|
-
}
|
4544
|
-
this.$emit.apply(this, [event].concat(args));
|
4545
|
-
},
|
4546
|
-
startApp: function startApp$1() {
|
4547
|
-
var _this2 = this;
|
4548
|
-
return _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() {
|
4549
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
4550
|
-
while (1)
|
4551
|
-
switch (_context.prev = _context.next) {
|
4552
|
-
case 0:
|
4553
|
-
_context.prev = 0;
|
4554
|
-
_context.next = 3;
|
4555
|
-
return startApp({
|
4556
|
-
name: _this2.name,
|
4557
|
-
url: _this2.url,
|
4558
|
-
el: _this2.$refs.wujie,
|
4559
|
-
loading: _this2.loading,
|
4560
|
-
alive: _this2.alive,
|
4561
|
-
fetch: _this2.fetch,
|
4562
|
-
props: _this2.props,
|
4563
|
-
attrs: _this2.attrs,
|
4564
|
-
replace: _this2.replace,
|
4565
|
-
sync: _this2.sync,
|
4566
|
-
prefix: _this2.prefix,
|
4567
|
-
fiber: _this2.fiber,
|
4568
|
-
degrade: _this2.degrade,
|
4569
|
-
plugins: _this2.plugins,
|
4570
|
-
beforeLoad: _this2.beforeLoad,
|
4571
|
-
beforeMount: _this2.beforeMount,
|
4572
|
-
afterMount: _this2.afterMount,
|
4573
|
-
beforeUnmount: _this2.beforeUnmount,
|
4574
|
-
afterUnmount: _this2.afterUnmount,
|
4575
|
-
activated: _this2.activated,
|
4576
|
-
deactivated: _this2.deactivated,
|
4577
|
-
loadError: _this2.loadError
|
4578
|
-
});
|
4579
|
-
case 3:
|
4580
|
-
_context.next = 8;
|
4581
|
-
break;
|
4582
|
-
case 5:
|
4583
|
-
_context.prev = 5;
|
4584
|
-
_context.t0 = _context["catch"](0);
|
4585
|
-
console.log(_context.t0);
|
4586
|
-
case 8:
|
4587
|
-
case "end":
|
4588
|
-
return _context.stop();
|
4589
|
-
}
|
4590
|
-
}, _callee, null, [[0, 5]]);
|
4591
|
-
}))();
|
4592
|
-
},
|
4593
|
-
execStartApp: function execStartApp() {
|
4594
|
-
this.startAppQueue = this.startAppQueue.then(this.startApp);
|
4595
|
-
},
|
4596
|
-
destroy: function destroy() {
|
4597
|
-
destroyApp(this.name);
|
4598
|
-
}
|
4599
|
-
},
|
4600
|
-
beforeDestroy: function beforeDestroy() {
|
4601
|
-
bus$1.$offAll(this.handleEmit);
|
4602
|
-
},
|
4603
|
-
render: function render() {
|
4604
|
-
return h("div", {
|
4605
|
-
style: {
|
4606
|
-
width: this.width,
|
4607
|
-
height: this.height
|
4608
|
-
},
|
4609
|
-
ref: "wujie"
|
4610
|
-
});
|
4611
|
-
}
|
4612
|
-
};
|
4613
|
-
var WujieVue = defineComponent(wujieVueOptions);
|
4614
|
-
WujieVue.setupApp = setupApp;
|
4615
|
-
WujieVue.preloadApp = preloadApp;
|
4616
|
-
WujieVue.bus = bus$1;
|
4617
|
-
WujieVue.destroyApp = destroyApp;
|
4618
|
-
WujieVue.install = function(app) {
|
4619
|
-
app.component("WujieVue", WujieVue);
|
4620
|
-
};
|
4621
|
-
const { bus } = WujieVue;
|
4622
|
-
class EventBus {
|
4623
|
-
constructor(framework) {
|
4624
|
-
__publicField(this, "bus");
|
4625
|
-
__publicField(this, "framework");
|
4626
|
-
this.framework = framework || "wujie";
|
4627
|
-
this.bus = this.initializeBus();
|
4628
|
-
}
|
4629
|
-
initializeBus() {
|
4630
|
-
switch (this.framework) {
|
4631
|
-
case "wujie":
|
4632
|
-
return window.$wujie ? window.$wujie.bus : bus;
|
4633
|
-
case "otherFramework":
|
4634
|
-
break;
|
4635
|
-
default:
|
4636
|
-
logger.warning("EventBus", "init", "未检测到已识别的微前端框架");
|
4637
|
-
return null;
|
4638
|
-
}
|
4639
|
-
}
|
4640
|
-
on(event, callback) {
|
4641
|
-
if (!this.bus)
|
4642
|
-
return logger.warning("EventBus", "on", "没有可用于当前框架的总线");
|
4643
|
-
if (typeof callback !== "function")
|
4644
|
-
return logger.error("EventBus", "on", "回调必须是一个函数");
|
4645
|
-
this.bus.$on(event, callback);
|
4646
|
-
}
|
4647
|
-
once(event, callback) {
|
4648
|
-
if (!this.bus)
|
4649
|
-
return logger.warning("EventBus", "once", "没有可用于当前框架的总线");
|
4650
|
-
if (typeof callback !== "function")
|
4651
|
-
return logger.error("EventBus", "once", "回调必须是一个函数");
|
4652
|
-
this.bus.$once(event, callback);
|
4653
|
-
}
|
4654
|
-
emit(event, ...args) {
|
4655
|
-
if (!this.bus)
|
4656
|
-
return logger.warning("EventBus", "emit", "没有可用于当前框架的总线");
|
4657
|
-
this.bus.$emit(event, ...args);
|
4658
|
-
}
|
4659
|
-
off(event, callback) {
|
4660
|
-
if (!this.bus)
|
4661
|
-
return logger.warning("EventBus", "off", "没有可用于当前框架的总线");
|
4662
|
-
this.bus.$off(event, callback);
|
4663
|
-
}
|
4664
|
-
clear() {
|
4665
|
-
if (!this.bus)
|
4666
|
-
return logger.warning("EventBus", "clear", "没有可用于当前框架的总线");
|
4667
|
-
this.bus.$clear();
|
4668
|
-
}
|
4669
|
-
}
|
4670
|
-
function getMicroAppData(id) {
|
4671
|
-
const iframeElement = window.document.querySelector(`iframe[name="${id}"]`);
|
4672
|
-
return iframeElement ? iframeElement.contentWindow : null;
|
4673
|
-
}
|
4674
|
-
export {
|
4675
|
-
EventBus,
|
4676
|
-
F as formatDay,
|
4677
|
-
I as formatSeconds,
|
4678
|
-
G as formatTime,
|
4679
|
-
J as formatTimeFn,
|
4680
|
-
E as getBeforeDays,
|
4681
|
-
H as getCurDtm,
|
4682
|
-
getMicroAppData,
|
4683
|
-
D as getNextDays,
|
4684
|
-
C as getToday,
|
4685
|
-
i as is,
|
4686
|
-
v as isArray,
|
4687
|
-
t as isBoolean,
|
4688
|
-
A as isClient,
|
4689
|
-
j as isDate,
|
4690
|
-
b as isDef,
|
4691
|
-
x as isElement,
|
4692
|
-
f as isEmpty,
|
4693
|
-
r as isFunction,
|
4694
|
-
y as isMap,
|
4695
|
-
k as isNull,
|
4696
|
-
m as isNullAndUnDef,
|
4697
|
-
n as isNullOrUnDef,
|
4698
|
-
o as isNumber,
|
4699
|
-
e as isObject,
|
4700
|
-
p as isPromise,
|
4701
|
-
u as isRegExp,
|
4702
|
-
z as isServer,
|
4703
|
-
q as isString,
|
4704
|
-
c as isUnDef,
|
4705
|
-
B as isValidKey,
|
4706
|
-
w as isWindow,
|
4707
|
-
a as localCache,
|
4708
|
-
logger,
|
4709
|
-
s as sessionCache
|
4710
|
-
};
|