@mojojs/core 0.12.5 → 0.15.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.
Files changed (53) hide show
  1. package/README.md +2 -1
  2. package/lib/app.js +2 -2
  3. package/lib/app.js.map +1 -1
  4. package/lib/cli/create-full-app.js +10 -10
  5. package/lib/cli/create-full-app.js.map +1 -1
  6. package/lib/cli/create-lite-app.js +4 -4
  7. package/lib/context.d.ts +4 -1
  8. package/lib/context.js +19 -0
  9. package/lib/context.js.map +1 -1
  10. package/lib/core.d.ts +1 -1
  11. package/lib/plugins/mt-engine.d.ts +2 -0
  12. package/lib/plugins/{ejs-engine.js → mt-engine.js} +9 -8
  13. package/lib/plugins/mt-engine.js.map +1 -0
  14. package/lib/plugins/view-helpers.js +17 -9
  15. package/lib/plugins/view-helpers.js.map +1 -1
  16. package/lib/renderer.js +1 -1
  17. package/lib/renderer.js.map +1 -1
  18. package/lib/session.d.ts +3 -2
  19. package/lib/session.js +12 -3
  20. package/lib/session.js.map +1 -1
  21. package/lib/types.d.ts +12 -1
  22. package/lib/user-agent/cookie-jar.d.ts +9 -0
  23. package/lib/user-agent/cookie-jar.js +27 -0
  24. package/lib/user-agent/cookie-jar.js.map +1 -0
  25. package/lib/user-agent/mock.js +1 -0
  26. package/lib/user-agent/mock.js.map +1 -1
  27. package/lib/user-agent/test.d.ts +1 -0
  28. package/lib/user-agent/test.js +5 -1
  29. package/lib/user-agent/test.js.map +1 -1
  30. package/lib/user-agent/transport/http.d.ts +12 -0
  31. package/lib/user-agent/transport/http.js +42 -0
  32. package/lib/user-agent/transport/http.js.map +1 -0
  33. package/lib/user-agent/transport/https.d.ts +11 -0
  34. package/lib/user-agent/transport/https.js +22 -0
  35. package/lib/user-agent/transport/https.js.map +1 -0
  36. package/lib/user-agent/transport/ws.d.ts +5 -0
  37. package/lib/user-agent/transport/ws.js +21 -0
  38. package/lib/user-agent/transport/ws.js.map +1 -0
  39. package/lib/user-agent.d.ts +67 -11
  40. package/lib/user-agent.js +78 -85
  41. package/lib/user-agent.js.map +1 -1
  42. package/lib/util.js +2 -2
  43. package/lib/util.js.map +1 -1
  44. package/package.json +3 -4
  45. package/vendor/README.md +1 -1
  46. package/vendor/views/mojo/{debug.html.ejs → debug.html.mt} +51 -51
  47. package/vendor/views/mojo/{exception.html.ejs → exception.html.mt} +1 -1
  48. package/vendor/views/mojo/{not-found.html.ejs → not-found.html.mt} +1 -1
  49. package/lib/plugins/ejs-engine.d.ts +0 -2
  50. package/lib/plugins/ejs-engine.js.map +0 -1
  51. package/lib/validator/schema.d.ts +0 -8
  52. package/lib/validator/schema.js +0 -19
  53. 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.5",
3
+ "version": "0.15.1",
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",
package/vendor/README.md CHANGED
@@ -4,7 +4,7 @@ This distribution includes a few files with different licenses that have been bu
4
4
 
5
5
  * Mojolicious Artwork
6
6
 
7
- Copyright (C) 2010-2021, Sebastian Riedel.
7
+ Copyright (C) 2010-2022, Sebastian Riedel.
8
8
 
9
9
  Licensed under the [CC-SA License, Version 4.0](http://creativecommons.org/licenses/by-sa/4.0).
10
10
 
@@ -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() {
@@ -61,7 +61,7 @@
61
61
  <div class="row flex-wrap">
62
62
  <main class="col-sm-12 col-md-8 col-lg-10 py-md-3 pl-md-5">
63
63
  <div class="row mojo-divider">
64
- <% if (ctx.stash.exception !== undefined) { %>
64
+ % if (ctx.stash.exception !== undefined) {
65
65
  <div class="alert alert-danger mojo-wide" role="alert">
66
66
  <h2>Server Error</h2>
67
67
  This application is in <b>development</b> mode and will show internal information to help you with
@@ -69,33 +69,33 @@
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) %>
73
- <% if (context !== null) { %>
72
+ % const context = await view.exceptionContext(exception);
73
+ % if (context !== null) {
74
74
  <div>
75
75
  <table class="mojo-wide">
76
- <% for (const line of context.source) { %>
77
- <% const extra = context.line === line.num ? ' mojo-important' : ''; %>
76
+ % for (const line of context.source) {
77
+ % const extra = context.line === line.num ? ' mojo-important' : '';
78
78
  <tr>
79
79
  <td class="text-right<%= extra %>"><%= line.num %></td>
80
80
  <td class="mojo-context mojo-wide<%= extra %>"><pre><code><%= line.code %></code></pre></td>
81
81
  </tr>
82
- <% } %>
82
+ % }
83
83
  </table>
84
84
  </div>
85
- <% } %>
85
+ % }
86
86
  </div>
87
87
  <div id="trace" class="mojo-box mojo-no-padding more mojo-no-top-border mojo-border-radius-bottom">
88
88
  <div id="frames" class="more">
89
89
  <table class="mojo-striped-grey mojo-wide">
90
- <% const lines = exception.stack.split('\n').filter(line => line.match(/^\s*at\ /)); %>
91
- <% const trace = lines.map(val => val.replace(/^\s+/, '')); %>
92
- <% for (const frame of trace) { %>
90
+ % const lines = exception.stack.split('\n').filter(line => line.match(/^\s*at\ /));
91
+ % const trace = lines.map(val => val.replace(/^\s+/, ''));
92
+ % for (const frame of trace) {
93
93
  <tr><td class="mojo-value"><pre><%= frame %></pre></td></tr>
94
- <% } %>
94
+ % }
95
95
  </table>
96
96
  </div>
97
97
  </div>
98
- <% } else { %>
98
+ % } else {
99
99
  <div class="alert alert-warning mojo-wide" role="alert">
100
100
  <h2>Page Not Found</h2>
101
101
  This application is in <b>development</b> mode and will show internal information to help you with
@@ -108,12 +108,12 @@
108
108
  for <code><%= ctx.req.path %></code>, maybe you need to add a new one?
109
109
  </p>
110
110
  </div>
111
- <% function walk (route, depth) { %>
112
- <% const pattern = route.pattern; %>
113
- <% let unparsed = pattern.unparsed || '/'; %>
114
- <% if (depth > 0) unparsed = `+${unparsed}`; %>
115
- <% pattern.match('/', {isEndpoint: route.isEndpoint}); %>
116
- <% const regex = pattern.regex.toString(); %>
111
+ % function walk (route, depth) {
112
+ % const pattern = route.pattern;
113
+ % let unparsed = pattern.unparsed || '/';
114
+ % if (depth > 0) unparsed = `+${unparsed}`;
115
+ % pattern.match('/', {isEndpoint: route.isEndpoint});
116
+ % const regex = pattern.regex.toString();
117
117
  <tr data-bs-toggle="tooltip" data-bs-placement="left" data-bs-html="true"
118
118
  title="<b>Regex:</b> <code><%= regex %></code>">
119
119
  <td class="mojo-value">
@@ -123,17 +123,17 @@
123
123
  <pre><%= route.methods.join(', ').toUpperCase() || '*' %></pre>
124
124
  </td>
125
125
  <td class="mojo-value">
126
- <% if (route.customName !== undefined) { %>
126
+ % if (route.customName !== undefined) {
127
127
  <span class="badge bg-success"><%= route.customName %></span>
128
- <% } else if (route.defaultName !== undefined) { %>
128
+ % } else if (route.defaultName !== undefined) {
129
129
  <span class="badge bg-secondary"><%= route.defaultName %></span>
130
- <% } %>
130
+ % }
131
131
  </td>
132
132
  </tr>
133
- <% depth++ %>
134
- <%= route.children.map(child => walk(child, depth)).join('') %>
135
- <% depth-- %>
136
- <% } %>
133
+ % depth++;
134
+ %= route.children.map(child => walk(child, depth)).join('')
135
+ % depth--;
136
+ % }
137
137
  <table class="mojo-striped-light mojo-wide">
138
138
  <thead>
139
139
  <tr>
@@ -142,43 +142,43 @@
142
142
  <th>Name</th>
143
143
  </tr>
144
144
  </thead>
145
- <%= ctx.app.router.children.map(child => walk(child, 0)).join('') %>
145
+ %= ctx.app.router.children.map(child => walk(child, 0)).join('')
146
146
  </table>
147
147
  </div>
148
- <% } %>
148
+ % }
149
149
  </div>
150
150
  <div class="row mojo-divider">
151
151
  <div id="request" class="mojo-box mojo-no-padding mojo-border-radius-both">
152
- <% function keyValue (key, value) { %>
152
+ % function keyValue (key, value) {
153
153
  <tr>
154
154
  <td class="mojo-key text-right"><%= key %>:</td>
155
155
  <td class="mojo-value"><pre><%= value %></pre></td>
156
156
  </tr>
157
- <% } %>
157
+ % }
158
158
  <table class="mojo-striped mojo-fixed-table mojo-wide">
159
- <%= keyValue('Request ID', ctx.req.requestId) %>
160
- <%= keyValue('Method', ctx.req.method) %>
161
- <%= keyValue('Path', ctx.req.path) %>
162
- <%= keyValue('Base URL', ctx.req.baseUrl) %>
163
- <%= keyValue('Parameters', ctx.inspect((await ctx.params()).toObject())) %>
164
- <%= keyValue('Stash', ctx.inspect(ctx.stash) ) %>
165
- <% const rawHeaders = ctx.req.raw.rawHeaders %>
166
- <% for (let i = 0; i < rawHeaders.length; i += 2) { %>
167
- <%= keyValue(rawHeaders[i], rawHeaders[i + 1]) %>
168
- <% } %>
159
+ %= keyValue('Request ID', ctx.req.requestId)
160
+ %= keyValue('Method', ctx.req.method)
161
+ %= keyValue('Path', ctx.req.path)
162
+ %= keyValue('Base URL', ctx.req.baseUrl)
163
+ %= keyValue('Parameters', ctx.inspect((await ctx.params()).toObject()))
164
+ %= keyValue('Stash', ctx.inspect(ctx.stash) )
165
+ % const rawHeaders = ctx.req.raw.rawHeaders;
166
+ % for (let i = 0; i < rawHeaders.length; i += 2) {
167
+ %= keyValue(rawHeaders[i], rawHeaders[i + 1])
168
+ % }
169
169
  </table>
170
170
  </div>
171
171
  </div>
172
172
  <div class="row">
173
- <% if (ctx.app.log.history.length > 0) { %>
174
- <% const log = ctx.app.log.history.map(view.stringFormatter).join('') %>
173
+ % if (ctx.app.log.history.length > 0) {
174
+ % const log = ctx.app.log.history.map(view.stringFormatter).join('');
175
175
  <pre class="mojo-terminal"><code class="nohighlight"><%= log %></code></pre>
176
- <% } else { %>
176
+ % } else {
177
177
  <div class="alert alert-warning mojo-wide" role="alert">
178
178
  The application log appears to be empty, perhaps the log level <b><%= ctx.app.log.level %></b> is too
179
179
  high? Try lowering it to <b>trace</b> for framework specific information.
180
180
  </div>
181
- <% } %>
181
+ % }
182
182
  </div>
183
183
  </main>
184
184
  </div>
@@ -190,7 +190,7 @@
190
190
  <b>Free</b> and <b>Open Source</b>.
191
191
  </div>
192
192
  <div class="col-sm align-self-center text-center mojo-copy">
193
- <i class="far fa-copyright"></i> 2021 Sebastian Riedel and the
193
+ <i class="far fa-copyright"></i> 2021-2022 Sebastian Riedel and the
194
194
  <a href="https://github.com/mojolicious/mojo.js/AUTHORS">mojo.js contributors</a>.
195
195
  </div>
196
196
  <div class="col-sm align-self-center text-center mojo-social">
@@ -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;IAAf;QACE,UAAK,GAAuC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IA0B3D,CAAC;IAxBC,KAAK,CAAC,MAAM,CAAC,GAAgB,EAAE,OAAsB;QACnD,IAAI,QAAQ,CAAC;QAEb,IAA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AC3F,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"}