Skip to content

Commit 1f87ece

Browse files
committed
Add project structure.
Adds README.md, AUTHORS, LICENSE, package.json, .gitignore, gulp tasks. The library is now built to lib/qmlweb.parser.js and minified to lib/qmlweb.parser.min.js. Exports are now done through `module.exports` (for Node.js) and though `window.qmlweb_parse` (for browser, as before). PR-URL: #6
1 parent 17175b2 commit 1f87ece

File tree

7 files changed

+154
-3
lines changed

7 files changed

+154
-3
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node_modules/
2+
lib/
3+
coverage/
4+
tmp/
5+
build/
6+
.idea/
7+
*~
8+
*.bak
9+
*.log
10+
.*.swp
11+
.*.swo
12+
*.kdev4
13+
*kate-swp
14+
.arcconfig
15+
.project

AUTHORS

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Authors ordered by first contribution.
2+
3+
Lauri Paimen <[email protected]>
4+
Anton Kreuzkamp <[email protected]>
5+
Сковорода Никита Андреевич <[email protected]>
6+
Michael Martin Moro <[email protected]>
7+
Pavel Vasev <[email protected]>
8+
Henrik Rudstrøm <[email protected]>

LICENSE

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
QmlWeb parser is based on UglifyJS parser, and is distributed under
2+
the BSD-2-Clause license, as follows:
3+
4+
"""
5+
Copyright (c) 2010 Mihai Bazon <[email protected]>
6+
Copyright (c) 2011 Lauri Paimen <[email protected]>
7+
Copyright (c) 2013 Anton Kreuzkamp <[email protected]>
8+
Based on parse-js (http://marijn.haverbeke.nl/parse-js/).
9+
10+
Redistribution and use in source and binary forms, with or without
11+
modification, are permitted provided that the following conditions
12+
are met:
13+
14+
* Redistributions of source code must retain the above
15+
copyright notice, this list of conditions and the following
16+
disclaimer.
17+
18+
* Redistributions in binary form must reproduce the above
19+
copyright notice, this list of conditions and the following
20+
disclaimer in the documentation and/or other materials
21+
provided with the distribution.
22+
23+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
24+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
27+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
32+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
33+
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34+
SUCH DAMAGE.
35+
"""

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# QML parser in JavaScript
2+
3+
[![Join the chat at https://gitter.im/qmlweb/qmlweb](https://badges.gitter.im/qmlweb/qmlweb.svg)](https://gitter.im/qmlweb/qmlweb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4+
5+
This is a QML parser in pure JavaScript, based on UglifyJS parser.
6+
7+
It serves both as an optional dependency to
8+
[QmlWeb](https://github.com/qmlweb/qmlweb) to allow it parse QML and
9+
JavaScript files in runtime and as a parser that powers
10+
[gulp-qmlweb](https://github.com/qmlweb/gulp-qmlweb) to pre-parse
11+
files before serving them to the browser.
12+
13+
## License
14+
15+
QmlWeb parser is licensed under the BSD-2-Clause license, see
16+
[LICENSE](https://github.com/qmlweb/qmlweb-parser/blob/master/LICENSE).

gulpfile.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const gulp = require('gulp');
2+
const concat = require('gulp-concat');
3+
const rename = require('gulp-rename');
4+
const changed = require('gulp-changed');
5+
const order = require('gulp-order');
6+
const uglify = require('gulp-uglify');
7+
const sourcemaps = require('gulp-sourcemaps');
8+
const iife = require('gulp-iife');
9+
10+
const sources = [
11+
'src/**/*.js'
12+
];
13+
14+
gulp.task('build-dev', function() {
15+
return gulp.src(sources)
16+
.pipe(order(sources, { base: __dirname }))
17+
.pipe(sourcemaps.init())
18+
.pipe(concat('qmlweb.parser.js'))
19+
.pipe(iife({
20+
useStrict: false,
21+
params: ['exports'],
22+
args: ['typeof exports !== \'undefined\' ? exports : window']
23+
}))
24+
.pipe(changed('./lib'))
25+
.pipe(sourcemaps.write('./'))
26+
.pipe(gulp.dest('./lib'));
27+
});
28+
29+
gulp.task('build', ['build-dev'], function() {
30+
return gulp.src('./lib/qmlweb.parser.js')
31+
.pipe(rename('qmlweb.parser.min.js'))
32+
.pipe(changed('./lib'))
33+
.pipe(sourcemaps.init({ loadMaps: true }))
34+
.pipe(uglify())
35+
.pipe(sourcemaps.write('./'))
36+
.pipe(gulp.dest('./lib'));
37+
});
38+
39+
gulp.task('watch', ['build'], function() {
40+
gulp.watch(sources, ['build']);
41+
});
42+
43+
gulp.task('watch-dev', ['build-dev'], function() {
44+
gulp.watch(sources, ['build-dev']);
45+
});
46+
47+
gulp.task('default', ['watch']);

package.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "qmlweb-parser",
3+
"version": "0.0.0",
4+
"description": "QML parser in JavaScript",
5+
"license": "BSD-2-Clause",
6+
"repository": "qmlweb/qmlweb-parser",
7+
"devDependencies": {
8+
"gulp": "^3.6.2",
9+
"gulp-changed": "^1.3.0",
10+
"gulp-concat": "^2.1.7",
11+
"gulp-iife": "^0.3.0",
12+
"gulp-order": "^1.1.1",
13+
"gulp-rename": "^1.2.2",
14+
"gulp-replace": "^0.5.4",
15+
"gulp-sourcemaps": "^1.6.0",
16+
"gulp-uglify": "^1.5.2"
17+
},
18+
"scripts": {
19+
"build": "gulp build",
20+
"watch": "gulp watch"
21+
},
22+
"main": "lib/qmlweb.parser.js",
23+
"files": [
24+
"AUTHORS",
25+
"LICENSE",
26+
"README.md",
27+
"lib/**/*.js",
28+
"lib/**/*.js.map",
29+
"src/**/*.js",
30+
"gulpfile.js"
31+
]
32+
}

src/parser.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,4 @@ function HOP(obj, prop) {
15591559

15601560
var warn = function() {};
15611561

1562-
if (typeof global != "undefined") {
1563-
global.qmlweb_parse = qmlweb_parse;
1564-
}
1562+
exports.qmlweb_parse = qmlweb_parse;

0 commit comments

Comments
 (0)