@remixproject/engine
Advanced tools
Comparing version 0.3.0-beta.8 to 0.3.0-beta.9
17
index.js
@@ -1,8 +0,11 @@ | ||
export * from './lib/abstract'; | ||
export * from './lib/connector'; | ||
export * from './lib/engine'; | ||
export * from './lib/host'; | ||
export * from './lib/library'; | ||
export * from './lib/manager'; | ||
export * from './lib/view'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./lib/abstract"), exports); | ||
tslib_1.__exportStar(require("./lib/connector"), exports); | ||
tslib_1.__exportStar(require("./lib/engine"), exports); | ||
tslib_1.__exportStar(require("./lib/host"), exports); | ||
tslib_1.__exportStar(require("./lib/library"), exports); | ||
tslib_1.__exportStar(require("./lib/manager"), exports); | ||
tslib_1.__exportStar(require("./lib/view"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,4 +0,7 @@ | ||
import { __awaiter } from "tslib"; | ||
import { createService, activateService, getMethodPath, } from '@remixproject/plugin-utils'; | ||
export class Plugin { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Plugin = void 0; | ||
const tslib_1 = require("tslib"); | ||
const plugin_utils_1 = require("@remixproject/plugin-utils"); | ||
class Plugin { | ||
constructor(profile) { | ||
@@ -33,3 +36,3 @@ this.profile = profile; | ||
const path = this.currentRequest && this.currentRequest.path; | ||
const method = getMethodPath(key, path); | ||
const method = plugin_utils_1.getMethodPath(key, path); | ||
if (!(method in this)) { | ||
@@ -48,3 +51,3 @@ throw new Error(`Method ${method} is not implemented by ${this.profile.name}`); | ||
// Add a new request to the queue | ||
this.requestQueue.push(() => __awaiter(this, void 0, void 0, function* () { | ||
this.requestQueue.push(() => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
this.currentRequest = request; | ||
@@ -110,8 +113,8 @@ let timedout = false; | ||
createService(name, service) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (this.methods && this.methods.includes(name)) { | ||
throw new Error('A service cannot have the same name as an exposed method'); | ||
} | ||
const _service = createService(name, service); | ||
yield activateService(this, _service); | ||
const _service = plugin_utils_1.createService(name, service); | ||
yield plugin_utils_1.activateService(this, _service); | ||
return _service; | ||
@@ -126,3 +129,3 @@ }); | ||
prepareService(name, factory) { | ||
return this.activateService[name] = () => __awaiter(this, void 0, void 0, function* () { | ||
return this.activateService[name] = () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (this.methods && this.methods.includes(name)) { | ||
@@ -132,4 +135,4 @@ throw new Error('A service cannot have the same name as an exposed method'); | ||
const service = yield factory(); | ||
const _service = createService(name, service); | ||
yield activateService(this, _service); | ||
const _service = plugin_utils_1.createService(name, service); | ||
yield plugin_utils_1.activateService(this, _service); | ||
delete this.activateService[name]; | ||
@@ -153,3 +156,3 @@ return _service; | ||
call(name, key, ...payload) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
throw new Error(`Cannot use method "call" from plugin "${this.name}". It is not registered in the engine yet.`); | ||
@@ -163,2 +166,3 @@ }); | ||
} | ||
exports.Plugin = Plugin; | ||
//# sourceMappingURL=abstract.js.map |
@@ -1,5 +0,8 @@ | ||
import { __awaiter } from "tslib"; | ||
import { Plugin } from './abstract'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PluginConnector = exports.transformUrl = exports.defaultGateways = void 0; | ||
const tslib_1 = require("tslib"); | ||
const abstract_1 = require("./abstract"); | ||
/** List of available gateways for decentralised storage */ | ||
export const defaultGateways = { | ||
exports.defaultGateways = { | ||
'ipfs://': (url, name) => `https://${name}.dyn.plugin.remixproject.org/ipfs/${url.replace('ipfs://', '')}`, | ||
@@ -9,7 +12,8 @@ 'swarm://': (url, name) => `https://swarm-gateways.net/bzz-raw://${url.replace('swarm://', '')}` | ||
/** Transform the URL to use a gateway if decentralised storage is specified */ | ||
export function transformUrl({ url, name }) { | ||
const network = Object.keys(defaultGateways).find(key => url.startsWith(key)); | ||
return network ? defaultGateways[network](url, name) : url; | ||
function transformUrl({ url, name }) { | ||
const network = Object.keys(exports.defaultGateways).find(key => url.startsWith(key)); | ||
return network ? exports.defaultGateways[network](url, name) : url; | ||
} | ||
export class PluginConnector extends Plugin { | ||
exports.transformUrl = transformUrl; | ||
class PluginConnector extends abstract_1.Plugin { | ||
constructor(profile) { | ||
@@ -50,3 +54,3 @@ super(profile); | ||
handshake() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (!this.loaded) { | ||
@@ -71,3 +75,3 @@ const methods = yield this.callPluginMethod('handshake', [this.profile.name]); | ||
getMessage(message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
// Check for handshake request from the client | ||
@@ -135,2 +139,3 @@ if (message.action === 'request' && message.key === 'handshake') { | ||
} | ||
exports.PluginConnector = PluginConnector; | ||
//# sourceMappingURL=connector.js.map |
@@ -1,4 +0,7 @@ | ||
import { __awaiter } from "tslib"; | ||
import { listenEvent } from '@remixproject/plugin-utils'; | ||
export class Engine { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Engine = void 0; | ||
const tslib_1 = require("tslib"); | ||
const plugin_utils_1 = require("@remixproject/plugin-utils"); | ||
class Engine { | ||
constructor(manager) { | ||
@@ -24,3 +27,3 @@ this.manager = manager; | ||
onload(cb) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return new Promise((res, rej) => { | ||
@@ -50,3 +53,3 @@ if (this.isLoaded) { // If already loaded resolve | ||
broadcast(emitter, event, ...payload) { | ||
const eventName = listenEvent(emitter, event); | ||
const eventName = plugin_utils_1.listenEvent(emitter, event); | ||
if (!this.listeners[eventName]) | ||
@@ -74,3 +77,3 @@ return; // Nobody is listening | ||
addListener(listener, emitter, event, cb) { | ||
const eventName = listenEvent(emitter, event); | ||
const eventName = plugin_utils_1.listenEvent(emitter, event); | ||
// If not already listening | ||
@@ -99,3 +102,3 @@ if (!this.events[listener][eventName]) { | ||
removeListener(listener, emitter, event) { | ||
const eventName = listenEvent(emitter, event); | ||
const eventName = plugin_utils_1.listenEvent(emitter, event); | ||
// Remove listener | ||
@@ -127,3 +130,3 @@ this.listeners[eventName] = this.listeners[eventName].filter(name => name !== listener); | ||
callMethod(caller, path, method, ...payload) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const target = path.split('.').shift(); | ||
@@ -165,3 +168,3 @@ if (!this.plugins[target]) { | ||
createApp(name) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const getProfiles = Object.keys(this.plugins).map(key => this.manager.getProfile(key)); | ||
@@ -189,3 +192,3 @@ const profiles = yield Promise.all(getProfiles); | ||
activatePlugin(name) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (!this.plugins[name]) { | ||
@@ -227,3 +230,3 @@ throw new Error(`Cannot active plugin ${name} because it's not registered yet`); | ||
deactivatePlugin(name) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (!this.plugins[name]) { | ||
@@ -316,2 +319,3 @@ throw new Error(`Cannot deactive plugin ${name} because it's not registered yet`); | ||
} | ||
exports.Engine = Engine; | ||
//# sourceMappingURL=engine.js.map |
@@ -1,3 +0,6 @@ | ||
import { Plugin } from './abstract'; | ||
export class HostPlugin extends Plugin { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HostPlugin = void 0; | ||
const abstract_1 = require("./abstract"); | ||
class HostPlugin extends abstract_1.Plugin { | ||
constructor(profile) { | ||
@@ -12,2 +15,3 @@ // Remove duplicated if needed | ||
} | ||
exports.HostPlugin = HostPlugin; | ||
//# sourceMappingURL=host.js.map |
@@ -1,7 +0,11 @@ | ||
import { __awaiter } from "tslib"; | ||
import { Plugin } from './abstract'; | ||
export function isViewLibrary(profile) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LibraryPlugin = exports.isViewLibrary = void 0; | ||
const tslib_1 = require("tslib"); | ||
const abstract_1 = require("./abstract"); | ||
function isViewLibrary(profile) { | ||
return !!profile.location; | ||
} | ||
export class LibraryPlugin extends Plugin { | ||
exports.isViewLibrary = isViewLibrary; | ||
class LibraryPlugin extends abstract_1.Plugin { | ||
constructor(library, profile) { | ||
@@ -25,3 +29,3 @@ super(profile); | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (this.isView) { | ||
@@ -77,2 +81,3 @@ yield this.call(this.profile.location, 'addView', this.profile, this['render']()); | ||
} | ||
exports.LibraryPlugin = LibraryPlugin; | ||
//# sourceMappingURL=library.js.map |
@@ -1,11 +0,14 @@ | ||
import { __awaiter } from "tslib"; | ||
import { pluginManagerProfile } from '@remixproject/plugin-api'; | ||
import { Plugin } from "./abstract"; | ||
export const managerMethods = ['getProfile', 'updateProfile', 'activatePlugin', 'deactivatePlugin', 'isActive', 'canCall']; | ||
export class PluginManager extends Plugin { | ||
constructor(profile = pluginManagerProfile) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PluginManager = exports.managerMethods = void 0; | ||
const tslib_1 = require("tslib"); | ||
const plugin_api_1 = require("@remixproject/plugin-api"); | ||
const abstract_1 = require("./abstract"); | ||
exports.managerMethods = ['getProfile', 'updateProfile', 'activatePlugin', 'deactivatePlugin', 'isActive', 'canCall']; | ||
class PluginManager extends abstract_1.Plugin { | ||
constructor(profile = plugin_api_1.pluginManagerProfile) { | ||
super(profile); | ||
this.profiles = {}; | ||
this.actives = []; | ||
this.methods = managerMethods; | ||
this.methods = exports.managerMethods; | ||
this.profiles[profile.name] = profile; // Initialise with own profile (cannot use addProfile because manager is not activated yet) | ||
@@ -23,3 +26,3 @@ } | ||
getProfile(name) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return this.profiles[name]; | ||
@@ -34,3 +37,3 @@ }); | ||
updateProfile(to) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (!to) | ||
@@ -67,3 +70,3 @@ return; | ||
isActive(name) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return this.actives.includes(name); | ||
@@ -77,4 +80,4 @@ }); | ||
activatePlugin(names) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const activate = (name) => __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const activate = (name) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const isActive = yield this.isActive(name); | ||
@@ -103,4 +106,4 @@ if (isActive) | ||
deactivatePlugin(names) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const deactivate = (name) => __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const deactivate = (name) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const isActive = yield this.isActive(name); | ||
@@ -130,4 +133,4 @@ if (!isActive) | ||
toggleActive(names) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const toggle = (name) => __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const toggle = (name) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const [isActive, profile] = yield Promise.all([ | ||
@@ -164,3 +167,3 @@ this.isActive(name), | ||
canActivate(from, to) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return true; | ||
@@ -176,3 +179,3 @@ }); | ||
canDeactivate(from, to) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (from.name === 'manager' || from.name === to.name) { | ||
@@ -192,3 +195,3 @@ return true; | ||
canCall(from, to, method, message) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return true; | ||
@@ -204,3 +207,3 @@ }); | ||
canUpdateProfile(from, to) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (to.name && from.name !== to.name) { | ||
@@ -216,2 +219,3 @@ throw new Error('A plugin cannot change its name.'); | ||
} | ||
exports.PluginManager = PluginManager; | ||
//# sourceMappingURL=manager.js.map |
@@ -1,7 +0,11 @@ | ||
import { __awaiter } from "tslib"; | ||
import { Plugin } from './abstract'; | ||
export function isView(profile) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ViewPlugin = exports.isView = void 0; | ||
const tslib_1 = require("tslib"); | ||
const abstract_1 = require("./abstract"); | ||
function isView(profile) { | ||
return !!profile['location']; | ||
} | ||
export class ViewPlugin extends Plugin { | ||
exports.isView = isView; | ||
class ViewPlugin extends abstract_1.Plugin { | ||
constructor(profile) { | ||
@@ -15,3 +19,3 @@ super(profile); | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
yield this.call(this.profile.location, 'addView', this.profile, this.render()); | ||
@@ -26,2 +30,3 @@ _super.activate.call(this); | ||
} | ||
exports.ViewPlugin = ViewPlugin; | ||
//# sourceMappingURL=view.js.map |
{ | ||
"name": "@remixproject/engine", | ||
"version": "0.3.0-beta.8", | ||
"version": "0.3.0-beta.9", | ||
"homepage": "https://github.com/ethereum/remix-plugin/tree/master/packages/engine/core#readme", | ||
@@ -27,5 +27,5 @@ "repository": { | ||
"dependencies": { | ||
"@remixproject/plugin-utils": "0.3.0-beta.8", | ||
"@remixproject/plugin-api": "0.3.0-beta.6" | ||
"@remixproject/plugin-utils": "0.3.0-beta.9", | ||
"@remixproject/plugin-api": "0.3.0-beta.9" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
89271
1306
+ Added@remixproject/plugin-api@0.3.0-beta.9(transitive)
+ Added@remixproject/plugin-utils@0.3.0-beta.9(transitive)
- Removed@remixproject/plugin-api@0.3.0-beta.6(transitive)
- Removed@remixproject/plugin-utils@0.3.0-beta.8(transitive)