Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

242
static/js/ketcher2/node_modules/gulp-hb/README.md generated vendored Normal file
View File

@ -0,0 +1,242 @@
# `gulp-hb`
[![NPM version][npm-img]][npm-url] [![Downloads][downloads-img]][npm-url] [![Build Status][travis-img]][travis-url] [![Coverage Status][coveralls-img]][coveralls-url] [![Chat][gitter-img]][gitter-url] [![Tip][amazon-img]][amazon-url]
A sane static [Handlebars][handlebars] Gulp plugin. Useful as a static site generator. Think [Assemble][assemble], but with a lot less [Jekyll][jekyll] baggage.
For Grunt, see [`grunt-hb`][grunt-hb]. To precompile templates into JavaScript, see [`gulp-handlebars`][gulp-handlebars].
## Install
$ npm install --save-dev gulp-hb
## Usage
```js
var gulp = require('gulp');
var hb = require('gulp-hb');
// Basic
gulp.task('basic', function () {
return gulp
.src('./src/{,posts/}*.html')
.pipe(hb({
partials: './src/assets/partials/**/*.hbs',
helpers: './src/assets/helpers/*.js',
data: './src/assets/data/**/*.{js,json}'
}))
.pipe(gulp.dest('./web'));
});
// Advanced
gulp.task('advanced', function () {
var hbStream = hb()
// Partials
.partials('./partials/components/**/*.{hbs,js}')
.partials('./partials/layouts/**/*.{hbs,js}')
.partials({
boo: '{{#each boo}}{{greet}}{{/each}}',
far: '{{#each far}}{{length}}{{/each}}'
})
// Helpers
.helpers(require('handlebars-layouts'))
.helpers('./helpers/**/*.js')
.helpers({
foo: function () { ... },
bar: function () { ... }
})
// Decorators
.decorators('./decorators/**/*.js')
.decorators({
baz: function () { ... },
qux: function () { ... }
})
// Data
.data('./data/**/*.{js,json}')
.data({
lorem: 'dolor',
ipsum: 'sit amet'
});
return gulp
.src('./src/{,posts/}*.html')
.pipe(hbStream)
.pipe(gulp.dest('./web'));
});
```
### Template Context
The template context is constructed from pre-registered data and file-specific data. Pre-registered data is used as the root context for all templates and is set using the `.data()` method. File-specific data is used as the template context and is set via the [`file.data`](#file-specific-data-sources) property.
#### `@` Data Variables
##### @root
In cases where file-specific data keys collide with pre-registered data keys, you may access the pre-registered data via `@root`:
```handlebars
{{ foo }}
{{ @root.foo }}
```
##### @file
In cases where information about the template file itself is needed, you may access the [file object][file] via `@file`:
```handlebars
{{ @file.path }}
```
#### File-specific Data Sources
File-specific data is set via the `file.data` property using other plugins such as [`gulp-data`][gulp-data], [`gulp-data-json`][gulp-data-json], or [`gulp-front-matter`][gulp-front-matter].
```js
var gulp = require('gulp');
var data = require('gulp-data');
var frontMatter = require('gulp-front-matter');
var hb = require('gulp-hb');
gulp.task('inject', function () {
return gulp
.src('./src/*.html')
// Load an associated JSON file per post.
.pipe(data(function(file) {
return require(file.path.replace('.html', '.json'));
}))
// Parse front matter from post file.
.pipe(frontMatter({
property: 'data.frontMatter'
}))
// Data for everyone.
.pipe(hb().data('./data/**/*.js'))
.pipe(gulp.dest('./web'));
```
#### Multiple Data Sources
Multiple data sources can be used to render the same set of templates to different directories using [`through2`][through2].
```js
var gulp = require('gulp');
var hb = require('gulp-hb');
var through = require('through2');
gulp.task('i18n', function () {
return gulp
.src('./i18n/*.json')
.pipe(through.obj(function (file, enc, cb) {
var locale = file.stem;
var data = {
locale: locale,
i18n: JSON.parse(file.contents.toString())
};
gulp
.src('./templates/**/*.html')
.pipe(hb().data(data))
.pipe(gulp.dest('./dist/' + locale))
.on('error', cb)
.on('end', cb);
}));
});
```
## API
### `hb([options]): TransformStream`
- `options` `{Object}` (optional) Passed directly to [`handlebars-wax`][wax] so check there for more options.
- `bustCache` `{Boolean}` (default: `true`) Force reload data, partials, helpers, and decorators.
- `cwd` `{String}` (default: `process.cwd()`) Current working directory.
- `debug` `{Number}` (default: `0`) Whether to log registered functions and data (level `1`) and glob parsing (level `2`).
- `handlebars` `{Handlebars}` (optional) A specific instance of Handlebars, if needed.
- `compileOptions` `{Object}` Options to use when compiling templates.
- `templateOptions` `{Object}` Options to use when rendering templates.
- `partials` `{String|Array.<String>|Object|Function(handlebars)}`
- `parsePartialName` `{Function(options, file): String}`
- `helpers` `{String|Array.<String>|Object|Function(handlebars)}`
- `parseHelperName` `{Function(options, file): String}`
- `decorators` `{String|Array.<String>|Object|Function(handlebars)}`
- `parseDecoratorName` `{Function(options, file): String}`
- `data` `{String|Array.<String>|Object}`
- `parseDataName` `{Function(options, file): String}`
Returns a Gulp-compatible transform stream that compiles [Handlebars][handlebars] templates to static output.
### .partials(pattern [, options]): TransformStream
- `pattern` `{String|Array<String>|Object|Function(handlebars)}`
- `options` `{Object}` Same options as `hb()`.
Loads additional partials. See [`handlebars-wax`][wax].
### .helpers(pattern [, options]): TransformStream
- `pattern` `{String|Array<String>|Object|Function(handlebars)}`
- `options` `{Object}` Same options as `hb()`.
Loads additional helpers. See [`handlebars-wax`][wax].
### .decorators(pattern [, options]): TransformStream
- `pattern` `{String|Array<String>|Object|Function(handlebars)}`
- `options` `{Object}` Same options as `hb()`.
Loads additional decorators. See [`handlebars-wax`][wax].
### .data(pattern [, options]): TransformStream
- `pattern` `{String|Array<String>|Object}`
- `options` `{Object}` Same options as `hb()`.
Loads additional data. See [`handlebars-wax`][wax].
## Contribute
Standards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors.
### Test
$ npm test
----
© Shannon Moeller <me@shannonmoeller.com> (shannonmoeller.com)
Licensed under [MIT](http://shannonmoeller.com/mit.txt)
[assemble]: http://assemble.io/
[context]: https://github.com/shannonmoeller/handlebars-wax#context-and-rendering
[file]: https://github.com/gulpjs/vinyl#file
[grunt-hb]: https://github.com/shannonmoeller/grunt-hb#usage
[gulp-data]: https://github.com/colynb/gulp-data#usage
[gulp-data-json]: https://github.com/kflorence/gulp-data-json#example
[gulp-front-matter]: https://github.com/lmtm/gulp-front-matter#usage
[gulp-handlebars]: https://github.com/lazd/gulp-handlebars#usage
[handlebars]: https://github.com/wycats/handlebars.js#usage
[jekyll]: https://jekyllrb.com/
[through2]: https://github.com/rvagg/through2#api
[wax]: https://github.com/shannonmoeller/handlebars-wax#usage
[amazon-img]: https://img.shields.io/badge/amazon-tip_jar-yellow.svg?style=flat-square
[amazon-url]: https://www.amazon.com/gp/registry/wishlist/1VQM9ID04YPC5?sort=universal-price
[coveralls-img]: http://img.shields.io/coveralls/shannonmoeller/gulp-hb/master.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/shannonmoeller/gulp-hb
[downloads-img]: http://img.shields.io/npm/dm/gulp-hb.svg?style=flat-square
[gitter-img]: http://img.shields.io/badge/gitter-join_chat-1dce73.svg?style=flat-square
[gitter-url]: https://gitter.im/shannonmoeller/shannonmoeller
[npm-img]: http://img.shields.io/npm/v/gulp-hb.svg?style=flat-square
[npm-url]: https://npmjs.org/package/gulp-hb
[travis-img]: http://img.shields.io/travis/shannonmoeller/gulp-hb.svg?style=flat-square
[travis-url]: https://travis-ci.org/shannonmoeller/gulp-hb

89
static/js/ketcher2/node_modules/gulp-hb/package.json generated vendored Normal file
View File

@ -0,0 +1,89 @@
{
"_from": "gulp-hb@5.1.4",
"_id": "gulp-hb@5.1.4",
"_inBundle": false,
"_integrity": "sha1-hvR6Yp0Qsh3jO4s8VvnYUYPLNag=",
"_location": "/gulp-hb",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "gulp-hb@5.1.4",
"name": "gulp-hb",
"escapedName": "gulp-hb",
"rawSpec": "5.1.4",
"saveSpec": null,
"fetchSpec": "5.1.4"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/gulp-hb/-/gulp-hb-5.1.4.tgz",
"_shasum": "86f47a629d10b21de33b8b3c56f9d85183cb35a8",
"_spec": "gulp-hb@5.1.4",
"_where": "/home/manfred/enviPath/ketcher2/ketcher",
"author": {
"name": "Shannon Moeller",
"email": "me@shannonmoeller.com",
"url": "http://shannonmoeller.com"
},
"bugs": {
"url": "https://github.com/shannonmoeller/gulp-hb/issues"
},
"bundleDependencies": false,
"dependencies": {
"cli-columns": "^1.0.6",
"gulp-util": "^3.0.7",
"handlebars": "^4.0.5",
"handlebars-wax": "^4.0.4",
"object-assign": "^4.1.0",
"through2": "^2.0.1"
},
"deprecated": false,
"description": "A sane Handlebars Gulp plugin.",
"devDependencies": {
"ava": "^0.16.0",
"chokidar-cli": "^1.2.0",
"coveralls": "^2.11.14",
"nyc": "^8.3.0",
"vinyl-fs": "^2.4.3",
"xo": "^0.16.0"
},
"engines": {
"node": ">= 0.12"
},
"homepage": "https://github.com/shannonmoeller/gulp-hb",
"keywords": [
"gulpplugin",
"gulp",
"handlebars",
"hb",
"hbs",
"hbt",
"compile",
"render",
"static",
"data",
"partial",
"partials",
"helper",
"helpers",
"decorator",
"decorators"
],
"license": "MIT",
"main": "src/gulp-hb.js",
"name": "gulp-hb",
"repository": {
"type": "git",
"url": "git+https://github.com/shannonmoeller/gulp-hb.git"
},
"scripts": {
"coveralls": "nyc report -r text-lcov | coveralls",
"posttest": "nyc report -r lcov",
"pretest": "xo",
"test": "nyc ava -v",
"watch": "chokidar '{src,test}/**/*.js' -c 'npm test'"
},
"version": "5.1.4"
}

138
static/js/ketcher2/node_modules/gulp-hb/src/gulp-hb.js generated vendored Normal file
View File

@ -0,0 +1,138 @@
'use strict';
var assign = require('object-assign');
var columns = require('cli-columns');
var gutil = require('gulp-util');
var handlebars = require('handlebars');
var handlebarsWax = require('handlebars-wax');
var through = require('through2');
function logKeys(file, pairs) {
var buf = [];
var options = {
width: process.stdout.columns - 12
};
pairs.forEach(function (pair) {
var key = pair[0];
var value = pair[1] || '';
if (typeof value !== 'string') {
value = columns(Object.keys(value), options);
}
buf.push(gutil.colors.grey(' ' + key + ':'));
buf.push(value.replace(/^/gm, ' '));
});
console.log(' ' + gutil.colors.green(file.relative));
console.log(buf.join('\n'));
console.log();
}
function gulpHb(options) {
var defaults = {
debug: 0
};
options = assign(defaults, options);
var debug = Number(options.debug) || 0;
// set { debug: 1 } to output gulp-hb info
// set { debug: 2 } to output node-glob info
options.debug = debug >= 2;
// Handlebars
var hb = options.handlebars || gulpHb.handlebars.create();
var wax = handlebarsWax(hb, options);
if (options.partials) {
wax.partials(options.partials);
}
if (options.helpers) {
wax.helpers(options.helpers);
}
if (options.decorators) {
wax.decorators(options.decorators);
}
if (options.data) {
wax.data(options.data);
}
// Stream
var stream = through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new gutil.PluginError('gulp-hb', 'Streaming not supported.'));
return;
}
try {
var data = assign({}, file.data);
var template = wax.compile(file.contents.toString());
if (debug) {
logKeys(file, [
['context', wax.context],
['data', data],
['decorators', hb.decorators],
['helpers', hb.helpers],
['partials', hb.partials]
]);
}
file.contents = new Buffer(template(data, {
data: {
file: file
}
}));
this.push(file);
} catch (err) {
this.emit('error', new gutil.PluginError('gulp-hb', err, {
file: file,
fileName: file.path,
showStack: true
}));
}
cb();
});
// Proxy
stream.partials = function () {
wax.partials.apply(wax, arguments);
return stream;
};
stream.helpers = function () {
wax.helpers.apply(wax, arguments);
return stream;
};
stream.decorators = function () {
wax.decorators.apply(wax, arguments);
return stream;
};
stream.data = function () {
wax.data.apply(wax, arguments);
return stream;
};
return stream;
}
module.exports = gulpHb;
module.exports.handlebars = handlebars;

266
static/js/ketcher2/node_modules/gulp-hb/test/gulp-hb.js generated vendored Normal file
View File

@ -0,0 +1,266 @@
import path from 'path';
import {Stream} from 'stream';
import gutil from 'gulp-util';
import test from 'ava';
import gulpHb from '../src/gulp-hb';
test.cb('should not render null', t => {
const stream = gulpHb();
stream.on('data', file => {
t.is(file.contents, null);
t.end();
});
stream.write(new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: null
}));
});
test.cb('should not render a stream', t => {
const stream = gulpHb();
stream.on('error', error => {
t.is(error.message, 'Streaming not supported.');
t.end();
});
stream.write(new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: new Stream()
}));
});
test.cb('should not render an invalid template', t => {
const stream = gulpHb();
stream.on('error', error => {
t.is(error.message.slice(0, 11), 'Parse error');
t.end();
});
stream.write(new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: new Buffer('{{>>> derp <<<}}')
}));
});
test.cb('should render a template', t => {
const stream = gulpHb();
stream.on('data', file => {
t.is(file.contents.toString(), 'hello');
t.end();
});
stream.write(new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: new Buffer('hello')
}));
});
test.cb('should render a template with file', t => {
const stream = gulpHb();
stream.on('data', file => {
t.is(file.contents.toString(), 'hello fixture/fixture.html');
t.end();
});
stream.write(new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.html'),
contents: new Buffer('hello {{@file.relative}}')
}));
});
test.cb('should use file data', t => {
const stream = gulpHb();
stream.on('data', file => {
t.is(file.contents.toString(), 'bar');
t.end();
});
var file = new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: new Buffer('{{foo}}')
});
file.data = {
foo: 'bar'
};
stream.write(file);
});
test.cb('should use registered data', t => {
const stream = gulpHb({
data: {
foo: 'fooA'
}
});
stream.data({
bar: 'barA'
});
stream.on('data', file => {
t.is(file.contents.toString(), 'fooA barA');
t.end();
});
stream.write(new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: new Buffer('{{foo}} {{bar}}')
}));
});
test.cb('should use registered partial', t => {
const stream = gulpHb({
partials: {
foo: '<div>foo</div>'
}
});
stream.partials({
bar: '<div>bar</div>'
});
stream.on('data', file => {
t.is(file.contents.toString(), '<div>foo</div> <div>bar</div>');
t.end();
});
stream.write(new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: new Buffer('{{> foo}} {{> bar}}')
}));
});
test.cb('should use registered helper', t => {
const stream = gulpHb({
helpers: {
foo: function (text) {
return 'foo' + text;
}
}
});
stream.helpers({
bar: function (text) {
return 'bar' + text;
}
});
stream.on('data', file => {
t.is(file.contents.toString(), 'fooA barB');
t.end();
});
stream.write(new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: new Buffer('{{foo "A"}} {{bar "B"}}')
}));
});
test.cb('should use registered decorator', t => {
const stream = gulpHb({
decorators: {
foo: function (program) {
return function (context, options) {
context.fooA = 'fooB';
return program(context, options);
};
}
}
});
stream.decorators({
bar: function (program) {
return function (context, options) {
context.barA = 'barB';
return program(context, options);
};
}
});
stream.on('data', file => {
t.is(file.contents.toString(), 'fooB barB');
t.end();
});
stream.write(new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'fixture.js'),
contents: new Buffer('{{* foo}}{{* bar}}{{fooA}} {{barA}}')
}));
});
test.cb('should display debug info', t => {
t.plan(3);
const stream = gulpHb({
debug: true,
partials: {
foo: function () {}
},
helpers: {
bar: function () {}
},
decorators: {
baz: function () {}
},
data: {
greeting: 'hello',
recipient: 'world'
}
});
stream.on('data', file => {
t.is(file.contents.toString(), 'howdy world');
});
var fileA = new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'a.js'),
contents: new Buffer('{{greeting}} {{recipient}}')
});
fileA.data = {
greeting: 'howdy',
a: 'lorem'
};
var fileB = new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'b.js'),
contents: new Buffer('{{greeting}} {{recipient}}')
});
fileB.data = {
greeting: 'howdy',
b: 'ipsum'
};
var fileC = new gutil.File({
base: __dirname,
path: path.join(__dirname, 'fixture', 'c.js'),
contents: new Buffer('howdy world')
});
stream.write(fileA);
stream.write(fileB);
stream.write(fileC);
setImmediate(t.end);
});