@lango-project/lango-client 0.2.1 → 0.4.0
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 +570 -906
- package/cli/.lango/localization.mjs +108 -0
- package/{dist/node → cli}/.lango/runtime.mjs +112 -19
- 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 +112 -19
- 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 +636 -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 +95 -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 +139 -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/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 +138 -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 +293 -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/tables.mjs +369 -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 +2540 -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 +42 -0
- package/package.json +25 -43
- package/src/accordion.lango +198 -0
- package/src/activities.lango +132 -0
- package/src/app.lango +508 -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 +100 -0
- package/src/create.lango +42 -0
- package/src/date_input.lango +215 -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 +109 -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 +288 -0
- package/src/rich_content.lango +66 -0
- package/src/tables.lango +271 -0
- package/src/tabs.lango +144 -0
- package/src/templates.lango +29 -0
- package/src/widgets.lango +141 -0
- package/web/client.css +95 -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/control.mjs
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { controlId } from "./templates.mjs";
|
|
2
|
+
import {
|
|
3
|
+
hostGlobal as __hostGlobal,
|
|
4
|
+
add as __add,
|
|
5
|
+
remove as __remove,
|
|
6
|
+
requireBoolean as __requireBoolean,
|
|
7
|
+
normalize as __normalize,
|
|
8
|
+
call as __call,
|
|
9
|
+
boundary as __boundary,
|
|
10
|
+
requireArity as __requireArity,
|
|
11
|
+
} from "./.lango/runtime.mjs";
|
|
12
|
+
|
|
13
|
+
export class Control {
|
|
14
|
+
form;
|
|
15
|
+
element;
|
|
16
|
+
release;
|
|
17
|
+
#value;
|
|
18
|
+
#feedback;
|
|
19
|
+
#target;
|
|
20
|
+
#describedBy;
|
|
21
|
+
#invalid;
|
|
22
|
+
constructor(form, props, element) {
|
|
23
|
+
__requireArity(arguments.length, [0, 1, 2], "constructor");
|
|
24
|
+
form = __boundary(form);
|
|
25
|
+
props = __boundary(props);
|
|
26
|
+
element = __boundary(element);
|
|
27
|
+
this.form = form;
|
|
28
|
+
this.element = element;
|
|
29
|
+
this.#value = __normalize(props.value);
|
|
30
|
+
this.release = [];
|
|
31
|
+
this.#feedback = null;
|
|
32
|
+
this.validationTarget(element);
|
|
33
|
+
}
|
|
34
|
+
getValue() {
|
|
35
|
+
return null;
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
setValue(value) {
|
|
39
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
40
|
+
value = __boundary(value);
|
|
41
|
+
this.#value = value;
|
|
42
|
+
return this;
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
setDisabled(value) {
|
|
46
|
+
__requireArity(arguments.length, [0], "setDisabled");
|
|
47
|
+
value = __boundary(value);
|
|
48
|
+
this.element.disabled = value;
|
|
49
|
+
return this;
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
setCaption(value) {
|
|
53
|
+
__requireArity(arguments.length, [0], "setCaption");
|
|
54
|
+
value = __boundary(value);
|
|
55
|
+
this.element.textContent = value;
|
|
56
|
+
return this;
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
validationTarget(element) {
|
|
60
|
+
__requireArity(arguments.length, [0], "validationTarget");
|
|
61
|
+
element = __boundary(element);
|
|
62
|
+
this.#target = element;
|
|
63
|
+
this.#describedBy = __normalize(element.getAttribute("aria-describedby"));
|
|
64
|
+
this.#invalid = __normalize(element.getAttribute("aria-invalid"));
|
|
65
|
+
return null;
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
setInvalid(message) {
|
|
69
|
+
__requireArity(arguments.length, [0], "setInvalid");
|
|
70
|
+
message = __boundary(message);
|
|
71
|
+
this.clearValidation();
|
|
72
|
+
this.#feedback = __normalize(__hostGlobal(["document"]).createElement("div"));
|
|
73
|
+
this.#feedback.id = controlId();
|
|
74
|
+
this.#feedback.className = "invalid-feedback d-block";
|
|
75
|
+
this.#feedback.textContent = message;
|
|
76
|
+
__add(this.#target.classList, "is-invalid");
|
|
77
|
+
__normalize(this.#target.setAttribute("aria-invalid", "true"));
|
|
78
|
+
let description = __normalize(this.#feedback.id);
|
|
79
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#describedBy) !== null) && __requireBoolean(__normalize(this.#describedBy) !== ""))) {
|
|
80
|
+
description = `${__normalize(this.#describedBy)} ${description}`;
|
|
81
|
+
}
|
|
82
|
+
__normalize(this.#target.setAttribute("aria-describedby", description));
|
|
83
|
+
__normalize(this.element.appendChild(__normalize(this.#feedback)));
|
|
84
|
+
return this;
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
clearValidation() {
|
|
88
|
+
if (__requireBoolean(__normalize(this.#feedback) !== null)) {
|
|
89
|
+
__remove(this.#feedback);
|
|
90
|
+
this.#feedback = null;
|
|
91
|
+
__remove(this.#target.classList, "is-invalid");
|
|
92
|
+
if (__requireBoolean(__normalize(this.#invalid) === null)) {
|
|
93
|
+
__normalize(this.#target.removeAttribute("aria-invalid"));
|
|
94
|
+
} else {
|
|
95
|
+
__normalize(this.#target.setAttribute("aria-invalid", __normalize(this.#invalid)));
|
|
96
|
+
}
|
|
97
|
+
if (__requireBoolean(__normalize(this.#describedBy) === null)) {
|
|
98
|
+
__normalize(this.#target.removeAttribute("aria-describedby"));
|
|
99
|
+
} else {
|
|
100
|
+
__normalize(this.#target.setAttribute("aria-describedby", __normalize(this.#describedBy)));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
dispose() {
|
|
107
|
+
this.clearValidation();
|
|
108
|
+
for (const release of __normalize(this.release)) {
|
|
109
|
+
__call(release, );
|
|
110
|
+
}
|
|
111
|
+
this.release = [];
|
|
112
|
+
return null;
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export class Value extends Control {
|
|
118
|
+
#value;
|
|
119
|
+
constructor(form, props, element) {
|
|
120
|
+
super(form, props, element);
|
|
121
|
+
__requireArity(arguments.length, [0, 1, 2], "constructor");
|
|
122
|
+
form = __boundary(form);
|
|
123
|
+
props = __boundary(props);
|
|
124
|
+
element = __boundary(element);
|
|
125
|
+
this.#value = __normalize(props.value);
|
|
126
|
+
}
|
|
127
|
+
getValue() {
|
|
128
|
+
return __normalize(this.#value);
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
setValue(value) {
|
|
132
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
133
|
+
value = __boundary(value);
|
|
134
|
+
this.#value = value;
|
|
135
|
+
return this;
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=control.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.mjs","sources":["control.lango"],"sourcesContent":["import js global document\nimport \"./templates\"\n controlId()\n\nexport class Control(form, props, element)\n properties\n form\n element\n release\n methods\n getValue()\n setValue(value)\n setDisabled(value)\n setCaption(value)\n validationTarget(element)\n setInvalid(message)\n clearValidation()\n dispose()\n\nControl(form, props, element)\n @form = form\n @element = element\n @value = props.value\n @release = []\n @feedback = null\n validationTarget(element)\n\nControl:getValue()\n return null\n\nControl:setValue(value)\n @value = value\n return @this\n\nControl:setDisabled(value)\n @element.disabled = value\n return @this\n\nControl:setCaption(value)\n @element.textContent = value\n return @this\n\nControl:validationTarget(element)\n @target = element\n @describedBy = element.getAttribute(\"aria-describedby\")\n @invalid = element.getAttribute(\"aria-invalid\")\n return null\n\nControl:setInvalid(message)\n clearValidation()\n @feedback = document/createElement(\"div\")\n @feedback.id = controlId()\n @feedback.className = \"invalid-feedback d-block\"\n @feedback.textContent = message\n @target.classList.add(\"is-invalid\")\n @target.setAttribute(\"aria-invalid\", \"true\")\n description = @feedback.id\n if @describedBy != null and @describedBy != \"\"\n description = \"${@describedBy} ${description}\"\n @target.setAttribute(\"aria-describedby\", description)\n @element.appendChild(@feedback)\n return @this\n\nControl:clearValidation()\n if @feedback != null\n @feedback.remove()\n @feedback = null\n @target.classList.remove(\"is-invalid\")\n if @invalid == null\n @target.removeAttribute(\"aria-invalid\")\n else\n @target.setAttribute(\"aria-invalid\", @invalid)\n if @describedBy == null\n @target.removeAttribute(\"aria-describedby\")\n else\n @target.setAttribute(\"aria-describedby\", @describedBy)\n return null\n\nControl:dispose()\n clearValidation()\n for @release as release\n release()\n @release = []\n return null\n\nexport class Value(form, props, element) : Control\n methods\n getValue()\n setValue(value)\n\nValue(form, props, element)\n super(form, props, element)\n @value = props.value\n\nValue:getValue()\n return @value\n\nValue:setValue(value)\n @value = value\n return @this\n"],"names":[],"mappings":";;;;;;;;;;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiFA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { Field } from "./fields.mjs";
|
|
2
|
+
import { cloneMarkup } from "./templates.mjs";
|
|
3
|
+
import { InputChanges } from "./input_changes.mjs";
|
|
4
|
+
import * as picker from "flatpickr";
|
|
5
|
+
import {
|
|
6
|
+
hostGlobal as __hostGlobal,
|
|
7
|
+
xmlEscape as __xmlEscape,
|
|
8
|
+
isNumber as __isNumber,
|
|
9
|
+
isString as __isString,
|
|
10
|
+
isBool as __isBool,
|
|
11
|
+
isObject as __isObject,
|
|
12
|
+
isArray as __isArray,
|
|
13
|
+
requireBoolean as __requireBoolean,
|
|
14
|
+
normalize as __normalize,
|
|
15
|
+
finite as __finite,
|
|
16
|
+
numericAdd as __numericAdd,
|
|
17
|
+
call as __call,
|
|
18
|
+
boundary as __boundary,
|
|
19
|
+
requireArity as __requireArity,
|
|
20
|
+
withArity as __withArity,
|
|
21
|
+
} from "./.lango/runtime.mjs";
|
|
22
|
+
|
|
23
|
+
export class DateInput extends Field {
|
|
24
|
+
#changes;
|
|
25
|
+
#locked;
|
|
26
|
+
#min;
|
|
27
|
+
#max;
|
|
28
|
+
#range;
|
|
29
|
+
#picker;
|
|
30
|
+
constructor(form, props) {
|
|
31
|
+
super(form, props, cloneMarkup("date-input", ["<input type=\"text\" class=\"form-control\" />"].join("")));
|
|
32
|
+
__requireArity(arguments.length, [0, 1], "constructor");
|
|
33
|
+
form = __boundary(form);
|
|
34
|
+
props = __boundary(props);
|
|
35
|
+
this.#changes = new InputChanges(form, __normalize(props.url));
|
|
36
|
+
this.#locked = __normalize(props.readonly) === true;
|
|
37
|
+
this.#min = dateText(__normalize(props.min));
|
|
38
|
+
this.#max = dateText(__normalize(props.max));
|
|
39
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.#min) !== null) && __requireBoolean(__normalize(this.#max) !== null)) && __requireBoolean(__normalize(this.#min.localeCompare(__normalize(this.#max))) > 0))) {
|
|
40
|
+
throw "Date min must not exceed max";
|
|
41
|
+
}
|
|
42
|
+
this.#range = dateRange(__normalize(props.value), __normalize(this.#min), __normalize(this.#max));
|
|
43
|
+
let months = __normalize(props.multiMonth);
|
|
44
|
+
if (__requireBoolean(months === null)) {
|
|
45
|
+
months = 1;
|
|
46
|
+
}
|
|
47
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(months))) || __requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isInteger(months))))) || __requireBoolean(months < 1)) || __requireBoolean(months > 12))) {
|
|
48
|
+
throw "Date multiMonth must be an integer between 1 and 12";
|
|
49
|
+
}
|
|
50
|
+
let first = __normalize(props.firstWeekDay);
|
|
51
|
+
if (__requireBoolean(first === null)) {
|
|
52
|
+
first = 1;
|
|
53
|
+
}
|
|
54
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(first))) || __requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isInteger(first))))) || __requireBoolean(first < 0)) || __requireBoolean(first > 6))) {
|
|
55
|
+
throw "Date firstWeekDay must be an integer between 0 and 6";
|
|
56
|
+
}
|
|
57
|
+
let format = { };
|
|
58
|
+
if (__requireBoolean(__isString(__normalize(props.format)))) {
|
|
59
|
+
format.display = __normalize(props.format);
|
|
60
|
+
} else {
|
|
61
|
+
if (__requireBoolean(__normalize(props.format) !== null)) {
|
|
62
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(__normalize(props.format)))) || __requireBoolean(__isArray(__normalize(props.format))))) {
|
|
63
|
+
throw "Date format must be a display format or options map";
|
|
64
|
+
}
|
|
65
|
+
format = __normalize(__hostGlobal(["Object"]).assign({ }, __normalize(props.format)));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let display = __normalize(format.display);
|
|
69
|
+
if (__requireBoolean(display === null)) {
|
|
70
|
+
display = "Y-m-d";
|
|
71
|
+
}
|
|
72
|
+
let locale = calendarLocale(format);
|
|
73
|
+
locale.firstDayOfWeek = first;
|
|
74
|
+
if (__requireBoolean(__normalize(props.label) !== null)) {
|
|
75
|
+
locale.monthAriaLabel = __normalize(props.label);
|
|
76
|
+
locale.yearAriaLabel = __normalize(props.label);
|
|
77
|
+
}
|
|
78
|
+
if (__requireBoolean(__normalize(format.calendar) !== null)) {
|
|
79
|
+
locale = __normalize(__hostGlobal(["Object"]).assign(locale, __normalize(format.calendar)));
|
|
80
|
+
}
|
|
81
|
+
let createPicker = __normalize(picker.default);
|
|
82
|
+
let change = __withArity((dates) => {
|
|
83
|
+
dates = __boundary(dates);
|
|
84
|
+
if (__requireBoolean(__normalize(this.input.disabled))) {
|
|
85
|
+
this.setValue(__normalize(this.#range));
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
let start = null;
|
|
89
|
+
let end = null;
|
|
90
|
+
if (__requireBoolean(__normalize(dates.length) > 0)) {
|
|
91
|
+
start = __normalize(this.#picker.formatDate(__normalize(dates[0]), "Y-m-d"));
|
|
92
|
+
}
|
|
93
|
+
if (__requireBoolean(__normalize(dates.length) > 1)) {
|
|
94
|
+
end = __normalize(this.#picker.formatDate(__normalize(dates[1]), "Y-m-d"));
|
|
95
|
+
}
|
|
96
|
+
this.#range = dateRange({ start: start, end: end }, __normalize(this.#min), __normalize(this.#max));
|
|
97
|
+
__normalize(this.#changes.changed());
|
|
98
|
+
return null;
|
|
99
|
+
}, [0], "closure");
|
|
100
|
+
let options = { mode: "range", dateFormat: display, showMonths: months, locale: locale, inline: __normalize(props.inline) === true, appendTo: __normalize(this.element), disableMobile: true, allowInput: false, onChange: change };
|
|
101
|
+
if (__requireBoolean(__normalize(this.#min) !== null)) {
|
|
102
|
+
options.minDate = __normalize(createPicker.parseDate(__normalize(this.#min), "Y-m-d"));
|
|
103
|
+
}
|
|
104
|
+
if (__requireBoolean(__normalize(this.#max) !== null)) {
|
|
105
|
+
options.maxDate = __normalize(createPicker.parseDate(__normalize(this.#max), "Y-m-d"));
|
|
106
|
+
}
|
|
107
|
+
this.#picker = __call(createPicker, __normalize(this.input), options);
|
|
108
|
+
if (__requireBoolean(__normalize(props.button) === true)) {
|
|
109
|
+
this.input.className = "btn btn-outline-secondary";
|
|
110
|
+
}
|
|
111
|
+
this.setValue(__normalize(this.#range));
|
|
112
|
+
this.setDisabled(__normalize(props.disabled) === true);
|
|
113
|
+
}
|
|
114
|
+
getValue() {
|
|
115
|
+
return { start: __normalize(this.#range.start), end: __normalize(this.#range.end) };
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
setValue(value) {
|
|
119
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
120
|
+
value = __boundary(value);
|
|
121
|
+
let range = dateRange(value, __normalize(this.#min), __normalize(this.#max));
|
|
122
|
+
let dates = [];
|
|
123
|
+
if (__requireBoolean(__normalize(range.start) !== null)) {
|
|
124
|
+
dates.push(__normalize(range.start));
|
|
125
|
+
}
|
|
126
|
+
if (__requireBoolean(__normalize(range.end) !== null)) {
|
|
127
|
+
dates.push(__normalize(range.end));
|
|
128
|
+
}
|
|
129
|
+
__normalize(this.#picker.setDate(dates, false, "Y-m-d"));
|
|
130
|
+
this.#range = range;
|
|
131
|
+
return this;
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
setDisabled(value) {
|
|
135
|
+
__requireArity(arguments.length, [0], "setDisabled");
|
|
136
|
+
value = __boundary(value);
|
|
137
|
+
this.input.disabled = __requireBoolean(value) || __requireBoolean(__normalize(this.#locked) === true);
|
|
138
|
+
if (__requireBoolean(__normalize(this.#picker) !== null)) {
|
|
139
|
+
let calendar = __normalize(this.#picker.calendarContainer);
|
|
140
|
+
calendar.inert = __normalize(this.input.disabled);
|
|
141
|
+
if (__requireBoolean(__normalize(this.input.disabled))) {
|
|
142
|
+
__normalize(this.#picker.close());
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return this;
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
dispose() {
|
|
149
|
+
__normalize(this.#changes.dispose());
|
|
150
|
+
__normalize(this.#picker.destroy());
|
|
151
|
+
super.dispose();
|
|
152
|
+
return null;
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export function dateText(value) {
|
|
157
|
+
__requireArity(arguments.length, [0], "dateText");
|
|
158
|
+
value = __boundary(value);
|
|
159
|
+
if (__requireBoolean(__requireBoolean(value === null) || __requireBoolean(value === ""))) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
let pattern = new (__hostGlobal(["RegExp"]))("^[0-9]{4}-[0-9]{2}-[0-9]{2}$");
|
|
163
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isString(value))) || __requireBoolean(!__requireBoolean(__normalize(pattern.test(value)))))) {
|
|
164
|
+
throw "Date requires YYYY-MM-DD calendar text";
|
|
165
|
+
}
|
|
166
|
+
let year = __normalize(__hostGlobal(["Number"]).parseInt(__normalize(value.slice(0, 4)), 10));
|
|
167
|
+
let month = __normalize(__hostGlobal(["Number"]).parseInt(__normalize(value.slice(5, 7)), 10));
|
|
168
|
+
let day = __normalize(__hostGlobal(["Number"]).parseInt(__normalize(value.slice(8, 10)), 10));
|
|
169
|
+
let days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
170
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(year < 1) || __requireBoolean(month < 1)) || __requireBoolean(month > 12))) {
|
|
171
|
+
throw "Invalid calendar date";
|
|
172
|
+
}
|
|
173
|
+
if (__requireBoolean(__requireBoolean(__finite(year % 4) === 0) && __requireBoolean(__requireBoolean(__finite(year % 100) !== 0) || __requireBoolean(__finite(year % 400) === 0)))) {
|
|
174
|
+
days[1] = 29;
|
|
175
|
+
}
|
|
176
|
+
let index = __finite(month - 1);
|
|
177
|
+
if (__requireBoolean(__requireBoolean(day < 1) || __requireBoolean(day > __normalize(days[index])))) {
|
|
178
|
+
throw "Invalid calendar date";
|
|
179
|
+
}
|
|
180
|
+
return value;
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function dateRange(value, min = null, max = null) {
|
|
185
|
+
__requireArity(arguments.length, [0], "dateRange");
|
|
186
|
+
value = __boundary(value);
|
|
187
|
+
min = __boundary(min);
|
|
188
|
+
max = __boundary(max);
|
|
189
|
+
if (__requireBoolean(value === null)) {
|
|
190
|
+
value = { };
|
|
191
|
+
}
|
|
192
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(value))) || __requireBoolean(__isArray(value)))) {
|
|
193
|
+
throw "Date value requires a start/end map";
|
|
194
|
+
}
|
|
195
|
+
let start = dateText(__normalize(value.start));
|
|
196
|
+
let end = dateText(__normalize(value.end));
|
|
197
|
+
if (__requireBoolean(__requireBoolean(end !== null) && __requireBoolean(__requireBoolean(start === null) || __requireBoolean(__normalize(end.localeCompare(start)) < 0)))) {
|
|
198
|
+
throw "Date range end must not precede its start";
|
|
199
|
+
}
|
|
200
|
+
for (const date of [start, end]) {
|
|
201
|
+
if (__requireBoolean(__requireBoolean(date !== null) && __requireBoolean(__requireBoolean(__requireBoolean(min !== null) && __requireBoolean(__normalize(date.localeCompare(min)) < 0)) || __requireBoolean(__requireBoolean(max !== null) && __requireBoolean(__normalize(date.localeCompare(max)) > 0))))) {
|
|
202
|
+
throw "Date is outside its min/max range";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return { start: start, end: end };
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function calendarLocale(options) {
|
|
210
|
+
__requireArity(arguments.length, [0], "calendarLocale");
|
|
211
|
+
options = __boundary(options);
|
|
212
|
+
let locale = __normalize(options.locale);
|
|
213
|
+
if (__requireBoolean(locale === null)) {
|
|
214
|
+
locale = [];
|
|
215
|
+
}
|
|
216
|
+
let months = [];
|
|
217
|
+
let shortMonths = [];
|
|
218
|
+
let weekdays = [];
|
|
219
|
+
let shortWeekdays = [];
|
|
220
|
+
let month = new (__hostGlobal(["Intl"]).DateTimeFormat)(locale, { month: "long", timeZone: "UTC" });
|
|
221
|
+
let shortMonth = new (__hostGlobal(["Intl"]).DateTimeFormat)(locale, { month: "short", timeZone: "UTC" });
|
|
222
|
+
let day = new (__hostGlobal(["Intl"]).DateTimeFormat)(locale, { weekday: "long", timeZone: "UTC" });
|
|
223
|
+
let shortDay = new (__hostGlobal(["Intl"]).DateTimeFormat)(locale, { weekday: "short", timeZone: "UTC" });
|
|
224
|
+
let index = 0;
|
|
225
|
+
let stamp = null;
|
|
226
|
+
__loop1: while (__requireBoolean(index < 12)) {
|
|
227
|
+
stamp = __normalize(__hostGlobal(["Date"]).UTC(2020, index, 1));
|
|
228
|
+
months.push(__normalize(month.format(stamp)));
|
|
229
|
+
shortMonths.push(__normalize(shortMonth.format(stamp)));
|
|
230
|
+
index = __numericAdd(index, 1);
|
|
231
|
+
}
|
|
232
|
+
index = 1;
|
|
233
|
+
__loop2: while (__requireBoolean(index <= 7)) {
|
|
234
|
+
stamp = __normalize(__hostGlobal(["Date"]).UTC(2020, 10, index));
|
|
235
|
+
weekdays.push(__normalize(day.format(stamp)));
|
|
236
|
+
shortWeekdays.push(__normalize(shortDay.format(stamp)));
|
|
237
|
+
index = __numericAdd(index, 1);
|
|
238
|
+
}
|
|
239
|
+
return { weekdays: { longhand: weekdays, shorthand: shortWeekdays }, months: { longhand: months, shorthand: shortMonths }, rangeSeparator: " – ", monthAriaLabel: "", yearAriaLabel: "" };
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=date_input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date_input.mjs","sources":["date_input.lango"],"sourcesContent":["import js \"flatpickr\" as picker\nimport js global Intl\nimport js global Date\nimport js global Number\nimport js global RegExp\nimport js global Object\nimport \"./fields\"\n class Field\nimport \"./templates\"\n cloneMarkup(name, xml)\nimport \"./input_changes\"\n class InputChanges\n\nexport dateText(value)\nexport dateRange(value, min = null, max = null)\n\ndateText(value)\n if value == null or value == \"\"\n return null\n pattern = new RegExp(\"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\")\n if !is_string(value) or !pattern.test(value)\n throw \"Date requires YYYY-MM-DD calendar text\"\n year = Number/parseInt(value.slice(0, 4), 10)\n month = Number/parseInt(value.slice(5, 7), 10)\n day = Number/parseInt(value.slice(8, 10), 10)\n days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n if year < 1 or month < 1 or month > 12\n throw \"Invalid calendar date\"\n if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)\n days[1] = 29\n index = month - 1\n if day < 1 or day > days[index]\n throw \"Invalid calendar date\"\n return value\n\ndateRange(value, min = null, max = null)\n if value == null\n value = {}\n if !is_object(value) or is_array(value)\n throw \"Date value requires a start/end map\"\n start = dateText(value.start)\n end = dateText(value.end)\n if end != null and (start == null or end.localeCompare(start) < 0)\n throw \"Date range end must not precede its start\"\n for [start, end] as date\n if date != null and ((min != null and date.localeCompare(min) < 0) or (max != null and date.localeCompare(max) > 0))\n throw \"Date is outside its min/max range\"\n return {\n start: start\n end: end\n }\n\ncalendarLocale(options)\n locale = options.locale\n if locale == null\n locale = []\n months = []\n shortMonths = []\n weekdays = []\n shortWeekdays = []\n month = new Intl/DateTimeFormat(locale, {\n month: \"long\"\n timeZone: \"UTC\"\n })\n shortMonth = new Intl/DateTimeFormat(locale, {\n month: \"short\"\n timeZone: \"UTC\"\n })\n day = new Intl/DateTimeFormat(locale, {\n weekday: \"long\"\n timeZone: \"UTC\"\n })\n shortDay = new Intl/DateTimeFormat(locale, {\n weekday: \"short\"\n timeZone: \"UTC\"\n })\n index = 0\n stamp = null\n loop while index < 12\n stamp = Date/UTC(2020, index, 1)\n months.add(month.format(stamp))\n shortMonths.add(shortMonth.format(stamp))\n index = index + 1\n index = 1\n loop while index <= 7\n stamp = Date/UTC(2020, 10, index)\n weekdays.add(day.format(stamp))\n shortWeekdays.add(shortDay.format(stamp))\n index = index + 1\n return {\n weekdays: {\n longhand: weekdays\n shorthand: shortWeekdays\n }\n months: {\n longhand: months\n shorthand: shortMonths\n }\n rangeSeparator: \" – \"\n monthAriaLabel: \"\"\n yearAriaLabel: \"\"\n }\n\nexport class DateInput(form, props) : Field\n methods\n getValue()\n setValue(value)\n setDisabled(value)\n dispose()\n\nDateInput(form, props)\n super(form, props, cloneMarkup(\"date-input\", <input type=\"text\" class=\"form-control\" />))\n @changes = new InputChanges(form, props.url)\n @locked = props.readonly == true\n @min = dateText(props.min)\n @max = dateText(props.max)\n if @min != null and @max != null and @min.localeCompare(@max) > 0\n throw \"Date min must not exceed max\"\n @range = dateRange(props.value, @min, @max)\n months = props.multiMonth\n if months == null\n months = 1\n if !is_number(months) or !Number/isInteger(months) or months < 1 or months > 12\n throw \"Date multiMonth must be an integer between 1 and 12\"\n first = props.firstWeekDay\n if first == null\n first = 1\n if !is_number(first) or !Number/isInteger(first) or first < 0 or first > 6\n throw \"Date firstWeekDay must be an integer between 0 and 6\"\n format = {}\n if is_string(props.format)\n format.display = props.format\n else\n if props.format != null\n if !is_object(props.format) or is_array(props.format)\n throw \"Date format must be a display format or options map\"\n format = Object/assign({}, props.format)\n display = format.display\n if display == null\n display = \"Y-m-d\"\n locale = calendarLocale(format)\n locale.firstDayOfWeek = first\n if props.label != null\n locale.monthAriaLabel = props.label\n locale.yearAriaLabel = props.label\n if format.calendar != null\n locale = Object/assign(locale, format.calendar)\n createPicker = picker.default\n change = (dates)\n if @input.disabled\n setValue(@range)\n return null\n start = null\n end = null\n if dates.length > 0\n start = @picker.formatDate(dates[0], \"Y-m-d\")\n if dates.length > 1\n end = @picker.formatDate(dates[1], \"Y-m-d\")\n @range = dateRange({\n start: start\n end: end\n }, @min, @max)\n @changes.changed()\n options = {\n mode: \"range\"\n dateFormat: display\n showMonths: months\n locale: locale\n inline: props.inline == true\n appendTo: @element\n disableMobile: true\n allowInput: false\n onChange: change\n }\n if @min != null\n options.minDate = createPicker.parseDate(@min, \"Y-m-d\")\n if @max != null\n options.maxDate = createPicker.parseDate(@max, \"Y-m-d\")\n @picker = createPicker(@input, options)\n if props.button == true\n @input.className = \"btn btn-outline-secondary\"\n setValue(@range)\n setDisabled(props.disabled == true)\n\nDateInput:getValue()\n return {\n start: @range.start\n end: @range.end\n }\n\nDateInput:setValue(value)\n range = dateRange(value, @min, @max)\n dates = []\n if range.start != null\n dates.add(range.start)\n if range.end != null\n dates.add(range.end)\n @picker.setDate(dates, false, \"Y-m-d\")\n @range = range\n return @this\n\nDateInput:setDisabled(value)\n @input.disabled = value or @locked == true\n if @picker != null\n calendar = @picker.calendarContainer\n calendar.inert = @input.disabled\n if @input.disabled\n @picker.close()\n return @this\n\nDateInput:dispose()\n @changes.dispose()\n @picker.destroy()\n super.dispose()\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAvFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hostGlobal as __hostGlobal,
|
|
3
|
+
isNumber as __isNumber,
|
|
4
|
+
isString as __isString,
|
|
5
|
+
isBool as __isBool,
|
|
6
|
+
isObject as __isObject,
|
|
7
|
+
isArray as __isArray,
|
|
8
|
+
add as __add,
|
|
9
|
+
requireBoolean as __requireBoolean,
|
|
10
|
+
normalize as __normalize,
|
|
11
|
+
finite as __finite,
|
|
12
|
+
numericAdd as __numericAdd,
|
|
13
|
+
boundary as __boundary,
|
|
14
|
+
requireArity as __requireArity,
|
|
15
|
+
withArity as __withArity,
|
|
16
|
+
} from "./.lango/runtime.mjs";
|
|
17
|
+
|
|
18
|
+
export class ErrorReporter {
|
|
19
|
+
active;
|
|
20
|
+
#app;
|
|
21
|
+
#url;
|
|
22
|
+
#pending;
|
|
23
|
+
#timer;
|
|
24
|
+
#flight;
|
|
25
|
+
#window;
|
|
26
|
+
#sent;
|
|
27
|
+
constructor(app, url) {
|
|
28
|
+
__requireArity(arguments.length, [0, 1], "constructor");
|
|
29
|
+
app = __boundary(app);
|
|
30
|
+
url = __boundary(url);
|
|
31
|
+
__normalize(app.checkUrl(url));
|
|
32
|
+
this.#app = app;
|
|
33
|
+
this.#url = url;
|
|
34
|
+
this.active = true;
|
|
35
|
+
this.#pending = [];
|
|
36
|
+
this.#timer = null;
|
|
37
|
+
this.#flight = false;
|
|
38
|
+
this.#window = __normalize(app.now());
|
|
39
|
+
this.#sent = 0;
|
|
40
|
+
}
|
|
41
|
+
capture(source, code, name, form) {
|
|
42
|
+
__requireArity(arguments.length, [0, 1, 2, 3], "capture");
|
|
43
|
+
source = __boundary(source);
|
|
44
|
+
code = __boundary(code);
|
|
45
|
+
name = __boundary(name);
|
|
46
|
+
form = __boundary(form);
|
|
47
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(this.active))) || __requireBoolean(form === null)) || __requireBoolean(__normalize(form.disposed)))) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (__requireBoolean(__finite(__normalize(this.#app.now()) - __normalize(this.#window)) >= 60000)) {
|
|
51
|
+
this.#window = __normalize(this.#app.now());
|
|
52
|
+
this.#sent = 0;
|
|
53
|
+
}
|
|
54
|
+
if (__requireBoolean(__normalize(this.#sent) >= 10)) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
let sources = ["ui", "window", "promise"];
|
|
58
|
+
let valid = new (__hostGlobal(["RegExp"]))("^[A-Za-z][A-Za-z0-9_]{0,63}$");
|
|
59
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(sources.includes(source)))) || __requireBoolean(!__requireBoolean(__isString(code)))) || __requireBoolean(!__requireBoolean(__normalize(valid.test(code)))))) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isString(name))) || __requireBoolean(__normalize(name.trim()) === "")) || __requireBoolean(__normalize(name.length) > 256))) {
|
|
63
|
+
name = null;
|
|
64
|
+
}
|
|
65
|
+
for (const entry of __normalize(this.#pending)) {
|
|
66
|
+
let previous = __normalize(entry.report);
|
|
67
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__normalize(entry.form) === form) && __requireBoolean(__normalize(previous.source) === source)) && __requireBoolean(__normalize(previous.code) === code)) && __requireBoolean(__normalize(previous.name) === name))) {
|
|
68
|
+
previous.count = __normalize(__hostGlobal(["Math"]).min(100, __numericAdd(__normalize(previous.count), 1)));
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (__requireBoolean(__normalize(this.#pending.length) >= 20)) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
let report = { source: source, code: code, count: 1 };
|
|
76
|
+
if (__requireBoolean(name !== null)) {
|
|
77
|
+
report.name = name;
|
|
78
|
+
}
|
|
79
|
+
__add(this.#pending, { form: form, report: report });
|
|
80
|
+
this.schedule();
|
|
81
|
+
return null;
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
schedule() {
|
|
85
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.active)) && __requireBoolean(!__requireBoolean(__normalize(this.#flight)))) && __requireBoolean(__normalize(this.#timer) === null)) && __requireBoolean(__normalize(this.#pending.length) > 0))) {
|
|
86
|
+
let action = () => {
|
|
87
|
+
this.#timer = null;
|
|
88
|
+
this.flush();
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
this.#timer = __normalize(this.#app.schedule(action, 0));
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
flush() {
|
|
97
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(this.active))) || __requireBoolean(__normalize(this.#flight)))) {
|
|
98
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
99
|
+
}
|
|
100
|
+
if (__requireBoolean(__normalize(this.#sent) >= 10)) {
|
|
101
|
+
this.#pending = [];
|
|
102
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
103
|
+
}
|
|
104
|
+
let entry = __normalize(this.#pending.shift());
|
|
105
|
+
if (__requireBoolean(entry === null)) {
|
|
106
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
107
|
+
}
|
|
108
|
+
if (__requireBoolean(entry.form.disposed)) {
|
|
109
|
+
this.schedule();
|
|
110
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
111
|
+
}
|
|
112
|
+
this.#sent = __numericAdd(__normalize(this.#sent), 1);
|
|
113
|
+
this.#flight = true;
|
|
114
|
+
return __normalize(this.#app.report(__normalize(entry.form), __normalize(this.#url), __normalize(entry.report), this)).catch(__withArity((error) => {
|
|
115
|
+
error = __boundary(error);
|
|
116
|
+
return null;
|
|
117
|
+
return null;
|
|
118
|
+
}, [0], "closure")).finally(() => {
|
|
119
|
+
this.#flight = false;
|
|
120
|
+
this.schedule();
|
|
121
|
+
return null;
|
|
122
|
+
});
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
dispose() {
|
|
126
|
+
this.active = false;
|
|
127
|
+
this.#pending = [];
|
|
128
|
+
if (__requireBoolean(__normalize(this.#timer) !== null)) {
|
|
129
|
+
__normalize(this.#app.cancelTimer(__normalize(this.#timer)));
|
|
130
|
+
this.#timer = null;
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=error_reporter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error_reporter.mjs","sources":["error_reporter.lango"],"sourcesContent":["import js global Promise\nimport js global Math\nimport js global RegExp\n\nexport class ErrorReporter(app, url)\n properties\n active\n methods\n capture(source, code, name, form)\n schedule()\n flush()\n dispose()\n\nErrorReporter(app, url)\n app.checkUrl(url)\n @app = app\n @url = url\n @active = true\n @pending = []\n @timer = null\n @flight = false\n @window = app.now()\n @sent = 0\n\nErrorReporter:capture(source, code, name, form)\n if !@active or form == null or form.disposed\n return null\n if @app.now() - @window >= 60000\n @window = @app.now()\n @sent = 0\n if @sent >= 10\n return null\n sources = [\"ui\", \"window\", \"promise\"]\n valid = new RegExp(\"^[A-Za-z][A-Za-z0-9_]{0,63}$\")\n if !sources.includes(source) or !is_string(code) or !valid.test(code)\n return null\n if !is_string(name) or name.trim() == \"\" or name.length > 256\n name = null\n for @pending as entry\n previous = entry.report\n if entry.form == form and previous.source == source and previous.code == code and previous.name == name\n previous.count = Math/min(100, previous.count + 1)\n return null\n if @pending.length >= 20\n return null\n report = {\n source: source\n code: code\n count: 1\n }\n if name != null\n report.name = name\n @pending.add({\n form: form\n report: report\n })\n schedule()\n return null\n\nErrorReporter:schedule()\n if @active and !@flight and @timer == null and @pending.length > 0\n action = ()\n @timer = null\n flush()\n @timer = @app.schedule(action, 0)\n return null\n\nErrorReporter:flush()\n if !@active or @flight\n return Promise/resolve(null)\n if @sent >= 10\n @pending = []\n return Promise/resolve(null)\n entry = @pending.shift()\n if entry == null\n return Promise/resolve(null)\n if entry.form.disposed\n schedule()\n return Promise/resolve(null)\n @sent = @sent + 1\n @flight = true\n return chain @app.report(entry.form, @url, entry.report, @this)\n catch(error)\n return null\n finally\n @flight = false\n schedule()\n\nErrorReporter:dispose()\n @active = false\n @pending = []\n if @timer != null\n @app.cancelTimer(@timer)\n @timer = null\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|