@jupyterlab/settingregistry
Advanced tools
Comparing version 4.0.0-alpha.4 to 4.0.0-alpha.5
@@ -270,2 +270,7 @@ import { IDataConnector } from '@jupyterlab/statedb'; | ||
/** | ||
* Checks if any fields are different from the default value. | ||
*/ | ||
isDefault(user: ReadonlyPartialJSONObject): boolean; | ||
get isModified(): boolean; | ||
/** | ||
* The user settings. | ||
@@ -289,3 +294,3 @@ */ | ||
*/ | ||
default(key: string): PartialJSONValue | undefined; | ||
default(key?: string): PartialJSONValue | undefined; | ||
/** | ||
@@ -292,0 +297,0 @@ * Dispose of the plugin settings resources. |
@@ -513,2 +513,26 @@ // Copyright (c) Jupyter Development Team. | ||
/** | ||
* Checks if any fields are different from the default value. | ||
*/ | ||
isDefault(user) { | ||
for (const key in this.schema.properties) { | ||
const value = user[key]; | ||
const defaultValue = this.default(key); | ||
if (value === undefined || | ||
value === null || | ||
defaultValue === undefined || | ||
defaultValue === null || | ||
JSONExt.deepEqual(value, JSONExt.emptyObject) || | ||
JSONExt.deepEqual(value, JSONExt.emptyArray)) { | ||
continue; | ||
} | ||
if (!JSONExt.deepEqual(value, defaultValue)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
get isModified() { | ||
return !this.isDefault(this.user); | ||
} | ||
/** | ||
* The user settings. | ||
@@ -976,17 +1000,42 @@ */ | ||
function reifyDefault(schema, root) { | ||
var _a; | ||
var _a, _b, _c; | ||
const definitions = schema.definitions; | ||
// If the property is at the root level, traverse its schema. | ||
schema = (root ? (_a = schema.properties) === null || _a === void 0 ? void 0 : _a[root] : schema) || {}; | ||
// If the property has no default or is a primitive, return. | ||
if (!('default' in schema) || schema.type !== 'object') { | ||
if (schema.type === 'object') { | ||
// Make a copy of the default value to populate. | ||
const result = JSONExt.deepCopy(schema.default); | ||
// Iterate through and populate each child property. | ||
const props = schema.properties || {}; | ||
for (const property in props) { | ||
result[property] = reifyDefault(props[property]); | ||
} | ||
return result; | ||
} | ||
else if (schema.type === 'array') { | ||
// Make a copy of the default value to populate. | ||
const result = JSONExt.deepCopy(schema.default); | ||
// Items defines the properties of each item in the array | ||
let props = schema.items || {}; | ||
// Use referenced definition if one exists | ||
if (props['$ref'] && definitions) { | ||
const ref = props['$ref'].replace('#/definitions/', ''); | ||
props = (_b = definitions[ref]) !== null && _b !== void 0 ? _b : {}; | ||
} | ||
// Iterate through the items in the array and fill in defaults | ||
for (const item in result) { | ||
// Use the values that are hard-coded in the default array over the defaults for each field. | ||
const reified = reifyDefault(props) || {}; | ||
for (const prop in reified) { | ||
if ((_c = result[item]) === null || _c === void 0 ? void 0 : _c[prop]) { | ||
reified[prop] = result[item][prop]; | ||
} | ||
} | ||
result[item] = reified; | ||
} | ||
return result; | ||
} | ||
else { | ||
return schema.default; | ||
} | ||
// Make a copy of the default value to populate. | ||
const result = JSONExt.deepCopy(schema.default); | ||
// Iterate through and populate each child property. | ||
const props = schema.properties || {}; | ||
for (const property in props) { | ||
result[property] = reifyDefault(props[property]); | ||
} | ||
return result; | ||
} | ||
@@ -993,0 +1042,0 @@ Private.reifyDefault = reifyDefault; |
@@ -6,3 +6,2 @@ /* ----------------------------------------------------------------------------- | ||
import { Token } from '@lumino/coreutils'; | ||
/* tslint:disable */ | ||
/** | ||
@@ -9,0 +8,0 @@ * The setting registry token. |
{ | ||
"name": "@jupyterlab/settingregistry", | ||
"version": "4.0.0-alpha.4", | ||
"version": "4.0.0-alpha.5", | ||
"description": "Settings registry for Jupyterlab", | ||
@@ -38,5 +38,5 @@ "homepage": "https://github.com/jupyterlab/jupyterlab", | ||
"dependencies": { | ||
"@jupyterlab/statedb": "^4.0.0-alpha.4", | ||
"@lumino/commands": "^1.19.0", | ||
"@lumino/coreutils": "^1.11.1", | ||
"@jupyterlab/statedb": "^4.0.0-alpha.5", | ||
"@lumino/commands": "^1.20.0", | ||
"@lumino/coreutils": "^1.12.0", | ||
"@lumino/disposable": "^1.10.1", | ||
@@ -48,3 +48,3 @@ "@lumino/signaling": "^1.10.1", | ||
"devDependencies": { | ||
"@jupyterlab/testutils": "^4.0.0-alpha.4", | ||
"@jupyterlab/testutils": "^4.0.0-alpha.5", | ||
"@types/jest": "^26.0.10", | ||
@@ -51,0 +51,0 @@ "@types/json5": "^0.0.30", |
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
108765
2332
Updated@lumino/commands@^1.20.0
Updated@lumino/coreutils@^1.12.0