Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jupyterlab/settingregistry

Package Overview
Dependencies
Maintainers
27
Versions
282
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupyterlab/settingregistry - npm Package Compare versions

Comparing version 3.1.0-alpha.11 to 3.1.0-alpha.12

131

lib/plugin-schema.json

@@ -9,3 +9,21 @@ {

"properties": {
"jupyter.lab.setting-deprecated": { "type": "boolean", "default": false },
"jupyter.lab.menus": {
"type": "object",
"properties": {
"main": {
"title": "Main menu entries",
"description": "List of menu items to add to the main menubar.",
"items": {
"$ref": "#/definitions/menu"
},
"type": "array",
"default": []
}
},
"additionalProperties": false
},
"jupyter.lab.setting-deprecated": {
"type": "boolean",
"default": false
},
"jupyter.lab.setting-icon": {

@@ -19,22 +37,117 @@ "type": "string",

},
"jupyter.lab.setting-icon-label": { "type": "string", "default": "Plugin" },
"jupyter.lab.setting-icon-label": {
"type": "string",
"default": "Plugin"
},
"jupyter.lab.shortcuts": {
"items": { "$ref": "#/definitions/shortcut" },
"items": {
"$ref": "#/definitions/shortcut"
},
"type": "array",
"default": []
},
"jupyter.lab.transform": { "type": "boolean", "default": false }
"jupyter.lab.transform": {
"type": "boolean",
"default": false
}
},
"definitions": {
"menu": {
"properties": {
"disabled": {
"type": "boolean",
"default": false
},
"id": {
"oneOf": [
{
"type": "string",
"enum": [
"jp-menu-file",
"jp-menu-file-new",
"jp-menu-edit",
"jp-menu-help",
"jp-menu-kernel",
"jp-menu-run",
"jp-menu-settings",
"jp-menu-view",
"jp-menu-tabs"
]
},
{ "type": "string", "pattern": "[a-z][a-z0-9\\-_]+" }
]
},
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/menuItem"
}
},
"label": {
"type": "string"
},
"rank": {
"type": "number",
"minimum": 0
}
},
"required": ["id"],
"type": "object"
},
"menuItem": {
"properties": {
"args": {
"type": "object"
},
"command": {
"type": "string"
},
"disabled": {
"type": "boolean",
"default": false
},
"type": {
"type": "string",
"enum": ["command", "submenu", "separator"],
"default": "command"
},
"rank": {
"type": "number",
"minimum": 0
},
"submenu": {
"oneOf": [
{
"$ref": "#/definitions/menu"
},
{
"type": "null"
}
]
}
},
"type": "object"
},
"shortcut": {
"properties": {
"args": { "type": "object" },
"command": { "type": "string" },
"disabled": { "type": "boolean", "default": false },
"args": {
"type": "object"
},
"command": {
"type": "string"
},
"disabled": {
"type": "boolean",
"default": false
},
"keys": {
"items": { "type": "string" },
"items": {
"type": "string"
},
"minItems": 1,
"type": "array"
},
"selector": { "type": "string" }
"selector": {
"type": "string"
}
},

@@ -41,0 +154,0 @@ "required": ["command", "keys", "selector"],

@@ -382,2 +382,11 @@ import { JSONValue, ReadonlyJSONObject, PartialJSONValue, ReadonlyPartialJSONObject, ReadonlyPartialJSONValue } from '@lumino/coreutils';

/**
* Reconcile the menus.
*
* @param reference The reference list of menus.
* @param addition The list of menus to add.
* @param warn Warn if the command items are duplicated within the same menu.
* @returns The reconciled list of menus.
*/
function reconcileMenus(reference: ISettingRegistry.IMenu[] | null, addition: ISettingRegistry.IMenu[] | null, warn?: boolean): ISettingRegistry.IMenu[];
/**
* Reconcile default and user shortcuts and return the composite list.

@@ -384,0 +393,0 @@ *

// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import Ajv from 'ajv';

@@ -630,2 +641,99 @@ import * as json5 from 'json5';

/**
* Reconcile the menus.
*
* @param reference The reference list of menus.
* @param addition The list of menus to add.
* @param warn Warn if the command items are duplicated within the same menu.
* @returns The reconciled list of menus.
*/
function reconcileMenus(reference, addition, warn = false) {
if (!reference) {
return addition ? JSONExt.deepCopy(addition) : [];
}
if (!addition) {
return JSONExt.deepCopy(reference);
}
const merged = JSONExt.deepCopy(reference);
addition.forEach(menu => {
const refIndex = merged.findIndex(ref => ref.id === menu.id);
if (refIndex >= 0) {
merged[refIndex] = Object.assign(Object.assign(Object.assign({}, merged[refIndex]), menu), { items: reconcileItems(merged[refIndex].items, menu.items, warn) });
}
else {
merged.push(menu);
}
});
// Remove disabled menus
return merged
.filter(menu => !menu.disabled)
.map(menu => filterDisableEntries(menu));
}
SettingRegistry.reconcileMenus = reconcileMenus;
function filterDisableEntries(menu) {
var _a;
return Object.assign(Object.assign({}, menu), { items: ((_a = menu.items) !== null && _a !== void 0 ? _a : []).reduce((final, value) => {
if (!value.disabled) {
if (value.type === 'submenu') {
const { submenu } = value, others = __rest(value, ["submenu"]);
final.push(Object.assign(Object.assign({}, others), { submenu: submenu && !submenu.disabled
? filterDisableEntries(submenu)
: null }));
}
else {
final.push(value);
}
}
return final;
}, []) });
}
function reconcileItems(reference, addition, warn = false) {
if (!reference) {
return addition ? JSONExt.deepCopy(addition) : undefined;
}
if (!addition) {
return JSONExt.deepCopy(reference);
}
const items = JSONExt.deepCopy(reference);
// Merge array element depending on the type
addition.forEach(item => {
var _a;
switch ((_a = item.type) !== null && _a !== void 0 ? _a : 'command') {
case 'separator':
items.push(Object.assign({}, item));
break;
case 'submenu':
if (item.submenu) {
const refIndex = items.findIndex(ref => { var _a, _b; return ref.type === 'submenu' && ((_a = ref.submenu) === null || _a === void 0 ? void 0 : _a.id) === ((_b = item.submenu) === null || _b === void 0 ? void 0 : _b.id); });
if (refIndex < 0) {
items.push(JSONExt.deepCopy(item));
}
else {
items[refIndex] = Object.assign(Object.assign(Object.assign({}, items[refIndex]), item), { submenu: reconcileMenus(items[refIndex].submenu
? [items[refIndex].submenu]
: null, [item.submenu], warn)[0] });
}
}
break;
case 'command':
if (item.command) {
const refIndex = items.findIndex(ref => {
var _a, _b;
return ref.command === item.command &&
JSONExt.deepEqual((_a = ref.args) !== null && _a !== void 0 ? _a : {}, (_b = item.args) !== null && _b !== void 0 ? _b : {});
});
if (refIndex < 0) {
items.push(Object.assign({}, item));
}
else {
if (warn) {
console.warn(`Menu entry for command '${item.command}' is duplicated.`);
}
items[refIndex] = Object.assign(Object.assign({}, items[refIndex]), item);
}
}
}
});
return items;
}
/**
* Reconcile default and user shortcuts and return the composite list.

@@ -632,0 +740,0 @@ *

@@ -131,2 +131,74 @@ import { PartialJSONObject, Token, PartialJSONValue, ReadonlyPartialJSONObject, ReadonlyPartialJSONValue } from '@lumino/coreutils';

/**
* The menu ids defined by default.
*/
type DefaultMenuId = 'jp-menu-file' | 'jp-menu-file-new' | 'jp-menu-edit' | 'jp-menu-help' | 'jp-menu-kernel' | 'jp-menu-run' | 'jp-menu-settings' | 'jp-menu-view' | 'jp-menu-tabs';
/**
* Menu defined by a specific plugin
*/
interface IMenu extends PartialJSONObject {
/**
* Unique menu identifier
*/
id: DefaultMenuId | string;
/**
* Menu items
*/
items?: IMenuItem[];
/**
* The rank order of the menu among its siblings.
*/
rank?: number;
/**
* Menu title
*
* #### Notes
* Default will be the capitalized id.
*/
label?: string;
/**
* Whether a menu is disabled. `False` by default.
*
* #### Notes
* This allows an user to suppress a menu.
*/
disabled?: boolean;
}
interface IMenuItem extends PartialJSONObject {
/**
* The type of the menu item.
*
* The default value is `'command'`.
*/
type?: 'command' | 'submenu' | 'separator';
/**
* The command to execute when the item is triggered.
*
* The default value is an empty string.
*/
command?: string;
/**
* The arguments for the command.
*
* The default value is an empty object.
*/
args?: PartialJSONObject;
/**
* The rank order of the menu item among its siblings.
*/
rank?: number;
/**
* The submenu for a `'submenu'` type item.
*
* The default value is `null`.
*/
submenu?: IMenu | null;
/**
* Whether a menu item is disabled. `false` by default.
*
* #### Notes
* This allows an user to suppress menu items.
*/
disabled?: boolean;
}
/**
* The settings for a specific plugin.

@@ -203,2 +275,8 @@ */

/**
* The JupyterLab menus that are created by a plugin's schema.
*/
'jupyter.lab.menus'?: {
main: IMenu[];
};
/**
* Whether the schema is deprecated.

@@ -205,0 +283,0 @@ *

8

package.json
{
"name": "@jupyterlab/settingregistry",
"version": "3.1.0-alpha.11",
"version": "3.1.0-alpha.12",
"description": "Settings registry for Jupyterlab",

@@ -39,3 +39,3 @@ "homepage": "https://github.com/jupyterlab/jupyterlab",

"dependencies": {
"@jupyterlab/statedb": "^3.1.0-alpha.11",
"@jupyterlab/statedb": "^3.1.0-alpha.12",
"@lumino/commands": "^1.12.0",

@@ -49,3 +49,3 @@ "@lumino/coreutils": "^1.5.3",

"devDependencies": {
"@jupyterlab/testutils": "^3.1.0-alpha.11",
"@jupyterlab/testutils": "^3.1.0-alpha.12",
"@types/jest": "^26.0.10",

@@ -61,3 +61,3 @@ "@types/json5": "^0.0.30",

},
"gitHead": "98427f4503f8e6f7b8cec181f0626b798f46dc47"
"gitHead": "12943471593e2ef73d3fd92393c33e1b1f9a60d5"
}

Sorry, the diff of this file is not supported yet

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