@lango-project/lango-server 0.1.0 → 0.1.2

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.
Files changed (80) hide show
  1. package/README.md +368 -10
  2. package/dist/builder.mjs +16 -1
  3. package/dist/builder.mjs.map +1 -1
  4. package/dist/cli/endpoint.mjs +8 -6
  5. package/dist/cli/endpoint.mjs.map +1 -1
  6. package/dist/cli/longpoll_broker.mjs +214 -0
  7. package/dist/cli/longpoll_broker.mjs.map +1 -0
  8. package/dist/cli/longpoll_options.mjs +102 -0
  9. package/dist/cli/longpoll_options.mjs.map +1 -0
  10. package/dist/cli/longpoll_session.mjs +135 -0
  11. package/dist/cli/longpoll_session.mjs.map +1 -0
  12. package/dist/cli/middleware.mjs +25 -0
  13. package/dist/cli/middleware.mjs.map +1 -0
  14. package/dist/cli/options.mjs +14 -2
  15. package/dist/cli/options.mjs.map +1 -1
  16. package/dist/cli/route_pattern.mjs +129 -0
  17. package/dist/cli/route_pattern.mjs.map +1 -0
  18. package/dist/cli/routes.mjs +80 -4
  19. package/dist/cli/routes.mjs.map +1 -1
  20. package/dist/cli/server.mjs +243 -23
  21. package/dist/cli/server.mjs.map +1 -1
  22. package/dist/cli/static_files.mjs +125 -0
  23. package/dist/cli/static_files.mjs.map +1 -0
  24. package/dist/endpoint.mjs +8 -6
  25. package/dist/endpoint.mjs.map +1 -1
  26. package/dist/group.mjs +17 -1
  27. package/dist/group.mjs.map +1 -1
  28. package/dist/http_failure.mjs +45 -0
  29. package/dist/http_failure.mjs.map +1 -0
  30. package/dist/longpoll_broker.mjs +214 -0
  31. package/dist/longpoll_broker.mjs.map +1 -0
  32. package/dist/longpoll_options.mjs +102 -0
  33. package/dist/longpoll_options.mjs.map +1 -0
  34. package/dist/longpoll_session.mjs +135 -0
  35. package/dist/longpoll_session.mjs.map +1 -0
  36. package/dist/middleware.mjs +25 -0
  37. package/dist/middleware.mjs.map +1 -0
  38. package/dist/options.mjs +14 -2
  39. package/dist/options.mjs.map +1 -1
  40. package/dist/response.mjs +8 -0
  41. package/dist/response.mjs.map +1 -1
  42. package/dist/route_info.mjs +22 -0
  43. package/dist/route_info.mjs.map +1 -0
  44. package/dist/route_pattern.mjs +129 -0
  45. package/dist/route_pattern.mjs.map +1 -0
  46. package/dist/routes.mjs +80 -4
  47. package/dist/routes.mjs.map +1 -1
  48. package/dist/runtime.mjs +170 -59
  49. package/dist/runtime.mjs.map +1 -1
  50. package/dist/server.mjs +243 -23
  51. package/dist/server.mjs.map +1 -1
  52. package/dist/server_context.mjs +88 -0
  53. package/dist/server_context.mjs.map +1 -0
  54. package/dist/static_files.mjs +125 -0
  55. package/dist/static_files.mjs.map +1 -0
  56. package/dist/token.mjs +12 -0
  57. package/dist/token.mjs.map +1 -1
  58. package/dist/tokens.mjs +16 -1
  59. package/dist/tokens.mjs.map +1 -1
  60. package/package.json +9 -4
  61. package/src/builder.lango +11 -0
  62. package/src/endpoint.lango +10 -4
  63. package/src/group.lango +14 -0
  64. package/src/http_failure.lango +26 -0
  65. package/src/longpoll.lua +61 -0
  66. package/src/longpoll_broker.lango +161 -0
  67. package/src/longpoll_options.lango +79 -0
  68. package/src/longpoll_session.lango +90 -0
  69. package/src/middleware.lango +10 -0
  70. package/src/options.lango +16 -0
  71. package/src/response.lango +6 -0
  72. package/src/route_info.lango +15 -0
  73. package/src/route_pattern.lango +86 -0
  74. package/src/routes.lango +80 -4
  75. package/src/runtime.lango +113 -13
  76. package/src/server.lango +182 -17
  77. package/src/server_context.lango +66 -0
  78. package/src/static_files.lango +90 -0
  79. package/src/token.lango +11 -0
  80. package/src/tokens.lango +11 -1
package/dist/runtime.mjs CHANGED
@@ -1,10 +1,14 @@
1
+ import { routePattern, matchPath, moreSpecific } from "./route_pattern.mjs";
2
+ import { ServerContext } from "./server_context.mjs";
1
3
  import { Database } from "./database.mjs";
2
4
  import { Token } from "./token.mjs";
3
5
  import { Tokens } from "./tokens.mjs";
4
6
  import { Response } from "./response.mjs";
7
+ import { HttpFailure } from "./http_failure.mjs";
5
8
  import * as threads from "node:worker_threads";
6
9
  import {
7
10
  hostGlobal as __hostGlobal,
11
+ hostGlobalCall as __hostGlobalCall,
8
12
  contextGet as __contextGet,
9
13
  contextSet as __contextSet,
10
14
  contextRestore as __contextRestore,
@@ -28,25 +32,34 @@ import {
28
32
  } from "./.lango/runtime.mjs";
29
33
 
30
34
  export class Runtime {
35
+ #serverContext;
31
36
  #definition;
32
37
  #routes;
33
38
  #events;
34
39
  #tokens;
35
40
  #modules;
41
+ #middlewares;
36
42
  #database;
37
43
  constructor(definition) {
38
44
  __requireArity(arguments.length, [0], "constructor");
39
45
  definition = __boundary(definition);
46
+ this.#serverContext = new ServerContext(__normalize(definition.routes));
40
47
  this.#definition = definition;
41
48
  this.#routes = [];
42
49
  this.#events = { };
43
50
  this.#tokens = new Tokens(__normalize(definition.settings));
44
51
  this.#modules = { };
52
+ this.#middlewares = __normalize(__hostGlobal(["Object"]).create(null));
45
53
  this.#database = new Database(definition.settings.database, definition.settings.root);
46
54
  }
47
55
  preload() {
48
56
  let definitions = __normalize(this.#definition.routes);
49
57
  let pending = __normalize(this.#database.open());
58
+ if (__requireBoolean(__normalize(this.#definition.middlewares) !== null)) {
59
+ for (const [name, spec] of __entries(__normalize(this.#definition.middlewares))) {
60
+ pending = this.#prepareMiddleware(pending, name, spec);
61
+ }
62
+ }
50
63
  for (const route of definitions) {
51
64
  pending = this.#prepareRoute(pending, route);
52
65
  }
@@ -67,17 +80,58 @@ export class Runtime {
67
80
  return null;
68
81
  return null;
69
82
  }
83
+ #prepareMiddleware(pending, name, spec) {
84
+ __requireArity(arguments.length, [0, 1, 2], "prepareMiddleware");
85
+ pending = __boundary(pending);
86
+ name = __boundary(name);
87
+ spec = __boundary(spec);
88
+ return pending.then(__withArity((ignored) => {
89
+ ignored = __boundary(ignored);
90
+ return this.#target(spec);
91
+ return null;
92
+ }, [0], "closure")).then(__withArity((handler) => {
93
+ handler = __boundary(handler);
94
+ this.#middlewares[name] = handler;
95
+ if (__requireBoolean(__normalize(spec.validate) !== null)) {
96
+ return this.#target({ module: __normalize(spec.module), handler: __normalize(spec.validate) });
97
+ }
98
+ return null;
99
+ return null;
100
+ }, [0], "closure")).then(__withArity((validator) => {
101
+ validator = __boundary(validator);
102
+ if (__requireBoolean(validator !== null)) {
103
+ return __call(validator, __normalize(this.#serverContext.routes()));
104
+ }
105
+ return null;
106
+ return null;
107
+ }, [0], "closure"));
108
+ return null;
109
+ }
70
110
  #prepareRoute(pending, route) {
71
111
  __requireArity(arguments.length, [0, 1], "prepareRoute");
72
112
  pending = __boundary(pending);
73
113
  route = __boundary(route);
114
+ if (__requireBoolean(__normalize(route.kind) === "longpoll")) {
115
+ let prepared = __normalize(__hostGlobal(["Object"]).assign({ }, route));
116
+ prepared.pattern = routePattern(__normalize(route.path));
117
+ __add(this.#routes, prepared);
118
+ return pending;
119
+ }
74
120
  return pending.then(__withArity((ignored) => {
75
121
  ignored = __boundary(ignored);
76
122
  return this.#target(route);
77
123
  return null;
78
124
  }, [0], "closure")).then(__withArity((handler) => {
79
125
  handler = __boundary(handler);
80
- __add(this.#routes, { path: __normalize(route.path), auth: __normalize(route.auth), handler: handler });
126
+ let middleware = null;
127
+ let name = __normalize(route.middleware);
128
+ if (__requireBoolean(name !== null)) {
129
+ if (__requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Object"]).hasOwn(__normalize(this.#middlewares), name))))) {
130
+ throw `Middleware is not registered: ${name}`;
131
+ }
132
+ middleware = __normalize(this.#middlewares[name]);
133
+ }
134
+ __add(this.#routes, { path: __normalize(route.path), pattern: routePattern(__normalize(route.path)), auth: __normalize(route.auth), handler: handler, middleware: middleware });
81
135
  return null;
82
136
  return null;
83
137
  }, [0], "closure"));
@@ -119,20 +173,20 @@ export class Runtime {
119
173
  __requireArity(arguments.length, [0], "match");
120
174
  path = __boundary(path);
121
175
  let best = null;
122
- let length = __finite(-1);
176
+ let parameters = null;
177
+ let pattern = null;
123
178
  for (const route of __normalize(this.#routes)) {
124
- if (__requireBoolean(__normalize(route.path) === path)) {
125
- return route;
126
- }
127
- if (__requireBoolean(__normalize(route.path.endsWith("/*")))) {
128
- let prefix = __normalize(route.path.slice(0, __finite(-1)));
129
- if (__requireBoolean(__requireBoolean(__normalize(path.startsWith(prefix))) && __requireBoolean(__normalize(prefix.length) > length))) {
130
- best = route;
131
- length = __normalize(prefix.length);
132
- }
179
+ let captured = matchPath(__normalize(route.pattern), path);
180
+ if (__requireBoolean(__requireBoolean(captured !== null) && __requireBoolean(moreSpecific(__normalize(route.pattern), pattern)))) {
181
+ best = route;
182
+ parameters = captured;
183
+ pattern = __normalize(route.pattern);
133
184
  }
134
185
  }
135
- return best;
186
+ if (__requireBoolean(best === null)) {
187
+ return null;
188
+ }
189
+ return { route: best, parameters: parameters };
136
190
  return null;
137
191
  }
138
192
  handle(task) {
@@ -141,6 +195,7 @@ export class Runtime {
141
195
  __requireArity(arguments.length, [0], "handle");
142
196
  task = __boundary(task);
143
197
  __normalize(__hostGlobal(["Object"]).freeze(task.request.headers));
198
+ __contextScope.push(__contextSet("server", __normalize(this.#serverContext)));
144
199
  __contextScope.push(__contextSet("request", __normalize(__hostGlobal(["Object"]).freeze(__normalize(task.request)))));
145
200
  __contextScope.push(__contextSet("response", new Response()));
146
201
  let fresh = __normalize(__contextGet("request").headers.authorization) === null;
@@ -154,10 +209,11 @@ export class Runtime {
154
209
  } catch (error) {
155
210
  return failure(401, "Unauthorized");
156
211
  }
157
- let route = this.#match(__normalize(__contextGet("request").path));
158
- if (__requireBoolean(route === null)) {
212
+ let matched = this.#match(__normalize(__contextGet("request").path));
213
+ if (__requireBoolean(matched === null)) {
159
214
  return failure(404, "RouteNotFound");
160
215
  }
216
+ let route = __normalize(matched.route);
161
217
  let input = null;
162
218
  try {
163
219
  input = __normalize(__hostGlobal(["JSON"]).parse(__normalize(task.body)));
@@ -167,16 +223,24 @@ export class Runtime {
167
223
  } catch (error) {
168
224
  return failure(400, "InvalidJson");
169
225
  }
226
+ try {
227
+ for (const [name, value] of __entries(__normalize(matched.parameters))) {
228
+ input[name] = __hostGlobalCall(["decodeURIComponent"], value);
229
+ }
230
+ } catch (error) {
231
+ return failure(400, "InvalidPath");
232
+ }
170
233
  __contextScope.push(__contextSet("token", new Token(claims)));
171
234
  __contextScope.push(__contextSet("db", __normalize(this.#database.scope())));
172
- return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4) => (ignored) => {
235
+ return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (ignored) => {
173
236
  const __contextScope = [];
174
237
  try {
175
- __contextScope.push(__contextSet("request", __capturedContext0));
176
- __contextScope.push(__contextSet("response", __capturedContext1));
177
- __contextScope.push(__contextSet("token", __capturedContext2));
178
- __contextScope.push(__contextSet("log", __capturedContext3));
179
- __contextScope.push(__contextSet("db", __capturedContext4));
238
+ __contextScope.push(__contextSet("server", __capturedContext0));
239
+ __contextScope.push(__contextSet("request", __capturedContext1));
240
+ __contextScope.push(__contextSet("response", __capturedContext2));
241
+ __contextScope.push(__contextSet("token", __capturedContext3));
242
+ __contextScope.push(__contextSet("log", __capturedContext4));
243
+ __contextScope.push(__contextSet("db", __capturedContext5));
180
244
  ignored = __boundary(ignored);
181
245
  if (__requireBoolean(fresh)) {
182
246
  return this.#event("register", input);
@@ -186,14 +250,15 @@ export class Runtime {
186
250
  } finally {
187
251
  __contextRestore(__contextScope);
188
252
  }
189
- })(__contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4) => (validatedAt) => {
253
+ })(__contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (validatedAt) => {
190
254
  const __contextScope = [];
191
255
  try {
192
- __contextScope.push(__contextSet("request", __capturedContext0));
193
- __contextScope.push(__contextSet("response", __capturedContext1));
194
- __contextScope.push(__contextSet("token", __capturedContext2));
195
- __contextScope.push(__contextSet("log", __capturedContext3));
196
- __contextScope.push(__contextSet("db", __capturedContext4));
256
+ __contextScope.push(__contextSet("server", __capturedContext0));
257
+ __contextScope.push(__contextSet("request", __capturedContext1));
258
+ __contextScope.push(__contextSet("response", __capturedContext2));
259
+ __contextScope.push(__contextSet("token", __capturedContext3));
260
+ __contextScope.push(__contextSet("log", __capturedContext4));
261
+ __contextScope.push(__contextSet("db", __capturedContext5));
197
262
  validatedAt = __boundary(validatedAt);
198
263
  if (__requireBoolean(__requireBoolean(!__requireBoolean(fresh)) && __requireBoolean(__isNumber(validatedAt)))) {
199
264
  stampValidation(claims, validatedAt);
@@ -201,29 +266,54 @@ export class Runtime {
201
266
  if (__requireBoolean(__requireBoolean(__normalize(route.auth) !== "anonymous") && __requireBoolean(!__requireBoolean(__normalize(__contextGet("token").hasAuth(__normalize(route.auth))))))) {
202
267
  throw { status: 401, error: "Unauthorized" };
203
268
  }
269
+ if (__requireBoolean(__normalize(route.kind) === "longpoll")) {
270
+ return null;
271
+ }
204
272
  let handler = __normalize(route.handler);
273
+ let middleware = __normalize(route.middleware);
274
+ if (__requireBoolean(middleware !== null)) {
275
+ return __call(middleware, handler, __normalize(__contextGet("request").path), input);
276
+ }
205
277
  return __call(handler, input);
206
278
  return null;
207
279
  } finally {
208
280
  __contextRestore(__contextScope);
209
281
  }
210
- })(__contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4) => (output) => {
282
+ })(__contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (output) => {
211
283
  const __contextScope = [];
212
284
  try {
213
- __contextScope.push(__contextSet("request", __capturedContext0));
214
- __contextScope.push(__contextSet("response", __capturedContext1));
215
- __contextScope.push(__contextSet("token", __capturedContext2));
216
- __contextScope.push(__contextSet("log", __capturedContext3));
217
- __contextScope.push(__contextSet("db", __capturedContext4));
285
+ __contextScope.push(__contextSet("server", __capturedContext0));
286
+ __contextScope.push(__contextSet("request", __capturedContext1));
287
+ __contextScope.push(__contextSet("response", __capturedContext2));
288
+ __contextScope.push(__contextSet("token", __capturedContext3));
289
+ __contextScope.push(__contextSet("log", __capturedContext4));
290
+ __contextScope.push(__contextSet("db", __capturedContext5));
218
291
  output = __boundary(output);
292
+ if (__requireBoolean(__normalize(task.authorize) === true)) {
293
+ closeScope(__contextGet("db"), true);
294
+ let authorizedClaims = this.#tokenClaims(__contextGet("token"), claims, true);
295
+ let encoded = __normalize(this.#tokens.sign(authorizedClaims));
296
+ if (__requireBoolean(__normalize(task.pollResult) === null)) {
297
+ return { status: 200, authorization: encoded };
298
+ }
299
+ if (__requireBoolean(task.pollResult.resyncRequired)) {
300
+ __normalize(__contextGet("response").status(409));
301
+ }
302
+ let pollBody = __normalize(__hostGlobal(["JSON"]).stringify(__normalize(task.pollResult)));
303
+ let pollResponse = __normalize(__contextGet("response").result(pollBody));
304
+ pollResponse.headers["x-lango-token"] = encoded;
305
+ if (__requireBoolean(__requireBoolean(__normalize(this.#definition.settings.requestEvent)) && __requireBoolean(__includes("request", __normalize(this.#events))))) {
306
+ return this.#audit(__normalize(__contextGet("request").id), pollResponse, __normalize(task.body), pollBody, authorizedClaims);
307
+ }
308
+ return pollResponse;
309
+ }
219
310
  let body = __normalize(__hostGlobal(["JSON"]).stringify(output));
220
311
  if (__requireBoolean(!__requireBoolean(__isString(body)))) {
221
312
  throw "Handler result is not JSON serializable";
222
313
  }
223
314
  closeScope(__contextGet("db"), true);
224
315
  let result = __normalize(__contextGet("response").result(body));
225
- let updated = __normalize(__contextGet("token").snapshot());
226
- updated.validatedAt = __normalize(claims.validatedAt);
316
+ let updated = this.#tokenClaims(__contextGet("token"), claims, __normalize(result.status) < 400);
227
317
  result.headers["x-lango-token"] = __normalize(this.#tokens.sign(updated));
228
318
  if (__requireBoolean(__requireBoolean(__normalize(this.#definition.settings.requestEvent)) && __requireBoolean(__includes("request", __normalize(this.#events))))) {
229
319
  return this.#audit(__normalize(__contextGet("request").id), result, __normalize(task.body), body, updated);
@@ -233,14 +323,18 @@ export class Runtime {
233
323
  } finally {
234
324
  __contextRestore(__contextScope);
235
325
  }
236
- })(__contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).catch(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2) => (error) => {
326
+ })(__contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).catch(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3) => (error) => {
237
327
  const __contextScope = [];
238
328
  try {
239
- __contextScope.push(__contextSet("request", __capturedContext0));
240
- __contextScope.push(__contextSet("log", __capturedContext1));
241
- __contextScope.push(__contextSet("db", __capturedContext2));
329
+ __contextScope.push(__contextSet("server", __capturedContext0));
330
+ __contextScope.push(__contextSet("request", __capturedContext1));
331
+ __contextScope.push(__contextSet("log", __capturedContext2));
332
+ __contextScope.push(__contextSet("db", __capturedContext3));
242
333
  error = __boundary(error);
243
334
  closeScope(__contextGet("db"), false);
335
+ if (__requireBoolean(__isKindof(error, HttpFailure))) {
336
+ return __normalize(error.result());
337
+ }
244
338
  if (__requireBoolean(__requireBoolean(error === "TokenExpired") || __requireBoolean(__requireBoolean(__isObject(error)) && __requireBoolean(__normalize(error.status) === 401)))) {
245
339
  return failure(401, "Unauthorized");
246
340
  }
@@ -250,7 +344,7 @@ export class Runtime {
250
344
  } finally {
251
345
  __contextRestore(__contextScope);
252
346
  }
253
- })(__contextGet("request"), __contextGet("log"), __contextGet("db")), [0], "closure")).finally(((__capturedContext0) => () => {
347
+ })(__contextGet("server"), __contextGet("request"), __contextGet("log"), __contextGet("db")), [0], "closure")).finally(((__capturedContext0) => () => {
254
348
  const __contextScope = [];
255
349
  try {
256
350
  __contextScope.push(__contextSet("db", __capturedContext0));
@@ -265,6 +359,19 @@ export class Runtime {
265
359
  __contextRestore(__contextScope);
266
360
  }
267
361
  }
362
+ #tokenClaims(token, claims, allowRenewal) {
363
+ __requireArity(arguments.length, [0, 1, 2], "tokenClaims");
364
+ token = __boundary(token);
365
+ claims = __boundary(claims);
366
+ allowRenewal = __boundary(allowRenewal);
367
+ let updated = __normalize(token.snapshot());
368
+ updated.validatedAt = __normalize(claims.validatedAt);
369
+ if (__requireBoolean(__requireBoolean(allowRenewal) && __requireBoolean(__normalize(token.renewalRequested())))) {
370
+ updated = __normalize(this.#tokens.renew(updated));
371
+ }
372
+ return updated;
373
+ return null;
374
+ }
268
375
  #event(name, input) {
269
376
  const __contextScope = [];
270
377
  try {
@@ -276,30 +383,32 @@ export class Runtime {
276
383
  }
277
384
  let handler = __normalize(this.#events[name]);
278
385
  __normalize(threads.parentPort.postMessage({ kind: "event", id: __normalize(__contextGet("request").id) }));
279
- return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4) => (ignored) => {
386
+ return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (ignored) => {
280
387
  const __contextScope = [];
281
388
  try {
282
- __contextScope.push(__contextSet("request", __capturedContext0));
283
- __contextScope.push(__contextSet("response", __capturedContext1));
284
- __contextScope.push(__contextSet("token", __capturedContext2));
285
- __contextScope.push(__contextSet("log", __capturedContext3));
286
- __contextScope.push(__contextSet("db", __capturedContext4));
389
+ __contextScope.push(__contextSet("server", __capturedContext0));
390
+ __contextScope.push(__contextSet("request", __capturedContext1));
391
+ __contextScope.push(__contextSet("response", __capturedContext2));
392
+ __contextScope.push(__contextSet("token", __capturedContext3));
393
+ __contextScope.push(__contextSet("log", __capturedContext4));
394
+ __contextScope.push(__contextSet("db", __capturedContext5));
287
395
  ignored = __boundary(ignored);
288
396
  return __call(handler, input);
289
397
  return null;
290
398
  } finally {
291
399
  __contextRestore(__contextScope);
292
400
  }
293
- })(__contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).finally(((__capturedContext0) => () => {
401
+ })(__contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("token"), __contextGet("log"), __contextGet("db")), [0], "closure")).finally(((__capturedContext0, __capturedContext1) => () => {
294
402
  const __contextScope = [];
295
403
  try {
296
- __contextScope.push(__contextSet("request", __capturedContext0));
404
+ __contextScope.push(__contextSet("server", __capturedContext0));
405
+ __contextScope.push(__contextSet("request", __capturedContext1));
297
406
  __normalize(threads.parentPort.postMessage({ kind: "handler", id: __normalize(__contextGet("request").id) }));
298
407
  return null;
299
408
  } finally {
300
409
  __contextRestore(__contextScope);
301
410
  }
302
- })(__contextGet("request")));
411
+ })(__contextGet("server"), __contextGet("request")));
303
412
  return null;
304
413
  } finally {
305
414
  __contextRestore(__contextScope);
@@ -314,21 +423,22 @@ export class Runtime {
314
423
  }
315
424
  let original = __normalize(__hostGlobal(["JSON"]).stringify(claims));
316
425
  __contextScope.push(__contextSet("token", new Token(claims, true)));
317
- return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4) => (ignored) => {
426
+ return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (ignored) => {
318
427
  const __contextScope = [];
319
428
  try {
320
429
  __contextScope.push(__contextSet("token", __capturedContext0));
321
430
  __contextScope.push(__contextSet("response", __capturedContext1));
322
- __contextScope.push(__contextSet("request", __capturedContext2));
323
- __contextScope.push(__contextSet("log", __capturedContext3));
324
- __contextScope.push(__contextSet("db", __capturedContext4));
431
+ __contextScope.push(__contextSet("server", __capturedContext2));
432
+ __contextScope.push(__contextSet("request", __capturedContext3));
433
+ __contextScope.push(__contextSet("log", __capturedContext4));
434
+ __contextScope.push(__contextSet("db", __capturedContext5));
325
435
  ignored = __boundary(ignored);
326
436
  return this.#event("validate", null);
327
437
  return null;
328
438
  } finally {
329
439
  __contextRestore(__contextScope);
330
440
  }
331
- })(__contextGet("token"), __contextGet("response"), __contextGet("request"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0) => (valid) => {
441
+ })(__contextGet("token"), __contextGet("response"), __contextGet("server"), __contextGet("request"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0) => (valid) => {
332
442
  const __contextScope = [];
333
443
  try {
334
444
  __contextScope.push(__contextSet("token", __capturedContext0));
@@ -368,21 +478,22 @@ export class Runtime {
368
478
  __contextScope.push(__contextSet("response", __normalize(__hostGlobal(["Object"]).freeze({ }))));
369
479
  let metadata = { input: input, output: output, status: __normalize(result.status) };
370
480
  __normalize(threads.parentPort.postMessage({ kind: "prepared", id: id, result: result }));
371
- return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4) => (ignored) => {
481
+ return __normalize(__hostGlobal(["Promise"]).resolve(null)).then(__withArity(((__capturedContext0, __capturedContext1, __capturedContext2, __capturedContext3, __capturedContext4, __capturedContext5) => (ignored) => {
372
482
  const __contextScope = [];
373
483
  try {
374
484
  __contextScope.push(__contextSet("token", __capturedContext0));
375
- __contextScope.push(__contextSet("request", __capturedContext1));
376
- __contextScope.push(__contextSet("response", __capturedContext2));
377
- __contextScope.push(__contextSet("log", __capturedContext3));
378
- __contextScope.push(__contextSet("db", __capturedContext4));
485
+ __contextScope.push(__contextSet("server", __capturedContext1));
486
+ __contextScope.push(__contextSet("request", __capturedContext2));
487
+ __contextScope.push(__contextSet("response", __capturedContext3));
488
+ __contextScope.push(__contextSet("log", __capturedContext4));
489
+ __contextScope.push(__contextSet("db", __capturedContext5));
379
490
  ignored = __boundary(ignored);
380
491
  return this.#event("request", __normalize(__hostGlobal(["Object"]).freeze(metadata)));
381
492
  return null;
382
493
  } finally {
383
494
  __contextRestore(__contextScope);
384
495
  }
385
- })(__contextGet("token"), __contextGet("request"), __contextGet("response"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0) => (ignored) => {
496
+ })(__contextGet("token"), __contextGet("server"), __contextGet("request"), __contextGet("response"), __contextGet("log"), __contextGet("db")), [0], "closure")).then(__withArity(((__capturedContext0) => (ignored) => {
386
497
  const __contextScope = [];
387
498
  try {
388
499
  __contextScope.push(__contextSet("db", __capturedContext0));
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","sources":["runtime.lango"],"sourcesContent":["import \"./database\"\n class Database\nimport js global Promise\nimport js global JSON\nimport js global Object\nimport js global Date\nimport js \"node:worker_threads\" as threads\nimport \"./token\"\n class Token\nimport \"./tokens\"\n class Tokens\nimport \"./response\"\n class Response\n\nexport class Runtime(definition)\n methods\n preload()\n handle(task)\n close()\n\nRuntime(definition)\n @definition = definition\n @routes = []\n @events = {}\n @tokens = new Tokens(definition.settings)\n @modules = {}\n @database = new Database(definition.settings.database, definition.settings.root)\n\nRuntime:preload()\n definitions = @definition.routes\n pending = @database.open()\n for definitions as route\n pending = prepareRoute(pending, route)\n events = @definition.events\n for events as name: target\n pending = prepareEvent(pending, name, target)\n return chain pending\n catch(error)\n close()\n throw error\n\nRuntime:close()\n @database.close()\n return null\n\nRuntime:prepareRoute(pending, route)\n return chain pending\n then(ignored)\n capture route\n return target(route)\n then(handler)\n capture route\n @routes.add({\n path: route.path\n auth: route.auth\n handler: handler\n })\n return null\n\nRuntime:prepareEvent(pending, name, spec)\n return chain pending\n then(ignored)\n capture spec\n return target(spec)\n then(handler)\n capture name\n @events[name] = handler\n return null\n\nRuntime:target(spec)\n file = spec.module\n if file in @modules\n return Promise/resolve(exported(@modules[file], spec.handler))\n return chain import_module(file)\n then(mod)\n capture file\n capture spec\n @modules[file] = mod\n return exported(mod, spec.handler)\n\nexported(mod, name)\n if !Object/hasOwn(mod, name) or !is_kindof(mod[name], Function)\n throw \"Handler is not exported: ${name}\"\n return mod[name]\n\nRuntime:match(path)\n best = null\n length = -1\n for @routes as route\n if route.path == path\n return route\n if route.path.endsWith(\"/*\")\n prefix = route.path.slice(0, -1)\n if path.startsWith(prefix) and prefix.length > length\n best = route\n length = prefix.length\n return best\n\nRuntime:handle(task)\n Object/freeze(task.request.headers)\n context request = Object/freeze(task.request)\n context response = new Response()\n context log\n fresh = request.headers.authorization == null\n claims = null\n try\n if fresh\n claims = @tokens.create()\n else\n claims = @tokens.read(request.headers.authorization)\n catch error\n return failure(401, \"Unauthorized\")\n route = match(request.path)\n if route == null\n return failure(404, \"RouteNotFound\")\n input = null\n try\n input = JSON/parse(task.body)\n if !is_object(input) or is_array(input)\n return failure(400, \"InputMustBeObject\")\n catch error\n return failure(400, \"InvalidJson\")\n context token = new Token(claims)\n context db = @database.scope()\n return chain Promise/resolve(null)\n then(ignored)\n capture request\n capture response\n capture token\n capture log\n capture db\n capture fresh\n capture input\n if fresh\n return event(\"register\", input)\n return validate()\n then(validatedAt)\n capture request\n capture response\n capture token\n capture log\n capture db\n capture route\n capture input\n capture claims\n capture fresh\n if !fresh and is_number(validatedAt)\n stampValidation(claims, validatedAt)\n if route.auth != \"anonymous\" and !token.hasAuth(route.auth)\n throw {\n status: 401\n error: \"Unauthorized\"\n }\n handler = route.handler\n return handler(input)\n then(output)\n capture request\n capture response\n capture token\n capture log\n capture db\n capture task\n capture claims\n body = JSON/stringify(output)\n if !is_string(body)\n throw \"Handler result is not JSON serializable\"\n closeScope(db, true)\n result = response.result(body)\n updated = token.snapshot()\n updated.validatedAt = claims.validatedAt\n result.headers[\"x-lango-token\"] = @tokens.sign(updated)\n if @definition.settings.requestEvent and \"request\" in @events\n return audit(request.id, result, task.body, body, updated)\n return result\n catch(error)\n capture request\n capture log\n capture db\n closeScope(db, false)\n if error == \"TokenExpired\" or (is_object(error) and error.status == 401)\n return failure(401, \"Unauthorized\")\n log.err(\"[${request.id}] Request failed\")\n return failure(500, \"InternalServerError\")\n finally\n capture db\n closeScope(db, false)\n\nRuntime:event(name, input)\n if !(name in @events)\n return null\n context request\n context response\n context token\n context log\n context db\n handler = @events[name]\n threads/parentPort/postMessage({\n kind: \"event\"\n id: request.id\n })\n return chain Promise/resolve(null)\n then(ignored)\n capture request\n capture response\n capture token\n capture log\n capture db\n capture handler\n capture input\n return handler(input)\n finally\n capture request\n capture threads\n threads/parentPort/postMessage({\n kind: \"handler\"\n id: request.id\n })\n\nRuntime:validate()\n context db\n context token\n context response\n context request\n context log\n claims = token.snapshot()\n if !(\"validate\" in @events) or Date/now() - claims.validatedAt < 1000\n return null\n original = JSON/stringify(claims)\n context token = new Token(claims, true)\n return chain Promise/resolve(null)\n then(ignored)\n capture token\n capture response\n capture request\n capture log\n capture db\n return event(\"validate\", null)\n then(valid)\n capture token\n capture original\n capture claims\n if !is_bool(valid)\n throw \"Validate must return boolean\"\n if !valid\n throw {\n status: 401\n error: \"Unauthorized\"\n }\n if JSON/stringify(token.snapshot()) != original\n throw \"Validate cannot change the token\"\n claims.validatedAt = Date/now()\n return claims.validatedAt\n\nRuntime:audit(id, result, input, output, claims)\n context db = @database.scope()\n context request\n context log\n context token = new Token(claims, true)\n context response = Object/freeze({})\n metadata = {\n input: input\n output: output\n status: result.status\n }\n threads/parentPort/postMessage({\n kind: \"prepared\"\n id: id\n result: result\n })\n return chain Promise/resolve(null)\n then(ignored)\n capture token\n capture request\n capture response\n capture log\n capture db\n capture metadata\n return event(\"request\", Object/freeze(metadata))\n then(ignored)\n capture db\n closeScope(db, true)\n return null\n catch(error)\n capture log\n capture db\n closeScope(db, false)\n log.err(\"Request event failed\")\n return null\n then(ignored)\n capture result\n return result\n finally\n capture db\n closeScope(db, false)\n\nfailure(status, code)\n headers = {\n \"content-type\": \"application/json; charset=utf-8\"\n \"cache-control\": \"no-store\"\n }\n if status == 401\n headers[\"www-authenticate\"] = \"Bearer\"\n return {\n status: status\n headers: headers\n body: JSON/stringify({\n error: code\n })\n }\n\nstampValidation(claims, validatedAt)\n claims.validatedAt = validatedAt\n return null\n\ncloseScope(db, strict)\n if db != null\n dirty = db.finish()\n if dirty and strict\n throw \"UnclosedTransaction\"\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA;;;;;;;;;;;AAuNA;;;;;;;;;;;;AAeA;;;;;;;;;AAIA;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"runtime.mjs","sources":["runtime.lango"],"sourcesContent":["import \"./route_pattern\"\n routePattern(path)\n matchPath(pattern, path)\n moreSpecific(candidate, current)\nimport js global decodeURIComponent\nimport \"./server_context\"\n class ServerContext\nimport \"./database\"\n class Database\nimport js global Promise\nimport js global JSON\nimport js global Object\nimport js global Date\nimport js \"node:worker_threads\" as threads\nimport \"./token\"\n class Token\nimport \"./tokens\"\n class Tokens\nimport \"./response\"\n class Response\nimport \"./http_failure\"\n class HttpFailure\n\nexport class Runtime(definition)\n methods\n preload()\n handle(task)\n close()\n\nRuntime(definition)\n @serverContext = new ServerContext(definition.routes)\n @definition = definition\n @routes = []\n @events = {}\n @tokens = new Tokens(definition.settings)\n @modules = {}\n @middlewares = Object/create(null)\n @database = new Database(definition.settings.database, definition.settings.root)\n\nRuntime:preload()\n definitions = @definition.routes\n pending = @database.open()\n if @definition.middlewares != null\n for @definition.middlewares as name: spec\n pending = prepareMiddleware(pending, name, spec)\n for definitions as route\n pending = prepareRoute(pending, route)\n events = @definition.events\n for events as name: target\n pending = prepareEvent(pending, name, target)\n return chain pending\n catch(error)\n close()\n throw error\n\nRuntime:close()\n @database.close()\n return null\n\nRuntime:prepareMiddleware(pending, name, spec)\n return chain pending\n then(ignored)\n capture spec\n return target(spec)\n then(handler)\n capture name\n capture spec\n @middlewares[name] = handler\n if spec.validate != null\n return target({\n module: spec.module\n handler: spec.validate\n })\n return null\n then(validator)\n if validator != null\n return validator(@serverContext.routes())\n return null\n\nRuntime:prepareRoute(pending, route)\n if route.kind == \"longpoll\"\n prepared = Object/assign({}, route)\n prepared.pattern = routePattern(route.path)\n @routes.add(prepared)\n return pending\n return chain pending\n then(ignored)\n capture route\n return target(route)\n then(handler)\n capture route\n middleware = null\n name = route.middleware\n if name != null\n if !Object/hasOwn(@middlewares, name)\n throw \"Middleware is not registered: ${name}\"\n middleware = @middlewares[name]\n @routes.add({\n path: route.path\n pattern: routePattern(route.path)\n auth: route.auth\n handler: handler\n middleware: middleware\n })\n return null\n\nRuntime:prepareEvent(pending, name, spec)\n return chain pending\n then(ignored)\n capture spec\n return target(spec)\n then(handler)\n capture name\n @events[name] = handler\n return null\n\nRuntime:target(spec)\n file = spec.module\n if file in @modules\n return Promise/resolve(exported(@modules[file], spec.handler))\n return chain import_module(file)\n then(mod)\n capture file\n capture spec\n @modules[file] = mod\n return exported(mod, spec.handler)\n\nexported(mod, name)\n if !Object/hasOwn(mod, name) or !is_kindof(mod[name], Function)\n throw \"Handler is not exported: ${name}\"\n return mod[name]\n\nRuntime:match(path)\n best = null\n parameters = null\n pattern = null\n for @routes as route\n captured = matchPath(route.pattern, path)\n if captured != null and moreSpecific(route.pattern, pattern)\n best = route\n parameters = captured\n pattern = route.pattern\n if best == null\n return null\n return {\n route: best\n parameters: parameters\n }\n\nRuntime:handle(task)\n Object/freeze(task.request.headers)\n context server = @serverContext\n context request = Object/freeze(task.request)\n context response = new Response()\n context log\n fresh = request.headers.authorization == null\n claims = null\n try\n if fresh\n claims = @tokens.create()\n else\n claims = @tokens.read(request.headers.authorization)\n catch error\n return failure(401, \"Unauthorized\")\n matched = match(request.path)\n if matched == null\n return failure(404, \"RouteNotFound\")\n route = matched.route\n input = null\n try\n input = JSON/parse(task.body)\n if !is_object(input) or is_array(input)\n return failure(400, \"InputMustBeObject\")\n catch error\n return failure(400, \"InvalidJson\")\n try\n for matched.parameters as name: value\n input[name] = decodeURIComponent(value)\n catch error\n return failure(400, \"InvalidPath\")\n context token = new Token(claims)\n context db = @database.scope()\n return chain Promise/resolve(null)\n then(ignored)\n capture server\n capture request\n capture response\n capture token\n capture log\n capture db\n capture fresh\n capture input\n if fresh\n return event(\"register\", input)\n return validate()\n then(validatedAt)\n capture server\n capture request\n capture response\n capture token\n capture log\n capture db\n capture route\n capture input\n capture claims\n capture fresh\n if !fresh and is_number(validatedAt)\n stampValidation(claims, validatedAt)\n if route.auth != \"anonymous\" and !token.hasAuth(route.auth)\n throw {\n status: 401\n error: \"Unauthorized\"\n }\n if route.kind == \"longpoll\"\n return null\n handler = route.handler\n middleware = route.middleware\n if middleware != null\n return middleware(handler, request.path, input)\n return handler(input)\n then(output)\n capture server\n capture request\n capture response\n capture token\n capture log\n capture db\n capture task\n capture claims\n if task.authorize == true\n closeScope(db, true)\n authorizedClaims = tokenClaims(token, claims, true)\n encoded = @tokens.sign(authorizedClaims)\n if task.pollResult == null\n return {\n status: 200\n authorization: encoded\n }\n if task.pollResult.resyncRequired\n response.status(409)\n pollBody = JSON/stringify(task.pollResult)\n pollResponse = response.result(pollBody)\n pollResponse.headers[\"x-lango-token\"] = encoded\n if @definition.settings.requestEvent and \"request\" in @events\n return audit(request.id, pollResponse, task.body, pollBody, authorizedClaims)\n return pollResponse\n body = JSON/stringify(output)\n if !is_string(body)\n throw \"Handler result is not JSON serializable\"\n closeScope(db, true)\n result = response.result(body)\n updated = tokenClaims(token, claims, result.status < 400)\n result.headers[\"x-lango-token\"] = @tokens.sign(updated)\n if @definition.settings.requestEvent and \"request\" in @events\n return audit(request.id, result, task.body, body, updated)\n return result\n catch(error)\n capture server\n capture request\n capture log\n capture db\n capture HttpFailure\n closeScope(db, false)\n if is_kindof(error, HttpFailure)\n return error.result()\n if error == \"TokenExpired\" or (is_object(error) and error.status == 401)\n return failure(401, \"Unauthorized\")\n log.err(\"[${request.id}] Request failed\")\n return failure(500, \"InternalServerError\")\n finally\n capture db\n closeScope(db, false)\n\nRuntime:tokenClaims(token, claims, allowRenewal)\n updated = token.snapshot()\n updated.validatedAt = claims.validatedAt\n if allowRenewal and token.renewalRequested()\n updated = @tokens.renew(updated)\n return updated\n\nRuntime:event(name, input)\n if !(name in @events)\n return null\n context server\n context request\n context response\n context token\n context log\n context db\n handler = @events[name]\n threads/parentPort/postMessage({\n kind: \"event\"\n id: request.id\n })\n return chain Promise/resolve(null)\n then(ignored)\n capture server\n capture request\n capture response\n capture token\n capture log\n capture db\n capture handler\n capture input\n return handler(input)\n finally\n capture server\n capture request\n capture threads\n threads/parentPort/postMessage({\n kind: \"handler\"\n id: request.id\n })\n\nRuntime:validate()\n context db\n context token\n context response\n context server\n context request\n context log\n claims = token.snapshot()\n if !(\"validate\" in @events) or Date/now() - claims.validatedAt < 1000\n return null\n original = JSON/stringify(claims)\n context token = new Token(claims, true)\n return chain Promise/resolve(null)\n then(ignored)\n capture token\n capture response\n capture server\n capture request\n capture log\n capture db\n return event(\"validate\", null)\n then(valid)\n capture token\n capture original\n capture claims\n if !is_bool(valid)\n throw \"Validate must return boolean\"\n if !valid\n throw {\n status: 401\n error: \"Unauthorized\"\n }\n if JSON/stringify(token.snapshot()) != original\n throw \"Validate cannot change the token\"\n claims.validatedAt = Date/now()\n return claims.validatedAt\n\nRuntime:audit(id, result, input, output, claims)\n context db = @database.scope()\n context server\n context request\n context log\n context token = new Token(claims, true)\n context response = Object/freeze({})\n metadata = {\n input: input\n output: output\n status: result.status\n }\n threads/parentPort/postMessage({\n kind: \"prepared\"\n id: id\n result: result\n })\n return chain Promise/resolve(null)\n then(ignored)\n capture token\n capture server\n capture request\n capture response\n capture log\n capture db\n capture metadata\n return event(\"request\", Object/freeze(metadata))\n then(ignored)\n capture db\n closeScope(db, true)\n return null\n catch(error)\n capture log\n capture db\n closeScope(db, false)\n log.err(\"Request event failed\")\n return null\n then(ignored)\n capture result\n return result\n finally\n capture db\n closeScope(db, false)\n\nfailure(status, code)\n headers = {\n \"content-type\": \"application/json; charset=utf-8\"\n \"cache-control\": \"no-store\"\n }\n if status == 401\n headers[\"www-authenticate\"] = \"Bearer\"\n return {\n status: status\n headers: headers\n body: JSON/stringify({\n error: code\n })\n }\n\nstampValidation(claims, validatedAt)\n claims.validatedAt = validatedAt\n return null\n\ncloseScope(db, strict)\n if db != null\n dirty = db.finish()\n if dirty and strict\n throw \"UnclosedTransaction\"\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA;;;;;;;;;;;AA4QA;;;;;;;;;;;;AAeA;;;;;;;;;AAIA;;;;;;;;;;;;;;;"}