File tree 6 files changed +89
-0
lines changed
6 files changed +89
-0
lines changed Original file line number Diff line number Diff line change
1
+ node_modules /
Original file line number Diff line number Diff line change
1
+ [submodule "qmlweb "]
2
+ path = qmlweb
3
+ url = https://github.com/qmlweb/qmlweb
Original file line number Diff line number Diff line change
1
+ ## Installation
2
+
3
+ Add the following dependencies to your ` package.json ` :
4
+
5
+ ```
6
+ {
7
+ "name": "QmlWebProject",
8
+ "devDependencies": {
9
+ "gulp": "~3.6.0",
10
+ "gulp-concat": "~2.1.7",
11
+ "gulp-qmlweb": "git://github.com/qmlweb/gulp-qmlweb.git"
12
+ }
13
+ }
14
+ ```
15
+
16
+ ## Usage
17
+ ```
18
+ var qml = require('gulp-qmlweb');
19
+ var concat = require('gulp-concat');
20
+
21
+ gulp.task('scripts', function() {
22
+ return gulp.src(['qml/**/*.qml', 'qml/**/*.js'])
23
+ .pipe(qml())
24
+ .pipe(concat('qrc.js'))
25
+ .pipe(gulp.dest('./dist/'));
26
+ });
27
+ ```
28
+
29
+ This will compile all your QML sources (qml and javascript) and concatenate them in the ` /dist/qrc.js ` file.
Original file line number Diff line number Diff line change
1
+ var es = require ( 'event-stream' ) ;
2
+ var gutil = require ( 'gulp-util' ) ;
3
+ require ( __dirname + '/qmlweb/src/qtcore/qml/QMLBinding.js' ) ;
4
+ require ( __dirname + '/qmlweb/src/qtcore/qml/lib/parser.js' ) ;
5
+ require ( __dirname + '/qmlweb/src/qtcore/qml/lib/jsparser.js' ) ;
6
+
7
+ module . exports = function ( opt ) {
8
+ function modifyFile ( file ) {
9
+ if ( file . isNull ( ) ) return this . emit ( 'data' , file ) ;
10
+ if ( file . isStream ( ) ) return this . emit ( 'error' , new Error ( "gulp-qml: Streaming not supported" ) ) ;
11
+
12
+ var data ;
13
+ var src ;
14
+ var str = file . contents . toString ( 'utf8' ) ;
15
+ var dest = gutil . replaceExtension ( file . path , ".js" ) ;
16
+ var gulpPath = __dirname . split ( '/' ) ;
17
+ gulpPath = gulpPath . splice ( 0 , gulpPath . length - 2 ) . join ( '/' ) + '/' ;
18
+ var path = file . path . substr ( gulpPath . length , file . path . length ) ;
19
+
20
+ try {
21
+ if ( file . path . match ( / \. q m l $ / ) != null )
22
+ data = qmlparse ( str ) ;
23
+ else if ( file . path . match ( / \. j s $ / ) != null )
24
+ data = jsparse ( str ) ;
25
+ else
26
+ data = str ;
27
+ } catch ( err ) {
28
+ return this . emit ( 'error' , new Error ( file . path + ': ' + err ) ) ;
29
+ }
30
+
31
+ src = "qrc['" + path + "'] = " + JSON . stringify ( data ) + ';' ;
32
+
33
+ file . contents = new Buffer ( src ) ;
34
+ file . path = dest ;
35
+ this . emit ( 'data' , file ) ;
36
+ }
37
+
38
+ return es . through ( modifyFile ) ;
39
+ } ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " gulp-qmlweb" ,
3
+ "version" : " 0.0.1" ,
4
+ "description" : " compiles QML source files for use with the qmlweb library" ,
5
+ "files" : [
6
+ " index.js" ,
7
+ " qmlweb/src/qtcore/qml/QMLBinding.js" ,
8
+ " qmlweb/src/qtcore/qml/lib/parser.js" ,
9
+ " qmlweb/src/qtcore/qml/lib/jsparser.js"
10
+ ],
11
+ "dependencies" : {
12
+ "event-stream" : " " ,
13
+ "gulp-util" : " ~2.2.14" ,
14
+ "uglify-js" : " ^2.6.1"
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments