@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/application.mjs
DELETED
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
import { mount, Renderer, Binding, Types } from "./library.mjs";
|
|
2
|
-
import { Session } from "./session.mjs";
|
|
3
|
-
import { browserTokenStore } from "./tokens.mjs";
|
|
4
|
-
import { Heartbeat } from "./heartbeat.mjs";
|
|
5
|
-
import { inheritedControls, inheritanceResources } from "./inheritance.mjs";
|
|
6
|
-
import { Coordinator } from "./coordinator.mjs";
|
|
7
|
-
import {
|
|
8
|
-
hostGlobal as __hostGlobal,
|
|
9
|
-
fromJson as __fromJson,
|
|
10
|
-
toJson as __toJson,
|
|
11
|
-
isNumber as __isNumber,
|
|
12
|
-
isString as __isString,
|
|
13
|
-
isBool as __isBool,
|
|
14
|
-
isObject as __isObject,
|
|
15
|
-
isArray as __isArray,
|
|
16
|
-
add as __add,
|
|
17
|
-
requireBoolean as __requireBoolean,
|
|
18
|
-
normalize as __normalize,
|
|
19
|
-
boundary as __boundary,
|
|
20
|
-
requireArity as __requireArity,
|
|
21
|
-
withArity as __withArity,
|
|
22
|
-
} from "./.lango/runtime.mjs";
|
|
23
|
-
|
|
24
|
-
export class Application {
|
|
25
|
-
control;
|
|
26
|
-
#renderer;
|
|
27
|
-
#transport;
|
|
28
|
-
#errors;
|
|
29
|
-
#tokens;
|
|
30
|
-
#pageToken;
|
|
31
|
-
#bindings;
|
|
32
|
-
#coordinator;
|
|
33
|
-
#disposed;
|
|
34
|
-
#window;
|
|
35
|
-
#unload;
|
|
36
|
-
#paused;
|
|
37
|
-
#logout;
|
|
38
|
-
#revoked;
|
|
39
|
-
#restartToken;
|
|
40
|
-
#bootstrapPath;
|
|
41
|
-
#logoutPath;
|
|
42
|
-
#heartbeat;
|
|
43
|
-
#pingEnabled;
|
|
44
|
-
#heartbeatOptions;
|
|
45
|
-
constructor(document, root, definition, options = null) {
|
|
46
|
-
__requireArity(arguments.length, [0, 1, 2], "constructor");
|
|
47
|
-
document = __boundary(document);
|
|
48
|
-
root = __boundary(root);
|
|
49
|
-
definition = __boundary(definition);
|
|
50
|
-
options = __boundary(options);
|
|
51
|
-
if (__requireBoolean(options === null)) {
|
|
52
|
-
options = { };
|
|
53
|
-
}
|
|
54
|
-
let types = __normalize(options.types);
|
|
55
|
-
if (__requireBoolean(types === null)) {
|
|
56
|
-
types = new Types();
|
|
57
|
-
}
|
|
58
|
-
this.control = mount(document, root, definition, types);
|
|
59
|
-
this.#renderer = new Renderer(document, types);
|
|
60
|
-
this.#transport = __normalize(options.transport);
|
|
61
|
-
this.#errors = __normalize(options.errors);
|
|
62
|
-
this.#tokens = __normalize(options.tokens);
|
|
63
|
-
if (__requireBoolean(__normalize(this.#tokens) === null)) {
|
|
64
|
-
let key = __normalize(options.storageKey);
|
|
65
|
-
if (__requireBoolean(key === null)) {
|
|
66
|
-
key = "lango:last-token";
|
|
67
|
-
}
|
|
68
|
-
this.#tokens = browserTokenStore(key);
|
|
69
|
-
}
|
|
70
|
-
if (__requireBoolean(__normalize(options.bootstrapPath) !== null)) {
|
|
71
|
-
__normalize(this.#tokens.initialize(__normalize(options.bootstrapPath)));
|
|
72
|
-
}
|
|
73
|
-
this.#pageToken = __normalize(this.#tokens.latest());
|
|
74
|
-
this.#bindings = [];
|
|
75
|
-
this.#coordinator = new Coordinator();
|
|
76
|
-
this.#disposed = false;
|
|
77
|
-
this.#window = __normalize(options.window);
|
|
78
|
-
this.#unload = null;
|
|
79
|
-
this.#paused = false;
|
|
80
|
-
this.#logout = null;
|
|
81
|
-
this.#revoked = false;
|
|
82
|
-
this.#restartToken = null;
|
|
83
|
-
this.#bootstrapPath = __normalize(options.bootstrapPath);
|
|
84
|
-
if (__requireBoolean(__normalize(this.#bootstrapPath) === null)) {
|
|
85
|
-
this.#bootstrapPath = "/_lango/start";
|
|
86
|
-
}
|
|
87
|
-
this.#logoutPath = __normalize(options.logoutPath);
|
|
88
|
-
if (__requireBoolean(__normalize(this.#logoutPath) === null)) {
|
|
89
|
-
this.#logoutPath = "/_lango/logout";
|
|
90
|
-
}
|
|
91
|
-
this.#heartbeat = null;
|
|
92
|
-
let pingEnabled = __normalize(options.pingEnabled);
|
|
93
|
-
if (__requireBoolean(pingEnabled === null)) {
|
|
94
|
-
pingEnabled = __requireBoolean(__normalize(options.bootstrapPath) !== null) || __requireBoolean(__normalize(options.pingPath) !== null);
|
|
95
|
-
}
|
|
96
|
-
if (__requireBoolean(!__requireBoolean(__isBool(pingEnabled)))) {
|
|
97
|
-
throw "UiPingEnabledMustBeBoolean";
|
|
98
|
-
}
|
|
99
|
-
this.#pingEnabled = pingEnabled;
|
|
100
|
-
this.#heartbeatOptions = { path: __normalize(options.pingPath), idleMs: __normalize(options.pingIdleMs), transport: __normalize(options.pingTransport) };
|
|
101
|
-
this.createHeartbeat();
|
|
102
|
-
this.reconcile();
|
|
103
|
-
if (__requireBoolean(__normalize(this.#heartbeat) !== null)) {
|
|
104
|
-
__normalize(this.#heartbeat.start());
|
|
105
|
-
observeStartup(__normalize(this.#heartbeat), __normalize(this.#tokens));
|
|
106
|
-
}
|
|
107
|
-
if (__requireBoolean(__normalize(this.#window) !== null)) {
|
|
108
|
-
let unload = __withArity((event) => {
|
|
109
|
-
event = __boundary(event);
|
|
110
|
-
if (__requireBoolean(this.isDirty())) {
|
|
111
|
-
__normalize(event.preventDefault());
|
|
112
|
-
event.returnValue = "";
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
}, [0], "closure");
|
|
116
|
-
this.#unload = unload;
|
|
117
|
-
__normalize(this.#window.addEventListener("beforeunload", unload));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
createHeartbeat() {
|
|
121
|
-
if (__requireBoolean(__normalize(this.#pingEnabled))) {
|
|
122
|
-
this.#heartbeat = new Heartbeat(__normalize(this.#heartbeatOptions));
|
|
123
|
-
}
|
|
124
|
-
return null;
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
session(formId) {
|
|
128
|
-
__requireArity(arguments.length, [0], "session");
|
|
129
|
-
formId = __boundary(formId);
|
|
130
|
-
let id = formId;
|
|
131
|
-
if (__requireBoolean(__isArray(formId))) {
|
|
132
|
-
id = managedFormId(formId);
|
|
133
|
-
}
|
|
134
|
-
for (const entry of __normalize(this.#bindings)) {
|
|
135
|
-
if (__requireBoolean(__normalize(entry.formId) === id)) {
|
|
136
|
-
return __normalize(entry.session);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
reconcile() {
|
|
143
|
-
if (__requireBoolean(__requireBoolean(__normalize(this.#disposed)) || __requireBoolean(__normalize(this.#paused)))) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
let forms = [];
|
|
147
|
-
collectForms(__normalize(this.control), [], forms);
|
|
148
|
-
for (const form of forms) {
|
|
149
|
-
form.resources = inheritanceResources(__normalize(form.path), __normalize(form.parentPath), form.control.inherit);
|
|
150
|
-
}
|
|
151
|
-
let retained = [];
|
|
152
|
-
for (const entry of __normalize(this.#bindings)) {
|
|
153
|
-
if (__requireBoolean(retainsForm(forms, entry))) {
|
|
154
|
-
retained.push(entry);
|
|
155
|
-
} else {
|
|
156
|
-
__normalize(entry.binding.dispose());
|
|
157
|
-
__normalize(entry.session.dispose());
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
this.#bindings = retained;
|
|
161
|
-
for (const form of forms) {
|
|
162
|
-
if (__requireBoolean(!__requireBoolean(containsForm(__normalize(this.#bindings), __normalize(form.control))))) {
|
|
163
|
-
let session = new Session({ formId: __normalize(form.formId), controls: form.control.controls, root: form.control.element, effects: __normalize(this.#renderer), transport: __normalize(this.#transport), lifecycle: this, tokens: __normalize(this.#tokens), heartbeat: __normalize(this.#heartbeat), coordinator: __normalize(this.#coordinator), resources: __normalize(form.resources), form: __normalize(form.control), parent: __normalize(form.parent), window: __normalize(this.#window), seedFromBootstrap: true, seedToken: __normalize(this.#pageToken) });
|
|
164
|
-
let binding = new Binding(__normalize(form.control), session, __normalize(this.#errors));
|
|
165
|
-
__add(this.#bindings, { formId: __normalize(form.formId), control: __normalize(form.control), parent: __normalize(form.parent), session: session, binding: binding });
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (__requireBoolean(__normalize(this.#heartbeat) !== null)) {
|
|
169
|
-
let sessions = [];
|
|
170
|
-
for (const entry of __normalize(this.#bindings)) {
|
|
171
|
-
sessions.push(__normalize(entry.session));
|
|
172
|
-
}
|
|
173
|
-
__normalize(this.#heartbeat.sessions(sessions));
|
|
174
|
-
}
|
|
175
|
-
return null;
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
controlsFor(form) {
|
|
179
|
-
__requireArity(arguments.length, [0], "controlsFor");
|
|
180
|
-
form = __boundary(form);
|
|
181
|
-
for (const entry of __normalize(this.#bindings)) {
|
|
182
|
-
if (__requireBoolean(__normalize(entry.control) === form)) {
|
|
183
|
-
return inheritedControls(form, __normalize(entry.parent));
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
throw "UiSessionDisposed";
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
dispose() {
|
|
190
|
-
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
this.#disposed = true;
|
|
194
|
-
if (__requireBoolean(__normalize(this.#window) !== null)) {
|
|
195
|
-
__normalize(this.#window.removeEventListener("beforeunload", __normalize(this.#unload)));
|
|
196
|
-
}
|
|
197
|
-
if (__requireBoolean(__requireBoolean(__normalize(this.#paused)) && __requireBoolean(__normalize(this.#tokens.cancelInitialization) !== null))) {
|
|
198
|
-
__normalize(this.#tokens.cancelInitialization());
|
|
199
|
-
}
|
|
200
|
-
if (__requireBoolean(__normalize(this.#heartbeat) !== null)) {
|
|
201
|
-
__normalize(this.#heartbeat.dispose());
|
|
202
|
-
}
|
|
203
|
-
for (const entry of __normalize(this.#bindings)) {
|
|
204
|
-
__normalize(entry.binding.dispose());
|
|
205
|
-
__normalize(entry.session.dispose());
|
|
206
|
-
}
|
|
207
|
-
this.#bindings = [];
|
|
208
|
-
__normalize(this.#renderer.release(__normalize(this.control)));
|
|
209
|
-
return null;
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
isDirty() {
|
|
213
|
-
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
for (const entry of __normalize(this.#bindings)) {
|
|
217
|
-
if (__requireBoolean(__normalize(entry.session.isDirty()))) {
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return false;
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
confirmDiscard(window) {
|
|
225
|
-
__requireArity(arguments.length, [0], "confirmDiscard");
|
|
226
|
-
window = __boundary(window);
|
|
227
|
-
if (__requireBoolean(!__requireBoolean(this.isDirty()))) {
|
|
228
|
-
return true;
|
|
229
|
-
}
|
|
230
|
-
return __normalize(window.confirm("You have unsaved changes. Discard them?"));
|
|
231
|
-
return null;
|
|
232
|
-
}
|
|
233
|
-
logout() {
|
|
234
|
-
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
235
|
-
throw "UiApplicationDisposed";
|
|
236
|
-
}
|
|
237
|
-
if (__requireBoolean(__normalize(this.#logout) !== null)) {
|
|
238
|
-
return __normalize(this.#logout);
|
|
239
|
-
}
|
|
240
|
-
if (__requireBoolean(__requireBoolean(__normalize(this.#tokens.logout) === null) || __requireBoolean(__normalize(this.#tokens.cancelInitialization) === null))) {
|
|
241
|
-
throw "UiLogoutRequiresTokenStore";
|
|
242
|
-
}
|
|
243
|
-
this.pause();
|
|
244
|
-
let ready = __normalize(__hostGlobal(["Promise"]).resolve());
|
|
245
|
-
let revoked = __normalize(ready.then(() => {
|
|
246
|
-
return this.revokeSession();
|
|
247
|
-
return null;
|
|
248
|
-
}));
|
|
249
|
-
let restarted = __normalize(revoked.then(() => {
|
|
250
|
-
return this.restartAnonymous();
|
|
251
|
-
return null;
|
|
252
|
-
}));
|
|
253
|
-
let work = __normalize(restarted.then(__withArity((token) => {
|
|
254
|
-
token = __boundary(token);
|
|
255
|
-
return this.resume(token);
|
|
256
|
-
return null;
|
|
257
|
-
}, [0], "closure")));
|
|
258
|
-
let pending = __normalize(work.finally(() => {
|
|
259
|
-
this.finishLogout();
|
|
260
|
-
return null;
|
|
261
|
-
}));
|
|
262
|
-
this.#logout = pending;
|
|
263
|
-
return pending;
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
pause() {
|
|
267
|
-
this.#paused = true;
|
|
268
|
-
if (__requireBoolean(__normalize(this.#heartbeat) !== null)) {
|
|
269
|
-
__normalize(this.#heartbeat.dispose());
|
|
270
|
-
}
|
|
271
|
-
for (const entry of __normalize(this.#bindings)) {
|
|
272
|
-
__normalize(entry.binding.dispose());
|
|
273
|
-
__normalize(entry.session.dispose());
|
|
274
|
-
}
|
|
275
|
-
this.#bindings = [];
|
|
276
|
-
this.control.element.inert = true;
|
|
277
|
-
__normalize(this.control.element.setAttribute("aria-busy", "true"));
|
|
278
|
-
return null;
|
|
279
|
-
return null;
|
|
280
|
-
}
|
|
281
|
-
revokeSession() {
|
|
282
|
-
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
283
|
-
throw "UiApplicationDisposed";
|
|
284
|
-
}
|
|
285
|
-
if (__requireBoolean(__normalize(this.#revoked))) {
|
|
286
|
-
return null;
|
|
287
|
-
}
|
|
288
|
-
return __normalize(this.#tokens.logout(__normalize(this.#logoutPath))).then(__withArity((previousToken) => {
|
|
289
|
-
previousToken = __boundary(previousToken);
|
|
290
|
-
this.rememberRevocation(previousToken);
|
|
291
|
-
return null;
|
|
292
|
-
}, [0], "closure"));
|
|
293
|
-
return null;
|
|
294
|
-
}
|
|
295
|
-
rememberRevocation(previousToken) {
|
|
296
|
-
__requireArity(arguments.length, [0], "rememberRevocation");
|
|
297
|
-
previousToken = __boundary(previousToken);
|
|
298
|
-
this.#revoked = true;
|
|
299
|
-
this.#restartToken = previousToken;
|
|
300
|
-
return null;
|
|
301
|
-
return null;
|
|
302
|
-
}
|
|
303
|
-
restartAnonymous() {
|
|
304
|
-
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
305
|
-
throw "UiApplicationDisposed";
|
|
306
|
-
}
|
|
307
|
-
return __normalize(this.#tokens.initialize(__normalize(this.#bootstrapPath), __normalize(this.#restartToken)));
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
resume(token) {
|
|
311
|
-
__requireArity(arguments.length, [0], "resume");
|
|
312
|
-
token = __boundary(token);
|
|
313
|
-
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
314
|
-
throw "UiApplicationDisposed";
|
|
315
|
-
}
|
|
316
|
-
this.#revoked = false;
|
|
317
|
-
this.#restartToken = null;
|
|
318
|
-
this.#pageToken = token;
|
|
319
|
-
this.#paused = false;
|
|
320
|
-
this.createHeartbeat();
|
|
321
|
-
this.reconcile();
|
|
322
|
-
this.control.element.inert = false;
|
|
323
|
-
__normalize(this.control.element.setAttribute("aria-busy", "false"));
|
|
324
|
-
if (__requireBoolean(__normalize(this.#heartbeat) !== null)) {
|
|
325
|
-
__normalize(this.#heartbeat.start());
|
|
326
|
-
}
|
|
327
|
-
return token;
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
finishLogout() {
|
|
331
|
-
this.#logout = null;
|
|
332
|
-
return null;
|
|
333
|
-
return null;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function containsForm(forms, control) {
|
|
337
|
-
__requireArity(arguments.length, [0, 1], "containsForm");
|
|
338
|
-
forms = __boundary(forms);
|
|
339
|
-
control = __boundary(control);
|
|
340
|
-
for (const form of forms) {
|
|
341
|
-
if (__requireBoolean(__normalize(form.control) === control)) {
|
|
342
|
-
return true;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
return false;
|
|
346
|
-
return null;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
function retainsForm(forms, entry) {
|
|
350
|
-
__requireArity(arguments.length, [0, 1], "retainsForm");
|
|
351
|
-
forms = __boundary(forms);
|
|
352
|
-
entry = __boundary(entry);
|
|
353
|
-
for (const form of forms) {
|
|
354
|
-
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(form.control) === __normalize(entry.control)) && __requireBoolean(__normalize(form.formId) === __normalize(entry.formId))) && __requireBoolean(__normalize(form.parent) === __normalize(entry.parent)))) {
|
|
355
|
-
return true;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
return false;
|
|
359
|
-
return null;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
function collectForms(control, parentPath, forms, parentForm = null, parentFormPath = null) {
|
|
363
|
-
__requireArity(arguments.length, [0, 1, 2], "collectForms");
|
|
364
|
-
control = __boundary(control);
|
|
365
|
-
parentPath = __boundary(parentPath);
|
|
366
|
-
forms = __boundary(forms);
|
|
367
|
-
parentForm = __boundary(parentForm);
|
|
368
|
-
parentFormPath = __boundary(parentFormPath);
|
|
369
|
-
let formId;
|
|
370
|
-
let path = __normalize(parentPath.slice());
|
|
371
|
-
let nearest = parentForm;
|
|
372
|
-
let nearestPath = parentFormPath;
|
|
373
|
-
if (__requireBoolean(__requireBoolean(__normalize(control.name) !== null) && __requireBoolean(__normalize(control.name) !== ""))) {
|
|
374
|
-
__add(path, __normalize(control.name));
|
|
375
|
-
}
|
|
376
|
-
if (__requireBoolean(control.element.langoFormRoot === true)) {
|
|
377
|
-
if (__requireBoolean(__requireBoolean(__normalize(control.name) === null) || __requireBoolean(__normalize(control.name) === ""))) {
|
|
378
|
-
throw "UiManagedFormRequiresName";
|
|
379
|
-
}
|
|
380
|
-
formId = managedFormId(path);
|
|
381
|
-
for (const existing of forms) {
|
|
382
|
-
if (__requireBoolean(__normalize(existing.formId) === formId)) {
|
|
383
|
-
throw "UiDuplicateFormPath";
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
__add(forms, { formId: formId, control: control, path: path, parent: parentForm, parentPath: parentFormPath });
|
|
387
|
-
nearest = control;
|
|
388
|
-
nearestPath = path;
|
|
389
|
-
}
|
|
390
|
-
if (__requireBoolean(__isArray(__normalize(control.controls)))) {
|
|
391
|
-
for (const child of __normalize(control.controls)) {
|
|
392
|
-
collectForms(child, path, forms, nearest, nearestPath);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return null;
|
|
396
|
-
return null;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
function managedFormId(path) {
|
|
400
|
-
__requireArity(arguments.length, [0], "managedFormId");
|
|
401
|
-
path = __boundary(path);
|
|
402
|
-
if (__requireBoolean(__normalize(path.length) === 1)) {
|
|
403
|
-
return __normalize(path[0]);
|
|
404
|
-
}
|
|
405
|
-
return __toJson(path);
|
|
406
|
-
return null;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
function observeStartup(heartbeat, tokens) {
|
|
410
|
-
__requireArity(arguments.length, [0, 1], "observeStartup");
|
|
411
|
-
heartbeat = __boundary(heartbeat);
|
|
412
|
-
tokens = __boundary(tokens);
|
|
413
|
-
if (__requireBoolean(__normalize(tokens.ready) === null)) {
|
|
414
|
-
return null;
|
|
415
|
-
}
|
|
416
|
-
let ready = __normalize(tokens.ready());
|
|
417
|
-
let observed = __normalize(ready.then(() => {
|
|
418
|
-
__normalize(heartbeat.activity());
|
|
419
|
-
return null;
|
|
420
|
-
}));
|
|
421
|
-
observed.catch(__withArity((error) => {
|
|
422
|
-
error = __boundary(error);
|
|
423
|
-
__normalize(heartbeat.activity());
|
|
424
|
-
return null;
|
|
425
|
-
}, [0], "closure"));
|
|
426
|
-
return null;
|
|
427
|
-
return null;
|
|
428
|
-
}
|
|
429
|
-
//# sourceMappingURL=application.mjs.map
|
package/dist/application.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application.mjs","sources":["application.lango"],"sourcesContent":["import js global Promise\nimport \"./library\"\n mount(document, root, definition, types = null)\n class Renderer\n class Binding\n class Types\nimport \"./session\"\n class Session\nimport \"./tokens\"\n browserTokenStore(key = \"lango:last-token\")\nimport \"./heartbeat\"\n class Heartbeat\nimport \"./inheritance\"\n inheritedControls(form, parent)\n inheritanceResources(path, parentPath, spec)\nimport \"./coordinator\"\n class Coordinator\n\nexport class Application\n properties\n control\n methods\n reconcile()\n session(formId)\n dispose()\n logout()\n pause()\n revokeSession()\n rememberRevocation(previousToken)\n restartAnonymous()\n resume(token)\n finishLogout()\n createHeartbeat()\n controlsFor(form)\n isDirty()\n confirmDiscard(window)\n\nApplication(document, root, definition, options = null)\n if options == null\n options = {\n }\n types = options.types\n if types == null\n types = new Types()\n @control = mount(document, root, definition, types)\n @renderer = new Renderer(document, types)\n @transport = options.transport\n @errors = options.errors\n @tokens = options.tokens\n if @tokens == null\n key = options.storageKey\n if key == null\n key = \"lango:last-token\"\n @tokens = browserTokenStore(key)\n if options.bootstrapPath != null\n @tokens.initialize(options.bootstrapPath)\n @pageToken = @tokens.latest()\n @bindings = []\n @coordinator = new Coordinator()\n @disposed = false\n @window = options.window\n @unload = null\n @paused = false\n @logout = null\n @revoked = false\n @restartToken = null\n @bootstrapPath = options.bootstrapPath\n if @bootstrapPath == null\n @bootstrapPath = \"/_lango/start\"\n @logoutPath = options.logoutPath\n if @logoutPath == null\n @logoutPath = \"/_lango/logout\"\n @heartbeat = null\n pingEnabled = options.pingEnabled\n if pingEnabled == null\n pingEnabled = options.bootstrapPath != null or options.pingPath != null\n if !is_bool(pingEnabled)\n throw \"UiPingEnabledMustBeBoolean\"\n @pingEnabled = pingEnabled\n @heartbeatOptions = {\n path: options.pingPath\n idleMs: options.pingIdleMs\n transport: options.pingTransport\n }\n createHeartbeat()\n reconcile()\n if @heartbeat != null\n @heartbeat.start()\n observeStartup(@heartbeat, @tokens)\n if @window != null\n unload = (event)\n if isDirty()\n event.preventDefault()\n event.returnValue = \"\"\n @unload = unload\n @window.addEventListener(\"beforeunload\", unload)\n\nApplication:createHeartbeat()\n if @pingEnabled\n @heartbeat = new Heartbeat(@heartbeatOptions)\n return null\n\nApplication:session(formId)\n id = formId\n if is_array(formId)\n id = managedFormId(formId)\n for @bindings as entry\n if entry.formId == id\n return entry.session\n return null\n\nApplication:reconcile()\n if @disposed or @paused\n return null\n forms = []\n collectForms(@control, [], forms)\n for forms as form\n form.resources = inheritanceResources(form.path, form.parentPath, form.control.inherit)\n retained = []\n for @bindings as entry\n if retainsForm(forms, entry)\n retained.add(entry)\n else\n entry.binding.dispose()\n entry.session.dispose()\n @bindings = retained\n for forms as form\n if not containsForm(@bindings, form.control)\n session = new Session({\n formId: form.formId\n controls: form.control.controls\n root: form.control.element\n effects: @renderer\n transport: @transport\n lifecycle: @this\n tokens: @tokens\n heartbeat: @heartbeat\n coordinator: @coordinator\n resources: form.resources\n form: form.control\n parent: form.parent\n window: @window\n seedFromBootstrap: true\n seedToken: @pageToken\n })\n binding = new Binding(form.control, session, @errors)\n @bindings.add({\n formId: form.formId\n control: form.control\n parent: form.parent\n session: session\n binding: binding\n })\n if @heartbeat != null\n sessions = []\n for @bindings as entry\n sessions.add(entry.session)\n @heartbeat.sessions(sessions)\n return null\n\nApplication:controlsFor(form)\n for @bindings as entry\n if entry.control == form\n return inheritedControls(form, entry.parent)\n throw \"UiSessionDisposed\"\n\nApplication:dispose()\n if @disposed\n return null\n @disposed = true\n if @window != null\n @window.removeEventListener(\"beforeunload\", @unload)\n if @paused and @tokens.cancelInitialization != null\n @tokens.cancelInitialization()\n if @heartbeat != null\n @heartbeat.dispose()\n for @bindings as entry\n entry.binding.dispose()\n entry.session.dispose()\n @bindings = []\n @renderer.release(@control)\n return null\n\nApplication:isDirty()\n if @disposed\n return false\n for @bindings as entry\n if entry.session.isDirty()\n return true\n return false\n\nApplication:confirmDiscard(window)\n if !isDirty()\n return true\n return window.confirm(\"You have unsaved changes. Discard them?\")\n\nApplication:logout()\n if @disposed\n throw \"UiApplicationDisposed\"\n if @logout != null\n return @logout\n if @tokens.logout == null or @tokens.cancelInitialization == null\n throw \"UiLogoutRequiresTokenStore\"\n pause()\n ready = Promise/resolve()\n revoked = ready.then(()\n return revokeSession()\n )\n restarted = revoked.then(()\n return restartAnonymous()\n )\n work = restarted.then((token)\n return resume(token)\n )\n pending = work.finally(()\n finishLogout()\n )\n @logout = pending\n return pending\n\nApplication:pause()\n @paused = true\n if @heartbeat != null\n @heartbeat.dispose()\n for @bindings as entry\n entry.binding.dispose()\n entry.session.dispose()\n @bindings = []\n @control.element.inert = true\n @control.element.setAttribute(\"aria-busy\", \"true\")\n return null\n\nApplication:revokeSession()\n if @disposed\n throw \"UiApplicationDisposed\"\n if @revoked\n return null\n return @tokens.logout(@logoutPath).then((previousToken)\n rememberRevocation(previousToken)\n )\n\nApplication:rememberRevocation(previousToken)\n @revoked = true\n @restartToken = previousToken\n return null\n\nApplication:restartAnonymous()\n if @disposed\n throw \"UiApplicationDisposed\"\n return @tokens.initialize(@bootstrapPath, @restartToken)\n\nApplication:resume(token)\n if @disposed\n throw \"UiApplicationDisposed\"\n @revoked = false\n @restartToken = null\n @pageToken = token\n @paused = false\n createHeartbeat()\n reconcile()\n @control.element.inert = false\n @control.element.setAttribute(\"aria-busy\", \"false\")\n if @heartbeat != null\n @heartbeat.start()\n return token\n\nApplication:finishLogout()\n @logout = null\n return null\n\ncontainsForm(forms, control)\n for forms as form\n if form.control == control\n return true\n return false\n\nretainsForm(forms, entry)\n for forms as form\n if form.control == entry.control and form.formId == entry.formId and form.parent == entry.parent\n return true\n return false\n\ncollectForms(control, parentPath, forms, parentForm = null, parentFormPath = null)\n path = parentPath.slice()\n nearest = parentForm\n nearestPath = parentFormPath\n if control.name != null and control.name != \"\"\n path.add(control.name)\n if control.element.langoFormRoot == true\n if control.name == null or control.name == \"\"\n throw \"UiManagedFormRequiresName\"\n formId = managedFormId(path)\n for forms as existing\n if existing.formId == formId\n throw \"UiDuplicateFormPath\"\n forms.add({\n formId: formId\n control: control\n path: path\n parent: parentForm\n parentPath: parentFormPath\n })\n nearest = control\n nearestPath = path\n if is_array(control.controls)\n for control.controls as child\n collectForms(child, path, forms, nearest, nearestPath)\n return null\n\nmanagedFormId(path)\n if path.length == 1\n return path[0]\n return to_json(path)\n\nobserveStartup(heartbeat, tokens)\n if tokens.ready == null\n return null\n ready = tokens.ready()\n observed = ready.then(()\n capture heartbeat\n heartbeat.activity()\n )\n observed.catch((error)\n capture heartbeat\n heartbeat.activity()\n )\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4PA;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA;;;;;;;;;;AAKA;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/coordinator.mjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hostGlobal as __hostGlobal,
|
|
3
|
-
entries as __entries,
|
|
4
|
-
add as __add,
|
|
5
|
-
requireBoolean as __requireBoolean,
|
|
6
|
-
normalize as __normalize,
|
|
7
|
-
boundary as __boundary,
|
|
8
|
-
requireArity as __requireArity,
|
|
9
|
-
} from "./.lango/runtime.mjs";
|
|
10
|
-
|
|
11
|
-
export class Coordinator {
|
|
12
|
-
#reservations;
|
|
13
|
-
constructor() {
|
|
14
|
-
this.#reservations = [];
|
|
15
|
-
}
|
|
16
|
-
reserve(resources) {
|
|
17
|
-
__requireArity(arguments.length, [0], "reserve");
|
|
18
|
-
resources = __boundary(resources);
|
|
19
|
-
let waiting = [];
|
|
20
|
-
for (const previous of __normalize(this.#reservations)) {
|
|
21
|
-
if (__requireBoolean(overlaps(resources, __normalize(previous.resources)))) {
|
|
22
|
-
waiting.push(previous.done.promise);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
let reservation = { resources: resources, ready: __normalize(__hostGlobal(["Promise"]).all(waiting)), done: __normalize(__hostGlobal(["Promise"]).withResolvers()), released: false };
|
|
26
|
-
__add(this.#reservations, reservation);
|
|
27
|
-
return reservation;
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
release(reservation) {
|
|
31
|
-
__requireArity(arguments.length, [0], "release");
|
|
32
|
-
reservation = __boundary(reservation);
|
|
33
|
-
if (__requireBoolean(__normalize(reservation.released))) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
reservation.released = true;
|
|
37
|
-
let index = __normalize(this.#reservations.indexOf(reservation));
|
|
38
|
-
if (__requireBoolean(index >= 0)) {
|
|
39
|
-
__normalize(this.#reservations.splice(index, 1));
|
|
40
|
-
}
|
|
41
|
-
__normalize(reservation.done.resolve(null));
|
|
42
|
-
return null;
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function overlaps(first, second) {
|
|
47
|
-
__requireArity(arguments.length, [0, 1], "overlaps");
|
|
48
|
-
first = __boundary(first);
|
|
49
|
-
second = __boundary(second);
|
|
50
|
-
for (const write of __normalize(first.writes)) {
|
|
51
|
-
for (const read of __normalize(second.reads)) {
|
|
52
|
-
if (__requireBoolean(related(write, read))) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
for (const other of __normalize(second.writes)) {
|
|
57
|
-
if (__requireBoolean(related(write, other))) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
for (const read of __normalize(first.reads)) {
|
|
63
|
-
for (const write of __normalize(second.writes)) {
|
|
64
|
-
if (__requireBoolean(related(read, write))) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function related(first, second) {
|
|
74
|
-
__requireArity(arguments.length, [0, 1], "related");
|
|
75
|
-
first = __boundary(first);
|
|
76
|
-
second = __boundary(second);
|
|
77
|
-
let count = __normalize(first.length);
|
|
78
|
-
if (__requireBoolean(__normalize(second.length) < count)) {
|
|
79
|
-
count = __normalize(second.length);
|
|
80
|
-
}
|
|
81
|
-
for (const [index, name] of __entries(first)) {
|
|
82
|
-
if (__requireBoolean(index < count)) {
|
|
83
|
-
if (__requireBoolean(name !== __normalize(second[index]))) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=coordinator.mjs.map
|
package/dist/coordinator.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator.mjs","sources":["coordinator.lango"],"sourcesContent":["import js global Promise\n\nexport class Coordinator\n methods\n reserve(resources)\n release(reservation)\n\nCoordinator()\n @reservations = []\n\nCoordinator:reserve(resources)\n waiting = []\n for @reservations as previous\n if overlaps(resources, previous.resources)\n waiting.add(previous.done.promise)\n reservation = {\n resources: resources\n ready: Promise/all(waiting)\n done: Promise/withResolvers()\n released: false\n }\n @reservations.add(reservation)\n return reservation\n\nCoordinator:release(reservation)\n if reservation.released\n return null\n reservation.released = true\n index = @reservations.indexOf(reservation)\n if index >= 0\n @reservations.splice(index, 1)\n reservation.done.resolve(null)\n return null\n\noverlaps(first, second)\n for first.writes as write\n for second.reads as read\n if related(write, read)\n return true\n for second.writes as other\n if related(write, other)\n return true\n for first.reads as read\n for second.writes as write\n if related(read, write)\n return true\n return false\n\nrelated(first, second)\n count = first.length\n if second.length < count\n count = second.length\n for first as index: name\n if index < count\n if name != second[index]\n return false\n return true\n"],"names":[],"mappings":";;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;;;;;"}
|
package/dist/demo.mjs
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Navigation } from "./navigation.mjs";
|
|
2
|
-
import { Application } from "./application.mjs";
|
|
3
|
-
import { demoTypes, DemoErrors } from "./demo_controls.mjs";
|
|
4
|
-
import {
|
|
5
|
-
hostGlobal as __hostGlobal,
|
|
6
|
-
contextGet as __contextGet,
|
|
7
|
-
contextSet as __contextSet,
|
|
8
|
-
contextRestore as __contextRestore,
|
|
9
|
-
requireBoolean as __requireBoolean,
|
|
10
|
-
normalize as __normalize,
|
|
11
|
-
boundary as __boundary,
|
|
12
|
-
requireArity as __requireArity,
|
|
13
|
-
withArity as __withArity,
|
|
14
|
-
} from "./.lango/runtime.mjs";
|
|
15
|
-
|
|
16
|
-
let demo = startDemo();
|
|
17
|
-
function startDemo() {
|
|
18
|
-
let root = __normalize(__hostGlobal(["document"]).getElementById("app"));
|
|
19
|
-
let application = new Application(__normalize(__hostGlobal(["document"])), root, { type: "Form", name: "page", classes: ["demo-theme"], style: { "--accent-color": "#0f766e" }, controls: [{ type: "Value", name: "url", value: "" }, { type: "Value", name: "template", value: null }, { type: "Container", name: "content", controls: [] }] }, { bootstrapPath: "/_lango/start", types: demoTypes(), window: __normalize(__hostGlobal(["window"])), errors: new DemoErrors(__normalize(__hostGlobal(["document"]).getElementById("form-status"))) });
|
|
20
|
-
let page = __normalize(application.control);
|
|
21
|
-
let urlField = page.controls[0];
|
|
22
|
-
let templateField = page.controls[1];
|
|
23
|
-
let changed = __withArity((event) => {
|
|
24
|
-
event = __boundary(event);
|
|
25
|
-
__normalize(urlField.setValue(__normalize(event.url)));
|
|
26
|
-
let session = __normalize(application.session("page"));
|
|
27
|
-
return __normalize(session.send("/app/url", "url", null));
|
|
28
|
-
return null;
|
|
29
|
-
}, [0], "closure");
|
|
30
|
-
let canLeave = __withArity((event) => {
|
|
31
|
-
event = __boundary(event);
|
|
32
|
-
if (__requireBoolean(__normalize(event.source) === "refresh")) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
return __normalize(application.confirmDiscard(__normalize(__hostGlobal(["window"]))));
|
|
36
|
-
return null;
|
|
37
|
-
}, [0], "closure");
|
|
38
|
-
let navigation = new Navigation(__normalize(__hostGlobal(["window"])), { rootRedirect: "/profile", onUrl: changed, beforeNavigate: canLeave });
|
|
39
|
-
let opening = __normalize(navigation.start());
|
|
40
|
-
opening.catch(__withArity((error) => {
|
|
41
|
-
const __contextScope = [];
|
|
42
|
-
try {
|
|
43
|
-
error = __boundary(error);
|
|
44
|
-
__normalize(__contextGet("log").err(error));
|
|
45
|
-
return null;
|
|
46
|
-
} finally {
|
|
47
|
-
__contextRestore(__contextScope);
|
|
48
|
-
}
|
|
49
|
-
}, [0], "closure"));
|
|
50
|
-
let button = __normalize(__hostGlobal(["document"]).getElementById("logout"));
|
|
51
|
-
let status = __normalize(__hostGlobal(["document"]).getElementById("session-status"));
|
|
52
|
-
__normalize(button.addEventListener("click", () => {
|
|
53
|
-
logoutDemo(application, navigation, templateField, button, status);
|
|
54
|
-
return null;
|
|
55
|
-
}));
|
|
56
|
-
return { application: application, navigation: navigation };
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function logoutDemo(application, navigation, templateField, button, status) {
|
|
61
|
-
__requireArity(arguments.length, [0, 1, 2, 3, 4], "logoutDemo");
|
|
62
|
-
application = __boundary(application);
|
|
63
|
-
navigation = __boundary(navigation);
|
|
64
|
-
templateField = __boundary(templateField);
|
|
65
|
-
button = __boundary(button);
|
|
66
|
-
status = __boundary(status);
|
|
67
|
-
if (__requireBoolean(!__requireBoolean(__normalize(application.confirmDiscard(__normalize(__hostGlobal(["window"]))))))) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
showLogoutStatus(button, status, "Logging out...", true);
|
|
71
|
-
return __normalize(application.logout()).then(__withArity((token) => {
|
|
72
|
-
token = __boundary(token);
|
|
73
|
-
__normalize(templateField.setValue(null));
|
|
74
|
-
return reloadAfterLogout(navigation, button, status);
|
|
75
|
-
return null;
|
|
76
|
-
}, [0], "closure")).catch(__withArity((error) => {
|
|
77
|
-
error = __boundary(error);
|
|
78
|
-
showLogoutStatus(button, status, "Logout failed. Retry, or reload if the server already ended the session.", false);
|
|
79
|
-
return null;
|
|
80
|
-
}, [0], "closure"));
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function reloadAfterLogout(navigation, button, status) {
|
|
85
|
-
__requireArity(arguments.length, [0, 1, 2], "reloadAfterLogout");
|
|
86
|
-
navigation = __boundary(navigation);
|
|
87
|
-
button = __boundary(button);
|
|
88
|
-
status = __boundary(status);
|
|
89
|
-
return __normalize(navigation.refresh()).then(() => {
|
|
90
|
-
showLogoutStatus(button, status, "A new anonymous session is ready.", false);
|
|
91
|
-
return null;
|
|
92
|
-
}).catch(__withArity((error) => {
|
|
93
|
-
error = __boundary(error);
|
|
94
|
-
showLogoutStatus(button, status, "Session restarted, but page loading failed. Reload to retry.", false);
|
|
95
|
-
return null;
|
|
96
|
-
}, [0], "closure"));
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function showLogoutStatus(button, status, text, busy) {
|
|
101
|
-
__requireArity(arguments.length, [0, 1, 2, 3], "showLogoutStatus");
|
|
102
|
-
button = __boundary(button);
|
|
103
|
-
status = __boundary(status);
|
|
104
|
-
text = __boundary(text);
|
|
105
|
-
busy = __boundary(busy);
|
|
106
|
-
button.disabled = busy;
|
|
107
|
-
status.textContent = text;
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=demo.mjs.map
|
package/dist/demo.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"demo.mjs","sources":["demo.lango"],"sourcesContent":["import js global document\nimport js global window\nimport \"./navigation\"\n class Navigation\nimport \"./application\"\n class Application\nimport \"./demo_controls\"\n demoTypes()\n class DemoErrors\n\nglobal demo = startDemo()\n\nstartDemo()\n root = document.getElementById(\"app\")\n application = new Application(document, root, {\n type: \"Form\"\n name: \"page\"\n classes: [\"demo-theme\"]\n style: {\n \"--accent-color\": \"#0f766e\"\n }\n controls: [{\n type: \"Value\"\n name: \"url\"\n value: \"\"\n }, {\n type: \"Value\"\n name: \"template\"\n value: null\n }, {\n type: \"Container\"\n name: \"content\"\n controls: []\n }]\n }, {\n bootstrapPath: \"/_lango/start\"\n types: demoTypes()\n window: window\n errors: new DemoErrors(document.getElementById(\"form-status\"))\n })\n page = application.control\n urlField = page.controls[0]\n templateField = page.controls[1]\n changed = (event)\n capture application\n capture urlField\n urlField.setValue(event.url)\n session = application.session(\"page\")\n return session.send(\"/app/url\", \"url\", null)\n canLeave = (event)\n capture application\n if event.source == \"refresh\"\n return true\n return application.confirmDiscard(window)\n navigation = new Navigation(window, {\n rootRedirect: \"/profile\"\n onUrl: changed\n beforeNavigate: canLeave\n })\n opening = navigation.start()\n opening.catch((error)\n context log\n log.err(error)\n )\n button = document.getElementById(\"logout\")\n status = document.getElementById(\"session-status\")\n button.addEventListener(\"click\", ()\n capture application\n capture navigation\n capture templateField\n capture button\n capture status\n logoutDemo(application, navigation, templateField, button, status)\n )\n return {\n application: application\n navigation: navigation\n }\n\nlogoutDemo(application, navigation, templateField, button, status)\n if !application.confirmDiscard(window)\n return null\n showLogoutStatus(button, status, \"Logging out...\", true)\n return application.logout().then((token)\n capture navigation\n capture templateField\n capture button\n capture status\n templateField.setValue(null)\n return reloadAfterLogout(navigation, button, status)\n ).catch((error)\n capture button\n capture status\n showLogoutStatus(button, status, \"Logout failed. Retry, or reload if the server already ended the session.\", false)\n )\n\nreloadAfterLogout(navigation, button, status)\n return navigation.refresh().then(()\n capture button\n capture status\n showLogoutStatus(button, status, \"A new anonymous session is ready.\", false)\n ).catch((error)\n capture button\n capture status\n showLogoutStatus(button, status, \"Session restarted, but page loading failed. Reload to retry.\", false)\n )\n\nshowLogoutStatus(button, status, text, busy)\n button.disabled = busy\n status.textContent = text\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAUA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;"}
|