Skip to content

Commit dbfbcda

Browse files
committed
initial
1 parent 4b105ac commit dbfbcda

26 files changed

Lines changed: 2919 additions & 1 deletion

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build
2+
doc
3+
dist
4+
node_modules
5+
test/output
6+
7+
texen-scripts.d.ts
8+
9+
.idea/

.npmignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
build
2+
doc
3+
gulp_tasks
4+
node_modules
5+
src
6+
test
7+
typings
8+
9+
.npmignore
10+
gulpfile.js
11+
texen-scripts.d.ts
12+
tsd.json
13+
14+
.idea/

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
# texen-scripts
1+
# texen-scripts
2+
3+
## Development
4+
5+
```
6+
npm i
7+
gulp
8+
```

gulp_tasks/browserify.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var browserify = require('browserify');
2+
var source = require('vinyl-source-stream');
3+
var buffer = require('vinyl-buffer');
4+
5+
module.exports = function (gulp, plugins) {
6+
return function () {
7+
var b = browserify({
8+
entries: 'build/texen-scripts.js',
9+
debug: false,
10+
standalone: 'txScripts'
11+
});
12+
13+
return b.bundle()
14+
.pipe(source('build/texen-scripts.js'))
15+
.pipe(plugins.rename('texen-scripts.js'))
16+
.pipe(gulp.dest('dist'))
17+
.pipe(plugins.rename('texen-scripts.min.js'))
18+
.pipe(buffer())
19+
.pipe(plugins.sourcemaps.init({loadMaps: true}))
20+
.pipe(plugins.uglify())
21+
.on('error', plugins.util.log)
22+
.pipe(plugins.sourcemaps.write('./'))
23+
.pipe(gulp.dest('dist'));
24+
};
25+
};

gulp_tasks/lib/server.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var path = require('path');
2+
var mkdirp = require('mkdirp');
3+
var fs = require('fs');
4+
var PNG = require('pngjs').PNG;
5+
6+
module.exports = function (file, mod) {
7+
var TexEn = require('../../dist/texen-scripts');
8+
var formula = require('../../node_modules/texen-samples').data[0];
9+
var wrap = new TexEn.Wrap(mod);
10+
var options = new TexEn.Options();
11+
options.width = 512;
12+
options.height = 512;
13+
wrap.run(JSON.stringify(formula), options);
14+
var png = new PNG({
15+
width: options.width,
16+
height: options.height,
17+
filterType: -1
18+
});
19+
TexEn.Canvas.draw(png.data, wrap);
20+
mkdirp.sync(path.dirname(file));
21+
png.pack().pipe(fs.createWriteStream(file));
22+
23+
return wrap.log();
24+
};

gulp_tasks/server-light.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var server = require('./lib/server');
2+
3+
module.exports = function (gulp, plugins) {
4+
return function (done) {
5+
var path = './test/output/server.png';
6+
var mod = require('../node_modules/texen-core/dist/texen-core-light');
7+
plugins.util.log(server(path, mod));
8+
done();
9+
};
10+
};

gulp_tasks/server-stats.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var server = require('./lib/server');
2+
3+
module.exports = function (gulp, plugins) {
4+
return function (done) {
5+
var path = './test/output/server-stats.png';
6+
var mod = require('../node_modules/texen-core/dist/texen-core-stats');
7+
plugins.util.log(server(path, mod));
8+
done();
9+
};
10+
};

gulp_tasks/tslint.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = function (gulp, plugins) {
2+
return function () {
3+
return gulp.src('scripts/*.ts')
4+
.pipe(plugins.tslint())
5+
.pipe(plugins.tslint.report('verbose'));
6+
};
7+
};

gulp_tasks/typedoc.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = function (gulp, plugins) {
2+
return function () {
3+
return gulp
4+
.src('src/*.ts')
5+
.pipe(plugins.typedoc({
6+
module: 'commonjs',
7+
out: 'doc',
8+
mode: 'file',
9+
name: 'txScripts'
10+
}));
11+
};
12+
};

gulp_tasks/typescript.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var merge = require('merge2');
2+
3+
module.exports = function (gulp, plugins) {
4+
return function () {
5+
var result = gulp.src('src/*.ts')
6+
.pipe(plugins.typescript({
7+
module: 'commonjs',
8+
target: 'ES5',
9+
noImplicitAny: true,
10+
declarationFiles: true,
11+
out: 'texen-scripts.js'
12+
}));
13+
14+
return merge([
15+
result.js.pipe(gulp.dest('build')),
16+
result.dts.pipe(gulp.dest('.'))
17+
]);
18+
};
19+
};

0 commit comments

Comments
 (0)