Comparing version 0.8.0 to 0.9.0
@@ -0,0 +0,0 @@ import { Token } from 'phosphor-di'; |
@@ -0,0 +0,0 @@ /*----------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ import { Container, Token } from 'phosphor-di'; |
@@ -17,2 +17,3 @@ /*----------------------------------------------------------------------------- | ||
var phosphor_dockpanel_1 = require('phosphor-dockpanel'); | ||
var phosphor_messaging_1 = require('phosphor-messaging'); | ||
var phosphor_panel_1 = require('phosphor-panel'); | ||
@@ -108,9 +109,49 @@ var phosphor_splitpanel_1 = require('phosphor-splitpanel'); | ||
}, | ||
/** | ||
* This command collapses the left side bar. | ||
* | ||
* @param args.id - An optional widget ID. | ||
* | ||
* #### Notes | ||
* If `args.id` is provided and a widget with that ID does not exist, | ||
* this is a no-op. | ||
* If a widget with that ID exists but is not currently active, | ||
* this is a no-op. | ||
* If no ID is provided, the side bar closes (if open). | ||
*/ | ||
{ | ||
id: 'appshell:collapse-left', | ||
handler: function () { _this._leftHandler.sideBar.currentTitle = null; } | ||
handler: function (args) { | ||
var id = args && args.id; | ||
if (id) { | ||
_this._leftHandler.deactivate(id); | ||
} | ||
else { | ||
_this._leftHandler.sideBar.currentTitle = null; | ||
} | ||
} | ||
}, | ||
/** | ||
* This command collapses the right side bar. | ||
* | ||
* @param args.id - An optional widget ID. | ||
* | ||
* #### Notes | ||
* If `args.id` is provided and a widget with that ID does not exist, | ||
* this is a no-op. | ||
* If a widget with that ID exists but is not currently active, | ||
* this is a no-op. | ||
* If no ID is provided, the side bar closes (if open). | ||
*/ | ||
{ | ||
id: 'appshell:collapse-right', | ||
handler: function () { _this._rightHandler.sideBar.currentTitle = null; } | ||
handler: function (args) { | ||
var id = args && args.id; | ||
if (id) { | ||
_this._rightHandler.deactivate(id); | ||
} | ||
else { | ||
_this._rightHandler.sideBar.currentTitle = null; | ||
} | ||
} | ||
}, | ||
@@ -184,3 +225,3 @@ { | ||
return AppShell; | ||
}(phosphor_widget_1.Widget)); | ||
})(phosphor_widget_1.Widget); | ||
exports.AppShell = AppShell; | ||
@@ -260,2 +301,22 @@ /** | ||
/** | ||
* Deactivate a widget residing in the side bar by ID. | ||
* | ||
* @param id - The widget's unique ID. | ||
* | ||
* #### Notes | ||
* This is a no-op if the ID does not exist in the side bar. If the ID exists | ||
* but is not currently active, this is a no-op. | ||
*/ | ||
SideBarHandler.prototype.deactivate = function (id) { | ||
for (var i = 0, n = this._stackedPanel.childCount(); i < n; ++i) { | ||
var widget = this._stackedPanel.childAt(i); | ||
if (widget.id === id) { | ||
if (widget.title === this._sideBar.currentTitle) { | ||
this._sideBar.currentTitle = null; | ||
} | ||
return; | ||
} | ||
} | ||
}; | ||
/** | ||
* Find the insertion index for a rank item. | ||
@@ -296,2 +357,3 @@ */ | ||
newWidget.show(); | ||
phosphor_messaging_1.sendMessage(newWidget, new phosphor_messaging_1.Message('focus-request')); | ||
document.body.dataset[(this._side + "Area")] = newWidget.id; | ||
@@ -313,2 +375,2 @@ } | ||
return SideBarHandler; | ||
}()); | ||
})(); |
@@ -0,0 +0,0 @@ import { Message } from 'phosphor-messaging'; |
@@ -274,3 +274,3 @@ /*----------------------------------------------------------------------------- | ||
return SideBar; | ||
}(phosphor_widget_1.Widget)); | ||
})(phosphor_widget_1.Widget); | ||
exports.SideBar = SideBar; | ||
@@ -277,0 +277,0 @@ /** |
@@ -0,0 +0,0 @@ import { Token } from 'phosphor-di'; |
@@ -0,0 +0,0 @@ /*----------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ import { Container } from 'phosphor-di'; |
@@ -17,2 +17,6 @@ /*----------------------------------------------------------------------------- | ||
/** | ||
* The ID seed for added groups of palette items. | ||
*/ | ||
var id = 0; | ||
/** | ||
* Register the plugin contributions. | ||
@@ -35,2 +39,18 @@ * | ||
exports.register = register; | ||
/** | ||
* Fetch and format a shortcut sequence. | ||
* | ||
* @param shortcutManager - The shortcut manager that will be queried. | ||
* | ||
* @param command - The ID of the comand. | ||
* | ||
* @param args - The arguments passed to the command. | ||
*/ | ||
function getShortcut(shortcutManager, command, args) { | ||
var shortcut = shortcutManager.getSequences(command, args); | ||
if (shortcut && shortcut.length > 0) { | ||
return shortcut[0].map(function (s) { return s.replace(/\s/g, '-'); }).join(' '); | ||
} | ||
return ''; | ||
} | ||
var CommandPaletteManager = (function () { | ||
@@ -50,2 +70,3 @@ /** | ||
}; | ||
this._additions = []; | ||
this._paletteModel = new phosphor_commandpalette_1.StandardPaletteModel(); | ||
@@ -56,2 +77,4 @@ this._commandPalette = new phosphor_commandpalette_1.CommandPalette(); | ||
this._shortcutManager = shortcutManager; | ||
shortcutManager.shortcutsAdded.connect(this._onShortcutsChanged, this); | ||
shortcutManager.shortcutsRemoved.connect(this._onShortcutsChanged, this); | ||
commandRegistry.add([ | ||
@@ -99,30 +122,104 @@ { | ||
var _this = this; | ||
var modelItems = items.map(function (item) { | ||
var commandExists = _this._commandRegistry.has(item.id); | ||
if (!commandExists) | ||
var modelOptions = items.map(function (item) { | ||
if (!_this._commandRegistry.has(item.id)) { | ||
return null; | ||
var options = { | ||
} | ||
return { | ||
handler: _this._commandHandler, | ||
args: { id: item.id, args: item.args }, | ||
text: item.text, | ||
shortcut: '', | ||
shortcut: getShortcut(_this._shortcutManager, item.id, item.args), | ||
category: item.category, | ||
caption: item.caption | ||
}; | ||
var shortcut = _this._shortcutManager.getSequences(item.id, item.args); | ||
if (shortcut && shortcut.length > 0) { | ||
options.shortcut = shortcut[0] | ||
.map(function (s) { return s.replace(/\s/g, '-'); }).join(' '); | ||
} | ||
return options; | ||
}).filter(function (item) { return !!item; }); | ||
if (!modelItems.length) | ||
if (!modelOptions.length) { | ||
return; | ||
var paletteItems = this._paletteModel.addItems(modelItems); | ||
} | ||
// Keep a local reference to the set of items that are disposed together. | ||
var disposable = "palette-items-" + ++id; | ||
var additions = this._paletteModel.addItems(modelOptions).map(function (item) { | ||
return { disposable: disposable, item: item }; | ||
}); | ||
Array.prototype.push.apply(this._additions, additions); | ||
return new phosphor_disposable_1.DisposableDelegate(function () { | ||
_this._paletteModel.removeItems(paletteItems); | ||
var rest = _this._additions.filter(function (addition) { | ||
var keep = addition.disposable !== disposable; | ||
if (!keep) | ||
_this._paletteModel.removeItem(addition.item); | ||
return keep; | ||
}); | ||
if (rest.length === _this._additions.length) { | ||
return; | ||
} | ||
_this._additions = rest; | ||
}); | ||
}; | ||
/** | ||
* A handler for shortcut manager add and remove signals. | ||
* | ||
* @param sender - The shortcut manager triggering the signal. | ||
* | ||
* @param items - The list of shortcuts being added or removed. | ||
*/ | ||
CommandPaletteManager.prototype._onShortcutsChanged = function (sender, items) { | ||
// Create a map of items for easily checking whether a command has changed. | ||
var changes = items.reduce(function (acc, item) { | ||
if (acc[item.command]) { | ||
acc[item.command].push(item.args); | ||
} | ||
else { | ||
acc[item.command] = [item.args]; | ||
} | ||
return acc; | ||
}, {}); | ||
// Check if each added item is in the map and needs to be updated. | ||
for (var i = 0, n = this._additions.length; i < n; ++i) { | ||
var addition = this._additions[i]; | ||
var command = addition.item.args.id; | ||
var args = addition.item.args.args; | ||
if (!(command in changes)) | ||
continue; | ||
if (changes[command].indexOf(args) === -1) | ||
continue; | ||
var removed = this._updateCommand(addition.item, i); | ||
// If the command was removed, change loop bounds. | ||
if (removed) { | ||
n -= 1; | ||
i -= 1; | ||
} | ||
} | ||
}; | ||
/** | ||
* Update a palette item in the model and replace its internal cached version. | ||
* | ||
* @param item - The palette item to update. | ||
* | ||
* @param index - The local index in `_additions` where it is stored. | ||
* | ||
* @returns `true` if the item was removed. | ||
*/ | ||
CommandPaletteManager.prototype._updateCommand = function (item, index) { | ||
var command = item.args.id; | ||
var args = item.args.args; | ||
if (!this._commandRegistry.has(command)) { | ||
this._paletteModel.removeItem(item); | ||
this._additions.splice(index, 1); | ||
return true; | ||
} | ||
; | ||
var options = { | ||
handler: this._commandHandler, | ||
args: { id: command, args: args }, | ||
text: item.text, | ||
shortcut: getShortcut(this._shortcutManager, command, args), | ||
category: item.category, | ||
caption: item.caption | ||
}; | ||
this._paletteModel.removeItem(item); | ||
this._additions[index].item = this._paletteModel.addItem(options); | ||
return false; | ||
}; | ||
return CommandPaletteManager; | ||
}()); | ||
})(); | ||
/** | ||
@@ -129,0 +226,0 @@ * The namespace for the `CommandPaletteManager` class private data. |
@@ -0,0 +0,0 @@ import { Token } from 'phosphor-di'; |
@@ -0,0 +0,0 @@ /*----------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ import { Container, Token } from 'phosphor-di'; |
@@ -135,4 +135,4 @@ /*----------------------------------------------------------------------------- | ||
// Add the new commands to the map and warn for duplicates. | ||
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { | ||
var _a = items_1[_i], id = _a.id, handler = _a.handler; | ||
for (var _i = 0; _i < items.length; _i++) { | ||
var _a = items[_i], id = _a.id, handler = _a.handler; | ||
if (id in this._map) { | ||
@@ -154,4 +154,4 @@ console.warn("Command '" + id + "' is already registered."); | ||
return new phosphor_disposable_1.DisposableDelegate(function () { | ||
for (var _i = 0, added_1 = added; _i < added_1.length; _i++) { | ||
var id = added_1[_i]; | ||
for (var _i = 0; _i < added.length; _i++) { | ||
var id = added[_i]; | ||
delete _this._map[id]; | ||
@@ -167,3 +167,3 @@ } | ||
return CommandRegistry; | ||
}()); | ||
})(); | ||
exports.CommandRegistry = CommandRegistry; | ||
@@ -170,0 +170,0 @@ /** |
@@ -0,0 +0,0 @@ import { Container } from 'phosphor-di'; |
@@ -27,4 +27,4 @@ /*----------------------------------------------------------------------------- | ||
var newPlugins = []; | ||
for (var _i = 0, plugins_1 = plugins; _i < plugins_1.length; _i++) { | ||
var plugin = plugins_1[_i]; | ||
for (var _i = 0; _i < plugins.length; _i++) { | ||
var plugin = plugins[_i]; | ||
if (plugin && !pluginSet.has(plugin)) { | ||
@@ -36,4 +36,4 @@ pluginSet.add(plugin); | ||
// Register the new plugins. | ||
for (var _a = 0, newPlugins_1 = newPlugins; _a < newPlugins_1.length; _a++) { | ||
var plugin = newPlugins_1[_a]; | ||
for (var _a = 0; _a < newPlugins.length; _a++) { | ||
var plugin = newPlugins[_a]; | ||
if (plugin.register) { | ||
@@ -45,4 +45,4 @@ plugin.register(container); | ||
var promises = []; | ||
for (var _b = 0, newPlugins_2 = newPlugins; _b < newPlugins_2.length; _b++) { | ||
var plugin = newPlugins_2[_b]; | ||
for (var _b = 0; _b < newPlugins.length; _b++) { | ||
var plugin = newPlugins[_b]; | ||
if (plugin.resolve) { | ||
@@ -49,0 +49,0 @@ var result = plugin.resolve(container); |
@@ -0,0 +0,0 @@ export * from './core'; |
@@ -0,0 +0,0 @@ /*----------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ import { Token } from 'phosphor-di'; |
@@ -0,0 +0,0 @@ /*----------------------------------------------------------------------------- |
@@ -0,0 +0,0 @@ import { Token, Container } from 'phosphor-di'; |
@@ -81,4 +81,4 @@ /*----------------------------------------------------------------------------- | ||
var bindings = []; | ||
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { | ||
var item = items_1[_i]; | ||
for (var _i = 0; _i < items.length; _i++) { | ||
var item = items[_i]; | ||
var id = item.command; | ||
@@ -158,3 +158,3 @@ var arr = this._commandShortcutMap[id]; | ||
return ShortcutManager; | ||
}()); | ||
})(); | ||
exports.ShortcutManager = ShortcutManager; | ||
@@ -161,0 +161,0 @@ /** |
{ | ||
"name": "phosphide", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "Slightly opinionated scaffolding for building plugin-based IDE-style applications.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -0,0 +0,0 @@ phosphide |
Sorry, the diff of this file is not supported yet
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
193258
5373
45
1