@cloud-app-dev/vidc 3.1.15 → 3.1.17
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/es/Api/index.js +0 -23
- package/es/AppContext/Sync.js +1 -15
- package/es/AppContext/index.js +21 -52
- package/es/AppContext/static.js +0 -7
- package/es/Auth/index.js +2 -5
- package/es/AutoExit/index.js +1 -5
- package/es/Box/BetweenBox/index.js +6 -8
- package/es/Box/InfoBox/index.js +6 -8
- package/es/Box/TwoColumnBox/index.js +8 -18
- package/es/Box/deps/grid-factory.js +0 -12
- package/es/Box/index.js +4 -6
- package/es/CheckGroupFixed/index.js +19 -34
- package/es/Config/index.js +0 -4
- package/es/Config/utils.js +3 -18
- package/es/ConfigContext/index.js +1 -3
- package/es/CustomRenderSelect/index.js +13 -29
- package/es/DisableMark/index.js +2 -2
- package/es/DomMove/index.js +24 -37
- package/es/DomMove/utils.js +3 -8
- package/es/Drag/DragAndDropItem.js +19 -37
- package/es/Drag/DropItem.js +5 -15
- package/es/Drawer/Demo.js +3 -17
- package/es/Drawer/Footer.js +3 -5
- package/es/Drawer/index.js +28 -50
- package/es/ErrorFallback/index.js +1 -3
- package/es/FullScreen/index.js +8 -18
- package/es/HightLevel/index.js +1 -5
- package/es/IconFont/index.js +5 -11
- package/es/ImageView/index.js +8 -20
- package/es/Input/index.js +14 -27
- package/es/InstanceHistory/index.js +0 -2
- package/es/LabelValue/index.js +8 -10
- package/es/List/DynamicGridList/Demo.js +0 -11
- package/es/List/DynamicGridList/index.js +16 -25
- package/es/List/DynamicList/index.js +23 -38
- package/es/List/GridList/Demo.js +3 -16
- package/es/List/GridList/hook.js +34 -65
- package/es/List/GridList/utils.js +0 -1
- package/es/List/VList/index.js +10 -20
- package/es/List/VList/utils.js +2 -3
- package/es/List/index.js +5 -7
- package/es/LoaderApp/index.js +5 -22
- package/es/LoaderApp/loader.js +5 -13
- package/es/LoaderApp/sandbox.back.js +16 -81
- package/es/LoaderApp/sandbox.js +8 -22
- package/es/LoaderApp/utils.js +20 -49
- package/es/LoaderScript/index.js +8 -19
- package/es/LoaderScript/utils.js +0 -51
- package/es/Map/BasicMap/AMapInstance.js +0 -10
- package/es/Map/BasicMap/LeafletInstance.js +11 -20
- package/es/Map/BasicMap/index.js +6 -28
- package/es/Map/ClusterLayer/hook.js +10 -32
- package/es/Map/ClusterLayer/index.js +2 -6
- package/es/Map/Config/index.js +8 -21
- package/es/Map/Config/utils.js +0 -6
- package/es/Map/Context/index.js +2 -22
- package/es/Map/FindPio/index.js +0 -2
- package/es/Map/InfoWindow/MakerLikeWindow.js +9 -28
- package/es/Map/InfoWindow/demo.js +5 -22
- package/es/Map/InfoWindow/index.js +13 -29
- package/es/Map/LevelCenter/DragMarker/index.js +5 -9
- package/es/Map/LevelCenter/demo.js +6 -16
- package/es/Map/LevelCenter/index.js +8 -15
- package/es/Map/LoaderMap/index.js +10 -10
- package/es/Map/MapDrawSelect/demo.js +12 -23
- package/es/Map/MapDrawSelect/index.js +14 -21
- package/es/Map/MouseTool/index.js +16 -26
- package/es/Map/MouseTool/useMouseTools.js +6 -29
- package/es/Map/ResetTools/index.js +4 -8
- package/es/Map/SinglePoint/index.js +6 -13
- package/es/Map/hook/useMapEvent.js +3 -7
- package/es/Map/hook/useMapType.js +1 -2
- package/es/Map/useMarker/index.js +10 -24
- package/es/Map/withMap/index.js +0 -2
- package/es/Modal/index.d.ts +1 -1
- package/es/Modal/index.js +29 -50
- package/es/Picture/component/DefaultRects/RectInfo.js +11 -25
- package/es/Picture/component/DefaultRects/index.js +3 -5
- package/es/Picture/component/DrawRect/index.js +6 -8
- package/es/Picture/component/RectMenu/index.js +10 -16
- package/es/Picture/component/RectMenu/utils.js +3 -6
- package/es/Picture/component/Tools/index.js +6 -8
- package/es/Picture/component/WheelScale/index.js +3 -6
- package/es/Picture/dragBound.js +4 -17
- package/es/Picture/index.js +46 -87
- package/es/Picture/loadCaptureRectImage.js +10 -26
- package/es/Picture/useDraw.js +20 -39
- package/es/Picture/utils.js +2 -11
- package/es/Player/api/index.js +14 -78
- package/es/Player/context.js +1 -2
- package/es/Player/contraller_bar/bar.js +5 -9
- package/es/Player/contraller_bar/contraller_event.js +5 -23
- package/es/Player/contraller_bar/index.js +7 -9
- package/es/Player/contraller_bar/left_bar.js +15 -27
- package/es/Player/contraller_bar/right_bar.js +7 -18
- package/es/Player/contraller_bar/time.js +6 -16
- package/es/Player/contraller_bar/useBarStatus.js +5 -16
- package/es/Player/contraller_bar/volume.js +6 -26
- package/es/Player/demo.js +59 -75
- package/es/Player/event/errorEvent.js +14 -39
- package/es/Player/event/eventName.js +1 -1
- package/es/Player/event/index.js +19 -53
- package/es/Player/fps_play.js +10 -27
- package/es/Player/frontend_player.js +10 -19
- package/es/Player/frontend_timeline.js +25 -47
- package/es/Player/iconfont.js +2 -5
- package/es/Player/live_heart.js +2 -14
- package/es/Player/message.js +9 -29
- package/es/Player/segment_player.js +39 -77
- package/es/Player/segment_timeline.js +42 -68
- package/es/Player/single_player.js +64 -87
- package/es/Player/style/iconfont.js +10 -17
- package/es/Player/timeline.js +11 -28
- package/es/Player/util.js +0 -21
- package/es/PlayerExt/demo.js +11 -21
- package/es/PlayerExt/index.js +18 -43
- package/es/Progress/index.js +3 -15
- package/es/ROI/demo.js +0 -2
- package/es/ROI/index.js +15 -22
- package/es/ScreenPlayer/Live.js +35 -68
- package/es/ScreenPlayer/LiveTools.js +24 -37
- package/es/ScreenPlayer/PlayerWithExt.js +43 -78
- package/es/ScreenPlayer/RatePick.js +1 -3
- package/es/ScreenPlayer/Record.js +52 -123
- package/es/ScreenPlayer/RecordTools.js +32 -53
- package/es/ScreenPlayer/ScreenSelect.js +1 -3
- package/es/ScreenPlayer/SegmentTimeLine.js +8 -12
- package/es/ScreenPlayer/TimeMode.js +1 -3
- package/es/ScreenPlayer/TimeSelect.js +11 -26
- package/es/ScreenPlayer/demo.js +3 -1
- package/es/ScreenPlayer/demo2.js +10 -46
- package/es/ScreenPlayer/useRecordList.js +7 -72
- package/es/ScreenPlayer/useTimeSlider.js +40 -132
- package/es/ScreenPlayer/useVideoFit.js +5 -18
- package/es/ScreenPlayer/utils.js +0 -8
- package/es/Service/fetch-adapter.js +2 -37
- package/es/Service/http.js +8 -27
- package/es/TableLayout/index.js +3 -7
- package/es/ThemeAntd/demo.js +0 -2
- package/es/Timeout/index.js +10 -26
- package/es/Tree/demo.js +0 -2
- package/es/Tree/index.js +14 -21
- package/es/useDrawROI/index.js +51 -105
- package/es/useEventEmitterHandle/index.js +2 -6
- package/es/useFullscreen/demo.js +6 -16
- package/es/useFullscreen/index.js +5 -25
- package/es/useHistory/index.js +0 -2
- package/es/useInfiniteScroll/index.js +14 -39
- package/es/useRafInterval/index.js +2 -26
- package/es/useSimpleState/index.js +5 -16
- package/es/useVirtualList/index.js +19 -57
- package/es/utils.js +0 -28
- package/package.json +14 -14
package/es/LoaderApp/index.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
|
|
3
2
|
import _useUnmount from "ahooks/es/useUnmount";
|
|
4
3
|
import _nextTick from "@cloud-app-dev/utils/es/nextTick";
|
|
5
4
|
import _useMount from "ahooks/es/useMount";
|
|
6
5
|
import _uuid from "@cloud-app-dev/utils/es/uuid";
|
|
7
|
-
|
|
8
6
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
9
|
-
|
|
10
7
|
import { __awaiter } from "tslib";
|
|
11
8
|
import React, { useRef, useMemo } from 'react';
|
|
12
9
|
import LoaderModule from './loader';
|
|
13
10
|
import "./index.css";
|
|
14
|
-
|
|
15
11
|
function LoaderApp(_ref) {
|
|
16
12
|
var _this = this;
|
|
17
|
-
|
|
18
13
|
var appConfig = _ref.appConfig,
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
appProps = _ref.appProps,
|
|
15
|
+
style = _ref.style;
|
|
21
16
|
var domRef = useRef(null);
|
|
22
17
|
var styleRef = useRef(null);
|
|
23
18
|
var loadedAppRef = useRef();
|
|
@@ -25,23 +20,20 @@ function LoaderApp(_ref) {
|
|
|
25
20
|
return _uuid();
|
|
26
21
|
}, []);
|
|
27
22
|
var statusRef = useRef();
|
|
28
|
-
|
|
29
23
|
_useMount(function () {
|
|
30
24
|
if (!appConfig) {
|
|
31
25
|
console.error('微应用不存在', 'appConfig ->', appConfig, 'appProps ->', appProps);
|
|
32
26
|
return undefined;
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
if (!domRef.current || !styleRef.current) {
|
|
36
29
|
console.error('LoaderApp组件未正常初始化!', 'config ->', appConfig, 'appProps ->', appProps);
|
|
37
30
|
return undefined;
|
|
38
31
|
}
|
|
39
|
-
|
|
40
32
|
var props = Object.assign(Object.assign({}, appProps), {
|
|
41
33
|
container: domRef.current
|
|
42
34
|
});
|
|
43
35
|
var routerPrefix = appConfig.routerPrefix,
|
|
44
|
-
|
|
36
|
+
html = appConfig.html;
|
|
45
37
|
var options = {
|
|
46
38
|
html: html,
|
|
47
39
|
name: routerPrefix,
|
|
@@ -54,24 +46,20 @@ function LoaderApp(_ref) {
|
|
|
54
46
|
while (1) {
|
|
55
47
|
switch (_context.prev = _context.next) {
|
|
56
48
|
case 0:
|
|
57
|
-
loadedAppRef.current = mod;
|
|
58
|
-
|
|
49
|
+
loadedAppRef.current = mod;
|
|
50
|
+
// 沙箱销毁方法
|
|
59
51
|
_context.next = 3;
|
|
60
52
|
return mod.bootstrap(props);
|
|
61
|
-
|
|
62
53
|
case 3:
|
|
63
54
|
_nextTick(function () {
|
|
64
55
|
return statusRef.current = 'bootstrap';
|
|
65
56
|
});
|
|
66
|
-
|
|
67
57
|
_context.next = 6;
|
|
68
58
|
return mod.mount(props);
|
|
69
|
-
|
|
70
59
|
case 6:
|
|
71
60
|
_nextTick(function () {
|
|
72
61
|
return statusRef.current = 'mounted';
|
|
73
62
|
});
|
|
74
|
-
|
|
75
63
|
case 7:
|
|
76
64
|
case "end":
|
|
77
65
|
return _context.stop();
|
|
@@ -81,7 +69,6 @@ function LoaderApp(_ref) {
|
|
|
81
69
|
}));
|
|
82
70
|
});
|
|
83
71
|
});
|
|
84
|
-
|
|
85
72
|
_useUnmount(function () {
|
|
86
73
|
if (loadedAppRef.current) {
|
|
87
74
|
var app = loadedAppRef.current;
|
|
@@ -89,15 +76,12 @@ function LoaderApp(_ref) {
|
|
|
89
76
|
container: domRef.current
|
|
90
77
|
});
|
|
91
78
|
app.unmount(props);
|
|
92
|
-
|
|
93
79
|
_nextTick(function () {
|
|
94
80
|
return statusRef.current = 'unmount';
|
|
95
81
|
});
|
|
96
|
-
|
|
97
82
|
loadedAppRef.current = null;
|
|
98
83
|
}
|
|
99
84
|
});
|
|
100
|
-
|
|
101
85
|
return /*#__PURE__*/React.createElement("main", {
|
|
102
86
|
ref: domRef,
|
|
103
87
|
className: "loaded-app-layout ".concat(appConfig.routerPrefix, "-").concat(id),
|
|
@@ -112,7 +96,6 @@ function LoaderApp(_ref) {
|
|
|
112
96
|
}
|
|
113
97
|
}));
|
|
114
98
|
}
|
|
115
|
-
|
|
116
99
|
LoaderApp.defaultProps = {
|
|
117
100
|
appConfig: {},
|
|
118
101
|
appProps: {},
|
package/es/LoaderApp/loader.js
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
|
|
3
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4
|
-
|
|
5
3
|
import { __awaiter } from "tslib";
|
|
6
4
|
import { arrayify, rewrite, importHTML } from './utils';
|
|
7
5
|
export function createScopedCssText(_ref) {
|
|
8
6
|
var styleNode = _ref.styleNode,
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
prefix = _ref.prefix;
|
|
11
8
|
var _a;
|
|
12
|
-
|
|
13
9
|
var sheet = styleNode.sheet;
|
|
14
10
|
var rules = arrayify((_a = sheet === null || sheet === void 0 ? void 0 : sheet.cssRules) !== null && _a !== void 0 ? _a : []);
|
|
15
11
|
return rewrite(rules, prefix);
|
|
16
12
|
}
|
|
17
13
|
export function LoaderStyle(_ref2) {
|
|
18
14
|
var cssText = _ref2.cssText,
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
prefix = _ref2.prefix,
|
|
16
|
+
styleNode = _ref2.styleNode;
|
|
21
17
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
22
18
|
var scopeCssText;
|
|
23
19
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -30,7 +26,6 @@ export function LoaderStyle(_ref2) {
|
|
|
30
26
|
styleNode: styleNode
|
|
31
27
|
});
|
|
32
28
|
styleNode.textContent = scopeCssText;
|
|
33
|
-
|
|
34
29
|
case 3:
|
|
35
30
|
case "end":
|
|
36
31
|
return _context.stop();
|
|
@@ -41,8 +36,8 @@ export function LoaderStyle(_ref2) {
|
|
|
41
36
|
}
|
|
42
37
|
export default function LoaderModule(_ref3) {
|
|
43
38
|
var prefix = _ref3.prefix,
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
styleNode = _ref3.styleNode,
|
|
40
|
+
html = _ref3.html;
|
|
46
41
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
47
42
|
var cssText, exports, result;
|
|
48
43
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -51,7 +46,6 @@ export default function LoaderModule(_ref3) {
|
|
|
51
46
|
case 0:
|
|
52
47
|
_context2.next = 2;
|
|
53
48
|
return importHTML(html);
|
|
54
|
-
|
|
55
49
|
case 2:
|
|
56
50
|
result = _context2.sent;
|
|
57
51
|
cssText = result.cssTexts.join(' ');
|
|
@@ -62,10 +56,8 @@ export default function LoaderModule(_ref3) {
|
|
|
62
56
|
prefix: prefix,
|
|
63
57
|
styleNode: styleNode
|
|
64
58
|
});
|
|
65
|
-
|
|
66
59
|
case 7:
|
|
67
60
|
return _context2.abrupt("return", exports);
|
|
68
|
-
|
|
69
61
|
case 8:
|
|
70
62
|
case "end":
|
|
71
63
|
return _context2.stop();
|
|
@@ -1,39 +1,27 @@
|
|
|
1
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
|
|
3
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
|
|
9
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
|
|
11
6
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
-
|
|
13
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
-
|
|
15
8
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
16
|
-
|
|
17
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
-
|
|
19
10
|
/**
|
|
20
11
|
* @file 全局window沙盒,隔离变量环境
|
|
21
12
|
*/
|
|
22
13
|
var originWindow = window;
|
|
23
14
|
var constructableMap = new WeakMap();
|
|
24
|
-
|
|
25
15
|
function isConstructable(fn) {
|
|
26
16
|
if (constructableMap.has(fn)) {
|
|
27
17
|
return constructableMap.get(fn);
|
|
28
18
|
}
|
|
29
|
-
|
|
30
19
|
var constructableFunctionRegex = /^function\b\s[A-Z].*/;
|
|
31
20
|
var classRegex = /^class\b/;
|
|
32
21
|
var constructable = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1 || constructableFunctionRegex.test(fn.toString()) || classRegex.test(fn.toString());
|
|
33
22
|
constructableMap.set(fn, constructable);
|
|
34
23
|
return constructable;
|
|
35
24
|
}
|
|
36
|
-
|
|
37
25
|
var naughtySafari = typeof document.all === 'function' && typeof document.all === 'undefined';
|
|
38
26
|
var isCallable = naughtySafari ? function (fn) {
|
|
39
27
|
return typeof fn === 'function' && typeof fn !== 'undefined';
|
|
@@ -41,45 +29,34 @@ var isCallable = naughtySafari ? function (fn) {
|
|
|
41
29
|
return typeof fn === 'function';
|
|
42
30
|
};
|
|
43
31
|
var boundedMap = new WeakMap();
|
|
44
|
-
|
|
45
32
|
function isBoundedFunction(fn) {
|
|
46
33
|
if (boundedMap.has(fn)) {
|
|
47
34
|
return boundedMap.get(fn);
|
|
48
35
|
}
|
|
49
|
-
|
|
50
36
|
var bounded = fn.name.indexOf('bound ') === 0 && !fn.hasOwnProperty('prototype');
|
|
51
37
|
boundedMap.set(fn, bounded);
|
|
52
38
|
return bounded;
|
|
53
39
|
}
|
|
54
|
-
|
|
55
40
|
var functionBoundedValueMap = new WeakMap();
|
|
56
|
-
|
|
57
41
|
function getTargetValue(target, value) {
|
|
58
42
|
var cachedBoundFunction = functionBoundedValueMap.get(value);
|
|
59
|
-
|
|
60
43
|
if (cachedBoundFunction) {
|
|
61
44
|
return cachedBoundFunction;
|
|
62
45
|
}
|
|
63
|
-
|
|
64
46
|
if (isCallable(value) && !isBoundedFunction(value) && !isConstructable(value)) {
|
|
65
47
|
var boundValue = Function.prototype.bind.call(value, target);
|
|
66
|
-
|
|
67
48
|
for (var key in value) {
|
|
68
49
|
boundValue[key] = value[key];
|
|
69
50
|
}
|
|
70
|
-
|
|
71
51
|
if (value.hasOwnProperty('prototype') && !boundValue.hasOwnProperty('prototype')) boundValue.prototype = value.prototype;
|
|
72
52
|
functionBoundedValueMap.set(value, boundValue);
|
|
73
53
|
return boundValue;
|
|
74
54
|
}
|
|
75
|
-
|
|
76
55
|
return value;
|
|
77
56
|
}
|
|
78
|
-
|
|
79
57
|
function getScript(scriptText) {
|
|
80
58
|
return '(function(window){with(window){;'.concat(scriptText, '\n').concat('}}).bind(window.proxy)(window.proxy);');
|
|
81
59
|
}
|
|
82
|
-
|
|
83
60
|
var rawAddEventListener = window.addEventListener;
|
|
84
61
|
var rawRemoveEventListener = window.removeEventListener;
|
|
85
62
|
var rawWindowInterval = window.setInterval;
|
|
@@ -98,35 +75,27 @@ var unscopables = {
|
|
|
98
75
|
parseFloat: true,
|
|
99
76
|
Float32Array: true
|
|
100
77
|
};
|
|
101
|
-
|
|
102
78
|
function createFakeWindow() {
|
|
103
79
|
var fakeWindow = {};
|
|
104
80
|
Object.getOwnPropertyNames(originWindow).forEach(function (key) {
|
|
105
81
|
var descriptor = Object.getOwnPropertyDescriptor(originWindow, key);
|
|
106
|
-
|
|
107
82
|
if (descriptor && !descriptor.configurable) {
|
|
108
83
|
var hasGetter = Object.prototype.hasOwnProperty.call(descriptor, 'get');
|
|
109
|
-
|
|
110
84
|
if (key === 'top' || key === 'parent' || key === 'self' || key === 'window') {
|
|
111
85
|
descriptor.configurable = true;
|
|
112
|
-
|
|
113
86
|
if (!hasGetter) {
|
|
114
87
|
descriptor.writable = true;
|
|
115
88
|
}
|
|
116
89
|
}
|
|
117
|
-
|
|
118
90
|
Object.defineProperty(fakeWindow, key, Object.freeze(descriptor));
|
|
119
91
|
}
|
|
120
92
|
});
|
|
121
93
|
return fakeWindow;
|
|
122
94
|
}
|
|
123
|
-
|
|
124
95
|
var Sandbox = /*#__PURE__*/function () {
|
|
125
96
|
function Sandbox(showlog) {
|
|
126
97
|
var _this = this;
|
|
127
|
-
|
|
128
98
|
_classCallCheck(this, Sandbox);
|
|
129
|
-
|
|
130
99
|
this.fakeWindow = createFakeWindow();
|
|
131
100
|
this.updateKeys = new Set();
|
|
132
101
|
this.listenerMap = new Map();
|
|
@@ -140,7 +109,6 @@ var Sandbox = /*#__PURE__*/function () {
|
|
|
140
109
|
set: function set(target, key, value) {
|
|
141
110
|
if (!_this.hasDisposed) {
|
|
142
111
|
_this.updateKeys.add(key);
|
|
143
|
-
|
|
144
112
|
try {
|
|
145
113
|
if (!_this.fakeWindow.hasOwnProperty(key) && target.hasOwnProperty(key)) {
|
|
146
114
|
// @ts-ignore
|
|
@@ -154,42 +122,35 @@ var Sandbox = /*#__PURE__*/function () {
|
|
|
154
122
|
throw error;
|
|
155
123
|
}
|
|
156
124
|
}
|
|
157
|
-
|
|
158
125
|
return true;
|
|
159
126
|
},
|
|
160
127
|
get: function get(target, key) {
|
|
161
128
|
if (key === Symbol.unscopables) {
|
|
162
129
|
return unscopables;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
130
|
+
}
|
|
131
|
+
// @ts-ignore
|
|
166
132
|
if (key === 'window' || key === 'self' || key === 'global' || key === 'globalThis') {
|
|
167
133
|
return _this.proxy;
|
|
168
134
|
}
|
|
169
|
-
|
|
170
135
|
if (key === 'document') {
|
|
171
136
|
return target.document;
|
|
172
137
|
}
|
|
173
|
-
|
|
174
138
|
if (key === 'hasOwnProperty') {
|
|
175
139
|
return target.hasOwnProperty;
|
|
176
140
|
}
|
|
177
|
-
|
|
178
141
|
if (key === 'eval') {
|
|
179
142
|
return target.eval;
|
|
180
143
|
}
|
|
181
|
-
|
|
182
144
|
try {
|
|
183
|
-
console.log(key, target);
|
|
184
|
-
|
|
185
|
-
var value = key in target ? target[key] : _this.fakeWindow[key];
|
|
186
|
-
|
|
145
|
+
console.log(key, target);
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
var value = key in target ? target[key] : _this.fakeWindow[key];
|
|
148
|
+
// @ts-ignore
|
|
187
149
|
if (isCallable(value) && !isBoundedFunction(value) && !isConstructable(value)) {
|
|
188
150
|
// @ts-ignore
|
|
189
151
|
// return target.matchMedia
|
|
190
152
|
value = Function.prototype.bind.call(value, target);
|
|
191
153
|
}
|
|
192
|
-
|
|
193
154
|
return getTargetValue(window, value);
|
|
194
155
|
} catch (error) {
|
|
195
156
|
console.error('get-key-error', key, error);
|
|
@@ -197,99 +158,77 @@ var Sandbox = /*#__PURE__*/function () {
|
|
|
197
158
|
}
|
|
198
159
|
},
|
|
199
160
|
has: function has(target, key) {
|
|
200
|
-
return key in unscopables || key in target || key in _this.fakeWindow;
|
|
161
|
+
return key in unscopables || key in target || key in _this.fakeWindow;
|
|
162
|
+
// return this.fakeWindow.hasOwnProperty(key)
|
|
201
163
|
}
|
|
202
|
-
});
|
|
203
|
-
|
|
164
|
+
});
|
|
165
|
+
// 事件
|
|
204
166
|
this.proxy.addEventListener = function (type, listener, options) {
|
|
205
167
|
if (!_this.hasDisposed) {
|
|
206
168
|
var listeners = _this.listenerMap.get(type) || [];
|
|
207
|
-
|
|
208
169
|
_this.listenerMap.set(type, [].concat(_toConsumableArray(listeners), [listener]));
|
|
209
|
-
|
|
210
170
|
return rawAddEventListener.call(window, type, listener, options);
|
|
211
171
|
}
|
|
212
172
|
};
|
|
213
|
-
|
|
214
173
|
this.proxy.removeEventListener = function (type, listener, options) {
|
|
215
174
|
var listeners = _this.listenerMap.get(type);
|
|
216
|
-
|
|
217
175
|
if (listeners && listeners.length) {
|
|
218
176
|
var listenerIndex = listeners.indexOf(listener);
|
|
219
|
-
|
|
220
177
|
if (listenerIndex !== -1) {
|
|
221
178
|
listeners.splice(listeners.indexOf(listener), 1);
|
|
222
179
|
}
|
|
223
180
|
}
|
|
224
|
-
|
|
225
181
|
return rawRemoveEventListener.call(window, type, listener, options);
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
|
|
182
|
+
};
|
|
183
|
+
// 定时器
|
|
229
184
|
this.proxy.setInterval = function (handler, timeout) {
|
|
230
185
|
if (!_this.hasDisposed) {
|
|
231
186
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
232
187
|
args[_key - 2] = arguments[_key];
|
|
233
188
|
}
|
|
234
|
-
|
|
235
189
|
var intervalId = rawWindowInterval.apply(void 0, [handler, timeout].concat(args));
|
|
236
|
-
|
|
237
190
|
_this.intervalList.push(intervalId);
|
|
238
|
-
|
|
239
191
|
return intervalId;
|
|
240
192
|
} else {
|
|
241
193
|
return 0;
|
|
242
194
|
}
|
|
243
195
|
};
|
|
244
|
-
|
|
245
196
|
this.proxy.clearInterval = function (intervalId) {
|
|
246
197
|
var intervalIndex = _this.intervalList.indexOf(intervalId);
|
|
247
|
-
|
|
248
198
|
if (intervalIndex !== -1) {
|
|
249
199
|
_this.intervalList.splice(intervalIndex, 1);
|
|
250
200
|
}
|
|
251
|
-
|
|
252
201
|
return rawWindowClearInterval(intervalId);
|
|
253
202
|
};
|
|
254
|
-
|
|
255
203
|
this.proxy.setTimeout = function (handler, timeout) {
|
|
256
204
|
if (!_this.hasDisposed) {
|
|
257
205
|
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
258
206
|
args[_key2 - 2] = arguments[_key2];
|
|
259
207
|
}
|
|
260
|
-
|
|
261
208
|
var timeoutId = rawWindowTimeout.apply(void 0, [handler, timeout].concat(args));
|
|
262
|
-
|
|
263
209
|
_this.timeoutList.push(timeoutId);
|
|
264
|
-
|
|
265
210
|
return timeoutId;
|
|
266
211
|
} else {
|
|
267
212
|
return 0;
|
|
268
213
|
}
|
|
269
214
|
};
|
|
270
|
-
|
|
271
215
|
this.proxy.clearTimeout = function (timeoutId) {
|
|
272
216
|
var timeoutIndex = _this.timeoutList.indexOf(timeoutId);
|
|
273
|
-
|
|
274
217
|
if (timeoutIndex !== -1) {
|
|
275
218
|
_this.timeoutList.splice(timeoutIndex, 1);
|
|
276
219
|
}
|
|
277
|
-
|
|
278
220
|
return rawWindowClearTimeout(timeoutId);
|
|
279
221
|
};
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
222
|
+
this.originKeys = this.showWindowKeys();
|
|
223
|
+
// @ts-ignore
|
|
283
224
|
originWindow.proxy = this.proxy;
|
|
284
225
|
}
|
|
285
|
-
|
|
286
226
|
_createClass(Sandbox, [{
|
|
287
227
|
key: "execScript",
|
|
288
228
|
value: function execScript(scriptText) {
|
|
289
229
|
if (this.hasDisposed) {
|
|
290
230
|
throw new Error('sandbox has been destroyed');
|
|
291
231
|
}
|
|
292
|
-
|
|
293
232
|
var scriptTextWithSandbox = getScript(scriptText);
|
|
294
233
|
originWindow.eval(scriptTextWithSandbox);
|
|
295
234
|
}
|
|
@@ -297,13 +236,11 @@ var Sandbox = /*#__PURE__*/function () {
|
|
|
297
236
|
key: "showWindowKeys",
|
|
298
237
|
value: function showWindowKeys() {
|
|
299
238
|
var originKeys = Object.keys(originWindow);
|
|
300
|
-
|
|
301
239
|
if (this.showlog === true) {
|
|
302
240
|
console.log('originWindow', originWindow);
|
|
303
241
|
console.log('updateKeys', this.updateKeys);
|
|
304
242
|
console.log('windowKeysLength', originKeys.length);
|
|
305
243
|
}
|
|
306
|
-
|
|
307
244
|
return originKeys;
|
|
308
245
|
}
|
|
309
246
|
}, {
|
|
@@ -333,7 +270,8 @@ var Sandbox = /*#__PURE__*/function () {
|
|
|
333
270
|
return rawWindowClearTimeout(timeoutId);
|
|
334
271
|
});
|
|
335
272
|
this.timeoutList = [];
|
|
336
|
-
this.fakeWindow = createFakeWindow();
|
|
273
|
+
this.fakeWindow = createFakeWindow();
|
|
274
|
+
// const originKeys = this.showWindowKeys()
|
|
337
275
|
// const newKeys = []
|
|
338
276
|
// for (var i = 0; i < originKeys.length; i++) {
|
|
339
277
|
// if (this.originKeys.indexOf(originKeys[i]) === -1) {
|
|
@@ -343,14 +281,11 @@ var Sandbox = /*#__PURE__*/function () {
|
|
|
343
281
|
// @ts-ignore
|
|
344
282
|
// originWindow.newKeys = newKeys
|
|
345
283
|
// @ts-ignore
|
|
346
|
-
|
|
347
284
|
delete originWindow.proxy;
|
|
348
285
|
this.hasDisposed = true;
|
|
349
286
|
console.log('Sandbox was successfully destroyed');
|
|
350
287
|
}
|
|
351
288
|
}]);
|
|
352
|
-
|
|
353
289
|
return Sandbox;
|
|
354
290
|
}();
|
|
355
|
-
|
|
356
291
|
export default Sandbox;
|
package/es/LoaderApp/sandbox.js
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
2
|
-
|
|
3
2
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
-
|
|
5
3
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
-
|
|
7
4
|
// 懒加载的脚本暂时没法拦截
|
|
8
5
|
var SandBox = /*#__PURE__*/_createClass(function SandBox() {
|
|
9
6
|
var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
|
|
10
|
-
|
|
11
7
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
_ref$blacklist = _ref.blacklist,
|
|
9
|
+
blacklist = _ref$blacklist === void 0 ? [] : _ref$blacklist,
|
|
10
|
+
_ref$docMap = _ref.docMap,
|
|
11
|
+
docMap = _ref$docMap === void 0 ? {} : _ref$docMap;
|
|
17
12
|
_classCallCheck(this, SandBox);
|
|
18
|
-
|
|
19
13
|
this.updatedValueSet = new Map();
|
|
20
14
|
var blackmap = {};
|
|
21
|
-
|
|
22
15
|
for (var i = 0; i < blacklist.length; i++) {
|
|
23
16
|
var name = blacklist[i];
|
|
24
17
|
blackmap[name] = true;
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
var updatedValueSet = this.updatedValueSet;
|
|
20
|
+
// const proxyDocoment = createSandBoxDocument(docMap);
|
|
29
21
|
var proxy = new Proxy(context, {
|
|
30
22
|
set: function set(target, name, value) {
|
|
31
23
|
if (!target[name]) {
|
|
@@ -33,7 +25,6 @@ var SandBox = /*#__PURE__*/_createClass(function SandBox() {
|
|
|
33
25
|
} else {
|
|
34
26
|
target[name] = value;
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
return true;
|
|
38
29
|
},
|
|
39
30
|
get: function get(target, name) {
|
|
@@ -41,10 +32,10 @@ var SandBox = /*#__PURE__*/_createClass(function SandBox() {
|
|
|
41
32
|
console.error("Can't assess property: ".concat(name, " in blacklist"));
|
|
42
33
|
return undefined;
|
|
43
34
|
}
|
|
44
|
-
|
|
45
35
|
if (updatedValueSet.has(name)) {
|
|
46
36
|
return updatedValueSet.get(name);
|
|
47
|
-
}
|
|
37
|
+
}
|
|
38
|
+
// if (
|
|
48
39
|
// name === 'Object' ||
|
|
49
40
|
// name === 'Symbol' ||
|
|
50
41
|
// typeof name === 'symbol' ||
|
|
@@ -61,15 +52,12 @@ var SandBox = /*#__PURE__*/_createClass(function SandBox() {
|
|
|
61
52
|
// } else {
|
|
62
53
|
// console.log(name);
|
|
63
54
|
// }
|
|
64
|
-
|
|
65
|
-
|
|
66
55
|
switch (name) {
|
|
67
56
|
case 'window':
|
|
68
57
|
case 'global':
|
|
69
58
|
case 'self':
|
|
70
59
|
case 'globalThis':
|
|
71
60
|
return proxy;
|
|
72
|
-
|
|
73
61
|
case 'document':
|
|
74
62
|
return document;
|
|
75
63
|
// return proxyDocoment;
|
|
@@ -105,6 +93,4 @@ var SandBox = /*#__PURE__*/_createClass(function SandBox() {
|
|
|
105
93
|
// })(new SandBox(window, { docMap: { head: document.body } }));
|
|
106
94
|
// }
|
|
107
95
|
// text();
|
|
108
|
-
|
|
109
|
-
|
|
110
96
|
export default SandBox;
|