@mojojs/core 0.12.4 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +11 -10
  2. package/lib/app.js +2 -2
  3. package/lib/app.js.map +1 -1
  4. package/lib/cli/create-full-app.js +7 -7
  5. package/lib/cli/create-full-app.js.map +1 -1
  6. package/lib/context.d.ts +4 -1
  7. package/lib/context.js +19 -0
  8. package/lib/context.js.map +1 -1
  9. package/lib/plugins/mt-engine.d.ts +2 -0
  10. package/lib/plugins/{ejs-engine.js → mt-engine.js} +9 -8
  11. package/lib/plugins/mt-engine.js.map +1 -0
  12. package/lib/plugins/view-helpers.js +7 -9
  13. package/lib/plugins/view-helpers.js.map +1 -1
  14. package/lib/renderer.js +1 -1
  15. package/lib/renderer.js.map +1 -1
  16. package/lib/session.d.ts +3 -2
  17. package/lib/session.js +12 -3
  18. package/lib/session.js.map +1 -1
  19. package/lib/types.d.ts +12 -1
  20. package/lib/user-agent/cookie-jar.d.ts +9 -0
  21. package/lib/user-agent/cookie-jar.js +27 -0
  22. package/lib/user-agent/cookie-jar.js.map +1 -0
  23. package/lib/user-agent/mock.js +1 -0
  24. package/lib/user-agent/mock.js.map +1 -1
  25. package/lib/user-agent/test.d.ts +1 -0
  26. package/lib/user-agent/test.js +5 -1
  27. package/lib/user-agent/test.js.map +1 -1
  28. package/lib/user-agent/transport/http.d.ts +12 -0
  29. package/lib/user-agent/transport/http.js +42 -0
  30. package/lib/user-agent/transport/http.js.map +1 -0
  31. package/lib/user-agent/transport/https.d.ts +11 -0
  32. package/lib/user-agent/transport/https.js +22 -0
  33. package/lib/user-agent/transport/https.js.map +1 -0
  34. package/lib/user-agent/transport/ws.d.ts +5 -0
  35. package/lib/user-agent/transport/ws.js +21 -0
  36. package/lib/user-agent/transport/ws.js.map +1 -0
  37. package/lib/user-agent.d.ts +67 -11
  38. package/lib/user-agent.js +78 -85
  39. package/lib/user-agent.js.map +1 -1
  40. package/lib/util.js +2 -2
  41. package/lib/util.js.map +1 -1
  42. package/package.json +3 -4
  43. package/vendor/views/mojo/{debug.html.ejs → debug.html.mt} +12 -12
  44. package/vendor/views/mojo/{exception.html.ejs → exception.html.mt} +1 -1
  45. package/vendor/views/mojo/{not-found.html.ejs → not-found.html.mt} +1 -1
  46. package/lib/plugins/ejs-engine.d.ts +0 -2
  47. package/lib/plugins/ejs-engine.js.map +0 -1
  48. package/lib/validator/schema.d.ts +0 -8
  49. package/lib/validator/schema.js +0 -19
  50. package/lib/validator/schema.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojojs/core",
3
- "version": "0.12.4",
3
+ "version": "0.15.0",
4
4
  "description": "Real-time web framework",
5
5
  "keywords": [
6
6
  "web",
@@ -51,7 +51,6 @@
51
51
  "devDependencies": {
52
52
  "@istanbuljs/esm-loader-hook": "^0.1.2",
53
53
  "@types/busboy": "^0.3.1",
54
- "@types/ejs": "^3.0.6",
55
54
  "@types/js-yaml": "^4.0.3",
56
55
  "@types/lru-cache": "^5.1.0",
57
56
  "@types/mime-types": "^2.1.0",
@@ -77,12 +76,12 @@
77
76
  "node": ">= 16"
78
77
  },
79
78
  "dependencies": {
80
- "@mojojs/dom": "^1.0.1",
79
+ "@mojojs/dom": "^1.1.2",
81
80
  "@mojojs/path": "^1.1.2",
81
+ "@mojojs/template": "^1.0.0",
82
82
  "ajv": "^8.5.0",
83
83
  "busboy": "^1.0.0",
84
84
  "chalk": "^5.0.0",
85
- "ejs": "^3.1.6",
86
85
  "form-data": "^4.0.0",
87
86
  "js-yaml": "^4.1.0",
88
87
  "lru-cache": "^6.0.0",
@@ -3,13 +3,13 @@
3
3
  <html>
4
4
  <head>
5
5
  <title>Debug</title>
6
- <%- ctx.mojoFaviconTag() %>
7
- <%- ctx.scriptTag('/mojo/bootstrap/bootstrap.bundle.min.js') %>
8
- <%- ctx.scriptTag('/mojo/highlight.js/highlight.pack.js') %>
9
- <%- ctx.styleTag('/mojo/bootstrap/bootstrap.min.css') %>
10
- <%- ctx.styleTag('/mojo/highlight.js/highlight-mojo-dark.css') %>
11
- <%- ctx.styleTag('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css') %>
12
- <%- ctx.styleTag('/mojo/mojo.css') %>
6
+ <%= ctx.mojoFaviconTag() %>
7
+ <%= ctx.scriptTag('/mojo/bootstrap/bootstrap.bundle.min.js') %>
8
+ <%= ctx.scriptTag('/mojo/highlight.js/highlight.pack.js') %>
9
+ <%= ctx.styleTag('/mojo/bootstrap/bootstrap.min.css') %>
10
+ <%= ctx.styleTag('/mojo/highlight.js/highlight-mojo-dark.css') %>
11
+ <%= ctx.styleTag('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css') %>
12
+ <%= ctx.styleTag('/mojo/mojo.css') %>
13
13
  <script>
14
14
  hljs.initHighlightingOnLoad();
15
15
  window.onload = function() {
@@ -69,7 +69,7 @@
69
69
  </div>
70
70
  <div id="showcase" class="mojo-box mojo-code mojo-no-bottom-border mojo-no-top-border mojo-border-radius-top">
71
71
  <pre id="error" class="mojo-error"><%= exception %></pre>
72
- <% const context = await view.exceptionContext(exception) %>
72
+ <% const context = await view.exceptionContext(exception); %>
73
73
  <% if (context !== null) { %>
74
74
  <div>
75
75
  <table class="mojo-wide">
@@ -130,9 +130,9 @@
130
130
  <% } %>
131
131
  </td>
132
132
  </tr>
133
- <% depth++ %>
133
+ <% depth++; %>
134
134
  <%= route.children.map(child => walk(child, depth)).join('') %>
135
- <% depth-- %>
135
+ <% depth--; %>
136
136
  <% } %>
137
137
  <table class="mojo-striped-light mojo-wide">
138
138
  <thead>
@@ -162,7 +162,7 @@
162
162
  <%= keyValue('Base URL', ctx.req.baseUrl) %>
163
163
  <%= keyValue('Parameters', ctx.inspect((await ctx.params()).toObject())) %>
164
164
  <%= keyValue('Stash', ctx.inspect(ctx.stash) ) %>
165
- <% const rawHeaders = ctx.req.raw.rawHeaders %>
165
+ <% const rawHeaders = ctx.req.raw.rawHeaders; %>
166
166
  <% for (let i = 0; i < rawHeaders.length; i += 2) { %>
167
167
  <%= keyValue(rawHeaders[i], rawHeaders[i + 1]) %>
168
168
  <% } %>
@@ -171,7 +171,7 @@
171
171
  </div>
172
172
  <div class="row">
173
173
  <% if (ctx.app.log.history.length > 0) { %>
174
- <% const log = ctx.app.log.history.map(view.stringFormatter).join('') %>
174
+ <% const log = ctx.app.log.history.map(view.stringFormatter).join(''); %>
175
175
  <pre class="mojo-terminal"><code class="nohighlight"><%= log %></code></pre>
176
176
  <% } else { %>
177
177
  <div class="alert alert-warning mojo-wide" role="alert">
@@ -3,7 +3,7 @@
3
3
  <html>
4
4
  <head>
5
5
  <title>Server Error</title>
6
- <%- ctx.mojoFaviconTag() %>
6
+ <%= ctx.mojoFaviconTag() %>
7
7
  <style>
8
8
  body {
9
9
  background-color: #caecf6;
@@ -3,7 +3,7 @@
3
3
  <html>
4
4
  <head>
5
5
  <title>Page Not Found</title>
6
- <%- ctx.mojoFaviconTag() %>
6
+ <%= ctx.mojoFaviconTag() %>
7
7
  <style>
8
8
  a img {
9
9
  border: 0;
@@ -1,2 +0,0 @@
1
- import type { App } from '../app.js';
2
- export default function ejsEnginePlugin(app: App): void;
@@ -1 +0,0 @@
1
- {"version":3,"file":"ejs-engine.js","sourceRoot":"","sources":["../../src/plugins/ejs-engine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;AAClC,OAAO,IAAI,MAAM,cAAc,CAAC;AAChC,OAAO,EAAC,OAAO,EAAC,MAAM,KAAK,CAAC;AAC5B,OAAO,GAAG,MAAM,WAAW,CAAC;AAE5B,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,GAAQ;IAC9C,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,SAAS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AC,IAAI,CAAC,MAAM,QAAQ,CAAC,EAAC,GAAG,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC;IAC3F,CAAC;CACF"}
@@ -1,8 +0,0 @@
1
- import type { JSONValue } from '../types.js';
2
- import type { ValidateFunction } from 'ajv';
3
- import { ValidatorResult } from './result.js';
4
- export declare class ValidatorSchema {
5
- _validate: ValidateFunction;
6
- constructor(validate: ValidateFunction);
7
- validate(data: JSONValue): ValidatorResult;
8
- }
@@ -1,19 +0,0 @@
1
- import { ValidatorResult } from './result.js';
2
- export class ValidatorSchema {
3
- constructor(validate) {
4
- this._validate = validate;
5
- }
6
- validate(data) {
7
- const validate = this._validate;
8
- const isValid = validate(data);
9
- const errors = [];
10
- const results = validate.errors;
11
- if (results != null) {
12
- for (const error of results) {
13
- errors.push({ instancePath: error.instancePath, schemaPath: error.schemaPath, message: error.message });
14
- }
15
- }
16
- return new ValidatorResult(isValid, errors);
17
- }
18
- }
19
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/validator/schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAE5C,MAAM,OAAO,eAAe;IAG1B,YAAY,QAA0B;QACpC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED,QAAQ,CAAC,IAAe;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE/B,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC;QAChC,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;gBAC3B,MAAM,CAAC,IAAI,CAAC,EAAC,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAC,CAAC,CAAC;aACvG;SACF;QAED,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;CACF"}