Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuta Imaya committed May 31, 2017
2 parents b99bd33 + 3ab6657 commit 5132e07
Show file tree
Hide file tree
Showing 95 changed files with 10,095 additions and 2,461 deletions.
19 changes: 19 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"presets": [
[
"env",
{
"targets": {
"node": "current"
}
}
]
],
"env": {
"development": {
"presets": [
"power-assert"
]
}
}
}
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ before_script:
- sleep 5
- .travis/chrome-start.sh http://localhost:1111/capture &
- sleep 5
# - phantomjs node_modules/buster/script/phantom.js http://localhost:1111/capture &
# - sleep 5
- phantomjs node_modules/buster/script/phantom.js http://localhost:1111/capture &
- sleep 5

script:
- "npm test"
Expand Down
23 changes: 21 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,36 @@
# Change Log


## 0.3.0: 2017/06/01

https://github.com/imaya/zlib.js/compare/0.2.0...0.3.0

### decompression

- fix bug in decode HLIT and HDIST (aefd58bc482258faaf70644717ac54b7f6d4e599)
- check invalid code length from malicious compressed data (4971111c1ad49e3c353ed38d51850e1ff5c206b9)

### compression

- fix data exists after payload (08a5b2eb89e1d31178d272857fbdf55358bdcec4)

### etc

- Task runner: Migrate to Grunt from Ant
- Testing framework: Migate to Karma and mocha from BusterJS


## 0.1.9, 0.2.0: 2014/02/21

https://github.com/imaya/zlib.js/compare/0.1.8...0.2.0


## decompression
### decompression

- fix RLE bug HDIST between HLIT


## etc
### etc

- support buster.js 0.7.4
- code cleanup
Expand Down
148 changes: 148 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-closure-tools');
grunt.loadNpmTasks('grunt-contrib-concat');

var license = grunt.file.read('LICENSE_min');
var basefiles = [
'closure-primitives/base.js',
'define/typedarray/hybrid.js',
'src/*.js'
];
var config = grunt.file.readJSON("build.json");
var targets = Object.keys(config);

grunt.initConfig({
closureDepsWriter: {
options: {
depswriter: 'closure-primitives/depswriter.py',
root_with_prefix: ['"src ../src"']
},
deps: {
dest: 'closure-primitives/deps.js'
}
},
closureCompiler: mergeObject(
{
options: {
compilerFile: 'vendor/google-closure-compiler/compiler.jar',
checkModified: false,
compilerOpts: {
compilation_level: 'PERFORMANCE_OPTIMIZATIONS',
language_in: 'ECMASCRIPT5_STRICT',
source_map_format: "V3",
manage_closure_dependencies: true,
summary_detail_level: 3,
warning_level: 'VERBOSE',
jscomp_error: [
'accessControls',
'checkTypes',
'checkVars',
'const',
'constantProperty',
'duplicate',
'visibility'
],
output_wrapper:
'"' + license + '(function() {%output%}).call(this);"'
}
}
}, (function() {
var result = {};

targets.forEach(function(target) {
result[target] = createClosureCompilerSetting(target);
});

return result;
})()
),
'concat': mergeObject(
{
options: {
process: concatProcess
}
}, (function() {
var result = {};

targets.forEach(function(target) {
result[target] = createConcatSettings(target);
});

return result;
})()
)
});

// create compile settings
function createClosureCompilerSetting(target) {
return {
src: basefiles.concat(config[target].src),
dest: config[target].dest,
TEMPcompilerOpts: mergeObject(
{
create_source_map: config[target].map
},
config[target].compilerOpts || {}
)
}
}

// create concat settings
function createConcatSettings(target) {
return {
src: config[target].dest,
dest: config[target].dev
}
}

// concat sourcemaps
function concatProcess(src, filepath) {
var mapfile = filepath + ".map";

var result =
src + '//# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
new Buffer(updateSourceMaps(mapfile)).toString('base64');
grunt.file.delete(mapfile);

return result;
}

// update sourcemaps
function updateSourceMaps(path) {
var mapObject = grunt.file.readJSON(path);
var contents = [];

/*
// source data-url version
mapObject.sources.forEach(function(sourcePath, i) {
mapObject.sources[i] = 'data:text/plain;charset=utf-8;base64,' +
new Buffer(grunt.file.read(sourcePath, {encoding: null}).toString('base64'))
});
*/

// sourceContent version
mapObject.sources.forEach(function(sourcePath) {
contents.push(grunt.file.read(sourcePath, {encoding: null}).toString())
});

mapObject.sourcesContent = contents;

return JSON.stringify(mapObject);
}

// merge object
function mergeObject(dst, src) {
Object.keys(src).forEach(function(key) {
dst[key] = src[key];
});

return dst;
}

grunt.registerTask("default", targets);
grunt.registerTask("all", targets);
grunt.registerTask("deps", ["closureDepsWriter:deps"]);
targets.forEach(function(target) {
grunt.registerTask(target, ["closureCompiler:" + target, "concat:" + target]);
});
};
71 changes: 45 additions & 26 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,14 @@ see unit tests.
If you want to know the code before compile, SourceMaps and PrettyPrint can be used.


### SourceMaps
### Source Map

If you want to enable the SourceMaps if, you can use the `src` directory and *.min.js.map.
If you want to use the Source Map, use `dev` version.

- inflate.min.js
- inflate.min.js.map
- [src]
- (source files)
For example, you want to use Inflate with Source Map.

`[src]` is zlib.js source code directory.
- inflate.min.js // release version
- inflate.dev.min.js // development version <- use this


### Pretty Print
Expand All @@ -238,38 +236,59 @@ If you want to enable the SourceMaps if, you can use the `src` directory and *.m
How to build
------------

Build using Ant and Closure Compiler.
Build using Grunt and Closure Compiler.

### Requirement

- Ant 1.8+
- JRE 1.6+
- Grunt
- Python

### Build

Use "ant" command.
Use "grunt" command.

```
$ ant [target]
$ grunt [target]
```

#### Build target

target | generate file | implementation
---------------|----------------------|-------------
deps | deps.js | (dependency: deps.js)
deflate | deflate.min.js | ZLIB Deflate
inflate | inflate.min.js | ZLIB Inflate
inflate_stream | inlate_stream.min.js | ZLIB Inlate (stream)
zlib | zlib.min.js | ZLIB Deflate + Inflate
gzip | gzip.min.js | GZIP Compression
gunzip | gunzip.min.js | GZIP Decompression
zlib_and_gzip | zlib_and_gzip.min.js | ZLIB + GZIP
node | node-zlib.js | ZLIB + GZIP for node.js
zip | zip.min.js | PKZIP Compression
unzip | unzip.min.js | PKZIP Decompression
all | * | default target
target | generate file | implementation
---------------|-----------------------|-------------in
deps | deps.js | (dependency: deps.js)
deflate | deflate.min.js | ZLIB Deflate
inflate | inflate.min.js | ZLIB Inflate
inflate_stream | inflate_stream.min.js | ZLIB Inflate (stream)
zlib | zlib.min.js | ZLIB Deflate + Inflate
gzip | gzip.min.js | GZIP Compression
gunzip | gunzip.min.js | GZIP Decompression
zlib_and_gzip | zlib_and_gzip.min.js | ZLIB + GZIP
node | node-zlib.js | ZLIB + GZIP for node.js
zip | zip.min.js | PKZIP Compression
unzip | unzip.min.js | PKZIP Decompression
all | * | default target


Test
------

Unit tests are using Karma and mocha.

```
$ npm test
```

### Browser only

```
$ npm run test-karma
```

### Node.js only

```
$ npm run test-mocha
```


Issue
Expand Down
Loading

0 comments on commit 5132e07

Please sign in to comment.