@remixproject/engine
Advanced tools
Comparing version 0.3.0-beta.3 to 0.3.0-beta.4
@@ -43,3 +43,3 @@ import type { Profile } from '@remixproject/plugin-utils'; | ||
*/ | ||
updateProfile(profile: Partial<Profile>): void; | ||
updateProfile(to: Partial<Profile>): Promise<void>; | ||
/** | ||
@@ -94,3 +94,10 @@ * Add a profile to the list of profile | ||
canCall(from: Profile, to: Profile, method: string, message?: string): Promise<boolean>; | ||
/** | ||
* Check if a plugin can update profile of another one | ||
* @param from Profile of the caller plugin | ||
* @param to Updates on the profile of the target plugin | ||
* @note This method can be overrided | ||
*/ | ||
canUpdateProfile(from: Profile, to: Partial<Profile>): Promise<boolean>; | ||
} | ||
export {}; |
@@ -32,17 +32,14 @@ import { __awaiter } from "tslib"; | ||
*/ | ||
updateProfile(profile) { | ||
if (!profile) | ||
return; | ||
if (profile.name && profile.name !== this.requestFrom) { | ||
throw new Error('A plugin cannot change its name.'); | ||
} | ||
const name = this.requestFrom; | ||
if (!this.profiles[name]) { | ||
throw new Error(`Plugin ${name} is not register, you cannot update it's profile.`); | ||
} | ||
if (profile['url'] && profile['url'] !== this.profiles[name]['url']) { | ||
throw new Error('Url from Profile cannot be updated.'); | ||
} | ||
this.profiles[name] = Object.assign(Object.assign({}, this.profiles[name]), profile); | ||
this.emit('profileUpdated', this.profiles[name]); | ||
updateProfile(to) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!to) | ||
return; | ||
if (!this.profiles[to.name]) { | ||
throw new Error(`Plugin ${to.name} is not register, you cannot update it's profile.`); | ||
} | ||
const from = yield this.getProfile(this.requestFrom); | ||
yield this.canUpdateProfile(from, to); | ||
this.profiles[name] = Object.assign(Object.assign({}, this.profiles[name]), to); | ||
this.emit('profileUpdated', this.profiles[name]); | ||
}); | ||
} | ||
@@ -174,3 +171,3 @@ /** | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (from.name === 'manager') { | ||
if (from.name === 'manager' || from.name === to.name) { | ||
return true; | ||
@@ -193,3 +190,20 @@ } | ||
} | ||
/** | ||
* Check if a plugin can update profile of another one | ||
* @param from Profile of the caller plugin | ||
* @param to Updates on the profile of the target plugin | ||
* @note This method can be overrided | ||
*/ | ||
canUpdateProfile(from, to) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (to.name && from.name !== to.name) { | ||
throw new Error('A plugin cannot change its name.'); | ||
} | ||
if (to['url'] && to['url'] !== this.profiles[to.name]['url']) { | ||
throw new Error('Url from Profile cannot be updated.'); | ||
} | ||
return true; | ||
}); | ||
} | ||
} | ||
//# sourceMappingURL=manager.js.map |
{ | ||
"name": "@remixproject/engine", | ||
"version": "0.3.0-beta.3", | ||
"version": "0.3.0-beta.4", | ||
"homepage": "https://github.com/ethereum/remix-plugin/tree/master/packages/engine/core#readme", | ||
@@ -23,8 +23,5 @@ "repository": { | ||
"license": "MIT", | ||
"gitHead": "ca5c69be64ec4eaf7fe5d1d362726e75cb3b5726", | ||
"main": "index.js", | ||
"typings": "index.d.ts", | ||
"dependencies": { | ||
"@remixproject/plugin-utils": "0.3.0-beta.3", | ||
"@remixproject/plugin-api": "0.3.0-beta.3" | ||
} | ||
"typings": "index.d.ts" | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
87515
0
1272
0
- Removed@remixproject/plugin-api@0.3.0-beta.3(transitive)
- Removed@remixproject/plugin-utils@0.3.0-beta.3(transitive)