32 |
33 |
34 |
35 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/qtloader.js:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | **
3 | ** Copyright (C) 2018 The Qt Company Ltd.
4 | ** Contact: https://www.qt.io/licensing/
5 | **
6 | ** This file is part of the plugins of the Qt Toolkit.
7 | **
8 | ** $QT_BEGIN_LICENSE:GPL$
9 | ** Commercial License Usage
10 | ** Licensees holding valid commercial Qt licenses may use this file in
11 | ** accordance with the commercial license agreement provided with the
12 | ** Software or, alternatively, in accordance with the terms contained in
13 | ** a written agreement between you and The Qt Company. For licensing terms
14 | ** and conditions see https://www.qt.io/terms-conditions. For further
15 | ** information use the contact form at https://www.qt.io/contact-us.
16 | **
17 | ** GNU General Public License Usage
18 | ** Alternatively, this file may be used under the terms of the GNU
19 | ** General Public License version 3 or (at your option) any later version
20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3
22 | ** included in the packaging of this file. Please review the following
23 | ** information to ensure the GNU General Public License requirements will
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25 | **
26 | ** $QT_END_LICENSE$
27 | **
28 | ****************************************************************************/
29 |
30 | // QtLoader provides javascript API for managing Qt application modules.
31 | //
32 | // QtLoader provides API on top of Emscripten which supports common lifecycle
33 | // tasks such as displaying placeholder content while the module downloads,
34 | // handing application exits, and checking for browser wasm support.
35 | //
36 | // There are two usage modes:
37 | // * Managed: QtLoader owns and manages the HTML display elements like
38 | // the loader and canvas.
39 | // * External: The embedding HTML page owns the display elements. QtLoader
40 | // provides event callbacks which the page reacts to.
41 | //
42 | // Managed mode usage:
43 | //
44 | // var config = {
45 | // containerElements : [$("container-id")];
46 | // }
47 | // var qtLoader = QtLoader(config);
48 | // qtLoader.loadEmscriptenModule("applicationName");
49 | //
50 | // External mode.usage:
51 | //
52 | // var config = {
53 | // canvasElements : [$("canvas-id")],
54 | // showLoader: function() {
55 | // loader.style.display = 'block'
56 | // canvas.style.display = 'hidden'
57 | // },
58 | // showCanvas: function() {
59 | // loader.style.display = 'hidden'
60 | // canvas.style.display = 'block'
61 | // return canvas;
62 | // }
63 | // }
64 | // var qtLoader = QtLoader(config);
65 | // qtLoader.loadEmscriptenModule("applicationName");
66 | //
67 | // Config keys
68 | //
69 | // containerElements : [container-element, ...]
70 | // One or more HTML elements. QtLoader will display loader elements
71 | // on these while loading the applicaton, and replace the loader with a
72 | // canvas on load complete.
73 | // canvasElements : [canvas-element, ...]
74 | // One or more canvas elements.
75 | // showLoader : function(status, containerElement)
76 | // Optional loading element constructor function. Implement to create
77 | // a custom loading screen. This function may be called multiple times,
78 | // while preparing the application binary. "status" is a string
79 | // containing the loading sub-status, and may be either "Downloading",
80 | // or "Compiling". The browser may be using streaming compilation, in
81 | // which case the wasm module is compiled during downloading and the
82 | // there is no separate compile step.
83 | // showCanvas : function(containerElement)
84 | // Optional canvas constructor function. Implement to create custom
85 | // canvas elements.
86 | // showExit : function(crashed, exitCode, containerElement)
87 | // Optional exited element constructor function.
88 | // showError : function(crashed, exitCode, containerElement)
89 | // Optional error element constructor function.
90 | //
91 | // path :
92 | // Prefix path for wasm file, realative to the loading HMTL file.
93 | // restartMode : "DoNotRestart", "RestartOnExit", "RestartOnCrash"
94 | // Controls whether the application should be reloaded on exits. The default is "DoNotRestart"
95 | // restartType : "RestartModule", "ReloadPage"
96 | // restartLimit :
97 | // Restart attempts limit. The default is 10.
98 | // stdoutEnabled :
99 | // stderrEnabled :
100 | // environment :