@cloud-app-dev/vidc 3.2.39 → 4.0.1

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.
@@ -1,85 +0,0 @@
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
- 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
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
-
7
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
8
-
9
- import { arrayify, rewrite, importHTML } from "./utils";
10
- export function createScopedCssText(_ref) {
11
- var _sheet$cssRules;
12
-
13
- var styleNode = _ref.styleNode,
14
- prefix = _ref.prefix;
15
- var sheet = styleNode.sheet;
16
- var rules = arrayify((_sheet$cssRules = sheet === null || sheet === void 0 ? void 0 : sheet.cssRules) !== null && _sheet$cssRules !== void 0 ? _sheet$cssRules : []);
17
- return rewrite(rules, prefix);
18
- }
19
- export function LoaderStyle(_x) {
20
- return _LoaderStyle.apply(this, arguments);
21
- }
22
-
23
- function _LoaderStyle() {
24
- _LoaderStyle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
25
- var cssText, prefix, styleNode, scopeCssText;
26
- return _regeneratorRuntime().wrap(function _callee$(_context) {
27
- while (1) {
28
- switch (_context.prev = _context.next) {
29
- case 0:
30
- cssText = _ref2.cssText, prefix = _ref2.prefix, styleNode = _ref2.styleNode;
31
- styleNode.innerHTML = cssText;
32
- scopeCssText = createScopedCssText({
33
- prefix: prefix,
34
- styleNode: styleNode
35
- });
36
- styleNode.textContent = scopeCssText;
37
-
38
- case 4:
39
- case "end":
40
- return _context.stop();
41
- }
42
- }
43
- }, _callee);
44
- }));
45
- return _LoaderStyle.apply(this, arguments);
46
- }
47
-
48
- export default function LoaderModule(_x2) {
49
- return _LoaderModule.apply(this, arguments);
50
- }
51
-
52
- function _LoaderModule() {
53
- _LoaderModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
54
- var prefix, styleNode, html, cssText, exports, result;
55
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
56
- while (1) {
57
- switch (_context2.prev = _context2.next) {
58
- case 0:
59
- prefix = _ref3.prefix, styleNode = _ref3.styleNode, html = _ref3.html;
60
- _context2.next = 3;
61
- return importHTML(html);
62
-
63
- case 3:
64
- result = _context2.sent;
65
- cssText = result.cssTexts.join(' ');
66
- exports = result.appInstance;
67
- _context2.next = 8;
68
- return LoaderStyle({
69
- cssText: cssText,
70
- prefix: prefix,
71
- styleNode: styleNode
72
- });
73
-
74
- case 8:
75
- return _context2.abrupt("return", exports);
76
-
77
- case 9:
78
- case "end":
79
- return _context2.stop();
80
- }
81
- }
82
- }, _callee2);
83
- }));
84
- return _LoaderModule.apply(this, arguments);
85
- }
@@ -1,18 +0,0 @@
1
- declare type FakeWindow = Window & Record<PropertyKey, any>;
2
- declare class Sandbox {
3
- fakeWindow: FakeWindow;
4
- proxy: Window;
5
- updateKeys: Set<unknown>;
6
- listenerMap: Map<string, EventListenerOrEventListenerObject[]>;
7
- timeoutList: number[];
8
- intervalList: number[];
9
- originKeys: string[];
10
- showlog: boolean;
11
- hasDisposed: boolean;
12
- constructor(showlog?: boolean);
13
- execScript(scriptText: string): void;
14
- showWindowKeys(): string[];
15
- preview(): void;
16
- dispose(): void;
17
- }
18
- export default Sandbox;
@@ -1,368 +0,0 @@
1
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
-
3
- 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
- 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
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
-
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
-
11
- 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
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
-
15
- 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
- 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
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
-
21
- /**
22
- * @file 全局window沙盒,隔离变量环境
23
- */
24
- var originWindow = window;
25
- var constructableMap = new WeakMap();
26
-
27
- function isConstructable(fn) {
28
- if (constructableMap.has(fn)) {
29
- return constructableMap.get(fn);
30
- }
31
-
32
- var constructableFunctionRegex = /^function\b\s[A-Z].*/;
33
- var classRegex = /^class\b/;
34
- var constructable = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1 || constructableFunctionRegex.test(fn.toString()) || classRegex.test(fn.toString());
35
- constructableMap.set(fn, constructable);
36
- return constructable;
37
- }
38
-
39
- var naughtySafari = typeof document.all === 'function' && typeof document.all === 'undefined';
40
- var isCallable = naughtySafari ? function (fn) {
41
- return typeof fn === 'function' && typeof fn !== 'undefined';
42
- } : function (fn) {
43
- return typeof fn === 'function';
44
- };
45
- var boundedMap = new WeakMap();
46
-
47
- function isBoundedFunction(fn) {
48
- if (boundedMap.has(fn)) {
49
- return boundedMap.get(fn);
50
- }
51
-
52
- var bounded = fn.name.indexOf('bound ') === 0 && !fn.hasOwnProperty('prototype');
53
- boundedMap.set(fn, bounded);
54
- return bounded;
55
- }
56
-
57
- var functionBoundedValueMap = new WeakMap();
58
-
59
- function getTargetValue(target, value) {
60
- var cachedBoundFunction = functionBoundedValueMap.get(value);
61
-
62
- if (cachedBoundFunction) {
63
- return cachedBoundFunction;
64
- }
65
-
66
- if (isCallable(value) && !isBoundedFunction(value) && !isConstructable(value)) {
67
- var boundValue = Function.prototype.bind.call(value, target);
68
-
69
- for (var key in value) {
70
- boundValue[key] = value[key];
71
- }
72
-
73
- if (value.hasOwnProperty('prototype') && !boundValue.hasOwnProperty('prototype')) boundValue.prototype = value.prototype;
74
- functionBoundedValueMap.set(value, boundValue);
75
- return boundValue;
76
- }
77
-
78
- return value;
79
- }
80
-
81
- function getScript(scriptText) {
82
- return '(function(window){with(window){;'.concat(scriptText, '\n').concat('}}).bind(window.proxy)(window.proxy);');
83
- }
84
-
85
- var rawAddEventListener = window.addEventListener;
86
- var rawRemoveEventListener = window.removeEventListener;
87
- var rawWindowInterval = window.setInterval;
88
- var rawWindowClearInterval = window.clearInterval;
89
- var rawWindowTimeout = window.setTimeout;
90
- var rawWindowClearTimeout = window.clearTimeout;
91
- var unscopables = {
92
- undefined: true,
93
- Array: true,
94
- Object: true,
95
- String: true,
96
- Boolean: true,
97
- Math: true,
98
- Number: true,
99
- Symbol: true,
100
- parseFloat: true,
101
- Float32Array: true
102
- };
103
-
104
- function createFakeWindow() {
105
- var fakeWindow = {};
106
- Object.getOwnPropertyNames(originWindow).forEach(function (key) {
107
- var descriptor = Object.getOwnPropertyDescriptor(originWindow, key);
108
-
109
- if (descriptor && !descriptor.configurable) {
110
- var hasGetter = Object.prototype.hasOwnProperty.call(descriptor, 'get');
111
-
112
- if (key === 'top' || key === 'parent' || key === 'self' || key === 'window') {
113
- descriptor.configurable = true;
114
-
115
- if (!hasGetter) {
116
- descriptor.writable = true;
117
- }
118
- }
119
-
120
- Object.defineProperty(fakeWindow, key, Object.freeze(descriptor));
121
- }
122
- });
123
- return fakeWindow;
124
- }
125
-
126
- var Sandbox = /*#__PURE__*/function () {
127
- function Sandbox(showlog) {
128
- var _this = this;
129
-
130
- _classCallCheck(this, Sandbox);
131
-
132
- _defineProperty(this, "fakeWindow", createFakeWindow());
133
-
134
- _defineProperty(this, "proxy", void 0);
135
-
136
- _defineProperty(this, "updateKeys", new Set());
137
-
138
- _defineProperty(this, "listenerMap", new Map());
139
-
140
- _defineProperty(this, "timeoutList", []);
141
-
142
- _defineProperty(this, "intervalList", []);
143
-
144
- _defineProperty(this, "originKeys", []);
145
-
146
- _defineProperty(this, "showlog", false);
147
-
148
- _defineProperty(this, "hasDisposed", false);
149
-
150
- this.showlog = showlog;
151
- this.proxy = new Proxy(window, {
152
- set: function set(target, key, value) {
153
- if (!_this.hasDisposed) {
154
- _this.updateKeys.add(key);
155
-
156
- try {
157
- if (!_this.fakeWindow.hasOwnProperty(key) && target.hasOwnProperty(key)) {
158
- // @ts-ignore
159
- target[key] = value;
160
- } else {
161
- // @ts-ignore
162
- _this.fakeWindow[key] = value;
163
- }
164
- } catch (error) {
165
- console.error('set-key-error', key, error);
166
- throw error;
167
- }
168
- }
169
-
170
- return true;
171
- },
172
- get: function get(target, key) {
173
- if (key === Symbol.unscopables) {
174
- return unscopables;
175
- } // @ts-ignore
176
-
177
-
178
- if (key === 'window' || key === 'self' || key === 'global' || key === 'globalThis') {
179
- return _this.proxy;
180
- }
181
-
182
- if (key === 'document') {
183
- return target.document;
184
- }
185
-
186
- if (key === 'hasOwnProperty') {
187
- return target.hasOwnProperty;
188
- }
189
-
190
- if (key === 'eval') {
191
- return target.eval;
192
- }
193
-
194
- try {
195
- console.log(key, target); // @ts-ignore
196
-
197
- var value = key in target ? target[key] : _this.fakeWindow[key]; // @ts-ignore
198
-
199
- if (isCallable(value) && !isBoundedFunction(value) && !isConstructable(value)) {
200
- // @ts-ignore
201
- // return target.matchMedia
202
- value = Function.prototype.bind.call(value, target);
203
- }
204
-
205
- return getTargetValue(window, value);
206
- } catch (error) {
207
- console.error('get-key-error', key, error);
208
- throw error;
209
- }
210
- },
211
- has: function has(target, key) {
212
- return key in unscopables || key in target || key in _this.fakeWindow; // return this.fakeWindow.hasOwnProperty(key)
213
- }
214
- }); // 事件
215
-
216
- this.proxy.addEventListener = function (type, listener, options) {
217
- if (!_this.hasDisposed) {
218
- var listeners = _this.listenerMap.get(type) || [];
219
-
220
- _this.listenerMap.set(type, [].concat(_toConsumableArray(listeners), [listener]));
221
-
222
- return rawAddEventListener.call(window, type, listener, options);
223
- }
224
- };
225
-
226
- this.proxy.removeEventListener = function (type, listener, options) {
227
- var listeners = _this.listenerMap.get(type);
228
-
229
- if (listeners && listeners.length) {
230
- var listenerIndex = listeners.indexOf(listener);
231
-
232
- if (listenerIndex !== -1) {
233
- listeners.splice(listeners.indexOf(listener), 1);
234
- }
235
- }
236
-
237
- return rawRemoveEventListener.call(window, type, listener, options);
238
- }; // 定时器
239
-
240
-
241
- this.proxy.setInterval = function (handler, timeout) {
242
- if (!_this.hasDisposed) {
243
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
244
- args[_key - 2] = arguments[_key];
245
- }
246
-
247
- var intervalId = rawWindowInterval.apply(void 0, [handler, timeout].concat(args));
248
-
249
- _this.intervalList.push(intervalId);
250
-
251
- return intervalId;
252
- } else {
253
- return 0;
254
- }
255
- };
256
-
257
- this.proxy.clearInterval = function (intervalId) {
258
- var intervalIndex = _this.intervalList.indexOf(intervalId);
259
-
260
- if (intervalIndex !== -1) {
261
- _this.intervalList.splice(intervalIndex, 1);
262
- }
263
-
264
- return rawWindowClearInterval(intervalId);
265
- };
266
-
267
- this.proxy.setTimeout = function (handler, timeout) {
268
- if (!_this.hasDisposed) {
269
- for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
270
- args[_key2 - 2] = arguments[_key2];
271
- }
272
-
273
- var timeoutId = rawWindowTimeout.apply(void 0, [handler, timeout].concat(args));
274
-
275
- _this.timeoutList.push(timeoutId);
276
-
277
- return timeoutId;
278
- } else {
279
- return 0;
280
- }
281
- };
282
-
283
- this.proxy.clearTimeout = function (timeoutId) {
284
- var timeoutIndex = _this.timeoutList.indexOf(timeoutId);
285
-
286
- if (timeoutIndex !== -1) {
287
- _this.timeoutList.splice(timeoutIndex, 1);
288
- }
289
-
290
- return rawWindowClearTimeout(timeoutId);
291
- };
292
-
293
- this.originKeys = this.showWindowKeys(); // @ts-ignore
294
-
295
- originWindow.proxy = this.proxy;
296
- }
297
-
298
- _createClass(Sandbox, [{
299
- key: "execScript",
300
- value: function execScript(scriptText) {
301
- if (this.hasDisposed) {
302
- throw new Error('sandbox has been destroyed');
303
- }
304
-
305
- var scriptTextWithSandbox = getScript(scriptText);
306
- originWindow.eval(scriptTextWithSandbox);
307
- }
308
- }, {
309
- key: "showWindowKeys",
310
- value: function showWindowKeys() {
311
- var originKeys = Object.keys(originWindow);
312
-
313
- if (this.showlog === true) {
314
- console.log('originWindow', originWindow);
315
- console.log('updateKeys', this.updateKeys);
316
- console.log('windowKeysLength', originKeys.length);
317
- }
318
-
319
- return originKeys;
320
- }
321
- }, {
322
- key: "preview",
323
- value: function preview() {
324
- if (this.showlog === true) {
325
- window.console.log('updateKeys', this.updateKeys);
326
- window.console.log('listenerMap', this.listenerMap);
327
- window.console.log('intervalList', this.intervalList);
328
- window.console.log('timeoutList', this.timeoutList);
329
- }
330
- }
331
- }, {
332
- key: "dispose",
333
- value: function dispose() {
334
- this.listenerMap.forEach(function (listeners, type) {
335
- return _toConsumableArray(listeners).forEach(function (listener) {
336
- return rawRemoveEventListener.call(window, type, listener);
337
- });
338
- });
339
- this.listenerMap.clear();
340
- this.intervalList.forEach(function (intervalId) {
341
- return rawWindowClearInterval(intervalId);
342
- });
343
- this.intervalList = [];
344
- this.timeoutList.forEach(function (timeoutId) {
345
- return rawWindowClearTimeout(timeoutId);
346
- });
347
- this.timeoutList = [];
348
- this.fakeWindow = createFakeWindow(); // const originKeys = this.showWindowKeys()
349
- // const newKeys = []
350
- // for (var i = 0; i < originKeys.length; i++) {
351
- // if (this.originKeys.indexOf(originKeys[i]) === -1) {
352
- // newKeys.push(originKeys)
353
- // }
354
- // }
355
- // @ts-ignore
356
- // originWindow.newKeys = newKeys
357
- // @ts-ignore
358
-
359
- delete originWindow.proxy;
360
- this.hasDisposed = true;
361
- console.log('Sandbox was successfully destroyed');
362
- }
363
- }]);
364
-
365
- return Sandbox;
366
- }();
367
-
368
- export default Sandbox;
@@ -1,12 +0,0 @@
1
- interface OPTIONS {
2
- inheritGlobal?: boolean;
3
- blacklist?: string[];
4
- docMap?: {
5
- [key: string]: any;
6
- };
7
- }
8
- declare class SandBox {
9
- private updatedValueSet;
10
- constructor(context?: Window & typeof globalThis, { blacklist, docMap }?: OPTIONS);
11
- }
12
- export default SandBox;
@@ -1,113 +0,0 @@
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
- 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
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
-
7
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
-
9
- // 懒加载的脚本暂时没法拦截
10
- var SandBox = /*#__PURE__*/_createClass(function SandBox() {
11
- var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
12
-
13
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
14
- _ref$blacklist = _ref.blacklist,
15
- blacklist = _ref$blacklist === void 0 ? [] : _ref$blacklist,
16
- _ref$docMap = _ref.docMap,
17
- docMap = _ref$docMap === void 0 ? {} : _ref$docMap;
18
-
19
- _classCallCheck(this, SandBox);
20
-
21
- _defineProperty(this, "updatedValueSet", new Map());
22
-
23
- var blackmap = {};
24
-
25
- for (var i = 0; i < blacklist.length; i++) {
26
- var name = blacklist[i];
27
- blackmap[name] = true;
28
- }
29
-
30
- var updatedValueSet = this.updatedValueSet; // const proxyDocoment = createSandBoxDocument(docMap);
31
-
32
- var proxy = new Proxy(context, {
33
- set: function set(target, name, value) {
34
- if (!target[name]) {
35
- updatedValueSet.set(name, value);
36
- } else {
37
- target[name] = value;
38
- }
39
-
40
- return true;
41
- },
42
- get: function get(target, name) {
43
- if (blackmap.hasOwnProperty(name)) {
44
- console.error("Can't assess property: ".concat(name, " in blacklist"));
45
- return undefined;
46
- }
47
-
48
- if (updatedValueSet.has(name)) {
49
- return updatedValueSet.get(name);
50
- } // if (
51
- // name === 'Object' ||
52
- // name === 'Symbol' ||
53
- // typeof name === 'symbol' ||
54
- // name === 'parseFloat' ||
55
- // name === 'parseInt' ||
56
- // name === 'Array' ||
57
- // name === 'Number' ||
58
- // name === 'Math' ||
59
- // name === 'String'||
60
- // name === 'Reflect'||
61
- // name === 'Boolean'||
62
- // name === 'isNaN'
63
- // ) {
64
- // } else {
65
- // console.log(name);
66
- // }
67
-
68
-
69
- switch (name) {
70
- case 'window':
71
- case 'global':
72
- case 'self':
73
- case 'globalThis':
74
- return proxy;
75
-
76
- case 'document':
77
- return document;
78
- // return proxyDocoment;
79
- }
80
-
81
- if (typeof target[name] === 'function' && /^[a-z]/.test(name)) {
82
- return target[name].bind && target[name].bind(target);
83
- } else {
84
- return target[name];
85
- }
86
- }
87
- });
88
- return proxy;
89
- }); // function createSandBoxDocument(proxyMap: { [key: string]: any } = {}) {
90
- // return new Proxy(document, {
91
- // get(target: any, p: string): any {
92
- // if (proxyMap.hasOwnProperty(p)) {
93
- // return proxyMap[p];
94
- // }
95
- // if (typeof target[p] === 'function' && /^[a-z]/.test(p)) {
96
- // return target[p].bind && target[p].bind(target);
97
- // } else {
98
- // return target[p];
99
- // }
100
- // },
101
- // });
102
- // }
103
- // function text() {
104
- // (function (global: any) {
105
- // const s = global.document.createElement('span');
106
- // s.innerHTML = '1111';
107
- // console.log(global.document.head.appendChild(s));
108
- // })(new SandBox(window, { docMap: { head: document.body } }));
109
- // }
110
- // text();
111
-
112
-
113
- export default SandBox;
@@ -1,19 +0,0 @@
1
- import { AppItemType } from '../Config/interface';
2
- export declare const getMicroConfig: (appConfig: AppItemType | undefined, appProps: any, container: HTMLDivElement) => {
3
- title: string;
4
- routerPrefix: string;
5
- container: HTMLDivElement;
6
- props: any;
7
- entry: {
8
- scripts: string[];
9
- styles: string[];
10
- html: string;
11
- };
12
- };
13
- export declare function fetchStyle(style: string): Promise<string>;
14
- export declare const arrayify: <T>(list: CSSRuleList | any[]) => T[];
15
- export declare function rewrite(rules: CSSRule[], prefix?: string): string;
16
- export declare function importHTML(url: string): Promise<{
17
- cssTexts: string[];
18
- appInstance: any;
19
- }>;