Skip to content

Commit 5132e07

Browse files
author
Yuta Imaya
committed
Merge branch 'release/0.3.0'
2 parents b99bd33 + 3ab6657 commit 5132e07

File tree

95 files changed

+10095
-2461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+10095
-2461
lines changed

‎.babelrc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"targets": {
7+
"node": "current"
8+
}
9+
}
10+
]
11+
],
12+
"env": {
13+
"development": {
14+
"presets": [
15+
"power-assert"
16+
]
17+
}
18+
}
19+
}

‎.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ before_script:
1111
- sleep 5
1212
- .travis/chrome-start.sh http://localhost:1111/capture &
1313
- sleep 5
14-
# - phantomjs node_modules/buster/script/phantom.js http://localhost:1111/capture &
15-
# - sleep 5
14+
- phantomjs node_modules/buster/script/phantom.js http://localhost:1111/capture &
15+
- sleep 5
1616

1717
script:
1818
- "npm test"

‎ChangeLog.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,36 @@
22
# Change Log
33

44

5+
## 0.3.0: 2017/06/01
6+
7+
https://github.com/imaya/zlib.js/compare/0.2.0...0.3.0
8+
9+
### decompression
10+
11+
- fix bug in decode HLIT and HDIST (aefd58bc482258faaf70644717ac54b7f6d4e599)
12+
- check invalid code length from malicious compressed data (4971111c1ad49e3c353ed38d51850e1ff5c206b9)
13+
14+
### compression
15+
16+
- fix data exists after payload (08a5b2eb89e1d31178d272857fbdf55358bdcec4)
17+
18+
### etc
19+
20+
- Task runner: Migrate to Grunt from Ant
21+
- Testing framework: Migate to Karma and mocha from BusterJS
22+
23+
524
## 0.1.9, 0.2.0: 2014/02/21
625

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

928

10-
## decompression
29+
### decompression
1130

1231
- fix RLE bug HDIST between HLIT
1332

1433

15-
## etc
34+
### etc
1635

1736
- support buster.js 0.7.4
1837
- code cleanup

‎Gruntfile.js

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
module.exports = function(grunt) {
2+
grunt.loadNpmTasks('grunt-closure-tools');
3+
grunt.loadNpmTasks('grunt-contrib-concat');
4+
5+
var license = grunt.file.read('LICENSE_min');
6+
var basefiles = [
7+
'closure-primitives/base.js',
8+
'define/typedarray/hybrid.js',
9+
'src/*.js'
10+
];
11+
var config = grunt.file.readJSON("build.json");
12+
var targets = Object.keys(config);
13+
14+
grunt.initConfig({
15+
closureDepsWriter: {
16+
options: {
17+
depswriter: 'closure-primitives/depswriter.py',
18+
root_with_prefix: ['"src ../src"']
19+
},
20+
deps: {
21+
dest: 'closure-primitives/deps.js'
22+
}
23+
},
24+
closureCompiler: mergeObject(
25+
{
26+
options: {
27+
compilerFile: 'vendor/google-closure-compiler/compiler.jar',
28+
checkModified: false,
29+
compilerOpts: {
30+
compilation_level: 'PERFORMANCE_OPTIMIZATIONS',
31+
language_in: 'ECMASCRIPT5_STRICT',
32+
source_map_format: "V3",
33+
manage_closure_dependencies: true,
34+
summary_detail_level: 3,
35+
warning_level: 'VERBOSE',
36+
jscomp_error: [
37+
'accessControls',
38+
'checkTypes',
39+
'checkVars',
40+
'const',
41+
'constantProperty',
42+
'duplicate',
43+
'visibility'
44+
],
45+
output_wrapper:
46+
'"' + license + '(function() {%output%}).call(this);"'
47+
}
48+
}
49+
}, (function() {
50+
var result = {};
51+
52+
targets.forEach(function(target) {
53+
result[target] = createClosureCompilerSetting(target);
54+
});
55+
56+
return result;
57+
})()
58+
),
59+
'concat': mergeObject(
60+
{
61+
options: {
62+
process: concatProcess
63+
}
64+
}, (function() {
65+
var result = {};
66+
67+
targets.forEach(function(target) {
68+
result[target] = createConcatSettings(target);
69+
});
70+
71+
return result;
72+
})()
73+
)
74+
});
75+
76+
// create compile settings
77+
function createClosureCompilerSetting(target) {
78+
return {
79+
src: basefiles.concat(config[target].src),
80+
dest: config[target].dest,
81+
TEMPcompilerOpts: mergeObject(
82+
{
83+
create_source_map: config[target].map
84+
},
85+
config[target].compilerOpts || {}
86+
)
87+
}
88+
}
89+
90+
// create concat settings
91+
function createConcatSettings(target) {
92+
return {
93+
src: config[target].dest,
94+
dest: config[target].dev
95+
}
96+
}
97+
98+
// concat sourcemaps
99+
function concatProcess(src, filepath) {
100+
var mapfile = filepath + ".map";
101+
102+
var result =
103+
src + '//# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
104+
new Buffer(updateSourceMaps(mapfile)).toString('base64');
105+
grunt.file.delete(mapfile);
106+
107+
return result;
108+
}
109+
110+
// update sourcemaps
111+
function updateSourceMaps(path) {
112+
var mapObject = grunt.file.readJSON(path);
113+
var contents = [];
114+
115+
/*
116+
// source data-url version
117+
mapObject.sources.forEach(function(sourcePath, i) {
118+
mapObject.sources[i] = 'data:text/plain;charset=utf-8;base64,' +
119+
new Buffer(grunt.file.read(sourcePath, {encoding: null}).toString('base64'))
120+
});
121+
*/
122+
123+
// sourceContent version
124+
mapObject.sources.forEach(function(sourcePath) {
125+
contents.push(grunt.file.read(sourcePath, {encoding: null}).toString())
126+
});
127+
128+
mapObject.sourcesContent = contents;
129+
130+
return JSON.stringify(mapObject);
131+
}
132+
133+
// merge object
134+
function mergeObject(dst, src) {
135+
Object.keys(src).forEach(function(key) {
136+
dst[key] = src[key];
137+
});
138+
139+
return dst;
140+
}
141+
142+
grunt.registerTask("default", targets);
143+
grunt.registerTask("all", targets);
144+
grunt.registerTask("deps", ["closureDepsWriter:deps"]);
145+
targets.forEach(function(target) {
146+
grunt.registerTask(target, ["closureCompiler:" + target, "concat:" + target]);
147+
});
148+
};

‎README.en.md

+45-26
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,14 @@ see unit tests.
218218
If you want to know the code before compile, SourceMaps and PrettyPrint can be used.
219219

220220

221-
### SourceMaps
221+
### Source Map
222222

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

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

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

232230

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

241-
Build using Ant and Closure Compiler.
239+
Build using Grunt and Closure Compiler.
242240

243241
### Requirement
244242

245-
- Ant 1.8+
246-
- JRE 1.6+
243+
- Grunt
247244
- Python
248245

249246
### Build
250247

251-
Use "ant" command.
248+
Use "grunt" command.
252249

253250
```
254-
$ ant [target]
251+
$ grunt [target]
255252
```
256253

257254
#### Build target
258255

259-
target | generate file | implementation
260-
---------------|----------------------|-------------
261-
deps | deps.js | (dependency: deps.js)
262-
deflate | deflate.min.js | ZLIB Deflate
263-
inflate | inflate.min.js | ZLIB Inflate
264-
inflate_stream | inlate_stream.min.js | ZLIB Inlate (stream)
265-
zlib | zlib.min.js | ZLIB Deflate + Inflate
266-
gzip | gzip.min.js | GZIP Compression
267-
gunzip | gunzip.min.js | GZIP Decompression
268-
zlib_and_gzip | zlib_and_gzip.min.js | ZLIB + GZIP
269-
node | node-zlib.js | ZLIB + GZIP for node.js
270-
zip | zip.min.js | PKZIP Compression
271-
unzip | unzip.min.js | PKZIP Decompression
272-
all | * | default target
256+
target | generate file | implementation
257+
---------------|-----------------------|-------------in
258+
deps | deps.js | (dependency: deps.js)
259+
deflate | deflate.min.js | ZLIB Deflate
260+
inflate | inflate.min.js | ZLIB Inflate
261+
inflate_stream | inflate_stream.min.js | ZLIB Inflate (stream)
262+
zlib | zlib.min.js | ZLIB Deflate + Inflate
263+
gzip | gzip.min.js | GZIP Compression
264+
gunzip | gunzip.min.js | GZIP Decompression
265+
zlib_and_gzip | zlib_and_gzip.min.js | ZLIB + GZIP
266+
node | node-zlib.js | ZLIB + GZIP for node.js
267+
zip | zip.min.js | PKZIP Compression
268+
unzip | unzip.min.js | PKZIP Decompression
269+
all | * | default target
270+
271+
272+
Test
273+
------
274+
275+
Unit tests are using Karma and mocha.
276+
277+
```
278+
$ npm test
279+
```
280+
281+
### Browser only
282+
283+
```
284+
$ npm run test-karma
285+
```
286+
287+
### Node.js only
288+
289+
```
290+
$ npm run test-mocha
291+
```
273292

274293

275294
Issue

0 commit comments

Comments
 (0)