New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

phosphide

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phosphide - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

5

lib/appshell/plugin.d.ts
import { Container, Token } from 'phosphor-di';
import { Widget } from 'phosphor-widget';
import { ICommandRegistry } from '../commandregistry/index';
import { IAppShell, IMainAreaOptions, ISideAreaOptions } from './index';

@@ -24,7 +25,7 @@ /**

*/
static create(): IAppShell;
static create(registry: ICommandRegistry): IAppShell;
/**
* Construct a new application shell.
*/
constructor();
constructor(registry: ICommandRegistry);
/**

@@ -31,0 +32,0 @@ * Add a widget to the top content area.

83

lib/appshell/plugin.js

@@ -21,3 +21,4 @@ /*-----------------------------------------------------------------------------

var phosphor_widget_1 = require('phosphor-widget');
var index_1 = require('./index');
var index_1 = require('../commandregistry/index');
var index_2 = require('./index');
var sidebar_1 = require('./sidebar');

@@ -39,3 +40,3 @@ require('./plugin.css');

function register(container) {
container.register(index_1.IAppShell, AppShell);
container.register(index_2.IAppShell, AppShell);
}

@@ -51,3 +52,4 @@ exports.register = register;

*/
function AppShell() {
function AppShell(registry) {
var _this = this;
_super.call(this);

@@ -59,4 +61,4 @@ this.addClass(APP_SHELL_CLASS);

var hsplitPanel = new phosphor_splitpanel_1.SplitPanel();
var leftHandler = new SideBarHandler();
var rightHandler = new SideBarHandler();
var leftHandler = new SideBarHandler('left');
var rightHandler = new SideBarHandler('right');
var rootLayout = new phosphor_boxpanel_1.BoxLayout();

@@ -100,2 +102,27 @@ this._topPanel = topPanel;

this.layout = rootLayout;
registry.add([
{
id: 'appshell:activate-left',
handler: function (args) { _this._leftHandler.activate(args.id); }
},
{
id: 'appshell:activate-right',
handler: function (args) { _this._rightHandler.activate(args.id); }
},
{
id: 'appshell:collapse-left',
handler: function () { _this._leftHandler.sideBar.currentTitle = null; }
},
{
id: 'appshell:collapse-right',
handler: function () { _this._rightHandler.sideBar.currentTitle = null; }
},
{
id: 'appshell:collapse-both',
handler: function () {
_this._leftHandler.sideBar.currentTitle = null;
_this._rightHandler.sideBar.currentTitle = null;
}
}
]);
}

@@ -105,4 +132,4 @@ /**

*/
AppShell.create = function () {
return new AppShell();
AppShell.create = function (registry) {
return new AppShell(registry);
};

@@ -115,2 +142,6 @@ /**

// TODO
if (!widget.id) {
console.error('widgets added to app shell must have unique id property');
return;
}
};

@@ -122,2 +153,6 @@ /**

if (options === void 0) { options = {}; }
if (!widget.id) {
console.error('widgets added to app shell must have unique id property');
return;
}
var rank = 'rank' in options ? options.rank : 100;

@@ -131,2 +166,6 @@ this._leftHandler.addWidget(widget, rank);

if (options === void 0) { options = {}; }
if (!widget.id) {
console.error('widgets added to app shell must have unique id property');
return;
}
var rank = 'rank' in options ? options.rank : 100;

@@ -141,2 +180,6 @@ this._rightHandler.addWidget(widget, rank);

// TODO
if (!widget.id) {
console.error('widgets added to app shell must have unique id property');
return;
}
this._dockPanel.insertTabAfter(widget);

@@ -147,3 +190,3 @@ };

*/
AppShell.requires = [];
AppShell.requires = [index_1.ICommandRegistry];
return AppShell;

@@ -159,4 +202,5 @@ }(phosphor_widget_1.Widget));

*/
function SideBarHandler() {
function SideBarHandler(side) {
this._items = [];
this._side = side;
this._sideBar = new sidebar_1.SideBar();

@@ -196,2 +240,16 @@ this._stackedPanel = new phosphor_stackedpanel_1.StackedPanel();

/**
* Activate a widget residing in the side bar by ID.
*
* @param id - The widget's unique ID.
*/
SideBarHandler.prototype.activate = function (id) {
for (var i = 0, n = this._stackedPanel.childCount(); i < n; ++i) {
var widget = this._stackedPanel.childAt(i);
if (widget.id === id) {
this._sideBar.currentTitle = widget.title;
return;
}
}
};
/**
* Add a widget and its title to the stacked panel and side bar.

@@ -245,4 +303,9 @@ *

oldWidget.hide();
if (newWidget)
if (newWidget) {
newWidget.show();
document.body.dataset[(this._side + "Area")] = newWidget.id;
}
else {
delete document.body.dataset[(this._side + "Area")];
}
this._refreshVisibility();

@@ -249,0 +312,0 @@ };

@@ -68,10 +68,12 @@ /*-----------------------------------------------------------------------------

var modelItems = items.map(function (item) {
var handler = _this._commandRegistry.get(item.id);
if (!handler)
var commandExists = _this._commandRegistry.has(item.id);
if (!commandExists)
return null;
var options = {
handler: handler,
handler: function (args) {
_this._commandRegistry.execute(item.id, args);
},
args: item.args,
text: item.text,
shortcut: "",
shortcut: '',
category: item.category,

@@ -78,0 +80,0 @@ caption: item.caption };

@@ -30,2 +30,9 @@ import { Token } from 'phosphor-di';

/**
* A signal emitted when a command is executed.
*/
commandExecuted: ISignal<ICommandRegistry, {
id: string;
args: any;
}>;
/**
* List the currently registered commands.

@@ -37,9 +44,9 @@ *

/**
* Lookup a command with a specific id.
* Test whether the registry contains a command.
*
* @param id - The id of the command of interest.
*
* @returns The command with the specified id, or `undefined`.
* @returns `true` if the command is registered, `false` otherwise.
*/
get(id: string): (args: any) => void;
has(id: string): boolean;
/**

@@ -57,2 +64,15 @@ * Add commands to the registry.

add(items: ICommandItem[]): IDisposable;
/**
* Execute a registered command.
*
* @param id - The id of the command of interest.
*
* @param args - The arguments to pass to the command, if necessary.
*
* #### Notes
* If the command id is not registered, a warning will be logged.
*
* If the handler throws an exception, it will be caught and logged.
*/
execute(id: string, args?: any): void;
}

@@ -59,0 +79,0 @@ /**

@@ -44,16 +44,36 @@ import { Container, Token } from 'phosphor-di';

/**
* List the ids of the currently registered commands.
* A signal emitted when a command is executed.
*/
commandExecuted: ISignal<ICommandRegistry, {
id: string;
args: any;
}>;
/**
* Execute a registered command.
*
* @returns A new array of the registered command ids.
* @param id - The id of the command of interest.
*
* @param args - The arguments to pass to the command, if necessary.
*
* #### Notes
* If the command id is not registered, a warning will be logged.
*
* If the handler throws an exception, it will be caught and logged.
*/
list(): string[];
execute(id: string, args?: any): void;
/**
* Lookup a command with a specific id.
* Test whether the registry contains a command.
*
* @param id - The id of the command of interest.
*
* @returns The command with the specified id, or `undefined`.
* @returns `true` if the command is registered, `false` otherwise.
*/
get(id: string): (args: any) => void;
has(id: string): boolean;
/**
* List the ids of the currently registered commands.
*
* @returns A new array of the registered command ids.
*/
list(): string[];
/**
* Add commands to the registry.

@@ -60,0 +80,0 @@ *

@@ -65,21 +65,57 @@ /*-----------------------------------------------------------------------------

});
Object.defineProperty(CommandRegistry.prototype, "commandExecuted", {
/**
* A signal emitted when a command is executed.
*/
get: function () {
return CommandRegistryPrivate.commandExecutedSignal.bind(this);
},
enumerable: true,
configurable: true
});
/**
* List the ids of the currently registered commands.
* Execute a registered command.
*
* @returns A new array of the registered command ids.
* @param id - The id of the command of interest.
*
* @param args - The arguments to pass to the command, if necessary.
*
* #### Notes
* If the command id is not registered, a warning will be logged.
*
* If the handler throws an exception, it will be caught and logged.
*/
CommandRegistry.prototype.list = function () {
return Object.keys(this._map);
CommandRegistry.prototype.execute = function (id, args) {
var command = this._map[id];
if (!command) {
console.warn("command " + id + " does not exist in command registry");
return;
}
try {
command(args);
this.commandExecuted.emit({ id: id, args: args });
}
catch (error) {
console.warn("execution of command " + id + " failed with args: ", args);
}
};
/**
* Lookup a command with a specific id.
* Test whether the registry contains a command.
*
* @param id - The id of the command of interest.
*
* @returns The command with the specified id, or `undefined`.
* @returns `true` if the command is registered, `false` otherwise.
*/
CommandRegistry.prototype.get = function (id) {
return this._map[id];
CommandRegistry.prototype.has = function (id) {
return !!this._map[id];
};
/**
* List the ids of the currently registered commands.
*
* @returns A new array of the registered command ids.
*/
CommandRegistry.prototype.list = function () {
return Object.keys(this._map);
};
/**
* Add commands to the registry.

@@ -145,2 +181,6 @@ *

CommandRegistryPrivate.commandsRemovedSignal = new phosphor_signaling_1.Signal();
/**
* A signal emitted when a command is added to the registry.
*/
CommandRegistryPrivate.commandExecutedSignal = new phosphor_signaling_1.Signal();
})(CommandRegistryPrivate || (CommandRegistryPrivate = {}));

@@ -148,3 +148,3 @@ /*-----------------------------------------------------------------------------

return function (args) {
_this._commandRegistry.get(id)(args);
_this._commandRegistry.execute(id, args);
return true;

@@ -151,0 +151,0 @@ };

{
"name": "phosphide",
"version": "0.6.0",
"version": "0.7.0",
"description": "Slightly opinionated scaffolding for building plugin-based IDE-style applications.",

@@ -8,9 +8,8 @@ "main": "lib/index.js",

"dependencies": {
"fuzzysearch-js": "^0.1.1",
"phosphor-arrays": "^1.0.6",
"phosphor-boxpanel": "^1.0.0-rc.0",
"phosphor-commandpalette": "^0.1.0",
"phosphor-commandpalette": "^0.2.0",
"phosphor-di": "^0.9.0",
"phosphor-disposable": "^1.0.5",
"phosphor-dockpanel": "^0.9.6",
"phosphor-dockpanel": "^0.9.7",
"phosphor-domutil": "^1.2.0",

@@ -17,0 +16,0 @@ "phosphor-keymap": "^0.7.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc