@remixproject/plugin-utils
Advanced tools
Comparing version 0.3.0-beta.6 to 0.3.0-beta.7
21
index.js
@@ -1,13 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./lib/tools/event-name"), exports); | ||
tslib_1.__exportStar(require("./lib/tools/method-path"), exports); | ||
tslib_1.__exportStar(require("./lib/tools/service"), exports); | ||
tslib_1.__exportStar(require("./lib/types/api"), exports); | ||
tslib_1.__exportStar(require("./lib/types/message"), exports); | ||
tslib_1.__exportStar(require("./lib/types/plugin"), exports); | ||
tslib_1.__exportStar(require("./lib/types/profile"), exports); | ||
tslib_1.__exportStar(require("./lib/types/service"), exports); | ||
tslib_1.__exportStar(require("./lib/types/status"), exports); | ||
export * from './lib/tools/event-name'; | ||
export * from './lib/tools/method-path'; | ||
export * from './lib/tools/service'; | ||
export * from './lib/types/api'; | ||
export * from './lib/types/message'; | ||
export * from './lib/types/plugin'; | ||
export * from './lib/types/profile'; | ||
export * from './lib/types/service'; | ||
export * from './lib/types/status'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,14 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.listenEvent = exports.callEvent = void 0; | ||
/** Create the name of the event for a call */ | ||
function callEvent(name, key, id) { | ||
export function callEvent(name, key, id) { | ||
return `[${name}] ${key}-${id}`; | ||
} | ||
exports.callEvent = callEvent; | ||
/** Create the name of the event for a listen */ | ||
function listenEvent(name, key) { | ||
export function listenEvent(name, key) { | ||
return `[${name}] ${key}`; | ||
} | ||
exports.listenEvent = listenEvent; | ||
//# sourceMappingURL=event-name.js.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getRootPath = exports.getMethodPath = void 0; | ||
/** Create a method path based on the method name and the path */ | ||
function getMethodPath(method, path) { | ||
export function getMethodPath(method, path) { | ||
if (!path) { | ||
@@ -14,8 +11,6 @@ return method; | ||
} | ||
exports.getMethodPath = getMethodPath; | ||
/** Get the root name of a path */ | ||
function getRootPath(path) { | ||
export function getRootPath(path) { | ||
return path.split('.').shift(); | ||
} | ||
exports.getRootPath = getRootPath; | ||
//# sourceMappingURL=method-path.js.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PluginService = exports.activateService = exports.createService = exports.getMethods = exports.isPluginService = void 0; | ||
const tslib_1 = require("tslib"); | ||
const method_path_1 = require("./method-path"); | ||
import { __awaiter } from "tslib"; | ||
import { getRootPath } from './method-path'; | ||
/** Check if the plugin is an instance of PluginService */ | ||
exports.isPluginService = (service) => { | ||
export const isPluginService = (service) => { | ||
return service instanceof PluginService; | ||
@@ -14,3 +11,3 @@ }; | ||
*/ | ||
function getMethods(service) { | ||
export function getMethods(service) { | ||
// If service exposes methods, use them | ||
@@ -26,3 +23,3 @@ if (service.methods) { | ||
// Else get the public methods (without "_") | ||
if (exports.isPluginService(service)) { | ||
if (isPluginService(service)) { | ||
const methods = Object.getPrototypeOf(service); | ||
@@ -39,3 +36,2 @@ return Object.getOwnPropertyNames(methods).filter(m => { | ||
} | ||
exports.getMethods = getMethods; | ||
/** | ||
@@ -47,4 +43,4 @@ * Create a plugin service | ||
*/ | ||
function createService(path, service) { | ||
if (service.path && method_path_1.getRootPath(service.path) !== path) { | ||
export function createService(path, service) { | ||
if (service.path && getRootPath(service.path) !== path) { | ||
throw new Error(`Service path ${service.path} is different from the one provided: ${path}`); | ||
@@ -58,3 +54,3 @@ } | ||
} | ||
if (exports.isPluginService(service)) { | ||
if (isPluginService(service)) { | ||
if (!service.methods) { | ||
@@ -69,3 +65,2 @@ service.methods = methods; | ||
} | ||
exports.createService = createService; | ||
/** | ||
@@ -76,3 +71,3 @@ * Connect the service to the plugin client | ||
*/ | ||
function activateService(client, service) { | ||
export function activateService(client, service) { | ||
client.methods = [ | ||
@@ -88,7 +83,6 @@ ...(client.methods || []), | ||
} | ||
exports.activateService = activateService; | ||
/** | ||
* A node that forward the call to the right path | ||
*/ | ||
class PluginService { | ||
export class PluginService { | ||
emit(key, ...payload) { | ||
@@ -103,3 +97,3 @@ this.plugin.emit(key, ...payload); | ||
createService(name, service) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (this.methods.includes(name)) { | ||
@@ -125,3 +119,3 @@ throw new Error('A service cannot have the same name as an exposed method'); | ||
const path = `${this.path}.${name}`; | ||
this.plugin.activateService[path] = () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
this.plugin.activateService[path] = () => __awaiter(this, void 0, void 0, function* () { | ||
const service = factory(); | ||
@@ -135,3 +129,2 @@ const _service = createService(path, service); | ||
} | ||
exports.PluginService = PluginService; | ||
//# sourceMappingURL=service.js.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=api.js.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=message.js.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=plugin.js.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=profile.js.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=service.js.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=status.js.map |
{ | ||
"name": "@remixproject/plugin-utils", | ||
"version": "0.3.0-beta.6", | ||
"version": "0.3.0-beta.7", | ||
"homepage": "https://github.com/ethereum/remix-plugin/tree/master/packages/utils#readme", | ||
@@ -5,0 +5,0 @@ "repository": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20397
340