It is still a prototype software. Use it at your own risk.
Proven Working Packages
fecha (Lightweight version of moment) lodash(--no-minify) sprintf
cd app/qmljsify qpm install qmake make #Then copy qmljsify to your favor path
p.s Windows is not working yet.
You must have the
webpackbinary be installed and searchable in PATH environment variable.
qmljsify convert sprintf
Then it will fetch
sprintffrom NPM and create two files
sprintf.orig.js # A compiled and minified sprintf library sprintf.js # A Wrapper of the compiled sprintf library for QML
That is what
.pragma library Qt.include("sprintf.orig.js") var object_stringify = QML.object_stringify; var format = QML.format; var cache = QML.cache; var parse = QML.parse; var sprintf = QML.sprintf; var vsprintf = QML.vsprintf;
Then you could use it in your QML file:
import "./sprintf.js" as SPrintf // [snipped] SPrintf.sprintf("%d %d", 1 , 2);
It don't works on Windows.
setTimeout is not wrapped.
It can't handle a library with only a single function yet. (e.g left-pad)
It may not works for some npm package.
- qml: SyntaxError: Expected token `;'
$ qmljsify convert lodash qml: SyntaxError: Expected token `;'
$ qmljsify convert --no-minify lodash lodash.orig.js saved lodash.js saved
- SyntaxError: Expected token
Basically, I have no idea what may trigger this problem.
You may try to use
--no-minify, if it is still not working and that package is small and tiny, please report to me. It may be used to investigate the problem
Looks interesting, thanks for sharing! :-)