Comparing version 0.14.0 to 0.14.1
@@ -0,1 +1,6 @@ | ||
### v0.14.1 (2023-12-17) | ||
- [Fix application of the hide marker in the README by evaldown.](https://github.com/papandreou/impro/commit/851218765352c4652dd383ed1aa8f482a2b826bc) ([Alex J Burke](mailto:alex@alexjeffburke.com)) | ||
- [Ensure engine options can be configured at the level of the Pipeline.](https://github.com/papandreou/impro/commit/c0aa66d0cddff0ec5f55b1db401c55148f4ed436) ([Alex J Burke](mailto:alex@alexjeffburke.com)) | ||
### v0.14.0 (2023-12-15) | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "impro", | ||
"version": "0.14.0", | ||
"version": "0.14.1", | ||
"description": "Image processing engine", | ||
@@ -21,3 +21,3 @@ "author": "Andreas Lind <andreaslindpetersen@gmail.com>", | ||
"coverage": "nyc --reporter=lcov --reporter=text -- npm test && echo Coverage Report written to coverage/lcov-report/index.html", | ||
"docs": "evaldown --inplace README.md", | ||
"docs": "evaldown docs/README.md > README.md", | ||
"test": "mocha", | ||
@@ -24,0 +24,0 @@ "lint": "eslint . && prettier --check '**/*.{js,json,md}'", |
@@ -15,23 +15,2 @@ # Impro | ||
<!-- evaldown hide:true,console:true --> | ||
```js | ||
const pkg = require('./package.json'); | ||
const engineLibs = Object.keys(require('./src/engines')).filter( | ||
(name) => name !== 'metadata' | ||
); | ||
const engineNameToDepName = { | ||
gm: 'gm-papandreou', | ||
}; | ||
for (const engineLib of engineLibs) { | ||
const depName = engineNameToDepName[engineLib] || engineLib; | ||
let depVersion = pkg.devDependencies[depName]; | ||
if (!/^[~^]/.test(depVersion)) depVersion = `^${depVersion}`; | ||
console.log(`- ${engineLib} (npm install ${depName}@${depVersion})`); | ||
} | ||
``` | ||
<!-- evaldown output:true --> | ||
@@ -169,1 +148,2 @@ | ||
Impro is licensed under a standard 3-clause BSD license. | ||
@@ -6,2 +6,10 @@ const Stream = require('stream'); | ||
function mapValues(obj, valueFn) { | ||
const target = { ...obj }; | ||
for (const [key, value] of Object.entries(obj)) { | ||
target[key] = valueFn(value); | ||
} | ||
return target; | ||
} | ||
module.exports = class Pipeline extends Stream.Duplex { | ||
@@ -19,6 +27,12 @@ constructor(impro, options) { | ||
this.impro = impro; | ||
this.isDisabledByEngineName = {}; | ||
this.options = {}; | ||
this.optionsByEngineName = {}; | ||
this.usedEngines = []; | ||
Object.defineProperty(this, 'isDisabledByEngineName', { | ||
get: () => { | ||
return mapValues(this.optionsByEngineName, ({ disabled }) => disabled); | ||
}, | ||
}); | ||
options = options || {}; | ||
@@ -35,9 +49,23 @@ const { type, engines, supportedOptions, sourceMetadata } = options; | ||
Object.keys(this.impro.engineByName).forEach((engineName) => { | ||
let isDisabled; | ||
if (typeof engineOptions[engineName] !== 'boolean') { | ||
isDisabled = false; | ||
const isAvailable = !impro.engineByName[engineName].unavailable; | ||
let isEnabled; | ||
let perEngineOptions; | ||
if (typeof engineOptions[engineName] === 'boolean') { | ||
isEnabled = engineOptions[engineName]; | ||
perEngineOptions = null; | ||
} else if (!engineOptions[engineName]) { | ||
isEnabled = true; | ||
perEngineOptions = null; | ||
} else { | ||
isDisabled = !engineOptions[engineName]; | ||
isEnabled = true; | ||
perEngineOptions = engineOptions[engineName]; | ||
} | ||
this.isDisabledByEngineName[engineName] = isDisabled; | ||
const disabled = !(isEnabled && isAvailable); | ||
this.optionsByEngineName[engineName] = Object.assign( | ||
{ disabled }, | ||
perEngineOptions | ||
); | ||
}); | ||
@@ -93,3 +121,4 @@ | ||
const engineName = candidateEngineNames[0]; | ||
let options; | ||
const options = this.optionsByEngineName[engineName]; | ||
if (this._queuedOperations[startIndex].name === engineName) { | ||
@@ -99,3 +128,4 @@ if (this._queuedOperations[startIndex].args.length > 1) { | ||
} | ||
options = this._queuedOperations[startIndex].args[0]; | ||
const engineArgument = this._queuedOperations[startIndex].args[0]; | ||
Object.assign(options, engineArgument); | ||
startIndex += 1; | ||
@@ -136,3 +166,3 @@ } | ||
const isEnabled = operation.args[0]; | ||
this.isDisabledByEngineName[operation.name] = !isEnabled; | ||
this.optionsByEngineName[operation.name].disabled = !isEnabled; | ||
if (i === 0) { | ||
@@ -275,4 +305,3 @@ startIndex += 1; | ||
return ( | ||
!this.isDisabledByEngineName[engineName] && | ||
!impro.engineByName[engineName].unavailable && | ||
!this.optionsByEngineName[engineName].disabled && | ||
(engineName === operationName || | ||
@@ -279,0 +308,0 @@ isSupportedByType['*'] || |
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
96857
2109
148