diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/examples/index.js b/lib/node_modules/@stdlib/plot/vega/signal/reference/examples/index.js new file mode 100644 index 000000000000..17e145f87c51 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/examples/index.js @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var SignalReference = require( './../lib' ); + +var signal = new SignalReference( 'width' ); +console.log( signal.toJSON() ); +// => { 'signal': 'width' } + +signal = new SignalReference( 'width / 2' ); +console.log( signal.toJSON() ); +// => { 'signal': 'width / 2' } diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/change_event.js b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/change_event.js new file mode 100644 index 000000000000..284840732359 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/change_event.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns a new change event object. +* +* @private +* @param {string} property - property name +* @returns {Object} event object +*/ +function event( property ) { // eslint-disable-line stdlib/no-redeclare + return { + 'type': 'update', + 'source': 'signal-reference', + 'property': property + }; +} + + +// EXPORTS // + +module.exports = event; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/index.js b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/index.js new file mode 100644 index 000000000000..7027a1f92f90 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/index.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Signal reference constructor. +* +* @module @stdlib/plot/vega/signal/reference +* +* @example +* var SignalReference = require( '@stdlib/plot/vega/signal/reference' ); +* +* var signal = new SignalReference( 'width' ); +* // returns +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/main.js b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/main.js new file mode 100644 index 000000000000..ccc6cd1b5f76 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/main.js @@ -0,0 +1,164 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var EventEmitter = require( 'events' ).EventEmitter; +var logger = require( 'debug' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var setNonEnumerableReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); // eslint-disable-line id-length +var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); +var inherit = require( '@stdlib/utils/inherit' ); +var instance2json = require( '@stdlib/plot/vega/base/to-json' ); +var transformErrorMessage = require( '@stdlib/plot/vega/base/transform-validation-message' ); +var format = require( '@stdlib/string/format' ); +var properties = require( './properties.json' ); + +// Note: keep the following in alphabetical order according to the `require` path... +var getProperties = require( './properties/get.js' ); + +var getSignal = require( './signal/get.js' ); +var setSignal = require( './signal/set.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:signal-reference:main' ); + + +// MAIN // + +/** +* Signal reference constructor. +* +* @constructor +* @param {string} reference - signal reference string +* @throws {TypeError} must provide a string +* @throws {Error} must provide valid arguments +* @returns {SignalReference} signal reference instance +* +* @example +* var signal = new SignalReference( 'width' ); +* // returns +* +* @example +* var signal = new SignalReference( 'width / 2' ); +* // returns +*/ +function SignalReference( reference ) { + if ( !( this instanceof SignalReference ) ) { + return new SignalReference( reference ); + } + EventEmitter.call( this ); + if ( !isString( reference ) ) { + throw new TypeError( format( 'invalid argument. Must provide a string. Value: `%s`.', reference ) ); + } + try { + this.signal = reference; + } catch ( err ) { + debug( 'Encountered an error. Error: %s', err.message ); + + // FIXME: retain thrown error type + throw new Error( transformErrorMessage( err.message ) ); + } + return this; +} + +/* +* Inherit from the `EventEmitter` prototype. +*/ +inherit( SignalReference, EventEmitter ); + +/** +* Constructor name. +* +* @private +* @name name +* @memberof SignalReference +* @readonly +* @type {string} +*/ +setNonEnumerableReadOnly( SignalReference, 'name', 'SignalReference' ); + +/** +* Signal reference string. +* +* @name signal +* @memberof SignalReference.prototype +* @type {string} +* +* @example +* var signal = new SignalReference( 'width' ); +* +* var v = signal.signal; +* // returns 'width' +* +* @example +* var signal = new SignalReference( 'width / 2' ); +* +* var v = signal.signal; +* // returns 'width / 2' +*/ +setReadWriteAccessor( SignalReference.prototype, 'signal', getSignal, setSignal ); + +/** +* Signal reference properties. +* +* @name properties +* @memberof SignalReference.prototype +* @type {Array} +* +* @example +* var signal = new SignalReference( 'width' ); +* +* var v = signal.properties; +* // returns [...] +*/ +setNonEnumerableReadOnlyAccessor( SignalReference.prototype, 'properties', getProperties ); + +/** +* Serializes an instance to a JSON object. +* +* ## Notes +* +* - This method is implicitly invoked by `JSON.stringify`. +* +* @name toJSON +* @memberof SignalReference.prototype +* @type {Function} +* @returns {Object} JSON object +* +* @example +* var signal = new SignalReference( 'width' ); +* +* var v = signal.toJSON(); +* // returns { 'signal': 'width' } +*/ +setNonEnumerableReadOnly( SignalReference.prototype, 'toJSON', function toJSON() { + return instance2json( this, properties ); +}); + + +// EXPORTS // + +module.exports = SignalReference; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/properties.json b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/properties.json new file mode 100644 index 000000000000..3bb6cbc23b53 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/properties.json @@ -0,0 +1,3 @@ +[ + "signal" +] diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/properties/get.js b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/properties/get.js new file mode 100644 index 000000000000..f3cbb28454ea --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/properties/get.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var properties = require( './../properties.json' ); + + +// MAIN // + +/** +* Returns the list of enumerable properties. +* +* @private +* @returns {Array} properties +*/ +function get() { + return properties.slice(); +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/signal/get.js b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/signal/get.js new file mode 100644 index 000000000000..489c5d4297f6 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/signal/get.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// VARIABLES // + +var prop = require( './properties.js' ); + + +// MAIN // + +/** +* Returns the signal reference. +* +* @private +* @returns {string} signal reference +*/ +function get() { + return this[ prop.private ]; +} + + +// EXPORTS // + +module.exports = get; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/signal/properties.js b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/signal/properties.js new file mode 100644 index 000000000000..9a15daba64d4 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/signal/properties.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var property2object = require( '@stdlib/plot/vega/base/property2object' ); + + +// MAIN // + +var obj = property2object( 'signal' ); + + +// EXPORTS // + +module.exports = obj; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/signal/set.js b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/signal/set.js new file mode 100644 index 000000000000..7f7c6a06e27f --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/lib/signal/set.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-invalid-this */ + +'use strict'; + +// MODULES // + +var logger = require( 'debug' ); +var isString = require( '@stdlib/assert/is-string' ).isPrimitive; +var format = require( '@stdlib/string/format' ); +var changeEvent = require( './../change_event.js' ); +var prop = require( './properties.js' ); + + +// VARIABLES // + +var debug = logger( 'vega:signal-reference:set:'+prop.name ); + + +// MAIN // + +/** +* Sets the signal reference. +* +* @private +* @param {string} value - input value +* @throws {TypeError} must be a string +* @returns {void} +*/ +function set( value ) { + if ( !isString( value ) ) { + throw new TypeError( format( 'invalid assignment. `%s` must be a string. Value: `%s`.', prop.name, value ) ); + } + if ( value !== this[ prop.private ] ) { + debug( 'Current value: %s. New value: %s.', this[ prop.private ], value ); + this[ prop.private ] = value; + this.emit( 'change', changeEvent( prop.name ) ); + } +} + + +// EXPORTS // + +module.exports = set; diff --git a/lib/node_modules/@stdlib/plot/vega/signal/reference/package.json b/lib/node_modules/@stdlib/plot/vega/signal/reference/package.json new file mode 100644 index 000000000000..fc512163027b --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/signal/reference/package.json @@ -0,0 +1,62 @@ +{ + "name": "@stdlib/plot/vega/signal/reference", + "version": "0.0.0", + "description": "Signal reference constructor.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "plot", + "vega", + "signal", + "reference", + "expression", + "constructor", + "ctor" + ], + "__stdlib__": {} +}