@lango-project/lango-client 0.2.1 → 0.4.1
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/LICENSE +1 -0
- package/NOTICE +5 -1
- package/README.md +603 -906
- package/cli/.lango/localization.mjs +108 -0
- package/{dist/node → cli}/.lango/runtime.mjs +120 -20
- package/cli/.lango/vendor/i18next.LICENSE +21 -0
- package/cli/.lango/vendor/i18next.mjs +2434 -0
- package/cli/create.mjs +62 -0
- package/cli/create.mjs.map +1 -0
- package/dist/.lango/localization.mjs +108 -0
- package/dist/.lango/runtime.mjs +120 -20
- package/dist/.lango/vendor/i18next.LICENSE +21 -0
- package/dist/.lango/vendor/i18next.mjs +2434 -0
- package/dist/accordion.mjs +277 -0
- package/dist/accordion.mjs.map +1 -0
- package/dist/activities.mjs +185 -0
- package/dist/activities.mjs.map +1 -0
- package/dist/app.mjs +671 -0
- package/dist/app.mjs.map +1 -0
- package/dist/boot.mjs +24 -0
- package/dist/boot.mjs.map +1 -0
- package/dist/bootstrap-LICENSE +21 -0
- package/dist/bootstrap.min.css +6 -0
- package/dist/bootstrap.min.css.map +1 -0
- package/dist/button.mjs +77 -0
- package/dist/button.mjs.map +1 -0
- package/dist/chip.mjs +134 -0
- package/dist/chip.mjs.map +1 -0
- package/dist/client.css +102 -0
- package/dist/collections.mjs +77 -0
- package/dist/collections.mjs.map +1 -0
- package/dist/combo_box.mjs +408 -0
- package/dist/combo_box.mjs.map +1 -0
- package/dist/content.mjs +123 -0
- package/dist/content.mjs.map +1 -0
- package/dist/control.mjs +141 -0
- package/dist/control.mjs.map +1 -0
- package/dist/date_input.mjs +242 -0
- package/dist/date_input.mjs.map +1 -0
- package/dist/dimensions.mjs +102 -0
- package/dist/dimensions.mjs.map +1 -0
- package/dist/error_reporter.mjs +136 -0
- package/dist/error_reporter.mjs.map +1 -0
- package/dist/fields.mjs +454 -0
- package/dist/fields.mjs.map +1 -0
- package/dist/file_input.mjs +227 -0
- package/dist/file_input.mjs.map +1 -0
- package/dist/form.mjs +272 -0
- package/dist/form.mjs.map +1 -0
- package/dist/heartbeat.mjs +167 -254
- package/dist/heartbeat.mjs.map +1 -1
- package/dist/index.html +18 -0
- package/dist/indicators.mjs +127 -0
- package/dist/indicators.mjs.map +1 -0
- package/dist/input_changes.mjs +58 -0
- package/dist/input_changes.mjs.map +1 -0
- package/dist/input_group.mjs +38 -0
- package/dist/input_group.mjs.map +1 -0
- package/dist/layouts.mjs +195 -0
- package/dist/layouts.mjs.map +1 -0
- package/dist/library.mjs +130 -807
- package/dist/library.mjs.map +1 -1
- package/dist/longpoll.mjs +254 -0
- package/dist/longpoll.mjs.map +1 -0
- package/dist/main.mjs +147 -0
- package/dist/main.mjs.map +1 -0
- package/dist/markdown.mjs +61 -0
- package/dist/markdown.mjs.map +1 -0
- package/dist/menus.mjs +468 -0
- package/dist/menus.mjs.map +1 -0
- package/dist/navigation.mjs +260 -410
- package/dist/navigation.mjs.map +1 -1
- package/dist/numeric_input.mjs +181 -0
- package/dist/numeric_input.mjs.map +1 -0
- package/dist/otp_input.mjs +113 -0
- package/dist/otp_input.mjs.map +1 -0
- package/dist/presentations.mjs +852 -0
- package/dist/presentations.mjs.map +1 -0
- package/dist/renderer.mjs +295 -0
- package/dist/renderer.mjs.map +1 -0
- package/dist/rich_content.mjs +99 -0
- package/dist/rich_content.mjs.map +1 -0
- package/dist/table_scope.mjs +166 -0
- package/dist/table_scope.mjs.map +1 -0
- package/dist/tables.mjs +1052 -0
- package/dist/tables.mjs.map +1 -0
- package/dist/tabs.mjs +205 -0
- package/dist/tabs.mjs.map +1 -0
- package/dist/templates.mjs +46 -0
- package/dist/templates.mjs.map +1 -0
- package/dist/vendor/DOMPurify-LICENSE +202 -0
- package/dist/vendor/dompurify.mjs +2454 -0
- package/dist/vendor/flatpickr-LICENSE.md +21 -0
- package/dist/vendor/flatpickr.min.css +13 -0
- package/dist/vendor/flatpickr.mjs +2340 -0
- package/dist/vendor/flatpickr.mjs.map +7 -0
- package/dist/vendor/marked-LICENSE.md +44 -0
- package/dist/vendor/marked.esm.js.map +7 -0
- package/dist/vendor/marked.mjs +85 -0
- package/dist/vendor/purify.es.mjs.map +1 -0
- package/dist/widgets.mjs +197 -0
- package/dist/widgets.mjs.map +1 -0
- package/docs/implementation.md +93 -0
- package/package.json +25 -43
- package/src/accordion.lango +198 -0
- package/src/activities.lango +132 -0
- package/src/app.lango +540 -0
- package/src/boot.lango +12 -0
- package/src/button.lango +49 -0
- package/src/chip.lango +94 -0
- package/src/collections.lango +46 -0
- package/src/combo_box.lango +298 -0
- package/src/content.lango +75 -0
- package/src/control.lango +103 -0
- package/src/create.lango +42 -0
- package/src/date_input.lango +215 -0
- package/src/dimensions.lango +65 -0
- package/src/error_reporter.lango +95 -0
- package/src/fields.lango +327 -0
- package/src/file_input.lango +175 -0
- package/src/form.lango +195 -0
- package/src/heartbeat.lango +136 -199
- package/src/indicators.lango +94 -0
- package/src/input_changes.lango +33 -0
- package/src/input_group.lango +22 -0
- package/src/layouts.lango +137 -0
- package/src/library.lango +194 -599
- package/src/longpoll.lango +187 -0
- package/src/main.lango +118 -0
- package/src/markdown.lango +48 -0
- package/src/menus.lango +336 -0
- package/src/navigation.lango +209 -299
- package/src/numeric_input.lango +131 -0
- package/src/otp_input.lango +83 -0
- package/src/presentations.lango +617 -0
- package/src/renderer.lango +296 -0
- package/src/rich_content.lango +66 -0
- package/src/table_scope.lango +119 -0
- package/src/tables.lango +786 -0
- package/src/tabs.lango +144 -0
- package/src/templates.lango +29 -0
- package/src/widgets.lango +141 -0
- package/web/client.css +102 -0
- package/web/index.html +18 -0
- package/dist/application.mjs +0 -429
- package/dist/application.mjs.map +0 -1
- package/dist/coordinator.mjs +0 -91
- package/dist/coordinator.mjs.map +0 -1
- package/dist/demo.mjs +0 -110
- package/dist/demo.mjs.map +0 -1
- package/dist/demo_controls.mjs +0 -59
- package/dist/demo_controls.mjs.map +0 -1
- package/dist/errors.mjs +0 -201
- package/dist/errors.mjs.map +0 -1
- package/dist/form_state.mjs +0 -266
- package/dist/form_state.mjs.map +0 -1
- package/dist/inheritance.mjs +0 -240
- package/dist/inheritance.mjs.map +0 -1
- package/dist/input_values.mjs +0 -65
- package/dist/input_values.mjs.map +0 -1
- package/dist/node/.lango/xmldom/conventions.js +0 -429
- package/dist/node/.lango/xmldom/dom-parser.js +0 -591
- package/dist/node/.lango/xmldom/dom.js +0 -3759
- package/dist/node/.lango/xmldom/entities.js +0 -2171
- package/dist/node/.lango/xmldom/errors.js +0 -205
- package/dist/node/.lango/xmldom/grammar.js +0 -559
- package/dist/node/.lango/xmldom/index.js +0 -41
- package/dist/node/.lango/xmldom/package.json +0 -1
- package/dist/node/.lango/xmldom/sax.js +0 -983
- package/dist/node/.lango/xmldom.LICENSE.md +0 -8
- package/dist/node/browser_host.mjs +0 -351
- package/dist/node/browser_host.mjs.map +0 -1
- package/dist/node/create_app.mjs +0 -118
- package/dist/node/create_app.mjs.map +0 -1
- package/dist/presentation.mjs +0 -89
- package/dist/presentation.mjs.map +0 -1
- package/dist/protocol.mjs +0 -706
- package/dist/protocol.mjs.map +0 -1
- package/dist/session.mjs +0 -471
- package/dist/session.mjs.map +0 -1
- package/dist/tokens.mjs +0 -298
- package/dist/tokens.mjs.map +0 -1
- package/examples/contacts.lango +0 -293
- package/examples/contacts_flow.lango +0 -174
- package/examples/contacts_store.lango +0 -109
- package/examples/contacts_store_test.lango +0 -65
- package/examples/demo.css +0 -87
- package/examples/demo_test.lango +0 -356
- package/examples/index.html +0 -32
- package/examples/pages.lango +0 -174
- package/examples/server.lango +0 -189
- package/examples/worker.lango +0 -142
- package/src/application.lango +0 -327
- package/src/browser_host.lango +0 -276
- package/src/coordinator.lango +0 -57
- package/src/demo.lango +0 -110
- package/src/demo_controls.lango +0 -53
- package/src/errors.lango +0 -149
- package/src/errors_test.lango +0 -157
- package/src/form_state.lango +0 -168
- package/src/heartbeat_test.lango +0 -479
- package/src/inheritance.lango +0 -167
- package/src/input_values.lango +0 -37
- package/src/logout_test.lango +0 -564
- package/src/navigation_test.lango +0 -556
- package/src/presentation.lango +0 -55
- package/src/protocol.lango +0 -787
- package/src/renderer_test.lango +0 -2047
- package/src/session.lango +0 -343
- package/src/session_test.lango +0 -455
- package/src/tabs_test.lango +0 -216
- package/src/tokens.lango +0 -215
- package/template/.vscode/extensions.json +0 -3
- package/template/.vscode/settings.json +0 -9
- package/template/README.md +0 -44
- package/template/gitignore +0 -4
- package/template/package.json +0 -22
- package/template/public/app.css +0 -10
- package/template/public/index.html +0 -24
- package/template/src/client.lango +0 -78
- package/template/src/pages.lango +0 -55
- package/template/src/server.lango +0 -24
- package/template/src/worker.lango +0 -77
- package/template/test/app.lango +0 -9
- package/tools/browser_runner.lango +0 -32
- package/tools/browser_test.lango +0 -343
- package/tools/create_app.lango +0 -88
- package/tools/create_app_test.lango +0 -43
- package/tools/starter_test.lango +0 -227
- /package/{dist/node → cli}/.lango/bignumber.mjs +0 -0
- /package/{dist → cli}/.lango/xmldom/conventions.js +0 -0
- /package/{dist → cli}/.lango/xmldom/dom-parser.js +0 -0
- /package/{dist → cli}/.lango/xmldom/dom.js +0 -0
- /package/{dist → cli}/.lango/xmldom/entities.js +0 -0
- /package/{dist → cli}/.lango/xmldom/errors.js +0 -0
- /package/{dist → cli}/.lango/xmldom/grammar.js +0 -0
- /package/{dist → cli}/.lango/xmldom/index.js +0 -0
- /package/{dist → cli}/.lango/xmldom/package.json +0 -0
- /package/{dist → cli}/.lango/xmldom/sax.js +0 -0
- /package/{dist → cli}/.lango/xmldom.LICENSE.md +0 -0
package/dist/app.mjs
ADDED
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import { Form } from "./form.mjs";
|
|
2
|
+
import { Heartbeat } from "./heartbeat.mjs";
|
|
3
|
+
import { ErrorReporter } from "./error_reporter.mjs";
|
|
4
|
+
import {
|
|
5
|
+
hostGlobal as __hostGlobal,
|
|
6
|
+
fromJson as __fromJson,
|
|
7
|
+
toJson as __toJson,
|
|
8
|
+
getClass as __getClass,
|
|
9
|
+
isKindof as __isKindof,
|
|
10
|
+
isNumber as __isNumber,
|
|
11
|
+
isString as __isString,
|
|
12
|
+
isBool as __isBool,
|
|
13
|
+
isObject as __isObject,
|
|
14
|
+
isArray as __isArray,
|
|
15
|
+
add as __add,
|
|
16
|
+
requireBoolean as __requireBoolean,
|
|
17
|
+
normalize as __normalize,
|
|
18
|
+
call as __call,
|
|
19
|
+
boundary as __boundary,
|
|
20
|
+
requireArity as __requireArity,
|
|
21
|
+
withArity as __withArity,
|
|
22
|
+
} from "./.lango/runtime.mjs";
|
|
23
|
+
|
|
24
|
+
export class App {
|
|
25
|
+
forms;
|
|
26
|
+
root;
|
|
27
|
+
renderer;
|
|
28
|
+
heartbeat;
|
|
29
|
+
resources;
|
|
30
|
+
reporter;
|
|
31
|
+
#host;
|
|
32
|
+
#queue;
|
|
33
|
+
#active;
|
|
34
|
+
#disposed;
|
|
35
|
+
#events;
|
|
36
|
+
#template;
|
|
37
|
+
#pingJob;
|
|
38
|
+
constructor(host, renderer) {
|
|
39
|
+
__requireArity(arguments.length, [0, 1], "constructor");
|
|
40
|
+
host = __boundary(host);
|
|
41
|
+
renderer = __boundary(renderer);
|
|
42
|
+
this.#host = host;
|
|
43
|
+
this.renderer = renderer;
|
|
44
|
+
this.forms = [];
|
|
45
|
+
this.#queue = [];
|
|
46
|
+
this.#active = [];
|
|
47
|
+
this.#disposed = false;
|
|
48
|
+
this.root = null;
|
|
49
|
+
this.#events = { };
|
|
50
|
+
this.#template = null;
|
|
51
|
+
this.heartbeat = null;
|
|
52
|
+
this.#pingJob = null;
|
|
53
|
+
this.resources = [];
|
|
54
|
+
this.reporter = null;
|
|
55
|
+
}
|
|
56
|
+
now() {
|
|
57
|
+
if (__requireBoolean(__normalize(this.#host.now) !== null)) {
|
|
58
|
+
return __normalize(this.#host.now());
|
|
59
|
+
}
|
|
60
|
+
return __normalize(__hostGlobal(["Date"]).now());
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
hostUrl() {
|
|
64
|
+
return __normalize(this.#host.location.href);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
schedule(action, delay) {
|
|
68
|
+
__requireArity(arguments.length, [0, 1], "schedule");
|
|
69
|
+
action = __boundary(action);
|
|
70
|
+
delay = __boundary(delay);
|
|
71
|
+
return __normalize(this.#host.schedule(action, delay));
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
cancelTimer(timer) {
|
|
75
|
+
__requireArity(arguments.length, [0], "cancelTimer");
|
|
76
|
+
timer = __boundary(timer);
|
|
77
|
+
__normalize(this.#host.cancelTimer(timer));
|
|
78
|
+
return null;
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
checkUrl(url) {
|
|
82
|
+
__requireArity(arguments.length, [0], "checkUrl");
|
|
83
|
+
url = __boundary(url);
|
|
84
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isString(url))) || __requireBoolean(__normalize(url.trim()) === ""))) {
|
|
85
|
+
throw "UI request requires a URL";
|
|
86
|
+
}
|
|
87
|
+
let target = new (__hostGlobal(["URL"]))(url, __normalize(this.#host.location.href));
|
|
88
|
+
if (__requireBoolean(__normalize(target.origin) !== __normalize(this.#host.location.origin))) {
|
|
89
|
+
throw "UI requests must use the current origin";
|
|
90
|
+
}
|
|
91
|
+
return target;
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
error(form, error, code = "UiFailure", name = null) {
|
|
95
|
+
__requireArity(arguments.length, [0, 1], "error");
|
|
96
|
+
form = __boundary(form);
|
|
97
|
+
error = __boundary(error);
|
|
98
|
+
code = __boundary(code);
|
|
99
|
+
name = __boundary(name);
|
|
100
|
+
if (__requireBoolean(__requireBoolean(form !== null) && __requireBoolean(__normalize(form.requestForm) !== null))) {
|
|
101
|
+
form = __normalize(form.requestForm);
|
|
102
|
+
}
|
|
103
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.#disposed)) || __requireBoolean(form === null)) || __requireBoolean(__normalize(form.disposed)))) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
__normalize(this.renderer.reportError(form, error));
|
|
107
|
+
if (__requireBoolean(__normalize(this.reporter) !== null)) {
|
|
108
|
+
__normalize(this.reporter.capture("ui", code, name, form));
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
saveToken(token) {
|
|
114
|
+
__requireArity(arguments.length, [0], "saveToken");
|
|
115
|
+
token = __boundary(token);
|
|
116
|
+
try {
|
|
117
|
+
__normalize(this.#host.storage.setItem("lango.token", token));
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
clearSavedToken() {
|
|
125
|
+
try {
|
|
126
|
+
__normalize(this.#host.storage.removeItem("lango.token"));
|
|
127
|
+
return true;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
post(url, input, token) {
|
|
134
|
+
__requireArity(arguments.length, [0, 1, 2], "post");
|
|
135
|
+
url = __boundary(url);
|
|
136
|
+
input = __boundary(input);
|
|
137
|
+
token = __boundary(token);
|
|
138
|
+
return this.request(url, input, token);
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
poll(url, input, token, signal) {
|
|
142
|
+
__requireArity(arguments.length, [0, 1, 2, 3], "poll");
|
|
143
|
+
url = __boundary(url);
|
|
144
|
+
input = __boundary(input);
|
|
145
|
+
token = __boundary(token);
|
|
146
|
+
signal = __boundary(signal);
|
|
147
|
+
return this.request(url, input, token, signal, true);
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
request(url, input, token, signal = null, channel = false, opening = false) {
|
|
151
|
+
__requireArity(arguments.length, [0, 1, 2], "request");
|
|
152
|
+
url = __boundary(url);
|
|
153
|
+
input = __boundary(input);
|
|
154
|
+
token = __boundary(token);
|
|
155
|
+
signal = __boundary(signal);
|
|
156
|
+
channel = __boundary(channel);
|
|
157
|
+
opening = __boundary(opening);
|
|
158
|
+
let target = this.checkUrl(url);
|
|
159
|
+
let headers = { "Content-Type": "application/json" };
|
|
160
|
+
headers["X-Lango-Screen"] = "wide";
|
|
161
|
+
if (__requireBoolean(__normalize(this.#host.screen) !== null)) {
|
|
162
|
+
headers["X-Lango-Screen"] = __normalize(this.#host.screen());
|
|
163
|
+
}
|
|
164
|
+
if (__requireBoolean(token !== null)) {
|
|
165
|
+
headers.Authorization = `Bearer ${token}`;
|
|
166
|
+
}
|
|
167
|
+
let options = { method: "POST", headers: headers, body: __toJson(input) };
|
|
168
|
+
if (__requireBoolean(signal !== null)) {
|
|
169
|
+
options.signal = signal;
|
|
170
|
+
}
|
|
171
|
+
return __normalize(this.#host.fetch(`${__normalize(target.pathname)}${__normalize(target.search)}`, options)).then(__withArity((res) => {
|
|
172
|
+
res = __boundary(res);
|
|
173
|
+
if (__requireBoolean(!__requireBoolean(__normalize(res.ok)))) {
|
|
174
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(opening) && __requireBoolean(__normalize(res.status) === 401)) && __requireBoolean(token !== null))) {
|
|
175
|
+
if (__requireBoolean(this.clearSavedToken())) {
|
|
176
|
+
throw new (__hostGlobal(["Error"]))("Startup HTTP 401: saved token was rejected and cleared. Reload the page to start a new session.");
|
|
177
|
+
}
|
|
178
|
+
throw new (__hostGlobal(["Error"]))("Startup HTTP 401: saved token was rejected but storage could not be cleared. Clear this site's local storage and reload.");
|
|
179
|
+
}
|
|
180
|
+
if (__requireBoolean(!__requireBoolean(channel))) {
|
|
181
|
+
throw `HTTP ${__normalize(res.status)}`;
|
|
182
|
+
}
|
|
183
|
+
if (__requireBoolean(__normalize(res.status) !== 409)) {
|
|
184
|
+
return { status: __normalize(res.status), retryAfter: __normalize(res.headers.get("retry-after")) };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return __normalize(res.json()).then(__withArity((body) => {
|
|
188
|
+
body = __boundary(body);
|
|
189
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(body))) || __requireBoolean(__isArray(body)))) {
|
|
190
|
+
if (__requireBoolean(channel)) {
|
|
191
|
+
throw { code: "InvalidPollResponse" };
|
|
192
|
+
}
|
|
193
|
+
throw "UI response must be a map";
|
|
194
|
+
}
|
|
195
|
+
let status = __normalize(res.status);
|
|
196
|
+
if (__requireBoolean(status === null)) {
|
|
197
|
+
status = 200;
|
|
198
|
+
}
|
|
199
|
+
return { status: status, token: __normalize(res.headers.get("x-lango-token")), body: body };
|
|
200
|
+
return null;
|
|
201
|
+
}, [0], "closure")).catch(__withArity((error) => {
|
|
202
|
+
error = __boundary(error);
|
|
203
|
+
if (__requireBoolean(channel)) {
|
|
204
|
+
throw { code: "InvalidPollResponse" };
|
|
205
|
+
}
|
|
206
|
+
throw error;
|
|
207
|
+
return null;
|
|
208
|
+
}, [0], "closure"));
|
|
209
|
+
return null;
|
|
210
|
+
}, [0], "closure"));
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
start() {
|
|
214
|
+
let token = null;
|
|
215
|
+
try {
|
|
216
|
+
token = __normalize(this.#host.storage.getItem("lango.token"));
|
|
217
|
+
} catch (error) {
|
|
218
|
+
token = null;
|
|
219
|
+
}
|
|
220
|
+
return this.request("/", { }, token, null, false, true).then(__withArity((packet) => {
|
|
221
|
+
packet = __boundary(packet);
|
|
222
|
+
this.#events = __normalize(packet.body);
|
|
223
|
+
if (__requireBoolean(__normalize(this.#events.clientErrorUrl) !== null)) {
|
|
224
|
+
this.reporter = new ErrorReporter(this, __normalize(this.#events.clientErrorUrl));
|
|
225
|
+
}
|
|
226
|
+
if (__requireBoolean(__normalize(this.#events.pingUrl) !== null)) {
|
|
227
|
+
this.heartbeat = new Heartbeat(this, __normalize(this.#host), __normalize(this.#events.pingUrl));
|
|
228
|
+
}
|
|
229
|
+
this.root = new Form(this, null, __normalize(packet.token));
|
|
230
|
+
this.root.element = __normalize(this.#host.mount);
|
|
231
|
+
__normalize(this.root.setToken(__normalize(packet.token)));
|
|
232
|
+
return this.navigate(__normalize(this.#host.location.pathname), false).then(__withArity((ignored) => {
|
|
233
|
+
ignored = __boundary(ignored);
|
|
234
|
+
if (__requireBoolean(__normalize(this.heartbeat) !== null)) {
|
|
235
|
+
__normalize(this.heartbeat.start());
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
return null;
|
|
239
|
+
}, [0], "closure"));
|
|
240
|
+
return null;
|
|
241
|
+
}, [0], "closure"));
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
send(form, url, owner = null) {
|
|
245
|
+
__requireArity(arguments.length, [0, 1], "send");
|
|
246
|
+
form = __boundary(form);
|
|
247
|
+
url = __boundary(url);
|
|
248
|
+
owner = __boundary(owner);
|
|
249
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#disposed)) || __requireBoolean(__normalize(form.disposed)))) {
|
|
250
|
+
return __normalize(__hostGlobal(["Promise"]).reject("Form is disposed"));
|
|
251
|
+
}
|
|
252
|
+
let pending = new (__hostGlobal(["Promise"]))(__withArity((resolve, reject) => {
|
|
253
|
+
resolve = __boundary(resolve);
|
|
254
|
+
reject = __boundary(reject);
|
|
255
|
+
__add(this.#queue, { kind: "send", form: form, url: url, owner: owner, resolve: resolve, reject: reject });
|
|
256
|
+
this.drain();
|
|
257
|
+
return null;
|
|
258
|
+
}, [0, 1], "closure"));
|
|
259
|
+
return pending;
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
deliver(form, action, owner, generation) {
|
|
263
|
+
__requireArity(arguments.length, [0, 1, 2, 3], "deliver");
|
|
264
|
+
form = __boundary(form);
|
|
265
|
+
action = __boundary(action);
|
|
266
|
+
owner = __boundary(owner);
|
|
267
|
+
generation = __boundary(generation);
|
|
268
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.#disposed)) || __requireBoolean(__normalize(form.disposed))) || __requireBoolean(!__requireBoolean(__normalize(owner.active))))) {
|
|
269
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
270
|
+
}
|
|
271
|
+
let deferred = __normalize(__hostGlobal(["Promise"]).withResolvers());
|
|
272
|
+
__add(this.#queue, { kind: "delivery", form: form, action: action, owner: owner, generation: generation, resolve: __normalize(deferred.resolve), reject: __normalize(deferred.reject) });
|
|
273
|
+
this.drain();
|
|
274
|
+
return __normalize(deferred.promise);
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
report(form, url, input, owner) {
|
|
278
|
+
__requireArity(arguments.length, [0, 1, 2, 3], "report");
|
|
279
|
+
form = __boundary(form);
|
|
280
|
+
url = __boundary(url);
|
|
281
|
+
input = __boundary(input);
|
|
282
|
+
owner = __boundary(owner);
|
|
283
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.#disposed)) || __requireBoolean(__normalize(form.disposed))) || __requireBoolean(!__requireBoolean(__normalize(owner.active))))) {
|
|
284
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
285
|
+
}
|
|
286
|
+
let deferred = __normalize(__hostGlobal(["Promise"]).withResolvers());
|
|
287
|
+
__add(this.#queue, { kind: "report", form: form, url: url, input: input, owner: owner, resolve: __normalize(deferred.resolve), reject: __normalize(deferred.reject) });
|
|
288
|
+
this.drain();
|
|
289
|
+
return __normalize(deferred.promise);
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
canPoll(form) {
|
|
293
|
+
__requireArity(arguments.length, [0], "canPoll");
|
|
294
|
+
form = __boundary(form);
|
|
295
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.#disposed)) || __requireBoolean(__normalize(form.disposed))) || __requireBoolean(__normalize(this.#pingJob) !== null))) {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
for (const job of __normalize(this.#active)) {
|
|
299
|
+
if (__requireBoolean(__normalize(form.related(__normalize(job.form))))) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
for (const job of __normalize(this.#queue)) {
|
|
304
|
+
if (__requireBoolean(__normalize(form.related(__normalize(job.form))))) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return true;
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
pausePolls(form = null) {
|
|
312
|
+
form = __boundary(form);
|
|
313
|
+
for (const candidate of __normalize(this.forms.slice())) {
|
|
314
|
+
if (__requireBoolean(__requireBoolean(form === null) || __requireBoolean(__normalize(form.related(candidate))))) {
|
|
315
|
+
__normalize(candidate.activity.pause());
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return null;
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
resumePolls() {
|
|
322
|
+
for (const form of __normalize(this.forms.slice())) {
|
|
323
|
+
__normalize(form.activity.resume());
|
|
324
|
+
}
|
|
325
|
+
return null;
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
drain() {
|
|
329
|
+
if (__requireBoolean(__normalize(this.#pingJob) !== null)) {
|
|
330
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#active.length) === 0) && __requireBoolean(!__requireBoolean(__normalize(this.#pingJob.running))))) {
|
|
331
|
+
this.#pingJob.running = true;
|
|
332
|
+
this.executePing(__normalize(this.#pingJob));
|
|
333
|
+
}
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
for (const job of __normalize(this.#queue.slice())) {
|
|
337
|
+
let blocked = false;
|
|
338
|
+
for (const running of __normalize(this.#active)) {
|
|
339
|
+
if (__requireBoolean(__normalize(job.form.related(__normalize(running.form))))) {
|
|
340
|
+
blocked = true;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
for (const earlier of __normalize(this.#queue)) {
|
|
344
|
+
if (__requireBoolean(earlier === job)) {
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
if (__requireBoolean(__normalize(job.form.related(__normalize(earlier.form))))) {
|
|
348
|
+
blocked = true;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (__requireBoolean(!__requireBoolean(blocked))) {
|
|
352
|
+
__normalize(this.#queue.splice(__normalize(this.#queue.indexOf(job)), 1));
|
|
353
|
+
__add(this.#active, job);
|
|
354
|
+
if (__requireBoolean(__normalize(job.kind) === "delivery")) {
|
|
355
|
+
this.executeDelivery(job);
|
|
356
|
+
} else {
|
|
357
|
+
this.pausePolls(__normalize(job.form));
|
|
358
|
+
this.execute(job);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
this.resumePolls();
|
|
363
|
+
return null;
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
executeDelivery(job) {
|
|
367
|
+
__requireArity(arguments.length, [0], "executeDelivery");
|
|
368
|
+
job = __boundary(job);
|
|
369
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity((ignored) => {
|
|
370
|
+
ignored = __boundary(ignored);
|
|
371
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(job.form.disposed)) && __requireBoolean(job.owner.active)) && __requireBoolean(job.owner.generation === __normalize(job.generation)))) {
|
|
372
|
+
let action = __normalize(job.action);
|
|
373
|
+
__call(action, );
|
|
374
|
+
}
|
|
375
|
+
__normalize(job.resolve(null));
|
|
376
|
+
return null;
|
|
377
|
+
}, [0], "closure")).catch(__withArity((error) => {
|
|
378
|
+
error = __boundary(error);
|
|
379
|
+
__normalize(job.reject(error));
|
|
380
|
+
return null;
|
|
381
|
+
}, [0], "closure")).finally(() => {
|
|
382
|
+
__normalize(this.#active.splice(__normalize(this.#active.indexOf(job)), 1));
|
|
383
|
+
this.drain();
|
|
384
|
+
return null;
|
|
385
|
+
});
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
ping() {
|
|
389
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#disposed)) || __requireBoolean(__normalize(this.heartbeat) === null))) {
|
|
390
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
391
|
+
}
|
|
392
|
+
if (__requireBoolean(__normalize(this.#pingJob) !== null)) {
|
|
393
|
+
return __normalize(this.#pingJob.promise);
|
|
394
|
+
}
|
|
395
|
+
let deferred = __normalize(__hostGlobal(["Promise"]).withResolvers());
|
|
396
|
+
this.#pingJob = { promise: __normalize(deferred.promise), resolve: __normalize(deferred.resolve), reject: __normalize(deferred.reject), running: false };
|
|
397
|
+
this.pausePolls();
|
|
398
|
+
this.drain();
|
|
399
|
+
return __normalize(deferred.promise);
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
executePing(job) {
|
|
403
|
+
__requireArity(arguments.length, [0], "executePing");
|
|
404
|
+
job = __boundary(job);
|
|
405
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity((ignored) => {
|
|
406
|
+
ignored = __boundary(ignored);
|
|
407
|
+
return __normalize(this.heartbeat.exchange());
|
|
408
|
+
return null;
|
|
409
|
+
}, [0], "closure")).then(__withArity((ignored) => {
|
|
410
|
+
ignored = __boundary(ignored);
|
|
411
|
+
__normalize(job.resolve(null));
|
|
412
|
+
return null;
|
|
413
|
+
}, [0], "closure")).catch(__withArity((error) => {
|
|
414
|
+
error = __boundary(error);
|
|
415
|
+
__normalize(job.reject(error));
|
|
416
|
+
return null;
|
|
417
|
+
}, [0], "closure")).finally(() => {
|
|
418
|
+
this.#pingJob = null;
|
|
419
|
+
this.drain();
|
|
420
|
+
return null;
|
|
421
|
+
});
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
execute(job) {
|
|
425
|
+
__requireArity(arguments.length, [0], "execute");
|
|
426
|
+
job = __boundary(job);
|
|
427
|
+
let form = __normalize(job.form);
|
|
428
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity((ignored) => {
|
|
429
|
+
ignored = __boundary(ignored);
|
|
430
|
+
if (__requireBoolean(__normalize(form.disposed))) {
|
|
431
|
+
throw "Form is disposed";
|
|
432
|
+
}
|
|
433
|
+
if (__requireBoolean(__requireBoolean(__normalize(job.owner) !== null) && __requireBoolean(!__requireBoolean(job.owner.active)))) {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
if (__requireBoolean(__normalize(job.kind) === "report")) {
|
|
437
|
+
return this.post(__normalize(job.url), __normalize(job.input), __normalize(form.token));
|
|
438
|
+
}
|
|
439
|
+
__normalize(form.clearValidation());
|
|
440
|
+
__normalize(this.renderer.waiting(form, true));
|
|
441
|
+
let ready = __normalize(form.prepareValue());
|
|
442
|
+
if (__requireBoolean(ready === null)) {
|
|
443
|
+
return this.post(__normalize(job.url), __normalize(form.getValue()), __normalize(form.token));
|
|
444
|
+
}
|
|
445
|
+
return ready.then(__withArity((ignored) => {
|
|
446
|
+
ignored = __boundary(ignored);
|
|
447
|
+
if (__requireBoolean(__normalize(form.disposed))) {
|
|
448
|
+
throw "Form is disposed";
|
|
449
|
+
}
|
|
450
|
+
if (__requireBoolean(__requireBoolean(__normalize(job.owner) !== null) && __requireBoolean(!__requireBoolean(job.owner.active)))) {
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
return this.post(__normalize(job.url), __normalize(form.getValue()), __normalize(form.token));
|
|
454
|
+
return null;
|
|
455
|
+
}, [0], "closure"));
|
|
456
|
+
return null;
|
|
457
|
+
}, [0], "closure")).then(__withArity((packet) => {
|
|
458
|
+
packet = __boundary(packet);
|
|
459
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(packet !== null) && __requireBoolean(!__requireBoolean(__normalize(form.disposed)))) && __requireBoolean(__requireBoolean(__normalize(job.owner) === null) || __requireBoolean(job.owner.active)))) {
|
|
460
|
+
if (__requireBoolean(__normalize(job.kind) === "report")) {
|
|
461
|
+
__normalize(form.setToken(__normalize(packet.token)));
|
|
462
|
+
} else {
|
|
463
|
+
__normalize(form.handle(packet));
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return null;
|
|
467
|
+
}, [0], "closure")).then(__withArity((ignored) => {
|
|
468
|
+
ignored = __boundary(ignored);
|
|
469
|
+
__normalize(job.resolve(null));
|
|
470
|
+
return null;
|
|
471
|
+
}, [0], "closure")).catch(__withArity((error) => {
|
|
472
|
+
error = __boundary(error);
|
|
473
|
+
__normalize(job.reject(error));
|
|
474
|
+
return null;
|
|
475
|
+
}, [0], "closure")).finally(() => {
|
|
476
|
+
if (__requireBoolean(__normalize(job.kind) === "send")) {
|
|
477
|
+
__normalize(this.renderer.waiting(form, false));
|
|
478
|
+
}
|
|
479
|
+
__normalize(this.#active.splice(__normalize(this.#active.indexOf(job)), 1));
|
|
480
|
+
this.drain();
|
|
481
|
+
return null;
|
|
482
|
+
});
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
navigate(url, push = true) {
|
|
486
|
+
__requireArity(arguments.length, [0], "navigate");
|
|
487
|
+
url = __boundary(url);
|
|
488
|
+
push = __boundary(push);
|
|
489
|
+
let target = new (__hostGlobal(["URL"]))(url, __normalize(this.#host.location.href));
|
|
490
|
+
if (__requireBoolean(__normalize(target.origin) !== __normalize(this.#host.location.origin))) {
|
|
491
|
+
throw "UI navigation must use the current origin";
|
|
492
|
+
}
|
|
493
|
+
let path = __normalize(target.pathname);
|
|
494
|
+
if (__requireBoolean(path === "/")) {
|
|
495
|
+
path = "/index";
|
|
496
|
+
}
|
|
497
|
+
let template = this.selectTemplate(path);
|
|
498
|
+
let ready = __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
499
|
+
if (__requireBoolean(template !== __normalize(this.#template))) {
|
|
500
|
+
if (__requireBoolean(template !== null)) {
|
|
501
|
+
ready = __normalize(this.root.send(template));
|
|
502
|
+
} else {
|
|
503
|
+
this.#template = null;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return ready.then(__withArity((ignored) => {
|
|
507
|
+
ignored = __boundary(ignored);
|
|
508
|
+
this.#template = template;
|
|
509
|
+
let form = __normalize(this.root);
|
|
510
|
+
if (__requireBoolean(template !== null)) {
|
|
511
|
+
form = __normalize(this.root.find("__content__"));
|
|
512
|
+
if (__requireBoolean(!__requireBoolean(__isKindof(form, Form)))) {
|
|
513
|
+
throw "Template requires a __content__ form";
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return __normalize(form.send(path));
|
|
517
|
+
return null;
|
|
518
|
+
}, [0], "closure")).then(__withArity((ignored) => {
|
|
519
|
+
ignored = __boundary(ignored);
|
|
520
|
+
if (__requireBoolean(push)) {
|
|
521
|
+
__normalize(this.#host.history.pushState(null, "", `${__normalize(target.pathname)}${__normalize(target.search)}${__normalize(target.hash)}`));
|
|
522
|
+
}
|
|
523
|
+
if (__requireBoolean(__normalize(this.renderer.locationChanged) !== null)) {
|
|
524
|
+
__normalize(this.renderer.locationChanged(__normalize(target.href)));
|
|
525
|
+
}
|
|
526
|
+
return null;
|
|
527
|
+
return null;
|
|
528
|
+
}, [0], "closure"));
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
selectTemplate(path) {
|
|
532
|
+
__requireArity(arguments.length, [0], "selectTemplate");
|
|
533
|
+
path = __boundary(path);
|
|
534
|
+
let urls = __normalize(this.#events.templates);
|
|
535
|
+
if (__requireBoolean(urls === null)) {
|
|
536
|
+
urls = [];
|
|
537
|
+
}
|
|
538
|
+
let selected = __normalize(this.#events.defaultTemplate);
|
|
539
|
+
if (__requireBoolean(path === selected)) {
|
|
540
|
+
throw "Template URLs cannot be used as page URLs";
|
|
541
|
+
}
|
|
542
|
+
let best = 0;
|
|
543
|
+
for (const url of urls) {
|
|
544
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isString(url))) || __requireBoolean(!__requireBoolean(__normalize(url.startsWith("/"))))) || __requireBoolean(url === "/")) || __requireBoolean(__normalize(url.endsWith("/"))))) {
|
|
545
|
+
throw "Invalid template URL";
|
|
546
|
+
}
|
|
547
|
+
if (__requireBoolean(path === url)) {
|
|
548
|
+
throw "Template URLs cannot be used as page URLs";
|
|
549
|
+
}
|
|
550
|
+
if (__requireBoolean(__requireBoolean(path === url) || __requireBoolean(__normalize(path.startsWith(`${url}/`))))) {
|
|
551
|
+
if (__requireBoolean(__normalize(url.length) > best)) {
|
|
552
|
+
selected = url;
|
|
553
|
+
best = __normalize(url.length);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (__requireBoolean(path === selected)) {
|
|
558
|
+
throw "Template URLs cannot be used as page URLs";
|
|
559
|
+
}
|
|
560
|
+
return selected;
|
|
561
|
+
return null;
|
|
562
|
+
}
|
|
563
|
+
command(form, cmd) {
|
|
564
|
+
__requireArity(arguments.length, [0, 1], "command");
|
|
565
|
+
form = __boundary(form);
|
|
566
|
+
cmd = __boundary(cmd);
|
|
567
|
+
if (__normalize(cmd.type) === "values") {
|
|
568
|
+
__normalize(form.setValue(__normalize(cmd.values)));
|
|
569
|
+
} else if (__normalize(cmd.type) === "addRow") {
|
|
570
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).addRow(__normalize(cmd.value)));
|
|
571
|
+
} else if (__normalize(cmd.type) === "insertRow") {
|
|
572
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).insertRow(__normalize(cmd.beforeIndex), __normalize(cmd.value)));
|
|
573
|
+
} else if (__normalize(cmd.type) === "deleteRow") {
|
|
574
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).deleteRow(__normalize(cmd.index)));
|
|
575
|
+
} else if (__normalize(cmd.type) === "setRowValue") {
|
|
576
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setRowValue(__normalize(cmd.index), __normalize(cmd.value)));
|
|
577
|
+
} else if (__normalize(cmd.type) === "setRowData") {
|
|
578
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setRowData(__normalize(cmd.index), __normalize(cmd.value)));
|
|
579
|
+
} else if (__normalize(cmd.type) === "setCellValue") {
|
|
580
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setCellValue(__normalize(cmd.index), __normalize(cmd.column), __normalize(cmd.value)));
|
|
581
|
+
} else if (__normalize(cmd.type) === "invalid") {
|
|
582
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setInvalid(__normalize(cmd.message)));
|
|
583
|
+
} else if (__normalize(cmd.type) === "set") {
|
|
584
|
+
let targetForm = __normalize(form.find(__normalize(cmd.name)));
|
|
585
|
+
if (__requireBoolean(!__requireBoolean(__isKindof(targetForm, Form)))) {
|
|
586
|
+
throw "Set requires a form target";
|
|
587
|
+
}
|
|
588
|
+
__normalize(this.renderer.show(targetForm, __normalize(cmd.control)));
|
|
589
|
+
} else if (__normalize(cmd.type) === "setUrl") {
|
|
590
|
+
let target = new (__hostGlobal(["URL"]))(__normalize(cmd.url), __normalize(this.#host.location.href));
|
|
591
|
+
if (__requireBoolean(__normalize(target.origin) !== __normalize(this.#host.location.origin))) {
|
|
592
|
+
throw "UI URL must use the current origin";
|
|
593
|
+
}
|
|
594
|
+
__normalize(this.#host.history.pushState(null, "", `${__normalize(target.pathname)}${__normalize(target.search)}${__normalize(target.hash)}`));
|
|
595
|
+
if (__requireBoolean(__normalize(this.renderer.locationChanged) !== null)) {
|
|
596
|
+
__normalize(this.renderer.locationChanged(__normalize(target.href)));
|
|
597
|
+
}
|
|
598
|
+
} else if (__normalize(cmd.type) === "redirect") {
|
|
599
|
+
let action = () => {
|
|
600
|
+
this.navigate(__normalize(cmd.url)).catch(__withArity((problem) => {
|
|
601
|
+
problem = __boundary(problem);
|
|
602
|
+
this.error(form, problem);
|
|
603
|
+
return null;
|
|
604
|
+
}, [0], "closure"));
|
|
605
|
+
return null;
|
|
606
|
+
};
|
|
607
|
+
__normalize(this.#host.defer(action));
|
|
608
|
+
} else if (__normalize(cmd.type) === "disable") {
|
|
609
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setDisabled(true));
|
|
610
|
+
} else if (__normalize(cmd.type) === "enable") {
|
|
611
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setDisabled(false));
|
|
612
|
+
} else if (__normalize(cmd.type) === "changeCaption") {
|
|
613
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setCaption(__normalize(cmd.caption)));
|
|
614
|
+
} else if (__normalize(cmd.type) === "activateTabItem") {
|
|
615
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).activate());
|
|
616
|
+
} else if (__normalize(cmd.type) === "setProgress") {
|
|
617
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setRange(__normalize(cmd.min), __normalize(cmd.max), __normalize(cmd.value)));
|
|
618
|
+
} else if (__normalize(cmd.type) === "updateProgress") {
|
|
619
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).update(__normalize(cmd.value), __normalize(cmd.label)));
|
|
620
|
+
} else if (__normalize(cmd.type) === "showAlert") {
|
|
621
|
+
__normalize(this.renderer.presentations.showAlert(form, cmd));
|
|
622
|
+
} else if (__normalize(cmd.type) === "dismissAlert") {
|
|
623
|
+
__normalize(this.renderer.presentations.dismissAlert(form, __normalize(cmd.name)));
|
|
624
|
+
} else if (__normalize(cmd.type) === "showToast") {
|
|
625
|
+
__normalize(this.renderer.presentations.showToast(form, __normalize(cmd.toast), __normalize(cmd.stack)));
|
|
626
|
+
} else if (__normalize(cmd.type) === "showDialog") {
|
|
627
|
+
__normalize(this.renderer.presentations.showDialog(form, __normalize(cmd.dialog), __normalize(cmd.keepPrev)));
|
|
628
|
+
} else if (__normalize(cmd.type) === "swapDialog") {
|
|
629
|
+
__normalize(this.renderer.presentations.swapDialog(form));
|
|
630
|
+
} else if (__normalize(cmd.type) === "setTimer") {
|
|
631
|
+
__normalize(form.activity.timer(__normalize(cmd.url), __normalize(cmd.interval)));
|
|
632
|
+
} else if (__normalize(cmd.type) === "clearTimer") {
|
|
633
|
+
__normalize(form.activity.clearTimer(__normalize(cmd.url)));
|
|
634
|
+
} else if (__normalize(cmd.type) === "setInterval") {
|
|
635
|
+
__normalize(form.activity.timer(__normalize(cmd.url), __normalize(cmd.interval), true));
|
|
636
|
+
} else if (__normalize(cmd.type) === "clearInterval") {
|
|
637
|
+
__normalize(form.activity.clearTimer(__normalize(cmd.url), true));
|
|
638
|
+
} else if (__normalize(cmd.type) === "startLongPoll") {
|
|
639
|
+
__normalize(form.activity.startLongPoll(__normalize(cmd.url), __normalize(cmd.key), __normalize(cmd.cursor)));
|
|
640
|
+
} else if (__normalize(cmd.type) === "stopLongPoll") {
|
|
641
|
+
__normalize(form.activity.stopLongPoll(__normalize(cmd.url), __normalize(cmd.key)));
|
|
642
|
+
} else {
|
|
643
|
+
throw `Unsupported UI command: ${__normalize(cmd.type)}`;
|
|
644
|
+
}
|
|
645
|
+
return null;
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
dispose() {
|
|
649
|
+
this.#disposed = true;
|
|
650
|
+
if (__requireBoolean(__normalize(this.heartbeat) !== null)) {
|
|
651
|
+
__normalize(this.heartbeat.dispose());
|
|
652
|
+
}
|
|
653
|
+
if (__requireBoolean(__normalize(this.reporter) !== null)) {
|
|
654
|
+
__normalize(this.reporter.dispose());
|
|
655
|
+
}
|
|
656
|
+
for (const form of __normalize(this.forms.slice())) {
|
|
657
|
+
__normalize(form.dispose());
|
|
658
|
+
}
|
|
659
|
+
for (const job of __normalize(this.#queue)) {
|
|
660
|
+
__normalize(job.reject("Application is disposed"));
|
|
661
|
+
}
|
|
662
|
+
this.#queue = [];
|
|
663
|
+
for (const release of __normalize(this.resources)) {
|
|
664
|
+
__call(release, );
|
|
665
|
+
}
|
|
666
|
+
this.resources = [];
|
|
667
|
+
return null;
|
|
668
|
+
return null;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
//# sourceMappingURL=app.mjs.map
|