diff --git a/lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/index.js b/lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/index.js new file mode 100644 index 000000000000..04339e7bf679 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/index.js @@ -0,0 +1,60 @@ +/** +* @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'; + +/** +* Render a Vega specification to an SVG file. +* +* @module @stdlib/plot/vega/base/spec2svg-file +* +* @example +* var join = require( 'path' ).join; +* var tmpdir = require( '@stdlib/os/tmpdir' ); +* var spec2svgFile = require( '@stdlib/plot/vega/base/spec2svg-file' ); +* +* var fpath = join( tmpdir(), 'output.svg' ); +* +* var spec = { +* '$schema': 'https://vega.github.io/schema/vega/v6.json', +* 'width': 400, +* 'height': 30, +* 'padding': 5, +* 'title': { +* 'text': 'Hello World' +* }, +* 'marks': [] +* }; +* +* function done( error ) { +* if ( error ) { +* throw error; +* } +* } +* +* spec2svgFile( fpath, spec, done ); +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/main.js b/lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/main.js new file mode 100644 index 000000000000..16c5ceb7b6af --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/lib/main.js @@ -0,0 +1,88 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var writeFile = require( '@stdlib/fs/write-file' ); +var spec2svg = require( '@stdlib/plot/vega/base/spec2svg' ); + + +// MAIN // + +/** +* Renders a Vega specification to an SVG file. +* +* @param {string} outputPath - file path for the SVG output +* @param {Object} spec - Vega specification +* @param {Callback} clbk - callback to invoke upon completion +* +* @example +* var join = require( 'path' ).join; +* var tmpdir = require( '@stdlib/os/tmpdir' ); +* var spec2svgFile = require( '@stdlib/plot/vega/base/spec2svg-file' ); +* +* var fpath = join( tmpdir(), 'output.svg' ); +* +* var spec = { +* '$schema': 'https://vega.github.io/schema/vega/v6.json', +* 'width': 400, +* 'height': 30, +* 'padding': 5, +* 'title': { +* 'text': 'Hello World' +* }, +* 'marks': [] +* }; +* +* function done( error ) { +* if ( error ) { +* throw error; +* } +* } +* +* spec2svgFile( fpath, spec, done ); +*/ +function spec2svgFile( outputPath, spec, clbk ) { + var fpath; + + fpath = resolve( outputPath ); + spec2svg( spec, onSVG ); + + /** + * Callback invoked upon rendering an SVG. + * + * @private + * @param {(Error|null)} error - error object + * @param {string} svg - rendered SVG string + * @returns {void} + */ + function onSVG( error, svg ) { + if ( error ) { + return clbk( error ); + } + writeFile( fpath, svg, clbk ); + } +} + + +// EXPORTS // + +module.exports = spec2svgFile; diff --git a/lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/package.json b/lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/package.json new file mode 100644 index 000000000000..31db4439a739 --- /dev/null +++ b/lib/node_modules/@stdlib/plot/vega/base/spec2svg-file/package.json @@ -0,0 +1,56 @@ +{ + "name": "@stdlib/plot/vega/base/spec2svg-file", + "version": "0.0.0", + "description": "Render a Vega specification to an SVG file.", + "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": { + "lib": "./lib" + }, + "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", + "render", + "svg", + "figure", + "visualization", + "dataviz" + ] +}