feat:debug support multi entry and fix some bugs
This commit is contained in:
@@ -147,26 +147,33 @@ function initNativeEnvironment(source) {
|
||||
});
|
||||
});
|
||||
}
|
||||
const entryHooks = [];
|
||||
global.Entry = function () {
|
||||
var _a, _b, _c;
|
||||
if (!!contextId) {
|
||||
return Reflect.apply(doric.jsObtainEntry(contextId), doric, arguments);
|
||||
}
|
||||
else {
|
||||
const jsFile = (_c = (_b = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n").map(e => e.match(/at\s__decorate\s\((.*?)\)/)).find(e => !!e)) === null || _b === void 0 ? void 0 : _b[1].match(/(.*?\.js)/)) === null || _c === void 0 ? void 0 : _c[1];
|
||||
console.log(new Error().stack);
|
||||
const jsFile = (_c = (_b = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n").map(e => e.match(/at\s__decorate.*?\s\((.*?)\)/)).find(e => !!e)) === null || _b === void 0 ? void 0 : _b[1].match(/(.*?\.js)/)) === null || _c === void 0 ? void 0 : _c[1];
|
||||
if (!jsFile) {
|
||||
throw new Error("Cannot find debugging file");
|
||||
}
|
||||
const source = path.basename(jsFile);
|
||||
const args = arguments;
|
||||
console.log(`Debugging ${source}`);
|
||||
initNativeEnvironment(source).then(ret => {
|
||||
contextId = ret;
|
||||
console.log("debugging context id: " + contextId);
|
||||
global.context = doric.jsObtainContext(contextId);
|
||||
entryHooks.push((contextId) => {
|
||||
Reflect.apply(doric.jsObtainEntry(contextId), doric, args);
|
||||
});
|
||||
return arguments[0];
|
||||
if (entryHooks.length <= 1) {
|
||||
const source = path.basename(jsFile);
|
||||
console.log(`Debugging ${source}`);
|
||||
initNativeEnvironment(source).then(ret => {
|
||||
contextId = ret;
|
||||
console.log("debugging context id: " + contextId);
|
||||
global.context = doric.jsObtainContext(contextId);
|
||||
entryHooks.forEach(e => e(contextId));
|
||||
});
|
||||
return arguments[0];
|
||||
}
|
||||
}
|
||||
};
|
||||
global.injectGlobal = (objName, obj) => {
|
||||
|
Reference in New Issue
Block a user