Qt
  1. Qt
  2. QTBUG-22356

Investigate support for 3rd party JS libraries

    Details

      Description

      Research if and how we should support 3rd party javascript libraries from QML.

      JavaScript libraries may attempt to do things not allowed by the QML JS environment. For example:

      Modify native objects:

      Modify the global object:

      Many libraries seem to be looking for either a browser environment or a CommonJS-like environment:

      In some cases, existing libraries can be made to work with code like:

      "import.js"
      var window = {}
      Qt.include("persistence.js")
      

      Possible solutions:

      • Many libraries introspect their JS environment and tweak their code to cater for different environments. We could offer a standard way to identify the QML environment, allowing libraries to tweak themselves to our environment as well
      • We could consider introducing a new pragma, or allowing ".pragma library" imports to do special things (e.g. have their own (private?) editable global object)
      • A pragma that bootstraps some sort of compatibility layer (like Envjs)

      Other notes:

        Issue Links

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

          Michael Brasser (closed Nokia identity) (Inactive) created issue -
          Michael Brasser (closed Nokia identity) (Inactive) made changes -
          Field Original Value New Value
          Link This issue relates to QTBUG-23933 [ QTBUG-23933 ]
          Charles Yin (closed Nokia identity) (Inactive) made changes -
          Fix Version/s 5.1.0 [ 12121 ]
          Charles Yin (closed Nokia identity) (Inactive) made changes -
          Link This issue relates to QTBUG-25411 [ QTBUG-25411 ]
          Martin Jones (closed Nokia identity) (Inactive) made changes -
          Priority Not Evaluated [ 6 ] P2: Important [ 3 ]
          Michael Brasser (closed Nokia identity) (Inactive) made changes -
          Description Research if and how we should support 3rd party javascript libraries from QML.

          JavaScript libraries may attempt to do things not allowed by the QML JS environment. For example:

          Modify native objects:
          * http://sugarjs.com/
          * http://www.datejs.com/

          Modify the global object:
          * http://www.diveintojavascript.com/projects/javascript-sprintf
          * http://documentcloud.github.com/underscore/

          Many libraries seem to be looking for either a browser environment or a CommonJS-like environment:
          * https://github.com/willconant/flow-js (CommonJS "exports" or "window" for browser)
          * http://persistencejs.org/ (CommonJS "exports" or "window" for browser)
          * https://github.com/caolan/async (CommonJS "exports" or "this" for browser)
          * https://github.com/michael/data (CommonJS "exports" or "this" for browser)

          In some cases, existing libraries can be made to work with code like:
          {code:title="import.js"}
          var window = {}
          Qt.include("persistence.js")
          {code}

          Possible solutions:
          * Many libraries already tweak their code to cater for different environments. We could offer a standard way for libraries to be tweaked to our environment as well
          * We could consider introducing a new pragma, or allowing ".pragma library" imports to do special things (e.g. have their own (private?) editable global object)

          Other notes:
          * There seem to be a particularly large number of libraries tailored to node's JS environment: https://github.com/joyent/node/wiki/modules, though it isn't immediately clear how many would also be relevant to QML.
          Research if and how we should support 3rd party javascript libraries from QML.

          JavaScript libraries may attempt to do things not allowed by the QML JS environment. For example:

          Modify native objects:
          * http://sugarjs.com/
          * http://www.datejs.com/

          Modify the global object:
          * http://www.diveintojavascript.com/projects/javascript-sprintf
          * http://documentcloud.github.com/underscore/

          Many libraries seem to be looking for either a browser environment or a CommonJS-like environment:
          * https://github.com/willconant/flow-js (CommonJS "exports" or "window" for browser)
          * http://persistencejs.org/ (CommonJS "exports" or "window" for browser)
          * https://github.com/caolan/async (CommonJS "exports" or "this" for browser)
          * https://github.com/michael/data (CommonJS "exports" or "this" for browser)

          In some cases, existing libraries can be made to work with code like:
          {code:title="import.js"}
          var window = {}
          Qt.include("persistence.js")
          {code}

          Possible solutions:
          * Many libraries introspect their JS environment and tweak their code to cater for different environments. We could offer a standard way to identify the QML environment, allowing libraries to tweak themselves to our environment as well
          * We could consider introducing a new pragma, or allowing ".pragma library" imports to do special things (e.g. have their own (private?) editable global object)
          * A pragma that bootstraps some sort of compatibility layer (like Envjs)

          Other notes:
          * There seem to be a particularly large number of libraries tailored to node's JS environment: https://github.com/joyent/node/wiki/modules, though it isn't immediately clear how many would also be relevant to QML.
          Alan Alpert made changes -
          Assignee Martin Jones (closed Nokia identity) [ martjone ]
          Fix Version/s 5.1.0 [ 12121 ]
          Alex Blasche made changes -
          Workflow Qt Bug Tracking [ 281364 ] Qt Bug Tracking v2.0 [ 308686 ]
          Simon Hausmann made changes -
          Status Reported [ 10011 ] Open [ 1 ]
          Simon Hausmann made changes -
          Link This issue replaces QTBUG-40028 [ QTBUG-40028 ]
          Michael Brasser made changes -
          Link This issue is related to QTBUG-47735 [ QTBUG-47735 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Michael Brasser (closed Nokia identity) (Inactive)
            • Votes:
              13 Vote for this issue
              Watchers:
              17 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes