@lango-project/lango-client 0.4.0 → 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/README.md +37 -4
- package/cli/.lango/runtime.mjs +8 -1
- package/cli/create.mjs +0 -0
- package/dist/.lango/runtime.mjs +8 -1
- package/dist/app.mjs +37 -2
- package/dist/app.mjs.map +1 -1
- package/dist/client.css +7 -0
- package/dist/control.mjs +2 -0
- package/dist/control.mjs.map +1 -1
- package/dist/dimensions.mjs +102 -0
- package/dist/dimensions.mjs.map +1 -0
- package/dist/form.mjs +1 -1
- package/dist/form.mjs.map +1 -1
- package/dist/index.html +1 -1
- package/dist/main.mjs +11 -2
- package/dist/main.mjs.map +1 -1
- package/dist/renderer.mjs +15 -13
- package/dist/renderer.mjs.map +1 -1
- package/dist/table_scope.mjs +166 -0
- package/dist/table_scope.mjs.map +1 -0
- package/dist/tables.mjs +798 -115
- package/dist/tables.mjs.map +1 -1
- package/dist/vendor/dompurify.mjs +181 -267
- package/dist/vendor/purify.es.mjs.map +1 -1
- package/docs/implementation.md +51 -0
- package/package.json +2 -2
- package/src/app.lango +35 -3
- package/src/control.lango +3 -0
- package/src/dimensions.lango +65 -0
- package/src/form.lango +1 -1
- package/src/main.lango +9 -0
- package/src/renderer.lango +17 -9
- package/src/table_scope.lango +119 -0
- package/src/tables.lango +620 -105
- package/web/client.css +7 -0
- package/web/index.html +1 -1
package/README.md
CHANGED
|
@@ -305,14 +305,15 @@ control definitions or arrays of definitions. Image accepts an HTTP(S) or image
|
|
|
305
305
|
data URL, or base64 `content` with an image `mimeType` (default `image/png`).
|
|
306
306
|
|
|
307
307
|
Cards, tables, tabs and navigation do not introduce implicit Form scopes.
|
|
308
|
-
Controls inside them
|
|
309
|
-
their independent values and tokens.
|
|
308
|
+
Controls inside them send through the containing Form; explicit nested Forms keep
|
|
309
|
+
their independent values and tokens. Tables use local cell scopes and their
|
|
310
|
+
valueMode controls collection; ordinary named non-field controls contribute null.
|
|
310
311
|
|
|
311
312
|
Tables consume `tableCol`, one optional `tableHeader`, `tableRow`, `tableCell`
|
|
312
313
|
and `tableDivider` definitions. Header rows contain native column headings.
|
|
313
314
|
`rowSpan` and `colSpan` are Cell properties; spans must be integers from 1 to
|
|
314
|
-
1000. Column `colSpan` uses the native column span.
|
|
315
|
-
|
|
315
|
+
1000. Column `colSpan` uses the native column span. Positive numeric column widths use character units (`ch`); -1 selects automatic
|
|
316
|
+
width. Resizable columns support pointer dragging and
|
|
316
317
|
Left/Right keys in 10-pixel steps, with a minimum width of 24 pixels per column.
|
|
317
318
|
A resizable column must end at a first-row cell boundary. Row/Cell `url` sends
|
|
318
319
|
the owning Form with its current token. Inner buttons, links and fields do not
|
|
@@ -592,3 +593,35 @@ values use DOM properties. Markdown uses its separate sanitization path.
|
|
|
592
593
|
- Query/hash history policy and additional platforms remain open. The delivery
|
|
593
594
|
generator currently targets same-origin Web/Bootstrap; deep-link static hosting
|
|
594
595
|
and a packed generated-application browser test are implemented.
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
## Table data and row commands
|
|
599
|
+
|
|
600
|
+
Tables support `valueMode` (`none`, `cells`, `rows`, `mixed`), an optional
|
|
601
|
+
`tableRowTemplate` definition in `rowTemplate`, and an initial `value` array.
|
|
602
|
+
`values` assignments to a table replace every body row, preserving its columns,
|
|
603
|
+
header and configuration. Null and [] clear the body. Row maps bind to column
|
|
604
|
+
names; missing fields render empty. Without a template, cells show safe text
|
|
605
|
+
(including JSON text for structured values) and contribute null when collected.
|
|
606
|
+
|
|
607
|
+
Template cells map to columns by position. One control receives/returns a direct
|
|
608
|
+
value; multiple named controls receive/return a map. Each cell has a local control
|
|
609
|
+
scope, so repeated template field names are independent. Rows do not create
|
|
610
|
+
Forms or tokens. Explicit nested Forms and asynchronous File fields remain
|
|
611
|
+
supported. Metadata (`tableRow.data`, `setRowData`) stays out of DOM and form
|
|
612
|
+
values. It is client-side data and must not contain server secrets.
|
|
613
|
+
|
|
614
|
+
A named table scopes targets as `table/cell/control`. Static unnamed cells expose
|
|
615
|
+
their named controls in the table scope; unnamed tables expose static cell names
|
|
616
|
+
in their containing scope. Generated rows keep unnamed-cell controls local.
|
|
617
|
+
Duplicate exposed names fail, including fixed named template cells repeated
|
|
618
|
+
across rows. Failed row replacement leaves previous rows and names usable.
|
|
619
|
+
Removed/replaced rows dispose their controls, nested Forms and listeners.
|
|
620
|
+
|
|
621
|
+
The dispatcher accepts `addRow`, `insertRow`, `deleteRow`, `setRowValue`,
|
|
622
|
+
`setRowData`, and `setCellValue`. All use `name` as the table target. Insert uses
|
|
623
|
+
`beforeIndex`; other indexed commands use `index`. Cell assignment adds `column`
|
|
624
|
+
(a name or definition index). Values use `value`. Indices are zero based;
|
|
625
|
+
insertion at the row count appends. Full `values` commands retain their final
|
|
626
|
+
position after incremental commands. See the Lango UI package
|
|
627
|
+
documentation for builder examples and precise collection rules.
|
package/cli/.lango/runtime.mjs
CHANGED
|
@@ -100,6 +100,9 @@ function postgresQuery(sql, parameters) {
|
|
|
100
100
|
return { text: text + sql.slice(at), values };
|
|
101
101
|
}
|
|
102
102
|
export const DB = Object.freeze({ Active: "active", RollbackOnly: "rollback_only", Failed: "failed" });
|
|
103
|
+
const loggingStore = Symbol.for("lango.logging");
|
|
104
|
+
const logging = globalThis[loggingStore] ?? { verbose: false };
|
|
105
|
+
globalThis[loggingStore] = logging;
|
|
103
106
|
const contextStore = Symbol.for("lango.contexts");
|
|
104
107
|
const contexts = globalThis[contextStore] ?? new Map();
|
|
105
108
|
globalThis[contextStore] = contexts;
|
|
@@ -114,6 +117,8 @@ export class RuntimeConfigurationError extends Error {
|
|
|
114
117
|
export function configure(options = {}) {
|
|
115
118
|
if (options === null || typeof options !== "object" || Array.isArray(options))
|
|
116
119
|
throw new RuntimeConfigurationError("runtime configuration must be an object");
|
|
120
|
+
if (options.verbose !== undefined && typeof options.verbose !== "boolean")
|
|
121
|
+
throw new RuntimeConfigurationError("runtime verbose must be boolean");
|
|
117
122
|
const nextCatalog = options.catalog ?? {};
|
|
118
123
|
const nextOutput = options.output ?? null;
|
|
119
124
|
const nextDatabase = options.database_adapter ?? null;
|
|
@@ -135,6 +140,7 @@ export function configure(options = {}) {
|
|
|
135
140
|
} catch (error) {
|
|
136
141
|
throw new RuntimeConfigurationError(error.message);
|
|
137
142
|
}
|
|
143
|
+
if (options.verbose !== undefined) logging.verbose = options.verbose;
|
|
138
144
|
defaultI18n = nextI18n;
|
|
139
145
|
output = nextOutput;
|
|
140
146
|
if (database !== null) failedTransactions.delete(database);
|
|
@@ -341,7 +347,8 @@ export function println(value) {
|
|
|
341
347
|
}
|
|
342
348
|
|
|
343
349
|
const defaultLog = Object.freeze({
|
|
344
|
-
|
|
350
|
+
get verbose() { return logging.verbose || process.env.LANGO_VERBOSE === "1"; },
|
|
351
|
+
debug(value) { if (!defaultLog.verbose) return null; return writeLog(process.stdout, "DEBUG", value); },
|
|
345
352
|
info(value) { return writeLog(process.stdout, "INFO", value); },
|
|
346
353
|
warn(value) { return writeLog(process.stderr, "WARN", value); },
|
|
347
354
|
err(value) { return writeLog(process.stderr, "ERROR", value); },
|
package/cli/create.mjs
CHANGED
|
File without changes
|
package/dist/.lango/runtime.mjs
CHANGED
|
@@ -98,6 +98,9 @@ function postgresQuery(sql, parameters) {
|
|
|
98
98
|
return { text: text + sql.slice(at), values };
|
|
99
99
|
}
|
|
100
100
|
export const DB = Object.freeze({ Active: "active", RollbackOnly: "rollback_only", Failed: "failed" });
|
|
101
|
+
const loggingStore = Symbol.for("lango.logging");
|
|
102
|
+
const logging = globalThis[loggingStore] ?? { verbose: false };
|
|
103
|
+
globalThis[loggingStore] = logging;
|
|
101
104
|
const contextStore = Symbol.for("lango.contexts");
|
|
102
105
|
const contexts = globalThis[contextStore] ?? new Map();
|
|
103
106
|
globalThis[contextStore] = contexts;
|
|
@@ -112,6 +115,8 @@ export class RuntimeConfigurationError extends Error {
|
|
|
112
115
|
export function configure(options = {}) {
|
|
113
116
|
if (options === null || typeof options !== "object" || Array.isArray(options))
|
|
114
117
|
throw new RuntimeConfigurationError("runtime configuration must be an object");
|
|
118
|
+
if (options.verbose !== undefined && typeof options.verbose !== "boolean")
|
|
119
|
+
throw new RuntimeConfigurationError("runtime verbose must be boolean");
|
|
115
120
|
const nextCatalog = options.catalog ?? {};
|
|
116
121
|
const nextOutput = options.output ?? null;
|
|
117
122
|
const nextDatabase = options.database_adapter ?? null;
|
|
@@ -133,6 +138,7 @@ export function configure(options = {}) {
|
|
|
133
138
|
} catch (error) {
|
|
134
139
|
throw new RuntimeConfigurationError(error.message);
|
|
135
140
|
}
|
|
141
|
+
if (options.verbose !== undefined) logging.verbose = options.verbose;
|
|
136
142
|
defaultI18n = nextI18n;
|
|
137
143
|
output = nextOutput;
|
|
138
144
|
if (database !== null) failedTransactions.delete(database);
|
|
@@ -339,7 +345,8 @@ export function println(value) {
|
|
|
339
345
|
}
|
|
340
346
|
|
|
341
347
|
const defaultLog = Object.freeze({
|
|
342
|
-
|
|
348
|
+
get verbose() { return logging.verbose || false; },
|
|
349
|
+
debug(value) { if (!defaultLog.verbose) return null; console.debug(String(value)); return null; },
|
|
343
350
|
info(value) { console.info(String(value)); return null; },
|
|
344
351
|
warn(value) { console.warn(String(value)); return null; },
|
|
345
352
|
err(value) { console.error(String(value)); return null; },
|
package/dist/app.mjs
CHANGED
|
@@ -97,6 +97,9 @@ export class App {
|
|
|
97
97
|
error = __boundary(error);
|
|
98
98
|
code = __boundary(code);
|
|
99
99
|
name = __boundary(name);
|
|
100
|
+
if (__requireBoolean(__requireBoolean(form !== null) && __requireBoolean(__normalize(form.requestForm) !== null))) {
|
|
101
|
+
form = __normalize(form.requestForm);
|
|
102
|
+
}
|
|
100
103
|
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.#disposed)) || __requireBoolean(form === null)) || __requireBoolean(__normalize(form.disposed)))) {
|
|
101
104
|
return null;
|
|
102
105
|
}
|
|
@@ -118,6 +121,15 @@ export class App {
|
|
|
118
121
|
return null;
|
|
119
122
|
return null;
|
|
120
123
|
}
|
|
124
|
+
clearSavedToken() {
|
|
125
|
+
try {
|
|
126
|
+
__normalize(this.#host.storage.removeItem("lango.token"));
|
|
127
|
+
return true;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
121
133
|
post(url, input, token) {
|
|
122
134
|
__requireArity(arguments.length, [0, 1, 2], "post");
|
|
123
135
|
url = __boundary(url);
|
|
@@ -135,15 +147,20 @@ export class App {
|
|
|
135
147
|
return this.request(url, input, token, signal, true);
|
|
136
148
|
return null;
|
|
137
149
|
}
|
|
138
|
-
request(url, input, token, signal = null, channel = false) {
|
|
150
|
+
request(url, input, token, signal = null, channel = false, opening = false) {
|
|
139
151
|
__requireArity(arguments.length, [0, 1, 2], "request");
|
|
140
152
|
url = __boundary(url);
|
|
141
153
|
input = __boundary(input);
|
|
142
154
|
token = __boundary(token);
|
|
143
155
|
signal = __boundary(signal);
|
|
144
156
|
channel = __boundary(channel);
|
|
157
|
+
opening = __boundary(opening);
|
|
145
158
|
let target = this.checkUrl(url);
|
|
146
159
|
let headers = { "Content-Type": "application/json" };
|
|
160
|
+
headers["X-Lango-Screen"] = "wide";
|
|
161
|
+
if (__requireBoolean(__normalize(this.#host.screen) !== null)) {
|
|
162
|
+
headers["X-Lango-Screen"] = __normalize(this.#host.screen());
|
|
163
|
+
}
|
|
147
164
|
if (__requireBoolean(token !== null)) {
|
|
148
165
|
headers.Authorization = `Bearer ${token}`;
|
|
149
166
|
}
|
|
@@ -154,6 +171,12 @@ export class App {
|
|
|
154
171
|
return __normalize(this.#host.fetch(`${__normalize(target.pathname)}${__normalize(target.search)}`, options)).then(__withArity((res) => {
|
|
155
172
|
res = __boundary(res);
|
|
156
173
|
if (__requireBoolean(!__requireBoolean(__normalize(res.ok)))) {
|
|
174
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(opening) && __requireBoolean(__normalize(res.status) === 401)) && __requireBoolean(token !== null))) {
|
|
175
|
+
if (__requireBoolean(this.clearSavedToken())) {
|
|
176
|
+
throw new (__hostGlobal(["Error"]))("Startup HTTP 401: saved token was rejected and cleared. Reload the page to start a new session.");
|
|
177
|
+
}
|
|
178
|
+
throw new (__hostGlobal(["Error"]))("Startup HTTP 401: saved token was rejected but storage could not be cleared. Clear this site's local storage and reload.");
|
|
179
|
+
}
|
|
157
180
|
if (__requireBoolean(!__requireBoolean(channel))) {
|
|
158
181
|
throw `HTTP ${__normalize(res.status)}`;
|
|
159
182
|
}
|
|
@@ -194,7 +217,7 @@ export class App {
|
|
|
194
217
|
} catch (error) {
|
|
195
218
|
token = null;
|
|
196
219
|
}
|
|
197
|
-
return this.
|
|
220
|
+
return this.request("/", { }, token, null, false, true).then(__withArity((packet) => {
|
|
198
221
|
packet = __boundary(packet);
|
|
199
222
|
this.#events = __normalize(packet.body);
|
|
200
223
|
if (__requireBoolean(__normalize(this.#events.clientErrorUrl) !== null)) {
|
|
@@ -543,6 +566,18 @@ export class App {
|
|
|
543
566
|
cmd = __boundary(cmd);
|
|
544
567
|
if (__normalize(cmd.type) === "values") {
|
|
545
568
|
__normalize(form.setValue(__normalize(cmd.values)));
|
|
569
|
+
} else if (__normalize(cmd.type) === "addRow") {
|
|
570
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).addRow(__normalize(cmd.value)));
|
|
571
|
+
} else if (__normalize(cmd.type) === "insertRow") {
|
|
572
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).insertRow(__normalize(cmd.beforeIndex), __normalize(cmd.value)));
|
|
573
|
+
} else if (__normalize(cmd.type) === "deleteRow") {
|
|
574
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).deleteRow(__normalize(cmd.index)));
|
|
575
|
+
} else if (__normalize(cmd.type) === "setRowValue") {
|
|
576
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setRowValue(__normalize(cmd.index), __normalize(cmd.value)));
|
|
577
|
+
} else if (__normalize(cmd.type) === "setRowData") {
|
|
578
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setRowData(__normalize(cmd.index), __normalize(cmd.value)));
|
|
579
|
+
} else if (__normalize(cmd.type) === "setCellValue") {
|
|
580
|
+
__normalize(__normalize(form.find(__normalize(cmd.name))).setCellValue(__normalize(cmd.index), __normalize(cmd.column), __normalize(cmd.value)));
|
|
546
581
|
} else if (__normalize(cmd.type) === "invalid") {
|
|
547
582
|
__normalize(__normalize(form.find(__normalize(cmd.name))).setInvalid(__normalize(cmd.message)));
|
|
548
583
|
} else if (__normalize(cmd.type) === "set") {
|
package/dist/app.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.mjs","sources":["app.lango"],"sourcesContent":["import js global Object\nimport js global Promise\nimport js global URL\nimport js global Date\nimport \"./form\"\n class Form\nimport \"./heartbeat\"\n class Heartbeat\nimport \"./error_reporter\"\n class ErrorReporter\n\nexport class App(host, renderer)\n properties\n forms\n root\n renderer\n heartbeat\n resources\n reporter\n methods\n start()\n post(url, input, token)\n saveToken(token)\n send(form, url, owner = null)\n deliver(form, action, owner, generation)\n report(form, url, input, owner)\n executeDelivery(job)\n checkUrl(url)\n hostUrl()\n request(url, input, token, signal = null, channel = false)\n poll(url, input, token, signal)\n canPoll(form)\n pausePolls(form = null)\n resumePolls()\n schedule(action, delay)\n cancelTimer(timer)\n now()\n error(form, error, code = \"UiFailure\", name = null)\n drain()\n execute(job)\n navigate(url, push = true)\n selectTemplate(path)\n ping()\n executePing(job)\n command(form, cmd)\n dispose()\n\nApp(host, renderer)\n @host = host\n @renderer = renderer\n @forms = []\n @queue = []\n @active = []\n @disposed = false\n @root = null\n @events = {}\n @template = null\n @heartbeat = null\n @pingJob = null\n @resources = []\n @reporter = null\n\nApp:now()\n if @host.now != null\n return @host.now()\n return Date/now()\n\nApp:hostUrl()\n return @host.location.href\n\nApp:schedule(action, delay)\n return @host.schedule(action, delay)\n\nApp:cancelTimer(timer)\n @host.cancelTimer(timer)\n return null\n\nApp:checkUrl(url)\n if !is_string(url) or url.trim() == \"\"\n throw \"UI request requires a URL\"\n target = new URL(url, @host.location.href)\n if target.origin != @host.location.origin\n throw \"UI requests must use the current origin\"\n return target\n\nApp:error(form, error, code = \"UiFailure\", name = null)\n if @disposed or form == null or form.disposed\n return null\n @renderer.reportError(form, error)\n if @reporter != null\n @reporter.capture(\"ui\", code, name, form)\n return null\n\nApp:saveToken(token)\n try\n @host.storage.setItem(\"lango.token\", token)\n catch error\n return null\n return null\n\nApp:post(url, input, token)\n return request(url, input, token)\n\nApp:poll(url, input, token, signal)\n return request(url, input, token, signal, true)\n\nApp:request(url, input, token, signal = null, channel = false)\n target = checkUrl(url)\n headers = {\n \"Content-Type\": \"application/json\"\n }\n if token != null\n headers.Authorization = \"Bearer ${token}\"\n options = {\n method: \"POST\"\n headers: headers\n body: to_json(input)\n }\n if signal != null\n options.signal = signal\n return chain @host.fetch(\"${target.pathname}${target.search}\", options)\n then(res)\n capture channel\n if !res.ok\n if !channel\n throw \"HTTP ${res.status}\"\n if res.status != 409\n return {\n status: res.status\n retryAfter: res.headers.get(\"retry-after\")\n }\n return chain res.json()\n then(body)\n capture res\n capture channel\n if !is_object(body) or is_array(body)\n if channel\n throw {\n code: \"InvalidPollResponse\"\n }\n throw \"UI response must be a map\"\n status = res.status\n if status == null\n status = 200\n return {\n status: status\n token: res.headers.get(\"x-lango-token\")\n body: body\n }\n catch(error)\n capture channel\n if channel\n throw {\n code: \"InvalidPollResponse\"\n }\n throw error\n\nApp:start()\n token = null\n try\n token = @host.storage.getItem(\"lango.token\")\n catch error\n token = null\n return chain post(\"/\", {}, token)\n then(packet)\n @events = packet.body\n if @events.clientErrorUrl != null\n @reporter = new ErrorReporter(@this, @events.clientErrorUrl)\n if @events.pingUrl != null\n @heartbeat = new Heartbeat(@this, @host, @events.pingUrl)\n @root = new Form(@this, null, packet.token)\n @root.element = @host.mount\n @root.setToken(packet.token)\n return chain navigate(@host.location.pathname, false)\n then(ignored)\n if @heartbeat != null\n @heartbeat.start()\n return null\n\nApp:send(form, url, owner = null)\n if @disposed or form.disposed\n return Promise/reject(\"Form is disposed\")\n pending = new Promise((resolve, reject)\n capture form\n capture url\n capture owner\n @queue.add({\n kind: \"send\"\n form: form\n url: url\n owner: owner\n resolve: resolve\n reject: reject\n })\n drain()\n )\n return pending\n\nApp:deliver(form, action, owner, generation)\n if @disposed or form.disposed or !owner.active\n return Promise/resolve(null)\n deferred = Promise/withResolvers()\n @queue.add({\n kind: \"delivery\"\n form: form\n action: action\n owner: owner\n generation: generation\n resolve: deferred.resolve\n reject: deferred.reject\n })\n drain()\n return deferred.promise\n\nApp:report(form, url, input, owner)\n if @disposed or form.disposed or !owner.active\n return Promise/resolve(null)\n deferred = Promise/withResolvers()\n @queue.add({\n kind: \"report\"\n form: form\n url: url\n input: input\n owner: owner\n resolve: deferred.resolve\n reject: deferred.reject\n })\n drain()\n return deferred.promise\n\nApp:canPoll(form)\n if @disposed or form.disposed or @pingJob != null\n return false\n for @active as job\n if form.related(job.form)\n return false\n for @queue as job\n if form.related(job.form)\n return false\n return true\n\nApp:pausePolls(form = null)\n for @forms.slice() as candidate\n if form == null or form.related(candidate)\n candidate.activity.pause()\n return null\n\nApp:resumePolls()\n for @forms.slice() as form\n form.activity.resume()\n return null\n\nApp:drain()\n if @pingJob != null\n if @active.length == 0 and !@pingJob.running\n @pingJob.running = true\n executePing(@pingJob)\n return null\n for @queue.slice() as job\n blocked = false\n for @active as running\n if job.form.related(running.form)\n blocked = true\n for @queue as earlier\n if earlier == job\n break\n if job.form.related(earlier.form)\n blocked = true\n if !blocked\n @queue.splice(@queue.indexOf(job), 1)\n @active.add(job)\n if job.kind == \"delivery\"\n executeDelivery(job)\n else\n pausePolls(job.form)\n execute(job)\n resumePolls()\n return null\n\nApp:executeDelivery(job)\n return chain Promise/resolve(null)\n then(ignored)\n capture job\n if !job.form.disposed and job.owner.active and job.owner.generation == job.generation\n action = job.action\n action()\n job.resolve(null)\n catch(error)\n capture job\n job.reject(error)\n finally\n capture job\n @active.splice(@active.indexOf(job), 1)\n drain()\n\nApp:ping()\n if @disposed or @heartbeat == null\n return Promise/resolve(null)\n if @pingJob != null\n return @pingJob.promise\n deferred = Promise/withResolvers()\n @pingJob = {\n promise: deferred.promise\n resolve: deferred.resolve\n reject: deferred.reject\n running: false\n }\n pausePolls()\n drain()\n return deferred.promise\n\nApp:executePing(job)\n return chain Promise/resolve(null)\n then(ignored)\n return @heartbeat.exchange()\n then(ignored)\n capture job\n job.resolve(null)\n catch(error)\n capture job\n job.reject(error)\n finally\n @pingJob = null\n drain()\n\nApp:execute(job)\n form = job.form\n return chain Promise/resolve(null)\n then(ignored)\n capture form\n capture job\n if form.disposed\n throw \"Form is disposed\"\n if job.owner != null and !job.owner.active\n return null\n if job.kind == \"report\"\n return post(job.url, job.input, form.token)\n form.clearValidation()\n @renderer.waiting(form, true)\n ready = form.prepareValue()\n if ready == null\n return post(job.url, form.getValue(), form.token)\n return chain ready\n then(ignored)\n capture form\n capture job\n if form.disposed\n throw \"Form is disposed\"\n if job.owner != null and !job.owner.active\n return null\n return post(job.url, form.getValue(), form.token)\n then(packet)\n capture form\n capture job\n if packet != null and !form.disposed and (job.owner == null or job.owner.active)\n if job.kind == \"report\"\n form.setToken(packet.token)\n else\n form.handle(packet)\n then(ignored)\n capture job\n job.resolve(null)\n catch(error)\n capture job\n job.reject(error)\n finally\n capture job\n capture form\n if job.kind == \"send\"\n @renderer.waiting(form, false)\n @active.splice(@active.indexOf(job), 1)\n drain()\n\nApp:navigate(url, push = true)\n target = new URL(url, @host.location.href)\n if target.origin != @host.location.origin\n throw \"UI navigation must use the current origin\"\n path = target.pathname\n if path == \"/\"\n path = \"/index\"\n template = selectTemplate(path)\n ready = Promise/resolve(null)\n if template != @template\n if template != null\n ready = @root.send(template)\n else\n @template = null\n return chain ready\n then(ignored)\n capture template\n capture path\n capture Form\n @template = template\n form = @root\n if template != null\n form = @root.find(\"__content__\")\n if !is_kindof(form, Form)\n throw \"Template requires a __content__ form\"\n return form.send(path)\n then(ignored)\n capture target\n capture push\n if push\n @host.history.pushState(null, \"\", \"${target.pathname}${target.search}${target.hash}\")\n if @renderer.locationChanged != null\n @renderer.locationChanged(target.href)\n return null\n\nApp:selectTemplate(path)\n urls = @events.templates\n if urls == null\n urls = []\n selected = @events.defaultTemplate\n if path == selected\n throw \"Template URLs cannot be used as page URLs\"\n best = 0\n for urls as url\n if !is_string(url) or !url.startsWith(\"/\") or url == \"/\" or url.endsWith(\"/\")\n throw \"Invalid template URL\"\n if path == url\n throw \"Template URLs cannot be used as page URLs\"\n if path == url or path.startsWith(\"${url}/\")\n if url.length > best\n selected = url\n best = url.length\n if path == selected\n throw \"Template URLs cannot be used as page URLs\"\n return selected\n\nApp:command(form, cmd)\n switch cmd.type\n case \"values\"\n form.setValue(cmd.values)\n case \"invalid\"\n form.find(cmd.name).setInvalid(cmd.message)\n case \"set\"\n targetForm = form.find(cmd.name)\n if !is_kindof(targetForm, Form)\n throw \"Set requires a form target\"\n @renderer.show(targetForm, cmd.control)\n case \"setUrl\"\n target = new URL(cmd.url, @host.location.href)\n if target.origin != @host.location.origin\n throw \"UI URL must use the current origin\"\n @host.history.pushState(null, \"\", \"${target.pathname}${target.search}${target.hash}\")\n if @renderer.locationChanged != null\n @renderer.locationChanged(target.href)\n case \"redirect\"\n action = ()\n capture cmd\n chain navigate(cmd.url)\n catch(problem)\n capture form\n error(form, problem)\n @host.defer(action)\n case \"disable\"\n form.find(cmd.name).setDisabled(true)\n case \"enable\"\n form.find(cmd.name).setDisabled(false)\n case \"changeCaption\"\n form.find(cmd.name).setCaption(cmd.caption)\n case \"activateTabItem\"\n form.find(cmd.name).activate()\n case \"setProgress\"\n form.find(cmd.name).setRange(cmd.min, cmd.max, cmd.value)\n case \"updateProgress\"\n form.find(cmd.name).update(cmd.value, cmd.label)\n case \"showAlert\"\n @renderer.presentations.showAlert(form, cmd)\n case \"dismissAlert\"\n @renderer.presentations.dismissAlert(form, cmd.name)\n case \"showToast\"\n @renderer.presentations.showToast(form, cmd.toast, cmd.stack)\n case \"showDialog\"\n @renderer.presentations.showDialog(form, cmd.dialog, cmd.keepPrev)\n case \"swapDialog\"\n @renderer.presentations.swapDialog(form)\n case \"setTimer\"\n form.activity.timer(cmd.url, cmd.interval)\n case \"clearTimer\"\n form.activity.clearTimer(cmd.url)\n case \"setInterval\"\n form.activity.timer(cmd.url, cmd.interval, true)\n case \"clearInterval\"\n form.activity.clearTimer(cmd.url, true)\n case \"startLongPoll\"\n form.activity.startLongPoll(cmd.url, cmd.key, cmd.cursor)\n case \"stopLongPoll\"\n form.activity.stopLongPoll(cmd.url, cmd.key)\n else\n throw \"Unsupported UI command: ${cmd.type}\"\n return null\n\nApp:dispose()\n @disposed = true\n if @heartbeat != null\n @heartbeat.dispose()\n if @reporter != null\n @reporter.dispose()\n for @forms.slice() as form\n form.dispose()\n for @queue as job\n job.reject(\"Application is disposed\")\n @queue = []\n for @resources as release\n release()\n @resources = []\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"app.mjs","sources":["app.lango"],"sourcesContent":["import js global Error\nimport js global Object\nimport js global Promise\nimport js global URL\nimport js global Date\nimport \"./form\"\n class Form\nimport \"./heartbeat\"\n class Heartbeat\nimport \"./error_reporter\"\n class ErrorReporter\n\nexport class App(host, renderer)\n properties\n forms\n root\n renderer\n heartbeat\n resources\n reporter\n methods\n start()\n post(url, input, token)\n saveToken(token)\n clearSavedToken()\n send(form, url, owner = null)\n deliver(form, action, owner, generation)\n report(form, url, input, owner)\n executeDelivery(job)\n checkUrl(url)\n hostUrl()\n request(url, input, token, signal = null, channel = false, opening = false)\n poll(url, input, token, signal)\n canPoll(form)\n pausePolls(form = null)\n resumePolls()\n schedule(action, delay)\n cancelTimer(timer)\n now()\n error(form, error, code = \"UiFailure\", name = null)\n drain()\n execute(job)\n navigate(url, push = true)\n selectTemplate(path)\n ping()\n executePing(job)\n command(form, cmd)\n dispose()\n\nApp(host, renderer)\n @host = host\n @renderer = renderer\n @forms = []\n @queue = []\n @active = []\n @disposed = false\n @root = null\n @events = {}\n @template = null\n @heartbeat = null\n @pingJob = null\n @resources = []\n @reporter = null\n\nApp:now()\n if @host.now != null\n return @host.now()\n return Date/now()\n\nApp:hostUrl()\n return @host.location.href\n\nApp:schedule(action, delay)\n return @host.schedule(action, delay)\n\nApp:cancelTimer(timer)\n @host.cancelTimer(timer)\n return null\n\nApp:checkUrl(url)\n if !is_string(url) or url.trim() == \"\"\n throw \"UI request requires a URL\"\n target = new URL(url, @host.location.href)\n if target.origin != @host.location.origin\n throw \"UI requests must use the current origin\"\n return target\n\nApp:error(form, error, code = \"UiFailure\", name = null)\n if form != null and form.requestForm != null\n form = form.requestForm\n if @disposed or form == null or form.disposed\n return null\n @renderer.reportError(form, error)\n if @reporter != null\n @reporter.capture(\"ui\", code, name, form)\n return null\n\nApp:saveToken(token)\n try\n @host.storage.setItem(\"lango.token\", token)\n catch error\n return null\n return null\n\nApp:clearSavedToken()\n try\n @host.storage.removeItem(\"lango.token\")\n return true\n catch error\n return false\n\nApp:post(url, input, token)\n return request(url, input, token)\n\nApp:poll(url, input, token, signal)\n return request(url, input, token, signal, true)\n\nApp:request(url, input, token, signal = null, channel = false, opening = false)\n target = checkUrl(url)\n headers = {\n \"Content-Type\": \"application/json\"\n }\n headers[\"X-Lango-Screen\"] = \"wide\"\n if @host.screen != null\n headers[\"X-Lango-Screen\"] = @host.screen()\n if token != null\n headers.Authorization = \"Bearer ${token}\"\n options = {\n method: \"POST\"\n headers: headers\n body: to_json(input)\n }\n if signal != null\n options.signal = signal\n return chain @host.fetch(\"${target.pathname}${target.search}\", options)\n then(res)\n capture channel\n capture opening\n capture token\n if !res.ok\n if opening and res.status == 401 and token != null\n if clearSavedToken()\n throw new Error(\"Startup HTTP 401: saved token was rejected and cleared. Reload the page to start a new session.\")\n throw new Error(\"Startup HTTP 401: saved token was rejected but storage could not be cleared. Clear this site's local storage and reload.\")\n if !channel\n throw \"HTTP ${res.status}\"\n if res.status != 409\n return {\n status: res.status\n retryAfter: res.headers.get(\"retry-after\")\n }\n return chain res.json()\n then(body)\n capture res\n capture channel\n if !is_object(body) or is_array(body)\n if channel\n throw {\n code: \"InvalidPollResponse\"\n }\n throw \"UI response must be a map\"\n status = res.status\n if status == null\n status = 200\n return {\n status: status\n token: res.headers.get(\"x-lango-token\")\n body: body\n }\n catch(error)\n capture channel\n if channel\n throw {\n code: \"InvalidPollResponse\"\n }\n throw error\n\nApp:start()\n token = null\n try\n token = @host.storage.getItem(\"lango.token\")\n catch error\n token = null\n return chain request(\"/\", {}, token, null, false, true)\n then(packet)\n @events = packet.body\n if @events.clientErrorUrl != null\n @reporter = new ErrorReporter(@this, @events.clientErrorUrl)\n if @events.pingUrl != null\n @heartbeat = new Heartbeat(@this, @host, @events.pingUrl)\n @root = new Form(@this, null, packet.token)\n @root.element = @host.mount\n @root.setToken(packet.token)\n return chain navigate(@host.location.pathname, false)\n then(ignored)\n if @heartbeat != null\n @heartbeat.start()\n return null\n\nApp:send(form, url, owner = null)\n if @disposed or form.disposed\n return Promise/reject(\"Form is disposed\")\n pending = new Promise((resolve, reject)\n capture form\n capture url\n capture owner\n @queue.add({\n kind: \"send\"\n form: form\n url: url\n owner: owner\n resolve: resolve\n reject: reject\n })\n drain()\n )\n return pending\n\nApp:deliver(form, action, owner, generation)\n if @disposed or form.disposed or !owner.active\n return Promise/resolve(null)\n deferred = Promise/withResolvers()\n @queue.add({\n kind: \"delivery\"\n form: form\n action: action\n owner: owner\n generation: generation\n resolve: deferred.resolve\n reject: deferred.reject\n })\n drain()\n return deferred.promise\n\nApp:report(form, url, input, owner)\n if @disposed or form.disposed or !owner.active\n return Promise/resolve(null)\n deferred = Promise/withResolvers()\n @queue.add({\n kind: \"report\"\n form: form\n url: url\n input: input\n owner: owner\n resolve: deferred.resolve\n reject: deferred.reject\n })\n drain()\n return deferred.promise\n\nApp:canPoll(form)\n if @disposed or form.disposed or @pingJob != null\n return false\n for @active as job\n if form.related(job.form)\n return false\n for @queue as job\n if form.related(job.form)\n return false\n return true\n\nApp:pausePolls(form = null)\n for @forms.slice() as candidate\n if form == null or form.related(candidate)\n candidate.activity.pause()\n return null\n\nApp:resumePolls()\n for @forms.slice() as form\n form.activity.resume()\n return null\n\nApp:drain()\n if @pingJob != null\n if @active.length == 0 and !@pingJob.running\n @pingJob.running = true\n executePing(@pingJob)\n return null\n for @queue.slice() as job\n blocked = false\n for @active as running\n if job.form.related(running.form)\n blocked = true\n for @queue as earlier\n if earlier == job\n break\n if job.form.related(earlier.form)\n blocked = true\n if !blocked\n @queue.splice(@queue.indexOf(job), 1)\n @active.add(job)\n if job.kind == \"delivery\"\n executeDelivery(job)\n else\n pausePolls(job.form)\n execute(job)\n resumePolls()\n return null\n\nApp:executeDelivery(job)\n return chain Promise/resolve(null)\n then(ignored)\n capture job\n if !job.form.disposed and job.owner.active and job.owner.generation == job.generation\n action = job.action\n action()\n job.resolve(null)\n catch(error)\n capture job\n job.reject(error)\n finally\n capture job\n @active.splice(@active.indexOf(job), 1)\n drain()\n\nApp:ping()\n if @disposed or @heartbeat == null\n return Promise/resolve(null)\n if @pingJob != null\n return @pingJob.promise\n deferred = Promise/withResolvers()\n @pingJob = {\n promise: deferred.promise\n resolve: deferred.resolve\n reject: deferred.reject\n running: false\n }\n pausePolls()\n drain()\n return deferred.promise\n\nApp:executePing(job)\n return chain Promise/resolve(null)\n then(ignored)\n return @heartbeat.exchange()\n then(ignored)\n capture job\n job.resolve(null)\n catch(error)\n capture job\n job.reject(error)\n finally\n @pingJob = null\n drain()\n\nApp:execute(job)\n form = job.form\n return chain Promise/resolve(null)\n then(ignored)\n capture form\n capture job\n if form.disposed\n throw \"Form is disposed\"\n if job.owner != null and !job.owner.active\n return null\n if job.kind == \"report\"\n return post(job.url, job.input, form.token)\n form.clearValidation()\n @renderer.waiting(form, true)\n ready = form.prepareValue()\n if ready == null\n return post(job.url, form.getValue(), form.token)\n return chain ready\n then(ignored)\n capture form\n capture job\n if form.disposed\n throw \"Form is disposed\"\n if job.owner != null and !job.owner.active\n return null\n return post(job.url, form.getValue(), form.token)\n then(packet)\n capture form\n capture job\n if packet != null and !form.disposed and (job.owner == null or job.owner.active)\n if job.kind == \"report\"\n form.setToken(packet.token)\n else\n form.handle(packet)\n then(ignored)\n capture job\n job.resolve(null)\n catch(error)\n capture job\n job.reject(error)\n finally\n capture job\n capture form\n if job.kind == \"send\"\n @renderer.waiting(form, false)\n @active.splice(@active.indexOf(job), 1)\n drain()\n\nApp:navigate(url, push = true)\n target = new URL(url, @host.location.href)\n if target.origin != @host.location.origin\n throw \"UI navigation must use the current origin\"\n path = target.pathname\n if path == \"/\"\n path = \"/index\"\n template = selectTemplate(path)\n ready = Promise/resolve(null)\n if template != @template\n if template != null\n ready = @root.send(template)\n else\n @template = null\n return chain ready\n then(ignored)\n capture template\n capture path\n capture Form\n @template = template\n form = @root\n if template != null\n form = @root.find(\"__content__\")\n if !is_kindof(form, Form)\n throw \"Template requires a __content__ form\"\n return form.send(path)\n then(ignored)\n capture target\n capture push\n if push\n @host.history.pushState(null, \"\", \"${target.pathname}${target.search}${target.hash}\")\n if @renderer.locationChanged != null\n @renderer.locationChanged(target.href)\n return null\n\nApp:selectTemplate(path)\n urls = @events.templates\n if urls == null\n urls = []\n selected = @events.defaultTemplate\n if path == selected\n throw \"Template URLs cannot be used as page URLs\"\n best = 0\n for urls as url\n if !is_string(url) or !url.startsWith(\"/\") or url == \"/\" or url.endsWith(\"/\")\n throw \"Invalid template URL\"\n if path == url\n throw \"Template URLs cannot be used as page URLs\"\n if path == url or path.startsWith(\"${url}/\")\n if url.length > best\n selected = url\n best = url.length\n if path == selected\n throw \"Template URLs cannot be used as page URLs\"\n return selected\n\nApp:command(form, cmd)\n switch cmd.type\n case \"values\"\n form.setValue(cmd.values)\n case \"addRow\"\n form.find(cmd.name).addRow(cmd.value)\n case \"insertRow\"\n form.find(cmd.name).insertRow(cmd.beforeIndex, cmd.value)\n case \"deleteRow\"\n form.find(cmd.name).deleteRow(cmd.index)\n case \"setRowValue\"\n form.find(cmd.name).setRowValue(cmd.index, cmd.value)\n case \"setRowData\"\n form.find(cmd.name).setRowData(cmd.index, cmd.value)\n case \"setCellValue\"\n form.find(cmd.name).setCellValue(cmd.index, cmd.column, cmd.value)\n case \"invalid\"\n form.find(cmd.name).setInvalid(cmd.message)\n case \"set\"\n targetForm = form.find(cmd.name)\n if !is_kindof(targetForm, Form)\n throw \"Set requires a form target\"\n @renderer.show(targetForm, cmd.control)\n case \"setUrl\"\n target = new URL(cmd.url, @host.location.href)\n if target.origin != @host.location.origin\n throw \"UI URL must use the current origin\"\n @host.history.pushState(null, \"\", \"${target.pathname}${target.search}${target.hash}\")\n if @renderer.locationChanged != null\n @renderer.locationChanged(target.href)\n case \"redirect\"\n action = ()\n capture cmd\n chain navigate(cmd.url)\n catch(problem)\n capture form\n error(form, problem)\n @host.defer(action)\n case \"disable\"\n form.find(cmd.name).setDisabled(true)\n case \"enable\"\n form.find(cmd.name).setDisabled(false)\n case \"changeCaption\"\n form.find(cmd.name).setCaption(cmd.caption)\n case \"activateTabItem\"\n form.find(cmd.name).activate()\n case \"setProgress\"\n form.find(cmd.name).setRange(cmd.min, cmd.max, cmd.value)\n case \"updateProgress\"\n form.find(cmd.name).update(cmd.value, cmd.label)\n case \"showAlert\"\n @renderer.presentations.showAlert(form, cmd)\n case \"dismissAlert\"\n @renderer.presentations.dismissAlert(form, cmd.name)\n case \"showToast\"\n @renderer.presentations.showToast(form, cmd.toast, cmd.stack)\n case \"showDialog\"\n @renderer.presentations.showDialog(form, cmd.dialog, cmd.keepPrev)\n case \"swapDialog\"\n @renderer.presentations.swapDialog(form)\n case \"setTimer\"\n form.activity.timer(cmd.url, cmd.interval)\n case \"clearTimer\"\n form.activity.clearTimer(cmd.url)\n case \"setInterval\"\n form.activity.timer(cmd.url, cmd.interval, true)\n case \"clearInterval\"\n form.activity.clearTimer(cmd.url, true)\n case \"startLongPoll\"\n form.activity.startLongPoll(cmd.url, cmd.key, cmd.cursor)\n case \"stopLongPoll\"\n form.activity.stopLongPoll(cmd.url, cmd.key)\n else\n throw \"Unsupported UI command: ${cmd.type}\"\n return null\n\nApp:dispose()\n @disposed = true\n if @heartbeat != null\n @heartbeat.dispose()\n if @reporter != null\n @reporter.dispose()\n for @forms.slice() as form\n form.dispose()\n for @queue as job\n job.reject(\"Application is disposed\")\n @queue = []\n for @resources as release\n release()\n @resources = []\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/client.css
CHANGED
|
@@ -93,3 +93,10 @@
|
|
|
93
93
|
.lango-waiting > .lango-form-spinner { filter: none; }
|
|
94
94
|
.lango-custom-spinner::after { display: none; }
|
|
95
95
|
.lango-spinner-rotate { width: 2rem; height: 2rem; border: .25rem dotted currentColor; border-radius: 50%; animation: lango-spin .8s linear infinite; }
|
|
96
|
+
|
|
97
|
+
/* Columns stack below the same 48rem boundary advertised in request headers. */
|
|
98
|
+
.lango-row { display: flex; flex-wrap: wrap; gap: var(--lango-gap, 1rem); min-width: 0; }
|
|
99
|
+
.lango-row > .lango-col { flex: 0 0 100%; width: 100% !important; min-width: 0; max-width: 100%; }
|
|
100
|
+
@media (min-width: 48rem) {
|
|
101
|
+
.lango-row > .lango-col { flex: var(--lango-grow, 1) 1 var(--lango-basis, 0px); width: auto !important; }
|
|
102
|
+
}
|
package/dist/control.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { applyDimensions } from "./dimensions.mjs";
|
|
1
2
|
import { controlId } from "./templates.mjs";
|
|
2
3
|
import {
|
|
3
4
|
hostGlobal as __hostGlobal,
|
|
@@ -26,6 +27,7 @@ export class Control {
|
|
|
26
27
|
element = __boundary(element);
|
|
27
28
|
this.form = form;
|
|
28
29
|
this.element = element;
|
|
30
|
+
applyDimensions(element, props);
|
|
29
31
|
this.#value = __normalize(props.value);
|
|
30
32
|
this.release = [];
|
|
31
33
|
this.#feedback = null;
|
package/dist/control.mjs.map
CHANGED
|
@@ -1 +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":"
|
|
1
|
+
{"version":3,"file":"control.mjs","sources":["control.lango"],"sourcesContent":["import \"./dimensions\"\n applyDimensions(element, props)\nimport 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 applyDimensions(element, props)\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":";;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
boundary as __boundary,
|
|
13
|
+
requireArity as __requireArity,
|
|
14
|
+
} from "./.lango/runtime.mjs";
|
|
15
|
+
|
|
16
|
+
export function measure(value, unit) {
|
|
17
|
+
__requireArity(arguments.length, [0, 1], "measure");
|
|
18
|
+
value = __boundary(value);
|
|
19
|
+
unit = __boundary(unit);
|
|
20
|
+
if (__requireBoolean(__requireBoolean(value === null) || __requireBoolean(value === __finite(-1)))) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(value))) || __requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isFinite(value))))) || __requireBoolean(value <= 0))) {
|
|
24
|
+
throw "Control dimensions must be positive numbers or -1 for automatic sizing";
|
|
25
|
+
}
|
|
26
|
+
return `${value}${unit}`;
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function applyDimensions(element, props) {
|
|
31
|
+
__requireArity(arguments.length, [0, 1], "applyDimensions");
|
|
32
|
+
element = __boundary(element);
|
|
33
|
+
props = __boundary(props);
|
|
34
|
+
let width = measure(__normalize(props.width), "ch");
|
|
35
|
+
let height = measure(__normalize(props.height), "lh");
|
|
36
|
+
if (__requireBoolean(width !== null)) {
|
|
37
|
+
element.style.width = width;
|
|
38
|
+
element.style.maxWidth = "100%";
|
|
39
|
+
element.style.boxSizing = "border-box";
|
|
40
|
+
}
|
|
41
|
+
if (__requireBoolean(height !== null)) {
|
|
42
|
+
element.style.height = height;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function applyLayout(element, props) {
|
|
49
|
+
__requireArity(arguments.length, [0, 1], "applyLayout");
|
|
50
|
+
element = __boundary(element);
|
|
51
|
+
props = __boundary(props);
|
|
52
|
+
if (__normalize(props.type) === "container") {
|
|
53
|
+
let fluid = __normalize(props.fluid);
|
|
54
|
+
if (__requireBoolean(fluid === null)) {
|
|
55
|
+
fluid = false;
|
|
56
|
+
}
|
|
57
|
+
if (__requireBoolean(!__requireBoolean(__isBool(fluid)))) {
|
|
58
|
+
throw "Container fluid must be boolean";
|
|
59
|
+
}
|
|
60
|
+
if (__requireBoolean(fluid)) {
|
|
61
|
+
__add(element.classList, "container-fluid");
|
|
62
|
+
} else {
|
|
63
|
+
__add(element.classList, "container");
|
|
64
|
+
}
|
|
65
|
+
} else if (__normalize(props.type) === "row") {
|
|
66
|
+
__add(element.classList, "lango-row");
|
|
67
|
+
let gap = __normalize(props.gap);
|
|
68
|
+
if (__requireBoolean(gap === null)) {
|
|
69
|
+
gap = "normal";
|
|
70
|
+
}
|
|
71
|
+
if (gap === "small") {
|
|
72
|
+
__normalize(element.style.setProperty("--lango-gap", ".5rem"));
|
|
73
|
+
} else if (gap === "normal") {
|
|
74
|
+
__normalize(element.style.setProperty("--lango-gap", "1rem"));
|
|
75
|
+
} else if (gap === "large") {
|
|
76
|
+
__normalize(element.style.setProperty("--lango-gap", "1.5rem"));
|
|
77
|
+
} else {
|
|
78
|
+
throw "Row gap must be small, normal or large";
|
|
79
|
+
}
|
|
80
|
+
} else if (__normalize(props.type) === "col") {
|
|
81
|
+
__add(element.classList, "lango-col");
|
|
82
|
+
let basis = measure(__normalize(props.width), "ch");
|
|
83
|
+
let grow = __normalize(props.grow);
|
|
84
|
+
if (__requireBoolean(grow === null)) {
|
|
85
|
+
grow = basis === null;
|
|
86
|
+
}
|
|
87
|
+
if (__requireBoolean(!__requireBoolean(__isBool(grow)))) {
|
|
88
|
+
throw "Col grow must be boolean";
|
|
89
|
+
}
|
|
90
|
+
if (__requireBoolean(basis !== null)) {
|
|
91
|
+
__normalize(element.style.setProperty("--lango-basis", basis));
|
|
92
|
+
}
|
|
93
|
+
if (__requireBoolean(grow)) {
|
|
94
|
+
__normalize(element.style.setProperty("--lango-grow", "1"));
|
|
95
|
+
} else {
|
|
96
|
+
__normalize(element.style.setProperty("--lango-grow", "0"));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=dimensions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimensions.mjs","sources":["dimensions.lango"],"sourcesContent":["import js global Number\n\nexport measure(value, unit)\nexport applyDimensions(element, props)\nexport applyLayout(element, props)\n\nmeasure(value, unit)\n if value == null or value == -1\n return null\n if !is_number(value) or !Number/isFinite(value) or value <= 0\n throw \"Control dimensions must be positive numbers or -1 for automatic sizing\"\n return \"${value}${unit}\"\n\napplyDimensions(element, props)\n width = measure(props.width, \"ch\")\n height = measure(props.height, \"lh\")\n if width != null\n element.style.width = width\n element.style.maxWidth = \"100%\"\n element.style.boxSizing = \"border-box\"\n if height != null\n element.style.height = height\n return null\n\napplyLayout(element, props)\n switch props.type\n case \"container\"\n fluid = props.fluid\n if fluid == null\n fluid = false\n if !is_bool(fluid)\n throw \"Container fluid must be boolean\"\n if fluid\n element.classList.add(\"container-fluid\")\n else\n element.classList.add(\"container\")\n case \"row\"\n element.classList.add(\"lango-row\")\n gap = props.gap\n if gap == null\n gap = \"normal\"\n switch gap\n case \"small\"\n element.style.setProperty(\"--lango-gap\", \".5rem\")\n case \"normal\"\n element.style.setProperty(\"--lango-gap\", \"1rem\")\n case \"large\"\n element.style.setProperty(\"--lango-gap\", \"1.5rem\")\n else\n throw \"Row gap must be small, normal or large\"\n case \"col\"\n element.classList.add(\"lango-col\")\n basis = measure(props.width, \"ch\")\n grow = props.grow\n if grow == null\n grow = basis == null\n if !is_bool(grow)\n throw \"Col grow must be boolean\"\n if basis != null\n element.style.setProperty(\"--lango-basis\", basis)\n if grow\n element.style.setProperty(\"--lango-grow\", \"1\")\n else\n element.style.setProperty(\"--lango-grow\", \"0\")\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;AAOA;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/form.mjs
CHANGED
|
@@ -133,7 +133,7 @@ export class Form {
|
|
|
133
133
|
}
|
|
134
134
|
prepareValue() {
|
|
135
135
|
let pending = [];
|
|
136
|
-
for (const
|
|
136
|
+
for (const control of __normalize(this.owned)) {
|
|
137
137
|
if (__requireBoolean(__normalize(control.prepareValue) !== null)) {
|
|
138
138
|
let ready = __normalize(control.prepareValue());
|
|
139
139
|
if (__requireBoolean(ready !== null)) {
|
package/dist/form.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.mjs","sources":["form.lango"],"sourcesContent":["import js global Object\nimport js global Reflect\nimport js global Promise\nimport \"./activities\"\n class Activities\n\nexport class Form(app, parent = null, token = null)\n properties\n app\n parent\n token\n controls\n owned\n inheritedNames\n disposed\n element\n resources\n activity\n presentation\n inheritThrough\n spinner\n waiting\n methods\n register(name, control)\n unregister(control)\n find(name)\n inherited(name)\n getValue()\n prepareValue()\n setValue(values)\n setToken(token)\n send(url)\n handle(packet)\n related(other)\n clearValidation()\n clearResources()\n dispose()\n\nForm(app, parent = null, token = null)\n @app = app\n @parent = parent\n @token = token\n @controls = Object/create(null)\n @owned = []\n @inheritedNames = []\n @disposed = false\n @element = null\n @resources = []\n @activity = new Activities(@this)\n @presentation = null\n @inheritThrough = false\n @spinner = null\n @waiting = false\n app.forms.add(@this)\n\nForm:register(name, control)\n @owned.add(control)\n if name == null\n return control\n if !is_string(name) or name == \"\" or name.includes(\"/\") or name in @controls\n throw \"Invalid or duplicate control name: ${name}\"\n @controls[name] = control\n return control\n\nForm:unregister(control)\n for Object/keys(@controls) as name\n if @controls[name] == control\n Reflect/deleteProperty(@controls, name)\n index = @owned.indexOf(control)\n if index >= 0\n @owned.splice(index, 1)\n return null\n\nForm:find(name)\n parts = name.split(\"/\")\n current = @controls[parts.shift()]\n if current == null\n if @inheritedNames.includes(name) and @parent != null\n return inherited(name)\n throw \"Unknown control: ${name}\"\n if parts.length > 0\n if current.find == null\n throw \"Control has no named children: ${name}\"\n return current.find(parts.join(\"/\"))\n return current\n\nForm:inherited(name)\n parent = @parent\n loop while parent != null and parent.inheritThrough\n parent = parent.parent\n if parent == null\n throw \"Inherited value has no parent: ${name}\"\n return parent.find(name)\n\nForm:getValue()\n result = Object/create(null)\n for @controls as name: control\n result[name] = control.getValue()\n for @inheritedNames as name\n if @parent == null or name in result\n throw \"Invalid inherited name: ${name}\"\n source = inherited(name)\n result[name] = source.getValue()\n return result\n\nForm:prepareValue()\n pending = []\n for @
|
|
1
|
+
{"version":3,"file":"form.mjs","sources":["form.lango"],"sourcesContent":["import js global Object\nimport js global Reflect\nimport js global Promise\nimport \"./activities\"\n class Activities\n\nexport class Form(app, parent = null, token = null)\n properties\n app\n parent\n token\n controls\n owned\n inheritedNames\n disposed\n element\n resources\n activity\n presentation\n inheritThrough\n spinner\n waiting\n methods\n register(name, control)\n unregister(control)\n find(name)\n inherited(name)\n getValue()\n prepareValue()\n setValue(values)\n setToken(token)\n send(url)\n handle(packet)\n related(other)\n clearValidation()\n clearResources()\n dispose()\n\nForm(app, parent = null, token = null)\n @app = app\n @parent = parent\n @token = token\n @controls = Object/create(null)\n @owned = []\n @inheritedNames = []\n @disposed = false\n @element = null\n @resources = []\n @activity = new Activities(@this)\n @presentation = null\n @inheritThrough = false\n @spinner = null\n @waiting = false\n app.forms.add(@this)\n\nForm:register(name, control)\n @owned.add(control)\n if name == null\n return control\n if !is_string(name) or name == \"\" or name.includes(\"/\") or name in @controls\n throw \"Invalid or duplicate control name: ${name}\"\n @controls[name] = control\n return control\n\nForm:unregister(control)\n for Object/keys(@controls) as name\n if @controls[name] == control\n Reflect/deleteProperty(@controls, name)\n index = @owned.indexOf(control)\n if index >= 0\n @owned.splice(index, 1)\n return null\n\nForm:find(name)\n parts = name.split(\"/\")\n current = @controls[parts.shift()]\n if current == null\n if @inheritedNames.includes(name) and @parent != null\n return inherited(name)\n throw \"Unknown control: ${name}\"\n if parts.length > 0\n if current.find == null\n throw \"Control has no named children: ${name}\"\n return current.find(parts.join(\"/\"))\n return current\n\nForm:inherited(name)\n parent = @parent\n loop while parent != null and parent.inheritThrough\n parent = parent.parent\n if parent == null\n throw \"Inherited value has no parent: ${name}\"\n return parent.find(name)\n\nForm:getValue()\n result = Object/create(null)\n for @controls as name: control\n result[name] = control.getValue()\n for @inheritedNames as name\n if @parent == null or name in result\n throw \"Invalid inherited name: ${name}\"\n source = inherited(name)\n result[name] = source.getValue()\n return result\n\nForm:prepareValue()\n pending = []\n for @owned as control\n if control.prepareValue != null\n ready = control.prepareValue()\n if ready != null\n pending.add(ready)\n for @inheritedNames as name\n source = inherited(name)\n if source.prepareValue != null\n inheritedReady = source.prepareValue()\n if inheritedReady != null\n pending.add(inheritedReady)\n if pending.length == 0\n return null\n return Promise/all(pending)\n\nForm:setValue(values)\n for values as name: value\n find(name).setValue(value)\n return @this\n\nForm:clearValidation()\n for @controls as name: control\n if control.clearValidation != null\n control.clearValidation()\n for @inheritedNames as name\n source = find(name)\n if source.clearValidation != null\n source.clearValidation()\n return null\n\nForm:clearResources()\n @activity.clear()\n resources = @resources\n @resources = []\n for resources as release\n release()\n return null\n\nForm:setToken(token)\n if token != null\n @token = token\n @app.saveToken(token)\n if @app.heartbeat != null\n @app.heartbeat.observe(token)\n return @this\n\nForm:send(url)\n return @app.send(@this, url)\n\nForm:handle(packet)\n if @disposed\n return null\n setToken(packet.token)\n body = packet.body\n if body.view != null\n @app.renderer.show(@this, body.view)\n if body.cmds != null\n for body.cmds as cmd\n @app.command(@this, cmd)\n return null\n\nForm:related(other)\n node = other\n loop while node != null\n if node == @this\n return true\n node = node.parent\n node = @this\n loop while node != null\n if node == other\n return true\n node = node.parent\n return false\n\nForm:dispose()\n if @disposed\n return null\n @disposed = true\n for @owned.slice() as control\n control.dispose()\n clearResources()\n @controls = Object/create(null)\n alive = []\n for @app.forms as form\n if form != @this\n alive.add(form)\n @app.forms = alive\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<link rel="stylesheet" href="/client.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
|
-
<main id="app" class="
|
|
12
|
+
<main id="app" class="py-3"></main>
|
|
13
13
|
<script type="importmap">
|
|
14
14
|
{ "imports": { "marked": "/vendor/marked.mjs", "dompurify": "/vendor/dompurify.mjs", "flatpickr": "/vendor/flatpickr.mjs" } }
|
|
15
15
|
</script>
|
package/dist/main.mjs
CHANGED
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
|
|
14
14
|
export function start() {
|
|
15
15
|
let renderer = new BootstrapRenderer();
|
|
16
|
-
let storage = { getItem: missingToken, setItem: discardToken };
|
|
16
|
+
let storage = { getItem: missingToken, setItem: discardToken, removeItem: missingToken };
|
|
17
17
|
try {
|
|
18
18
|
storage = __normalize(__hostGlobal(["window"]).localStorage);
|
|
19
19
|
} catch (error) {
|
|
20
20
|
storage = storage;
|
|
21
21
|
}
|
|
22
|
-
let app = new App({ storage: storage, mount: __normalize(__hostGlobal(["document"]).querySelector("#app")), location: __normalize(__hostGlobal(["window"]).location), history: __normalize(__hostGlobal(["window"]).history), fetch: request, defer: defer, schedule: schedule, cancelTimer: cancelTimer }, renderer);
|
|
22
|
+
let app = new App({ storage: storage, mount: __normalize(__hostGlobal(["document"]).querySelector("#app")), location: __normalize(__hostGlobal(["window"]).location), history: __normalize(__hostGlobal(["window"]).history), screen: screenMode, fetch: request, defer: defer, schedule: schedule, cancelTimer: cancelTimer }, renderer);
|
|
23
23
|
let click = __withArity((event) => {
|
|
24
24
|
event = __boundary(event);
|
|
25
25
|
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__normalize(event.defaultPrevented)) || __requireBoolean(__normalize(event.button) !== 0)) || __requireBoolean(__normalize(event.ctrlKey))) || __requireBoolean(__normalize(event.metaKey))) || __requireBoolean(__normalize(event.shiftKey))) || __requireBoolean(__normalize(event.altKey)))) {
|
|
@@ -135,4 +135,13 @@ function cancelTimer(timer) {
|
|
|
135
135
|
return null;
|
|
136
136
|
return null;
|
|
137
137
|
}
|
|
138
|
+
|
|
139
|
+
function screenMode() {
|
|
140
|
+
let media = __normalize(__hostGlobal(["window"]).matchMedia("(min-width: 48rem)"));
|
|
141
|
+
if (__requireBoolean(__normalize(media.matches))) {
|
|
142
|
+
return "wide";
|
|
143
|
+
}
|
|
144
|
+
return "narrow";
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
138
147
|
//# sourceMappingURL=main.mjs.map
|
package/dist/main.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.mjs","sources":["main.lango"],"sourcesContent":["import js global document\nimport js global window\nimport js global fetch\nimport js global setTimeout\nimport js global clearTimeout\nimport \"./app\"\n class App\nimport \"./renderer\"\n class BootstrapRenderer\n\nexport start()\n\nstart()\n renderer = new BootstrapRenderer()\n storage = {\n getItem: missingToken\n setItem: discardToken\n }\n try\n storage = window.localStorage\n catch error\n storage = storage\n app = new App({\n storage: storage\n mount: document/querySelector(\"#app\")\n location: window.location\n history: window.history\n fetch: request\n defer: defer\n schedule: schedule\n cancelTimer: cancelTimer\n }, renderer)\n click = (event)\n capture app\n if event.defaultPrevented or event.button != 0 or event.ctrlKey or event.metaKey or event.shiftKey or event.altKey\n return null\n link = event.target.closest(\"a[href]\")\n if link == null or link.origin != window.location.origin or link.hasAttribute(\"download\") or (link.target != \"\" and link.target != \"_self\")\n return null\n event.preventDefault()\n chain app.navigate(link.href)\n catch(error)\n capture app\n app.error(app.root, error)\n pop = ()\n capture app\n chain app.navigate(window.location.href, false)\n catch(error)\n capture app\n app.error(app.root, error)\n windowError = (event)\n capture app\n if app.reporter != null\n app.reporter.capture(\"window\", \"UnhandledError\", null, app.root)\n rejection = (event)\n capture app\n if app.reporter != null\n app.reporter.capture(\"promise\", \"UnhandledRejection\", null, app.root)\n document/addEventListener(\"click\", click)\n window.addEventListener(\"popstate\", pop)\n window.addEventListener(\"error\", windowError)\n window.addEventListener(\"unhandledrejection\", rejection)\n return chain app.start()\n then(ignored)\n capture app\n release = ()\n capture click\n capture pop\n capture windowError\n capture rejection\n document/removeEventListener(\"click\", click)\n window.removeEventListener(\"popstate\", pop)\n window.removeEventListener(\"error\", windowError)\n window.removeEventListener(\"unhandledrejection\", rejection)\n resources = app.resources\n resources.add(release)\n return app\n catch(error)\n capture app\n capture click\n capture pop\n capture windowError\n capture rejection\n document/removeEventListener(\"click\", click)\n window.removeEventListener(\"popstate\", pop)\n window.removeEventListener(\"error\", windowError)\n window.removeEventListener(\"unhandledrejection\", rejection)\n app.dispose()\n throw error\n\nmissingToken(key)\n return null\n\ndiscardToken(key, value)\n return null\n\ndefer(action)\n setTimeout(action, 0)\n return null\n\nrequest(url, options)\n return fetch(url, options)\n\nschedule(action, delay)\n return setTimeout(action, delay)\n\ncancelTimer(timer)\n clearTimeout(timer)\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"main.mjs","sources":["main.lango"],"sourcesContent":["import js global document\nimport js global window\nimport js global fetch\nimport js global setTimeout\nimport js global clearTimeout\nimport \"./app\"\n class App\nimport \"./renderer\"\n class BootstrapRenderer\n\nexport start()\n\nstart()\n renderer = new BootstrapRenderer()\n storage = {\n getItem: missingToken\n setItem: discardToken\n removeItem: missingToken\n }\n try\n storage = window.localStorage\n catch error\n storage = storage\n app = new App({\n storage: storage\n mount: document/querySelector(\"#app\")\n location: window.location\n history: window.history\n screen: screenMode\n fetch: request\n defer: defer\n schedule: schedule\n cancelTimer: cancelTimer\n }, renderer)\n click = (event)\n capture app\n if event.defaultPrevented or event.button != 0 or event.ctrlKey or event.metaKey or event.shiftKey or event.altKey\n return null\n link = event.target.closest(\"a[href]\")\n if link == null or link.origin != window.location.origin or link.hasAttribute(\"download\") or (link.target != \"\" and link.target != \"_self\")\n return null\n event.preventDefault()\n chain app.navigate(link.href)\n catch(error)\n capture app\n app.error(app.root, error)\n pop = ()\n capture app\n chain app.navigate(window.location.href, false)\n catch(error)\n capture app\n app.error(app.root, error)\n windowError = (event)\n capture app\n if app.reporter != null\n app.reporter.capture(\"window\", \"UnhandledError\", null, app.root)\n rejection = (event)\n capture app\n if app.reporter != null\n app.reporter.capture(\"promise\", \"UnhandledRejection\", null, app.root)\n document/addEventListener(\"click\", click)\n window.addEventListener(\"popstate\", pop)\n window.addEventListener(\"error\", windowError)\n window.addEventListener(\"unhandledrejection\", rejection)\n return chain app.start()\n then(ignored)\n capture app\n release = ()\n capture click\n capture pop\n capture windowError\n capture rejection\n document/removeEventListener(\"click\", click)\n window.removeEventListener(\"popstate\", pop)\n window.removeEventListener(\"error\", windowError)\n window.removeEventListener(\"unhandledrejection\", rejection)\n resources = app.resources\n resources.add(release)\n return app\n catch(error)\n capture app\n capture click\n capture pop\n capture windowError\n capture rejection\n document/removeEventListener(\"click\", click)\n window.removeEventListener(\"popstate\", pop)\n window.removeEventListener(\"error\", windowError)\n window.removeEventListener(\"unhandledrejection\", rejection)\n app.dispose()\n throw error\n\nmissingToken(key)\n return null\n\ndiscardToken(key, value)\n return null\n\ndefer(action)\n setTimeout(action, 0)\n return null\n\nrequest(url, options)\n return fetch(url, options)\n\nschedule(action, delay)\n return setTimeout(action, delay)\n\ncancelTimer(timer)\n clearTimeout(timer)\n return null\n\n\nscreenMode()\n media = window.matchMedia(\"(min-width: 48rem)\")\n if media.matches\n return \"wide\"\n return \"narrow\"\n"],"names":[],"mappings":";;;;;;;;;;;;;AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA;;;;;;;AAGA;;;;;;;;AAGA;;;;;;;;AAIA;;;;;;;;AAGA;;;;;;;;AAGA;;;;;;;;AAKA;;;;;;;;;"}
|