@wailsio/runtime 3.0.0-alpha.10 → 3.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wailsio/runtime",
3
- "version": "3.0.0-alpha.10",
3
+ "version": "3.0.0-alpha.11",
4
4
  "description": "Wails Runtime",
5
5
  "main": "src/index.js",
6
6
  "types": "types/index.d.ts",
package/src/index.js CHANGED
@@ -10,7 +10,6 @@ The electron alternative for Go
10
10
 
11
11
  import {setupContextMenus} from "./contextmenu";
12
12
  import {setupDrag} from "./drag";
13
- import {reloadWML} from "./wml";
14
13
  import {Emit, Off, OffAll, On, Once, OnMultiple, WailsEvent} from './events';
15
14
  import {ByID, ByName, Plugin} from "./calls";
16
15
  import {Error, Info, OpenFile, Question, SaveFile, Warning} from "./dialogs";
@@ -24,8 +23,9 @@ import * as Runtime from "./runtime";
24
23
  import * as Screens from "./screens";
25
24
  import * as System from "./system";
26
25
  import * as Window from "./window";
26
+ import * as WML from './wml';
27
27
 
28
- export { Application, Browser, Clipboard, ContextMenu, Flags, Runtime, Screens, System, Window };
28
+ export { Application, Browser, Clipboard, ContextMenu, Flags, Runtime, Screens, System, Window, WML };
29
29
 
30
30
  export const Events = {
31
31
  On,
@@ -50,9 +50,52 @@ export const Dialogs = {
50
50
  OpenFile, Question, Warning, SaveFile
51
51
  }
52
52
 
53
- setupContextMenus();
54
- setupDrag();
53
+ /***
54
+ This technique for proper load detection is taken from HTMX:
55
55
 
56
- document.addEventListener("DOMContentLoaded", function () {
57
- reloadWML();
56
+ BSD 2-Clause License
57
+
58
+ Copyright (c) 2020, Big Sky Software
59
+ All rights reserved.
60
+
61
+ Redistribution and use in source and binary forms, with or without
62
+ modification, are permitted provided that the following conditions are met:
63
+
64
+ 1. Redistributions of source code must retain the above copyright notice, this
65
+ list of conditions and the following disclaimer.
66
+
67
+ 2. Redistributions in binary form must reproduce the above copyright notice,
68
+ this list of conditions and the following disclaimer in the documentation
69
+ and/or other materials provided with the distribution.
70
+
71
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
72
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
73
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
74
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
75
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
76
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
77
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
78
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
79
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81
+
82
+ ***/
83
+
84
+ let isReady = false
85
+ document.addEventListener('DOMContentLoaded', function() {
86
+ isReady = true
87
+ })
88
+
89
+ function whenReady(fn) {
90
+ if (isReady || document.readyState === 'complete') {
91
+ fn();
92
+ } else {
93
+ document.addEventListener('DOMContentLoaded', fn);
94
+ }
95
+ }
96
+
97
+ whenReady(() => {
98
+ setupContextMenus();
99
+ setupDrag();
100
+ WML.Reload();
58
101
  });
package/src/wml.js CHANGED
@@ -143,7 +143,7 @@ function addWMLOpenBrowserListener() {
143
143
  *
144
144
  * @return {void}
145
145
  */
146
- export function reloadWML() {
146
+ export function Reload() {
147
147
  console.log("Reloading WML");
148
148
  addWMLEventListeners();
149
149
  addWMLWindowListeners();