@jupyterlab/coreutils
Advanced tools
| import { IPlugin, PluginRegistry } from '@lumino/coreutils'; | ||
| export declare class JupyterPluginRegistry<T = any> extends PluginRegistry<T> { | ||
| constructor(options?: JupyterPluginRegistry.IOptions); | ||
| registerPlugin(plugin: IPlugin<T, any>): void; | ||
| activatePlugin(id: string): Promise<void>; | ||
| private _getDependentCount; | ||
| private _pluginData; | ||
| private _expectedActivationTime; | ||
| } | ||
| export declare namespace JupyterPluginRegistry { | ||
| /** | ||
| * Options for Jupyter plugin registry. | ||
| */ | ||
| interface IOptions extends PluginRegistry.IOptions { | ||
| /** | ||
| * Time within the plugins are expected to activate. | ||
| * | ||
| * If a plugin activation time exceed this value, a warning will be logged in the console. | ||
| */ | ||
| expectedActivationTime?: number; | ||
| } | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.JupyterPluginRegistry = void 0; | ||
| const coreutils_1 = require("@lumino/coreutils"); | ||
| const PLUGIN_ACTIVATION_TIMEOUT = 5000; | ||
| class JupyterPluginRegistry extends coreutils_1.PluginRegistry { | ||
| constructor(options) { | ||
| var _a; | ||
| super(options); | ||
| this._pluginData = new Map(); | ||
| this._expectedActivationTime = | ||
| (_a = options === null || options === void 0 ? void 0 : options.expectedActivationTime) !== null && _a !== void 0 ? _a : PLUGIN_ACTIVATION_TIMEOUT; | ||
| } | ||
| registerPlugin(plugin) { | ||
| this._pluginData.set(plugin.id, plugin); | ||
| return super.registerPlugin(plugin); | ||
| } | ||
| async activatePlugin(id) { | ||
| const startTime = performance.now(); | ||
| // Set a timeout to detect if the plugin stalls | ||
| let timeoutId = setTimeout(() => { | ||
| console.warn(`Plugin ${id} is taking too long to activate.`); | ||
| }, this._expectedActivationTime); | ||
| try { | ||
| const result = await super.activatePlugin(id); | ||
| clearTimeout(timeoutId); | ||
| const endTime = performance.now(); | ||
| const activationTime = endTime - startTime; | ||
| if (activationTime >= this._expectedActivationTime) { | ||
| const dependantCount = this._getDependentCount(id); | ||
| console.warn(`Plugin ${id} (with ${dependantCount} dependants) took ${activationTime.toFixed(2)}ms to activate.`); | ||
| } | ||
| return result; | ||
| } | ||
| catch (error) { | ||
| clearTimeout(timeoutId); | ||
| console.error(`Error activating plugin: ${id}`, error); | ||
| throw error; | ||
| } | ||
| } | ||
| _getDependentCount(id) { | ||
| var _a; | ||
| const plugin = this._pluginData.get(id); | ||
| if (!(plugin === null || plugin === void 0 ? void 0 : plugin.provides)) | ||
| return 0; | ||
| const tokenName = plugin.provides.name; | ||
| let dependentCount = 0; | ||
| for (const [otherId, otherPlugin] of this._pluginData.entries()) { | ||
| if (otherId === id) | ||
| continue; | ||
| const isDependant = (_a = otherPlugin.requires) === null || _a === void 0 ? void 0 : _a.filter((token) => !!token).some((token) => token.name === tokenName); | ||
| if (isDependant) { | ||
| dependentCount++; | ||
| } | ||
| } | ||
| return dependentCount; | ||
| } | ||
| } | ||
| exports.JupyterPluginRegistry = JupyterPluginRegistry; | ||
| //# sourceMappingURL=pluginregistry.js.map |
| {"version":3,"file":"pluginregistry.js","sourceRoot":"","sources":["../src/pluginregistry.ts"],"names":[],"mappings":";;;AAAA,iDAAmE;AAEnE,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAa,qBAA+B,SAAQ,0BAAiB;IACnE,YAAY,OAAwC;;QAClD,KAAK,CAAC,OAAO,CAAC,CAAC;QA+DT,gBAAW,GAAiC,IAAI,GAAG,EAAE,CAAC;QA9D5D,IAAI,CAAC,uBAAuB;YAC1B,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,sBAAsB,mCAAI,yBAAyB,CAAC;IACjE,CAAC;IAED,cAAc,CAAC,MAAuB;QACpC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACxC,OAAO,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAU;QAC7B,M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,CAAC;QAEvB,KAAK,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,EAAE,CAAC;YAChE,IAAI,OAAO,KAAK,EAAE;gBAAE,SAAS;YAE7B,MAAM,WAAW,GAAG,MAAA,WAAW,CAAC,QAAQ,0CACpC,MAAM,CAAC,CAAC,KAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EACtC,IAAI,CAAC,CAAC,KAAiB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;YAEzD,IAAI,WAAW,EAAE,CAAC;gBAChB,cAAc,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CAIF;AAnED,sDAmEC"} |
| import { IPlugin, PluginRegistry, Token } from '@lumino/coreutils'; | ||
| const PLUGIN_ACTIVATION_TIMEOUT = 5000; | ||
| export class JupyterPluginRegistry<T = any> extends PluginRegistry<T> { | ||
| constructor(options?: JupyterPluginRegistry.IOptions) { | ||
| super(options); | ||
| this._expectedActivationTime = | ||
| options?.expectedActivationTime ?? PLUGIN_ACTIVATION_TIMEOUT; | ||
| } | ||
| registerPlugin(plugin: IPlugin<T, any>): void { | ||
| this._pluginData.set(plugin.id, plugin); | ||
| return super.registerPlugin(plugin); | ||
| } | ||
| async activatePlugin(id: string) { | ||
| const startTime = performance.now(); | ||
| // Set a timeout to detect if the plugin stalls | ||
| let timeoutId = setTimeout(() => { | ||
| console.warn(`Plugin ${id} is taking too long to activate.`); | ||
| }, this._expectedActivationTime); | ||
| try { | ||
| const result = await super.activatePlugin(id); | ||
| clearTimeout(timeoutId); | ||
| const endTime = performance.now(); | ||
| const activationTime = endTime - startTime; | ||
| if (activationTime >= this._expectedActivationTime) { | ||
| const dependantCount = this._getDependentCount(id); | ||
| console.warn( | ||
| `Plugin ${id} (with ${dependantCount} dependants) took ${activationTime.toFixed( | ||
| 2 | ||
| )}ms to activate.` | ||
| ); | ||
| } | ||
| return result; | ||
| } catch (error) { | ||
| clearTimeout(timeoutId); | ||
| console.error(`Error activating plugin: ${id}`, error); | ||
| throw error; | ||
| } | ||
| } | ||
| private _getDependentCount(id: string): number { | ||
| const plugin = this._pluginData.get(id); | ||
| if (!plugin?.provides) return 0; | ||
| const tokenName = plugin.provides.name; | ||
| let dependentCount = 0; | ||
| for (const [otherId, otherPlugin] of this._pluginData.entries()) { | ||
| if (otherId === id) continue; | ||
| const isDependant = otherPlugin.requires | ||
| ?.filter((token: Token<any>) => !!token) | ||
| .some((token: Token<any>) => token.name === tokenName); | ||
| if (isDependant) { | ||
| dependentCount++; | ||
| } | ||
| } | ||
| return dependentCount; | ||
| } | ||
| private _pluginData: Map<string, IPlugin<T, any>> = new Map(); | ||
| private _expectedActivationTime: number; | ||
| } | ||
| export namespace JupyterPluginRegistry { | ||
| /** | ||
| * Options for Jupyter plugin registry. | ||
| */ | ||
| export interface IOptions extends PluginRegistry.IOptions { | ||
| /** | ||
| * Time within the plugins are expected to activate. | ||
| * | ||
| * If a plugin activation time exceed this value, a warning will be logged in the console. | ||
| */ | ||
| expectedActivationTime?: number; | ||
| } | ||
| } |
+1
-0
@@ -15,1 +15,2 @@ /** | ||
| export * from './url'; | ||
| export * from './pluginregistry'; |
+1
-0
@@ -33,2 +33,3 @@ "use strict"; | ||
| __exportStar(require("./url"), exports); | ||
| __exportStar(require("./pluginregistry"), exports); | ||
| //# sourceMappingURL=index.js.map |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;;;;;;;;;;;;;;;;AAEH,oDAAkC;AAClC,+CAA6B;AAC7B,wCAAsB;AACtB,uDAAqC;AACrC,+CAA6B;AAC7B,yCAAuB;AACvB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,wCAAsB"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,2DAA2D;AAC3D;;;GAGG;;;;;;;;;;;;;;;;AAEH,oDAAkC;AAClC,+CAA6B;AAC7B,wCAAsB;AACtB,uDAAqC;AACrC,+CAA6B;AAC7B,yCAAuB;AACvB,2CAAyB;AACzB,yCAAuB;AACvB,yCAAuB;AACvB,wCAAsB;AACtB,mDAAiC"} |
+1
-1
| { | ||
| "name": "@jupyterlab/coreutils", | ||
| "version": "6.5.0", | ||
| "version": "6.5.1", | ||
| "description": "JupyterLab - Core Utilities", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", |
+1
-0
@@ -18,1 +18,2 @@ // Copyright (c) Jupyter Development Team. | ||
| export * from './url'; | ||
| export * from './pluginregistry'; |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
123307
6.91%54
8%2934
5.54%