diff --git a/CHANGELOG.md b/CHANGELOG.md index d4d75005b2..730d2db551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ They had been made public by mistake, and had been considered internal since the - `stringUtils.getStringValue` - `Client.isBrowserSupported` has been removed. It didn't correctly validate all prerequisites required to know if the browser supports maxGraph. So, remove it without replacement. +- `Client.VERSION` moved to `constants.VERSION`. VERSION is supposed to be immutable as it represents the actual version of maxGraph. +When it was stored in Client, it was a static property that could be modified. Moving it to the constants module ensures that it cannot be modified. ## 0.15.1 diff --git a/packages/core/src/Client.ts b/packages/core/src/Client.ts index 4e2d223e00..98cf8eff0b 100644 --- a/packages/core/src/Client.ts +++ b/packages/core/src/Client.ts @@ -19,13 +19,6 @@ limitations under the License. import { NS_SVG } from './util/Constants'; class Client { - /** - * The version of the `maxGraph` library. - */ - // WARN: this constant is updated at release time by the script located at `scripts/update-versions.mjs`. - // So, if you modify the name of this file or this constant, please update the script accordingly. - static VERSION = '0.15.1'; - /** * Base path for all URLs in the core without trailing slash. * diff --git a/packages/core/src/gui/MaxLog.ts b/packages/core/src/gui/MaxLog.ts index ea3a7e7365..9437e3f3bc 100644 --- a/packages/core/src/gui/MaxLog.ts +++ b/packages/core/src/gui/MaxLog.ts @@ -24,6 +24,7 @@ import MaxWindow, { popup } from './MaxWindow'; import { KeyboardEventListener, MouseEventListener } from '../types'; import { copyTextToClipboard } from '../util/Utils'; import { getElapseMillisecondsMessage } from '../util/logger'; +import { VERSION } from '../util/Constants'; /** * A singleton class that implements a simple console. @@ -40,7 +41,7 @@ class MaxLog { */ static init(): void { if (MaxLog.window == null && document.body != null) { - const title = `${MaxLog.consoleName} - mxGraph ${Client.VERSION}`; + const title = `${MaxLog.consoleName} - mxGraph ${VERSION}`; // Creates a table that maintains the layout const table = document.createElement('table'); diff --git a/packages/core/src/util/Constants.ts b/packages/core/src/util/Constants.ts index 4626a53dd4..005370c05f 100644 --- a/packages/core/src/util/Constants.ts +++ b/packages/core/src/util/Constants.ts @@ -16,6 +16,13 @@ See the License for the specific language governing permissions and limitations under the License. */ +/** + * The version of the `maxGraph` library. + */ +// WARN: this constant is updated at release time by the script located at 'scripts/update-versions.mjs'. +// So, if you modify the name of this file or this constant, please update the script accordingly. +export const VERSION = '0.15.1'; + /** * Defines the portion of the cell which is to be used as a connectable * region. Default is 0.3. Possible values are 0 < x <= 1. diff --git a/packages/js-example-without-defaults/src/index.js b/packages/js-example-without-defaults/src/index.js index 2dc77b20b1..2713c5a361 100644 --- a/packages/js-example-without-defaults/src/index.js +++ b/packages/js-example-without-defaults/src/index.js @@ -17,7 +17,6 @@ limitations under the License. import './style.css'; import { CellRenderer, - Client, constants, Graph, InternalEvent, @@ -105,7 +104,7 @@ const initializeGraph = (container) => { // display the maxGraph version in the footer const footer = document.querySelector('footer'); -footer.innerText = `Built with maxGraph ${Client.VERSION}`; +footer.innerText = `Built with maxGraph ${constants.VERSION}`; // Creates the graph inside the given container initializeGraph(document.querySelector('#graph-container')); diff --git a/packages/js-example/src/index.js b/packages/js-example/src/index.js index 9a85d621c2..c0e4a3e2c8 100644 --- a/packages/js-example/src/index.js +++ b/packages/js-example/src/index.js @@ -17,7 +17,7 @@ limitations under the License. import '@maxgraph/core/css/common.css'; import './style.css'; import { - Client, + constants, DomHelpers, getDefaultPlugins, Graph, @@ -74,7 +74,7 @@ const initializeGraph = (container) => { // display the maxGraph version in the footer const footer = document.querySelector('footer'); -footer.innerText = `Built with maxGraph ${Client.VERSION}`; +footer.innerText = `Built with maxGraph ${constants.VERSION}`; // Creates the graph inside the given container const container = document.querySelector('#graph-container'); diff --git a/packages/ts-example-without-defaults/src/main.ts b/packages/ts-example-without-defaults/src/main.ts index d9956883ec..fdde79ea8a 100644 --- a/packages/ts-example-without-defaults/src/main.ts +++ b/packages/ts-example-without-defaults/src/main.ts @@ -17,7 +17,6 @@ limitations under the License. import './style.css'; import { CellRenderer, - Client, constants, Graph, InternalEvent, @@ -105,7 +104,7 @@ const initializeGraph = (container: HTMLElement) => { // display the maxGraph version in the footer const footer = document.querySelector('footer'); -footer.innerText = `Built with maxGraph ${Client.VERSION}`; +footer.innerText = `Built with maxGraph ${constants.VERSION}`; // Creates the graph inside the given container initializeGraph(document.querySelector('#graph-container')); diff --git a/packages/ts-example/src/main.ts b/packages/ts-example/src/main.ts index 295cfcdacd..b71105ff3c 100644 --- a/packages/ts-example/src/main.ts +++ b/packages/ts-example/src/main.ts @@ -17,7 +17,6 @@ limitations under the License. import '@maxgraph/core/css/common.css'; // required by RubberBandHandler import './style.css'; import { - Client, constants, getDefaultPlugins, Graph, @@ -116,7 +115,7 @@ const initializeGraph = (container: HTMLElement) => { // display the maxGraph version in the footer const footer = document.querySelector('footer'); -footer.innerText = `Built with maxGraph ${Client.VERSION}`; +footer.innerText = `Built with maxGraph ${constants.VERSION}`; // Creates the graph inside the given container initializeGraph(document.querySelector('#graph-container')); diff --git a/packages/ts-support/src/index.ts b/packages/ts-support/src/index.ts index c03e42fce3..cb5bdc98f7 100644 --- a/packages/ts-support/src/index.ts +++ b/packages/ts-support/src/index.ts @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { Client, Graph, InternalEvent } from '@maxgraph/core'; +import { constants, Graph, InternalEvent } from '@maxgraph/core'; -const version = Client.VERSION; +const version = constants.VERSION; // Creates the graph inside the given container const container = document.getElementById('graph-container'); diff --git a/scripts/update-versions.mjs b/scripts/update-versions.mjs index 2bc93a12f1..f29494d519 100644 --- a/scripts/update-versions.mjs +++ b/scripts/update-versions.mjs @@ -46,13 +46,13 @@ function updateVersionInCorePackageJsonFile(newVersion) { } function updateVersionInSourceFile(newVersion) { - const path = 'packages/core/src/Client.ts'; + const path = 'packages/core/src/util/Constants.ts'; console.info('Updating', path); const content = readFileContent(path); // replace the 1st occurrence, this is OK as the constant appears only once in the file const updatedContent = content.replace( - /static VERSION =.*/, - `static VERSION = '${newVersion}';` + /const VERSION =.*/, + `const VERSION = '${newVersion}';` ); writeFileSync(path, updatedContent); }