Initial commit

This commit is contained in:
2021-08-26 21:47:42 +02:00
commit fe941c6433
1432 changed files with 161130 additions and 0 deletions

38
node_modules/jstransformer/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,38 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [1.0.0] - 2016-06-06
### Changed
- Browser support is fixed
- Marked as stable
## [0.0.4] - 2015-11-23
### Changed
- Switched to [Keep a Changelog](http://keepachangelog.com/) spec for CHANGELOG.md
- Creates an `options.filename` for `*File()` functions, if one is not provided
## [0.0.3] - 2015-07-13
### Added
- Added `.render()` fallbacks for `.compile()`
### Changed
- Prefers locals over options when passing a single argument to `.render()`
- Updated dependencies
## [0.0.2] - 2015-04-11
### Added
- Now have a logo
- Added tests
### Changed
- Updated documentation
## 0.0.1 - 2015-02-09
### Added
- Initial release
[1.0.0]: https://github.com/jstransformers/jstransformer/compare/0.0.4...1.0.0
[0.0.4]: https://github.com/jstransformers/jstransformer/compare/0.0.3...0.0.4
[0.0.3]: https://github.com/jstransformers/jstransformer/compare/0.0.2...0.0.3
[0.0.2]: https://github.com/jstransformers/jstransformer/compare/0.0.1...0.0.2

21
node_modules/jstransformer/LICENSE.md generated vendored Normal file
View File

@ -0,0 +1,21 @@
# The MIT License (MIT)
Copyright (c) 2015 Forbes Lindesay
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.

114
node_modules/jstransformer/README.md generated vendored Normal file
View File

@ -0,0 +1,114 @@
<p align="center"><img src="https://cdn.rawgit.com/jstransformers/jstransformer/2bb6dc6c410e8683a17a4af5f1b73bcbee95aada/logo.svg" width="300px" height="299px" /></p>
<h1 align="center">JSTransformer</h1>
<p align="center">Normalize the API of any jstransformer</p>
<p align="center"><a href="https://travis-ci.org/jstransformers/jstransformer"><img src="https://img.shields.io/travis/jstransformers/jstransformer/master.svg" alt="Build Status"></a>
<a href="https://david-dm.org/jstransformers/jstransformer"><img src="https://img.shields.io/david/jstransformers/jstransformer.svg" alt="Dependency Status"></a>
<a href="https://david-dm.org/jstransformers/jstransformer#info=devDependencies"><img src="https://img.shields.io/david/dev/jstransformers/jstransformer.svg" alt="Developers' Dependency Status"></a>
<a href="https://coveralls.io/r/jstransformers/jstransformer?branch=master"><img src="https://img.shields.io/coveralls/jstransformers/jstransformer/master.svg" alt="Coverage Status"></a>
<a href="https://www.npmjs.org/package/jstransformer"><img src="https://img.shields.io/npm/v/jstransformer.svg" alt="NPM version"></a></p>
## Installation
npm install jstransformer
## Usage
```js
var transformer = require('jstransformer');
var marked = transformer(require('jstransformer-marked'));
var options = {};
var res = marked.render('Some **markdown**', options);
// => {body: 'Some <strong>markdown</strong>', dependencies: []}
```
This gives the same API regardless of the jstransformer passed in.
## API
A transformer, once normalised using this module, will implement the following methods. Note that if the underlying transformer cannot be used to implement the functionality, it may ultimately just throw an error.
### Returned object from `.render*`
```js
{body: String, dependencies: Array.<String>}
```
- `body` represents the result as a string
- `dependencies` is an array of files that were read in as part of the render process (or an empty array if there were no dependencies)
### `.render`
```js
transformer.render(str, options, locals);
=> {body: String, dependencies: Array.<String>}
```
_requires the underlying transform to implement `.render` or `.compile`_
Transform a string and return an object.
### `.renderAsync`
```js
transformer.renderAsync(str[, options], locals, callback);
```
```js
transformer.renderAsync(str[, options], locals);
=> Promise({body: String, dependencies: Array.<String>})
```
_requires the underlying transform to implement `.renderAsync` or `.render`_
Transform a string asynchronously. If a callback is provided, it is called as `callback(err, data)`, otherwise a Promise is returned.
### `.renderFile`
```js
transformer.renderFile(filename, options, locals)
=> {body: String, dependencies: Array.<String>}
```
_requires the underlying transform to implement `.renderFile`, `.render`, `.compileFile`, or `.compile`_
Transform a file and return an object.
### `.renderFileAsync`
```js
transformer.renderFileAsync(filename[, options], locals, callback);
```
```js
transformer.renderFileAsync(filename[, options], locals);
=> Promise({body: String, dependencies: Array.<String>})
```
_requires the underlying transform to implement `.renderFileAsync`, `.renderFile`, `.renderAsync`, `.render`, `.compileFileAsync`, `.compileFile`, `.compileAsync`, or `.compileFile`_
Transform a file asynchronously. If a callback is provided, it is called as `callback(err, data)`, otherwise a Promise is returned.
### `.inputFormats`
```js
var formats = transformer.inputFormats;
=> ['md', 'markdown']
```
Returns an array of strings representing potential input formats for the transform. If not provided directly by the transform, results in an array containing the name of the transform.
### `.outputFormat`
```js
var md = require('jstransformer')(require('jstransformer-markdown'))
var outputFormat = md.outputFormat
=> 'html'
```
Returns a string representing the default output format the transform would be expected to return when calling `.render()`.
## License
MIT

359
node_modules/jstransformer/index.js generated vendored Normal file
View File

@ -0,0 +1,359 @@
'use strict';
var fs = require('fs');
var assert = require('assert');
var Promise = require('promise');
var isPromise = require('is-promise');
var tr = (module.exports = function (transformer) {
return new Transformer(transformer);
});
tr.Transformer = Transformer;
tr.normalizeFn = normalizeFn;
tr.normalizeFnAsync = normalizeFnAsync;
tr.normalize = normalize;
tr.normalizeAsync = normalizeAsync;
if (fs.readFile) {
tr.readFile = Promise.denodeify(fs.readFile);
tr.readFileSync = fs.readFileSync;
} else {
tr.readFile = function () { throw new Error('fs.readFile unsupported'); };
tr.readFileSync = function () { throw new Error('fs.readFileSync unsupported'); };
}
function normalizeFn(result) {
if (typeof result === 'function') {
return {fn: result, dependencies: []};
} else if (result && typeof result === 'object' && typeof result.fn === 'function') {
if ('dependencies' in result) {
if (!Array.isArray(result.dependencies)) {
throw new Error('Result should have a dependencies property that is an array');
}
} else {
result.dependencies = [];
}
return result;
} else {
throw new Error('Invalid result object from transform.');
}
}
function normalizeFnAsync(result, cb) {
return Promise.resolve(result).then(function (result) {
if (result && isPromise(result.fn)) {
return result.fn.then(function (fn) {
result.fn = fn;
return result;
});
}
return result;
}).then(tr.normalizeFn).nodeify(cb);
}
function normalize(result) {
if (typeof result === 'string') {
return {body: result, dependencies: []};
} else if (result && typeof result === 'object' && typeof result.body === 'string') {
if ('dependencies' in result) {
if (!Array.isArray(result.dependencies)) {
throw new Error('Result should have a dependencies property that is an array');
}
} else {
result.dependencies = [];
}
return result;
} else {
throw new Error('Invalid result object from transform.');
}
}
function normalizeAsync(result, cb) {
return Promise.resolve(result).then(function (result) {
if (result && isPromise(result.body)) {
return result.body.then(function (body) {
result.body = body;
return result;
});
}
return result;
}).then(tr.normalize).nodeify(cb);
}
function Transformer(tr) {
assert(tr, 'Transformer must be an object');
assert(typeof tr.name === 'string', 'Transformer must have a name');
assert(typeof tr.outputFormat === 'string', 'Transformer must have an output format');
assert([
'compile',
'compileAsync',
'compileFile',
'compileFileAsync',
'compileClient',
'compileClientAsync',
'compileFileClient',
'compileFileClientAsync',
'render',
'renderAsync',
'renderFile',
'renderFileAsync'
].some(function (method) {
return typeof tr[method] === 'function';
}), 'Transformer must implement at least one of the potential methods.');
this._tr = tr;
this.name = this._tr.name;
this.outputFormat = this._tr.outputFormat;
this.inputFormats = this._tr.inputFormats || [this.name];
}
var fallbacks = {
compile: ['compile', 'render'],
compileAsync: ['compileAsync', 'compile', 'render'],
compileFile: ['compileFile', 'compile', 'renderFile', 'render'],
compileFileAsync: [
'compileFileAsync', 'compileFile', 'compileAsync', 'compile',
'renderFile', 'render'
],
compileClient: ['compileClient'],
compileClientAsync: ['compileClientAsync', 'compileClient'],
compileFileClient: ['compileFileClient', 'compileClient'],
compileFileClientAsync: [
'compileFileClientAsync', 'compileFileClient', 'compileClientAsync', 'compileClient'
],
render: ['render', 'compile'],
renderAsync: ['renderAsync', 'render', 'compileAsync', 'compile'],
renderFile: ['renderFile', 'render', 'compileFile', 'compile'],
renderFileAsync: [
'renderFileAsync', 'renderFile', 'renderAsync', 'render',
'compileFileAsync', 'compileFile', 'compileAsync', 'compile'
]
};
Transformer.prototype._hasMethod = function (method) {
return typeof this._tr[method] === 'function';
};
Transformer.prototype.can = function (method) {
return fallbacks[method].some(function (method) {
return this._hasMethod(method);
}.bind(this));
};
/* COMPILE */
Transformer.prototype.compile = function (str, options) {
if (!this._hasMethod('compile')) {
if (this.can('render')) {
var _this = this;
return {
fn: function (locals) {
return tr.normalize(_this._tr.render(str, options, locals)).body;
},
dependencies: []
};
}
if (this.can('compileAsync')) {
throw new Error('The Transform "' + this.name + '" does not support synchronous compilation');
} else if (this.can('compileFileAsync')) {
throw new Error('The Transform "' + this.name + '" does not support compiling plain strings');
} else {
throw new Error('The Transform "' + this.name + '" does not support compilation');
}
}
return tr.normalizeFn(this._tr.compile(str, options));
};
Transformer.prototype.compileAsync = function (str, options, cb) {
if (!this.can('compileAsync')) { // compileFile* || renderFile* || renderAsync || compile*Client*
return Promise.reject(new Error('The Transform "' + this.name + '" does not support compiling plain strings')).nodeify(cb);
}
if (this._hasMethod('compileAsync')) {
return tr.normalizeFnAsync(this._tr.compileAsync(str, options), cb);
} else { // render || compile
return tr.normalizeFnAsync(this.compile(str, options), cb);
}
};
Transformer.prototype.compileFile = function (filename, options) {
if (!this.can('compileFile')) { // compile*Client* || compile*Async || render*Async
throw new Error('The Transform "' + this.name + '" does not support synchronous compilation');
}
if (this._hasMethod('compileFile')) {
return tr.normalizeFn(this._tr.compileFile(filename, options));
} else if (this._hasMethod('renderFile')) {
return tr.normalizeFn(function (locals) {
return tr.normalize(this._tr.renderFile(filename, options, locals)).body;
}.bind(this));
} else { // render || compile
if (!options) options = {};
if (options.filename === undefined) options.filename = filename;
return this.compile(tr.readFileSync(filename, 'utf8'), options);
}
};
Transformer.prototype.compileFileAsync = function (filename, options, cb) {
if (!this.can('compileFileAsync')) {
return Promise.reject(new Error('The Transform "' + this.name + '" does not support compilation'));
}
if (this._hasMethod('compileFileAsync')) {
return tr.normalizeFnAsync(this._tr.compileFileAsync(filename, options), cb);
} else if (this._hasMethod('compileFile') || this._hasMethod('renderFile')) {
return tr.normalizeFnAsync(this.compileFile(filename, options), cb);
} else { // compileAsync || compile || render
if (!options) options = {};
if (options.filename === undefined) options.filename = filename;
return tr.normalizeFnAsync(tr.readFile(filename, 'utf8').then(function (str) {
if (this._hasMethod('compileAsync')) {
return this._tr.compileAsync(str, options);
} else { // compile || render
return this.compile(str, options);
}
}.bind(this)), cb);
}
};
/* COMPILE CLIENT */
Transformer.prototype.compileClient = function (str, options) {
if (!this.can('compileClient')) {
if (this.can('compileClientAsync')) {
throw new Error('The Transform "' + this.name + '" does not support compiling for the client synchronously.');
} else if (this.can('compileFileClientAsync')) {
throw new Error('The Transform "' + this.name + '" does not support compiling for the client from a string.');
} else {
throw new Error('The Transform "' + this.name + '" does not support compiling for the client');
}
}
return tr.normalize(this._tr.compileClient(str, options));
};
Transformer.prototype.compileClientAsync = function (str, options, cb) {
if (!this.can('compileClientAsync')) {
if (this.can('compileFileClientAsync')) {
return Promise.reject(new Error('The Transform "' + this.name + '" does not support compiling for the client from a string.')).nodeify(cb);
} else {
return Promise.reject(new Error('The Transform "' + this.name + '" does not support compiling for the client')).nodeify(cb);
}
}
if (this._hasMethod('compileClientAsync')) {
return tr.normalizeAsync(this._tr.compileClientAsync(str, options), cb);
} else {
return tr.normalizeAsync(this._tr.compileClient(str, options), cb);
}
};
Transformer.prototype.compileFileClient = function (filename, options) {
if (!this.can('compileFileClient')) {
if (this.can('compileFileClientAsync')) {
throw new Error('The Transform "' + this.name + '" does not support compiling for the client synchronously.');
} else {
throw new Error('The Transform "' + this.name + '" does not support compiling for the client');
}
}
if (this._hasMethod('compileFileClient')) {
return tr.normalize(this._tr.compileFileClient(filename, options));
} else {
if (!options) options = {};
if (options.filename === undefined) options.filename = filename;
return tr.normalize(this._tr.compileClient(tr.readFileSync(filename, 'utf8'), options));
}
};
Transformer.prototype.compileFileClientAsync = function (filename, options, cb) {
if (!this.can('compileFileClientAsync')) {
return Promise.reject(new Error('The Transform "' + this.name + '" does not support compiling for the client')).nodeify(cb)
}
if (this._hasMethod('compileFileClientAsync')) {
return tr.normalizeAsync(this._tr.compileFileClientAsync(filename, options), cb);
} else if (this._hasMethod('compileFileClient')) {
return tr.normalizeAsync(this._tr.compileFileClient(filename, options), cb);
} else {
if (!options) options = {};
if (options.filename === undefined) options.filename = filename;
return tr.normalizeAsync(tr.readFile(filename, 'utf8').then(function (str) {
if (this._hasMethod('compileClientAsync')) {
return this._tr.compileClientAsync(str, options);
} else {
return this._tr.compileClient(str, options);
}
}.bind(this)), cb);
}
};
/* RENDER */
Transformer.prototype.render = function (str, options, locals) {
if (!this.can('render')) {
if (this.can('renderAsync')) {
throw new Error('The Transform "' + this.name + '" does not support rendering synchronously.');
} else if (this.can('renderFileAsync')) {
throw new Error('The Transform "' + this.name + '" does not support rendering from a string.');
} else {
throw new Error('The Transform "' + this.name + '" does not support rendering');
}
}
if (this._hasMethod('render')) {
return tr.normalize(this._tr.render(str, options, locals));
} else {
var compiled = tr.normalizeFn(this._tr.compile(str, options));
var body = compiled.fn(locals || options);
if (typeof body !== 'string') {
throw new Error('The Transform "' + this.name + '" does not support rendering synchronously.');
}
return tr.normalize({body: body, dependencies: compiled.dependencies});
}
};
Transformer.prototype.renderAsync = function (str, options, locals, cb) {
if (typeof locals === 'function') {
cb = locals;
locals = options;
}
if (!this.can('renderAsync')) {
if (this.can('renderFileAsync')) {
return Promise.reject(new Error('The Transform "' + this.name + '" does not support rendering from a string.')).nodeify(cb);
} else {
return Promise.reject(new Error('The Transform "' + this.name + '" does not support rendering')).nodeify(cb);
}
}
if (this._hasMethod('renderAsync')) {
return tr.normalizeAsync(this._tr.renderAsync(str, options, locals), cb);
} else if (this._hasMethod('render')) {
return tr.normalizeAsync(this._tr.render(str, options, locals), cb);
} else {
return tr.normalizeAsync(this.compileAsync(str, options).then(function (compiled) {
return {body: compiled.fn(locals || options), dependencies: compiled.dependencies};
}), cb);
}
};
Transformer.prototype.renderFile = function (filename, options, locals) {
if (!this.can('renderFile')) { // *Async, *Client
throw new Error('The Transform "' + this.name + '" does not support rendering synchronously.');
}
if (this._hasMethod('renderFile')) {
return tr.normalize(this._tr.renderFile(filename, options, locals));
} else if (this._hasMethod('render')) {
if (!options) options = {};
if (options.filename === undefined) options.filename = filename;
return tr.normalize(this._tr.render(tr.readFileSync(filename, 'utf8'), options, locals));
} else { // compile || compileFile
var compiled = this.compileFile(filename, options);
return tr.normalize({body: compiled.fn(locals || options), dependencies: compiled.dependencies});
}
};
Transformer.prototype.renderFileAsync = function (filename, options, locals, cb) {
if (!this.can('renderFileAsync')) { // *Client
throw new Error('The Transform "' + this.name + '" does not support rendering.');
}
if (typeof locals === 'function') {
cb = locals;
locals = options;
}
if (this._hasMethod('renderFileAsync')) {
return tr.normalizeAsync(this._tr.renderFileAsync(filename, options, locals), cb);
} else if (this._hasMethod('renderFile')) {
return tr.normalizeAsync(this._tr.renderFile(filename, options, locals), cb);
} else if (this._hasMethod('compile') || this._hasMethod('compileAsync')
|| this._hasMethod('compileFile') || this._hasMethod('compileFileAsync')) {
return tr.normalizeAsync(this.compileFileAsync(filename, options).then(function (compiled) {
return {body: compiled.fn(locals || options), dependencies: compiled.dependencies};
}), cb);
} else { // render || renderAsync
if (!options) options = {};
if (options.filename === undefined) options.filename = filename;
return tr.normalizeAsync(tr.readFile(filename, 'utf8').then(function (str) {
return this.renderAsync(str, options, locals);
}.bind(this)), cb);
}
};

31
node_modules/jstransformer/package.json generated vendored Normal file
View File

@ -0,0 +1,31 @@
{
"name": "jstransformer",
"version": "1.0.0",
"description": "Normalize the API of any jstransformer",
"keywords": [
"jstransformer"
],
"dependencies": {
"is-promise": "^2.0.0",
"promise": "^7.0.1"
},
"devDependencies": {
"coveralls": "^2.11.2",
"istanbul": "^0.4.0",
"testit": "^2.0.2"
},
"scripts": {
"test": "node test",
"coverage": "istanbul cover test",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls"
},
"files": [
"index.js"
],
"repository": {
"type": "git",
"url": "https://github.com/jstransformers/jstransformer.git"
},
"author": "ForbesLindesay",
"license": "MIT"
}